import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_template_CollectionTemplate_mjs__ from "../../data-source/collection-template/CollectionTemplate.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__i18n_index_mjs__ from "../../i18n/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__components_sql_collection_index_mjs__ from "./components/sql-collection/index.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 SqlCollectionTemplate extends __WEBPACK_EXTERNAL_MODULE__data_source_collection_template_CollectionTemplate_mjs__.CollectionTemplate {
    constructor(...args){
        super(...args), _define_property(this, "name", 'sql'), _define_property(this, "title", '{{t("SQL collection")}}'), _define_property(this, "order", 4), _define_property(this, "color", 'yellow'), _define_property(this, "default", {
            fields: []
        }), _define_property(this, "configurableProperties", {
            title: {
                type: 'string',
                title: '{{ t("Collection display name") }}',
                required: true,
                'x-decorator': 'FormItem',
                'x-component': 'Input'
            },
            name: {
                type: 'string',
                title: '{{t("Collection name")}}',
                required: true,
                'x-disabled': '{{ !createOnly }}',
                'x-decorator': 'FormItem',
                'x-component': 'Input',
                'x-validator': 'uid',
                description: "{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"
            },
            config: {
                type: 'void',
                'x-decorator': __WEBPACK_EXTERNAL_MODULE__components_sql_collection_index_mjs__.SQLRequestProvider,
                properties: {
                    sql: {
                        type: 'string',
                        title: '{{t("SQL")}}',
                        'x-decorator': 'FormItem',
                        'x-component': __WEBPACK_EXTERNAL_MODULE__components_sql_collection_index_mjs__.SQLInput,
                        required: true,
                        'x-validator': (value, rules, param)=>{
                            let { form } = param;
                            const field = form.query('sql').take();
                            if (!field.componentProps.disabled) return __WEBPACK_EXTERNAL_MODULE__i18n_index_mjs__.i18n.t('Please confirm the SQL statement first');
                            return '';
                        }
                    },
                    sources: {
                        type: 'array',
                        title: '{{t("Source collections")}}',
                        'x-decorator': 'FormItem',
                        'x-component': 'Select',
                        'x-component-props': {
                            multiple: true
                        },
                        'x-reactions': [
                            '{{useAsyncDataSource(loadCollections)}}'
                        ]
                    },
                    fields: {
                        type: 'array',
                        title: '{{t("Fields")}}',
                        'x-decorator': 'FormItem',
                        'x-component': __WEBPACK_EXTERNAL_MODULE__components_sql_collection_index_mjs__.FieldsConfigure,
                        required: true
                    },
                    table: {
                        type: 'void',
                        title: '{{t("Preview")}}',
                        'x-decorator': 'FormItem',
                        'x-component': __WEBPACK_EXTERNAL_MODULE__components_sql_collection_index_mjs__.PreviewTable
                    }
                }
            },
            ...(0, __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.getConfigurableProperties)('category')
        });
    }
}
export { SqlCollectionTemplate };
