"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.GapSearchContext = void 0;
/** @packageDocumentation
 * @module Curve
 */
const CurveCollection_1 = require("../CurveCollection");
const CurveProcessor_1 = require("../CurveProcessor");
// import { SumLengthsContext, GapSearchContext, CountLinearPartsSearchContext, CloneCurvesContext, TransformInPlaceContext } from "./CurveSearches";
/**
 * Algorithmic class: Accumulate maximum gap between adjacent primitives of CurveChain.
 * @internal
 */
class GapSearchContext extends CurveProcessor_1.RecursiveCurveProcessorWithStack {
    maxGap;
    constructor() {
        super();
        this.maxGap = 0.0;
    }
    static maxGap(target) {
        const context = new GapSearchContext();
        target.announceToCurveProcessor(context);
        return context.maxGap;
    }
    announceCurvePrimitive(curve, _indexInParent) {
        if (this._stack.length > 0) {
            const parent = this._stack[this._stack.length - 1];
            if (parent instanceof CurveCollection_1.CurveChain) {
                const chain = parent;
                const nextCurve = chain.cyclicCurvePrimitive(_indexInParent + 1);
                if (curve !== undefined && nextCurve !== undefined) {
                    this.maxGap = Math.max(this.maxGap, curve.endPoint().distance(nextCurve.startPoint()));
                }
            }
        }
    }
}
exports.GapSearchContext = GapSearchContext;
//# sourceMappingURL=GapSearchContext.js.map