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, OptionalProps } from "@mikro-orm/core";
import { Entity, Index, ManyToOne, OneToMany, OneToOne, PrimaryKey, Property, Unique } from "@mikro-orm/decorators/legacy";
OptionalProps;
let CustomerEntity = class {
  constructor() {
    this.isActive = true;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
    this.addresses = new Collection(this);
    this.activities = new Collection(this);
    this.comments = new Collection(this);
    this.tagAssignments = new Collection(this);
    this.todoLinks = new Collection(this);
    this.interactions = new Collection(this);
    this.dealPersonLinks = new Collection(this);
    this.dealCompanyLinks = new Collection(this);
    this.personCompanyLinks = new Collection(this);
    this.linkedPeople = new Collection(this);
    this.companyMembers = new Collection(this);
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerEntity.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerEntity.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerEntity.prototype, "tenantId", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerEntity.prototype, "kind", 2);
__decorateClass([
  Property({ name: "display_name", type: "text" })
], CustomerEntity.prototype, "displayName", 2);
__decorateClass([
  Property({ type: "text", nullable: true })
], CustomerEntity.prototype, "description", 2);
__decorateClass([
  Property({ name: "owner_user_id", type: "uuid", nullable: true })
], CustomerEntity.prototype, "ownerUserId", 2);
__decorateClass([
  Property({ name: "primary_email", type: "text", nullable: true })
], CustomerEntity.prototype, "primaryEmail", 2);
__decorateClass([
  Property({ name: "primary_phone", type: "text", nullable: true })
], CustomerEntity.prototype, "primaryPhone", 2);
__decorateClass([
  Property({ name: "status", type: "text", nullable: true })
], CustomerEntity.prototype, "status", 2);
__decorateClass([
  Property({ name: "lifecycle_stage", type: "text", nullable: true })
], CustomerEntity.prototype, "lifecycleStage", 2);
__decorateClass([
  Property({ name: "source", type: "text", nullable: true })
], CustomerEntity.prototype, "source", 2);
__decorateClass([
  Property({ name: "temperature", type: "text", nullable: true })
], CustomerEntity.prototype, "temperature", 2);
__decorateClass([
  Property({ name: "renewal_quarter", type: "text", nullable: true })
], CustomerEntity.prototype, "renewalQuarter", 2);
__decorateClass([
  Property({ name: "next_interaction_at", type: Date, nullable: true })
], CustomerEntity.prototype, "nextInteractionAt", 2);
__decorateClass([
  Property({ name: "next_interaction_name", type: "text", nullable: true })
], CustomerEntity.prototype, "nextInteractionName", 2);
__decorateClass([
  Property({ name: "next_interaction_ref_id", type: "text", nullable: true })
], CustomerEntity.prototype, "nextInteractionRefId", 2);
__decorateClass([
  Property({ name: "next_interaction_icon", type: "text", nullable: true })
], CustomerEntity.prototype, "nextInteractionIcon", 2);
__decorateClass([
  Property({ name: "next_interaction_color", type: "text", nullable: true })
], CustomerEntity.prototype, "nextInteractionColor", 2);
__decorateClass([
  Property({ name: "is_active", type: "boolean", default: true })
], CustomerEntity.prototype, "isActive", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerEntity.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerEntity.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomerEntity.prototype, "deletedAt", 2);
__decorateClass([
  OneToOne(() => CustomerPersonProfile, (profile) => profile.entity, { nullable: true, mappedBy: "entity" })
], CustomerEntity.prototype, "personProfile", 2);
__decorateClass([
  OneToOne(() => CustomerCompanyProfile, (profile) => profile.entity, { nullable: true, mappedBy: "entity" })
], CustomerEntity.prototype, "companyProfile", 2);
__decorateClass([
  OneToMany(() => CustomerAddress, (address) => address.entity)
], CustomerEntity.prototype, "addresses", 2);
__decorateClass([
  OneToMany(() => CustomerActivity, (activity) => activity.entity)
], CustomerEntity.prototype, "activities", 2);
__decorateClass([
  OneToMany(() => CustomerComment, (comment) => comment.entity)
], CustomerEntity.prototype, "comments", 2);
__decorateClass([
  OneToMany(() => CustomerTagAssignment, (assignment) => assignment.entity)
], CustomerEntity.prototype, "tagAssignments", 2);
__decorateClass([
  OneToMany(() => CustomerTodoLink, (link) => link.entity)
], CustomerEntity.prototype, "todoLinks", 2);
__decorateClass([
  OneToMany(() => CustomerInteraction, (interaction) => interaction.entity)
], CustomerEntity.prototype, "interactions", 2);
__decorateClass([
  OneToMany(() => CustomerDealPersonLink, (link) => link.person)
], CustomerEntity.prototype, "dealPersonLinks", 2);
__decorateClass([
  OneToMany(() => CustomerDealCompanyLink, (link) => link.company)
], CustomerEntity.prototype, "dealCompanyLinks", 2);
__decorateClass([
  OneToMany(() => CustomerPersonCompanyLink, (link) => link.person)
], CustomerEntity.prototype, "personCompanyLinks", 2);
__decorateClass([
  OneToMany(() => CustomerPersonCompanyLink, (link) => link.company)
], CustomerEntity.prototype, "linkedPeople", 2);
__decorateClass([
  OneToMany(() => CustomerPersonProfile, (person) => person.company)
], CustomerEntity.prototype, "companyMembers", 2);
CustomerEntity = __decorateClass([
  Entity({ tableName: "customer_entities" }),
  Index({ name: "customer_entities_org_tenant_kind_idx", properties: ["organizationId", "tenantId", "kind"] }),
  Index({
    name: "idx_ce_tenant_org_person_id",
    expression: `create index "idx_ce_tenant_org_person_id" on "customer_entities" ("tenant_id", "organization_id", "id") where deleted_at is null and kind = 'person'`
  }),
  Index({
    name: "idx_ce_tenant_org_company_id",
    expression: `create index "idx_ce_tenant_org_company_id" on "customer_entities" ("tenant_id", "organization_id", "id") where deleted_at is null and kind = 'company'`
  }),
  Index({
    name: "idx_ce_tenant_company_id",
    expression: `create index "idx_ce_tenant_company_id" on "customer_entities" ("tenant_id", "id") where deleted_at is null and kind = 'company'`
  }),
  Index({
    name: "idx_ce_tenant_person_id",
    expression: `create index "idx_ce_tenant_person_id" on "customer_entities" ("tenant_id", "id") where deleted_at is null and kind = 'person'`
  })
], CustomerEntity);
OptionalProps;
let CustomerPersonProfile = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerPersonProfile.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerPersonProfile.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerPersonProfile.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "first_name", type: "text", nullable: true })
], CustomerPersonProfile.prototype, "firstName", 2);
__decorateClass([
  Property({ name: "last_name", type: "text", nullable: true })
], CustomerPersonProfile.prototype, "lastName", 2);
__decorateClass([
  Property({ name: "preferred_name", type: "text", nullable: true })
], CustomerPersonProfile.prototype, "preferredName", 2);
__decorateClass([
  Property({ name: "job_title", type: "text", nullable: true })
], CustomerPersonProfile.prototype, "jobTitle", 2);
__decorateClass([
  Property({ name: "department", type: "text", nullable: true })
], CustomerPersonProfile.prototype, "department", 2);
__decorateClass([
  Property({ name: "seniority", type: "text", nullable: true })
], CustomerPersonProfile.prototype, "seniority", 2);
__decorateClass([
  Property({ name: "timezone", type: "text", nullable: true })
], CustomerPersonProfile.prototype, "timezone", 2);
__decorateClass([
  Property({ name: "linked_in_url", type: "text", nullable: true })
], CustomerPersonProfile.prototype, "linkedInUrl", 2);
__decorateClass([
  Property({ name: "twitter_url", type: "text", nullable: true })
], CustomerPersonProfile.prototype, "twitterUrl", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerPersonProfile.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerPersonProfile.prototype, "updatedAt", 2);
__decorateClass([
  OneToOne(() => CustomerEntity, (entity) => entity.personProfile, {
    fieldName: "entity_id",
    owner: true
  })
], CustomerPersonProfile.prototype, "entity", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, {
    fieldName: "company_entity_id",
    nullable: true
  })
], CustomerPersonProfile.prototype, "company", 2);
CustomerPersonProfile = __decorateClass([
  Entity({ tableName: "customer_people" }),
  Index({ name: "customer_people_org_tenant_idx", properties: ["organizationId", "tenantId"] }),
  Index({
    name: "idx_customer_people_entity_id",
    expression: `create index "idx_customer_people_entity_id" on "customer_people" ("entity_id")`
  })
], CustomerPersonProfile);
OptionalProps;
let CustomerPersonCompanyLink = class {
  constructor() {
    this.isPrimary = false;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerPersonCompanyLink.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerPersonCompanyLink.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerPersonCompanyLink.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "is_primary", type: "boolean", default: false })
], CustomerPersonCompanyLink.prototype, "isPrimary", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerPersonCompanyLink.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerPersonCompanyLink.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomerPersonCompanyLink.prototype, "deletedAt", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "person_entity_id" })
], CustomerPersonCompanyLink.prototype, "person", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "company_entity_id" })
], CustomerPersonCompanyLink.prototype, "company", 2);
CustomerPersonCompanyLink = __decorateClass([
  Entity({ tableName: "customer_person_company_links" }),
  Index({ name: "customer_person_company_links_person_idx", properties: ["person"] }),
  Index({ name: "customer_person_company_links_company_idx", properties: ["company"] }),
  Index({ name: "customer_person_company_links_scope_idx", properties: ["organizationId", "tenantId"] }),
  Index({
    name: "customer_person_company_links_active_unique",
    expression: `create unique index "customer_person_company_links_active_unique" on "customer_person_company_links" ("person_entity_id", "company_entity_id") where "deleted_at" is null`
  })
], CustomerPersonCompanyLink);
OptionalProps;
let CustomerCompanyProfile = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerCompanyProfile.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerCompanyProfile.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerCompanyProfile.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "legal_name", type: "text", nullable: true })
], CustomerCompanyProfile.prototype, "legalName", 2);
__decorateClass([
  Property({ name: "brand_name", type: "text", nullable: true })
], CustomerCompanyProfile.prototype, "brandName", 2);
__decorateClass([
  Property({ name: "domain", type: "text", nullable: true })
], CustomerCompanyProfile.prototype, "domain", 2);
__decorateClass([
  Property({ name: "website_url", type: "text", nullable: true })
], CustomerCompanyProfile.prototype, "websiteUrl", 2);
__decorateClass([
  Property({ name: "industry", type: "text", nullable: true })
], CustomerCompanyProfile.prototype, "industry", 2);
__decorateClass([
  Property({ name: "size_bucket", type: "text", nullable: true })
], CustomerCompanyProfile.prototype, "sizeBucket", 2);
__decorateClass([
  Property({ name: "annual_revenue", type: "numeric", precision: 16, scale: 2, nullable: true })
], CustomerCompanyProfile.prototype, "annualRevenue", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerCompanyProfile.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerCompanyProfile.prototype, "updatedAt", 2);
__decorateClass([
  OneToOne(() => CustomerEntity, (entity) => entity.companyProfile, {
    fieldName: "entity_id",
    owner: true
  })
], CustomerCompanyProfile.prototype, "entity", 2);
CustomerCompanyProfile = __decorateClass([
  Entity({ tableName: "customer_companies" }),
  Index({ name: "customer_companies_org_tenant_idx", properties: ["organizationId", "tenantId"] }),
  Index({
    name: "idx_customer_companies_entity_id",
    expression: `create index "idx_customer_companies_entity_id" on "customer_companies" ("entity_id")`
  })
], CustomerCompanyProfile);
OptionalProps;
let CustomerDeal = class {
  constructor() {
    this.status = "open";
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
    this.people = new Collection(this);
    this.companies = new Collection(this);
    this.activities = new Collection(this);
    this.comments = new Collection(this);
    this.stageTransitions = new Collection(this);
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerDeal.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerDeal.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerDeal.prototype, "tenantId", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerDeal.prototype, "title", 2);
__decorateClass([
  Property({ type: "text", nullable: true })
], CustomerDeal.prototype, "description", 2);
__decorateClass([
  Property({ name: "status", type: "text", default: "open" })
], CustomerDeal.prototype, "status", 2);
__decorateClass([
  Property({ name: "pipeline_stage", type: "text", nullable: true })
], CustomerDeal.prototype, "pipelineStage", 2);
__decorateClass([
  Property({ name: "pipeline_id", type: "uuid", nullable: true })
], CustomerDeal.prototype, "pipelineId", 2);
__decorateClass([
  Property({ name: "pipeline_stage_id", type: "uuid", nullable: true })
], CustomerDeal.prototype, "pipelineStageId", 2);
__decorateClass([
  Property({ name: "value_amount", type: "numeric", precision: 14, scale: 2, nullable: true })
], CustomerDeal.prototype, "valueAmount", 2);
__decorateClass([
  Property({ name: "value_currency", type: "text", nullable: true })
], CustomerDeal.prototype, "valueCurrency", 2);
__decorateClass([
  Property({ name: "probability", type: "int", nullable: true })
], CustomerDeal.prototype, "probability", 2);
__decorateClass([
  Property({ name: "expected_close_at", type: Date, nullable: true })
], CustomerDeal.prototype, "expectedCloseAt", 2);
__decorateClass([
  Property({ name: "owner_user_id", type: "uuid", nullable: true })
], CustomerDeal.prototype, "ownerUserId", 2);
__decorateClass([
  Property({ name: "source", type: "text", nullable: true })
], CustomerDeal.prototype, "source", 2);
__decorateClass([
  Property({ name: "closure_outcome", type: "text", nullable: true })
], CustomerDeal.prototype, "closureOutcome", 2);
__decorateClass([
  Property({ name: "loss_reason_id", type: "uuid", nullable: true })
], CustomerDeal.prototype, "lossReasonId", 2);
__decorateClass([
  Property({ name: "loss_notes", type: "text", nullable: true })
], CustomerDeal.prototype, "lossNotes", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerDeal.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerDeal.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomerDeal.prototype, "deletedAt", 2);
__decorateClass([
  OneToMany(() => CustomerDealPersonLink, (link) => link.deal)
], CustomerDeal.prototype, "people", 2);
__decorateClass([
  OneToMany(() => CustomerDealCompanyLink, (link) => link.deal)
], CustomerDeal.prototype, "companies", 2);
__decorateClass([
  OneToMany(() => CustomerActivity, (activity) => activity.deal)
], CustomerDeal.prototype, "activities", 2);
__decorateClass([
  OneToMany(() => CustomerComment, (comment) => comment.deal)
], CustomerDeal.prototype, "comments", 2);
__decorateClass([
  OneToMany(() => CustomerDealStageTransition, (transition) => transition.deal)
], CustomerDeal.prototype, "stageTransitions", 2);
CustomerDeal = __decorateClass([
  Entity({ tableName: "customer_deals" }),
  Index({ name: "customer_deals_org_tenant_idx", properties: ["organizationId", "tenantId"] }),
  Index({
    name: "customer_deals_closure_stats_idx",
    properties: ["organizationId", "tenantId", "closureOutcome", "updatedAt"]
  })
], CustomerDeal);
OptionalProps;
let CustomerDealStageTransition = class {
  constructor() {
    this.transitionedAt = /* @__PURE__ */ new Date();
    this.isActive = true;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerDealStageTransition.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerDealStageTransition.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerDealStageTransition.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "pipeline_id", type: "uuid" })
], CustomerDealStageTransition.prototype, "pipelineId", 2);
__decorateClass([
  Property({ name: "stage_id", type: "uuid" })
], CustomerDealStageTransition.prototype, "stageId", 2);
__decorateClass([
  Property({ name: "stage_label", type: "text" })
], CustomerDealStageTransition.prototype, "stageLabel", 2);
__decorateClass([
  Property({ name: "stage_order", type: "int" })
], CustomerDealStageTransition.prototype, "stageOrder", 2);
__decorateClass([
  Property({ name: "transitioned_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerDealStageTransition.prototype, "transitionedAt", 2);
__decorateClass([
  Property({ name: "transitioned_by_user_id", type: "uuid", nullable: true })
], CustomerDealStageTransition.prototype, "transitionedByUserId", 2);
__decorateClass([
  Property({ name: "is_active", type: "boolean", default: true })
], CustomerDealStageTransition.prototype, "isActive", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerDealStageTransition.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerDealStageTransition.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomerDealStageTransition.prototype, "deletedAt", 2);
__decorateClass([
  ManyToOne(() => CustomerDeal, { fieldName: "deal_id" })
], CustomerDealStageTransition.prototype, "deal", 2);
CustomerDealStageTransition = __decorateClass([
  Entity({ tableName: "customer_deal_stage_transitions" }),
  Index({ name: "customer_deal_stage_transitions_deal_idx", properties: ["deal"] }),
  Index({ name: "customer_deal_stage_transitions_org_tenant_idx", properties: ["organizationId", "tenantId"] }),
  Unique({ name: "customer_deal_stage_transitions_deal_stage_uq", properties: ["deal", "stageId"] })
], CustomerDealStageTransition);
OptionalProps;
let CustomerDealPersonLink = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerDealPersonLink.prototype, "id", 2);
__decorateClass([
  Property({ name: "role", type: "text", nullable: true })
], CustomerDealPersonLink.prototype, "participantRole", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerDealPersonLink.prototype, "createdAt", 2);
__decorateClass([
  ManyToOne(() => CustomerDeal, { fieldName: "deal_id" })
], CustomerDealPersonLink.prototype, "deal", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "person_entity_id" })
], CustomerDealPersonLink.prototype, "person", 2);
CustomerDealPersonLink = __decorateClass([
  Entity({ tableName: "customer_deal_people" }),
  Index({ name: "customer_deal_people_deal_idx", properties: ["deal"] }),
  Index({ name: "customer_deal_people_person_idx", properties: ["person"] }),
  Unique({ name: "customer_deal_people_unique", properties: ["deal", "person"] })
], CustomerDealPersonLink);
OptionalProps;
let CustomerDealCompanyLink = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerDealCompanyLink.prototype, "id", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerDealCompanyLink.prototype, "createdAt", 2);
__decorateClass([
  ManyToOne(() => CustomerDeal, { fieldName: "deal_id" })
], CustomerDealCompanyLink.prototype, "deal", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "company_entity_id" })
], CustomerDealCompanyLink.prototype, "company", 2);
CustomerDealCompanyLink = __decorateClass([
  Entity({ tableName: "customer_deal_companies" }),
  Index({ name: "customer_deal_companies_deal_idx", properties: ["deal"] }),
  Index({ name: "customer_deal_companies_company_idx", properties: ["company"] }),
  Unique({ name: "customer_deal_companies_unique", properties: ["deal", "company"] })
], CustomerDealCompanyLink);
OptionalProps;
let CustomerActivity = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerActivity.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerActivity.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerActivity.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "activity_type", type: "text" })
], CustomerActivity.prototype, "activityType", 2);
__decorateClass([
  Property({ name: "subject", type: "text", nullable: true })
], CustomerActivity.prototype, "subject", 2);
__decorateClass([
  Property({ name: "body", type: "text", nullable: true })
], CustomerActivity.prototype, "body", 2);
__decorateClass([
  Property({ name: "occurred_at", type: Date, nullable: true })
], CustomerActivity.prototype, "occurredAt", 2);
__decorateClass([
  Property({ name: "author_user_id", type: "uuid", nullable: true })
], CustomerActivity.prototype, "authorUserId", 2);
__decorateClass([
  Property({ name: "appearance_icon", type: "text", nullable: true })
], CustomerActivity.prototype, "appearanceIcon", 2);
__decorateClass([
  Property({ name: "appearance_color", type: "text", nullable: true })
], CustomerActivity.prototype, "appearanceColor", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerActivity.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerActivity.prototype, "updatedAt", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "entity_id" })
], CustomerActivity.prototype, "entity", 2);
__decorateClass([
  ManyToOne(() => CustomerDeal, { fieldName: "deal_id", nullable: true })
], CustomerActivity.prototype, "deal", 2);
CustomerActivity = __decorateClass([
  Entity({ tableName: "customer_activities" }),
  Index({ name: "customer_activities_org_tenant_idx", properties: ["organizationId", "tenantId"] }),
  Index({ name: "customer_activities_entity_idx", properties: ["entity"] }),
  Index({ name: "customer_activities_entity_occurred_created_idx", properties: ["entity", "occurredAt", "createdAt"] })
], CustomerActivity);
OptionalProps;
let CustomerInteraction = class {
  constructor() {
    this.status = "planned";
    this.pinned = false;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerInteraction.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerInteraction.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerInteraction.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "interaction_type", type: "text" })
], CustomerInteraction.prototype, "interactionType", 2);
__decorateClass([
  Property({ name: "title", type: "text", nullable: true })
], CustomerInteraction.prototype, "title", 2);
__decorateClass([
  Property({ name: "body", type: "text", nullable: true })
], CustomerInteraction.prototype, "body", 2);
__decorateClass([
  Property({ name: "external_message_id", type: "uuid", nullable: true })
], CustomerInteraction.prototype, "externalMessageId", 2);
__decorateClass([
  Property({ name: "channel_provider_key", type: "text", nullable: true })
], CustomerInteraction.prototype, "channelProviderKey", 2);
__decorateClass([
  Property({ name: "status", type: "text", default: "planned" })
], CustomerInteraction.prototype, "status", 2);
__decorateClass([
  Property({ name: "scheduled_at", type: Date, nullable: true })
], CustomerInteraction.prototype, "scheduledAt", 2);
__decorateClass([
  Property({ name: "occurred_at", type: Date, nullable: true })
], CustomerInteraction.prototype, "occurredAt", 2);
__decorateClass([
  Property({ name: "priority", type: "int", nullable: true })
], CustomerInteraction.prototype, "priority", 2);
__decorateClass([
  Property({ name: "author_user_id", type: "uuid", nullable: true })
], CustomerInteraction.prototype, "authorUserId", 2);
__decorateClass([
  Property({ name: "owner_user_id", type: "uuid", nullable: true })
], CustomerInteraction.prototype, "ownerUserId", 2);
__decorateClass([
  Property({ name: "appearance_icon", type: "text", nullable: true })
], CustomerInteraction.prototype, "appearanceIcon", 2);
__decorateClass([
  Property({ name: "appearance_color", type: "text", nullable: true })
], CustomerInteraction.prototype, "appearanceColor", 2);
__decorateClass([
  Property({ name: "source", type: "text", nullable: true })
], CustomerInteraction.prototype, "source", 2);
__decorateClass([
  Property({ name: "deal_id", type: "uuid", nullable: true })
], CustomerInteraction.prototype, "dealId", 2);
__decorateClass([
  Property({ name: "duration_minutes", type: "int", nullable: true })
], CustomerInteraction.prototype, "durationMinutes", 2);
__decorateClass([
  Property({ name: "location", type: "text", nullable: true })
], CustomerInteraction.prototype, "location", 2);
__decorateClass([
  Property({ name: "all_day", type: "boolean", nullable: true })
], CustomerInteraction.prototype, "allDay", 2);
__decorateClass([
  Property({ name: "recurrence_rule", type: "text", nullable: true })
], CustomerInteraction.prototype, "recurrenceRule", 2);
__decorateClass([
  Property({ name: "recurrence_end", type: Date, nullable: true })
], CustomerInteraction.prototype, "recurrenceEnd", 2);
__decorateClass([
  Property({ name: "participants", type: "jsonb", nullable: true })
], CustomerInteraction.prototype, "participants", 2);
__decorateClass([
  Property({ name: "reminder_minutes", type: "int", nullable: true })
], CustomerInteraction.prototype, "reminderMinutes", 2);
__decorateClass([
  Property({ name: "visibility", type: "text", nullable: true })
], CustomerInteraction.prototype, "visibility", 2);
__decorateClass([
  Property({ name: "linked_entities", type: "jsonb", nullable: true })
], CustomerInteraction.prototype, "linkedEntities", 2);
__decorateClass([
  Property({ name: "guest_permissions", type: "jsonb", nullable: true })
], CustomerInteraction.prototype, "guestPermissions", 2);
__decorateClass([
  Property({ name: "pinned", type: "boolean", default: false })
], CustomerInteraction.prototype, "pinned", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerInteraction.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onCreate: () => /* @__PURE__ */ new Date(), onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerInteraction.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomerInteraction.prototype, "deletedAt", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "entity_id" })
], CustomerInteraction.prototype, "entity", 2);
CustomerInteraction = __decorateClass([
  Entity({ tableName: "customer_interactions" }),
  Index({
    name: "customer_interactions_entity_status_scheduled_idx",
    properties: ["entity", "status", "scheduledAt", "createdAt"]
  }),
  Index({
    name: "customer_interactions_org_tenant_status_idx",
    properties: ["organizationId", "tenantId", "status", "scheduledAt"]
  }),
  Index({
    name: "customer_interactions_type_idx",
    properties: ["tenantId", "organizationId", "interactionType"]
  }),
  Index({
    name: "customer_interactions_external_msg_idx",
    expression: `create index "customer_interactions_external_msg_idx" on "customer_interactions" ("external_message_id") where "external_message_id" is not null`
  }),
  Index({
    name: "customer_interactions_email_dedupe_uq",
    expression: `create unique index "customer_interactions_email_dedupe_uq" on "customer_interactions" ("entity_id", "external_message_id") where "external_message_id" is not null and "deleted_at" is null`
  }),
  Index({
    name: "customer_interactions_email_visibility_idx",
    expression: `create index "customer_interactions_email_visibility_idx" on "customer_interactions" ("entity_id", "interaction_type", "visibility", "author_user_id") where "interaction_type" = 'email' and "deleted_at" is null`
  })
], CustomerInteraction);
OptionalProps;
let CustomerComment = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerComment.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerComment.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerComment.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "body", type: "text" })
], CustomerComment.prototype, "body", 2);
__decorateClass([
  Property({ name: "author_user_id", type: "uuid", nullable: true })
], CustomerComment.prototype, "authorUserId", 2);
__decorateClass([
  Property({ name: "appearance_icon", type: "text", nullable: true })
], CustomerComment.prototype, "appearanceIcon", 2);
__decorateClass([
  Property({ name: "appearance_color", type: "text", nullable: true })
], CustomerComment.prototype, "appearanceColor", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerComment.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerComment.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomerComment.prototype, "deletedAt", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "entity_id" })
], CustomerComment.prototype, "entity", 2);
__decorateClass([
  ManyToOne(() => CustomerDeal, { fieldName: "deal_id", nullable: true })
], CustomerComment.prototype, "deal", 2);
CustomerComment = __decorateClass([
  Entity({ tableName: "customer_comments" }),
  Index({ name: "customer_comments_entity_idx", properties: ["entity"] }),
  Index({ name: "customer_comments_entity_created_idx", properties: ["entity", "createdAt"] })
], CustomerComment);
OptionalProps;
let CustomerAddress = class {
  constructor() {
    this.isPrimary = false;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerAddress.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerAddress.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerAddress.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "name", type: "text", nullable: true })
], CustomerAddress.prototype, "name", 2);
__decorateClass([
  Property({ name: "purpose", type: "text", nullable: true })
], CustomerAddress.prototype, "purpose", 2);
__decorateClass([
  Property({ name: "company_name", type: "text", nullable: true })
], CustomerAddress.prototype, "companyName", 2);
__decorateClass([
  Property({ name: "address_line1", type: "text" })
], CustomerAddress.prototype, "addressLine1", 2);
__decorateClass([
  Property({ name: "address_line2", type: "text", nullable: true })
], CustomerAddress.prototype, "addressLine2", 2);
__decorateClass([
  Property({ name: "city", type: "text", nullable: true })
], CustomerAddress.prototype, "city", 2);
__decorateClass([
  Property({ name: "region", type: "text", nullable: true })
], CustomerAddress.prototype, "region", 2);
__decorateClass([
  Property({ name: "postal_code", type: "text", nullable: true })
], CustomerAddress.prototype, "postalCode", 2);
__decorateClass([
  Property({ name: "country", type: "text", nullable: true })
], CustomerAddress.prototype, "country", 2);
__decorateClass([
  Property({ name: "building_number", type: "text", nullable: true })
], CustomerAddress.prototype, "buildingNumber", 2);
__decorateClass([
  Property({ name: "flat_number", type: "text", nullable: true })
], CustomerAddress.prototype, "flatNumber", 2);
__decorateClass([
  Property({ name: "latitude", type: "float", nullable: true })
], CustomerAddress.prototype, "latitude", 2);
__decorateClass([
  Property({ name: "longitude", type: "float", nullable: true })
], CustomerAddress.prototype, "longitude", 2);
__decorateClass([
  Property({ name: "is_primary", type: "boolean", default: false })
], CustomerAddress.prototype, "isPrimary", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerAddress.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerAddress.prototype, "updatedAt", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "entity_id" })
], CustomerAddress.prototype, "entity", 2);
CustomerAddress = __decorateClass([
  Entity({ tableName: "customer_addresses" }),
  Index({ name: "customer_addresses_entity_idx", properties: ["entity"] })
], CustomerAddress);
OptionalProps;
let CustomerSettings = class {
  constructor() {
    this.addressFormat = "line_first";
    this.stuckThresholdDays = 14;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerSettings.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerSettings.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerSettings.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "address_format", type: "text", default: "line_first" })
], CustomerSettings.prototype, "addressFormat", 2);
__decorateClass([
  Property({ name: "stuck_threshold_days", type: "int", default: 14 })
], CustomerSettings.prototype, "stuckThresholdDays", 2);
__decorateClass([
  Property({ name: "dictionary_sort_modes", type: "jsonb", nullable: true })
], CustomerSettings.prototype, "dictionarySortModes", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerSettings.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerSettings.prototype, "updatedAt", 2);
CustomerSettings = __decorateClass([
  Entity({ tableName: "customer_settings" }),
  Unique({ name: "customer_settings_scope_unique", properties: ["organizationId", "tenantId"] })
], CustomerSettings);
OptionalProps;
let CustomerTag = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
    this.assignments = new Collection(this);
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerTag.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerTag.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerTag.prototype, "tenantId", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerTag.prototype, "slug", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerTag.prototype, "label", 2);
__decorateClass([
  Property({ name: "color", type: "text", nullable: true })
], CustomerTag.prototype, "color", 2);
__decorateClass([
  Property({ name: "description", type: "text", nullable: true })
], CustomerTag.prototype, "description", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerTag.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerTag.prototype, "updatedAt", 2);
__decorateClass([
  OneToMany(() => CustomerTagAssignment, (assignment) => assignment.tag)
], CustomerTag.prototype, "assignments", 2);
CustomerTag = __decorateClass([
  Entity({ tableName: "customer_tags" }),
  Index({ name: "customer_tags_org_tenant_idx", properties: ["organizationId", "tenantId"] }),
  Unique({ name: "customer_tags_org_slug_unique", properties: ["organizationId", "tenantId", "slug"] })
], CustomerTag);
OptionalProps;
let CustomerTagAssignment = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerTagAssignment.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerTagAssignment.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerTagAssignment.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerTagAssignment.prototype, "createdAt", 2);
__decorateClass([
  ManyToOne(() => CustomerTag, { fieldName: "tag_id" })
], CustomerTagAssignment.prototype, "tag", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "entity_id" })
], CustomerTagAssignment.prototype, "entity", 2);
CustomerTagAssignment = __decorateClass([
  Entity({ tableName: "customer_tag_assignments" }),
  Index({ name: "customer_tag_assignments_entity_idx", properties: ["entity"] }),
  Unique({ name: "customer_tag_assignments_unique", properties: ["tag", "entity"] })
], CustomerTagAssignment);
OptionalProps;
let CustomerDictionaryEntry = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerDictionaryEntry.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerDictionaryEntry.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerDictionaryEntry.prototype, "tenantId", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerDictionaryEntry.prototype, "kind", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerDictionaryEntry.prototype, "value", 2);
__decorateClass([
  Property({ name: "normalized_value", type: "text" })
], CustomerDictionaryEntry.prototype, "normalizedValue", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerDictionaryEntry.prototype, "label", 2);
__decorateClass([
  Property({ type: "text", nullable: true })
], CustomerDictionaryEntry.prototype, "color", 2);
__decorateClass([
  Property({ type: "text", nullable: true })
], CustomerDictionaryEntry.prototype, "icon", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerDictionaryEntry.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerDictionaryEntry.prototype, "updatedAt", 2);
CustomerDictionaryEntry = __decorateClass([
  Entity({ tableName: "customer_dictionary_entries" }),
  Index({ name: "customer_dictionary_entries_scope_idx", properties: ["organizationId", "tenantId", "kind"] }),
  Unique({ name: "customer_dictionary_entries_unique", properties: ["organizationId", "tenantId", "kind", "normalizedValue"] })
], CustomerDictionaryEntry);
OptionalProps;
let CustomerPipeline = class {
  constructor() {
    this.isDefault = false;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerPipeline.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerPipeline.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerPipeline.prototype, "tenantId", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerPipeline.prototype, "name", 2);
__decorateClass([
  Property({ name: "is_default", type: "boolean", default: false })
], CustomerPipeline.prototype, "isDefault", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerPipeline.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerPipeline.prototype, "updatedAt", 2);
CustomerPipeline = __decorateClass([
  Entity({ tableName: "customer_pipelines" }),
  Index({ name: "customer_pipelines_org_tenant_idx", properties: ["organizationId", "tenantId"] })
], CustomerPipeline);
OptionalProps;
let CustomerPipelineStage = class {
  constructor() {
    this.order = 0;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerPipelineStage.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerPipelineStage.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerPipelineStage.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "pipeline_id", type: "uuid" })
], CustomerPipelineStage.prototype, "pipelineId", 2);
__decorateClass([
  Property({ name: "name", type: "text" })
], CustomerPipelineStage.prototype, "label", 2);
__decorateClass([
  Property({ name: "position", type: "int", default: 0 })
], CustomerPipelineStage.prototype, "order", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerPipelineStage.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerPipelineStage.prototype, "updatedAt", 2);
CustomerPipelineStage = __decorateClass([
  Entity({ tableName: "customer_pipeline_stages" }),
  Index({ name: "customer_pipeline_stages_pipeline_position_idx", properties: ["pipelineId", "order"] }),
  Index({ name: "customer_pipeline_stages_org_tenant_idx", properties: ["organizationId", "tenantId"] })
], CustomerPipelineStage);
OptionalProps;
let CustomerTodoLink = class {
  constructor() {
    this.todoSource = "customers:interaction";
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerTodoLink.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerTodoLink.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerTodoLink.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "todo_id", type: "uuid" })
], CustomerTodoLink.prototype, "todoId", 2);
__decorateClass([
  Property({ name: "todo_source", type: "text", default: "customers:interaction" })
], CustomerTodoLink.prototype, "todoSource", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerTodoLink.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "created_by_user_id", type: "uuid", nullable: true })
], CustomerTodoLink.prototype, "createdByUserId", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "entity_id" })
], CustomerTodoLink.prototype, "entity", 2);
CustomerTodoLink = __decorateClass([
  Entity({ tableName: "customer_todo_links" }),
  Index({ name: "customer_todo_links_entity_idx", properties: ["entity"] }),
  Index({ name: "customer_todo_links_entity_created_idx", properties: ["entity", "createdAt"] }),
  Unique({ name: "customer_todo_links_unique", properties: ["entity", "todoId", "todoSource"] })
], CustomerTodoLink);
OptionalProps;
let CustomerEntityRole = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerEntityRole.prototype, "id", 2);
__decorateClass([
  Property({ name: "entity_type", type: "text" })
], CustomerEntityRole.prototype, "entityType", 2);
__decorateClass([
  Property({ name: "entity_id", type: "uuid" })
], CustomerEntityRole.prototype, "entityId", 2);
__decorateClass([
  Property({ name: "user_id", type: "uuid" })
], CustomerEntityRole.prototype, "userId", 2);
__decorateClass([
  Property({ name: "role_type", type: "text" })
], CustomerEntityRole.prototype, "roleType", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerEntityRole.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerEntityRole.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerEntityRole.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onCreate: () => /* @__PURE__ */ new Date(), onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerEntityRole.prototype, "updatedAt", 2);
__decorateClass([
  Property({ name: "deleted_at", type: Date, nullable: true })
], CustomerEntityRole.prototype, "deletedAt", 2);
CustomerEntityRole = __decorateClass([
  Entity({ tableName: "customer_entity_roles" }),
  Index({ name: "customer_entity_roles_entity_idx", properties: ["entityType", "entityId"] }),
  Index({ name: "customer_entity_roles_scope_idx", properties: ["organizationId", "tenantId"] }),
  Index({
    name: "customer_entity_roles_active_unique",
    expression: 'create unique index "customer_entity_roles_active_unique" on "customer_entity_roles" ("entity_type", "entity_id", "role_type") where "deleted_at" is null'
  })
], CustomerEntityRole);
OptionalProps;
let CustomerDictionaryKindSetting = class {
  constructor() {
    this.selectionMode = "single";
    this.visibleInTags = true;
    this.sortOrder = 0;
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerDictionaryKindSetting.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerDictionaryKindSetting.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerDictionaryKindSetting.prototype, "tenantId", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerDictionaryKindSetting.prototype, "kind", 2);
__decorateClass([
  Property({ name: "selection_mode", type: "text", default: "single" })
], CustomerDictionaryKindSetting.prototype, "selectionMode", 2);
__decorateClass([
  Property({ name: "visible_in_tags", type: "boolean", default: true })
], CustomerDictionaryKindSetting.prototype, "visibleInTags", 2);
__decorateClass([
  Property({ name: "sort_order", type: "int", default: 0 })
], CustomerDictionaryKindSetting.prototype, "sortOrder", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerDictionaryKindSetting.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerDictionaryKindSetting.prototype, "updatedAt", 2);
CustomerDictionaryKindSetting = __decorateClass([
  Entity({ tableName: "customer_dictionary_kind_settings" }),
  Index({ name: "customer_dict_kind_settings_scope_idx", properties: ["organizationId", "tenantId"] }),
  Unique({ name: "customer_dict_kind_settings_unique", properties: ["organizationId", "tenantId", "kind"] })
], CustomerDictionaryKindSetting);
OptionalProps;
let CustomerLabel = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerLabel.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerLabel.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerLabel.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "user_id", type: "uuid" })
], CustomerLabel.prototype, "userId", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerLabel.prototype, "slug", 2);
__decorateClass([
  Property({ type: "text" })
], CustomerLabel.prototype, "label", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerLabel.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerLabel.prototype, "updatedAt", 2);
CustomerLabel = __decorateClass([
  Entity({ tableName: "customer_labels" }),
  Index({ name: "customer_labels_scope_idx", properties: ["organizationId", "tenantId", "userId"] }),
  Unique({ name: "customer_labels_unique", properties: ["userId", "tenantId", "organizationId", "slug"] })
], CustomerLabel);
OptionalProps;
let CustomerLabelAssignment = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerLabelAssignment.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerLabelAssignment.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerLabelAssignment.prototype, "tenantId", 2);
__decorateClass([
  Property({ name: "user_id", type: "uuid" })
], CustomerLabelAssignment.prototype, "userId", 2);
__decorateClass([
  ManyToOne(() => CustomerLabel, { fieldName: "label_id" })
], CustomerLabelAssignment.prototype, "label", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "entity_id" })
], CustomerLabelAssignment.prototype, "entity", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerLabelAssignment.prototype, "createdAt", 2);
CustomerLabelAssignment = __decorateClass([
  Entity({ tableName: "customer_label_assignments" }),
  Index({ name: "customer_label_assignments_entity_idx", properties: ["entity"] }),
  Unique({ name: "customer_label_assignments_unique", properties: ["label", "entity"] })
], CustomerLabelAssignment);
OptionalProps;
let CustomerCompanyBilling = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
    this.updatedAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerCompanyBilling.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerCompanyBilling.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerCompanyBilling.prototype, "tenantId", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "entity_id" })
], CustomerCompanyBilling.prototype, "entity", 2);
__decorateClass([
  Property({ name: "bank_name", type: "text", nullable: true })
], CustomerCompanyBilling.prototype, "bankName", 2);
__decorateClass([
  Property({ name: "bank_account_masked", type: "text", nullable: true })
], CustomerCompanyBilling.prototype, "bankAccountMasked", 2);
__decorateClass([
  Property({ name: "payment_terms", type: "text", nullable: true })
], CustomerCompanyBilling.prototype, "paymentTerms", 2);
__decorateClass([
  Property({ name: "preferred_currency", type: "text", nullable: true })
], CustomerCompanyBilling.prototype, "preferredCurrency", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerCompanyBilling.prototype, "createdAt", 2);
__decorateClass([
  Property({ name: "updated_at", type: Date, onCreate: () => /* @__PURE__ */ new Date(), onUpdate: () => /* @__PURE__ */ new Date() })
], CustomerCompanyBilling.prototype, "updatedAt", 2);
CustomerCompanyBilling = __decorateClass([
  Entity({ tableName: "customer_company_billing" }),
  Index({ name: "customer_company_billing_scope_idx", properties: ["organizationId", "tenantId"] }),
  Unique({ name: "customer_company_billing_entity_unique", properties: ["entity"] })
], CustomerCompanyBilling);
OptionalProps;
let CustomerPersonCompanyRole = class {
  constructor() {
    this.createdAt = /* @__PURE__ */ new Date();
  }
};
__decorateClass([
  PrimaryKey({ type: "uuid", defaultRaw: "gen_random_uuid()" })
], CustomerPersonCompanyRole.prototype, "id", 2);
__decorateClass([
  Property({ name: "organization_id", type: "uuid" })
], CustomerPersonCompanyRole.prototype, "organizationId", 2);
__decorateClass([
  Property({ name: "tenant_id", type: "uuid" })
], CustomerPersonCompanyRole.prototype, "tenantId", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "person_entity_id" })
], CustomerPersonCompanyRole.prototype, "personEntity", 2);
__decorateClass([
  ManyToOne(() => CustomerEntity, { fieldName: "company_entity_id" })
], CustomerPersonCompanyRole.prototype, "companyEntity", 2);
__decorateClass([
  Property({ name: "role_value", type: "text" })
], CustomerPersonCompanyRole.prototype, "roleValue", 2);
__decorateClass([
  Property({ name: "created_at", type: Date, onCreate: () => /* @__PURE__ */ new Date() })
], CustomerPersonCompanyRole.prototype, "createdAt", 2);
CustomerPersonCompanyRole = __decorateClass([
  Entity({ tableName: "customer_person_company_roles" }),
  Index({ name: "customer_pcr_scope_idx", properties: ["organizationId", "tenantId"] }),
  Index({ name: "customer_pcr_person_company_idx", properties: ["personEntity", "companyEntity"] }),
  Unique({ name: "customer_pcr_unique", properties: ["personEntity", "companyEntity", "roleValue"] })
], CustomerPersonCompanyRole);
export {
  CustomerActivity,
  CustomerAddress,
  CustomerComment,
  CustomerCompanyBilling,
  CustomerCompanyProfile,
  CustomerDeal,
  CustomerDealCompanyLink,
  CustomerDealPersonLink,
  CustomerDealStageTransition,
  CustomerDictionaryEntry,
  CustomerDictionaryKindSetting,
  CustomerEntity,
  CustomerEntityRole,
  CustomerInteraction,
  CustomerLabel,
  CustomerLabelAssignment,
  CustomerPersonCompanyLink,
  CustomerPersonCompanyRole,
  CustomerPersonProfile,
  CustomerPipeline,
  CustomerPipelineStage,
  CustomerSettings,
  CustomerTag,
  CustomerTagAssignment,
  CustomerTodoLink
};
//# sourceMappingURL=entities.js.map
