import { Fragment, jsx } from "react/jsx-runtime";
import "react";
import { RecursionField, observer, useField, useFieldSchema } from "@tachybase/schema";
import { css } from "@emotion/css";
import { Button, Drawer } from "antd";
import classnames from "classnames";
import { Icon } from "../../../icon/index.mjs";
import { useStyles } from "./Action.Drawer.style.mjs";
import { useActionContext } from "./hooks.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                background: none;\n                border: none;\n              "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const ActionSheet = observer((props)=>{
    const { footerNodeName = 'Action.Drawer.Footer', ...others } = props;
    const { visible, setVisible, drawerProps } = useActionContext();
    const schema = useFieldSchema();
    const field = useField();
    const { componentCls, hashId } = useStyles();
    return /*#__PURE__*/ jsx(Drawer, {
        placement: "bottom",
        height: "90%",
        title: field.title,
        ...others,
        ...drawerProps,
        rootStyle: {
            ...null == drawerProps ? void 0 : drawerProps.style,
            ...null == others ? void 0 : others.style
        },
        extra: /*#__PURE__*/ jsx(Fragment, {
            children: /*#__PURE__*/ jsx(Button, {
                type: "text",
                icon: /*#__PURE__*/ jsx(Icon, {
                    type: "CloseOutlined"
                }),
                className: css(_templateObject()),
                onClick: ()=>setVisible(false, true)
            })
        }),
        closable: false,
        destroyOnClose: true,
        open: visible,
        onClose: ()=>setVisible(false, true),
        rootClassName: classnames(componentCls, hashId, null == drawerProps ? void 0 : drawerProps.className, others.className, 'reset'),
        className: "".concat(props.className, " amplifier-block"),
        children: /*#__PURE__*/ jsx(RecursionField, {
            basePath: field.address,
            schema: schema,
            onlyRenderProperties: true,
            filterProperties: (s)=>s['x-component'] !== footerNodeName
        })
    });
}, {
    displayName: 'ActionSheet'
});
ActionSheet.Footer = observer(()=>{
    const field = useField();
    const schema = useFieldSchema();
    return /*#__PURE__*/ jsx(RecursionField, {
        basePath: field.address,
        schema: schema,
        onlyRenderProperties: true
    });
}, {
    displayName: 'ActionSheet.Footer'
});
const Action_Sheet = ActionSheet;
export { ActionSheet, Action_Sheet as default };
