package decoder

import (
	
	
	
	

	
)

type bytesDecoder struct {
	typ           reflect.Type
	sliceDecoder  Decoder
	stringDecoder *stringDecoder
	structName    string
	fieldName     string
	// sliceType is the type of the slice, which the type errors report.
	sliceType reflect.Type
}

func byteUnmarshalerSliceDecoder( reflect.Type,  string,  string) Decoder {
	var  Decoder
	switch {
	case reflect.PointerTo().Implements(unmarshalJSONType):
		 = newUnmarshalJSONDecoder(reflect.PointerTo())
	case reflect.PointerTo().Implements(unmarshalTextType):
		 = newUnmarshalTextDecoder(reflect.PointerTo())
	default:
		, _ = compileUint8(, , )
	}
	return newSliceDecoder(, , 1, , )
}

func newBytesDecoder( reflect.Type,  string,  string) *bytesDecoder {
	return &bytesDecoder{
		typ:           ,
		sliceType:     reflect.SliceOf(),
		sliceDecoder:  byteUnmarshalerSliceDecoder(, , ),
		stringDecoder: newStringDecoder(, ),
		structName:    ,
		fieldName:     ,
	}
}

func ( *bytesDecoder) ( *RuntimeContext, ,  int64,  unsafe.Pointer) (int64, error) {
	 = skipWhiteSpace(.Buf, )
	 := 
	, ,  := .decodeBinary(, , , )
	if  != nil {
		if  := .Buf[];  != '[' && isOtherValue(, stringValue) {
			return .skipTypeError(, , .sliceType)
		}
		return 0, 
	}
	if  == nil {
		return , nil
	}
	 = 
	 := base64.StdEncoding.DecodedLen(len())
	 := make([]byte, )
	,  := base64.StdEncoding.Decode(, )
	if  != nil {
		.base64Error(, , .sliceType, )
		return , nil
	}
	*(*[]byte)() = [:]
	return , nil
}

func ( *bytesDecoder) ( *RuntimeContext, ,  int64) ([][]byte, int64, error) {
	return nil, 0, fmt.Errorf("json: []byte decoder does not support decode path")
}

func ( *bytesDecoder) ( *RuntimeContext, ,  int64,  unsafe.Pointer) ([]byte, int64, error) {
	 := .Buf
	 = skipWhiteSpace(, )
	if [] == '[' {
		if .sliceDecoder == nil {
			return nil, 0, &errors.UnmarshalTypeError{
				Type:   .typ,
				Offset: ,
			}
		}
		,  := .sliceDecoder.Decode(, , , )
		if  != nil {
			return nil, 0, 
		}
		return nil, , nil
	}
	return .stringDecoder.decodeByte(, )
}