File: /www/server/panel/BTPanel/static/js/useController-legacy23.js
!function(){function t(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,r,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.toStringTag||"@@toStringTag";function u(t,o,a,i){var u=o&&o.prototype instanceof l?o:l,c=Object.create(u.prototype);return n(c,"_invoke",function(t,n,o){var a,i,u,l=0,c=o||[],f=!1,v={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return a=t,i=0,u=e,v.n=n,s}};function d(t,n){for(i=t,u=n,r=0;!f&&l&&!o&&r<c.length;r++){var o,a=c[r],d=v.p,p=a[2];t>3?(o=p===n)&&(u=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=e):a[0]<=d&&((o=t<2&&d<a[1])?(i=0,v.v=n,v.n=a[1]):d<p&&(o=t<3||a[0]>n||n>p)&&(a[4]=t,a[5]=n,v.n=p,i=0))}if(o||t>1)return s;throw f=!0,n}return function(o,c,p){if(l>1)throw TypeError("Generator is already running");for(f&&1===c&&d(c,p),i=c,u=p;(r=i<2?e:u)||!f;){a||(i?i<3?(i>1&&(v.n=-1),d(i,u)):v.n=u:v.v=u);try{if(l=2,a){if(i||(o="next"),r=a[o]){if(!(r=r.call(a,u)))throw TypeError("iterator result is not an object");if(!r.done)return r;u=r.value,i<2&&(i=0)}else 1===i&&(r=a.return)&&r.call(a),i<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),i=1);a=e}else if((r=(f=v.n<0)?u:t.call(n,v))!==s)break}catch(r){a=e,i=1,u=r}finally{l=1}}return{value:r,done:f}}}(t,a,i),!0),c}var s={};function l(){}function c(){}function f(){}r=Object.getPrototypeOf;var v=[][a]?r(r([][a]())):(n(r={},a,function(){return this}),r),d=f.prototype=l.prototype=Object.create(v);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,n(t,i,"GeneratorFunction")),t.prototype=Object.create(d),t}return c.prototype=f,n(d,"constructor",f),n(f,"constructor",c),c.displayName="GeneratorFunction",n(f,i,"GeneratorFunction"),n(d),n(d,i,"Generator"),n(d,a,function(){return this}),n(d,"toString",function(){return"[object Generator]"}),(t=function(){return{w:u,m:p}})()}function n(t,e,r,o){var a=Object.defineProperty;try{a({},"",{})}catch(t){a=0}n=function(t,e,r,o){function i(e,r){n(t,e,function(t){return this._invoke(e,r,t)})}e?a?a(t,e,{value:r,enumerable:!o,configurable:!o,writable:!o}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},n(t,e,r,o)}function e(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||i(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t,n,e,r,o,a,i){try{var u=t[a](i),s=u.value}catch(t){return void e(t)}u.done?n(s):Promise.resolve(s).then(r,o)}function o(t){return function(){var n=this,e=arguments;return new Promise(function(o,a){var i=t.apply(n,e);function u(t){r(i,o,a,u,s,"next",t)}function s(t){r(i,o,a,u,s,"throw",t)}u(void 0)})}}function a(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=i(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==e.return||e.return()}finally{if(s)throw a}}}}function i(t,n){if(t){if("string"==typeof t)return u(t,n);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?u(t,n):void 0}}function u(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e<n;e++)r[e]=t[e];return r}System.register(["./utils-lib-legacy.js?v=1777008528","./base-lib-legacy.js?v=1777008528","./ai-legacy.js?v=1777008528"],function(n,r){"use strict";var i,u,s,l,c,f,v,d;return{setters:[function(t){i=t.c,u=t.f},function(t){s=t.r,l=t.V,c=t.g},function(t){f=t.g,v=t.d,d=t.a}],execute:function(){function r(t){try{var n=JSON.parse(t).todos;if("string"==typeof n&&(n=JSON.parse(n)),Array.isArray(n))return n}catch(e){}}n({i:F,j:function(t){try{var n=t.match(/<toolcall_result>\s*([\s\S]*?)\s*<\/toolcall_result>/);if(!n)return;var e=n[1].trim(),r=JSON.parse(e);if(Array.isArray(r))return r}catch(o){}return},p:r});var p=s(""),y=s([]),h=s([]),m=s(null),g=s(null),b=s(null),w=s(""),S=s(""),_=s(""),A=s([]),O=s(!1),T=s(!1),I=s(!1),j=s([]),x=s(!1),k=s([]),C=s(""),M=s([]),P=s([]),L=s(!1),N=s(!1),D=s(!1),E=s(!1),G=s(!1),J=s(!1),q=s(!0);function F(){var n=function(t){for(var n=[],e=0;e<t.length;){var o=t[e];if("user"===o.role)n.push({role:"user",content:o.content,time:new Date(1e3*o.timestamp).toISOString(),id:o.id}),e++;else if("assistant"===o.role){var i=[];if(o.reasoning_content&&i.push({type:"think",content:o.reasoning_content,collapsed:!0}),o.tool_calls&&o.tool_calls.length>0){var u,s=a(o.tool_calls);try{var l=function(){var n=u.value,e="TodoWrite"===n.function.name,o=function(){try{return JSON.parse(n.function.arguments).description}catch(t){return}}(),a={type:"tool_call",tool:n.function.name,args:n.function.arguments,id:n.id,status:"calling",collapsed:!e,description:o,todoItems:e?r(n.function.arguments):void 0},s=t.find(function(t){return"tool"===t.role&&t.tool_call_id===n.id});s&&(a.result=s.content,a.status="completed"),i.push(a)};for(s.s();!(u=s.n()).done;)l()}catch(v){s.e(v)}finally{s.f()}}var c=o.content;if(Array.isArray(o.content)){var f=o.content.find(function(t){return"text"===t.type});c=(null==f?void 0:f.text)||""}for(c&&i.push({type:"message",content:c}),n.push({role:"assistant",content:c||"",time:new Date(1e3*o.timestamp).toISOString(),contentBlocks:i.length>0?i:void 0,id:o.id}),e++;e<t.length&&"tool"===t[e].role;)e++}else o.role,e++}return n},i=function(){var r=o(t().m(function r(o,a){var i,u,s,l,c;return t().w(function(t){for(;;)switch(t.n){case 0:if(!((i=h.value.find(function(t){return t.id===o}))&&i.messages.length>0)){t.n=1;break}return m.value=o,y.value=e(i.messages),t.a(2);case 1:return t.n=2,f({session_id:o,sessions_dir:a||"skill_agent_sessions"});case 2:u=t.v,(s=u.data).data&&Array.isArray(s.data)&&(l=n(s.data),(c=h.value.findIndex(function(t){return t.id===o}))>=0&&(h.value[c].messages=l),m.value=o,y.value=l);case 3:return t.a(2)}},r)}));return function(t,n){return r.apply(this,arguments)}}(),u=function(){var n=o(t().m(function n(e,r){return t().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,v({session_id:e,sessions_dir:r});case 1:t.v.status&&(h.value=h.value.filter(function(t){return t.id!==e}),m.value===e&&s());case 2:return t.a(2)}},n)}));return function(t,e){return n.apply(this,arguments)}}(),s=function(){m.value=null,g.value=null,y.value=[],j.value=[]};return{inputMessage:p,currentMessages:y,conversations:h,currentConversationId:m,currentSkillAgentId:g,currentAssistantId:b,currentAssistantName:_,currentSessionDir:w,currentTimeStr:S,currentAssistantPresetQuestions:A,historyPanelVisible:O,isTyping:T,isSending:I,streamingContentBlocks:j,streamingThinkCollapsed:x,modelsList:k,currentModel:C,toolsList:M,selectedTools:P,showModelPopover:L,showToolPopover:N,showUploadPopover:D,modelsLoading:E,toolsLoading:G,webSearchEnabled:J,smartMode:q,saveConversation:function(){if(m.value&&0!==y.value.length){var t=y.value.find(function(t){return"user"===t.role}),n="新对话";if(t)if("string"==typeof t.content)n=t.content.substring(0,30);else if(Array.isArray(t.content)){var e=t.content.find(function(t){return"text"===t.type});n=null!=e&&e.text?e.text.substring(0,30):"[图片消息]"}var r={id:m.value,title:n,messages:y.value,updatedAt:(new Date).toISOString()},o=h.value.findIndex(function(t){return t.id===m.value});o>=0?h.value[o]=r:h.value.unshift(r)}},loadConversation:i,deleteConversation:u,createNewConversation:s,getTimeAgo:function(t){var n=(new Date).getTime()-t.getTime(),e=Math.floor(n/6e4),r=Math.floor(n/36e5),o=Math.floor(n/864e5);return e<1?"刚刚":e<60?"".concat(e,"分钟前"):r<24?"".concat(r,"小时前"):o<7?"".concat(o,"天前"):t.toLocaleDateString("zh-CN",{month:"numeric",day:"numeric"})},setAssistantInfo:function(t){b.value=t.id,_.value=t.name,A.value=t.preset_questions||[],t.skill_agent_id&&(g.value=t.skill_agent_id)},clearAssistantInfo:function(){b.value=null,_.value="",A.value=[],g.value=null}}}var B=u(),U=l([]),V=n("s",s("")),W=n("t",l([])),z=n("f",l([])),Q=n("c",s("all")),$=n("b",s([])),H=n("l",s(!1)),K=i().mainWidth,R=(n("a",function(t){return"all"===t?"全部":t}),function(){return Math.floor((K.value-420)/80)}),X=(n("v",c(function(){var t=Math.max(0,R()),n=["all"].concat(U.value);return n.slice(0,Math.min(n.length,t+1))})),n("d",c(function(){var t=Math.max(1,Math.floor((K.value-100)/300));return{gridTemplateColumns:"repeat(".concat(t,", minmax(280px, 1fr))")}})),n("g",o(t().m(function n(){var e,r,o;return t().w(function(t){for(;;)switch(t.n){case 0:return H.value=!0,t.n=1,d();case 1:e=t.v,r=e.status,o=e.data,r&&(z.value=o.data.list||[],U.value=o.data.categories||[],$.value=U.value.slice(R(),U.value.length),Y()),H.value=!1;case 2:return t.a(2)}},n)})))),Y=function(){var t=V.value.trim().toLowerCase(),n=Q.value,e=z.value;"all"!==n&&(e=e.filter(function(t){return t.category===n})),t&&(e=e.filter(function(n){var e;return n.name.toLowerCase().includes(t)||(null===(e=n.description)||void 0===e?void 0:e.toLowerCase().includes(t))||n.id.toLowerCase().includes(t)})),W.value=e};n("h",function(){var n=o(t().m(function n(e){return t().w(function(t){for(;;)switch(t.n){case 0:Q.value=e,V.value="",Y();case 1:return t.a(2)}},n)}));return function(t){return n.apply(this,arguments)}}()),n("r",o(t().m(function n(){var e=arguments;return t().w(function(t){for(;;)switch(t.n){case 0:if(!(e.length>0&&void 0!==e[0]&&e[0])){t.n=2;break}return t.n=1,X();case 1:B.success("刷新成功"),t.n=3;break;case 2:Y();case 3:return t.a(2)}},n)}))),n("u",function(){W.value=[],z.value=[],U.value=[],$.value=[],V.value="",Q.value="all"}),n("e",function(t,n){(0,F().setAssistantInfo)({id:t.id,name:t.name,preset_questions:t.preset_questions,skill_agent_id:t.id}),n.push({path:"/ai/chat"})})}}})}();