/**
 * Readiness derivation for the section runtime engine (M7).
 *
 * Canonical home of `createReadinessDetail` and `resolveReadinessPhase`.
 * As of M7 PR 7 the previous duplicates in
 * `packages/section-player/src/components/shared/section-player-readiness.ts`
 * have been deleted; section-player now consumes these helpers via
 * `@pie-players/pie-assessment-toolkit/runtime/internal`.
 *
 * Type duplication note: the public DOM-event detail aliases
 * (`SectionPlayerReadinessChangeDetail` /
 * `SectionPlayerReadinessPhase`) still live in section-player's
 * `contracts/public-events.ts` because that file is part of section-
 * player's published custom-element contract. The toolkit core defines
 * `EngineReadinessPhase` independently so it has zero section-player
 * imports. The two definitions must stay structurally identical;
 * that invariant is covered by the readiness assertions in this
 * package's tests, which mirror the section-player suite.
 */
export function resolveReadinessPhase(signals) {
    if (signals.runtimeError)
        return "error";
    if (signals.allLoadingComplete)
        return "ready";
    if (signals.interactionReady)
        return "interaction-ready";
    if (signals.sectionReady)
        return "loading";
    return "bootstrapping";
}
export function createReadinessDetail(args) {
    // Final ready must always be gated by section lifecycle and complete loading.
    const finalReady = args.signals.sectionReady && args.signals.allLoadingComplete;
    const interactionReady = args.mode === "strict" ? finalReady : args.signals.interactionReady;
    const phase = resolveReadinessPhase({
        ...args.signals,
        allLoadingComplete: finalReady,
        interactionReady,
    });
    return {
        phase,
        interactionReady,
        allLoadingComplete: finalReady,
        reason: args.reason,
    };
}
//# sourceMappingURL=engine-readiness.js.map