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 { OptionalProps } from "@mikro-orm/core";
import { Entity, Index, PrimaryKey, Property, Unique } from "@mikro-orm/decorators/legacy";
OptionalProps;
let Message = class {
  constructor() {
    this.type = "default";
    this.bodyFormat = "text";
    this.priority = "normal";
    this.status = "draft";
    this.isDraft = true;
    this.sendViaEmail = false;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], Message.prototype, "id", 2);
__decorateClass([
  Property({ name: "type", type: "text" })
], Message.prototype, "type", 2);
__decorateClass([
  Property({ name: "thread_id", type: "uuid", nullable: true })
], Message.prototype, "threadId", 2);
__decorateClass([
  Property({ name: "parent_message_id", type: "uuid", nullable: true })
], Message.prototype, "parentMessageId", 2);
__decorateClass([
  Property({ name: "sender_user_id", type: "uuid" })
], Message.prototype, "senderUserId", 2);
__decorateClass([
  Property({ name: "subject", type: "text" })
], Message.prototype, "subject", 2);
__decorateClass([
  Property({ name: "body", type: "text" })
], Message.prototype, "body", 2);
__decorateClass([
  Property({ name: "body_format", type: "text" })
], Message.prototype, "bodyFormat", 2);
__decorateClass([
  Property({ name: "priority", type: "text" })
], Message.prototype, "priority", 2);
__decorateClass([
  Property({ name: "status", type: "text" })
], Message.prototype, "status", 2);
__decorateClass([
  Property({ name: "is_draft", type: "boolean" })
], Message.prototype, "isDraft", 2);
__decorateClass([
  Property({ name: "sent_at", type: Date, nullable: true })
], Message.prototype, "sentAt", 2);
__decorateClass([
  Property({ name: "action_data", type: "json", nullable: true })
], Message.prototype, "actionData", 2);
__decorateClass([
  Property({ name: "action_result", type: "json", nullable: true })
], Message.prototype, "actionResult", 2);
__decorateClass([
  Property({ name: "action_taken", type: "text", nullable: true })
], Message.prototype, "actionTaken", 2);
__decorateClass([
  Property({ name: "action_taken_by_user_id", type: "uuid", nullable: true })
], Message.prototype, "actionTakenByUserId", 2);
__decorateClass([
  Property({ name: "action_taken_at", type: Date, nullable: true })
], Message.prototype, "actionTakenAt", 2);
__decorateClass([
  Property({ name: "send_via_email", type: "boolean", default: false })
], Message.prototype, "sendViaEmail", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], Message.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], Message.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], Message.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], Message.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], Message.prototype, "deletedAt", 2);
__decorateClass([
  Property({ name: "visibility", type: "text", nullable: true })
], Message.prototype, "visibility", 2);
__decorateClass([
  Property({ name: "source_entity_type", type: "text", nullable: true })
], Message.prototype, "sourceEntityType", 2);
__decorateClass([
  Property({ name: "source_entity_id", type: "uuid", nullable: true })
], Message.prototype, "sourceEntityId", 2);
__decorateClass([
  Property({ name: "external_email", type: "text", nullable: true })
], Message.prototype, "externalEmail", 2);
__decorateClass([
  Property({ name: "external_email_hash", type: "text", nullable: true })
], Message.prototype, "externalEmailHash", 2);
__decorateClass([
  Property({ name: "idempotency_key", type: "text", nullable: true })
], Message.prototype, "idempotencyKey", 2);
__decorateClass([
  Property({ name: "external_name", type: "text", nullable: true })
], Message.prototype, "externalName", 2);
__decorateClass([
  Property({ name: "external_email_sent_at", type: Date, nullable: true })
], Message.prototype, "externalEmailSentAt", 2);
__decorateClass([
  Property({ name: "external_email_failed_at", type: Date, nullable: true })
], Message.prototype, "externalEmailFailedAt", 2);
__decorateClass([
  Property({ name: "external_email_error", type: "text", nullable: true })
], Message.prototype, "externalEmailError", 2);
Message = __decorateClass([
  Entity({ tableName: "messages" }),
  Index({ name: "messages_sender_idx", properties: ["senderUserId", "sentAt"] }),
  Index({ name: "messages_thread_idx", properties: ["threadId"] }),
  Index({ name: "messages_type_idx", properties: ["type", "tenantId"] }),
  Index({ name: "messages_tenant_idx", properties: ["tenantId", "organizationId"] }),
  Index({ name: "messages_external_email_hash_idx", properties: ["externalEmailHash"] }),
  Index({
    name: "messages_idempotency_key_uq",
    expression: 'create unique index "messages_idempotency_key_uq" on "messages" ("tenant_id", "idempotency_key") where "idempotency_key" is not null'
  })
], Message);
OptionalProps;
let MessageRecipient = class {
  constructor() {
    this.recipientType = "to";
    this.status = "unread";
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], MessageRecipient.prototype, "id", 2);
__decorateClass([
  Property({ name: "message_id", type: "uuid" })
], MessageRecipient.prototype, "messageId", 2);
__decorateClass([
  Property({ name: "recipient_user_id", type: "uuid" })
], MessageRecipient.prototype, "recipientUserId", 2);
__decorateClass([
  Property({ name: "recipient_type", type: "text" })
], MessageRecipient.prototype, "recipientType", 2);
__decorateClass([
  Property({ name: "status", type: "text" })
], MessageRecipient.prototype, "status", 2);
__decorateClass([
  Property({ name: "read_at", type: Date, nullable: true })
], MessageRecipient.prototype, "readAt", 2);
__decorateClass([
  Property({ name: "archived_at", type: Date, nullable: true })
], MessageRecipient.prototype, "archivedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], MessageRecipient.prototype, "deletedAt", 2);
__decorateClass([
  Property({ name: "email_sent_at", type: Date, nullable: true })
], MessageRecipient.prototype, "emailSentAt", 2);
__decorateClass([
  Property({ name: "email_delivered_at", type: Date, nullable: true })
], MessageRecipient.prototype, "emailDeliveredAt", 2);
__decorateClass([
  Property({ name: "email_opened_at", type: Date, nullable: true })
], MessageRecipient.prototype, "emailOpenedAt", 2);
__decorateClass([
  Property({ name: "email_failed_at", type: Date, nullable: true })
], MessageRecipient.prototype, "emailFailedAt", 2);
__decorateClass([
  Property({ name: "email_error", type: "text", nullable: true })
], MessageRecipient.prototype, "emailError", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], MessageRecipient.prototype, "createdAt", 2);
MessageRecipient = __decorateClass([
  Entity({ tableName: "message_recipients" }),
  Index({ name: "message_recipients_user_idx", properties: ["recipientUserId", "status"] }),
  Index({ name: "message_recipients_message_idx", properties: ["messageId"] }),
  Unique({ name: "message_recipients_message_user_unique", properties: ["messageId", "recipientUserId"] })
], MessageRecipient);
OptionalProps;
let MessageObject = class {
  constructor() {
    this.actionRequired = false;
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], MessageObject.prototype, "id", 2);
__decorateClass([
  Property({ name: "message_id", type: "uuid" })
], MessageObject.prototype, "messageId", 2);
__decorateClass([
  Property({ name: "entity_module", type: "text" })
], MessageObject.prototype, "entityModule", 2);
__decorateClass([
  Property({ name: "entity_type", type: "text" })
], MessageObject.prototype, "entityType", 2);
__decorateClass([
  Property({ name: "entity_id", type: "uuid" })
], MessageObject.prototype, "entityId", 2);
__decorateClass([
  Property({ name: "action_required", type: "boolean" })
], MessageObject.prototype, "actionRequired", 2);
__decorateClass([
  Property({ name: "action_type", type: "text", nullable: true })
], MessageObject.prototype, "actionType", 2);
__decorateClass([
  Property({ name: "action_label", type: "text", nullable: true })
], MessageObject.prototype, "actionLabel", 2);
__decorateClass([
  Property({ name: "entity_snapshot", type: "json", nullable: true })
], MessageObject.prototype, "entitySnapshot", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], MessageObject.prototype, "createdAt", 2);
MessageObject = __decorateClass([
  Entity({ tableName: "message_objects" }),
  Index({ name: "message_objects_message_idx", properties: ["messageId"] }),
  Index({ name: "message_objects_entity_idx", properties: ["entityType", "entityId"] })
], MessageObject);
OptionalProps;
let MessageAccessToken = class {
  constructor() {
    this.useCount = 0;
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], MessageAccessToken.prototype, "id", 2);
__decorateClass([
  Property({ name: "message_id", type: "uuid" })
], MessageAccessToken.prototype, "messageId", 2);
__decorateClass([
  Property({ name: "recipient_user_id", type: "uuid" })
], MessageAccessToken.prototype, "recipientUserId", 2);
__decorateClass([
  Property({ name: "token", type: "text", unique: true })
], MessageAccessToken.prototype, "token", 2);
__decorateClass([
  Property({ name: "expires_at", type: Date })
], MessageAccessToken.prototype, "expiresAt", 2);
__decorateClass([
  Property({ name: "used_at", type: Date, nullable: true })
], MessageAccessToken.prototype, "usedAt", 2);
__decorateClass([
  Property({ name: "use_count", type: "int", default: 0 })
], MessageAccessToken.prototype, "useCount", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], MessageAccessToken.prototype, "createdAt", 2);
MessageAccessToken = __decorateClass([
  Entity({ tableName: "message_access_tokens" }),
  Index({ name: "message_access_tokens_token_idx", properties: ["token"] }),
  Index({ name: "message_access_tokens_message_idx", properties: ["messageId"] })
], MessageAccessToken);
OptionalProps;
let MessageConfirmation = class {
  constructor() {
    this.confirmed = true;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], MessageConfirmation.prototype, "id", 2);
__decorateClass([
  Property({ name: "message_id", type: "uuid" })
], MessageConfirmation.prototype, "messageId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], MessageConfirmation.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid", nullable: true })
], MessageConfirmation.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "confirmed", type: "boolean" })
], MessageConfirmation.prototype, "confirmed", 2);
__decorateClass([
  Property({ name: "confirmed_by_user_id", type: "uuid", nullable: true })
], MessageConfirmation.prototype, "confirmedByUserId", 2);
__decorateClass([
  Property({ name: "confirmed_at", type: Date, nullable: true })
], MessageConfirmation.prototype, "confirmedAt", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], MessageConfirmation.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], MessageConfirmation.prototype, "updatedAt", 2);
MessageConfirmation = __decorateClass([
  Entity({ tableName: "message_confirmations" }),
  Index({ name: "message_confirmations_message_idx", properties: ["messageId"] }),
  Index({ name: "message_confirmations_scope_idx", properties: ["tenantId", "organizationId"] }),
  Unique({ name: "message_confirmations_message_unique", properties: ["messageId"] })
], MessageConfirmation);
var entities_default = [Message, MessageRecipient, MessageObject, MessageAccessToken, MessageConfirmation];
export {
  Message,
  MessageAccessToken,
  MessageConfirmation,
  MessageObject,
  MessageRecipient,
  entities_default as default
};
//# sourceMappingURL=entities.js.map
