You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: crop_decoder.go
    path of file: ./repos/tania-core/backend/src/growth/decoder
    
    the code of the file until where you have to start completion: package decoder

import (
	"encoding/json"
	"errors"
	"time"

	"github.com/gofrs/uuid"
	"github.com/mitchellh/mapstructure"
	"github.com/usetania/tania-core/src/growth/domain"
)

type CropEventWrapper InterfaceWrapper

func (w *CropEventWrapper) UnmarshalJSON(b []byte) error {
	wrapper := InterfaceWrapper{}

	err := json.Unmarshal(b, &wrapper)
	if err != nil {
		return err
	}

	mapped, ok := wrapper.Data.(map[string]interface{})
	if !ok {
		return errors.New("error type assertion")
	}

	f := mapstructure.ComposeDecodeHookFunc(
		UIDHook(),
		TimeHook(time.RFC3339),
		CropContainerHook(),
	)

	switch wrapper.Name {
	case "CropBatchCreated":
		e := domain.CropBatchCreated{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchTypeChanged":
		e := domain.CropBatchTypeChanged{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchInventoryChanged":
		e := domain.CropBatchInventoryChanged{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchContainerChanged":
		e := domain.CropBatchContainerChanged{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchMoved":
		e := domain.CropBatchMoved{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		// This decoding is too complex so we do this here instead in DecodeHookFunc
		if v, ok := mapped["UpdatedSrcArea"]; ok {
			code, ok2 := mapped["UpdatedSrcAreaCode"].(string)
			if !ok2 {
				return errors.New("error type assertion")
			}

			if code == "INITIAL_AREA" {
				initialArea, err := makeCropInitialArea(v)
				if err != nil {
					return err
				}

				e.UpdatedSrcArea = initialArea
			}

			if code == "MOVED_AREA" {
				movedArea, err := makeCropMovedArea(v)
				if err != nil {
					return err
				}

				e.UpdatedSrcArea = movedArea
			}
		}

		if v, ok := mapped["UpdatedDstArea"]; ok {
			code, ok2 := mapped["UpdatedDstAreaCode"].(string)
			if !ok2 {
				return errors.New("error type assertion")
			}

			if code == "INITIAL_AREA" {
				initialArea, err := makeCropInitialArea(v)
				if err != nil {
					return err
				}

				e.UpdatedDstArea = initialArea
			}

			if code == "MOVED_AREA" {
				movedArea, err := makeCropMovedArea(v)
				if err != nil {
					return err
				}

				e.UpdatedDstArea = movedArea
			}
		}

		w.Data = e

	case "CropBatchHarvested":
		e := domain.CropBatchHarvested{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		// This decoding is too complex so we do this here instead in DecodeHookFunc
		if v, ok := mapped["UpdatedHarvestedStorage"]; ok {
			mapped2, ok2 := v.(map[string]interface{})
			if !ok2 {
				return errors.New("error type assertion")
			}

			harvestedStorage := domain.HarvestedStorage{}

			if v2, ok2 := mapped2["quantity"]; ok2 {
				val, ok3 := v2.(float64)
				if !ok3 {
					return errors.New("error type assertion")
				}

				harvestedStorage.Quantity = int(val)
			}

			if v2, ok2 := mapped2["produced_gram_quantity"]; ok2 {
				val, ok3 := v2.(float64)
				if !ok3 {
					return errors.New("error type assertion")
				}

				harvestedStorage.ProducedGramQuantity = float32(val)
			}

			if v2, ok2 := mapped2["source_area_id"]; ok2 {
				uid, err := makeUUID(v2)
				if err != nil {
					return err
				}

				harvestedStorage.SourceAreaUID = uid
			}

			if v2, ok2 := mapped2["created_date"]; ok2 {
				val, err := makeTime(v2)
				if err != nil {
					return err
				}

				harvestedStorage.CreatedDate = val
			}

			if v2, ok2 := mapped2["last_updated"]; ok2 {
				val, err := makeTime(v2)
				if err != nil {
					return err
				}

				harvestedStorage.LastUpdated = val
			}

			e.UpdatedHarvestedStorage = harvestedStorage
		}

		if v, ok := mapped["HarvestedArea"]; ok {
			code, ok2 := mapped["HarvestedAreaCode"].(string)
			if !ok2 {
				return errors.New("error type assertion")
			}

			if code == "INITIAL_AREA" {
				initialArea, err := makeCropInitialArea(v)
				if err != nil {
					return err
				}

				e.HarvestedArea = initialArea
			}

			if code == "MOVED_AREA" {
				movedArea, err := makeCropMovedArea(v)
				if err != nil {
					return err
				}

				e.HarvestedArea = movedArea
			}
		}

		w.Data = e

	case "CropBatchDumped":
		e := domain.CropBatchDumped{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		if v, ok := mapped["UpdatedTrash"]; ok {
			mapp
    
func (w *CropEventWrapper) UnmarshalJSON(b []byte) error {
	wrapper := InterfaceWrapper{}

	err := json.Unmarshal(b, &wrapper)
	if err != nil {
		return err
	}

	mapped, ok := wrapper.Data.(map[string]interface{})
	if !ok {
		return errors.New("error type assertion")
	}

	f := mapstructure.ComposeDecodeHookFunc(
		UIDHook(),
		TimeHook(time.RFC3339),
		CropContainerHook(),
	)

	switch wrapper.Name {
	case "CropBatchCreated":
		e := domain.CropBatchCreated{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchTypeChanged":
		e := domain.CropBatchTypeChanged{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchInventoryChanged":
		e := domain.CropBatchInventoryChanged{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchContainerChanged":
		e := domain.CropBatchContainerChanged{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchMoved":
		e := domain.CropBatchMoved{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		// This decoding is too complex so we do this here instead in DecodeHookFunc
		if v, ok := mapped["UpdatedSrcArea"]; ok {
			code, ok2 := mapped["UpdatedSrcAreaCode"].(string)
			if !ok2 {
				return errors.New("error type assertion")
			}

			if code == "INITIAL_AREA" {
				initialArea, err := makeCropInitialArea(v)
				if err != nil {
					return err
				}

				e.UpdatedSrcArea = initialArea
			}

			if code == "MOVED_AREA" {
				movedArea, err := makeCropMovedArea(v)
				if err != nil {
					return err
				}

				e.UpdatedSrcArea = movedArea
			}
		}

		if v, ok := mapped["UpdatedDstArea"]; ok {
			code, ok2 := mapped["UpdatedDstAreaCode"].(string)
			if !ok2 {
				return errors.New("error type assertion")
			}

			if code == "INITIAL_AREA" {
				initialArea, err := makeCropInitialArea(v)
				if err != nil {
					return err
				}

				e.UpdatedDstArea = initialArea
			}

			if code == "MOVED_AREA" {
				movedArea, err := makeCropMovedArea(v)
				if err != nil {
					return err
				}

				e.UpdatedDstArea = movedArea
			}
		}

		w.Data = e

	case "CropBatchHarvested":
		e := domain.CropBatchHarvested{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		// This decoding is too complex so we do this here instead in DecodeHookFunc
		if v, ok := mapped["UpdatedHarvestedStorage"]; ok {
			mapped2, ok2 := v.(map[string]interface{})
			if !ok2 {
				return errors.New("error type assertion")
			}

			harvestedStorage := domain.HarvestedStorage{}

			if v2, ok2 := mapped2["quantity"]; ok2 {
				val, ok3 := v2.(float64)
				if !ok3 {
					return errors.New("error type assertion")
				}

				harvestedStorage.Quantity = int(val)
			}

			if v2, ok2 := mapped2["produced_gram_quantity"]; ok2 {
				val, ok3 := v2.(float64)
				if !ok3 {
					return errors.New("error type assertion")
				}

				harvestedStorage.ProducedGramQuantity = float32(val)
			}

			if v2, ok2 := mapped2["source_area_id"]; ok2 {
				uid, err := makeUUID(v2)
				if err != nil {
					return err
				}

				harvestedStorage.SourceAreaUID = uid
			}

			if v2, ok2 := mapped2["created_date"]; ok2 {
				val, err := makeTime(v2)
				if err != nil {
					return err
				}

				harvestedStorage.CreatedDate = val
			}

			if v2, ok2 := mapped2["last_updated"]; ok2 {
				val, err := makeTime(v2)
				if err != nil {
					return err
				}

				harvestedStorage.LastUpdated = val
			}

			e.UpdatedHarvestedStorage = harvestedStorage
		}

		if v, ok := mapped["HarvestedArea"]; ok {
			code, ok2 := mapped["HarvestedAreaCode"].(string)
			if !ok2 {
				return errors.New("error type assertion")
			}

			if code == "INITIAL_AREA" {
				initialArea, err := makeCropInitialArea(v)
				if err != nil {
					return err
				}

				e.HarvestedArea = initialArea
			}

			if code == "MOVED_AREA" {
				movedArea, err := makeCropMovedArea(v)
				if err != nil {
					return err
				}

				e.HarvestedArea = movedArea
			}
		}

		w.Data = e

	case "CropBatchDumped":
		e := domain.CropBatchDumped{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		if v, ok := mapped["UpdatedTrash"]; ok {
			mapped2, ok2 := v.(map[string]interface{})
			if !ok2 {
				return errors.New("error type assertion")
			}

			trash := domain.Trash{}

			if v2, ok2 := mapped2["quantity"]; ok2 {
				val, ok3 := v2.(float64)
				if !ok3 {
					return errors.New("error type assertion")
				}

				trash.Quantity = int(val)
			}

			if v2, ok2 := mapped2["source_area_id"]; ok2 {
				uid, err := makeUUID(v2)
				if err != nil {
					return err
				}

				trash.SourceAreaUID = uid
			}

			if v2, ok2 := mapped2["created_date"]; ok2 {
				val, err := makeTime(v2)
				if err != nil {
					return err
				}

				trash.CreatedDate = val
			}

			if v2, ok2 := mapped2["last_updated"]; ok2 {
				val, err := makeTime(v2)
				if err != nil {
					return err
				}

				trash.LastUpdated = val
			}

			e.UpdatedTrash = trash
		}

		if v, ok := mapped["DumpedArea"]; ok {
			code, ok2 := mapped["DumpedAreaCode"].(string)
			if !ok2 {
				return errors.New("error type assertion")
			}

			if code == "INITIAL_AREA" {
				initialArea, err := makeCropInitialArea(v)
				if err != nil {
					return err
				}

				e.DumpedArea = initialArea
			}

			if code == "MOVED_AREA" {
				movedArea, err := makeCropMovedArea(v)
				if err != nil {
					return err
				}

				e.DumpedArea = movedArea
			}
		}

		w.Data = e

	case "CropBatchWatered":
		e := domain.CropBatchWatered{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchPhotoCreated":
		e := domain.CropBatchPhotoCreated{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchNoteCreated":
		e := domain.CropBatchNoteCreated{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e

	case "CropBatchNoteRemoved":
		e := domain.CropBatchNoteRemoved{}

		_, err := Decode(f, &mapped, &e)
		if err != nil {
			return err
		}

		w.Data = e
	}

	return nil
}