jodit-pro 4.11.26 → 4.11.28

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 (335) hide show
  1. package/CHANGELOG.md +115 -1
  2. package/es2015/jodit.css +32 -1
  3. package/es2015/jodit.fat.min.css +1 -1
  4. package/es2015/jodit.fat.min.js +6 -6
  5. package/es2015/jodit.js +39 -9
  6. package/es2015/jodit.min.css +1 -1
  7. package/es2015/jodit.min.js +3 -3
  8. package/es2015/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
  9. package/es2015/plugins/ai-assistant-pro/ai-assistant-pro.js +105 -3
  10. package/es2015/plugins/ai-assistant-pro/ai-assistant-pro.min.js +4 -4
  11. package/es2015/plugins/autocomplete/autocomplete.js +1 -1
  12. package/es2015/plugins/autocomplete/autocomplete.min.js +1 -1
  13. package/es2015/plugins/backup/backup.css +1 -1
  14. package/es2015/plugins/backup/backup.js +1 -1
  15. package/es2015/plugins/backup/backup.min.js +1 -1
  16. package/es2015/plugins/button-generator/button-generator.css +1 -1
  17. package/es2015/plugins/button-generator/button-generator.js +1 -1
  18. package/es2015/plugins/button-generator/button-generator.min.js +1 -1
  19. package/es2015/plugins/change-case/change-case.js +1 -1
  20. package/es2015/plugins/change-case/change-case.min.js +1 -1
  21. package/es2015/plugins/color-picker/color-picker.css +1 -1
  22. package/es2015/plugins/color-picker/color-picker.js +1 -1
  23. package/es2015/plugins/color-picker/color-picker.min.js +1 -1
  24. package/es2015/plugins/emoji/emoji.css +1 -1
  25. package/es2015/plugins/emoji/emoji.js +1 -1
  26. package/es2015/plugins/emoji/emoji.min.js +1 -1
  27. package/es2015/plugins/export-docs/export-docs.js +1 -1
  28. package/es2015/plugins/export-docs/export-docs.min.js +1 -1
  29. package/es2015/plugins/finder/finder.css +1 -1
  30. package/es2015/plugins/finder/finder.js +1 -1
  31. package/es2015/plugins/finder/finder.min.js +1 -1
  32. package/es2015/plugins/google-maps/google-maps.css +1 -1
  33. package/es2015/plugins/google-maps/google-maps.js +1 -1
  34. package/es2015/plugins/google-maps/google-maps.min.js +1 -1
  35. package/es2015/plugins/google-search/google-search.js +1 -1
  36. package/es2015/plugins/google-search/google-search.min.js +1 -1
  37. package/es2015/plugins/highlight-signature/highlight-signature.js +1 -1
  38. package/es2015/plugins/highlight-signature/highlight-signature.min.js +1 -1
  39. package/es2015/plugins/iframe-editor/iframe-editor.css +1 -1
  40. package/es2015/plugins/iframe-editor/iframe-editor.js +1 -1
  41. package/es2015/plugins/iframe-editor/iframe-editor.min.js +1 -1
  42. package/es2015/plugins/keyboard/keyboard.css +1 -1
  43. package/es2015/plugins/keyboard/keyboard.js +1 -1
  44. package/es2015/plugins/keyboard/keyboard.min.js +1 -1
  45. package/es2015/plugins/mobile-view/mobile-view.js +1 -1
  46. package/es2015/plugins/mobile-view/mobile-view.min.js +1 -1
  47. package/es2015/plugins/page-break/page-break.js +1 -1
  48. package/es2015/plugins/page-break/page-break.min.js +1 -1
  49. package/es2015/plugins/paste-code/paste-code.css +1 -1
  50. package/es2015/plugins/paste-code/paste-code.js +1 -1
  51. package/es2015/plugins/paste-code/paste-code.min.js +1 -1
  52. package/es2015/plugins/paste-from-word/paste-from-word.js +1 -1
  53. package/es2015/plugins/paste-from-word/paste-from-word.min.js +1 -1
  54. package/es2015/plugins/show-blocks/show-blocks.js +1 -1
  55. package/es2015/plugins/show-blocks/show-blocks.min.js +1 -1
  56. package/es2015/plugins/style/style.css +1 -1
  57. package/es2015/plugins/style/style.js +58 -7
  58. package/es2015/plugins/style/style.min.js +2 -2
  59. package/es2015/plugins/templates/templates.css +1 -1
  60. package/es2015/plugins/templates/templates.js +1 -1
  61. package/es2015/plugins/templates/templates.min.js +1 -1
  62. package/es2015/plugins/todo-list/todo-list.css +1 -1
  63. package/es2015/plugins/todo-list/todo-list.js +1 -1
  64. package/es2015/plugins/todo-list/todo-list.min.js +1 -1
  65. package/es2015/plugins/translate/translate.css +1 -1
  66. package/es2015/plugins/translate/translate.js +1 -1
  67. package/es2015/plugins/translate/translate.min.js +1 -1
  68. package/es2015/plugins/tune-block/tune-block.css +1 -1
  69. package/es2015/plugins/tune-block/tune-block.js +1 -1
  70. package/es2015/plugins/tune-block/tune-block.min.js +1 -1
  71. package/es2018/jodit.fat.min.css +1 -1
  72. package/es2018/jodit.fat.min.js +6 -6
  73. package/es2018/jodit.min.css +1 -1
  74. package/es2018/jodit.min.js +3 -3
  75. package/es2018/plugins/ai-assistant-pro/ai-assistant-pro.min.js +23 -23
  76. package/es2018/plugins/autocomplete/autocomplete.min.js +1 -1
  77. package/es2018/plugins/backup/backup.min.js +1 -1
  78. package/es2018/plugins/button-generator/button-generator.min.js +1 -1
  79. package/es2018/plugins/change-case/change-case.min.js +1 -1
  80. package/es2018/plugins/color-picker/color-picker.min.js +1 -1
  81. package/es2018/plugins/emoji/emoji.min.js +1 -1
  82. package/es2018/plugins/export-docs/export-docs.min.js +1 -1
  83. package/es2018/plugins/finder/finder.min.js +1 -1
  84. package/es2018/plugins/google-maps/google-maps.min.js +1 -1
  85. package/es2018/plugins/google-search/google-search.min.js +1 -1
  86. package/es2018/plugins/highlight-signature/highlight-signature.min.js +1 -1
  87. package/es2018/plugins/iframe-editor/iframe-editor.min.js +1 -1
  88. package/es2018/plugins/keyboard/keyboard.min.js +1 -1
  89. package/es2018/plugins/mobile-view/mobile-view.min.js +1 -1
  90. package/es2018/plugins/page-break/page-break.min.js +1 -1
  91. package/es2018/plugins/paste-code/paste-code.min.js +1 -1
  92. package/es2018/plugins/paste-from-word/paste-from-word.min.js +1 -1
  93. package/es2018/plugins/show-blocks/show-blocks.min.js +1 -1
  94. package/es2018/plugins/style/style.min.js +2 -2
  95. package/es2018/plugins/templates/templates.min.js +1 -1
  96. package/es2018/plugins/todo-list/todo-list.min.js +1 -1
  97. package/es2018/plugins/translate/translate.min.js +1 -1
  98. package/es2018/plugins/tune-block/tune-block.min.js +1 -1
  99. package/es2021/jodit.css +32 -1
  100. package/es2021/jodit.fat.min.css +1 -1
  101. package/es2021/jodit.fat.min.js +6 -6
  102. package/es2021/jodit.js +39 -8
  103. package/es2021/jodit.min.css +1 -1
  104. package/es2021/jodit.min.js +3 -3
  105. package/es2021/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
  106. package/es2021/plugins/ai-assistant-pro/ai-assistant-pro.js +105 -3
  107. package/es2021/plugins/ai-assistant-pro/ai-assistant-pro.min.js +5 -5
  108. package/es2021/plugins/autocomplete/autocomplete.js +1 -1
  109. package/es2021/plugins/autocomplete/autocomplete.min.js +1 -1
  110. package/es2021/plugins/backup/backup.css +1 -1
  111. package/es2021/plugins/backup/backup.js +1 -1
  112. package/es2021/plugins/backup/backup.min.js +1 -1
  113. package/es2021/plugins/button-generator/button-generator.css +1 -1
  114. package/es2021/plugins/button-generator/button-generator.js +1 -1
  115. package/es2021/plugins/button-generator/button-generator.min.js +1 -1
  116. package/es2021/plugins/change-case/change-case.js +1 -1
  117. package/es2021/plugins/change-case/change-case.min.js +1 -1
  118. package/es2021/plugins/color-picker/color-picker.css +1 -1
  119. package/es2021/plugins/color-picker/color-picker.js +1 -1
  120. package/es2021/plugins/color-picker/color-picker.min.js +1 -1
  121. package/es2021/plugins/emoji/emoji.css +1 -1
  122. package/es2021/plugins/emoji/emoji.js +1 -1
  123. package/es2021/plugins/emoji/emoji.min.js +1 -1
  124. package/es2021/plugins/export-docs/export-docs.js +1 -1
  125. package/es2021/plugins/export-docs/export-docs.min.js +1 -1
  126. package/es2021/plugins/finder/finder.css +1 -1
  127. package/es2021/plugins/finder/finder.js +1 -1
  128. package/es2021/plugins/finder/finder.min.js +1 -1
  129. package/es2021/plugins/google-maps/google-maps.css +1 -1
  130. package/es2021/plugins/google-maps/google-maps.js +1 -1
  131. package/es2021/plugins/google-maps/google-maps.min.js +1 -1
  132. package/es2021/plugins/google-search/google-search.js +1 -1
  133. package/es2021/plugins/google-search/google-search.min.js +1 -1
  134. package/es2021/plugins/highlight-signature/highlight-signature.js +1 -1
  135. package/es2021/plugins/highlight-signature/highlight-signature.min.js +1 -1
  136. package/es2021/plugins/iframe-editor/iframe-editor.css +1 -1
  137. package/es2021/plugins/iframe-editor/iframe-editor.js +1 -1
  138. package/es2021/plugins/iframe-editor/iframe-editor.min.js +1 -1
  139. package/es2021/plugins/keyboard/keyboard.css +1 -1
  140. package/es2021/plugins/keyboard/keyboard.js +1 -1
  141. package/es2021/plugins/keyboard/keyboard.min.js +1 -1
  142. package/es2021/plugins/mobile-view/mobile-view.js +1 -1
  143. package/es2021/plugins/mobile-view/mobile-view.min.js +1 -1
  144. package/es2021/plugins/page-break/page-break.js +1 -1
  145. package/es2021/plugins/page-break/page-break.min.js +1 -1
  146. package/es2021/plugins/paste-code/paste-code.css +1 -1
  147. package/es2021/plugins/paste-code/paste-code.js +1 -1
  148. package/es2021/plugins/paste-code/paste-code.min.js +1 -1
  149. package/es2021/plugins/paste-from-word/paste-from-word.js +1 -1
  150. package/es2021/plugins/paste-from-word/paste-from-word.min.js +1 -1
  151. package/es2021/plugins/show-blocks/show-blocks.js +1 -1
  152. package/es2021/plugins/show-blocks/show-blocks.min.js +1 -1
  153. package/es2021/plugins/style/style.css +1 -1
  154. package/es2021/plugins/style/style.js +56 -5
  155. package/es2021/plugins/style/style.min.js +2 -2
  156. package/es2021/plugins/templates/templates.css +1 -1
  157. package/es2021/plugins/templates/templates.js +1 -1
  158. package/es2021/plugins/templates/templates.min.js +1 -1
  159. package/es2021/plugins/todo-list/todo-list.css +1 -1
  160. package/es2021/plugins/todo-list/todo-list.js +1 -1
  161. package/es2021/plugins/todo-list/todo-list.min.js +1 -1
  162. package/es2021/plugins/translate/translate.css +1 -1
  163. package/es2021/plugins/translate/translate.js +1 -1
  164. package/es2021/plugins/translate/translate.min.js +1 -1
  165. package/es2021/plugins/tune-block/tune-block.css +1 -1
  166. package/es2021/plugins/tune-block/tune-block.js +1 -1
  167. package/es2021/plugins/tune-block/tune-block.min.js +1 -1
  168. package/es2021.en/jodit.css +32 -1
  169. package/es2021.en/jodit.fat.min.css +1 -1
  170. package/es2021.en/jodit.fat.min.js +6 -6
  171. package/es2021.en/jodit.js +39 -8
  172. package/es2021.en/jodit.min.css +1 -1
  173. package/es2021.en/jodit.min.js +3 -3
  174. package/es2021.en/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
  175. package/es2021.en/plugins/ai-assistant-pro/ai-assistant-pro.js +105 -3
  176. package/es2021.en/plugins/ai-assistant-pro/ai-assistant-pro.min.js +26 -26
  177. package/es2021.en/plugins/autocomplete/autocomplete.js +1 -1
  178. package/es2021.en/plugins/autocomplete/autocomplete.min.js +1 -1
  179. package/es2021.en/plugins/backup/backup.css +1 -1
  180. package/es2021.en/plugins/backup/backup.js +1 -1
  181. package/es2021.en/plugins/backup/backup.min.js +1 -1
  182. package/es2021.en/plugins/button-generator/button-generator.css +1 -1
  183. package/es2021.en/plugins/button-generator/button-generator.js +1 -1
  184. package/es2021.en/plugins/button-generator/button-generator.min.js +1 -1
  185. package/es2021.en/plugins/change-case/change-case.js +1 -1
  186. package/es2021.en/plugins/change-case/change-case.min.js +1 -1
  187. package/es2021.en/plugins/color-picker/color-picker.css +1 -1
  188. package/es2021.en/plugins/color-picker/color-picker.js +1 -1
  189. package/es2021.en/plugins/color-picker/color-picker.min.js +1 -1
  190. package/es2021.en/plugins/emoji/emoji.css +1 -1
  191. package/es2021.en/plugins/emoji/emoji.js +1 -1
  192. package/es2021.en/plugins/emoji/emoji.min.js +1 -1
  193. package/es2021.en/plugins/export-docs/export-docs.js +1 -1
  194. package/es2021.en/plugins/export-docs/export-docs.min.js +1 -1
  195. package/es2021.en/plugins/finder/finder.css +1 -1
  196. package/es2021.en/plugins/finder/finder.js +1 -1
  197. package/es2021.en/plugins/finder/finder.min.js +1 -1
  198. package/es2021.en/plugins/google-maps/google-maps.css +1 -1
  199. package/es2021.en/plugins/google-maps/google-maps.js +1 -1
  200. package/es2021.en/plugins/google-maps/google-maps.min.js +1 -1
  201. package/es2021.en/plugins/google-search/google-search.js +1 -1
  202. package/es2021.en/plugins/google-search/google-search.min.js +1 -1
  203. package/es2021.en/plugins/highlight-signature/highlight-signature.js +1 -1
  204. package/es2021.en/plugins/highlight-signature/highlight-signature.min.js +1 -1
  205. package/es2021.en/plugins/iframe-editor/iframe-editor.css +1 -1
  206. package/es2021.en/plugins/iframe-editor/iframe-editor.js +1 -1
  207. package/es2021.en/plugins/iframe-editor/iframe-editor.min.js +1 -1
  208. package/es2021.en/plugins/keyboard/keyboard.css +1 -1
  209. package/es2021.en/plugins/keyboard/keyboard.js +1 -1
  210. package/es2021.en/plugins/keyboard/keyboard.min.js +1 -1
  211. package/es2021.en/plugins/mobile-view/mobile-view.js +1 -1
  212. package/es2021.en/plugins/mobile-view/mobile-view.min.js +1 -1
  213. package/es2021.en/plugins/page-break/page-break.js +1 -1
  214. package/es2021.en/plugins/page-break/page-break.min.js +1 -1
  215. package/es2021.en/plugins/paste-code/paste-code.css +1 -1
  216. package/es2021.en/plugins/paste-code/paste-code.js +1 -1
  217. package/es2021.en/plugins/paste-code/paste-code.min.js +1 -1
  218. package/es2021.en/plugins/paste-from-word/paste-from-word.js +1 -1
  219. package/es2021.en/plugins/paste-from-word/paste-from-word.min.js +1 -1
  220. package/es2021.en/plugins/show-blocks/show-blocks.js +1 -1
  221. package/es2021.en/plugins/show-blocks/show-blocks.min.js +1 -1
  222. package/es2021.en/plugins/style/style.css +1 -1
  223. package/es2021.en/plugins/style/style.js +56 -5
  224. package/es2021.en/plugins/style/style.min.js +2 -2
  225. package/es2021.en/plugins/templates/templates.css +1 -1
  226. package/es2021.en/plugins/templates/templates.js +1 -1
  227. package/es2021.en/plugins/templates/templates.min.js +1 -1
  228. package/es2021.en/plugins/todo-list/todo-list.css +1 -1
  229. package/es2021.en/plugins/todo-list/todo-list.js +1 -1
  230. package/es2021.en/plugins/todo-list/todo-list.min.js +1 -1
  231. package/es2021.en/plugins/translate/translate.css +1 -1
  232. package/es2021.en/plugins/translate/translate.js +1 -1
  233. package/es2021.en/plugins/translate/translate.min.js +1 -1
  234. package/es2021.en/plugins/tune-block/tune-block.css +1 -1
  235. package/es2021.en/plugins/tune-block/tune-block.js +1 -1
  236. package/es2021.en/plugins/tune-block/tune-block.min.js +1 -1
  237. package/es5/jodit.css +37 -2
  238. package/es5/jodit.fat.min.css +1 -1
  239. package/es5/jodit.fat.min.js +2 -2
  240. package/es5/jodit.js +43 -9
  241. package/es5/jodit.min.css +3 -3
  242. package/es5/jodit.min.js +2 -2
  243. package/es5/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
  244. package/es5/plugins/ai-assistant-pro/ai-assistant-pro.js +169 -3
  245. package/es5/plugins/ai-assistant-pro/ai-assistant-pro.min.js +2 -2
  246. package/es5/plugins/autocomplete/autocomplete.js +1 -1
  247. package/es5/plugins/autocomplete/autocomplete.min.js +1 -1
  248. package/es5/plugins/backup/backup.css +1 -1
  249. package/es5/plugins/backup/backup.js +1 -1
  250. package/es5/plugins/backup/backup.min.js +1 -1
  251. package/es5/plugins/button-generator/button-generator.css +1 -1
  252. package/es5/plugins/button-generator/button-generator.js +1 -1
  253. package/es5/plugins/button-generator/button-generator.min.js +1 -1
  254. package/es5/plugins/change-case/change-case.js +1 -1
  255. package/es5/plugins/change-case/change-case.min.js +1 -1
  256. package/es5/plugins/color-picker/color-picker.css +1 -1
  257. package/es5/plugins/color-picker/color-picker.js +1 -1
  258. package/es5/plugins/color-picker/color-picker.min.js +1 -1
  259. package/es5/plugins/emoji/emoji.css +1 -1
  260. package/es5/plugins/emoji/emoji.js +1 -1
  261. package/es5/plugins/emoji/emoji.min.js +1 -1
  262. package/es5/plugins/export-docs/export-docs.js +1 -1
  263. package/es5/plugins/export-docs/export-docs.min.js +1 -1
  264. package/es5/plugins/finder/finder.css +1 -1
  265. package/es5/plugins/finder/finder.js +1 -1
  266. package/es5/plugins/finder/finder.min.js +1 -1
  267. package/es5/plugins/google-maps/google-maps.css +1 -1
  268. package/es5/plugins/google-maps/google-maps.js +1 -1
  269. package/es5/plugins/google-maps/google-maps.min.js +1 -1
  270. package/es5/plugins/google-search/google-search.js +1 -1
  271. package/es5/plugins/google-search/google-search.min.js +1 -1
  272. package/es5/plugins/highlight-signature/highlight-signature.js +1 -1
  273. package/es5/plugins/highlight-signature/highlight-signature.min.js +1 -1
  274. package/es5/plugins/iframe-editor/iframe-editor.css +1 -1
  275. package/es5/plugins/iframe-editor/iframe-editor.js +1 -1
  276. package/es5/plugins/iframe-editor/iframe-editor.min.js +1 -1
  277. package/es5/plugins/keyboard/keyboard.css +1 -1
  278. package/es5/plugins/keyboard/keyboard.js +1 -1
  279. package/es5/plugins/keyboard/keyboard.min.js +1 -1
  280. package/es5/plugins/mobile-view/mobile-view.js +1 -1
  281. package/es5/plugins/mobile-view/mobile-view.min.js +1 -1
  282. package/es5/plugins/page-break/page-break.js +1 -1
  283. package/es5/plugins/page-break/page-break.min.js +1 -1
  284. package/es5/plugins/paste-code/paste-code.css +1 -1
  285. package/es5/plugins/paste-code/paste-code.js +1 -1
  286. package/es5/plugins/paste-code/paste-code.min.js +1 -1
  287. package/es5/plugins/paste-from-word/paste-from-word.js +1 -1
  288. package/es5/plugins/paste-from-word/paste-from-word.min.js +1 -1
  289. package/es5/plugins/show-blocks/show-blocks.js +1 -1
  290. package/es5/plugins/show-blocks/show-blocks.min.js +1 -1
  291. package/es5/plugins/style/style.css +1 -1
  292. package/es5/plugins/style/style.js +114 -25
  293. package/es5/plugins/style/style.min.js +2 -2
  294. package/es5/plugins/templates/templates.css +1 -1
  295. package/es5/plugins/templates/templates.js +1 -1
  296. package/es5/plugins/templates/templates.min.js +1 -1
  297. package/es5/plugins/todo-list/todo-list.css +1 -1
  298. package/es5/plugins/todo-list/todo-list.js +1 -1
  299. package/es5/plugins/todo-list/todo-list.min.js +1 -1
  300. package/es5/plugins/translate/translate.css +1 -1
  301. package/es5/plugins/translate/translate.js +1 -1
  302. package/es5/plugins/translate/translate.min.js +1 -1
  303. package/es5/plugins/tune-block/tune-block.css +1 -1
  304. package/es5/plugins/tune-block/tune-block.js +1 -1
  305. package/es5/plugins/tune-block/tune-block.min.js +1 -1
  306. package/es5/polyfills.fat.min.js +1 -1
  307. package/es5/polyfills.js +1 -1
  308. package/es5/polyfills.min.js +1 -1
  309. package/esm/config.d.ts +2 -0
  310. package/esm/plugins/ai-assistant-pro/ai-assistant-pro.d.ts +3 -0
  311. package/esm/plugins/ai-assistant-pro/ai-assistant-pro.js +2 -2
  312. package/esm/plugins/ai-assistant-pro/config.js +1 -1
  313. package/esm/plugins/ai-assistant-pro/interface/options.d.ts +40 -0
  314. package/esm/plugins/ai-assistant-pro/providers/jodit-ai-adapter.js +1 -1
  315. package/esm/plugins/autocomplete/autocomplete.js +1 -1
  316. package/esm/plugins/autocomplete/config.d.ts +2 -1
  317. package/esm/plugins/autocomplete/config.js +1 -1
  318. package/esm/plugins/autocomplete/interface.d.ts +1 -0
  319. package/esm/plugins/autocomplete/ui/autocomplete.d.ts +3 -1
  320. package/esm/plugins/autocomplete/ui/autocomplete.js +1 -1
  321. package/esm/plugins/autocomplete/ui/item.d.ts +2 -0
  322. package/esm/plugins/autocomplete/ui/item.js +1 -1
  323. package/esm/plugins/style/helpers/apply-style.js +1 -1
  324. package/esm/plugins/style/helpers/detect-active-style.js +1 -1
  325. package/esm/plugins/style/interface.d.ts +2 -1
  326. package/esm/plugins/style/ui/style-popup.js +1 -1
  327. package/package.json +1 -1
  328. package/types/config.d.ts +2 -0
  329. package/types/plugins/ai-assistant-pro/ai-assistant-pro.d.ts +3 -0
  330. package/types/plugins/ai-assistant-pro/interface/options.d.ts +40 -0
  331. package/types/plugins/autocomplete/config.d.ts +2 -1
  332. package/types/plugins/autocomplete/interface.d.ts +1 -0
  333. package/types/plugins/autocomplete/ui/autocomplete.d.ts +3 -1
  334. package/types/plugins/autocomplete/ui/item.d.ts +2 -0
  335. package/types/plugins/style/interface.d.ts +2 -1
@@ -1,19 +1,19 @@
1
1
  /*!
2
2
  * jodit-pro - PRO Version of Jodit Editor
3
3
  * Author: Chupurnov Valerii <chupurnov@gmail.com>
4
- * Version: v4.11.26
4
+ * Version: v4.11.28
5
5
  * Url: https://xdsoft.net/jodit/pro/
6
6
  * License(s): SEE LICENSE IN LICENSE.md
7
7
  */
8
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var s=t();for(var i in s)("object"==typeof exports?exports:e)[i]=s[i]}}(self,function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[830],{94668:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> \x3c!-- Plus icon with document/context --\x3e <path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z"/> </svg>'},86428:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> \x3c!-- Background rounded rect --\x3e <rect x="1" y="1" width="22" height="22" rx="3"/> \x3c!-- Letter A - outer shape --\x3e <polygon points="8,5 2,19 5,19 6.5,16 11.5,16 13,19 16,19 10,5" fill="white"/> \x3c!-- Letter A - inner triangle (hole) --\x3e <polygon points="9,9 7.5,13 10.5,13" fill="currentColor"/> \x3c!-- Letter I --\x3e <rect x="17" y="5" width="3" height="14" fill="white"/> </svg>'},75966:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> \x3c!-- Wand handle - diagonal line --\x3e <rect x="12" y="10" width="13" height="3.5" rx="0.5" transform="rotate(45 12 12)"/> \x3c!-- Wand tip - diamond --\x3e <rect x="3" y="3" width="6" height="6" rx="1" transform="rotate(45 6 6)"/> \x3c!-- Large sparkle - top --\x3e <polygon points="15,0 16,4 15,8 14,4"/> <polygon points="11,4 15,5 19,4 15,3"/> \x3c!-- Medium sparkle - left --\x3e <polygon points="1,11 2,14 1,17 0,14"/> <polygon points="-2,14 1,15 4,14 1,13"/> \x3c!-- Small sparkle - middle --\x3e <polygon points="8,14 8.5,16 8,18 7.5,16"/> <polygon points="6,16 8,16.5 10,16 8,15.5"/> </svg>'},83207:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M9 18l6-6-6-6"/> </svg>'},99219:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <line x1="22" y1="2" x2="11" y2="13"></line> <polygon points="22 2 15 22 11 13 2 9 22 2"></polygon> </svg>'},63674:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/> </svg>'},4133:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M13 2L4 14h6l-1 8 9-12h-6z"/> </svg>'},62357:function(e,t,s){"use strict";s.d(t,{UIRange:function(){return l}});var i=s(82749),n=s(31635),r=s(65478),a=s(21537),o=s(67510);class l extends o.UIInput{className(){return"UIRange"}appendUIRange(){let e=this.j.create.div(this.getFullElName("slider"));this.container.appendChild(e);let t=this.j.create.div(this.getFullElName("handle"));e.appendChild(t);let s=this.j.create.div(this.getFullElName("log")),i=this.getElm("label");i&&i.appendChild(s)}onDragStart(e){this.startValue=parseFloat(this.value)||0,this.startX=e.clientX;let t=this.getElm("slider");(0,a.assert)(null!=t,"slider element does not exists"),this.width=t.offsetWidth,this.j.e.on(this.j.ow,"mousemove",this.onDrag)}onDrag(e){let{min:t,max:s,step:i=1}=this.state,n=(e.clientX-this.startX)/this.width*(this.state.max-this.state.min),r=this.startValue+n;r<t&&(r=t),r>s&&(r=s),r=Math.round(r/i)*i,this.value=r.toFixed(10)}onDragEnd(){this.j.e.off(this.j.ow,"mousemove",this.onDrag)}onChangeSelfValue(){let e=this.getElm("handle"),t=parseFloat(this.value)||0;(0,a.assert)(null!=e,"Handle element does not exist"),(0,a.css)(e,{left:(t-this.state.min)/(this.state.max-this.state.min)*100+"%"});let s=this.getElm("log");(0,a.assert)(null!=s,"log element does not exist"),s.innerText=t.toString()}destruct(){return this.onDragEnd(),super.destruct()}constructor(e,t){super(e,{...t,type:"hidden"}),(0,i._)(this,"state",{...o.UIInput.defaultState,min:0,max:100,step:1}),(0,i._)(this,"startValue",0),(0,i._)(this,"startX",0),(0,i._)(this,"width",100),Object.assign(this.state,t),this.appendUIRange(),this.onChangeSelfValue()}}(0,n.__decorate)([(0,r.watch)(["handle:mousedown","handle:touchstart"])],l.prototype,"onDragStart",null),(0,n.__decorate)([r.autobind],l.prototype,"onDrag",null),(0,n.__decorate)([(0,r.watch)(["j.ow:mouseup","j.ow:touchend"])],l.prototype,"onDragEnd",null),(0,n.__decorate)([(0,r.watch)(":change")],l.prototype,"onChangeSelfValue",null),l=(0,n.__decorate)([r.component],l)},41810:function(e,t,s){"use strict";s.r(t),s.d(t,{aiAssistantPro:function(){return y}});var i=s(82749),n=s(31635);s(66645);var r=s(86449),a=s(21020),o=s(46166),l=s(62895),c=s(55487),h=s(27769),u=s(58579),d=s(63805),p=s(82758),g=s(65478),m=s(580),f=s(21537),v=s(50911),C=s(2692),w=s(18549),x=s(54747);class y extends v.Plugin{get state(){return this.stateManager.state}get toolRegistry(){return new c.ToolRegistry(this.j)}get permissionManager(){return new a.PermissionManager(this.j,this.toolRegistry)}get apiClient(){return new r.APIClient(this.j,this.toolRegistry)}get storage(){let{storage:e,storageKey:t,maxConversations:s}=this.j.o.aiAssistantPro;if("string"==typeof e){let i=(0,l.createStorageProvider)(e,t);return new l.WebStorageConversationStorage(i,s)}return e}get stateManager(){return new o.StateManager(this.j)}get mainPanel(){return new h.UIMainPanel(this.j,this.stateManager.state,this.j.o.aiAssistantPro,e=>{let t=this.stateManager.getCurrentConversation();t&&this.stateManager.setCurrentConversation({...t,...e})})}get dialog(){let e=this.j.dlg({resizable:this.j.o.aiAssistantPro.resizable,eventEmmiter:this.j.e});return e.e.on(e,"afterClose",()=>{this.j.e.fire("closeAIAssistantPro.ai-assistant-pro")}),e}afterInit(){(0,m.extendLang)(d),this.setupEventListeners(),this.j.async.promise(e=>{let{initiallyOpened:t,persistOpenState:s}=this.j.o.aiAssistantPro,i=t;s?this.storage.getGlobalSettings().then(e=>{if(e?.isOpen!=null&&(i=e.isOpen),i)return this.openAssistant()}).catch(()=>null).finally(()=>e(void 0)):e(void 0)}).catch(()=>null)}__loadData(){return this.__initedPromise?this.__initedPromise:this.isDestructed?Promise.reject():(this.__initedPromise=this.j.async.promise(e=>{this.loadInitialData().then(e)}).catch(()=>null),this.__initedPromise)}async loadInitialData(){this.mainPanel.setMod("ready",!0),await (0,u.loadInitialData)(this.j,this.storage,this.stateManager),await this.restorePendingToolCalls()}async restorePendingToolCalls(){let e=this.stateManager.getCurrentConversation();if(!e)return;let t=(0,u.findMessagesWithPendingToolCalls)(e);if(0!==t.length)for(let e of t)await this.handleToolCalls(e.id)}setupEventListeners(){this.j.e.on("selectConversation.ai-assistant-pro",async e=>{try{await this.__loadData(),await (0,u.handleConversationSelect)(e,this.storage,this.stateManager)}catch(e){p.IS_PROD}}),this.j.e.on("newConversation.ai-assistant-pro",async()=>{await this.__loadData();let e=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature);this.stateManager.setCurrentConversation(e)}),this.j.e.on("deleteConversation.ai-assistant-pro",async e=>{await this.__loadData(),await this.deleteConversation(e)}),this.j.e.on("renameConversation.ai-assistant-pro",async(e,t)=>{await this.__loadData(),await this.renameConversation(e,t)}),this.j.e.on("backToList.ai-assistant-pro",async()=>{await this.__loadData(),await (0,u.handleBackToList)(this.storage,this.stateManager)}),this.j.e.on("removeContext.ai-assistant-pro",async e=>{await this.__loadData(),this.stateManager.removeSelectionContext(e)}),this.j.e.on("approveToolCall.ai-assistant-pro",async(e,t)=>{try{await this.__loadData();let s=await (0,u.handleToolApproval)(e,t,this.stateManager,this.permissionManager,this.storage);if(s){let e=this.stateManager.getCurrentConversation();if(!e)return;let t=e.messages.find(e=>e.toolCalls?.some(e=>e.id===s.id));if(!t)return;await this.executeToolCall(t.id,s)}}catch(e){if((0,f.isAbortError)(e))return;this.stateManager.setError(e instanceof Error?e.message:e+"")}}),this.j.e.on("denyToolCall.ai-assistant-pro",async e=>{await this.__loadData(),await (0,u.handleToolDenial)(this.j,e,this.stateManager,this.storage)}),this.j.e.on("abortRequest.ai-assistant-pro",async()=>{await this.__loadData(),this.apiClient.abort(),this.stateManager.setLoading(!1)})}__applyTheme(){(0,u.applyTheme)(this.j,this.stateManager.state.theme,this.stateManager.state.displayMode,this.mainPanel.container,this.dialog)}async openAssistant(){if(this.stateManager.isOpen()){this.stateManager.close(),await this.__closeInContainer();return}await this.__loadData(),this.isDestructed||(this.stateManager.open(),await this.__openInContainer(),this.j.o.aiAssistantPro.includeSelectionByDefault&&!this.j.s.isCollapsed()&&this.addCurrentSelectionToContext())}async __openInContainer(){let{resizable:e,allowClose:t,flightPanelHeight:s}=this.j.o.aiAssistantPro,{displayMode:i="right",panelWidth:n,panelHeight:r}=this.stateManager.state;switch(this.__applyTheme(),this.mainPanel.setMod("displayMode",i),this.mainPanel.setMod("allowClose",t),this.mainPanel.setParentView("dialog"===i||"flight"===i?this.dialog:this.j),this.__openedMode=i,i){case"dialog":this.dialog.setSize(n,r).open().setContent(this.mainPanel.container);break;case"flight":w.UIFlightPosition.install(this.mainPanel,this.j.container,{panelHeight:s,containerClassName:this.getFullElName("flight-container")});break;default:e&&(x.UIResize.remove(this.mainPanel),x.UIResize.install(this.mainPanel,(0,u.invertMode)(i),{handleClassName:this.getFullElName("ai-assistent-resize-handle"),onResize:({newSize:e})=>{let t="left"===i||"right"===i?e:n,s="top"===i||"bottom"===i?e:r;return this.stateManager.state.panelWidth=t,this.stateManager.state.panelHeight=s,!0}})),this.j.currentPlace.slots[i].appendChild(this.mainPanel.container),(0,u.resizeInPanelView)(this.j,i,n,r)}}__onResizeInPanelView(){let{displayMode:e,panelWidth:t,panelHeight:s}=this.stateManager.state;(0,u.resizeInPanelView)(this.j,e,t,s)}async __closeInContainer(){let{displayMode:e}=await this.stateManager.state;switch(this.__openedMode!==e&&"dialog"===this.__openedMode&&this.dialog.close(),this.__openedMode!==e&&"flight"===this.__openedMode&&this.__closeFlightMode(),e){case"dialog":this.dialog.close();break;case"flight":this.__closeFlightMode();break;default:this.mainPanel.container.remove()}}__closeFlightMode(){w.UIFlightPosition.remove(this.mainPanel)}__onSavedStateChange(){let e=this.stateManager.state;return this.storage.saveGlobalSettings({displayMode:e.displayMode,panelWidth:e.panelWidth,panelHeight:e.panelHeight,theme:e.theme,defaultModel:e.defaultModel,defaultTemperature:e.defaultTemperature,currentConversationId:e.currentConversation?.id,...this.j.o.aiAssistantPro.persistOpenState?{isOpen:e.isOpen}:{}})}async closeAssistant(){this.stateManager.isOpen()&&(await this.__loadData(),this.stateManager.close(),this.__closeInContainer())}async addCurrentSelectionToContext(){await this.__loadData();let e=(0,u.getCurrentSelectionContext)(this.j);e&&this.stateManager.addSelectionContext(e)}async executeQuickCommand(e){let t,{quickCommandsSilentMode:s,quickCommandsDisplayMode:i}=this.j.o.aiAssistantPro,n=this.j.o.aiAssistant;if(n&&n[e]&&(0,f.isString)(n[e])&&(t=n[e]),!t)return void this.j.e.fire("error","Command not found: "+e);let r=this.j.s.isCollapsed()?this.j.value:this.j.s.html;if(!r)return;let a=n?.aiCommonPrefixPrompt||"",o=n?.aiCommonSuffixPrompt||"",l=`${a}${t}${o}
8
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var s=t();for(var i in s)("object"==typeof exports?exports:e)[i]=s[i]}}(self,function(){return(self.webpackChunkjodit_pro=self.webpackChunkjodit_pro||[]).push([[830],{94668:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> \x3c!-- Plus icon with document/context --\x3e <path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 14h-3v3h-2v-3H8v-2h3v-3h2v3h3v2zm-3-7V3.5L18.5 9H13z"/> </svg>'},86428:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> \x3c!-- Background rounded rect --\x3e <rect x="1" y="1" width="22" height="22" rx="3"/> \x3c!-- Letter A - outer shape --\x3e <polygon points="8,5 2,19 5,19 6.5,16 11.5,16 13,19 16,19 10,5" fill="white"/> \x3c!-- Letter A - inner triangle (hole) --\x3e <polygon points="9,9 7.5,13 10.5,13" fill="currentColor"/> \x3c!-- Letter I --\x3e <rect x="17" y="5" width="3" height="14" fill="white"/> </svg>'},75966:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"> \x3c!-- Wand handle - diagonal line --\x3e <rect x="12" y="10" width="13" height="3.5" rx="0.5" transform="rotate(45 12 12)"/> \x3c!-- Wand tip - diamond --\x3e <rect x="3" y="3" width="6" height="6" rx="1" transform="rotate(45 6 6)"/> \x3c!-- Large sparkle - top --\x3e <polygon points="15,0 16,4 15,8 14,4"/> <polygon points="11,4 15,5 19,4 15,3"/> \x3c!-- Medium sparkle - left --\x3e <polygon points="1,11 2,14 1,17 0,14"/> <polygon points="-2,14 1,15 4,14 1,13"/> \x3c!-- Small sparkle - middle --\x3e <polygon points="8,14 8.5,16 8,18 7.5,16"/> <polygon points="6,16 8,16.5 10,16 8,15.5"/> </svg>'},83207:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M9 18l6-6-6-6"/> </svg>'},99219:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <line x1="22" y1="2" x2="11" y2="13"></line> <polygon points="22 2 15 22 11 13 2 9 22 2"></polygon> </svg>'},63674:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/> </svg>'},4133:function(e){e.exports='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <path d="M13 2L4 14h6l-1 8 9-12h-6z"/> </svg>'},62357:function(e,t,s){"use strict";s.d(t,{UIRange:function(){return l}});var i=s(82749),n=s(31635),a=s(65478),r=s(21537),o=s(67510);class l extends o.UIInput{className(){return"UIRange"}appendUIRange(){let e=this.j.create.div(this.getFullElName("slider"));this.container.appendChild(e);let t=this.j.create.div(this.getFullElName("handle"));e.appendChild(t);let s=this.j.create.div(this.getFullElName("log")),i=this.getElm("label");i&&i.appendChild(s)}onDragStart(e){this.startValue=parseFloat(this.value)||0,this.startX=e.clientX;let t=this.getElm("slider");(0,r.assert)(null!=t,"slider element does not exists"),this.width=t.offsetWidth,this.j.e.on(this.j.ow,"mousemove",this.onDrag)}onDrag(e){let{min:t,max:s,step:i=1}=this.state,n=(e.clientX-this.startX)/this.width*(this.state.max-this.state.min),a=this.startValue+n;a<t&&(a=t),a>s&&(a=s),a=Math.round(a/i)*i,this.value=a.toFixed(10)}onDragEnd(){this.j.e.off(this.j.ow,"mousemove",this.onDrag)}onChangeSelfValue(){let e=this.getElm("handle"),t=parseFloat(this.value)||0;(0,r.assert)(null!=e,"Handle element does not exist"),(0,r.css)(e,{left:(t-this.state.min)/(this.state.max-this.state.min)*100+"%"});let s=this.getElm("log");(0,r.assert)(null!=s,"log element does not exist"),s.innerText=t.toString()}destruct(){return this.onDragEnd(),super.destruct()}constructor(e,t){super(e,{...t,type:"hidden"}),(0,i._)(this,"state",{...o.UIInput.defaultState,min:0,max:100,step:1}),(0,i._)(this,"startValue",0),(0,i._)(this,"startX",0),(0,i._)(this,"width",100),Object.assign(this.state,t),this.appendUIRange(),this.onChangeSelfValue()}}(0,n.__decorate)([(0,a.watch)(["handle:mousedown","handle:touchstart"])],l.prototype,"onDragStart",null),(0,n.__decorate)([a.autobind],l.prototype,"onDrag",null),(0,n.__decorate)([(0,a.watch)(["j.ow:mouseup","j.ow:touchend"])],l.prototype,"onDragEnd",null),(0,n.__decorate)([(0,a.watch)(":change")],l.prototype,"onChangeSelfValue",null),l=(0,n.__decorate)([a.component],l)},41810:function(e,t,s){"use strict";s.r(t),s.d(t,{aiAssistantPro:function(){return y}});var i=s(82749),n=s(31635);s(66645);var a=s(86449),r=s(21020),o=s(46166),l=s(62895),c=s(55487),h=s(27769),u=s(58579),d=s(63805),p=s(82758),g=s(65478),m=s(580),f=s(21537),v=s(50911),C=s(2692),w=s(18549),x=s(54747);class y extends v.Plugin{get state(){return this.stateManager.state}get toolRegistry(){return new c.ToolRegistry(this.j)}get permissionManager(){return new r.PermissionManager(this.j,this.toolRegistry)}get apiClient(){return new a.APIClient(this.j,this.toolRegistry)}get storage(){let{storage:e,storageKey:t,maxConversations:s}=this.j.o.aiAssistantPro;if("string"==typeof e){let i=(0,l.createStorageProvider)(e,t);return new l.WebStorageConversationStorage(i,s)}return e}get stateManager(){return new o.StateManager(this.j)}get mainPanel(){return new h.UIMainPanel(this.j,this.stateManager.state,this.j.o.aiAssistantPro,e=>{let t=this.stateManager.getCurrentConversation();t&&this.stateManager.setCurrentConversation({...t,...e})})}get dialog(){let e=this.j.dlg({resizable:this.j.o.aiAssistantPro.resizable,eventEmmiter:this.j.e});return e.e.on(e,"afterClose",()=>{this.j.e.fire("closeAIAssistantPro.ai-assistant-pro")}),e}setupTextAutocomplete(){let{textAutocompleteEnabled:e,textAutocompleteApiRequest:t,textAutocompleteMinQueryLength:s,textAutocompleteMaxSuggestions:i,textAutocompleteDebounceMs:n,textAutocompleteCacheTTL:a,textAutocompleteCacheMaxSize:r}=this.j.o.aiAssistantPro;if(!e||!t)return;this.j.o.autocomplete={...this.j.o.autocomplete,displayMode:"inline"};let o=this.textAutocompleteCache,l=null;this.textAutocompleteSource=e=>{if(e.length<s)return[];let c=`${e}:${i}`;if(a>0){let e=o.get(c);if(e&&Date.now()-e.ts<a)return e.data.map(e=>({value:e,title:e}))}l&&clearTimeout(l);let h=new AbortController;return new Promise(s=>{l=setTimeout(async()=>{try{let n=await t(e,i,h.signal);if(Array.isArray(n)){let e=n.slice(0,i);if(a>0){if(o.size>=r){let e=o.keys().next().value;null!=e&&o.delete(e)}o.set(c,{ts:Date.now(),data:e})}s(e.map(e=>({value:e,title:e})));return}s([])}catch{s([])}},n)})},this.j.e.fire("registerAutocompleteSource",this.textAutocompleteSource)}afterInit(){(0,m.extendLang)(d),this.setupEventListeners(),this.setupTextAutocomplete(),this.j.async.promise(e=>{let{initiallyOpened:t,persistOpenState:s}=this.j.o.aiAssistantPro,i=t;s?this.storage.getGlobalSettings().then(e=>{if(e?.isOpen!=null&&(i=e.isOpen),i)return this.openAssistant()}).catch(()=>null).finally(()=>e(void 0)):e(void 0)}).catch(()=>null)}__loadData(){return this.__initedPromise?this.__initedPromise:this.isDestructed?Promise.reject():(this.__initedPromise=this.j.async.promise(e=>{this.loadInitialData().then(e)}).catch(()=>null),this.__initedPromise)}async loadInitialData(){this.mainPanel.setMod("ready",!0),await (0,u.loadInitialData)(this.j,this.storage,this.stateManager),await this.restorePendingToolCalls()}async restorePendingToolCalls(){let e=this.stateManager.getCurrentConversation();if(!e)return;let t=(0,u.findMessagesWithPendingToolCalls)(e);if(0!==t.length)for(let e of t)await this.handleToolCalls(e.id)}setupEventListeners(){this.j.e.on("selectConversation.ai-assistant-pro",async e=>{try{await this.__loadData(),await (0,u.handleConversationSelect)(e,this.storage,this.stateManager)}catch(e){p.IS_PROD}}),this.j.e.on("newConversation.ai-assistant-pro",async()=>{await this.__loadData();let e=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature);this.stateManager.setCurrentConversation(e)}),this.j.e.on("deleteConversation.ai-assistant-pro",async e=>{await this.__loadData(),await this.deleteConversation(e)}),this.j.e.on("renameConversation.ai-assistant-pro",async(e,t)=>{await this.__loadData(),await this.renameConversation(e,t)}),this.j.e.on("backToList.ai-assistant-pro",async()=>{await this.__loadData(),await (0,u.handleBackToList)(this.storage,this.stateManager)}),this.j.e.on("removeContext.ai-assistant-pro",async e=>{await this.__loadData(),this.stateManager.removeSelectionContext(e)}),this.j.e.on("approveToolCall.ai-assistant-pro",async(e,t)=>{try{await this.__loadData();let s=await (0,u.handleToolApproval)(e,t,this.stateManager,this.permissionManager,this.storage);if(s){let e=this.stateManager.getCurrentConversation();if(!e)return;let t=e.messages.find(e=>e.toolCalls?.some(e=>e.id===s.id));if(!t)return;await this.executeToolCall(t.id,s)}}catch(e){if((0,f.isAbortError)(e))return;this.stateManager.setError(e instanceof Error?e.message:e+"")}}),this.j.e.on("denyToolCall.ai-assistant-pro",async e=>{await this.__loadData(),await (0,u.handleToolDenial)(this.j,e,this.stateManager,this.storage)}),this.j.e.on("abortRequest.ai-assistant-pro",async()=>{await this.__loadData(),this.apiClient.abort(),this.stateManager.setLoading(!1)})}__applyTheme(){(0,u.applyTheme)(this.j,this.stateManager.state.theme,this.stateManager.state.displayMode,this.mainPanel.container,this.dialog)}async openAssistant(){if(this.stateManager.isOpen()){this.stateManager.close(),await this.__closeInContainer();return}await this.__loadData(),this.isDestructed||(this.stateManager.open(),await this.__openInContainer(),this.j.o.aiAssistantPro.includeSelectionByDefault&&!this.j.s.isCollapsed()&&this.addCurrentSelectionToContext())}async __openInContainer(){let{resizable:e,allowClose:t,flightPanelHeight:s}=this.j.o.aiAssistantPro,{displayMode:i="right",panelWidth:n,panelHeight:a}=this.stateManager.state;switch(this.__applyTheme(),this.mainPanel.setMod("displayMode",i),this.mainPanel.setMod("allowClose",t),this.mainPanel.setParentView("dialog"===i||"flight"===i?this.dialog:this.j),this.__openedMode=i,i){case"dialog":this.dialog.setSize(n,a).open().setContent(this.mainPanel.container);break;case"flight":w.UIFlightPosition.install(this.mainPanel,this.j.container,{panelHeight:s,containerClassName:this.getFullElName("flight-container")});break;default:e&&(x.UIResize.remove(this.mainPanel),x.UIResize.install(this.mainPanel,(0,u.invertMode)(i),{handleClassName:this.getFullElName("ai-assistent-resize-handle"),onResize:({newSize:e})=>{let t="left"===i||"right"===i?e:n,s="top"===i||"bottom"===i?e:a;return this.stateManager.state.panelWidth=t,this.stateManager.state.panelHeight=s,!0}})),this.j.currentPlace.slots[i].appendChild(this.mainPanel.container),(0,u.resizeInPanelView)(this.j,i,n,a)}}__onResizeInPanelView(){let{displayMode:e,panelWidth:t,panelHeight:s}=this.stateManager.state;(0,u.resizeInPanelView)(this.j,e,t,s)}async __closeInContainer(){let{displayMode:e}=await this.stateManager.state;switch(this.__openedMode!==e&&"dialog"===this.__openedMode&&this.dialog.close(),this.__openedMode!==e&&"flight"===this.__openedMode&&this.__closeFlightMode(),e){case"dialog":this.dialog.close();break;case"flight":this.__closeFlightMode();break;default:this.mainPanel.container.remove()}}__closeFlightMode(){w.UIFlightPosition.remove(this.mainPanel)}__onSavedStateChange(){let e=this.stateManager.state;return this.storage.saveGlobalSettings({displayMode:e.displayMode,panelWidth:e.panelWidth,panelHeight:e.panelHeight,theme:e.theme,defaultModel:e.defaultModel,defaultTemperature:e.defaultTemperature,currentConversationId:e.currentConversation?.id,...this.j.o.aiAssistantPro.persistOpenState?{isOpen:e.isOpen}:{}})}async closeAssistant(){this.stateManager.isOpen()&&(await this.__loadData(),this.stateManager.close(),this.__closeInContainer())}async addCurrentSelectionToContext(){await this.__loadData();let e=(0,u.getCurrentSelectionContext)(this.j);e&&this.stateManager.addSelectionContext(e)}async executeQuickCommand(e){let t,{quickCommandsSilentMode:s,quickCommandsDisplayMode:i}=this.j.o.aiAssistantPro,n=this.j.o.aiAssistant;if(n&&n[e]&&(0,f.isString)(n[e])&&(t=n[e]),!t)return void this.j.e.fire("error","Command not found: "+e);let a=this.j.s.isCollapsed()?this.j.value:this.j.s.html;if(!a)return;let r=n?.aiCommonPrefixPrompt||"",o=n?.aiCommonSuffixPrompt||"",l=`${r}${t}${o}
9
9
 
10
- ${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQuickCommandWithPanel(l,i)}async __executeQuickCommandSilent(e,t){await this.__loadData(),this.j.progressbar.show().progress(100);try{let t=(0,u.createUserMessage)(e),s=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature,[t]),i=await this.apiClient.sendRequest(s.id,s.messages,null,[],s.options);if("final"===i.mode){let e=i.response.content;e&&this.j.s.insertHTML(e)}}catch(e){(0,f.isAbortError)(e)||this.j.e.fire("error",e)}finally{this.j.progressbar.hide()}}async __executeQuickCommandWithPanel(e,t){await this.__loadData();let s=this.stateManager.state.displayMode;this.stateManager.state.displayMode=t;let i=(0,u.getCurrentSelectionContext)(this.j);i&&this.stateManager.addSelectionContext(i),this.stateManager.isOpen()||await this.openAssistant(),await this.sendMessage(e),this.stateManager.state.displayMode=s}async sendMessage(e){await this.__loadData();let t=this.stateManager.getCurrentConversation(),s=this.stateManager.getEditingMessageId();if(s&&t){let e=t.messages.findIndex(e=>e.id===s);if(-1!==e){let s=t.messages.slice(0,e),i={...t,messages:s,updatedAt:Date.now()};this.stateManager.setCurrentConversation(i),await this.storage.save(i),this.stateManager.clearEditingMessage(),t=i}}t||(t=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature),this.stateManager.setCurrentConversation(t));let i=null;e.trim()&&(i=(0,u.createUserMessage)(e),t.title||(t={...t,title:e}),t={...t,updated:Date.now(),messages:[...t.messages,i]}),this.stateManager.setCurrentConversation({...t}),i&&this.j.e.fire("messageSent.ai-assistant-pro",i),this.stateManager.setLoading(!0),this.stateManager.clearError();try{await this.sendRequestToAI(0),this.stateManager.clearSelectionContexts()}catch(e){if((0,f.isAbortError)(e))return;this.stateManager.setError(e instanceof Error?e.message:e+"")}finally{this.stateManager.setLoading(!1)}}async sendRequestToAI(e=0){let t,s,i=this.j.o.aiAssistantPro.maxRecursionToolCallDepth;if(e>=i)throw Error(`Max recursion depth ${i} reached for tool calls`);let n=this.stateManager.getCurrentConversation();if(!n)return;let r=(0,u.findParentMessageId)(n),[a]=await Promise.all([this.apiClient.sendRequest(n.id,n.messages,r,this.stateManager.getSelectionContexts(),n.options),this.storage.save(n)]);if("stream"===a.mode){let e=await (0,u.processStreamingResponse)(this.stateManager,a,n);t=e.aiMessage,s=e.index,n=e.conversation}else{let e=(0,u.processFinalResponse)(a,n);t=e.aiMessage,s=e.index,n=e.conversation}n=await (0,u.processArtifacts)(this.j,t,n,s),this.j.e.fire("messageReceived.ai-assistant-pro",t),this.stateManager.setCurrentConversation({...n}),await this.storage.save(n),await this.handleToolCalls(t.id,e)}async deleteConversation(e){await this.__loadData(),await (0,u.deleteConversationWithCleanup)(this.j,e,this.storage,this.stateManager,this.permissionManager)}async renameConversation(e,t){let s=await this.storage.get(e);if(!s)return;let i={...s,title:t,updated:Date.now()};await this.storage.save(i),this.state.currentConversation?.id===e&&this.stateManager.setCurrentConversation(i);let n=await this.storage.list();this.stateManager.setConversations(n)}async searchConversations(e){await this.__loadData(),await (0,u.handleConversationSearch)(e,this.storage,this.stateManager)}async handleToolCalls(e,t=0){let s=this.stateManager.getCurrentConversation();if(!s)return;let i=s.messages.find(t=>t.id===e);if(!i)return;let n=i.toolCalls;if(!n||0===n.length)return;let r=n.filter(e=>!(0,u.isTerminalToolCallStatus)(e.status));if(0===r.length)return;let{approved:a,needsPermission:o}=this.permissionManager.filterToolCalls(r,s.permissions);for(let s of(this.stateManager.setPendingToolCalls(o),a))await this.executeToolCall(e,s,t)}async executeToolCall(e,t,s=0){let i=this.stateManager.getCurrentConversation();if(!i)return;let n=await (0,u.executeToolCall)(this.j,t,this.toolRegistry),r=i.messages.findIndex(t=>t.id===e);if(-1===r)return;let a=i.messages[r],o=i.messages.slice();o[r]=(0,u.updateToolCallInMessage)(a,n),i={...i,messages:o,updated:Date.now()},this.stateManager.setCurrentConversation(i),(0,u.areAllToolCallsExecuted)(i)&&await this.sendRequestToAI(s+1)}async copyMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.find(t=>t.id===e);if(s)try{await navigator.clipboard.writeText(s.content),this.j.message.success("Message copied to clipboard")}catch(e){this.j.e.fire("error",Error("Failed to copy message"))}}async restartFromMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.findIndex(t=>t.id===e);if(-1===s)return;let i=t.messages[s];if("user"!==i.role)return;await this.__loadData();let n=t.messages.slice(0,s),r={...t,messages:n,updatedAt:Date.now()};this.stateManager.setCurrentConversation(r),await this.storage.save(r),await this.sendMessage(i.content)}async editMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.find(t=>t.id===e);s&&"user"===s.role&&(this.stateManager.setEditingMessageId(e),this.mainPanel.inputArea.setValue(s.content),this.mainPanel.inputArea.focus())}cancelEditMessage(){this.stateManager.isEditingMessage()&&(this.stateManager.clearEditingMessage(),this.mainPanel.inputArea.setValue(""))}async deleteMessage(e){await this.__loadData();let t=this.stateManager.getCurrentConversation();if(!t||-1===t.messages.findIndex(t=>t.id===e))return;let s=t.messages.filter(t=>t.id!==e),i={...t,messages:s,updatedAt:Date.now()};this.stateManager.setCurrentConversation(i),await this.storage.save(i)}beforeDestruct(){this.__closeFlightMode(),(0,g.cached)(this,"toolRegistry")?.destruct(),(0,g.cached)(this,"permissionManager")?.destruct(),(0,g.cached)(this,"apiClient")?.destruct(),(0,g.cached)(this,"stateManager")?.destruct(),(0,g.cached)(this,"mainPanel")?.destruct(),(0,g.cached)(this,"dialog")?.destruct(),(0,g.cached)(this,"storage")?.close?.()}constructor(...e){super(...e),(0,i._)(this,"buttons",[{name:"aiAssistantPro",group:"insert"},{name:"aiCommandsPro",group:"insert"}]),(0,i._)(this,"__initedPromise",null),(0,i._)(this,"__openedMode",null)}}(0,i._)(y,"requires",["license"]),(0,n.__decorate)([g.cache],y.prototype,"toolRegistry",null),(0,n.__decorate)([g.cache],y.prototype,"permissionManager",null),(0,n.__decorate)([g.cache],y.prototype,"apiClient",null),(0,n.__decorate)([g.cache],y.prototype,"storage",null),(0,n.__decorate)([g.cache],y.prototype,"stateManager",null),(0,n.__decorate)([g.cache],y.prototype,"mainPanel",null),(0,n.__decorate)([g.cache],y.prototype,"dialog",null),(0,n.__decorate)([(0,g.watch)("state.theme")],y.prototype,"__applyTheme",null),(0,n.__decorate)([(0,g.watch)(":openAIAssistantPro.ai-assistant-pro")],y.prototype,"openAssistant",null),(0,n.__decorate)([(0,g.watch)([":resize","state.panelWidth","state.panelHeight"])],y.prototype,"__onResizeInPanelView",null),(0,n.__decorate)([(0,g.watch)(["state.isOpen","state.displayMode","state.panelWidth","state.panelHeight","state.theme","state.defaultModel","state.defaultTemperature","state.currentConversation"]),(0,g.debounce)()],y.prototype,"__onSavedStateChange",null),(0,n.__decorate)([(0,g.watch)(":closeAIAssistantPro.ai-assistant-pro")],y.prototype,"closeAssistant",null),(0,n.__decorate)([(0,g.watch)(":addContextToAIAssistant.ai-assistant-pro")],y.prototype,"addCurrentSelectionToContext",null),(0,n.__decorate)([(0,g.watch)(":executeQuickCommand.ai-assistant-pro")],y.prototype,"executeQuickCommand",null),(0,n.__decorate)([(0,g.watch)(":sendMessage.ai-assistant-pro")],y.prototype,"sendMessage",null),(0,n.__decorate)([(0,g.watch)(":searchConversations.ai-assistant-pro")],y.prototype,"searchConversations",null),(0,n.__decorate)([(0,g.watch)(":copyMessage.ai-assistant-pro")],y.prototype,"copyMessage",null),(0,n.__decorate)([(0,g.watch)(":restartFromMessage.ai-assistant-pro")],y.prototype,"restartFromMessage",null),(0,n.__decorate)([(0,g.watch)(":editMessage.ai-assistant-pro")],y.prototype,"editMessage",null),(0,n.__decorate)([(0,g.watch)(":cancelEditMessage.ai-assistant-pro")],y.prototype,"cancelEditMessage",null),(0,n.__decorate)([(0,g.watch)(":deleteMessage.ai-assistant-pro")],y.prototype,"deleteMessage",null),y=(0,n.__decorate)([g.component],y),C.JoditPro.plugins.add("aiAssistantPro",y)},66645:function(e,t,s){"use strict";var i=s(47373),n=s(94668),r=s.n(n),a=s(86428),o=s.n(a),l=s(75966),c=s.n(l),h=s(83207),u=s.n(h),d=s(99219),p=s.n(d),g=s(63674),m=s.n(g),f=s(4133),v=s.n(f),C=s(94454),w=s(53835),x=s(6441),y=s(12153),k=s(31974),b=s(72573);y.Icon.set("ai-assistant-pro",o()).set("ai-commands-pro",c()).set("ai-add-context",r()).set("send",p()).set("tool-bolt",v()).set("chevron-right",u()).set("shield",m()),x.Config.prototype.aiAssistantPro={displayMode:"right",panelWidth:400,panelHeight:500,flightPanelHeight:250,dialogFullSize:!1,resizable:!0,apiMode:"incremental",apiRequest:null,maxRetries:3,requestTimeout:3e5,retryDelay:1e3,maxRecursionToolCallDepth:1e3,enabledTools:(0,w.getToolNames)(),customTools:[],toolPermissions:{},autoApproveTools:["readDocument","readBlocks","readSelection","insertHTML"],alwaysDenyTools:[],defaultPermissionScope:"conversation",storage:"indexedDB",maxConversations:50,storageKey:"jodit-ai-assistant-pro",showConversationList:!0,enableMarkdown:!0,enableCodeHighlight:!0,maxMessageHeight:400,placeholderText:"Ask AI assistant...",sendShortcut:"Ctrl+Enter",showTimestamps:!0,formatTimestamp(e,t){let s=new Date(e),i=new Date().getTime()-s.getTime();return i<6e4?t("Just now"):i<36e5?t("%dm ago",Math.floor(i/6e4)):i<864e5?t("%dh ago",Math.floor(i/36e5)):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},formatMessageContent:(e,t)=>b.marked.parse(e,{breaks:!0,gfm:!0}),showAvatars:!0,showTypingIndicator:!0,includeSelectionByDefault:!0,maxContextRanges:5,showContextPreview:!0,sendOnEnter:!0,instructions:void 0,includeEditorMetadata:!1,autoOpen:!0,rememberLastConversation:!0,autoFocusInput:!0,closeAfterInsert:!1,enableSoundNotifications:!1,debug:!1,quickCommandsSilentMode:!1,quickCommandsDisplayMode:"flight",showCopyMessageAction:!0,showRestartMessageAction:!0,showEditMessageAction:!0,showDeleteMessageAction:!0,dialogSettings:{},allowEditDialogSettings:!1,allowEditDisplayMode:!0,allowEditPanelWidth:!0,initiallyOpened:!1,allowClose:!0,persistOpenState:!0,theme:"parent",allowEditTheme:!0,async uploadBase64Artifact(e,t){if("image"===e.type&&e.data&&"base64"===e.data.kind)try{let s=(0,i.base64ToFile)(e.data.base64,e.id,e.mimeType),n=await t.uploader.upload([s]);return{...e,data:{kind:"url",url:n.baseurl+n.files[0]},metadata:{...e.metadata,filename:n.files[0]}}}catch(e){t.e.fire("error",e)}return e},getAIProviderOptions:(e,t)=>(0,C.getAIProviderOptions)(e,t),registerAIProvider(e,t){(0,C.registerAIProvider)(e,t)}},x.Config.prototype.controls.aiAssistantPro={icon:"ai-assistant-pro",tooltip:"AI Assistant",hotkeys:["ctrl+shift+a","cmd+shift+a"],exec(e){e.e.fire("openAIAssistantPro.ai-assistant-pro")},isDisabled:e=>!e.o.aiAssistantPro.apiRequest,getLabel:e=>e.o.aiAssistantPro.apiRequest?"AI Assistant":"AI Assistant (not configured)"},x.Config.prototype.controls.aiAddContext={icon:"ai-add-context",tooltip:"Add to AI Context",exec(e){e.e.fire("addContextToAIAssistant")},isDisabled:e=>!e.o.aiAssistantPro.apiRequest||e.s.isCollapsed()},x.Config.prototype.controls.aiCommandsPro={icon:"ai-commands-pro",tooltip:"AI Commands",isDisabled:e=>!e.o.aiAssistantPro.apiRequest,list:k.aiAssitentCommands,exec(e,t,{control:s}){e.e.fire("executeQuickCommand.ai-assistant-pro",s.name)}};let _=x.Config.prototype.tuneBlock?.popup||{},S={};["p","h1","h2","h3","h4","h5","h6","div","section","article","pre","blockquote","ul","ol","li","table","tr","td","th","img","figure"].forEach(e=>{let t=_[e]||["tune.up","tune.remove","tune.down"];S[e]=[...t,"|","aiAddContext"]}),x.Config.prototype.tuneBlock&&(x.Config.prototype.tuneBlock.popup={..._,...S})},6689:function(e,t,s){"use strict";s.d(t,{throwIfAborted:function(){return n}});var i=s(93661);function n(e){if(e.aborted)throw(0,i.abort)()}},61872:function(e,t,s){"use strict";s.d(t,{processArtifacts:function(){return a},processFinalResponse:function(){return r},processStreamingResponse:function(){return n}});var i=s(61558);async function n(e,t,s){let n=(0,i.createAIMessage)(),r=-1;for await(let a of t.stream){switch(a.type){case"created":n={...n,id:a.response.responseId,content:""},r=s.messages.length;break;case"text-delta":n={...n,content:n.content+a.delta};break;case"completed":n={...n,id:a.response.responseId,toolCalls:a.response.toolCalls||[],artifacts:a.response.artifacts||[]};break;case"error":{let e=(0,i.createErrorMessage)(a.error);n={...n,id:e.id,content:e.content}}}if(n.id){let t=s.messages.slice();t[r>=0?r:s.messages.length]=n,s={...s,messages:t,updated:Date.now()},e.setCurrentConversation(s)}}return{aiMessage:n,index:r,conversation:s}}function r(e,t){let s={...(0,i.createAIMessage)(),id:e.response.responseId,content:e.response.content,toolCalls:e.response.toolCalls||[],artifacts:e.response.artifacts||[]},n=t.messages.slice();return n.push(s),{aiMessage:s,index:(t={...t,messages:n,updated:Date.now()}).messages.length-1,conversation:t}}async function a(e,t,s,n){if(t.artifacts&&t.artifacts.length>0){let r=s.messages.slice();return r[n]={...r[n],artifacts:await (0,i.uploadArtifacts)(e,t.artifacts)},{...s,messages:r,updated:Date.now()}}return s}},49459:function(e,t,s){"use strict";function i(e,t,s={}){let n=e[t];if("string"!=typeof n||!s.allowEmpty&&""===n)throw Error(`Parameter "${t}" is required and must be a${s.allowEmpty?"":" non-empty"} string`);return n}s.d(t,{requireString:function(){return i}})},44526:function(e,t,s){"use strict";s.d(t,{resolveBlock:function(){return n}});var i=s(22732);function n(e,{selector:t,index:s,requireExactlyOne:r=!1}={}){let a=null!=t&&""!==t.trim(),o=null!=s;if(r&&a===o)throw Error("Either index or selector must be provided, but not both");if(!a&&!o)throw Error("Block identifier is required");if(a){if("string"!=typeof t)throw Error("Selector must be a string");let s=e.editor.querySelector(t);if(!s)throw Error(`No element found matching selector "${t}"`);if(!i.Dom.isElement(s))throw Error(`Selector "${t}" does not point to an element node`);return{element:s,identifier:`with selector "${t}"`}}if("number"!=typeof s)throw Error("Block index must be a number");let l=Array.from(e.editor.children);if(s<0||s>=l.length)throw Error(`Block index ${s} is out of range. Document has ${l.length} blocks`);let c=l[s];if(!i.Dom.isElement(c))throw Error(`Block at index ${s} is not a valid element`);return{element:c,identifier:"at index "+s}}},70308:function(e,t,s){"use strict";s.d(t,{areAllToolCallsExecuted:function(){return l},createNewConversation:function(){return n},findMessagesWithPendingToolCalls:function(){return c},findParentMessageId:function(){return r},isTerminalToolCallStatus:function(){return o}});var i=s(21064);function n(e,t,s,r=[]){let a=e.o.aiAssistantPro,o={id:(0,i.generateConversationId)(),created:Date.now(),updated:Date.now(),messages:r,permissions:[],options:{model:t??a.defaultModel,temperature:s??a.defaultTemperature}};return e.e.fire("conversationCreated.ai-assistant-pro",o),o}function r(e){for(let t=e.messages.length-1;t>=0;t--){let s=e.messages[t];if("assistant"===s.role&&!s.id.startsWith("error_"))return s.id}return null}let a=new Set(["executed","denied","error"]);function o(e){return a.has(e)}function l(e){let t=e.messages[e.messages.length-1];return!!t?.toolCalls&&t.toolCalls.every(e=>o(e.status))}function c(e){return e.messages.filter(e=>e.toolCalls&&e.toolCalls.length>0&&e.toolCalls.some(e=>!o(e.status)))}},473:function(e,t,s){"use strict";s.d(t,{handleBackToList:function(){return l},handleConversationSearch:function(){return c},handleConversationSelect:function(){return o},handleToolApproval:function(){return r},handleToolDenial:function(){return a}});var i=s(79078),n=s(82758);async function r(e,t,s,i,n){let r=s.getPendingToolCalls().find(t=>t.id===e);if(!r)return null;let a=i.grantPermission(r.name,t),o=s.getCurrentConversation();return o&&(o.permissions.push(a),await n.save(o)),s.removePendingToolCall(e),{...r,status:"approved"}}async function a(e,t,s,n){let r=s.getPendingToolCalls().find(e=>e.id===t);if(!r)return;let a=s.getCurrentConversation();if(!a)return;let o=a.messages.findIndex(e=>e.toolCalls?.find(e=>e.id===t));if(-1===o)return;let l=a.messages[o],c={...r,result:{error:"Tool call denied by user."},status:"denied"},h=(0,i.updateToolCallInMessage)(l,c),u=[...a.messages];u[o]=h,a={...a,messages:u,updated:Date.now()},s.setCurrentConversation(a),await n.save(a),e.e.fire("toolCallDenied.ai-assistant-pro",r),s.removePendingToolCall(t)}async function o(e,t,s){try{s.setLoading(!0);let i=await t.get(e);if(!i)throw Error("Conversation not found: "+e);s.setCurrentConversation({...i})}catch(e){n.IS_PROD}finally{s.setLoading(!1)}}async function l(e,t){t.setView("conversationList");try{t.setLoading(!0);let s=await e.list().catch(()=>[]);t.setConversations(s)}finally{t.setLoading(!1)}}async function c(e,t,s){s.setLoading(!0);try{let i=await t.list(e||void 0);s.setConversations(i),s.setView("conversationList")}finally{s.setLoading(!1)}}},58579:function(e,t,s){"use strict";s.d(t,{applyTheme:function(){return h.applyTheme},areAllToolCallsExecuted:function(){return n.areAllToolCallsExecuted},createNewConversation:function(){return n.createNewConversation},createUserMessage:function(){return a.createUserMessage},deleteConversationWithCleanup:function(){return c.deleteConversationWithCleanup},executeToolCall:function(){return u.executeToolCall},findMessagesWithPendingToolCalls:function(){return n.findMessagesWithPendingToolCalls},findParentMessageId:function(){return n.findParentMessageId},getCurrentSelectionContext:function(){return l.getCurrentSelectionContext},handleBackToList:function(){return r.handleBackToList},handleConversationSearch:function(){return r.handleConversationSearch},handleConversationSelect:function(){return r.handleConversationSelect},handleToolApproval:function(){return r.handleToolApproval},handleToolDenial:function(){return r.handleToolDenial},invertMode:function(){return o.invertMode},isTerminalToolCallStatus:function(){return n.isTerminalToolCallStatus},loadInitialData:function(){return c.loadInitialData},processArtifacts:function(){return i.processArtifacts},processFinalResponse:function(){return i.processFinalResponse},processStreamingResponse:function(){return i.processStreamingResponse},resizeInPanelView:function(){return o.resizeInPanelView},updateToolCallInMessage:function(){return u.updateToolCallInMessage}});var i=s(61872),n=s(70308),r=s(473),a=s(61558),o=s(71050),l=s(15927),c=s(56110),h=s(53014),u=s(79078)},61558:function(e,t,s){"use strict";s.d(t,{createAIMessage:function(){return r},createErrorMessage:function(){return a},createUserMessage:function(){return n},uploadArtifacts:function(){return o}});var i=s(21064);function n(e){return{id:(0,i.generateMessageId)(),role:"user",content:e,timestamp:Date.now()}}function r(){return{id:"",role:"assistant",content:"",artifacts:[],timestamp:Date.now(),toolCalls:[]}}function a(e){return{id:"error_"+(0,i.generateMessageId)(),role:"assistant",content:"❌ Error: "+e.message,timestamp:Date.now(),toolCalls:[],artifacts:[]}}async function o(e,t){if(!t||0===t.length)return t;let s=e.o.aiAssistantPro.uploadBase64Artifact;return s?Promise.all(t.map(async t=>s(t,e)??t)):t}},71050:function(e,t,s){"use strict";s.d(t,{invertMode:function(){return n},resizeInPanelView:function(){return r}});var i=s(41180);function n(e){switch(e){case"left":return"right";case"right":return"left";case"top":return"bottom";case"bottom":return"top"}}function r(e,t,s,r){if("dialog"===t||"flight"===t)return;("left"===t||"right"===t)&&(e.currentPlace.slots[n(t)]?.style.setProperty(`--jd-slot-${n(t)}-width`,"auto"),e.currentPlace.slots[t]?.style.setProperty(`--jd-slot-${t}-width`,`${s}px`));let a=(0,i.css)(e.currentPlace.workplace,"height")??0;e.currentPlace.slots[t]?.style.setProperty("min-height",`${Math.min(a,r)}px`)}},15927:function(e,t,s){"use strict";function i(e){if(e.s.isCollapsed())return null;let t=e.s.html,s=e.s.range;return{html:t,rangeInfo:{startContainer:s.startContainer.nodeName,startOffset:s.startOffset,endContainer:s.endContainer.nodeName,endOffset:s.endOffset}}}s.d(t,{getCurrentSelectionContext:function(){return i}})},56110:function(e,t,s){"use strict";s.d(t,{deleteConversationWithCleanup:function(){return n},loadInitialData:function(){return r}});var i=s(82758);async function n(e,t,s,i,n){try{i.setLoading(!0),await s.delete(t),i.removeConversation(t),n.clearConversationPermissions(t);let r=i.getCurrentConversation();r?.id===t&&i.setCurrentConversation(null);let a=await s.list();i.setConversations(a),i.setView(0===a.length?"welcome":"conversationList"),e.e.fire("conversationDeleted.ai-assistant-pro",t)}catch(t){e.alert(e.i18n("Failed to delete conversation")+": "+(t?.message||"Unknown error"))}finally{i.setLoading(!1)}}async function r(e,t,s){s.setLoading(!0);try{let[i,n]=await Promise.all([t.list().catch(()=>[]),t.getGlobalSettings().catch(()=>null)]);if(s.setConversations(i),n&&s.setSavedState(n),0===i.length)s.setView("welcome");else if(e.o.aiAssistantPro.rememberLastConversation&&n?.currentConversationId){let e=i.find(e=>e.id===n.currentConversationId)??i[0],r=await t.get(e.id);r?s.setCurrentConversation(r):s.setView("conversationList")}else s.setView("conversationList")}catch(e){i.IS_PROD,s.setView("welcome")}finally{s.setLoading(!1)}}},53014:function(e,t,s){"use strict";s.d(t,{applyTheme:function(){return r}});let i=["jodit_theme_dark","jodit-ai-assistant-pro_theme_dark","jodit-dialog_theme_dark"],n=["jodit_theme_light","jodit-ai-assistant-pro_theme_light","jodit-dialog_theme_light"];function r(e,t,s,r,a){let o;if(r?.classList.remove(...i),r?.classList.remove(...n),"dialog"===s){let e=a?.container;e?.classList.remove(...i),e?.classList.remove(...n)}if(o="dark"===t?i:n,r?.classList.add(...o),"dialog"===s){let e=a?.container;e?.classList.add(...o)}}},79078:function(e,t,s){"use strict";async function i(e,t,s){let i;try{let e=new AbortController().signal,n=await s.executeTool(t.name,t.arguments,e);i={...t,result:{result:n},status:"executed"}}catch(s){i={...t,result:{error:s instanceof Error?s.message:s+""},status:"error"},e.e.fire("toolCallFailed.ai-assistant-pro",i)}return e.e.fire("toolCallExecuted.ai-assistant-pro",i,{toolCallId:i.id,result:i.result}),i}function n(e,t){let s=e.toolCalls?.findIndex(e=>e.id===t.id);if(null==s||-1===s)return e;let i=[...e?.toolCalls??[]];return i[s]=t,{...e,toolCalls:i}}s.d(t,{executeToolCall:function(){return i},updateToolCallInMessage:function(){return n}})},86449:function(e,t,s){"use strict";s.d(t,{APIClient:function(){return a}});var i=s(82749),n=s(82758),r=s(21537);class a{async sendRequest(e,t,s,i,a){let{apiRequest:o,requestTimeout:l,maxRetries:c}=this.jodit.o.aiAssistantPro;if(!o)throw Error("AI Assistant Pro callback is not configured");let h=new AbortController;this.abortControllers.add(h);try{let u=this.buildRequestContext(e,t,s,i,a),d=null;for(let e=0;c>=e;e++)try{if(h.signal.aborted)throw(0,r.abort)();let e=setTimeout(()=>{h.abort()},l);try{let t=await o(u,h.signal);return clearTimeout(e),this.validateResponse(t),t}catch(t){throw clearTimeout(e),t}}catch(t){if(d=t,n.IS_PROD,c>e){let t=this.calculateRetryDelay(e);await this.sleep(t)}else throw t}throw d||Error("API request failed after all retries")}finally{this.abortControllers.delete(h)}}abort(){this.abortControllers.forEach(e=>{e.abort()}),this.abortControllers.clear()}isInProgress(){return this.abortControllers.size>0}buildRequestContext(e,t,s,i,n){let r,{apiMode:a,instructions:o}=this.jodit.o.aiAssistantPro,l={mode:a,conversationId:e,tools:this.toolRegistry.getAllTools(),selectionContexts:i,conversationOptions:n,instructions:o};if("full"===a)r=t;else if(s){let e=t.findIndex(e=>e.id===s);r=-1!==e?t.slice(e+1):t,l={...l,parentMessageId:s}}else r=t;return{...l,messages:this.expandToolMessages(r,t.find(e=>e.id===s))}}expandToolMessages(e,t){let s=[];for(let t of e)s.push(t),this.expandToolResultsMessage(t,s);return t&&this.expandToolResultsMessage(t,s),s}expandToolResultsMessage(e,t){if(e.toolCalls&&e.toolCalls.length>0)for(let s of e.toolCalls){let i=s.result??{error:"result not found"};if(t.find(e=>e.id===`${s.id}-result`))continue;let n={id:`${s.id}-result`,role:"tool",content:i.error?"Error: "+i.error:JSON.stringify(i.result),timestamp:e.timestamp,toolResults:[{toolCallId:s.id,result:i}]};t.push(n)}}validateResponse(e){if("final"!==e.mode)return;let t=e.response;if(!t)throw Error("API returned empty response");if(!t.responseId)throw Error("API response missing responseId");if(void 0===t.content)throw Error("API response missing content");if(void 0===t.finished)throw Error("API response missing finished flag");if(t.toolCalls){if(!Array.isArray(t.toolCalls))throw Error("API response toolCalls must be an array");t.toolCalls.forEach((e,t)=>{if(!e.id)throw Error(`Tool call at index ${t} is missing id`);if(!e.name)throw Error(`Tool call at index ${t} is missing name`);if(!e.arguments||"object"!=typeof e.arguments)throw Error(`Tool call at index ${t} has invalid arguments`)})}}calculateRetryDelay(e){let{retryDelay:t}=this.jodit.o.aiAssistantPro;return t*Math.pow(2,e)+Math.random()*t}sleep(e){return new Promise(t=>setTimeout(t,e))}destruct(){this.abort()}constructor(e,t){(0,i._)(this,"jodit",void 0),(0,i._)(this,"toolRegistry",void 0),(0,i._)(this,"abortControllers",void 0),this.jodit=e,this.toolRegistry=t,this.abortControllers=new Set}}},47373:function(e,t,s){"use strict";function i(e,t,s="image/png"){let n=atob(e),r=n.length,a=new Uint8Array(r);for(let e=0;r>e;e++)a[e]=n.charCodeAt(e);return new File([new Blob([a],{type:s})],t,{type:s})}s.d(t,{base64ToFile:function(){return i}})},21020:function(e,t,s){"use strict";s.d(t,{PermissionManager:function(){return n}});var i=s(82749);class n{requiresPermission(e){let{autoApproveTools:t,alwaysDenyTools:s}=this.jodit.o.aiAssistantPro;if(s.includes(e))return!0;if(t.includes(e))return!1;let i=this.toolRegistry.getTool(e);return!i||i.requiresPermission}isAutoDenied(e){let{alwaysDenyTools:t}=this.jodit.o.aiAssistantPro;return t.includes(e)}isAutoApproved(e){let{autoApproveTools:t}=this.jodit.o.aiAssistantPro;return t.includes(e)}checkPermission(e,t){if(this.isAutoApproved(e))return{toolName:e,granted:!0,grantedAt:Date.now(),scope:"once"};if(this.isAutoDenied(e))return null;let s=this.permanentPermissions.get(e);return s&&s.granted?s:t.find(t=>t.toolName===e&&t.granted)||null}grantPermission(e,t){let s={toolName:e,granted:!0,grantedAt:Date.now(),scope:t};return"forever"===t&&(this.permanentPermissions.set(e,s),this.savePermanentPermissions()),s}denyPermission(e){return{toolName:e,granted:!1,grantedAt:Date.now(),scope:"once"}}filterToolCalls(e,t){let s=[],i=[],n=[];for(let r of e){if(this.isAutoDenied(r.name)){n.push({...r,status:"denied"});continue}if(this.isAutoApproved(r.name)){s.push({...r,status:"approved"});continue}let e=this.checkPermission(r.name,t);e&&e.granted?s.push({...r,status:"approved"}):this.requiresPermission(r.name)?(this.jodit.e.fire("permissionRequested.ai-assistant-pro",r.name),i.push({...r,status:"pending"})):s.push({...r,status:"approved"})}return{approved:s,needsPermission:i,denied:n}}clearConversationPermissions(e){}loadPermanentPermissions(){try{let e=localStorage.getItem(this.PERMANENT_PERMISSIONS_KEY);e&&JSON.parse(e).forEach(e=>{"forever"===e.scope&&e.granted&&this.permanentPermissions.set(e.toolName,e)})}catch(e){}}savePermanentPermissions(){try{let e=Array.from(this.permanentPermissions.values());localStorage.setItem(this.PERMANENT_PERMISSIONS_KEY,JSON.stringify(e))}catch(e){}}clearPermanentPermissions(){this.permanentPermissions.clear(),localStorage.removeItem(this.PERMANENT_PERMISSIONS_KEY)}getPermanentPermissions(){return Array.from(this.permanentPermissions.values())}revokePermanentPermission(e){this.permanentPermissions.delete(e),this.savePermanentPermissions()}destruct(){this.permanentPermissions.clear()}constructor(e,t){(0,i._)(this,"jodit",void 0),(0,i._)(this,"toolRegistry",void 0),(0,i._)(this,"permanentPermissions",void 0),(0,i._)(this,"PERMANENT_PERMISSIONS_KEY",void 0),this.jodit=e,this.toolRegistry=t,this.permanentPermissions=new Map,this.PERMANENT_PERMISSIONS_KEY="jodit-permissions.ai-assistant-pro",this.loadPermanentPermissions()}}},46166:function(e,t,s){"use strict";s.d(t,{StateManager:function(){return n}});var i=s(82749);class n{createInitialState(){return{isOpen:!1,currentView:"welcome",currentConversation:null,conversations:[],isLoading:!1,error:null,pendingToolCalls:[],selectionContexts:[],abortController:null,editingMessageId:null,theme:this.jodit.o.aiAssistantPro.theme||"parent",displayMode:this.jodit.o.aiAssistantPro.displayMode,panelWidth:this.jodit.o.aiAssistantPro.panelWidth,panelHeight:this.jodit.o.aiAssistantPro.panelHeight,defaultModel:this.jodit.o.aiAssistantPro.defaultModel,defaultTemperature:this.jodit.o.aiAssistantPro.defaultTemperature}}open(){this.state.isOpen=!0,this.jodit.e.fire("open.ai-assistant-pro",this.state.currentConversation)}close(){this.state.isOpen=!1,this.jodit.e.fire("close.ai-assistant-pro")}isOpen(){return this.state.isOpen}setView(e){this.state.currentView=e,this.jodit.e.fire("viewChanged.ai-assistant-pro",e)}getView(){return this.state.currentView}setConversations(e){this.state.conversations=e}setSavedState(e){e.theme&&(this.state.theme=e.theme),e.displayMode&&(this.state.displayMode=e.displayMode),e.panelWidth&&(this.state.panelWidth=e.panelWidth),e.panelHeight&&(this.state.panelHeight=e.panelHeight),e.defaultModel&&(this.state.defaultModel=e.defaultModel),e.defaultTemperature&&(this.state.defaultTemperature=e.defaultTemperature)}getConversations(){return this.state.conversations}setCurrentConversation(e){if(this.state.currentConversation===e)throw Error("Conversation is already current");this.state.currentConversation=e||null,e&&(this.setView("conversation"),this.jodit.e.fire("conversationSwitched.ai-assistant-pro",e))}getCurrentConversation(){return this.state.currentConversation}removeConversation(e){let t=this.state.conversations.filter(t=>t.id!==e);this.setConversations(t)}setLoading(e){this.state.isLoading=e}isLoading(){return this.state.isLoading}setError(e){this.state.error=e,e&&this.jodit.e.fire("error.ai-assistant-pro",Error(e))}getError(){return this.state.error}clearError(){this.setError(null)}setPendingToolCalls(e){this.state.pendingToolCalls=e}getPendingToolCalls(){return this.state.pendingToolCalls}addPendingToolCall(e){let t=[...this.state.pendingToolCalls,e];this.setPendingToolCalls(t)}removePendingToolCall(e){let t=this.state.pendingToolCalls.filter(t=>t.id!==e);this.setPendingToolCalls(t)}updateToolCallStatus(e,t){let s=this.state.pendingToolCalls.map(s=>s.id===e?{...s,status:t}:s);this.setPendingToolCalls(s)}setSelectionContexts(e){this.state.selectionContexts=e}getSelectionContexts(){return this.state.selectionContexts}addSelectionContext(e){let{maxContextRanges:t}=this.jodit.o.aiAssistantPro,s=[...this.state.selectionContexts,e];s.length>t&&(s=s.slice(-t)),this.setSelectionContexts(s),this.jodit.e.fire("contextAdded.ai-assistant-pro",e)}removeSelectionContext(e){let t=this.state.selectionContexts.filter((t,s)=>s!==e);this.setSelectionContexts(t),this.jodit.e.fire("contextRemoved.ai-assistant-pro",e)}clearSelectionContexts(){this.setSelectionContexts([])}setAbortController(e){this.state.abortController=e}getAbortController(){return this.state.abortController}setEditingMessageId(e){this.state.editingMessageId=e}getEditingMessageId(){return this.state.editingMessageId}isEditingMessage(){return null!=this.state.editingMessageId}clearEditingMessage(){this.setEditingMessageId(null)}reset(){this.state=this.createInitialState()}destruct(){this.state.abortController&&this.state.abortController.abort(),this.reset()}constructor(e){(0,i._)(this,"jodit",void 0),(0,i._)(this,"state",void 0),this.jodit=e,this.state=this.createInitialState()}}},62895:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return i.WebStorageConversationStorage},createStorageProvider:function(){return i.createStorageProvider}});var i=s(21064)},21064:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return r},createStorageProvider:function(){return a},generateConversationId:function(){return o},generateMessageId:function(){return l}});var i=s(82749),n=s(97333);class r{close(){return this.storage.close()}getConversationKey(e){return"conv:"+e}async getAllKeys(){let e=await this.storage.get("__conversation_index__");return e&&Array.isArray(e)?e:[]}async updateIndex(e){await this.storage.set("__conversation_index__",e)}async addToIndex(e){let t=await this.getAllKeys();t.includes(e)||(t.push(e),await this.updateIndex(t))}async removeFromIndex(e){let t=(await this.getAllKeys()).filter(t=>t!==e);await this.updateIndex(t)}async list(e){try{let t=await this.getAllKeys(),s=[],i=e?.toLowerCase().trim();for(let e of t){let t=await this.get(e);if(t){if(i){let e=t.title?.toLowerCase().includes(i),s=!e&&t.messages.some(e=>e.content.toLowerCase().includes(i));if(!e&&!s)continue}s.push({id:t.id,title:t.title??"",created:t.created,updated:t.updated,messageCount:t.messages.length})}}return s.sort((e,t)=>t.updated-e.updated),s}catch(e){return[]}}async get(e){try{let t=this.getConversationKey(e);return await this.storage.get(t)||null}catch(e){return null}}async save(e){try{if(0===e.messages.length)throw Error("Conversation must have at least one message.");let t=await this.getAllKeys();t.length>=this.maxConversations&&!t.includes(e.id)&&await this.evictOldest();let s=this.getConversationKey(e.id);await this.storage.set(s,e),await this.addToIndex(e.id)}catch(t){if(t?.name==="QuotaExceededError"||t?.code===22||t?.code===1014){await this.evictOldest();try{let t=this.getConversationKey(e.id);await this.storage.set(t,e),await this.addToIndex(e.id)}catch{throw Error("Storage quota exceeded. Please delete some conversations.")}}else throw Error("Failed to save conversation: "+(t?.message||"Unknown error"))}}async delete(e){try{let t=this.getConversationKey(e);await this.storage.delete(t),await this.removeFromIndex(e)}catch(e){}}async clear(){try{for(let e of(await this.getAllKeys())){let t=this.getConversationKey(e);await this.storage.delete(t)}await this.updateIndex([])}catch(e){}}async evictOldest(){try{let e=await this.list();if(0===e.length)return;e.sort((e,t)=>e.updated-t.updated);let t=e[0];await this.delete(t.id)}catch(e){}}async getGlobalSettings(){try{return await this.storage.get("global-settings")||null}catch(e){return null}}async saveGlobalSettings(e){try{let t={...await this.getGlobalSettings(),...e};await this.storage.set("global-settings",t)}catch{throw Error("Failed to save global settings")}}constructor(e,t){(0,i._)(this,"storage",void 0),(0,i._)(this,"maxConversations",void 0),this.storage=e,this.maxConversations=t}}function a(e,t){return n.AsyncStorage.makeStorage(e,t)}function o(){return`conv_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function l(){return`msg_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}},55487:function(e,t,s){"use strict";s.d(t,{ToolRegistry:function(){return r}});var i=s(82749),n=s(53835);class r{registerBuiltInTools(e){e.forEach(e=>{let t=n.BUILT_IN_TOOLS[e];t&&this.tools.set(e,t)})}registerCustomTools(e){e.forEach(e=>{this.validateToolDefinition(e),this.tools.set(e.name,e)})}validateToolDefinition(e){if(!e.name||"string"!=typeof e.name)throw Error("Tool must have a valid name");if(!e.description||"string"!=typeof e.description)throw Error(`Tool "${e.name}" must have a description`);if(!Array.isArray(e.parameters))throw Error(`Tool "${e.name}" must have a parameters array`);if("function"!=typeof e.execute)throw Error(`Tool "${e.name}" must have an execute function`);e.parameters.forEach(t=>{if(!t.name||"string"!=typeof t.name)throw Error(`Tool "${e.name}" has a parameter without a valid name`);if(!t.type)throw Error(`Tool "${e.name}" parameter "${t.name}" must have a type`);if("boolean"!=typeof t.required)throw Error(`Tool "${e.name}" parameter "${t.name}" must specify if it's required`)})}getAllTools(){return Array.from(this.tools.values())}getTool(e){return this.tools.get(e)}hasTool(e){return this.tools.has(e)}getToolNames(){return Array.from(this.tools.keys())}async executeTool(e,t,s){let i=this.getTool(e);if(!i)throw Error(`Tool "${e}" not found`);let n=this.applyDefaults(i,t);this.validateArguments(i,n);try{return await i.execute(this.jodit,n,s)}catch(e){if(e?.name==="AbortError"||s.aborted)throw Error("Tool execution was aborted");throw e}}validateArguments(e,t){let s=Object.keys(t);for(let t of e.parameters.filter(e=>e.required).map(e=>e.name))if(!s.includes(t))throw Error(`Tool "${e.name}" requires parameter "${t}"`);for(let[s,i]of Object.entries(t)){let t=e.parameters.find(e=>e.name===s);if(!t){this.jodit.o.aiAssistantPro.debug;continue}let n=Array.isArray(i)?"array":"object"==typeof i&&null!=i?"object":typeof i;if(t.type!==n&&!("number"===t.type&&"string"===n&&!isNaN(Number(i))))throw Error(`Tool "${e.name}" parameter "${s}" expects type "${t.type}" but got "${n}"`);if(t.enum&&t.enum.length>0&&!t.enum.includes(i))throw Error(`Tool "${e.name}" parameter "${s}" must be one of: ${t.enum.join(", ")}`)}}applyDefaults(e,t){let s={...t};for(let t of e.parameters)void 0===s[t.name]&&void 0!==t.default&&(s[t.name]=t.default);return s}destruct(){this.tools.clear()}constructor(e){(0,i._)(this,"jodit",void 0),(0,i._)(this,"tools",void 0),this.jodit=e,this.tools=new Map,this.registerBuiltInTools(e.o.aiAssistantPro.enabledTools||[]),this.registerCustomTools(e.o.aiAssistantPro.customTools||[])}}},26612:function(e){e.exports={"AI Assistant":"AI Assistant","AI Assistant Pro":"AI Assistant Pro","Welcome to AI Assistant":"Welcome to AI Assistant","Start your first conversation":"Start your first conversation","Tip: Select text in editor to add context":"Tip: Select text in editor to add context","New Chat":"New Chat","Search conversations...":"Search conversations...","No conversations yet":"No conversations yet","Ask me anything...":"Ask me anything...","Ask a follow-up...":"Ask a follow-up...","Reply...":"Reply...","Type your message...":"Type your message...",Send:"Send",Cancel:"Cancel",Retry:"Retry",Insert:"Insert",Copy:"Copy",Edit:"Edit",Delete:"Delete",New:"New",Back:"Back","Permission Required":"Permission Required",Approve:"Approve",Deny:"Deny",Once:"Once","This conversation":"This conversation",Always:"Always","The AI wants to execute:":"The AI wants to execute:","This will modify your document content.":"This will modify your document content.","Executing...":"Executing...","Completed successfully":"Completed successfully",Failed:"Failed","Pending approval":"Pending approval","Denied by user":"Denied by user","Tool Result":"Tool Result","Tool Execution Error":"Tool Execution Error",Context:"Context",Contexts:"Contexts","Add to AI Context":"Add to AI Context",Remove:"Remove","Clear all":"Clear all","An error occurred":"An error occurred","Request failed":"Request failed","Connection error":"Connection error","AI Assistant is not configured":"AI Assistant is not configured","Thinking...":"Thinking...","Generating response...":"Generating response...",insertHTML:"Insert HTML",readDocument:"Read Document",readBlock:"Read Block",replaceInDocument:"Replace in Document",replaceInBlock:"Replace in Block",getSelection:"Get Selection","Just now":"Just now",Conversation:"Conversation","New Conversation":"New Conversation",Yesterday:"Yesterday","Delete conversation":"Delete conversation","Are you sure you want to delete this conversation?":"Are you sure you want to delete this conversation?","Failed to delete conversation":"Failed to delete conversation"}},63805:function(e,t,s){"use strict";s.r(t),s.d(t,{en:function(){return n.a},ru:function(){return a.a}});var i=s(26612),n=s.n(i),r=s(41324),a=s.n(r)},94454:function(e,t,s){"use strict";s.d(t,{getAIProviderOptions:function(){return i.getAIProviderOptions},registerAIProvider:function(){return i.registerAIProvider}}),s(82923);var i=s(58211)},82923:function(e,t,s){"use strict";var i=s(58211),n=s(54079);(0,i.registerAIProvider)("jodit-ai-adapter",e=>{let t=e.url.replace(/\/+$/,""),s=e.provider??"openai",i=!1!==e.stream;return{apiMode:"incremental",maxRetries:0,async apiRequest(r,a){let o=new n.Ajax({url:`${t}/ai/request?key=${encodeURIComponent(e.apiKey)}`,method:"POST",contentType:"application/json",data:{provider:s,context:i?{...r,metadata:{...r.metadata,stream:!0}}:r}});if(a&&a.addEventListener("abort",()=>o.abort(),{once:!0}),!i){let e=await o.send();return{mode:"final",response:(await e.json()).result}}let l=o.stream();return{mode:"stream",stream:async function*(){for await(let e of l)yield JSON.parse(e)}()}}}})},58211:function(e,t,s){"use strict";s.d(t,{getAIProviderOptions:function(){return n},registerAIProvider:function(){return r}});let i=new Map;function n(e,t){let s=i.get(e);if(!s)throw Error(`AI provider "${e}" is not registered. Available providers: `+[...i.keys()].join(", "));return s(t)}function r(e,t){i.set(e,t)}},73943:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="applyFormat",n="Apply or remove inline formatting to the current selection (bold, italic, underline, etc.) or to a specific block",r=[{name:"element",type:"string",description:'HTML element to wrap selection (e.g., "strong", "em", "u", "span")',required:!1},{name:"attributes",type:"object",description:'Attributes to apply (e.g., {"className": "highlight"}, {"style": {"color": "red"}})',required:!1},{name:"remove",type:"boolean",description:"If true, remove the formatting instead of applying it",required:!1,default:!1},{name:"blockIndex",type:"number",description:"Zero-based index of the block to format (if not using current selection)",required:!1},{name:"selector",type:"string",description:"CSS selector to find the block to format (if not using current selection)",required:!1}],a=!0},19127:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(44526);async function r(e,t,s){let{element:r,attributes:a,remove:o,blockIndex:l,selector:c}=t;if((0,i.throwIfAborted)(s),!r&&!a)throw Error('Either "element" or "attributes" must be provided');if(e.s.restore(),void 0!==l||c){let{element:t}=(0,n.resolveBlock)(e,{selector:c,index:l});e.s.select(t)}if(e.s.isCollapsed())throw Error("No selection found. Please select text to format");try{let t={};return r&&(t.element=r),a&&(t.attributes=a),o?e.s.commitStyle({...t,mode:"remove"}):e.s.commitStyle(t),e.synchronizeValues(),{success:!0,message:o?"Formatting removed successfully":"Formatting applied successfully"}}catch(e){throw Error(`Failed to ${o?"remove":"apply"} formatting: ${e.message}`)}}},39296:function(e,t,s){"use strict";var i=s(73943),n=s(19127);t.default={...i,execute:n.execute}},53835:function(e,t,s){"use strict";s.d(t,{BUILT_IN_TOOLS:function(){return d},getToolNames:function(){return p}});var i=s(39296),n=s(16745),r=s(78717),a=s(5618),o=s(90991),l=s(2020),c=s(12570),h=s(95323),u=s(97603);let d={readDocument:a.default,readBlocks:r.default,readSelection:o.default,writeDocument:u.default,replaceSelection:h.default,replaceBlock:l.default,replaceInDocument:c.default,insertHTML:n.default,applyFormat:i.default};function p(){return Object.keys(d)}},56732:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="insertHTML",n="Insert or replace HTML content at the current cursor position in the editor",r=[{name:"html",type:"string",description:"HTML content to insert",required:!0},{name:"replace",type:"boolean",description:"If true, replaces current selection. If false, inserts at cursor",required:!1,default:!1}],a=!0},39592:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"html",{allowEmpty:!0}),{replace:a}=t;if(!r.trim())return{success:!0,message:"Nothing to insert: HTML is empty"};(0,i.throwIfAborted)(s);try{return e.s.focus(),a&&!e.s.isCollapsed()&&e.s.remove(),e.s.insertHTML(r),e.synchronizeValues(),{success:!0,message:`Inserted ${r.length} characters of HTML`}}catch(e){throw Error("Failed to insert HTML: "+(e?.message||"Unknown error"))}}},16745:function(e,t,s){"use strict";var i=s(56732),n=s(39592);t.default={...i,execute:n.execute}},75352:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="readBlocks",n="Read blocks from the editor with optional filtering and pagination",r=[{name:"offset",type:"number",description:"Number of blocks to skip from the beginning (default: 0)",required:!1,default:0},{name:"limit",type:"number",description:"Maximum number of blocks to return (default: all)",required:!1},{name:"query",type:"string",description:"Filter blocks by text content",required:!1}],a=!1},91140:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(22732);async function r(e,t,s){let{offset:r,limit:a,query:o}=t;(0,i.throwIfAborted)(s);let l=[];Array.from(e.editor.children).forEach((e,t)=>{n.Dom.isElement(e)&&l.push({blockIndex:t,tagName:e.tagName.toLowerCase(),content:e.innerHTML,textContent:e.textContent||"",classList:Array.from(e.classList)})});let c=l;if(o&&"string"==typeof o){let e=o.toLowerCase();c=l.filter(t=>t.textContent.toLowerCase().includes(e))}let h=Math.max(0,Math.min("number"==typeof r?r:0,c.length)),u=void 0!==a?Math.min(h+a,c.length):c.length;return{blocks:c.slice(h,u),total:l.length,offset:h,limit:void 0!==a?a:void 0}}},78717:function(e,t,s){"use strict";var i=s(75352),n=s(91140);t.default={...i,execute:n.execute}},93809:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="readDocument",n="Read the entire content of the editor document in HTML format",r=[{name:"start",type:"number",description:"Start character position (default: 0)",required:!1,default:0},{name:"end",type:"number",description:"End character position (default: length of document)",required:!1},{name:"aroundSelection",type:"boolean",description:"If true, return only the maximum block around the current selection",required:!1,default:!1}],a=!1},28157:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(22732);async function r(e,t,s){let{start:r,end:a,aroundSelection:o}=t;(0,i.throwIfAborted)(s);let l=e.value,c=l.length;if(o&&!e.s.isCollapsed()){let t=e.s.range.commonAncestorContainer;for(;t&&t!==e.editor;){if(n.Dom.isElement(t)&&t.parentNode===e.editor){l=t.outerHTML;break}t=t.parentNode}return{html:l,length:c}}let h=void 0!==a?Math.min(a,c):c,u=Math.max(0,Math.min("number"==typeof r?r:0,c));return(u>0||c>h)&&(l=l.substring(u,h)),{html:l,length:c,start:u,end:h}}},5618:function(e,t,s){"use strict";var i=s(93809),n=s(28157);t.default={...i,execute:n.execute}},52826:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="readSelection",n="Get information about the current selection including HTML content and optional context",r=[{name:"contextCharsBefore",type:"number",description:"Number of characters to include before the selection",required:!1,default:0},{name:"contextCharsAfter",type:"number",description:"Number of characters to include after the selection",required:!1,default:0}],a=!1},85130:function(e,t,s){"use strict";s.d(t,{execute:function(){return n}});var i=s(6689);async function n(e,t,s){let{contextCharsBefore:n,contextCharsAfter:r}=t;if((0,i.throwIfAborted)(s),e.s.restore(),e.s.isCollapsed())return{hasSelection:!1};let a=e.s.html,o=e.s.range,l=o.toString(),c={hasSelection:!0,html:a,text:l,startContainer:o.startContainer.nodeName,endContainer:o.endContainer.nodeName};if(n>0||r>0){let t=e.editor.textContent||"",s=t.substring(0,t.indexOf(l)),i=t.substring(t.indexOf(l)+l.length);n>0&&(c.contextBefore=s.slice(-n)),r>0&&(c.contextAfter=i.slice(0,r))}return c}},90991:function(e,t,s){"use strict";var i=s(52826),n=s(85130);t.default={...i,execute:n.execute}},96675:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="replaceBlock",n="Replace a specific block in the document by its index or CSS selector with new HTML content",r=[{name:"index",type:"number",description:"Zero-based index of the block to replace (use either index or selector, not both)",required:!1},{name:"selector",type:"string",description:'CSS selector to find the block to replace (e.g., "h1", ".my-class", "#my-id"). Use either selector or index, not both',required:!1},{name:"html",type:"string",description:"HTML content for the new block",required:!0}],a=!0},3091:function(e,t,s){"use strict";s.d(t,{execute:function(){return o}});var i=s(6689),n=s(49459),r=s(44526),a=s(22732);async function o(e,t,s){let{index:o,selector:l}=t,c=(0,n.requireString)(t,"html");if((0,i.throwIfAborted)(s),void 0===o&&!l||void 0!==o&&l)throw Error("Either index or selector must be provided, but not both");let{element:h,identifier:u}=(0,r.resolveBlock)(e,{selector:l,index:o,requireExactlyOne:!0});try{let t=e.createInside.div();t.innerHTML=c;let s=t.firstChild;if(!s||!a.Dom.isElement(s))throw Error("Invalid HTML: must contain at least one element");return h.parentNode?.replaceChild(s,h),e.synchronizeValues(),{success:!0,message:`Block ${u} replaced successfully`}}catch(e){throw Error(`Failed to replace block ${u}: ${e.message}`)}}},2020:function(e,t,s){"use strict";var i=s(96675),n=s(3091);t.default={...i,execute:n.execute}},62553:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="replaceInDocument",n="Find and replace text or HTML patterns throughout the entire document",r=[{name:"search",type:"string",description:"Text or pattern to search for",required:!0},{name:"replace",type:"string",description:"Replacement text or HTML",required:!0},{name:"useRegex",type:"boolean",description:"If true, treats search as a regular expression",required:!1,default:!1},{name:"useSelector",type:"string",description:"CSS selector to narrow down the search scope to specific elements",required:!1}],a=!0},56293:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"search"),a=(0,n.requireString)(t,"replace",{allowEmpty:!0}),{useRegex:o,useSelector:l}=t;(0,i.throwIfAborted)(s);try{let t;e.s.focus(),e.s.save();let n=0;if(l){let c=function(e,t,s,n,r,a){let o=e.editor.querySelectorAll(r);if(0===o.length)return{replacements:0,message:`No elements found matching selector "${r}"`};let l=0;return o.forEach(e=>{(0,i.throwIfAborted)(a);let r=e.innerHTML,o=r;if(n)try{let e=RegExp(t,"g");r=r.replace(e,()=>(l++,s))}catch(e){throw Error("Invalid regex pattern: "+(e?.message||"Unknown error"))}else{let e=t.length,n=0;for(;-1!==(n=r.indexOf(t,n));)(0,i.throwIfAborted)(a),r=r.substring(0,n)+s+r.substring(n+e),n+=s.length,l++}r!==o&&(e.innerHTML=r)}),l>0&&(e.synchronizeValues(),e.s.restore()),{replacements:l}}(e,r,a,o,l,s);n=c.replacements,t=c.message}else n=function(e,t,s,n,r,a){let o=0,l=t;if(r)try{let e=RegExp(s,"g");l=l.replace(e,()=>(o++,n))}catch(e){throw Error("Invalid regex pattern: "+(e?.message||"Unknown error"))}else{let e=s.length,t=0;for(;-1!==(t=l.indexOf(s,t));)(0,i.throwIfAborted)(a),l=l.substring(0,t)+n+l.substring(t+e),t+=n.length,o++}return o>0&&(e.value=l,e.s.restore(),e.synchronizeValues()),o}(e,e.value,r,a,o,s);return{replacements:n,message:t||(n>0?`Replaced ${n} occurrence(s)`:"No matches found")}}catch(t){throw e.s.restore(),Error("Failed to replace in document: "+(t?.message||"Unknown error"))}}},12570:function(e,t,s){"use strict";var i=s(62553),n=s(56293);t.default={...i,execute:n.execute}},70750:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="replaceSelection",n="Replace the current selection with new HTML content",r=[{name:"html",type:"string",description:"HTML content to insert in place of the selection",required:!0},{name:"collapseToEnd",type:"boolean",description:"Move cursor to the end of the inserted content",required:!1,default:!0}],a=!0},36142:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"html"),{collapseToEnd:a}=t;(0,i.throwIfAborted)(s);try{if(e.s.restore(),e.s.insertHTML(r),a){let t=e.s.range;t.collapse(!1),e.s.selectRange(t)}return e.e.fire("change"),{success:!0,message:"Selection replaced successfully"}}catch(e){throw Error("Failed to replace selection: "+e.message)}}},95323:function(e,t,s){"use strict";var i=s(70750),n=s(36142);t.default={...i,execute:n.execute}},90022:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return r},requiresPermission:function(){return a}});let i="writeDocument",n="Write (replace) the entire document content with new HTML",r=[{name:"html",type:"string",description:"HTML content to set as the document",required:!0}],a=!0},79766:function(e,t,s){"use strict";s.d(t,{execute:function(){return r}});var i=s(6689),n=s(49459);async function r(e,t,s){let r=(0,n.requireString)(t,"html",{allowEmpty:!0});(0,i.throwIfAborted)(s);try{return e.s.focus(),e.value=r,e.synchronizeValues(),{success:!0,message:`Document content was replaced with provided HTML(${r.length} characters)`}}catch(e){throw Error("Failed to replace HTML: "+(e?.message||"Unknown error"))}}},97603:function(e,t,s){"use strict";var i=s(90022),n=s(79766);t.default={...i,execute:n.execute}},80453:function(e,t,s){"use strict";s.d(t,{UIConversationListItem:function(){return c}});var i=s(82749),n=s(31635),r=s(65478),a=s(67510),o=s(62843),l=s(80870);class c extends a.UIElement{className(){return"UIConversationListItem"}render(){return'<div class="jodit-ui-conversation-list__item"></div>'}setActive(e){this.isActive=e,this.updateContent()}updateContent(){let e=this.container;e.innerHTML="",e.setAttribute("data-id",this.conversation.id),this.isActive?e.classList.add("jodit-ui-conversation-list__item_active"):e.classList.remove("jodit-ui-conversation-list__item_active");let t=this.j.c.div("jodit-ui-conversation-list__item-avatar");t.textContent="AI",e.appendChild(t);let s=this.j.c.div("jodit-ui-conversation-list__item-wrapper"),i=this.j.c.div("jodit-ui-conversation-list__item-content"),n=this.j.c.div("jodit-ui-conversation-list__item-title");if(n.textContent=this.conversation.title,this.titleElement=n,i.appendChild(n),this.opts.showTimestamps){let e=this.j.c.div("jodit-ui-conversation-list__item-meta");e.textContent=this.opts.formatTimestamp(this.conversation.updated,this.j.i18n.bind(this.j)),i.appendChild(e)}if(s.appendChild(i),this.conversation.messageCount>0){let e=this.j.c.div("jodit-ui-conversation-list__item-badge");e.textContent=this.conversation.messageCount+"",s.appendChild(e)}e.appendChild(s),this.actionsButton||(this.actionsButton=new o.UIButton(this.j,{icon:{name:"dots"},tooltip:"Actions",name:"conversationActions",size:"tiny"}),this.actionsButton.container.classList.add("jodit-ui-conversation-list__item-actions"),this.actionsButton.onAction(e=>{e.stopPropagation(),this.showActionsMenu(e)})),e.appendChild(this.actionsButton.container)}onClick(){this.isRenaming||this.j.e.fire("selectConversation.ai-assistant-pro",this.conversation.id)}showActionsMenu(e){if(!this.contextMenu||!this.actionsButton)return;let t=this.actionsButton.container.getBoundingClientRect();this.contextMenu.show(t.left,t.bottom,[{title:"Rename",icon:"pencil",exec:()=>{this.startInlineRename()}},{title:"Delete",icon:"bin",exec:()=>{this.onDelete()}}]),e.stopPropagation()}startInlineRename(){if(this.isRenaming||!this.titleElement)return;this.isRenaming=!0;let e=this.titleElement,t=this.conversation.title,s=this.j.c.element("input");s.type="text",s.value=t,s.className="jodit-ui-conversation-list__item-title-input",e.textContent="",e.appendChild(s),s.focus(),s.select();let i=()=>{if(!this.isRenaming)return;let i=s.value.trim();this.isRenaming=!1,i&&i!==t?(e.textContent=i,this.j.e.fire("renameConversation.ai-assistant-pro",this.conversation.id,i)):e.textContent=t};this.j.e.on(s,"blur",i),this.j.e.on(s,"keydown",i=>{"Enter"===i.key&&(i.preventDefault(),s.blur()),"Escape"===i.key&&(this.isRenaming=!1,e.textContent=t)}),this.j.e.on(s,"click",e=>{e.stopPropagation()})}onDelete(){this.j.e.fire("deleteConversation.ai-assistant-pro",this.conversation.id)}destruct(){this.actionsButton?.destruct(),this.contextMenu?.destruct(),super.destruct()}constructor(e,t,s=!1,n){super(e),(0,i._)(this,"opts",void 0),(0,i._)(this,"conversation",void 0),(0,i._)(this,"isActive",void 0),(0,i._)(this,"actionsButton",void 0),(0,i._)(this,"contextMenu",void 0),(0,i._)(this,"titleElement",void 0),(0,i._)(this,"isRenaming",void 0),this.opts=n,this.actionsButton=null,this.contextMenu=null,this.titleElement=null,this.isRenaming=!1,this.conversation=t,this.isActive=s,this.contextMenu=new l.ContextMenu(this.j),this.updateContent()}}(0,n.__decorate)([(0,r.watch)("container:click")],c.prototype,"onClick",null),(0,n.__decorate)([r.autobind],c.prototype,"showActionsMenu",null),(0,n.__decorate)([r.autobind],c.prototype,"startInlineRename",null),(0,n.__decorate)([r.autobind],c.prototype,"onDelete",null),c=(0,n.__decorate)([r.component],c)},68365:function(e,t,s){"use strict";s.d(t,{UIConversationList:function(){return h}});var i=s(82749),n=s(31635),r=s(31356),a=s(80453),o=s(65478),l=s(80256),c=s(62405);class h extends c.UIGroup{className(){return"UIConversationList"}render(){return`<div class="&__container">
10
+ ${a}`.trim();s?await this.__executeQuickCommandSilent(l,a):await this.__executeQuickCommandWithPanel(l,i)}async __executeQuickCommandSilent(e,t){await this.__loadData(),this.j.progressbar.show().progress(100);try{let t=(0,u.createUserMessage)(e),s=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature,[t]),i=await this.apiClient.sendRequest(s.id,s.messages,null,[],s.options);if("final"===i.mode){let e=i.response.content;e&&this.j.s.insertHTML(e)}}catch(e){(0,f.isAbortError)(e)||this.j.e.fire("error",e)}finally{this.j.progressbar.hide()}}async __executeQuickCommandWithPanel(e,t){await this.__loadData();let s=this.stateManager.state.displayMode;this.stateManager.state.displayMode=t;let i=(0,u.getCurrentSelectionContext)(this.j);i&&this.stateManager.addSelectionContext(i),this.stateManager.isOpen()||await this.openAssistant(),await this.sendMessage(e),this.stateManager.state.displayMode=s}async sendMessage(e){await this.__loadData();let t=this.stateManager.getCurrentConversation(),s=this.stateManager.getEditingMessageId();if(s&&t){let e=t.messages.findIndex(e=>e.id===s);if(-1!==e){let s=t.messages.slice(0,e),i={...t,messages:s,updatedAt:Date.now()};this.stateManager.setCurrentConversation(i),await this.storage.save(i),this.stateManager.clearEditingMessage(),t=i}}t||(t=(0,u.createNewConversation)(this.j,this.state.defaultModel,this.state.defaultTemperature),this.stateManager.setCurrentConversation(t));let i=null;e.trim()&&(i=(0,u.createUserMessage)(e),t.title||(t={...t,title:e}),t={...t,updated:Date.now(),messages:[...t.messages,i]}),this.stateManager.setCurrentConversation({...t}),i&&this.j.e.fire("messageSent.ai-assistant-pro",i),this.stateManager.setLoading(!0),this.stateManager.clearError();try{await this.sendRequestToAI(0),this.stateManager.clearSelectionContexts()}catch(e){if((0,f.isAbortError)(e))return;this.stateManager.setError(e instanceof Error?e.message:e+"")}finally{this.stateManager.setLoading(!1)}}async sendRequestToAI(e=0){let t,s,i=this.j.o.aiAssistantPro.maxRecursionToolCallDepth;if(e>=i)throw Error(`Max recursion depth ${i} reached for tool calls`);let n=this.stateManager.getCurrentConversation();if(!n)return;let a=(0,u.findParentMessageId)(n),[r]=await Promise.all([this.apiClient.sendRequest(n.id,n.messages,a,this.stateManager.getSelectionContexts(),n.options),this.storage.save(n)]);if("stream"===r.mode){let e=await (0,u.processStreamingResponse)(this.stateManager,r,n);t=e.aiMessage,s=e.index,n=e.conversation}else{let e=(0,u.processFinalResponse)(r,n);t=e.aiMessage,s=e.index,n=e.conversation}n=await (0,u.processArtifacts)(this.j,t,n,s),this.j.e.fire("messageReceived.ai-assistant-pro",t),this.stateManager.setCurrentConversation({...n}),await this.storage.save(n),await this.handleToolCalls(t.id,e)}async deleteConversation(e){await this.__loadData(),await (0,u.deleteConversationWithCleanup)(this.j,e,this.storage,this.stateManager,this.permissionManager)}async renameConversation(e,t){let s=await this.storage.get(e);if(!s)return;let i={...s,title:t,updated:Date.now()};await this.storage.save(i),this.state.currentConversation?.id===e&&this.stateManager.setCurrentConversation(i);let n=await this.storage.list();this.stateManager.setConversations(n)}async searchConversations(e){await this.__loadData(),await (0,u.handleConversationSearch)(e,this.storage,this.stateManager)}async handleToolCalls(e,t=0){let s=this.stateManager.getCurrentConversation();if(!s)return;let i=s.messages.find(t=>t.id===e);if(!i)return;let n=i.toolCalls;if(!n||0===n.length)return;let a=n.filter(e=>!(0,u.isTerminalToolCallStatus)(e.status));if(0===a.length)return;let{approved:r,needsPermission:o}=this.permissionManager.filterToolCalls(a,s.permissions);for(let s of(this.stateManager.setPendingToolCalls(o),r))await this.executeToolCall(e,s,t)}async executeToolCall(e,t,s=0){let i=this.stateManager.getCurrentConversation();if(!i)return;let n=await (0,u.executeToolCall)(this.j,t,this.toolRegistry),a=i.messages.findIndex(t=>t.id===e);if(-1===a)return;let r=i.messages[a],o=i.messages.slice();o[a]=(0,u.updateToolCallInMessage)(r,n),i={...i,messages:o,updated:Date.now()},this.stateManager.setCurrentConversation(i),(0,u.areAllToolCallsExecuted)(i)&&await this.sendRequestToAI(s+1)}async copyMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.find(t=>t.id===e);if(s)try{await navigator.clipboard.writeText(s.content),this.j.message.success("Message copied to clipboard")}catch(e){this.j.e.fire("error",Error("Failed to copy message"))}}async restartFromMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.findIndex(t=>t.id===e);if(-1===s)return;let i=t.messages[s];if("user"!==i.role)return;await this.__loadData();let n=t.messages.slice(0,s),a={...t,messages:n,updatedAt:Date.now()};this.stateManager.setCurrentConversation(a),await this.storage.save(a),await this.sendMessage(i.content)}async editMessage(e){let t=this.stateManager.getCurrentConversation();if(!t)return;let s=t.messages.find(t=>t.id===e);s&&"user"===s.role&&(this.stateManager.setEditingMessageId(e),this.mainPanel.inputArea.setValue(s.content),this.mainPanel.inputArea.focus())}cancelEditMessage(){this.stateManager.isEditingMessage()&&(this.stateManager.clearEditingMessage(),this.mainPanel.inputArea.setValue(""))}async deleteMessage(e){await this.__loadData();let t=this.stateManager.getCurrentConversation();if(!t||-1===t.messages.findIndex(t=>t.id===e))return;let s=t.messages.filter(t=>t.id!==e),i={...t,messages:s,updatedAt:Date.now()};this.stateManager.setCurrentConversation(i),await this.storage.save(i)}beforeDestruct(){this.textAutocompleteSource&&(this.j.e.fire("unregisterAutocompleteSource",this.textAutocompleteSource),this.textAutocompleteSource=null),this.textAutocompleteCache.clear(),this.__closeFlightMode(),(0,g.cached)(this,"toolRegistry")?.destruct(),(0,g.cached)(this,"permissionManager")?.destruct(),(0,g.cached)(this,"apiClient")?.destruct(),(0,g.cached)(this,"stateManager")?.destruct(),(0,g.cached)(this,"mainPanel")?.destruct(),(0,g.cached)(this,"dialog")?.destruct(),(0,g.cached)(this,"storage")?.close?.()}constructor(...e){super(...e),(0,i._)(this,"buttons",[{name:"aiAssistantPro",group:"insert"},{name:"aiCommandsPro",group:"insert"}]),(0,i._)(this,"textAutocompleteSource",null),(0,i._)(this,"textAutocompleteCache",new Map),(0,i._)(this,"__initedPromise",null),(0,i._)(this,"__openedMode",null)}}(0,i._)(y,"requires",["license","autocomplete"]),(0,n.__decorate)([g.cache],y.prototype,"toolRegistry",null),(0,n.__decorate)([g.cache],y.prototype,"permissionManager",null),(0,n.__decorate)([g.cache],y.prototype,"apiClient",null),(0,n.__decorate)([g.cache],y.prototype,"storage",null),(0,n.__decorate)([g.cache],y.prototype,"stateManager",null),(0,n.__decorate)([g.cache],y.prototype,"mainPanel",null),(0,n.__decorate)([g.cache],y.prototype,"dialog",null),(0,n.__decorate)([(0,g.watch)("state.theme")],y.prototype,"__applyTheme",null),(0,n.__decorate)([(0,g.watch)(":openAIAssistantPro.ai-assistant-pro")],y.prototype,"openAssistant",null),(0,n.__decorate)([(0,g.watch)([":resize","state.panelWidth","state.panelHeight"])],y.prototype,"__onResizeInPanelView",null),(0,n.__decorate)([(0,g.watch)(["state.isOpen","state.displayMode","state.panelWidth","state.panelHeight","state.theme","state.defaultModel","state.defaultTemperature","state.currentConversation"]),(0,g.debounce)()],y.prototype,"__onSavedStateChange",null),(0,n.__decorate)([(0,g.watch)(":closeAIAssistantPro.ai-assistant-pro")],y.prototype,"closeAssistant",null),(0,n.__decorate)([(0,g.watch)(":addContextToAIAssistant.ai-assistant-pro")],y.prototype,"addCurrentSelectionToContext",null),(0,n.__decorate)([(0,g.watch)(":executeQuickCommand.ai-assistant-pro")],y.prototype,"executeQuickCommand",null),(0,n.__decorate)([(0,g.watch)(":sendMessage.ai-assistant-pro")],y.prototype,"sendMessage",null),(0,n.__decorate)([(0,g.watch)(":searchConversations.ai-assistant-pro")],y.prototype,"searchConversations",null),(0,n.__decorate)([(0,g.watch)(":copyMessage.ai-assistant-pro")],y.prototype,"copyMessage",null),(0,n.__decorate)([(0,g.watch)(":restartFromMessage.ai-assistant-pro")],y.prototype,"restartFromMessage",null),(0,n.__decorate)([(0,g.watch)(":editMessage.ai-assistant-pro")],y.prototype,"editMessage",null),(0,n.__decorate)([(0,g.watch)(":cancelEditMessage.ai-assistant-pro")],y.prototype,"cancelEditMessage",null),(0,n.__decorate)([(0,g.watch)(":deleteMessage.ai-assistant-pro")],y.prototype,"deleteMessage",null),y=(0,n.__decorate)([g.component],y),C.JoditPro.plugins.add("aiAssistantPro",y)},66645:function(e,t,s){"use strict";var i=s(47373),n=s(94668),a=s.n(n),r=s(86428),o=s.n(r),l=s(75966),c=s.n(l),h=s(83207),u=s.n(h),d=s(99219),p=s.n(d),g=s(63674),m=s.n(g),f=s(4133),v=s.n(f),C=s(94454),w=s(53835),x=s(6441),y=s(12153),k=s(31974),b=s(72573);y.Icon.set("ai-assistant-pro",o()).set("ai-commands-pro",c()).set("ai-add-context",a()).set("send",p()).set("tool-bolt",v()).set("chevron-right",u()).set("shield",m()),x.Config.prototype.aiAssistantPro={displayMode:"right",panelWidth:400,panelHeight:500,flightPanelHeight:250,dialogFullSize:!1,resizable:!0,apiMode:"incremental",apiRequest:null,maxRetries:3,requestTimeout:3e5,retryDelay:1e3,maxRecursionToolCallDepth:1e3,enabledTools:(0,w.getToolNames)(),customTools:[],toolPermissions:{},autoApproveTools:["readDocument","readBlocks","readSelection","insertHTML"],alwaysDenyTools:[],defaultPermissionScope:"conversation",storage:"indexedDB",maxConversations:50,storageKey:"jodit-ai-assistant-pro",showConversationList:!0,enableMarkdown:!0,enableCodeHighlight:!0,maxMessageHeight:400,placeholderText:"Ask AI assistant...",sendShortcut:"Ctrl+Enter",showTimestamps:!0,formatTimestamp(e,t){let s=new Date(e),i=new Date().getTime()-s.getTime();return i<6e4?t("Just now"):i<36e5?t("%dm ago",Math.floor(i/6e4)):i<864e5?t("%dh ago",Math.floor(i/36e5)):s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},formatMessageContent:(e,t)=>b.marked.parse(e,{breaks:!0,gfm:!0}),showAvatars:!0,showTypingIndicator:!0,includeSelectionByDefault:!0,maxContextRanges:5,showContextPreview:!0,sendOnEnter:!0,instructions:void 0,includeEditorMetadata:!1,autoOpen:!0,rememberLastConversation:!0,autoFocusInput:!0,closeAfterInsert:!1,enableSoundNotifications:!1,debug:!1,textAutocompleteEnabled:!1,textAutocompleteApiRequest:null,textAutocompleteMinQueryLength:3,textAutocompleteMaxSuggestions:3,textAutocompleteDebounceMs:500,textAutocompleteCacheTTL:3e4,textAutocompleteCacheMaxSize:50,quickCommandsSilentMode:!1,quickCommandsDisplayMode:"flight",showCopyMessageAction:!0,showRestartMessageAction:!0,showEditMessageAction:!0,showDeleteMessageAction:!0,dialogSettings:{},allowEditDialogSettings:!1,allowEditDisplayMode:!0,allowEditPanelWidth:!0,initiallyOpened:!1,allowClose:!0,persistOpenState:!0,theme:"parent",allowEditTheme:!0,async uploadBase64Artifact(e,t){if("image"===e.type&&e.data&&"base64"===e.data.kind)try{let s=(0,i.base64ToFile)(e.data.base64,e.id,e.mimeType),n=await t.uploader.upload([s]);return{...e,data:{kind:"url",url:n.baseurl+n.files[0]},metadata:{...e.metadata,filename:n.files[0]}}}catch(e){t.e.fire("error",e)}return e},getAIProviderOptions:(e,t)=>(0,C.getAIProviderOptions)(e,t),registerAIProvider(e,t){(0,C.registerAIProvider)(e,t)}},x.Config.prototype.controls.aiAssistantPro={icon:"ai-assistant-pro",tooltip:"AI Assistant",hotkeys:["ctrl+shift+a","cmd+shift+a"],exec(e){e.e.fire("openAIAssistantPro.ai-assistant-pro")},isDisabled:e=>!e.o.aiAssistantPro.apiRequest,getLabel:e=>e.o.aiAssistantPro.apiRequest?"AI Assistant":"AI Assistant (not configured)"},x.Config.prototype.controls.aiAddContext={icon:"ai-add-context",tooltip:"Add to AI Context",exec(e){e.e.fire("addContextToAIAssistant")},isDisabled:e=>!e.o.aiAssistantPro.apiRequest||e.s.isCollapsed()},x.Config.prototype.controls.aiCommandsPro={icon:"ai-commands-pro",tooltip:"AI Commands",isDisabled:e=>!e.o.aiAssistantPro.apiRequest,list:k.aiAssitentCommands,exec(e,t,{control:s}){e.e.fire("executeQuickCommand.ai-assistant-pro",s.name)}};let _=x.Config.prototype.tuneBlock?.popup||{},S={};["p","h1","h2","h3","h4","h5","h6","div","section","article","pre","blockquote","ul","ol","li","table","tr","td","th","img","figure"].forEach(e=>{let t=_[e]||["tune.up","tune.remove","tune.down"];S[e]=[...t,"|","aiAddContext"]}),x.Config.prototype.tuneBlock&&(x.Config.prototype.tuneBlock.popup={..._,...S})},6689:function(e,t,s){"use strict";s.d(t,{throwIfAborted:function(){return n}});var i=s(93661);function n(e){if(e.aborted)throw(0,i.abort)()}},61872:function(e,t,s){"use strict";s.d(t,{processArtifacts:function(){return r},processFinalResponse:function(){return a},processStreamingResponse:function(){return n}});var i=s(61558);async function n(e,t,s){let n=(0,i.createAIMessage)(),a=-1;for await(let r of t.stream){switch(r.type){case"created":n={...n,id:r.response.responseId,content:""},a=s.messages.length;break;case"text-delta":n={...n,content:n.content+r.delta};break;case"completed":n={...n,id:r.response.responseId,toolCalls:r.response.toolCalls||[],artifacts:r.response.artifacts||[]};break;case"error":{let e=(0,i.createErrorMessage)(r.error);n={...n,id:e.id,content:e.content}}}if(n.id){let t=s.messages.slice();t[a>=0?a:s.messages.length]=n,s={...s,messages:t,updated:Date.now()},e.setCurrentConversation(s)}}return{aiMessage:n,index:a,conversation:s}}function a(e,t){let s={...(0,i.createAIMessage)(),id:e.response.responseId,content:e.response.content,toolCalls:e.response.toolCalls||[],artifacts:e.response.artifacts||[]},n=t.messages.slice();return n.push(s),{aiMessage:s,index:(t={...t,messages:n,updated:Date.now()}).messages.length-1,conversation:t}}async function r(e,t,s,n){if(t.artifacts&&t.artifacts.length>0){let a=s.messages.slice();return a[n]={...a[n],artifacts:await (0,i.uploadArtifacts)(e,t.artifacts)},{...s,messages:a,updated:Date.now()}}return s}},49459:function(e,t,s){"use strict";function i(e,t,s={}){let n=e[t];if("string"!=typeof n||!s.allowEmpty&&""===n)throw Error(`Parameter "${t}" is required and must be a${s.allowEmpty?"":" non-empty"} string`);return n}s.d(t,{requireString:function(){return i}})},44526:function(e,t,s){"use strict";s.d(t,{resolveBlock:function(){return n}});var i=s(22732);function n(e,{selector:t,index:s,requireExactlyOne:a=!1}={}){let r=null!=t&&""!==t.trim(),o=null!=s;if(a&&r===o)throw Error("Either index or selector must be provided, but not both");if(!r&&!o)throw Error("Block identifier is required");if(r){if("string"!=typeof t)throw Error("Selector must be a string");let s=e.editor.querySelector(t);if(!s)throw Error(`No element found matching selector "${t}"`);if(!i.Dom.isElement(s))throw Error(`Selector "${t}" does not point to an element node`);return{element:s,identifier:`with selector "${t}"`}}if("number"!=typeof s)throw Error("Block index must be a number");let l=Array.from(e.editor.children);if(s<0||s>=l.length)throw Error(`Block index ${s} is out of range. Document has ${l.length} blocks`);let c=l[s];if(!i.Dom.isElement(c))throw Error(`Block at index ${s} is not a valid element`);return{element:c,identifier:"at index "+s}}},70308:function(e,t,s){"use strict";s.d(t,{areAllToolCallsExecuted:function(){return l},createNewConversation:function(){return n},findMessagesWithPendingToolCalls:function(){return c},findParentMessageId:function(){return a},isTerminalToolCallStatus:function(){return o}});var i=s(21064);function n(e,t,s,a=[]){let r=e.o.aiAssistantPro,o={id:(0,i.generateConversationId)(),created:Date.now(),updated:Date.now(),messages:a,permissions:[],options:{model:t??r.defaultModel,temperature:s??r.defaultTemperature}};return e.e.fire("conversationCreated.ai-assistant-pro",o),o}function a(e){for(let t=e.messages.length-1;t>=0;t--){let s=e.messages[t];if("assistant"===s.role&&!s.id.startsWith("error_"))return s.id}return null}let r=new Set(["executed","denied","error"]);function o(e){return r.has(e)}function l(e){let t=e.messages[e.messages.length-1];return!!t?.toolCalls&&t.toolCalls.every(e=>o(e.status))}function c(e){return e.messages.filter(e=>e.toolCalls&&e.toolCalls.length>0&&e.toolCalls.some(e=>!o(e.status)))}},473:function(e,t,s){"use strict";s.d(t,{handleBackToList:function(){return l},handleConversationSearch:function(){return c},handleConversationSelect:function(){return o},handleToolApproval:function(){return a},handleToolDenial:function(){return r}});var i=s(79078),n=s(82758);async function a(e,t,s,i,n){let a=s.getPendingToolCalls().find(t=>t.id===e);if(!a)return null;let r=i.grantPermission(a.name,t),o=s.getCurrentConversation();return o&&(o.permissions.push(r),await n.save(o)),s.removePendingToolCall(e),{...a,status:"approved"}}async function r(e,t,s,n){let a=s.getPendingToolCalls().find(e=>e.id===t);if(!a)return;let r=s.getCurrentConversation();if(!r)return;let o=r.messages.findIndex(e=>e.toolCalls?.find(e=>e.id===t));if(-1===o)return;let l=r.messages[o],c={...a,result:{error:"Tool call denied by user."},status:"denied"},h=(0,i.updateToolCallInMessage)(l,c),u=[...r.messages];u[o]=h,r={...r,messages:u,updated:Date.now()},s.setCurrentConversation(r),await n.save(r),e.e.fire("toolCallDenied.ai-assistant-pro",a),s.removePendingToolCall(t)}async function o(e,t,s){try{s.setLoading(!0);let i=await t.get(e);if(!i)throw Error("Conversation not found: "+e);s.setCurrentConversation({...i})}catch(e){n.IS_PROD}finally{s.setLoading(!1)}}async function l(e,t){t.setView("conversationList");try{t.setLoading(!0);let s=await e.list().catch(()=>[]);t.setConversations(s)}finally{t.setLoading(!1)}}async function c(e,t,s){s.setLoading(!0);try{let i=await t.list(e||void 0);s.setConversations(i),s.setView("conversationList")}finally{s.setLoading(!1)}}},58579:function(e,t,s){"use strict";s.d(t,{applyTheme:function(){return h.applyTheme},areAllToolCallsExecuted:function(){return n.areAllToolCallsExecuted},createNewConversation:function(){return n.createNewConversation},createUserMessage:function(){return r.createUserMessage},deleteConversationWithCleanup:function(){return c.deleteConversationWithCleanup},executeToolCall:function(){return u.executeToolCall},findMessagesWithPendingToolCalls:function(){return n.findMessagesWithPendingToolCalls},findParentMessageId:function(){return n.findParentMessageId},getCurrentSelectionContext:function(){return l.getCurrentSelectionContext},handleBackToList:function(){return a.handleBackToList},handleConversationSearch:function(){return a.handleConversationSearch},handleConversationSelect:function(){return a.handleConversationSelect},handleToolApproval:function(){return a.handleToolApproval},handleToolDenial:function(){return a.handleToolDenial},invertMode:function(){return o.invertMode},isTerminalToolCallStatus:function(){return n.isTerminalToolCallStatus},loadInitialData:function(){return c.loadInitialData},processArtifacts:function(){return i.processArtifacts},processFinalResponse:function(){return i.processFinalResponse},processStreamingResponse:function(){return i.processStreamingResponse},resizeInPanelView:function(){return o.resizeInPanelView},updateToolCallInMessage:function(){return u.updateToolCallInMessage}});var i=s(61872),n=s(70308),a=s(473),r=s(61558),o=s(71050),l=s(15927),c=s(56110),h=s(53014),u=s(79078)},61558:function(e,t,s){"use strict";s.d(t,{createAIMessage:function(){return a},createErrorMessage:function(){return r},createUserMessage:function(){return n},uploadArtifacts:function(){return o}});var i=s(21064);function n(e){return{id:(0,i.generateMessageId)(),role:"user",content:e,timestamp:Date.now()}}function a(){return{id:"",role:"assistant",content:"",artifacts:[],timestamp:Date.now(),toolCalls:[]}}function r(e){return{id:"error_"+(0,i.generateMessageId)(),role:"assistant",content:"❌ Error: "+e.message,timestamp:Date.now(),toolCalls:[],artifacts:[]}}async function o(e,t){if(!t||0===t.length)return t;let s=e.o.aiAssistantPro.uploadBase64Artifact;return s?Promise.all(t.map(async t=>s(t,e)??t)):t}},71050:function(e,t,s){"use strict";s.d(t,{invertMode:function(){return n},resizeInPanelView:function(){return a}});var i=s(41180);function n(e){switch(e){case"left":return"right";case"right":return"left";case"top":return"bottom";case"bottom":return"top"}}function a(e,t,s,a){if("dialog"===t||"flight"===t)return;("left"===t||"right"===t)&&(e.currentPlace.slots[n(t)]?.style.setProperty(`--jd-slot-${n(t)}-width`,"auto"),e.currentPlace.slots[t]?.style.setProperty(`--jd-slot-${t}-width`,`${s}px`));let r=(0,i.css)(e.currentPlace.workplace,"height")??0;e.currentPlace.slots[t]?.style.setProperty("min-height",`${Math.min(r,a)}px`)}},15927:function(e,t,s){"use strict";function i(e){if(e.s.isCollapsed())return null;let t=e.s.html,s=e.s.range;return{html:t,rangeInfo:{startContainer:s.startContainer.nodeName,startOffset:s.startOffset,endContainer:s.endContainer.nodeName,endOffset:s.endOffset}}}s.d(t,{getCurrentSelectionContext:function(){return i}})},56110:function(e,t,s){"use strict";s.d(t,{deleteConversationWithCleanup:function(){return n},loadInitialData:function(){return a}});var i=s(82758);async function n(e,t,s,i,n){try{i.setLoading(!0),await s.delete(t),i.removeConversation(t),n.clearConversationPermissions(t);let a=i.getCurrentConversation();a?.id===t&&i.setCurrentConversation(null);let r=await s.list();i.setConversations(r),i.setView(0===r.length?"welcome":"conversationList"),e.e.fire("conversationDeleted.ai-assistant-pro",t)}catch(t){e.alert(e.i18n("Failed to delete conversation")+": "+(t?.message||"Unknown error"))}finally{i.setLoading(!1)}}async function a(e,t,s){s.setLoading(!0);try{let[i,n]=await Promise.all([t.list().catch(()=>[]),t.getGlobalSettings().catch(()=>null)]);if(s.setConversations(i),n&&s.setSavedState(n),0===i.length)s.setView("welcome");else if(e.o.aiAssistantPro.rememberLastConversation&&n?.currentConversationId){let e=i.find(e=>e.id===n.currentConversationId)??i[0],a=await t.get(e.id);a?s.setCurrentConversation(a):s.setView("conversationList")}else s.setView("conversationList")}catch(e){i.IS_PROD,s.setView("welcome")}finally{s.setLoading(!1)}}},53014:function(e,t,s){"use strict";s.d(t,{applyTheme:function(){return a}});let i=["jodit_theme_dark","jodit-ai-assistant-pro_theme_dark","jodit-dialog_theme_dark"],n=["jodit_theme_light","jodit-ai-assistant-pro_theme_light","jodit-dialog_theme_light"];function a(e,t,s,a,r){let o;if(a?.classList.remove(...i),a?.classList.remove(...n),"dialog"===s){let e=r?.container;e?.classList.remove(...i),e?.classList.remove(...n)}if(o="dark"===t?i:n,a?.classList.add(...o),"dialog"===s){let e=r?.container;e?.classList.add(...o)}}},79078:function(e,t,s){"use strict";async function i(e,t,s){let i;try{let e=new AbortController().signal,n=await s.executeTool(t.name,t.arguments,e);i={...t,result:{result:n},status:"executed"}}catch(s){i={...t,result:{error:s instanceof Error?s.message:s+""},status:"error"},e.e.fire("toolCallFailed.ai-assistant-pro",i)}return e.e.fire("toolCallExecuted.ai-assistant-pro",i,{toolCallId:i.id,result:i.result}),i}function n(e,t){let s=e.toolCalls?.findIndex(e=>e.id===t.id);if(null==s||-1===s)return e;let i=[...e?.toolCalls??[]];return i[s]=t,{...e,toolCalls:i}}s.d(t,{executeToolCall:function(){return i},updateToolCallInMessage:function(){return n}})},86449:function(e,t,s){"use strict";s.d(t,{APIClient:function(){return r}});var i=s(82749),n=s(82758),a=s(21537);class r{async sendRequest(e,t,s,i,r){let{apiRequest:o,requestTimeout:l,maxRetries:c}=this.jodit.o.aiAssistantPro;if(!o)throw Error("AI Assistant Pro callback is not configured");let h=new AbortController;this.abortControllers.add(h);try{let u=this.buildRequestContext(e,t,s,i,r),d=null;for(let e=0;c>=e;e++)try{if(h.signal.aborted)throw(0,a.abort)();let e=setTimeout(()=>{h.abort()},l);try{let t=await o(u,h.signal);return clearTimeout(e),this.validateResponse(t),t}catch(t){throw clearTimeout(e),t}}catch(t){if(d=t,n.IS_PROD,c>e){let t=this.calculateRetryDelay(e);await this.sleep(t)}else throw t}throw d||Error("API request failed after all retries")}finally{this.abortControllers.delete(h)}}abort(){this.abortControllers.forEach(e=>{e.abort()}),this.abortControllers.clear()}isInProgress(){return this.abortControllers.size>0}buildRequestContext(e,t,s,i,n){let a,{apiMode:r,instructions:o}=this.jodit.o.aiAssistantPro,l={mode:r,conversationId:e,tools:this.toolRegistry.getAllTools(),selectionContexts:i,conversationOptions:n,instructions:o};if("full"===r)a=t;else if(s){let e=t.findIndex(e=>e.id===s);a=-1!==e?t.slice(e+1):t,l={...l,parentMessageId:s}}else a=t;return{...l,messages:this.expandToolMessages(a,t.find(e=>e.id===s))}}expandToolMessages(e,t){let s=[];for(let t of e)s.push(t),this.expandToolResultsMessage(t,s);return t&&this.expandToolResultsMessage(t,s),s}expandToolResultsMessage(e,t){if(e.toolCalls&&e.toolCalls.length>0)for(let s of e.toolCalls){let i=s.result??{error:"result not found"};if(t.find(e=>e.id===`${s.id}-result`))continue;let n={id:`${s.id}-result`,role:"tool",content:i.error?"Error: "+i.error:JSON.stringify(i.result),timestamp:e.timestamp,toolResults:[{toolCallId:s.id,result:i}]};t.push(n)}}validateResponse(e){if("final"!==e.mode)return;let t=e.response;if(!t)throw Error("API returned empty response");if(!t.responseId)throw Error("API response missing responseId");if(void 0===t.content)throw Error("API response missing content");if(void 0===t.finished)throw Error("API response missing finished flag");if(t.toolCalls){if(!Array.isArray(t.toolCalls))throw Error("API response toolCalls must be an array");t.toolCalls.forEach((e,t)=>{if(!e.id)throw Error(`Tool call at index ${t} is missing id`);if(!e.name)throw Error(`Tool call at index ${t} is missing name`);if(!e.arguments||"object"!=typeof e.arguments)throw Error(`Tool call at index ${t} has invalid arguments`)})}}calculateRetryDelay(e){let{retryDelay:t}=this.jodit.o.aiAssistantPro;return t*Math.pow(2,e)+Math.random()*t}sleep(e){return new Promise(t=>setTimeout(t,e))}destruct(){this.abort()}constructor(e,t){(0,i._)(this,"jodit",void 0),(0,i._)(this,"toolRegistry",void 0),(0,i._)(this,"abortControllers",void 0),this.jodit=e,this.toolRegistry=t,this.abortControllers=new Set}}},47373:function(e,t,s){"use strict";function i(e,t,s="image/png"){let n=atob(e),a=n.length,r=new Uint8Array(a);for(let e=0;a>e;e++)r[e]=n.charCodeAt(e);return new File([new Blob([r],{type:s})],t,{type:s})}s.d(t,{base64ToFile:function(){return i}})},21020:function(e,t,s){"use strict";s.d(t,{PermissionManager:function(){return n}});var i=s(82749);class n{requiresPermission(e){let{autoApproveTools:t,alwaysDenyTools:s}=this.jodit.o.aiAssistantPro;if(s.includes(e))return!0;if(t.includes(e))return!1;let i=this.toolRegistry.getTool(e);return!i||i.requiresPermission}isAutoDenied(e){let{alwaysDenyTools:t}=this.jodit.o.aiAssistantPro;return t.includes(e)}isAutoApproved(e){let{autoApproveTools:t}=this.jodit.o.aiAssistantPro;return t.includes(e)}checkPermission(e,t){if(this.isAutoApproved(e))return{toolName:e,granted:!0,grantedAt:Date.now(),scope:"once"};if(this.isAutoDenied(e))return null;let s=this.permanentPermissions.get(e);return s&&s.granted?s:t.find(t=>t.toolName===e&&t.granted)||null}grantPermission(e,t){let s={toolName:e,granted:!0,grantedAt:Date.now(),scope:t};return"forever"===t&&(this.permanentPermissions.set(e,s),this.savePermanentPermissions()),s}denyPermission(e){return{toolName:e,granted:!1,grantedAt:Date.now(),scope:"once"}}filterToolCalls(e,t){let s=[],i=[],n=[];for(let a of e){if(this.isAutoDenied(a.name)){n.push({...a,status:"denied"});continue}if(this.isAutoApproved(a.name)){s.push({...a,status:"approved"});continue}let e=this.checkPermission(a.name,t);e&&e.granted?s.push({...a,status:"approved"}):this.requiresPermission(a.name)?(this.jodit.e.fire("permissionRequested.ai-assistant-pro",a.name),i.push({...a,status:"pending"})):s.push({...a,status:"approved"})}return{approved:s,needsPermission:i,denied:n}}clearConversationPermissions(e){}loadPermanentPermissions(){try{let e=localStorage.getItem(this.PERMANENT_PERMISSIONS_KEY);e&&JSON.parse(e).forEach(e=>{"forever"===e.scope&&e.granted&&this.permanentPermissions.set(e.toolName,e)})}catch(e){}}savePermanentPermissions(){try{let e=Array.from(this.permanentPermissions.values());localStorage.setItem(this.PERMANENT_PERMISSIONS_KEY,JSON.stringify(e))}catch(e){}}clearPermanentPermissions(){this.permanentPermissions.clear(),localStorage.removeItem(this.PERMANENT_PERMISSIONS_KEY)}getPermanentPermissions(){return Array.from(this.permanentPermissions.values())}revokePermanentPermission(e){this.permanentPermissions.delete(e),this.savePermanentPermissions()}destruct(){this.permanentPermissions.clear()}constructor(e,t){(0,i._)(this,"jodit",void 0),(0,i._)(this,"toolRegistry",void 0),(0,i._)(this,"permanentPermissions",void 0),(0,i._)(this,"PERMANENT_PERMISSIONS_KEY",void 0),this.jodit=e,this.toolRegistry=t,this.permanentPermissions=new Map,this.PERMANENT_PERMISSIONS_KEY="jodit-permissions.ai-assistant-pro",this.loadPermanentPermissions()}}},46166:function(e,t,s){"use strict";s.d(t,{StateManager:function(){return n}});var i=s(82749);class n{createInitialState(){return{isOpen:!1,currentView:"welcome",currentConversation:null,conversations:[],isLoading:!1,error:null,pendingToolCalls:[],selectionContexts:[],abortController:null,editingMessageId:null,theme:this.jodit.o.aiAssistantPro.theme||"parent",displayMode:this.jodit.o.aiAssistantPro.displayMode,panelWidth:this.jodit.o.aiAssistantPro.panelWidth,panelHeight:this.jodit.o.aiAssistantPro.panelHeight,defaultModel:this.jodit.o.aiAssistantPro.defaultModel,defaultTemperature:this.jodit.o.aiAssistantPro.defaultTemperature}}open(){this.state.isOpen=!0,this.jodit.e.fire("open.ai-assistant-pro",this.state.currentConversation)}close(){this.state.isOpen=!1,this.jodit.e.fire("close.ai-assistant-pro")}isOpen(){return this.state.isOpen}setView(e){this.state.currentView=e,this.jodit.e.fire("viewChanged.ai-assistant-pro",e)}getView(){return this.state.currentView}setConversations(e){this.state.conversations=e}setSavedState(e){e.theme&&(this.state.theme=e.theme),e.displayMode&&(this.state.displayMode=e.displayMode),e.panelWidth&&(this.state.panelWidth=e.panelWidth),e.panelHeight&&(this.state.panelHeight=e.panelHeight),e.defaultModel&&(this.state.defaultModel=e.defaultModel),e.defaultTemperature&&(this.state.defaultTemperature=e.defaultTemperature)}getConversations(){return this.state.conversations}setCurrentConversation(e){if(this.state.currentConversation===e)throw Error("Conversation is already current");this.state.currentConversation=e||null,e&&(this.setView("conversation"),this.jodit.e.fire("conversationSwitched.ai-assistant-pro",e))}getCurrentConversation(){return this.state.currentConversation}removeConversation(e){let t=this.state.conversations.filter(t=>t.id!==e);this.setConversations(t)}setLoading(e){this.state.isLoading=e}isLoading(){return this.state.isLoading}setError(e){this.state.error=e,e&&this.jodit.e.fire("error.ai-assistant-pro",Error(e))}getError(){return this.state.error}clearError(){this.setError(null)}setPendingToolCalls(e){this.state.pendingToolCalls=e}getPendingToolCalls(){return this.state.pendingToolCalls}addPendingToolCall(e){let t=[...this.state.pendingToolCalls,e];this.setPendingToolCalls(t)}removePendingToolCall(e){let t=this.state.pendingToolCalls.filter(t=>t.id!==e);this.setPendingToolCalls(t)}updateToolCallStatus(e,t){let s=this.state.pendingToolCalls.map(s=>s.id===e?{...s,status:t}:s);this.setPendingToolCalls(s)}setSelectionContexts(e){this.state.selectionContexts=e}getSelectionContexts(){return this.state.selectionContexts}addSelectionContext(e){let{maxContextRanges:t}=this.jodit.o.aiAssistantPro,s=[...this.state.selectionContexts,e];s.length>t&&(s=s.slice(-t)),this.setSelectionContexts(s),this.jodit.e.fire("contextAdded.ai-assistant-pro",e)}removeSelectionContext(e){let t=this.state.selectionContexts.filter((t,s)=>s!==e);this.setSelectionContexts(t),this.jodit.e.fire("contextRemoved.ai-assistant-pro",e)}clearSelectionContexts(){this.setSelectionContexts([])}setAbortController(e){this.state.abortController=e}getAbortController(){return this.state.abortController}setEditingMessageId(e){this.state.editingMessageId=e}getEditingMessageId(){return this.state.editingMessageId}isEditingMessage(){return null!=this.state.editingMessageId}clearEditingMessage(){this.setEditingMessageId(null)}reset(){this.state=this.createInitialState()}destruct(){this.state.abortController&&this.state.abortController.abort(),this.reset()}constructor(e){(0,i._)(this,"jodit",void 0),(0,i._)(this,"state",void 0),this.jodit=e,this.state=this.createInitialState()}}},62895:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return i.WebStorageConversationStorage},createStorageProvider:function(){return i.createStorageProvider}});var i=s(21064)},21064:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return a},createStorageProvider:function(){return r},generateConversationId:function(){return o},generateMessageId:function(){return l}});var i=s(82749),n=s(97333);class a{close(){return this.storage.close()}getConversationKey(e){return"conv:"+e}async getAllKeys(){let e=await this.storage.get("__conversation_index__");return e&&Array.isArray(e)?e:[]}async updateIndex(e){await this.storage.set("__conversation_index__",e)}async addToIndex(e){let t=await this.getAllKeys();t.includes(e)||(t.push(e),await this.updateIndex(t))}async removeFromIndex(e){let t=(await this.getAllKeys()).filter(t=>t!==e);await this.updateIndex(t)}async list(e){try{let t=await this.getAllKeys(),s=[],i=e?.toLowerCase().trim();for(let e of t){let t=await this.get(e);if(t){if(i){let e=t.title?.toLowerCase().includes(i),s=!e&&t.messages.some(e=>e.content.toLowerCase().includes(i));if(!e&&!s)continue}s.push({id:t.id,title:t.title??"",created:t.created,updated:t.updated,messageCount:t.messages.length})}}return s.sort((e,t)=>t.updated-e.updated),s}catch(e){return[]}}async get(e){try{let t=this.getConversationKey(e);return await this.storage.get(t)||null}catch(e){return null}}async save(e){try{if(0===e.messages.length)throw Error("Conversation must have at least one message.");let t=await this.getAllKeys();t.length>=this.maxConversations&&!t.includes(e.id)&&await this.evictOldest();let s=this.getConversationKey(e.id);await this.storage.set(s,e),await this.addToIndex(e.id)}catch(t){if(t?.name==="QuotaExceededError"||t?.code===22||t?.code===1014){await this.evictOldest();try{let t=this.getConversationKey(e.id);await this.storage.set(t,e),await this.addToIndex(e.id)}catch{throw Error("Storage quota exceeded. Please delete some conversations.")}}else throw Error("Failed to save conversation: "+(t?.message||"Unknown error"))}}async delete(e){try{let t=this.getConversationKey(e);await this.storage.delete(t),await this.removeFromIndex(e)}catch(e){}}async clear(){try{for(let e of(await this.getAllKeys())){let t=this.getConversationKey(e);await this.storage.delete(t)}await this.updateIndex([])}catch(e){}}async evictOldest(){try{let e=await this.list();if(0===e.length)return;e.sort((e,t)=>e.updated-t.updated);let t=e[0];await this.delete(t.id)}catch(e){}}async getGlobalSettings(){try{return await this.storage.get("global-settings")||null}catch(e){return null}}async saveGlobalSettings(e){try{let t={...await this.getGlobalSettings(),...e};await this.storage.set("global-settings",t)}catch{throw Error("Failed to save global settings")}}constructor(e,t){(0,i._)(this,"storage",void 0),(0,i._)(this,"maxConversations",void 0),this.storage=e,this.maxConversations=t}}function r(e,t){return n.AsyncStorage.makeStorage(e,t)}function o(){return`conv_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function l(){return`msg_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}},55487:function(e,t,s){"use strict";s.d(t,{ToolRegistry:function(){return a}});var i=s(82749),n=s(53835);class a{registerBuiltInTools(e){e.forEach(e=>{let t=n.BUILT_IN_TOOLS[e];t&&this.tools.set(e,t)})}registerCustomTools(e){e.forEach(e=>{this.validateToolDefinition(e),this.tools.set(e.name,e)})}validateToolDefinition(e){if(!e.name||"string"!=typeof e.name)throw Error("Tool must have a valid name");if(!e.description||"string"!=typeof e.description)throw Error(`Tool "${e.name}" must have a description`);if(!Array.isArray(e.parameters))throw Error(`Tool "${e.name}" must have a parameters array`);if("function"!=typeof e.execute)throw Error(`Tool "${e.name}" must have an execute function`);e.parameters.forEach(t=>{if(!t.name||"string"!=typeof t.name)throw Error(`Tool "${e.name}" has a parameter without a valid name`);if(!t.type)throw Error(`Tool "${e.name}" parameter "${t.name}" must have a type`);if("boolean"!=typeof t.required)throw Error(`Tool "${e.name}" parameter "${t.name}" must specify if it's required`)})}getAllTools(){return Array.from(this.tools.values())}getTool(e){return this.tools.get(e)}hasTool(e){return this.tools.has(e)}getToolNames(){return Array.from(this.tools.keys())}async executeTool(e,t,s){let i=this.getTool(e);if(!i)throw Error(`Tool "${e}" not found`);let n=this.applyDefaults(i,t);this.validateArguments(i,n);try{return await i.execute(this.jodit,n,s)}catch(e){if(e?.name==="AbortError"||s.aborted)throw Error("Tool execution was aborted");throw e}}validateArguments(e,t){let s=Object.keys(t);for(let t of e.parameters.filter(e=>e.required).map(e=>e.name))if(!s.includes(t))throw Error(`Tool "${e.name}" requires parameter "${t}"`);for(let[s,i]of Object.entries(t)){let t=e.parameters.find(e=>e.name===s);if(!t){this.jodit.o.aiAssistantPro.debug;continue}let n=Array.isArray(i)?"array":"object"==typeof i&&null!=i?"object":typeof i;if(t.type!==n&&!("number"===t.type&&"string"===n&&!isNaN(Number(i))))throw Error(`Tool "${e.name}" parameter "${s}" expects type "${t.type}" but got "${n}"`);if(t.enum&&t.enum.length>0&&!t.enum.includes(i))throw Error(`Tool "${e.name}" parameter "${s}" must be one of: ${t.enum.join(", ")}`)}}applyDefaults(e,t){let s={...t};for(let t of e.parameters)void 0===s[t.name]&&void 0!==t.default&&(s[t.name]=t.default);return s}destruct(){this.tools.clear()}constructor(e){(0,i._)(this,"jodit",void 0),(0,i._)(this,"tools",void 0),this.jodit=e,this.tools=new Map,this.registerBuiltInTools(e.o.aiAssistantPro.enabledTools||[]),this.registerCustomTools(e.o.aiAssistantPro.customTools||[])}}},26612:function(e){e.exports={"AI Assistant":"AI Assistant","AI Assistant Pro":"AI Assistant Pro","Welcome to AI Assistant":"Welcome to AI Assistant","Start your first conversation":"Start your first conversation","Tip: Select text in editor to add context":"Tip: Select text in editor to add context","New Chat":"New Chat","Search conversations...":"Search conversations...","No conversations yet":"No conversations yet","Ask me anything...":"Ask me anything...","Ask a follow-up...":"Ask a follow-up...","Reply...":"Reply...","Type your message...":"Type your message...",Send:"Send",Cancel:"Cancel",Retry:"Retry",Insert:"Insert",Copy:"Copy",Edit:"Edit",Delete:"Delete",New:"New",Back:"Back","Permission Required":"Permission Required",Approve:"Approve",Deny:"Deny",Once:"Once","This conversation":"This conversation",Always:"Always","The AI wants to execute:":"The AI wants to execute:","This will modify your document content.":"This will modify your document content.","Executing...":"Executing...","Completed successfully":"Completed successfully",Failed:"Failed","Pending approval":"Pending approval","Denied by user":"Denied by user","Tool Result":"Tool Result","Tool Execution Error":"Tool Execution Error",Context:"Context",Contexts:"Contexts","Add to AI Context":"Add to AI Context",Remove:"Remove","Clear all":"Clear all","An error occurred":"An error occurred","Request failed":"Request failed","Connection error":"Connection error","AI Assistant is not configured":"AI Assistant is not configured","Thinking...":"Thinking...","Generating response...":"Generating response...",insertHTML:"Insert HTML",readDocument:"Read Document",readBlock:"Read Block",replaceInDocument:"Replace in Document",replaceInBlock:"Replace in Block",getSelection:"Get Selection","Just now":"Just now",Conversation:"Conversation","New Conversation":"New Conversation",Yesterday:"Yesterday","Delete conversation":"Delete conversation","Are you sure you want to delete this conversation?":"Are you sure you want to delete this conversation?","Failed to delete conversation":"Failed to delete conversation"}},63805:function(e,t,s){"use strict";s.r(t),s.d(t,{en:function(){return n.a},ru:function(){return r.a}});var i=s(26612),n=s.n(i),a=s(41324),r=s.n(a)},94454:function(e,t,s){"use strict";s.d(t,{getAIProviderOptions:function(){return i.getAIProviderOptions},registerAIProvider:function(){return i.registerAIProvider}}),s(82923);var i=s(58211)},82923:function(e,t,s){"use strict";var i=s(58211),n=s(54079);(0,i.registerAIProvider)("jodit-ai-adapter",e=>{let t=e.url.replace(/\/+$/,""),s=e.provider??"openai",i=!1!==e.stream;return{apiMode:"incremental",maxRetries:0,textAutocompleteEnabled:!0,async textAutocompleteApiRequest(i,a,r){let o=new n.Ajax({url:`${t}/ai/autocomplete?query=${encodeURIComponent(i)}&key=${encodeURIComponent(e.apiKey)}`,method:"POST",contentType:"application/json",data:{provider:s,context:{maxSuggestions:a}}});r.addEventListener("abort",()=>o.abort(),{once:!0});let l=await o.send(),c=await l.json();return c.success&&c.result?.suggestions?c.result.suggestions:[]},async apiRequest(a,r){let o=new n.Ajax({url:`${t}/ai/request?key=${encodeURIComponent(e.apiKey)}`,method:"POST",contentType:"application/json",data:{provider:s,context:i?{...a,metadata:{...a.metadata,stream:!0}}:a}});if(r&&r.addEventListener("abort",()=>o.abort(),{once:!0}),!i){let e=await o.send();return{mode:"final",response:(await e.json()).result}}let l=o.stream();return{mode:"stream",stream:async function*(){for await(let e of l)yield JSON.parse(e)}()}}}})},58211:function(e,t,s){"use strict";s.d(t,{getAIProviderOptions:function(){return n},registerAIProvider:function(){return a}});let i=new Map;function n(e,t){let s=i.get(e);if(!s)throw Error(`AI provider "${e}" is not registered. Available providers: `+[...i.keys()].join(", "));return s(t)}function a(e,t){i.set(e,t)}},73943:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return a},requiresPermission:function(){return r}});let i="applyFormat",n="Apply or remove inline formatting to the current selection (bold, italic, underline, etc.) or to a specific block",a=[{name:"element",type:"string",description:'HTML element to wrap selection (e.g., "strong", "em", "u", "span")',required:!1},{name:"attributes",type:"object",description:'Attributes to apply (e.g., {"className": "highlight"}, {"style": {"color": "red"}})',required:!1},{name:"remove",type:"boolean",description:"If true, remove the formatting instead of applying it",required:!1,default:!1},{name:"blockIndex",type:"number",description:"Zero-based index of the block to format (if not using current selection)",required:!1},{name:"selector",type:"string",description:"CSS selector to find the block to format (if not using current selection)",required:!1}],r=!0},19127:function(e,t,s){"use strict";s.d(t,{execute:function(){return a}});var i=s(6689),n=s(44526);async function a(e,t,s){let{element:a,attributes:r,remove:o,blockIndex:l,selector:c}=t;if((0,i.throwIfAborted)(s),!a&&!r)throw Error('Either "element" or "attributes" must be provided');if(e.s.restore(),void 0!==l||c){let{element:t}=(0,n.resolveBlock)(e,{selector:c,index:l});e.s.select(t)}if(e.s.isCollapsed())throw Error("No selection found. Please select text to format");try{let t={};return a&&(t.element=a),r&&(t.attributes=r),o?e.s.commitStyle({...t,mode:"remove"}):e.s.commitStyle(t),e.synchronizeValues(),{success:!0,message:o?"Formatting removed successfully":"Formatting applied successfully"}}catch(e){throw Error(`Failed to ${o?"remove":"apply"} formatting: ${e.message}`)}}},39296:function(e,t,s){"use strict";var i=s(73943),n=s(19127);t.default={...i,execute:n.execute}},53835:function(e,t,s){"use strict";s.d(t,{BUILT_IN_TOOLS:function(){return d},getToolNames:function(){return p}});var i=s(39296),n=s(16745),a=s(78717),r=s(5618),o=s(90991),l=s(2020),c=s(12570),h=s(95323),u=s(97603);let d={readDocument:r.default,readBlocks:a.default,readSelection:o.default,writeDocument:u.default,replaceSelection:h.default,replaceBlock:l.default,replaceInDocument:c.default,insertHTML:n.default,applyFormat:i.default};function p(){return Object.keys(d)}},56732:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return a},requiresPermission:function(){return r}});let i="insertHTML",n="Insert or replace HTML content at the current cursor position in the editor",a=[{name:"html",type:"string",description:"HTML content to insert",required:!0},{name:"replace",type:"boolean",description:"If true, replaces current selection. If false, inserts at cursor",required:!1,default:!1}],r=!0},39592:function(e,t,s){"use strict";s.d(t,{execute:function(){return a}});var i=s(6689),n=s(49459);async function a(e,t,s){let a=(0,n.requireString)(t,"html",{allowEmpty:!0}),{replace:r}=t;if(!a.trim())return{success:!0,message:"Nothing to insert: HTML is empty"};(0,i.throwIfAborted)(s);try{return e.s.focus(),r&&!e.s.isCollapsed()&&e.s.remove(),e.s.insertHTML(a),e.synchronizeValues(),{success:!0,message:`Inserted ${a.length} characters of HTML`}}catch(e){throw Error("Failed to insert HTML: "+(e?.message||"Unknown error"))}}},16745:function(e,t,s){"use strict";var i=s(56732),n=s(39592);t.default={...i,execute:n.execute}},75352:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return a},requiresPermission:function(){return r}});let i="readBlocks",n="Read blocks from the editor with optional filtering and pagination",a=[{name:"offset",type:"number",description:"Number of blocks to skip from the beginning (default: 0)",required:!1,default:0},{name:"limit",type:"number",description:"Maximum number of blocks to return (default: all)",required:!1},{name:"query",type:"string",description:"Filter blocks by text content",required:!1}],r=!1},91140:function(e,t,s){"use strict";s.d(t,{execute:function(){return a}});var i=s(6689),n=s(22732);async function a(e,t,s){let{offset:a,limit:r,query:o}=t;(0,i.throwIfAborted)(s);let l=[];Array.from(e.editor.children).forEach((e,t)=>{n.Dom.isElement(e)&&l.push({blockIndex:t,tagName:e.tagName.toLowerCase(),content:e.innerHTML,textContent:e.textContent||"",classList:Array.from(e.classList)})});let c=l;if(o&&"string"==typeof o){let e=o.toLowerCase();c=l.filter(t=>t.textContent.toLowerCase().includes(e))}let h=Math.max(0,Math.min("number"==typeof a?a:0,c.length)),u=void 0!==r?Math.min(h+r,c.length):c.length;return{blocks:c.slice(h,u),total:l.length,offset:h,limit:void 0!==r?r:void 0}}},78717:function(e,t,s){"use strict";var i=s(75352),n=s(91140);t.default={...i,execute:n.execute}},93809:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return a},requiresPermission:function(){return r}});let i="readDocument",n="Read the entire content of the editor document in HTML format",a=[{name:"start",type:"number",description:"Start character position (default: 0)",required:!1,default:0},{name:"end",type:"number",description:"End character position (default: length of document)",required:!1},{name:"aroundSelection",type:"boolean",description:"If true, return only the maximum block around the current selection",required:!1,default:!1}],r=!1},28157:function(e,t,s){"use strict";s.d(t,{execute:function(){return a}});var i=s(6689),n=s(22732);async function a(e,t,s){let{start:a,end:r,aroundSelection:o}=t;(0,i.throwIfAborted)(s);let l=e.value,c=l.length;if(o&&!e.s.isCollapsed()){let t=e.s.range.commonAncestorContainer;for(;t&&t!==e.editor;){if(n.Dom.isElement(t)&&t.parentNode===e.editor){l=t.outerHTML;break}t=t.parentNode}return{html:l,length:c}}let h=void 0!==r?Math.min(r,c):c,u=Math.max(0,Math.min("number"==typeof a?a:0,c));return(u>0||c>h)&&(l=l.substring(u,h)),{html:l,length:c,start:u,end:h}}},5618:function(e,t,s){"use strict";var i=s(93809),n=s(28157);t.default={...i,execute:n.execute}},52826:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return a},requiresPermission:function(){return r}});let i="readSelection",n="Get information about the current selection including HTML content and optional context",a=[{name:"contextCharsBefore",type:"number",description:"Number of characters to include before the selection",required:!1,default:0},{name:"contextCharsAfter",type:"number",description:"Number of characters to include after the selection",required:!1,default:0}],r=!1},85130:function(e,t,s){"use strict";s.d(t,{execute:function(){return n}});var i=s(6689);async function n(e,t,s){let{contextCharsBefore:n,contextCharsAfter:a}=t;if((0,i.throwIfAborted)(s),e.s.restore(),e.s.isCollapsed())return{hasSelection:!1};let r=e.s.html,o=e.s.range,l=o.toString(),c={hasSelection:!0,html:r,text:l,startContainer:o.startContainer.nodeName,endContainer:o.endContainer.nodeName};if(n>0||a>0){let t=e.editor.textContent||"",s=t.substring(0,t.indexOf(l)),i=t.substring(t.indexOf(l)+l.length);n>0&&(c.contextBefore=s.slice(-n)),a>0&&(c.contextAfter=i.slice(0,a))}return c}},90991:function(e,t,s){"use strict";var i=s(52826),n=s(85130);t.default={...i,execute:n.execute}},96675:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return a},requiresPermission:function(){return r}});let i="replaceBlock",n="Replace a specific block in the document by its index or CSS selector with new HTML content",a=[{name:"index",type:"number",description:"Zero-based index of the block to replace (use either index or selector, not both)",required:!1},{name:"selector",type:"string",description:'CSS selector to find the block to replace (e.g., "h1", ".my-class", "#my-id"). Use either selector or index, not both',required:!1},{name:"html",type:"string",description:"HTML content for the new block",required:!0}],r=!0},3091:function(e,t,s){"use strict";s.d(t,{execute:function(){return o}});var i=s(6689),n=s(49459),a=s(44526),r=s(22732);async function o(e,t,s){let{index:o,selector:l}=t,c=(0,n.requireString)(t,"html");if((0,i.throwIfAborted)(s),void 0===o&&!l||void 0!==o&&l)throw Error("Either index or selector must be provided, but not both");let{element:h,identifier:u}=(0,a.resolveBlock)(e,{selector:l,index:o,requireExactlyOne:!0});try{let t=e.createInside.div();t.innerHTML=c;let s=t.firstChild;if(!s||!r.Dom.isElement(s))throw Error("Invalid HTML: must contain at least one element");return h.parentNode?.replaceChild(s,h),e.synchronizeValues(),{success:!0,message:`Block ${u} replaced successfully`}}catch(e){throw Error(`Failed to replace block ${u}: ${e.message}`)}}},2020:function(e,t,s){"use strict";var i=s(96675),n=s(3091);t.default={...i,execute:n.execute}},62553:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return a},requiresPermission:function(){return r}});let i="replaceInDocument",n="Find and replace text or HTML patterns throughout the entire document",a=[{name:"search",type:"string",description:"Text or pattern to search for",required:!0},{name:"replace",type:"string",description:"Replacement text or HTML",required:!0},{name:"useRegex",type:"boolean",description:"If true, treats search as a regular expression",required:!1,default:!1},{name:"useSelector",type:"string",description:"CSS selector to narrow down the search scope to specific elements",required:!1}],r=!0},56293:function(e,t,s){"use strict";s.d(t,{execute:function(){return a}});var i=s(6689),n=s(49459);async function a(e,t,s){let a=(0,n.requireString)(t,"search"),r=(0,n.requireString)(t,"replace",{allowEmpty:!0}),{useRegex:o,useSelector:l}=t;(0,i.throwIfAborted)(s);try{let t;e.s.focus(),e.s.save();let n=0;if(l){let c=function(e,t,s,n,a,r){let o=e.editor.querySelectorAll(a);if(0===o.length)return{replacements:0,message:`No elements found matching selector "${a}"`};let l=0;return o.forEach(e=>{(0,i.throwIfAborted)(r);let a=e.innerHTML,o=a;if(n)try{let e=RegExp(t,"g");a=a.replace(e,()=>(l++,s))}catch(e){throw Error("Invalid regex pattern: "+(e?.message||"Unknown error"))}else{let e=t.length,n=0;for(;-1!==(n=a.indexOf(t,n));)(0,i.throwIfAborted)(r),a=a.substring(0,n)+s+a.substring(n+e),n+=s.length,l++}a!==o&&(e.innerHTML=a)}),l>0&&(e.synchronizeValues(),e.s.restore()),{replacements:l}}(e,a,r,o,l,s);n=c.replacements,t=c.message}else n=function(e,t,s,n,a,r){let o=0,l=t;if(a)try{let e=RegExp(s,"g");l=l.replace(e,()=>(o++,n))}catch(e){throw Error("Invalid regex pattern: "+(e?.message||"Unknown error"))}else{let e=s.length,t=0;for(;-1!==(t=l.indexOf(s,t));)(0,i.throwIfAborted)(r),l=l.substring(0,t)+n+l.substring(t+e),t+=n.length,o++}return o>0&&(e.value=l,e.s.restore(),e.synchronizeValues()),o}(e,e.value,a,r,o,s);return{replacements:n,message:t||(n>0?`Replaced ${n} occurrence(s)`:"No matches found")}}catch(t){throw e.s.restore(),Error("Failed to replace in document: "+(t?.message||"Unknown error"))}}},12570:function(e,t,s){"use strict";var i=s(62553),n=s(56293);t.default={...i,execute:n.execute}},70750:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return a},requiresPermission:function(){return r}});let i="replaceSelection",n="Replace the current selection with new HTML content",a=[{name:"html",type:"string",description:"HTML content to insert in place of the selection",required:!0},{name:"collapseToEnd",type:"boolean",description:"Move cursor to the end of the inserted content",required:!1,default:!0}],r=!0},36142:function(e,t,s){"use strict";s.d(t,{execute:function(){return a}});var i=s(6689),n=s(49459);async function a(e,t,s){let a=(0,n.requireString)(t,"html"),{collapseToEnd:r}=t;(0,i.throwIfAborted)(s);try{if(e.s.restore(),e.s.insertHTML(a),r){let t=e.s.range;t.collapse(!1),e.s.selectRange(t)}return e.e.fire("change"),{success:!0,message:"Selection replaced successfully"}}catch(e){throw Error("Failed to replace selection: "+e.message)}}},95323:function(e,t,s){"use strict";var i=s(70750),n=s(36142);t.default={...i,execute:n.execute}},90022:function(e,t,s){"use strict";s.r(t),s.d(t,{description:function(){return n},name:function(){return i},parameters:function(){return a},requiresPermission:function(){return r}});let i="writeDocument",n="Write (replace) the entire document content with new HTML",a=[{name:"html",type:"string",description:"HTML content to set as the document",required:!0}],r=!0},79766:function(e,t,s){"use strict";s.d(t,{execute:function(){return a}});var i=s(6689),n=s(49459);async function a(e,t,s){let a=(0,n.requireString)(t,"html",{allowEmpty:!0});(0,i.throwIfAborted)(s);try{return e.s.focus(),e.value=a,e.synchronizeValues(),{success:!0,message:`Document content was replaced with provided HTML(${a.length} characters)`}}catch(e){throw Error("Failed to replace HTML: "+(e?.message||"Unknown error"))}}},97603:function(e,t,s){"use strict";var i=s(90022),n=s(79766);t.default={...i,execute:n.execute}},80453:function(e,t,s){"use strict";s.d(t,{UIConversationListItem:function(){return c}});var i=s(82749),n=s(31635),a=s(65478),r=s(67510),o=s(62843),l=s(80870);class c extends r.UIElement{className(){return"UIConversationListItem"}render(){return'<div class="jodit-ui-conversation-list__item"></div>'}setActive(e){this.isActive=e,this.updateContent()}updateContent(){let e=this.container;e.innerHTML="",e.setAttribute("data-id",this.conversation.id),this.isActive?e.classList.add("jodit-ui-conversation-list__item_active"):e.classList.remove("jodit-ui-conversation-list__item_active");let t=this.j.c.div("jodit-ui-conversation-list__item-avatar");t.textContent="AI",e.appendChild(t);let s=this.j.c.div("jodit-ui-conversation-list__item-wrapper"),i=this.j.c.div("jodit-ui-conversation-list__item-content"),n=this.j.c.div("jodit-ui-conversation-list__item-title");if(n.textContent=this.conversation.title,this.titleElement=n,i.appendChild(n),this.opts.showTimestamps){let e=this.j.c.div("jodit-ui-conversation-list__item-meta");e.textContent=this.opts.formatTimestamp(this.conversation.updated,this.j.i18n.bind(this.j)),i.appendChild(e)}if(s.appendChild(i),this.conversation.messageCount>0){let e=this.j.c.div("jodit-ui-conversation-list__item-badge");e.textContent=this.conversation.messageCount+"",s.appendChild(e)}e.appendChild(s),this.actionsButton||(this.actionsButton=new o.UIButton(this.j,{icon:{name:"dots"},tooltip:"Actions",name:"conversationActions",size:"tiny"}),this.actionsButton.container.classList.add("jodit-ui-conversation-list__item-actions"),this.actionsButton.onAction(e=>{e.stopPropagation(),this.showActionsMenu(e)})),e.appendChild(this.actionsButton.container)}onClick(){this.isRenaming||this.j.e.fire("selectConversation.ai-assistant-pro",this.conversation.id)}showActionsMenu(e){if(!this.contextMenu||!this.actionsButton)return;let t=this.actionsButton.container.getBoundingClientRect();this.contextMenu.show(t.left,t.bottom,[{title:"Rename",icon:"pencil",exec:()=>{this.startInlineRename()}},{title:"Delete",icon:"bin",exec:()=>{this.onDelete()}}]),e.stopPropagation()}startInlineRename(){if(this.isRenaming||!this.titleElement)return;this.isRenaming=!0;let e=this.titleElement,t=this.conversation.title,s=this.j.c.element("input");s.type="text",s.value=t,s.className="jodit-ui-conversation-list__item-title-input",e.textContent="",e.appendChild(s),s.focus(),s.select();let i=()=>{if(!this.isRenaming)return;let i=s.value.trim();this.isRenaming=!1,i&&i!==t?(e.textContent=i,this.j.e.fire("renameConversation.ai-assistant-pro",this.conversation.id,i)):e.textContent=t};this.j.e.on(s,"blur",i),this.j.e.on(s,"keydown",i=>{"Enter"===i.key&&(i.preventDefault(),s.blur()),"Escape"===i.key&&(this.isRenaming=!1,e.textContent=t)}),this.j.e.on(s,"click",e=>{e.stopPropagation()})}onDelete(){this.j.e.fire("deleteConversation.ai-assistant-pro",this.conversation.id)}destruct(){this.actionsButton?.destruct(),this.contextMenu?.destruct(),super.destruct()}constructor(e,t,s=!1,n){super(e),(0,i._)(this,"opts",void 0),(0,i._)(this,"conversation",void 0),(0,i._)(this,"isActive",void 0),(0,i._)(this,"actionsButton",void 0),(0,i._)(this,"contextMenu",void 0),(0,i._)(this,"titleElement",void 0),(0,i._)(this,"isRenaming",void 0),this.opts=n,this.actionsButton=null,this.contextMenu=null,this.titleElement=null,this.isRenaming=!1,this.conversation=t,this.isActive=s,this.contextMenu=new l.ContextMenu(this.j),this.updateContent()}}(0,n.__decorate)([(0,a.watch)("container:click")],c.prototype,"onClick",null),(0,n.__decorate)([a.autobind],c.prototype,"showActionsMenu",null),(0,n.__decorate)([a.autobind],c.prototype,"startInlineRename",null),(0,n.__decorate)([a.autobind],c.prototype,"onDelete",null),c=(0,n.__decorate)([a.component],c)},68365:function(e,t,s){"use strict";s.d(t,{UIConversationList:function(){return h}});var i=s(82749),n=s(31635),a=s(31356),r=s(80453),o=s(65478),l=s(80256),c=s(62405);class h extends c.UIGroup{className(){return"UIConversationList"}render(){return`<div class="&__container">
11
11
  <div class="&__header"></div>
12
12
  <div class="&__search">
13
13
  <div class="&__search-loader"></div>
14
14
  </div>
15
15
  <div class="&__list"></div>
16
- </div>`}afterRender(){this.createControls(),this.listContainer=this.getElm("list")}appendChildToContainer(e){this.listContainer&&this.listContainer.appendChild(e)}createControls(){let e=this.getElm("search");this.searchInput=new l.UIInput(this.j,{name:"search",placeholder:"Search conversations...",icon:"search",clearButton:!0}),this.j.e.on(this.searchInput.nativeInput,"input",this.onSearch),e.appendChild(this.searchInput.container)}setConversations(e){this.buildList(e)}setActiveConversation(e){this.activeConversationId=e,this.elements.forEach(t=>{t.setActive(t.conversation.id===e)})}onSearch(){let e=this.searchInput.value.trim();this.j.e.fire("searchConversations.ai-assistant-pro",e)}buildList(e){let t=this.elements.map(e=>e.conversation),s=r.ListReconciler.reconcile(t,e,{getId:e=>e.id,isEqual:(e,t)=>e.id===t.id&&e.updated===t.updated,preserveOrder:!0});s.toRemove.forEach(e=>{let t=this.conversationItems.get(e.id);t&&(-1!==this.elements.indexOf(t)&&(this.remove(t),t.destruct()),this.conversationItems.delete(e.id))}),s.toUpdate.forEach(({newItem:e,index:t})=>{let s=this.conversationItems.get(e.id);if(s){let i=e.id===this.activeConversationId;s.setActive(i),this.elements.indexOf(s)!==t&&t<this.elements.length&&(this.remove(s),this.append(s,t))}}),s.toCreate.forEach(t=>{let s=t.id===this.activeConversationId,i=new a.UIConversationListItem(this.j,t,s,this.opts);this.conversationItems.set(t.id,i);let n=e.indexOf(t);this.append(i,n)}),s.unchanged.forEach(e=>{let t=this.conversationItems.get(e.id);if(t){let s=e.id===this.activeConversationId;t.setActive(s)}})}setLoading(e){this.setMod("loading",e)}setParentView(e){return this.searchInput?.setParentView(e),super.setParentView(e)}destruct(){this.searchInput?.destruct(),super.destruct()}constructor(e,t){super(e),(0,i._)(this,"opts",void 0),(0,i._)(this,"searchInput",void 0),(0,i._)(this,"activeConversationId",void 0),(0,i._)(this,"listContainer",void 0),(0,i._)(this,"conversationItems",void 0),this.opts=t,this.searchInput=null,this.activeConversationId=null,this.conversationItems=new Map}}(0,n.__decorate)([(0,o.hook)("ready")],h.prototype,"afterRender",null),(0,n.__decorate)([(0,o.debounce)()],h.prototype,"onSearch",null),h=(0,n.__decorate)([o.component],h)},63227:function(e,t,s){"use strict";s.d(t,{UIInputArea:function(){return h}});var i=s(82749),n=s(31635),r=s(65478),a=s(38837),o=s(67510),l=s(62843),c=s(85120);class h extends o.UIElement{className(){return"UIInputArea"}setParentView(e){return this.textarea?.setParentView(e),this.sendButton?.setParentView(e),this.stopButton?.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
16
+ </div>`}afterRender(){this.createControls(),this.listContainer=this.getElm("list")}appendChildToContainer(e){this.listContainer&&this.listContainer.appendChild(e)}createControls(){let e=this.getElm("search");this.searchInput=new l.UIInput(this.j,{name:"search",placeholder:"Search conversations...",icon:"search",clearButton:!0}),this.j.e.on(this.searchInput.nativeInput,"input",this.onSearch),e.appendChild(this.searchInput.container)}setConversations(e){this.buildList(e)}setActiveConversation(e){this.activeConversationId=e,this.elements.forEach(t=>{t.setActive(t.conversation.id===e)})}onSearch(){let e=this.searchInput.value.trim();this.j.e.fire("searchConversations.ai-assistant-pro",e)}buildList(e){let t=this.elements.map(e=>e.conversation),s=a.ListReconciler.reconcile(t,e,{getId:e=>e.id,isEqual:(e,t)=>e.id===t.id&&e.updated===t.updated,preserveOrder:!0});s.toRemove.forEach(e=>{let t=this.conversationItems.get(e.id);t&&(-1!==this.elements.indexOf(t)&&(this.remove(t),t.destruct()),this.conversationItems.delete(e.id))}),s.toUpdate.forEach(({newItem:e,index:t})=>{let s=this.conversationItems.get(e.id);if(s){let i=e.id===this.activeConversationId;s.setActive(i),this.elements.indexOf(s)!==t&&t<this.elements.length&&(this.remove(s),this.append(s,t))}}),s.toCreate.forEach(t=>{let s=t.id===this.activeConversationId,i=new r.UIConversationListItem(this.j,t,s,this.opts);this.conversationItems.set(t.id,i);let n=e.indexOf(t);this.append(i,n)}),s.unchanged.forEach(e=>{let t=this.conversationItems.get(e.id);if(t){let s=e.id===this.activeConversationId;t.setActive(s)}})}setLoading(e){this.setMod("loading",e)}setParentView(e){return this.searchInput?.setParentView(e),super.setParentView(e)}destruct(){this.searchInput?.destruct(),super.destruct()}constructor(e,t){super(e),(0,i._)(this,"opts",void 0),(0,i._)(this,"searchInput",void 0),(0,i._)(this,"activeConversationId",void 0),(0,i._)(this,"listContainer",void 0),(0,i._)(this,"conversationItems",void 0),this.opts=t,this.searchInput=null,this.activeConversationId=null,this.conversationItems=new Map}}(0,n.__decorate)([(0,o.hook)("ready")],h.prototype,"afterRender",null),(0,n.__decorate)([(0,o.debounce)()],h.prototype,"onSearch",null),h=(0,n.__decorate)([o.component],h)},63227:function(e,t,s){"use strict";s.d(t,{UIInputArea:function(){return h}});var i=s(82749),n=s(31635),a=s(65478),r=s(38837),o=s(67510),l=s(62843),c=s(85120);class h extends o.UIElement{className(){return"UIInputArea"}setParentView(e){return this.textarea?.setParentView(e),this.sendButton?.setParentView(e),this.stopButton?.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
17
17
  <div class="&__context-badges"></div>
18
18
  <div class="&__loading-indicator">
19
19
  <span class="&__loading-dot"></span>
@@ -24,7 +24,7 @@ ${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQ
24
24
  <div class="&__textarea-wrapper"></div>
25
25
  <div class="&__buttons"></div>
26
26
  </div>
27
- </div>`}onInputRowClick(){this.textarea!==this.j.od.activeElement&&this.textarea?.focus()}afterRender(){this.contextBadges=this.getElm("context-badges"),this.createControls(),this.attachHandlers()}createControls(){let e=this.getElm("textarea-wrapper"),t=this.getElm("buttons");this.textarea=new c.UITextArea(this.j,{name:"message",placeholder:this.options.placeholderText,resizable:!1}),e.appendChild(this.textarea.container),this.sendButton=new l.UIButton(this.j,{name:"send-message",icon:{name:"send"},variant:"initial",size:"middle"}),this.stopButton=new l.UIButton(this.j,{name:"abort-message",icon:{name:"cancel"},variant:"default",size:"middle"}),this.stopButton.container.style.display="none",t.appendChild(this.sendButton.container),t.appendChild(this.stopButton.container)}attachHandlers(){this.j.e.on(this.sendButton,"click",this.onSend),this.j.e.on(this.stopButton,"click",this.onStop),this.j.e.on(this.textarea.nativeInput,"keydown",e=>{let{sendShortcut:t,sendOnEnter:s}=this.options;if("Ctrl+Enter"===t&&e.ctrlKey&&"Enter"===e.key){e.preventDefault(),this.onSend();return}"Escape"===e.key?this.j.e.fire("cancelEditMessage.ai-assistant-pro"):"Enter"===e.key&&(s?e.shiftKey||(e.preventDefault(),this.onSend()):e.shiftKey&&(e.preventDefault(),this.onSend()))})}onSend(){let e=this.textarea?.value.trim();!e||this.isLoading||(this.j.e.fire("sendMessage.ai-assistant-pro",e),this.textarea&&(this.textarea.value="",this.textarea.nativeInput.focus()))}onStop(){this.j.e.fire("abortRequest.ai-assistant-pro")}setContexts(e){this.contexts=e,this.updateContextBadges()}updateContextBadges(){if(this.contextBadges.innerHTML="",0===this.contexts.length){this.contextBadges.style.display="none";return}this.contextBadges.style.display="",this.contexts.forEach((e,t)=>{let s=this.createContextBadge(e,t);this.contextBadges.appendChild(s)})}createContextBadge(e,t){let s=this.j.c.div(this.getFullElName("context-badge")),i=this.j.c.span(),n=e.html.replace(/<[^>]*>/g,"").substring(0,20);i.textContent=void 0!==e.blockIndex?`Block ${e.blockIndex}: ${n}...`:`${n}...`;let r=this.j.c.span(this.getFullElName("context-remove"));return r.textContent="×",r.setAttribute("data-index",t+""),this.j.e.on(r,"click",()=>{this.j.e.fire("removeContext.ai-assistant-pro",t)}),s.appendChild(i),s.appendChild(r),s}setLoading(e){this.isLoading=e;let{sendButton:t,stopButton:s,textarea:i}=this;(0,a.assert)(t&&s&&i,"Buttons must be initialized"),i.setMod("disabled",e),t.setMod("disabled",e),this.setMod("loading",e),e?(t.container.style.display="none",s.container.style.display=""):(t.container.style.display="",s.container.style.display="none")}focus(){this.textarea?.nativeInput.focus()}setValue(e){this.textarea&&(this.textarea.value=e)}getValue(){return this.textarea?.value.trim()||""}destruct(){this.textarea?.destruct(),this.sendButton?.destruct(),this.stopButton?.destruct(),super.destruct()}constructor(e,t){super(e),(0,i._)(this,"options",void 0),(0,i._)(this,"textarea",void 0),(0,i._)(this,"sendButton",void 0),(0,i._)(this,"stopButton",void 0),(0,i._)(this,"contextBadges",void 0),(0,i._)(this,"contexts",void 0),(0,i._)(this,"isLoading",void 0),this.options=t,this.textarea=null,this.sendButton=null,this.stopButton=null,this.contexts=[],this.isLoading=!1}}(0,n.__decorate)([(0,r.watch)("input-row:click")],h.prototype,"onInputRowClick",null),(0,n.__decorate)([(0,r.hook)("ready")],h.prototype,"afterRender",null),(0,n.__decorate)([r.autobind],h.prototype,"onSend",null),(0,n.__decorate)([r.autobind],h.prototype,"onStop",null),h=(0,n.__decorate)([r.component],h)},27769:function(e,t,s){"use strict";s.d(t,{UIMainPanel:function(){return i.UIMainPanel}});var i=s(51251)},51251:function(e,t,s){"use strict";s.d(t,{UIMainPanel:function(){return f}});var i=s(82749),n=s(31635),r=s(68365),a=s(63227),o=s(86563),l=s(93677),c=s(48705),h=s(55885),u=s(65478),d=s(2748),p=s(67510),g=s(62843),m=s(80870);class f extends p.UIElement{className(){return"UIMainPanel"}setParentView(e){return this.welcomeScreen?.setParentView(e),this.conversationList?.setParentView(e),this.messageList?.setParentView(e),this.inputArea?.setParentView(e),this.permissionRequest?.setParentView(e),this.settingsButton?.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
27
+ </div>`}onInputRowClick(){this.textarea!==this.j.od.activeElement&&this.textarea?.focus()}afterRender(){this.contextBadges=this.getElm("context-badges"),this.createControls(),this.attachHandlers()}createControls(){let e=this.getElm("textarea-wrapper"),t=this.getElm("buttons");this.textarea=new c.UITextArea(this.j,{name:"message",placeholder:this.options.placeholderText,resizable:!1}),e.appendChild(this.textarea.container),this.sendButton=new l.UIButton(this.j,{name:"send-message",icon:{name:"send"},variant:"initial",size:"middle"}),this.stopButton=new l.UIButton(this.j,{name:"abort-message",icon:{name:"cancel"},variant:"default",size:"middle"}),this.stopButton.container.style.display="none",t.appendChild(this.sendButton.container),t.appendChild(this.stopButton.container)}attachHandlers(){this.j.e.on(this.sendButton,"click",this.onSend),this.j.e.on(this.stopButton,"click",this.onStop),this.j.e.on(this.textarea.nativeInput,"keydown",e=>{let{sendShortcut:t,sendOnEnter:s}=this.options;if("Ctrl+Enter"===t&&e.ctrlKey&&"Enter"===e.key){e.preventDefault(),this.onSend();return}"Escape"===e.key?this.j.e.fire("cancelEditMessage.ai-assistant-pro"):"Enter"===e.key&&(s?e.shiftKey||(e.preventDefault(),this.onSend()):e.shiftKey&&(e.preventDefault(),this.onSend()))})}onSend(){let e=this.textarea?.value.trim();!e||this.isLoading||(this.j.e.fire("sendMessage.ai-assistant-pro",e),this.textarea&&(this.textarea.value="",this.textarea.nativeInput.focus()))}onStop(){this.j.e.fire("abortRequest.ai-assistant-pro")}setContexts(e){this.contexts=e,this.updateContextBadges()}updateContextBadges(){if(this.contextBadges.innerHTML="",0===this.contexts.length){this.contextBadges.style.display="none";return}this.contextBadges.style.display="",this.contexts.forEach((e,t)=>{let s=this.createContextBadge(e,t);this.contextBadges.appendChild(s)})}createContextBadge(e,t){let s=this.j.c.div(this.getFullElName("context-badge")),i=this.j.c.span(),n=e.html.replace(/<[^>]*>/g,"").substring(0,20);i.textContent=void 0!==e.blockIndex?`Block ${e.blockIndex}: ${n}...`:`${n}...`;let a=this.j.c.span(this.getFullElName("context-remove"));return a.textContent="×",a.setAttribute("data-index",t+""),this.j.e.on(a,"click",()=>{this.j.e.fire("removeContext.ai-assistant-pro",t)}),s.appendChild(i),s.appendChild(a),s}setLoading(e){this.isLoading=e;let{sendButton:t,stopButton:s,textarea:i}=this;(0,r.assert)(t&&s&&i,"Buttons must be initialized"),i.setMod("disabled",e),t.setMod("disabled",e),this.setMod("loading",e),e?(t.container.style.display="none",s.container.style.display=""):(t.container.style.display="",s.container.style.display="none")}focus(){this.textarea?.nativeInput.focus()}setValue(e){this.textarea&&(this.textarea.value=e)}getValue(){return this.textarea?.value.trim()||""}destruct(){this.textarea?.destruct(),this.sendButton?.destruct(),this.stopButton?.destruct(),super.destruct()}constructor(e,t){super(e),(0,i._)(this,"options",void 0),(0,i._)(this,"textarea",void 0),(0,i._)(this,"sendButton",void 0),(0,i._)(this,"stopButton",void 0),(0,i._)(this,"contextBadges",void 0),(0,i._)(this,"contexts",void 0),(0,i._)(this,"isLoading",void 0),this.options=t,this.textarea=null,this.sendButton=null,this.stopButton=null,this.contexts=[],this.isLoading=!1}}(0,n.__decorate)([(0,a.watch)("input-row:click")],h.prototype,"onInputRowClick",null),(0,n.__decorate)([(0,a.hook)("ready")],h.prototype,"afterRender",null),(0,n.__decorate)([a.autobind],h.prototype,"onSend",null),(0,n.__decorate)([a.autobind],h.prototype,"onStop",null),h=(0,n.__decorate)([a.component],h)},27769:function(e,t,s){"use strict";s.d(t,{UIMainPanel:function(){return i.UIMainPanel}});var i=s(51251)},51251:function(e,t,s){"use strict";s.d(t,{UIMainPanel:function(){return f}});var i=s(82749),n=s(31635),a=s(68365),r=s(63227),o=s(86563),l=s(93677),c=s(48705),h=s(55885),u=s(65478),d=s(2748),p=s(67510),g=s(62843),m=s(80870);class f extends p.UIElement{className(){return"UIMainPanel"}setParentView(e){return this.welcomeScreen?.setParentView(e),this.conversationList?.setParentView(e),this.messageList?.setParentView(e),this.inputArea?.setParentView(e),this.permissionRequest?.setParentView(e),this.settingsButton?.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
28
28
  <div class="&__header">
29
29
  <div class="&__header-left"></div>
30
30
  <div class="&__header-title"></div>
@@ -35,7 +35,7 @@ ${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQ
35
35
  <div class="&__loading-spinner"></div>
36
36
  </div>
37
37
  <div class="&__footer"></div>
38
- </div>`}addResize(){}afterRender(){this.content=this.getElm("content"),this.headerContextMenu=new m.ContextMenu(this.j),this.createComponents(),this.createHeaderButtons(),this.setupConversationRenameHandler(),this.__updateView("welcome")}async __onChangeView(){this.__updateView(this.state.currentView,this.state.currentConversation)}createComponents(){this.welcomeScreen=new h.UIWelcomeScreen(this.j),this.conversationList=new r.UIConversationList(this.j,this.options),this.messageList=new o.UIMessageList(this.j,this.options),this.inputArea=new a.UIInputArea(this.j,this.options),this.getElm("footer").appendChild(this.inputArea.container)}createHeaderButtons(){let e=this.getElm("header-left"),t=this.getElm("header-right"),s=new g.UIButton(this.j,{icon:{name:"angle-left"},size:"small",variant:"initial"});s.container.classList.add(this.getFullElName("back-button")),this.j.e.on(s,"click",()=>{this.j.e.fire("backToList.ai-assistant-pro")}),e.appendChild(s.container),this.conversationActionsButton=new g.UIButton(this.j,{icon:{name:"dots"},size:"small",tooltip:"Conversation actions",variant:"initial"}),this.conversationActionsButton.container.classList.add(this.getFullElName("conversation-actions-button")),this.conversationActionsButton.onAction(this.showConversationActionsMenu),t.appendChild(this.conversationActionsButton.container);let i=new g.UIButton(this.j,{icon:{name:"plus"},size:"small",tooltip:"New chat",variant:"initial"});if(i.container.classList.add(this.getFullElName("new-button")),this.j.e.on(i,"click",()=>{this.j.e.fire("newConversation.ai-assistant-pro")}),t.appendChild(i.container),this.shouldShowSettings()&&(this.settingsButton=new c.UISettingsButton(this.j,this.state,this.options,()=>this.state.currentConversation,this.updateConversation),this.settingsButton.container.classList.add(this.getFullElName("settings-button")),t.appendChild(this.settingsButton.container)),"dialog"===this.mods.displayMode||!1===this.mods.allowClose)return;let n=new g.UIButton(this.j,{icon:{name:"cancel"},size:"small",tooltip:"Close",variant:"initial"});n.container.classList.add(this.getFullElName("close-button")),this.j.e.on(n,"click",()=>{this.j.e.fire("closeAIAssistantPro.ai-assistant-pro")}),t.appendChild(n.container)}setupConversationRenameHandler(){}showConversationActionsMenu(e){if(!this.headerContextMenu||!this.state.currentConversation)return;let t=this.state.currentConversation,s=[{title:"Rename",icon:"pencil",exec:()=>{this.showRenamePrompt(t.id,t.title||this.j.i18n("Conversation"))}},{title:"Delete",icon:"bin",exec:()=>{this.j.e.fire("deleteConversation.ai-assistant-pro",t.id)}}],i=this.conversationActionsButton.container.getBoundingClientRect();this.headerContextMenu.show(i.left,i.bottom,s),e.stopPropagation()}showRenamePrompt(e,t){if(this.isEditingTitle)return;this.isEditingTitle=!0;let s=this.getElm("header-title"),i=this.j.c.element("input");i.type="text",i.value=t,i.className=this.getFullElName("header-title-input"),s.textContent="",s.appendChild(i),i.focus(),i.select();let n=()=>{let n=i.value.trim();this.isEditingTitle=!1,n&&n!==t?(this.j.e.fire("renameConversation.ai-assistant-pro",e,n),s.textContent=n):s.textContent=t};this.j.e.on(i,"blur",n),this.j.e.on(i,"keydown",e=>{"Enter"===e.key&&(e.preventDefault(),i.blur()),"Escape"===e.key&&(this.isEditingTitle=!1,s.textContent=t)})}isFlightMode(){return"flight"===this.mods.displayMode}shouldShowSettings(){let e=this.options,t=e.allowEditDisplayMode||e.allowEditPanelWidth,s=e.allowEditDialogSettings;return t||s}__updateView(e,t=null){this.settingsButton?.update();let s=this.getElm("header-title");this.setMod("view",e);let i=this.isFlightMode();switch(e){case"welcome":s.textContent=this.j.i18n("AI Assistant"),d.Dom.safeRemove(this.conversationList.container),d.Dom.safeRemove(this.messageList.container),this.content.appendChild(this.welcomeScreen.container),this.inputArea.focus();break;case"conversationList":s.textContent=this.j.i18n("AI Assistant"),d.Dom.safeRemove(this.welcomeScreen.container),d.Dom.safeRemove(this.messageList.container),this.conversationList.container.isConnected||this.content.appendChild(this.conversationList.container);break;case"conversation":s.textContent=i?this.j.i18n("AI Assistant"):t?.title||this.j.i18n("Conversation"),d.Dom.safeRemove(this.welcomeScreen.container),d.Dom.safeRemove(this.conversationList.container),this.messageList.container.isConnected||this.content.appendChild(this.messageList.container),t&&this.messageList.setMessages(t.messages),this.inputArea.focus()}}onChangeCurrentConversation(){let{currentConversation:e}=this.state;e&&(this.conversationList.setActiveConversation(e.id),this.messageList.setMessages(e.messages))}onChangeConversations(){this.conversationList.setConversations(this.state.conversations)}onChangeSelectionContexts(){this.inputArea.setContexts(this.state.selectionContexts)}onChangeLoading(){this.inputArea.setLoading(this.state.isLoading)}onChangePendingToolCalls(){this.state.pendingToolCalls&&this.state.pendingToolCalls.length>0?this.showPermissionRequest(this.state.pendingToolCalls[0]):this.hidePermissionRequest()}showPermissionRequest(e){this.permissionRequest||(this.permissionRequest=new l.UIPermissionRequest(this.j,this.options)),this.permissionRequest.setToolCall(e);let t=this.getElm("footer");t.contains(this.permissionRequest.container)||t.insertBefore(this.permissionRequest.container,this.inputArea.container)}hidePermissionRequest(){this.permissionRequest&&this.permissionRequest.container.parentNode&&this.permissionRequest.container.parentNode.removeChild(this.permissionRequest.container)}destruct(){this.welcomeScreen?.destruct(),this.conversationList?.destruct(),this.messageList?.destruct(),this.inputArea?.destruct(),this.permissionRequest?.destruct(),this.settingsButton?.destruct(),this.conversationActionsButton?.destruct(),this.headerContextMenu?.destruct(),super.destruct()}constructor(e,t,s,n){super(e),(0,i._)(this,"state",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"updateConversation",void 0),(0,i._)(this,"permissionRequest",void 0),(0,i._)(this,"settingsButton",void 0),(0,i._)(this,"content",void 0),(0,i._)(this,"isEditingTitle",void 0),(0,i._)(this,"conversationActionsButton",void 0),(0,i._)(this,"headerContextMenu",void 0),this.state=t,this.options=s,this.updateConversation=n,this.permissionRequest=null,this.settingsButton=null,this.isEditingTitle=!1,this.conversationActionsButton=null,this.headerContextMenu=null}}(0,n.__decorate)([(0,u.hook)("ready")],f.prototype,"afterRender",null),(0,n.__decorate)([(0,u.watch)(["state.currentView","state.currentConversation"])],f.prototype,"__onChangeView",null),(0,n.__decorate)([u.autobind],f.prototype,"showConversationActionsMenu",null),(0,n.__decorate)([u.autobind],f.prototype,"showRenamePrompt",null),(0,n.__decorate)([(0,u.watch)("state.currentConversation")],f.prototype,"onChangeCurrentConversation",null),(0,n.__decorate)([(0,u.watch)("state.conversations")],f.prototype,"onChangeConversations",null),(0,n.__decorate)([(0,u.watch)("state.selectionContexts")],f.prototype,"onChangeSelectionContexts",null),(0,n.__decorate)([(0,u.watch)("state.isLoading")],f.prototype,"onChangeLoading",null),(0,n.__decorate)([(0,u.watch)("state.pendingToolCalls")],f.prototype,"onChangePendingToolCalls",null),f=(0,n.__decorate)([u.component],f)},81835:function(e,t,s){"use strict";s.d(t,{UIArtifact:function(){return l}});var i=s(82749),n=s(31635),r=s(65478),a=s(29960),o=s(67510);class l extends o.UIElement{className(){return"UIArtifact"}onReady(){this.renderArtifact()}renderArtifact(){let e=this.container;e.innerHTML="",(0,a.attr)(e,{"data-type":this.artifact.type,"data-status":this.artifact.status});let t=this.createStatusIndicator();if(e.appendChild(t),"pending"===this.artifact.status||"generating"===this.artifact.status)return void this.renderLoading();if("failed"===this.artifact.status)return void this.renderError();switch(this.artifact.type){case"image":this.renderImage();break;case"audio":this.renderAudio();break;case"file":this.renderFile();break;case"json":this.renderJSON();break;default:this.renderOther()}}createStatusIndicator(){let e=this.j.c.div(this.getFullElName("status"));e.setAttribute("data-status",this.artifact.status);let t=this.j.c.span(this.getFullElName("status-icon")),s=this.j.c.span(this.getFullElName("status-text"));switch(this.artifact.status){case"pending":t.textContent="⏳",s.textContent=this.j.i18n("Pending");break;case"generating":t.textContent="🔄",s.textContent=this.j.i18n("Generating...");break;case"ready":t.textContent="✅",s.textContent=this.j.i18n("Ready");break;case"failed":t.textContent="❌",s.textContent=this.j.i18n("Failed")}return e.appendChild(t),e.appendChild(s),e}renderLoading(){let e=this.j.c.div(this.getFullElName("loader")),t=this.j.c.div(this.getFullElName("spinner")),s=this.j.c.div(this.getFullElName("loader-message"));s.textContent=this.j.i18n("Generating artifact..."),e.appendChild(t),e.appendChild(s),this.container.appendChild(e)}renderError(){let e=this.j.c.div(this.getFullElName("error")),t=this.j.c.div(this.getFullElName("error-icon"));t.textContent="❌";let s=this.j.c.div(this.getFullElName("error-message"));s.textContent=this.artifact.metadata?.error||this.j.i18n("Failed to generate artifact"),e.appendChild(t),e.appendChild(s),this.container.appendChild(e)}renderImage(){if(!this.artifact.data)return;let e=this.j.c.div(this.getFullElName("content")),t=this.j.c.element("img",{class:this.getFullElName("image")});if("url"===this.artifact.data.kind)t.src=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"image/png";t.src=`data:${e};base64,${this.artifact.data.base64}`}if(t.alt=this.artifact.metadata?.alt||"AI Generated Image",e.appendChild(t),this.artifact.metadata?.caption){let t=this.j.c.div(this.getFullElName("caption"));t.textContent=this.artifact.metadata.caption,e.appendChild(t)}this.container.appendChild(e)}renderAudio(){if(!this.artifact.data)return;let e=this.j.c.div(this.getFullElName("content")),t=this.j.c.element("audio",{class:this.getFullElName("audio"),controls:"controls"});if("url"===this.artifact.data.kind)t.src=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"audio/mpeg";t.src=`data:${e};base64,${this.artifact.data.base64}`}e.appendChild(t),this.container.appendChild(e)}renderFile(){if(!this.artifact.data)return;let e=this.j.c.div(this.getFullElName("content")),t=this.j.c.div(this.getFullElName("file-card")),s=this.j.c.div(this.getFullElName("file-icon"));s.textContent="📄";let i=this.j.c.div(this.getFullElName("file-info")),n=this.j.c.div(this.getFullElName("file-name"));n.textContent=this.artifact.metadata?.filename||"download.file";let r=this.j.c.div(this.getFullElName("file-size"));this.artifact.metadata?.size&&(r.textContent=this.formatFileSize(this.artifact.metadata.size)),i.appendChild(n),i.appendChild(r);let a=this.j.c.element("a",{class:this.getFullElName("download-btn"),download:this.artifact.metadata?.filename||"download.file"});if(a.textContent=this.j.i18n("Download"),"url"===this.artifact.data.kind)a.href=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"application/octet-stream";a.href=`data:${e};base64,${this.artifact.data.base64}`}t.appendChild(s),t.appendChild(i),t.appendChild(a),e.appendChild(t),this.container.appendChild(e)}renderJSON(){let e;if(!this.artifact.data)return;let t=this.j.c.div(this.getFullElName("content")),s=this.j.c.element("pre",{class:this.getFullElName("json")}),i=this.j.c.element("code");if("url"===this.artifact.data.kind)i.textContent=this.j.i18n("JSON data at URL");else if("base64"===this.artifact.data.kind)try{let t=atob(this.artifact.data.base64);e=JSON.parse(t),i.textContent=JSON.stringify(e,null,2)}catch(e){i.textContent=this.j.i18n("Invalid JSON data")}s.appendChild(i),t.appendChild(s),this.container.appendChild(t)}renderOther(){let e=this.j.c.div(this.getFullElName("content")),t=this.j.c.div(this.getFullElName("placeholder")),s=this.j.c.div(this.getFullElName("placeholder-icon"));s.textContent="📦";let i=this.j.c.div(this.getFullElName("placeholder-text"));i.textContent=this.j.i18n("Unknown artifact type"),t.appendChild(s),t.appendChild(i),e.appendChild(t),this.container.appendChild(e)}formatFileSize(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(2)} KB`:e<0x40000000?`${(e/1048576).toFixed(2)} MB`:`${(e/0x40000000).toFixed(2)} GB`}updateArtifact(e){this.artifact=e,this.renderArtifact()}constructor(e,t){super(e),(0,i._)(this,"artifact",void 0),this.artifact=t}}(0,n.__decorate)([(0,r.hook)("ready")],l.prototype,"onReady",null),l=(0,n.__decorate)([r.component],l)},51359:function(e,t,s){"use strict";s.d(t,{UIMessageListItem:function(){return d}});var i=s(82749),n=s(31635),r=s(81835),a=s(65478),o=s(67510),l=s(62843),c=s(62405),h=s(12153),u=s(80870);class d extends o.UIElement{className(){return"UIMessageListItem"}render(){return`<div class="${this.getFullElName("message")}"></div>`}onReady(){this.updateContent(),this.contextMenu=new u.ContextMenu(this.j)}updateContent(){let e=this.container;e.innerHTML="",e.setAttribute("data-message-id",this.message.id),e.setAttribute("data-role",this.message.role);let t=this.j.c.div(this.getFullElName("message-bubble"));t.classList.add(this.getFullElName("message-bubble",this.message.role,!0));let s=this.j.c.div(this.getFullElName("message-content"));if(s.innerHTML=this.formatMessageContent(this.message.content),t.appendChild(s),this.opts.showTimestamps){let e=this.j.c.div(this.getFullElName("message-timestamp"));e.textContent=this.formatTimestamp(this.message.timestamp),t.appendChild(e)}let i=this.j.c.div(this.getFullElName("message-actions"));if(this.renderActionsButton(i),t.appendChild(i),e.appendChild(t),this.message.toolCalls&&this.message.toolCalls.length>0){let t=this.j.c.div(this.getFullElName("tool-calls"));e.appendChild(t),this.message.toolCalls.forEach(e=>{let s=this.createToolCallElement(e);t.appendChild(s)})}this.message.artifacts&&this.message.artifacts.length>0&&this.renderArtifacts()}renderActionsButton(e){let t=this.opts;(t.showCopyMessageAction||t.showRestartMessageAction||t.showEditMessageAction||t.showDeleteMessageAction)&&(this.actionsButton=new l.UIButton(this.j,{icon:{name:"dots"},tooltip:"Message actions",name:"messageActions",size:"tiny"}),this.actionsButton.onAction(e=>{this.showActionsMenu(e)}),e.appendChild(this.actionsButton.container))}showActionsMenu(e){if(!this.contextMenu||!this.actionsButton)return;let t=this.j,s=t.o.aiAssistantPro,i=[];s.showCopyMessageAction&&i.push({title:"Copy message",icon:"copy",exec:()=>{this.j.e.fire("copyMessage.ai-assistant-pro",this.message.id)}}),"user"===this.message.role&&(s.showRestartMessageAction&&i.push({title:"Restart from here",icon:"update",exec:()=>{this.j.e.fire("restartFromMessage.ai-assistant-pro",this.message.id)}}),s.showEditMessageAction&&i.push({title:"Edit message",icon:"pencil",exec:()=>{this.j.e.fire("editMessage.ai-assistant-pro",this.message.id)}})),s.showDeleteMessageAction&&i.push({title:"Delete message",icon:"bin",exec:()=>{t.confirm("Are you sure you want to delete this message?","Delete message",e=>{e&&this.j.e.fire("deleteMessage.ai-assistant-pro",this.message.id)})}});let n=this.actionsButton.container.getBoundingClientRect();this.contextMenu.show(n.left,n.bottom,i),e.stopPropagation()}renderArtifacts(){if(!this.message.artifacts||0===this.message.artifacts.length)return;let e=this.j.c.div(this.getFullElName("artifacts"));this.container.appendChild(e),this.artifactGroup||(this.artifactGroup=new c.UIGroup(this.j),this.artifactGroup.container.className="jodit-ui-artifact-group"),this.artifactGroup.clear(),this.message.artifacts.forEach(e=>{let t=new r.UIArtifact(this.j,e);this.artifactGroup.append(t)}),e.appendChild(this.artifactGroup.container)}createToolCallElement(e){let t=this.j.c.div(this.getFullElName("tool-call"));t.setAttribute("data-tool-id",e.id),t.setAttribute("data-status",e.status);let s=this.j.c.div(this.getFullElName("tool-header")),i=this.j.c.div(this.getFullElName("tool-icon"));i.classList.add(this.getFullElName("tool-icon",e.status,!0)),i.innerHTML=h.Icon.get("tool-bolt")||"";let n=this.j.c.div(this.getFullElName("tool-name"));n.textContent=this.j.i18n(e.name);let r=this.j.c.div(this.getFullElName("tool-status"));r.textContent=this.getToolStatusText(e.status||"unknown"),s.appendChild(i),s.appendChild(n),s.appendChild(r),t.appendChild(s);let a=this.createExpandableSection("Arguments",JSON.stringify(e.arguments||{},null,2));if(t.appendChild(a),e.result){let s=e.result.error?"Error: "+e.result.error:e.result.result||"",i=this.createExpandableSection("Result","string"==typeof s?s:JSON.stringify(s,null,2));t.appendChild(i)}return t}createExpandableSection(e,t){let s=this.j.c.div(this.getFullElName("tool-expandable")),i=this.j.c.element("button",{type:"button",class:this.getFullElName("tool-expandable-toggle")}),n=this.j.c.span(this.getFullElName("tool-expandable-chevron"));n.innerHTML=h.Icon.get("chevron-right")||"";let r=this.j.c.span();r.textContent=this.j.i18n(e),i.appendChild(n),i.appendChild(r);let a=this.j.c.element("pre",{class:this.getFullElName("tool-expandable-content")});return a.textContent=t,a.style.display="none",this.j.e.on(i,"click",()=>{"none"!==a.style.display?(a.style.display="none",i.classList.remove("expanded")):(a.style.display="block",i.classList.add("expanded"))}),s.appendChild(i),s.appendChild(a),s}getToolStatusText(e){return({pending:"pending",approved:"approved",denied:"denied",executing:"running",executed:"done",error:"error"})[e]||e}formatMessageContent(e){return(0,this.opts.formatMessageContent)(e,this.message.role,this.j.i18n.bind(this.j))}formatTimestamp(e){return(0,this.opts.formatTimestamp)(e,this.j.i18n.bind(this.j))}updateMessage(e){this.message=e,this.updateContent()}destruct(){this.actionsButton?.destruct(),this.contextMenu?.destruct(),this.artifactGroup?.destruct(),super.destruct()}constructor(e,t,s){super(e),(0,i._)(this,"message",void 0),(0,i._)(this,"opts",void 0),(0,i._)(this,"artifactGroup",void 0),(0,i._)(this,"actionsButton",void 0),(0,i._)(this,"contextMenu",void 0),this.message=t,this.opts=s,this.artifactGroup=null,this.actionsButton=null,this.contextMenu=null}}(0,n.__decorate)([(0,a.hook)("ready")],d.prototype,"onReady",null),d=(0,n.__decorate)([a.component],d)},86563:function(e,t,s){"use strict";s.d(t,{UIMessageList:function(){return c}});var i=s(82749),n=s(31635),r=s(51359),a=s(65478),o=s(62405),l=s(31356);class c extends o.UIGroup{className(){return"UIMessageList"}render(){return'<div class="&__scroll-container"></div>'}afterRender(){this.scrollContainer=this.container}onUserScroll(){if(!this.scrollContainer)return;let{scrollTop:e,scrollHeight:t,clientHeight:s}=this.scrollContainer;this.autoScrollEnabled=t-e-s<10}onMessageSent(){this.autoScrollEnabled=!0,this.scrollToBottom()}appendChildToContainer(e){this.scrollContainer&&this.scrollContainer.appendChild(e)}setMessages(e){let t=this.messages.slice();this.messages=e.slice(),this.updateMessageList(t),this.scrollToBottom()}updateMessageList(e){let t=l.ListReconciler.reconcile(e,this.messages,{getId:e=>e.id,isEqual:(e,t)=>e.id===t.id&&e.content===t.content&&e.timestamp===t.timestamp&&JSON.stringify(e.artifacts)===JSON.stringify(t.artifacts)&&JSON.stringify(e.toolCalls)===JSON.stringify(t.toolCalls),preserveOrder:!0});t.toRemove.forEach(e=>{let t=this.messageItems.get(e.id);t&&(-1!==this.elements.indexOf(t)&&(this.remove(t),t.destruct()),this.messageItems.delete(e.id))}),t.toUpdate.forEach(({newItem:e,index:t})=>{let s=this.messageItems.get(e.id);s&&(s.updateMessage(e),this.elements.indexOf(s)!==t&&t<this.elements.length&&(this.remove(s),this.append(s,t)))}),t.toCreate.forEach(e=>{let t=new r.UIMessageListItem(this.j,e,this.params);this.messageItems.set(e.id,t);let s=this.messages.indexOf(e);this.append(t,s)})}scrollToBottom(){!this.j.isDestructed&&this.autoScrollEnabled&&(this.container.scrollTop=this.container.scrollHeight)}destruct(){this.messageItems.clear(),this.messages=[],super.destruct()}constructor(e,t){super(e),(0,i._)(this,"params",void 0),(0,i._)(this,"messages",void 0),(0,i._)(this,"messageItems",void 0),(0,i._)(this,"scrollContainer",void 0),(0,i._)(this,"autoScrollEnabled",void 0),this.params=t,this.messages=[],this.messageItems=new Map,this.autoScrollEnabled=!0}}(0,n.__decorate)([(0,a.hook)("ready")],c.prototype,"afterRender",null),(0,n.__decorate)([(0,a.watch)(["scrollContainer:wheel","scrollContainer:scroll","scrollContainer:touchmove"]),(0,a.throttle)(e=>e.defaultTimeout)],c.prototype,"onUserScroll",null),(0,n.__decorate)([(0,a.watch)(":messageSent.ai-assistant-pro")],c.prototype,"onMessageSent",null),(0,n.__decorate)([a.autobind],c.prototype,"setMessages",null),(0,n.__decorate)([(0,a.throttle)(e=>2*e.defaultTimeout)],c.prototype,"scrollToBottom",null),c=(0,n.__decorate)([a.component],c)},93677:function(e,t,s){"use strict";s.d(t,{UIPermissionRequest:function(){return h}});var i=s(82749),n=s(31635),r=s(65478),a=s(67510),o=s(62843),l=s(12234),c=s(12153);class h extends a.UIElement{className(){return"UIPermissionRequest"}setToolCall(e){this.toolCall=e,this.updateContent()}setParentView(e){return this.scopeSelect?.setParentView(e),this.approveButton?.setParentView(e),this.denyButton?.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
38
+ </div>`}addResize(){}afterRender(){this.content=this.getElm("content"),this.headerContextMenu=new m.ContextMenu(this.j),this.createComponents(),this.createHeaderButtons(),this.setupConversationRenameHandler(),this.__updateView("welcome")}async __onChangeView(){this.__updateView(this.state.currentView,this.state.currentConversation)}createComponents(){this.welcomeScreen=new h.UIWelcomeScreen(this.j),this.conversationList=new a.UIConversationList(this.j,this.options),this.messageList=new o.UIMessageList(this.j,this.options),this.inputArea=new r.UIInputArea(this.j,this.options),this.getElm("footer").appendChild(this.inputArea.container)}createHeaderButtons(){let e=this.getElm("header-left"),t=this.getElm("header-right"),s=new g.UIButton(this.j,{icon:{name:"angle-left"},size:"small",variant:"initial"});s.container.classList.add(this.getFullElName("back-button")),this.j.e.on(s,"click",()=>{this.j.e.fire("backToList.ai-assistant-pro")}),e.appendChild(s.container),this.conversationActionsButton=new g.UIButton(this.j,{icon:{name:"dots"},size:"small",tooltip:"Conversation actions",variant:"initial"}),this.conversationActionsButton.container.classList.add(this.getFullElName("conversation-actions-button")),this.conversationActionsButton.onAction(this.showConversationActionsMenu),t.appendChild(this.conversationActionsButton.container);let i=new g.UIButton(this.j,{icon:{name:"plus"},size:"small",tooltip:"New chat",variant:"initial"});if(i.container.classList.add(this.getFullElName("new-button")),this.j.e.on(i,"click",()=>{this.j.e.fire("newConversation.ai-assistant-pro")}),t.appendChild(i.container),this.shouldShowSettings()&&(this.settingsButton=new c.UISettingsButton(this.j,this.state,this.options,()=>this.state.currentConversation,this.updateConversation),this.settingsButton.container.classList.add(this.getFullElName("settings-button")),t.appendChild(this.settingsButton.container)),"dialog"===this.mods.displayMode||!1===this.mods.allowClose)return;let n=new g.UIButton(this.j,{icon:{name:"cancel"},size:"small",tooltip:"Close",variant:"initial"});n.container.classList.add(this.getFullElName("close-button")),this.j.e.on(n,"click",()=>{this.j.e.fire("closeAIAssistantPro.ai-assistant-pro")}),t.appendChild(n.container)}setupConversationRenameHandler(){}showConversationActionsMenu(e){if(!this.headerContextMenu||!this.state.currentConversation)return;let t=this.state.currentConversation,s=[{title:"Rename",icon:"pencil",exec:()=>{this.showRenamePrompt(t.id,t.title||this.j.i18n("Conversation"))}},{title:"Delete",icon:"bin",exec:()=>{this.j.e.fire("deleteConversation.ai-assistant-pro",t.id)}}],i=this.conversationActionsButton.container.getBoundingClientRect();this.headerContextMenu.show(i.left,i.bottom,s),e.stopPropagation()}showRenamePrompt(e,t){if(this.isEditingTitle)return;this.isEditingTitle=!0;let s=this.getElm("header-title"),i=this.j.c.element("input");i.type="text",i.value=t,i.className=this.getFullElName("header-title-input"),s.textContent="",s.appendChild(i),i.focus(),i.select();let n=()=>{let n=i.value.trim();this.isEditingTitle=!1,n&&n!==t?(this.j.e.fire("renameConversation.ai-assistant-pro",e,n),s.textContent=n):s.textContent=t};this.j.e.on(i,"blur",n),this.j.e.on(i,"keydown",e=>{"Enter"===e.key&&(e.preventDefault(),i.blur()),"Escape"===e.key&&(this.isEditingTitle=!1,s.textContent=t)})}isFlightMode(){return"flight"===this.mods.displayMode}shouldShowSettings(){let e=this.options,t=e.allowEditDisplayMode||e.allowEditPanelWidth,s=e.allowEditDialogSettings;return t||s}__updateView(e,t=null){this.settingsButton?.update();let s=this.getElm("header-title");this.setMod("view",e);let i=this.isFlightMode();switch(e){case"welcome":s.textContent=this.j.i18n("AI Assistant"),d.Dom.safeRemove(this.conversationList.container),d.Dom.safeRemove(this.messageList.container),this.content.appendChild(this.welcomeScreen.container),this.inputArea.focus();break;case"conversationList":s.textContent=this.j.i18n("AI Assistant"),d.Dom.safeRemove(this.welcomeScreen.container),d.Dom.safeRemove(this.messageList.container),this.conversationList.container.isConnected||this.content.appendChild(this.conversationList.container);break;case"conversation":s.textContent=i?this.j.i18n("AI Assistant"):t?.title||this.j.i18n("Conversation"),d.Dom.safeRemove(this.welcomeScreen.container),d.Dom.safeRemove(this.conversationList.container),this.messageList.container.isConnected||this.content.appendChild(this.messageList.container),t&&this.messageList.setMessages(t.messages),this.inputArea.focus()}}onChangeCurrentConversation(){let{currentConversation:e}=this.state;e&&(this.conversationList.setActiveConversation(e.id),this.messageList.setMessages(e.messages))}onChangeConversations(){this.conversationList.setConversations(this.state.conversations)}onChangeSelectionContexts(){this.inputArea.setContexts(this.state.selectionContexts)}onChangeLoading(){this.inputArea.setLoading(this.state.isLoading)}onChangePendingToolCalls(){this.state.pendingToolCalls&&this.state.pendingToolCalls.length>0?this.showPermissionRequest(this.state.pendingToolCalls[0]):this.hidePermissionRequest()}showPermissionRequest(e){this.permissionRequest||(this.permissionRequest=new l.UIPermissionRequest(this.j,this.options)),this.permissionRequest.setToolCall(e);let t=this.getElm("footer");t.contains(this.permissionRequest.container)||t.insertBefore(this.permissionRequest.container,this.inputArea.container)}hidePermissionRequest(){this.permissionRequest&&this.permissionRequest.container.parentNode&&this.permissionRequest.container.parentNode.removeChild(this.permissionRequest.container)}destruct(){this.welcomeScreen?.destruct(),this.conversationList?.destruct(),this.messageList?.destruct(),this.inputArea?.destruct(),this.permissionRequest?.destruct(),this.settingsButton?.destruct(),this.conversationActionsButton?.destruct(),this.headerContextMenu?.destruct(),super.destruct()}constructor(e,t,s,n){super(e),(0,i._)(this,"state",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"updateConversation",void 0),(0,i._)(this,"permissionRequest",void 0),(0,i._)(this,"settingsButton",void 0),(0,i._)(this,"content",void 0),(0,i._)(this,"isEditingTitle",void 0),(0,i._)(this,"conversationActionsButton",void 0),(0,i._)(this,"headerContextMenu",void 0),this.state=t,this.options=s,this.updateConversation=n,this.permissionRequest=null,this.settingsButton=null,this.isEditingTitle=!1,this.conversationActionsButton=null,this.headerContextMenu=null}}(0,n.__decorate)([(0,u.hook)("ready")],f.prototype,"afterRender",null),(0,n.__decorate)([(0,u.watch)(["state.currentView","state.currentConversation"])],f.prototype,"__onChangeView",null),(0,n.__decorate)([u.autobind],f.prototype,"showConversationActionsMenu",null),(0,n.__decorate)([u.autobind],f.prototype,"showRenamePrompt",null),(0,n.__decorate)([(0,u.watch)("state.currentConversation")],f.prototype,"onChangeCurrentConversation",null),(0,n.__decorate)([(0,u.watch)("state.conversations")],f.prototype,"onChangeConversations",null),(0,n.__decorate)([(0,u.watch)("state.selectionContexts")],f.prototype,"onChangeSelectionContexts",null),(0,n.__decorate)([(0,u.watch)("state.isLoading")],f.prototype,"onChangeLoading",null),(0,n.__decorate)([(0,u.watch)("state.pendingToolCalls")],f.prototype,"onChangePendingToolCalls",null),f=(0,n.__decorate)([u.component],f)},81835:function(e,t,s){"use strict";s.d(t,{UIArtifact:function(){return l}});var i=s(82749),n=s(31635),a=s(65478),r=s(29960),o=s(67510);class l extends o.UIElement{className(){return"UIArtifact"}onReady(){this.renderArtifact()}renderArtifact(){let e=this.container;e.innerHTML="",(0,r.attr)(e,{"data-type":this.artifact.type,"data-status":this.artifact.status});let t=this.createStatusIndicator();if(e.appendChild(t),"pending"===this.artifact.status||"generating"===this.artifact.status)return void this.renderLoading();if("failed"===this.artifact.status)return void this.renderError();switch(this.artifact.type){case"image":this.renderImage();break;case"audio":this.renderAudio();break;case"file":this.renderFile();break;case"json":this.renderJSON();break;default:this.renderOther()}}createStatusIndicator(){let e=this.j.c.div(this.getFullElName("status"));e.setAttribute("data-status",this.artifact.status);let t=this.j.c.span(this.getFullElName("status-icon")),s=this.j.c.span(this.getFullElName("status-text"));switch(this.artifact.status){case"pending":t.textContent="⏳",s.textContent=this.j.i18n("Pending");break;case"generating":t.textContent="🔄",s.textContent=this.j.i18n("Generating...");break;case"ready":t.textContent="✅",s.textContent=this.j.i18n("Ready");break;case"failed":t.textContent="❌",s.textContent=this.j.i18n("Failed")}return e.appendChild(t),e.appendChild(s),e}renderLoading(){let e=this.j.c.div(this.getFullElName("loader")),t=this.j.c.div(this.getFullElName("spinner")),s=this.j.c.div(this.getFullElName("loader-message"));s.textContent=this.j.i18n("Generating artifact..."),e.appendChild(t),e.appendChild(s),this.container.appendChild(e)}renderError(){let e=this.j.c.div(this.getFullElName("error")),t=this.j.c.div(this.getFullElName("error-icon"));t.textContent="❌";let s=this.j.c.div(this.getFullElName("error-message"));s.textContent=this.artifact.metadata?.error||this.j.i18n("Failed to generate artifact"),e.appendChild(t),e.appendChild(s),this.container.appendChild(e)}renderImage(){if(!this.artifact.data)return;let e=this.j.c.div(this.getFullElName("content")),t=this.j.c.element("img",{class:this.getFullElName("image")});if("url"===this.artifact.data.kind)t.src=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"image/png";t.src=`data:${e};base64,${this.artifact.data.base64}`}if(t.alt=this.artifact.metadata?.alt||"AI Generated Image",e.appendChild(t),this.artifact.metadata?.caption){let t=this.j.c.div(this.getFullElName("caption"));t.textContent=this.artifact.metadata.caption,e.appendChild(t)}this.container.appendChild(e)}renderAudio(){if(!this.artifact.data)return;let e=this.j.c.div(this.getFullElName("content")),t=this.j.c.element("audio",{class:this.getFullElName("audio"),controls:"controls"});if("url"===this.artifact.data.kind)t.src=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"audio/mpeg";t.src=`data:${e};base64,${this.artifact.data.base64}`}e.appendChild(t),this.container.appendChild(e)}renderFile(){if(!this.artifact.data)return;let e=this.j.c.div(this.getFullElName("content")),t=this.j.c.div(this.getFullElName("file-card")),s=this.j.c.div(this.getFullElName("file-icon"));s.textContent="📄";let i=this.j.c.div(this.getFullElName("file-info")),n=this.j.c.div(this.getFullElName("file-name"));n.textContent=this.artifact.metadata?.filename||"download.file";let a=this.j.c.div(this.getFullElName("file-size"));this.artifact.metadata?.size&&(a.textContent=this.formatFileSize(this.artifact.metadata.size)),i.appendChild(n),i.appendChild(a);let r=this.j.c.element("a",{class:this.getFullElName("download-btn"),download:this.artifact.metadata?.filename||"download.file"});if(r.textContent=this.j.i18n("Download"),"url"===this.artifact.data.kind)r.href=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"application/octet-stream";r.href=`data:${e};base64,${this.artifact.data.base64}`}t.appendChild(s),t.appendChild(i),t.appendChild(r),e.appendChild(t),this.container.appendChild(e)}renderJSON(){let e;if(!this.artifact.data)return;let t=this.j.c.div(this.getFullElName("content")),s=this.j.c.element("pre",{class:this.getFullElName("json")}),i=this.j.c.element("code");if("url"===this.artifact.data.kind)i.textContent=this.j.i18n("JSON data at URL");else if("base64"===this.artifact.data.kind)try{let t=atob(this.artifact.data.base64);e=JSON.parse(t),i.textContent=JSON.stringify(e,null,2)}catch(e){i.textContent=this.j.i18n("Invalid JSON data")}s.appendChild(i),t.appendChild(s),this.container.appendChild(t)}renderOther(){let e=this.j.c.div(this.getFullElName("content")),t=this.j.c.div(this.getFullElName("placeholder")),s=this.j.c.div(this.getFullElName("placeholder-icon"));s.textContent="📦";let i=this.j.c.div(this.getFullElName("placeholder-text"));i.textContent=this.j.i18n("Unknown artifact type"),t.appendChild(s),t.appendChild(i),e.appendChild(t),this.container.appendChild(e)}formatFileSize(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(2)} KB`:e<0x40000000?`${(e/1048576).toFixed(2)} MB`:`${(e/0x40000000).toFixed(2)} GB`}updateArtifact(e){this.artifact=e,this.renderArtifact()}constructor(e,t){super(e),(0,i._)(this,"artifact",void 0),this.artifact=t}}(0,n.__decorate)([(0,a.hook)("ready")],l.prototype,"onReady",null),l=(0,n.__decorate)([a.component],l)},51359:function(e,t,s){"use strict";s.d(t,{UIMessageListItem:function(){return d}});var i=s(82749),n=s(31635),a=s(81835),r=s(65478),o=s(67510),l=s(62843),c=s(62405),h=s(12153),u=s(80870);class d extends o.UIElement{className(){return"UIMessageListItem"}render(){return`<div class="${this.getFullElName("message")}"></div>`}onReady(){this.updateContent(),this.contextMenu=new u.ContextMenu(this.j)}updateContent(){let e=this.container;e.innerHTML="",e.setAttribute("data-message-id",this.message.id),e.setAttribute("data-role",this.message.role);let t=this.j.c.div(this.getFullElName("message-bubble"));t.classList.add(this.getFullElName("message-bubble",this.message.role,!0));let s=this.j.c.div(this.getFullElName("message-content"));if(s.innerHTML=this.formatMessageContent(this.message.content),t.appendChild(s),this.opts.showTimestamps){let e=this.j.c.div(this.getFullElName("message-timestamp"));e.textContent=this.formatTimestamp(this.message.timestamp),t.appendChild(e)}let i=this.j.c.div(this.getFullElName("message-actions"));if(this.renderActionsButton(i),t.appendChild(i),e.appendChild(t),this.message.toolCalls&&this.message.toolCalls.length>0){let t=this.j.c.div(this.getFullElName("tool-calls"));e.appendChild(t),this.message.toolCalls.forEach(e=>{let s=this.createToolCallElement(e);t.appendChild(s)})}this.message.artifacts&&this.message.artifacts.length>0&&this.renderArtifacts()}renderActionsButton(e){let t=this.opts;(t.showCopyMessageAction||t.showRestartMessageAction||t.showEditMessageAction||t.showDeleteMessageAction)&&(this.actionsButton=new l.UIButton(this.j,{icon:{name:"dots"},tooltip:"Message actions",name:"messageActions",size:"tiny"}),this.actionsButton.onAction(e=>{this.showActionsMenu(e)}),e.appendChild(this.actionsButton.container))}showActionsMenu(e){if(!this.contextMenu||!this.actionsButton)return;let t=this.j,s=t.o.aiAssistantPro,i=[];s.showCopyMessageAction&&i.push({title:"Copy message",icon:"copy",exec:()=>{this.j.e.fire("copyMessage.ai-assistant-pro",this.message.id)}}),"user"===this.message.role&&(s.showRestartMessageAction&&i.push({title:"Restart from here",icon:"update",exec:()=>{this.j.e.fire("restartFromMessage.ai-assistant-pro",this.message.id)}}),s.showEditMessageAction&&i.push({title:"Edit message",icon:"pencil",exec:()=>{this.j.e.fire("editMessage.ai-assistant-pro",this.message.id)}})),s.showDeleteMessageAction&&i.push({title:"Delete message",icon:"bin",exec:()=>{t.confirm("Are you sure you want to delete this message?","Delete message",e=>{e&&this.j.e.fire("deleteMessage.ai-assistant-pro",this.message.id)})}});let n=this.actionsButton.container.getBoundingClientRect();this.contextMenu.show(n.left,n.bottom,i),e.stopPropagation()}renderArtifacts(){if(!this.message.artifacts||0===this.message.artifacts.length)return;let e=this.j.c.div(this.getFullElName("artifacts"));this.container.appendChild(e),this.artifactGroup||(this.artifactGroup=new c.UIGroup(this.j),this.artifactGroup.container.className="jodit-ui-artifact-group"),this.artifactGroup.clear(),this.message.artifacts.forEach(e=>{let t=new a.UIArtifact(this.j,e);this.artifactGroup.append(t)}),e.appendChild(this.artifactGroup.container)}createToolCallElement(e){let t=this.j.c.div(this.getFullElName("tool-call"));t.setAttribute("data-tool-id",e.id),t.setAttribute("data-status",e.status);let s=this.j.c.div(this.getFullElName("tool-header")),i=this.j.c.div(this.getFullElName("tool-icon"));i.classList.add(this.getFullElName("tool-icon",e.status,!0)),i.innerHTML=h.Icon.get("tool-bolt")||"";let n=this.j.c.div(this.getFullElName("tool-name"));n.textContent=this.j.i18n(e.name);let a=this.j.c.div(this.getFullElName("tool-status"));a.textContent=this.getToolStatusText(e.status||"unknown"),s.appendChild(i),s.appendChild(n),s.appendChild(a),t.appendChild(s);let r=this.createExpandableSection("Arguments",JSON.stringify(e.arguments||{},null,2));if(t.appendChild(r),e.result){let s=e.result.error?"Error: "+e.result.error:e.result.result||"",i=this.createExpandableSection("Result","string"==typeof s?s:JSON.stringify(s,null,2));t.appendChild(i)}return t}createExpandableSection(e,t){let s=this.j.c.div(this.getFullElName("tool-expandable")),i=this.j.c.element("button",{type:"button",class:this.getFullElName("tool-expandable-toggle")}),n=this.j.c.span(this.getFullElName("tool-expandable-chevron"));n.innerHTML=h.Icon.get("chevron-right")||"";let a=this.j.c.span();a.textContent=this.j.i18n(e),i.appendChild(n),i.appendChild(a);let r=this.j.c.element("pre",{class:this.getFullElName("tool-expandable-content")});return r.textContent=t,r.style.display="none",this.j.e.on(i,"click",()=>{"none"!==r.style.display?(r.style.display="none",i.classList.remove("expanded")):(r.style.display="block",i.classList.add("expanded"))}),s.appendChild(i),s.appendChild(r),s}getToolStatusText(e){return({pending:"pending",approved:"approved",denied:"denied",executing:"running",executed:"done",error:"error"})[e]||e}formatMessageContent(e){return(0,this.opts.formatMessageContent)(e,this.message.role,this.j.i18n.bind(this.j))}formatTimestamp(e){return(0,this.opts.formatTimestamp)(e,this.j.i18n.bind(this.j))}updateMessage(e){this.message=e,this.updateContent()}destruct(){this.actionsButton?.destruct(),this.contextMenu?.destruct(),this.artifactGroup?.destruct(),super.destruct()}constructor(e,t,s){super(e),(0,i._)(this,"message",void 0),(0,i._)(this,"opts",void 0),(0,i._)(this,"artifactGroup",void 0),(0,i._)(this,"actionsButton",void 0),(0,i._)(this,"contextMenu",void 0),this.message=t,this.opts=s,this.artifactGroup=null,this.actionsButton=null,this.contextMenu=null}}(0,n.__decorate)([(0,r.hook)("ready")],d.prototype,"onReady",null),d=(0,n.__decorate)([r.component],d)},86563:function(e,t,s){"use strict";s.d(t,{UIMessageList:function(){return c}});var i=s(82749),n=s(31635),a=s(51359),r=s(65478),o=s(62405),l=s(31356);class c extends o.UIGroup{className(){return"UIMessageList"}render(){return'<div class="&__scroll-container"></div>'}afterRender(){this.scrollContainer=this.container}onUserScroll(){if(!this.scrollContainer)return;let{scrollTop:e,scrollHeight:t,clientHeight:s}=this.scrollContainer;this.autoScrollEnabled=t-e-s<10}onMessageSent(){this.autoScrollEnabled=!0,this.scrollToBottom()}appendChildToContainer(e){this.scrollContainer&&this.scrollContainer.appendChild(e)}setMessages(e){let t=this.messages.slice();this.messages=e.slice(),this.updateMessageList(t),this.scrollToBottom()}updateMessageList(e){let t=l.ListReconciler.reconcile(e,this.messages,{getId:e=>e.id,isEqual:(e,t)=>e.id===t.id&&e.content===t.content&&e.timestamp===t.timestamp&&JSON.stringify(e.artifacts)===JSON.stringify(t.artifacts)&&JSON.stringify(e.toolCalls)===JSON.stringify(t.toolCalls),preserveOrder:!0});t.toRemove.forEach(e=>{let t=this.messageItems.get(e.id);t&&(-1!==this.elements.indexOf(t)&&(this.remove(t),t.destruct()),this.messageItems.delete(e.id))}),t.toUpdate.forEach(({newItem:e,index:t})=>{let s=this.messageItems.get(e.id);s&&(s.updateMessage(e),this.elements.indexOf(s)!==t&&t<this.elements.length&&(this.remove(s),this.append(s,t)))}),t.toCreate.forEach(e=>{let t=new a.UIMessageListItem(this.j,e,this.params);this.messageItems.set(e.id,t);let s=this.messages.indexOf(e);this.append(t,s)})}scrollToBottom(){!this.j.isDestructed&&this.autoScrollEnabled&&(this.container.scrollTop=this.container.scrollHeight)}destruct(){this.messageItems.clear(),this.messages=[],super.destruct()}constructor(e,t){super(e),(0,i._)(this,"params",void 0),(0,i._)(this,"messages",void 0),(0,i._)(this,"messageItems",void 0),(0,i._)(this,"scrollContainer",void 0),(0,i._)(this,"autoScrollEnabled",void 0),this.params=t,this.messages=[],this.messageItems=new Map,this.autoScrollEnabled=!0}}(0,n.__decorate)([(0,r.hook)("ready")],c.prototype,"afterRender",null),(0,n.__decorate)([(0,r.watch)(["scrollContainer:wheel","scrollContainer:scroll","scrollContainer:touchmove"]),(0,r.throttle)(e=>e.defaultTimeout)],c.prototype,"onUserScroll",null),(0,n.__decorate)([(0,r.watch)(":messageSent.ai-assistant-pro")],c.prototype,"onMessageSent",null),(0,n.__decorate)([r.autobind],c.prototype,"setMessages",null),(0,n.__decorate)([(0,r.throttle)(e=>2*e.defaultTimeout)],c.prototype,"scrollToBottom",null),c=(0,n.__decorate)([r.component],c)},93677:function(e,t,s){"use strict";s.d(t,{UIPermissionRequest:function(){return h}});var i=s(82749),n=s(31635),a=s(65478),r=s(67510),o=s(62843),l=s(12234),c=s(12153);class h extends r.UIElement{className(){return"UIPermissionRequest"}setToolCall(e){this.toolCall=e,this.updateContent()}setParentView(e){return this.scopeSelect?.setParentView(e),this.approveButton?.setParentView(e),this.denyButton?.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
39
39
  <div class="&__header">
40
40
  <div class="&__icon"></div>
41
41
  <div class="&__title">~Permission Required~</div>
@@ -48,12 +48,12 @@ ${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQ
48
48
  </div>`}afterRender(){let e=this.getElm("icon");e&&(e.innerHTML=c.Icon.get("shield")||""),this.createControls(),this.updateContent()}createControls(){let e=this.getElm("actions-buttons"),t=this.getElm("actions-scope");this.denyButton=new o.UIButton(this.j,{text:this.j.i18n("Deny"),variant:"initial",size:"small",name:"deny-permission"}),this.j.e.on(this.denyButton,"click",this.onDeny),this.approveButton=new o.UIButton(this.j,{text:this.j.i18n("Allow"),variant:"initial",size:"small",name:"approve-permission"}),this.j.e.on(this.approveButton,"click",this.onApprove),this.scopeSelect=new l.UISelect(this.j,{name:"permission-scope",options:[{value:"once",text:this.j.i18n("Once")},{value:"conversation",text:this.j.i18n("This conversation")},{value:"forever",text:this.j.i18n("Always")}]}),this.scopeSelect.value=this.state.defaultPermissionScope,e.appendChild(this.denyButton.container),e.appendChild(this.approveButton.container),t.appendChild(this.scopeSelect.container)}updateContent(){this.toolCall&&(this.getElm("tool-info").innerHTML=`
49
49
  <div class="${this.getFullElName("tool-name")}">${this.j.i18n(this.toolCall.name)}</div>
50
50
  <div class="${this.getFullElName("tool-args")}">${this.formatArguments(this.toolCall.arguments)}</div>
51
- `)}formatArguments(e){return Object.entries(e).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(", ")}onApprove(){let e=this.scopeSelect?.value;this.j.e.fire("approveToolCall.ai-assistant-pro",this.toolCall.id,e)}onDeny(){this.j.e.fire("denyToolCall.ai-assistant-pro",this.toolCall.id)}destruct(){this.scopeSelect?.destruct(),this.approveButton?.destruct(),this.denyButton?.destruct(),super.destruct()}constructor(e,t){super(e),(0,i._)(this,"state",void 0),(0,i._)(this,"toolCall",void 0),(0,i._)(this,"scopeSelect",void 0),(0,i._)(this,"approveButton",void 0),(0,i._)(this,"denyButton",void 0),this.state=t,this.scopeSelect=null,this.approveButton=null,this.denyButton=null}}(0,n.__decorate)([(0,r.hook)("ready")],h.prototype,"afterRender",null),(0,n.__decorate)([r.autobind],h.prototype,"onApprove",null),(0,n.__decorate)([r.autobind],h.prototype,"onDeny",null),h=(0,n.__decorate)([r.component],h)},48705:function(e,t,s){"use strict";s.d(t,{UISettingsButton:function(){return i.UISettingsButton}});var i=s(76697)},76697:function(e,t,s){"use strict";s.d(t,{UISettingsButton:function(){return h}});var i=s(82749),n=s(31635),r=s(79455),a=s(87325),o=s(37133),l=s(48538),c=s(78644);class h extends l.UIElement{className(){return"UISettingsButton"}setParentView(e){return this.settingsPopup?.setParentView(e),this.button?.setParentView(e),super.setParentView(e)}onChangeOptionsClosePopup(e){this.closeCallback()}openSettingsPopup(){return this.settingsPopup||(this.settingsPopup=new r.UISettingsPopup(this.jodit,this.extraState,this.options,this.getConversation,this.updateConversation)),this.settingsPopup.update(),this.settingsPopup}constructor(e,t,s,n,r){super(e),(0,i._)(this,"extraState",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"getConversation",void 0),(0,i._)(this,"updateConversation",void 0),(0,i._)(this,"closeCallback",void 0),(0,i._)(this,"settingsPopup",void 0),(0,i._)(this,"button",void 0),this.extraState=t,this.options=s,this.getConversation=n,this.updateConversation=r,this.closeCallback=()=>{},this.settingsPopup=null,this.button=new c.ToolbarButton(this.jodit,{name:"settings",tooltip:"Settings",popup:(e,t,s)=>(this.closeCallback=s,this.openSettingsPopup())}),this.button.state.variant="initial",this.button.state.size="small",this.container.appendChild(this.button.container)}}(0,n.__decorate)([(0,o.watch)("extraState.displayMode")],h.prototype,"onChangeOptionsClosePopup",null),h=(0,n.__decorate)([a.component],h)},16015:function(e,t,s){"use strict";s.d(t,{UIDialogSettings:function(){return c}});var i=s(82749),n=s(31635),r=s(65478),a=s(67510),o=s(12234),l=s(62357);class c extends a.UIElement{className(){return"UIDialogSettings"}setParentView(e){return this.modelSelect?.setParentView(e),this.temperatureInput?.setParentView(e),super.setParentView(e)}async build(){let e=this.container,t=this.getConversation().options||{};if(this.options.dialogSettings.models&&this.options.dialogSettings.models.length>0){let s=this.parseModels(this.options.dialogSettings.models),i=t.model??this.state.defaultModel??s[0].value;this.modelSelect=new o.UISelect(this.j,{label:"Model",name:"model",value:i,options:s,onChange:this.onModelChange.bind(this)}),e.appendChild(this.modelSelect.container)}if(this.options.dialogSettings.temperature){this.temperatureInput=new l.UIRange(this.j,{label:"Temperature",name:"temperature",min:this.options.dialogSettings.temperature.min,max:this.options.dialogSettings.temperature.max,value:t.temperature??this.state.defaultTemperature??.5,onChange:this.onTemperatureChange.bind(this)});let s=this.temperatureInput.nativeInput;s&&s.setAttribute("step",(this.options.dialogSettings.temperature.step??.1)+""),e.appendChild(this.temperatureInput.container)}}parseModels(e){return 0===e.length?[]:"object"==typeof e[0]&&"title"in e[0]?e.map(e=>({text:e.title,value:e.value})):e.map(e=>({text:e,value:e}))}async onModelChange(){if(!this.modelSelect)return;let e=this.modelSelect.value;this.updateConversation({options:{...this.getConversation().options,model:e}}),this.state.defaultModel=e}async onTemperatureChange(){if(!this.temperatureInput)return;let e=parseFloat(this.temperatureInput.value);this.updateConversation({options:{...this.getConversation().options,temperature:e}}),this.state.defaultTemperature=e}onDefaultModelChange(){this.modelSelect&&this.state.defaultModel&&(this.modelSelect.value=this.state.defaultModel)}onDefaultTemperatureChange(){this.temperatureInput&&void 0!==this.state.defaultTemperature&&(this.temperatureInput.value=this.state.defaultTemperature+"")}destruct(){this.modelSelect?.destruct(),super.destruct()}constructor(e,t,s,n,r){super(e),(0,i._)(this,"getConversation",void 0),(0,i._)(this,"updateConversation",void 0),(0,i._)(this,"state",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"modelSelect",void 0),(0,i._)(this,"temperatureInput",void 0),this.getConversation=t,this.updateConversation=s,this.state=n,this.options=r,this.modelSelect=null,this.temperatureInput=null,this.build()}}(0,n.__decorate)([(0,r.watch)("state.defaultModel")],c.prototype,"onDefaultModelChange",null),(0,n.__decorate)([(0,r.watch)("state.defaultTemperature")],c.prototype,"onDefaultTemperatureChange",null),c=(0,n.__decorate)([r.component],c)},71102:function(e,t,s){"use strict";s.d(t,{UIGlobalSettings:function(){return c}});var i=s(82749),n=s(31635),r=s(65478),a=s(67510),o=s(80256),l=s(12234);class c extends a.UIElement{className(){return"UIGlobalSettings"}setParentView(e){return this.displayModeSelect?.setParentView(e),this.panelWidthInput?.setParentView(e),this.themeSelect?.setParentView(e),super.setParentView(e)}async build(){let e=this.container;this.options.allowEditDisplayMode&&(this.displayModeSelect=new l.UISelect(this.j,{label:"Display Mode",name:"displayMode",value:this.state?.displayMode??"right",options:[{text:"Dialog",value:"dialog"},{text:"Flight",value:"flight"},{text:"Left",value:"left"},{text:"Right",value:"right"},{text:"Top",value:"top"},{text:"Bottom",value:"bottom"}],onChange:()=>{this.onDisplayModeChange()}}),e.appendChild(this.displayModeSelect.container)),this.options.allowEditPanelWidth&&(this.panelWidthInput=new o.UIInput(this.j,{label:"Panel Width",name:"panelWidth",type:"number",value:(this.state?.panelWidth??400)+"",onChange:()=>{this.onPanelWidthChange()}}),this.panelWidthInput.nativeInput.setAttribute("min","200"),this.panelWidthInput.nativeInput.setAttribute("max","800"),this.panelWidthInput.nativeInput.setAttribute("step","10"),e.appendChild(this.panelWidthInput.container)),this.options.allowEditTheme&&(this.themeSelect=new l.UISelect(this.j,{label:"Theme",name:"theme",value:this.state?.theme??"parent",options:[{text:"Inherit",value:"parent"},{text:"Light",value:"light"},{text:"Dark",value:"dark"}],onChange:()=>{this.onThemeChange()}}),e.appendChild(this.themeSelect.container))}async onDisplayModeChange(){this.displayModeSelect&&(this.state.displayMode=this.displayModeSelect.value,this.j.async.setTimeout(async()=>{this.j.e.fire("closeAIAssistantPro.ai-assistant-pro"),await this.j.async.requestIdlePromise(),this.j.e.fire("openAIAssistantPro.ai-assistant-pro")},100))}async onPanelWidthChange(){if(!this.panelWidthInput)return;let e=parseInt(this.panelWidthInput.value,10);isNaN(e)||e<200||e>800||(this.state.panelWidth=e)}async onThemeChange(){this.themeSelect&&(this.state.theme=this.themeSelect.value)}destruct(){this.displayModeSelect?.destruct(),this.panelWidthInput?.destruct(),this.themeSelect?.destruct(),super.destruct()}onStateDisplayModeChange(){this.displayModeSelect&&(this.displayModeSelect.value=this.state.displayMode)}onStatePanelWidthChange(){this.panelWidthInput&&this.panelWidthInput.value!==this.state.panelWidth+""&&(this.panelWidthInput.value=this.state.panelWidth+"")}onStateThemeChange(){this.themeSelect&&(this.themeSelect.value=this.state.theme)}constructor(e,t,s){super(e),(0,i._)(this,"state",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"displayModeSelect",void 0),(0,i._)(this,"panelWidthInput",void 0),(0,i._)(this,"themeSelect",void 0),this.state=t,this.options=s,this.displayModeSelect=null,this.panelWidthInput=null,this.themeSelect=null,this.build()}}(0,n.__decorate)([(0,r.watch)("state.displayMode")],c.prototype,"onStateDisplayModeChange",null),(0,n.__decorate)([(0,r.watch)("state.panelWidth")],c.prototype,"onStatePanelWidthChange",null),(0,n.__decorate)([(0,r.watch)("state.theme")],c.prototype,"onStateThemeChange",null),c=(0,n.__decorate)([r.component],c)},79455:function(e,t,s){"use strict";s.d(t,{UISettingsPopup:function(){return c}});var i=s(82749),n=s(31635),r=s(16015),a=s(71102),o=s(65478),l=s(67510);class c extends l.UIElement{className(){return"UISettingsPopup"}async onChangeTheme(){let e=this.state?.theme&&this.state?.theme!=="parent"?this.state?.theme:this.j.o.theme;this.container.classList.remove("jodit_theme_dark","jodit_theme_light"),this.container.classList.add("jodit_theme_"+e)}update(){return this.dialogSettings?.update(),this.globalSettings?.update(),this.updateContent(),super.update()}setParentView(e){return this.globalSettings?.setParentView(e),this.dialogSettings?.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
51
+ `)}formatArguments(e){return Object.entries(e).map(([e,t])=>`${e}: ${JSON.stringify(t)}`).join(", ")}onApprove(){let e=this.scopeSelect?.value;this.j.e.fire("approveToolCall.ai-assistant-pro",this.toolCall.id,e)}onDeny(){this.j.e.fire("denyToolCall.ai-assistant-pro",this.toolCall.id)}destruct(){this.scopeSelect?.destruct(),this.approveButton?.destruct(),this.denyButton?.destruct(),super.destruct()}constructor(e,t){super(e),(0,i._)(this,"state",void 0),(0,i._)(this,"toolCall",void 0),(0,i._)(this,"scopeSelect",void 0),(0,i._)(this,"approveButton",void 0),(0,i._)(this,"denyButton",void 0),this.state=t,this.scopeSelect=null,this.approveButton=null,this.denyButton=null}}(0,n.__decorate)([(0,a.hook)("ready")],h.prototype,"afterRender",null),(0,n.__decorate)([a.autobind],h.prototype,"onApprove",null),(0,n.__decorate)([a.autobind],h.prototype,"onDeny",null),h=(0,n.__decorate)([a.component],h)},48705:function(e,t,s){"use strict";s.d(t,{UISettingsButton:function(){return i.UISettingsButton}});var i=s(76697)},76697:function(e,t,s){"use strict";s.d(t,{UISettingsButton:function(){return h}});var i=s(82749),n=s(31635),a=s(79455),r=s(87325),o=s(37133),l=s(48538),c=s(78644);class h extends l.UIElement{className(){return"UISettingsButton"}setParentView(e){return this.settingsPopup?.setParentView(e),this.button?.setParentView(e),super.setParentView(e)}onChangeOptionsClosePopup(e){this.closeCallback()}openSettingsPopup(){return this.settingsPopup||(this.settingsPopup=new a.UISettingsPopup(this.jodit,this.extraState,this.options,this.getConversation,this.updateConversation)),this.settingsPopup.update(),this.settingsPopup}constructor(e,t,s,n,a){super(e),(0,i._)(this,"extraState",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"getConversation",void 0),(0,i._)(this,"updateConversation",void 0),(0,i._)(this,"closeCallback",void 0),(0,i._)(this,"settingsPopup",void 0),(0,i._)(this,"button",void 0),this.extraState=t,this.options=s,this.getConversation=n,this.updateConversation=a,this.closeCallback=()=>{},this.settingsPopup=null,this.button=new c.ToolbarButton(this.jodit,{name:"settings",tooltip:"Settings",popup:(e,t,s)=>(this.closeCallback=s,this.openSettingsPopup())}),this.button.state.variant="initial",this.button.state.size="small",this.container.appendChild(this.button.container)}}(0,n.__decorate)([(0,o.watch)("extraState.displayMode")],h.prototype,"onChangeOptionsClosePopup",null),h=(0,n.__decorate)([r.component],h)},16015:function(e,t,s){"use strict";s.d(t,{UIDialogSettings:function(){return c}});var i=s(82749),n=s(31635),a=s(65478),r=s(67510),o=s(12234),l=s(62357);class c extends r.UIElement{className(){return"UIDialogSettings"}setParentView(e){return this.modelSelect?.setParentView(e),this.temperatureInput?.setParentView(e),super.setParentView(e)}async build(){let e=this.container,t=this.getConversation().options||{};if(this.options.dialogSettings.models&&this.options.dialogSettings.models.length>0){let s=this.parseModels(this.options.dialogSettings.models),i=t.model??this.state.defaultModel??s[0].value;this.modelSelect=new o.UISelect(this.j,{label:"Model",name:"model",value:i,options:s,onChange:this.onModelChange.bind(this)}),e.appendChild(this.modelSelect.container)}if(this.options.dialogSettings.temperature){this.temperatureInput=new l.UIRange(this.j,{label:"Temperature",name:"temperature",min:this.options.dialogSettings.temperature.min,max:this.options.dialogSettings.temperature.max,value:t.temperature??this.state.defaultTemperature??.5,onChange:this.onTemperatureChange.bind(this)});let s=this.temperatureInput.nativeInput;s&&s.setAttribute("step",(this.options.dialogSettings.temperature.step??.1)+""),e.appendChild(this.temperatureInput.container)}}parseModels(e){return 0===e.length?[]:"object"==typeof e[0]&&"title"in e[0]?e.map(e=>({text:e.title,value:e.value})):e.map(e=>({text:e,value:e}))}async onModelChange(){if(!this.modelSelect)return;let e=this.modelSelect.value;this.updateConversation({options:{...this.getConversation().options,model:e}}),this.state.defaultModel=e}async onTemperatureChange(){if(!this.temperatureInput)return;let e=parseFloat(this.temperatureInput.value);this.updateConversation({options:{...this.getConversation().options,temperature:e}}),this.state.defaultTemperature=e}onDefaultModelChange(){this.modelSelect&&this.state.defaultModel&&(this.modelSelect.value=this.state.defaultModel)}onDefaultTemperatureChange(){this.temperatureInput&&void 0!==this.state.defaultTemperature&&(this.temperatureInput.value=this.state.defaultTemperature+"")}destruct(){this.modelSelect?.destruct(),super.destruct()}constructor(e,t,s,n,a){super(e),(0,i._)(this,"getConversation",void 0),(0,i._)(this,"updateConversation",void 0),(0,i._)(this,"state",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"modelSelect",void 0),(0,i._)(this,"temperatureInput",void 0),this.getConversation=t,this.updateConversation=s,this.state=n,this.options=a,this.modelSelect=null,this.temperatureInput=null,this.build()}}(0,n.__decorate)([(0,a.watch)("state.defaultModel")],c.prototype,"onDefaultModelChange",null),(0,n.__decorate)([(0,a.watch)("state.defaultTemperature")],c.prototype,"onDefaultTemperatureChange",null),c=(0,n.__decorate)([a.component],c)},71102:function(e,t,s){"use strict";s.d(t,{UIGlobalSettings:function(){return c}});var i=s(82749),n=s(31635),a=s(65478),r=s(67510),o=s(80256),l=s(12234);class c extends r.UIElement{className(){return"UIGlobalSettings"}setParentView(e){return this.displayModeSelect?.setParentView(e),this.panelWidthInput?.setParentView(e),this.themeSelect?.setParentView(e),super.setParentView(e)}async build(){let e=this.container;this.options.allowEditDisplayMode&&(this.displayModeSelect=new l.UISelect(this.j,{label:"Display Mode",name:"displayMode",value:this.state?.displayMode??"right",options:[{text:"Dialog",value:"dialog"},{text:"Flight",value:"flight"},{text:"Left",value:"left"},{text:"Right",value:"right"},{text:"Top",value:"top"},{text:"Bottom",value:"bottom"}],onChange:()=>{this.onDisplayModeChange()}}),e.appendChild(this.displayModeSelect.container)),this.options.allowEditPanelWidth&&(this.panelWidthInput=new o.UIInput(this.j,{label:"Panel Width",name:"panelWidth",type:"number",value:(this.state?.panelWidth??400)+"",onChange:()=>{this.onPanelWidthChange()}}),this.panelWidthInput.nativeInput.setAttribute("min","200"),this.panelWidthInput.nativeInput.setAttribute("max","800"),this.panelWidthInput.nativeInput.setAttribute("step","10"),e.appendChild(this.panelWidthInput.container)),this.options.allowEditTheme&&(this.themeSelect=new l.UISelect(this.j,{label:"Theme",name:"theme",value:this.state?.theme??"parent",options:[{text:"Inherit",value:"parent"},{text:"Light",value:"light"},{text:"Dark",value:"dark"}],onChange:()=>{this.onThemeChange()}}),e.appendChild(this.themeSelect.container))}async onDisplayModeChange(){this.displayModeSelect&&(this.state.displayMode=this.displayModeSelect.value,this.j.async.setTimeout(async()=>{this.j.e.fire("closeAIAssistantPro.ai-assistant-pro"),await this.j.async.requestIdlePromise(),this.j.e.fire("openAIAssistantPro.ai-assistant-pro")},100))}async onPanelWidthChange(){if(!this.panelWidthInput)return;let e=parseInt(this.panelWidthInput.value,10);isNaN(e)||e<200||e>800||(this.state.panelWidth=e)}async onThemeChange(){this.themeSelect&&(this.state.theme=this.themeSelect.value)}destruct(){this.displayModeSelect?.destruct(),this.panelWidthInput?.destruct(),this.themeSelect?.destruct(),super.destruct()}onStateDisplayModeChange(){this.displayModeSelect&&(this.displayModeSelect.value=this.state.displayMode)}onStatePanelWidthChange(){this.panelWidthInput&&this.panelWidthInput.value!==this.state.panelWidth+""&&(this.panelWidthInput.value=this.state.panelWidth+"")}onStateThemeChange(){this.themeSelect&&(this.themeSelect.value=this.state.theme)}constructor(e,t,s){super(e),(0,i._)(this,"state",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"displayModeSelect",void 0),(0,i._)(this,"panelWidthInput",void 0),(0,i._)(this,"themeSelect",void 0),this.state=t,this.options=s,this.displayModeSelect=null,this.panelWidthInput=null,this.themeSelect=null,this.build()}}(0,n.__decorate)([(0,a.watch)("state.displayMode")],c.prototype,"onStateDisplayModeChange",null),(0,n.__decorate)([(0,a.watch)("state.panelWidth")],c.prototype,"onStatePanelWidthChange",null),(0,n.__decorate)([(0,a.watch)("state.theme")],c.prototype,"onStateThemeChange",null),c=(0,n.__decorate)([a.component],c)},79455:function(e,t,s){"use strict";s.d(t,{UISettingsPopup:function(){return c}});var i=s(82749),n=s(31635),a=s(16015),r=s(71102),o=s(65478),l=s(67510);class c extends l.UIElement{className(){return"UISettingsPopup"}async onChangeTheme(){let e=this.state?.theme&&this.state?.theme!=="parent"?this.state?.theme:this.j.o.theme;this.container.classList.remove("jodit_theme_dark","jodit_theme_light"),this.container.classList.add("jodit_theme_"+e)}update(){return this.dialogSettings?.update(),this.globalSettings?.update(),this.updateContent(),super.update()}setParentView(e){return this.globalSettings?.setParentView(e),this.dialogSettings?.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
52
52
  <div class="&__header">
53
53
  <h3 class="&__title">~Settings~</h3>
54
54
  </div>
55
55
  <div class="&__content"></div>
56
- </div>`}async updateContent(){let e=this.getElm("content");if(!e)return;e.innerHTML="";let t=this.options,s=t.allowEditDisplayMode||t.allowEditPanelWidth||t.allowEditTheme,i=t.allowEditDialogSettings;if(s){let t=document.createElement("div");t.className=this.getFullElName("section");let s=document.createElement("h4");s.className=this.getFullElName("section-title"),s.textContent=this.j.i18n("General Settings"),t.appendChild(s),this.globalSettings=new a.UIGlobalSettings(this.j,this.state,this.options),t.appendChild(this.globalSettings.container),e.appendChild(t)}let n=this.getConversation();if(i&&n){let t=document.createElement("div");t.className=this.getFullElName("section");let s=document.createElement("h4");s.className=this.getFullElName("section-title"),s.textContent=this.j.i18n("Conversation Settings"),t.appendChild(s),this.dialogSettings=new r.UIDialogSettings(this.j,()=>this.getConversation(),this.updateConversation,this.state,this.options),t.appendChild(this.dialogSettings.container),e.appendChild(t)}}destruct(){this.globalSettings?.destruct(),this.dialogSettings?.destruct(),super.destruct()}constructor(e,t,s,n,r){super(e),(0,i._)(this,"state",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"getConversation",void 0),(0,i._)(this,"updateConversation",void 0),(0,i._)(this,"globalSettings",void 0),(0,i._)(this,"dialogSettings",void 0),this.state=t,this.options=s,this.getConversation=n,this.updateConversation=r,this.globalSettings=null,this.dialogSettings=null}}(0,n.__decorate)([(0,o.watch)("state.theme"),(0,o.hook)("ready")],c.prototype,"onChangeTheme",null),c=(0,n.__decorate)([o.component],c)},55885:function(e,t,s){"use strict";s.d(t,{UIWelcomeScreen:function(){return a}});var i=s(31635),n=s(65478),r=s(67510);class a extends r.UIElement{className(){return"UIWelcomeScreen"}render(){return`<div class="&__container">
56
+ </div>`}async updateContent(){let e=this.getElm("content");if(!e)return;e.innerHTML="";let t=this.options,s=t.allowEditDisplayMode||t.allowEditPanelWidth||t.allowEditTheme,i=t.allowEditDialogSettings;if(s){let t=document.createElement("div");t.className=this.getFullElName("section");let s=document.createElement("h4");s.className=this.getFullElName("section-title"),s.textContent=this.j.i18n("General Settings"),t.appendChild(s),this.globalSettings=new r.UIGlobalSettings(this.j,this.state,this.options),t.appendChild(this.globalSettings.container),e.appendChild(t)}let n=this.getConversation();if(i&&n){let t=document.createElement("div");t.className=this.getFullElName("section");let s=document.createElement("h4");s.className=this.getFullElName("section-title"),s.textContent=this.j.i18n("Conversation Settings"),t.appendChild(s),this.dialogSettings=new a.UIDialogSettings(this.j,()=>this.getConversation(),this.updateConversation,this.state,this.options),t.appendChild(this.dialogSettings.container),e.appendChild(t)}}destruct(){this.globalSettings?.destruct(),this.dialogSettings?.destruct(),super.destruct()}constructor(e,t,s,n,a){super(e),(0,i._)(this,"state",void 0),(0,i._)(this,"options",void 0),(0,i._)(this,"getConversation",void 0),(0,i._)(this,"updateConversation",void 0),(0,i._)(this,"globalSettings",void 0),(0,i._)(this,"dialogSettings",void 0),this.state=t,this.options=s,this.getConversation=n,this.updateConversation=a,this.globalSettings=null,this.dialogSettings=null}}(0,n.__decorate)([(0,o.watch)("state.theme"),(0,o.hook)("ready")],c.prototype,"onChangeTheme",null),c=(0,n.__decorate)([o.component],c)},55885:function(e,t,s){"use strict";s.d(t,{UIWelcomeScreen:function(){return r}});var i=s(31635),n=s(65478),a=s(67510);class r extends a.UIElement{className(){return"UIWelcomeScreen"}render(){return`<div class="&__container">
57
57
  <div class="&__icon">
58
58
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
59
59
  <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2v1.93zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39z"/>
@@ -62,32 +62,32 @@ ${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQ
62
62
  <div class="&__title">~Welcome to AI Assistant~</div>
63
63
  <div class="&__subtitle">~Start your first conversation~</div>
64
64
  <div class="&__tip">~Tip: Select text in editor to add context~</div>
65
- </div>`}}a=(0,i.__decorate)([n.component],a)},18549:function(e,t,s){"use strict";s.d(t,{UIFlightPosition:function(){return r}});var i=s(2748);let n=new WeakMap;class r{static install(e,t,s={}){this.remove(e);let{panelHeight:i=250,containerClassName:r,toolbarSelector:a=".jodit-toolbar__box",gap:o=16}=s,l=e.j.c.div("jodit-flight-position");r&&l.classList.add(r),l.style.setProperty("--flight-panel-height",`${i}px`),l.appendChild(e.container),document.body.appendChild(l);let c={toolbarSelector:a,gap:o},h=()=>{this.updatePosition(l,t,c)},u=new ResizeObserver(h);u.observe(t),window.addEventListener("scroll",h,{passive:!0}),window.addEventListener("resize",h,{passive:!0}),n.set(e,{container:l,anchor:t,onScroll:h,resizeObserver:u,options:c}),this.updatePosition(l,t,c)}static updatePosition(e,t,s){let{toolbarSelector:i,gap:n}=s,r=t.getBoundingClientRect(),a=window.innerHeight,o=e.offsetHeight||250;e.style.left=`${r.left}px`,e.style.width=`${r.width}px`;let l=t.querySelector(i),c=l?l.getBoundingClientRect().bottom:r.top,h=r.bottom-c,u=r.bottom<=a;o<=h?u?(e.style.top="auto",e.style.bottom=`${a-r.bottom+n}px`):(e.style.top="auto",e.style.bottom=`${n}px`):(e.style.bottom="auto",e.style.top=`${c}px`)}static remove(e){let t=n.get(e);t&&(window.removeEventListener("scroll",t.onScroll),window.removeEventListener("resize",t.onScroll),t.resizeObserver.disconnect(),e.container.parentNode===t.container&&t.container.parentNode?.insertBefore(e.container,t.container),i.Dom.safeRemove(t.container),n.delete(e))}static isInstalled(e){return n.has(e)}static setPanelHeight(e,t){let s=n.get(e);s&&s.container.style.setProperty("--flight-panel-height",`${t}px`)}static refresh(e){let t=n.get(e);t&&this.updatePosition(t.container,t.anchor,t.options)}}},54747:function(e,t,s){"use strict";s.d(t,{UIResize:function(){return r}});var i=s(2748),n=s(41180);class r{static remove(e){e.container.classList.remove("jodit-ui-resize"),i.Dom.safeRemove(e.container.querySelector(".jodit-ui-resize__handle"))}static install(e,t,s={}){e.container.classList.add("jodit-ui-resize"),"static"===(0,n.css)(e.container,"position")&&(0,n.css)(e.container,"position","relative");let i=e.j.c.div("jodit-ui-resize__handle");i.classList.add("jodit-ui-resize__handle_type_"+t),s.handleClassName&&i.classList.add(s.handleClassName),e.container.appendChild(i),e.j.e.on(i,"mousedown touchstart",this.onStartResize.bind(this,e,t,s.onResize??(()=>void 0)))}static onStartResize(e,t,s,i){let n={x:i.clientX,y:i.clientY,w:e.container.offsetWidth,h:e.container.offsetHeight,direction:t},r=e.j.async.throttle(this.onResize.bind(this,e,n,s),e.j.defaultTimeout/10);e.j.lock(),e.j.e.on(e.j.ow,"mousemove touchmove",r).one(e.j.ow,"mouseup touchend",this.onEndResize.bind(this,e,r))}static onResize(e,t,s,i){let r,a=["left","right"].includes(t.direction),o=e.container.parentElement;o&&(r=a?t.w+(i.clientX-t.x)*("right"===t.direction?1:-1):t.h+(i.clientY-t.y)*("top"===t.direction?-1:1),!0!==s?.({newSize:r})&&(0,n.css)(e.container,a?"width":"height",r/(a?o.offsetWidth:o.offsetHeight)*100+"%"))}static onEndResize(e,t,s){e.j.e.off(e.j.ow,"mousemove touchmove",t),e.j.unlock()}}},72573:function(e,t,s){"use strict";function i(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function n(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}s.d(t,{marked:function(){return ey}});var r,a=n(),o={exec:()=>null};function l(e,t=""){let s="string"==typeof e?e:e.source,i={replace(e,t){let n="string"==typeof t?t:t.source;return n=n.replace(h.caret,"$1"),s=s.replace(e,n),i},getRegex:()=>new RegExp(s,t)};return i}var c=(()=>{try{return!!RegExp("(?<=1)(?<!1)")}catch{return!1}})(),h={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},u=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,d=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,p=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,g=l(p).replace(/bull/g,d).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),m=l(p).replace(/bull/g,d).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),f=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,v=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,C=l(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",v).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),w=l(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,d).getRegex(),x="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",y=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,k=l("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",y).replace("tag",x).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),b=l(f).replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex(),_={blockquote:l(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",b).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:C,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:u,html:k,lheading:g,list:w,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:b,table:o,text:/^[^\n]+/},S=l("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex(),I={..._,lheading:m,table:S,paragraph:l(f).replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",S).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex()},M={..._,html:l("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",y).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:o,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:l(f).replace("hr",u).replace("heading",` *#{1,6} *[^
66
- ]`).replace("lheading",g).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},A=/^( {2,}|\\)\n(?!\s*$)/,T=/[\p{P}\p{S}]/u,P=/[\s\p{P}\p{S}]/u,E=/[^\s\p{P}\p{S}]/u,j=l(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,P).getRegex(),R=/(?!~)[\p{P}\p{S}]/u,L=/(?![*_])[\p{P}\p{S}]/u,$=l(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",c?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),B=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,D=l(B,"u").replace(/punct/g,T).getRegex(),N=l(B,"u").replace(/punct/g,R).getRegex(),q="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",z=l(q,"gu").replace(/notPunctSpace/g,E).replace(/punctSpace/g,P).replace(/punct/g,T).getRegex(),F=l(q,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,R).getRegex(),U=l("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,E).replace(/punctSpace/g,P).replace(/punct/g,T).getRegex(),O=l(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,L).getRegex(),H=l("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|[*_])/u).replace(/punctSpace/g,/(?![*_])[\s\p{P}\p{S}]/u).replace(/punct/g,L).getRegex(),V=l(/\\(punct)/,"gu").replace(/punct/g,T).getRegex(),W=l(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),G=l(y).replace("(?:--\x3e|$)","--\x3e").getRegex(),Z=l("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",G).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,K=l(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),J=l(/^!?\[(label)\]\[(ref)\]/).replace("label",Q).replace("ref",v).getRegex(),X=l(/^!?\[(ref)\](?:\[\])?/).replace("ref",v).getRegex(),Y=l("reflink|nolink(?!\\()","g").replace("reflink",J).replace("nolink",X).getRegex(),ee=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,et={_backpedal:o,anyPunctuation:V,autolink:W,blockSkip:$,br:A,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:o,delLDelim:o,delRDelim:o,emStrongLDelim:D,emStrongRDelimAst:z,emStrongRDelimUnd:U,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:K,nolink:X,punctuation:j,reflink:J,reflinkSearch:Y,tag:Z,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:o},es={...et,link:l(/^!?\[(label)\]\((.*?)\)/).replace("label",Q).getRegex(),reflink:l(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Q).getRegex()},ei={...et,emStrongRDelimAst:F,emStrongLDelim:N,delLDelim:O,delRDelim:H,url:l(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ee).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:l(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ee).getRegex()},en={...ei,br:l(A).replace("{2,}","*").getRegex(),text:l(ei.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},er={normal:_,gfm:I,pedantic:M},ea={normal:et,gfm:ei,breaks:en,pedantic:es},eo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},el=e=>eo[e];function ec(e,t){if(t){if(h.escapeTest.test(e))return e.replace(h.escapeReplace,el)}else if(h.escapeTestNoEncode.test(e))return e.replace(h.escapeReplaceNoEncode,el);return e}function eh(e){try{e=encodeURI(e).replace(h.percentDecode,"%")}catch{return null}return e}function eu(e,t){let s=e.replace(h.findPipe,(e,t,s)=>{let i=!1,n=t;for(;--n>=0&&"\\"===s[n];)i=!i;return i?"|":" |"}).split(h.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(h.slashPipe,"|");return s}function ed(e,t,s){let i=e.length;if(0===i)return"";let n=0;for(;n<i;){let r=e.charAt(i-n-1);if(r!==t||s)if(r!==t&&s)n++;else break;else n++}return e.slice(0,i-n)}function ep(e,t,s,i,n){let r=t.href,a=t.title||null,o=e[1].replace(n.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:s,href:r,title:a,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,l}var eg=class{space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:ed(e,`
65
+ </div>`}}r=(0,i.__decorate)([n.component],r)},18549:function(e,t,s){"use strict";s.d(t,{UIFlightPosition:function(){return a}});var i=s(2748);let n=new WeakMap;class a{static install(e,t,s={}){this.remove(e);let{panelHeight:i=250,containerClassName:a,toolbarSelector:r=".jodit-toolbar__box",gap:o=16}=s,l=e.j.c.div("jodit-flight-position");a&&l.classList.add(a),l.style.setProperty("--flight-panel-height",`${i}px`),l.appendChild(e.container),document.body.appendChild(l);let c={toolbarSelector:r,gap:o},h=()=>{this.updatePosition(l,t,c)},u=new ResizeObserver(h);u.observe(t),window.addEventListener("scroll",h,{passive:!0}),window.addEventListener("resize",h,{passive:!0}),n.set(e,{container:l,anchor:t,onScroll:h,resizeObserver:u,options:c}),this.updatePosition(l,t,c)}static updatePosition(e,t,s){let{toolbarSelector:i,gap:n}=s,a=t.getBoundingClientRect(),r=window.innerHeight,o=e.offsetHeight||250;e.style.left=`${a.left}px`,e.style.width=`${a.width}px`;let l=t.querySelector(i),c=l?l.getBoundingClientRect().bottom:a.top,h=a.bottom-c,u=a.bottom<=r;o<=h?u?(e.style.top="auto",e.style.bottom=`${r-a.bottom+n}px`):(e.style.top="auto",e.style.bottom=`${n}px`):(e.style.bottom="auto",e.style.top=`${c}px`)}static remove(e){let t=n.get(e);t&&(window.removeEventListener("scroll",t.onScroll),window.removeEventListener("resize",t.onScroll),t.resizeObserver.disconnect(),e.container.parentNode===t.container&&t.container.parentNode?.insertBefore(e.container,t.container),i.Dom.safeRemove(t.container),n.delete(e))}static isInstalled(e){return n.has(e)}static setPanelHeight(e,t){let s=n.get(e);s&&s.container.style.setProperty("--flight-panel-height",`${t}px`)}static refresh(e){let t=n.get(e);t&&this.updatePosition(t.container,t.anchor,t.options)}}},54747:function(e,t,s){"use strict";s.d(t,{UIResize:function(){return a}});var i=s(2748),n=s(41180);class a{static remove(e){e.container.classList.remove("jodit-ui-resize"),i.Dom.safeRemove(e.container.querySelector(".jodit-ui-resize__handle"))}static install(e,t,s={}){e.container.classList.add("jodit-ui-resize"),"static"===(0,n.css)(e.container,"position")&&(0,n.css)(e.container,"position","relative");let i=e.j.c.div("jodit-ui-resize__handle");i.classList.add("jodit-ui-resize__handle_type_"+t),s.handleClassName&&i.classList.add(s.handleClassName),e.container.appendChild(i),e.j.e.on(i,"mousedown touchstart",this.onStartResize.bind(this,e,t,s.onResize??(()=>void 0)))}static onStartResize(e,t,s,i){let n={x:i.clientX,y:i.clientY,w:e.container.offsetWidth,h:e.container.offsetHeight,direction:t},a=e.j.async.throttle(this.onResize.bind(this,e,n,s),e.j.defaultTimeout/10);e.j.lock(),e.j.e.on(e.j.ow,"mousemove touchmove",a).one(e.j.ow,"mouseup touchend",this.onEndResize.bind(this,e,a))}static onResize(e,t,s,i){let a,r=["left","right"].includes(t.direction),o=e.container.parentElement;o&&(a=r?t.w+(i.clientX-t.x)*("right"===t.direction?1:-1):t.h+(i.clientY-t.y)*("top"===t.direction?-1:1),!0!==s?.({newSize:a})&&(0,n.css)(e.container,r?"width":"height",a/(r?o.offsetWidth:o.offsetHeight)*100+"%"))}static onEndResize(e,t,s){e.j.e.off(e.j.ow,"mousemove touchmove",t),e.j.unlock()}}},72573:function(e,t,s){"use strict";function i(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function n(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}s.d(t,{marked:function(){return ey}});var a,r=n(),o={exec:()=>null};function l(e,t=""){let s="string"==typeof e?e:e.source,i={replace(e,t){let n="string"==typeof t?t:t.source;return n=n.replace(h.caret,"$1"),s=s.replace(e,n),i},getRegex:()=>new RegExp(s,t)};return i}var c=(()=>{try{return!!RegExp("(?<=1)(?<!1)")}catch{return!1}})(),h={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},u=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,d=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,p=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,g=l(p).replace(/bull/g,d).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),m=l(p).replace(/bull/g,d).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),f=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,v=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,C=l(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",v).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),w=l(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,d).getRegex(),x="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",y=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,k=l("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",y).replace("tag",x).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),b=l(f).replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex(),_={blockquote:l(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",b).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:C,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:u,html:k,lheading:g,list:w,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:b,table:o,text:/^[^\n]+/},S=l("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex(),A={..._,lheading:m,table:S,paragraph:l(f).replace("hr",u).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",S).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex()},I={..._,html:l("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",y).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:o,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:l(f).replace("hr",u).replace("heading",` *#{1,6} *[^
66
+ ]`).replace("lheading",g).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},M=/^( {2,}|\\)\n(?!\s*$)/,T=/[\p{P}\p{S}]/u,P=/[\s\p{P}\p{S}]/u,E=/[^\s\p{P}\p{S}]/u,j=l(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,P).getRegex(),R=/(?!~)[\p{P}\p{S}]/u,L=/(?![*_])[\p{P}\p{S}]/u,$=l(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",c?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),B=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,D=l(B,"u").replace(/punct/g,T).getRegex(),N=l(B,"u").replace(/punct/g,R).getRegex(),q="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",z=l(q,"gu").replace(/notPunctSpace/g,E).replace(/punctSpace/g,P).replace(/punct/g,T).getRegex(),F=l(q,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,R).getRegex(),U=l("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,E).replace(/punctSpace/g,P).replace(/punct/g,T).getRegex(),O=l(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,L).getRegex(),H=l("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|[*_])/u).replace(/punctSpace/g,/(?![*_])[\s\p{P}\p{S}]/u).replace(/punct/g,L).getRegex(),V=l(/\\(punct)/,"gu").replace(/punct/g,T).getRegex(),W=l(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),G=l(y).replace("(?:--\x3e|$)","--\x3e").getRegex(),Q=l("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",G).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Z=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,K=l(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Z).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),J=l(/^!?\[(label)\]\[(ref)\]/).replace("label",Z).replace("ref",v).getRegex(),X=l(/^!?\[(ref)\](?:\[\])?/).replace("ref",v).getRegex(),Y=l("reflink|nolink(?!\\()","g").replace("reflink",J).replace("nolink",X).getRegex(),ee=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,et={_backpedal:o,anyPunctuation:V,autolink:W,blockSkip:$,br:M,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:o,delLDelim:o,delRDelim:o,emStrongLDelim:D,emStrongRDelimAst:z,emStrongRDelimUnd:U,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:K,nolink:X,punctuation:j,reflink:J,reflinkSearch:Y,tag:Q,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:o},es={...et,link:l(/^!?\[(label)\]\((.*?)\)/).replace("label",Z).getRegex(),reflink:l(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Z).getRegex()},ei={...et,emStrongRDelimAst:F,emStrongLDelim:N,delLDelim:O,delRDelim:H,url:l(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ee).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:l(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ee).getRegex()},en={...ei,br:l(M).replace("{2,}","*").getRegex(),text:l(ei.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ea={normal:_,gfm:A,pedantic:I},er={normal:et,gfm:ei,breaks:en,pedantic:es},eo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},el=e=>eo[e];function ec(e,t){if(t){if(h.escapeTest.test(e))return e.replace(h.escapeReplace,el)}else if(h.escapeTestNoEncode.test(e))return e.replace(h.escapeReplaceNoEncode,el);return e}function eh(e){try{e=encodeURI(e).replace(h.percentDecode,"%")}catch{return null}return e}function eu(e,t){let s=e.replace(h.findPipe,(e,t,s)=>{let i=!1,n=t;for(;--n>=0&&"\\"===s[n];)i=!i;return i?"|":" |"}).split(h.splitPipe),i=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;i<s.length;i++)s[i]=s[i].trim().replace(h.slashPipe,"|");return s}function ed(e,t,s){let i=e.length;if(0===i)return"";let n=0;for(;n<i;){let a=e.charAt(i-n-1);if(a!==t||s)if(a!==t&&s)n++;else break;else n++}return e.slice(0,i-n)}function ep(e,t,s,i,n){let a=t.href,r=t.title||null,o=e[1].replace(n.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:s,href:a,title:r,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,l}var eg=class{space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:ed(e,`
67
67
  `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],s=function(e,t,s){let i=e.match(s.other.indentCodeCompensation);if(null===i)return t;let n=i[1];return t.split(`
68
68
  `).map(e=>{let t=e.match(s.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=n.length?e.slice(n.length):e}).join(`
69
69
  `)}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=ed(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ed(t[0],`
70
70
  `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=ed(t[0],`
71
71
  `).split(`
72
- `),s="",i="",n=[];for(;e.length>0;){let t=!1,r=[],a;for(a=0;a<e.length;a++)if(this.rules.other.blockquoteStart.test(e[a]))r.push(e[a]),t=!0;else if(t)break;else r.push(e[a]);e=e.slice(a);let o=r.join(`
72
+ `),s="",i="",n=[];for(;e.length>0;){let t=!1,a=[],r;for(r=0;r<e.length;r++)if(this.rules.other.blockquoteStart.test(e[r]))a.push(e[r]),t=!0;else if(t)break;else a.push(e[r]);e=e.slice(r);let o=a.join(`
73
73
  `),l=o.replace(this.rules.other.blockquoteSetextReplace,`
74
74
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
75
75
  ${o}`:o,i=i?`${i}
76
76
  ${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,n,!0),this.lexer.state.top=c,0===e.length)break;let h=n.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let t=h.raw+`
77
77
  `+e.join(`
78
- `),r=this.blockquote(t);n[n.length-1]=r,s=s.substring(0,s.length-h.raw.length)+r.raw,i=i.substring(0,i.length-h.text.length)+r.text;break}if(h?.type==="list"){let t=h.raw+`
78
+ `),a=this.blockquote(t);n[n.length-1]=a,s=s.substring(0,s.length-h.raw.length)+a.raw,i=i.substring(0,i.length-h.text.length)+a.text;break}if(h?.type==="list"){let t=h.raw+`
79
79
  `+e.join(`
80
- `),r=this.list(t);n[n.length-1]=r,s=s.substring(0,s.length-h.raw.length)+r.raw,i=i.substring(0,i.length-h.raw.length)+r.raw,e=t.substring(n.at(-1).raw.length).split(`
81
- `);continue}}return{type:"blockquote",raw:s,tokens:n,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),i=s.length>1,n={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?"\\d{1,9}\\"+s.slice(-1):"\\"+s,this.options.pedantic&&(s=i?s:"[*+-]");let r=this.rules.other.listItemRegex(s),a=!1;for(;e;){let s=!1,i="",o="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=function(e,t=0){let s=t,i="";for(let t of e)if(" "===t){let e=4-s%4;i+=" ".repeat(e),s+=e}else i+=t,s++;return i}(t[2].split(`
80
+ `),a=this.list(t);n[n.length-1]=a,s=s.substring(0,s.length-h.raw.length)+a.raw,i=i.substring(0,i.length-h.raw.length)+a.raw,e=t.substring(n.at(-1).raw.length).split(`
81
+ `);continue}}return{type:"blockquote",raw:s,tokens:n,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let s=t[1].trim(),i=s.length>1,n={type:"list",raw:"",ordered:i,start:i?+s.slice(0,-1):"",loose:!1,items:[]};s=i?"\\d{1,9}\\"+s.slice(-1):"\\"+s,this.options.pedantic&&(s=i?s:"[*+-]");let a=this.rules.other.listItemRegex(s),r=!1;for(;e;){let s=!1,i="",o="";if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=function(e,t=0){let s=t,i="";for(let t of e)if(" "===t){let e=4-s%4;i+=" ".repeat(e),s+=e}else i+=t,s++;return i}(t[2].split(`
82
82
  `,1)[0],t[1].length),c=e.split(`
83
83
  `,1)[0],h=!l.trim(),u=0;if(this.options.pedantic?(u=2,o=l.trimStart()):h?u=t[1].length+1:(u=(u=l.search(this.rules.other.nonSpaceChar))>4?1:u,o=l.slice(u),u+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(i+=c+`
84
- `,e=e.substring(c.length+1),s=!0),!s){let t=this.rules.other.nextBulletRegex(u),s=this.rules.other.hrRegex(u),n=this.rules.other.fencesBeginRegex(u),r=this.rules.other.headingBeginRegex(u),a=this.rules.other.htmlBeginRegex(u),d=this.rules.other.blockquoteBeginRegex(u);for(;e;){let p=e.split(`
85
- `,1)[0],g;if(c=p,g=this.options.pedantic?c=c.replace(this.rules.other.listReplaceNesting," "):c.replace(this.rules.other.tabCharGlobal," "),n.test(c)||r.test(c)||a.test(c)||d.test(c)||t.test(c)||s.test(c))break;if(g.search(this.rules.other.nonSpaceChar)>=u||!c.trim())o+=`
86
- `+g.slice(u);else{if(h||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||n.test(l)||r.test(l)||s.test(l))break;o+=`
84
+ `,e=e.substring(c.length+1),s=!0),!s){let t=this.rules.other.nextBulletRegex(u),s=this.rules.other.hrRegex(u),n=this.rules.other.fencesBeginRegex(u),a=this.rules.other.headingBeginRegex(u),r=this.rules.other.htmlBeginRegex(u),d=this.rules.other.blockquoteBeginRegex(u);for(;e;){let p=e.split(`
85
+ `,1)[0],g;if(c=p,g=this.options.pedantic?c=c.replace(this.rules.other.listReplaceNesting," "):c.replace(this.rules.other.tabCharGlobal," "),n.test(c)||a.test(c)||r.test(c)||d.test(c)||t.test(c)||s.test(c))break;if(g.search(this.rules.other.nonSpaceChar)>=u||!c.trim())o+=`
86
+ `+g.slice(u);else{if(h||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||n.test(l)||a.test(l)||s.test(l))break;o+=`
87
87
  `+c}h=!c.trim(),i+=p+`
88
- `,e=e.substring(p.length+1),l=g.slice(u)}}n.loose||(a?n.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(a=!0)),n.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),n.raw+=i}let o=n.items.at(-1);if(!o)return;for(let e of(o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),n.raw=n.raw.trimEnd(),n.items)){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),e.tokens[0]?.type==="text"||e.tokens[0]?.type==="paragraph"){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let s={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=s.checked,n.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=s.raw+e.tokens[0].raw,e.tokens[0].text=s.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(s)):e.tokens.unshift({type:"paragraph",raw:s.raw,text:s.raw,tokens:[s]}):e.tokens.unshift(s)}}if(!n.loose){let t=e.tokens.filter(e=>"space"===e.type);n.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(n.loose)for(let e of n.items)for(let t of(e.loose=!0,e.tokens))"text"===t.type&&(t.type="paragraph");return n}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let s=eu(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
89
- `):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(s.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?r.align.push("right"):this.rules.other.tableAlignCenter.test(e)?r.align.push("center"):this.rules.other.tableAlignLeft.test(e)?r.align.push("left"):r.align.push(null);for(let e=0;e<s.length;e++)r.header.push({text:s[e],tokens:this.lexer.inline(s[e]),header:!0,align:r.align[e]});for(let e of n)r.rows.push(eu(e,r.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:r.align[t]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
90
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=ed(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e){if(-1===e.indexOf(")"))return -1;let t=0;for(let s=0;s<e.length;s++)if("\\"===e[s])s++;else if("("===e[s])t++;else if(")"===e[s]&&--t<0)return s;return t>0?-2:-1}(t[2]);if(-2===e)return;if(e>-1){let s=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,s).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(s);e&&(s=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(s=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?s.slice(1):s.slice(1,-1)),ep(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let s;if((s=this.rules.inline.reflink.exec(e))||(s=this.rules.inline.nolink.exec(e))){let e=t[(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=s[0].charAt(0);return{type:"text",raw:e,text:e}}return ep(s,e,s[0],this.lexer,this.rules)}}emStrong(e,t,s=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!s||this.rules.inline.punctuation.exec(s))){let s=[...i[0]].length-1,n,r,a=s,o=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+s);null!=(i=l.exec(t));){if(!(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6]))continue;if(r=[...n].length,i[3]||i[4]){a+=r;continue}if((i[5]||i[6])&&s%3&&!((s+r)%3)){o+=r;continue}if((a-=r)>0)continue;r=Math.min(r,r+a+o);let t=[...i[0]][0].length,l=e.slice(0,s+i.index+t+r);if(Math.min(s,r)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return s&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,s=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!s||this.rules.inline.punctuation.exec(s))){let s=[...i[0]].length-1,n,r,a=s,o=this.rules.inline.delRDelim;for(o.lastIndex=0,t=t.slice(-1*e.length+s);null!=(i=o.exec(t));){if(!(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6])||(r=[...n].length)!==s)continue;if(i[3]||i[4]){a+=r;continue}if((a-=r)>0)continue;r=Math.min(r,r+a);let t=[...i[0]][0].length,o=e.slice(0,s+i.index+t+r),l=o.slice(s,-s);return{type:"del",raw:o,text:l,tokens:this.lexer.inlineTokens(l)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,s;return s="@"===t[2]?"mailto:"+(e=t[1]):e=t[1],{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,s;if("@"===t[2])s="mailto:"+(e=t[0]);else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0])e=t[0],s="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}constructor(e){i(this,"options",void 0),i(this,"rules",void 0),i(this,"lexer",void 0),this.options=e||a}},em=class e{static get rules(){return{block:er,inline:ea}}static lex(t,s){return new e(s).lex(t)}static lexInline(t,s){return new e(s).inlineTokens(t)}lex(e){e=e.replace(h.carriageReturn,`
88
+ `,e=e.substring(p.length+1),l=g.slice(u)}}n.loose||(r?n.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(r=!0)),n.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(o),loose:!1,text:o,tokens:[]}),n.raw+=i}let o=n.items.at(-1);if(!o)return;for(let e of(o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd(),n.raw=n.raw.trimEnd(),n.items)){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),e.tokens[0]?.type==="text"||e.tokens[0]?.type==="paragraph"){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let s={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=s.checked,n.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=s.raw+e.tokens[0].raw,e.tokens[0].text=s.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(s)):e.tokens.unshift({type:"paragraph",raw:s.raw,text:s.raw,tokens:[s]}):e.tokens.unshift(s)}}if(!n.loose){let t=e.tokens.filter(e=>"space"===e.type);n.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(n.loose)for(let e of n.items)for(let t of(e.loose=!0,e.tokens))"text"===t.type&&(t.type="paragraph");return n}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:s,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let s=eu(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),n=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
89
+ `):[],a={type:"table",raw:t[0],header:[],align:[],rows:[]};if(s.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?a.align.push("right"):this.rules.other.tableAlignCenter.test(e)?a.align.push("center"):this.rules.other.tableAlignLeft.test(e)?a.align.push("left"):a.align.push(null);for(let e=0;e<s.length;e++)a.header.push({text:s[e],tokens:this.lexer.inline(s[e]),header:!0,align:a.align[e]});for(let e of n)a.rows.push(eu(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
90
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=ed(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e){if(-1===e.indexOf(")"))return -1;let t=0;for(let s=0;s<e.length;s++)if("\\"===e[s])s++;else if("("===e[s])t++;else if(")"===e[s]&&--t<0)return s;return t>0?-2:-1}(t[2]);if(-2===e)return;if(e>-1){let s=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,s).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(s);e&&(s=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(s=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?s.slice(1):s.slice(1,-1)),ep(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let s;if((s=this.rules.inline.reflink.exec(e))||(s=this.rules.inline.nolink.exec(e))){let e=t[(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=s[0].charAt(0);return{type:"text",raw:e,text:e}}return ep(s,e,s[0],this.lexer,this.rules)}}emStrong(e,t,s=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!s||this.rules.inline.punctuation.exec(s))){let s=[...i[0]].length-1,n,a,r=s,o=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+s);null!=(i=l.exec(t));){if(!(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6]))continue;if(a=[...n].length,i[3]||i[4]){r+=a;continue}if((i[5]||i[6])&&s%3&&!((s+a)%3)){o+=a;continue}if((r-=a)>0)continue;a=Math.min(a,a+r+o);let t=[...i[0]][0].length,l=e.slice(0,s+i.index+t+a);if(Math.min(s,a)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return s&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,s=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!s||this.rules.inline.punctuation.exec(s))){let s=[...i[0]].length-1,n,a,r=s,o=this.rules.inline.delRDelim;for(o.lastIndex=0,t=t.slice(-1*e.length+s);null!=(i=o.exec(t));){if(!(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6])||(a=[...n].length)!==s)continue;if(i[3]||i[4]){r+=a;continue}if((r-=a)>0)continue;a=Math.min(a,a+r);let t=[...i[0]][0].length,o=e.slice(0,s+i.index+t+a),l=o.slice(s,-s);return{type:"del",raw:o,text:l,tokens:this.lexer.inlineTokens(l)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,s;return s="@"===t[2]?"mailto:"+(e=t[1]):e=t[1],{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,s;if("@"===t[2])s="mailto:"+(e=t[0]);else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0])e=t[0],s="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:s,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}constructor(e){i(this,"options",void 0),i(this,"rules",void 0),i(this,"lexer",void 0),this.options=e||r}},em=class e{static get rules(){return{block:ea,inline:er}}static lex(t,s){return new e(s).lex(t)}static lexInline(t,s){return new e(s).inlineTokens(t)}lex(e){e=e.replace(h.carriageReturn,`
91
91
  `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){for(this.options.pedantic&&(e=e.replace(h.tabCharGlobal," ").replace(h.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(s=>!!(i=s.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let s=t.at(-1);1===i.raw.length&&void 0!==s?s.raw+=`
92
92
  `:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
93
93
  `)?"":`
@@ -95,13 +95,13 @@ ${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
95
95
  `+i.text,this.inlineQueue.at(-1).src=s.text):t.push(i);continue}if((i=this.tokenizer.fences(e))||(i=this.tokenizer.heading(e))||(i=this.tokenizer.hr(e))||(i=this.tokenizer.blockquote(e))||(i=this.tokenizer.list(e))||(i=this.tokenizer.html(e))){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
96
96
  `)?"":`
97
97
  `)+i.raw,s.text+=`
98
- `+i.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if((i=this.tokenizer.table(e))||(i=this.tokenizer.lheading(e))){e=e.substring(i.raw.length),t.push(i);continue}let n=e;if(this.options.extensions?.startBlock){let t=1/0,s=e.slice(1),i;this.options.extensions.startBlock.forEach(e=>{"number"==typeof(i=e.call({lexer:this},s))&&i>=0&&(t=Math.min(t,i))}),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(n))){let r=t.at(-1);s&&r?.type==="paragraph"?(r.raw+=(r.raw.endsWith(`
98
+ `+i.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if((i=this.tokenizer.table(e))||(i=this.tokenizer.lheading(e))){e=e.substring(i.raw.length),t.push(i);continue}let n=e;if(this.options.extensions?.startBlock){let t=1/0,s=e.slice(1),i;this.options.extensions.startBlock.forEach(e=>{"number"==typeof(i=e.call({lexer:this},s))&&i>=0&&(t=Math.min(t,i))}),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(n))){let a=t.at(-1);s&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
99
99
  `)?"":`
100
- `)+i.raw,r.text+=`
101
- `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),s=n.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let s=t.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
100
+ `)+i.raw,a.text+=`
101
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(i),s=n.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let s=t.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
102
102
  `)?"":`
103
103
  `)+i.raw,s.text+=`
104
- `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent)break;throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let s,i=e,n=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(n=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(n=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,n.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(n=this.tokenizer.rules.inline.blockSkip.exec(i));)s=n[2]?n[2].length:0,i=i.slice(0,n.index+s)+"["+"a".repeat(n[0].length-s-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,a="";for(;e;){let s;if(r||(a=""),r=!1,this.options.extensions?.inline?.some(i=>!!(s=i.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))continue;if((s=this.tokenizer.escape(e))||(s=this.tokenizer.tag(e))||(s=this.tokenizer.link(e))){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let i=t.at(-1);"text"===s.type&&i?.type==="text"?(i.raw+=s.raw,i.text+=s.text):t.push(s);continue}if((s=this.tokenizer.emStrong(e,i,a))||(s=this.tokenizer.codespan(e))||(s=this.tokenizer.br(e))||(s=this.tokenizer.del(e,i,a))||(s=this.tokenizer.autolink(e))||!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),t.push(s);continue}let n=e;if(this.options.extensions?.startInline){let t=1/0,s=e.slice(1),i;this.options.extensions.startInline.forEach(e=>{"number"==typeof(i=e.call({lexer:this},s))&&i>=0&&(t=Math.min(t,i))}),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(s=this.tokenizer.inlineText(n)){e=e.substring(s.raw.length),"_"!==s.raw.slice(-1)&&(a=s.raw.slice(-1)),r=!0;let i=t.at(-1);i?.type==="text"?(i.raw+=s.raw,i.text+=s.text):t.push(s);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent)break;throw Error(t)}}return t}constructor(e){i(this,"tokens",void 0),i(this,"options",void 0),i(this,"state",void 0),i(this,"inlineQueue",void 0),i(this,"tokenizer",void 0),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||a,this.options.tokenizer=this.options.tokenizer||new eg,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:h,block:er.normal,inline:ea.normal};this.options.pedantic?(t.block=er.pedantic,t.inline=ea.pedantic):this.options.gfm&&(t.block=er.gfm,this.options.breaks?t.inline=ea.breaks:t.inline=ea.gfm),this.tokenizer.rules=t}},ef=class{space(e){return""}code({text:e,lang:t,escaped:s}){let i=(t||"").match(h.notSpaceStart)?.[0],n=e.replace(h.endingNewline,"")+`
104
+ `+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent)break;throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let s,i=e,n=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(n=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(n[0].slice(n[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,n.index)+"["+"a".repeat(n[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(n=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,n.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(n=this.tokenizer.rules.inline.blockSkip.exec(i));)s=n[2]?n[2].length:0,i=i.slice(0,n.index+s)+"["+"a".repeat(n[0].length-s-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let a=!1,r="";for(;e;){let s;if(a||(r=""),a=!1,this.options.extensions?.inline?.some(i=>!!(s=i.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))continue;if((s=this.tokenizer.escape(e))||(s=this.tokenizer.tag(e))||(s=this.tokenizer.link(e))){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(s.raw.length);let i=t.at(-1);"text"===s.type&&i?.type==="text"?(i.raw+=s.raw,i.text+=s.text):t.push(s);continue}if((s=this.tokenizer.emStrong(e,i,r))||(s=this.tokenizer.codespan(e))||(s=this.tokenizer.br(e))||(s=this.tokenizer.del(e,i,r))||(s=this.tokenizer.autolink(e))||!this.state.inLink&&(s=this.tokenizer.url(e))){e=e.substring(s.raw.length),t.push(s);continue}let n=e;if(this.options.extensions?.startInline){let t=1/0,s=e.slice(1),i;this.options.extensions.startInline.forEach(e=>{"number"==typeof(i=e.call({lexer:this},s))&&i>=0&&(t=Math.min(t,i))}),t<1/0&&t>=0&&(n=e.substring(0,t+1))}if(s=this.tokenizer.inlineText(n)){e=e.substring(s.raw.length),"_"!==s.raw.slice(-1)&&(r=s.raw.slice(-1)),a=!0;let i=t.at(-1);i?.type==="text"?(i.raw+=s.raw,i.text+=s.text):t.push(s);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent)break;throw Error(t)}}return t}constructor(e){i(this,"tokens",void 0),i(this,"options",void 0),i(this,"state",void 0),i(this,"inlineQueue",void 0),i(this,"tokenizer",void 0),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||r,this.options.tokenizer=this.options.tokenizer||new eg,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:h,block:ea.normal,inline:er.normal};this.options.pedantic?(t.block=ea.pedantic,t.inline=er.pedantic):this.options.gfm&&(t.block=ea.gfm,this.options.breaks?t.inline=er.breaks:t.inline=er.gfm),this.tokenizer.rules=t}},ef=class{space(e){return""}code({text:e,lang:t,escaped:s}){let i=(t||"").match(h.notSpaceStart)?.[0],n=e.replace(h.endingNewline,"")+`
105
105
  `;return i?'<pre><code class="language-'+ec(i)+'">'+(s?n:ec(n,!0))+`</code></pre>
106
106
  `:"<pre><code>"+(s?n:ec(n,!0))+`</code></pre>
107
107
  `}blockquote({tokens:e}){return`<blockquote>
@@ -119,5 +119,5 @@ ${this.parser.parse(e)}</blockquote>
119
119
  `}tablerow({text:e}){return`<tr>
120
120
  ${e}</tr>
121
121
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),s=e.header?"th":"td";return(e.align?`<${s} align="${e.align}">`:`<${s}>`)+t+`</${s}>
122
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ec(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:s}){let i=this.parser.parseInline(s),n=eh(e);if(null===n)return i;let r='<a href="'+(e=n)+'"';return t&&(r+=' title="'+ec(t)+'"'),r+=">"+i+"</a>"}image({href:e,title:t,text:s,tokens:i}){i&&(s=this.parser.parseInline(i,this.parser.textRenderer));let n=eh(e);if(null===n)return ec(s);e=n;let r=`<img src="${e}" alt="${ec(s)}"`;return t&&(r+=` title="${ec(t)}"`),r+=">"}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ec(e.text)}constructor(e){i(this,"options",void 0),i(this,"parser",void 0),this.options=e||a}},ev=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},eC=class e{static parse(t,s){return new e(s).parse(t)}static parseInline(t,s){return new e(s).parseInline(t)}parse(e){let t="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){t+=e||"";continue}}switch(i.type){case"space":t+=this.renderer.space(i);break;case"hr":t+=this.renderer.hr(i);break;case"heading":t+=this.renderer.heading(i);break;case"code":t+=this.renderer.code(i);break;case"table":t+=this.renderer.table(i);break;case"blockquote":t+=this.renderer.blockquote(i);break;case"list":t+=this.renderer.list(i);break;case"checkbox":t+=this.renderer.checkbox(i);break;case"html":t+=this.renderer.html(i);break;case"def":t+=this.renderer.def(i);break;case"paragraph":t+=this.renderer.paragraph(i);break;case"text":t+=this.renderer.text(i);break;default:{let e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return"";throw Error(e)}}}return t}parseInline(e,t=this.renderer){let s="";for(let i=0;i<e.length;i++){let n=e[i];if(this.options.extensions?.renderers?.[n.type]){let e=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){s+=e||"";continue}}switch(n.type){case"escape":case"text":s+=t.text(n);break;case"html":s+=t.html(n);break;case"link":s+=t.link(n);break;case"image":s+=t.image(n);break;case"checkbox":s+=t.checkbox(n);break;case"strong":s+=t.strong(n);break;case"em":s+=t.em(n);break;case"codespan":s+=t.codespan(n);break;case"br":s+=t.br(n);break;case"del":s+=t.del(n);break;default:{let e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return"";throw Error(e)}}}return s}constructor(e){i(this,"options",void 0),i(this,"renderer",void 0),i(this,"textRenderer",void 0),this.options=e||a,this.options.renderer=this.options.renderer||new ef,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ev}},ew=(r=class{preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?em.lex:em.lexInline}provideParser(){return this.block?eC.parse:eC.parseInline}constructor(e){i(this,"options",void 0),i(this,"block",void 0),this.options=e||a}},i(r,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),i(r,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),r),ex=new class{walkTokens(e,t){let s=[];for(let i of e)switch(s=s.concat(t.call(this,i)),i.type){case"table":for(let e of i.header)s=s.concat(this.walkTokens(e.tokens,t));for(let e of i.rows)for(let i of e)s=s.concat(this.walkTokens(i.tokens,t));break;case"list":s=s.concat(this.walkTokens(i.items,t));break;default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let n=e[i].flat(1/0);s=s.concat(this.walkTokens(n,t))}):e.tokens&&(s=s.concat(this.walkTokens(e.tokens,t)))}}return s}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let s={...e};if(s.async=this.defaults.async||s.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error("extension name required");if("renderer"in e){let s=t.renderers[e.name];s?t.renderers[e.name]=function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=s.apply(this,t)),i}:t.renderers[e.name]=e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw Error("extension level must be 'block' or 'inline'");let s=t[e.level];s?s.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),s.extensions=t),e.renderer){let t=this.defaults.renderer||new ef(this.defaults);for(let s in e.renderer){if(!(s in t))throw Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=e.renderer[s],n=t[s];t[s]=(...e)=>{let s=i.apply(t,e);return!1===s&&(s=n.apply(t,e)),s||""}}s.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new eg(this.defaults);for(let s in e.tokenizer){if(!(s in t))throw Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=e.tokenizer[s],n=t[s];t[s]=(...e)=>{let s=i.apply(t,e);return!1===s&&(s=n.apply(t,e)),s}}s.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ew;for(let s in e.hooks){if(!(s in t))throw Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=e.hooks[s],n=t[s];ew.passThroughHooks.has(s)?t[s]=e=>{if(this.defaults.async&&ew.passThroughHooksRespectAsync.has(s))return(async()=>{let s=await i.call(t,e);return n.call(t,s)})();let r=i.call(t,e);return n.call(t,r)}:t[s]=(...e)=>{if(this.defaults.async)return(async()=>{let s=await i.apply(t,e);return!1===s&&(s=await n.apply(t,e)),s})();let s=i.apply(t,e);return!1===s&&(s=n.apply(t,e)),s}}s.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;s.walkTokens=function(e){let s=[];return s.push(i.call(this,e)),t&&(s=s.concat(t.call(this,e))),s}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return em.lex(e,t??this.defaults)}parser(e,t){return eC.parse(e,t??this.defaults)}parseMarkdown(e){return(t,s)=>{let i={...s},n={...this.defaults,...i},r=this.onError(!!n.silent,!!n.async);if(!0===this.defaults.async&&!1===i.async)return r(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return r(Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return r(Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=e),n.async)return(async()=>{let s=n.hooks?await n.hooks.preprocess(t):t,i=await (n.hooks?await n.hooks.provideLexer():e?em.lex:em.lexInline)(s,n),r=n.hooks?await n.hooks.processAllTokens(i):i;n.walkTokens&&await Promise.all(this.walkTokens(r,n.walkTokens));let a=await (n.hooks?await n.hooks.provideParser():e?eC.parse:eC.parseInline)(r,n);return n.hooks?await n.hooks.postprocess(a):a})().catch(r);try{n.hooks&&(t=n.hooks.preprocess(t));let s=(n.hooks?n.hooks.provideLexer():e?em.lex:em.lexInline)(t,n);n.hooks&&(s=n.hooks.processAllTokens(s)),n.walkTokens&&this.walkTokens(s,n.walkTokens);let i=(n.hooks?n.hooks.provideParser():e?eC.parse:eC.parseInline)(s,n);return n.hooks&&(i=n.hooks.postprocess(i)),i}catch(e){return r(e)}}}onError(e,t){return s=>{if(s.message+=`
123
- Please report this to https://github.com/markedjs/marked.`,e){let e="<p>An error occurred:</p><pre>"+ec(s.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(s);throw s}}constructor(...e){i(this,"defaults",n()),i(this,"options",this.setOptions),i(this,"parse",this.parseMarkdown(!0)),i(this,"parseInline",this.parseMarkdown(!1)),i(this,"Parser",eC),i(this,"Renderer",ef),i(this,"TextRenderer",ev),i(this,"Lexer",em),i(this,"Tokenizer",eg),i(this,"Hooks",ew),this.use(...e)}};function ey(e,t){return ex.parse(e,t)}ey.options=ey.setOptions=function(e){return ex.setOptions(e),ey.defaults=ex.defaults,a=ey.defaults,ey},ey.getDefaults=n,ey.defaults=a,ey.use=function(...e){return ex.use(...e),ey.defaults=ex.defaults,a=ey.defaults,ey},ey.walkTokens=function(e,t){return ex.walkTokens(e,t)},ey.parseInline=ex.parseInline,ey.Parser=eC,ey.parser=eC.parse,ey.Renderer=ef,ey.TextRenderer=ev,ey.Lexer=em,ey.lexer=em.lex,ey.Tokenizer=eg,ey.Hooks=ew,ey.parse=ey,ey.options,ey.setOptions,ey.use,ey.walkTokens,ey.parseInline,eC.parse,em.lex}},function(e){return e(e.s=41810)}])});
122
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ec(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:s}){let i=this.parser.parseInline(s),n=eh(e);if(null===n)return i;let a='<a href="'+(e=n)+'"';return t&&(a+=' title="'+ec(t)+'"'),a+=">"+i+"</a>"}image({href:e,title:t,text:s,tokens:i}){i&&(s=this.parser.parseInline(i,this.parser.textRenderer));let n=eh(e);if(null===n)return ec(s);e=n;let a=`<img src="${e}" alt="${ec(s)}"`;return t&&(a+=` title="${ec(t)}"`),a+=">"}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ec(e.text)}constructor(e){i(this,"options",void 0),i(this,"parser",void 0),this.options=e||r}},ev=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},eC=class e{static parse(t,s){return new e(s).parse(t)}static parseInline(t,s){return new e(s).parseInline(t)}parse(e){let t="";for(let s=0;s<e.length;s++){let i=e[s];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(!1!==e||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){t+=e||"";continue}}switch(i.type){case"space":t+=this.renderer.space(i);break;case"hr":t+=this.renderer.hr(i);break;case"heading":t+=this.renderer.heading(i);break;case"code":t+=this.renderer.code(i);break;case"table":t+=this.renderer.table(i);break;case"blockquote":t+=this.renderer.blockquote(i);break;case"list":t+=this.renderer.list(i);break;case"checkbox":t+=this.renderer.checkbox(i);break;case"html":t+=this.renderer.html(i);break;case"def":t+=this.renderer.def(i);break;case"paragraph":t+=this.renderer.paragraph(i);break;case"text":t+=this.renderer.text(i);break;default:{let e='Token with "'+i.type+'" type was not found.';if(this.options.silent)return"";throw Error(e)}}}return t}parseInline(e,t=this.renderer){let s="";for(let i=0;i<e.length;i++){let n=e[i];if(this.options.extensions?.renderers?.[n.type]){let e=this.options.extensions.renderers[n.type].call({parser:this},n);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(n.type)){s+=e||"";continue}}switch(n.type){case"escape":case"text":s+=t.text(n);break;case"html":s+=t.html(n);break;case"link":s+=t.link(n);break;case"image":s+=t.image(n);break;case"checkbox":s+=t.checkbox(n);break;case"strong":s+=t.strong(n);break;case"em":s+=t.em(n);break;case"codespan":s+=t.codespan(n);break;case"br":s+=t.br(n);break;case"del":s+=t.del(n);break;default:{let e='Token with "'+n.type+'" type was not found.';if(this.options.silent)return"";throw Error(e)}}}return s}constructor(e){i(this,"options",void 0),i(this,"renderer",void 0),i(this,"textRenderer",void 0),this.options=e||r,this.options.renderer=this.options.renderer||new ef,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ev}},ew=(a=class{preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?em.lex:em.lexInline}provideParser(){return this.block?eC.parse:eC.parseInline}constructor(e){i(this,"options",void 0),i(this,"block",void 0),this.options=e||r}},i(a,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),i(a,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),a),ex=new class{walkTokens(e,t){let s=[];for(let i of e)switch(s=s.concat(t.call(this,i)),i.type){case"table":for(let e of i.header)s=s.concat(this.walkTokens(e.tokens,t));for(let e of i.rows)for(let i of e)s=s.concat(this.walkTokens(i.tokens,t));break;case"list":s=s.concat(this.walkTokens(i.items,t));break;default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let n=e[i].flat(1/0);s=s.concat(this.walkTokens(n,t))}):e.tokens&&(s=s.concat(this.walkTokens(e.tokens,t)))}}return s}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let s={...e};if(s.async=this.defaults.async||s.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error("extension name required");if("renderer"in e){let s=t.renderers[e.name];s?t.renderers[e.name]=function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=s.apply(this,t)),i}:t.renderers[e.name]=e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw Error("extension level must be 'block' or 'inline'");let s=t[e.level];s?s.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),s.extensions=t),e.renderer){let t=this.defaults.renderer||new ef(this.defaults);for(let s in e.renderer){if(!(s in t))throw Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=e.renderer[s],n=t[s];t[s]=(...e)=>{let s=i.apply(t,e);return!1===s&&(s=n.apply(t,e)),s||""}}s.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new eg(this.defaults);for(let s in e.tokenizer){if(!(s in t))throw Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=e.tokenizer[s],n=t[s];t[s]=(...e)=>{let s=i.apply(t,e);return!1===s&&(s=n.apply(t,e)),s}}s.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ew;for(let s in e.hooks){if(!(s in t))throw Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=e.hooks[s],n=t[s];ew.passThroughHooks.has(s)?t[s]=e=>{if(this.defaults.async&&ew.passThroughHooksRespectAsync.has(s))return(async()=>{let s=await i.call(t,e);return n.call(t,s)})();let a=i.call(t,e);return n.call(t,a)}:t[s]=(...e)=>{if(this.defaults.async)return(async()=>{let s=await i.apply(t,e);return!1===s&&(s=await n.apply(t,e)),s})();let s=i.apply(t,e);return!1===s&&(s=n.apply(t,e)),s}}s.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;s.walkTokens=function(e){let s=[];return s.push(i.call(this,e)),t&&(s=s.concat(t.call(this,e))),s}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return em.lex(e,t??this.defaults)}parser(e,t){return eC.parse(e,t??this.defaults)}parseMarkdown(e){return(t,s)=>{let i={...s},n={...this.defaults,...i},a=this.onError(!!n.silent,!!n.async);if(!0===this.defaults.async&&!1===i.async)return a(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return a(Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return a(Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(n.hooks&&(n.hooks.options=n,n.hooks.block=e),n.async)return(async()=>{let s=n.hooks?await n.hooks.preprocess(t):t,i=await (n.hooks?await n.hooks.provideLexer():e?em.lex:em.lexInline)(s,n),a=n.hooks?await n.hooks.processAllTokens(i):i;n.walkTokens&&await Promise.all(this.walkTokens(a,n.walkTokens));let r=await (n.hooks?await n.hooks.provideParser():e?eC.parse:eC.parseInline)(a,n);return n.hooks?await n.hooks.postprocess(r):r})().catch(a);try{n.hooks&&(t=n.hooks.preprocess(t));let s=(n.hooks?n.hooks.provideLexer():e?em.lex:em.lexInline)(t,n);n.hooks&&(s=n.hooks.processAllTokens(s)),n.walkTokens&&this.walkTokens(s,n.walkTokens);let i=(n.hooks?n.hooks.provideParser():e?eC.parse:eC.parseInline)(s,n);return n.hooks&&(i=n.hooks.postprocess(i)),i}catch(e){return a(e)}}}onError(e,t){return s=>{if(s.message+=`
123
+ Please report this to https://github.com/markedjs/marked.`,e){let e="<p>An error occurred:</p><pre>"+ec(s.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(s);throw s}}constructor(...e){i(this,"defaults",n()),i(this,"options",this.setOptions),i(this,"parse",this.parseMarkdown(!0)),i(this,"parseInline",this.parseMarkdown(!1)),i(this,"Parser",eC),i(this,"Renderer",ef),i(this,"TextRenderer",ev),i(this,"Lexer",em),i(this,"Tokenizer",eg),i(this,"Hooks",ew),this.use(...e)}};function ey(e,t){return ex.parse(e,t)}ey.options=ey.setOptions=function(e){return ex.setOptions(e),ey.defaults=ex.defaults,r=ey.defaults,ey},ey.getDefaults=n,ey.defaults=r,ey.use=function(...e){return ex.use(...e),ey.defaults=ex.defaults,r=ey.defaults,ey},ey.walkTokens=function(e,t){return ex.walkTokens(e,t)},ey.parseInline=ex.parseInline,ey.Parser=eC,ey.parser=eC.parse,ey.Renderer=ef,ey.TextRenderer=ev,ey.Lexer=em,ey.lexer=em.lex,ey.Tokenizer=eg,ey.Hooks=ew,ey.parse=ey,ey.options,ey.setOptions,ey.use,ey.walkTokens,ey.parseInline,eC.parse,em.lex}},function(e){return e(e.s=41810)}])});