@dialpad/dialtone-vue 4.4.1 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/dist/{Datepicker-CGFa1nGm.js → Datepicker-D-Lgvthq.js} +17 -5
  2. package/dist/Datepicker-D-Lgvthq.js.map +1 -0
  3. package/dist/Datepicker-DmKOuf5y.cjs +2 -0
  4. package/dist/Datepicker-DmKOuf5y.cjs.map +1 -0
  5. package/dist/EmojiPicker-CXFd-iVj.cjs +2 -0
  6. package/dist/EmojiPicker-CXFd-iVj.cjs.map +1 -0
  7. package/dist/{EmojiPicker-BllVwJf4.js → EmojiPicker-D46lLRMp.js} +75 -41
  8. package/dist/EmojiPicker-D46lLRMp.js.map +1 -0
  9. package/dist/{ForceLinkify-bO3ug94b.js → ForceLinkify-DuAo3TMB.js} +1 -1
  10. package/dist/{ForceLinkify-bO3ug94b.js.map → ForceLinkify-DuAo3TMB.js.map} +1 -1
  11. package/dist/{ForceLinkify-CI1tkUBf.cjs → ForceLinkify-kQ_kWKVm.cjs} +1 -1
  12. package/dist/{ForceLinkify-CI1tkUBf.cjs.map → ForceLinkify-kQ_kWKVm.cjs.map} +1 -1
  13. package/dist/{MarkdownRenderer-B6oyniLV.cjs → MarkdownRenderer-C5wdjC5_.cjs} +1 -1
  14. package/dist/{MarkdownRenderer-B6oyniLV.cjs.map → MarkdownRenderer-C5wdjC5_.cjs.map} +1 -1
  15. package/dist/{MarkdownRenderer-D-EV50_M.js → MarkdownRenderer-eMwmPygx.js} +1 -1
  16. package/dist/{MarkdownRenderer-D-EV50_M.js.map → MarkdownRenderer-eMwmPygx.js.map} +1 -1
  17. package/dist/RichTextEditor-7eY8gy9u.cjs +11 -0
  18. package/dist/RichTextEditor-7eY8gy9u.cjs.map +1 -0
  19. package/dist/{RichTextEditor-Cz2VXb7-.js → RichTextEditor-DaOHmXD_.js} +362 -1254
  20. package/dist/RichTextEditor-DaOHmXD_.js.map +1 -0
  21. package/dist/{Scroller-JDoDYC5V.js → Scroller-B1xwv6TG.js} +1 -1
  22. package/dist/{Scroller-JDoDYC5V.js.map → Scroller-B1xwv6TG.js.map} +1 -1
  23. package/dist/{Scroller-Du2kJsTR.cjs → Scroller-pAU8UWIH.cjs} +1 -1
  24. package/dist/{Scroller-Du2kJsTR.cjs.map → Scroller-pAU8UWIH.cjs.map} +1 -1
  25. package/dist/Slider-D2cDYZcJ.cjs +2 -0
  26. package/dist/Slider-D2cDYZcJ.cjs.map +1 -0
  27. package/dist/Slider-Du45PVLU.js +1188 -0
  28. package/dist/Slider-Du45PVLU.js.map +1 -0
  29. package/dist/{TextList-D40u4g4T.js → TextList-7RwngSie.js} +1 -1
  30. package/dist/{TextList-D40u4g4T.js.map → TextList-7RwngSie.js.map} +1 -1
  31. package/dist/{TextList-rS1MQdPB.cjs → TextList-CLUdOdlp.cjs} +1 -1
  32. package/dist/{TextList-rS1MQdPB.cjs.map → TextList-CLUdOdlp.cjs.map} +1 -1
  33. package/dist/{TextListItem-CF6DzdvT.cjs → TextListItem-B-bhrqik.cjs} +1 -1
  34. package/dist/{TextListItem-CF6DzdvT.cjs.map → TextListItem-B-bhrqik.cjs.map} +1 -1
  35. package/dist/{TextListItem-PHgDIWV1.js → TextListItem-D0UmIR_q.js} +1 -1
  36. package/dist/{TextListItem-PHgDIWV1.js.map → TextListItem-D0UmIR_q.js.map} +1 -1
  37. package/dist/{Toast-CN9x3jKH.cjs → Toast-57Ts-hX9.cjs} +1 -1
  38. package/dist/{Toast-CN9x3jKH.cjs.map → Toast-57Ts-hX9.cjs.map} +1 -1
  39. package/dist/{Toast-DVUE2_fV.js → Toast-BNhGD6l8.js} +1 -1
  40. package/dist/{Toast-DVUE2_fV.js.map → Toast-BNhGD6l8.js.map} +1 -1
  41. package/dist/component-documentation.json +1 -1
  42. package/dist/components/ButtonGroup/ButtonGroup.vue.d.ts.map +1 -1
  43. package/dist/components/Codeblock/Codeblock.vue.d.ts.map +1 -1
  44. package/dist/components/Datepicker/Datepicker.vue.d.ts.map +1 -1
  45. package/dist/components/Datepicker/Modules/Calendar.vue.d.ts.map +1 -1
  46. package/dist/components/Datepicker/Modules/MonthYearPicker.vue.d.ts.map +1 -1
  47. package/dist/components/DescriptionList/DescriptionList.vue.d.ts.map +1 -1
  48. package/dist/components/Emoji/Emoji.vue.d.ts.map +1 -1
  49. package/dist/components/EmojiPicker/EmojiPicker.vue.d.ts.map +1 -1
  50. package/dist/components/EmojiPicker/Modules/EmojiDescription.vue.d.ts.map +1 -1
  51. package/dist/components/EmojiPicker/Modules/EmojiSearch.vue.d.ts.map +1 -1
  52. package/dist/components/EmojiPicker/Modules/EmojiSelector.vue.d.ts.map +1 -1
  53. package/dist/components/EmojiPicker/Modules/EmojiSkinSelector.vue.d.ts.map +1 -1
  54. package/dist/components/EmojiPicker/Modules/EmojiTabset.vue.d.ts.map +1 -1
  55. package/dist/components/EmptyState/EmptyState.vue.d.ts.map +1 -1
  56. package/dist/components/KeyboardShortcut/KeyboardShortcut.vue.d.ts.map +1 -1
  57. package/dist/components/LazyShow/LazyShow.vue.d.ts.map +1 -1
  58. package/dist/components/ModeIsland/ModeIsland.vue.d.ts.map +1 -1
  59. package/dist/components/MotionText/MotionText.vue.d.ts.map +1 -1
  60. package/dist/components/MotionText/MotionTextConstants.d.ts +72 -0
  61. package/dist/components/MotionText/MotionTextConstants.d.ts.map +1 -1
  62. package/dist/components/MotionText/index.d.ts +1 -1
  63. package/dist/components/MotionText/utils.d.ts +9 -0
  64. package/dist/components/MotionText/utils.d.ts.map +1 -0
  65. package/dist/components/Skeleton/Skeleton.vue.d.ts.map +1 -1
  66. package/dist/components/Slider/Composables/UseSliderCollisionAvoidance.d.ts +25 -0
  67. package/dist/components/Slider/Composables/UseSliderCollisionAvoidance.d.ts.map +1 -0
  68. package/dist/components/Slider/Composables/UseSliderDevWarnings.d.ts +5 -0
  69. package/dist/components/Slider/Composables/UseSliderDevWarnings.d.ts.map +1 -0
  70. package/dist/components/Slider/Composables/UseSliderDirection.d.ts +4 -0
  71. package/dist/components/Slider/Composables/UseSliderDirection.d.ts.map +1 -0
  72. package/dist/components/Slider/Composables/UseSliderGeometry.d.ts +88 -0
  73. package/dist/components/Slider/Composables/UseSliderGeometry.d.ts.map +1 -0
  74. package/dist/components/Slider/Composables/UseSliderInteraction.d.ts +33 -0
  75. package/dist/components/Slider/Composables/UseSliderInteraction.d.ts.map +1 -0
  76. package/dist/components/Slider/Composables/UseSliderMagneticSnap.d.ts +8 -0
  77. package/dist/components/Slider/Composables/UseSliderMagneticSnap.d.ts.map +1 -0
  78. package/dist/components/Slider/Composables/UseSliderMarksAndTicks.d.ts +13 -0
  79. package/dist/components/Slider/Composables/UseSliderMarksAndTicks.d.ts.map +1 -0
  80. package/dist/components/Slider/Composables/UseSliderTooltipReadout.d.ts +10 -0
  81. package/dist/components/Slider/Composables/UseSliderTooltipReadout.d.ts.map +1 -0
  82. package/dist/components/Slider/Composables/UseSliderValue.d.ts +16 -0
  83. package/dist/components/Slider/Composables/UseSliderValue.d.ts.map +1 -0
  84. package/dist/components/Slider/Slider.vue.d.ts +304 -0
  85. package/dist/components/Slider/Slider.vue.d.ts.map +1 -0
  86. package/dist/components/Slider/SliderConstants.d.ts +7 -0
  87. package/dist/components/Slider/SliderConstants.d.ts.map +1 -0
  88. package/dist/components/Slider/index.d.ts +3 -0
  89. package/dist/components/Slider/index.d.ts.map +1 -0
  90. package/dist/components/Slider/utils.d.ts +8 -0
  91. package/dist/components/Slider/utils.d.ts.map +1 -0
  92. package/dist/dialtone-vue.cjs +1 -1
  93. package/dist/dialtone-vue.js +26 -24
  94. package/dist/floating-ui.dom-D2zQ_96p.cjs +2 -0
  95. package/dist/floating-ui.dom-D2zQ_96p.cjs.map +1 -0
  96. package/dist/floating-ui.dom-j5GI2lJG.js +963 -0
  97. package/dist/floating-ui.dom-j5GI2lJG.js.map +1 -0
  98. package/dist/index.d.ts +1 -0
  99. package/dist/lib/button-group/button-group.cjs +1 -1
  100. package/dist/lib/button-group/button-group.cjs.map +1 -1
  101. package/dist/lib/button-group/button-group.js +2 -1
  102. package/dist/lib/button-group/button-group.js.map +1 -1
  103. package/dist/lib/codeblock/codeblock.cjs +1 -1
  104. package/dist/lib/codeblock/codeblock.cjs.map +1 -1
  105. package/dist/lib/codeblock/codeblock.js +7 -1
  106. package/dist/lib/codeblock/codeblock.js.map +1 -1
  107. package/dist/lib/datepicker/datepicker.cjs +1 -1
  108. package/dist/lib/datepicker/datepicker.js +1 -1
  109. package/dist/lib/datepicker/index.cjs +1 -1
  110. package/dist/lib/datepicker/index.js +1 -1
  111. package/dist/lib/description-list/description-list.cjs +1 -1
  112. package/dist/lib/description-list/description-list.cjs.map +1 -1
  113. package/dist/lib/description-list/description-list.js +14 -5
  114. package/dist/lib/description-list/description-list.js.map +1 -1
  115. package/dist/lib/emoji/emoji.cjs +1 -1
  116. package/dist/lib/emoji/emoji.cjs.map +1 -1
  117. package/dist/lib/emoji/emoji.js +5 -1
  118. package/dist/lib/emoji/emoji.js.map +1 -1
  119. package/dist/lib/emoji-picker/emoji-picker.cjs +1 -1
  120. package/dist/lib/emoji-picker/emoji-picker.js +1 -1
  121. package/dist/lib/emoji-picker/index.cjs +1 -1
  122. package/dist/lib/emoji-picker/index.js +1 -1
  123. package/dist/lib/empty-state/empty-state.cjs +1 -1
  124. package/dist/lib/empty-state/empty-state.cjs.map +1 -1
  125. package/dist/lib/empty-state/empty-state.js +6 -3
  126. package/dist/lib/empty-state/empty-state.js.map +1 -1
  127. package/dist/lib/keyboard-shortcut/keyboard-shortcut.cjs +1 -1
  128. package/dist/lib/keyboard-shortcut/keyboard-shortcut.cjs.map +1 -1
  129. package/dist/lib/keyboard-shortcut/keyboard-shortcut.js +8 -2
  130. package/dist/lib/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
  131. package/dist/lib/lazy-show/lazy-show.cjs +1 -1
  132. package/dist/lib/lazy-show/lazy-show.cjs.map +1 -1
  133. package/dist/lib/lazy-show/lazy-show.js +10 -10
  134. package/dist/lib/lazy-show/lazy-show.js.map +1 -1
  135. package/dist/lib/mode-island/mode-island.cjs +1 -1
  136. package/dist/lib/mode-island/mode-island.cjs.map +1 -1
  137. package/dist/lib/mode-island/mode-island.js +1 -0
  138. package/dist/lib/mode-island/mode-island.js.map +1 -1
  139. package/dist/lib/motion-text/index.cjs +1 -1
  140. package/dist/lib/motion-text/index.js +3 -3
  141. package/dist/lib/motion-text/motion-text-constants.cjs +1 -1
  142. package/dist/lib/motion-text/motion-text-constants.cjs.map +1 -1
  143. package/dist/lib/motion-text/motion-text-constants.js +64 -2
  144. package/dist/lib/motion-text/motion-text-constants.js.map +1 -1
  145. package/dist/lib/motion-text/motion-text.cjs +1 -1
  146. package/dist/lib/motion-text/motion-text.cjs.map +1 -1
  147. package/dist/lib/motion-text/motion-text.js +186 -146
  148. package/dist/lib/motion-text/motion-text.js.map +1 -1
  149. package/dist/lib/motion-text/utils.cjs +2 -0
  150. package/dist/lib/motion-text/utils.cjs.map +1 -0
  151. package/dist/lib/motion-text/utils.js +24 -0
  152. package/dist/lib/motion-text/utils.js.map +1 -0
  153. package/dist/lib/rich-text-editor/force-linkify.cjs +1 -1
  154. package/dist/lib/rich-text-editor/force-linkify.js +1 -1
  155. package/dist/lib/rich-text-editor/index.cjs +1 -1
  156. package/dist/lib/rich-text-editor/index.js +1 -1
  157. package/dist/lib/rich-text-editor/markdown-renderer.cjs +1 -1
  158. package/dist/lib/rich-text-editor/markdown-renderer.js +1 -1
  159. package/dist/lib/rich-text-editor/rich-text-editor.cjs +1 -1
  160. package/dist/lib/rich-text-editor/rich-text-editor.js +1 -1
  161. package/dist/lib/scroller/index.cjs +1 -1
  162. package/dist/lib/scroller/index.js +1 -1
  163. package/dist/lib/scroller/scroller.cjs +1 -1
  164. package/dist/lib/scroller/scroller.js +1 -1
  165. package/dist/lib/skeleton/skeleton.cjs +1 -1
  166. package/dist/lib/skeleton/skeleton.cjs.map +1 -1
  167. package/dist/lib/skeleton/skeleton.js +1 -0
  168. package/dist/lib/skeleton/skeleton.js.map +1 -1
  169. package/dist/lib/slider/index.cjs +1 -0
  170. package/dist/lib/slider/index.js +2 -0
  171. package/dist/lib/slider/slider.cjs +1 -0
  172. package/dist/lib/slider/slider.js +2 -0
  173. package/dist/lib/slider/utils.cjs +2 -0
  174. package/dist/lib/slider/utils.cjs.map +1 -0
  175. package/dist/lib/slider/utils.js +32 -0
  176. package/dist/lib/slider/utils.js.map +1 -0
  177. package/dist/lib/text-list/index.cjs +1 -1
  178. package/dist/lib/text-list/index.js +2 -2
  179. package/dist/lib/text-list/text-list-item.cjs +1 -1
  180. package/dist/lib/text-list/text-list-item.js +1 -1
  181. package/dist/lib/text-list/text-list.cjs +1 -1
  182. package/dist/lib/text-list/text-list.js +1 -1
  183. package/dist/lib/toast/index.cjs +1 -1
  184. package/dist/lib/toast/index.js +1 -1
  185. package/dist/lib/toast/toast.cjs +1 -1
  186. package/dist/lib/toast/toast.js +1 -1
  187. package/package.json +5 -5
  188. package/dist/Datepicker-CGFa1nGm.js.map +0 -1
  189. package/dist/Datepicker-DkGmnVc8.cjs +0 -2
  190. package/dist/Datepicker-DkGmnVc8.cjs.map +0 -1
  191. package/dist/EmojiPicker-BllVwJf4.js.map +0 -1
  192. package/dist/EmojiPicker-KO1yhODv.cjs +0 -2
  193. package/dist/EmojiPicker-KO1yhODv.cjs.map +0 -1
  194. package/dist/RichTextEditor-Cz2VXb7-.js.map +0 -1
  195. package/dist/RichTextEditor-EHgahp8r.cjs +0 -11
  196. package/dist/RichTextEditor-EHgahp8r.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRenderer-B6oyniLV.cjs","names":["Node","codeToEmojiData","stringToUnicode"],"sources":["../../../node_modules/.pnpm/@tiptap+static-renderer@3.19.0_@tiptap+core@3.19.0_@tiptap+pm@3.19.0__@tiptap+pm@3.19.0_9606d4b01b88c88c850636a0b274a958/node_modules/@tiptap/static-renderer/dist/pm/markdown/index.js","../components/RichTextEditor/MarkdownRenderer.js"],"sourcesContent":["// src/pm/extensionRenderer.ts\nimport {\n getAttributesFromExtensions,\n getExtensionField,\n getSchemaByResolvedExtensions,\n resolveExtensions,\n splitExtensions\n} from \"@tiptap/core\";\nimport { Node } from \"@tiptap/pm/model\";\n\n// src/helpers.ts\nimport { mergeAttributes } from \"@tiptap/core\";\nfunction getAttributes(nodeOrMark, extensionAttributes, onlyRenderedAttributes) {\n const nodeOrMarkAttributes = nodeOrMark.attrs;\n if (!nodeOrMarkAttributes) {\n return {};\n }\n return extensionAttributes.filter((item) => {\n if (item.type !== (typeof nodeOrMark.type === \"string\" ? nodeOrMark.type : nodeOrMark.type.name)) {\n return false;\n }\n if (onlyRenderedAttributes) {\n return item.attribute.rendered;\n }\n return true;\n }).map((item) => {\n if (!item.attribute.renderHTML) {\n return {\n [item.name]: item.name in nodeOrMarkAttributes ? nodeOrMarkAttributes[item.name] : item.attribute.default\n };\n }\n return item.attribute.renderHTML(nodeOrMarkAttributes) || {\n [item.name]: item.name in nodeOrMarkAttributes ? nodeOrMarkAttributes[item.name] : item.attribute.default\n };\n }).reduce((attributes, attribute) => mergeAttributes(attributes, attribute), {});\n}\nfunction getHTMLAttributes(nodeOrMark, extensionAttributes) {\n return getAttributes(nodeOrMark, extensionAttributes, true);\n}\n\n// src/pm/extensionRenderer.ts\nfunction mapNodeExtensionToReactNode(domOutputSpecToElement, extension, extensionAttributes, options) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n parent: extension.parent\n };\n const renderToHTML = getExtensionField(extension, \"renderHTML\", context);\n if (!renderToHTML) {\n if (options == null ? void 0 : options.unhandledNode) {\n return [extension.name, options.unhandledNode];\n }\n return [\n extension.name,\n () => {\n throw new Error(\n `[tiptap error]: Node ${extension.name} cannot be rendered, it is missing a \"renderToHTML\" method, please implement it or override the corresponding \"nodeMapping\" method to have a custom rendering`\n );\n }\n ];\n }\n return [\n extension.name,\n ({ node, children }) => {\n try {\n return domOutputSpecToElement(\n renderToHTML({\n node,\n HTMLAttributes: getHTMLAttributes(node, extensionAttributes)\n })\n )(children);\n } catch (e) {\n throw new Error(\n `[tiptap error]: Node ${extension.name} cannot be rendered, it's \"renderToHTML\" method threw an error: ${e.message}`,\n { cause: e }\n );\n }\n }\n ];\n}\nfunction mapMarkExtensionToReactNode(domOutputSpecToElement, extension, extensionAttributes, options) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n parent: extension.parent\n };\n const renderToHTML = getExtensionField(extension, \"renderHTML\", context);\n if (!renderToHTML) {\n if (options == null ? void 0 : options.unhandledMark) {\n return [extension.name, options.unhandledMark];\n }\n return [\n extension.name,\n () => {\n throw new Error(`Node ${extension.name} cannot be rendered, it is missing a \"renderToHTML\" method`);\n }\n ];\n }\n return [\n extension.name,\n ({ mark, children }) => {\n try {\n return domOutputSpecToElement(\n renderToHTML({\n mark,\n HTMLAttributes: getHTMLAttributes(mark, extensionAttributes)\n })\n )(children);\n } catch (e) {\n throw new Error(\n `[tiptap error]: Mark ${extension.name} cannot be rendered, it's \"renderToHTML\" method threw an error: ${e.message}`,\n { cause: e }\n );\n }\n }\n ];\n}\nfunction renderToElement({\n renderer,\n domOutputSpecToElement,\n mapDefinedTypes,\n content,\n extensions,\n options\n}) {\n extensions = resolveExtensions(extensions);\n const extensionAttributes = getAttributesFromExtensions(extensions);\n const { nodeExtensions, markExtensions } = splitExtensions(extensions);\n if (!(content instanceof Node)) {\n content = Node.fromJSON(getSchemaByResolvedExtensions(extensions), content);\n }\n return renderer({\n ...options,\n nodeMapping: {\n ...Object.fromEntries(\n nodeExtensions.filter((e) => {\n if (e.name in mapDefinedTypes) {\n return false;\n }\n if (options == null ? void 0 : options.nodeMapping) {\n return !(e.name in options.nodeMapping);\n }\n return true;\n }).map(\n (nodeExtension) => mapNodeExtensionToReactNode(domOutputSpecToElement, nodeExtension, extensionAttributes, options)\n )\n ),\n ...mapDefinedTypes,\n ...options == null ? void 0 : options.nodeMapping\n },\n markMapping: {\n ...Object.fromEntries(\n markExtensions.filter((e) => {\n if (options == null ? void 0 : options.markMapping) {\n return !(e.name in options.markMapping);\n }\n return true;\n }).map((mark) => mapMarkExtensionToReactNode(domOutputSpecToElement, mark, extensionAttributes, options))\n ),\n ...options == null ? void 0 : options.markMapping\n }\n })({ content });\n}\n\n// src/json/renderer.ts\nfunction TiptapStaticRenderer(renderComponent, {\n nodeMapping,\n markMapping,\n unhandledNode,\n unhandledMark\n}) {\n return function renderContent({\n content,\n parent\n }) {\n var _a;\n const nodeType = typeof content.type === \"string\" ? content.type : content.type.name;\n const NodeHandler = (_a = nodeMapping[nodeType]) != null ? _a : unhandledNode;\n if (!NodeHandler) {\n throw new Error(`missing handler for node type ${nodeType}`);\n }\n const nodeContent = renderComponent({\n component: NodeHandler,\n props: {\n node: content,\n parent,\n renderElement: renderContent,\n // Lazily compute the children to avoid unnecessary recursion\n get children() {\n const children = [];\n if (content.content) {\n content.content.forEach((child) => {\n children.push(\n renderContent({\n content: child,\n parent: content\n })\n );\n });\n }\n return children;\n }\n }\n });\n const markedContent = content.marks ? content.marks.reduce((acc, mark) => {\n var _a2;\n const markType = typeof mark.type === \"string\" ? mark.type : mark.type.name;\n const MarkHandler = (_a2 = markMapping[markType]) != null ? _a2 : unhandledMark;\n if (!MarkHandler) {\n throw new Error(`missing handler for mark type ${markType}`);\n }\n return renderComponent({\n component: MarkHandler,\n props: {\n mark,\n parent,\n node: content,\n children: acc\n }\n });\n }, nodeContent) : nodeContent;\n return markedContent;\n };\n}\n\n// src/json/html-string/string.ts\nfunction renderJSONContentToString(options) {\n return TiptapStaticRenderer((ctx) => {\n return ctx.component(ctx.props);\n }, options);\n}\nfunction serializeAttrsToHTMLString(attrs) {\n const output = Object.entries(attrs || {}).map(([key, value]) => `${key.split(\" \").at(-1)}=${JSON.stringify(value)}`).join(\" \");\n return output ? ` ${output}` : \"\";\n}\nfunction serializeChildrenToHTMLString(children) {\n return [].concat(children || \"\").filter(Boolean).join(\"\");\n}\n\n// src/pm/html-string/html-string.ts\nvar NON_SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([\"iframe\", \"script\", \"style\", \"title\", \"textarea\", \"div\", \"span\", \"a\", \"button\"]);\nfunction domOutputSpecToHTMLString(content) {\n if (typeof content === \"string\") {\n return () => content;\n }\n if (typeof content === \"object\" && \"length\" in content) {\n const [_tag, attrs, children, ...rest] = content;\n let tag = _tag;\n const parts = tag.split(\" \");\n if (parts.length > 1) {\n tag = `${parts[1]} xmlns=\"${parts[0]}\"`;\n }\n if (attrs === void 0) {\n return () => `<${tag}/>`;\n }\n if (attrs === 0) {\n return (child) => `<${tag}>${serializeChildrenToHTMLString(child)}</${tag}>`;\n }\n if (typeof attrs === \"object\") {\n if (Array.isArray(attrs)) {\n if (children === void 0) {\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}</${tag}>`;\n }\n if (children === 0) {\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}</${tag}>`;\n }\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}${[children].concat(rest).map((a) => domOutputSpecToHTMLString(a)(child))}</${tag}>`;\n }\n if (children === void 0) {\n if (NON_SELF_CLOSING_TAGS.has(tag)) {\n return () => `<${tag}${serializeAttrsToHTMLString(attrs)}></${tag}>`;\n }\n return () => `<${tag}${serializeAttrsToHTMLString(attrs)}/>`;\n }\n if (children === 0) {\n return (child) => `<${tag}${serializeAttrsToHTMLString(attrs)}>${serializeChildrenToHTMLString(child)}</${tag}>`;\n }\n return (child) => `<${tag}${serializeAttrsToHTMLString(attrs)}>${[children].concat(rest).map((a) => domOutputSpecToHTMLString(a)(child)).join(\"\")}</${tag}>`;\n }\n }\n throw new Error(\n \"[tiptap error]: Unsupported DomOutputSpec type, check the `renderHTML` method output or implement a node mapping\",\n {\n cause: content\n }\n );\n}\nfunction renderToHTMLString({\n content,\n extensions,\n options\n}) {\n return renderToElement({\n renderer: renderJSONContentToString,\n domOutputSpecToElement: domOutputSpecToHTMLString,\n mapDefinedTypes: {\n // Map a doc node to concatenated children\n doc: ({ children }) => serializeChildrenToHTMLString(children),\n // Map a text node to its text content\n text: ({ node }) => {\n var _a;\n return (_a = node.text) != null ? _a : \"\";\n }\n },\n content,\n extensions,\n options\n });\n}\n\n// src/pm/markdown/markdown.ts\nfunction renderToMarkdown({\n content,\n extensions,\n options\n}) {\n return renderToHTMLString({\n content,\n extensions,\n options: {\n ...options,\n nodeMapping: {\n bulletList({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}`;\n },\n orderedList({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}`;\n },\n listItem({ node, children, parent }) {\n if ((parent == null ? void 0 : parent.type.name) === \"bulletList\") {\n return `- ${serializeChildrenToHTMLString(children).trim()}\n`;\n }\n if ((parent == null ? void 0 : parent.type.name) === \"orderedList\") {\n let number = parent.attrs.start || 1;\n parent.forEach((parentChild, _offset, index) => {\n if (node === parentChild) {\n number = index + 1;\n }\n });\n return `${number}. ${serializeChildrenToHTMLString(children).trim()}\n`;\n }\n return serializeChildrenToHTMLString(children);\n },\n paragraph({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}\n`;\n },\n heading({ node, children }) {\n const level = node.attrs.level;\n return `${new Array(level).fill(\"#\").join(\"\")} ${children}\n`;\n },\n codeBlock({ node, children }) {\n return `\n\\`\\`\\`${node.attrs.language}\n${serializeChildrenToHTMLString(children)}\n\\`\\`\\`\n`;\n },\n blockquote({ children }) {\n return `\n${serializeChildrenToHTMLString(children).trim().split(\"\\n\").map((a) => `> ${a}`).join(\"\\n\")}`;\n },\n image({ node }) {\n return `![${node.attrs.alt}](${node.attrs.src})`;\n },\n hardBreak() {\n return \"\\n\";\n },\n horizontalRule() {\n return \"\\n---\\n\";\n },\n table({ children, node }) {\n if (!Array.isArray(children)) {\n return `\n${serializeChildrenToHTMLString(children)}\n`;\n }\n const columnCount = node.children[0].childCount;\n return `\n${serializeChildrenToHTMLString(children[0])}| ${new Array(columnCount).fill(\"---\").join(\" | \")} |\n${serializeChildrenToHTMLString(children.slice(1))}\n`;\n },\n tableRow({ children }) {\n if (Array.isArray(children)) {\n return `| ${children.join(\" | \")} |\n`;\n }\n return `${serializeChildrenToHTMLString(children)}\n`;\n },\n tableHeader({ children }) {\n return serializeChildrenToHTMLString(children).trim();\n },\n tableCell({ children }) {\n return serializeChildrenToHTMLString(children).trim();\n },\n ...options == null ? void 0 : options.nodeMapping\n },\n markMapping: {\n bold({ children }) {\n return `**${serializeChildrenToHTMLString(children)}**`;\n },\n italic({ children, node }) {\n let isBoldToo = false;\n if (node == null ? void 0 : node.marks.some((m) => m.type.name === \"bold\")) {\n isBoldToo = true;\n }\n if (isBoldToo) {\n return `*${serializeChildrenToHTMLString(children)}*`;\n }\n return `_${serializeChildrenToHTMLString(children)}_`;\n },\n code({ children }) {\n return `\\`${serializeChildrenToHTMLString(children)}\\``;\n },\n strike({ children }) {\n return `~~${serializeChildrenToHTMLString(children)}~~`;\n },\n underline({ children }) {\n return `<u>${serializeChildrenToHTMLString(children)}</u>`;\n },\n subscript({ children }) {\n return `<sub>${serializeChildrenToHTMLString(children)}</sub>`;\n },\n superscript({ children }) {\n return `<sup>${serializeChildrenToHTMLString(children)}</sup>`;\n },\n link({ mark, children }) {\n return `[${serializeChildrenToHTMLString(children)}](${mark.attrs.href})`;\n },\n highlight({ children }) {\n return `==${serializeChildrenToHTMLString(children)}==`;\n },\n ...options == null ? void 0 : options.markMapping\n }\n }\n });\n}\nexport {\n mapMarkExtensionToReactNode,\n mapNodeExtensionToReactNode,\n renderToElement,\n renderToMarkdown\n};\n//# sourceMappingURL=index.js.map","import { renderToMarkdown } from '@tiptap/static-renderer/pm/markdown';\nimport { codeToEmojiData, stringToUnicode } from '@/common/emoji';\n\n// The pm/markdown renderer passes children as string[] (one entry per child node),\n// not as a pre-joined string. Normalize to a string before processing.\nconst joinChildren = (children) => Array.isArray(children) ? children.join('') : (children || '');\n\n// Move leading/trailing spaces outside mark delimiters so parsers like CommonMark\n// don't reject them (e.g. \"** bold **\" → \" **bold** \").\nconst wrapMark = (text, open, close) => {\n const trimmed = text.trim();\n if (!trimmed) return text;\n const leading = text.slice(0, text.length - text.trimStart().length);\n const trailing = text.slice(text.trimEnd().length);\n return `${leading}${open}${trimmed}${close}${trailing}`;\n};\n\n/**\n * Renders a TipTap/ProseMirror JSON document to a markdown string.\n *\n * Uses @tiptap/static-renderer with custom mappings to preserve the output\n * format of the legacy jsonToMarkdownConverter, including Dialtone-specific\n * node types (mention, channel, emoji, variable, slash-commands).\n *\n * @param {import('@tiptap/core').JSONContent} jsonContent - TipTap JSON document\n * @param {import('@tiptap/core').Extensions} extensions - Active editor extensions\n * @returns {string}\n */\nexport function renderEditorToMarkdown (jsonContent, extensions) {\n const output = renderToMarkdown({\n extensions,\n content: jsonContent,\n options: {\n nodeMapping: {\n // Override blockquote: built-in omits trailing newline (causes lazy continuation).\n // Since we replace the built-in entirely, we must add the '> ' prefix ourselves.\n blockquote ({ children }) {\n const text = joinChildren(children).trim();\n const quoted = text\n .split('\\n')\n .map(line => line ? `> ${line}` : '>')\n .join('\\n');\n return quoted + '\\n';\n },\n\n // Override codeBlock: built-in passes null language through literally\n codeBlock ({ node, children }) {\n const lang = node.attrs?.language || '';\n return `\\`\\`\\`${lang}\\n${joinChildren(children)}\\n\\`\\`\\`\\n`;\n },\n\n // Custom Dialtone node types\n mention ({ node }) {\n const id = node.attrs?.id || '';\n const contactKey = node.attrs?.contactKey || '';\n const name = node.attrs?.name || '';\n return `<!-- @mention: {\"id\": \"${id}\", \"contactKey\": \"${contactKey}\", \"name\": \"${name}\"} -->`;\n },\n\n channel ({ node }) {\n const id = node.attrs?.id || '';\n const channelKey = node.attrs?.channelKey || '';\n const name = node.attrs?.name || '';\n const locked = String(node.attrs?.locked ?? '');\n return `<!-- @channel: {\"id\": \"${id}\", \"channelKey\": \"${channelKey}\", \"name\": \"${name}\", \"locked\": \"${locked}\"} -->`;\n },\n\n 'slash-commands' ({ node }) {\n return `/${node.attrs?.command || ''}`;\n },\n\n emoji ({ node }) {\n const code = node.attrs?.code;\n if (!code) return '';\n // Always output emoji as unicode characters rather than shortcodes, matching\n // renderText's backwards-compatibility behavior with our backend (see Emoji.js).\n const emojiData = codeToEmojiData(code);\n return emojiData ? stringToUnicode(emojiData.unicode_output) : code;\n },\n\n variable ({ node }) {\n const id = node.attrs?.id || '';\n const altText = node.attrs?.altText || '';\n return `{{${id}=${altText}}}`;\n },\n },\n\n markMapping: {\n bold ({ children }) {\n return wrapMark(joinChildren(children), '**', '**');\n },\n\n // Override italic: use * instead of built-in _ and fix boundary spaces\n italic ({ children }) {\n return wrapMark(joinChildren(children), '*', '*');\n },\n\n strike ({ children }) {\n return wrapMark(joinChildren(children), '~~', '~~');\n },\n\n code ({ children }) {\n return wrapMark(joinChildren(children), '`', '`');\n },\n\n link ({ mark, children }) {\n const text = joinChildren(children);\n const href = mark.attrs?.href || '';\n const trimmed = text.trim();\n const leading = text.slice(0, text.length - text.trimStart().length);\n const trailing = text.slice(text.trimEnd().length);\n return `${leading}[${trimmed}](${href})${trailing}`;\n },\n\n // Override underline: pass-through (no markdown equivalent, matches legacy no-op)\n underline ({ children }) {\n return joinChildren(children);\n },\n },\n },\n });\n // Collapse 3+ consecutive newlines to 2 (CommonMark ignores extra blank\n // lines between blocks), and strip the leading newline that the built-in\n // paragraph renderer always prepends to the first node.\n return output.replace(/\\n{3,}/g, '\\n\\n').replace(/^\\n+|\\n+$/g, '');\n}\n"],"x_google_ignoreList":[0],"mappings":"wIAYA,SAAS,EAAc,EAAY,EAAqB,EAAwB,CAC9E,IAAM,EAAuB,EAAW,MAIxC,OAHK,EAGE,EAAoB,OAAQ,GAC7B,EAAK,QAAU,OAAO,EAAW,MAAS,SAAW,EAAW,KAAO,EAAW,KAAK,MAGvF,EACK,EAAK,UAAU,SAEjB,GALE,GAMT,CAAC,IAAK,GACD,EAAK,UAAU,YAKb,EAAK,UAAU,WAAW,EAAqB,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,EAAK,OAAO,SAAW,GACb,KAE7B,CAED,YAAa,CACX,KAAM,CAAE,YAAY,CAClB,OAAO,EAAS,EAAa,EAAS,CAAE,KAAM,KAAK,EAIrD,OAAQ,CAAE,YAAY,CACpB,OAAO,EAAS,EAAa,EAAS,CAAE,IAAK,IAAI,EAGnD,OAAQ,CAAE,YAAY,CACpB,OAAO,EAAS,EAAa,EAAS,CAAE,KAAM,KAAK,EAGrD,KAAM,CAAE,YAAY,CAClB,OAAO,EAAS,EAAa,EAAS,CAAE,IAAK,IAAI,EAGnD,KAAM,CAAE,OAAM,YAAY,CACxB,IAAM,EAAO,EAAa,EAAS,CAC7B,EAAO,EAAK,OAAO,MAAQ,GAC3B,EAAU,EAAK,MAAM,CAG3B,MAAO,GAFS,EAAK,MAAM,EAAG,EAAK,OAAS,EAAK,WAAW,CAAC,OAAO,CAElD,GAAG,EAAQ,IAAI,EAAK,GADrB,EAAK,MAAM,EAAK,SAAS,CAAC,OAAO,IAKpD,UAAW,CAAE,YAAY,CACvB,OAAO,EAAa,EAAS,EAEhC,CACF,CACF,CAAC,CAIY,QAAQ,UAAW;;EAAO,CAAC,QAAQ,aAAc,GAAG"}
1
+ {"version":3,"file":"MarkdownRenderer-C5wdjC5_.cjs","names":["Node","codeToEmojiData","stringToUnicode"],"sources":["../../../node_modules/.pnpm/@tiptap+static-renderer@3.19.0_@tiptap+core@3.19.0_@tiptap+pm@3.19.0__@tiptap+pm@3.19.0_9606d4b01b88c88c850636a0b274a958/node_modules/@tiptap/static-renderer/dist/pm/markdown/index.js","../components/RichTextEditor/MarkdownRenderer.js"],"sourcesContent":["// src/pm/extensionRenderer.ts\nimport {\n getAttributesFromExtensions,\n getExtensionField,\n getSchemaByResolvedExtensions,\n resolveExtensions,\n splitExtensions\n} from \"@tiptap/core\";\nimport { Node } from \"@tiptap/pm/model\";\n\n// src/helpers.ts\nimport { mergeAttributes } from \"@tiptap/core\";\nfunction getAttributes(nodeOrMark, extensionAttributes, onlyRenderedAttributes) {\n const nodeOrMarkAttributes = nodeOrMark.attrs;\n if (!nodeOrMarkAttributes) {\n return {};\n }\n return extensionAttributes.filter((item) => {\n if (item.type !== (typeof nodeOrMark.type === \"string\" ? nodeOrMark.type : nodeOrMark.type.name)) {\n return false;\n }\n if (onlyRenderedAttributes) {\n return item.attribute.rendered;\n }\n return true;\n }).map((item) => {\n if (!item.attribute.renderHTML) {\n return {\n [item.name]: item.name in nodeOrMarkAttributes ? nodeOrMarkAttributes[item.name] : item.attribute.default\n };\n }\n return item.attribute.renderHTML(nodeOrMarkAttributes) || {\n [item.name]: item.name in nodeOrMarkAttributes ? nodeOrMarkAttributes[item.name] : item.attribute.default\n };\n }).reduce((attributes, attribute) => mergeAttributes(attributes, attribute), {});\n}\nfunction getHTMLAttributes(nodeOrMark, extensionAttributes) {\n return getAttributes(nodeOrMark, extensionAttributes, true);\n}\n\n// src/pm/extensionRenderer.ts\nfunction mapNodeExtensionToReactNode(domOutputSpecToElement, extension, extensionAttributes, options) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n parent: extension.parent\n };\n const renderToHTML = getExtensionField(extension, \"renderHTML\", context);\n if (!renderToHTML) {\n if (options == null ? void 0 : options.unhandledNode) {\n return [extension.name, options.unhandledNode];\n }\n return [\n extension.name,\n () => {\n throw new Error(\n `[tiptap error]: Node ${extension.name} cannot be rendered, it is missing a \"renderToHTML\" method, please implement it or override the corresponding \"nodeMapping\" method to have a custom rendering`\n );\n }\n ];\n }\n return [\n extension.name,\n ({ node, children }) => {\n try {\n return domOutputSpecToElement(\n renderToHTML({\n node,\n HTMLAttributes: getHTMLAttributes(node, extensionAttributes)\n })\n )(children);\n } catch (e) {\n throw new Error(\n `[tiptap error]: Node ${extension.name} cannot be rendered, it's \"renderToHTML\" method threw an error: ${e.message}`,\n { cause: e }\n );\n }\n }\n ];\n}\nfunction mapMarkExtensionToReactNode(domOutputSpecToElement, extension, extensionAttributes, options) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n parent: extension.parent\n };\n const renderToHTML = getExtensionField(extension, \"renderHTML\", context);\n if (!renderToHTML) {\n if (options == null ? void 0 : options.unhandledMark) {\n return [extension.name, options.unhandledMark];\n }\n return [\n extension.name,\n () => {\n throw new Error(`Node ${extension.name} cannot be rendered, it is missing a \"renderToHTML\" method`);\n }\n ];\n }\n return [\n extension.name,\n ({ mark, children }) => {\n try {\n return domOutputSpecToElement(\n renderToHTML({\n mark,\n HTMLAttributes: getHTMLAttributes(mark, extensionAttributes)\n })\n )(children);\n } catch (e) {\n throw new Error(\n `[tiptap error]: Mark ${extension.name} cannot be rendered, it's \"renderToHTML\" method threw an error: ${e.message}`,\n { cause: e }\n );\n }\n }\n ];\n}\nfunction renderToElement({\n renderer,\n domOutputSpecToElement,\n mapDefinedTypes,\n content,\n extensions,\n options\n}) {\n extensions = resolveExtensions(extensions);\n const extensionAttributes = getAttributesFromExtensions(extensions);\n const { nodeExtensions, markExtensions } = splitExtensions(extensions);\n if (!(content instanceof Node)) {\n content = Node.fromJSON(getSchemaByResolvedExtensions(extensions), content);\n }\n return renderer({\n ...options,\n nodeMapping: {\n ...Object.fromEntries(\n nodeExtensions.filter((e) => {\n if (e.name in mapDefinedTypes) {\n return false;\n }\n if (options == null ? void 0 : options.nodeMapping) {\n return !(e.name in options.nodeMapping);\n }\n return true;\n }).map(\n (nodeExtension) => mapNodeExtensionToReactNode(domOutputSpecToElement, nodeExtension, extensionAttributes, options)\n )\n ),\n ...mapDefinedTypes,\n ...options == null ? void 0 : options.nodeMapping\n },\n markMapping: {\n ...Object.fromEntries(\n markExtensions.filter((e) => {\n if (options == null ? void 0 : options.markMapping) {\n return !(e.name in options.markMapping);\n }\n return true;\n }).map((mark) => mapMarkExtensionToReactNode(domOutputSpecToElement, mark, extensionAttributes, options))\n ),\n ...options == null ? void 0 : options.markMapping\n }\n })({ content });\n}\n\n// src/json/renderer.ts\nfunction TiptapStaticRenderer(renderComponent, {\n nodeMapping,\n markMapping,\n unhandledNode,\n unhandledMark\n}) {\n return function renderContent({\n content,\n parent\n }) {\n var _a;\n const nodeType = typeof content.type === \"string\" ? content.type : content.type.name;\n const NodeHandler = (_a = nodeMapping[nodeType]) != null ? _a : unhandledNode;\n if (!NodeHandler) {\n throw new Error(`missing handler for node type ${nodeType}`);\n }\n const nodeContent = renderComponent({\n component: NodeHandler,\n props: {\n node: content,\n parent,\n renderElement: renderContent,\n // Lazily compute the children to avoid unnecessary recursion\n get children() {\n const children = [];\n if (content.content) {\n content.content.forEach((child) => {\n children.push(\n renderContent({\n content: child,\n parent: content\n })\n );\n });\n }\n return children;\n }\n }\n });\n const markedContent = content.marks ? content.marks.reduce((acc, mark) => {\n var _a2;\n const markType = typeof mark.type === \"string\" ? mark.type : mark.type.name;\n const MarkHandler = (_a2 = markMapping[markType]) != null ? _a2 : unhandledMark;\n if (!MarkHandler) {\n throw new Error(`missing handler for mark type ${markType}`);\n }\n return renderComponent({\n component: MarkHandler,\n props: {\n mark,\n parent,\n node: content,\n children: acc\n }\n });\n }, nodeContent) : nodeContent;\n return markedContent;\n };\n}\n\n// src/json/html-string/string.ts\nfunction renderJSONContentToString(options) {\n return TiptapStaticRenderer((ctx) => {\n return ctx.component(ctx.props);\n }, options);\n}\nfunction serializeAttrsToHTMLString(attrs) {\n const output = Object.entries(attrs || {}).map(([key, value]) => `${key.split(\" \").at(-1)}=${JSON.stringify(value)}`).join(\" \");\n return output ? ` ${output}` : \"\";\n}\nfunction serializeChildrenToHTMLString(children) {\n return [].concat(children || \"\").filter(Boolean).join(\"\");\n}\n\n// src/pm/html-string/html-string.ts\nvar NON_SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([\"iframe\", \"script\", \"style\", \"title\", \"textarea\", \"div\", \"span\", \"a\", \"button\"]);\nfunction domOutputSpecToHTMLString(content) {\n if (typeof content === \"string\") {\n return () => content;\n }\n if (typeof content === \"object\" && \"length\" in content) {\n const [_tag, attrs, children, ...rest] = content;\n let tag = _tag;\n const parts = tag.split(\" \");\n if (parts.length > 1) {\n tag = `${parts[1]} xmlns=\"${parts[0]}\"`;\n }\n if (attrs === void 0) {\n return () => `<${tag}/>`;\n }\n if (attrs === 0) {\n return (child) => `<${tag}>${serializeChildrenToHTMLString(child)}</${tag}>`;\n }\n if (typeof attrs === \"object\") {\n if (Array.isArray(attrs)) {\n if (children === void 0) {\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}</${tag}>`;\n }\n if (children === 0) {\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}</${tag}>`;\n }\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}${[children].concat(rest).map((a) => domOutputSpecToHTMLString(a)(child))}</${tag}>`;\n }\n if (children === void 0) {\n if (NON_SELF_CLOSING_TAGS.has(tag)) {\n return () => `<${tag}${serializeAttrsToHTMLString(attrs)}></${tag}>`;\n }\n return () => `<${tag}${serializeAttrsToHTMLString(attrs)}/>`;\n }\n if (children === 0) {\n return (child) => `<${tag}${serializeAttrsToHTMLString(attrs)}>${serializeChildrenToHTMLString(child)}</${tag}>`;\n }\n return (child) => `<${tag}${serializeAttrsToHTMLString(attrs)}>${[children].concat(rest).map((a) => domOutputSpecToHTMLString(a)(child)).join(\"\")}</${tag}>`;\n }\n }\n throw new Error(\n \"[tiptap error]: Unsupported DomOutputSpec type, check the `renderHTML` method output or implement a node mapping\",\n {\n cause: content\n }\n );\n}\nfunction renderToHTMLString({\n content,\n extensions,\n options\n}) {\n return renderToElement({\n renderer: renderJSONContentToString,\n domOutputSpecToElement: domOutputSpecToHTMLString,\n mapDefinedTypes: {\n // Map a doc node to concatenated children\n doc: ({ children }) => serializeChildrenToHTMLString(children),\n // Map a text node to its text content\n text: ({ node }) => {\n var _a;\n return (_a = node.text) != null ? _a : \"\";\n }\n },\n content,\n extensions,\n options\n });\n}\n\n// src/pm/markdown/markdown.ts\nfunction renderToMarkdown({\n content,\n extensions,\n options\n}) {\n return renderToHTMLString({\n content,\n extensions,\n options: {\n ...options,\n nodeMapping: {\n bulletList({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}`;\n },\n orderedList({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}`;\n },\n listItem({ node, children, parent }) {\n if ((parent == null ? void 0 : parent.type.name) === \"bulletList\") {\n return `- ${serializeChildrenToHTMLString(children).trim()}\n`;\n }\n if ((parent == null ? void 0 : parent.type.name) === \"orderedList\") {\n let number = parent.attrs.start || 1;\n parent.forEach((parentChild, _offset, index) => {\n if (node === parentChild) {\n number = index + 1;\n }\n });\n return `${number}. ${serializeChildrenToHTMLString(children).trim()}\n`;\n }\n return serializeChildrenToHTMLString(children);\n },\n paragraph({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}\n`;\n },\n heading({ node, children }) {\n const level = node.attrs.level;\n return `${new Array(level).fill(\"#\").join(\"\")} ${children}\n`;\n },\n codeBlock({ node, children }) {\n return `\n\\`\\`\\`${node.attrs.language}\n${serializeChildrenToHTMLString(children)}\n\\`\\`\\`\n`;\n },\n blockquote({ children }) {\n return `\n${serializeChildrenToHTMLString(children).trim().split(\"\\n\").map((a) => `> ${a}`).join(\"\\n\")}`;\n },\n image({ node }) {\n return `![${node.attrs.alt}](${node.attrs.src})`;\n },\n hardBreak() {\n return \"\\n\";\n },\n horizontalRule() {\n return \"\\n---\\n\";\n },\n table({ children, node }) {\n if (!Array.isArray(children)) {\n return `\n${serializeChildrenToHTMLString(children)}\n`;\n }\n const columnCount = node.children[0].childCount;\n return `\n${serializeChildrenToHTMLString(children[0])}| ${new Array(columnCount).fill(\"---\").join(\" | \")} |\n${serializeChildrenToHTMLString(children.slice(1))}\n`;\n },\n tableRow({ children }) {\n if (Array.isArray(children)) {\n return `| ${children.join(\" | \")} |\n`;\n }\n return `${serializeChildrenToHTMLString(children)}\n`;\n },\n tableHeader({ children }) {\n return serializeChildrenToHTMLString(children).trim();\n },\n tableCell({ children }) {\n return serializeChildrenToHTMLString(children).trim();\n },\n ...options == null ? void 0 : options.nodeMapping\n },\n markMapping: {\n bold({ children }) {\n return `**${serializeChildrenToHTMLString(children)}**`;\n },\n italic({ children, node }) {\n let isBoldToo = false;\n if (node == null ? void 0 : node.marks.some((m) => m.type.name === \"bold\")) {\n isBoldToo = true;\n }\n if (isBoldToo) {\n return `*${serializeChildrenToHTMLString(children)}*`;\n }\n return `_${serializeChildrenToHTMLString(children)}_`;\n },\n code({ children }) {\n return `\\`${serializeChildrenToHTMLString(children)}\\``;\n },\n strike({ children }) {\n return `~~${serializeChildrenToHTMLString(children)}~~`;\n },\n underline({ children }) {\n return `<u>${serializeChildrenToHTMLString(children)}</u>`;\n },\n subscript({ children }) {\n return `<sub>${serializeChildrenToHTMLString(children)}</sub>`;\n },\n superscript({ children }) {\n return `<sup>${serializeChildrenToHTMLString(children)}</sup>`;\n },\n link({ mark, children }) {\n return `[${serializeChildrenToHTMLString(children)}](${mark.attrs.href})`;\n },\n highlight({ children }) {\n return `==${serializeChildrenToHTMLString(children)}==`;\n },\n ...options == null ? void 0 : options.markMapping\n }\n }\n });\n}\nexport {\n mapMarkExtensionToReactNode,\n mapNodeExtensionToReactNode,\n renderToElement,\n renderToMarkdown\n};\n//# sourceMappingURL=index.js.map","import { renderToMarkdown } from '@tiptap/static-renderer/pm/markdown';\nimport { codeToEmojiData, stringToUnicode } from '@/common/emoji';\n\n// The pm/markdown renderer passes children as string[] (one entry per child node),\n// not as a pre-joined string. Normalize to a string before processing.\nconst joinChildren = (children) => Array.isArray(children) ? children.join('') : (children || '');\n\n// Move leading/trailing spaces outside mark delimiters so parsers like CommonMark\n// don't reject them (e.g. \"** bold **\" → \" **bold** \").\nconst wrapMark = (text, open, close) => {\n const trimmed = text.trim();\n if (!trimmed) return text;\n const leading = text.slice(0, text.length - text.trimStart().length);\n const trailing = text.slice(text.trimEnd().length);\n return `${leading}${open}${trimmed}${close}${trailing}`;\n};\n\n/**\n * Renders a TipTap/ProseMirror JSON document to a markdown string.\n *\n * Uses @tiptap/static-renderer with custom mappings to preserve the output\n * format of the legacy jsonToMarkdownConverter, including Dialtone-specific\n * node types (mention, channel, emoji, variable, slash-commands).\n *\n * @param {import('@tiptap/core').JSONContent} jsonContent - TipTap JSON document\n * @param {import('@tiptap/core').Extensions} extensions - Active editor extensions\n * @returns {string}\n */\nexport function renderEditorToMarkdown (jsonContent, extensions) {\n const output = renderToMarkdown({\n extensions,\n content: jsonContent,\n options: {\n nodeMapping: {\n // Override blockquote: built-in omits trailing newline (causes lazy continuation).\n // Since we replace the built-in entirely, we must add the '> ' prefix ourselves.\n blockquote ({ children }) {\n const text = joinChildren(children).trim();\n const quoted = text\n .split('\\n')\n .map(line => line ? `> ${line}` : '>')\n .join('\\n');\n return quoted + '\\n';\n },\n\n // Override codeBlock: built-in passes null language through literally\n codeBlock ({ node, children }) {\n const lang = node.attrs?.language || '';\n return `\\`\\`\\`${lang}\\n${joinChildren(children)}\\n\\`\\`\\`\\n`;\n },\n\n // Custom Dialtone node types\n mention ({ node }) {\n const id = node.attrs?.id || '';\n const contactKey = node.attrs?.contactKey || '';\n const name = node.attrs?.name || '';\n return `<!-- @mention: {\"id\": \"${id}\", \"contactKey\": \"${contactKey}\", \"name\": \"${name}\"} -->`;\n },\n\n channel ({ node }) {\n const id = node.attrs?.id || '';\n const channelKey = node.attrs?.channelKey || '';\n const name = node.attrs?.name || '';\n const locked = String(node.attrs?.locked ?? '');\n return `<!-- @channel: {\"id\": \"${id}\", \"channelKey\": \"${channelKey}\", \"name\": \"${name}\", \"locked\": \"${locked}\"} -->`;\n },\n\n 'slash-commands' ({ node }) {\n return `/${node.attrs?.command || ''}`;\n },\n\n emoji ({ node }) {\n const code = node.attrs?.code;\n if (!code) return '';\n // Always output emoji as unicode characters rather than shortcodes, matching\n // renderText's backwards-compatibility behavior with our backend (see Emoji.js).\n const emojiData = codeToEmojiData(code);\n return emojiData ? stringToUnicode(emojiData.unicode_output) : code;\n },\n\n variable ({ node }) {\n const id = node.attrs?.id || '';\n const altText = node.attrs?.altText || '';\n return `{{${id}=${altText}}}`;\n },\n },\n\n markMapping: {\n bold ({ children }) {\n return wrapMark(joinChildren(children), '**', '**');\n },\n\n // Override italic: use * instead of built-in _ and fix boundary spaces\n italic ({ children }) {\n return wrapMark(joinChildren(children), '*', '*');\n },\n\n strike ({ children }) {\n return wrapMark(joinChildren(children), '~~', '~~');\n },\n\n code ({ children }) {\n return wrapMark(joinChildren(children), '`', '`');\n },\n\n link ({ mark, children }) {\n const text = joinChildren(children);\n const href = mark.attrs?.href || '';\n const trimmed = text.trim();\n const leading = text.slice(0, text.length - text.trimStart().length);\n const trailing = text.slice(text.trimEnd().length);\n return `${leading}[${trimmed}](${href})${trailing}`;\n },\n\n // Override underline: pass-through (no markdown equivalent, matches legacy no-op)\n underline ({ children }) {\n return joinChildren(children);\n },\n },\n },\n });\n // Collapse 3+ consecutive newlines to 2 (CommonMark ignores extra blank\n // lines between blocks), and strip the leading newline that the built-in\n // paragraph renderer always prepends to the first node.\n return output.replace(/\\n{3,}/g, '\\n\\n').replace(/^\\n+|\\n+$/g, '');\n}\n"],"x_google_ignoreList":[0],"mappings":"wIAYA,SAAS,EAAc,EAAY,EAAqB,EAAwB,CAC9E,IAAM,EAAuB,EAAW,MAIxC,OAHK,EAGE,EAAoB,OAAQ,GAC7B,EAAK,QAAU,OAAO,EAAW,MAAS,SAAW,EAAW,KAAO,EAAW,KAAK,MAGvF,EACK,EAAK,UAAU,SAEjB,GALE,GAMT,CAAC,IAAK,GACD,EAAK,UAAU,YAKb,EAAK,UAAU,WAAW,EAAqB,EAJ7C,EACJ,EAAK,MAAO,EAAK,QAAQ,EAAuB,EAAqB,EAAK,MAAQ,EAAK,UAAU,QACnG,CAKH,CAAC,QAAQ,EAAY,KAAA,EAAA,EAAA,iBAA8B,EAAY,EAAU,CAAE,EAAE,CAAC,CAnBvE,EAAE,CAqBb,SAAS,EAAkB,EAAY,EAAqB,CAC1D,OAAO,EAAc,EAAY,EAAqB,GAAK,CAI7D,SAAS,EAA4B,EAAwB,EAAW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,CAClB,OAAO,EAAS,EAAa,EAAS,CAAE,IAAK,IAAI,EAGnD,KAAM,CAAE,OAAM,YAAY,CACxB,IAAM,EAAO,EAAa,EAAS,CAC7B,EAAO,EAAK,OAAO,MAAQ,GAC3B,EAAU,EAAK,MAAM,CAG3B,MAAO,GAFS,EAAK,MAAM,EAAG,EAAK,OAAS,EAAK,WAAW,CAAC,OAAO,CAElD,GAAG,EAAQ,IAAI,EAAK,GADrB,EAAK,MAAM,EAAK,SAAS,CAAC,OAAO,IAKpD,UAAW,CAAE,YAAY,CACvB,OAAO,EAAa,EAAS,EAEhC,CACF,CACF,CAAC,CAIY,QAAQ,UAAW;;EAAO,CAAC,QAAQ,aAAc,GAAG"}
@@ -323,4 +323,4 @@ function w(n, r) {
323
323
  //#endregion
324
324
  export { w as t };
325
325
 
326
- //# sourceMappingURL=MarkdownRenderer-D-EV50_M.js.map
326
+ //# sourceMappingURL=MarkdownRenderer-eMwmPygx.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRenderer-D-EV50_M.js","names":["Node"],"sources":["../../../node_modules/.pnpm/@tiptap+static-renderer@3.19.0_@tiptap+core@3.19.0_@tiptap+pm@3.19.0__@tiptap+pm@3.19.0_9606d4b01b88c88c850636a0b274a958/node_modules/@tiptap/static-renderer/dist/pm/markdown/index.js","../components/RichTextEditor/MarkdownRenderer.js"],"sourcesContent":["// src/pm/extensionRenderer.ts\nimport {\n getAttributesFromExtensions,\n getExtensionField,\n getSchemaByResolvedExtensions,\n resolveExtensions,\n splitExtensions\n} from \"@tiptap/core\";\nimport { Node } from \"@tiptap/pm/model\";\n\n// src/helpers.ts\nimport { mergeAttributes } from \"@tiptap/core\";\nfunction getAttributes(nodeOrMark, extensionAttributes, onlyRenderedAttributes) {\n const nodeOrMarkAttributes = nodeOrMark.attrs;\n if (!nodeOrMarkAttributes) {\n return {};\n }\n return extensionAttributes.filter((item) => {\n if (item.type !== (typeof nodeOrMark.type === \"string\" ? nodeOrMark.type : nodeOrMark.type.name)) {\n return false;\n }\n if (onlyRenderedAttributes) {\n return item.attribute.rendered;\n }\n return true;\n }).map((item) => {\n if (!item.attribute.renderHTML) {\n return {\n [item.name]: item.name in nodeOrMarkAttributes ? nodeOrMarkAttributes[item.name] : item.attribute.default\n };\n }\n return item.attribute.renderHTML(nodeOrMarkAttributes) || {\n [item.name]: item.name in nodeOrMarkAttributes ? nodeOrMarkAttributes[item.name] : item.attribute.default\n };\n }).reduce((attributes, attribute) => mergeAttributes(attributes, attribute), {});\n}\nfunction getHTMLAttributes(nodeOrMark, extensionAttributes) {\n return getAttributes(nodeOrMark, extensionAttributes, true);\n}\n\n// src/pm/extensionRenderer.ts\nfunction mapNodeExtensionToReactNode(domOutputSpecToElement, extension, extensionAttributes, options) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n parent: extension.parent\n };\n const renderToHTML = getExtensionField(extension, \"renderHTML\", context);\n if (!renderToHTML) {\n if (options == null ? void 0 : options.unhandledNode) {\n return [extension.name, options.unhandledNode];\n }\n return [\n extension.name,\n () => {\n throw new Error(\n `[tiptap error]: Node ${extension.name} cannot be rendered, it is missing a \"renderToHTML\" method, please implement it or override the corresponding \"nodeMapping\" method to have a custom rendering`\n );\n }\n ];\n }\n return [\n extension.name,\n ({ node, children }) => {\n try {\n return domOutputSpecToElement(\n renderToHTML({\n node,\n HTMLAttributes: getHTMLAttributes(node, extensionAttributes)\n })\n )(children);\n } catch (e) {\n throw new Error(\n `[tiptap error]: Node ${extension.name} cannot be rendered, it's \"renderToHTML\" method threw an error: ${e.message}`,\n { cause: e }\n );\n }\n }\n ];\n}\nfunction mapMarkExtensionToReactNode(domOutputSpecToElement, extension, extensionAttributes, options) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n parent: extension.parent\n };\n const renderToHTML = getExtensionField(extension, \"renderHTML\", context);\n if (!renderToHTML) {\n if (options == null ? void 0 : options.unhandledMark) {\n return [extension.name, options.unhandledMark];\n }\n return [\n extension.name,\n () => {\n throw new Error(`Node ${extension.name} cannot be rendered, it is missing a \"renderToHTML\" method`);\n }\n ];\n }\n return [\n extension.name,\n ({ mark, children }) => {\n try {\n return domOutputSpecToElement(\n renderToHTML({\n mark,\n HTMLAttributes: getHTMLAttributes(mark, extensionAttributes)\n })\n )(children);\n } catch (e) {\n throw new Error(\n `[tiptap error]: Mark ${extension.name} cannot be rendered, it's \"renderToHTML\" method threw an error: ${e.message}`,\n { cause: e }\n );\n }\n }\n ];\n}\nfunction renderToElement({\n renderer,\n domOutputSpecToElement,\n mapDefinedTypes,\n content,\n extensions,\n options\n}) {\n extensions = resolveExtensions(extensions);\n const extensionAttributes = getAttributesFromExtensions(extensions);\n const { nodeExtensions, markExtensions } = splitExtensions(extensions);\n if (!(content instanceof Node)) {\n content = Node.fromJSON(getSchemaByResolvedExtensions(extensions), content);\n }\n return renderer({\n ...options,\n nodeMapping: {\n ...Object.fromEntries(\n nodeExtensions.filter((e) => {\n if (e.name in mapDefinedTypes) {\n return false;\n }\n if (options == null ? void 0 : options.nodeMapping) {\n return !(e.name in options.nodeMapping);\n }\n return true;\n }).map(\n (nodeExtension) => mapNodeExtensionToReactNode(domOutputSpecToElement, nodeExtension, extensionAttributes, options)\n )\n ),\n ...mapDefinedTypes,\n ...options == null ? void 0 : options.nodeMapping\n },\n markMapping: {\n ...Object.fromEntries(\n markExtensions.filter((e) => {\n if (options == null ? void 0 : options.markMapping) {\n return !(e.name in options.markMapping);\n }\n return true;\n }).map((mark) => mapMarkExtensionToReactNode(domOutputSpecToElement, mark, extensionAttributes, options))\n ),\n ...options == null ? void 0 : options.markMapping\n }\n })({ content });\n}\n\n// src/json/renderer.ts\nfunction TiptapStaticRenderer(renderComponent, {\n nodeMapping,\n markMapping,\n unhandledNode,\n unhandledMark\n}) {\n return function renderContent({\n content,\n parent\n }) {\n var _a;\n const nodeType = typeof content.type === \"string\" ? content.type : content.type.name;\n const NodeHandler = (_a = nodeMapping[nodeType]) != null ? _a : unhandledNode;\n if (!NodeHandler) {\n throw new Error(`missing handler for node type ${nodeType}`);\n }\n const nodeContent = renderComponent({\n component: NodeHandler,\n props: {\n node: content,\n parent,\n renderElement: renderContent,\n // Lazily compute the children to avoid unnecessary recursion\n get children() {\n const children = [];\n if (content.content) {\n content.content.forEach((child) => {\n children.push(\n renderContent({\n content: child,\n parent: content\n })\n );\n });\n }\n return children;\n }\n }\n });\n const markedContent = content.marks ? content.marks.reduce((acc, mark) => {\n var _a2;\n const markType = typeof mark.type === \"string\" ? mark.type : mark.type.name;\n const MarkHandler = (_a2 = markMapping[markType]) != null ? _a2 : unhandledMark;\n if (!MarkHandler) {\n throw new Error(`missing handler for mark type ${markType}`);\n }\n return renderComponent({\n component: MarkHandler,\n props: {\n mark,\n parent,\n node: content,\n children: acc\n }\n });\n }, nodeContent) : nodeContent;\n return markedContent;\n };\n}\n\n// src/json/html-string/string.ts\nfunction renderJSONContentToString(options) {\n return TiptapStaticRenderer((ctx) => {\n return ctx.component(ctx.props);\n }, options);\n}\nfunction serializeAttrsToHTMLString(attrs) {\n const output = Object.entries(attrs || {}).map(([key, value]) => `${key.split(\" \").at(-1)}=${JSON.stringify(value)}`).join(\" \");\n return output ? ` ${output}` : \"\";\n}\nfunction serializeChildrenToHTMLString(children) {\n return [].concat(children || \"\").filter(Boolean).join(\"\");\n}\n\n// src/pm/html-string/html-string.ts\nvar NON_SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([\"iframe\", \"script\", \"style\", \"title\", \"textarea\", \"div\", \"span\", \"a\", \"button\"]);\nfunction domOutputSpecToHTMLString(content) {\n if (typeof content === \"string\") {\n return () => content;\n }\n if (typeof content === \"object\" && \"length\" in content) {\n const [_tag, attrs, children, ...rest] = content;\n let tag = _tag;\n const parts = tag.split(\" \");\n if (parts.length > 1) {\n tag = `${parts[1]} xmlns=\"${parts[0]}\"`;\n }\n if (attrs === void 0) {\n return () => `<${tag}/>`;\n }\n if (attrs === 0) {\n return (child) => `<${tag}>${serializeChildrenToHTMLString(child)}</${tag}>`;\n }\n if (typeof attrs === \"object\") {\n if (Array.isArray(attrs)) {\n if (children === void 0) {\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}</${tag}>`;\n }\n if (children === 0) {\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}</${tag}>`;\n }\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}${[children].concat(rest).map((a) => domOutputSpecToHTMLString(a)(child))}</${tag}>`;\n }\n if (children === void 0) {\n if (NON_SELF_CLOSING_TAGS.has(tag)) {\n return () => `<${tag}${serializeAttrsToHTMLString(attrs)}></${tag}>`;\n }\n return () => `<${tag}${serializeAttrsToHTMLString(attrs)}/>`;\n }\n if (children === 0) {\n return (child) => `<${tag}${serializeAttrsToHTMLString(attrs)}>${serializeChildrenToHTMLString(child)}</${tag}>`;\n }\n return (child) => `<${tag}${serializeAttrsToHTMLString(attrs)}>${[children].concat(rest).map((a) => domOutputSpecToHTMLString(a)(child)).join(\"\")}</${tag}>`;\n }\n }\n throw new Error(\n \"[tiptap error]: Unsupported DomOutputSpec type, check the `renderHTML` method output or implement a node mapping\",\n {\n cause: content\n }\n );\n}\nfunction renderToHTMLString({\n content,\n extensions,\n options\n}) {\n return renderToElement({\n renderer: renderJSONContentToString,\n domOutputSpecToElement: domOutputSpecToHTMLString,\n mapDefinedTypes: {\n // Map a doc node to concatenated children\n doc: ({ children }) => serializeChildrenToHTMLString(children),\n // Map a text node to its text content\n text: ({ node }) => {\n var _a;\n return (_a = node.text) != null ? _a : \"\";\n }\n },\n content,\n extensions,\n options\n });\n}\n\n// src/pm/markdown/markdown.ts\nfunction renderToMarkdown({\n content,\n extensions,\n options\n}) {\n return renderToHTMLString({\n content,\n extensions,\n options: {\n ...options,\n nodeMapping: {\n bulletList({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}`;\n },\n orderedList({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}`;\n },\n listItem({ node, children, parent }) {\n if ((parent == null ? void 0 : parent.type.name) === \"bulletList\") {\n return `- ${serializeChildrenToHTMLString(children).trim()}\n`;\n }\n if ((parent == null ? void 0 : parent.type.name) === \"orderedList\") {\n let number = parent.attrs.start || 1;\n parent.forEach((parentChild, _offset, index) => {\n if (node === parentChild) {\n number = index + 1;\n }\n });\n return `${number}. ${serializeChildrenToHTMLString(children).trim()}\n`;\n }\n return serializeChildrenToHTMLString(children);\n },\n paragraph({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}\n`;\n },\n heading({ node, children }) {\n const level = node.attrs.level;\n return `${new Array(level).fill(\"#\").join(\"\")} ${children}\n`;\n },\n codeBlock({ node, children }) {\n return `\n\\`\\`\\`${node.attrs.language}\n${serializeChildrenToHTMLString(children)}\n\\`\\`\\`\n`;\n },\n blockquote({ children }) {\n return `\n${serializeChildrenToHTMLString(children).trim().split(\"\\n\").map((a) => `> ${a}`).join(\"\\n\")}`;\n },\n image({ node }) {\n return `![${node.attrs.alt}](${node.attrs.src})`;\n },\n hardBreak() {\n return \"\\n\";\n },\n horizontalRule() {\n return \"\\n---\\n\";\n },\n table({ children, node }) {\n if (!Array.isArray(children)) {\n return `\n${serializeChildrenToHTMLString(children)}\n`;\n }\n const columnCount = node.children[0].childCount;\n return `\n${serializeChildrenToHTMLString(children[0])}| ${new Array(columnCount).fill(\"---\").join(\" | \")} |\n${serializeChildrenToHTMLString(children.slice(1))}\n`;\n },\n tableRow({ children }) {\n if (Array.isArray(children)) {\n return `| ${children.join(\" | \")} |\n`;\n }\n return `${serializeChildrenToHTMLString(children)}\n`;\n },\n tableHeader({ children }) {\n return serializeChildrenToHTMLString(children).trim();\n },\n tableCell({ children }) {\n return serializeChildrenToHTMLString(children).trim();\n },\n ...options == null ? void 0 : options.nodeMapping\n },\n markMapping: {\n bold({ children }) {\n return `**${serializeChildrenToHTMLString(children)}**`;\n },\n italic({ children, node }) {\n let isBoldToo = false;\n if (node == null ? void 0 : node.marks.some((m) => m.type.name === \"bold\")) {\n isBoldToo = true;\n }\n if (isBoldToo) {\n return `*${serializeChildrenToHTMLString(children)}*`;\n }\n return `_${serializeChildrenToHTMLString(children)}_`;\n },\n code({ children }) {\n return `\\`${serializeChildrenToHTMLString(children)}\\``;\n },\n strike({ children }) {\n return `~~${serializeChildrenToHTMLString(children)}~~`;\n },\n underline({ children }) {\n return `<u>${serializeChildrenToHTMLString(children)}</u>`;\n },\n subscript({ children }) {\n return `<sub>${serializeChildrenToHTMLString(children)}</sub>`;\n },\n superscript({ children }) {\n return `<sup>${serializeChildrenToHTMLString(children)}</sup>`;\n },\n link({ mark, children }) {\n return `[${serializeChildrenToHTMLString(children)}](${mark.attrs.href})`;\n },\n highlight({ children }) {\n return `==${serializeChildrenToHTMLString(children)}==`;\n },\n ...options == null ? void 0 : options.markMapping\n }\n }\n });\n}\nexport {\n mapMarkExtensionToReactNode,\n mapNodeExtensionToReactNode,\n renderToElement,\n renderToMarkdown\n};\n//# sourceMappingURL=index.js.map","import { renderToMarkdown } from '@tiptap/static-renderer/pm/markdown';\nimport { codeToEmojiData, stringToUnicode } from '@/common/emoji';\n\n// The pm/markdown renderer passes children as string[] (one entry per child node),\n// not as a pre-joined string. Normalize to a string before processing.\nconst joinChildren = (children) => Array.isArray(children) ? children.join('') : (children || '');\n\n// Move leading/trailing spaces outside mark delimiters so parsers like CommonMark\n// don't reject them (e.g. \"** bold **\" → \" **bold** \").\nconst wrapMark = (text, open, close) => {\n const trimmed = text.trim();\n if (!trimmed) return text;\n const leading = text.slice(0, text.length - text.trimStart().length);\n const trailing = text.slice(text.trimEnd().length);\n return `${leading}${open}${trimmed}${close}${trailing}`;\n};\n\n/**\n * Renders a TipTap/ProseMirror JSON document to a markdown string.\n *\n * Uses @tiptap/static-renderer with custom mappings to preserve the output\n * format of the legacy jsonToMarkdownConverter, including Dialtone-specific\n * node types (mention, channel, emoji, variable, slash-commands).\n *\n * @param {import('@tiptap/core').JSONContent} jsonContent - TipTap JSON document\n * @param {import('@tiptap/core').Extensions} extensions - Active editor extensions\n * @returns {string}\n */\nexport function renderEditorToMarkdown (jsonContent, extensions) {\n const output = renderToMarkdown({\n extensions,\n content: jsonContent,\n options: {\n nodeMapping: {\n // Override blockquote: built-in omits trailing newline (causes lazy continuation).\n // Since we replace the built-in entirely, we must add the '> ' prefix ourselves.\n blockquote ({ children }) {\n const text = joinChildren(children).trim();\n const quoted = text\n .split('\\n')\n .map(line => line ? `> ${line}` : '>')\n .join('\\n');\n return quoted + '\\n';\n },\n\n // Override codeBlock: built-in passes null language through literally\n codeBlock ({ node, children }) {\n const lang = node.attrs?.language || '';\n return `\\`\\`\\`${lang}\\n${joinChildren(children)}\\n\\`\\`\\`\\n`;\n },\n\n // Custom Dialtone node types\n mention ({ node }) {\n const id = node.attrs?.id || '';\n const contactKey = node.attrs?.contactKey || '';\n const name = node.attrs?.name || '';\n return `<!-- @mention: {\"id\": \"${id}\", \"contactKey\": \"${contactKey}\", \"name\": \"${name}\"} -->`;\n },\n\n channel ({ node }) {\n const id = node.attrs?.id || '';\n const channelKey = node.attrs?.channelKey || '';\n const name = node.attrs?.name || '';\n const locked = String(node.attrs?.locked ?? '');\n return `<!-- @channel: {\"id\": \"${id}\", \"channelKey\": \"${channelKey}\", \"name\": \"${name}\", \"locked\": \"${locked}\"} -->`;\n },\n\n 'slash-commands' ({ node }) {\n return `/${node.attrs?.command || ''}`;\n },\n\n emoji ({ node }) {\n const code = node.attrs?.code;\n if (!code) return '';\n // Always output emoji as unicode characters rather than shortcodes, matching\n // renderText's backwards-compatibility behavior with our backend (see Emoji.js).\n const emojiData = codeToEmojiData(code);\n return emojiData ? stringToUnicode(emojiData.unicode_output) : code;\n },\n\n variable ({ node }) {\n const id = node.attrs?.id || '';\n const altText = node.attrs?.altText || '';\n return `{{${id}=${altText}}}`;\n },\n },\n\n markMapping: {\n bold ({ children }) {\n return wrapMark(joinChildren(children), '**', '**');\n },\n\n // Override italic: use * instead of built-in _ and fix boundary spaces\n italic ({ children }) {\n return wrapMark(joinChildren(children), '*', '*');\n },\n\n strike ({ children }) {\n return wrapMark(joinChildren(children), '~~', '~~');\n },\n\n code ({ children }) {\n return wrapMark(joinChildren(children), '`', '`');\n },\n\n link ({ mark, children }) {\n const text = joinChildren(children);\n const href = mark.attrs?.href || '';\n const trimmed = text.trim();\n const leading = text.slice(0, text.length - text.trimStart().length);\n const trailing = text.slice(text.trimEnd().length);\n return `${leading}[${trimmed}](${href})${trailing}`;\n },\n\n // Override underline: pass-through (no markdown equivalent, matches legacy no-op)\n underline ({ children }) {\n return joinChildren(children);\n },\n },\n },\n });\n // Collapse 3+ consecutive newlines to 2 (CommonMark ignores extra blank\n // lines between blocks), and strip the leading newline that the built-in\n // paragraph renderer always prepends to the first node.\n return output.replace(/\\n{3,}/g, '\\n\\n').replace(/^\\n+|\\n+$/g, '');\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;AAYA,SAAS,EAAc,GAAY,GAAqB,GAAwB;CAC9E,IAAM,IAAuB,EAAW;AAIxC,QAHK,IAGE,EAAoB,QAAQ,MAC7B,EAAK,UAAU,OAAO,EAAW,QAAS,WAAW,EAAW,OAAO,EAAW,KAAK,QAGvF,IACK,EAAK,UAAU,WAEjB,KALE,GAMT,CAAC,KAAK,MACD,EAAK,UAAU,cAKb,EAAK,UAAU,WAAW,EAAqB,IAJ7C,GACJ,EAAK,OAAO,EAAK,QAAQ,IAAuB,EAAqB,EAAK,QAAQ,EAAK,UAAU,SACnG,CAKH,CAAC,QAAQ,GAAY,MAAc,EAAgB,GAAY,EAAU,EAAE,EAAE,CAAC,GAnBvE,EAAE;;AAqBb,SAAS,EAAkB,GAAY,GAAqB;AAC1D,QAAO,EAAc,GAAY,GAAqB,GAAK;;AAI7D,SAAS,EAA4B,GAAwB,GAAW,GAAqB,GAAS;CAOpG,IAAM,IAAe,EAAkB,GAAW,cANlC;EACd,MAAM,EAAU;EAChB,SAAS,EAAU;EACnB,SAAS,EAAU;EACnB,QAAQ,EAAU;EACnB,CACuE;AAcxE,QAbK,IA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B,YAAO,GAFS,EAAK,MAAM,GAAG,EAAK,SAAS,EAAK,WAAW,CAAC,OAAO,CAElD,GAAG,EAAQ,IAAI,EAAK,GADrB,EAAK,MAAM,EAAK,SAAS,CAAC,OAAO;;IAKpD,UAAW,EAAE,eAAY;AACvB,YAAO,EAAa,EAAS;;IAEhC;GACF;EACF,CAAC,CAIY,QAAQ,WAAW,OAAO,CAAC,QAAQ,cAAc,GAAG"}
1
+ {"version":3,"file":"MarkdownRenderer-eMwmPygx.js","names":["Node"],"sources":["../../../node_modules/.pnpm/@tiptap+static-renderer@3.19.0_@tiptap+core@3.19.0_@tiptap+pm@3.19.0__@tiptap+pm@3.19.0_9606d4b01b88c88c850636a0b274a958/node_modules/@tiptap/static-renderer/dist/pm/markdown/index.js","../components/RichTextEditor/MarkdownRenderer.js"],"sourcesContent":["// src/pm/extensionRenderer.ts\nimport {\n getAttributesFromExtensions,\n getExtensionField,\n getSchemaByResolvedExtensions,\n resolveExtensions,\n splitExtensions\n} from \"@tiptap/core\";\nimport { Node } from \"@tiptap/pm/model\";\n\n// src/helpers.ts\nimport { mergeAttributes } from \"@tiptap/core\";\nfunction getAttributes(nodeOrMark, extensionAttributes, onlyRenderedAttributes) {\n const nodeOrMarkAttributes = nodeOrMark.attrs;\n if (!nodeOrMarkAttributes) {\n return {};\n }\n return extensionAttributes.filter((item) => {\n if (item.type !== (typeof nodeOrMark.type === \"string\" ? nodeOrMark.type : nodeOrMark.type.name)) {\n return false;\n }\n if (onlyRenderedAttributes) {\n return item.attribute.rendered;\n }\n return true;\n }).map((item) => {\n if (!item.attribute.renderHTML) {\n return {\n [item.name]: item.name in nodeOrMarkAttributes ? nodeOrMarkAttributes[item.name] : item.attribute.default\n };\n }\n return item.attribute.renderHTML(nodeOrMarkAttributes) || {\n [item.name]: item.name in nodeOrMarkAttributes ? nodeOrMarkAttributes[item.name] : item.attribute.default\n };\n }).reduce((attributes, attribute) => mergeAttributes(attributes, attribute), {});\n}\nfunction getHTMLAttributes(nodeOrMark, extensionAttributes) {\n return getAttributes(nodeOrMark, extensionAttributes, true);\n}\n\n// src/pm/extensionRenderer.ts\nfunction mapNodeExtensionToReactNode(domOutputSpecToElement, extension, extensionAttributes, options) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n parent: extension.parent\n };\n const renderToHTML = getExtensionField(extension, \"renderHTML\", context);\n if (!renderToHTML) {\n if (options == null ? void 0 : options.unhandledNode) {\n return [extension.name, options.unhandledNode];\n }\n return [\n extension.name,\n () => {\n throw new Error(\n `[tiptap error]: Node ${extension.name} cannot be rendered, it is missing a \"renderToHTML\" method, please implement it or override the corresponding \"nodeMapping\" method to have a custom rendering`\n );\n }\n ];\n }\n return [\n extension.name,\n ({ node, children }) => {\n try {\n return domOutputSpecToElement(\n renderToHTML({\n node,\n HTMLAttributes: getHTMLAttributes(node, extensionAttributes)\n })\n )(children);\n } catch (e) {\n throw new Error(\n `[tiptap error]: Node ${extension.name} cannot be rendered, it's \"renderToHTML\" method threw an error: ${e.message}`,\n { cause: e }\n );\n }\n }\n ];\n}\nfunction mapMarkExtensionToReactNode(domOutputSpecToElement, extension, extensionAttributes, options) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n parent: extension.parent\n };\n const renderToHTML = getExtensionField(extension, \"renderHTML\", context);\n if (!renderToHTML) {\n if (options == null ? void 0 : options.unhandledMark) {\n return [extension.name, options.unhandledMark];\n }\n return [\n extension.name,\n () => {\n throw new Error(`Node ${extension.name} cannot be rendered, it is missing a \"renderToHTML\" method`);\n }\n ];\n }\n return [\n extension.name,\n ({ mark, children }) => {\n try {\n return domOutputSpecToElement(\n renderToHTML({\n mark,\n HTMLAttributes: getHTMLAttributes(mark, extensionAttributes)\n })\n )(children);\n } catch (e) {\n throw new Error(\n `[tiptap error]: Mark ${extension.name} cannot be rendered, it's \"renderToHTML\" method threw an error: ${e.message}`,\n { cause: e }\n );\n }\n }\n ];\n}\nfunction renderToElement({\n renderer,\n domOutputSpecToElement,\n mapDefinedTypes,\n content,\n extensions,\n options\n}) {\n extensions = resolveExtensions(extensions);\n const extensionAttributes = getAttributesFromExtensions(extensions);\n const { nodeExtensions, markExtensions } = splitExtensions(extensions);\n if (!(content instanceof Node)) {\n content = Node.fromJSON(getSchemaByResolvedExtensions(extensions), content);\n }\n return renderer({\n ...options,\n nodeMapping: {\n ...Object.fromEntries(\n nodeExtensions.filter((e) => {\n if (e.name in mapDefinedTypes) {\n return false;\n }\n if (options == null ? void 0 : options.nodeMapping) {\n return !(e.name in options.nodeMapping);\n }\n return true;\n }).map(\n (nodeExtension) => mapNodeExtensionToReactNode(domOutputSpecToElement, nodeExtension, extensionAttributes, options)\n )\n ),\n ...mapDefinedTypes,\n ...options == null ? void 0 : options.nodeMapping\n },\n markMapping: {\n ...Object.fromEntries(\n markExtensions.filter((e) => {\n if (options == null ? void 0 : options.markMapping) {\n return !(e.name in options.markMapping);\n }\n return true;\n }).map((mark) => mapMarkExtensionToReactNode(domOutputSpecToElement, mark, extensionAttributes, options))\n ),\n ...options == null ? void 0 : options.markMapping\n }\n })({ content });\n}\n\n// src/json/renderer.ts\nfunction TiptapStaticRenderer(renderComponent, {\n nodeMapping,\n markMapping,\n unhandledNode,\n unhandledMark\n}) {\n return function renderContent({\n content,\n parent\n }) {\n var _a;\n const nodeType = typeof content.type === \"string\" ? content.type : content.type.name;\n const NodeHandler = (_a = nodeMapping[nodeType]) != null ? _a : unhandledNode;\n if (!NodeHandler) {\n throw new Error(`missing handler for node type ${nodeType}`);\n }\n const nodeContent = renderComponent({\n component: NodeHandler,\n props: {\n node: content,\n parent,\n renderElement: renderContent,\n // Lazily compute the children to avoid unnecessary recursion\n get children() {\n const children = [];\n if (content.content) {\n content.content.forEach((child) => {\n children.push(\n renderContent({\n content: child,\n parent: content\n })\n );\n });\n }\n return children;\n }\n }\n });\n const markedContent = content.marks ? content.marks.reduce((acc, mark) => {\n var _a2;\n const markType = typeof mark.type === \"string\" ? mark.type : mark.type.name;\n const MarkHandler = (_a2 = markMapping[markType]) != null ? _a2 : unhandledMark;\n if (!MarkHandler) {\n throw new Error(`missing handler for mark type ${markType}`);\n }\n return renderComponent({\n component: MarkHandler,\n props: {\n mark,\n parent,\n node: content,\n children: acc\n }\n });\n }, nodeContent) : nodeContent;\n return markedContent;\n };\n}\n\n// src/json/html-string/string.ts\nfunction renderJSONContentToString(options) {\n return TiptapStaticRenderer((ctx) => {\n return ctx.component(ctx.props);\n }, options);\n}\nfunction serializeAttrsToHTMLString(attrs) {\n const output = Object.entries(attrs || {}).map(([key, value]) => `${key.split(\" \").at(-1)}=${JSON.stringify(value)}`).join(\" \");\n return output ? ` ${output}` : \"\";\n}\nfunction serializeChildrenToHTMLString(children) {\n return [].concat(children || \"\").filter(Boolean).join(\"\");\n}\n\n// src/pm/html-string/html-string.ts\nvar NON_SELF_CLOSING_TAGS = /* @__PURE__ */ new Set([\"iframe\", \"script\", \"style\", \"title\", \"textarea\", \"div\", \"span\", \"a\", \"button\"]);\nfunction domOutputSpecToHTMLString(content) {\n if (typeof content === \"string\") {\n return () => content;\n }\n if (typeof content === \"object\" && \"length\" in content) {\n const [_tag, attrs, children, ...rest] = content;\n let tag = _tag;\n const parts = tag.split(\" \");\n if (parts.length > 1) {\n tag = `${parts[1]} xmlns=\"${parts[0]}\"`;\n }\n if (attrs === void 0) {\n return () => `<${tag}/>`;\n }\n if (attrs === 0) {\n return (child) => `<${tag}>${serializeChildrenToHTMLString(child)}</${tag}>`;\n }\n if (typeof attrs === \"object\") {\n if (Array.isArray(attrs)) {\n if (children === void 0) {\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}</${tag}>`;\n }\n if (children === 0) {\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}</${tag}>`;\n }\n return (child) => `<${tag}>${domOutputSpecToHTMLString(attrs)(child)}${[children].concat(rest).map((a) => domOutputSpecToHTMLString(a)(child))}</${tag}>`;\n }\n if (children === void 0) {\n if (NON_SELF_CLOSING_TAGS.has(tag)) {\n return () => `<${tag}${serializeAttrsToHTMLString(attrs)}></${tag}>`;\n }\n return () => `<${tag}${serializeAttrsToHTMLString(attrs)}/>`;\n }\n if (children === 0) {\n return (child) => `<${tag}${serializeAttrsToHTMLString(attrs)}>${serializeChildrenToHTMLString(child)}</${tag}>`;\n }\n return (child) => `<${tag}${serializeAttrsToHTMLString(attrs)}>${[children].concat(rest).map((a) => domOutputSpecToHTMLString(a)(child)).join(\"\")}</${tag}>`;\n }\n }\n throw new Error(\n \"[tiptap error]: Unsupported DomOutputSpec type, check the `renderHTML` method output or implement a node mapping\",\n {\n cause: content\n }\n );\n}\nfunction renderToHTMLString({\n content,\n extensions,\n options\n}) {\n return renderToElement({\n renderer: renderJSONContentToString,\n domOutputSpecToElement: domOutputSpecToHTMLString,\n mapDefinedTypes: {\n // Map a doc node to concatenated children\n doc: ({ children }) => serializeChildrenToHTMLString(children),\n // Map a text node to its text content\n text: ({ node }) => {\n var _a;\n return (_a = node.text) != null ? _a : \"\";\n }\n },\n content,\n extensions,\n options\n });\n}\n\n// src/pm/markdown/markdown.ts\nfunction renderToMarkdown({\n content,\n extensions,\n options\n}) {\n return renderToHTMLString({\n content,\n extensions,\n options: {\n ...options,\n nodeMapping: {\n bulletList({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}`;\n },\n orderedList({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}`;\n },\n listItem({ node, children, parent }) {\n if ((parent == null ? void 0 : parent.type.name) === \"bulletList\") {\n return `- ${serializeChildrenToHTMLString(children).trim()}\n`;\n }\n if ((parent == null ? void 0 : parent.type.name) === \"orderedList\") {\n let number = parent.attrs.start || 1;\n parent.forEach((parentChild, _offset, index) => {\n if (node === parentChild) {\n number = index + 1;\n }\n });\n return `${number}. ${serializeChildrenToHTMLString(children).trim()}\n`;\n }\n return serializeChildrenToHTMLString(children);\n },\n paragraph({ children }) {\n return `\n${serializeChildrenToHTMLString(children)}\n`;\n },\n heading({ node, children }) {\n const level = node.attrs.level;\n return `${new Array(level).fill(\"#\").join(\"\")} ${children}\n`;\n },\n codeBlock({ node, children }) {\n return `\n\\`\\`\\`${node.attrs.language}\n${serializeChildrenToHTMLString(children)}\n\\`\\`\\`\n`;\n },\n blockquote({ children }) {\n return `\n${serializeChildrenToHTMLString(children).trim().split(\"\\n\").map((a) => `> ${a}`).join(\"\\n\")}`;\n },\n image({ node }) {\n return `![${node.attrs.alt}](${node.attrs.src})`;\n },\n hardBreak() {\n return \"\\n\";\n },\n horizontalRule() {\n return \"\\n---\\n\";\n },\n table({ children, node }) {\n if (!Array.isArray(children)) {\n return `\n${serializeChildrenToHTMLString(children)}\n`;\n }\n const columnCount = node.children[0].childCount;\n return `\n${serializeChildrenToHTMLString(children[0])}| ${new Array(columnCount).fill(\"---\").join(\" | \")} |\n${serializeChildrenToHTMLString(children.slice(1))}\n`;\n },\n tableRow({ children }) {\n if (Array.isArray(children)) {\n return `| ${children.join(\" | \")} |\n`;\n }\n return `${serializeChildrenToHTMLString(children)}\n`;\n },\n tableHeader({ children }) {\n return serializeChildrenToHTMLString(children).trim();\n },\n tableCell({ children }) {\n return serializeChildrenToHTMLString(children).trim();\n },\n ...options == null ? void 0 : options.nodeMapping\n },\n markMapping: {\n bold({ children }) {\n return `**${serializeChildrenToHTMLString(children)}**`;\n },\n italic({ children, node }) {\n let isBoldToo = false;\n if (node == null ? void 0 : node.marks.some((m) => m.type.name === \"bold\")) {\n isBoldToo = true;\n }\n if (isBoldToo) {\n return `*${serializeChildrenToHTMLString(children)}*`;\n }\n return `_${serializeChildrenToHTMLString(children)}_`;\n },\n code({ children }) {\n return `\\`${serializeChildrenToHTMLString(children)}\\``;\n },\n strike({ children }) {\n return `~~${serializeChildrenToHTMLString(children)}~~`;\n },\n underline({ children }) {\n return `<u>${serializeChildrenToHTMLString(children)}</u>`;\n },\n subscript({ children }) {\n return `<sub>${serializeChildrenToHTMLString(children)}</sub>`;\n },\n superscript({ children }) {\n return `<sup>${serializeChildrenToHTMLString(children)}</sup>`;\n },\n link({ mark, children }) {\n return `[${serializeChildrenToHTMLString(children)}](${mark.attrs.href})`;\n },\n highlight({ children }) {\n return `==${serializeChildrenToHTMLString(children)}==`;\n },\n ...options == null ? void 0 : options.markMapping\n }\n }\n });\n}\nexport {\n mapMarkExtensionToReactNode,\n mapNodeExtensionToReactNode,\n renderToElement,\n renderToMarkdown\n};\n//# sourceMappingURL=index.js.map","import { renderToMarkdown } from '@tiptap/static-renderer/pm/markdown';\nimport { codeToEmojiData, stringToUnicode } from '@/common/emoji';\n\n// The pm/markdown renderer passes children as string[] (one entry per child node),\n// not as a pre-joined string. Normalize to a string before processing.\nconst joinChildren = (children) => Array.isArray(children) ? children.join('') : (children || '');\n\n// Move leading/trailing spaces outside mark delimiters so parsers like CommonMark\n// don't reject them (e.g. \"** bold **\" → \" **bold** \").\nconst wrapMark = (text, open, close) => {\n const trimmed = text.trim();\n if (!trimmed) return text;\n const leading = text.slice(0, text.length - text.trimStart().length);\n const trailing = text.slice(text.trimEnd().length);\n return `${leading}${open}${trimmed}${close}${trailing}`;\n};\n\n/**\n * Renders a TipTap/ProseMirror JSON document to a markdown string.\n *\n * Uses @tiptap/static-renderer with custom mappings to preserve the output\n * format of the legacy jsonToMarkdownConverter, including Dialtone-specific\n * node types (mention, channel, emoji, variable, slash-commands).\n *\n * @param {import('@tiptap/core').JSONContent} jsonContent - TipTap JSON document\n * @param {import('@tiptap/core').Extensions} extensions - Active editor extensions\n * @returns {string}\n */\nexport function renderEditorToMarkdown (jsonContent, extensions) {\n const output = renderToMarkdown({\n extensions,\n content: jsonContent,\n options: {\n nodeMapping: {\n // Override blockquote: built-in omits trailing newline (causes lazy continuation).\n // Since we replace the built-in entirely, we must add the '> ' prefix ourselves.\n blockquote ({ children }) {\n const text = joinChildren(children).trim();\n const quoted = text\n .split('\\n')\n .map(line => line ? `> ${line}` : '>')\n .join('\\n');\n return quoted + '\\n';\n },\n\n // Override codeBlock: built-in passes null language through literally\n codeBlock ({ node, children }) {\n const lang = node.attrs?.language || '';\n return `\\`\\`\\`${lang}\\n${joinChildren(children)}\\n\\`\\`\\`\\n`;\n },\n\n // Custom Dialtone node types\n mention ({ node }) {\n const id = node.attrs?.id || '';\n const contactKey = node.attrs?.contactKey || '';\n const name = node.attrs?.name || '';\n return `<!-- @mention: {\"id\": \"${id}\", \"contactKey\": \"${contactKey}\", \"name\": \"${name}\"} -->`;\n },\n\n channel ({ node }) {\n const id = node.attrs?.id || '';\n const channelKey = node.attrs?.channelKey || '';\n const name = node.attrs?.name || '';\n const locked = String(node.attrs?.locked ?? '');\n return `<!-- @channel: {\"id\": \"${id}\", \"channelKey\": \"${channelKey}\", \"name\": \"${name}\", \"locked\": \"${locked}\"} -->`;\n },\n\n 'slash-commands' ({ node }) {\n return `/${node.attrs?.command || ''}`;\n },\n\n emoji ({ node }) {\n const code = node.attrs?.code;\n if (!code) return '';\n // Always output emoji as unicode characters rather than shortcodes, matching\n // renderText's backwards-compatibility behavior with our backend (see Emoji.js).\n const emojiData = codeToEmojiData(code);\n return emojiData ? stringToUnicode(emojiData.unicode_output) : code;\n },\n\n variable ({ node }) {\n const id = node.attrs?.id || '';\n const altText = node.attrs?.altText || '';\n return `{{${id}=${altText}}}`;\n },\n },\n\n markMapping: {\n bold ({ children }) {\n return wrapMark(joinChildren(children), '**', '**');\n },\n\n // Override italic: use * instead of built-in _ and fix boundary spaces\n italic ({ children }) {\n return wrapMark(joinChildren(children), '*', '*');\n },\n\n strike ({ children }) {\n return wrapMark(joinChildren(children), '~~', '~~');\n },\n\n code ({ children }) {\n return wrapMark(joinChildren(children), '`', '`');\n },\n\n link ({ mark, children }) {\n const text = joinChildren(children);\n const href = mark.attrs?.href || '';\n const trimmed = text.trim();\n const leading = text.slice(0, text.length - text.trimStart().length);\n const trailing = text.slice(text.trimEnd().length);\n return `${leading}[${trimmed}](${href})${trailing}`;\n },\n\n // Override underline: pass-through (no markdown equivalent, matches legacy no-op)\n underline ({ children }) {\n return joinChildren(children);\n },\n },\n },\n });\n // Collapse 3+ consecutive newlines to 2 (CommonMark ignores extra blank\n // lines between blocks), and strip the leading newline that the built-in\n // paragraph renderer always prepends to the first node.\n return output.replace(/\\n{3,}/g, '\\n\\n').replace(/^\\n+|\\n+$/g, '');\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;AAYA,SAAS,EAAc,GAAY,GAAqB,GAAwB;CAC9E,IAAM,IAAuB,EAAW;AAIxC,QAHK,IAGE,EAAoB,QAAQ,MAC7B,EAAK,UAAU,OAAO,EAAW,QAAS,WAAW,EAAW,OAAO,EAAW,KAAK,QAGvF,IACK,EAAK,UAAU,WAEjB,KALE,GAMT,CAAC,KAAK,MACD,EAAK,UAAU,cAKb,EAAK,UAAU,WAAW,EAAqB,IAJ7C,GACJ,EAAK,OAAO,EAAK,QAAQ,IAAuB,EAAqB,EAAK,QAAQ,EAAK,UAAU,SACnG,CAKH,CAAC,QAAQ,GAAY,MAAc,EAAgB,GAAY,EAAU,EAAE,EAAE,CAAC,GAnBvE,EAAE;;AAqBb,SAAS,EAAkB,GAAY,GAAqB;AAC1D,QAAO,EAAc,GAAY,GAAqB,GAAK;;AAI7D,SAAS,EAA4B,GAAwB,GAAW,GAAqB,GAAS;CAOpG,IAAM,IAAe,EAAkB,GAAW,cANlC;EACd,MAAM,EAAU;EAChB,SAAS,EAAU;EACnB,SAAS,EAAU;EACnB,QAAQ,EAAU;EACnB,CACuE;AAcxE,QAbK,IAaE,CACL,EAAU,OACT,EAAE,SAAM,kBAAe;AACtB,MAAI;AACF,UAAO,EACL,EAAa;IACX;IACA,gBAAgB,EAAkB,GAAM,EAAoB;IAC7D,CAAC,CACH,CAAC,EAAS;WACJ,GAAG;AACV,SAAU,MACR,wBAAwB,EAAU,KAAK,kEAAkE,EAAE,WAC3G,EAAE,OAAO,GAAG,CACb;;GAGN,GA7BK,GAAmC,gBAC9B,CAAC,EAAU,MAAM,EAAQ,cAAc,GAEzC,CACL,EAAU,YACJ;AACJ,QAAU,MACR,wB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index.cjs`),n=require(`./_plugin-vue_export-helper-D8jCH6HB.cjs`),r=require(`./common/emoji/index.cjs`),i=require(`./lib/avatar/avatar.cjs`),a=require(`./lib/badge/badge.cjs`),o=require(`./lib/text/text.cjs`),s=require(`./lib/link/link.cjs`),c=require(`./localization/index.cjs`),l=require(`./lib/button/button.cjs`),u=require(`./lib/list-item/list-item.cjs`),d=require(`./lib/stack/stack.cjs`),f=require(`./lib/popover/popover.cjs`),p=require(`./lib/emoji/emoji.cjs`),ee=require(`./lib/input/input.cjs`),m=require(`./node_modules/@tiptap/vue-3.cjs`),h=require(`./floating-ui.dom-D2zQ_96p.cjs`),te=require(`./ForceLinkify-kQ_kWKVm.cjs`),g=require(`./lib/rich-text-editor/rich-text-editor-constants.cjs`),_=require(`./MarkdownRenderer-C5wdjC5_.cjs`);let v=require(`vue`),ne=require(`@dialpad/dialtone-icons/vue`),y=require(`regex-combined-emojis`),b=require(`@tiptap/core`),x=require(`@tiptap/pm/state`),re=require(`@tiptap/pm/tables`),S=require(`@tiptap/extension-blockquote`);S=e.t(S);let C=require(`@tiptap/extension-code-block`);C=e.t(C);let w=require(`@tiptap/extension-code`);w=e.t(w);let T=require(`@tiptap/extension-document`);T=e.t(T);let E=require(`@tiptap/extensions`),D=require(`@tiptap/extension-hard-break`);D=e.t(D);let O=require(`@tiptap/extension-paragraph`);O=e.t(O);let k=require(`@tiptap/extension-bold`);k=e.t(k);let A=require(`@tiptap/extension-list`),j=require(`@tiptap/extension-italic`);j=e.t(j);let M=require(`@tiptap/extension-link`);M=e.t(M);let N=require(`@tiptap/extension-strike`);N=e.t(N);let P=require(`@tiptap/extension-underline`);P=e.t(P);let F=require(`@tiptap/extension-text`);F=e.t(F);let I=require(`@tiptap/extension-text-align`);I=e.t(I);let L=require(`@tiptap/extension-table`),R=require(`@tiptap/extension-text-style`),z=require(`@tiptap/suggestion`);z=e.t(z);let B=require(`@tiptap/extension-image`);B=e.t(B);let V=require(`@tiptap/extension-mention`);V=e.t(V);let H=require(`@dialpad/dialtone-icons/vue/hash`);H=e.t(H);let U=require(`@dialpad/dialtone-icons/vue/lock`);U=e.t(U);let W=require(`deep-equal`);W=e.t(W);function ie(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var ae=class{constructor({editor:e,element:t,view:n,updateDelay:r=250,resizeDelay:i=60,shouldShow:a,appendTo:o,getReferencedVirtualElement:s,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&(0,b.isTextSelection)(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);!n&&!r||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(`bubbleMenu`);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`&&this.updateOptions(t.options)},this.editor=e,this.element=t,this.view=n,this.updateDelay=r,this.resizeDelay=i,this.appendTo=o,this.scrollTarget=c?.scrollTarget??window,this.getReferencedVirtualElement=s,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,a&&(this.shouldShow=a),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(h.a(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(h.l(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(h.c(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(h.t(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(h.u(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(h.n(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(h.o(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(h.s(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){let{selection:e}=this.editor.state,t=this.getReferencedVirtualElement?.call(this);if(t)return t;if(!this.view?.dom?.parentNode)return;let n=(0,b.posToDOMRect)(this.view,e.from,e.to),r={getBoundingClientRect:()=>n,getClientRects:()=>[n]};if(e instanceof x.NodeSelection){let t=this.view.nodeDOM(e.from),n=t.dataset.nodeViewWrapper?t:t.querySelector(`[data-node-view-wrapper]`);n&&(t=n),t&&(r={getBoundingClientRect:()=>t.getBoundingClientRect(),getClientRects:()=>[t.getBoundingClientRect()]})}if(e instanceof re.CellSelection){let{$anchorCell:t,$headCell:n}=e,i=t?t.pos:n.pos,a=n?n.pos:t.pos,o=this.view.nodeDOM(i),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():ie(o.getBoundingClientRect(),s.getBoundingClientRect());r={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return r}updatePosition(){let e=this.virtualElement;e&&h.i(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},oe=e=>new x.Plugin({key:typeof e.pluginKey==`string`?new x.PluginKey(e.pluginKey):e.pluginKey,view:t=>new ae({view:t,...e})}),se=(0,v.defineComponent)({name:`BubbleMenu`,inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:`bubbleMenu`},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(e,{slots:t,attrs:n}){let r=(0,v.ref)(null);return(0,v.onMounted)(()=>{let{editor:t,options:n,pluginKey:i,resizeDelay:a,appendTo:o,shouldShow:s,getReferencedVirtualElement:c,updateDelay:l}=e,u=r.value;u&&(u.style.visibility=`hidden`,u.style.position=`absolute`,u.remove(),(0,v.nextTick)(()=>{t.registerPlugin(oe({editor:t,element:u,options:n,pluginKey:i,resizeDelay:a,appendTo:o,shouldShow:s,getReferencedVirtualElement:c,updateDelay:l}))}))}),(0,v.onBeforeUnmount)(()=>{let{pluginKey:t,editor:n}=e;n.unregisterPlugin(t)}),()=>(0,v.h)(`div`,{ref:r,...n},t.default?.call(t))}}),ce=class{constructor({editor:e,element:t,view:n,updateDelay:r=250,resizeDelay:i=60,options:a,appendTo:o,shouldShow:s}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:e,state:t})=>{let{selection:n}=t,{$anchor:r,empty:i}=n,a=r.depth===1,o=r.parent.isTextblock&&!r.parent.type.spec.code&&!r.parent.textContent&&r.parent.childCount===0&&!this.getTextContent(r.parent);return!(!e.hasFocus()||!i||!a||!o||!this.editor.isEditable)},this.floatingUIOptions={strategy:`absolute`,placement:`right`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;if(!(i||!t&&!n)){if(!this.getShouldShow(r)){this.hide();return}this.updatePosition(),this.show()}},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{if(this.preventHide){this.preventHide=!1;return}e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(`floatingMenu`);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`&&this.updateOptions(t.options)},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.editor=e,this.element=t,this.view=n,this.updateDelay=r,this.resizeDelay=i,this.appendTo=o,this.scrollTarget=a?.scrollTarget??window,this.floatingUIOptions={...this.floatingUIOptions,...a},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return(0,b.getText)(e,{textSerializers:(0,b.getTextSerializersFromSchema)(this.editor.schema)})}get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(h.a(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(h.l(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(h.c(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(h.t(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(h.u(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(h.n(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(h.o(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(h.s(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,view:this.view,state:t,oldState:e,from:i,to:a})}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){let{selection:e}=this.editor.state,t=(0,b.posToDOMRect)(this.view,e.from,e.to);h.i({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{if(r.hide?.referenceHidden||r.hide?.escaped){this.element.style.visibility=`hidden`;return}this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);this.updateHandler(e,n,r,t)}show(){var e;this.isVisible||(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0)}hide(){this.isVisible&&(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},le=e=>new x.Plugin({key:typeof e.pluginKey==`string`?new x.PluginKey(e.pluginKey):e.pluginKey,view:t=>new ce({view:t,...e})});(0,v.defineComponent)({name:`FloatingMenu`,inheritAttrs:!1,props:{pluginKey:{type:null,default:`floatingMenu`},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null}},setup(e,{slots:t,attrs:n}){let r=(0,v.ref)(null);return(0,v.onMounted)(()=>{let{pluginKey:t,editor:n,updateDelay:i,resizeDelay:a,options:o,appendTo:s,shouldShow:c}=e,l=r.value;l&&(l.style.visibility=`hidden`,l.style.position=`absolute`,l.remove(),n.registerPlugin(le({pluginKey:t,editor:n,element:l,updateDelay:i,resizeDelay:a,options:o,appendTo:s,shouldShow:c})))}),(0,v.onBeforeUnmount)(()=>{let{pluginKey:t,editor:n}=e;n.unregisterPlugin(t)}),()=>(0,v.h)(`div`,{ref:r,...n},t.default?.call(t))}});var G=e=>({default:null,parseHTML:t=>t.getAttribute(e),renderHTML:t=>t[e]?{[e]:t[e]}:{}}),ue=()=>{let e=G(`style`);return e.renderHTML=e=>e.style?{style:de(e.style)}:{},e};function de(e){return e.replace(/(?<![a-z-])width\s*:\s*([^;]+);?/gi,(e,t)=>/^\s*0\s*[a-z%]*\s*(!important)?\s*$/i.test(t)?`width: 100%;`:e)}var fe=L.Table.extend({addAttributes(){return{...this.parent?.(),border:G(`border`),cellpadding:G(`cellpadding`),cellspacing:G(`cellspacing`),style:ue()}},renderHTML({HTMLAttributes:e}){return[`table`,(0,b.mergeAttributes)(this.options.HTMLAttributes,e),[`tbody`,0]]}}),pe=L.TableRow.extend({addAttributes(){return{...this.parent?.(),style:G(`style`)}}}),K={style:G(`style`),valign:G(`valign`),width:G(`width`)},me=L.TableCell.extend({addAttributes(){return{...this.parent?.(),...K}}}),he=L.TableHeader.extend({addAttributes(){return{...this.parent?.(),...K}}}),ge=R.TextStyle.extend({parseHTML(){return[...this.parent?.()||[],{tag:`div`,consuming:!1,getAttrs:e=>e.hasAttribute(`style`)?{}:!1},{tag:`a`,consuming:!1,getAttrs:e=>e.hasAttribute(`style`)?{}:!1}]}}),_e={name:`EmojiComponent`,components:{NodeViewWrapper:m.NodeViewWrapper,DtEmoji:p.default},props:m.nodeViewProps};function ve(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-emoji`),s=(0,v.resolveComponent)(`node-view-wrapper`);return(0,v.openBlock)(),(0,v.createBlock)(s,{class:`d-d-inline-block d-va-bottom d-lh0`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(o,{size:`500`,code:e.node.attrs.code},null,8,[`code`])]),_:1})}var ye=n.t(_e,[[`render`,ve]]),be={name:`SuggestionList`,components:{DtListItem:u.default},props:{items:{type:Array,required:!0},command:{type:Function,required:!0},itemComponent:{type:Object,required:!0},itemType:{type:String,required:!0}},data(){return{selectedIndex:0}},watch:{items(){this.selectedIndex=0}},methods:{onKeyDown({event:e}){return e.key===`ArrowUp`?(this.upHandler(),!0):e.key===`ArrowDown`?(this.downHandler(),!0):e.key===`Enter`||e.key===`Tab`?(this.selectHandler(),!0):!1},upHandler(){this.selectedIndex=(this.selectedIndex+this.items.length-1)%this.items.length,this.scrollActiveElementIntoView()},downHandler(){this.selectedIndex=(this.selectedIndex+1)%this.items.length,this.scrollActiveElementIntoView()},async scrollActiveElementIntoView(){await this.$nextTick();let e=this.$refs.suggestionList.querySelector(`.d-list-item--highlighted`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},selectHandler(){this.selectItem(this.selectedIndex)},selectItem(e){let t=this.items[e];switch(this.itemType){case`emoji`:this.command(t);return;case`mention`:this.command({name:t.name,id:t.id,avatarSrc:t.avatarSrc,contactKey:t.contactKey});break;case`channel`:this.command({name:t.name,id:t.id,locked:t.locked,channelKey:t.channelKey});break;case`slash-command`:this.command({command:t.command});break}}}},xe={class:`d-popover__dialog d-suggestion-list__container`},Se={ref:`suggestionList`,class:`d-suggestion-list`};function Ce(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-list-item`);return(0,v.openBlock)(),(0,v.createElementBlock)(`div`,xe,[(0,v.withDirectives)((0,v.createElementVNode)(`ul`,Se,[((0,v.openBlock)(!0),(0,v.createElementBlock)(v.Fragment,null,(0,v.renderList)(n.items,(e,t)=>((0,v.openBlock)(),(0,v.createBlock)(o,{key:e.id,class:(0,v.normalizeClass)([`d-suggestion-list__item`,{"d-list-item--highlighted":t===i.selectedIndex}]),"navigation-type":`arrow-keys`,onClick:e=>a.selectItem(t),onKeydown:(0,v.withModifiers)(a.onKeyDown,[`prevent`])},{default:(0,v.withCtx)(()=>[((0,v.openBlock)(),(0,v.createBlock)((0,v.resolveDynamicComponent)(n.itemComponent),{item:e},null,8,[`item`]))]),_:2},1032,[`class`,`onClick`,`onKeydown`]))),128))],512),[[v.vShow,n.items.length]])])}var we=n.t(be,[[`render`,Ce]]),q=`top-start`;function Te(){return{getBoundingClientRect:()=>({width:0,height:0,x:0,y:0,top:0,left:0,right:0,bottom:0})}}function J(e){return{getBoundingClientRect:e}}async function Ee(e,t,n={}){if(!e||!t?.getBoundingClientRect)return;let{placement:r=q,middleware:i=[h.c(0),h.a(),h.l({padding:8})]}=n,{x:a,y:o}=await h.i(t,e,{placement:r,middleware:i});Object.assign(e.style,{left:`${a}px`,top:`${o}px`})}function De(e,t={}){let{zIndex:n=`650`}=t;e.style.position=`absolute`,e.style.zIndex=n,e.style.display=`none`}function Oe(e){e&&(e.style.display=`block`)}function ke(e){e&&(e.style.display=`none`)}function Ae(e,t){return n=>{n.key===`Escape`&&t()&&e()}}function je(e){document.addEventListener(`keydown`,e)}function Me(e){document.removeEventListener(`keydown`,e)}function Ne(e,t,n,r){return new m.VueRenderer(e,{props:{itemComponent:(0,v.markRaw)(t),itemType:n,...r},editor:r.editor})}function Pe(e){e.escHandler&&Me(e.escHandler),e.floatingEl?.remove(),e.component?.destroy()}function Y(e,t,n={}){let{listComponent:r=we,placement:i=q,zIndex:a=`650`}=n;return()=>{let n=null,o=null,s=!1,c=Te(),l=null;function u(){Ee(o,c,{placement:i})}function d(){o&&(Oe(o),s=!0,u())}function f(){o&&(ke(o),s=!1)}return{onStart:i=>{n=Ne(r,e,t,i),i.clientRect&&(o=n.element,De(o,{zIndex:a}),document.body.appendChild(o),c=J(i.clientRect),l=Ae(f,()=>s),je(l),i.items.length>0&&d())},onUpdate(e){n?.updateProps(e),e.items.length>0?d():f(),e.clientRect&&(c=J(e.clientRect),u())},onKeyDown(e){if(s)return n?.ref?.onKeyDown(e)},onExit(){Pe({escHandler:l,floatingEl:o,component:n}),l=null,o=null,n=null}}}}var Fe={name:`EmojiSuggestion`,components:{DtEmoji:p.default,DtStack:d.default},props:{item:{type:Object,required:!0}}};function Ie(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-emoji`),s=(0,v.resolveComponent)(`dt-stack`);return(0,v.openBlock)(),(0,v.createBlock)(s,{direction:`row`,gap:`100`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(o,{size:`200`,code:n.item.code},null,8,[`code`]),(0,v.createTextVNode)(` `+(0,v.toDisplayString)(n.item.code),1)]),_:1})}var Le=n.t(Fe,[[`render`,Ie]]),Re=20,ze=(e,t,n)=>{let r=e.shortname?.replaceAll(`:`,``),i=t.shortname?.replaceAll(`:`,``),a=r.startsWith(n),o=i.startsWith(n);return a&&!o?-1:!a&&o?1:r.localeCompare(i)},Be={items:({query:e})=>{if(e.length<2)return[];let t=Object.values(r.getEmojiData());return e=e.toLowerCase(),t.filter(t=>[t.name,t.shortname?.replaceAll(`:`,``),...t.keywords||[]].some(t=>t&&t.startsWith(e))).splice(0,Re).sort((t,n)=>ze(t,n,e)).map(e=>({code:e.shortname}))},command:({editor:e,range:t,props:n})=>{e.view.state.selection.$to.nodeAfter?.text?.startsWith(` `)&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:`emoji`,attrs:n}]).run(),window.getSelection()?.collapseToEnd()},render:Y(Le,`emoji`)},Ve=/(:\w+:)$/,He=RegExp(y.emojiPattern+`$`),Ue=e=>{if(e&&r.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},We=e=>[...e.matchAll(r.emojiShortCodeRegex)].filter(e=>r.codeToEmojiData(e[0])).map(e=>({index:e.index,text:e[0],match:e})),Ge=b.Node.create({name:`emoji`,addOptions(){return{HTMLAttributes:{}}},group:`inline`,inline:!0,selectable:!1,atom:!0,addNodeView(){return m.VueNodeViewRenderer(ye)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:`emoji-component`}]},renderText({node:e}){let t=e.attrs.code??``,n=t?r.codeToEmojiData(t):void 0;return n?r.stringToUnicode(n.unicode_output):t},renderHTML({HTMLAttributes:e}){return[`emoji-component`,(0,b.mergeAttributes)(this.options.HTMLAttributes,e)]},addInputRules(){return[new b.InputRule({find:e=>{let t=e.match(Ve)||e.match(He);if(t)return Ue(t)},handler:({state:e,range:t,match:n})=>{let{tr:r}=e,i=t.from,a=t.to;r.replaceWith(i,a,this.type.create({code:n[0]}))}})]},addPasteRules(){return[(0,b.nodePasteRule)({find:We,type:this.type,getAttributes(e){return{code:e[0]}}}),(0,b.nodePasteRule)({find:r.emojiRegex,type:this.type,getAttributes(e){return{code:e[0]}}})]},addProseMirrorPlugins(){return[(0,z.default)({char:`:`,pluginKey:new x.PluginKey(`emoji`),editor:this.editor,...this.options.suggestion,...Be})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1,{selection:r}=t,{empty:i,anchor:a}=r;return i?(t.doc.nodesBetween(a-1,a,(t,r)=>{if(t.type.name===this.name)return n=!0,e.insertText(``,r,r+t.nodeSize),!1}),n):!1})}}});function Ke(e,t,n=()=>!0){let r=[];t.lastIndex=0;let i;for(;i=t.exec(e);)n(e,i)&&r.push(i);return r}function qe(e,t){return![`#`,`@`].includes(e.charAt(t.index))&&![`#`,`@`].includes(e.charAt(t.index-1))}function Je(e){let t=RegExp(`(?:`+[`[!?.,:;'"]`,`(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$`].join(`|`),`g`);return e.replace(t,``)}function Ye(e,t){let n=e.slice(0,t+1).search(/\S+\s*$/),r=e.slice(t).search(/\s/);if(r<0){let t=e.slice(n);return{text:t,from:n,to:n+t.length}}return{text:e.slice(n,r+t),from:n,to:r+t}}function X(e,t,n,r){let i=Ye(e,t);if(r.lastIndex=0,!r.test(i.text))return i;let a=n===`left`?i.from-1:i.to+1;return a<=0||a>=e.length||a===t?i:X(e,a,n,r)}function Xe(e,t,n,r){let i=(0,b.getMarksBetween)(Math.max(e.from-1,0),Math.min(e.to+1,t.content.size),t);for(let e of i)e.mark.type===r&&n.removeMark(e.from,e.to,r)}var Z=t.getPhoneNumberRegex(1,15);function Q(e,n,r,i,a,o){if(!e)return;let s=r-n-1;s=s<0?0:s;let c=i-n,l=X(e,s,`left`,Z),u=X(e,c,`right`,Z);Ke(e.slice(l.from,u.to),t.linkRegex,qe).forEach(e=>{let t=Je(e[0]),r=n+l.from+e.index+1,i=r+t.length;a.addMark(r,i,o.create())})}function Ze(e){let t=!1;return new x.Plugin({key:new x.PluginKey(`autolink`),appendTransaction:(n,r,i)=>{let a=n.some(e=>e.docChanged)&&!r.doc.eq(i.doc);if(t&&!a)return;let{tr:o}=i,{textContent:s}=i.doc;if(!t||!r.doc.textContent)return Q(s,0,0,s.length,o,e.type),t=!0,o;t=!0;let c=(0,b.getChangedRanges)((0,b.combineTransactionSteps)(r.doc,[...n]));return c.length?(c.forEach(({oldRange:t,newRange:n})=>{if(n.from===n.to){Q(s,0,0,s.length,o,e.type);return}Xe(n,i.doc,o,e.type),(0,b.findChildrenInRange)(i.doc,n,e=>e.isTextblock).forEach(({node:r,pos:i})=>{Q(r.textContent,i,t.from,n.to,o,e.type)})}),o):(Q(s,0,0,s.length,o,e.type),o)}})}var Qe={class:`d-link d-c-text d-d-inline-block d-wb-break-all`,rel:`noopener noreferrer nofollow`},$e=b.Mark.create({name:`CustomLink`,renderHTML({HTMLAttributes:e}){return[`a`,(0,b.mergeAttributes)(this.options.HTMLAttributes,e,Qe)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[Ze({type:this.type})]}}),et=b.Mark.create({name:`LinkPhoneNumbers`,renderHTML({HTMLAttributes:e}){return[`a`,(0,b.mergeAttributes)(e,{class:`d-link d-c-pointer d-d-inline-block d-wb-break-all`,rel:`noopener noreferrer nofollow`})]},addProseMirrorPlugins(){let e=this.editor,t=this.type;return[new x.Plugin({key:new x.PluginKey(`phoneClick`),props:{handleClick(n,r,i){let{state:a}=n,o=a.doc.resolve(r);if(!o.marks().some(e=>e.type===t))return!1;let s=(0,b.getMarkRange)(o,t),c=s?a.doc.textBetween(s.from,s.to):``;return i.preventDefault(),e.emit(`phone-click`,{phoneNumber:c}),!0}}})]}}),tt=B.default.extend({name:`ConfigurableImage`,addAttributes(){return{src:{default:``},alt:{default:void 0},title:{default:void 0},width:{default:void 0},height:{default:void 0},style:{default:void 0}}}}).configure({inline:!0,allowBase64:!0}),nt=new Set(`address.article.aside.blockquote.dd.details.dialog.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hgroup.hr.li.main.nav.ol.p.pre.section.table.ul`.split(`.`)),rt=O.default.extend({parseHTML(){return[{tag:`div`,getAttrs:e=>{for(let t of e.children)if(nt.has(t.tagName.toLowerCase()))return!1;return null}}]},renderHTML({HTMLAttributes:e}){return[`div`,(0,b.mergeAttributes)(this.options.HTMLAttributes,e),0]}}),it={name:`MentionComponent`,components:{NodeViewWrapper:m.NodeViewWrapper,DtLink:s.default},props:m.nodeViewProps,computed:{text(){return`@`+this.$props.node.attrs.name}},methods:{getMentionData(){return{name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,avatarSrc:this.$props.node.attrs.avatarSrc,contactKey:this.$props.node.attrs.contactKey}},handleClick(){this.$props.editor.emit(`mention-click`,this.getMentionData())},handleMouseEnter(e){this.$props.editor.emit(`mention-hover`,{...this.getMentionData(),event:e})},handleMouseLeave(e){this.$props.editor.emit(`mention-leave`,{...this.getMentionData(),event:e})}}};function at(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-link`),s=(0,v.resolveComponent)(`node-view-wrapper`);return(0,v.openBlock)(),(0,v.createBlock)(s,{class:`d-d-inline-block`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(o,{tone:`mention`,onClick:(0,v.withModifiers)(a.handleClick,[`prevent`]),onMouseenter:a.handleMouseEnter,onMouseleave:a.handleMouseLeave,onFocusin:a.handleMouseEnter,onFocusout:a.handleMouseLeave},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.text),1)]),_:1},8,[`onClick`,`onMouseenter`,`onMouseleave`,`onFocusin`,`onFocusout`])]),_:1})}var ot=n.t(it,[[`render`,at]]),st=V.default.extend({addNodeView(){return m.VueNodeViewRenderer(ot)},parseHTML(){return[{tag:`mention-component`}]},addAttributes(){return{name:{default:``},avatarSrc:{default:``},id:{default:``},contactKey:{default:``}}},renderText({node:e}){return`@${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return[`mention-component`,(0,b.mergeAttributes)(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:`@`,pluginKey:new x.PluginKey(`mentionSuggestion`)}}),ct={name:`ChannelComponent`,components:{NodeViewWrapper:m.NodeViewWrapper,DtLink:s.default,DtIconLock:ne.DtIconLock,DtStack:d.default},props:m.nodeViewProps,computed:{text(){return this.$props.node.attrs.locked?this.$props.node.attrs.name:`#`+this.$props.node.attrs.name}},methods:{handleClick(){let e={name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,locked:this.$props.node.attrs.locked,channelKey:this.$props.node.attrs.channelKey};this.$props.editor.emit(`channel-click`,e)}}};function lt(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-icon-lock`),s=(0,v.resolveComponent)(`dt-stack`),c=(0,v.resolveComponent)(`dt-link`),l=(0,v.resolveComponent)(`node-view-wrapper`);return(0,v.openBlock)(),(0,v.createBlock)(l,{class:`d-d-inline-block`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(c,{tone:`mention`,onClick:(0,v.withModifiers)(a.handleClick,[`prevent`])},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(s,{direction:`row`,gap:`0`},{default:(0,v.withCtx)(()=>[e.$props.node.attrs.locked?((0,v.openBlock)(),(0,v.createBlock)(o,{key:0,size:`200`})):(0,v.createCommentVNode)(``,!0),(0,v.createElementVNode)(`span`,null,(0,v.toDisplayString)(a.text),1)]),_:1})]),_:1},8,[`onClick`])]),_:1})}var ut=n.t(ct,[[`render`,lt]]),dt=V.default.extend({name:`channel`,addNodeView(){return m.VueNodeViewRenderer(ut)},parseHTML(){return[{tag:`channel-component`}]},addAttributes(){return{name:{default:``},id:{default:``},locked:{default:!1},channelKey:{default:``}}},renderText({node:e}){return`#${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return[`channel-component`,(0,b.mergeAttributes)(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:`#`,pluginKey:new x.PluginKey(`channelSuggestion`)}}),ft={name:`SlashCommandsComponent`,components:{NodeViewWrapper:m.NodeViewWrapper},props:{...m.nodeViewProps},emits:[`selected-command`],computed:{text(){return`/`+this.$props.node.attrs.command}},created(){let e=this.$props.node.attrs.command;this.$emit(`selected-command`,e);let t=this.editor?.storage?.[`slash-commands`]?.onSelectedCommand;t&&typeof t==`function`&&t(e)}};function pt(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`node-view-wrapper`);return(0,v.openBlock)(),(0,v.createBlock)(o,{class:`d-d-inline-block`},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.text),1)]),_:1})}var mt=n.t(ft,[[`render`,pt]]),ht=(e,t)=>[...e.matchAll(t)].map(e=>{let t=e[2];return t.endsWith(` `)||(t+=` `),{index:e.index,text:t,match:e}}),gt=V.default.extend({name:`slash-commands`,group:`inline`,inline:!0,addOptions(){return{...this.parent?.(),onSelectedCommand:null}},addStorage(){return{onSelectedCommand:this.options.onSelectedCommand}},addNodeView(){return m.VueNodeViewRenderer(mt)},parseHTML(){return[{tag:`command-component`}]},addAttributes(){return{command:{default:``},parametersExample:{default:``},description:{default:``}}},renderText({node:e}){return`/${e.attrs.command}`},renderHTML({HTMLAttributes:e}){return[`command-component`,(0,b.mergeAttributes)(this.options.HTMLAttributes,e)]},addInputRules(){let e=this.options.suggestion?.items({query:``}).map(e=>e.command);return[(0,b.nodeInputRule)({find:RegExp(`^((?:\\/)(${e.join(`|`)})) $`),type:this.type,getAttributes(e){return{command:e[2]}}})]},addPasteRules(){let e=this.options.suggestion?.items({query:``}).map(e=>e.command),t=RegExp(`^((?:\\/)(${e.join(`|`)})) ?$`,`g`);return[(0,b.nodePasteRule)({find:e=>ht(e,t),type:this.type,getAttributes(e){return{command:e[0].trim()}}})]}}).configure({suggestion:{char:`/`,pluginKey:new x.PluginKey(`slashCommandSuggestion`)}}),_t=100,vt={name:`VariableComponent`,components:{DtBadge:a.default,DtButton:l.default,DtPopover:f.default,DtInput:ee.default,NodeViewWrapper:m.NodeViewWrapper},props:m.nodeViewProps,data(){return{i18n:new c.DialtoneLocalization,MAX_VARIABLE_ALT_LENGTH:_t}},computed:{altText:{get(){return this.node?.attrs?.altText||``},set(e){this.updateAttributes({altText:e})}},variableId(){return this.node?.attrs?.id},placeholder(){return this.variableData?.placeholder||``},variableItems(){return this.extension?.options?.variableItems||[]},variableData(){return this.variableItems.find(e=>e.id===this.variableId)},enableAltText(){return this.node?.attrs?.enableAltText},badgeLabel(){return`{} ${this.placeholder}`},placeholderText(){return`Replaces ${this.placeholder}`}}};function yt(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-badge`),s=(0,v.resolveComponent)(`dt-button`),c=(0,v.resolveComponent)(`dt-input`),l=(0,v.resolveComponent)(`dt-popover`),u=(0,v.resolveComponent)(`node-view-wrapper`);return(0,v.openBlock)(),(0,v.createBlock)(u,{class:`d-d-inline-block`},{default:(0,v.withCtx)(()=>[a.enableAltText?((0,v.openBlock)(),(0,v.createBlock)(l,{key:0,padding:`small`,"navigation-type":`arrow-keys`,placement:`top-start`,modal:!1},{anchor:(0,v.withCtx)(({attrs:e})=>[(0,v.createVNode)(s,(0,v.mergeProps)(e,{kind:`unstyled`}),{default:(0,v.withCtx)(()=>[(0,v.createVNode)(o,{text:a.badgeLabel,contenteditable:`false`},null,8,[`text`])]),_:1},16)]),content:(0,v.withCtx)(({close:e})=>[(0,v.createVNode)(c,{modelValue:a.altText,"onUpdate:modelValue":t[0]||(t[0]=e=>a.altText=e),class:`d-p-100 d-w332`,label:i.i18n.$t(`DIALTONE_EDITOR_VARIABLE_LABEL`),placeholder:a.placeholderText,validate:{length:{description:i.i18n.$t(`DIALTONE_EDITOR_VARIABLE_VALIDATE_DESCRIPTION`),message:i.i18n.$t(`DIALTONE_EDITOR_VARIABLE_VALIDATE_MESSAGE`),max:i.MAX_VARIABLE_ALT_LENGTH,warn:i.MAX_VARIABLE_ALT_LENGTH,limitMaxLength:!0}},onKeyup:(0,v.withKeys)(t=>e(),[`enter`])},null,8,[`modelValue`,`label`,`placeholder`,`validate`,`onKeyup`])]),_:1})):((0,v.openBlock)(),(0,v.createBlock)(o,{key:1,text:a.badgeLabel,contenteditable:`false`},null,8,[`text`]))]),_:1})}var bt=n.t(vt,[[`render`,yt]]),xt=b.Node.create({name:`variable`,group:`inline`,inline:!0,selectable:!0,atom:!0,addOptions(){return{HTMLAttributes:{},variableItems:[]}},addNodeView(){return m.VueNodeViewRenderer(bt)},addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute(`data-variable-id`),renderHTML:e=>e.id?{"data-variable-id":e.id}:{}},altText:{default:``,parseHTML:e=>e.getAttribute(`data-alt-text`),renderHTML:e=>e.altText?{"data-alt-text":e.altText}:{}},enableAltText:{default:!0,parseHTML:e=>e.getAttribute(`data-enable-alt-text`)===`true`,renderHTML:e=>({"data-enable-alt-text":String(e.enableAltText)})}}},parseHTML(){return[{tag:`variable`}]},renderText({node:e}){return e.attrs.altText},renderHTML({node:e,HTMLAttributes:t}){return[`variable`,(0,b.mergeAttributes)(this.options.HTMLAttributes,t,{"data-variable-id":e.attrs.id,"data-alt-text":e.attrs.altText,"data-enable-alt-text":String(e.attrs.enableAltText)})]},addCommands(){return{insertVariable:(e={})=>({commands:t})=>t.insertContent({type:this.name,attrs:{id:e.id||null,altText:e.altText||``,enableAltText:e.enableAltText}})}}}),St={name:`MentionSuggestion`,components:{DtAvatar:i.default,DtStack:d.default,DtText:o.default},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name},avatarSrc(){return this.item.avatarSrc},presence(){return this.item.presence},status(){return this.item.status},presenceText(){return this.item.presenceText},presenceFontColorClass(){return{active:`d-mention-suggestion__presence--active`,busy:`d-mention-suggestion__presence--busy`,away:`d-mention-suggestion__presence--away`,offline:`d-mention-suggestion__presence--busy`}[this.presence]},showDetails(){return this.item.showDetails}}},Ct={class:`d-mention-suggestion__name`};function wt(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-avatar`),s=(0,v.resolveComponent)(`dt-text`),c=(0,v.resolveComponent)(`dt-stack`);return(0,v.openBlock)(),(0,v.createBlock)(c,{direction:`row`,class:`d-mention-suggestion__container`,gap:`100`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(o,{"full-name":a.name,"image-src":a.avatarSrc,"image-alt":a.name,"show-presence":a.showDetails,presence:a.presence,size:200},null,8,[`full-name`,`image-src`,`image-alt`,`show-presence`,`presence`]),(0,v.createVNode)(c,{class:`d-mention-suggestion__details-container`,gap:`1`},{default:(0,v.withCtx)(()=>[(0,v.createElementVNode)(`span`,Ct,(0,v.toDisplayString)(a.name),1),a.showDetails?((0,v.openBlock)(),(0,v.createBlock)(c,{key:0,direction:`row`,gap:`50`},{default:(0,v.withCtx)(()=>[a.presenceText?((0,v.openBlock)(),(0,v.createBlock)(s,{key:0,kind:`label`,size:200,strength:`normal`,class:(0,v.normalizeClass)([`d-mention-suggestion__presence`,[a.presenceFontColorClass]])},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.presenceText),1)]),_:1},8,[`class`])):(0,v.createCommentVNode)(``,!0),a.status&&a.presenceText?((0,v.openBlock)(),(0,v.createBlock)(s,{key:1,kind:`label`,size:200,strength:`normal`,as:`div`,class:`d-mention-suggestion__divider`},{default:(0,v.withCtx)(()=>[...t[0]||(t[0]=[(0,v.createTextVNode)(` • `,-1)])]),_:1})):(0,v.createCommentVNode)(``,!0),a.status?((0,v.openBlock)(),(0,v.createBlock)(s,{key:2,kind:`label`,size:200,strength:`normal`,as:`div`,class:`d-mention-suggestion__status`},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.status),1)]),_:1})):(0,v.createCommentVNode)(``,!0)]),_:1})):(0,v.createCommentVNode)(``,!0)]),_:1})]),_:1})}var Tt={allowSpaces:!0,render:Y(n.t(St,[[`render`,wt]]),`mention`)},Et={name:`ChannelSuggestion`,components:{DtStack:d.default,DtIconHash:H.default,DtIconLock:U.default},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};function $(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-icon-hash`),s=(0,v.resolveComponent)(`dt-icon-lock`),c=(0,v.resolveComponent)(`dt-stack`);return(0,v.openBlock)(),(0,v.createBlock)(c,{direction:`row`,gap:`100`},{default:(0,v.withCtx)(()=>[n.item.locked?((0,v.openBlock)(),(0,v.createBlock)(s,{key:1,size:`300`})):((0,v.openBlock)(),(0,v.createBlock)(o,{key:0,size:`300`})),(0,v.createElementVNode)(`span`,null,(0,v.toDisplayString)(a.name),1)]),_:1})}var Dt={allowSpaces:!0,render:Y(n.t(Et,[[`render`,$]]),`channel`)},Ot={name:`SlashCommandSuggestion`,components:{DtText:o.default},props:{item:{type:Object,required:!0}},computed:{command(){return this.item.command},description(){return this.item.description},parametersExample(){return this.item.parametersExample}}},kt={key:0};function At(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-text`);return(0,v.openBlock)(),(0,v.createElementBlock)(`div`,null,[(0,v.createVNode)(o,{kind:`body`,size:300,density:300,as:`div`},{default:(0,v.withCtx)(()=>[(0,v.createElementVNode)(`span`,null,`/`+(0,v.toDisplayString)(a.command),1),a.parametersExample?((0,v.openBlock)(),(0,v.createElementBlock)(`span`,kt,(0,v.toDisplayString)(a.parametersExample),1)):(0,v.createCommentVNode)(``,!0)]),_:1}),(0,v.createVNode)(o,{kind:`body`,size:200,tone:`tertiary`,as:`div`},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(a.description),1)]),_:1})])}var jt={allowSpaces:!0,startOfLine:!0,render:Y(n.t(Ot,[[`render`,At]]),`slash-command`)},Mt={name:`DtRichTextEditor`,components:{EditorContent:m.EditorContent,BubbleMenu:se,DtButton:l.default,DtStack:d.default},props:{modelValue:{type:[Object,String],default:``},editable:{type:Boolean,default:!0},allowTyping:{type:Boolean,default:!0},pasteRichText:{type:Boolean,default:!0},allowLineBreaks:{type:Boolean,default:!1},inputAriaLabel:{type:String,required:!0},inputClass:{type:String,default:``},autoFocus:{type:[Boolean,String,Number],default:!1,validator(e){return typeof e==`string`?g.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:`html`,validator(e){return g.RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(e)}},placeholder:{type:String,default:``},link:{type:[Boolean,Object],default:!1},customLink:{type:[Boolean,Object],default:!1},linkPhoneNumbers:{type:Array,default:null},mentionSuggestion:{type:Object,default:null},channelSuggestion:{type:Object,default:null},slashCommandSuggestion:{type:Object,default:null},allowBlockquote:{type:Boolean,default:!0},allowBold:{type:Boolean,default:!0},allowBulletList:{type:Boolean,default:!0},allowItalic:{type:Boolean,default:!0},allowStrike:{type:Boolean,default:!0},allowUnderline:{type:Boolean,default:!0},allowCode:{type:Boolean,default:!0},allowCodeblock:{type:Boolean,default:!0},allowInlineImages:{type:Boolean,default:!1},allowFontColor:{type:Boolean,default:!1},allowBackgroundColor:{type:Boolean,default:!1},allowFontSize:{type:Boolean,default:!1},allowFontFamily:{type:Boolean,default:!1},allowLineHeight:{type:Boolean,default:!1},allowVariable:{type:Boolean,default:!1},variableItems:{type:Array,default:()=>[]},additionalExtensions:{type:Array,default:()=>[]},showLinkBubbleMenu:{type:Boolean,default:!0},preserveWhitespace:{type:[Boolean,String],default:`full`},useDivTags:{type:Boolean,default:!1},allowTables:{type:Boolean,default:!1},allowTextAlign:{type:Boolean,default:!0},allowImageResize:{type:Boolean,default:!1}},emits:[`update:modelValue`,`json-input`,`html-input`,`text-input`,`markdown-input`,`blur`,`focus`,`enter`,`edit-link`,`selected`,`selected-command`,`mention-click`,`mention-hover`,`mention-leave`,`channel-click`,`phone-click`,`link-click`],data(){return{editor:null,appendTo:()=>t.returnFirstEl(this.$refs.editor.$el).getRootNode()?.querySelector(`body`),floatingOptions:{placement:`top-start`},i18n:new c.DialtoneLocalization}},computed:{attrs(){return{...this.$attrs,onInput:()=>{},onFocus:()=>{},onBlur:()=>{}}},extensions(){let e=[T.default,F.default,E.UndoRedo,D.default];e.push(this.useDivTags?rt:O.default),this.allowBold&&e.push(k.default),this.allowBlockquote&&e.push(S.default),this.allowBulletList&&(e.push(A.BulletList),e.push(A.ListItem.extend({renderText({node:e}){return e.textContent}})),e.push(A.OrderedList)),this.allowItalic&&e.push(j.default),this.allowStrike&&e.push(N.default),this.allowUnderline&&e.push(P.default),this.placeholder&&e.push(E.Placeholder.configure({placeholder:this.placeholder}));let t=this,n=b.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:e})=>t.allowLineBreaks?!1:(e.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>t.allowBulletList&&e.splitListItem(`listItem`),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit(`enter`),!0)}}});if(e.push(n),this.link&&e.push(M.default.extend({inclusive:!1,addKeyboardShortcuts(){return{"Mod-k":()=>(t.$emit(`edit-link`),!0)}}}).configure({HTMLAttributes:{class:`d-link d-wb-break-all`},openOnClick:!1,autolink:!this.customLink,protocols:g.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension($e,this.customLink)),this.linkPhoneNumbers!==null&&e.push(et),this.mentionSuggestion){let t={...this.mentionSuggestion,...Tt};e.push(st.configure({suggestion:t}))}if(this.channelSuggestion){let t={...this.channelSuggestion,...Dt};e.push(dt.configure({suggestion:t}))}if(this.slashCommandSuggestion){let t={...this.slashCommandSuggestion,...jt};e.push(gt.configure({suggestion:t,onSelectedCommand:e=>{this.$emit(`selected-command`,e)}}))}return this.allowVariable&&e.push(xt.configure({variableItems:this.variableItems})),e.push(Ge),this.allowTextAlign&&e.push(I.default.configure({types:[`paragraph`]})),this.allowCode&&e.push(w.default),this.allowCodeblock&&e.push(C.default.extend({renderText({node:e,pos:t,range:n}){let r=n?.from??0,i=n?.to??t+e.nodeSize;if(r<=t&&i>=t+e.nodeSize)return`\`\`\`\n${e.textContent}\n\`\`\``;let a=Math.max(0,r-t-1),o=Math.min(e.textContent.length,i-t-1);return e.textContent.slice(a,o)},addCommands(){return{...this.parent?.(),toggleCodeBlock:(e={})=>({state:t,chain:n,commands:r})=>{let i=t.schema.nodes[this.name],{$from:a,$to:o}=t.selection,s=[];return t.doc.nodesBetween(a.pos,o.pos,(e,t)=>{if(e.isTextblock)return s.push({node:e,pos:t}),!1}),s.length<=1?r.toggleNode(this.name,`paragraph`,e):s.every(({node:e})=>e.type===i)?r.toggleNode(this.name,`paragraph`):n().setNode(this.name,e).command(({tr:e})=>{for(let n=s.length-1;n>0;n--){let r=e.mapping.map(s[n].pos),a=r-1;e.doc.resolve(a).parent.type===i&&e.replaceWith(a,r+1,t.schema.text(`
2
+ `))}return!0}).run()}}}}).configure({HTMLAttributes:{class:`d-rich-text-editor__code-block`}})),this.allowInlineImages&&e.push(tt.configure({resize:{enabled:this.allowImageResize,alwaysPreserveAspectRatio:!0}})),(this.allowFontFamily||this.allowFontColor||this.allowFontSize||this.allowBackgroundColor||this.allowLineHeight)&&(e.push(R.TextStyleKit.configure({textStyle:!1,color:this.allowFontColor,backgroundColor:this.allowBackgroundColor,fontFamily:this.allowFontFamily,fontSize:this.allowFontSize,lineHeight:this.allowLineHeight})),e.push(ge)),this.additionalExtensions.length&&e.push(...this.additionalExtensions),this.allowTables&&e.push(fe.configure({resizable:!0}),pe,he,me,E.Gapcursor),e},inputAttrs(){let e={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:`textbox`};return this.editable||(e[`aria-readonly`]=!0),e}},watch:{editable(e){this.editor.setEditable(e),this.updateEditorAttributes({"aria-readonly":!e})},inputClass(e){this.updateEditorAttributes({class:e})},inputAriaLabel(e){this.updateEditorAttributes({"aria-label":e})},extensions(){this.destroyEditor(),this.createEditor()},modelValue(e){this.processValue(e)},linkPhoneNumbers(){this._applyPhoneMarks()}},created(){this.createEditor()},beforeUnmount(){this.destroyEditor()},mounted(){t.warnIfUnmounted(t.returnFirstEl(this.$el),this.$options.name),this.processValue(this.modelValue,!1)},methods:{createEditor(){this.editor=new m.Editor({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,shouldRerenderOnTransaction:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleDOMEvents:{click:(e,t)=>{if(!this.link||t.button!==0)return!1;let n=t.target?.closest?.(`a`);return n?(this.editor.emit(`link-click`,{href:n.href,text:n.textContent,event:t}),t.defaultPrevented):!1}},handleKeyDown:(e,t)=>{if(this.allowTyping)return!1;let n=[`Backspace`];return!this.allowLineBreaks&&!t.shiftKey&&n.push(`Enter`),!n.includes(t.key)},handlePaste:(e,t)=>{let n=t.clipboardData||window.clipboardData,r=n.getData(`text/plain`),i=n.getData(`text/html`);return this.processPasteData(e,r,i)},transformPastedHTML(e){return e.replace(/<hr[^>]*\/?>/gi,`<p><br></p>`).replace(/(<\/\w+>)((<br \/>)+)/g,`$2$1`).replace(/(<br[^>]*>\s*)+<\/p>(\s*)$/i,`</p>$2`)}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return this.showLinkBubbleMenu&&e.isActive(`link`)},getSelectedLinkText(e){let{view:t,state:n}=e,{from:r,to:i}=t.state.selection,a=n.doc.textBetween(r,i,``),o=this.editor.state.doc.nodeAt(r);return o&&o.marks?.at(0)?.type?.name===`link`?o.textContent:a},editLink(){let e=this.getSelectedLinkText(this.editor),t={href:this.editor.getAttributes(`link`).href,text:e};this.$emit(`edit-link`,t)},removeLink(){this.editor?.chain()?.focus()?.unsetLink()?.run()},openLink(){this.editor?.chain()?.focus();let e=this.editor.getAttributes(`link`).href;window.open(e,`_blank`)},forceLinkifyPendingText(){!this.editor||!this.link||this.customLink||te.t(this.editor)},setLink(e,t,n,r=g.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,i){if(!e){this.removeLink();return}r.find(t=>t.test(e))||(e=`${i}${e}`),this.editor.chain().focus().extendMarkRange(`link`).run();let a=this.editor?.view?.state?.selection,o=t||e;this.editor.chain().focus().insertContent(o).setTextSelection({from:a.from,to:a.from+o.length}).setLink({href:e,class:n.class}).run()},processValue(e,t=!0){if(!this.editor)return;let n=this.getOutput();if(!(t&&(0,W.default)(e,n))){if(typeof e==`string`&&this.outputFormat===`text`){let t=RegExp(`(${y.emojiPattern})`,`g`);e=e?.replace(t,`<emoji-component code="$1"></emoji-component>`)}this.editor.commands.setContent(e,{emitUpdate:!1,parseOptions:{preserveWhitespace:this.preserveWhitespace}}),this._applyPhoneMarks()}},_applyPhoneMarks(){if(!this.editor)return;let e=this.editor.schema.marks.LinkPhoneNumbers;if(!e)return;let{tr:t,doc:n}=this.editor.state;t.removeMark(0,n.content.size,e),this.linkPhoneNumbers?.length&&n.descendants((n,r)=>{if(!(!n.isText||!n.text))for(let i of this.linkPhoneNumbers){let a=0,o;for(;(o=n.text.indexOf(i,a))!==-1;)t.addMark(r+o,r+o+i.length,e.create()),a=o+i.length}}),this.editor.view.dispatch(t)},destroyEditor(){this.editor.destroy()},insertPlainTextWithHardBreaks(e,t){let n=(this.pasteRichText?t:t.replace(/\r\n/g,`
3
+ `).replace(/\n\n/g,`
4
+ `)).replace(/[\r\n]+$/,``).split(/\r?\n/),r=[];for(let e=0;e<n.length;e++)e>0&&r.push({type:`hardBreak`}),n[e]&&r.push({type:`text`,text:n[e]});this.editor.chain().focus().insertContent(r).run()},shouldPreserveLineBreaks(e,t){return this.pasteRichText?!t&&e&&this.hasBlankLines(e):!!e},processPasteData(e,t,n){if(this.shouldPreserveLineBreaks(t,n))return this.insertPlainTextWithHardBreaks(e,t),!0;if(this.shouldHandlePreformattedHTML(n)){let t=this.extractPreformattedText(n);if(t&&t.includes(`
5
+ `))return this.insertPlainTextWithHardBreaks(e,t),!0}return!1},shouldHandlePreformattedHTML(e){return this.pasteRichText&&e&&this.containsPreformattedContent(e)},containsPreformattedContent(e){let t=document.createElement(`div`);t.innerHTML=e;let n=t.querySelectorAll(`*`);for(let e of n)if(this.hasPreWhitespace(e)&&this.hasLineBreaks(e))return!0;return!1},hasPreWhitespace(e){let t=e.getAttribute(`style`)||``,n=e.style.whiteSpace||``,r=n===`pre`||n===`pre-wrap`,i=t.includes(`white-space: pre`);return r||i},hasLineBreaks(e){return e.textContent&&e.textContent.includes(`
6
+ `)},hasBlankLines(e){return e.includes(`
7
+
8
+ `)||/\n\s*\n/.test(e)},extractPreformattedText(e){let t=document.createElement(`div`);return t.innerHTML=e,this.walkAndExtractText(t)},walkAndExtractText(e){let t=``;if(e.nodeType===Node.TEXT_NODE)t+=e.textContent;else if(e.nodeType===Node.ELEMENT_NODE)if(this.hasPreWhitespace(e))t+=e.textContent;else for(let n of e.childNodes)t+=this.walkAndExtractText(n);return t},triggerInputChangeEvents(){let e=this.getOutput();this.$emit(`update:modelValue`,e);let t=this.editor.getJSON();this.$emit(`json-input`,t);let n=this.editor.getHTML();this.$emit(`html-input`,n);let r=this.editor.getText({blockSeparator:`
9
+ `});this.$emit(`text-input`,r);let i=_.t(t,this.extensions);this.$emit(`markdown-input`,i)},addEditorListeners(){this.editor.on(`create`,()=>{this.triggerInputChangeEvents()}),this.editor.on(`update`,()=>{this.triggerInputChangeEvents()}),this.editor.on(`selectionUpdate`,({editor:e})=>{this.$emit(`selected`,this.getSelectedLinkText(e))}),this.editor.on(`focus`,({event:e})=>{this.$emit(`focus`,e)}),this.editor.on(`blur`,({event:e})=>{this.$emit(`blur`,e)}),this.editor.on(`mention-click`,e=>{this.$emit(`mention-click`,e)}),this.editor.on(`mention-hover`,e=>{this.$emit(`mention-hover`,e)}),this.editor.on(`mention-leave`,e=>{this.$emit(`mention-leave`,e)}),this.editor.on(`channel-click`,e=>{this.$emit(`channel-click`,e)}),this.editor.on(`phone-click`,e=>{this.$emit(`phone-click`,e)}),this.editor.on(`link-click`,e=>{this.$emit(`link-click`,e)})},getOutput(){switch(this.outputFormat){case`json`:return this.editor.getJSON();case`html`:return this.editor.getHTML();case`markdown`:return _.t(this.editor.getJSON(),this.extensions);default:return this.editor.getText({blockSeparator:`
10
+ `})}},getExtension(e,t){return typeof t==`boolean`?e:e.configure?.(t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}},Nt={class:`d-popover__dialog`};function Pt(e,t,n,r,i,a){let o=(0,v.resolveComponent)(`dt-button`),s=(0,v.resolveComponent)(`dt-stack`),c=(0,v.resolveComponent)(`bubble-menu`),l=(0,v.resolveComponent)(`editor-content`);return(0,v.openBlock)(),(0,v.createElementBlock)(`div`,null,[i.editor&&n.link?((0,v.openBlock)(),(0,v.createBlock)(c,{key:0,editor:i.editor,"should-show":a.bubbleMenuShouldShow,options:i.floatingOptions,"append-to":i.appendTo,style:{visibility:`visible`}},{default:(0,v.withCtx)(()=>[(0,v.createElementVNode)(`div`,Nt,[(0,v.createVNode)(s,{direction:`row`,class:`d-rich-text-editor-bubble-menu__button-stack`,gap:`0`},{default:(0,v.withCtx)(()=>[(0,v.createVNode)(o,{kind:`muted`,importance:`clear`,onClick:a.editLink},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(i.i18n.$t(`DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL`)),1)]),_:1},8,[`onClick`]),(0,v.createVNode)(o,{kind:`muted`,importance:`clear`,onClick:a.openLink},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(i.i18n.$t(`DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL`)),1)]),_:1},8,[`onClick`]),(0,v.createVNode)(o,{kind:`critical`,importance:`clear`,onClick:a.removeLink},{default:(0,v.withCtx)(()=>[(0,v.createTextVNode)((0,v.toDisplayString)(i.i18n.$t(`DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL`)),1)]),_:1},8,[`onClick`])]),_:1})])]),_:1},8,[`editor`,`should-show`,`options`,`append-to`])):(0,v.createCommentVNode)(``,!0),(0,v.createVNode)(l,(0,v.mergeProps)({ref:`editor`,editor:i.editor,class:`d-rich-text-editor`,"data-qa":`dt-rich-text-editor`},a.attrs),null,16,[`editor`])])}var Ft=n.t(Mt,[[`render`,Pt]]);Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Ft}});
11
+ //# sourceMappingURL=RichTextEditor-7eY8gy9u.cjs.map