function _ts_decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function _ts_metadata(k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from "typeorm";
import { Note } from "./note.js";
import { User } from "./user.js";
import { UserGroup } from "./user-group.js";
import { id } from "../id.js";
export let NoteFavorite = class NoteFavorite {
    id;
    createdAt;
    userId;
    user;
    groupId;
    group;
    noteId;
    note;
};
_ts_decorate([
    PrimaryColumn(id()),
    _ts_metadata("design:type", String)
], NoteFavorite.prototype, "id", void 0);
_ts_decorate([
    Column("timestamp with time zone", {
        comment: "The created date of the NoteFavorite."
    }),
    _ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
], NoteFavorite.prototype, "createdAt", void 0);
_ts_decorate([
    Index(),
    Column(id()),
    _ts_metadata("design:type", Object)
], NoteFavorite.prototype, "userId", void 0);
_ts_decorate([
    ManyToOne((type)=>User, {
        onDelete: "CASCADE"
    }),
    JoinColumn(),
    _ts_metadata("design:type", Object)
], NoteFavorite.prototype, "user", void 0);
_ts_decorate([
    Index(),
    Column({
        ...id(),
        nullable: true
    }),
    _ts_metadata("design:type", Object)
], NoteFavorite.prototype, "groupId", void 0);
_ts_decorate([
    ManyToOne((type)=>UserGroup, {
        onDelete: "CASCADE"
    }),
    JoinColumn(),
    _ts_metadata("design:type", Object)
], NoteFavorite.prototype, "group", void 0);
_ts_decorate([
    Column(id()),
    _ts_metadata("design:type", Object)
], NoteFavorite.prototype, "noteId", void 0);
_ts_decorate([
    ManyToOne((type)=>Note, {
        onDelete: "CASCADE"
    }),
    JoinColumn(),
    _ts_metadata("design:type", Object)
], NoteFavorite.prototype, "note", void 0);
NoteFavorite = _ts_decorate([
    Entity(),
    Index([
        "userId",
        "noteId"
    ], {
        unique: true,
        where: '"groupId" IS NULL'
    }),
    Index([
        "groupId",
        "noteId"
    ], {
        unique: true,
        where: '"groupId" IS NOT NULL'
    })
], NoteFavorite);
