package oshared

import (
	"strings"
	"time"

	"github.com/tech/sendico/payments/orchestrator/internal/service/orchestrationv2/agg"
)

func CloneExternalRefs(refs []agg.ExternalRef) []agg.ExternalRef {
	if len(refs) == 0 {
		return nil
	}
	out := make([]agg.ExternalRef, 0, len(refs))
	for i := range refs {
		ref := refs[i]
		ref.GatewayInstanceID = strings.TrimSpace(ref.GatewayInstanceID)
		ref.Kind = strings.TrimSpace(ref.Kind)
		ref.Ref = strings.TrimSpace(ref.Ref)
		out = append(out, ref)
	}
	return out
}

func CloneTimeUTC(ts *time.Time) *time.Time {
	if ts == nil {
		return nil
	}
	val := ts.UTC()
	return &val
}
