import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_components__ from "@tachybase/components";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_field_interface_CollectionFieldInterface_mjs__ from "../../data-source/collection-field-interface/CollectionFieldInterface.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;
}
(0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.registerValidateRules)({
    json (value) {
        try {
            JSON.parse(value);
            return true;
        } catch (error) {
            return {
                type: 'error',
                message: error.message
            };
        }
    }
});
class JsonFieldInterface extends __WEBPACK_EXTERNAL_MODULE__data_source_collection_field_interface_CollectionFieldInterface_mjs__.CollectionFieldInterface {
    constructor(...args){
        super(...args), _define_property(this, "name", 'json'), _define_property(this, "type", 'object'), _define_property(this, "group", 'advanced'), _define_property(this, "order", 4), _define_property(this, "title", '{{t("JSON")}}'), _define_property(this, "sortable", true), _define_property(this, "default", {
            type: 'json',
            uiSchema: {
                type: 'object',
                'x-component': 'Input.JSON',
                'x-component-props': {
                    autoSize: {
                        minRows: 5
                    }
                },
                default: null
            }
        }), _define_property(this, "availableTypes", [
            'json',
            'array',
            'jsonb',
            'text',
            'circle',
            'lineString',
            'point',
            'polygon'
        ]), _define_property(this, "hasDefaultValue", true), _define_property(this, "properties", {
            ...__WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.defaultProps,
            jsonb: {
                type: 'boolean',
                title: 'JSONB',
                'x-decorator': (param)=>{
                    let { children } = param;
                    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_components__.FormLayout, {
                        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_components__.FormItem, {
                            children: children
                        })
                    });
                },
                'x-component': 'Checkbox',
                'x-hidden': "{{ !isDialect('postgres') }}",
                'x-disabled': "{{ disabledJSONB }}"
            }
        }), _define_property(this, "filterable", {
            operators: __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.operators.string
        });
    }
}
export { JsonFieldInterface };
