import { jsx } from "react/jsx-runtime";
import react from "react";
import { ArrayBase } from "@tego/client";
import { Switch } from "antd";
import { useTranslation } from "react-i18next";
const EnableLinkage = /*#__PURE__*/ react.forwardRef((props, ref)=>{
    var _array_field;
    const array = ArrayBase.useArray();
    const index = ArrayBase.useIndex(props.index);
    const { t } = useTranslation();
    return /*#__PURE__*/ jsx(Switch, {
        ...props,
        checkedChildren: t('On'),
        unCheckedChildren: t('Off'),
        checked: !(null == array ? void 0 : null == (_array_field = array.field) ? void 0 : _array_field.value[index].disabled),
        size: 'small',
        style: {
            transition: 'all 0.25s ease-in-out',
            color: 'rgba(0, 0, 0, 0.8)',
            fontSize: 16,
            marginLeft: 6,
            marginBottom: 3
        },
        onChange: (checked, e)=>{
            var _array_field;
            e.stopPropagation();
            array.field.value.splice(index, 1, {
                ...null == array ? void 0 : null == (_array_field = array.field) ? void 0 : _array_field.value[index],
                disabled: !checked
            });
        },
        onClick: (checked, e)=>{
            e.stopPropagation();
        }
    });
});
EnableLinkage.displayName = 'EnableLinkage';
export { EnableLinkage };
