/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Widget
 */
function isGenerated(value) {
    return value.startsWith("Widget-");
}
/** Proxy will return `stableId` if target [[WidgetDef]] id is auto-generated.
 * @internal
 */
export function createStableWidgetDef(widgetDef, stableId) {
    return new Proxy(widgetDef, {
        get(target, name, receiver) {
            const idName = "id";
            const value = Reflect.get(target, name, receiver);
            if (name === idName && isGenerated(value)) {
                return stableId;
            }
            return value;
        },
    });
}
//# sourceMappingURL=StableWidgetDef.js.map