import { GenericVersioningApi } from "../generic.js";
import { DistroInfo } from "../distro.js";
import { RollingReleasesData } from "./common.js";

//#region lib/modules/versioning/debian/index.ts
const id = "debian";
var DebianVersioningApi = class extends GenericVersioningApi {
	_distroInfo;
	_rollingReleases;
	constructor() {
		super();
		this._distroInfo = new DistroInfo("data/debian-distro-info.json");
		this._rollingReleases = new RollingReleasesData(this._distroInfo);
	}
	isValid(version) {
		const isValid = super.isValid(version);
		let ver;
		ver = this._rollingReleases.getVersionByLts(version);
		ver = this._distroInfo.getVersionByCodename(ver);
		return isValid && this._distroInfo.isCreated(ver);
	}
	isStable(version) {
		let ver;
		ver = this._rollingReleases.getVersionByLts(version);
		ver = this._distroInfo.getVersionByCodename(ver);
		return this._distroInfo.isReleased(ver) && !this._distroInfo.isEolLts(ver);
	}
	getNewValue({ currentValue, newVersion }) {
		if (this._rollingReleases.has(currentValue)) return this._rollingReleases.getLtsByVersion(newVersion);
		if (this._distroInfo.isCodename(currentValue)) {
			const di = this._rollingReleases.schedule(newVersion);
			let ver = newVersion;
			if (di) ver = di.version;
			return this._distroInfo.getCodenameByVersion(ver);
		}
		if (this._rollingReleases.has(newVersion)) return this._rollingReleases.schedule(newVersion).version;
		return this._distroInfo.getVersionByCodename(newVersion);
	}
	_parse(version) {
		let ver;
		ver = this._rollingReleases.getVersionByLts(version);
		ver = this._distroInfo.getVersionByCodename(ver);
		if (!this._distroInfo.exists(ver)) return null;
		return { release: ver.split(".").map(Number) };
	}
};
const api = new DebianVersioningApi();

//#endregion
export { api as default, id };
//# sourceMappingURL=index.js.map