fn(remote$0, content_limit$1, events$2, index$3, limit$4, count$5, errors$6, then$7) =>
match @core.less-than(left: $5, right: $4) {
false =>
$7(summary: {count: $5, errors: $6}),
true =>
match @core.list-get(list: $2, index: $3) {
#none(_) =>
$7(summary: {count: $5, errors: $6}),
#some(event$8) =>
@definy.mirror-fetch-and-sync-event(
remote: $0,
content_limit: $1,
event: $8,
then: fn(result$9) =>
let label$10 = @std.string-join(items: [$8.event_type, " ", $8.event_hash, ": "], separator: "");
match $9 {
#stored(_) =>
@definy.mirror-events-loop(
remote: $0,
content_limit: $1,
events: $2,
index: @core.plus(left: $3, right: 1),
limit: $4,
count: @core.plus(left: $5, right: 1),
errors: $6,
then: fn(summary$13) =>
$7(summary: $13)
),
#partial(message$11) =>
$7(
summary: {
count: $5,
errors: @core.list-append(list: $6, item: @std.string-join(items: [$10, $11], separator: ""))
}
),
#failed(message$12) =>
@definy.mirror-events-loop(
remote: $0,
content_limit: $1,
events: $2,
index: @core.plus(left: $3, right: 1),
limit: $4,
count: $5,
errors: @core.list-append(list: $6, item: @std.string-join(items: [$10, $12], separator: "")),
then: fn(summary$14) =>
$7(summary: $14)
)
}
)
}
}