function runMigrationChain(e){if(typeof e.value!=`object`||e.value===null)throw Error(`${e.label}: value has no numeric "version" field.`);let t=e.value.version,n;if(typeof t==`number`)n=e.value;else if(!(`version`in e.value)&&e.initialVersion!==void 0)n={...e.value,version:e.initialVersion};else throw Error(`${e.label}: value has no numeric "version" field.`);let r=e.initialVersion??1;if(!Number.isInteger(n.version)||n.version<r)throw Error(`${e.label}: version ${n.version} is not a positive integer.`);if(n.version>e.targetVersion)throw Error(`${e.label}: encountered version ${n.version}, which is newer than the supported version ${e.targetVersion}. This usually indicates the wire was written by a newer Eve deployment than the one reading it.`);for(;n.version<e.targetVersion;){let t=e.migrations.find(e=>e.from===n.version);if(!t)throw Error(`${e.label}: no migration registered for version ${n.version} → ${n.version+1}.`);if(t.to!==t.from+1)throw Error(`${e.label}: migration ${t.from} → ${t.to} must step exactly one version at a time.`);let r=t.migrate(n);if(r.version!==t.to)throw Error(`${e.label}: migration ${t.from} → ${t.to} produced a value with version ${r.version}.`);n=r}return n}export{runMigrationChain};