import {CloneTierAction} from "./interfaces";
import {TierType} from "../tiers";
import {TreeNode} from "../TreeNode";
import { NestedTestableNodeData } from "../InMemoryTestableNode";
import {NestedBranchData, NestedTieredData} from "../MemoryBranchNode";
import {increaseNumericTestable} from "../testableHelpers";
import {TestablePartial} from "../store";
import {TieredExtraData} from "../StateBranchNode";

export class NumericTestableCloner implements CloneTierAction {
    canCloneTier(treeNode: TreeNode): boolean {
        return treeNode.getParentBranch()!.getExtraData().tierType === TierType.Numeric
    }

    // @ts-ignore
    cloneTier(nestedTestableNodeData: NestedTestableNodeData, nestedBranchData: NestedBranchData<NestedBranchData, TieredExtraData>, targetTreeNodeToClone: TreeNode) {
        increaseNumericTestable(
            nestedTestableNodeData as TestablePartial,
            // @ts-ignore
            targetTreeNodeToClone.getParentBranch()?.getBaseTestable()?.type!
        )
    }
}