/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { ElementGeometry, TextStyleSettings } from "@itwin/core-common";
import { Range2d } from "@itwin/core-geometry";
import { layoutTextBlock, TextStyleResolver } from "../core-backend";
export function computeTextRangeAsStringLength(args) {
    const range = new Range2d(0, 0, args.chars.length, args.textHeight);
    return { layout: range, justification: range };
}
export function doLayout(textBlock, args) {
    const textStyleResolver = new TextStyleResolver({
        textBlock,
        textStyleId: args?.textStyleId ?? "",
        iModel: {},
        findTextStyle: args?.findTextStyle ?? (() => TextStyleSettings.defaults)
    });
    const layout = layoutTextBlock({
        textBlock,
        iModel: {},
        textStyleResolver,
        findFontId: args?.findFontId ?? (() => 0),
        computeTextRange: computeTextRangeAsStringLength,
    });
    return layout;
}
// Extending this because the ElementGeometry.Builder.entries attribute is hard to parse
export class MockBuilder extends ElementGeometry.Builder {
    params = [];
    geometries = [];
    textStrings = [];
    appendGeometryParamsChange(params) {
        this.params.push(params.clone());
        return super.appendGeometryParamsChange(params);
    }
    appendGeometryQuery(geometry) {
        this.geometries.push(geometry);
        return super.appendGeometryQuery(geometry);
    }
    appendTextString(text) {
        this.textStrings.push(text);
        return super.appendTextString(text);
    }
}
//# sourceMappingURL=AnnotationTestUtils.js.map