src/Models/IntegrationFlow.ps1

# IntegrationFlow — Modelo del flujo Integrate (replica IntegrationFlowModel del v2).
#
# 4 inputs + flag opcional. La screen edita estas properties; cuando todas las
# *Valid son true, el botón Execute se habilita y al presionar Enter dispara los
# 5 pasos: create branch from target → merge source → version bump (si hay
# package.json) → push (con/sin --no-verify) → ofrecer PR url.
#
# Sin lógica de ejecución acá — eso vive en IntegrateScreen. Este modelo es
# data + validación pura.

class IntegrationFlow {
    [string] $TargetBranch = ''      # 'origin/<name>' destino contra el que se integra
    [bool]   $TargetValid = $false

    [string] $NewBranchName = ''     # nombre de la branch nueva a crear
    [bool]   $NameValid = $false

    [string] $SourceBranch = ''      # branch local que se mergea en la nueva
    [bool]   $SourceValid = $false

    [bool]   $NoVerifyPush = $false  # push con --no-verify (skip pre-push hooks)

    IntegrationFlow() { }

    [bool] IsReadyToExecute() {
        return $this.TargetValid -and $this.NameValid -and $this.SourceValid
    }

    [void] SetTarget([string]$value) {
        $this.TargetBranch = if ($null -eq $value) { '' } else { $value.Trim() }
        $this.TargetValid = -not [string]::IsNullOrWhiteSpace($this.TargetBranch)
    }

    [void] SetName([string]$value) {
        $this.NewBranchName = if ($null -eq $value) { '' } else { $value.Trim() }
        $this.NameValid = -not [string]::IsNullOrWhiteSpace($this.NewBranchName)
    }

    [void] SetSource([string]$value) {
        $this.SourceBranch = if ($null -eq $value) { '' } else { $value.Trim() }
        $this.SourceValid = -not [string]::IsNullOrWhiteSpace($this.SourceBranch)
    }

    [void] ToggleNoVerify() {
        $this.NoVerifyPush = -not $this.NoVerifyPush
    }
}