Spaces:
Running

File size: 13,383 Bytes
95ab2cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
import { useMemo, useState } from 'react'
import { Copy, Check, Download } from 'lucide-react'
import { STATUS_META } from './status'
import { OUTLOOK_CAVEAT, OUTLOOK_CONCLUSION, OUTLOOK_DISCLAIMER, OUTLOOK_POINTS, OUTLOOK_QUESTIONS, outlookText } from '../data/outlook'
import { CHECK_DATE, buildText, predText, predTopics, stats, theoryGroups, theoryText } from '../lib/kkText'
import type { Prediction, Theory } from '../data/types'

const BASE = import.meta.env.BASE_URL

async function copyText(s: string) {
  try {
    await navigator.clipboard.writeText(s)
    return true
  } catch {
    const ta = document.createElement('textarea')
    ta.value = s
    ta.style.position = 'fixed'
    ta.style.opacity = '0'
    document.body.appendChild(ta)
    ta.select()
    const ok = document.execCommand('copy')
    ta.remove()
    return ok
  }
}

function CopyBtn({ text, label = '复制', strong }: { text: string; label?: string; strong?: boolean }) {
  const [done, setDone] = useState(false)
  return (
    <button
      onClick={() =>
        copyText(text).then((ok) => {
          if (!ok) return
          setDone(true)
          setTimeout(() => setDone(false), 1500)
        })
      }
      className={
        strong
          ? 'inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-2 text-sm font-bold text-primary-foreground'
          : 'inline-flex shrink-0 items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-muted-foreground hover:text-foreground'
      }
    >
      {done ? <Check size={strong ? 15 : 12} /> : <Copy size={strong ? 15 : 12} />}
      {done ? '已复制' : label}
    </button>
  )
}

function Row({ k, children }: { k: string; children: React.ReactNode }) {
  return (
    <p className="mt-1.5 text-sm leading-relaxed">
      <span className="mr-1 font-semibold text-foreground">{k}:</span>
      <span className="text-foreground/85">{children}</span>
    </p>
  )
}

function TheoryBlock({ t }: { t: Theory }) {
  return (
    <article id={`tx-${t.id}`} className="scroll-mt-24 border-b border-border/60 py-4 last:border-b-0">
      <div className="flex items-start justify-between gap-3">
        <h4 className="text-[15px] font-bold leading-snug">
          <span className="mr-1.5 font-mono text-xs text-muted-foreground">{t.id}</span>
          {t.title}
        </h4>
        <CopyBtn text={theoryText(t, false)} />
      </div>
      <Row k="观点">{t.summary}</Row>
      <Row k="原话">
        {t.quote}
        <span className="text-muted-foreground">({t.ref})</span>
      </Row>
      {t.hindsight && <Row k="15 年后回头看">{t.hindsight}</Row>}
    </article>
  )
}

function PredBlock({ p }: { p: Prediction }) {
  const m = STATUS_META[p.status]
  return (
    <article id={`tx-${p.id}`} className="scroll-mt-24 border-b border-border/60 py-4 last:border-b-0">
      <div className="flex items-start justify-between gap-3">
        <h4 className="text-[15px] font-bold leading-snug">
          <span className="mr-1.5 font-mono text-xs text-muted-foreground">{p.id}</span>
          {p.title}
          <span className="ml-2 inline-block whitespace-nowrap rounded-full px-2 py-0.5 align-middle text-[11px] font-semibold" style={{ color: m.color, border: `1px solid ${m.color}66` }}>
            {m.label}
          </span>
        </h4>
        <CopyBtn text={predText(p, false)} />
      </div>
      <Row k="原话">{p.quote}</Row>
      <Row k="意思">{p.claim}</Row>
      <Row k="出处">
        {p.ref};发帖 {p.posted};预测期限 {p.horizon}
      </Row>
      <Row k="核对结论">{p.verdict}</Row>
      {p.evidence.length > 0 && (
        <div className="mt-1.5 text-sm leading-relaxed">
          <span className="font-semibold">依据:</span>
          <ol className="mt-0.5 list-decimal space-y-0.5 pl-5 text-foreground/80">
            {p.evidence.map((e, i) => (
              <li key={i}>
                {e.text}
                <span className="text-muted-foreground">({e.source})</span>
              </li>
            ))}
          </ol>
        </div>
      )}
    </article>
  )
}

export default function TextVersion() {
  const [part, setPart] = useState<'all' | 'theory' | 'pred' | 'ai'>('all')
  const s = stats()
  const full = useMemo(() => buildText(false), [])
  const theoryAll = useMemo(() => theoryGroups.flatMap((g) => g.items.map((t) => theoryText(t, false))).join('\n\n'), [])
  const predAll = useMemo(() => predTopics.flatMap((g) => g.items.map((p) => predText(p, false))).join('\n\n'), [])
  const aiAll = useMemo(() => outlookText(false), [])
  const chars = [...full].length

  return (
    <section className="mt-4">
      <div className="rounded-xl border border-border bg-card/60 p-4">
        <h3 className="text-base font-black">📝 文字版 · kkndme 的理论与预测</h3>
        <p className="mt-1 text-sm leading-relaxed text-muted-foreground">
          把 {theoryGroups.reduce((n, g) => n + g.items.length, 0)} 条理论和 {s.n} 条预测全部写成文字:每条理论有观点、原话、15 年后回头看;每条预测有原话、意思、出处、核对结论和依据;最后附 AI 按他的理论框架对未来房价的推演。核对截至 {CHECK_DATE},全文约 {(chars / 10000).toFixed(1)} 万字,可以整份复制、下载,也可以单条复制。
        </p>
        <div className="mt-3 flex flex-wrap gap-2">
          <CopyBtn text={full} label="复制全文" strong />
          <a href={`${BASE}dl/kkndme-text.txt`} download="kkndme理论与预测-文字版.txt" className="inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-2 text-sm font-bold">
            <Download size={15} />
            下载 TXT
          </a>
          <a href={`${BASE}dl/kkndme-text.md`} download="kkndme理论与预测-文字版.md" className="inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-2 text-sm font-bold">
            <Download size={15} />
            下载 Markdown
          </a>
          <CopyBtn text={theoryAll} label="只复制理论" />
          <CopyBtn text={predAll} label="只复制预测" />
          <CopyBtn text={aiAll} label="只复制 AI 推演" />
        </div>
        <p className="mt-3 rounded-lg bg-muted/40 px-3 py-2 text-sm leading-relaxed">
          <b>总账:</b>
          {s.n} 条预测中,已到期 {s.due} 条——说中 <b style={{ color: STATUS_META.correct.color }}>{s.correct}</b> 条、没说中{' '}
          <b style={{ color: STATUS_META.wrong.color }}>{s.wrong}</b> 条、存疑 <b style={{ color: STATUS_META.disputed.color }}>{s.disputed}</b> 条;还没到时间 {s.pending} 条。命中率:只算能分对错的是 {s.hit}%,存疑算半分约 {s.half}%,存疑一律当错(最严格)约 {s.strict}%。
        </p>
      </div>

      <div className="sticky top-0 z-10 -mx-4 mt-4 flex gap-1 overflow-x-auto bg-background/95 px-4 py-2 backdrop-blur">
        {(
          [
            ['all', '全部'],
            ['theory', `理论框架 ${theoryGroups.reduce((n, g) => n + g.items.length, 0)}`],
            ['pred', `预测与核对 ${s.n}`],
            ['ai', 'AI 推演'],
          ] as const
        ).map(([k, label]) => (
          <button
            key={k}
            onClick={() => setPart(k)}
            className={`shrink-0 rounded-full border px-3 py-1 text-xs font-semibold ${part === k ? 'border-foreground bg-foreground text-background' : 'border-border text-muted-foreground'}`}
          >
            {label}
          </button>
        ))}
        <span className="mx-1 w-px shrink-0 bg-border" />
        {([] as [string, string, string][])
          .concat(part === 'all' || part === 'theory' ? theoryGroups.map((g): [string, string, string] => ['th', g.name, g.items[0].id]) : [])
          .concat(part === 'all' || part === 'pred' ? predTopics.map((g): [string, string, string] => ['pd', g.name, g.items[0].id]) : [])
          .map(([kind, name, id]) => (
            <button
              key={kind + name}
              onClick={() => document.getElementById(`tx-${id}`)?.scrollIntoView({ behavior: 'smooth', block: 'start' })}
              className="shrink-0 whitespace-nowrap rounded-full px-2.5 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground"
            >
              {kind === 'th' ? '理论·' : '预测·'}
              {name}
            </button>
          ))}
      </div>

      {(part === 'all' || part === 'theory') && (
        <div className="mt-4">
          <h3 className="text-lg font-black">第一部分 · 理论框架</h3>
          {theoryGroups.map((g, gi) => (
            <div key={g.name} className="mt-4 rounded-xl border border-border bg-card/40 px-4">
              <div className="border-b border-border py-2.5 text-sm font-bold">
                {gi + 1}. {g.name}
                <span className="ml-1.5 font-normal text-muted-foreground">{g.items.length} 条</span>
              </div>
              {g.items.map((t) => (
                <TheoryBlock key={t.id} t={t} />
              ))}
            </div>
          ))}
        </div>
      )}

      {(part === 'all' || part === 'pred') && (
        <div className="mt-8">
          <h3 className="text-lg font-black">第二部分 · 预测与核对</h3>
          {predTopics.map((g, gi) => {
            const ok = g.items.filter((p) => p.status === 'correct').length
            const no = g.items.filter((p) => p.status === 'wrong').length
            return (
              <div key={g.name} className="mt-4 rounded-xl border border-border bg-card/40 px-4">
                <div className="border-b border-border py-2.5 text-sm font-bold">
                  {gi + 1}. {g.name}
                  <span className="ml-1.5 font-normal text-muted-foreground">
                    {g.items.length} 条 · 说中 {ok} · 没说中 {no}
                  </span>
                </div>
                {g.items.map((p) => (
                  <PredBlock key={p.id} p={p} />
                ))}
              </div>
            )
          })}
        </div>
      )}
      {(part === 'all' || part === 'ai') && <AiOutlook />}
      <p className="mt-6 text-xs text-muted-foreground">说明:前两部分仅做历史言论的事实核对;第三部分为 AI 推演。全部内容均不构成任何买房或投资建议。</p>
    </section>
  )
}

const TONE = { up: '#34d399', down: '#f87171', flat: '#fbbf24' } as const

function AiOutlook() {
  return (
    <div className="mt-8" id="tx-ai">
      <div className="flex flex-wrap items-center gap-2">
        <h3 className="text-lg font-black">第三部分 · AI 推演:按理论框架看未来房价</h3>
        <span className="rounded-full border border-amber-400/60 bg-amber-400/10 px-2 py-0.5 text-xs font-bold text-amber-300">不构成投资建议</span>
      </div>
      <p className="mt-2 rounded-lg border border-amber-400/30 bg-amber-400/5 px-3 py-2 text-sm leading-relaxed text-muted-foreground">{OUTLOOK_DISCLAIMER}</p>
      <div className="mt-4 rounded-xl border border-border bg-card/40 p-4">
        <div className="text-sm font-bold">理论框架回答的三个根本问题</div>
        <div className="mt-3 grid gap-2 sm:grid-cols-3">
          {OUTLOOK_QUESTIONS.map((x, i) => (
            <div key={x.q} className="rounded-lg bg-muted/40 px-3 py-2.5">
              <div className="text-xs text-muted-foreground">问题 {i + 1}</div>
              <div className="mt-0.5 font-black">{x.q}</div>
              <div className="mt-1 text-xs leading-relaxed text-muted-foreground">
                {x.basis}({x.refs.join('、')})
              </div>
            </div>
          ))}
        </div>
      </div>
      <div className="mt-4 grid gap-3">
        {OUTLOOK_POINTS.map((pt) => (
          <div key={pt.no} className="rounded-xl border border-border bg-card/40 p-4" style={{ borderLeft: `3px solid ${TONE[pt.tone]}` }}>
            <div className="flex flex-wrap items-baseline gap-2">
              <span className="font-mono text-sm font-bold" style={{ color: TONE[pt.tone] }}>
                {pt.no}
              </span>
              <span className="text-base font-black">{pt.title}</span>
              <span className="text-sm font-bold">{pt.short}</span>
            </div>
            <div className="mt-1.5 text-xs text-muted-foreground">
              依据:{pt.basis}({pt.refs.join('、')})
            </div>
            <p className="mt-2 text-sm leading-relaxed">{pt.detail}</p>
          </div>
        ))}
      </div>
      <div className="mt-4 rounded-xl border border-border bg-card/40 p-4">
        <div className="text-sm font-bold">要打折扣的地方:{OUTLOOK_CAVEAT.title}</div>
        <div className="mt-3 flex flex-wrap gap-3">
          {OUTLOOK_CAVEAT.stats.map((x) => (
            <div key={x.l} className="rounded-lg bg-muted/40 px-3 py-2">
              <div className="text-xs text-muted-foreground">{x.l}</div>
              <div className="font-mono text-xl font-black">{x.v}</div>
            </div>
          ))}
        </div>
        <p className="mt-3 text-sm leading-relaxed text-muted-foreground">{OUTLOOK_CAVEAT.text}</p>
      </div>
      <p className="mt-4 rounded-xl bg-muted/40 px-4 py-3 text-sm font-bold leading-relaxed">结论:{OUTLOOK_CONCLUSION}</p>
    </div>
  )
}