import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE_antd_style__ from "antd-style";
import * as __WEBPACK_EXTERNAL_MODULE_classnames__ from "classnames";
import * as __WEBPACK_EXTERNAL_MODULE__application_index_mjs__ from "../../../application/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__icon_index_mjs__ from "../../../icon/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__common_index_mjs__ from "../../common/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_useDesigner_mjs__ from "../../hooks/useDesigner.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__context_mjs__ from "./context.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__Tabs_Designer_mjs__ from "./Tabs.Designer.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      position: relative;\n      &:hover {\n        > .general-schema-designer {\n          display: block;\n        }\n      }\n      &.tb-action-link {\n        > .general-schema-designer {\n          top: -10px;\n          bottom: -10px;\n          left: -10px;\n          right: -10px;\n        }\n      }\n      > .general-schema-designer {\n        position: absolute;\n        z-index: 999;\n        top: 0;\n        bottom: 0;\n        left: 0;\n        right: 0;\n        display: none;\n        background: var(--colorBgSettingsHover);\n        border: 0;\n        top: 0;\n        bottom: 0;\n        left: 0;\n        right: 0;\n        pointer-events: none;\n        > .general-schema-designer-icons {\n          position: absolute;\n          right: 2px;\n          top: 2px;\n          line-height: 16px;\n          pointer-events: all;\n          .ant-space-item {\n            background-color: var(--colorSettings);\n            color: #fff;\n            line-height: 16px;\n            width: 16px;\n            padding-left: 1px;\n            align-self: stretch;\n          }\n        }\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const useStyles = (0, __WEBPACK_EXTERNAL_MODULE_antd_style__.createStyles)((param)=>{
    let { css } = param;
    return {
        designer: css(_templateObject())
    };
});
const Tabs = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)((props)=>{
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const { render } = (0, __WEBPACK_EXTERNAL_MODULE__application_index_mjs__.useSchemaInitializerRender)(fieldSchema['x-initializer'], fieldSchema['x-initializer-props']);
    const contextProps = (0, __WEBPACK_EXTERNAL_MODULE__context_mjs__.useTabsContext)();
    const { PaneRoot = __WEBPACK_EXTERNAL_MODULE_react__["default"].Fragment } = contextProps;
    const items = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        const result = fieldSchema.mapProperties((schema, key)=>({
                key,
                label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.RecursionField, {
                    name: key,
                    schema: schema,
                    onlyRenderSelf: true
                }),
                children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(PaneRoot, {
                    ...PaneRoot !== __WEBPACK_EXTERNAL_MODULE_react__["default"].Fragment ? {
                        active: key === contextProps.activeKey
                    } : {},
                    children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.RecursionField, {
                        name: key,
                        schema: schema,
                        onlyRenderProperties: true
                    })
                })
            }));
        return result;
    }, [
        fieldSchema.mapProperties((s, key)=>key).join()
    ]);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__common_index_mjs__.DndContext, {
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Tabs, {
            ...contextProps,
            destroyInactiveTabPane: true,
            tabBarExtraContent: render(),
            style: props.style,
            items: items
        })
    });
}, {
    displayName: 'Tabs'
});
Tabs.TabPane = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)((props)=>{
    const { styles } = useStyles();
    const Designer = (0, __WEBPACK_EXTERNAL_MODULE__hooks_useDesigner_mjs__.useDesigner)();
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE__common_index_mjs__.SortableItem, {
        className: (0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])('tb-action-link', styles.designer, props.className),
        children: [
            props.icon && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__icon_index_mjs__.Icon, {
                style: {
                    marginRight: 2
                },
                type: props.icon
            }),
            " ",
            props.tab || field.title,
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Designer, {})
        ]
    });
}, {
    displayName: 'Tabs.TabPane'
});
Tabs.Designer = __WEBPACK_EXTERNAL_MODULE__Tabs_Designer_mjs__.TabsDesigner;
export { Tabs };
