/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-e694c50 | Cube Dev Team */
//#region src/_internal/hooks/use-timer/timer.ts
var Timer = class {
	callback;
	delay;
	remaining;
	timerId = null;
	startTime = null;
	_status = "stopped";
	get status() {
		return this._status;
	}
	set status(status) {
		this._status = status;
	}
	constructor(callback, delay) {
		this.callback = callback;
		this.delay = delay;
		this.remaining = delay;
		this.resume();
	}
	reset() {
		this.clear();
		this.remaining = this.delay;
		this.status = "stopped";
	}
	pause() {
		if (this.timerId === null || this.startTime === null) return;
		this.clear();
		this.remaining -= Date.now() - this.startTime;
		this.status = "paused";
	}
	resume() {
		if (this.timerId !== null) return;
		this.startTime = Date.now();
		this.clear();
		this.timerId = setTimeout(() => {
			this.reset();
			this.callback();
		}, this.remaining);
		this.status = "running";
	}
	clear() {
		if (this.timerId === null) return;
		clearTimeout(this.timerId);
		this.timerId = null;
	}
};

//#endregion
export { Timer };
//# sourceMappingURL=timer.js.map