/**
 * Start Repository Deployment Use Case
 *
 * Starts a local dev server rooted at a repository's top-level directory.
 *
 * Business Rules:
 * - repositoryPath must be an absolute path
 * - The directory must exist on disk
 * - Rejects the currently running Shep instance's own repository
 *
 * Returns the deployment status after the start call (Booting).
 */
var __decorate = (this && this.__decorate) || function (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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { isAbsolute } from 'node:path';
import { injectable, inject } from 'tsyringe';
import { DeploymentState } from '../../../domain/generated/output.js';
let StartRepositoryDeploymentUseCase = class StartRepositoryDeploymentUseCase {
    deploymentService;
    fileSystem;
    shepInstance;
    constructor(deploymentService, fileSystem, shepInstance) {
        this.deploymentService = deploymentService;
        this.fileSystem = fileSystem;
        this.shepInstance = shepInstance;
    }
    async execute(repositoryPath) {
        if (!repositoryPath || !isAbsolute(repositoryPath)) {
            throw new Error('repositoryPath must be an absolute path');
        }
        if (!this.fileSystem.pathExists(repositoryPath)) {
            throw new Error(`Directory does not exist: ${repositoryPath}`);
        }
        if (this.shepInstance.isSameInstance(repositoryPath)) {
            throw new Error('Cannot start a dev server for the repository Shep is running from');
        }
        this.deploymentService.start(repositoryPath, repositoryPath, 'repository');
        return { state: DeploymentState.Booting, url: null };
    }
};
StartRepositoryDeploymentUseCase = __decorate([
    injectable(),
    __param(0, inject('IDeploymentService')),
    __param(1, inject('IFileSystemService')),
    __param(2, inject('IShepInstanceService')),
    __metadata("design:paramtypes", [Object, Object, Object])
], StartRepositoryDeploymentUseCase);
export { StartRepositoryDeploymentUseCase };
