rewrite: TS monorepo — pi SDK stateless agents, Postgres+pg-boss, SvelteKit themed UI; legacy moved to legacy/
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<script lang="ts">
|
||||
import { Chessground } from '@lichess-org/chessground';
|
||||
import type { Api } from '@lichess-org/chessground/api';
|
||||
import type { Key } from '@lichess-org/chessground/types';
|
||||
|
||||
let {
|
||||
fen,
|
||||
lastMove = null,
|
||||
check = false,
|
||||
orientation = 'white',
|
||||
arrow = null,
|
||||
turn = 'w'
|
||||
}: {
|
||||
fen: string;
|
||||
lastMove?: [string, string] | null;
|
||||
check?: boolean;
|
||||
orientation?: 'white' | 'black';
|
||||
arrow?: [string, string] | null;
|
||||
turn?: 'w' | 'b';
|
||||
} = $props();
|
||||
|
||||
let el: HTMLDivElement;
|
||||
let api: Api | undefined;
|
||||
|
||||
$effect(() => {
|
||||
api = Chessground(el, {
|
||||
fen,
|
||||
orientation,
|
||||
coordinates: true,
|
||||
viewOnly: true,
|
||||
disableContextMenu: true,
|
||||
animation: { enabled: true, duration: 220 },
|
||||
highlight: { lastMove: true, check: true },
|
||||
drawable: {
|
||||
enabled: false,
|
||||
visible: true,
|
||||
brushes: {
|
||||
green: { key: 'g', color: '#4cff5e', opacity: 0.85, lineWidth: 10 },
|
||||
red: { key: 'r', color: '#ff3b5c', opacity: 0.8, lineWidth: 10 },
|
||||
blue: { key: 'b', color: '#42e8ff', opacity: 0.8, lineWidth: 10 },
|
||||
yellow: { key: 'y', color: '#ffe14d', opacity: 0.8, lineWidth: 10 }
|
||||
}
|
||||
}
|
||||
});
|
||||
return () => api?.destroy();
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
api?.set({
|
||||
fen,
|
||||
orientation,
|
||||
turnColor: turn === 'w' ? 'white' : 'black',
|
||||
check,
|
||||
lastMove: lastMove ? (lastMove as Key[]) : [],
|
||||
drawable: {
|
||||
autoShapes: arrow ? [{ orig: arrow[0] as Key, dest: arrow[1] as Key, brush: 'green' }] : []
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="board-wrap">
|
||||
<div class="cg-wrap" bind:this={el}></div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.board-wrap {
|
||||
width: 100%;
|
||||
aspect-ratio: 1;
|
||||
position: relative;
|
||||
}
|
||||
.board-wrap :global(.cg-wrap) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,51 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
let { to }: { to: string } = $props();
|
||||
let now = $state(Date.now());
|
||||
onMount(() => {
|
||||
const t = setInterval(() => (now = Date.now()), 1000);
|
||||
return () => clearInterval(t);
|
||||
});
|
||||
const left = $derived(Math.max(0, Math.floor((new Date(to).getTime() - now) / 1000)));
|
||||
const h = $derived(Math.floor(left / 3600));
|
||||
const m = $derived(Math.floor((left % 3600) / 60));
|
||||
const s = $derived(left % 60);
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
</script>
|
||||
|
||||
<div class="cd">
|
||||
<span class="seg"><b>{pad(h)}</b><i class="pixel">ч</i></span>
|
||||
<span class="colon">:</span>
|
||||
<span class="seg"><b>{pad(m)}</b><i class="pixel">м</i></span>
|
||||
<span class="colon">:</span>
|
||||
<span class="seg"><b>{pad(s)}</b><i class="pixel">с</i></span>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.cd {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
font-family: var(--font-pixel);
|
||||
}
|
||||
.seg {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 4px;
|
||||
}
|
||||
.seg b {
|
||||
font-size: 28px;
|
||||
color: var(--p1);
|
||||
font-weight: 400;
|
||||
text-shadow: 3px 3px 0 #000;
|
||||
}
|
||||
.seg i {
|
||||
color: var(--muted);
|
||||
font-style: normal;
|
||||
}
|
||||
.colon {
|
||||
color: var(--p1);
|
||||
font-size: 22px;
|
||||
animation: blink 1s steps(2) infinite;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,88 @@
|
||||
<script lang="ts">
|
||||
import type { Ply } from '#lib/game.ts';
|
||||
import { winProb } from '#lib/mock.ts';
|
||||
|
||||
let {
|
||||
plies,
|
||||
current,
|
||||
onselect
|
||||
}: { plies: Ply[]; current: number; onselect?: (i: number) => void } = $props();
|
||||
|
||||
const W = 600;
|
||||
const H = 120;
|
||||
const MAX = 600; // cp clamp
|
||||
|
||||
// plot win probability (white POV) rather than raw cp — small edges stay visible
|
||||
const clamp = (p: Ply) => (winProb(p.m.cp, p.m.mate) - 0.5) * 2 * MAX;
|
||||
const n = $derived(Math.max(plies.length, 2));
|
||||
const x = (i: number) => ((i + 1) / n) * W;
|
||||
const y = (cp: number) => H / 2 - (cp / MAX) * (H / 2);
|
||||
|
||||
const pts = $derived(plies.map((p, i) => [x(i), y(clamp(p))] as const));
|
||||
const line = $derived(
|
||||
pts.length ? `M0,${H / 2} ` + pts.map(([px, py]) => `L${px},${py}`).join(' ') : ''
|
||||
);
|
||||
const areaTop = $derived(line ? `${line} L${pts[pts.length - 1][0]},${H / 2} Z` : '');
|
||||
|
||||
function pick(e: MouseEvent) {
|
||||
const r = (e.currentTarget as SVGElement).getBoundingClientRect();
|
||||
const fx = ((e.clientX - r.left) / r.width) * W;
|
||||
let best = 0;
|
||||
let bd = 1e9;
|
||||
pts.forEach(([px], i) => {
|
||||
const d = Math.abs(px - fx);
|
||||
if (d < bd) {
|
||||
bd = d;
|
||||
best = i;
|
||||
}
|
||||
});
|
||||
onselect?.(best);
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events a11y_no_noninteractive_element_interactions -->
|
||||
<svg class="eg" viewBox="0 0 {W} {H}" preserveAspectRatio="none" onclick={pick} role="button" tabindex="-1" aria-label="График оценки">
|
||||
<defs>
|
||||
<clipPath id="eg-top"><rect x="0" y="0" width={W} height={H / 2} /></clipPath>
|
||||
<clipPath id="eg-bot"><rect x="0" y={H / 2} width={W} height={H / 2} /></clipPath>
|
||||
</defs>
|
||||
<rect width={W} height={H} fill="#1a1a24" />
|
||||
<rect width={W} height={H / 2} fill="#23232f" />
|
||||
<!-- grid -->
|
||||
{#each [0.25, 0.75] as g}
|
||||
<line x1="0" x2={W} y1={H * g} y2={H * g} stroke="#2e2e3c" stroke-dasharray="3 5" />
|
||||
{/each}
|
||||
<line x1="0" x2={W} y1={H / 2} y2={H / 2} stroke="#4a4a5c" />
|
||||
<!-- white advantage (above center) -->
|
||||
<path d={areaTop} fill="#f3efe4" clip-path="url(#eg-top)" />
|
||||
<!-- black advantage (below center) -->
|
||||
<path d={areaTop} fill="#0b0b10" clip-path="url(#eg-bot)" />
|
||||
<path d={line} fill="none" stroke="var(--p1)" stroke-width="2" vector-effect="non-scaling-stroke" />
|
||||
<!-- marks -->
|
||||
{#each plies as p, i}
|
||||
{#if p.m.cls === 'blunder' || p.m.cls === 'mistake' || p.m.cls === 'inacc' || p.m.cls === 'brilliant'}
|
||||
<circle
|
||||
cx={x(i)}
|
||||
cy={y(clamp(p))}
|
||||
r="5"
|
||||
fill={p.m.cls === 'blunder' ? 'var(--c-blunder)' : p.m.cls === 'mistake' ? 'var(--c-mistake)' : p.m.cls === 'inacc' ? 'var(--c-inacc)' : 'var(--c-brill)'}
|
||||
stroke="#000"
|
||||
stroke-width="1.5"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
{/if}
|
||||
{/each}
|
||||
<!-- cursor -->
|
||||
{#if plies[current]}
|
||||
<line x1={x(current)} x2={x(current)} y1="0" y2={H} stroke="var(--p2)" stroke-width="2" vector-effect="non-scaling-stroke" />
|
||||
{/if}
|
||||
</svg>
|
||||
|
||||
<style>
|
||||
.eg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
cursor: crosshair;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,248 @@
|
||||
<script lang="ts">
|
||||
// One side of the fighting-game HUD: avatar, name plate, health bar, meters.
|
||||
import type { Entity, Persona } from '#lib/mock.ts';
|
||||
import { fmtSec, fmtTok, fmtUsd } from '#lib/mock.ts';
|
||||
import Mark from './Mark.svelte';
|
||||
import HealthBar from './HealthBar.svelte';
|
||||
|
||||
let {
|
||||
e,
|
||||
side,
|
||||
persona,
|
||||
hp,
|
||||
acc,
|
||||
thinking = false,
|
||||
thinkSec = 0,
|
||||
cost,
|
||||
tokens,
|
||||
delta = null,
|
||||
winner = false,
|
||||
counts
|
||||
}: {
|
||||
e: Entity;
|
||||
side: 'w' | 'b';
|
||||
persona: Persona;
|
||||
hp: number;
|
||||
acc: number;
|
||||
thinking?: boolean;
|
||||
thinkSec?: number;
|
||||
cost: number;
|
||||
tokens: number;
|
||||
delta?: number | null;
|
||||
winner?: boolean;
|
||||
counts: Record<string, number>;
|
||||
} = $props();
|
||||
const p = $derived(side === 'w' ? 'p1' : 'p2');
|
||||
</script>
|
||||
|
||||
<div class="fighter {p}" class:thinking class:winner>
|
||||
<div class="av">
|
||||
<Mark {e} size={56} />
|
||||
<span class="pnum pixel">{side === 'w' ? 'P1' : 'P2'}</span>
|
||||
</div>
|
||||
<div class="plate">
|
||||
<div class="name">
|
||||
<span class="display nm">{e.name}</span>
|
||||
{#if e.variant}<span class="tag {e.variant.toLowerCase()}">{e.variant}</span>{/if}
|
||||
{#if e.provider === 'human'}<span class="tag human">human</span>{/if}
|
||||
<span class="rating mono">{e.rating}{#if delta !== null}<b class:neg={delta < 0}>{delta > 0 ? '+' : ''}{delta}</b>{/if}</span>
|
||||
</div>
|
||||
<HealthBar pct={hp} side={side === 'w' ? 'left' : 'right'} label={e.name} />
|
||||
<div class="meters mono">
|
||||
<span class="persona"><i class="pixel">persona</i> {persona}</span>
|
||||
<span><i class="pixel">acc</i> <b>{acc.toFixed(0)}%</b></span>
|
||||
<span class="cls">
|
||||
<em style="color:var(--c-best)">★{counts.best + counts.brilliant}</em>
|
||||
<em style="color:var(--c-inacc)">?!{counts.inacc}</em>
|
||||
<em style="color:var(--c-mistake)">?{counts.mistake}</em>
|
||||
<em style="color:var(--c-blunder)">??{counts.blunder}</em>
|
||||
</span>
|
||||
<span class="cost"><i class="pixel">$</i> {fmtUsd(cost)} · {fmtTok(tokens)}</span>
|
||||
</div>
|
||||
</div>
|
||||
{#if thinking}
|
||||
<div class="timer">
|
||||
<span class="pixel">thinking</span>
|
||||
<span class="mono t">{fmtSec(thinkSec)}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if winner}
|
||||
<div class="win pixel">WINNER</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.fighter {
|
||||
--acc: var(--p1);
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
padding: 8px 12px;
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-top: 3px solid var(--acc);
|
||||
min-width: 0;
|
||||
}
|
||||
.fighter.p2 {
|
||||
--acc: var(--p2);
|
||||
grid-template-columns: 1fr auto;
|
||||
}
|
||||
.p2 .av {
|
||||
order: 2;
|
||||
}
|
||||
.p2 .plate {
|
||||
text-align: right;
|
||||
}
|
||||
.p2 .name {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.p2 .meters {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
.av {
|
||||
position: relative;
|
||||
}
|
||||
.pnum {
|
||||
position: absolute;
|
||||
left: -4px;
|
||||
top: -8px;
|
||||
background: var(--acc);
|
||||
color: #000;
|
||||
padding: 2px 4px;
|
||||
font-size: 8px;
|
||||
}
|
||||
.p2 .pnum {
|
||||
left: auto;
|
||||
right: -4px;
|
||||
}
|
||||
.plate {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
.name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.nm {
|
||||
font-size: 15px;
|
||||
font-weight: 900;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rating {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
.rating b {
|
||||
color: var(--hp);
|
||||
margin-left: 4px;
|
||||
}
|
||||
.rating b.neg {
|
||||
color: var(--c-blunder);
|
||||
}
|
||||
.meters {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.meters i {
|
||||
color: var(--dim);
|
||||
font-size: 7px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
.meters b {
|
||||
color: var(--text);
|
||||
}
|
||||
.cls em {
|
||||
font-style: normal;
|
||||
margin-right: 5px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.persona {
|
||||
color: var(--text);
|
||||
}
|
||||
.timer {
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
right: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
background: var(--acc);
|
||||
color: #000;
|
||||
padding: 4px 8px;
|
||||
animation: tick 1s steps(2) infinite;
|
||||
}
|
||||
.p2 .timer {
|
||||
right: auto;
|
||||
left: 12px;
|
||||
}
|
||||
.timer .t {
|
||||
font-weight: 700;
|
||||
font-size: 14px;
|
||||
}
|
||||
.thinking {
|
||||
box-shadow: 0 0 0 1px var(--acc), 0 0 24px color-mix(in srgb, var(--acc) 30%, transparent);
|
||||
}
|
||||
.winner {
|
||||
box-shadow: 0 0 0 2px var(--hp);
|
||||
}
|
||||
.win {
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
right: 12px;
|
||||
background: var(--hp);
|
||||
color: #000;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
.p2 .win {
|
||||
right: auto;
|
||||
left: 12px;
|
||||
}
|
||||
@keyframes tick {
|
||||
50% {
|
||||
filter: brightness(0.85);
|
||||
}
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.fighter {
|
||||
padding: 6px 10px;
|
||||
gap: 8px;
|
||||
}
|
||||
.nm {
|
||||
font-size: 12px;
|
||||
}
|
||||
.cls,
|
||||
.cost,
|
||||
.rating {
|
||||
display: none;
|
||||
}
|
||||
.plate {
|
||||
gap: 4px;
|
||||
}
|
||||
.timer {
|
||||
position: static;
|
||||
order: 5;
|
||||
grid-column: 1 / -1;
|
||||
justify-self: start;
|
||||
padding: 2px 6px;
|
||||
margin-top: -2px;
|
||||
}
|
||||
.p2 .timer {
|
||||
justify-self: end;
|
||||
}
|
||||
.timer .t {
|
||||
font-size: 12px;
|
||||
}
|
||||
.win {
|
||||
top: auto;
|
||||
bottom: -3px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,96 @@
|
||||
<script lang="ts">
|
||||
// Fighting-game style health bar. `pct` is the player's win-probability (0..1).
|
||||
// The pale "ghost" segment lags behind on damage like in SF/KOF.
|
||||
let {
|
||||
pct,
|
||||
side = 'left',
|
||||
label = ''
|
||||
}: { pct: number; side?: 'left' | 'right'; label?: string } = $props();
|
||||
|
||||
const v = $derived(Math.max(0.02, Math.min(1, pct)));
|
||||
const tone = $derived(v > 0.55 ? 'hi' : v > 0.3 ? 'mid' : 'low');
|
||||
</script>
|
||||
|
||||
<div class="hp {side} {tone}" aria-label="{label}: {(v * 100).toFixed(0)}%">
|
||||
<div class="track">
|
||||
<div class="ghost" style:width="{v * 100}%"></div>
|
||||
<div class="fill" style:width="{v * 100}%"></div>
|
||||
<div class="ticks"></div>
|
||||
</div>
|
||||
<div class="pct mono">{(v * 100).toFixed(0)}%</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.hp {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
.hp.right {
|
||||
grid-template-columns: auto 1fr;
|
||||
}
|
||||
.hp.right .track {
|
||||
order: 2;
|
||||
}
|
||||
.hp.right .pct {
|
||||
order: 1;
|
||||
text-align: right;
|
||||
}
|
||||
.track {
|
||||
position: relative;
|
||||
height: 18px;
|
||||
background: #1c1c26;
|
||||
border: 2px solid #f3efe4;
|
||||
clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
|
||||
overflow: hidden;
|
||||
}
|
||||
.right .track {
|
||||
clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%);
|
||||
}
|
||||
.fill,
|
||||
.ghost {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
}
|
||||
.right .fill,
|
||||
.right .ghost {
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
.fill {
|
||||
background: linear-gradient(180deg, #8fff9c 0 45%, var(--hp) 45% 100%);
|
||||
transition: width 0.45s cubic-bezier(0.2, 0.9, 0.2, 1);
|
||||
}
|
||||
.mid .fill {
|
||||
background: linear-gradient(180deg, #ffe88a 0 45%, var(--hp-mid) 45% 100%);
|
||||
}
|
||||
.low .fill {
|
||||
background: linear-gradient(180deg, #ff8a8a 0 45%, var(--hp-low) 45% 100%);
|
||||
animation: pulse 0.7s steps(2) infinite;
|
||||
}
|
||||
.ghost {
|
||||
background: #ffb4b4;
|
||||
transition: width 0.9s ease-out 0.5s;
|
||||
}
|
||||
.ticks {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), rgba(0, 0, 0, 0.55) calc(10% - 2px) 10%);
|
||||
pointer-events: none;
|
||||
}
|
||||
.pct {
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
min-width: 38px;
|
||||
color: var(--text);
|
||||
}
|
||||
@keyframes pulse {
|
||||
50% {
|
||||
filter: brightness(1.6);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,87 @@
|
||||
<script lang="ts">
|
||||
// Provider mark or pixel-avatar for a player entity.
|
||||
import { siClaude, siAnthropic } from 'simple-icons';
|
||||
import type { Entity } from '#lib/mock.ts';
|
||||
|
||||
let {
|
||||
e,
|
||||
size = 40,
|
||||
glow = false,
|
||||
company = false
|
||||
}: { e: Entity; size?: number; glow?: boolean; company?: boolean } = $props();
|
||||
|
||||
// simple-icons v16 no longer ships `siOpenai` (trademark removal) — a hand-drawn
|
||||
// hexagonal knot stands in, drawn in the same 24-grid.
|
||||
const openaiPath =
|
||||
'M12 2.2 20.4 7v9.9L12 21.8 3.6 16.9V7L12 2.2Zm0 2.3L5.6 8.2v7.5L12 19.5l6.4-3.8V8.2L12 4.5Zm0 3.1 3.6 2.1v4.2L12 16.1l-3.6-2.1V9.7L12 7.6Zm0 2.3-1.6.9v1.9l1.6.9 1.6-.9v-1.9L12 9.9Z';
|
||||
|
||||
// Pixel identicon for humans: 5x5 symmetric grid from a name hash
|
||||
function pix(name: string) {
|
||||
let h = 2166136261;
|
||||
for (const ch of name) h = Math.imul(h ^ ch.charCodeAt(0), 16777619) >>> 0;
|
||||
const cells: [number, number][] = [];
|
||||
for (let y = 0; y < 5; y++)
|
||||
for (let x = 0; x < 3; x++) {
|
||||
h = Math.imul(h ^ (h >>> 13), 1274126177) >>> 0;
|
||||
if (h % 3 !== 0) {
|
||||
cells.push([x, y]);
|
||||
if (x !== 2) cells.push([4 - x, y]);
|
||||
}
|
||||
}
|
||||
const hue = h % 360;
|
||||
return { cells, hue };
|
||||
}
|
||||
const p = $derived(e.provider === 'human' ? pix(e.name) : null);
|
||||
</script>
|
||||
|
||||
{#if e.provider === 'human' && p}
|
||||
<svg
|
||||
class="mark human"
|
||||
viewBox="0 0 7 7"
|
||||
width={size}
|
||||
height={size}
|
||||
shape-rendering="crispEdges"
|
||||
style:--hue={p.hue}
|
||||
class:glow
|
||||
>
|
||||
<rect width="7" height="7" fill="hsl({p.hue} 45% 14%)" />
|
||||
{#each p.cells as [x, y]}
|
||||
<rect x={x + 1} y={y + 1} width="1" height="1" fill="hsl({p.hue} 90% 62%)" />
|
||||
{/each}
|
||||
</svg>
|
||||
{:else}
|
||||
<svg
|
||||
class="mark {e.provider}"
|
||||
viewBox="0 0 24 24"
|
||||
width={size}
|
||||
height={size}
|
||||
class:glow
|
||||
role="img"
|
||||
aria-label={e.provider}
|
||||
>
|
||||
<rect width="24" height="24" fill={e.provider === 'anthropic' ? '#d97757' : '#111'} />
|
||||
{#if e.provider === 'anthropic' && company}
|
||||
<path transform="translate(3 3) scale(0.75)" d={siAnthropic.path} fill="#0b0b0f" />
|
||||
{:else if e.provider === 'anthropic'}
|
||||
<path transform="translate(3 3) scale(0.75)" d={siClaude.path} fill="#0b0b0f" />
|
||||
{:else}
|
||||
<path d={openaiPath} fill="#f3efe4" />
|
||||
{/if}
|
||||
</svg>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.mark {
|
||||
display: block;
|
||||
flex: none;
|
||||
border-radius: 2px;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
.mark.openai {
|
||||
outline: 1px solid #3a3a46;
|
||||
outline-offset: -1px;
|
||||
}
|
||||
.glow {
|
||||
box-shadow: 0 0 0 2px var(--bg), 0 0 18px rgba(255, 225, 77, 0.35);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script lang="ts">
|
||||
// Tiny static board from FEN. Uses chessground's cburnett piece CSS via the
|
||||
// `.cg-wrap piece.role.color` selectors — no JS board instance needed.
|
||||
let { fen, flip = false }: { fen: string; flip?: boolean } = $props();
|
||||
|
||||
const roles: Record<string, string> = { p: 'pawn', n: 'knight', b: 'bishop', r: 'rook', q: 'queen', k: 'king' };
|
||||
|
||||
const cells = $derived.by(() => {
|
||||
const rows = fen.split(' ')[0].split('/');
|
||||
const out: { role: string; color: string; i: number }[] = [];
|
||||
rows.forEach((r, y) => {
|
||||
let x = 0;
|
||||
for (const ch of r) {
|
||||
if (/\d/.test(ch)) x += +ch;
|
||||
else {
|
||||
const yy = flip ? 7 - y : y;
|
||||
const xx = flip ? 7 - x : x;
|
||||
out.push({ role: roles[ch.toLowerCase()], color: ch === ch.toUpperCase() ? 'white' : 'black', i: yy * 8 + xx });
|
||||
x++;
|
||||
}
|
||||
}
|
||||
});
|
||||
return out;
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="mini cg-wrap">
|
||||
{#each cells as c (c.i)}
|
||||
<piece class="{c.role} {c.color}" style="grid-area: {Math.floor(c.i / 8) + 1} / {(c.i % 8) + 1}"></piece>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.mini {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(8, 1fr);
|
||||
grid-template-rows: repeat(8, 1fr);
|
||||
aspect-ratio: 1;
|
||||
width: 100%;
|
||||
background-color: #e7e2d2;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8" shape-rendering="crispEdges"><g fill="%235a6b86"><rect x="1" y="0" width="1" height="1"/><rect x="3" y="0" width="1" height="1"/><rect x="5" y="0" width="1" height="1"/><rect x="7" y="0" width="1" height="1"/><rect x="0" y="1" width="1" height="1"/><rect x="2" y="1" width="1" height="1"/><rect x="4" y="1" width="1" height="1"/><rect x="6" y="1" width="1" height="1"/><rect x="1" y="2" width="1" height="1"/><rect x="3" y="2" width="1" height="1"/><rect x="5" y="2" width="1" height="1"/><rect x="7" y="2" width="1" height="1"/><rect x="0" y="3" width="1" height="1"/><rect x="2" y="3" width="1" height="1"/><rect x="4" y="3" width="1" height="1"/><rect x="6" y="3" width="1" height="1"/><rect x="1" y="4" width="1" height="1"/><rect x="3" y="4" width="1" height="1"/><rect x="5" y="4" width="1" height="1"/><rect x="7" y="4" width="1" height="1"/><rect x="0" y="5" width="1" height="1"/><rect x="2" y="5" width="1" height="1"/><rect x="4" y="5" width="1" height="1"/><rect x="6" y="5" width="1" height="1"/><rect x="1" y="6" width="1" height="1"/><rect x="3" y="6" width="1" height="1"/><rect x="5" y="6" width="1" height="1"/><rect x="7" y="6" width="1" height="1"/><rect x="0" y="7" width="1" height="1"/><rect x="2" y="7" width="1" height="1"/><rect x="4" y="7" width="1" height="1"/><rect x="6" y="7" width="1" height="1"/></g></svg>');
|
||||
background-size: 100% 100%;
|
||||
image-rendering: pixelated;
|
||||
}
|
||||
.mini piece {
|
||||
position: static;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-size: cover;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,186 @@
|
||||
<script lang="ts">
|
||||
// "COMBO LOG": move list with classifications. Click a move → board jumps there
|
||||
// and the agent's thoughts expand beneath the row (accordion).
|
||||
import type { Ply } from '#lib/game.ts';
|
||||
import { clsMeta, fmtEval } from '#lib/mock.ts';
|
||||
import Thought from './Thought.svelte';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
let {
|
||||
plies,
|
||||
current,
|
||||
open = null,
|
||||
onselect,
|
||||
onopen
|
||||
}: {
|
||||
plies: Ply[];
|
||||
current: number;
|
||||
open?: number | null;
|
||||
onselect: (i: number) => void;
|
||||
onopen: (i: number | null) => void;
|
||||
} = $props();
|
||||
|
||||
const rows = $derived.by(() => {
|
||||
const out: { num: number; w?: Ply; b?: Ply }[] = [];
|
||||
for (const p of plies) {
|
||||
if (p.color === 'w') out.push({ num: p.num, w: p });
|
||||
else {
|
||||
const last = out[out.length - 1];
|
||||
if (last && last.num === p.num) last.b = p;
|
||||
else out.push({ num: p.num, b: p });
|
||||
}
|
||||
}
|
||||
return out;
|
||||
});
|
||||
|
||||
let list: HTMLDivElement;
|
||||
$effect(() => {
|
||||
// opened thought: bring its row to the top so the panel has room
|
||||
const o = open;
|
||||
if (o === null) return;
|
||||
tick().then(() => {
|
||||
const el = list?.querySelector('.ply.open') as HTMLElement | null;
|
||||
if (!el || !list) return;
|
||||
list.scrollTo({ top: el.offsetTop - 8, behavior: 'smooth' });
|
||||
});
|
||||
});
|
||||
$effect(() => {
|
||||
// keep the current move in view
|
||||
current;
|
||||
if (open !== null) return;
|
||||
tick().then(() => {
|
||||
const el = list?.querySelector('.ply.cur') as HTMLElement | null;
|
||||
if (!el || !list) return;
|
||||
const top = el.offsetTop;
|
||||
if (top < list.scrollTop + 8) list.scrollTop = top - 8;
|
||||
else if (top + el.offsetHeight > list.scrollTop + list.clientHeight - 8)
|
||||
list.scrollTop = top + el.offsetHeight - list.clientHeight + 8;
|
||||
});
|
||||
});
|
||||
|
||||
function click(p: Ply) {
|
||||
if (open === p.idx) {
|
||||
onopen(null);
|
||||
return;
|
||||
}
|
||||
onselect(p.idx);
|
||||
onopen(p.idx);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="list" bind:this={list}>
|
||||
{#each rows as r (r.num)}
|
||||
<div class="row">
|
||||
<span class="num mono">{r.num}.</span>
|
||||
{#each [r.w, r.b] as p, i}
|
||||
{#if p}
|
||||
<button
|
||||
class="ply {p.m.cls} {i === 0 ? 'p1' : 'p2'}"
|
||||
class:cur={p.idx === current}
|
||||
class:open={p.idx === open}
|
||||
onclick={() => click(p)}
|
||||
title={clsMeta[p.m.cls].label}
|
||||
>
|
||||
<span class="san">{p.san}</span>
|
||||
<span class="sym" style:color={clsMeta[p.m.cls].color}>{clsMeta[p.m.cls].sym}</span>
|
||||
<span class="ev mono">{fmtEval(p.m)}</span>
|
||||
{#if p.m.thought}<span class="brain" aria-hidden="true"></span>{/if}
|
||||
</button>
|
||||
{:else}
|
||||
<span class="ply empty"></span>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{#if open !== null && (r.w?.idx === open || r.b?.idx === open)}
|
||||
{@const p = r.w?.idx === open ? r.w : r.b}
|
||||
{#if p}
|
||||
<Thought ply={p} side={p.color} onclose={() => onopen(null)} />
|
||||
{/if}
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.list {
|
||||
position: relative;
|
||||
overflow: auto;
|
||||
padding: 6px 8px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--line-2) transparent;
|
||||
}
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 30px 1fr 1fr;
|
||||
gap: 3px;
|
||||
align-items: stretch;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.num {
|
||||
color: var(--dim);
|
||||
font-size: 11px;
|
||||
align-self: center;
|
||||
}
|
||||
.ply {
|
||||
display: grid;
|
||||
grid-template-columns: auto auto 1fr;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 5px 7px;
|
||||
border: 1px solid transparent;
|
||||
background: var(--panel-2);
|
||||
text-align: left;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12.5px;
|
||||
position: relative;
|
||||
transition: background 0.1s;
|
||||
}
|
||||
.ply:hover {
|
||||
background: #24243a;
|
||||
border-color: var(--line-2);
|
||||
}
|
||||
.ply.cur {
|
||||
border-color: var(--text);
|
||||
background: #2a2a3a;
|
||||
}
|
||||
.ply.open {
|
||||
border-color: var(--p1);
|
||||
}
|
||||
.ply.p2.open {
|
||||
border-color: var(--p2);
|
||||
}
|
||||
.ply.empty {
|
||||
background: transparent;
|
||||
}
|
||||
.san {
|
||||
font-weight: 700;
|
||||
}
|
||||
.sym {
|
||||
font-weight: 700;
|
||||
font-size: 11px;
|
||||
}
|
||||
.ev {
|
||||
justify-self: end;
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.brain {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
background: var(--c-brill);
|
||||
}
|
||||
.ply.blunder {
|
||||
background: rgba(255, 59, 59, 0.14);
|
||||
}
|
||||
.ply.mistake {
|
||||
background: rgba(255, 140, 66, 0.12);
|
||||
}
|
||||
.ply.inacc {
|
||||
background: rgba(255, 210, 63, 0.1);
|
||||
}
|
||||
.ply.brilliant {
|
||||
background: rgba(66, 232, 255, 0.12);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,146 @@
|
||||
<script lang="ts">
|
||||
// Spectator predictions: white / draw / black. Points, not money.
|
||||
let {
|
||||
votes,
|
||||
locked = false,
|
||||
mine = null,
|
||||
compact = false
|
||||
}: {
|
||||
votes: { white: number; draw: number; black: number };
|
||||
locked?: boolean;
|
||||
mine?: 'white' | 'draw' | 'black' | null;
|
||||
compact?: boolean;
|
||||
} = $props();
|
||||
|
||||
let pick = $state<'white' | 'draw' | 'black' | null>(null);
|
||||
$effect(() => {
|
||||
pick = mine;
|
||||
});
|
||||
const total = $derived(votes.white + votes.draw + votes.black);
|
||||
const pct = (n: number) => Math.round((n / total) * 100);
|
||||
const opts = [
|
||||
{ k: 'white', label: 'Белые', cls: 'p1' },
|
||||
{ k: 'draw', label: 'Ничья', cls: 'dr' },
|
||||
{ k: 'black', label: 'Чёрные', cls: 'p2' }
|
||||
] as const;
|
||||
</script>
|
||||
|
||||
<div class="pred" class:compact>
|
||||
<div class="bar">
|
||||
<span class="seg p1" style:width="{pct(votes.white)}%"></span>
|
||||
<span class="seg dr" style:width="{pct(votes.draw)}%"></span>
|
||||
<span class="seg p2" style:width="{pct(votes.black)}%"></span>
|
||||
</div>
|
||||
<div class="opts">
|
||||
{#each opts as o}
|
||||
<button
|
||||
class="opt {o.cls}"
|
||||
class:on={pick === o.k}
|
||||
disabled={locked}
|
||||
onclick={() => (pick = o.k)}
|
||||
>
|
||||
<span class="pct mono">{pct(votes[o.k])}%</span>
|
||||
<span class="lb">{o.label}</span>
|
||||
{#if pick === o.k}<span class="chip pixel">{locked ? 'ставка' : 'выбрано'}</span>{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="foot pixel">
|
||||
{#if locked}
|
||||
ставки закрыты · {total} голосов{#if pick} · при победе +{Math.round(100 * (total / votes[pick]))} pts{/if}
|
||||
{:else}
|
||||
{total} голосов · закроются на старте · очки, не деньги
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.pred {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
.bar {
|
||||
display: flex;
|
||||
height: 10px;
|
||||
border: 1px solid var(--line-2);
|
||||
overflow: hidden;
|
||||
}
|
||||
.seg {
|
||||
height: 100%;
|
||||
display: block;
|
||||
transition: width 0.4s;
|
||||
}
|
||||
.seg.p1 {
|
||||
background: var(--p1);
|
||||
}
|
||||
.seg.dr {
|
||||
background: var(--line-2);
|
||||
}
|
||||
.seg.p2 {
|
||||
background: var(--p2);
|
||||
}
|
||||
.opts {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
gap: 6px;
|
||||
}
|
||||
.opt {
|
||||
--acc: var(--p1);
|
||||
position: relative;
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
padding: 8px 8px;
|
||||
border: 1px solid var(--line-2);
|
||||
background: var(--panel-2);
|
||||
text-align: left;
|
||||
transition: border-color 0.1s;
|
||||
}
|
||||
.opt.dr {
|
||||
--acc: var(--muted);
|
||||
}
|
||||
.opt.p2 {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.opt:not(:disabled):hover,
|
||||
.opt.on {
|
||||
border-color: var(--acc);
|
||||
}
|
||||
.opt.on {
|
||||
background: color-mix(in srgb, var(--acc) 14%, var(--panel-2));
|
||||
}
|
||||
.opt:disabled {
|
||||
cursor: default;
|
||||
opacity: 0.85;
|
||||
}
|
||||
.pct {
|
||||
font-weight: 700;
|
||||
font-size: 16px;
|
||||
color: var(--acc);
|
||||
}
|
||||
.lb {
|
||||
font-size: 11px;
|
||||
color: var(--muted);
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.chip {
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
right: -1px;
|
||||
background: var(--acc);
|
||||
color: #000;
|
||||
padding: 1px 4px;
|
||||
font-size: 7px;
|
||||
}
|
||||
.foot {
|
||||
color: var(--dim);
|
||||
font-size: 7.5px;
|
||||
}
|
||||
.compact .opt {
|
||||
padding: 6px;
|
||||
}
|
||||
.compact .pct {
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,109 @@
|
||||
<script lang="ts">
|
||||
// Big fighting-game stinger: "ROUND 22 / FIGHT!", "BLUNDER!!", "K.O."
|
||||
// Slams in with a scale punch + screen-shake on the parent, then fades.
|
||||
let {
|
||||
text,
|
||||
sub = '',
|
||||
tone = 'yellow',
|
||||
sticky = false,
|
||||
onDone
|
||||
}: { text: string; sub?: string; tone?: 'yellow' | 'red' | 'cyan' | 'green'; sticky?: boolean; onDone?: () => void } =
|
||||
$props();
|
||||
|
||||
let visible = $state(true);
|
||||
$effect(() => {
|
||||
if (sticky) return;
|
||||
const t = setTimeout(() => {
|
||||
visible = false;
|
||||
onDone?.();
|
||||
}, 1900);
|
||||
return () => clearTimeout(t);
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<div class="stinger {tone} crt" class:sticky>
|
||||
<div class="slab">
|
||||
<div class="txt">{text}</div>
|
||||
{#if sub}<div class="sub pixel">{sub}</div>{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.stinger {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
z-index: 20;
|
||||
pointer-events: none;
|
||||
animation: fade 1.9s steps(1) forwards;
|
||||
}
|
||||
.stinger.sticky {
|
||||
animation: none;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.slab {
|
||||
background: rgba(8, 8, 12, 0.9);
|
||||
padding: 18px 34px 20px;
|
||||
border-top: 4px solid var(--tone);
|
||||
border-bottom: 4px solid var(--tone);
|
||||
text-align: center;
|
||||
transform-origin: center;
|
||||
animation: slam 0.32s cubic-bezier(0.1, 1.4, 0.3, 1) both;
|
||||
width: 100%;
|
||||
}
|
||||
.txt {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 900;
|
||||
font-size: clamp(42px, 9vw, 96px);
|
||||
line-height: 0.95;
|
||||
letter-spacing: -0.02em;
|
||||
text-transform: uppercase;
|
||||
color: var(--tone);
|
||||
text-shadow:
|
||||
4px 4px 0 #000,
|
||||
0 0 36px color-mix(in srgb, var(--tone) 55%, transparent);
|
||||
-webkit-text-stroke: 1px #000;
|
||||
}
|
||||
.sub {
|
||||
margin-top: 12px;
|
||||
color: var(--text);
|
||||
font-size: 11px;
|
||||
}
|
||||
.yellow {
|
||||
--tone: var(--p1);
|
||||
}
|
||||
.red {
|
||||
--tone: var(--p2);
|
||||
}
|
||||
.cyan {
|
||||
--tone: var(--c-brill);
|
||||
}
|
||||
.green {
|
||||
--tone: var(--hp);
|
||||
}
|
||||
@keyframes slam {
|
||||
0% {
|
||||
transform: scale(2.4);
|
||||
opacity: 0;
|
||||
}
|
||||
60% {
|
||||
transform: scale(0.94);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
@keyframes fade {
|
||||
0%,
|
||||
80% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,223 @@
|
||||
<script lang="ts">
|
||||
// Expandable "what the agent saw & thought" panel for one ply.
|
||||
import type { Ply } from '#lib/game.ts';
|
||||
import { fmtSec, fmtTok, fmtUsd } from '#lib/mock.ts';
|
||||
|
||||
let { ply, side, onclose }: { ply: Ply; side: 'w' | 'b'; onclose?: () => void } = $props();
|
||||
let tab: 'mind' | 'tools' | 'ctx' = $state('mind');
|
||||
const t = $derived(ply.m.thought);
|
||||
</script>
|
||||
|
||||
<div class="thought crt {side === 'w' ? 'p1' : 'p2'}">
|
||||
<div class="th">
|
||||
<span class="pixel who">{side === 'w' ? 'P1' : 'P2'} · ход {ply.num}{side === 'b' ? '…' : '.'} {ply.san}</span>
|
||||
<span class="mono meta">{fmtSec(ply.m.sec)} · {fmtTok(ply.m.tokens)} tok · {fmtUsd(ply.m.cost)}</span>
|
||||
<button class="x" onclick={onclose} aria-label="Закрыть">✕</button>
|
||||
</div>
|
||||
{#if t}
|
||||
<div class="tabs">
|
||||
<button class:on={tab === 'mind'} onclick={() => (tab = 'mind')}>Мысли</button>
|
||||
<button class:on={tab === 'tools'} onclick={() => (tab = 'tools')}>Тулы <i>{t.tools.length}</i></button>
|
||||
<button class:on={tab === 'ctx'} onclick={() => (tab = 'ctx')}>Контекст</button>
|
||||
</div>
|
||||
<div class="body">
|
||||
{#if tab === 'mind'}
|
||||
<p class="summary">{t.summary}<span class="cursor">▮</span></p>
|
||||
{#if t.note}
|
||||
<div class="note">
|
||||
<span class="pixel">заметка себе →</span>
|
||||
<span>{t.note}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if ply.m.trash}
|
||||
<div class="said">
|
||||
<span class="pixel">сказал сопернику</span>
|
||||
<span>«{ply.m.trash}»</span>
|
||||
</div>
|
||||
{/if}
|
||||
{:else if tab === 'tools'}
|
||||
<ol class="tools mono">
|
||||
{#each t.tools as tc}
|
||||
<li>
|
||||
<div class="call"><span class="fn">{tc.name}</span>(<span class="args">{tc.args}</span>)</div>
|
||||
<div class="out" class:ok={tc.ok}>→ {tc.out}</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ol>
|
||||
{:else}
|
||||
<div class="ctxhead pixel">точный контекст · fresh, без памяти</div>
|
||||
<pre class="ctx mono">{t.context}</pre>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="body empty">
|
||||
<p class="muted">Для этого хода мысли не сохранены (режим «Теория»): агент сделал ход без размышлений — {fmtSec(ply.m.sec)}, {fmtTok(ply.m.tokens)} tok.</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.thought {
|
||||
--acc: var(--p1);
|
||||
margin: 4px 0 8px;
|
||||
background: #0c0c12;
|
||||
border: 1px solid var(--line-2);
|
||||
border-left: 3px solid var(--acc);
|
||||
animation: poweron 0.28s cubic-bezier(0.2, 0.9, 0.2, 1) both;
|
||||
transform-origin: top center;
|
||||
}
|
||||
.thought.p2 {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.th {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 10px;
|
||||
padding: 7px 10px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.who {
|
||||
color: var(--acc);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.meta {
|
||||
margin-left: auto;
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
}
|
||||
.x {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
.x:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
.tabs {
|
||||
display: flex;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.tabs button {
|
||||
flex: 1;
|
||||
padding: 7px 8px;
|
||||
font-family: var(--font-display);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
border-right: 1px solid var(--line);
|
||||
}
|
||||
.tabs button:last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
.tabs button i {
|
||||
font-style: normal;
|
||||
color: var(--acc);
|
||||
}
|
||||
.tabs button.on {
|
||||
color: #000;
|
||||
background: var(--acc);
|
||||
}
|
||||
.tabs button.on i {
|
||||
color: #000;
|
||||
}
|
||||
.body {
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.summary {
|
||||
margin: 0;
|
||||
color: var(--text);
|
||||
}
|
||||
.cursor {
|
||||
color: var(--acc);
|
||||
animation: blink 1s steps(2) infinite;
|
||||
margin-left: 2px;
|
||||
}
|
||||
.note,
|
||||
.said {
|
||||
margin-top: 10px;
|
||||
padding: 8px 10px;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.note {
|
||||
background: rgba(255, 225, 77, 0.08);
|
||||
border: 1px dashed var(--p1);
|
||||
}
|
||||
.note .pixel {
|
||||
color: var(--p1);
|
||||
}
|
||||
.said {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
font-style: italic;
|
||||
}
|
||||
.said .pixel {
|
||||
color: var(--muted);
|
||||
}
|
||||
.tools {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
font-size: 11px;
|
||||
}
|
||||
.tools li {
|
||||
border: 1px solid var(--line);
|
||||
background: var(--panel);
|
||||
}
|
||||
.call {
|
||||
padding: 6px 8px;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
.fn {
|
||||
color: var(--c-brill);
|
||||
font-weight: 700;
|
||||
}
|
||||
.args {
|
||||
color: var(--text);
|
||||
}
|
||||
.out {
|
||||
padding: 6px 8px;
|
||||
border-top: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.out.ok {
|
||||
color: var(--hp);
|
||||
}
|
||||
.ctxhead {
|
||||
color: var(--muted);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.ctx {
|
||||
margin: 0;
|
||||
font-size: 10.5px;
|
||||
line-height: 1.45;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
color: #c9c6ba;
|
||||
max-height: 320px;
|
||||
overflow: auto;
|
||||
}
|
||||
.empty p {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
@keyframes poweron {
|
||||
0% {
|
||||
transform: scaleY(0.02);
|
||||
filter: brightness(3);
|
||||
}
|
||||
100% {
|
||||
transform: scaleY(1);
|
||||
filter: brightness(1);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,166 @@
|
||||
<script lang="ts">
|
||||
// YouTube-style clickbait thumbnail composed from CSS/SVG (no image generation).
|
||||
import { byId, type MatchCard } from '#lib/mock.ts';
|
||||
import Mark from './Mark.svelte';
|
||||
import MiniBoard from './MiniBoard.svelte';
|
||||
|
||||
let { m, big = false }: { m: MatchCard; big?: boolean } = $props();
|
||||
const w = $derived(byId(m.white));
|
||||
const b = $derived(byId(m.black));
|
||||
const loserSide = $derived(m.result === '1-0' ? 'b' : m.result === '0-1' ? 'w' : null);
|
||||
</script>
|
||||
|
||||
<div class="thumb {m.accent}" class:big>
|
||||
<div class="burst"></div>
|
||||
<div class="face l" class:loser={loserSide === 'w'}>
|
||||
<Mark e={w} size={big ? 120 : 72} />
|
||||
{#if loserSide === 'w'}<span class="x">✕</span>{/if}
|
||||
</div>
|
||||
<div class="boardbox">
|
||||
<MiniBoard fen={m.fen} />
|
||||
</div>
|
||||
<div class="face r" class:loser={loserSide === 'b'}>
|
||||
<Mark e={b} size={big ? 120 : 72} />
|
||||
{#if loserSide === 'b'}<span class="x">✕</span>{/if}
|
||||
</div>
|
||||
<div class="vs pixel">VS</div>
|
||||
<div class="caption">{m.caption}</div>
|
||||
<div class="res mono">{m.result}</div>
|
||||
{#if !m.rated}<div class="unrated pixel">UNRATED</div>{/if}
|
||||
<div class="dur mono">{m.moves} ходов</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.thumb {
|
||||
--acc: var(--p1);
|
||||
position: relative;
|
||||
aspect-ratio: 16 / 9;
|
||||
background: #101018;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--line);
|
||||
isolation: isolate;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
align-items: center;
|
||||
padding: 8% 6% 22%;
|
||||
}
|
||||
.thumb.yellow {
|
||||
--acc: var(--p1);
|
||||
}
|
||||
.thumb.red {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.thumb.cyan {
|
||||
--acc: var(--c-brill);
|
||||
}
|
||||
.thumb.green {
|
||||
--acc: var(--hp);
|
||||
}
|
||||
.burst {
|
||||
position: absolute;
|
||||
inset: -40%;
|
||||
background: repeating-conic-gradient(from 0deg, var(--acc) 0 6deg, transparent 6deg 14deg);
|
||||
opacity: 0.16;
|
||||
z-index: -1;
|
||||
animation: spin 60s linear infinite;
|
||||
}
|
||||
.face {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
position: relative;
|
||||
transform: rotate(-6deg);
|
||||
}
|
||||
.face.r {
|
||||
transform: rotate(6deg);
|
||||
}
|
||||
.face :global(svg) {
|
||||
box-shadow:
|
||||
0 0 0 3px #000,
|
||||
0 0 0 6px var(--acc);
|
||||
}
|
||||
.face.loser :global(svg) {
|
||||
filter: grayscale(1) brightness(0.6);
|
||||
}
|
||||
.x {
|
||||
position: absolute;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 900;
|
||||
font-size: 64px;
|
||||
color: var(--p2);
|
||||
text-shadow: 3px 3px 0 #000;
|
||||
transform: rotate(10deg);
|
||||
}
|
||||
.boardbox {
|
||||
width: 34%;
|
||||
min-width: 70px;
|
||||
transform: perspective(500px) rotateX(18deg);
|
||||
box-shadow:
|
||||
0 0 0 3px #000,
|
||||
0 18px 30px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
.vs {
|
||||
position: absolute;
|
||||
top: 8%;
|
||||
left: 50%;
|
||||
transform: translateX(-50%) rotate(-4deg);
|
||||
color: #000;
|
||||
background: var(--acc);
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.caption {
|
||||
position: absolute;
|
||||
left: 4%;
|
||||
right: 4%;
|
||||
bottom: 5%;
|
||||
font-family: var(--font-display);
|
||||
font-weight: 900;
|
||||
text-transform: uppercase;
|
||||
font-size: 15.5px;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
text-shadow:
|
||||
2px 2px 0 #000,
|
||||
-2px 2px 0 #000,
|
||||
2px -2px 0 #000,
|
||||
-2px -2px 0 #000,
|
||||
4px 4px 0 var(--acc);
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
.big .caption {
|
||||
font-size: 30px;
|
||||
}
|
||||
.res {
|
||||
position: absolute;
|
||||
top: 6%;
|
||||
right: 4%;
|
||||
background: #000;
|
||||
color: #fff;
|
||||
padding: 2px 6px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
border: 1px solid var(--line-2);
|
||||
}
|
||||
.dur {
|
||||
position: absolute;
|
||||
top: 6%;
|
||||
left: 4%;
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
.unrated {
|
||||
position: absolute;
|
||||
top: 34%;
|
||||
right: -14px;
|
||||
transform: rotate(14deg);
|
||||
background: var(--c-blunder);
|
||||
color: #fff;
|
||||
padding: 4px 24px;
|
||||
font-size: 9px;
|
||||
}
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,127 @@
|
||||
<script lang="ts">
|
||||
import type { Ply } from '#lib/game.ts';
|
||||
import type { Entity } from '#lib/mock.ts';
|
||||
import Mark from './Mark.svelte';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
let {
|
||||
plies,
|
||||
white,
|
||||
black,
|
||||
current,
|
||||
onselect
|
||||
}: { plies: Ply[]; white: Entity; black: Entity; current: number; onselect?: (i: number) => void } = $props();
|
||||
|
||||
const lines = $derived(plies.filter((p) => p.m.trash));
|
||||
let box: HTMLDivElement;
|
||||
$effect(() => {
|
||||
lines.length;
|
||||
current;
|
||||
tick().then(() => requestAnimationFrame(() => {
|
||||
if (!box) return;
|
||||
const last = lines[lines.length - 1];
|
||||
if (last && current >= last.idx) box.scrollTo({ top: box.scrollHeight });
|
||||
else {
|
||||
// nearest line at or before current
|
||||
const target = [...lines].reverse().find((l) => l.idx <= current);
|
||||
const el = target ? (box.querySelector(`[data-idx="${target.idx}"]`) as HTMLElement | null) : null;
|
||||
if (el) box.scrollTop = el.offsetTop - box.clientHeight / 2 + el.offsetHeight / 2;
|
||||
}
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="feed" bind:this={box}>
|
||||
{#each lines as p (p.idx)}
|
||||
<button class="line {p.color}" class:cur={p.idx === current} data-idx={p.idx} onclick={() => onselect?.(p.idx)}>
|
||||
<div class="av"><Mark e={p.color === 'w' ? white : black} size={26} /></div>
|
||||
<div class="bubble">
|
||||
<div class="hd pixel">
|
||||
<span>{p.color === 'w' ? 'P1' : 'P2'}</span>
|
||||
<span class="mono mv">{p.num}{p.color === 'w' ? '.' : '…'} {p.san}</span>
|
||||
</div>
|
||||
<div class="txt">{p.m.trash}</div>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.feed {
|
||||
position: relative;
|
||||
overflow: auto;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--line-2) transparent;
|
||||
}
|
||||
.line {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
gap: 8px;
|
||||
align-items: flex-end;
|
||||
text-align: left;
|
||||
max-width: 92%;
|
||||
}
|
||||
.line.b {
|
||||
grid-template-columns: 1fr auto;
|
||||
align-self: flex-end;
|
||||
}
|
||||
.line.b .av {
|
||||
order: 2;
|
||||
}
|
||||
.av {
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
.bubble {
|
||||
--acc: var(--p1);
|
||||
position: relative;
|
||||
background: var(--panel-2);
|
||||
border: 1px solid var(--line-2);
|
||||
padding: 6px 10px 8px;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
.b .bubble {
|
||||
--acc: var(--p2);
|
||||
}
|
||||
.bubble::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -1px;
|
||||
left: -7px;
|
||||
border: 6px solid transparent;
|
||||
border-bottom-color: var(--line-2);
|
||||
border-right-color: var(--line-2);
|
||||
}
|
||||
.b .bubble::after {
|
||||
left: auto;
|
||||
right: -7px;
|
||||
border-right-color: transparent;
|
||||
border-left-color: var(--line-2);
|
||||
}
|
||||
.cur .bubble {
|
||||
border-color: var(--acc);
|
||||
box-shadow: 0 0 0 1px var(--acc);
|
||||
}
|
||||
.hd {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
color: var(--acc);
|
||||
margin-bottom: 3px;
|
||||
font-size: 8px;
|
||||
}
|
||||
.mv {
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
.txt {
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
color: var(--text);
|
||||
}
|
||||
.line:hover .bubble {
|
||||
border-color: var(--acc);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user