@nocobase/plugin-ai 2.0.6 → 2.0.7

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.
Files changed (37) hide show
  1. package/dist/client/{1907d8fc160052b4.js → 05bb46e182de283c.js} +1 -1
  2. package/dist/client/{888db19c1c5dd1c9.js → 35156dfea5f288fa.js} +1 -1
  3. package/dist/client/9d99ede69dc880d7.js +10 -0
  4. package/dist/client/ai-employees/chatbox/model.d.ts +3 -4
  5. package/dist/client/c49179ef6fcbc972.js +10 -0
  6. package/dist/client/index.d.ts +2 -2
  7. package/dist/client/index.js +3 -3
  8. package/dist/client/llm-services/hooks/useLLMServiceCatalog.d.ts +2 -2
  9. package/dist/client/llm-services/utils.d.ts +1 -1
  10. package/dist/client/repositories/AIConfigRepository.d.ts +52 -0
  11. package/dist/client/{ai-employees/flow/context/index.d.ts → repositories/hooks/useAIConfigRepository.d.ts} +2 -1
  12. package/dist/externalVersion.js +14 -13
  13. package/dist/node_modules/@langchain/anthropic/package.json +1 -1
  14. package/dist/node_modules/@langchain/core/package.json +1 -1
  15. package/dist/node_modules/@langchain/deepseek/package.json +1 -1
  16. package/dist/node_modules/@langchain/google-genai/package.json +1 -1
  17. package/dist/node_modules/@langchain/langgraph/package.json +1 -1
  18. package/dist/node_modules/@langchain/langgraph-checkpoint/package.json +1 -1
  19. package/dist/node_modules/@langchain/ollama/package.json +1 -1
  20. package/dist/node_modules/@langchain/openai/package.json +1 -1
  21. package/dist/node_modules/fast-glob/package.json +1 -1
  22. package/dist/node_modules/flexsearch/package.json +1 -1
  23. package/dist/node_modules/fs-extra/package.json +1 -1
  24. package/dist/node_modules/langchain/package.json +1 -1
  25. package/dist/node_modules/nodejs-snowflake/package.json +1 -1
  26. package/dist/node_modules/zod/package.json +1 -1
  27. package/dist/server/manager/ai-context-datasource-manager.js +4 -3
  28. package/dist/server/plugin.js +1 -5
  29. package/dist/server/tools/docs.d.ts +3 -4
  30. package/dist/server/tools/docs.js +104 -43
  31. package/package.json +3 -2
  32. package/dist/client/66c939b3395bb7c4.js +0 -10
  33. package/dist/client/ai-employees/flow/context/ai-employees-data.d.ts +0 -10
  34. package/dist/client/ai-employees/hooks/useAIEmployeesData.d.ts +0 -17
  35. package/dist/client/f52e5acb1a4b991c.js +0 -10
  36. package/dist/client/llm-services/LLMServicesRepository.d.ts +0 -30
  37. package/dist/client/llm-services/hooks/useLLMServicesRepository.d.ts +0 -10
@@ -1 +1 @@
1
- {"name":"langchain","version":"1.2.24","description":"Typescript bindings for langchain","author":"LangChain","license":"MIT","type":"module","engines":{"node":">=20"},"files":["dist/","CHANGELOG.md","README.md","LICENSE","storage","load","load.d.cts","load.cjs","load.d.ts","load.js","hub","chat_models","hub.d.cts","hub.cjs","hub.d.ts","hub.js"],"repository":{"type":"git","url":"git+ssh://git@github.com/langchain-ai/langchainjs.git"},"homepage":"https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain/","devDependencies":{"@tsconfig/recommended":"^1.0.2","@types/js-yaml":"^4","@types/jsdom":"^21.1.1","@types/uuid":"^9","@types/ws":"^8","@vitest/coverage-v8":"^3.2.4","cheerio":"1.0.0-rc.12","dotenv":"^16.0.3","dpdm":"^3.14.0","eslint":"^9.34.0","openai":"^5.1.0","peggy":"^3.0.2","prettier":"^3.5.0","reflect-metadata":"^0.2.2","rimraf":"^5.0.1","tinybench":"^6.0.0","typeorm":"^0.3.28","typescript":"~5.8.3","vitest":"^3.2.4","yaml":"^2.8.1","@langchain/anthropic":"1.3.17","@langchain/core":"^1.1.24","@langchain/cohere":"1.0.2","@langchain/eslint":"0.1.1","@langchain/openai":"1.2.7","@langchain/tsconfig":"0.0.1"},"peerDependencies":{"@langchain/core":"^1.1.24"},"dependencies":{"@langchain/langgraph":"^1.1.2","@langchain/langgraph-checkpoint":"^1.0.0","langsmith":">=0.5.0 <1.0.0","uuid":"^10.0.0","zod":"^3.25.76 || ^4"},"publishConfig":{"access":"public"},"keywords":["llm","ai","gpt3","chain","prompt","prompt engineering","chatgpt","machine learning","ml","openai","embeddings","vectorstores"],"main":"./dist/index.cjs","types":"./dist/index.d.cts","exports":{".":{"input":"./src/index.ts","require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"},"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./chat_models/universal":{"input":"./src/chat_models/universal.ts","require":{"types":"./dist/chat_models/universal.d.cts","default":"./dist/chat_models/universal.cjs"},"import":{"types":"./dist/chat_models/universal.d.ts","default":"./dist/chat_models/universal.js"}},"./hub":{"input":"./src/hub/index.ts","require":{"types":"./dist/hub/index.d.cts","default":"./dist/hub/index.cjs"},"import":{"types":"./dist/hub/index.d.ts","default":"./dist/hub/index.js"}},"./hub/node":{"input":"./src/hub/node.ts","require":{"types":"./dist/hub/node.d.cts","default":"./dist/hub/node.cjs"},"import":{"types":"./dist/hub/node.d.ts","default":"./dist/hub/node.js"}},"./load":{"input":"./src/load/index.ts","require":{"types":"./dist/load/index.d.cts","default":"./dist/load/index.cjs"},"import":{"types":"./dist/load/index.d.ts","default":"./dist/load/index.js"}},"./load/serializable":{"input":"./src/load/serializable.ts","require":{"types":"./dist/load/serializable.d.cts","default":"./dist/load/serializable.cjs"},"import":{"types":"./dist/load/serializable.d.ts","default":"./dist/load/serializable.js"}},"./storage/encoder_backed":{"input":"./src/storage/encoder_backed.ts","require":{"types":"./dist/storage/encoder_backed.d.cts","default":"./dist/storage/encoder_backed.cjs"},"import":{"types":"./dist/storage/encoder_backed.d.ts","default":"./dist/storage/encoder_backed.js"}},"./storage/file_system":{"input":"./src/storage/file_system.ts","require":{"types":"./dist/storage/file_system.d.cts","default":"./dist/storage/file_system.cjs"},"import":{"types":"./dist/storage/file_system.d.ts","default":"./dist/storage/file_system.js"}},"./storage/in_memory":{"input":"./src/storage/in_memory.ts","require":{"types":"./dist/storage/in_memory.d.cts","default":"./dist/storage/in_memory.cjs"},"import":{"types":"./dist/storage/in_memory.d.ts","default":"./dist/storage/in_memory.js"}},"./package.json":"./package.json"},"module":"./dist/index.js","scripts":{"build":"turbo build:compile --filter langchain --output-logs new-only","build:compile":"tsdown","lint:eslint":"eslint --cache src/","lint:dpdm":"dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts","lint":"pnpm lint:eslint && pnpm lint:dpdm","lint:fix":"pnpm lint:eslint --fix && pnpm lint:dpdm","precommit":"lint-staged","clean":"rm -rf .turbo dist/","test":"vitest run","test:watch":"vitest --watch","test:bench":"vitest --mode bench --run","test:integration":"vitest --mode int","format":"prettier --write \"src\"","format:check":"prettier --check \"src\""},"_lastModified":"2026-02-26T06:58:10.112Z"}
1
+ {"name":"langchain","version":"1.2.24","description":"Typescript bindings for langchain","author":"LangChain","license":"MIT","type":"module","engines":{"node":">=20"},"files":["dist/","CHANGELOG.md","README.md","LICENSE","storage","load","load.d.cts","load.cjs","load.d.ts","load.js","hub","chat_models","hub.d.cts","hub.cjs","hub.d.ts","hub.js"],"repository":{"type":"git","url":"git+ssh://git@github.com/langchain-ai/langchainjs.git"},"homepage":"https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain/","devDependencies":{"@tsconfig/recommended":"^1.0.2","@types/js-yaml":"^4","@types/jsdom":"^21.1.1","@types/uuid":"^9","@types/ws":"^8","@vitest/coverage-v8":"^3.2.4","cheerio":"1.0.0-rc.12","dotenv":"^16.0.3","dpdm":"^3.14.0","eslint":"^9.34.0","openai":"^5.1.0","peggy":"^3.0.2","prettier":"^3.5.0","reflect-metadata":"^0.2.2","rimraf":"^5.0.1","tinybench":"^6.0.0","typeorm":"^0.3.28","typescript":"~5.8.3","vitest":"^3.2.4","yaml":"^2.8.1","@langchain/anthropic":"1.3.17","@langchain/core":"^1.1.24","@langchain/cohere":"1.0.2","@langchain/eslint":"0.1.1","@langchain/openai":"1.2.7","@langchain/tsconfig":"0.0.1"},"peerDependencies":{"@langchain/core":"^1.1.24"},"dependencies":{"@langchain/langgraph":"^1.1.2","@langchain/langgraph-checkpoint":"^1.0.0","langsmith":">=0.5.0 <1.0.0","uuid":"^10.0.0","zod":"^3.25.76 || ^4"},"publishConfig":{"access":"public"},"keywords":["llm","ai","gpt3","chain","prompt","prompt engineering","chatgpt","machine learning","ml","openai","embeddings","vectorstores"],"main":"./dist/index.cjs","types":"./dist/index.d.cts","exports":{".":{"input":"./src/index.ts","require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"},"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"./chat_models/universal":{"input":"./src/chat_models/universal.ts","require":{"types":"./dist/chat_models/universal.d.cts","default":"./dist/chat_models/universal.cjs"},"import":{"types":"./dist/chat_models/universal.d.ts","default":"./dist/chat_models/universal.js"}},"./hub":{"input":"./src/hub/index.ts","require":{"types":"./dist/hub/index.d.cts","default":"./dist/hub/index.cjs"},"import":{"types":"./dist/hub/index.d.ts","default":"./dist/hub/index.js"}},"./hub/node":{"input":"./src/hub/node.ts","require":{"types":"./dist/hub/node.d.cts","default":"./dist/hub/node.cjs"},"import":{"types":"./dist/hub/node.d.ts","default":"./dist/hub/node.js"}},"./load":{"input":"./src/load/index.ts","require":{"types":"./dist/load/index.d.cts","default":"./dist/load/index.cjs"},"import":{"types":"./dist/load/index.d.ts","default":"./dist/load/index.js"}},"./load/serializable":{"input":"./src/load/serializable.ts","require":{"types":"./dist/load/serializable.d.cts","default":"./dist/load/serializable.cjs"},"import":{"types":"./dist/load/serializable.d.ts","default":"./dist/load/serializable.js"}},"./storage/encoder_backed":{"input":"./src/storage/encoder_backed.ts","require":{"types":"./dist/storage/encoder_backed.d.cts","default":"./dist/storage/encoder_backed.cjs"},"import":{"types":"./dist/storage/encoder_backed.d.ts","default":"./dist/storage/encoder_backed.js"}},"./storage/file_system":{"input":"./src/storage/file_system.ts","require":{"types":"./dist/storage/file_system.d.cts","default":"./dist/storage/file_system.cjs"},"import":{"types":"./dist/storage/file_system.d.ts","default":"./dist/storage/file_system.js"}},"./storage/in_memory":{"input":"./src/storage/in_memory.ts","require":{"types":"./dist/storage/in_memory.d.cts","default":"./dist/storage/in_memory.cjs"},"import":{"types":"./dist/storage/in_memory.d.ts","default":"./dist/storage/in_memory.js"}},"./package.json":"./package.json"},"module":"./dist/index.js","scripts":{"build":"turbo build:compile --filter langchain --output-logs new-only","build:compile":"tsdown","lint:eslint":"eslint --cache src/","lint:dpdm":"dpdm --skip-dynamic-imports circular --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts","lint":"pnpm lint:eslint && pnpm lint:dpdm","lint:fix":"pnpm lint:eslint --fix && pnpm lint:dpdm","precommit":"lint-staged","clean":"rm -rf .turbo dist/","test":"vitest run","test:watch":"vitest --watch","test:bench":"vitest --mode bench --run","test:integration":"vitest --mode int","format":"prettier --write \"src\"","format:check":"prettier --check \"src\""},"_lastModified":"2026-02-27T08:23:27.841Z"}
@@ -1 +1 @@
1
- {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2026-02-26T06:58:03.481Z"}
1
+ {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2026-02-27T08:23:20.233Z"}
@@ -1 +1 @@
1
- {"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-02-26T06:58:04.574Z"}
1
+ {"name":"zod","version":"4.3.5","type":"module","license":"MIT","author":"Colin McDonnell <zod@colinhacks.com>","description":"TypeScript-first schema declaration and validation library with static type inference","homepage":"https://zod.dev","llms":"https://zod.dev/llms.txt","llmsFull":"https://zod.dev/llms-full.txt","mcpServer":"https://mcp.inkeep.com/zod/mcp","funding":"https://github.com/sponsors/colinhacks","sideEffects":false,"files":["src","**/*.js","**/*.mjs","**/*.cjs","**/*.d.ts","**/*.d.mts","**/*.d.cts","**/package.json"],"keywords":["typescript","schema","validation","type","inference"],"main":"./index.cjs","types":"./index.d.cts","module":"./index.js","zshy":{"exports":{"./package.json":"./package.json",".":"./src/index.ts","./mini":"./src/mini/index.ts","./locales":"./src/locales/index.ts","./v3":"./src/v3/index.ts","./v4":"./src/v4/index.ts","./v4-mini":"./src/v4-mini/index.ts","./v4/mini":"./src/v4/mini/index.ts","./v4/core":"./src/v4/core/index.ts","./v4/locales":"./src/v4/locales/index.ts","./v4/locales/*":"./src/v4/locales/*"},"conditions":{"@zod/source":"src"}},"exports":{"./package.json":"./package.json",".":{"@zod/source":"./src/index.ts","types":"./index.d.cts","import":"./index.js","require":"./index.cjs"},"./mini":{"@zod/source":"./src/mini/index.ts","types":"./mini/index.d.cts","import":"./mini/index.js","require":"./mini/index.cjs"},"./locales":{"@zod/source":"./src/locales/index.ts","types":"./locales/index.d.cts","import":"./locales/index.js","require":"./locales/index.cjs"},"./v3":{"@zod/source":"./src/v3/index.ts","types":"./v3/index.d.cts","import":"./v3/index.js","require":"./v3/index.cjs"},"./v4":{"@zod/source":"./src/v4/index.ts","types":"./v4/index.d.cts","import":"./v4/index.js","require":"./v4/index.cjs"},"./v4-mini":{"@zod/source":"./src/v4-mini/index.ts","types":"./v4-mini/index.d.cts","import":"./v4-mini/index.js","require":"./v4-mini/index.cjs"},"./v4/mini":{"@zod/source":"./src/v4/mini/index.ts","types":"./v4/mini/index.d.cts","import":"./v4/mini/index.js","require":"./v4/mini/index.cjs"},"./v4/core":{"@zod/source":"./src/v4/core/index.ts","types":"./v4/core/index.d.cts","import":"./v4/core/index.js","require":"./v4/core/index.cjs"},"./v4/locales":{"@zod/source":"./src/v4/locales/index.ts","types":"./v4/locales/index.d.cts","import":"./v4/locales/index.js","require":"./v4/locales/index.cjs"},"./v4/locales/*":{"@zod/source":"./src/v4/locales/*","types":"./v4/locales/*","import":"./v4/locales/*","require":"./v4/locales/*"}},"repository":{"type":"git","url":"git+https://github.com/colinhacks/zod.git"},"bugs":{"url":"https://github.com/colinhacks/zod/issues"},"support":{"backing":{"npm-funding":true}},"scripts":{"clean":"git clean -xdf . -e node_modules","build":"zshy --project tsconfig.build.json","postbuild":"tsx ../../scripts/write-stub-package-jsons.ts && pnpm biome check --write .","test:watch":"pnpm vitest","test":"pnpm vitest run","prepublishOnly":"tsx ../../scripts/check-versions.ts"},"_lastModified":"2026-02-27T08:23:21.568Z"}
@@ -30,6 +30,7 @@ __export(ai_context_datasource_manager_exports, {
30
30
  });
31
31
  module.exports = __toCommonJS(ai_context_datasource_manager_exports);
32
32
  var import_utils = require("@nocobase/utils");
33
+ var import_acl = require("@nocobase/acl");
33
34
  class AIContextDatasourceManager {
34
35
  constructor(plugin) {
35
36
  this.plugin = plugin;
@@ -51,7 +52,7 @@ class AIContextDatasourceManager {
51
52
  };
52
53
  }
53
54
  async innerQuery(ctx, options) {
54
- var _a;
55
+ var _a, _b;
55
56
  const { datasource, collectionName } = options;
56
57
  const resource = collectionName;
57
58
  const action = "list";
@@ -87,8 +88,8 @@ class AIContextDatasourceManager {
87
88
  records: []
88
89
  };
89
90
  }
90
- const filteredParams = ds.acl.filterParams(ctx, collectionName, can.params);
91
- const parsedParams = filteredParams ? await ds.acl.parseJsonTemplate(filteredParams, ctx) : {};
91
+ (0, import_acl.checkFilterParams)(collection, (_b = can.params) == null ? void 0 : _b.filter);
92
+ const parsedParams = can.params ? await (0, import_acl.parseJsonTemplate)(can.params, ctx) : {};
92
93
  if (parsedParams.appends && options.fields) {
93
94
  for (const queryField of options.fields) {
94
95
  if (parsedParams.appends.indexOf(queryField) !== -1) {
@@ -117,11 +117,7 @@ class PluginAIServer extends import_server.Plugin {
117
117
  }
118
118
  registerTools() {
119
119
  const toolsManager = this.ai.toolsManager;
120
- const docsModulesDescription = (0, import_tools.describeDocModules)("Docs modules unavailable. Run ai:create-docs-index first.");
121
- toolsManager.registerTools([
122
- (0, import_tools.createDocsSearchTool)({ description: docsModulesDescription }),
123
- (0, import_tools.createReadDocEntryTool)()
124
- ]);
120
+ toolsManager.registerTools([(0, import_tools.createDocsSearchTool)(), (0, import_tools.createReadDocEntryTool)()]);
125
121
  toolsManager.registerDynamicTools((0, import_tools.getWorkflowCallers)(this, "workflowCaller"));
126
122
  }
127
123
  defineResources() {
@@ -23,12 +23,11 @@ export type DocEntryResult = {
23
23
  export declare function loadDocsIndexes(baseDir?: string): Promise<void>;
24
24
  export declare function getDocModuleKeys(): string[];
25
25
  export declare function describeDocModules(emptyMessage?: string): string;
26
- export declare function searchDocsModule(moduleKey: string, query: string, limit?: number): Promise<{
26
+ export declare function searchDocsModule(moduleKey: string, keywords: string[], limit?: number): Promise<{
27
27
  key: string;
28
+ keywords: string[];
28
29
  matches: string[];
29
30
  }>;
30
31
  export declare function readDocEntry(docPath: string): Promise<DocEntryResult>;
31
- export declare function createDocsSearchTool(options?: {
32
- description?: string;
33
- }): ToolsOptions;
32
+ export declare function createDocsSearchTool(): ToolsOptions;
34
33
  export declare function createReadDocEntryTool(): ToolsOptions;
@@ -56,6 +56,8 @@ let docsBaseDir = DEFAULT_DOCS_DIR;
56
56
  let docsMeta = {};
57
57
  const DOCS_INDEX_TTL_MS = 5 * 60 * 1e3;
58
58
  const DOCS_INDEX_MAX_CACHE = 5;
59
+ const DOCS_SEARCH_MAX_KEYWORDS = 5;
60
+ const DOCS_READ_MAX_PATHS = 3;
59
61
  const docsIndexCache = /* @__PURE__ */ new Map();
60
62
  const docsIndexLoading = /* @__PURE__ */ new Map();
61
63
  async function loadDocsIndexes(baseDir = DEFAULT_DOCS_DIR) {
@@ -122,26 +124,55 @@ function describeDocModules(emptyMessage = "No document modules available.") {
122
124
  });
123
125
  return `Available modules: ${items.join(", ")}`;
124
126
  }
125
- async function searchDocsModule(moduleKey, query, limit = 5) {
127
+ async function searchDocsModule(moduleKey, keywords, limit = 5) {
126
128
  const key = normalizeModuleKey(moduleKey);
127
129
  const entry = docsModules.get(key);
128
130
  if (!entry) {
129
131
  throw new Error(`Document module "${key}" not found.`);
130
132
  }
131
133
  const { index: flexIndex, fileMap } = await getOrLoadDocsIndex(entry);
134
+ const searchTerms = buildSearchTerms(keywords);
135
+ if (!searchTerms.length) {
136
+ throw new Error("At least one valid keyword is required.");
137
+ }
132
138
  const boundedLimit = Math.min(Math.max(limit ?? 5, 1), 20);
133
- const hits = await flexIndex.searchAsync(query, { limit: boundedLimit }) || [];
134
- const seen = /* @__PURE__ */ new Set();
135
- const matches = [];
136
- for (const hit of hits) {
137
- const filePath = fileMap[String(hit)];
138
- if (filePath && !seen.has(filePath)) {
139
- seen.add(filePath);
140
- matches.push(filePath);
139
+ const perKeywordLimit = Math.min(Math.max(boundedLimit * 2, 4), 20);
140
+ const keywordHits = await Promise.all(
141
+ searchTerms.map(
142
+ async (keyword) => (await flexIndex.searchAsync(keyword, { limit: perKeywordLimit }) || []).map(
143
+ (id) => String(id)
144
+ )
145
+ )
146
+ );
147
+ const aggregate = /* @__PURE__ */ new Map();
148
+ for (const hits of keywordHits) {
149
+ for (let i = 0; i < hits.length; i++) {
150
+ const filePath = fileMap[hits[i]];
151
+ if (!filePath) {
152
+ continue;
153
+ }
154
+ const rankScore = perKeywordLimit - i;
155
+ const record = aggregate.get(filePath);
156
+ if (record) {
157
+ record.score += rankScore;
158
+ record.bestRank = Math.min(record.bestRank, i);
159
+ } else {
160
+ aggregate.set(filePath, { score: rankScore, bestRank: i });
161
+ }
141
162
  }
142
163
  }
164
+ const matches = Array.from(aggregate.entries()).sort((a, b) => {
165
+ if (b[1].score !== a[1].score) {
166
+ return b[1].score - a[1].score;
167
+ }
168
+ if (a[1].bestRank !== b[1].bestRank) {
169
+ return a[1].bestRank - b[1].bestRank;
170
+ }
171
+ return a[0].localeCompare(b[0]);
172
+ }).slice(0, boundedLimit).map(([filePath]) => filePath);
143
173
  return {
144
174
  key,
175
+ keywords: searchTerms,
145
176
  matches
146
177
  };
147
178
  }
@@ -183,7 +214,8 @@ async function readDocEntry(docPath) {
183
214
  content
184
215
  };
185
216
  }
186
- function createDocsSearchTool(options) {
217
+ function createDocsSearchTool() {
218
+ const docsModulesDescription = describeDocModules("Docs modules unavailable. Run ai:create-docs-index first.");
187
219
  return {
188
220
  scope: "GENERAL",
189
221
  defaultPermission: "ALLOW",
@@ -194,17 +226,16 @@ function createDocsSearchTool(options) {
194
226
  definition: {
195
227
  name: "searchDocs",
196
228
  description: `Search indexed documentation using a FlexSearch-based keyword index.
197
- The index is built from module identifiers (e.g. "runjs") and English technical terms.
198
- Use concise, exact keywords (module names, API names, identifiers). Avoid natural language queries or vague wording.
199
- Return matching document paths only. ${options.description}`,
229
+ Provide a small keyword list (identifiers, API names, module terms). The tool will search them concurrently with limited parallelism.
230
+ Return matching document paths only. ${docsModulesDescription}`,
200
231
  schema: import_zod.z.object({
201
232
  module: import_zod.z.string().min(1, "module is required").describe("Module key, e.g. runjs"),
202
- query: import_zod.z.string().min(1, "query is required").describe("Search keyword or phrase in English"),
233
+ keywords: import_zod.z.array(import_zod.z.string().min(1)).min(1, "keywords is required").max(DOCS_SEARCH_MAX_KEYWORDS, `keywords can contain up to ${DOCS_SEARCH_MAX_KEYWORDS} items`).describe('Keywords to search, e.g. ["router", "ctx.state", "runjs"]'),
203
234
  limit: import_zod.z.number().int().min(1).max(20).optional().describe("Maximum number of hits (default 5, max 20)")
204
235
  })
205
236
  },
206
237
  invoke: async (ctx, args) => {
207
- var _a, _b, _c, _d;
238
+ var _a, _b, _c;
208
239
  const available = getDocModuleKeys();
209
240
  if (!available.length) {
210
241
  return {
@@ -213,26 +244,27 @@ Return matching document paths only. ${options.description}`,
213
244
  };
214
245
  }
215
246
  const moduleKey = (_a = args == null ? void 0 : args.module) == null ? void 0 : _a.trim();
216
- const query = (_b = args == null ? void 0 : args.query) == null ? void 0 : _b.trim();
247
+ const keywords = Array.isArray(args == null ? void 0 : args.keywords) ? args.keywords : [];
217
248
  const limit = typeof (args == null ? void 0 : args.limit) === "number" ? args.limit : void 0;
218
- if (!moduleKey || !query) {
249
+ if (!moduleKey || !keywords.length) {
219
250
  return {
220
251
  status: "error",
221
- content: `Both module and query are required. Available modules: ${available.join(", ")}`
252
+ content: `Both module and keywords are required. Available modules: ${available.join(", ")}`
222
253
  };
223
254
  }
224
255
  try {
225
- const result = await searchDocsModule(moduleKey, query, limit);
256
+ const result = await searchDocsModule(moduleKey, keywords, limit);
226
257
  return {
227
258
  status: "success",
228
259
  content: JSON.stringify({
229
260
  module: result.key,
261
+ keywords: result.keywords,
230
262
  matches: result.matches,
231
263
  availableModules: available
232
264
  })
233
265
  };
234
266
  } catch (error) {
235
- (_d = (_c = ctx.log) == null ? void 0 : _c.error) == null ? void 0 : _d.call(_c, error, {
267
+ (_c = (_b = ctx.log) == null ? void 0 : _b.error) == null ? void 0 : _c.call(_b, error, {
236
268
  module: "ai",
237
269
  subModule: "toolCalling",
238
270
  toolName: "searchDocs"
@@ -255,43 +287,56 @@ function createReadDocEntryTool() {
255
287
  },
256
288
  definition: {
257
289
  name: "readDocEntry",
258
- description: "Read files or list directories inside storage/ai/docs using canonical module-based paths.",
290
+ description: "Read files or list directories inside storage/ai/docs using canonical module-based paths. Supports up to 3 paths per call.",
259
291
  schema: import_zod.z.object({
260
- path: import_zod.z.string().min(1, "path is required").describe(
261
- "Canonical path like runjs/context/router/index.md or /runjs/context/router/index.md. No wildcards, relative segments, or globbing."
262
- )
292
+ paths: import_zod.z.array(
293
+ import_zod.z.string().min(1, "path is required").describe(
294
+ "Canonical path like runjs/context/router/index.md or /runjs/context/router/index.md. No wildcards, relative segments, or globbing."
295
+ )
296
+ ).min(1, "paths is required").max(DOCS_READ_MAX_PATHS, `paths can contain up to ${DOCS_READ_MAX_PATHS} items`)
263
297
  })
264
298
  },
265
299
  invoke: async (ctx, args) => {
266
- var _a, _b, _c;
300
+ var _a, _b;
267
301
  const available = getDocModuleKeys();
268
- const targetPath = (_a = args == null ? void 0 : args.path) == null ? void 0 : _a.trim();
269
- if (!targetPath) {
302
+ if (!available.length) {
270
303
  return {
271
304
  status: "error",
272
- content: `Path is required. Available indexes: ${available.join(", ")}`
305
+ content: "No document indexes available."
273
306
  };
274
307
  }
275
- try {
276
- const entry = await readDocEntry(targetPath);
277
- if (entry.type === "directory") {
278
- const listing = entry.entries.map((item) => `${item.type === "directory" ? "DIR " : "FILE"} ${item.path}`).join("\n");
279
- return {
280
- status: "success",
281
- content: `DIRECTORY ${entry.path}
282
- ${listing}`
283
- };
284
- }
285
- const clean = entry.content.replace(/\r\n/g, "\n");
308
+ const rawPaths = Array.isArray(args == null ? void 0 : args.paths) ? args.paths : [];
309
+ const paths = Array.from(
310
+ new Set(
311
+ rawPaths.map((p) => String(p ?? "").trim()).filter((p) => !!p).slice(0, DOCS_READ_MAX_PATHS)
312
+ )
313
+ );
314
+ if (!paths.length) {
286
315
  return {
287
- status: "success",
288
- content: `FILE ${entry.path}
316
+ status: "error",
317
+ content: `Paths are required. Available indexes: ${available.join(", ")}`
318
+ };
319
+ }
320
+ try {
321
+ const entries = await Promise.all(paths.map((targetPath) => readDocEntry(targetPath)));
322
+ const blocks = entries.map((entry) => {
323
+ if (entry.type === "directory") {
324
+ const listing = entry.entries.map((item) => `${item.type === "directory" ? "DIR " : "FILE"} ${item.path}`).join("\n");
325
+ return `DIRECTORY ${entry.path}
326
+ ${listing}`;
327
+ }
328
+ const clean = entry.content.replace(/\r\n/g, "\n");
329
+ return `FILE ${entry.path}
289
330
  \`\`\`
290
331
  ${clean}
291
- \`\`\``
332
+ \`\`\``;
333
+ });
334
+ return {
335
+ status: "success",
336
+ content: blocks.join("\n\n")
292
337
  };
293
338
  } catch (error) {
294
- (_c = (_b = ctx.log) == null ? void 0 : _b.error) == null ? void 0 : _c.call(_b, error, {
339
+ (_b = (_a = ctx.log) == null ? void 0 : _a.error) == null ? void 0 : _b.call(_a, error, {
295
340
  module: "ai",
296
341
  subModule: "toolCalling",
297
342
  toolName: "readDocEntry"
@@ -427,6 +472,22 @@ function enforceDocsIndexCacheLimit() {
427
472
  docsIndexCache.delete(entries[i][0]);
428
473
  }
429
474
  }
475
+ function buildSearchTerms(keywords) {
476
+ const seen = /* @__PURE__ */ new Set();
477
+ const terms = [];
478
+ for (const raw of keywords) {
479
+ const keyword = String(raw ?? "").trim().replace(/\s+/g, " ");
480
+ if (!keyword || seen.has(keyword)) {
481
+ continue;
482
+ }
483
+ seen.add(keyword);
484
+ terms.push(keyword);
485
+ if (terms.length >= DOCS_SEARCH_MAX_KEYWORDS) {
486
+ break;
487
+ }
488
+ }
489
+ return terms;
490
+ }
430
491
  // Annotate the CommonJS export names for ESM import in node:
431
492
  0 && (module.exports = {
432
493
  createDocsSearchTool,
package/package.json CHANGED
@@ -6,13 +6,14 @@
6
6
  "description": "Create AI employees with diverse skills to collaborate with humans, build systems, and handle business operations.",
7
7
  "description.ru-RU": "Поддержка интеграции с AI-сервисами: предоставляются AI-узлы для рабочих процессов, расширяя возможности бизнес-обработки.",
8
8
  "description.zh-CN": "创建各种技能的 AI 员工,与人类协同,搭建系统,处理业务。",
9
- "version": "2.0.6",
9
+ "version": "2.0.7",
10
10
  "license": "Apache-2.0",
11
11
  "main": "dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/action-ai",
13
13
  "homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/action-ai",
14
14
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/action-ai",
15
15
  "peerDependencies": {
16
+ "@nocobase/acl": "2.x",
16
17
  "@nocobase/ai": "2.x",
17
18
  "@nocobase/client": "2.x",
18
19
  "@nocobase/flow-engine": "2.x",
@@ -52,5 +53,5 @@
52
53
  "keywords": [
53
54
  "AI"
54
55
  ],
55
- "gitHead": "8364210afd350869f33619e892fc82c8176f647a"
56
+ "gitHead": "71519f094dea3451ddfebe0045d8fd6e4281a6c5"
56
57
  }
@@ -1,10 +0,0 @@
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([["107"],{3973:function(e,t,n){n.r(t),n.d(t,{AIEmployeesProvider:function(){return t$}});var r=n(8156),o=n.n(r),l=n(5997),a=n(3772),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(2721),s=n(482),p=n(5441),f=n(4964),m=n(3990),d=n(3505),y=n(8875),v=n(8520),b=n(4241),h=n(5708),g=n(679),E=n(9039),x=n(5940),O=n(3972);function w(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 S(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){w(l,r,o,a,i,"next",e)}function i(e){w(l,r,o,a,i,"throw",e)}a(void 0)})}}function j(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function C(){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 C=function(){return n},n}var k=function(){var e=(0,a.useActionContext)().setVisible,t=(0,d.useForm)();return{onClick:function(){e(!1),t.reset()}}},P=function(e){var t=(0,a.useActionContext)().setVisible,n=(0,a.useAPIClient)(),r=(0,d.useForm)(),o=(0,v.D)().conversationsService;return{onClick:S(function(){return j(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.run(),[2]}})})}},A=function(e){var t,n,r,l=e.conversation,i=(0,m.NT)();return o().createElement(a.SchemaComponent,{scope:{useCloseActionProps:k,useSubmitActionProps:function(){return P(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,y.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)}})},T=(0,r.memo)(function(){var e,t=(0,m.NT)(),n=(0,a.useAPIClient)(),l=c.App.useApp(),i=l.modal,u=l.message,d=(0,O.S)().aiEmployeesMap,y=x.h.use.currentEmployee(),w=x.h.use.setCurrentEmployee(),k=x.h.use.setShowConversations(),P=x.h.use.setModel(),T=x.h.use.expanded(),I=b.U.use.currentConversation(),z=b.U.use.setCurrentConversation(),D=b.U.use.conversations(),M=b.U.use.keyword(),N=b.U.use.setKeyword(),F=h.h.use.setMessages(),B=(0,g.z)().messagesService,R=(0,v.D)(),L=R.conversationsService,U=R.lastConversationRef,_=L.loading,H=(0,E.W)(),$=H.startNewConversation,W=H.clear,q=(0,r.useMemo)(function(){var e=D.map(function(e){var n=e.title||t("New conversation");return{key:e.sessionId,title:n,timestamp:new Date(e.updatedAt).getTime(),label:n}});return _&&e.push({key:"loading",label:o().createElement(c.Spin,{style:{display:"block",margin:"8px auto"}})}),e},[D,_]),V=(0,r.useRef)(null);(0,r.useEffect)(function(){if(V.current&&D.length){var e=V.current.querySelector(".ant-conversations-item:last-child");e&&U(e)}},[D,U]);var Y=(e=S(function(e){return j(this,function(r){switch(r.label){case 0:return[4,n.resource("aiConversations").destroy({filterByTk:e})];case 1:return r.sent(),u.success(t("Deleted successfully")),L.run(),y&&$(),[2]}})}),function(t){return e.apply(this,arguments)});return 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:M,onChange:function(e){N(e.target.value)},placeholder:t("Search"),onSearch:function(e){return L.run(1,e)},onClear:function(){return L.run(1)},allowClear:!0})),o().createElement("div",{ref:V,style:{flex:1,minHeight:0,overflowY:"auto",overflowX:"hidden"}},D&&D.length?o().createElement(p.Z,{className:(0,f.css)(C()),activeKey:I,onActiveChange:function(e){if(e!==I){z(e);var t,n=D.find(function(t){return t.sessionId===e});w(d[null==n||null==(t=n.aiEmployee)?void 0:t.username]),F([]),W(),P(null),B.run(e),T||k(!1)}},items:q,menu:function(e){return{items:[{label:o().createElement(A,{conversation:e}),key:"rename",icon:o().createElement(s.EditOutlined,null)},{label:t("Delete"),key:"delete",icon:o().createElement(s.DeleteOutlined,null)}],onClick:function(n){var r=n.key;n.domEvent.stopPropagation(),"delete"===r&&i.confirm({title:t("Delete conversation"),content:t("Are you sure you want to delete it?"),onOk:function(){return Y(e.key)}})}}}}):o().createElement(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE})))}),I=n(1e3),z=n(8731);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,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var N=function(){var e=(0,m.NT)(),t=(0,a.useToken)().token,n=x.h.use.roles(),l=h.h.use.messages(),i=z.Y.use.updateTools(),u=(0,g.z)(),s=u.messagesService,p=u.lastMessageRef;(0,r.useEffect)(function(){i(l)},[l,i]);var f=(0,r.useRef)(null);return(0,r.useEffect)(function(){if(f.current){var e=f.current,t=new ResizeObserver(function(){e.scrollTop=e.scrollHeight});return t.observe(e),function(){return t.disconnect()}}},[l]),o().createElement(c.Layout.Content,{ref:f,style:{margin:"16px 0",overflow:"auto",position:"relative"}},s.loading&&o().createElement(c.Spin,{style:{display:"block",margin:"8px auto"}}),(null==l?void 0:l.length)?o().createElement("div",null,l.map(function(e,t){var r,l=n[e.role];return l?0===t&&(null==(r=e.content)?void 0:r.type)!=="greeting"?o().createElement("div",{key:e.key,ref:p},o().createElement(I.Z,M(D({},l),{loading:e.loading,content:e.content}))):o().createElement(I.Z,M(D({},l),{key:e.key,loading:e.loading,content:e.content})):null})):o().createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:t.colorTextDescription}},e("Work with your AI crew")))},F=n(2634),B=n(1707),R=n(3183),L=n.n(R);function U(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 _=function(){var e,t,n,o,l,u,c,s,p,f,m,d,y=h.h.use.setAttachments(),v={action:"aiFiles:create",onChange:function(e){y(e.fileList.map(function(e){if("done"===e.status){var t,n,r;return(null==e||null==(t=e.response)?void 0:t.data)?(n=U({},e.response.data),r=r={status:e.status},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n):e}return e}))}},b=(e=(0,a.useAPIClient)(),U({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.")}}}},v)),g=(t=(0,r.useContext)(i).storage,n=(0,a.usePlugin)(L()),o=null!=t?t:"",l="storages:getBasicInfo/".concat(o),c=(u=(0,a.useRequest)({url:l},{refreshDeps:[o],cacheKey:l})).loading,s=u.data,p=!c&&(null==s?void 0:s.data)||null,d=(null==(m=null==(f=n.getStorageType(t))?void 0:f.useUploadProps)?void 0:m(U({storage:p,rules:p.rules},v)))||{},U({rules:null==p?void 0:p.rules},d));return U({},b,v,g)};function H(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 $=function(){var e=(0,m.NT)(),t=_(),n=x.h.use.chatBoxRef(),l=x.h.use.currentEmployee(),a=h.h.use.attachments(),i=(0,r.useMemo)(function(){return null==a?void 0:a.map(function(e,t){var n;return H({uid:t.toString(),name:e.filename,status:null!=(n=e.status)?n:"done",url:e.url,size:e.size,thumbUrl:e.preview},e)})},[a]);return l?o().createElement(B.Z,H({getDropContainer:function(){return n.current},styles:{placeholder:{opacity:.8}},placeholder:{icon:o().createElement(s.PaperClipOutlined,null),title:e("Drag & Drop files here")},items:i},t),o().createElement(c.Tooltip,{title:e("Upload files"),arrow:!1},o().createElement(c.Button,{type:"text",icon:o().createElement(s.PaperClipOutlined,null)}))):o().createElement(c.Button,{type:"text",icon:o().createElement(s.PaperClipOutlined,null),disabled:!0})},W=n(7928),q=n(467),V=n.n(q),Y=n(2667),X=n(4102),G=n(3715),K=(0,Y.observer)(function(){var e,t,n=(0,m.NT)(),l=b.U.use.webSearch(),a=b.U.use.setWebSearch(),i=x.h.use.currentEmployee(),u=x.h.use.model(),p=(0,X.j)().services,f=(0,G.zC)(p,u),d=null!=(e=null==f?void 0:f.supportWebSearch)&&e,y=null!=(t=null==f?void 0:f.isToolConflict)&&t;(0,r.useEffect)(function(){!d&&l&&a(!1)},[d,l,a]);var v=function(){d&&a(!l)};if(!i)return o().createElement(c.Button,{type:"text",icon:o().createElement(s.GlobalOutlined,null),disabled:!0});var h=n("Disable search"),g=n("Web search not supported"),E=y?o().createElement("div",null,o().createElement("div",null,n("Enable search")),o().createElement("div",{style:{marginTop:4}},n("Search disables tools"))):n("Enable search");return l?o().createElement(c.Tooltip,{title:h,arrow:!1},o().createElement(c.Button,{color:"primary",variant:"filled",icon:o().createElement(s.GlobalOutlined,null),onClick:v})):o().createElement(c.Tooltip,{title:d?E:g,arrow:!1},o().createElement(c.Button,{type:"text",icon:o().createElement(s.GlobalOutlined,null),onClick:v,disabled:!d}))},{displayName:"SearchSwitch"}),Z=n(8563),J=n(4627),Q=n(4153),ee=n(611),et=n(392);function en(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 er(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 eo(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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 en(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 en(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 el=(0,d.observer)(function(){var e=(0,d.useForm)(),t=(0,Q.useProviderSettingsForm)(e.values.provider);return t?o().createElement(t,null):null},{displayName:"ModalSettings"}),ea=function(){return{form:(0,r.useMemo)(function(){return(0,Z.createForm)({initialValues:{name:"v_".concat((0,y.uid)())}})},[])}},ei=function(){var e=(0,a.useActionContext)().setVisible;return{type:"default",onClick:function(){e(!1)}}},eu={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"}}}}}}},ec=function(e){var t=e.open,n=e.onClose,l=e.onSuccess,i=(0,m.NT)(),u=(0,a.useAPIClient)(),s=eo((0,r.useState)([]),2),p=s[0],f=s[1],y=eo((0,r.useState)(0),2),v=y[0],b=y[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:d.Schema.compile(e.title||e.name,{t:i}),value:e.name,supportedModel:e.supportedModel}})})},{onSuccess:function(e){f(e)}}),o().createElement(J.Y1.Provider,{value:{providers:p}},o().createElement(a.ActionContextProvider,{value:{visible:t,setVisible:function(e){e||(n(),b(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:v,schema:eu,components:{ProviderSelect:Q.ProviderSelect,ModalSettings:el,LLMTestFlight:ee.w,EnabledModelsSelect:et.YX},scope:{useCreateFormProps:ea,useCancelActionProps:ei,useModalCreateActionProps:function(){var e=(0,a.useActionContext)().setVisible,t=c.App.useApp().message,n=(0,d.useForm)(),r=(0,a.useAPIClient)(),o=(0,m.NT)();return{type:"primary",onClick:function(){var a;return(a=function(){var a;return function(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[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){er(o,n,r,l,i,"next",e)}function i(e){er(o,n,r,l,i,"throw",e)}l(void 0)})})()}}},$getProviderLabel:function(e){var t=p.find(function(t){return t.value===e});return(null==t?void 0:t.label)||e},providers:p}}))))},es=n(929);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 ef(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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,Y.observer)(function(){var e=(0,m.NT)(),t=(0,a.useApp)(),n=(0,a.useAPIClient)(),l=(0,a.useToken)().token,i=c.App.useApp().message,u=ef((0,r.useState)(!1),2),p=u[0],f=u[1],d=x.h.use.currentEmployee(),y=null==d?void 0:d.username,v=x.h.use.model(),b=x.h.use.setModel(),h=t.pluginSettingsManager.has("ai.llm-services"),g=ef((0,r.useState)(!1),2),E=g[0],O=g[1],w=(0,X.j)(),S=w.repo,j=w.services,C=w.loading,k=w.allModelsWithLabel,P=w.allModels;(0,r.useEffect)(function(){if(y&&P.length){var e=(0,es.QU)(n,y,P,v);(0,es.ff)(e,v)||b(e)}},[n,y,P,v,b]);var A=(0,r.useMemo)(function(){return(0,es.Pu)(v,P)?v:P.length?{llmService:P[0].llmService,model:P[0].model}:void 0},[v,P]),T=(0,r.useMemo)(function(){if(A){var e=k.find(function(e){return e.llmService===A.llmService&&e.model===A.model});return(null==e?void 0:e.label)||A.model}},[A,k]),I=function(e,t){var r=k.find(function(n){return n.llmService===e&&n.value===t});if(r&&(b({llmService:r.llmService,model:r.model}),d))try{null==n||n.storage.setItem(es.kX+d.username,"".concat(r.llmService,":").concat(r.model))}catch(e){console.log(e)}};if(!d)return null;if(C&&!j.length)return o().createElement(c.Spin,{size:"small"});var z=P.length>0,D=[];j.forEach(function(e,t){t>0&&D.push({type:"divider",key:"divider-".concat(t)}),D.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=A&&A.llmService===e.llmService&&A.model===t.value;D.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:l.colorPrimary}})),onClick:function(){return I(e.llmService,t.value)}})})}),z||D.push({key:"empty-placeholder",label:o().createElement(c.Typography.Text,{type:"secondary",style:{fontSize:12}},e("No LLM services enabled yet")),disabled:!0,style:{cursor:"default",padding:"16px 12px",height:"auto",minHeight:0}}),D.length>0&&D.push({type:"divider",key:"divider-add"}),D.push({key:"add-model",icon:o().createElement(s.PlusOutlined,null),label:e("Add LLM service"),onClick:function(){h?O(!0):i.warning(e("Please contact the administrator to configure models"))}});var M=o().createElement("span",{onClick:function(e){e.stopPropagation()},style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:12,backgroundColor:l.colorFillTertiary,borderRadius:6,height:28,padding:"0 8px",cursor:"pointer",minWidth:z?"auto":void 0,userSelect:"none"}},o().createElement("span",{style:{color:z?l.colorText:l.colorError,display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:88}},z?T:e("No model available")),o().createElement(s.DownOutlined,{style:{fontSize:10,color:z?l.colorTextSecondary:l.colorError}}));return o().createElement(o().Fragment,null,o().createElement(c.Dropdown,{menu:{items:D,style:{maxHeight:400,overflow:"auto"}},trigger:["hover"],open:p,onOpenChange:f,overlayStyle:{zIndex:1200}},M),h&&o().createElement(ec,{open:E,onClose:function(){return O(!1)},onSuccess:function(){return S.refresh()}}))},{displayName:"ModelSwitcher"}),ed=n(7437),ey=n(7097);function ev(){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 ev=function(){return n},n}n(8456);var eb=function(){var e=h.h.use.attachments(),t=h.h.use.removeAttachment(),n=(0,r.useMemo)(function(){return null==e?void 0:e.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)})},[e]);if(!(null==n?void 0:n.length))return null;var l=(0,f.css)(ev());return o().createElement("div",{className:l,style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:4}},n.map(function(e){return o().createElement(B.Z.FileCard,{key:e.uid,item:e,onRemove:function(e){return t(e.name)}})}))},eh=n(8495);function eg(){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 eg=function(){return n},n}var eE=function(){var e=h.h.use.contextItems(),t=h.h.use.removeContextItem();return(null==e?void 0:e.length)?o().createElement("div",{className:(0,f.css)(eg())},e.map(function(e){return o().createElement(eh.P,{within:"sender",key:"".concat(e.type,":").concat(e.uid),item:e,closable:!0,onRemove:t})})):null},ex=function(){var e=(0,m.NT)(),t=(0,a.useToken)().token,n=x.h.use.setSenderValue(),r=b.U.use.currentConversation(),l=h.h.use.setMessages(),i=(0,g.z)(),u=i.messagesService,p=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"),type:"info",showIcon:!0,closable:!0,onClose:function(){p(),n(""),l([]),u.run(r)}})};function eO(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=function(){var e,t=(0,m.NT)(),n=(e=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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),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,2)||function(e,t){if(e){if("string"==typeof e)return eO(e,2);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 eO(e,t)}}(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.")}()),l=n[0],i=n[1],u=(0,O.S)().aiEmployees,p=x.h.use.currentEmployee(),f=(0,E.W)().switchAIEmployee,d=(0,a.useToken)().token,y=(0,r.useMemo)(function(){return u.length?u.map(function(e){var t=(null==p?void 0:p.username)===e.username;return{key:e.username,label:o().createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}},o().createElement(ed.B,{aiEmployee:e}),t&&o().createElement(s.CheckOutlined,{style:{fontSize:12,color:d.colorPrimary}})),onClick:function(){return f(e)}}}):[{key:"empty",label:o().createElement("span",{style:{fontSize:12,color:d.colorTextSecondary}},t("Please choose an AI employee")),disabled:!0,style:{cursor:"default",padding:"16px 12px",height:"auto",minHeight:0}}]},[u,null==p?void 0:p.username,f,t,d.colorPrimary,d.colorTextSecondary]),v=u.length>0,b=p?p.nickname:"".concat(t("Select an")," ").concat(t("AI employee")),h=o().createElement("span",{onClick:function(e){return e.stopPropagation()},style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:12,backgroundColor:d.colorFillTertiary,borderRadius:6,height:28,padding:"0 8px",cursor:"pointer",userSelect:"none"}},p?o().createElement(c.Avatar,{shape:"circle",size:20,src:(0,ey.a)(p.avatar)}):null,o().createElement("span",{style:{color:v?d.colorText:d.colorError,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:160}},b),o().createElement(s.DownOutlined,{style:{fontSize:10,color:v?d.colorTextSecondary:d.colorError}}));return o().createElement(c.Dropdown,{menu:{items:y,style:{maxHeight:400,overflow:"auto"}},trigger:["hover"],open:l,onOpenChange:i,overlayStyle:{zIndex:1200}},h)},eS=function(e){var t,n,l=e.components,a=e.handleSubmit,i=l.SendButton,u=l.LoadingButton,s=(0,r.useRef)(null),p=null==(t=(n=x.h.use).currentEmployee)?void 0:t.call(n),f=h.h.use.responseLoading(),m=h.h.use.addContextItems(),d=h.h.use.removeContextItem(),y=x.h.use.senderValue(),v=h.h.use.contextItems(),b=x.h.use.senderRef();return(0,r.useEffect)(function(){var e;(null==b||null==(e=b.current)?void 0:e.nativeElement)&&(b.current.nativeElement.onkeydown=function(e){if("Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),V().isEmpty(y)&&v.length)){var t;null==(t=s.current)||t.click()}})},[b,y,v]),o().createElement(c.Flex,{justify:"space-between",align:"center"},o().createElement(c.Flex,{gap:"middle",align:"center"},o().createElement(W.u,{onAdd:m,onRemove:d,disabled:!p,ignore:function(e){return"flow-model.variable"===e}}),o().createElement($,null),o().createElement(K,null),o().createElement(ew,null),o().createElement(em,null)),o().createElement(c.Flex,{align:"center",gap:"middle"},f?o().createElement(u,{type:"default"}):o().createElement(i,{ref:s,type:"primary",disabled:!1,onClick:function(){V().isEmpty(y)&&v.length&&a("")}})))},ej=function(){var e=x.h.use.currentEmployee(),t=x.h.use.isEditingMessage(),n=h.h.use.contextItems(),r=h.h.use.attachments(),l=!!(null==n?void 0:n.length),a=!!(null==r?void 0:r.length);return t||e&&(l||a)?o().createElement("div",{style:{padding:"8px 8px 0 8px"}},t?o().createElement("div",null,o().createElement(ex,null)):null,e?o().createElement(eE,null):null,e?o().createElement(eb,null):null):null};function eC(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 ek(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 eP(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eA(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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)||eT(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 eT(e,t){if(e){if("string"==typeof e)return eC(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 eC(e,t)}}function eI(){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 eI=function(){return n},n}var ez=function(){var e=x.h.use.currentEmployee(),t=x.h.use.isEditingMessage(),n=x.h.use.editingMessageId(),r=b.U.use.currentConversation(),o=b.U.use.webSearch(),l=h.h.use.attachments(),a=h.h.use.contextItems(),i=h.h.use.systemMessage(),u=h.h.use.skillSettings(),c=(0,g.z)().finishEditingMessage,s=(0,E.W)().send;return[function(p){s({sessionId:r,aiEmployee:e,systemMessage:i,messages:[{type:"text",content:p}],attachments:l.filter(function(e){return"done"===e.status}),workContext:a,editingMessageId:t?n:void 0,skillSettings:u,webSearch:o}),t&&c()}]},eD=function(){var e=(0,m.NT)(),t=(0,f.css)(eI()),n=eA(ez(),1)[0],l=(0,r.useRef)(null),a=x.h.use.senderValue(),i=x.h.use.setSenderValue(),u=x.h.use.currentEmployee(),c=x.h.use.setSenderRef(),s=h.h.use.setAttachments(),p=_(),d=h.h.use.responseLoading(),y=(0,g.z)().cancelRequest,v=eA((0,r.useState)(a),2),b=v[0],E=v[1];return(0,r.useEffect)(function(){c(l)},[]),(0,r.useEffect)(function(){b!==a&&i(b)},[b]),(0,r.useEffect)(function(){E(a)},[a]),o().createElement("div",{style:{margin:"8px 16px"}},o().createElement(F.Z,{className:t,value:b,ref:l,onChange:function(e){E(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};s(function(e){return((function(e){if(Array.isArray(e))return eC(e)})(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eT(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=p.customRequest,u=p.data,c=p.headers,f=p.action;i&&i({file:l,filename:"file",data:u,headers:c,action:f,onProgress:function(e){var t=e.percent;s(function(e){return e.map(function(e){return e.uid===o?eP(ek({},e),{percent:t}):e})})},onSuccess:function(e,t){var n=null==e?void 0:e.data;s(function(t){return t.map(function(t){return t.uid===o?eP(ek(eP(ek({},t),{status:"done",response:e}),n),{url:(null==n?void 0:n.url)||t.url}):t})})},onError:function(e){s(function(t){return t.map(function(t){return t.uid===o?eP(ek({},t),{status:"error",error:e}):t})})}})}},onSubmit:n,onCancel:y,header:o().createElement(ej,null),loading:d,footer:function(e){var t=e.components;return o().createElement(eS,{components:t,handleSubmit:n})},disabled:!u,placeholder:e("Enter your question"),actions:!1,autoSize:{minRows:2,maxRows:8}}))};function eM(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 eN(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 eF(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var eB=function(){var e=(0,a.useActionContext)().setVisible,t=(0,d.useForm)();return{type:"default",onClick:function(){e(!1),t.reset()}}},eR=function(){var e=(0,a.useActionContext)().setVisible,t=c.App.useApp().message,n=(0,d.useForm)(),r=(0,a.useAPIClient)(),o=(0,m.NT)(),l=x.h.use.currentEmployee(),i=x.h.use.setCurrentEmployee(),u=(0,O.S)().refresh;return{type:"primary",onClick:function(){var a;return(a=function(){var a;return function(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(c){switch(c.label){case 0:return[4,n.submit()];case 1:return c.sent(),[4,r.resource("aiEmployees").updateUserPrompt({values:{aiEmployee:l.username,prompt:null==(a=n.values)?void 0:a.prompt}})];case 2:return c.sent(),u(),i(function(e){var t;return eF(eN({},e),{userConfig:eF(eN({},e.userConfig),{prompt:null==(t=n.values)?void 0:t.prompt})})}),t.success(o("Saved successfully")),e(!1),n.reset(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=a.apply(e,t);function l(e){eM(o,n,r,l,i,"next",e)}function i(e){eM(o,n,r,l,i,"throw",e)}l(void 0)})})()}}},eL=function(){var e,t=(0,m.NT)(),n=x.h.use.currentEmployee();return o().createElement(a.SchemaComponent,{scope:{useCancelActionProps:eB,useEditActionProps:eR},schema:{type:"void",name:(0,y.uid)(),"x-component":"Action",title:'{{t("Edit")}}',"x-component-props":{variant:"link",color:"primary"},properties:{modal:{type:"void","x-component":"Action.Modal","x-component-props":{styles:{wrapper:{zIndex:1200},mask:{zIndex:1200}}},title:t("Edit personalized prompt"),"x-decorator":"FormV2","x-decorator-props":"useEditFormProps",properties:{prompt:{type:"string",title:t("Personalized prompt"),"x-decorator":"FormItem","x-component":"Input.TextArea",default:null==n||null==(e=n.userConfig)?void 0:e.prompt},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{close:{title:t("Cancel"),"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:t("Submit"),"x-component":"Action","x-use-component-props":"useEditActionProps"}}}}}}}})},eU=function(){var e,t=(0,m.NT)(),n=(0,a.useToken)().token,r=x.h.use.currentEmployee();return o().createElement(c.Popover,{zIndex:1101,styles:{body:{padding:0,marginRight:"8px"}},arrow:!1,content:o().createElement(c.Card,{styles:{body:{width:"400px"}},variant:"borderless",size:"small",title:o().createElement("div",{style:{fontWeight:500,fontSize:n.fontSize}},t("Personalized prompt")),extra:o().createElement(eL,null)},(null==r||null==(e=r.userConfig)?void 0:e.prompt)?o().createElement("div",{style:{whiteSpace:"pre-wrap"}},r.userConfig.prompt):o().createElement(c.Alert,{message:t("Personalized prompt description"),type:"info"}))},o().createElement(c.Button,{icon:o().createElement(s.InfoCircleOutlined,null),type:"text"}))},e_=n(9557),eH=n(1863);function e$(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 eW(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 eq(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eV(e){return function(e){if(Array.isArray(e))return e$(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eY(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 eY(e,t){if(e){if("string"==typeof e)return e$(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 e$(e,t)}}function eX(){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 eX=function(){return n},n}var eG=c.Layout.Header,eK=c.Layout.Content,eZ=c.Typography.Title,eJ=function(){var e=(0,m.NT)(),t=(0,a.useToken)().token,n=x.h.use.setShowCodeHistory();return o().createElement(c.Layout,{style:{padding:"0 16px 16px",height:"100%"}},o().createElement(eG,{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(eZ,{level:5,style:{margin:0}},e("Code history")))),o().createElement(eK,null,o().createElement(eQ,null)))},eQ=function(){var e,t="javascript",n="code-editor",l=x.h.use.currentEmployee(),a=h.h.use.messages(),i=(e=(0,r.useState)([]),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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),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,2)||eY(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.")}()),u=i[0],s=i[1];return(0,r.useEffect)(function(){if(l&&(null==a?void 0:a.length)){var e=RegExp("```"+t+"([\\s\\S]*?)```","s"),r=a.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=a.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]}}}}),i=eV(r).concat(eV(o));i.sort(function(e,t){return Number(e.message.key)-Number(t.message.key)}),s(i)}},[a,l]),o().createElement(c.List,{style:{height:"100%",overflowY:"auto"},dataSource:u,renderItem:function(e,t){return o().createElement(c.List.Item,{key:t},o().createElement(e0,e))}})},e0=function(e){var t=e.message,n=e.workContext,r=x.h.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,eq(eW({},i),{icon:o().createElement(s.UserOutlined,null)})):o().createElement(c.Avatar,eq(eW({},i),{src:(0,ey.a)(r.avatar)})),o().createElement("div",{className:(0,a.css)(eX())},o().createElement(eH.un,{className:"language-".concat(l.language)},l.code)))},e1=n(8003);function e2(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 e8=c.Layout.Header,e3=c.Layout.Footer,e4=c.Layout.Sider,e5=c.Typography.Text,e6=function(){var e=(0,r.useRef)(null),t=x.h.use.setChatBoxRef(),n=x.h.use.setOpen(),l=x.h.use.currentEmployee(),i=x.h.use.expanded(),u=x.h.use.setExpanded(),p=x.h.use.setMinimize(),f=x.h.use.showConversations(),d=x.h.use.setShowConversations(),y=x.h.use.setShowCodeHistory(),v=x.h.use.showDebugPanel(),b=x.h.use.setShowDebugPanel(),h=(0,E.W)().startNewConversation,g=(0,a.useToken)().token,O=(0,m.NT)();(0,r.useEffect)(function(){t(e)},[]);var w=(0,a.useMobileLayout)().isMobileLayout;return o().createElement(c.Layout,{style:{height:"100%",position:"relative"},ref:e},f&&!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 d(!1)}}),o().createElement("div",{style:{position:"absolute",top:0,left:0,width:"300px",height:"100%",backgroundColor:g.colorBgContainer,zIndex:11,borderRight:"1px solid ".concat(g.colorBorder),overflow:"hidden"}},o().createElement(T,null))),f&&i&&o().createElement(e4,{width:300,style:{backgroundColor:g.colorBgContainer,borderRight:"1px solid ".concat(g.colorBorder),overflow:"hidden"}},o().createElement(T,null)),o().createElement(c.Layout,null,o().createElement(e8,{style:{backgroundColor:g.colorBgContainer,height:"48px",lineHeight:"48px",padding:"0 16px",borderBottom:"1px solid ".concat(g.colorBorder),display:"flex",alignItems:"center",justifyContent:"space-between"}},o().createElement("div",null,o().createElement(c.Button,{icon:f?o().createElement(s.MenuFoldOutlined,null):o().createElement(s.MenuUnfoldOutlined,null),type:"text",onClick:function(e){e.stopPropagation(),d(!f)}})),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:h})),o().createElement(eU,null),(0,e1.pN)(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(){y(!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 b(!v)}})),o().createElement(c.Divider,{type:"vertical"})):null,w?o().createElement(c.Button,{icon:o().createElement(s.CompressOutlined,null),type:"text",onClick:function(){p(!0)}}):o().createElement(c.Button,{icon:i?o().createElement(s.FullscreenExitOutlined,null):o().createElement(s.FullscreenOutlined,null),type:"text",onClick:function(){i||b(!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(N,null),o().createElement(e3,{style:{backgroundColor:g.colorBgContainer,padding:0}},o().createElement(eD,null),o().createElement("div",{style:{textAlign:"center",margin:"10px 0",fontSize:g.fontSizeSM,color:g.colorTextTertiary}},O("AI disclaimer")))))},e7=(0,Y.observer)(function(){return o().createElement(c.Card,{style:{position:"fixed",transform:"translate(-50%, -50%)",left:"50%",top:"50%",width:"95%",height:"95%",zIndex:e_.t.shouldHide?-1:1100},styles:{body:{height:"100%",padding:0}}},o().createElement(e6,null))}),e9=(0,Y.observer)(function(e){var t=e.minimize;return o().createElement("div",{style:{position:"fixed",left:"0",top:"0",width:"100%",height:"100%",zIndex:e_.t.shouldHide?-1:1100,backgroundColor:"white",display:t?"none":"block"}},o().createElement(e6,null),o().createElement(te,null))}),te=function(){var e,t=x.h.use.currentEmployee(),n=x.h.use.minimize(),l=x.h.use.setMinimize(),a=x.h.use.setOpen(),i=(0,m.NT)(),u=(e=c.notification.useNotification(),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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),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,2)||function(e,t){if(e){if("string"==typeof e)return e2(e,2);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 e2(e,t)}}(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.")}()),p=u[0],f=u[1],d=(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?p.open({key:d.current,closeIcon:!1,message:o().createElement(c.Flex,{justify:"space-between",align:"center"},o().createElement(c.Avatar,{shape:"circle",size:35,src:(0,ey.a)(y)}),o().createElement(e5,{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)}}):p.destroy(d.current),function(){p.destroy(d.current)}},[p,y,n,l,a,i]),o().createElement(o().Fragment,null,f)},tt=function(){var e=x.h.use.expanded(),t=x.h.use.minimize(),n=x.h.use.showCodeHistory();return(0,a.useMobileLayout)().isMobileLayout?o().createElement(e9,{minimize:t}):e?o().createElement(e7,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(eJ,null):o().createElement(e6,null))},tn=n(1272),tr=n.p+"f0053e745af0ad03.svg";function to(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 tl(){var e,t,n=(e=["\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\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\n ","\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return tl=function(){return n},n}var ta=(0,Y.observer)(function(){var e,t,n=(0,Y.useFlowContext)(),l=(0,a.useMobileLayout)().isMobileLayout,i=(null==n||null==(t=n.pageInfo)?void 0:t.version)==="v1",u=(0,a.useToken)().token,s=(0,O.S)().aiEmployees,p=(e=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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),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,2)||function(e,t){if(e){if("string"==typeof e)return to(e,2);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 to(e,t)}}(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.")}()),m=p[0],d=p[1],y=x.h.use.open(),v=x.h.use.setOpen();x.h.use.currentEmployee();var h=(0,E.W)().switchAIEmployee,g=b.U.use.setWebSearch(),w=(0,r.useMemo)(function(){return null==s?void 0:s.filter(function(e){return!(0,e1.D1)(e)}).map(function(e){return{key:e.username,label:o().createElement(ed.B,{aiEmployee:e,onClick:function(){g(!0),v(!0),h(e)}})}})},[s]);if(y||!(null==s?void 0:s.length)||i)return null;var S=u.boxShadowSecondary||u.boxShadow;return!l&&o().createElement(c.Dropdown,{menu:{items:w},placement:"topRight",trigger:["hover"],align:{offset:[-16,-6]},open:m,onOpenChange:function(e){return d(e)}},o().createElement("div",{onClick:function(){d(!1),v(!0)},className:(0,f.css)(tl(),u.colorBgElevated,S,m?"\n opacity: 1;\n transform: translateX(-8px);\n ":"")},o().createElement(c.Avatar,{src:tr,size:42,shape:"square"})))}),ti=n(4822);function tu(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tc(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){tu(e,t,n[t])})}return e}var ts=function(){var e=(0,O.S)().aiEmployees,t=x.h.use.open(),n=x.h.use.senderRef(),o=x.h.use.currentEmployee(),l=x.h.use.setRoles(),i=(0,v.D)().conversationsService,u=(0,a.useTools)().refresh;(0,r.useEffect)(function(){if(!e)return void l(function(e){return tc({},e,ti.O)});var t=e.reduce(function(e,t){var n,r;return n=tc({},e),r=null!=(r=tu({},t.username,(0,ti.D)(t)))?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n},{});l(function(e){return tc({},e,ti.O,t)})},[e]),(0,r.useEffect)(function(){var e;null==n||null==(e=n.current)||e.focus()},[o]),(0,r.useEffect)(function(){if(t){var e;i.run(),null==n||null==(e=n.current)||e.focus(),u()}},[t]),(0,r.useEffect)(function(){o&&t&&i.run()},[null==o?void 0:o.username])},tp=n(5451);function tf(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 tm(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){tf(l,r,o,a,i,"next",e)}function i(e){tf(l,r,o,a,i,"throw",e)}a(void 0)})}}function td(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var ty=function(e){return{onOk:tm(function(){return td(this,function(e){return[2]})})}},tv=function(){var e,t,n,l,i=(0,m.NT)(),u=(0,a.useTools)().tools,s=(0,a.toToolsMap)(u),p=z.Y.use.openToolModal(),f=z.Y.use.setOpenToolModal(),y=z.Y.use.activeTool(),v=z.Y.use.setActiveTool(),h=z.Y.use.activeMessageId(),E=z.Y.use.setActiveMessageId(),x=z.Y.use.toolsByName(),O=b.U.use.currentConversation(),w=(0,g.z)(),S=w.updateToolArgs,j=w.messagesService,C=s.get(null==y?void 0:y.name),k=null==C||null==(t=C.ui)?void 0:t.modal,P=(null==C||null==(l=C.ui)||null==(n=l.modal)?void 0:n.useOnOk)||ty,A=null==k?void 0:k.Component,T=z.Y.use.adjustArgs(),I=P((0,(0,tp.e)({messageId:h}).getDecisionActions)(y),T).onOk,D=x[null==y?void 0:y.name]||[],M=D.map(function(e,t){return{key:e.id,value:e.id,label:"Version ".concat(t+1)}}),N=(0,r.useCallback)((e=tm(function(e){return td(this,function(t){switch(t.label){case 0:if(!y||!O||!h)return[2];return[4,S({sessionId:O,messageId:h,tool:{id:y.id,args:e}})];case 1:var n,r;return t.sent(),c.message.success(i("Saved successfully")),v((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}({},y),r=r={args:e},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n)),[2]}})}),function(t){return e.apply(this,arguments)}),[j,h,y,O,S]);return o().createElement(c.Modal,{title:o().createElement(o().Fragment,null,(null==k?void 0:k.title)?d.Schema.compile(k.title,{t:i}):"",M.length>1&&o().createElement(c.Select,{options:M,value:null==y?void 0:y.id,style:{marginLeft:"8px"},onChange:function(e){var t=D.find(function(t){return t.id===e});E((null==t?void 0:t.messageId)||""),v(t)}})),open:p,width:"90%",onCancel:function(){f(!1),v(null)},okText:(null==k?void 0:k.okText)?d.Schema.compile(k.okText,{t:i}):i("Submit"),onOk:tm(function(){return td(this,function(e){switch(e.label){case 0:return[4,null==I?void 0:I()];case 1:return e.sent(),f(!1),[2]}})}),okButtonProps:{disabled:!["init","interrupted","pending"].includes(y.invokeStatus)},footer:function(e,t){var n=t.OkBtn;return o().createElement(o().Fragment,null,o().createElement(n,null))}},A?o().createElement(A,{tool:y,saveToolArgs:N}):null)},tb=n(8087),th=n(7271);function tg(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=(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),p=(n=(0,r.useState)(400),function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,r,o=null==e?null:"undefined"!=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),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}}(n,2)||function(e,t){if(e){if("string"==typeof e)return tg(e,2);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 tg(e,t)}}(n,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.")}()),f=p[0],m=p[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;m(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),m(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(th.Z,{ref:s,data:l,itemKey:a,height:f,itemHeight:void 0===i?48:i,fullHeight:!1},u))});function tx(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 tO(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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)||tj(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 tw(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function tS(e){return function(e){if(Array.isArray(e))return tx(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||tj(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 tj(e,t){if(e){if("string"==typeof e)return tx(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 tx(e,t)}}function tC(){var e=tw(["\n padding: 8px 12px;\n border-bottom: 1px solid ",";\n &:hover {\n background-color: ",";\n }\n "]);return tC=function(){return e},e}function tk(){var e=tw(["\n display: flex;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n "]);return tk=function(){return e},e}function tP(){var e=tw(["\n color: ",";\n "]);return tP=function(){return e},e}function tA(){var e=tw(["\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 tA=function(){return e},e}function tT(){var e=tw(["\n display: flex;\n flex-direction: column;\n height: 100%;\n "]);return tT=function(){return e},e}function tI(){var e=tw(["\n padding: 12px;\n border-bottom: 1px solid ",";\n display: flex;\n gap: 8px;\n "]);return tI=function(){return e},e}var tz=c.Typography.Text,tD=c.Input.Search,tM={request:"blue",stream_text:"green",stream_search:"cyan",stream_start:"geekblue",stream_tools:"orange",stream_delta:"lime",stream_error:"volcano",tool_call:"gold",tool_result:"purple",error:"red"},tN=[{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_error",label:"Stream Error"},{value:"tool_call",label:"Tool Call"},{value:"tool_result",label:"Tool Result"},{value:"error",label:"Error"}],tF=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)(tC(),l.colorBorderSecondary,l.colorFillQuaternary)},o().createElement("div",{className:(0,f.css)(tk()),onClick:r},n?o().createElement(s.DownOutlined,{style:{fontSize:10}}):o().createElement(s.RightOutlined,{style:{fontSize:10}}),o().createElement(tz,{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:tM[t.type],style:{margin:0}},t.type),o().createElement(tz,{ellipsis:!0,style:{flex:1,fontFamily:"monospace",fontSize:12},className:(0,f.css)(tP(),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)(tA(),l.colorFillSecondary)},JSON.stringify(t.data,null,2)))},tB=function(){var e=x.h.use.showDebugPanel(),t=x.h.use.setShowDebugPanel(),n=b.U.use.currentConversation(),l=tO((0,r.useState)([]),2),i=l[0],u=l[1],p=tO((0,r.useState)("all"),2),d=p[0],y=p[1],v=tO((0,r.useState)(""),2),h=v[0],g=v[1],E=tO((0,r.useState)(new Set),2),O=E[0],w=E[1],S=(0,r.useRef)(null),j=(0,m.NT)(),C=(0,a.useToken)().token;(0,r.useEffect)(function(){if(!n)return void u([]);var e=tb._.getSession(n);return e?u(tS(e.logs)):u([]),tb._.subscribe(function(e,t){t===n&&u(function(t){return tS(t).concat([e])})})},[n]);var k=(0,r.useMemo)(function(){return i.filter(function(e){if("all"!==d&&e.type!==d)return!1;if(h){var t=h.toLowerCase();return JSON.stringify(e.data).toLowerCase().includes(t)}return!0})},[i,d,h]);(0,r.useEffect)(function(){k.length>0&&requestAnimationFrame(function(){var e;null==(e=S.current)||e.scrollTo({index:k.length-1,align:"bottom"})})},[i]);var P=(0,r.useCallback)(function(e){w(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),A=(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,j("Debug Panel")),n&&o().createElement(tz,{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=tb._.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},j("Export"))},o().createElement("div",{className:(0,f.css)(tT())},o().createElement("div",{className:(0,f.css)(tI(),C.colorBorder)},o().createElement(c.Select,{value:d,onChange:y,options:tN,style:{width:120},size:"small"}),o().createElement(tD,{placeholder:j("Search logs..."),value:h,onChange:function(e){return g(e.target.value)},allowClear:!0,size:"small",style:{flex:1}})),n?0===k.length?o().createElement(c.Empty,{description:j("No logs"),style:{marginTop:100}}):o().createElement(tE,{ref:S,data:k,itemKey:A,itemHeight:40},function(e){return o().createElement(tF,{log:e,expanded:O.has(e.id),onToggleExpand:function(){return P(e.id)}})}):o().createElement(c.Empty,{description:j("No conversation selected"),style:{marginTop:100}})))},tR=function(e){var t=x.h.use.open(),n=x.h.use.expanded(),r=z.Y.use.activeTool(),l=x.h.use.showDebugPanel(),i=(0,a.useMobileLayout)().isMobileLayout;return ts(),o().createElement(o().Fragment,null,e.children,o().createElement(ta,null),!t||n||i?null:o().createElement(tn.q,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(tt,null):null,r&&o().createElement(tv,null),l&&o().createElement(tB,null))},tL=n(9382),tU=(0,Y.observer)(function(){return tL.n.selectable&&o().createElement(tn.q,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 t_(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 tH=(0,Y.observer)(function(){var e,t=(0,m.NT)(),n=c.theme.useToken().token,l=(e=c.notification.useNotification(),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=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),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,2)||function(e,t){if(e){if("string"==typeof e)return t_(e,2);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 t_(e,t)}}(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.")}()),a=l[0],i=l[1],u=(0,r.useRef)("ai-selection-control-".concat(new Date().getTime())),p=tL.n.selectable;return(0,r.useEffect)(function(){return""!==p?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(){tL.n.stopSelect(),e_.t.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,p,t,n]),o().createElement(o().Fragment,null,i)}),t$=function(e){var t,n=(0,a.useApp)().aiManager.toolsManager,i=(0,r.useContext)(a.CurrentUserContext);return(null==i||null==(t=i.data)?void 0:t.data)?o().createElement(l.K$,null,o().createElement(u,null,o().createElement(a.ToolsProvider,{toolsManager:n},o().createElement(tR,null,e.children),o().createElement(tU,null),o().createElement(tH,null)))):o().createElement(o().Fragment,null,e.children)}},1863:function(e,t,n){n.d(t,{EK:function(){return k},un:function(){return C},ws:function(){return j}});var r=n(8156),o=n.n(r),l=n(2721),a=n(482),i=n(3772),u=n(3990),c=n(8003),s=n(2667),p=n(5708),f=n(3581);function m(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 d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(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=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(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}var v=(0,i.lazy)(function(){return f("imported_1na2390_component",Promise.all([n.e("204"),n.e("124")]).then(n.bind(n,3770)))},"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,d(m({},a),{language:t,value:n,height:r,scrollToBottom:l}))},h=function(e){var t=(0,s.useFlowContext)(),n=(0,u.NT)(),r=e.children,i=e.className,c=(e.node,e.message),f=y(e,["children","className","node","message"]),v=/language-(\w+)/.exec(i||""),h=v?v[1]:"",E=String(r).replace(/<!--[\s\S]*?-->/g,"").replace(/\n$/,""),x=l.App.useApp().message,O=!0;(null==c?void 0:c.type)==="text"&&(O=RegExp("```"+h+"[\\s\\S]*?```","s").test(c.content));var w=p.h.use.editorRef()[p.h.use.currentEditorRefUid()];return v?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,h)),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(E),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(g,d(m({},f),{language:h,value:E,height:"75vh"}))})}}))),styles:{header:{padding:0},body:{padding:0}},actions:w?[o().createElement(l.Button,{key:"accept",type:"link",onClick:function(e){e.stopPropagation(),null==w||w.write(E),t.message.info(n("Applied"))},disabled:!O},n("Apply to editor"))]:[]},o().createElement(b,d(m({},f),{language:h,value:E,scrollToBottom:!O}))):o().createElement(l.Typography.Text,d(m({code:!0},f),{className:i}),r)},g=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,d(m({},r),{language:t,value:n})))},E=n(3581);function x(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 O(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function w(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(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}var S=(0,i.lazy)(function(){return E("imported_1na2390_component",Promise.all([n.e("204"),n.e("124")]).then(n.bind(n,3770)))},"CodeHighlight").CodeHighlight,j=function(e){var t=e.language,n=e.value,r=w(e,["language","value"]);return o().createElement(S,O(x({},r),{language:t,value:n}))},C=function(e){var t=e.children,n=e.className,r=(e.node,e.message,w(e,["children","className","node","message"])),c=/language-(\w+)/.exec(n||""),s=c?c[1]:"",p=(0,i.useToken)().token,f=(0,u.NT)(),m=String(t).replace(/\n$/,""),d=l.App.useApp().message;return c?o().createElement(l.Card,{size:"small",title:s,styles:{title:{fontSize:p.fontSize,fontWeight:400},body:{width:"100%",fontSize:p.fontSizeSM}},extra:o().createElement(l.Button,{variant:"link",color:"default",size:"small",onClick:function(){navigator.clipboard.writeText(m),d.success(f("Copied"))},icon:o().createElement(a.CopyOutlined,null)})},o().createElement(j,O(x({},r),{language:s,value:m}))):o().createElement(l.Typography.Text,O(x({code:!0},r),{className:n}),t)},k=function(e){var t=e.className,n=/language-(\w+)/.exec(t||""),r=n?n[1]:"";return p.h.use.editorRef()[p.h.use.currentEditorRefUid()]&&(0,c.p0)(r)?o().createElement(h,e):o().createElement(C,e)}}}]);