"use strict";
/*
The raw URL is the following, of course encoded as a URL:

.../raw/{share id}/{the full path in the project to file}
*/
var __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.encodePath = void 0;
var path_1 = require("path");
var base_path_1 = __importDefault(require("lib/base-path"));
function rawURL(_a) {
    var id = _a.id, path = _a.path, relativePath = _a.relativePath;
    return (0, path_1.join)(base_path_1.default, "share/raw/".concat(id, "/").concat(encodePath((0, path_1.join)(path, relativePath))));
}
exports.default = rawURL;
function encodePath(path) {
    var e_1, _a;
    var segments = path.split("/");
    var encoded = [];
    try {
        for (var segments_1 = __values(segments), segments_1_1 = segments_1.next(); !segments_1_1.done; segments_1_1 = segments_1.next()) {
            var segment = segments_1_1.value;
            encoded.push(encodeURIComponent(segment));
        }
    }
    catch (e_1_1) { e_1 = { error: e_1_1 }; }
    finally {
        try {
            if (segments_1_1 && !segments_1_1.done && (_a = segments_1.return)) _a.call(segments_1);
        }
        finally { if (e_1) throw e_1.error; }
    }
    return encoded.join("/");
}
exports.encodePath = encodePath;
//# sourceMappingURL=raw-url.js.map