@blueking/ai-blueking 2.0.0-dev.16 → 2.0.0-dev.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"chat-bot.vue.d.ts","sourceRoot":"","sources":["../../src/components/chat-bot.vue"],"names":[],"mappings":"AAmpCE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAgB,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAoC,MAAM,kBAAkB,CAAC;AAksC9F,QAAA,IAAI,QAAQ,IAAiC,CAAE;AAC/C,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAO9C,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6EAKd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"chat-bot.vue.d.ts","sourceRoot":"","sources":["../../src/components/chat-bot.vue"],"names":[],"mappings":"AA6pCE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAgB,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAoC,MAAM,kBAAkB,CAAC;AA4sC9F,QAAA,IAAI,QAAQ,IAAiC,CAAE;AAC/C,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AAO9C,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6EAKd,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -27844,7 +27844,10 @@ var UIStateManager = class {
27844
27844
  Ug.value = [[]], Wg.value = "", a("send-message", typeof e == "string" ? e : ""), await Bg.sendMessage(e, r, n);
27845
27845
  }, l_ = async (e) => {
27846
27846
  let n = I?.session.current?.value?.sessionCode;
27847
- return n && await I.session.uploadFile(n, e) || {};
27847
+ if (!n) throw Error("[ChatBot] Cannot upload: no active session");
27848
+ let r = await I.session.uploadFile(n, e);
27849
+ if (!r?.download_url) throw Error("[ChatBot] Upload failed: no download URL returned");
27850
+ return r;
27848
27851
  }, u_ = async (e, n) => {
27849
27852
  try {
27850
27853
  await c_(e, Wg.value ? { property: { extra: { cite: Wg.value } } } : {});
@@ -3045,5 +3045,5 @@ Use Shift + Enter to enter a new line`:`输入 “/”唤出 Prompt
3045
3045
  </div>
3046
3046
  `}),T=async()=>{if(r.sessionBusinessManager)try{await r.sessionBusinessManager.createNewSession()}catch(e){console.error(`Failed to create new session:`,e),up({theme:`error`,message:D9(`创建会话失败`)})}i(`new-chat`)},E=e=>{e.stopPropagation(),r.sessionBusinessManager?(g||_(),g&&g.handleTriggerClick(e)):i(`history-click`,e)},D=()=>{i(`help-click`)},O=e=>{e.stopPropagation(),h&&(h.state.isVisible?h.hide():h.show())},k=e=>{e.stopPropagation(),e.preventDefault();let t=e.currentTarget,n=t.dataset.action;if(!t.classList.contains(`disabled`))switch(h&&h.hide(),n){case`rename`:A();break;case`auto-generate`:i(`auto-generate-name`);break;case`share`:i(`share`);break}},A=()=>{document.removeEventListener(`click`,P),p.value=r.sessionName||``,f.value=!0,setTimeout(()=>{document.addEventListener(`click`,P)},100),setTimeout(()=>{if(m.value)try{let e=m.value;e&&typeof e.focus==`function`&&e.focus();let t=e.$el?.querySelector(`input`);t&&typeof t.select==`function`&&t.select()}catch(e){console.warn(`Failed to focus rename input:`,e)}},100)},j=()=>{let e=p.value.trim();if(!e){M();return}i(`rename`,e),f.value=!1,p.value=``},M=()=>{f.value=!1,p.value=``},N=(e,t)=>{p.value=e,t.key===`Enter`?j():t.key===`Escape`&&M()},P=e=>{if(!f.value)return;let t=e.target,n=document.querySelector(`.rename-tooltip`);n&&!n.contains(t)&&M()},F=async()=>{if(!l.value)return;let e=(await Promise.resolve().then(()=>(T9(),E6t))).default;h&&=(h.destroy(),null),h=e(l.value,{content:w.value,theme:`ai-blueking-light more-menu-light light`,placement:`bottom-start`,trigger:`manual`,interactive:!0,allowHTML:!0,arrow:!1,offset:[0,4],appendTo:()=>document.querySelector(`.ai-blueking-panel`)||document.body,onShow:()=>{setTimeout(()=>{document.querySelectorAll(`.tippy-menu-item`).forEach(e=>{e.addEventListener(`click`,k)})},0)},onHide:()=>{document.querySelectorAll(`.tippy-menu-item`).forEach(e=>{e.removeEventListener(`click`,k)})}})};return lr(()=>[r.isCompressionHeight,r.hasSessionContents],()=>{h&&h.setContent(w.value)}),Vn(()=>{F(),r.sessionBusinessManager&&_(),document.addEventListener(`click`,P)}),Hn(()=>{h&&=(h.destroy(),null),g&&=(g.destroy(),null),document.removeEventListener(`click`,P)}),t({headerRef:o,historyIconRef:s}),(t,n)=>(H(),kr(`div`,{ref_key:`headerRef`,ref:o,class:_e([`ai-header drag-handle`,{draggable:r.draggable}])},[Pr(`div`,J7t,[Pr(`div`,Y7t,[Pr(`img`,{alt:`logo`,src:V(g7t)},null,8,X7t)]),Pr(`div`,{class:_e([`title`,{"title-with-tooltip":f.value}])},[Rr(Ce(v.value)+` `,1),zr(` 重命名 tooltip 直接绑定在 title 上 `),f.value?(H(),kr(`div`,Z7t,[Pr(`div`,Q7t,[Fr(V(af),{ref_key:`renameInputRef`,ref:m,modelValue:p.value,"onUpdate:modelValue":n[0]||=e=>p.value=e,class:`rename-input`,placeholder:V(D9)(`请输入新的会话名称`),onKeyup:N},null,8,[`modelValue`,`placeholder`]),Pr(`div`,{class:`rename-buttons`},[Pr(`i`,{class:`bkai-icon bkai-check-1 rename-btn confirm-btn`,onClick:j}),Pr(`i`,{class:`bkai-icon bkai-close rename-btn cancel-btn`,onClick:M})])])])):zr(`v-if`,!0)],2),r.showMoreIcon&&x.value?(H(),kr(`span`,{key:0,ref_key:`moreIconRef`,ref:l,class:`bkai-icon bkai-more`,onClick:O},null,512)):zr(`v-if`,!0)]),Pr(`div`,$7t,[zr(` 新增会话按钮 `),r.showNewChatIcon&&e.enableChatSession!==!1?bn((H(),kr(`i`,{key:0,class:_e([`bkai-icon`,`bkai-xinzengliaotian`,{disabled:!x.value}]),style:fe(C()),onClick:n[1]||=e=>x.value?T():void 0},null,6)),[[V(a),{content:S(V(D9)(`新增会话`)),boundary:`parent`}]]):zr(`v-if`,!0),zr(` 历史会话按钮 `),r.showHistoryIcon&&e.enableChatSession!==!1?bn((H(),kr(`i`,{key:1,ref_key:`historyIconRef`,ref:s,class:_e([`bkai-icon`,`bkai-history`,{disabled:!x.value}]),style:fe(C()),onClick:n[2]||=e=>x.value?E(e):void 0},null,6)),[[V(a),{content:S(V(D9)(`历史会话`)),boundary:`parent`}]]):zr(`v-if`,!0),e.chatGroup?.enabled?bn((H(),kr(`i`,{key:2,class:`bkai-icon bkai-zhushou`,onClick:D},null,512)),[[V(a),{content:V(D9)(`转人工`),boundary:`parent`}]]):zr(`v-if`,!0),r.showCompressionIcon?bn((H(),kr(`i`,{key:3,ref_key:`compressionRef`,ref:u,class:_e([`bkai-icon`,y.value]),onClick:n[3]||=e=>i(`toggle-compression`)},null,2)),[[V(a),{content:b.value,boundary:`parent`}]]):zr(`v-if`,!0),bn(Pr(`i`,{ref_key:`closeRef`,ref:d,class:`bkai-icon bkai-close-line-2`,onClick:n[4]||=e=>i(`close`)},null,512),[[V(a),{content:V(D9)(`关闭`),boundary:`parent`}]])])],2))}}),[[`__scopeId`,`data-v-e9f38ba5`]]);let t9t=e=>{var t;return{conversationSettings:{openingRemark:e?.conversation_settings?.opening_remark,predefinedQuestions:e?.conversation_settings?.predefined_questions,commands:e==null||(t=e.conversation_settings)==null?void 0:t.commands?.map(e=>({id:e.id,name:e.name,icon:e.icon,components:e.components.map(e=>({type:e.type,name:e.name,key:e.key,placeholder:e.placeholder,default:e.default,required:e.required,fillBack:e.fill_back,fillRegx:e.fill_regx,rows:e.rows,min:e.min,max:e.max,options:e.options})),content:e.content,agentId:e.agent_id,status:e.status})),enableChatSession:e?.conversation_settings?.enable_chat_session},promptSetting:e?.prompt_setting,agentName:e?.agent_name,chatGroup:e?.chat_group?{enabled:e.chat_group.enabled,staff:e.chat_group.staff,username:e.chat_group.username}:void 0,saasUrl:e?.saas_url,resources:e?.resources}};var O9;(function(e){e.KnowledgeRag=`knowledge_rag`,e.ReferenceDocument=`reference_document`})(O9||={});var k9;(function(e){e.Activity=`activity`,e.Assistant=`assistant`,e.Developer=`developer`,e.Guide=`guide`,e.Hidden=`hidden`,e.HiddenAssistant=`hidden-assistant`,e.HiddenGuide=`hidden-guide`,e.HiddenSystem=`hidden-system`,e.HiddenUser=`hidden-user`,e.Info=`info`,e.Pause=`pause`,e.Placeholder=`placeholder`,e.Reasoning=`reasoning`,e.System=`system`,e.TemplateAssistant=`template-assistant`,e.TemplateGuide=`template-guide`,e.TemplateHidden=`template-hidden`,e.TemplateSystem=`template-system`,e.TemplateUser=`template-user`,e.Tool=`tool`,e.User=`user`})(k9||={});var A9;(function(e){e.Complete=`complete`,e.Error=`error`,e.Pending=`pending`,e.Stop=`stop`,e.Streaming=`streaming`})(A9||={});var j9;(function(e){e.Binary=`binary`,e.Function=`function`,e.Text=`text`})(j9||={});function n9t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M9(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){n9t(e,t,n[t])})}return e}function r9t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function N9(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):r9t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let P9=e=>{let t={id:e.id,messageId:e.message_id,name:e.name,role:e.role,sessionCode:e.session_code,status:e.status};switch(e.role){case k9.Activity:{let n=e;return N9(M9({},t),{activityType:n.activity_type,content:Array.isArray(n.content)?n.content.map(e=>({name:e.name,originFileUrl:e.origin_file_url,url:e.url})):{content:n.content.content,referenceDocument:n.content.reference_document.map(e=>({name:e.name,originFileUrl:e.origin_file_url,url:e.url}))},role:n.role})}case k9.Assistant:{let n=e;return N9(M9({},t),{content:n.content,role:n.role,toolCalls:n.tool_calls?.map(e=>({function:{arguments:e.function.arguments,name:e.function.name,description:e.function.description,mcpName:e.function.mcp_name},id:e.id,type:e.type}))})}case k9.Developer:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Guide:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Hidden:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.HiddenAssistant:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.HiddenGuide:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.HiddenSystem:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.HiddenUser:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Info:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Pause:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Placeholder:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Reasoning:{let n=e;return N9(M9({},t),{content:n.content,duration:n.duration,role:n.role})}case k9.System:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateAssistant:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateGuide:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateHidden:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateSystem:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateUser:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Tool:{let n=e;return N9(M9({},t),{content:n.content,duration:n.duration,error:n.error,role:n.role,toolCallId:n.tool_call_id})}case k9.User:{let n=e,r=n.content;return N9(M9({},t),{content:Array.isArray(r)?r.map(e=>{if(e.type===j9.Binary){let t=e;return{data:t.data,filename:t.filename,id:t.id,mimeType:t.mime_type,type:t.type,url:t.url}}return e}):r,property:n.property,role:n.role})}}},i9t=e=>{let t={id:e.id,message_id:e.messageId,name:e.name,role:e.role,session_code:e.sessionCode,status:e.status};switch(e.role){case k9.Activity:{let n=e;return N9(M9({},t),{activity_type:n.activityType,content:Array.isArray(n.content)?n.content.map(e=>({name:e.name,origin_file_url:e.originFileUrl,url:e.url})):{content:n.content.content,reference_document:n.content.referenceDocument.map(e=>({name:e.name,origin_file_url:e.originFileUrl,url:e.url}))},role:n.role})}case k9.Assistant:{let n=e;return N9(M9({},t),{content:n.content,role:n.role,tool_calls:n.toolCalls?.map(e=>({function:{arguments:e.function.arguments,name:e.function.name,description:e.function.description,mcp_name:e.function.mcpName},id:e.id,type:e.type}))})}case k9.Developer:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Guide:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Hidden:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.HiddenAssistant:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.HiddenGuide:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.HiddenSystem:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.HiddenUser:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Info:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Pause:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Placeholder:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Reasoning:{let n=e;return N9(M9({},t),{content:n.content,duration:n.duration,role:n.role})}case k9.System:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateAssistant:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateGuide:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateHidden:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateSystem:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.TemplateUser:{let n=e;return N9(M9({},t),{content:n.content,role:n.role})}case k9.Tool:{let n=e;return N9(M9({},t),{content:n.content,duration:n.duration,error:n.error,role:n.role,tool_call_id:n.toolCallId})}case k9.User:{let n=e,r=n.content;return N9(M9({},t),{content:Array.isArray(r)?r.map(e=>{if(e.type===j9.Binary){let t=e;return{data:t.data,filename:t.filename,id:t.id,mime_type:t.mimeType,type:t.type,url:t.url}}return e}):r,property:n.property,role:n.role})}}},F9=e=>({sessionCode:e.session_code,sessionContentCount:e.session_content_count,sessionName:e.session_name,isTemporary:e.is_temporary,model:e.model,comment:e.comment,labels:e.labels,rate:e.rate,updatedAt:e.updated_at,createdAt:e.created_at,roleInfo:e.role_info?{collectionId:e.role_info.collection_id,collectionName:e.role_info.collection_name,content:e.role_info.content,variables:e.role_info.variables}:void 0,sessionProperty:{isAutoClear:e.session_property?.is_auto_clear,isAutoCalcPrompt:e.session_property?.is_auto_clac_prompt}}),a9t=e=>({session_code:e.sessionCode,session_content_count:e.sessionContentCount,session_name:e.sessionName,is_temporary:e.isTemporary,model:e.model,comment:e.comment,labels:e.labels,rate:e.rate,updated_at:e.updatedAt,created_at:e.createdAt,role_info:e.roleInfo?{collection_id:e.roleInfo.collectionId,collection_name:e.roleInfo.collectionName,content:e.roleInfo.content,variables:e.roleInfo.variables}:void 0,session_property:{is_auto_clear:e.sessionProperty?.isAutoClear,is_auto_clac_prompt:e.sessionProperty?.isAutoCalcPrompt}}),o9t=e=>({session_code:e.sessionCode,session_content_ids:e.sessionContentIds,rate:e.rate,comment:e.comment,labels:e.labels}),s9t=e=>({sessionCode:e.session_code,sessionContentIds:e.session_content_ids,rate:e.rate,comment:e.comment,labels:e.lables});function c9t(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function l9t(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){c9t(a,r,i,o,s,`next`,e)}function s(e){c9t(a,r,i,o,s,`throw`,e)}o(void 0)})}}function u9t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d9t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){u9t(e,t,n[t])})}return e}function f9t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function p9t(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):f9t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var m9t=()=>`temp_${Date.now()}_${Math.random().toString(36).slice(2,9)}`;let h9t=e=>{let t=Xt([]),n=Xt(!1),r=Xt(!1);return{list:t,isListLoading:n,isDeleteLoading:r,getMessages:r=>(n.value=!0,e.http?.message.getMessages(r).then(e=>{t.value=e}).finally(()=>{n.value=!1})),getCurrentLoadingMessage:()=>t.value.findLast(e=>[A9.Pending,A9.Streaming].includes(e.status)),getMessageByMessageId:e=>t.value.find(t=>t.messageId===e),modifyMessage:e=>{t.value=t.value.map(t=>t.messageId===e.messageId?e:t)},plusMessage:e=>{t.value.push(e)},createAndPlusMessage:function(){var n=l9t(function*(n){let r=m9t(),i=p9t(d9t({},n),{id:r,messageId:r});t.value.push(i);try{let i=yield e.http?.message.plusMessage(n);if(i){let e=t.value.findIndex(e=>e.messageId===r);if(e!==-1){let r=d9t({},i,`property`in n&&n.property?{property:n.property}:{});t.value[e]=r}}}catch(e){let n=t.value.findIndex(e=>e.messageId===r);throw n!==-1&&(t.value[n]=p9t(d9t({},t.value[n]),{status:A9.Error})),e}});return function(e){return n.apply(this,arguments)}}(),deleteMessages:function(){var n=l9t(function*(n){let i=n.reduce((e,t)=>(t.role===k9.User&&e.push(t.id),e),[]);if(i.length<=0)return;let a=[...t.value];t.value=t.value.filter(e=>!n.includes(e)),r.value=!0;try{yield e.http?.message.batchDeleteMessages(i)}catch(e){throw t.value=a,e}finally{r.value=!1}});return function(e){return n.apply(this,arguments)}}(),shareMessages:function(){var t=l9t(function*(t,n,r){let i=n.reduce((e,t)=>(t.role===k9.User&&e.push(t.id),e),[]);if(!(i.length<=0))return e.http?.message.shareMessages(t,i,r)});return function(e,n,r){return t.apply(this,arguments)}}(),reset:()=>{t.value=[],n.value=!1,r.value=!1}}};var I9;(function(e){e.KnowledgeRagEnd=`knowledge_rag_end`,e.KnowledgeRagResult=`knowledge_rag_result`,e.KnowledgeRagStart=`knowledge_rag_start`,e.KnowledgeRagTextContent=`knowledge_rag_text_content`,e.ReferenceDocument=`reference_document`})(I9||={});var L9;(function(e){e.ActivityDelta=`ACTIVITY_DELTA`,e.ActivitySnapshot=`ACTIVITY_SNAPSHOT`,e.Custom=`CUSTOM`,e.MessagesSnapshot=`MESSAGES_SNAPSHOT`,e.Raw=`RAW`,e.RunError=`RUN_ERROR`,e.RunFinished=`RUN_FINISHED`,e.RunStarted=`RUN_STARTED`,e.StateDelta=`STATE_DELTA`,e.StateSnapshot=`STATE_SNAPSHOT`,e.StepFinished=`STEP_FINISHED`,e.StepStarted=`STEP_STARTED`,e.TextMessageChunk=`TEXT_MESSAGE_CHUNK`,e.TextMessageContent=`TEXT_MESSAGE_CONTENT`,e.TextMessageEnd=`TEXT_MESSAGE_END`,e.TextMessageStart=`TEXT_MESSAGE_START`,e.ThinkingEnd=`THINKING_END`,e.ThinkingStart=`THINKING_START`,e.ThinkingTextMessageContent=`THINKING_TEXT_MESSAGE_CONTENT`,e.ThinkingTextMessageEnd=`THINKING_TEXT_MESSAGE_END`,e.ThinkingTextMessageStart=`THINKING_TEXT_MESSAGE_START`,e.ToolCallArgs=`TOOL_CALL_ARGS`,e.ToolCallChunk=`TOOL_CALL_CHUNK`,e.ToolCallEnd=`TOOL_CALL_END`,e.ToolCallResult=`TOOL_CALL_RESULT`,e.ToolCallStart=`TOOL_CALL_START`})(L9||={});function R9(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var z9=class{handleActivityDeltaEvent(e){}handleActivitySnapshotEvent(e){}handleCustomEvent(e){switch(e.name){case I9.ReferenceDocument:this.handleReferenceDocumentCustomEvent(e);break;case I9.KnowledgeRagStart:this.handleKnowledgeRagStartCustomEvent(e);break;case I9.KnowledgeRagTextContent:this.handleKnowledgeRagTextContentCustomEvent(e);break;case I9.KnowledgeRagResult:this.handleKnowledgeRagResultCustomEvent(e);break;case I9.KnowledgeRagEnd:this.handleKnowledgeRagEndCustomEvent(e);break;default:break}}handleKnowledgeRagEndCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===k9.Activity&&t.activityType===O9.KnowledgeRag&&(t.status=A9.Complete)}handleKnowledgeRagResultCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===k9.Activity&&t.activityType===O9.KnowledgeRag&&(t.content.referenceDocument=e.value)}handleKnowledgeRagStartCustomEvent(e){this.messageModule.plusMessage({role:k9.Activity,activityType:O9.KnowledgeRag,content:{content:``,referenceDocument:[]},status:A9.Streaming})}handleKnowledgeRagTextContentCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();if(t&&t.role===k9.Activity&&t.activityType===O9.KnowledgeRag){let n=e.value;t.content.content=n.cover?n.chunk.content:t.content.content+n.chunk.content}}handleMessagesSnapshotEvent(e){e.messages&&e.messages.length>0&&(this.messageModule.list.value=e.messages.map(P9))}handleRawEvent(e){}handleReferenceDocumentCustomEvent(e){this.messageModule.plusMessage({role:k9.Activity,activityType:O9.ReferenceDocument,content:e.value,status:A9.Complete})}handleRunErrorEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&(t.status=A9.Complete),this.messageModule.plusMessage({role:k9.Assistant,content:e.message,status:A9.Error})}handleRunFinishedEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&(t.status=A9.Complete)}handleRunStartedEvent(e){}handleStateDeltaEvent(e){}handleStateSnapshotEvent(e){}handleStepFinishedEvent(e){}handleStepStartedEvent(e){}handleTextMessageChunkEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t?t.content+=e.delta||``:this.messageModule.plusMessage({role:e.role,content:e.delta||``,status:A9.Complete,messageId:e.messageId})}handleTextMessageContentEvent(e){let t=this.messageModule.getMessageByMessageId(e.messageId);t&&(t.content+=e.delta)}handleTextMessageEndEvent(e){let t=this.messageModule.getMessageByMessageId(e.messageId);t&&(t.status=A9.Complete)}handleTextMessageStartEvent(e){this.messageModule.plusMessage({role:e.role,content:``,status:A9.Streaming,messageId:e.messageId})}handleThinkingEndEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===k9.Reasoning&&(t.duration=e.duration,t.status=A9.Complete)}handleThinkingStartEvent(e){this.messageModule.plusMessage({role:k9.Reasoning,content:[],status:A9.Streaming})}handleThinkingTextMessageContentEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===k9.Reasoning&&(t.content[t.content.length-1]+=e.delta)}handleThinkingTextMessageEndEvent(e){}handleThinkingTextMessageStartEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===k9.Reasoning&&t.content.push(``)}handleToolCallArgsEvent(e){this.messageModule.list.value.forEach(t=>{t.role===k9.Assistant&&t.toolCalls&&t.toolCalls.forEach(t=>{t.id===e.toolCallId&&(t.function.arguments+=e.delta)})})}handleToolCallChunkEvent(e){}handleToolCallEndEvent(e){this.messageModule.list.value.forEach(t=>{t.role===k9.Assistant&&t.toolCalls&&t.toolCalls.some(t=>t.id===e.toolCallId)&&(t.status=A9.Complete)})}handleToolCallResultEvent(e){this.messageModule.plusMessage({role:k9.Tool,content:e.content,duration:e.duration,status:A9.Complete,toolCallId:e.toolCallId,messageId:e.messageId})}handleToolCallStartEvent(e){this.messageModule.plusMessage({role:k9.Assistant,content:``,status:A9.Streaming,toolCalls:[{id:e.toolCallId,type:j9.Function,function:{mcpName:e.mcpName,name:e.toolCallName,arguments:``,description:e.description}}]})}injectMessageModule(e){this.messageModule=e}onDone(){var e,t;(e=(t=this).onDoneCallback)==null||e.call(t)}onError(e){var t,n;this.messageModule.plusMessage({role:k9.Assistant,content:e.message,status:A9.Error}),(t=(n=this).onErrorCallback)==null||t.call(n,e)}onMessage(e){var t,n;let r=e;switch((t=(n=this).onMessageCallback)==null||t.call(n,r),r.type){case L9.ActivityDelta:this.handleActivityDeltaEvent(r);break;case L9.ActivitySnapshot:this.handleActivitySnapshotEvent(r);break;case L9.Custom:this.handleCustomEvent(r);break;case L9.MessagesSnapshot:this.handleMessagesSnapshotEvent(r);break;case L9.Raw:this.handleRawEvent(r);break;case L9.RunError:this.handleRunErrorEvent(r);break;case L9.RunFinished:this.handleRunFinishedEvent(r);break;case L9.RunStarted:this.handleRunStartedEvent(r);break;case L9.StateDelta:this.handleStateDeltaEvent(r);break;case L9.StateSnapshot:this.handleStateSnapshotEvent(r);break;case L9.StepFinished:this.handleStepFinishedEvent(r);break;case L9.StepStarted:this.handleStepStartedEvent(r);break;case L9.TextMessageChunk:this.handleTextMessageChunkEvent(r);break;case L9.TextMessageContent:this.handleTextMessageContentEvent(r);break;case L9.TextMessageEnd:this.handleTextMessageEndEvent(r);break;case L9.TextMessageStart:this.handleTextMessageStartEvent(r);break;case L9.ThinkingEnd:this.handleThinkingEndEvent(r);break;case L9.ThinkingStart:this.handleThinkingStartEvent(r);break;case L9.ThinkingTextMessageContent:this.handleThinkingTextMessageContentEvent(r);break;case L9.ThinkingTextMessageEnd:this.handleThinkingTextMessageEndEvent(r);break;case L9.ThinkingTextMessageStart:this.handleThinkingTextMessageStartEvent(r);break;case L9.ToolCallArgs:this.handleToolCallArgsEvent(r);break;case L9.ToolCallChunk:this.handleToolCallChunkEvent(r);break;case L9.ToolCallEnd:this.handleToolCallEndEvent(r);break;case L9.ToolCallResult:this.handleToolCallResultEvent(r);break;case L9.ToolCallStart:this.handleToolCallStartEvent(r);break;default:break}}onStart(){var e,t;(e=(t=this).onStartCallback)==null||e.call(t)}constructor(e){R9(this,`messageModule`,void 0),R9(this,`onDoneCallback`,void 0),R9(this,`onErrorCallback`,void 0),R9(this,`onMessageCallback`,void 0),R9(this,`onStartCallback`,void 0),this.onDoneCallback=e?.onDone,this.onErrorCallback=e?.onError,this.onMessageCallback=e?.onMessage,this.onStartCallback=e?.onStart}};function g9t(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function B9(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){g9t(a,r,i,o,s,`next`,e)}function s(e){g9t(a,r,i,o,s,`throw`,e)}o(void 0)})}}function _9t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v9t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){_9t(e,t,n[t])})}return e}let y9t=(e,t)=>{let n=Xt(null),r=Xt(!1),i=Xt(!1),a=t||new z9,o=null,s=()=>(r.value=!0,e.http?.agent.getAgentInfo().then(e=>{n.value=e}).finally(()=>{r.value=!1})),l=function(){var t=B9(function*(t,n,r){var s;a instanceof z9&&a.injectMessageModule(e.message),o=new AbortController,(s=e.http)==null||s.fetchClient.streamRequest(v9t({url:n||`chat_completion/`,method:`POST`,data:{session_code:t},controller:o,onDone:()=>{var e;i.value=!1,(e=a.onDone)==null||e.call(a)},onError:e=>{var t;i.value=!1,(t=a.onError)==null||t.call(a,e)},onMessage:e=>{var t;(t=a.onMessage)==null||t.call(a,e)},onStart:()=>{var e;i.value=!0,(e=a.onStart)==null||e.call(a)}},r))});return function(e,n,r){return t.apply(this,arguments)}}(),u=function(){var t=B9(function*(t,n,r,i,a){yield e.message?.createAndPlusMessage(v9t({role:k9.User,content:t,status:A9.Complete,sessionCode:n},a&&{property:a})),l(n,r,i)});return function(e,n,r,i,a){return t.apply(this,arguments)}}(),d=(t,n,r)=>{let i=e.message?.list.value.at(-1);(i?.status===A9.Streaming||i?.role===k9.User)&&l(t,n,r)},f=()=>{var e;o==null||(e=o.abort)==null||e.call(o),o=null},p=function(){var t=B9(function*(t){return e.http.message?.stopChat(t)});return function(e){return t.apply(this,arguments)}}();return{info:n,isInfoLoading:r,isChatting:i,chat:u,resendMessage:function(){var t=B9(function*(t,n,r,i,a){let o=e.message?.list.value||[],s=o.findIndex(e=>String(e.id)===t);if(s===-1)throw Error(`Message not found: ${t}`);let u=o[s];if(u.role!==k9.User)throw Error(`Can only resend user messages`);let d=u.content,f=u.property,p=r??d,m=o.slice(s),h=e.message?.deleteMessages(m),g=e.message?.createAndPlusMessage(v9t({role:k9.User,content:p,status:A9.Complete,sessionCode:n},f&&{property:f}));l(n,i,a),Promise.all([h,g]).catch(e=>{console.error(`[resendMessage] API error:`,e)})});return function(e,n,r,i,a){return t.apply(this,arguments)}}(),resumeStreamingChat:d,abortChat:f,stopChat:p,getAgentInfo:s,reset:e=>{a=e||new z9,n.value=null,r.value=!1}}};function b9t(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function x9t(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){b9t(a,r,i,o,s,`next`,e)}function s(e){b9t(a,r,i,o,s,`throw`,e)}o(void 0)})}}function V9(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function H9(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){V9(e,t,n[t])})}return e}function S9t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function U9(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):S9t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var C9t=class{clear(){this.handlers=[]}eject(e){this.handlers[e]&&(this.handlers[e]=null)}forEach(e){this.handlers.forEach(t=>{t!==null&&e(t)})}use(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1}constructor(){V9(this,`handlers`,[])}},w9t=class e{applyResponseErrorInterceptors(e){let t=e;return this.interceptors.response.forEach(e=>{e.rejected&&(t=e.rejected(t))}),t}create(t){return new e(G9(this.defaults,t||{}))}delete(e,t,n){return this.request(U9(H9({},n),{url:e,method:`DELETE`,params:t}))}get(e,t,n){return this.request(U9(H9({},n),{url:e,method:`GET`,params:t}))}head(e,t,n){return this.request(U9(H9({},n),{url:e,method:`HEAD`,params:t}))}options(e,t,n){return this.request(U9(H9({},n),{url:e,method:`OPTIONS`,params:t}))}patch(e,t,n){return this.request(U9(H9({},n),{url:e,method:`PATCH`,data:t}))}post(e,t,n){return this.request(U9(H9({},n),{url:e,method:`POST`,data:t}))}prepareRequest(e,t=!1){let n=G9(this.defaults,e);this.interceptors.request.forEach(e=>{if(e.fulfilled)try{n=e.fulfilled(n)}catch(t){throw e.rejected?e.rejected(t):t}});let r=n.url||``;n.baseURL&&!r.startsWith(`http`)&&(r=n.baseURL+r),r=T9t(r,n.params);let i=E9t(n.data),a=new Headers(E9t(n.headers));t&&!a.has(`Accept`)&&a.set(`Accept`,`text/event-stream`),i!=null&&(n.transformRequest?i=n.transformRequest(i,E9t(n.headers)):a.get(`Content-Type`)?.includes(`application/json`)&&typeof i==`object`&&!(i instanceof FormData)&&!(i instanceof Blob)&&!(i instanceof ArrayBuffer)&&(i=JSON.stringify(i)));let o=n.controller?n.controller:new AbortController,s={method:n.method,credentials:n.credentials,mode:n.mode,headers:a,body:i,signal:o.signal};return{url:r,requestConfig:n,fetchConfig:s,controller:o}}put(e,t,n){return this.request(U9(H9({},n),{url:e,method:`PUT`,data:t}))}request(e){var t=this;return x9t(function*(){let{url:n,fetchConfig:r,requestConfig:i,controller:a}=t.prepareRequest(e),o=i.timeout&&i.timeout>0?setTimeout(()=>a.abort(),i.timeout):void 0;try{let e=yield fetch(n,r);o&&clearTimeout(o);let a,s=i.responseType||`json`;try{switch(s){case`json`:a=yield e.json();break;case`text`:a=yield e.text();break;case`blob`:a=yield e.blob();break;case`arrayBuffer`:a=yield e.arrayBuffer();break;case`formData`:a=yield e.formData();break;default:a=yield e.json()}}catch{a=null}i.transformResponse&&(a=i.transformResponse(a));let l={data:a,status:e.status,statusText:e.statusText,headers:e.headers,config:i};if(!(i.validateStatus||t.defaults.validateStatus)(e.status))throw W9(`Request failed with status code ${e.status}`,i,`ERR_BAD_RESPONSE`,l);let u=l;t.interceptors.response.forEach(e=>{if(e.fulfilled)try{u=e.fulfilled(u)}catch(t){throw e.rejected?e.rejected(t):t}}),u instanceof Promise&&(u=yield u);let d=u.data;if(![0,`success`].includes(d.code))throw W9(d.message,i,d.code,u);return d.data}catch(e){if(o&&clearTimeout(o),e instanceof Error&&e.name===`AbortError`){let e=W9(`Request timeout`,i,`ECONNABORTED`,void 0);throw t.applyResponseErrorInterceptors(e)}let n=e.isAxiosError===!0?e:W9(e.message,i,e.code,void 0);throw t.applyResponseErrorInterceptors(n)}})()}stream(e,t){return this.streamRequest(U9(H9({},t),{url:e}))}streamRequest(e){var t=this;return x9t(function*(){let{url:n,fetchConfig:r,requestConfig:i}=t.prepareRequest(e,!0);try{var a;let u=yield fetch(n,r);if(!(i.validateStatus||t.defaults.validateStatus)(u.status)){var o;let t=W9(`Request failed with status code ${u.status}`,i,`ERR_BAD_RESPONSE`,void 0);(o=e.onError)==null||o.call(e,t);return}(a=e.onStart)==null||a.call(e);let d=u.body?.pipeThrough(new window.TextDecoderStream).getReader();if(!d){var s;let t=Error(`IResponse body is not readable`);(s=e.onError)==null||s.call(e,t);return}let f=``,p=e=>{try{return JSON.parse(e),!0}catch{return!1}};for(;;){let{value:t,done:n}=yield d.read();if(n){var l;(l=e.onDone)==null||l.call(e);break}(f+t.toString()).split(`
3047
3047
  `).forEach(t=>{let n=t.replace(`data:`,``).trim();if(p(n)){var r;let t=JSON.parse(n);(r=e.onMessage)==null||r.call(e,t),f=``}else n&&(f=n)})}}catch(t){if(t instanceof Error)if(t.name===`AbortError`){var u;(u=e.onDone)==null||u.call(e)}else{var d;(d=e.onError)==null||d.call(e,t)}throw t}})()}constructor(e={}){V9(this,`defaults`,void 0),V9(this,`interceptors`,void 0),this.defaults=G9({method:`GET`,headers:{"Content-Type":`application/json`},timeout:3e4,responseType:`json`,credentials:`include`,mode:`cors`,validateStatus:e=>e>=200&&e<300},e),this.interceptors={request:new C9t,response:new C9t}}};function T9t(e,t){if(!t)return e;let n=new URLSearchParams;Object.keys(t).forEach(e=>{let r=t[e];r!=null&&(Array.isArray(r)?r.forEach(t=>n.append(e,String(t))):n.append(e,String(r)))});let r=n.toString();return r?`${e}${e.includes(`?`)?`&`:`?`}${r}`:e}function W9(e,t,n,r){let i=Error(e);return i.config=t,i.code=String(n),i.response=r,i.isAxiosError=!0,i}function E9t(e){return typeof e==`function`?e():e}function D9t(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function G9(e,t){let n=H9({},e);for(let r in t){let i=t[r];if(D9t(i)){let t=e[r];n[r]=G9(t||{},i)}else n[r]=i}return n}new w9t;let O9t=e=>{let t=new w9t({baseURL:e.requestData.urlPrefix});return e.interceptors?.request&&t.interceptors.request.use(e.interceptors.request),e.interceptors?.response&&t.interceptors.response.use(e.interceptors.response),{fetchClient:t,reset:e=>{t.defaults.baseURL=e.requestData.urlPrefix,t.interceptors.request.clear(),t.interceptors.response.clear(),e.interceptors?.request&&t.interceptors.request.use(e.interceptors.request),e.interceptors?.response&&t.interceptors.response.use(e.interceptors.response)}}},k9t=e=>({getAgentInfo:t=>e.get(`agent/info/`,void 0,t).then(t9t)});function A9t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j9t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){A9t(e,t,n[t])})}return e}let M9t=e=>({getMessages:(t,n,r)=>e.get(`session_content/content/`,{session_code:t,limit:n},r).then(e=>e.map(P9)),plusMessage:(t,n)=>e.post(`session_content/`,i9t(t),n).then(P9),modifyMessage:(t,n)=>e.put(`session_content/${t.id}/`,i9t(t),n).then(P9),deleteMessage:(t,n)=>e.delete(`session_content/${t}/`,void 0,n),batchDeleteMessages:(t,n)=>e.post(`session_content/batch_delete/`,{ids:t},n),shareMessages:(t,n,r,i)=>e.post(`share/`,j9t({session_code:t,content_ids:n},r?{expired_at:r}:{}),i),stopChat:(t,n)=>e.post(`session_content/stop/`,{session_code:t},n)});function N9t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P9t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){N9t(e,t,n[t])})}return e}function F9t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function I9t(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):F9t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let L9t=e=>({clearSession:(t,n)=>e.post(`chat_completion/${t}/clear/`,void 0,n),getSessions:t=>e.get(`session/`,void 0,t).then(e=>e.map(F9)),plusSession:(t,n)=>e.post(`session/`,a9t(t),n).then(e=>F9(e)),modifySession:(t,n)=>e.put(`session/${t.sessionCode}/`,a9t(t),n).then(e=>F9(e)),deleteSession:(t,n)=>e.delete(`session/${t}/`,void 0,n),batchDeleteSessions:(t,n)=>e.post(`session/batch_delete/`,{session_codes:t},n),getSession:(t,n)=>e.get(`session/${t}/`,void 0,n).then(e=>F9(e)),postSessionFeedback:(t,n)=>e.post(`session_feedback/`,o9t(t),n).then(e=>s9t(e)),getSessionFeedbackReasons:(t,n)=>e.get(`session_feedback/reasons/`,{rate:t},n),renameSession:(t,n)=>e.post(`session/${t}/ai_rename/`,void 0,n).then(e=>F9(e)),uploadFile:(t,n,r)=>{let i=encodeURIComponent(n.name);return n.arrayBuffer().then(a=>e.post(`session/${t}/upload/${i}/`,a,I9t(P9t({},r),{headers:{"Content-Disposition":`attachment; filename="${n.name}"`}})))}}),R9t=e=>({agent:k9t(e),session:L9t(e),message:M9t(e),fetchClient:e});function z9t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function B9t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){z9t(e,t,n[t])})}return e}function V9t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function H9t(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):V9t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let U9t=e=>{let{fetchClient:t,reset:n}=O9t(e);return H9t(B9t({},R9t(t)),{reset:n})},W9t=()=>({agent:null,http:null,message:null,session:null,registerAgent(e){this.agent=e},registerHttp(e){this.http=e},registerMessage(e){this.message=e},registerSession(e){this.session=e}});function G9t(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function K9t(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){G9t(a,r,i,o,s,`next`,e)}function s(e){G9t(a,r,i,o,s,`throw`,e)}o(void 0)})}}function q9t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function J9t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){q9t(e,t,n[t])})}return e}let Y9t=e=>{let t=Xt([]),n=Xt(null),r=Xt(!1),i=Xt(!1),a=Xt(!1),o=Xt(!1),s=Xt(!1),l=Xt(!1),u=e=>{t.value=t.value.map(t=>t.sessionCode===e.sessionCode?J9t({},t,e):t),n.value?.sessionCode===e.sessionCode&&(n.value=t.value.find(t=>t.sessionCode===e.sessionCode)??n.value)},d=()=>(i.value=!0,e.http?.session.getSessions().then(e=>{t.value=e}).finally(()=>{i.value=!1})),f=function(){var r=K9t(function*(r,i){var a;if((a=e.agent)==null||a.abortChat(),n.value=t.value.find(e=>e.sessionCode===r)??null,i?.loadMessages!==!1){var o;yield e.message?.getMessages(r),(o=e.agent)==null||o.resumeStreamingChat(r)}else e.message&&(e.message.list.value=[])});return function(e,t){return r.apply(this,arguments)}}();return{list:t,current:n,isCurrentLoading:r,isListLoading:i,isCreateLoading:a,isUpdateLoading:o,isDeleteLoading:s,getSessions:d,chooseSession:f,getSession:t=>(r.value=!0,e.http?.session.getSession(t).then(e=>{n.value=e}).finally(()=>{r.value=!1})),createSession:function(){var n=K9t(function*(n,r){a.value=!0;try{let i=yield e.http?.session.plusSession(n);i&&(t.value.unshift(i),yield f(i.sessionCode,{loadMessages:r?.loadMessages??!1}))}finally{a.value=!1}});return function(e,t){return n.apply(this,arguments)}}(),updateSession:t=>(o.value=!0,e.http?.session.modifySession(t).then(e=>{u(e)}).finally(()=>{o.value=!1})),deleteSession:function(){var r=K9t(function*(r){s.value=!0;try{yield e.http?.session.deleteSession(r),t.value=t.value.filter(e=>e.sessionCode!==r),n.value?.sessionCode===r&&t.value[0]?.sessionCode&&(yield f(t.value[0].sessionCode))}finally{s.value=!1}});return function(e){return r.apply(this,arguments)}}(),postSessionFeedback:t=>e.http?.session.postSessionFeedback(t),getSessionFeedbackReasons:t=>e.http?.session.getSessionFeedbackReasons(t),renameSession:t=>(l.value=!0,e.http?.session.renameSession(t).then(e=>{u({sessionCode:e.sessionCode,sessionName:e.sessionName})}).finally(()=>{l.value=!1})),uploadFile:(t,n)=>e.http?.session.uploadFile(t,n),reset:()=>{t.value=[],n.value=null,r.value=!1,i.value=!1,a.value=!1,o.value=!1,s.value=!1,l.value=!1}}},X9t=e=>{let t=W9t(),n=U9t(e),r=y9t(t,e.protocol),i=h9t(t),a=Y9t(t);return t.registerHttp(n),t.registerMessage(i),t.registerAgent(r),t.registerSession(a),{agent:r,session:a,message:i,http:n,reset:e=>{n.reset(e),r.reset(e.protocol),i.reset(),a.reset()}}};var Z9t=class{_isGenerating;agentModule;config;eventEmitter;messageModule;sessionModule;autoRenameSessionIfNeeded(e){this.sessionModule&&this.messageModule.list.value.length===1&&this.sessionModule.renameSession(e).catch(e=>{console.error(`[ChatBusinessManager] Auto rename session failed:`,e)})}emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,t,n=null,r=null,i={}){this.agentModule=e,this.messageModule=t,this.sessionModule=n,this.eventEmitter=r,this.config=i,this._isGenerating=Xt(!1)}get isGenerating(){return this._isGenerating}get isMessagesLoading(){return this.messageModule.isListLoading}get messages(){return this.messageModule.list}get openingRemark(){return this.config.openingRemark||``}get predefinedQuestions(){return this.config.predefinedQuestions||[]}async batchDeleteMessages(e){try{await this.messageModule.deleteMessages(e);let t=e.map(e=>e.id).filter(Boolean);this.emit(`messages-batch-deleted`,{messageIds:t})}catch(e){throw console.error(`Failed to batch delete messages:`,e),this.emit(`chat-error`,{action:`batch-delete-messages`,error:e}),e}}async deleteMessage(e){try{await this.messageModule.deleteMessages([e]),this.emit(`message-deleted`,{messageId:e.id})}catch(e){throw console.error(`Failed to delete message:`,e),this.emit(`chat-error`,{action:`delete-message`,error:e}),e}}handleStreamEnd(){this._isGenerating.value=!1,this.emit(`receive-end`,{})}handleStreamError(e){this._isGenerating.value=!1,this.emit(`receive-error`,{error:e})}handleStreamStart(){this._isGenerating.value=!0,this.emit(`receive-start`,{})}async regenerateFromAIMessages(e,t){try{if(!e||e.length===0)throw Error(`No AI messages provided`);let n=this.messages.value,r=_7t(n,e[0]);if(!r)throw Error(`No user message found before AI messages`);let i=r.id;if(i===void 0)throw Error(`User message has no id`);await this.regenerateMessage(String(i),t)}catch(e){throw console.error(`Failed to regenerate from AI messages:`,e),this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async regenerateMessage(e,t){try{let n=this.messages.value,r=n.findIndex(t=>String(t.id)===e);if(r===-1)throw Error(`Message not found: ${e}`);let i=n[r];if(i.role!==k9.User)throw Error(`Can only regenerate from user messages`);let a=n.slice(r),o=typeof i.content==`string`?i.content:JSON.stringify(i.content),s=i.property;this._isGenerating.value=!0;let l=this.messageModule.deleteMessages(a);this.agentModule.chat(o,t,void 0,void 0,s),this.emit(`chat-regenerate`,{messageId:e}),l.catch(e=>{console.error(`[regenerateMessage] Delete API error:`,e)})}catch(e){throw console.error(`Failed to regenerate message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async resendMessageWithProperty(e,t,n,r){try{let i=this.messages.value,a=i.findIndex(t=>String(t.id)===e);if(a===-1)throw Error(`Message not found: ${e}`);if(i[a].role!==k9.User)throw Error(`Can only resend user messages`);let o=i.slice(a);this._isGenerating.value=!0;let s=this.messageModule.deleteMessages(o);this.agentModule.chat(n,t,void 0,void 0,r),this.emit(`chat-resend`,{messageId:e}),s.catch(e=>{console.error(`[resendMessageWithProperty] Delete API error:`,e)})}catch(e){throw console.error(`Failed to resend message with property:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`resend`,error:e}),e}}async retryMessage(e){try{console.warn(`retryMessage not implemented yet`),this.emit(`chat-retry`,{messageId:e})}catch(e){throw console.error(`Failed to retry message:`,e),this.emit(`chat-error`,{action:`retry`,error:e}),e}}async sendMessage(e,t,n={}){try{if(!t)throw Error(`No active session. Please create or select a session first.`);this._isGenerating.value=!0,this.emit(`send-message`,{content:e}),await this.agentModule.chat(e,t,void 0,void 0,n.property),this.autoRenameSessionIfNeeded(t)}catch(e){throw console.error(`Failed to send message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`send`,error:e}),e}}stopGeneration(){try{let e=this.sessionModule?.current?.value?.sessionCode??``;this.agentModule.stopChat(e),this._isGenerating.value=!1,this.emit(`stop`,{})}catch(e){console.error(`Failed to stop generation:`,e),this.emit(`chat-error`,{action:`stop`,error:e})}}},Q9t=class{config;eventEmitter;messageModule;sessionModule;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,t,n=null,r={}){this.sessionModule=e,this.messageModule=t,this.eventEmitter=n,this.config=r}get currentSession(){return this.sessionModule.current}get isCreateLoading(){return this.sessionModule.isCreateLoading}get isCurrentLoading(){return this.sessionModule.isCurrentLoading}get isDeleteLoading(){return this.sessionModule.isDeleteLoading}get isListLoading(){return this.sessionModule.isListLoading}get isUpdateLoading(){return this.sessionModule.isUpdateLoading}get sessionList(){return this.sessionModule.list}async createNewSession(){return this.createSession({name:`新会话`,sessionCode:`new_session_${Date.now()}`})}async createSession(e={}){if(this.config.enableChatSession===!1)throw Error(`Chat session is disabled`);try{let t={sessionName:e.name||`新会话`,sessionCode:e.sessionCode||`session_${Date.now()}`,isTemporary:e.isTemporary||!1};await this.sessionModule.createSession(t),this.emit(`session-created`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to create session:`,e),this.emit(`session-error`,{action:`create`,error:e}),e}}async deleteSession(e){try{await this.sessionModule.deleteSession(e),this.emit(`session-deleted`,{sessionCode:e})}catch(e){throw console.error(`Failed to delete session:`,e),this.emit(`session-error`,{action:`delete`,error:e}),e}}async getSession(e){try{await this.sessionModule.getSession(e)}catch(e){throw console.error(`Failed to get session:`,e),this.emit(`session-error`,{action:`get`,error:e}),e}}async loadRecentSession(e){try{e?.skipLoadSessions||await this.loadSessions();let t=this.sessionList.value;if(this.config.initialSessionCode){await this.switchSession(this.config.initialSessionCode);return}if(t.length>0){let e=t[0];(e.sessionContentCount??0)>0?await this.createNewSession():await this.switchSession(e.sessionCode,{loadMessages:!1});return}await this.createNewSession()}catch(e){throw console.error(`Failed to load recent session:`,e),e}}async loadSessions(){try{await this.sessionModule.getSessions(),this.emit(`sessions-loaded`,{sessions:this.sessionList.value})}catch(e){throw console.error(`Failed to load sessions:`,e),this.emit(`session-error`,{action:`load`,error:e}),e}}async switchSession(e,t){try{await this.sessionModule.chooseSession(e,t),this.emit(`session-switched`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to switch session:`,e),this.emit(`session-error`,{action:`switch`,error:e}),e}}async updateSessionName(e,t){try{let n=this.sessionList.value.find(t=>t.sessionCode===e);if(!n)throw Error(`Session not found: ${e}`);await this.sessionModule.updateSession({...n,sessionName:t}),this.emit(`session-updated`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to update session name:`,e),this.emit(`session-error`,{action:`update`,error:e}),e}}},$9t=class{messageModule;sessionModule;constructor(e,t){this.messageModule=e,this.sessionModule=t}async shareMessages(e){if(e.length===0)throw Error(`No messages to share`);let t=this.sessionModule.current?.value?.sessionCode;if(!t)throw Error(`No active session`);let n=await this.messageModule.shareMessages(t,e);if(!n)throw Error(`Share failed: no result returned`);return{shareUrl:`${n.share_page}share-page/${n.share_token}`,userMessageIds:e.filter(e=>e.role===`user`).map(e=>String(e.id))}}},een=class{_agentShortcuts;_effectiveShortcuts;_propsShortcuts;eventEmitter;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e=null,t=[]){this._propsShortcuts=Xt(t),this._agentShortcuts=Xt([]),this.eventEmitter=e,this._effectiveShortcuts=Qr(()=>this._propsShortcuts.value.length>0?this._propsShortcuts.value:this._agentShortcuts.value.length>0?this._agentShortcuts.value:[])}get count(){return this._effectiveShortcuts.value.length}get effectiveShortcuts(){return this._effectiveShortcuts}get hasShortcuts(){return this._effectiveShortcuts.value.length>0}get shortcuts(){return this._effectiveShortcuts}addShortcut(e){this._propsShortcuts.value.push(e)}clear(){this._propsShortcuts.value=[],this._agentShortcuts.value=[]}filterByTextLength(e,t){return!e||e.length>t?[]:this._effectiveShortcuts.value}filterShortcuts(e,t){return t?this._effectiveShortcuts.value.filter(n=>t(n,e)):this._effectiveShortcuts.value}getShortcutById(e){return this._effectiveShortcuts.value.find(t=>t.id===e)}handleShortcutClick(e,t,n=`main`){this.emit(`shortcut-click`,{shortcut:e,selectedText:t,source:n})}limitShortcuts(e){return this._effectiveShortcuts.value.slice(0,e)}removeShortcut(e){this._propsShortcuts.value=this._propsShortcuts.value.filter(t=>t.id!==e)}setAgentShortcuts(e){this._agentShortcuts.value=e}setShortcuts(e){this._propsShortcuts.value=e}},ten=class{config;_panelVisible;_nimbusMinimized;_isDraggingOrResizing;_positionAndSize;_isCompressed;containerRef=null;listeners;onceListeners;debugMode;cleanupFunctions;constructor(e={}){this.config=e,this.listeners=new Map,this.onceListeners=new Map,this.debugMode=e.debug??!1,this.cleanupFunctions=[],this._panelVisible=Xt(e.initialPanelVisible??!1),this._nimbusMinimized=Xt(e.initialNimbusMinimized??!1),this._isDraggingOrResizing=Xt(!1),this._isCompressed=Xt(!1),this._positionAndSize=Xt({x:0,y:0,width:400,height:window.innerHeight})}getConfig(){return this.config}get state(){return{panelVisible:this._panelVisible,nimbusMinimized:this._nimbusMinimized,isDraggingOrResizing:this._isDraggingOrResizing,positionAndSize:this._positionAndSize}}get panelVisible(){return this._panelVisible}get nimbusMinimized(){return this._nimbusMinimized}get isDraggingOrResizing(){return this._isDraggingOrResizing}get isCompressed(){return this._isCompressed}get panel(){return{show:this.showPanel.bind(this),hide:this.hidePanel.bind(this),toggle:this.togglePanel.bind(this),isVisible:Qr(()=>this._panelVisible.value)}}showPanel(e){this._panelVisible.value=!0,this.emit(`panel-show`,{sessionCode:e})}hidePanel(){this._panelVisible.value=!1,this.emit(`panel-hide`,{})}togglePanel(){this._panelVisible.value?this.hidePanel():this.showPanel()}get nimbus(){return{minimize:this.minimizeNimbus.bind(this),restore:this.restoreNimbus.bind(this),toggle:this.toggleNimbus.bind(this),isMinimized:Qr(()=>this._nimbusMinimized.value)}}minimizeNimbus(){this._nimbusMinimized.value=!0,this.emit(`nimbus-minimize`,{})}restoreNimbus(){this._nimbusMinimized.value=!1,this.emit(`nimbus-restore`,{})}toggleNimbus(){this._nimbusMinimized.value?this.restoreNimbus():this.minimizeNimbus()}handleNimbusClick(){this.emit(`nimbus-click`,{}),this.showPanel()}get container(){return{updatePosition:this.updatePosition.bind(this),updateSize:this.updateSize.bind(this),updatePositionAndSize:this.updatePositionAndSize.bind(this),toggleCompression:this.toggleCompression.bind(this),positionAndSize:Qr(()=>this._positionAndSize.value),isCompressed:Qr(()=>this._isCompressed.value)}}updatePosition(e,t){this._positionAndSize.value={...this._positionAndSize.value,x:e,y:t}}updateSize(e,t){this._positionAndSize.value={...this._positionAndSize.value,width:e,height:t}}updatePositionAndSize(e,t,n,r){this._positionAndSize.value={x:e,y:t,width:n,height:r}}setContainerRef(e){this.containerRef=e,e?.isCompressed&&(this._isCompressed.value=e.isCompressed.value)}setCompressed(e){this._isCompressed.value=e}toggleCompression(){this.containerRef?this.containerRef.toggleCompression():this._isCompressed.value=!this._isCompressed.value}setDraggingOrResizing(e){this._isDraggingOrResizing.value=e}handleDragging(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`dragging`,e)}handleResizing(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`resizing`,e)}handleDragStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`drag-stop`,e)}handleResizeStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`resize-stop`,e)}handlePopupClick(){this.emit(`popup-click`,{}),this.showPanel()}handlePopupShortcutClick(e){this.emit(`popup-shortcut-click`,{shortcut:e}),this.emit(`shortcut-click`,{shortcut:e,source:`popup`})}handleShortcutClick(e,t){this.emit(`shortcut-click`,{shortcut:e,source:t})}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed to "${e}", total: ${this.listenerCount(e)}`),()=>{this.off(e,t)}}once(e,t){return this.onceListeners.has(e)||this.onceListeners.set(e,new Set),this.onceListeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed once to "${e}"`),()=>{this.onceListeners.get(e)?.delete(t)}}off(e,t){t?(this.listeners.get(e)?.delete(t),this.onceListeners.get(e)?.delete(t),this.debugMode&&console.debug(`[ComponentManager] Unsubscribed from "${e}", remaining: ${this.listenerCount(e)}`)):(this.listeners.delete(e),this.onceListeners.delete(e),this.debugMode&&console.debug(`[ComponentManager] Removed all listeners for "${e}"`))}emit(e,t){this.debugMode&&console.debug(`[ComponentManager] Emitting "${e}"`,t);let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in listener for "${e}":`,t)}});let r=this.onceListeners.get(e);if(r&&r.size>0){let n=Array.from(r);this.onceListeners.delete(e),n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in once listener for "${e}":`,t)}})}}emitInternal(e,t){this.emit(e,t)}listenerCount(e){return(this.listeners.get(e)?.size??0)+(this.onceListeners.get(e)?.size??0)}hasListeners(e){return this.listenerCount(e)>0}getRegisteredEvents(){let e=new Set;return this.listeners.forEach((t,n)=>e.add(n)),this.onceListeners.forEach((t,n)=>e.add(n)),Array.from(e)}setDebugMode(e){this.debugMode=e}destroy(){this.listeners.clear(),this.onceListeners.clear(),this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.debugMode&&console.debug(`[ComponentManager] Destroyed`)}};function nen(e){return new ten(e)}let ren={"panel-show":`show`,"panel-hide":`close`,"panel-toggle":null,"nimbus-click":null,"nimbus-minimize":null,"nimbus-restore":null,"popup-click":null,"popup-shortcut-click":null,dragging:`dragging`,resizing:`resizing`,"drag-stop":`drag-stop`,"resize-stop":`resize-stop`,"compression-toggle":null,"send-message":`send-message`,"receive-start":`receive-start`,"receive-text":`receive-text`,"receive-end":`receive-end`,"receive-error":null,stop:`stop`,"chat-regenerate":null,"chat-retry":null,"message-deleted":null,"messages-batch-deleted":null,"session-created":null,"session-switched":null,"session-deleted":null,"session-updated":null,"sessions-loaded":null,"session-initialized":`session-initialized`,"session-error":null,"shortcut-click":`shortcut-click`,"chat-error":null,"sdk-error":`sdk-error`,"new-chat":`new-chat`,"history-click":`history-click`,"auto-generate-name":`auto-generate-name`,"help-click":`help-click`,rename:`rename`,share:`share`,close:`close`,"toggle-compression":null,"transfer-messages":`transfer-messages`,"share-messages":`share-messages`,"agent-info-loaded":null,error:null};function ien(e,t){switch(e){case`send-message`:return[t.content];case`rename`:return[t.newName];case`history-click`:return[t.event];case`dragging`:case`resizing`:case`drag-stop`:case`resize-stop`:case`shortcut-click`:case`session-initialized`:case`sdk-error`:case`transfer-messages`:case`share-messages`:return[t];case`panel-show`:case`panel-hide`:case`receive-start`:case`receive-text`:case`receive-end`:case`stop`:case`new-chat`:case`auto-generate-name`:case`help-click`:case`share`:case`close`:return[];default:return[t]}}var aen=class{_selectedMessageIds;_isSelectionMode;_editingSessionCode;_loadingStates;constructor(){this._selectedMessageIds=Xt(new Set),this._isSelectionMode=Xt(!1),this._editingSessionCode=Xt(null),this._loadingStates=Lt({})}get isSelectionMode(){return this._isSelectionMode}get editingSessionCode(){return this._editingSessionCode}toggleSelectionMode(){this._isSelectionMode.value=!this._isSelectionMode.value,this._isSelectionMode.value||this.clearSelection()}enableSelectionMode(){this._isSelectionMode.value=!0}disableSelectionMode(){this._isSelectionMode.value=!1,this.clearSelection()}toggleMessageSelection(e){this._selectedMessageIds.value.has(e)?this._selectedMessageIds.value.delete(e):this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectMessage(e){this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}deselectMessage(e){this._selectedMessageIds.value.delete(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}isMessageSelected(e){return this._selectedMessageIds.value.has(e)}clearSelection(){this._selectedMessageIds.value.clear(),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectAllMessages(e){this._selectedMessageIds.value=new Set(e)}get selectedMessages(){return Array.from(this._selectedMessageIds.value)}get selectedCount(){return this._selectedMessageIds.value.size}get hasSelection(){return this._selectedMessageIds.value.size>0}startEditingSession(e){this._editingSessionCode.value=e}stopEditingSession(){this._editingSessionCode.value=null}isEditingSession(e){return e?this._editingSessionCode.value===e:this._editingSessionCode.value!==null}setLoading(e,t){this._loadingStates[e]=t}isLoading(e){return this._loadingStates[e]??!1}clearLoadingStates(){Object.keys(this._loadingStates).forEach(e=>{this._loadingStates[e]=!1})}reset(){this.clearSelection(),this.disableSelectionMode(),this.stopEditingSession(),this.clearLoadingStates()}},oen={class:`selection-footer`},sen={class:`selection-footer-left`},cen={class:`select-all-text`},len={class:`selection-footer-right`},uen=E9(Nn({__name:`selection-footer`,props:{isAllSelected:{type:Boolean},loading:{type:Boolean,default:!1},selectedCount:{}},emits:[`cancel`,`confirm`,`toggle-all`],setup(e){let t=e;return(e,n)=>(H(),kr(`div`,oen,[Pr(`div`,sen,[Fr(V(ff),{"model-value":t.isAllSelected,"onUpdate:modelValue":n[0]||=t=>e.$emit(`toggle-all`,t)},null,8,[`model-value`]),Pr(`span`,cen,Ce(V(D9)(`全选`)),1)]),Pr(`div`,len,[Fr(V(Hu),{disabled:t.loading,onClick:n[1]||=t=>e.$emit(`cancel`)},{default:yn(()=>[Rr(Ce(V(D9)(`取消`)),1)]),_:1},8,[`disabled`]),Fr(V(Hu),{disabled:t.selectedCount===0,loading:t.loading,theme:`primary`,onClick:n[2]||=t=>e.$emit(`confirm`)},{default:yn(()=>[Rr(Ce(V(D9)(`确定`)),1)]),_:1},8,[`disabled`,`loading`])])]))}}),[[`__scopeId`,`data-v-3247bea6`]]),den={key:0,class:`chatbot-error`},fen={class:`chatbot-loading`},pen={key:0,class:`chatbot-welcome`},men={class:`welcome-content`},hen={key:0,class:`welcome-remark`},gen={key:0,class:`chatbot-loading`},_en={key:3,class:`chatbot-input`},ven=Nn({__name:`chat-bot`,props:{autoLoad:{type:Boolean,default:!0},chatHelper:{default:void 0},enableSelection:{type:Boolean,default:!1},extCls:{},height:{},helloText:{},maxWidth:{},placeholder:{},prompts:{},requestOptions:{},resources:{default:()=>[]},sessionCode:{},shareLoading:{type:Boolean,default:!1},shortcutLimit:{default:10},shortcuts:{default:()=>[]},url:{default:``}},emits:[`agent-info-loaded`,`cancel-share`,`confirm-share`,`error`,`feedback`,`receive-end`,`receive-start`,`receive-text`,`request-share`,`send-message`,`session-switched`,`shortcut-click`,`stop`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=Xt(),o=Xt(),s=Xt(null),l=Zt([]),u=Xt(!1),d=Xt(null),f=()=>r.chatHelper?!r.chatHelper.agent||!r.chatHelper.session||!r.chatHelper.message?{valid:!1,error:`[ChatBot] Invalid chatHelper: missing required modules (agent, session, message)`}:{valid:!0}:r.url?{valid:!0}:{valid:!1,error:`[ChatBot] Neither chatHelper nor url provided. Component requires at least one.`},p=(()=>{let e=f();if(!e.valid)return console.error(e.error),d.value=Error(e.error),null;if(r.chatHelper)return r.chatHelper;let t=new z9({onStart:()=>{i(`receive-start`)},onMessage:e=>{i(`receive-text`)},onDone:()=>{i(`receive-end`),ae()},onError:e=>{i(`error`,e)}}),n=X9t({requestData:{urlPrefix:C7t(r.url),headers:r.requestOptions?.headers,data:r.requestOptions?.data},protocol:t});return t.injectMessageModule(n.message),n})(),m=Qr(()=>((r.chatHelper||p)?.agent)?.isChatting?.value?wi.Streaming:wi.Complete),h=Qr(()=>m.value===wi.Streaming?l9.Disabled:void 0),g=async(e,t)=>{if(e.id===`cite`){j.value=t.filter(e=>e.role!==Ci.Reasoning).map(e=>typeof e.content==`string`?e.content:JSON.stringify(e.content||``)).join(`
3048
- `),be();return}if(e.id===`rebuild`){await y(t);return}if(e.id===`delete`){await v(t);return}if(e.id===`share`){i(`request-share`);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await p?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},_=async(e,t,n,r)=>{if(!p){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let a=p.session.current?.value?.sessionCode;if(!a){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let o=v7t(O?.messages.value||[],t[0]);if(o===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let s=e.id===`like`?5:0;try{await p.session.postSessionFeedback({sessionCode:a,sessionContentIds:[o],rate:s,labels:n,comment:r}),i(`feedback`,e,t[0],n,r)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),i(`error`,e)}},v=async e=>{if(!O||!p){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=O.messages.value,n=_7t(t,e[0]);if(!n){console.error(`[ChatBot] No user message found before AI messages`);return}let r=[n,...e];await p.message.deleteMessages(r)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),i(`error`,e)}},y=async e=>{if(!O||!p){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let t=p.session.current?.value?.sessionCode;if(!t){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await O.regenerateFromAIMessages(e,t),ae()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),i(`error`,e)}},b=async(e,t)=>{if(e.id===`delete`){await w(t);return}if(e.id===`cite`){j.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),be();return}console.log(`handleUserAction`,e,t)},x=async(e,t,n)=>{if(!p){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let r=p.session.current?.value?.sessionCode;if(!r){console.error(`[ChatBot] Cannot edit message: no active session`);return}let a=e.id;if(a===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,a,r,t),await p.agent.resendMessage(String(a),r,t),ae()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),i(`error`,e)}},S=async(e,t)=>{if(!O||!p){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let n=p.session.current?.value?.sessionCode;if(!n){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let r=e.id;if(r===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let i=C(e);if(!i){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let a=me(i,t),o=String(t.input??``);await O.resendMessageWithProperty(String(r),n,o,a),ae()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),i(`error`,e)}},C=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?ie.value.find(e=>e.id===t.command)??null:null},w=async e=>{if(!O||!p){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=O.messages.value,n=t.findIndex(t=>t===e);if(n===-1){console.error(`[ChatBot] User message not found in messages list`);return}let r=[];for(let e=n+1;e<t.length;e++){let n=t[e];if(n.role===Ci.User)break;r.push(n)}let i=[e,...r];await p.message.deleteMessages(i)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),i(`error`,e)}},T=async()=>{((r.chatHelper||p)?.agent)?.stopChat?.(p?.session.current?.value?.sessionCode??``)},E=!r.chatHelper,D=p?new Q9t(p.session,p.message,null,{enableChatSession:!0,autoSwitchToInitialSession:!!r.sessionCode,loadRecentSessionOnMount:r.autoLoad,initialSessionCode:r.sessionCode}):null,O=p?new Z9t(p.agent,p.message,p.session,null,{openingRemark:r.helloText,predefinedQuestions:r.prompts,placeholder:r.placeholder}):null,k=new een(null,r.shortcuts||[]),A=Zt([[]]),j=Xt(``),M=Qr(()=>O?.messages.value??[]),N=Qr(()=>O?.isMessagesLoading.value??!1),P=Qr(()=>O?.isGenerating.value??!1),F=Qr(()=>D?.currentSession.value??null),I=Qr(()=>E&&!u.value?!1:!N.value&&M.value.length===0),L=Qr(()=>p?.agent.info.value?.conversationSettings?.openingRemark||``),R=Qr(()=>r.resources?.length?r.resources:b7t(p?.agent.info.value?.resources)),ee=Qr(()=>r.prompts?.length?r.prompts:p?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),te=Qr(()=>({height:typeof r.height==`number`?`${r.height}px`:r.height,maxWidth:typeof r.maxWidth==`number`?`${r.maxWidth}px`:r.maxWidth})),z=Qr(()=>{let e=k.shortcuts.value;return r.shortcutLimit&&e.length>r.shortcutLimit?e.slice(0,r.shortcutLimit):e}),B=()=>{l.value=[],i(`cancel-share`)},ne=()=>{i(`confirm-share`,l.value)},re=e=>{e?l.value=M.value:l.value=[]},ie=k.effectiveShortcuts;lr(()=>r.shortcuts,e=>{k.setShortcuts(e||[])},{immediate:!0}),lr(()=>p?.agent.info.value?.conversationSettings?.commands,e=>{e&&k.setAgentShortcuts(e)},{immediate:!0});let ae=async()=>{await mn(),a.value&&(a.value.scrollTop=a.value.scrollHeight)},oe=async(e,t={})=>{if(!O||!p)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let n=p.session.current?.value?.sessionCode;if(!n)throw Error(`[ChatBot] Cannot send message: no active session`);A.value=[[]],j.value=``,i(`send-message`,typeof e==`string`?e:``),await O.sendMessage(e,n,t)},se=async e=>{let t=p?.session.current?.value?.sessionCode;return t&&await p.session.uploadFile(t,e)||{}},ce=async(e,t)=>{try{await oe(e,j.value?{property:{extra:{cite:j.value}}}:{})}catch(e){console.error(`Failed to send message:`,e),i(`error`,e)}},le=async()=>{ge()},ue=(e,t)=>{de(e,t),i(`shortcut-click`,{shortcut:e,source:`main`})},de=(e,t)=>{let n=e,r=n.components?.find(e=>e.fillBack)?.key||`input`;s.value={...n,formModel:{...n.formModel,[r]:t||``}}},pe=()=>{s.value=null},me=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},he=async e=>{if(!s.value){console.error(`[ChatBot] No selected shortcut`);return}let t=me(s.value,e),n=s.value.name,r=s.value;pe();try{await oe(n,{property:t})}catch(e){s.value=r,console.error(`[ChatBot] Failed to submit shortcut:`,e),i(`error`,e)}},ge=()=>{if(!O){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}O.stopGeneration(),i(`stop`)},ve=async e=>{if(!D){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await D.switchSession(e),i(`session-switched`,D.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),i(`error`,e)}},ye=e=>{j.value=e},be=()=>{o.value?.focus?.()};return Vn(async()=>{if(!(!p||d.value))try{if(E){if(await p.agent.getAgentInfo(),await p.session.getSessions(),r.sessionCode)await p.session.chooseSession(r.sessionCode);else if(p.session.list.value.length>0){let e=p.session.list.value[0];await p.session.chooseSession(e.sessionCode)}u.value=!0}else u.value=!0;i(`agent-info-loaded`,p)}catch(e){console.error(`Failed to initialize ChatBot:`,e),d.value=e,i(`error`,e)}}),Hn(()=>{E&&p&&p.agent.stopChat(p.session.current?.value?.sessionCode??``)}),t({sendMessage:e=>ce(e,[[]]),stopGeneration:ge,switchSession:ve,messages:M,currentSession:F,isGenerating:P,getChatHelper:()=>p,setCiteText:ye,focusInput:be,selectShortcut:(e,t)=>{de(e,t)}}),(e,t)=>(H(),kr(`div`,{class:_e([`ai-chatbot`,r.extCls,{"welcome-state":I.value}]),style:fe(te.value)},[zr(` 初始化错误提示 `),d.value?(H(),kr(`div`,den,[Pr(`span`,null,Ce(d.value.message),1)])):E&&!u.value?(H(),kr(xr,{key:1},[zr(` 独立模式:初始化中(getAgentInfo → getSessions → chooseSession)统一展示 Loading `),Pr(`div`,fen,[Fr(V(Pu),{mode:`spin`,size:`small`,theme:`primary`})])],2112)):(H(),kr(xr,{key:2},[zr(` 内容区:欢迎状态 `),I.value?(H(),kr(`div`,pen,[Pr(`div`,men,[t[3]||=Pr(`h2`,{class:`welcome-title`},`你好,我是小鲸`,-1),L.value?(H(),kr(`div`,hen,[Fr(V(e3t),{content:L.value},null,8,[`content`])])):zr(`v-if`,!0)])])):(H(),kr(xr,{key:1},[zr(` 内容区:消息列表 `),Pr(`div`,{ref_key:`messagesContainerRef`,ref:a,class:`chatbot-messages`},[N.value?(H(),kr(`div`,gen,[Fr(V(Pu),{mode:`spin`,size:`small`,theme:`primary`})])):(H(),Ar(V(h7t),{key:1,"selected-messages":l.value,"onUpdate:selectedMessages":t[0]||=e=>l.value=e,"enable-selection":r.enableSelection,"message-status":m.value,"message-tools-status":h.value,messages:M.value,"on-agent-action":g,"on-agent-feedback":_,"on-user-action":b,"on-user-input-confirm":x,"on-user-shortcut-confirm":S,onStopStreaming:T},null,8,[`selected-messages`,`enable-selection`,`message-status`,`message-tools-status`,`messages`]))],512)],2112)),zr(` 统一底部区域 `),!I.value&&r.enableSelection?(H(),Ar(uen,{key:2,"is-all-selected":l.value.length===M.value.length,loading:r.shareLoading,"selected-count":l.value.length,onCancel:B,onConfirm:ne,onToggleAll:re},null,8,[`is-all-selected`,`loading`,`selected-count`])):(H(),kr(`div`,_en,[s.value?.components?.length?(H(),Ar(V(wDe),Ur({key:0},s.value,{onClose:pe,onSubmit:he}),null,16)):qn(e.$slots,`input`,{key:1},()=>[Fr(V(e5t),{ref_key:`chatInputRef`,ref:o,modelValue:A.value,"onUpdate:modelValue":t[1]||=e=>A.value=e,cite:j.value,"onUpdate:cite":t[2]||=e=>j.value=e,"message-status":m.value,"on-send-message":ce,"on-stop-sending":le,"on-upload":se,placeholder:r.placeholder,prompts:ee.value,resources:R.value,"shortcut-id":s.value?.id,shortcuts:z.value,onSelectShortcut:ue},null,8,[`modelValue`,`cite`,`message-status`,`placeholder`,`prompts`,`resources`,`shortcut-id`,`shortcuts`])])]))],64))],6))}});let K9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function yen(e){let{url:t,requestOptions:n,autoInit:r=!0,protocolCallbacks:i}=e,a=Qt(t);if(!a)throw Error(`[useChatBootstrap] url is required`);let o=Xt(K9.IDLE),s=Xt(null),l=Xt(!1),u=new Map,d=new z9({onStart:()=>{i?.onStart?.()},onMessage:e=>{i?.onMessage?.(e)},onDone:()=>{i?.onDone?.()},onError:e=>{i?.onError?.(e)}}),f=X9t({requestData:{urlPrefix:a,headers:n?.headers,data:n?.data},protocol:d});d.injectMessageModule(f.message);let p=Qr(()=>o.value===K9.LOADING_AGENT),m=Qr(()=>o.value===K9.READY),h=Qr(()=>f.agent.info.value??null),g=Qr(()=>h.value?.agentName??``),_=Qr(()=>f.session.current.value??null),v=Qr(()=>f.session.list.value??[]),y=async()=>{if(!l.value&&!p.value){s.value=null;try{o.value=K9.LOADING_AGENT,await Promise.all([f.agent.getAgentInfo(),f.session.getSessions()]),o.value=K9.READY,l.value=!0}catch(e){throw console.error(`[useChatBootstrap] Initialization failed:`,e),s.value=e,o.value=K9.ERROR,e}}},b=async()=>{o.value=K9.IDLE,s.value=null,l.value=!1,await y()},x=async e=>{o.value=K9.IDLE,s.value=null,l.value=!1;let t=f.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await y()};return lr(()=>Qt(t),(e,t)=>{e&&e!==t&&t&&x(e)}),r&&Promise.resolve().then(()=>{y()}),{chatHelper:f,protocol:d,phase:o,isInitializing:p,isReady:m,error:s,agentInfo:h,agentName:g,currentSession:_,sessionList:v,initialize:y,retry:b,updateConfig:x,registerExtension:(e,t)=>{u.set(e,t)},getExtension:e=>u.get(e)}}function ben(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function xen(e){let{componentManager:t,emit:n,debug:r=!1}=e,i=[],a=()=>{for(let[e,a]of Object.entries(ren)){if(a===null)continue;let o=t.on(e,t=>{let i=ien(e,t);r&&console.debug(`[useEventBridge] ${e} -> ${a}`,i),n(a,...i)});i.push(o)}},o=(e,n)=>{r&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,n),t.emit(e,n)},s=(e,...t)=>{r&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),n(e,...t)},l=()=>{i.forEach(e=>e()),i.length=0};return a(),Un(()=>{l()}),{forwardToManager:o,emitDirect:s,cleanup:l}}function Sen(e,t=!1){let n=window.innerHeight-48-40,r=window.innerWidth-48-16,i=Xt(r),a=Xt(n),o=Xt(0),s=Xt(t),l=Xt(!1),u=Xt(!1),d=0,f=e=>{e?i.value=window.innerWidth-12:i.value=r},p=(e,t)=>{a.value=t,o.value=t-n},m=()=>{mn(()=>{a.value=window.innerHeight-48-40+o.value,s.value?i.value=window.innerWidth-12:i.value=window.innerWidth-48-16})};return Vn(()=>{window.addEventListener(`resize`,m),m()}),Un(()=>{window.removeEventListener(`resize`,m)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:i,nimbusTop:a,isMinimize:s,isHovering:l,isDragging:u,handleNimbusDragging:p,handleNimbusMinimize:f,handleClick:()=>{if(u.value){u.value=!1;return}e(`click`)},handleMinimize:()=>{s.value=!s.value,e(`minimize`,s.value),s.value?i.value=window.innerWidth-12:i.value=window.innerWidth-60},handleDragging:(e,t)=>{i.value=e,a.value=t},handleMouseEnter:()=>{l.value=!0},handleMouseLeave:()=>{l.value=!1},handleMouseDown:()=>{d=Date.now(),u.value=!1},handleMouseUp:()=>{Date.now()-d>200&&(u.value=!0)}}}T9();function Cen(e={}){let t=Xt([]),n=(n,r,i={})=>{try{let a=typeof n==`string`?document.querySelector(n):n;if(!a)return console.warn(`Tooltip target not found: ${n}`),null;let o=w9(a,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return t.value.push(o),o}catch(e){return console.error(`Failed to create tooltip:`,e),null}},r=(e,t,r={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=n(e,t,r);i&&a.push(i)}),a},i=e=>{let t=[];return e.forEach(({element:e,content:r,options:i})=>{let a=n(e,r,i);a&&t.push(a)}),t},a=()=>{t.value.forEach(e=>{e.destroy()}),t.value=[]};return Hn(()=>{a()}),{instances:t,createTooltip:n,createTooltipsForSelector:r,createMultipleTooltips:i,destroyAll:a,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}let wen={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:D9(`输入 "/" 唤出 Prompt
3048
+ `),be();return}if(e.id===`rebuild`){await y(t);return}if(e.id===`delete`){await v(t);return}if(e.id===`share`){i(`request-share`);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await p?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},_=async(e,t,n,r)=>{if(!p){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let a=p.session.current?.value?.sessionCode;if(!a){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let o=v7t(O?.messages.value||[],t[0]);if(o===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let s=e.id===`like`?5:0;try{await p.session.postSessionFeedback({sessionCode:a,sessionContentIds:[o],rate:s,labels:n,comment:r}),i(`feedback`,e,t[0],n,r)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),i(`error`,e)}},v=async e=>{if(!O||!p){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=O.messages.value,n=_7t(t,e[0]);if(!n){console.error(`[ChatBot] No user message found before AI messages`);return}let r=[n,...e];await p.message.deleteMessages(r)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),i(`error`,e)}},y=async e=>{if(!O||!p){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let t=p.session.current?.value?.sessionCode;if(!t){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await O.regenerateFromAIMessages(e,t),ae()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),i(`error`,e)}},b=async(e,t)=>{if(e.id===`delete`){await w(t);return}if(e.id===`cite`){j.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),be();return}console.log(`handleUserAction`,e,t)},x=async(e,t,n)=>{if(!p){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let r=p.session.current?.value?.sessionCode;if(!r){console.error(`[ChatBot] Cannot edit message: no active session`);return}let a=e.id;if(a===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,a,r,t),await p.agent.resendMessage(String(a),r,t),ae()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),i(`error`,e)}},S=async(e,t)=>{if(!O||!p){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let n=p.session.current?.value?.sessionCode;if(!n){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let r=e.id;if(r===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let i=C(e);if(!i){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let a=me(i,t),o=String(t.input??``);await O.resendMessageWithProperty(String(r),n,o,a),ae()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),i(`error`,e)}},C=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?ie.value.find(e=>e.id===t.command)??null:null},w=async e=>{if(!O||!p){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=O.messages.value,n=t.findIndex(t=>t===e);if(n===-1){console.error(`[ChatBot] User message not found in messages list`);return}let r=[];for(let e=n+1;e<t.length;e++){let n=t[e];if(n.role===Ci.User)break;r.push(n)}let i=[e,...r];await p.message.deleteMessages(i)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),i(`error`,e)}},T=async()=>{((r.chatHelper||p)?.agent)?.stopChat?.(p?.session.current?.value?.sessionCode??``)},E=!r.chatHelper,D=p?new Q9t(p.session,p.message,null,{enableChatSession:!0,autoSwitchToInitialSession:!!r.sessionCode,loadRecentSessionOnMount:r.autoLoad,initialSessionCode:r.sessionCode}):null,O=p?new Z9t(p.agent,p.message,p.session,null,{openingRemark:r.helloText,predefinedQuestions:r.prompts,placeholder:r.placeholder}):null,k=new een(null,r.shortcuts||[]),A=Zt([[]]),j=Xt(``),M=Qr(()=>O?.messages.value??[]),N=Qr(()=>O?.isMessagesLoading.value??!1),P=Qr(()=>O?.isGenerating.value??!1),F=Qr(()=>D?.currentSession.value??null),I=Qr(()=>E&&!u.value?!1:!N.value&&M.value.length===0),L=Qr(()=>p?.agent.info.value?.conversationSettings?.openingRemark||``),R=Qr(()=>r.resources?.length?r.resources:b7t(p?.agent.info.value?.resources)),ee=Qr(()=>r.prompts?.length?r.prompts:p?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),te=Qr(()=>({height:typeof r.height==`number`?`${r.height}px`:r.height,maxWidth:typeof r.maxWidth==`number`?`${r.maxWidth}px`:r.maxWidth})),z=Qr(()=>{let e=k.shortcuts.value;return r.shortcutLimit&&e.length>r.shortcutLimit?e.slice(0,r.shortcutLimit):e}),B=()=>{l.value=[],i(`cancel-share`)},ne=()=>{i(`confirm-share`,l.value)},re=e=>{e?l.value=M.value:l.value=[]},ie=k.effectiveShortcuts;lr(()=>r.shortcuts,e=>{k.setShortcuts(e||[])},{immediate:!0}),lr(()=>p?.agent.info.value?.conversationSettings?.commands,e=>{e&&k.setAgentShortcuts(e)},{immediate:!0});let ae=async()=>{await mn(),a.value&&(a.value.scrollTop=a.value.scrollHeight)},oe=async(e,t={})=>{if(!O||!p)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let n=p.session.current?.value?.sessionCode;if(!n)throw Error(`[ChatBot] Cannot send message: no active session`);A.value=[[]],j.value=``,i(`send-message`,typeof e==`string`?e:``),await O.sendMessage(e,n,t)},se=async e=>{let t=p?.session.current?.value?.sessionCode;if(!t)throw Error(`[ChatBot] Cannot upload: no active session`);let n=await p.session.uploadFile(t,e);if(!n?.download_url)throw Error(`[ChatBot] Upload failed: no download URL returned`);return n},ce=async(e,t)=>{try{await oe(e,j.value?{property:{extra:{cite:j.value}}}:{})}catch(e){console.error(`Failed to send message:`,e),i(`error`,e)}},le=async()=>{ge()},ue=(e,t)=>{de(e,t),i(`shortcut-click`,{shortcut:e,source:`main`})},de=(e,t)=>{let n=e,r=n.components?.find(e=>e.fillBack)?.key||`input`;s.value={...n,formModel:{...n.formModel,[r]:t||``}}},pe=()=>{s.value=null},me=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},he=async e=>{if(!s.value){console.error(`[ChatBot] No selected shortcut`);return}let t=me(s.value,e),n=s.value.name,r=s.value;pe();try{await oe(n,{property:t})}catch(e){s.value=r,console.error(`[ChatBot] Failed to submit shortcut:`,e),i(`error`,e)}},ge=()=>{if(!O){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}O.stopGeneration(),i(`stop`)},ve=async e=>{if(!D){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await D.switchSession(e),i(`session-switched`,D.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),i(`error`,e)}},ye=e=>{j.value=e},be=()=>{o.value?.focus?.()};return Vn(async()=>{if(!(!p||d.value))try{if(E){if(await p.agent.getAgentInfo(),await p.session.getSessions(),r.sessionCode)await p.session.chooseSession(r.sessionCode);else if(p.session.list.value.length>0){let e=p.session.list.value[0];await p.session.chooseSession(e.sessionCode)}u.value=!0}else u.value=!0;i(`agent-info-loaded`,p)}catch(e){console.error(`Failed to initialize ChatBot:`,e),d.value=e,i(`error`,e)}}),Hn(()=>{E&&p&&p.agent.stopChat(p.session.current?.value?.sessionCode??``)}),t({sendMessage:e=>ce(e,[[]]),stopGeneration:ge,switchSession:ve,messages:M,currentSession:F,isGenerating:P,getChatHelper:()=>p,setCiteText:ye,focusInput:be,selectShortcut:(e,t)=>{de(e,t)}}),(e,t)=>(H(),kr(`div`,{class:_e([`ai-chatbot`,r.extCls,{"welcome-state":I.value}]),style:fe(te.value)},[zr(` 初始化错误提示 `),d.value?(H(),kr(`div`,den,[Pr(`span`,null,Ce(d.value.message),1)])):E&&!u.value?(H(),kr(xr,{key:1},[zr(` 独立模式:初始化中(getAgentInfo → getSessions → chooseSession)统一展示 Loading `),Pr(`div`,fen,[Fr(V(Pu),{mode:`spin`,size:`small`,theme:`primary`})])],2112)):(H(),kr(xr,{key:2},[zr(` 内容区:欢迎状态 `),I.value?(H(),kr(`div`,pen,[Pr(`div`,men,[t[3]||=Pr(`h2`,{class:`welcome-title`},`你好,我是小鲸`,-1),L.value?(H(),kr(`div`,hen,[Fr(V(e3t),{content:L.value},null,8,[`content`])])):zr(`v-if`,!0)])])):(H(),kr(xr,{key:1},[zr(` 内容区:消息列表 `),Pr(`div`,{ref_key:`messagesContainerRef`,ref:a,class:`chatbot-messages`},[N.value?(H(),kr(`div`,gen,[Fr(V(Pu),{mode:`spin`,size:`small`,theme:`primary`})])):(H(),Ar(V(h7t),{key:1,"selected-messages":l.value,"onUpdate:selectedMessages":t[0]||=e=>l.value=e,"enable-selection":r.enableSelection,"message-status":m.value,"message-tools-status":h.value,messages:M.value,"on-agent-action":g,"on-agent-feedback":_,"on-user-action":b,"on-user-input-confirm":x,"on-user-shortcut-confirm":S,onStopStreaming:T},null,8,[`selected-messages`,`enable-selection`,`message-status`,`message-tools-status`,`messages`]))],512)],2112)),zr(` 统一底部区域 `),!I.value&&r.enableSelection?(H(),Ar(uen,{key:2,"is-all-selected":l.value.length===M.value.length,loading:r.shareLoading,"selected-count":l.value.length,onCancel:B,onConfirm:ne,onToggleAll:re},null,8,[`is-all-selected`,`loading`,`selected-count`])):(H(),kr(`div`,_en,[s.value?.components?.length?(H(),Ar(V(wDe),Ur({key:0},s.value,{onClose:pe,onSubmit:he}),null,16)):qn(e.$slots,`input`,{key:1},()=>[Fr(V(e5t),{ref_key:`chatInputRef`,ref:o,modelValue:A.value,"onUpdate:modelValue":t[1]||=e=>A.value=e,cite:j.value,"onUpdate:cite":t[2]||=e=>j.value=e,"message-status":m.value,"on-send-message":ce,"on-stop-sending":le,"on-upload":se,placeholder:r.placeholder,prompts:ee.value,resources:R.value,"shortcut-id":s.value?.id,shortcuts:z.value,onSelectShortcut:ue},null,8,[`modelValue`,`cite`,`message-status`,`placeholder`,`prompts`,`resources`,`shortcut-id`,`shortcuts`])])]))],64))],6))}});let K9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function yen(e){let{url:t,requestOptions:n,autoInit:r=!0,protocolCallbacks:i}=e,a=Qt(t);if(!a)throw Error(`[useChatBootstrap] url is required`);let o=Xt(K9.IDLE),s=Xt(null),l=Xt(!1),u=new Map,d=new z9({onStart:()=>{i?.onStart?.()},onMessage:e=>{i?.onMessage?.(e)},onDone:()=>{i?.onDone?.()},onError:e=>{i?.onError?.(e)}}),f=X9t({requestData:{urlPrefix:a,headers:n?.headers,data:n?.data},protocol:d});d.injectMessageModule(f.message);let p=Qr(()=>o.value===K9.LOADING_AGENT),m=Qr(()=>o.value===K9.READY),h=Qr(()=>f.agent.info.value??null),g=Qr(()=>h.value?.agentName??``),_=Qr(()=>f.session.current.value??null),v=Qr(()=>f.session.list.value??[]),y=async()=>{if(!l.value&&!p.value){s.value=null;try{o.value=K9.LOADING_AGENT,await Promise.all([f.agent.getAgentInfo(),f.session.getSessions()]),o.value=K9.READY,l.value=!0}catch(e){throw console.error(`[useChatBootstrap] Initialization failed:`,e),s.value=e,o.value=K9.ERROR,e}}},b=async()=>{o.value=K9.IDLE,s.value=null,l.value=!1,await y()},x=async e=>{o.value=K9.IDLE,s.value=null,l.value=!1;let t=f.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await y()};return lr(()=>Qt(t),(e,t)=>{e&&e!==t&&t&&x(e)}),r&&Promise.resolve().then(()=>{y()}),{chatHelper:f,protocol:d,phase:o,isInitializing:p,isReady:m,error:s,agentInfo:h,agentName:g,currentSession:_,sessionList:v,initialize:y,retry:b,updateConfig:x,registerExtension:(e,t)=>{u.set(e,t)},getExtension:e=>u.get(e)}}function ben(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function xen(e){let{componentManager:t,emit:n,debug:r=!1}=e,i=[],a=()=>{for(let[e,a]of Object.entries(ren)){if(a===null)continue;let o=t.on(e,t=>{let i=ien(e,t);r&&console.debug(`[useEventBridge] ${e} -> ${a}`,i),n(a,...i)});i.push(o)}},o=(e,n)=>{r&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,n),t.emit(e,n)},s=(e,...t)=>{r&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),n(e,...t)},l=()=>{i.forEach(e=>e()),i.length=0};return a(),Un(()=>{l()}),{forwardToManager:o,emitDirect:s,cleanup:l}}function Sen(e,t=!1){let n=window.innerHeight-48-40,r=window.innerWidth-48-16,i=Xt(r),a=Xt(n),o=Xt(0),s=Xt(t),l=Xt(!1),u=Xt(!1),d=0,f=e=>{e?i.value=window.innerWidth-12:i.value=r},p=(e,t)=>{a.value=t,o.value=t-n},m=()=>{mn(()=>{a.value=window.innerHeight-48-40+o.value,s.value?i.value=window.innerWidth-12:i.value=window.innerWidth-48-16})};return Vn(()=>{window.addEventListener(`resize`,m),m()}),Un(()=>{window.removeEventListener(`resize`,m)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:i,nimbusTop:a,isMinimize:s,isHovering:l,isDragging:u,handleNimbusDragging:p,handleNimbusMinimize:f,handleClick:()=>{if(u.value){u.value=!1;return}e(`click`)},handleMinimize:()=>{s.value=!s.value,e(`minimize`,s.value),s.value?i.value=window.innerWidth-12:i.value=window.innerWidth-60},handleDragging:(e,t)=>{i.value=e,a.value=t},handleMouseEnter:()=>{l.value=!0},handleMouseLeave:()=>{l.value=!1},handleMouseDown:()=>{d=Date.now(),u.value=!1},handleMouseUp:()=>{Date.now()-d>200&&(u.value=!0)}}}T9();function Cen(e={}){let t=Xt([]),n=(n,r,i={})=>{try{let a=typeof n==`string`?document.querySelector(n):n;if(!a)return console.warn(`Tooltip target not found: ${n}`),null;let o=w9(a,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return t.value.push(o),o}catch(e){return console.error(`Failed to create tooltip:`,e),null}},r=(e,t,r={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=n(e,t,r);i&&a.push(i)}),a},i=e=>{let t=[];return e.forEach(({element:e,content:r,options:i})=>{let a=n(e,r,i);a&&t.push(a)}),t},a=()=>{t.value.forEach(e=>{e.destroy()}),t.value=[]};return Hn(()=>{a()}),{instances:t,createTooltip:n,createTooltipsForSelector:r,createMultipleTooltips:i,destroyAll:a,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}let wen={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:D9(`输入 "/" 唤出 Prompt
3049
3049
  通过 Shift + Enter 进行换行输入`),helloText:D9(`你好,我是小鲸`),disabledInput:!1,showHistoryIcon:!0,showNewChatIcon:!0,showCompressionIcon:!0,showMoreIcon:!0,initialSessionCode:``,autoSwitchToInitialSession:!1,loadRecentSessionOnMount:!0,prompts:()=>[],dropdownMenuConfig:()=>({showRename:!0,showAutoGenerate:!0,showShare:!0}),defaultChatInputPosition:void 0};function Ten(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function q9(e,t,n,r=1){let[i,a]=typeof r==`number`?[r,r]:r;return[Math.round(t/i/e[0])*e[0],Math.round(n/a/e[1])*e[1]]}function Een(e,t,n){return e-t-n}function Den(e,t,n){return e-t-n}function J9(e,t,n){return t!==null&&e<t?t:n!==null&&n<e?n:e}function Oen(e,t,n){let r=e,i=[`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`].find(e=>Ten(r[e]));if(!Ten(r[i]))return!1;do{if(r[i](t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function ken(e){let t=window.getComputedStyle(e);return[parseFloat(t.getPropertyValue(`width`),10),parseFloat(t.getPropertyValue(`height`),10)]}function Y9(e,t,n){e&&(e.attachEvent?e.attachEvent(`on`+t,n):e.addEventListener?e.addEventListener(t,n,!0):e[`on`+t]=n)}function X9(e,t,n){e&&(e.detachEvent?e.detachEvent(`on`+t,n):e.removeEventListener?e.removeEventListener(t,n,!0):e[`on`+t]=null)}var Aen=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Z9={mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`},touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`}},jen={userSelect:`none`,MozUserSelect:`none`,WebkitUserSelect:`none`,MsUserSelect:`none`},Men={userSelect:`auto`,MozUserSelect:`auto`,WebkitUserSelect:`auto`,MsUserSelect:`auto`},Q9=Z9.mouse,Nen={replace:!0,name:`vue-draggable-resizable`,props:{className:{type:String,default:`vdr`},classNameDraggable:{type:String,default:`draggable`},classNameResizable:{type:String,default:`resizable`},classNameDragging:{type:String,default:`dragging`},classNameResizing:{type:String,default:`resizing`},classNameActive:{type:String,default:`active`},classNameHandle:{type:String,default:`handle`},disableUserSelect:{type:Boolean,default:!0},enableNativeDrag:{type:Boolean,default:!1},preventDeactivation:{type:Boolean,default:!1},active:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},w:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},h:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},minWidth:{type:Number,default:0,validator:e=>e>=0},minHeight:{type:Number,default:0,validator:e=>e>=0},maxWidth:{type:Number,default:null,validator:e=>e>=0},maxHeight:{type:Number,default:null,validator:e=>e>=0},x:{type:Number,default:0},y:{type:Number,default:0},z:{type:[String,Number],default:`auto`,validator:e=>typeof e==`string`?e===`auto`:e>=0},handles:{type:Array,default:()=>[`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`],validator:e=>{let t=new Set([`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`]);return new Set(e.filter(e=>t.has(e))).size===e.length}},dragHandle:{type:String,default:null},dragCancel:{type:String,default:null},axis:{type:String,default:`both`,validator:e=>[`x`,`y`,`both`].includes(e)},grid:{type:Array,default:()=>[1,1]},parent:{type:Boolean,default:!1},scale:{type:[Number,Array],default:1,validator:e=>typeof e==`number`?e>0:e.length===2&&e[0]>0&&e[1]>0},onDragStart:{type:Function,default:()=>!0},onDrag:{type:Function,default:()=>!0},onResizeStart:{type:Function,default:()=>!0},onResize:{type:Function,default:()=>!0}},data:function(){return{left:this.x,top:this.y,right:null,bottom:null,width:null,height:null,widthTouched:!1,heightTouched:!1,aspectFactor:null,parentWidth:null,parentHeight:null,handle:null,enabled:this.active,resizing:!1,dragging:!1,dragEnable:!1,resizeEnable:!1,zIndex:this.z}},created:function(){this.maxWidth&&this.minWidth>this.maxWidth&&console.warn(`[Vdr warn]: Invalid prop: minWidth cannot be greater than maxWidth`),this.maxHeight&&this.minHeight>this.maxHeight&&console.warn(`[Vdr warn]: Invalid prop: minHeight cannot be greater than maxHeight`),this.resetBoundsAndMouseState()},mounted:function(){this.enableNativeDrag||(this.$el.ondragstart=()=>!1);let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t;let[n,r]=ken(this.$el);this.aspectFactor=(this.w===`auto`?n:this.w)/(this.h===`auto`?r:this.h),this.width=this.w===`auto`?n:this.w,this.height=this.h===`auto`?r:this.h,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top,this.active&&this.$emit(`activated`),Y9(document.documentElement,`mousedown`,this.deselect),Y9(document.documentElement,`touchend touchcancel`,this.deselect),Y9(window,`resize`,this.checkParentSize)},beforeUnmount:function(){X9(document.documentElement,`mousedown`,this.deselect),X9(document.documentElement,`touchstart`,this.handleUp),X9(document.documentElement,`mousemove`,this.move),X9(document.documentElement,`touchmove`,this.move),X9(document.documentElement,`mouseup`,this.handleUp),X9(document.documentElement,`touchend touchcancel`,this.deselect),X9(window,`resize`,this.checkParentSize)},methods:{resetBoundsAndMouseState(){this.mouseClickPosition={mouseX:0,mouseY:0,x:0,y:0,w:0,h:0},this.bounds={minLeft:null,maxLeft:null,minRight:null,maxRight:null,minTop:null,maxTop:null,minBottom:null,maxBottom:null}},checkParentSize(){if(this.parent){let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top}},getParentSize(){if(this.parent){let e=window.getComputedStyle(this.$el.parentNode,null);return[parseInt(e.getPropertyValue(`width`),10),parseInt(e.getPropertyValue(`height`),10)]}return[null,null]},elementTouchDown(e){Q9=Z9.touch,this.elementDown(e)},elementMouseDown(e){Q9=Z9.mouse,this.elementDown(e)},elementDown(e){if(e instanceof MouseEvent&&e.button!==0)return;let t=e.target||e.srcElement;if(this.$el.contains(t)){if(this.onDragStart(e)===!1)return;if(this.dragHandle&&!Oen(t,this.dragHandle,this.$el)||this.dragCancel&&Oen(t,this.dragCancel,this.$el)){this.dragging=!1;return}this.enabled||(this.enabled=!0,this.$emit(`activated`),this.$emit(`update:active`,!0)),this.draggable&&(this.dragEnable=!0),this.mouseClickPosition.mouseX=e.touches?e.touches[0].pageX:e.pageX,this.mouseClickPosition.mouseY=e.touches?e.touches[0].pageY:e.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.parent&&(this.bounds=this.calcDragLimits()),Y9(document.documentElement,Q9.move,this.move),Y9(document.documentElement,Q9.stop,this.handleUp)}},calcDragLimits(){return{minLeft:this.left%this.grid[0],maxLeft:Math.floor((this.parentWidth-this.width-this.left)/this.grid[0])*this.grid[0]+this.left,minRight:this.right%this.grid[0],maxRight:Math.floor((this.parentWidth-this.width-this.right)/this.grid[0])*this.grid[0]+this.right,minTop:this.top%this.grid[1],maxTop:Math.floor((this.parentHeight-this.height-this.top)/this.grid[1])*this.grid[1]+this.top,minBottom:this.bottom%this.grid[1],maxBottom:Math.floor((this.parentHeight-this.height-this.bottom)/this.grid[1])*this.grid[1]+this.bottom}},deselect(e){let t=e.target||e.srcElement,n=RegExp(this.className+`-([trmbl]{2})`,``);!this.$el.contains(t)&&!n.test(t.className)&&(this.enabled&&!this.preventDeactivation&&(this.enabled=!1,this.$emit(`deactivated`),this.$emit(`update:active`,!1)),X9(document.documentElement,Q9.move,this.handleResize)),this.resetBoundsAndMouseState()},handleTouchDown(e,t){Q9=Z9.touch,this.handleDown(e,t)},handleDown(e,t){t instanceof MouseEvent&&t.which!==1||this.onResizeStart(e,t)!==!1&&(t.stopPropagation&&t.stopPropagation(),this.lockAspectRatio&&!e.includes(`m`)?this.handle=`m`+e.substring(1):this.handle=e,this.resizeEnable=!0,this.mouseClickPosition.mouseX=t.touches?t.touches[0].pageX:t.pageX,this.mouseClickPosition.mouseY=t.touches?t.touches[0].pageY:t.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.bounds=this.calcResizeLimits(),Y9(document.documentElement,Q9.move,this.handleResize),Y9(document.documentElement,Q9.stop,this.handleUp))},calcResizeLimits(){let e=this.minW,t=this.minH,n=this.maxW,r=this.maxH,i=this.aspectFactor,[a,o]=this.grid,s=this.width,l=this.height,u=this.left,d=this.top,f=this.right,p=this.bottom;this.lockAspectRatio&&(e/t>i?t=e/i:e=i*t,n&&r?(n=Math.min(n,i*r),r=Math.min(r,n/i)):n?r=n/i:r&&(n=i*r)),n-=n%a,r-=r%o;let m={minLeft:null,maxLeft:null,minTop:null,maxTop:null,minRight:null,maxRight:null,minBottom:null,maxBottom:null};return this.parent?(m.minLeft=u%a,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=d%o,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=f%a,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=p%o,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=Math.max(m.minLeft,this.parentWidth-f-n),m.minRight=Math.max(m.minRight,this.parentWidth-u-n)),r&&(m.minTop=Math.max(m.minTop,this.parentHeight-p-r),m.minBottom=Math.max(m.minBottom,this.parentHeight-d-r)),this.lockAspectRatio&&(m.minLeft=Math.max(m.minLeft,u-d*i),m.minTop=Math.max(m.minTop,d-u/i),m.minRight=Math.max(m.minRight,f-p*i),m.minBottom=Math.max(m.minBottom,p-f/i))):(m.minLeft=null,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=null,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=null,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=null,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=-(f+n),m.minRight=-(u+n)),r&&(m.minTop=-(p+r),m.minBottom=-(d+r)),this.lockAspectRatio&&n&&r&&(m.minLeft=Math.min(m.minLeft,-(f+n)),m.minTop=Math.min(m.minTop,-(r+p)),m.minRight=Math.min(m.minRight,-u-n),m.minBottom=Math.min(m.minBottom,-d-r))),m},move(e){this.resizing?this.handleResize(e):this.dragEnable&&this.handleDrag(e)},handleDrag(e){let t=this.axis,n=this.grid,r=this.bounds,i=this.mouseClickPosition,[a,o]=q9(n,t&&t!==`y`?i.mouseX-(e.touches?e.touches[0].pageX:e.pageX):0,t&&t!==`x`?i.mouseY-(e.touches?e.touches[0].pageY:e.pageY):0,this.scale),s=J9(i.left-a,r.minLeft,r.maxLeft),l=J9(i.top-o,r.minTop,r.maxTop);if(this.onDrag(s,l)===!1)return;let u=J9(i.right+a,r.minRight,r.maxRight),d=J9(i.bottom+o,r.minBottom,r.maxBottom);this.left=s,this.top=l,this.right=u,this.bottom=d,this.$emit(`dragging`,this.left,this.top),this.dragging=!0},moveHorizontally(e){let[t,n]=q9(this.grid,e,this.top,1),r=J9(t,this.bounds.minLeft,this.bounds.maxLeft);this.left=r,this.right=this.parentWidth-this.width-r},moveVertically(e){let[t,n]=q9(this.grid,this.left,e,1),r=J9(n,this.bounds.minTop,this.bounds.maxTop);this.top=r,this.bottom=this.parentHeight-this.height-r},handleResize(e){let t=this.left,n=this.top,r=this.right,i=this.bottom,a=this.mouseClickPosition,o=this.aspectFactor,s=a.mouseX-(e.touches?e.touches[0].pageX:e.pageX),l=a.mouseY-(e.touches?e.touches[0].pageY:e.pageY);!this.widthTouched&&s&&(this.widthTouched=!0),!this.heightTouched&&l&&(this.heightTouched=!0);let[u,d]=q9(this.grid,s,l,this.scale);this.handle.includes(`b`)?(i=J9(a.bottom+d,this.bounds.minBottom,this.bounds.maxBottom),this.lockAspectRatio&&this.resizingOnY&&(r=this.right-(this.bottom-i)*o)):this.handle.includes(`t`)&&(n=J9(a.top-d,this.bounds.minTop,this.bounds.maxTop),this.lockAspectRatio&&this.resizingOnY&&(t=this.left-(this.top-n)*o)),this.handle.includes(`r`)?(r=J9(a.right+u,this.bounds.minRight,this.bounds.maxRight),this.lockAspectRatio&&this.resizingOnX&&(i=this.bottom-(this.right-r)/o)):this.handle.includes(`l`)&&(t=J9(a.left-u,this.bounds.minLeft,this.bounds.maxLeft),this.lockAspectRatio&&this.resizingOnX&&(n=this.top-(this.left-t)/o));let f=Een(this.parentWidth,t,r),p=Den(this.parentHeight,n,i);this.onResize(this.handle,t,n,f,p)!==!1&&(this.left=t,this.top=n,this.right=r,this.bottom=i,this.width=f,this.height=p,this.$emit(`resizing`,this.left,this.top,this.width,this.height),this.resizing=!0)},changeWidth(e){let[t,n]=q9(this.grid,e,0,1),r=J9(this.parentWidth-t-this.left,this.bounds.minRight,this.bounds.maxRight),i=this.bottom;this.lockAspectRatio&&(i=this.bottom-(this.right-r)/this.aspectFactor);let a=Een(this.parentWidth,this.left,r),o=Den(this.parentHeight,this.top,i);this.right=r,this.bottom=i,this.width=a,this.height=o},changeHeight(e){let[t,n]=q9(this.grid,0,e,1),r=J9(this.parentHeight-n-this.top,this.bounds.minBottom,this.bounds.maxBottom),i=this.right;this.lockAspectRatio&&(i=this.right-(this.bottom-r)*this.aspectFactor);let a=Een(this.parentWidth,this.left,i),o=Den(this.parentHeight,this.top,r);this.right=i,this.bottom=r,this.width=a,this.height=o},handleUp(e){this.handle=null,this.resetBoundsAndMouseState(),this.dragEnable=!1,this.resizeEnable=!1,this.resizing&&(this.resizing=!1,this.$emit(`resizeStop`,this.left,this.top,this.width,this.height)),this.dragging&&(this.dragging=!1,this.$emit(`dragStop`,this.left,this.top)),X9(document.documentElement,Q9.move,this.handleResize)}},computed:{style(){return{transform:`translate(${this.left}px, ${this.top}px)`,width:this.computedWidth,height:this.computedHeight,zIndex:this.zIndex,...this.dragging&&this.disableUserSelect?jen:Men}},actualHandles(){return this.resizable?this.handles:[]},computedWidth(){return this.w===`auto`&&!this.widthTouched?`auto`:this.width+`px`},computedHeight(){return this.h===`auto`&&!this.heightTouched?`auto`:this.height+`px`},minW(){return this.minWidth},minH(){return this.minHeight},maxW(){return this.maxWidth},maxH(){return this.maxHeight},resizingOnX(){return!!this.handle&&(this.handle.includes(`l`)||this.handle.includes(`r`))},resizingOnY(){return!!this.handle&&(this.handle.includes(`t`)||this.handle.includes(`b`))},isCornerHandle(){return!!this.handle&&[`tl`,`tr`,`br`,`bl`].includes(this.handle)}},watch:{active(e){this.enabled=e,e?this.$emit(`activated`):this.$emit(`deactivated`)},z(e){(e>=0||e===`auto`)&&(this.zIndex=e)},x(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveHorizontally(e))},y(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveVertically(e))},lockAspectRatio(e){e?this.aspectFactor=this.width/this.height:this.aspectFactor=void 0},w(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeWidth(e))},h(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeHeight(e))}}},Pen=[`onMousedown`,`onTouchstart`];function Fen(e,t,n,r,i,a){return H(),kr(`div`,{style:fe(a.style),class:_e([{[n.classNameActive]:e.enabled,[n.classNameDragging]:e.dragging,[n.classNameResizing]:e.resizing,[n.classNameDraggable]:n.draggable,[n.classNameResizable]:n.resizable},n.className]),onMousedown:t[0]||=(...e)=>a.elementMouseDown&&a.elementMouseDown(...e),onTouchstart:t[1]||=(...e)=>a.elementTouchDown&&a.elementTouchDown(...e)},[(H(!0),kr(xr,null,Kn(a.actualHandles,t=>(H(),kr(`div`,{key:t,class:_e([n.classNameHandle,n.classNameHandle+`-`+t]),style:fe({display:e.enabled?`block`:`none`}),onMousedown:yi(e=>a.handleDown(t,e),[`stop`,`prevent`]),onTouchstart:yi(e=>a.handleTouchDown(t,e),[`stop`,`prevent`])},[qn(e.$slots,t)],46,Pen))),128)),qn(e.$slots,`default`)],38)}var Ien=Aen(Nen,[[`render`,Fen]]);function Len(e){Len.installed||(Len.installed=!0,e.component(`VueDraggableResizable`,Ien))}var Ren={install:Len},$9=null;typeof window<`u`?$9=window.Vue:typeof global<`u`&&($9=global.Vue),$9&&$9.use(Ren);function zen(e={},t){let n=e.initWidth||400,r=e.minWidth||400,i=e.minHeight||400,a=e.maxWidthPercent||40,o=e.compressedHeight||800,s=e.compressedPadding===void 0?0:e.compressedPadding,l=Xt(e.defaultLeft===void 0?window.innerWidth-n:e.defaultLeft),u=Xt(e.defaultTop===void 0?0:e.defaultTop),d=Xt(e.defaultHeight===void 0?window.innerHeight-(e.defaultTop===void 0?0:e.defaultTop):e.defaultHeight),f=Xt(n),p=Xt(u.value),m=Xt(l.value),h=Xt(f.value),g=Xt(d.value),_=Xt(Math.max(window.innerWidth*(a/100),h.value)),v=Xt(!1),y=Xt(0),b=()=>({x:m.value,y:p.value,width:h.value,height:g.value}),x=(e,n)=>{m.value=e,p.value=n,y.value=e-(window.innerWidth-h.value),t?.onDragging?.(b())},S=(e,n,r,i)=>{m.value=e,p.value=n,h.value=Math.min(r,_.value),g.value=i,t?.onResizing?.(b())},C=(e,n)=>{m.value=e,p.value=n,y.value=e-(window.innerWidth-h.value),t?.onDragStop?.(b())},w=(e,n,r,i)=>{m.value=e,p.value=n,h.value=Math.min(r,_.value),g.value=i,t?.onResizeStop?.(b())},T=()=>{_.value=Math.max(window.innerWidth*(a/100),h.value),mn(()=>{if(v.value)m.value=window.innerWidth-h.value-s,p.value=window.innerHeight-o-s;else{let e=window.innerWidth-h.value-y.value;m.value=Math.max(0,e),setTimeout(()=>{g.value=window.innerHeight-p.value},0)}h.value>_.value&&(h.value=_.value)})},E=()=>{v.value?(p.value=u.value,mn(()=>{g.value=d.value,m.value=l.value,h.value=f.value})):(p.value=window.innerHeight-o-s,m.value=l.value-s,h.value=n,g.value=o),v.value=!v.value},D=(e,t)=>{m.value=e,p.value=t,y.value=e-(window.innerWidth-h.value)},O=(e,t)=>{h.value=Math.max(r,Math.min(e,_.value)),g.value=Math.max(i,t)};return Vn(()=>{window.addEventListener(`resize`,T)}),Hn(()=>{window.removeEventListener(`resize`,T)}),{minWidth:r,minHeight:i,maxWidth:_,top:p,left:m,width:h,height:g,isCompressed:v,handleDragging:x,handleResizing:S,handleDragStop:C,handleResizeStop:w,toggleCompression:E,updatePosition:D,updateSize:O,updatePositionAndSize:(e,t,n,r)=>{D(e,t),O(n,r)}}}var Ben={class:`draggable-container-content`},Ven=E9(Nn({__name:`draggable-container`,props:{visible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},defaultWidth:{default:400},defaultHeight:{default:void 0},defaultX:{default:void 0},defaultY:{default:0},minWidth:{default:400},minHeight:{default:400},maxWidth:{default:void 0},maxWidthPercent:{default:80},compressedHeight:{default:800},compressedPadding:{default:0},dragHandle:{default:`.drag-handle`},className:{default:``},teleportTo:{default:`body`}},emits:[`dragging`,`resizing`,`drag-stop`,`resize-stop`,`compression-change`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=Xt(!1),{minWidth:o,minHeight:s,maxWidth:l,top:u,left:d,width:f,height:p,isCompressed:m,handleDragging:h,handleResizing:g,handleDragStop:_,handleResizeStop:v,toggleCompression:y,updatePosition:b,updateSize:x,updatePositionAndSize:S}=zen({initWidth:r.defaultWidth,minWidth:r.minWidth,minHeight:r.minHeight,maxWidthPercent:r.maxWidthPercent,compressedHeight:r.compressedHeight,defaultHeight:r.defaultHeight,defaultTop:r.defaultY,defaultLeft:r.defaultX,compressedPadding:r.compressedPadding},{onDragStop:e=>i(`drag-stop`,e),onResizeStop:e=>i(`resize-stop`,e),onDragging:e=>i(`dragging`,e),onResizing:e=>i(`resizing`,e)}),C=Qr(()=>{let e=typeof r.maxWidth==`number`?`${r.maxWidth}px`:r.maxWidth??`${l.value}px`;return{"--draggable-max-width":e}}),w=Qr(()=>({x:d.value,y:u.value,width:f.value,height:p.value})),T=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=`none`})},E=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=``})},D=(e,t)=>{a.value||(a.value=!0,T()),h(e,t)},O=(e,t,n,r)=>{a.value||(a.value=!0,T()),g(e,t,n,r)},k=(e,t)=>{_(e,t),a.value=!1,E()},A=(e,t,n,r)=>{v(e,t,n,r),a.value=!1,E()};return lr(m,e=>{i(`compression-change`,e)}),t({updatePosition:b,updateSize:x,updatePositionAndSize:S,toggleCompression:y,positionAndSize:w,isCompressed:m}),(e,t)=>bn((H(),Ar(V(Ien),{ref:`draggableRef`,class:_e([`draggable-container-wrapper`,r.className]),style:fe(C.value),active:r.visible,draggable:r.draggable,resizable:r.resizable,w:V(f),h:V(p),x:V(d),y:V(u),"min-width":V(o),"min-height":V(s),"max-width":V(l),parent:!0,"prevent-deactivation":!0,"drag-handle":r.dragHandle,"class-name":`draggable-container-inner`,onDragging:D,onResizing:O,onDragStop:k,onResizeStop:A},{default:yn(()=>[Pr(`div`,Ben,[qn(e.$slots,`default`,{},void 0,!0)])]),_:3},8,[`class`,`style`,`active`,`draggable`,`resizable`,`w`,`h`,`x`,`y`,`min-width`,`min-height`,`max-width`,`drag-handle`])),[[ui,r.visible]])}}),[[`__scopeId`,`data-v-6e2c6cb7`]]),Hen={class:`nimbus-bkai-wrapper`},Uen=[`width`,`height`,`src`],Wen=E9(Nn({name:`NimbusButton`,__name:`nimbus`,props:{isPanelShow:{type:Boolean},isMinimize:{type:Boolean},size:{default:`normal`}},emits:[`click`,`minimize`,`update:isMinimize`],setup(e,{emit:t}){fi(e=>({v05a8b16e:`${a.value.container}px`,v4e1cf4ca:`${a.value.wrapper}px`,v5ab0c513:`${a.value.mini.right}px`,v40c13a80:`${a.value.mini.size}px`,v0d35a9ef:`${a.value.mini.fontSize}px`}));let n=e,r=t,i={small:{container:40,wrapper:32,img:24,mini:{size:14,fontSize:10,right:-4}},normal:{container:48,wrapper:40,img:32,mini:{size:16,fontSize:12,right:-6}},large:{container:56,wrapper:48,img:40,mini:{size:18,fontSize:14,right:-6}}},a=Qr(()=>i[n.size]),o=Xt(null),s=Xt(null),{nimbusLeft:l,nimbusTop:u,isMinimize:d,handleClick:f,handleMinimize:p,handleDragging:m,handleMouseEnter:h,handleMouseLeave:g,handleMouseDown:_,handleMouseUp:v}=Sen(r,n.isMinimize);lr(d,e=>{r(`update:isMinimize`,e)});let y=Qr(()=>d.value?D9(`恢复默认大小`):D9(`最小化,将缩成锚点`)),{createTooltip:b,destroyAll:x}=Cen({theme:`ai-blueking`,delay:[0,0]}),S=()=>{mn(()=>{C()})},C=()=>{x(),o.value&&!d.value&&b(o.value,E7t(),{placement:`left`}),s.value&&b(s.value,y.value,{placement:`top`})};return lr(()=>d.value,()=>{mn(()=>{C()})}),Vn(()=>{mn(()=>{C()}),window.addEventListener(`resize`,S)}),Hn(()=>{window.removeEventListener(`resize`,S)}),(t,n)=>(H(),Ar(V(Ien),{active:!e.isPanelShow,axis:`y`,draggable:!0,h:a.value.container,parent:!0,"prevent-deactivation":!0,resizable:!1,w:a.value.container,x:V(l),y:V(u),onDragging:V(m)},{default:yn(()=>[Pr(`div`,{ref_key:`nimbusContainerRef`,ref:o,class:_e([`nimbus-container`,{"is-minimize":V(d)}]),onClick:n[1]||=(...e)=>V(f)&&V(f)(...e),onMousedown:n[2]||=(...e)=>V(_)&&V(_)(...e),onMouseenter:n[3]||=(...e)=>V(h)&&V(h)(...e),onMouseleave:n[4]||=(...e)=>V(g)&&V(g)(...e),onMouseup:n[5]||=(...e)=>V(v)&&V(v)(...e)},[Pr(`div`,Hen,[Pr(`img`,{width:a.value.img,height:a.value.img,src:V(g7t),alt:`nimbus`},null,8,Uen)]),Pr(`i`,{ref_key:`minimizeButtonRef`,ref:s,class:_e([`nimbus-mini bkai-icon`,V(d)?`bkai-yinyong`:`bkai-minus-line`]),onClick:n[0]||=yi((...e)=>V(p)&&V(p)(...e),[`stop`])},null,2)],34)]),_:1},8,[`active`,`h`,`w`,`x`,`y`,`onDragging`]))}}),[[`__scopeId`,`data-v-26b6f3ea`]]),Gen={class:`ai-blueking-panel`},Ken=E9(Nn({__name:`ai-blueking`,props:pte({autoSwitchToInitialSession:{type:Boolean},defaultChatInputPosition:{},defaultHeight:{},defaultLeft:{},defaultMinimize:{type:Boolean},defaultTop:{},defaultWidth:{},disabledInput:{type:Boolean},draggable:{type:Boolean},dropdownMenuConfig:{},enableChatSession:{type:Boolean},enablePopup:{type:Boolean},extCls:{},helloText:{},hideDefaultTrigger:{type:Boolean},hideHeader:{type:Boolean},hideNimbus:{type:Boolean},initialSessionCode:{},loadRecentSessionOnMount:{type:Boolean},maxWidth:{},miniPadding:{},nimbusSize:{},placeholder:{},prompts:{},requestOptions:{},resources:{},shortcutLimit:{},shortcuts:{},showCompressionIcon:{type:Boolean},showHistoryIcon:{type:Boolean},showMoreIcon:{type:Boolean},showNewChatIcon:{type:Boolean},teleportTo:{},title:{},url:{},shortcutFilter:{type:Function}},wen),emits:[`show`,`close`,`dragging`,`resizing`,`drag-stop`,`resize-stop`,`send-message`,`receive-start`,`receive-text`,`receive-end`,`stop`,`shortcut-click`,`session-initialized`,`sdk-error`,`transfer-messages`,`share-messages`,`new-chat`,`history-click`,`auto-generate-name`,`help-click`,`rename`,`share`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=Xt(),o=Xt(),s=Qr(()=>C7t(r.url)),l=nen({initialPanelVisible:!1,initialNimbusMinimized:r.defaultMinimize,enablePopup:r.enablePopup,enableNimbus:!r.hideNimbus,enableDraggable:r.draggable}),u=l.panelVisible,d=l.nimbusMinimized,{forwardToManager:f}=xen({componentManager:l,emit:i}),p=ben(f),{chatHelper:m,isReady:h,agentInfo:g,agentName:_,currentSession:v}=yen({url:s,requestOptions:r.requestOptions,autoInit:!0,protocolCallbacks:{onStart:()=>{p.receiveStart()},onMessage:()=>{p.receiveText()},onDone:()=>{p.receiveEnd()},onError:e=>{l.emitInternal(`sdk-error`,{apiName:`chat`,code:-1,message:e.message,data:e})}}}),y=m,b=new Q9t(y.session,y.message,null,{enableChatSession:r.enableChatSession,initialSessionCode:r.initialSessionCode}),x=new $9t(y.message,y.session),S=new aen,C=Qr(()=>S.isSelectionMode.value),w=Xt(!1),T=new een(null,r.shortcuts||[]),E=Xt(!1),D=Xt(``),O=Qr(()=>l.isCompressed.value),k=Qr(()=>_.value),A=Xt(``),j=Xt(!0),M=Xt(!1),N=Qr(()=>r.resources?.length?r.resources:b7t(g.value?.resources)),P=Qr(()=>r.prompts?.length?r.prompts:g.value?.conversationSettings?.predefinedQuestions??[]),F=Qr(()=>{let e=T.effectiveShortcuts.value;return typeof r.shortcutFilter==`function`&&D.value?e.filter(e=>r.shortcutFilter?.(e,D.value)):e});lr(()=>h.value,async e=>{if(e&&g.value){let e=g.value;if(e.saasUrl&&fetch(e.saasUrl,{method:`GET`,credentials:`include`}).catch(()=>{}),e.conversationSettings&&(f(`session-initialized`,{openingRemark:e.conversationSettings.openingRemark||``,predefinedQuestions:e.conversationSettings.predefinedQuestions||[]}),e.conversationSettings.commands&&T.setAgentShortcuts(e.conversationSettings.commands)),r.loadRecentSessionOnMount)try{await b.loadRecentSession({skipLoadSessions:!0})}catch(e){console.error(`[AIBlueking] Failed to load recent session:`,e)}}},{immediate:!0}),lr(()=>r.shortcuts,e=>{T.setShortcuts(e||[])},{immediate:!0}),lr(()=>v.value,e=>{e&&(A.value=e.sessionName||``,M.value=(e.sessionContentCount??0)>0)},{immediate:!0}),lr(()=>y.message.list.value.length,e=>{e>0&&(M.value=!0)});let I=async e=>{l.showPanel(e),e&&o.value&&await o.value.switchSession(e)},L=()=>{l.hidePanel()},R=()=>{L()},ee=()=>{l.handleNimbusClick()},te=e=>{D.value=e},z=async(e,t)=>{E.value=!1,await I(),e.components?.length&&o.value?o.value.selectShortcut(e,t):o.value&&(o.value.setCiteText(t),o.value.focusInput()),f(`shortcut-click`,{shortcut:e,source:`popup`})},B=e=>{f(`shortcut-click`,e)},ne=e=>{l.handleDragging(e)},re=e=>{l.handleResizing(e)},ie=e=>{l.handleDragStop(e)},ae=e=>{l.handleResizeStop(e)},oe=()=>{l.container.toggleCompression()},se=e=>{l.setCompressed(e)},ce=async()=>{p.newChat()},le=e=>{p.historyClick(e)},ue=async e=>{await b.switchSession(e)},de=async e=>{await b.deleteSession(e)},fe=async(e,t)=>{await b.updateSessionName(e,t)},pe=async()=>{let e=y.session.current?.value?.sessionCode;if(!e){console.error(`[AIBlueking] Cannot auto-generate name: no active session`);return}try{await y.session.renameSession(e);let t=y.session.list.value.find(t=>t.sessionCode===e);t&&(A.value=t.sessionName||``)}catch(e){console.error(`[AIBlueking] Failed to auto-generate session name:`,e),je(e)}p.autoGenerateName()},me=()=>{p.helpClick()},he=async e=>{let t=y.session.current?.value;if(!t){console.error(`[AIBlueking] Cannot rename: no active session`);return}try{await y.session.updateSession({...t,sessionName:e}),A.value=e}catch(e){console.error(`[AIBlueking] Failed to rename session:`,e),je(e)}p.rename(e)},ge=()=>{S.enableSelectionMode(),p.share()},ve=()=>{S.disableSelectionMode()},ye=async e=>{w.value=!0;try{let{shareUrl:t,userMessageIds:n}=await x.shareMessages(e);await w7t(t),up({message:D9(`分享链接已复制到剪贴板`),theme:`success`}),S.disableSelectionMode(),p.shareMessages(n)}catch(e){console.error(`[AIBlueking] Failed to share messages:`,e),je(e)}finally{w.value=!1}},be=async e=>{o.value&&await o.value.sendMessage(e)},xe=e=>{M.value=!0,p.sendMessage(e)},Se=()=>{p.receiveStart()},Ce=()=>{p.receiveText()},we=()=>{p.receiveEnd()},Te=()=>{p.stop()},Ee=()=>{o.value&&o.value.stopGeneration()},De=async e=>{e?await b.createSession({sessionCode:e}):await b.createNewSession()},Oe=async e=>{o.value&&await o.value.switchSession(e)},ke=async(e,t)=>{try{await b.updateSessionName(e,t),A.value=t}catch(e){console.error(`[AIBlueking] Failed to update session name:`,e),je(e)}},Ae=e=>{e&&(A.value=e.sessionName||``,M.value=(e.sessionContentCount??0)>0||y.message.list.value.length>0)},je=e=>{console.error(`ChatBot error:`,e),l.emitInternal(`sdk-error`,{apiName:`chat`,code:-1,message:e.message,data:e})},Me=(e,t)=>{l.container.updatePosition(e,t)},Ne=(e,t)=>{l.container.updateSize(e,t)},Pe=(e,t,n,r)=>{l.container.updatePositionAndSize(e,t,n,r)},Fe=e=>{o.value&&o.value.setCiteText(e)},Ie=()=>{o.value&&o.value.focusInput()},Le=e=>{O7t(e)&&(e.preventDefault(),u.value?L():I())};return Vn(async()=>{a.value&&l.setContainerRef(a.value),window.addEventListener(`keydown`,Le)}),Hn(()=>{window.removeEventListener(`keydown`,Le),l.destroy()}),t({show:I,hide:L,sendMessage:be,stopGeneration:Ee,addNewSession:De,switchToSession:Oe,updateSessionName:ke,updatePosition:Me,updateSize:Ne,updatePositionAndSize:Pe,setCiteText:Fe,focusInput:Ie}),(e,t)=>(H(),Ar(Tn,{to:r.teleportTo},[Pr(`div`,{class:_e([`ai-blueking-v2`,r.extCls])},[zr(` 可拖拽容器 `),Fr(V(Ven),{ref_key:`draggableContainerRef`,ref:a,"compressed-padding":r.miniPadding,"default-height":r.defaultHeight,"default-width":r.defaultWidth,"default-x":r.defaultLeft,"default-y":r.defaultTop,"drag-handle":`.drag-handle`,draggable:r.draggable,"max-width":r.maxWidth,"max-width-percent":80,visible:V(u),onCompressionChange:se,onDragStop:ie,onDragging:ne,onResizeStop:ae,onResizing:re},{default:yn(()=>[Pr(`div`,Gen,[zr(` 独立的 Header 组件 `),r.hideHeader?zr(`v-if`,!0):(H(),Ar(e9t,{key:0,"agent-name":k.value,"chat-helper":V(y),draggable:r.draggable,"dropdown-menu-config":r.dropdownMenuConfig,"enable-chat-session":r.enableChatSession,"has-permission":j.value,"has-session-contents":M.value,"is-compression-height":O.value,"session-business-manager":V(b),"session-name":A.value,"show-compression-icon":r.showCompressionIcon,"show-history-icon":r.showHistoryIcon,"show-more-icon":r.showMoreIcon,"show-new-chat-icon":r.showNewChatIcon,title:r.title,onAutoGenerateName:pe,onClose:R,onHelpClick:me,onHistoryClick:le,onHistorySessionDelete:de,onHistorySessionRename:fe,onHistorySessionSwitch:ue,onNewChat:ce,onRename:he,onShare:ge,onToggleCompression:oe},null,8,[`agent-name`,`chat-helper`,`draggable`,`dropdown-menu-config`,`enable-chat-session`,`has-permission`,`has-session-contents`,`is-compression-height`,`session-business-manager`,`session-name`,`show-compression-icon`,`show-history-icon`,`show-more-icon`,`show-new-chat-icon`,`title`])),zr(` ChatBot 核心组件(仅聊天区域) `),Fr(ven,{ref_key:`chatBotRef`,ref:o,"auto-load":r.loadRecentSessionOnMount,"chat-helper":V(y),"enable-selection":C.value,"hello-text":r.helloText,placeholder:r.placeholder,prompts:P.value,"request-options":r.requestOptions,resources:N.value,"session-code":r.initialSessionCode,"share-loading":w.value,"shortcut-limit":r.shortcutLimit,shortcuts:r.shortcuts,url:s.value,onCancelShare:ve,onConfirmShare:t[0]||=e=>ye(e),onError:t[1]||=e=>je(e),onReceiveEnd:we,onReceiveStart:Se,onReceiveText:Ce,onRequestShare:ge,onSendMessage:t[2]||=e=>xe(e),onSessionSwitched:t[3]||=e=>Ae(e),onShortcutClick:t[4]||=e=>B(e),onStop:Te},null,8,[`auto-load`,`chat-helper`,`enable-selection`,`hello-text`,`placeholder`,`prompts`,`request-options`,`resources`,`session-code`,`share-loading`,`shortcut-limit`,`shortcuts`,`url`])])]),_:1},8,[`compressed-padding`,`default-height`,`default-width`,`default-x`,`default-y`,`draggable`,`max-width`,`visible`]),zr(` Nimbus 悬浮球 `),r.hideNimbus?zr(`v-if`,!0):(H(),Ar(Wen,{key:0,"is-minimize":V(d),"onUpdate:isMinimize":t[5]||=e=>Yt(d)?d.value=e:null,"is-panel-show":V(u),"onUpdate:isPanelShow":t[6]||=e=>Yt(u)?u.value=e:null,"default-minimize":r.defaultMinimize,size:r.nimbusSize,onClick:ee},null,8,[`is-minimize`,`is-panel-show`,`default-minimize`,`size`])),zr(` 划词选择弹窗(使用 chat-x 的 AiSelection 组件) `),r.enablePopup?(H(),Ar(V(Loe),{key:1,visible:E.value,"onUpdate:visible":t[7]||=e=>E.value=e,"max-shortcut-count":r.shortcutLimit,shortcuts:F.value,onSelectShortcut:z,onSelectionChange:te},null,8,[`visible`,`max-shortcut-count`,`shortcuts`])):zr(`v-if`,!0)],2)],8,[`to`]))}}),[[`__scopeId`,`data-v-390ddb5e`]]);return e.default={name:`AIBluekingV2`,render(e){return e(`div`,{style:{width:`100%`,height:`100%`}})},props:{extCls:{type:String,default:``},shortcuts:{type:Array,default:()=>[]},enablePopup:{type:Boolean,default:!0},url:{type:String,default:``},prompts:{type:Array,default:()=>[]},teleportTo:{type:String,default:`body`},title:{type:String,default:``},helloText:{type:String,default:``},requestOptions:{type:Object,default:()=>({})},defaultMinimize:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1},hideNimbus:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},defaultWidth:{type:Number,default:700},defaultHeight:{type:Number,default:800},defaultLeft:{type:Number,default:void 0},defaultTop:{type:Number,default:void 0},disabledInput:{type:Boolean,default:!1},showCompressionIcon:{type:Boolean,default:!0},showMoreIcon:{type:Boolean,default:!0},showHistoryIcon:{type:Boolean,default:!0},showNewChatIcon:{type:Boolean,default:!0},defaultChatInputPosition:{type:String,default:void 0},maxWidth:{type:[Number,String],default:1e3},initialSessionCode:{type:String,default:``},autoSwitchToInitialSession:{type:Boolean,default:!1},loadRecentSessionOnMount:{type:Boolean,default:!1},shortcutLimit:{type:Number,default:3},shortcutFilter:{type:Function,default:void 0},placeholder:{type:String,default:``},enableChatSession:{type:Boolean,default:!0},nimbusSize:{type:String,default:`medium`},miniPadding:{type:Number,default:20},dropdownMenuConfig:{type:Array,default:()=>[]},hideDefaultTrigger:{type:Boolean,default:!1}},data(){return{app:null,componentInstance:null,unWatchStack:[]}},created(){let e=this.$emit.bind(this),t=this;this.app=xi({setup(){return()=>$r(Ken,{extCls:t.extCls,shortcuts:t.shortcuts,shortcutLimit:t.shortcutLimit,shortcutFilter:t.shortcutFilter,enablePopup:t.enablePopup,url:t.url,title:t.title,helloText:t.helloText,requestOptions:t.requestOptions,prompts:t.prompts,disabledInput:t.disabledInput,teleportTo:t.teleportTo,defaultMinimize:t.defaultMinimize,hideHeader:t.hideHeader,hideNimbus:t.hideNimbus,draggable:t.draggable,defaultWidth:t.defaultWidth,defaultHeight:t.defaultHeight,defaultLeft:t.defaultLeft,defaultTop:t.defaultTop,initialSessionCode:t.initialSessionCode,autoSwitchToInitialSession:t.autoSwitchToInitialSession,loadRecentSessionOnMount:t.loadRecentSessionOnMount,showCompressionIcon:t.showCompressionIcon,showMoreIcon:t.showMoreIcon,showHistoryIcon:t.showHistoryIcon,showNewChatIcon:t.showNewChatIcon,defaultChatInputPosition:t.defaultChatInputPosition,maxWidth:t.maxWidth,placeholder:t.placeholder,enableChatSession:t.enableChatSession,nimbusSize:t.nimbusSize,miniPadding:t.miniPadding,dropdownMenuConfig:t.dropdownMenuConfig,hideDefaultTrigger:t.hideDefaultTrigger,onClose:()=>e(`close`),onShow:()=>e(`show`),onStop:()=>e(`stop`),onShortcutClick:t=>e(`shortcut-click`,t),onSendMessage:t=>e(`send-message`,t),onReceiveStart:()=>e(`receive-start`),onReceiveEnd:()=>e(`receive-end`),onReceiveText:()=>e(`receive-text`),onSessionInitialized:t=>e(`session-initialized`,t),onDragStop:t=>e(`drag-stop`,t),onResizeStop:t=>e(`resize-stop`,t),onDragging:t=>e(`dragging`,t),onResizing:t=>e(`resizing`,t),onTransferMessages:t=>e(`transfer-messages`,t),onShareMessages:t=>e(`share-messages`,t),onSdkError:t=>e(`sdk-error`,t),onSessionSwitched:t=>e(`session-switched`,t),onHelpClick:()=>e(`help-click`),onRename:()=>e(`rename`),onShare:()=>e(`share`),...t.$attrs,ref:e=>{t.componentInstance=e}})}}),this.unWatchStack.push(this.$watch(`requestOptions`,e=>{this.app&&(this.app.unmount(),this.app.mount(this.$el))},{deep:!0})),this.unWatchStack.push(this.$watch(`shortcuts`,()=>{this.app&&(this.app.unmount(),this.app.mount(this.$el))},{deep:!0}))},mounted(){this.app?.mount(this.$el),this.$nextTick(()=>{if(this.componentInstance){let e=this.componentInstance;this.show=e.show.bind(e),this.hide=e.hide.bind(e),this.sendMessage=e.sendMessage.bind(e),this.stopGeneration=e.stopGeneration.bind(e),this.addNewSession=e.addNewSession.bind(e),this.switchToSession=e.switchToSession.bind(e),this.updateSessionName=e.updateSessionName.bind(e),this.updatePosition=e.updatePosition.bind(e),this.updateSize=e.updateSize.bind(e),this.updatePositionAndSize=e.updatePositionAndSize.bind(e),this.setCiteText=e.setCiteText.bind(e),this.focusInput=e.focusInput.bind(e)}})},beforeDestroy(){this.unWatchStack.forEach(e=>e?.()),this.unWatchStack=[],this.app&&=(this.app.unmount(),null),this.componentInstance=null},methods:{show(e,t){return console.warn(`AIBluekingV2: show method not ready`),Promise.resolve()},hide(){console.warn(`AIBluekingV2: hide method not ready`)},sendMessage(e){return console.warn(`AIBluekingV2: sendMessage method not ready`),Promise.resolve()},stopGeneration(){console.warn(`AIBluekingV2: stopGeneration method not ready`)},addNewSession(e){return console.warn(`AIBluekingV2: addNewSession method not ready`),Promise.resolve()},switchToSession(e){return console.warn(`AIBluekingV2: switchToSession method not ready`),Promise.resolve()},updateSessionName(e,t){return console.warn(`AIBluekingV2: updateSessionName method not ready`),Promise.resolve()},updatePosition(e,t){console.warn(`AIBluekingV2: updatePosition method not ready`)},updateSize(e,t){console.warn(`AIBluekingV2: updateSize method not ready`)},updatePositionAndSize(e,t,n,r){console.warn(`AIBluekingV2: updatePositionAndSize method not ready`)},setCiteText(e){console.warn(`AIBluekingV2: setCiteText method not ready`)},focusInput(){console.warn(`AIBluekingV2: focusInput method not ready`)}}},e.h=$r,e})({});
@@ -2818,5 +2818,5 @@ Use Shift + Enter to enter a new line`:`输入 “/”唤出 Prompt
2818
2818
  ${r}
2819
2819
  </div>
2820
2820
  `}),D=async()=>{if(a.sessionBusinessManager)try{await a.sessionBusinessManager.createNewSession()}catch(e){console.error(`Failed to create new session:`,e),(0,i.Message)({theme:`error`,message:V9(`创建会话失败`)})}o(`new-chat`)},O=e=>{e.stopPropagation(),a.sessionBusinessManager?(v||y(),v&&v.handleTriggerClick(e)):o(`history-click`,e)},k=()=>{o(`help-click`)},A=e=>{e.stopPropagation(),_&&(_.state.isVisible?_.hide():_.show())},j=e=>{e.stopPropagation(),e.preventDefault();let t=e.currentTarget,n=t.dataset.action;if(!t.classList.contains(`disabled`))switch(_&&_.hide(),n){case`rename`:M();break;case`auto-generate`:o(`auto-generate-name`);break;case`share`:o(`share`);break}},M=()=>{document.removeEventListener(`click`,I),h.value=a.sessionName||``,m.value=!0,setTimeout(()=>{document.addEventListener(`click`,I)},100),setTimeout(()=>{if(g.value)try{let e=g.value;e&&typeof e.focus==`function`&&e.focus();let t=e.$el?.querySelector(`input`);t&&typeof t.select==`function`&&t.select()}catch(e){console.warn(`Failed to focus rename input:`,e)}},100)},N=()=>{let e=h.value.trim();if(!e){P();return}o(`rename`,e),m.value=!1,h.value=``},P=()=>{m.value=!1,h.value=``},F=(e,t)=>{h.value=e,t.key===`Enter`?N():t.key===`Escape`&&P()},I=e=>{if(!m.value)return;let t=e.target,n=document.querySelector(`.rename-tooltip`);n&&!n.contains(t)&&P()},L=async()=>{if(!d.value)return;let e=(await import(`tippy.js`)).default;_&&=(_.destroy(),null),_=e(d.value,{content:E.value,theme:`ai-blueking-light more-menu-light light`,placement:`bottom-start`,trigger:`manual`,interactive:!0,allowHTML:!0,arrow:!1,offset:[0,4],appendTo:()=>document.querySelector(`.ai-blueking-panel`)||document.body,onShow:()=>{setTimeout(()=>{document.querySelectorAll(`.tippy-menu-item`).forEach(e=>{e.addEventListener(`click`,j)})},0)},onHide:()=>{document.querySelectorAll(`.tippy-menu-item`).forEach(e=>{e.removeEventListener(`click`,j)})}})};return(0,t.watch)(()=>[a.isCompressionHeight,a.hasSessionContents],()=>{_&&_.setContent(E.value)}),(0,t.onMounted)(()=>{L(),a.sessionBusinessManager&&y(),document.addEventListener(`click`,I)}),(0,t.onBeforeUnmount)(()=>{_&&=(_.destroy(),null),v&&=(v.destroy(),null),document.removeEventListener(`click`,I)}),n({headerRef:l,historyIconRef:u}),(n,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`headerRef`,ref:l,class:(0,t.normalizeClass)([`ai-header drag-handle`,{draggable:a.draggable}])},[(0,t.createElementVNode)(`div`,hxt,[(0,t.createElementVNode)(`div`,gxt,[(0,t.createElementVNode)(`img`,{alt:`logo`,src:(0,t.unref)(Rbt)},null,8,_xt)]),(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`title`,{"title-with-tooltip":m.value}])},[(0,t.createTextVNode)((0,t.toDisplayString)(b.value)+` `,1),(0,t.createCommentVNode)(` 重命名 tooltip 直接绑定在 title 上 `),m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,vxt,[(0,t.createElementVNode)(`div`,yxt,[(0,t.createVNode)((0,t.unref)(i.Input),{ref_key:`renameInputRef`,ref:g,modelValue:h.value,"onUpdate:modelValue":r[0]||=e=>h.value=e,class:`rename-input`,placeholder:(0,t.unref)(V9)(`请输入新的会话名称`),onKeyup:F},null,8,[`modelValue`,`placeholder`]),(0,t.createElementVNode)(`div`,{class:`rename-buttons`},[(0,t.createElementVNode)(`i`,{class:`bkai-icon bkai-check-1 rename-btn confirm-btn`,onClick:N}),(0,t.createElementVNode)(`i`,{class:`bkai-icon bkai-close rename-btn cancel-btn`,onClick:P})])])])):(0,t.createCommentVNode)(`v-if`,!0)],2),a.showMoreIcon&&C.value?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:0,ref_key:`moreIconRef`,ref:d,class:`bkai-icon bkai-more`,onClick:A},null,512)):(0,t.createCommentVNode)(`v-if`,!0)]),(0,t.createElementVNode)(`div`,bxt,[(0,t.createCommentVNode)(` 新增会话按钮 `),a.showNewChatIcon&&e.enableChatSession!==!1?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:0,class:(0,t.normalizeClass)([`bkai-icon`,`bkai-xinzengliaotian`,{disabled:!C.value}]),style:(0,t.normalizeStyle)(T()),onClick:r[1]||=e=>C.value?D():void 0},null,6)),[[(0,t.unref)(s),{content:w((0,t.unref)(V9)(`新增会话`)),boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),(0,t.createCommentVNode)(` 历史会话按钮 `),a.showHistoryIcon&&e.enableChatSession!==!1?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:1,ref_key:`historyIconRef`,ref:u,class:(0,t.normalizeClass)([`bkai-icon`,`bkai-history`,{disabled:!C.value}]),style:(0,t.normalizeStyle)(T()),onClick:r[2]||=e=>C.value?O(e):void 0},null,6)),[[(0,t.unref)(s),{content:w((0,t.unref)(V9)(`历史会话`)),boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),e.chatGroup?.enabled?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:2,class:`bkai-icon bkai-zhushou`,onClick:k},null,512)),[[(0,t.unref)(s),{content:(0,t.unref)(V9)(`转人工`),boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),a.showCompressionIcon?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:3,ref_key:`compressionRef`,ref:f,class:(0,t.normalizeClass)([`bkai-icon`,x.value]),onClick:r[3]||=e=>o(`toggle-compression`)},null,2)),[[(0,t.unref)(s),{content:S.value,boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),(0,t.withDirectives)((0,t.createElementVNode)(`i`,{ref_key:`closeRef`,ref:p,class:`bkai-icon bkai-close-line-2`,onClick:r[4]||=e=>o(`close`)},null,512),[[(0,t.unref)(s),{content:(0,t.unref)(V9)(`关闭`),boundary:`parent`}]])])],2))}}),[[`__scopeId`,`data-v-e9f38ba5`]]),Sxt=class{_isGenerating;agentModule;config;eventEmitter;messageModule;sessionModule;autoRenameSessionIfNeeded(e){this.sessionModule&&this.messageModule.list.value.length===1&&this.sessionModule.renameSession(e).catch(e=>{console.error(`[ChatBusinessManager] Auto rename session failed:`,e)})}emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,n,r=null,i=null,a={}){this.agentModule=e,this.messageModule=n,this.sessionModule=r,this.eventEmitter=i,this.config=a,this._isGenerating=(0,t.ref)(!1)}get isGenerating(){return this._isGenerating}get isMessagesLoading(){return this.messageModule.isListLoading}get messages(){return this.messageModule.list}get openingRemark(){return this.config.openingRemark||``}get predefinedQuestions(){return this.config.predefinedQuestions||[]}async batchDeleteMessages(e){try{await this.messageModule.deleteMessages(e);let t=e.map(e=>e.id).filter(Boolean);this.emit(`messages-batch-deleted`,{messageIds:t})}catch(e){throw console.error(`Failed to batch delete messages:`,e),this.emit(`chat-error`,{action:`batch-delete-messages`,error:e}),e}}async deleteMessage(e){try{await this.messageModule.deleteMessages([e]),this.emit(`message-deleted`,{messageId:e.id})}catch(e){throw console.error(`Failed to delete message:`,e),this.emit(`chat-error`,{action:`delete-message`,error:e}),e}}handleStreamEnd(){this._isGenerating.value=!1,this.emit(`receive-end`,{})}handleStreamError(e){this._isGenerating.value=!1,this.emit(`receive-error`,{error:e})}handleStreamStart(){this._isGenerating.value=!0,this.emit(`receive-start`,{})}async regenerateFromAIMessages(e,t){try{if(!e||e.length===0)throw Error(`No AI messages provided`);let n=this.messages.value,r=B9(n,e[0]);if(!r)throw Error(`No user message found before AI messages`);let i=r.id;if(i===void 0)throw Error(`User message has no id`);await this.regenerateMessage(String(i),t)}catch(e){throw console.error(`Failed to regenerate from AI messages:`,e),this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async regenerateMessage(e,t){try{let n=this.messages.value,r=n.findIndex(t=>String(t.id)===e);if(r===-1)throw Error(`Message not found: ${e}`);let i=n[r];if(i.role!==s.MessageRole.User)throw Error(`Can only regenerate from user messages`);let a=n.slice(r),o=typeof i.content==`string`?i.content:JSON.stringify(i.content),l=i.property;this._isGenerating.value=!0;let u=this.messageModule.deleteMessages(a);this.agentModule.chat(o,t,void 0,void 0,l),this.emit(`chat-regenerate`,{messageId:e}),u.catch(e=>{console.error(`[regenerateMessage] Delete API error:`,e)})}catch(e){throw console.error(`Failed to regenerate message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async resendMessageWithProperty(e,t,n,r){try{let i=this.messages.value,a=i.findIndex(t=>String(t.id)===e);if(a===-1)throw Error(`Message not found: ${e}`);if(i[a].role!==s.MessageRole.User)throw Error(`Can only resend user messages`);let o=i.slice(a);this._isGenerating.value=!0;let l=this.messageModule.deleteMessages(o);this.agentModule.chat(n,t,void 0,void 0,r),this.emit(`chat-resend`,{messageId:e}),l.catch(e=>{console.error(`[resendMessageWithProperty] Delete API error:`,e)})}catch(e){throw console.error(`Failed to resend message with property:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`resend`,error:e}),e}}async retryMessage(e){try{console.warn(`retryMessage not implemented yet`),this.emit(`chat-retry`,{messageId:e})}catch(e){throw console.error(`Failed to retry message:`,e),this.emit(`chat-error`,{action:`retry`,error:e}),e}}async sendMessage(e,t,n={}){try{if(!t)throw Error(`No active session. Please create or select a session first.`);this._isGenerating.value=!0,this.emit(`send-message`,{content:e}),await this.agentModule.chat(e,t,void 0,void 0,n.property),this.autoRenameSessionIfNeeded(t)}catch(e){throw console.error(`Failed to send message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`send`,error:e}),e}}stopGeneration(){try{let e=this.sessionModule?.current?.value?.sessionCode??``;this.agentModule.stopChat(e),this._isGenerating.value=!1,this.emit(`stop`,{})}catch(e){console.error(`Failed to stop generation:`,e),this.emit(`chat-error`,{action:`stop`,error:e})}}},Cxt=class{config;eventEmitter;messageModule;sessionModule;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,t,n=null,r={}){this.sessionModule=e,this.messageModule=t,this.eventEmitter=n,this.config=r}get currentSession(){return this.sessionModule.current}get isCreateLoading(){return this.sessionModule.isCreateLoading}get isCurrentLoading(){return this.sessionModule.isCurrentLoading}get isDeleteLoading(){return this.sessionModule.isDeleteLoading}get isListLoading(){return this.sessionModule.isListLoading}get isUpdateLoading(){return this.sessionModule.isUpdateLoading}get sessionList(){return this.sessionModule.list}async createNewSession(){return this.createSession({name:`新会话`,sessionCode:`new_session_${Date.now()}`})}async createSession(e={}){if(this.config.enableChatSession===!1)throw Error(`Chat session is disabled`);try{let t={sessionName:e.name||`新会话`,sessionCode:e.sessionCode||`session_${Date.now()}`,isTemporary:e.isTemporary||!1};await this.sessionModule.createSession(t),this.emit(`session-created`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to create session:`,e),this.emit(`session-error`,{action:`create`,error:e}),e}}async deleteSession(e){try{await this.sessionModule.deleteSession(e),this.emit(`session-deleted`,{sessionCode:e})}catch(e){throw console.error(`Failed to delete session:`,e),this.emit(`session-error`,{action:`delete`,error:e}),e}}async getSession(e){try{await this.sessionModule.getSession(e)}catch(e){throw console.error(`Failed to get session:`,e),this.emit(`session-error`,{action:`get`,error:e}),e}}async loadRecentSession(e){try{e?.skipLoadSessions||await this.loadSessions();let t=this.sessionList.value;if(this.config.initialSessionCode){await this.switchSession(this.config.initialSessionCode);return}if(t.length>0){let e=t[0];(e.sessionContentCount??0)>0?await this.createNewSession():await this.switchSession(e.sessionCode,{loadMessages:!1});return}await this.createNewSession()}catch(e){throw console.error(`Failed to load recent session:`,e),e}}async loadSessions(){try{await this.sessionModule.getSessions(),this.emit(`sessions-loaded`,{sessions:this.sessionList.value})}catch(e){throw console.error(`Failed to load sessions:`,e),this.emit(`session-error`,{action:`load`,error:e}),e}}async switchSession(e,t){try{await this.sessionModule.chooseSession(e,t),this.emit(`session-switched`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to switch session:`,e),this.emit(`session-error`,{action:`switch`,error:e}),e}}async updateSessionName(e,t){try{let n=this.sessionList.value.find(t=>t.sessionCode===e);if(!n)throw Error(`Session not found: ${e}`);await this.sessionModule.updateSession({...n,sessionName:t}),this.emit(`session-updated`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to update session name:`,e),this.emit(`session-error`,{action:`update`,error:e}),e}}},wxt=class{messageModule;sessionModule;constructor(e,t){this.messageModule=e,this.sessionModule=t}async shareMessages(e){if(e.length===0)throw Error(`No messages to share`);let t=this.sessionModule.current?.value?.sessionCode;if(!t)throw Error(`No active session`);let n=await this.messageModule.shareMessages(t,e);if(!n)throw Error(`Share failed: no result returned`);return{shareUrl:`${n.share_page}share-page/${n.share_token}`,userMessageIds:e.filter(e=>e.role===`user`).map(e=>String(e.id))}}},Txt=class{_agentShortcuts;_effectiveShortcuts;_propsShortcuts;eventEmitter;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e=null,n=[]){this._propsShortcuts=(0,t.ref)(n),this._agentShortcuts=(0,t.ref)([]),this.eventEmitter=e,this._effectiveShortcuts=(0,t.computed)(()=>this._propsShortcuts.value.length>0?this._propsShortcuts.value:this._agentShortcuts.value.length>0?this._agentShortcuts.value:[])}get count(){return this._effectiveShortcuts.value.length}get effectiveShortcuts(){return this._effectiveShortcuts}get hasShortcuts(){return this._effectiveShortcuts.value.length>0}get shortcuts(){return this._effectiveShortcuts}addShortcut(e){this._propsShortcuts.value.push(e)}clear(){this._propsShortcuts.value=[],this._agentShortcuts.value=[]}filterByTextLength(e,t){return!e||e.length>t?[]:this._effectiveShortcuts.value}filterShortcuts(e,t){return t?this._effectiveShortcuts.value.filter(n=>t(n,e)):this._effectiveShortcuts.value}getShortcutById(e){return this._effectiveShortcuts.value.find(t=>t.id===e)}handleShortcutClick(e,t,n=`main`){this.emit(`shortcut-click`,{shortcut:e,selectedText:t,source:n})}limitShortcuts(e){return this._effectiveShortcuts.value.slice(0,e)}removeShortcut(e){this._propsShortcuts.value=this._propsShortcuts.value.filter(t=>t.id!==e)}setAgentShortcuts(e){this._agentShortcuts.value=e}setShortcuts(e){this._propsShortcuts.value=e}},Ext=class{config;_panelVisible;_nimbusMinimized;_isDraggingOrResizing;_positionAndSize;_isCompressed;containerRef=null;listeners;onceListeners;debugMode;cleanupFunctions;constructor(e={}){this.config=e,this.listeners=new Map,this.onceListeners=new Map,this.debugMode=e.debug??!1,this.cleanupFunctions=[],this._panelVisible=(0,t.ref)(e.initialPanelVisible??!1),this._nimbusMinimized=(0,t.ref)(e.initialNimbusMinimized??!1),this._isDraggingOrResizing=(0,t.ref)(!1),this._isCompressed=(0,t.ref)(!1),this._positionAndSize=(0,t.ref)({x:0,y:0,width:400,height:window.innerHeight})}getConfig(){return this.config}get state(){return{panelVisible:this._panelVisible,nimbusMinimized:this._nimbusMinimized,isDraggingOrResizing:this._isDraggingOrResizing,positionAndSize:this._positionAndSize}}get panelVisible(){return this._panelVisible}get nimbusMinimized(){return this._nimbusMinimized}get isDraggingOrResizing(){return this._isDraggingOrResizing}get isCompressed(){return this._isCompressed}get panel(){return{show:this.showPanel.bind(this),hide:this.hidePanel.bind(this),toggle:this.togglePanel.bind(this),isVisible:(0,t.computed)(()=>this._panelVisible.value)}}showPanel(e){this._panelVisible.value=!0,this.emit(`panel-show`,{sessionCode:e})}hidePanel(){this._panelVisible.value=!1,this.emit(`panel-hide`,{})}togglePanel(){this._panelVisible.value?this.hidePanel():this.showPanel()}get nimbus(){return{minimize:this.minimizeNimbus.bind(this),restore:this.restoreNimbus.bind(this),toggle:this.toggleNimbus.bind(this),isMinimized:(0,t.computed)(()=>this._nimbusMinimized.value)}}minimizeNimbus(){this._nimbusMinimized.value=!0,this.emit(`nimbus-minimize`,{})}restoreNimbus(){this._nimbusMinimized.value=!1,this.emit(`nimbus-restore`,{})}toggleNimbus(){this._nimbusMinimized.value?this.restoreNimbus():this.minimizeNimbus()}handleNimbusClick(){this.emit(`nimbus-click`,{}),this.showPanel()}get container(){return{updatePosition:this.updatePosition.bind(this),updateSize:this.updateSize.bind(this),updatePositionAndSize:this.updatePositionAndSize.bind(this),toggleCompression:this.toggleCompression.bind(this),positionAndSize:(0,t.computed)(()=>this._positionAndSize.value),isCompressed:(0,t.computed)(()=>this._isCompressed.value)}}updatePosition(e,t){this._positionAndSize.value={...this._positionAndSize.value,x:e,y:t}}updateSize(e,t){this._positionAndSize.value={...this._positionAndSize.value,width:e,height:t}}updatePositionAndSize(e,t,n,r){this._positionAndSize.value={x:e,y:t,width:n,height:r}}setContainerRef(e){this.containerRef=e,e?.isCompressed&&(this._isCompressed.value=e.isCompressed.value)}setCompressed(e){this._isCompressed.value=e}toggleCompression(){this.containerRef?this.containerRef.toggleCompression():this._isCompressed.value=!this._isCompressed.value}setDraggingOrResizing(e){this._isDraggingOrResizing.value=e}handleDragging(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`dragging`,e)}handleResizing(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`resizing`,e)}handleDragStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`drag-stop`,e)}handleResizeStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`resize-stop`,e)}handlePopupClick(){this.emit(`popup-click`,{}),this.showPanel()}handlePopupShortcutClick(e){this.emit(`popup-shortcut-click`,{shortcut:e}),this.emit(`shortcut-click`,{shortcut:e,source:`popup`})}handleShortcutClick(e,t){this.emit(`shortcut-click`,{shortcut:e,source:t})}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed to "${e}", total: ${this.listenerCount(e)}`),()=>{this.off(e,t)}}once(e,t){return this.onceListeners.has(e)||this.onceListeners.set(e,new Set),this.onceListeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed once to "${e}"`),()=>{this.onceListeners.get(e)?.delete(t)}}off(e,t){t?(this.listeners.get(e)?.delete(t),this.onceListeners.get(e)?.delete(t),this.debugMode&&console.debug(`[ComponentManager] Unsubscribed from "${e}", remaining: ${this.listenerCount(e)}`)):(this.listeners.delete(e),this.onceListeners.delete(e),this.debugMode&&console.debug(`[ComponentManager] Removed all listeners for "${e}"`))}emit(e,t){this.debugMode&&console.debug(`[ComponentManager] Emitting "${e}"`,t);let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in listener for "${e}":`,t)}});let r=this.onceListeners.get(e);if(r&&r.size>0){let n=Array.from(r);this.onceListeners.delete(e),n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in once listener for "${e}":`,t)}})}}emitInternal(e,t){this.emit(e,t)}listenerCount(e){return(this.listeners.get(e)?.size??0)+(this.onceListeners.get(e)?.size??0)}hasListeners(e){return this.listenerCount(e)>0}getRegisteredEvents(){let e=new Set;return this.listeners.forEach((t,n)=>e.add(n)),this.onceListeners.forEach((t,n)=>e.add(n)),Array.from(e)}setDebugMode(e){this.debugMode=e}destroy(){this.listeners.clear(),this.onceListeners.clear(),this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.debugMode&&console.debug(`[ComponentManager] Destroyed`)}};function Dxt(e){return new Ext(e)}let Oxt={"panel-show":`show`,"panel-hide":`close`,"panel-toggle":null,"nimbus-click":null,"nimbus-minimize":null,"nimbus-restore":null,"popup-click":null,"popup-shortcut-click":null,dragging:`dragging`,resizing:`resizing`,"drag-stop":`drag-stop`,"resize-stop":`resize-stop`,"compression-toggle":null,"send-message":`send-message`,"receive-start":`receive-start`,"receive-text":`receive-text`,"receive-end":`receive-end`,"receive-error":null,stop:`stop`,"chat-regenerate":null,"chat-retry":null,"message-deleted":null,"messages-batch-deleted":null,"session-created":null,"session-switched":null,"session-deleted":null,"session-updated":null,"sessions-loaded":null,"session-initialized":`session-initialized`,"session-error":null,"shortcut-click":`shortcut-click`,"chat-error":null,"sdk-error":`sdk-error`,"new-chat":`new-chat`,"history-click":`history-click`,"auto-generate-name":`auto-generate-name`,"help-click":`help-click`,rename:`rename`,share:`share`,close:`close`,"toggle-compression":null,"transfer-messages":`transfer-messages`,"share-messages":`share-messages`,"agent-info-loaded":null,error:null};function kxt(e,t){switch(e){case`send-message`:return[t.content];case`rename`:return[t.newName];case`history-click`:return[t.event];case`dragging`:case`resizing`:case`drag-stop`:case`resize-stop`:case`shortcut-click`:case`session-initialized`:case`sdk-error`:case`transfer-messages`:case`share-messages`:return[t];case`panel-show`:case`panel-hide`:case`receive-start`:case`receive-text`:case`receive-end`:case`stop`:case`new-chat`:case`auto-generate-name`:case`help-click`:case`share`:case`close`:return[];default:return[t]}}var Axt=class{_selectedMessageIds;_isSelectionMode;_editingSessionCode;_loadingStates;constructor(){this._selectedMessageIds=(0,t.ref)(new Set),this._isSelectionMode=(0,t.ref)(!1),this._editingSessionCode=(0,t.ref)(null),this._loadingStates=(0,t.reactive)({})}get isSelectionMode(){return this._isSelectionMode}get editingSessionCode(){return this._editingSessionCode}toggleSelectionMode(){this._isSelectionMode.value=!this._isSelectionMode.value,this._isSelectionMode.value||this.clearSelection()}enableSelectionMode(){this._isSelectionMode.value=!0}disableSelectionMode(){this._isSelectionMode.value=!1,this.clearSelection()}toggleMessageSelection(e){this._selectedMessageIds.value.has(e)?this._selectedMessageIds.value.delete(e):this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectMessage(e){this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}deselectMessage(e){this._selectedMessageIds.value.delete(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}isMessageSelected(e){return this._selectedMessageIds.value.has(e)}clearSelection(){this._selectedMessageIds.value.clear(),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectAllMessages(e){this._selectedMessageIds.value=new Set(e)}get selectedMessages(){return Array.from(this._selectedMessageIds.value)}get selectedCount(){return this._selectedMessageIds.value.size}get hasSelection(){return this._selectedMessageIds.value.size>0}startEditingSession(e){this._editingSessionCode.value=e}stopEditingSession(){this._editingSessionCode.value=null}isEditingSession(e){return e?this._editingSessionCode.value===e:this._editingSessionCode.value!==null}setLoading(e,t){this._loadingStates[e]=t}isLoading(e){return this._loadingStates[e]??!1}clearLoadingStates(){Object.keys(this._loadingStates).forEach(e=>{this._loadingStates[e]=!1})}reset(){this.clearSelection(),this.disableSelectionMode(),this.stopEditingSession(),this.clearLoadingStates()}},jxt={class:`selection-footer`},Mxt={class:`selection-footer-left`},Nxt={class:`select-all-text`},Pxt={class:`selection-footer-right`},Fxt=z9((0,t.defineComponent)({__name:`selection-footer`,props:{isAllSelected:{type:Boolean},loading:{type:Boolean,default:!1},selectedCount:{}},emits:[`cancel`,`confirm`,`toggle-all`],setup(e){let n=e;return(e,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,jxt,[(0,t.createElementVNode)(`div`,Mxt,[(0,t.createVNode)((0,t.unref)(i.Checkbox),{"model-value":n.isAllSelected,"onUpdate:modelValue":r[0]||=t=>e.$emit(`toggle-all`,t)},null,8,[`model-value`]),(0,t.createElementVNode)(`span`,Nxt,(0,t.toDisplayString)((0,t.unref)(V9)(`全选`)),1)]),(0,t.createElementVNode)(`div`,Pxt,[(0,t.createVNode)((0,t.unref)(i.Button),{disabled:n.loading,onClick:r[1]||=t=>e.$emit(`cancel`)},{default:(0,t.withCtx)(()=>[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(V9)(`取消`)),1)]),_:1},8,[`disabled`]),(0,t.createVNode)((0,t.unref)(i.Button),{disabled:n.selectedCount===0,loading:n.loading,theme:`primary`,onClick:r[2]||=t=>e.$emit(`confirm`)},{default:(0,t.withCtx)(()=>[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(V9)(`确定`)),1)]),_:1},8,[`disabled`,`loading`])])]))}}),[[`__scopeId`,`data-v-3247bea6`]]),Ixt={key:0,class:`chatbot-error`},Lxt={class:`chatbot-loading`},Rxt={key:0,class:`chatbot-welcome`},zxt={class:`welcome-content`},Bxt={key:0,class:`welcome-remark`},Vxt={key:0,class:`chatbot-loading`},Hxt={key:3,class:`chatbot-input`},Uxt=(0,t.defineComponent)({__name:`chat-bot`,props:{autoLoad:{type:Boolean,default:!0},chatHelper:{default:void 0},enableSelection:{type:Boolean,default:!1},extCls:{},height:{},helloText:{},maxWidth:{},placeholder:{},prompts:{},requestOptions:{},resources:{default:()=>[]},sessionCode:{},shareLoading:{type:Boolean,default:!1},shortcutLimit:{default:10},shortcuts:{default:()=>[]},url:{default:``}},emits:[`agent-info-loaded`,`cancel-share`,`confirm-share`,`error`,`feedback`,`receive-end`,`receive-start`,`receive-text`,`request-share`,`send-message`,`session-switched`,`shortcut-click`,`stop`],setup(e,{expose:n,emit:r}){let a=e,o=r,l=(0,t.ref)(),u=(0,t.ref)(),d=(0,t.ref)(null),f=(0,t.shallowRef)([]),p=(0,t.ref)(!1),m=(0,t.ref)(null),h=()=>a.chatHelper?!a.chatHelper.agent||!a.chatHelper.session||!a.chatHelper.message?{valid:!1,error:`[ChatBot] Invalid chatHelper: missing required modules (agent, session, message)`}:{valid:!0}:a.url?{valid:!0}:{valid:!1,error:`[ChatBot] Neither chatHelper nor url provided. Component requires at least one.`},g=(()=>{let e=h();if(!e.valid)return console.error(e.error),m.value=Error(e.error),null;if(a.chatHelper)return a.chatHelper;let t=new s.AGUIProtocol({onStart:()=>{o(`receive-start`)},onMessage:e=>{o(`receive-text`)},onDone:()=>{o(`receive-end`),le()},onError:e=>{o(`error`,e)}}),n=(0,s.useChatHelper)({requestData:{urlPrefix:Wbt(a.url),headers:a.requestOptions?.headers,data:a.requestOptions?.data},protocol:t});return t.injectMessageModule(n.message),n})(),_=(0,t.computed)(()=>((a.chatHelper||g)?.agent)?.isChatting?.value?T.Streaming:T.Complete),v=(0,t.computed)(()=>_.value===T.Streaming?F9.Disabled:void 0),y=async(e,t)=>{if(e.id===`cite`){I.value=t.filter(e=>e.role!==w.Reasoning).map(e=>typeof e.content==`string`?e.content:JSON.stringify(e.content||``)).join(`
2821
- `),Se();return}if(e.id===`rebuild`){await S(t);return}if(e.id===`delete`){await x(t);return}if(e.id===`share`){o(`request-share`);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await g?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},b=async(e,t,n,r)=>{if(!g){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let i=g.session.current?.value?.sessionCode;if(!i){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let a=zbt(N?.messages.value||[],t[0]);if(a===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let s=e.id===`like`?5:0;try{await g.session.postSessionFeedback({sessionCode:i,sessionContentIds:[a],rate:s,labels:n,comment:r}),o(`feedback`,e,t[0],n,r)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),o(`error`,e)}},x=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=N.messages.value,n=B9(t,e[0]);if(!n){console.error(`[ChatBot] No user message found before AI messages`);return}let r=[n,...e];await g.message.deleteMessages(r)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),o(`error`,e)}},S=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let t=g.session.current?.value?.sessionCode;if(!t){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await N.regenerateFromAIMessages(e,t),le()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),o(`error`,e)}},C=async(e,t)=>{if(e.id===`delete`){await k(t);return}if(e.id===`cite`){I.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),Se();return}console.log(`handleUserAction`,e,t)},E=async(e,t,n)=>{if(!g){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let r=g.session.current?.value?.sessionCode;if(!r){console.error(`[ChatBot] Cannot edit message: no active session`);return}let i=e.id;if(i===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,i,r,t),await g.agent.resendMessage(String(i),r,t),le()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),o(`error`,e)}},D=async(e,t)=>{if(!N||!g){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let n=g.session.current?.value?.sessionCode;if(!n){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let r=e.id;if(r===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let i=O(e);if(!i){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let a=_e(i,t),o=String(t.input??``);await N.resendMessageWithProperty(String(r),n,o,a),le()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),o(`error`,e)}},O=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?ce.value.find(e=>e.id===t.command)??null:null},k=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=N.messages.value,n=t.findIndex(t=>t===e);if(n===-1){console.error(`[ChatBot] User message not found in messages list`);return}let r=[];for(let e=n+1;e<t.length;e++){let n=t[e];if(n.role===w.User)break;r.push(n)}let i=[e,...r];await g.message.deleteMessages(i)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),o(`error`,e)}},A=async()=>{((a.chatHelper||g)?.agent)?.stopChat?.(g?.session.current?.value?.sessionCode??``)},j=!a.chatHelper,M=g?new Cxt(g.session,g.message,null,{enableChatSession:!0,autoSwitchToInitialSession:!!a.sessionCode,loadRecentSessionOnMount:a.autoLoad,initialSessionCode:a.sessionCode}):null,N=g?new Sxt(g.agent,g.message,g.session,null,{openingRemark:a.helloText,predefinedQuestions:a.prompts,placeholder:a.placeholder}):null,P=new Txt(null,a.shortcuts||[]),F=(0,t.shallowRef)([[]]),I=(0,t.ref)(``),L=(0,t.computed)(()=>N?.messages.value??[]),R=(0,t.computed)(()=>N?.isMessagesLoading.value??!1),ee=(0,t.computed)(()=>N?.isGenerating.value??!1),te=(0,t.computed)(()=>M?.currentSession.value??null),z=(0,t.computed)(()=>j&&!p.value?!1:!R.value&&L.value.length===0),B=(0,t.computed)(()=>g?.agent.info.value?.conversationSettings?.openingRemark||``),ne=(0,t.computed)(()=>a.resources?.length?a.resources:Vbt(g?.agent.info.value?.resources)),re=(0,t.computed)(()=>a.prompts?.length?a.prompts:g?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),ie=(0,t.computed)(()=>({height:typeof a.height==`number`?`${a.height}px`:a.height,maxWidth:typeof a.maxWidth==`number`?`${a.maxWidth}px`:a.maxWidth})),ae=(0,t.computed)(()=>{let e=P.shortcuts.value;return a.shortcutLimit&&e.length>a.shortcutLimit?e.slice(0,a.shortcutLimit):e}),oe=()=>{f.value=[],o(`cancel-share`)},V=()=>{o(`confirm-share`,f.value)},se=e=>{e?f.value=L.value:f.value=[]},ce=P.effectiveShortcuts;(0,t.watch)(()=>a.shortcuts,e=>{P.setShortcuts(e||[])},{immediate:!0}),(0,t.watch)(()=>g?.agent.info.value?.conversationSettings?.commands,e=>{e&&P.setAgentShortcuts(e)},{immediate:!0});let le=async()=>{await(0,t.nextTick)(),l.value&&(l.value.scrollTop=l.value.scrollHeight)},ue=async(e,t={})=>{if(!N||!g)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let n=g.session.current?.value?.sessionCode;if(!n)throw Error(`[ChatBot] Cannot send message: no active session`);F.value=[[]],I.value=``,o(`send-message`,typeof e==`string`?e:``),await N.sendMessage(e,n,t)},de=async e=>{let t=g?.session.current?.value?.sessionCode;return t&&await g.session.uploadFile(t,e)||{}},fe=async(e,t)=>{try{await ue(e,I.value?{property:{extra:{cite:I.value}}}:{})}catch(e){console.error(`Failed to send message:`,e),o(`error`,e)}},pe=async()=>{ye()},me=(e,t)=>{he(e,t),o(`shortcut-click`,{shortcut:e,source:`main`})},he=(e,t)=>{let n=e,r=n.components?.find(e=>e.fillBack)?.key||`input`;d.value={...n,formModel:{...n.formModel,[r]:t||``}}},ge=()=>{d.value=null},_e=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},ve=async e=>{if(!d.value){console.error(`[ChatBot] No selected shortcut`);return}let t=_e(d.value,e),n=d.value.name,r=d.value;ge();try{await ue(n,{property:t})}catch(e){d.value=r,console.error(`[ChatBot] Failed to submit shortcut:`,e),o(`error`,e)}},ye=()=>{if(!N){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}N.stopGeneration(),o(`stop`)},be=async e=>{if(!M){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await M.switchSession(e),o(`session-switched`,M.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),o(`error`,e)}},xe=e=>{I.value=e},Se=()=>{u.value?.focus?.()};return(0,t.onMounted)(async()=>{if(!(!g||m.value))try{if(j){if(await g.agent.getAgentInfo(),await g.session.getSessions(),a.sessionCode)await g.session.chooseSession(a.sessionCode);else if(g.session.list.value.length>0){let e=g.session.list.value[0];await g.session.chooseSession(e.sessionCode)}p.value=!0}else p.value=!0;o(`agent-info-loaded`,g)}catch(e){console.error(`Failed to initialize ChatBot:`,e),m.value=e,o(`error`,e)}}),(0,t.onBeforeUnmount)(()=>{j&&g&&g.agent.stopChat(g.session.current?.value?.sessionCode??``)}),n({sendMessage:e=>fe(e,[[]]),stopGeneration:ye,switchSession:be,messages:L,currentSession:te,isGenerating:ee,getChatHelper:()=>g,setCiteText:xe,focusInput:Se,selectShortcut:(e,t)=>{he(e,t)}}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:(0,t.normalizeClass)([`ai-chatbot`,a.extCls,{"welcome-state":z.value}]),style:(0,t.normalizeStyle)(ie.value)},[(0,t.createCommentVNode)(` 初始化错误提示 `),m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Ixt,[(0,t.createElementVNode)(`span`,null,(0,t.toDisplayString)(m.value.message),1)])):j&&!p.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 独立模式:初始化中(getAgentInfo → getSessions → chooseSession)统一展示 Loading `),(0,t.createElementVNode)(`div`,Lxt,[(0,t.createVNode)((0,t.unref)(i.Loading),{mode:`spin`,size:`small`,theme:`primary`})])],2112)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[(0,t.createCommentVNode)(` 内容区:欢迎状态 `),z.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Rxt,[(0,t.createElementVNode)(`div`,zxt,[n[3]||=(0,t.createElementVNode)(`h2`,{class:`welcome-title`},`你好,我是小鲸`,-1),B.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Bxt,[(0,t.createVNode)((0,t.unref)(c9),{content:B.value},null,8,[`content`])])):(0,t.createCommentVNode)(`v-if`,!0)])])):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 内容区:消息列表 `),(0,t.createElementVNode)(`div`,{ref_key:`messagesContainerRef`,ref:l,class:`chatbot-messages`},[R.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Vxt,[(0,t.createVNode)((0,t.unref)(i.Loading),{mode:`spin`,size:`small`,theme:`primary`})])):((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Lbt),{key:1,"selected-messages":f.value,"onUpdate:selectedMessages":n[0]||=e=>f.value=e,"enable-selection":a.enableSelection,"message-status":_.value,"message-tools-status":v.value,messages:L.value,"on-agent-action":y,"on-agent-feedback":b,"on-user-action":C,"on-user-input-confirm":E,"on-user-shortcut-confirm":D,onStopStreaming:A},null,8,[`selected-messages`,`enable-selection`,`message-status`,`message-tools-status`,`messages`]))],512)],2112)),(0,t.createCommentVNode)(` 统一底部区域 `),!z.value&&a.enableSelection?((0,t.openBlock)(),(0,t.createBlock)(Fxt,{key:2,"is-all-selected":f.value.length===L.value.length,loading:a.shareLoading,"selected-count":f.value.length,onCancel:oe,onConfirm:V,onToggleAll:se},null,8,[`is-all-selected`,`loading`,`selected-count`])):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Hxt,[d.value?.components?.length?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Be),(0,t.mergeProps)({key:0},d.value,{onClose:ge,onSubmit:ve}),null,16)):(0,t.renderSlot)(e.$slots,`input`,{key:1},()=>[(0,t.createVNode)((0,t.unref)(wyt),{ref_key:`chatInputRef`,ref:u,modelValue:F.value,"onUpdate:modelValue":n[1]||=e=>F.value=e,cite:I.value,"onUpdate:cite":n[2]||=e=>I.value=e,"message-status":_.value,"on-send-message":fe,"on-stop-sending":pe,"on-upload":de,placeholder:a.placeholder,prompts:re.value,resources:ne.value,"shortcut-id":d.value?.id,shortcuts:ae.value,onSelectShortcut:me},null,8,[`modelValue`,`cite`,`message-status`,`placeholder`,`prompts`,`resources`,`shortcut-id`,`shortcuts`])])]))],64))],6))}});let H9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function Wxt(e){let{url:n,requestOptions:r,autoInit:i=!0,protocolCallbacks:a}=e,o=(0,t.toValue)(n);if(!o)throw Error(`[useChatBootstrap] url is required`);let l=(0,t.ref)(H9.IDLE),u=(0,t.ref)(null),d=(0,t.ref)(!1),f=new Map,p=new s.AGUIProtocol({onStart:()=>{a?.onStart?.()},onMessage:e=>{a?.onMessage?.(e)},onDone:()=>{a?.onDone?.()},onError:e=>{a?.onError?.(e)}}),m=(0,s.useChatHelper)({requestData:{urlPrefix:o,headers:r?.headers,data:r?.data},protocol:p});p.injectMessageModule(m.message);let h=(0,t.computed)(()=>l.value===H9.LOADING_AGENT),g=(0,t.computed)(()=>l.value===H9.READY),_=(0,t.computed)(()=>m.agent.info.value??null),v=(0,t.computed)(()=>_.value?.agentName??``),y=(0,t.computed)(()=>m.session.current.value??null),b=(0,t.computed)(()=>m.session.list.value??[]),x=async()=>{if(!d.value&&!h.value){u.value=null;try{l.value=H9.LOADING_AGENT,await Promise.all([m.agent.getAgentInfo(),m.session.getSessions()]),l.value=H9.READY,d.value=!0}catch(e){throw console.error(`[useChatBootstrap] Initialization failed:`,e),u.value=e,l.value=H9.ERROR,e}}},S=async()=>{l.value=H9.IDLE,u.value=null,d.value=!1,await x()},C=async e=>{l.value=H9.IDLE,u.value=null,d.value=!1;let t=m.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await x()};return(0,t.watch)(()=>(0,t.toValue)(n),(e,t)=>{e&&e!==t&&t&&C(e)}),i&&Promise.resolve().then(()=>{x()}),{chatHelper:m,protocol:p,phase:l,isInitializing:h,isReady:g,error:u,agentInfo:_,agentName:v,currentSession:y,sessionList:b,initialize:x,retry:S,updateConfig:C,registerExtension:(e,t)=>{f.set(e,t)},getExtension:e=>f.get(e)}}function Gxt(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function Kxt(e){let{componentManager:n,emit:r,debug:i=!1}=e,a=[],o=()=>{for(let[e,t]of Object.entries(Oxt)){if(t===null)continue;let o=n.on(e,n=>{let a=kxt(e,n);i&&console.debug(`[useEventBridge] ${e} -> ${t}`,a),r(t,...a)});a.push(o)}},s=(e,t)=>{i&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,t),n.emit(e,t)},l=(e,...t)=>{i&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),r(e,...t)},u=()=>{a.forEach(e=>e()),a.length=0};return o(),(0,t.onUnmounted)(()=>{u()}),{forwardToManager:s,emitDirect:l,cleanup:u}}function qxt(e,n=!1){let r=window.innerHeight-48-40,i=window.innerWidth-48-16,a=(0,t.ref)(i),o=(0,t.ref)(r),s=(0,t.ref)(0),l=(0,t.ref)(n),u=(0,t.ref)(!1),d=(0,t.ref)(!1),f=0,p=e=>{e?a.value=window.innerWidth-12:a.value=i},m=(e,t)=>{o.value=t,s.value=t-r},h=()=>{(0,t.nextTick)(()=>{o.value=window.innerHeight-48-40+s.value,l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-48-16})};return(0,t.onMounted)(()=>{window.addEventListener(`resize`,h),h()}),(0,t.onUnmounted)(()=>{window.removeEventListener(`resize`,h)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:a,nimbusTop:o,isMinimize:l,isHovering:u,isDragging:d,handleNimbusDragging:m,handleNimbusMinimize:p,handleClick:()=>{if(d.value){d.value=!1;return}e(`click`)},handleMinimize:()=>{l.value=!l.value,e(`minimize`,l.value),l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-60},handleDragging:(e,t)=>{a.value=e,o.value=t},handleMouseEnter:()=>{u.value=!0},handleMouseLeave:()=>{u.value=!1},handleMouseDown:()=>{f=Date.now(),d.value=!1},handleMouseUp:()=>{Date.now()-f>200&&(d.value=!0)}}}function Jxt(e={}){let n=(0,t.ref)([]),r=(t,r,i={})=>{try{let o=typeof t==`string`?document.querySelector(t):t;if(!o)return console.warn(`Tooltip target not found: ${t}`),null;let s=(0,a.default)(o,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return n.value.push(s),s}catch(e){return console.error(`Failed to create tooltip:`,e),null}},i=(e,t,n={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=r(e,t,n);i&&a.push(i)}),a},o=e=>{let t=[];return e.forEach(({element:e,content:n,options:i})=>{let a=r(e,n,i);a&&t.push(a)}),t},s=()=>{n.value.forEach(e=>{e.destroy()}),n.value=[]};return(0,t.onBeforeUnmount)(()=>{s()}),{instances:n,createTooltip:r,createTooltipsForSelector:i,createMultipleTooltips:o,destroyAll:s,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}let Yxt={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:V9(`输入 "/" 唤出 Prompt
2821
+ `),Se();return}if(e.id===`rebuild`){await S(t);return}if(e.id===`delete`){await x(t);return}if(e.id===`share`){o(`request-share`);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await g?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},b=async(e,t,n,r)=>{if(!g){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let i=g.session.current?.value?.sessionCode;if(!i){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let a=zbt(N?.messages.value||[],t[0]);if(a===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let s=e.id===`like`?5:0;try{await g.session.postSessionFeedback({sessionCode:i,sessionContentIds:[a],rate:s,labels:n,comment:r}),o(`feedback`,e,t[0],n,r)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),o(`error`,e)}},x=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=N.messages.value,n=B9(t,e[0]);if(!n){console.error(`[ChatBot] No user message found before AI messages`);return}let r=[n,...e];await g.message.deleteMessages(r)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),o(`error`,e)}},S=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let t=g.session.current?.value?.sessionCode;if(!t){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await N.regenerateFromAIMessages(e,t),le()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),o(`error`,e)}},C=async(e,t)=>{if(e.id===`delete`){await k(t);return}if(e.id===`cite`){I.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),Se();return}console.log(`handleUserAction`,e,t)},E=async(e,t,n)=>{if(!g){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let r=g.session.current?.value?.sessionCode;if(!r){console.error(`[ChatBot] Cannot edit message: no active session`);return}let i=e.id;if(i===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,i,r,t),await g.agent.resendMessage(String(i),r,t),le()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),o(`error`,e)}},D=async(e,t)=>{if(!N||!g){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let n=g.session.current?.value?.sessionCode;if(!n){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let r=e.id;if(r===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let i=O(e);if(!i){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let a=_e(i,t),o=String(t.input??``);await N.resendMessageWithProperty(String(r),n,o,a),le()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),o(`error`,e)}},O=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?ce.value.find(e=>e.id===t.command)??null:null},k=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=N.messages.value,n=t.findIndex(t=>t===e);if(n===-1){console.error(`[ChatBot] User message not found in messages list`);return}let r=[];for(let e=n+1;e<t.length;e++){let n=t[e];if(n.role===w.User)break;r.push(n)}let i=[e,...r];await g.message.deleteMessages(i)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),o(`error`,e)}},A=async()=>{((a.chatHelper||g)?.agent)?.stopChat?.(g?.session.current?.value?.sessionCode??``)},j=!a.chatHelper,M=g?new Cxt(g.session,g.message,null,{enableChatSession:!0,autoSwitchToInitialSession:!!a.sessionCode,loadRecentSessionOnMount:a.autoLoad,initialSessionCode:a.sessionCode}):null,N=g?new Sxt(g.agent,g.message,g.session,null,{openingRemark:a.helloText,predefinedQuestions:a.prompts,placeholder:a.placeholder}):null,P=new Txt(null,a.shortcuts||[]),F=(0,t.shallowRef)([[]]),I=(0,t.ref)(``),L=(0,t.computed)(()=>N?.messages.value??[]),R=(0,t.computed)(()=>N?.isMessagesLoading.value??!1),ee=(0,t.computed)(()=>N?.isGenerating.value??!1),te=(0,t.computed)(()=>M?.currentSession.value??null),z=(0,t.computed)(()=>j&&!p.value?!1:!R.value&&L.value.length===0),B=(0,t.computed)(()=>g?.agent.info.value?.conversationSettings?.openingRemark||``),ne=(0,t.computed)(()=>a.resources?.length?a.resources:Vbt(g?.agent.info.value?.resources)),re=(0,t.computed)(()=>a.prompts?.length?a.prompts:g?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),ie=(0,t.computed)(()=>({height:typeof a.height==`number`?`${a.height}px`:a.height,maxWidth:typeof a.maxWidth==`number`?`${a.maxWidth}px`:a.maxWidth})),ae=(0,t.computed)(()=>{let e=P.shortcuts.value;return a.shortcutLimit&&e.length>a.shortcutLimit?e.slice(0,a.shortcutLimit):e}),oe=()=>{f.value=[],o(`cancel-share`)},V=()=>{o(`confirm-share`,f.value)},se=e=>{e?f.value=L.value:f.value=[]},ce=P.effectiveShortcuts;(0,t.watch)(()=>a.shortcuts,e=>{P.setShortcuts(e||[])},{immediate:!0}),(0,t.watch)(()=>g?.agent.info.value?.conversationSettings?.commands,e=>{e&&P.setAgentShortcuts(e)},{immediate:!0});let le=async()=>{await(0,t.nextTick)(),l.value&&(l.value.scrollTop=l.value.scrollHeight)},ue=async(e,t={})=>{if(!N||!g)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let n=g.session.current?.value?.sessionCode;if(!n)throw Error(`[ChatBot] Cannot send message: no active session`);F.value=[[]],I.value=``,o(`send-message`,typeof e==`string`?e:``),await N.sendMessage(e,n,t)},de=async e=>{let t=g?.session.current?.value?.sessionCode;if(!t)throw Error(`[ChatBot] Cannot upload: no active session`);let n=await g.session.uploadFile(t,e);if(!n?.download_url)throw Error(`[ChatBot] Upload failed: no download URL returned`);return n},fe=async(e,t)=>{try{await ue(e,I.value?{property:{extra:{cite:I.value}}}:{})}catch(e){console.error(`Failed to send message:`,e),o(`error`,e)}},pe=async()=>{ye()},me=(e,t)=>{he(e,t),o(`shortcut-click`,{shortcut:e,source:`main`})},he=(e,t)=>{let n=e,r=n.components?.find(e=>e.fillBack)?.key||`input`;d.value={...n,formModel:{...n.formModel,[r]:t||``}}},ge=()=>{d.value=null},_e=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},ve=async e=>{if(!d.value){console.error(`[ChatBot] No selected shortcut`);return}let t=_e(d.value,e),n=d.value.name,r=d.value;ge();try{await ue(n,{property:t})}catch(e){d.value=r,console.error(`[ChatBot] Failed to submit shortcut:`,e),o(`error`,e)}},ye=()=>{if(!N){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}N.stopGeneration(),o(`stop`)},be=async e=>{if(!M){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await M.switchSession(e),o(`session-switched`,M.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),o(`error`,e)}},xe=e=>{I.value=e},Se=()=>{u.value?.focus?.()};return(0,t.onMounted)(async()=>{if(!(!g||m.value))try{if(j){if(await g.agent.getAgentInfo(),await g.session.getSessions(),a.sessionCode)await g.session.chooseSession(a.sessionCode);else if(g.session.list.value.length>0){let e=g.session.list.value[0];await g.session.chooseSession(e.sessionCode)}p.value=!0}else p.value=!0;o(`agent-info-loaded`,g)}catch(e){console.error(`Failed to initialize ChatBot:`,e),m.value=e,o(`error`,e)}}),(0,t.onBeforeUnmount)(()=>{j&&g&&g.agent.stopChat(g.session.current?.value?.sessionCode??``)}),n({sendMessage:e=>fe(e,[[]]),stopGeneration:ye,switchSession:be,messages:L,currentSession:te,isGenerating:ee,getChatHelper:()=>g,setCiteText:xe,focusInput:Se,selectShortcut:(e,t)=>{he(e,t)}}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:(0,t.normalizeClass)([`ai-chatbot`,a.extCls,{"welcome-state":z.value}]),style:(0,t.normalizeStyle)(ie.value)},[(0,t.createCommentVNode)(` 初始化错误提示 `),m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Ixt,[(0,t.createElementVNode)(`span`,null,(0,t.toDisplayString)(m.value.message),1)])):j&&!p.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 独立模式:初始化中(getAgentInfo → getSessions → chooseSession)统一展示 Loading `),(0,t.createElementVNode)(`div`,Lxt,[(0,t.createVNode)((0,t.unref)(i.Loading),{mode:`spin`,size:`small`,theme:`primary`})])],2112)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[(0,t.createCommentVNode)(` 内容区:欢迎状态 `),z.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Rxt,[(0,t.createElementVNode)(`div`,zxt,[n[3]||=(0,t.createElementVNode)(`h2`,{class:`welcome-title`},`你好,我是小鲸`,-1),B.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Bxt,[(0,t.createVNode)((0,t.unref)(c9),{content:B.value},null,8,[`content`])])):(0,t.createCommentVNode)(`v-if`,!0)])])):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 内容区:消息列表 `),(0,t.createElementVNode)(`div`,{ref_key:`messagesContainerRef`,ref:l,class:`chatbot-messages`},[R.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Vxt,[(0,t.createVNode)((0,t.unref)(i.Loading),{mode:`spin`,size:`small`,theme:`primary`})])):((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Lbt),{key:1,"selected-messages":f.value,"onUpdate:selectedMessages":n[0]||=e=>f.value=e,"enable-selection":a.enableSelection,"message-status":_.value,"message-tools-status":v.value,messages:L.value,"on-agent-action":y,"on-agent-feedback":b,"on-user-action":C,"on-user-input-confirm":E,"on-user-shortcut-confirm":D,onStopStreaming:A},null,8,[`selected-messages`,`enable-selection`,`message-status`,`message-tools-status`,`messages`]))],512)],2112)),(0,t.createCommentVNode)(` 统一底部区域 `),!z.value&&a.enableSelection?((0,t.openBlock)(),(0,t.createBlock)(Fxt,{key:2,"is-all-selected":f.value.length===L.value.length,loading:a.shareLoading,"selected-count":f.value.length,onCancel:oe,onConfirm:V,onToggleAll:se},null,8,[`is-all-selected`,`loading`,`selected-count`])):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Hxt,[d.value?.components?.length?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Be),(0,t.mergeProps)({key:0},d.value,{onClose:ge,onSubmit:ve}),null,16)):(0,t.renderSlot)(e.$slots,`input`,{key:1},()=>[(0,t.createVNode)((0,t.unref)(wyt),{ref_key:`chatInputRef`,ref:u,modelValue:F.value,"onUpdate:modelValue":n[1]||=e=>F.value=e,cite:I.value,"onUpdate:cite":n[2]||=e=>I.value=e,"message-status":_.value,"on-send-message":fe,"on-stop-sending":pe,"on-upload":de,placeholder:a.placeholder,prompts:re.value,resources:ne.value,"shortcut-id":d.value?.id,shortcuts:ae.value,onSelectShortcut:me},null,8,[`modelValue`,`cite`,`message-status`,`placeholder`,`prompts`,`resources`,`shortcut-id`,`shortcuts`])])]))],64))],6))}});let H9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function Wxt(e){let{url:n,requestOptions:r,autoInit:i=!0,protocolCallbacks:a}=e,o=(0,t.toValue)(n);if(!o)throw Error(`[useChatBootstrap] url is required`);let l=(0,t.ref)(H9.IDLE),u=(0,t.ref)(null),d=(0,t.ref)(!1),f=new Map,p=new s.AGUIProtocol({onStart:()=>{a?.onStart?.()},onMessage:e=>{a?.onMessage?.(e)},onDone:()=>{a?.onDone?.()},onError:e=>{a?.onError?.(e)}}),m=(0,s.useChatHelper)({requestData:{urlPrefix:o,headers:r?.headers,data:r?.data},protocol:p});p.injectMessageModule(m.message);let h=(0,t.computed)(()=>l.value===H9.LOADING_AGENT),g=(0,t.computed)(()=>l.value===H9.READY),_=(0,t.computed)(()=>m.agent.info.value??null),v=(0,t.computed)(()=>_.value?.agentName??``),y=(0,t.computed)(()=>m.session.current.value??null),b=(0,t.computed)(()=>m.session.list.value??[]),x=async()=>{if(!d.value&&!h.value){u.value=null;try{l.value=H9.LOADING_AGENT,await Promise.all([m.agent.getAgentInfo(),m.session.getSessions()]),l.value=H9.READY,d.value=!0}catch(e){throw console.error(`[useChatBootstrap] Initialization failed:`,e),u.value=e,l.value=H9.ERROR,e}}},S=async()=>{l.value=H9.IDLE,u.value=null,d.value=!1,await x()},C=async e=>{l.value=H9.IDLE,u.value=null,d.value=!1;let t=m.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await x()};return(0,t.watch)(()=>(0,t.toValue)(n),(e,t)=>{e&&e!==t&&t&&C(e)}),i&&Promise.resolve().then(()=>{x()}),{chatHelper:m,protocol:p,phase:l,isInitializing:h,isReady:g,error:u,agentInfo:_,agentName:v,currentSession:y,sessionList:b,initialize:x,retry:S,updateConfig:C,registerExtension:(e,t)=>{f.set(e,t)},getExtension:e=>f.get(e)}}function Gxt(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function Kxt(e){let{componentManager:n,emit:r,debug:i=!1}=e,a=[],o=()=>{for(let[e,t]of Object.entries(Oxt)){if(t===null)continue;let o=n.on(e,n=>{let a=kxt(e,n);i&&console.debug(`[useEventBridge] ${e} -> ${t}`,a),r(t,...a)});a.push(o)}},s=(e,t)=>{i&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,t),n.emit(e,t)},l=(e,...t)=>{i&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),r(e,...t)},u=()=>{a.forEach(e=>e()),a.length=0};return o(),(0,t.onUnmounted)(()=>{u()}),{forwardToManager:s,emitDirect:l,cleanup:u}}function qxt(e,n=!1){let r=window.innerHeight-48-40,i=window.innerWidth-48-16,a=(0,t.ref)(i),o=(0,t.ref)(r),s=(0,t.ref)(0),l=(0,t.ref)(n),u=(0,t.ref)(!1),d=(0,t.ref)(!1),f=0,p=e=>{e?a.value=window.innerWidth-12:a.value=i},m=(e,t)=>{o.value=t,s.value=t-r},h=()=>{(0,t.nextTick)(()=>{o.value=window.innerHeight-48-40+s.value,l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-48-16})};return(0,t.onMounted)(()=>{window.addEventListener(`resize`,h),h()}),(0,t.onUnmounted)(()=>{window.removeEventListener(`resize`,h)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:a,nimbusTop:o,isMinimize:l,isHovering:u,isDragging:d,handleNimbusDragging:m,handleNimbusMinimize:p,handleClick:()=>{if(d.value){d.value=!1;return}e(`click`)},handleMinimize:()=>{l.value=!l.value,e(`minimize`,l.value),l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-60},handleDragging:(e,t)=>{a.value=e,o.value=t},handleMouseEnter:()=>{u.value=!0},handleMouseLeave:()=>{u.value=!1},handleMouseDown:()=>{f=Date.now(),d.value=!1},handleMouseUp:()=>{Date.now()-f>200&&(d.value=!0)}}}function Jxt(e={}){let n=(0,t.ref)([]),r=(t,r,i={})=>{try{let o=typeof t==`string`?document.querySelector(t):t;if(!o)return console.warn(`Tooltip target not found: ${t}`),null;let s=(0,a.default)(o,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return n.value.push(s),s}catch(e){return console.error(`Failed to create tooltip:`,e),null}},i=(e,t,n={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=r(e,t,n);i&&a.push(i)}),a},o=e=>{let t=[];return e.forEach(({element:e,content:n,options:i})=>{let a=r(e,n,i);a&&t.push(a)}),t},s=()=>{n.value.forEach(e=>{e.destroy()}),n.value=[]};return(0,t.onBeforeUnmount)(()=>{s()}),{instances:n,createTooltip:r,createTooltipsForSelector:i,createMultipleTooltips:o,destroyAll:s,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}let Yxt={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:V9(`输入 "/" 唤出 Prompt
2822
2822
  通过 Shift + Enter 进行换行输入`),helloText:V9(`你好,我是小鲸`),disabledInput:!1,showHistoryIcon:!0,showNewChatIcon:!0,showCompressionIcon:!0,showMoreIcon:!0,initialSessionCode:``,autoSwitchToInitialSession:!1,loadRecentSessionOnMount:!0,prompts:()=>[],dropdownMenuConfig:()=>({showRename:!0,showAutoGenerate:!0,showShare:!0}),defaultChatInputPosition:void 0};function Xxt(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function U9(e,t,n,r=1){let[i,a]=typeof r==`number`?[r,r]:r;return[Math.round(t/i/e[0])*e[0],Math.round(n/a/e[1])*e[1]]}function W9(e,t,n){return e-t-n}function G9(e,t,n){return e-t-n}function K9(e,t,n){return t!==null&&e<t?t:n!==null&&n<e?n:e}function Zxt(e,t,n){let r=e,i=[`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`].find(e=>Xxt(r[e]));if(!Xxt(r[i]))return!1;do{if(r[i](t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function Qxt(e){let t=window.getComputedStyle(e);return[parseFloat(t.getPropertyValue(`width`),10),parseFloat(t.getPropertyValue(`height`),10)]}function q9(e,t,n){e&&(e.attachEvent?e.attachEvent(`on`+t,n):e.addEventListener?e.addEventListener(t,n,!0):e[`on`+t]=n)}function J9(e,t,n){e&&(e.detachEvent?e.detachEvent(`on`+t,n):e.removeEventListener?e.removeEventListener(t,n,!0):e[`on`+t]=null)}var $xt=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Y9={mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`},touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`}},eSt={userSelect:`none`,MozUserSelect:`none`,WebkitUserSelect:`none`,MsUserSelect:`none`},tSt={userSelect:`auto`,MozUserSelect:`auto`,WebkitUserSelect:`auto`,MsUserSelect:`auto`},X9=Y9.mouse,nSt={replace:!0,name:`vue-draggable-resizable`,props:{className:{type:String,default:`vdr`},classNameDraggable:{type:String,default:`draggable`},classNameResizable:{type:String,default:`resizable`},classNameDragging:{type:String,default:`dragging`},classNameResizing:{type:String,default:`resizing`},classNameActive:{type:String,default:`active`},classNameHandle:{type:String,default:`handle`},disableUserSelect:{type:Boolean,default:!0},enableNativeDrag:{type:Boolean,default:!1},preventDeactivation:{type:Boolean,default:!1},active:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},w:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},h:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},minWidth:{type:Number,default:0,validator:e=>e>=0},minHeight:{type:Number,default:0,validator:e=>e>=0},maxWidth:{type:Number,default:null,validator:e=>e>=0},maxHeight:{type:Number,default:null,validator:e=>e>=0},x:{type:Number,default:0},y:{type:Number,default:0},z:{type:[String,Number],default:`auto`,validator:e=>typeof e==`string`?e===`auto`:e>=0},handles:{type:Array,default:()=>[`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`],validator:e=>{let t=new Set([`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`]);return new Set(e.filter(e=>t.has(e))).size===e.length}},dragHandle:{type:String,default:null},dragCancel:{type:String,default:null},axis:{type:String,default:`both`,validator:e=>[`x`,`y`,`both`].includes(e)},grid:{type:Array,default:()=>[1,1]},parent:{type:Boolean,default:!1},scale:{type:[Number,Array],default:1,validator:e=>typeof e==`number`?e>0:e.length===2&&e[0]>0&&e[1]>0},onDragStart:{type:Function,default:()=>!0},onDrag:{type:Function,default:()=>!0},onResizeStart:{type:Function,default:()=>!0},onResize:{type:Function,default:()=>!0}},data:function(){return{left:this.x,top:this.y,right:null,bottom:null,width:null,height:null,widthTouched:!1,heightTouched:!1,aspectFactor:null,parentWidth:null,parentHeight:null,handle:null,enabled:this.active,resizing:!1,dragging:!1,dragEnable:!1,resizeEnable:!1,zIndex:this.z}},created:function(){this.maxWidth&&this.minWidth>this.maxWidth&&console.warn(`[Vdr warn]: Invalid prop: minWidth cannot be greater than maxWidth`),this.maxHeight&&this.minHeight>this.maxHeight&&console.warn(`[Vdr warn]: Invalid prop: minHeight cannot be greater than maxHeight`),this.resetBoundsAndMouseState()},mounted:function(){this.enableNativeDrag||(this.$el.ondragstart=()=>!1);let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t;let[n,r]=Qxt(this.$el);this.aspectFactor=(this.w===`auto`?n:this.w)/(this.h===`auto`?r:this.h),this.width=this.w===`auto`?n:this.w,this.height=this.h===`auto`?r:this.h,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top,this.active&&this.$emit(`activated`),q9(document.documentElement,`mousedown`,this.deselect),q9(document.documentElement,`touchend touchcancel`,this.deselect),q9(window,`resize`,this.checkParentSize)},beforeUnmount:function(){J9(document.documentElement,`mousedown`,this.deselect),J9(document.documentElement,`touchstart`,this.handleUp),J9(document.documentElement,`mousemove`,this.move),J9(document.documentElement,`touchmove`,this.move),J9(document.documentElement,`mouseup`,this.handleUp),J9(document.documentElement,`touchend touchcancel`,this.deselect),J9(window,`resize`,this.checkParentSize)},methods:{resetBoundsAndMouseState(){this.mouseClickPosition={mouseX:0,mouseY:0,x:0,y:0,w:0,h:0},this.bounds={minLeft:null,maxLeft:null,minRight:null,maxRight:null,minTop:null,maxTop:null,minBottom:null,maxBottom:null}},checkParentSize(){if(this.parent){let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top}},getParentSize(){if(this.parent){let e=window.getComputedStyle(this.$el.parentNode,null);return[parseInt(e.getPropertyValue(`width`),10),parseInt(e.getPropertyValue(`height`),10)]}return[null,null]},elementTouchDown(e){X9=Y9.touch,this.elementDown(e)},elementMouseDown(e){X9=Y9.mouse,this.elementDown(e)},elementDown(e){if(e instanceof MouseEvent&&e.button!==0)return;let t=e.target||e.srcElement;if(this.$el.contains(t)){if(this.onDragStart(e)===!1)return;if(this.dragHandle&&!Zxt(t,this.dragHandle,this.$el)||this.dragCancel&&Zxt(t,this.dragCancel,this.$el)){this.dragging=!1;return}this.enabled||(this.enabled=!0,this.$emit(`activated`),this.$emit(`update:active`,!0)),this.draggable&&(this.dragEnable=!0),this.mouseClickPosition.mouseX=e.touches?e.touches[0].pageX:e.pageX,this.mouseClickPosition.mouseY=e.touches?e.touches[0].pageY:e.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.parent&&(this.bounds=this.calcDragLimits()),q9(document.documentElement,X9.move,this.move),q9(document.documentElement,X9.stop,this.handleUp)}},calcDragLimits(){return{minLeft:this.left%this.grid[0],maxLeft:Math.floor((this.parentWidth-this.width-this.left)/this.grid[0])*this.grid[0]+this.left,minRight:this.right%this.grid[0],maxRight:Math.floor((this.parentWidth-this.width-this.right)/this.grid[0])*this.grid[0]+this.right,minTop:this.top%this.grid[1],maxTop:Math.floor((this.parentHeight-this.height-this.top)/this.grid[1])*this.grid[1]+this.top,minBottom:this.bottom%this.grid[1],maxBottom:Math.floor((this.parentHeight-this.height-this.bottom)/this.grid[1])*this.grid[1]+this.bottom}},deselect(e){let t=e.target||e.srcElement,n=RegExp(this.className+`-([trmbl]{2})`,``);!this.$el.contains(t)&&!n.test(t.className)&&(this.enabled&&!this.preventDeactivation&&(this.enabled=!1,this.$emit(`deactivated`),this.$emit(`update:active`,!1)),J9(document.documentElement,X9.move,this.handleResize)),this.resetBoundsAndMouseState()},handleTouchDown(e,t){X9=Y9.touch,this.handleDown(e,t)},handleDown(e,t){t instanceof MouseEvent&&t.which!==1||this.onResizeStart(e,t)!==!1&&(t.stopPropagation&&t.stopPropagation(),this.lockAspectRatio&&!e.includes(`m`)?this.handle=`m`+e.substring(1):this.handle=e,this.resizeEnable=!0,this.mouseClickPosition.mouseX=t.touches?t.touches[0].pageX:t.pageX,this.mouseClickPosition.mouseY=t.touches?t.touches[0].pageY:t.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.bounds=this.calcResizeLimits(),q9(document.documentElement,X9.move,this.handleResize),q9(document.documentElement,X9.stop,this.handleUp))},calcResizeLimits(){let e=this.minW,t=this.minH,n=this.maxW,r=this.maxH,i=this.aspectFactor,[a,o]=this.grid,s=this.width,l=this.height,u=this.left,d=this.top,f=this.right,p=this.bottom;this.lockAspectRatio&&(e/t>i?t=e/i:e=i*t,n&&r?(n=Math.min(n,i*r),r=Math.min(r,n/i)):n?r=n/i:r&&(n=i*r)),n-=n%a,r-=r%o;let m={minLeft:null,maxLeft:null,minTop:null,maxTop:null,minRight:null,maxRight:null,minBottom:null,maxBottom:null};return this.parent?(m.minLeft=u%a,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=d%o,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=f%a,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=p%o,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=Math.max(m.minLeft,this.parentWidth-f-n),m.minRight=Math.max(m.minRight,this.parentWidth-u-n)),r&&(m.minTop=Math.max(m.minTop,this.parentHeight-p-r),m.minBottom=Math.max(m.minBottom,this.parentHeight-d-r)),this.lockAspectRatio&&(m.minLeft=Math.max(m.minLeft,u-d*i),m.minTop=Math.max(m.minTop,d-u/i),m.minRight=Math.max(m.minRight,f-p*i),m.minBottom=Math.max(m.minBottom,p-f/i))):(m.minLeft=null,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=null,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=null,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=null,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=-(f+n),m.minRight=-(u+n)),r&&(m.minTop=-(p+r),m.minBottom=-(d+r)),this.lockAspectRatio&&n&&r&&(m.minLeft=Math.min(m.minLeft,-(f+n)),m.minTop=Math.min(m.minTop,-(r+p)),m.minRight=Math.min(m.minRight,-u-n),m.minBottom=Math.min(m.minBottom,-d-r))),m},move(e){this.resizing?this.handleResize(e):this.dragEnable&&this.handleDrag(e)},handleDrag(e){let t=this.axis,n=this.grid,r=this.bounds,i=this.mouseClickPosition,[a,o]=U9(n,t&&t!==`y`?i.mouseX-(e.touches?e.touches[0].pageX:e.pageX):0,t&&t!==`x`?i.mouseY-(e.touches?e.touches[0].pageY:e.pageY):0,this.scale),s=K9(i.left-a,r.minLeft,r.maxLeft),l=K9(i.top-o,r.minTop,r.maxTop);if(this.onDrag(s,l)===!1)return;let u=K9(i.right+a,r.minRight,r.maxRight),d=K9(i.bottom+o,r.minBottom,r.maxBottom);this.left=s,this.top=l,this.right=u,this.bottom=d,this.$emit(`dragging`,this.left,this.top),this.dragging=!0},moveHorizontally(e){let[t,n]=U9(this.grid,e,this.top,1),r=K9(t,this.bounds.minLeft,this.bounds.maxLeft);this.left=r,this.right=this.parentWidth-this.width-r},moveVertically(e){let[t,n]=U9(this.grid,this.left,e,1),r=K9(n,this.bounds.minTop,this.bounds.maxTop);this.top=r,this.bottom=this.parentHeight-this.height-r},handleResize(e){let t=this.left,n=this.top,r=this.right,i=this.bottom,a=this.mouseClickPosition,o=this.aspectFactor,s=a.mouseX-(e.touches?e.touches[0].pageX:e.pageX),l=a.mouseY-(e.touches?e.touches[0].pageY:e.pageY);!this.widthTouched&&s&&(this.widthTouched=!0),!this.heightTouched&&l&&(this.heightTouched=!0);let[u,d]=U9(this.grid,s,l,this.scale);this.handle.includes(`b`)?(i=K9(a.bottom+d,this.bounds.minBottom,this.bounds.maxBottom),this.lockAspectRatio&&this.resizingOnY&&(r=this.right-(this.bottom-i)*o)):this.handle.includes(`t`)&&(n=K9(a.top-d,this.bounds.minTop,this.bounds.maxTop),this.lockAspectRatio&&this.resizingOnY&&(t=this.left-(this.top-n)*o)),this.handle.includes(`r`)?(r=K9(a.right+u,this.bounds.minRight,this.bounds.maxRight),this.lockAspectRatio&&this.resizingOnX&&(i=this.bottom-(this.right-r)/o)):this.handle.includes(`l`)&&(t=K9(a.left-u,this.bounds.minLeft,this.bounds.maxLeft),this.lockAspectRatio&&this.resizingOnX&&(n=this.top-(this.left-t)/o));let f=W9(this.parentWidth,t,r),p=G9(this.parentHeight,n,i);this.onResize(this.handle,t,n,f,p)!==!1&&(this.left=t,this.top=n,this.right=r,this.bottom=i,this.width=f,this.height=p,this.$emit(`resizing`,this.left,this.top,this.width,this.height),this.resizing=!0)},changeWidth(e){let[t,n]=U9(this.grid,e,0,1),r=K9(this.parentWidth-t-this.left,this.bounds.minRight,this.bounds.maxRight),i=this.bottom;this.lockAspectRatio&&(i=this.bottom-(this.right-r)/this.aspectFactor);let a=W9(this.parentWidth,this.left,r),o=G9(this.parentHeight,this.top,i);this.right=r,this.bottom=i,this.width=a,this.height=o},changeHeight(e){let[t,n]=U9(this.grid,0,e,1),r=K9(this.parentHeight-n-this.top,this.bounds.minBottom,this.bounds.maxBottom),i=this.right;this.lockAspectRatio&&(i=this.right-(this.bottom-r)*this.aspectFactor);let a=W9(this.parentWidth,this.left,i),o=G9(this.parentHeight,this.top,r);this.right=i,this.bottom=r,this.width=a,this.height=o},handleUp(e){this.handle=null,this.resetBoundsAndMouseState(),this.dragEnable=!1,this.resizeEnable=!1,this.resizing&&(this.resizing=!1,this.$emit(`resizeStop`,this.left,this.top,this.width,this.height)),this.dragging&&(this.dragging=!1,this.$emit(`dragStop`,this.left,this.top)),J9(document.documentElement,X9.move,this.handleResize)}},computed:{style(){return{transform:`translate(${this.left}px, ${this.top}px)`,width:this.computedWidth,height:this.computedHeight,zIndex:this.zIndex,...this.dragging&&this.disableUserSelect?eSt:tSt}},actualHandles(){return this.resizable?this.handles:[]},computedWidth(){return this.w===`auto`&&!this.widthTouched?`auto`:this.width+`px`},computedHeight(){return this.h===`auto`&&!this.heightTouched?`auto`:this.height+`px`},minW(){return this.minWidth},minH(){return this.minHeight},maxW(){return this.maxWidth},maxH(){return this.maxHeight},resizingOnX(){return!!this.handle&&(this.handle.includes(`l`)||this.handle.includes(`r`))},resizingOnY(){return!!this.handle&&(this.handle.includes(`t`)||this.handle.includes(`b`))},isCornerHandle(){return!!this.handle&&[`tl`,`tr`,`br`,`bl`].includes(this.handle)}},watch:{active(e){this.enabled=e,e?this.$emit(`activated`):this.$emit(`deactivated`)},z(e){(e>=0||e===`auto`)&&(this.zIndex=e)},x(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveHorizontally(e))},y(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveVertically(e))},lockAspectRatio(e){e?this.aspectFactor=this.width/this.height:this.aspectFactor=void 0},w(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeWidth(e))},h(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeHeight(e))}}},rSt=[`onMousedown`,`onTouchstart`];function iSt(e,n,r,i,a,o){return(0,t.openBlock)(),(0,t.createElementBlock)(`div`,{style:(0,t.normalizeStyle)(o.style),class:(0,t.normalizeClass)([{[r.classNameActive]:e.enabled,[r.classNameDragging]:e.dragging,[r.classNameResizing]:e.resizing,[r.classNameDraggable]:r.draggable,[r.classNameResizable]:r.resizable},r.className]),onMousedown:n[0]||=(...e)=>o.elementMouseDown&&o.elementMouseDown(...e),onTouchstart:n[1]||=(...e)=>o.elementTouchDown&&o.elementTouchDown(...e)},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(o.actualHandles,n=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:n,class:(0,t.normalizeClass)([r.classNameHandle,r.classNameHandle+`-`+n]),style:(0,t.normalizeStyle)({display:e.enabled?`block`:`none`}),onMousedown:(0,t.withModifiers)(e=>o.handleDown(n,e),[`stop`,`prevent`]),onTouchstart:(0,t.withModifiers)(e=>o.handleTouchDown(n,e),[`stop`,`prevent`])},[(0,t.renderSlot)(e.$slots,n)],46,rSt))),128)),(0,t.renderSlot)(e.$slots,`default`)],38)}var Z9=$xt(nSt,[[`render`,iSt]]);function Q9(e){Q9.installed||(Q9.installed=!0,e.component(`VueDraggableResizable`,Z9))}var aSt={install:Q9},$9=null;typeof window<`u`?$9=window.Vue:typeof global<`u`&&($9=global.Vue),$9&&$9.use(aSt);function oSt(e={},n){let r=e.initWidth||400,i=e.minWidth||400,a=e.minHeight||400,o=e.maxWidthPercent||40,s=e.compressedHeight||800,l=e.compressedPadding===void 0?0:e.compressedPadding,u=(0,t.ref)(e.defaultLeft===void 0?window.innerWidth-r:e.defaultLeft),d=(0,t.ref)(e.defaultTop===void 0?0:e.defaultTop),f=(0,t.ref)(e.defaultHeight===void 0?window.innerHeight-(e.defaultTop===void 0?0:e.defaultTop):e.defaultHeight),p=(0,t.ref)(r),m=(0,t.ref)(d.value),h=(0,t.ref)(u.value),g=(0,t.ref)(p.value),_=(0,t.ref)(f.value),v=(0,t.ref)(Math.max(window.innerWidth*(o/100),g.value)),y=(0,t.ref)(!1),b=(0,t.ref)(0),x=()=>({x:h.value,y:m.value,width:g.value,height:_.value}),S=(e,t)=>{h.value=e,m.value=t,b.value=e-(window.innerWidth-g.value),n?.onDragging?.(x())},C=(e,t,r,i)=>{h.value=e,m.value=t,g.value=Math.min(r,v.value),_.value=i,n?.onResizing?.(x())},w=(e,t)=>{h.value=e,m.value=t,b.value=e-(window.innerWidth-g.value),n?.onDragStop?.(x())},T=(e,t,r,i)=>{h.value=e,m.value=t,g.value=Math.min(r,v.value),_.value=i,n?.onResizeStop?.(x())},E=()=>{v.value=Math.max(window.innerWidth*(o/100),g.value),(0,t.nextTick)(()=>{if(y.value)h.value=window.innerWidth-g.value-l,m.value=window.innerHeight-s-l;else{let e=window.innerWidth-g.value-b.value;h.value=Math.max(0,e),setTimeout(()=>{_.value=window.innerHeight-m.value},0)}g.value>v.value&&(g.value=v.value)})},D=()=>{y.value?(m.value=d.value,(0,t.nextTick)(()=>{_.value=f.value,h.value=u.value,g.value=p.value})):(m.value=window.innerHeight-s-l,h.value=u.value-l,g.value=r,_.value=s),y.value=!y.value},O=(e,t)=>{h.value=e,m.value=t,b.value=e-(window.innerWidth-g.value)},k=(e,t)=>{g.value=Math.max(i,Math.min(e,v.value)),_.value=Math.max(a,t)};return(0,t.onMounted)(()=>{window.addEventListener(`resize`,E)}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,E)}),{minWidth:i,minHeight:a,maxWidth:v,top:m,left:h,width:g,height:_,isCompressed:y,handleDragging:S,handleResizing:C,handleDragStop:w,handleResizeStop:T,toggleCompression:D,updatePosition:O,updateSize:k,updatePositionAndSize:(e,t,n,r)=>{O(e,t),k(n,r)}}}var sSt={class:`draggable-container-content`},cSt=z9((0,t.defineComponent)({__name:`draggable-container`,props:{visible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},defaultWidth:{default:400},defaultHeight:{default:void 0},defaultX:{default:void 0},defaultY:{default:0},minWidth:{default:400},minHeight:{default:400},maxWidth:{default:void 0},maxWidthPercent:{default:80},compressedHeight:{default:800},compressedPadding:{default:0},dragHandle:{default:`.drag-handle`},className:{default:``},teleportTo:{default:`body`}},emits:[`dragging`,`resizing`,`drag-stop`,`resize-stop`,`compression-change`],setup(e,{expose:n,emit:r}){let i=e,a=r,o=(0,t.ref)(!1),{minWidth:s,minHeight:l,maxWidth:u,top:d,left:f,width:p,height:m,isCompressed:h,handleDragging:g,handleResizing:_,handleDragStop:v,handleResizeStop:y,toggleCompression:b,updatePosition:x,updateSize:S,updatePositionAndSize:C}=oSt({initWidth:i.defaultWidth,minWidth:i.minWidth,minHeight:i.minHeight,maxWidthPercent:i.maxWidthPercent,compressedHeight:i.compressedHeight,defaultHeight:i.defaultHeight,defaultTop:i.defaultY,defaultLeft:i.defaultX,compressedPadding:i.compressedPadding},{onDragStop:e=>a(`drag-stop`,e),onResizeStop:e=>a(`resize-stop`,e),onDragging:e=>a(`dragging`,e),onResizing:e=>a(`resizing`,e)}),w=(0,t.computed)(()=>{let e=typeof i.maxWidth==`number`?`${i.maxWidth}px`:i.maxWidth??`${u.value}px`;return{"--draggable-max-width":e}}),T=(0,t.computed)(()=>({x:f.value,y:d.value,width:p.value,height:m.value})),E=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=`none`})},D=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=``})},O=(e,t)=>{o.value||(o.value=!0,E()),g(e,t)},k=(e,t,n,r)=>{o.value||(o.value=!0,E()),_(e,t,n,r)},A=(e,t)=>{v(e,t),o.value=!1,D()},j=(e,t,n,r)=>{y(e,t,n,r),o.value=!1,D()};return(0,t.watch)(h,e=>{a(`compression-change`,e)}),n({updatePosition:x,updateSize:S,updatePositionAndSize:C,toggleCompression:b,positionAndSize:T,isCompressed:h}),(e,n)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Z9),{ref:`draggableRef`,class:(0,t.normalizeClass)([`draggable-container-wrapper`,i.className]),style:(0,t.normalizeStyle)(w.value),active:i.visible,draggable:i.draggable,resizable:i.resizable,w:(0,t.unref)(p),h:(0,t.unref)(m),x:(0,t.unref)(f),y:(0,t.unref)(d),"min-width":(0,t.unref)(s),"min-height":(0,t.unref)(l),"max-width":(0,t.unref)(u),parent:!0,"prevent-deactivation":!0,"drag-handle":i.dragHandle,"class-name":`draggable-container-inner`,onDragging:O,onResizing:k,onDragStop:A,onResizeStop:j},{default:(0,t.withCtx)(()=>[(0,t.createElementVNode)(`div`,sSt,[(0,t.renderSlot)(e.$slots,`default`,{},void 0,!0)])]),_:3},8,[`class`,`style`,`active`,`draggable`,`resizable`,`w`,`h`,`x`,`y`,`min-width`,`min-height`,`max-width`,`drag-handle`])),[[t.vShow,i.visible]])}}),[[`__scopeId`,`data-v-6e2c6cb7`]]),lSt={class:`nimbus-bkai-wrapper`},uSt=[`width`,`height`,`src`],dSt=z9((0,t.defineComponent)({name:`NimbusButton`,__name:`nimbus`,props:{isPanelShow:{type:Boolean},isMinimize:{type:Boolean},size:{default:`normal`}},emits:[`click`,`minimize`,`update:isMinimize`],setup(e,{emit:n}){(0,t.useCssVars)(e=>({v05a8b16e:`${o.value.container}px`,v4e1cf4ca:`${o.value.wrapper}px`,v5ab0c513:`${o.value.mini.right}px`,v40c13a80:`${o.value.mini.size}px`,v0d35a9ef:`${o.value.mini.fontSize}px`}));let r=e,i=n,a={small:{container:40,wrapper:32,img:24,mini:{size:14,fontSize:10,right:-4}},normal:{container:48,wrapper:40,img:32,mini:{size:16,fontSize:12,right:-6}},large:{container:56,wrapper:48,img:40,mini:{size:18,fontSize:14,right:-6}}},o=(0,t.computed)(()=>a[r.size]),s=(0,t.ref)(null),l=(0,t.ref)(null),{nimbusLeft:u,nimbusTop:d,isMinimize:f,handleClick:p,handleMinimize:m,handleDragging:h,handleMouseEnter:g,handleMouseLeave:_,handleMouseDown:v,handleMouseUp:y}=qxt(i,r.isMinimize);(0,t.watch)(f,e=>{i(`update:isMinimize`,e)});let b=(0,t.computed)(()=>f.value?V9(`恢复默认大小`):V9(`最小化,将缩成锚点`)),{createTooltip:x,destroyAll:S}=Jxt({theme:`ai-blueking`,delay:[0,0]}),C=()=>{(0,t.nextTick)(()=>{w()})},w=()=>{S(),s.value&&!f.value&&x(s.value,qbt(),{placement:`left`}),l.value&&x(l.value,b.value,{placement:`top`})};return(0,t.watch)(()=>f.value,()=>{(0,t.nextTick)(()=>{w()})}),(0,t.onMounted)(()=>{(0,t.nextTick)(()=>{w()}),window.addEventListener(`resize`,C)}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,C)}),(n,r)=>((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Z9),{active:!e.isPanelShow,axis:`y`,draggable:!0,h:o.value.container,parent:!0,"prevent-deactivation":!0,resizable:!1,w:o.value.container,x:(0,t.unref)(u),y:(0,t.unref)(d),onDragging:(0,t.unref)(h)},{default:(0,t.withCtx)(()=>[(0,t.createElementVNode)(`div`,{ref_key:`nimbusContainerRef`,ref:s,class:(0,t.normalizeClass)([`nimbus-container`,{"is-minimize":(0,t.unref)(f)}]),onClick:r[1]||=(...e)=>(0,t.unref)(p)&&(0,t.unref)(p)(...e),onMousedown:r[2]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onMouseenter:r[3]||=(...e)=>(0,t.unref)(g)&&(0,t.unref)(g)(...e),onMouseleave:r[4]||=(...e)=>(0,t.unref)(_)&&(0,t.unref)(_)(...e),onMouseup:r[5]||=(...e)=>(0,t.unref)(y)&&(0,t.unref)(y)(...e)},[(0,t.createElementVNode)(`div`,lSt,[(0,t.createElementVNode)(`img`,{width:o.value.img,height:o.value.img,src:(0,t.unref)(Rbt),alt:`nimbus`},null,8,uSt)]),(0,t.createElementVNode)(`i`,{ref_key:`minimizeButtonRef`,ref:l,class:(0,t.normalizeClass)([`nimbus-mini bkai-icon`,(0,t.unref)(f)?`bkai-yinyong`:`bkai-minus-line`]),onClick:r[0]||=(0,t.withModifiers)((...e)=>(0,t.unref)(m)&&(0,t.unref)(m)(...e),[`stop`])},null,2)],34)]),_:1},8,[`active`,`h`,`w`,`x`,`y`,`onDragging`]))}}),[[`__scopeId`,`data-v-26b6f3ea`]]),fSt={class:`ai-blueking-panel`},pSt=z9((0,t.defineComponent)({__name:`ai-blueking`,props:(0,t.mergeDefaults)({autoSwitchToInitialSession:{type:Boolean},defaultChatInputPosition:{},defaultHeight:{},defaultLeft:{},defaultMinimize:{type:Boolean},defaultTop:{},defaultWidth:{},disabledInput:{type:Boolean},draggable:{type:Boolean},dropdownMenuConfig:{},enableChatSession:{type:Boolean},enablePopup:{type:Boolean},extCls:{},helloText:{},hideDefaultTrigger:{type:Boolean},hideHeader:{type:Boolean},hideNimbus:{type:Boolean},initialSessionCode:{},loadRecentSessionOnMount:{type:Boolean},maxWidth:{},miniPadding:{},nimbusSize:{},placeholder:{},prompts:{},requestOptions:{},resources:{},shortcutLimit:{},shortcuts:{},showCompressionIcon:{type:Boolean},showHistoryIcon:{type:Boolean},showMoreIcon:{type:Boolean},showNewChatIcon:{type:Boolean},teleportTo:{},title:{},url:{},shortcutFilter:{type:Function}},Yxt),emits:[`show`,`close`,`dragging`,`resizing`,`drag-stop`,`resize-stop`,`send-message`,`receive-start`,`receive-text`,`receive-end`,`stop`,`shortcut-click`,`session-initialized`,`sdk-error`,`transfer-messages`,`share-messages`,`new-chat`,`history-click`,`auto-generate-name`,`help-click`,`rename`,`share`],setup(e,{expose:n,emit:r}){let a=e,o=r,s=(0,t.ref)(),l=(0,t.ref)(),u=(0,t.computed)(()=>Wbt(a.url)),d=Dxt({initialPanelVisible:!1,initialNimbusMinimized:a.defaultMinimize,enablePopup:a.enablePopup,enableNimbus:!a.hideNimbus,enableDraggable:a.draggable}),f=d.panelVisible,p=d.nimbusMinimized,{forwardToManager:m}=Kxt({componentManager:d,emit:o}),h=Gxt(m),{chatHelper:g,isReady:_,agentInfo:v,agentName:y,currentSession:b}=Wxt({url:u,requestOptions:a.requestOptions,autoInit:!0,protocolCallbacks:{onStart:()=>{h.receiveStart()},onMessage:()=>{h.receiveText()},onDone:()=>{h.receiveEnd()},onError:e=>{d.emitInternal(`sdk-error`,{apiName:`chat`,code:-1,message:e.message,data:e})}}}),x=g,S=new Cxt(x.session,x.message,null,{enableChatSession:a.enableChatSession,initialSessionCode:a.initialSessionCode}),C=new wxt(x.message,x.session),w=new Axt,T=(0,t.computed)(()=>w.isSelectionMode.value),E=(0,t.ref)(!1),D=new Txt(null,a.shortcuts||[]),O=(0,t.ref)(!1),k=(0,t.ref)(``),A=(0,t.computed)(()=>d.isCompressed.value),j=(0,t.computed)(()=>y.value),M=(0,t.ref)(``),N=(0,t.ref)(!0),P=(0,t.ref)(!1),F=(0,t.computed)(()=>a.resources?.length?a.resources:Vbt(v.value?.resources)),I=(0,t.computed)(()=>a.prompts?.length?a.prompts:v.value?.conversationSettings?.predefinedQuestions??[]),L=(0,t.computed)(()=>{let e=D.effectiveShortcuts.value;return typeof a.shortcutFilter==`function`&&k.value?e.filter(e=>a.shortcutFilter?.(e,k.value)):e});(0,t.watch)(()=>_.value,async e=>{if(e&&v.value){let e=v.value;if(e.saasUrl&&fetch(e.saasUrl,{method:`GET`,credentials:`include`}).catch(()=>{}),e.conversationSettings&&(m(`session-initialized`,{openingRemark:e.conversationSettings.openingRemark||``,predefinedQuestions:e.conversationSettings.predefinedQuestions||[]}),e.conversationSettings.commands&&D.setAgentShortcuts(e.conversationSettings.commands)),a.loadRecentSessionOnMount)try{await S.loadRecentSession({skipLoadSessions:!0})}catch(e){console.error(`[AIBlueking] Failed to load recent session:`,e)}}},{immediate:!0}),(0,t.watch)(()=>a.shortcuts,e=>{D.setShortcuts(e||[])},{immediate:!0}),(0,t.watch)(()=>b.value,e=>{e&&(M.value=e.sessionName||``,P.value=(e.sessionContentCount??0)>0)},{immediate:!0}),(0,t.watch)(()=>x.message.list.value.length,e=>{e>0&&(P.value=!0)});let R=async e=>{d.showPanel(e),e&&l.value&&await l.value.switchSession(e)},ee=()=>{d.hidePanel()},te=()=>{ee()},z=()=>{d.handleNimbusClick()},B=e=>{k.value=e},ne=async(e,t)=>{O.value=!1,await R(),e.components?.length&&l.value?l.value.selectShortcut(e,t):l.value&&(l.value.setCiteText(t),l.value.focusInput()),m(`shortcut-click`,{shortcut:e,source:`popup`})},re=e=>{m(`shortcut-click`,e)},ie=e=>{d.handleDragging(e)},ae=e=>{d.handleResizing(e)},oe=e=>{d.handleDragStop(e)},V=e=>{d.handleResizeStop(e)},se=()=>{d.container.toggleCompression()},ce=e=>{d.setCompressed(e)},le=async()=>{h.newChat()},ue=e=>{h.historyClick(e)},de=async e=>{await S.switchSession(e)},fe=async e=>{await S.deleteSession(e)},pe=async(e,t)=>{await S.updateSessionName(e,t)},me=async()=>{let e=x.session.current?.value?.sessionCode;if(!e){console.error(`[AIBlueking] Cannot auto-generate name: no active session`);return}try{await x.session.renameSession(e);let t=x.session.list.value.find(t=>t.sessionCode===e);t&&(M.value=t.sessionName||``)}catch(e){console.error(`[AIBlueking] Failed to auto-generate session name:`,e),Me(e)}h.autoGenerateName()},he=()=>{h.helpClick()},ge=async e=>{let t=x.session.current?.value;if(!t){console.error(`[AIBlueking] Cannot rename: no active session`);return}try{await x.session.updateSession({...t,sessionName:e}),M.value=e}catch(e){console.error(`[AIBlueking] Failed to rename session:`,e),Me(e)}h.rename(e)},_e=()=>{w.enableSelectionMode(),h.share()},ve=()=>{w.disableSelectionMode()},ye=async e=>{E.value=!0;try{let{shareUrl:t,userMessageIds:n}=await C.shareMessages(e);await Gbt(t),(0,i.Message)({message:V9(`分享链接已复制到剪贴板`),theme:`success`}),w.disableSelectionMode(),h.shareMessages(n)}catch(e){console.error(`[AIBlueking] Failed to share messages:`,e),Me(e)}finally{E.value=!1}},be=async e=>{l.value&&await l.value.sendMessage(e)},xe=e=>{P.value=!0,h.sendMessage(e)},Se=()=>{h.receiveStart()},Ce=()=>{h.receiveText()},we=()=>{h.receiveEnd()},Te=()=>{h.stop()},Ee=()=>{l.value&&l.value.stopGeneration()},De=async e=>{e?await S.createSession({sessionCode:e}):await S.createNewSession()},Oe=async e=>{l.value&&await l.value.switchSession(e)},ke=async(e,t)=>{try{await S.updateSessionName(e,t),M.value=t}catch(e){console.error(`[AIBlueking] Failed to update session name:`,e),Me(e)}},je=e=>{e&&(M.value=e.sessionName||``,P.value=(e.sessionContentCount??0)>0||x.message.list.value.length>0)},Me=e=>{console.error(`ChatBot error:`,e),d.emitInternal(`sdk-error`,{apiName:`chat`,code:-1,message:e.message,data:e})},Ne=(e,t)=>{d.container.updatePosition(e,t)},Pe=(e,t)=>{d.container.updateSize(e,t)},Fe=(e,t,n,r)=>{d.container.updatePositionAndSize(e,t,n,r)},Ie=e=>{l.value&&l.value.setCiteText(e)},Le=()=>{l.value&&l.value.focusInput()},Re=e=>{Ybt(e)&&(e.preventDefault(),f.value?ee():R())};return(0,t.onMounted)(async()=>{s.value&&d.setContainerRef(s.value),window.addEventListener(`keydown`,Re)}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`keydown`,Re),d.destroy()}),n({show:R,hide:ee,sendMessage:be,stopGeneration:Ee,addNewSession:De,switchToSession:Oe,updateSessionName:ke,updatePosition:Ne,updateSize:Pe,updatePositionAndSize:Fe,setCiteText:Ie,focusInput:Le}),(e,n)=>((0,t.openBlock)(),(0,t.createBlock)(t.Teleport,{to:a.teleportTo},[(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`ai-blueking-v2`,a.extCls])},[(0,t.createCommentVNode)(` 可拖拽容器 `),(0,t.createVNode)((0,t.unref)(cSt),{ref_key:`draggableContainerRef`,ref:s,"compressed-padding":a.miniPadding,"default-height":a.defaultHeight,"default-width":a.defaultWidth,"default-x":a.defaultLeft,"default-y":a.defaultTop,"drag-handle":`.drag-handle`,draggable:a.draggable,"max-width":a.maxWidth,"max-width-percent":80,visible:(0,t.unref)(f),onCompressionChange:ce,onDragStop:oe,onDragging:ie,onResizeStop:V,onResizing:ae},{default:(0,t.withCtx)(()=>[(0,t.createElementVNode)(`div`,fSt,[(0,t.createCommentVNode)(` 独立的 Header 组件 `),a.hideHeader?(0,t.createCommentVNode)(`v-if`,!0):((0,t.openBlock)(),(0,t.createBlock)(xxt,{key:0,"agent-name":j.value,"chat-helper":(0,t.unref)(x),draggable:a.draggable,"dropdown-menu-config":a.dropdownMenuConfig,"enable-chat-session":a.enableChatSession,"has-permission":N.value,"has-session-contents":P.value,"is-compression-height":A.value,"session-business-manager":(0,t.unref)(S),"session-name":M.value,"show-compression-icon":a.showCompressionIcon,"show-history-icon":a.showHistoryIcon,"show-more-icon":a.showMoreIcon,"show-new-chat-icon":a.showNewChatIcon,title:a.title,onAutoGenerateName:me,onClose:te,onHelpClick:he,onHistoryClick:ue,onHistorySessionDelete:fe,onHistorySessionRename:pe,onHistorySessionSwitch:de,onNewChat:le,onRename:ge,onShare:_e,onToggleCompression:se},null,8,[`agent-name`,`chat-helper`,`draggable`,`dropdown-menu-config`,`enable-chat-session`,`has-permission`,`has-session-contents`,`is-compression-height`,`session-business-manager`,`session-name`,`show-compression-icon`,`show-history-icon`,`show-more-icon`,`show-new-chat-icon`,`title`])),(0,t.createCommentVNode)(` ChatBot 核心组件(仅聊天区域) `),(0,t.createVNode)(Uxt,{ref_key:`chatBotRef`,ref:l,"auto-load":a.loadRecentSessionOnMount,"chat-helper":(0,t.unref)(x),"enable-selection":T.value,"hello-text":a.helloText,placeholder:a.placeholder,prompts:I.value,"request-options":a.requestOptions,resources:F.value,"session-code":a.initialSessionCode,"share-loading":E.value,"shortcut-limit":a.shortcutLimit,shortcuts:a.shortcuts,url:u.value,onCancelShare:ve,onConfirmShare:n[0]||=e=>ye(e),onError:n[1]||=e=>Me(e),onReceiveEnd:we,onReceiveStart:Se,onReceiveText:Ce,onRequestShare:_e,onSendMessage:n[2]||=e=>xe(e),onSessionSwitched:n[3]||=e=>je(e),onShortcutClick:n[4]||=e=>re(e),onStop:Te},null,8,[`auto-load`,`chat-helper`,`enable-selection`,`hello-text`,`placeholder`,`prompts`,`request-options`,`resources`,`session-code`,`share-loading`,`shortcut-limit`,`shortcuts`,`url`])])]),_:1},8,[`compressed-padding`,`default-height`,`default-width`,`default-x`,`default-y`,`draggable`,`max-width`,`visible`]),(0,t.createCommentVNode)(` Nimbus 悬浮球 `),a.hideNimbus?(0,t.createCommentVNode)(`v-if`,!0):((0,t.openBlock)(),(0,t.createBlock)(dSt,{key:0,"is-minimize":(0,t.unref)(p),"onUpdate:isMinimize":n[5]||=e=>(0,t.isRef)(p)?p.value=e:null,"is-panel-show":(0,t.unref)(f),"onUpdate:isPanelShow":n[6]||=e=>(0,t.isRef)(f)?f.value=e:null,"default-minimize":a.defaultMinimize,size:a.nimbusSize,onClick:z},null,8,[`is-minimize`,`is-panel-show`,`default-minimize`,`size`])),(0,t.createCommentVNode)(` 划词选择弹窗(使用 chat-x 的 AiSelection 组件) `),a.enablePopup?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Ae),{key:1,visible:O.value,"onUpdate:visible":n[7]||=e=>O.value=e,"max-shortcut-count":a.shortcutLimit,shortcuts:L.value,onSelectShortcut:ne,onSelectionChange:B},null,8,[`visible`,`max-shortcut-count`,`shortcuts`])):(0,t.createCommentVNode)(`v-if`,!0)],2)],8,[`to`]))}}),[[`__scopeId`,`data-v-390ddb5e`]]);e.default={name:`AIBluekingV2`,render(e){return e(`div`,{style:{width:`100%`,height:`100%`}})},props:{extCls:{type:String,default:``},shortcuts:{type:Array,default:()=>[]},enablePopup:{type:Boolean,default:!0},url:{type:String,default:``},prompts:{type:Array,default:()=>[]},teleportTo:{type:String,default:`body`},title:{type:String,default:``},helloText:{type:String,default:``},requestOptions:{type:Object,default:()=>({})},defaultMinimize:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1},hideNimbus:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},defaultWidth:{type:Number,default:700},defaultHeight:{type:Number,default:800},defaultLeft:{type:Number,default:void 0},defaultTop:{type:Number,default:void 0},disabledInput:{type:Boolean,default:!1},showCompressionIcon:{type:Boolean,default:!0},showMoreIcon:{type:Boolean,default:!0},showHistoryIcon:{type:Boolean,default:!0},showNewChatIcon:{type:Boolean,default:!0},defaultChatInputPosition:{type:String,default:void 0},maxWidth:{type:[Number,String],default:1e3},initialSessionCode:{type:String,default:``},autoSwitchToInitialSession:{type:Boolean,default:!1},loadRecentSessionOnMount:{type:Boolean,default:!1},shortcutLimit:{type:Number,default:3},shortcutFilter:{type:Function,default:void 0},placeholder:{type:String,default:``},enableChatSession:{type:Boolean,default:!0},nimbusSize:{type:String,default:`medium`},miniPadding:{type:Number,default:20},dropdownMenuConfig:{type:Array,default:()=>[]},hideDefaultTrigger:{type:Boolean,default:!1}},data(){return{app:null,componentInstance:null,unWatchStack:[]}},created(){let e=this.$emit.bind(this),n=this;this.app=(0,t.createApp)({setup(){return()=>(0,t.h)(pSt,{extCls:n.extCls,shortcuts:n.shortcuts,shortcutLimit:n.shortcutLimit,shortcutFilter:n.shortcutFilter,enablePopup:n.enablePopup,url:n.url,title:n.title,helloText:n.helloText,requestOptions:n.requestOptions,prompts:n.prompts,disabledInput:n.disabledInput,teleportTo:n.teleportTo,defaultMinimize:n.defaultMinimize,hideHeader:n.hideHeader,hideNimbus:n.hideNimbus,draggable:n.draggable,defaultWidth:n.defaultWidth,defaultHeight:n.defaultHeight,defaultLeft:n.defaultLeft,defaultTop:n.defaultTop,initialSessionCode:n.initialSessionCode,autoSwitchToInitialSession:n.autoSwitchToInitialSession,loadRecentSessionOnMount:n.loadRecentSessionOnMount,showCompressionIcon:n.showCompressionIcon,showMoreIcon:n.showMoreIcon,showHistoryIcon:n.showHistoryIcon,showNewChatIcon:n.showNewChatIcon,defaultChatInputPosition:n.defaultChatInputPosition,maxWidth:n.maxWidth,placeholder:n.placeholder,enableChatSession:n.enableChatSession,nimbusSize:n.nimbusSize,miniPadding:n.miniPadding,dropdownMenuConfig:n.dropdownMenuConfig,hideDefaultTrigger:n.hideDefaultTrigger,onClose:()=>e(`close`),onShow:()=>e(`show`),onStop:()=>e(`stop`),onShortcutClick:t=>e(`shortcut-click`,t),onSendMessage:t=>e(`send-message`,t),onReceiveStart:()=>e(`receive-start`),onReceiveEnd:()=>e(`receive-end`),onReceiveText:()=>e(`receive-text`),onSessionInitialized:t=>e(`session-initialized`,t),onDragStop:t=>e(`drag-stop`,t),onResizeStop:t=>e(`resize-stop`,t),onDragging:t=>e(`dragging`,t),onResizing:t=>e(`resizing`,t),onTransferMessages:t=>e(`transfer-messages`,t),onShareMessages:t=>e(`share-messages`,t),onSdkError:t=>e(`sdk-error`,t),onSessionSwitched:t=>e(`session-switched`,t),onHelpClick:()=>e(`help-click`),onRename:()=>e(`rename`),onShare:()=>e(`share`),...n.$attrs,ref:e=>{n.componentInstance=e}})}}),this.unWatchStack.push(this.$watch(`requestOptions`,e=>{this.app&&(this.app.unmount(),this.app.mount(this.$el))},{deep:!0})),this.unWatchStack.push(this.$watch(`shortcuts`,()=>{this.app&&(this.app.unmount(),this.app.mount(this.$el))},{deep:!0}))},mounted(){this.app?.mount(this.$el),this.$nextTick(()=>{if(this.componentInstance){let e=this.componentInstance;this.show=e.show.bind(e),this.hide=e.hide.bind(e),this.sendMessage=e.sendMessage.bind(e),this.stopGeneration=e.stopGeneration.bind(e),this.addNewSession=e.addNewSession.bind(e),this.switchToSession=e.switchToSession.bind(e),this.updateSessionName=e.updateSessionName.bind(e),this.updatePosition=e.updatePosition.bind(e),this.updateSize=e.updateSize.bind(e),this.updatePositionAndSize=e.updatePositionAndSize.bind(e),this.setCiteText=e.setCiteText.bind(e),this.focusInput=e.focusInput.bind(e)}})},beforeDestroy(){this.unWatchStack.forEach(e=>e?.()),this.unWatchStack=[],this.app&&=(this.app.unmount(),null),this.componentInstance=null},methods:{show(e,t){return console.warn(`AIBluekingV2: show method not ready`),Promise.resolve()},hide(){console.warn(`AIBluekingV2: hide method not ready`)},sendMessage(e){return console.warn(`AIBluekingV2: sendMessage method not ready`),Promise.resolve()},stopGeneration(){console.warn(`AIBluekingV2: stopGeneration method not ready`)},addNewSession(e){return console.warn(`AIBluekingV2: addNewSession method not ready`),Promise.resolve()},switchToSession(e){return console.warn(`AIBluekingV2: switchToSession method not ready`),Promise.resolve()},updateSessionName(e,t){return console.warn(`AIBluekingV2: updateSessionName method not ready`),Promise.resolve()},updatePosition(e,t){console.warn(`AIBluekingV2: updatePosition method not ready`)},updateSize(e,t){console.warn(`AIBluekingV2: updateSize method not ready`)},updatePositionAndSize(e,t,n,r){console.warn(`AIBluekingV2: updatePositionAndSize method not ready`)},setCiteText(e){console.warn(`AIBluekingV2: setCiteText method not ready`)},focusInput(){console.warn(`AIBluekingV2: focusInput method not ready`)}}},e.h=t.h});
@@ -27844,7 +27844,10 @@ var UIStateManager = class {
27844
27844
  Wg.value = [[]], Gg.value = "", a("send-message", typeof e == "string" ? e : ""), await Hg.sendMessage(e, r, n);
27845
27845
  }, u_ = async (e) => {
27846
27846
  let n = I?.session.current?.value?.sessionCode;
27847
- return n && await I.session.uploadFile(n, e) || {};
27847
+ if (!n) throw Error("[ChatBot] Cannot upload: no active session");
27848
+ let r = await I.session.uploadFile(n, e);
27849
+ if (!r?.download_url) throw Error("[ChatBot] Upload failed: no download URL returned");
27850
+ return r;
27848
27851
  }, d_ = async (e, n) => {
27849
27852
  try {
27850
27853
  await l_(e, Gg.value ? { property: { extra: { cite: Gg.value } } } : {});
@@ -3045,5 +3045,5 @@ Use Shift + Enter to enter a new line`:`输入 “/”唤出 Prompt
3045
3045
  </div>
3046
3046
  `}),E=async()=>{if(i.sessionBusinessManager)try{await i.sessionBusinessManager.createNewSession()}catch(e){console.error(`Failed to create new session:`,e),wu({theme:`error`,message:m9(`创建会话失败`)})}a(`new-chat`)},D=e=>{e.stopPropagation(),i.sessionBusinessManager?(_||v(),_&&_.handleTriggerClick(e)):a(`history-click`,e)},O=()=>{a(`help-click`)},k=e=>{e.stopPropagation(),g&&(g.state.isVisible?g.hide():g.show())},A=e=>{e.stopPropagation(),e.preventDefault();let t=e.currentTarget,n=t.dataset.action;if(!t.classList.contains(`disabled`))switch(g&&g.hide(),n){case`rename`:j();break;case`auto-generate`:a(`auto-generate-name`);break;case`share`:a(`share`);break}},j=()=>{document.removeEventListener(`click`,F),m.value=i.sessionName||``,p.value=!0,setTimeout(()=>{document.addEventListener(`click`,F)},100),setTimeout(()=>{if(h.value)try{let e=h.value;e&&typeof e.focus==`function`&&e.focus();let t=e.$el?.querySelector(`input`);t&&typeof t.select==`function`&&t.select()}catch(e){console.warn(`Failed to focus rename input:`,e)}},100)},M=()=>{let e=m.value.trim();if(!e){N();return}a(`rename`,e),p.value=!1,m.value=``},N=()=>{p.value=!1,m.value=``},P=(e,t)=>{m.value=e,t.key===`Enter`?M():t.key===`Escape`&&N()},F=e=>{if(!p.value)return;let t=e.target,n=document.querySelector(`.rename-tooltip`);n&&!n.contains(t)&&N()},I=async()=>{if(!u.value)return;let e=(await Promise.resolve().then(()=>(c9(),MZt))).default;g&&=(g.destroy(),null),g=e(u.value,{content:T.value,theme:`ai-blueking-light more-menu-light light`,placement:`bottom-start`,trigger:`manual`,interactive:!0,allowHTML:!0,arrow:!1,offset:[0,4],appendTo:()=>document.querySelector(`.ai-blueking-panel`)||document.body,onShow:()=>{setTimeout(()=>{document.querySelectorAll(`.tippy-menu-item`).forEach(e=>{e.addEventListener(`click`,A)})},0)},onHide:()=>{document.querySelectorAll(`.tippy-menu-item`).forEach(e=>{e.removeEventListener(`click`,A)})}})};return(0,t.watch)(()=>[i.isCompressionHeight,i.hasSessionContents],()=>{g&&g.setContent(T.value)}),(0,t.onMounted)(()=>{I(),i.sessionBusinessManager&&v(),document.addEventListener(`click`,F)}),(0,t.onBeforeUnmount)(()=>{g&&=(g.destroy(),null),_&&=(_.destroy(),null),document.removeEventListener(`click`,F)}),n({headerRef:s,historyIconRef:l}),(n,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`headerRef`,ref:s,class:(0,t.normalizeClass)([`ai-header drag-handle`,{draggable:i.draggable}])},[(0,t.createElementVNode)(`div`,R1t,[(0,t.createElementVNode)(`div`,z1t,[(0,t.createElementVNode)(`img`,{alt:`logo`,src:(0,t.unref)(s1t)},null,8,B1t)]),(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`title`,{"title-with-tooltip":p.value}])},[(0,t.createTextVNode)((0,t.toDisplayString)(y.value)+` `,1),(0,t.createCommentVNode)(` 重命名 tooltip 直接绑定在 title 上 `),p.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,V1t,[(0,t.createElementVNode)(`div`,H1t,[(0,t.createVNode)((0,t.unref)(yl),{ref_key:`renameInputRef`,ref:h,modelValue:m.value,"onUpdate:modelValue":r[0]||=e=>m.value=e,class:`rename-input`,placeholder:(0,t.unref)(m9)(`请输入新的会话名称`),onKeyup:P},null,8,[`modelValue`,`placeholder`]),(0,t.createElementVNode)(`div`,{class:`rename-buttons`},[(0,t.createElementVNode)(`i`,{class:`bkai-icon bkai-check-1 rename-btn confirm-btn`,onClick:M}),(0,t.createElementVNode)(`i`,{class:`bkai-icon bkai-close rename-btn cancel-btn`,onClick:N})])])])):(0,t.createCommentVNode)(`v-if`,!0)],2),i.showMoreIcon&&S.value?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:0,ref_key:`moreIconRef`,ref:u,class:`bkai-icon bkai-more`,onClick:k},null,512)):(0,t.createCommentVNode)(`v-if`,!0)]),(0,t.createElementVNode)(`div`,U1t,[(0,t.createCommentVNode)(` 新增会话按钮 `),i.showNewChatIcon&&e.enableChatSession!==!1?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:0,class:(0,t.normalizeClass)([`bkai-icon`,`bkai-xinzengliaotian`,{disabled:!S.value}]),style:(0,t.normalizeStyle)(w()),onClick:r[1]||=e=>S.value?E():void 0},null,6)),[[(0,t.unref)(o),{content:C((0,t.unref)(m9)(`新增会话`)),boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),(0,t.createCommentVNode)(` 历史会话按钮 `),i.showHistoryIcon&&e.enableChatSession!==!1?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:1,ref_key:`historyIconRef`,ref:l,class:(0,t.normalizeClass)([`bkai-icon`,`bkai-history`,{disabled:!S.value}]),style:(0,t.normalizeStyle)(w()),onClick:r[2]||=e=>S.value?D(e):void 0},null,6)),[[(0,t.unref)(o),{content:C((0,t.unref)(m9)(`历史会话`)),boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),e.chatGroup?.enabled?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:2,class:`bkai-icon bkai-zhushou`,onClick:O},null,512)),[[(0,t.unref)(o),{content:(0,t.unref)(m9)(`转人工`),boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),i.showCompressionIcon?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:3,ref_key:`compressionRef`,ref:d,class:(0,t.normalizeClass)([`bkai-icon`,b.value]),onClick:r[3]||=e=>a(`toggle-compression`)},null,2)),[[(0,t.unref)(o),{content:x.value,boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),(0,t.withDirectives)((0,t.createElementVNode)(`i`,{ref_key:`closeRef`,ref:f,class:`bkai-icon bkai-close-line-2`,onClick:r[4]||=e=>a(`close`)},null,512),[[(0,t.unref)(o),{content:(0,t.unref)(m9)(`关闭`),boundary:`parent`}]])])],2))}}),[[`__scopeId`,`data-v-e9f38ba5`]]);let G1t=e=>{var t;return{conversationSettings:{openingRemark:e?.conversation_settings?.opening_remark,predefinedQuestions:e?.conversation_settings?.predefined_questions,commands:e==null||(t=e.conversation_settings)==null?void 0:t.commands?.map(e=>({id:e.id,name:e.name,icon:e.icon,components:e.components.map(e=>({type:e.type,name:e.name,key:e.key,placeholder:e.placeholder,default:e.default,required:e.required,fillBack:e.fill_back,fillRegx:e.fill_regx,rows:e.rows,min:e.min,max:e.max,options:e.options})),content:e.content,agentId:e.agent_id,status:e.status})),enableChatSession:e?.conversation_settings?.enable_chat_session},promptSetting:e?.prompt_setting,agentName:e?.agent_name,chatGroup:e?.chat_group?{enabled:e.chat_group.enabled,staff:e.chat_group.staff,username:e.chat_group.username}:void 0,saasUrl:e?.saas_url,resources:e?.resources}};var h9;(function(e){e.KnowledgeRag=`knowledge_rag`,e.ReferenceDocument=`reference_document`})(h9||={});var g9;(function(e){e.Activity=`activity`,e.Assistant=`assistant`,e.Developer=`developer`,e.Guide=`guide`,e.Hidden=`hidden`,e.HiddenAssistant=`hidden-assistant`,e.HiddenGuide=`hidden-guide`,e.HiddenSystem=`hidden-system`,e.HiddenUser=`hidden-user`,e.Info=`info`,e.Pause=`pause`,e.Placeholder=`placeholder`,e.Reasoning=`reasoning`,e.System=`system`,e.TemplateAssistant=`template-assistant`,e.TemplateGuide=`template-guide`,e.TemplateHidden=`template-hidden`,e.TemplateSystem=`template-system`,e.TemplateUser=`template-user`,e.Tool=`tool`,e.User=`user`})(g9||={});var _9;(function(e){e.Complete=`complete`,e.Error=`error`,e.Pending=`pending`,e.Stop=`stop`,e.Streaming=`streaming`})(_9||={});var v9;(function(e){e.Binary=`binary`,e.Function=`function`,e.Text=`text`})(v9||={});function K1t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y9(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){K1t(e,t,n[t])})}return e}function q1t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function b9(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):q1t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let x9=e=>{let t={id:e.id,messageId:e.message_id,name:e.name,role:e.role,sessionCode:e.session_code,status:e.status};switch(e.role){case g9.Activity:{let n=e;return b9(y9({},t),{activityType:n.activity_type,content:Array.isArray(n.content)?n.content.map(e=>({name:e.name,originFileUrl:e.origin_file_url,url:e.url})):{content:n.content.content,referenceDocument:n.content.reference_document.map(e=>({name:e.name,originFileUrl:e.origin_file_url,url:e.url}))},role:n.role})}case g9.Assistant:{let n=e;return b9(y9({},t),{content:n.content,role:n.role,toolCalls:n.tool_calls?.map(e=>({function:{arguments:e.function.arguments,name:e.function.name,description:e.function.description,mcpName:e.function.mcp_name},id:e.id,type:e.type}))})}case g9.Developer:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Guide:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Hidden:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.HiddenAssistant:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.HiddenGuide:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.HiddenSystem:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.HiddenUser:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Info:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Pause:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Placeholder:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Reasoning:{let n=e;return b9(y9({},t),{content:n.content,duration:n.duration,role:n.role})}case g9.System:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateAssistant:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateGuide:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateHidden:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateSystem:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateUser:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Tool:{let n=e;return b9(y9({},t),{content:n.content,duration:n.duration,error:n.error,role:n.role,toolCallId:n.tool_call_id})}case g9.User:{let n=e,r=n.content;return b9(y9({},t),{content:Array.isArray(r)?r.map(e=>{if(e.type===v9.Binary){let t=e;return{data:t.data,filename:t.filename,id:t.id,mimeType:t.mime_type,type:t.type,url:t.url}}return e}):r,property:n.property,role:n.role})}}},J1t=e=>{let t={id:e.id,message_id:e.messageId,name:e.name,role:e.role,session_code:e.sessionCode,status:e.status};switch(e.role){case g9.Activity:{let n=e;return b9(y9({},t),{activity_type:n.activityType,content:Array.isArray(n.content)?n.content.map(e=>({name:e.name,origin_file_url:e.originFileUrl,url:e.url})):{content:n.content.content,reference_document:n.content.referenceDocument.map(e=>({name:e.name,origin_file_url:e.originFileUrl,url:e.url}))},role:n.role})}case g9.Assistant:{let n=e;return b9(y9({},t),{content:n.content,role:n.role,tool_calls:n.toolCalls?.map(e=>({function:{arguments:e.function.arguments,name:e.function.name,description:e.function.description,mcp_name:e.function.mcpName},id:e.id,type:e.type}))})}case g9.Developer:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Guide:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Hidden:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.HiddenAssistant:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.HiddenGuide:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.HiddenSystem:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.HiddenUser:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Info:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Pause:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Placeholder:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Reasoning:{let n=e;return b9(y9({},t),{content:n.content,duration:n.duration,role:n.role})}case g9.System:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateAssistant:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateGuide:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateHidden:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateSystem:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.TemplateUser:{let n=e;return b9(y9({},t),{content:n.content,role:n.role})}case g9.Tool:{let n=e;return b9(y9({},t),{content:n.content,duration:n.duration,error:n.error,role:n.role,tool_call_id:n.toolCallId})}case g9.User:{let n=e,r=n.content;return b9(y9({},t),{content:Array.isArray(r)?r.map(e=>{if(e.type===v9.Binary){let t=e;return{data:t.data,filename:t.filename,id:t.id,mime_type:t.mimeType,type:t.type,url:t.url}}return e}):r,property:n.property,role:n.role})}}},S9=e=>({sessionCode:e.session_code,sessionContentCount:e.session_content_count,sessionName:e.session_name,isTemporary:e.is_temporary,model:e.model,comment:e.comment,labels:e.labels,rate:e.rate,updatedAt:e.updated_at,createdAt:e.created_at,roleInfo:e.role_info?{collectionId:e.role_info.collection_id,collectionName:e.role_info.collection_name,content:e.role_info.content,variables:e.role_info.variables}:void 0,sessionProperty:{isAutoClear:e.session_property?.is_auto_clear,isAutoCalcPrompt:e.session_property?.is_auto_clac_prompt}}),Y1t=e=>({session_code:e.sessionCode,session_content_count:e.sessionContentCount,session_name:e.sessionName,is_temporary:e.isTemporary,model:e.model,comment:e.comment,labels:e.labels,rate:e.rate,updated_at:e.updatedAt,created_at:e.createdAt,role_info:e.roleInfo?{collection_id:e.roleInfo.collectionId,collection_name:e.roleInfo.collectionName,content:e.roleInfo.content,variables:e.roleInfo.variables}:void 0,session_property:{is_auto_clear:e.sessionProperty?.isAutoClear,is_auto_clac_prompt:e.sessionProperty?.isAutoCalcPrompt}}),X1t=e=>({session_code:e.sessionCode,session_content_ids:e.sessionContentIds,rate:e.rate,comment:e.comment,labels:e.labels}),Z1t=e=>({sessionCode:e.session_code,sessionContentIds:e.session_content_ids,rate:e.rate,comment:e.comment,labels:e.lables});function Q1t(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function C9(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){Q1t(a,r,i,o,s,`next`,e)}function s(e){Q1t(a,r,i,o,s,`throw`,e)}o(void 0)})}}function $1t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w9(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){$1t(e,t,n[t])})}return e}function e0t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function t0t(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):e0t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var n0t=()=>`temp_${Date.now()}_${Math.random().toString(36).slice(2,9)}`;let r0t=e=>{let n=(0,t.ref)([]),r=(0,t.ref)(!1),i=(0,t.ref)(!1);return{list:n,isListLoading:r,isDeleteLoading:i,getMessages:t=>(r.value=!0,e.http?.message.getMessages(t).then(e=>{n.value=e}).finally(()=>{r.value=!1})),getCurrentLoadingMessage:()=>n.value.findLast(e=>[_9.Pending,_9.Streaming].includes(e.status)),getMessageByMessageId:e=>n.value.find(t=>t.messageId===e),modifyMessage:e=>{n.value=n.value.map(t=>t.messageId===e.messageId?e:t)},plusMessage:e=>{n.value.push(e)},createAndPlusMessage:function(){var t=C9(function*(t){let r=n0t(),i=t0t(w9({},t),{id:r,messageId:r});n.value.push(i);try{let i=yield e.http?.message.plusMessage(t);if(i){let e=n.value.findIndex(e=>e.messageId===r);if(e!==-1){let r=w9({},i,`property`in t&&t.property?{property:t.property}:{});n.value[e]=r}}}catch(e){let t=n.value.findIndex(e=>e.messageId===r);throw t!==-1&&(n.value[t]=t0t(w9({},n.value[t]),{status:_9.Error})),e}});return function(e){return t.apply(this,arguments)}}(),deleteMessages:function(){var t=C9(function*(t){let r=t.reduce((e,t)=>(t.role===g9.User&&e.push(t.id),e),[]);if(r.length<=0)return;let a=[...n.value];n.value=n.value.filter(e=>!t.includes(e)),i.value=!0;try{yield e.http?.message.batchDeleteMessages(r)}catch(e){throw n.value=a,e}finally{i.value=!1}});return function(e){return t.apply(this,arguments)}}(),shareMessages:function(){var t=C9(function*(t,n,r){let i=n.reduce((e,t)=>(t.role===g9.User&&e.push(t.id),e),[]);if(!(i.length<=0))return e.http?.message.shareMessages(t,i,r)});return function(e,n,r){return t.apply(this,arguments)}}(),reset:()=>{n.value=[],r.value=!1,i.value=!1}}};var T9;(function(e){e.KnowledgeRagEnd=`knowledge_rag_end`,e.KnowledgeRagResult=`knowledge_rag_result`,e.KnowledgeRagStart=`knowledge_rag_start`,e.KnowledgeRagTextContent=`knowledge_rag_text_content`,e.ReferenceDocument=`reference_document`})(T9||={});var E9;(function(e){e.ActivityDelta=`ACTIVITY_DELTA`,e.ActivitySnapshot=`ACTIVITY_SNAPSHOT`,e.Custom=`CUSTOM`,e.MessagesSnapshot=`MESSAGES_SNAPSHOT`,e.Raw=`RAW`,e.RunError=`RUN_ERROR`,e.RunFinished=`RUN_FINISHED`,e.RunStarted=`RUN_STARTED`,e.StateDelta=`STATE_DELTA`,e.StateSnapshot=`STATE_SNAPSHOT`,e.StepFinished=`STEP_FINISHED`,e.StepStarted=`STEP_STARTED`,e.TextMessageChunk=`TEXT_MESSAGE_CHUNK`,e.TextMessageContent=`TEXT_MESSAGE_CONTENT`,e.TextMessageEnd=`TEXT_MESSAGE_END`,e.TextMessageStart=`TEXT_MESSAGE_START`,e.ThinkingEnd=`THINKING_END`,e.ThinkingStart=`THINKING_START`,e.ThinkingTextMessageContent=`THINKING_TEXT_MESSAGE_CONTENT`,e.ThinkingTextMessageEnd=`THINKING_TEXT_MESSAGE_END`,e.ThinkingTextMessageStart=`THINKING_TEXT_MESSAGE_START`,e.ToolCallArgs=`TOOL_CALL_ARGS`,e.ToolCallChunk=`TOOL_CALL_CHUNK`,e.ToolCallEnd=`TOOL_CALL_END`,e.ToolCallResult=`TOOL_CALL_RESULT`,e.ToolCallStart=`TOOL_CALL_START`})(E9||={});function D9(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O9=class{handleActivityDeltaEvent(e){}handleActivitySnapshotEvent(e){}handleCustomEvent(e){switch(e.name){case T9.ReferenceDocument:this.handleReferenceDocumentCustomEvent(e);break;case T9.KnowledgeRagStart:this.handleKnowledgeRagStartCustomEvent(e);break;case T9.KnowledgeRagTextContent:this.handleKnowledgeRagTextContentCustomEvent(e);break;case T9.KnowledgeRagResult:this.handleKnowledgeRagResultCustomEvent(e);break;case T9.KnowledgeRagEnd:this.handleKnowledgeRagEndCustomEvent(e);break;default:break}}handleKnowledgeRagEndCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===g9.Activity&&t.activityType===h9.KnowledgeRag&&(t.status=_9.Complete)}handleKnowledgeRagResultCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===g9.Activity&&t.activityType===h9.KnowledgeRag&&(t.content.referenceDocument=e.value)}handleKnowledgeRagStartCustomEvent(e){this.messageModule.plusMessage({role:g9.Activity,activityType:h9.KnowledgeRag,content:{content:``,referenceDocument:[]},status:_9.Streaming})}handleKnowledgeRagTextContentCustomEvent(e){let t=this.messageModule.getCurrentLoadingMessage();if(t&&t.role===g9.Activity&&t.activityType===h9.KnowledgeRag){let n=e.value;t.content.content=n.cover?n.chunk.content:t.content.content+n.chunk.content}}handleMessagesSnapshotEvent(e){e.messages&&e.messages.length>0&&(this.messageModule.list.value=e.messages.map(x9))}handleRawEvent(e){}handleReferenceDocumentCustomEvent(e){this.messageModule.plusMessage({role:g9.Activity,activityType:h9.ReferenceDocument,content:e.value,status:_9.Complete})}handleRunErrorEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&(t.status=_9.Complete),this.messageModule.plusMessage({role:g9.Assistant,content:e.message,status:_9.Error})}handleRunFinishedEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&(t.status=_9.Complete)}handleRunStartedEvent(e){}handleStateDeltaEvent(e){}handleStateSnapshotEvent(e){}handleStepFinishedEvent(e){}handleStepStartedEvent(e){}handleTextMessageChunkEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t?t.content+=e.delta||``:this.messageModule.plusMessage({role:e.role,content:e.delta||``,status:_9.Complete,messageId:e.messageId})}handleTextMessageContentEvent(e){let t=this.messageModule.getMessageByMessageId(e.messageId);t&&(t.content+=e.delta)}handleTextMessageEndEvent(e){let t=this.messageModule.getMessageByMessageId(e.messageId);t&&(t.status=_9.Complete)}handleTextMessageStartEvent(e){this.messageModule.plusMessage({role:e.role,content:``,status:_9.Streaming,messageId:e.messageId})}handleThinkingEndEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===g9.Reasoning&&(t.duration=e.duration,t.status=_9.Complete)}handleThinkingStartEvent(e){this.messageModule.plusMessage({role:g9.Reasoning,content:[],status:_9.Streaming})}handleThinkingTextMessageContentEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===g9.Reasoning&&(t.content[t.content.length-1]+=e.delta)}handleThinkingTextMessageEndEvent(e){}handleThinkingTextMessageStartEvent(e){let t=this.messageModule.getCurrentLoadingMessage();t&&t.role===g9.Reasoning&&t.content.push(``)}handleToolCallArgsEvent(e){this.messageModule.list.value.forEach(t=>{t.role===g9.Assistant&&t.toolCalls&&t.toolCalls.forEach(t=>{t.id===e.toolCallId&&(t.function.arguments+=e.delta)})})}handleToolCallChunkEvent(e){}handleToolCallEndEvent(e){this.messageModule.list.value.forEach(t=>{t.role===g9.Assistant&&t.toolCalls&&t.toolCalls.some(t=>t.id===e.toolCallId)&&(t.status=_9.Complete)})}handleToolCallResultEvent(e){this.messageModule.plusMessage({role:g9.Tool,content:e.content,duration:e.duration,status:_9.Complete,toolCallId:e.toolCallId,messageId:e.messageId})}handleToolCallStartEvent(e){this.messageModule.plusMessage({role:g9.Assistant,content:``,status:_9.Streaming,toolCalls:[{id:e.toolCallId,type:v9.Function,function:{mcpName:e.mcpName,name:e.toolCallName,arguments:``,description:e.description}}]})}injectMessageModule(e){this.messageModule=e}onDone(){var e,t;(e=(t=this).onDoneCallback)==null||e.call(t)}onError(e){var t,n;this.messageModule.plusMessage({role:g9.Assistant,content:e.message,status:_9.Error}),(t=(n=this).onErrorCallback)==null||t.call(n,e)}onMessage(e){var t,n;let r=e;switch((t=(n=this).onMessageCallback)==null||t.call(n,r),r.type){case E9.ActivityDelta:this.handleActivityDeltaEvent(r);break;case E9.ActivitySnapshot:this.handleActivitySnapshotEvent(r);break;case E9.Custom:this.handleCustomEvent(r);break;case E9.MessagesSnapshot:this.handleMessagesSnapshotEvent(r);break;case E9.Raw:this.handleRawEvent(r);break;case E9.RunError:this.handleRunErrorEvent(r);break;case E9.RunFinished:this.handleRunFinishedEvent(r);break;case E9.RunStarted:this.handleRunStartedEvent(r);break;case E9.StateDelta:this.handleStateDeltaEvent(r);break;case E9.StateSnapshot:this.handleStateSnapshotEvent(r);break;case E9.StepFinished:this.handleStepFinishedEvent(r);break;case E9.StepStarted:this.handleStepStartedEvent(r);break;case E9.TextMessageChunk:this.handleTextMessageChunkEvent(r);break;case E9.TextMessageContent:this.handleTextMessageContentEvent(r);break;case E9.TextMessageEnd:this.handleTextMessageEndEvent(r);break;case E9.TextMessageStart:this.handleTextMessageStartEvent(r);break;case E9.ThinkingEnd:this.handleThinkingEndEvent(r);break;case E9.ThinkingStart:this.handleThinkingStartEvent(r);break;case E9.ThinkingTextMessageContent:this.handleThinkingTextMessageContentEvent(r);break;case E9.ThinkingTextMessageEnd:this.handleThinkingTextMessageEndEvent(r);break;case E9.ThinkingTextMessageStart:this.handleThinkingTextMessageStartEvent(r);break;case E9.ToolCallArgs:this.handleToolCallArgsEvent(r);break;case E9.ToolCallChunk:this.handleToolCallChunkEvent(r);break;case E9.ToolCallEnd:this.handleToolCallEndEvent(r);break;case E9.ToolCallResult:this.handleToolCallResultEvent(r);break;case E9.ToolCallStart:this.handleToolCallStartEvent(r);break;default:break}}onStart(){var e,t;(e=(t=this).onStartCallback)==null||e.call(t)}constructor(e){D9(this,`messageModule`,void 0),D9(this,`onDoneCallback`,void 0),D9(this,`onErrorCallback`,void 0),D9(this,`onMessageCallback`,void 0),D9(this,`onStartCallback`,void 0),this.onDoneCallback=e?.onDone,this.onErrorCallback=e?.onError,this.onMessageCallback=e?.onMessage,this.onStartCallback=e?.onStart}};function i0t(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function k9(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){i0t(a,r,i,o,s,`next`,e)}function s(e){i0t(a,r,i,o,s,`throw`,e)}o(void 0)})}}function a0t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function A9(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){a0t(e,t,n[t])})}return e}let o0t=(e,n)=>{let r=(0,t.ref)(null),i=(0,t.ref)(!1),a=(0,t.ref)(!1),o=n||new O9,s=null,l=()=>(i.value=!0,e.http?.agent.getAgentInfo().then(e=>{r.value=e}).finally(()=>{i.value=!1})),u=function(){var t=k9(function*(t,n,r){var i;o instanceof O9&&o.injectMessageModule(e.message),s=new AbortController,(i=e.http)==null||i.fetchClient.streamRequest(A9({url:n||`chat_completion/`,method:`POST`,data:{session_code:t},controller:s,onDone:()=>{var e;a.value=!1,(e=o.onDone)==null||e.call(o)},onError:e=>{var t;a.value=!1,(t=o.onError)==null||t.call(o,e)},onMessage:e=>{var t;(t=o.onMessage)==null||t.call(o,e)},onStart:()=>{var e;a.value=!0,(e=o.onStart)==null||e.call(o)}},r))});return function(e,n,r){return t.apply(this,arguments)}}(),d=function(){var t=k9(function*(t,n,r,i,a){yield e.message?.createAndPlusMessage(A9({role:g9.User,content:t,status:_9.Complete,sessionCode:n},a&&{property:a})),u(n,r,i)});return function(e,n,r,i,a){return t.apply(this,arguments)}}(),f=(t,n,r)=>{let i=e.message?.list.value.at(-1);(i?.status===_9.Streaming||i?.role===g9.User)&&u(t,n,r)},p=()=>{var e;s==null||(e=s.abort)==null||e.call(s),s=null},m=function(){var t=k9(function*(t){return e.http.message?.stopChat(t)});return function(e){return t.apply(this,arguments)}}();return{info:r,isInfoLoading:i,isChatting:a,chat:d,resendMessage:function(){var t=k9(function*(t,n,r,i,a){let o=e.message?.list.value||[],s=o.findIndex(e=>String(e.id)===t);if(s===-1)throw Error(`Message not found: ${t}`);let l=o[s];if(l.role!==g9.User)throw Error(`Can only resend user messages`);let d=l.content,f=l.property,p=r??d,m=o.slice(s),h=e.message?.deleteMessages(m),g=e.message?.createAndPlusMessage(A9({role:g9.User,content:p,status:_9.Complete,sessionCode:n},f&&{property:f}));u(n,i,a),Promise.all([h,g]).catch(e=>{console.error(`[resendMessage] API error:`,e)})});return function(e,n,r,i,a){return t.apply(this,arguments)}}(),resumeStreamingChat:f,abortChat:p,stopChat:m,getAgentInfo:l,reset:e=>{o=e||new O9,r.value=null,i.value=!1}}};function s0t(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function c0t(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){s0t(a,r,i,o,s,`next`,e)}function s(e){s0t(a,r,i,o,s,`throw`,e)}o(void 0)})}}function j9(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M9(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){j9(e,t,n[t])})}return e}function l0t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function N9(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l0t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var u0t=class{clear(){this.handlers=[]}eject(e){this.handlers[e]&&(this.handlers[e]=null)}forEach(e){this.handlers.forEach(t=>{t!==null&&e(t)})}use(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1}constructor(){j9(this,`handlers`,[])}},d0t=class e{applyResponseErrorInterceptors(e){let t=e;return this.interceptors.response.forEach(e=>{e.rejected&&(t=e.rejected(t))}),t}create(t){return new e(I9(this.defaults,t||{}))}delete(e,t,n){return this.request(N9(M9({},n),{url:e,method:`DELETE`,params:t}))}get(e,t,n){return this.request(N9(M9({},n),{url:e,method:`GET`,params:t}))}head(e,t,n){return this.request(N9(M9({},n),{url:e,method:`HEAD`,params:t}))}options(e,t,n){return this.request(N9(M9({},n),{url:e,method:`OPTIONS`,params:t}))}patch(e,t,n){return this.request(N9(M9({},n),{url:e,method:`PATCH`,data:t}))}post(e,t,n){return this.request(N9(M9({},n),{url:e,method:`POST`,data:t}))}prepareRequest(e,t=!1){let n=I9(this.defaults,e);this.interceptors.request.forEach(e=>{if(e.fulfilled)try{n=e.fulfilled(n)}catch(t){throw e.rejected?e.rejected(t):t}});let r=n.url||``;n.baseURL&&!r.startsWith(`http`)&&(r=n.baseURL+r),r=f0t(r,n.params);let i=F9(n.data),a=new Headers(F9(n.headers));t&&!a.has(`Accept`)&&a.set(`Accept`,`text/event-stream`),i!=null&&(n.transformRequest?i=n.transformRequest(i,F9(n.headers)):a.get(`Content-Type`)?.includes(`application/json`)&&typeof i==`object`&&!(i instanceof FormData)&&!(i instanceof Blob)&&!(i instanceof ArrayBuffer)&&(i=JSON.stringify(i)));let o=n.controller?n.controller:new AbortController,s={method:n.method,credentials:n.credentials,mode:n.mode,headers:a,body:i,signal:o.signal};return{url:r,requestConfig:n,fetchConfig:s,controller:o}}put(e,t,n){return this.request(N9(M9({},n),{url:e,method:`PUT`,data:t}))}request(e){var t=this;return c0t(function*(){let{url:n,fetchConfig:r,requestConfig:i,controller:a}=t.prepareRequest(e),o=i.timeout&&i.timeout>0?setTimeout(()=>a.abort(),i.timeout):void 0;try{let e=yield fetch(n,r);o&&clearTimeout(o);let a,s=i.responseType||`json`;try{switch(s){case`json`:a=yield e.json();break;case`text`:a=yield e.text();break;case`blob`:a=yield e.blob();break;case`arrayBuffer`:a=yield e.arrayBuffer();break;case`formData`:a=yield e.formData();break;default:a=yield e.json()}}catch{a=null}i.transformResponse&&(a=i.transformResponse(a));let l={data:a,status:e.status,statusText:e.statusText,headers:e.headers,config:i};if(!(i.validateStatus||t.defaults.validateStatus)(e.status))throw P9(`Request failed with status code ${e.status}`,i,`ERR_BAD_RESPONSE`,l);let u=l;t.interceptors.response.forEach(e=>{if(e.fulfilled)try{u=e.fulfilled(u)}catch(t){throw e.rejected?e.rejected(t):t}}),u instanceof Promise&&(u=yield u);let d=u.data;if(![0,`success`].includes(d.code))throw P9(d.message,i,d.code,u);return d.data}catch(e){if(o&&clearTimeout(o),e instanceof Error&&e.name===`AbortError`){let e=P9(`Request timeout`,i,`ECONNABORTED`,void 0);throw t.applyResponseErrorInterceptors(e)}let n=e.isAxiosError===!0?e:P9(e.message,i,e.code,void 0);throw t.applyResponseErrorInterceptors(n)}})()}stream(e,t){return this.streamRequest(N9(M9({},t),{url:e}))}streamRequest(e){var t=this;return c0t(function*(){let{url:n,fetchConfig:r,requestConfig:i}=t.prepareRequest(e,!0);try{var a;let u=yield fetch(n,r);if(!(i.validateStatus||t.defaults.validateStatus)(u.status)){var o;let t=P9(`Request failed with status code ${u.status}`,i,`ERR_BAD_RESPONSE`,void 0);(o=e.onError)==null||o.call(e,t);return}(a=e.onStart)==null||a.call(e);let d=u.body?.pipeThrough(new window.TextDecoderStream).getReader();if(!d){var s;let t=Error(`IResponse body is not readable`);(s=e.onError)==null||s.call(e,t);return}let f=``,p=e=>{try{return JSON.parse(e),!0}catch{return!1}};for(;;){let{value:t,done:n}=yield d.read();if(n){var l;(l=e.onDone)==null||l.call(e);break}(f+t.toString()).split(`
3047
3047
  `).forEach(t=>{let n=t.replace(`data:`,``).trim();if(p(n)){var r;let t=JSON.parse(n);(r=e.onMessage)==null||r.call(e,t),f=``}else n&&(f=n)})}}catch(t){if(t instanceof Error)if(t.name===`AbortError`){var u;(u=e.onDone)==null||u.call(e)}else{var d;(d=e.onError)==null||d.call(e,t)}throw t}})()}constructor(e={}){j9(this,`defaults`,void 0),j9(this,`interceptors`,void 0),this.defaults=I9({method:`GET`,headers:{"Content-Type":`application/json`},timeout:3e4,responseType:`json`,credentials:`include`,mode:`cors`,validateStatus:e=>e>=200&&e<300},e),this.interceptors={request:new u0t,response:new u0t}}};function f0t(e,t){if(!t)return e;let n=new URLSearchParams;Object.keys(t).forEach(e=>{let r=t[e];r!=null&&(Array.isArray(r)?r.forEach(t=>n.append(e,String(t))):n.append(e,String(r)))});let r=n.toString();return r?`${e}${e.includes(`?`)?`&`:`?`}${r}`:e}function P9(e,t,n,r){let i=Error(e);return i.config=t,i.code=String(n),i.response=r,i.isAxiosError=!0,i}function F9(e){return typeof e==`function`?e():e}function p0t(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function I9(e,t){let n=M9({},e);for(let r in t){let i=t[r];if(p0t(i)){let t=e[r];n[r]=I9(t||{},i)}else n[r]=i}return n}new d0t;let m0t=e=>{let t=new d0t({baseURL:e.requestData.urlPrefix});return e.interceptors?.request&&t.interceptors.request.use(e.interceptors.request),e.interceptors?.response&&t.interceptors.response.use(e.interceptors.response),{fetchClient:t,reset:e=>{t.defaults.baseURL=e.requestData.urlPrefix,t.interceptors.request.clear(),t.interceptors.response.clear(),e.interceptors?.request&&t.interceptors.request.use(e.interceptors.request),e.interceptors?.response&&t.interceptors.response.use(e.interceptors.response)}}},h0t=e=>({getAgentInfo:t=>e.get(`agent/info/`,void 0,t).then(G1t)});function g0t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _0t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){g0t(e,t,n[t])})}return e}let v0t=e=>({getMessages:(t,n,r)=>e.get(`session_content/content/`,{session_code:t,limit:n},r).then(e=>e.map(x9)),plusMessage:(t,n)=>e.post(`session_content/`,J1t(t),n).then(x9),modifyMessage:(t,n)=>e.put(`session_content/${t.id}/`,J1t(t),n).then(x9),deleteMessage:(t,n)=>e.delete(`session_content/${t}/`,void 0,n),batchDeleteMessages:(t,n)=>e.post(`session_content/batch_delete/`,{ids:t},n),shareMessages:(t,n,r,i)=>e.post(`share/`,_0t({session_code:t,content_ids:n},r?{expired_at:r}:{}),i),stopChat:(t,n)=>e.post(`session_content/stop/`,{session_code:t},n)});function y0t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function b0t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){y0t(e,t,n[t])})}return e}function x0t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function S0t(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):x0t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let C0t=e=>({clearSession:(t,n)=>e.post(`chat_completion/${t}/clear/`,void 0,n),getSessions:t=>e.get(`session/`,void 0,t).then(e=>e.map(S9)),plusSession:(t,n)=>e.post(`session/`,Y1t(t),n).then(e=>S9(e)),modifySession:(t,n)=>e.put(`session/${t.sessionCode}/`,Y1t(t),n).then(e=>S9(e)),deleteSession:(t,n)=>e.delete(`session/${t}/`,void 0,n),batchDeleteSessions:(t,n)=>e.post(`session/batch_delete/`,{session_codes:t},n),getSession:(t,n)=>e.get(`session/${t}/`,void 0,n).then(e=>S9(e)),postSessionFeedback:(t,n)=>e.post(`session_feedback/`,X1t(t),n).then(e=>Z1t(e)),getSessionFeedbackReasons:(t,n)=>e.get(`session_feedback/reasons/`,{rate:t},n),renameSession:(t,n)=>e.post(`session/${t}/ai_rename/`,void 0,n).then(e=>S9(e)),uploadFile:(t,n,r)=>{let i=encodeURIComponent(n.name);return n.arrayBuffer().then(a=>e.post(`session/${t}/upload/${i}/`,a,S0t(b0t({},r),{headers:{"Content-Disposition":`attachment; filename="${n.name}"`}})))}}),w0t=e=>({agent:h0t(e),session:C0t(e),message:v0t(e),fetchClient:e});function T0t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E0t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){T0t(e,t,n[t])})}return e}function D0t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function O0t(e,t){return t??={},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):D0t(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}let k0t=e=>{let{fetchClient:t,reset:n}=m0t(e);return O0t(E0t({},w0t(t)),{reset:n})},A0t=()=>({agent:null,http:null,message:null,session:null,registerAgent(e){this.agent=e},registerHttp(e){this.http=e},registerMessage(e){this.message=e},registerSession(e){this.session=e}});function j0t(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function L9(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){j0t(a,r,i,o,s,`next`,e)}function s(e){j0t(a,r,i,o,s,`throw`,e)}o(void 0)})}}function M0t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function N0t(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t],r=Object.keys(n);typeof Object.getOwnPropertySymbols==`function`&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){M0t(e,t,n[t])})}return e}let P0t=e=>{let n=(0,t.ref)([]),r=(0,t.ref)(null),i=(0,t.ref)(!1),a=(0,t.ref)(!1),o=(0,t.ref)(!1),s=(0,t.ref)(!1),l=(0,t.ref)(!1),u=(0,t.ref)(!1),d=e=>{n.value=n.value.map(t=>t.sessionCode===e.sessionCode?N0t({},t,e):t),r.value?.sessionCode===e.sessionCode&&(r.value=n.value.find(t=>t.sessionCode===e.sessionCode)??r.value)},f=()=>(a.value=!0,e.http?.session.getSessions().then(e=>{n.value=e}).finally(()=>{a.value=!1})),p=function(){var t=L9(function*(t,i){var a;if((a=e.agent)==null||a.abortChat(),r.value=n.value.find(e=>e.sessionCode===t)??null,i?.loadMessages!==!1){var o;yield e.message?.getMessages(t),(o=e.agent)==null||o.resumeStreamingChat(t)}else e.message&&(e.message.list.value=[])});return function(e,n){return t.apply(this,arguments)}}();return{list:n,current:r,isCurrentLoading:i,isListLoading:a,isCreateLoading:o,isUpdateLoading:s,isDeleteLoading:l,getSessions:f,chooseSession:p,getSession:t=>(i.value=!0,e.http?.session.getSession(t).then(e=>{r.value=e}).finally(()=>{i.value=!1})),createSession:function(){var t=L9(function*(t,r){o.value=!0;try{let i=yield e.http?.session.plusSession(t);i&&(n.value.unshift(i),yield p(i.sessionCode,{loadMessages:r?.loadMessages??!1}))}finally{o.value=!1}});return function(e,n){return t.apply(this,arguments)}}(),updateSession:t=>(s.value=!0,e.http?.session.modifySession(t).then(e=>{d(e)}).finally(()=>{s.value=!1})),deleteSession:function(){var t=L9(function*(t){l.value=!0;try{yield e.http?.session.deleteSession(t),n.value=n.value.filter(e=>e.sessionCode!==t),r.value?.sessionCode===t&&n.value[0]?.sessionCode&&(yield p(n.value[0].sessionCode))}finally{l.value=!1}});return function(e){return t.apply(this,arguments)}}(),postSessionFeedback:t=>e.http?.session.postSessionFeedback(t),getSessionFeedbackReasons:t=>e.http?.session.getSessionFeedbackReasons(t),renameSession:t=>(u.value=!0,e.http?.session.renameSession(t).then(e=>{d({sessionCode:e.sessionCode,sessionName:e.sessionName})}).finally(()=>{u.value=!1})),uploadFile:(t,n)=>e.http?.session.uploadFile(t,n),reset:()=>{n.value=[],r.value=null,i.value=!1,a.value=!1,o.value=!1,s.value=!1,l.value=!1,u.value=!1}}},R9=e=>{let t=A0t(),n=k0t(e),r=o0t(t,e.protocol),i=r0t(t),a=P0t(t);return t.registerHttp(n),t.registerMessage(i),t.registerAgent(r),t.registerSession(a),{agent:r,session:a,message:i,http:n,reset:e=>{n.reset(e),r.reset(e.protocol),i.reset(),a.reset()}}};var F0t=class{_isGenerating;agentModule;config;eventEmitter;messageModule;sessionModule;autoRenameSessionIfNeeded(e){this.sessionModule&&this.messageModule.list.value.length===1&&this.sessionModule.renameSession(e).catch(e=>{console.error(`[ChatBusinessManager] Auto rename session failed:`,e)})}emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,n,r=null,i=null,a={}){this.agentModule=e,this.messageModule=n,this.sessionModule=r,this.eventEmitter=i,this.config=a,this._isGenerating=(0,t.ref)(!1)}get isGenerating(){return this._isGenerating}get isMessagesLoading(){return this.messageModule.isListLoading}get messages(){return this.messageModule.list}get openingRemark(){return this.config.openingRemark||``}get predefinedQuestions(){return this.config.predefinedQuestions||[]}async batchDeleteMessages(e){try{await this.messageModule.deleteMessages(e);let t=e.map(e=>e.id).filter(Boolean);this.emit(`messages-batch-deleted`,{messageIds:t})}catch(e){throw console.error(`Failed to batch delete messages:`,e),this.emit(`chat-error`,{action:`batch-delete-messages`,error:e}),e}}async deleteMessage(e){try{await this.messageModule.deleteMessages([e]),this.emit(`message-deleted`,{messageId:e.id})}catch(e){throw console.error(`Failed to delete message:`,e),this.emit(`chat-error`,{action:`delete-message`,error:e}),e}}handleStreamEnd(){this._isGenerating.value=!1,this.emit(`receive-end`,{})}handleStreamError(e){this._isGenerating.value=!1,this.emit(`receive-error`,{error:e})}handleStreamStart(){this._isGenerating.value=!0,this.emit(`receive-start`,{})}async regenerateFromAIMessages(e,t){try{if(!e||e.length===0)throw Error(`No AI messages provided`);let n=this.messages.value,r=p9(n,e[0]);if(!r)throw Error(`No user message found before AI messages`);let i=r.id;if(i===void 0)throw Error(`User message has no id`);await this.regenerateMessage(String(i),t)}catch(e){throw console.error(`Failed to regenerate from AI messages:`,e),this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async regenerateMessage(e,t){try{let n=this.messages.value,r=n.findIndex(t=>String(t.id)===e);if(r===-1)throw Error(`Message not found: ${e}`);let i=n[r];if(i.role!==g9.User)throw Error(`Can only regenerate from user messages`);let a=n.slice(r),o=typeof i.content==`string`?i.content:JSON.stringify(i.content),s=i.property;this._isGenerating.value=!0;let l=this.messageModule.deleteMessages(a);this.agentModule.chat(o,t,void 0,void 0,s),this.emit(`chat-regenerate`,{messageId:e}),l.catch(e=>{console.error(`[regenerateMessage] Delete API error:`,e)})}catch(e){throw console.error(`Failed to regenerate message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async resendMessageWithProperty(e,t,n,r){try{let i=this.messages.value,a=i.findIndex(t=>String(t.id)===e);if(a===-1)throw Error(`Message not found: ${e}`);if(i[a].role!==g9.User)throw Error(`Can only resend user messages`);let o=i.slice(a);this._isGenerating.value=!0;let s=this.messageModule.deleteMessages(o);this.agentModule.chat(n,t,void 0,void 0,r),this.emit(`chat-resend`,{messageId:e}),s.catch(e=>{console.error(`[resendMessageWithProperty] Delete API error:`,e)})}catch(e){throw console.error(`Failed to resend message with property:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`resend`,error:e}),e}}async retryMessage(e){try{console.warn(`retryMessage not implemented yet`),this.emit(`chat-retry`,{messageId:e})}catch(e){throw console.error(`Failed to retry message:`,e),this.emit(`chat-error`,{action:`retry`,error:e}),e}}async sendMessage(e,t,n={}){try{if(!t)throw Error(`No active session. Please create or select a session first.`);this._isGenerating.value=!0,this.emit(`send-message`,{content:e}),await this.agentModule.chat(e,t,void 0,void 0,n.property),this.autoRenameSessionIfNeeded(t)}catch(e){throw console.error(`Failed to send message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`send`,error:e}),e}}stopGeneration(){try{let e=this.sessionModule?.current?.value?.sessionCode??``;this.agentModule.stopChat(e),this._isGenerating.value=!1,this.emit(`stop`,{})}catch(e){console.error(`Failed to stop generation:`,e),this.emit(`chat-error`,{action:`stop`,error:e})}}},z9=class{config;eventEmitter;messageModule;sessionModule;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,t,n=null,r={}){this.sessionModule=e,this.messageModule=t,this.eventEmitter=n,this.config=r}get currentSession(){return this.sessionModule.current}get isCreateLoading(){return this.sessionModule.isCreateLoading}get isCurrentLoading(){return this.sessionModule.isCurrentLoading}get isDeleteLoading(){return this.sessionModule.isDeleteLoading}get isListLoading(){return this.sessionModule.isListLoading}get isUpdateLoading(){return this.sessionModule.isUpdateLoading}get sessionList(){return this.sessionModule.list}async createNewSession(){return this.createSession({name:`新会话`,sessionCode:`new_session_${Date.now()}`})}async createSession(e={}){if(this.config.enableChatSession===!1)throw Error(`Chat session is disabled`);try{let t={sessionName:e.name||`新会话`,sessionCode:e.sessionCode||`session_${Date.now()}`,isTemporary:e.isTemporary||!1};await this.sessionModule.createSession(t),this.emit(`session-created`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to create session:`,e),this.emit(`session-error`,{action:`create`,error:e}),e}}async deleteSession(e){try{await this.sessionModule.deleteSession(e),this.emit(`session-deleted`,{sessionCode:e})}catch(e){throw console.error(`Failed to delete session:`,e),this.emit(`session-error`,{action:`delete`,error:e}),e}}async getSession(e){try{await this.sessionModule.getSession(e)}catch(e){throw console.error(`Failed to get session:`,e),this.emit(`session-error`,{action:`get`,error:e}),e}}async loadRecentSession(e){try{e?.skipLoadSessions||await this.loadSessions();let t=this.sessionList.value;if(this.config.initialSessionCode){await this.switchSession(this.config.initialSessionCode);return}if(t.length>0){let e=t[0];(e.sessionContentCount??0)>0?await this.createNewSession():await this.switchSession(e.sessionCode,{loadMessages:!1});return}await this.createNewSession()}catch(e){throw console.error(`Failed to load recent session:`,e),e}}async loadSessions(){try{await this.sessionModule.getSessions(),this.emit(`sessions-loaded`,{sessions:this.sessionList.value})}catch(e){throw console.error(`Failed to load sessions:`,e),this.emit(`session-error`,{action:`load`,error:e}),e}}async switchSession(e,t){try{await this.sessionModule.chooseSession(e,t),this.emit(`session-switched`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to switch session:`,e),this.emit(`session-error`,{action:`switch`,error:e}),e}}async updateSessionName(e,t){try{let n=this.sessionList.value.find(t=>t.sessionCode===e);if(!n)throw Error(`Session not found: ${e}`);await this.sessionModule.updateSession({...n,sessionName:t}),this.emit(`session-updated`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to update session name:`,e),this.emit(`session-error`,{action:`update`,error:e}),e}}},I0t=class{messageModule;sessionModule;constructor(e,t){this.messageModule=e,this.sessionModule=t}async shareMessages(e){if(e.length===0)throw Error(`No messages to share`);let t=this.sessionModule.current?.value?.sessionCode;if(!t)throw Error(`No active session`);let n=await this.messageModule.shareMessages(t,e);if(!n)throw Error(`Share failed: no result returned`);return{shareUrl:`${n.share_page}share-page/${n.share_token}`,userMessageIds:e.filter(e=>e.role===`user`).map(e=>String(e.id))}}},B9=class{_agentShortcuts;_effectiveShortcuts;_propsShortcuts;eventEmitter;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e=null,n=[]){this._propsShortcuts=(0,t.ref)(n),this._agentShortcuts=(0,t.ref)([]),this.eventEmitter=e,this._effectiveShortcuts=(0,t.computed)(()=>this._propsShortcuts.value.length>0?this._propsShortcuts.value:this._agentShortcuts.value.length>0?this._agentShortcuts.value:[])}get count(){return this._effectiveShortcuts.value.length}get effectiveShortcuts(){return this._effectiveShortcuts}get hasShortcuts(){return this._effectiveShortcuts.value.length>0}get shortcuts(){return this._effectiveShortcuts}addShortcut(e){this._propsShortcuts.value.push(e)}clear(){this._propsShortcuts.value=[],this._agentShortcuts.value=[]}filterByTextLength(e,t){return!e||e.length>t?[]:this._effectiveShortcuts.value}filterShortcuts(e,t){return t?this._effectiveShortcuts.value.filter(n=>t(n,e)):this._effectiveShortcuts.value}getShortcutById(e){return this._effectiveShortcuts.value.find(t=>t.id===e)}handleShortcutClick(e,t,n=`main`){this.emit(`shortcut-click`,{shortcut:e,selectedText:t,source:n})}limitShortcuts(e){return this._effectiveShortcuts.value.slice(0,e)}removeShortcut(e){this._propsShortcuts.value=this._propsShortcuts.value.filter(t=>t.id!==e)}setAgentShortcuts(e){this._agentShortcuts.value=e}setShortcuts(e){this._propsShortcuts.value=e}},L0t=class{config;_panelVisible;_nimbusMinimized;_isDraggingOrResizing;_positionAndSize;_isCompressed;containerRef=null;listeners;onceListeners;debugMode;cleanupFunctions;constructor(e={}){this.config=e,this.listeners=new Map,this.onceListeners=new Map,this.debugMode=e.debug??!1,this.cleanupFunctions=[],this._panelVisible=(0,t.ref)(e.initialPanelVisible??!1),this._nimbusMinimized=(0,t.ref)(e.initialNimbusMinimized??!1),this._isDraggingOrResizing=(0,t.ref)(!1),this._isCompressed=(0,t.ref)(!1),this._positionAndSize=(0,t.ref)({x:0,y:0,width:400,height:window.innerHeight})}getConfig(){return this.config}get state(){return{panelVisible:this._panelVisible,nimbusMinimized:this._nimbusMinimized,isDraggingOrResizing:this._isDraggingOrResizing,positionAndSize:this._positionAndSize}}get panelVisible(){return this._panelVisible}get nimbusMinimized(){return this._nimbusMinimized}get isDraggingOrResizing(){return this._isDraggingOrResizing}get isCompressed(){return this._isCompressed}get panel(){return{show:this.showPanel.bind(this),hide:this.hidePanel.bind(this),toggle:this.togglePanel.bind(this),isVisible:(0,t.computed)(()=>this._panelVisible.value)}}showPanel(e){this._panelVisible.value=!0,this.emit(`panel-show`,{sessionCode:e})}hidePanel(){this._panelVisible.value=!1,this.emit(`panel-hide`,{})}togglePanel(){this._panelVisible.value?this.hidePanel():this.showPanel()}get nimbus(){return{minimize:this.minimizeNimbus.bind(this),restore:this.restoreNimbus.bind(this),toggle:this.toggleNimbus.bind(this),isMinimized:(0,t.computed)(()=>this._nimbusMinimized.value)}}minimizeNimbus(){this._nimbusMinimized.value=!0,this.emit(`nimbus-minimize`,{})}restoreNimbus(){this._nimbusMinimized.value=!1,this.emit(`nimbus-restore`,{})}toggleNimbus(){this._nimbusMinimized.value?this.restoreNimbus():this.minimizeNimbus()}handleNimbusClick(){this.emit(`nimbus-click`,{}),this.showPanel()}get container(){return{updatePosition:this.updatePosition.bind(this),updateSize:this.updateSize.bind(this),updatePositionAndSize:this.updatePositionAndSize.bind(this),toggleCompression:this.toggleCompression.bind(this),positionAndSize:(0,t.computed)(()=>this._positionAndSize.value),isCompressed:(0,t.computed)(()=>this._isCompressed.value)}}updatePosition(e,t){this._positionAndSize.value={...this._positionAndSize.value,x:e,y:t}}updateSize(e,t){this._positionAndSize.value={...this._positionAndSize.value,width:e,height:t}}updatePositionAndSize(e,t,n,r){this._positionAndSize.value={x:e,y:t,width:n,height:r}}setContainerRef(e){this.containerRef=e,e?.isCompressed&&(this._isCompressed.value=e.isCompressed.value)}setCompressed(e){this._isCompressed.value=e}toggleCompression(){this.containerRef?this.containerRef.toggleCompression():this._isCompressed.value=!this._isCompressed.value}setDraggingOrResizing(e){this._isDraggingOrResizing.value=e}handleDragging(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`dragging`,e)}handleResizing(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`resizing`,e)}handleDragStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`drag-stop`,e)}handleResizeStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`resize-stop`,e)}handlePopupClick(){this.emit(`popup-click`,{}),this.showPanel()}handlePopupShortcutClick(e){this.emit(`popup-shortcut-click`,{shortcut:e}),this.emit(`shortcut-click`,{shortcut:e,source:`popup`})}handleShortcutClick(e,t){this.emit(`shortcut-click`,{shortcut:e,source:t})}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed to "${e}", total: ${this.listenerCount(e)}`),()=>{this.off(e,t)}}once(e,t){return this.onceListeners.has(e)||this.onceListeners.set(e,new Set),this.onceListeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed once to "${e}"`),()=>{this.onceListeners.get(e)?.delete(t)}}off(e,t){t?(this.listeners.get(e)?.delete(t),this.onceListeners.get(e)?.delete(t),this.debugMode&&console.debug(`[ComponentManager] Unsubscribed from "${e}", remaining: ${this.listenerCount(e)}`)):(this.listeners.delete(e),this.onceListeners.delete(e),this.debugMode&&console.debug(`[ComponentManager] Removed all listeners for "${e}"`))}emit(e,t){this.debugMode&&console.debug(`[ComponentManager] Emitting "${e}"`,t);let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in listener for "${e}":`,t)}});let r=this.onceListeners.get(e);if(r&&r.size>0){let n=Array.from(r);this.onceListeners.delete(e),n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in once listener for "${e}":`,t)}})}}emitInternal(e,t){this.emit(e,t)}listenerCount(e){return(this.listeners.get(e)?.size??0)+(this.onceListeners.get(e)?.size??0)}hasListeners(e){return this.listenerCount(e)>0}getRegisteredEvents(){let e=new Set;return this.listeners.forEach((t,n)=>e.add(n)),this.onceListeners.forEach((t,n)=>e.add(n)),Array.from(e)}setDebugMode(e){this.debugMode=e}destroy(){this.listeners.clear(),this.onceListeners.clear(),this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.debugMode&&console.debug(`[ComponentManager] Destroyed`)}};function R0t(e){return new L0t(e)}let z0t={"panel-show":`show`,"panel-hide":`close`,"panel-toggle":null,"nimbus-click":null,"nimbus-minimize":null,"nimbus-restore":null,"popup-click":null,"popup-shortcut-click":null,dragging:`dragging`,resizing:`resizing`,"drag-stop":`drag-stop`,"resize-stop":`resize-stop`,"compression-toggle":null,"send-message":`send-message`,"receive-start":`receive-start`,"receive-text":`receive-text`,"receive-end":`receive-end`,"receive-error":null,stop:`stop`,"chat-regenerate":null,"chat-retry":null,"message-deleted":null,"messages-batch-deleted":null,"session-created":null,"session-switched":null,"session-deleted":null,"session-updated":null,"sessions-loaded":null,"session-initialized":`session-initialized`,"session-error":null,"shortcut-click":`shortcut-click`,"chat-error":null,"sdk-error":`sdk-error`,"new-chat":`new-chat`,"history-click":`history-click`,"auto-generate-name":`auto-generate-name`,"help-click":`help-click`,rename:`rename`,share:`share`,close:`close`,"toggle-compression":null,"transfer-messages":`transfer-messages`,"share-messages":`share-messages`,"agent-info-loaded":null,error:null};function B0t(e,t){switch(e){case`send-message`:return[t.content];case`rename`:return[t.newName];case`history-click`:return[t.event];case`dragging`:case`resizing`:case`drag-stop`:case`resize-stop`:case`shortcut-click`:case`session-initialized`:case`sdk-error`:case`transfer-messages`:case`share-messages`:return[t];case`panel-show`:case`panel-hide`:case`receive-start`:case`receive-text`:case`receive-end`:case`stop`:case`new-chat`:case`auto-generate-name`:case`help-click`:case`share`:case`close`:return[];default:return[t]}}var V0t=class{_selectedMessageIds;_isSelectionMode;_editingSessionCode;_loadingStates;constructor(){this._selectedMessageIds=(0,t.ref)(new Set),this._isSelectionMode=(0,t.ref)(!1),this._editingSessionCode=(0,t.ref)(null),this._loadingStates=(0,t.reactive)({})}get isSelectionMode(){return this._isSelectionMode}get editingSessionCode(){return this._editingSessionCode}toggleSelectionMode(){this._isSelectionMode.value=!this._isSelectionMode.value,this._isSelectionMode.value||this.clearSelection()}enableSelectionMode(){this._isSelectionMode.value=!0}disableSelectionMode(){this._isSelectionMode.value=!1,this.clearSelection()}toggleMessageSelection(e){this._selectedMessageIds.value.has(e)?this._selectedMessageIds.value.delete(e):this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectMessage(e){this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}deselectMessage(e){this._selectedMessageIds.value.delete(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}isMessageSelected(e){return this._selectedMessageIds.value.has(e)}clearSelection(){this._selectedMessageIds.value.clear(),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectAllMessages(e){this._selectedMessageIds.value=new Set(e)}get selectedMessages(){return Array.from(this._selectedMessageIds.value)}get selectedCount(){return this._selectedMessageIds.value.size}get hasSelection(){return this._selectedMessageIds.value.size>0}startEditingSession(e){this._editingSessionCode.value=e}stopEditingSession(){this._editingSessionCode.value=null}isEditingSession(e){return e?this._editingSessionCode.value===e:this._editingSessionCode.value!==null}setLoading(e,t){this._loadingStates[e]=t}isLoading(e){return this._loadingStates[e]??!1}clearLoadingStates(){Object.keys(this._loadingStates).forEach(e=>{this._loadingStates[e]=!1})}reset(){this.clearSelection(),this.disableSelectionMode(),this.stopEditingSession(),this.clearLoadingStates()}},H0t={class:`selection-footer`},U0t={class:`selection-footer-left`},W0t={class:`select-all-text`},G0t={class:`selection-footer-right`},K0t=f9((0,t.defineComponent)({__name:`selection-footer`,props:{isAllSelected:{type:Boolean},loading:{type:Boolean,default:!1},selectedCount:{}},emits:[`cancel`,`confirm`,`toggle-all`],setup(e){let n=e;return(e,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,H0t,[(0,t.createElementVNode)(`div`,U0t,[(0,t.createVNode)((0,t.unref)(El),{"model-value":n.isAllSelected,"onUpdate:modelValue":r[0]||=t=>e.$emit(`toggle-all`,t)},null,8,[`model-value`]),(0,t.createElementVNode)(`span`,W0t,(0,t.toDisplayString)((0,t.unref)(m9)(`全选`)),1)]),(0,t.createElementVNode)(`div`,G0t,[(0,t.createVNode)((0,t.unref)(tc),{disabled:n.loading,onClick:r[1]||=t=>e.$emit(`cancel`)},{default:(0,t.withCtx)(()=>[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(m9)(`取消`)),1)]),_:1},8,[`disabled`]),(0,t.createVNode)((0,t.unref)(tc),{disabled:n.selectedCount===0,loading:n.loading,theme:`primary`,onClick:r[2]||=t=>e.$emit(`confirm`)},{default:(0,t.withCtx)(()=>[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(m9)(`确定`)),1)]),_:1},8,[`disabled`,`loading`])])]))}}),[[`__scopeId`,`data-v-3247bea6`]]),q0t={key:0,class:`chatbot-error`},J0t={class:`chatbot-loading`},Y0t={key:0,class:`chatbot-welcome`},X0t={class:`welcome-content`},Z0t={key:0,class:`welcome-remark`},Q0t={key:0,class:`chatbot-loading`},$0t={key:3,class:`chatbot-input`},e2t=(0,t.defineComponent)({__name:`chat-bot`,props:{autoLoad:{type:Boolean,default:!0},chatHelper:{default:void 0},enableSelection:{type:Boolean,default:!1},extCls:{},height:{},helloText:{},maxWidth:{},placeholder:{},prompts:{},requestOptions:{},resources:{default:()=>[]},sessionCode:{},shareLoading:{type:Boolean,default:!1},shortcutLimit:{default:10},shortcuts:{default:()=>[]},url:{default:``}},emits:[`agent-info-loaded`,`cancel-share`,`confirm-share`,`error`,`feedback`,`receive-end`,`receive-start`,`receive-text`,`request-share`,`send-message`,`session-switched`,`shortcut-click`,`stop`],setup(e,{expose:n,emit:r}){let i=e,a=r,o=(0,t.ref)(),s=(0,t.ref)(),l=(0,t.ref)(null),u=(0,t.shallowRef)([]),d=(0,t.ref)(!1),f=(0,t.ref)(null),p=()=>i.chatHelper?!i.chatHelper.agent||!i.chatHelper.session||!i.chatHelper.message?{valid:!1,error:`[ChatBot] Invalid chatHelper: missing required modules (agent, session, message)`}:{valid:!0}:i.url?{valid:!0}:{valid:!1,error:`[ChatBot] Neither chatHelper nor url provided. Component requires at least one.`},m=(()=>{let e=p();if(!e.valid)return console.error(e.error),f.value=Error(e.error),null;if(i.chatHelper)return i.chatHelper;let t=new O9({onStart:()=>{a(`receive-start`)},onMessage:e=>{a(`receive-text`)},onDone:()=>{a(`receive-end`),oe()},onError:e=>{a(`error`,e)}}),n=R9({requestData:{urlPrefix:p1t(i.url),headers:i.requestOptions?.headers,data:i.requestOptions?.data},protocol:t});return t.injectMessageModule(n.message),n})(),h=(0,t.computed)(()=>((i.chatHelper||m)?.agent)?.isChatting?.value?_.Streaming:_.Complete),v=(0,t.computed)(()=>h.value===_.Streaming?P7.Disabled:void 0),y=async(e,t)=>{if(e.id===`cite`){P.value=t.filter(e=>e.role!==g.Reasoning).map(e=>typeof e.content==`string`?e.content:JSON.stringify(e.content||``)).join(`
3048
- `),ye();return}if(e.id===`rebuild`){await S(t);return}if(e.id===`delete`){await x(t);return}if(e.id===`share`){a(`request-share`);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await m?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},b=async(e,t,n,r)=>{if(!m){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let i=m.session.current?.value?.sessionCode;if(!i){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let o=c1t(j?.messages.value||[],t[0]);if(o===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let s=e.id===`like`?5:0;try{await m.session.postSessionFeedback({sessionCode:i,sessionContentIds:[o],rate:s,labels:n,comment:r}),a(`feedback`,e,t[0],n,r)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),a(`error`,e)}},x=async e=>{if(!j||!m){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=j.messages.value,n=p9(t,e[0]);if(!n){console.error(`[ChatBot] No user message found before AI messages`);return}let r=[n,...e];await m.message.deleteMessages(r)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),a(`error`,e)}},S=async e=>{if(!j||!m){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let t=m.session.current?.value?.sessionCode;if(!t){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await j.regenerateFromAIMessages(e,t),oe()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),a(`error`,e)}},C=async(e,t)=>{if(e.id===`delete`){await D(t);return}if(e.id===`cite`){P.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),ye();return}console.log(`handleUserAction`,e,t)},w=async(e,t,n)=>{if(!m){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let r=m.session.current?.value?.sessionCode;if(!r){console.error(`[ChatBot] Cannot edit message: no active session`);return}let i=e.id;if(i===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,i,r,t),await m.agent.resendMessage(String(i),r,t),oe()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),a(`error`,e)}},T=async(e,t)=>{if(!j||!m){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let n=m.session.current?.value?.sessionCode;if(!n){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let r=e.id;if(r===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let i=E(e);if(!i){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let a=me(i,t),o=String(t.input??``);await j.resendMessageWithProperty(String(r),n,o,a),oe()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),a(`error`,e)}},E=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?H.value.find(e=>e.id===t.command)??null:null},D=async e=>{if(!j||!m){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=j.messages.value,n=t.findIndex(t=>t===e);if(n===-1){console.error(`[ChatBot] User message not found in messages list`);return}let r=[];for(let e=n+1;e<t.length;e++){let n=t[e];if(n.role===g.User)break;r.push(n)}let i=[e,...r];await m.message.deleteMessages(i)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),a(`error`,e)}},O=async()=>{((i.chatHelper||m)?.agent)?.stopChat?.(m?.session.current?.value?.sessionCode??``)},k=!i.chatHelper,A=m?new z9(m.session,m.message,null,{enableChatSession:!0,autoSwitchToInitialSession:!!i.sessionCode,loadRecentSessionOnMount:i.autoLoad,initialSessionCode:i.sessionCode}):null,j=m?new F0t(m.agent,m.message,m.session,null,{openingRemark:i.helloText,predefinedQuestions:i.prompts,placeholder:i.placeholder}):null,M=new B9(null,i.shortcuts||[]),N=(0,t.shallowRef)([[]]),P=(0,t.ref)(``),F=(0,t.computed)(()=>j?.messages.value??[]),I=(0,t.computed)(()=>j?.isMessagesLoading.value??!1),L=(0,t.computed)(()=>j?.isGenerating.value??!1),R=(0,t.computed)(()=>A?.currentSession.value??null),ee=(0,t.computed)(()=>k&&!d.value?!1:!I.value&&F.value.length===0),z=(0,t.computed)(()=>m?.agent.info.value?.conversationSettings?.openingRemark||``),B=(0,t.computed)(()=>i.resources?.length?i.resources:u1t(m?.agent.info.value?.resources)),V=(0,t.computed)(()=>i.prompts?.length?i.prompts:m?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),te=(0,t.computed)(()=>({height:typeof i.height==`number`?`${i.height}px`:i.height,maxWidth:typeof i.maxWidth==`number`?`${i.maxWidth}px`:i.maxWidth})),ne=(0,t.computed)(()=>{let e=M.shortcuts.value;return i.shortcutLimit&&e.length>i.shortcutLimit?e.slice(0,i.shortcutLimit):e}),re=()=>{u.value=[],a(`cancel-share`)},ie=()=>{a(`confirm-share`,u.value)},ae=e=>{e?u.value=F.value:u.value=[]},H=M.effectiveShortcuts;(0,t.watch)(()=>i.shortcuts,e=>{M.setShortcuts(e||[])},{immediate:!0}),(0,t.watch)(()=>m?.agent.info.value?.conversationSettings?.commands,e=>{e&&M.setAgentShortcuts(e)},{immediate:!0});let oe=async()=>{await(0,t.nextTick)(),o.value&&(o.value.scrollTop=o.value.scrollHeight)},se=async(e,t={})=>{if(!j||!m)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let n=m.session.current?.value?.sessionCode;if(!n)throw Error(`[ChatBot] Cannot send message: no active session`);N.value=[[]],P.value=``,a(`send-message`,typeof e==`string`?e:``),await j.sendMessage(e,n,t)},ce=async e=>{let t=m?.session.current?.value?.sessionCode;return t&&await m.session.uploadFile(t,e)||{}},le=async(e,t)=>{try{await se(e,P.value?{property:{extra:{cite:P.value}}}:{})}catch(e){console.error(`Failed to send message:`,e),a(`error`,e)}},ue=async()=>{ge()},de=(e,t)=>{fe(e,t),a(`shortcut-click`,{shortcut:e,source:`main`})},fe=(e,t)=>{let n=e,r=n.components?.find(e=>e.fillBack)?.key||`input`;l.value={...n,formModel:{...n.formModel,[r]:t||``}}},pe=()=>{l.value=null},me=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},he=async e=>{if(!l.value){console.error(`[ChatBot] No selected shortcut`);return}let t=me(l.value,e),n=l.value.name,r=l.value;pe();try{await se(n,{property:t})}catch(e){l.value=r,console.error(`[ChatBot] Failed to submit shortcut:`,e),a(`error`,e)}},ge=()=>{if(!j){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}j.stopGeneration(),a(`stop`)},_e=async e=>{if(!A){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await A.switchSession(e),a(`session-switched`,A.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),a(`error`,e)}},ve=e=>{P.value=e},ye=()=>{s.value?.focus?.()};return(0,t.onMounted)(async()=>{if(!(!m||f.value))try{if(k){if(await m.agent.getAgentInfo(),await m.session.getSessions(),i.sessionCode)await m.session.chooseSession(i.sessionCode);else if(m.session.list.value.length>0){let e=m.session.list.value[0];await m.session.chooseSession(e.sessionCode)}d.value=!0}else d.value=!0;a(`agent-info-loaded`,m)}catch(e){console.error(`Failed to initialize ChatBot:`,e),f.value=e,a(`error`,e)}}),(0,t.onBeforeUnmount)(()=>{k&&m&&m.agent.stopChat(m.session.current?.value?.sessionCode??``)}),n({sendMessage:e=>le(e,[[]]),stopGeneration:ge,switchSession:_e,messages:F,currentSession:R,isGenerating:L,getChatHelper:()=>m,setCiteText:ve,focusInput:ye,selectShortcut:(e,t)=>{fe(e,t)}}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:(0,t.normalizeClass)([`ai-chatbot`,i.extCls,{"welcome-state":ee.value}]),style:(0,t.normalizeStyle)(te.value)},[(0,t.createCommentVNode)(` 初始化错误提示 `),f.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,q0t,[(0,t.createElementVNode)(`span`,null,(0,t.toDisplayString)(f.value.message),1)])):k&&!d.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 独立模式:初始化中(getAgentInfo → getSessions → chooseSession)统一展示 Loading `),(0,t.createElementVNode)(`div`,J0t,[(0,t.createVNode)((0,t.unref)(qs),{mode:`spin`,size:`small`,theme:`primary`})])],2112)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[(0,t.createCommentVNode)(` 内容区:欢迎状态 `),ee.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Y0t,[(0,t.createElementVNode)(`div`,X0t,[n[3]||=(0,t.createElementVNode)(`h2`,{class:`welcome-title`},`你好,我是小鲸`,-1),z.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Z0t,[(0,t.createVNode)((0,t.unref)(s7),{content:z.value},null,8,[`content`])])):(0,t.createCommentVNode)(`v-if`,!0)])])):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 内容区:消息列表 `),(0,t.createElementVNode)(`div`,{ref_key:`messagesContainerRef`,ref:o,class:`chatbot-messages`},[I.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Q0t,[(0,t.createVNode)((0,t.unref)(qs),{mode:`spin`,size:`small`,theme:`primary`})])):((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(o1t),{key:1,"selected-messages":u.value,"onUpdate:selectedMessages":n[0]||=e=>u.value=e,"enable-selection":i.enableSelection,"message-status":h.value,"message-tools-status":v.value,messages:F.value,"on-agent-action":y,"on-agent-feedback":b,"on-user-action":C,"on-user-input-confirm":w,"on-user-shortcut-confirm":T,onStopStreaming:O},null,8,[`selected-messages`,`enable-selection`,`message-status`,`message-tools-status`,`messages`]))],512)],2112)),(0,t.createCommentVNode)(` 统一底部区域 `),!ee.value&&i.enableSelection?((0,t.openBlock)(),(0,t.createBlock)(K0t,{key:2,"is-all-selected":u.value.length===F.value.length,loading:i.shareLoading,"selected-count":u.value.length,onCancel:re,onConfirm:ie,onToggleAll:ae},null,8,[`is-all-selected`,`loading`,`selected-count`])):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,$0t,[l.value?.components?.length?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Bxe),(0,t.mergeProps)({key:0},l.value,{onClose:pe,onSubmit:he}),null,16)):(0,t.renderSlot)(e.$slots,`input`,{key:1},()=>[(0,t.createVNode)((0,t.unref)(qQt),{ref_key:`chatInputRef`,ref:s,modelValue:N.value,"onUpdate:modelValue":n[1]||=e=>N.value=e,cite:P.value,"onUpdate:cite":n[2]||=e=>P.value=e,"message-status":h.value,"on-send-message":le,"on-stop-sending":ue,"on-upload":ce,placeholder:i.placeholder,prompts:V.value,resources:B.value,"shortcut-id":l.value?.id,shortcuts:ne.value,onSelectShortcut:de},null,8,[`modelValue`,`cite`,`message-status`,`placeholder`,`prompts`,`resources`,`shortcut-id`,`shortcuts`])])]))],64))],6))}});let V9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function t2t(e){let{url:n,requestOptions:r,autoInit:i=!0,protocolCallbacks:a}=e,o=(0,t.toValue)(n);if(!o)throw Error(`[useChatBootstrap] url is required`);let s=(0,t.ref)(V9.IDLE),l=(0,t.ref)(null),u=(0,t.ref)(!1),d=new Map,f=new O9({onStart:()=>{a?.onStart?.()},onMessage:e=>{a?.onMessage?.(e)},onDone:()=>{a?.onDone?.()},onError:e=>{a?.onError?.(e)}}),p=R9({requestData:{urlPrefix:o,headers:r?.headers,data:r?.data},protocol:f});f.injectMessageModule(p.message);let m=(0,t.computed)(()=>s.value===V9.LOADING_AGENT),h=(0,t.computed)(()=>s.value===V9.READY),g=(0,t.computed)(()=>p.agent.info.value??null),_=(0,t.computed)(()=>g.value?.agentName??``),v=(0,t.computed)(()=>p.session.current.value??null),y=(0,t.computed)(()=>p.session.list.value??[]),b=async()=>{if(!u.value&&!m.value){l.value=null;try{s.value=V9.LOADING_AGENT,await Promise.all([p.agent.getAgentInfo(),p.session.getSessions()]),s.value=V9.READY,u.value=!0}catch(e){throw console.error(`[useChatBootstrap] Initialization failed:`,e),l.value=e,s.value=V9.ERROR,e}}},x=async()=>{s.value=V9.IDLE,l.value=null,u.value=!1,await b()},S=async e=>{s.value=V9.IDLE,l.value=null,u.value=!1;let t=p.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await b()};return(0,t.watch)(()=>(0,t.toValue)(n),(e,t)=>{e&&e!==t&&t&&S(e)}),i&&Promise.resolve().then(()=>{b()}),{chatHelper:p,protocol:f,phase:s,isInitializing:m,isReady:h,error:l,agentInfo:g,agentName:_,currentSession:v,sessionList:y,initialize:b,retry:x,updateConfig:S,registerExtension:(e,t)=>{d.set(e,t)},getExtension:e=>d.get(e)}}function n2t(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function r2t(e){let{componentManager:n,emit:r,debug:i=!1}=e,a=[],o=()=>{for(let[e,t]of Object.entries(z0t)){if(t===null)continue;let o=n.on(e,n=>{let a=B0t(e,n);i&&console.debug(`[useEventBridge] ${e} -> ${t}`,a),r(t,...a)});a.push(o)}},s=(e,t)=>{i&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,t),n.emit(e,t)},l=(e,...t)=>{i&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),r(e,...t)},u=()=>{a.forEach(e=>e()),a.length=0};return o(),(0,t.onUnmounted)(()=>{u()}),{forwardToManager:s,emitDirect:l,cleanup:u}}function i2t(e,n=!1){let r=window.innerHeight-48-40,i=window.innerWidth-48-16,a=(0,t.ref)(i),o=(0,t.ref)(r),s=(0,t.ref)(0),l=(0,t.ref)(n),u=(0,t.ref)(!1),d=(0,t.ref)(!1),f=0,p=e=>{e?a.value=window.innerWidth-12:a.value=i},m=(e,t)=>{o.value=t,s.value=t-r},h=()=>{(0,t.nextTick)(()=>{o.value=window.innerHeight-48-40+s.value,l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-48-16})};return(0,t.onMounted)(()=>{window.addEventListener(`resize`,h),h()}),(0,t.onUnmounted)(()=>{window.removeEventListener(`resize`,h)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:a,nimbusTop:o,isMinimize:l,isHovering:u,isDragging:d,handleNimbusDragging:m,handleNimbusMinimize:p,handleClick:()=>{if(d.value){d.value=!1;return}e(`click`)},handleMinimize:()=>{l.value=!l.value,e(`minimize`,l.value),l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-60},handleDragging:(e,t)=>{a.value=e,o.value=t},handleMouseEnter:()=>{u.value=!0},handleMouseLeave:()=>{u.value=!1},handleMouseDown:()=>{f=Date.now(),d.value=!1},handleMouseUp:()=>{Date.now()-f>200&&(d.value=!0)}}}c9();function a2t(e={}){let n=(0,t.ref)([]),r=(t,r,i={})=>{try{let a=typeof t==`string`?document.querySelector(t):t;if(!a)return console.warn(`Tooltip target not found: ${t}`),null;let o=s9(a,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return n.value.push(o),o}catch(e){return console.error(`Failed to create tooltip:`,e),null}},i=(e,t,n={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=r(e,t,n);i&&a.push(i)}),a},a=e=>{let t=[];return e.forEach(({element:e,content:n,options:i})=>{let a=r(e,n,i);a&&t.push(a)}),t},o=()=>{n.value.forEach(e=>{e.destroy()}),n.value=[]};return(0,t.onBeforeUnmount)(()=>{o()}),{instances:n,createTooltip:r,createTooltipsForSelector:i,createMultipleTooltips:a,destroyAll:o,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}let o2t={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:m9(`输入 "/" 唤出 Prompt
3048
+ `),ye();return}if(e.id===`rebuild`){await S(t);return}if(e.id===`delete`){await x(t);return}if(e.id===`share`){a(`request-share`);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await m?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},b=async(e,t,n,r)=>{if(!m){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let i=m.session.current?.value?.sessionCode;if(!i){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let o=c1t(j?.messages.value||[],t[0]);if(o===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let s=e.id===`like`?5:0;try{await m.session.postSessionFeedback({sessionCode:i,sessionContentIds:[o],rate:s,labels:n,comment:r}),a(`feedback`,e,t[0],n,r)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),a(`error`,e)}},x=async e=>{if(!j||!m){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=j.messages.value,n=p9(t,e[0]);if(!n){console.error(`[ChatBot] No user message found before AI messages`);return}let r=[n,...e];await m.message.deleteMessages(r)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),a(`error`,e)}},S=async e=>{if(!j||!m){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let t=m.session.current?.value?.sessionCode;if(!t){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await j.regenerateFromAIMessages(e,t),oe()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),a(`error`,e)}},C=async(e,t)=>{if(e.id===`delete`){await D(t);return}if(e.id===`cite`){P.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),ye();return}console.log(`handleUserAction`,e,t)},w=async(e,t,n)=>{if(!m){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let r=m.session.current?.value?.sessionCode;if(!r){console.error(`[ChatBot] Cannot edit message: no active session`);return}let i=e.id;if(i===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,i,r,t),await m.agent.resendMessage(String(i),r,t),oe()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),a(`error`,e)}},T=async(e,t)=>{if(!j||!m){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let n=m.session.current?.value?.sessionCode;if(!n){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let r=e.id;if(r===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let i=E(e);if(!i){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let a=me(i,t),o=String(t.input??``);await j.resendMessageWithProperty(String(r),n,o,a),oe()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),a(`error`,e)}},E=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?H.value.find(e=>e.id===t.command)??null:null},D=async e=>{if(!j||!m){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=j.messages.value,n=t.findIndex(t=>t===e);if(n===-1){console.error(`[ChatBot] User message not found in messages list`);return}let r=[];for(let e=n+1;e<t.length;e++){let n=t[e];if(n.role===g.User)break;r.push(n)}let i=[e,...r];await m.message.deleteMessages(i)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),a(`error`,e)}},O=async()=>{((i.chatHelper||m)?.agent)?.stopChat?.(m?.session.current?.value?.sessionCode??``)},k=!i.chatHelper,A=m?new z9(m.session,m.message,null,{enableChatSession:!0,autoSwitchToInitialSession:!!i.sessionCode,loadRecentSessionOnMount:i.autoLoad,initialSessionCode:i.sessionCode}):null,j=m?new F0t(m.agent,m.message,m.session,null,{openingRemark:i.helloText,predefinedQuestions:i.prompts,placeholder:i.placeholder}):null,M=new B9(null,i.shortcuts||[]),N=(0,t.shallowRef)([[]]),P=(0,t.ref)(``),F=(0,t.computed)(()=>j?.messages.value??[]),I=(0,t.computed)(()=>j?.isMessagesLoading.value??!1),L=(0,t.computed)(()=>j?.isGenerating.value??!1),R=(0,t.computed)(()=>A?.currentSession.value??null),ee=(0,t.computed)(()=>k&&!d.value?!1:!I.value&&F.value.length===0),z=(0,t.computed)(()=>m?.agent.info.value?.conversationSettings?.openingRemark||``),B=(0,t.computed)(()=>i.resources?.length?i.resources:u1t(m?.agent.info.value?.resources)),V=(0,t.computed)(()=>i.prompts?.length?i.prompts:m?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),te=(0,t.computed)(()=>({height:typeof i.height==`number`?`${i.height}px`:i.height,maxWidth:typeof i.maxWidth==`number`?`${i.maxWidth}px`:i.maxWidth})),ne=(0,t.computed)(()=>{let e=M.shortcuts.value;return i.shortcutLimit&&e.length>i.shortcutLimit?e.slice(0,i.shortcutLimit):e}),re=()=>{u.value=[],a(`cancel-share`)},ie=()=>{a(`confirm-share`,u.value)},ae=e=>{e?u.value=F.value:u.value=[]},H=M.effectiveShortcuts;(0,t.watch)(()=>i.shortcuts,e=>{M.setShortcuts(e||[])},{immediate:!0}),(0,t.watch)(()=>m?.agent.info.value?.conversationSettings?.commands,e=>{e&&M.setAgentShortcuts(e)},{immediate:!0});let oe=async()=>{await(0,t.nextTick)(),o.value&&(o.value.scrollTop=o.value.scrollHeight)},se=async(e,t={})=>{if(!j||!m)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let n=m.session.current?.value?.sessionCode;if(!n)throw Error(`[ChatBot] Cannot send message: no active session`);N.value=[[]],P.value=``,a(`send-message`,typeof e==`string`?e:``),await j.sendMessage(e,n,t)},ce=async e=>{let t=m?.session.current?.value?.sessionCode;if(!t)throw Error(`[ChatBot] Cannot upload: no active session`);let n=await m.session.uploadFile(t,e);if(!n?.download_url)throw Error(`[ChatBot] Upload failed: no download URL returned`);return n},le=async(e,t)=>{try{await se(e,P.value?{property:{extra:{cite:P.value}}}:{})}catch(e){console.error(`Failed to send message:`,e),a(`error`,e)}},ue=async()=>{ge()},de=(e,t)=>{fe(e,t),a(`shortcut-click`,{shortcut:e,source:`main`})},fe=(e,t)=>{let n=e,r=n.components?.find(e=>e.fillBack)?.key||`input`;l.value={...n,formModel:{...n.formModel,[r]:t||``}}},pe=()=>{l.value=null},me=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},he=async e=>{if(!l.value){console.error(`[ChatBot] No selected shortcut`);return}let t=me(l.value,e),n=l.value.name,r=l.value;pe();try{await se(n,{property:t})}catch(e){l.value=r,console.error(`[ChatBot] Failed to submit shortcut:`,e),a(`error`,e)}},ge=()=>{if(!j){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}j.stopGeneration(),a(`stop`)},_e=async e=>{if(!A){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await A.switchSession(e),a(`session-switched`,A.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),a(`error`,e)}},ve=e=>{P.value=e},ye=()=>{s.value?.focus?.()};return(0,t.onMounted)(async()=>{if(!(!m||f.value))try{if(k){if(await m.agent.getAgentInfo(),await m.session.getSessions(),i.sessionCode)await m.session.chooseSession(i.sessionCode);else if(m.session.list.value.length>0){let e=m.session.list.value[0];await m.session.chooseSession(e.sessionCode)}d.value=!0}else d.value=!0;a(`agent-info-loaded`,m)}catch(e){console.error(`Failed to initialize ChatBot:`,e),f.value=e,a(`error`,e)}}),(0,t.onBeforeUnmount)(()=>{k&&m&&m.agent.stopChat(m.session.current?.value?.sessionCode??``)}),n({sendMessage:e=>le(e,[[]]),stopGeneration:ge,switchSession:_e,messages:F,currentSession:R,isGenerating:L,getChatHelper:()=>m,setCiteText:ve,focusInput:ye,selectShortcut:(e,t)=>{fe(e,t)}}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:(0,t.normalizeClass)([`ai-chatbot`,i.extCls,{"welcome-state":ee.value}]),style:(0,t.normalizeStyle)(te.value)},[(0,t.createCommentVNode)(` 初始化错误提示 `),f.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,q0t,[(0,t.createElementVNode)(`span`,null,(0,t.toDisplayString)(f.value.message),1)])):k&&!d.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 独立模式:初始化中(getAgentInfo → getSessions → chooseSession)统一展示 Loading `),(0,t.createElementVNode)(`div`,J0t,[(0,t.createVNode)((0,t.unref)(qs),{mode:`spin`,size:`small`,theme:`primary`})])],2112)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[(0,t.createCommentVNode)(` 内容区:欢迎状态 `),ee.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Y0t,[(0,t.createElementVNode)(`div`,X0t,[n[3]||=(0,t.createElementVNode)(`h2`,{class:`welcome-title`},`你好,我是小鲸`,-1),z.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Z0t,[(0,t.createVNode)((0,t.unref)(s7),{content:z.value},null,8,[`content`])])):(0,t.createCommentVNode)(`v-if`,!0)])])):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 内容区:消息列表 `),(0,t.createElementVNode)(`div`,{ref_key:`messagesContainerRef`,ref:o,class:`chatbot-messages`},[I.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Q0t,[(0,t.createVNode)((0,t.unref)(qs),{mode:`spin`,size:`small`,theme:`primary`})])):((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(o1t),{key:1,"selected-messages":u.value,"onUpdate:selectedMessages":n[0]||=e=>u.value=e,"enable-selection":i.enableSelection,"message-status":h.value,"message-tools-status":v.value,messages:F.value,"on-agent-action":y,"on-agent-feedback":b,"on-user-action":C,"on-user-input-confirm":w,"on-user-shortcut-confirm":T,onStopStreaming:O},null,8,[`selected-messages`,`enable-selection`,`message-status`,`message-tools-status`,`messages`]))],512)],2112)),(0,t.createCommentVNode)(` 统一底部区域 `),!ee.value&&i.enableSelection?((0,t.openBlock)(),(0,t.createBlock)(K0t,{key:2,"is-all-selected":u.value.length===F.value.length,loading:i.shareLoading,"selected-count":u.value.length,onCancel:re,onConfirm:ie,onToggleAll:ae},null,8,[`is-all-selected`,`loading`,`selected-count`])):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,$0t,[l.value?.components?.length?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Bxe),(0,t.mergeProps)({key:0},l.value,{onClose:pe,onSubmit:he}),null,16)):(0,t.renderSlot)(e.$slots,`input`,{key:1},()=>[(0,t.createVNode)((0,t.unref)(qQt),{ref_key:`chatInputRef`,ref:s,modelValue:N.value,"onUpdate:modelValue":n[1]||=e=>N.value=e,cite:P.value,"onUpdate:cite":n[2]||=e=>P.value=e,"message-status":h.value,"on-send-message":le,"on-stop-sending":ue,"on-upload":ce,placeholder:i.placeholder,prompts:V.value,resources:B.value,"shortcut-id":l.value?.id,shortcuts:ne.value,onSelectShortcut:de},null,8,[`modelValue`,`cite`,`message-status`,`placeholder`,`prompts`,`resources`,`shortcut-id`,`shortcuts`])])]))],64))],6))}});let V9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function t2t(e){let{url:n,requestOptions:r,autoInit:i=!0,protocolCallbacks:a}=e,o=(0,t.toValue)(n);if(!o)throw Error(`[useChatBootstrap] url is required`);let s=(0,t.ref)(V9.IDLE),l=(0,t.ref)(null),u=(0,t.ref)(!1),d=new Map,f=new O9({onStart:()=>{a?.onStart?.()},onMessage:e=>{a?.onMessage?.(e)},onDone:()=>{a?.onDone?.()},onError:e=>{a?.onError?.(e)}}),p=R9({requestData:{urlPrefix:o,headers:r?.headers,data:r?.data},protocol:f});f.injectMessageModule(p.message);let m=(0,t.computed)(()=>s.value===V9.LOADING_AGENT),h=(0,t.computed)(()=>s.value===V9.READY),g=(0,t.computed)(()=>p.agent.info.value??null),_=(0,t.computed)(()=>g.value?.agentName??``),v=(0,t.computed)(()=>p.session.current.value??null),y=(0,t.computed)(()=>p.session.list.value??[]),b=async()=>{if(!u.value&&!m.value){l.value=null;try{s.value=V9.LOADING_AGENT,await Promise.all([p.agent.getAgentInfo(),p.session.getSessions()]),s.value=V9.READY,u.value=!0}catch(e){throw console.error(`[useChatBootstrap] Initialization failed:`,e),l.value=e,s.value=V9.ERROR,e}}},x=async()=>{s.value=V9.IDLE,l.value=null,u.value=!1,await b()},S=async e=>{s.value=V9.IDLE,l.value=null,u.value=!1;let t=p.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await b()};return(0,t.watch)(()=>(0,t.toValue)(n),(e,t)=>{e&&e!==t&&t&&S(e)}),i&&Promise.resolve().then(()=>{b()}),{chatHelper:p,protocol:f,phase:s,isInitializing:m,isReady:h,error:l,agentInfo:g,agentName:_,currentSession:v,sessionList:y,initialize:b,retry:x,updateConfig:S,registerExtension:(e,t)=>{d.set(e,t)},getExtension:e=>d.get(e)}}function n2t(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function r2t(e){let{componentManager:n,emit:r,debug:i=!1}=e,a=[],o=()=>{for(let[e,t]of Object.entries(z0t)){if(t===null)continue;let o=n.on(e,n=>{let a=B0t(e,n);i&&console.debug(`[useEventBridge] ${e} -> ${t}`,a),r(t,...a)});a.push(o)}},s=(e,t)=>{i&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,t),n.emit(e,t)},l=(e,...t)=>{i&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),r(e,...t)},u=()=>{a.forEach(e=>e()),a.length=0};return o(),(0,t.onUnmounted)(()=>{u()}),{forwardToManager:s,emitDirect:l,cleanup:u}}function i2t(e,n=!1){let r=window.innerHeight-48-40,i=window.innerWidth-48-16,a=(0,t.ref)(i),o=(0,t.ref)(r),s=(0,t.ref)(0),l=(0,t.ref)(n),u=(0,t.ref)(!1),d=(0,t.ref)(!1),f=0,p=e=>{e?a.value=window.innerWidth-12:a.value=i},m=(e,t)=>{o.value=t,s.value=t-r},h=()=>{(0,t.nextTick)(()=>{o.value=window.innerHeight-48-40+s.value,l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-48-16})};return(0,t.onMounted)(()=>{window.addEventListener(`resize`,h),h()}),(0,t.onUnmounted)(()=>{window.removeEventListener(`resize`,h)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:a,nimbusTop:o,isMinimize:l,isHovering:u,isDragging:d,handleNimbusDragging:m,handleNimbusMinimize:p,handleClick:()=>{if(d.value){d.value=!1;return}e(`click`)},handleMinimize:()=>{l.value=!l.value,e(`minimize`,l.value),l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-60},handleDragging:(e,t)=>{a.value=e,o.value=t},handleMouseEnter:()=>{u.value=!0},handleMouseLeave:()=>{u.value=!1},handleMouseDown:()=>{f=Date.now(),d.value=!1},handleMouseUp:()=>{Date.now()-f>200&&(d.value=!0)}}}c9();function a2t(e={}){let n=(0,t.ref)([]),r=(t,r,i={})=>{try{let a=typeof t==`string`?document.querySelector(t):t;if(!a)return console.warn(`Tooltip target not found: ${t}`),null;let o=s9(a,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return n.value.push(o),o}catch(e){return console.error(`Failed to create tooltip:`,e),null}},i=(e,t,n={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=r(e,t,n);i&&a.push(i)}),a},a=e=>{let t=[];return e.forEach(({element:e,content:n,options:i})=>{let a=r(e,n,i);a&&t.push(a)}),t},o=()=>{n.value.forEach(e=>{e.destroy()}),n.value=[]};return(0,t.onBeforeUnmount)(()=>{o()}),{instances:n,createTooltip:r,createTooltipsForSelector:i,createMultipleTooltips:a,destroyAll:o,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}let o2t={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:m9(`输入 "/" 唤出 Prompt
3049
3049
  通过 Shift + Enter 进行换行输入`),helloText:m9(`你好,我是小鲸`),disabledInput:!1,showHistoryIcon:!0,showNewChatIcon:!0,showCompressionIcon:!0,showMoreIcon:!0,initialSessionCode:``,autoSwitchToInitialSession:!1,loadRecentSessionOnMount:!0,prompts:()=>[],dropdownMenuConfig:()=>({showRename:!0,showAutoGenerate:!0,showShare:!0}),defaultChatInputPosition:void 0};var s2t=class extends O9{eventEmitter;constructor(e={}){super({onStart:e.onStart,onMessage:e.onMessage,onDone:e.onDone,onError:e.onError}),this.eventEmitter=e.eventEmitter}handleRunErrorEvent(e){super.handleRunErrorEvent(e),this.eventEmitter?.emit(`run-error`,{event:e})}handleTextMessageChunkEvent(e){super.handleTextMessageChunkEvent(e),this.eventEmitter?.emit(`text-chunk`,{event:e})}handleThinkingEndEvent(e){super.handleThinkingEndEvent(e),this.eventEmitter?.emit(`thinking-end`,{event:e})}handleThinkingStartEvent(e){super.handleThinkingStartEvent(e),this.eventEmitter?.emit(`thinking-start`,{event:e})}handleToolCallEndEvent(e){super.handleToolCallEndEvent(e),this.eventEmitter?.emit(`tool-call-end`,{event:e})}handleToolCallStartEvent(e){super.handleToolCallStartEvent(e),this.eventEmitter?.emit(`tool-call-start`,{event:e})}};function c2t(e={}){let{eventEmitter:t,onStart:n,onMessage:r,onDone:i,onError:a,onTextChunk:o}=e;return new O9({onStart:()=>{t?.emit(`receive-start`,{}),n?.()},onMessage:e=>{t?.emit(`receive-message`,{event:e}),e.type===`TextMessageChunk`&&o&&o(e),r?.(e)},onDone:()=>{t?.emit(`receive-end`,{}),i?.()},onError:e=>{t?.emit(`receive-error`,{error:e}),a?.(e)}})}function l2t(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function H9(e,t,n,r=1){let[i,a]=typeof r==`number`?[r,r]:r;return[Math.round(t/i/e[0])*e[0],Math.round(n/a/e[1])*e[1]]}function U9(e,t,n){return e-t-n}function W9(e,t,n){return e-t-n}function G9(e,t,n){return t!==null&&e<t?t:n!==null&&n<e?n:e}function u2t(e,t,n){let r=e,i=[`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`].find(e=>l2t(r[e]));if(!l2t(r[i]))return!1;do{if(r[i](t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function d2t(e){let t=window.getComputedStyle(e);return[parseFloat(t.getPropertyValue(`width`),10),parseFloat(t.getPropertyValue(`height`),10)]}function K9(e,t,n){e&&(e.attachEvent?e.attachEvent(`on`+t,n):e.addEventListener?e.addEventListener(t,n,!0):e[`on`+t]=n)}function q9(e,t,n){e&&(e.detachEvent?e.detachEvent(`on`+t,n):e.removeEventListener?e.removeEventListener(t,n,!0):e[`on`+t]=null)}var f2t=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},J9={mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`},touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`}},p2t={userSelect:`none`,MozUserSelect:`none`,WebkitUserSelect:`none`,MsUserSelect:`none`},m2t={userSelect:`auto`,MozUserSelect:`auto`,WebkitUserSelect:`auto`,MsUserSelect:`auto`},Y9=J9.mouse,h2t={replace:!0,name:`vue-draggable-resizable`,props:{className:{type:String,default:`vdr`},classNameDraggable:{type:String,default:`draggable`},classNameResizable:{type:String,default:`resizable`},classNameDragging:{type:String,default:`dragging`},classNameResizing:{type:String,default:`resizing`},classNameActive:{type:String,default:`active`},classNameHandle:{type:String,default:`handle`},disableUserSelect:{type:Boolean,default:!0},enableNativeDrag:{type:Boolean,default:!1},preventDeactivation:{type:Boolean,default:!1},active:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},w:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},h:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},minWidth:{type:Number,default:0,validator:e=>e>=0},minHeight:{type:Number,default:0,validator:e=>e>=0},maxWidth:{type:Number,default:null,validator:e=>e>=0},maxHeight:{type:Number,default:null,validator:e=>e>=0},x:{type:Number,default:0},y:{type:Number,default:0},z:{type:[String,Number],default:`auto`,validator:e=>typeof e==`string`?e===`auto`:e>=0},handles:{type:Array,default:()=>[`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`],validator:e=>{let t=new Set([`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`]);return new Set(e.filter(e=>t.has(e))).size===e.length}},dragHandle:{type:String,default:null},dragCancel:{type:String,default:null},axis:{type:String,default:`both`,validator:e=>[`x`,`y`,`both`].includes(e)},grid:{type:Array,default:()=>[1,1]},parent:{type:Boolean,default:!1},scale:{type:[Number,Array],default:1,validator:e=>typeof e==`number`?e>0:e.length===2&&e[0]>0&&e[1]>0},onDragStart:{type:Function,default:()=>!0},onDrag:{type:Function,default:()=>!0},onResizeStart:{type:Function,default:()=>!0},onResize:{type:Function,default:()=>!0}},data:function(){return{left:this.x,top:this.y,right:null,bottom:null,width:null,height:null,widthTouched:!1,heightTouched:!1,aspectFactor:null,parentWidth:null,parentHeight:null,handle:null,enabled:this.active,resizing:!1,dragging:!1,dragEnable:!1,resizeEnable:!1,zIndex:this.z}},created:function(){this.maxWidth&&this.minWidth>this.maxWidth&&console.warn(`[Vdr warn]: Invalid prop: minWidth cannot be greater than maxWidth`),this.maxHeight&&this.minHeight>this.maxHeight&&console.warn(`[Vdr warn]: Invalid prop: minHeight cannot be greater than maxHeight`),this.resetBoundsAndMouseState()},mounted:function(){this.enableNativeDrag||(this.$el.ondragstart=()=>!1);let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t;let[n,r]=d2t(this.$el);this.aspectFactor=(this.w===`auto`?n:this.w)/(this.h===`auto`?r:this.h),this.width=this.w===`auto`?n:this.w,this.height=this.h===`auto`?r:this.h,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top,this.active&&this.$emit(`activated`),K9(document.documentElement,`mousedown`,this.deselect),K9(document.documentElement,`touchend touchcancel`,this.deselect),K9(window,`resize`,this.checkParentSize)},beforeUnmount:function(){q9(document.documentElement,`mousedown`,this.deselect),q9(document.documentElement,`touchstart`,this.handleUp),q9(document.documentElement,`mousemove`,this.move),q9(document.documentElement,`touchmove`,this.move),q9(document.documentElement,`mouseup`,this.handleUp),q9(document.documentElement,`touchend touchcancel`,this.deselect),q9(window,`resize`,this.checkParentSize)},methods:{resetBoundsAndMouseState(){this.mouseClickPosition={mouseX:0,mouseY:0,x:0,y:0,w:0,h:0},this.bounds={minLeft:null,maxLeft:null,minRight:null,maxRight:null,minTop:null,maxTop:null,minBottom:null,maxBottom:null}},checkParentSize(){if(this.parent){let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top}},getParentSize(){if(this.parent){let e=window.getComputedStyle(this.$el.parentNode,null);return[parseInt(e.getPropertyValue(`width`),10),parseInt(e.getPropertyValue(`height`),10)]}return[null,null]},elementTouchDown(e){Y9=J9.touch,this.elementDown(e)},elementMouseDown(e){Y9=J9.mouse,this.elementDown(e)},elementDown(e){if(e instanceof MouseEvent&&e.button!==0)return;let t=e.target||e.srcElement;if(this.$el.contains(t)){if(this.onDragStart(e)===!1)return;if(this.dragHandle&&!u2t(t,this.dragHandle,this.$el)||this.dragCancel&&u2t(t,this.dragCancel,this.$el)){this.dragging=!1;return}this.enabled||(this.enabled=!0,this.$emit(`activated`),this.$emit(`update:active`,!0)),this.draggable&&(this.dragEnable=!0),this.mouseClickPosition.mouseX=e.touches?e.touches[0].pageX:e.pageX,this.mouseClickPosition.mouseY=e.touches?e.touches[0].pageY:e.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.parent&&(this.bounds=this.calcDragLimits()),K9(document.documentElement,Y9.move,this.move),K9(document.documentElement,Y9.stop,this.handleUp)}},calcDragLimits(){return{minLeft:this.left%this.grid[0],maxLeft:Math.floor((this.parentWidth-this.width-this.left)/this.grid[0])*this.grid[0]+this.left,minRight:this.right%this.grid[0],maxRight:Math.floor((this.parentWidth-this.width-this.right)/this.grid[0])*this.grid[0]+this.right,minTop:this.top%this.grid[1],maxTop:Math.floor((this.parentHeight-this.height-this.top)/this.grid[1])*this.grid[1]+this.top,minBottom:this.bottom%this.grid[1],maxBottom:Math.floor((this.parentHeight-this.height-this.bottom)/this.grid[1])*this.grid[1]+this.bottom}},deselect(e){let t=e.target||e.srcElement,n=RegExp(this.className+`-([trmbl]{2})`,``);!this.$el.contains(t)&&!n.test(t.className)&&(this.enabled&&!this.preventDeactivation&&(this.enabled=!1,this.$emit(`deactivated`),this.$emit(`update:active`,!1)),q9(document.documentElement,Y9.move,this.handleResize)),this.resetBoundsAndMouseState()},handleTouchDown(e,t){Y9=J9.touch,this.handleDown(e,t)},handleDown(e,t){t instanceof MouseEvent&&t.which!==1||this.onResizeStart(e,t)!==!1&&(t.stopPropagation&&t.stopPropagation(),this.lockAspectRatio&&!e.includes(`m`)?this.handle=`m`+e.substring(1):this.handle=e,this.resizeEnable=!0,this.mouseClickPosition.mouseX=t.touches?t.touches[0].pageX:t.pageX,this.mouseClickPosition.mouseY=t.touches?t.touches[0].pageY:t.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.bounds=this.calcResizeLimits(),K9(document.documentElement,Y9.move,this.handleResize),K9(document.documentElement,Y9.stop,this.handleUp))},calcResizeLimits(){let e=this.minW,t=this.minH,n=this.maxW,r=this.maxH,i=this.aspectFactor,[a,o]=this.grid,s=this.width,l=this.height,u=this.left,d=this.top,f=this.right,p=this.bottom;this.lockAspectRatio&&(e/t>i?t=e/i:e=i*t,n&&r?(n=Math.min(n,i*r),r=Math.min(r,n/i)):n?r=n/i:r&&(n=i*r)),n-=n%a,r-=r%o;let m={minLeft:null,maxLeft:null,minTop:null,maxTop:null,minRight:null,maxRight:null,minBottom:null,maxBottom:null};return this.parent?(m.minLeft=u%a,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=d%o,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=f%a,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=p%o,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=Math.max(m.minLeft,this.parentWidth-f-n),m.minRight=Math.max(m.minRight,this.parentWidth-u-n)),r&&(m.minTop=Math.max(m.minTop,this.parentHeight-p-r),m.minBottom=Math.max(m.minBottom,this.parentHeight-d-r)),this.lockAspectRatio&&(m.minLeft=Math.max(m.minLeft,u-d*i),m.minTop=Math.max(m.minTop,d-u/i),m.minRight=Math.max(m.minRight,f-p*i),m.minBottom=Math.max(m.minBottom,p-f/i))):(m.minLeft=null,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=null,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=null,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=null,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=-(f+n),m.minRight=-(u+n)),r&&(m.minTop=-(p+r),m.minBottom=-(d+r)),this.lockAspectRatio&&n&&r&&(m.minLeft=Math.min(m.minLeft,-(f+n)),m.minTop=Math.min(m.minTop,-(r+p)),m.minRight=Math.min(m.minRight,-u-n),m.minBottom=Math.min(m.minBottom,-d-r))),m},move(e){this.resizing?this.handleResize(e):this.dragEnable&&this.handleDrag(e)},handleDrag(e){let t=this.axis,n=this.grid,r=this.bounds,i=this.mouseClickPosition,[a,o]=H9(n,t&&t!==`y`?i.mouseX-(e.touches?e.touches[0].pageX:e.pageX):0,t&&t!==`x`?i.mouseY-(e.touches?e.touches[0].pageY:e.pageY):0,this.scale),s=G9(i.left-a,r.minLeft,r.maxLeft),l=G9(i.top-o,r.minTop,r.maxTop);if(this.onDrag(s,l)===!1)return;let u=G9(i.right+a,r.minRight,r.maxRight),d=G9(i.bottom+o,r.minBottom,r.maxBottom);this.left=s,this.top=l,this.right=u,this.bottom=d,this.$emit(`dragging`,this.left,this.top),this.dragging=!0},moveHorizontally(e){let[t,n]=H9(this.grid,e,this.top,1),r=G9(t,this.bounds.minLeft,this.bounds.maxLeft);this.left=r,this.right=this.parentWidth-this.width-r},moveVertically(e){let[t,n]=H9(this.grid,this.left,e,1),r=G9(n,this.bounds.minTop,this.bounds.maxTop);this.top=r,this.bottom=this.parentHeight-this.height-r},handleResize(e){let t=this.left,n=this.top,r=this.right,i=this.bottom,a=this.mouseClickPosition,o=this.aspectFactor,s=a.mouseX-(e.touches?e.touches[0].pageX:e.pageX),l=a.mouseY-(e.touches?e.touches[0].pageY:e.pageY);!this.widthTouched&&s&&(this.widthTouched=!0),!this.heightTouched&&l&&(this.heightTouched=!0);let[u,d]=H9(this.grid,s,l,this.scale);this.handle.includes(`b`)?(i=G9(a.bottom+d,this.bounds.minBottom,this.bounds.maxBottom),this.lockAspectRatio&&this.resizingOnY&&(r=this.right-(this.bottom-i)*o)):this.handle.includes(`t`)&&(n=G9(a.top-d,this.bounds.minTop,this.bounds.maxTop),this.lockAspectRatio&&this.resizingOnY&&(t=this.left-(this.top-n)*o)),this.handle.includes(`r`)?(r=G9(a.right+u,this.bounds.minRight,this.bounds.maxRight),this.lockAspectRatio&&this.resizingOnX&&(i=this.bottom-(this.right-r)/o)):this.handle.includes(`l`)&&(t=G9(a.left-u,this.bounds.minLeft,this.bounds.maxLeft),this.lockAspectRatio&&this.resizingOnX&&(n=this.top-(this.left-t)/o));let f=U9(this.parentWidth,t,r),p=W9(this.parentHeight,n,i);this.onResize(this.handle,t,n,f,p)!==!1&&(this.left=t,this.top=n,this.right=r,this.bottom=i,this.width=f,this.height=p,this.$emit(`resizing`,this.left,this.top,this.width,this.height),this.resizing=!0)},changeWidth(e){let[t,n]=H9(this.grid,e,0,1),r=G9(this.parentWidth-t-this.left,this.bounds.minRight,this.bounds.maxRight),i=this.bottom;this.lockAspectRatio&&(i=this.bottom-(this.right-r)/this.aspectFactor);let a=U9(this.parentWidth,this.left,r),o=W9(this.parentHeight,this.top,i);this.right=r,this.bottom=i,this.width=a,this.height=o},changeHeight(e){let[t,n]=H9(this.grid,0,e,1),r=G9(this.parentHeight-n-this.top,this.bounds.minBottom,this.bounds.maxBottom),i=this.right;this.lockAspectRatio&&(i=this.right-(this.bottom-r)*this.aspectFactor);let a=U9(this.parentWidth,this.left,i),o=W9(this.parentHeight,this.top,r);this.right=i,this.bottom=r,this.width=a,this.height=o},handleUp(e){this.handle=null,this.resetBoundsAndMouseState(),this.dragEnable=!1,this.resizeEnable=!1,this.resizing&&(this.resizing=!1,this.$emit(`resizeStop`,this.left,this.top,this.width,this.height)),this.dragging&&(this.dragging=!1,this.$emit(`dragStop`,this.left,this.top)),q9(document.documentElement,Y9.move,this.handleResize)}},computed:{style(){return{transform:`translate(${this.left}px, ${this.top}px)`,width:this.computedWidth,height:this.computedHeight,zIndex:this.zIndex,...this.dragging&&this.disableUserSelect?p2t:m2t}},actualHandles(){return this.resizable?this.handles:[]},computedWidth(){return this.w===`auto`&&!this.widthTouched?`auto`:this.width+`px`},computedHeight(){return this.h===`auto`&&!this.heightTouched?`auto`:this.height+`px`},minW(){return this.minWidth},minH(){return this.minHeight},maxW(){return this.maxWidth},maxH(){return this.maxHeight},resizingOnX(){return!!this.handle&&(this.handle.includes(`l`)||this.handle.includes(`r`))},resizingOnY(){return!!this.handle&&(this.handle.includes(`t`)||this.handle.includes(`b`))},isCornerHandle(){return!!this.handle&&[`tl`,`tr`,`br`,`bl`].includes(this.handle)}},watch:{active(e){this.enabled=e,e?this.$emit(`activated`):this.$emit(`deactivated`)},z(e){(e>=0||e===`auto`)&&(this.zIndex=e)},x(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveHorizontally(e))},y(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveVertically(e))},lockAspectRatio(e){e?this.aspectFactor=this.width/this.height:this.aspectFactor=void 0},w(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeWidth(e))},h(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeHeight(e))}}},g2t=[`onMousedown`,`onTouchstart`];function _2t(e,n,r,i,a,o){return(0,t.openBlock)(),(0,t.createElementBlock)(`div`,{style:(0,t.normalizeStyle)(o.style),class:(0,t.normalizeClass)([{[r.classNameActive]:e.enabled,[r.classNameDragging]:e.dragging,[r.classNameResizing]:e.resizing,[r.classNameDraggable]:r.draggable,[r.classNameResizable]:r.resizable},r.className]),onMousedown:n[0]||=(...e)=>o.elementMouseDown&&o.elementMouseDown(...e),onTouchstart:n[1]||=(...e)=>o.elementTouchDown&&o.elementTouchDown(...e)},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(o.actualHandles,n=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:n,class:(0,t.normalizeClass)([r.classNameHandle,r.classNameHandle+`-`+n]),style:(0,t.normalizeStyle)({display:e.enabled?`block`:`none`}),onMousedown:(0,t.withModifiers)(e=>o.handleDown(n,e),[`stop`,`prevent`]),onTouchstart:(0,t.withModifiers)(e=>o.handleTouchDown(n,e),[`stop`,`prevent`])},[(0,t.renderSlot)(e.$slots,n)],46,g2t))),128)),(0,t.renderSlot)(e.$slots,`default`)],38)}var X9=f2t(h2t,[[`render`,_2t]]);function Z9(e){Z9.installed||(Z9.installed=!0,e.component(`VueDraggableResizable`,X9))}var v2t={install:Z9},Q9=null;typeof window<`u`?Q9=window.Vue:typeof global<`u`&&(Q9=global.Vue),Q9&&Q9.use(v2t);function y2t(e={},n){let r=e.initWidth||400,i=e.minWidth||400,a=e.minHeight||400,o=e.maxWidthPercent||40,s=e.compressedHeight||800,l=e.compressedPadding===void 0?0:e.compressedPadding,u=(0,t.ref)(e.defaultLeft===void 0?window.innerWidth-r:e.defaultLeft),d=(0,t.ref)(e.defaultTop===void 0?0:e.defaultTop),f=(0,t.ref)(e.defaultHeight===void 0?window.innerHeight-(e.defaultTop===void 0?0:e.defaultTop):e.defaultHeight),p=(0,t.ref)(r),m=(0,t.ref)(d.value),h=(0,t.ref)(u.value),g=(0,t.ref)(p.value),_=(0,t.ref)(f.value),v=(0,t.ref)(Math.max(window.innerWidth*(o/100),g.value)),y=(0,t.ref)(!1),b=(0,t.ref)(0),x=()=>({x:h.value,y:m.value,width:g.value,height:_.value}),S=(e,t)=>{h.value=e,m.value=t,b.value=e-(window.innerWidth-g.value),n?.onDragging?.(x())},C=(e,t,r,i)=>{h.value=e,m.value=t,g.value=Math.min(r,v.value),_.value=i,n?.onResizing?.(x())},w=(e,t)=>{h.value=e,m.value=t,b.value=e-(window.innerWidth-g.value),n?.onDragStop?.(x())},T=(e,t,r,i)=>{h.value=e,m.value=t,g.value=Math.min(r,v.value),_.value=i,n?.onResizeStop?.(x())},E=()=>{v.value=Math.max(window.innerWidth*(o/100),g.value),(0,t.nextTick)(()=>{if(y.value)h.value=window.innerWidth-g.value-l,m.value=window.innerHeight-s-l;else{let e=window.innerWidth-g.value-b.value;h.value=Math.max(0,e),setTimeout(()=>{_.value=window.innerHeight-m.value},0)}g.value>v.value&&(g.value=v.value)})},D=()=>{y.value?(m.value=d.value,(0,t.nextTick)(()=>{_.value=f.value,h.value=u.value,g.value=p.value})):(m.value=window.innerHeight-s-l,h.value=u.value-l,g.value=r,_.value=s),y.value=!y.value},O=(e,t)=>{h.value=e,m.value=t,b.value=e-(window.innerWidth-g.value)},k=(e,t)=>{g.value=Math.max(i,Math.min(e,v.value)),_.value=Math.max(a,t)};return(0,t.onMounted)(()=>{window.addEventListener(`resize`,E)}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,E)}),{minWidth:i,minHeight:a,maxWidth:v,top:m,left:h,width:g,height:_,isCompressed:y,handleDragging:S,handleResizing:C,handleDragStop:w,handleResizeStop:T,toggleCompression:D,updatePosition:O,updateSize:k,updatePositionAndSize:(e,t,n,r)=>{O(e,t),k(n,r)}}}var b2t={class:`draggable-container-content`},x2t=f9((0,t.defineComponent)({__name:`draggable-container`,props:{visible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},defaultWidth:{default:400},defaultHeight:{default:void 0},defaultX:{default:void 0},defaultY:{default:0},minWidth:{default:400},minHeight:{default:400},maxWidth:{default:void 0},maxWidthPercent:{default:80},compressedHeight:{default:800},compressedPadding:{default:0},dragHandle:{default:`.drag-handle`},className:{default:``},teleportTo:{default:`body`}},emits:[`dragging`,`resizing`,`drag-stop`,`resize-stop`,`compression-change`],setup(e,{expose:n,emit:r}){let i=e,a=r,o=(0,t.ref)(!1),{minWidth:s,minHeight:l,maxWidth:u,top:d,left:f,width:p,height:m,isCompressed:h,handleDragging:g,handleResizing:_,handleDragStop:v,handleResizeStop:y,toggleCompression:b,updatePosition:x,updateSize:S,updatePositionAndSize:C}=y2t({initWidth:i.defaultWidth,minWidth:i.minWidth,minHeight:i.minHeight,maxWidthPercent:i.maxWidthPercent,compressedHeight:i.compressedHeight,defaultHeight:i.defaultHeight,defaultTop:i.defaultY,defaultLeft:i.defaultX,compressedPadding:i.compressedPadding},{onDragStop:e=>a(`drag-stop`,e),onResizeStop:e=>a(`resize-stop`,e),onDragging:e=>a(`dragging`,e),onResizing:e=>a(`resizing`,e)}),w=(0,t.computed)(()=>{let e=typeof i.maxWidth==`number`?`${i.maxWidth}px`:i.maxWidth??`${u.value}px`;return{"--draggable-max-width":e}}),T=(0,t.computed)(()=>({x:f.value,y:d.value,width:p.value,height:m.value})),E=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=`none`})},D=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=``})},O=(e,t)=>{o.value||(o.value=!0,E()),g(e,t)},k=(e,t,n,r)=>{o.value||(o.value=!0,E()),_(e,t,n,r)},A=(e,t)=>{v(e,t),o.value=!1,D()},j=(e,t,n,r)=>{y(e,t,n,r),o.value=!1,D()};return(0,t.watch)(h,e=>{a(`compression-change`,e)}),n({updatePosition:x,updateSize:S,updatePositionAndSize:C,toggleCompression:b,positionAndSize:T,isCompressed:h}),(e,n)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(X9),{ref:`draggableRef`,class:(0,t.normalizeClass)([`draggable-container-wrapper`,i.className]),style:(0,t.normalizeStyle)(w.value),active:i.visible,draggable:i.draggable,resizable:i.resizable,w:(0,t.unref)(p),h:(0,t.unref)(m),x:(0,t.unref)(f),y:(0,t.unref)(d),"min-width":(0,t.unref)(s),"min-height":(0,t.unref)(l),"max-width":(0,t.unref)(u),parent:!0,"prevent-deactivation":!0,"drag-handle":i.dragHandle,"class-name":`draggable-container-inner`,onDragging:O,onResizing:k,onDragStop:A,onResizeStop:j},{default:(0,t.withCtx)(()=>[(0,t.createElementVNode)(`div`,b2t,[(0,t.renderSlot)(e.$slots,`default`,{},void 0,!0)])]),_:3},8,[`class`,`style`,`active`,`draggable`,`resizable`,`w`,`h`,`x`,`y`,`min-width`,`min-height`,`max-width`,`drag-handle`])),[[t.vShow,i.visible]])}}),[[`__scopeId`,`data-v-6e2c6cb7`]]),S2t={class:`nimbus-bkai-wrapper`},C2t=[`width`,`height`,`src`],w2t=f9((0,t.defineComponent)({name:`NimbusButton`,__name:`nimbus`,props:{isPanelShow:{type:Boolean},isMinimize:{type:Boolean},size:{default:`normal`}},emits:[`click`,`minimize`,`update:isMinimize`],setup(e,{emit:n}){(0,t.useCssVars)(e=>({v05a8b16e:`${o.value.container}px`,v4e1cf4ca:`${o.value.wrapper}px`,v5ab0c513:`${o.value.mini.right}px`,v40c13a80:`${o.value.mini.size}px`,v0d35a9ef:`${o.value.mini.fontSize}px`}));let r=e,i=n,a={small:{container:40,wrapper:32,img:24,mini:{size:14,fontSize:10,right:-4}},normal:{container:48,wrapper:40,img:32,mini:{size:16,fontSize:12,right:-6}},large:{container:56,wrapper:48,img:40,mini:{size:18,fontSize:14,right:-6}}},o=(0,t.computed)(()=>a[r.size]),s=(0,t.ref)(null),l=(0,t.ref)(null),{nimbusLeft:u,nimbusTop:d,isMinimize:f,handleClick:p,handleMinimize:m,handleDragging:h,handleMouseEnter:g,handleMouseLeave:_,handleMouseDown:v,handleMouseUp:y}=i2t(i,r.isMinimize);(0,t.watch)(f,e=>{i(`update:isMinimize`,e)});let b=(0,t.computed)(()=>f.value?m9(`恢复默认大小`):m9(`最小化,将缩成锚点`)),{createTooltip:x,destroyAll:S}=a2t({theme:`ai-blueking`,delay:[0,0]}),C=()=>{(0,t.nextTick)(()=>{w()})},w=()=>{S(),s.value&&!f.value&&x(s.value,g1t(),{placement:`left`}),l.value&&x(l.value,b.value,{placement:`top`})};return(0,t.watch)(()=>f.value,()=>{(0,t.nextTick)(()=>{w()})}),(0,t.onMounted)(()=>{(0,t.nextTick)(()=>{w()}),window.addEventListener(`resize`,C)}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,C)}),(n,r)=>((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(X9),{active:!e.isPanelShow,axis:`y`,draggable:!0,h:o.value.container,parent:!0,"prevent-deactivation":!0,resizable:!1,w:o.value.container,x:(0,t.unref)(u),y:(0,t.unref)(d),onDragging:(0,t.unref)(h)},{default:(0,t.withCtx)(()=>[(0,t.createElementVNode)(`div`,{ref_key:`nimbusContainerRef`,ref:s,class:(0,t.normalizeClass)([`nimbus-container`,{"is-minimize":(0,t.unref)(f)}]),onClick:r[1]||=(...e)=>(0,t.unref)(p)&&(0,t.unref)(p)(...e),onMousedown:r[2]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onMouseenter:r[3]||=(...e)=>(0,t.unref)(g)&&(0,t.unref)(g)(...e),onMouseleave:r[4]||=(...e)=>(0,t.unref)(_)&&(0,t.unref)(_)(...e),onMouseup:r[5]||=(...e)=>(0,t.unref)(y)&&(0,t.unref)(y)(...e)},[(0,t.createElementVNode)(`div`,S2t,[(0,t.createElementVNode)(`img`,{width:o.value.img,height:o.value.img,src:(0,t.unref)(s1t),alt:`nimbus`},null,8,C2t)]),(0,t.createElementVNode)(`i`,{ref_key:`minimizeButtonRef`,ref:l,class:(0,t.normalizeClass)([`nimbus-mini bkai-icon`,(0,t.unref)(f)?`bkai-yinyong`:`bkai-minus-line`]),onClick:r[0]||=(0,t.withModifiers)((...e)=>(0,t.unref)(m)&&(0,t.unref)(m)(...e),[`stop`])},null,2)],34)]),_:1},8,[`active`,`h`,`w`,`x`,`y`,`onDragging`]))}}),[[`__scopeId`,`data-v-26b6f3ea`]]),T2t={class:`ai-blueking-panel`},$9=f9((0,t.defineComponent)({__name:`ai-blueking`,props:(0,t.mergeDefaults)({autoSwitchToInitialSession:{type:Boolean},defaultChatInputPosition:{},defaultHeight:{},defaultLeft:{},defaultMinimize:{type:Boolean},defaultTop:{},defaultWidth:{},disabledInput:{type:Boolean},draggable:{type:Boolean},dropdownMenuConfig:{},enableChatSession:{type:Boolean},enablePopup:{type:Boolean},extCls:{},helloText:{},hideDefaultTrigger:{type:Boolean},hideHeader:{type:Boolean},hideNimbus:{type:Boolean},initialSessionCode:{},loadRecentSessionOnMount:{type:Boolean},maxWidth:{},miniPadding:{},nimbusSize:{},placeholder:{},prompts:{},requestOptions:{},resources:{},shortcutLimit:{},shortcuts:{},showCompressionIcon:{type:Boolean},showHistoryIcon:{type:Boolean},showMoreIcon:{type:Boolean},showNewChatIcon:{type:Boolean},teleportTo:{},title:{},url:{},shortcutFilter:{type:Function}},o2t),emits:[`show`,`close`,`dragging`,`resizing`,`drag-stop`,`resize-stop`,`send-message`,`receive-start`,`receive-text`,`receive-end`,`stop`,`shortcut-click`,`session-initialized`,`sdk-error`,`transfer-messages`,`share-messages`,`new-chat`,`history-click`,`auto-generate-name`,`help-click`,`rename`,`share`],setup(e,{expose:n,emit:r}){let i=e,a=r,o=(0,t.ref)(),s=(0,t.ref)(),l=(0,t.computed)(()=>p1t(i.url)),u=R0t({initialPanelVisible:!1,initialNimbusMinimized:i.defaultMinimize,enablePopup:i.enablePopup,enableNimbus:!i.hideNimbus,enableDraggable:i.draggable}),d=u.panelVisible,f=u.nimbusMinimized,{forwardToManager:p}=r2t({componentManager:u,emit:a}),m=n2t(p),{chatHelper:h,isReady:g,agentInfo:_,agentName:v,currentSession:y}=t2t({url:l,requestOptions:i.requestOptions,autoInit:!0,protocolCallbacks:{onStart:()=>{m.receiveStart()},onMessage:()=>{m.receiveText()},onDone:()=>{m.receiveEnd()},onError:e=>{u.emitInternal(`sdk-error`,{apiName:`chat`,code:-1,message:e.message,data:e})}}}),b=h,x=new z9(b.session,b.message,null,{enableChatSession:i.enableChatSession,initialSessionCode:i.initialSessionCode}),S=new I0t(b.message,b.session),C=new V0t,w=(0,t.computed)(()=>C.isSelectionMode.value),T=(0,t.ref)(!1),E=new B9(null,i.shortcuts||[]),D=(0,t.ref)(!1),O=(0,t.ref)(``),k=(0,t.computed)(()=>u.isCompressed.value),A=(0,t.computed)(()=>v.value),j=(0,t.ref)(``),M=(0,t.ref)(!0),N=(0,t.ref)(!1),P=(0,t.computed)(()=>i.resources?.length?i.resources:u1t(_.value?.resources)),F=(0,t.computed)(()=>i.prompts?.length?i.prompts:_.value?.conversationSettings?.predefinedQuestions??[]),I=(0,t.computed)(()=>{let e=E.effectiveShortcuts.value;return typeof i.shortcutFilter==`function`&&O.value?e.filter(e=>i.shortcutFilter?.(e,O.value)):e});(0,t.watch)(()=>g.value,async e=>{if(e&&_.value){let e=_.value;if(e.saasUrl&&fetch(e.saasUrl,{method:`GET`,credentials:`include`}).catch(()=>{}),e.conversationSettings&&(p(`session-initialized`,{openingRemark:e.conversationSettings.openingRemark||``,predefinedQuestions:e.conversationSettings.predefinedQuestions||[]}),e.conversationSettings.commands&&E.setAgentShortcuts(e.conversationSettings.commands)),i.loadRecentSessionOnMount)try{await x.loadRecentSession({skipLoadSessions:!0})}catch(e){console.error(`[AIBlueking] Failed to load recent session:`,e)}}},{immediate:!0}),(0,t.watch)(()=>i.shortcuts,e=>{E.setShortcuts(e||[])},{immediate:!0}),(0,t.watch)(()=>y.value,e=>{e&&(j.value=e.sessionName||``,N.value=(e.sessionContentCount??0)>0)},{immediate:!0}),(0,t.watch)(()=>b.message.list.value.length,e=>{e>0&&(N.value=!0)});let L=async e=>{u.showPanel(e),e&&s.value&&await s.value.switchSession(e)},R=()=>{u.hidePanel()},ee=()=>{R()},z=()=>{u.handleNimbusClick()},B=e=>{O.value=e},V=async(e,t)=>{D.value=!1,await L(),e.components?.length&&s.value?s.value.selectShortcut(e,t):s.value&&(s.value.setCiteText(t),s.value.focusInput()),p(`shortcut-click`,{shortcut:e,source:`popup`})},te=e=>{p(`shortcut-click`,e)},ne=e=>{u.handleDragging(e)},re=e=>{u.handleResizing(e)},ie=e=>{u.handleDragStop(e)},ae=e=>{u.handleResizeStop(e)},H=()=>{u.container.toggleCompression()},oe=e=>{u.setCompressed(e)},se=async()=>{m.newChat()},ce=e=>{m.historyClick(e)},le=async e=>{await x.switchSession(e)},ue=async e=>{await x.deleteSession(e)},de=async(e,t)=>{await x.updateSessionName(e,t)},fe=async()=>{let e=b.session.current?.value?.sessionCode;if(!e){console.error(`[AIBlueking] Cannot auto-generate name: no active session`);return}try{await b.session.renameSession(e);let t=b.session.list.value.find(t=>t.sessionCode===e);t&&(j.value=t.sessionName||``)}catch(e){console.error(`[AIBlueking] Failed to auto-generate session name:`,e),ke(e)}m.autoGenerateName()},pe=()=>{m.helpClick()},me=async e=>{let t=b.session.current?.value;if(!t){console.error(`[AIBlueking] Cannot rename: no active session`);return}try{await b.session.updateSession({...t,sessionName:e}),j.value=e}catch(e){console.error(`[AIBlueking] Failed to rename session:`,e),ke(e)}m.rename(e)},he=()=>{C.enableSelectionMode(),m.share()},ge=()=>{C.disableSelectionMode()},_e=async e=>{T.value=!0;try{let{shareUrl:t,userMessageIds:n}=await S.shareMessages(e);await m1t(t),wu({message:m9(`分享链接已复制到剪贴板`),theme:`success`}),C.disableSelectionMode(),m.shareMessages(n)}catch(e){console.error(`[AIBlueking] Failed to share messages:`,e),ke(e)}finally{T.value=!1}},ve=async e=>{s.value&&await s.value.sendMessage(e)},ye=e=>{N.value=!0,m.sendMessage(e)},be=()=>{m.receiveStart()},xe=()=>{m.receiveText()},Se=()=>{m.receiveEnd()},Ce=()=>{m.stop()},we=()=>{s.value&&s.value.stopGeneration()},Te=async e=>{e?await x.createSession({sessionCode:e}):await x.createNewSession()},Ee=async e=>{s.value&&await s.value.switchSession(e)},De=async(e,t)=>{try{await x.updateSessionName(e,t),j.value=t}catch(e){console.error(`[AIBlueking] Failed to update session name:`,e),ke(e)}},Oe=e=>{e&&(j.value=e.sessionName||``,N.value=(e.sessionContentCount??0)>0||b.message.list.value.length>0)},ke=e=>{console.error(`ChatBot error:`,e),u.emitInternal(`sdk-error`,{apiName:`chat`,code:-1,message:e.message,data:e})},Ae=(e,t)=>{u.container.updatePosition(e,t)},je=(e,t)=>{u.container.updateSize(e,t)},Me=(e,t,n,r)=>{u.container.updatePositionAndSize(e,t,n,r)},Ne=e=>{s.value&&s.value.setCiteText(e)},Pe=()=>{s.value&&s.value.focusInput()},Fe=e=>{v1t(e)&&(e.preventDefault(),d.value?R():L())};return(0,t.onMounted)(async()=>{o.value&&u.setContainerRef(o.value),window.addEventListener(`keydown`,Fe)}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`keydown`,Fe),u.destroy()}),n({show:L,hide:R,sendMessage:ve,stopGeneration:we,addNewSession:Te,switchToSession:Ee,updateSessionName:De,updatePosition:Ae,updateSize:je,updatePositionAndSize:Me,setCiteText:Ne,focusInput:Pe}),(e,n)=>((0,t.openBlock)(),(0,t.createBlock)(t.Teleport,{to:i.teleportTo},[(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`ai-blueking-v2`,i.extCls])},[(0,t.createCommentVNode)(` 可拖拽容器 `),(0,t.createVNode)((0,t.unref)(x2t),{ref_key:`draggableContainerRef`,ref:o,"compressed-padding":i.miniPadding,"default-height":i.defaultHeight,"default-width":i.defaultWidth,"default-x":i.defaultLeft,"default-y":i.defaultTop,"drag-handle":`.drag-handle`,draggable:i.draggable,"max-width":i.maxWidth,"max-width-percent":80,visible:(0,t.unref)(d),onCompressionChange:oe,onDragStop:ie,onDragging:ne,onResizeStop:ae,onResizing:re},{default:(0,t.withCtx)(()=>[(0,t.createElementVNode)(`div`,T2t,[(0,t.createCommentVNode)(` 独立的 Header 组件 `),i.hideHeader?(0,t.createCommentVNode)(`v-if`,!0):((0,t.openBlock)(),(0,t.createBlock)(W1t,{key:0,"agent-name":A.value,"chat-helper":(0,t.unref)(b),draggable:i.draggable,"dropdown-menu-config":i.dropdownMenuConfig,"enable-chat-session":i.enableChatSession,"has-permission":M.value,"has-session-contents":N.value,"is-compression-height":k.value,"session-business-manager":(0,t.unref)(x),"session-name":j.value,"show-compression-icon":i.showCompressionIcon,"show-history-icon":i.showHistoryIcon,"show-more-icon":i.showMoreIcon,"show-new-chat-icon":i.showNewChatIcon,title:i.title,onAutoGenerateName:fe,onClose:ee,onHelpClick:pe,onHistoryClick:ce,onHistorySessionDelete:ue,onHistorySessionRename:de,onHistorySessionSwitch:le,onNewChat:se,onRename:me,onShare:he,onToggleCompression:H},null,8,[`agent-name`,`chat-helper`,`draggable`,`dropdown-menu-config`,`enable-chat-session`,`has-permission`,`has-session-contents`,`is-compression-height`,`session-business-manager`,`session-name`,`show-compression-icon`,`show-history-icon`,`show-more-icon`,`show-new-chat-icon`,`title`])),(0,t.createCommentVNode)(` ChatBot 核心组件(仅聊天区域) `),(0,t.createVNode)(e2t,{ref_key:`chatBotRef`,ref:s,"auto-load":i.loadRecentSessionOnMount,"chat-helper":(0,t.unref)(b),"enable-selection":w.value,"hello-text":i.helloText,placeholder:i.placeholder,prompts:F.value,"request-options":i.requestOptions,resources:P.value,"session-code":i.initialSessionCode,"share-loading":T.value,"shortcut-limit":i.shortcutLimit,shortcuts:i.shortcuts,url:l.value,onCancelShare:ge,onConfirmShare:n[0]||=e=>_e(e),onError:n[1]||=e=>ke(e),onReceiveEnd:Se,onReceiveStart:be,onReceiveText:xe,onRequestShare:he,onSendMessage:n[2]||=e=>ye(e),onSessionSwitched:n[3]||=e=>Oe(e),onShortcutClick:n[4]||=e=>te(e),onStop:Ce},null,8,[`auto-load`,`chat-helper`,`enable-selection`,`hello-text`,`placeholder`,`prompts`,`request-options`,`resources`,`session-code`,`share-loading`,`shortcut-limit`,`shortcuts`,`url`])])]),_:1},8,[`compressed-padding`,`default-height`,`default-width`,`default-x`,`default-y`,`draggable`,`max-width`,`visible`]),(0,t.createCommentVNode)(` Nimbus 悬浮球 `),i.hideNimbus?(0,t.createCommentVNode)(`v-if`,!0):((0,t.openBlock)(),(0,t.createBlock)(w2t,{key:0,"is-minimize":(0,t.unref)(f),"onUpdate:isMinimize":n[5]||=e=>(0,t.isRef)(f)?f.value=e:null,"is-panel-show":(0,t.unref)(d),"onUpdate:isPanelShow":n[6]||=e=>(0,t.isRef)(d)?d.value=e:null,"default-minimize":i.defaultMinimize,size:i.nimbusSize,onClick:z},null,8,[`is-minimize`,`is-panel-show`,`default-minimize`,`size`])),(0,t.createCommentVNode)(` 划词选择弹窗(使用 chat-x 的 AiSelection 组件) `),i.enablePopup?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Ote),{key:1,visible:D.value,"onUpdate:visible":n[7]||=e=>D.value=e,"max-shortcut-count":i.shortcutLimit,shortcuts:I.value,onSelectShortcut:V,onSelectionChange:B},null,8,[`visible`,`max-shortcut-count`,`shortcuts`])):(0,t.createCommentVNode)(`v-if`,!0)],2)],8,[`to`]))}}),[[`__scopeId`,`data-v-390ddb5e`]]);return e.AGUIProtocol=O9,e.AIBlueking=$9,e.default=$9,e.BluekingProtocol=s2t,e.BootstrapPhase=V9,e.ChatBot=e2t,e.ChatBusinessManager=F0t,e.ComponentManager=L0t,e.DraggableContainer=x2t,e.MessageContentType=h,e.SessionBusinessManager=z9,e.ShortcutManager=B9,e.UIStateManager=V0t,e.createBluekingProtocol=c2t,e.createComponentManager=R0t,e.defaultProps=o2t,e.useChatBootstrap=t2t,e.useChatHelper=R9,e.useDraggable=y2t,e})({},Vue);
@@ -2818,5 +2818,5 @@ Use Shift + Enter to enter a new line`:`输入 “/”唤出 Prompt
2818
2818
  ${r}
2819
2819
  </div>
2820
2820
  `}),D=async()=>{if(a.sessionBusinessManager)try{await a.sessionBusinessManager.createNewSession()}catch(e){console.error(`Failed to create new session:`,e),(0,i.Message)({theme:`error`,message:z9(`创建会话失败`)})}o(`new-chat`)},O=e=>{e.stopPropagation(),a.sessionBusinessManager?(v||y(),v&&v.handleTriggerClick(e)):o(`history-click`,e)},k=()=>{o(`help-click`)},A=e=>{e.stopPropagation(),_&&(_.state.isVisible?_.hide():_.show())},j=e=>{e.stopPropagation(),e.preventDefault();let t=e.currentTarget,n=t.dataset.action;if(!t.classList.contains(`disabled`))switch(_&&_.hide(),n){case`rename`:M();break;case`auto-generate`:o(`auto-generate-name`);break;case`share`:o(`share`);break}},M=()=>{document.removeEventListener(`click`,I),h.value=a.sessionName||``,m.value=!0,setTimeout(()=>{document.addEventListener(`click`,I)},100),setTimeout(()=>{if(g.value)try{let e=g.value;e&&typeof e.focus==`function`&&e.focus();let t=e.$el?.querySelector(`input`);t&&typeof t.select==`function`&&t.select()}catch(e){console.warn(`Failed to focus rename input:`,e)}},100)},N=()=>{let e=h.value.trim();if(!e){P();return}o(`rename`,e),m.value=!1,h.value=``},P=()=>{m.value=!1,h.value=``},F=(e,t)=>{h.value=e,t.key===`Enter`?N():t.key===`Escape`&&P()},I=e=>{if(!m.value)return;let t=e.target,n=document.querySelector(`.rename-tooltip`);n&&!n.contains(t)&&P()},L=async()=>{if(!d.value)return;let e=(await import(`tippy.js`)).default;_&&=(_.destroy(),null),_=e(d.value,{content:E.value,theme:`ai-blueking-light more-menu-light light`,placement:`bottom-start`,trigger:`manual`,interactive:!0,allowHTML:!0,arrow:!1,offset:[0,4],appendTo:()=>document.querySelector(`.ai-blueking-panel`)||document.body,onShow:()=>{setTimeout(()=>{document.querySelectorAll(`.tippy-menu-item`).forEach(e=>{e.addEventListener(`click`,j)})},0)},onHide:()=>{document.querySelectorAll(`.tippy-menu-item`).forEach(e=>{e.removeEventListener(`click`,j)})}})};return(0,t.watch)(()=>[a.isCompressionHeight,a.hasSessionContents],()=>{_&&_.setContent(E.value)}),(0,t.onMounted)(()=>{L(),a.sessionBusinessManager&&y(),document.addEventListener(`click`,I)}),(0,t.onBeforeUnmount)(()=>{_&&=(_.destroy(),null),v&&=(v.destroy(),null),document.removeEventListener(`click`,I)}),n({headerRef:l,historyIconRef:u}),(n,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`headerRef`,ref:l,class:(0,t.normalizeClass)([`ai-header drag-handle`,{draggable:a.draggable}])},[(0,t.createElementVNode)(`div`,_xt,[(0,t.createElementVNode)(`div`,vxt,[(0,t.createElementVNode)(`img`,{alt:`logo`,src:(0,t.unref)(Bbt)},null,8,yxt)]),(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`title`,{"title-with-tooltip":m.value}])},[(0,t.createTextVNode)((0,t.toDisplayString)(b.value)+` `,1),(0,t.createCommentVNode)(` 重命名 tooltip 直接绑定在 title 上 `),m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,bxt,[(0,t.createElementVNode)(`div`,xxt,[(0,t.createVNode)((0,t.unref)(i.Input),{ref_key:`renameInputRef`,ref:g,modelValue:h.value,"onUpdate:modelValue":r[0]||=e=>h.value=e,class:`rename-input`,placeholder:(0,t.unref)(z9)(`请输入新的会话名称`),onKeyup:F},null,8,[`modelValue`,`placeholder`]),(0,t.createElementVNode)(`div`,{class:`rename-buttons`},[(0,t.createElementVNode)(`i`,{class:`bkai-icon bkai-check-1 rename-btn confirm-btn`,onClick:N}),(0,t.createElementVNode)(`i`,{class:`bkai-icon bkai-close rename-btn cancel-btn`,onClick:P})])])])):(0,t.createCommentVNode)(`v-if`,!0)],2),a.showMoreIcon&&C.value?((0,t.openBlock)(),(0,t.createElementBlock)(`span`,{key:0,ref_key:`moreIconRef`,ref:d,class:`bkai-icon bkai-more`,onClick:A},null,512)):(0,t.createCommentVNode)(`v-if`,!0)]),(0,t.createElementVNode)(`div`,Sxt,[(0,t.createCommentVNode)(` 新增会话按钮 `),a.showNewChatIcon&&e.enableChatSession!==!1?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:0,class:(0,t.normalizeClass)([`bkai-icon`,`bkai-xinzengliaotian`,{disabled:!C.value}]),style:(0,t.normalizeStyle)(T()),onClick:r[1]||=e=>C.value?D():void 0},null,6)),[[(0,t.unref)(s),{content:w((0,t.unref)(z9)(`新增会话`)),boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),(0,t.createCommentVNode)(` 历史会话按钮 `),a.showHistoryIcon&&e.enableChatSession!==!1?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:1,ref_key:`historyIconRef`,ref:u,class:(0,t.normalizeClass)([`bkai-icon`,`bkai-history`,{disabled:!C.value}]),style:(0,t.normalizeStyle)(T()),onClick:r[2]||=e=>C.value?O(e):void 0},null,6)),[[(0,t.unref)(s),{content:w((0,t.unref)(z9)(`历史会话`)),boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),e.chatGroup?.enabled?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:2,class:`bkai-icon bkai-zhushou`,onClick:k},null,512)),[[(0,t.unref)(s),{content:(0,t.unref)(z9)(`转人工`),boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),a.showCompressionIcon?(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`i`,{key:3,ref_key:`compressionRef`,ref:f,class:(0,t.normalizeClass)([`bkai-icon`,x.value]),onClick:r[3]||=e=>o(`toggle-compression`)},null,2)),[[(0,t.unref)(s),{content:S.value,boundary:`parent`}]]):(0,t.createCommentVNode)(`v-if`,!0),(0,t.withDirectives)((0,t.createElementVNode)(`i`,{ref_key:`closeRef`,ref:p,class:`bkai-icon bkai-close-line-2`,onClick:r[4]||=e=>o(`close`)},null,512),[[(0,t.unref)(s),{content:(0,t.unref)(z9)(`关闭`),boundary:`parent`}]])])],2))}}),[[`__scopeId`,`data-v-e9f38ba5`]]),wxt=class{_isGenerating;agentModule;config;eventEmitter;messageModule;sessionModule;autoRenameSessionIfNeeded(e){this.sessionModule&&this.messageModule.list.value.length===1&&this.sessionModule.renameSession(e).catch(e=>{console.error(`[ChatBusinessManager] Auto rename session failed:`,e)})}emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,n,r=null,i=null,a={}){this.agentModule=e,this.messageModule=n,this.sessionModule=r,this.eventEmitter=i,this.config=a,this._isGenerating=(0,t.ref)(!1)}get isGenerating(){return this._isGenerating}get isMessagesLoading(){return this.messageModule.isListLoading}get messages(){return this.messageModule.list}get openingRemark(){return this.config.openingRemark||``}get predefinedQuestions(){return this.config.predefinedQuestions||[]}async batchDeleteMessages(e){try{await this.messageModule.deleteMessages(e);let t=e.map(e=>e.id).filter(Boolean);this.emit(`messages-batch-deleted`,{messageIds:t})}catch(e){throw console.error(`Failed to batch delete messages:`,e),this.emit(`chat-error`,{action:`batch-delete-messages`,error:e}),e}}async deleteMessage(e){try{await this.messageModule.deleteMessages([e]),this.emit(`message-deleted`,{messageId:e.id})}catch(e){throw console.error(`Failed to delete message:`,e),this.emit(`chat-error`,{action:`delete-message`,error:e}),e}}handleStreamEnd(){this._isGenerating.value=!1,this.emit(`receive-end`,{})}handleStreamError(e){this._isGenerating.value=!1,this.emit(`receive-error`,{error:e})}handleStreamStart(){this._isGenerating.value=!0,this.emit(`receive-start`,{})}async regenerateFromAIMessages(e,t){try{if(!e||e.length===0)throw Error(`No AI messages provided`);let n=this.messages.value,r=R9(n,e[0]);if(!r)throw Error(`No user message found before AI messages`);let i=r.id;if(i===void 0)throw Error(`User message has no id`);await this.regenerateMessage(String(i),t)}catch(e){throw console.error(`Failed to regenerate from AI messages:`,e),this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async regenerateMessage(e,t){try{let n=this.messages.value,r=n.findIndex(t=>String(t.id)===e);if(r===-1)throw Error(`Message not found: ${e}`);let i=n[r];if(i.role!==s.MessageRole.User)throw Error(`Can only regenerate from user messages`);let a=n.slice(r),o=typeof i.content==`string`?i.content:JSON.stringify(i.content),l=i.property;this._isGenerating.value=!0;let u=this.messageModule.deleteMessages(a);this.agentModule.chat(o,t,void 0,void 0,l),this.emit(`chat-regenerate`,{messageId:e}),u.catch(e=>{console.error(`[regenerateMessage] Delete API error:`,e)})}catch(e){throw console.error(`Failed to regenerate message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`regenerate`,error:e}),e}}async resendMessageWithProperty(e,t,n,r){try{let i=this.messages.value,a=i.findIndex(t=>String(t.id)===e);if(a===-1)throw Error(`Message not found: ${e}`);if(i[a].role!==s.MessageRole.User)throw Error(`Can only resend user messages`);let o=i.slice(a);this._isGenerating.value=!0;let l=this.messageModule.deleteMessages(o);this.agentModule.chat(n,t,void 0,void 0,r),this.emit(`chat-resend`,{messageId:e}),l.catch(e=>{console.error(`[resendMessageWithProperty] Delete API error:`,e)})}catch(e){throw console.error(`Failed to resend message with property:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`resend`,error:e}),e}}async retryMessage(e){try{console.warn(`retryMessage not implemented yet`),this.emit(`chat-retry`,{messageId:e})}catch(e){throw console.error(`Failed to retry message:`,e),this.emit(`chat-error`,{action:`retry`,error:e}),e}}async sendMessage(e,t,n={}){try{if(!t)throw Error(`No active session. Please create or select a session first.`);this._isGenerating.value=!0,this.emit(`send-message`,{content:e}),await this.agentModule.chat(e,t,void 0,void 0,n.property),this.autoRenameSessionIfNeeded(t)}catch(e){throw console.error(`Failed to send message:`,e),this._isGenerating.value=!1,this.emit(`chat-error`,{action:`send`,error:e}),e}}stopGeneration(){try{let e=this.sessionModule?.current?.value?.sessionCode??``;this.agentModule.stopChat(e),this._isGenerating.value=!1,this.emit(`stop`,{})}catch(e){console.error(`Failed to stop generation:`,e),this.emit(`chat-error`,{action:`stop`,error:e})}}},B9=class{config;eventEmitter;messageModule;sessionModule;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e,t,n=null,r={}){this.sessionModule=e,this.messageModule=t,this.eventEmitter=n,this.config=r}get currentSession(){return this.sessionModule.current}get isCreateLoading(){return this.sessionModule.isCreateLoading}get isCurrentLoading(){return this.sessionModule.isCurrentLoading}get isDeleteLoading(){return this.sessionModule.isDeleteLoading}get isListLoading(){return this.sessionModule.isListLoading}get isUpdateLoading(){return this.sessionModule.isUpdateLoading}get sessionList(){return this.sessionModule.list}async createNewSession(){return this.createSession({name:`新会话`,sessionCode:`new_session_${Date.now()}`})}async createSession(e={}){if(this.config.enableChatSession===!1)throw Error(`Chat session is disabled`);try{let t={sessionName:e.name||`新会话`,sessionCode:e.sessionCode||`session_${Date.now()}`,isTemporary:e.isTemporary||!1};await this.sessionModule.createSession(t),this.emit(`session-created`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to create session:`,e),this.emit(`session-error`,{action:`create`,error:e}),e}}async deleteSession(e){try{await this.sessionModule.deleteSession(e),this.emit(`session-deleted`,{sessionCode:e})}catch(e){throw console.error(`Failed to delete session:`,e),this.emit(`session-error`,{action:`delete`,error:e}),e}}async getSession(e){try{await this.sessionModule.getSession(e)}catch(e){throw console.error(`Failed to get session:`,e),this.emit(`session-error`,{action:`get`,error:e}),e}}async loadRecentSession(e){try{e?.skipLoadSessions||await this.loadSessions();let t=this.sessionList.value;if(this.config.initialSessionCode){await this.switchSession(this.config.initialSessionCode);return}if(t.length>0){let e=t[0];(e.sessionContentCount??0)>0?await this.createNewSession():await this.switchSession(e.sessionCode,{loadMessages:!1});return}await this.createNewSession()}catch(e){throw console.error(`Failed to load recent session:`,e),e}}async loadSessions(){try{await this.sessionModule.getSessions(),this.emit(`sessions-loaded`,{sessions:this.sessionList.value})}catch(e){throw console.error(`Failed to load sessions:`,e),this.emit(`session-error`,{action:`load`,error:e}),e}}async switchSession(e,t){try{await this.sessionModule.chooseSession(e,t),this.emit(`session-switched`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to switch session:`,e),this.emit(`session-error`,{action:`switch`,error:e}),e}}async updateSessionName(e,t){try{let n=this.sessionList.value.find(t=>t.sessionCode===e);if(!n)throw Error(`Session not found: ${e}`);await this.sessionModule.updateSession({...n,sessionName:t}),this.emit(`session-updated`,{session:this.sessionModule.current.value})}catch(e){throw console.error(`Failed to update session name:`,e),this.emit(`session-error`,{action:`update`,error:e}),e}}},Txt=class{messageModule;sessionModule;constructor(e,t){this.messageModule=e,this.sessionModule=t}async shareMessages(e){if(e.length===0)throw Error(`No messages to share`);let t=this.sessionModule.current?.value?.sessionCode;if(!t)throw Error(`No active session`);let n=await this.messageModule.shareMessages(t,e);if(!n)throw Error(`Share failed: no result returned`);return{shareUrl:`${n.share_page}share-page/${n.share_token}`,userMessageIds:e.filter(e=>e.role===`user`).map(e=>String(e.id))}}},V9=class{_agentShortcuts;_effectiveShortcuts;_propsShortcuts;eventEmitter;emit(e,t){this.eventEmitter?.emit(e,t)}constructor(e=null,n=[]){this._propsShortcuts=(0,t.ref)(n),this._agentShortcuts=(0,t.ref)([]),this.eventEmitter=e,this._effectiveShortcuts=(0,t.computed)(()=>this._propsShortcuts.value.length>0?this._propsShortcuts.value:this._agentShortcuts.value.length>0?this._agentShortcuts.value:[])}get count(){return this._effectiveShortcuts.value.length}get effectiveShortcuts(){return this._effectiveShortcuts}get hasShortcuts(){return this._effectiveShortcuts.value.length>0}get shortcuts(){return this._effectiveShortcuts}addShortcut(e){this._propsShortcuts.value.push(e)}clear(){this._propsShortcuts.value=[],this._agentShortcuts.value=[]}filterByTextLength(e,t){return!e||e.length>t?[]:this._effectiveShortcuts.value}filterShortcuts(e,t){return t?this._effectiveShortcuts.value.filter(n=>t(n,e)):this._effectiveShortcuts.value}getShortcutById(e){return this._effectiveShortcuts.value.find(t=>t.id===e)}handleShortcutClick(e,t,n=`main`){this.emit(`shortcut-click`,{shortcut:e,selectedText:t,source:n})}limitShortcuts(e){return this._effectiveShortcuts.value.slice(0,e)}removeShortcut(e){this._propsShortcuts.value=this._propsShortcuts.value.filter(t=>t.id!==e)}setAgentShortcuts(e){this._agentShortcuts.value=e}setShortcuts(e){this._propsShortcuts.value=e}},Ext=class{config;_panelVisible;_nimbusMinimized;_isDraggingOrResizing;_positionAndSize;_isCompressed;containerRef=null;listeners;onceListeners;debugMode;cleanupFunctions;constructor(e={}){this.config=e,this.listeners=new Map,this.onceListeners=new Map,this.debugMode=e.debug??!1,this.cleanupFunctions=[],this._panelVisible=(0,t.ref)(e.initialPanelVisible??!1),this._nimbusMinimized=(0,t.ref)(e.initialNimbusMinimized??!1),this._isDraggingOrResizing=(0,t.ref)(!1),this._isCompressed=(0,t.ref)(!1),this._positionAndSize=(0,t.ref)({x:0,y:0,width:400,height:window.innerHeight})}getConfig(){return this.config}get state(){return{panelVisible:this._panelVisible,nimbusMinimized:this._nimbusMinimized,isDraggingOrResizing:this._isDraggingOrResizing,positionAndSize:this._positionAndSize}}get panelVisible(){return this._panelVisible}get nimbusMinimized(){return this._nimbusMinimized}get isDraggingOrResizing(){return this._isDraggingOrResizing}get isCompressed(){return this._isCompressed}get panel(){return{show:this.showPanel.bind(this),hide:this.hidePanel.bind(this),toggle:this.togglePanel.bind(this),isVisible:(0,t.computed)(()=>this._panelVisible.value)}}showPanel(e){this._panelVisible.value=!0,this.emit(`panel-show`,{sessionCode:e})}hidePanel(){this._panelVisible.value=!1,this.emit(`panel-hide`,{})}togglePanel(){this._panelVisible.value?this.hidePanel():this.showPanel()}get nimbus(){return{minimize:this.minimizeNimbus.bind(this),restore:this.restoreNimbus.bind(this),toggle:this.toggleNimbus.bind(this),isMinimized:(0,t.computed)(()=>this._nimbusMinimized.value)}}minimizeNimbus(){this._nimbusMinimized.value=!0,this.emit(`nimbus-minimize`,{})}restoreNimbus(){this._nimbusMinimized.value=!1,this.emit(`nimbus-restore`,{})}toggleNimbus(){this._nimbusMinimized.value?this.restoreNimbus():this.minimizeNimbus()}handleNimbusClick(){this.emit(`nimbus-click`,{}),this.showPanel()}get container(){return{updatePosition:this.updatePosition.bind(this),updateSize:this.updateSize.bind(this),updatePositionAndSize:this.updatePositionAndSize.bind(this),toggleCompression:this.toggleCompression.bind(this),positionAndSize:(0,t.computed)(()=>this._positionAndSize.value),isCompressed:(0,t.computed)(()=>this._isCompressed.value)}}updatePosition(e,t){this._positionAndSize.value={...this._positionAndSize.value,x:e,y:t}}updateSize(e,t){this._positionAndSize.value={...this._positionAndSize.value,width:e,height:t}}updatePositionAndSize(e,t,n,r){this._positionAndSize.value={x:e,y:t,width:n,height:r}}setContainerRef(e){this.containerRef=e,e?.isCompressed&&(this._isCompressed.value=e.isCompressed.value)}setCompressed(e){this._isCompressed.value=e}toggleCompression(){this.containerRef?this.containerRef.toggleCompression():this._isCompressed.value=!this._isCompressed.value}setDraggingOrResizing(e){this._isDraggingOrResizing.value=e}handleDragging(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`dragging`,e)}handleResizing(e){this._isDraggingOrResizing.value=!0,this._positionAndSize.value=e,this.emit(`resizing`,e)}handleDragStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`drag-stop`,e)}handleResizeStop(e){this._isDraggingOrResizing.value=!1,this._positionAndSize.value=e,this.emit(`resize-stop`,e)}handlePopupClick(){this.emit(`popup-click`,{}),this.showPanel()}handlePopupShortcutClick(e){this.emit(`popup-shortcut-click`,{shortcut:e}),this.emit(`shortcut-click`,{shortcut:e,source:`popup`})}handleShortcutClick(e,t){this.emit(`shortcut-click`,{shortcut:e,source:t})}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed to "${e}", total: ${this.listenerCount(e)}`),()=>{this.off(e,t)}}once(e,t){return this.onceListeners.has(e)||this.onceListeners.set(e,new Set),this.onceListeners.get(e).add(t),this.debugMode&&console.debug(`[ComponentManager] Subscribed once to "${e}"`),()=>{this.onceListeners.get(e)?.delete(t)}}off(e,t){t?(this.listeners.get(e)?.delete(t),this.onceListeners.get(e)?.delete(t),this.debugMode&&console.debug(`[ComponentManager] Unsubscribed from "${e}", remaining: ${this.listenerCount(e)}`)):(this.listeners.delete(e),this.onceListeners.delete(e),this.debugMode&&console.debug(`[ComponentManager] Removed all listeners for "${e}"`))}emit(e,t){this.debugMode&&console.debug(`[ComponentManager] Emitting "${e}"`,t);let n=this.listeners.get(e);n&&n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in listener for "${e}":`,t)}});let r=this.onceListeners.get(e);if(r&&r.size>0){let n=Array.from(r);this.onceListeners.delete(e),n.forEach(n=>{try{n(t)}catch(t){console.error(`[ComponentManager] Error in once listener for "${e}":`,t)}})}}emitInternal(e,t){this.emit(e,t)}listenerCount(e){return(this.listeners.get(e)?.size??0)+(this.onceListeners.get(e)?.size??0)}hasListeners(e){return this.listenerCount(e)>0}getRegisteredEvents(){let e=new Set;return this.listeners.forEach((t,n)=>e.add(n)),this.onceListeners.forEach((t,n)=>e.add(n)),Array.from(e)}setDebugMode(e){this.debugMode=e}destroy(){this.listeners.clear(),this.onceListeners.clear(),this.cleanupFunctions.forEach(e=>e()),this.cleanupFunctions=[],this.debugMode&&console.debug(`[ComponentManager] Destroyed`)}};function Dxt(e){return new Ext(e)}let Oxt={"panel-show":`show`,"panel-hide":`close`,"panel-toggle":null,"nimbus-click":null,"nimbus-minimize":null,"nimbus-restore":null,"popup-click":null,"popup-shortcut-click":null,dragging:`dragging`,resizing:`resizing`,"drag-stop":`drag-stop`,"resize-stop":`resize-stop`,"compression-toggle":null,"send-message":`send-message`,"receive-start":`receive-start`,"receive-text":`receive-text`,"receive-end":`receive-end`,"receive-error":null,stop:`stop`,"chat-regenerate":null,"chat-retry":null,"message-deleted":null,"messages-batch-deleted":null,"session-created":null,"session-switched":null,"session-deleted":null,"session-updated":null,"sessions-loaded":null,"session-initialized":`session-initialized`,"session-error":null,"shortcut-click":`shortcut-click`,"chat-error":null,"sdk-error":`sdk-error`,"new-chat":`new-chat`,"history-click":`history-click`,"auto-generate-name":`auto-generate-name`,"help-click":`help-click`,rename:`rename`,share:`share`,close:`close`,"toggle-compression":null,"transfer-messages":`transfer-messages`,"share-messages":`share-messages`,"agent-info-loaded":null,error:null};function kxt(e,t){switch(e){case`send-message`:return[t.content];case`rename`:return[t.newName];case`history-click`:return[t.event];case`dragging`:case`resizing`:case`drag-stop`:case`resize-stop`:case`shortcut-click`:case`session-initialized`:case`sdk-error`:case`transfer-messages`:case`share-messages`:return[t];case`panel-show`:case`panel-hide`:case`receive-start`:case`receive-text`:case`receive-end`:case`stop`:case`new-chat`:case`auto-generate-name`:case`help-click`:case`share`:case`close`:return[];default:return[t]}}var Axt=class{_selectedMessageIds;_isSelectionMode;_editingSessionCode;_loadingStates;constructor(){this._selectedMessageIds=(0,t.ref)(new Set),this._isSelectionMode=(0,t.ref)(!1),this._editingSessionCode=(0,t.ref)(null),this._loadingStates=(0,t.reactive)({})}get isSelectionMode(){return this._isSelectionMode}get editingSessionCode(){return this._editingSessionCode}toggleSelectionMode(){this._isSelectionMode.value=!this._isSelectionMode.value,this._isSelectionMode.value||this.clearSelection()}enableSelectionMode(){this._isSelectionMode.value=!0}disableSelectionMode(){this._isSelectionMode.value=!1,this.clearSelection()}toggleMessageSelection(e){this._selectedMessageIds.value.has(e)?this._selectedMessageIds.value.delete(e):this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectMessage(e){this._selectedMessageIds.value.add(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}deselectMessage(e){this._selectedMessageIds.value.delete(e),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}isMessageSelected(e){return this._selectedMessageIds.value.has(e)}clearSelection(){this._selectedMessageIds.value.clear(),this._selectedMessageIds.value=new Set(this._selectedMessageIds.value)}selectAllMessages(e){this._selectedMessageIds.value=new Set(e)}get selectedMessages(){return Array.from(this._selectedMessageIds.value)}get selectedCount(){return this._selectedMessageIds.value.size}get hasSelection(){return this._selectedMessageIds.value.size>0}startEditingSession(e){this._editingSessionCode.value=e}stopEditingSession(){this._editingSessionCode.value=null}isEditingSession(e){return e?this._editingSessionCode.value===e:this._editingSessionCode.value!==null}setLoading(e,t){this._loadingStates[e]=t}isLoading(e){return this._loadingStates[e]??!1}clearLoadingStates(){Object.keys(this._loadingStates).forEach(e=>{this._loadingStates[e]=!1})}reset(){this.clearSelection(),this.disableSelectionMode(),this.stopEditingSession(),this.clearLoadingStates()}},jxt={class:`selection-footer`},Mxt={class:`selection-footer-left`},Nxt={class:`select-all-text`},Pxt={class:`selection-footer-right`},Fxt=L9((0,t.defineComponent)({__name:`selection-footer`,props:{isAllSelected:{type:Boolean},loading:{type:Boolean,default:!1},selectedCount:{}},emits:[`cancel`,`confirm`,`toggle-all`],setup(e){let n=e;return(e,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,jxt,[(0,t.createElementVNode)(`div`,Mxt,[(0,t.createVNode)((0,t.unref)(i.Checkbox),{"model-value":n.isAllSelected,"onUpdate:modelValue":r[0]||=t=>e.$emit(`toggle-all`,t)},null,8,[`model-value`]),(0,t.createElementVNode)(`span`,Nxt,(0,t.toDisplayString)((0,t.unref)(z9)(`全选`)),1)]),(0,t.createElementVNode)(`div`,Pxt,[(0,t.createVNode)((0,t.unref)(i.Button),{disabled:n.loading,onClick:r[1]||=t=>e.$emit(`cancel`)},{default:(0,t.withCtx)(()=>[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(z9)(`取消`)),1)]),_:1},8,[`disabled`]),(0,t.createVNode)((0,t.unref)(i.Button),{disabled:n.selectedCount===0,loading:n.loading,theme:`primary`,onClick:r[2]||=t=>e.$emit(`confirm`)},{default:(0,t.withCtx)(()=>[(0,t.createTextVNode)((0,t.toDisplayString)((0,t.unref)(z9)(`确定`)),1)]),_:1},8,[`disabled`,`loading`])])]))}}),[[`__scopeId`,`data-v-3247bea6`]]),Ixt={key:0,class:`chatbot-error`},Lxt={class:`chatbot-loading`},Rxt={key:0,class:`chatbot-welcome`},zxt={class:`welcome-content`},Bxt={key:0,class:`welcome-remark`},Vxt={key:0,class:`chatbot-loading`},Hxt={key:3,class:`chatbot-input`},Uxt=(0,t.defineComponent)({__name:`chat-bot`,props:{autoLoad:{type:Boolean,default:!0},chatHelper:{default:void 0},enableSelection:{type:Boolean,default:!1},extCls:{},height:{},helloText:{},maxWidth:{},placeholder:{},prompts:{},requestOptions:{},resources:{default:()=>[]},sessionCode:{},shareLoading:{type:Boolean,default:!1},shortcutLimit:{default:10},shortcuts:{default:()=>[]},url:{default:``}},emits:[`agent-info-loaded`,`cancel-share`,`confirm-share`,`error`,`feedback`,`receive-end`,`receive-start`,`receive-text`,`request-share`,`send-message`,`session-switched`,`shortcut-click`,`stop`],setup(e,{expose:n,emit:r}){let a=e,o=r,l=(0,t.ref)(),u=(0,t.ref)(),d=(0,t.ref)(null),f=(0,t.shallowRef)([]),p=(0,t.ref)(!1),m=(0,t.ref)(null),h=()=>a.chatHelper?!a.chatHelper.agent||!a.chatHelper.session||!a.chatHelper.message?{valid:!1,error:`[ChatBot] Invalid chatHelper: missing required modules (agent, session, message)`}:{valid:!0}:a.url?{valid:!0}:{valid:!1,error:`[ChatBot] Neither chatHelper nor url provided. Component requires at least one.`},g=(()=>{let e=h();if(!e.valid)return console.error(e.error),m.value=Error(e.error),null;if(a.chatHelper)return a.chatHelper;let t=new s.AGUIProtocol({onStart:()=>{o(`receive-start`)},onMessage:e=>{o(`receive-text`)},onDone:()=>{o(`receive-end`),le()},onError:e=>{o(`error`,e)}}),n=(0,s.useChatHelper)({requestData:{urlPrefix:Kbt(a.url),headers:a.requestOptions?.headers,data:a.requestOptions?.data},protocol:t});return t.injectMessageModule(n.message),n})(),_=(0,t.computed)(()=>((a.chatHelper||g)?.agent)?.isChatting?.value?T.Streaming:T.Complete),v=(0,t.computed)(()=>_.value===T.Streaming?N9.Disabled:void 0),y=async(e,t)=>{if(e.id===`cite`){I.value=t.filter(e=>e.role!==w.Reasoning).map(e=>typeof e.content==`string`?e.content:JSON.stringify(e.content||``)).join(`
2821
- `),Se();return}if(e.id===`rebuild`){await S(t);return}if(e.id===`delete`){await x(t);return}if(e.id===`share`){o(`request-share`);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await g?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},b=async(e,t,n,r)=>{if(!g){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let i=g.session.current?.value?.sessionCode;if(!i){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let a=Vbt(N?.messages.value||[],t[0]);if(a===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let s=e.id===`like`?5:0;try{await g.session.postSessionFeedback({sessionCode:i,sessionContentIds:[a],rate:s,labels:n,comment:r}),o(`feedback`,e,t[0],n,r)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),o(`error`,e)}},x=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=N.messages.value,n=R9(t,e[0]);if(!n){console.error(`[ChatBot] No user message found before AI messages`);return}let r=[n,...e];await g.message.deleteMessages(r)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),o(`error`,e)}},S=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let t=g.session.current?.value?.sessionCode;if(!t){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await N.regenerateFromAIMessages(e,t),le()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),o(`error`,e)}},C=async(e,t)=>{if(e.id===`delete`){await k(t);return}if(e.id===`cite`){I.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),Se();return}console.log(`handleUserAction`,e,t)},E=async(e,t,n)=>{if(!g){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let r=g.session.current?.value?.sessionCode;if(!r){console.error(`[ChatBot] Cannot edit message: no active session`);return}let i=e.id;if(i===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,i,r,t),await g.agent.resendMessage(String(i),r,t),le()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),o(`error`,e)}},D=async(e,t)=>{if(!N||!g){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let n=g.session.current?.value?.sessionCode;if(!n){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let r=e.id;if(r===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let i=O(e);if(!i){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let a=_e(i,t),o=String(t.input??``);await N.resendMessageWithProperty(String(r),n,o,a),le()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),o(`error`,e)}},O=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?ce.value.find(e=>e.id===t.command)??null:null},k=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=N.messages.value,n=t.findIndex(t=>t===e);if(n===-1){console.error(`[ChatBot] User message not found in messages list`);return}let r=[];for(let e=n+1;e<t.length;e++){let n=t[e];if(n.role===w.User)break;r.push(n)}let i=[e,...r];await g.message.deleteMessages(i)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),o(`error`,e)}},A=async()=>{((a.chatHelper||g)?.agent)?.stopChat?.(g?.session.current?.value?.sessionCode??``)},j=!a.chatHelper,M=g?new B9(g.session,g.message,null,{enableChatSession:!0,autoSwitchToInitialSession:!!a.sessionCode,loadRecentSessionOnMount:a.autoLoad,initialSessionCode:a.sessionCode}):null,N=g?new wxt(g.agent,g.message,g.session,null,{openingRemark:a.helloText,predefinedQuestions:a.prompts,placeholder:a.placeholder}):null,P=new V9(null,a.shortcuts||[]),F=(0,t.shallowRef)([[]]),I=(0,t.ref)(``),L=(0,t.computed)(()=>N?.messages.value??[]),R=(0,t.computed)(()=>N?.isMessagesLoading.value??!1),ee=(0,t.computed)(()=>N?.isGenerating.value??!1),te=(0,t.computed)(()=>M?.currentSession.value??null),z=(0,t.computed)(()=>j&&!p.value?!1:!R.value&&L.value.length===0),B=(0,t.computed)(()=>g?.agent.info.value?.conversationSettings?.openingRemark||``),ne=(0,t.computed)(()=>a.resources?.length?a.resources:Ubt(g?.agent.info.value?.resources)),re=(0,t.computed)(()=>a.prompts?.length?a.prompts:g?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),ie=(0,t.computed)(()=>({height:typeof a.height==`number`?`${a.height}px`:a.height,maxWidth:typeof a.maxWidth==`number`?`${a.maxWidth}px`:a.maxWidth})),ae=(0,t.computed)(()=>{let e=P.shortcuts.value;return a.shortcutLimit&&e.length>a.shortcutLimit?e.slice(0,a.shortcutLimit):e}),oe=()=>{f.value=[],o(`cancel-share`)},V=()=>{o(`confirm-share`,f.value)},se=e=>{e?f.value=L.value:f.value=[]},ce=P.effectiveShortcuts;(0,t.watch)(()=>a.shortcuts,e=>{P.setShortcuts(e||[])},{immediate:!0}),(0,t.watch)(()=>g?.agent.info.value?.conversationSettings?.commands,e=>{e&&P.setAgentShortcuts(e)},{immediate:!0});let le=async()=>{await(0,t.nextTick)(),l.value&&(l.value.scrollTop=l.value.scrollHeight)},ue=async(e,t={})=>{if(!N||!g)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let n=g.session.current?.value?.sessionCode;if(!n)throw Error(`[ChatBot] Cannot send message: no active session`);F.value=[[]],I.value=``,o(`send-message`,typeof e==`string`?e:``),await N.sendMessage(e,n,t)},de=async e=>{let t=g?.session.current?.value?.sessionCode;return t&&await g.session.uploadFile(t,e)||{}},fe=async(e,t)=>{try{await ue(e,I.value?{property:{extra:{cite:I.value}}}:{})}catch(e){console.error(`Failed to send message:`,e),o(`error`,e)}},pe=async()=>{ye()},me=(e,t)=>{he(e,t),o(`shortcut-click`,{shortcut:e,source:`main`})},he=(e,t)=>{let n=e,r=n.components?.find(e=>e.fillBack)?.key||`input`;d.value={...n,formModel:{...n.formModel,[r]:t||``}}},ge=()=>{d.value=null},_e=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},ve=async e=>{if(!d.value){console.error(`[ChatBot] No selected shortcut`);return}let t=_e(d.value,e),n=d.value.name,r=d.value;ge();try{await ue(n,{property:t})}catch(e){d.value=r,console.error(`[ChatBot] Failed to submit shortcut:`,e),o(`error`,e)}},ye=()=>{if(!N){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}N.stopGeneration(),o(`stop`)},be=async e=>{if(!M){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await M.switchSession(e),o(`session-switched`,M.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),o(`error`,e)}},xe=e=>{I.value=e},Se=()=>{u.value?.focus?.()};return(0,t.onMounted)(async()=>{if(!(!g||m.value))try{if(j){if(await g.agent.getAgentInfo(),await g.session.getSessions(),a.sessionCode)await g.session.chooseSession(a.sessionCode);else if(g.session.list.value.length>0){let e=g.session.list.value[0];await g.session.chooseSession(e.sessionCode)}p.value=!0}else p.value=!0;o(`agent-info-loaded`,g)}catch(e){console.error(`Failed to initialize ChatBot:`,e),m.value=e,o(`error`,e)}}),(0,t.onBeforeUnmount)(()=>{j&&g&&g.agent.stopChat(g.session.current?.value?.sessionCode??``)}),n({sendMessage:e=>fe(e,[[]]),stopGeneration:ye,switchSession:be,messages:L,currentSession:te,isGenerating:ee,getChatHelper:()=>g,setCiteText:xe,focusInput:Se,selectShortcut:(e,t)=>{he(e,t)}}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:(0,t.normalizeClass)([`ai-chatbot`,a.extCls,{"welcome-state":z.value}]),style:(0,t.normalizeStyle)(ie.value)},[(0,t.createCommentVNode)(` 初始化错误提示 `),m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Ixt,[(0,t.createElementVNode)(`span`,null,(0,t.toDisplayString)(m.value.message),1)])):j&&!p.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 独立模式:初始化中(getAgentInfo → getSessions → chooseSession)统一展示 Loading `),(0,t.createElementVNode)(`div`,Lxt,[(0,t.createVNode)((0,t.unref)(i.Loading),{mode:`spin`,size:`small`,theme:`primary`})])],2112)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[(0,t.createCommentVNode)(` 内容区:欢迎状态 `),z.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Rxt,[(0,t.createElementVNode)(`div`,zxt,[n[3]||=(0,t.createElementVNode)(`h2`,{class:`welcome-title`},`你好,我是小鲸`,-1),B.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Bxt,[(0,t.createVNode)((0,t.unref)(o9),{content:B.value},null,8,[`content`])])):(0,t.createCommentVNode)(`v-if`,!0)])])):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 内容区:消息列表 `),(0,t.createElementVNode)(`div`,{ref_key:`messagesContainerRef`,ref:l,class:`chatbot-messages`},[R.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Vxt,[(0,t.createVNode)((0,t.unref)(i.Loading),{mode:`spin`,size:`small`,theme:`primary`})])):((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(zbt),{key:1,"selected-messages":f.value,"onUpdate:selectedMessages":n[0]||=e=>f.value=e,"enable-selection":a.enableSelection,"message-status":_.value,"message-tools-status":v.value,messages:L.value,"on-agent-action":y,"on-agent-feedback":b,"on-user-action":C,"on-user-input-confirm":E,"on-user-shortcut-confirm":D,onStopStreaming:A},null,8,[`selected-messages`,`enable-selection`,`message-status`,`message-tools-status`,`messages`]))],512)],2112)),(0,t.createCommentVNode)(` 统一底部区域 `),!z.value&&a.enableSelection?((0,t.openBlock)(),(0,t.createBlock)(Fxt,{key:2,"is-all-selected":f.value.length===L.value.length,loading:a.shareLoading,"selected-count":f.value.length,onCancel:oe,onConfirm:V,onToggleAll:se},null,8,[`is-all-selected`,`loading`,`selected-count`])):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Hxt,[d.value?.components?.length?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Be),(0,t.mergeProps)({key:0},d.value,{onClose:ge,onSubmit:ve}),null,16)):(0,t.renderSlot)(e.$slots,`input`,{key:1},()=>[(0,t.createVNode)((0,t.unref)(Eyt),{ref_key:`chatInputRef`,ref:u,modelValue:F.value,"onUpdate:modelValue":n[1]||=e=>F.value=e,cite:I.value,"onUpdate:cite":n[2]||=e=>I.value=e,"message-status":_.value,"on-send-message":fe,"on-stop-sending":pe,"on-upload":de,placeholder:a.placeholder,prompts:re.value,resources:ne.value,"shortcut-id":d.value?.id,shortcuts:ae.value,onSelectShortcut:me},null,8,[`modelValue`,`cite`,`message-status`,`placeholder`,`prompts`,`resources`,`shortcut-id`,`shortcuts`])])]))],64))],6))}});let H9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function Wxt(e){let{url:n,requestOptions:r,autoInit:i=!0,protocolCallbacks:a}=e,o=(0,t.toValue)(n);if(!o)throw Error(`[useChatBootstrap] url is required`);let l=(0,t.ref)(H9.IDLE),u=(0,t.ref)(null),d=(0,t.ref)(!1),f=new Map,p=new s.AGUIProtocol({onStart:()=>{a?.onStart?.()},onMessage:e=>{a?.onMessage?.(e)},onDone:()=>{a?.onDone?.()},onError:e=>{a?.onError?.(e)}}),m=(0,s.useChatHelper)({requestData:{urlPrefix:o,headers:r?.headers,data:r?.data},protocol:p});p.injectMessageModule(m.message);let h=(0,t.computed)(()=>l.value===H9.LOADING_AGENT),g=(0,t.computed)(()=>l.value===H9.READY),_=(0,t.computed)(()=>m.agent.info.value??null),v=(0,t.computed)(()=>_.value?.agentName??``),y=(0,t.computed)(()=>m.session.current.value??null),b=(0,t.computed)(()=>m.session.list.value??[]),x=async()=>{if(!d.value&&!h.value){u.value=null;try{l.value=H9.LOADING_AGENT,await Promise.all([m.agent.getAgentInfo(),m.session.getSessions()]),l.value=H9.READY,d.value=!0}catch(e){throw console.error(`[useChatBootstrap] Initialization failed:`,e),u.value=e,l.value=H9.ERROR,e}}},S=async()=>{l.value=H9.IDLE,u.value=null,d.value=!1,await x()},C=async e=>{l.value=H9.IDLE,u.value=null,d.value=!1;let t=m.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await x()};return(0,t.watch)(()=>(0,t.toValue)(n),(e,t)=>{e&&e!==t&&t&&C(e)}),i&&Promise.resolve().then(()=>{x()}),{chatHelper:m,protocol:p,phase:l,isInitializing:h,isReady:g,error:u,agentInfo:_,agentName:v,currentSession:y,sessionList:b,initialize:x,retry:S,updateConfig:C,registerExtension:(e,t)=>{f.set(e,t)},getExtension:e=>f.get(e)}}function Gxt(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function Kxt(e){let{componentManager:n,emit:r,debug:i=!1}=e,a=[],o=()=>{for(let[e,t]of Object.entries(Oxt)){if(t===null)continue;let o=n.on(e,n=>{let a=kxt(e,n);i&&console.debug(`[useEventBridge] ${e} -> ${t}`,a),r(t,...a)});a.push(o)}},s=(e,t)=>{i&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,t),n.emit(e,t)},l=(e,...t)=>{i&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),r(e,...t)},u=()=>{a.forEach(e=>e()),a.length=0};return o(),(0,t.onUnmounted)(()=>{u()}),{forwardToManager:s,emitDirect:l,cleanup:u}}function qxt(e,n=!1){let r=window.innerHeight-48-40,i=window.innerWidth-48-16,a=(0,t.ref)(i),o=(0,t.ref)(r),s=(0,t.ref)(0),l=(0,t.ref)(n),u=(0,t.ref)(!1),d=(0,t.ref)(!1),f=0,p=e=>{e?a.value=window.innerWidth-12:a.value=i},m=(e,t)=>{o.value=t,s.value=t-r},h=()=>{(0,t.nextTick)(()=>{o.value=window.innerHeight-48-40+s.value,l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-48-16})};return(0,t.onMounted)(()=>{window.addEventListener(`resize`,h),h()}),(0,t.onUnmounted)(()=>{window.removeEventListener(`resize`,h)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:a,nimbusTop:o,isMinimize:l,isHovering:u,isDragging:d,handleNimbusDragging:m,handleNimbusMinimize:p,handleClick:()=>{if(d.value){d.value=!1;return}e(`click`)},handleMinimize:()=>{l.value=!l.value,e(`minimize`,l.value),l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-60},handleDragging:(e,t)=>{a.value=e,o.value=t},handleMouseEnter:()=>{u.value=!0},handleMouseLeave:()=>{u.value=!1},handleMouseDown:()=>{f=Date.now(),d.value=!1},handleMouseUp:()=>{Date.now()-f>200&&(d.value=!0)}}}function Jxt(e={}){let n=(0,t.ref)([]),r=(t,r,i={})=>{try{let o=typeof t==`string`?document.querySelector(t):t;if(!o)return console.warn(`Tooltip target not found: ${t}`),null;let s=(0,a.default)(o,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return n.value.push(s),s}catch(e){return console.error(`Failed to create tooltip:`,e),null}},i=(e,t,n={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=r(e,t,n);i&&a.push(i)}),a},o=e=>{let t=[];return e.forEach(({element:e,content:n,options:i})=>{let a=r(e,n,i);a&&t.push(a)}),t},s=()=>{n.value.forEach(e=>{e.destroy()}),n.value=[]};return(0,t.onBeforeUnmount)(()=>{s()}),{instances:n,createTooltip:r,createTooltipsForSelector:i,createMultipleTooltips:o,destroyAll:s,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}let Yxt={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:z9(`输入 "/" 唤出 Prompt
2821
+ `),Se();return}if(e.id===`rebuild`){await S(t);return}if(e.id===`delete`){await x(t);return}if(e.id===`share`){o(`request-share`);return}if(e.id===`like`||e.id===`unlike`){let t=e.id===`like`?5:0;try{return await g?.session.getSessionFeedbackReasons(t)||[]}catch(e){return console.error(`[ChatBot] Failed to get feedback reasons:`,e),[]}}console.log(`handleAgentAction`,e,t)},b=async(e,t,n,r)=>{if(!g){console.error(`[ChatBot] Cannot submit feedback: chatHelper not initialized`);return}let i=g.session.current?.value?.sessionCode;if(!i){console.error(`[ChatBot] Cannot submit feedback: no active session`);return}let a=Vbt(N?.messages.value||[],t[0]);if(a===void 0){console.error(`[ChatBot] Cannot submit feedback: no user message found`);return}let s=e.id===`like`?5:0;try{await g.session.postSessionFeedback({sessionCode:i,sessionContentIds:[a],rate:s,labels:n,comment:r}),o(`feedback`,e,t[0],n,r)}catch(e){console.error(`[ChatBot] Failed to submit feedback:`,e),o(`error`,e)}},x=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot delete messages: chatBusinessManager not initialized`);return}try{let t=N.messages.value,n=R9(t,e[0]);if(!n){console.error(`[ChatBot] No user message found before AI messages`);return}let r=[n,...e];await g.message.deleteMessages(r)}catch(e){console.error(`[ChatBot] Failed to delete messages:`,e),o(`error`,e)}},S=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot regenerate: chatBusinessManager not initialized`);return}let t=g.session.current?.value?.sessionCode;if(!t){console.error(`[ChatBot] Cannot regenerate: no active session`);return}try{await N.regenerateFromAIMessages(e,t),le()}catch(e){console.error(`[ChatBot] Failed to regenerate:`,e),o(`error`,e)}},C=async(e,t)=>{if(e.id===`delete`){await k(t);return}if(e.id===`cite`){I.value=typeof t.content==`string`?t.content:JSON.stringify(t.content||``),Se();return}console.log(`handleUserAction`,e,t)},E=async(e,t,n)=>{if(!g){console.error(`[ChatBot] Cannot edit message: chatHelper not initialized`);return}let r=g.session.current?.value?.sessionCode;if(!r){console.error(`[ChatBot] Cannot edit message: no active session`);return}let i=e.id;if(i===void 0){console.error(`[ChatBot] Cannot edit message: message has no id`);return}try{console.log(`handleUserInputConfirm`,i,r,t),await g.agent.resendMessage(String(i),r,t),le()}catch(e){console.error(`[ChatBot] Failed to edit and resend message:`,e),o(`error`,e)}},D=async(e,t)=>{if(!N||!g){console.error(`[ChatBot] Cannot edit shortcut message: chatHelper not initialized`);return}let n=g.session.current?.value?.sessionCode;if(!n){console.error(`[ChatBot] Cannot edit shortcut message: no active session`);return}let r=e.id;if(r===void 0){console.error(`[ChatBot] Cannot edit shortcut message: message has no id`);return}try{let i=O(e);if(!i){console.error(`[ChatBot] Cannot edit shortcut message: shortcut not found`);return}let a=_e(i,t),o=String(t.input??``);await N.resendMessageWithProperty(String(r),n,o,a),le()}catch(e){console.error(`[ChatBot] Failed to edit shortcut message:`,e),o(`error`,e)}},O=e=>{let t=e.property?.extra;return t?.shortcut?t.shortcut:t?.command?ce.value.find(e=>e.id===t.command)??null:null},k=async e=>{if(!N||!g){console.error(`[ChatBot] Cannot delete message: chatHelper not initialized`);return}try{let t=N.messages.value,n=t.findIndex(t=>t===e);if(n===-1){console.error(`[ChatBot] User message not found in messages list`);return}let r=[];for(let e=n+1;e<t.length;e++){let n=t[e];if(n.role===w.User)break;r.push(n)}let i=[e,...r];await g.message.deleteMessages(i)}catch(e){console.error(`[ChatBot] Failed to delete user message:`,e),o(`error`,e)}},A=async()=>{((a.chatHelper||g)?.agent)?.stopChat?.(g?.session.current?.value?.sessionCode??``)},j=!a.chatHelper,M=g?new B9(g.session,g.message,null,{enableChatSession:!0,autoSwitchToInitialSession:!!a.sessionCode,loadRecentSessionOnMount:a.autoLoad,initialSessionCode:a.sessionCode}):null,N=g?new wxt(g.agent,g.message,g.session,null,{openingRemark:a.helloText,predefinedQuestions:a.prompts,placeholder:a.placeholder}):null,P=new V9(null,a.shortcuts||[]),F=(0,t.shallowRef)([[]]),I=(0,t.ref)(``),L=(0,t.computed)(()=>N?.messages.value??[]),R=(0,t.computed)(()=>N?.isMessagesLoading.value??!1),ee=(0,t.computed)(()=>N?.isGenerating.value??!1),te=(0,t.computed)(()=>M?.currentSession.value??null),z=(0,t.computed)(()=>j&&!p.value?!1:!R.value&&L.value.length===0),B=(0,t.computed)(()=>g?.agent.info.value?.conversationSettings?.openingRemark||``),ne=(0,t.computed)(()=>a.resources?.length?a.resources:Ubt(g?.agent.info.value?.resources)),re=(0,t.computed)(()=>a.prompts?.length?a.prompts:g?.agent.info.value?.conversationSettings?.predefinedQuestions??[]),ie=(0,t.computed)(()=>({height:typeof a.height==`number`?`${a.height}px`:a.height,maxWidth:typeof a.maxWidth==`number`?`${a.maxWidth}px`:a.maxWidth})),ae=(0,t.computed)(()=>{let e=P.shortcuts.value;return a.shortcutLimit&&e.length>a.shortcutLimit?e.slice(0,a.shortcutLimit):e}),oe=()=>{f.value=[],o(`cancel-share`)},V=()=>{o(`confirm-share`,f.value)},se=e=>{e?f.value=L.value:f.value=[]},ce=P.effectiveShortcuts;(0,t.watch)(()=>a.shortcuts,e=>{P.setShortcuts(e||[])},{immediate:!0}),(0,t.watch)(()=>g?.agent.info.value?.conversationSettings?.commands,e=>{e&&P.setAgentShortcuts(e)},{immediate:!0});let le=async()=>{await(0,t.nextTick)(),l.value&&(l.value.scrollTop=l.value.scrollHeight)},ue=async(e,t={})=>{if(!N||!g)throw Error(`[ChatBot] Cannot send message: chatBusinessManager not initialized`);let n=g.session.current?.value?.sessionCode;if(!n)throw Error(`[ChatBot] Cannot send message: no active session`);F.value=[[]],I.value=``,o(`send-message`,typeof e==`string`?e:``),await N.sendMessage(e,n,t)},de=async e=>{let t=g?.session.current?.value?.sessionCode;if(!t)throw Error(`[ChatBot] Cannot upload: no active session`);let n=await g.session.uploadFile(t,e);if(!n?.download_url)throw Error(`[ChatBot] Upload failed: no download URL returned`);return n},fe=async(e,t)=>{try{await ue(e,I.value?{property:{extra:{cite:I.value}}}:{})}catch(e){console.error(`Failed to send message:`,e),o(`error`,e)}},pe=async()=>{ye()},me=(e,t)=>{he(e,t),o(`shortcut-click`,{shortcut:e,source:`main`})},he=(e,t)=>{let n=e,r=n.components?.find(e=>e.fillBack)?.key||`input`;d.value={...n,formModel:{...n.formModel,[r]:t||``}}},ge=()=>{d.value=null},_e=(e,t)=>{let n=e.components||[];return{extra:{cite:{type:`structured`,title:e.name,data:n.map(e=>({key:e.name||e.key,value:String(t[e.key]??``)}))},command:e.id,context:n.map(e=>({[e.key]:t[e.key],context_type:e.type,__label:e.name||e.key,__key:e.key,__value:t[e.key]}))}}},ve=async e=>{if(!d.value){console.error(`[ChatBot] No selected shortcut`);return}let t=_e(d.value,e),n=d.value.name,r=d.value;ge();try{await ue(n,{property:t})}catch(e){d.value=r,console.error(`[ChatBot] Failed to submit shortcut:`,e),o(`error`,e)}},ye=()=>{if(!N){console.error(`[ChatBot] Cannot stop generation: chatBusinessManager not initialized`);return}N.stopGeneration(),o(`stop`)},be=async e=>{if(!M){console.error(`[ChatBot] Cannot switch session: sessionBusinessManager not initialized`);return}try{await M.switchSession(e),o(`session-switched`,M.currentSession.value)}catch(e){console.error(`Failed to switch session:`,e),o(`error`,e)}},xe=e=>{I.value=e},Se=()=>{u.value?.focus?.()};return(0,t.onMounted)(async()=>{if(!(!g||m.value))try{if(j){if(await g.agent.getAgentInfo(),await g.session.getSessions(),a.sessionCode)await g.session.chooseSession(a.sessionCode);else if(g.session.list.value.length>0){let e=g.session.list.value[0];await g.session.chooseSession(e.sessionCode)}p.value=!0}else p.value=!0;o(`agent-info-loaded`,g)}catch(e){console.error(`Failed to initialize ChatBot:`,e),m.value=e,o(`error`,e)}}),(0,t.onBeforeUnmount)(()=>{j&&g&&g.agent.stopChat(g.session.current?.value?.sessionCode??``)}),n({sendMessage:e=>fe(e,[[]]),stopGeneration:ye,switchSession:be,messages:L,currentSession:te,isGenerating:ee,getChatHelper:()=>g,setCiteText:xe,focusInput:Se,selectShortcut:(e,t)=>{he(e,t)}}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:(0,t.normalizeClass)([`ai-chatbot`,a.extCls,{"welcome-state":z.value}]),style:(0,t.normalizeStyle)(ie.value)},[(0,t.createCommentVNode)(` 初始化错误提示 `),m.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Ixt,[(0,t.createElementVNode)(`span`,null,(0,t.toDisplayString)(m.value.message),1)])):j&&!p.value?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 独立模式:初始化中(getAgentInfo → getSessions → chooseSession)统一展示 Loading `),(0,t.createElementVNode)(`div`,Lxt,[(0,t.createVNode)((0,t.unref)(i.Loading),{mode:`spin`,size:`small`,theme:`primary`})])],2112)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[(0,t.createCommentVNode)(` 内容区:欢迎状态 `),z.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Rxt,[(0,t.createElementVNode)(`div`,zxt,[n[3]||=(0,t.createElementVNode)(`h2`,{class:`welcome-title`},`你好,我是小鲸`,-1),B.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Bxt,[(0,t.createVNode)((0,t.unref)(o9),{content:B.value},null,8,[`content`])])):(0,t.createCommentVNode)(`v-if`,!0)])])):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[(0,t.createCommentVNode)(` 内容区:消息列表 `),(0,t.createElementVNode)(`div`,{ref_key:`messagesContainerRef`,ref:l,class:`chatbot-messages`},[R.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Vxt,[(0,t.createVNode)((0,t.unref)(i.Loading),{mode:`spin`,size:`small`,theme:`primary`})])):((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(zbt),{key:1,"selected-messages":f.value,"onUpdate:selectedMessages":n[0]||=e=>f.value=e,"enable-selection":a.enableSelection,"message-status":_.value,"message-tools-status":v.value,messages:L.value,"on-agent-action":y,"on-agent-feedback":b,"on-user-action":C,"on-user-input-confirm":E,"on-user-shortcut-confirm":D,onStopStreaming:A},null,8,[`selected-messages`,`enable-selection`,`message-status`,`message-tools-status`,`messages`]))],512)],2112)),(0,t.createCommentVNode)(` 统一底部区域 `),!z.value&&a.enableSelection?((0,t.openBlock)(),(0,t.createBlock)(Fxt,{key:2,"is-all-selected":f.value.length===L.value.length,loading:a.shareLoading,"selected-count":f.value.length,onCancel:oe,onConfirm:V,onToggleAll:se},null,8,[`is-all-selected`,`loading`,`selected-count`])):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Hxt,[d.value?.components?.length?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Be),(0,t.mergeProps)({key:0},d.value,{onClose:ge,onSubmit:ve}),null,16)):(0,t.renderSlot)(e.$slots,`input`,{key:1},()=>[(0,t.createVNode)((0,t.unref)(Eyt),{ref_key:`chatInputRef`,ref:u,modelValue:F.value,"onUpdate:modelValue":n[1]||=e=>F.value=e,cite:I.value,"onUpdate:cite":n[2]||=e=>I.value=e,"message-status":_.value,"on-send-message":fe,"on-stop-sending":pe,"on-upload":de,placeholder:a.placeholder,prompts:re.value,resources:ne.value,"shortcut-id":d.value?.id,shortcuts:ae.value,onSelectShortcut:me},null,8,[`modelValue`,`cite`,`message-status`,`placeholder`,`prompts`,`resources`,`shortcut-id`,`shortcuts`])])]))],64))],6))}});let H9=function(e){return e.ERROR=`error`,e.IDLE=`idle`,e.LOADING_AGENT=`loading_agent`,e.READY=`ready`,e}({});function Wxt(e){let{url:n,requestOptions:r,autoInit:i=!0,protocolCallbacks:a}=e,o=(0,t.toValue)(n);if(!o)throw Error(`[useChatBootstrap] url is required`);let l=(0,t.ref)(H9.IDLE),u=(0,t.ref)(null),d=(0,t.ref)(!1),f=new Map,p=new s.AGUIProtocol({onStart:()=>{a?.onStart?.()},onMessage:e=>{a?.onMessage?.(e)},onDone:()=>{a?.onDone?.()},onError:e=>{a?.onError?.(e)}}),m=(0,s.useChatHelper)({requestData:{urlPrefix:o,headers:r?.headers,data:r?.data},protocol:p});p.injectMessageModule(m.message);let h=(0,t.computed)(()=>l.value===H9.LOADING_AGENT),g=(0,t.computed)(()=>l.value===H9.READY),_=(0,t.computed)(()=>m.agent.info.value??null),v=(0,t.computed)(()=>_.value?.agentName??``),y=(0,t.computed)(()=>m.session.current.value??null),b=(0,t.computed)(()=>m.session.list.value??[]),x=async()=>{if(!d.value&&!h.value){u.value=null;try{l.value=H9.LOADING_AGENT,await Promise.all([m.agent.getAgentInfo(),m.session.getSessions()]),l.value=H9.READY,d.value=!0}catch(e){throw console.error(`[useChatBootstrap] Initialization failed:`,e),u.value=e,l.value=H9.ERROR,e}}},S=async()=>{l.value=H9.IDLE,u.value=null,d.value=!1,await x()},C=async e=>{l.value=H9.IDLE,u.value=null,d.value=!1;let t=m.http;t?.updateConfig?t.updateConfig({urlPrefix:e}):console.warn(`[useChatBootstrap] chatHelper.http.updateConfig is not implemented yet, URL change may not take effect`),await x()};return(0,t.watch)(()=>(0,t.toValue)(n),(e,t)=>{e&&e!==t&&t&&C(e)}),i&&Promise.resolve().then(()=>{x()}),{chatHelper:m,protocol:p,phase:l,isInitializing:h,isReady:g,error:u,agentInfo:_,agentName:v,currentSession:y,sessionList:b,initialize:x,retry:S,updateConfig:C,registerExtension:(e,t)=>{f.set(e,t)},getExtension:e=>f.get(e)}}function Gxt(e){return{sendMessage:t=>e(`send-message`,{content:t}),receiveStart:()=>e(`receive-start`,{}),receiveText:()=>e(`receive-text`,{}),receiveEnd:()=>e(`receive-end`,{}),stop:()=>e(`stop`,{}),newChat:()=>e(`new-chat`,{}),historyClick:t=>e(`history-click`,{event:t}),autoGenerateName:()=>e(`auto-generate-name`,{}),helpClick:()=>e(`help-click`,{}),rename:t=>e(`rename`,{newName:t}),share:()=>e(`share`,{}),transferMessages:t=>e(`transfer-messages`,{messageIds:t}),shareMessages:t=>e(`share-messages`,{messageIds:t})}}function Kxt(e){let{componentManager:n,emit:r,debug:i=!1}=e,a=[],o=()=>{for(let[e,t]of Object.entries(Oxt)){if(t===null)continue;let o=n.on(e,n=>{let a=kxt(e,n);i&&console.debug(`[useEventBridge] ${e} -> ${t}`,a),r(t,...a)});a.push(o)}},s=(e,t)=>{i&&console.debug(`[useEventBridge] Forwarding to manager: ${e}`,t),n.emit(e,t)},l=(e,...t)=>{i&&console.debug(`[useEventBridge] Direct emit: ${e}`,t),r(e,...t)},u=()=>{a.forEach(e=>e()),a.length=0};return o(),(0,t.onUnmounted)(()=>{u()}),{forwardToManager:s,emitDirect:l,cleanup:u}}function qxt(e,n=!1){let r=window.innerHeight-48-40,i=window.innerWidth-48-16,a=(0,t.ref)(i),o=(0,t.ref)(r),s=(0,t.ref)(0),l=(0,t.ref)(n),u=(0,t.ref)(!1),d=(0,t.ref)(!1),f=0,p=e=>{e?a.value=window.innerWidth-12:a.value=i},m=(e,t)=>{o.value=t,s.value=t-r},h=()=>{(0,t.nextTick)(()=>{o.value=window.innerHeight-48-40+s.value,l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-48-16})};return(0,t.onMounted)(()=>{window.addEventListener(`resize`,h),h()}),(0,t.onUnmounted)(()=>{window.removeEventListener(`resize`,h)}),{nimbusWidth:48,nimbusHeight:48,nimbusLeft:a,nimbusTop:o,isMinimize:l,isHovering:u,isDragging:d,handleNimbusDragging:m,handleNimbusMinimize:p,handleClick:()=>{if(d.value){d.value=!1;return}e(`click`)},handleMinimize:()=>{l.value=!l.value,e(`minimize`,l.value),l.value?a.value=window.innerWidth-12:a.value=window.innerWidth-60},handleDragging:(e,t)=>{a.value=e,o.value=t},handleMouseEnter:()=>{u.value=!0},handleMouseLeave:()=>{u.value=!1},handleMouseDown:()=>{f=Date.now(),d.value=!1},handleMouseUp:()=>{Date.now()-f>200&&(d.value=!0)}}}function Jxt(e={}){let n=(0,t.ref)([]),r=(t,r,i={})=>{try{let o=typeof t==`string`?document.querySelector(t):t;if(!o)return console.warn(`Tooltip target not found: ${t}`),null;let s=(0,a.default)(o,{content:r,placement:`top`,arrow:!0,delay:[300,0],theme:`ai-blueking-tooltip`,...e,...i});return n.value.push(s),s}catch(e){return console.error(`Failed to create tooltip:`,e),null}},i=(e,t,n={})=>{let i=document.querySelectorAll(e),a=[];return i.forEach(e=>{let i=r(e,t,n);i&&a.push(i)}),a},o=e=>{let t=[];return e.forEach(({element:e,content:n,options:i})=>{let a=r(e,n,i);a&&t.push(a)}),t},s=()=>{n.value.forEach(e=>{e.destroy()}),n.value=[]};return(0,t.onBeforeUnmount)(()=>{s()}),{instances:n,createTooltip:r,createTooltipsForSelector:i,createMultipleTooltips:o,destroyAll:s,updateContent:(e,t)=>{e.setContent(t)},destroyInstance:e=>{e.destroy()}}}let Yxt={url:``,title:``,extCls:``,hideNimbus:!1,hideHeader:!1,enablePopup:!0,draggable:!0,enableChatSession:!0,defaultWidth:400,defaultHeight:void 0,defaultTop:0,defaultLeft:void 0,maxWidth:1e3,miniPadding:0,nimbusSize:`normal`,defaultMinimize:!1,shortcuts:()=>[],shortcutLimit:3,shortcutFilter:void 0,hideDefaultTrigger:!1,requestOptions:()=>({}),teleportTo:`body`,placeholder:z9(`输入 "/" 唤出 Prompt
2822
2822
  通过 Shift + Enter 进行换行输入`),helloText:z9(`你好,我是小鲸`),disabledInput:!1,showHistoryIcon:!0,showNewChatIcon:!0,showCompressionIcon:!0,showMoreIcon:!0,initialSessionCode:``,autoSwitchToInitialSession:!1,loadRecentSessionOnMount:!0,prompts:()=>[],dropdownMenuConfig:()=>({showRename:!0,showAutoGenerate:!0,showShare:!0}),defaultChatInputPosition:void 0};var Xxt=class extends s.AGUIProtocol{eventEmitter;constructor(e={}){super({onStart:e.onStart,onMessage:e.onMessage,onDone:e.onDone,onError:e.onError}),this.eventEmitter=e.eventEmitter}handleRunErrorEvent(e){super.handleRunErrorEvent(e),this.eventEmitter?.emit(`run-error`,{event:e})}handleTextMessageChunkEvent(e){super.handleTextMessageChunkEvent(e),this.eventEmitter?.emit(`text-chunk`,{event:e})}handleThinkingEndEvent(e){super.handleThinkingEndEvent(e),this.eventEmitter?.emit(`thinking-end`,{event:e})}handleThinkingStartEvent(e){super.handleThinkingStartEvent(e),this.eventEmitter?.emit(`thinking-start`,{event:e})}handleToolCallEndEvent(e){super.handleToolCallEndEvent(e),this.eventEmitter?.emit(`tool-call-end`,{event:e})}handleToolCallStartEvent(e){super.handleToolCallStartEvent(e),this.eventEmitter?.emit(`tool-call-start`,{event:e})}};function Zxt(e={}){let{eventEmitter:t,onStart:n,onMessage:r,onDone:i,onError:a,onTextChunk:o}=e;return new s.AGUIProtocol({onStart:()=>{t?.emit(`receive-start`,{}),n?.()},onMessage:e=>{t?.emit(`receive-message`,{event:e}),e.type===`TextMessageChunk`&&o&&o(e),r?.(e)},onDone:()=>{t?.emit(`receive-end`,{}),i?.()},onError:e=>{t?.emit(`receive-error`,{error:e}),a?.(e)}})}function Qxt(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function U9(e,t,n,r=1){let[i,a]=typeof r==`number`?[r,r]:r;return[Math.round(t/i/e[0])*e[0],Math.round(n/a/e[1])*e[1]]}function W9(e,t,n){return e-t-n}function G9(e,t,n){return e-t-n}function K9(e,t,n){return t!==null&&e<t?t:n!==null&&n<e?n:e}function $xt(e,t,n){let r=e,i=[`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`].find(e=>Qxt(r[e]));if(!Qxt(r[i]))return!1;do{if(r[i](t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function eSt(e){let t=window.getComputedStyle(e);return[parseFloat(t.getPropertyValue(`width`),10),parseFloat(t.getPropertyValue(`height`),10)]}function q9(e,t,n){e&&(e.attachEvent?e.attachEvent(`on`+t,n):e.addEventListener?e.addEventListener(t,n,!0):e[`on`+t]=n)}function J9(e,t,n){e&&(e.detachEvent?e.detachEvent(`on`+t,n):e.removeEventListener?e.removeEventListener(t,n,!0):e[`on`+t]=null)}var tSt=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},Y9={mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`},touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`}},nSt={userSelect:`none`,MozUserSelect:`none`,WebkitUserSelect:`none`,MsUserSelect:`none`},rSt={userSelect:`auto`,MozUserSelect:`auto`,WebkitUserSelect:`auto`,MsUserSelect:`auto`},X9=Y9.mouse,iSt={replace:!0,name:`vue-draggable-resizable`,props:{className:{type:String,default:`vdr`},classNameDraggable:{type:String,default:`draggable`},classNameResizable:{type:String,default:`resizable`},classNameDragging:{type:String,default:`dragging`},classNameResizing:{type:String,default:`resizing`},classNameActive:{type:String,default:`active`},classNameHandle:{type:String,default:`handle`},disableUserSelect:{type:Boolean,default:!0},enableNativeDrag:{type:Boolean,default:!1},preventDeactivation:{type:Boolean,default:!1},active:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},lockAspectRatio:{type:Boolean,default:!1},w:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},h:{type:[Number,String],default:200,validator:e=>typeof e==`number`?e>0:e===`auto`},minWidth:{type:Number,default:0,validator:e=>e>=0},minHeight:{type:Number,default:0,validator:e=>e>=0},maxWidth:{type:Number,default:null,validator:e=>e>=0},maxHeight:{type:Number,default:null,validator:e=>e>=0},x:{type:Number,default:0},y:{type:Number,default:0},z:{type:[String,Number],default:`auto`,validator:e=>typeof e==`string`?e===`auto`:e>=0},handles:{type:Array,default:()=>[`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`],validator:e=>{let t=new Set([`tl`,`tm`,`tr`,`mr`,`br`,`bm`,`bl`,`ml`]);return new Set(e.filter(e=>t.has(e))).size===e.length}},dragHandle:{type:String,default:null},dragCancel:{type:String,default:null},axis:{type:String,default:`both`,validator:e=>[`x`,`y`,`both`].includes(e)},grid:{type:Array,default:()=>[1,1]},parent:{type:Boolean,default:!1},scale:{type:[Number,Array],default:1,validator:e=>typeof e==`number`?e>0:e.length===2&&e[0]>0&&e[1]>0},onDragStart:{type:Function,default:()=>!0},onDrag:{type:Function,default:()=>!0},onResizeStart:{type:Function,default:()=>!0},onResize:{type:Function,default:()=>!0}},data:function(){return{left:this.x,top:this.y,right:null,bottom:null,width:null,height:null,widthTouched:!1,heightTouched:!1,aspectFactor:null,parentWidth:null,parentHeight:null,handle:null,enabled:this.active,resizing:!1,dragging:!1,dragEnable:!1,resizeEnable:!1,zIndex:this.z}},created:function(){this.maxWidth&&this.minWidth>this.maxWidth&&console.warn(`[Vdr warn]: Invalid prop: minWidth cannot be greater than maxWidth`),this.maxHeight&&this.minHeight>this.maxHeight&&console.warn(`[Vdr warn]: Invalid prop: minHeight cannot be greater than maxHeight`),this.resetBoundsAndMouseState()},mounted:function(){this.enableNativeDrag||(this.$el.ondragstart=()=>!1);let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t;let[n,r]=eSt(this.$el);this.aspectFactor=(this.w===`auto`?n:this.w)/(this.h===`auto`?r:this.h),this.width=this.w===`auto`?n:this.w,this.height=this.h===`auto`?r:this.h,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top,this.active&&this.$emit(`activated`),q9(document.documentElement,`mousedown`,this.deselect),q9(document.documentElement,`touchend touchcancel`,this.deselect),q9(window,`resize`,this.checkParentSize)},beforeUnmount:function(){J9(document.documentElement,`mousedown`,this.deselect),J9(document.documentElement,`touchstart`,this.handleUp),J9(document.documentElement,`mousemove`,this.move),J9(document.documentElement,`touchmove`,this.move),J9(document.documentElement,`mouseup`,this.handleUp),J9(document.documentElement,`touchend touchcancel`,this.deselect),J9(window,`resize`,this.checkParentSize)},methods:{resetBoundsAndMouseState(){this.mouseClickPosition={mouseX:0,mouseY:0,x:0,y:0,w:0,h:0},this.bounds={minLeft:null,maxLeft:null,minRight:null,maxRight:null,minTop:null,maxTop:null,minBottom:null,maxBottom:null}},checkParentSize(){if(this.parent){let[e,t]=this.getParentSize();this.parentWidth=e,this.parentHeight=t,this.right=this.parentWidth-this.width-this.left,this.bottom=this.parentHeight-this.height-this.top}},getParentSize(){if(this.parent){let e=window.getComputedStyle(this.$el.parentNode,null);return[parseInt(e.getPropertyValue(`width`),10),parseInt(e.getPropertyValue(`height`),10)]}return[null,null]},elementTouchDown(e){X9=Y9.touch,this.elementDown(e)},elementMouseDown(e){X9=Y9.mouse,this.elementDown(e)},elementDown(e){if(e instanceof MouseEvent&&e.button!==0)return;let t=e.target||e.srcElement;if(this.$el.contains(t)){if(this.onDragStart(e)===!1)return;if(this.dragHandle&&!$xt(t,this.dragHandle,this.$el)||this.dragCancel&&$xt(t,this.dragCancel,this.$el)){this.dragging=!1;return}this.enabled||(this.enabled=!0,this.$emit(`activated`),this.$emit(`update:active`,!0)),this.draggable&&(this.dragEnable=!0),this.mouseClickPosition.mouseX=e.touches?e.touches[0].pageX:e.pageX,this.mouseClickPosition.mouseY=e.touches?e.touches[0].pageY:e.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.parent&&(this.bounds=this.calcDragLimits()),q9(document.documentElement,X9.move,this.move),q9(document.documentElement,X9.stop,this.handleUp)}},calcDragLimits(){return{minLeft:this.left%this.grid[0],maxLeft:Math.floor((this.parentWidth-this.width-this.left)/this.grid[0])*this.grid[0]+this.left,minRight:this.right%this.grid[0],maxRight:Math.floor((this.parentWidth-this.width-this.right)/this.grid[0])*this.grid[0]+this.right,minTop:this.top%this.grid[1],maxTop:Math.floor((this.parentHeight-this.height-this.top)/this.grid[1])*this.grid[1]+this.top,minBottom:this.bottom%this.grid[1],maxBottom:Math.floor((this.parentHeight-this.height-this.bottom)/this.grid[1])*this.grid[1]+this.bottom}},deselect(e){let t=e.target||e.srcElement,n=RegExp(this.className+`-([trmbl]{2})`,``);!this.$el.contains(t)&&!n.test(t.className)&&(this.enabled&&!this.preventDeactivation&&(this.enabled=!1,this.$emit(`deactivated`),this.$emit(`update:active`,!1)),J9(document.documentElement,X9.move,this.handleResize)),this.resetBoundsAndMouseState()},handleTouchDown(e,t){X9=Y9.touch,this.handleDown(e,t)},handleDown(e,t){t instanceof MouseEvent&&t.which!==1||this.onResizeStart(e,t)!==!1&&(t.stopPropagation&&t.stopPropagation(),this.lockAspectRatio&&!e.includes(`m`)?this.handle=`m`+e.substring(1):this.handle=e,this.resizeEnable=!0,this.mouseClickPosition.mouseX=t.touches?t.touches[0].pageX:t.pageX,this.mouseClickPosition.mouseY=t.touches?t.touches[0].pageY:t.pageY,this.mouseClickPosition.left=this.left,this.mouseClickPosition.right=this.right,this.mouseClickPosition.top=this.top,this.mouseClickPosition.bottom=this.bottom,this.bounds=this.calcResizeLimits(),q9(document.documentElement,X9.move,this.handleResize),q9(document.documentElement,X9.stop,this.handleUp))},calcResizeLimits(){let e=this.minW,t=this.minH,n=this.maxW,r=this.maxH,i=this.aspectFactor,[a,o]=this.grid,s=this.width,l=this.height,u=this.left,d=this.top,f=this.right,p=this.bottom;this.lockAspectRatio&&(e/t>i?t=e/i:e=i*t,n&&r?(n=Math.min(n,i*r),r=Math.min(r,n/i)):n?r=n/i:r&&(n=i*r)),n-=n%a,r-=r%o;let m={minLeft:null,maxLeft:null,minTop:null,maxTop:null,minRight:null,maxRight:null,minBottom:null,maxBottom:null};return this.parent?(m.minLeft=u%a,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=d%o,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=f%a,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=p%o,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=Math.max(m.minLeft,this.parentWidth-f-n),m.minRight=Math.max(m.minRight,this.parentWidth-u-n)),r&&(m.minTop=Math.max(m.minTop,this.parentHeight-p-r),m.minBottom=Math.max(m.minBottom,this.parentHeight-d-r)),this.lockAspectRatio&&(m.minLeft=Math.max(m.minLeft,u-d*i),m.minTop=Math.max(m.minTop,d-u/i),m.minRight=Math.max(m.minRight,f-p*i),m.minBottom=Math.max(m.minBottom,p-f/i))):(m.minLeft=null,m.maxLeft=u+Math.floor((s-e)/a)*a,m.minTop=null,m.maxTop=d+Math.floor((l-t)/o)*o,m.minRight=null,m.maxRight=f+Math.floor((s-e)/a)*a,m.minBottom=null,m.maxBottom=p+Math.floor((l-t)/o)*o,n&&(m.minLeft=-(f+n),m.minRight=-(u+n)),r&&(m.minTop=-(p+r),m.minBottom=-(d+r)),this.lockAspectRatio&&n&&r&&(m.minLeft=Math.min(m.minLeft,-(f+n)),m.minTop=Math.min(m.minTop,-(r+p)),m.minRight=Math.min(m.minRight,-u-n),m.minBottom=Math.min(m.minBottom,-d-r))),m},move(e){this.resizing?this.handleResize(e):this.dragEnable&&this.handleDrag(e)},handleDrag(e){let t=this.axis,n=this.grid,r=this.bounds,i=this.mouseClickPosition,[a,o]=U9(n,t&&t!==`y`?i.mouseX-(e.touches?e.touches[0].pageX:e.pageX):0,t&&t!==`x`?i.mouseY-(e.touches?e.touches[0].pageY:e.pageY):0,this.scale),s=K9(i.left-a,r.minLeft,r.maxLeft),l=K9(i.top-o,r.minTop,r.maxTop);if(this.onDrag(s,l)===!1)return;let u=K9(i.right+a,r.minRight,r.maxRight),d=K9(i.bottom+o,r.minBottom,r.maxBottom);this.left=s,this.top=l,this.right=u,this.bottom=d,this.$emit(`dragging`,this.left,this.top),this.dragging=!0},moveHorizontally(e){let[t,n]=U9(this.grid,e,this.top,1),r=K9(t,this.bounds.minLeft,this.bounds.maxLeft);this.left=r,this.right=this.parentWidth-this.width-r},moveVertically(e){let[t,n]=U9(this.grid,this.left,e,1),r=K9(n,this.bounds.minTop,this.bounds.maxTop);this.top=r,this.bottom=this.parentHeight-this.height-r},handleResize(e){let t=this.left,n=this.top,r=this.right,i=this.bottom,a=this.mouseClickPosition,o=this.aspectFactor,s=a.mouseX-(e.touches?e.touches[0].pageX:e.pageX),l=a.mouseY-(e.touches?e.touches[0].pageY:e.pageY);!this.widthTouched&&s&&(this.widthTouched=!0),!this.heightTouched&&l&&(this.heightTouched=!0);let[u,d]=U9(this.grid,s,l,this.scale);this.handle.includes(`b`)?(i=K9(a.bottom+d,this.bounds.minBottom,this.bounds.maxBottom),this.lockAspectRatio&&this.resizingOnY&&(r=this.right-(this.bottom-i)*o)):this.handle.includes(`t`)&&(n=K9(a.top-d,this.bounds.minTop,this.bounds.maxTop),this.lockAspectRatio&&this.resizingOnY&&(t=this.left-(this.top-n)*o)),this.handle.includes(`r`)?(r=K9(a.right+u,this.bounds.minRight,this.bounds.maxRight),this.lockAspectRatio&&this.resizingOnX&&(i=this.bottom-(this.right-r)/o)):this.handle.includes(`l`)&&(t=K9(a.left-u,this.bounds.minLeft,this.bounds.maxLeft),this.lockAspectRatio&&this.resizingOnX&&(n=this.top-(this.left-t)/o));let f=W9(this.parentWidth,t,r),p=G9(this.parentHeight,n,i);this.onResize(this.handle,t,n,f,p)!==!1&&(this.left=t,this.top=n,this.right=r,this.bottom=i,this.width=f,this.height=p,this.$emit(`resizing`,this.left,this.top,this.width,this.height),this.resizing=!0)},changeWidth(e){let[t,n]=U9(this.grid,e,0,1),r=K9(this.parentWidth-t-this.left,this.bounds.minRight,this.bounds.maxRight),i=this.bottom;this.lockAspectRatio&&(i=this.bottom-(this.right-r)/this.aspectFactor);let a=W9(this.parentWidth,this.left,r),o=G9(this.parentHeight,this.top,i);this.right=r,this.bottom=i,this.width=a,this.height=o},changeHeight(e){let[t,n]=U9(this.grid,0,e,1),r=K9(this.parentHeight-n-this.top,this.bounds.minBottom,this.bounds.maxBottom),i=this.right;this.lockAspectRatio&&(i=this.right-(this.bottom-r)*this.aspectFactor);let a=W9(this.parentWidth,this.left,i),o=G9(this.parentHeight,this.top,r);this.right=i,this.bottom=r,this.width=a,this.height=o},handleUp(e){this.handle=null,this.resetBoundsAndMouseState(),this.dragEnable=!1,this.resizeEnable=!1,this.resizing&&(this.resizing=!1,this.$emit(`resizeStop`,this.left,this.top,this.width,this.height)),this.dragging&&(this.dragging=!1,this.$emit(`dragStop`,this.left,this.top)),J9(document.documentElement,X9.move,this.handleResize)}},computed:{style(){return{transform:`translate(${this.left}px, ${this.top}px)`,width:this.computedWidth,height:this.computedHeight,zIndex:this.zIndex,...this.dragging&&this.disableUserSelect?nSt:rSt}},actualHandles(){return this.resizable?this.handles:[]},computedWidth(){return this.w===`auto`&&!this.widthTouched?`auto`:this.width+`px`},computedHeight(){return this.h===`auto`&&!this.heightTouched?`auto`:this.height+`px`},minW(){return this.minWidth},minH(){return this.minHeight},maxW(){return this.maxWidth},maxH(){return this.maxHeight},resizingOnX(){return!!this.handle&&(this.handle.includes(`l`)||this.handle.includes(`r`))},resizingOnY(){return!!this.handle&&(this.handle.includes(`t`)||this.handle.includes(`b`))},isCornerHandle(){return!!this.handle&&[`tl`,`tr`,`br`,`bl`].includes(this.handle)}},watch:{active(e){this.enabled=e,e?this.$emit(`activated`):this.$emit(`deactivated`)},z(e){(e>=0||e===`auto`)&&(this.zIndex=e)},x(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveHorizontally(e))},y(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcDragLimits()),this.moveVertically(e))},lockAspectRatio(e){e?this.aspectFactor=this.width/this.height:this.aspectFactor=void 0},w(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeWidth(e))},h(e){this.resizing||this.dragging||(this.parent&&(this.bounds=this.calcResizeLimits()),this.changeHeight(e))}}},aSt=[`onMousedown`,`onTouchstart`];function oSt(e,n,r,i,a,o){return(0,t.openBlock)(),(0,t.createElementBlock)(`div`,{style:(0,t.normalizeStyle)(o.style),class:(0,t.normalizeClass)([{[r.classNameActive]:e.enabled,[r.classNameDragging]:e.dragging,[r.classNameResizing]:e.resizing,[r.classNameDraggable]:r.draggable,[r.classNameResizable]:r.resizable},r.className]),onMousedown:n[0]||=(...e)=>o.elementMouseDown&&o.elementMouseDown(...e),onTouchstart:n[1]||=(...e)=>o.elementTouchDown&&o.elementTouchDown(...e)},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(o.actualHandles,n=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:n,class:(0,t.normalizeClass)([r.classNameHandle,r.classNameHandle+`-`+n]),style:(0,t.normalizeStyle)({display:e.enabled?`block`:`none`}),onMousedown:(0,t.withModifiers)(e=>o.handleDown(n,e),[`stop`,`prevent`]),onTouchstart:(0,t.withModifiers)(e=>o.handleTouchDown(n,e),[`stop`,`prevent`])},[(0,t.renderSlot)(e.$slots,n)],46,aSt))),128)),(0,t.renderSlot)(e.$slots,`default`)],38)}var Z9=tSt(iSt,[[`render`,oSt]]);function Q9(e){Q9.installed||(Q9.installed=!0,e.component(`VueDraggableResizable`,Z9))}var sSt={install:Q9},$9=null;typeof window<`u`?$9=window.Vue:typeof global<`u`&&($9=global.Vue),$9&&$9.use(sSt);function cSt(e={},n){let r=e.initWidth||400,i=e.minWidth||400,a=e.minHeight||400,o=e.maxWidthPercent||40,s=e.compressedHeight||800,l=e.compressedPadding===void 0?0:e.compressedPadding,u=(0,t.ref)(e.defaultLeft===void 0?window.innerWidth-r:e.defaultLeft),d=(0,t.ref)(e.defaultTop===void 0?0:e.defaultTop),f=(0,t.ref)(e.defaultHeight===void 0?window.innerHeight-(e.defaultTop===void 0?0:e.defaultTop):e.defaultHeight),p=(0,t.ref)(r),m=(0,t.ref)(d.value),h=(0,t.ref)(u.value),g=(0,t.ref)(p.value),_=(0,t.ref)(f.value),v=(0,t.ref)(Math.max(window.innerWidth*(o/100),g.value)),y=(0,t.ref)(!1),b=(0,t.ref)(0),x=()=>({x:h.value,y:m.value,width:g.value,height:_.value}),S=(e,t)=>{h.value=e,m.value=t,b.value=e-(window.innerWidth-g.value),n?.onDragging?.(x())},C=(e,t,r,i)=>{h.value=e,m.value=t,g.value=Math.min(r,v.value),_.value=i,n?.onResizing?.(x())},w=(e,t)=>{h.value=e,m.value=t,b.value=e-(window.innerWidth-g.value),n?.onDragStop?.(x())},T=(e,t,r,i)=>{h.value=e,m.value=t,g.value=Math.min(r,v.value),_.value=i,n?.onResizeStop?.(x())},E=()=>{v.value=Math.max(window.innerWidth*(o/100),g.value),(0,t.nextTick)(()=>{if(y.value)h.value=window.innerWidth-g.value-l,m.value=window.innerHeight-s-l;else{let e=window.innerWidth-g.value-b.value;h.value=Math.max(0,e),setTimeout(()=>{_.value=window.innerHeight-m.value},0)}g.value>v.value&&(g.value=v.value)})},D=()=>{y.value?(m.value=d.value,(0,t.nextTick)(()=>{_.value=f.value,h.value=u.value,g.value=p.value})):(m.value=window.innerHeight-s-l,h.value=u.value-l,g.value=r,_.value=s),y.value=!y.value},O=(e,t)=>{h.value=e,m.value=t,b.value=e-(window.innerWidth-g.value)},k=(e,t)=>{g.value=Math.max(i,Math.min(e,v.value)),_.value=Math.max(a,t)};return(0,t.onMounted)(()=>{window.addEventListener(`resize`,E)}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,E)}),{minWidth:i,minHeight:a,maxWidth:v,top:m,left:h,width:g,height:_,isCompressed:y,handleDragging:S,handleResizing:C,handleDragStop:w,handleResizeStop:T,toggleCompression:D,updatePosition:O,updateSize:k,updatePositionAndSize:(e,t,n,r)=>{O(e,t),k(n,r)}}}var lSt={class:`draggable-container-content`},uSt=L9((0,t.defineComponent)({__name:`draggable-container`,props:{visible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},defaultWidth:{default:400},defaultHeight:{default:void 0},defaultX:{default:void 0},defaultY:{default:0},minWidth:{default:400},minHeight:{default:400},maxWidth:{default:void 0},maxWidthPercent:{default:80},compressedHeight:{default:800},compressedPadding:{default:0},dragHandle:{default:`.drag-handle`},className:{default:``},teleportTo:{default:`body`}},emits:[`dragging`,`resizing`,`drag-stop`,`resize-stop`,`compression-change`],setup(e,{expose:n,emit:r}){let i=e,a=r,o=(0,t.ref)(!1),{minWidth:s,minHeight:l,maxWidth:u,top:d,left:f,width:p,height:m,isCompressed:h,handleDragging:g,handleResizing:_,handleDragStop:v,handleResizeStop:y,toggleCompression:b,updatePosition:x,updateSize:S,updatePositionAndSize:C}=cSt({initWidth:i.defaultWidth,minWidth:i.minWidth,minHeight:i.minHeight,maxWidthPercent:i.maxWidthPercent,compressedHeight:i.compressedHeight,defaultHeight:i.defaultHeight,defaultTop:i.defaultY,defaultLeft:i.defaultX,compressedPadding:i.compressedPadding},{onDragStop:e=>a(`drag-stop`,e),onResizeStop:e=>a(`resize-stop`,e),onDragging:e=>a(`dragging`,e),onResizing:e=>a(`resizing`,e)}),w=(0,t.computed)(()=>{let e=typeof i.maxWidth==`number`?`${i.maxWidth}px`:i.maxWidth??`${u.value}px`;return{"--draggable-max-width":e}}),T=(0,t.computed)(()=>({x:f.value,y:d.value,width:p.value,height:m.value})),E=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=`none`})},D=()=>{document.querySelectorAll(`iframe`).forEach(e=>{e.style.pointerEvents=``})},O=(e,t)=>{o.value||(o.value=!0,E()),g(e,t)},k=(e,t,n,r)=>{o.value||(o.value=!0,E()),_(e,t,n,r)},A=(e,t)=>{v(e,t),o.value=!1,D()},j=(e,t,n,r)=>{y(e,t,n,r),o.value=!1,D()};return(0,t.watch)(h,e=>{a(`compression-change`,e)}),n({updatePosition:x,updateSize:S,updatePositionAndSize:C,toggleCompression:b,positionAndSize:T,isCompressed:h}),(e,n)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Z9),{ref:`draggableRef`,class:(0,t.normalizeClass)([`draggable-container-wrapper`,i.className]),style:(0,t.normalizeStyle)(w.value),active:i.visible,draggable:i.draggable,resizable:i.resizable,w:(0,t.unref)(p),h:(0,t.unref)(m),x:(0,t.unref)(f),y:(0,t.unref)(d),"min-width":(0,t.unref)(s),"min-height":(0,t.unref)(l),"max-width":(0,t.unref)(u),parent:!0,"prevent-deactivation":!0,"drag-handle":i.dragHandle,"class-name":`draggable-container-inner`,onDragging:O,onResizing:k,onDragStop:A,onResizeStop:j},{default:(0,t.withCtx)(()=>[(0,t.createElementVNode)(`div`,lSt,[(0,t.renderSlot)(e.$slots,`default`,{},void 0,!0)])]),_:3},8,[`class`,`style`,`active`,`draggable`,`resizable`,`w`,`h`,`x`,`y`,`min-width`,`min-height`,`max-width`,`drag-handle`])),[[t.vShow,i.visible]])}}),[[`__scopeId`,`data-v-6e2c6cb7`]]),dSt={class:`nimbus-bkai-wrapper`},fSt=[`width`,`height`,`src`],pSt=L9((0,t.defineComponent)({name:`NimbusButton`,__name:`nimbus`,props:{isPanelShow:{type:Boolean},isMinimize:{type:Boolean},size:{default:`normal`}},emits:[`click`,`minimize`,`update:isMinimize`],setup(e,{emit:n}){(0,t.useCssVars)(e=>({v05a8b16e:`${o.value.container}px`,v4e1cf4ca:`${o.value.wrapper}px`,v5ab0c513:`${o.value.mini.right}px`,v40c13a80:`${o.value.mini.size}px`,v0d35a9ef:`${o.value.mini.fontSize}px`}));let r=e,i=n,a={small:{container:40,wrapper:32,img:24,mini:{size:14,fontSize:10,right:-4}},normal:{container:48,wrapper:40,img:32,mini:{size:16,fontSize:12,right:-6}},large:{container:56,wrapper:48,img:40,mini:{size:18,fontSize:14,right:-6}}},o=(0,t.computed)(()=>a[r.size]),s=(0,t.ref)(null),l=(0,t.ref)(null),{nimbusLeft:u,nimbusTop:d,isMinimize:f,handleClick:p,handleMinimize:m,handleDragging:h,handleMouseEnter:g,handleMouseLeave:_,handleMouseDown:v,handleMouseUp:y}=qxt(i,r.isMinimize);(0,t.watch)(f,e=>{i(`update:isMinimize`,e)});let b=(0,t.computed)(()=>f.value?z9(`恢复默认大小`):z9(`最小化,将缩成锚点`)),{createTooltip:x,destroyAll:S}=Jxt({theme:`ai-blueking`,delay:[0,0]}),C=()=>{(0,t.nextTick)(()=>{w()})},w=()=>{S(),s.value&&!f.value&&x(s.value,Ybt(),{placement:`left`}),l.value&&x(l.value,b.value,{placement:`top`})};return(0,t.watch)(()=>f.value,()=>{(0,t.nextTick)(()=>{w()})}),(0,t.onMounted)(()=>{(0,t.nextTick)(()=>{w()}),window.addEventListener(`resize`,C)}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`resize`,C)}),(n,r)=>((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Z9),{active:!e.isPanelShow,axis:`y`,draggable:!0,h:o.value.container,parent:!0,"prevent-deactivation":!0,resizable:!1,w:o.value.container,x:(0,t.unref)(u),y:(0,t.unref)(d),onDragging:(0,t.unref)(h)},{default:(0,t.withCtx)(()=>[(0,t.createElementVNode)(`div`,{ref_key:`nimbusContainerRef`,ref:s,class:(0,t.normalizeClass)([`nimbus-container`,{"is-minimize":(0,t.unref)(f)}]),onClick:r[1]||=(...e)=>(0,t.unref)(p)&&(0,t.unref)(p)(...e),onMousedown:r[2]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onMouseenter:r[3]||=(...e)=>(0,t.unref)(g)&&(0,t.unref)(g)(...e),onMouseleave:r[4]||=(...e)=>(0,t.unref)(_)&&(0,t.unref)(_)(...e),onMouseup:r[5]||=(...e)=>(0,t.unref)(y)&&(0,t.unref)(y)(...e)},[(0,t.createElementVNode)(`div`,dSt,[(0,t.createElementVNode)(`img`,{width:o.value.img,height:o.value.img,src:(0,t.unref)(Bbt),alt:`nimbus`},null,8,fSt)]),(0,t.createElementVNode)(`i`,{ref_key:`minimizeButtonRef`,ref:l,class:(0,t.normalizeClass)([`nimbus-mini bkai-icon`,(0,t.unref)(f)?`bkai-yinyong`:`bkai-minus-line`]),onClick:r[0]||=(0,t.withModifiers)((...e)=>(0,t.unref)(m)&&(0,t.unref)(m)(...e),[`stop`])},null,2)],34)]),_:1},8,[`active`,`h`,`w`,`x`,`y`,`onDragging`]))}}),[[`__scopeId`,`data-v-26b6f3ea`]]),mSt={class:`ai-blueking-panel`},hSt=L9((0,t.defineComponent)({__name:`ai-blueking`,props:(0,t.mergeDefaults)({autoSwitchToInitialSession:{type:Boolean},defaultChatInputPosition:{},defaultHeight:{},defaultLeft:{},defaultMinimize:{type:Boolean},defaultTop:{},defaultWidth:{},disabledInput:{type:Boolean},draggable:{type:Boolean},dropdownMenuConfig:{},enableChatSession:{type:Boolean},enablePopup:{type:Boolean},extCls:{},helloText:{},hideDefaultTrigger:{type:Boolean},hideHeader:{type:Boolean},hideNimbus:{type:Boolean},initialSessionCode:{},loadRecentSessionOnMount:{type:Boolean},maxWidth:{},miniPadding:{},nimbusSize:{},placeholder:{},prompts:{},requestOptions:{},resources:{},shortcutLimit:{},shortcuts:{},showCompressionIcon:{type:Boolean},showHistoryIcon:{type:Boolean},showMoreIcon:{type:Boolean},showNewChatIcon:{type:Boolean},teleportTo:{},title:{},url:{},shortcutFilter:{type:Function}},Yxt),emits:[`show`,`close`,`dragging`,`resizing`,`drag-stop`,`resize-stop`,`send-message`,`receive-start`,`receive-text`,`receive-end`,`stop`,`shortcut-click`,`session-initialized`,`sdk-error`,`transfer-messages`,`share-messages`,`new-chat`,`history-click`,`auto-generate-name`,`help-click`,`rename`,`share`],setup(e,{expose:n,emit:r}){let a=e,o=r,s=(0,t.ref)(),l=(0,t.ref)(),u=(0,t.computed)(()=>Kbt(a.url)),d=Dxt({initialPanelVisible:!1,initialNimbusMinimized:a.defaultMinimize,enablePopup:a.enablePopup,enableNimbus:!a.hideNimbus,enableDraggable:a.draggable}),f=d.panelVisible,p=d.nimbusMinimized,{forwardToManager:m}=Kxt({componentManager:d,emit:o}),h=Gxt(m),{chatHelper:g,isReady:_,agentInfo:v,agentName:y,currentSession:b}=Wxt({url:u,requestOptions:a.requestOptions,autoInit:!0,protocolCallbacks:{onStart:()=>{h.receiveStart()},onMessage:()=>{h.receiveText()},onDone:()=>{h.receiveEnd()},onError:e=>{d.emitInternal(`sdk-error`,{apiName:`chat`,code:-1,message:e.message,data:e})}}}),x=g,S=new B9(x.session,x.message,null,{enableChatSession:a.enableChatSession,initialSessionCode:a.initialSessionCode}),C=new Txt(x.message,x.session),w=new Axt,T=(0,t.computed)(()=>w.isSelectionMode.value),E=(0,t.ref)(!1),D=new V9(null,a.shortcuts||[]),O=(0,t.ref)(!1),k=(0,t.ref)(``),A=(0,t.computed)(()=>d.isCompressed.value),j=(0,t.computed)(()=>y.value),M=(0,t.ref)(``),N=(0,t.ref)(!0),P=(0,t.ref)(!1),F=(0,t.computed)(()=>a.resources?.length?a.resources:Ubt(v.value?.resources)),I=(0,t.computed)(()=>a.prompts?.length?a.prompts:v.value?.conversationSettings?.predefinedQuestions??[]),L=(0,t.computed)(()=>{let e=D.effectiveShortcuts.value;return typeof a.shortcutFilter==`function`&&k.value?e.filter(e=>a.shortcutFilter?.(e,k.value)):e});(0,t.watch)(()=>_.value,async e=>{if(e&&v.value){let e=v.value;if(e.saasUrl&&fetch(e.saasUrl,{method:`GET`,credentials:`include`}).catch(()=>{}),e.conversationSettings&&(m(`session-initialized`,{openingRemark:e.conversationSettings.openingRemark||``,predefinedQuestions:e.conversationSettings.predefinedQuestions||[]}),e.conversationSettings.commands&&D.setAgentShortcuts(e.conversationSettings.commands)),a.loadRecentSessionOnMount)try{await S.loadRecentSession({skipLoadSessions:!0})}catch(e){console.error(`[AIBlueking] Failed to load recent session:`,e)}}},{immediate:!0}),(0,t.watch)(()=>a.shortcuts,e=>{D.setShortcuts(e||[])},{immediate:!0}),(0,t.watch)(()=>b.value,e=>{e&&(M.value=e.sessionName||``,P.value=(e.sessionContentCount??0)>0)},{immediate:!0}),(0,t.watch)(()=>x.message.list.value.length,e=>{e>0&&(P.value=!0)});let R=async e=>{d.showPanel(e),e&&l.value&&await l.value.switchSession(e)},ee=()=>{d.hidePanel()},te=()=>{ee()},z=()=>{d.handleNimbusClick()},B=e=>{k.value=e},ne=async(e,t)=>{O.value=!1,await R(),e.components?.length&&l.value?l.value.selectShortcut(e,t):l.value&&(l.value.setCiteText(t),l.value.focusInput()),m(`shortcut-click`,{shortcut:e,source:`popup`})},re=e=>{m(`shortcut-click`,e)},ie=e=>{d.handleDragging(e)},ae=e=>{d.handleResizing(e)},oe=e=>{d.handleDragStop(e)},V=e=>{d.handleResizeStop(e)},se=()=>{d.container.toggleCompression()},ce=e=>{d.setCompressed(e)},le=async()=>{h.newChat()},ue=e=>{h.historyClick(e)},de=async e=>{await S.switchSession(e)},fe=async e=>{await S.deleteSession(e)},pe=async(e,t)=>{await S.updateSessionName(e,t)},me=async()=>{let e=x.session.current?.value?.sessionCode;if(!e){console.error(`[AIBlueking] Cannot auto-generate name: no active session`);return}try{await x.session.renameSession(e);let t=x.session.list.value.find(t=>t.sessionCode===e);t&&(M.value=t.sessionName||``)}catch(e){console.error(`[AIBlueking] Failed to auto-generate session name:`,e),Me(e)}h.autoGenerateName()},he=()=>{h.helpClick()},ge=async e=>{let t=x.session.current?.value;if(!t){console.error(`[AIBlueking] Cannot rename: no active session`);return}try{await x.session.updateSession({...t,sessionName:e}),M.value=e}catch(e){console.error(`[AIBlueking] Failed to rename session:`,e),Me(e)}h.rename(e)},_e=()=>{w.enableSelectionMode(),h.share()},ve=()=>{w.disableSelectionMode()},ye=async e=>{E.value=!0;try{let{shareUrl:t,userMessageIds:n}=await C.shareMessages(e);await qbt(t),(0,i.Message)({message:z9(`分享链接已复制到剪贴板`),theme:`success`}),w.disableSelectionMode(),h.shareMessages(n)}catch(e){console.error(`[AIBlueking] Failed to share messages:`,e),Me(e)}finally{E.value=!1}},be=async e=>{l.value&&await l.value.sendMessage(e)},xe=e=>{P.value=!0,h.sendMessage(e)},Se=()=>{h.receiveStart()},Ce=()=>{h.receiveText()},we=()=>{h.receiveEnd()},Te=()=>{h.stop()},Ee=()=>{l.value&&l.value.stopGeneration()},De=async e=>{e?await S.createSession({sessionCode:e}):await S.createNewSession()},Oe=async e=>{l.value&&await l.value.switchSession(e)},ke=async(e,t)=>{try{await S.updateSessionName(e,t),M.value=t}catch(e){console.error(`[AIBlueking] Failed to update session name:`,e),Me(e)}},je=e=>{e&&(M.value=e.sessionName||``,P.value=(e.sessionContentCount??0)>0||x.message.list.value.length>0)},Me=e=>{console.error(`ChatBot error:`,e),d.emitInternal(`sdk-error`,{apiName:`chat`,code:-1,message:e.message,data:e})},Ne=(e,t)=>{d.container.updatePosition(e,t)},Pe=(e,t)=>{d.container.updateSize(e,t)},Fe=(e,t,n,r)=>{d.container.updatePositionAndSize(e,t,n,r)},Ie=e=>{l.value&&l.value.setCiteText(e)},Le=()=>{l.value&&l.value.focusInput()},Re=e=>{Zbt(e)&&(e.preventDefault(),f.value?ee():R())};return(0,t.onMounted)(async()=>{s.value&&d.setContainerRef(s.value),window.addEventListener(`keydown`,Re)}),(0,t.onBeforeUnmount)(()=>{window.removeEventListener(`keydown`,Re),d.destroy()}),n({show:R,hide:ee,sendMessage:be,stopGeneration:Ee,addNewSession:De,switchToSession:Oe,updateSessionName:ke,updatePosition:Ne,updateSize:Pe,updatePositionAndSize:Fe,setCiteText:Ie,focusInput:Le}),(e,n)=>((0,t.openBlock)(),(0,t.createBlock)(t.Teleport,{to:a.teleportTo},[(0,t.createElementVNode)(`div`,{class:(0,t.normalizeClass)([`ai-blueking-v2`,a.extCls])},[(0,t.createCommentVNode)(` 可拖拽容器 `),(0,t.createVNode)((0,t.unref)(uSt),{ref_key:`draggableContainerRef`,ref:s,"compressed-padding":a.miniPadding,"default-height":a.defaultHeight,"default-width":a.defaultWidth,"default-x":a.defaultLeft,"default-y":a.defaultTop,"drag-handle":`.drag-handle`,draggable:a.draggable,"max-width":a.maxWidth,"max-width-percent":80,visible:(0,t.unref)(f),onCompressionChange:ce,onDragStop:oe,onDragging:ie,onResizeStop:V,onResizing:ae},{default:(0,t.withCtx)(()=>[(0,t.createElementVNode)(`div`,mSt,[(0,t.createCommentVNode)(` 独立的 Header 组件 `),a.hideHeader?(0,t.createCommentVNode)(`v-if`,!0):((0,t.openBlock)(),(0,t.createBlock)(Cxt,{key:0,"agent-name":j.value,"chat-helper":(0,t.unref)(x),draggable:a.draggable,"dropdown-menu-config":a.dropdownMenuConfig,"enable-chat-session":a.enableChatSession,"has-permission":N.value,"has-session-contents":P.value,"is-compression-height":A.value,"session-business-manager":(0,t.unref)(S),"session-name":M.value,"show-compression-icon":a.showCompressionIcon,"show-history-icon":a.showHistoryIcon,"show-more-icon":a.showMoreIcon,"show-new-chat-icon":a.showNewChatIcon,title:a.title,onAutoGenerateName:me,onClose:te,onHelpClick:he,onHistoryClick:ue,onHistorySessionDelete:fe,onHistorySessionRename:pe,onHistorySessionSwitch:de,onNewChat:le,onRename:ge,onShare:_e,onToggleCompression:se},null,8,[`agent-name`,`chat-helper`,`draggable`,`dropdown-menu-config`,`enable-chat-session`,`has-permission`,`has-session-contents`,`is-compression-height`,`session-business-manager`,`session-name`,`show-compression-icon`,`show-history-icon`,`show-more-icon`,`show-new-chat-icon`,`title`])),(0,t.createCommentVNode)(` ChatBot 核心组件(仅聊天区域) `),(0,t.createVNode)(Uxt,{ref_key:`chatBotRef`,ref:l,"auto-load":a.loadRecentSessionOnMount,"chat-helper":(0,t.unref)(x),"enable-selection":T.value,"hello-text":a.helloText,placeholder:a.placeholder,prompts:I.value,"request-options":a.requestOptions,resources:F.value,"session-code":a.initialSessionCode,"share-loading":E.value,"shortcut-limit":a.shortcutLimit,shortcuts:a.shortcuts,url:u.value,onCancelShare:ve,onConfirmShare:n[0]||=e=>ye(e),onError:n[1]||=e=>Me(e),onReceiveEnd:we,onReceiveStart:Se,onReceiveText:Ce,onRequestShare:_e,onSendMessage:n[2]||=e=>xe(e),onSessionSwitched:n[3]||=e=>je(e),onShortcutClick:n[4]||=e=>re(e),onStop:Te},null,8,[`auto-load`,`chat-helper`,`enable-selection`,`hello-text`,`placeholder`,`prompts`,`request-options`,`resources`,`session-code`,`share-loading`,`shortcut-limit`,`shortcuts`,`url`])])]),_:1},8,[`compressed-padding`,`default-height`,`default-width`,`default-x`,`default-y`,`draggable`,`max-width`,`visible`]),(0,t.createCommentVNode)(` Nimbus 悬浮球 `),a.hideNimbus?(0,t.createCommentVNode)(`v-if`,!0):((0,t.openBlock)(),(0,t.createBlock)(pSt,{key:0,"is-minimize":(0,t.unref)(p),"onUpdate:isMinimize":n[5]||=e=>(0,t.isRef)(p)?p.value=e:null,"is-panel-show":(0,t.unref)(f),"onUpdate:isPanelShow":n[6]||=e=>(0,t.isRef)(f)?f.value=e:null,"default-minimize":a.defaultMinimize,size:a.nimbusSize,onClick:z},null,8,[`is-minimize`,`is-panel-show`,`default-minimize`,`size`])),(0,t.createCommentVNode)(` 划词选择弹窗(使用 chat-x 的 AiSelection 组件) `),a.enablePopup?((0,t.openBlock)(),(0,t.createBlock)((0,t.unref)(Ae),{key:1,visible:O.value,"onUpdate:visible":n[7]||=e=>O.value=e,"max-shortcut-count":a.shortcutLimit,shortcuts:L.value,onSelectShortcut:ne,onSelectionChange:B},null,8,[`visible`,`max-shortcut-count`,`shortcuts`])):(0,t.createCommentVNode)(`v-if`,!0)],2)],8,[`to`]))}}),[[`__scopeId`,`data-v-390ddb5e`]]);Object.defineProperty(e,`AGUIProtocol`,{enumerable:!0,get:function(){return s.AGUIProtocol}}),e.AIBlueking=hSt,e.default=hSt,e.BluekingProtocol=Xxt,e.BootstrapPhase=H9,e.ChatBot=Uxt,e.ChatBusinessManager=wxt,e.ComponentManager=Ext,e.DraggableContainer=uSt,e.MessageContentType=C,e.SessionBusinessManager=B9,e.ShortcutManager=V9,e.UIStateManager=Axt,e.createBluekingProtocol=Zxt,e.createComponentManager=Dxt,e.defaultProps=Yxt,e.useChatBootstrap=Wxt,Object.defineProperty(e,`useChatHelper`,{enumerable:!0,get:function(){return s.useChatHelper}}),e.useDraggable=cSt});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/ai-blueking",
3
- "version": "2.0.0-dev.16",
3
+ "version": "2.0.0-dev.17",
4
4
  "description": "AI 小鲸 V2 - 基于新架构的智能对话组件",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",