import { Optional, Type } from '@ephox/katamari';
import { Attribute, SugarPosition } from '@ephox/sugar';
const parseAttrToInt = (element, name) => {
    const value = Attribute.get(element, name);
    return Type.isUndefined(value) ? NaN : parseInt(value, 10);
};
// NOTE: Moved from ego with some parameterisation
const get = (component, snapsInfo) => {
    const element = component.element;
    const x = parseAttrToInt(element, snapsInfo.leftAttr);
    const y = parseAttrToInt(element, snapsInfo.topAttr);
    return isNaN(x) || isNaN(y) ? Optional.none() : Optional.some(SugarPosition(x, y));
};
const set = (component, snapsInfo, pt) => {
    const element = component.element;
    Attribute.set(element, snapsInfo.leftAttr, pt.left + 'px');
    Attribute.set(element, snapsInfo.topAttr, pt.top + 'px');
};
const clear = (component, snapsInfo) => {
    const element = component.element;
    Attribute.remove(element, snapsInfo.leftAttr);
    Attribute.remove(element, snapsInfo.topAttr);
};
export { get, set, clear };
//# sourceMappingURL=Presnaps.js.map