"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __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__, {
    ActionAreaStub: ()=>ActionAreaStub,
    ActionAreaProvider: ()=>ActionAreaProvider,
    useActionAreaStub: ()=>useActionAreaStub,
    ActionArea: ()=>ActionArea,
    ActionAreaPlayer: ()=>ActionAreaPlayer,
    default: ()=>Action_Area_rslib_entry_
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const schema_namespaceObject = require("@tachybase/schema");
const external_react_dom_namespaceObject = require("react-dom");
const external_Action_Area_style_js_namespaceObject = require("./Action.Area.style.js");
const external_hooks_js_namespaceObject = require("./hooks.js");
const ActionAreaContext = /*#__PURE__*/ external_react_default().createContext({});
const ActionAreaProvider = (param)=>{
    let { children } = param;
    const [component, setComponent] = (0, external_react_namespaceObject.useState)(()=>{});
    const [prevSetVisible, setPrevSetVisible] = (0, external_react_namespaceObject.useState)(()=>{});
    const ref = (0, external_react_namespaceObject.useRef)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ActionAreaContext.Provider, {
        value: {
            component,
            setComponent,
            prevSetVisible,
            setPrevSetVisible,
            ref
        },
        children: children
    });
};
const useActionAreaStub = ()=>{
    const { component } = (0, external_react_namespaceObject.useContext)(ActionAreaContext);
    return component;
};
const ActionAreaStub = ()=>{
    const { ref } = (0, external_react_namespaceObject.useContext)(ActionAreaContext);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        ref: ref
    });
};
const ActionAreaPlayer = (param)=>{
    let { children } = param;
    const { visible, setVisible } = (0, external_hooks_js_namespaceObject.useActionContext)();
    const { prevSetVisible, setPrevSetVisible, ref } = (0, external_react_namespaceObject.useContext)(ActionAreaContext);
    (0, external_react_namespaceObject.useEffect)(()=>{
        if (visible) null == setPrevSetVisible || setPrevSetVisible(()=>{
            null == prevSetVisible || prevSetVisible(false);
            setVisible(true);
            return setVisible;
        });
    }, [
        visible
    ]);
    return visible && ref.current ? /*#__PURE__*/ (0, external_react_dom_namespaceObject.createPortal)(children, ref.current) : null;
};
const ActionArea = (0, schema_namespaceObject.observer)((props)=>{
    const { footerNodeName = 'ActionArea.Footer' } = props;
    const schema = (0, schema_namespaceObject.useFieldSchema)();
    const field = (0, schema_namespaceObject.useField)();
    const { styles } = (0, external_Action_Area_style_js_namespaceObject.useStyles)();
    const Current = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
            children: [
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                    className: styles.footer,
                    children: [
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                            className: "title",
                            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("strong", {
                                children: field.title
                            })
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(schema_namespaceObject.RecursionField, {
                            basePath: field.address,
                            schema: schema,
                            onlyRenderProperties: true,
                            filterProperties: (s)=>s['x-component'] === footerNodeName
                        })
                    ]
                }),
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                    className: styles.container,
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(schema_namespaceObject.RecursionField, {
                        basePath: field.address,
                        schema: schema,
                        onlyRenderProperties: true,
                        filterProperties: (s)=>s['x-component'] !== footerNodeName
                    })
                })
            ]
        });
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ActionAreaPlayer, {
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Current, {})
    });
}, {
    displayName: 'ActionArea'
});
ActionArea.Footer = (0, schema_namespaceObject.observer)(()=>{
    const field = (0, schema_namespaceObject.useField)();
    const schema = (0, schema_namespaceObject.useFieldSchema)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(schema_namespaceObject.RecursionField, {
        basePath: field.address,
        schema: schema,
        onlyRenderProperties: true
    });
}, {
    displayName: 'ActionArea.Footer'
});
const Action_Area_rslib_entry_ = ActionArea;
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
});
