import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__block_provider_BlockProvider_mjs__ from "../../../block-provider/BlockProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__ from "../../../schema-settings/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__ from "../../hooks/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__FixedBlock_mjs__ from "./FixedBlock.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_useIsBlockInPage_mjs__ from "./hooks/useIsBlockInPage.mjs";
const FixedBlockDesignerItem = ()=>{
    var _fieldSchema_xdecoratorprops;
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
    const { inFixedBlock } = (0, __WEBPACK_EXTERNAL_MODULE__FixedBlock_mjs__.useFixedBlock)();
    const { isBlockInPage } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_useIsBlockInPage_mjs__.useIsBlockInPage)();
    const { service } = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_BlockProvider_mjs__.useBlockRequestContext)();
    if (!isBlockInPage() || !inFixedBlock) return null;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__.SchemaSettingsSwitchItem, {
        title: t('Fix block'),
        checked: null === (_fieldSchema_xdecoratorprops = fieldSchema['x-decorator-props']) || void 0 === _fieldSchema_xdecoratorprops ? void 0 : _fieldSchema_xdecoratorprops.fixedBlock,
        onChange: async (fixedBlock)=>{
            var _service_refresh;
            const decoratorProps = {
                ...fieldSchema['x-decorator-props'],
                fixedBlock
            };
            await dn.emit('patch', {
                schema: {
                    ['x-uid']: fieldSchema['x-uid'],
                    'x-decorator-props': decoratorProps
                }
            });
            field.decoratorProps = fieldSchema['x-decorator-props'] = decoratorProps;
            null == service || null === (_service_refresh = service.refresh) || void 0 === _service_refresh || _service_refresh.call(service);
        }
    });
};
export { FixedBlockDesignerItem };
