package model

import (
	json "encoding/json"

	easyjson "github.com/mailru/easyjson"
	jlexer "github.com/mailru/easyjson/jlexer"
	jwriter "github.com/mailru/easyjson/jwriter"
)

var (
	_ *json.RawMessage
	_ *jlexer.Lexer
	_ *jwriter.Writer
	_ easyjson.Marshaler
)

func easyjsonC5568b25DecodeGithubComPrometheusCommonModel(in *jlexer.Lexer, out *Vector) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		in.Skip()
		*out = nil
	} else {
		in.Delim('[')
		if *out == nil {
			if !in.IsDelim(']') {
				*out = make(Vector, 0, 8)
			} else {
				*out = Vector{}
			}
		} else {
			*out = (*out)[:0]
		}
		for !in.IsDelim(']') {
			var v1 *Sample
			if in.IsNull() {
				in.Skip()
				v1 = nil
			} else {
				if v1 == nil {
					v1 = new(Sample)
				}
				(*v1).UnmarshalEasyJSON(in)
			}
			*out = append(*out, v1)
			in.WantComma()
		}
		in.Delim(']')
	}
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonC5568b25EncodeGithubComPrometheusCommonModel(out *jwriter.Writer, in Vector) {
	if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
		out.RawString("null")
	} else {
		out.RawByte('[')
		for v2, v3 := range in {
			if v2 > 0 {
				out.RawByte(',')
			}
			if v3 == nil {
				out.RawString("null")
			} else {
				(*v3).MarshalEasyJSON(out)
			}
		}
		out.RawByte(']')
	}
}

func (v Vector) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

func (v Vector) MarshalEasyJSON(w *jwriter.Writer) {
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel(w, v)
}

func (v *Vector) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel(&r, v)
	return r.Error()
}

func (v *Vector) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel(l, v)
}
func easyjsonC5568b25DecodeGithubComPrometheusCommonModel1(in *jlexer.Lexer, out *SampleStream) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeString()
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "metric":
			if in.IsNull() {
				in.Skip()
			} else {
				in.Delim('{')
				if !in.IsDelim('}') {
					out.Metric = make(Metric)
				} else {
					out.Metric = nil
				}
				for !in.IsDelim('}') {
					key := LabelName(in.String())
					in.WantColon()
					var v4 LabelValue
					v4 = LabelValue(in.String())
					(out.Metric)[key] = v4
					in.WantComma()
				}
				in.Delim('}')
			}
		case "values":
			if in.IsNull() {
				in.Skip()
				out.Values = nil
			} else {
				in.Delim('[')
				if out.Values == nil {
					if !in.IsDelim(']') {
						out.Values = make([]SamplePair, 0, 4)
					} else {
						out.Values = []SamplePair{}
					}
				} else {
					out.Values = (out.Values)[:0]
				}
				for !in.IsDelim(']') {
					var v5 SamplePair
					(v5).UnmarshalEasyJSON(in)
					out.Values = append(out.Values, v5)
					in.WantComma()
				}
				in.Delim(']')
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonC5568b25EncodeGithubComPrometheusCommonModel1(out *jwriter.Writer, in SampleStream) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"metric\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		(in.Metric).MarshalEasyJSON(out)
	}
	{
		const prefix string = ",\"values\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		if in.Values == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
			out.RawString("null")
		} else {
			out.RawByte('[')
			for v6, v7 := range in.Values {
				if v6 > 0 {
					out.RawByte(',')
				}
				(v7).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	out.RawByte('}')
}

func (v SampleStream) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel1(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

func (v SampleStream) MarshalEasyJSON(w *jwriter.Writer) {
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel1(w, v)
}

func (v *SampleStream) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel1(&r, v)
	return r.Error()
}

func (v *SampleStream) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel1(l, v)
}
func easyjsonC5568b25DecodeGithubComPrometheusCommonModel2(in *jlexer.Lexer, out *Matrix) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		in.Skip()
		*out = nil
	} else {
		in.Delim('[')
		if *out == nil {
			if !in.IsDelim(']') {
				*out = make(Matrix, 0, 8)
			} else {
				*out = Matrix{}
			}
		} else {
			*out = (*out)[:0]
		}
		for !in.IsDelim(']') {
			var v8 *SampleStream
			if in.IsNull() {
				in.Skip()
				v8 = nil
			} else {
				if v8 == nil {
					v8 = new(SampleStream)
				}
				(*v8).UnmarshalEasyJSON(in)
			}
			*out = append(*out, v8)
			in.WantComma()
		}
		in.Delim(']')
	}
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonC5568b25EncodeGithubComPrometheusCommonModel2(out *jwriter.Writer, in Matrix) {
	if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
		out.RawString("null")
	} else {
		out.RawByte('[')
		for v9, v10 := range in {
			if v9 > 0 {
				out.RawByte(',')
			}
			if v10 == nil {
				out.RawString("null")
			} else {
				(*v10).MarshalEasyJSON(out)
			}
		}
		out.RawByte(']')
	}
}

func (v Matrix) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel2(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

func (v Matrix) MarshalEasyJSON(w *jwriter.Writer) {
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel2(w, v)
}

func (v *Matrix) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel2(&r, v)
	return r.Error()
}

func (v *Matrix) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel2(l, v)
}
// Code generated by easyjson for marshaling/unmarshaling. DO NOT EDIT.

package model

import (
	json "encoding/json"

	easyjson "github.com/mailru/easyjson"
	jlexer "github.com/mailru/easyjson/jlexer"
	jwriter "github.com/mailru/easyjson/jwriter"
)

// suppress unused package warning
var (
	_ *json.RawMessage
	_ *jlexer.Lexer
	_ *jwriter.Writer
	_ easyjson.Marshaler
)

func easyjsonC5568b25DecodeGithubComPrometheusCommonModel(in *jlexer.Lexer, out *Vector) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		in.Skip()
		*out = nil
	} else {
		in.Delim('[')
		if *out == nil {
			if !in.IsDelim(']') {
				*out = make(Vector, 0, 8)
			} else {
				*out = Vector{}
			}
		} else {
			*out = (*out)[:0]
		}
		for !in.IsDelim(']') {
			var v1 *Sample
			if in.IsNull() {
				in.Skip()
				v1 = nil
			} else {
				if v1 == nil {
					v1 = new(Sample)
				}
				(*v1).UnmarshalEasyJSON(in)
			}
			*out = append(*out, v1)
			in.WantComma()
		}
		in.Delim(']')
	}
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonC5568b25EncodeGithubComPrometheusCommonModel(out *jwriter.Writer, in Vector) {
	if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
		out.RawString("null")
	} else {
		out.RawByte('[')
		for v2, v3 := range in {
			if v2 > 0 {
				out.RawByte(',')
			}
			if v3 == nil {
				out.RawString("null")
			} else {
				(*v3).MarshalEasyJSON(out)
			}
		}
		out.RawByte(']')
	}
}

// MarshalJSON supports json.Marshaler interface
func (v Vector) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Vector) MarshalEasyJSON(w *jwriter.Writer) {
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *Vector) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Vector) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel(l, v)
}
func easyjsonC5568b25DecodeGithubComPrometheusCommonModel1(in *jlexer.Lexer, out *SampleStream) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		if isTopLevel {
			in.Consumed()
		}
		in.Skip()
		return
	}
	in.Delim('{')
	for !in.IsDelim('}') {
		key := in.UnsafeString()
		in.WantColon()
		if in.IsNull() {
			in.Skip()
			in.WantComma()
			continue
		}
		switch key {
		case "metric":
			if in.IsNull() {
				in.Skip()
			} else {
				in.Delim('{')
				if !in.IsDelim('}') {
					out.Metric = make(Metric)
				} else {
					out.Metric = nil
				}
				for !in.IsDelim('}') {
					key := LabelName(in.String())
					in.WantColon()
					var v4 LabelValue
					v4 = LabelValue(in.String())
					(out.Metric)[key] = v4
					in.WantComma()
				}
				in.Delim('}')
			}
		case "values":
			if in.IsNull() {
				in.Skip()
				out.Values = nil
			} else {
				in.Delim('[')
				if out.Values == nil {
					if !in.IsDelim(']') {
						out.Values = make([]SamplePair, 0, 4)
					} else {
						out.Values = []SamplePair{}
					}
				} else {
					out.Values = (out.Values)[:0]
				}
				for !in.IsDelim(']') {
					var v5 SamplePair
					(v5).UnmarshalEasyJSON(in)
					out.Values = append(out.Values, v5)
					in.WantComma()
				}
				in.Delim(']')
			}
		default:
			in.SkipRecursive()
		}
		in.WantComma()
	}
	in.Delim('}')
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonC5568b25EncodeGithubComPrometheusCommonModel1(out *jwriter.Writer, in SampleStream) {
	out.RawByte('{')
	first := true
	_ = first
	{
		const prefix string = ",\"metric\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		(in.Metric).MarshalEasyJSON(out)
	}
	{
		const prefix string = ",\"values\":"
		if first {
			first = false
			out.RawString(prefix[1:])
		} else {
			out.RawString(prefix)
		}
		if in.Values == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
			out.RawString("null")
		} else {
			out.RawByte('[')
			for v6, v7 := range in.Values {
				if v6 > 0 {
					out.RawByte(',')
				}
				(v7).MarshalEasyJSON(out)
			}
			out.RawByte(']')
		}
	}
	out.RawByte('}')
}

// MarshalJSON supports json.Marshaler interface
func (v SampleStream) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel1(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v SampleStream) MarshalEasyJSON(w *jwriter.Writer) {
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel1(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *SampleStream) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel1(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *SampleStream) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel1(l, v)
}
func easyjsonC5568b25DecodeGithubComPrometheusCommonModel2(in *jlexer.Lexer, out *Matrix) {
	isTopLevel := in.IsStart()
	if in.IsNull() {
		in.Skip()
		*out = nil
	} else {
		in.Delim('[')
		if *out == nil {
			if !in.IsDelim(']') {
				*out = make(Matrix, 0, 8)
			} else {
				*out = Matrix{}
			}
		} else {
			*out = (*out)[:0]
		}
		for !in.IsDelim(']') {
			var v8 *SampleStream
			if in.IsNull() {
				in.Skip()
				v8 = nil
			} else {
				if v8 == nil {
					v8 = new(SampleStream)
				}
				(*v8).UnmarshalEasyJSON(in)
			}
			*out = append(*out, v8)
			in.WantComma()
		}
		in.Delim(']')
	}
	if isTopLevel {
		in.Consumed()
	}
}
func easyjsonC5568b25EncodeGithubComPrometheusCommonModel2(out *jwriter.Writer, in Matrix) {
	if in == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 {
		out.RawString("null")
	} else {
		out.RawByte('[')
		for v9, v10 := range in {
			if v9 > 0 {
				out.RawByte(',')
			}
			if v10 == nil {
				out.RawString("null")
			} else {
				(*v10).MarshalEasyJSON(out)
			}
		}
		out.RawByte(']')
	}
}

// MarshalJSON supports json.Marshaler interface
func (v Matrix) MarshalJSON() ([]byte, error) {
	w := jwriter.Writer{}
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel2(&w, v)
	return w.Buffer.BuildBytes(), w.Error
}

// MarshalEasyJSON supports easyjson.Marshaler interface
func (v Matrix) MarshalEasyJSON(w *jwriter.Writer) {
	easyjsonC5568b25EncodeGithubComPrometheusCommonModel2(w, v)
}

// UnmarshalJSON supports json.Unmarshaler interface
func (v *Matrix) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel2(&r, v)
	return r.Error()
}

// UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (v *Matrix) UnmarshalEasyJSON(l *jlexer.Lexer) {
	easyjsonC5568b25DecodeGithubComPrometheusCommonModel2(l, v)
}
