import { isValid, useFieldSchema } from "@tachybase/schema";
import { useSchemaToolbar } from "../../../application/index.mjs";
import { SchemaSettings } from "../../../application/schema-settings/SchemaSettings.mjs";
import { AfterSuccess, ButtonEditor, RemoveButton, SecondConFirm, WorkflowConfig } from "../../../schema-component/antd/action/Action.Designer.mjs";
import { SaveMode } from "./createSubmitActionSettings.mjs";
const updateSubmitActionSettings = new SchemaSettings({
    name: 'actionSettings:updateSubmit',
    items: [
        {
            name: 'editButton',
            Component: ButtonEditor,
            useComponentProps () {
                const { buttonEditorProps } = useSchemaToolbar();
                return buttonEditorProps;
            }
        },
        {
            name: 'secondConfirmation',
            Component: SecondConFirm
        },
        {
            name: 'afterSuccessfulSubmission',
            Component: AfterSuccess
        },
        {
            name: 'workflowConfig',
            Component: WorkflowConfig,
            useVisible () {
                var _fieldSchema_xactionsettings;
                const fieldSchema = useFieldSchema();
                return isValid(null == fieldSchema ? void 0 : null == (_fieldSchema_xactionsettings = fieldSchema['x-action-settings']) ? void 0 : _fieldSchema_xactionsettings.triggerWorkflows);
            }
        },
        {
            name: 'remove',
            sort: 100,
            Component: RemoveButton,
            useComponentProps () {
                const { removeButtonProps } = useSchemaToolbar();
                return removeButtonProps;
            }
        }
    ]
});
const submitActionSettings = new SchemaSettings({
    name: 'actionSettings:submit',
    items: [
        {
            name: 'editButton',
            Component: ButtonEditor,
            useComponentProps () {
                const { buttonEditorProps } = useSchemaToolbar();
                return buttonEditorProps;
            }
        },
        {
            name: 'secondConfirmation',
            Component: SecondConFirm
        },
        {
            name: 'workflowConfig',
            Component: WorkflowConfig,
            useVisible () {
                var _fieldSchema_xactionsettings;
                const fieldSchema = useFieldSchema();
                return isValid(null == fieldSchema ? void 0 : null == (_fieldSchema_xactionsettings = fieldSchema['x-action-settings']) ? void 0 : _fieldSchema_xactionsettings.triggerWorkflows);
            }
        },
        {
            name: 'saveMode',
            Component: SaveMode,
            useVisible () {
                var _fieldSchema_parent;
                const fieldSchema = useFieldSchema();
                return 'submit' === fieldSchema['x-action'] && (null == (_fieldSchema_parent = fieldSchema.parent) ? void 0 : _fieldSchema_parent['x-initializer']) === 'createForm:configureActions';
            }
        },
        {
            name: 'remove',
            sort: 100,
            Component: RemoveButton,
            useComponentProps () {
                const { removeButtonProps } = useSchemaToolbar();
                return removeButtonProps;
            }
        }
    ]
});
export { submitActionSettings, updateSubmitActionSettings };
