import { jsx } from "react/jsx-runtime";
import { useEffect } from "react";
import { RecursionField, observer, useField, useFieldSchema } from "@tachybase/schema";
import { FormLayout } from "@tego/client";
import { createStyles } from "antd-style";
import classnames from "classnames";
import { ACLCollectionProvider, useACLActionParamsContext } from "../../../built-in/acl/index.mjs";
import { CollectionProvider_deprecated } from "../../../collection-manager/index.mjs";
import { useAssociationFieldContext, useInsertSchema } from "./hooks.mjs";
import schema from "./schema.mjs";
function _tagged_template_literal(strings, raw) {
    if (!raw) raw = strings.slice(0);
    return Object.freeze(Object.defineProperties(strings, {
        raw: {
            value: Object.freeze(raw)
        }
    }));
}
function _templateObject() {
    const data = _tagged_template_literal([
        "\n      & .ant-formily-item-layout-vertical {\n        margin-bottom: 10px;\n      }\n      .ant-card-body {\n        padding: 15px 20px 5px;\n      }\n      .ant-divider-horizontal {\n        margin: 10px 0;\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
function _templateObject1() {
    const data = _tagged_template_literal([
        "\n      .ant-card-body {\n        padding: 0px 20px 20px 0px;\n      }\n      > .ant-card-bordered {\n        border: none;\n      }\n    "
    ]);
    _templateObject1 = function() {
        return data;
    };
    return data;
}
const useStyles = createStyles((param)=>{
    let { css } = param;
    return {
        body: css(_templateObject()),
        showTitle: css(_templateObject1())
    };
});
const InternalNester = observer(()=>{
    var _fieldSchema_xdecoratorprops;
    const field = useField();
    const fieldSchema = useFieldSchema();
    const insertNester = useInsertSchema('Nester');
    const { options: collectionField } = useAssociationFieldContext();
    var _fieldSchema_xdecoratorprops_showTitle;
    const showTitle = null != (_fieldSchema_xdecoratorprops_showTitle = null == (_fieldSchema_xdecoratorprops = fieldSchema['x-decorator-props']) ? void 0 : _fieldSchema_xdecoratorprops.showTitle) ? _fieldSchema_xdecoratorprops_showTitle : true;
    const { actionName } = useACLActionParamsContext();
    const { styles } = useStyles();
    useEffect(()=>{
        insertNester(schema.Nester);
    }, []);
    return /*#__PURE__*/ jsx(CollectionProvider_deprecated, {
        name: collectionField.target,
        children: /*#__PURE__*/ jsx(ACLCollectionProvider, {
            actionPath: "".concat(collectionField.target, ":").concat(actionName),
            children: /*#__PURE__*/ jsx(FormLayout, {
                layout: 'vertical',
                children: /*#__PURE__*/ jsx("div", {
                    className: classnames(styles.body, {
                        [styles.showTitle]: false === showTitle
                    }),
                    children: /*#__PURE__*/ jsx(RecursionField, {
                        onlyRenderProperties: true,
                        basePath: field.address,
                        schema: fieldSchema,
                        filterProperties: (s)=>'AssociationField.Nester' === s['x-component']
                    })
                })
            })
        })
    });
}, {
    displayName: 'InternalNester'
});
export { InternalNester };
