// Code generated by scripts/gen-clone.go; DO NOT EDIT.

package store

import (
	"maps"
	"slices"
)

// deepCloneTask returns a full copy of t, duplicating all slices, maps, and
// pointer-bearing fields so callers can safely mutate the returned value.
func deepCloneTask(t *Task) Task {
	if t == nil {
		return Task{}
	}

	cp := *t
	cp.PromptHistory = slices.Clone(t.PromptHistory)
	cp.RetryHistory = slices.Clone(t.RetryHistory)
	cp.RefineSessions = cloneRefinementSessionSlice(t.RefineSessions)
	cp.CustomPassPatterns = slices.Clone(t.CustomPassPatterns)
	cp.CustomFailPatterns = slices.Clone(t.CustomFailPatterns)
	cp.Tags = slices.Clone(t.Tags)
	cp.DependsOn = slices.Clone(t.DependsOn)
	cp.TruncatedTurns = slices.Clone(t.TruncatedTurns)
	cp.SandboxByActivity = maps.Clone(t.SandboxByActivity)
	cp.UsageBreakdown = maps.Clone(t.UsageBreakdown)
	cp.WorktreePaths = maps.Clone(t.WorktreePaths)
	cp.CommitHashes = maps.Clone(t.CommitHashes)
	cp.BaseCommitHashes = maps.Clone(t.BaseCommitHashes)
	cp.SnapshotDiffs = maps.Clone(t.SnapshotDiffs)
	cp.AutoRetryBudget = maps.Clone(t.AutoRetryBudget)

	if t.CurrentRefinement != nil {
		currentRefinement := *t.CurrentRefinement
		cp.CurrentRefinement = &currentRefinement
	}
	if t.SessionID != nil {
		sessionID := *t.SessionID
		cp.SessionID = &sessionID
	}
	if t.Result != nil {
		result := *t.Result
		cp.Result = &result
	}
	if t.StopReason != nil {
		stopReason := *t.StopReason
		cp.StopReason = &stopReason
	}
	if t.Environment != nil {
		environment := *t.Environment
		cp.Environment = &environment
	}
	if t.StartedAt != nil {
		startedAt := *t.StartedAt
		cp.StartedAt = &startedAt
	}
	if t.ModelOverride != nil {
		modelOverride := *t.ModelOverride
		cp.ModelOverride = &modelOverride
	}
	if t.ScheduledAt != nil {
		scheduledAt := *t.ScheduledAt
		cp.ScheduledAt = &scheduledAt
	}
	if t.LastFetchErrorAt != nil {
		lastFetchErrorAt := *t.LastFetchErrorAt
		cp.LastFetchErrorAt = &lastFetchErrorAt
	}

	return cp
}
