import { jsx as _jsx } from "react/jsx-runtime";
import { BinStrategy } from '@data-wrangling-components/core';
import { num } from '@data-wrangling-components/utilities';
import { memo, useMemo } from 'react';
import { FormInputType, VerbForm } from '../verbForm/VerbForm.js';
import { checkbox, enumDropdown } from '../verbForm/VerbFormFactories.js';
/**
 * Provides inputs for a binning step.
 */ export const BinBase = /*#__PURE__*/ memo(function BinBase({ step , onChange  }) {
    const verbInputs = useMemo(()=>[
            enumDropdown('Bin strategy', BinStrategy, step.args.strategy, (s, opt)=>s.args.strategy = opt, {
                required: true
            }),
            {
                label: 'Bin count',
                type: FormInputType.NumberSpinner,
                if: step.args.strategy === BinStrategy.FixedCount,
                min: 1,
                max: 100,
                step: 1,
                onChange: (s, opt)=>s.args.fixedcount = num(opt),
                current: step.args.fixedcount
            },
            {
                label: 'Bin size',
                type: FormInputType.NumberSpinner,
                if: step.args.strategy === BinStrategy.FixedWidth,
                min: 1,
                onChange: (s, opt)=>s.args.fixedwidth = num(opt),
                current: step.args.fixedwidth
            },
            {
                label: 'Min Boundary',
                type: FormInputType.NumberSpinner,
                if: step.args.strategy !== BinStrategy.Auto,
                onChange: (s, opt)=>s.args.min = num(opt),
                current: step.args.min
            },
            {
                label: 'Max Boundary',
                type: FormInputType.NumberSpinner,
                if: step.args.strategy !== BinStrategy.Auto,
                onChange: (s, opt)=>s.args.max = num(opt),
                current: step.args.max
            },
            checkbox('Clamp to min/max', step.args.clamped, (s, val)=>s.args.clamped = val, {
                if: step.args.strategy !== BinStrategy.Auto,
                styles: {
                    root: {
                        marginTop: 8
                    }
                }
            }),
            checkbox('Print range as output', step.args.printRange, (s, opt)=>s.args.printRange = opt, {
                styles: {
                    root: {
                        marginTop: 8
                    }
                }
            }), 
        ], [
        step
    ]);
    return /*#__PURE__*/ _jsx(VerbForm, {
        onChange: onChange,
        step: step,
        inputs: verbInputs
    });
});
