"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isCanonicalSlug = exports.normalizeCanonicalSlug = exports.SLUG_REJECTION_CODES = void 0;
exports.composeOrderedSlugName = composeOrderedSlugName;
exports.isOrderedPrefixCompatibleSlugName = isOrderedPrefixCompatibleSlugName;
var slug_normalization_1 = require("./slug-normalization");
Object.defineProperty(exports, "SLUG_REJECTION_CODES", { enumerable: true, get: function () { return slug_normalization_1.SLUG_REJECTION_CODES; } });
Object.defineProperty(exports, "normalizeCanonicalSlug", { enumerable: true, get: function () { return slug_normalization_1.normalizeCanonicalSlug; } });
Object.defineProperty(exports, "isCanonicalSlug", { enumerable: true, get: function () { return slug_normalization_1.isCanonicalSlug; } });
const slug_normalization_2 = require("./slug-normalization");
function composeOrderedSlugName(orderedPrefix, slug) {
    if (!(0, slug_normalization_2.isCanonicalSlug)(orderedPrefix)) {
        return rejectOrderedSlugName(orderedPrefix, slug, "non-canonical-value", "ordered-prefix", "Ordered prefixes must already be canonical slugs.");
    }
    if (!(0, slug_normalization_2.isCanonicalSlug)(slug)) {
        return rejectOrderedSlugName(orderedPrefix, slug, "non-canonical-value", "slug", "Canonical slugs are required before composing ordered directory names.");
    }
    return {
        kind: "ordered-slug-name",
        orderedPrefix,
        slug,
        orderedSlugName: `${orderedPrefix}-${slug}`
    };
}
function isOrderedPrefixCompatibleSlugName(orderedPrefix, slug) {
    return composeOrderedSlugName(orderedPrefix, slug).kind === "ordered-slug-name";
}
function rejectOrderedSlugName(orderedPrefix, slug, code, field, message) {
    return {
        kind: "ordered-slug-name-rejection",
        orderedPrefix,
        slug,
        reason: {
            code,
            field,
            message,
            details: {
                normalizedCandidate: `${orderedPrefix}-${slug}`
            }
        }
    };
}
