package app

import (
	
	
	
	
	

	
)

func toString( any) string {
	switch v := .(type) {
	case string:
		return 

	case []byte:
		return string()

	case int:
		return strconv.Itoa()

	case float64:
		return strconv.FormatFloat(, 'f', 4, 64)

	case bool:
		return strconv.FormatBool()

	case nil:
		return ""

	default:
		return fmt.Sprint()
	}
}

func toPath( ...any) string {
	var  strings.Builder

	for ,  := range  {
		 := toString()
		if  == "" {
			continue
		}
		.WriteByte('/')
		.WriteString()
	}

	return .String()
}

func stringTo( string,  any) error {
	 := reflect.ValueOf()

	if .Kind() != reflect.Ptr {
		return errors.New("receiver in not a pointer").WithTag("receiver-type", .Type())
	}
	 = .Elem()

	switch .Kind() {
	case reflect.String:
		.SetString()

	case reflect.Int,
		reflect.Int8,
		reflect.Int16,
		reflect.Int32,
		reflect.Int64:
		,  := strconv.ParseInt(, 10, 0)
		.SetInt()

	case reflect.Uint,
		reflect.Uint8,
		reflect.Uint16,
		reflect.Uint32,
		reflect.Uint64:
		,  := strconv.ParseUint(, 10, 0)
		.SetUint()

	case reflect.Float64:
		,  := strconv.ParseFloat(, 64)
		.SetFloat()

	case reflect.Float32:
		,  := strconv.ParseFloat(, 32)
		.SetFloat()

	default:
		return errors.New("string cannot be converted to receiver type").
			WithTag("string", ).
			WithTag("receiver-type", .Type())
	}

	return nil
}

// AppendClass adds values to the given class string.
func ( string,  ...string) string {
	var  strings.Builder
	.WriteString(strings.TrimSpace())

	for ,  := range  {
		 = strings.TrimSpace()
		if  == "" {
			continue
		}

		if .Len() != 0 {
			.WriteByte(' ')
		}
		.WriteString()
	}

	return .String()
}

func jsonString( any) string {
	,  := json.Marshal()
	if  != nil {
		panic(errors.New("converting value to json string failed").Wrap())
	}
	return string()
}

// Formats a string with the given format and values.
// It uses fmt.Sprintf when len(v) != 0.
//
// TODO: Write a faster Sprintf to use with values.
func ( string,  ...any) string {
	if len() == 0 {
		return 
	}
	return fmt.Sprintf(, ...)
}

func previewText( string) string {
	if len() <= 80 {
		return 
	}
	return [:77] + "..."
}