@nocobase/plugin-ai 2.1.23 → 2.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/docs/nocobase/multi-app/multi-app-vs-multi-portal-vs-multi-space.md +159 -0
- package/dist/ai/docs/nocobase/multi-app/multi-portal/index.md +195 -0
- package/dist/client/646.02b133e5482c37e9.js +10 -0
- package/dist/client/index.js +3 -3
- package/dist/externalVersion.js +16 -16
- package/dist/locale/en-US.json +2 -0
- package/dist/locale/zh-CN.json +2 -0
- package/dist/node_modules/@langchain/mistralai/package.json +1 -1
- package/dist/node_modules/@langchain/xai/package.json +1 -1
- package/dist/node_modules/fs-extra/package.json +1 -1
- package/dist/node_modules/jsonrepair/package.json +1 -1
- package/dist/node_modules/just-bash/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/node_modules/openai/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/ai-employees/ai-employee.d.ts +1 -0
- package/dist/server/ai-employees/ai-employee.js +30 -1
- package/dist/server/attachments.d.ts +23 -0
- package/dist/server/attachments.js +203 -0
- package/dist/server/llm-providers/anthropic.d.ts +2 -1
- package/dist/server/llm-providers/anthropic.js +1 -3
- package/dist/server/llm-providers/google-genai.d.ts +1 -1
- package/dist/server/llm-providers/google-genai.js +1 -5
- package/dist/server/llm-providers/provider.d.ts +3 -2
- package/dist/server/llm-providers/provider.js +23 -3
- package/dist/server/plugin.js +14 -0
- package/dist/server/resource/aiConversations.js +28 -0
- package/dist/server/utils.d.ts +5 -2
- package/dist/server/utils.js +11 -19
- package/dist/server/workflow/nodes/employee/files.d.ts +3 -1
- package/dist/server/workflow/nodes/employee/files.js +29 -5
- package/package.json +2 -2
- package/dist/client/646.d4483b4ff23da0a0.js +0 -10
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Multi-portal, Multi-app, and Multi-space
|
|
2
|
+
|
|
3
|
+
NocoBase provides three capabilities: Multi-portal, Multi-app, and Multi-space.
|
|
4
|
+
|
|
5
|
+
They solve problems at different levels. They can be used independently or together.
|
|
6
|
+
|
|
7
|
+
## Key differences
|
|
8
|
+
|
|
9
|
+
| Capability | Multi-portal | Multi-app | Multi-space |
|
|
10
|
+
|------|------|------|------|
|
|
11
|
+
| What problem it solves | Provides multiple access entries | Splits business into multiple systems | Isolates business data |
|
|
12
|
+
| Core focus | Where users enter | How the system is divided | Who the data belongs to |
|
|
13
|
+
| Data | Shared | Independent by default | Isolated |
|
|
14
|
+
| Pages and menus | Independent | Independent | Shared |
|
|
15
|
+
| Plugin configuration | Shared | Independent | Shared |
|
|
16
|
+
| User system | Shared | Can be shared through SSO | Shared |
|
|
17
|
+
| Typical scenarios | Different roles need different entries | Different businesses need independent management | Multiple organizations, stores, or tenants |
|
|
18
|
+
| Can be combined | Yes | Yes | Yes |
|
|
19
|
+
|
|
20
|
+
## Multi-portal
|
|
21
|
+
|
|
22
|
+
Multi-portal provides multiple access entries within the same application.
|
|
23
|
+
|
|
24
|
+
For example:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
ERP App
|
|
28
|
+
|
|
29
|
+
├─ Admin Portal (/v/admin)
|
|
30
|
+
├─ Store Portal (/v/store)
|
|
31
|
+
├─ Distributor Portal (/v/dealer)
|
|
32
|
+
└─ Mobile Portal (/v/mobile)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Features:
|
|
36
|
+
|
|
37
|
+
- Uses the same application
|
|
38
|
+
- Shares the same data
|
|
39
|
+
- Shares plugin configuration
|
|
40
|
+
- Pages and menus can be configured independently
|
|
41
|
+
|
|
42
|
+
Suitable for scenarios where different roles need different access entries, such as:
|
|
43
|
+
|
|
44
|
+
- Administrators
|
|
45
|
+
- Employees
|
|
46
|
+
- Customers
|
|
47
|
+
- Distributors
|
|
48
|
+
|
|
49
|
+
## Multi-app
|
|
50
|
+
|
|
51
|
+
Multi-app splits business into multiple independent applications.
|
|
52
|
+
|
|
53
|
+
For example:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
Group System
|
|
57
|
+
|
|
58
|
+
├─ CRM
|
|
59
|
+
├─ ERP
|
|
60
|
+
├─ OA
|
|
61
|
+
└─ Analytics
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Features:
|
|
65
|
+
|
|
66
|
+
- Each app is managed independently
|
|
67
|
+
- Independent plugin configuration
|
|
68
|
+
- Independent database connection
|
|
69
|
+
- Independent upgrade and maintenance
|
|
70
|
+
|
|
71
|
+
Suitable for:
|
|
72
|
+
|
|
73
|
+
- Splitting large business systems
|
|
74
|
+
- Multi-team collaborative development
|
|
75
|
+
- Batch creation of apps for SaaS platforms
|
|
76
|
+
- Independent apps for different customers
|
|
77
|
+
|
|
78
|
+
## Multi-space
|
|
79
|
+
|
|
80
|
+
Multi-space isolates business data within the same application.
|
|
81
|
+
|
|
82
|
+
For example:
|
|
83
|
+
|
|
84
|
+
```text
|
|
85
|
+
Store Management App
|
|
86
|
+
|
|
87
|
+
Spaces
|
|
88
|
+
├─ Beijing Store
|
|
89
|
+
├─ Shanghai Store
|
|
90
|
+
└─ Shenzhen Store
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Features:
|
|
94
|
+
|
|
95
|
+
- Shared pages
|
|
96
|
+
- Shared menus
|
|
97
|
+
- Shared workflows
|
|
98
|
+
- Shared configuration
|
|
99
|
+
- Isolated data
|
|
100
|
+
|
|
101
|
+
For tables that have a space field enabled, the system automatically filters data according to the current space.
|
|
102
|
+
|
|
103
|
+
From the user's perspective:
|
|
104
|
+
|
|
105
|
+
- The Beijing store can only see Beijing store data
|
|
106
|
+
- The Shanghai store can only see Shanghai store data
|
|
107
|
+
- The Shenzhen store can only see Shenzhen store data
|
|
108
|
+
|
|
109
|
+
But all stores still use the same system.
|
|
110
|
+
|
|
111
|
+
## Relationship among the three
|
|
112
|
+
|
|
113
|
+
These three capabilities do not conflict. They work on different dimensions.
|
|
114
|
+
|
|
115
|
+
They can be used together:
|
|
116
|
+
|
|
117
|
+
```text
|
|
118
|
+
Group System
|
|
119
|
+
|
|
120
|
+
CRM App
|
|
121
|
+
├─ Admin Portal
|
|
122
|
+
├─ Sales Portal
|
|
123
|
+
└─ Customer Portal
|
|
124
|
+
|
|
125
|
+
Spaces
|
|
126
|
+
├─ Beijing Branch
|
|
127
|
+
├─ Shanghai Branch
|
|
128
|
+
└─ Shenzhen Branch
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Conceptually:
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
Portal
|
|
135
|
+
↓
|
|
136
|
+
Where users enter the system
|
|
137
|
+
|
|
138
|
+
App
|
|
139
|
+
↓
|
|
140
|
+
How the system is divided
|
|
141
|
+
|
|
142
|
+
Space
|
|
143
|
+
↓
|
|
144
|
+
Who the data belongs to
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## How to choose
|
|
148
|
+
|
|
149
|
+
If you only want to provide different entries for different roles, choose **Multi-portal**.
|
|
150
|
+
|
|
151
|
+
If you want to split business into multiple independent systems, choose **Multi-app**.
|
|
152
|
+
|
|
153
|
+
If you want to isolate data for different organizations or tenants within the same system, choose **Multi-space**.
|
|
154
|
+
|
|
155
|
+
In real projects, these three capabilities are usually combined rather than used as substitutes for one another.
|
|
156
|
+
|
|
157
|
+
In one sentence:
|
|
158
|
+
|
|
159
|
+
> Multi-portal solves entry points, Multi-app solves system splitting, and Multi-space solves data isolation.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Multi-portal"
|
|
3
|
+
description: "Learn the concept, use cases, configuration, and relationship between Multi-portal, Multi-app, and Multi-space in NocoBase."
|
|
4
|
+
keywords: "workspace, portal, multi-portal, NocoBase"
|
|
5
|
+
pkg: "@nocobase/plugin-multi-portal"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Multi-portal
|
|
9
|
+
|
|
10
|
+
## What is a portal
|
|
11
|
+
|
|
12
|
+
A portal is used to provide multiple access entries within the same application.
|
|
13
|
+
|
|
14
|
+
Each portal can have its own:
|
|
15
|
+
|
|
16
|
+
- Pages
|
|
17
|
+
- Menus
|
|
18
|
+
- Navigation structure
|
|
19
|
+
- Layout
|
|
20
|
+
- Permission settings
|
|
21
|
+
|
|
22
|
+
The Multi-portal plugin provides the following capabilities:
|
|
23
|
+
|
|
24
|
+
- Portal management
|
|
25
|
+
- Portal switching
|
|
26
|
+
- Portal permission control
|
|
27
|
+
|
|
28
|
+
With these capabilities, you can provide different experiences for different roles while sharing the same data and business capabilities.
|
|
29
|
+
|
|
30
|
+
## Why use portals
|
|
31
|
+
|
|
32
|
+
In real business scenarios, different roles often need different interfaces.
|
|
33
|
+
|
|
34
|
+
For example, in a retail management system:
|
|
35
|
+
|
|
36
|
+
```text
|
|
37
|
+
Retail Management System
|
|
38
|
+
|
|
39
|
+
├─ Headquarters Portal
|
|
40
|
+
├─ Store Portal
|
|
41
|
+
├─ Distributor Portal
|
|
42
|
+
└─ Mobile Portal
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Headquarters staff focus on:
|
|
46
|
+
|
|
47
|
+
- Product management
|
|
48
|
+
- Inventory management
|
|
49
|
+
- Data analysis
|
|
50
|
+
|
|
51
|
+
Store staff focus on:
|
|
52
|
+
|
|
53
|
+
- Cashiering
|
|
54
|
+
- Stocktaking
|
|
55
|
+
- Order processing
|
|
56
|
+
|
|
57
|
+
Distributors focus on:
|
|
58
|
+
|
|
59
|
+
- Purchasing
|
|
60
|
+
- Reconciliation
|
|
61
|
+
- Shipment status
|
|
62
|
+
|
|
63
|
+
Although everyone uses the same system, different roles do not need to see the same menus and pages.
|
|
64
|
+
|
|
65
|
+
That is exactly the problem portals solve.
|
|
66
|
+
|
|
67
|
+
## Relationship between portals and menus
|
|
68
|
+
|
|
69
|
+
Each portal has its own menu tree.
|
|
70
|
+
|
|
71
|
+
Menus in different portals do not affect each other.
|
|
72
|
+
|
|
73
|
+
For example:
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
Headquarters Portal
|
|
77
|
+
├─ Product Management
|
|
78
|
+
├─ Supply Chain Management
|
|
79
|
+
└─ Data Analysis
|
|
80
|
+
|
|
81
|
+
Store Portal
|
|
82
|
+
├─ Cashiering
|
|
83
|
+
├─ Order Management
|
|
84
|
+
└─ Stocktaking
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Relationship between portals and pages
|
|
88
|
+
|
|
89
|
+
Pages belong to their respective portals.
|
|
90
|
+
|
|
91
|
+
The same page can also be shown only in specific portals.
|
|
92
|
+
|
|
93
|
+
This makes it possible to design completely different workflows for different roles.
|
|
94
|
+
|
|
95
|
+
## Relationship between portals and permissions
|
|
96
|
+
|
|
97
|
+
Portals themselves can be configured with access permissions.
|
|
98
|
+
|
|
99
|
+
Only authorized users can access the corresponding portal.
|
|
100
|
+
|
|
101
|
+
Unauthorized portals:
|
|
102
|
+
|
|
103
|
+
- Do not appear in the switcher list
|
|
104
|
+
- Cannot be accessed directly
|
|
105
|
+
|
|
106
|
+
## Portal management
|
|
107
|
+
|
|
108
|
+
After enabling the Multi-portal plugin, the system provides two built-in portals by default:
|
|
109
|
+
|
|
110
|
+
| Portal | Path | Purpose |
|
|
111
|
+
|----------|----------|----------|
|
|
112
|
+
| Desktop | `/v/admin` | Desktop entry |
|
|
113
|
+
| Mobile | `/v/mobile` | Mobile entry |
|
|
114
|
+
|
|
115
|
+
### Built-in portals
|
|
116
|
+
|
|
117
|
+

|
|
118
|
+
|
|
119
|
+
### Desktop portal
|
|
120
|
+
|
|
121
|
+
Access path:
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
/v/admin
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+

|
|
128
|
+
|
|
129
|
+
### Mobile portal
|
|
130
|
+
|
|
131
|
+
Access path:
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
/v/mobile
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+

|
|
138
|
+
|
|
139
|
+
## Create a portal
|
|
140
|
+
|
|
141
|
+
In addition to the built-in portals, you can create more portals based on business needs.
|
|
142
|
+
|
|
143
|
+
For example:
|
|
144
|
+
|
|
145
|
+
- Store portal
|
|
146
|
+
- Distributor portal
|
|
147
|
+
- Customer service portal
|
|
148
|
+
- Data analysis portal
|
|
149
|
+
|
|
150
|
+
After creation, you can configure:
|
|
151
|
+
|
|
152
|
+
- Pages
|
|
153
|
+
- Menus
|
|
154
|
+
- Permissions
|
|
155
|
+
- Navigation
|
|
156
|
+
|
|
157
|
+

|
|
158
|
+
|
|
159
|
+
## Switch portals
|
|
160
|
+
|
|
161
|
+
Users can quickly switch between portals through the portal switcher.
|
|
162
|
+
|
|
163
|
+
### Switch portals within a single app
|
|
164
|
+
|
|
165
|
+
Add it to the portal switcher panel in the upper-left corner
|
|
166
|
+
|
|
167
|
+

|
|
168
|
+
|
|
169
|
+
Add it to the action panel block
|
|
170
|
+
|
|
171
|
+

|
|
172
|
+
|
|
173
|
+
### Switch portals across apps
|
|
174
|
+
|
|
175
|
+
After enabling Multi-app and configuring SSO, users can also switch between portals across different apps through the portal switcher.
|
|
176
|
+
|
|
177
|
+
Add it to the portal switcher panel in the upper-left corner
|
|
178
|
+
|
|
179
|
+

|
|
180
|
+
|
|
181
|
+
Add it to the action panel block
|
|
182
|
+
|
|
183
|
+

|
|
184
|
+
|
|
185
|
+
## Portal permissions
|
|
186
|
+
|
|
187
|
+
You can control which portals a user can access through role permissions.
|
|
188
|
+
|
|
189
|
+
Unauthorized portals do not appear in the portal switcher list, and users cannot access those entries directly.
|
|
190
|
+
|
|
191
|
+

|
|
192
|
+
|
|
193
|
+
## Related links
|
|
194
|
+
|
|
195
|
+
For the differences and combination patterns among Multi-portal, Multi-app, and Multi-space, see: [Multi-portal, Multi-app, and Multi-space](../multi-app-vs-multi-portal-vs-multi-space.md).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
"use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["646"],{7289:function(e,t,n){n.r(t),n.d(t,{AIEmployeesProvider:function(){return ns}});var r=n(9155),o=n.n(r),l=n(4118),a=n(3342),i=(0,r.createContext)({}),u=function(e){var t=(0,a.useAPIClient)(),n=(0,a.useRequest)(function(){return t.resource("aiSettings").publicGet().then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})}).data;return o().createElement(i.Provider,{value:n},e.children)},c=n(2059),s=n(7375),f=n(5477),p=n(3079),d=n(7330),m=n(2326),y=n(7546),v=n(2456),b=n(7821),g=n(7596),h=n(2341),E=n(5230),w=n(166),O=n(7262),S=n(4181),x=function(){return o().createElement(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE})};function k(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function j(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){k(l,r,o,a,i,"next",e)}function i(e){k(l,r,o,a,i,"throw",e)}a(void 0)})}}function C(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function I(){var e,t,n=(e=["\n .ant-conversations-item {\n .ant-conversations-label {\n display: block !important;\n overflow: hidden !important;\n text-overflow: ellipsis !important;\n white-space: nowrap !important;\n max-width: calc(100% - 30px);\n }\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return I=function(){return n},n}var P=function(e){var t,n=null==e||null==(t=e.options)?void 0:t.modelSettings;if((null==n?void 0:n.llmService)&&(null==n?void 0:n.model))return{llmService:n.llmService,model:n.model}},A=(0,f.css)(I()),T=function(){var e=(0,a.useActionContext)().setVisible,t=(0,E.useForm)();return{onClick:function(){e(!1),t.reset()}}},M=function(e){var t=(0,a.useActionContext)().setVisible,n=(0,a.useAPIClient)(),r=(0,E.useForm)(),o=(0,O.o)().refresh;return{onClick:function(){return j(function(){return C(this,function(l){switch(l.label){case 0:return[4,r.submit()];case 1:return l.sent(),[4,n.resource("aiConversations").update({filterByTk:e,values:{title:r.values.title}})];case 2:return l.sent(),t(!1),r.reset(),o(),[2]}})})()}}},R=function(e){var t,n,r,l=e.conversation,i=(0,p.kj)();return o().createElement(a.SchemaComponent,{scope:{useCloseActionProps:T,useSubmitActionProps:function(){return M(l.key)}},schema:{name:"rename",type:"void","x-component":"Action","x-component-props":{component:function(e){return o().createElement("div",e,i("Rename"))}},title:i("Rename"),properties:(t={},n=(0,w.uid)(),r={type:"void","x-component":"Action.Modal","x-component-props":{styles:{mask:{zIndex:1100},wrapper:{zIndex:1100}}},title:i("Rename conversation"),"x-decorator":"FormV2",properties:{title:{type:"string",title:i("Title"),required:!0,"x-decorator":"FormItem","x-component":"Input",default:l.title||""},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{close:{title:i("Cancel"),"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:i("Submit"),"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSubmitActionProps"}}}}},n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t)}})},B=function(e){var t,n,l,i,u=e.onOpenConversation,f=(0,p.kj)(),d=(0,r.useRef)(null),y=(0,a.useAPIClient)(),v=c.App.useApp(),E=v.modal,w=v.message,k=g.J.use.conversations(),I=null==(t=(n=g.J.use).currentConversation)?void 0:t.call(n),T=null==(l=(i=b.I.use).currentEmployee)?void 0:l.call(i),M=b.I.use.setReadonly(),B=S.u.use.setCurrentWorkflowTask(),D=(0,m.Q)().startNewConversation,z=(0,O.o)(),L=z.refresh,F=z.lastConversationRef,J=(0,r.useCallback)(function(e){M(!1),B(void 0);var t,n=k.find(function(t){return t.sessionId===e});u(e,null==n||null==(t=n.aiEmployee)?void 0:t.username,P(n))},[u,k,B,M]),N=(0,r.useCallback)(function(e){if(e&&k.length){var t=e.querySelector(".ant-conversations-item:last-child");t&&F(t)}},[k.length,F]),U=(0,r.useCallback)(function(e){return j(function(){return C(this,function(t){switch(t.label){case 0:return[4,y.resource("aiConversations").destroy({filterByTk:e})];case 1:return t.sent(),w.success(f("Deleted successfully")),L(),T&&D(),[2]}})})()},[y,w,f,L,T,D]),_=(0,r.useCallback)(function(e){E.confirm({title:f("Delete conversation"),content:f("Are you sure you want to delete it?"),onOk:function(){return U(e)}})},[E,f,U]),H=(0,r.useMemo)(function(){return k.map(function(e){var t=e.title||f("New conversation");return{key:e.sessionId,title:t,icon:e.read?void 0:o().createElement(c.Badge,{dot:!0,offset:[-3,0]}),timestamp:new Date(e.updatedAt).getTime(),label:t}})},[k,f]);return((0,r.useEffect)(function(){N(d.current)},[N]),H.length)?o().createElement("div",{ref:d,style:{height:"100%"}},o().createElement(h.A,{className:A,activeKey:I,onActiveChange:J,items:H,menu:function(e){return{items:[{label:o().createElement(R,{conversation:e}),key:"rename",icon:o().createElement(s.EditOutlined,null)},{label:f("Delete"),key:"delete",icon:o().createElement(s.DeleteOutlined,null)}],onClick:function(t){var n=t.key;t.domEvent.stopPropagation(),"delete"===n&&_(e.key)}}}})):o().createElement(x,null)},D=n(7768),z=n(283),L=n(1990);function F(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function J(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}var N=L.JobStatusOptionsMap,U=function(e){var t,n,l,i=e.onOpenConversation,u=c.theme.useToken().token,f=(0,a.useCompile)(),p=(0,r.useRef)(null),d=(0,z.h)(),m=d.loading,v=d.workflowTasks,h=d.selectedJobStatus,E=d.runJobStatusFilter,w=d.hasMore,O=d.loadMoreWorkflowTasks,S=d.lastWorkflowTaskRef,k=d.acceptWorkflowTask,j=d.getWorkflowTaskBySession,C=null==(n=(l=g.J.use).currentConversation)?void 0:n.call(l),I=(0,y.Y)(C),P=b.I.use.setReadonly(),A=function(e){if(Array.isArray(e))return e}(t=(0,r.useState)())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return F(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return F(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),T=A[0],M=A[1],R=[L.JOB_STATUS.PENDING,L.JOB_STATUS.RESOLVED,L.JOB_STATUS.REJECTED,L.JOB_STATUS.ABORTED].map(function(e){return N[e]}).filter(Boolean);(0,r.useEffect)(function(){var e,t=null==(e=p.current)?void 0:e.parentElement;if(t){var n=function(){!m&&w&&t.scrollHeight-t.scrollTop-t.clientHeight<=24&&O()};return t.addEventListener("scroll",n),function(){t.removeEventListener("scroll",n)}}},[w,O,m]),(0,r.useEffect)(function(){T&&T===C&&M(void 0)},[C,T]);var B=(0,r.useCallback)(function(e){var t;return(t=function(){var t,n,r,o,l,a,u,c,s;return function(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(f){switch(f.label){case 0:M(e),f.label=1;case 1:return f.trys.push([1,7,,8]),[4,k(e)];case 2:f.sent(),r=!1,o=!1,f.label=3;case 3:return f.trys.push([3,5,,6]),[4,j(e)];case 4:return t=null==(c=f.sent())||null==(a=c.config)?void 0:a.username,n=null!=(l=null==c||null==(u=c.config)?void 0:u.model)?l:void 0,r=(null==c?void 0:c.readonly)===!0,o=(null==c?void 0:c.status)==="processing",[3,6];case 5:return f.sent(),t=void 0,n=void 0,[3,6];case 6:return P(r),I.for(e).setResponseLoading(o),i(e,t,n),[3,8];case 7:throw s=f.sent(),M(void 0),s;case 8:return[2]}})},function(){var e=this,n=arguments;return new Promise(function(r,o){var l=t.apply(e,n);function a(e){J(l,r,o,a,i,"next",e)}function i(e){J(l,r,o,a,i,"throw",e)}a(void 0)})})()},[k,I,j,i,P]);return m&&!v.length?o().createElement(c.Spin,{style:{display:"block",margin:"16px auto"}}):o().createElement("div",{ref:p,style:{padding:"10px 12px 12px"}},o().createElement(c.Select,{prefix:o().createElement(s.FilterOutlined,null),allowClear:!0,value:h,onChange:E,style:{width:"100%",marginBottom:"10px"},placeholder:f('{{t("Filter by status")}}'),options:R.map(function(e){return{value:e.value,label:f(e.label),color:e.color}}),optionRender:function(e){return o().createElement(c.Tag,{color:e.data.color},e.label)},labelRender:function(e){var t=N[e.value];return o().createElement(c.Tag,{color:null==t?void 0:t.color},e.label)}}),v.length?o().createElement(c.List,{dataSource:v,split:!1,footer:m&&v.length?o().createElement("div",{style:{textAlign:"center",padding:"8px 0 4px"}},o().createElement(c.Spin,{size:"small"})):null,renderItem:function(e){var t,n,r=e.sessionId===(null!=T?T:C),l=(null==(n=v[v.length-1])?void 0:n.sessionId)===e.sessionId,a=void 0!==e.jobStatus?N[e.jobStatus]:null,i=e.createdAt?(0,D.dayjs)(e.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,s=null!==e.executionId&&void 0!==e.executionId?"#".concat(e.executionId):null;return o().createElement(c.List.Item,{key:e.sessionId,style:{padding:"0 0 8px"}},o().createElement("div",{ref:l?S:void 0,style:{width:"100%"}},o().createElement(c.Card,{type:"inner",title:o().createElement(c.Space,null,!e.read&&o().createElement(c.Badge,{status:"error"}),o().createElement(c.Typography.Text,{strong:!0,ellipsis:!0,style:{flex:1,minWidth:0}},e.workflowTitle)),extra:o().createElement(c.Tag,{color:null!=(t=null==a?void 0:a.color)?t:"default"},(null==a?void 0:a.label)?f(a.label):"-"),size:"small",hoverable:!0,onClick:function(){return B(e.sessionId)},style:{width:"100%",backgroundColor:r?u.colorPrimaryBg:u.colorBgContainer,borderColor:r?u.colorPrimary:u.colorBorderSecondary,boxShadow:r?"0 0 0 1px ".concat(u.colorPrimaryBorder):void 0},styles:{body:{padding:"10px 12px"}}},o().createElement(c.Flex,{vertical:!0,gap:6},o().createElement(c.Typography.Text,{ellipsis:!0},e.nodeTitle),o().createElement(c.Space,{direction:"vertical"},i?o().createElement(c.Typography.Text,{type:"secondary"},i):null,s?o().createElement(c.Typography.Text,{type:"secondary"},s):null)))))}}):o().createElement(x,null))};function _(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function H(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){_(l,r,o,a,i,"next",e)}function i(e){_(l,r,o,a,i,"throw",e)}a(void 0)})}}function W(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}function $(){var e,t,n=(e=["\n .ant-segmented-item,\n .ant-segmented-item-selected {\n width: 100%;\n justify-content: center;\n }\n"],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return $=function(){return n},n}var Y=(0,f.css)($()),q=(0,r.memo)(function(){var e,t,n=(0,p.kj)(),l=(0,d.M)();(0,a.useRequest)(function(){return H(function(){return W(this,function(e){return[2,l.getAIEmployees()]})})()});var i=l.getAIEmployeesMap(),u=b.I.use.setCurrentEmployee(),s=b.I.use.showConversations(),f=b.I.use.setShowConversations(),h=b.I.use.setModel(),E=b.I.use.expanded(),w=null==(e=(t=g.J.use).currentConversation)?void 0:e.call(t),S=g.J.use.setCurrentConversation(),x=g.J.use.conversationSegmented(),k=g.J.use.setConversationSegmented(),j=g.J.use.keyword(),C=g.J.use.setKeyword(),I=(0,O.o)(),P=I.unreadCount,A=I.loadUnreadCounts,T=I.runSearch,M=I.refresh,R=(0,z.h)(),D=R.unreadCount,L=R.runSearch,F=R.refresh,J=(0,v.u)(),N=J.loadMessages,_=J.getConversationLLMActiveState,$=J.resumeStream,q=(0,y.Y)(w),G=(0,m.Q)().clear,V=(0,r.useRef)(0),K=(0,r.useCallback)(function(e){var t=q.for(e).getState();return t.responseLoading||!!t.abortController},[q]),X=(0,r.useCallback)(function(e,t){return H(function(){var n,r;return W(this,function(o){switch(o.label){case 0:return n=V.current+1,V.current=n,[4,N(e)];case 1:if(o.sent(),!t||K(e)||V.current!==n||g.J.getState().currentConversation!==e)return[2];return[4,_(e)];case 2:if(r=o.sent(),K(e)||V.current!==n||g.J.getState().currentConversation!==e||"streaming"!==r)return[2];return[4,$({sessionId:e,aiEmployee:t})];case 3:return o.sent(),[2]}})})()},[_,K,N,$]),Q=(0,r.useCallback)(function(e,t,n){if(e===w)return void f(!1);S(e);var r=t?i[t]:void 0;t?u(r):u(void 0);var o=q.for(e),l=o.getState(),a=K(e)&&l.messages.length>0;a?G({systemMessage:!1,attachments:!1,contextItems:!1,skillSettings:!1},e):(o.setMessages([]),G(void 0,e)),n?h(n):h(null),a||X(e,r).catch(console.error),E||f(!1)},[w,S,u,i,q,G,K,h,X,E,f]);return(0,r.useEffect)(function(){A()},[A]),(0,r.useEffect)(function(){s&&("conversations"===x?M():F())},[s,x,M,F]),o().createElement("div",{style:{display:"flex",flexDirection:"column",height:"100%"}},o().createElement("div",{style:{padding:"8px 12px",flexShrink:0}},o().createElement(c.Input.Search,{value:j,onChange:function(e){C(e.target.value)},placeholder:n("Search"),onSearch:function(e){"conversations"===x?T(e):L(e)},onClear:function(){"conversations"===x?T(""):L("")},allowClear:!0}),o().createElement(c.Segmented,{style:{width:"100%",marginTop:8},className:Y,options:[{label:o().createElement(c.Space,null,n("Conversations"),o().createElement(c.Badge,{count:P,size:"small"})),value:"conversations"},{label:o().createElement(c.Space,null,n("Workflow tasks"),o().createElement(c.Badge,{count:D,size:"small"})),value:"workflowTasks"}],value:x,onChange:k})),o().createElement("div",{style:{flex:1,minHeight:0,overflowY:"auto",overflowX:"hidden"}},"conversations"===x?o().createElement(B,{onOpenConversation:Q}):o().createElement(U,{onOpenConversation:Q})))}),G=n(9192),V=n(107),K=n(4969);function X(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Q(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function Z(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){Q(l,r,o,a,i,"next",e)}function i(e){Q(l,r,o,a,i,"throw",e)}a(void 0)})}}function ee(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function et(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){ee(e,t,n[t])})}return e}function en(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function er(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var eo=c.Typography.Text,el=c.Typography.Link,ea=o().memo(G.A,function(e,t){var n,r;return e.loading===t.loading&&e.placement===t.placement&&e.variant===t.variant&&e.avatar===t.avatar&&e.header===t.header&&e.footer===t.footer&&e.messageRender===t.messageRender&&((n=e.content)===(r=t.content)||(null==n?void 0:n.messageId)===(null==r?void 0:r.messageId)&&(null==n?void 0:n.content)===(null==r?void 0:r.content)&&(null==n?void 0:n.reasoning)===(null==r?void 0:r.reasoning)&&(null==n?void 0:n.tool_calls)===(null==r?void 0:r.tool_calls)&&(null==n?void 0:n.metadata)===(null==r?void 0:r.metadata)&&(null==n?void 0:n.reference)===(null==r?void 0:r.reference))}),ei=function(){var e,t=(0,p.kj)(),n=(0,a.useToken)().token,l=g.J.use.currentConversation(),i=(0,y.Y)(l),u=b.I.use.roles(),f=i.use.messages(),d=i.use.messagesLoading(),m=V.y.use.updateTools(),h=(0,v.u)(),E=h.loadMessages,w=h.lastMessageRef,O=(0,r.useMemo)(function(){return(0,K.FA)(f)},[f]),S=function(e){if(Array.isArray(e))return e}(e=(0,r.useState)({}))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return X(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return X(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),x=S[0],k=S[1],j=O.findIndex(function(e){var t;return"message"===e.type&&e.isRoot&&(null==(t=e.message.content)?void 0:t.type)!=="greeting"});(0,r.useEffect)(function(){m(f)},[f,m]),(0,r.useEffect)(function(){k(function(e){var t=et({},e),n=!1,r=function(e){e.forEach(function(e){"conversation-group"===e.type&&("completed"!==e.status||e.key in t||(t[e.key]=!1,n=!0),r(e.items))})};return r(O),n?t:e})},[O]);var C=(0,r.useRef)(null),I=(0,r.useRef)(!0),P=(0,r.useCallback)(function(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=48},[]),A=(0,r.useCallback)(function(){var e=C.current;e&&(I.current=P(e))},[P]);(0,r.useEffect)(function(){var e=C.current;if(e){var t=requestAnimationFrame(function(){I.current&&(e.scrollTop=e.scrollHeight)});return function(){return cancelAnimationFrame(t)}}},[f]);var T=function(e,r){var l=(0,K.XZ)(e.durationMs);return o().createElement(c.Divider,{key:"".concat(e.key,"-divider-top"),dashed:!0,plain:!0,style:{margin:"0 0 8px 0",color:n.colorTextDescription}},o().createElement(c.Button,{type:"link",size:"small",onClick:function(){return k(function(t){return en(et({},t),ee({},e.key,!r))})},style:{paddingInline:0,color:n.colorTextDescription},icon:r?o().createElement(s.RightOutlined,null):o().createElement(s.DownOutlined,null),iconPosition:"end"},t("Done in {{ durationText }}",{durationText:l})))},M=function(e){var r,l=e.roleName?(null==(r=u[e.roleName])?void 0:r.nickname)||e.roleName:void 0;return o().createElement(c.Divider,{key:"".concat(e.key,"-divider-bottom"),dashed:!0,plain:!0,style:{margin:"0 0 8px 0",color:n.colorTextDescription}},t("{{ nickname }} has completed the work",{nickname:l}))},R=function(e,t){if("conversation-group"===e.type)return"completed"===e.status&&!1!==x[e.key]?T(e,!0):o().createElement(o().Fragment,{key:e.key},"completed"===e.status?T(e,!1):null,e.items.map(function(e,n){return R(e,"".concat(t,"-").concat(n))}),"completed"===e.status?M(e):null);var n=e.message,r=u[n.role];return r?t===String(j)?o().createElement("div",{key:n.key,ref:w},o().createElement(ea,en(et({},r),{loading:n.loading,content:n.content}))):o().createElement(ea,en(et({},r),{key:n.key,loading:n.loading,content:n.content})):null},B=(0,a.useApp)(),D=i.setResponseLoading,L=(0,z.h)().updateReadonly,F=(0,r.useCallback)(function(e){var t=e.detail,n=t.sessionId,r=t.status;l&&l===n&&"processing"!==r&&(E(n),D(!1),L(n).catch(console.log))},[E,L,D,l]);return(0,r.useEffect)(function(){return B.eventBus.addEventListener("ws:message:ai-employee-tasks:status",F),function(){B.eventBus.removeEventListener("ws:message:ai-employee-tasks:status",F)}},[B.eventBus,F]),o().createElement(c.Layout.Content,{ref:C,onScroll:A,style:{margin:"16px 0",overflow:"auto",position:"relative"}},d&&o().createElement(c.Spin,{style:{display:"block",margin:"8px auto"}}),O.length?o().createElement("div",null,O.map(function(e,t){return R(e,String(t))}),o().createElement(eu,null)):o().createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:n.colorTextDescription}},t("Work with your AI crew")))},eu=function(){var e,t,n,l,a=(0,p.kj)(),i=(0,v.u)(),u=i.loadMessages,f=i.getConversationLLMActiveState,d=null==(e=(t=g.J.use).currentConversation)?void 0:e.call(t),m=(0,y.Y)(d),h=null==(n=(l=b.I.use).currentEmployee)?void 0:n.call(l),E=m.use.messages(),w=m.use.backgroundWorking(),O=m.use.resumeStreamFailed(),S=m.setBackgroundWorking,x=m.setResponseLoading,k=m.setResumeStreamFailed,j=(0,r.useCallback)(function(){return Z(function(){var e,t;return er(this,function(n){switch(n.label){case 0:if(!d)return[3,2];return[4,f(d)];case 1:(e=n.sent())&&(S(t="invoking"===e||O&&"streaming"===e),t&&x(!0),"idle"===e&&O&&(k(!1),x(!1))),n.label=2;case 2:return[2]}})})()},[d,f,O,S,x,k]),C=(0,r.useCallback)(function(){return Z(function(){return er(this,function(e){switch(e.label){case 0:if(!d)return[3,3];return[4,u(d)];case 1:return e.sent(),[4,j()];case 2:e.sent(),e.label=3;case 3:return[2]}})})()},[j,u,d]);if((0,r.useEffect)(function(){d&&j().catch(console.error)},[d,E.length,j]),!d)return null;var I=function(){return o().createElement(c.Typography,null,o().createElement(c.Space,null,o().createElement(c.Spin,{indicator:o().createElement(s.LoadingOutlined,{spin:!0})}),o().createElement(eo,{type:"secondary"},a("{{ nickname }} is working in background.",{ns:p.MF,nickname:null==h?void 0:h.nickname})),o().createElement(el,{onClick:C},a("Click",{ns:p.MF})),o().createElement(eo,{type:"secondary"},a("to Refresh.",{ns:p.MF}))))};return w&&o().createElement(G.A,{placement:"start",variant:"borderless",styles:{content:{margin:"8px 16px"}},messageRender:function(){return o().createElement(I,null)}})},ec=n(606),es=n(4313),ef=n(1609),ep=n.n(ef);function ed(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}var em=function(){var e,t,n,o,l,u,c,s,f,p,d,m,v,b=g.J.use.currentConversation(),h=(0,y.Y)(b).setAttachments,E={action:"aiFiles:create",onChange:function(e){h(e.fileList.map(function(e){if("done"===e.status){var t,n,r,o;return(null==e||null==(t=e.response)?void 0:t.data)?(r=ed({},e.response.data,(null==(n=e.response.data.meta)?void 0:n.source)?{source:e.response.data.meta.source}:{}),o=o={status:e.status},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(o)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}),r):e}return e}))}},w=(e=(0,a.useAPIClient)(),t=g.J.use.currentConversation(),(0,y.Y)(t),ed({customRequest:function(t){var n=t.action,r=t.data,o=t.file,l=t.filename,a=t.headers,i=t.onError,u=(t.onProgress,t.onSuccess),c=t.withCredentials,s=new FormData;return r&&Object.keys(r).forEach(function(e){s.append(e,r[e])}),s.append(l,o),e.axios.post(n,s,{withCredentials:c,headers:a}).then(function(e){u(e.data,o)}).catch(function(e){return i(Error(e.message))}).finally(function(){}),{abort:function(){console.log("upload progress is aborted.")}}}},E)),O=(n=(0,r.useContext)(i).storage,o=(0,a.usePlugin)(ep()),l=null!=n?n:"",u="storages:getBasicInfo/".concat(l),s=(c=(0,a.useRequest)({url:u},{refreshDeps:[l],cacheKey:u})).loading,f=c.data,p=!s&&(null==f?void 0:f.data)||null,v=(null==(m=null==(d=o.getStorageType(n))?void 0:d.useUploadProps)?void 0:m(ed({storage:p,rules:p.rules},E)))||{},ed({rules:null==p?void 0:p.rules},v));return ed({},w,E,O)};function ey(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}var ev=function(e){var t=e.disabled,n=(0,p.kj)(),l=em(),a=b.I.use.chatBoxRef(),i=g.J.use.currentConversation(),u=(0,y.Y)(i).use.attachments(),f=(0,r.useMemo)(function(){return null==u?void 0:u.map(function(e,t){var n;return ey({uid:t.toString(),name:e.filename,status:null!=(n=e.status)?n:"done",url:e.url,size:e.size,thumbUrl:e.preview},e)})},[u]);return t?o().createElement(c.Button,{type:"text",icon:o().createElement(s.PaperClipOutlined,null),disabled:!0}):o().createElement(es.A,ey({getDropContainer:function(){return a.current},styles:{placeholder:{opacity:.8}},placeholder:{icon:o().createElement(s.PaperClipOutlined,null),title:n("Drag & Drop files here")},items:f},l),o().createElement(c.Tooltip,{title:n("Upload files"),arrow:!1},o().createElement(c.Button,{type:"text",icon:o().createElement(s.PaperClipOutlined,null)})))},eb=n(720),eg=n(6773),eh=n.n(eg),eE=n(7694),ew=n(475),eO=n(1285),eS=(0,eE.observer)(function(e){var t,n,l=e.disabled,a=(0,p.kj)(),i=g.J.use.webSearch(),u=g.J.use.setWebSearch(),f=b.I.use.model(),d=(0,ew.l)().services,m=(0,eO.JT)(d,f),y=null!=(t=null==m?void 0:m.supportWebSearch)&&t,v=null!=(n=null==m?void 0:m.isToolConflict)&&n;(0,r.useEffect)(function(){!y&&i&&u(!1)},[y,i,u]);var h=function(){y&&u(!i)};if(l)return o().createElement(c.Button,{type:"text",icon:o().createElement(s.GlobalOutlined,null),disabled:!0});var E=a("Disable search"),w=a("Web search not supported"),O=v?o().createElement("div",null,o().createElement("div",null,a("Enable search"))):a("Enable search");return i?o().createElement(c.Tooltip,{title:E,arrow:!1},o().createElement(c.Button,{color:"primary",variant:"filled",icon:o().createElement(s.GlobalOutlined,null),onClick:h})):o().createElement(c.Tooltip,{title:y?O:w,arrow:!1},o().createElement(c.Button,{type:"text",icon:o().createElement(s.GlobalOutlined,null),onClick:h,disabled:!y}))},{displayName:"SearchSwitch"}),ex=n(9452),ek=n(284),ej=n(6482),eC=n(6759),eI=n(5555);function eP(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eA(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function eT(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eP(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eP(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var eM=(0,E.observer)(function(){var e=(0,E.useForm)(),t=(0,ej.useProviderSettingsForm)(e.values.provider);return t?o().createElement(t,null):null},{displayName:"ModalSettings"}),eR=function(){return{form:(0,r.useMemo)(function(){return(0,ex.createForm)({initialValues:{name:"v_".concat((0,w.uid)())}})},[])}},eB=function(){var e=(0,a.useActionContext)().setVisible;return{type:"default",onClick:function(){e(!1)}}},eD={type:"void",properties:{form:{type:"void","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",properties:{provider:{type:"string","x-decorator":"FormItem",title:'{{ t("Provider") }}',"x-component":"ProviderSelect",required:!0},title:{type:"string","x-decorator":"FormItem",title:'{{ t("Title") }}',"x-component":"Input","x-reactions":{dependencies:["provider"],when:"{{!$self.modified}}",fulfill:{state:{value:"{{$getProviderLabel($deps[0])}}"},schema:{"x-visible":"{{!!$deps[0]}}"}}}},options:{type:"object","x-component":"ModalSettings","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},"options.baseURL":{type:"string","x-decorator":"FormItem",title:'{{ t("Base URL") }}',"x-component":"Input","x-component-props":{placeholder:'{{ t("Base URL is optional, leave blank to use default (recommended)") }}'},"x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},enabledModels:{type:"object","x-decorator":"FormItem",title:'{{ t("Enabled Models") }}',"x-component":"EnabledModelsSelect","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},footer:{type:"void","x-component":"Space","x-component-props":{style:{display:"flex",justifyContent:"flex-end"}},properties:{testFlight:{type:"void","x-component":"LLMTestFlight","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useModalCreateActionProps"}}}}}}},ez=function(e){var t=e.open,n=e.onClose,l=e.onSuccess,i=(0,p.kj)(),u=(0,a.useAPIClient)(),s=eT((0,r.useState)([]),2),f=s[0],d=s[1],m=eT((0,r.useState)(0),2),y=m[0],v=m[1];return(0,a.useRequest)(function(){return u.resource("ai").listLLMProviders().then(function(e){var t;return((null==e||null==(t=e.data)?void 0:t.data)||[]).map(function(e){return{key:e.name,label:E.Schema.compile(e.title||e.name,{t:i}),value:e.name,supportedModel:e.supportedModel}})})},{onSuccess:function(e){d(e)}}),o().createElement(ek.PL.Provider,{value:{providers:f}},o().createElement(a.ActionContextProvider,{value:{visible:t,setVisible:function(e){e||(n(),v(function(e){return e+1}))}}},o().createElement(c.Modal,{title:i("Add LLM service"),open:t,onCancel:n,footer:null,destroyOnClose:!0,width:600},o().createElement(a.SchemaComponent,{key:y,schema:eD,components:{ProviderSelect:ej.ProviderSelect,ModalSettings:eM,LLMTestFlight:eC.e,EnabledModelsSelect:eI.uQ},scope:{useCreateFormProps:eR,useCancelActionProps:eB,useModalCreateActionProps:function(){var e=(0,a.useActionContext)().setVisible,t=c.App.useApp().message,n=(0,E.useForm)(),r=(0,a.useAPIClient)(),o=(0,p.kj)();return{type:"primary",onClick:function(){var a;return(a=function(){var a;return function(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return[4,n.submit()];case 1:return i.sent(),a=n.values,[4,r.resource("llmServices").create({values:a})];case 2:return i.sent(),t.success(o("Saved successfully")),e(!1),l(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=a.apply(e,t);function l(e){eA(o,n,r,l,i,"next",e)}function i(e){eA(o,n,r,l,i,"throw",e)}l(void 0)})})()}}},$getProviderLabel:function(e){var t=f.find(function(t){return t.value===e});return(null==t?void 0:t.label)||e},providers:f}}))))},eL=n(8973);function eF(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eJ(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eF(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eF(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var eN=(0,eE.observer)(function(e){var t=e.disabled,n=(0,p.kj)(),l=(0,a.useApp)(),i=(0,a.useAPIClient)(),u=(0,a.useToken)().token,f=c.App.useApp().message,d=eJ((0,r.useState)(!1),2),m=d[0],y=d[1],v=b.I.use.currentEmployee(),h=null==v?void 0:v.username,E=g.J.use.currentConversation(),w=b.I.use.model(),O=b.I.use.setModel(),S=l.pluginSettingsManager.has("ai.llm-services"),x=eJ((0,r.useState)(!1),2),k=x[0],j=x[1],C=(0,ew.l)(),I=C.repo,P=C.services,A=C.loading,T=C.allModelsWithLabel,M=C.allModels,R=(0,r.useMemo)(function(){return(0,eL.lf)(v,M)},[M,v]),B=(0,r.useMemo)(function(){return new Set(R.map(function(e){return"".concat(e.llmService,":").concat(e.model)}))},[R]),D=P.map(function(e){var t,n;return t=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},e),n=n={enabledModels:e.enabledModels.filter(function(t){return B.has("".concat(e.llmService,":").concat(t.value))})},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}),t}).filter(function(e){return Array.isArray(e.enabledModels)&&e.enabledModels.length>0}),z=T.filter(function(e){return B.has("".concat(e.llmService,":").concat(e.model))});(0,r.useEffect)(function(){if(h&&!E){var e=(0,eL.AX)(i,v,M,w);(0,eL.SQ)(e,w)||O(e)}},[i,E,v,h,M,w,O]);var L=(0,r.useMemo)(function(){return(0,eL.Ug)(w,R)?w:R.length?{llmService:R[0].llmService,model:R[0].model}:void 0},[w,R]),F=(0,r.useMemo)(function(){if(L){var e=z.find(function(e){return e.llmService===L.llmService&&e.model===L.model});return(null==e?void 0:e.label)||L.model}},[L,z]),J=function(e,t){var n=z.find(function(n){return n.llmService===e&&n.value===t});if(n&&(O({llmService:n.llmService,model:n.model}),v))try{null==i||i.storage.setItem(eL.UZ+v.username,"".concat(n.llmService,":").concat(n.model))}catch(e){console.log(e)}};if(!v)return null;if(A&&!P.length)return o().createElement(c.Spin,{size:"small"});var N=D.length>0,U=[];D.forEach(function(e,t){t>0&&U.push({type:"divider",key:"divider-".concat(t)}),U.push({key:"group-".concat(e.llmService),label:o().createElement(c.Typography.Text,{type:"secondary",style:{fontSize:12}},e.llmServiceTitle),disabled:!0,style:{cursor:"default",padding:"4px 12px",height:"auto",minHeight:0}}),e.enabledModels.forEach(function(t){var n=L&&L.llmService===e.llmService&&L.model===t.value;U.push({key:"".concat(e.llmService,":").concat(t.value),label:o().createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}},o().createElement("span",null,t.label),n&&o().createElement(s.CheckOutlined,{style:{fontSize:12,color:u.colorPrimary}})),onClick:function(){return J(e.llmService,t.value)}})})}),N||U.push({key:"empty-placeholder",label:o().createElement(c.Typography.Text,{type:"secondary",style:{fontSize:12}},n("No LLM services enabled yet")),disabled:!0,style:{cursor:"default",padding:"16px 12px",height:"auto",minHeight:0}}),U.length>0&&U.push({type:"divider",key:"divider-add"}),U.push({key:"add-model",icon:o().createElement(s.PlusOutlined,null),label:n("Add LLM service"),onClick:function(){S?j(!0):f.warning(n("Please contact the administrator to configure models"))}});var _=o().createElement("span",{onClick:function(e){e.stopPropagation()},style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:12,backgroundColor:u.colorFillTertiary,borderRadius:6,height:28,padding:"0 8px",cursor:"pointer",minWidth:N?"auto":void 0,userSelect:"none"}},o().createElement("span",{style:{color:N?u.colorText:u.colorError,display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:88}},N?F:n("No model available")),o().createElement(s.DownOutlined,{style:{fontSize:10,color:N?u.colorTextSecondary:u.colorError}}));return o().createElement(o().Fragment,null,o().createElement(c.Dropdown,{disabled:t,menu:{items:U,style:{maxHeight:400,overflow:"auto"}},trigger:["hover"],open:m,onOpenChange:y,overlayStyle:{zIndex:1200}},_),S&&o().createElement(ez,{open:k,onClose:function(){return j(!1)},onSuccess:function(){return I.refreshLLMServices()}}))},{displayName:"ModelSwitcher"}),eU=n(6673),e_=n(4450);function eH(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var eW=(0,eE.observer)(function(e){var t,n=e.disabled,l=(0,p.kj)(),i=function(e){if(Array.isArray(e))return e}(t=(0,r.useState)(!1))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw n}}return o}}(t)||function(e){if(e){if("string"==typeof e)return eH(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return eH(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=i[0],f=i[1],y=(0,d.M)(),v=y.aiEmployees,g=b.I.use.currentEmployee(),h=(0,m.Q)().switchAIEmployee,E=(0,a.useToken)().token;(0,r.useEffect)(function(){y.getAIEmployees()},[y]);var w=v.length?v.filter(function(e){return"business"===e.category}).map(function(e){var t=(null==g?void 0:g.username)===e.username;return{key:e.username,label:o().createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}},o().createElement(eU.a,{aiEmployee:e}),t&&o().createElement(s.CheckOutlined,{style:{fontSize:12,color:E.colorPrimary}})),onClick:function(){return h(e,{clear:{sender:!1,attachments:!1,contextItems:!1}})}}}):[{key:"empty",label:o().createElement("span",{style:{fontSize:12,color:E.colorTextSecondary}},l("Please choose an AI employee")),disabled:!0,style:{cursor:"default",padding:"16px 12px",height:"auto",minHeight:0}}],O=v.length>0,S=g?g.nickname:"".concat(l("Select an")," ").concat(l("AI employee")),x=o().createElement("span",{onClick:function(e){return e.stopPropagation()},style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:12,backgroundColor:E.colorFillTertiary,borderRadius:6,height:28,padding:"0 8px",cursor:"pointer",userSelect:"none"}},g?o().createElement(c.Avatar,{shape:"circle",size:20,src:(0,e_.H)(g.avatar)}):null,o().createElement("span",{style:{color:O?E.colorText:E.colorError,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:160}},S),o().createElement(s.DownOutlined,{style:{fontSize:10,color:O?E.colorTextSecondary:E.colorError}}));return o().createElement(c.Dropdown,{disabled:n,menu:{items:w,style:{maxHeight:400,overflow:"auto"}},trigger:["hover"],open:u,onOpenChange:f,overlayStyle:{zIndex:1200}},x)}),e$=function(e){var t,n,l=e.components,a=e.handleSubmit,i=l.SendButton,u=l.LoadingButton,s=(0,r.useRef)(null),f=null==(t=(n=b.I.use).currentEmployee)?void 0:t.call(n),p=g.J.use.currentConversation(),d=(0,y.Y)(p),m=b.I.use.readonly(),v=d.use.responseLoading(),h=d.addContextItems,E=d.removeContextItem,w=b.I.use.senderValue(),O=d.use.contextItems(),S=b.I.use.senderRef();(0,r.useEffect)(function(){var e;(null==S||null==(e=S.current)?void 0:e.nativeElement)&&(S.current.nativeElement.onkeydown=function(e){if("Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),eh().isEmpty(w)&&O.length)){var t;null==(t=s.current)||t.click()}})},[S,w,O]);var x=!f||m;return o().createElement(c.Flex,{justify:"space-between",align:"center"},o().createElement(c.Flex,{gap:"middle",align:"center"},o().createElement(eb.b,{onAdd:h,onRemove:E,disabled:x,ignore:function(e){return"flow-model.variable"===e}}),o().createElement(ev,{disabled:x}),o().createElement(eS,{disabled:x}),o().createElement(eW,{disabled:m}),o().createElement(eN,{disabled:x})),o().createElement(c.Flex,{align:"center",gap:"middle"},v?o().createElement(u,{type:"default"}):o().createElement(i,{ref:s,type:"primary",disabled:!1,onClick:function(){eh().isEmpty(w)&&O.length&&a("")}})))};function eY(){var e,t,n=(e=["\n .ant-attachment-list-card .ant-image img {\n height: 60px;\n width: 60px;\n object-fit: cover;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eY=function(){return n},n}var eq=function(){var e=g.J.use.currentConversation(),t=(0,y.Y)(e),n=t.use.attachments(),l=t.removeAttachment,a=(0,r.useMemo)(function(){return null==n?void 0:n.map(function(e){var t;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({uid:e.uid||e.filename,name:e.filename||e.name,status:null!=(t=e.status)?t:"done",url:e.url,size:e.size,thumbUrl:e.preview},e)})},[n]);if(!(null==a?void 0:a.length))return null;var i=(0,f.css)(eY());return o().createElement("div",{className:i,style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:4}},a.map(function(e){return o().createElement(es.A.FileCard,{key:e.uid,item:e,onRemove:function(e){return l(e.name)}})}))},eG=n(8723);function eV(){var e,t,n=(e=["\n display: flex;\n justify-content: flex-start;\n flex-wrap: wrap;\n gap: 2px 0;\n margin-top: 4px;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eV=function(){return n},n}var eK=function(){var e=g.J.use.currentConversation(),t=(0,y.Y)(e),n=t.use.contextItems(),r=t.removeContextItem;return(null==n?void 0:n.length)?o().createElement("div",{className:(0,f.css)(eV())},n.map(function(e){return o().createElement(eG.x,{within:"sender",key:"".concat(e.type,":").concat(e.uid),item:e,closable:!0,onRemove:r})})):null},eX=function(){var e=(0,p.kj)(),t=(0,a.useToken)().token,n=b.I.use.setSenderValue(),r=g.J.use.currentConversation(),l=(0,y.Y)(r).setMessages,i=(0,v.u)(),u=i.loadMessages,f=i.finishEditingMessage;return o().createElement(c.Alert,{style:{background:t.colorBgContainer,borderColor:t.colorBorderSecondary,color:t.colorText},icon:o().createElement(s.EditOutlined,{style:{color:t.colorText}}),message:e("Editing message for AI employee",{ns:p.MF}),type:"info",showIcon:!0,closable:!0,onClose:function(){f(),n(""),l([]),u(r)}})},eQ=function(){var e=(0,p.kj)(),t=(0,a.useToken)().token;return o().createElement(c.Alert,{style:{background:t.colorBgContainer,borderColor:t.colorBorderSecondary,color:t.colorText},icon:o().createElement(s.InfoCircleOutlined,{style:{color:t.colorText}}),message:e("Please enter and send the modification request",{ns:p.MF}),type:"info",showIcon:!0})},eZ=function(){var e=b.I.use.currentEmployee(),t=b.I.use.isEditingMessage(),n=b.I.use.isShowSenderHint(),r=g.J.use.currentConversation(),l=(0,y.Y)(r),a=l.use.contextItems(),i=l.use.attachments(),u=!!(null==a?void 0:a.length),c=!!(null==i?void 0:i.length);return n||t||e&&(u||c)?o().createElement("div",{style:{padding:"8px 8px 0 8px"}},n?o().createElement(eQ,null):null,t?o().createElement("div",null,o().createElement(eX,null)):null,e?o().createElement(eK,null):null,e?o().createElement(eq,null):null):null};function e0(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function e1(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function e2(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function e3(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||e5(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e5(e,t){if(e){if("string"==typeof e)return e0(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e0(e,t)}}function e8(){var e,t,n=(e=["\n .ant-sender-content {\n padding: 16px;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return e8=function(){return n},n}var e4=function(){var e=b.I.use.currentEmployee(),t=b.I.use.isEditingMessage(),n=b.I.use.editingMessageId(),r=b.I.use.setShowSenderHint(),o=g.J.use.currentConversation(),l=(0,y.Y)(o),a=g.J.use.webSearch(),i=l.use.attachments(),u=l.use.contextItems(),c=l.use.systemMessage(),s=l.use.skillSettings(),f=(0,v.u)().finishEditingMessage,p=(0,m.Q)().send;return[function(l){r(!1),p({sessionId:o,aiEmployee:e,systemMessage:c,messages:[{type:"text",content:l}],attachments:i.filter(function(e){return"done"===e.status}),workContext:u,editingMessageId:t?n:void 0,skillSettings:s,webSearch:a}),t&&f()}]},e6=function(){var e=(0,p.kj)(),t=(0,f.css)(e8()),n=e3(e4(),1)[0],l=(0,r.useRef)(null),a=b.I.use.senderValue(),i=b.I.use.setSenderValue(),u=b.I.use.currentEmployee(),c=g.J.use.currentConversation(),s=(0,y.Y)(c),d=b.I.use.setShowSenderHint(),m=b.I.use.setSenderRef(),h=b.I.use.readonly(),E=s.setAttachments,w=em(),O=s.use.responseLoading(),S=(0,v.u)().cancelRequest,x=e3((0,r.useState)(a),2),k=x[0],j=x[1];return(0,r.useEffect)(function(){m(l)},[]),(0,r.useEffect)(function(){k!==a&&i(k)},[k]),(0,r.useEffect)(function(){j(a)},[a]),o().createElement("div",{style:{margin:"8px 16px"}},o().createElement(ec.A,{className:t,value:k,ref:l,onChange:function(e){j(e)},onPaste:function(e){for(var t=e.clipboardData.items,n=null,r=0;r<t.length;r++)if("file"===t[r].kind){n=t[r].getAsFile();break}if(n){e.preventDefault();var o=Date.now().toString(),l=n,a={uid:o,name:l.name,status:"uploading",originFileObj:l,percent:0,type:l.type,size:l.size};E(function(e){return((function(e){if(Array.isArray(e))return e0(e)})(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||e5(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([a])});var i=w.customRequest,u=w.data,c=w.headers,s=w.action;i&&i({file:l,filename:"file",data:u,headers:c,action:s,onProgress:function(e){var t=e.percent;E(function(e){return e.map(function(e){return e.uid===o?e2(e1({},e),{percent:t}):e})})},onSuccess:function(e,t){var n=null==e?void 0:e.data;E(function(t){return t.map(function(t){return t.uid===o?n?e2(e1({},n),{status:"done"}):e2(e1({},t),{status:"done",response:e}):t})})},onError:function(e){E(function(t){return t.map(function(t){return t.uid===o?e2(e1({},t),{status:"error",error:e}):t})})}})}},onSubmit:n,onCancel:S,onBlur:function(){d(!1)},header:o().createElement(eZ,null),loading:O,footer:function(e){var t=e.components;return o().createElement(e$,{components:t,handleSubmit:n})},disabled:!u||h,placeholder:e("Enter your question"),actions:!1,autoSize:{minRows:2,maxRows:8}}))};function e7(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function e9(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function te(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function tt(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function tn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return e7(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e7(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var tr=function(){var e,t=(0,p.kj)(),n=(0,a.useToken)().token,l=(0,a.useMobileLayout)().isMobileLayout,i=c.App.useApp().message,u=(0,a.useAPIClient)(),f=b.I.use.currentEmployee(),m=b.I.use.setCurrentEmployee(),y=(0,d.M)(),v=tn((0,r.useState)(!1),2),g=v[0],h=v[1],E=tn((0,r.useState)(!1),2),w=E[0],O=E[1],S=tn((0,r.useState)(!1),2),x=S[0],k=S[1],j=tn((0,r.useState)(""),2),C=j[0],I=j[1],P=l?w:g;(0,r.useEffect)(function(){if(P){var e,t;I(null!=(e=null==f||null==(t=f.userConfig)?void 0:t.prompt)?e:"")}},[P,null==f||null==(e=f.userConfig)?void 0:e.prompt]);var A=function(){l?O(!1):h(!1)},T=o().createElement(c.Card,{variant:"borderless",size:"small",styles:{body:{width:l?"auto":"420px",maxWidth:"calc(100vw - 32px)",padding:"16px"}}},o().createElement(c.Typography.Title,{level:5,style:{margin:0,marginBottom:12,fontSize:n.fontSizeLG,fontWeight:500}},t("Personalized prompt")),o().createElement(c.Typography.Paragraph,{style:{marginBottom:12,color:n.colorTextSecondary}},t("Personalized prompt description")),o().createElement(c.Input.TextArea,{value:C,onChange:function(e){return I(e.target.value)},autoSize:{minRows:4,maxRows:8},placeholder:t("Personalized prompt")}),o().createElement("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:12}},o().createElement(c.Space,null,o().createElement(c.Button,{onClick:A},t("Cancel")),o().createElement(c.Button,{type:"primary",loading:x,onClick:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:if(!f)return[2];k(!0),n.label=1;case 1:return n.trys.push([1,4,5,6]),[4,u.resource("aiEmployees").updateUserPrompt({values:{aiEmployee:f.username,prompt:C}})];case 2:return n.sent(),[4,y.refreshAIEmployees()];case 3:return n.sent(),m(function(e){return tt(te({},e),{userConfig:tt(te({},e.userConfig),{prompt:C})})}),i.success(t("Saved successfully")),A(),[3,6];case 4:return e=n.sent(),i.error((null==e?void 0:e.message)||t("Request failed")),[3,6];case 5:return k(!1),[7];case 6:return[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){e9(l,r,o,a,i,"next",e)}function i(e){e9(l,r,o,a,i,"throw",e)}a(void 0)})})()}},t("Submit")))));return o().createElement(o().Fragment,null,l?o().createElement(c.Tooltip,{arrow:!1,title:t("Personalized prompt")},o().createElement(c.Button,{icon:o().createElement(s.InfoCircleOutlined,null),type:"text",onClick:function(){return O(!0)}})):o().createElement(c.Tooltip,{arrow:!1,title:t("Personalized prompt")},o().createElement(c.Popover,{zIndex:1101,placement:"bottomRight",open:g,onOpenChange:h,trigger:"click",styles:{body:{padding:0,marginRight:"8px"}},arrow:!1,content:T},o().createElement(c.Button,{icon:o().createElement(s.InfoCircleOutlined,null),type:"text"}))),o().createElement(c.Modal,{open:l&&w,onCancel:A,footer:null,centered:!0,width:"calc(100vw - 32px)",styles:{body:{padding:0}},destroyOnClose:!0},T))},to=n(9468),tl=n(4281);function ta(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ti(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function tu(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function tc(e){return function(e){if(Array.isArray(e))return ta(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ts(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ts(e,t){if(e){if("string"==typeof e)return ta(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ta(e,t)}}function tf(){var e,t,n=(e=["\n width: 350px;\n margin-bottom: -1em;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return tf=function(){return n},n}var tp=c.Layout.Header,td=c.Layout.Content,tm=c.Typography.Title,ty=function(){var e=(0,p.kj)(),t=(0,a.useToken)().token,n=b.I.use.setShowCodeHistory();return o().createElement(c.Layout,{style:{padding:"0 16px 16px",height:"100%"}},o().createElement(tp,{style:{backgroundColor:t.colorBgContainer,height:"48px",lineHeight:"48px",padding:0,borderBottom:"1px solid ".concat(t.colorBorder)}},o().createElement(c.Flex,{style:{height:"100%"},justify:"flex-start",align:"center",gap:"middle"},o().createElement(c.Button,{icon:o().createElement(s.LeftOutlined,null),type:"text",onClick:function(){n(!1)}}),o().createElement(tm,{level:5,style:{margin:0}},e("Code history")))),o().createElement(td,null,o().createElement(tv,null)))},tv=function(){var e,t="javascript",n="code-editor",l=b.I.use.currentEmployee(),a=g.J.use.currentConversation(),i=(0,y.Y)(a).use.messages(),u=function(e){if(Array.isArray(e))return e}(e=(0,r.useState)([]))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||ts(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),s=u[0],f=u[1];return(0,r.useEffect)(function(){if(l&&(null==i?void 0:i.length)){var e=RegExp("```"+t+"([\\s\\S]*?)```","s"),r=i.filter(function(e){return"user"===e.role}).filter(function(e){var t,n;return(null==(n=e.content)||null==(t=n.workContext)?void 0:t.length)!==0}).filter(function(e){return e.content.workContext.some(function(e){return e.type===n})}).flatMap(function(e){return e.content.workContext.map(function(t){return{message:e,workContext:t}})}).filter(function(e){return e.workContext.type===n}),o=i.filter(function(e){return e.role===l.username}).filter(function(e){var t;return(null==(t=e.content)?void 0:t.type)==="text"}).filter(function(t){return e.test(t.content.content)}).map(function(r){var o=e.exec(r.content.content);return{message:r,workContext:{type:n,uid:r.key,content:{language:t,code:o[1]}}}}),a=tc(r).concat(tc(o));a.sort(function(e,t){return Number(e.message.key)-Number(t.message.key)}),f(a)}},[i,l]),o().createElement(c.List,{style:{height:"100%",overflowY:"auto"},dataSource:s,renderItem:function(e,t){return o().createElement(c.List.Item,{key:t},o().createElement(tb,e))}})},tb=function(e){var t=e.message,n=e.workContext,r=b.I.use.currentEmployee(),l=n.content,i={size:33,shape:"circle",style:{border:"1px solid #eee"}};return o().createElement(c.Flex,{justify:"space-around",style:{width:"100%"}},"user"===t.role?o().createElement(c.Avatar,tu(ti({},i),{icon:o().createElement(s.UserOutlined,null)})):o().createElement(c.Avatar,tu(ti({},i),{src:(0,e_.H)(r.avatar)})),o().createElement("div",{className:(0,a.css)(tf())},o().createElement(tl.w,{className:"language-".concat(l.language)},l.code)))},tg=n(8680);function th(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var tE=c.Layout.Header,tw=c.Layout.Footer,tO=c.Layout.Sider,tS=c.Typography.Text,tx=function(){var e=(0,r.useRef)(null),t=b.I.use.setChatBoxRef(),n=b.I.use.setOpen(),l=b.I.use.currentEmployee(),i=b.I.use.expanded(),u=b.I.use.setExpanded(),f=b.I.use.setMinimize(),d=b.I.use.showConversations(),y=b.I.use.setShowConversations(),v=b.I.use.setShowCodeHistory(),g=b.I.use.showDebugPanel(),h=b.I.use.setShowDebugPanel(),E=(0,m.Q)().startNewConversation,w=(0,a.useToken)().token,O=(0,p.kj)();(0,r.useEffect)(function(){t(e)},[]);var S=(0,a.useMobileLayout)().isMobileLayout;return o().createElement(c.Layout,{style:{height:"100%",position:"relative"},ref:e},d&&!i&&o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:10,cursor:"pointer"},onClick:function(){return y(!1)}}),o().createElement("div",{style:{position:"absolute",top:0,left:0,width:"300px",height:"100%",backgroundColor:w.colorBgContainer,zIndex:11,borderRight:"1px solid ".concat(w.colorBorder),overflow:"hidden"}},o().createElement(q,null))),d&&i&&o().createElement(tO,{width:300,style:{backgroundColor:w.colorBgContainer,borderRight:"1px solid ".concat(w.colorBorder),overflow:"hidden"}},o().createElement(q,null)),o().createElement(c.Layout,null,o().createElement(tE,{style:{backgroundColor:w.colorBgContainer,height:"48px",lineHeight:"48px",padding:"0 16px",borderBottom:"1px solid ".concat(w.colorBorder),display:"flex",alignItems:"center",justifyContent:"space-between"}},o().createElement("div",null,o().createElement(c.Button,{icon:d?o().createElement(s.MenuFoldOutlined,null):o().createElement(s.MenuUnfoldOutlined,null),type:"text",onClick:function(e){e.stopPropagation(),y(!d)}})),o().createElement("div",null,l?o().createElement(o().Fragment,null,o().createElement(c.Tooltip,{arrow:!1,title:O("New conversation")},o().createElement(c.Button,{icon:o().createElement(s.PlusCircleOutlined,null),type:"text",onClick:E})),o().createElement(tr,null),(0,tg.G8)(l)&&o().createElement(c.Tooltip,{arrow:!1,title:O("Code history")},o().createElement(c.Button,{icon:o().createElement(s.CodeOutlined,null),type:"text",onClick:function(){v(!0)}})),!i&&o().createElement(c.Tooltip,{arrow:!1,title:O("Debug Panel")},o().createElement(c.Button,{icon:o().createElement(s.BugOutlined,null),type:"text",onClick:function(){return h(!g)}})),o().createElement(c.Divider,{type:"vertical"})):null,S?o().createElement(c.Button,{icon:o().createElement(s.CompressOutlined,null),type:"text",onClick:function(){f(!0)}}):o().createElement(c.Button,{icon:i?o().createElement(s.FullscreenExitOutlined,null):o().createElement(s.FullscreenOutlined,null),type:"text",onClick:function(){i||h(!1),u(!i)}}),o().createElement(c.Tooltip,{arrow:!1,title:O("Collapse panel")},o().createElement(c.Button,{icon:o().createElement(s.CloseOutlined,null),type:"text",onClick:function(){return n(!1)}})))),o().createElement(ei,null),o().createElement(tw,{style:{backgroundColor:w.colorBgContainer,padding:0}},o().createElement(e6,null),o().createElement("div",{style:{textAlign:"center",margin:"10px 0",fontSize:w.fontSizeSM,color:w.colorTextTertiary}},O("AI disclaimer")))))},tk=(0,eE.observer)(function(){return o().createElement(c.Card,{style:{position:"fixed",transform:"translate(-50%, -50%)",left:"50%",top:"50%",width:"95%",height:"95%",zIndex:to.b.shouldHide?-1:1100},styles:{body:{height:"100%",padding:0}}},o().createElement(tx,null))}),tj=(0,eE.observer)(function(e){var t=e.minimize;return o().createElement("div",{style:{position:"fixed",left:"0",top:"0",width:"100%",height:"100%",zIndex:to.b.shouldHide?-1:1100,backgroundColor:"white",display:t?"none":"block"}},o().createElement(tx,null),o().createElement(tC,null))}),tC=function(){var e,t=b.I.use.currentEmployee(),n=b.I.use.minimize(),l=b.I.use.setMinimize(),a=b.I.use.setOpen(),i=(0,p.kj)(),u=function(e){if(Array.isArray(e))return e}(e=c.notification.useNotification())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return th(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return th(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),f=u[0],d=u[1],m=(0,r.useRef)("ai-chat-box-minimize--control-".concat(new Date().getTime())),y=null==t?void 0:t.avatar;return(0,r.useEffect)(function(){return!0===n&&y?f.open({key:m.current,closeIcon:!1,message:o().createElement(c.Flex,{justify:"space-between",align:"center"},o().createElement(c.Avatar,{shape:"circle",size:35,src:(0,e_.H)(y)}),o().createElement(tS,{ellipsis:!0},i("Conversation")),o().createElement(c.Button,{type:"text",icon:o().createElement(s.CloseOutlined,null),onClick:function(e){e.stopPropagation(),a(!1),l(!1)}})),duration:0,placement:"top",style:{width:200},onClick:function(){l(!1)}}):f.destroy(m.current),function(){f.destroy(m.current)}},[f,y,n,l,a,i]),o().createElement(o().Fragment,null,d)},tI=function(){var e=b.I.use.expanded(),t=b.I.use.minimize(),n=b.I.use.showCodeHistory();return(0,a.useMobileLayout)().isMobileLayout?o().createElement(tj,{minimize:t}):e?o().createElement(tk,null):o().createElement("div",{style:{position:"fixed",transform:"translateX(0px) !important",right:"-450px",zIndex:1,top:0,width:"450px",height:"100vh",overflow:"hidden",borderInlineStart:"1px solid rgba(5, 5, 5, 0.06)"}},n?o().createElement(ty,null):o().createElement(tx,null))},tP=n(5195),tA=n.p+"f0053e745af0ad03.svg",tT=n(4442);function tM(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tR(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return tM(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tM(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tB(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function tD(){var e=tB(["\n .ant-badge-count,\n .ant-badge-dot {\n transform-origin: center;\n }\n\n .ant-badge-count {\n ","\n }\n\n @keyframes chat-button-badge-shake {\n 0%,\n 100% {\n transform: translate(50%, -50%) translate3d(0, 0, 0) rotate(0deg);\n }\n 10%,\n 30%,\n 50% {\n transform: translate(50%, -50%) translate3d(-1px, 0, 0) rotate(-8deg);\n }\n 20%,\n 40%,\n 60% {\n transform: translate(50%, -50%) translate3d(1px, 0, 0) rotate(8deg);\n }\n 70% {\n transform: translate(50%, -50%) translate3d(-1px, 0, 0) rotate(-4deg);\n }\n 80% {\n transform: translate(50%, -50%) translate3d(1px, 0, 0) rotate(4deg);\n }\n 90% {\n transform: translate(50%, -50%) translate3d(0, 0, 0) rotate(0deg);\n }\n }\n "]);return tD=function(){return e},e}function tz(){var e=tB(["\n z-index: 1050;\n position: fixed;\n bottom: 42px;\n inset-inline-end: -8px;\n padding: 9px 22px 9px 10px;\n border-radius: 31px 0 0 31px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n opacity: 0.7;\n background: ",";\n box-shadow: ",";\n transform: translateX(0);\n will-change: transform;\n transition:\n transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),\n opacity 0.2s ease;\n &:hover {\n opacity: 1;\n transform: translateX(-8px);\n }\n "]);return tz=function(){return e},e}var tL=(0,eE.observer)(function(){var e,t=(0,eE.useFlowContext)(),n=(0,tT.useLocation)().pathname,l=(null==t||null==(e=t.pageInfo)?void 0:e.version)==="v1",i=(0,a.useMobileLayout)().isMobileLayout,u=(0,a.useToken)().token,s=(0,O.o)().unreadCount+(0,z.h)().unreadCount,p=(0,d.M)(),v=p.aiEmployees;o().useEffect(function(){p.getAIEmployees()},[p]);var g=tR((0,r.useState)(!1),2),h=g[0],E=g[1],w=b.I.use.open(),S=(0,y.Y)(),x=b.I.use.setOpen(),k=b.I.use.setReadonly(),j=tR((0,r.useState)(!1),2),C=j[0],I=j[1],P=(0,r.useRef)(0),A=(0,r.useRef)(null),T=(0,m.Q)().switchAIEmployee;if((0,r.useEffect)(function(){return A.current&&(clearTimeout(A.current),A.current=null),0===s?I(!1):s>P.current&&(I(!1),A.current=setTimeout(function(){I(!0),A.current=null},800)),P.current=s,function(){A.current&&(clearTimeout(A.current),A.current=null)}},[s]),w||!(null==v?void 0:v.length)||l||!n.startsWith("/admin"))return null;var M=u.boxShadowSecondary||u.boxShadow,R=(0,f.css)(tD(),C?"\n animation: chat-button-badge-shake 1.6s ease-in-out infinite;\n ":"");return!i&&o().createElement("div",{onClick:function(){A.current&&(clearTimeout(A.current),A.current=null),I(!1),E(!1),k(!1),S.setResponseLoading(!1),x(!0);var e=v.find(tg.oT);e&&T(e)},className:(0,f.css)(tz(),u.colorBgElevated,M),style:h||C?{opacity:1,transform:"translateX(-8px)"}:void 0},o().createElement(c.Badge,{count:s,offset:[-5,5],className:R},o().createElement(c.Avatar,{src:tA,size:42,shape:"square"})))}),tF=n(3251);function tJ(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tN(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){tJ(e,t,n[t])})}return e}var tU=function(){var e=(0,d.M)(),t=e.aiEmployees,n=b.I.use.open(),o=b.I.use.senderRef(),l=b.I.use.currentEmployee(),a=b.I.use.setRoles(),i=g.J.use.currentConversation();(0,r.useEffect)(function(){e.getAIEmployees()},[e]),(0,r.useEffect)(function(){if(!t)return void a(function(e){return tN({},e,tF.H)});var e=t.reduce(function(e,t){var n,r;return n=tN({},e),r=null!=(r=tJ({},t.username,(0,tF.V)(t)))?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n},{});a(function(t){return tN({},t,tF.H,e)})},[t]),(0,r.useEffect)(function(){var e;null==o||null==(e=o.current)||e.focus()},[l]),(0,r.useEffect)(function(){if(n){var e;null==o||null==(e=o.current)||e.focus()}},[n,o]),(0,r.useEffect)(function(){n&&e.refreshAITools(i)},[n,i])},t_=n(2427);function tH(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function tW(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){tH(l,r,o,a,i,"next",e)}function i(e){tH(l,r,o,a,i,"throw",e)}a(void 0)})}}function t$(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var tY=function(e){return{onOk:function(){return tW(function(){return t$(this,function(e){return[2]})})()}}},tq=(0,eE.observer)(function(){var e,t,n,l,i=(0,p.kj)(),u=(0,d.M)(),s=u.aiTools,f=(0,a.toToolsMap)(s),m=g.J.use.currentConversation();(0,r.useEffect)(function(){u.getAITools(m)},[u,m]);var y=V.y.use.openToolModal(),h=V.y.use.setOpenToolModal(),w=V.y.use.activeTool(),O=V.y.use.setActiveTool(),S=V.y.use.activeMessageId(),x=V.y.use.setActiveMessageId(),k=V.y.use.toolsByMessageId(),j=V.y.use.toolsByName(),C=b.I.use.readonly(),I=(0,v.u)().updateToolArgs,P=(S&&(null==w?void 0:w.id)?null==(e=k[S])?void 0:e[w.id]:null)||w,A=f.get(null==P?void 0:P.name),T=null==A||null==(t=A.ui)?void 0:t.modal,M=(null==A||null==(l=A.ui)||null==(n=l.modal)?void 0:n.useOnOk)||tY,R=null==T?void 0:T.Component,B=null==T?void 0:T.footer,D=null==T?void 0:T.props,z=V.y.use.adjustArgs(),L=M((0,(0,t_.t)({messageId:S}).getDecisionActions)(P),z).onOk,F=j[null==P?void 0:P.name]||[],J=F.map(function(e,t){return{key:e.id,value:e.id,label:"Version ".concat(t+1)}}),N=(0,r.useCallback)(function(e){return tW(function(){return t$(this,function(t){switch(t.label){case 0:if(!P||!m||!S)return[2];return[4,I({sessionId:m,messageId:S,tool:{id:P.id,args:e}})];case 1:var n,r;return t.sent(),c.message.success(i("Saved successfully")),O((n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},P),r=r={args:e},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n)),[2]}})})()},[S,m,P,O,i,I]);return o().createElement(c.Modal,{title:o().createElement(o().Fragment,null,(null==T?void 0:T.title)?E.Schema.compile(T.title,{t:i}):"",J.length>1&&o().createElement(c.Select,{options:J,value:null==P?void 0:P.id,style:{marginLeft:"8px"},onChange:function(e){var t=F.find(function(t){return t.id===e});x((null==t?void 0:t.messageId)||""),O(t)}})),open:y,width:(null==D?void 0:D.width)||"90%",styles:null==D?void 0:D.styles,onCancel:function(){h(!1),O(null)},okText:(null==T?void 0:T.okText)?E.Schema.compile(T.okText,{t:i}):i("Submit"),onOk:function(){return tW(function(){return t$(this,function(e){switch(e.label){case 0:return[4,null==L?void 0:L()];case 1:return e.sent(),h(!1),[2]}})})()},okButtonProps:{disabled:!["init","interrupted","pending"].includes(null==P?void 0:P.invokeStatus)||C},footer:B&&P?o().createElement(B,{tool:P}):(null==T?void 0:T.hideOkButton)?null:function(e,t){var n=t.OkBtn;return o().createElement(o().Fragment,null,o().createElement(n,null))}},R&&P?o().createElement(R,{tool:P,saveToolArgs:N}):null)}),tG=n(4143),tV=n(6768);function tK(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var tX=(0,r.forwardRef)(function(e,t){var n,l=e.data,a=e.itemKey,i=e.itemHeight,u=e.children,c=(0,r.useRef)(null),s=(0,r.useRef)(null),f=function(e){if(Array.isArray(e))return e}(n=(0,r.useState)(400))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw n}}return o}}(n)||function(e){if(e){if("string"==typeof e)return tK(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return tK(e,2)}}(n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),p=f[0],d=f[1];return(0,r.useEffect)(function(){var e=c.current;if(e){var t=new ResizeObserver(function(e){var t=!0,n=!1,r=void 0;try{for(var o,l=e[Symbol.iterator]();!(t=(o=l.next()).done);t=!0){var a=o.value;d(a.contentRect.height)}}catch(e){n=!0,r=e}finally{try{t||null==l.return||l.return()}finally{if(n)throw r}}});return t.observe(e),d(e.clientHeight),function(){return t.disconnect()}}},[]),(0,r.useImperativeHandle)(t,function(){return{scrollTo:function(e){var t;null==(t=s.current)||t.scrollTo(e)}}}),o().createElement("div",{ref:c,style:{flex:1,overflow:"hidden"}},o().createElement(tV.A,{ref:s,data:l,itemKey:a,height:p,itemHeight:void 0===i?48:i,fullHeight:!1},u))});function tQ(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tZ(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||t2(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t0(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function t1(e){return function(e){if(Array.isArray(e))return tQ(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||t2(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t2(e,t){if(e){if("string"==typeof e)return tQ(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tQ(e,t)}}function t3(){var e=t0(["\n padding: 8px 12px;\n border-bottom: 1px solid ",";\n &:hover {\n background-color: ",";\n }\n "]);return t3=function(){return e},e}function t5(){var e=t0(["\n display: flex;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n "]);return t5=function(){return e},e}function t8(){var e=t0(["\n color: ",";\n "]);return t8=function(){return e},e}function t4(){var e=t0(["\n margin: 8px 0 0 18px;\n padding: 8px;\n background-color: ",";\n border-radius: 4px;\n font-size: 12px;\n overflow-x: auto;\n max-height: 300px;\n overflow-y: auto;\n "]);return t4=function(){return e},e}function t6(){var e=t0(["\n display: flex;\n flex-direction: column;\n height: 100%;\n "]);return t6=function(){return e},e}function t7(){var e=t0(["\n padding: 12px;\n border-bottom: 1px solid ",";\n display: flex;\n gap: 8px;\n "]);return t7=function(){return e},e}var t9=c.Typography.Text,ne=c.Input.Search,nt={request:"blue",stream_text:"green",stream_search:"cyan",stream_start:"geekblue",stream_tools:"orange",stream_delta:"lime",stream_reasoning:"magenta",stream_error:"volcano",tool_call:"gold",tool_result:"purple",error:"red"},nn=[{value:"all",label:"All"},{value:"request",label:"Request"},{value:"stream_text",label:"Stream Text"},{value:"stream_search",label:"Stream Search"},{value:"stream_start",label:"Stream Start"},{value:"stream_tools",label:"Stream Tools"},{value:"stream_delta",label:"Stream Delta"},{value:"stream_reasoning",label:"Stream Reasoning"},{value:"stream_error",label:"Stream Error"},{value:"tool_call",label:"Tool Call"},{value:"tool_result",label:"Tool Result"},{value:"error",label:"Error"}],nr=function(e){var t=e.log,n=e.expanded,r=e.onToggleExpand,l=(0,a.useToken)().token,i=function(){try{navigator.clipboard.writeText(JSON.stringify(t.data,null,2)),c.message.success("Copied to clipboard")}catch(e){c.message.error("Failed to copy")}};return o().createElement("div",{className:(0,f.css)(t3(),l.colorBorderSecondary,l.colorFillQuaternary)},o().createElement("div",{className:(0,f.css)(t5()),onClick:r},n?o().createElement(s.DownOutlined,{style:{fontSize:10}}):o().createElement(s.RightOutlined,{style:{fontSize:10}}),o().createElement(t9,{type:"secondary",style:{fontFamily:"monospace",fontSize:12}},new Date(t.time).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3})),o().createElement(c.Tag,{color:nt[t.type],style:{margin:0}},t.type),o().createElement(t9,{ellipsis:!0,style:{flex:1,fontFamily:"monospace",fontSize:12},className:(0,f.css)(t8(),l.colorTextSecondary)},function(e){try{var t=JSON.stringify(e);return t.length>100?t.slice(0,100)+"...":t}catch(e){return"[Unable to stringify]"}}(t.data)),o().createElement(c.Tooltip,{title:"Copy"},o().createElement(c.Button,{type:"text",size:"small",icon:o().createElement(s.CopyOutlined,null),onClick:function(e){e.stopPropagation(),i()}}))),n&&o().createElement("pre",{className:(0,f.css)(t4(),l.colorFillSecondary)},JSON.stringify(t.data,null,2)))},no=function(){var e=b.I.use.showDebugPanel(),t=b.I.use.setShowDebugPanel(),n=g.J.use.currentConversation(),l=tZ((0,r.useState)([]),2),i=l[0],u=l[1],d=tZ((0,r.useState)("all"),2),m=d[0],y=d[1],v=tZ((0,r.useState)(""),2),h=v[0],E=v[1],w=tZ((0,r.useState)(new Set),2),O=w[0],S=w[1],x=(0,r.useRef)(null),k=(0,p.kj)(),j=(0,a.useToken)().token;(0,r.useEffect)(function(){if(!n)return void u([]);var e=tG._.getSession(n);return e?u(t1(e.logs)):u([]),tG._.subscribe(function(e,t){t===n&&u(function(t){return t1(t).concat([e])})})},[n]);var C=(0,r.useMemo)(function(){return i.filter(function(e){if("all"!==m&&e.type!==m)return!1;if(h){var t=h.toLowerCase();return JSON.stringify(e.data).toLowerCase().includes(t)}return!0})},[i,m,h]);(0,r.useEffect)(function(){C.length>0&&requestAnimationFrame(function(){var e;null==(e=x.current)||e.scrollTo({index:C.length-1,align:"bottom"})})},[i]);var I=(0,r.useCallback)(function(e){S(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),P=(0,r.useCallback)(function(e){return O.has(e.id)?"".concat(e.id,"-e"):e.id},[O]);return o().createElement(c.Drawer,{title:o().createElement(c.Space,null,o().createElement("span",null,k("Debug Panel")),n&&o().createElement(t9,{type:"secondary",style:{fontSize:12}},"(",i.length," logs)")),placement:"right",width:500,open:e,onClose:function(){return t(!1)},styles:{body:{padding:0,overflow:"hidden"}},extra:o().createElement(c.Button,{icon:o().createElement(s.DownloadOutlined,null),size:"small",onClick:function(){if(n&&0!==i.length){var e=tG._.getSession(n),t=new Blob([JSON.stringify({sessionId:n,employeeId:null==e?void 0:e.employeeId,employeeName:null==e?void 0:e.employeeName,exportedAt:new Date().toISOString(),logs:i},null,2)],{type:"application/json"}),r=URL.createObjectURL(t),o=document.createElement("a");o.href=r;var l=(null==e?void 0:e.employeeName)||"unknown";o.download="ai-chat-log-".concat(l,"-").concat(new Date().toISOString().slice(0,16).replace("T","_"),".json"),o.click(),URL.revokeObjectURL(r)}},disabled:0===i.length},k("Export"))},o().createElement("div",{className:(0,f.css)(t6())},o().createElement("div",{className:(0,f.css)(t7(),j.colorBorder)},o().createElement(c.Select,{value:m,onChange:y,options:nn,style:{width:120},size:"small"}),o().createElement(ne,{placeholder:k("Search logs..."),value:h,onChange:function(e){return E(e.target.value)},allowClear:!0,size:"small",style:{flex:1}})),n?0===C.length?o().createElement(c.Empty,{description:k("No logs"),style:{marginTop:100}}):o().createElement(tX,{ref:x,data:C,itemKey:P,itemHeight:40},function(e){return o().createElement(nr,{log:e,expanded:O.has(e.id),onToggleExpand:function(){return I(e.id)}})}):o().createElement(c.Empty,{description:k("No conversation selected"),style:{marginTop:100}})))},nl=function(e){var t=b.I.use.open(),n=b.I.use.expanded(),l=V.y.use.activeTool(),i=b.I.use.showDebugPanel(),u=(0,a.useMobileLayout)().isMobileLayout;tU();var c=(0,a.useApp)(),s=(0,O.o)().loadUnreadCounts;return(0,r.useEffect)(function(){s()},[s]),(0,r.useEffect)(function(){return c.eventBus.addEventListener("ws:message:ai-employee-tasks:status",s),c.eventBus.addEventListener("ws:message:ai-conversations:read",s),function(){c.eventBus.removeEventListener("ws:message:ai-employee-tasks:status",s),c.eventBus.removeEventListener("ws:message:ai-conversations:read",s)}},[c.eventBus,s]),o().createElement(o().Fragment,null,e.children,o().createElement(tL,null),!t||n||u?null:o().createElement(tP.m,null,o().createElement("style",{type:"text/css"},"\nhtml {\n padding-left: 450px;\n}\nhtml body {\n position: relative;\n overflow: hidden;\n transform: translateX(-450px);\n}\n.ant-dropdown-placement-topLeft {\n transform: translateX(450px) !important;\n}\n.ant-dropdown-placement-bottomLeft {\n transform: translateX(450px) !important;\n}\n.ant-dropdown-menu-submenu-placement-rightTop {\n transform: translateX(450px) !important;\n}\n.ant-dropdown-menu-submenu-placement-rightBottom {\n transform: translateX(450px) !important;\n}\n")),t?o().createElement(tI,null):null,l&&o().createElement(tq,null),i&&o().createElement(no,null))},na=n(4310),ni=(0,eE.observer)(function(){return na.l.selectable&&o().createElement(tP.m,null,o().createElement("style",{type:"text/css"},"\n.ai-selectable {\n position: relative;\n transition: all 0.3s ease;\n &:hover {\n cursor: grab;\n }\n &::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 210, 255, 0.2);\n opacity: 0;\n transition: opacity 0.3s ease;\n z-index: 100;\n }\n\n &:hover::after {\n opacity: 1;\n }\n}\n"))});function nu(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var nc=(0,eE.observer)(function(){var e,t=(0,p.kj)(),n=c.theme.useToken().token,l=function(e){if(Array.isArray(e))return e}(e=c.notification.useNotification())||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],l=!0,a=!1;try{for(r=r.call(e);!(l=(t=r.next()).done)&&(o.push(t.value),2!==o.length);l=!0);}catch(e){a=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(a)throw n}}return o}}(e)||function(e){if(e){if("string"==typeof e)return nu(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return nu(e,2)}}(e)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),a=l[0],i=l[1],u=(0,r.useRef)("ai-selection-control-".concat(new Date().getTime())),f=na.l.selectable;return(0,r.useEffect)(function(){return""!==f?a.open({key:u.current,closeIcon:!1,message:o().createElement(c.Flex,{justify:"space-between",align:"center",style:{width:"100%"}},o().createElement("span",{style:{fontWeight:500,fontSize:13,color:n.colorTextSecondary,lineHeight:1.2}},t("Picking block")),o().createElement(c.Button,{type:"text",size:"small",icon:o().createElement(s.StopOutlined,null),style:{color:n.colorError,fontSize:13,lineHeight:1.2},"aria-label":t("Cancel"),onClick:function(){na.l.stopSelect(),to.b.resume()}})),duration:0,placement:"bottom",style:{width:180,padding:"7px 12px 5px 12px",background:n.colorBgContainer,border:"1px solid ".concat(n.colorBorder),boxShadow:n.boxShadowSecondary,borderRadius:6}}):a.destroy(u.current),function(){a.destroy(u.current)}},[a,f,t,n]),o().createElement(o().Fragment,null,i)}),ns=function(e){var t,n=(0,r.useContext)(a.CurrentUserContext);return(null==n||null==(t=n.data)?void 0:t.data)?o().createElement(l.S7,null,o().createElement(u,null,o().createElement(nl,null,e.children),o().createElement(ni,null),o().createElement(nc,null))):o().createElement(o().Fragment,null,e.children)}},4281:function(e,t,n){n.d(t,{w:function(){return k},Rs:function(){return x},Cy:function(){return j}});var r=n(9155),o=n.n(r),l=n(2059),a=n(7375),i=n(3342),u=n(3079),c=n(8680),s=n(7694),f=n(7546),p=n(7596);function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function m(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){if(null==e)return{};var n,r,o,l={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r]);return l}if(l=function(e,t){if(null==e)return{};var n,r,o={},l=Object.getOwnPropertyNames(e);for(r=0;r<l.length;r++)n=l[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r]);return l}var v=(0,i.lazy)(function(){return Promise.all([n.e("428"),n.e("758")]).then(n.bind(n,2733))},"CodeHighlight").CodeHighlight,b=function(e){var t=e.language,n=e.value,r=e.height,l=e.scrollToBottom,a=y(e,["language","value","height","scrollToBottom"]);return o().createElement(v,m(d({},a),{language:t,value:n,height:r,scrollToBottom:l}))},g=function(e){var t=(0,s.useFlowContext)(),n=(0,u.kj)(),r=p.J.use.currentConversation(),i=(0,f.Y)(r),c=e.children,v=e.className,g=(e.node,e.message),E=y(e,["children","className","node","message"]),w=/language-(\w+)/.exec(v||""),O=w?w[1]:"",S=String(c).replace(/<!--[\s\S]*?-->/g,"").replace(/\n$/,""),x=l.App.useApp().message,k=!0;(null==g?void 0:g.type)==="text"&&(k=RegExp("```"+O+"[\\s\\S]*?```","s").test(g.content));var j=i.use.editorRef()[i.use.currentEditorRefUid()];return w?o().createElement(l.Card,{type:"inner",size:"small",title:o().createElement(l.Space,{style:{margin:"0 8px"},size:"middle"},o().createElement(a.CodeOutlined,null),o().createElement("span",null,O)),extra:o().createElement(o().Fragment,null,o().createElement(l.Tooltip,{title:n("Copy")},o().createElement(l.Button,{type:"text",icon:o().createElement(a.CopyOutlined,null),onClick:function(){navigator.clipboard.writeText(S),x.success(n("Copied"))}})),o().createElement(l.Divider,{type:"vertical"}),o().createElement(l.Tooltip,{title:n("Expand")},o().createElement(l.Button,{type:"text",icon:o().createElement(a.ExpandOutlined,null),onClick:function(){t.viewer.dialog({width:"80%",zIndex:6e3,content:o().createElement(h,m(d({},E),{language:O,value:S,height:"75vh"}))})}}))),styles:{header:{padding:0},body:{padding:0}},actions:j?[o().createElement(l.Button,{key:"accept",type:"link",onClick:function(e){e.stopPropagation(),null==j||j.write(S),t.message.info(n("Applied"))},disabled:!k},n("Apply to editor"))]:[]},o().createElement(b,m(d({},E),{language:O,value:S,scrollToBottom:!k}))):o().createElement(l.Typography.Text,m(d({code:!0},E),{className:v}),c)},h=function(e){var t=e.language,n=e.value,r=y(e,["language","value"]),i=(0,s.useFlowViewContext)(),u=i.view.Header,c=o().createElement(l.Button,{type:"text",icon:o().createElement(a.CloseOutlined,null),onClick:function(){i.view.close()}});return o().createElement("div",{style:{borderRadius:8}},o().createElement(u,{title:o().createElement(o().Fragment,null,o().createElement(l.Space,null,c,o().createElement("span",null,t)))}),o().createElement(b,m(d({},r),{language:t,value:n})))};function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function w(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function O(e,t){if(null==e)return{};var n,r,o,l={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,n=Reflect.ownKeys(Object(e));o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r]);return l}if(l=function(e,t){if(null==e)return{};var n,r,o={},l=Object.getOwnPropertyNames(e);for(r=0;r<l.length;r++)n=l[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)r=n[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r]);return l}var S=(0,i.lazy)(function(){return Promise.all([n.e("428"),n.e("758")]).then(n.bind(n,2733))},"CodeHighlight").CodeHighlight,x=function(e){var t=e.language,n=e.value,r=O(e,["language","value"]);return o().createElement(S,w(E({},r),{language:t,value:n}))},k=function(e){var t=e.children,n=e.className,r=(e.node,e.message,O(e,["children","className","node","message"])),c=/language-(\w+)/.exec(n||""),s=c?c[1]:"",f=(0,i.useToken)().token,p=(0,u.kj)(),d=String(t).replace(/\n$/,""),m=l.App.useApp().message;return c?o().createElement(l.Card,{size:"small",title:s,styles:{title:{fontSize:f.fontSize,fontWeight:400},body:{width:"100%",fontSize:f.fontSizeSM}},extra:o().createElement(l.Button,{variant:"link",color:"default",size:"small",onClick:function(){navigator.clipboard.writeText(d),m.success(p("Copied"))},icon:o().createElement(a.CopyOutlined,null)})},o().createElement(x,w(E({},r),{language:s,value:d}))):o().createElement(l.Typography.Text,w(E({code:!0},r),{className:n}),t)},j=function(e){var t=e.className,n=/language-(\w+)/.exec(t||""),r=n?n[1]:"",l=p.J.use.currentConversation(),a=(0,f.Y)(l);return a.use.editorRef()[a.use.currentEditorRefUid()]&&(0,c._t)(r)?o().createElement(g,e):o().createElement(k,e)}},283:function(e,t,n){n.d(t,{h:function(){return b}});var r,o=n(9155),l=n(3342),a=n(4181),i=n(3559),u=n(7821),c=n(1990);function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){f(l,r,o,a,i,"next",e)}function i(e){f(l,r,o,a,i,"throw",e)}a(void 0)})}}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e){if(e){if("string"==typeof e)return s(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return s(e,void 0)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){var n,r,o,l={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:u(0)}),i(a,"throw",{value:u(1)}),i(a,"return",{value:u(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function u(i){return function(u){var c=[i,u];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(l=0)),l;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return l.label++,{value:c[1],done:!1};case 5:l.label++,r=c[1],c=[0];continue;case 7:c=l.ops.pop(),l.trys.pop();continue;default:if(!(o=(o=l.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){l=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){l.label=c[1];break}if(6===c[0]&&l.label<o[1]){l.label=o[1],o=c;break}if(o&&l.label<o[2]){l.label=o[2],l.ops.push(c);break}o[2]&&l.ops.pop(),l.trys.pop();continue}c=t.call(e,l)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var v=(d(r={},c.JOB_STATUS.PENDING,["processing","pending_acceptance","pending_approval"]),d(r,c.JOB_STATUS.RESOLVED,["approved"]),d(r,c.JOB_STATUS.REJECTED,["rejected"]),d(r,c.JOB_STATUS.ABORTED,["aborted"]),r),b=function(){var e,t,n,r,c=(0,l.useAPIClient)().resource("aiWorkflowTasks"),s=a.u.use.workflowTasks(),f=a.u.use.currentWorkflowTask(),d=a.u.use.unreadCount(),b=a.u.use.loading(),g=a.u.use.keyword(),h=a.u.use.selectedJobStatus(),E=a.u.use.setWorkflowTasks(),w=a.u.use.setCurrentWorkflowTask(),O=a.u.use.setLoading(),S=a.u.use.setKeyword(),x=a.u.use.setSelectedJobStatus(),k=(0,o.useRef)(g);k.current=g;var j=(0,o.useRef)(h);j.current=h;var C=(0,l.useRequest)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0;return p(function(){var r,o,l;return y(this,function(a){switch(a.label){case 0:r={},t&&(r.$or=[{workflowTitle:{$includes:t}},{nodeTitle:{$includes:t}},{status:{$includes:t}}]),(null==(o="number"==typeof n?v[n]:void 0)?void 0:o.length)&&(r.status={$in:o}),a.label=1;case 1:return a.trys.push([1,3,4,5]),O(!0),[4,c.list({sort:["-updatedAt"],page:e,pageSize:15,filter:r})];case 2:return[2,null==(l=a.sent())?void 0:l.data];case 3:throw a.sent();case 4:return O(!1),[7];case 5:return[2]}})})()},{manual:!0,onSuccess:function(e,t){var n=t[0]||1,r=(null==e?void 0:e.data)||[];1===n?E(r):E(function(e){var t=new Set(e.map(function(e){return e.sessionId})),n=r.filter(function(e){return!t.has(e.sessionId)});return m(e).concat(m(n))})}}),I=(0,o.useRef)(C);I.current=C;var P=(0,o.useCallback)(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";S(e),C.run(1,e,h)},[h,S,C]),A=(0,o.useCallback)(function(){I.current.run(1,k.current||"",j.current)},[]),T=(0,o.useCallback)(function(e){x(e),C.run(1,g||"",e)},[g,x,C]),M=(0,o.useCallback)(function(){return p(function(){var e,t,n;return y(this,function(r){switch(r.label){case 0:if(n=null==(e=(t=I.current).data)?void 0:e.meta,t.loading||n&&n.page>=n.totalPage)return[2];return[4,t.runAsync((null==n?void 0:n.page)?n.page+1:1,g||"",h)];case 1:return r.sent(),[2]}})})()},[g,h]),R=(0,i.d)({loadMore:M}).ref,B=null!=(t=C.data)&&null!=(e=t.meta)&&!!e.page&&null!=(r=C.data)&&null!=(n=r.meta)&&!!n.totalPage&&C.data.meta.page<C.data.meta.totalPage,D=(0,o.useCallback)(function(e){return p(function(){return y(this,function(t){switch(t.label){case 0:return[4,c.accept({values:{sessionId:e}}).catch(function(){})];case 1:return t.sent(),[2]}})})()},[c]),z=(0,o.useCallback)(function(e){return p(function(){var t,n,r,o;return y(this,function(l){switch(l.label){case 0:return[4,c.getBySession({values:{sessionId:e}})];case 1:return w(o=null!=(t=null==(r=l.sent())||null==(n=r.data)?void 0:n.data)?t:null==r?void 0:r.data),[2,o]}})})()},[w,c]),L=u.I.use.setReadonly(),F=(0,o.useCallback)(function(e){return p(function(){var t;return y(this,function(n){switch(n.label){case 0:return[4,D(e)];case 1:return n.sent(),[4,z(e)];case 2:return L((null==(t=n.sent())?void 0:t.readonly)===!0),[2]}})})()},[D,z,L]);return{loading:b,workflowTasks:s,unreadCount:d,selectedJobStatus:h,runSearch:P,runJobStatusFilter:T,refresh:A,hasMore:B,loadMoreWorkflowTasks:M,lastWorkflowTaskRef:R,acceptWorkflowTask:D,getWorkflowTaskBySession:z,updateReadonly:F,currentWorkflowTask:f,setCurrentWorkflowTask:w,setSelectedJobStatus:x}}}}]);
|