import { connectAssessmentToolkitRegionScopeContext, connectAssessmentToolkitRuntimeContext, connectAssessmentToolkitShellContext, } from "../context/runtime-context-consumer.js";
const CROSS_BOUNDARY_EVENT_INIT = {
    bubbles: true,
    composed: true,
    cancelable: false,
};
/**
 * Contract helper for all toolkit/tool events that must cross custom-element boundaries.
 */
export function createCrossBoundaryEvent(name, detail, init = {}) {
    return new CustomEvent(name, {
        detail,
        ...CROSS_BOUNDARY_EVENT_INIT,
        ...init,
    });
}
/**
 * Dispatches a cross-boundary event with toolkit defaults.
 */
export function dispatchCrossBoundaryEvent(target, name, detail, init = {}) {
    return target.dispatchEvent(createCrossBoundaryEvent(name, detail, init));
}
/**
 * Shared runtime-context connection contract for tools and shells.
 * Uses retry + provider announcements so late providers are tolerated.
 */
export function connectToolRuntimeContext(host, onValue) {
    return connectAssessmentToolkitRuntimeContext(host, onValue);
}
/**
 * Shared shell-context connection contract for tools needing item/passage scope.
 */
export function connectToolShellContext(host, onValue) {
    return connectAssessmentToolkitShellContext(host, onValue);
}
/**
 * Shared region-scope context contract for tools targeting content subregions.
 */
export function connectToolRegionScopeContext(host, onValue) {
    return connectAssessmentToolkitRegionScopeContext(host, onValue);
}
/**
 * Guard utility: narrows unknown context payloads when needed by callers.
 */
export function isContextValueDefined(value) {
    return value !== null && value !== undefined;
}
//# sourceMappingURL=tool-host-contract.js.map