var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var FileModel_exports = {};
__export(FileModel_exports, {
  FileModel: () => FileModel
});
module.exports = __toCommonJS(FileModel_exports);
var import_server = require("@tego/server");
class FileModel extends import_server.Model {
  toJSON() {
    var _a, _b;
    const json = super.toJSON();
    const fileStorages = (_a = this.constructor["database"]) == null ? void 0 : _a["_fileStorages"];
    if (json.storageId && fileStorages && fileStorages.has(json.storageId)) {
      const storage = fileStorages.get(json.storageId);
      json["thumbnailRule"] = (_b = storage == null ? void 0 : storage.options) == null ? void 0 : _b.thumbnailRule;
      if (!json["thumbnailRule"] && (storage == null ? void 0 : storage.type) === "ali-oss") {
        json["thumbnailRule"] = "?x-oss-process=image/auto-orient,1/resize,m_fill,w_94,h_94/quality,q_90";
      }
      if ((storage == null ? void 0 : storage.type) === "local" && process.env.APP_PUBLIC_PATH) {
        json["url"] = process.env.APP_PUBLIC_PATH.replace(/\/$/g, "") + json.url;
      }
    }
    return json;
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FileModel
});
