-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathConfigureAnalysis.tsx
More file actions
166 lines (163 loc) · 6.49 KB
/
ConfigureAnalysis.tsx
File metadata and controls
166 lines (163 loc) · 6.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import React from 'react'
import { AnalyzedGame } from 'src/types'
import { ContinueAgainstMaia } from 'src/components'
interface Props {
currentMaiaModel: string
setCurrentMaiaModel: (model: string) => void
showTopMoveBadges: boolean
setShowTopMoveBadges: (show: boolean) => void
launchContinue: () => void
MAIA_MODELS: string[]
game: AnalyzedGame
onDeleteCustomGame?: () => void
onAnalyzeEntireGame?: () => void
onLearnFromMistakes?: () => void
isAnalysisInProgress?: boolean
isLearnFromMistakesActive?: boolean
autoSave?: {
hasUnsavedChanges: boolean
isSaving: boolean
status: 'saving' | 'unsaved' | 'saved'
}
}
export const ConfigureAnalysis: React.FC<Props> = ({
currentMaiaModel,
setCurrentMaiaModel,
showTopMoveBadges,
setShowTopMoveBadges,
launchContinue,
MAIA_MODELS,
game,
onDeleteCustomGame,
onAnalyzeEntireGame,
onLearnFromMistakes,
isAnalysisInProgress = false,
isLearnFromMistakesActive = false,
autoSave,
}: Props) => {
return (
<div className="flex w-full flex-col items-start justify-start gap-1.5 rounded-md p-3 text-white/90">
<div className="flex w-full flex-col gap-0.5">
<p className="text-xs text-white/70">Analyze using:</p>
<div className="relative inline-flex w-full items-center">
<select
value={currentMaiaModel}
className="edge-dark-select w-full cursor-pointer appearance-none rounded border border-glass-border bg-glass py-[5px] pl-2.5 pr-6 text-xs text-white/90 outline-none transition duration-200 hover:bg-glass-stronger"
onChange={(e) => setCurrentMaiaModel(e.target.value)}
>
{MAIA_MODELS.map((model) => (
<option value={model} key={model}>
{model.replace('maia_kdd_', 'Maia ')}
</option>
))}
</select>
<span className="material-symbols-outlined pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-xs text-white/70">
keyboard_arrow_down
</span>
</div>
</div>
{onAnalyzeEntireGame && (
<button
onClick={onAnalyzeEntireGame}
disabled={isAnalysisInProgress || isLearnFromMistakesActive}
className="flex w-full items-center gap-1.5 rounded border border-glass-border bg-glass !px-2.5 !py-[5px] !text-sm text-white/90 transition duration-200 hover:bg-glass-stronger disabled:cursor-not-allowed disabled:opacity-50"
>
<div className="flex items-center justify-center gap-1.5">
<span className="material-symbols-outlined !text-sm text-white/80">
network_intelligence
</span>
<span className="text-xs">
{isAnalysisInProgress
? 'Analysis in progress...'
: 'Analyze entire game'}
</span>
</div>
</button>
)}
{onLearnFromMistakes && (
<button
onClick={onLearnFromMistakes}
disabled={isAnalysisInProgress || isLearnFromMistakesActive}
className="flex w-full items-center gap-1.5 rounded border border-glass-border bg-glass !px-2.5 !py-[5px] !text-sm text-white/90 transition duration-200 hover:bg-glass-stronger disabled:cursor-not-allowed disabled:opacity-50"
>
<div className="flex items-center justify-center gap-1.5">
<span className="material-symbols-outlined !text-sm text-white/80">
school
</span>
<span className="text-xs">
{isLearnFromMistakesActive
? 'Learning in progress...'
: 'Learn from mistakes'}
</span>
</div>
</button>
)}
<div className="mt-1 flex w-full items-center justify-between rounded border border-glass-border bg-glass px-2.5 py-2">
<div className="flex flex-col">
<span className="text-xs text-white/90">Show board badges</span>
<span className="text-[11px] text-white/60">
Show ? / ?? marker on top human move destination
</span>
</div>
<label
htmlFor="analysis-top-move-badges-toggle"
className="relative inline-flex cursor-pointer items-center"
>
<input
id="analysis-top-move-badges-toggle"
type="checkbox"
checked={showTopMoveBadges}
onChange={() => setShowTopMoveBadges(!showTopMoveBadges)}
className="peer sr-only"
/>
<div className="peer h-5 w-9 rounded-full bg-white/10 after:absolute after:left-[2px] after:top-[2px] after:h-4 after:w-4 after:rounded-full after:border after:border-white/20 after:bg-white after:transition-all after:content-[''] peer-checked:bg-red-500/40 peer-checked:after:translate-x-full peer-checked:after:border-white peer-checked:after:bg-red-400"></div>
<span className="sr-only">Toggle top move board badges</span>
</label>
</div>
{autoSave && game.type !== 'tournament' && (
<div className="mt-2 w-full">
<div className="flex items-center gap-1.5">
{autoSave.status === 'saving' && (
<>
<div className="h-2 w-2 animate-spin rounded-full border border-white/50 border-t-white"></div>
<span className="text-xs text-white/70">
Saving analysis...
</span>
</>
)}
{autoSave.status === 'unsaved' && (
<>
<span className="material-symbols-outlined !text-sm text-orange-400">
sync_problem
</span>
<span className="text-xs text-orange-400">
Unsaved analysis. Will auto-save...
</span>
</>
)}
{autoSave.status === 'saved' && (
<>
<span className="material-symbols-outlined !text-sm text-green-400">
cloud_done
</span>
<span className="text-xs text-green-400">
Analysis auto-saved
</span>
</>
)}
</div>
</div>
)}
{game.type === 'custom' && onDeleteCustomGame && (
<div className="mt-2 w-full">
<button
onClick={onDeleteCustomGame}
className="text-xs text-white/70 transition duration-200 hover:text-white"
>
<span className="underline">Delete</span> this stored Custom Game
</button>
</div>
)}
</div>
)
}