import { numberAndUnit } from "../modules/core/regex.js";
//#region node_modules/@svgdotjs/svg.js/src/types/SVGNumber.js
var SVGNumber = class SVGNumber {
	constructor(...args) {
		this.init(...args);
	}
	convert(unit) {
		return new SVGNumber(this.value, unit);
	}
	divide(number) {
		number = new SVGNumber(number);
		return new SVGNumber(this / number, this.unit || number.unit);
	}
	init(value, unit) {
		unit = Array.isArray(value) ? value[1] : unit;
		value = Array.isArray(value) ? value[0] : value;
		this.value = 0;
		this.unit = unit || "";
		if (typeof value === "number") this.value = isNaN(value) ? 0 : !isFinite(value) ? value < 0 ? -34e37 : 34e37 : value;
		else if (typeof value === "string") {
			unit = value.match(numberAndUnit);
			if (unit) {
				this.value = parseFloat(unit[1]);
				if (unit[5] === "%") this.value /= 100;
				else if (unit[5] === "s") this.value *= 1e3;
				this.unit = unit[5];
			}
		} else if (value instanceof SVGNumber) {
			this.value = value.valueOf();
			this.unit = value.unit;
		}
		return this;
	}
	minus(number) {
		number = new SVGNumber(number);
		return new SVGNumber(this - number, this.unit || number.unit);
	}
	plus(number) {
		number = new SVGNumber(number);
		return new SVGNumber(this + number, this.unit || number.unit);
	}
	times(number) {
		number = new SVGNumber(number);
		return new SVGNumber(this * number, this.unit || number.unit);
	}
	toArray() {
		return [this.value, this.unit];
	}
	toJSON() {
		return this.toString();
	}
	toString() {
		return (this.unit === "%" ? ~~(this.value * 1e8) / 1e6 : this.unit === "s" ? this.value / 1e3 : this.value) + this.unit;
	}
	valueOf() {
		return this.value;
	}
};
//#endregion
export { SVGNumber as default };
