/**
 * This file is part of the NocoBase (R) project.
 * Copyright (c) 2020-2024 NocoBase Co., Ltd.
 * Authors: NocoBase Team.
 *
 * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
 * For more information, please refer to: https://www.nocobase.com/agreement.
 */

var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var ai_coding_manager_exports = {};
__export(ai_coding_manager_exports, {
  AICodingManager: () => AICodingManager
});
module.exports = __toCommonJS(ai_coding_manager_exports);
var import_flow_resource = __toESM(require("../ai-employees/built-in/ai-coding/document/basic/flow-resource"));
var import_js_block = __toESM(require("../ai-employees/built-in/ai-coding/document/js-block"));
var import_js_field = __toESM(require("../ai-employees/built-in/ai-coding/document/js-field"));
var import_js_column = __toESM(require("../ai-employees/built-in/ai-coding/document/js-column"));
var import_js_item = __toESM(require("../ai-employees/built-in/ai-coding/document/js-item"));
var import_js_action = __toESM(require("../ai-employees/built-in/ai-coding/document/js-action"));
var import_js_column2 = __toESM(require("../ai-employees/built-in/ai-coding/document/example/js-column"));
var import_js_filter = __toESM(require("../ai-employees/built-in/ai-coding/document/example/js-filter"));
class AICodingManager {
  constructor(plugin) {
    this.plugin = plugin;
  }
  provideWorkContextResolveStrategy() {
    return async (ctx, contextItem) => {
      const { scene, language, code } = contextItem.content;
      return String.raw`The following is the code of the "${scene}" component\n\n\`\`\`${language}\n${code}\n\`\`\``;
    };
  }
  provideWorkContextBackgroundStrategy() {
    return async (_ctx, _aiMessages, workContext) => {
      const document = [import_flow_resource.default];
      const sceneSet = new Set(workContext.map((item) => item.content).map((content) => content.scene));
      if (sceneSet.has("block")) {
        document.push(import_js_block.default);
        document.push(...import_js_filter.default["en-US"]);
      }
      if (sceneSet.has("detail")) {
        document.push(import_js_field.default);
      }
      if (sceneSet.has("form")) {
        document.push(import_js_item.default);
        document.push(import_js_action.default);
      }
      if (sceneSet.has("table")) {
        document.push(import_js_column.default);
        document.push(...import_js_column2.default["en-US"]);
        document.push(import_js_action.default);
      }
      return document.map((doc) => String.raw`<document name="${doc.name}">\n${doc.content}\n</document>`).join("\n");
    };
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  AICodingManager
});
