/**
 * DelegationPort — delegation via → operator (Claim Algebra, S7 spec).
 *
 * Implements capability narrowing (R-1 invariant: child ⊆ parent),
 * chain verification, revocation cascade, and depth limits.
 * Ed25519 signatures, max_depth=5 V0 (configurable 1..10 Enterprise).
 *
 * Spec: docs/plans/PreCarre/canonical/specs/S7.md
 */
// ─── Typed errors ─────────────────────────────────────────────────────────────
export class DelegationNotNarrowingError extends Error {
    parentId;
    childId;
    violationType;
    constructor(parentId, childId, violationType // "capability_expansion" | "constraint_removal" | "jurisdiction_expansion"
    ) {
        super(`Delegation R-1 narrowing violated (parent=${parentId}, child=${childId}): ${violationType}`);
        this.parentId = parentId;
        this.childId = childId;
        this.violationType = violationType;
        this.name = "DelegationNotNarrowingError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class DelegationExpiredError extends Error {
    claimId;
    expiresAt;
    constructor(claimId, expiresAt) {
        super(`Delegation claim expired (${claimId}): expires_at=${expiresAt}`);
        this.claimId = claimId;
        this.expiresAt = expiresAt;
        this.name = "DelegationExpiredError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class DelegationRevokedError extends Error {
    claimId;
    revokedAt;
    reason;
    constructor(claimId, revokedAt, reason) {
        super(`Delegation claim revoked (${claimId}) at ${revokedAt}${reason ? `: ${reason}` : ""}`);
        this.claimId = claimId;
        this.revokedAt = revokedAt;
        this.reason = reason;
        this.name = "DelegationRevokedError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class DelegationChainTooDeepError extends Error {
    claimId;
    depth;
    maxDepth;
    constructor(claimId, depth, maxDepth) {
        super(`Delegation chain exceeds max depth (${claimId}): depth=${depth}, max=${maxDepth}`);
        this.claimId = claimId;
        this.depth = depth;
        this.maxDepth = maxDepth;
        this.name = "DelegationChainTooDeepError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class DelegationSignatureInvalidError extends Error {
    claimId;
    reason;
    constructor(claimId, reason) {
        super(`Delegation signature invalid (${claimId}): ${reason}`);
        this.claimId = claimId;
        this.reason = reason;
        this.name = "DelegationSignatureInvalidError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class DelegationCycleDetectedError extends Error {
    claimId;
    cycleSubject;
    constructor(claimId, cycleSubject) {
        super(`Delegation cycle detected (${claimId}): subject ${cycleSubject} appears in chain`);
        this.claimId = claimId;
        this.cycleSubject = cycleSubject;
        this.name = "DelegationCycleDetectedError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class DelegationNotFoundError extends Error {
    claimId;
    constructor(claimId) {
        super(`Delegation claim not found: ${claimId}`);
        this.claimId = claimId;
        this.name = "DelegationNotFoundError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class DelegationTemporalFrameError extends Error {
    claimId;
    reason;
    constructor(claimId, reason // "not_yet_valid" | "temporal_nesting_violated"
    ) {
        super(`Delegation temporal frame error (${claimId}): ${reason}`);
        this.claimId = claimId;
        this.reason = reason;
        this.name = "DelegationTemporalFrameError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
//# sourceMappingURL=delegation.js.map