"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    SubTableFieldInterface: ()=>SubTableFieldInterface
});
const schema_namespaceObject = require("@tachybase/schema");
const CollectionFieldInterface_js_namespaceObject = require("../../data-source/collection-field-interface/CollectionFieldInterface.js");
const index_js_namespaceObject = require("./properties/index.js");
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 SubTableFieldInterface extends CollectionFieldInterface_js_namespaceObject.CollectionFieldInterface {
    schemaInitialize(schema, param) {
        let { field, readPretty } = param;
        const association = "".concat(field.collectionName, ".").concat(field.name);
        schema['type'] = 'void';
        schema['x-component'] = 'TableField';
        schema['properties'] = {
            block: {
                type: 'void',
                'x-decorator': 'TableFieldProvider',
                'x-acl-action': "".concat(field.target, ":list"),
                'x-decorator-props': {
                    collection: field.target,
                    association: association,
                    resource: association,
                    action: 'list',
                    params: {
                        paginate: false
                    },
                    showIndex: true,
                    dragSort: false
                },
                properties: {
                    actions: {
                        type: 'void',
                        'x-initializer': 'subTable:configureActions',
                        'x-component': 'TableField.ActionBar',
                        'x-component-props': {}
                    },
                    [field.name]: {
                        type: 'array',
                        'x-initializer': 'table:configureColumns',
                        'x-component': 'TableV2',
                        'x-use-component-props': 'useTableFieldProps',
                        'x-component-props': {
                            rowSelection: {
                                type: 'checkbox'
                            }
                        }
                    }
                }
            }
        };
    }
    constructor(...args){
        super(...args), _define_property(this, "name", 'subTable'), _define_property(this, "type", 'object'), _define_property(this, "group", 'relation'), _define_property(this, "order", 2), _define_property(this, "title", '{{t("Sub-table")}}'), _define_property(this, "isAssociation", true), _define_property(this, "default", {
            type: 'hasMany',
            uiSchema: {
                type: 'void',
                'x-component': 'TableField',
                'x-component-props': {}
            }
        }), _define_property(this, "availableTypes", [
            'hasMany'
        ]), _define_property(this, "initialize", (values)=>{
            if (!values.target) values.target = "t_".concat((0, schema_namespaceObject.uid)());
            if (!values.foreignKey) values.foreignKey = "f_".concat((0, schema_namespaceObject.uid)());
        }), _define_property(this, "properties", {
            ...index_js_namespaceObject.defaultProps,
            subtable: {
                type: 'void',
                'x-component': 'SubFieldDataSourceProvider',
                properties: {
                    actions: {
                        type: 'void',
                        'x-component': 'ActionBar',
                        'x-component-props': {},
                        properties: {
                            delete: {
                                type: 'void',
                                title: '{{ t("Delete") }}',
                                'x-component': 'Action',
                                'x-component-props': {
                                    useAction: '{{ ds.useBulkDestroyAction }}',
                                    confirm: {
                                        title: "{{t('Delete record')}}",
                                        content: "{{t('Are you sure you want to delete it?')}}"
                                    }
                                }
                            },
                            create: {
                                type: 'void',
                                title: '{{ t("Add new") }}',
                                'x-component': 'AddSubFieldAction',
                                'x-component-props': {
                                    type: 'primary'
                                }
                            }
                        }
                    },
                    children: {
                        type: 'array',
                        title: '{{t("Fields")}}',
                        'x-decorator': 'FormItem',
                        'x-component': 'Table.Array',
                        'x-component-props': {
                            pagination: false,
                            expandable: {
                                childrenColumnName: '__nochildren__'
                            },
                            rowKey: 'name',
                            rowSelection: {
                                type: 'checkbox'
                            },
                            useSelectedRowKeys: '{{ ds.useSelectedRowKeys }}',
                            useDataSource: '{{ ds.useDataSource }}'
                        },
                        properties: {
                            column1: {
                                type: 'void',
                                title: '{{ t("Field display name") }}',
                                'x-component': 'Table.Column',
                                properties: {
                                    'uiSchema.title': {
                                        type: 'number',
                                        'x-component': 'Input',
                                        'x-read-pretty': true
                                    }
                                }
                            },
                            column2: {
                                type: 'void',
                                title: '{{ t("Field name") }}',
                                'x-component': 'Table.Column',
                                properties: {
                                    name: {
                                        'x-component': 'Input',
                                        'x-read-pretty': true
                                    }
                                }
                            },
                            column3: {
                                type: 'void',
                                title: '{{ t("Field interface") }}',
                                'x-component': 'Table.Column',
                                properties: {
                                    interface: {
                                        'x-component': 'Input',
                                        'x-read-pretty': true
                                    }
                                }
                            },
                            column4: {
                                type: 'void',
                                title: '{{ t("Actions") }}',
                                'x-component': 'Table.Column',
                                properties: {
                                    actions: {
                                        type: 'void',
                                        'x-component': 'Space',
                                        'x-component-props': {
                                            split: '|'
                                        },
                                        properties: {
                                            update: {
                                                type: 'void',
                                                title: '{{ t("Edit") }}',
                                                'x-component': 'EditSubFieldAction',
                                                'x-component-props': {}
                                            },
                                            delete: {
                                                type: 'void',
                                                title: '{{ t("Delete") }}',
                                                'x-component': 'Action.Link',
                                                'x-component-props': {
                                                    useAction: '{{ ds.useDestroyAction }}',
                                                    confirm: {
                                                        title: "{{t('Delete record')}}",
                                                        content: "{{t('Are you sure you want to delete it?')}}"
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        });
    }
}
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
