"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateElementGraphics = generateElementGraphics;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
const core_bentley_1 = require("@itwin/core-bentley");
const core_common_1 = require("@itwin/core-common");
const Symbols_1 = require("./internal/Symbols");
/** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.
 * @internal
 */
async function generateElementGraphics(request, iModel) {
    const result = await iModel[Symbols_1._nativeDb].generateElementGraphics(request); // ###TODO update package versions in addon
    let error;
    switch (result.status) {
        case 2 /* ElementGraphicsStatus.NoGeometry */:
        case 1 /* ElementGraphicsStatus.Canceled */:
            return undefined;
        case 0 /* ElementGraphicsStatus.Success */:
            return result.content;
        case 3 /* ElementGraphicsStatus.InvalidJson */:
            error = "Invalid JSON";
            break;
        case 4 /* ElementGraphicsStatus.UnknownMajorFormatVersion */:
            error = "Unknown major format version";
            break;
        case 5 /* ElementGraphicsStatus.ElementNotFound */:
            error = `Element Id ${request.elementId} not found`;
            break;
        case 6 /* ElementGraphicsStatus.DuplicateRequestId */:
            error = `Duplicate request Id "${request.id}"`;
            break;
    }
    (0, core_bentley_1.assert)(undefined !== error);
    throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadRequest, error);
}
//# sourceMappingURL=ElementGraphics.js.map