const mongoose = require('mongoose');

const tourSchema = new mongoose.Schema({
    name: { 
        type: String, 
        required: true,
        trim: true 
    },
    description: {
        type: String,
        trim: true
    },
    location: {
        lat: Number,
        lng: Number
    },
    createdBy: { 
        type: mongoose.Schema.Types.ObjectId, 
        ref: 'User', 
        required: true 
    },
    rootSceneId: { 
        type: mongoose.Schema.Types.ObjectId, 
        ref: 'Scene' 
    },
    privacy: {
        type: String,
        enum: ['public', 'private', 'member', 'shared'],
        default: 'private'
    },
    shareToken: String,
    shareTokenExpires: Date,
    sharedWith: [{ 
        type: mongoose.Schema.Types.ObjectId, 
        ref: 'User' 
    }],
    sharedEmails: [String],
    scenes: [{ 
        type: mongoose.Schema.Types.ObjectId, 
        ref: 'Scene' 
    }]
}, { 
    timestamps: true 
});

module.exports = mongoose.model('Tour', tourSchema);