import { FieldSchema } from '@ephox/boulder';
import { Direction } from '@ephox/sugar';
import { isBottomToTopDir } from './VerticalDir';
const schema = () => FieldSchema.optionObjOf('layouts', [
    FieldSchema.required('onLtr'),
    FieldSchema.required('onRtl'),
    FieldSchema.option('onBottomLtr'),
    FieldSchema.option('onBottomRtl')
]);
const get = (elem, info, defaultLtr, defaultRtl, defaultBottomLtr, defaultBottomRtl, dirElement) => {
    const isBottomToTop = dirElement.map(isBottomToTopDir).getOr(false);
    const customLtr = info.layouts.map((ls) => ls.onLtr(elem));
    const customRtl = info.layouts.map((ls) => ls.onRtl(elem));
    const ltr = isBottomToTop ?
        info.layouts.bind((ls) => ls.onBottomLtr.map((f) => f(elem)))
            .or(customLtr)
            .getOr(defaultBottomLtr) :
        customLtr.getOr(defaultLtr);
    const rtl = isBottomToTop ?
        info.layouts.bind((ls) => ls.onBottomRtl.map((f) => f(elem)))
            .or(customRtl)
            .getOr(defaultBottomRtl) :
        customRtl.getOr(defaultRtl);
    const f = Direction.onDirection(ltr, rtl);
    return f(elem);
};
export { schema, get };
//# sourceMappingURL=AnchorLayouts.js.map