"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__, {
    default: ()=>FixedBlock_rslib_entry_,
    FixedBlockWrapper: ()=>FixedBlockWrapper,
    useFixedSchema: ()=>useFixedSchema,
    useFixedBlock: ()=>useFixedBlock
});
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_antd_style_namespaceObject = require("antd-style");
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      overflow: hidden;\n      position: relative;\n      .tb-card-item {\n        height: 100%;\n        .ant-card {\n          display: flex;\n          flex-direction: column;\n          height: 100%;\n          .ant-card-body {\n            height: 1px;\n            flex: 1;\n            display: flex;\n            flex-direction: column;\n            overflow: hidden;\n          }\n        }\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const FixedBlockContext = /*#__PURE__*/ external_react_default().createContext({
    setFixedBlock: ()=>{},
    height: 0,
    fixedBlockUID: false,
    fixedBlockUIDRef: {
        current: false
    },
    inFixedBlock: false
});
const useFixedSchema = ()=>{
    var _field_decoratorProps;
    const field = (0, schema_namespaceObject.useField)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { setFixedBlock, fixedBlockUID, fixedBlockUIDRef } = useFixedBlock();
    const hasSet = (0, external_react_namespaceObject.useRef)(false);
    (0, external_react_namespaceObject.useEffect)(()=>{
        if (!fixedBlockUIDRef.current || hasSet.current) {
            var _field_decoratorProps;
            setFixedBlock(null != field && null !== (_field_decoratorProps = field.decoratorProps) && void 0 !== _field_decoratorProps && !!_field_decoratorProps.fixedBlock && fieldSchema['x-uid']);
            hasSet.current = true;
        }
    }, [
        null == field ? void 0 : null === (_field_decoratorProps = field.decoratorProps) || void 0 === _field_decoratorProps ? void 0 : _field_decoratorProps.fixedBlock
    ]);
    return fieldSchema['x-uid'] === fixedBlockUID;
};
const useFixedBlock = ()=>(0, external_react_namespaceObject.useContext)(FixedBlockContext);
const FixedBlockWrapper = (props)=>{
    const fixedBlock = useFixedSchema();
    const { height, fixedBlockUID } = useFixedBlock();
    if (!fixedBlock && fixedBlockUID) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
        children: props.children
    });
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        className: "tb-fixed-block",
        style: {
            height: fixedBlockUID ? "calc(100vh - ".concat(height, ")") : void 0
        },
        children: props.children
    });
};
const useStyles = (0, external_antd_style_namespaceObject.createStyles)((param)=>{
    let { css } = param;
    return {
        fixedBlockCss: css(_templateObject())
    };
});
const FixedBlock = (props)=>{
    const { height } = props;
    const { styles } = useStyles();
    const [fixedBlockUID, _setFixedBlock] = (0, external_react_namespaceObject.useState)(false);
    const fixedBlockUIDRef = (0, external_react_namespaceObject.useRef)(fixedBlockUID);
    const setFixedBlock = (v)=>{
        fixedBlockUIDRef.current = v;
        _setFixedBlock(v);
    };
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FixedBlockContext.Provider, {
        value: {
            inFixedBlock: true,
            height,
            setFixedBlock,
            fixedBlockUID,
            fixedBlockUIDRef
        },
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
            className: fixedBlockUID ? styles.fixedBlockCss : '',
            style: {
                height: fixedBlockUID ? "calc(100vh - ".concat(height, ")") : void 0
            },
            children: props.children
        })
    });
};
const FixedBlock_rslib_entry_ = FixedBlock;
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
});
