const mongoose = require('mongoose');

const sceneSchema = new mongoose.Schema({
    name: {
        type: String,
        required: true,
        trim: true
    },
    scene_url: {
        type: String
    },
    assetId: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'Asset',
        required: true
    },
    gps: {
        lat: { type: Number, required: true },
        lng: { type: Number, required: true }
    },
    createdBy: {
        type: mongoose.Schema.Types.ObjectId,
        ref: 'User',
        required: true
    },
    privacy: {
        type: String,
        enum: ['public', 'private', 'shared', 'member'],
        default: 'private'
    },
    shareToken: {
        type: String,
        unique: true,
        sparse: true
    },
    sharedWith: [{
        type: mongoose.Schema.Types.ObjectId,
        ref: 'User'
    }],
}, {
    timestamps: true
});

module.exports = mongoose.model('Scene', sceneSchema);
