var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
import { Collection } from "@mikro-orm/core";
import { Entity, ManyToOne, OneToMany, PrimaryKey, Property, Unique } from "@mikro-orm/decorators/legacy";
let Tenant = class {
  constructor() {
    this.isActive = true;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
    this.organizations = new Collection(this);
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], Tenant.prototype, "id", 2);
__decorateClass([
  Property({ type: "text" })
], Tenant.prototype, "name", 2);
__decorateClass([
  Property({ name: "is_active", type: "boolean", default: true })
], Tenant.prototype, "isActive", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], Tenant.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], Tenant.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], Tenant.prototype, "deletedAt", 2);
__decorateClass([
  OneToMany(() => Organization, (o) => o.tenant)
], Tenant.prototype, "organizations", 2);
Tenant = __decorateClass([
  Entity({ tableName: "tenants" })
], Tenant);
let Organization = class {
  constructor() {
    this.isActive = true;
    this.parentId = null;
    this.rootId = null;
    this.treePath = null;
    this.depth = 0;
    this.ancestorIds = [];
    this.childIds = [];
    this.descendantIds = [];
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], Organization.prototype, "id", 2);
__decorateClass([
  ManyToOne(() => Tenant)
], Organization.prototype, "tenant", 2);
__decorateClass([
  Property({ type: "text" })
], Organization.prototype, "name", 2);
__decorateClass([
  Property({ type: "text", nullable: true })
], Organization.prototype, "slug", 2);
__decorateClass([
  Property({ name: "logo_url", type: "text", nullable: true })
], Organization.prototype, "logoUrl", 2);
__decorateClass([
  Property({ name: "is_active", type: "boolean", default: true })
], Organization.prototype, "isActive", 2);
__decorateClass([
  Property({ name: "parent_id", type: "uuid", nullable: true })
], Organization.prototype, "parentId", 2);
__decorateClass([
  Property({ name: "root_id", type: "uuid", nullable: true })
], Organization.prototype, "rootId", 2);
__decorateClass([
  Property({ name: "tree_path", type: "text", nullable: true })
], Organization.prototype, "treePath", 2);
__decorateClass([
  Property({ type: "int", default: 0 })
], Organization.prototype, "depth", 2);
__decorateClass([
  Property({ name: "ancestor_ids", type: "jsonb", default: [], nullable: false })
], Organization.prototype, "ancestorIds", 2);
__decorateClass([
  Property({ name: "child_ids", type: "jsonb", default: [], nullable: false })
], Organization.prototype, "childIds", 2);
__decorateClass([
  Property({ name: "descendant_ids", type: "jsonb", default: [], nullable: false })
], Organization.prototype, "descendantIds", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], Organization.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], Organization.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], Organization.prototype, "deletedAt", 2);
Organization = __decorateClass([
  Entity({ tableName: "organizations" }),
  Unique({ name: "organizations_tenant_slug_uniq", properties: ["tenant", "slug"] })
], Organization);
export {
  Organization,
  Tenant
};
//# sourceMappingURL=entities.js.map
