/**
 * Measurement Tools Registrations
 *
 * Registers ruler and protractor tools for on-screen measurements.
 *
 * Maps to QTI 3.0 standard access features:
 * - ruler (assessment tool)
 * - protractor (assessment tool)
 */
import { hasMathContent } from "../../services/tool-context.js";
import { createToolElement, } from "../tool-tag-map.js";
import { applyOverlaySurface, createScopedVisibilityBinding, syncButtonAndOverlayVisibility, } from "./toolbar-registration-helpers.js";
/**
 * Ruler tool registration
 *
 * Provides an on-screen ruler for measuring lengths.
 * Typically appears on geometry or measurement problems.
 */
export const rulerToolRegistration = {
    toolId: "ruler",
    name: "Ruler",
    description: "On-screen ruler for measurements",
    icon: "ruler",
    // Ruler typically appears at section/item/element level
    supportedLevels: ["section", "item", "element"],
    // PNP support IDs
    // Maps to QTI 3.0 standard feature: ruler
    pnpSupportIds: [
        "ruler", // QTI 3.0 standard (assessment.ruler)
        "measurement", // Common variant
    ],
    /**
     * Pass 2: Ruler is relevant when math content is present
     */
    isVisibleInContext(context) {
        return hasMathContent(context);
    },
    renderToolbar(context, toolbarContext) {
        const visibility = createScopedVisibilityBinding(this.toolId, toolbarContext);
        const button = {
            toolId: this.toolId,
            label: this.name,
            icon: typeof this.icon === "function" ? this.icon(context) : this.icon,
            disabled: false,
            ariaLabel: "Open ruler tool",
            tooltip: "Ruler",
            onClick: () => toolbarContext.toggleTool(this.toolId),
            active: visibility.isActive(),
        };
        const componentOverrides = toolbarContext.componentOverrides ?? {};
        const overlay = createToolElement(this.toolId, context, toolbarContext, componentOverrides);
        overlay.setAttribute("tool-id", visibility.fullToolId);
        applyOverlaySurface(overlay, "frameless");
        return {
            toolId: this.toolId,
            button,
            elements: [{ element: overlay, mount: "after-buttons" }],
            sync: () => {
                syncButtonAndOverlayVisibility({
                    button,
                    overlay,
                    isActive: visibility.isActive,
                });
                if (toolbarContext.toolkitCoordinator) {
                    overlay.toolkitCoordinator = toolbarContext.toolkitCoordinator;
                }
            },
            subscribeActive: visibility.subscribeActive,
        };
    },
};
/**
 * Protractor tool registration
 *
 * Provides an on-screen protractor for measuring angles.
 * Typically appears on geometry problems.
 */
export const protractorToolRegistration = {
    toolId: "protractor",
    name: "Protractor",
    description: "On-screen protractor for angle measurements",
    icon: "protractor",
    // Protractor typically appears at section/item/element level
    supportedLevels: ["section", "item", "element"],
    // PNP support IDs
    // Maps to QTI 3.0 standard feature: protractor
    pnpSupportIds: [
        "protractor", // QTI 3.0 standard (assessment.protractor)
        "angleMeasurement", // Common variant
    ],
    /**
     * Pass 2: Protractor is relevant when math content is present
     */
    isVisibleInContext(context) {
        return hasMathContent(context);
    },
    renderToolbar(context, toolbarContext) {
        const visibility = createScopedVisibilityBinding(this.toolId, toolbarContext);
        const button = {
            toolId: this.toolId,
            label: this.name,
            icon: typeof this.icon === "function" ? this.icon(context) : this.icon,
            disabled: false,
            ariaLabel: "Open protractor tool",
            tooltip: "Protractor",
            onClick: () => toolbarContext.toggleTool(this.toolId),
            active: visibility.isActive(),
        };
        const componentOverrides = toolbarContext.componentOverrides ?? {};
        const overlay = createToolElement(this.toolId, context, toolbarContext, componentOverrides);
        overlay.setAttribute("tool-id", visibility.fullToolId);
        applyOverlaySurface(overlay, "frameless");
        return {
            toolId: this.toolId,
            button,
            elements: [{ element: overlay, mount: "after-buttons" }],
            sync: () => {
                syncButtonAndOverlayVisibility({
                    button,
                    overlay,
                    isActive: visibility.isActive,
                });
                if (toolbarContext.toolkitCoordinator) {
                    overlay.toolkitCoordinator = toolbarContext.toolkitCoordinator;
                }
            },
            subscribeActive: visibility.subscribeActive,
        };
    },
};
//# sourceMappingURL=measurement-tools.js.map