def es.chain
import bend-kit-zlib@0.5.1.0/zlib.bend as Zlibimport Base
import bend-kit-bits@0.1.0.1/bits.bend as Bits
959# ponytail: greedy parse, 32 chain steps; lazy matching would compress text further.
960def es.chain(r: Lz & U32, w: Bits.Writer, +i: U32, +n: U32) -> Es:
961 (z, +c) = r
962 +room = (n - i : U32)
963 +max = Bool.pick(U32, U32.is_lt(room, 258), room, 258)
964 es.pick(ch.go(32n, Ch{z, i, c, max, 0, 0, ch.ok(i, c, max, 0)}), w, n)