/*!
 * Copyright (c) 2026 Vertex Software LLC. All rights reserved.
 */
import { GetCanvasRequest, } from "@vertexvis/scene-view-protos/sceneview/protos/scene_view_api_pb";
import { createMetadata, requestUnary } from "../grpc";
import { toUuid2l } from "../mappers/uuid";
import { mapGetCanvasResponseOrThrow } from "./mapper";
export class CanvasController {
    constructor(client, jwtProvider, deviceIdProvider) {
        this.client = client;
        this.jwtProvider = jwtProvider;
        this.deviceIdProvider = deviceIdProvider;
    }
    async getCanvas({ canvasId, sceneViewStateId, }) {
        if (canvasId != null && sceneViewStateId != null) {
            throw new Error('Invalid request. Only one lookup ID between `canvasId` and `sceneViewStateId` can be provided.');
        }
        const res = await requestUnary(async (handler) => {
            const deviceId = this.deviceIdProvider();
            const meta = await createMetadata(this.jwtProvider, deviceId);
            const req = new GetCanvasRequest();
            if (canvasId != null) {
                const canvasId2l = toUuid2l(canvasId);
                req.setCanvasId(canvasId2l);
            }
            else if (sceneViewStateId != null) {
                const sceneViewStateId2l = toUuid2l(sceneViewStateId);
                req.setSceneViewStateId(sceneViewStateId2l);
            }
            this.client.getCanvas(req, meta, handler);
        });
        return mapGetCanvasResponseOrThrow(res.toObject());
    }
}
//# sourceMappingURL=controller.js.map
