@core-pilot/client-vue 0.0.1-beta.1

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/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # Agent Chat UI
2
+ 一套基础的聊天组件,可用于 Agent 聊天、客服聊天等场景。
3
+ ## 安装
4
+ ```bash
5
+ npm install @core-pilot/client-vue
6
+ ```
7
+ ## 引入
8
+ ```js
9
+ import { XMarkdown } from '@core-pilot/client-vue'
10
+ ```
11
+ ## 使用
12
+ ```js
13
+ <AgentChatUI />
14
+ ```
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("vue"),t=require("vue-element-plus-x"),o=require("element-plus");require("element-plus/es/components/input/style/index"),require("element-plus/es/components/button/style/index"),require("element-plus/es/components/message/style/index");var n,i,a,l,s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const r=c(function(){if(l)return a;l=1;var e=i?n:(i=1,n=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,o=[],n=0;n<e.rangeCount;n++)o.push(e.getRangeAt(n));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||o.forEach(function(t){e.addRange(t)}),t&&t.focus()}}),t={"text/plain":"Text","text/html":"Url",default:"Text"};return a=function(o,n){var i,a,l,s,c,r,d=!1;n||(n={}),i=n.debug||!1;try{if(l=e(),s=document.createRange(),c=document.getSelection(),(r=document.createElement("span")).textContent=o,r.ariaHidden="true",r.style.all="unset",r.style.position="fixed",r.style.top=0,r.style.clip="rect(0, 0, 0, 0)",r.style.whiteSpace="pre",r.style.webkitUserSelect="text",r.style.MozUserSelect="text",r.style.msUserSelect="text",r.style.userSelect="text",r.addEventListener("copy",function(e){if(e.stopPropagation(),n.format)if(e.preventDefault(),void 0===e.clipboardData){i&&console.warn("unable to use e.clipboardData"),i&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var a=t[n.format]||t.default;window.clipboardData.setData(a,o)}else e.clipboardData.clearData(),e.clipboardData.setData(n.format,o);n.onCopy&&(e.preventDefault(),n.onCopy(e.clipboardData))}),document.body.appendChild(r),s.selectNodeContents(r),c.addRange(s),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");d=!0}catch(u){i&&console.error("unable to copy using execCommand: ",u),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(n.format||"text",o),n.onCopy&&n.onCopy(window.clipboardData),d=!0}catch(p){i&&console.error("unable to copy using clipboardData: ",p),i&&console.error("falling back to prompt"),a=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in n?n.message:"Copy to clipboard: #{key}, Enter"),window.prompt(a,o)}}finally{c&&("function"==typeof c.removeRange?c.removeRange(s):c.removeAllRanges()),r&&document.body.removeChild(r),l()}return d}}()),d=e.defineComponent({name:"Feedback",props:{show:{type:Boolean,default:!1},feedbackList:{type:Array,default:()=>[]},feedbackTitle:{type:String,default:"你觉得什么让你不满意?"},needOtherContent:{type:Boolean,default:!1}},emits:["closeFeedback","submit"],setup(t,{emit:o}){const n=e.ref(""),i=e.computed(()=>!(t.feedbackList.find(e=>"其他"===e.title&&e.checked)&&!n.value&&t.needOtherContent)&&t.feedbackList.some(e=>e.checked)),a=e.computed(()=>t.feedbackList.find(e=>"其他"===e.title&&e.checked));e.watch(()=>t.feedbackList,()=>{n.value=""});return{showInput:a,otherContent:n,selectdReason:i,itemClick:e=>{const o=!e.checked;t.feedbackList.forEach(e=>{e.checked=!1}),e.checked=o},closeFeedback:()=>{o("closeFeedback")},submitHandler:()=>{const e=t.feedbackList.filter(e=>e.checked).map(e=>e.content),i=t.feedbackList.find(e=>"其他"===e.title&&e.checked);if(n.value&&i){const t=e.findIndex(e=>"其他"===e);e.splice(t,1,n.value)}o("submit",e)}}},render(){return this.show?e.createVNode("div",{class:"feedback-wrapper"},[e.createVNode("div",{class:"feedback-title"},[e.createVNode("span",null,[this.feedbackTitle]),e.createVNode("span",{class:"close",onClick:this.closeFeedback},null)]),e.createVNode("div",{class:"feedback-content"},[e.createVNode("div",{class:"feedback-list"},[this.feedbackList.map((t,o)=>e.createVNode("span",{class:t.checked?"feedback-item checked":"feedback-item",key:o,onClick:()=>this.itemClick(t)},[e.createVNode("span",null,[t.title])])),this.showInput&&e.createVNode(o.ElInput,{class:"other-input",placeholder:"其他原因",modelValue:this.otherContent,"onUpdate:modelValue":e=>this.otherContent=e},null)]),e.createVNode("div",{class:"footer"},[e.createVNode(o.ElButton,{disabled:!this.selectdReason,class:"submit",type:"primary",onClick:this.submitHandler},{default:()=>[e.createTextVNode("提交")]})])])]):null}}),u=[{title:"没有帮助",content:"没有帮助",checked:!1},{title:"有害/不安全",content:"有害/不安全",checked:!1},{title:"信息虚假",content:"信息虚假",checked:!1},{title:"隐私相关",content:"隐私相关",checked:!1},{title:"其他",content:"其他",checked:!1}],p=[{title:"内容准确",content:"内容准确",checked:!1},{title:"易于理解",content:"易于理解",checked:!1},{title:"内容完善",content:"内容完善",checked:!1},{title:"其他",content:"其他",checked:!1}],k=e.defineComponent({name:"ActionBar",props:{content:{type:String,default:""},isLast:{type:Boolean,default:!1},disLikeFeedbackList:{type:Array,default:()=>u},likeFeedbackList:{type:Array,default:()=>p},message:{type:Object,default:()=>({})}},emits:["click"],setup(t,{emit:n}){const i=e.ref([]),a=e.useTemplateRef("x-markdown-copy"),l=e.ref("你觉得什么让你不满意?"),s=e.ref(!1),c=e.ref(""),d=e.computed(()=>{const e=[{icon:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6.33337%205.73672V4.19702C6.33337%203.67925%206.75311%203.25952%207.27087%203.25952H15.3959C15.9136%203.25952%2016.3334%203.67925%2016.3334%204.19702V12.322C16.3334%2012.8398%2015.9136%2013.2595%2015.3959%2013.2595H13.8388'%20stroke='%2353576A'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M12.7291%205.92603H4.60413C4.08636%205.92603%203.66663%206.34576%203.66663%206.86353V14.9885C3.66663%2015.5063%204.08636%2015.926%204.60413%2015.926H12.7291C13.2469%2015.926%2013.6666%2015.5063%2013.6666%2014.9885V6.86353C13.6666%206.34576%2013.2469%205.92603%2012.7291%205.92603Z'%20stroke='%2353576A'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3c/svg%3e",type:"copy"},{icon:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M11.3509%207.72498V5.025C11.3509%203.90662%2010.4443%203%209.32596%203L6.62598%209.07497V16.4999H14.4694C15.1426%2016.5075%2015.7185%2016.018%2015.8194%2015.3524L16.7509%209.27746C16.8103%208.88586%2016.6948%208.48791%2016.4349%208.18904C16.175%207.89016%2015.797%207.72048%2015.4009%207.72498H11.3509Z'%20stroke='%2353576A'%20stroke-width='1.34999'%20stroke-linejoin='round'/%3e%3cpath%20d='M6.62583%208.99998H4.82359C4.03284%208.98599%203.35687%209.641%203.25085%2010.4247V15.1497C3.35687%2015.9334%204.03284%2016.5136%204.82359%2016.4997H6.62583V8.99998Z'%20stroke='%2353576A'%20stroke-width='1.34999'%20stroke-linejoin='round'/%3e%3c/svg%3e",type:"like"},{icon:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.64049%2012.275V14.975C8.64049%2016.0934%209.54708%2017%2010.6655%2017L13.3655%2010.925V3.50009H5.52201C4.84885%203.49248%204.27295%203.98199%204.17201%204.64758L3.24052%2010.7225C3.18108%2011.1141%203.29661%2011.5121%203.55651%2011.811C3.81641%2012.1098%204.19445%2012.2795%204.59051%2012.275H8.64049Z'%20stroke='%23195FFF'%20stroke-width='1.34999'%20stroke-linejoin='round'/%3e%3cpath%20d='M13.3656%203.5H15.1678C15.9586%203.48602%2016.6346%204.06626%2016.7406%204.84999V9.57497C16.6346%2010.3587%2015.9586%2011.0139%2015.1678%2011H13.3656V3.5Z'%20stroke='%23195FFF'%20stroke-width='1.34999'%20stroke-linejoin='round'/%3e%3c/svg%3e",type:"dislike"}];return t.isLast&&e.unshift({icon:"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14.2426%2013.8354C13.1569%2014.9212%2011.6569%2015.5928%2010%2015.5928C6.6863%2015.5928%204%2012.9065%204%209.59277C4%206.27907%206.6863%203.59277%2010%203.59277C11.6569%203.59277%2013.1569%204.26435%2014.2426%205.35014C14.7953%205.90281%2016%207.25944%2016%207.25944'%20stroke='%2353576A'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M16%204.25952V7.25952H13'%20stroke='%2353576A'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e",type:"regenerate"}),e}),u=e.ref(null),p=e.ref(!1);e.watch(()=>{var e;return null==(e=t.message)?void 0:e.feedback},e=>{e&&(u.value=e)},{immediate:!0});const k=()=>{p.value=!1},f=(e,t,o)=>{n("click",e,t,o)};return{btns:d,activeBtn:u,showFeedback:p,feedbackList:i,feedbackTitle:l,needOtherContent:s,copyContent:c,triggerEvent:f,btnClick:(e,n)=>{u.value===n?f(n,null,!0):f(n);switch(n){case"copy":(()=>{var e,n,i;let l=null==(i=null==(n=null==(e=t.content.split("</details>")[1])?void 0:e.split)?void 0:n.call(e,"<div hidden>"))?void 0:i[0];l=l.replace(/<sub ([^>]+)>([^<]+)<\/sub>/g,""),c.value=l,setTimeout(()=>{var e;const t=null==(e=a.value)?void 0:e.getContentText();r(t),o.ElMessage.success("已复制净化文本")},100)})();break;case"dislike":l.value="你觉得什么让你不满意?",p.value=t.disLikeFeedbackList.length>0,i.value=t.disLikeFeedbackList,s.value=!0;break;case"like":l.value="你觉得什么让你满意?",p.value=t.likeFeedbackList.length>0,i.value=t.likeFeedbackList,s.value=!1}["regenerate","copy"].includes(n)||(e=>{u.value===e?(k(),u.value=null):u.value=e})(n)},hideFeedback:k,submitFeedback:e=>{f(u.value,e),k()}}},render(){return e.createVNode("div",{class:"action-bar-wrapper"},[e.createVNode("div",{class:"button-wrapper"},[this.btns.map(t=>e.createVNode("div",{class:"btn-item"},[e.createVNode("img",{src:t.icon,class:this.activeBtn===t.type?"active":"",onClick:e=>this.btnClick(e,t.type)},null)]))]),e.createVNode(d,{show:this.showFeedback,feedbackList:this.feedbackList,feedbackTitle:this.feedbackTitle,onCloseFeedback:this.hideFeedback,needOtherContent:this.needOtherContent,onSubmit:this.submitFeedback},null),e.createVNode(e.resolveComponent("x-markdown"),{style:"position: absolute; top: -9999px; left: -9999px",ref:"x-markdown-copy",text:this.copyContent},null)])}}),f=e.defineComponent({props:{list:{type:Array,default:()=>[]},btnLoading:{type:Boolean,default:!0},maxHeight:{type:String,default:"500px"},autoHideThinking:{type:Boolean,default:!0},speed:{type:Number,default:200},disLikeFeedbackList:{type:Array,default:()=>{}},likeFeedbackList:{type:Array,default:()=>{}}},expose:["showLastActionGroup","scrollToBottom","hideLastActionGroup"],emits:["hoverActiveRefTrigger","clickActiveRefTrigger","like","dislike","regenerate","copy","refConfigUpdate","questionClick","downloadFile"],setup(t,{emit:o}){const n=e.useTemplateRef("bubbleList"),i=e.useTemplateRef("bubbleListContainer"),a=e.ref(!1),l=e.ref(null),s=e.ref(()=>{});e.watch(()=>l.value,(e,t)=>{var n;if(null===e)return;if(t===e)return;const i=null==(n=l.value)?void 0:n.querySelector("div[hidden]"),a=JSON.parse((null==i?void 0:i.textContent)||"[]");o("refConfigUpdate",a)}),e.watch(()=>t.list.length,()=>{e.nextTick(()=>{s.value(),s.value=u()})});const c=(e,t,n,i)=>{o(e,{content:t,message:i,cancel:n})},r=e=>{o("questionClick",e)},d=e=>t.list[t.list.length-1]===e,u=()=>{const e=i.value.querySelectorAll(".el-bubble-start"),t=new IntersectionObserver(e=>{e.forEach(e=>{if(e.isIntersecting){const t=e.boundingClientRect.bottom,o=e.target.clientHeight,n=i.value.getBoundingClientRect().bottom;Math.abs(t-n)<o&&(l.value=e.target)}})},{root:i.value,threshold:[.1,.9]});return e.forEach(e=>{t.observe(e)}),()=>{t.disconnect()}};return e.onMounted(()=>{s.value=u()}),{hoverActiveRefTrigger:e=>{o("hoverActiveRefTrigger",e)},showLastActionGroup:()=>{a.value=!0},hideLastActionGroup:()=>{a.value=!1},showLastBubbleFooter:a,clickActiveRefTrigger:e=>{o("clickActiveRefTrigger",e)},clickAction:c,scrollToBottom:()=>{var e;null==(e=n.value)||e.scrollToBottom()},lastRefConfigUpdate:(e,n)=>{t.list[t.list.length-1]===n&&o("refConfigUpdate",e)},getQuestions:t=>t.questions&&t.questions.length>0?e.createVNode("div",{class:"question-list"},[t.questions.map((t,o)=>e.createVNode("span",{class:"question-item",key:o,onClick:()=>r(t)},[t,e.createVNode("span",{class:"icon"},null)]))]):null,questionClick:r,isLastItem:d,getActionBar:o=>{if("boolean"==typeof o.showActions&&!o.showActions)return null;const n=d(o);return n&&a.value?e.createVNode(k,{isLast:n,content:o.content,message:o,disLikeFeedbackList:t.disLikeFeedbackList,likeFeedbackList:t.likeFeedbackList,onClick:(e,t,n)=>c(e,t,n,o)},null):n?void 0:e.createVNode(k,{isLast:n,content:o.content,message:o,disLikeFeedbackList:t.disLikeFeedbackList,likeFeedbackList:t.likeFeedbackList,onClick:(e,t,n)=>c(e,t,n,o)},null)},onDownloadFile:e=>{o("downloadFile",e)}}},render(){return e.createVNode("div",{ref:"bubbleListContainer",class:"bubble-list"},[e.createVNode(t.BubbleList,{ref:"bubbleList",list:this.list,btnLoading:this.btnLoading,maxHeight:this.maxHeight},{header:({item:o})=>{var n;return(null==(n=o.files)?void 0:n.length)?e.createVNode("div",{class:"bubble-item-header"},[o.files.map(o=>e.createVNode(t.FilesCard,{name:o.name,status:"done"},null))]):null},content:({item:t})=>e.createVNode(e.resolveComponent("x-markdown"),{key:t.id,typing:t.typing,speed:this.speed,text:t.content,autoHideThinking:this.autoHideThinking,onHoverActiveRefTrigger:this.hoverActiveRefTrigger,onClickActiveRefTrigger:this.clickActiveRefTrigger,onRefConfigUpdate:e=>this.lastRefConfigUpdate(e,t),onDownloadFile:this.onDownloadFile},null),footer:({item:t})=>"ai"===t.role?e.createVNode("div",null,[this.getActionBar(t),this.getQuestions(t)]):null})])}});exports.commonjsGlobal=s,exports.getDefaultExportFromCjs=c,exports.index=f;
2
+ //# sourceMappingURL=bubbleList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bubbleList.js","sources":["../../../node_modules/.pnpm/copy-to-clipboard@3.3.3/node_modules/copy-to-clipboard/index.js","../../../node_modules/.pnpm/toggle-selection@1.0.6/node_modules/toggle-selection/index.js","../src/components/bubble-list/feedback.tsx","../src/components/bubble-list/actionBar.tsx","../src/components/bubble-list/static/copy.svg","../src/components/bubble-list/static/like.svg","../src/components/bubble-list/static/dislike.svg","../src/components/bubble-list/static/regenerate.svg","../src/components/bubble-list/index.tsx"],"sourcesContent":["\"use strict\";\n\nvar deselectCurrent = require(\"toggle-selection\");\n\nvar clipboardToIE11Formatting = {\n \"text/plain\": \"Text\",\n \"text/html\": \"Url\",\n \"default\": \"Text\"\n}\n\nvar defaultMessage = \"Copy to clipboard: #{key}, Enter\";\n\nfunction format(message) {\n var copyKey = (/mac os x/i.test(navigator.userAgent) ? \"⌘\" : \"Ctrl\") + \"+C\";\n return message.replace(/#{\\s*key\\s*}/g, copyKey);\n}\n\nfunction copy(text, options) {\n var debug,\n message,\n reselectPrevious,\n range,\n selection,\n mark,\n success = false;\n if (!options) {\n options = {};\n }\n debug = options.debug || false;\n try {\n reselectPrevious = deselectCurrent();\n\n range = document.createRange();\n selection = document.getSelection();\n\n mark = document.createElement(\"span\");\n mark.textContent = text;\n // avoid screen readers from reading out loud the text\n mark.ariaHidden = \"true\"\n // reset user styles for span element\n mark.style.all = \"unset\";\n // prevents scrolling to the end of the page\n mark.style.position = \"fixed\";\n mark.style.top = 0;\n mark.style.clip = \"rect(0, 0, 0, 0)\";\n // used to preserve spaces and line breaks\n mark.style.whiteSpace = \"pre\";\n // do not inherit user-select (it may be `none`)\n mark.style.webkitUserSelect = \"text\";\n mark.style.MozUserSelect = \"text\";\n mark.style.msUserSelect = \"text\";\n mark.style.userSelect = \"text\";\n mark.addEventListener(\"copy\", function(e) {\n e.stopPropagation();\n if (options.format) {\n e.preventDefault();\n if (typeof e.clipboardData === \"undefined\") { // IE 11\n debug && console.warn(\"unable to use e.clipboardData\");\n debug && console.warn(\"trying IE specific stuff\");\n window.clipboardData.clearData();\n var format = clipboardToIE11Formatting[options.format] || clipboardToIE11Formatting[\"default\"]\n window.clipboardData.setData(format, text);\n } else { // all other browsers\n e.clipboardData.clearData();\n e.clipboardData.setData(options.format, text);\n }\n }\n if (options.onCopy) {\n e.preventDefault();\n options.onCopy(e.clipboardData);\n }\n });\n\n document.body.appendChild(mark);\n\n range.selectNodeContents(mark);\n selection.addRange(range);\n\n var successful = document.execCommand(\"copy\");\n if (!successful) {\n throw new Error(\"copy command was unsuccessful\");\n }\n success = true;\n } catch (err) {\n debug && console.error(\"unable to copy using execCommand: \", err);\n debug && console.warn(\"trying IE specific stuff\");\n try {\n window.clipboardData.setData(options.format || \"text\", text);\n options.onCopy && options.onCopy(window.clipboardData);\n success = true;\n } catch (err) {\n debug && console.error(\"unable to copy using clipboardData: \", err);\n debug && console.error(\"falling back to prompt\");\n message = format(\"message\" in options ? options.message : defaultMessage);\n window.prompt(message, text);\n }\n } finally {\n if (selection) {\n if (typeof selection.removeRange == \"function\") {\n selection.removeRange(range);\n } else {\n selection.removeAllRanges();\n }\n }\n\n if (mark) {\n document.body.removeChild(mark);\n }\n reselectPrevious();\n }\n\n return success;\n}\n\nmodule.exports = copy;\n","\nmodule.exports = function () {\n var selection = document.getSelection();\n if (!selection.rangeCount) {\n return function () {};\n }\n var active = document.activeElement;\n\n var ranges = [];\n for (var i = 0; i < selection.rangeCount; i++) {\n ranges.push(selection.getRangeAt(i));\n }\n\n switch (active.tagName.toUpperCase()) { // .toUpperCase handles XHTML\n case 'INPUT':\n case 'TEXTAREA':\n active.blur();\n break;\n\n default:\n active = null;\n break;\n }\n\n selection.removeAllRanges();\n return function () {\n selection.type === 'Caret' &&\n selection.removeAllRanges();\n\n if (!selection.rangeCount) {\n ranges.forEach(function(range) {\n selection.addRange(range);\n });\n }\n\n active &&\n active.focus();\n };\n};\n","import { computed, defineComponent, ref, watch } from 'vue';\nimport './style/feedback.less'\nimport { ElInput, ElButton } from 'element-plus';\nimport { FeedbackItem } from './index';\n\nexport default defineComponent({\n name: 'Feedback',\n props: {\n show: {\n type: Boolean,\n default: false\n },\n feedbackList: {\n type: Array<FeedbackItem>,\n default: () => []\n },\n feedbackTitle: {\n type: String,\n default: '你觉得什么让你不满意?'\n },\n needOtherContent: { // 区分喜欢和不喜欢input 框是否必填\n type: Boolean,\n default: false\n }\n },\n emits: ['closeFeedback', 'submit'],\n setup(props, {emit}) {\n const otherContent = ref('');\n const selectdReason = computed(() => {\n // 如果选择了其他,且输入框没有内容,则不能提交\n const otherChecked = props.feedbackList.find((item) => {\n if (item.title === '其他') {\n return item.checked;\n }\n return false;\n });\n if (otherChecked && !otherContent.value && props.needOtherContent) {\n return false;\n }\n\n return props.feedbackList.some((item) => {\n return item.checked;\n });\n })\n\n const itemClick = (item: FeedbackItem) => {\n const curChecked = !item.checked;\n props.feedbackList.forEach((item) => {\n item.checked = false;\n });\n item.checked = curChecked;\n }\n const closeFeedback = () => {\n emit('closeFeedback');\n }\n\n const showInput = computed(() => {\n return props.feedbackList.find((item) => {\n if (item.title === '其他') {\n return item.checked;\n }\n return false;\n });\n })\n\n watch(() => props.feedbackList, () => {\n otherContent.value = '';\n })\n\n const submitHandler = () => {\n const reason = props.feedbackList.filter((item) => {\n return item.checked;\n }).map((item) => {\n return item.content;\n });\n\n // 是否选择了其他\n const otherChecked = props.feedbackList.find((item) => {\n return item.title === '其他' && item.checked;\n });\n\n if (otherContent.value && otherChecked) {\n const index = reason.findIndex((item) => {\n return item === '其他';\n });\n reason.splice(index, 1, otherContent.value);\n }\n\n emit('submit', reason);\n }\n\n return {\n showInput,\n otherContent,\n selectdReason,\n itemClick,\n closeFeedback,\n submitHandler\n }\n },\n render() {\n if (!this.show) return null;\n return (\n <div class=\"feedback-wrapper\">\n <div class=\"feedback-title\">\n <span>\n {this.feedbackTitle}\n </span>\n <span \n class='close'\n onClick={this.closeFeedback}\n ></span>\n </div>\n <div class=\"feedback-content\">\n <div class=\"feedback-list\">\n {\n this.feedbackList.map((item, index) => (\n <span\n class={item.checked ? 'feedback-item checked' : 'feedback-item'}\n key={index}\n onClick={() => this.itemClick(item)}\n >\n <span>{item.title}</span>\n </span>\n ))\n }\n {\n this.showInput && (\n <ElInput\n class=\"other-input\"\n placeholder='其他原因'\n modelValue={this.otherContent}\n onUpdate:modelValue={(val) => this.otherContent = val}\n />\n )\n }\n </div>\n <div class=\"footer\">\n <ElButton \n disabled={!this.selectdReason} \n class=\"submit\" \n type=\"primary\"\n onClick={this.submitHandler}\n >提交</ElButton>\n </div>\n </div>\n </div>\n )\n }\n})","import { defineComponent, ref, computed, useTemplateRef, watch, nextTick, PropType } from 'vue';\nimport copy from 'copy-to-clipboard';\nimport Feedback from './feedback';\n// @ts-ignore\nimport regenerate from './static/regenerate.svg';\n// @ts-ignore\nimport copyIcon from './static/copy.svg';\n// @ts-ignore\nimport like from './static/like.svg';\n// @ts-ignore\nimport dislike from './static/dislike.svg';\nimport './style/actionBar.less';\nimport { ElMessage } from 'element-plus';\nimport { FeedbackItem, MessageItem } from './index';\nimport xMarkdown from '../x-markdown';\n\nconst disLikeFeedbackListref = [\n {\n title: '没有帮助',\n content: '没有帮助',\n checked: false\n },\n {\n title: '有害/不安全',\n content: '有害/不安全',\n checked: false,\n },\n {\n title: '信息虚假',\n content: '信息虚假',\n checked: false,\n },\n {\n title: '隐私相关',\n content: '隐私相关',\n checked: false,\n },\n {\n title: '其他',\n content: '其他',\n checked: false,\n },\n];\n\nconst likeFeedbackListref = [\n {\n title: '内容准确',\n content: '内容准确',\n checked: false,\n },\n {\n title: '易于理解',\n content: '易于理解',\n checked: false,\n },\n {\n title: '内容完善',\n content: '内容完善',\n checked: false,\n },\n {\n title: '其他',\n content: '其他',\n checked: false,\n }\n]\n\nexport interface BtnItemConfig {\n icon: string;\n type: 'regenerate' | 'copy' | 'like' | 'dislike';\n}\n\nexport default defineComponent({\n name: 'ActionBar',\n props: {\n content: {\n type: String,\n default: ''\n },\n isLast: {\n type: Boolean,\n default: false\n },\n disLikeFeedbackList: {\n type: Array<FeedbackItem>,\n default: () => disLikeFeedbackListref\n },\n likeFeedbackList: {\n type: Array<FeedbackItem>,\n default: () => likeFeedbackListref\n },\n message: {\n type: Object as PropType<MessageItem>,\n default: () => ({})\n }\n },\n emits: ['click'],\n setup(props, { emit}) {\n const feedbackList = ref<FeedbackItem[]>([])\n const xMarkDownCopy = useTemplateRef<typeof xMarkdown>('x-markdown-copy')\n const feedbackTitle = ref('你觉得什么让你不满意?');\n const needOtherContent = ref(false);\n const copyContent = ref('');\n\n const btns = computed(() => {\n const list: Array<BtnItemConfig> = [\n {\n icon: copyIcon,\n type: 'copy'\n },\n {\n icon: like,\n type: 'like'\n },\n {\n icon: dislike,\n type: 'dislike'\n }\n ]\n if (props.isLast) {\n list.unshift({\n icon: regenerate,\n type: 'regenerate'\n })\n }\n return list;\n })\n const activeBtn = ref<BtnItemConfig['type'] | null>(null);\n const showFeedback = ref(false);\n\n watch(() => props.message?.feedback, (val) => {\n if (val) {\n activeBtn.value = val;\n }\n }, {\n immediate: true\n })\n\n const hideFeedback = () => {\n showFeedback.value = false;\n }\n\n const triggerActive = (type: BtnItemConfig['type']) => {\n if (activeBtn.value === type) {\n hideFeedback();\n activeBtn.value = null;\n } else {\n activeBtn.value = type;\n }\n }\n const copyContentHandler = () => {\n // 截取props.content中</details>之后的内容\n let content = props.content.split('</details>')[1]?.split?.('<div hidden>')?.[0];\n // 过滤角标\n const regex = /<sub ([^>]+)>([^<]+)<\\/sub>/g;\n content = content.replace(regex, '');\n copyContent.value = content;\n setTimeout(() => {\n const content = xMarkDownCopy.value?.getContentText();\n copy(content!);\n ElMessage.success('已复制净化文本');\n }, 100);\n }\n\n const triggerEvent = (type: BtnItemConfig['type'], content?: any, cancel?: boolean) => {\n emit('click', type, content, cancel);\n }\n\n const btnClick = (e: Event, type: BtnItemConfig['type']) => {\n if (activeBtn.value === type) {\n triggerEvent(type, null, true);\n } else {\n triggerEvent(type);\n }\n \n const ignore = ['regenerate', 'copy'];\n \n switch (type) {\n case 'copy':\n copyContentHandler();\n break;\n case 'dislike':\n feedbackTitle.value = '你觉得什么让你不满意?';\n showFeedback.value = props.disLikeFeedbackList.length > 0;\n feedbackList.value = props.disLikeFeedbackList;\n needOtherContent.value = true;\n break;\n case 'like':\n feedbackTitle.value = '你觉得什么让你满意?';\n showFeedback.value = props.likeFeedbackList.length > 0;\n feedbackList.value = props.likeFeedbackList;\n needOtherContent.value = false;\n break;\n case 'regenerate':\n break;\n default:\n const other: never = type;\n break;\n }\n if (ignore.includes(type)) return;\n triggerActive(type);\n }\n\n const submitFeedback = (res) => {\n triggerEvent(activeBtn.value!, res);\n hideFeedback();\n }\n\n return {\n btns,\n activeBtn,\n showFeedback,\n feedbackList,\n feedbackTitle,\n needOtherContent,\n copyContent,\n triggerEvent,\n btnClick,\n hideFeedback,\n submitFeedback\n };\n },\n render() {\n return (\n <div class=\"action-bar-wrapper\">\n <div class=\"button-wrapper\">\n {\n this.btns.map((btn) => {\n return (\n <div class=\"btn-item\">\n <img\n src={btn.icon}\n class={this.activeBtn === btn.type ? 'active' : ''}\n onClick={(e) => this.btnClick(e, btn.type)}\n />\n </div>\n );\n })\n }\n </div>\n <Feedback\n show={this.showFeedback}\n feedbackList={this.feedbackList}\n feedbackTitle={this.feedbackTitle}\n onCloseFeedback={this.hideFeedback}\n needOtherContent={this.needOtherContent}\n onSubmit={this.submitFeedback}\n />\n\n <x-markdown\n style=\"position: absolute; top: -9999px; left: -9999px\"\n ref=\"x-markdown-copy\"\n text={this.copyContent}\n />\n </div>\n );\n }\n});","export default \"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6.33337%205.73672V4.19702C6.33337%203.67925%206.75311%203.25952%207.27087%203.25952H15.3959C15.9136%203.25952%2016.3334%203.67925%2016.3334%204.19702V12.322C16.3334%2012.8398%2015.9136%2013.2595%2015.3959%2013.2595H13.8388'%20stroke='%2353576A'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M12.7291%205.92603H4.60413C4.08636%205.92603%203.66663%206.34576%203.66663%206.86353V14.9885C3.66663%2015.5063%204.08636%2015.926%204.60413%2015.926H12.7291C13.2469%2015.926%2013.6666%2015.5063%2013.6666%2014.9885V6.86353C13.6666%206.34576%2013.2469%205.92603%2012.7291%205.92603Z'%20stroke='%2353576A'%20stroke-width='1.5'%20stroke-linejoin='round'/%3e%3c/svg%3e\"","export default \"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M11.3509%207.72498V5.025C11.3509%203.90662%2010.4443%203%209.32596%203L6.62598%209.07497V16.4999H14.4694C15.1426%2016.5075%2015.7185%2016.018%2015.8194%2015.3524L16.7509%209.27746C16.8103%208.88586%2016.6948%208.48791%2016.4349%208.18904C16.175%207.89016%2015.797%207.72048%2015.4009%207.72498H11.3509Z'%20stroke='%2353576A'%20stroke-width='1.34999'%20stroke-linejoin='round'/%3e%3cpath%20d='M6.62583%208.99998H4.82359C4.03284%208.98599%203.35687%209.641%203.25085%2010.4247V15.1497C3.35687%2015.9334%204.03284%2016.5136%204.82359%2016.4997H6.62583V8.99998Z'%20stroke='%2353576A'%20stroke-width='1.34999'%20stroke-linejoin='round'/%3e%3c/svg%3e\"","export default \"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M8.64049%2012.275V14.975C8.64049%2016.0934%209.54708%2017%2010.6655%2017L13.3655%2010.925V3.50009H5.52201C4.84885%203.49248%204.27295%203.98199%204.17201%204.64758L3.24052%2010.7225C3.18108%2011.1141%203.29661%2011.5121%203.55651%2011.811C3.81641%2012.1098%204.19445%2012.2795%204.59051%2012.275H8.64049Z'%20stroke='%23195FFF'%20stroke-width='1.34999'%20stroke-linejoin='round'/%3e%3cpath%20d='M13.3656%203.5H15.1678C15.9586%203.48602%2016.6346%204.06626%2016.7406%204.84999V9.57497C16.6346%2010.3587%2015.9586%2011.0139%2015.1678%2011H13.3656V3.5Z'%20stroke='%23195FFF'%20stroke-width='1.34999'%20stroke-linejoin='round'/%3e%3c/svg%3e\"","export default \"data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14.2426%2013.8354C13.1569%2014.9212%2011.6569%2015.5928%2010%2015.5928C6.6863%2015.5928%204%2012.9065%204%209.59277C4%206.27907%206.6863%203.59277%2010%203.59277C11.6569%203.59277%2013.1569%204.26435%2014.2426%205.35014C14.7953%205.90281%2016%207.25944%2016%207.25944'%20stroke='%2353576A'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20d='M16%204.25952V7.25952H13'%20stroke='%2353576A'%20stroke-width='1.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e\"","import { defineComponent, nextTick, onMounted, ref, useTemplateRef, watch } from 'vue';\nimport { BubbleList, FilesCard } from 'vue-element-plus-x';\nimport type { BubbleListItemProps } from 'vue-element-plus-x/types/BubbleList';\nimport './style/index.less';\nimport ActionBar, { BtnItemConfig } from './actionBar';\n\nexport interface FeedbackItem {\n title: string;\n content: string;\n checked: boolean;\n // showInput?: boolean; // 是否显示输入框\n}\n\nexport interface MessageItem extends BubbleListItemProps {\n role: 'user' | 'ai';\n questions?: Array<string>;\n speed?: number;\n id: string;\n showActions?: boolean;\n feedback?: 'like' | 'dislike';\n files?: Array<{\n id: string,\n extension: string,\n name: string,\n }>;\n}\n\nexport default defineComponent({\n props: {\n list: {\n type: Array as () => Array<MessageItem>,\n default: () => [],\n },\n btnLoading: {\n type: Boolean,\n default: true,\n },\n maxHeight: {\n type: String,\n default: '500px',\n },\n autoHideThinking: {\n type: Boolean,\n default: true,\n },\n speed: {\n type: Number,\n default: 200,\n },\n disLikeFeedbackList: {\n type: Array as () => Array<FeedbackItem>,\n default: () => undefined,\n },\n likeFeedbackList: {\n type: Array as () => Array<FeedbackItem>,\n default: () => undefined,\n },\n },\n expose: ['showLastActionGroup', 'scrollToBottom', 'hideLastActionGroup'],\n emits: [\n 'hoverActiveRefTrigger',\n 'clickActiveRefTrigger',\n 'like',\n 'dislike',\n 'regenerate',\n 'copy',\n 'refConfigUpdate',\n 'questionClick',\n 'downloadFile',\n ],\n setup(props, { emit }) {\n const bubbleList = useTemplateRef<typeof BubbleList>('bubbleList');\n const bubbleListContainer = useTemplateRef<Element>('bubbleListContainer');\n const showLastBubbleFooter = ref(false);\n const curActiveItem = ref<Element | null>(null);\n const destoryObserver = ref<Function>(() => {});\n\n watch(() => curActiveItem.value, (newVal, oldVal) => {\n if (newVal === null) {\n return;\n }\n if (oldVal === newVal) {\n return;\n }\n const refContainer = (curActiveItem.value as HTMLElement)?.querySelector('div[hidden]');\n const curRefList = JSON.parse(refContainer?.textContent || '[]');\n emit('refConfigUpdate', curRefList);\n })\n\n watch(() => props.list.length, () => {\n nextTick(() => {\n destoryObserver.value();\n destoryObserver.value = scrollTrigger();\n })\n })\n\n const hoverActiveRefTrigger = (item) => {\n emit('hoverActiveRefTrigger', item);\n }\n\n const clickActiveRefTrigger = (item) => {\n emit('clickActiveRefTrigger', item);\n }\n\n const showLastActionGroup = () => {\n showLastBubbleFooter.value = true;\n }\n\n const hideLastActionGroup = () => {\n showLastBubbleFooter.value = false;\n }\n\n const clickAction = (type: BtnItemConfig['type'], content, cancel, item) => {\n emit(type, { content, message: item, cancel })\n }\n\n const scrollToBottom = () => {\n (bubbleList.value as any)?.scrollToBottom();\n }\n\n const lastRefConfigUpdate = (refList, item) => {\n // 更新最后一条消息的引用列表\n if (props.list[props.list.length - 1] === item) {\n emit('refConfigUpdate', refList);\n }\n }\n\n const getQuestions = (item) => {\n if (item.questions && item.questions.length > 0) {\n return (\n <div class='question-list'>\n {\n item.questions.map((question, index) => {\n return (\n <span\n class='question-item'\n key={index}\n onClick={() => questionClick(question)}\n >\n {question}\n <span class='icon'></span>\n </span>\n )\n })\n }\n </div>\n )\n }\n return null;\n }\n\n const questionClick = (q) => {\n emit('questionClick', q)\n }\n\n const isLastItem = (item: MessageItem) => {\n return props.list[props.list.length - 1] === item;\n }\n\n const getActionBar = (item: MessageItem) => {\n // 如果当前项中明确指定不显示actionbar,则不显示\n if (typeof item.showActions === 'boolean' && !item.showActions) {\n return null;\n }\n const isLast = isLastItem(item);\n if (isLast && showLastBubbleFooter.value) {\n return (\n <ActionBar\n isLast={isLast}\n content={item.content}\n message={item}\n disLikeFeedbackList={props.disLikeFeedbackList}\n likeFeedbackList={props.likeFeedbackList}\n onClick={(type, content, cancel) => clickAction(type, content, cancel, item)}\n />\n )\n }\n if (!isLast) {\n return (\n <ActionBar\n isLast={isLast}\n content={item.content}\n message={item}\n disLikeFeedbackList={props.disLikeFeedbackList}\n likeFeedbackList={props.likeFeedbackList}\n onClick={(type, content, cancel) => clickAction(type, content, cancel, item)}\n />\n );\n }\n }\n\n const onDownloadFile = (payload) => {\n emit('downloadFile', payload);\n }\n\n const scrollTrigger = () => {\n const messageItems = bubbleListContainer.value!.querySelectorAll('.el-bubble-start');\n\n const observer = new IntersectionObserver((entries) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n const itemBottom = entry.boundingClientRect.bottom;\n const height = entry.target.clientHeight;\n const listBottom = bubbleListContainer.value!.getBoundingClientRect().bottom;\n \n if (Math.abs(itemBottom - listBottom) < height) {\n curActiveItem.value = entry.target;\n }\n }\n });\n }, {\n root: bubbleListContainer.value!,\n threshold: [0.1, 0.9]\n });\n\n // 3. 为所有消息项添加监听\n messageItems.forEach(item => {\n observer.observe(item);\n });\n\n return () => {\n observer.disconnect();\n }\n }\n\n onMounted(() => {\n destoryObserver.value = scrollTrigger();\n })\n\n return {\n hoverActiveRefTrigger,\n showLastActionGroup,\n hideLastActionGroup,\n showLastBubbleFooter,\n clickActiveRefTrigger,\n clickAction,\n scrollToBottom,\n lastRefConfigUpdate,\n getQuestions,\n questionClick,\n isLastItem,\n getActionBar,\n onDownloadFile,\n };\n },\n\n render() {\n return (\n <div\n ref=\"bubbleListContainer\"\n class=\"bubble-list\"\n >\n <BubbleList\n ref=\"bubbleList\"\n list={this.list}\n btnLoading={this.btnLoading}\n maxHeight={this.maxHeight}\n >\n {{\n header: ({ item }: { item: MessageItem }) => {\n if (!item.files?.length) {\n return null;\n }\n return (\n <div class=\"bubble-item-header\">\n {\n item.files.map((item) => (\n <FilesCard\n name={item.name}\n status=\"done\"\n />\n ))\n }\n </div>\n )\n },\n content: ({ item }: { item: MessageItem }) => (\n <x-markdown\n key={item.id}\n typing={item.typing}\n speed={this.speed}\n text={item.content}\n autoHideThinking={this.autoHideThinking}\n onHoverActiveRefTrigger={this.hoverActiveRefTrigger}\n onClickActiveRefTrigger={this.clickActiveRefTrigger}\n onRefConfigUpdate={(refList) => this.lastRefConfigUpdate(refList, item)}\n onDownloadFile={this.onDownloadFile}\n />\n ),\n footer: ({ item }: { item: MessageItem }) => {\n if (item.role === 'ai') {\n return (\n <div>\n {\n this.getActionBar(item)\n }\n {\n this.getQuestions(item)\n }\n </div>\n )\n }\n return null;\n }\n }}\n </BubbleList>\n </div>\n );\n }\n});"],"names":["deselectCurrent","toggleSelection","selection","document","getSelection","rangeCount","active","activeElement","ranges","i","push","getRangeAt","tagName","toUpperCase","blur","removeAllRanges","type","forEach","range","addRange","focus","clipboardToIE11Formatting","default","copyToClipboard","text","options","debug","message","reselectPrevious","mark","success","createRange","createElement","textContent","ariaHidden","style","all","position","top","clip","whiteSpace","webkitUserSelect","MozUserSelect","msUserSelect","userSelect","addEventListener","e","stopPropagation","format","preventDefault","clipboardData","console","warn","window","clearData","setData","onCopy","body","appendChild","selectNodeContents","execCommand","Error","err","error","copyKey","test","navigator","userAgent","replace","prompt","removeRange","removeChild","Feedback","name","props","show","Boolean","feedbackList","Array","feedbackTitle","String","needOtherContent","emits","setup","emit","otherContent","ref","selectdReason","computed","find","item","title","checked","value","some","showInput","watch","itemClick","curChecked","closeFeedback","submitHandler","reason","filter","map","content","otherChecked","index","findIndex","splice","render","this","_createVNode","class","onClick","key","ElInput","placeholder","modelValue","val","ElButton","disabled","_createTextVNode","disLikeFeedbackListref","likeFeedbackListref","ActionBar","isLast","disLikeFeedbackList","likeFeedbackList","Object","xMarkDownCopy","useTemplateRef","copyContent","btns","list","icon","unshift","activeBtn","showFeedback","feedback","immediate","hideFeedback","triggerEvent","cancel","btnClick","copyContentHandler","split","setTimeout","getContentText","copy","ElMessage","length","includes","triggerActive","submitFeedback","res","btn","src","onCloseFeedback","onSubmit","_resolveComponent","btnLoading","maxHeight","autoHideThinking","speed","Number","expose","bubbleList","bubbleListContainer","showLastBubbleFooter","curActiveItem","destoryObserver","newVal","oldVal","refContainer","querySelector","curRefList","JSON","parse","nextTick","scrollTrigger","clickAction","questionClick","q","isLastItem","messageItems","querySelectorAll","observer","IntersectionObserver","entries","entry","isIntersecting","itemBottom","boundingClientRect","bottom","height","target","clientHeight","listBottom","getBoundingClientRect","Math","abs","root","threshold","observe","disconnect","onMounted","hoverActiveRefTrigger","showLastActionGroup","hideLastActionGroup","clickActiveRefTrigger","scrollToBottom","lastRefConfigUpdate","refList","getQuestions","questions","question","getActionBar","showActions","onDownloadFile","payload","BubbleList","header","files","FilesCard","status","id","typing","onHoverActiveRefTrigger","onClickActiveRefTrigger","onRefConfigUpdate","footer","role"],"mappings":"ijBAEA,IAAIA,WCDJC,EAAiB,WACf,IAAIC,EAAYC,SAASC,eACzB,IAAKF,EAAUG,WACb,OAAO,WAAY,EAKrB,IAHA,IAAIC,EAASH,SAASI,cAElBC,EAAS,GACJC,EAAI,EAAGA,EAAIP,EAAUG,WAAYI,IACxCD,EAAOE,KAAKR,EAAUS,WAAWF,IAGnC,OAAQH,EAAOM,QAAQC,eACrB,IAAK,QACL,IAAK,WACHP,EAAOQ,OACP,MAEF,QACER,EAAS,KAKb,OADAJ,EAAUa,kBACH,WACc,UAAnBb,EAAUc,MACVd,EAAUa,kBAELb,EAAUG,YACbG,EAAOS,QAAQ,SAASC,GACtBhB,EAAUiB,SAASD,EAC3B,GAGIZ,GACAA,EAAOc,OACX,CACA,GDlCIC,EAA4B,CAC9B,aAAc,OACd,YAAa,MACbC,QAAW,eA2GbC,EAjGA,SAAcC,EAAMC,GAClB,IAAIC,EACFC,EACAC,EACAV,EACAhB,EACA2B,EACAC,GAAU,EACPL,IACHA,EAAU,CAAA,GAEZC,EAAQD,EAAQC,QAAS,EACzB,IAkDE,GAjDAE,EAAmB5B,IAEnBkB,EAAQf,SAAS4B,cACjB7B,EAAYC,SAASC,gBAErByB,EAAO1B,SAAS6B,cAAc,SACzBC,YAAcT,EAEnBK,EAAKK,WAAa,OAElBL,EAAKM,MAAMC,IAAM,QAEjBP,EAAKM,MAAME,SAAW,QACtBR,EAAKM,MAAMG,IAAM,EACjBT,EAAKM,MAAMI,KAAO,mBAElBV,EAAKM,MAAMK,WAAa,MAExBX,EAAKM,MAAMM,iBAAmB,OAC9BZ,EAAKM,MAAMO,cAAgB,OAC3Bb,EAAKM,MAAMQ,aAAe,OAC1Bd,EAAKM,MAAMS,WAAa,OACxBf,EAAKgB,iBAAiB,OAAQ,SAASC,GAErC,GADAA,EAAEC,kBACEtB,EAAQuB,OAEV,GADAF,EAAEG,sBAC6B,IAApBH,EAAEI,cAA+B,CAC1CxB,GAASyB,QAAQC,KAAK,iCACtB1B,GAASyB,QAAQC,KAAK,4BACtBC,OAAOH,cAAcI,YACrB,IAAIN,EAAS3B,EAA0BI,EAAQuB,SAAW3B,EAAmC,QAC7FgC,OAAOH,cAAcK,QAAQP,EAAQxB,EAC/C,MACUsB,EAAEI,cAAcI,YAChBR,EAAEI,cAAcK,QAAQ9B,EAAQuB,OAAQxB,GAGxCC,EAAQ+B,SACVV,EAAEG,iBACFxB,EAAQ+B,OAAOV,EAAEI,eAEzB,GAEI/C,SAASsD,KAAKC,YAAY7B,GAE1BX,EAAMyC,mBAAmB9B,GACzB3B,EAAUiB,SAASD,IAEFf,SAASyD,YAAY,QAEpC,MAAM,IAAIC,MAAM,iCAElB/B,GAAU,CACd,OAAWgC,GACPpC,GAASyB,QAAQY,MAAM,qCAAsCD,GAC7DpC,GAASyB,QAAQC,KAAK,4BACtB,IACEC,OAAOH,cAAcK,QAAQ9B,EAAQuB,QAAU,OAAQxB,GACvDC,EAAQ+B,QAAU/B,EAAQ+B,OAAOH,OAAOH,eACxCpB,GAAU,CAChB,OAAagC,GACPpC,GAASyB,QAAQY,MAAM,uCAAwCD,GAC/DpC,GAASyB,QAAQY,MAAM,0BACvBpC,EAjFN,SAAgBA,GACd,IAAIqC,GAAW,YAAYC,KAAKC,UAAUC,WAAa,IAAM,QAAU,KACvE,OAAOxC,EAAQyC,QAAQ,gBAAiBJ,EAC1C,CA8EgBhB,CAAO,YAAavB,EAAUA,EAAQE,QAnFjC,oCAoFf0B,OAAOgB,OAAO1C,EAASH,EAC7B,CACA,CAAA,QACQtB,IACkC,mBAAzBA,EAAUoE,YACnBpE,EAAUoE,YAAYpD,GAEtBhB,EAAUa,mBAIVc,GACF1B,SAASsD,KAAKc,YAAY1C,GAE5BD,GACJ,CAEE,OAAOE,CACT,ME3GA0C,oBAA+B,CAC7BC,KAAM,WACNC,MAAO,CACLC,KAAM,CACJ3D,KAAM4D,QACNtD,SAAS,GAEXuD,aAAc,CACZ7D,KAAM8D,MACNxD,QAASA,IAAM,IAEjByD,cAAe,CACb/D,KAAMgE,OACN1D,QAAS,eAEX2D,iBAAkB,CAChBjE,KAAM4D,QACNtD,SAAS,IAGb4D,MAAO,CAAC,gBAAiB,UACzBC,KAAAA,CAAMT,GAAOU,KAACA,IACZ,MAAMC,EAAeC,EAAAA,IAAI,IACnBC,EAAgBC,EAAAA,SAAS,MAERd,EAAMG,aAAaY,KAAMC,GACzB,OAAfA,EAAKC,OACAD,EAAKE,WAIKP,EAAaQ,OAASnB,EAAMO,mBAI1CP,EAAMG,aAAaiB,KAAMJ,GACvBA,EAAKE,UAeVG,EAAYP,EAAAA,SAAS,IAClBd,EAAMG,aAAaY,KAAMC,GACX,OAAfA,EAAKC,OACAD,EAAKE,UAMlBI,QAAM,IAAMtB,EAAMG,aAAc,KAC9BQ,EAAaQ,MAAQ,KAyBvB,MAAO,CACLE,YACAV,eACAE,gBACAU,UAlDiBP,IACjB,MAAMQ,GAAcR,EAAKE,QACzBlB,EAAMG,aAAa5D,QAASyE,IAC1BA,EAAKE,SAAU,IAEjBF,EAAKE,QAAUM,GA8CfC,cA5CoBA,KACpBf,EAAK,kBA4CLgB,cA5BoBA,KACpB,MAAMC,EAAS3B,EAAMG,aAAayB,OAAQZ,GACjCA,EAAKE,SACXW,IAAKb,GACCA,EAAKc,SAIRC,EAAe/B,EAAMG,aAAaY,KAAMC,GACtB,OAAfA,EAAKC,OAAkBD,EAAKE,SAGrC,GAAIP,EAAaQ,OAASY,EAAc,CACtC,MAAMC,EAAQL,EAAOM,UAAWjB,GACd,OAATA,GAETW,EAAOO,OAAOF,EAAO,EAAGrB,EAAaQ,MACvC,CAEAT,EAAK,SAAUiB,IAWnB,EACAQ,MAAAA,GACE,OAAKC,KAAKnC,KACVoC,EAAAA,YAAA,MAAA,CAAAC,MAAA,oBAAA,CAAAD,EAAAA,YAAA,MAAA,CAAAC,MAAA,kBAAA,CAAAD,EAAAA,YAAA,OAAA,KAAA,CAISD,KAAK/B,gBAAagC,EAAAA,YAAA,OAAA,CAAAC,MAAA,QAAAC,QAIVH,KAAKX,eAAa,QAAAY,EAAAA,YAAA,MAAA,CAAAC,MAAA,oBAAA,CAAAD,EAAAA,YAAA,MAAA,CAAAC,MAAA,iBAAA,CAMzBF,KAAKjC,aAAa0B,IAAI,CAACb,EAAMgB,IAAKK,EAAAA,YAAA,OAAA,CAAAC,MAEvBtB,EAAKE,QAAU,wBAA0B,gBAAesB,IAC1DR,EAAKO,QACDA,IAAMH,KAAKb,UAAUP,IAAK,CAAAqB,EAAAA,YAAA,OAAA,KAAA,CAE5BrB,EAAKC,WAKhBmB,KAAKf,WAASgB,EAAAA,YAAAI,EAAAA,QAAA,CAAAH,MAAA,cAAAI,YAAA,OAAAC,WAIEP,KAAKzB,aAAY,sBACPiC,GAAQR,KAAKzB,aAAeiC,GAAG,QAExDP,EAAAA,YAAA,MAAA,CAAAC,MAAA,UAAA,CAAAD,EAAAA,YAAAQ,WAAA,CAAAC,UAKUV,KAAKvB,cAAayB,MAAA,SAAAhG,KAAA,UAAAiG,QAGpBH,KAAKV,eAAa,CAAA9E,QAAAA,IAAA,CAAAmG,EAAAA,gBAAA,eAzCd,IA+CzB,ICpIIC,EAAyB,CAC7B,CACE/B,MAAO,OACPa,QAAS,OACTZ,SAAS,GAEX,CACED,MAAO,SACPa,QAAS,SACTZ,SAAS,GAEX,CACED,MAAO,OACPa,QAAS,OACTZ,SAAS,GAEX,CACED,MAAO,OACPa,QAAS,OACTZ,SAAS,GAEX,CACED,MAAO,KACPa,QAAS,KACTZ,SAAS,IAIP+B,EAAsB,CAC1B,CACEhC,MAAO,OACPa,QAAS,OACTZ,SAAS,GAEX,CACED,MAAO,OACPa,QAAS,OACTZ,SAAS,GAEX,CACED,MAAO,OACPa,QAAS,OACTZ,SAAS,GAEX,CACED,MAAO,KACPa,QAAS,KACTZ,SAAS,IASbgC,oBAA+B,CAC7BnD,KAAM,YACNC,MAAO,CACL8B,QAAS,CACPxF,KAAMgE,OACN1D,QAAS,IAEXuG,OAAQ,CACN7G,KAAM4D,QACNtD,SAAS,GAEXwG,oBAAqB,CACnB9G,KAAM8D,MACNxD,QAASA,IAAMoG,GAEjBK,iBAAkB,CAChB/G,KAAM8D,MACNxD,QAASA,IAAMqG,GAEjBhG,QAAS,CACPX,KAAMgH,OACN1G,QAASA,MAAO,KAGpB4D,MAAO,CAAC,SACRC,KAAAA,CAAMT,GAAOU,KAAEA,IACb,MAAMP,EAAeS,EAAAA,IAAoB,IACnC2C,EAAgBC,EAAAA,eAAiC,mBACjDnD,EAAgBO,EAAAA,IAAI,eACpBL,EAAmBK,EAAAA,KAAI,GACvB6C,EAAc7C,EAAAA,IAAI,IAElB8C,EAAO5C,EAAAA,SAAS,KACpB,MAAM6C,EAA6B,CACjC,CACEC,KC3GK,+0BD4GLtH,KAAM,QAER,CACEsH,KE/GK,0xBFgHLtH,KAAM,QAER,CACEsH,KGnHK,ixBHoHLtH,KAAM,YASV,OANI0D,EAAMmD,QACRQ,EAAKE,QAAQ,CACXD,KIzHK,qpBJ0HLtH,KAAM,eAGHqH,IAEHG,EAAYlD,EAAAA,IAAkC,MAC9CmD,EAAenD,EAAAA,KAAI,GAEzBU,EAAAA,MAAM,WAAMtB,OAAAA,OAAAA,EAAAA,EAAM/C,cAAN+C,EAAAA,EAAegE,UAAWpB,IAChCA,IACFkB,EAAU3C,MAAQyB,IAEnB,CACDqB,WAAW,IAGb,MAAMC,EAAeA,KACnBH,EAAa5C,OAAQ,GAyBjBgD,EAAeA,CAAC7H,EAA6BwF,EAAesC,KAChE1D,EAAK,QAASpE,EAAMwF,EAASsC,IA2C/B,MAAO,CACLV,OACAI,YACAC,eACA5D,eACAE,gBACAE,mBACAkD,cACAU,eACAE,SAjDeA,CAACjG,EAAU9B,KACtBwH,EAAU3C,QAAU7E,EACtB6H,EAAa7H,EAAM,MAAM,GAEzB6H,EAAa7H,GAKf,OAAQA,GACN,IAAK,OA5BkBgI,gBAEzB,IAAIxC,EAAU9B,OAAAA,EAAAA,OAAAA,EAAAA,OAAAA,EAAAA,EAAM8B,QAAQyC,MAAM,cAAc,SAAlCvE,EAAAA,EAAsCuE,YAAtCvE,EAAAA,EAAAA,KAAAA,EAA8C,sBAA9CA,EAAAA,EAAgE,GAG9E8B,EAAUA,EAAQpC,QADJ,+BACmB,IACjC+D,EAAYtC,MAAQW,EACpB0C,WAAW,WACT,MAAM1C,EAAUyB,OAAAA,EAAAA,EAAcpC,cAAdoC,EAAqBkB,iBACrCC,EAAK5C,GACL6C,EAAAA,UAAUvH,QAAQ,YACjB,MAkBCkH,GACA,MACF,IAAK,UACHjE,EAAcc,MAAQ,cACtB4C,EAAa5C,MAAQnB,EAAMoD,oBAAoBwB,OAAS,EACxDzE,EAAagB,MAAQnB,EAAMoD,oBAC3B7C,EAAiBY,OAAQ,EACzB,MACF,IAAK,OACHd,EAAcc,MAAQ,aACtB4C,EAAa5C,MAAQnB,EAAMqD,iBAAiBuB,OAAS,EACrDzE,EAAagB,MAAQnB,EAAMqD,iBAC3B9C,EAAiBY,OAAQ,EAhBd,CAAC,aAAc,QAwBnB0D,SAASvI,IAzDCA,CAAAA,IACjBwH,EAAU3C,QAAU7E,GACtB4H,IACAJ,EAAU3C,MAAQ,MAElB2C,EAAU3C,MAAQ7E,GAqDpBwI,CAAcxI,IAkBd4H,eACAa,eAhBsBC,IACtBb,EAAaL,EAAU3C,MAAQ6D,GAC/Bd,KAgBJ,EACA/B,MAAAA,GACE,OAAAE,EAAAA,YAAA,MAAA,CAAAC,MAAA,sBAAA,CAAAD,EAAAA,YAAA,MAAA,CAAAC,MAAA,kBAAA,CAIQF,KAAKsB,KAAK7B,IAAKoD,GACb5C,EAAAA,YAAA,MAAA,CAAAC,MAAA,YAAA,CAAAD,EAAAA,YAAA,MAAA,CAAA6C,IAGWD,EAAIrB,KAAItB,MACNF,KAAK0B,YAAcmB,EAAI3I,KAAO,SAAW,GAAEiG,QACxCnE,GAAMgE,KAAKiC,SAASjG,EAAG6G,EAAI3I,OAAK,WAIhD+F,EAAAA,YAAAvC,EAAA,CAAAG,KAIEmC,KAAK2B,aAAY5D,aACTiC,KAAKjC,aAAYE,cAChB+B,KAAK/B,cAAa8E,gBAChB/C,KAAK8B,aAAY3D,iBAChB6B,KAAK7B,iBAAgB6E,SAC7BhD,KAAK2C,gBAAc,MAAA1C,EAAAA,YAAAgD,EAAAA,iBAAA,cAAA,CAAA5H,MAAA,kDAAAmD,IAAA,kBAAA9D,KAMvBsF,KAAKqB,aAAW,OAI9B,IKrOFzB,oBAA+B,CAC7BhC,MAAO,CACL2D,KAAM,CACJrH,KAAM8D,MACNxD,QAASA,IAAM,IAEjB0I,WAAY,CACVhJ,KAAM4D,QACNtD,SAAS,GAEX2I,UAAW,CACTjJ,KAAMgE,OACN1D,QAAS,SAEX4I,iBAAkB,CAChBlJ,KAAM4D,QACNtD,SAAS,GAEX6I,MAAO,CACLnJ,KAAMoJ,OACN9I,QAAS,KAEXwG,oBAAqB,CACnB9G,KAAM8D,MACNxD,QAASA,QAEXyG,iBAAkB,CAChB/G,KAAM8D,MACNxD,QAASA,SAGb+I,OAAQ,CAAC,sBAAuB,iBAAkB,uBAClDnF,MAAO,CACL,wBACA,wBACA,OACA,UACA,aACA,OACA,kBACA,gBACA,gBAEFC,KAAAA,CAAMT,GAAOU,KAAEA,IACb,MAAMkF,EAAapC,EAAAA,eAAkC,cAC/CqC,EAAsBrC,EAAAA,eAAwB,uBAC9CsC,EAAuBlF,EAAAA,KAAI,GAC3BmF,EAAgBnF,EAAAA,IAAoB,MACpCoF,EAAkBpF,EAAAA,IAAc,QAEtCU,EAAAA,MAAM,IAAMyE,EAAc5E,MAAO,CAAC8E,EAAQC,WACxC,GAAe,OAAXD,EACF,OAEF,GAAIC,IAAWD,EACb,OAEF,MAAME,EAAgBJ,OAAAA,EAAAA,EAAc5E,YAAd4E,EAAAA,EAAqCK,cAAc,eACnEC,EAAaC,KAAKC,OAAMJ,MAAAA,OAAAA,EAAAA,EAAc5I,cAAe,MAC3DmD,EAAK,kBAAmB2F,KAG1B/E,EAAAA,MAAM,IAAMtB,EAAM2D,KAAKiB,OAAQ,KAC7B4B,EAAAA,SAAS,KACPR,EAAgB7E,QAChB6E,EAAgB7E,MAAQsF,QAI5B,MAgBMC,EAAcA,CAACpK,EAA6BwF,EAASsC,EAAQpD,KACjEN,EAAKpE,EAAM,CAAEwF,UAAS7E,QAAS+D,EAAMoD,YAsCjCuC,EAAiBC,IACrBlG,EAAK,gBAAiBkG,IAGlBC,EAAc7F,GACXhB,EAAM2D,KAAK3D,EAAM2D,KAAKiB,OAAS,KAAO5D,EAuCzCyF,EAAgBA,KACpB,MAAMK,EAAejB,EAAoB1E,MAAO4F,iBAAiB,oBAE3DC,EAAW,IAAIC,qBAAsBC,IACzCA,EAAQ3K,QAAQ4K,IACd,GAAIA,EAAMC,eAAgB,CACxB,MAAMC,EAAaF,EAAMG,mBAAmBC,OACtCC,EAASL,EAAMM,OAAOC,aACtBC,EAAa9B,EAAoB1E,MAAOyG,wBAAwBL,OAElEM,KAAKC,IAAIT,EAAaM,GAAcH,IACtCzB,EAAc5E,MAAQgG,EAAMM,OAEhC,KAED,CACDM,KAAMlC,EAAoB1E,MAC1B6G,UAAW,CAAC,GAAK,MAQnB,OAJAlB,EAAavK,QAAQyE,IACnBgG,EAASiB,QAAQjH,KAGZ,KACLgG,EAASkB,eAQb,OAJAC,EAAAA,UAAU,KACRnC,EAAgB7E,MAAQsF,MAGnB,CACL2B,sBAtI6BpH,IAC7BN,EAAK,wBAAyBM,IAsI9BqH,oBA/H0BA,KAC1BvC,EAAqB3E,OAAQ,GA+H7BmH,oBA5H0BA,KAC1BxC,EAAqB3E,OAAQ,GA4H7B2E,uBACAyC,sBAtI6BvH,IAC7BN,EAAK,wBAAyBM,IAsI9B0F,cACA8B,eAxHqBA,WACpB5C,OAAAA,EAAAA,EAAWzE,QAAXyE,EAA0B4C,kBAwH3BC,oBArH0BA,CAACC,EAAS1H,KAEhChB,EAAM2D,KAAK3D,EAAM2D,KAAKiB,OAAS,KAAO5D,GACxCN,EAAK,kBAAmBgI,IAmH1BC,aA/GoB3H,GAChBA,EAAK4H,WAAa5H,EAAK4H,UAAUhE,OAAS,EAC5CvC,EAAAA,YAAA,MAAA,CAAAC,MAAA,iBAAA,CAGMtB,EAAK4H,UAAU/G,IAAI,CAACgH,EAAU7G,IAC5BK,EAAAA,YAAA,OAAA,CAAAC,MAAA,gBAAAE,IAGSR,EAAKO,QACDA,IAAMoE,EAAckC,IAAS,CAErCA,EAAQxG,EAAAA,YAAA,OAAA,CAAAC,MAAA,QAAA,WAShB,KA2FPqE,gBACAE,aACAiC,aAlFoB9H,IAEpB,GAAgC,kBAArBA,EAAK+H,cAA8B/H,EAAK+H,YACjD,OAAO,KAET,MAAM5F,EAAS0D,EAAW7F,GAC1B,OAAImC,GAAU2C,EAAqB3E,MACjCkB,EAAAA,YAAAa,EAAA,CAAAC,OAEYA,EAAMrB,QACLd,EAAKc,QAAO7E,QACZ+D,EAAIoC,oBACQpD,EAAMoD,oBAAmBC,iBAC5BrD,EAAMqD,iBAAgBd,QAC/BA,CAACjG,EAAMwF,EAASsC,IAAWsC,EAAYpK,EAAMwF,EAASsC,EAAQpD,IAAK,MAI7EmC,OAAL,EACEd,EAAAA,YAAAa,EAAA,CAAAC,OAEYA,EAAMrB,QACLd,EAAKc,QAAO7E,QACZ+D,EAAIoC,oBACQpD,EAAMoD,oBAAmBC,iBAC5BrD,EAAMqD,iBAAgBd,QAC/BA,CAACjG,EAAMwF,EAASsC,IAAWsC,EAAYpK,EAAMwF,EAASsC,EAAQpD,IAAK,OAyDlFgI,eAnDsBC,IACtBvI,EAAK,eAAgBuI,IAoDzB,EAEA9G,MAAAA,GACE,OAAAE,EAAAA,YAAA,MAAA,CAAAzB,IAAA,sBAAA0B,MAAA,eAAA,CAAAD,EAAAA,YAAA6G,aAAA,CAAAtI,IAAA,aAAA+C,KAOYvB,KAAKuB,KAAI2B,WACHlD,KAAKkD,WAAUC,UAChBnD,KAAKmD,WAAS,CAGvB4D,OAAQA,EAAGnI,iBACT,OAAKA,OAAAA,EAAAA,EAAKoI,YAALpI,EAAAA,EAAY4D,QAGjBvC,EAAAA,YAAA,MAAA,CAAAC,MAAA,sBAAA,CAGMtB,EAAKoI,MAAMvH,IAAKb,GAAIqB,EAAAA,YAAAgH,YAAA,CAAAtJ,KAEViB,EAAKjB,KAAIuJ,OAAA,QAAA,SAPhB,MAeXxH,QAASA,EAAGd,UAA6BqB,EAAAA,YAAAgD,mBAAA,cAAA,CAAA7C,IAEhCxB,EAAKuI,GAAEC,OACJxI,EAAKwI,OAAM/D,MACZrD,KAAKqD,MAAK3I,KACXkE,EAAKc,QAAO0D,iBACApD,KAAKoD,iBAAgBiE,wBACdrH,KAAKgG,sBAAqBsB,wBAC1BtH,KAAKmG,sBAAqBoB,kBAC/BjB,GAAYtG,KAAKqG,oBAAoBC,EAAS1H,GAAKgI,eACvD5G,KAAK4G,gBAAc,MAGvCY,OAAQA,EAAG5I,UACS,OAAdA,EAAK6I,KACPxH,cAAA,MAAA,KAAA,CAGMD,KAAK0G,aAAa9H,GAGlBoB,KAAKuG,aAAa3H,KAKnB,QAMnB","x_google_ignoreList":[0,1]}
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("vue"),r=e.defineComponent({props:{label:{type:String,required:!1},value:{type:String,required:!1},color:{type:String,required:!1}},render(){return this.label?e.createVNode("span",{class:"core-text"},[this.label,e.createTextVNode(" : "),e.createVNode("span",{style:{color:this.color}},[this.value])]):e.createVNode("span",{class:"core-text"},[e.createVNode("span",{style:{color:this.color}},[this.value])])}});exports.CoreText=r;
2
+ //# sourceMappingURL=coreText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coreText.js","sources":["../src/components/core-text/index.tsx"],"sourcesContent":["import { computed, defineComponent, ref, watch } from 'vue';\n\nexport default defineComponent({\n props: {\n label: {\n type: String,\n required: false\n },\n value: {\n type: String,\n required: false\n },\n color: {\n type: String,\n required: false\n }\n },\n render() {\n return (\n this.label ? (\n <span class=\"core-text\">\n {this.label} : <span style={{color: this.color}}>{this.value}</span>\n </span>\n ) : (\n <span class=\"core-text\">\n <span style={{color: this.color}}>{this.value}</span>\n </span>\n )\n );\n }\n});\n"],"names":["CoreText","props","label","type","String","required","value","color","render","this","_createVNode","class","_createTextVNode","style"],"mappings":"oCAEAA,oBAA+B,CAC7BC,MAAO,CACLC,MAAO,CACLC,KAAMC,OACNC,UAAU,GAEZC,MAAO,CACLH,KAAMC,OACNC,UAAU,GAEZE,MAAO,CACLJ,KAAMC,OACNC,UAAU,IAGdG,MAAAA,GACE,OACEC,KAAKP,MAAKQ,EAAAA,YAAA,OAAA,CAAAC,MAAA,aAAA,CAELF,KAAKP,MAAKU,EAAAA,uBAAAF,EAAAA,YAAA,OAAA,CAAAG,MAAiB,CAACN,MAAOE,KAAKF,QAAM,CAAGE,KAAKH,UAAKI,EAAAA,YAAA,OAAA,CAAAC,MAAA,aAAA,CAAAD,EAAAA,YAAA,OAAA,CAAAG,MAI/C,CAACN,MAAOE,KAAKF,QAAM,CAAGE,KAAKH,SAIhD"}
@@ -0,0 +1,4 @@
1
+ "use strict";const t=require("vue"),e=require("vue-element-plus-x"),i=require("element-plus");require("element-plus/es/components/icon/style/index"),require("element-plus/es/components/upload/style/index"),require("element-plus/es/components/notification/style/index");var n=Object.defineProperty,a=(t,e,i)=>((t,e,i)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i);function s(t,e=!1,i="block"){t&&(t.className=t.className.replace(/ chat-view-show| chat-view-hidden/g,""),e?(t.style.display=i,t.className+=" chat-view-show"):(t.className+=" chat-view-hidden",t.style.display="none"))}function l(t){return t&&t.classList.contains("chat-view-show")}function o(t,e,i){t.classList[i?"add":"remove"](e)}const r="richWrap",c="richGrid",h="richMark",d="richInput",p="richTag",g="application/chatarea-custom-format",u="data-set-component",m='<div class="ant-spin ant-spin-spinning" aria-live="polite" aria-busy="true"><span class="ant-spin-dot ant-spin-dot-spin"><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i><i class="ant-spin-dot-item"></i></span></div>',E='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24"><path fill="currentColor" d="m20.23 8.653-7.795 9.685a1.2 1.2 0 0 1-1.87 0L2.771 8.652C2.14 7.867 2.698 6.7 3.706 6.7h15.588c1.008 0 1.567 1.167.935 1.952"></path></svg>',f=(t=50)=>new Promise(e=>{setTimeout(e,t)}),v=t=>"false"!==String(t)&&"null"!==String(t)&&"0"!==String(t),x=(t,e,i=!1)=>{let n;return function(...a){const s=this,l=i&&!n;clearTimeout(n),n=setTimeout(()=>{n=null,i||t.apply(s,a)},e),l&&t.apply(s,a)}},y=(t,e)=>{let i;return function(...n){i||(t.apply(this,n),i=!0,setTimeout(function(){i=!1},e))}},T=(t,e)=>{if(!t||!t.getAttribute)return null;const i=t.getAttribute("data-set-richType");return i===c?null:i===h||i===p?t:t.parentElement&&e>0?T(t.parentElement,e-1):null},C=(t,e,i)=>t&&t[e]?t[e]:i;function b(t,e){let i=t;for(const[n,a]of Object.entries(e)){const t=`{{${n}}}`;i=i.replace(new RegExp(t,"g"),String(a))}return i}function I(t){let e=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");return e=e.replace(/[&<>"']/g,t=>{switch(t){case"&":return"&amp;";case"<":return"&lt;";case">":return"&gt;";case'"':return"&quot;";case"'":return"&#039;";default:return t}}),e=e.replace(/ /g,"&nbsp;"),e}function D(t){let e=t.replace(/&nbsp;/g," ");return e=e.replace(/&amp;|&lt;|&gt;|&quot;|&#039;/g,t=>{switch(t){case"&amp;":return"&";case"&lt;":return"<";case"&gt;":return">";case"&quot;":return'"';case"&#039;":return"'";default:return t}}),e}function k(t){return function(t){const e=[];let i=[],n=0;const a=t.split(/(<\/?p[^>]*>)/gi);for(const s of a)s&&(s.startsWith("<p")&&!s.startsWith("</p")?(n++,i.push(s),1===n&&i.length>1&&(i=[s])):s.startsWith("</p")?(i.push(s),n--,0===n&&(e.push(i.join("").trim()),i=[])):n>0&&i.push(s));return e}(t).map(t=>function(t){const e=[];let i=[],n=0;const a=t.replace(/^<p[^>]*>/,"").replace(/<\/p>\s*$/,"").split(/(<\/?[^>]+\/?>)/g);for(const s of a){const t=s.trim();t&&(t.startsWith("<")&&t.endsWith("/>")?0===n?e.push(s):i.push(s):!t.startsWith("<")||t.startsWith("</")||t.startsWith("<!")?t.startsWith("</")?(n--,i.push(s),0===n&&(e.push(i.join("").trim()),i=[])):n>0&&i.push(s):(n++,i.push(s)))}if(i.length>0){const t=i.join("").trim();t&&e.push(t)}return e}(t)).map(t=>t.map(t=>{let e="",i="",n="",a="",s="",l="";switch(N(t)){case"chat-grid-input":n=A(t,"span",1),a=function(t,e){const i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`${i}=("([^"]*)"|'([^']*)'|([^\\s>]+))`),a=t.match(n);return a&&(a[2]||a[3]||a[4])||null}(n,"data-set-empty"),i=A(n,"span",1),e="false"===String(a)?L(t,i):t;break;case"chat-tag":switch(s=A(t,"span",1),l=N(s),l){case"at-user":case"at-tag":i=A(s,"span",1),e=L(t,i);break;case"at-select":i=A(s.replace(E,""),"span",1),e=L(t,i+E,I(i)+E);break;case"at-input":e=function(t){let e=t.replace(/(<span class="input-write" contenteditable="true">)(.*?)(<\/span>)/,(t,e,i,n)=>`${e}${I(i)}${n}`);return e=e.replace(/(<span class="[^"]*input-tip[^"]*"[^>]*>)(.*?)(<\/span>)/,(t,e,i,n)=>`${e}${I(i)}${n}`),e}(t);break;default:e=t}}return e})).map(t=>t.join("")).map(t=>'<p class="chat-grid-wrap" data-set-richtype="richGrid">'+t+"</p>").join("")}function N(t){const e=t.match(/<span[^>]*?class="([^"]*)"/i);return e?e[1]:null}function A(t,e,i=1){const n=t.indexOf(">")+1,a=t.lastIndexOf(`</${e}`),s=t.substring(n,a);return i<=1?s:A(s,e,i-1)}function L(t,e,i){return t.replace(e,i||I(e))}function w(t,e){switch(e){case"text-delete":return"Backspace"===t.key||"Backspace"===t.code;case"text-move":return"ArrowLeft"===t.key||"ArrowRight"===t.key||"ArrowLeft"===t.code||"ArrowRight"===t.code;case"text-select-all":return(t.ctrlKey||t.metaKey)&&("A"===t.key||"a"===t.key||"KeyA"===t.code);case"text-undo":return(t.ctrlKey||t.metaKey)&&("Z"===t.key||"z"===t.key||"KeyZ"===t.code);case"text-redo":return(t.ctrlKey||t.metaKey)&&("Y"===t.key||"y"===t.key||"KeyY"===t.code);case"text-write":return t.isComposing||!t.ctrlKey&&!t.altKey&&!t.metaKey&&!["Backspace","Shift","Tab","CapsLock","Control","Meta","Alt","ContextMenu","Enter","NumpadEnter","Escape","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","Home","End","PageUp","PageDown","Insert","Delete","NumLock"].includes(t.key);case"dialog-options":return"ArrowUp"===t.key||"ArrowDown"===t.key||"Enter"===t.key||"ArrowUp"===t.code||"ArrowDown"===t.code||"Enter"===t.code||"NumpadEnter"===t.code;case"IME":return"Unidentified"===t.key||229===t.keyCode;default:return!1}}function S(t,e,i){const n=e.split(/\s+/),a=t.split("").map((t,i)=>{let a=n[i]||"";return""===e&&""===a&&(a=t),{char:t,pinyin:a.toLowerCase(),initial:a?a[0].toLowerCase():""}}),s=(t=>{const e=[];let i="";for(const n of t)/[a-zA-Z]/.test(n)?i+=n.toLowerCase():(i&&(e.push({type:"pinyin",value:i}),i=""),e.push({type:"char",value:n}));return i&&e.push({type:"pinyin",value:i}),e})(i),l=a.length,o=s.length,r=Array.from({length:l+1},()=>Array(o+1).fill(!1));r[0][0]=!0;for(let c=0;c<=l;c++)for(let t=0;t<=o;t++)if(r[c][t]&&t<o){const e=s[t];for(let i=c;i<l;i++){const n=a[i];if("char"===e.type)n.char===e.value&&(r[i+1][t+1]=!0);else{const s=n.pinyin.toLowerCase(),o=n.initial,c=e.value;if(c===o)r[i+1][t+1]=!0;else if(c===s)r[i+1][t+1]=!0;else if(P(c,s))r[i+1][t+1]=!0;else for(let e=2;e<=l-i;e++){const n=a.slice(i,i+e),s=n.map(t=>t.pinyin.toLowerCase()).join(""),l=n.map(t=>t.initial).join("");if(c===s||c===l||P(c,s)){r[i+e][t+1]=!0;break}}}}}for(let c=0;c<=l;c++)if(r[c][o])return!0;return!1}function P(t,e){let i=0,n=0;for(;i<t.length&&n<e.length;)t[i]===e[n]&&i++,n++;return i===t.length}class O{constructor(t){a(this,"target"),a(this,"richText",document.createElement("div")),a(this,"placeholderElm",document.createElement("div")),a(this,"tipElm",null),a(this,"isExternalCallPopup",!1),a(this,"isPointSearchMode",!1),a(this,"checkboxRows",[]),a(this,"customTags",{}),a(this,"selectTags",{}),a(this,"rects",{}),a(this,"pcElms",{containerDialogElm:null,pointDialogElm:null,pointDialogCheckElm:null,pointDialogMainElm:null,pointDialogUsersElm:[],pointDialogActiveElm:null,pointDialogLoadingElm:null,pointDialogEmptyElm:null,checkDialogElm:null,checkDialogSearchResultElm:null,checkDialogUsersElm:null,checkDialogSearchInputElm:null,checkDialogTagsElm:null,customTagDialogElms:{},customTagDialogTagKey:"",customTagDialogActiveElm:null,selectDialogElms:{},selectDialogKey:"",selectDialogAim:null,tipContainerPopoverElm:null,tipPopoverElm:null}),a(this,"h5Elms",{dialogElm:null,dialogMainElm:null,dialogCheckElm:null,dialogShowElm:null,dialogSearchElm:null,dialogEmptyElm:null,dialogLoadingElm:null}),this.target=t,this.createRichText(),this.createPlaceholder(),t.deviceInfo.isPc?this.createPCDialog():this.createH5Dialog()}createRichText(){const{options:t,deviceInfo:e}=this.target,{elm:i}=t;o(i,"chat-area-"+(e.isPc?"pc":"h5"),!0),o(this.richText,"chat-rich-text",!0),this.richText.setAttribute("data-set-richType",r),this.richText.setAttribute("contenteditable","true"),i.appendChild(this.richText)}createPlaceholder(){const{options:t}=this.target,{elm:e}=t;o(this.placeholderElm,"chat-placeholder-wrap",!0),s(this.placeholderElm,!0),e.appendChild(this.placeholderElm),this.rects.plaRect=this.placeholderElm.getBoundingClientRect()}createPCDialog(){const{options:t}=this.target,{needDialog:e,elm:i,asyncMatch:n}=t;if(!e)return;const{pcElms:a}=this;a.containerDialogElm=document.createElement("div"),o(this.pcElms.containerDialogElm,"chat-dialog",!0),i.nextElementSibling?i.parentElement.insertBefore(a.containerDialogElm,i.nextElementSibling):i.parentElement.appendChild(a.containerDialogElm),n||this.createPCCheckDialog(),this.createPCPointDialog()}createPCCheckDialog(){const{options:t}=this.target,e=this.target.options.dialogLabels.pcPCheckDialog,{pcElms:i}=this;i.checkDialogElm=document.createElement("div"),o(i.checkDialogElm,"checkbox-dialog",!0),s(i.checkDialogElm),i.checkDialogElm.innerHTML=`\n <div class="checkbox-dialog-container">\n <div class="checkbox-dialog-container-header">\n <span>${e.title}</span>\n <span class="checkbox-dialog-container-header-close">⛌</span>\n </div>\n <div class="checkbox-dialog-container-body">\n <div class="checkbox-dialog-left-box">\n <div class="checkbox-dialog-search">\n <input class="checkbox-dialog-search-input" placeholder="${e.searchPlaceholder}" type="text">\n <div class="checkbox-dialog-search-group"></div>\n </div>\n <div class="checkbox-dialog-tags"></div>\n <div class="checkbox-dialog-option">\n <button class="checkbox-dialog-option-btn btn-submit disabled">${e.confirmLabel}</button>\n <button class="checkbox-dialog-option-btn btn-close">${e.cancelLabel}</button>\n </div>\n </div>\n <div class="checkbox-dialog-right-box">\n <div class="checkbox-dialog-right-box-title">${e.userTagTitle}</div>\n <div class="checkbox-dialog-check-group"></div>\n </div>\n </div>\n </div>\n `,i.containerDialogElm.appendChild(i.checkDialogElm),i.checkDialogUsersElm=i.checkDialogElm.querySelector(".checkbox-dialog-check-group"),i.checkDialogSearchResultElm=i.checkDialogElm.querySelector(".checkbox-dialog-search-group"),i.checkDialogSearchInputElm=i.checkDialogElm.querySelector(".checkbox-dialog-search-input"),i.checkDialogTagsElm=i.checkDialogElm.querySelector(".checkbox-dialog-tags");const n=()=>{s(i.checkDialogElm),o(document.body,"disable-scroll")};i.checkDialogElm.querySelector(".checkbox-dialog-container-header-close").onclick=n,i.checkDialogElm.querySelector(".btn-close").onclick=n;const a=i.checkDialogElm.querySelector(".btn-submit");a.onclick=async()=>{if(a.classList.contains("disabled"))return;const e=this.checkboxRows.map(e=>{const i=Object.create(null);return i[t.userProps.id]=e.id,i[t.userProps.name]=e.name,i});await this.target.batchSetTag(e),n()},s(i.checkDialogSearchResultElm),i.checkDialogSearchResultElm.onclick=t=>{t.stopPropagation()},i.checkDialogSearchInputElm.onclick=t=>{t.stopPropagation()};const l=x(t=>{const e=String(t.target.value||"").replace(/'/g,"").trim();if(!e)return void s(i.checkDialogSearchResultElm);const n=this.target.searchUserList(e).map(t=>t.id);Array.from(i.checkDialogSearchResultElm.children,(t,e)=>{if(e===i.checkDialogSearchResultElm.children.length-1)s(t,0===n.length);else{const e=t.getAttribute("data-set-id");s(t,-1!==n.indexOf(e),"flex")}}),s(i.checkDialogSearchResultElm,!0)},200);i.checkDialogSearchInputElm.oninput=l,i.checkDialogSearchInputElm.onfocus=l}createPCPointDialog(){const{pcElms:t,target:e}=this;t.pointDialogElm=document.createElement("div"),o(t.pointDialogElm,"call-user-dialog",!0),s(t.pointDialogElm);const i=document.createElement("div");o(i,"call-user-dialog-header",!0),i.innerHTML=`<span class="call-user-dialog-header-title">${e.options.dialogLabels.pcPointDialog.title}</span>`,t.pointDialogCheckElm=document.createElement("span"),o(t.pointDialogCheckElm,"call-user-dialog-header-check",!0),t.pointDialogCheckElm.innerText=e.options.dialogLabels.pcPointDialog.checkLabel,t.pointDialogCheckElm.onclick=()=>{this.target.showPCCheckDialog(),this.isExternalCallPopup=!1},i.appendChild(t.pointDialogCheckElm),t.pointDialogElm.appendChild(i),t.pointDialogMainElm=document.createElement("div"),o(t.pointDialogMainElm,"call-user-dialog-main",!0),t.pointDialogElm.appendChild(t.pointDialogMainElm),e.options.asyncMatch&&(t.pointDialogLoadingElm=document.createElement("div"),o(t.pointDialogLoadingElm,"call-user-dialog-loading",!0),t.pointDialogLoadingElm.innerHTML=m,t.pointDialogElm.appendChild(t.pointDialogLoadingElm),s(t.pointDialogLoadingElm),t.pointDialogEmptyElm=document.createElement("div"),o(t.pointDialogEmptyElm,"call-user-dialog-empty",!0),t.pointDialogEmptyElm.innerHTML=`\n <svg class="match-empty-svg" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"></ellipse><g fill-rule="nonzero" stroke="#d9d9d9"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"></path></g></g></svg>\n <span class="empty-label">${e.options.dialogLabels.pcPointDialog.emptyLabel}</span>\n `,t.pointDialogElm.appendChild(t.pointDialogEmptyElm),s(t.pointDialogEmptyElm)),t.containerDialogElm.appendChild(t.pointDialogElm)}createH5Dialog(){const{options:t,chatEvent:e}=this.target,{needDialog:i,dialogLabels:n}=t;if(!i)return;const{h5Elms:a}=this;a.dialogElm=document.createElement("div"),o(a.dialogElm,"call-user-popup",!0),a.dialogElm.innerHTML=`\n <div class="call-user-popup-main">\n <div class="call-user-popup-header">\n <span class="popup-show">${n.h5Dialog.cancelLabel}</span>\n <span class="popup-title">${n.h5Dialog.title}</span>\n <span class="popup-check">${n.h5Dialog.confirmLabel}</span>\n </div>\n <div class="call-user-popup-search">\n <svg class="icon-search" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M684.8 223.530667a326.272 326.272 0 0 1 24.96 433.621333c2.645333 2.133333 5.290667 4.48 7.850667 7.04L870.4 817.066667c24.789333 24.746667 32.896 56.832 18.133333 71.594666-14.762667 14.805333-46.848 6.656-71.637333-18.090666l-152.789333-152.832a106.282667 106.282667 0 0 1-7.210667-7.936 326.101333 326.101333 0 0 1-433.109333-25.173334c-127.445333-127.445333-127.573333-333.952-0.256-461.269333 127.36-127.36 333.866667-127.232 461.269333 0.213333zM275.328 275.114667a252.885333 252.885333 0 0 0 0.256 357.632 252.885333 252.885333 0 0 0 357.632 0.256 252.885333 252.885333 0 0 0-0.256-357.632 252.885333 252.885333 0 0 0-357.632-0.256z" fill="#9B9B9B"></path></svg>\n <input class="call-user-popup-search-input"\n placeholder="${n.h5Dialog.searchPlaceholder}"\n type="text">\n </div>\n <div class="call-user-popup-body"></div>\n </div>\n `;const l=async()=>{a.dialogElm.className=a.dialogElm.className.replace(/ chat-view-show/g," chat-view-hidden"),a.dialogSearchElm.value="",await f(260),s(a.dialogElm),o(document.body,"disable-scroll"),t.asyncMatch&&this.target.updateUserList([]),this.target.chatInput.restCursorPos(this.target.chatInput.vnode,this.target.chatInput.cursorIndex),this.target.chatInput.viewIntoPoint()};a.dialogElm.onclick=l;const r=a.dialogElm.querySelector(".call-user-popup-main");r.onclick=t=>{t.stopPropagation()},a.dialogShowElm=a.dialogElm.querySelector(".popup-show"),a.dialogShowElm.onclick=l,a.dialogCheckElm=a.dialogElm.querySelector(".popup-check"),a.dialogCheckElm.onclick=async()=>{if(a.dialogCheckElm.classList.contains("disabled"))return;const e=a.dialogElm.querySelectorAll(".user-popup-check-item-check")||[];if(0===e.length)return void(await l());if(Array.prototype.some.call(e,t=>"isALL"===t.getAttribute("data-set-id")))return await this.target.onceSetTag({[t.userProps.id]:"isALL",[t.userProps.name]:t.dialogLabels.h5Dialog.callEveryLabel}),void(await l());const i=Array.from(e,t=>t.getAttribute("data-set-id")),n=t.userList.filter(e=>-1!==i.indexOf(String(e[t.userProps.id])));await this.target.batchSetTag(n),await l()},a.dialogMainElm=a.dialogElm.querySelector(".call-user-popup-body"),a.dialogEmptyElm=document.createElement("div"),o(a.dialogEmptyElm,"call-user-popup-empty",!0),this.h5Elms.dialogEmptyElm.innerHTML=`\n <svg class="empty-svg" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"></ellipse><g fill-rule="nonzero" stroke="#d9d9d9"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"></path></g></g></svg>\n <span class="empty-label">${t.dialogLabels.h5Dialog.searchEmptyLabel}</span>\n `,s(a.dialogEmptyElm),r.appendChild(a.dialogEmptyElm),t.asyncMatch&&(a.dialogLoadingElm=document.createElement("div"),o(a.dialogLoadingElm,"call-user-popup-loading",!0),a.dialogLoadingElm.innerHTML=m,s(a.dialogLoadingElm),r.appendChild(a.dialogLoadingElm)),a.dialogSearchElm=a.dialogElm.querySelector(".call-user-popup-search-input"),a.dialogSearchElm.oninput=x(i=>{const n=String(i.target.value||"").replace(/'/g,"").trim();if(t.asyncMatch){e.matchKey++;const t=e.matchKey;this.target.updateUserList([]),s(a.dialogLoadingElm,!0),s(a.dialogEmptyElm);const i=e.triggerChatEvent("atMatch",n).find(t=>t&&t instanceof Promise);return void(i&&i.then(i=>{t===e.matchKey&&(s(a.dialogLoadingElm),!i||i.length<=0?s(a.dialogEmptyElm,!0,"flex"):this.target.updateUserList(i))}))}const l=[];Array.from(this.h5Elms.dialogMainElm.children,t=>{if(!n)return s(t,!0,"flex"),void l.push(t);S(t.getAttribute("data-set-name")||"",t.getAttribute("data-set-pinyin")||"",n)?(s(t,!0,"flex"),l.push(t)):s(t)}),s(this.h5Elms.dialogEmptyElm,!l.length,"flex")},200),s(a.dialogElm),document.body.appendChild(a.dialogElm)}updatePCUser(){const{pcElms:t,target:e}=this;t.pointDialogMainElm.innerHTML="",t.pointDialogActiveElm=void 0;const i=document.createDocumentFragment();if(this.target.options.needCallEvery){const t=document.createElement("div");o(t,"call-user-dialog-item",!0),t.setAttribute("data-set-id","isALL"),this.userSelectStyleAndEvent(t,{id:"isALL",name:e.options.dialogLabels.pcPointDialog.callEveryLabel}),t.innerHTML=`\n <span class="call-user-dialog-item-sculpture">\n <span style="transform: scale(0.75)">@</span>\n </span>\n <span class="call-user-dialog-item-name">${e.options.dialogLabels.pcPointDialog.callEveryLabel}(${e.options.reformList.length})</span>\n `,i.appendChild(t)}if(e.options.reformList.forEach(t=>{const e=document.createElement("div");o(e,"call-user-dialog-item",!0),e.setAttribute("data-set-id",t.id),this.userSelectStyleAndEvent(e,t),this.getUserHtmlTemplate(e,t),i.appendChild(e)}),t.pointDialogMainElm.appendChild(i),t.pointDialogUsersElm=[],Array.from(t.pointDialogMainElm.children||[],(e,i)=>{t.pointDialogUsersElm.push({index:i,elm:e})}),e.options.asyncMatch)return;t.checkDialogUsersElm.innerHTML=`\n <div class="checkbox-dialog-check-item" data-set-value="ALL">\n <input type="checkbox" value>\n <span class="checkbox-dialog-check-item-inner"></span>\n <div class="checkbox-dialog-check-item-label">${e.options.dialogLabels.pcPCheckDialog.checkAllLabel}</div>\n </div>\n `;const n=document.createDocumentFragment();e.options.reformList.forEach(t=>{const e=document.createElement("div");o(e,"checkbox-dialog-check-item",!0),e.setAttribute("data-set-value",t.id),e.innerHTML='\n <input type="checkbox" value>\n <span class="checkbox-dialog-check-item-inner"></span>\n ',this.getUserHtmlTemplate(e,t),n.appendChild(e)}),t.checkDialogUsersElm.appendChild(n),t.checkDialogUsersElm&&t.checkDialogUsersElm.children.length&&Array.from(t.checkDialogUsersElm.children,t=>{t.onclick=()=>{const i=t.getAttribute("data-set-value")||"",n=e.options.reformList.find(t=>t.id===i),a=-1===t.className.indexOf("checkbox-dialog-check-item-check");"ALL"===i?this.checkboxRows=a?e.options.reformList.map(t=>t):[]:a?this.checkboxRows.push(n):this.checkboxRows=this.checkboxRows.filter(t=>t.id!==i),this.updateCheckDialogTags()}}),t.checkDialogSearchResultElm.innerHTML="";const a=document.createDocumentFragment();e.options.reformList.forEach(t=>{const i=document.createElement("div");o(i,"checkbox-dialog-check-item",!0),i.setAttribute("data-set-id",t.id);const n=document.createElement("div");o(n,"checkbox-dialog-check-item-label",!0),this.getUserHtmlTemplate(n,t),i.appendChild(n),i.onclick=()=>{s(this.pcElms.checkDialogSearchResultElm);const t=i.getAttribute("data-set-id")||"";if(this.pcElms.checkDialogSearchInputElm.value="",this.pcElms.checkDialogSearchInputElm.focus(),this.checkboxRows.some(e=>e.id===t))return;const n=e.options.reformList.find(e=>e.id===t);n&&this.checkboxRows.push(n),this.updateCheckDialogTags()},a.appendChild(i)});const l=document.createElement("div");o(l,"checkbox-dialog-search-empty",!0),l.innerText=e.options.dialogLabels.pcPCheckDialog.searchEmptyLabel,a.appendChild(l),t.checkDialogSearchResultElm.appendChild(a)}updateH5User(){const{h5Elms:t,target:e}=this;t.dialogMainElm.innerHTML="";const i=e.options.reformList&&e.options.reformList.length>0,n=document.createDocumentFragment(),a=document.createElement("span");if(a.innerHTML='\n <input type="checkbox" value>\n <span class="user-popup-check-item-inner"></span>\n ',i){const t=document.createElement("div");e.options.needCallEvery&&(o(t,"call-user-popup-item",!0),t.setAttribute("data-set-id","isALL"),t.innerHTML=`\n <span class="call-user-dialog-item-sculpture">\n <span style="transform: scale(0.75)">@</span>\n </span>\n <span class="call-user-dialog-item-name">${e.options.dialogLabels.h5Dialog.callEveryLabel}(${e.options.reformList.length})</span>\n `,t.appendChild(a.cloneNode(!0)),t.onclick=()=>{const e=!t.classList.contains("user-popup-check-item-check");Array.from(this.h5Elms.dialogMainElm.children,t=>{o(t,"user-popup-check-item-check",e)}),o(this.h5Elms.dialogCheckElm,"disabled",!e)},n.appendChild(t)),e.options.reformList.forEach((e,i)=>{const s=document.createElement("div");o(s,"call-user-popup-item",!0),s.setAttribute("data-set-id",e.id),s.setAttribute("data-set-name",e.name),s.setAttribute("data-set-pinyin",e.pinyin||""),this.getUserHtmlTemplate(s,e),s.appendChild(a.cloneNode(!0)),n.appendChild(s),s.onclick=e=>{const i=!s.classList.contains("user-popup-check-item-check");o(s,"user-popup-check-item-check",i);const n=Array.prototype.every.call(this.h5Elms.dialogMainElm.children,t=>t.classList.contains("user-popup-check-item-check")||"isALL"===t.getAttribute("data-set-id"));o(t,"user-popup-check-item-check",n);const a=Array.prototype.some.call(this.h5Elms.dialogMainElm.children,t=>t.classList.contains("user-popup-check-item-check"));o(this.h5Elms.dialogCheckElm,"disabled",!a)}})}t.dialogMainElm.appendChild(n)}updateCheckDialogTags(){const t=this.checkboxRows.map(t=>t.id),e=[],i=[],n=document.createElement("div");n.className="check-empty",n.innerHTML=`\n <svg class="check-empty-svg" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg"><g transform="translate(0 1)" fill="none" fill-rule="evenodd"><ellipse fill="#f5f5f5" cx="32" cy="33" rx="32" ry="7"></ellipse><g fill-rule="nonzero" stroke="#d9d9d9"><path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path><path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="#fafafa"></path></g></g></svg>\n <span class="check-empty-label">${this.target.options.dialogLabels.pcPCheckDialog.checkEmptyLabel}</span>\n `,Array.from(this.pcElms.checkDialogTagsElm.children,n=>{const a=n.getAttribute("data-set-value");-1===t.indexOf(a)?i.push(n):e.push(a)}),Array.from(this.pcElms.checkDialogUsersElm.children,(e,i)=>{if(0===i)return void o(e,"checkbox-dialog-check-item-check",t.length===this.target.options.reformList.length);const n=e.getAttribute("data-set-value");o(e,"checkbox-dialog-check-item-check",-1!==t.indexOf(n))}),i.forEach(t=>{this.pcElms.checkDialogTagsElm.removeChild(t)}),o(this.pcElms.checkDialogElm.querySelector(".btn-submit"),"disabled",t.length<=0),t.length||this.pcElms.checkDialogTagsElm.appendChild(n);const a=this.checkboxRows.filter(t=>-1===e.indexOf(t.id));if(!a.length)return;const s=document.createDocumentFragment();a.forEach(t=>{const e=document.createElement("div");e.setAttribute("class","checkbox-dialog-tag-item"),e.setAttribute("data-set-value",t.id),e.innerHTML=`\n <span>${t.name}</span>\n `;const i=document.createElement("span");i.setAttribute("class","checkbox-dialog-tag-item-close"),i.innerHTML="⛌",i.onclick=()=>{const t=e.getAttribute("data-set-value");this.checkboxRows=this.checkboxRows.filter(e=>e.id!==t),this.updateCheckDialogTags()},e.appendChild(i),s.appendChild(e)}),this.pcElms.checkDialogTagsElm.appendChild(s)}userSelectStyleAndEvent(t,e){t.addEventListener("click",async i=>{const{options:n}=this.target;if(i.stopPropagation(),this.updatePointActiveUserElm(t),this.isPointSearchMode||n.asyncMatch)await this.target.matchSetTag(e);else{const t=n.userList.find(t=>String(t[n.userProps.id])===e.id);await this.target.onceSetTag(t)}this.exitPointDialog()})}bindCustomTrigger(){Object.values(this.pcElms.customTagDialogElms).forEach(t=>{this.pcElms.containerDialogElm.removeChild(t)}),this.pcElms.customTagDialogElms={},this.customTags={},this.target.options.customTrigger.forEach(t=>{t.tagList&&t.tagList.length>0&&(this.customTags[t.prefix]=t.tagList.map(t=>({id:String(t.id),name:String(t.name),pinyin:String(t.pinyin||"")})),this.createCustomTagDialog(t))})}createCustomTagDialog(t){const e=document.createElement("div");e.setAttribute("class","call-tag-dialog"),s(e);const i=document.createElement("div");i.setAttribute("class","call-tag-dialog-header"),i.innerHTML=`<span class="call-tag-dialog-header-title">${t.dialogTitle||t.prefix}</span>`,e.appendChild(i);const n=document.createElement("div");n.setAttribute("class","call-tag-dialog-main"),t.tagList.forEach(t=>{const e=document.createElement("div");e.setAttribute("class","call-tag-dialog-item"),e.setAttribute("data-set-id",t.id);const i=document.createElement("span");i.setAttribute("class","call-tag-dialog-item-name"),i.innerHTML=t.name,e.appendChild(i),e.addEventListener("click",async i=>{i.stopPropagation(),this.updateActiveCustomTagElm(e),this.isPointSearchMode?await this.target.matchSetCustomTag(t):await this.target.onceSetCustomTag(t),this.exitCustomTagDialog()}),n.appendChild(e)}),e.appendChild(n),this.pcElms.containerDialogElm.appendChild(e),this.pcElms.customTagDialogElms[t.prefix]=e}getUserHtmlTemplate(t,e){const i=document.createElement("span");if(i.setAttribute("class","call-user-dialog-item-sculpture "+(e.avatar?"is-avatar":"")),e.avatar){const t=new Image;t.alt="",t.src=String(e.avatar),i.appendChild(t)}else i.innerHTML=`<span style="transform: scale(0.75)">${e.name.slice(-2)}</span>`;t.appendChild(i);const n=document.createElement("span");n.setAttribute("class","call-user-dialog-item-name"),n.innerHTML=e.name,t.appendChild(n)}updatePointActiveUserElm(t,e=!1){if(this.pcElms.pointDialogActiveElm&&o(this.pcElms.pointDialogActiveElm,"call-user-dialog-item-active"),this.pcElms.pointDialogActiveElm=t,t&&(o(t,"call-user-dialog-item-active",!0),e)){const e=Array.prototype.filter.call(this.pcElms.pointDialogMainElm.children,t=>-1===t.className.indexOf("user-no-match")),i=t.clientHeight,n=Array.prototype.indexOf.call(e,t)+1-Math.ceil(Math.floor(this.pcElms.pointDialogMainElm.clientHeight/i)/2);this.pcElms.pointDialogMainElm.scrollTop=n>0?n*i:0}}updateActiveCustomTagElm(t,e=!1){if(this.pcElms.customTagDialogActiveElm&&o(this.pcElms.customTagDialogActiveElm,"call-tag-dialog-item-active"),this.pcElms.customTagDialogActiveElm=t,t&&(o(t,"call-tag-dialog-item-active",!0),e)){const e=this.pcElms.customTagDialogElms[this.pcElms.customTagDialogTagKey].children[1],i=Array.prototype.filter.call(e.children,t=>-1===t.className.indexOf("tag-no-match")),n=t.clientHeight,a=Array.prototype.indexOf.call(i,t)+1-Math.ceil(Math.floor(e.clientHeight/n)/2);e.scrollTop=a>0?a*n:0}}showPointDialog(t){this.exitSelectDialog(),this.exitCustomTagDialog(),this.exitPointDialog(),this.isPointSearchMode=!!t;let e=null;this.pcElms.pointDialogUsersElm.forEach(i=>{const n=i.elm,a=n.getAttribute("data-set-id"),s=t&&t.every(t=>t.id!==a);e||s||(e=n),o(n,"user-no-match",s)}),null!==e&&this.updatePointActiveUserElm(e),s(this.pcElms.pointDialogCheckElm,!this.target.options.asyncMatch&&!this.isPointSearchMode),s(this.pcElms.pointDialogElm,!0),this.target.chatEvent.debounceEvents.dialogMoveToRange(this.pcElms.pointDialogElm),this.pcElms.pointDialogMainElm.scrollTop=0}showCustomTagDialog(t,e){this.exitSelectDialog(),this.exitCustomTagDialog(),this.exitPointDialog(),this.isPointSearchMode=!!e,this.pcElms.customTagDialogTagKey=t;const i=this.pcElms.customTagDialogElms[t],n=i.children[1];let a=null;Array.from(n.children,t=>{const i=t.getAttribute("data-set-id"),n=e&&e.every(t=>t.id!==i);a||n||(a=t),o(t,"tag-no-match",n)}),null!==a&&this.updateActiveCustomTagElm(a),s(i,!0),this.target.chatEvent.debounceEvents.dialogMoveToRange(i),i.children[1].scrollTop=0}exitPointDialog(){this.updatePointActiveUserElm(),this.target.options.asyncMatch&&this.target.updateUserList([]),s(this.pcElms.pointDialogElm)}exitCustomTagDialog(){this.updateActiveCustomTagElm();for(const t in this.pcElms.customTagDialogElms)s(this.pcElms.customTagDialogElms[t])}ruleShowPointDialog(){const{options:t}=this.target;t.needDialog&&t.reformList.length>0&&(this.isExternalCallPopup=!1,this.showPointDialog())}showPlaceholder(){s(this.placeholderElm,this.target.isEmpty()),this.offsetTipElm()}bindSelectList(){Object.values(this.pcElms.selectDialogElms).forEach(t=>{this.pcElms.containerDialogElm.removeChild(t)}),this.pcElms.selectDialogElms={},this.selectTags={},this.target.options.selectList.forEach(t=>{t.options&&t.options.length>0&&(this.selectTags[t.key]=t.options.map(t=>({id:String(t.id),name:String(t.name),preview:String(t.preview||"")})),this.createSelectDialog(t))})}createSelectDialog(t){const e=document.createElement("div");e.setAttribute("class","chat-select-dialog"),s(e);const i=document.createElement("div");i.setAttribute("class","chat-select-dialog-header"),i.innerHTML=`<span class="chat-select-dialog-header-title">${t.dialogTitle||t.key}</span>`,e.appendChild(i);const n=document.createElement("div");n.setAttribute("class","chat-select-dialog-main"),t.options.forEach(t=>{const e=document.createElement("div");if(e.setAttribute("class","chat-select-dialog-item"),e.setAttribute("data-set-id",t.id),t.preview){const i=document.createElement("img");i.setAttribute("class","chat-select-dialog-preview"),i.src=String(t.preview),e.appendChild(i)}const i=document.createElement("span");i.setAttribute("class","chat-select-dialog-name"),i.textContent=t.name;const a=document.createElement("span");a.setAttribute("class","chat-select-dialog-check"),a.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24"><path fill="currentColor" d="M9.218 17.41 19.83 6.796a.99.99 0 1 1 1.389 1.415c-3.545 3.425-4.251 4.105-11.419 11.074a.997.997 0 0 1-1.375.018c-1.924-1.801-3.709-3.568-5.573-5.43a.999.999 0 0 1 1.414-1.413z"></path></svg>',s(a),i.appendChild(a),e.appendChild(i),e.onclick=async()=>{await this.target.setSelectTag(t)},n.appendChild(e)}),e.appendChild(n);const a=document.createElement("div");a.setAttribute("class","chat-select-arrow"),e.appendChild(a),this.pcElms.containerDialogElm.appendChild(e),this.pcElms.selectDialogElms[t.key]=e}exitSelectDialog(){for(const t in this.pcElms.selectDialogElms)s(this.pcElms.selectDialogElms[t]);this.pcElms.selectDialogKey="",this.pcElms.selectDialogAim&&(o(this.pcElms.selectDialogAim,"aim"),this.pcElms.selectDialogAim=null)}createTipElm(t){this.tipElm||(this.tipElm=document.createElement("div")),o(this.tipElm,"chat-tip-wrap",!0),this.tipElm.innerHTML=`\n <div class="chat-tip-tag">\n <span class="chat-tip-tag-txt">${t.tagLabel||"--"}</span>\n <span class="chat-tip-tag-close">\n ${this.target.deviceInfo.isPc?'<svg focusable="false" data-icon="close-circle" width="1em" height="1em" fill="currentColor" aria-hidden="true" fill-rule="evenodd" viewBox="64 64 896 896"><path d="M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z"></path></svg>':""}\n </span>\n </div>\n `,this.target.options.elm.appendChild(this.tipElm);const e=this.tipElm.children[0],i=(e.clientHeight-this.target.chatInput.NODE_HEIGHT)/2;if(this.tipElm.style.top=`-${i}px`,e.onclick=()=>{this.target.deviceInfo.isPc&&this.target.closeTipTag()},e.onmouseenter=()=>{if(this.pcElms.tipContainerPopoverElm&&this.pcElms.tipPopoverElm){s(this.pcElms.tipPopoverElm,!0);const t=this.pcElms.tipContainerPopoverElm.getBoundingClientRect();this.rects.tipRect=this.tipElm.getBoundingClientRect();const i=(this.pcElms.tipPopoverElm.clientWidth-(this.tipElm.clientWidth+(this.tipElm.clientWidth-e.clientWidth)))/2;this.pcElms.tipPopoverElm.style.left=-i+"px",this.pcElms.tipPopoverElm.style.bottom=t.y-this.rects.tipRect.y+"px",this.pcElms.tipPopoverElm.style.transform=e.style.transform}},e.onmouseleave=()=>{this.pcElms.tipPopoverElm&&s(this.pcElms.tipPopoverElm)},this.offsetApplyElm(),this.target.deviceInfo.isPc){this.pcElms.tipContainerPopoverElm||(this.pcElms.tipContainerPopoverElm=document.createElement("div"),o(this.pcElms.tipContainerPopoverElm,"chat-tip-dialog",!0)),this.pcElms.tipPopoverElm||(this.pcElms.tipPopoverElm=document.createElement("div")),o(this.pcElms.tipPopoverElm,"chat-tip-popover",!0),this.pcElms.tipPopoverElm.innerHTML=`\n <div class="chat-tip-popover-main">\n <span class="chat-tip-popover-txt">${t.popoverLabel||"--"}</span>\n <span class="chat-tip-popover-code ${t.codeLabel?"":"chat-view-show"}">${t.codeLabel||"--"}</span>\n </div>\n <div class="chat-tip-popover-arrow"></div>\n `,this.pcElms.tipContainerPopoverElm.appendChild(this.pcElms.tipPopoverElm),s(this.pcElms.tipPopoverElm);const{elm:e}=this.target.options;e.parentElement&&(e.nextElementSibling?e.parentElement.insertBefore(this.pcElms.tipContainerPopoverElm,e.nextElementSibling):e.parentElement.appendChild(this.pcElms.tipContainerPopoverElm))}this.target.chatEvent.triggerChatEvent("tipTagState",!0)}createCustomTipElm(t){this.tipElm||(this.tipElm=document.createElement("div")),o(this.tipElm,"chat-tip-wrap",!0),this.tipElm.innerHTML=`<div class="chat-custom-tip">${t}</div>`,this.target.options.elm.appendChild(this.tipElm);const e=this.tipElm.children[0],i=(e.clientHeight-this.target.chatInput.NODE_HEIGHT)/2;return this.tipElm.style.top=`-${i}px`,this.offsetApplyElm(),this.target.chatEvent.triggerChatEvent("tipTagState",!0),e.children[0]}offsetApplyElm(){if(!this.tipElm)return;const t=this.richText.children[0].children[0];this.rects.tipRect=this.tipElm.getBoundingClientRect();const e=this.rects.tipRect;this.placeholderElm.style.paddingLeft=e.width+"px",t.style.paddingLeft=e.width-t.offsetLeft+"px",this.offsetTipElm()}offsetTipElm(){if(this.tipElm){const t=this.richText.children[0].children[0];t.style.paddingLeft=this.rects.tipRect.width-t.offsetLeft+"px",this.target.nextTick(()=>{if(this.tipElm){const t=this.tipElm.children[0],e=this.richText.children[0].children[0];t.style.transform=`translateY(${e.offsetTop-this.target.chatInput.NODE_PADDING_DIFF}px)`}})}}removeTipElm(){this.tipElm&&(this.target.options.elm.removeChild(this.tipElm),this.tipElm=null),this.pcElms.tipContainerPopoverElm&&(this.pcElms.tipContainerPopoverElm.removeChild(this.pcElms.tipPopoverElm),this.target.options.elm.parentElement.removeChild(this.pcElms.tipContainerPopoverElm),this.pcElms.tipContainerPopoverElm=null,this.pcElms.tipPopoverElm=null);const t=this.richText.children[0].children[0];this.placeholderElm.style.removeProperty("padding-left"),t.style.removeProperty("padding-left"),this.target.chatInput.setRangeLastRecord(),this.target.chatEvent.triggerChatEvent("tipTagState",!1)}}class R{constructor(t){a(this,"target"),a(this,"richText"),a(this,"vnode"),a(this,"cursorIndex"),a(this,"inputTag_vnode"),a(this,"inputTag_cursorIndex"),a(this,"lastCursorType","gridInput"),a(this,"needCallSpace",!1),a(this,"VOID_KEY","\ufeff"),a(this,"ZERO_WIDTH_KEY","​"),a(this,"INPUT_TAG_WRAP_KEY","​\n​"),a(this,"NODE_HEIGHT",24),a(this,"NODE_PADDING_DIFF",10),this.target=t,this.richText=t.chatElement.richText,this.initEditor()}initEditor(t=!1,e){if(t||this.getNodeEmpty(this.richText)){this.richText.innerHTML="";const i=this.getGridElm();this.richText.appendChild(i);const n=i.children[0].children[0];e&&(n.textContent=e,n.setAttribute("data-set-empty","false"));const a=n.childNodes[0];t||this.target.options.autoFocus?this.restCursorPos(a,a.textContent===this.VOID_KEY?1:a.textContent.length):this.updateGridInputCursor(a,a.textContent.length),this.target.nextTick(()=>{const t=i.getBoundingClientRect();this.NODE_HEIGHT=t.height,this.NODE_PADDING_DIFF=t.top-this.target.options.elm.getBoundingClientRect().top})}}onceCall(t){return new Promise(e=>{const i=this.createChatTagElm(t,"@","at-user","user-id");this.replaceRegContent(i),e()})}onceSearchCall(t,e){return new Promise(i=>{const n=this.createChatTagElm(t,"@","at-user","user-id");this.replaceRegContent(n,e),i()})}onceCustomCall(t,e,i){return new Promise(n=>{const a=this.createChatTagElm(t,i,"at-tag","tag-id");a.children[0].setAttribute("data-set-prefix",i),this.replaceRegContent(a,e),n()})}getCurrentCursorKey(){return this.updateNodeCursor(),this.vnode&&this.vnode.nodeType===Node.TEXT_NODE?(this.vnode.textContent||"")[this.cursorIndex-1]:""}getRangeRect(){let t=0,e=0;const i=this.target.getSelection();if(i.focusNode.nodeType!==Node.TEXT_NODE)return null;const n=i.getRangeAt(0).getClientRects()[0];return n&&(t=n.x,e=n.y),{x:t,y:e}}createChatTagElm(t,e,i,n){const a=document.createElement("span");return a.className=i,a.setAttribute(`data-${n}`,String(t.id)),a.textContent=`${e}${t.name}${this.needCallSpace?" ":""}`,this.createNewDom(a)}createNewDom(t){const e=document.createElement("span");return e.className="chat-tag",e.setAttribute("contenteditable","false"),e.setAttribute("data-set-richType",p),e.appendChild(t),e}replaceRegContent(t,e=!0){const i=this.vnode.textContent;let n;n="boolean"==typeof e?i.slice(0,e?this.cursorIndex-1:this.cursorIndex):i.slice(0,e-1),0===n.length?(this.vnode.parentElement.setAttribute("data-set-empty","true"),this.vnode.textContent=this.VOID_KEY):this.vnode.textContent=n;let a=i.slice(this.cursorIndex);const s=this.vnode.parentNode.parentNode,l=s.nextSibling;l?s.parentNode.insertBefore(t,l):s.parentNode.appendChild(t);const o=t.previousSibling.childNodes[0],r=o.childNodes[1];r&&o.removeChild(r);const c=this.getGridElm(!0),h=c.childNodes[0];a&&a!==this.VOID_KEY&&(h.setAttribute("data-set-empty","false"),h.innerHTML=a);const d=h.childNodes[1];t.nextSibling?(d&&h.removeChild(d),s.parentNode.insertBefore(c,t.nextSibling)):s.parentNode.appendChild(c),this.restCursorPos(h.childNodes[0])}batchReplaceRegContent(t=[],e=!0){return new Promise(i=>{let n=`<span data-set-richType="${h}"><span class="chat-grid-input" data-set-richType="${d}" data-set-empty="true">${this.VOID_KEY}</span></span>`;t.forEach(t=>{n+=`<span class="chat-tag" contenteditable="false" data-set-richType="${p}"><span class="at-user" data-user-id="${t.id}" contentEditable="false">@${t.name}${this.needCallSpace?" ":""}</span></span><span data-set-richType="${h}"><span class="chat-grid-input" data-set-richType="${d}" data-set-empty="true">${this.VOID_KEY}</span></span>`});const a=document.createElement("div");a.innerHTML=n,this.insetRangeGrid(a,e?1:0),i()})}switchRange(t){var e,i;let{focusNode:n,focusOffset:a,isCollapsed:s,anchorNode:l,anchorOffset:o}=this.target.getSelection();n.getAttribute&&n.getAttribute("data-set-richType")===d&&(n=n.childNodes[0]);let r,c,h=!1,p=!1;if(n.nodeType===Node.TEXT_NODE){const d=n.textContent.length,g=n.parentNode.parentNode;switch(t){case"ArrowLeft":if(!s){const t=this.getRangeReverse();r=t?n:l,c=t?a:o,p=!0;break}if(a>0&&n.textContent!==this.VOID_KEY){c=a-1,r=n;break}const t=g.previousSibling;if(t&&t.children[0].classList.contains("at-input")){r=t.children[0].children[0].childNodes[0],c=r.textContent===this.VOID_KEY?1:r.textContent.length,h=!0;break}const u=null==(e=null==g?void 0:g.previousSibling)?void 0:e.previousSibling;if(u)r=u.childNodes[0].childNodes[0],c=r.textContent.length;else{const t=g.parentNode.previousSibling;t&&(r=t.lastChild.childNodes[0].childNodes[0],c=r.textContent.length)}break;case"ArrowRight":if(!s){const t=this.getRangeReverse();r=t?l:n,c=t?o:a,p=!0;break}if(a<d&&n.textContent!==this.VOID_KEY){c=a+1,r=n;break}const m=g.nextSibling;if(m&&m.children[0].classList.contains("at-input")){r=m.children[0].children[0].childNodes[0],c=r.textContent===this.VOID_KEY?1:0,h=!0;break}const E=null==(i=null==g?void 0:g.nextSibling)?void 0:i.nextSibling;if(E)r=E.childNodes[0].childNodes[0],c=r.textContent===this.VOID_KEY?1:0;else{const t=g.parentNode.nextSibling;t&&(r=t.childNodes[0].childNodes[0].childNodes[0],c=r.textContent===this.VOID_KEY?1:0)}}}(c||0===c)&&(h?this.setInputTagRange(r,c):this.restCursorPos(r,c)),p&&this.viewIntoPoint()}getRangeReverse(){let{focusNode:t,focusOffset:e,isCollapsed:i,anchorNode:n,anchorOffset:a}=this.target.getSelection();if(i)return!1;if(t===n)return a>e;const s=T(t.parentElement,10),l=T(n.parentElement,10);if(!s||!l)return!1;const o=s.parentElement,r=l.parentElement;if(o===r){const t=Array.from(o.children).indexOf(s);return Array.from(r.children).indexOf(l)>t}const c=Array.from(o.parentElement.children).indexOf(o);return Array.from(r.parentElement.children).indexOf(r)>c}getGridElm(t=!1){const e=document.createElement("span");if(e.setAttribute("data-set-richType",h),e.innerHTML=`<span class="chat-grid-input" data-set-richType="${d}" data-set-empty="true">${this.VOID_KEY}<br></span>`,t)return e;const i=document.createElement("p");return i.className="chat-grid-wrap",i.setAttribute("data-set-richType",c),i.appendChild(e),i}updateGrid(){const t=this.target.getSelection(),e=t.focusNode;if(!e)return;const i=e.parentNode;let n,a,s,l;switch(i.getAttribute("data-set-richType")){case r:if(!e.getAttribute||e.getAttribute("data-set-richType")!==c)break;if(n=e.childNodes[t.focusOffset],!n||n.getAttribute("data-set-richType")===p){const t=this.getGridElm(!0),i=t.children[0];n?(i.removeChild(i.childNodes[1]),e.insertBefore(t,n)):e.appendChild(t),this.restCursorPos(i.childNodes[0]);break}if(n.tagName&&"BR"===n.tagName.toLocaleUpperCase()){const t=this.getGridElm(!0),i=t.children[0];e.insertBefore(t,n),e.removeChild(n),t.nextElementSibling&&t.children[0].removeChild(t.children[0].childNodes[1]),this.restCursorPos(i.childNodes[0],i.childNodes[0].textContent.length)}break;case h:const o=i.parentNode,g=Array.prototype.indexOf.call(o.childNodes,i);if(-1===g)break;if(0===g){const e=t.focusNode;e.setAttribute("data-set-empty","true"),e.innerHTML=`${this.VOID_KEY}<br>`,n=e.childNodes[0],this.restCursorPos(n,n.textContent.length);break}let u,m=i.previousSibling;m.getAttribute("data-set-richType")===p?(u=m.previousSibling,o.removeChild(m),o.removeChild(i)):(u=i.previousSibling,o.removeChild(i)),n=u.childNodes[0].childNodes[0],n.textContent===this.VOID_KEY&&n.parentNode.appendChild(document.createElement("br")),this.restCursorPos(n,n.textContent.length);break;case d:if(l=i.parentNode,s=l.parentNode,this.getNodeEmpty(i)){i.setAttribute("data-set-empty","true"),s.childNodes[s.childNodes.length-1]===l&&(i.innerHTML=`${this.VOID_KEY}<br>`),n=i.childNodes[0],this.restCursorPos(n,n.textContent.length);break}if("true"===String(i.getAttribute("data-set-empty"))){i.setAttribute("data-set-empty","false"),n=i.childNodes[0],this.target.chatEvent.isIMEModel?(i.childNodes[1]&&i.removeChild(i.childNodes[1]),n.textContent===this.VOID_KEY&&i.setAttribute("data-set-empty","true")):i.textContent=n.textContent.replace(new RegExp(this.VOID_KEY,"g"),"");const t=i.childNodes[0];this.restCursorPos(t,t.textContent.length)}if(a=i.parentNode.nextSibling,a&&a.nodeType===Node.TEXT_NODE){let t=a.textContent,e=this.getGridElm(!0);e.childNodes[0].textContent=t,e.childNodes[0].setAttribute("data-set-empty","false"),a.parentNode.insertBefore(e,a),a.parentNode.removeChild(a),a=e}a&&a.getAttribute("data-set-richType")===h&&this.markMerge(i.parentNode,a)}}getNodeEmpty(t){const e=new RegExp(`^(${this.ZERO_WIDTH_KEY}|<br>|${this.VOID_KEY})+$`);return!t.innerHTML||e.test(t.innerHTML)}setWrap(t=!0){const e=this.target.getSelection();let{focusNode:i,focusOffset:n}=e;if(i.nodeType!==Node.TEXT_NODE){if(!i.getAttribute||i.getAttribute("data-set-richType")!==d)return;i=i.childNodes[0]}const a=i.textContent.slice(n),s=i.parentNode.parentNode,l=s.parentNode,o=Array.prototype.indexOf.call(l.childNodes,s),r=Array.prototype.slice.call(l.childNodes,o+1),c=this.getGridElm();let p=c.children[0].children[0].childNodes[0];(a||r.length>0)&&p.parentNode.removeChild(p.parentNode.childNodes[1]),a&&a!==this.VOID_KEY&&(i.textContent=i.textContent.slice(0,n),p.textContent=a,p.parentElement.setAttribute("data-set-empty","false")),r.forEach(t=>{l.removeChild(t),c.appendChild(t)});const g=l.lastChild.childNodes[0],u=c.lastChild.childNodes[0];if(g.childNodes.length<=1){const t=g.childNodes[0];t.textContent&&t.textContent!==this.VOID_KEY||(g.innerHTML=`${this.VOID_KEY}<br>`,g.setAttribute("data-set-empty","true"))}if(u.parentElement.getAttribute("data-set-richType")!==h)c.appendChild(this.getGridElm(!0));else if(u.childNodes.length<=1){const t=u.childNodes[0];t.textContent&&t.textContent!==this.VOID_KEY||(u.innerHTML=`${this.VOID_KEY}<br>`,u.setAttribute("data-set-empty","true"),p=c.children[0].children[0].childNodes[0])}l.nextSibling?this.richText.insertBefore(c,l.nextSibling):this.richText.appendChild(c),t&&this.restCursorPos(p,p.textContent===this.VOID_KEY?1:0)}selectAll(){const t=document.createRange(),e=this.richText.children[0].children[0].childNodes[0].childNodes[0],i=this.richText.lastElementChild.lastElementChild.childNodes[0].childNodes[0];t.setStart(e,0),t.setEnd(i,i.textContent.length);const n=this.target.getSelection();n.removeAllRanges(),n.addRange(t)}selectRegionMerge(){const t=this.target.getSelection();if(t.isCollapsed||t.rangeCount<=0)return;const e=t.getRangeAt(0);if(e.startContainer.nodeType===Node.TEXT_NODE&&e.startContainer===e.endContainer){const t=e.startContainer;if(t.length===e.endOffset-e.startOffset){const e=t.parentNode,i=e.parentNode===e.parentNode.parentNode.lastChild;e.setAttribute("data-set-empty","true"),e.innerHTML="\ufeff"+(i?"<br>":""),this.restCursorPos(e.childNodes[0])}else e.deleteContents()}else if(e.commonAncestorContainer&&e.commonAncestorContainer.getAttribute("data-set-richType")===c){const t=e.startContainer.nodeType===Node.TEXT_NODE?e.startContainer.parentNode.parentNode:e.startContainer,i=e.endContainer.nodeType===Node.TEXT_NODE?e.endContainer.parentNode.parentNode:e.endContainer;e.deleteContents(),t.getAttribute("data-set-richType")===i.getAttribute("data-set-richType")&&this.markMerge(t,i)}else if(e.commonAncestorContainer===e.startContainer&&e.startContainer===e.endContainer)this.initEditor(!0);else{const t=t=>{if(t.nodeType===Node.TEXT_NODE)return t.parentNode.parentNode.parentNode;switch(t.getAttribute("data-set-richType")){case d:return t.parentNode.parentNode;case h:return t.parentNode;case c:return t;default:return null}},i=t(e.startContainer),n=t(e.endContainer);if(!i||!n)return;e.deleteContents(),this.gridMerge(i,n)}return!0}gridElmMerge(){const t=this.target.getSelection(),{focusNode:e,focusOffset:i,isCollapsed:n}=t;if(!e)return this.restCursorPos(this.vnode,this.cursorIndex),!1;if(i>1)return!1;if(!n)return!1;const a=(t,e)=>(t.parentNode===this.richText||t===t.parentNode.childNodes[0])&&(-1!==Array.prototype.indexOf.call(this.richText.childNodes,t)?t:!(e>=6)&&a(t.parentNode,e+1)),s=a(e,0);if(!s||s===this.richText.childNodes[0]||1===i&&"false"===s.children[0].children[0].getAttribute("data-set-empty"))return!1;const l=s.previousSibling;return this.gridMerge(l,s),!0}delMarkRule(){const t=this.target.getSelection(),e=t.focusNode;if(!e)return this.restCursorPos(this.vnode,this.cursorIndex),!1;const i=e.textContent,n=e.parentNode,a=n.parentNode,s=a.parentNode;if(!t.isCollapsed||n.getAttribute("data-set-richType")!==d)return!1;if(i&&1===i.length&&a!==s.childNodes[0]&&(0!==t.focusOffset||i===this.VOID_KEY)){if(i===this.VOID_KEY){const t=a.previousSibling;if(t.children[0].classList.contains("at-input")&&t.children[0].children[0].textContent!==this.VOID_KEY)return this.rangeToInputTag(t.children[0]),!0;const e=t.previousSibling;s.removeChild(t),s.removeChild(a);const i=e.childNodes[0],n=i.childNodes[0];n.textContent===this.VOID_KEY&&e===s.lastChild&&i.appendChild(document.createElement("br")),this.restCursorPos(n,n.textContent.length)}else{n.innerHTML=a===s.lastChild?`${this.VOID_KEY}<br>`:this.VOID_KEY,n.setAttribute("data-set-empty","true");const t=n.childNodes[0];this.restCursorPos(t,1)}return!0}if(0===t.focusOffset){const t=n.parentNode,e=null==t?void 0:t.previousSibling;return!(!e||e.getAttribute("data-set-richType")!==p||(e.children[0].classList.contains("at-input")&&e.children[0].children[0].textContent!==this.VOID_KEY?(this.rangeToInputTag(e.children[0]),0):(this.delTag(e),0)))}}delTag(t){const e=t.previousSibling,i=t.nextSibling;t.parentNode.removeChild(t),this.markMerge(e,i)}gridMerge(t,e,i=!0){t.lastChild.getAttribute("data-set-richType")!==h&&t.appendChild(this.getGridElm(!0)),e.childNodes[0].getAttribute("data-set-richType")!==h&&e.insertBefore(this.getGridElm(!0),e.childNodes[0]);const n=t.lastChild.childNodes[0],a=n.childNodes[0];let s=a.textContent.length;Array.from(e.childNodes,e=>{t.appendChild(e.cloneNode(!0))}),e.childNodes.length>1&&n.childNodes[1]&&n.removeChild(n.childNodes[1]);const l=n.parentNode.nextSibling;if(l){const e=l.children[0].childNodes[0];e&&e.textContent!==this.VOID_KEY&&(n.childNodes[1]&&n.removeChild(n.childNodes[1]),a.textContent=(a.textContent+e.textContent).replace(new RegExp(this.VOID_KEY,"g"),()=>(s--,"")),a.parentElement.setAttribute("data-set-empty","false")),t.removeChild(l)}""===a.textContent&&(a.textContent=this.VOID_KEY,a.parentNode.setAttribute("data-set-empty","true"),s=1),this.richText.removeChild(e),i&&this.restCursorPos(a,s)}markMerge(t,e){const i=t.children[0].childNodes[0];let n=i.textContent.length;if(e){const t=e.children[0].childNodes[0];t&&t.textContent!==this.VOID_KEY&&(i.textContent=(i.textContent+t.textContent).replace(new RegExp(this.VOID_KEY,"g"),()=>(n--,"")),i.parentElement.setAttribute("data-set-empty","false")),e.parentNode.removeChild(e)}""===i.textContent&&(i.textContent=this.VOID_KEY,i.parentNode.setAttribute("data-set-empty","true"),n=1);const a=t.parentNode;i.textContent===this.VOID_KEY&&t===a.lastChild&&(i.parentNode.appendChild(document.createElement("br")),i.parentNode.setAttribute("data-set-empty","true"),n=1),this.restCursorPos(i,n)}setCallSpace(t){this.needCallSpace=t}getWrapNode(t,e=!1){if(t.nodeType===Node.TEXT_NODE)return t.parentNode.parentNode.parentNode;const i=t.getAttribute("data-set-richType");if(e&&i===p)return t.parentNode;switch(i){case d:return t.parentNode.parentNode;case h:return t.parentNode;case c:return t}}getMarkNode(t,e=!1){if(t.nodeType===Node.TEXT_NODE)return t.parentNode?t.parentNode.parentNode:null;const i=t.getAttribute("data-set-richType");if(e&&i===p)return t;switch(i){case d:return t.parentNode;case h:return t}}getRichTextNodeIndex(){let t,e,i,n=null,a=null,s=null;switch(this.lastCursorType){case"inputTag":if(!this.inputTag_vnode)break;if(e=T(this.inputTag_vnode.parentElement,5),!e)break;i=e.parentElement,n=Array.prototype.indexOf.call(this.richText.children,i),s=Array.prototype.indexOf.call(i.children,e);break;case"gridInput":if(!this.vnode)break;if(t=T(this.vnode.parentElement,5),!t)break;i=t.parentElement,n=Array.prototype.indexOf.call(this.richText.children,i),a=Array.prototype.indexOf.call(i.children,t)}return{gridIndex:n,markIndex:a,tagIndex:s}}setWrapNodeByMark(t){const e=document.createElement("p");return e.className="chat-grid-wrap",e.setAttribute("data-set-richType",c),Array.from(t,t=>{e.appendChild(t)}),e}insetRangeGrid(t,e=0){const i=this.vnode.textContent,n=i.slice(0,this.cursorIndex-e);0===n.length?(this.vnode.parentElement.setAttribute("data-set-empty","true"),this.vnode.textContent=this.VOID_KEY):this.vnode.textContent=n;let a=i.slice(this.cursorIndex);const s=[],l=document.createDocumentFragment();Array.from(t.children).forEach((t,e)=>{s.push(t),0!==e&&l.appendChild(t)});const o=s[s.length-1].children[0];a&&a.length>0&&a!==this.VOID_KEY?(o.setAttribute("data-set-empty","false"),o.textContent=o.textContent+a):o.setAttribute("data-set-empty","true");const r=this.getMarkNode(this.vnode),c=r.parentElement,h=r.children[0],d=s[0].textContent;d&&d.length>0&&d!==this.VOID_KEY&&(h.setAttribute("data-set-empty","false"),h.textContent=(h.textContent+d).replace(new RegExp(this.VOID_KEY,"g"),"")),h.childNodes[1]&&h.removeChild(h.childNodes[1]),r.nextElementSibling?(o.childNodes[1]&&o.removeChild(o.childNodes[1]),c.insertBefore(l,r.nextElementSibling)):c.appendChild(l);const p=a&&a!==this.VOID_KEY?a.length:0;if(s.length>1){const t=o.childNodes[0];this.restCursorPos(t,t.textContent===this.VOID_KEY?1:t.textContent.length-p)}else{const t=h.childNodes[0];this.restCursorPos(t,t.textContent===this.VOID_KEY?1:t.textContent.length-p)}}insetRangeGrids(t){const e=document.createDocumentFragment();Array.from(t).forEach(t=>{e.appendChild(t)});const i=this.getWrapNode(this.vnode);this.restCursorPos(this.vnode,this.cursorIndex),this.setWrap(!1);const n=i.nextElementSibling;n&&this.richText.insertBefore(e,n),n&&n.previousElementSibling?(this.gridMerge(i,i.nextElementSibling,!1),this.gridMerge(n.previousElementSibling,n,!0)):this.gridMerge(i,i.nextElementSibling,!0)}getOffsetRange(t,e,i=!1){const n=e.children[0].childNodes[0],a=n.textContent;if(0===t)return{rangeNode:n,rangeIndex:i?a.length:a===this.VOID_KEY?1:0};if(a!==this.VOID_KEY&&a.length>=t)return{rangeNode:n,rangeIndex:i?a.length-t:t};let s,l;if(i?(s=Boolean(e.previousElementSibling&&e.previousElementSibling.previousElementSibling),l=Boolean(e.parentElement.previousElementSibling)):(s=Boolean(e.nextElementSibling&&e.nextElementSibling.nextElementSibling),l=Boolean(e.parentElement.nextElementSibling)),!s&&!l)return{rangeNode:n,rangeIndex:i?a.length===this.VOID_KEY?1:0:a.length===this.VOID_KEY?1:a.length};const o=t-a.length,r=i?s?e.previousElementSibling.previousElementSibling:e.parentElement.previousElementSibling.lastElementChild:s?e.nextElementSibling.nextElementSibling:e.parentElement.nextElementSibling.children[0];return this.getOffsetRange(o,r,i)}isInInputTag(){const t=this.target.getSelection().focusNode;return!!t&&(t.classList&&t.classList.contains("input-write")?t:t.nodeType===Node.TEXT_NODE&&!!(t.parentElement&&t.parentElement.classList&&t.parentElement.classList.contains("input-write"))&&t.parentElement)}rangeToInputTag(t){const e=t.children[0].childNodes[0];this.setInputTagRange(e,e.textContent===this.VOID_KEY?1:e.textContent.length)}watchInputTag(t){if(0===t.childNodes.length||0===t.textContent.length)t.textContent=this.VOID_KEY,this.rangeToInputTag(t.parentElement);else{const e=t.childNodes[0];this.target.nextTick(()=>{if(!this.target.chatEvent.isComposition){const i=this.target.getSelection().focusOffset,n=t.textContent===this.VOID_KEY||-1===t.textContent.indexOf(this.VOID_KEY)?0:1;let a=!1;1===n&&(e.textContent=e.textContent.replace(this.VOID_KEY,""),a=!0),-1!==t.textContent.indexOf(this.INPUT_TAG_WRAP_KEY[1])&&(t.textContent=t.textContent.replace(new RegExp(this.INPUT_TAG_WRAP_KEY[0],"g"),"").replace(new RegExp(this.INPUT_TAG_WRAP_KEY[1],"g"),this.INPUT_TAG_WRAP_KEY),a=!0),a&&this.setInputTagRange(t.childNodes[0],i-n)}})}s(t.nextElementSibling,t.textContent===this.VOID_KEY,"inline")}backRuleInputTag(t){if(t.textContent===this.VOID_KEY)return this.delTag(t.parentElement.parentElement),!0;const e=this.target.getSelection();if(0===e.focusOffset&&e.isCollapsed){const e=t.parentElement.parentElement.previousElementSibling.children[0].childNodes[0];return this.restCursorPos(e,e.textContent===this.VOID_KEY?1:e.textContent.length),!0}if(-1!==e.focusNode.textContent.indexOf(this.INPUT_TAG_WRAP_KEY[1])){const t=this.getDiffInputTagOffset(e.focusNode,e.focusOffset,"left");if(t>0){const i=e.focusNode.textContent.slice(0,e.focusOffset-1-t),n=e.focusNode.textContent.slice(e.focusOffset);return e.focusNode.textContent=i+n,e.focusNode.textContent?this.setInputTagRange(e.focusNode,i.length):(e.focusNode.textContent=this.VOID_KEY,this.watchInputTag(e.focusNode.parentElement),this.setInputTagRange(e.focusNode,1)),!0}}return!1}mergeRuleInputTag(t){return new Promise(e=>{this.target.nextTick(()=>{t.childNodes.length>1&&(t.removeChild(t.childNodes[1]),this.watchInputTag(t),this.setInputTagRange(t.childNodes[0])),e()})})}inputTagSwitchRange(t){const{focusNode:e,focusOffset:i,isCollapsed:n,anchorNode:a,anchorOffset:s}=this.target.getSelection(),l=e.textContent.length,o=e.parentElement.parentElement.parentElement;let r,c,h,d=!1,p=!1;switch(t){case"ArrowLeft":if(!n){const t=this.getRangeReverse();r=t?e:a,c=t?i:s,d=!1,p=!0;break}i>0&&e.textContent!==this.VOID_KEY?(h=this.getDiffInputTagOffset(e,i,"left"),c=i-1-h,r=e):(r=o.previousElementSibling.children[0].childNodes[0],c=r.textContent===this.VOID_KEY?1:r.textContent.length,d=!0);break;case"ArrowRight":if(!n){const t=this.getRangeReverse();r=t?a:e,c=t?s:i,d=!1,p=!0;break}i<l&&e.textContent!==this.VOID_KEY?(h=this.getDiffInputTagOffset(e,i,"right"),c=i+1+h,r=e):(r=o.nextElementSibling.children[0].childNodes[0],c=r.textContent===this.VOID_KEY?1:0,d=!0)}d?this.restCursorPos(r,c):this.setInputTagRange(r,c),p&&this.viewIntoPoint()}pasteInputTag(t){t=t.replace(new RegExp(this.INPUT_TAG_WRAP_KEY[0],"g"),"").replace(new RegExp(this.INPUT_TAG_WRAP_KEY[1],"g"),this.INPUT_TAG_WRAP_KEY);const e=this.target.getSelection(),{focusNode:i,focusOffset:n,anchorOffset:a}=e;let s="",l="";e.isCollapsed?(s=i.textContent.slice(0,n)||"",l=i.textContent.slice(n)||""):(s=i.textContent.slice(0,a<n?a:n)||"",l=i.textContent.slice(n>a?n:a)||""),i.textContent=s+t+l,this.setInputTagRange(i,(a<n?a:n)+t.length);const o=i.parentElement;this.watchInputTag(o)}setInputTagWrap(t){const e=this.target.getSelection(),{focusOffset:i}=e,n=t.textContent,a=n.slice(0,i),s=n.slice(i);t.textContent=a+this.INPUT_TAG_WRAP_KEY+s,this.setInputTagRange(t.childNodes[0],i+this.INPUT_TAG_WRAP_KEY.length),this.watchInputTag(t)}getDiffInputTagOffset(t,e,i){const n="left"===i?t.textContent[e-1]:t.textContent[e];if(-1===this.INPUT_TAG_WRAP_KEY.indexOf(n))return 0;switch(i){case"left":return t.textContent[e-2]===this.INPUT_TAG_WRAP_KEY[1]?2:t.textContent[e-2]===this.INPUT_TAG_WRAP_KEY[0]?3:1;case"right":return t.textContent[e+1]===this.INPUT_TAG_WRAP_KEY[1]?2:t.textContent[e+1]===this.INPUT_TAG_WRAP_KEY[0]?3:1}}updateNodeCursor(){const{focusNode:t,focusOffset:e}=this.target.getSelection();if(!t||t.nodeType!==Node.TEXT_NODE)return;const i=T(t.parentElement,5);if(!i)return;const n=i.getAttribute("data-set-richType");if(n&&i.parentElement.parentElement===this.richText)switch(n){case h:this.updateGridInputCursor(t,e);break;case p:i.children[0].classList.contains("at-input")&&this.updateInputTagCursor(t,e)}}updateGridInputCursor(t,e){this.lastCursorType="gridInput",this.vnode=t,this.cursorIndex=t.textContent===this.VOID_KEY?1:e}updateInputTagCursor(t,e){this.lastCursorType="inputTag",this.inputTag_vnode=t,this.inputTag_cursorIndex=t.textContent===this.VOID_KEY?1:e}restCursorPos(t,e){var i;if(-1===(null==(i=t.parentElement)?void 0:i.className.indexOf("chat-grid-input")))return;null==e?e=t.textContent===this.VOID_KEY?1:0:e>t.textContent.length&&(e=t.textContent.length);const n=new Range;n.setStart(t,e),n.setEnd(t,e);const a=this.target.getSelection();a.removeAllRanges(),a.addRange(n),this.updateGridInputCursor(t,e)}setInputTagRange(t,e){var i;if(-1===(null==(i=t.parentElement)?void 0:i.className.indexOf("input-write")))return;null==e?e=t.textContent===this.VOID_KEY?1:0:e>t.textContent.length&&(e=t.textContent.length);const n=new Range;n.setStart(t,e),n.setEnd(t,e);const a=this.target.getSelection();a.removeAllRanges(),a.addRange(n),this.updateInputTagCursor(t,e)}setRangeLastRecord(){switch(this.lastCursorType){case"gridInput":this.restCursorPos(this.vnode,this.cursorIndex);break;case"inputTag":this.setInputTagRange(this.inputTag_vnode,this.inputTag_cursorIndex)}}setRangeLastText(){const t=this.richText.childNodes[this.richText.childNodes.length-1],e=t.childNodes[t.childNodes.length-1].children[0].childNodes[0];this.restCursorPos(e,e.textContent===this.VOID_KEY?1:e.textContent.length),this.viewIntoPoint()}viewIntoPoint(){let t,e;const i=this.target.getSelection(),{focusNode:n,focusOffset:a}=i;if(n&&n.parentElement&&n.parentElement.classList.contains("input-write"))t=n.parentElement.parentElement,e=a;else{if(!this.vnode)return;t=this.getMarkNode(this.vnode),e=this.cursorIndex}if(!t)return;const s=t.getBoundingClientRect(),l=Math.ceil(s.height/this.NODE_HEIGHT),o=Math.floor(t.textContent.length/l)||1,r=(Math.floor(e/o)||1)*this.NODE_HEIGHT,c=s.top+(r-this.NODE_HEIGHT),h=this.richText.parentElement,d=h.getBoundingClientRect(),p=d.top,g=d.top+d.height;if(c<p+this.NODE_PADDING_DIFF){const t=p-c;h.scrollTo(0,h.scrollTop-t)}else if(c>g-this.NODE_HEIGHT){const t=c-g+this.NODE_HEIGHT;h.scrollTo(0,h.scrollTop+t)}}}class _{constructor(t){a(this,"target"),a(this,"outerApply",!1),a(this,"isComposition",!1),a(this,"matchKey",0),a(this,"startOpenIndex",0),a(this,"textLength",0),a(this,"isIMEModel",!1),a(this,"takeIMEModel",!1),a(this,"undoHistory",[]),a(this,"redoHistory",[]),a(this,"doOverHistory",!0),a(this,"chatEventModule",{enterSend:[],operate:[],defaultAction:[],atMatch:[],atCheck:[],tagCheck:[],selectCheck:[],tipTagState:[],afterAtCheck:[],afterTagCheck:[],afterSelectCheck:[],showAtDialog:[],showTagDialog:[],showSelectDialog:[],elementClicked:[]}),a(this,"debounceEvents",{recordHistory:()=>{},dialogMoveToRange:t=>{},selectDialogToAim:()=>{},matchPointDialog:()=>{},movePointActiveUserElm:t=>{},moveCustomActiveTagElm:t=>{}}),this.target=t,this.registerEvent(),this.otherEvent()}registerEvent(){const{chatElement:t,options:e,chatInput:i}=this.target;t.richText.addEventListener("keyup",this.onKeyUp.bind(this)),t.richText.addEventListener("keydown",this.onKeyDown.bind(this)),t.richText.addEventListener("beforeinput",this.onBeforeinput.bind(this)),t.richText.addEventListener("input",this.onInput.bind(this)),t.richText.addEventListener("copy",t=>{t.preventDefault(),this.ruleChatEvent(()=>{this.copyRange(t)},"defaultAction","COPY")}),t.richText.addEventListener("cut",t=>{t.preventDefault();const e=this.target.chatInput.isInInputTag();this.ruleChatEvent(()=>{this.copyRange(t),this.removeRange(),e&&this.target.chatInput.mergeRuleInputTag(e)},"defaultAction","CUT")}),t.richText.addEventListener("paste",t=>{t.preventDefault();const e=this.target.chatInput.isInInputTag(),{options:i,chatInput:n}=this.target;this.ruleChatEvent(()=>{const a=t.clipboardData.getData("text/plain");if("string"==typeof a&&""!==a){if(-1===i.copyType.indexOf("text"))return;if(this.removeRange(),e)return void this.target.chatInput.mergeRuleInputTag(e).then(()=>{n.pasteInputTag(a),this.richTextInput()});const s=t.clipboardData.getData(g)||"";if(s&&-1!==s.indexOf(c))return void this.insertInsideHtml(k(s));this.target.insertText(a)}else{if(-1===i.copyType.indexOf("image"))return;this.removeRange();const e=(t.clipboardData||t.originalEvent.clipboardData).items||[];Array.from(e,async t=>{if(-1===t.type.indexOf("image"))return;const e=t.getAsFile();if(i.uploadImage){const t=await i.uploadImage(e);this.target.insertHtml(`<img class="chat-img" src="${t}" alt="" />`)}else{const t=new FileReader;t.onload=t=>{this.target.insertHtml(`<img class="chat-img" src="${t.target.result}" alt="" />`)},t.readAsDataURL(e)}})}},"defaultAction","PASTE")}),t.richText.addEventListener("blur",()=>{i.updateNodeCursor()}),t.richText.addEventListener("focus",()=>{i.updateNodeCursor()}),t.richText.addEventListener("click",t=>{i.updateNodeCursor();const n=T(t.target,10);if(n){const t=n.children[0];if(t.classList.contains("chat-grid-input"))return void this.triggerChatEvent("elementClicked","gridInput",t);if(t.classList.contains("at-input"))return t.children[0].textContent===i.VOID_KEY&&i.rangeToInputTag(t),void this.triggerChatEvent("elementClicked","inputTag",t);if(t.classList.contains("at-select")){const i=t.getAttribute("data-select-key");return this.triggerChatEvent("showSelectDialog",i,t),e.needDialog&&this.target.showPCSelectDialog(i,t),void this.triggerChatEvent("elementClicked","selectTag",t)}if(t.classList.contains("at-user"))return void this.triggerChatEvent("elementClicked","userTag",t);if(t.classList.contains("at-tag"))return void this.triggerChatEvent("elementClicked","customTag",t);if(t.classList.contains("chat-set-html"))return void this.triggerChatEvent("elementClicked","htmlTag",t.children[0])}}),t.richText.addEventListener("dragstart",t=>{t.stopPropagation(),t.preventDefault()}),t.richText.addEventListener("dragover",t=>{t.stopPropagation(),t.preventDefault()}),t.richText.addEventListener("drop",t=>{t.stopPropagation(),t.preventDefault()}),t.richText.addEventListener("compositionstart",()=>{this.isComposition=!0}),t.richText.addEventListener("compositionend",()=>{this.isComposition=!1}),window.addEventListener("click",this.winClick.bind(this)),window.addEventListener("keydown",this.winKeydown.bind(this))}onKeyUp(t){if(this.target.chatInput.isInInputTag())return;t.stopPropagation();const e=this.target.chatInput.getCurrentCursorKey();this.target.deviceInfo.isPc?"@"!==t.key&&"2"!==String(t.key)||"@"!==e?this.target.options.customTrigger.filter(e=>e.keyMap.includes(String(t.key))).map(t=>t.prefix).forEach(t=>{e===t&&(this.triggerChatEvent("showTagDialog",t),this.target.options.needDialog&&this.target.chatElement.showCustomTagDialog(t))}):(this.triggerChatEvent("showAtDialog"),this.target.options.needDialog&&this.target.chatElement.ruleShowPointDialog()):(this.target.options.reformList.length>0||this.target.options.asyncMatch)&&"@"===e?(this.triggerChatEvent("showAtDialog"),this.target.options.needDialog&&this.target.showH5Dialog(),this.target.chatElement.isExternalCallPopup=!1):this.target.options.customTrigger.map(t=>t.prefix).forEach(t=>{e===t&&this.triggerChatEvent("showTagDialog",t)})}onKeyDown(t){const e=this.target.chatInput.isInInputTag();if(!this.target.deviceInfo.isPc&&w(t,"IME"))return e&&this.target.chatInput.mergeRuleInputTag(e),void(this.isIMEModel=!0);this.isIMEModel||(l(this.target.chatElement.pcElms.pointDialogElm)?w(t,"dialog-options")?t.preventDefault():w(t,"text-move")&&this.target.chatElement.exitPointDialog():this.target.chatElement.pcElms.customTagDialogTagKey&&l(this.target.chatElement.pcElms.customTagDialogElms[this.target.chatElement.pcElms.customTagDialogTagKey])?w(t,"dialog-options")?t.preventDefault():w(t,"text-move")&&this.target.chatElement.exitCustomTagDialog():(!this.isComposition&&w(t,"text-delete")?e?(this.target.chatInput.backRuleInputTag(e)&&(t.preventDefault(),this.richTextInput()),this.target.chatInput.mergeRuleInputTag(e)):this.target.chatInput.selectRegionMerge()||this.target.chatInput.gridElmMerge()||this.target.chatInput.delMarkRule()?(t.preventDefault(),this.richTextInput()):this.target.chatElement.tipElm&&this.target.isEmpty()&&this.target.chatElement.removeTipElm():"Delete"===t.key||"Delete"===t.code?(t.preventDefault(),this.target.getSelection().isCollapsed?this.target.cursorDel(1):(this.removeRange(),e&&this.target.chatInput.mergeRuleInputTag(e))):this.target.options.wrapKeyFun(t)||!this.target.deviceInfo.isPc&&"Enter"===t.key?(t.preventDefault(),this.isComposition||(e?this.target.chatInput.setInputTagWrap(e):this.target.chatInput.setWrap(),this.richTextInput())):this.target.options.sendKeyFun(t)?(t.preventDefault(),this.isComposition||this.triggerChatEvent("enterSend")):w(t,"text-move")?(t.preventDefault(),this.isComposition||(e?this.target.chatInput.inputTagSwitchRange(t.code):this.target.chatInput.switchRange(t.code))):w(t,"text-select-all")?(t.preventDefault(),this.isComposition||this.target.isEmpty()||this.target.chatInput.selectAll()):w(t,"text-undo")?(t.preventDefault(),this.isComposition||this.ruleChatEvent(()=>{this.target.undo()},"defaultAction","UNDO")):w(t,"text-redo")&&(t.preventDefault(),this.isComposition||this.ruleChatEvent(()=>{this.target.redo()},"defaultAction","REDO")),this.target.deviceInfo.isPc&&!this.target.getSelection().isCollapsed&&w(t,"text-write")&&this.target.chatInput.selectRegionMerge()))}onBeforeinput(t){const e=this.target.chatInput.isInInputTag();if(this.isIMEModel){if("insertParagraph"===t.inputType)return t.preventDefault(),e?this.target.chatInput.setInputTagWrap(e):this.target.chatInput.setWrap(),void this.richTextInput();if("deleteContentBackward"===t.inputType){this.takeIMEModel=!0,t.preventDefault();const i=this.target.chatElement.richText.innerHTML,n=this.target.getSelection(),a=n.focusNode,s=n.focusOffset;let l=-1,o=-1;if(a.nodeType!==Node.TEXT_NODE){const t=a;if(!t||!t.getAttribute||t.getAttribute("data-set-richType")!==c)return;l=Array.prototype.indexOf.call(this.target.chatElement.richText.children,t),o=0}else{const t=e?a.parentElement.parentElement.parentElement:a.parentElement.parentElement,i=t.parentElement;l=Array.prototype.indexOf.call(this.target.chatElement.richText.children,i),o=Array.prototype.indexOf.call(i.children,t)}this.target.nextTick(()=>{if(this.target.chatElement.richText.innerHTML=i,-1===l||-1===o)return this.takeIMEModel=!1,void(this.isIMEModel=!1);const t=this.target.chatElement.richText.children[l].children[o],n=e?t.children[0].children[0].childNodes[0]:t.children[0].childNodes[0];e?(this.target.chatInput.setInputTagRange(n,s),this.target.chatInput.backRuleInputTag(n.parentElement)||(n.textContent=n.textContent.slice(0,s-1)+n.textContent.slice(s),this.target.chatInput.setInputTagRange(n,s-1)),this.target.chatInput.watchInputTag(n.parentElement)):(this.target.chatInput.restCursorPos(n,s),this.target.chatInput.selectRegionMerge()||this.target.chatInput.gridElmMerge()||this.target.chatInput.delMarkRule()||(n.textContent=n.textContent.slice(0,s-1)+n.textContent.slice(s),this.target.chatInput.restCursorPos(n,s-1))),this.target.nextTick(async()=>{await this.richTextInput(),this.takeIMEModel=!1,this.isIMEModel=!1})})}}}onInput(){const t=this.target.chatInput.isInInputTag();if(this.isIMEModel){if(this.takeIMEModel)return;this.target.nextTick(()=>{t&&this.target.chatInput.watchInputTag(t),this.richTextInput()})}else{if(t)return this.target.chatInput.watchInputTag(t),void this.richTextInput();this.richTextInput().then(()=>{this.target.deviceInfo.isPc&&!this.isComposition&&this.debounceEvents.matchPointDialog()})}}winClick(){if(!this.target||this.outerApply)return;const{chatElement:t}=this.target;l(t.pcElms.pointDialogElm)&&t.exitPointDialog(),t.pcElms.checkDialogSearchResultElm&&s(t.pcElms.checkDialogSearchResultElm),t.pcElms.customTagDialogTagKey&&l(t.pcElms.customTagDialogElms[t.pcElms.customTagDialogTagKey])&&t.exitCustomTagDialog(),t.pcElms.selectDialogKey&&l(t.pcElms.selectDialogElms[t.pcElms.selectDialogKey])&&t.exitSelectDialog()}async winKeydown(t){if(!this.target)return;const{chatElement:e,options:i}=this.target;if((t.ctrlKey||t.metaKey)&&"KeyZ"===t.code&&t.preventDefault(),!this.isComposition)if(l(e.pcElms.pointDialogElm)){if("ArrowDown"===t.code)return t.preventDefault(),void this.debounceEvents.movePointActiveUserElm("down");if("ArrowUp"===t.code)return t.preventDefault(),void this.debounceEvents.movePointActiveUserElm("up");if(("Enter"===t.code||"NumpadEnter"===t.code)&&e.pcElms.pointDialogActiveElm){t.preventDefault();const n=e.pcElms.pointDialogActiveElm.getAttribute("data-set-id");if(await f(100),e.isPointSearchMode||i.asyncMatch)await this.target.matchSetTag(i.reformList.find(t=>t.id===n));else{const t=i.userList.find(t=>String(t[i.userProps.id])===n);await this.target.onceSetTag(t)}e.exitPointDialog()}}else if(e.pcElms.customTagDialogTagKey&&l(e.pcElms.customTagDialogElms[e.pcElms.customTagDialogTagKey])){if("ArrowDown"===t.code)return t.preventDefault(),void this.debounceEvents.moveCustomActiveTagElm("down");if("ArrowUp"===t.code)return t.preventDefault(),void this.debounceEvents.moveCustomActiveTagElm("up");if(("Enter"===t.code||"NumpadEnter"===t.code)&&e.pcElms.customTagDialogActiveElm){t.preventDefault();const i=e.pcElms.customTagDialogActiveElm.getAttribute("data-set-id");await f(100);const n=e.customTags[e.pcElms.customTagDialogTagKey].find(t=>t.id===i);e.isPointSearchMode?await this.target.matchSetCustomTag(n):await this.target.onceSetCustomTag(n),e.exitCustomTagDialog()}}}otherEvent(){const{options:t,chatInput:e,chatElement:i}=this.target,{needDebounce:n}=t,a=()=>{const{gridIndex:t,markIndex:n,tagIndex:a}=e.getRichTextNodeIndex();null!==n?this.undoHistory.push({html:i.richText.innerHTML,gridIndex:t,markIndex:n,tagIndex:a,cursorIndex:e.cursorIndex,inputTag_cursorIndex:e.inputTag_cursorIndex,type:"gridInput"}):null!==a&&this.undoHistory.push({html:i.richText.innerHTML,gridIndex:t,markIndex:n,tagIndex:a,cursorIndex:e.cursorIndex,inputTag_cursorIndex:e.inputTag_cursorIndex,type:"inputTag"}),this.undoHistory.length>50&&this.undoHistory.shift()};this.debounceEvents.recordHistory=n?x(a,200):a;const l=t=>{let n="0",a="100%";const s=e.getRangeRect();if(!s)return;const l=i.pcElms.containerDialogElm.getBoundingClientRect();let o=s.x-l.x,r=l.y-s.y;const{clientWidth:c,clientHeight:h}=t;s.x>window.innerWidth-c-30&&(o=s.x-c-l.x-16,n="100%"),s.y<h&&(r-=h,a="0"),t.style.transform="translate(0, 0)",t.style.transformOrigin=`${n} ${a}`,t.style.left=o+6+"px",t.style.bottom=`${r}px`,t.style.opacity="1"};this.debounceEvents.dialogMoveToRange=n?x(l,120,!0):l;const r=()=>{if(!t.needDialog||!t.asyncMatch&&0===t.reformList.length&&0===t.customTrigger.length)return;const n=e.getCurrentCursorKey();if(!t.asyncMatch&&"@"===n)return void i.ruleShowPointDialog();if(t.customTrigger.some(t=>{if(n===t.prefix)return i.showCustomTagDialog(t.prefix),!0}))return;const a=e.vnode.textContent||"",l=e.cursorIndex,o=a.slice(0,l);let r=-1,c=-1,h="userTag";if(-1!==o.lastIndexOf("@")&&(r=o.lastIndexOf("@")),i.pcElms.customTagDialogTagKey&&-1!==o.lastIndexOf(i.pcElms.customTagDialogTagKey)&&(c=o.lastIndexOf(i.pcElms.customTagDialogTagKey)),c>r&&(h="customTag"),"userTag"===h&&t.asyncMatch){if(r<0)return void i.exitPointDialog();this.matchKey++;const t=this.matchKey;this.startOpenIndex=r+1;const e=o.slice(this.startOpenIndex)||"";if(/\s/gi.test(e))return void i.exitPointDialog();this.target.updateUserList([]),s(i.pcElms.pointDialogLoadingElm,!0,"flex"),s(i.pcElms.pointDialogEmptyElm),i.showPointDialog();const n=this.triggerChatEvent("atMatch",e).find(t=>t&&t instanceof Promise);return void(n&&n.then(e=>{t===this.matchKey&&(s(i.pcElms.pointDialogLoadingElm),!e||e.length<=0?s(i.pcElms.pointDialogEmptyElm,!0,"flex"):(this.target.updateUserList(e),i.pcElms.pointDialogUsersElm&&i.pcElms.pointDialogUsersElm.length>0&&i.updatePointActiveUserElm(i.pcElms.pointDialogUsersElm[0].elm)))}))}if("userTag"===h&&t.reformList.length<=0)return void i.exitCustomTagDialog();if("customTag"===h&&i.customTags[i.pcElms.customTagDialogTagKey].length<=0)return;const d=()=>{"userTag"===h?i.exitPointDialog():i.exitCustomTagDialog()};if(r<0&&c<0)return i.exitPointDialog(),void i.exitCustomTagDialog();this.startOpenIndex="userTag"===h?r+1:c+1;const p=new RegExp(`^([${e.ZERO_WIDTH_KEY}${e.VOID_KEY}])+$`);if(!o||p.test(o)||l<this.startOpenIndex)return void d();const g=o.slice(this.startOpenIndex)||"";if(/\s/gi.test(g))d();else if(g)if("userTag"===h){i.isExternalCallPopup=!1;const t=this.target.searchUserList(g);t.length>0?i.showPointDialog(t):d()}else{const t=i.customTags[i.pcElms.customTagDialogTagKey].filter(t=>S(t.name,t.pinyin||"",g));t.length>0?i.showCustomTagDialog(i.pcElms.customTagDialogTagKey,t):d()}else"userTag"===h?i.ruleShowPointDialog():i.showCustomTagDialog(i.pcElms.customTagDialogTagKey)};this.debounceEvents.matchPointDialog=n?x(r,200):r,this.debounceEvents.movePointActiveUserElm=y(t=>{if(!i.pcElms.pointDialogActiveElm)return;let e=0;const n=i.pcElms.pointDialogActiveElm.getAttribute("data-set-id");i.pcElms.pointDialogUsersElm.some(t=>{const i=t.elm.getAttribute("data-set-id");return e=t.index,n===i});const a=i.pcElms.pointDialogUsersElm.filter(t=>!t.elm.classList.contains("user-no-match")),s=a.map(t=>t.index);let l;"down"===t?l=e===a[a.length-1].index?a[0]:a[s.indexOf(e)+1]:"up"===t&&(l=e===a[0].index?a[a.length-1]:a[s.indexOf(e)-1]),l&&i.updatePointActiveUserElm(l.elm,!0)},80),this.debounceEvents.moveCustomActiveTagElm=y(t=>{if(!i.pcElms.customTagDialogActiveElm)return;const e=i.customTags[i.pcElms.customTagDialogTagKey].map(t=>t.id),n=i.pcElms.customTagDialogActiveElm.getAttribute("data-set-id"),a=e.indexOf(n),s=Array.from(i.pcElms.customTagDialogElms[i.pcElms.customTagDialogTagKey].children[1].children,(t,e)=>({elm:t,index:e})).filter(t=>!t.elm.classList.contains("tag-no-match")),l=s.map(t=>t.index);let o;"down"===t?o=a===s[s.length-1].index?s[0]:s[l.indexOf(a)+1]:"up"===t&&(o=a===s[0].index?s[s.length-1]:s[l.indexOf(a)-1]),o&&i.updateActiveCustomTagElm(o.elm,!0)},80);const c=()=>{const t=i.pcElms.selectDialogAim.getClientRects()[0],e=i.pcElms.selectDialogElms[i.pcElms.selectDialogKey];s(e,!0);const n=e.querySelector(".chat-select-arrow");let a=e.clientHeight+16;if(a>t.y?(a=-(t.height+16),n.style.top="-16px",n.style.bottom="auto",n.style.transform="rotate(0deg)"):(n.style.transform="rotate(180deg)",n.style.bottom="-16px",n.style.top="auto"),window.innerWidth-t.x<e.clientWidth){const i=e.clientWidth-(window.innerWidth-t.x)-10;e.style.left="auto",e.style.right="10px",n.style.left="auto",n.style.right=i-n.clientWidth/2+t.width/2+"px"}else e.style.left=t.x+"px",e.style.right="auto",n.style.left=t.width/2-n.clientWidth/2+"px",n.style.right="auto";e.style.top=t.y+"px",e.style.transform=`translateY(${-a}px)`;const l=e.children[1],r=l.children;let c=0,h=!1,d=0;if(i.pcElms.selectDialogAim.classList.contains("at-select")){const t=i.pcElms.selectDialogAim.getAttribute("data-select-id");o(i.pcElms.selectDialogAim,"aim",!0),Array.from(r,e=>{const i=e.lastChild.lastChild,n=t===e.getAttribute("data-set-id");n&&(d=e.clientHeight,h=!0),n||h||(c+=e.clientHeight),s(i,n,"inline-block")});const e=c-l.clientHeight/2+d/2;l.scrollTop=e>0?e:0}else Array.from(r,t=>{s(t.lastChild.lastChild,!1,"inline-block")})};this.debounceEvents.selectDialogToAim=n?x(c,120):c;const h={html:i.richText.innerHTML,gridIndex:0,markIndex:0,tagIndex:0,type:e.lastCursorType,cursorIndex:e.cursorIndex,inputTag_cursorIndex:e.inputTag_cursorIndex};this.undoHistory=[h]}async richTextInput(t=!0){const{chatInput:e,deviceInfo:i,chatElement:n,options:a}=this.target;return e.updateNodeCursor(),i.isPc&&e.selectRegionMerge(),await this.target.nextTick(()=>{this.isComposition||e.updateGrid(),this.fixEditor()||(-1!==a.maxLength&&this.ruleMaxLength(),n.showPlaceholder(),this.triggerChatEvent("operate"),i.isPc&&t&&this.doOverHistory&&!this.isComposition&&this.debounceEvents.recordHistory(),e.viewIntoPoint())}),!0}ruleMaxLength(){const{options:t,chatElement:e}=this.target;if(this.target.isEmpty()||-1===t.maxLength)return void(this.textLength=0);let i=0,n=0;const a=[];Array.prototype.some.call(e.richText.children,(e,s)=>{const{nodeInfos:l,nodeTextLength:o}=this.getGirdNodeTextInfo(e);if(i+=o,a.push(l),n=s,i>=t.maxLength)return!0});const s=[];Array.from(e.richText.children,(t,e)=>{e>n&&s.push(t)}),s.forEach(t=>e.richText.removeChild(t)),this.deepDelGirdText(a,i)}getGirdNodeTextInfo(t){const{chatInput:e}=this.target,i=[];let n=0;if(1===t.children.length&&t!==t.parentElement.children[0]){const a=t.children[0],s=(a.textContent||"").replace(new RegExp(e.VOID_KEY,"g"),"");n+=s.length||1,i[0]={node:a,textLength:s.length||1,type:h}}else Array.from(t.children,(t,a)=>{if(t.getAttribute("data-set-richType")===h){const s=(t.textContent||"").replace(new RegExp(e.VOID_KEY,"g"),"");n+=s.length,i[a]={node:t,textLength:s.length,type:h}}else{const s=(t.textContent||"").replace(new RegExp(e.VOID_KEY,"g"),"");n+=s.length||1,i[a]={node:t,textLength:s.length||1,type:p}}});return{nodeInfos:i,nodeTextLength:n}}deepDelGirdText(t,e){if(e>this.target.options.maxLength){const i=t[t.length-1];t.pop(),this.deepDelNode(i,t,e)}else this.textLength=e}deepDelNode(t,e,i){const n=t[0].node.parentElement;if(i>this.target.options.maxLength){let a=i-this.target.options.maxLength,s=t[t.length-1];if(s.type===h)if(0===s.textLength||a>=s.textLength)n.removeChild(s.node),t.pop(),a-=s.textLength,s=t[t.length-1],n.removeChild(s.node),t.pop(),a-=s.textLength;else{const t=s.node.childNodes[0];t.textContent=t.textContent.slice(0,s.textLength-a),0===t.textContent&&(t.setAttribute("data-set-empty","true"),t.innerHTML=`${this.target.chatInput.VOID_KEY}<br>`),a=0}else n.removeChild(s.node),t.pop(),a-=s.textLength;a>0?t.length>0?this.deepDelNode(t,e,a+this.target.options.maxLength):(this.target.chatElement.richText.appendChild(n),this.deepDelGirdText(e,a+this.target.options.maxLength)):(this.textLength=this.target.options.maxLength+a,this.target.chatInput.setRangeLastText())}}copyRange(t){const e=this.target.getSelection();if(e.isCollapsed||e.rangeCount<=0)return t.clipboardData.setData(g,""),void t.clipboardData.setData("text/plain","");const{chatElement:i,chatInput:n}=this.target,a=e.toString()||"";let s=document.createElement("div");s.innerHTML=I(a);const l=s.textContent.replace(/\n\n/g,"\n");s=null,t.clipboardData.setData("text/plain",l);const o=e.anchorNode,r=e.focusNode;if(o===r&&o.nodeType===Node.TEXT_NODE)return void t.clipboardData.setData(g,l);if(o===i.richText&&r===i.richText)return void t.clipboardData.setData(g,i.richText.innerHTML);const c=n.getWrapNode(o,!0),d=n.getWrapNode(r,!0),p=n.getMarkNode(o,!0),u=n.getMarkNode(r,!0),m=p.getAttribute("data-set-richType")===h,E=u.getAttribute("data-set-richType")===h,f=Array.prototype.indexOf.call(c.childNodes,p),v=Array.prototype.indexOf.call(d.childNodes,u);if(c===d&&c.parentNode===i.richText){const i=f>v,a=Array.prototype.filter.call(c.childNodes,(t,e)=>i?e<f&&e>v:e>f&&e<v).map(t=>t.cloneNode(!0)),s=m?i?o.textContent.slice(0,e.anchorOffset):o.textContent.slice(e.anchorOffset):"",l=E?i?r.textContent.slice(e.focusOffset):r.textContent.slice(0,e.focusOffset):"",d=n.getGridElm(!0),p=n.getGridElm(!0);s&&(d.childNodes[0].innerHTML=s,d.childNodes[0].setAttribute("data-set-empty","false")),l&&(p.childNodes[0].innerHTML=l,p.childNodes[0].setAttribute("data-set-empty","false")),i?(a[0].getAttribute("data-set-richType")!==h&&a.unshift(p),a[a.length-1].getAttribute("data-set-richType")!==h&&a.push(d)):(a[0].getAttribute("data-set-richType")!==h&&a.unshift(d),a[a.length-1].getAttribute("data-set-richType")!==h&&a.push(p));let u=document.createElement("div");const x=n.setWrapNodeByMark(a);return u.appendChild(x),t.clipboardData.setData(g,u.innerHTML),void(u=null)}if(c.parentNode===i.richText&&d.parentNode===i.richText){const a=Array.prototype.indexOf.call(i.richText.childNodes,c),s=Array.prototype.indexOf.call(i.richText.childNodes,d),l=a>s,h=Array.prototype.filter.call(i.richText.childNodes,(t,e)=>l?e<a&&e>s:e>a&&e<s).map(t=>t.cloneNode(!0)),p=m?l?o.textContent.slice(0,e.anchorOffset):o.textContent.slice(e.anchorOffset):"",u=E?l?r.textContent.slice(e.focusOffset):r.textContent.slice(0,e.focusOffset):"",x=n.getGridElm(!0),y=n.getGridElm(!0);p&&(x.childNodes[0].innerHTML=p,x.childNodes[0].setAttribute("data-set-empty","false")),u&&(y.childNodes[0].innerHTML=u,y.childNodes[0].setAttribute("data-set-empty","false"));const T=Array.prototype.filter.call(c.childNodes,(t,e)=>l?e<f:e>f).map(t=>t.cloneNode(!0)),C=Array.prototype.filter.call(d.childNodes,(t,e)=>l?e>v:e<v).map(t=>t.cloneNode(!0));if(l){T.push(x),C.unshift(y);const t=n.setWrapNodeByMark(T),e=n.setWrapNodeByMark(C);h.push(t),h.unshift(e)}else{T.unshift(x),C.push(y);const t=n.setWrapNodeByMark(T),e=n.setWrapNodeByMark(C);h.unshift(t),h.push(e)}let b=document.createElement("div");return Array.from(h,t=>{b.appendChild(t)}),t.clipboardData.setData(g,b.innerHTML),void(b=null)}}async removeRange(){const t=this.target.getSelection().getRangeAt(0);t&&!t.collapsed&&(this.target.chatInput.selectRegionMerge(),await this.richTextInput())}async setChatHistory(t){const{chatElement:e,chatInput:i}=this.target;this.doOverHistory=!1;const{html:n,gridIndex:a,markIndex:s,tagIndex:l,cursorIndex:o,inputTag_cursorIndex:r,type:c}=t;if(e.richText.innerHTML=n,"inputTag"===c){const t=e.richText.children[a].children[l].children[0].children[0].childNodes[0];i.setInputTagRange(t,r)}else{const t=e.richText.children[a].children[s].children[0].childNodes[0];i.restCursorPos(t,o)}await this.richTextInput(),this.doOverHistory=!0}async insertInsideHtml(t,e=!0){const{chatInput:i}=this.target;i.updateNodeCursor();let n=document.createElement("div");n.innerHTML=t,n.children.length&&(e&&Array.from(n.children,t=>{Array.from(t.children,(e,n)=>{const a=e.getAttribute("data-set-richType");if(a===h){const a=e.children[0];a.textContent&&a.textContent!==i.VOID_KEY?a.textContent=D(a.textContent):(a.setAttribute("data-set-empty","true"),a.innerHTML=n===t.children.length-1?`${i.VOID_KEY}<br>`:i.VOID_KEY)}else if(a===p){const t=e.children[0];t.classList.contains("at-input")?(t.children[1].textContent=D(t.children[1].textContent),t.children[0].textContent&&t.children[0].textContent!==i.VOID_KEY?t.children[0].textContent=D(t.children[0].textContent):(t.children[0].textContent=i.VOID_KEY,s(t.children[1],!0,"inline"))):t.classList.contains("at-user")||t.classList.contains("at-tag")?t.textContent=D(t.textContent):t.classList.contains("at-select")&&(t.childNodes[0].textContent=D(t.childNodes[0].textContent))}})}),1===n.children.length?i.insetRangeGrid(n.children[0]):i.insetRangeGrids(n.children),n=null,await this.richTextInput())}triggerChatEvent(t,...e){const i=[];return this.chatEventModule[t].forEach(t=>{t&&i.push(t(...e))}),i}ruleChatEvent(t,e,...i){this.triggerChatEvent(e,...i).some(t=>t&&"PREVENT"===t)||(t&&t.bind(this)(),t=null)}fixEditor(){const t=()=>{this.target.chatInput.initEditor(!0),this.target.chatElement.showPlaceholder(),this.textLength=0,this.triggerChatEvent("operate")};if(0===this.target.chatElement.richText.childNodes.length)return t(),!0;const e=this.target.chatElement.richText.childNodes[0];if(!e.getAttribute||e.getAttribute("data-set-richType")!==c||0===e.childNodes.length)return t(),!0;const i=e.childNodes[0];if(!i.getAttribute||i.getAttribute("data-set-richType")!==h||0===i.childNodes.length)return t(),!0;const n=i.childNodes[0];return n.getAttribute&&n.getAttribute("data-set-richType")===d&&0!==n.childNodes.length?0===n.childNodes[0].textContent.length?(t(),!0):void 0:(t(),!0)}}class M{constructor(t){a(this,"target"),a(this,"rankLen",4),this.target=t}getCurrentNodes(){const t=[];return Array.from(this.target.chatElement.richText.children,(e,i)=>{t.push(this.analyzeGrid(e,i))}),t}getRank(t){let e=t+1+"";const i=this.rankLen-e.length;for(let n=0;n<i;n++)e="0"+e;return e}analyzeGrid(t,e){const i={type:"gridBox",rank:this.getRank(e),children:[]};return Array.from(t.children,(t,e)=>{switch(t.getAttribute("data-set-richType")){case h:i.children.push(this.analyzeMark(t,e,i.rank));break;case p:i.children.push(this.analyzeTag(t,e,i.rank))}}),i}analyzeMark(t,e,i){return{type:"gridInput",rank:i+this.getRank(e),text:t.textContent.replace(new RegExp(this.target.chatInput.VOID_KEY,"g"),"")}}analyzeTag(t,e,i){const n=t.children[0],a={type:"htmlTag",rank:i+this.getRank(e)};return n.classList.contains("at-user")?(a.type="userTag",a.dataset={[this.target.options.userProps.id]:n.getAttribute("data-user-id"),[this.target.options.userProps.name]:n.textContent.slice(1)}):n.classList.contains("at-tag")?(a.type="customTag",a.dataset={id:n.getAttribute("data-tag-id"),name:n.textContent.slice(1),prefix:n.getAttribute("data-set-prefix")}):n.classList.contains("at-select")?(a.type="selectTag",a.dataset={id:n.getAttribute("data-select-id"),name:n.textContent,key:n.getAttribute("data-select-key")}):n.classList.contains("at-input")?(a.type="inputTag",a.dataset={key:n.getAttribute("data-input-key"),placeholder:n.children[1].textContent,value:n.children[0].textContent===this.target.chatInput.VOID_KEY?"":n.children[0].textContent.replace(new RegExp(this.target.chatInput.INPUT_TAG_WRAP_KEY[0],"g"),"")}):(a.type="htmlTag",a.html=t.children[0].innerHTML),a}analyzeGridNodes(t){t.children=t.children||[];const e=t.children;if(0===e.length)return void e.push({type:"gridInput",rank:t.rank+this.getRank(0),text:""});const i=[];e.forEach((t,n)=>{if(n===e.length-1)return;const a=n+1;if("gridInput"===t.type&&"gridInput"===e[a].type){let t=a-i.length;i.push(t)}}),i.forEach(t=>{const i=e[t];e[t-1].text+=i.text,e.splice(t,1)});const n=[];e.forEach((t,i)=>{if(i===e.length-1)return;const a=i+1;if("gridInput"!==t.type&&"gridInput"!==e[a].type){let t=a+n.length;n.push(t)}}),n.forEach(t=>{e.splice(t,0,{type:"gridInput",rank:"",text:""})}),"gridInput"!==e[0].type&&e.unshift({type:"gridInput",rank:"",text:""}),"gridInput"!==e[e.length-1].type&&e.push({type:"gridInput",rank:"",text:""}),e.forEach((e,i)=>{e.rank=t.rank+this.getRank(i)})}analyzeNode(t,e=!1){switch(t.type){case"gridInput":return`<span data-set-richType="${h}"><span class="chat-grid-input" data-set-richType="${d}" data-set-empty="${String(""===t.text)}">${""===t.text?this.target.chatInput.VOID_KEY:I(t.text)}${e&&""===t.text?"<br>":""}</span></span>`;case"userTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${p}"><span class="at-user" data-user-id="${t.dataset[this.target.options.userProps.id]}">@${I(t.dataset[this.target.options.userProps.name])}</span></span>`;case"customTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${p}"><span class="at-tag" data-tag-id="${t.dataset.id}" data-set-prefix="${t.dataset.prefix}">${t.dataset.prefix}${I(t.dataset.name)}</span></span>`;case"selectTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${p}"><span class="at-select" data-select-id="${t.dataset.id}" data-select-key="${t.dataset.key}">${I(t.dataset.name)}${E}</span></span>`;case"htmlTag":return`<span class="chat-tag" contenteditable="false" data-set-richType="${p}"><span class="chat-set-html">${t.html}</span></span>`;case"inputTag":const i=!Boolean(t.dataset.value),n=I(t.dataset.placeholder),a=I((t.dataset.value||"").replace(new RegExp(this.target.chatInput.INPUT_TAG_WRAP_KEY[1],"g"),this.target.chatInput.INPUT_TAG_WRAP_KEY)),s=i?`<span class="input-tip">${n}</span>`:`<span class="input-tip chat-view-show" style="display: none">${n}</span>`;return`<span class="chat-tag" contenteditable="false" data-set-richType="${p}"><span class="at-input" contenteditable="false" data-input-key="${t.dataset.key}"><span class="input-write" contenteditable="true">${i?this.target.chatInput.VOID_KEY:a}</span>${s}</span></span>`;case"gridBox":let l="";return this.analyzeGridNodes(t),t.children.forEach((e,i)=>{l+=this.analyzeNode(e,i===t.children.length-1)}),`<p class="chat-grid-wrap" data-set-richType="${c}">${l}</p>`;default:return""}}async insertNode(t){if("gridBox"===t.type){const e=this.analyzeNode(t);let i=document.createElement("div");i.innerHTML=e;const n=i.children[0],a=parseFloat(t.rank)-1;if(-1===a||a>this.target.chatElement.richText.children.length-1)this.target.chatElement.richText.appendChild(n);else{const t=this.target.chatElement.richText.children[a];if(!t)return;this.target.chatElement.richText.insertBefore(n,t)}const s=n.lastElementChild.children[0].childNodes[0];this.target.chatInput.restCursorPos(s,s.textContent===this.target.chatInput.VOID_KEY?1:s.textContent.length),i=null,await this.target.chatEvent.richTextInput()}else{const e=(t.text||"").length,i=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=this.getNodeByRank(i[0]);if(!n)return;const a=parseFloat(i[1])-1;-1==a?n.children.push(t):n.children.splice(a,0,t),await this.updateNode(n,()=>{if("gridInput"===t.type){const t=-1===a||a>n.children.length-1,i=!t&&a%2==0,s=t?n.children[n.children.length-1]:n.children[i?a:a-1];this.setCursorNode(s,i?e:-1)}else if("inputTag"===t.type){const e=this.getElmByRank(t.rank).nextElementSibling;this.target.chatInput.updateGridInputCursor(e.children[0].childNodes[0],0),this.setCursorNode(t,-1)}else{const e=n.children.indexOf(t);this.setCursorNode(n.children[e+1],0)}})}}async updateNode(t,e){const i=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=parseFloat(i[0])-1,a=this.target.chatElement.richText.children[n];if("gridBox"===t.type){if(!a)return;this.analyzeGridNodes(t);let i="";if(t.children.forEach((e,n)=>{i+=this.analyzeNode(e,n===t.children.length-1)}),a.innerHTML=i,e)e();else{const t=a.lastElementChild.children[0].childNodes[0];this.target.chatInput.restCursorPos(t,t.textContent===this.target.chatInput.VOID_KEY?1:t.textContent.length)}return void(await this.target.chatEvent.richTextInput())}const l=parseFloat(i[1])-1,o=a.children[l],r=this.getNodeByRank(t.rank);if(!r||t.type!==r.type)return;let c,h;if("gridInput"===t.type){const e=o.children[0];e.innerHTML=I(t.text);const i=""!==e.textContent;e.setAttribute("data-set-empty",String(!i)),i||(e.innerHTML=o.nextElementSibling?this.target.chatInput.VOID_KEY:`${this.target.chatInput.VOID_KEY}<br>`),c=e.childNodes[0],h=c.textContent.length}else if("userTag"===t.type){const e=o.children[0];e.setAttribute("data-user-id",t.dataset[this.target.options.userProps.id]),e.textContent=`@${t.dataset[this.target.options.userProps.name]}`,c=o.nextElementSibling.children[0].childNodes[0]}else if("customTag"===t.type){const e=o.children[0];e.setAttribute("data-tag-id",t.dataset.id),e.setAttribute("data-set-prefix",t.dataset.prefix),e.textContent=`${t.dataset.prefix}${t.dataset.name}`,c=o.nextElementSibling.children[0].childNodes[0]}else if("selectTag"===t.type){const e=o.children[0];e.setAttribute("data-select-id",t.dataset.id),e.setAttribute("data-select-key",t.dataset.key),e.childNodes[0].textContent=t.dataset.name,c=o.nextElementSibling.children[0].childNodes[0]}else if("inputTag"===t.type){const i=o.children[0];i.setAttribute("data-input-key",t.dataset.key),i.children[0].textContent=""===t.dataset.value?this.target.chatInput.VOID_KEY:t.dataset.value,i.children[1].textContent=t.dataset.placeholder,s(i.children[1],""===t.dataset.value,"inline-block"),e=()=>{this.target.chatInput.rangeToInputTag(i)}}else"htmlTag"===t.type&&(o.children[0].innerHTML=t.html,c=o.nextElementSibling.children[0].childNodes[0]);e?e():this.target.chatInput.restCursorPos(c,h),await this.target.chatEvent.richTextInput()}getNodeByRank(t){if(!t)return null;const e=t.match(new RegExp(`.{1,${this.rankLen}}`,"g"));if(0===e.length)return null;const i=parseFloat(e[0])-1,n=-1===i?this.target.chatElement.richText.lastElementChild:this.target.chatElement.richText.children[i];if(!n)return null;if(1===e.length)return this.analyzeGrid(n,-1===i?this.target.chatElement.richText.children.length-1:i);-1===i&&(e[0]=this.getRank(this.target.chatElement.richText.children.length-1));const a=parseFloat(e[1])-1,s=-1===a?n.lastElementChild:n.children[a];return s?s.getAttribute("data-set-richType")===h?this.analyzeMark(s,-1===a?n.children.length-1:a,e[0]):this.analyzeTag(s,-1===a?n.children.length-1:a,e[0]):null}async delNodeByRank(t){const e=this.getNodeByRank(t);if(e)if("gridBox"===e.type){const e=parseFloat(t)-1,i=this.target.chatElement.richText.children[e],n=i.nextElementSibling||i.previousElementSibling;if(n){const t=n.lastElementChild.children[0].childNodes[0];this.target.chatInput.restCursorPos(t,t.textContent===this.target.chatInput.VOID_KEY?1:t.textContent.length)}this.target.chatElement.richText.removeChild(i),0===this.target.chatElement.richText.children.length&&this.target.chatInput.initEditor(!0),await this.target.chatEvent.richTextInput()}else if("gridInput"===e.type)e.text="",await this.updateNode(e);else{const i=e.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=this.getNodeByRank(i[0]),a=n.children[parseFloat(i[1])-1-1],s=a.text.length;n.children=n.children.filter(e=>e.rank!==t),await this.updateNode(n,()=>{this.setCursorNode(a,s)})}}async coverNodes(t){if(t.length<0)return;let e="";t.forEach(t=>{e+=this.analyzeNode(t)}),this.target.chatElement.richText.innerHTML=e,this.target.chatInput.setRangeLastText(),await this.target.chatEvent.richTextInput()}setCursorNode(t,e=-1){const i=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),n=parseFloat(i[0])-1,a=-1===n?this.target.chatElement.richText.lastElementChild:this.target.chatElement.richText.children[n];let s=null;if("gridInput"===t.type){const t=parseFloat(i[1])-1;s=-1===t?a.lastElementChild:a.children[t]}else if("gridBox"===t.type)s=-1===e?a.lastElementChild:a.children[0];else if("inputTag"===t.type){const t=parseFloat(i[1])-1,n=a.children[t].children[0].children[0].childNodes[0],s=n.textContent===this.target.chatInput.VOID_KEY?1:-1===e?n.textContent.length:e;this.target.chatInput.setInputTagRange(n,s)}else{const t=parseFloat(i[1])-1,n=a.children[t];s=-1===e?n.nextElementSibling:n.previousElementSibling,e=-1===e?0:-1}if(s){const t=s.children[0].childNodes[0];-1===e&&(e=t.textContent.length),this.target.chatInput.restCursorPos(t,t.textContent===this.target.chatInput.VOID_KEY?1:e)}}getCursorNode(){const t=this.target.getSelection(),e=t.focusNode;if(e&&e.parentElement&&e.parentElement.classList.contains("input-write")){const i=e.parentElement.parentElement.parentElement;return{node:this.analyzeTag(i,Array.prototype.indexOf.call(i.parentElement.children,i),this.getRank(Array.prototype.indexOf.call(this.target.chatElement.richText.children,i.parentElement))),offset:e.textContent===this.target.chatInput.VOID_KEY?0:t.focusOffset}}const i=this.target.chatInput.vnode.parentElement.parentElement;return{node:this.analyzeMark(i,Array.prototype.indexOf.call(i.parentElement.children,i),this.getRank(Array.prototype.indexOf.call(this.target.chatElement.richText.children,i.parentElement))),offset:this.target.chatInput.vnode.textContent===this.target.chatInput.VOID_KEY?0:this.target.chatInput.cursorIndex}}setSelectNodes(t,e,i=0,n=-1){let a,s;const l=t.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),o=e.rank.match(new RegExp(`.{1,${this.rankLen}}`,"g")),r=this.target.chatElement.richText.children[parseFloat(l[0])-1],c=this.target.chatElement.richText.children[parseFloat(o[0])-1];if("gridInput"===t.type)a=r.children[parseFloat(l[1])-1];else if("gridBox"===t.type)a=-1===i?r.lastElementChild:r.children[0];else{const t=parseFloat(l[1])-1,e=r.children[t];a=-1===i?e.nextElementSibling:e.previousElementSibling,i=-1===i?0:-1}if("gridInput"===e.type)s=c.children[parseFloat(o[1])-1];else if("gridBox"===t.type)s=-1===n?c.lastElementChild:c.children[0];else{const t=parseFloat(o[1])-1,e=c.children[t];s=-1===n?e.nextElementSibling:e.previousElementSibling,n=-1===n?0:-1}const h=a.children[0].childNodes[0],d=s.children[0].childNodes[0],p=document.createRange(),g=parseFloat(t.rank)>parseFloat(e.rank);p[g?"setEnd":"setStart"](h,h.textContent===this.target.chatInput.VOID_KEY?1:-1===i?h.textContent.length:i),p[g?"setStart":"setEnd"](d,d.textContent===this.target.chatInput.VOID_KEY?1:-1===n?d.textContent.length:n);const u=this.target.getSelection();u.removeAllRanges(),u.addRange(p)}getElmByRank(t){const e=t.match(new RegExp(`.{1,${this.rankLen}}`,"g")),i=parseFloat(e[0])-1,n=-1===i?this.target.chatElement.richText.lastElementChild:this.target.chatElement.richText.children[i];if(1===e.length)return n;const a=parseFloat(e[1])-1;return-1===a?n.lastElementChild:n.children[a]}getRankByElm(t){const e=this.target.chatElement.richText.children;let i=null,n=null;return Array.prototype.find.call(e,(e,a)=>t===e?(i=a,!0):Array.prototype.find.call(e.children,(e,s)=>e===t&&(i=a,n=s,!0))),(null!==i?this.getRank(i):"")+(null!==n?this.getRank(n):"")}}class K{constructor(t){a(this,"target"),a(this,"components",{}),a(this,"eventTypes",[]),this.target=t}useComponent(t){t.props=t.props||{},t.template=(t=>t.replace(/\n+/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><").trim())(t.template||""),t.template=((t,e)=>{const i=document.createElement("div");i.innerHTML=t,i.querySelectorAll("div, p, h1, h2, h3, h4, h5, h6, section, article, header, footer, aside, nav").forEach(t=>{const e=document.createElement("span");for(e.style.display="block",Array.from(t.attributes).forEach(t=>{e.setAttribute(t.name,t.value)});t.firstChild;)e.appendChild(t.firstChild);t.parentNode.replaceChild(e,t)});const n=i.children[0];if(n&&"block"===n.style.display&&(n.style.display="inline-block"),n){for(const t in e)n.dataset[t]="{{"+t+"}}";n.setAttribute("data-set-component","{{data-set-component}}")}return i.innerHTML})(t.template||"",t.props),this.components[t.name]=t;const e=/bind-([a-zA-Z]+)="([^"]*)"/g,i=[];let n;for(;null!==(n=e.exec(t.template));)i.push({eventType:n[1],handlerName:n[2]});i.forEach(t=>{this.useComponentEvent(t.eventType)})}useComponentEvent(t){this.eventTypes.includes(t)||(this.eventTypes.push(t),this.target.chatElement.richText.addEventListener(t,e=>{this.componentEventRecognizer(e,t)}))}componentEventRecognizer(t,e){const i=t.target,n=T(i,20);if(!n||!n.classList.contains("chat-tag")||!n.children[0].classList.contains("chat-set-html"))return;const a=n.children[0].children[0],s=a.getAttribute("data-set-component");if(!s)return;const l=this.components[s];if(!l)return;const o=l.methods,r=this.deppComponentEvent(a,e).reverse();let c=!1,h=0;const d=()=>{if(c)return;const n=r[h];if(i===n||n.contains(i)){const i=n.getAttribute("bind-"+e),s=Object.create(null);for(const t in a.dataset)t in l.props&&(s[t]=a.dataset[t]);const r={componentElm:a,targetElm:n,data:s,eventType:e,eventName:i,stopPropagation:()=>{c=!0}};o[i]&&o[i](r,t)}h<r.length-1&&(h++,d())};d()}deppComponentEvent(t,e){const i=[];return t.getAttribute("bind-"+e)&&i.push(t),t.children&&t.children.length>0&&Array.from(t.children).forEach(t=>{i.push(...this.deppComponentEvent(t,e))}),i}async insertComponent(t,e){const i=this.components[t];if(!i)return;const n=Object.assign({},i.props,e),a=b(i.template,{...n,[u]:i.name}),s=await this.target.insertHtml(a);return await this.target.chatEvent.richTextInput(),s}async removeComponentElm(t){const e=T(t,20);e&&(this.target.chatInput.delTag(e),await this.target.chatEvent.richTextInput())}async updateComponentElm(t,e){var i,n;const a=T(t,20);if(!a)return;const s=null==(n=null==(i=null==a?void 0:a.children[0])?void 0:i.children[0])?void 0:n.getAttribute("data-set-component");if(!s)return;const l=this.components[s];if(!l)return;const o=Object.assign({},l.props,e);a.children[0].innerHTML=b(l.template,{...o,[u]:l.name}),await this.target.chatEvent.richTextInput()}getComponentElms(t){const e=[],i=this.target.chatElement.richText.querySelectorAll(".chat-tag");return Array.from(i,i=>{this.isComponentElm(i,t)&&e.push(i)}),e}isComponentElm(t,e){return!!(t&&t.children[0]&&t.children[0].children[0])&&t.children[0].children[0].getAttribute("data-set-component")===e}}const H={device:"auto",autoFocus:!0,needDialog:!0,needDebounce:!0,asyncMatch:!1,userList:[],reformList:[],placeholder:"",maxLength:-1,copyType:["text"],uploadImage:void 0,needCallEvery:!0,needCallSpace:!1,userProps:{},customTrigger:[],dialogLabels:{pcPointDialog:{},pcPCheckDialog:{},h5Dialog:{}},wrapKeyFun:t=>t.ctrlKey&&["Enter"].includes(t.key),sendKeyFun:t=>!t.ctrlKey&&["Enter"].includes(t.key)},V={id:"id",name:"name",avatar:"avatar",pinyin:"pinyin"},$={title:"群成员",callEveryLabel:"所有人",checkLabel:"多选",emptyLabel:"暂无数据"},B={title:"选择要@的人",searchPlaceholder:"搜素人员名称",searchEmptyLabel:"没有匹配到任何结果",userTagTitle:"研讨成员列表",checkAllLabel:"全选",checkEmptyLabel:"请选择需要@的成员",confirmLabel:"确定",cancelLabel:"取消"},Y={title:"选择提醒的人",callEveryLabel:"所有人",searchPlaceholder:"搜素人员名称",searchEmptyLabel:"没有匹配到任何结果",confirmLabel:"确定",cancelLabel:"收起"},U={saveTagData:!1,needUserId:!1,needTagId:!1,needSelectId:!1,needTipKey:!1,wrapClassName:void 0,rowClassName:void 0,imgToText:!1,identifyLink:!1},F={"`":["`","~"],"~":["`","~"],1:["1","!"],"!":["1","!"],3:["3","#"],"#":["3","#"],4:["4","$"],$:["4","$"],5:["5","%"],"%":["5","%"],6:["6","^"],"^":["6","^"],7:["7","&"],"&":["7","&"],8:["8","*"],"*":["8","*"],";":[";",":"],":":[";",":"],"/":["/","?"],"?":["/","?"],"\\":["\\","|"],"|":["\\","|"]},G=function(t,e,i){return t.forEach(t=>{if(i in t){const n=e.indexOf(String(t[i]));-1!==n&&(e[n]=t)}}),e.filter(t=>t[i])};class W{constructor(t){switch(a(this,"options"),a(this,"deviceInfo",function(){if("undefined"==typeof navigator)return{isTablet:!1,isPhone:!1,isAndroid:!1,isIOS:!1,isPc:!0,isIPhone:!1,isIPad:!1,isWindows:!1,isMacOS:!1,isLinux:!1,isWechat:!1,isMobile:!1};const t=navigator.userAgent.toLowerCase(),e=t.includes("windows"),i=t.includes("macintosh"),n=t.includes("linux")&&!t.includes("android"),a=t.includes("android"),s=/iphone|ipad|ipod/.test(t),l=t.includes("iphone"),o=t.includes("ipad")||t.includes("macintosh")&&navigator.maxTouchPoints>1,r=t.includes("micromessenger"),c=o||a&&!/mobile/.test(t)||t.includes("firefox")&&t.includes("tablet")||t.includes("playbook"),h=l&&!c||a&&/mobile/.test(t)||t.includes("windows phone");return{isTablet:c,isPhone:h,isAndroid:a,isIOS:s,isPc:!h&&!c&&(e||i||n),isIPhone:l,isIPad:o,isWindows:e,isMacOS:i,isLinux:n,isWechat:r,isMobile:h||c}}()),a(this,"chatElement"),a(this,"chatInput"),a(this,"chatEvent"),this.options=Object.assign({},H,t),this.options.device=this.options.device.toLocaleLowerCase(),this.deviceInfo.isTablet&&(this.deviceInfo.isPc=!1),this.options.device){case"pc":this.deviceInfo.isPc=!0;break;case"h5":this.deviceInfo.isPc=!1}this.options.userProps=Object.assign({},V,t.userProps||{}),this.options.dialogLabels.pcPointDialog=Object.assign({},$,C(t.dialogLabels,"pcPointDialog",{})),this.options.dialogLabels.pcPCheckDialog=Object.assign({},B,C(t.dialogLabels,"pcPCheckDialog",{})),this.options.dialogLabels.h5Dialog=Object.assign({},Y,C(t.dialogLabels,"h5Dialog",{})),this.chatElement=new O(this),this.chatInput=new R(this),this.chatEvent=new _(this),this.updateConfig(t);const e=this;Object.defineProperty(this,"richText",{get:()=>e.chatElement.richText}),Object.defineProperty(this,"textLength",{get:()=>e.chatEvent.textLength}),this.options.autoFocus&&this.nextTick(()=>{this.chatElement.richText.focus()})}updateConfig(t){void 0!==t.copyType&&(this.options.copyType=t.copyType),t.userProps&&(this.options.userProps=Object.assign({},V,t.userProps)),void 0!==t.uploadImage&&(this.options.uploadImage=t.uploadImage),void 0!==t.placeholder&&(this.chatElement.placeholderElm.textContent=t.placeholder),void 0!==t.maxLength&&(this.options.maxLength=t.maxLength<=0?-1:t.maxLength,this.chatEvent.ruleMaxLength()),this.options.asyncMatch?(this.options.needCallEvery=!1,this.updateUserList([])):(void 0!==t.needCallEvery||t.userList)&&(this.options.needCallEvery=v(void 0===t.needCallEvery?this.options.needCallEvery:t.needCallEvery),this.updateUserList(t.userList)),void 0!==t.needCallSpace&&this.chatInput.setCallSpace(v(t.needCallSpace)),void 0!==t.wrapKeyFun&&(this.options.wrapKeyFun=t.wrapKeyFun),void 0!==t.sendKeyFun&&(this.options.sendKeyFun=t.sendKeyFun),t.customTrigger&&(this.options.customTrigger=t.customTrigger.map(t=>(t.keyMap||(t.keyMap=F[t.prefix]||[]),t)),this.options.needDialog&&this.deviceInfo.isPc&&this.chatElement.bindCustomTrigger()),t.selectList&&(this.options.selectList=t.selectList,this.options.needDialog&&this.deviceInfo.isPc&&this.chatElement.bindSelectList())}updateUserList(t){const{options:e,chatElement:i}=this;if(t){e.userList=JSON.parse(JSON.stringify(t));const i={[e.userProps.id]:"isALL",[e.userProps.name]:""};e.userList.unshift(i),e.reformList=t.map(t=>({id:String(t[e.userProps.id]),name:String(t[e.userProps.name]||""),avatar:String(t[e.userProps.avatar]||""),pinyin:String(t[e.userProps.pinyin]||"")}))}const n=e.userList[0];n&&"isALL"===n[e.userProps.id]&&(n[e.userProps.name]=this.deviceInfo.isPc?e.dialogLabels.pcPointDialog.callEveryLabel:e.dialogLabels.h5Dialog.callEveryLabel),e.needDialog&&(this.deviceInfo.isPc?i.updatePCUser():i.updateH5User())}searchUserList(t){return this.options.reformList.filter(e=>S(e.name,e.pinyin||"",t))}getReduceNode(t){const e=Object.assign({},U,t||{});e.saveTagData&&(e.needUserId=!0,e.needTagId=!0,e.needSelectId=!0,e.needTipKey=!0);const i=/(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g,n=this.chatElement.richText.cloneNode(!0).children||[],a=document.createElement("div");return e.wrapClassName&&(a.className=e.wrapClassName),Array.from(n,(t,n)=>{const s=document.createElement("p");Array.from(t.children,t=>{const n=t.children[0];this.chatInput.getNodeEmpty(n)||(n.removeAttribute("data-set-richType"),n.removeAttribute("contenteditable"),n.removeAttribute("data-set-empty"),e.needUserId||n.removeAttribute("data-user-id"),e.needTagId||(n.removeAttribute("data-set-prefix"),n.removeAttribute("data-tag-id")),e.needSelectId||(n.removeAttribute("data-select-id"),n.removeAttribute("data-select-key")),e.imgToText&&n.firstChild&&"IMG"===n.firstChild.tagName&&(n.classList.add("img-to-text"),n.innerHTML=`[${n.firstChild.getAttribute("data-img-text")||"you need set data-img-text"}]`),e.identifyLink&&n.classList.contains("chat-grid-input")&&(n.innerHTML=n.innerHTML.replace(i,t=>`<a class="chat-grid-link" href="${t}" target="_blank">${t}</a>`)),n.classList.contains("at-select")&&(n.classList.remove("aim"),n.removeChild(n.lastChild)),n.classList.contains("at-input")&&(e.needTipKey?n.setAttribute("data-input-tip",n.children[1].textContent):n.removeAttribute("data-input-key"),n.textContent=n.children[0].textContent!==this.chatInput.VOID_KEY?n.children[0].textContent:n.children[1].textContent,n.textContent=n.textContent.replace(new RegExp(this.chatInput.INPUT_TAG_WRAP_KEY[0],"g"),"")),s.appendChild(n))}),e.rowClassName&&(s.className=e.rowClassName),s.innerHTML||(s.innerHTML="<br>"),a.appendChild(s)}),a}getText(t){let e="";const i=this.getReduceNode(t);return Array.from(i.children,(t,i)=>{e=e+(i>0?"\n":"")+t.textContent}),e}getHtml(t){return this.getReduceNode(t).innerHTML}async reverseAnalysis(t,e){if(!t)return;const i=document.createElement("div");i.innerHTML=t;const n=i.children;Array.from(n,t=>{t.className="chat-grid-wrap",t.setAttribute("data-set-richType",c);const e=t.children,i={},n=[];Array.from(e,(a,s)=>{if(-1!==a.className.indexOf("chat-grid-input")){const t=a.textContent||"";return a.hasAttribute("class")&&a.removeAttribute("class"),a.setAttribute("data-set-richType",h),void(a.innerHTML=`<span class="chat-grid-input" data-set-richType="${d}" data-set-empty="false">${I(t)}</span>`)}if(a.tagName&&"BR"===a.tagName.toLocaleUpperCase()){const e=this.chatInput.getGridElm(!0);return t.removeChild(a),void t.appendChild(e)}const l=a.cloneNode(!0);l.setAttribute("contenteditable","false");const o=document.createElement("span");o.className="chat-tag",o.setAttribute("contenteditable","false"),o.setAttribute("data-set-richType",p),o.appendChild(l),i[s]=o,s!==e.length-1?-1===e[s+1].className.indexOf("chat-grid-input")&&n.push(s):n.push(s),0===s&&n.push(-1)});for(const l in i){const n=Number(l),a=i[l].lastChild;if(a.classList.contains("at-select"))a.innerHTML=`${I(a.textContent)}${E}`;else if(a.classList.contains("at-input")){const t=I(a.getAttribute("data-input-tip")),e=I((a.textContent||"").replace(new RegExp(this.chatInput.INPUT_TAG_WRAP_KEY[1],"g"),this.chatInput.INPUT_TAG_WRAP_KEY)),i=""===a.textContent,n=i?`<span class="input-tip">${t}</span>`:`<span class="input-tip chat-view-hidden" style="display: none">${t}</span>`;a.innerHTML=`<span class="input-write" contenteditable="true">${i?this.chatInput.VOID_KEY:e}</span>${n}`,a.removeAttribute("data-input-tip")}n===e.length-1?(t.removeChild(e[n]),t.appendChild(i[l])):(t.insertBefore(i[l],e[n+1]),t.removeChild(e[n]))}const a=[],s=t.children;n.forEach(t=>{t===s.length-1?a.push("isEnd"):a.push(s[t+1])}),a.forEach(e=>{const i=this.chatInput.getGridElm(!0);if("isEnd"===e)t.appendChild(i);else{const n=i.children[0];n.childNodes.length>1&&n.removeChild(n.childNodes[1]),t.insertBefore(i,e)}})}),e?(this.chatInput.setRangeLastText(),await this.chatEvent.insertInsideHtml(i.innerHTML,!1)):(this.chatElement.richText.innerHTML=i.innerHTML,this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput())}async insertHtml(t){if(!t)return;const e=document.createElement("span");e.innerHTML=t,e.className="chat-set-html";const i=this.chatInput.createNewDom(e);return this.chatInput.replaceRegContent(i,!1),await this.chatEvent.richTextInput(),i}async insertText(t){if(!t)return;t=I(t);const e=new RegExp(`[${this.chatInput.ZERO_WIDTH_KEY}|${this.chatInput.VOID_KEY}]`,"ig"),i=t.replace(e,"");if(!i)return;const n=i.split("\n");let a="";n.forEach(t=>{const e=""!==t;a+=`<p class="chat-grid-wrap" data-set-richType="${c}"><span data-set-richType="${h}"><span class="chat-grid-input" data-set-richType="${d}" data-set-empty="${e?"false":"true"}">${e?t:this.chatInput.VOID_KEY+"<br>"}</span></span></p>`}),await this.chatEvent.insertInsideHtml(a)}getCallUserList(){const t=this.chatElement.richText.querySelectorAll(".at-user");if(t&&t.length>0){const e=Array.from(t,t=>t.dataset.userId);return G(this.options.userList,e,this.options.userProps.id)}return[]}getCallUserTagList(){const t=this.chatElement.richText.querySelectorAll(".at-user");if(t&&t.length>0){const e=[];return Array.from(t,t=>{e.some(e=>e[this.options.userProps.id]===t.dataset.userId)||e.push({[this.options.userProps.id]:t.dataset.userId,[this.options.userProps.name]:t.textContent.slice(1)})}),e}return[]}getCustomTagList(){const t=Object.keys(this.chatElement.customTags),e={},i=this.chatElement.richText.querySelectorAll(".at-tag");return t.forEach(t=>{let n=Array.prototype.filter.call(i,e=>e.getAttribute("data-set-prefix")===String(t)).map(t=>t.getAttribute("data-tag-id"));n=n.filter((t,e)=>n.indexOf(t)===e),e[t]=G(this.chatElement.customTags[t],n,"id")}),e}getSelectTagList(){const t=Object.keys(this.chatElement.selectTags),e={},i=this.chatElement.richText.querySelectorAll(".at-select");return t.forEach(t=>{let n=Array.prototype.filter.call(i,e=>e.getAttribute("data-select-key")===String(t)).map(t=>t.getAttribute("data-select-id"));n=n.filter((t,e)=>n.indexOf(t)===e),e[t]=G(this.chatElement.selectTags[t],n,"id")}),e}getInputTagList(){const t={},e=this.chatElement.richText.querySelectorAll(".at-input");return Array.from(e,e=>{const i=e.getAttribute("data-input-key"),n=e.children[0].textContent===this.chatInput.VOID_KEY?null:e.children[0].textContent;t[i]||(t[i]=[]),t[i].push(n)}),t}async clear(t){this.chatInput.initEditor(!0,t),this.clearHistory(),await this.chatEvent.richTextInput(!1)}lineBreak(){this.cursorToLastRecord(),"inputTag"===this.chatInput.lastCursorType?this.chatInput.setInputTagWrap(this.chatInput.inputTag_vnode.parentElement):this.chatInput.setWrap(!0)}isEmpty(t=!1){if(0===this.chatElement.richText.children.length)return!0;if(-1!==this.chatElement.richText.innerHTML.indexOf("chat-tag"))return!1;if(1===this.chatElement.richText.children.length){const t=this.chatElement.richText.children[0],e=t.children[0].children[0];if(1===t.children.length&&(0===e.textContent.length||e.textContent===this.chatInput.VOID_KEY))return!0}return!!t&&""===this.chatElement.richText.textContent.trim()}dispose(){if(this.options.elm.removeChild(this.chatElement.richText),this.options.elm.removeChild(this.chatElement.placeholderElm),this.options.needDialog)if(this.deviceInfo.isPc){const t=this.chatElement.pcElms.containerDialogElm.parentElement;t&&t.removeChild(this.chatElement.pcElms.containerDialogElm)}else document.body.removeChild(this.chatElement.h5Elms.dialogElm)}showPCPointDialog(){this.options.needDialog&&(this.insertText("@"),this.options.asyncMatch&&s(this.chatElement.pcElms.pointDialogEmptyElm,!0,"flex"),this.chatEvent.outerApply=!0,this.chatElement.showPointDialog(),f(50).then(()=>{this.chatEvent.outerApply=!1}))}showPCCheckDialog(){this.options.needDialog&&!this.options.asyncMatch&&(this.chatEvent.winClick(),this.chatElement.checkboxRows=[],s(this.chatElement.pcElms.checkDialogElm,!0),o(document.body,"disable-scroll",!0),this.chatElement.pcElms.checkDialogTagsElm.scrollTop=0,this.chatElement.pcElms.checkDialogUsersElm.scrollTop=0,this.chatElement.pcElms.checkDialogSearchInputElm.value="",this.chatElement.updateCheckDialogTags(),this.chatElement.isExternalCallPopup=!0)}showPCCustomTagDialog(t){this.options.needDialog&&!this.options.asyncMatch&&(this.insertText(t),this.chatEvent.outerApply=!0,this.chatElement.showCustomTagDialog(t),f(50).then(()=>{this.chatEvent.outerApply=!1}))}showPCSelectDialog(t,e){this.chatElement.exitCustomTagDialog(),this.chatElement.exitPointDialog(),this.chatEvent.outerApply=!0,e&&(this.chatElement.exitSelectDialog(),this.chatElement.pcElms.selectDialogAim=e),this.chatElement.pcElms.selectDialogKey=t,this.chatEvent.debounceEvents.selectDialogToAim(),f(50).then(()=>{this.chatEvent.outerApply=!1})}showH5Dialog(){this.chatElement.richText&&this.chatElement.richText.blur(),Array.from(this.chatElement.h5Elms.dialogMainElm.children,t=>{t.style.display="",o(t,"user-popup-check-item-check")}),o(this.chatElement.h5Elms.dialogCheckElm,"disabled",!0),s(this.chatElement.h5Elms.dialogElm,!0),o(document.body,"disable-scroll",!0),this.options.asyncMatch&&s(this.chatElement.h5Elms.dialogEmptyElm,!0,"flex"),this.chatElement.h5Elms.dialogMainElm.scrollTop=0,this.chatElement.isExternalCallPopup=!0}disabled(){this.chatElement.richText.setAttribute("contenteditable","false"),o(this.chatElement.richText,"chat-rich-text-disabled",!0)}enable(){this.chatElement.richText.setAttribute("contenteditable","true"),o(this.chatElement.richText,"chat-rich-text-disabled"),this.chatInput.setRangeLastText()}async setUserTag(t){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("atCheck",[t]);const e=this.chatInput.createChatTagElm({id:t[this.options.userProps.id],name:t[this.options.userProps.name]},"@","at-user","user-id");this.chatInput.replaceRegContent(e,!1),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",[t])}async setCustomTag(t,e){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("tagCheck",t,e),await this.chatInput.onceCustomCall(t,!1,e),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterTagCheck",t,e)}async setSelectTag(t,e){if(this.chatInput.updateNodeCursor(),e||(e=this.chatElement.pcElms.selectDialogKey),this.chatEvent.triggerChatEvent("selectCheck",t,e),this.chatElement.pcElms.selectDialogAim&&this.chatElement.pcElms.selectDialogAim.classList.contains("at-select")){const e=this.chatElement.pcElms.selectDialogAim.getAttribute("data-select-id"),i=this.chatElement.pcElms.selectDialogAim.parentElement.nextElementSibling.childNodes[0].childNodes[0];if(this.chatInput.restCursorPos(i),e===t.id)return;this.chatElement.pcElms.selectDialogAim.setAttribute("data-select-id",t.id),this.chatElement.pcElms.selectDialogAim.childNodes[0].textContent=t.name}else{const i=document.createElement("span");i.setAttribute("class","at-select"),i.setAttribute("data-select-key",e),i.setAttribute("data-select-id",t.id),i.innerHTML=`${I(t.name)}${E}`;const n=this.chatInput.createNewDom(i);this.chatInput.replaceRegContent(n,!1)}await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterSelectCheck",t,e)}async setInputTag(t,e,i=""){this.chatInput.updateNodeCursor();const n=document.createElement("span");n.setAttribute("class","at-input"),n.setAttribute("contenteditable","false"),n.setAttribute("data-input-key",t);const a=document.createElement("span");a.setAttribute("class","input-write"),a.setAttribute("contenteditable","true"),a.textContent=i||this.chatInput.VOID_KEY;const s=document.createElement("span");s.setAttribute("class","input-tip"),s.textContent="["+(e||"Please input")+"]",n.appendChild(a),n.appendChild(s);const l=this.chatInput.createNewDom(n);this.chatInput.replaceRegContent(l,!1),i&&this.chatInput.watchInputTag(a),this.chatInput.rangeToInputTag(n),await this.chatEvent.richTextInput()}async matchSetTag(t){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("atCheck",[t]),await this.chatInput.onceSearchCall(t,this.chatEvent.startOpenIndex),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",[t])}async onceSetTag(t){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("atCheck",[t]),await this.chatInput.onceCall({id:t[this.options.userProps.id],name:t[this.options.userProps.name]}),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",[t])}async batchSetTag(t){this.chatInput.updateNodeCursor(),this.chatEvent.triggerChatEvent("atCheck",t);const e=[];for(let i=0;i<=t.length-1;)e.push({id:t[i][this.options.userProps.id],name:t[i][this.options.userProps.name]}),i++;await this.chatInput.batchReplaceRegContent(e,!this.chatElement.isExternalCallPopup),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterAtCheck",t)}async onceSetCustomTag(t,e){this.chatInput.updateNodeCursor(),e||(e=this.chatElement.pcElms.customTagDialogTagKey),this.chatEvent.triggerChatEvent("tagCheck",t,e),await this.chatInput.onceCustomCall(t,!0,e),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterTagCheck",t,e)}async matchSetCustomTag(t,e){this.chatInput.updateNodeCursor(),e||(e=this.chatElement.pcElms.customTagDialogTagKey),this.chatEvent.triggerChatEvent("tagCheck",t,e),await this.chatInput.onceCustomCall(t,this.chatEvent.startOpenIndex,e),await this.chatEvent.richTextInput(),this.chatEvent.triggerChatEvent("afterTagCheck",e)}async undo(){const{chatEvent:t}=this;if(!t.doOverHistory||!t.undoHistory||t.undoHistory.length<=1)return;const e=t.undoHistory[t.undoHistory.length-2],i=t.undoHistory[t.undoHistory.length-1];t.redoHistory.push(i),t.undoHistory.pop(),await t.setChatHistory(e)}async redo(){const{chatEvent:t}=this;if(!t.doOverHistory||!t.redoHistory||t.redoHistory.length<1)return;const e=t.redoHistory[t.redoHistory.length-1];t.redoHistory.pop(),t.undoHistory.push(e),await t.setChatHistory(e)}clearHistory(){const{gridIndex:t,markIndex:e,tagIndex:i}=this.chatInput.getRichTextNodeIndex();this.chatEvent.undoHistory=[{html:this.chatElement.richText.innerHTML,gridIndex:t||0,markIndex:e||0,tagIndex:i||0,type:this.chatInput.lastCursorType,cursorIndex:this.chatInput.cursorIndex,inputTag_cursorIndex:this.chatInput.inputTag_cursorIndex}],this.chatEvent.redoHistory=[]}cursorMove(t){if(0===t)return void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const e=new RegExp(`[${this.chatInput.ZERO_WIDTH_KEY}|${this.chatInput.VOID_KEY}]`,"ig");if(t>0){const i=this.chatInput.vnode.textContent.replace(e,"").slice(this.chatInput.cursorIndex);if(i.length>=t)return this.chatInput.cursorIndex+=t,void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const n=this.chatInput.vnode.parentElement.parentElement,a=n.parentElement;let s=Boolean(n.nextElementSibling&&n.nextElementSibling.nextElementSibling);const l=Boolean(a.nextElementSibling);if(!s&&!l)return this.chatInput.cursorIndex+=i.length,0===this.chatInput.cursorIndex&&(this.chatInput.cursorIndex=1),void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const o=t-i.length-1,r=s?n.nextElementSibling.nextElementSibling:a.nextElementSibling.children[0],{rangeNode:c,rangeIndex:h}=this.chatInput.getOffsetRange(o,r);this.chatInput.restCursorPos(c,h)}else if(t<0){let i=Math.abs(t);const n=this.chatInput.vnode.textContent.replace(e,"").slice(0,this.chatInput.cursorIndex);if(n.length>=i)return this.chatInput.cursorIndex-=i,void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const a=this.chatInput.vnode.parentElement.parentElement,s=a.parentElement,l=Boolean(a.previousElementSibling&&a.previousElementSibling.previousElementSibling),o=Boolean(s.previousElementSibling);if(!l&&!o)return void this.chatInput.restCursorPos(this.chatInput.vnode);i=i-n.length-1;const r=l?a.previousElementSibling.previousElementSibling:s.previousElementSibling.lastElementChild,{rangeNode:c,rangeIndex:h}=this.chatInput.getOffsetRange(i,r,!0);this.chatInput.restCursorPos(c,h)}}async cursorDel(t){if(0===t)return void this.chatInput.restCursorPos(this.chatInput.vnode,this.chatInput.cursorIndex);const e=this.chatInput.vnode,i=this.chatInput.cursorIndex;this.cursorMove(t);const n=this.chatInput.vnode,a=this.chatInput.cursorIndex,s=document.createRange();t<0?(s.setStart(n,a),s.setEnd(e,i)):(s.setStart(e,i),s.setEnd(n,a));const l=this.getSelection();l.removeAllRanges(),l.addRange(s),await this.chatEvent.removeRange()}cursorToLastRecord(){this.chatInput.setRangeLastRecord()}async delUserTags(t){const e=t||this.options.userList.map(t=>t[this.options.userProps.id]),i=this.chatElement.richText.querySelectorAll(".at-user"),n=[];Array.from(i,t=>{const i=t.getAttribute("data-user-id");e.some(t=>String(t)===i)&&n.push(t.parentElement)});for(let a=0;a<n.length;){const t=n[a];this.chatInput.delTag(t),a++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}async delCustomTags(t,e){const i=this.options.customTrigger.find(e=>e.prefix===t);if(!i||0===i.tagList.length)return;const n=e||i.tagList.map(t=>t.id),a=this.chatElement.richText.querySelectorAll(".at-tag"),s=[];Array.from(a,e=>{const i=e.getAttribute("data-set-prefix"),a=e.getAttribute("data-tag-id");i===t&&n.some(t=>String(t)===a)&&s.push(e.parentElement)});for(let l=0;l<s.length;){const t=s[l];this.chatInput.delTag(t),l++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}async delSelectTags(t,e){const i=this.options.selectList.find(e=>e.key===t);if(!i||0===i.options.length)return;const n=e||i.options.map(t=>t.id),a=this.chatElement.richText.querySelectorAll(".at-select"),s=[];Array.from(a,e=>{const i=e.getAttribute("data-select-key"),a=e.getAttribute("data-select-id");i===t&&n.some(t=>String(t)===a)&&s.push(e.parentElement)});for(let l=0;l<s.length;){const t=s[l];this.chatInput.delTag(t),l++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}async delInputTags(t){const e=this.chatElement.richText.querySelectorAll(".at-input"),i=[];Array.from(e,e=>{if(t){const n=e.getAttribute("data-input-key");t.some(t=>String(t)===n)&&i.push(e.parentElement)}else i.push(e.parentElement)});for(let n=0;n<i.length;){const t=i[n];this.chatInput.delTag(t),n++}this.chatInput.setRangeLastText(),await this.chatEvent.richTextInput()}openTipTag(t){this.chatElement.createTipElm(t),this.cursorToLastRecord()}openCustomTipTag(t){const e=this.chatElement.createCustomTipElm(t);return this.cursorToLastRecord(),e}closeTipTag(){this.chatElement.tipElm&&this.chatElement.removeTipElm()}addEventListener(t,e){this.chatEvent.chatEventModule[t].push(e)}removeEventListener(t,e){const i=this.chatEvent.chatEventModule[t],n=i.indexOf(e);-1!==n&&i.splice(n,1)}revisePCPointDialogLabel(t){this.options.needDialog&&(this.options.dialogLabels.pcPointDialog=Object.assign({},$,t||{}),this.chatElement.pcElms.pointDialogElm.querySelector(".call-user-dialog-header-title").textContent=this.options.dialogLabels.pcPointDialog.title,this.chatElement.pcElms.pointDialogCheckElm.textContent=this.options.dialogLabels.pcPointDialog.checkLabel,this.chatElement.pcElms.pointDialogEmptyElm&&(this.chatElement.pcElms.pointDialogEmptyElm.children[1].textContent=this.options.dialogLabels.pcPointDialog.emptyLabel),this.options.asyncMatch||this.updateUserList())}revisePCCheckDialogLabel(t){this.options.needDialog&&!this.options.asyncMatch&&(this.options.dialogLabels.pcPCheckDialog=Object.assign({},B,t||{}),this.chatElement.pcElms.checkDialogElm.querySelector(".checkbox-dialog-container-header").children[0].textContent=this.options.dialogLabels.pcPCheckDialog.title,this.chatElement.pcElms.checkDialogSearchInputElm.setAttribute("placeholder",this.options.dialogLabels.pcPCheckDialog.searchPlaceholder),this.chatElement.pcElms.checkDialogElm.querySelector(".checkbox-dialog-search-empty").textContent=this.options.dialogLabels.pcPCheckDialog.searchEmptyLabel,this.chatElement.pcElms.checkDialogElm.querySelector(".checkbox-dialog-right-box-title").textContent=this.options.dialogLabels.pcPCheckDialog.userTagTitle,this.chatElement.pcElms.checkDialogUsersElm.children[0].children[2].textContent=this.options.dialogLabels.pcPCheckDialog.checkAllLabel,this.chatElement.pcElms.checkDialogElm.querySelector(".btn-submit").textContent=this.options.dialogLabels.pcPCheckDialog.confirmLabel,this.chatElement.pcElms.checkDialogElm.querySelector(".btn-close").textContent=this.options.dialogLabels.pcPCheckDialog.cancelLabel)}reviseH5DialogLabel(t){this.options.needDialog&&(this.options.dialogLabels.h5Dialog=Object.assign({},Y,t||{}),this.chatElement.h5Elms.dialogElm.querySelector(".popup-title").textContent=this.options.dialogLabels.h5Dialog.title,this.chatElement.h5Elms.dialogSearchElm.setAttribute("placeholder",this.options.dialogLabels.h5Dialog.searchPlaceholder),this.chatElement.h5Elms.dialogEmptyElm.children[1].textContent=this.options.dialogLabels.h5Dialog.searchEmptyLabel,this.chatElement.h5Elms.dialogCheckElm.textContent=this.options.dialogLabels.h5Dialog.confirmLabel,this.chatElement.h5Elms.dialogShowElm.textContent=this.options.dialogLabels.h5Dialog.cancelLabel,this.options.asyncMatch||this.updateUserList())}async nextTick(t){return new Promise(e=>{requestAnimationFrame(()=>{const i=t();i instanceof Promise?i.then(()=>{e()}):e()})})}getSelection(){return window.getSelection()}createOperateNode(){return new M(this)}createChatComponent(){return new K(this)}}a(W,"version","6.0.6");
2
+ /*! Element Plus Icons Vue v2.3.2 */
3
+ var z=t.defineComponent({name:"Brush",__name:"brush",setup:e=>(e,i)=>(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{fill:"currentColor",d:"M896 448H128v192a64 64 0 0 0 64 64h192v192h256V704h192a64 64 0 0 0 64-64zm-770.752-64c0-47.552 5.248-90.24 15.552-128 14.72-54.016 42.496-107.392 83.2-160h417.28l-15.36 70.336L736 96h211.2c-24.832 42.88-41.92 96.256-51.2 160a664 664 0 0 0-6.144 128H960v256a128 128 0 0 1-128 128H704v160a32 32 0 0 1-32 32H352a32 32 0 0 1-32-32V768H192A128 128 0 0 1 64 640V384zm64 0h636.544c-2.048-45.824.256-91.584 6.848-137.216 4.48-30.848 10.688-59.776 18.688-86.784h-96.64l-221.12 141.248L561.92 160H256.512c-25.856 37.888-43.776 75.456-53.952 112.832-8.768 32.064-13.248 69.12-13.312 111.168"})]))}),q=t.defineComponent({name:"Paperclip",__name:"paperclip",setup:e=>(e,i)=>(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{fill:"currentColor",d:"M602.496 240.448A192 192 0 1 1 874.048 512l-316.8 316.8A256 256 0 0 1 195.2 466.752L602.496 59.456l45.248 45.248L240.448 512A192 192 0 0 0 512 783.552l316.8-316.8a128 128 0 1 0-181.056-181.056L353.6 579.904a32 32 0 1 0 45.248 45.248l294.144-294.144 45.312 45.248L444.096 670.4a96 96 0 1 1-135.744-135.744z"})]))}),j=t.defineComponent({name:"Top",__name:"top",setup:e=>(e,i)=>(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{fill:"currentColor",d:"M572.235 205.282v600.365a30.118 30.118 0 1 1-60.235 0V205.282L292.382 438.633a28.913 28.913 0 0 1-42.646 0 33.43 33.43 0 0 1 0-45.236l271.058-288.045a28.913 28.913 0 0 1 42.647 0L834.5 393.397a33.43 33.43 0 0 1 0 45.176 28.913 28.913 0 0 1-42.647 0l-219.618-233.23z"})]))});const X={class:"el-send-button"},Z=(t,e)=>{const i=t.__vccOpts||t;for(const[n,a]of e)i[n]=a;return i},J=Z(t.defineComponent({__name:"index",props:{disabled:{type:Boolean,default:!1}},emits:["clear"],setup(e,{emit:i}){const n=e,a=i;return(e,i)=>{const s=t.resolveComponent("el-icon"),l=t.resolveComponent("el-button");return t.openBlock(),t.createElementBlock("div",X,[t.createVNode(l,{circle:"",disabled:n.disabled,onClick:i[0]||(i[0]=t=>a("clear"))},{default:t.withCtx(()=>[t.createVNode(s,null,{default:t.withCtx(()=>[t.createVNode(t.unref(z))]),_:1})]),_:1},8,["disabled"])])}}}),[["__scopeId","data-v-262ae79f"]]),Q={viewBox:"0 0 1000 1000",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"};const tt=Z({},[["render",function(e,i){return t.openBlock(),t.createElementBlock("svg",Q,[...i[0]||(i[0]=[t.createElementVNode("title",null,"Loading",-1),t.createElementVNode("rect",{fill:"currentColor",height:"250",rx:"24",ry:"24",width:"250",x:"375",y:"375"},null,-1),t.createElementVNode("circle",{cx:"500",cy:"500",fill:"none",r:"450",stroke:"currentColor","stroke-width":"100",opacity:"0.45"},null,-1),t.createElementVNode("circle",{cx:"500",cy:"500",fill:"none",r:"450",stroke:"currentColor","stroke-width":"100","stroke-dasharray":"600 9999999"},[t.createElementVNode("animateTransform",{attributeName:"transform",dur:"1s",from:"0 500 500",repeatCount:"indefinite",to:"360 500 500",type:"rotate"})],-1)])])}]]),et={class:"el-send-button"},it=Z(t.defineComponent({__name:"index",emits:["cancel"],setup(e,{emit:i}){const n=i;return(e,i)=>{const a=t.resolveComponent("el-button");return t.openBlock(),t.createElementBlock("div",et,[t.createVNode(a,{circle:"",onClick:i[0]||(i[0]=t=>n("cancel"))},{default:t.withCtx(()=>[t.createVNode(tt,{class:"loading-svg"})]),_:1})])}}}),[["__scopeId","data-v-a09b3fa6"]]),nt={class:"el-send-button"},at=t.defineComponent({__name:"index",props:{disabled:{type:Boolean,default:!1}},emits:["submit"],setup(e,{emit:i}){const n=e,a=i;return(e,i)=>{const s=t.resolveComponent("el-icon"),l=t.resolveComponent("el-button");return t.openBlock(),t.createElementBlock("div",nt,[t.createVNode(l,{circle:"",disabled:n.disabled,onClick:i[0]||(i[0]=t=>a("submit"))},{default:t.withCtx(()=>[t.createVNode(s,null,{default:t.withCtx(()=>[t.createVNode(t.unref(j))]),_:1})]),_:1},8,["disabled"])])}}}),st={key:0,class:"el-editor-sender-header"},lt={class:"el-editor-sender-header-container"},ot={key:0,class:"el-editor-sender-prefix"},rt={key:1,class:"el-editor-sender-active-tag"},ct={key:0,class:"el-editor-sender-action-list"},ht={class:"el-editor-sender-action-list-presets"},dt={key:1,class:"el-editor-sender-updown-action-list"},pt={class:"el-editor-sender-action-list"},gt={class:"el-editor-sender-action-list-presets"},ut={key:0,class:"el-editor-sender-footer"},mt=Z(t.defineComponent({__name:"index",props:{placeholder:{default:"请输入内容"},device:{default:"pc"},autoFocus:{type:Boolean,default:!1},variant:{default:"default"},userList:{default:()=>[]},customTrigger:{default:()=>[]},selectList:{default:()=>[]},maxLength:{default:void 0},submitType:{default:"enter"},customStyle:{default:()=>({})},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},headerAnimationTimer:{default:300},asyncMatchFun:{type:Function,default:void 0},customDialog:{type:Boolean,default:!1},activeTag:{default:null}},emits:["submit","change","cancel","showAtDialog","showSelectDialog","showTagDialog","pasteFile"],setup(e,{expose:i,emit:n}){const a=e,s=n,l=t.getCurrentInstance(),o=t.computed(()=>{var t;return!!(null==(t=null==l?void 0:l.vnode.props)?void 0:t.onPasteFile)}),r=t.ref(),c=t.ref(),h=t.ref(),d=t.reactive({isEmpty:!0,textLength:0,lastFocusNode:null,lastOffset:0,wrapCallSelectDialog:!1,beforeText:"",afterText:""});function p(){return{text:r.value.getText(),html:r.value.getHtml(),inputTags:r.value.getInputTagList(),userTags:a.userList.length>0?r.value.getCallUserTagList():void 0,selectTags:a.selectList.length>0?r.value.getSelectTagList():void 0,customTags:a.customTrigger.length>0?r.value.getCustomTagList():void 0}}function g(){d.isEmpty||s("submit",p())}function u(){s("cancel")}function m(t){r.value.clear(t),f()}function E(){requestAnimationFrame(()=>{var t;const e=null==(t=d.lastFocusNode)?void 0:t.parentElement,i=r.value.chatInput;e&&e.classList.contains("input-write")?i.setInputTagRange(d.lastFocusNode,d.lastOffset):i.restCursorPos(i.vnode,i.cursorIndex)})}function f(){r.value&&c.value&&c.value.setCursorNode(c.value.getNodeByRank(c.value.getRank(-1)+c.value.getRank(-1)))}function v(t){var e,i,n,s,l,o,r,c;const{type:h,value:d,key:p}=t;switch(h){case"userTag":return(null==(i=null==(e=a.userList)?void 0:e.find(t=>t.id===d))?void 0:i.name)||"";case"selectTag":return(null==(l=null==(s=null==(n=a.selectList)?void 0:n.find(t=>t.key===p))?void 0:s.options.find(t=>t.id===d))?void 0:l.name)||"";case"customTag":return(null==(c=null==(r=null==(o=a.customTrigger)?void 0:o.find(t=>t.prefix===p))?void 0:r.tagList.find(t=>t.id===d))?void 0:c.name)||"";default:return""}}function x(){var t;null==(t=r.value)||t.closeTipTag()}function y(t){"Escape"===t.key&&x()}function T(t){var e;const i=null==(e=t.clipboardData)?void 0:e.files;(null==i?void 0:i.length)&&o.value&&(s("pasteFile",i[0],i),t.preventDefault())}return t.watch(()=>a.disabled,()=>{var t,e;a.disabled?null==(t=r.value)||t.disabled():null==(e=r.value)||e.enable()}),t.watch(()=>a.placeholder,()=>{var t;null==(t=r.value)||t.updateConfig({placeholder:a.placeholder})}),t.watch(()=>a.maxLength,()=>{var t;null==(t=r.value)||t.updateConfig({maxLength:a.maxLength})}),t.watch(()=>a.submitType,()=>{var t;null==(t=r.value)||t.updateConfig({sendKeyFun:"enter"===a.submitType?t=>!t.shiftKey&&"Enter"===t.key:t=>t.shiftKey&&"Enter"===t.key,wrapKeyFun:"shiftEnter"===a.submitType?t=>!t.shiftKey&&"Enter"===t.key:t=>t.shiftKey&&"Enter"===t.key})}),t.watch(()=>a.userList,()=>{var t;null==(t=r.value)||t.updateConfig({userList:a.userList})},{deep:!0}),t.watch(()=>a.selectList,()=>{var t;null==(t=r.value)||t.updateConfig({selectList:a.selectList})},{deep:!0}),t.watch(()=>a.customTrigger,()=>{var t;null==(t=r.value)||t.updateConfig({customTrigger:a.customTrigger})},{deep:!0}),t.onMounted(()=>{r.value=new W({elm:h.value,...a,userList:JSON.parse(JSON.stringify(a.userList)),needDialog:!a.customDialog&&"pc"===a.device,copyType:["text"],asyncMatch:Boolean(a.asyncMatchFun),needDebounce:!0,needCallSpace:!1,sendKeyFun:"enter"===a.submitType?t=>!t.shiftKey&&"Enter"===t.key:t=>t.shiftKey&&"Enter"===t.key,wrapKeyFun:"shiftEnter"===a.submitType?t=>!t.shiftKey&&"Enter"===t.key:t=>t.shiftKey&&"Enter"===t.key}),c.value=r.value.createOperateNode(),r.value.addEventListener("enterSend",g),r.value.addEventListener("operate",()=>{d.isEmpty=r.value.isEmpty(!0),d.textLength=r.value.textLength,s("change")}),r.value.richText.addEventListener("blur",()=>{const t=getSelection();d.lastFocusNode=t.focusNode,d.lastOffset=t.focusOffset},!0),r.value.addEventListener("selectCheck",()=>{var t;d.wrapCallSelectDialog&&d.beforeText&&(null==(t=r.value)||t.insertText(d.beforeText),d.beforeText="")}),r.value.addEventListener("afterSelectCheck",()=>{var t;d.wrapCallSelectDialog&&d.afterText&&(null==(t=r.value)||t.insertText(d.afterText),d.afterText="",d.wrapCallSelectDialog=!1)}),a.asyncMatchFun&&r.value.addEventListener("atMatch",a.asyncMatchFun),r.value.addEventListener("showAtDialog",()=>{s("showAtDialog")}),r.value.addEventListener("showSelectDialog",(t,e)=>{s("showSelectDialog",t,e)}),r.value.addEventListener("showTagDialog",t=>{s("showTagDialog",t)}),a.disabled&&r.value.disabled(),window.addEventListener("keydown",y)}),t.onBeforeUnmount(()=>{r.value&&(r.value.dispose(),r.value=void 0,c.value=void 0,window.removeEventListener("keydown",y))}),i({getCurrentValue:p,focusToStart:function(){r.value&&c.value&&c.value.setCursorNode(c.value.getNodeByRank(c.value.getRank(0)+c.value.getRank(0)),0)},focusToEnd:f,blur:function(){if(r.value){getSelection().removeAllRanges(),r.value.richText.blur()}},selectAll:function(){if(r.value&&c.value){const t=c.value.getNodeByRank(c.value.getRank(0)+c.value.getRank(0)),e=c.value.getNodeByRank(c.value.getRank(-1)+c.value.getRank(-1));c.value.setSelectNodes(t,e)}},clear:m,setSelectTag:function(t,e){var i,n,s;d.wrapCallSelectDialog=!1;const l=null==(n=null==(i=a.selectList)?void 0:i.find(e=>e.key===t))?void 0:n.options.find(t=>t.id===e);l&&(null==(s=r.value)||s.setSelectTag(l,t))},setInputTag:function(t,e,i){var n;null==(n=r.value)||n.setInputTag(t,e,i)},setUserTag:function(t){var e,i;const n=null==(e=a.userList)?void 0:e.find(e=>e.id===t);n&&(null==(i=r.value)||i.setUserTag(n))},setCustomTag:function(t,e){var i,n,s;const l=null==(n=null==(i=a.customTrigger)?void 0:i.find(e=>e.prefix===t))?void 0:n.tagList.find(t=>t.id===e);l&&(null==(s=r.value)||s.setCustomTag(l,t))},setMixTags:function(t){var e;const i=t.map((t,e)=>{var i;return{type:"gridBox",rank:null==(i=c.value)?void 0:i.getRank(e),children:t.map(t=>({type:t.type,text:t.value,html:t.value,dataset:{id:t.value,name:v(t),prefix:t.key,key:t.key,placeholder:t.placeholder,value:t.value}}))}});null==(e=c.value)||e.coverNodes(i)},setHtml:function(t){var e;null==(e=r.value)||e.insertHtml(t)},setText:function(t){var e;null==(e=r.value)||e.insertText(t)},openSelectDialog:function(t){var e;d.beforeText=t.beforeText||"",d.afterText=t.afterText||"",d.wrapCallSelectDialog=!0,null==(e=r.value)||e.showPCSelectDialog(t.key,t.elm)},customSetUser:function(t){r.value.onceSetTag(t)},customSetTag:function(t,e){r.value.onceSetCustomTag(e,t)},updateSelectTag:function(t,e){var i,n,a;const s=null==(i=c.value)?void 0:i.getRankByElm(t.parentElement);if(!s)return;const l=null==(n=c.value)?void 0:n.getNodeByRank(s);if(!l)return;const o=l.dataset;o.id=e.id,o.name=e.name,null==(a=c.value)||a.updateNode(l)},openTipTag:function(t){var e;null==(e=r.value)||e.openTipTag({...t,codeLabel:"ESC"})},closeTipTag:x,chat:r,opNode:c,chatState:d}),(i,n)=>(t.openBlock(),t.createElementBlock("div",{class:"el-editor-sender-wrap",style:t.normalizeStyle({"--el-editor-sender-header-duration":`${e.headerAnimationTimer}ms`})},[t.createVNode(t.Transition,{name:"slide"},{default:t.withCtx(()=>[i.$slots.header?(t.openBlock(),t.createElementBlock("div",st,[t.createElementVNode("div",lt,[t.renderSlot(i.$slots,"header",{},void 0,!0)])])):t.createCommentVNode("",!0)]),_:3}),t.createElementVNode("div",{class:t.normalizeClass(["el-editor-sender-content",{"content-variant-updown":"updown"===a.variant}]),onMousedown:E},[t.createElementVNode("div",{class:"el-editor-sender-chat-room",onMousedown:t.withModifiers(()=>{},["stop"])},[i.$slots.prefix?(t.openBlock(),t.createElementBlock("div",ot,[t.renderSlot(i.$slots,"prefix",{},void 0,!0)])):t.createCommentVNode("",!0),a.activeTag?(t.openBlock(),t.createElementBlock("span",rt,t.toDisplayString(a.activeTag.name),1)):t.createCommentVNode("",!0),t.createElementVNode("div",{ref_key:"container",ref:h,style:t.normalizeStyle({...e.customStyle}),class:"el-editor-sender-chat",onPaste:T},null,36)],32),"default"===a.variant?(t.openBlock(),t.createElementBlock("div",ct,[t.renderSlot(i.$slots,"action-list",{},()=>[t.createElementVNode("div",ht,[a.loading?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(at,{key:0,disabled:d.isEmpty||a.disabled,onSubmit:g},null,8,["disabled"])),a.loading?(t.openBlock(),t.createBlock(it,{key:1,onCancel:u})):t.createCommentVNode("",!0),a.clearable?(t.openBlock(),t.createBlock(J,{key:2,disabled:d.isEmpty||a.disabled,onClear:m},null,8,["disabled"])):t.createCommentVNode("",!0)])],!0)])):"updown"===a.variant?(t.openBlock(),t.createElementBlock("div",dt,[t.createElementVNode("div",pt,[t.renderSlot(i.$slots,"action-list",{},()=>[t.createElementVNode("div",gt,[a.loading?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(at,{key:0,disabled:d.isEmpty||a.disabled,onSubmit:g},null,8,["disabled"])),a.loading?(t.openBlock(),t.createBlock(it,{key:1,onCancel:u})):t.createCommentVNode("",!0),a.clearable?(t.openBlock(),t.createBlock(J,{key:2,disabled:d.isEmpty||a.disabled,onClear:m},null,8,["disabled"])):t.createCommentVNode("",!0)])],!0)])])):t.createCommentVNode("",!0)],34),t.createVNode(t.Transition,{name:"slide"},{default:t.withCtx(()=>[i.$slots.footer?(t.openBlock(),t.createElementBlock("div",ut,[t.renderSlot(i.$slots,"footer",{},void 0,!0)])):t.createCommentVNode("",!0)]),_:3})],4))}}),[["__scopeId","data-v-5619e038"]]),Et={viewBox:"0 0 1000 1000",xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink"};const ft=Z({},[["render",function(e,i){return t.openBlock(),t.createElementBlock("svg",Et,[...i[0]||(i[0]=[t.createElementVNode("title",null,"Loading",-1),t.createElementVNode("rect",{fill:"currentColor",height:"250",rx:"24",ry:"24",width:"250",x:"375",y:"375"},null,-1),t.createElementVNode("circle",{cx:"500",cy:"500",fill:"none",r:"450",stroke:"currentColor","stroke-width":"100",opacity:"0.45"},null,-1),t.createElementVNode("circle",{cx:"500",cy:"500",fill:"none",r:"450",stroke:"currentColor","stroke-width":"100","stroke-dasharray":"600 9999999"},[t.createElementVNode("animateTransform",{attributeName:"transform",dur:"1s",from:"0 500 500",repeatCount:"indefinite",to:"360 500 500",type:"rotate"})],-1)])])}]]),vt={class:"el-send-button"},xt=Z(t.defineComponent({__name:"index",emits:["cancel"],setup(e,{emit:i}){const n=i;return(e,i)=>{const a=t.resolveComponent("el-button");return t.openBlock(),t.createElementBlock("div",vt,[t.createVNode(a,{circle:"",onClick:i[0]||(i[0]=t=>n("cancel"))},{default:t.withCtx(()=>[t.createVNode(ft,{class:"loading-svg"})]),_:1})])}}}),[["__scopeId","data-v-460f4bed"]]);const yt=t.defineComponent({props:{loading:{type:Boolean,default:!1},actionUrl:{type:String,default:"/openapi/v1/app/files/upload"},extendData:{type:Object,default:()=>({user:"abc-123"})},acceptFileType:{type:String,default:".txt,.md,.mdx,.markdown,.pdf,.html,.xlsx,.xls,.doc,.docx,.csv,.eml,.msg,.pptx,.ppt,.xml,.epub,.jpg,.jpeg,.png,.gif,.webp,.svg"},headers:{type:Object,default:()=>({Authorization:"Bearer ApiSecretKey_mEKsrCMvxNLzzUUKeQmpzaUZqwZxFyJf",appId:"9a673565-d4f6-4382-bc67-f1beb07df435"})},agentName:{type:String,default:"知识问答智能体"},limit:{type:Number,default:5},customStyle:{type:Object,default:()=>({maxHeight:"75px"})},inputData:{type:String,default:""},placeholder:{type:String,default:"请尝试输入任务、问题或想法,我会帮你搞定"},tagList:{type:Array,default:()=>[{id:"1",name:"问产品"},{id:"2",name:"问品类"},{id:"3",name:"问品牌"},{id:"4",name:"找物料"},{id:"5",name:"问知识"},{id:"6",name:"遇客诉"}]}},emits:["cancel","submit"],setup(n,{emit:a}){const s=t.useTemplateRef("editorSender"),l=t.useTemplateRef("editorSenderWrapper"),o=t.useTemplateRef("fileUpload"),r=t.ref(!0),c=t.ref([]),h=t.ref(n.tagList[0]);t.watch(()=>n.agentName,e=>{t.nextTick(()=>{var t;const i=null==(t=l.value)?void 0:t.querySelector(".el-editor-sender-chat-room");null==i||i.setAttribute("datatype",e)})},{immediate:!0}),t.watch(()=>n.inputData,e=>{t.nextTick(()=>{var t,i;null==(t=s.value)||t.clear(),null==(i=s.value)||i.setText(e)})});const d=()=>{a("cancel")},p=t=>{if(r.value||n.loading)return;const e={text:t.text,file:c.value.map(t=>t.response)};var i,l;a("submit",e),null==(i=s.value)||i.clear(),c.value=[],null==(l=o.value)||l.clearFiles()},g=()=>{i.ElNotification({title:"",message:"上传文件失败",type:"error"})},u=(t,e,i)=>{c.value=i},m=t=>{if(e=t.type,!new Set(["text/plain","text/markdown","application/pdf","text/html","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","message/rfc822","application/vnd.ms-outlook","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.ms-powerpoint","application/xml","text/xml","application/epub+zip","image/jpeg","image/png","image/gif","image/webp","image/svg+xml"]).has(null==e?void 0:e.trim().toLowerCase()))return i.ElNotification({title:"",message:"无法解析上传",type:"warning"}),!1;var e;const n=t.type.includes("image"),a=!n,s=t.size/1024/1024<15,l=t.size/1024/1024<10;return a&&!s?(i.ElNotification({title:"",message:"上传文档大小不能超过 15MB!",type:"warning"}),!1):!(n&&!l)||(i.ElNotification({title:"",message:"上传图片大小不能超过 10MB!",type:"warning"}),!1)},E=()=>{i.ElNotification({title:"",message:"最多上传5个文件",type:"warning"})},f=({name:t})=>{var e;const i=c.value.find(e=>e.name===t);i&&(null==(e=o.value)||e.handleRemove(i))},v=(t,e)=>{c.value=e},x=()=>{var t;const e=null==(t=s.value)?void 0:t.getCurrentValue();p(e)};return{isEmpty:r,fileList:c,activeTag:h,cancelHandler:d,submitHandler:p,changeHandler:()=>{var t,e;r.value=null==(e=null==(t=s.value)?void 0:t.chatState)?void 0:e.isEmpty},handleUploadError:g,handleUploadSuccess:u,handleUploadBefore:m,handleUploadExceed:E,removeFile:f,handleUploadRemove:v,submitBtnClick:x,getSlots:()=>{const a={"action-list":()=>t.createVNode("div",{class:"sender-action-wrapper"},[t.createVNode(i.ElUpload,{ref:"fileUpload",disabled:c.value.length>5,action:n.actionUrl,"show-file-list":!1,multiple:!0,limit:n.limit-c.value.length,data:n.extendData,beforeUpload:m,headers:n.headers,onError:g,onSuccess:u,onExceed:E,onRemove:v,accept:n.acceptFileType},{default:()=>[t.createVNode(i.ElIcon,{class:"sender-file-icon"},{default:()=>[t.createVNode(q,null,null)]})]}),n.loading?t.createVNode(xt,{class:"sender-cancel",onCancel:d},null):t.createVNode("div",{class:{"sender-btn":!0,active:!r.value},onClick:x},null)])};return(c.value.length>0||n.tagList.length>0)&&(a.header=()=>t.createVNode("div",{class:"sender-header-wrapper"},[t.createVNode("div",{class:"sender-file-list"},[c.value.map(i=>t.createVNode(e.FilesCard,{name:i.name,"show-del-icon":!0,status:"done",onDelete:f},null))]),t.createVNode("div",{class:"tag-list-wrapper"},[n.tagList.map(e=>t.createVNode("span",{class:h.value.id===e.id?"tag-item active":"tag-item",onClick:()=>{h.value=e}},[e.name]))])])),a}}},render(){let e;return t.createVNode("div",{class:"editor-sender-wrapper",ref:"editorSenderWrapper"},[t.createVNode(mt,{ref:"editorSender",variant:"updown",loading:this.loading,placeholder:this.placeholder,activeTag:this.activeTag,onSubmit:this.submitHandler,onCancel:this.cancelHandler,onChange:this.changeHandler,"custom-style":this.customStyle},(i=e=this.getSlots(),"function"==typeof i||"[object Object]"===Object.prototype.toString.call(i)&&!t.isVNode(i)?e:{default:()=>[e]}))]);var i}});exports.index=yt;
4
+ //# sourceMappingURL=editorSender.js.map