var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { RegisterClass } from '@memberjunction/global';
import { BaseEntity } from '@memberjunction/core';
import { MJEntityEntity } from '../generated/entity_subclasses.js';
/**
 * Extended MJEntityEntity class that provides automatic handling of Description field updates.
 * When a user manually updates the Description, it automatically sets AutoUpdateDescription to 1
 * to prevent CodeGen from overwriting the custom description.
 */
let MJEntityEntityExtended = class MJEntityEntityExtended extends MJEntityEntity {
    /**
     * Override Set to handle Description field changes
     */
    Set(FieldName, Value) {
        // Handle Description field changes
        if (FieldName.toLowerCase() === 'description' && !this.NewRecord) {
            const currentDescription = this.GetFieldByName('Description')?.Value;
            const autoUpdateDescription = this.GetFieldByName('AutoUpdateDescription')?.Value;
            // If description is changing and AutoUpdateDescription is not already true
            if (Value !== currentDescription && autoUpdateDescription !== true) {
                console.warn(`Setting AutoUpdateDescription to true for Entity "${this.Name}" because Description is being manually updated. This will prevent CodeGen from overwriting this description.`);
                // Set AutoUpdateDescription to true first
                this.AutoUpdateDescription = true;
            }
        }
        // Call parent Set method
        super.Set(FieldName, Value);
    }
};
MJEntityEntityExtended = __decorate([
    RegisterClass(BaseEntity, 'MJ: Entities')
], MJEntityEntityExtended);
export { MJEntityEntityExtended };
//# sourceMappingURL=MJEntityEntityExtended.js.map