/** Current format version, major tag, increase on major and/or incompatible
 * changes (and write a converter) */
export const CurrentMajorVersion = 1;
/** Current format version, minor tag, increase on any changes. */
export const CurrentMinorVersion = 1;
/** Enum for item type IDs */
export var EItemType;
(function (EItemType) {
    EItemType[EItemType["Group"] = 0] = "Group";
    EItemType[EItemType["Text"] = 1] = "Text";
    EItemType[EItemType["Article"] = 2] = "Article";
    EItemType[EItemType["Impression"] = 3] = "Impression";
    EItemType[EItemType["Set"] = 4] = "Set";
    EItemType[EItemType["HeadData"] = 5] = "HeadData";
})(EItemType || (EItemType = {}));
/** Enumeration of calculation rules for additional prices */
export var EAddPriceRule;
(function (EAddPriceRule) {
    /** If currency is %, calculate absolute value on base price */
    EAddPriceRule[EAddPriceRule["ToBase"] = 0] = "ToBase";
    /** If currency is %, calculate absolute value on the sum of base price
     * and all additional prices so far */
    EAddPriceRule[EAddPriceRule["ToSum"] = 1] = "ToSum";
})(EAddPriceRule || (EAddPriceRule = {}));
/** Enumeration of price types used in this BOM */
export var EPriceType;
(function (EPriceType) {
    /** BOM includes no prices */
    EPriceType[EPriceType["None"] = 0] = "None";
    /** BOM includes net prices (without VAT) */
    EPriceType[EPriceType["Net"] = 1] = "Net";
    /** BOM includes gross prices (with VAT). Specify used VAT in defined field! */
    EPriceType[EPriceType["Gross"] = 2] = "Gross";
})(EPriceType || (EPriceType = {}));
/**
 * Traverses the item tree and executes the callback for every decendant as well as item of the initial array
 *
 * @param {TItems} items
 * @param {(item: TAnyItem) => void} cb
 */
export const traverse = (items, cb) => {
    for (const item of items) {
        cb(item);
        if (item.ItemType === EItemType.Article &&
            item.SubItems !== undefined) {
            traverse(item.SubItems, cb);
        }
        else if (item.ItemType === EItemType.Group ||
            item.ItemType === EItemType.Set) {
            traverse(item.Items, cb);
        }
    }
};
