import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_template_CollectionTemplate_mjs__ from "../../data-source/collection-template/CollectionTemplate.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__ from "./properties/index.mjs";
function _define_property(obj, key, value) {
    if (key in obj) Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
    });
    else obj[key] = value;
    return obj;
}
class TreeCollectionTemplate extends __WEBPACK_EXTERNAL_MODULE__data_source_collection_template_CollectionTemplate_mjs__.CollectionTemplate {
    constructor(...args){
        super(...args), _define_property(this, "name", 'tree'), _define_property(this, "title", '{{t("Tree collection")}}'), _define_property(this, "order", 3), _define_property(this, "color", 'blue'), _define_property(this, "default", {
            tree: 'adjacencyList',
            fields: [
                {
                    interface: 'integer',
                    name: 'parentId',
                    type: 'bigInt',
                    isForeignKey: true,
                    uiSchema: {
                        type: 'number',
                        title: '{{t("Parent ID")}}',
                        'x-component': 'InputNumber',
                        'x-read-pretty': true
                    }
                },
                {
                    interface: 'm2o',
                    type: 'belongsTo',
                    name: 'parent',
                    foreignKey: 'parentId',
                    treeParent: true,
                    onDelete: 'CASCADE',
                    uiSchema: {
                        title: '{{t("Parent")}}',
                        'x-component': 'AssociationField',
                        'x-component-props': {
                            multiple: false,
                            fieldNames: {
                                label: 'id',
                                value: 'id'
                            }
                        }
                    }
                },
                {
                    interface: 'o2m',
                    type: 'hasMany',
                    name: 'children',
                    foreignKey: 'parentId',
                    treeChildren: true,
                    onDelete: 'CASCADE',
                    uiSchema: {
                        title: '{{t("Children")}}',
                        'x-component': 'AssociationField',
                        'x-component-props': {
                            multiple: true,
                            fieldNames: {
                                label: 'id',
                                value: 'id'
                            }
                        }
                    }
                }
            ]
        }), _define_property(this, "events", {
            beforeSubmit (values) {
                if (Array.isArray(null == values ? void 0 : values.fields)) null == values || values.fields.map((f)=>{
                    f.target = values.name;
                });
            }
        }), _define_property(this, "configurableProperties", (0, __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.getConfigurableProperties)('title', 'name', 'inherits', 'category', 'description', 'presetFields'));
    }
}
export { TreeCollectionTemplate };
