{{define "up-label"}}{{if .Models.Adding}}{{copy "chat.connections.title"}}{{else}}{{template "settings-up-label" .}}{{end}}{{end}} {{define "up"}}{{if .Models.Adding}}/conversation/settings/connections{{else}}{{template "settings-up" .}}{{end}}{{end}} {{define "title"}}{{if .Models.Adding}}{{copy "chat.connections.add"}}{{else}}{{copy "chat.connections.title"}}{{end}}{{end}} {{define "conn-star"}}{{end}} {{define "conn-copy"}}{{end}} {{define "conn-copy-link"}}{{end}} {{define "conn-sign-in-instead"}}
{{with .}}{{end}}
{{end}} {{define "conn-paste-instead"}}
{{with .}}{{end}}
{{end}} {{define "conn-waiting"}}

{{template "conn-star"}}{{.}}

{{end}} {{define "conn-cancel"}}
{{end}} {{define "conn-attempt"}}
{{template "conn-mark" .Provider}}

{{if .Title}}{{.Title}}{{else if eq .Provider "codex"}}{{copy "chat.connections.title_codex"}}{{else}}{{copy "chat.connections.title_claude"}}{{end}}

{{if .Sub}}{{.Sub}}{{else if eq .Kind "token"}}{{copy "chat.connections.token_sub"}}{{else if .Phrases}}{{copy "chat.connections.loading_sub"}}{{else if eq .Provider "codex"}}{{copy "chat.connections.codex_sub"}}{{else}}{{copy "chat.connections.claude_sub"}}{{end}}

{{if eq .Kind "api_key"}}{{template "conn-api-key" .}}{{else if .SignIn}}{{if .Phrases}}
{{template "conn-star"}}

{{index (split .Phrases "|") 0}}

{{template "conn-cancel" .ID}}
{{else if .Prompt.URL}}
  1. {{icon "external-link"}}{{copy "chat.connections.open_anthropic"}}{{template "conn-copy-link" .Prompt.URL}}
  2. {{if .Prompt.WrongCode}}{{copy "chat.connections.code_wrong"}}{{end}}{{copy "chat.connections.token_sealed"}}{{copy "chat.connections.email_hint"}}
{{template "conn-paste-instead" .Machine}}{{template "conn-cancel" .ID}}
{{else}}{{template "conn-waiting" (copy "chat.connections.waiting_code")}}

{{copy "chat.connections.token_sealed"}}

{{template "conn-cancel" .ID}}
{{end}}{{else if and (not .Prompt) (eq .Kind "token")}}{{template "conn-waiting" (copy "chat.connections.waiting_token")}}

{{copy "chat.connections.token_sealed"}}

{{template "conn-cancel" .ID}}
{{else if not .Prompt}}
{{template "conn-star"}}

{{index (split .Phrases "|") 0}}

{{template "conn-cancel" .ID}}
{{else if eq .Prompt.Kind "device_code"}}
  1. {{icon "external-link"}}{{copy "chat.connections.open_openai"}}{{template "conn-copy-link" .Prompt.URL}}
  2. {{copy "chat.connections.enter_code"}}

    {{.Prompt.Code}}{{template "conn-copy" .Prompt.Code}}

    {{copy "chat.connections.code_once"}}

  3. {{copy "chat.connections.approve_back"}}

{{template "conn-waiting" (copy "chat.connections.waiting_approve")}}

{{copy "chat.connections.device_off"}}

{{copy "chat.connections.codex_fine"}}{{template "conn-cancel" .ID}}
{{else if eq .Prompt.Kind "token"}}
  1. {{copy "chat.connections.token_run"}}

    {{.Prompt.Code}}{{template "conn-copy" .Prompt.Code}}
  2. {{copy "chat.connections.token_approve"}}

  3. {{copy "chat.connections.token_sealed"}}
{{template "conn-sign-in-instead" .Machine}}{{template "conn-cancel" .ID}}
{{else}}
{{template "conn-cancel" .ID}}
{{end}}
{{end}} {{define "conn-api-key"}}{{if and .Prompt (eq .Prompt.Kind "api_key")}}
  1. {{copy "chat.connections.token_sealed"}}
{{else if and .Prompt (eq .Prompt.Kind "model") .Prompt.Models}}

{{copy "chat.connections.metered.model_pick"}}

{{range $i, $m := .Prompt.Models}}{{end}}
{{else if and .Prompt (eq .Prompt.Kind "models") .Prompt.Choices}}

{{copy "chat.connections.metered.models_pick"}}

{{range .Prompt.Choices}}{{end}}

{{copy "chat.connections.metered.models_one"}}

{{else if and .Prompt (or (eq .Prompt.Kind "model") (eq .Prompt.Kind "models"))}}{{template "conn-waiting" (copy "chat.connections.metered.waiting_probe")}} {{else}}{{template "conn-waiting" (copy "chat.connections.metered.waiting_key")}}{{end}}
{{template "conn-cancel" .ID}}
{{end}} {{define "conn-metered-add"}}
{{template "conn-mark" .Provider}}{{.Name}}{{.Desc}}{{icon "chevron-right"}}
{{with .Refused}}

{{.}}

{{end}}

{{.How}} {{.DocsText}}

{{.CannotSee}}

{{copy "chat.connections.metered.budget_legend"}}

{{copy "chat.connections.metered.budget_note"}}

{{end}} {{define "conn-metered-row"}}
{{with .Model}}{{.}}{{end}}{{with .ModelsTooOld}}

{{.}}

{{end}}{{if .ModelsLine}}
{{.ModelsLine}}
{{range .Models}}{{end}}

{{copy "chat.connections.metered.models_one"}}

{{with .ModelsPending}}

{{.}}

{{end}}
{{end}}{{with .Spend}}

{{.}} {{$.SpendTail}}

{{end}} {{with .Paused}}

{{.}}

{{end}} {{with .Unknown}}
{{.}}
{{end}} {{with .Pending}}

{{.}}

{{end}} {{if .BudgetDay}}
{{copy "chat.connections.metered.change_budget"}}

{{copy "chat.connections.metered.budget_note"}}

{{end}}
{{end}} {{define "conn-chooser"}}
{{template "conn-paste-instead"}}
{{range .Metered}}{{template "conn-metered-add" .}}{{end}}

{{copy "chat.connections.soon"}}

{{end}} {{define "conn-add-link"}}{{icon "plug"}}{{copy "chat.connections.add"}}{{end}} {{define "conn-note"}}
{{.Row.Note}}
{{if .Add}}{{end}}
{{end}} {{define "conn-row"}}
{{template "conn-mark" .Provider}}

{{.Name}}{{template "conn-account" .Tag}}{{with .Plan}}, {{.}}{{end}}{{if .Preferred}}{{icon "star"}}{{copy "chat.connections.preferred"}}{{end}}

{{.Words}}{{with .Expires}}{{.}}{{end}}{{range .Meters}}{{.Name}} {{.Used}}%{{with .Resets}}, {{.}}{{end}}{{end}}{{with .Age}}{{.}}{{end}}{{with .UsageNote}}{{.}}{{end}}

{{if .Metered}}{{template "conn-metered-row" .}}{{end}} {{if .AskEmail}}
{{if .Stated}}{{copy "chat.connections.email_change"}}{{else}}{{copy "chat.connections.email_add"}}{{end}}
{{copy "chat.connections.email_hint"}}
{{end}} {{if .Renew}}
{{copy "chat.connections.token_renew"}}
{{with .Machine}}{{end}}
{{end}} {{if .Roles}}

{{copy "chat.connections.serving"}}{{range .Roles}}{{if .Live}}{{template "conn-star"}}{{end}}{{.Name}}{{end}}

{{else}}{{with .RolesNote}}

{{.}}

{{end}}{{end}}
{{if .Needs}}
{{with .Machine}}{{end}}
{{end}}{{if or .MakePreferred .SignOut .Forget .CheckAgain}}{{template "conn-quiet" .}}
{{icon "more-horizontal"}}
{{template "conn-quiet" .}}
{{end}}

{{if eq .State "signed_out"}}{{printf (copy "chat.connections.tokens_before") .Usage}}{{else}}{{.Usage}}{{.UsageTail}}{{end}}

{{end}} {{define "conn-quiet"}}{{if .CheckAgain}}
{{end}}{{if .MakePreferred}}
{{end}}{{if .SignOut}}
{{end}}{{if .Forget}}
{{end}}{{end}} {{define "content"}}
{{template "settings-nav" .}}
{{if .Models.Adding}}{{template "settings-head" (dict "Title" "chat.connections.add" "Lede" "chat.connections.chooser_lede")}} {{else}}{{template "settings-head" (dict "Title" "chat.connections.title" "Lede" (and .Models.Rows "chat.connections.lede"))}}{{end}} {{if .Models.Offline}}

{{copy "chat.connections.offline"}}

{{end}}
{{if .Models.Adding}}{{range .Models.Ended}}{{template "conn-note" (dict "Row" . "Add" $.Models.Adding)}}{{end}}
{{range .Models.Attempts}}{{template "conn-attempt" .}}{{else}}{{template "conn-chooser" .Models}}{{end}}
{{else if or .Models.Rows (gt (len .Models.Machines) 1)}}{{if .Models.Rows}}{{with .Models.Answering}}
{{if .Tone}}{{else}}{{template "conn-star"}}{{end}}

{{.LeadStart}}{{.LeadName}}{{.LeadEnd}}

{{.Sub}}{{if .SeeConversation}} {{copy "chat.connections.answering.see"}}{{end}}

{{if not .Tone}}{{with $.Models.Prefer}}
{{copy "chat.connections.prefer"}}{{range .Options}}
{{end}}
{{.Hint}}
{{end}}{{end}}
{{end}}{{end}} {{if gt (len .Models.Machines) 1}}{{range $i, $m := .Models.Machines}}

{{$m.Name}} {{len $m.Rows}}{{if eq $i 0}}{{copy "chat.connections.usage_resets"}}{{end}}

{{range $m.Rows}}{{template "conn-row" .}}{{end}}
{{if $m.Primary}}{{range $.Models.Ended}}{{template "conn-note" (dict "Row" . "Add" $.Models.Adding)}}{{end}}
{{template "conn-add-link" false}}{{copy "chat.connections.add_hint"}}
{{end}} {{with $m.AddClaude}}
{{end}}
{{end}}{{else}}

{{copy "chat.connections.group"}} {{len .Models.Rows}}{{copy "chat.connections.usage_resets"}}

{{range .Models.Rows}}{{template "conn-row" .}}{{end}}
{{range .Models.Ended}}{{template "conn-note" (dict "Row" . "Add" $.Models.Adding)}}{{end}}
{{template "conn-add-link" false}}{{copy "chat.connections.add_hint"}}
{{end}} {{else}}

{{template "conn-mark" "claude"}}{{template "conn-mark" "codex"}}

{{copy "chat.connections.empty_title"}}

{{copy "chat.connections.empty_body"}}

{{range .Models.Ended}}{{template "conn-note" (dict "Row" . "Add" $.Models.Adding)}}{{end}} {{template "conn-add-link" true}}

{{copy "chat.connections.empty_fine"}}

{{end}}
{{if and .Models.Adding .Models.Connecting}}{{with index .Models.Attempts 0}}{{end}}{{end}}
{{if .Models.Adding}} {{end}}
{{end}}