(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.cssNumberToString = void 0;
    function cssNumberToString(n, unit = "px") {
        if (typeof n === "number") {
            if (n === 0) {
                return n + "";
            }
            return n + unit;
        }
        return n;
    }
    exports.cssNumberToString = cssNumberToString;
    class StyleBuilder {
        constructor(style) {
            this.style = style;
            this.style = this.style || {};
        }
        static get newStyle() {
            return new StyleBuilder();
        }
        toStyle() {
            return this.style;
        }
        size(width, height) {
            width = cssNumberToString(width);
            height = cssNumberToString(height);
            return this.merge({
                width,
                height
            });
        }
        roundBorder(radius) {
            radius = cssNumberToString(radius);
            return this.merge({
                borderRadius: radius,
                padding: radius
            });
        }
        border(borderWidth, borderColor, borderStyle = "solid") {
            borderWidth = cssNumberToString(borderWidth);
            return this.merge({
                borderWidth,
                borderStyle,
                borderColor
            });
        }
        center(width, height) {
            width = cssNumberToString(width);
            height = cssNumberToString(height);
            return this.merge({
                position: "absolute",
                left: 0,
                right: 0,
                top: 0,
                bottom: 0,
                width,
                height,
                margin: "auto"
            });
        }
        absolute(left, top, right, bottom) {
            left = cssNumberToString(left);
            top = cssNumberToString(top);
            if (right !== undefined) {
                right = cssNumberToString(right);
                bottom = cssNumberToString(bottom);
                return this.merge({
                    position: "absolute",
                    left,
                    top,
                    right,
                    bottom
                });
            }
            return this.merge({
                position: "absolute",
                left,
                top
            });
        }
        merge(style) {
            return new StyleBuilder(Object.assign(Object.assign({}, this.style), style));
        }
    }
    exports.default = StyleBuilder;
});
//# sourceMappingURL=StyleBuilder.js.map