Trimming copies the frames between round(start x sampleRate) and round(end x sampleRate) of every channel into a new buffer. Nothing is re-encoded at that point: the frames are the decoder's own, and no frame inside the cut is dropped or doubled.
Fades multiply each frame by a straight line. In a fade of N frames the i-th frame is multiplied by i/(N-1) on the way in and by (N-1-i)/(N-1) on the way out, so the outer frame is exactly zero and the inner frame is untouched. When both fades together are longer than the selection they are scaled down until they meet exactly.
Normalization finds the largest absolute frame in the faded selection and multiplies every channel by the same factor, 10^(target/20) divided by that peak. One factor for all channels keeps the stereo image where it was. The target is a peak ceiling, not a loudness.
A change of sample rate or channel count goes to the browser's OfflineAudioContext, which resamples the buffer and mixes stereo to mono as (L+R)/2. When the rate and the channels already match, that stage is skipped so the samples stay exactly the ones the decoder produced.
The WAV writer builds the 44-byte RIFF header (PCM, 16 or 24 bits, the chosen rate and channels) and writes the samples little-endian, clamped at full scale. Frames x channels x bytes per sample is the data size, so the header length and the file length always agree.
The decoder is opened at the rate the file declares, read from the container header (RIFF/WAVE, AIFF, FLAC, Ogg, MP3 frame header or the MP4 mdhd box), so loading a 48 kHz file does not quietly resample it to 44.1 kHz. When that declaration cannot be read - a WebM or a stream with no header the page understands - the browser's default rate is used and the message above the waveform says so; "original rate" then means the rate the file was decoded at, which the source line shows.