"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");
const url_1 = require("url");
class FilePath {
    get fileUrl() {
        return (0, url_1.pathToFileURL)(this.filePath).toString();
    }
    constructor(filePath) {
        if (filePath.startsWith("file://")) {
            filePath = (0, url_1.fileURLToPath)(filePath);
        }
        this.filePath = filePath;
        const { dir, name, base, ext } = path.parse(filePath);
        this.dir = dir;
        this.name = base;
        this.baseName = name;
        this.ext = ext;
        this.webPath = `/${filePath.replaceAll("\\", "/").replace(":/", "/")}`;
    }
    relativeTo(root) {
        const r = path.relative(new FilePath(root.dir).webPath, this.webPath).replaceAll("\\", "/");
        return "./" + r;
    }
    toString() {
        return this.filePath;
    }
    changeExtension(ext) {
        return path.join(this.dir, this.baseName + ext);
    }
}
exports.default = FilePath;
//# sourceMappingURL=FilePath.js.map