Files
LangBot/web/.next/static/chunks/e1bbcd4d755907c7.js
T

1 line
55 KiB
JavaScript

(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,58462,e=>{e.v({botListContainer:"botConfig-module__yXJ0ia__botListContainer"})},74748,e=>{e.v({basicInfoAdapterContainer:"botCard-module__1kNUfG__basicInfoAdapterContainer",basicInfoAdapterIcon:"botCard-module__1kNUfG__basicInfoAdapterIcon",basicInfoAdapterLabel:"botCard-module__1kNUfG__basicInfoAdapterLabel",basicInfoContainer:"botCard-module__1kNUfG__basicInfoContainer",basicInfoDescription:"botCard-module__1kNUfG__basicInfoDescription",basicInfoName:"botCard-module__1kNUfG__basicInfoName",basicInfoNameContainer:"botCard-module__1kNUfG__basicInfoNameContainer",basicInfoPipelineContainer:"botCard-module__1kNUfG__basicInfoPipelineContainer",basicInfoPipelineIcon:"botCard-module__1kNUfG__basicInfoPipelineIcon",basicInfoPipelineLabel:"botCard-module__1kNUfG__basicInfoPipelineLabel",bigText:"botCard-module__1kNUfG__bigText",botOperationContainer:"botCard-module__1kNUfG__botOperationContainer",cardContainer:"botCard-module__1kNUfG__cardContainer",iconBasicInfoContainer:"botCard-module__1kNUfG__iconBasicInfoContainer",iconImage:"botCard-module__1kNUfG__iconImage"})},4491,e=>{e.v({botLogCardContainer:"botLog-module__gbBa3q__botLogCardContainer",botLogListContainer:"botLog-module__gbBa3q__botLogListContainer",cardText:"botLog-module__gbBa3q__cardText",cardTitleContainer:"botLog-module__gbBa3q__cardTitleContainer",chatId:"botLog-module__gbBa3q__chatId",chatTag:"botLog-module__gbBa3q__chatTag",listHeader:"botLog-module__gbBa3q__listHeader",tag:"botLog-module__gbBa3q__tag",timestamp:"botLog-module__gbBa3q__timestamp"})},79648,e=>{"use strict";var t=e.i(60498),n=e.i(49311),a=e.i(58462);class r{id;iconURL;name;description;adapter;adapterLabel;adapterConfig;usePipelineName;enable;constructor(e){this.id=e.id,this.iconURL=e.iconURL,this.name=e.name,this.description=e.description,this.adapter=e.adapter,this.adapterConfig=e.adapterConfig,this.adapterLabel=e.adapterLabel,this.usePipelineName=e.usePipelineName,this.enable=e.enable}}var s=e.i(74748);e.i(56907);var i=e.i(20317),o=e.i(13781);e.i(26128);var l=e.i(91830),c=e.i(50098);function d({botCardVO:e,setBotEnableCallback:n}){let{t:a}=(0,l.useTranslation)();return(0,t.jsx)("div",{className:`${s.default.cardContainer}`,children:(0,t.jsxs)("div",{className:`${s.default.iconBasicInfoContainer}`,children:[(0,t.jsx)("img",{className:`${s.default.iconImage}`,src:e.iconURL,alt:"icon"}),(0,t.jsxs)("div",{className:`${s.default.basicInfoContainer}`,children:[(0,t.jsxs)("div",{className:`${s.default.basicInfoNameContainer}`,children:[(0,t.jsx)("div",{className:`${s.default.basicInfoName}`,children:e.name}),(0,t.jsx)("div",{className:`${s.default.basicInfoDescription}`,children:e.description})]}),(0,t.jsxs)("div",{className:`${s.default.basicInfoAdapterContainer}`,children:[(0,t.jsx)("svg",{className:`${s.default.basicInfoAdapterIcon}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M2 8.99374C2 5.68349 4.67654 3 8.00066 3H15.9993C19.3134 3 22 5.69478 22 8.99374V21H8.00066C4.68659 21 2 18.3052 2 15.0063V8.99374ZM20 19V8.99374C20 6.79539 18.2049 5 15.9993 5H8.00066C5.78458 5 4 6.78458 4 8.99374V15.0063C4 17.2046 5.79512 19 8.00066 19H20ZM14 11H16V13H14V11ZM8 11H10V13H8V11Z"})}),(0,t.jsx)("span",{className:`${s.default.basicInfoAdapterLabel}`,children:e.adapterLabel})]}),(0,t.jsxs)("div",{className:`${s.default.basicInfoPipelineContainer}`,children:[(0,t.jsx)("svg",{className:`${s.default.basicInfoPipelineIcon}`,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M6 21.5C4.067 21.5 2.5 19.933 2.5 18C2.5 16.067 4.067 14.5 6 14.5C7.5852 14.5 8.92427 15.5539 9.35481 16.9992L15 16.9994V15L17 14.9994V9.24339L14.757 6.99938H9V9.00003H3V3.00003H9V4.99939H14.757L18 1.75739L22.2426 6.00003L19 9.24139V14.9994L21 15V21H15V18.9994L9.35499 19.0003C8.92464 20.4459 7.58543 21.5 6 21.5ZM6 16.5C5.17157 16.5 4.5 17.1716 4.5 18C4.5 18.8285 5.17157 19.5 6 19.5C6.82843 19.5 7.5 18.8285 7.5 18C7.5 17.1716 6.82843 16.5 6 16.5ZM19 17H17V19H19V17ZM18 4.58581L16.5858 6.00003L18 7.41424L19.4142 6.00003L18 4.58581ZM7 5.00003H5V7.00003H7V5.00003Z"})}),(0,t.jsx)("span",{className:`${s.default.basicInfoPipelineLabel}`,children:e.usePipelineName})]})]}),(0,t.jsx)("div",{className:`${s.default.botOperationContainer}`,children:(0,t.jsx)(o.Switch,{checked:e.enable,onCheckedChange:t=>{i.httpClient.updateBot(e.id,{name:e.name,description:e.description,adapter:e.adapter,adapter_config:e.adapterConfig,enable:t}).then(()=>{n(e.id,t)}).catch(e=>{console.error(e),c.toast.error(a("bots.setBotEnableError"))})},onClick:e=>{e.stopPropagation()}})})]})})}var u=e.i(57717),m=e.i(11607),h=e.i(88274),f=e.i(8557),p=e.i(74035),x=e.i(24110),g=e.i(27340),v=e.i(71654),b=e.i(16585),C=e.i(57728),j=e.i(19309),w=e.i(17755),_=e.i(18941),y=e.i(64339),N=e.i(87980),k=e.i(47977);function S({initBotId:e,onFormSubmit:a,onBotDeleted:r,onNewBotCreated:s}){let{t:d}=(0,l.useTranslation)(),u=j.z.object({name:j.z.string().min(1,{message:d("bots.botNameRequired")}),description:j.z.string().min(1,{message:d("bots.botDescriptionRequired")}),adapter:j.z.string().min(1,{message:d("bots.adapterRequired")}),adapter_config:j.z.record(j.z.string(),j.z.any()),enable:j.z.boolean().optional(),use_pipeline_uuid:j.z.string().optional()}),f=(0,C.useForm)({resolver:(0,b.zodResolver)(u),defaultValues:{name:"",description:d("bots.defaultDescription"),adapter:"",adapter_config:{},enable:!0,use_pipeline_uuid:""}}),[S,I]=(0,n.useState)(!1),[M,L]=(0,n.useState)(new Map),[V,E]=(0,n.useState)(!1),[P,D]=(0,n.useState)([]),[B,F]=(0,n.useState)({}),[T,H]=(0,n.useState)({}),[R,A]=(0,n.useState)([]),[$,Y]=(0,n.useState)([]),[U,X]=(0,n.useState)([]),[,O]=(0,n.useState)(!1),[W,z]=(0,n.useState)(""),Z=n.default.useRef(null),[q,G]=(0,n.useState)(!1),K=f.watch("adapter"),J=f.watch("adapter_config");function Q(){ee().then(()=>{e?et(e).then(e=>{f.setValue("name",e.name),f.setValue("description",e.description),f.setValue("adapter",e.adapter),f.setValue("adapter_config",e.adapter_config),f.setValue("enable",e.enable),f.setValue("use_pipeline_uuid",e.use_pipeline_uuid||""),en(e.adapter),e.webhook_full_url?z(e.webhook_full_url):z("")}).catch(e=>{c.toast.error(d("bots.getBotConfigError")+e.msg)}):(f.reset(),z(""))})}async function ee(){A((await i.httpClient.getPipelines()).pipelines.map(e=>({label:e.name,value:e.uuid??""})));let e=await i.httpClient.getAdapters();D(e.adapters.map(e=>({label:(0,m.extractI18nObject)(e.label),value:e.name}))),F(e.adapters.reduce((e,t)=>(e[t.name]=i.httpClient.getAdapterIconURL(t.name),e),{})),H(e.adapters.reduce((e,t)=>(e[t.name]=(0,m.extractI18nObject)(t.description),e),{})),e.adapters.forEach(e=>{M.set(e.name,e.spec.config.map(e=>new x.DynamicFormItemConfig({default:e.default,id:g.UUID.generate(),label:e.label,description:e.description,name:e.name,required:e.required,type:(0,x.parseDynamicFormItemType)(e.type),options:e.options})))}),L(M)}async function et(e){return new Promise((t,n)=>{i.httpClient.getBot(e).then(e=>{let n=e.bot;t({adapter:n.adapter,description:n.description,name:n.name,adapter_config:n.adapter_config,enable:n.enable??!0,use_pipeline_uuid:n.use_pipeline_uuid??"",webhook_full_url:n.adapter_runtime_values?n.adapter_runtime_values.webhook_full_url:void 0})}).catch(e=>{n(e)})})}function en(t){if(t){let n=M.get(t);n&&(Y(n),e||f.setValue("adapter_config",(0,x.getDefaultValues)(n))),E(!0)}else E(!1)}return(0,n.useEffect)(()=>{Q()},[]),(0,n.useEffect)(()=>{"lark"===K&&!1===J?.["enable-webhook"]?X($.filter(e=>"encrypt-key"!==e.name)):X($)},[K,J,$]),(0,t.jsxs)("div",{children:[(0,t.jsx)(h.Dialog,{open:S,onOpenChange:I,children:(0,t.jsxs)(h.DialogContent,{children:[(0,t.jsx)(h.DialogHeader,{children:(0,t.jsx)(h.DialogTitle,{children:d("common.confirmDelete")})}),(0,t.jsx)(h.DialogDescription,{children:d("bots.deleteConfirmation")}),(0,t.jsxs)(h.DialogFooter,{children:[(0,t.jsx)(p.Button,{variant:"outline",onClick:()=>I(!1),children:"取消"}),(0,t.jsx)(p.Button,{variant:"destructive",onClick:()=>{e&&i.httpClient.deleteBot(e).then(()=>{r(),c.toast.success(d("bots.deleteSuccess"))}).catch(e=>{c.toast.error(d("bots.deleteError")+e.msg)}),I(!1)},children:d("common.confirmDelete")})]})]})}),(0,t.jsx)(y.Form,{...f,children:(0,t.jsx)("form",{id:"bot-form",onSubmit:f.handleSubmit(function(){if(O(!0),e){let t={uuid:e,name:f.getValues().name,description:f.getValues().description,adapter:f.getValues().adapter,adapter_config:f.getValues().adapter_config,enable:f.getValues().enable,use_pipeline_uuid:f.getValues().use_pipeline_uuid};i.httpClient.updateBot(e,t).then(()=>{a(f.getValues()),c.toast.success(d("bots.saveSuccess"))}).catch(e=>{c.toast.error(d("bots.saveError")+e.msg)}).finally(()=>{O(!1)})}else{let t={name:f.getValues().name,description:f.getValues().description,adapter:f.getValues().adapter,adapter_config:f.getValues().adapter_config};i.httpClient.createBot(t).then(t=>{c.toast.success(d("bots.createSuccess")),e=t.uuid,Q(),s(t.uuid)}).catch(e=>{c.toast.error(d("bots.createError")+e.msg)}).finally(()=>{O(!1),f.reset()})}}),className:"space-y-8",children:(0,t.jsxs)("div",{className:"space-y-4",children:[e&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-6",children:[(0,t.jsx)(y.FormField,{control:f.control,name:"enable",render:({field:e})=>(0,t.jsxs)(y.FormItem,{className:"flex flex-col justify-start gap-[0.8rem] h-[3.8rem]",children:[(0,t.jsx)(y.FormLabel,{children:d("common.enable")}),(0,t.jsx)(y.FormControl,{children:(0,t.jsx)(o.Switch,{checked:e.value,onCheckedChange:e.onChange})})]})}),(0,t.jsx)(y.FormField,{control:f.control,name:"use_pipeline_uuid",render:({field:e})=>(0,t.jsxs)(y.FormItem,{className:"flex flex-col justify-start gap-[0.8rem] h-[3.8rem]",children:[(0,t.jsx)(y.FormLabel,{children:d("bots.bindPipeline")}),(0,t.jsx)(y.FormControl,{children:(0,t.jsxs)(k.Select,{onValueChange:e.onChange,...e,children:[(0,t.jsx)(k.SelectTrigger,{className:"bg-[#ffffff] dark:bg-[#2a2a2e]",children:(0,t.jsx)(k.SelectValue,{placeholder:d("bots.selectPipeline")})}),(0,t.jsx)(k.SelectContent,{className:"fixed z-[1000]",children:(0,t.jsx)(k.SelectGroup,{children:R.map(e=>(0,t.jsx)(k.SelectItem,{value:e.value,children:e.label},e.value))})})]})})]})})]}),W&&("lark"!==K||J?.["enable-webhook"]!==!1)&&(0,t.jsxs)(y.FormItem,{children:[(0,t.jsx)(y.FormLabel,{children:d("bots.webhookUrl")}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(N.Input,{ref:Z,value:W,readOnly:!0,className:"flex-1 bg-gray-50 dark:bg-gray-900",onClick:e=>{e.target.select()}}),(0,t.jsxs)(p.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>{console.log("[Copy] Attempting to copy from input element");let e=Z.current;if(!e)return void console.error("[Copy] Input element not found");try{if(e.disabled=!1,e.readOnly=!1,e.focus(),e.select(),navigator.clipboard&&navigator.clipboard.writeText)console.log("[Copy] Using Clipboard API with input value:",e.value),navigator.clipboard.writeText(e.value).then(()=>{console.log("[Copy] Clipboard API success"),e.blur(),e.readOnly=!0,G(!0),setTimeout(()=>G(!1),2e3)}).catch(t=>{console.error("[Copy] Clipboard API failed, trying execCommand:",t);let n=document.execCommand("copy");console.log("[Copy] execCommand result:",n),e.blur(),e.readOnly=!0,n&&(G(!0),setTimeout(()=>G(!1),2e3))});else{console.log("[Copy] Using execCommand with input value:",e.value);let t=document.execCommand("copy");console.log("[Copy] execCommand result:",t),e.blur(),e.readOnly=!0,t&&(G(!0),setTimeout(()=>G(!1),2e3))}}catch(t){console.error("[Copy] Copy failed:",t),e.readOnly=!0}},children:[q?(0,t.jsx)(_.Check,{className:"h-4 w-4 text-green-600 mr-2"}):(0,t.jsx)(w.Copy,{className:"h-4 w-4 mr-2"}),d("common.copy")]})]}),(0,t.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:d("bots.webhookUrlHint")})]})]}),(0,t.jsx)(y.FormField,{control:f.control,name:"name",render:({field:e})=>(0,t.jsxs)(y.FormItem,{children:[(0,t.jsxs)(y.FormLabel,{children:[d("bots.botName"),(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)(y.FormControl,{children:(0,t.jsx)(N.Input,{...e})}),(0,t.jsx)(y.FormMessage,{})]})}),(0,t.jsx)(y.FormField,{control:f.control,name:"description",render:({field:e})=>(0,t.jsxs)(y.FormItem,{children:[(0,t.jsxs)(y.FormLabel,{children:[d("bots.botDescription"),(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)(y.FormControl,{children:(0,t.jsx)(N.Input,{...e})}),(0,t.jsx)(y.FormMessage,{})]})}),(0,t.jsx)(y.FormField,{control:f.control,name:"adapter",render:({field:e})=>(0,t.jsxs)(y.FormItem,{children:[(0,t.jsxs)(y.FormLabel,{children:[d("bots.platformAdapter"),(0,t.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,t.jsx)(y.FormControl,{children:(0,t.jsx)("div",{className:"relative",children:(0,t.jsxs)(k.Select,{onValueChange:t=>{e.onChange(t),en(t)},value:e.value,children:[(0,t.jsx)(k.SelectTrigger,{className:"w-[180px] bg-[#ffffff] dark:bg-[#2a2a2e]",children:(0,t.jsx)(k.SelectValue,{placeholder:d("bots.selectAdapter")})}),(0,t.jsx)(k.SelectContent,{className:"fixed z-[1000]",children:(0,t.jsx)(k.SelectGroup,{children:P.map(e=>(0,t.jsx)(k.SelectItem,{value:e.value,children:e.label},e.value))})})]})})}),(0,t.jsx)(y.FormMessage,{})]})}),f.watch("adapter")&&(0,t.jsxs)("div",{className:"flex items-start gap-3 p-4 rounded-lg border",children:[(0,t.jsx)("img",{src:B[f.watch("adapter")],alt:"adapter icon",className:"w-12 h-12 rounded-[8%]"}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("div",{className:"font-medium",children:P.find(e=>e.value===f.watch("adapter"))?.label}),(0,t.jsx)("div",{className:"text-sm text-gray-500",children:T[f.watch("adapter")]})]})]}),V&&U.length>0&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"text-lg font-medium",children:d("bots.adapterConfig")}),(0,t.jsx)(v.default,{itemConfigList:U,initialValues:f.watch("adapter_config"),onSubmit:e=>{f.setValue("adapter_config",e)}})]})]})})})]})}class I{botId;callbacks=[];intervalIds=[];constructor(e){this.botId=e}startListenServerPush(){let e=setInterval(()=>{this.getLogList(-1,50).then(e=>{this.callbacks.forEach(t=>t(this.parseResponse(e)))})},3e3);this.intervalIds.push(Number(e))}stopServerPush(){this.intervalIds.forEach(e=>clearInterval(e)),this.intervalIds=[]}subscribeLogPush(e){this.callbacks.includes(e)||this.callbacks.push(e)}dispose(){this.callbacks=[]}getLogList(e,t=20){return i.httpClient.getBotLogs(this.botId,{from_index:e,max_count:t})}async loadFirstPage(){return this.parseResponse(await this.getLogList(-1,10))}async loadMore(e,t){return this.parseResponse(await this.getLogList(e,t))}parseResponse(e){return e.logs}}var M=e.i(4491),L=e.i(16312);function V(){return(V=Object.assign.bind()).apply(null,arguments)}function E(e,t){if(null==e)return{};var n={};for(var a in e)if(({}).hasOwnProperty.call(e,a)){if(t.includes(a))continue;n[a]=e[a]}return n}function P(e){var t=(0,n.useRef)({fn:e,curr:void 0}).current;if(t.fn=e,!t.curr){var a=Object.create(null);Object.keys(e).forEach(function(e){a[e]=function(){var n;return(n=t.fn[e]).call.apply(n,[t.fn].concat([].slice.call(arguments)))}}),t.curr=a}return t.curr}function D(e){return(0,n.useReducer)(function(e,t){return V({},e,"function"==typeof t?t(e):t)},e)}var B=(0,n.createContext)(void 0),F="cubic-bezier(0.25, 0.8, 0.25, 1)",T="u">typeof window&&"ontouchstart"in window,H=function(e,t,n){return Math.max(Math.min(e,n),t)},R=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),H(e,+(1-n),Math.max(6,t)*(1+n))},A="u"<typeof window||/ServerSideRendering/.test(navigator&&navigator.userAgent)?n.useEffect:n.useLayoutEffect;function $(e,t,a){var r=(0,n.useRef)(t);r.current=t,(0,n.useEffect)(function(){function t(e){r.current(e)}return e&&window.addEventListener(e,t,a),function(){e&&window.removeEventListener(e,t)}},[e])}var Y=["container"];function U(e){var t=e.container,a=void 0===t?document.body:t,r=E(e,Y);return(0,L.createPortal)(n.default.createElement("div",V({},r)),a)}function X(e){return n.default.createElement("svg",V({width:"44",height:"44",viewBox:"0 0 768 768"},e),n.default.createElement("path",{d:"M607.5 205.5l-178.5 178.5 178.5 178.5-45 45-178.5-178.5-178.5 178.5-45-45 178.5-178.5-178.5-178.5 45-45 178.5 178.5 178.5-178.5z"}))}function O(e){return n.default.createElement("svg",V({width:"44",height:"44",viewBox:"0 0 768 768"},e),n.default.createElement("path",{d:"M640.5 352.5v63h-390l178.5 180-45 45-256.5-256.5 256.5-256.5 45 45-178.5 180h390z"}))}function W(e){return n.default.createElement("svg",V({width:"44",height:"44",viewBox:"0 0 768 768"},e),n.default.createElement("path",{d:"M384 127.5l256.5 256.5-256.5 256.5-45-45 178.5-180h-390v-63h390l-178.5-180z"}))}function z(){return(0,n.useEffect)(function(){var e=document.body.style,t=e.overflow;return e.overflow="hidden",function(){e.overflow=t}},[]),null}function Z(e){var t=e.touches[0],n=t.clientX,a=t.clientY;if(e.touches.length>=2){var r=e.touches[1],s=r.clientX,i=r.clientY;return[(n+s)/2,(a+i)/2,Math.sqrt(Math.pow(s-n,2)+Math.pow(i-a,2))]}return[n,a,0]}var q=function(e,t,n,a){var r,s=n*t,i=(s-a)/2,o=e;return s<=a?(r=1,o=0):e>0&&i-e<=0?(r=2,o=i):e<0&&i+e<=0&&(r=3,o=-i),[r,o]};function G(e,t,n,a,r,s,i,o,l,c){void 0===i&&(i=innerWidth/2),void 0===o&&(o=innerHeight/2),void 0===l&&(l=0),void 0===c&&(c=0);var d=q(e,s,n,innerWidth)[0],u=q(t,s,a,innerHeight),m=innerWidth/2,h=innerHeight/2;return{x:i-s/r*(i-(m+e))-m+(a/n>=3&&n*s===innerWidth?0:d?l/2:l),y:o-s/r*(o-(h+t))-h+(u[0]?c/2:c),lastCX:i,lastCY:o}}function K(e,t,n){var a=e%180!=0;return a?[n,t,a]:[t,n,a]}function J(e,t,n){var a=K(n,innerWidth,innerHeight),r=a[0],s=a[1],i=0,o=r,l=s,c=e/t*s,d=t/e*r;return e<r&&t<s?(o=e,l=t):e<r&&t>=s?o=c:e>=r&&t<s||e/t>r/s?l=d:t/e>=3&&!a[2]?i=((l=d)-s)/2:o=c,{width:o,height:l,x:0,y:i,pause:!0}}function Q(e,t){var a=t.leading,r=void 0!==a&&a,s=t.maxWait,i=t.wait,o=void 0===i?s||0:i,l=(0,n.useRef)(e);l.current=e;var c=(0,n.useRef)(0),d=(0,n.useRef)(),u=function(){return d.current&&clearTimeout(d.current)},m=(0,n.useCallback)(function(){var e=[].slice.call(arguments),t=Date.now();function n(){c.current=t,u(),l.current.apply(null,e)}var a=c.current,i=t-a;if(0===a&&(r&&n(),c.current=t),void 0!==s){if(i>s)return void n()}else i<o&&(c.current=t);u(),d.current=setTimeout(function(){n(),c.current=0},o)},[o,s,r]);return m.cancel=u,m}var ee=function(e,t,n){return en(e,t,n,100,function(e){return e},function(){return en(t,e,n)})},et=function(e){return 1-Math.pow(1-e,4)};function en(e,t,n,a,r,s){void 0===a&&(a=400),void 0===r&&(r=et);var i=t-e;if(0!==i){var o=Date.now(),l=0,c=function(){var t=Math.min(1,(Date.now()-o)/a);n(e+r(t)*i)&&t<1?d():(cancelAnimationFrame(l),t>=1&&s&&s())};d()}function d(){l=requestAnimationFrame(c)}}var ea={T:0,L:0,W:0,H:0,FIT:void 0},er=function(){var e=(0,n.useRef)(!1);return(0,n.useEffect)(function(){return e.current=!0,function(){e.current=!1}},[]),e},es=["className"];function ei(e){var t=e.className,a=E(e,es);return n.default.createElement("div",V({className:"PhotoView__Spinner "+(void 0===t?"":t)},a),n.default.createElement("svg",{viewBox:"0 0 32 32",width:"36",height:"36",fill:"white"},n.default.createElement("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),n.default.createElement("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z"})))}var eo=["src","loaded","broken","className","onPhotoLoad","loadingElement","brokenElement"];function el(e){var t=e.src,a=e.loaded,r=e.broken,s=e.className,i=e.onPhotoLoad,o=e.loadingElement,l=e.brokenElement,c=E(e,eo),d=er();return t&&!r?n.default.createElement(n.default.Fragment,null,n.default.createElement("img",V({className:"PhotoView__Photo"+(s?" "+s:""),src:t,onLoad:function(e){var t=e.target;d.current&&i({loaded:!0,naturalWidth:t.naturalWidth,naturalHeight:t.naturalHeight})},onError:function(){d.current&&i({broken:!0})},draggable:!1,alt:""},c)),!a&&(o?n.default.createElement("span",{className:"PhotoView__icon"},o):n.default.createElement(ei,{className:"PhotoView__icon"}))):l?n.default.createElement("span",{className:"PhotoView__icon"},"function"==typeof l?l({src:t}):l):null}var ec={naturalWidth:void 0,naturalHeight:void 0,width:void 0,height:void 0,loaded:void 0,broken:!1,x:0,y:0,touched:!1,maskTouched:!1,rotate:0,scale:1,CX:0,CY:0,lastX:0,lastY:0,lastCX:0,lastCY:0,lastScale:1,touchTime:0,touchLength:0,pause:!0,stopRaf:!0,reach:void 0};function ed(e){var t,a,r,s,i,o,l,c,d,u,m,h,f,p,x,g,v,b,C,j,w,_,y,N,k,S,I,M,L,E,B,F,H,Y=e.item,U=Y.src,X=Y.render,O=Y.width,W=void 0===O?0:O,z=Y.height,et=void 0===z?0:z,es=Y.originRef,ei=e.visible,eo=e.speed,ed=e.easing,eu=e.wrapClassName,em=e.className,eh=e.style,ef=e.loadingElement,ep=e.brokenElement,ex=e.onPhotoTap,eg=e.onMaskTap,ev=e.onReachMove,eb=e.onReachUp,eC=e.onPhotoResize,ej=e.isActive,ew=e.expose,e_=D(ec),ey=e_[0],eN=e_[1],ek=(0,n.useRef)(0),eS=er(),eI=ey.naturalWidth,eM=void 0===eI?W:eI,eL=ey.naturalHeight,eV=void 0===eL?et:eL,eE=ey.width,eP=void 0===eE?W:eE,eD=ey.height,eB=void 0===eD?et:eD,eF=ey.loaded,eT=void 0===eF?!U:eF,eH=ey.broken,eR=ey.x,eA=ey.y,e$=ey.touched,eY=ey.stopRaf,eU=ey.maskTouched,eX=ey.rotate,eO=ey.scale,eW=ey.CX,ez=ey.CY,eZ=ey.lastX,eq=ey.lastY,eG=ey.lastCX,eK=ey.lastCY,eJ=ey.lastScale,eQ=ey.touchTime,e0=ey.touchLength,e1=ey.pause,e2=ey.reach,e5=P({onScale:function(e){return e4(R(e))},onRotate:function(e){eX!==e&&(ew({rotate:e}),eN(V({rotate:e},J(eM,eV,e))))}});function e4(e,t,n){eO!==e&&(ew({scale:e}),eN(V({scale:e},G(eR,eA,eP,eB,eO,e,t,n),e<=1&&{x:0,y:0})))}var e6=Q(function(e,t,n){if(void 0===n&&(n=0),(e$||eU)&&ej){var a=K(eX,eP,eB),r=a[0],s=a[1];if(0===n&&0===ek.current){var i=20>=Math.abs(e-eW),o=20>=Math.abs(t-ez);if(i&&o)return void eN({lastCX:e,lastCY:t});ek.current=i?t>ez?3:2:1}var l,c=e-eG,d=t-eK;if(0===n){var u,m,h=q(c+eZ,eO,r,innerWidth)[0],f=q(d+eq,eO,s,innerHeight);u=ek.current,m=f[0],void 0!==(l=h&&1===u||"x"===e2?"x":m&&u>1||"y"===e2?"y":void 0)&&ev(l,e,t,eO)}if("x"===l||eU)return void eN({reach:"x"});var p=R(eO+(n-e0)/100/2*eO,eM/eP,.2);ew({scale:p}),eN(V({touchLength:n,reach:l,scale:p},G(eR,eA,eP,eB,eO,p,e,t,c,d)))}},{maxWait:8});function e3(e){return!eY&&!e$&&(eS.current&&eN(V({},e,{pause:ei})),eS.current)}var e8,e7,e9,te,tt,tn,ta,tr=(te=function(e){return e3({x:e})},tt=function(e){return e3({y:e})},tn=function(e){return eS.current&&(ew({scale:e}),eN({scale:e})),!e$&&eS.current},ta=P({X:function(e){return te(e)},Y:function(e){return tt(e)},S:function(e){return tn(e)}}),function(e,t,n,a,r,s,i,o,l,c,d){var u=K(c,r,s),m=u[0],h=u[1],f=q(e,o,m,innerWidth),p=f[0],x=f[1],g=q(t,o,h,innerHeight),v=g[0],b=g[1],C=Date.now()-d;if(C>=200||o!==i||Math.abs(l-i)>1){var j=G(e,t,r,s,i,o),w=j.x,_=j.y,y=p?x:w!==e?w:null,N=v?b:_!==t?_:null;return null!==y&&en(e,y,ta.X),null!==N&&en(t,N,ta.Y),void(o!==i&&en(i,o,ta.S))}var k=(e-n)/C,S=(t-a)/C,I=Math.sqrt(Math.pow(k,2)+Math.pow(S,2)),M=!1,L=!1;!function(e,t){var n,a=e,r=0,s=0,i=function(s){n||(n=s);var i=s-n,c=Math.sign(e),d=-.001*c,u=Math.sign(-a)*Math.pow(a,2)*2e-4;r+=a*i+(d+u)*Math.pow(i,2)/2,n=s,c*(a+=(d+u)*i)<=0?l():t(r)?o():l()};function o(){s=requestAnimationFrame(i)}function l(){cancelAnimationFrame(s)}o()}(I,function(n){var a=e+k/I*n,r=t+S/I*n,s=q(a,i,m,innerWidth),o=s[0],l=s[1],c=q(r,i,h,innerHeight),d=c[0],u=c[1];if(o&&!M&&(M=!0,p?en(a,l,ta.X):ee(l,a+(a-l),ta.X)),d&&!L&&(L=!0,v?en(r,u,ta.Y):ee(u,r+(r-u),ta.Y)),M&&L)return!1;var f=M||ta.X(l),x=L||ta.Y(u);return f&&x})}),ts=(e8=function(e,t){e2||e4(1!==eO?1:Math.max(2,eM/eP),e,t)},e7=(0,n.useRef)(0),e9=Q(function(){e7.current=0,ex.apply(void 0,[].slice.call(arguments))},{wait:300}),function(){var e=[].slice.call(arguments);e7.current+=1,e9.apply(void 0,e),e7.current>=2&&(e9.cancel(),e7.current=0,e8.apply(void 0,e))});function ti(e,t){if(ek.current=0,(e$||eU)&&ej){eN({touched:!1,maskTouched:!1,pause:!1,stopRaf:!1,reach:void 0});var n=R(eO,eM/eP);if(tr(eR,eA,eZ,eq,eP,eB,eO,n,eJ,eX,eQ),eb(e,t),eW===e&&ez===t){if(e$)return void ts(e,t);eU&&eg(e,t)}}}function to(e,t,n){void 0===n&&(n=0),eN({touched:!0,CX:e,CY:t,lastCX:e,lastCY:t,lastX:eR,lastY:eA,lastScale:eO,touchLength:n,touchTime:Date.now()})}function tl(e){eN({maskTouched:!0,CX:e.clientX,CY:e.clientY,lastX:eR,lastY:eA})}$(T?void 0:"mousemove",function(e){e.preventDefault(),e6(e.clientX,e.clientY)}),$(T?void 0:"mouseup",function(e){ti(e.clientX,e.clientY)}),$(T?"touchmove":void 0,function(e){e.preventDefault();var t=Z(e);e6.apply(void 0,t)},{passive:!1}),$(T?"touchend":void 0,function(e){var t=e.changedTouches[0];ti(t.clientX,t.clientY)},{passive:!1}),$("resize",Q(function(){eT&&!e$&&(eN(J(eM,eV,eX)),eC())},{maxWait:8})),A(function(){ej&&ew(V({scale:eO,rotate:eX},e5))},[ej]);var tc=(y=(p=function(e){return eN({pause:e})},x=(0,n.useRef)(!1),b=(v=(g=D({lead:!0,scale:eO}))[0]).lead,C=v.scale,j=g[1],w=Q(function(e){try{return p(!0),j({lead:!1,scale:e}),Promise.resolve()}catch(e){return Promise.reject(e)}},{wait:eo}),A(function(){x.current?(p(!1),j({lead:!0}),w(eO)):x.current=!0},[eO]),_=b?[eP*C,eB*C,eO/C]:[eP*eO,eB*eO,1])[0],N=_[1],k=_[2],I=(t=ei,a=es,r=eT,s=eo,i=p,l=(o=(0,n.useState)(ea))[0],c=o[1],u=(d=(0,n.useState)(0))[0],m=d[1],h=(0,n.useRef)(),f=P({OK:function(){return t&&m(4)}}),(0,n.useEffect)(function(){if(h.current||(h.current=Date.now()),r){if(function(e,t){var n=e&&e.current;if(n&&1===n.nodeType){var a=n.getBoundingClientRect();t({T:a.top,L:a.left,W:a.width,H:a.height,FIT:"IMG"===n.tagName?getComputedStyle(n).objectFit:void 0})}}(a,c),t)return Date.now()-h.current<250?(m(1),requestAnimationFrame(function(){m(2),requestAnimationFrame(function(){i(!1),m(3)})}),void setTimeout(f.OK,s)):void m(4);i(!1),m(5)}},[t,r]),S=[u,l])[0],L=(M=S[1]).W,E=M.FIT,B=innerWidth/2,F=innerHeight/2,[(H=I<3||I>4)?L?M.L:B:eR+(B-eP*eO/2),H?L?M.T:F:eA+(F-eB*eO/2),y,H&&E?y*(M.H/L):N,0===I?k:H?L/(eP*eO)||.01:k,H?+!!E:1,I,E]),td=tc[4],tu=tc[6],tm="transform "+eo+"ms "+ed,th={className:em,onMouseDown:T?void 0:function(e){e.stopPropagation(),0===e.button&&to(e.clientX,e.clientY,0)},onTouchStart:T?function(e){e.stopPropagation(),to.apply(void 0,Z(e))}:void 0,onWheel:function(e){if(!e2){var t=R(eO-e.deltaY/100/2,eM/eP);eN({stopRaf:!0}),e4(t,e.clientX,e.clientY)}},style:{width:tc[2]+"px",height:tc[3]+"px",opacity:tc[5],objectFit:4===tu?void 0:tc[7],transform:eX?"rotate("+eX+"deg)":void 0,transition:tu>2?tm+", opacity "+eo+"ms ease, height "+(tu<4?eo/2:tu>4?eo:0)+"ms "+ed:void 0}};return n.default.createElement("div",{className:"PhotoView__PhotoWrap"+(eu?" "+eu:""),style:eh,onMouseDown:!T&&ej?tl:void 0,onTouchStart:T&&ej?function(e){return tl(e.touches[0])}:void 0},n.default.createElement("div",{className:"PhotoView__PhotoBox",style:{transform:"matrix("+td+", 0, 0, "+td+", "+tc[0]+", "+tc[1]+")",transition:e$||e1?void 0:tm,willChange:ej?"transform":void 0}},U?n.default.createElement(el,V({src:U,loaded:eT,broken:eH},th,{onPhotoLoad:function(e){eN(V({},e,e.loaded&&J(e.naturalWidth||0,e.naturalHeight||0,eX)))},loadingElement:ef,brokenElement:ep})):X&&X({attrs:th,scale:td,rotate:eX})))}var eu={x:0,touched:!1,pause:!1,lastCX:void 0,lastCY:void 0,bg:void 0,lastBg:void 0,overlay:!0,minimal:!0,scale:1,rotate:0};function em(e){var t,a,r,s,i=e.loop,o=void 0===i?3:i,l=e.speed,c=e.easing,d=e.photoClosable,u=e.maskClosable,m=void 0===u||u,h=e.maskOpacity,f=void 0===h?1:h,p=e.pullClosable,x=void 0===p||p,g=e.bannerVisible,v=void 0===g||g,b=e.overlayRender,C=e.toolbarRender,j=e.className,w=e.maskClassName,_=e.photoClassName,y=e.photoWrapClassName,N=e.loadingElement,k=e.brokenElement,S=e.images,I=e.index,M=e.onIndexChange,L=e.visible,V=e.onClose,E=e.afterClose,B=e.portalContainer,R=D(eu),Y=R[0],Z=R[1],q=(0,n.useState)(0),G=q[0],K=q[1],J=Y.x,Q=Y.touched,ee=Y.pause,et=Y.lastCX,en=Y.lastCY,ea=Y.bg,er=void 0===ea?f:ea,es=Y.lastBg,ei=Y.overlay,eo=Y.minimal,el=Y.scale,ec=Y.rotate,em=Y.onScale,eh=Y.onRotate,ef=e.hasOwnProperty("index"),ep=ef?void 0===I?0:I:G,ex=ef?M:K,eg=(0,n.useRef)(ep),ev=S.length,eb=S[ep],eC="boolean"==typeof o?o:ev>o,ej=(t=(0,n.useReducer)(function(e){return!e},!1)[1],a=(0,n.useRef)(0),s=(r=function(e){var t=(0,n.useRef)(e);function r(e){t.current=e}return(0,n.useMemo)(function(){L?(r(L),a.current=1):a.current=2},[e]),[t.current,r]}(L))[1],[r[0],a.current,function(){t(),2===a.current&&(s(!1),E&&E()),a.current=0}]),ew=ej[0],e_=ej[1],ey=ej[2];A(function(){ew?(Z({pause:!0,x:-(ep*(innerWidth+20))}),eg.current=ep):Z(eu)},[ew]);var eN=P({close:function(e){eh&&eh(0),Z({overlay:!0,lastBg:er}),V(e)},changeIndex:function(e,t){void 0===t&&(t=!1);var n=eC?eg.current+(e-ep):e,a=ev-1,r=H(n,0,a),s=eC?n:r;Z({touched:!1,lastCX:void 0,lastCY:void 0,x:-(innerWidth+20)*s,pause:t}),eg.current=s,ex&&ex(eC?e<0?a:e>a?0:e:r)}}),ek=eN.close,eS=eN.changeIndex;function eI(e){return e?ek():Z({overlay:!ei})}function eM(){Z({x:-(innerWidth+20)*ep,lastCX:void 0,lastCY:void 0,pause:!0}),eg.current=ep}function eL(e,t,n,a){"x"===e?function(e){if(void 0!==et){var t=e-et,n=t;!eC&&(0===ep&&t>0||ep===ev-1&&t<0)&&(n=t/2),Z({touched:!0,lastCX:et,x:-(innerWidth+20)*eg.current+n,pause:!1})}else Z({touched:!0,lastCX:e,x:J,pause:!1})}(t):"y"===e&&function(e,t){if(void 0!==en){var n=null===f?null:H(f,.01,f-Math.abs(e-en)/100/4);Z({touched:!0,lastCY:en,bg:1===t?n:f,minimal:1===t})}else Z({touched:!0,lastCY:e,bg:er,minimal:!0})}(n,a)}function eV(e,t){var n=e-(null!=et?et:e),a=t-(null!=en?en:t),r=!1;if(n<-40)eS(ep+1);else if(n>40)eS(ep-1);else{var s=-(innerWidth+20)*eg.current;Math.abs(a)>100&&eo&&x&&(r=!0,ek()),Z({touched:!1,x:s,lastCX:void 0,lastCY:void 0,bg:f,overlay:!!r||ei})}}$("keydown",function(e){if(L)switch(e.key){case"ArrowLeft":eS(ep-1,!0);break;case"ArrowRight":eS(ep+1,!0);break;case"Escape":ek()}});var eE=(0,n.useMemo)(function(){var e=S.length;return eC?S.concat(S).concat(S).slice(e+ep-1,e+ep+2):S.slice(Math.max(ep-1,0),Math.min(ep+2,e+1))},[S,ep,eC]);if(!ew)return null;var eP=ei&&!e_,eD=L?er:es,eB=em&&eh&&{images:S,index:ep,visible:L,onClose:ek,onIndexChange:eS,overlayVisible:eP,overlay:eb&&eb.overlay,scale:el,rotate:ec,onScale:em,onRotate:eh},eF=l?l(e_):400,eT=c?c(e_):F,eH=l?l(3):600,eR=c?c(3):F;return n.default.createElement(U,{className:"PhotoView-Portal"+(eP?"":" PhotoView-Slider__clean")+(L?"":" PhotoView-Slider__willClose")+(j?" "+j:""),role:"dialog",onClick:function(e){return e.stopPropagation()},container:B},L&&n.default.createElement(z,null),n.default.createElement("div",{className:"PhotoView-Slider__Backdrop"+(w?" "+w:"")+(1===e_?" PhotoView-Slider__fadeIn":2===e_?" PhotoView-Slider__fadeOut":""),style:{background:eD?"rgba(0, 0, 0, "+eD+")":void 0,transitionTimingFunction:eT,transitionDuration:(Q?0:eF)+"ms",animationDuration:eF+"ms"},onAnimationEnd:ey}),v&&n.default.createElement("div",{className:"PhotoView-Slider__BannerWrap"},n.default.createElement("div",{className:"PhotoView-Slider__Counter"},ep+1," / ",ev),n.default.createElement("div",{className:"PhotoView-Slider__BannerRight"},C&&eB&&C(eB),n.default.createElement(X,{className:"PhotoView-Slider__toolbarIcon",onClick:ek}))),eE.map(function(e,t){var a=eC||0!==ep?eg.current-1+t:ep+t;return n.default.createElement(ed,{key:eC?e.key+"/"+e.src+"/"+a:e.key,item:e,speed:eF,easing:eT,visible:L,onReachMove:eL,onReachUp:eV,onPhotoTap:function(){return eI(d)},onMaskTap:function(){return eI(m)},wrapClassName:y,className:_,style:{left:(innerWidth+20)*a+"px",transform:"translate3d("+J+"px, 0px, 0)",transition:Q||ee?void 0:"transform "+eH+"ms "+eR},loadingElement:N,brokenElement:k,onPhotoResize:eM,isActive:eg.current===a,expose:Z})}),!T&&v&&n.default.createElement(n.default.Fragment,null,(eC||0!==ep)&&n.default.createElement("div",{className:"PhotoView-Slider__ArrowLeft",onClick:function(){return eS(ep-1,!0)}},n.default.createElement(O,null)),(eC||ep+1<ev)&&n.default.createElement("div",{className:"PhotoView-Slider__ArrowRight",onClick:function(){return eS(ep+1,!0)}},n.default.createElement(W,null))),b&&eB&&n.default.createElement("div",{className:"PhotoView-Slider__Overlay"},b(eB)))}var eh=["children","onIndexChange","onVisibleChange"],ef={images:[],visible:!1,index:0};function ep(e){var t=e.children,a=e.onIndexChange,r=e.onVisibleChange,s=E(e,eh),i=D(ef),o=i[0],l=i[1],c=(0,n.useRef)(0),d=o.images,u=o.visible,m=o.index,h=P({nextId:function(){return c.current+=1},update:function(e){var t=d.findIndex(function(t){return t.key===e.key});if(t>-1){var n=d.slice();return n.splice(t,1,e),void l({images:n})}l(function(t){return{images:t.images.concat(e)}})},remove:function(e){l(function(t){var n=t.images.filter(function(t){return t.key!==e});return{images:n,index:Math.min(n.length-1,m)}})},show:function(e){var t=d.findIndex(function(t){return t.key===e});l({visible:!0,index:t}),r&&r(!0,t,o)}}),f=P({close:function(){l({visible:!1}),r&&r(!1,m,o)},changeIndex:function(e){l({index:e}),a&&a(e,o)}}),p=(0,n.useMemo)(function(){return V({},o,h)},[o,h]);return n.default.createElement(B.Provider,{value:p},t,n.default.createElement(em,V({images:d,visible:u,index:m,onIndexChange:f.changeIndex,onClose:f.close},s)))}var ex=e.i(21984),eg=e.i(37106);function ev({botLog:e}){var a;let r,s,o,d,u,m,h,f,p,x,{t:g}=(0,l.useTranslation)(),v=i.httpClient.getBaseUrl(),[b,C]=(0,n.useState)(!1),[j,w]=(0,n.useState)(!1);function y(e){let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-9999px",t.style.top="-9999px",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy"),c.toast.success(g("common.copySuccess"))}catch{c.toast.error(g("common.copyFailed"))}document.body.removeChild(t)}let N=e.text.length>100||e.images.length>0;return(0,t.jsxs)("div",{className:`${M.default.botLogCardContainer}`,children:[(0,t.jsxs)("div",{className:`${M.default.cardTitleContainer}`,children:[(0,t.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[(0,t.jsx)("div",{className:`px-2 py-1 rounded text-xs font-medium uppercase ${function(e){switch(e.toLowerCase()){case"error":return"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-400";case"warning":return"bg-orange-100 text-orange-800 dark:bg-orange-900/30 dark:text-orange-400";case"info":return"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400";default:return"bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-400"}}(e.level)}`,children:e.level}),e.message_session_id&&(0,t.jsxs)("div",{className:`${M.default.tag} ${M.default.chatTag} relative`,onClick:t=>{t.stopPropagation(),navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e.message_session_id).then(()=>{C(!0),setTimeout(()=>C(!1),2e3),c.toast.success(g("common.copySuccess"))}).catch(()=>{y(e.message_session_id)}):y(e.message_session_id)},title:g("common.clickToCopy"),children:[b?(0,t.jsx)(_.Check,{className:"w-4 h-4 text-green-600"}):(0,t.jsxs)("svg",{className:"icon",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg","p-id":"1664",width:"16",height:"16",fill:"currentColor",children:[(0,t.jsx)("path",{d:"M96.1 575.7a32.2 32.1 0 1 0 64.4 0 32.2 32.1 0 1 0-64.4 0Z","p-id":"1665",fill:"currentColor"}),(0,t.jsx)("path",{d:"M742.1 450.7l-269.5-2.1c-14.3-0.1-26 13.8-26 31s11.7 31.3 26 31.4l269.5 2.1c14.3 0.1 26-13.8 26-31s-11.7-31.3-26-31.4zM742.1 577.7l-269.5-2.1c-14.3-0.1-26 13.8-26 31s11.7 31.3 26 31.4l269.5 2.1c14.3 0.2 26-13.8 26-31s-11.7-31.3-26-31.4z","p-id":"1666",fill:"currentColor"}),(0,t.jsx)("path",{d:"M736.1 63.9H417c-70.4 0-128 57.6-128 128h-64.9c-70.4 0-128 57.6-128 128v128c-0.1 17.7 14.4 32 32.2 32 17.8 0 32.2-14.4 32.2-32.1V320c0-35.2 28.8-64 64-64H289v447.8c0 70.4 57.6 128 128 128h255.1c-0.1 35.2-28.8 63.8-64 63.8H224.5c-35.2 0-64-28.8-64-64V703.5c0-17.7-14.4-32.1-32.2-32.1-17.8 0-32.3 14.4-32.3 32.1v128.3c0 70.4 57.6 128 128 128h384.1c70.4 0 128-57.6 128-128h65c70.4 0 128-57.6 128-128V255.9l-193-192z m0.1 63.4l127.7 128.3H800c-35.2 0-64-28.8-64-64v-64.3h0.2z m64 641H416.1c-35.2 0-64-28.8-64-64v-513c0-35.2 28.8-64 64-64H671V191c0 70.4 57.6 128 128 128h65.2v385.3c0 35.2-28.8 64-64 64z","p-id":"1667",fill:"currentColor"})]}),(0,t.jsx)("span",{className:`${M.default.chatId}`,children:e.message_session_id.split("")})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[N&&(0,t.jsx)("button",{onClick:()=>w(!j),className:"flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 transition-colors",children:j?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ex.ChevronDown,{className:"w-3 h-3"}),g("bots.collapse")]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eg.ChevronRight,{className:"w-3 h-3"}),g("bots.viewDetails")]})}),(0,t.jsx)("div",{className:`${M.default.timestamp}`,children:(a=e.timestamp,r=new Date,o=(s=new Date(1e3*a)).getFullYear(),d=s.getMonth()+1,u=s.getDate(),m=s.getHours().toString().padStart(2,"0"),h=s.getMinutes().toString().padStart(2,"0"),f=r.toDateString()===s.toDateString(),p=new Date(r.setDate(r.getDate()-1)).toDateString()===s.toDateString(),x=r.getFullYear()===o,f?`${m}:${h}`:p?`${g("bots.yesterday")} ${m}:${h}`:x?g("bots.dateFormat",{month:d,day:u}):g("bots.earlier"))})]})]}),(0,t.jsx)("div",{className:`${M.default.cardText}`,children:j?e.text:function(e,t=100){return e.length<=t?e:e.substring(0,t)+"..."}(e.text)}),j&&e.images.length>0&&(0,t.jsx)(ep,{children:(0,t.jsx)("div",{className:"flex flex-wrap gap-2 mt-3",children:e.images.map(e=>(0,t.jsx)("img",{src:`${v}/api/v1/files/image/${e}`,alt:"",className:"max-w-xs rounded cursor-pointer hover:opacity-90 transition-opacity"},e))})}),!j&&e.images.length>0&&(0,t.jsxs)("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:["📷 ",e.images.length," ",g("bots.imagesAttached")]})]})}var eb=e.i(90285),eC=e.i(74110),ej=e.i(30891),ew=e.i(56604),e_=e.i(75551),ey=e.i(4480);function eN({botId:e}){let{t:a}=(0,l.useTranslation)(),r=(0,ey.useRouter)(),s=(0,n.useRef)(new I(e)).current,[i,c]=(0,n.useState)([]),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(["info","warning","error"]),f=(0,n.useRef)(null),x=(0,n.useRef)(i),g=[{value:"error",label:"ERROR"},{value:"warning",label:"WARNING"},{value:"info",label:"INFO"},{value:"debug",label:"DEBUG"}];(0,n.useEffect)(()=>(s.subscribeLogPush(b),s.loadFirstPage().then(e=>{c(e.reverse())}),f.current&&f.current.addEventListener("scroll",C),()=>{s.dispose(),f.current&&f.current.removeEventListener("scroll",C)}),[]),(0,n.useEffect)(()=>{x.current=i},[i]);let v=(0,n.useMemo)(()=>0===m.length?i:i.filter(e=>m.includes(e.level)),[i,m]);function b(e){c(e.reverse())}(0,n.useEffect)(()=>(d?s.startListenServerPush():s.stopServerPush(),()=>{s.stopServerPush()}),[d]);let C=(0,n.useCallback)((0,e_.default)(()=>{if(!f.current)return;let{scrollTop:e,scrollHeight:t,clientHeight:n}=f.current,a=e+n>=t-5,r=0===e;if(a){let e,t;u(!1),0!==(t=(e=x.current)[e.length-1].seq_id)&&s.loadMore(t-1,10).then(t=>{c([...e,...t.reverse()])})}r&&u(!0),r||a||u(!1)},300),[i]);return(0,t.jsxs)("div",{className:`${M.default.botLogListContainer}`,ref:f,children:[(0,t.jsxs)("div",{className:`${M.default.listHeader}`,children:[(0,t.jsx)("div",{className:"mr-2",children:a("bots.enableAutoRefresh")}),(0,t.jsx)(o.Switch,{checked:d,onCheckedChange:e=>u(e)}),(0,t.jsx)("div",{className:"ml-4 mr-2",children:a("bots.logLevel")}),(0,t.jsxs)(eb.Popover,{children:[(0,t.jsx)(eb.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)(p.Button,{variant:"outline",size:"sm",className:"w-[180px] flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm truncate flex-1 text-left",children:0===m.length?a("bots.selectLevel"):m.length===g.length?a("bots.allLevels"):m.length>=3?`${m.length} ${a("bots.levelsSelected")}`:g.filter(e=>m.includes(e.value)).map(e=>e.label).join(", ")}),(0,t.jsx)(ej.ChevronDownIcon,{className:"ml-2 h-4 w-4 flex-shrink-0"})]})}),(0,t.jsx)(eb.PopoverContent,{className:"w-[180px] p-2",children:(0,t.jsx)("div",{className:"flex flex-col gap-2",children:g.map(e=>(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(eC.Checkbox,{id:e.value,checked:m.includes(e.value),onCheckedChange:()=>{var t;return t=e.value,void h(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t])}}),(0,t.jsx)("label",{htmlFor:e.value,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:e.label})]},e.value))})})]}),(0,t.jsxs)(p.Button,{variant:"outline",size:"sm",className:"ml-4 flex items-center gap-1",onClick:()=>r.push(`/home/monitoring?botId=${e}`),children:[(0,t.jsx)(ew.ExternalLink,{className:"h-4 w-4"}),(0,t.jsx)("span",{className:"text-sm",children:a("bots.viewDetailedLogs")})]})]}),v.map(e=>(0,t.jsx)(ev,{botLog:e},e.seq_id))]})}var ek=e.i(42839),eS=e.i(14407);function eI({botId:e}){let{t:a}=(0,l.useTranslation)(),[r,s]=(0,n.useState)([]),[o,c]=(0,n.useState)(null),[d,u]=(0,n.useState)([]),[m,h]=(0,n.useState)(!1),[f,x]=(0,n.useState)(!1),g=(0,n.useRef)(null),v=(0,n.useCallback)(async()=>{h(!0);try{let t=await i.httpClient.getBotSessions(e);s(t.sessions??[])}catch(e){console.error("Failed to load sessions:",e)}finally{h(!1)}},[e]),b=(0,n.useCallback)(async e=>{x(!0);try{let t=((await i.httpClient.getSessionMessages(e)).messages??[]).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime());u(t)}catch(e){console.error("Failed to load session messages:",e)}finally{x(!1)}},[]);(0,n.useEffect)(()=>{v()},[v]),(0,n.useEffect)(()=>{o?b(o):u([])},[o,b]),(0,n.useEffect)(()=>{let e=g.current;if(e){let t=e.querySelector("[data-radix-scroll-area-viewport]")||e;t.scrollTop=t.scrollHeight}},[d]);let C=(e,n)=>{switch(e.type){case"Plain":return(0,t.jsx)("span",{children:e.text},n);case"At":{let a=e.display||e.target?.toString()||"";return(0,t.jsxs)("span",{className:"inline-flex align-middle mx-0.5 px-1.5 py-0.5 bg-blue-200/60 dark:bg-blue-800/60 text-blue-700 dark:text-blue-300 rounded-md text-xs font-medium",children:["@",a]},n)}case"AtAll":return(0,t.jsx)("span",{className:"inline-flex align-middle mx-0.5 px-1.5 py-0.5 bg-blue-200/60 dark:bg-blue-800/60 text-blue-700 dark:text-blue-300 rounded-md text-xs font-medium",children:"@All"},n);case"Image":{let a=e.url||(e.base64?e.base64:"");if(!a)return(0,t.jsx)("span",{className:"inline-flex items-center gap-1 text-muted-foreground text-xs",children:"[Image]"},n);return(0,t.jsx)("div",{className:"my-1.5",children:(0,t.jsx)("img",{src:a,alt:"Image",className:"max-w-full max-h-52 rounded-lg"})},n)}case"Voice":{let a=e.url||(e.base64?e.base64:"");if(!a)return(0,t.jsx)("span",{className:"inline-flex items-center gap-1 text-muted-foreground text-xs",children:"🎙 [Voice]"},n);return(0,t.jsx)("div",{className:"my-1",children:(0,t.jsx)("audio",{controls:!0,src:a,className:"h-8 max-w-[220px]"})},n)}case"Quote":return(0,t.jsx)("div",{className:"mb-2 pl-2.5 border-l-2 border-gray-300 dark:border-gray-600 opacity-80",children:(0,t.jsx)("div",{className:"text-sm",children:e.origin?.map((e,t)=>C(e,t))})},n);case"Source":return null;case"File":return(0,t.jsxs)("span",{className:"text-muted-foreground text-xs",children:["📎 ",e.name||"File"]},n);default:return(0,t.jsxs)("span",{className:"text-muted-foreground text-xs",children:["[",e.type,"]"]},n)}},j=r.find(e=>e.session_id===o);return(0,t.jsxs)("div",{className:"flex h-full min-h-0",children:[(0,t.jsxs)("div",{className:"w-64 flex-shrink-0 border-r flex flex-col min-h-0",children:[(0,t.jsxs)("div",{className:"px-4 py-3 border-b shrink-0 flex items-center justify-between",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:a("bots.sessionMonitor.sessions")}),(0,t.jsx)(p.Button,{variant:"ghost",size:"icon",className:"w-7 h-7",onClick:v,disabled:m,children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:(0,eS.cn)("w-3.5 h-3.5",m&&"animate-spin"),children:(0,t.jsx)("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"})})})]}),(0,t.jsx)(ek.ScrollArea,{className:"flex-1 min-h-0",children:m&&0===r.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-sm text-muted-foreground",children:a("bots.sessionMonitor.loading")}):0===r.length?(0,t.jsx)("div",{className:"text-center text-muted-foreground py-12 text-sm",children:a("bots.sessionMonitor.noSessions")}):(0,t.jsx)("div",{className:"p-1",children:r.map(e=>{let n=o===e.session_id;return(0,t.jsxs)("button",{className:(0,eS.cn)("w-full text-left px-3 py-2.5 rounded-md transition-colors",n?"bg-accent":"hover:bg-accent/50"),onClick:()=>c(e.session_id),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-0.5",children:[(0,t.jsx)("span",{className:"text-sm font-medium truncate mr-2",children:e.user_id||e.session_id.slice(0,12)}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground tabular-nums flex-shrink-0",children:(e=>{if(!e)return"";let t=new Date(e),n=new Date().getTime()-t.getTime(),a=Math.floor(n/6e4),r=Math.floor(n/36e5),s=Math.floor(n/864e5);return a<1?"<1m":a<60?`${a}m`:r<24?`${r}h`:`${s}d`})(e.last_activity)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.platform&&(0,t.jsx)("span",{className:"px-1 py-0.5 rounded bg-muted text-[10px]",children:e.platform}),e.is_active&&(0,t.jsx)("span",{className:"flex items-center gap-0.5 text-green-600 dark:text-green-400",children:(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 inline-block"})}),(0,t.jsxs)("span",{children:[e.message_count," ",a("bots.sessionMonitor.messages")]})]})]},e.session_id)})})})]}),(0,t.jsx)("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:o?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"px-6 py-3 border-b shrink-0 flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-sm font-medium truncate",children:j?.user_id||o.slice(0,20)}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[j?.platform&&(0,t.jsx)("span",{children:j.platform}),j?.pipeline_name&&(0,t.jsxs)(t.Fragment,{children:[j?.platform&&(0,t.jsx)("span",{children:"·"}),(0,t.jsx)("span",{children:j.pipeline_name})]}),j?.is_active&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{children:"·"}),(0,t.jsxs)("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400",children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500 inline-block"}),"Active"]})]})]})]}),(0,t.jsx)(p.Button,{variant:"ghost",size:"icon",className:"w-8 h-8",onClick:()=>b(o),disabled:f,children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:(0,eS.cn)("w-4 h-4",f&&"animate-spin"),children:(0,t.jsx)("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"})})})]}),(0,t.jsx)(ek.ScrollArea,{ref:g,className:"flex-1 p-6 overflow-y-auto min-h-0 bg-white dark:bg-black",children:(0,t.jsx)("div",{className:"space-y-6",children:f?(0,t.jsx)("div",{className:"text-center text-muted-foreground py-12 text-lg",children:a("bots.sessionMonitor.loading")}):0===d.length?(0,t.jsx)("div",{className:"text-center text-muted-foreground py-12 text-lg",children:a("bots.sessionMonitor.noMessages")}):d.map(e=>{let n,r="assistant"!==e.role&&("user"===e.role||!e.runner_name);return(0,t.jsx)("div",{className:(0,eS.cn)("flex",r?"justify-end":"justify-start"),children:(0,t.jsxs)("div",{className:(0,eS.cn)("max-w-3xl px-5 py-3 rounded-2xl",r?"bg-blue-100 dark:bg-blue-900 text-gray-900 dark:text-gray-100 rounded-br-none":"bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-bl-none","error"===e.status&&"ring-1 ring-red-400/50"),children:[(n=(e=>{try{let t=JSON.parse(e);if(Array.isArray(t))return t}catch{}return[{type:"Plain",text:e}]})(e.message_content),(0,t.jsx)("div",{className:"whitespace-pre-wrap break-words",children:n.map((e,t)=>C(e,t))})),(0,t.jsxs)("div",{className:(0,eS.cn)("text-xs mt-2 flex items-center gap-2",r?"text-gray-600 dark:text-gray-300":"text-gray-500 dark:text-gray-400"),children:[(0,t.jsx)("span",{children:r?a("bots.sessionMonitor.userMessage",{defaultValue:"User"}):a("bots.sessionMonitor.botMessage",{defaultValue:"Assistant"})}),(0,t.jsx)("span",{className:"tabular-nums",children:(e=>{if(!e)return"";let t=new Date(e),n=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0");return`${n}:${a}`})(e.timestamp)}),"error"===e.status&&(0,t.jsx)("span",{className:"text-red-500",children:"error"}),e.runner_name&&(0,t.jsx)("span",{className:"opacity-70",children:e.runner_name})]})]})},e.id)})})})]}):(0,t.jsx)("div",{className:"text-center text-muted-foreground py-12 text-lg flex-1 flex items-center justify-center",children:a("bots.sessionMonitor.selectSession")})})]})}function eM({open:e,onOpenChange:a,botId:r,onFormSubmit:s,onFormCancel:o,onBotDeleted:c,onNewBotCreated:d}){let{t:u}=(0,l.useTranslation)(),[m,x]=(0,n.useState)(r),[g,v]=(0,n.useState)("config"),[b,C]=(0,n.useState)(!1);(0,n.useEffect)(()=>{x(r),v("config")},[r,e]);let j=[{key:"config",label:u("bots.configuration"),icon:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M5 7C5 6.17157 5.67157 5.5 6.5 5.5C7.32843 5.5 8 6.17157 8 7C8 7.82843 7.32843 8.5 6.5 8.5C5.67157 8.5 5 7.82843 5 7ZM6.5 3.5C4.567 3.5 3 5.067 3 7C3 8.933 4.567 10.5 6.5 10.5C8.433 10.5 10 8.933 10 7C10 5.067 8.433 3.5 6.5 3.5ZM12 8H20V6H12V8ZM16 17C16 16.1716 16.6716 15.5 17.5 15.5C18.3284 15.5 19 16.1716 19 17C19 17.8284 18.3284 18.5 17.5 18.5C16.6716 18.5 16 17.8284 16 17ZM17.5 13.5C15.567 13.5 14 15.067 14 17C14 18.933 15.567 20.5 17.5 20.5C19.433 20.5 21 18.933 21 17C21 15.067 19.433 13.5 17.5 13.5ZM4 16V18H12V16H4Z"})})},{key:"logs",label:u("bots.logs"),icon:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M21 8V20.9932C21 21.5501 20.5552 22 20.0066 22H3.9934C3.44495 22 3 21.556 3 21.0082V2.9918C3 2.45531 3.4487 2 4.00221 2H14.9968L21 8ZM19 9H14V4H5V20H19V9ZM8 7H11V9H8V7ZM8 11H16V13H8V11ZM8 15H16V17H8V15Z"})})},{key:"sessions",label:u("bots.sessionMonitor.title"),icon:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",children:(0,t.jsx)("path",{d:"M2 22C2 17.5817 5.58172 14 10 14C14.4183 14 18 17.5817 18 22H16C16 18.6863 13.3137 16 10 16C6.68629 16 4 18.6863 4 22H2ZM10 13C6.685 13 4 10.315 4 7C4 3.685 6.685 1 10 1C13.315 1 16 3.685 16 7C16 10.315 13.315 13 10 13ZM10 11C12.21 11 14 9.21 14 7C14 4.79 12.21 3 10 3C7.79 3 6 4.79 6 7C6 9.21 7.79 11 10 11ZM18.2837 14.7028C21.0644 15.9561 23 18.752 23 22H21C21 19.564 19.5483 17.4671 17.4628 16.5271L18.2837 14.7028ZM17.5962 3.41321C19.5944 4.23703 21 6.20361 21 8.5C21 11.3702 18.8042 13.7252 16 13.9776V11.9646C17.6967 11.7222 19 10.264 19 8.5C19 7.11935 18.2016 5.92603 17.041 5.35635L17.5962 3.41321Z"})})}],w=e=>{s(e)},_=()=>{o()},y=()=>{i.httpClient.deleteBot(m??"").then(()=>{c()})},N=e=>{x(e),v("config"),d(e)};return m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h.Dialog,{open:e,onOpenChange:a,children:(0,t.jsx)(h.DialogContent,{className:"overflow-hidden p-0 !max-w-[70rem] max-h-[75vh] flex",children:(0,t.jsxs)(f.SidebarProvider,{className:"items-start w-full flex",children:[(0,t.jsx)(f.Sidebar,{collapsible:"none",className:"hidden md:flex h-[80vh] w-40 min-w-[120px] border-r bg-white dark:bg-black",children:(0,t.jsx)(f.SidebarContent,{children:(0,t.jsx)(f.SidebarGroup,{children:(0,t.jsx)(f.SidebarGroupContent,{children:(0,t.jsx)(f.SidebarMenu,{children:j.map(e=>(0,t.jsx)(f.SidebarMenuItem,{children:(0,t.jsx)(f.SidebarMenuButton,{asChild:!0,isActive:g===e.key,onClick:()=>v(e.key),children:(0,t.jsxs)("a",{href:"#",children:[e.icon,(0,t.jsx)("span",{children:e.label})]})})},e.key))})})})})}),(0,t.jsxs)("main",{className:"flex flex-1 flex-col h-[75vh]",children:[(0,t.jsxs)(h.DialogHeader,{className:"px-6 pt-6 pb-4 shrink-0",children:[(0,t.jsx)(h.DialogTitle,{children:u("config"===g?"bots.editBot":"logs"===g?"bots.botLogTitle":"bots.sessionMonitor.title")}),(0,t.jsx)(h.DialogDescription,{className:"sr-only",children:u("config"===g?"bots.editBot":"logs"===g?"bots.botLogTitle":"bots.sessionMonitor.title")})]}),(0,t.jsxs)("div",{className:"sessions"===g?"flex-1 min-h-0":"flex-1 overflow-y-auto px-6 pb-6",children:["config"===g&&(0,t.jsx)(S,{initBotId:m,onFormSubmit:w,onBotDeleted:y,onNewBotCreated:N}),"logs"===g&&m&&(0,t.jsx)(eN,{botId:m}),"sessions"===g&&m&&(0,t.jsx)(eI,{botId:m})]}),"config"===g&&(0,t.jsx)(h.DialogFooter,{className:"px-6 py-4 border-t shrink-0",children:(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(p.Button,{type:"button",variant:"destructive",onClick:()=>{C(!0)},children:u("common.delete")}),(0,t.jsx)(p.Button,{type:"submit",form:"bot-form",children:u("common.save")}),(0,t.jsx)(p.Button,{type:"button",variant:"outline",onClick:_,children:u("common.cancel")})]})})]})]})})}),(0,t.jsx)(h.Dialog,{open:b,onOpenChange:C,children:(0,t.jsxs)(h.DialogContent,{children:[(0,t.jsxs)(h.DialogHeader,{children:[(0,t.jsx)(h.DialogTitle,{children:u("common.confirmDelete")}),(0,t.jsx)(h.DialogDescription,{className:"sr-only",children:u("bots.deleteConfirmation")})]}),(0,t.jsx)("div",{className:"py-4",children:u("bots.deleteConfirmation")}),(0,t.jsxs)(h.DialogFooter,{children:[(0,t.jsx)(p.Button,{variant:"outline",onClick:()=>C(!1),children:u("common.cancel")}),(0,t.jsx)(p.Button,{variant:"destructive",onClick:()=>{y(),C(!1)},children:u("common.confirmDelete")})]})]})})]}):(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(h.Dialog,{open:e,onOpenChange:a,children:(0,t.jsx)(h.DialogContent,{className:"overflow-hidden p-0 !max-w-[40vw] max-h-[70vh] flex",children:(0,t.jsxs)("main",{className:"flex flex-1 flex-col h-[70vh]",children:[(0,t.jsxs)(h.DialogHeader,{className:"px-6 pt-6 pb-4 shrink-0",children:[(0,t.jsx)(h.DialogTitle,{children:u("bots.createBot")}),(0,t.jsx)(h.DialogDescription,{className:"sr-only",children:u("bots.createBot")})]}),(0,t.jsx)("div",{className:"flex-1 overflow-y-auto px-6 pb-6",children:(0,t.jsx)(S,{initBotId:void 0,onFormSubmit:w,onBotDeleted:y,onNewBotCreated:N})}),(0,t.jsx)(h.DialogFooter,{className:"px-6 py-4 border-t shrink-0",children:(0,t.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,t.jsx)(p.Button,{type:"submit",form:"bot-form",children:u("common.submit")}),(0,t.jsx)(p.Button,{type:"button",variant:"outline",onClick:_,children:u("common.cancel")})]})})]})})})})}var eL=e.i(15742);function eV(){let{t:e}=(0,l.useTranslation)(),[s,o]=(0,n.useState)(!1),[h,f]=(0,n.useState)([]),[p,x]=(0,n.useState)("");async function g(){let t=(await i.httpClient.getAdapters()).adapters.map(e=>({label:(0,m.extractI18nObject)(e.label),value:e.name}));i.httpClient.getBots().then(e=>{f(e.bots.map(e=>new r({id:e.uuid||"",iconURL:i.httpClient.getAdapterIconURL(e.adapter),name:e.name,description:e.description,adapter:e.adapter,adapterConfig:e.adapter_config,adapterLabel:t.find(t=>t.value===e.adapter)?.label||e.adapter.substring(0,10),usePipelineName:e.use_pipeline_name||"",enable:e.enable||!1})))}).catch(t=>{console.error("get bot list error",t),c.toast.error(e("bots.getBotListError")+t.msg)})}return(0,n.useEffect)(()=>{g()},[]),(0,t.jsxs)("div",{children:[(0,t.jsx)(eM,{open:s,onOpenChange:o,botId:p||void 0,onFormSubmit:function(){g()},onFormCancel:function(){o(!1)},onBotDeleted:function(){g(),o(!1)},onNewBotCreated:function(e){g(),x(e)}}),(0,t.jsxs)("div",{className:`${a.default.botListContainer}`,children:[(0,t.jsx)(u.default,{width:"100%",height:"10rem",plusSize:"90px",onClick:function(){let t=eL.systemInfo.limitation?.max_bots??-1;t>=0&&h.length>=t?c.toast.error(e("limitation.maxBotsReached",{max:t})):(x(""),o(!0))}}),h.map(e=>(0,t.jsx)("div",{onClick:()=>{x(e.id),o(!0)},children:(0,t.jsx)(d,{botCardVO:e,setBotEnableCallback:(e,t)=>{f(h.map(n=>n.id===e?{...n,enable:t}:n))}})},e.id))]})]})}e.s(["default",()=>eV],79648)}]);