import { LengthUnit, LengthValue, Observable, SingleArgCallback } from "@configura/web-utilities"; import { DtoFeature, DtoFeatureConf, DtoFeatureRef, DtoPartsConstrainedOption, DtoSelectedOption } from "../CatalogueAPI.js"; import { CfgProduct, _CfgProductInternal } from "../CfgProduct.js"; import { CfgFeature, _CfgFeatureInternal } from "./CfgFeature.js"; import { ProductConfigurationBubbleMode } from "./CfgOption.js"; export declare type ProductConfigurationChangeNotification = { freshRef: CfgProductConfiguration; committed: boolean; }; export declare type StretchMap = Map; /** * This class is meant to only be used through CfgProductConfiguration. It should never be * instantiated on its own. Normally the internal state of this class should never be directly * modified. CfgProductConfiguration is the class that should be used and interacted with. */ export declare class _CfgProductConfigurationInternal { readonly parentProduct: _CfgProductInternal; readonly rootProduct: _CfgProductInternal; private readonly _initialRootFeatureRefs; static _makeUninitialized(rootFeatureRefs: DtoFeatureRef[], rawFeatures: DtoFeature[], // Flat packed. All the features that can currently appear anyplace in the selection tree. parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal): _CfgProductConfigurationInternal; private constructor(); readonly key = "~"; private _rootFeatureRefs; readonly accumulatedRawFeatures: DtoFeature[]; private _features; private _stretchReferenceLengthsByMeasureParamCode; get stretchReferenceLengthsByMeasureParamCode(): StretchMap; clearStretchMeasurements(): void; readonly changeObservable: Observable; get rootFeatureRefs(): DtoFeatureRef[]; get features(): CfgFeature[]; private _notifyAllOfChange; /** Called by child to tell its parent that it has changed. */ _childHasChanged: (freshRef: CfgFeature, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise; getDtoConf: (includeExtendedData: boolean) => DtoFeatureConf[]; getApiSelection: () => DtoSelectedOption[]; getApiConstrained: () => DtoPartsConstrainedOption[]; /** * When used internally the notifications are taken care off by the caller, but if set from * outside we want notifications to bubble all the way to the root. * This method will not cause validation calls. Data is assumed to already be validated. */ setApiSelection: (selectedOptions: DtoSelectedOption[], constrOptions: readonly DtoPartsConstrainedOption[] | undefined, bubbleToRoot: boolean) => Promise; structureCompare: (other: _CfgProductConfigurationInternal, strictOrder: boolean, descriptionMatch: boolean) => boolean; /** * When used internally the notifications are taken care off by the caller, but if set from * outside we want notifications to bubble all the way to the root. */ tryMatchSelection: (other: _CfgProductConfigurationInternal, descriptionMatch: boolean | undefined, validate: boolean) => Promise; /** Only selected features. */ _getFeaturesWithCode: (code: string) => _CfgFeatureInternal[]; /** * Extends the list of loaded potentially used features. Will warn for but ignore duplicates. * Returns true if a change happened. */ addRawFeatures: (rawFeatures: DtoFeature[], warnForDuplicates: boolean) => boolean; private _hasRootFeaturesChanged; /** * True if what root Features are used is not the same as at initial load. * This means that functional selection has happened. */ get hasRootFeaturesChanged(): boolean; /** * Populates _features based on the passed @param rootFeatureRefs . * @return true if a change happened. */ populateFeatures: (rootFeatureRefs: DtoFeatureRef[]) => boolean; setStretchReferenceLength: (measureParamCode: string, referenceLength: number | undefined, unit: LengthUnit) => Promise; } export declare class CfgProductConfiguration { readonly _internal: _CfgProductConfigurationInternal; /** * This method is semi-async. It will immediately give you a reference to the created * CfgProductConfiguration, but is not properly initialized until the initDone-callback * has been called. */ static make(initSuccess: (c: CfgProductConfiguration) => void, initFail: (error: Error) => void, rootFeatureRefs: DtoFeatureRef[], rawFeatures: DtoFeature[], // Flat packed. All the features that can currently appear anyplace in the selection tree. apiSelection: DtoSelectedOption[], apiConstraints: readonly DtoPartsConstrainedOption[] | undefined, parentProduct: _CfgProductInternal, rootProduct: _CfgProductInternal): CfgProductConfiguration; /** * Makes an object wrapping the passed object. This is not a clone method, it is a method to * make a new outer reference. Like a shallow copy. * * We use this to help frameworks that are built around using equals to detect change. */ static _makeNewRefFrom(internal: _CfgProductConfigurationInternal): CfgProductConfiguration; /** * Private constructor and make-method because make new ref requires the constructor to take an * internal and we don't want those who instantiate CfgProductConfiguration to have to be aware * of the internal. */ private constructor(); isBackedBySame: (other: CfgProductConfiguration) => boolean; get parentProduct(): CfgProduct; get rootProduct(): CfgProduct; get key(): string; /** * Every (unprocessed) feature that is currently loaded for this product. This can be extended * by validation calls. What features are actually used is controlled by rootFeatureRefs and what * options are selected. */ get rawFeatures(): DtoFeature[]; /** What features are used in the root of this. This can change with new validate calls. */ get rootFeatureRefs(): DtoFeatureRef[]; /** The root features at the root of the selection tree. */ get features(): CfgFeature[]; structureCompare: (other: CfgProductConfiguration, strictOrder?: boolean, descriptionMatch?: boolean) => boolean; /** * This method will try to match the selection from another product configuration * This method does not propagate its selections. * This method will cause validation calls. */ tryMatchSelection: (other: CfgProductConfiguration, descriptionMatch?: boolean) => Promise; /** * Set how stretched a certain measure should be measureParamCode is the measure to be * stretched referenceLength is a value relative to the initial length of the measure. If the * stretch drawn up in Model Lab was from the start let's say 2.4 units from start point to end * point a reference value of 4.8 would stretch the start point to end point to double length. * This however does not stop things from extending outside start point to end point. So the * actual perceived length after stretching might have little to do with the referenceLength. * Undefined as referenceLength will clear, that is, make the stretched thing revert to its * default state. */ setStretchReferenceLength: (measureParamCode: string, referenceLength: number, unit: LengthUnit) => Promise; listenForChange: (l: SingleArgCallback) => void; stopListenForChange: (l: SingleArgCallback) => void; stopAllListenForChange: () => void; /** * Clears cached stretch measurement map. Called by the parent product when the * rawProductData has changed, which may potentially change the measurements. */ clearStretchMeasurements(): void; } //# sourceMappingURL=CfgProductConfiguration.d.ts.map