viz4.html 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  1. <!doctype html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>工序五层筛选</title>
  6. <style>
  7. :root {
  8. --bg: #f8fafc;
  9. --panel: #ffffff;
  10. --panel2: #f1f5f9;
  11. --border: #e2e8f0;
  12. --fg: #0f172a;
  13. --muted: #64748b;
  14. --accent: #3b82f6;
  15. --accent2: #8b5cf6;
  16. --tag-bg: #e2e8f0;
  17. --tag-bg-active: #3b82f6;
  18. --tag-fg-active: #fff;
  19. --code: #f1f5f9;
  20. --warn: #eab308;
  21. --suggest: #8b5cf6;
  22. --inferred: #94a3b8;
  23. }
  24. * {
  25. box-sizing: border-box;
  26. }
  27. html,
  28. body {
  29. margin: 0;
  30. height: 100%;
  31. background: var(--bg);
  32. color: var(--fg);
  33. font:
  34. 13px/1.55 -apple-system,
  35. BlinkMacSystemFont,
  36. "PingFang SC",
  37. "Helvetica Neue",
  38. sans-serif;
  39. }
  40. header {
  41. display: flex;
  42. align-items: center;
  43. gap: 12px;
  44. padding: 8px 14px;
  45. border-bottom: 1px solid var(--border);
  46. background: var(--panel);
  47. position: sticky;
  48. top: 0;
  49. z-index: 5;
  50. flex-wrap: wrap;
  51. }
  52. h1 {
  53. font-size: 14px;
  54. margin: 0;
  55. font-weight: 600;
  56. }
  57. .stats {
  58. color: var(--muted);
  59. font-size: 11px;
  60. }
  61. .clear-all {
  62. margin-left: auto;
  63. font-size: 11px;
  64. color: var(--muted);
  65. cursor: pointer;
  66. padding: 4px 10px;
  67. border: 1px solid var(--border);
  68. border-radius: 4px;
  69. background: transparent;
  70. }
  71. .clear-all:hover {
  72. color: var(--fg);
  73. border-color: var(--accent);
  74. }
  75. .clear-all.active {
  76. color: var(--warn);
  77. border-color: var(--warn);
  78. }
  79. .exit-fs {
  80. margin-left: auto;
  81. font-size: 11px;
  82. color: var(--muted);
  83. cursor: pointer;
  84. padding: 4px 10px;
  85. border: 1px solid var(--border);
  86. border-radius: 4px;
  87. background: transparent;
  88. display: none;
  89. }
  90. .exit-fs:hover {
  91. color: var(--fg);
  92. border-color: var(--accent);
  93. }
  94. main {
  95. display: grid;
  96. grid-template-columns: 160px 360px 220px 320px 1fr;
  97. height: 100vh;
  98. min-width: 1480px;
  99. background: var(--bg);
  100. }
  101. section {
  102. overflow: auto;
  103. border-right: 1px solid var(--border);
  104. padding: 8px 10px;
  105. }
  106. section:last-child {
  107. border-right: none;
  108. }
  109. section.fac1 {
  110. background: var(--panel);
  111. }
  112. section.fac2 {
  113. background: #f8fafc;
  114. }
  115. section.fac3 {
  116. background: var(--panel);
  117. }
  118. section.fac4 {
  119. background: #f4f4f5;
  120. }
  121. section.detail {
  122. background: var(--panel);
  123. }
  124. .col-title {
  125. font-size: 10px;
  126. text-transform: uppercase;
  127. letter-spacing: 0.6px;
  128. color: var(--muted);
  129. margin: 2px 4px 8px;
  130. display: flex;
  131. justify-content: space-between;
  132. align-items: baseline;
  133. }
  134. .col-count {
  135. font-size: 10px;
  136. color: var(--muted);
  137. }
  138. .col-clear {
  139. font-size: 10px;
  140. color: var(--accent);
  141. cursor: pointer;
  142. display: none;
  143. }
  144. .col-clear.show {
  145. display: inline;
  146. }
  147. .item {
  148. padding: 6px 8px;
  149. border-radius: 5px;
  150. cursor: pointer;
  151. margin-bottom: 3px;
  152. border: 1px solid transparent;
  153. display: flex;
  154. justify-content: space-between;
  155. align-items: center;
  156. gap: 6px;
  157. }
  158. .item:hover:not(.disabled):not(.active) {
  159. background: var(--panel2);
  160. }
  161. .item.active {
  162. background: var(--tag-bg-active);
  163. color: var(--tag-fg-active);
  164. border-color: var(--tag-bg-active);
  165. }
  166. .item.disabled {
  167. opacity: 0.32;
  168. cursor: not-allowed;
  169. }
  170. .item-name {
  171. flex: 1;
  172. min-width: 0;
  173. font-size: 12px;
  174. white-space: nowrap;
  175. overflow: hidden;
  176. text-overflow: ellipsis;
  177. }
  178. .item-count {
  179. font-size: 10px;
  180. background: var(--bg);
  181. padding: 1px 5px;
  182. border-radius: 8px;
  183. color: var(--muted);
  184. min-width: 20px;
  185. text-align: center;
  186. flex-shrink: 0;
  187. }
  188. .item.active .item-count {
  189. background: rgba(0, 0, 0, 0.3);
  190. color: #fff;
  191. }
  192. .item-def {
  193. display: block;
  194. font-size: 10px;
  195. color: var(--muted);
  196. margin-top: 2px;
  197. line-height: 1.4;
  198. }
  199. .item.active .item-def {
  200. color: rgba(255, 255, 255, 0.85);
  201. }
  202. .item-stack {
  203. flex: 1;
  204. min-width: 0;
  205. }
  206. /* col-2 tabs */
  207. .scope-tabs {
  208. display: flex;
  209. gap: 4px;
  210. margin: 0 0 8px;
  211. border-bottom: 1px solid var(--border);
  212. padding-bottom: 5px;
  213. }
  214. .scope-tab {
  215. padding: 4px 10px;
  216. border-radius: 5px 5px 0 0;
  217. cursor: pointer;
  218. font-size: 12px;
  219. color: var(--muted);
  220. background: transparent;
  221. border: 1px solid transparent;
  222. border-bottom: none;
  223. user-select: none;
  224. }
  225. .scope-tab.active {
  226. color: var(--fg);
  227. background: var(--panel2);
  228. border-color: var(--border);
  229. }
  230. .scope-tab:hover:not(.active) {
  231. color: var(--fg);
  232. }
  233. .scope-pane {
  234. display: none;
  235. }
  236. .scope-pane.active {
  237. display: block;
  238. }
  239. .scope-meta {
  240. font-size: 10px;
  241. color: var(--muted);
  242. margin: 0 4px 8px;
  243. line-height: 1.4;
  244. }
  245. /* facets */
  246. .facet-title {
  247. margin-top: 10px;
  248. padding: 4px 6px;
  249. font-size: 11px;
  250. color: var(--muted);
  251. font-weight: 600;
  252. border-bottom: 1px solid var(--border);
  253. text-transform: uppercase;
  254. letter-spacing: 0.5px;
  255. }
  256. .facet-title:first-child {
  257. margin-top: 0;
  258. }
  259. /* itemsets (pattern tab) */
  260. .iset {
  261. padding: 8px 10px;
  262. border-radius: 5px;
  263. cursor: pointer;
  264. margin-bottom: 5px;
  265. border: 1px solid var(--border);
  266. background: var(--panel2);
  267. }
  268. .iset:hover:not(.disabled):not(.active) {
  269. border-color: var(--accent);
  270. }
  271. .iset.active {
  272. border-color: var(--accent);
  273. background: #eff6ff;
  274. box-shadow: 0 0 0 1px var(--accent) inset;
  275. }
  276. .iset.disabled {
  277. opacity: 0.32;
  278. cursor: not-allowed;
  279. }
  280. .iset-head {
  281. display: flex;
  282. align-items: center;
  283. gap: 6px;
  284. margin-bottom: 5px;
  285. }
  286. .iset-sup {
  287. background: var(--accent);
  288. color: #fff;
  289. padding: 1px 7px;
  290. border-radius: 3px;
  291. font-weight: 700;
  292. font-size: 11px;
  293. }
  294. .iset-k {
  295. background: var(--tag-bg);
  296. color: var(--fg);
  297. padding: 1px 6px;
  298. border-radius: 3px;
  299. font-size: 10px;
  300. letter-spacing: 0.3px;
  301. }
  302. .iset-meta {
  303. font-size: 10px;
  304. color: var(--muted);
  305. margin-left: auto;
  306. }
  307. .iset-paths {
  308. display: flex;
  309. flex-direction: column;
  310. gap: 3px;
  311. }
  312. .iset-path {
  313. display: flex;
  314. gap: 5px;
  315. font-size: 11px;
  316. line-height: 1.4;
  317. align-items: flex-start;
  318. }
  319. .iset-fdot {
  320. width: 18px;
  321. flex-shrink: 0;
  322. font-size: 9px;
  323. font-weight: 700;
  324. text-align: center;
  325. border-radius: 3px;
  326. line-height: 16px;
  327. height: 16px;
  328. letter-spacing: 0;
  329. margin-top: 1px;
  330. }
  331. .iset-fdot.shi {
  332. background: #dbeafe;
  333. color: #1d4ed8;
  334. }
  335. .iset-fdot.xing {
  336. background: #f3e8ff;
  337. color: #7e22ce;
  338. }
  339. .iset-fdot.both {
  340. background: #fef9c3;
  341. color: #a16207;
  342. }
  343. .iset-leaf {
  344. font-weight: 600;
  345. color: var(--fg);
  346. word-break: break-all;
  347. }
  348. .iset-parent {
  349. color: var(--muted);
  350. font-size: 10px;
  351. margin-top: 1px;
  352. word-break: break-all;
  353. line-height: 1.3;
  354. font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  355. }
  356. /* tree */
  357. .tnode {
  358. margin-left: 0;
  359. }
  360. .tnode .tnode {
  361. margin-left: 12px;
  362. border-left: 1px dashed var(--border);
  363. padding-left: 6px;
  364. }
  365. .tline {
  366. display: flex;
  367. align-items: center;
  368. gap: 4px;
  369. padding: 3px 4px;
  370. border-radius: 4px;
  371. cursor: pointer;
  372. font-size: 12px;
  373. line-height: 1.35;
  374. }
  375. .tline:hover:not(.disabled):not(.active) {
  376. background: var(--panel2);
  377. }
  378. .tline.active {
  379. background: var(--tag-bg-active);
  380. color: var(--tag-fg-active);
  381. }
  382. .tline.disabled {
  383. opacity: 0.32;
  384. cursor: not-allowed;
  385. }
  386. .tline.suggested .tname {
  387. color: var(--suggest);
  388. font-style: italic;
  389. }
  390. .tline.suggested.active .tname {
  391. color: #fff;
  392. }
  393. .tline.inferred .tname {
  394. color: var(--inferred);
  395. font-style: italic;
  396. }
  397. .tline.inferred.active .tname {
  398. color: #fff;
  399. }
  400. .tcaret {
  401. width: 12px;
  402. display: inline-block;
  403. text-align: center;
  404. color: var(--muted);
  405. cursor: pointer;
  406. user-select: none;
  407. flex-shrink: 0;
  408. font-size: 10px;
  409. }
  410. .tcaret.invis {
  411. visibility: hidden;
  412. }
  413. .tname {
  414. flex: 1;
  415. min-width: 0;
  416. white-space: nowrap;
  417. overflow: hidden;
  418. text-overflow: ellipsis;
  419. }
  420. .tcount {
  421. font-size: 10px;
  422. color: var(--muted);
  423. background: var(--bg);
  424. padding: 1px 5px;
  425. border-radius: 8px;
  426. flex-shrink: 0;
  427. }
  428. .tline.active .tcount {
  429. background: rgba(0, 0, 0, 0.3);
  430. color: #fff;
  431. }
  432. .tcollapsed > .tnode {
  433. display: none;
  434. }
  435. /* fragments list */
  436. .frag {
  437. padding: 7px 9px;
  438. border-radius: 5px;
  439. cursor: pointer;
  440. margin-bottom: 4px;
  441. border: 1px solid var(--border);
  442. background: var(--panel);
  443. }
  444. .frag:hover {
  445. background: var(--panel2);
  446. }
  447. .frag.active {
  448. border-color: var(--accent);
  449. background: var(--panel2);
  450. }
  451. .frag-head {
  452. font-size: 10px;
  453. color: var(--muted);
  454. margin-bottom: 3px;
  455. display: flex;
  456. gap: 6px;
  457. align-items: center;
  458. }
  459. .case-badge {
  460. background: var(--accent);
  461. color: #fff;
  462. padding: 1px 5px;
  463. border-radius: 3px;
  464. font-weight: 600;
  465. font-size: 10px;
  466. }
  467. .frag-badge {
  468. background: var(--accent2);
  469. color: #fff;
  470. padding: 1px 5px;
  471. border-radius: 3px;
  472. font-weight: 600;
  473. font-size: 10px;
  474. }
  475. .act-badge {
  476. background: var(--warn);
  477. color: #000;
  478. padding: 1px 5px;
  479. border-radius: 3px;
  480. font-weight: 600;
  481. font-size: 10px;
  482. }
  483. .frag-sig {
  484. font-size: 11px;
  485. color: var(--muted);
  486. margin-top: 2px;
  487. font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  488. }
  489. .frag-body {
  490. font-size: 12px;
  491. color: #334155;
  492. margin-top: 4px;
  493. line-height: 1.45;
  494. display: -webkit-box;
  495. -webkit-line-clamp: 2;
  496. -webkit-box-orient: vertical;
  497. overflow: hidden;
  498. }
  499. /* detail */
  500. .detail-empty {
  501. color: var(--muted);
  502. text-align: center;
  503. padding: 60px 20px;
  504. font-size: 13px;
  505. }
  506. .detail h2 {
  507. font-size: 14px;
  508. margin: 0 0 8px;
  509. display: flex;
  510. gap: 8px;
  511. align-items: center;
  512. flex-wrap: wrap;
  513. }
  514. .case-title {
  515. font-size: 12px;
  516. color: var(--accent);
  517. margin: 6px 0;
  518. line-height: 1.5;
  519. }
  520. .case-title a {
  521. color: var(--accent);
  522. text-decoration: none;
  523. }
  524. .case-title a:hover {
  525. text-decoration: underline;
  526. }
  527. .detail-section {
  528. margin: 12px 0;
  529. }
  530. .detail-section h3 {
  531. font-size: 10px;
  532. color: var(--muted);
  533. text-transform: uppercase;
  534. letter-spacing: 0.6px;
  535. margin: 0 0 6px;
  536. font-weight: 600;
  537. }
  538. .body-text {
  539. font-size: 12px;
  540. line-height: 1.6;
  541. color: #334155;
  542. background: var(--code);
  543. padding: 8px 10px;
  544. border-radius: 5px;
  545. white-space: pre-wrap;
  546. }
  547. .effect-card {
  548. background: var(--code);
  549. border-radius: 5px;
  550. padding: 7px 9px;
  551. margin-bottom: 5px;
  552. border-left: 3px solid var(--accent2);
  553. font-size: 12px;
  554. }
  555. .effect-stmt {
  556. font-weight: 600;
  557. margin-bottom: 4px;
  558. }
  559. .effect-meta {
  560. color: var(--muted);
  561. font-size: 11px;
  562. margin-top: 3px;
  563. }
  564. .pill {
  565. display: inline-block;
  566. padding: 1px 6px;
  567. background: var(--tag-bg);
  568. border-radius: 8px;
  569. font-size: 11px;
  570. margin-right: 3px;
  571. margin-bottom: 3px;
  572. }
  573. .pill.in {
  574. background: #dbeafe;
  575. color: #1e3a8a;
  576. }
  577. .pill.out {
  578. background: #f3e8ff;
  579. color: #581c87;
  580. }
  581. .pill.cfg {
  582. background: #fef9c3;
  583. color: #854d0e;
  584. }
  585. .io-row {
  586. margin-bottom: 4px;
  587. font-size: 11px;
  588. }
  589. .io-row .lbl {
  590. color: var(--muted);
  591. font-size: 10px;
  592. margin-right: 6px;
  593. text-transform: uppercase;
  594. }
  595. .pathline {
  596. font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  597. font-size: 11px;
  598. color: var(--accent);
  599. margin-bottom: 2px;
  600. word-break: break-all;
  601. }
  602. .pathline.suggest {
  603. color: var(--suggest);
  604. }
  605. .rationale {
  606. color: var(--muted);
  607. font-size: 11px;
  608. margin-bottom: 6px;
  609. margin-left: 4px;
  610. line-height: 1.45;
  611. }
  612. .json-raw {
  613. font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  614. font-size: 10px;
  615. background: var(--code);
  616. padding: 8px;
  617. border-radius: 5px;
  618. white-space: pre-wrap;
  619. color: var(--fg);
  620. max-height: 240px;
  621. overflow: auto;
  622. }
  623. details summary {
  624. cursor: pointer;
  625. color: var(--muted);
  626. font-size: 10px;
  627. margin: 6px 0;
  628. user-select: none;
  629. }
  630. details summary:hover {
  631. color: var(--fg);
  632. }
  633. .empty-msg {
  634. color: var(--muted);
  635. text-align: center;
  636. padding: 30px 10px;
  637. font-size: 11px;
  638. font-style: italic;
  639. }
  640. /* modality side filter (column 3 internal) */
  641. .mod-filter {
  642. margin: 0 4px 8px;
  643. padding: 6px 6px 4px;
  644. background: var(--code);
  645. border: 1px solid var(--border);
  646. border-radius: 5px;
  647. }
  648. .mod-filter-row {
  649. display: flex;
  650. align-items: center;
  651. gap: 6px;
  652. margin-bottom: 4px;
  653. }
  654. .mod-filter-row:last-child {
  655. margin-bottom: 0;
  656. }
  657. .mod-filter-lbl {
  658. font-size: 10px;
  659. color: var(--muted);
  660. min-width: 42px;
  661. flex-shrink: 0;
  662. }
  663. .mod-chips {
  664. display: flex;
  665. gap: 4px;
  666. flex-wrap: wrap;
  667. }
  668. .mod-chip {
  669. font-size: 11px;
  670. padding: 1px 7px;
  671. background: var(--tag-bg);
  672. border-radius: 8px;
  673. cursor: pointer;
  674. color: var(--fg);
  675. user-select: none;
  676. border: 1px solid transparent;
  677. }
  678. .mod-chip:hover:not(.disabled) {
  679. background: var(--panel2);
  680. border-color: var(--border);
  681. }
  682. .mod-chip.active {
  683. background: var(--tag-bg-active);
  684. color: var(--tag-fg-active);
  685. }
  686. .mod-chip.disabled {
  687. opacity: 0.32;
  688. cursor: not-allowed;
  689. }
  690. /* selection summary chip in header */
  691. .filter-chip {
  692. font-size: 11px;
  693. padding: 3px 8px;
  694. background: var(--tag-bg);
  695. border-radius: 10px;
  696. color: var(--fg);
  697. display: inline-flex;
  698. align-items: center;
  699. gap: 6px;
  700. }
  701. .filter-chip .x {
  702. color: var(--muted);
  703. cursor: pointer;
  704. font-weight: bold;
  705. }
  706. .filter-chip .x:hover {
  707. color: var(--warn);
  708. }
  709. .filter-chip .lbl {
  710. color: var(--muted);
  711. font-size: 9px;
  712. text-transform: uppercase;
  713. }
  714. </style>
  715. </head>
  716. <body>
  717. <header>
  718. <h1>工序五层筛选</h1>
  719. <span class="stats" id="stats"></span>
  720. <span id="chips"></span>
  721. <button class="exit-fs" id="exitFs">退出全屏</button>
  722. <button class="clear-all" id="clearAll">清除全部筛选</button>
  723. </header>
  724. <main>
  725. <section class="fac1" id="actCol">
  726. <div class="col-title">
  727. <span>① 动作</span><span class="col-count" id="actCnt"></span>
  728. </div>
  729. <div id="actList"></div>
  730. </section>
  731. <section class="fac2" id="scopeCol">
  732. <div class="col-title">
  733. <span>② 作用域</span>
  734. <span class="col-count" id="scopeStat"></span>
  735. </div>
  736. <div class="scope-tabs">
  737. <div class="scope-tab" data-mode="node" id="tabNode">
  738. node · 内容树
  739. </div>
  740. <div class="scope-tab" data-mode="pattern" id="tabPattern">
  741. pattern · 频繁项集
  742. </div>
  743. <span
  744. class="col-clear"
  745. id="scopeClear"
  746. style="margin-left: auto; align-self: center"
  747. >清除</span
  748. >
  749. </div>
  750. <div class="scope-pane" id="paneNode">
  751. <div class="facet-title">实质</div>
  752. <div id="shizhiTree"></div>
  753. <div class="facet-title">形式</div>
  754. <div id="xingshiTree"></div>
  755. </div>
  756. <div class="scope-pane" id="panePattern">
  757. <div class="scope-meta" id="isParams"></div>
  758. <div id="isList"></div>
  759. </div>
  760. </section>
  761. <section class="fac3" id="modCol">
  762. <div class="col-title">
  763. <span>③ 输入 → 输出模态</span
  764. ><span class="col-clear" id="modClear">清除</span>
  765. </div>
  766. <div class="mod-filter">
  767. <div class="mod-filter-row">
  768. <span class="mod-filter-lbl">输入含</span>
  769. <span class="mod-chips" id="modInChips"></span>
  770. </div>
  771. <div class="mod-filter-row">
  772. <span class="mod-filter-lbl">输出含</span>
  773. <span class="mod-chips" id="modOutChips"></span>
  774. </div>
  775. </div>
  776. <div id="modList"></div>
  777. </section>
  778. <section class="fac4" id="fragCol">
  779. <div class="col-title">
  780. <span id="fragColTitle">④ Fragments</span
  781. ><span class="col-count" id="fragCnt"></span>
  782. </div>
  783. <div id="fragList"></div>
  784. </section>
  785. <section class="detail" id="detailCol">
  786. <div class="col-title"><span>⑤ 来源工序详情</span></div>
  787. <div id="detailBody">
  788. <div class="detail-empty">点击左侧 fragment 查看详情</div>
  789. </div>
  790. </section>
  791. </main>
  792. <script>
  793. let data = null;
  794. let SIDE_MODS = null;
  795. let shiDesc = null;
  796. let xingDesc = null;
  797. Promise.all([
  798. fetch('/fragment.json').then(r => r.json()),
  799. fetch('/case_pure.json').then(r => r.json()).catch(() => null)
  800. ]).then(([fragData, caseData]) => {
  801. data = fragData;
  802. const casesMap = {};
  803. if (caseData && caseData.cases) {
  804. caseData.cases.forEach(c => casesMap[c.index] = c);
  805. }
  806. data.fragments.forEach(f => {
  807. if (casesMap[f.case_index]) {
  808. f.case_title = casesMap[f.case_index].title;
  809. f.case_url = casesMap[f.case_index].url;
  810. f.case_cover = casesMap[f.case_index].cover;
  811. f.case_body = casesMap[f.case_index].body;
  812. f.case_images = casesMap[f.case_index].images;
  813. }
  814. });
  815. initApp();
  816. });
  817. function initApp() {
  818. // State of selections (cascading filters)
  819. const state = {
  820. action: null, // verb string
  821. scopeMode: "node", // 'node' or 'pattern' — which sub-filter is active
  822. shizhiPath: null, // path (node mode)
  823. xingshiPath: null, // path (node mode)
  824. itemsetIdx: null, // index into data.itemsets (pattern mode)
  825. modSig: null,
  826. modInFilter: new Set(),
  827. modOutFilter: new Set(),
  828. fragKey: null,
  829. collapsed: new Set(),
  830. };
  831. // Parse a modality signature into input/output sets
  832. function sigParts(sig) {
  833. const [inS, outS] = sig.split(" → ");
  834. const parse = (s) =>
  835. new Set(s.split("+").filter((x) => x && x !== "∅"));
  836. return { in: parse(inS), out: parse(outS) };
  837. }
  838. // All non-config modalities seen in any signature (for the chip palette)
  839. const SIDE_MODS = (() => {
  840. const inSet = new Set(),
  841. outSet = new Set();
  842. for (const m of data.modalities) {
  843. const p = sigParts(m.sig);
  844. for (const x of p.in) inSet.add(x);
  845. for (const x of p.out) outSet.add(x);
  846. }
  847. return { in: [...inSet].sort(), out: [...outSet].sort() };
  848. })();
  849. function $(id) {
  850. return document.getElementById(id);
  851. }
  852. function el(tag, attrs, ...kids) {
  853. const e = document.createElement(tag);
  854. if (attrs)
  855. for (const k in attrs) {
  856. if (k === "class") e.className = attrs[k];
  857. else if (k === "onClick") e.addEventListener("click", attrs[k]);
  858. else if (k.startsWith("data-")) e.setAttribute(k, attrs[k]);
  859. else if (k === "title") e.title = attrs[k];
  860. else e[k] = attrs[k];
  861. }
  862. for (const kid of kids) {
  863. if (kid == null || kid === false) continue;
  864. if (typeof kid === "string")
  865. e.appendChild(document.createTextNode(kid));
  866. else e.appendChild(kid);
  867. }
  868. return e;
  869. }
  870. const fragKey = (f) => f.case_index + ":" + f.fragment_id;
  871. // build path -> all descendant paths map for tree filtering
  872. function buildDescMap(roots) {
  873. const map = new Map();
  874. function walk(node) {
  875. const all = [node.path];
  876. for (const c of node.children || []) {
  877. const sub = walk(c);
  878. for (const p of sub) all.push(p);
  879. }
  880. map.set(node.path, all);
  881. return all;
  882. }
  883. for (const r of roots) walk(r);
  884. return map;
  885. }
  886. const shiDesc = buildDescMap(data.subtree.shizhi || []);
  887. const xingDesc = buildDescMap(data.subtree.xingshi || []);
  888. function fragMatchesPath(f, key, selPath, descMap) {
  889. if (!selPath) return true;
  890. const allowed = descMap.get(selPath) || [selPath];
  891. const allowedSet = new Set(allowed);
  892. const list = key === "shizhi" ? f.apply_shizhi : f.apply_xingshi;
  893. for (const e of list || []) {
  894. if (allowedSet.has(e.category_path)) return true;
  895. }
  896. return false;
  897. }
  898. // Pattern mode helpers
  899. function fragPathSet(f) {
  900. const s = new Set();
  901. for (const e of f.apply_shizhi || [])
  902. if (e.category_path) s.add(e.category_path);
  903. for (const e of f.apply_xingshi || [])
  904. if (e.category_path) s.add(e.category_path);
  905. return s;
  906. }
  907. const fragPaths = new Map();
  908. for (const f of data.fragments)
  909. fragPaths.set(f.case_index + ":" + f.fragment_id, fragPathSet(f));
  910. function fragMatchesItemset(f, itemset) {
  911. if (!itemset) return true;
  912. const ps = fragPaths.get(f.case_index + ":" + f.fragment_id);
  913. for (const p of itemset.items) if (!ps.has(p)) return false;
  914. return true;
  915. }
  916. // Active scope filter only counts when we're on the matching tab.
  917. function scopeFilterActive() {
  918. if (state.scopeMode === "node")
  919. return !!(state.shizhiPath || state.xingshiPath);
  920. if (state.scopeMode === "pattern") return state.itemsetIdx != null;
  921. return false;
  922. }
  923. // Compute filtered fragments given the current state, optionally excluding one filter dim
  924. function applyFilters(except) {
  925. return data.fragments.filter((f) => {
  926. if (except !== "action" && state.action && f.action !== state.action)
  927. return false;
  928. if (except !== "scope" && scopeFilterActive()) {
  929. if (state.scopeMode === "node") {
  930. if (
  931. state.shizhiPath &&
  932. !fragMatchesPath(f, "shizhi", state.shizhiPath, shiDesc)
  933. )
  934. return false;
  935. if (
  936. state.xingshiPath &&
  937. !fragMatchesPath(f, "xingshi", state.xingshiPath, xingDesc)
  938. )
  939. return false;
  940. } else if (state.scopeMode === "pattern") {
  941. const sel = data.itemsets[state.itemsetIdx];
  942. if (sel && !fragMatchesItemset(f, sel)) return false;
  943. }
  944. }
  945. if (
  946. except !== "mod" &&
  947. state.modSig &&
  948. f.modality_signature !== state.modSig
  949. )
  950. return false;
  951. return true;
  952. });
  953. }
  954. // === RENDERERS ===
  955. function renderActions() {
  956. const baseFiltered = applyFilters("action");
  957. const counts = {};
  958. for (const f of baseFiltered)
  959. counts[f.action] = (counts[f.action] || 0) + 1;
  960. const wrap = $("actList");
  961. wrap.innerHTML = "";
  962. for (const a of data.actions) {
  963. const c = counts[a.verb] || 0;
  964. const node = el("div", {
  965. class:
  966. "item" +
  967. (state.action === a.verb ? " active" : "") +
  968. (c === 0 && state.action !== a.verb ? " disabled" : ""),
  969. onClick: () => {
  970. if (c === 0 && state.action !== a.verb) return;
  971. state.action = state.action === a.verb ? null : a.verb;
  972. renderAll();
  973. },
  974. });
  975. const stack = el(
  976. "div",
  977. { class: "item-stack" },
  978. el("div", { class: "item-name" }, a.verb),
  979. el("div", { class: "item-def" }, a.definition),
  980. );
  981. node.appendChild(stack);
  982. node.appendChild(el("span", { class: "item-count" }, String(c)));
  983. wrap.appendChild(node);
  984. }
  985. $("actCnt").textContent = "共 " + data.actions.length + " 个";
  986. }
  987. function renderTreeFacet(roots, key, mountId, selPath, descMap) {
  988. const wrap = $(mountId);
  989. wrap.innerHTML = "";
  990. const baseFiltered = applyFilters("scope"); // exclude scope filters so this column shows what could be selected
  991. // Compute hits: each fragment puts its 实质/形式 leaf paths in hit set
  992. const hitCounts = new Map();
  993. for (const f of baseFiltered) {
  994. const list = key === "shizhi" ? f.apply_shizhi : f.apply_xingshi;
  995. const seen = new Set();
  996. for (const e of list || []) {
  997. // walk up the path adding to ancestor counts so subtree counts roll up
  998. const parts = (e.category_path || "").split("/").filter(Boolean);
  999. for (let i = 1; i <= parts.length; i++) {
  1000. const p = "/" + parts.slice(0, i).join("/");
  1001. if (seen.has(p)) continue;
  1002. seen.add(p);
  1003. }
  1004. }
  1005. for (const p of seen) hitCounts.set(p, (hitCounts.get(p) || 0) + 1);
  1006. }
  1007. function renderNode(node, parent) {
  1008. const c = hitCounts.get(node.path) || 0;
  1009. const collapsed = state.collapsed.has(node.path);
  1010. const hasChildren = (node.children || []).length > 0;
  1011. const tnode = el("div", {
  1012. class: "tnode" + (collapsed ? " tcollapsed" : ""),
  1013. });
  1014. const cls = ["tline"];
  1015. if (selPath === node.path) cls.push("active");
  1016. if (c === 0 && selPath !== node.path) cls.push("disabled");
  1017. if (node.is_suggested && !node.is_hit) cls.push("suggested");
  1018. if (node.is_inferred) cls.push("inferred");
  1019. const line = el("div", {
  1020. class: cls.join(" "),
  1021. title:
  1022. node.path + (node.description ? "\n\n" + node.description : ""),
  1023. });
  1024. const caret = el(
  1025. "span",
  1026. {
  1027. class: "tcaret" + (hasChildren ? "" : " invis"),
  1028. onClick: (ev) => {
  1029. ev.stopPropagation();
  1030. if (state.collapsed.has(node.path))
  1031. state.collapsed.delete(node.path);
  1032. else state.collapsed.add(node.path);
  1033. renderTrees();
  1034. },
  1035. },
  1036. hasChildren ? (collapsed ? "▶" : "▼") : "·",
  1037. );
  1038. line.appendChild(caret);
  1039. let label = node.name;
  1040. if (node.is_suggested && !node.is_hit) label += " ✦";
  1041. if (node.is_inferred) label += " (推断)";
  1042. line.appendChild(el("span", { class: "tname" }, label));
  1043. line.appendChild(el("span", { class: "tcount" }, String(c)));
  1044. line.addEventListener("click", () => {
  1045. if (c === 0 && selPath !== node.path) return;
  1046. const k = key === "shizhi" ? "shizhiPath" : "xingshiPath";
  1047. state[k] = state[k] === node.path ? null : node.path;
  1048. renderAll();
  1049. });
  1050. tnode.appendChild(line);
  1051. for (const ch of node.children || []) renderNode(ch, tnode);
  1052. parent.appendChild(tnode);
  1053. }
  1054. for (const r of roots) renderNode(r, wrap);
  1055. }
  1056. function renderTrees() {
  1057. renderTreeFacet(
  1058. data.subtree.shizhi || [],
  1059. "shizhi",
  1060. "shizhiTree",
  1061. state.shizhiPath,
  1062. shiDesc,
  1063. );
  1064. renderTreeFacet(
  1065. data.subtree.xingshi || [],
  1066. "xingshi",
  1067. "xingshiTree",
  1068. state.xingshiPath,
  1069. xingDesc,
  1070. );
  1071. }
  1072. function pathLeafAndParent(p) {
  1073. const parts = p.split("/").filter(Boolean);
  1074. if (!parts.length) return { leaf: p, parent: "" };
  1075. return {
  1076. leaf: parts[parts.length - 1],
  1077. parent: "/" + parts.slice(0, -1).join("/"),
  1078. };
  1079. }
  1080. function renderItemsets() {
  1081. const wrap = $("isList");
  1082. wrap.innerHTML = "";
  1083. $("isParams").textContent =
  1084. `${data.itemsets.length} closed · min_support=${data.itemsetsParams.min_support}, k≤${data.itemsetsParams.max_k}, ${data.itemsetsParams.include_ancestors ? "+ancestors" : "leaf-only"}`;
  1085. const baseFiltered = applyFilters("scope");
  1086. data.itemsets.forEach((iset, idx) => {
  1087. const supportNow = baseFiltered.filter((f) =>
  1088. fragMatchesItemset(f, iset),
  1089. ).length;
  1090. const isActive = state.itemsetIdx === idx;
  1091. const cls = ["iset"];
  1092. if (isActive) cls.push("active");
  1093. if (supportNow === 0 && !isActive) cls.push("disabled");
  1094. const node = el("div", {
  1095. class: cls.join(" "),
  1096. onClick: () => {
  1097. if (supportNow === 0 && !isActive) return;
  1098. state.itemsetIdx = isActive ? null : idx;
  1099. renderAll();
  1100. },
  1101. });
  1102. const head = el(
  1103. "div",
  1104. { class: "iset-head" },
  1105. el(
  1106. "span",
  1107. { class: "iset-sup", title: "当前筛选下的支持度" },
  1108. "×" + supportNow,
  1109. ),
  1110. el("span", { class: "iset-k" }, "k=" + iset.size),
  1111. el("span", { class: "iset-meta" }, "原始 sup " + iset.support),
  1112. );
  1113. node.appendChild(head);
  1114. const paths = el("div", { class: "iset-paths" });
  1115. for (const p of iset.items) {
  1116. const facet = data.pathToFacet[p] || "?";
  1117. const dot =
  1118. facet === "实质"
  1119. ? el("span", { class: "iset-fdot shi", title: "实质" }, "实")
  1120. : facet === "形式"
  1121. ? el("span", { class: "iset-fdot xing", title: "形式" }, "形")
  1122. : el(
  1123. "span",
  1124. { class: "iset-fdot both", title: "两侧都有" },
  1125. "双",
  1126. );
  1127. const lp = pathLeafAndParent(p);
  1128. const row = el(
  1129. "div",
  1130. { class: "iset-path", title: p },
  1131. dot,
  1132. el(
  1133. "div",
  1134. null,
  1135. el("span", { class: "iset-leaf" }, lp.leaf),
  1136. el("div", { class: "iset-parent" }, lp.parent),
  1137. ),
  1138. );
  1139. paths.appendChild(row);
  1140. }
  1141. node.appendChild(paths);
  1142. wrap.appendChild(node);
  1143. });
  1144. }
  1145. function renderScope() {
  1146. // tab visuals
  1147. $("tabNode").classList.toggle("active", state.scopeMode === "node");
  1148. $("tabPattern").classList.toggle(
  1149. "active",
  1150. state.scopeMode === "pattern",
  1151. );
  1152. $("paneNode").classList.toggle("active", state.scopeMode === "node");
  1153. $("panePattern").classList.toggle(
  1154. "active",
  1155. state.scopeMode === "pattern",
  1156. );
  1157. // status
  1158. if (state.scopeMode === "node") {
  1159. $("scopeStat").textContent = "路径树(双 facet)";
  1160. } else {
  1161. $("scopeStat").textContent = `${data.itemsets.length} 项集`;
  1162. }
  1163. $("scopeClear").classList.toggle("show", scopeFilterActive());
  1164. // body
  1165. if (state.scopeMode === "node") renderTrees();
  1166. else renderItemsets();
  1167. }
  1168. function sigPassesChipFilter(sig) {
  1169. const p = sigParts(sig);
  1170. for (const m of state.modInFilter) if (!p.in.has(m)) return false;
  1171. for (const m of state.modOutFilter) if (!p.out.has(m)) return false;
  1172. return true;
  1173. }
  1174. function renderModalityChips() {
  1175. const renderSide = (mountId, palette, selectedSet, side) => {
  1176. const wrap = $(mountId);
  1177. wrap.innerHTML = "";
  1178. // Counts: how many sigs would remain if THIS chip were toggled on (alongside the other already-selected chips on this side)
  1179. for (const m of palette) {
  1180. const trial = new Set(selectedSet);
  1181. if (!trial.has(m)) trial.add(m);
  1182. let c = 0;
  1183. for (const sig of data.modalities) {
  1184. const p = sigParts(sig.sig);
  1185. const inOK =
  1186. side === "in"
  1187. ? [...trial].every((x) => p.in.has(x)) &&
  1188. [...state.modOutFilter].every((x) => p.out.has(x))
  1189. : [...state.modInFilter].every((x) => p.in.has(x)) &&
  1190. [...trial].every((x) => p.out.has(x));
  1191. if (inOK) c++;
  1192. }
  1193. const isActive = selectedSet.has(m);
  1194. const chip = el(
  1195. "span",
  1196. {
  1197. class:
  1198. "mod-chip" +
  1199. (isActive ? " active" : "") +
  1200. (c === 0 && !isActive ? " disabled" : ""),
  1201. title: m + (c === 0 && !isActive ? " (无匹配)" : ""),
  1202. onClick: () => {
  1203. if (c === 0 && !isActive) return;
  1204. if (selectedSet.has(m)) selectedSet.delete(m);
  1205. else selectedSet.add(m);
  1206. // if the currently selected modSig no longer matches, drop it
  1207. if (state.modSig && !sigPassesChipFilter(state.modSig))
  1208. state.modSig = null;
  1209. renderAll();
  1210. },
  1211. },
  1212. m,
  1213. );
  1214. wrap.appendChild(chip);
  1215. }
  1216. };
  1217. renderSide("modInChips", SIDE_MODS.in, state.modInFilter, "in");
  1218. renderSide("modOutChips", SIDE_MODS.out, state.modOutFilter, "out");
  1219. }
  1220. function renderModalities() {
  1221. const baseFiltered = applyFilters("mod");
  1222. const counts = {};
  1223. for (const f of baseFiltered)
  1224. counts[f.modality_signature] =
  1225. (counts[f.modality_signature] || 0) + 1;
  1226. renderModalityChips();
  1227. const wrap = $("modList");
  1228. wrap.innerHTML = "";
  1229. const visible = data.modalities.filter((m) =>
  1230. sigPassesChipFilter(m.sig),
  1231. );
  1232. const sorted = [...visible].sort(
  1233. (a, b) => (counts[b.sig] || 0) - (counts[a.sig] || 0),
  1234. );
  1235. if (sorted.length === 0) {
  1236. wrap.appendChild(
  1237. el("div", { class: "empty-msg" }, "当前 chip 筛选下没有匹配签名"),
  1238. );
  1239. }
  1240. for (const m of sorted) {
  1241. const c = counts[m.sig] || 0;
  1242. const node = el(
  1243. "div",
  1244. {
  1245. class:
  1246. "item" +
  1247. (state.modSig === m.sig ? " active" : "") +
  1248. (c === 0 && state.modSig !== m.sig ? " disabled" : ""),
  1249. onClick: () => {
  1250. if (c === 0 && state.modSig !== m.sig) return;
  1251. state.modSig = state.modSig === m.sig ? null : m.sig;
  1252. renderAll();
  1253. },
  1254. },
  1255. el("span", { class: "item-name" }, m.sig),
  1256. el("span", { class: "item-count" }, String(c)),
  1257. );
  1258. wrap.appendChild(node);
  1259. }
  1260. $("modClear").classList.toggle(
  1261. "show",
  1262. !!state.modSig ||
  1263. state.modInFilter.size > 0 ||
  1264. state.modOutFilter.size > 0,
  1265. );
  1266. }
  1267. function renderFragments() {
  1268. const filtered = applyFilters(null);
  1269. const wrap = $("fragList");
  1270. wrap.innerHTML = "";
  1271. $("fragCnt").textContent =
  1272. filtered.length + " / " + data.fragments.length;
  1273. $("fragColTitle").textContent =
  1274. "④ Fragments · " +
  1275. (state.scopeMode === "pattern" ? "分子能力" : "原子能力");
  1276. if (filtered.length === 0) {
  1277. wrap.appendChild(
  1278. el("div", { class: "empty-msg" }, "当前筛选下没有命中的 fragment"),
  1279. );
  1280. return;
  1281. }
  1282. for (const f of filtered) {
  1283. const k = fragKey(f);
  1284. const head = el(
  1285. "div",
  1286. { class: "frag-head" },
  1287. el("span", { class: "case-badge" }, "案例" + f.case_index),
  1288. el("span", { class: "frag-badge" }, f.fragment_id),
  1289. el("span", { class: "act-badge" }, f.action),
  1290. );
  1291. const sig = el("div", { class: "frag-sig" }, f.modality_signature);
  1292. const body = el("div", { class: "frag-body" }, f.body || "");
  1293. const node = el(
  1294. "div",
  1295. {
  1296. class: "frag" + (state.fragKey === k ? " active" : ""),
  1297. onClick: () => {
  1298. state.fragKey = k;
  1299. renderFragments();
  1300. renderDetail();
  1301. },
  1302. },
  1303. head,
  1304. sig,
  1305. body,
  1306. );
  1307. wrap.appendChild(node);
  1308. }
  1309. }
  1310. function renderDetail() {
  1311. const wrap = $("detailBody");
  1312. wrap.innerHTML = "";
  1313. const f = data.fragments.find((x) => fragKey(x) === state.fragKey);
  1314. if (!f) {
  1315. wrap.appendChild(
  1316. el("div", { class: "detail-empty" }, "点击左侧 fragment 查看详情"),
  1317. );
  1318. return;
  1319. }
  1320. // Header
  1321. wrap.appendChild(
  1322. el(
  1323. "h2",
  1324. null,
  1325. el("span", { class: "case-badge" }, "案例 " + f.case_index),
  1326. el("span", { class: "frag-badge" }, f.fragment_id),
  1327. el("span", { class: "act-badge" }, f.action),
  1328. f.workflow_step_ref && f.workflow_step_ref.step_id
  1329. ? el(
  1330. "span",
  1331. { class: "pill" },
  1332. "step " + f.workflow_step_ref.step_id,
  1333. )
  1334. : null,
  1335. ),
  1336. );
  1337. if (f.case_title) {
  1338. const det = el("details", { style: "margin: 8px 0; padding-bottom: 8px; border-bottom: 1px solid var(--border);" });
  1339. const sum = el("summary", { class: "case-title", style: "cursor: pointer; margin: 0; outline: none; font-weight: bold; color: var(--accent); padding: 6px 8px; background: var(--panel2); border-radius: 4px; font-size: 11px;" }, "📄 源: " + f.case_title);
  1340. det.appendChild(sum);
  1341. const caseContent = el("div", { style: "padding: 10px; background: var(--code); border-radius: 5px; margin-top: 4px; border: 1px solid var(--border);" });
  1342. const imgsToRender = f.case_images && f.case_images.length ? f.case_images : (f.case_cover ? [f.case_cover] : []);
  1343. if (imgsToRender.length > 0) {
  1344. const imgContainer = el("div", { style: "display: flex; gap: 8px; overflow-x: auto; margin-bottom: 8px; padding-bottom: 4px;" });
  1345. for (const imgSrc of imgsToRender) {
  1346. const img = el("img", { src: imgSrc, style: "height: 160px; border-radius: 5px; object-fit: contain; background: var(--panel2); border: 1px solid var(--border);" });
  1347. imgContainer.appendChild(img);
  1348. }
  1349. caseContent.appendChild(imgContainer);
  1350. }
  1351. if (f.case_body) {
  1352. const body = el("div", { style: "font-size: 12px; line-height: 1.6; color: var(--fg); white-space: pre-wrap; margin-bottom: 10px; max-height: 250px; overflow-y: auto; padding-right: 4px;" }, f.case_body);
  1353. caseContent.appendChild(body);
  1354. }
  1355. if (f.case_url) {
  1356. const link = el("a", { href: f.case_url, target: "_blank", rel: "noopener", style: "font-size: 11px; color: var(--accent); display: inline-block; background: var(--panel2); padding: 4px 8px; border-radius: 4px; text-decoration: none;" }, "🔗 访问原始链接");
  1357. caseContent.appendChild(link);
  1358. }
  1359. det.appendChild(caseContent);
  1360. wrap.appendChild(det);
  1361. }
  1362. // I/O modalities
  1363. const ioSec = el(
  1364. "div",
  1365. { class: "detail-section" },
  1366. el("h3", null, "I/O 模态"),
  1367. );
  1368. ioSec.appendChild(
  1369. el(
  1370. "div",
  1371. { class: "frag-sig", style: "font-size:13px;margin-bottom:6px" },
  1372. f.modality_signature,
  1373. ),
  1374. );
  1375. const ioRow = (lbl, arr, kind) => {
  1376. const row = el(
  1377. "div",
  1378. { class: "io-row" },
  1379. el("span", { class: "lbl" }, lbl),
  1380. );
  1381. if (!arr || !arr.length) {
  1382. row.appendChild(
  1383. el("span", { style: "color:var(--muted)" }, "(无)"),
  1384. );
  1385. return row;
  1386. }
  1387. for (const x of arr) {
  1388. const isCfg = x.modality === "模型" || x.modality === "参数";
  1389. const txt =
  1390. (x.description || "") +
  1391. (x.modality ? "[" + x.modality + "]" : "") +
  1392. (x.relation ? " " + x.relation : "");
  1393. row.appendChild(
  1394. el("span", { class: "pill " + (isCfg ? "cfg" : kind) }, txt),
  1395. );
  1396. }
  1397. return row;
  1398. };
  1399. ioSec.appendChild(ioRow("IN", f.inputs, "in"));
  1400. ioSec.appendChild(ioRow("OUT", f.outputs, "out"));
  1401. wrap.appendChild(ioSec);
  1402. // Body
  1403. if (f.body) {
  1404. wrap.appendChild(
  1405. el(
  1406. "div",
  1407. { class: "detail-section" },
  1408. el("h3", null, "Body"),
  1409. el("div", { class: "body-text" }, f.body),
  1410. ),
  1411. );
  1412. }
  1413. // apply_to (实质 + 形式) — highlight rule depends on scope mode
  1414. let hotPaths = new Set();
  1415. if (state.scopeMode === "pattern" && state.itemsetIdx != null) {
  1416. const sel = data.itemsets[state.itemsetIdx];
  1417. if (sel) for (const p of sel.items) hotPaths.add(p);
  1418. }
  1419. const renderApply = (label, arr) => {
  1420. const sec = el(
  1421. "div",
  1422. { class: "detail-section" },
  1423. el("h3", null, "Apply to · " + label),
  1424. );
  1425. if (!arr || !arr.length) {
  1426. sec.appendChild(
  1427. el("div", { class: "empty-msg", style: "padding:8px" }, "无"),
  1428. );
  1429. return sec;
  1430. }
  1431. for (const e of arr) {
  1432. let isHighlighted = false;
  1433. if (state.scopeMode === "node") {
  1434. isHighlighted =
  1435. (label === "实质" &&
  1436. state.shizhiPath &&
  1437. (shiDesc.get(state.shizhiPath) || []).includes(
  1438. e.category_path,
  1439. )) ||
  1440. (label === "形式" &&
  1441. state.xingshiPath &&
  1442. (xingDesc.get(state.xingshiPath) || []).includes(
  1443. e.category_path,
  1444. ));
  1445. } else {
  1446. isHighlighted = hotPaths.has(e.category_path);
  1447. }
  1448. sec.appendChild(
  1449. el(
  1450. "div",
  1451. {
  1452. class: "pathline",
  1453. style: isHighlighted ? "color:#f1e05a" : "",
  1454. },
  1455. e.category_path,
  1456. ),
  1457. );
  1458. if (e.rationale)
  1459. sec.appendChild(
  1460. el("div", { class: "rationale" }, "— " + e.rationale),
  1461. );
  1462. }
  1463. return sec;
  1464. };
  1465. wrap.appendChild(renderApply("实质", f.apply_shizhi));
  1466. wrap.appendChild(renderApply("形式", f.apply_xingshi));
  1467. // suggest_apply_to
  1468. if (f.suggest_apply_to) {
  1469. const sec = el(
  1470. "div",
  1471. { class: "detail-section" },
  1472. el("h3", null, "Suggest Apply to ✦(建议新增节点)"),
  1473. el("div", { class: "pathline suggest" }, f.suggest_apply_to),
  1474. );
  1475. wrap.appendChild(sec);
  1476. }
  1477. // effects
  1478. if (f.effects && f.effects.length) {
  1479. const sec = el(
  1480. "div",
  1481. { class: "detail-section" },
  1482. el("h3", null, "Effects"),
  1483. );
  1484. f.effects.forEach((e, i) => {
  1485. const card = el("div", { class: "effect-card" });
  1486. card.appendChild(
  1487. el(
  1488. "div",
  1489. { class: "effect-stmt" },
  1490. "#" + i + " " + (e.statement || "-"),
  1491. ),
  1492. );
  1493. if (e.criteria)
  1494. card.appendChild(
  1495. el("div", { class: "effect-meta" }, "判定标准:" + e.criteria),
  1496. );
  1497. if (e.judge_method)
  1498. card.appendChild(
  1499. el(
  1500. "div",
  1501. { class: "effect-meta" },
  1502. "判定方式:" + e.judge_method,
  1503. ),
  1504. );
  1505. if (e.negative_examples && e.negative_examples.length) {
  1506. const ne = el("div", { class: "effect-meta" }, "反例:");
  1507. for (const n of e.negative_examples)
  1508. ne.appendChild(
  1509. el("div", { style: "margin-left:8px" }, "· " + n),
  1510. );
  1511. card.appendChild(ne);
  1512. }
  1513. sec.appendChild(card);
  1514. });
  1515. wrap.appendChild(sec);
  1516. }
  1517. // misc
  1518. const miscRows = [];
  1519. miscRows.push(["tools", (f.tools && f.tools.length) ? f.tools.join(", ") : "-"]);
  1520. miscRows.push(["artifact_type", f.artifact_type ? f.artifact_type : "-"]);
  1521. miscRows.push(["control_target", (f.control_target && f.control_target.length) ? f.control_target.join(", ") : "-"]);
  1522. miscRows.push(["alt_to", (f.is_alternative_to && f.is_alternative_to.length) ? f.is_alternative_to.join(", ") : "-"]);
  1523. if (miscRows.length) {
  1524. const sec = el(
  1525. "div",
  1526. { class: "detail-section" },
  1527. el("h3", null, "其他"),
  1528. );
  1529. for (const [k2, v2] of miscRows) {
  1530. const row = el(
  1531. "div",
  1532. { style: "font-size:11px;margin-bottom:3px" },
  1533. el("span", { style: "color:var(--muted);margin-right:8px" }, k2),
  1534. el("span", null, v2),
  1535. );
  1536. sec.appendChild(row);
  1537. }
  1538. wrap.appendChild(sec);
  1539. }
  1540. // raw fold-out
  1541. wrap.appendChild(
  1542. el(
  1543. "details",
  1544. null,
  1545. el("summary", null, "查看原始 fragment JSON"),
  1546. el("pre", { class: "json-raw" }, JSON.stringify(f, null, 2)),
  1547. ),
  1548. );
  1549. }
  1550. function renderChips() {
  1551. const c = $("chips");
  1552. c.innerHTML = "";
  1553. let any = false;
  1554. const mk = (lbl, val, onX) => {
  1555. any = true;
  1556. c.appendChild(
  1557. el(
  1558. "span",
  1559. { class: "filter-chip" },
  1560. el("span", { class: "lbl" }, lbl),
  1561. el("span", null, val),
  1562. el(
  1563. "span",
  1564. {
  1565. class: "x",
  1566. onClick: () => {
  1567. onX();
  1568. renderAll();
  1569. },
  1570. },
  1571. "×",
  1572. ),
  1573. ),
  1574. );
  1575. };
  1576. if (state.action)
  1577. mk("动作", state.action, () => {
  1578. state.action = null;
  1579. });
  1580. if (state.scopeMode === "node") {
  1581. if (state.shizhiPath)
  1582. mk(
  1583. "实质",
  1584. state.shizhiPath.split("/").pop() || state.shizhiPath,
  1585. () => {
  1586. state.shizhiPath = null;
  1587. },
  1588. );
  1589. if (state.xingshiPath)
  1590. mk(
  1591. "形式",
  1592. state.xingshiPath.split("/").pop() || state.xingshiPath,
  1593. () => {
  1594. state.xingshiPath = null;
  1595. },
  1596. );
  1597. } else if (state.scopeMode === "pattern" && state.itemsetIdx != null) {
  1598. const sel = data.itemsets[state.itemsetIdx];
  1599. const desc = sel.items.map((p) => p.split("/").pop()).join(" + ");
  1600. mk("项集 k=" + sel.size, desc, () => {
  1601. state.itemsetIdx = null;
  1602. });
  1603. }
  1604. if (state.modSig)
  1605. mk("模态", state.modSig, () => {
  1606. state.modSig = null;
  1607. });
  1608. $("clearAll").classList.toggle("active", any);
  1609. }
  1610. function renderStats() {
  1611. $("stats").textContent =
  1612. `${data.stats.fragments} fragments · ${data.actions.length} 动作 · ${data.modalities.length} 模态组合${data.stats.fragments_skipped ? ` · 已跳过 ${data.stats.fragments_skipped} 个空模态片段` : ""}`;
  1613. }
  1614. function renderAll() {
  1615. renderActions();
  1616. renderScope();
  1617. renderModalities();
  1618. renderFragments();
  1619. renderDetail();
  1620. renderChips();
  1621. }
  1622. $("clearAll").addEventListener("click", () => {
  1623. state.action = null;
  1624. state.shizhiPath = null;
  1625. state.xingshiPath = null;
  1626. state.itemsetIdx = null;
  1627. state.modSig = null;
  1628. state.modInFilter.clear();
  1629. state.modOutFilter.clear();
  1630. renderAll();
  1631. });
  1632. $("scopeClear").addEventListener("click", () => {
  1633. // clear only the current tab's selection
  1634. if (state.scopeMode === "node") {
  1635. state.shizhiPath = null;
  1636. state.xingshiPath = null;
  1637. } else {
  1638. state.itemsetIdx = null;
  1639. }
  1640. renderAll();
  1641. });
  1642. $("tabNode").addEventListener("click", () => {
  1643. state.scopeMode = "node";
  1644. renderAll();
  1645. });
  1646. $("tabPattern").addEventListener("click", () => {
  1647. state.scopeMode = "pattern";
  1648. renderAll();
  1649. });
  1650. $("modClear").addEventListener("click", () => {
  1651. state.modSig = null;
  1652. state.modInFilter.clear();
  1653. state.modOutFilter.clear();
  1654. renderAll();
  1655. });
  1656. renderStats();
  1657. renderAll();
  1658. }
  1659. document.getElementById('exitFs').addEventListener('click', () => {
  1660. window.parent.postMessage({ type: 'EXIT_FULLSCREEN' }, '*');
  1661. });
  1662. window.addEventListener('message', (e) => {
  1663. if (e.data && e.data.type === 'SET_FULLSCREEN') {
  1664. const btn = document.getElementById('exitFs');
  1665. const clearAll = document.getElementById('clearAll');
  1666. if (e.data.isFullscreen) {
  1667. btn.style.display = 'inline-block';
  1668. clearAll.style.marginLeft = '8px';
  1669. } else {
  1670. btn.style.display = 'none';
  1671. clearAll.style.marginLeft = 'auto';
  1672. }
  1673. }
  1674. });
  1675. </script>
  1676. </body>
  1677. </html>