import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types, HydratedDocument } from 'mongoose';
import moment from 'moment';
import { Workspace } from './workspace.model';

export enum subscription_plan_interval {
    // daily = 'daily',
    monthly = 'monthly',
    // quarterly = 'quarterly',
    yearly = 'yearly'
  }

export enum subscription_plan_type {
  FREE_TIRE = 'FREE_TIRE',
  BASE_PLAN = 'BASE_PLAN',
  SILVER_PLAN = 'SILVER_PLAN',
  GOLD_PLAN = 'GOLD_PLAN'
}

@Schema()
export class SubscriptionPlan extends Document {

    @Prop({ type: String, enum: subscription_plan_type })
    plan_type: string;

    @Prop({ type: String, unique: true, required: true })
    plan_id: string;

    @Prop({ type: String, default: "" })
    name: string = ""

    @Prop({ type: String, default: null })
    description: string = null

    @Prop({ type: Number, default: 0 })
    amount: number = 0

    @Prop({ type: String, enum: subscription_plan_interval, default: subscription_plan_interval.monthly })
    interval: string = null;

    @Prop({ type: Number, default: 1 })
    interval_count: number;

    @Prop({ type: [String] })
    benefits?: string[];

    @Prop({ type: Number, default: 0 })
    chat_token_limit: number;

    @Prop({ type: Number, default: 0 })
    call_limit: number;

    @Prop({ type: Number, default: 0 })
    knowledgebase_limit: number;

    @Prop({ type: Number, default: 0 })
    agent_limit: number;

    @Prop({ type: Number, default: 0 })
    workspace_member_limit: number;

    @Prop({ type: String, default: null })
    currency: string = null

    @Prop({ type: Boolean, default: false })
    is_deleted: boolean = false

    @Prop({ default: moment().utc().valueOf() })
    created_at: number = moment().utc().valueOf();

    @Prop({ default: moment().utc().valueOf() })
    updated_at: number = moment().utc().valueOf();
}

export const SubscriptionPlanSchema = SchemaFactory.createForClass(SubscriptionPlan);