import { getLatestMediaEngine } from "../tasks/makeMediaEngineTask.js";
import { Task } from "@lit/task";
const makeScrubVideoSegmentIdTask = (host) => {
	return new Task(host, {
		args: () => [host.mediaEngineTask.value, host.desiredSeekTimeMs],
		onError: (error) => {
			console.error("scrubVideoSegmentIdTask error", error);
		},
		onComplete: (_value) => {},
		task: async ([, targetSeekTimeMs], { signal }) => {
			const mediaEngine = await getLatestMediaEngine(host, signal);
			signal.throwIfAborted();
			const scrubRendition = mediaEngine.getScrubVideoRendition();
			if (!scrubRendition) return void 0;
			return mediaEngine.computeSegmentId(targetSeekTimeMs, {
				...scrubRendition,
				src: mediaEngine.src
			});
		}
	});
};
export { makeScrubVideoSegmentIdTask };
