"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__, {
    InternaDrawerSubTable: ()=>InternaDrawerSubTable
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const schema_namespaceObject = require("@tachybase/schema");
const icons_namespaceObject = require("@ant-design/icons");
const external_antd_namespaceObject = require("antd");
const external_react_i18next_namespaceObject = require("react-i18next");
const index_js_namespaceObject = require("../../../data-source/index.js");
const external_flag_provider_index_js_namespaceObject = require("../../../flag-provider/index.js");
const context_js_namespaceObject = require("../action/context.js");
const external_hooks_js_namespaceObject = require("./hooks.js");
const external_InternalSubTable_js_namespaceObject = require("./InternalSubTable.js");
const external_InternalViewer_js_namespaceObject = require("./InternalViewer.js");
const InternaDrawerSubTable = (0, schema_namespaceObject.observer)((props)=>{
    var _options_uiSchema;
    const { options } = (0, external_hooks_js_namespaceObject.useAssociationFieldContext)();
    const [visible, setVisible] = (0, external_react_namespaceObject.useState)(false);
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const nesterProps = {
        ...props,
        shouldMountElement: true
    };
    const titleProps = {
        ...props,
        enableLink: true
    };
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const cm = (0, index_js_namespaceObject.useCollectionManager)();
    const ctx = (0, external_react_namespaceObject.useContext)(context_js_namespaceObject.ActionContext);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
                style: {
                    cursor: 'pointer',
                    display: 'flex'
                },
                onClick: ()=>{
                    setVisible(true);
                },
                children: [
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                        style: {
                            maxWidth: '95%'
                        },
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_InternalViewer_js_namespaceObject.ReadPrettyInternalViewer, {
                            ...titleProps
                        })
                    }),
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.EditOutlined, {
                        style: {
                            display: 'inline-flex',
                            marginLeft: '5px'
                        }
                    })
                ]
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(context_js_namespaceObject.ActionContextProvider, {
                value: {
                    ...ctx,
                    visible,
                    setVisible,
                    openMode: 'drawer'
                },
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Drawer, {
                    title: t(null == options ? void 0 : null === (_options_uiSchema = options.uiSchema) || void 0 === _options_uiSchema ? void 0 : _options_uiSchema.rawTitle),
                    open: visible,
                    onClose: ()=>{
                        setVisible(false);
                    },
                    style: {
                        backgroundColor: '#f3f3f3'
                    },
                    width: '70%',
                    destroyOnClose: true,
                    extra: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
                        type: "primary",
                        onClick: ()=>setVisible(false),
                        children: "确认"
                    }),
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_flag_provider_index_js_namespaceObject.FlagProvider, {
                        isInSubForm: true,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_hooks_js_namespaceObject.SubFormProvider, {
                            value: {
                                value: field.value,
                                collection: cm.getCollection(fieldSchema['x-collection-field'])
                            },
                            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_InternalSubTable_js_namespaceObject.InternalSubTable, {
                                ...nesterProps
                            })
                        })
                    })
                })
            })
        ]
    });
}, {
    displayName: 'InternaDrawerSubTable'
});
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
});
