jodit-pro 4.9.4 → 4.9.12
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.
- package/CHANGELOG.md +44 -2
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +6 -6
- package/es2015/jodit.js +5 -3
- package/es2015/jodit.min.js +2 -2
- package/es2015/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
- package/es2015/plugins/ai-assistant-pro/ai-assistant-pro.js +10 -4
- package/es2015/plugins/ai-assistant-pro/ai-assistant-pro.min.js +6 -6
- package/es2015/plugins/autocomplete/autocomplete.js +1 -1
- package/es2015/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es2015/plugins/backup/backup.css +1 -1
- package/es2015/plugins/backup/backup.js +1 -1
- package/es2015/plugins/backup/backup.min.js +1 -1
- package/es2015/plugins/button-generator/button-generator.css +1 -1
- package/es2015/plugins/button-generator/button-generator.js +1 -1
- package/es2015/plugins/button-generator/button-generator.min.js +1 -1
- package/es2015/plugins/change-case/change-case.js +1 -1
- package/es2015/plugins/change-case/change-case.min.js +1 -1
- package/es2015/plugins/color-picker/color-picker.css +1 -1
- package/es2015/plugins/color-picker/color-picker.js +1 -1
- package/es2015/plugins/color-picker/color-picker.min.js +1 -1
- package/es2015/plugins/emoji/emoji.css +1 -1
- package/es2015/plugins/emoji/emoji.js +1 -1
- package/es2015/plugins/emoji/emoji.min.js +1 -1
- package/es2015/plugins/export-docs/export-docs.js +1 -1
- package/es2015/plugins/export-docs/export-docs.min.js +1 -1
- package/es2015/plugins/finder/finder.css +1 -1
- package/es2015/plugins/finder/finder.js +1 -1
- package/es2015/plugins/finder/finder.min.js +1 -1
- package/es2015/plugins/google-maps/google-maps.css +1 -1
- package/es2015/plugins/google-maps/google-maps.js +1 -1
- package/es2015/plugins/google-maps/google-maps.min.js +1 -1
- package/es2015/plugins/google-search/google-search.js +1 -1
- package/es2015/plugins/google-search/google-search.min.js +1 -1
- package/es2015/plugins/highlight-signature/highlight-signature.js +1 -1
- package/es2015/plugins/highlight-signature/highlight-signature.min.js +1 -1
- package/es2015/plugins/iframe-editor/iframe-editor.css +1 -1
- package/es2015/plugins/iframe-editor/iframe-editor.js +1 -1
- package/es2015/plugins/iframe-editor/iframe-editor.min.js +1 -1
- package/es2015/plugins/keyboard/keyboard.css +1 -1
- package/es2015/plugins/keyboard/keyboard.js +1 -1
- package/es2015/plugins/keyboard/keyboard.min.js +1 -1
- package/es2015/plugins/mobile-view/mobile-view.js +1 -1
- package/es2015/plugins/mobile-view/mobile-view.min.js +1 -1
- package/es2015/plugins/page-break/page-break.js +1 -1
- package/es2015/plugins/page-break/page-break.min.js +1 -1
- package/es2015/plugins/paste-code/paste-code.css +1 -1
- package/es2015/plugins/paste-code/paste-code.js +1 -1
- package/es2015/plugins/paste-code/paste-code.min.js +1 -1
- package/es2015/plugins/paste-from-word/paste-from-word.js +1 -1
- package/es2015/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es2015/plugins/show-blocks/show-blocks.js +1 -1
- package/es2015/plugins/show-blocks/show-blocks.min.js +1 -1
- package/es2015/plugins/todo-list/todo-list.css +1 -1
- package/es2015/plugins/todo-list/todo-list.js +1 -1
- package/es2015/plugins/todo-list/todo-list.min.js +1 -1
- package/es2015/plugins/translate/translate.css +1 -1
- package/es2015/plugins/translate/translate.js +1 -1
- package/es2015/plugins/translate/translate.min.js +1 -1
- package/es2015/plugins/tune-block/tune-block.css +1 -1
- package/es2015/plugins/tune-block/tune-block.js +1 -1
- package/es2015/plugins/tune-block/tune-block.min.js +1 -1
- package/es2018/jodit.fat.min.js +6 -6
- package/es2018/jodit.min.js +2 -2
- package/es2018/plugins/ai-assistant-pro/ai-assistant-pro.min.js +7 -7
- package/es2018/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es2018/plugins/backup/backup.min.js +1 -1
- package/es2018/plugins/button-generator/button-generator.min.js +1 -1
- package/es2018/plugins/change-case/change-case.min.js +1 -1
- package/es2018/plugins/color-picker/color-picker.min.js +1 -1
- package/es2018/plugins/emoji/emoji.min.js +1 -1
- package/es2018/plugins/export-docs/export-docs.min.js +1 -1
- package/es2018/plugins/finder/finder.min.js +1 -1
- package/es2018/plugins/google-maps/google-maps.min.js +1 -1
- package/es2018/plugins/google-search/google-search.min.js +1 -1
- package/es2018/plugins/highlight-signature/highlight-signature.min.js +1 -1
- package/es2018/plugins/iframe-editor/iframe-editor.min.js +1 -1
- package/es2018/plugins/keyboard/keyboard.min.js +1 -1
- package/es2018/plugins/mobile-view/mobile-view.min.js +1 -1
- package/es2018/plugins/page-break/page-break.min.js +1 -1
- package/es2018/plugins/paste-code/paste-code.min.js +1 -1
- package/es2018/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es2018/plugins/show-blocks/show-blocks.min.js +1 -1
- package/es2018/plugins/todo-list/todo-list.min.js +1 -1
- package/es2018/plugins/translate/translate.min.js +1 -1
- package/es2018/plugins/tune-block/tune-block.min.js +1 -1
- package/es2021/jodit.css +1 -1
- package/es2021/jodit.fat.min.js +6 -6
- package/es2021/jodit.js +5 -3
- package/es2021/jodit.min.js +2 -2
- package/es2021/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
- package/es2021/plugins/ai-assistant-pro/ai-assistant-pro.js +9 -4
- package/es2021/plugins/ai-assistant-pro/ai-assistant-pro.min.js +28 -28
- package/es2021/plugins/autocomplete/autocomplete.js +1 -1
- package/es2021/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es2021/plugins/backup/backup.css +1 -1
- package/es2021/plugins/backup/backup.js +1 -1
- package/es2021/plugins/backup/backup.min.js +1 -1
- package/es2021/plugins/button-generator/button-generator.css +1 -1
- package/es2021/plugins/button-generator/button-generator.js +1 -1
- package/es2021/plugins/button-generator/button-generator.min.js +1 -1
- package/es2021/plugins/change-case/change-case.js +1 -1
- package/es2021/plugins/change-case/change-case.min.js +1 -1
- package/es2021/plugins/color-picker/color-picker.css +1 -1
- package/es2021/plugins/color-picker/color-picker.js +1 -1
- package/es2021/plugins/color-picker/color-picker.min.js +1 -1
- package/es2021/plugins/emoji/emoji.css +1 -1
- package/es2021/plugins/emoji/emoji.js +1 -1
- package/es2021/plugins/emoji/emoji.min.js +1 -1
- package/es2021/plugins/export-docs/export-docs.js +1 -1
- package/es2021/plugins/export-docs/export-docs.min.js +1 -1
- package/es2021/plugins/finder/finder.css +1 -1
- package/es2021/plugins/finder/finder.js +1 -1
- package/es2021/plugins/finder/finder.min.js +1 -1
- package/es2021/plugins/google-maps/google-maps.css +1 -1
- package/es2021/plugins/google-maps/google-maps.js +1 -1
- package/es2021/plugins/google-maps/google-maps.min.js +1 -1
- package/es2021/plugins/google-search/google-search.js +1 -1
- package/es2021/plugins/google-search/google-search.min.js +1 -1
- package/es2021/plugins/highlight-signature/highlight-signature.js +1 -1
- package/es2021/plugins/highlight-signature/highlight-signature.min.js +1 -1
- package/es2021/plugins/iframe-editor/iframe-editor.css +1 -1
- package/es2021/plugins/iframe-editor/iframe-editor.js +1 -1
- package/es2021/plugins/iframe-editor/iframe-editor.min.js +1 -1
- package/es2021/plugins/keyboard/keyboard.css +1 -1
- package/es2021/plugins/keyboard/keyboard.js +1 -1
- package/es2021/plugins/keyboard/keyboard.min.js +1 -1
- package/es2021/plugins/mobile-view/mobile-view.js +1 -1
- package/es2021/plugins/mobile-view/mobile-view.min.js +1 -1
- package/es2021/plugins/page-break/page-break.js +1 -1
- package/es2021/plugins/page-break/page-break.min.js +1 -1
- package/es2021/plugins/paste-code/paste-code.css +1 -1
- package/es2021/plugins/paste-code/paste-code.js +1 -1
- package/es2021/plugins/paste-code/paste-code.min.js +1 -1
- package/es2021/plugins/paste-from-word/paste-from-word.js +1 -1
- package/es2021/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es2021/plugins/show-blocks/show-blocks.js +1 -1
- package/es2021/plugins/show-blocks/show-blocks.min.js +1 -1
- package/es2021/plugins/todo-list/todo-list.css +1 -1
- package/es2021/plugins/todo-list/todo-list.js +1 -1
- package/es2021/plugins/todo-list/todo-list.min.js +1 -1
- package/es2021/plugins/translate/translate.css +1 -1
- package/es2021/plugins/translate/translate.js +1 -1
- package/es2021/plugins/translate/translate.min.js +1 -1
- package/es2021/plugins/tune-block/tune-block.css +1 -1
- package/es2021/plugins/tune-block/tune-block.js +1 -1
- package/es2021/plugins/tune-block/tune-block.min.js +1 -1
- package/es2021.en/jodit.css +1 -1
- package/es2021.en/jodit.fat.min.js +6 -6
- package/es2021.en/jodit.js +5 -3
- package/es2021.en/jodit.min.js +2 -2
- package/es2021.en/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
- package/es2021.en/plugins/ai-assistant-pro/ai-assistant-pro.js +9 -4
- package/es2021.en/plugins/ai-assistant-pro/ai-assistant-pro.min.js +7 -7
- package/es2021.en/plugins/autocomplete/autocomplete.js +1 -1
- package/es2021.en/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es2021.en/plugins/backup/backup.css +1 -1
- package/es2021.en/plugins/backup/backup.js +1 -1
- package/es2021.en/plugins/backup/backup.min.js +1 -1
- package/es2021.en/plugins/button-generator/button-generator.css +1 -1
- package/es2021.en/plugins/button-generator/button-generator.js +1 -1
- package/es2021.en/plugins/button-generator/button-generator.min.js +1 -1
- package/es2021.en/plugins/change-case/change-case.js +1 -1
- package/es2021.en/plugins/change-case/change-case.min.js +1 -1
- package/es2021.en/plugins/color-picker/color-picker.css +1 -1
- package/es2021.en/plugins/color-picker/color-picker.js +1 -1
- package/es2021.en/plugins/color-picker/color-picker.min.js +1 -1
- package/es2021.en/plugins/emoji/emoji.css +1 -1
- package/es2021.en/plugins/emoji/emoji.js +1 -1
- package/es2021.en/plugins/emoji/emoji.min.js +1 -1
- package/es2021.en/plugins/export-docs/export-docs.js +1 -1
- package/es2021.en/plugins/export-docs/export-docs.min.js +1 -1
- package/es2021.en/plugins/finder/finder.css +1 -1
- package/es2021.en/plugins/finder/finder.js +1 -1
- package/es2021.en/plugins/finder/finder.min.js +1 -1
- package/es2021.en/plugins/google-maps/google-maps.css +1 -1
- package/es2021.en/plugins/google-maps/google-maps.js +1 -1
- package/es2021.en/plugins/google-maps/google-maps.min.js +1 -1
- package/es2021.en/plugins/google-search/google-search.js +1 -1
- package/es2021.en/plugins/google-search/google-search.min.js +1 -1
- package/es2021.en/plugins/highlight-signature/highlight-signature.js +1 -1
- package/es2021.en/plugins/highlight-signature/highlight-signature.min.js +1 -1
- package/es2021.en/plugins/iframe-editor/iframe-editor.css +1 -1
- package/es2021.en/plugins/iframe-editor/iframe-editor.js +1 -1
- package/es2021.en/plugins/iframe-editor/iframe-editor.min.js +1 -1
- package/es2021.en/plugins/keyboard/keyboard.css +1 -1
- package/es2021.en/plugins/keyboard/keyboard.js +1 -1
- package/es2021.en/plugins/keyboard/keyboard.min.js +1 -1
- package/es2021.en/plugins/mobile-view/mobile-view.js +1 -1
- package/es2021.en/plugins/mobile-view/mobile-view.min.js +1 -1
- package/es2021.en/plugins/page-break/page-break.js +1 -1
- package/es2021.en/plugins/page-break/page-break.min.js +1 -1
- package/es2021.en/plugins/paste-code/paste-code.css +1 -1
- package/es2021.en/plugins/paste-code/paste-code.js +1 -1
- package/es2021.en/plugins/paste-code/paste-code.min.js +1 -1
- package/es2021.en/plugins/paste-from-word/paste-from-word.js +1 -1
- package/es2021.en/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es2021.en/plugins/show-blocks/show-blocks.js +1 -1
- package/es2021.en/plugins/show-blocks/show-blocks.min.js +1 -1
- package/es2021.en/plugins/todo-list/todo-list.css +1 -1
- package/es2021.en/plugins/todo-list/todo-list.js +1 -1
- package/es2021.en/plugins/todo-list/todo-list.min.js +1 -1
- package/es2021.en/plugins/translate/translate.css +1 -1
- package/es2021.en/plugins/translate/translate.js +1 -1
- package/es2021.en/plugins/translate/translate.min.js +1 -1
- package/es2021.en/plugins/tune-block/tune-block.css +1 -1
- package/es2021.en/plugins/tune-block/tune-block.js +1 -1
- package/es2021.en/plugins/tune-block/tune-block.min.js +1 -1
- package/es5/jodit.css +2 -2
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +5 -3
- package/es5/jodit.min.css +2 -2
- package/es5/jodit.min.js +2 -2
- package/es5/plugins/ai-assistant-pro/ai-assistant-pro.css +1 -1
- package/es5/plugins/ai-assistant-pro/ai-assistant-pro.js +11 -5
- package/es5/plugins/ai-assistant-pro/ai-assistant-pro.min.js +2 -2
- package/es5/plugins/autocomplete/autocomplete.js +1 -1
- package/es5/plugins/autocomplete/autocomplete.min.js +1 -1
- package/es5/plugins/backup/backup.css +1 -1
- package/es5/plugins/backup/backup.js +1 -1
- package/es5/plugins/backup/backup.min.js +1 -1
- package/es5/plugins/button-generator/button-generator.css +1 -1
- package/es5/plugins/button-generator/button-generator.js +1 -1
- package/es5/plugins/button-generator/button-generator.min.js +1 -1
- package/es5/plugins/change-case/change-case.js +1 -1
- package/es5/plugins/change-case/change-case.min.js +1 -1
- package/es5/plugins/color-picker/color-picker.css +1 -1
- package/es5/plugins/color-picker/color-picker.js +1 -1
- package/es5/plugins/color-picker/color-picker.min.js +1 -1
- package/es5/plugins/emoji/emoji.css +1 -1
- package/es5/plugins/emoji/emoji.js +1 -1
- package/es5/plugins/emoji/emoji.min.js +1 -1
- package/es5/plugins/export-docs/export-docs.js +1 -1
- package/es5/plugins/export-docs/export-docs.min.js +1 -1
- package/es5/plugins/finder/finder.css +1 -1
- package/es5/plugins/finder/finder.js +1 -1
- package/es5/plugins/finder/finder.min.js +1 -1
- package/es5/plugins/google-maps/google-maps.css +1 -1
- package/es5/plugins/google-maps/google-maps.js +1 -1
- package/es5/plugins/google-maps/google-maps.min.js +1 -1
- package/es5/plugins/google-search/google-search.js +1 -1
- package/es5/plugins/google-search/google-search.min.js +1 -1
- package/es5/plugins/highlight-signature/highlight-signature.js +1 -1
- package/es5/plugins/highlight-signature/highlight-signature.min.js +1 -1
- package/es5/plugins/iframe-editor/iframe-editor.css +1 -1
- package/es5/plugins/iframe-editor/iframe-editor.js +1 -1
- package/es5/plugins/iframe-editor/iframe-editor.min.js +1 -1
- package/es5/plugins/keyboard/keyboard.css +1 -1
- package/es5/plugins/keyboard/keyboard.js +1 -1
- package/es5/plugins/keyboard/keyboard.min.js +1 -1
- package/es5/plugins/mobile-view/mobile-view.js +1 -1
- package/es5/plugins/mobile-view/mobile-view.min.js +1 -1
- package/es5/plugins/page-break/page-break.js +1 -1
- package/es5/plugins/page-break/page-break.min.js +1 -1
- package/es5/plugins/paste-code/paste-code.css +1 -1
- package/es5/plugins/paste-code/paste-code.js +1 -1
- package/es5/plugins/paste-code/paste-code.min.js +1 -1
- package/es5/plugins/paste-from-word/paste-from-word.js +1 -1
- package/es5/plugins/paste-from-word/paste-from-word.min.js +1 -1
- package/es5/plugins/show-blocks/show-blocks.js +1 -1
- package/es5/plugins/show-blocks/show-blocks.min.js +1 -1
- package/es5/plugins/todo-list/todo-list.css +1 -1
- package/es5/plugins/todo-list/todo-list.js +1 -1
- package/es5/plugins/todo-list/todo-list.min.js +1 -1
- package/es5/plugins/translate/translate.css +1 -1
- package/es5/plugins/translate/translate.js +1 -1
- package/es5/plugins/translate/translate.min.js +1 -1
- package/es5/plugins/tune-block/tune-block.css +1 -1
- package/es5/plugins/tune-block/tune-block.js +1 -1
- package/es5/plugins/tune-block/tune-block.min.js +1 -1
- package/es5/polyfills.fat.min.js +1 -1
- package/es5/polyfills.js +1 -1
- package/es5/polyfills.min.js +1 -1
- package/esm/plugins/ai-assistant-pro/ai-assistant-pro.js +2 -2
- package/esm/plugins/ai-assistant-pro/core/ai-response-handler.js +1 -1
- package/esm/plugins/ai-assistant-pro/core/panel-resize.js +1 -1
- package/esm/plugins/ai-assistant-pro/helpers/api-client.js +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* jodit-pro - PRO Version of Jodit Editor
|
|
3
3
|
* Author: Chupurnov Valerii <chupurnov@gmail.com>
|
|
4
|
-
* Version: v4.9.
|
|
4
|
+
* Version: v4.9.12
|
|
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],{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=>{var s;return null==(s=e.toolCalls)?void 0:s.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)}}},2020:function(e,t,s){"use strict";var i=s(96675),n=s(3091);t.default={...i,execute:n.execute}},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{var d;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 null==(d=h.parentNode)||d.replaceChild(s,h),e.synchronizeValues(),{success:!0,message:`Block ${u} replaced successfully`}}catch(e){throw Error(`Failed to replace block ${u}: ${e.message}`)}}},5618:function(e,t,s){"use strict";var i=s(93809),n=s(28157);t.default={...i,execute:n.execute}},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)()}},12570:function(e,t,s){"use strict";var i=s(62553),n=s(56293);t.default={...i,execute:n.execute}},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}})},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){var t,s;return null==(t=this.modelSelect)||t.setParentView(e),null==(s=this.temperatureInput)||s.setParentView(e),super.setParentView(e)}async build(){var e,t,s,i,n;let r=this.container,a=this.getConversation().options||{};if(this.options.dialogSettings.models&&this.options.dialogSettings.models.length>0){let s=this.parseModels(this.options.dialogSettings.models),i=null!=(e=null!=(t=a.model)?t:this.state.defaultModel)?e:s[0].value;this.modelSelect=new o.UISelect(this.j,{label:"Model",name:"model",value:i,options:s,onChange:this.onModelChange.bind(this)}),r.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:null!=(s=null!=(i=a.temperature)?i:this.state.defaultTemperature)?s:.5,onChange:this.onTemperatureChange.bind(this)});let e=this.temperatureInput.nativeInput;e&&e.setAttribute("step",String(null!=(n=this.options.dialogSettings.temperature.step)?n:.1)),r.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=String(this.state.defaultTemperature))}destruct(){var e;null==(e=this.modelSelect)||e.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)},16745:function(e,t,s){"use strict";var i=s(56732),n=s(39592);t.default={...i,execute:n.execute}},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);if(t){if(window.removeEventListener("scroll",t.onScroll),window.removeEventListener("resize",t.onScroll),t.resizeObserver.disconnect(),e.container.parentNode===t.container){var s;null==(s=t.container.parentNode)||s.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)}}},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}`)}}},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()}}},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 i=await this.getAllKeys(),n=[],r=null==e?void 0:e.toLowerCase().trim();for(let e of i){var t,s;let i=await this.get(e);if(i){if(r){let e=null==(s=i.title)?void 0:s.toLowerCase().includes(r),t=!e&&i.messages.some(e=>e.content.toLowerCase().includes(r));if(!e&&!t)continue}n.push({id:i.id,title:null!=(t=i.title)?t:"",created:i.created,updated:i.updated,messageCount:i.messages.length})}}return n.sort((e,t)=>t.updated-e.updated),n}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((null==t?void 0:t.name)==="QuotaExceededError"||(null==t?void 0:t.code)===22||(null==t?void 0: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(e){throw Error("Storage quota exceeded. Please delete some conversations.")}}else throw Error(`Failed to save conversation: ${(null==t?void 0: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(e){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)}`}},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"}},27769:function(e,t,s){"use strict";s.d(t,{UIMainPanel:function(){return i.UIMainPanel}});var i=s(51251)},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}}},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}`)}}},39296:function(e,t,s){"use strict";var i=s(73943),n=s(19127);t.default={...i,execute:n.execute}},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: ${(null==e?void 0:e.message)||"Unknown error"}`)}}},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),w=s(2692),C=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((null==e?void 0: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)}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("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=>{var t;return null==(t=e.toolCalls)?void 0:t.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:String(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,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":C.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(){C.UIFlightPosition.remove(this.mainPanel)}__onSavedStateChange(){var e;let t=this.stateManager.state;return this.storage.saveGlobalSettings({displayMode:t.displayMode,panelWidth:t.panelWidth,panelHeight:t.panelHeight,theme:t.theme,defaultModel:t.defaultModel,defaultTemperature:t.defaultTemperature,currentConversationId:null==(e=t.currentConversation)?void 0:e.id,...this.j.o.aiAssistantPro.persistOpenState?{isOpen:t.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=(null==n?void 0:n.aiCommonPrefixPrompt)||"",o=(null==n?void 0: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],{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=>{var s;return null==(s=e.toolCalls)?void 0:s.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)}}},2020:function(e,t,s){"use strict";var i=s(96675),n=s(3091);t.default={...i,execute:n.execute}},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{var d;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 null==(d=h.parentNode)||d.replaceChild(s,h),e.synchronizeValues(),{success:!0,message:`Block ${u} replaced successfully`}}catch(e){throw Error(`Failed to replace block ${u}: ${e.message}`)}}},5618:function(e,t,s){"use strict";var i=s(93809),n=s(28157);t.default={...i,execute:n.execute}},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)()}},12570:function(e,t,s){"use strict";var i=s(62553),n=s(56293);t.default={...i,execute:n.execute}},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}})},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){var t,s;return null==(t=this.modelSelect)||t.setParentView(e),null==(s=this.temperatureInput)||s.setParentView(e),super.setParentView(e)}async build(){var e,t,s,i,n;let r=this.container,a=this.getConversation().options||{};if(this.options.dialogSettings.models&&this.options.dialogSettings.models.length>0){let s=this.parseModels(this.options.dialogSettings.models),i=null!=(e=null!=(t=a.model)?t:this.state.defaultModel)?e:s[0].value;this.modelSelect=new o.UISelect(this.j,{label:"Model",name:"model",value:i,options:s,onChange:this.onModelChange.bind(this)}),r.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:null!=(s=null!=(i=a.temperature)?i:this.state.defaultTemperature)?s:.5,onChange:this.onTemperatureChange.bind(this)});let e=this.temperatureInput.nativeInput;e&&e.setAttribute("step",String(null!=(n=this.options.dialogSettings.temperature.step)?n:.1)),r.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=String(this.state.defaultTemperature))}destruct(){var e;null==(e=this.modelSelect)||e.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)},16745:function(e,t,s){"use strict";var i=s(56732),n=s(39592);t.default={...i,execute:n.execute}},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);if(t){if(window.removeEventListener("scroll",t.onScroll),window.removeEventListener("resize",t.onScroll),t.resizeObserver.disconnect(),e.container.parentNode===t.container){var s;null==(s=t.container.parentNode)||s.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)}}},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}`)}}},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()}}},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 i=await this.getAllKeys(),n=[],r=null==e?void 0:e.toLowerCase().trim();for(let e of i){var t,s;let i=await this.get(e);if(i){if(r){let e=null==(s=i.title)?void 0:s.toLowerCase().includes(r),t=!e&&i.messages.some(e=>e.content.toLowerCase().includes(r));if(!e&&!t)continue}n.push({id:i.id,title:null!=(t=i.title)?t:"",created:i.created,updated:i.updated,messageCount:i.messages.length})}}return n.sort((e,t)=>t.updated-e.updated),n}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((null==t?void 0:t.name)==="QuotaExceededError"||(null==t?void 0:t.code)===22||(null==t?void 0: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(e){throw Error("Storage quota exceeded. Please delete some conversations.")}}else throw Error(`Failed to save conversation: ${(null==t?void 0: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(e){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)}`}},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"}},27769:function(e,t,s){"use strict";s.d(t,{UIMainPanel:function(){return i.UIMainPanel}});var i=s(51251)},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}}},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}`)}}},39296:function(e,t,s){"use strict";var i=s(73943),n=s(19127);t.default={...i,execute:n.execute}},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: ${(null==e?void 0:e.message)||"Unknown error"}`)}}},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),w=s(2692),C=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((null==e?void 0: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)}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("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=>{var t;return null==(t=e.toolCalls)?void 0:t.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:String(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":C.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(){C.UIFlightPosition.remove(this.mainPanel)}__onSavedStateChange(){var e;let t=this.stateManager.state;return this.storage.saveGlobalSettings({displayMode:t.displayMode,panelWidth:t.panelWidth,panelHeight:t.panelHeight,theme:t.theme,defaultModel:t.defaultModel,defaultTemperature:t.defaultTemperature,currentConversationId:null==(e=t.currentConversation)?void 0:e.id,...this.j.o.aiAssistantPro.persistOpenState?{isOpen:t.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=(null==n?void 0:n.aiCommonPrefixPrompt)||"",o=(null==n?void 0:n.aiCommonSuffixPrompt)||"",l=`${a}${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:String(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 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;await this.__loadData();let{approved:r,needsPermission:a}=this.permissionManager.filterToolCalls(n,s.permissions);for(let s of(this.stateManager.setPendingToolCalls(a),r))await this.executeToolCall(e,s,t)}async executeToolCall(e,t,s=0){await this.__loadData();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(){var e,t,s,i,n,r,a,o;this.__closeFlightMode(),null==(e=(0,g.cached)(this,"toolRegistry"))||e.destruct(),null==(t=(0,g.cached)(this,"permissionManager"))||t.destruct(),null==(s=(0,g.cached)(this,"apiClient"))||s.destruct(),null==(i=(0,g.cached)(this,"stateManager"))||i.destruct(),null==(n=(0,g.cached)(this,"mainPanel"))||n.destruct(),null==(r=(0,g.cached)(this,"dialog"))||r.destruct(),null==(o=(0,g.cached)(this,"storage"))||null==(a=o.close)||a.call(o)}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)(["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),w.JoditPro.plugins.add("aiAssistantPro",y)},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,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}`}}},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()}}},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}})},48705:function(e,t,s){"use strict";s.d(t,{UISettingsButton:function(){return i.UISettingsButton}});var i=s(76697)},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}})},51251:function(e,t,s){"use strict";s.d(t,{UIMainPanel:function(){return m}});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);class m extends p.UIElement{className(){return"UIMainPanel"}setParentView(e){var t,s,i,n,r,a;return null==(t=this.welcomeScreen)||t.setParentView(e),null==(s=this.conversationList)||s.setParentView(e),null==(i=this.messageList)||i.setParentView(e),null==(n=this.inputArea)||n.setParentView(e),null==(r=this.permissionRequest)||r.setParentView(e),null==(a=this.settingsButton)||a.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
|
|
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:String(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 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;await this.__loadData();let{approved:r,needsPermission:a}=this.permissionManager.filterToolCalls(n,s.permissions);for(let s of(this.stateManager.setPendingToolCalls(a),r))await this.executeToolCall(e,s,t)}async executeToolCall(e,t,s=0){await this.__loadData();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(){var e,t,s,i,n,r,a,o;this.__closeFlightMode(),null==(e=(0,g.cached)(this,"toolRegistry"))||e.destruct(),null==(t=(0,g.cached)(this,"permissionManager"))||t.destruct(),null==(s=(0,g.cached)(this,"apiClient"))||s.destruct(),null==(i=(0,g.cached)(this,"stateManager"))||i.destruct(),null==(n=(0,g.cached)(this,"mainPanel"))||n.destruct(),null==(r=(0,g.cached)(this,"dialog"))||r.destruct(),null==(o=(0,g.cached)(this,"storage"))||null==(a=o.close)||a.call(o)}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),w.JoditPro.plugins.add("aiAssistantPro",y)},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,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}`}}},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()}}},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}})},48705:function(e,t,s){"use strict";s.d(t,{UISettingsButton:function(){return i.UISettingsButton}});var i=s(76697)},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}})},51251:function(e,t,s){"use strict";s.d(t,{UIMainPanel:function(){return m}});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);class m extends p.UIElement{className(){return"UIMainPanel"}setParentView(e){var t,s,i,n,r,a;return null==(t=this.welcomeScreen)||t.setParentView(e),null==(s=this.conversationList)||s.setParentView(e),null==(i=this.messageList)||i.setParentView(e),null==(n=this.inputArea)||n.setParentView(e),null==(r=this.permissionRequest)||r.setParentView(e),null==(a=this.settingsButton)||a.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
|
|
11
11
|
<div class="&__header">
|
|
12
12
|
<div class="&__header-left"></div>
|
|
13
13
|
<div class="&__header-title"></div>
|
|
@@ -27,7 +27,7 @@ ${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQ
|
|
|
27
27
|
<div class="&__title">~Welcome to AI Assistant~</div>
|
|
28
28
|
<div class="&__subtitle">~Start your first conversation~</div>
|
|
29
29
|
<div class="&__tip">~Tip: Select text in editor to add context~</div>
|
|
30
|
-
</div>`}}a=(0,i.__decorate)([n.component],a)},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();(null==r?void 0: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")+": "+((null==t?void 0:t.message)||"Unknown error"))}finally{i.setLoading(!1)}}async function r(e,t,s){s.setLoading(!0);try{let[i,r]=await Promise.all([t.list().catch(()=>[]),t.getGlobalSettings().catch(()=>null)]);if(s.setConversations(i),r&&s.setSavedState(r),0===i.length)s.setView("welcome");else if(e.o.aiAssistantPro.rememberLastConversation&&(null==r?void 0:r.currentConversationId)){var n;let e=null!=(n=i.find(e=>e.id===r.currentConversationId))?n: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)}}},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: ${(null==e?void 0: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: ${(null==e?void 0: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: ${(null==t?void 0:t.message)||"Unknown error"}`)}}},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},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},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},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=>{var i;return null!=(i=s(t,e))?i:t})):t}},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,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}},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)},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},62895:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return i.WebStorageConversationStorage},createStorageProvider:function(){return i.createStorageProvider}});var i=s(21064)},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){var t,s,i;return null==(t=this.textarea)||t.setParentView(e),null==(s=this.sendButton)||s.setParentView(e),null==(i=this.stopButton)||i.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
|
|
30
|
+
</div>`}}a=(0,i.__decorate)([n.component],a)},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();(null==r?void 0: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")+": "+((null==t?void 0:t.message)||"Unknown error"))}finally{i.setLoading(!1)}}async function r(e,t,s){s.setLoading(!0);try{let[i,r]=await Promise.all([t.list().catch(()=>[]),t.getGlobalSettings().catch(()=>null)]);if(s.setConversations(i),r&&s.setSavedState(r),0===i.length)s.setView("welcome");else if(e.o.aiAssistantPro.rememberLastConversation&&(null==r?void 0:r.currentConversationId)){var n;let e=null!=(n=i.find(e=>e.id===r.currentConversationId))?n: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)}}},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: ${(null==e?void 0: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: ${(null==e?void 0: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: ${(null==t?void 0:t.message)||"Unknown error"}`)}}},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},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},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},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=>{var i;return null!=(i=s(t,e))?i:t})):t}},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}},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)},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},62895:function(e,t,s){"use strict";s.d(t,{WebStorageConversationStorage:function(){return i.WebStorageConversationStorage},createStorageProvider:function(){return i.createStorageProvider}});var i=s(21064)},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){var t,s,i;return null==(t=this.textarea)||t.setParentView(e),null==(s=this.sendButton)||s.setParentView(e),null==(i=this.stopButton)||i.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
|
|
31
31
|
<div class="&__context-badges"></div>
|
|
32
32
|
<div class="&__loading-indicator">
|
|
33
33
|
<span class="&__loading-dot"></span>
|
|
@@ -44,8 +44,8 @@ ${r}`.trim();s?await this.__executeQuickCommandSilent(l,r):await this.__executeQ
|
|
|
44
44
|
<div class="&__search-loader"></div>
|
|
45
45
|
</div>
|
|
46
46
|
<div class="&__list"></div>
|
|
47
|
-
</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){var t;return null==(t=this.searchInput)||t.setParentView(e),super.setParentView(e)}destruct(){var e;null==(e=this.searchInput)||e.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)},70308:function(e,t,s){"use strict";s.d(t,{areAllToolCallsExecuted:function(){return a},createNewConversation:function(){return n},findParentMessageId:function(){return r}});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:null!=t?t:a.defaultModel,temperature:null!=s?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}function a(e){let t=e.messages[e.messages.length-1];return!!(null==t?void 0:t.toolCalls)&&t.toolCalls.every(e=>"executed"===e.status||"denied"===e.status||"error"===e.status)}},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},71050:function(e,t,s){"use strict";function i(e){switch(e){case"left":return"right";case"right":return"left";case"top":return"bottom";case"bottom":return"top"}}function n(e,t,s,n){var r,a,o;"dialog"!==t&&"flight"!==t&&(("left"===t||"right"===t)&&(null==(a=e.currentPlace.slots[i(t)])||a.style.setProperty(`--jd-slot-${i(t)}-width`,"auto"),null==(o=e.currentPlace.slots[t])||o.style.setProperty(`--jd-slot-${t}-width`,`${s}px`)),null==(r=e.currentPlace.slots[t])||r.style.setProperty("min-height",`${n}px`))}s.d(t,{invertMode:function(){return i},resizeInPanelView:function(){return n}})},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){var t,s,i;return null==(t=this.displayModeSelect)||t.setParentView(e),null==(s=this.panelWidthInput)||s.setParentView(e),null==(i=this.themeSelect)||i.setParentView(e),super.setParentView(e)}async build(){var e,t,s,i,n,r;let a=this.container;this.options.allowEditDisplayMode&&(this.displayModeSelect=new l.UISelect(this.j,{label:"Display Mode",name:"displayMode",value:null!=(e=null==(t=this.state)?void 0:t.displayMode)?e:"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()}}),a.appendChild(this.displayModeSelect.container)),this.options.allowEditPanelWidth&&(this.panelWidthInput=new o.UIInput(this.j,{label:"Panel Width",name:"panelWidth",type:"number",value:String(null!=(s=null==(i=this.state)?void 0:i.panelWidth)?s:400),onChange:()=>{this.onPanelWidthChange()}}),this.panelWidthInput.nativeInput.setAttribute("min","200"),this.panelWidthInput.nativeInput.setAttribute("max","800"),this.panelWidthInput.nativeInput.setAttribute("step","10"),a.appendChild(this.panelWidthInput.container)),this.options.allowEditTheme&&(this.themeSelect=new l.UISelect(this.j,{label:"Theme",name:"theme",value:null!=(n=null==(r=this.state)?void 0:r.theme)?n:"parent",options:[{text:"Inherit",value:"parent"},{text:"Light",value:"light"},{text:"Dark",value:"dark"}],onChange:()=>{this.onThemeChange()}}),a.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(){var e,t,s;null==(e=this.displayModeSelect)||e.destruct(),null==(t=this.panelWidthInput)||t.destruct(),null==(s=this.themeSelect)||s.destruct(),super.destruct()}onStateDisplayModeChange(){this.displayModeSelect&&(this.displayModeSelect.value=this.state.displayMode)}onStatePanelWidthChange(){this.panelWidthInput&&this.panelWidthInput.value!==String(this.state.panelWidth)&&(this.panelWidthInput.value=String(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)},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 ew}});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(e){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,listReplaceTabs:/^\t+/,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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,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")},u=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,d=/(?:[*+-]|\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]|[^\[\]\\])+/,w=l(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",v).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),C=l(/^( {0,3}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[.)]) ").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:w,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:C,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[.)]) ").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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex()},A={..._,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} *[^
|
|
48
|
-
]`).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,
|
|
47
|
+
</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){var t;return null==(t=this.searchInput)||t.setParentView(e),super.setParentView(e)}destruct(){var e;null==(e=this.searchInput)||e.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)},70308:function(e,t,s){"use strict";s.d(t,{areAllToolCallsExecuted:function(){return a},createNewConversation:function(){return n},findParentMessageId:function(){return r}});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:null!=t?t:a.defaultModel,temperature:null!=s?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}function a(e){let t=e.messages[e.messages.length-1];return!!(null==t?void 0:t.toolCalls)&&t.toolCalls.every(e=>"executed"===e.status||"denied"===e.status||"error"===e.status)}},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},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){var a,o,l,c;if("dialog"===t||"flight"===t)return;("left"===t||"right"===t)&&(null==(l=e.currentPlace.slots[n(t)])||l.style.setProperty(`--jd-slot-${n(t)}-width`,"auto"),null==(c=e.currentPlace.slots[t])||c.style.setProperty(`--jd-slot-${t}-width`,`${s}px`));let h=null!=(a=(0,i.css)(e.currentPlace.workplace,"height"))?a:0;null==(o=e.currentPlace.slots[t])||o.style.setProperty("min-height",`${Math.min(h,r)}px`)}},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){var t,s,i;return null==(t=this.displayModeSelect)||t.setParentView(e),null==(s=this.panelWidthInput)||s.setParentView(e),null==(i=this.themeSelect)||i.setParentView(e),super.setParentView(e)}async build(){var e,t,s,i,n,r;let a=this.container;this.options.allowEditDisplayMode&&(this.displayModeSelect=new l.UISelect(this.j,{label:"Display Mode",name:"displayMode",value:null!=(e=null==(t=this.state)?void 0:t.displayMode)?e:"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()}}),a.appendChild(this.displayModeSelect.container)),this.options.allowEditPanelWidth&&(this.panelWidthInput=new o.UIInput(this.j,{label:"Panel Width",name:"panelWidth",type:"number",value:String(null!=(s=null==(i=this.state)?void 0:i.panelWidth)?s:400),onChange:()=>{this.onPanelWidthChange()}}),this.panelWidthInput.nativeInput.setAttribute("min","200"),this.panelWidthInput.nativeInput.setAttribute("max","800"),this.panelWidthInput.nativeInput.setAttribute("step","10"),a.appendChild(this.panelWidthInput.container)),this.options.allowEditTheme&&(this.themeSelect=new l.UISelect(this.j,{label:"Theme",name:"theme",value:null!=(n=null==(r=this.state)?void 0:r.theme)?n:"parent",options:[{text:"Inherit",value:"parent"},{text:"Light",value:"light"},{text:"Dark",value:"dark"}],onChange:()=>{this.onThemeChange()}}),a.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(){var e,t,s;null==(e=this.displayModeSelect)||e.destruct(),null==(t=this.panelWidthInput)||t.destruct(),null==(s=this.themeSelect)||s.destruct(),super.destruct()}onStateDisplayModeChange(){this.displayModeSelect&&(this.displayModeSelect.value=this.state.displayMode)}onStatePanelWidthChange(){this.panelWidthInput&&this.panelWidthInput.value!==String(this.state.panelWidth)&&(this.panelWidthInput.value=String(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)},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 ew}});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(e){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,listReplaceTabs:/^\t+/,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,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,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")},u=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,d=/(?:[*+-]|\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]|[^\[\]\\])+/,w=l(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",v).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),C=l(/^( {0,3}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[.)]) ").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:w,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:C,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[.)]) ").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[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex()},A={..._,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} *[^
|
|
48
|
+
]`).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=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(),$=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,D=l($,"u").replace(/punct/g,T).getRegex(),B=l($,"u").replace(/punct/g,R).getRegex(),N="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",q=l(N,"gu").replace(/notPunctSpace/g,E).replace(/punctSpace/g,P).replace(/punct/g,T).getRegex(),z=l(N,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,R).getRegex(),F=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(),U=l(/\\(punct)/,"gu").replace(/punct/g,T).getRegex(),O=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(),V=l(y).replace("(?:--\x3e|$)","--\x3e").getRegex(),H=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",V).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),W=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,G=l(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",W).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Z=l(/^!?\[(label)\]\[(ref)\]/).replace("label",W).replace("ref",v).getRegex(),Q=l(/^!?\[(ref)\](?:\[\])?/).replace("ref",v).getRegex(),K=l("reflink|nolink(?!\\()","g").replace("reflink",Z).replace("nolink",Q).getRegex(),J=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,X={_backpedal:o,anyPunctuation:U,autolink:O,blockSkip:L,br:M,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:o,emStrongLDelim:D,emStrongRDelimAst:q,emStrongRDelimUnd:F,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:G,nolink:Q,punctuation:j,reflink:Z,reflinkSearch:K,tag:H,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:o},Y={...X,link:l(/^!?\[(label)\]\((.*?)\)/).replace("label",W).getRegex(),reflink:l(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",W).getRegex()},ee={...X,emStrongRDelimAst:z,emStrongLDelim:B,url:l(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",J).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",J).getRegex()},et={...ee,br:l(M).replace("{2,}","*").getRegex(),text:l(ee.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},es={normal:_,gfm:I,pedantic:A},ei={normal:X,gfm:ee,breaks:et,pedantic:Y},en={"&":"&","<":"<",">":">",'"':""","'":"'"},er=e=>en[e];function ea(e,t){if(t){if(h.escapeTest.test(e))return e.replace(h.escapeReplace,er)}else if(h.escapeTestNoEncode.test(e))return e.replace(h.escapeReplaceNoEncode,er);return e}function eo(e){try{e=encodeURI(e).replace(h.percentDecode,"%")}catch(e){return null}return e}function el(e,t){var s;let i=e.replace(h.findPipe,(e,t,s)=>{let i=!1,n=t;for(;--n>=0&&"\\"===s[n];)i=!i;return i?"|":" |"}).split(h.splitPipe),n=0;if(i[0].trim()||i.shift(),!(i.length>0)||(null==(s=i.at(-1))?void 0:s.trim())||i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;n<i.length;n++)i[n]=i[n].trim().replace(h.slashPipe,"|");return i}function ec(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 eh(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 eu=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:ec(e,`
|
|
49
49
|
`)}}}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(`
|
|
50
50
|
`).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(`
|
|
51
51
|
`)}(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=ec(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:ec(t[0],`
|
|
@@ -107,7 +107,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let e="<p>An error
|
|
|
107
107
|
<h3 class="&__title">~Settings~</h3>
|
|
108
108
|
</div>
|
|
109
109
|
<div class="&__content"></div>
|
|
110
|
-
</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(){var e,t;null==(e=this.globalSettings)||e.destruct(),null==(t=this.dialogSettings)||t.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)},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: ${(null==e?void 0:e.message)||"Unknown error"}`)}}},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(26866);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,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=String(this.conversation.messageCount),s.appendChild(e)}e.appendChild(s),this.deleteButton||(this.deleteButton=new o.UIButton(this.j,{icon:{name:"bin"},variant:"outline",size:"tiny",tooltip:"Delete conversation"}),this.deleteButton.container.classList.add("jodit-ui-conversation-list__item-delete"),this.deleteButton.onAction(e=>{e.stopPropagation(),this.onDelete()})),e.appendChild(this.deleteButton.container)}onClick(){this.j.e.fire("selectConversation.ai-assistant-pro",this.conversation.id)}onDelete(){l.Confirm.call(void 0,this.j.i18n("Are you sure you want to delete this conversation?"),this.j.i18n("Delete conversation"),e=>{e&&this.j.e.fire("deleteConversation.ai-assistant-pro",this.conversation.id)})}destruct(){var e;null==(e=this.deleteButton)||e.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,"deleteButton",void 0),this.opts=n,this.conversation=t,this.isActive=s,this.updateContent()}}(0,n.__decorate)([(0,r.watch)("container:click")],c.prototype,"onClick",null),(0,n.__decorate)([r.autobind],c.prototype,"onDelete",null),c=(0,n.__decorate)([r.component],c)},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="\uD83D\uDD04",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(){var e;let t=this.j.c.div(this.getFullElName("error")),s=this.j.c.div(this.getFullElName("error-icon"));s.textContent="❌";let i=this.j.c.div(this.getFullElName("error-message"));i.textContent=(null==(e=this.artifact.metadata)?void 0:e.error)||this.j.i18n("Failed to generate artifact"),t.appendChild(s),t.appendChild(i),this.container.appendChild(t)}renderImage(){var e,t;if(!this.artifact.data)return;let s=this.j.c.div(this.getFullElName("content")),i=this.j.c.element("img",{class:this.getFullElName("image")});if("url"===this.artifact.data.kind)i.src=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"image/png";i.src=`data:${e};base64,${this.artifact.data.base64}`}if(i.alt=(null==(e=this.artifact.metadata)?void 0:e.alt)||"AI Generated Image",s.appendChild(i),null==(t=this.artifact.metadata)?void 0:t.caption){let e=this.j.c.div(this.getFullElName("caption"));e.textContent=this.artifact.metadata.caption,s.appendChild(e)}this.container.appendChild(s)}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(){var e,t,s;if(!this.artifact.data)return;let i=this.j.c.div(this.getFullElName("content")),n=this.j.c.div(this.getFullElName("file-card")),r=this.j.c.div(this.getFullElName("file-icon"));r.textContent="\uD83D\uDCC4";let a=this.j.c.div(this.getFullElName("file-info")),o=this.j.c.div(this.getFullElName("file-name"));o.textContent=(null==(e=this.artifact.metadata)?void 0:e.filename)||"download.file";let l=this.j.c.div(this.getFullElName("file-size"));(null==(t=this.artifact.metadata)?void 0:t.size)&&(l.textContent=this.formatFileSize(this.artifact.metadata.size)),a.appendChild(o),a.appendChild(l);let c=this.j.c.element("a",{class:this.getFullElName("download-btn"),download:(null==(s=this.artifact.metadata)?void 0:s.filename)||"download.file"});if(c.textContent=this.j.i18n("Download"),"url"===this.artifact.data.kind)c.href=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"application/octet-stream";c.href=`data:${e};base64,${this.artifact.data.base64}`}n.appendChild(r),n.appendChild(a),n.appendChild(c),i.appendChild(n),this.container.appendChild(i)}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="\uD83D\uDCE6";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)},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}},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>'},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{apiMode:r,instructions:a}=this.jodit.o.aiAssistantPro,o={mode:r,conversationId:e,tools:this.toolRegistry.getAllTools(),selectionContexts:i,conversationOptions:n,instructions:a},l=[];if("full"===r)l=t;else if(s){let e=t.findIndex(e=>e.id===s);l=-1!==e?t.slice(e+1):t,o={...o,parentMessageId:s}}else l=t;return{...o,messages:this.expandToolMessages(l,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 i of e.toolCalls){var s;let n=null!=(s=i.result)?s:{error:"result not found"};if(t.find(e=>e.id===`${i.id}-result`))continue;let r={id:`${i.id}-result`,role:"tool",content:n.error?`Error: ${n.error}`:JSON.stringify(n.result),timestamp:e.timestamp,toolResults:[{toolCallId:i.id,result:n}]};t.push(r)}}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 messageId");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}}},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)},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},90991:function(e,t,s){"use strict";var i=s(52826),n=s(85130);t.default={...i,execute:n.execute}},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}}},93677:function(e,t,s){"use strict";s.d(t,{UIPermissionRequest:function(){return c}});var i=s(82749),n=s(31635),r=s(65478),a=s(67510),o=s(62843),l=s(12234);class c extends a.UIElement{className(){return"UIPermissionRequest"}setToolCall(e){this.toolCall=e,this.updateContent()}setParentView(e){var t,s,i;return null==(t=this.scopeSelect)||t.setParentView(e),null==(s=this.approveButton)||s.setParentView(e),null==(i=this.denyButton)||i.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
|
|
110
|
+
</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(){var e,t;null==(e=this.globalSettings)||e.destruct(),null==(t=this.dialogSettings)||t.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)},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: ${(null==e?void 0:e.message)||"Unknown error"}`)}}},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(26866);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,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=String(this.conversation.messageCount),s.appendChild(e)}e.appendChild(s),this.deleteButton||(this.deleteButton=new o.UIButton(this.j,{icon:{name:"bin"},variant:"outline",size:"tiny",tooltip:"Delete conversation"}),this.deleteButton.container.classList.add("jodit-ui-conversation-list__item-delete"),this.deleteButton.onAction(e=>{e.stopPropagation(),this.onDelete()})),e.appendChild(this.deleteButton.container)}onClick(){this.j.e.fire("selectConversation.ai-assistant-pro",this.conversation.id)}onDelete(){l.Confirm.call(void 0,this.j.i18n("Are you sure you want to delete this conversation?"),this.j.i18n("Delete conversation"),e=>{e&&this.j.e.fire("deleteConversation.ai-assistant-pro",this.conversation.id)})}destruct(){var e;null==(e=this.deleteButton)||e.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,"deleteButton",void 0),this.opts=n,this.conversation=t,this.isActive=s,this.updateContent()}}(0,n.__decorate)([(0,r.watch)("container:click")],c.prototype,"onClick",null),(0,n.__decorate)([r.autobind],c.prototype,"onDelete",null),c=(0,n.__decorate)([r.component],c)},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="\uD83D\uDD04",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(){var e;let t=this.j.c.div(this.getFullElName("error")),s=this.j.c.div(this.getFullElName("error-icon"));s.textContent="❌";let i=this.j.c.div(this.getFullElName("error-message"));i.textContent=(null==(e=this.artifact.metadata)?void 0:e.error)||this.j.i18n("Failed to generate artifact"),t.appendChild(s),t.appendChild(i),this.container.appendChild(t)}renderImage(){var e,t;if(!this.artifact.data)return;let s=this.j.c.div(this.getFullElName("content")),i=this.j.c.element("img",{class:this.getFullElName("image")});if("url"===this.artifact.data.kind)i.src=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"image/png";i.src=`data:${e};base64,${this.artifact.data.base64}`}if(i.alt=(null==(e=this.artifact.metadata)?void 0:e.alt)||"AI Generated Image",s.appendChild(i),null==(t=this.artifact.metadata)?void 0:t.caption){let e=this.j.c.div(this.getFullElName("caption"));e.textContent=this.artifact.metadata.caption,s.appendChild(e)}this.container.appendChild(s)}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(){var e,t,s;if(!this.artifact.data)return;let i=this.j.c.div(this.getFullElName("content")),n=this.j.c.div(this.getFullElName("file-card")),r=this.j.c.div(this.getFullElName("file-icon"));r.textContent="\uD83D\uDCC4";let a=this.j.c.div(this.getFullElName("file-info")),o=this.j.c.div(this.getFullElName("file-name"));o.textContent=(null==(e=this.artifact.metadata)?void 0:e.filename)||"download.file";let l=this.j.c.div(this.getFullElName("file-size"));(null==(t=this.artifact.metadata)?void 0:t.size)&&(l.textContent=this.formatFileSize(this.artifact.metadata.size)),a.appendChild(o),a.appendChild(l);let c=this.j.c.element("a",{class:this.getFullElName("download-btn"),download:(null==(s=this.artifact.metadata)?void 0:s.filename)||"download.file"});if(c.textContent=this.j.i18n("Download"),"url"===this.artifact.data.kind)c.href=this.artifact.data.url;else if("base64"===this.artifact.data.kind){let e=this.artifact.mimeType||"application/octet-stream";c.href=`data:${e};base64,${this.artifact.data.base64}`}n.appendChild(r),n.appendChild(a),n.appendChild(c),i.appendChild(n),this.container.appendChild(i)}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="\uD83D\uDCE6";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)},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}},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>'},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{apiMode:r,instructions:a}=this.jodit.o.aiAssistantPro,o={mode:r,conversationId:e,tools:this.toolRegistry.getAllTools(),selectionContexts:i,conversationOptions:n,instructions:a},l=[];if("full"===r)l=t;else if(s){let e=t.findIndex(e=>e.id===s);l=-1!==e?t.slice(e+1):t,o={...o,parentMessageId:s}}else l=t;return{...o,messages:this.expandToolMessages(l,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 i of e.toolCalls){var s;let n=null!=(s=i.result)?s:{error:"result not found"};if(t.find(e=>e.id===`${i.id}-result`))continue;let r={id:`${i.id}-result`,role:"tool",content:n.error?`Error: ${n.error}`:JSON.stringify(n.result),timestamp:e.timestamp,toolResults:[{toolCallId:i.id,result:n}]};t.push(r)}}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}}},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)},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},90991:function(e,t,s){"use strict";var i=s(52826),n=s(85130);t.default={...i,execute:n.execute}},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}}},93677:function(e,t,s){"use strict";s.d(t,{UIPermissionRequest:function(){return c}});var i=s(82749),n=s(31635),r=s(65478),a=s(67510),o=s(62843),l=s(12234);class c extends a.UIElement{className(){return"UIPermissionRequest"}setToolCall(e){this.toolCall=e,this.updateContent()}setParentView(e){var t,s,i;return null==(t=this.scopeSelect)||t.setParentView(e),null==(s=this.approveButton)||s.setParentView(e),null==(i=this.denyButton)||i.setParentView(e),super.setParentView(e)}render(){return`<div class="&__container">
|
|
111
111
|
<div class="&__header">
|
|
112
112
|
<div class="&__icon"></div>
|
|
113
113
|
<div class="&__title">~Permission Required~</div>
|