import { CombinatorRestatePromise, ConstRestatePromise, InternalRestatePromise } from "./promises.js";

//#region src/context.ts
const InvocationIdParser = { fromString(id) {
	if (!id.startsWith("inv")) throw new Error(`Expected invocation id to start with 'inv' but got ${id}`);
	return id;
} };
const RestatePromise = {
	resolve(value) {
		if (value instanceof InternalRestatePromise) return value;
		return ConstRestatePromise.resolve(value);
	},
	reject(reason) {
		return ConstRestatePromise.reject(reason);
	},
	all(values) {
		return CombinatorRestatePromise.fromPromises((p) => Promise.all(p), values);
	},
	race(values) {
		if (values.length === 0) return ConstRestatePromise.pending();
		return CombinatorRestatePromise.fromPromises((p) => Promise.race(p), values);
	},
	any(values) {
		return CombinatorRestatePromise.fromPromises((p) => Promise.any(p), values);
	},
	allSettled(values) {
		return CombinatorRestatePromise.fromPromises((p) => Promise.allSettled(p), values);
	}
};

//#endregion
export { InvocationIdParser, RestatePromise };
//# sourceMappingURL=context.js.map