book-index-ui 0.55.1 → 0.55.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -5
- package/dist/index.js +35 -35
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Bp=Object.create;var fs=Object.defineProperty;var Op=Object.getOwnPropertyDescriptor;var Wp=Object.getOwnPropertyNames;var Fp=Object.getPrototypeOf,Hp=Object.prototype.hasOwnProperty;var Dp=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Wp(n))!Hp.call(e,s)&&s!==i&&fs(e,s,{get:()=>n[s],enumerable:!(o=Op(n,s))||o.enumerable});return e};var oi=(e,n,i)=>(i=e!=null?Bp(Fp(e)):{},Dp(n||!e||!e.__esModule?fs(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ke=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),g=require("react"),Up=require("opencc-js/t2cn"),Qa=require("./variant-supplement.cjs"),Vp=require("react-markdown"),Gp=require("remark-gfm"),Yp=e=>`/item/${e}`,el=g.createContext(Yp);function qp({buildUrl:e,children:n}){const i=g.useMemo(()=>e,[e]);return t.jsx(el.Provider,{value:i,children:n})}function it(){return g.useContext(el)}const tl="",nl="";function Yr(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?nl:tl,a=o.indexOf(s);if(a===-1){n.push({text:o,marked:i});break}a>0&&n.push({text:o.slice(0,a),marked:i}),o=o.slice(a+1),i=!i}return n}function dt(e,n){return{title:e,tokens:n}}const xs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Kp=[dt("基础(VS Code 环境下跟随 --vscode-*)",{bg:{value:"#ffffff",vscode:"--vscode-editor-background"},fg:{value:"#333333",vscode:"--vscode-foreground"},"input-bg":{value:"#ffffff",vscode:"--vscode-input-background"},"input-fg":{value:"#333333",vscode:"--vscode-input-foreground"},"input-border":{value:"#cccccc",vscode:"--vscode-input-border"},"widget-border":{value:"#e0e0e0",vscode:"--vscode-widget-border"},"link-fg":{value:"#0066cc",vscode:"--vscode-textLink-foreground"},"desc-fg":{value:"#717171",vscode:"--vscode-descriptionForeground"},primary:{value:"#0078d4",vscode:"--vscode-button-background"},"primary-fg":{value:"#ffffff",vscode:"--vscode-button-foreground"},"primary-soft":{value:"rgba(0, 120, 212, 0.15)",css:"color-mix(in srgb, var(--bim-primary) 15%, transparent)"},danger:{value:"#f44336"},warning:{value:"#ff9800"},success:{value:"#4caf50"},"sidebar-bg":{value:"#f3f3f3",vscode:"--vscode-sideBar-background"},"list-hover-bg":{value:"rgba(0, 0, 0, 0.04)",vscode:"--vscode-list-hoverBackground"},"list-active-bg":{value:"rgba(0, 120, 212, 0.1)",vscode:"--vscode-list-activeSelectionBackground"},"focus-border":{value:"#0078d4",vscode:"--vscode-focusBorder"}}),dt("底色层次 / 文字与描边 / 链接",{"bg-subtle":{value:"#fafafa"},"widget-bg":{value:"#f8f8f8"},muted:{value:"#888888"},border:{value:"#e5e5e5"},"primary-bg":{value:"#fdf4f4"},link:{value:"#1976d2"},"tag-bg":{value:"#f0f0f0"},"accent-bg":{value:"#1976d2"},"on-color-fg":{value:"#ffffff",note:"彩色底(徽章、选中态按钮)上的文字"}}),dt("提示与警告",{"info-fg":{value:"#0c5380"},"info-bg":{value:"#e7f3ff"},"info-border":{value:"#b3dbff"},"warn-fg":{value:"#856404"},"warn-bg":{value:"#fff3cd"},"warn-border":{value:"#ffc107"},"danger-bg":{value:"rgba(244, 67, 54, 0.08)",note:"错误提示条底色"},"danger-soft-bg":{value:"rgba(244, 67, 54, 0.03)",note:"编辑器危险区块"},"danger-soft-border":{value:"rgba(244, 67, 54, 0.13)"}}),dt("遮罩与阴影",{backdrop:{value:"rgba(0, 0, 0, 0.5)",note:"对话框遮罩"},"overlay-bg":{value:"#00000010",note:"轻量遮罩底(图片占位等)"},"shadow-dialog":{value:"0 4px 20px rgba(0, 0, 0, 0.3)"},"shadow-dropdown":{value:"0 4px 12px rgba(0, 0, 0, 0.1)"},"shadow-tooltip":{value:"0 2px 8px rgba(0, 0, 0, 0.08)"},"shadow-fab":{value:"0 2px 8px rgba(0, 0, 0, 0.25)",note:"悬浮按钮(反馈)"},"shadow-card":{value:"0 1px 4px rgba(0, 0, 0, 0.06)",note:"展开的卡片"},"shadow-node":{value:"0 1px 3px rgba(0, 0, 0, 0.1)",note:"谱系图节点"},"shadow-node-selected":{value:"0 0 0 3px rgba(0, 120, 212, 0.2), 0 2px 8px rgba(0, 120, 212, 0.3)"}}),dt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),dt("资源",{"restype-text":{value:"#2196f3"},"restype-image":{value:"#ff9800"},"restype-text-image":{value:"#9c27b0"},"restype-physical":{value:"#795548"},"missing-fg":{value:"#e67e22",note:"资源缺册提示"},"colormode-bw-bg":{value:"#f5f5f5",note:"影印件色彩模式标记(黑白 / 彩色)"},"colormode-bw-fg":{value:"#757575"},"colormode-color-bg":{value:"#fff8e1"},"colormode-color-fg":{value:"#f57f17"},"progress-active":{value:"#f59e0b",note:"资源导入进度"},"progress-done":{value:"#10b981"},"progress-todo":{value:"#9ca3af"},"check-fine-bg":{value:"#e8f5e9",note:"文字资源校对程度徽章(精校 / 粗校 / AI整理)"},"check-fine-fg":{value:"#2e7d32"},"check-rough-bg":{value:"#fff3e0"},"check-rough-fg":{value:"#e65100"},"check-ai-bg":{value:"#e3f2fd"},"check-ai-fg":{value:"#1565c0"}}),dt("整理本(CollatedEdition)",{"highlight-bg":{value:"#fff59d",note:"搜索命中高亮底"},"highlight-fg":{value:"inherit",root:!1},"section-lei":{value:"#8e6f3e",note:"章节类型标记:类 / 书 / 序 / 结语 / 考证 / 注释"},"section-shu":{value:"#c0392b"},"section-xu":{value:"#1a5276"},"section-jieyu":{value:"#7d6608"},"section-kaozhen":{value:"#5d6d7e"},"section-zhushi":{value:"#6c5b7b"},"section-tag-fg":{value:"#e74c3c",note:"章节标记(△ 等)"},"matchstate-fg":{value:"#b78900",note:"与底本匹配状态提示"},"quality-source":{value:"#1b5e20",note:"文本质量等级(底本 / OCR / 粗校 / 精校 / 暂无正文 / 占位)"},"quality-ocr":{value:"#e65100"},"quality-rough":{value:"#1565c0"},"quality-fine":{value:"#2e7d32"},"quality-none":{value:"#5f6368",note:"中性灰:暂无正文"},"quality-placeholder":{value:"#757575",note:"中性灰:占位"}}),dt("版本传承(VersionLineageGraph / List) / 关系方向(RelationPanel)",{"lost-fg":{value:"#c62828",note:"佚失标记"},"confidence-certain":{value:"#2e7d32",note:"关系置信度"},"confidence-consensus":{value:"#1976d2"},"confidence-probable":{value:"#ed6c02"},"confidence-disputed":{value:"#c62828"},"lineage-edge-consensus":{value:"#555555",note:"⚠️ 同为 consensus,List 徽章用 --bim-confidence-consensus(蓝),Graph 连线用这个(灰)。若要统一,覆盖成 var(--bim-confidence-consensus)"},"relation-up":{value:"#2196f3"},"relation-down":{value:"#4caf50"},"relation-flat":{value:"#ff9800"}}),dt("编辑器视图(主要在 guji-platform 插件中可见)",{"editor-type-work":{value:"#4caf50",note:"⚠️ 与展示视图的 --bim-type-* 是两套配色(历史如此)。若要统一,覆盖成对应的 var(--bim-type-*)"},"editor-type-collection":{value:"#2196f3"},"editor-type-book":{value:"#ff9800"},"editor-type-entity":{value:"#9c27b0"},"source-url":{value:"#2196f3",note:"来源类型(SourceEditor)"},"source-bookid":{value:"#4caf50"},"mode-active-bg":{value:"#2196f3",note:"模式指示器当前态(ModeIndicator)"},"cover-accent":{value:"#8e6f3e",note:'书目卡片「封面」点缀(IndexBrowser resultVariant="card")'}}),dt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#3b4a58",note:"主题切换控件的色点:墨"},"sect-jing":{value:"#2e5266",note:"四部分布条:經部(人物页提要卡;无别处使用)"},"sect-shi":{value:"#9a7a3b",note:"四部分布条:史部"},"sect-zi":{value:"#4f7a5c",note:"四部分布条:子部"},"sect-ji":{value:"#9fb3bc",note:"四部分布条:集部"},"table-border":{value:"color-mix(in srgb, currentColor 28%, transparent)",root:!1,note:"古籍表格(跟随当前文字色)"},"table-head-bg":{value:"color-mix(in srgb, currentColor 8%, transparent)",root:!1}}),dt('版式(v4 外观系统,overview#291):疏朗=留白分区(默认,下列值即疏朗);界栏=框线分区(`<html data-layout="boxed">`)',{"fr-bd":{value:"0 solid transparent",note:"区块外框(border 简写)。疏朗无框;界栏 1px 实线"},"fr-bg":{value:"transparent",note:"区块底。界栏=卡面色"},"fr-hd-pad":{value:"14px 18px",note:"区块标题栏内边距。10-01 起疏朗也有淡染底的标题栏(--bim-fr-hd-bg),故疏朗 14px 18px,界栏 12px 18px"},"fr-hd-bd":{value:"0 solid transparent",note:"区块标题栏下沿线(border 简写)"},"fr-bd-pad":{value:"0",note:"区块正文内边距"},"fr-gap":{value:"56px",note:"区块之间的间距。界栏收紧到 24px(框线本身已分隔)"},"fr-side-gap":{value:"34px",note:"侧栏各块之间的间距;界栏 20px"},"fr-shadow":{value:"0 1px 0 var(--bim-rule), 0 12px 32px -18px rgba(40, 36, 31, 0.25)",note:"抬起的面(提要卡)的投影;界栏不用投影,靠框线"},"fr-tab-bd":{value:"transparent",note:"页签行下沿线颜色(疏朗不画,界栏画)"},"fr-hd-size":{value:"24px",note:"分区标题字号。界栏标题在框顶标题栏里,小一档 19px"},"fr-hd-bg":{value:"color-mix(in srgb, var(--bim-accent) 7%, var(--bim-page-bg))",note:"分区标题栏底色(淡染主色)。疏朗混进页面底,界栏 6% 混进卡面底。主色取 accent(primary 是 VS Code 按钮蓝,不随配色)"},"fr-card-bd":{value:"1px solid transparent",note:"卡片边框。疏朗不画(靠卡面底与淡投影);界栏 1px"},"fr-card-bg":{value:"var(--bim-card-bg)",note:"卡片底"},"fr-row-bd":{value:"1px solid transparent",note:"列表行线、块内小分割线。疏朗不画(靠行距);界栏 1px"},"fr-row-pad":{value:"10px 2px",note:"列表行内边距。界栏收紧 7px 2px"},"fr-chrome-bd":{value:"1px solid transparent",note:"顶栏、分区导航(吸顶锚点条)的线"},"fr-tag-bd":{value:"1px solid transparent",note:"标签、版本签、计数签、工具按钮的边框。疏朗浅底无框;界栏透明底加框"},"fr-tag-bg":{value:"var(--bim-tint-bg)",note:"标签底"},"fr-tbl-cell-bd":{value:"0 solid transparent",note:"表格格线。疏朗不画(靠斑马纹);界栏全格线"},"fr-tbl-zebra":{value:"var(--bim-tint-bg)",note:"表格斑马纹(只在疏朗下有)"},"fr-rail-bd":{value:"1px solid transparent",note:"侧栏里的块、提示块的边框"},"fr-rail-bg":{value:"var(--bim-tint-bg)",note:"侧栏块底。疏朗浅底;界栏卡面底"},"fr-spine-bd":{value:"1px solid transparent",note:"题签、书脊(竖排书名)的边框。界栏是强调色浅线"},"fr-spine-bg":{value:"var(--bim-flag-bg)",note:"题签、书脊底。疏朗浅色实底;界栏卡面底(正史原志两种版式都是强调色实底)"},"fr-plank":{value:"0 solid transparent",note:"书架架板(border 简写)。只在界栏下画 3px"},"fr-axis-bd":{value:"0 solid transparent",note:"时间轴轴线。界栏 1px"},"fr-axis-band":{value:"6px",note:"时间轴底带高度。疏朗用 6px 浅色带代替轴线;界栏 0"},"fr-tick":{value:"0",note:"时间轴刻度短线长度。界栏 5px"},"fr-band-gap":{value:"3px",note:"年代带各段之间的空隙。疏朗 3px;界栏紧贴"},"fr-band-bd":{value:"0 solid transparent",note:"年代带外框与段间分隔。界栏 1px"}}),dt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"reader-warm":{value:"#c9a24a",note:"阅读设置侧栏的暖黄:只做底色(8%)与选中态(24%),与朱/靛/墨三套主色都不冲"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),dt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),dt("字体(全站无衬线,2026-09-05 定)",{"font-ui":{value:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif'},"font-body":{value:"system-ui, sans-serif",css:"var(--bim-font-ui)"},"font-serif":{value:xs,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:xs,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Xp=Object.assign({},...Kp.map(e=>e.tokens)),il={};for(const[e,n]of Object.entries(Xp))il[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=il[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Bt(e){return e.types&&e.types.length>0?e.types:[]}function Zp(e,n){return Bt(e).includes(n)}const Jp={source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"};r("quality-source"),r("quality-ocr"),r("quality-rough"),r("quality-fine"),r("quality-none"),r("quality-placeholder");const Qp={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃","www.shidianguji.com":"識典古籍","shidianguji.com":"識典古籍","archive.org":"Internet Archive","www.shuge.org":"書格","shuge.org":"書格","pan.baidu.com":"百度網盤"};function bn(e){try{return Qp[new URL(e).hostname]}catch{return}}const bs={text:0,image:1,physical:2};function qr(e){return e.length===0?"physical":[...e].sort((n,i)=>(bs[n]??99)-(bs[i]??99)).join("+")}function eu(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function Kr(e){var l;const n=d=>{const c=d.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const p=d.match(/^(.+?)[·(](\d+)[)]?$/);return p?[p[1],parseInt(p[2])]:null},i=new Map;for(let d=0;d<e.length;d++){const c=e[d];if(c.volumes&&c.volumes.length>0)continue;const p=n(c.name);if(!p)continue;const[h,u]=p,m=`${h}|${qr(Bt(c))}`;i.has(m)||i.set(m,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const f=i.get(m);f.volumes.push({volume:u,url:c.url||void 0,status:"found"}),f.indices.push(d)}const o=[],s=new Set;for(const d of i.values())if(!(d.volumes.length<2)){d.volumes.sort((c,p)=>c.volume-p.volume),d.base.volumes=d.volumes,d.base.expected_volumes=d.volumes.length,d.base.url||(d.base.url=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function rl(e){if(e.url)return e.url;for(const[n,i]of Object.entries(e))if(n.endsWith("_url")&&typeof i=="string")return i}function ol(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||rl(n)}))}function Si(e){const n=ol(e);if(!n)return null;const i=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,o=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:i,missing:o,expected:e.expected_volumes??i+o}}function Xr(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const i=n.match(/^(\d+)/);return i?parseInt(i[1],10):void 0}function Zr(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const o=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(o)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(o[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function yn(e){if(!e.url)return;const n=Xr(e.metadata);return n?Zr(e.url,n):e.url}const Nt=g.createContext(null),sl=["曹霑"];function tu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nu(e,n=sl){const i=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!i.length)return e;const o=new RegExp(`(${i.map(tu).join("|")})`,"g"),s=new Set(i);return a=>{if(!a)return e(a);const l=a.split(o);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let _n=null;function al(){if(_n)return _n;try{const e=Up.Converter({from:"t",to:"cn"});_n=nu(n=>e(ke.normalizeVariants(n)))}catch{_n=e=>e}return _n}const iu={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("check-ai-fg")}},action:{save:"保存",delete:"刪除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"訪問 →",view:"查看 →",viewEntity:"查看",copy:"複製 ID",copied:"已複製",linkExisting:"+ 關聯現有",createAndLink:"+ 創建並關聯",remove:"刪除",clearAll:"清除全部",reselect:"重選",changeType:"更換類型",expand:"展開",collapse:"收起",expandMore:"展開更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加書籍",addSubCollection:"添加子叢編",addCollectionImpl:"添加叢編實現",addSource:"添加來源",addResource:"添加資源",addIndexedBy:"+ 添加收錄來源",addEmendatedBy:"+ 添加考證來源",addAdditionalWork:"+ 添加附屬作品",selectBookOrWork:"選擇書籍/作品",clickToSelectBookOrWork:"點擊選擇書籍/作品",unlink:"解除關聯"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷數",pageCount:"頁數 (Pages)",volumeCount:"冊數 (Volumes)",holder:"現藏於 (Holder)",firstImage:"首頁圖片 (First Image URL)",year:"年代",currentLocation:"現藏",parentWork:"上級作品",relatedWorks:"相關作品",type:"類型",rootType:"根類型",coverageLevel:"覆蓋層級",coverageRange:"覆蓋範圍",metadata:"元數據",optionalInfo:"可選信息",details:"詳細說明",detailsOptional:"詳細說明 (可選)",positionOptional:"位置/頁碼 (可選)",dataVersionOptional:"數據版本 (可選)",processorVersionOptional:"處理器版本 (可選)",sourceName:"來源名稱",sourceBid:"來源 BID",titleInfo:"題名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介紹 (Description)",additionalWorks:"📑 附屬作品 (Additional Works)",indexedBy:"📖 著錄於",emendatedBy:"📝 考證",resources:"資源",textResources:"📝 文字資源 (Text Resources)",imageResources:"🖼️ 圖片資源 (Image Resources)",sources:"📚 資料來源 (Sources)",provenance:"📜 收藏歷史 (Provenance)",relatedVersions:"相關版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危險區域 (Danger Zone)",aliases:"別名",attachedTexts:"附載篇目",appendix:"附錄",containedIn:"收入叢編",collectedIn:"收入叢編",belongsToWork:"所屬作品",locationHistory:"流轉歷史",historyOverview:"歷史沿革",containedBooks:"收錄書籍",relations:"關聯關係",summary:"提要",comment:"按語",additionalComment:"附按",indexed:"收錄於",emendated:"考證",relatedWorks:"相關作品",containedWorks:"包含作品",adaptations:"改編作品",derivativeWorks:"續書與評註",studies:"所考典籍"},relation:{belongsToWork:"所屬作品 (Work)",containedInCollection:"收入叢編",siblingVersions:"同作品其他版本",addVersionForWork:"為此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"叢編實現",allVersions:"所有版本",correspondingWork:"對應作品 (Work)",parentCollection:"父叢編 (Parent Collection)",childCollections:"子叢編",containedBooks:"包含書籍",notLinked:"(未關聯)",none:"(暫無)"},search:{placeholder:"搜索作品、書籍、叢編...",searching:"搜索中...",loading:"加載中...",noResults:"無匹配結果",noResultsFor:"未找到與「{query}」相關的結果",tryOther:"試試其他關鍵詞、別名或作者名",recentBrowse:"最近瀏覽",history:"搜索歷史",clearAll:"清除全部",clearRecent:"清除最近瀏覽",itemNotFound:"無法找到,可能已刪除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"結果分類",searchSubtitle:"輸入關鍵詞搜索作品、書籍或叢編",searchBookName:"搜索書名...",alias:"別名"},searchV4:{filterTitle:"篩選",dynasty:"朝代",classification:"部類",resources:"資源",extant:"存佚",clearAllFilters:"清除全部篩選",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"篩選",filterSelected:"{n} 項已選",expand:"展開",collapse:"收起",filteredCount:"篩出 {n} 條",removeFilter:"取消篩選:{name}",viewLabel:"結果視圖",viewTable:"表格",viewCard:"卡片",colTitle:"題名",colType:"類型",colAuthor:"責任者",colEra:"年代",colClass:"部類",colResource:"資源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 條 · 每頁 {size} 條 · 第 {page} / {pages} 頁",pagerLabel:"翻頁",prevPage:"上一頁",nextPage:"下一頁",emptyFiltered:"沒有找到匹配的條目。試試更短的書名、減少篩選,或切換繁 / 簡。",limitedNote:"各類只列前幾條,點上方分類頁籤看全部。",sortLabel:"排序",sortRelevance:"相關度",sortEra:"年代",sortTitle:"書名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A"},home:{title:"古籍索引",subtitle:"從左側搜索框輸入關鍵詞,查找作品、書籍或叢編",recommendedBrowse:"推薦瀏覽",catalogTab:"目錄",collectionTab:"叢編",siteTab:"在線資源",recommendTab:"推薦",feedbackTab:"反饋",statusInProgress:"進行中",statusDone:"已完成",statusTodo:"未開始",typeCatalog:"目錄",typeCollection:"資源集合",totalPending:"待統計",progressFormat:"{imported} / {total}",siteCoverage:"資源覆蓋"},browser:{title:"古籍資源索引",subtitle:""},detailTab:{basicInfo:"概覽",catalog:"目錄",collectionCatalog:"叢編目錄",collatedEdition:"文本",catalogSuffix:"·目錄",fullText:"文本",lineage:"版本傳承",feedback:"勘誤反饋",dataSource:"數據源",backToIndex:"典籍版本索引",submitVersion:"提交新版本",dataLicense:"數據源與授權"},metadata:{edition:"版本",version:"修訂版本",quality:"資源質量",check_type:"校對",image_source:"影像來源",team:"所屬團隊",publisher:"出版社",year:"出版年份",format:"格式",note:"備註",total_page:"頁數",total_pages:"總頁數",page_range:"頁碼範圍",page_count:"頁數",file_page_range:"文件頁碼",file_page_count:"文件頁數",content_page_range:"影印頁碼",volume:"冊",color_mode:"色彩",paragraph_count:"段落數",has_translation:"翻譯"},editor:{untitled:"未命名",workTitle:"作品名 (Work Title)",collectionTitle:"叢書名 (Collection Title)",bookTitle:"書名 (Book Title)",belongsToWork:"所屬作品 (Work)",authorLabel:"作者 (Author)",publicationYearLabel:"出版年 (Publication year)",containedIn:"收入叢編",holderLabel:"現藏於 (Holder)",pageLabel:"頁數 (Pages)",volumeLabel:"冊數 (Volumes)",firstImageLabel:"首頁圖片 (First Image URL)",descriptionPlaceholder:"簡要介紹...",provenancePlaceholder:"該資源的流轉與收藏記錄...",otherEditionsPlaceholder:"相關版本的 ID...",dangerZoneDesc:"從索引庫中永久刪除該實體的所有元數據文件。",deleteEntity:"刪除該實體 (Delete Entity)",selectToLink:"選擇要關聯的",unnamedSource:"(未命名來源)",selectSourceType:"選擇來源類型",fromExistingBook:"從現有書籍選擇",enterUrl:"輸入網址鏈接",sourceNamePlaceholder:"如: 維基文庫、中國基本古籍庫",deleteThisSource:"刪除此來源",deleteThisResource:"刪除此資源",resourcePlaceholder:"資源",idAutoExtract:"ID (自動從URL提取)",resourceName:"資源名稱",resourceUrl:"資源鏈接 (URL)",structurePlaceholder:"層級結構 (如: 冊、卷)",coverageRangePlaceholder:"如: 2,3,5-8",detailsPlaceholder:"詳細說明",summaryPlaceholder:"提要...",commentPlaceholder:"按語...",additionalCommentPlaceholder:"附按...",imageResourceLink:"圖片資源鏈接",bookNameLabel:"書名",sourcePlaceholder:"來源"},download:{completed:"下載完成",downloading:"下載中",downloadThis:"下載此資源"},mode:{localMode:"本地模式",syncMode:"同步模式:",githubSync:"GitHub 同步",switchToSync:"點擊切換到同步模式",switchToLocal:"點擊切換到本地模式",switchToGithub:"點擊切換到 GitHub 同步模式",switchToDraft:"點擊切換到 draft 倉庫",switchToOfficial:"點擊切換到 official 倉庫",selectFolder:"選擇本地文件夾",configurePath:"配置同步路徑"},catalog:{totalVolumes:"共",processed:"已處理",contains:"收錄",matched:"已匹配",unmatched:"待匹配",source:"來源:",all:"全部",loading:"加載叢編目錄...",notFound:"未找到叢編目錄數據",loadFailed:"加載失敗",noMatch:"無匹配結果",unmatched_label:"未匹配",volume:"第 {n} 冊"},unit:{juan:"卷",volume:"冊",bu:"部",items:"條"},workSubtype:{book:"書",article:"篇",poem:"詩",chapter:"篇章"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暫無資源信息",hasTranslation:"有",noTranslation:"無",structure:"層級",coverage:"覆蓋",notFoundEntry:"未找到該條目",loadFailed:"加載失敗",textResource:"文字資源",imageResource:"圖片資源"}},ru={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("check-ai-fg")}},action:{save:"保存",delete:"删除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"访问 →",view:"查看 →",viewEntity:"查看",copy:"复制 ID",copied:"已复制",linkExisting:"+ 关联现有",createAndLink:"+ 创建并关联",remove:"删除",clearAll:"清除全部",reselect:"重选",changeType:"更换类型",expand:"展开",collapse:"收起",expandMore:"展开更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加书籍",addSubCollection:"添加子丛编",addCollectionImpl:"添加丛编实现",addSource:"添加来源",addResource:"添加资源",addIndexedBy:"+ 添加收录来源",addEmendatedBy:"+ 添加考证来源",addAdditionalWork:"+ 添加附属作品",selectBookOrWork:"选择书籍/作品",clickToSelectBookOrWork:"点击选择书籍/作品",unlink:"解除关联"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷数",pageCount:"页数 (Pages)",volumeCount:"册数 (Volumes)",holder:"现藏于 (Holder)",firstImage:"首页图片 (First Image URL)",year:"年代",currentLocation:"现藏",parentWork:"上级作品",relatedWorks:"相关作品",type:"类型",rootType:"根类型",coverageLevel:"覆盖层级",coverageRange:"覆盖范围",metadata:"元数据",optionalInfo:"可选信息",details:"详细说明",detailsOptional:"详细说明 (可选)",positionOptional:"位置/页码 (可选)",dataVersionOptional:"数据版本 (可选)",processorVersionOptional:"处理器版本 (可选)",sourceName:"来源名称",sourceBid:"来源 BID",titleInfo:"题名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介绍 (Description)",additionalWorks:"📑 附属作品 (Additional Works)",indexedBy:"📖 著录于",emendatedBy:"📝 考证",resources:"资源",textResources:"📝 文字资源 (Text Resources)",imageResources:"🖼️ 图片资源 (Image Resources)",sources:"📚 资料来源 (Sources)",provenance:"📜 收藏历史 (Provenance)",relatedVersions:"相关版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危险区域 (Danger Zone)",aliases:"别名",attachedTexts:"附载篇目",appendix:"附录",containedIn:"收入丛编",collectedIn:"收入丛编",belongsToWork:"所属作品",locationHistory:"流转历史",historyOverview:"历史沿革",containedBooks:"收录书籍",relations:"关联关系",summary:"提要",comment:"按语",additionalComment:"附按",indexed:"收录于",emendated:"考证",relatedWorks:"相关作品",containedWorks:"包含作品",adaptations:"改编作品",derivativeWorks:"续书与评注",studies:"所考典籍"},relation:{belongsToWork:"所属作品 (Work)",containedInCollection:"收入丛编",siblingVersions:"同作品其他版本",addVersionForWork:"为此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"丛编实现",allVersions:"所有版本",correspondingWork:"对应作品 (Work)",parentCollection:"父丛编 (Parent Collection)",childCollections:"子丛编",containedBooks:"包含书籍",notLinked:"(未关联)",none:"(暂无)"},search:{placeholder:"搜索作品、书籍、丛编...",searching:"搜索中...",loading:"加载中...",noResults:"无匹配结果",noResultsFor:"未找到与「{query}」相关的结果",tryOther:"试试其他关键词、别名或作者名",recentBrowse:"最近浏览",history:"搜索历史",clearAll:"清除全部",clearRecent:"清除最近浏览",itemNotFound:"无法找到,可能已删除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"结果分类",searchSubtitle:"输入关键词搜索作品、书籍或丛编",searchBookName:"搜索书名...",alias:"别名"},searchV4:{filterTitle:"筛选",dynasty:"朝代",classification:"部类",resources:"资源",extant:"存佚",clearAllFilters:"清除全部筛选",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"筛选",filterSelected:"{n} 项已选",expand:"展开",collapse:"收起",filteredCount:"筛出 {n} 条",removeFilter:"取消筛选:{name}",viewLabel:"结果视图",viewTable:"表格",viewCard:"卡片",colTitle:"题名",colType:"类型",colAuthor:"责任者",colEra:"年代",colClass:"部类",colResource:"资源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 条 · 每页 {size} 条 · 第 {page} / {pages} 页",pagerLabel:"翻页",prevPage:"上一页",nextPage:"下一页",emptyFiltered:"没有找到匹配的条目。试试更短的书名、减少筛选,或切换繁 / 简。",limitedNote:"各类只列前几条,点上方分类页签看全部。",sortLabel:"排序",sortRelevance:"相关度",sortEra:"年代",sortTitle:"书名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A"},home:{title:"古籍索引",subtitle:"从左侧搜索框输入关键词,查找作品、书籍或丛编",recommendedBrowse:"推荐浏览",catalogTab:"目录",collectionTab:"丛编",siteTab:"在线资源",recommendTab:"推荐",feedbackTab:"反馈",statusInProgress:"进行中",statusDone:"已完成",statusTodo:"未开始",typeCatalog:"目录",typeCollection:"资源集合",totalPending:"待统计",progressFormat:"{imported} / {total}",siteCoverage:"资源覆盖"},browser:{title:"古籍资源索引",subtitle:""},detailTab:{basicInfo:"概览",catalog:"目录",collectionCatalog:"丛编目录",collatedEdition:"文本",catalogSuffix:"·目录",fullText:"文本",lineage:"版本传承",feedback:"勘误反馈",dataSource:"数据源",backToIndex:"典籍版本索引",submitVersion:"提交新版本",dataLicense:"数据源与授权"},metadata:{edition:"版本",version:"修订版本",quality:"资源质量",check_type:"校对",image_source:"影像来源",team:"所属团队",publisher:"出版社",year:"出版年份",format:"格式",note:"备注",total_page:"页数",total_pages:"总页数",page_range:"页码范围",page_count:"页数",file_page_range:"文件页码",file_page_count:"文件页数",content_page_range:"影印页码",volume:"册",color_mode:"色彩",paragraph_count:"段落数",has_translation:"翻译"},editor:{untitled:"未命名",workTitle:"作品名 (Work Title)",collectionTitle:"丛书名 (Collection Title)",bookTitle:"书名 (Book Title)",belongsToWork:"所属作品 (Work)",authorLabel:"作者 (Author)",publicationYearLabel:"出版年 (Publication year)",containedIn:"收入丛编",holderLabel:"现藏于 (Holder)",pageLabel:"页数 (Pages)",volumeLabel:"册数 (Volumes)",firstImageLabel:"首页图片 (First Image URL)",descriptionPlaceholder:"简要介绍...",provenancePlaceholder:"该资源的流转与收藏记录...",otherEditionsPlaceholder:"相关版本的 ID...",dangerZoneDesc:"从索引库中永久删除该实体的所有元数据文件。",deleteEntity:"删除该实体 (Delete Entity)",selectToLink:"选择要关联的",unnamedSource:"(未命名来源)",selectSourceType:"选择来源类型",fromExistingBook:"从现有书籍选择",enterUrl:"输入网址链接",sourceNamePlaceholder:"如: 维基文库、中国基本古籍库",deleteThisSource:"删除此来源",deleteThisResource:"删除此资源",resourcePlaceholder:"资源",idAutoExtract:"ID (自动从URL提取)",resourceName:"资源名称",resourceUrl:"资源链接 (URL)",structurePlaceholder:"层级结构 (如: 册、卷)",coverageRangePlaceholder:"如: 2,3,5-8",detailsPlaceholder:"详细说明",summaryPlaceholder:"提要...",commentPlaceholder:"按语...",additionalCommentPlaceholder:"附按...",imageResourceLink:"图片资源链接",bookNameLabel:"书名",sourcePlaceholder:"来源"},download:{completed:"下载完成",downloading:"下载中",downloadThis:"下载此资源"},mode:{localMode:"本地模式",syncMode:"同步模式:",githubSync:"GitHub 同步",switchToSync:"点击切换到同步模式",switchToLocal:"点击切换到本地模式",switchToGithub:"点击切换到 GitHub 同步模式",switchToDraft:"点击切换到 draft 仓库",switchToOfficial:"点击切换到 official 仓库",selectFolder:"选择本地文件夹",configurePath:"配置同步路径"},catalog:{totalVolumes:"共",processed:"已处理",contains:"收录",matched:"已匹配",unmatched:"待匹配",source:"来源:",all:"全部",loading:"加载丛编目录...",notFound:"未找到丛编目录数据",loadFailed:"加载失败",noMatch:"无匹配结果",unmatched_label:"未匹配",volume:"第 {n} 册"},unit:{juan:"卷",volume:"册",bu:"部",items:"条"},workSubtype:{book:"书",article:"篇",poem:"诗",chapter:"篇章"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暂无资源信息",hasTranslation:"有",noTranslation:"无",structure:"层级",coverage:"覆盖",notFoundEntry:"未找到该条目",loadFailed:"加载失败",textResource:"文字资源",imageResource:"图片资源"}};function ut(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const ou=ut({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),_i=ut({relation:{part_of:"所屬",has_part:"包含",contains_text_of:"收錄",collected_in:"叢編",text_carried_by:"載錄",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"後繼",derived_from:"衍生",has_adaptation:"改編",related:"相關"},lossStatus:{extant:"今存",fragment:"殘存",partial:"殘存",lost:"已佚",unknown:"未詳"},resourceKind:{text:"文本",image:"影印",textImage:"圖文",physical:"館藏"},otherImages:"其他影印",fragmentTag:"殘片",collapseVolumes:"收起分冊",expandVolumes:"展開 {n} 冊",mirror:"鏡像",volumeStats:"{found} / {expected} 冊",volumeStatsMissing:"{found} / {expected} 冊 缺 {missing}",pageNav:"本頁導航",thisPage:"本頁",more:"更多",expandRest:"展開其餘 {n} {unit}",read:"閱讀",showMore:"顯示更多({n})",review:{reviewed:"已審核",disputed:"有爭議",unreviewed:"未審核",draft:"草稿"},dataVersion:"數據版本",todoCount:"待核 {n} 項",lacuna:"闕文",lacunaWith:"闕文:{label}",composedChar:"組字:{label}",bce:"前{n}",roleAll:"全部",loading:"加載中…",noLineageGraph:"暫無版本圖數據",notFound:"找不到該條目,可能已被刪除或 ID 不正確",workInfo:"作品信息"},{relation:{part_of:"所属",has_part:"包含",contains_text_of:"收录",collected_in:"丛编",text_carried_by:"载录",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"后继",derived_from:"衍生",has_adaptation:"改编",related:"相关"},lossStatus:{extant:"今存",fragment:"残存",partial:"残存",lost:"已佚",unknown:"未详"},resourceKind:{text:"文本",image:"影印",textImage:"图文",physical:"馆藏"},otherImages:"其他影印",fragmentTag:"残片",collapseVolumes:"收起分册",expandVolumes:"展开 {n} 册",mirror:"镜像",volumeStats:"{found} / {expected} 册",volumeStatsMissing:"{found} / {expected} 册 缺 {missing}",pageNav:"本页导航",thisPage:"本页",more:"更多",expandRest:"展开其余 {n} {unit}",read:"阅读",showMore:"显示更多({n})",review:{reviewed:"已审核",disputed:"有争议",unreviewed:"未审核",draft:"草稿"},dataVersion:"数据版本",todoCount:"待核 {n} 项",lacuna:"阙文",lacunaWith:"阙文:{label}",composedChar:"组字:{label}",bce:"前{n}",roleAll:"全部",loading:"加载中…",noLineageGraph:"暂无版本图数据",notFound:"找不到该条目,可能已被删除或 ID 不正确",workInfo:"作品信息"}),su=ut({kind:"版本",fact:{editionType:"版本類型",publication:"刊印",era:"刊寫年代",measure:"卷帙",volumes:"冊次",baseEdition:"底本",holdings:"存藏",callNumber:"索書號",seals:"藏印",leafStyle:"行款",binding:"裝幀",dimensions:"尺寸",condition:"品相",aliases:"又名"},inferredFromEdition:"據版本題名推斷",volumesValue:"第 {range} {unit}({n} {unit})",andMorePlaces:" 等 {n} 處",viewImages:"看原書影印",sec:{fulltext:"文本",images:"影印",physical:"館藏",lineage:"版本源流",empty:"影印與文本"},chapterUnit:"章",chapterCount:"{n} {unit}",sourceBy:"據{src}",readFrom:"從{ch}讀起",firstChapter:"第一章",enterReader:"進入閱讀頁",externalText:"站外文本",groupCount:"{n} 組",placeCount:"{n} 處",lineageMeta:"據版本傳承著錄",lineageView:"源流視圖",viewCards:"卡片",viewGraph:"關係圖",totalOf:"全 {n} {unit}",emptyText:"尚未著錄該版本的影印、文本與收藏信息。",editionCount:"{n} 種版本",siblings:"同作品版本",byEra:"按年代",kindCount:"{n} 種",viewAllInWork:"在作品頁看全部 {n} 種 →",volumeRange:"第 {range} {unit}",volumeCount:"{n} {unit}",confidence:{certain:"確證",consensus:"通說",probable:"可能",disputed:"有爭議"},confidenceNote:"({c})",lineage:{ancestor:"祖本",reconstructed:"擬構祖本",thisEdition:"本版",derivatives:"翻刻 · 衍生",appendix:"附記"}},{kind:"版本",fact:{editionType:"版本类型",publication:"刊印",era:"刊写年代",measure:"卷帙",volumes:"册次",baseEdition:"底本",holdings:"存藏",callNumber:"索书号",seals:"藏印",leafStyle:"行款",binding:"装帧",dimensions:"尺寸",condition:"品相",aliases:"又名"},inferredFromEdition:"据版本题名推断",volumesValue:"第 {range} {unit}({n} {unit})",andMorePlaces:" 等 {n} 处",viewImages:"看原书影印",sec:{fulltext:"文本",images:"影印",physical:"馆藏",lineage:"版本源流",empty:"影印与文本"},chapterUnit:"章",chapterCount:"{n} {unit}",sourceBy:"据{src}",readFrom:"从{ch}读起",firstChapter:"第一章",enterReader:"进入阅读页",externalText:"站外文本",groupCount:"{n} 组",placeCount:"{n} 处",lineageMeta:"据版本传承著录",lineageView:"源流视图",viewCards:"卡片",viewGraph:"关系图",totalOf:"全 {n} {unit}",emptyText:"尚未著录该版本的影印、文本与收藏信息。",editionCount:"{n} 种版本",siblings:"同作品版本",byEra:"按年代",kindCount:"{n} 种",viewAllInWork:"在作品页看全部 {n} 种 →",volumeRange:"第 {range} {unit}",volumeCount:"{n} {unit}",confidence:{certain:"确证",consensus:"通说",probable:"可能",disputed:"有争议"},confidenceNote:"({c})",lineage:{ancestor:"祖本",reconstructed:"拟构祖本",thisEdition:"本版",derivatives:"翻刻 · 衍生",appendix:"附记"}}),au=ut({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),lu=ut({kind:"叢編",workCollection:"作品集",stat:{titles:"子目"},fact:{publication:"刊印",expected:"應收",measure:"卷帙"},member:{Book:"所收版本",Work:"所收作品",other:"成員"},memberNote:"子目與其各版本合計",nZhong:"{n} 種",nHan:"{n} 函",dist:{head:"全帙冊次分佈",segTitle:"{section} 第 {from}–{to} 冊",only:"只看{section}",unclassified:"未分類",hint:"點色段篩選部類"},sec:{titles:"子目",resources:"影印與文本"},totalVolumes:"全帙 {n} {unit}",currentN:"當前 {n} {unit}",loadAllTitle:"將載入全部 {n} {unit}",grouping:"正在按部類分組…",groupBySection:"按部類分組",find:"在本叢編中檢索",col:{volumes:"冊次",title:"書名",versions:"版本"},volumeRange:"第 {range} {unit}",resourcesCount:"{n} 處",text:"文本",empty:"尚未著錄該叢編的子目。",parent:"上級叢編"},{kind:"丛编",workCollection:"作品集",stat:{titles:"子目"},fact:{publication:"刊印",expected:"应收",measure:"卷帙"},member:{Book:"所收版本",Work:"所收作品",other:"成员"},memberNote:"子目与其各版本合计",nZhong:"{n} 种",nHan:"{n} 函",dist:{head:"全帙册次分布",segTitle:"{section} 第 {from}–{to} 册",only:"只看{section}",unclassified:"未分类",hint:"点色段筛选部类"},sec:{titles:"子目",resources:"影印与文本"},totalVolumes:"全帙 {n} {unit}",currentN:"当前 {n} {unit}",loadAllTitle:"将载入全部 {n} {unit}",grouping:"正在按部类分组…",groupBySection:"按部类分组",find:"在本丛编中检索",col:{volumes:"册次",title:"书名",versions:"版本"},volumeRange:"第 {range} {unit}",resourcesCount:"{n} 处",text:"文本",empty:"尚未著录该丛编的子目。",parent:"上级丛编"}),cu=ut({subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对"}),du=ut({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",properNameOff:"不顯示",properNameLite:"精簡",properNameFull:"完整",properNameLiteTitle:"只標人名、地名、朝代",showWorks:"標註書名",bookTitleStyle:"書名樣式",bookTitleWavy:"波浪線",bookTitleBracket:"書名號",scriptOrig:"原字",scriptOrigUnavailable:"此文本沒有規範層,無「原字」可選",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁體",scriptHans:"簡體",quoteStyle:"引號",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原樣",pageBreaks:"顯示分葉分割線",pageIndicator:"頁指示頭(上下鍵調整位置)",preserveMargins:"書影保留空白",facsimilePager:"書影翻頁",facsimilePageInput:"書影葉碼(輸入數字後按 Enter 或離開輸入框跳轉)",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",properNameOff:"不显示",properNameLite:"精简",properNameFull:"完整",properNameLiteTitle:"只标人名、地名、朝代",showWorks:"标注书名",bookTitleStyle:"书名样式",bookTitleWavy:"波浪线",bookTitleBracket:"书名号",scriptOrig:"原字",scriptOrigUnavailable:"此文本没有规范层,无「原字」可选",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁体",scriptHans:"简体",quoteStyle:"引号",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原样",pageBreaks:"显示分叶分割线",pageIndicator:"页指示头(上下键调整位置)",preserveMargins:"书影保留空白",facsimilePager:"书影翻页",facsimilePageInput:"书影叶码(输入数字后按 Enter 或离开输入框跳转)",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),pu=ut({nJuan:"{n}卷",viewWork:"查看作品",viewWorkOf:"查看作品:{title}",workArrow:"作品 →",arrowWork:"→作品",nWorks:"{n}部作品",unlinked:"未關聯",summary:"提要",comment:"按語",additionalComment:"附按",noMatch:"無匹配結果",sectionType:{类:"類",书:"書",序:"序",结语:"結語",注释:"註釋",考证:"考證",诗:"詩",小计:"小計"},countTiao:"{n} 條",countTiaoOf:"{m} / {n} 條",countPoems:"{n} 首",countPoemsOf:"{m} / {n} 首",countBooks:"{n} 部書",countBooksOf:"{m} / {n} 部書",kaozhenTarget:"考證對象 {target}",baseText:"底本 {note}",textQuality:"文本質量",qualityLabel:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"},qualityCriteria:{source:"照錄來源原文,本站未另行校對",ocr:"保持大意和結構,錯誤率在百分之十以內",rough:"保證文意基本正確,錯誤率在百分之三以內",fine:"通讀無障礙,錯誤率在百分之一以內",none:"質量未評定",placeholder:"占位條目,正文尚未錄入"},originalSource:"原文來源",viewsGroup:"看法",viewText:"正文",viewEntries:"條目",rowHeadNo:"序",rowHeadTitle:"書名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部書",linkedN:"已關聯 {n}",linkedOf:"已關聯 {n} / {total}",railEntriesNav:"本卷條目"},{nJuan:"{n}卷",viewWork:"查看作品",viewWorkOf:"查看作品:{title}",workArrow:"作品 →",arrowWork:"→作品",nWorks:"{n}部作品",unlinked:"未关联",summary:"提要",comment:"按语",additionalComment:"附按",noMatch:"无匹配结果",sectionType:{类:"类",书:"书",序:"序",结语:"结语",注释:"注释",考证:"考证",诗:"诗",小计:"小计"},countTiao:"{n} 条",countTiaoOf:"{m} / {n} 条",countPoems:"{n} 首",countPoemsOf:"{m} / {n} 首",countBooks:"{n} 部书",countBooksOf:"{m} / {n} 部书",kaozhenTarget:"考证对象 {target}",baseText:"底本 {note}",textQuality:"文本质量",qualityLabel:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暂无正文",placeholder:"占位"},qualityCriteria:{source:"照录来源原文,本站未另行校对",ocr:"保持大意和结构,错误率在百分之十以内",rough:"保证文意基本正确,错误率在百分之三以内",fine:"通读无障碍,错误率在百分之一以内",none:"质量未评定",placeholder:"占位条目,正文尚未录入"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),uu=ut({typeShort:{work:"作",book:"版",collection:"叢",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"叢編",entity:"人物"},typeAll:"全部",typeChipsLabel:"按類型檢索",recentTitle:"最近瀏覽",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"還沒有瀏覽記錄。打開任一條目後會出現在這裏。",status:{done:"已完成",in_progress:"進行中",todo:"計劃中"},siteStatus:{done:"已對接",in_progress:"進行中"},catalogTitle:"書目著錄進度",catalogNote:"每條著錄對到作品條目",colCatalog:"書目",colRecords:"著錄條目",colMatched:"已對上作品",colProgress:"進度",colStatus:"狀態",relatedTitle:"同類書目與考證",relatedNote:"不在書架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 種",allNKinds:"全部 {n} 種",pavilion:"閣",yearBC:"前{n}",missingLife:"生卒年未錄、未上軸:{names}",viewLineage:"看版本譜系 →",plannedSites:"計劃接入:{names}",loss:{extant:"存",partially_extant:"殘",lost:"佚",unknown:"未詳"},lossNote:{extant:"今有傳本",partially_extant:"部分存世",lost:"僅見著錄",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"叢編",entities:"人物",has_image:"有影印",has_text:"有文本",article:"單篇文",poem:"單篇詩"},dataScale:"數據規模",byLoss:"按存佚檢索",license:"古籍元數據以 CC0 公有領域發布,可自由複製、改編、再發布。",repo:"數據倉庫:",repoNote:"(GitHub,CC0)",version:"當前數據版本:",download:"引用方式與數據下載 →",navLabel:"元數據首頁分區",nav:{zhi:"歷代史志",sibu:"四部",cong:"叢編",people:"人物",lineage:"版本譜系",sites:"在線資源",data:"數據與授權"},zhiSub:"正史藝文志、經籍志與後人補志,按所志朝代排列;每部志的著錄逐條對到作品",shelfLegendCount:"脊下數字=著錄條目",shelfLegendClick:"點書脊進作品頁",sibuSub:"全部作品按經史子集分類;與「目錄」頁同一棵分類樹",toCatalog:"進入目錄 →",unclassifiedNote:"多為只見於史志著錄、尚未歸類的書",congSub:"大型叢書、影印彙編、出土文獻與館藏,逐種列到版本",allNKindsMore:"全部 {n} 種 →",peopleSub:"歷代目錄學家,按生卒年排在一條時間軸上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流與異同",sitesSub:"外部數字圖書館與本站條目的對接",dataSub:"規模、存佚、許可與版本"},{typeShort:{work:"作",book:"版",collection:"丛",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"丛编",entity:"人物"},typeAll:"全部",typeChipsLabel:"按类型检索",recentTitle:"最近浏览",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"还没有浏览记录。打开任一条目后会出现在这里。",status:{done:"已完成",in_progress:"进行中",todo:"计划中"},siteStatus:{done:"已对接",in_progress:"进行中"},catalogTitle:"书目著录进度",catalogNote:"每条著录对到作品条目",colCatalog:"书目",colRecords:"著录条目",colMatched:"已对上作品",colProgress:"进度",colStatus:"状态",relatedTitle:"同类书目与考证",relatedNote:"不在书架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 种",allNKinds:"全部 {n} 种",pavilion:"阁",yearBC:"前{n}",missingLife:"生卒年未录、未上轴:{names}",viewLineage:"看版本谱系 →",plannedSites:"计划接入:{names}",loss:{extant:"存",partially_extant:"残",lost:"佚",unknown:"未详"},lossNote:{extant:"今有传本",partially_extant:"部分存世",lost:"仅见著录",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"丛编",entities:"人物",has_image:"有影印",has_text:"有文本",article:"单篇文",poem:"单篇诗"},dataScale:"数据规模",byLoss:"按存佚检索",license:"古籍元数据以 CC0 公有领域发布,可自由复制、改编、再发布。",repo:"数据仓库:",repoNote:"(GitHub,CC0)",version:"当前数据版本:",download:"引用方式与数据下载 →",navLabel:"元数据首页分区",nav:{zhi:"历代史志",sibu:"四部",cong:"丛编",people:"人物",lineage:"版本谱系",sites:"在线资源",data:"数据与授权"},zhiSub:"正史艺文志、经籍志与后人补志,按所志朝代排列;每部志的著录逐条对到作品",shelfLegendCount:"脊下数字=著录条目",shelfLegendClick:"点书脊进作品页",sibuSub:"全部作品按经史子集分类;与「目录」页同一棵分类树",toCatalog:"进入目录 →",unclassifiedNote:"多为只见于史志著录、尚未归类的书",congSub:"大型丛书、影印汇编、出土文献与馆藏,逐种列到版本",allNKindsMore:"全部 {n} 种 →",peopleSub:"历代目录学家,按生卒年排在一条时间轴上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流与异同",sitesSub:"外部数字图书馆与本站条目的对接",dataSub:"规模、存佚、许可与版本"}),Jr=ut({readable:"部可讀",pieces:"篇單篇詩文",startReading:"開始閱讀 →",nCopies:"{n}本",shelfHint:"按所志朝代排列,一脊一部",shelfLegendCount:"脊下「2本」=站內有幾個本子",shelfOther:"其他",shelfRegion:"{label}書架,可橫向滾動",origZhi:"正史原志",laterZhi:"後人補撰、續補",spineBy:"{name} 撰",spineRecords:"著錄 {n} 條",spineOnSite:"站內 {n}",nWorks:"{n} 部",allNWorks:"全部 {n} 部",nCopiesCard:"{n} 個本子",workPageLink:"作品頁:{title}的源流與全部版本 →",sibuUnclassifiedNote:"書目分類還沒補齊,其中多數是單篇詩文,已單列在下方。",subClasses:"{label}子類",allNClasses:"{label}全部 {n} 類 →",unclassified:"未分類",viewUnclassified:"查看未分類 →",periodItem:"{label},{n} 部",periodUnknown:"另有 {n} 部作者無朝代,在「四部」和搜索裏能找到",hoverHint:"窄段懸停看全名",nPieces:"{n} 篇",authorAll:"{name}全部 {n} 篇 →",period:{xianqin:"先秦",qinhan:"秦漢",weijin:"魏晉南北朝",suitang:"隋唐五代",song:"宋",liaojinyuan:"遼金元",ming:"明",qing:"清",modern:"近現代"},navLabel:"閱讀首頁分區",nav:{picks:"推薦閱讀",topics:"專題",famous:"名著與版本",sibu:"四部",period:"按年代",pieces:"單篇詩文"},picksSub:"編輯挑選,定期輪換",topicsSub:"按作品類型歸組;小說見下方「名著與版本」",famousSub:"一部作品一張卡,卡上列出站內能讀的各個本子",sibuSub:"按古籍總目的分類樹,只計站內可讀的作品",periodSub:"按作者朝代歸段,寬度與部數成比例",piecesSub:"單篇的詩、文、賦、表,按作者歸組",piecesMore:"按作者瀏覽全部 →"},{readable:"部可读",pieces:"篇单篇诗文",startReading:"开始阅读 →",nCopies:"{n}本",shelfHint:"按所志朝代排列,一脊一部",shelfLegendCount:"脊下「2本」=站内有几个本子",shelfOther:"其他",shelfRegion:"{label}书架,可横向滚动",origZhi:"正史原志",laterZhi:"后人补撰、续补",spineBy:"{name} 撰",spineRecords:"著录 {n} 条",spineOnSite:"站内 {n}",nWorks:"{n} 部",allNWorks:"全部 {n} 部",nCopiesCard:"{n} 个本子",workPageLink:"作品页:{title}的源流与全部版本 →",sibuUnclassifiedNote:"书目分类还没补齐,其中多数是单篇诗文,已单列在下方。",subClasses:"{label}子类",allNClasses:"{label}全部 {n} 类 →",unclassified:"未分类",viewUnclassified:"查看未分类 →",periodItem:"{label},{n} 部",periodUnknown:"另有 {n} 部作者无朝代,在「四部」和搜索里能找到",hoverHint:"窄段悬停看全名",nPieces:"{n} 篇",authorAll:"{name}全部 {n} 篇 →",period:{xianqin:"先秦",qinhan:"秦汉",weijin:"魏晋南北朝",suitang:"隋唐五代",song:"宋",liaojinyuan:"辽金元",ming:"明",qing:"清",modern:"近现代"},navLabel:"阅读首页分区",nav:{picks:"推荐阅读",topics:"专题",famous:"名著与版本",sibu:"四部",period:"按年代",pieces:"单篇诗文"},picksSub:"编辑挑选,定期轮换",topicsSub:"按作品类型归组;小说见下方「名著与版本」",famousSub:"一部作品一张卡,卡上列出站内能读的各个本子",sibuSub:"按古籍总目的分类树,只计站内可读的作品",periodSub:"按作者朝代归段,宽度与部数成比例",piecesSub:"单篇的诗、文、赋、表,按作者归组",piecesMore:"按作者浏览全部 →"}),mu=ut({sideNav:"分類導航",classification:"分類",drawerLabel:"分類:{path}",all:"全部",allTitle:"全部典籍",stat:"共 {total} 種 · 每頁 {size} 條",statPage:" · 第 {page} / {pages} 頁",viewLabel:"呈現方式",viewCard:"卡片",viewList:"列表",juanN:"{n}卷",pagerLabel:"分頁",prevPage:"上一頁",nextPage:"下一頁",pageN:"第 {n} 頁",emptyWorks:"此類暫無作品",zhulu:"著錄",cunmu:"存目",categoriesN:"{n} 類",divisionStat:"{cats} 類 · {books} 部",categoryJuan:"卷{n}",booksN:"{n} 部",expandAllN:"展開全部 {n} 條"},{sideNav:"分类导航",classification:"分类",drawerLabel:"分类:{path}",all:"全部",allTitle:"全部典籍",stat:"共 {total} 种 · 每页 {size} 条",statPage:" · 第 {page} / {pages} 页",viewLabel:"呈现方式",viewCard:"卡片",viewList:"列表",juanN:"{n}卷",pagerLabel:"分页",prevPage:"上一页",nextPage:"下一页",pageN:"第 {n} 页",emptyWorks:"此类暂无作品",zhulu:"著录",cunmu:"存目",categoriesN:"{n} 类",divisionStat:"{cats} 类 · {books} 部",categoryJuan:"卷{n}",booksN:"{n} 部",expandAllN:"展开全部 {n} 条"}),hu=ut({loss:{all:"全部",extant:"存",partially_extant:"殘",lost:"佚"},unclassified:"未分類",statBook:"書",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"詩詞",statPoemUnit:"首",statCollection:"叢編",submit:"搜索"},{loss:{all:"全部",extant:"存",partially_extant:"残",lost:"佚"},unclassified:"未分类",statBook:"书",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"诗词",statPoemUnit:"首",statCollection:"丛编",submit:"搜索"}),gu=ut({title:"反饋",close:"關閉",submitType:{bug:"反饋錯誤",resource:"添加資源",suggestion:"功能建議",contact:"想參與"},placeholder:{bug:"請描述您發現的錯誤,包括頁面位置和具體內容",resource:"請提供完整資源鏈接和簡要版本說明",suggestion:"您希望網站增加或改進什麼?",contact:"想參與整理、校對或合作?簡單介紹一下您自己,並留下聯繫方式(此類留言不公開)"},chooseTypeFirst:"請先選擇反饋類型",contactPlaceholder:"郵箱(選填,僅站方可見,方便我們回覆您)",contactLabel:"聯繫方式(選填)",submitFailedRetry:"提交失敗,請稍後重試",submitFailed:"提交失敗",thanks:"感謝您的反饋!",viewList:"查看反饋列表 →",continueSubmit:"繼續提交",submitting:"提交中...",submit:"提交",submitFeedback:"提交反饋",listType:{bug:"錯誤反饋",resource:"資源建議",suggestion:"功能建議",other:"其他"},status:{pending:"待處理",in_progress:"處理中",resolved:"已處理",wontfix:"不採納",duplicate:"重複"},empty:"暫無反饋",reply:"回覆"},{title:"反馈",close:"关闭",submitType:{bug:"反馈错误",resource:"添加资源",suggestion:"功能建议",contact:"想参与"},placeholder:{bug:"请描述您发现的错误,包括页面位置和具体内容",resource:"请提供完整资源链接和简要版本说明",suggestion:"您希望网站增加或改进什么?",contact:"想参与整理、校对或合作?简单介绍一下您自己,并留下联系方式(此类留言不公开)"},chooseTypeFirst:"请先选择反馈类型",contactPlaceholder:"邮箱(选填,仅站方可见,方便我们回复您)",contactLabel:"联系方式(选填)",submitFailedRetry:"提交失败,请稍后重试",submitFailed:"提交失败",thanks:"感谢您的反馈!",viewList:"查看反馈列表 →",continueSubmit:"继续提交",submitting:"提交中...",submit:"提交",submitFeedback:"提交反馈",listType:{bug:"错误反馈",resource:"资源建议",suggestion:"功能建议",other:"其他"},status:{pending:"待处理",in_progress:"处理中",resolved:"已处理",wontfix:"不采纳",duplicate:"重复"},empty:"暂无反馈",reply:"回复"}),fu=ut({empty:"暫無版本傳承數據",emptyGraph:"暫無版本圖數據",modeList:"列表",modeGraph:"關係圖",collectionLabel:"集合:",collectionAll:"全部",collectionAllDesc:"顯示該作品所有版本(含橋接節點)",graphLoading:"加載圖組件中…",graphMissing:"圖組件未安裝。請安裝 {xyflow} 與 {dagre}。",graphMissingHint:"或使用 {list} 列表視圖。",bridgeTitle:"橋接節點:本身不在核心集,為保持派生鏈完整而顯示",otherGroup:"其他",lost:"已佚",fragment:"殘本",hypothetical:"假想祖本",bridge:"橋接",extant:"現存:{juan}",sources:"來源:",related:"關聯:",confidence:{certain:"確定",consensus:"共識",probable:"推測",disputed:"有爭議"}},{empty:"暂无版本传承数据",emptyGraph:"暂无版本图数据",modeList:"列表",modeGraph:"关系图",collectionLabel:"集合:",collectionAll:"全部",collectionAllDesc:"显示该作品所有版本(含桥接节点)",graphLoading:"加载图组件中…",graphMissing:"图组件未安装。请安装 {xyflow} 与 {dagre}。",graphMissingHint:"或使用 {list} 列表视图。",bridgeTitle:"桥接节点:本身不在核心集,为保持派生链完整而显示",otherGroup:"其他",lost:"已佚",fragment:"残本",hypothetical:"假想祖本",bridge:"桥接",extant:"现存:{juan}",sources:"来源:",related:"关联:",confidence:{certain:"确定",consensus:"共识",probable:"推测",disputed:"有争议"}}),xu={common:ou,detail:_i,bookPage:su,workPage:au,collectionPage:lu,entityPage:cu,reader:du,collated:pu,metaHome:uu,readHome:Jr,catalogPage:mu,searchPage:hu,feedback:gu,lineage:fu};function bu(e){const n={};for(const[i,o]of Object.entries(xu))n[i]=o[e];return n}function xt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const ys=new Map;function jn(e){let n=ys.get(e);return n||(n={...e==="zh-Hans"?ru:iu,...bu(e)},ys.set(e,n)),n}function js(e,n){let i=e;for(const o of n.split(".")){if(i==null||typeof i!="object")return;i=i[o]}return typeof i=="string"?i:void 0}function ll(e){return(n,i)=>{const o=js(e,n)??js(jn("zh-Hant"),n)??n;return i?xt(o,i):o}}const vs=new Map;function vn(e){let n=vs.get(e);return n||(n=ll(jn(e)),vs.set(e,n)),n}const cl="bim-locale";function yu(){try{const e=localStorage.getItem(cl);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function ju(e){try{localStorage.setItem(cl,e)}catch{}}const vu="zh-Hans",ku=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=g.useState(e??vu),l=e??s;g.useEffect(()=>{if(e)return;const h=yu();h&&h!==s&&a(h)},[]);const d=g.useMemo(()=>l==="zh-Hans"?i??al():null,[l,i]),c=g.useCallback(h=>{a(h),ju(h),n==null||n(h)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:jn(l),converter:d}),[l,c,d]);return t.jsx(Nt.Provider,{value:p,children:o})};function Ee(){const e=g.useContext(Nt);return(e==null?void 0:e.messages)??jn("zh-Hant")}const wu=2e3;function Oe(){const e=g.useContext(Nt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=g.useRef(new Map),s=g.useRef(n),a=g.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=g.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=wu){const h=o.current.keys().next().value;h!==void 0&&o.current.delete(h)}return o.current.set(d,p),p},[i]);return g.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function ne(){const e=g.useContext(Nt),{convert:n,locale:i,isSimplified:o}=Oe(),s=(e==null?void 0:e.messages)??jn("zh-Hant"),a=g.useMemo(()=>e?ll(s):vn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const dl=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Su=new Set([...dl,...Object.keys(ke.VARIANT_CHARS),...Object.keys(Qa.VARIANT_SUPPLEMENT)]),pl=[...sl,"切換為繁體","漢籍リポジトリ"];function _u(e,n=pl){let i=e;for(const a of n)a&&(i=i.split(a).join(" "));const o=[],s=Array.from(i);return s.forEach((a,l)=>{Su.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function $u(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??al():e==="hant"?ke.normalizeVariants:i:n==="zh-Hans"?i:ke.normalizeVariants}const Cu=({mode:e,children:n})=>{const i=g.useContext(Nt),o=g.useMemo(()=>i&&{...i,converter:$u(e,i.locale,i.converter)},[i,e]);return t.jsx(Nt.Provider,{value:o,children:n})};function Tu(e){if(!e)return"";try{const n=new URL(e).hostname,i={"zh.wikisource.org":"wikisource","www.shidianguji.com":"shidianguji","shidianguji.com":"shidianguji","archive.org":"archive","ctext.org":"ctext","read.nlc.cn":"nlc","www.digital.archives.go.jp":"japan_archives"};if(i[n])return i[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function ks(e){return e==="text+image"?["text","image"]:[e]}function ws(e){const n=Bt(e);return n.length===0?"text":eu(n)}function zu(){return{id:"",name:"",url:"",types:["text"],details:""}}const kr=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Ee(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],h=w=>{if(!s)return!0;const j=Bt(w);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},u=e.map((w,j)=>({item:w,originalIndex:j})).filter(({item:w})=>h(w)),m=()=>{const w=zu();s&&(w.types=ks(s)),n([...e,w]),d(e.length)},f=w=>{n(e.filter((j,k)=>k!==w)),d(null)},x=(w,j,k)=>{const C=[...e];if(C[w]={...C[w],[j]:k},j==="url"&&!C[w].id){const S=Tu(k);S&&(C[w].id=S)}n(C)},v=(w,j)=>{const k=[...e],{type:C,...S}=k[w];k[w]={...S,types:ks(j)},n(k)},y=(w,j,k)=>{const S={...e[w].metadata||{}};k?S[j]=k:delete S[j],x(w,"metadata",Object.keys(S).length>0?S:void 0)},$=(w,j)=>{const k=j.trim()?j.split(/[,,、]/).map(C=>C.trim()).filter(Boolean):void 0;x(w,"structure",k)},b=(w,j,k)=>{const S=e[w].coverage||{level:1,ranges:""};j==="level"?S.level=parseInt(k)||1:S.ranges=k,x(w,"coverage",S.ranges?S:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[u.map(({item:w,originalIndex:j})=>{var k,C,S;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===j?null:j),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===j?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Nu(ws(w)),color:r("on-color-fg")},children:(()=>{var L,z;const _=Bt(w);return _.length===0?"text":_.length===1?((L=c.find(T=>T.value===_[0]))==null?void 0:L.label)??_[0]:_.includes("text")&&_.includes("image")?((z=c.find(T=>T.value==="text+image"))==null?void 0:z.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:w.name||`${a.editor.resourcePlaceholder} ${j+1}`}),w.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:w.id}),w.url&&t.jsx("a",{href:w.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&w.url&&Iu(j,o==null?void 0:o[j],i,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(j)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===j&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[Zp(w,"image")&&w.url&&Eu(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.type}),t.jsx("select",{value:ws(w),onChange:_=>v(j,_.target.value),style:{...$t,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{...$t,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:w.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...$t,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{...$t,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:$t}),t.jsx("input",{type:"text",value:((k=w.structure)==null?void 0:k.join("、"))||"",onChange:_=>$(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:$t}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((C=w.coverage)==null?void 0:C.level)??"",onChange:_=>b(j,"level",_.target.value),placeholder:"1",style:{...$t,width:"60px"}})]}),t.jsxs("label",{style:{...$n,flex:1},children:[t.jsx("span",{style:Cn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((S=w.coverage)==null?void 0:S.ranges)||"",onChange:_=>b(j,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...$t,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...$t,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${r("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"6px"},children:a.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(a.metadata).map(([_,L])=>{var z;return t.jsxs("label",{style:{...$n,gap:"4px"},children:[t.jsx("span",{style:{...Cn,minWidth:"56px"},children:L}),t.jsx("input",{type:"text",value:((z=w.metadata)==null?void 0:z[_])||"",onChange:T=>y(j,_,T.target.value),placeholder:L,style:{...$t,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function Nu(e){switch(e){case"text":return r("restype-text");case"image":return r("restype-image");case"text+image":return r("restype-text-image");case"physical":return r("restype-physical")}}function Iu(e,n,i,o){const s=(n==null?void 0:n.status)==="downloading",a=(n==null?void 0:n.status)==="completed";return t.jsx("button",{onClick:l=>{l.stopPropagation(),s||i(e,"")},disabled:s,style:{background:"transparent",border:"none",color:r(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?o.download.completed:s?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function Eu(e,n){const i=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.url)||e.url.includes("iiif")||e.url.includes("image");return t.jsx("div",{style:{marginBottom:"12px"},children:i?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:r("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:r("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:r("desc-fg")},children:n.editor.imageResourceLink})})}const $t={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},$n={display:"flex",alignItems:"center",gap:"6px"},Cn={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},Ss={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function Ru(e){return e.includes("text")&&e.includes("image")?Ss["text+image"]:Ss[e[0]||"physical"]}const Qr=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ee(),{convert:l}=Oe(),d=g.useMemo(()=>Kr(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,$=[];for(const b of d){const w=b.group;w?(y.has(w)||y.set(w,[]),y.get(w).push(b)):$.push(b)}for(const b of y.values())b.sort((w,j)=>{const k=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return k(w)-k(j)});return{mirrorGroups:y,ungroupedItems:$}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},u=y=>h[y]?h[y]:y.split("+").map($=>h[$]||$).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,$)=>t.jsx(ir,{item:y},y.id||$))});const m=(y,$)=>{const b=i==null?void 0:i[y],w=(b==null?void 0:b.label)||y,j=b==null?void 0:b.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(w)}),j&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.5},children:l(j)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((k,C)=>t.jsx(ir,{item:k,onNavigate:o,renderLink:s},k.id||C))})]},`group-${y}`)},f=new Map;for(const y of p){const $=qr(Bt(y));f.has($)||f.set($,[]),f.get($).push(y)}const x=["text","image","text+image","physical"],v=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,$])=>m(y,$)),v.map(y=>{const $=f.get(y),b=Ru(y.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:u(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((w,j)=>t.jsx(ir,{item:w,onNavigate:o,renderLink:s},w.id||j))})]},y)})]})},Lu={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},ir=({item:e})=>{const n=Ee(),{convert:i}=Oe(),[o,s]=g.useState(!1),a=g.useMemo(()=>(e.url?bn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||rl(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,h=e.expected_volumes??(d?c+p:0),u=e.color_mode?{...Lu[e.color_mode],label:n.colorMode[e.color_mode]}:null,m=e.details&&!d?i(e.details):null,f={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",background:r("input-bg"),fontSize:"12px",color:r("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),u&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:u.bg,color:u.fg},children:u.label}),m&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",h,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:xt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Xr(e.metadata);return x?Zr(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:r("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),d&&o&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const v=x.status==="missing";return x.url&&!v?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${r("widget-border")}`,color:r("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:r(v?"missing-fg":"desc-fg"),textDecoration:v?"line-through":"none",opacity:v?.6:1},children:x.volume},x.volume)})})]})},ul=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ee(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,h=(n==null?void 0:n.repoPath)||"",u=h?h.split(/[/\\]/).pop()||h:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},f={onMouseOver:v=>v.currentTarget.style.opacity="0.8",onMouseOut:v=>v.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...m,background:r(p?"warning":"success"),color:r("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:m,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:u||d.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]}),!c&&u&&t.jsxs("div",{style:{...m,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:h,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:u})]})]})},$i="bim-search-history",_s=10,$s=8;function Ln(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):[]}catch{return[]}}function ml(e){try{const n=Ln().filter(i=>i!==e);n.unshift(e),n.length>_s&&(n.length=_s),localStorage.setItem($i,JSON.stringify(n))}catch{}}function Au(e){try{const n=Ln().filter(i=>i!==e);localStorage.setItem($i,JSON.stringify(n))}catch{}}function Mu(){try{localStorage.removeItem($i)}catch{}}const hl=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Ee(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,h]=g.useState(!1),[u,m]=g.useState([]),[f,x]=g.useState(-1),[v,y]=g.useState(Ln),$=g.useRef(null),b=g.useRef(null),w=g.useRef(null),j=g.useRef(!1);g.useEffect(()=>{x(-1);const T=n.trim();if(!T){m(v.map(N=>({type:"history",text:N})));return}if(!e.searchAll){m([]);return}let B=!1;const W=setTimeout(()=>{e.searchAll(T,$s).then(N=>{if(B)return;const R=[...N.works,...N.books,...N.collections,...N.entities??[]];m(R.slice(0,$s).map(H=>({type:"entry",text:H.title||H.id,entry:H})))}).catch(()=>{B||m([])})},80);return()=>{B=!0,clearTimeout(W)}},[n,v,e]),g.useEffect(()=>{const T=B=>{w.current&&!w.current.contains(B.target)&&h(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),g.useEffect(()=>{const T=B=>{var W,N;if(B.key==="/"&&document.activeElement!==$.current){const R=(W=document.activeElement)==null?void 0:W.tagName;if(R==="INPUT"||R==="TEXTAREA"||R==="SELECT")return;B.preventDefault(),(N=$.current)==null||N.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const k=g.useCallback(T=>{T.trim()&&(ml(T.trim()),y(Ln())),o(T),h(!1)},[o]),C=g.useCallback(T=>{T.type==="history"?(i(T.text),k(T.text)):T.entry&&(s?(s(T.entry),h(!1)):(i(T.text),k(T.text)))},[i,k,s]),S=g.useCallback(T=>{if(!p||u.length===0){T.key==="Enter"&&k(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(B=>(B+1)%u.length);break;case"ArrowUp":T.preventDefault(),x(B=>(B-1+u.length)%u.length);break;case"Enter":T.preventDefault(),f>=0&&f<u.length?C(u[f]):k(n);break;case"Escape":T.preventDefault(),h(!1);break}},[p,u,f,n,k,C]),_=g.useCallback((T,B)=>{B.stopPropagation(),Au(T),y(Ln()),m(W=>W.filter(N=>!(N.type==="history"&&N.text===T)))},[]),L=g.useCallback(T=>{T.stopPropagation(),Mu(),y([]),m([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const T=b.current.children;T[f]&&T[f].scrollIntoView({block:"nearest"})}},[f]);const z=!n.trim()&&v.length>0;return t.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:$,type:"text",placeholder:d,value:n,onChange:T=>{i(T.target.value),h(!0)},onCompositionStart:()=>{j.current=!0},onCompositionEnd:()=>{j.current=!1},onFocus:()=>{h(!0)},onKeyDown:S,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&u.length>0&&t.jsxs("div",{ref:b,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:r("input-bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"6px",boxShadow:r("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[z&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:r("desc-fg"),borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:L,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),u.map((T,B)=>t.jsxs("div",{onClick:()=>C(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:B===f?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:T.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.text}),T.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[T.entry.type],T.entry.edition&&` · ${T.entry.edition}`,T.entry.author&&` · ${T.entry.author}`]}),T.type==="history"&&t.jsx("button",{onClick:W=>_(T.text,W),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${T.type}-${T.text}-${B}`))]})]})},kn=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:r(`type-${e}`),verticalAlign:"middle"}}),Ci={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},gl=new Set(["work","book","entity"]);function Pu(e){return bl(e)||!!e.sort}function Bu(e,n){return n.sort&&gl.has(e)?n.sort:void 0}const Ti=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],zi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],fl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],xl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Ni(e){return e.dynasty.length+e.classification.length+(e.hasImage?1:0)+(e.hasText?1:0)+(e.hasCollated?1:0)+(e.loss?1:0)}function bl(e){return Ni(e)>0}function Ou(e){const n=[];return e.dynasty.length&&n.push("dynasty"),e.classification.length&&n.push("classification"),e.hasImage&&n.push("hasImage"),e.hasText&&n.push("hasText"),e.hasCollated&&n.push("hasCollated"),e.loss&&n.push("loss"),n}function yl(e,n){const i=xl[e];return Ou(n).every(o=>i.has(o))}const Tn=e=>JSON.stringify(e);function Wu(e,n){if(!yl(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=Ti.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${Tn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(Tn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${Tn(e.classification[0])}`:`classification IN [${e.classification.map(Tn).join(", ")}]`),e.hasImage&&i.push("has_image = true"),e.hasText&&i.push("has_text = true"),e.hasCollated&&i.push("has_collated = true"),e.loss&&i.push(`loss_status = ${Tn(e.loss)}`),i.join(" AND ")}const ct={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},jl="_";function xi(e,n=new URLSearchParams){for(const i of Object.values(ct))n.delete(i);return e.dynasty.length&&n.set(ct.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(ct.classification,e.classification.map(i=>i||jl).join(",")),e.hasImage&&n.set(ct.hasImage,"1"),e.hasText&&n.set(ct.hasText,"1"),e.hasCollated&&n.set(ct.hasCollated,"1"),e.loss&&n.set(ct.loss,e.loss),e.sort&&n.set(ct.sort,e.sort),n}function Fu(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(Ti.map(a=>a.key)),o=new Set(zi.map(a=>a.value)),s=e.get(ct.loss);return{dynasty:Array.from(new Set(n(ct.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(ct.classification).map(a=>a===jl?"":a).filter(a=>o.has(a)))),hasImage:e.get(ct.hasImage)==="1",hasText:e.get(ct.hasText)==="1"||e.get(ct.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(a=>a===e.get(ct.sort))??""}}function Hu(e,n){return JSON.stringify([e.dynasty.slice().sort(),e.classification.slice().sort(),e.hasImage,e.hasText,e.hasCollated,e.loss,e.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Cs(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Du=({filters:e,onChange:n})=>{const i=Ee(),o=i.searchV4,{convert:s}=Oe(),[a,l]=g.useState(!1),d=g.useId(),c=Ni(e),p=h=>n({...e,...h});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(o.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(h=>!h),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(xt(o.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?o.collapse:o.expand)," ",a?"▴":"▾"]})]}),t.jsxs("div",{className:"bim-sr-filters",id:d,"data-open":a?"true":"false",...a?{}:{"data-collapsed":"true"},children:[t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:Ti.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:Cs(e.dynasty,h.key)}),children:s(h.key)},h.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),zi.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:Cs(e.classification,h.value)})}),h.value?s(h.label):i.searchPage.unclassified]},h.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:h=>p({hasImage:h.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:h=>p({hasText:h.target.checked})}),s(o.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(o.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:fl.map(h=>t.jsx("button",{type:"button","aria-pressed":e.loss===h.value,onClick:()=>p({loss:h.value}),children:i.searchPage.loss[h.value||"all"]},h.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Ci,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function vl({text:e,query:n}){const i=(n??"").trim();if(!i||!e)return t.jsx(t.Fragment,{children:e});const o=e.toLowerCase(),s=i.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=o.indexOf(s,l);if(c<0){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{className:"bim-sr-hl",children:e.slice(c,c+s.length)},d++)),l=c+s.length}return t.jsx(t.Fragment,{children:a})}const Ts=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ee(),a=s.searchV4,{convert:l}=Oe(),d=it();return t.jsx("div",{className:"bim-sr-tablewrap",children:t.jsxs("table",{className:"bim-sr-table",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"34%"}}),t.jsx("col",{style:{width:"8%"}}),t.jsx("col",{style:{width:"19%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"14%"}})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:l(a.colTitle)}),t.jsx("th",{scope:"col",children:l(a.colType)}),t.jsx("th",{scope:"col",children:l(a.colAuthor)}),t.jsx("th",{scope:"col",children:l(a.colEra)}),t.jsx("th",{scope:"col",children:l(a.colClass)}),t.jsx("th",{scope:"col",style:{textAlign:"right"},children:l(a.colResource)})]})}),t.jsx("tbody",{children:e.map(c=>{const p=l(c.title||c.primary_name||c.id),h=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",u=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,f=m?l(m):"",x=c.classification?l(c.classification):"",v=[];c.has_image&&v.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&v.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&v.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[u,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:$=>i(c,$),children:t.jsx(vl,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sr-measure",children:h})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(kn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:u||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:v.map($=>t.jsx("span",{className:`bim-sr-tag ${$.cls}`,children:l($.label)},$.label))})]},c.id)})})]})})},Uu=`
|
|
1
|
+
"use strict";var Bp=Object.create;var fs=Object.defineProperty;var Op=Object.getOwnPropertyDescriptor;var Wp=Object.getOwnPropertyNames;var Fp=Object.getPrototypeOf,Hp=Object.prototype.hasOwnProperty;var Dp=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Wp(n))!Hp.call(e,s)&&s!==i&&fs(e,s,{get:()=>n[s],enumerable:!(o=Op(n,s))||o.enumerable});return e};var oi=(e,n,i)=>(i=e!=null?Bp(Fp(e)):{},Dp(n||!e||!e.__esModule?fs(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ke=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),g=require("react"),Up=require("opencc-js/t2cn"),Qa=require("./variant-supplement.cjs"),Vp=require("react-markdown"),Gp=require("remark-gfm"),Yp=e=>`/item/${e}`,el=g.createContext(Yp);function qp({buildUrl:e,children:n}){const i=g.useMemo(()=>e,[e]);return t.jsx(el.Provider,{value:i,children:n})}function it(){return g.useContext(el)}const tl="",nl="";function Yr(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?nl:tl,a=o.indexOf(s);if(a===-1){n.push({text:o,marked:i});break}a>0&&n.push({text:o.slice(0,a),marked:i}),o=o.slice(a+1),i=!i}return n}function dt(e,n){return{title:e,tokens:n}}const xs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Kp=[dt("基础(VS Code 环境下跟随 --vscode-*)",{bg:{value:"#ffffff",vscode:"--vscode-editor-background"},fg:{value:"#333333",vscode:"--vscode-foreground"},"input-bg":{value:"#ffffff",vscode:"--vscode-input-background"},"input-fg":{value:"#333333",vscode:"--vscode-input-foreground"},"input-border":{value:"#cccccc",vscode:"--vscode-input-border"},"widget-border":{value:"#e0e0e0",vscode:"--vscode-widget-border"},"link-fg":{value:"#0066cc",vscode:"--vscode-textLink-foreground"},"desc-fg":{value:"#717171",vscode:"--vscode-descriptionForeground"},primary:{value:"#0078d4",vscode:"--vscode-button-background"},"primary-fg":{value:"#ffffff",vscode:"--vscode-button-foreground"},"primary-soft":{value:"rgba(0, 120, 212, 0.15)",css:"color-mix(in srgb, var(--bim-primary) 15%, transparent)"},danger:{value:"#f44336"},warning:{value:"#ff9800"},success:{value:"#4caf50"},"sidebar-bg":{value:"#f3f3f3",vscode:"--vscode-sideBar-background"},"list-hover-bg":{value:"rgba(0, 0, 0, 0.04)",vscode:"--vscode-list-hoverBackground"},"list-active-bg":{value:"rgba(0, 120, 212, 0.1)",vscode:"--vscode-list-activeSelectionBackground"},"focus-border":{value:"#0078d4",vscode:"--vscode-focusBorder"}}),dt("底色层次 / 文字与描边 / 链接",{"bg-subtle":{value:"#fafafa"},"widget-bg":{value:"#f8f8f8"},muted:{value:"#888888"},border:{value:"#e5e5e5"},"primary-bg":{value:"#fdf4f4"},link:{value:"#1976d2"},"tag-bg":{value:"#f0f0f0"},"accent-bg":{value:"#1976d2"},"on-color-fg":{value:"#ffffff",note:"彩色底(徽章、选中态按钮)上的文字"}}),dt("提示与警告",{"info-fg":{value:"#0c5380"},"info-bg":{value:"#e7f3ff"},"info-border":{value:"#b3dbff"},"warn-fg":{value:"#856404"},"warn-bg":{value:"#fff3cd"},"warn-border":{value:"#ffc107"},"danger-bg":{value:"rgba(244, 67, 54, 0.08)",note:"错误提示条底色"},"danger-soft-bg":{value:"rgba(244, 67, 54, 0.03)",note:"编辑器危险区块"},"danger-soft-border":{value:"rgba(244, 67, 54, 0.13)"}}),dt("遮罩与阴影",{backdrop:{value:"rgba(0, 0, 0, 0.5)",note:"对话框遮罩"},"overlay-bg":{value:"#00000010",note:"轻量遮罩底(图片占位等)"},"shadow-dialog":{value:"0 4px 20px rgba(0, 0, 0, 0.3)"},"shadow-dropdown":{value:"0 4px 12px rgba(0, 0, 0, 0.1)"},"shadow-tooltip":{value:"0 2px 8px rgba(0, 0, 0, 0.08)"},"shadow-fab":{value:"0 2px 8px rgba(0, 0, 0, 0.25)",note:"悬浮按钮(反馈)"},"shadow-card":{value:"0 1px 4px rgba(0, 0, 0, 0.06)",note:"展开的卡片"},"shadow-node":{value:"0 1px 3px rgba(0, 0, 0, 0.1)",note:"谱系图节点"},"shadow-node-selected":{value:"0 0 0 3px rgba(0, 120, 212, 0.2), 0 2px 8px rgba(0, 120, 212, 0.3)"}}),dt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),dt("资源",{"restype-text":{value:"#2196f3"},"restype-image":{value:"#ff9800"},"restype-text-image":{value:"#9c27b0"},"restype-physical":{value:"#795548"},"missing-fg":{value:"#e67e22",note:"资源缺册提示"},"colormode-bw-bg":{value:"#f5f5f5",note:"影印件色彩模式标记(黑白 / 彩色)"},"colormode-bw-fg":{value:"#757575"},"colormode-color-bg":{value:"#fff8e1"},"colormode-color-fg":{value:"#f57f17"},"progress-active":{value:"#f59e0b",note:"资源导入进度"},"progress-done":{value:"#10b981"},"progress-todo":{value:"#9ca3af"},"check-fine-bg":{value:"#e8f5e9",note:"文字资源校对程度徽章(精校 / 粗校 / AI整理)"},"check-fine-fg":{value:"#2e7d32"},"check-rough-bg":{value:"#fff3e0"},"check-rough-fg":{value:"#e65100"},"check-ai-bg":{value:"#e3f2fd"},"check-ai-fg":{value:"#1565c0"}}),dt("整理本(CollatedEdition)",{"highlight-bg":{value:"#fff59d",note:"搜索命中高亮底"},"highlight-fg":{value:"inherit",root:!1},"section-lei":{value:"#8e6f3e",note:"章节类型标记:类 / 书 / 序 / 结语 / 考证 / 注释"},"section-shu":{value:"#c0392b"},"section-xu":{value:"#1a5276"},"section-jieyu":{value:"#7d6608"},"section-kaozhen":{value:"#5d6d7e"},"section-zhushi":{value:"#6c5b7b"},"section-tag-fg":{value:"#e74c3c",note:"章节标记(△ 等)"},"matchstate-fg":{value:"#b78900",note:"与底本匹配状态提示"},"quality-source":{value:"#1b5e20",note:"文本质量等级(底本 / OCR / 粗校 / 精校 / 暂无正文 / 占位)"},"quality-ocr":{value:"#e65100"},"quality-rough":{value:"#1565c0"},"quality-fine":{value:"#2e7d32"},"quality-none":{value:"#5f6368",note:"中性灰:暂无正文"},"quality-placeholder":{value:"#757575",note:"中性灰:占位"}}),dt("版本传承(VersionLineageGraph / List) / 关系方向(RelationPanel)",{"lost-fg":{value:"#c62828",note:"佚失标记"},"confidence-certain":{value:"#2e7d32",note:"关系置信度"},"confidence-consensus":{value:"#1976d2"},"confidence-probable":{value:"#ed6c02"},"confidence-disputed":{value:"#c62828"},"lineage-edge-consensus":{value:"#555555",note:"⚠️ 同为 consensus,List 徽章用 --bim-confidence-consensus(蓝),Graph 连线用这个(灰)。若要统一,覆盖成 var(--bim-confidence-consensus)"},"relation-up":{value:"#2196f3"},"relation-down":{value:"#4caf50"},"relation-flat":{value:"#ff9800"}}),dt("编辑器视图(主要在 guji-platform 插件中可见)",{"editor-type-work":{value:"#4caf50",note:"⚠️ 与展示视图的 --bim-type-* 是两套配色(历史如此)。若要统一,覆盖成对应的 var(--bim-type-*)"},"editor-type-collection":{value:"#2196f3"},"editor-type-book":{value:"#ff9800"},"editor-type-entity":{value:"#9c27b0"},"source-url":{value:"#2196f3",note:"来源类型(SourceEditor)"},"source-bookid":{value:"#4caf50"},"mode-active-bg":{value:"#2196f3",note:"模式指示器当前态(ModeIndicator)"},"cover-accent":{value:"#8e6f3e",note:'书目卡片「封面」点缀(IndexBrowser resultVariant="card")'}}),dt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#3b4a58",note:"主题切换控件的色点:墨"},"sect-jing":{value:"#2e5266",note:"四部分布条:經部(人物页提要卡;无别处使用)"},"sect-shi":{value:"#9a7a3b",note:"四部分布条:史部"},"sect-zi":{value:"#4f7a5c",note:"四部分布条:子部"},"sect-ji":{value:"#9fb3bc",note:"四部分布条:集部"},"table-border":{value:"color-mix(in srgb, currentColor 28%, transparent)",root:!1,note:"古籍表格(跟随当前文字色)"},"table-head-bg":{value:"color-mix(in srgb, currentColor 8%, transparent)",root:!1}}),dt('版式(v4 外观系统,overview#291):疏朗=留白分区(默认,下列值即疏朗);界栏=框线分区(`<html data-layout="boxed">`)',{"fr-bd":{value:"0 solid transparent",note:"区块外框(border 简写)。疏朗无框;界栏 1px 实线"},"fr-bg":{value:"transparent",note:"区块底。界栏=卡面色"},"fr-hd-pad":{value:"14px 18px",note:"区块标题栏内边距。10-01 起疏朗也有淡染底的标题栏(--bim-fr-hd-bg),故疏朗 14px 18px,界栏 12px 18px"},"fr-hd-bd":{value:"0 solid transparent",note:"区块标题栏下沿线(border 简写)"},"fr-bd-pad":{value:"0",note:"区块正文内边距"},"fr-gap":{value:"56px",note:"区块之间的间距。界栏收紧到 24px(框线本身已分隔)"},"fr-side-gap":{value:"34px",note:"侧栏各块之间的间距;界栏 20px"},"fr-shadow":{value:"0 1px 0 var(--bim-rule), 0 12px 32px -18px rgba(40, 36, 31, 0.25)",note:"抬起的面(提要卡)的投影;界栏不用投影,靠框线"},"fr-tab-bd":{value:"transparent",note:"页签行下沿线颜色(疏朗不画,界栏画)"},"fr-hd-size":{value:"24px",note:"分区标题字号。界栏标题在框顶标题栏里,小一档 19px"},"fr-hd-bg":{value:"color-mix(in srgb, var(--bim-accent) 7%, var(--bim-page-bg))",note:"分区标题栏底色(淡染主色)。疏朗混进页面底,界栏 6% 混进卡面底。主色取 accent(primary 是 VS Code 按钮蓝,不随配色)"},"fr-card-bd":{value:"1px solid transparent",note:"卡片边框。疏朗不画(靠卡面底与淡投影);界栏 1px"},"fr-card-bg":{value:"var(--bim-card-bg)",note:"卡片底"},"fr-row-bd":{value:"1px solid transparent",note:"列表行线、块内小分割线。疏朗不画(靠行距);界栏 1px"},"fr-row-pad":{value:"10px 2px",note:"列表行内边距。界栏收紧 7px 2px"},"fr-chrome-bd":{value:"1px solid transparent",note:"顶栏、分区导航(吸顶锚点条)的线"},"fr-tag-bd":{value:"1px solid transparent",note:"标签、版本签、计数签、工具按钮的边框。疏朗浅底无框;界栏透明底加框"},"fr-tag-bg":{value:"var(--bim-tint-bg)",note:"标签底"},"fr-tbl-cell-bd":{value:"0 solid transparent",note:"表格格线。疏朗不画(靠斑马纹);界栏全格线"},"fr-tbl-zebra":{value:"var(--bim-tint-bg)",note:"表格斑马纹(只在疏朗下有)"},"fr-rail-bd":{value:"1px solid transparent",note:"侧栏里的块、提示块的边框"},"fr-rail-bg":{value:"var(--bim-tint-bg)",note:"侧栏块底。疏朗浅底;界栏卡面底"},"fr-spine-bd":{value:"1px solid transparent",note:"题签、书脊(竖排书名)的边框。界栏是强调色浅线"},"fr-spine-bg":{value:"var(--bim-flag-bg)",note:"题签、书脊底。疏朗浅色实底;界栏卡面底(正史原志两种版式都是强调色实底)"},"fr-plank":{value:"0 solid transparent",note:"书架架板(border 简写)。只在界栏下画 3px"},"fr-axis-bd":{value:"0 solid transparent",note:"时间轴轴线。界栏 1px"},"fr-axis-band":{value:"6px",note:"时间轴底带高度。疏朗用 6px 浅色带代替轴线;界栏 0"},"fr-tick":{value:"0",note:"时间轴刻度短线长度。界栏 5px"},"fr-band-gap":{value:"3px",note:"年代带各段之间的空隙。疏朗 3px;界栏紧贴"},"fr-band-bd":{value:"0 solid transparent",note:"年代带外框与段间分隔。界栏 1px"}}),dt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"reader-warm":{value:"#c9a24a",note:"阅读设置侧栏的暖黄:只做底色(8%)与选中态(24%),与朱/靛/墨三套主色都不冲"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),dt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),dt("字体(全站无衬线,2026-09-05 定)",{"font-ui":{value:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif'},"font-body":{value:"system-ui, sans-serif",css:"var(--bim-font-ui)"},"font-serif":{value:xs,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:xs,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Xp=Object.assign({},...Kp.map(e=>e.tokens)),il={};for(const[e,n]of Object.entries(Xp))il[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=il[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Bt(e){return e.types&&e.types.length>0?e.types:[]}function Zp(e,n){return Bt(e).includes(n)}const Jp={source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"};r("quality-source"),r("quality-ocr"),r("quality-rough"),r("quality-fine"),r("quality-none"),r("quality-placeholder");const Qp={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃","www.shidianguji.com":"識典古籍","shidianguji.com":"識典古籍","archive.org":"Internet Archive","www.shuge.org":"書格","shuge.org":"書格","pan.baidu.com":"百度網盤"};function bn(e){try{return Qp[new URL(e).hostname]}catch{return}}const bs={text:0,image:1,physical:2};function qr(e){return e.length===0?"physical":[...e].sort((n,i)=>(bs[n]??99)-(bs[i]??99)).join("+")}function eu(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function Kr(e){var l;const n=d=>{const c=d.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const p=d.match(/^(.+?)[·(](\d+)[)]?$/);return p?[p[1],parseInt(p[2])]:null},i=new Map;for(let d=0;d<e.length;d++){const c=e[d];if(c.volumes&&c.volumes.length>0)continue;const p=n(c.name);if(!p)continue;const[h,u]=p,m=`${h}|${qr(Bt(c))}`;i.has(m)||i.set(m,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const f=i.get(m);f.volumes.push({volume:u,url:c.url||void 0,status:"found"}),f.indices.push(d)}const o=[],s=new Set;for(const d of i.values())if(!(d.volumes.length<2)){d.volumes.sort((c,p)=>c.volume-p.volume),d.base.volumes=d.volumes,d.base.expected_volumes=d.volumes.length,d.base.url||(d.base.url=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function rl(e){if(e.url)return e.url;for(const[n,i]of Object.entries(e))if(n.endsWith("_url")&&typeof i=="string")return i}function ol(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||rl(n)}))}function Si(e){const n=ol(e);if(!n)return null;const i=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,o=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:i,missing:o,expected:e.expected_volumes??i+o}}function Xr(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const i=n.match(/^(\d+)/);return i?parseInt(i[1],10):void 0}function Zr(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const o=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(o)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(o[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function yn(e){if(!e.url)return;const n=Xr(e.metadata);return n?Zr(e.url,n):e.url}const Nt=g.createContext(null),sl=["曹霑"];function tu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nu(e,n=sl){const i=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!i.length)return e;const o=new RegExp(`(${i.map(tu).join("|")})`,"g"),s=new Set(i);return a=>{if(!a)return e(a);const l=a.split(o);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let _n=null;function al(){if(_n)return _n;try{const e=Up.Converter({from:"t",to:"cn"});_n=nu(n=>e(ke.normalizeVariants(n)))}catch{_n=e=>e}return _n}const iu={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("check-ai-fg")}},action:{save:"保存",delete:"刪除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"訪問 →",view:"查看 →",viewEntity:"查看",copy:"複製 ID",copied:"已複製",linkExisting:"+ 關聯現有",createAndLink:"+ 創建並關聯",remove:"刪除",clearAll:"清除全部",reselect:"重選",changeType:"更換類型",expand:"展開",collapse:"收起",expandMore:"展開更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加書籍",addSubCollection:"添加子叢編",addCollectionImpl:"添加叢編實現",addSource:"添加來源",addResource:"添加資源",addIndexedBy:"+ 添加收錄來源",addEmendatedBy:"+ 添加考證來源",addAdditionalWork:"+ 添加附屬作品",selectBookOrWork:"選擇書籍/作品",clickToSelectBookOrWork:"點擊選擇書籍/作品",unlink:"解除關聯"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷數",pageCount:"頁數 (Pages)",volumeCount:"冊數 (Volumes)",holder:"現藏於 (Holder)",firstImage:"首頁圖片 (First Image URL)",year:"年代",currentLocation:"現藏",parentWork:"上級作品",relatedWorks:"相關作品",type:"類型",rootType:"根類型",coverageLevel:"覆蓋層級",coverageRange:"覆蓋範圍",metadata:"元數據",optionalInfo:"可選信息",details:"詳細說明",detailsOptional:"詳細說明 (可選)",positionOptional:"位置/頁碼 (可選)",dataVersionOptional:"數據版本 (可選)",processorVersionOptional:"處理器版本 (可選)",sourceName:"來源名稱",sourceBid:"來源 BID",titleInfo:"題名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介紹 (Description)",additionalWorks:"📑 附屬作品 (Additional Works)",indexedBy:"📖 著錄於",emendatedBy:"📝 考證",resources:"資源",textResources:"📝 文字資源 (Text Resources)",imageResources:"🖼️ 圖片資源 (Image Resources)",sources:"📚 資料來源 (Sources)",provenance:"📜 收藏歷史 (Provenance)",relatedVersions:"相關版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危險區域 (Danger Zone)",aliases:"別名",attachedTexts:"附載篇目",appendix:"附錄",containedIn:"收入叢編",collectedIn:"收入叢編",belongsToWork:"所屬作品",locationHistory:"流轉歷史",historyOverview:"歷史沿革",containedBooks:"收錄書籍",relations:"關聯關係",summary:"提要",comment:"按語",additionalComment:"附按",indexed:"收錄於",emendated:"考證",relatedWorks:"相關作品",containedWorks:"包含作品",adaptations:"改編作品",derivativeWorks:"續書與評註",studies:"所考典籍"},relation:{belongsToWork:"所屬作品 (Work)",containedInCollection:"收入叢編",siblingVersions:"同作品其他版本",addVersionForWork:"為此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"叢編實現",allVersions:"所有版本",correspondingWork:"對應作品 (Work)",parentCollection:"父叢編 (Parent Collection)",childCollections:"子叢編",containedBooks:"包含書籍",notLinked:"(未關聯)",none:"(暫無)"},search:{placeholder:"搜索作品、書籍、叢編...",searching:"搜索中...",loading:"加載中...",noResults:"無匹配結果",noResultsFor:"未找到與「{query}」相關的結果",tryOther:"試試其他關鍵詞、別名或作者名",recentBrowse:"最近瀏覽",history:"搜索歷史",clearAll:"清除全部",clearRecent:"清除最近瀏覽",itemNotFound:"無法找到,可能已刪除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"結果分類",searchSubtitle:"輸入關鍵詞搜索作品、書籍或叢編",searchBookName:"搜索書名...",alias:"別名"},searchV4:{filterTitle:"篩選",dynasty:"朝代",classification:"部類",resources:"資源",extant:"存佚",clearAllFilters:"清除全部篩選",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"篩選",filterSelected:"{n} 項已選",expand:"展開",collapse:"收起",filteredCount:"篩出 {n} 條",removeFilter:"取消篩選:{name}",viewLabel:"結果視圖",viewTable:"表格",viewCard:"卡片",colTitle:"題名",colType:"類型",colAuthor:"責任者",colEra:"年代",colClass:"部類",colResource:"資源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 條 · 每頁 {size} 條 · 第 {page} / {pages} 頁",pagerLabel:"翻頁",prevPage:"上一頁",nextPage:"下一頁",emptyFiltered:"沒有找到匹配的條目。試試更短的書名、減少篩選,或切換繁 / 簡。",limitedNote:"各類只列前幾條,點上方分類頁籤看全部。",sortLabel:"排序",sortRelevance:"相關度",sortEra:"年代",sortTitle:"書名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A"},home:{title:"古籍索引",subtitle:"從左側搜索框輸入關鍵詞,查找作品、書籍或叢編",recommendedBrowse:"推薦瀏覽",catalogTab:"目錄",collectionTab:"叢編",siteTab:"在線資源",recommendTab:"推薦",feedbackTab:"反饋",statusInProgress:"進行中",statusDone:"已完成",statusTodo:"未開始",typeCatalog:"目錄",typeCollection:"資源集合",totalPending:"待統計",progressFormat:"{imported} / {total}",siteCoverage:"資源覆蓋"},browser:{title:"古籍資源索引",subtitle:""},detailTab:{basicInfo:"概覽",catalog:"目錄",collectionCatalog:"叢編目錄",collatedEdition:"文本",catalogSuffix:"·目錄",fullText:"文本",lineage:"版本傳承",feedback:"勘誤反饋",dataSource:"數據源",backToIndex:"典籍版本索引",submitVersion:"提交新版本",dataLicense:"數據源與授權"},metadata:{edition:"版本",version:"修訂版本",quality:"資源質量",check_type:"校對",image_source:"影像來源",team:"所屬團隊",publisher:"出版社",year:"出版年份",format:"格式",note:"備註",total_page:"頁數",total_pages:"總頁數",page_range:"頁碼範圍",page_count:"頁數",file_page_range:"文件頁碼",file_page_count:"文件頁數",content_page_range:"影印頁碼",volume:"冊",color_mode:"色彩",paragraph_count:"段落數",has_translation:"翻譯"},editor:{untitled:"未命名",workTitle:"作品名 (Work Title)",collectionTitle:"叢書名 (Collection Title)",bookTitle:"書名 (Book Title)",belongsToWork:"所屬作品 (Work)",authorLabel:"作者 (Author)",publicationYearLabel:"出版年 (Publication year)",containedIn:"收入叢編",holderLabel:"現藏於 (Holder)",pageLabel:"頁數 (Pages)",volumeLabel:"冊數 (Volumes)",firstImageLabel:"首頁圖片 (First Image URL)",descriptionPlaceholder:"簡要介紹...",provenancePlaceholder:"該資源的流轉與收藏記錄...",otherEditionsPlaceholder:"相關版本的 ID...",dangerZoneDesc:"從索引庫中永久刪除該實體的所有元數據文件。",deleteEntity:"刪除該實體 (Delete Entity)",selectToLink:"選擇要關聯的",unnamedSource:"(未命名來源)",selectSourceType:"選擇來源類型",fromExistingBook:"從現有書籍選擇",enterUrl:"輸入網址鏈接",sourceNamePlaceholder:"如: 維基文庫、中國基本古籍庫",deleteThisSource:"刪除此來源",deleteThisResource:"刪除此資源",resourcePlaceholder:"資源",idAutoExtract:"ID (自動從URL提取)",resourceName:"資源名稱",resourceUrl:"資源鏈接 (URL)",structurePlaceholder:"層級結構 (如: 冊、卷)",coverageRangePlaceholder:"如: 2,3,5-8",detailsPlaceholder:"詳細說明",summaryPlaceholder:"提要...",commentPlaceholder:"按語...",additionalCommentPlaceholder:"附按...",imageResourceLink:"圖片資源鏈接",bookNameLabel:"書名",sourcePlaceholder:"來源"},download:{completed:"下載完成",downloading:"下載中",downloadThis:"下載此資源"},mode:{localMode:"本地模式",syncMode:"同步模式:",githubSync:"GitHub 同步",switchToSync:"點擊切換到同步模式",switchToLocal:"點擊切換到本地模式",switchToGithub:"點擊切換到 GitHub 同步模式",switchToDraft:"點擊切換到 draft 倉庫",switchToOfficial:"點擊切換到 official 倉庫",selectFolder:"選擇本地文件夾",configurePath:"配置同步路徑"},catalog:{totalVolumes:"共",processed:"已處理",contains:"收錄",matched:"已匹配",unmatched:"待匹配",source:"來源:",all:"全部",loading:"加載叢編目錄...",notFound:"未找到叢編目錄數據",loadFailed:"加載失敗",noMatch:"無匹配結果",unmatched_label:"未匹配",volume:"第 {n} 冊"},unit:{juan:"卷",volume:"冊",bu:"部",items:"條"},workSubtype:{book:"書",article:"篇",poem:"詩",chapter:"篇章"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暫無資源信息",hasTranslation:"有",noTranslation:"無",structure:"層級",coverage:"覆蓋",notFoundEntry:"未找到該條目",loadFailed:"加載失敗",textResource:"文字資源",imageResource:"圖片資源"}},ru={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("check-ai-fg")}},action:{save:"保存",delete:"删除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"访问 →",view:"查看 →",viewEntity:"查看",copy:"复制 ID",copied:"已复制",linkExisting:"+ 关联现有",createAndLink:"+ 创建并关联",remove:"删除",clearAll:"清除全部",reselect:"重选",changeType:"更换类型",expand:"展开",collapse:"收起",expandMore:"展开更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加书籍",addSubCollection:"添加子丛编",addCollectionImpl:"添加丛编实现",addSource:"添加来源",addResource:"添加资源",addIndexedBy:"+ 添加收录来源",addEmendatedBy:"+ 添加考证来源",addAdditionalWork:"+ 添加附属作品",selectBookOrWork:"选择书籍/作品",clickToSelectBookOrWork:"点击选择书籍/作品",unlink:"解除关联"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷数",pageCount:"页数 (Pages)",volumeCount:"册数 (Volumes)",holder:"现藏于 (Holder)",firstImage:"首页图片 (First Image URL)",year:"年代",currentLocation:"现藏",parentWork:"上级作品",relatedWorks:"相关作品",type:"类型",rootType:"根类型",coverageLevel:"覆盖层级",coverageRange:"覆盖范围",metadata:"元数据",optionalInfo:"可选信息",details:"详细说明",detailsOptional:"详细说明 (可选)",positionOptional:"位置/页码 (可选)",dataVersionOptional:"数据版本 (可选)",processorVersionOptional:"处理器版本 (可选)",sourceName:"来源名称",sourceBid:"来源 BID",titleInfo:"题名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介绍 (Description)",additionalWorks:"📑 附属作品 (Additional Works)",indexedBy:"📖 著录于",emendatedBy:"📝 考证",resources:"资源",textResources:"📝 文字资源 (Text Resources)",imageResources:"🖼️ 图片资源 (Image Resources)",sources:"📚 资料来源 (Sources)",provenance:"📜 收藏历史 (Provenance)",relatedVersions:"相关版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危险区域 (Danger Zone)",aliases:"别名",attachedTexts:"附载篇目",appendix:"附录",containedIn:"收入丛编",collectedIn:"收入丛编",belongsToWork:"所属作品",locationHistory:"流转历史",historyOverview:"历史沿革",containedBooks:"收录书籍",relations:"关联关系",summary:"提要",comment:"按语",additionalComment:"附按",indexed:"收录于",emendated:"考证",relatedWorks:"相关作品",containedWorks:"包含作品",adaptations:"改编作品",derivativeWorks:"续书与评注",studies:"所考典籍"},relation:{belongsToWork:"所属作品 (Work)",containedInCollection:"收入丛编",siblingVersions:"同作品其他版本",addVersionForWork:"为此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"丛编实现",allVersions:"所有版本",correspondingWork:"对应作品 (Work)",parentCollection:"父丛编 (Parent Collection)",childCollections:"子丛编",containedBooks:"包含书籍",notLinked:"(未关联)",none:"(暂无)"},search:{placeholder:"搜索作品、书籍、丛编...",searching:"搜索中...",loading:"加载中...",noResults:"无匹配结果",noResultsFor:"未找到与「{query}」相关的结果",tryOther:"试试其他关键词、别名或作者名",recentBrowse:"最近浏览",history:"搜索历史",clearAll:"清除全部",clearRecent:"清除最近浏览",itemNotFound:"无法找到,可能已删除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"结果分类",searchSubtitle:"输入关键词搜索作品、书籍或丛编",searchBookName:"搜索书名...",alias:"别名"},searchV4:{filterTitle:"筛选",dynasty:"朝代",classification:"部类",resources:"资源",extant:"存佚",clearAllFilters:"清除全部筛选",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"筛选",filterSelected:"{n} 项已选",expand:"展开",collapse:"收起",filteredCount:"筛出 {n} 条",removeFilter:"取消筛选:{name}",viewLabel:"结果视图",viewTable:"表格",viewCard:"卡片",colTitle:"题名",colType:"类型",colAuthor:"责任者",colEra:"年代",colClass:"部类",colResource:"资源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 条 · 每页 {size} 条 · 第 {page} / {pages} 页",pagerLabel:"翻页",prevPage:"上一页",nextPage:"下一页",emptyFiltered:"没有找到匹配的条目。试试更短的书名、减少筛选,或切换繁 / 简。",limitedNote:"各类只列前几条,点上方分类页签看全部。",sortLabel:"排序",sortRelevance:"相关度",sortEra:"年代",sortTitle:"书名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A"},home:{title:"古籍索引",subtitle:"从左侧搜索框输入关键词,查找作品、书籍或丛编",recommendedBrowse:"推荐浏览",catalogTab:"目录",collectionTab:"丛编",siteTab:"在线资源",recommendTab:"推荐",feedbackTab:"反馈",statusInProgress:"进行中",statusDone:"已完成",statusTodo:"未开始",typeCatalog:"目录",typeCollection:"资源集合",totalPending:"待统计",progressFormat:"{imported} / {total}",siteCoverage:"资源覆盖"},browser:{title:"古籍资源索引",subtitle:""},detailTab:{basicInfo:"概览",catalog:"目录",collectionCatalog:"丛编目录",collatedEdition:"文本",catalogSuffix:"·目录",fullText:"文本",lineage:"版本传承",feedback:"勘误反馈",dataSource:"数据源",backToIndex:"典籍版本索引",submitVersion:"提交新版本",dataLicense:"数据源与授权"},metadata:{edition:"版本",version:"修订版本",quality:"资源质量",check_type:"校对",image_source:"影像来源",team:"所属团队",publisher:"出版社",year:"出版年份",format:"格式",note:"备注",total_page:"页数",total_pages:"总页数",page_range:"页码范围",page_count:"页数",file_page_range:"文件页码",file_page_count:"文件页数",content_page_range:"影印页码",volume:"册",color_mode:"色彩",paragraph_count:"段落数",has_translation:"翻译"},editor:{untitled:"未命名",workTitle:"作品名 (Work Title)",collectionTitle:"丛书名 (Collection Title)",bookTitle:"书名 (Book Title)",belongsToWork:"所属作品 (Work)",authorLabel:"作者 (Author)",publicationYearLabel:"出版年 (Publication year)",containedIn:"收入丛编",holderLabel:"现藏于 (Holder)",pageLabel:"页数 (Pages)",volumeLabel:"册数 (Volumes)",firstImageLabel:"首页图片 (First Image URL)",descriptionPlaceholder:"简要介绍...",provenancePlaceholder:"该资源的流转与收藏记录...",otherEditionsPlaceholder:"相关版本的 ID...",dangerZoneDesc:"从索引库中永久删除该实体的所有元数据文件。",deleteEntity:"删除该实体 (Delete Entity)",selectToLink:"选择要关联的",unnamedSource:"(未命名来源)",selectSourceType:"选择来源类型",fromExistingBook:"从现有书籍选择",enterUrl:"输入网址链接",sourceNamePlaceholder:"如: 维基文库、中国基本古籍库",deleteThisSource:"删除此来源",deleteThisResource:"删除此资源",resourcePlaceholder:"资源",idAutoExtract:"ID (自动从URL提取)",resourceName:"资源名称",resourceUrl:"资源链接 (URL)",structurePlaceholder:"层级结构 (如: 册、卷)",coverageRangePlaceholder:"如: 2,3,5-8",detailsPlaceholder:"详细说明",summaryPlaceholder:"提要...",commentPlaceholder:"按语...",additionalCommentPlaceholder:"附按...",imageResourceLink:"图片资源链接",bookNameLabel:"书名",sourcePlaceholder:"来源"},download:{completed:"下载完成",downloading:"下载中",downloadThis:"下载此资源"},mode:{localMode:"本地模式",syncMode:"同步模式:",githubSync:"GitHub 同步",switchToSync:"点击切换到同步模式",switchToLocal:"点击切换到本地模式",switchToGithub:"点击切换到 GitHub 同步模式",switchToDraft:"点击切换到 draft 仓库",switchToOfficial:"点击切换到 official 仓库",selectFolder:"选择本地文件夹",configurePath:"配置同步路径"},catalog:{totalVolumes:"共",processed:"已处理",contains:"收录",matched:"已匹配",unmatched:"待匹配",source:"来源:",all:"全部",loading:"加载丛编目录...",notFound:"未找到丛编目录数据",loadFailed:"加载失败",noMatch:"无匹配结果",unmatched_label:"未匹配",volume:"第 {n} 册"},unit:{juan:"卷",volume:"册",bu:"部",items:"条"},workSubtype:{book:"书",article:"篇",poem:"诗",chapter:"篇章"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暂无资源信息",hasTranslation:"有",noTranslation:"无",structure:"层级",coverage:"覆盖",notFoundEntry:"未找到该条目",loadFailed:"加载失败",textResource:"文字资源",imageResource:"图片资源"}};function mt(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const ou=mt({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),_i=mt({relation:{part_of:"所屬",has_part:"包含",contains_text_of:"收錄",collected_in:"叢編",text_carried_by:"載錄",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"後繼",derived_from:"衍生",has_adaptation:"改編",related:"相關"},lossStatus:{extant:"今存",fragment:"殘存",partial:"殘存",lost:"已佚",unknown:"未詳"},resourceKind:{text:"文本",image:"影印",textImage:"圖文",physical:"館藏"},otherImages:"其他影印",fragmentTag:"殘片",collapseVolumes:"收起分冊",expandVolumes:"展開 {n} 冊",mirror:"鏡像",volumeStats:"{found} / {expected} 冊",volumeStatsMissing:"{found} / {expected} 冊 缺 {missing}",pageNav:"本頁導航",thisPage:"本頁",more:"更多",expandRest:"展開其餘 {n} {unit}",read:"閱讀",showMore:"顯示更多({n})",review:{reviewed:"已審核",disputed:"有爭議",unreviewed:"未審核",draft:"草稿"},dataVersion:"數據版本",todoCount:"待核 {n} 項",lacuna:"闕文",lacunaWith:"闕文:{label}",composedChar:"組字:{label}",bce:"前{n}",roleAll:"全部",loading:"加載中…",noLineageGraph:"暫無版本圖數據",notFound:"找不到該條目,可能已被刪除或 ID 不正確",workInfo:"作品信息"},{relation:{part_of:"所属",has_part:"包含",contains_text_of:"收录",collected_in:"丛编",text_carried_by:"载录",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"后继",derived_from:"衍生",has_adaptation:"改编",related:"相关"},lossStatus:{extant:"今存",fragment:"残存",partial:"残存",lost:"已佚",unknown:"未详"},resourceKind:{text:"文本",image:"影印",textImage:"图文",physical:"馆藏"},otherImages:"其他影印",fragmentTag:"残片",collapseVolumes:"收起分册",expandVolumes:"展开 {n} 册",mirror:"镜像",volumeStats:"{found} / {expected} 册",volumeStatsMissing:"{found} / {expected} 册 缺 {missing}",pageNav:"本页导航",thisPage:"本页",more:"更多",expandRest:"展开其余 {n} {unit}",read:"阅读",showMore:"显示更多({n})",review:{reviewed:"已审核",disputed:"有争议",unreviewed:"未审核",draft:"草稿"},dataVersion:"数据版本",todoCount:"待核 {n} 项",lacuna:"阙文",lacunaWith:"阙文:{label}",composedChar:"组字:{label}",bce:"前{n}",roleAll:"全部",loading:"加载中…",noLineageGraph:"暂无版本图数据",notFound:"找不到该条目,可能已被删除或 ID 不正确",workInfo:"作品信息"}),su=mt({kind:"版本",fact:{editionType:"版本類型",publication:"刊印",era:"刊寫年代",measure:"卷帙",volumes:"冊次",baseEdition:"底本",holdings:"存藏",callNumber:"索書號",seals:"藏印",leafStyle:"行款",binding:"裝幀",dimensions:"尺寸",condition:"品相",aliases:"又名"},inferredFromEdition:"據版本題名推斷",volumesValue:"第 {range} {unit}({n} {unit})",andMorePlaces:" 等 {n} 處",viewImages:"看原書影印",sec:{fulltext:"文本",images:"影印",physical:"館藏",lineage:"版本源流",empty:"影印與文本"},chapterUnit:"章",chapterCount:"{n} {unit}",sourceBy:"據{src}",readFrom:"從{ch}讀起",firstChapter:"第一章",enterReader:"進入閱讀頁",externalText:"站外文本",groupCount:"{n} 組",placeCount:"{n} 處",lineageMeta:"據版本傳承著錄",lineageView:"源流視圖",viewCards:"卡片",viewGraph:"關係圖",totalOf:"全 {n} {unit}",emptyText:"尚未著錄該版本的影印、文本與收藏信息。",editionCount:"{n} 種版本",siblings:"同作品版本",byEra:"按年代",kindCount:"{n} 種",viewAllInWork:"在作品頁看全部 {n} 種 →",volumeRange:"第 {range} {unit}",volumeCount:"{n} {unit}",confidence:{certain:"確證",consensus:"通說",probable:"可能",disputed:"有爭議"},confidenceNote:"({c})",lineage:{ancestor:"祖本",reconstructed:"擬構祖本",thisEdition:"本版",derivatives:"翻刻 · 衍生",appendix:"附記"}},{kind:"版本",fact:{editionType:"版本类型",publication:"刊印",era:"刊写年代",measure:"卷帙",volumes:"册次",baseEdition:"底本",holdings:"存藏",callNumber:"索书号",seals:"藏印",leafStyle:"行款",binding:"装帧",dimensions:"尺寸",condition:"品相",aliases:"又名"},inferredFromEdition:"据版本题名推断",volumesValue:"第 {range} {unit}({n} {unit})",andMorePlaces:" 等 {n} 处",viewImages:"看原书影印",sec:{fulltext:"文本",images:"影印",physical:"馆藏",lineage:"版本源流",empty:"影印与文本"},chapterUnit:"章",chapterCount:"{n} {unit}",sourceBy:"据{src}",readFrom:"从{ch}读起",firstChapter:"第一章",enterReader:"进入阅读页",externalText:"站外文本",groupCount:"{n} 组",placeCount:"{n} 处",lineageMeta:"据版本传承著录",lineageView:"源流视图",viewCards:"卡片",viewGraph:"关系图",totalOf:"全 {n} {unit}",emptyText:"尚未著录该版本的影印、文本与收藏信息。",editionCount:"{n} 种版本",siblings:"同作品版本",byEra:"按年代",kindCount:"{n} 种",viewAllInWork:"在作品页看全部 {n} 种 →",volumeRange:"第 {range} {unit}",volumeCount:"{n} {unit}",confidence:{certain:"确证",consensus:"通说",probable:"可能",disputed:"有争议"},confidenceNote:"({c})",lineage:{ancestor:"祖本",reconstructed:"拟构祖本",thisEdition:"本版",derivatives:"翻刻 · 衍生",appendix:"附记"}}),au=mt({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),lu=mt({kind:"叢編",workCollection:"作品集",stat:{titles:"子目"},fact:{publication:"刊印",expected:"應收",measure:"卷帙"},member:{Book:"所收版本",Work:"所收作品",other:"成員"},memberNote:"子目與其各版本合計",nZhong:"{n} 種",nHan:"{n} 函",dist:{head:"全帙冊次分佈",segTitle:"{section} 第 {from}–{to} 冊",only:"只看{section}",unclassified:"未分類",hint:"點色段篩選部類"},sec:{titles:"子目",resources:"影印與文本"},totalVolumes:"全帙 {n} {unit}",currentN:"當前 {n} {unit}",loadAllTitle:"將載入全部 {n} {unit}",grouping:"正在按部類分組…",groupBySection:"按部類分組",find:"在本叢編中檢索",col:{volumes:"冊次",title:"書名",versions:"版本"},volumeRange:"第 {range} {unit}",resourcesCount:"{n} 處",text:"文本",empty:"尚未著錄該叢編的子目。",parent:"上級叢編"},{kind:"丛编",workCollection:"作品集",stat:{titles:"子目"},fact:{publication:"刊印",expected:"应收",measure:"卷帙"},member:{Book:"所收版本",Work:"所收作品",other:"成员"},memberNote:"子目与其各版本合计",nZhong:"{n} 种",nHan:"{n} 函",dist:{head:"全帙册次分布",segTitle:"{section} 第 {from}–{to} 册",only:"只看{section}",unclassified:"未分类",hint:"点色段筛选部类"},sec:{titles:"子目",resources:"影印与文本"},totalVolumes:"全帙 {n} {unit}",currentN:"当前 {n} {unit}",loadAllTitle:"将载入全部 {n} {unit}",grouping:"正在按部类分组…",groupBySection:"按部类分组",find:"在本丛编中检索",col:{volumes:"册次",title:"书名",versions:"版本"},volumeRange:"第 {range} {unit}",resourcesCount:"{n} 处",text:"文本",empty:"尚未著录该丛编的子目。",parent:"上级丛编"}),cu=mt({subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对"}),du=mt({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",properNameOff:"不顯示",properNameLite:"精簡",properNameFull:"完整",properNameLiteTitle:"只標人名、地名、朝代",showWorks:"標註書名",bookTitleStyle:"書名樣式",bookTitleWavy:"波浪線",bookTitleBracket:"書名號",scriptOrig:"原字",scriptOrigUnavailable:"此文本沒有規範層,無「原字」可選",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁體",scriptHans:"簡體",quoteStyle:"引號",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原樣",pageBreaks:"顯示分葉分割線",pageIndicator:"頁指示頭(上下鍵調整位置)",preserveMargins:"書影保留空白",facsimilePager:"書影翻頁",facsimilePageInput:"書影葉碼(輸入數字後按 Enter 或離開輸入框跳轉)",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",properNameOff:"不显示",properNameLite:"精简",properNameFull:"完整",properNameLiteTitle:"只标人名、地名、朝代",showWorks:"标注书名",bookTitleStyle:"书名样式",bookTitleWavy:"波浪线",bookTitleBracket:"书名号",scriptOrig:"原字",scriptOrigUnavailable:"此文本没有规范层,无「原字」可选",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁体",scriptHans:"简体",quoteStyle:"引号",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原样",pageBreaks:"显示分叶分割线",pageIndicator:"页指示头(上下键调整位置)",preserveMargins:"书影保留空白",facsimilePager:"书影翻页",facsimilePageInput:"书影叶码(输入数字后按 Enter 或离开输入框跳转)",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),pu=mt({nJuan:"{n}卷",viewWork:"查看作品",viewWorkOf:"查看作品:{title}",workArrow:"作品 →",arrowWork:"→作品",nWorks:"{n}部作品",unlinked:"未關聯",summary:"提要",comment:"按語",additionalComment:"附按",noMatch:"無匹配結果",sectionType:{类:"類",书:"書",序:"序",结语:"結語",注释:"註釋",考证:"考證",诗:"詩",小计:"小計"},countTiao:"{n} 條",countTiaoOf:"{m} / {n} 條",countPoems:"{n} 首",countPoemsOf:"{m} / {n} 首",countBooks:"{n} 部書",countBooksOf:"{m} / {n} 部書",kaozhenTarget:"考證對象 {target}",baseText:"底本 {note}",textQuality:"文本質量",qualityLabel:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"},qualityCriteria:{source:"照錄來源原文,本站未另行校對",ocr:"保持大意和結構,錯誤率在百分之十以內",rough:"保證文意基本正確,錯誤率在百分之三以內",fine:"通讀無障礙,錯誤率在百分之一以內",none:"質量未評定",placeholder:"占位條目,正文尚未錄入"},originalSource:"原文來源",viewsGroup:"看法",viewText:"正文",viewEntries:"條目",rowHeadNo:"序",rowHeadTitle:"書名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部書",linkedN:"已關聯 {n}",linkedOf:"已關聯 {n} / {total}",railEntriesNav:"本卷條目"},{nJuan:"{n}卷",viewWork:"查看作品",viewWorkOf:"查看作品:{title}",workArrow:"作品 →",arrowWork:"→作品",nWorks:"{n}部作品",unlinked:"未关联",summary:"提要",comment:"按语",additionalComment:"附按",noMatch:"无匹配结果",sectionType:{类:"类",书:"书",序:"序",结语:"结语",注释:"注释",考证:"考证",诗:"诗",小计:"小计"},countTiao:"{n} 条",countTiaoOf:"{m} / {n} 条",countPoems:"{n} 首",countPoemsOf:"{m} / {n} 首",countBooks:"{n} 部书",countBooksOf:"{m} / {n} 部书",kaozhenTarget:"考证对象 {target}",baseText:"底本 {note}",textQuality:"文本质量",qualityLabel:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暂无正文",placeholder:"占位"},qualityCriteria:{source:"照录来源原文,本站未另行校对",ocr:"保持大意和结构,错误率在百分之十以内",rough:"保证文意基本正确,错误率在百分之三以内",fine:"通读无障碍,错误率在百分之一以内",none:"质量未评定",placeholder:"占位条目,正文尚未录入"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),uu=mt({typeShort:{work:"作",book:"版",collection:"叢",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"叢編",entity:"人物"},typeAll:"全部",typeChipsLabel:"按類型檢索",recentTitle:"最近瀏覽",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"還沒有瀏覽記錄。打開任一條目後會出現在這裏。",status:{done:"已完成",in_progress:"進行中",todo:"計劃中"},siteStatus:{done:"已對接",in_progress:"進行中"},catalogTitle:"書目著錄進度",catalogNote:"每條著錄對到作品條目",colCatalog:"書目",colRecords:"著錄條目",colMatched:"已對上作品",colProgress:"進度",colStatus:"狀態",relatedTitle:"同類書目與考證",relatedNote:"不在書架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 種",allNKinds:"全部 {n} 種",pavilion:"閣",yearBC:"前{n}",missingLife:"生卒年未錄、未上軸:{names}",viewLineage:"看版本譜系 →",plannedSites:"計劃接入:{names}",loss:{extant:"存",partially_extant:"殘",lost:"佚",unknown:"未詳"},lossNote:{extant:"今有傳本",partially_extant:"部分存世",lost:"僅見著錄",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"叢編",entities:"人物",has_image:"有影印",has_text:"有文本",article:"單篇文",poem:"單篇詩"},dataScale:"數據規模",byLoss:"按存佚檢索",license:"古籍元數據以 CC0 公有領域發布,可自由複製、改編、再發布。",repo:"數據倉庫:",repoNote:"(GitHub,CC0)",version:"當前數據版本:",download:"引用方式與數據下載 →",navLabel:"元數據首頁分區",nav:{zhi:"歷代史志",sibu:"四部",cong:"叢編",people:"人物",lineage:"版本譜系",sites:"在線資源",data:"數據與授權"},zhiSub:"正史藝文志、經籍志與後人補志,按所志朝代排列;每部志的著錄逐條對到作品",shelfLegendCount:"脊下數字=著錄條目",shelfLegendClick:"點書脊進作品頁",sibuSub:"全部作品按經史子集分類;與「目錄」頁同一棵分類樹",toCatalog:"進入目錄 →",unclassifiedNote:"多為只見於史志著錄、尚未歸類的書",congSub:"大型叢書、影印彙編、出土文獻與館藏,逐種列到版本",allNKindsMore:"全部 {n} 種 →",peopleSub:"歷代目錄學家,按生卒年排在一條時間軸上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流與異同",sitesSub:"外部數字圖書館與本站條目的對接",dataSub:"規模、存佚、許可與版本"},{typeShort:{work:"作",book:"版",collection:"丛",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"丛编",entity:"人物"},typeAll:"全部",typeChipsLabel:"按类型检索",recentTitle:"最近浏览",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"还没有浏览记录。打开任一条目后会出现在这里。",status:{done:"已完成",in_progress:"进行中",todo:"计划中"},siteStatus:{done:"已对接",in_progress:"进行中"},catalogTitle:"书目著录进度",catalogNote:"每条著录对到作品条目",colCatalog:"书目",colRecords:"著录条目",colMatched:"已对上作品",colProgress:"进度",colStatus:"状态",relatedTitle:"同类书目与考证",relatedNote:"不在书架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 种",allNKinds:"全部 {n} 种",pavilion:"阁",yearBC:"前{n}",missingLife:"生卒年未录、未上轴:{names}",viewLineage:"看版本谱系 →",plannedSites:"计划接入:{names}",loss:{extant:"存",partially_extant:"残",lost:"佚",unknown:"未详"},lossNote:{extant:"今有传本",partially_extant:"部分存世",lost:"仅见著录",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"丛编",entities:"人物",has_image:"有影印",has_text:"有文本",article:"单篇文",poem:"单篇诗"},dataScale:"数据规模",byLoss:"按存佚检索",license:"古籍元数据以 CC0 公有领域发布,可自由复制、改编、再发布。",repo:"数据仓库:",repoNote:"(GitHub,CC0)",version:"当前数据版本:",download:"引用方式与数据下载 →",navLabel:"元数据首页分区",nav:{zhi:"历代史志",sibu:"四部",cong:"丛编",people:"人物",lineage:"版本谱系",sites:"在线资源",data:"数据与授权"},zhiSub:"正史艺文志、经籍志与后人补志,按所志朝代排列;每部志的著录逐条对到作品",shelfLegendCount:"脊下数字=著录条目",shelfLegendClick:"点书脊进作品页",sibuSub:"全部作品按经史子集分类;与「目录」页同一棵分类树",toCatalog:"进入目录 →",unclassifiedNote:"多为只见于史志著录、尚未归类的书",congSub:"大型丛书、影印汇编、出土文献与馆藏,逐种列到版本",allNKindsMore:"全部 {n} 种 →",peopleSub:"历代目录学家,按生卒年排在一条时间轴上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流与异同",sitesSub:"外部数字图书馆与本站条目的对接",dataSub:"规模、存佚、许可与版本"}),Jr=mt({readable:"部可讀",pieces:"篇單篇詩文",startReading:"開始閱讀 →",nCopies:"{n}本",shelfHint:"按所志朝代排列,一脊一部",shelfLegendCount:"脊下「2本」=站內有幾個本子",shelfOther:"其他",shelfRegion:"{label}書架,可橫向滾動",origZhi:"正史原志",laterZhi:"後人補撰、續補",spineBy:"{name} 撰",spineRecords:"著錄 {n} 條",spineOnSite:"站內 {n}",nWorks:"{n} 部",allNWorks:"全部 {n} 部",nCopiesCard:"{n} 個本子",workPageLink:"作品頁:{title}的源流與全部版本 →",sibuUnclassifiedNote:"書目分類還沒補齊,其中多數是單篇詩文,已單列在下方。",subClasses:"{label}子類",allNClasses:"{label}全部 {n} 類 →",unclassified:"未分類",viewUnclassified:"查看未分類 →",periodItem:"{label},{n} 部",periodUnknown:"另有 {n} 部作者無朝代,在「四部」和搜索裏能找到",hoverHint:"窄段懸停看全名",nPieces:"{n} 篇",authorAll:"{name}全部 {n} 篇 →",period:{xianqin:"先秦",qinhan:"秦漢",weijin:"魏晉南北朝",suitang:"隋唐五代",song:"宋",liaojinyuan:"遼金元",ming:"明",qing:"清",modern:"近現代"},navLabel:"閱讀首頁分區",nav:{picks:"推薦閱讀",topics:"專題",famous:"名著與版本",sibu:"四部",period:"按年代",pieces:"單篇詩文"},picksSub:"編輯挑選,定期輪換",topicsSub:"按作品類型歸組;小說見下方「名著與版本」",famousSub:"一部作品一張卡,卡上列出站內能讀的各個本子",sibuSub:"按古籍總目的分類樹,只計站內可讀的作品",periodSub:"按作者朝代歸段,寬度與部數成比例",piecesSub:"單篇的詩、文、賦、表,按作者歸組",piecesMore:"按作者瀏覽全部 →"},{readable:"部可读",pieces:"篇单篇诗文",startReading:"开始阅读 →",nCopies:"{n}本",shelfHint:"按所志朝代排列,一脊一部",shelfLegendCount:"脊下「2本」=站内有几个本子",shelfOther:"其他",shelfRegion:"{label}书架,可横向滚动",origZhi:"正史原志",laterZhi:"后人补撰、续补",spineBy:"{name} 撰",spineRecords:"著录 {n} 条",spineOnSite:"站内 {n}",nWorks:"{n} 部",allNWorks:"全部 {n} 部",nCopiesCard:"{n} 个本子",workPageLink:"作品页:{title}的源流与全部版本 →",sibuUnclassifiedNote:"书目分类还没补齐,其中多数是单篇诗文,已单列在下方。",subClasses:"{label}子类",allNClasses:"{label}全部 {n} 类 →",unclassified:"未分类",viewUnclassified:"查看未分类 →",periodItem:"{label},{n} 部",periodUnknown:"另有 {n} 部作者无朝代,在「四部」和搜索里能找到",hoverHint:"窄段悬停看全名",nPieces:"{n} 篇",authorAll:"{name}全部 {n} 篇 →",period:{xianqin:"先秦",qinhan:"秦汉",weijin:"魏晋南北朝",suitang:"隋唐五代",song:"宋",liaojinyuan:"辽金元",ming:"明",qing:"清",modern:"近现代"},navLabel:"阅读首页分区",nav:{picks:"推荐阅读",topics:"专题",famous:"名著与版本",sibu:"四部",period:"按年代",pieces:"单篇诗文"},picksSub:"编辑挑选,定期轮换",topicsSub:"按作品类型归组;小说见下方「名著与版本」",famousSub:"一部作品一张卡,卡上列出站内能读的各个本子",sibuSub:"按古籍总目的分类树,只计站内可读的作品",periodSub:"按作者朝代归段,宽度与部数成比例",piecesSub:"单篇的诗、文、赋、表,按作者归组",piecesMore:"按作者浏览全部 →"}),mu=mt({sideNav:"分類導航",classification:"分類",drawerLabel:"分類:{path}",all:"全部",allTitle:"全部典籍",stat:"共 {total} 種 · 每頁 {size} 條",statPage:" · 第 {page} / {pages} 頁",viewLabel:"呈現方式",viewCard:"卡片",viewList:"列表",juanN:"{n}卷",pagerLabel:"分頁",prevPage:"上一頁",nextPage:"下一頁",pageN:"第 {n} 頁",emptyWorks:"此類暫無作品",zhulu:"著錄",cunmu:"存目",categoriesN:"{n} 類",divisionStat:"{cats} 類 · {books} 部",categoryJuan:"卷{n}",booksN:"{n} 部",expandAllN:"展開全部 {n} 條"},{sideNav:"分类导航",classification:"分类",drawerLabel:"分类:{path}",all:"全部",allTitle:"全部典籍",stat:"共 {total} 种 · 每页 {size} 条",statPage:" · 第 {page} / {pages} 页",viewLabel:"呈现方式",viewCard:"卡片",viewList:"列表",juanN:"{n}卷",pagerLabel:"分页",prevPage:"上一页",nextPage:"下一页",pageN:"第 {n} 页",emptyWorks:"此类暂无作品",zhulu:"著录",cunmu:"存目",categoriesN:"{n} 类",divisionStat:"{cats} 类 · {books} 部",categoryJuan:"卷{n}",booksN:"{n} 部",expandAllN:"展开全部 {n} 条"}),hu=mt({loss:{all:"全部",extant:"存",partially_extant:"殘",lost:"佚"},unclassified:"未分類",statBook:"書",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"詩詞",statPoemUnit:"首",statCollection:"叢編",submit:"搜索"},{loss:{all:"全部",extant:"存",partially_extant:"残",lost:"佚"},unclassified:"未分类",statBook:"书",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"诗词",statPoemUnit:"首",statCollection:"丛编",submit:"搜索"}),gu=mt({title:"反饋",close:"關閉",submitType:{bug:"反饋錯誤",resource:"添加資源",suggestion:"功能建議",contact:"想參與"},placeholder:{bug:"請描述您發現的錯誤,包括頁面位置和具體內容",resource:"請提供完整資源鏈接和簡要版本說明",suggestion:"您希望網站增加或改進什麼?",contact:"想參與整理、校對或合作?簡單介紹一下您自己,並留下聯繫方式(此類留言不公開)"},chooseTypeFirst:"請先選擇反饋類型",contactPlaceholder:"郵箱(選填,僅站方可見,方便我們回覆您)",contactLabel:"聯繫方式(選填)",submitFailedRetry:"提交失敗,請稍後重試",submitFailed:"提交失敗",thanks:"感謝您的反饋!",viewList:"查看反饋列表 →",continueSubmit:"繼續提交",submitting:"提交中...",submit:"提交",submitFeedback:"提交反饋",listType:{bug:"錯誤反饋",resource:"資源建議",suggestion:"功能建議",other:"其他"},status:{pending:"待處理",in_progress:"處理中",resolved:"已處理",wontfix:"不採納",duplicate:"重複"},empty:"暫無反饋",reply:"回覆"},{title:"反馈",close:"关闭",submitType:{bug:"反馈错误",resource:"添加资源",suggestion:"功能建议",contact:"想参与"},placeholder:{bug:"请描述您发现的错误,包括页面位置和具体内容",resource:"请提供完整资源链接和简要版本说明",suggestion:"您希望网站增加或改进什么?",contact:"想参与整理、校对或合作?简单介绍一下您自己,并留下联系方式(此类留言不公开)"},chooseTypeFirst:"请先选择反馈类型",contactPlaceholder:"邮箱(选填,仅站方可见,方便我们回复您)",contactLabel:"联系方式(选填)",submitFailedRetry:"提交失败,请稍后重试",submitFailed:"提交失败",thanks:"感谢您的反馈!",viewList:"查看反馈列表 →",continueSubmit:"继续提交",submitting:"提交中...",submit:"提交",submitFeedback:"提交反馈",listType:{bug:"错误反馈",resource:"资源建议",suggestion:"功能建议",other:"其他"},status:{pending:"待处理",in_progress:"处理中",resolved:"已处理",wontfix:"不采纳",duplicate:"重复"},empty:"暂无反馈",reply:"回复"}),fu=mt({empty:"暫無版本傳承數據",emptyGraph:"暫無版本圖數據",modeList:"列表",modeGraph:"關係圖",collectionLabel:"集合:",collectionAll:"全部",collectionAllDesc:"顯示該作品所有版本(含橋接節點)",graphLoading:"加載圖組件中…",graphMissing:"圖組件未安裝。請安裝 {xyflow} 與 {dagre}。",graphMissingHint:"或使用 {list} 列表視圖。",bridgeTitle:"橋接節點:本身不在核心集,為保持派生鏈完整而顯示",otherGroup:"其他",lost:"已佚",fragment:"殘本",hypothetical:"假想祖本",bridge:"橋接",extant:"現存:{juan}",sources:"來源:",related:"關聯:",confidence:{certain:"確定",consensus:"共識",probable:"推測",disputed:"有爭議"}},{empty:"暂无版本传承数据",emptyGraph:"暂无版本图数据",modeList:"列表",modeGraph:"关系图",collectionLabel:"集合:",collectionAll:"全部",collectionAllDesc:"显示该作品所有版本(含桥接节点)",graphLoading:"加载图组件中…",graphMissing:"图组件未安装。请安装 {xyflow} 与 {dagre}。",graphMissingHint:"或使用 {list} 列表视图。",bridgeTitle:"桥接节点:本身不在核心集,为保持派生链完整而显示",otherGroup:"其他",lost:"已佚",fragment:"残本",hypothetical:"假想祖本",bridge:"桥接",extant:"现存:{juan}",sources:"来源:",related:"关联:",confidence:{certain:"确定",consensus:"共识",probable:"推测",disputed:"有争议"}}),xu={common:ou,detail:_i,bookPage:su,workPage:au,collectionPage:lu,entityPage:cu,reader:du,collated:pu,metaHome:uu,readHome:Jr,catalogPage:mu,searchPage:hu,feedback:gu,lineage:fu};function bu(e){const n={};for(const[i,o]of Object.entries(xu))n[i]=o[e];return n}function xt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const ys=new Map;function jn(e){let n=ys.get(e);return n||(n={...e==="zh-Hans"?ru:iu,...bu(e)},ys.set(e,n)),n}function js(e,n){let i=e;for(const o of n.split(".")){if(i==null||typeof i!="object")return;i=i[o]}return typeof i=="string"?i:void 0}function ll(e){return(n,i)=>{const o=js(e,n)??js(jn("zh-Hant"),n)??n;return i?xt(o,i):o}}const vs=new Map;function vn(e){let n=vs.get(e);return n||(n=ll(jn(e)),vs.set(e,n)),n}const cl="bim-locale";function yu(){try{const e=localStorage.getItem(cl);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function ju(e){try{localStorage.setItem(cl,e)}catch{}}const vu="zh-Hans",ku=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=g.useState(e??vu),l=e??s;g.useEffect(()=>{if(e)return;const h=yu();h&&h!==s&&a(h)},[]);const d=g.useMemo(()=>l==="zh-Hans"?i??al():null,[l,i]),c=g.useCallback(h=>{a(h),ju(h),n==null||n(h)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:jn(l),converter:d}),[l,c,d]);return t.jsx(Nt.Provider,{value:p,children:o})};function Ee(){const e=g.useContext(Nt);return(e==null?void 0:e.messages)??jn("zh-Hant")}const wu=2e3;function Oe(){const e=g.useContext(Nt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=g.useRef(new Map),s=g.useRef(n),a=g.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=g.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=wu){const h=o.current.keys().next().value;h!==void 0&&o.current.delete(h)}return o.current.set(d,p),p},[i]);return g.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function ne(){const e=g.useContext(Nt),{convert:n,locale:i,isSimplified:o}=Oe(),s=(e==null?void 0:e.messages)??jn("zh-Hant"),a=g.useMemo(()=>e?ll(s):vn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const dl=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Su=new Set([...dl,...Object.keys(ke.VARIANT_CHARS),...Object.keys(Qa.VARIANT_SUPPLEMENT)]),pl=[...sl,"切換為繁體","漢籍リポジトリ"];function _u(e,n=pl){let i=e;for(const a of n)a&&(i=i.split(a).join(" "));const o=[],s=Array.from(i);return s.forEach((a,l)=>{Su.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function $u(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??al():e==="hant"?ke.normalizeVariants:i:n==="zh-Hans"?i:ke.normalizeVariants}const Cu=({mode:e,children:n})=>{const i=g.useContext(Nt),o=g.useMemo(()=>i&&{...i,converter:$u(e,i.locale,i.converter)},[i,e]);return t.jsx(Nt.Provider,{value:o,children:n})};function Tu(e){if(!e)return"";try{const n=new URL(e).hostname,i={"zh.wikisource.org":"wikisource","www.shidianguji.com":"shidianguji","shidianguji.com":"shidianguji","archive.org":"archive","ctext.org":"ctext","read.nlc.cn":"nlc","www.digital.archives.go.jp":"japan_archives"};if(i[n])return i[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function ks(e){return e==="text+image"?["text","image"]:[e]}function ws(e){const n=Bt(e);return n.length===0?"text":eu(n)}function zu(){return{id:"",name:"",url:"",types:["text"],details:""}}const kr=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Ee(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],h=w=>{if(!s)return!0;const j=Bt(w);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},u=e.map((w,j)=>({item:w,originalIndex:j})).filter(({item:w})=>h(w)),m=()=>{const w=zu();s&&(w.types=ks(s)),n([...e,w]),d(e.length)},f=w=>{n(e.filter((j,k)=>k!==w)),d(null)},x=(w,j,k)=>{const C=[...e];if(C[w]={...C[w],[j]:k},j==="url"&&!C[w].id){const S=Tu(k);S&&(C[w].id=S)}n(C)},v=(w,j)=>{const k=[...e],{type:C,...S}=k[w];k[w]={...S,types:ks(j)},n(k)},y=(w,j,k)=>{const S={...e[w].metadata||{}};k?S[j]=k:delete S[j],x(w,"metadata",Object.keys(S).length>0?S:void 0)},$=(w,j)=>{const k=j.trim()?j.split(/[,,、]/).map(C=>C.trim()).filter(Boolean):void 0;x(w,"structure",k)},b=(w,j,k)=>{const S=e[w].coverage||{level:1,ranges:""};j==="level"?S.level=parseInt(k)||1:S.ranges=k,x(w,"coverage",S.ranges?S:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[u.map(({item:w,originalIndex:j})=>{var k,C,S;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===j?null:j),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===j?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Nu(ws(w)),color:r("on-color-fg")},children:(()=>{var L,z;const _=Bt(w);return _.length===0?"text":_.length===1?((L=c.find(T=>T.value===_[0]))==null?void 0:L.label)??_[0]:_.includes("text")&&_.includes("image")?((z=c.find(T=>T.value==="text+image"))==null?void 0:z.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:w.name||`${a.editor.resourcePlaceholder} ${j+1}`}),w.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:w.id}),w.url&&t.jsx("a",{href:w.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&w.url&&Iu(j,o==null?void 0:o[j],i,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(j)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===j&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[Zp(w,"image")&&w.url&&Eu(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.type}),t.jsx("select",{value:ws(w),onChange:_=>v(j,_.target.value),style:{...$t,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{...$t,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:w.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...$t,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{...$t,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:$t}),t.jsx("input",{type:"text",value:((k=w.structure)==null?void 0:k.join("、"))||"",onChange:_=>$(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:$t}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:$n,children:[t.jsx("span",{style:Cn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((C=w.coverage)==null?void 0:C.level)??"",onChange:_=>b(j,"level",_.target.value),placeholder:"1",style:{...$t,width:"60px"}})]}),t.jsxs("label",{style:{...$n,flex:1},children:[t.jsx("span",{style:Cn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((S=w.coverage)==null?void 0:S.ranges)||"",onChange:_=>b(j,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...$t,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...$t,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${r("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"6px"},children:a.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(a.metadata).map(([_,L])=>{var z;return t.jsxs("label",{style:{...$n,gap:"4px"},children:[t.jsx("span",{style:{...Cn,minWidth:"56px"},children:L}),t.jsx("input",{type:"text",value:((z=w.metadata)==null?void 0:z[_])||"",onChange:T=>y(j,_,T.target.value),placeholder:L,style:{...$t,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function Nu(e){switch(e){case"text":return r("restype-text");case"image":return r("restype-image");case"text+image":return r("restype-text-image");case"physical":return r("restype-physical")}}function Iu(e,n,i,o){const s=(n==null?void 0:n.status)==="downloading",a=(n==null?void 0:n.status)==="completed";return t.jsx("button",{onClick:l=>{l.stopPropagation(),s||i(e,"")},disabled:s,style:{background:"transparent",border:"none",color:r(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?o.download.completed:s?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function Eu(e,n){const i=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.url)||e.url.includes("iiif")||e.url.includes("image");return t.jsx("div",{style:{marginBottom:"12px"},children:i?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:r("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:r("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:r("desc-fg")},children:n.editor.imageResourceLink})})}const $t={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},$n={display:"flex",alignItems:"center",gap:"6px"},Cn={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},Ss={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function Ru(e){return e.includes("text")&&e.includes("image")?Ss["text+image"]:Ss[e[0]||"physical"]}const Qr=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ee(),{convert:l}=Oe(),d=g.useMemo(()=>Kr(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,$=[];for(const b of d){const w=b.group;w?(y.has(w)||y.set(w,[]),y.get(w).push(b)):$.push(b)}for(const b of y.values())b.sort((w,j)=>{const k=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return k(w)-k(j)});return{mirrorGroups:y,ungroupedItems:$}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},u=y=>h[y]?h[y]:y.split("+").map($=>h[$]||$).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,$)=>t.jsx(ir,{item:y},y.id||$))});const m=(y,$)=>{const b=i==null?void 0:i[y],w=(b==null?void 0:b.label)||y,j=b==null?void 0:b.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(w)}),j&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.5},children:l(j)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((k,C)=>t.jsx(ir,{item:k,onNavigate:o,renderLink:s},k.id||C))})]},`group-${y}`)},f=new Map;for(const y of p){const $=qr(Bt(y));f.has($)||f.set($,[]),f.get($).push(y)}const x=["text","image","text+image","physical"],v=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,$])=>m(y,$)),v.map(y=>{const $=f.get(y),b=Ru(y.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:u(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((w,j)=>t.jsx(ir,{item:w,onNavigate:o,renderLink:s},w.id||j))})]},y)})]})},Lu={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},ir=({item:e})=>{const n=Ee(),{convert:i}=Oe(),[o,s]=g.useState(!1),a=g.useMemo(()=>(e.url?bn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||rl(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,h=e.expected_volumes??(d?c+p:0),u=e.color_mode?{...Lu[e.color_mode],label:n.colorMode[e.color_mode]}:null,m=e.details&&!d?i(e.details):null,f={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",background:r("input-bg"),fontSize:"12px",color:r("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),u&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:u.bg,color:u.fg},children:u.label}),m&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:m}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",h,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:xt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Xr(e.metadata);return x?Zr(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:r("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),d&&o&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const v=x.status==="missing";return x.url&&!v?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${r("widget-border")}`,color:r("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:r(v?"missing-fg":"desc-fg"),textDecoration:v?"line-through":"none",opacity:v?.6:1},children:x.volume},x.volume)})})]})},ul=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ee(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,h=(n==null?void 0:n.repoPath)||"",u=h?h.split(/[/\\]/).pop()||h:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},f={onMouseOver:v=>v.currentTarget.style.opacity="0.8",onMouseOut:v=>v.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...m,background:r(p?"warning":"success"),color:r("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:m,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:u||d.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:m,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:h||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),u&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]}),!c&&u&&t.jsxs("div",{style:{...m,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:h,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:u})]})]})},$i="bim-search-history",_s=10,$s=8;function Ln(){try{const e=localStorage.getItem($i);return e?JSON.parse(e):[]}catch{return[]}}function ml(e){try{const n=Ln().filter(i=>i!==e);n.unshift(e),n.length>_s&&(n.length=_s),localStorage.setItem($i,JSON.stringify(n))}catch{}}function Au(e){try{const n=Ln().filter(i=>i!==e);localStorage.setItem($i,JSON.stringify(n))}catch{}}function Mu(){try{localStorage.removeItem($i)}catch{}}const hl=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Ee(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,h]=g.useState(!1),[u,m]=g.useState([]),[f,x]=g.useState(-1),[v,y]=g.useState(Ln),$=g.useRef(null),b=g.useRef(null),w=g.useRef(null),j=g.useRef(!1);g.useEffect(()=>{x(-1);const T=n.trim();if(!T){m(v.map(N=>({type:"history",text:N})));return}if(!e.searchAll){m([]);return}let B=!1;const W=setTimeout(()=>{e.searchAll(T,$s).then(N=>{if(B)return;const R=[...N.works,...N.books,...N.collections,...N.entities??[]];m(R.slice(0,$s).map(H=>({type:"entry",text:H.title||H.id,entry:H})))}).catch(()=>{B||m([])})},80);return()=>{B=!0,clearTimeout(W)}},[n,v,e]),g.useEffect(()=>{const T=B=>{w.current&&!w.current.contains(B.target)&&h(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),g.useEffect(()=>{const T=B=>{var W,N;if(B.key==="/"&&document.activeElement!==$.current){const R=(W=document.activeElement)==null?void 0:W.tagName;if(R==="INPUT"||R==="TEXTAREA"||R==="SELECT")return;B.preventDefault(),(N=$.current)==null||N.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const k=g.useCallback(T=>{T.trim()&&(ml(T.trim()),y(Ln())),o(T),h(!1)},[o]),C=g.useCallback(T=>{T.type==="history"?(i(T.text),k(T.text)):T.entry&&(s?(s(T.entry),h(!1)):(i(T.text),k(T.text)))},[i,k,s]),S=g.useCallback(T=>{if(!p||u.length===0){T.key==="Enter"&&k(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(B=>(B+1)%u.length);break;case"ArrowUp":T.preventDefault(),x(B=>(B-1+u.length)%u.length);break;case"Enter":T.preventDefault(),f>=0&&f<u.length?C(u[f]):k(n);break;case"Escape":T.preventDefault(),h(!1);break}},[p,u,f,n,k,C]),_=g.useCallback((T,B)=>{B.stopPropagation(),Au(T),y(Ln()),m(W=>W.filter(N=>!(N.type==="history"&&N.text===T)))},[]),L=g.useCallback(T=>{T.stopPropagation(),Mu(),y([]),m([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const T=b.current.children;T[f]&&T[f].scrollIntoView({block:"nearest"})}},[f]);const z=!n.trim()&&v.length>0;return t.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:$,type:"text",placeholder:d,value:n,onChange:T=>{i(T.target.value),h(!0)},onCompositionStart:()=>{j.current=!0},onCompositionEnd:()=>{j.current=!1},onFocus:()=>{h(!0)},onKeyDown:S,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&u.length>0&&t.jsxs("div",{ref:b,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:r("input-bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"6px",boxShadow:r("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[z&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:r("desc-fg"),borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:L,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),u.map((T,B)=>t.jsxs("div",{onClick:()=>C(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:B===f?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:T.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.text}),T.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[T.entry.type],T.entry.edition&&` · ${T.entry.edition}`,T.entry.author&&` · ${T.entry.author}`]}),T.type==="history"&&t.jsx("button",{onClick:W=>_(T.text,W),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${T.type}-${T.text}-${B}`))]})]})},kn=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:r(`type-${e}`),verticalAlign:"middle"}}),Ci={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},gl=new Set(["work","book","entity"]);function Pu(e){return bl(e)||!!e.sort}function Bu(e,n){return n.sort&&gl.has(e)?n.sort:void 0}const Ti=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],zi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],fl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],xl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Ni(e){return e.dynasty.length+e.classification.length+(e.hasImage?1:0)+(e.hasText?1:0)+(e.hasCollated?1:0)+(e.loss?1:0)}function bl(e){return Ni(e)>0}function Ou(e){const n=[];return e.dynasty.length&&n.push("dynasty"),e.classification.length&&n.push("classification"),e.hasImage&&n.push("hasImage"),e.hasText&&n.push("hasText"),e.hasCollated&&n.push("hasCollated"),e.loss&&n.push("loss"),n}function yl(e,n){const i=xl[e];return Ou(n).every(o=>i.has(o))}const Tn=e=>JSON.stringify(e);function Wu(e,n){if(!yl(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=Ti.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${Tn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(Tn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${Tn(e.classification[0])}`:`classification IN [${e.classification.map(Tn).join(", ")}]`),e.hasImage&&i.push("has_image = true"),e.hasText&&i.push("has_text = true"),e.hasCollated&&i.push("has_collated = true"),e.loss&&i.push(`loss_status = ${Tn(e.loss)}`),i.join(" AND ")}const ct={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},jl="_";function xi(e,n=new URLSearchParams){for(const i of Object.values(ct))n.delete(i);return e.dynasty.length&&n.set(ct.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(ct.classification,e.classification.map(i=>i||jl).join(",")),e.hasImage&&n.set(ct.hasImage,"1"),e.hasText&&n.set(ct.hasText,"1"),e.hasCollated&&n.set(ct.hasCollated,"1"),e.loss&&n.set(ct.loss,e.loss),e.sort&&n.set(ct.sort,e.sort),n}function Fu(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(Ti.map(a=>a.key)),o=new Set(zi.map(a=>a.value)),s=e.get(ct.loss);return{dynasty:Array.from(new Set(n(ct.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(ct.classification).map(a=>a===jl?"":a).filter(a=>o.has(a)))),hasImage:e.get(ct.hasImage)==="1",hasText:e.get(ct.hasText)==="1"||e.get(ct.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(a=>a===e.get(ct.sort))??""}}function Hu(e,n){return JSON.stringify([e.dynasty.slice().sort(),e.classification.slice().sort(),e.hasImage,e.hasText,e.hasCollated,e.loss,e.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Cs(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Du=({filters:e,onChange:n})=>{const i=Ee(),o=i.searchV4,{convert:s}=Oe(),[a,l]=g.useState(!1),d=g.useId(),c=Ni(e),p=h=>n({...e,...h});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(o.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(h=>!h),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(xt(o.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?o.collapse:o.expand)," ",a?"▴":"▾"]})]}),t.jsxs("div",{className:"bim-sr-filters",id:d,"data-open":a?"true":"false",...a?{}:{"data-collapsed":"true"},children:[t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:Ti.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:Cs(e.dynasty,h.key)}),children:s(h.key)},h.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),zi.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:Cs(e.classification,h.value)})}),h.value?s(h.label):i.searchPage.unclassified]},h.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:h=>p({hasImage:h.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:h=>p({hasText:h.target.checked})}),s(o.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(o.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:fl.map(h=>t.jsx("button",{type:"button","aria-pressed":e.loss===h.value,onClick:()=>p({loss:h.value}),children:i.searchPage.loss[h.value||"all"]},h.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Ci,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function vl({text:e,query:n}){const i=(n??"").trim();if(!i||!e)return t.jsx(t.Fragment,{children:e});const o=e.toLowerCase(),s=i.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=o.indexOf(s,l);if(c<0){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{className:"bim-sr-hl",children:e.slice(c,c+s.length)},d++)),l=c+s.length}return t.jsx(t.Fragment,{children:a})}const Ts=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ee(),a=s.searchV4,{convert:l}=Oe(),d=it();return t.jsx("div",{className:"bim-sr-tablewrap",children:t.jsxs("table",{className:"bim-sr-table",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"34%"}}),t.jsx("col",{style:{width:"8%"}}),t.jsx("col",{style:{width:"19%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"14%"}})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:l(a.colTitle)}),t.jsx("th",{scope:"col",children:l(a.colType)}),t.jsx("th",{scope:"col",children:l(a.colAuthor)}),t.jsx("th",{scope:"col",children:l(a.colEra)}),t.jsx("th",{scope:"col",children:l(a.colClass)}),t.jsx("th",{scope:"col",style:{textAlign:"right"},children:l(a.colResource)})]})}),t.jsx("tbody",{children:e.map(c=>{const p=l(c.title||c.primary_name||c.id),h=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",u=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,f=m?l(m):"",x=c.classification?l(c.classification):"",v=[];c.has_image&&v.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&v.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&v.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[u,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:$=>i(c,$),children:t.jsx(vl,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sr-measure",children:h})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(kn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:u||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:v.map($=>t.jsx("span",{className:`bim-sr-tag ${$.cls}`,children:l($.label)},$.label))})]},c.id)})})]})})},Uu=`
|
|
2
2
|
.bim-sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 10px; }
|
|
3
3
|
.bim-sc { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 12px; border: 1px solid ${r("rule")}; background: ${r("card-bg")}; color: inherit; text-decoration: none; }
|
|
4
4
|
.bim-sc:hover { border-color: ${r("rule-dashed")}; box-shadow: ${r("fr-shadow")}; }
|
|
@@ -1340,7 +1340,7 @@ a.bim-et:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 2px;
|
|
|
1340
1340
|
.bim-et-card { animation: bim-et-in 120ms ease-out; }
|
|
1341
1341
|
@keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
|
|
1342
1342
|
}
|
|
1343
|
-
`,jf=120;function gt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function vf(e,n=jf){if(!e)return;const i=e.replace(/\s+/g," ").trim(),o=Array.from(i);return o.length>n?o.slice(0,n).join("")+"…":i}function kf(e){const n=e.dates&&typeof e.dates=="object"?e.dates:{},i=typeof n.birth=="number"?n.birth:void 0,o=typeof n.death=="number"?n.death:void 0;if(!(i===void 0&&o===void 0))return`${i??"?"}–${o??"?"}`}function wf(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=gt(o.name);return s?[gt(o.dynasty)&&`〔${gt(o.dynasty)}〕`,s,gt(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Uc(e,n){const i=gt(n.type),o=gt(n.primary_name)??gt(n.title)??e,s=i==="entity"?[gt(n.dynasty),kf(n),gt(n.native_place)].filter(Boolean).join(" · "):[wf(n),gt(n.edition),gt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?gt(n.description.text):gt(n.description);return{id:e,type:i,title:o,meta:s||void 0,description:vf(a)}}function Vc(e){const n=[e.dynasty,e.author,e.edition].filter(Boolean).join(" · ");return{id:e.id,type:e.type,title:e.title,meta:n||void 0}}function Gc(e){return async n=>{const i=await e.getItem(n);if(i)return Uc(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return Vc(o)}return null}}const ca=new WeakMap;function Sf(e,n,i){let o=ca.get(e);o||(o=new Map,ca.set(e,o));const s=o.get(i);if(s)return s;const a=n(i);return o.set(i,a),a.catch(()=>o.delete(i)),a}const Yc=e=>`/item/${encodeURIComponent(e)}`,da={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},_f=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Ao(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:Gc(e)}:null,[n,e])}const $f=e=>e,Cf=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=Yc,onNavigate:d,renderText:c=$f,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:u=!0,className:m})=>{const f=g.useMemo(()=>{const v=i==="plain"?Oc(e,n,o):n;return Wc(e,v)},[e,n,i,o]),x=Ao(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:Lo}),f.map(v=>v.type==="text"?t.jsx(g.Fragment,{children:c(v.text)},`t${v.start}`):t.jsx(Mo,{span:v.span,label:v.text,hasBrackets:e[v.start-1]==="《"&&e[v.start+v.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:h},`${v.span.key}@${v.start}`))]})};let Ut=null;const Mo=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,renderText:d,hoverDelayMs:c,closeDelayMs:p=280})=>{const h=g.useId(),[u,m]=g.useState(!1),[f,x]=g.useState(!1),v=g.useRef(null),y=g.useRef(null),$=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,b=e.kind==="work"&&!i,w=t.jsxs(t.Fragment,{children:[b&&t.jsx("span",{className:"bim-et-sr",children:"《"}),d(n),b&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),j=()=>{v.current&&(clearTimeout(v.current),v.current=null)},k=()=>{y.current&&(clearTimeout(y.current),y.current=null)},C=g.useCallback(()=>{j(),k(),m(!1),x(!1),Ut===C&&(Ut=null)},[]);g.useEffect(()=>()=>{j(),k(),Ut===C&&(Ut=null)},[C]);const S=g.useCallback(()=>{Ut&&Ut!==C&&Ut(),Ut=C,m(!0)},[C]),_=g.useCallback(W=>{k(),x(!0),!u&&(j(),W<=0?S():v.current=setTimeout(S,W))},[u,S]),L=g.useCallback(()=>{j(),k(),y.current=setTimeout(C,p)},[C,p]),z=!!e.targetId,T=e.targetId,B={className:"bim-et-w","data-active":f?"":void 0,onMouseEnter:()=>_(c),onMouseLeave:L,onBlur:W=>{W.currentTarget.contains(W.relatedTarget)||C()},onKeyDown:W=>{W.key==="Escape"&&u&&(W.stopPropagation(),C())}};return!z||!T?t.jsxs("span",{...B,children:[t.jsx("span",{className:$,children:w}),u&&t.jsx(pa,{id:h,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...B,children:[t.jsx("a",{className:$,href:a(T),"data-entity-id":T,"aria-describedby":u?h:void 0,onFocus:()=>_(0),onClick:l?W=>l(T,W):void 0,children:w}),u&&t.jsx(pa,{id:h,entityId:T,span:e,loader:s,buildHref:a,onNavigate:l})]})},pa=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a})=>{const{convert:l,t:d}=ne(),c=g.useRef(null),[p,h]=g.useState("start"),[u,m]=g.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!o||!n)return;let v=!1;return m({status:"loading"}),Sf(o.owner,o.load,n).then(y=>{v||m({status:"ready",summary:y})}).catch(()=>{v||m({status:"error"})}),()=>{v=!0}},[o,n]),_f(()=>{const v=c.current;if(!v||typeof window>"u")return;const y=v.getBoundingClientRect(),$=document.documentElement.clientWidth||window.innerWidth;y.right>$-8&&p==="start"&&h("end")},[u,p]);const f=u.status==="ready"?u.summary:null,x=(f==null?void 0:f.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:[t.jsx("span",{className:"bim-et-card-k",children:l(da[i.kind])}),x&&t.jsx("span",{className:"bim-et-card-t",children:l(x)}),(f==null?void 0:f.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(f.meta)}),(f==null?void 0:f.description)&&t.jsx("span",{className:"bim-et-card-d",children:l(f.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),f&&t.jsx("a",{className:"bim-et-card-a",href:s(n),onClick:a?v=>a(n,v):void 0,children:d("reader.entityDetail")})]}):t.jsx("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:t.jsx("span",{className:"bim-et-card-k",children:l(da[i.kind])})})},Tf=e=>`/item/${encodeURIComponent(e)}`;function zf(e){const n=e.filter(i=>i.kind!=="break");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function Nf(e,n){const i=[];for(const o of e){const s=n.get(o.charData.id)??null,a=i[i.length-1];a&&a.entity===s?a.chars.push(o):i.push({entity:s,chars:[o]})}return i}const Po=({pageData:e,pages:n,punctuations:i=Ef,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:u,scrollToPage:m,entities:f,entityTransport:x,loadEntitySummary:v,buildEntityHref:y,onEntityNavigate:$,pageBreaks:b=!0,pageIndicatorY:w,onPageIndicatorYChange:j,quoteStyle:k,bookTitleStyle:C,showWorks:S})=>{const _=g.useRef(null),L=g.useRef(0),z=g.useMemo(()=>{const ee=new Map;return p&&i.forEach((F,U)=>{const he=F.id?F:{...F,id:`${F.anchor}#${U}`},X=ee.get(he.anchor)||[];X.push(he),ee.set(he.anchor,X)}),ee},[i,p]),T=g.useMemo(()=>k===void 0&&C===void 0&&S===void 0?null:{quoteStyle:k??"original",hideBookBrackets:C==="wavy"||S===!1},[k,C,S]),B=C==="bracket",W=g.useMemo(()=>{var he;const ee=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],F=ee.filter(X=>X.columns.some(O=>O.chars.length>0)).map(X=>{const O=[...X.columns].sort((se,_e)=>se.col-_e.col),J=[];let oe=[],re=0;for(const se of O){if(se.chars.length===0){se.kind==="blank"&&re++;continue}const _e=se.raised||se.lead_blank||re?{raised:se.raised,leadBlank:se.lead_blank,blankBefore:re}:void 0;re=0;let Ae=!0;for(const M of se.chars){const{before:ie,after:ve}=zf(z.get(M.id)||[]),we=(z.get(M.id)||[]).some(P=>P.kind==="break");oe.push({charData:M,col:se.col,beforePuncts:ie,afterPuncts:ve,...Ae&&_e?{start:_e}:{}}),Ae=!1,we&&(J.push({id:`para-p${X.page}-${J.length}`,chars:oe}),oe=[])}}const D=oe.length>0;return D&&J.push({id:`para-p${X.page}-${J.length}`,chars:oe}),{page:X.page,paragraphs:J,endsOpen:D,...X.label?{label:X.label}:{},...re>0?{trailingBlank:re}:{}}}),U=new Map;if(!b){const X=new Map;for(const re of ee)for(const D of re.columns)D.chars.length>0&&X.set(D.lead_blank||0,(X.get(D.lead_blank||0)||0)+1);let O=0,J=-1;for(const[re,D]of X)(D>J||D===J&&re<O)&&(O=re,J=D);let oe=null;for(const re of F){const D=re.paragraphs[0],se=(he=D==null?void 0:D.chars[0])==null?void 0:he.start,_e=!!se&&!!(se.raised||(se.leadBlank||0)>O||se.blankBefore),Ae=re.paragraphs.length===1&&!!re.trailingBlank;if(oe&&D&&!_e&&!Ae){for(const M of D.chars)U.set(M.charData.id,oe.owner);oe.para.chars=oe.para.chars.concat(D.chars),re.leadFirstId=D.chars[0].charData.id,re.paragraphs=re.paragraphs.slice(1)}if(re.endsOpen&&!re.trailingBlank){const M=re.paragraphs[re.paragraphs.length-1];M&&(oe={para:M,owner:re.page})}else oe=null}}return{pages:F,mergedOwner:U}},[n,e,z,b]),N=W.pages,R=g.useMemo(()=>{const ee=[];for(const F of N)for(const U of F.paragraphs)for(const he of U.chars)ee.push(he.charData.id);return ee},[N]),H=g.useMemo(()=>{const ee=new Map;if(!f||f.length===0)return ee;const F=new Map(R.map((U,he)=>[U,he]));for(const U of f){if(!U.anchor)continue;const he=F.get(U.anchor.start),X=F.get(U.anchor.end);if(!(he===void 0||X===void 0||X<he))for(let O=he;O<=X;O++)ee.has(R[O])||ee.set(R[O],U)}return ee},[f,R]),q=Ao(x,v),te=H.size>0,ae=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:$});ae.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:$};const V=g.useMemo(()=>({click:ee=>{var F,U;L.current=Date.now()+1200,(U=(F=ae.current).onCharClick)==null||U.call(F,ee)},enter:ee=>{var F,U;return(U=(F=ae.current).onCharHover)==null?void 0:U.call(F,ee)},leave:()=>{var ee,F;return(F=(ee=ae.current).onCharHover)==null?void 0:F.call(ee,null)},navigate:(ee,F)=>{var he,X;if(!(F.detail===0||F.ctrlKey||F.metaKey||F.shiftKey)){F.preventDefault();return}(X=(he=ae.current).onEntityNavigate)==null||X.call(he,ee,F)}}),[]),G=Rf(o,W.mergedOwner),me=g.useRef(null);g.useEffect(()=>{var F,U;if((F=me.current)==null||F.classList.remove("is-hovered"),me.current=null,!s)return;const ee=(U=_.current)==null?void 0:U.querySelector(`span[data-char-id="${s}"]`);ee&&(ee.classList.add("is-hovered"),me.current=ee)},[s]),g.useEffect(()=>{let ee=null;const F=()=>{var ve,we;ee=null;const he=window.getSelection(),X=_.current;if(!he||he.isCollapsed||he.rangeCount===0||!X)return;const O=he.getRangeAt(0),J=O.commonAncestorContainer,oe=J.nodeType===3?J.parentElement:J;if(!oe||!X.contains(oe))return;const re=X.querySelectorAll("span[data-char-id]"),D=P=>P.firstChild??P;let se=0,_e=re.length;for(;se<_e;){const P=se+_e>>1;O.comparePoint(D(re[P]),0)<0?se=P+1:_e=P}const Ae=se;for(_e=re.length;se<_e;){const P=se+_e>>1;O.comparePoint(D(re[P]),0)<=0?se=P+1:_e=P}let M=se-1;if(M>=Ae&&O.endOffset===0&&O.endContainer===D(re[M])&&M--,M<Ae)return;const ie=[];for(let P=Ae;P<=M;P++)ie.push(re[P].getAttribute("data-char-id"));ie.length>0&&(L.current=Date.now()+1200,(we=(ve=ae.current).onSelectionChange)==null||we.call(ve,ie))},U=()=>{ee&&clearTimeout(ee),ee=setTimeout(F,120)};return document.addEventListener("selectionchange",U),()=>{document.removeEventListener("selectionchange",U),ee&&clearTimeout(ee)}},[]),g.useEffect(()=>{var ee;if(o.size===1){const F=Array.from(o)[0],U=(ee=_.current)==null?void 0:ee.querySelector(`span[data-char-id="${F}"]`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[o]);const K=ee=>{var he;const F=_.current;if(!F)return null;const U=(he=N.find(X=>X.page===ee))==null?void 0:he.leadFirstId;return U?F.querySelector(`span[data-char-id="${U}"]`):F.querySelector(`[data-page-section="${ee}"]`)},le=m==null?void 0:m.nonce;g.useEffect(()=>{if(!m)return;const ee=K(m.page);ee&&(L.current=Date.now()+800,ee.scrollIntoView({behavior:"auto",block:"start"}))},[le]);const Se=!!h,A=Se&&typeof w=="number",[je,ce]=g.useState(null),ze=Br(je??w??0),$e=g.useRef(null);$e.current=A?ze:null;const Fe=g.useRef(()=>{});return g.useEffect(()=>{if(!Se)return;const ee=[],F=[];for(const O of N){const J=K(O.page);J&&(ee.push(J),F.push(O.page))}if(ee.length===0)return;let U=0;const he=()=>{var re,D;if(U=0,Date.now()<L.current||ee.length>1&&ee[0].getBoundingClientRect().top===ee[ee.length-1].getBoundingClientRect().top)return;const O=$e.current===null?120:$e.current*window.innerHeight;let J=0,oe=ee.length-1;for(;J<oe;){const se=J+oe+1>>1;ee[se].getBoundingClientRect().top<=O?J=se:oe=se-1}(D=(re=ae.current).onVisiblePageChange)==null||D.call(re,F[J])},X=()=>{U||(U=requestAnimationFrame(he))};return Fe.current=()=>{U||(U=requestAnimationFrame(he))},window.addEventListener("scroll",X,{passive:!0}),he(),()=>{window.removeEventListener("scroll",X),U&&cancelAnimationFrame(U),Fe.current=()=>{}}},[Se,N]),g.useEffect(()=>{A&&Fe.current()},[A,ze]),t.jsxs("div",{ref:_,className:"guji-text-pane-content",children:[te&&t.jsx("style",{children:Lo}),A&&t.jsx(Pf,{y:ze,containerRef:_,onDrag:ce,onCommit:ee=>{ce(null),j==null||j(ee)}}),t.jsx("div",{className:"guji-text-reflow-view",children:N.map((ee,F)=>t.jsx(Af,{pGroup:ee,first:F===0,pageBreaks:b,markOpts:T,plainBooks:B,selected:G.get(ee.page)??If,entityOfChar:H,entityLoader:q,convert:u,buildHref:y??Tf,handlers:V},`page-sec-${ee.page}`))})]})},If=new Set,Ef=[];function Rf(e,n){const i=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function ua({n:e}){return t.jsx(t.Fragment,{children:Array.from({length:e},(n,i)=>t.jsx("span",{className:"guji-text-blank-col","aria-hidden":"true","data-blank-col":""},i))})}function Lf(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}const Af=g.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:u}){const m=g.useMemo(()=>{const y=new Map;if(!p)return y;for(const $ of n.paragraphs){const b=Lf($.chars.map(w=>w.charData.norm??w.charData.char),p);$.chars.forEach((w,j)=>y.set(w.charData.id,b[j]))}return y},[n,p]),f=y=>m.get(y.id)??y.char,{t:x}=ne(),v=y=>{const $=s?Lc(y.mark,s):y.mark;return $?t.jsx("span",{className:"guji-text-punct","data-punct-id":y.id,children:$},y.id):null};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((y,$)=>t.jsxs("p",{className:"guji-reflow-paragraph",children:[Nf(y.chars,d).map((b,w)=>{const j=b.chars.map(({charData:S,beforePuncts:_,afterPuncts:L,start:z},T)=>{const B=!!b.entity&&T===0,W=!!b.entity&&T===b.chars.length-1,N=B?[]:_,R=W?[]:L;return t.jsxs(g.Fragment,{children:[z&&z.blankBefore>0&&t.jsx(ua,{n:z.blankBefore}),N.map(v),t.jsx("span",{"data-char-id":S.id,onClick:()=>u.click(S.id),onMouseEnter:()=>u.enter(S.id),onMouseLeave:u.leave,className:`guji-text-char${l.has(S.id)?" is-selected":""}${S.sub?" is-sub":""}${S.lane==="solo"?" is-solo":""}${S.lacuna?" is-lacuna":""}${S.guess?" is-guess":""}${S.zi?" is-zi":""}${z!=null&&z.raised?" is-raised":""}`,"data-raised":(z==null?void 0:z.raised)||void 0,title:S.lacuna?x("detail.lacuna"):S.zi?x("detail.composedChar",{label:S.zi}):S.guess?x("reader.charGuess"):void 0,children:f(S)}),R.map(v)]},S.id)});if(!b.entity)return t.jsx(g.Fragment,{children:j},`r${w}`);const k=b.chars[0].beforePuncts.map(v),C=b.chars[b.chars.length-1].afterPuncts.map(v);return t.jsxs(g.Fragment,{children:[k,t.jsx(Mo,{span:b.entity,label:b.chars.map(S=>f(S.charData)).join(""),hasBrackets:!0,plain:a&&b.entity.kind==="work",loader:c,buildHref:h,onNavigate:u.navigate,renderText:()=>j,hoverDelayMs:250}),C]},`${b.entity.key}@${w}`)}),$===n.paragraphs.length-1&&n.trailingBlank?t.jsx(ua,{n:n.trailingBlank}):null]},y.id))]})});function Br(e){const[n,i]=On,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const Mf=.02,li=16;function Pf({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ne(),[a,l]=g.useState(0),d=g.useRef(!1),c=g.useRef(e);c.current=e;const p=g.useCallback(()=>{var f,x;const m=(x=((f=n.current)==null?void 0:f.querySelector(".guji-text-reflow-view"))??n.current)==null?void 0:x.getBoundingClientRect();l(Math.max(0,((m==null?void 0:m.left)??0)-li-2))},[n]);g.useLayoutEffect(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[p]);const h=u=>Br(u/Math.max(1,window.innerHeight));return t.jsx("div",{role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(On[0]*100),"aria-valuemax":Math.round(On[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${li/2}px)`,width:li,height:li,zIndex:20,cursor:"ns-resize",touchAction:"none",background:r("accent"),clipPath:"polygon(0 0, 100% 50%, 0 100%)",outline:"none"},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const m=h(u.clientY);c.current=m,i(m)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(h(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(c.current))},onKeyDown:u=>{const m=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;m&&(u.preventDefault(),o(Br(e+m*(u.shiftKey?5:1)*Mf)))}})}const qc=1,Kc=6,ci={s:1,x:0,y:0},hi=(e,n,i)=>Math.min(i,Math.max(n,e));function Bo(e,n,i){const o=hi(e.s,qc,Kc);return{s:o,x:hi(e.x,n*(1-o),0),y:hi(e.y,i*(1-o),0)}}function ur(e,n,i,o,s,a){const l=hi(e.s*o,qc,Kc),d=l/e.s;return Bo({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function Bf(e,n,i,o,s){return Bo({s:e.s,x:e.x+n,y:e.y+i},o,s)}function Of(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const ma=4,Wf=g.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=g.useRef(null),[d,c]=g.useState(ci),p=g.useRef(d),h=g.useRef(i);h.current=i;const u=b=>{var j;const w=p.current;p.current=b,c(b),b.s!==w.s&&((j=h.current)==null||j.call(h,b.s))},m=()=>{var w;const b=(w=l.current)==null?void 0:w.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w,h:j}=m();u(ur(p.current,w/2,j/2,b,w,j))},reset(){u(ci)}})),g.useEffect(()=>{u(ci)},[o]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:j,h:k}=m(),C=Bo(p.current,j,k);(C.x!==p.current.x||C.y!==p.current.y)&&u(C)});return w.observe(b),()=>w.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const w=j=>{const k=Of(j.deltaY,j.deltaMode,j.ctrlKey);if(p.current.s<=1&&k<1)return;j.preventDefault();const{w:C,h:S,left:_,top:L}=m();u(ur(p.current,j.clientX-_,j.clientY-L,k,C,S))};return b.addEventListener("wheel",w,{passive:!1}),()=>b.removeEventListener("wheel",w)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),v=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const w=x.current;if(w.swallowClick=!1,f.current.size===1&&(w.moved=0,w.dragging=!1),f.current.size===2){const[j,k]=[...f.current.values()];w.pinchDist=Math.hypot(j.x-k.x,j.y-k.y),w.moved=ma+1}},y=b=>{var B;const w=f.current.get(b.pointerId);if(!w)return;const j={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,j);const k=x.current,{w:C,h:S,left:_,top:L}=m();if(f.current.size>=2){const[W,N]=[...f.current.values()],R=Math.hypot(W.x-N.x,W.y-N.y);if(k.pinchDist>0&&R>0){const H=(W.x+N.x)/2-_,q=(W.y+N.y)/2-L;u(ur(p.current,H,q,R/k.pinchDist,C,S))}k.pinchDist=R,k.swallowClick=!0;return}const z=j.x-w.x,T=j.y-w.y;if(k.moved+=Math.abs(z)+Math.abs(T),!(k.moved<=ma)){if(!k.dragging){k.dragging=!0;try{(B=l.current)==null||B.setPointerCapture(b.pointerId)}catch{}}k.swallowClick=!0,p.current.s>1&&u(Bf(p.current,z,T,C,S))}},$=b=>{f.current.delete(b.pointerId);const w=x.current;w.pinchDist=0,f.current.size===0&&(w.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:v,onPointerMove:y,onPointerUp:$,onPointerCancel:$,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>u(ci),style:{position:"relative",overflow:"hidden",touchAction:"none",cursor:d.s>1?"grab":void 0,...s},children:t.jsx("div",{className:"bim-zp-inner",style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transformOrigin:"0 0",transform:`translate(${d.x}px, ${d.y}px) scale(${d.s})`,willChange:d.s>1?"transform":void 0},children:n})})});function Xc(e,n,i,o){const[s,a]=g.useState(n??null),[l,d]=g.useState(!1),c=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){a(n);return}const p=++c.current;if(!i){a(null),d(!1);return}if(e){let h;try{h=e(i,o)}catch{a(null),d(!1);return}if(!h||typeof h.then!="function"){a(h??null),d(!1);return}d(!0),h.then(u=>{p===c.current&&a(u??null)}).catch(()=>{p===c.current&&a(null)}).finally(()=>{p===c.current&&d(!1)});return}a(null),d(!1)},[e,n,i,o]),{warpData:s,loading:l}}function Ff(e,n,i){const[o,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,i)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?Bc(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const ha={padding:24,color:r("desc-fg"),fontSize:14};function ga({title:e,label:n,className:i,style:o}){const s=(a,l=14,d=14)=>({width:a,height:l,marginTop:d,borderRadius:3,background:r("rule")});return t.jsxs("div",{className:i,style:{...o,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[e&&t.jsx("div",{style:{fontSize:15,color:r("ink"),fontFamily:r("font-ui")},children:e}),t.jsx("div",{style:s("42%",24,28)}),t.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((a,l)=>t.jsx("div",{style:s(a,16,l===0?30:14)},l)),t.jsx("p",{role:"status",style:{marginTop:24,color:r("desc-fg"),fontSize:14,fontFamily:r("font-ui")},children:n})]})}const fa=/^https?:\/\//i,Hf=[];function Df(e){if(!e||typeof e!="object")return null;const n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,i=n(e.url),o=n(e.license_url),s={name:n(e.name),url:i&&fa.test(i)?i:void 0,license:n(e.license),license_url:o&&fa.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Uf(e,n){return{work_id:n.work_id??e,title:n.title,type:n.type,juan_files:n.chapters.map(i=>i.file),juan_metadata:n.juan_metadata,juan_groups:n.juan_groups,references:n.references,target_source:n.target_source,target_source_id:n.target_source_id,text_source:n.text_source,text_quality:n.text_quality}}function Vf(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(i=>i.vol_label)?"冊":ke.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function Zc(e,n,i,o=!1){const s=i(`${n}${e.n}`);if(!e.title)return s;const a=i(e.title);return o&&!/^[卷冊册章篇回第]/.test(e.title)?`${s} ${a}`:a}function Gf(e,n,i,o,s){var p;const a=new Map(e.chapters.map(h=>[h.file,h])),l=h=>h==="loading"?"…":typeof h=="number"&&h>0?h:void 0,d=(h,u)=>{const m=a.get(h);return{key:h,label:u??(m?Zc(m,i,o,s):h),hint:l(n[h]),disabled:n[h]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(h=>{var u;return h.files.some(m=>a.has(m))||((u=h.children)==null?void 0:u.length)});if(c&&c.length>0){const h=(u,m)=>{var x;if(u.files.length===1&&!((x=u.children)!=null&&x.length))return d(u.files[0],o(u.label));const f=ef(u,n);return{key:`group:${m}`,label:o(u.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Hc(u),defaultExpanded:typeof f=="number"&&f>0,children:[...u.files.filter(v=>a.has(v)).map(v=>d(v)),...(u.children??[]).map((v,y)=>h(v,`${m}.${y}`))]}};return c.map((u,m)=>h(u,`${m}`))}return e.chapters.map(h=>d(h.file))}const Oo=e=>{const n=Ul();return t.jsx(Cu,{mode:n[0].scriptMode,children:t.jsx(Yf,{...e,prefsState:n})})},Yf=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,title:d,subtitle:c,resolveImages:p,renderImageOverlay:h,imagePanel:u,allowVertical:m,onReportError:f,revisedAt:x,backHref:v,backLabel:y,resolveWarpData:$,warpData:b,resolveEntities:w,onEntityNavigate:j,className:k,style:C})=>{var cs,ds,ps;const{t:S,convert:_}=ne(),L=g.useMemo(()=>Ll(i),[i]),[z,T]=e,B=it(),W=g.useRef(a);W.current=a;const[N,R]=g.useState(null),[H,q]=g.useState("loading");g.useEffect(()=>{let E=!1;return R(null),q("loading"),L.getManifest(n).then(ue=>{E||(ue?(R(ue),q("ready")):q("missing"))}).catch(()=>{E||q("missing")}),()=>{E=!0}},[L,n]);const te=o!==void 0,ae=s!==void 0,[V,G]=g.useState(null),[me,K]=g.useState(null);g.useEffect(()=>{G(null),K(null)},[n]);const le=ke.pickTextVersion(N,te?o:V),Se=((cs=N==null?void 0:N.versions.find(E=>E.key==="default"))==null?void 0:cs.key)??((ds=N==null?void 0:N.versions[0])==null?void 0:ds.key)??"default",A=(le==null?void 0:le.key)??null,je=ae?s:me,ce=g.useCallback((E,ue,Te)=>{var Ge;(Ge=W.current)==null||Ge.call(W,{key:E,chapter:ue,isDefault:E===Se},Te)},[Se]);g.useEffect(()=>{!N||!te||o==null||N.versions.some(E=>E.key===o)||ce(Se,null,"auto")},[N,te,o,Se,ce]);const ze=g.useRef(new Map);g.useEffect(()=>{ze.current.clear()},[L,n]);const $e=g.useCallback(async E=>{const ue=`${n}
|
|
1343
|
+
`,jf=120;function pt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function vf(e,n=jf){if(!e)return;const i=e.replace(/\s+/g," ").trim(),o=Array.from(i);return o.length>n?o.slice(0,n).join("")+"…":i}function kf(e){const n=e.dates&&typeof e.dates=="object"?e.dates:{},i=typeof n.birth=="number"?n.birth:void 0,o=typeof n.death=="number"?n.death:void 0;if(!(i===void 0&&o===void 0))return`${i??"?"}–${o??"?"}`}function wf(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=pt(o.name);return s?[pt(o.dynasty)&&`〔${pt(o.dynasty)}〕`,s,pt(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Uc(e,n){const i=pt(n.type),o=pt(n.primary_name)??pt(n.title)??e,s=i==="entity"?[pt(n.dynasty),kf(n),pt(n.native_place)].filter(Boolean).join(" · "):[wf(n),pt(n.edition),pt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?pt(n.description.text):pt(n.description);return{id:pt(n.id)??e,type:i,title:o,meta:s||void 0,description:vf(a)}}function Vc(e){const n=[e.dynasty,e.author,e.edition].filter(Boolean).join(" · ");return{id:e.id,type:e.type,title:e.title,meta:n||void 0}}function Gc(e){return async n=>{const i=await e.getItem(n);if(i)return Uc(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return Vc(o)}return null}}const ca=new WeakMap;function Sf(e,n,i){let o=ca.get(e);o||(o=new Map,ca.set(e,o));const s=o.get(i);if(s)return s;const a=n(i);return o.set(i,a),a.catch(()=>o.delete(i)),a}const Yc=e=>`/item/${encodeURIComponent(e)}`,da={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},_f=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Ao(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:Gc(e)}:null,[n,e])}const $f=e=>e,Cf=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=Yc,onNavigate:d,renderText:c=$f,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:u=!0,className:m})=>{const f=g.useMemo(()=>{const v=i==="plain"?Oc(e,n,o):n;return Wc(e,v)},[e,n,i,o]),x=Ao(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:Lo}),f.map(v=>v.type==="text"?t.jsx(g.Fragment,{children:c(v.text)},`t${v.start}`):t.jsx(Mo,{span:v.span,label:v.text,hasBrackets:e[v.start-1]==="《"&&e[v.start+v.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:h},`${v.span.key}@${v.start}`))]})};let Ut=null;const Mo=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,renderText:d,hoverDelayMs:c,closeDelayMs:p=280})=>{const h=g.useId(),[u,m]=g.useState(!1),[f,x]=g.useState(!1),v=g.useRef(null),y=g.useRef(null),$=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,b=e.kind==="work"&&!i,w=t.jsxs(t.Fragment,{children:[b&&t.jsx("span",{className:"bim-et-sr",children:"《"}),d(n),b&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),j=()=>{v.current&&(clearTimeout(v.current),v.current=null)},k=()=>{y.current&&(clearTimeout(y.current),y.current=null)},C=g.useCallback(()=>{j(),k(),m(!1),x(!1),Ut===C&&(Ut=null)},[]);g.useEffect(()=>()=>{j(),k(),Ut===C&&(Ut=null)},[C]);const S=g.useCallback(()=>{Ut&&Ut!==C&&Ut(),Ut=C,m(!0)},[C]),_=g.useCallback(W=>{k(),x(!0),!u&&(j(),W<=0?S():v.current=setTimeout(S,W))},[u,S]),L=g.useCallback(()=>{j(),k(),y.current=setTimeout(C,p)},[C,p]),z=!!e.targetId,T=e.targetId,B={className:"bim-et-w","data-active":f?"":void 0,onMouseEnter:()=>_(c),onMouseLeave:L,onBlur:W=>{W.currentTarget.contains(W.relatedTarget)||C()},onKeyDown:W=>{W.key==="Escape"&&u&&(W.stopPropagation(),C())}};return!z||!T?t.jsxs("span",{...B,children:[t.jsx("span",{className:$,children:w}),u&&t.jsx(pa,{id:h,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...B,children:[t.jsx("a",{className:$,href:a(T),"data-entity-id":T,"aria-describedby":u?h:void 0,onFocus:()=>_(0),onClick:l?W=>l(T,W):void 0,children:w}),u&&t.jsx(pa,{id:h,entityId:T,span:e,loader:s,buildHref:a,onNavigate:l})]})},pa=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a})=>{const{convert:l,t:d}=ne(),c=g.useRef(null),[p,h]=g.useState("start"),[u,m]=g.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!o||!n)return;let v=!1;return m({status:"loading"}),Sf(o.owner,o.load,n).then(y=>{v||m({status:"ready",summary:y})}).catch(()=>{v||m({status:"error"})}),()=>{v=!0}},[o,n]),_f(()=>{const v=c.current;if(!v||typeof window>"u")return;const y=v.getBoundingClientRect(),$=document.documentElement.clientWidth||window.innerWidth;y.right>$-8&&p==="start"&&h("end")},[u,p]);const f=u.status==="ready"?u.summary:null,x=(f==null?void 0:f.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:[t.jsx("span",{className:"bim-et-card-k",children:l(da[i.kind])}),x&&t.jsx("span",{className:"bim-et-card-t",children:l(x)}),(f==null?void 0:f.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(f.meta)}),(f==null?void 0:f.description)&&t.jsx("span",{className:"bim-et-card-d",children:l(f.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),f&&t.jsx("a",{className:"bim-et-card-a",href:s(f.id||n),onClick:a?v=>a(f.id||n,v):void 0,children:d("reader.entityDetail")})]}):t.jsx("span",{ref:c,id:e,role:"tooltip",className:"bim-et-card","data-align":p,children:t.jsx("span",{className:"bim-et-card-k",children:l(da[i.kind])})})},Tf=e=>`/item/${encodeURIComponent(e)}`;function zf(e){const n=e.filter(i=>i.kind!=="break");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function Nf(e,n){const i=[];for(const o of e){const s=n.get(o.charData.id)??null,a=i[i.length-1];a&&a.entity===s?a.chars.push(o):i.push({entity:s,chars:[o]})}return i}const Po=({pageData:e,pages:n,punctuations:i=Ef,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:u,scrollToPage:m,entities:f,entityTransport:x,loadEntitySummary:v,buildEntityHref:y,onEntityNavigate:$,pageBreaks:b=!0,pageIndicatorY:w,onPageIndicatorYChange:j,quoteStyle:k,bookTitleStyle:C,showWorks:S})=>{const _=g.useRef(null),L=g.useRef(0),z=g.useMemo(()=>{const ee=new Map;return p&&i.forEach((F,U)=>{const he=F.id?F:{...F,id:`${F.anchor}#${U}`},X=ee.get(he.anchor)||[];X.push(he),ee.set(he.anchor,X)}),ee},[i,p]),T=g.useMemo(()=>k===void 0&&C===void 0&&S===void 0?null:{quoteStyle:k??"original",hideBookBrackets:C==="wavy"||S===!1},[k,C,S]),B=C==="bracket",W=g.useMemo(()=>{var he;const ee=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],F=ee.filter(X=>X.columns.some(O=>O.chars.length>0)).map(X=>{const O=[...X.columns].sort((se,_e)=>se.col-_e.col),J=[];let oe=[],re=0;for(const se of O){if(se.chars.length===0){se.kind==="blank"&&re++;continue}const _e=se.raised||se.lead_blank||re?{raised:se.raised,leadBlank:se.lead_blank,blankBefore:re}:void 0;re=0;let Ae=!0;for(const M of se.chars){const{before:ie,after:ve}=zf(z.get(M.id)||[]),we=(z.get(M.id)||[]).some(P=>P.kind==="break");oe.push({charData:M,col:se.col,beforePuncts:ie,afterPuncts:ve,...Ae&&_e?{start:_e}:{}}),Ae=!1,we&&(J.push({id:`para-p${X.page}-${J.length}`,chars:oe}),oe=[])}}const D=oe.length>0;return D&&J.push({id:`para-p${X.page}-${J.length}`,chars:oe}),{page:X.page,paragraphs:J,endsOpen:D,...X.label?{label:X.label}:{},...re>0?{trailingBlank:re}:{}}}),U=new Map;if(!b){const X=new Map;for(const re of ee)for(const D of re.columns)D.chars.length>0&&X.set(D.lead_blank||0,(X.get(D.lead_blank||0)||0)+1);let O=0,J=-1;for(const[re,D]of X)(D>J||D===J&&re<O)&&(O=re,J=D);let oe=null;for(const re of F){const D=re.paragraphs[0],se=(he=D==null?void 0:D.chars[0])==null?void 0:he.start,_e=!!se&&!!(se.raised||(se.leadBlank||0)>O||se.blankBefore),Ae=re.paragraphs.length===1&&!!re.trailingBlank;if(oe&&D&&!_e&&!Ae){for(const M of D.chars)U.set(M.charData.id,oe.owner);oe.para.chars=oe.para.chars.concat(D.chars),re.leadFirstId=D.chars[0].charData.id,re.paragraphs=re.paragraphs.slice(1)}if(re.endsOpen&&!re.trailingBlank){const M=re.paragraphs[re.paragraphs.length-1];M&&(oe={para:M,owner:re.page})}else oe=null}}return{pages:F,mergedOwner:U}},[n,e,z,b]),N=W.pages,R=g.useMemo(()=>{const ee=[];for(const F of N)for(const U of F.paragraphs)for(const he of U.chars)ee.push(he.charData.id);return ee},[N]),H=g.useMemo(()=>{const ee=new Map;if(!f||f.length===0)return ee;const F=new Map(R.map((U,he)=>[U,he]));for(const U of f){if(!U.anchor)continue;const he=F.get(U.anchor.start),X=F.get(U.anchor.end);if(!(he===void 0||X===void 0||X<he))for(let O=he;O<=X;O++)ee.has(R[O])||ee.set(R[O],U)}return ee},[f,R]),q=Ao(x,v),te=H.size>0,ae=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:$});ae.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:$};const V=g.useMemo(()=>({click:ee=>{var F,U;L.current=Date.now()+1200,(U=(F=ae.current).onCharClick)==null||U.call(F,ee)},enter:ee=>{var F,U;return(U=(F=ae.current).onCharHover)==null?void 0:U.call(F,ee)},leave:()=>{var ee,F;return(F=(ee=ae.current).onCharHover)==null?void 0:F.call(ee,null)},navigate:(ee,F)=>{var he,X;if(!(F.detail===0||F.ctrlKey||F.metaKey||F.shiftKey)){F.preventDefault();return}(X=(he=ae.current).onEntityNavigate)==null||X.call(he,ee,F)}}),[]),G=Rf(o,W.mergedOwner),me=g.useRef(null);g.useEffect(()=>{var F,U;if((F=me.current)==null||F.classList.remove("is-hovered"),me.current=null,!s)return;const ee=(U=_.current)==null?void 0:U.querySelector(`span[data-char-id="${s}"]`);ee&&(ee.classList.add("is-hovered"),me.current=ee)},[s]),g.useEffect(()=>{let ee=null;const F=()=>{var ve,we;ee=null;const he=window.getSelection(),X=_.current;if(!he||he.isCollapsed||he.rangeCount===0||!X)return;const O=he.getRangeAt(0),J=O.commonAncestorContainer,oe=J.nodeType===3?J.parentElement:J;if(!oe||!X.contains(oe))return;const re=X.querySelectorAll("span[data-char-id]"),D=P=>P.firstChild??P;let se=0,_e=re.length;for(;se<_e;){const P=se+_e>>1;O.comparePoint(D(re[P]),0)<0?se=P+1:_e=P}const Ae=se;for(_e=re.length;se<_e;){const P=se+_e>>1;O.comparePoint(D(re[P]),0)<=0?se=P+1:_e=P}let M=se-1;if(M>=Ae&&O.endOffset===0&&O.endContainer===D(re[M])&&M--,M<Ae)return;const ie=[];for(let P=Ae;P<=M;P++)ie.push(re[P].getAttribute("data-char-id"));ie.length>0&&(L.current=Date.now()+1200,(we=(ve=ae.current).onSelectionChange)==null||we.call(ve,ie))},U=()=>{ee&&clearTimeout(ee),ee=setTimeout(F,120)};return document.addEventListener("selectionchange",U),()=>{document.removeEventListener("selectionchange",U),ee&&clearTimeout(ee)}},[]),g.useEffect(()=>{var ee;if(o.size===1){const F=Array.from(o)[0],U=(ee=_.current)==null?void 0:ee.querySelector(`span[data-char-id="${F}"]`);U&&U.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[o]);const K=ee=>{var he;const F=_.current;if(!F)return null;const U=(he=N.find(X=>X.page===ee))==null?void 0:he.leadFirstId;return U?F.querySelector(`span[data-char-id="${U}"]`):F.querySelector(`[data-page-section="${ee}"]`)},le=m==null?void 0:m.nonce;g.useEffect(()=>{if(!m)return;const ee=K(m.page);ee&&(L.current=Date.now()+800,ee.scrollIntoView({behavior:"auto",block:"start"}))},[le]);const Se=!!h,A=Se&&typeof w=="number",[je,ce]=g.useState(null),ze=Br(je??w??0),$e=g.useRef(null);$e.current=A?ze:null;const Fe=g.useRef(()=>{});return g.useEffect(()=>{if(!Se)return;const ee=[],F=[];for(const O of N){const J=K(O.page);J&&(ee.push(J),F.push(O.page))}if(ee.length===0)return;let U=0;const he=()=>{var re,D;if(U=0,Date.now()<L.current||ee.length>1&&ee[0].getBoundingClientRect().top===ee[ee.length-1].getBoundingClientRect().top)return;const O=$e.current===null?120:$e.current*window.innerHeight;let J=0,oe=ee.length-1;for(;J<oe;){const se=J+oe+1>>1;ee[se].getBoundingClientRect().top<=O?J=se:oe=se-1}(D=(re=ae.current).onVisiblePageChange)==null||D.call(re,F[J])},X=()=>{U||(U=requestAnimationFrame(he))};return Fe.current=()=>{U||(U=requestAnimationFrame(he))},window.addEventListener("scroll",X,{passive:!0}),he(),()=>{window.removeEventListener("scroll",X),U&&cancelAnimationFrame(U),Fe.current=()=>{}}},[Se,N]),g.useEffect(()=>{A&&Fe.current()},[A,ze]),t.jsxs("div",{ref:_,className:"guji-text-pane-content",children:[te&&t.jsx("style",{children:Lo}),A&&t.jsx(Pf,{y:ze,containerRef:_,onDrag:ce,onCommit:ee=>{ce(null),j==null||j(ee)}}),t.jsx("div",{className:"guji-text-reflow-view",children:N.map((ee,F)=>t.jsx(Af,{pGroup:ee,first:F===0,pageBreaks:b,markOpts:T,plainBooks:B,selected:G.get(ee.page)??If,entityOfChar:H,entityLoader:q,convert:u,buildHref:y??Tf,handlers:V},`page-sec-${ee.page}`))})]})},If=new Set,Ef=[];function Rf(e,n){const i=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function ua({n:e}){return t.jsx(t.Fragment,{children:Array.from({length:e},(n,i)=>t.jsx("span",{className:"guji-text-blank-col","aria-hidden":"true","data-blank-col":""},i))})}function Lf(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}const Af=g.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:u}){const m=g.useMemo(()=>{const y=new Map;if(!p)return y;for(const $ of n.paragraphs){const b=Lf($.chars.map(w=>w.charData.norm??w.charData.char),p);$.chars.forEach((w,j)=>y.set(w.charData.id,b[j]))}return y},[n,p]),f=y=>m.get(y.id)??y.char,{t:x}=ne(),v=y=>{const $=s?Lc(y.mark,s):y.mark;return $?t.jsx("span",{className:"guji-text-punct","data-punct-id":y.id,children:$},y.id):null};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((y,$)=>t.jsxs("p",{className:"guji-reflow-paragraph",children:[Nf(y.chars,d).map((b,w)=>{const j=b.chars.map(({charData:S,beforePuncts:_,afterPuncts:L,start:z},T)=>{const B=!!b.entity&&T===0,W=!!b.entity&&T===b.chars.length-1,N=B?[]:_,R=W?[]:L;return t.jsxs(g.Fragment,{children:[z&&z.blankBefore>0&&t.jsx(ua,{n:z.blankBefore}),N.map(v),t.jsx("span",{"data-char-id":S.id,onClick:()=>u.click(S.id),onMouseEnter:()=>u.enter(S.id),onMouseLeave:u.leave,className:`guji-text-char${l.has(S.id)?" is-selected":""}${S.sub?" is-sub":""}${S.lane==="solo"?" is-solo":""}${S.lacuna?" is-lacuna":""}${S.guess?" is-guess":""}${S.zi?" is-zi":""}${z!=null&&z.raised?" is-raised":""}`,"data-raised":(z==null?void 0:z.raised)||void 0,title:S.lacuna?x("detail.lacuna"):S.zi?x("detail.composedChar",{label:S.zi}):S.guess?x("reader.charGuess"):void 0,children:f(S)}),R.map(v)]},S.id)});if(!b.entity)return t.jsx(g.Fragment,{children:j},`r${w}`);const k=b.chars[0].beforePuncts.map(v),C=b.chars[b.chars.length-1].afterPuncts.map(v);return t.jsxs(g.Fragment,{children:[k,t.jsx(Mo,{span:b.entity,label:b.chars.map(S=>f(S.charData)).join(""),hasBrackets:!0,plain:a&&b.entity.kind==="work",loader:c,buildHref:h,onNavigate:u.navigate,renderText:()=>j,hoverDelayMs:250}),C]},`${b.entity.key}@${w}`)}),$===n.paragraphs.length-1&&n.trailingBlank?t.jsx(ua,{n:n.trailingBlank}):null]},y.id))]})});function Br(e){const[n,i]=On,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const Mf=.02,li=16;function Pf({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ne(),[a,l]=g.useState(0),d=g.useRef(!1),c=g.useRef(e);c.current=e;const p=g.useCallback(()=>{var f,x;const m=(x=((f=n.current)==null?void 0:f.querySelector(".guji-text-reflow-view"))??n.current)==null?void 0:x.getBoundingClientRect();l(Math.max(0,((m==null?void 0:m.left)??0)-li-2))},[n]);g.useLayoutEffect(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[p]);const h=u=>Br(u/Math.max(1,window.innerHeight));return t.jsx("div",{role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(On[0]*100),"aria-valuemax":Math.round(On[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${li/2}px)`,width:li,height:li,zIndex:20,cursor:"ns-resize",touchAction:"none",background:r("accent"),clipPath:"polygon(0 0, 100% 50%, 0 100%)",outline:"none"},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const m=h(u.clientY);c.current=m,i(m)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(h(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(c.current))},onKeyDown:u=>{const m=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;m&&(u.preventDefault(),o(Br(e+m*(u.shiftKey?5:1)*Mf)))}})}const qc=1,Kc=6,ci={s:1,x:0,y:0},hi=(e,n,i)=>Math.min(i,Math.max(n,e));function Bo(e,n,i){const o=hi(e.s,qc,Kc);return{s:o,x:hi(e.x,n*(1-o),0),y:hi(e.y,i*(1-o),0)}}function ur(e,n,i,o,s,a){const l=hi(e.s*o,qc,Kc),d=l/e.s;return Bo({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function Bf(e,n,i,o,s){return Bo({s:e.s,x:e.x+n,y:e.y+i},o,s)}function Of(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const ma=4,Wf=g.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=g.useRef(null),[d,c]=g.useState(ci),p=g.useRef(d),h=g.useRef(i);h.current=i;const u=b=>{var j;const w=p.current;p.current=b,c(b),b.s!==w.s&&((j=h.current)==null||j.call(h,b.s))},m=()=>{var w;const b=(w=l.current)==null?void 0:w.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w,h:j}=m();u(ur(p.current,w/2,j/2,b,w,j))},reset(){u(ci)}})),g.useEffect(()=>{u(ci)},[o]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:j,h:k}=m(),C=Bo(p.current,j,k);(C.x!==p.current.x||C.y!==p.current.y)&&u(C)});return w.observe(b),()=>w.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const w=j=>{const k=Of(j.deltaY,j.deltaMode,j.ctrlKey);if(p.current.s<=1&&k<1)return;j.preventDefault();const{w:C,h:S,left:_,top:L}=m();u(ur(p.current,j.clientX-_,j.clientY-L,k,C,S))};return b.addEventListener("wheel",w,{passive:!1}),()=>b.removeEventListener("wheel",w)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),v=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const w=x.current;if(w.swallowClick=!1,f.current.size===1&&(w.moved=0,w.dragging=!1),f.current.size===2){const[j,k]=[...f.current.values()];w.pinchDist=Math.hypot(j.x-k.x,j.y-k.y),w.moved=ma+1}},y=b=>{var B;const w=f.current.get(b.pointerId);if(!w)return;const j={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,j);const k=x.current,{w:C,h:S,left:_,top:L}=m();if(f.current.size>=2){const[W,N]=[...f.current.values()],R=Math.hypot(W.x-N.x,W.y-N.y);if(k.pinchDist>0&&R>0){const H=(W.x+N.x)/2-_,q=(W.y+N.y)/2-L;u(ur(p.current,H,q,R/k.pinchDist,C,S))}k.pinchDist=R,k.swallowClick=!0;return}const z=j.x-w.x,T=j.y-w.y;if(k.moved+=Math.abs(z)+Math.abs(T),!(k.moved<=ma)){if(!k.dragging){k.dragging=!0;try{(B=l.current)==null||B.setPointerCapture(b.pointerId)}catch{}}k.swallowClick=!0,p.current.s>1&&u(Bf(p.current,z,T,C,S))}},$=b=>{f.current.delete(b.pointerId);const w=x.current;w.pinchDist=0,f.current.size===0&&(w.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:v,onPointerMove:y,onPointerUp:$,onPointerCancel:$,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>u(ci),style:{position:"relative",overflow:"hidden",touchAction:"none",cursor:d.s>1?"grab":void 0,...s},children:t.jsx("div",{className:"bim-zp-inner",style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transformOrigin:"0 0",transform:`translate(${d.x}px, ${d.y}px) scale(${d.s})`,willChange:d.s>1?"transform":void 0},children:n})})});function Xc(e,n,i,o){const[s,a]=g.useState(n??null),[l,d]=g.useState(!1),c=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){a(n);return}const p=++c.current;if(!i){a(null),d(!1);return}if(e){let h;try{h=e(i,o)}catch{a(null),d(!1);return}if(!h||typeof h.then!="function"){a(h??null),d(!1);return}d(!0),h.then(u=>{p===c.current&&a(u??null)}).catch(()=>{p===c.current&&a(null)}).finally(()=>{p===c.current&&d(!1)});return}a(null),d(!1)},[e,n,i,o]),{warpData:s,loading:l}}function Ff(e,n,i){const[o,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,i)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?Bc(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const ha={padding:24,color:r("desc-fg"),fontSize:14};function ga({title:e,label:n,className:i,style:o}){const s=(a,l=14,d=14)=>({width:a,height:l,marginTop:d,borderRadius:3,background:r("rule")});return t.jsxs("div",{className:i,style:{...o,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[e&&t.jsx("div",{style:{fontSize:15,color:r("ink"),fontFamily:r("font-ui")},children:e}),t.jsx("div",{style:s("42%",24,28)}),t.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((a,l)=>t.jsx("div",{style:s(a,16,l===0?30:14)},l)),t.jsx("p",{role:"status",style:{marginTop:24,color:r("desc-fg"),fontSize:14,fontFamily:r("font-ui")},children:n})]})}const fa=/^https?:\/\//i,Hf=[];function Df(e){if(!e||typeof e!="object")return null;const n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,i=n(e.url),o=n(e.license_url),s={name:n(e.name),url:i&&fa.test(i)?i:void 0,license:n(e.license),license_url:o&&fa.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Uf(e,n){return{work_id:n.work_id??e,title:n.title,type:n.type,juan_files:n.chapters.map(i=>i.file),juan_metadata:n.juan_metadata,juan_groups:n.juan_groups,references:n.references,target_source:n.target_source,target_source_id:n.target_source_id,text_source:n.text_source,text_quality:n.text_quality}}function Vf(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(i=>i.vol_label)?"冊":ke.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function Zc(e,n,i,o=!1){const s=i(`${n}${e.n}`);if(!e.title)return s;const a=i(e.title);return o&&!/^[卷冊册章篇回第]/.test(e.title)?`${s} ${a}`:a}function Gf(e,n,i,o,s){var p;const a=new Map(e.chapters.map(h=>[h.file,h])),l=h=>h==="loading"?"…":typeof h=="number"&&h>0?h:void 0,d=(h,u)=>{const m=a.get(h);return{key:h,label:u??(m?Zc(m,i,o,s):h),hint:l(n[h]),disabled:n[h]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(h=>{var u;return h.files.some(m=>a.has(m))||((u=h.children)==null?void 0:u.length)});if(c&&c.length>0){const h=(u,m)=>{var x;if(u.files.length===1&&!((x=u.children)!=null&&x.length))return d(u.files[0],o(u.label));const f=ef(u,n);return{key:`group:${m}`,label:o(u.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Hc(u),defaultExpanded:typeof f=="number"&&f>0,children:[...u.files.filter(v=>a.has(v)).map(v=>d(v)),...(u.children??[]).map((v,y)=>h(v,`${m}.${y}`))]}};return c.map((u,m)=>h(u,`${m}`))}return e.chapters.map(h=>d(h.file))}const Oo=e=>{const n=Ul();return t.jsx(Cu,{mode:n[0].scriptMode,children:t.jsx(Yf,{...e,prefsState:n})})},Yf=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,title:d,subtitle:c,resolveImages:p,renderImageOverlay:h,imagePanel:u,allowVertical:m,onReportError:f,revisedAt:x,backHref:v,backLabel:y,resolveWarpData:$,warpData:b,resolveEntities:w,onEntityNavigate:j,className:k,style:C})=>{var cs,ds,ps;const{t:S,convert:_}=ne(),L=g.useMemo(()=>Ll(i),[i]),[z,T]=e,B=it(),W=g.useRef(a);W.current=a;const[N,R]=g.useState(null),[H,q]=g.useState("loading");g.useEffect(()=>{let E=!1;return R(null),q("loading"),L.getManifest(n).then(ue=>{E||(ue?(R(ue),q("ready")):q("missing"))}).catch(()=>{E||q("missing")}),()=>{E=!0}},[L,n]);const te=o!==void 0,ae=s!==void 0,[V,G]=g.useState(null),[me,K]=g.useState(null);g.useEffect(()=>{G(null),K(null)},[n]);const le=ke.pickTextVersion(N,te?o:V),Se=((cs=N==null?void 0:N.versions.find(E=>E.key==="default"))==null?void 0:cs.key)??((ds=N==null?void 0:N.versions[0])==null?void 0:ds.key)??"default",A=(le==null?void 0:le.key)??null,je=ae?s:me,ce=g.useCallback((E,ue,Te)=>{var Ge;(Ge=W.current)==null||Ge.call(W,{key:E,chapter:ue,isDefault:E===Se},Te)},[Se]);g.useEffect(()=>{!N||!te||o==null||N.versions.some(E=>E.key===o)||ce(Se,null,"auto")},[N,te,o,Se,ce]);const ze=g.useRef(new Map);g.useEffect(()=>{ze.current.clear()},[L,n]);const $e=g.useCallback(async E=>{const ue=`${n}
|
|
1344
1344
|
${E}`;if(ze.current.has(ue))return ze.current.get(ue)??null;const Te=await L.getIndex(n,E).catch(()=>null);return Te&&ze.current.set(ue,Te),Te},[L,n]),[Fe,ee]=g.useState(null),[F,U]=g.useState("loading"),he=A?`${n}
|
|
1345
1345
|
${A}`:null,X=Fe&&Fe.owner===he?Fe.idx:null;g.useEffect(()=>{if(!A)return;let E=!1;const ue=`${n}
|
|
1346
1346
|
${A}`;return ee(null),U("loading"),$e(A).then(Te=>{E||(Te&&Te.chapters.length>0?(ee({owner:ue,idx:Te}),U("ready")):U("failed"))}),()=>{E=!0}},[n,A,$e]),g.useEffect(()=>{if(!X||!A||je!=null&&X.chapters.some(Te=>Te.file===je))return;const ue=X.chapters[0].file;ae||K(ue),ce(A,ue,"auto")},[X,A,je,ae,ce]);const O=X?je!=null&&X.chapters.some(E=>E.file===je)?je:X.chapters[0].file:je,J=g.useMemo(()=>X&&O?X.chapters.find(E=>E.file===O)??null:null,[X,O]),oe=g.useRef(0),re=g.useCallback(async E=>{if(!N||E===A||!N.versions.some(kt=>kt.key===E))return;const ue=++oe.current,Te=await $e(E);if(ue!==oe.current)return;const Ge=J??(O?{file:O}:null),et=ke.matchChapterAcrossVersions(Ge,Te);te||G(E),ae||K(et),ce(E,et,"version")},[N,A,$e,J,O,te,ae,ce]),D=g.useCallback(E=>{A&&(ae||K(E),ce(A,E,"chapter"))},[A,ae,ce]),[se,_e]=g.useState(null),Ae=A&&J?`${n}
|
|
@@ -1350,7 +1350,7 @@ ${A}
|
|
|
1350
1350
|
${J.file}`;_e(null),L.getChapter(n,A,J.file,{json:!!J.has_json}).then(Te=>{E===we.current&&_e(Te)}).catch(()=>{E===we.current&&_e(null)}).finally(()=>{E===we.current&&ie(ue)})},[L,n,A,J]);const P=ke.isCollatedKind(le==null?void 0:le.kind),[fe,de]=g.useState("");g.useEffect(()=>{de("")},[n,A]);const xe=g.useMemo(()=>A&&P?async E=>{const ue=await L.getChapter(n,A,E,{json:!0});return{juan:(ue==null?void 0:ue.json)??null,rawText:(ue==null?void 0:ue.md)??null}}:null,[L,n,A,P]),Ce=(X==null?void 0:X.type)==="kaozhen",Ue=g.useMemo(()=>(X==null?void 0:X.chapters.map(E=>E.file))??[],[X]),{matchStates:Ke}=hf({resetKey:`${n}
|
|
1351
1351
|
${A??""}`,load:xe,files:Ue,activeFile:O??null,activeJuan:(se==null?void 0:se.json)??null,activeRawText:(se==null?void 0:se.md)??null,query:fe,isKaozhen:Ce}),Je=g.useRef(new Map);g.useEffect(()=>{Je.current.clear()},[n]);const qe=g.useMemo(()=>({versionKey:A,chapter:J??null}),[A,J]),I=Fg(p,O??null,qe),{warpData:Y,loading:pe}=Xc($,b,O??null,qe),be=Ff(w,O??null,qe),Re=z.properNameMode??(be.length>0?"full":"off"),ge=g.useMemo(()=>({...z,properNameMode:Re}),[z,Re]),Me=g.useMemo(()=>Wg(be,Re,{showWorks:ge.showWorks}),[be,Re,ge.showWorks]),[Q,ye]=g.useState(new Set),[We,He]=g.useState(null),[Ne,Pe]=g.useState(!0),Le=z.preserveMargins;g.useCallback(E=>T({preserveMargins:E}),[T]);const Be=g.useRef(null),[Ie,De]=g.useState(1),[Qe,Ft]=g.useState(null),yt=E=>{var Te;const ue=parseInt(((Te=E==null?void 0:E.page_id)==null?void 0:Te.split(":")[1])??"",10);return isNaN(ue)?null:ue},Kt=E=>{var Te,Ge;const ue=(E==null?void 0:E.pages)??[];return yt(E)??((Te=ue.find(et=>et.columns.some(kt=>kt.chars.length>0)))==null?void 0:Te.page)??((Ge=ue[0])==null?void 0:Ge.page)??1},[Ye,Z]=g.useState(()=>Kt(Y)),Ve=`${n}
|
|
1352
1352
|
${A}
|
|
1353
|
-
${O??""}`,[st,_t]=g.useState({key:Ve,data:Y,started:!!Y});if(st.key!==Ve)_t({key:Ve,data:Y,started:!1});else if(Y!==st.data&&(_t({key:Ve,data:Y,started:!!Y}),Y)){const E=Y.pages??[];(!st.started||!E.some(ue=>ue.page===Ye))&&Z(Kt(Y))}g.useEffect(()=>{ye(new Set),He(null)},[O,A]);const Sp=g.useCallback(E=>{if(ye(new Set(E)),E.length>0){const ue=E[0],Te=parseInt(ue.split(":")[0],10);isNaN(Te)||Z(Te)}},[]),It=g.useMemo(()=>{const E=new Map;for(const ue of(Y==null?void 0:Y.pages)??[])E.set(ue.page,ue);return E},[Y]),wn=yt(Y),qn=g.useCallback(E=>{var Ge;const ue=I.images;if(!ue||ue.length===0)return;const Te=(Ge=It.get(E))==null?void 0:Ge.seq;return(Te?ue.find(et=>et.seq===Te):void 0)??ue.find(et=>et.pageNo===E)??ue[E-1]},[I.images,It]),es=Ie>1.5,Kn=g.useCallback((E,ue=!1)=>{const Te=qn(E);return Te?E===wn||ue?Te.hiresUrl??Te.url:Te.url:E===wn?(Y==null?void 0:Y.imageUrl)??"":""},[qn,Y,wn]),_p=g.useMemo(()=>Kn(Ye,es),[Kn,Ye,es]),Et=g.useMemo(()=>[...It.keys()].sort((E,ue)=>E-ue),[It]),Xn=g.useRef(Ye);Xn.current=Ye;const ts=g.useRef(0),Zn=g.useCallback(E=>{var ue;Xn.current===E||!It.has(E)||(ts.current=Date.now()+1e3,Xn.current=E,Z(E),(ue=It.get(E))!=null&&ue.columns.some(Te=>Te.chars.length>0)&&Ft(Te=>({page:E,nonce:((Te==null?void 0:Te.nonce)??0)+1})))},[It]),Sn=g.useCallback(E=>{const ue=Xn.current,Te=Et.indexOf(ue),Ge=Et[Te<0?0:Te+E];Ge===void 0||Ge===ue||Zn(Ge)},[Et,Zn]),ns=g.useCallback(E=>{if(!E.trim().match(/^\d+$/)||Et.length===0)return null;const Te=parseInt(E.trim(),10),Ge=Number.isFinite(Te)?Te:Number.MAX_SAFE_INTEGER;return Et.reduce((et,kt)=>Math.abs(kt-Ge)<Math.abs(et-Ge)?kt:et,Et[0])},[Et]),[qi,Ki]=g.useState(null),Jn=g.useRef(null),$p=g.useCallback(E=>{Jn.current=E,Ki(E)},[]),is=g.useCallback(()=>{const E=Jn.current;if(Jn.current=null,Ki(null),E===null)return;const ue=ns(E);ue!==null&&Zn(ue)},[ns,Zn]),Xi=Et.indexOf(Ye),Cp=g.useCallback(E=>{if(E.altKey||E.ctrlKey||E.metaKey)return;const ue=E.target.tagName;ue==="INPUT"||ue==="TEXTAREA"||ue==="SELECT"||(E.key==="ArrowLeft"||E.key==="PageUp"?(E.preventDefault(),Sn(-1)):(E.key==="ArrowRight"||E.key==="PageDown")&&(E.preventDefault(),Sn(1)))},[Sn]);g.useEffect(()=>{if(Y)for(const E of[1,-1,2,3]){const ue=Kn(Ye+E);ue&&Pr(ue)}},[Y,Ye,Kn]);const rs=g.useMemo(()=>{var gs;if(!Y)return null;if(Ye===wn)return Y;const E=It.get(Ye);if(E&&E.width>0&&E.height>0)return{page_id:`p:${Ye}`,title:`第${Ye}葉`,image_size:[E.width,E.height],total_warped_w:E.width,columns:[{col:1,warped_w:E.width,warped_h:E.height,offset_x:0,strips:[],chars:E.columns.flatMap(Ze=>Ze.chars).map(Ze=>({id:Ze.id,char:Ze.char,slot:Ze.slot,pos:Ze.pos,sub:Ze.sub,bbox_col:Ze.bbox??[0,0,0,0]}))}]};const ue=(gs=Y.pages)==null?void 0:gs.find(Ze=>Ze.page===Ye),[Te,Ge]=Y.image_size||[2386,3082],et=qn(Ye),kt=(et==null?void 0:et.width)??Te,tr=(et==null?void 0:et.height)??Ge,us=kt/Te,ms=tr/Ge,hs=new Map;for(const Ze of Y.columns){const ht=(Ze.strips||[]).flatMap(ii=>ii.srcQuad.map(ri=>ri[0]));if(ht.length===0)continue;const Rt=Ze.top_y??0,nr=Ze.bottom_y??Rt+Ze.warped_h;hs.set(Ze.col,{x0:Math.min(...ht),x1:Math.max(...ht),top:Rt,slotH:(nr-Rt)/21})}return{page_id:`p:${Ye}`,title:`第${Ye}葉`,image_size:[kt,tr],total_warped_w:kt,columns:ue?ue.columns.map(Ze=>{const ht=hs.get(Ze.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ze.col,warped_w:kt,warped_h:tr,offset_x:0,strips:[],chars:Ze.chars.map(Rt=>{const nr=Rt.slot??Rt.pos??0,ii=(ht.top+(nr-1)*ht.slotH)*ms,ri=(ht.x0+ht.x1)/2,[Mp,Pp]=Rt.sub==="a"?[ri,ht.x1]:Rt.sub==="b"?[ht.x0,ri]:[ht.x0,ht.x1];return{...Rt,bbox_col:[Mp*us,ii,Pp*us,ii+ht.slotH*ms]}})}}):[]}},[Y,Ye,wn,It,qn]),{entryTitle:Qn,authors:os}=Xf(n,i,d===void 0),[ss,Zi]=g.useState("text");if(g.useEffect(()=>{Zi("text")},[O,A]),H==="loading")return t.jsx(ga,{className:k,style:C,title:d??Qn,label:S("reader.loading")});if(H==="missing"||!N||!le)return t.jsx("div",{className:k,style:{...C,...ha},children:S("reader.noText")});if(F==="failed")return t.jsx("div",{className:k,style:{...C,...ha},children:S("reader.tocFailed")});if(!X)return t.jsx(ga,{className:k,style:C,title:d??Qn,label:S("reader.tocLoading")});const Xt=Vf(le,X),Tp=Gf(X,Ke,Xt,_,P),Ji=N.versions.map(E=>({key:E.key,label:ke.textVersionLabel(E),optionLabel:_(ke.textVersionLabel(E)),sourceName:xa(E)?S("reader.originalSource"):E.source_name?_(E.source_name):void 0,license:E.license??void 0,sourceUrl:E.source_url??void 0,primary:E.key===Se})),mt=Df((ps=X.source)==null?void 0:ps.upstream),ei=(typeof d=="string"?_(d):d)??(X.title?_(X.title):Qn?_(Qn):void 0),as=le.edition_label?_(le.edition_label):void 0,Qi=ei?t.jsx("a",{href:B(n),title:S("reader.viewEntry"),onClick:l?E=>{E.metaKey||E.ctrlKey||(E.preventDefault(),l(n))}:void 0,children:ei}):void 0,zp=Qi&&as?t.jsxs(t.Fragment,{children:[Qi,t.jsxs("span",{className:"bim-rd-ed",children:["·",as]})]}):Qi,Np=os.length>0?_(os.slice(0,2).map(E=>`${E.dynasty?`〔${E.dynasty}〕`:""}${E.name}${` ${E.role||S("reader.defaultRole")}`}`).join("、")):void 0,er=J?Zc(J,Xt,_,P):void 0,Zt=P&&!!(se!=null&&se.json),Jt=(se==null?void 0:se.json)??null,ln=(se==null?void 0:se.md)??null,ls=Zt&&!Ce&&Dc(Jt.sections),Ip=ls&&!(ln&&ge.readingMode==="paragraph"&&ji(ln)),Ep=Zt&&ls?t.jsx(gf,{juan:Jt,view:ss,onView:Zi,textHasEntries:Ip}):void 0,Rp=!0,ti=ln?ln.replace(/^##\s+[^\n]+\n+/,""):null,ni=xa(le),Ht=ni?S("reader.originalSource"):le.source_name?_(le.source_name):void 0,Lp=(typeof c=="string"?_(c):c)??(ni?void 0:Ht??_(ke.textVersionLabel(le))),Ap=(Y==null?void 0:Y.hasNorm)===!0;return t.jsxs(Yl,{className:k,style:C,title:zp,subtitle:Lp,byline:Np,current:er,pagerUnit:Xt,rail:Ep,revisedAt:x,backHref:v,backLabel:y,onReportError:f?E=>f({...E,bookTitle:typeof ei=="string"?ei:void 0,entryId:n}):void 0,workLinkToggle:Zt&&!Ce&&!!l&&!!(Jt!=null&&Jt.sections.some(E=>E.work_id)),toc:Tp,tocCaption:S("reader.tocCaption",{n:X.chapters.length,unit:_(Xt)}),tocHeader:P&&X.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:Ce?S("reader.searchChaptersPlaceholder"):S("reader.searchUnitPlaceholder",{unit:_(Xt)}),"aria-label":Ce?S("reader.searchChapters"):S("reader.searchUnit",{unit:_(Xt)}),value:fe,onChange:E=>de(E.target.value)}):void 0,activeKey:O??null,onSelect:D,images:I.images,renderImageOverlay:h,imagePanel:Y?"open":u,isWarpMode:!!Y,customImagePanel:Y&&rs?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Cp,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",outline:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px 6px",fontSize:12,color:r("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4},children:t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[Q.size>0&&t.jsxs("button",{type:"button",onClick:()=>ye(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",Q.size,")"]}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2},"data-testid":"facsimile-zoom-tools",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"缩小",title:"缩小",disabled:Ie<=1,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Ie*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Ie>=6,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Ie===1,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Wf,{ref:Be,resetKey:Ye,onScaleChange:De,style:{flex:1,minHeight:0},children:t.jsx(Ro,{imageUrl:_p,pageData:rs,selectedCharIds:Q,hoveredCharId:We,preserveMargins:Le,onCharClick:E=>{ye(Te=>{const Ge=new Set(Te);return Ge.has(E)?Ge.delete(E):(Ge.clear(),Ge.add(E)),Ge});const ue=document.querySelector(`[data-char-id="${E}"]`);ue&&ue.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:He})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":S("reader.facsimilePager"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"6px 4px 0",fontSize:13,color:r("meta-fg")},children:[t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:Xi<=0,onClick:()=>Sn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Ye,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 8px",background:r("rule"),borderRadius:10},children:["第",t.jsx("input",{type:"text",inputMode:"numeric","data-testid":"facsimile-page-input","aria-label":S("reader.facsimilePageInput"),size:Math.max(2,String(qi??Ye).length),value:qi??String(Ye),onFocus:E=>E.currentTarget.select(),onChange:E=>$p(E.target.value),onKeyDown:E=>{E.key==="Enter"?(E.preventDefault(),is()):E.key==="Escape"&&(Jn.current=null,Ki(null)),E.stopPropagation()},onBlur:is,style:{width:`${Math.max(2,String(qi??Ye).length)+1}ch`,minHeight:28,textAlign:"center",font:"inherit",border:`1px solid ${r("rule")}`,borderRadius:4,background:"transparent",color:"inherit"}}),"葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:Xi<0||Xi>=Et.length-1,onClick:()=>Sn(1),children:"›"})]})]}):void 0,settingsAnnotate:Y?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${Ne?"bim-rd-on":""}`,"aria-pressed":Ne,title:"切换外挂现代断句标点",onClick:()=>Pe(E=>!E),children:Ne?"标点":"无标点"}):void 0,prefs:ge,onPrefsChange:T,versions:Ji.length>1?Ji:void 0,currentVersionKey:Ji.length>1?le.key:void 0,onVersionChange:re,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:ji(ln),allowVertical:m,origScriptAvailable:Ap,contentLoading:ve,children:[(ve||pe&&!Y&&!Zt&&ti==null)&&t.jsx(sn,{}),!ve&&Y&&t.jsxs("article",{className:"bim-rd-prose",style:{marginTop:0},children:[t.jsxs("header",{style:{marginBottom:16},children:[t.jsx("h1",{className:"bim-rd-h1",children:J!=null&&J.title?_(J.title):er}),(Ht||le.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Ht,le.license&&t.jsxs(t.Fragment,{children:[Ht&&t.jsx("span",{className:"bim-rd-dot"}),le.license]})]})]}),t.jsx(Po,{pageData:Y,pages:Y.pages,punctuations:Y.punctuations||Hf,selectedCharIds:Q,hoveredCharId:We,onSelectionChange:Sp,onCharClick:E=>{ye(Te=>{const Ge=new Set(Te);return Ge.has(E)?Ge.delete(E):(Ge.clear(),Ge.add(E)),Ge});const ue=parseInt(E.split(":")[0],10);isNaN(ue)||Z(ue)},onCharHover:He,mode:"horizontal",showPunctuation:Ne,entities:Me,entityTransport:i,onEntityNavigate:j,onVisiblePageChange:E=>{Date.now()>=ts.current&&Z(E)},convert:_,scrollToPage:Qe,pageBreaks:ge.pageBreaks,pageIndicatorY:ge.pageIndicatorY,onPageIndicatorYChange:E=>T({pageIndicatorY:E}),quoteStyle:ge.quoteStyle,bookTitleStyle:ge.bookTitleStyle,showWorks:ge.showWorks})]}),!ve&&!Y&&Zt&&Jt&&t.jsx(mf,{juan:Jt,rawText:ln,positionLabel:qf(J,X,Xt,_),groupLabel:Kf(X,O??null),index:Uf(n,X),searchQuery:fe,onNavigate:l,transport:i,workLabelCache:Je,prefs:ge,view:ss,onViewChange:Zi},`${A}/${O}`),!ve&&!Y&&!Zt&&ti!=null&&J&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:J.title?_(J.title):er}),(Ht||le.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ni&&Ht&&t.jsx(t.Fragment,{children:Ht}),!ni&&le.source_name&&t.jsxs(t.Fragment,{children:[S("reader.textSource")," ",le.source_url?t.jsx("a",{className:"bim-rd-link",href:le.source_url,target:"_blank",rel:"noreferrer",children:_(le.source_name)}):_(le.source_name)]}),Ht&&le.license&&t.jsx("span",{className:"bim-rd-dot"}),le.license]}),mt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[S("reader.upstream")," ",mt.url?t.jsx("a",{className:"bim-rd-link",href:mt.url,target:"_blank",rel:"noreferrer",children:_(mt.name??mt.url)}):_(mt.name??""),mt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),mt.license_url?t.jsx("a",{className:"bim-rd-link",href:mt.license_url,target:"_blank",rel:"noreferrer",children:mt.license}):mt.license]}),mt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Al,{text:mt.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(_o,{text:ti,mode:ge.readingMode,tables:Rp,gujiMarkdown:!0,bookMarking:So(ge),quoteStyle:ge.quoteStyle})})]}),!ve&&!pe&&!Y&&!Zt&&ti==null&&J&&t.jsx("div",{className:"bim-rd-state",children:S("reader.chapterFailed")}),!ve&&X.references&&X.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:S("reader.references")}),t.jsx("ol",{children:X.references.map((E,ue)=>t.jsxs("li",{children:[E.url?t.jsx("a",{className:"bim-rd-link",href:E.url,target:"_blank",rel:"noopener noreferrer",children:_(E.title)}):t.jsx("span",{children:_(E.title)}),E.author&&t.jsxs("span",{children:[",",_(E.author)]}),E.note&&t.jsxs("span",{children:["。",_(E.note)]})]},ue))})]})]})};function xa(e){return e.is_original===!0||e.source==="original"}function qf(e,n,i,o){var a,l;if(!e)return;const s=(l=(a=n.juan_metadata)==null?void 0:a[e.file])==null?void 0:l.vol_label;return o(s?`${s}冊`:`${i}${e.n}`)}function Kf(e,n){if(!n)return;const i=o=>{var s;for(const a of o??[]){const l=i(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return i(e.juan_groups)}function Xf(e,n,i){const[o,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const Jc={bug:{key:"bug",color:r("danger")},resource:{key:"resource",color:r("primary")},suggestion:{key:"suggestion",color:r("primary")},other:{key:"other",color:r("desc-fg")}},Zf=Jc.other,Qc={pending:{key:"pending",color:r("warning")},in_progress:{key:"in_progress",color:r("primary")},resolved:{key:"resolved",color:r("success")},wontfix:{key:"wontfix",color:r("desc-fg")},duplicate:{key:"duplicate",color:r("desc-fg")}},Jf=Qc.pending;function Qf(e){try{const n=new Date(e),i=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())} ${i(n.getHours())}:${i(n.getMinutes())}`}catch{return e}}function ex(e,n){if(!e)return!1;try{const i=new URL(e,n);if(i.protocol!=="http:"&&i.protocol!=="https:")return!1;const o=new URL(n);return i.hostname===o.hostname}catch{return!1}}const Wo=({items:e,loading:n})=>{const i=it(),{t:o,convert:s}=ne();return n?t.jsx(sn,{}):e.length===0?t.jsx("div",{style:tx,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=Jc[a.type]||Zf,d=Qc[a.status]||Jf,c=typeof window<"u"&&ex(a.pageUrl,window.location.href);return t.jsxs("div",{style:nx,children:[t.jsxs("div",{style:ix,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...ba,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...ba,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:rx,children:Qf(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:ox,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:mr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:mr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:mr,children:a.pageUrl}))]}),t.jsx("div",{style:sx,children:s(a.content)}),a.reply&&t.jsxs("div",{style:ax,children:[t.jsx("div",{style:lx,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},tx={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},nx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},ix={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},ba={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},rx={fontSize:"12px",color:r("desc-fg")},ox={fontSize:"12px",marginBottom:"6px"},mr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},sx={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},ax={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},lx={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},Or=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ee(),[d,c]=g.useState(null),[p,h]=g.useState([]),[u,m]=g.useState("recommend"),[f,x]=g.useState([]),[v,y]=g.useState(!1),$=o??u,b=R=>{m(R),s==null||s(R)},[w,j]=g.useState(!0),[k,C]=g.useState(null),[S,_]=g.useState(null),[L,z]=g.useState(null);g.useEffect(()=>{let R=!1;if(e.getCounts)return e.getCounts().then(H=>{R||c({works:H.works,books:H.books,collections:H.collections})}).catch(()=>{}),()=>{R=!0}},[e]),g.useEffect(()=>{let R=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const q=await e.getRecommended();if(q!=null&&q.groups)return q.groups.flatMap(te=>te.items.map(ae=>({...ae,group:te.name})))}catch{}return[]})().then(async q=>{if(R)return;const te=q.filter(V=>V.id);if(te.length===0){j(!1);return}const ae=await Promise.all(te.map(async V=>{if(V.type)return{id:V.id,title:V.title,type:V.type,author:V.author,dynasty:V.dynasty,role:V.role,edition:V.edition,has_text:V.has_text,has_image:V.has_image,has_collated:V.has_collated,subtype:V.subtype,primary_name:V.primary_name,group:V.group,fallbackDescription:V.description};try{let G=null;if(e.getEntry)G=await e.getEntry(V.id);else{const me=await e.getItem(V.id);me&&(G={id:V.id,title:me.title||V.id,type:me.type||"work"})}if(G)return{...G,group:V.group,fallbackDescription:V.description}}catch{}return{id:V.id,title:V.title,type:ke.extractType(V.id),group:V.group,fallbackDescription:V.description}}));R||(h(ae.filter(V=>V!==null)),j(!1))}),()=>{R=!0}},[e,i]);const T=g.useRef(!1),B=g.useRef(!1),W=g.useRef(!1);g.useEffect(()=>{if($!=="catalog"||T.current)return;const R=e.getCatalogProgress??e.getResourceProgress;if(!R)return;T.current=!0;let H=!1;return R.call(e).then(q=>{H||C(q)}).catch(()=>{T.current=!1}),()=>{H=!0}},[e,$]),g.useEffect(()=>{if($!=="collection"||B.current||!e.getCollectionProgress)return;B.current=!0;let R=!1;return e.getCollectionProgress().then(H=>{R||_(H)}).catch(()=>{B.current=!1}),()=>{R=!0}},[e,$]),g.useEffect(()=>{if($!=="site"||W.current||!e.getSiteProgress)return;W.current=!0;let R=!1;return e.getSiteProgress().then(H=>{R||z(H)}).catch(()=>{W.current=!1}),()=>{R=!0}},[e,$]),g.useEffect(()=>{if(!a||$!=="feedback")return;let R=!1;return y(!0),fetch(a).then(H=>H.json()).then(H=>{!R&&H.success&&x(H.items||[])}).catch(()=>{}).finally(()=>{R||y(!1)}),()=>{R=!0}},[a,$]);const N=R=>t.jsx(kn,{type:R,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:r("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"16px"},children:[t.jsx(zn,{label:l.home.recommendTab,active:$==="recommend",onClick:()=>b("recommend")}),t.jsx(zn,{label:l.home.catalogTab,active:$==="catalog",onClick:()=>b("catalog")}),t.jsx(zn,{label:l.home.collectionTab,active:$==="collection",onClick:()=>b("collection")}),t.jsx(zn,{label:l.home.siteTab,active:$==="site",onClick:()=>b("site")}),a&&t.jsx(zn,{label:l.home.feedbackTab,active:$==="feedback",onClick:()=>b("feedback")})]}),$==="recommend"&&t.jsx(cx,{recommended:p,loading:w,onNavigate:n,getIcon:N,t:l}),$==="catalog"&&t.jsx(ya,{progress:k,t:l,onNavigate:n}),$==="collection"&&t.jsx(ya,{progress:S,t:l,onNavigate:n}),$==="site"&&t.jsx(px,{progress:L,t:l,totalWorks:(d==null?void 0:d.works)??0}),$==="feedback"&&a&&t.jsx(Wo,{items:f,loading:v})]})})},zn=({label:e,active:n,onClick:i})=>t.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:r(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${r("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),cx=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=it();if(n)return t.jsx(sn,{});if(e.length===0)return null;const l=new Map;for(const d of e){const c=d.group||s.home.recommendedBrowse;l.has(c)||l.set(c,[]),l.get(c).push(d)}return t.jsx(t.Fragment,{children:Array.from(l.entries()).map(([d,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:d}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(p=>{const h=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i==null||i(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,cursor:"pointer",background:r("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:o(p.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.title,p.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:p.edition})]}),h&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h})]})]},p.id)})})]},d))})},ya=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(sn,{});const o=[...e.resources].sort((d,c)=>d.priority-c.priority),s=["in_progress","done","todo"],a={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},l={in_progress:r("progress-active"),done:r("progress-done"),todo:r("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=o.filter(p=>p.status===d);return c.length===0?null:t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:l[d]}}),a[d]," (",c.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(p=>t.jsx(dx,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},dx=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=it(),a=e.total>0?Math.round(e.imported/e.total*100):0,l=e.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const d=e.edition?`${e.name}·${e.edition}`:e.name,c=e.collection_id||e.work_id;return c&&o?t.jsx("a",{href:s(c),onClick:p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},onMouseEnter:p=>p.currentTarget.style.borderBottomStyle="solid",onMouseLeave:p=>p.currentTarget.style.borderBottomStyle="dashed",children:d}):e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:d}):d})()}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:r("widget-border"),color:r("desc-fg"),whiteSpace:"nowrap"},children:e.collection_id?n.indexType.collection:e.work_id?n.indexType.work:l})]}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?xt(n.home.progressFormat,{imported:String(e.imported),total:String(e.total)}):n.home.totalPending})]}),e.total>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:i,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},px=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(sn,{});const o=[...e.resources].sort((c,p)=>c.priority-p.priority),s=o.filter(c=>c.imported>0),a=o.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=i>0?Math.round(l/i*100):0;return t.jsxs("div",{children:[i>0&&t.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${r("primary")} 6%, transparent)`,fontSize:"13px",color:r("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",i.toLocaleString()," ",n.indexType.work," (",d,"%)"]}),s.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(ja,{item:c,t:n,totalWorks:i},c.id))})]}),a.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(ja,{item:c,t:n,totalWorks:i},c.id))})]})]})},ja=({item:e,t:n,totalWorks:i})=>{const o=i>0?Math.round(e.imported/i*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:t.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:e.name}):e.name})}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${o}%)`:n.home.statusTodo})]}),e.imported>0&&i>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${o}%`,borderRadius:"2px",background:r("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},va="(max-width: 768px)";function ux(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(va).matches);return g.useEffect(()=>{const i=window.matchMedia(va),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const mx=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var B;const a=Ee(),{convert:l}=Oe(),d=ux(),[c,p]=g.useState(null),[h,u]=g.useState(null),[m,f]=g.useState(!1),[x,v]=g.useState("detail"),[y,$]=g.useState([]),[b,w]=g.useState(!1),j=g.useCallback(async W=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){$([]);return}w(!0);try{if(e.getCollectionCatalogs){const N=await e.getCollectionCatalogs(W);$(N||[])}else if(e.getCollectionCatalog){const N=await e.getCollectionCatalog(W);$(N?[{resource_id:"",data:N}]:[])}}catch{$([])}finally{w(!1)}},[e]),k=g.useCallback(async W=>{if(i){i(W);return}p(W),u(null),$([]),v("detail"),f(!0);try{const N=await e.getItem(W.id);N&&(u(N),N.type==="collection"&&j(W.id))}catch(N){console.error("加载详情失败:",N)}finally{f(!1)}},[e,i,j]),C=g.useCallback(async W=>{u(null),$([]),v("detail"),f(!0);try{const N=await e.getItem(W);N&&(u(N),p({id:W,title:N.title||W,type:N.type||"book"}),N.type==="collection"&&j(W))}catch(N){console.error("导航失败:",N)}finally{f(!1)}},[e,j]),S=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,_=(h==null?void 0:h.type)==="collection"&&(y.length>0||b)||(h==null?void 0:h.type)==="work"&&S,L=d&&(m||h),z=g.useCallback(()=>{p(null),u(null),$([]),v("detail")},[]),T=t.jsx(t.Fragment,{children:m?t.jsx(sn,{}):h?t.jsxs(t.Fragment,{children:[(_||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${r("widget-border")}`,padding:d?"0 12px":"0 48px",background:r("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[_&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>v("detail"),style:di(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:di(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&y.map(W=>t.jsx("button",{onClick:()=>v(`catalog:${W.resource_id}`),style:di(x===`catalog:${W.resource_id}`),children:W.short_name?`${l(W.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},W.resource_id)),h.type==="work"&&S&&t.jsx("button",{onClick:()=>v("collated"),style:di(x==="collated"),children:a.detailTab.collatedEdition})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),t.jsx("div",{style:{padding:d?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:x==="detail"?t.jsx(io,{data:h,transport:e,onNavigate:C}):x.startsWith("catalog:")?t.jsx(ro,{data:(B=y.find(W=>`catalog:${W.resource_id}`===x))==null?void 0:B.data,onNavigate:C}):x==="collated"?t.jsx(Oo,{id:h.id,transport:e,onNavigate:C}):null})]}):t.jsx(Or,{transport:e,onNavigate:C,recommendedIds:o})});return d?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:L?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${r("widget-border")}`,background:r("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:z,style:{padding:"4px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",a.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:T})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Sr,{transport:e,onEntryClick:k,hideModeIndicator:n}),!h&&t.jsx(Or,{transport:e,onNavigate:C,recommendedIds:o})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${r("widget-border")}`,display:"flex",flexDirection:"column",background:r("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(Sr,{transport:e,onEntryClick:k,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:T})]})};function di(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const hx=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[h,u]=g.useState(null),[m,f]=g.useState("horizontal"),[x,v]=g.useState(!0),y=g.useRef(null),$=g.useCallback(k=>{p(new Set(k))},[]),b=g.useCallback(k=>{if(p(C=>{const S=new Set(C);return S.has(k)?S.delete(k):(S.clear(),S.add(k)),S}),y.current){const C=y.current.querySelector(`[data-char-id="${k}"]`);C&&C.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),w=()=>{var k;p(new Set),window.getSelection&&((k=window.getSelection())==null||k.removeAllRanges())},j=i.length>0?i:e.punctuations||[];return t.jsxs("div",{className:`guji-reader-container ${l}`,style:d,children:[t.jsxs("header",{className:"guji-reader-header",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&t.jsx("button",{type:"button",onClick:a,className:"guji-reader-btn",style:{marginRight:6},children:"‹ 返回"}),t.jsx("span",{className:"guji-reader-title",children:o||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:r("meta-fg")},children:s}),t.jsx("span",{className:"guji-reader-tag",children:"WebGL 客户端透视矫正对读"})]}),t.jsxs("div",{className:"guji-reader-actions",children:[t.jsxs("span",{style:{fontSize:"0.85rem",color:r("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:r("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:w,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>v(k=>!k),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(k=>k==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:m==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(Ro,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:b,onCharHover:u})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:m==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Po,{pageData:e,punctuations:j,selectedCharIds:c,hoveredCharId:h,onSelectionChange:$,onCharClick:b,onCharHover:u,mode:m,showPunctuation:x})]})]})]})},gx=e=>typeof e=="string"&&Array.from(e).length===1;function fx(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!gx(s.pre_char)||i.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char??void 0})}return i}function xx(e){var i;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const o of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((i=o==null?void 0:o.canvas)==null?void 0:i.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const ed=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function lt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const bx=new Set(["main","solo","jz_r","jz_l"]),yx=new Set(["body","banxin","blank"]);function jx(e){const n={};return typeof e.lane=="string"&&bx.has(e.lane)&&e.lane!=="main"&&(n.lane=e.lane),e.lacuna===!0&&(n.lacuna=!0),e.guess===!0&&(n.guess=!0),typeof e.zi=="string"&&e.zi&&(n.zi=e.zi),n}function vx(e){const n={};typeof e.kind=="string"&&yx.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=lt(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=lt(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function hr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function kx(e){return typeof e=="string"&&Array.from(e).length===1}function td(e){const n=new Map,i={badAnchor:0,badChar:0,badWhy:0,notObject:0},o=e&&typeof e=="object"?e.items:void 0;for(const s of Array.isArray(o)?o:[]){if(!s||typeof s!="object"){i.notObject++;continue}const{a,t:l,why:d}=s;if(typeof a!="string"||!ed.test(a)){i.badAnchor++;continue}if(!kx(l)){i.badChar++;continue}if(d!==void 0&&d!=="异体"){i.badWhy++;continue}n.set(a,l)}return{map:n,dropped:i}}function nd(e){return td(e).map}function wx(e,n,i){var h,u,m,f,x,v,y,$,b,w;const o=i==null?null:nd(i),s=new Map,a=new Map;for(const j of hr(n)){const k=lt(j.page);if(k!==void 0){s.set(k,j);for(const C of Array.isArray(j.cells)?j.cells:[]){const S=C==null?void 0:C.box;typeof(C==null?void 0:C.a)=="string"&&Array.isArray(S)&&S.length===4&&S.every(_=>lt(_)!==void 0)&&a.set(C.a,[S[0],S[1],S[0]+S[2],S[1]+S[3]])}}}const l=[],d=new Map,c=new Map;for(const j of hr(e)){const k=lt(j.page);k!==void 0&&typeof j.label=="string"&&j.label&&d.set(k,j.label)}for(const j of hr(e)){const k=lt(j.page);if(k===void 0)continue;const C=[];for(const _ of Array.isArray(j.columns)?j.columns:[]){const L=lt(_==null?void 0:_.col);if(L===void 0)continue;const z=[];for(const B of Array.isArray(_.cells)?_.cells:[]){const W=ed.exec(String((B==null?void 0:B.a)??""));if(!W||typeof B.c!="string")continue;const N=parseInt(W[3],10),R=o==null?void 0:o.get(B.a);z.push({id:B.a,char:B.c,slot:N,pos:N,sub:W[4]||null,bbox:a.get(B.a)??null,...jx(B),...R!==void 0&&R!==B.c?{norm:R}:{}})}const T=vx(_);(z.length>0||T.kind==="blank")&&C.push({col:L,chars:z,...T})}if(!C.some(_=>_.chars.length>0)){C.length>0&&c.set(k,C);continue}C.sort((_,L)=>_.col-L.col);const S=s.get(k);l.push({page:k,seq:String(((h=S==null?void 0:S.canvas)==null?void 0:h.seq)??""),width:lt((u=S==null?void 0:S.canvas)==null?void 0:u.width)??lt((m=S==null?void 0:S.image)==null?void 0:m.width)??0,height:lt((f=S==null?void 0:S.canvas)==null?void 0:f.height)??lt((x=S==null?void 0:S.image)==null?void 0:x.height)??0,...typeof j.label=="string"&&j.label?{label:j.label}:{},columns:C})}const p=new Set(l.map(j=>j.page));for(const[j,k]of s){const C=(v=k==null?void 0:k.canvas)==null?void 0:v.seq;p.has(j)||typeof C!="string"&&typeof C!="number"||String(C)===""||l.push({page:j,seq:String(C),width:lt((y=k.canvas)==null?void 0:y.width)??lt(($=k.image)==null?void 0:$.width)??0,height:lt((b=k.canvas)==null?void 0:b.height)??lt((w=k.image)==null?void 0:w.height)??0,...d.has(j)?{label:d.get(j)}:{},columns:c.get(j)??[]})}return l.sort((j,k)=>j.page-k.page)}const Sx=({data:e,onNavigate:n,className:i,style:o})=>{var h;const{t:s,convert:a}=ne(),[l,d]=g.useState(((h=e.divisions[0])==null?void 0:h.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(u=>t.jsx(_x,{division:u,expanded:l===u.name,onToggle:()=>d(l===u.name?null:u.name),expandedCat:c,onCatToggle:m=>p(c===m?null:m),onNavigate:n},u.name))})]})},_x=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ne(),c=e.categories.reduce((p,h)=>{const u=h.stats||{zhulu:0,cunmu:0};return p+(u.zhulu||0)+(u.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${r("primary")} 6%, transparent)`:r("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:r("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg")},children:[l("catalogPage.divisionStat",{cats:e.categories.length,books:c}),t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(p=>{const h=`${e.name}/${p.name}`;return t.jsx($x,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},$x=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,u,m;const{t:s,convert:a}=ne(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((h=e.books)==null?void 0:h.cunmu)||[],c=(((u=e.stats)==null?void 0:u.zhulu)||l.length)+(((m=e.stats)==null?void 0:m.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(ka,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(ka,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},ka=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ne(),a=it(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,h)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:r("fg")},children:p.work_id&&i?t.jsx("a",{href:a(p.work_id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.author).slice(0,20)})]},h))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:o("catalogPage.expandAllN",{n:n.length})})]})},wt=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Ee();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:r("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o,i&&t.jsx("button",{onClick:i,style:Tx,children:"AI"}),n&&t.jsx("button",{onClick:n,style:Cx,children:a.action.save})]})]}),s]})},Cx={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Tx={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},ft=({label:e,value:n,onChange:i,placeholder:o,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>i(a.target.value),placeholder:o,disabled:s,style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),on=({value:e,onChange:n,placeholder:i})=>{const o=g.useRef(null);return g.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},ki=({children:e,color:n,style:i})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||r("primary-soft"),color:r(n?"on-color-fg":"fg"),...i},children:e});function zx(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const gi=({value:e,onChange:n,label:i})=>{const[o,s]=g.useState(!1),a=g.useRef(null),l=zx(e||"");return g.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:wa,children:i}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${r("input-border")}`,borderRadius:"2px",background:r("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:r("fg")},children:l.name}),t.jsx(ki,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:wa,children:i}),t.jsx("input",{ref:a,type:"text",value:e||"",onChange:d=>n(d.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},wa={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function Nx(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function Ix(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const id=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Ee(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=u=>{n(e.filter((m,f)=>f!==u)),s===u&&a(null)},c=(u,m,f)=>{const x=[...e];x[u]={...x[u],[m]:f},n(x)},p=(u,m)=>{const f=[...e];f[u]={...f[u],type:m,id:"",name:""},n(f),m==="bookID"&&i&&i(x=>{const v=[...e];v[u]={...v[u],id:x.id,name:x.title,type:"bookID"},n(v)})},h=u=>{i&&i(m=>{const f=[...e];f[u]={...f[u],id:m.id,name:m.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===m?null:m),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:u.name||`${o.editor.sourcePlaceholder} ${m+1}`}),u.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Nx(u.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Ix(u.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(m)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===m&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!u.type&&t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(m,"bookID"),style:{...Sa,borderColor:r("source-bookid"),color:r("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(m,"url"),style:{...Sa,borderColor:r("source-url"),color:r("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),u.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Lt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:_a,children:o.action.changeType})]}),u.id&&u.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:r("bg"),border:`1px solid ${r("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:r("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:u.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:u.id})]}),t.jsx("button",{onClick:()=>h(m),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>h(m),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),u.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Lt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:_a,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:u.name,onChange:f=>c(m,"name",f.target.value),placeholder:o.editor.sourceNamePlaceholder,style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:u.id,onChange:f=>c(m,"id",f.target.value),placeholder:"https://...",style:dn})]})]}),u.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${r("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...Lt,opacity:.7},children:o.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:u.details,onChange:f=>c(m,"details",f.target.value),placeholder:o.editor.detailsPlaceholder,style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:u.position,onChange:f=>c(m,"position",f.target.value),placeholder:"如: 卷三, p.52",style:dn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:u.version,onChange:f=>c(m,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:u.processor_version,onChange:f=>c(m,"processor_version",f.target.value),placeholder:"如: v0.1",style:dn})]})]})]})]})})]},m)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Lt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},dn={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Sa={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:r("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},_a={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function rd(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(i=>({id:i.id||"",name:i.name||"",type:i.type||"",details:i.details||"",position:i.position||"",version:i.version||"",processor_version:i.processor_version||""}))}catch{}return[]}function od(e){return!e||e.length===0?"":JSON.stringify(e)}const sd=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:u,onUnlinkEntity:m,onViewEntity:f,onCreateAndLink:x,onSaveRelations:v})=>{const y=Ee();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),v&&t.jsx("button",{onClick:v,style:Ex,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Nn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>m("collectionId"),onLink:()=>u("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&h&&h.length>0&&t.jsx(pn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${h.length})`,entities:h,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.parentWork,entity:o,onView:f,onUnlink:()=>m("parentWorkId"),onLink:()=>u("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),d&&d.length>0&&t.jsx(pn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(pn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(pn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Nn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>m("parentCollectionId"),onLink:()=>u("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(pn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(pn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},Nn=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:u})=>{const m=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:f}),t.jsx("span",{children:n})]}),i?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:r("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:ad(i.type)}),t.jsx("span",{style:{fontWeight:500},children:i.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:i.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx($a,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx($a,{onClick:s,title:u,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(Wr,{onClick:a,children:d}),t.jsx(Wr,{onClick:l,primary:!0,children:c})]})]})},pn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),h=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),u=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",m=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:u}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(f=>t.jsxs("div",{onClick:()=>o(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:ad(f.type)}),t.jsx("span",{children:f.title})]},f.id)),i.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:r("link-fg"),cursor:"pointer"},children:[d," (",i.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(Wr,{onClick:s,primary:!0,children:["+ ",a]})})]})},$a=({onClick:e,title:n,danger:i,children:o})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:i?r("danger"):"inherit",opacity:.7},children:o}),Wr=({onClick:e,primary:n,children:i})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${r("widget-border")}`,borderRadius:"4px",background:n?r("primary"):"transparent",color:n?r("primary-fg"):"inherit",cursor:"pointer"},children:i});function ad(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Ex={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},ld=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,u]=g.useState(""),m=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(u(""),d(""))},[e]);const f=y=>{u(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",v=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:Rx,children:t.jsxs("div",{style:Lx,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:i}),t.jsx("button",{onClick:s,style:Ax,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:Mx})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:gr,children:"搜索中..."}):m.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>t.jsxs("div",{onClick:()=>o(y),style:Px,children:[t.jsx("span",{style:{fontSize:"16px"},children:v}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):h?t.jsxs("div",{style:gr,children:["未找到匹配的",x]}):t.jsxs("div",{style:gr,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:Bx,children:["创建新",x,"并关联"]})]})]})})},Rx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Lx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},Ax={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Mx={width:"100%",padding:"10px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},Px={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},gr={padding:"20px",textAlign:"center",color:r("desc-fg")},Bx={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Ca={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Ox={work:"📜",book:"📖",collection:"📚",entity:"👤"},cd=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var m,f;(m=c.current)==null||m.focus(),(f=c.current)==null||f.select()},100))},[e,o==null?void 0:o.title]);const p=m=>{m.key==="Enter"&&l.trim()?h():m.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const u=()=>{switch(i){case"parentWorkId":return"创建父作品";case"workId":return"创建所属作品";case"collectionId":return"创建所属丛编";case"parentCollectionId":return"创建父丛编";case"childWork":return"创建子作品";case"childBook":case"siblingBook":return"创建书籍";case"childCollection":return"创建子丛编";default:return`创建新${Ca[n]}`}};return t.jsx("div",{style:Wx,onClick:m=>{m.target===m.currentTarget&&a()},children:t.jsxs("div",{style:Fx,onClick:m=>m.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ox[n]}),t.jsx("span",{children:u()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:m=>d(m.target.value),onKeyDown:p,placeholder:`请输入${Ca[n]}名称...`,style:Hx})]}),((o==null?void 0:o.author)||(o==null?void 0:o.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),background:r("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(o==null?void 0:o.author)&&t.jsxs("div",{children:["作者: ",o.author]}),(o==null?void 0:o.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",o.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:Dx,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...Ux,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Wx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Fx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:r("shadow-dialog")},Hx={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box"},Dx={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Ux={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Vx(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function dd(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Gx(e){switch(e){case"work":return r("editor-type-work");case"collection":return r("editor-type-collection");case"book":return r("editor-type-book");default:return r("desc-fg")}}const pd=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:h})=>{const[u,m]=g.useState(""),[f,x]=g.useState([]),[v,y]=g.useState(!1),[$,b]=g.useState("recent");g.useEffect(()=>{e&&(m(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),g.useEffect(()=>{if(!u.trim()){x([]);return}const _=setTimeout(async()=>{y(!0);try{x(await h(u,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(_)},[u,i,h]);const w=g.useCallback(_=>{m(_.target.value),_.target.value.trim()&&b("search")},[]),j=g.useCallback(_=>s?_.filter(L=>L.id!==s):_,[s]);if(!e)return null;const k=n||(i==="all"?"选择实体":`选择${dd(i)}`),C=j(o),S=j(f);return t.jsx("div",{style:qx,children:t.jsxs("div",{style:Kx,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:k}),t.jsx("button",{onClick:c,style:Xx,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:u,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Zx}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),v&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),C.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs(Ta,{active:$==="recent",onClick:()=>b("recent"),children:["最近使用 (",C.length,")"]}),t.jsxs(Ta,{active:$==="search",onClick:()=>b("search"),children:["搜索结果 ",S.length>0&&`(${S.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:$==="recent"&&C.length>0?t.jsx(za,{entities:C,onSelect:d}):u.trim()?v?t.jsx(fr,{message:"搜索中..."}):S.length>0?t.jsx(za,{entities:S,onSelect:d}):t.jsx(fr,{message:"未找到匹配的结果"}):t.jsx(fr,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:Jx,children:l||"创建新实体"})]})]})})},Ta=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),za=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Yx,{entity:i,onClick:()=>n(i)},i.id))}),Yx=({entity:e,onClick:n})=>{const[i,o]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Vx(e.type)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.title,e.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:e.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[t.jsx("code",{style:{fontSize:"10px",background:r("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:e.id}),e.author&&t.jsx("span",{children:e.author}),e.dynasty&&t.jsx("span",{children:e.dynasty})]})]}),t.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:Gx(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:dd(e.type)})]})},fr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),qx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Kx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},Xx={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Zx={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},Jx={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Qx={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},eb={work:"📜",collection:"📚",book:"📖",entity:"👤"},ud=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:u,onRelationsChange:m})=>{var re;const f=Ee(),[x,v]=g.useState(!1),[y,$]=g.useState("work"),[b,w]=g.useState(""),[j,k]=g.useState(""),[C,S]=g.useState([]),[_,L]=g.useState(!1),[z,T]=g.useState(!1),[B,W]=g.useState("work"),[N,R]=g.useState(""),[H,q]=g.useState(),[te,ae]=g.useState(!1),[V,G]=g.useState(null),[me,K]=g.useState([]);g.useRef(null);const le=e.type,Se=le==="work",A=le==="collection",je=le==="book",ce=g.useCallback((D,se)=>{n({...e,[D]:se})},[e,n]),ze=g.useCallback((D,se)=>{w(D),$(se),k(f.editor.selectToLink+f.indexType[se]),S([]),v(!0)},[f]),$e=g.useCallback(D=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,D)},[o,e.id]),Fe=g.useCallback(D=>{s==null||s(D.id,D.type)},[s]),ee=g.useCallback((D,se,_e)=>{const Ae={..._e,author:(_e==null?void 0:_e.author)||e.author,dynasty:_e==null?void 0:_e.dynasty};W(se),R(D),q(Ae),T(!0)},[e.author]),F=g.useCallback((D,se)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,N,{type:B,title:D,inheritData:se}),T(!1)},[o,e.id,N,B]),U=g.useCallback(D=>{if(!D.trim()){S([]);return}L(!0),o!=null&&o.searchEntities&&o.searchEntities(D,y).then(se=>{S(se),L(!1)}).catch(()=>{S([]),L(!1)})},[o,y]),he=g.useCallback(D=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,D.id),v(!1)},[o,e.id,b]),X=g.useCallback(()=>{i()},[i]),O=g.useCallback(D=>{G(()=>D),ae(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(K).catch(()=>{})},[o]),J=g.useCallback((D,se)=>o!=null&&o.searchEntities?o.searchEntities(D,se==="all"?void 0:se):Promise.resolve([]),[o]),oe=g.useCallback(D=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(D),K(se=>[D,...se.filter(_e=>_e.id!==D.id)].slice(0,10)),V==null||V(D),ae(!1),G(null)},[o,V]);return t.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${r("widget-border")}`,paddingBottom:"16px"},children:t.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:eb[le]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(ki,{children:e.id}),t.jsx(ki,{color:Qx[le],children:f.indexType[le]})]})}),t.jsx(wt,{title:f.section.basicInfo,onSave:i,onAskAI:d?()=>d("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[t.jsx(gi,{label:Se?f.editor.workTitle:A?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:D=>ce("title",D)}),je&&t.jsx(gi,{label:f.editor.belongsToWork,value:e.workName||"",onChange:D=>ce("workName",D)}),t.jsx(ft,{label:f.editor.authorLabel,value:e.author||"",onChange:D=>ce("author",D)}),t.jsx(ft,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:D=>ce("publicationYear",D)}),(je||A)&&t.jsx(gi,{label:f.editor.containedIn,value:e.collection||"",onChange:D=>ce("collection",D)}),(je||A)&&t.jsx(ft,{label:f.editor.holderLabel,value:e.holder||"",onChange:D=>ce("holder",D)}),(je||A)&&t.jsx(ft,{label:je?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:D=>ce("pages",D)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(ft,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:D=>ce("firstImage",D)})})]})}),t.jsx(wt,{title:f.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(on,{value:e.description||"",onChange:D=>ce("description",D),placeholder:f.editor.descriptionPlaceholder})}),(((re=e.additional_works)==null?void 0:re.length)||0)>0&&t.jsx(wt,{title:f.section.additionalWorks,onSave:i,children:t.jsx(tb,{items:e.additional_works||[],onChange:D=>ce("additional_works",D)})}),t.jsx(wt,{title:f.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(nb,{items:e.indexed_by||[],onChange:D=>ce("indexed_by",D)})}),t.jsx(wt,{title:f.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(ib,{items:e.emendated_by||[],onChange:D=>ce("emendated_by",D)})}),t.jsx(wt,{title:f.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(kr,{items:e.resources||[],onChange:D=>ce("resources",D),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(wt,{title:f.section.imageResources,onSave:i,children:t.jsx(kr,{items:e.resources||[],onChange:D=>ce("resources",D),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(wt,{title:f.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(id,{items:rd(e.sources||""),onChange:D=>ce("sources",od(D)),onOpenEntityPicker:O})}),(je||A)&&t.jsx(wt,{title:f.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(on,{value:e.provenance||"",onChange:D=>ce("provenance",D),placeholder:f.editor.provenancePlaceholder})}),je&&t.jsx(wt,{title:f.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(on,{value:e.otherEditions||"",onChange:D=>ce("otherEditions",D),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(sd,{entityType:le,entityId:e.id,entityTitle:e.title,parentWork:u==null?void 0:u.parentWork,parentCollection:u==null?void 0:u.parentCollection,belongsToWork:u==null?void 0:u.belongsToWork,belongsToCollection:u==null?void 0:u.belongsToCollection,childWorks:u==null?void 0:u.childWorks,childCollections:u==null?void 0:u.childCollections,containedBooks:u==null?void 0:u.containedBooks,siblingBooks:u==null?void 0:u.siblingBooks,onLinkEntity:ze,onUnlinkEntity:$e,onViewEntity:Fe,onCreateAndLink:ee,onSaveRelations:X}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${r("danger-soft-border")}`,background:r("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:r("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("danger")}`,borderRadius:"4px",background:"transparent",color:r("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),t.jsx(ld,{isOpen:x,entityType:y,title:j,onSelect:he,onCancel:()=>v(!1),onCreate:()=>{v(!1),ee(b,y)},searchResults:C,onSearch:U,isLoading:_,excludeId:e.id}),t.jsx(cd,{isOpen:z,entityType:B,relationField:N,inheritData:H,onConfirm:F,onCancel:()=>T(!1)}),t.jsx(pd,{isOpen:te,title:f.action.selectBookOrWork,filterType:"all",recentEntities:me,excludeId:e.id,onSelect:oe,onCancel:()=>{ae(!1),G(null)},onSearch:J})]})};function tb({items:e,onChange:n}){const i=Ee(),o=(l,d,c)=>{const p=e.map((h,u)=>u===l?{...h,[d]:c}:h);n(p)},s=l=>n(e.filter((d,c)=>c!==l)),a=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((l,d)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(ft,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(ft,{label:i.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>o(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(d),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("muted"),marginTop:"18px"},children:"✕"})]},d)),t.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:i.action.addAdditionalWork})]})}function md({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ee(),[a,l]=g.useState(null),d=(h,u,m)=>{const f=e.map((x,v)=>v===h?{...x,[u]:m||void 0}:x);n(f)},c=h=>{n(e.filter((u,m)=>m!==h)),a===h&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((h,u)=>{const m=a===u;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(m?null:u),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:h.source||s.editor.unnamedSource}),h.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(u)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!m&&i&&(h.title_info||h.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[h.title_info,h.title_info&&h.author_info&&" — ",h.author_info]}),m&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ft,{label:s.label.sourceName,value:h.source,onChange:f=>d(u,"source",f)}),t.jsx(ft,{label:s.label.sourceBid,value:h.source_bid||"",onChange:f=>d(u,"source_bid",f)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ft,{label:s.label.titleInfo,value:h.title_info||"",onChange:f=>d(u,"title_info",f)}),t.jsx(ft,{label:s.label.authorInfo,value:h.author_info||"",onChange:f=>d(u,"author_info",f)})]}),t.jsx(ft,{label:s.label.edition,value:h.edition||"",onChange:f=>d(u,"edition",f)})]}),t.jsx(on,{value:h.summary||"",onChange:f=>d(u,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(on,{value:h.comment||"",onChange:f=>d(u,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(on,{value:h.additional_comment||"",onChange:f=>d(u,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},u)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:o})]})}function nb({items:e,onChange:n}){const i=Ee();return t.jsx(md,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function ib({items:e,onChange:n}){const i=Ee();return t.jsx(md,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function hd(e){var d,c,p,h,u,m,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",i=((p=e.publication_info)==null?void 0:p.year)||"",o=((h=e.current_location)==null?void 0:h.name)||"",s=(u=e.page_count)!=null&&u.number?String(e.page_count.number):((m=e.page_count)==null?void 0:m.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:i,holder:o,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const v=x.related_works.find(y=>y.relation==="part_of");v&&(l.parentWorkId=v.id,l.parentWorkName=v.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(f=x.contained_in[0])==null?void 0:f.id)}return l}function rb(e){const n={id:e.id,title:e.title,type:e.type,description:e.description?{text:e.description}:void 0,authors:e.author?[{name:e.author}]:void 0,publication_info:e.publicationYear?{year:e.publicationYear}:void 0,current_location:e.holder?{name:e.holder}:void 0,page_count:e.pages?{number:parseInt(e.pages)||0,description:e.pages}:void 0,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};return e.type==="work"&&e.parentWorkId&&(n.related_works=[{id:e.parentWorkId,title:e.parentWorkName||"",relation:"part_of"}]),e.type==="book"&&(n.work_id=e.workId,e.collectionId&&(n.contained_in=[{id:e.collectionId}])),n}const ob=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:h,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:y,headerExtra:$,className:b,style:w}=e,j=Ee(),[k,C]=g.useState(s),S=a?s:k;g.useEffect(()=>{s!==k&&C(s)},[s]);const _=g.useCallback(()=>{const R=S==="view"?"edit":"view";a?a(R):C(R)},[S,a]),[L,z]=g.useState(null);g.useEffect(()=>{i&&o&&o.getItem(i).then(R=>{R&&z(R)})},[i,o]);const T=n||L,B=g.useMemo(()=>T?hd(T):null,[T]),W=a||!n?t.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:S==="edit"?r("accent-bg"):"transparent",color:r(S==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:S==="view"?j.common.switchToEdit:j.common.switchToView,children:S==="view"?j.common.modeEdit:j.common.modeView}):null,N=t.jsxs(t.Fragment,{children:[W,$]});return!T&&!B?t.jsx(sn,{}):S==="view"?t.jsx(io,{data:T,transport:o,onNavigate:p?R=>p(R):void 0,renderLink:h,headerExtra:N,className:b,style:w}):B?t.jsxs("div",{className:b,style:w,children:[N&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:N}),t.jsx(ud,{data:B,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:j.common.noData})},sb=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],gd=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=ne(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,h]=g.useState(""),[u,m]=g.useState("idle"),[f,x]=g.useState(""),v=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),h(""),m("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=v.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(u==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[u,n]),g.useEffect(()=>{if(!e)return;const b=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){m("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),m("success")}catch(b){m("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const $=a&&d.trim()&&u!=="submitting";return t.jsx("div",{style:ab,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:lb,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:cb,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:db,"aria-label":s("feedback.close"),children:"✕"})]}),u==="success"?t.jsxs("div",{style:gb,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),o&&t.jsx("a",{href:o,style:{fontSize:"13px",color:r("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:sb.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...pb,...a===b.value?ub:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:v,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||u==="submitting",style:{...mb,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>h(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||u==="submitting","aria-label":s("feedback.contactLabel"),style:xb}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),u==="error"&&t.jsx("div",{style:fb,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!$,style:{...hb,opacity:$?1:.6,cursor:$?"pointer":"not-allowed"},children:s(u==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},ab={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},lb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},cb={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},db={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},pb={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},ub={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},mb={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},hb={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},gb={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},fb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},xb={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},Fr="--bim-feedback-fab-offset",Hr=48,bb=16,yb=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=ne(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(Fr,`calc(${c+Hr+bb}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Fr)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...jb,zIndex:s??r("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":a("feedback.title"),title:a("feedback.title"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsx(gd,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},jb={position:"fixed",width:`${Hr}px`,height:`${Hr}px`,borderRadius:"50%",border:"none",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},vb=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],fd=({onSubmit:e})=>{const{t:n}=ne(),[i,o]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[h,u]=g.useState(""),m=g.useRef(null);g.useEffect(()=>{i&&setTimeout(()=>{var v;return(v=m.current)==null?void 0:v.focus()},100)},[i]);const f=async()=>{if(!(!i||!s.trim())){p("submitting"),u("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(v){p("error"),u(v instanceof Error?v.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Na,children:t.jsxs("div",{style:$b,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:Cb,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Na,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:vb.map(v=>t.jsxs("button",{onClick:()=>o(v.value),style:{...kb,...i===v.value?wb:{}},children:[t.jsx("span",{children:v.icon})," ",n(`feedback.submitType.${v.value}`)]},v.value))}),t.jsx("textarea",{ref:m,value:s,onChange:v=>a(v.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Sb}}),t.jsx("input",{type:"text",value:l,onChange:v=>d(v.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:zb}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:f,disabled:!x,style:{..._b,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:Tb,children:h})]})},Na={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},kb={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},wb={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Sb={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},_b={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},$b={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},Cb={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Tb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},zb={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Ia(e){return typeof e=="function"?e():e??"/api/feedback"}const xd=({resourceId:e,apiUrl:n})=>{const{t:i}=ne(),[o,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=Ia(n);l(!0);try{const u=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();u.success&&s(u.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const h=Ia(n),u=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!u.ok){const m=await u.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Wo,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(fd,{onSubmit:c})})]})},Oi=8;async function Wi(e,n,i,o){const s=Number.isFinite(n)?Math.max(1,Math.floor(n)):1,a=new Array(e.length);let l=0;const d=Array.from({length:Math.min(s,Math.max(1,e.length))},async()=>{for(;l<e.length&&!(o!=null&&o());){const c=l++;a[c]=await i(e[c],c)}});return await Promise.all(d),a}const Nb=_i["zh-Hant"].relation,Ib=_i["zh-Hant"].lossStatus,Eb=_i["zh-Hant"].resourceKind,Fi=vn("zh-Hant"),Fo=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Ea(e,n=Fi){return e?Fo(Nb,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function Rb(e,n=Fi){return Fo(Ib,e)?n(`detail.lossStatus.${e}`):e}function Lb(e,n=Fi){return Fo(Eb,e)?n(`detail.resourceKind.${e}`):""}function Ho({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=ne(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=uo(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(nt,{id:a.entity_id,label:o(a.name),onNavigate:n,renderLink:i,dense:!0}):o(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:o(d)})]},l)})}):null}function bd(e,n,i=Fi){var c,p;const o=co(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(u=>u.group_role!=="mirror"),mirrors:h.items.filter(u=>u.group_role==="mirror")})),a=o.buckets.filter(h=>h.key==="image"||h.key==="textImage").flatMap(h=>h.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(h=>h.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:i("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=o.buckets.find(h=>h.key==="text"))==null?void 0:p.items)??[],groups:s}}function yd(e,n){const i=(e.url?bn(e.url):void 0)||e.name,o=Ql(e,n);return o?`${i}(${o})`:i}function Do({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ne(),[a,l]=g.useState(!1),d=Si(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(yd(e,n)),h=yn(e),u=Ri(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const m=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:o("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?o("colorMode.color"):o("colorMode.bw")})]}):null;return h?t.jsxs("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,m]})})(),u&&t.jsx("span",{className:"bim-d-meta",children:s(u)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(yo,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(m=>!m),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function jd({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=ne();return t.jsx(t.Fragment,{children:e.map(s=>t.jsxs("div",{className:"bim-d-rg",children:[s.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:o(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:o(s.description)}),s.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:s.rows.map((a,l)=>t.jsx(Do,{item:a,siblings:s.rows,listedVolumeCounts:n},`${a.id||a.url||a.name}-${l}`))})}),s.mirrors.length>0&&t.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&t.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:i("detail.mirror")}),s.mirrors.map((a,l)=>{const d=yn(a),c=o(yd(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?o(a.details):void 0,children:[c," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]},l):t.jsx("span",{style:{marginRight:14},children:c},l)})]})]},s.key))})}const Bn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Dr(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Bn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const Ra=12,Ab=60,vd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var U,he,X;const{t:c,convert:p,messages:h}=ne(),u=g.useMemo(()=>mo({_books:e._books}),[e._books]),[m,f]=g.useState(new Map),[x,v]=g.useState(!1),[y,$]=g.useState(""),[b,w]=g.useState(!1),j=u.length<=Ab,k=j||x||!!y||b,C=g.useMemo(()=>k?u:u.slice(0,Ra),[u,k]);g.useEffect(()=>{if(!n||C.length===0)return;const O=C.filter(oe=>!m.has(oe));if(O.length===0)return;let J=!1;return Wi(O,Oi,oe=>n.getItem(oe).then(re=>{const D=re??{};return[oe,{id:oe,title:D.title,edition:D.edition,resources:D.resources,publication_info:D.publication_info,current_location:D.current_location,lineage:D.lineage,measure_info:D.measure_info}]}).catch(()=>[oe,{id:oe}]),()=>J).then(oe=>{J||f(re=>{const D=new Map(re);for(const[se,_e]of oe)D.set(se,_e);return D})}),()=>{J=!0}},[n,C,m]);const S=g.useMemo(()=>u.map(O=>m.get(O)??{id:O}),[u,m]),_=u.length>0&&u.every(O=>m.has(O)),L=!!n&&C.some(O=>!m.has(O)),z=j||k,T=g.useMemo(()=>tc(S,e.version_graph,{era:y,scanOnly:b,sort:z?"year":"default"}),[S,e.version_graph,y,b,z]),B=x?T.rows:T.rows.slice(0,Ra),W=T.allRows.filter(O=>O.hasImage).length,N=g.useMemo(()=>(e._related||[]).map(O=>({...O,title:O.title??""})),[e._related]),R=N.filter(O=>O.relation==="collected_in"),H=g.useMemo(()=>{const O=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],J=oe=>{const re=O.indexOf(oe??"");return re<0?O.length:re};return N.filter(oe=>oe.relation!=="collected_in").map((oe,re)=>({r:oe,i:re})).sort((oe,re)=>J(oe.r.relation)-J(re.r.relation)||oe.i-re.i).map(oe=>oe.r)},[N]),q=g.useMemo(()=>{const O=co(e.resources,e.resource_groups);return[...O.mirrors.flatMap(J=>J.items.map(oe=>({r:oe,kind:p(J.label)}))),...O.buckets.flatMap(J=>J.items.map(oe=>({r:oe,kind:p(Lb(J.key,c))})))]},[e.resources,e.resource_groups,p,c]),te=e.indexed_by||[],ae=e.emendated_by||[],V=g.useMemo(()=>{var M,ie,ve;const O=[],J=(ie=(M=e.authors)==null?void 0:M[0])==null?void 0:ie.dynasty;J&&O.push({label:c("workPage.fact.written"),value:p(J)});const oe=Wt(e,h.unit.juan);if(oe){const we=(ve=e.juan_count)==null?void 0:ve.description;O.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(oe),we&&we!==oe?t.jsxs("span",{className:"bim-d-meta",children:["(",p(we),")"]}):null]})})}e.loss_status&&O.push({label:c("workPage.fact.loss"),value:p(Rb(e.loss_status,c))});const re=T.allRows.filter(we=>we.sortYear!=null),D=re.length>0?re.reduce((we,P)=>we.sortYear<=P.sortYear?we:P):null;D!=null&&D.era.era?O.push({label:c("workPage.fact.earliest"),value:p([D.era.era,D.era.reign].filter(Boolean).join(" ")),title:D.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):L&&O.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),ae.length&&O.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:ae.length})});const se=La(e.additional_titles);se.length&&O.push({label:c("workPage.fact.alias"),value:se.map(p).join("、")});const _e=La(e.attached_texts);_e.length&&O.push({label:c("workPage.fact.attached"),value:_e.map(p).join("、")});const Ae=(e.additional_works||[]).map(we=>p(we.book_title)+(we.n_juan!=null?` ${we.n_juan}${h.unit.juan}`:""));return Ae.length&&O.push({label:c("workPage.fact.appendix"),value:Ae.join("、")}),O},[e,p,c,h,L,T.allRows,ae.length]),me=[{value:e._edition_count??u.length,label:c("workPage.stat.editions")},{value:_?W:0,label:c("workPage.stat.hasImage")},{value:te.length,label:c("workPage.stat.catalogs")}],K=ho(e),le=K?[K.l1,K.l2,K.l3,K.l4].filter(Boolean).map(O=>p(O)):[],Se=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",A=t.jsx(Dn,{title:p(e.title),byline:t.jsx(Ho,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(ot,{items:[...le,K!=null&&K.source?c("workPage.classifiedBy",{source:p(K.source.split("/")[0])}):"",Se]}),description:(U=e.description)!=null&&U.text?t.jsxs(t.Fragment,{children:[t.jsx(Ot,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(he=e.description.sources)!=null&&he.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(O=>({text:p(Ch(O)),href:Th(O)})).filter(O=>O.text).map((O,J)=>t.jsxs(g.Fragment,{children:[J>0?" · ":null,O.href?t.jsx("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",children:O.text}):O.text]},J))}):null]}):void 0,stats:me,facts:V,readAction:s,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(X=e.appendix)==null?void 0:X.map((O,J)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(O.title)}),t.jsx(Ot,{text:O.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},J))}),je=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(O=>({key:O,label:`${O} ${T.allRows.filter(J=>J.era.era===O).length}`}))]:[],ce=[];u.length&&ce.push({id:"versions",label:c("workPage.sec.versions"),count:u.length}),te.length&&ce.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:te.length}),R.length&&ce.push({id:"collected",label:c("workPage.sec.collected"),count:R.length}),H.length&&ce.push({id:"related",label:c("workPage.sec.related"),count:H.length}),q.length&&ce.push({id:"resources",label:c("workPage.sec.resources"),count:q.length});const ze=u.length===0&&te.length===0,$e=t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs(at,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(ot,{items:[c("workPage.versionsTotal",{n:u.length}),_&&W?c("workPage.versionsWithImage",{n:W}):"",T.rows.length!==T.allRows.length?c("workPage.versionsCurrent",{n:T.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":L&&je.length===0&&u.length>1?"":void 0,children:[je.length>0&&t.jsx(Ai,{items:je,value:y,onChange:O=>{$(O),v(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(mc,{label:c("workPage.scanOnly"),checked:b,onChange:O=>{w(O),v(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(z?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Mi(T.rows.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("workPage.col.edition")}),t.jsx("th",{children:c("workPage.col.era")}),t.jsx("th",{children:c("workPage.col.holder")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),t.jsx("tbody",{children:B.map(O=>{var J;return t.jsx(Mb,{row:O,measure:(J=m.get(O.id))==null?void 0:J.measure_info,loaded:m.has(O.id),onNavigate:i,renderLink:o},`${O.id}:${m.has(O.id)?"r":"p"}`)})})]}),B.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(go,{total:T.rows.length,shown:B.length,unit:c("workPage.moreUnit"),onClick:()=>v(!0)}),T.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),te.length>0&&t.jsx(Pb,{items:te,transport:n,onNavigate:i,renderLink:o}),ze&&t.jsx(at,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Fe=(O,J)=>t.jsx(nt,{id:O,label:p(J),onNavigate:i,renderLink:o,dense:!0}),ee=g.useMemo(()=>{const O=new Map;for(const J of H){const oe=Ea(J.relation,c);O.set(oe,(O.get(oe)??0)+1)}return O.size>1?[...O.entries()].sort((J,oe)=>oe[1]-J[1]).slice(0,4).map(([J,oe])=>`${p(J)} ${oe}`).join(" · "):void 0},[H,p,c]),F=t.jsxs(t.Fragment,{children:[t.jsx(rn,{id:"collected",title:c("workPage.sec.collected"),items:R.map(O=>Fe(O.id,O.title))}),t.jsx(rn,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:H.length}),sub:ee,items:H.map(O=>t.jsxs(t.Fragment,{children:[Fe(O.id,O.title),t.jsx("span",{className:"bim-d-meta",title:O.note?p(O.note):void 0,children:p(Ea(O.relation,c))})]}))}),t.jsx(rn,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:q.map(({r:O,kind:J})=>{const oe=p((O.url?bn(O.url):void 0)||O.name),re=yn(O);return t.jsxs(t.Fragment,{children:[re?t.jsxs("a",{href:re,target:"_blank",rel:"noopener noreferrer",children:[oe," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:oe}),J&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:J})]})})})]});return t.jsx(Hn,{railTop:a,back:l,nav:ce,railLinks:d,main:$e,card:A,side:F})};function La(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Aa(e,n){return n((e.url?bn(e.url):void 0)||e.name)}function Mb({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=ne(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],h=p?Aa(p,l):e.locationName?l(e.locationName):"",u=e.images[0],m=u?yn(u):void 0,f=e.images.map(x=>Aa(x,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:e.id,label:l(e.name),onNavigate:o,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?a("workPage.inferredFromEdition"):void 0,children:d?l(d):i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${h?"":" bim-d-zt-blank"}`,children:[h||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(m?t.jsx("a",{className:"bim-d-flag",href:m,target:"_blank",rel:"noopener noreferrer",title:f,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:f,children:a("workPage.hasImage")}))})]})}function Pb({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=ne(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[h,u]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const m=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(m.length===0)return;let f=!1;return Promise.all(m.map(x=>n.getItem(x).then(v=>{var y,$;return[x,(($=(y=v==null?void 0:v.authors)==null?void 0:y[0])==null?void 0:$.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||u(new Map(x.filter(([,v])=>v)))}),()=>{f=!0}},[n,e]),t.jsx(at,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(ot,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((m,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(m.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(m.source_bid??"")?a(h.get(m.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(m.source)].slice(0,9).map((x,v)=>t.jsx("span",{children:x},v))})]})},f))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[p.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:a(p.title_info)}),t.jsx(ot,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(nt,{id:p.source_bid,label:a(p.source),onNavigate:i,renderLink:o,dense:!0}):a(p.source),p.section?a(p.section):"",p.author_info?`${s("label.authorInfo")} ${a(p.author_info)}`:"",p.edition?`${s("label.edition")} ${a(p.edition)}`:"",p.page??""]}),p.summary&&t.jsx("p",{className:"bim-d-quote",children:bt(a(p.summary),void 0,{t:s})}),p.comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),t.jsx("p",{className:"bim-d-quote",children:bt(a(p.comment),void 0,{t:s})})]}),p.additional_comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),t.jsx("p",{className:"bim-d-quote",children:bt(a(p.additional_comment),void 0,{t:s})})]}),!p.summary&&!p.comment&&!p.additional_comment&&!p.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:a(e[c-1].source)}),onClick:()=>d(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",a(e[c-1].source)]})}):t.jsx("span",{"aria-hidden":"true"}),t.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",e.length]}),c<e.length-1?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:a(e[c+1].source)}),onClick:()=>d(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[a(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function Bb(e){var n;return{id:e.id,kind:"hypothetical",label:e.label,year:e.year??((n=e.year_range)==null?void 0:n[0]),year_range:e.year_range,year_uncertain:e.year_uncertain,group:e.group,note:e.note,description:e.description}}function Ob(e,n){if(!e.lineage)return null;const i=e.lineage;return{id:e.id,kind:"book",label:e.title,year:i.year,year_text:i.year_text,year_uncertain:i.year_uncertain,category:i.category,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function Ma(e,n,i){return{id:`derive:${n.ref}->${e}:${i}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Wb(e,n,i){const[o,s]=[e,n.book_id].sort();return{id:`sibling:${o}-${s}:${i}`,source:o,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Fb(e,n){var p;if(n==="all")return null;const i=(p=e.collections)==null?void 0:p[n],o=Array.isArray(i==null?void 0:i.groups)&&i.groups.length>0,s=Array.isArray(i==null?void 0:i.book_ids)&&i.book_ids.length>0,a=o||s||!!(i!=null&&i.hypothetical_ids);if(!a&&n==="core"&&Array.isArray(e.core_books)&&e.core_books.length>0)return{books:new Set(e.core_books),hypos:e.core_hypotheticals?new Set(e.core_hypotheticals):null};if(!i||!a)return null;const l=o?new Set(i.groups):null,d=new Set(i.book_ids??[]);if(l&&e.node_groups)for(const[h,u]of Object.entries(e.node_groups))l.has(u)&&d.add(h);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const h of e.hypothetical_nodes??[])h.group&&l.has(h.group)&&c.add(h.id)}return{books:d,hypos:c}}function fi(e,n,i){const o=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!o||!o.enabled)return s;const a=new Set(o.excluded_books??[]),l=o.node_groups??{},d=Fb(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,h=(d==null?void 0:d.hypos)??null,u=new Set,m=new Set;if(c){const j=new Map(n.map(z=>[z.id,z])),k=new Map((o.hypothetical_nodes??[]).map(z=>[z.id,z])),C=z=>{const T=j.get(z);if(T&&T.lineage)return(T.lineage.derived_from??[]).map(W=>W.ref);const B=k.get(z);return B?(B.derived_from??[]).map(W=>W.ref):[]},S=z=>k.has(z)?!h||h.has(z):!p||p.has(z),_=new Set,L=z=>{if(!_.has(z)){_.add(z);for(const T of C(z))a.has(T)||(S(T)||(k.has(T)?m.add(T):j.has(T)&&u.add(T)),L(T))}};for(const z of n)p&&p.has(z.id)&&!a.has(z.id)&&L(z.id);for(const z of o.hypothetical_nodes??[])h&&h.has(z.id)&&L(z.id)}const f=n.filter(j=>!a.has(j.id)).filter(j=>!p||p.has(j.id)||u.has(j.id)).map(j=>{const k=Ob(j,l);return k&&u.has(j.id)&&(k.bridge=!0),k}).filter(j=>j!==null),x=(o.hypothetical_nodes??[]).filter(j=>!h||h.has(j.id)||m.has(j.id)).map(j=>{const k=Bb(j);return m.has(j.id)&&(k.bridge=!0),k}),v=[...f,...x],y=new Set(v.map(j=>j.id)),$=new Set,b=[],w=j=>{$.has(j.id)||!y.has(j.source)||!y.has(j.target)||($.add(j.id),b.push(j))};for(const j of n)a.has(j.id)||!j.lineage||p&&!p.has(j.id)&&!u.has(j.id)||((j.lineage.derived_from??[]).forEach((k,C)=>{w(Ma(j.id,k,C))}),(j.lineage.related_to??[]).forEach((k,C)=>{w(Wb(j.id,k,C))}));for(const j of o.hypothetical_nodes??[])h&&!h.has(j.id)&&!m.has(j.id)||(j.derived_from??[]).forEach((k,C)=>{w(Ma(j.id,k,C))});return{nodes:v,edges:b,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function kd(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function Hb(e,n){const i=[],o=e.version_graph;if(!o)return i;const s=new Set(n.map(c=>c.id)),a=new Set((o.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||i.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const p=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(h=>d(p,h)),(c.lineage.related_to??[]).forEach(h=>{s.has(h.book_id)||i.push(`${p}: related_to.book_id "${h.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(h=>d(p,h))}return i}const wd=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ne();if(!e.nodes.length)return t.jsx("div",{style:{...ny,...o},className:i,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const f of e.edges)if(f.kind==="derive"){const x=l.get(f.target)??[];x.push(f),l.set(f.target,x)}else for(const x of[f.source,f.target]){const v=d.get(x)??[];v.push(f),d.set(x,v)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,h=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else h.push(f);const u=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(u)),h.sort(u);const m=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:i,style:{...Ub,...o},children:[e.title&&t.jsx("div",{style:Vb,children:a(e.title)}),e.description&&t.jsx("div",{style:Gb,children:a(e.description)}),m.map(f=>t.jsx(Pa,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),h.length>0&&t.jsx(Pa,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Pa=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ne();return t.jsxs("div",{style:Yb,children:[t.jsx("div",{style:{...qb,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(Db,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Db=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ne();return t.jsxs("div",{style:{...Kb,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?r("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:Xb,children:[t.jsx("span",{style:Zb,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Jb,children:kd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Qb,children:[e.category&&t.jsx(In,{children:c(e.category)}),e.status==="lost"&&t.jsx(In,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(In,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(In,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(In,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:ey,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:ty,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:Oa,children:[t.jsx("div",{style:Wa,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:Fa(p.confidence),children:[t.jsx("span",{style:Ha,children:c(p.relation)}),t.jsx("span",{children:(h==null?void 0:h.kind)==="book"&&s?s(h.id,c(h.label)):c((h==null?void 0:h.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(Ba,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Da,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:Oa,children:[t.jsx("div",{style:Wa,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,u=o.get(h);return t.jsxs("div",{style:Fa(p.confidence),children:[t.jsx("span",{style:Ha,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??h)}),t.jsx(Ba,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Da,children:["· ",c(p.evidence)]})]},p.id)})]})]})},In=({children:e,tone:n="default"})=>{const o={default:{bg:r("tag-bg"),fg:r("fg")},warn:{bg:r("warn-bg"),fg:r("warn-fg")},info:{bg:r("info-bg"),fg:r("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:o.bg,color:o.fg,marginRight:"4px"},children:e})},Ba=({level:e})=>{const{t:n}=ne(),o={certain:{key:"certain",color:r("confidence-certain")},consensus:{key:"consensus",color:r("confidence-consensus")},probable:{key:"probable",color:r("confidence-probable")},disputed:{key:"disputed",color:r("confidence-disputed")}}[e];return o?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${o.color}`,color:o.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${o.key}`)}):null},Ub={fontSize:"14px",color:r("fg")},Vb={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Gb={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},Yb={marginBottom:"16px"},qb={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},Kb={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},Xb={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Zb={fontSize:"15px",fontWeight:600},Jb={fontSize:"12px",color:r("muted")},Qb={marginBottom:"6px"},ey={fontSize:"12px",color:r("muted"),margin:"2px 0"},ty={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},Oa={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},Wa={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Fa=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),Ha={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},Da={fontSize:"11px",color:r("muted")},ny={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Sd=({selectedNodeId:e,...n})=>{const{t:i}=ne(),[o,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return iy().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:Va,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:Va,children:[t.jsx("div",{children:Ua(i("lineage.graphMissing"),{xyflow:t.jsx("code",{children:"@xyflow/react"}),dagre:t.jsx("code",{children:"@dagrejs/dagre"})})}),t.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:Ua(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(ry,{modules:a,selectedNodeId:e,...n})};function Ua(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function iy(){try{const[e,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let i=!1;try{await import("@xyflow/react/dist/style.css"),i=!0}catch{i=!1}return{ReactFlow:e.ReactFlow,Background:e.Background,Controls:e.Controls,Handle:e.Handle,Position:e.Position,BaseEdge:e.BaseEdge,EdgeLabelRenderer:e.EdgeLabelRenderer,getSmoothStepPath:e.getSmoothStepPath,dagre:n,cssLoaded:i}}catch{return null}}const ry=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:h,Position:u,BaseEdge:m,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:v}=l,y=g.useMemo(()=>({lineage:C=>{var H,q,te,ae;const S=((H=C.data)==null?void 0:H.stepPosition)??.85,[_,L,z]=x({sourceX:C.sourceX,sourceY:C.sourceY,sourcePosition:C.sourcePosition,targetX:C.targetX,targetY:C.targetY,targetPosition:C.targetPosition,stepPosition:S,borderRadius:5}),T=!!((q=C.data)!=null&&q.isSibling),B=T?L:C.targetX-18,W=T?z:C.targetY-12,N=(te=C.data)==null?void 0:te.labelStyle,R=(ae=C.data)==null?void 0:ae.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(m,{id:C.id,path:_,style:C.style,markerStart:C.markerStart,markerEnd:C.markerEnd}),C.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${B}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...R,...N},children:C.label})})]})}}),[m,f,x]),$=g.useMemo(()=>({version:C=>{const{t:S}=ne(),_=C.data,L=_.kind==="hypothetical",z=_.status==="lost",T=_.isSelected,B=_.bridge,W=_.borderColor??r("muted"),N=B||L?"dashed":"solid",R=B?.5:z?.6:1;return t.jsxs("div",{style:{background:r(B?"bg-subtle":"bg"),border:`2px ${N} ${T?r("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:R,boxShadow:T?r("shadow-node-selected"):L||B?"none":r("shadow-node")},title:B?S("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:u.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:L||!_.renderLink?_.label:_.renderLink(_.bookId,_.label)}),_.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:_.description}),_.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:kd(_.yearText,void 0,_.uncertain)}),z&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:S("lineage.lost")}),t.jsx(h,{type:"source",position:u.Right,style:{visibility:"hidden"}})]})}}),[h,u]),{convert:b}=ne(),{rfNodes:w,rfEdges:j}=g.useMemo(()=>oy(e,v,n,a,b),[e,v,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:j,nodeTypes:$,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[t.jsx(c,{gap:16}),t.jsx(p,{showInteractive:!1})]})})};function oy(e,n,i,o,s=a=>a??""){const d=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:d?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const p=new Map(e.groups.map($=>[$.id,$.color??r("muted")]));for(const $ of e.nodes)c.setNode($.id,{width:160,height:90});const h=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const $ of e.edges)$.kind==="derive"&&(h.has($.relation)||c.setEdge($.source,$.target));n.layout(c);const u=e.nodes.map($=>{const b=c.node($.id),w=o?$.id===o:void 0,j={kind:$.kind,label:s($.label),bookId:$.kind==="book"?$.id:void 0,yearText:s($.year_text??ay($)),uncertain:$.year_uncertain,category:$.category,status:$.status,borderColor:$.group?p.get($.group):void 0,renderLink:i,isSelected:w,description:s($.description),bridge:$.bridge};return{id:$.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:j,draggable:!1,selected:w}}),m=.78,f=.06,x=new Map;for(const $ of e.edges)$.kind==="derive"&&(x.has($.source)||x.set($.source,[]),x.get($.source).push($));const v=new Map;for(const[$,b]of x){if(b.length<=1)continue;const w=[...b].sort((k,C)=>{var L,z;const S=((L=c.node(k.target))==null?void 0:L.y)??0,_=((z=c.node(C.target))==null?void 0:z.y)??0;return S-_}),j=w.length;w.forEach((k,C)=>{const S=(C-(j-1)/2)*f;v.set(k.id,m+S)})}const y=e.edges.map($=>sy($,v.get($.id),s));return{rfNodes:u,rfEdges:y}}function sy(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=ly(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:i(e.relation),data:{labelStyle:{color:r("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":o?"6 4":void 0,opacity:o?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function ay(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function ly(e){switch(e){case"certain":return r("confidence-certain");case"consensus":return r("lineage-edge-consensus");case"probable":return r("confidence-probable");case"disputed":return r("confidence-disputed");default:return r("muted")}}const Va={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},Uo=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:h,style:u})=>{var j;const{t:m,convert:f}=ne(),[x,v]=g.useState(n),y=k=>{v(k),a==null||a(k)},$=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(d&&$.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:m("lineage.empty")});const w=l?(j=c==null?void 0:c[l])==null?void 0:j.description:void 0;return t.jsxs("div",{className:h,style:u,children:[t.jsxs("div",{style:cy,children:[t.jsx("button",{onClick:()=>y("list"),style:xr(x==="list"),children:m("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:xr(x==="graph"),children:m("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:m("lineage.collectionLabel")}),$.map(([k,C])=>{const S=p==null?void 0:p[k];return t.jsxs("button",{onClick:()=>d==null?void 0:d(k),style:xr(l===k),title:C.description?f(C.description):void 0,children:[f(C.label),S!=null?` ${S}`:""]},k)})]})]}),b&&w&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:f(w)}),x==="list"?t.jsx(wd,{graph:e,renderLink:i}):t.jsx(Sd,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},cy={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},xr=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${r("widget-border")}`,borderRadius:4,background:e?r("primary"):"transparent",color:r(e?"primary-fg":"fg"),cursor:"pointer"}),Ga=40,Ya=2,dy=9,py=new Set(["certain","consensus","probable","disputed"]);function br(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const _d=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var ve,we,P,fe,de,xe,Ce,Ue,Ke,Je,qe;const u=Ee(),{t:m,convert:f}=ne(),[x,v]=g.useState(null),[y,$]=g.useState(new Map),[b,w]=g.useState([]),[j,k]=g.useState(new Map),[C,S]=g.useState(!1),[_,L]=g.useState("flow"),[z,T]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){v(null);return}let I=!1;return n.getItem(e.work_id).then(Y=>{!I&&Y&&Y.type==="work"&&v(Y)}).catch(()=>{}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let I=!1;return n.getLineageGraph(e.work_id).then(Y=>{I||T(Y&&Y.nodes.length>1?Y:null)}).catch(()=>{I||T(null)}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{const I=e._collections||[];if(!n||I.length===0){$(new Map);return}let Y=!1;return Promise.all(I.map(pe=>{const be=pe.id;return n.getItem(be).then(Re=>[be,Re]).catch(()=>[be,null])})).then(pe=>{if(Y)return;const be=new Map;for(const[Re,ge]of pe)ge&&be.set(Re,ge);$(be)}),()=>{Y=!0}},[n,e._collections]);const B=g.useMemo(()=>{const I=new Set([...x?mo(x):[],...e.related_books||[]]);return I.add(e.id),[...I]},[x,e.related_books,e.id]),W=B.length-1;g.useEffect(()=>{if(!n||W<=0){w([]);return}const I=B.length<=Ga,Y=I?B:B.slice(0,8);let pe=!1;return Promise.all(Y.map(be=>be===e.id?Promise.resolve({id:be,title:e.title,edition:e.edition,year:yi(e)}):n.getItem(be).then(Re=>{const ge=Re??{};return{id:be,title:ge.title,edition:ge.edition,year:Re?yi(ge):void 0}}).catch(()=>({id:be})))).then(be=>{if(pe)return;const Re=be.filter(ge=>ge.id===e.id||ge.title||ge.edition);I&&Re.sort((ge,Me)=>(ge.year??1/0)-(Me.year??1/0)),w(Re)}),()=>{pe=!0}},[n,B,W,e]);const N=e.lineage,R=g.useMemo(()=>[...((N==null?void 0:N.derived_from)||[]).filter(I=>I.ref_type==="book").map(I=>I.ref),...((N==null?void 0:N.related_to)||[]).map(I=>I.book_id)].filter(Boolean),[N]);g.useEffect(()=>{if(!n||R.length===0){k(new Map);return}let I=!1;return Promise.all(R.map(Y=>n.getItem(Y).then(pe=>[Y,{id:Y,title:pe==null?void 0:pe.title,edition:pe==null?void 0:pe.edition}]).catch(()=>[Y,{id:Y}]))).then(Y=>{I||k(new Map(Y))}),()=>{I=!0}},[n,R]);const H=g.useMemo(()=>bd(e.resources,e.resource_groups,m),[e.resources,e.resource_groups,m]),q=H.groups.reduce((I,Y)=>I+Y.rows.length+Y.mirrors.length,0),te=H.groups.length>0&&H.groups.every(I=>I.key==="_physical"),ae=Fn(e),V=ac(e),G=Wt(e,u.unit.juan),me=new Set((e._collections||[]).map(I=>Mn(I.vol).length).filter(I=>I>0)),K=I=>{var be;const Y=(be=e.base_edition)==null?void 0:be.find(Re=>Re.book_id===I&&Re.name);if(Y!=null&&Y.name)return Y.name;const pe=j.get(I);return(pe==null?void 0:pe.edition)||(pe==null?void 0:pe.title)||""},le=g.useMemo(()=>{var ye,We,He,Ne,Pe;const I=[];V&&I.push({label:m("bookPage.fact.editionType"),value:f(V),title:e.edition_type||(ye=e.lineage)!=null&&ye.category?void 0:m("bookPage.inferredFromEdition")}),(We=e.publication_info)!=null&&We.details?I.push({label:m("bookPage.fact.publication"),value:f(e.publication_info.details)}):(ae.era||ae.reign)&&I.push({label:m("bookPage.fact.era"),value:f([ae.era,ae.reign].filter(Boolean).join(" ")),title:ae.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),G&&I.push({label:m("bookPage.fact.measure"),value:f(G)});const Y=(e._collections||[]).flatMap(Le=>Mn(Le.vol));Y.length&&I.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Li(Y,u.unit.volume),unit:u.unit.volume,n:Y.length})});const pe=(((He=e.lineage)==null?void 0:He.derived_from)||[]).find(Le=>Le.relation==="底本"&&Le.ref_type==="book");pe&&K(pe.ref)&&I.push({label:m("bookPage.fact.baseEdition"),value:t.jsx(nt,{id:pe.ref,label:f(K(pe.ref)),onNavigate:i,renderLink:o,dense:!0})});const be=(e.base_edition||[]).filter(Le=>Le&&Le.name);for(const Le of["底本","配補","參校"]){if(Le==="底本"&&pe&&K(pe.ref))continue;const Be=be.filter(Ie=>Ie.role===Le);Be.length&&I.push({label:f(Le),value:Be.map((Ie,De)=>t.jsxs(g.Fragment,{children:[De>0&&"、",Ie.book_id?t.jsx(nt,{id:Ie.book_id,label:f(Ie.name),onNavigate:i,renderLink:o,dense:!0}):f(Ie.name)]},De))})}const Re=(e.provenance||[]).filter(Le=>Le&&Le.institution),ge=(e.resources||[]).filter(Le=>Bt(Le).includes("physical"));if(Re.length){I.push({label:m("bookPage.fact.holdings"),value:Re.slice(0,2).map(Ie=>f(Ie.institution)).join("、")+(Re.length>2?m("bookPage.andMorePlaces",{n:Re.length}):"")});const Le=Re.filter(Ie=>Ie.call_number).slice(0,2).map(Ie=>`${f(Ie.institution)} ${Ie.call_number}`);Le.length&&I.push({label:m("bookPage.fact.callNumber"),value:Le.join(";")+(Re.filter(Ie=>Ie.call_number).length>2?"…":"")});const Be=Re.flatMap(Ie=>Ie.seals||[]).filter(Boolean);Be.length&&I.push({label:m("bookPage.fact.seals"),value:f(Be.join("、"))})}else ge.length?I.push({label:m("bookPage.fact.holdings"),value:ge.slice(0,2).map(Le=>f(Le.name)).join("、")+(ge.length>2?m("bookPage.andMorePlaces",{n:ge.length}):"")}):(Ne=e.current_location)!=null&&Ne.name&&I.push({label:m("bookPage.fact.holdings"),value:f(e.current_location.name)});const Me=e.physical_description;if(Me){const Le=[[m("bookPage.fact.leafStyle"),Me.leaf_style],[m("bookPage.fact.binding"),Me.binding],[m("bookPage.fact.dimensions"),Me.dimensions],[m("bookPage.fact.condition"),Me.condition]];for(const[Be,Ie]of Le)Ie&&Ie.trim()&&I.push({label:Be,value:f(Ie)})}(Pe=e.page_count)!=null&&Pe.description&&I.push({label:u.label.pageCount,value:f(e.page_count.description)});const Q=[...Lr(e.additional_titles),...Lr(e.attached_texts)];return Q.length&&I.push({label:m("bookPage.fact.aliases"),value:Q.map(f).join("、")}),I},[e,f,u,m,ae,V,G,j,i,o]),Se=f(e.title),A=e.edition?f(e.edition):void 0,je=((ve=e.lineage)==null?void 0:ve.year_text)||"",ce=t.jsx(Dn,{kind:m("bookPage.kind"),title:Se,subtitle:A,byline:t.jsx(Ho,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const I=[V?f(V):"",ae.era?f([ae.era,ae.reign].filter(Boolean).join("")):"",G?f(G):""].filter(Boolean);return I.length?t.jsx("span",{className:"bim-d-tags",children:I.map((Y,pe)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(pe,2)}`,children:Y},pe))}):null})(),description:(we=e.description)!=null&&we.text?t.jsx(Ot,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:xo((P=e.description)==null?void 0:P.text)?6:void 0,facts:le,readAction:s,secondaryAction:s&&q>0&&!te?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),ze=e._collections||[],$e=(a==null?void 0:a.chapters)||[],Fe=f($e[0]&&br($e[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),ee=m("bookPage.chapterCount",{n:$e.length,unit:Fe}),F=!!((fe=N==null?void 0:N.derived_from)!=null&&fe.length||(de=N==null?void 0:N.related_to)!=null&&de.length||(xe=e.appendix)!=null&&xe.length),U=[],he=m(te?"bookPage.sec.physical":"bookPage.sec.images");($e.length||H.text.length||l)&&U.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:$e.length?ee:void 0}),H.groups.length&&U.push({id:"images",label:he,count:q}),F&&U.push({id:"lineage",label:m("bookPage.sec.lineage")}),ze.length&&U.push({id:"collections",label:m("section.containedIn"),count:ze.length}),(Ce=e.location_history)!=null&&Ce.length&&U.push({id:"provenance",label:m("section.locationHistory")});const X=I=>(d==null?void 0:d(I))??null,O=$e[0],J=O?X(O.file):null,oe=C?$e:$e.slice(0,dy),re=(I,Y,pe)=>I?t.jsx("a",{className:pe,href:I.href??"#",onClick:I.onClick?be=>{be.metaKey||be.ctrlKey||(be.preventDefault(),I.onClick())}:void 0,children:Y}):t.jsx("span",{className:pe,children:Y}),D=t.jsxs(t.Fragment,{children:[($e.length>0||H.text.length>0||l)&&t.jsxs(at,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:$e.length>0?t.jsx(ot,{items:[ee,(Ue=a==null?void 0:a.source)!=null&&Ue.name?m("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!O&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[t.jsx("span",{className:"bim-d-ft-h",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "})]}),t.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),O&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:f(br(O.title)[0])||m("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((O.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),re(J,t.jsxs(t.Fragment,{children:[m("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),$e.length>1&&t.jsx("ul",{className:"bim-d-chap",children:oe.map(I=>{const[Y,pe]=br(I.title);return t.jsx("li",{children:re(X(I.file),t.jsxs(t.Fragment,{children:[Y&&t.jsx("b",{children:f(Y)}),f(pe||I.file)]}))},I.file)})}),$e.length>oe.length&&t.jsx(fo,{label:m("detail.expandRest",{n:$e.length-oe.length,unit:Fe}),onClick:()=>S(!0)}),H.text.length>0&&t.jsxs(t.Fragment,{children:[($e.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:H.text.map((I,Y)=>t.jsx(Do,{item:I,siblings:H.text,listedVolumeCounts:me},`${I.id||I.url||I.name}-${Y}`))})})]})]}),H.groups.length>0&&t.jsx(at,{id:"images",title:he,meta:t.jsx(ot,{items:[H.groups.length>1?m("bookPage.groupCount",{n:H.groups.length}):"",m("bookPage.placeCount",{n:q})]}),children:t.jsx(jd,{groups:H.groups,listedVolumeCounts:me})}),F&&t.jsx(at,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(Ke=N==null?void 0:N.derived_from)!=null&&Ke.length?m("bookPage.lineageMeta"):void 0,action:z?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":_==="flow",onClick:()=>L("flow"),children:m("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>L("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&z?t.jsx(Uo,{graph:z,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(I,Y)=>t.jsx(nt,{id:I,label:f(Y),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(my,{data:e,heading:A||Se,yearText:je,refName:K,onNavigate:i,renderLink:o})}),ze.length>0&&t.jsx(at,{id:"collections",title:m("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:ze.map((I,Y)=>{const pe=I.id,be=Mn(I.vol),Re=y.get(pe),ge=_h(Re);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:pe,label:Re?f(Re.title):pe,onNavigate:i,renderLink:o,dense:!0}),be.length>0&&t.jsx(uy,{volumes:be,unit:u.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ge?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ge>0&&m("bookPage.totalOf",{n:ge,unit:u.unit.bu})})]},`${pe}-${Y}`)})})})}),(Je=e.location_history)!=null&&Je.length?t.jsx(at,{id:"provenance",title:m("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((I,Y)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(I.name)}),([I.start_date,I.end_date].filter(Boolean).join("—")||I.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(ot,{items:[[I.start_date,I.end_date].filter(Boolean).join("—"),I.description?f(I.description):""]})})]},Y))})}):null,U.length===0&&t.jsx(at,{title:m("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),se=b.findIndex(I=>I.id===e.id),_e=B.length<=Ga,Ae=_e&&se>=0?b.slice(Math.max(0,se-Ya),se+Ya+1):b.filter(I=>I.id!==e.id),M=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(u.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(nt,{id:x.id,label:f(x.title),onNavigate:i,renderLink:o})}),t.jsx(ot,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(I=>`${I.dynasty?`〔${f(I.dynasty)}〕`:""}${f(I.name)}`),f(Wt(x,u.unit.juan)),x._edition_count?m("bookPage.editionCount",{n:x._edition_count}):""]}),((qe=x.description)==null?void 0:qe.text)&&t.jsx("p",{style:{fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc bim-d-side-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&Ae.length>0&&t.jsxs("div",{children:[t.jsx(rn,{id:"siblings",timeline:!0,title:_e?m("bookPage.siblings"):u.relation.siblingVersions,meta:_e?m("bookPage.byEra"):m("bookPage.kindCount",{n:W}),cap:Ae.length,items:Ae.map(I=>I.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(I.edition||I.title||I.id)}):t.jsx(nt,{id:I.id,label:f(I.edition||I.title||I.id),onNavigate:i,renderLink:o,dense:!0})),metas:Ae.map(I=>[I.year!=null?I.year<0?m("detail.bce",{n:-I.year}):String(I.year):"",I.id===e.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:Ae.findIndex(I=>I.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(nt,{id:x.id,label:m("bookPage.viewAllInWork",{n:B.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),ie=e.work_id?t.jsx(uc,{caption:u.section.belongsToWork,children:t.jsx(nt,{id:e.work_id,label:x?f(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(Hn,{railTop:c,back:p,up:ie,nav:U,railLinks:h,main:D,card:ce,side:M})};function uy({volumes:e,unit:n}){const{t:i}=ne();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Li(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),i("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function my({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var $;const{t:l,convert:d}=ne(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],h=p.filter(b=>b.ref_type!=="book"),u=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,v=b=>b&&py.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,w)=>t.jsx(nt,{id:b,label:d(w||b),onNavigate:s,renderLink:a,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[x&&t.jsxs("ol",{className:"bim-d-lf-list",children:[h.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),v(b.confidence)]})]})},`a-${w}`)),u.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]})},`b-${w}`)),t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[t.jsxs("div",{className:"bim-d-lf-here",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:l("bookPage.lineage.thisEdition")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),i&&t.jsx("span",{className:"bim-d-lf-yr",children:d(i)})]}),m.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:m.map((b,w)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]},w))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,o(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},w))})]})]}),($=e.appendix)==null?void 0:$.map((b,w)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Ot,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${w}`)),(c==null?void 0:c.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(c.note)})]})}const En=16,hy=200,gy=16,$d=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var se,_e,Ae,M,ie,ve,we;const{t:p,convert:h,messages:u}=ne(),[m,f]=g.useState(""),[x,v]=g.useState(!1),[y,$]=g.useState(null),[b,w]=g.useState(""),[j,k]=g.useState(!1),C=g.useMemo(()=>oc(e,n),[e,n]),S=g.useMemo(()=>rc(e),[e]),[_,L]=g.useState(new Map),z=!!i&&C.rows.length>0&&C.rows.length<=hy,T=z&&(C.rows.length<=En||j),B=T&&C.rows.every(P=>!P.id||_.has(P.id)),W=P=>{var fe;return Dr(P?(fe=_.get(P))==null?void 0:fe.l1:void 0)},N=g.useMemo(()=>{const P=m.trim(),fe=P?h(P):"";return C.rows.filter(de=>{var Ce,Ue;if(b&&Dr(de.id?(Ce=_.get(de.id))==null?void 0:Ce.l1:void 0)!==b)return!1;if(!fe)return!0;const xe=de.id&&((Ue=_.get(de.id))==null?void 0:Ue.title)||de.title;return h(xe).includes(fe)||(de.subItems||[]).some(Ke=>h(Ke).includes(fe))})},[C.rows,m,b,_,h]),R=x?N:N.slice(0,En),H=g.useMemo(()=>(T?C.rows:R).filter(P=>P.id&&!_.has(P.id)).map(P=>P.id),[T,C.rows,R,_]);g.useEffect(()=>{if(!i||H.length===0)return;let P=!1;const fe=H.slice(0,gy);return Wi(fe,Oi,de=>i.getItem(de).then(xe=>{var Ke,Je;const Ce=xe??{},Ue={title:Ce.title,edition:Ce.edition,authors:Ce.authors,measure:xe?Wt(xe,u.unit.juan):void 0,versionCount:Ce._edition_count??((Ke=Ce._books)==null?void 0:Ke.length),l1:((Je=ho(Ce))==null?void 0:Je.l1)||void 0};return[de,Ue]}).catch(()=>[de,{}]),()=>P).then(de=>{P||L(xe=>{const Ce=new Map(xe);for(const[Ue,Ke]of de)Ce.set(Ue,Ke);return Ce})}),()=>{P=!0}},[i,H,u.unit.juan]);const q=(se=(e.contained_in||[])[0])==null?void 0:se.id;g.useEffect(()=>{if(!q){$(null);return}if($({id:q}),!i)return;let P=!1;return i.getItem(q).then(fe=>{P||$({id:q,title:fe==null?void 0:fe.title})}).catch(()=>{}),()=>{P=!0}},[i,q]);const te=g.useMemo(()=>bd(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),ae=te.text.length+te.groups.reduce((P,fe)=>P+fe.rows.length+fe.mirrors.length,0),V=S.works,G=new Set(C.rows.map(P=>P.id).filter(Boolean)),me=V.length>0&&!V.every(P=>G.has(P.id)),K=(()=>{const P=C.rows.map(fe=>fe.edition).filter(Boolean);return P.length>1&&new Set(P).size===1})(),le=C.rows.some(P=>P.volumes.length>0||P.expected!=null),Se=S.total,A=S.truncated?Se:C.rows.length,je=Wt(e,u.unit.juan),ce=e.count,ze=P=>typeof P=="number"&&Number.isFinite(P)?P:null,$e=ze(ce==null?void 0:ce.juan)??ze((_e=e.juan_count)==null?void 0:_e.number),Fe=ze(ce==null?void 0:ce.ce)??(C.totalVolumes||null),ee=[{value:A,label:p("collectionPage.stat.titles")},{value:$e??0,label:u.unit.juan},{value:Fe??0,label:u.unit.volume}],F=g.useMemo(()=>{var de,xe;const P=[];if((de=e.publication_info)!=null&&de.details&&P.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),Se&&(Se!==C.rows.length||S.truncated)){const Ce=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");P.push({label:Ce,value:`${Se} ${u.unit.bu}`,title:p("collectionPage.memberNote")})}const fe=[ze(ce==null?void 0:ce.zhong)!=null?p("collectionPage.nZhong",{n:ce.zhong}):"",ze(ce==null?void 0:ce.han)!=null?p("collectionPage.nHan",{n:ce.han}):""].filter(Boolean);return fe.length&&P.push({label:p("collectionPage.fact.expected"),value:fe.join(" ")}),$e==null&&je&&P.push({label:p("collectionPage.fact.measure"),value:h(je),title:(xe=e.juan_count)!=null&&xe.description?h(e.juan_count.description):void 0}),P},[e,Se,S.truncated,C.rows.length,$e,je,ce,h,p,u]),U=g.useMemo(()=>{if(!B)return[];const P=new Map;for(const de of C.rows){const xe=W(de.id);xe&&P.set(xe,(P.get(xe)??0)+1)}const fe=Bn.filter(de=>(P.get(de.key)??0)>0);return fe.length<2?[]:[{key:"",label:`${u.catalog.all} ${A}`},...fe.map(de=>({key:de.key,label:`${de.label} ${P.get(de.key)}`}))]},[B,C.rows,_,u]),he=g.useMemo(()=>{if(!B||!C.rows.some(xe=>xe.volumes.length>0))return null;const P=[],fe=C.rows.filter(xe=>xe.volumes.length>0).map(xe=>({k:W(xe.id)??"",from:Math.min(...xe.volumes),to:Math.max(...xe.volumes)})).sort((xe,Ce)=>xe.from-Ce.from);for(const xe of fe){const Ce=xe.to-xe.from+1,Ue=P[P.length-1];Ue&&Ue.key===xe.k?(Ue.to=Math.max(Ue.to,xe.to),Ue.n+=Ce):P.push({key:xe.k,from:xe.from,to:xe.to,n:Ce})}const de=fe.reduce((xe,Ce)=>Math.max(xe,Ce.to),0);return P.length>1&&P.some(xe=>xe.key)?{segs:P,last:de}:null},[B,C.rows,_]),X=(Ae=e.description)==null?void 0:Ae.text,O=t.jsx(Dn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(Ho,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(ot,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(M=e.publication_info)!=null&&M.year?h(e.publication_info.year):""]}),description:X||(ie=e.history)!=null&&ie.length?t.jsxs(t.Fragment,{children:[X&&t.jsx(Ot,{text:X,style:{fontSize:15,lineHeight:1.85}}),(ve=e.history)!=null&&ve.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((P,fe)=>t.jsx("li",{children:h(P)},fe))}):null]}):void 0,clampDescription:xo(X)||(((we=e.history)==null?void 0:we.length)??0)>2?6:void 0,stats:ee,facts:F,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:he&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:p("collectionPage.dist.head")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":p("collectionPage.dist.head"),children:he.segs.map((P,fe)=>{const de=Bn.find(xe=>xe.key===P.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!de,title:de?p("collectionPage.dist.segTitle",{section:h(de.label),from:P.from,to:P.to}):void 0,"aria-label":de?p("collectionPage.dist.only",{section:h(de.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!de&&b===P.key,style:{flexGrow:P.n,background:r(de?de.token:"rule")},onClick:()=>{de&&(w(b===P.key?"":P.key),v(!1))}},fe)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:p("catalog.volume",{n:1})}),t.jsx("span",{children:p("collectionPage.dist.hint")}),t.jsx("span",{children:p("catalog.volume",{n:he.last})})]})]})}),J=[];C.rows.length&&J.push({id:"titles",label:p("collectionPage.sec.titles"),count:A}),ae&&J.push({id:"resources",label:p("collectionPage.sec.resources"),count:ae}),me&&J.push({id:"works",label:u.section.containedWorks,count:V.length});const oe=t.jsxs(t.Fragment,{children:[C.rows.length>0&&t.jsxs(at,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(ot,{items:[`${A} ${u.unit.items}`,C.totalVolumes?p("collectionPage.totalVolumes",{n:C.totalVolumes,unit:u.unit.volume}):"",N.length!==A?p("collectionPage.currentN",{n:N.length,unit:u.unit.items}):""]}),action:a,children:[(C.rows.length>En||U.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[U.length>0&&t.jsx(Ai,{items:U,value:b,onChange:P=>{w(P),v(!1)}}),z&&C.rows.length>En&&!B&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:j,onClick:()=>k(!0),title:p("collectionPage.loadAllTitle",{n:C.rows.length,unit:u.unit.items}),children:p(j?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),C.rows.length>En&&t.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:P=>{f(P.target.value),v(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Mi(N.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[le&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:R.map((P,fe)=>{var qe;const de=P.id?_.get(P.id):void 0,xe=de!=null&&de.title&&P.title===P.id?de.title:P.title,Ce=((de==null?void 0:de.authors)||[]).find(I=>I&&I.name),Ue=[Ce?`${Ce.dynasty?`〔${h(Ce.dynasty)}〕`:""}${h(Ce.name)}${Ce.role?` ${h(Ce.role)}`:""}`:"",de!=null&&de.measure?h(de.measure):"",(qe=P.subItems)!=null&&qe.length?P.subItems.map(I=>h(I)).join("、"):"",(de!=null&&de.edition||P.edition)&&!K?h((de==null?void 0:de.edition)||P.edition||""):""].filter(Boolean),Ke=Bn.find(I=>I.key===W(P.id)),Je=P.volumes.length>0?p("collectionPage.volumeRange",{range:Li(P.volumes,u.unit.volume),unit:u.unit.volume}):P.expected!=null?`${P.found??0}/${P.expected} ${u.unit.volume}`:"";return t.jsxs("tr",{children:[le&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Je?"":" bim-d-zt-blank"}`,children:[Ke&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(Ke.token)}}),Je||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[P.id?t.jsx(nt,{id:P.id,label:h(xe),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(xe)}),Ue.length>0?t.jsx(ot,{items:Ue}):P.id&&!de&&i?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${de!=null&&de.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:de!=null&&de.versionCount?p("collectionPage.nZhong",{n:de.versionCount}):""})]},`${P.id??P.title}-${fe}`)})})]}),R.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(go,{total:N.length,shown:R.length,unit:u.unit.items,onClick:()=>v(!0)})]}),ae>0&&t.jsxs(at,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:ae}),children:[te.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[te.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:te.text.map((P,fe)=>t.jsx(Do,{item:P,siblings:te.text},`${P.id||P.url||P.name}-${fe}`))})})]}),t.jsx(jd,{groups:te.groups})]}),C.rows.length===0&&ae===0&&t.jsx(at,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),re=me?t.jsx(rn,{id:"works",title:u.section.containedWorks,meta:p("collectionPage.nZhong",{n:V.length}),cap:12,items:V.map(P=>t.jsx(nt,{id:P.id,label:h(P.title),onNavigate:o,renderLink:s,dense:!0}))}):null,D=y?t.jsx(uc,{caption:p("collectionPage.parent"),children:t.jsx(nt,{id:y.id,label:h(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(Hn,{railTop:l,back:d,up:D,nav:J,railLinks:c,main:oe,card:O,side:re})},fy=16,yr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function qa(e){if(!e)return yr.length;const n=yr.indexOf(e);return n===-1?yr.length:n}function xy(e,n,i){if(n)return e[n]??i(n)}function by(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const yy={秦:[-221,-207],西漢:[-202,8],西汉:[-202,8],東漢:[25,220],东汉:[25,220],漢:[-202,220],汉:[-202,220],三國:[220,280],三国:[220,280],西晉:[265,316],西晋:[265,316],東晉:[317,420],东晋:[317,420],隋:[581,618],唐:[618,907],五代:[907,960],北宋:[960,1127],南宋:[1127,1279],宋:[960,1279],遼:[916,1125],辽:[916,1125],金:[1115,1234],元:[1271,1368],明:[1368,1644],清:[1636,1912]},Cd=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l})=>{var re,D,se,_e,Ae;const{t:d,convert:c,messages:p}=ne(),h=M=>by(M,d),[u,m]=g.useState("全部"),[f,x]=g.useState(!1),[v,y]=g.useState("default"),[$,b]=g.useState(new Map),w=g.useMemo(()=>e._works||[],[e._works]),j=g.useMemo(()=>w.map(M=>{const ie=$.get(M.work_id);return{id:M.work_id,title:(ie==null?void 0:ie.title)??M.title??M.work_id,role:M.role||"",cls:po(M.role),versionCount:ie==null?void 0:ie.versionCount,section:ie==null?void 0:ie.cls,l1:ie==null?void 0:ie.l1,measure:ie==null?void 0:ie.measure,hasImage:ie==null?void 0:ie.hasImage,loaded:!!(ie!=null&&ie.loaded)}}),[w,$]),k=g.useMemo(()=>ic(w.map(M=>M.role),d("detail.roleAll")),[w,d]),C=g.useMemo(()=>{const M=u==="全部"?j:j.filter(ie=>ie.cls===u);return v==="versions"?[...M].sort((ie,ve)=>(ve.versionCount??-1)-(ie.versionCount??-1)):M},[j,u,v]),S=f?C:C.slice(0,fy),_=g.useMemo(()=>S.filter(M=>!$.has(M.id)).map(M=>M.id),[S,$]);g.useEffect(()=>{if(!n||_.length===0)return;let M=!1;return Wi(_,Oi,ie=>n.getItem(ie).then(ve=>{var xe;const we=ve??{},P=we._edition_count??((xe=we._books)==null?void 0:xe.length)??0,fe=ho(we),de=[fe==null?void 0:fe.l1,fe==null?void 0:fe.l2].filter(Boolean).join(" ");return[ie,{id:ie,title:we.title,versionCount:P,loaded:!0,cls:de||void 0,l1:(fe==null?void 0:fe.l1)||void 0,measure:ve&&Wt(ve,p.unit.juan)||void 0,hasImage:!!we._has_image}]}).catch(()=>[ie,{id:ie,loaded:!0}]),()=>M).then(ie=>{M||b(ve=>{const we=new Map(ve);for(const[P,fe]of ie)we.set(P,fe);return we})}),()=>{M=!0}},[n,_,p.unit.juan]);const L=g.useMemo(()=>{const M=new Map;for(const ie of e.alt_names||[]){const ve=ie.type||p.section.aliases;M.has(ve)||M.set(ve,[]),M.get(ve).push(ie.name)}return[...M.entries()].sort((ie,ve)=>qa(ie[0])-qa(ve[0])).map(([ie,ve])=>({label:ie,names:ve}))},[e.alt_names,p]),z=((re=e.dates)==null?void 0:re.birth)??void 0,T=((D=e.dates)==null?void 0:D.death)??void 0,B=(se=e.dates)==null?void 0:se.floruit,W=z!=null||T!=null?`${h(z)||"?"}—${h(T)||"?"}`:Array.isArray(B)&&B.length===2&&B.every(M=>Number.isFinite(M))?d("entityPage.floruit",{from:h(B[0]),to:h(B[1])}):"",N=new Set(["本名","字","號","号"]),R=L.filter(M=>N.has(M.label)),H=L.filter(M=>!N.has(M.label)),q=H.reduce((M,ie)=>M+ie.names.length,0),te=g.useMemo(()=>{const M=[];for(const ve of R)M.push({label:ve.label,value:ve.names.map(we=>c(we)).join("、")});const ie=w.length;return ie&&M.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:ie})}),M},[w,R,c,d]),ae=M=>{var ie;return(ie=L.find(ve=>M.includes(ve.label)))==null?void 0:ie.names[0]},V=ae(["字"]),G=ae(["號","号"]),me=[V?d("entityPage.zi",{name:c(V)}):"",G?d("entityPage.hao",{name:c(G)}):""].filter(Boolean).join(","),K=e.native_place,le=e.dynasty?yy[e.dynasty]:void 0,Se=(()=>{if(!le||z==null||T==null||T<z)return null;const[M,ie]=le,ve=Math.max(z,M),we=Math.min(T,ie);if(we<=ve)return null;const P=ie-M;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":d("entityPage.lifeAria",{birth:h(z),death:h(T),years:T-z+1}),children:t.jsx("i",{style:{left:`${(ve-M)/P*100}%`,width:`${(we-ve)/P*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${h(M)} ${c(e.dynasty)}`}),t.jsx("span",{children:d("entityPage.lifeYears",{years:T-z+1})}),t.jsx("span",{children:h(ie)})]})]})})(),A=g.useMemo(()=>{if(!n||j.length===0||j.some(ve=>!ve.loaded))return null;const M=new Map;for(const ve of j){const we=Dr(ve.l1);we&&M.set(we,(M.get(we)??0)+1)}const ie=Bn.map(ve=>({...ve,n:M.get(ve.key)??0})).filter(ve=>ve.n>0);return ie.length?ie:null},[j,n]),je=t.jsxs(Dn,{kind:xy(p.entityPage.subtype,e.subtype,c),title:c(e.primary_name||e.title),subtitle:me||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(ot,{items:[e.dynasty?c(e.dynasty):"",W,K?d("entityPage.nativePlace",{place:c(K)}):""]}),Se]}),description:(_e=e.description)!=null&&_e.text?t.jsx(Ot,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:xo((Ae=e.description)==null?void 0:Ae.text)?6:void 0,facts:te,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[q>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:d("entityPage.moreNames",{n:q})}),t.jsx("dl",{children:H.map(M=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(M.label)}),t.jsx("dd",{children:M.names.map(ie=>c(ie)).join("、")})]},M.label))})]}),A&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:d("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:A.map(M=>t.jsx("i",{style:{flexGrow:M.n,background:r(M.token)}},M.key))}),t.jsx("div",{className:"bim-d-dist-key",children:A.map(M=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(M.token)}}),c(M.label)," ",M.n]},M.key))})]})]}),ce=g.useMemo(()=>j.filter(M=>M.loaded&&(M.versionCount??0)>0).sort((M,ie)=>(ie.versionCount??0)-(M.versionCount??0)).slice(0,3),[j]),ze=!!n&&j.length>=3&&S.some(M=>!M.loaded),$e=u==="全部"&&(ze||ce.length>=2),Fe=e.external_ids||{},ee=[];Fe.cbdb_id!=null&&ee.push({label:"CBDB",id:String(Fe.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${Fe.cbdb_id}`,note:Fe.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const F=Fe.wikidata_id;F&&ee.push({label:"Wikidata",id:F,href:`https://www.wikidata.org/wiki/${F}`});const U=Fe.viaf_id;U&&ee.push({label:"VIAF",id:U,href:`https://viaf.org/viaf/${U}`});const he=k.map(M=>({key:M.cls,label:`${M.label} ${M.count}`})),X=[...$e&&!ze?[{id:"featured",label:d("entityPage.sec.featured"),count:ce.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...ee.length?[{id:"external",label:d("entityPage.sec.external"),count:ee.length}]:[]],O=$e?t.jsxs(at,{id:"featured",title:d("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:d("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":ze||void 0,children:[ze&&[0,1,2].map(M=>t.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[t.jsx("span",{className:"bim-d-pick-t",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "}),t.jsx("div",{className:"bim-d-pick-n",children:" "})]},M)),!ze&&ce.map(M=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(nt,{id:M.id,label:c(M.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(ot,{items:[M.section?c(M.section):"",M.measure?c(M.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:M.versionCount}),t.jsx("span",{children:d("entityPage.versionsUnit")}),M.hasImage&&t.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},M.id))]})]}):null,J=j.length===0?t.jsx(at,{title:d("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[O,t.jsxs(at,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(ot,{items:[d("entityPage.total",{n:j.length}),C.length!==j.length?d("entityPage.current",{n:C.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[he.length>1&&t.jsx(Ai,{items:he,value:u,onChange:M=>{m(M),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":v==="versions",onClick:()=>{v==="default"&&x(!0),y(M=>M==="default"?"versions":"default")},children:d(v==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Mi(C.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:d("entityPage.col.work")}),t.jsx("th",{children:d("entityPage.col.section")}),t.jsx("th",{children:d("entityPage.col.role")}),t.jsx("th",{children:d("entityPage.col.versions")}),t.jsx("th",{"aria-label":d("entityPage.col.image")})]})}),t.jsx("tbody",{children:S.map(M=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:M.id,label:c(M.title),onNavigate:i,renderLink:o,dense:!0}),M.measure?t.jsx(ot,{items:[c(M.measure)]}):!M.loaded&&n?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.section||M.loaded?"":" bim-d-zt-blank"}`,children:M.section?c(M.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.role?"":" bim-d-zt-blank"}`,children:M.role?c(M.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.loaded?"":" bim-d-zt-blank"}`,children:M.loaded?M.versionCount?d("entityPage.nZhong",{n:M.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),t.jsx("td",{className:M.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:M.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},M.id))})]}),S.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("entityPage.emptyRole")}),!f&&t.jsx(go,{total:C.length,shown:S.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),oe=ee.length>0?t.jsx(rn,{id:"external",title:d("entityPage.sec.external"),items:ee.map(M=>t.jsxs("a",{href:M.href,target:"_blank",rel:"noopener noreferrer",children:[M.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:ee.map(M=>M.id),foot:Fe.cbdb_id!=null&&Fe.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Hn,{railTop:s,back:a,nav:X,railLinks:l,main:J,card:je,side:oe})},Vo="(max-width: 719px)",jy=`${Vo}, (pointer: coarse)`,Td=`
|
|
1353
|
+
${O??""}`,[st,_t]=g.useState({key:Ve,data:Y,started:!!Y});if(st.key!==Ve)_t({key:Ve,data:Y,started:!1});else if(Y!==st.data&&(_t({key:Ve,data:Y,started:!!Y}),Y)){const E=Y.pages??[];(!st.started||!E.some(ue=>ue.page===Ye))&&Z(Kt(Y))}g.useEffect(()=>{ye(new Set),He(null)},[O,A]);const Sp=g.useCallback(E=>{if(ye(new Set(E)),E.length>0){const ue=E[0],Te=parseInt(ue.split(":")[0],10);isNaN(Te)||Z(Te)}},[]),It=g.useMemo(()=>{const E=new Map;for(const ue of(Y==null?void 0:Y.pages)??[])E.set(ue.page,ue);return E},[Y]),wn=yt(Y),qn=g.useCallback(E=>{var Ge;const ue=I.images;if(!ue||ue.length===0)return;const Te=(Ge=It.get(E))==null?void 0:Ge.seq;return(Te?ue.find(et=>et.seq===Te):void 0)??ue.find(et=>et.pageNo===E)??ue[E-1]},[I.images,It]),es=Ie>1.5,Kn=g.useCallback((E,ue=!1)=>{const Te=qn(E);return Te?E===wn||ue?Te.hiresUrl??Te.url:Te.url:E===wn?(Y==null?void 0:Y.imageUrl)??"":""},[qn,Y,wn]),_p=g.useMemo(()=>Kn(Ye,es),[Kn,Ye,es]),Et=g.useMemo(()=>[...It.keys()].sort((E,ue)=>E-ue),[It]),Xn=g.useRef(Ye);Xn.current=Ye;const ts=g.useRef(0),Zn=g.useCallback(E=>{var ue;Xn.current===E||!It.has(E)||(ts.current=Date.now()+1e3,Xn.current=E,Z(E),(ue=It.get(E))!=null&&ue.columns.some(Te=>Te.chars.length>0)&&Ft(Te=>({page:E,nonce:((Te==null?void 0:Te.nonce)??0)+1})))},[It]),Sn=g.useCallback(E=>{const ue=Xn.current,Te=Et.indexOf(ue),Ge=Et[Te<0?0:Te+E];Ge===void 0||Ge===ue||Zn(Ge)},[Et,Zn]),ns=g.useCallback(E=>{if(!E.trim().match(/^\d+$/)||Et.length===0)return null;const Te=parseInt(E.trim(),10),Ge=Number.isFinite(Te)?Te:Number.MAX_SAFE_INTEGER;return Et.reduce((et,kt)=>Math.abs(kt-Ge)<Math.abs(et-Ge)?kt:et,Et[0])},[Et]),[qi,Ki]=g.useState(null),Jn=g.useRef(null),$p=g.useCallback(E=>{Jn.current=E,Ki(E)},[]),is=g.useCallback(()=>{const E=Jn.current;if(Jn.current=null,Ki(null),E===null)return;const ue=ns(E);ue!==null&&Zn(ue)},[ns,Zn]),Xi=Et.indexOf(Ye),Cp=g.useCallback(E=>{if(E.altKey||E.ctrlKey||E.metaKey)return;const ue=E.target.tagName;ue==="INPUT"||ue==="TEXTAREA"||ue==="SELECT"||(E.key==="ArrowLeft"||E.key==="PageUp"?(E.preventDefault(),Sn(-1)):(E.key==="ArrowRight"||E.key==="PageDown")&&(E.preventDefault(),Sn(1)))},[Sn]);g.useEffect(()=>{if(Y)for(const E of[1,-1,2,3]){const ue=Kn(Ye+E);ue&&Pr(ue)}},[Y,Ye,Kn]);const rs=g.useMemo(()=>{var gs;if(!Y)return null;if(Ye===wn)return Y;const E=It.get(Ye);if(E&&E.width>0&&E.height>0)return{page_id:`p:${Ye}`,title:`第${Ye}葉`,image_size:[E.width,E.height],total_warped_w:E.width,columns:[{col:1,warped_w:E.width,warped_h:E.height,offset_x:0,strips:[],chars:E.columns.flatMap(Ze=>Ze.chars).map(Ze=>({id:Ze.id,char:Ze.char,slot:Ze.slot,pos:Ze.pos,sub:Ze.sub,bbox_col:Ze.bbox??[0,0,0,0]}))}]};const ue=(gs=Y.pages)==null?void 0:gs.find(Ze=>Ze.page===Ye),[Te,Ge]=Y.image_size||[2386,3082],et=qn(Ye),kt=(et==null?void 0:et.width)??Te,tr=(et==null?void 0:et.height)??Ge,us=kt/Te,ms=tr/Ge,hs=new Map;for(const Ze of Y.columns){const gt=(Ze.strips||[]).flatMap(ii=>ii.srcQuad.map(ri=>ri[0]));if(gt.length===0)continue;const Rt=Ze.top_y??0,nr=Ze.bottom_y??Rt+Ze.warped_h;hs.set(Ze.col,{x0:Math.min(...gt),x1:Math.max(...gt),top:Rt,slotH:(nr-Rt)/21})}return{page_id:`p:${Ye}`,title:`第${Ye}葉`,image_size:[kt,tr],total_warped_w:kt,columns:ue?ue.columns.map(Ze=>{const gt=hs.get(Ze.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ze.col,warped_w:kt,warped_h:tr,offset_x:0,strips:[],chars:Ze.chars.map(Rt=>{const nr=Rt.slot??Rt.pos??0,ii=(gt.top+(nr-1)*gt.slotH)*ms,ri=(gt.x0+gt.x1)/2,[Mp,Pp]=Rt.sub==="a"?[ri,gt.x1]:Rt.sub==="b"?[gt.x0,ri]:[gt.x0,gt.x1];return{...Rt,bbox_col:[Mp*us,ii,Pp*us,ii+gt.slotH*ms]}})}}):[]}},[Y,Ye,wn,It,qn]),{entryTitle:Qn,authors:os}=Xf(n,i,d===void 0),[ss,Zi]=g.useState("text");if(g.useEffect(()=>{Zi("text")},[O,A]),H==="loading")return t.jsx(ga,{className:k,style:C,title:d??Qn,label:S("reader.loading")});if(H==="missing"||!N||!le)return t.jsx("div",{className:k,style:{...C,...ha},children:S("reader.noText")});if(F==="failed")return t.jsx("div",{className:k,style:{...C,...ha},children:S("reader.tocFailed")});if(!X)return t.jsx(ga,{className:k,style:C,title:d??Qn,label:S("reader.tocLoading")});const Xt=Vf(le,X),Tp=Gf(X,Ke,Xt,_,P),Ji=N.versions.map(E=>({key:E.key,label:ke.textVersionLabel(E),optionLabel:_(ke.textVersionLabel(E)),sourceName:xa(E)?S("reader.originalSource"):E.source_name?_(E.source_name):void 0,license:E.license??void 0,sourceUrl:E.source_url??void 0,primary:E.key===Se})),ht=Df((ps=X.source)==null?void 0:ps.upstream),ei=(typeof d=="string"?_(d):d)??(X.title?_(X.title):Qn?_(Qn):void 0),as=le.edition_label?_(le.edition_label):void 0,Qi=ei?t.jsx("a",{href:B(n),title:S("reader.viewEntry"),onClick:l?E=>{E.metaKey||E.ctrlKey||(E.preventDefault(),l(n))}:void 0,children:ei}):void 0,zp=Qi&&as?t.jsxs(t.Fragment,{children:[Qi,t.jsxs("span",{className:"bim-rd-ed",children:["·",as]})]}):Qi,Np=os.length>0?_(os.slice(0,2).map(E=>`${E.dynasty?`〔${E.dynasty}〕`:""}${E.name}${` ${E.role||S("reader.defaultRole")}`}`).join("、")):void 0,er=J?Zc(J,Xt,_,P):void 0,Zt=P&&!!(se!=null&&se.json),Jt=(se==null?void 0:se.json)??null,ln=(se==null?void 0:se.md)??null,ls=Zt&&!Ce&&Dc(Jt.sections),Ip=ls&&!(ln&&ge.readingMode==="paragraph"&&ji(ln)),Ep=Zt&&ls?t.jsx(gf,{juan:Jt,view:ss,onView:Zi,textHasEntries:Ip}):void 0,Rp=!0,ti=ln?ln.replace(/^##\s+[^\n]+\n+/,""):null,ni=xa(le),Ht=ni?S("reader.originalSource"):le.source_name?_(le.source_name):void 0,Lp=(typeof c=="string"?_(c):c)??(ni?void 0:Ht??_(ke.textVersionLabel(le))),Ap=(Y==null?void 0:Y.hasNorm)===!0;return t.jsxs(Yl,{className:k,style:C,title:zp,subtitle:Lp,byline:Np,current:er,pagerUnit:Xt,rail:Ep,revisedAt:x,backHref:v,backLabel:y,onReportError:f?E=>f({...E,bookTitle:typeof ei=="string"?ei:void 0,entryId:n}):void 0,workLinkToggle:Zt&&!Ce&&!!l&&!!(Jt!=null&&Jt.sections.some(E=>E.work_id)),toc:Tp,tocCaption:S("reader.tocCaption",{n:X.chapters.length,unit:_(Xt)}),tocHeader:P&&X.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:Ce?S("reader.searchChaptersPlaceholder"):S("reader.searchUnitPlaceholder",{unit:_(Xt)}),"aria-label":Ce?S("reader.searchChapters"):S("reader.searchUnit",{unit:_(Xt)}),value:fe,onChange:E=>de(E.target.value)}):void 0,activeKey:O??null,onSelect:D,images:I.images,renderImageOverlay:h,imagePanel:Y?"open":u,isWarpMode:!!Y,customImagePanel:Y&&rs?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Cp,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",outline:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px 6px",fontSize:12,color:r("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4},children:t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[Q.size>0&&t.jsxs("button",{type:"button",onClick:()=>ye(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",Q.size,")"]}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2},"data-testid":"facsimile-zoom-tools",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"缩小",title:"缩小",disabled:Ie<=1,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Ie*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Ie>=6,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Ie===1,onClick:()=>{var E;return(E=Be.current)==null?void 0:E.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Wf,{ref:Be,resetKey:Ye,onScaleChange:De,style:{flex:1,minHeight:0},children:t.jsx(Ro,{imageUrl:_p,pageData:rs,selectedCharIds:Q,hoveredCharId:We,preserveMargins:Le,onCharClick:E=>{ye(Te=>{const Ge=new Set(Te);return Ge.has(E)?Ge.delete(E):(Ge.clear(),Ge.add(E)),Ge});const ue=document.querySelector(`[data-char-id="${E}"]`);ue&&ue.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:He})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":S("reader.facsimilePager"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"6px 4px 0",fontSize:13,color:r("meta-fg")},children:[t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:Xi<=0,onClick:()=>Sn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Ye,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 8px",background:r("rule"),borderRadius:10},children:["第",t.jsx("input",{type:"text",inputMode:"numeric","data-testid":"facsimile-page-input","aria-label":S("reader.facsimilePageInput"),size:Math.max(2,String(qi??Ye).length),value:qi??String(Ye),onFocus:E=>E.currentTarget.select(),onChange:E=>$p(E.target.value),onKeyDown:E=>{E.key==="Enter"?(E.preventDefault(),is()):E.key==="Escape"&&(Jn.current=null,Ki(null)),E.stopPropagation()},onBlur:is,style:{width:`${Math.max(2,String(qi??Ye).length)+1}ch`,minHeight:28,textAlign:"center",font:"inherit",border:`1px solid ${r("rule")}`,borderRadius:4,background:"transparent",color:"inherit"}}),"葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:Xi<0||Xi>=Et.length-1,onClick:()=>Sn(1),children:"›"})]})]}):void 0,settingsAnnotate:Y?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${Ne?"bim-rd-on":""}`,"aria-pressed":Ne,title:"切换外挂现代断句标点",onClick:()=>Pe(E=>!E),children:Ne?"标点":"无标点"}):void 0,prefs:ge,onPrefsChange:T,versions:Ji.length>1?Ji:void 0,currentVersionKey:Ji.length>1?le.key:void 0,onVersionChange:re,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:ji(ln),allowVertical:m,origScriptAvailable:Ap,contentLoading:ve,children:[(ve||pe&&!Y&&!Zt&&ti==null)&&t.jsx(sn,{}),!ve&&Y&&t.jsxs("article",{className:"bim-rd-prose",style:{marginTop:0},children:[t.jsxs("header",{style:{marginBottom:16},children:[t.jsx("h1",{className:"bim-rd-h1",children:J!=null&&J.title?_(J.title):er}),(Ht||le.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Ht,le.license&&t.jsxs(t.Fragment,{children:[Ht&&t.jsx("span",{className:"bim-rd-dot"}),le.license]})]})]}),t.jsx(Po,{pageData:Y,pages:Y.pages,punctuations:Y.punctuations||Hf,selectedCharIds:Q,hoveredCharId:We,onSelectionChange:Sp,onCharClick:E=>{ye(Te=>{const Ge=new Set(Te);return Ge.has(E)?Ge.delete(E):(Ge.clear(),Ge.add(E)),Ge});const ue=parseInt(E.split(":")[0],10);isNaN(ue)||Z(ue)},onCharHover:He,mode:"horizontal",showPunctuation:Ne,entities:Me,entityTransport:i,onEntityNavigate:j,onVisiblePageChange:E=>{Date.now()>=ts.current&&Z(E)},convert:_,scrollToPage:Qe,pageBreaks:ge.pageBreaks,pageIndicatorY:ge.pageIndicatorY,onPageIndicatorYChange:E=>T({pageIndicatorY:E}),quoteStyle:ge.quoteStyle,bookTitleStyle:ge.bookTitleStyle,showWorks:ge.showWorks})]}),!ve&&!Y&&Zt&&Jt&&t.jsx(mf,{juan:Jt,rawText:ln,positionLabel:qf(J,X,Xt,_),groupLabel:Kf(X,O??null),index:Uf(n,X),searchQuery:fe,onNavigate:l,transport:i,workLabelCache:Je,prefs:ge,view:ss,onViewChange:Zi},`${A}/${O}`),!ve&&!Y&&!Zt&&ti!=null&&J&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:J.title?_(J.title):er}),(Ht||le.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ni&&Ht&&t.jsx(t.Fragment,{children:Ht}),!ni&&le.source_name&&t.jsxs(t.Fragment,{children:[S("reader.textSource")," ",le.source_url?t.jsx("a",{className:"bim-rd-link",href:le.source_url,target:"_blank",rel:"noreferrer",children:_(le.source_name)}):_(le.source_name)]}),Ht&&le.license&&t.jsx("span",{className:"bim-rd-dot"}),le.license]}),ht&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[S("reader.upstream")," ",ht.url?t.jsx("a",{className:"bim-rd-link",href:ht.url,target:"_blank",rel:"noreferrer",children:_(ht.name??ht.url)}):_(ht.name??""),ht.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),ht.license_url?t.jsx("a",{className:"bim-rd-link",href:ht.license_url,target:"_blank",rel:"noreferrer",children:ht.license}):ht.license]}),ht.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Al,{text:ht.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(_o,{text:ti,mode:ge.readingMode,tables:Rp,gujiMarkdown:!0,bookMarking:So(ge),quoteStyle:ge.quoteStyle})})]}),!ve&&!pe&&!Y&&!Zt&&ti==null&&J&&t.jsx("div",{className:"bim-rd-state",children:S("reader.chapterFailed")}),!ve&&X.references&&X.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:S("reader.references")}),t.jsx("ol",{children:X.references.map((E,ue)=>t.jsxs("li",{children:[E.url?t.jsx("a",{className:"bim-rd-link",href:E.url,target:"_blank",rel:"noopener noreferrer",children:_(E.title)}):t.jsx("span",{children:_(E.title)}),E.author&&t.jsxs("span",{children:[",",_(E.author)]}),E.note&&t.jsxs("span",{children:["。",_(E.note)]})]},ue))})]})]})};function xa(e){return e.is_original===!0||e.source==="original"}function qf(e,n,i,o){var a,l;if(!e)return;const s=(l=(a=n.juan_metadata)==null?void 0:a[e.file])==null?void 0:l.vol_label;return o(s?`${s}冊`:`${i}${e.n}`)}function Kf(e,n){if(!n)return;const i=o=>{var s;for(const a of o??[]){const l=i(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return i(e.juan_groups)}function Xf(e,n,i){const[o,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const Jc={bug:{key:"bug",color:r("danger")},resource:{key:"resource",color:r("primary")},suggestion:{key:"suggestion",color:r("primary")},other:{key:"other",color:r("desc-fg")}},Zf=Jc.other,Qc={pending:{key:"pending",color:r("warning")},in_progress:{key:"in_progress",color:r("primary")},resolved:{key:"resolved",color:r("success")},wontfix:{key:"wontfix",color:r("desc-fg")},duplicate:{key:"duplicate",color:r("desc-fg")}},Jf=Qc.pending;function Qf(e){try{const n=new Date(e),i=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())} ${i(n.getHours())}:${i(n.getMinutes())}`}catch{return e}}function ex(e,n){if(!e)return!1;try{const i=new URL(e,n);if(i.protocol!=="http:"&&i.protocol!=="https:")return!1;const o=new URL(n);return i.hostname===o.hostname}catch{return!1}}const Wo=({items:e,loading:n})=>{const i=it(),{t:o,convert:s}=ne();return n?t.jsx(sn,{}):e.length===0?t.jsx("div",{style:tx,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=Jc[a.type]||Zf,d=Qc[a.status]||Jf,c=typeof window<"u"&&ex(a.pageUrl,window.location.href);return t.jsxs("div",{style:nx,children:[t.jsxs("div",{style:ix,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...ba,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...ba,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:rx,children:Qf(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:ox,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:mr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:mr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:mr,children:a.pageUrl}))]}),t.jsx("div",{style:sx,children:s(a.content)}),a.reply&&t.jsxs("div",{style:ax,children:[t.jsx("div",{style:lx,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},tx={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},nx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},ix={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},ba={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},rx={fontSize:"12px",color:r("desc-fg")},ox={fontSize:"12px",marginBottom:"6px"},mr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},sx={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},ax={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},lx={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},Or=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ee(),[d,c]=g.useState(null),[p,h]=g.useState([]),[u,m]=g.useState("recommend"),[f,x]=g.useState([]),[v,y]=g.useState(!1),$=o??u,b=R=>{m(R),s==null||s(R)},[w,j]=g.useState(!0),[k,C]=g.useState(null),[S,_]=g.useState(null),[L,z]=g.useState(null);g.useEffect(()=>{let R=!1;if(e.getCounts)return e.getCounts().then(H=>{R||c({works:H.works,books:H.books,collections:H.collections})}).catch(()=>{}),()=>{R=!0}},[e]),g.useEffect(()=>{let R=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const q=await e.getRecommended();if(q!=null&&q.groups)return q.groups.flatMap(te=>te.items.map(ae=>({...ae,group:te.name})))}catch{}return[]})().then(async q=>{if(R)return;const te=q.filter(V=>V.id);if(te.length===0){j(!1);return}const ae=await Promise.all(te.map(async V=>{if(V.type)return{id:V.id,title:V.title,type:V.type,author:V.author,dynasty:V.dynasty,role:V.role,edition:V.edition,has_text:V.has_text,has_image:V.has_image,has_collated:V.has_collated,subtype:V.subtype,primary_name:V.primary_name,group:V.group,fallbackDescription:V.description};try{let G=null;if(e.getEntry)G=await e.getEntry(V.id);else{const me=await e.getItem(V.id);me&&(G={id:V.id,title:me.title||V.id,type:me.type||"work"})}if(G)return{...G,group:V.group,fallbackDescription:V.description}}catch{}return{id:V.id,title:V.title,type:ke.extractType(V.id),group:V.group,fallbackDescription:V.description}}));R||(h(ae.filter(V=>V!==null)),j(!1))}),()=>{R=!0}},[e,i]);const T=g.useRef(!1),B=g.useRef(!1),W=g.useRef(!1);g.useEffect(()=>{if($!=="catalog"||T.current)return;const R=e.getCatalogProgress??e.getResourceProgress;if(!R)return;T.current=!0;let H=!1;return R.call(e).then(q=>{H||C(q)}).catch(()=>{T.current=!1}),()=>{H=!0}},[e,$]),g.useEffect(()=>{if($!=="collection"||B.current||!e.getCollectionProgress)return;B.current=!0;let R=!1;return e.getCollectionProgress().then(H=>{R||_(H)}).catch(()=>{B.current=!1}),()=>{R=!0}},[e,$]),g.useEffect(()=>{if($!=="site"||W.current||!e.getSiteProgress)return;W.current=!0;let R=!1;return e.getSiteProgress().then(H=>{R||z(H)}).catch(()=>{W.current=!1}),()=>{R=!0}},[e,$]),g.useEffect(()=>{if(!a||$!=="feedback")return;let R=!1;return y(!0),fetch(a).then(H=>H.json()).then(H=>{!R&&H.success&&x(H.items||[])}).catch(()=>{}).finally(()=>{R||y(!1)}),()=>{R=!0}},[a,$]);const N=R=>t.jsx(kn,{type:R,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:r("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"16px"},children:[t.jsx(zn,{label:l.home.recommendTab,active:$==="recommend",onClick:()=>b("recommend")}),t.jsx(zn,{label:l.home.catalogTab,active:$==="catalog",onClick:()=>b("catalog")}),t.jsx(zn,{label:l.home.collectionTab,active:$==="collection",onClick:()=>b("collection")}),t.jsx(zn,{label:l.home.siteTab,active:$==="site",onClick:()=>b("site")}),a&&t.jsx(zn,{label:l.home.feedbackTab,active:$==="feedback",onClick:()=>b("feedback")})]}),$==="recommend"&&t.jsx(cx,{recommended:p,loading:w,onNavigate:n,getIcon:N,t:l}),$==="catalog"&&t.jsx(ya,{progress:k,t:l,onNavigate:n}),$==="collection"&&t.jsx(ya,{progress:S,t:l,onNavigate:n}),$==="site"&&t.jsx(px,{progress:L,t:l,totalWorks:(d==null?void 0:d.works)??0}),$==="feedback"&&a&&t.jsx(Wo,{items:f,loading:v})]})})},zn=({label:e,active:n,onClick:i})=>t.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:r(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${r("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),cx=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=it();if(n)return t.jsx(sn,{});if(e.length===0)return null;const l=new Map;for(const d of e){const c=d.group||s.home.recommendedBrowse;l.has(c)||l.set(c,[]),l.get(c).push(d)}return t.jsx(t.Fragment,{children:Array.from(l.entries()).map(([d,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:d}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(p=>{const h=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i==null||i(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,cursor:"pointer",background:r("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:o(p.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.title,p.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:p.edition})]}),h&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h})]})]},p.id)})})]},d))})},ya=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(sn,{});const o=[...e.resources].sort((d,c)=>d.priority-c.priority),s=["in_progress","done","todo"],a={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},l={in_progress:r("progress-active"),done:r("progress-done"),todo:r("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=o.filter(p=>p.status===d);return c.length===0?null:t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:l[d]}}),a[d]," (",c.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(p=>t.jsx(dx,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},dx=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=it(),a=e.total>0?Math.round(e.imported/e.total*100):0,l=e.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const d=e.edition?`${e.name}·${e.edition}`:e.name,c=e.collection_id||e.work_id;return c&&o?t.jsx("a",{href:s(c),onClick:p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},onMouseEnter:p=>p.currentTarget.style.borderBottomStyle="solid",onMouseLeave:p=>p.currentTarget.style.borderBottomStyle="dashed",children:d}):e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:d}):d})()}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:r("widget-border"),color:r("desc-fg"),whiteSpace:"nowrap"},children:e.collection_id?n.indexType.collection:e.work_id?n.indexType.work:l})]}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?xt(n.home.progressFormat,{imported:String(e.imported),total:String(e.total)}):n.home.totalPending})]}),e.total>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:i,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},px=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(sn,{});const o=[...e.resources].sort((c,p)=>c.priority-p.priority),s=o.filter(c=>c.imported>0),a=o.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=i>0?Math.round(l/i*100):0;return t.jsxs("div",{children:[i>0&&t.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${r("primary")} 6%, transparent)`,fontSize:"13px",color:r("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",i.toLocaleString()," ",n.indexType.work," (",d,"%)"]}),s.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(ja,{item:c,t:n,totalWorks:i},c.id))})]}),a.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(ja,{item:c,t:n,totalWorks:i},c.id))})]})]})},ja=({item:e,t:n,totalWorks:i})=>{const o=i>0?Math.round(e.imported/i*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:t.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:e.name}):e.name})}),t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${o}%)`:n.home.statusTodo})]}),e.imported>0&&i>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${o}%`,borderRadius:"2px",background:r("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},va="(max-width: 768px)";function ux(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(va).matches);return g.useEffect(()=>{const i=window.matchMedia(va),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const mx=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var B;const a=Ee(),{convert:l}=Oe(),d=ux(),[c,p]=g.useState(null),[h,u]=g.useState(null),[m,f]=g.useState(!1),[x,v]=g.useState("detail"),[y,$]=g.useState([]),[b,w]=g.useState(!1),j=g.useCallback(async W=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){$([]);return}w(!0);try{if(e.getCollectionCatalogs){const N=await e.getCollectionCatalogs(W);$(N||[])}else if(e.getCollectionCatalog){const N=await e.getCollectionCatalog(W);$(N?[{resource_id:"",data:N}]:[])}}catch{$([])}finally{w(!1)}},[e]),k=g.useCallback(async W=>{if(i){i(W);return}p(W),u(null),$([]),v("detail"),f(!0);try{const N=await e.getItem(W.id);N&&(u(N),N.type==="collection"&&j(W.id))}catch(N){console.error("加载详情失败:",N)}finally{f(!1)}},[e,i,j]),C=g.useCallback(async W=>{u(null),$([]),v("detail"),f(!0);try{const N=await e.getItem(W);N&&(u(N),p({id:W,title:N.title||W,type:N.type||"book"}),N.type==="collection"&&j(W))}catch(N){console.error("导航失败:",N)}finally{f(!1)}},[e,j]),S=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,_=(h==null?void 0:h.type)==="collection"&&(y.length>0||b)||(h==null?void 0:h.type)==="work"&&S,L=d&&(m||h),z=g.useCallback(()=>{p(null),u(null),$([]),v("detail")},[]),T=t.jsx(t.Fragment,{children:m?t.jsx(sn,{}):h?t.jsxs(t.Fragment,{children:[(_||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${r("widget-border")}`,padding:d?"0 12px":"0 48px",background:r("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[_&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>v("detail"),style:di(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:di(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&y.map(W=>t.jsx("button",{onClick:()=>v(`catalog:${W.resource_id}`),style:di(x===`catalog:${W.resource_id}`),children:W.short_name?`${l(W.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},W.resource_id)),h.type==="work"&&S&&t.jsx("button",{onClick:()=>v("collated"),style:di(x==="collated"),children:a.detailTab.collatedEdition})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),t.jsx("div",{style:{padding:d?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:x==="detail"?t.jsx(io,{data:h,transport:e,onNavigate:C}):x.startsWith("catalog:")?t.jsx(ro,{data:(B=y.find(W=>`catalog:${W.resource_id}`===x))==null?void 0:B.data,onNavigate:C}):x==="collated"?t.jsx(Oo,{id:h.id,transport:e,onNavigate:C}):null})]}):t.jsx(Or,{transport:e,onNavigate:C,recommendedIds:o})});return d?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:L?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${r("widget-border")}`,background:r("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:z,style:{padding:"4px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",a.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:T})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Sr,{transport:e,onEntryClick:k,hideModeIndicator:n}),!h&&t.jsx(Or,{transport:e,onNavigate:C,recommendedIds:o})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${r("widget-border")}`,display:"flex",flexDirection:"column",background:r("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(Sr,{transport:e,onEntryClick:k,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:T})]})};function di(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const hx=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[h,u]=g.useState(null),[m,f]=g.useState("horizontal"),[x,v]=g.useState(!0),y=g.useRef(null),$=g.useCallback(k=>{p(new Set(k))},[]),b=g.useCallback(k=>{if(p(C=>{const S=new Set(C);return S.has(k)?S.delete(k):(S.clear(),S.add(k)),S}),y.current){const C=y.current.querySelector(`[data-char-id="${k}"]`);C&&C.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),w=()=>{var k;p(new Set),window.getSelection&&((k=window.getSelection())==null||k.removeAllRanges())},j=i.length>0?i:e.punctuations||[];return t.jsxs("div",{className:`guji-reader-container ${l}`,style:d,children:[t.jsxs("header",{className:"guji-reader-header",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&t.jsx("button",{type:"button",onClick:a,className:"guji-reader-btn",style:{marginRight:6},children:"‹ 返回"}),t.jsx("span",{className:"guji-reader-title",children:o||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:r("meta-fg")},children:s}),t.jsx("span",{className:"guji-reader-tag",children:"WebGL 客户端透视矫正对读"})]}),t.jsxs("div",{className:"guji-reader-actions",children:[t.jsxs("span",{style:{fontSize:"0.85rem",color:r("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:r("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:w,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>v(k=>!k),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(k=>k==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:m==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(Ro,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:b,onCharHover:u})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:m==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Po,{pageData:e,punctuations:j,selectedCharIds:c,hoveredCharId:h,onSelectionChange:$,onCharClick:b,onCharHover:u,mode:m,showPunctuation:x})]})]})]})},gx=e=>typeof e=="string"&&Array.from(e).length===1;function fx(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!gx(s.pre_char)||i.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char??void 0})}return i}function xx(e){var i;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const o of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((i=o==null?void 0:o.canvas)==null?void 0:i.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const ed=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function lt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const bx=new Set(["main","solo","jz_r","jz_l"]),yx=new Set(["body","banxin","blank"]);function jx(e){const n={};return typeof e.lane=="string"&&bx.has(e.lane)&&e.lane!=="main"&&(n.lane=e.lane),e.lacuna===!0&&(n.lacuna=!0),e.guess===!0&&(n.guess=!0),typeof e.zi=="string"&&e.zi&&(n.zi=e.zi),n}function vx(e){const n={};typeof e.kind=="string"&&yx.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=lt(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=lt(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function hr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function kx(e){return typeof e=="string"&&Array.from(e).length===1}function td(e){const n=new Map,i={badAnchor:0,badChar:0,badWhy:0,notObject:0},o=e&&typeof e=="object"?e.items:void 0;for(const s of Array.isArray(o)?o:[]){if(!s||typeof s!="object"){i.notObject++;continue}const{a,t:l,why:d}=s;if(typeof a!="string"||!ed.test(a)){i.badAnchor++;continue}if(!kx(l)){i.badChar++;continue}if(d!==void 0&&d!=="异体"){i.badWhy++;continue}n.set(a,l)}return{map:n,dropped:i}}function nd(e){return td(e).map}function wx(e,n,i){var h,u,m,f,x,v,y,$,b,w;const o=i==null?null:nd(i),s=new Map,a=new Map;for(const j of hr(n)){const k=lt(j.page);if(k!==void 0){s.set(k,j);for(const C of Array.isArray(j.cells)?j.cells:[]){const S=C==null?void 0:C.box;typeof(C==null?void 0:C.a)=="string"&&Array.isArray(S)&&S.length===4&&S.every(_=>lt(_)!==void 0)&&a.set(C.a,[S[0],S[1],S[0]+S[2],S[1]+S[3]])}}}const l=[],d=new Map,c=new Map;for(const j of hr(e)){const k=lt(j.page);k!==void 0&&typeof j.label=="string"&&j.label&&d.set(k,j.label)}for(const j of hr(e)){const k=lt(j.page);if(k===void 0)continue;const C=[];for(const _ of Array.isArray(j.columns)?j.columns:[]){const L=lt(_==null?void 0:_.col);if(L===void 0)continue;const z=[];for(const B of Array.isArray(_.cells)?_.cells:[]){const W=ed.exec(String((B==null?void 0:B.a)??""));if(!W||typeof B.c!="string")continue;const N=parseInt(W[3],10),R=o==null?void 0:o.get(B.a);z.push({id:B.a,char:B.c,slot:N,pos:N,sub:W[4]||null,bbox:a.get(B.a)??null,...jx(B),...R!==void 0&&R!==B.c?{norm:R}:{}})}const T=vx(_);(z.length>0||T.kind==="blank")&&C.push({col:L,chars:z,...T})}if(!C.some(_=>_.chars.length>0)){C.length>0&&c.set(k,C);continue}C.sort((_,L)=>_.col-L.col);const S=s.get(k);l.push({page:k,seq:String(((h=S==null?void 0:S.canvas)==null?void 0:h.seq)??""),width:lt((u=S==null?void 0:S.canvas)==null?void 0:u.width)??lt((m=S==null?void 0:S.image)==null?void 0:m.width)??0,height:lt((f=S==null?void 0:S.canvas)==null?void 0:f.height)??lt((x=S==null?void 0:S.image)==null?void 0:x.height)??0,...typeof j.label=="string"&&j.label?{label:j.label}:{},columns:C})}const p=new Set(l.map(j=>j.page));for(const[j,k]of s){const C=(v=k==null?void 0:k.canvas)==null?void 0:v.seq;p.has(j)||typeof C!="string"&&typeof C!="number"||String(C)===""||l.push({page:j,seq:String(C),width:lt((y=k.canvas)==null?void 0:y.width)??lt(($=k.image)==null?void 0:$.width)??0,height:lt((b=k.canvas)==null?void 0:b.height)??lt((w=k.image)==null?void 0:w.height)??0,...d.has(j)?{label:d.get(j)}:{},columns:c.get(j)??[]})}return l.sort((j,k)=>j.page-k.page)}const Sx=({data:e,onNavigate:n,className:i,style:o})=>{var h;const{t:s,convert:a}=ne(),[l,d]=g.useState(((h=e.divisions[0])==null?void 0:h.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(u=>t.jsx(_x,{division:u,expanded:l===u.name,onToggle:()=>d(l===u.name?null:u.name),expandedCat:c,onCatToggle:m=>p(c===m?null:m),onNavigate:n},u.name))})]})},_x=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ne(),c=e.categories.reduce((p,h)=>{const u=h.stats||{zhulu:0,cunmu:0};return p+(u.zhulu||0)+(u.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${r("primary")} 6%, transparent)`:r("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:r("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg")},children:[l("catalogPage.divisionStat",{cats:e.categories.length,books:c}),t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(p=>{const h=`${e.name}/${p.name}`;return t.jsx($x,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},$x=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,u,m;const{t:s,convert:a}=ne(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((h=e.books)==null?void 0:h.cunmu)||[],c=(((u=e.stats)==null?void 0:u.zhulu)||l.length)+(((m=e.stats)==null?void 0:m.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(ka,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(ka,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},ka=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ne(),a=it(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,h)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:r("fg")},children:p.work_id&&i?t.jsx("a",{href:a(p.work_id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.author).slice(0,20)})]},h))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:o("catalogPage.expandAllN",{n:n.length})})]})},wt=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Ee();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:r("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o,i&&t.jsx("button",{onClick:i,style:Tx,children:"AI"}),n&&t.jsx("button",{onClick:n,style:Cx,children:a.action.save})]})]}),s]})},Cx={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Tx={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},ft=({label:e,value:n,onChange:i,placeholder:o,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>i(a.target.value),placeholder:o,disabled:s,style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),on=({value:e,onChange:n,placeholder:i})=>{const o=g.useRef(null);return g.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},ki=({children:e,color:n,style:i})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||r("primary-soft"),color:r(n?"on-color-fg":"fg"),...i},children:e});function zx(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const gi=({value:e,onChange:n,label:i})=>{const[o,s]=g.useState(!1),a=g.useRef(null),l=zx(e||"");return g.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:wa,children:i}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${r("input-border")}`,borderRadius:"2px",background:r("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:r("fg")},children:l.name}),t.jsx(ki,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:wa,children:i}),t.jsx("input",{ref:a,type:"text",value:e||"",onChange:d=>n(d.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},wa={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function Nx(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function Ix(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const id=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Ee(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=u=>{n(e.filter((m,f)=>f!==u)),s===u&&a(null)},c=(u,m,f)=>{const x=[...e];x[u]={...x[u],[m]:f},n(x)},p=(u,m)=>{const f=[...e];f[u]={...f[u],type:m,id:"",name:""},n(f),m==="bookID"&&i&&i(x=>{const v=[...e];v[u]={...v[u],id:x.id,name:x.title,type:"bookID"},n(v)})},h=u=>{i&&i(m=>{const f=[...e];f[u]={...f[u],id:m.id,name:m.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===m?null:m),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:u.name||`${o.editor.sourcePlaceholder} ${m+1}`}),u.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Nx(u.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Ix(u.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(m)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===m&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!u.type&&t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(m,"bookID"),style:{...Sa,borderColor:r("source-bookid"),color:r("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(m,"url"),style:{...Sa,borderColor:r("source-url"),color:r("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),u.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Lt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:_a,children:o.action.changeType})]}),u.id&&u.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:r("bg"),border:`1px solid ${r("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:r("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:u.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:u.id})]}),t.jsx("button",{onClick:()=>h(m),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>h(m),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),u.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Lt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:_a,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:u.name,onChange:f=>c(m,"name",f.target.value),placeholder:o.editor.sourceNamePlaceholder,style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:u.id,onChange:f=>c(m,"id",f.target.value),placeholder:"https://...",style:dn})]})]}),u.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${r("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...Lt,opacity:.7},children:o.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:u.details,onChange:f=>c(m,"details",f.target.value),placeholder:o.editor.detailsPlaceholder,style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:u.position,onChange:f=>c(m,"position",f.target.value),placeholder:"如: 卷三, p.52",style:dn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:u.version,onChange:f=>c(m,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:dn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Lt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:u.processor_version,onChange:f=>c(m,"processor_version",f.target.value),placeholder:"如: v0.1",style:dn})]})]})]})]})})]},m)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Lt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},dn={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Sa={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:r("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},_a={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function rd(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(i=>({id:i.id||"",name:i.name||"",type:i.type||"",details:i.details||"",position:i.position||"",version:i.version||"",processor_version:i.processor_version||""}))}catch{}return[]}function od(e){return!e||e.length===0?"":JSON.stringify(e)}const sd=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:u,onUnlinkEntity:m,onViewEntity:f,onCreateAndLink:x,onSaveRelations:v})=>{const y=Ee();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),v&&t.jsx("button",{onClick:v,style:Ex,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Nn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>m("collectionId"),onLink:()=>u("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&h&&h.length>0&&t.jsx(pn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${h.length})`,entities:h,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.parentWork,entity:o,onView:f,onUnlink:()=>m("parentWorkId"),onLink:()=>u("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),d&&d.length>0&&t.jsx(pn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(pn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(pn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Nn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>u("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Nn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>m("parentCollectionId"),onLink:()=>u("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(pn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(pn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},Nn=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:u})=>{const m=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:f}),t.jsx("span",{children:n})]}),i?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:r("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:ad(i.type)}),t.jsx("span",{style:{fontWeight:500},children:i.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:i.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx($a,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx($a,{onClick:s,title:u,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(Wr,{onClick:a,children:d}),t.jsx(Wr,{onClick:l,primary:!0,children:c})]})]})},pn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),h=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),u=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",m=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:u}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(f=>t.jsxs("div",{onClick:()=>o(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:ad(f.type)}),t.jsx("span",{children:f.title})]},f.id)),i.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:r("link-fg"),cursor:"pointer"},children:[d," (",i.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(Wr,{onClick:s,primary:!0,children:["+ ",a]})})]})},$a=({onClick:e,title:n,danger:i,children:o})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:i?r("danger"):"inherit",opacity:.7},children:o}),Wr=({onClick:e,primary:n,children:i})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${r("widget-border")}`,borderRadius:"4px",background:n?r("primary"):"transparent",color:n?r("primary-fg"):"inherit",cursor:"pointer"},children:i});function ad(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Ex={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},ld=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,u]=g.useState(""),m=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(u(""),d(""))},[e]);const f=y=>{u(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",v=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:Rx,children:t.jsxs("div",{style:Lx,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:i}),t.jsx("button",{onClick:s,style:Ax,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:Mx})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:gr,children:"搜索中..."}):m.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>t.jsxs("div",{onClick:()=>o(y),style:Px,children:[t.jsx("span",{style:{fontSize:"16px"},children:v}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):h?t.jsxs("div",{style:gr,children:["未找到匹配的",x]}):t.jsxs("div",{style:gr,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:Bx,children:["创建新",x,"并关联"]})]})]})})},Rx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Lx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},Ax={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Mx={width:"100%",padding:"10px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},Px={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},gr={padding:"20px",textAlign:"center",color:r("desc-fg")},Bx={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Ca={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Ox={work:"📜",book:"📖",collection:"📚",entity:"👤"},cd=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var m,f;(m=c.current)==null||m.focus(),(f=c.current)==null||f.select()},100))},[e,o==null?void 0:o.title]);const p=m=>{m.key==="Enter"&&l.trim()?h():m.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const u=()=>{switch(i){case"parentWorkId":return"创建父作品";case"workId":return"创建所属作品";case"collectionId":return"创建所属丛编";case"parentCollectionId":return"创建父丛编";case"childWork":return"创建子作品";case"childBook":case"siblingBook":return"创建书籍";case"childCollection":return"创建子丛编";default:return`创建新${Ca[n]}`}};return t.jsx("div",{style:Wx,onClick:m=>{m.target===m.currentTarget&&a()},children:t.jsxs("div",{style:Fx,onClick:m=>m.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ox[n]}),t.jsx("span",{children:u()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:m=>d(m.target.value),onKeyDown:p,placeholder:`请输入${Ca[n]}名称...`,style:Hx})]}),((o==null?void 0:o.author)||(o==null?void 0:o.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),background:r("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(o==null?void 0:o.author)&&t.jsxs("div",{children:["作者: ",o.author]}),(o==null?void 0:o.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",o.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:Dx,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...Ux,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Wx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Fx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:r("shadow-dialog")},Hx={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box"},Dx={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Ux={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Vx(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function dd(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Gx(e){switch(e){case"work":return r("editor-type-work");case"collection":return r("editor-type-collection");case"book":return r("editor-type-book");default:return r("desc-fg")}}const pd=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:h})=>{const[u,m]=g.useState(""),[f,x]=g.useState([]),[v,y]=g.useState(!1),[$,b]=g.useState("recent");g.useEffect(()=>{e&&(m(""),x([]),b(o.length>0?"recent":"search"))},[e,o.length]),g.useEffect(()=>{if(!u.trim()){x([]);return}const _=setTimeout(async()=>{y(!0);try{x(await h(u,i))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(_)},[u,i,h]);const w=g.useCallback(_=>{m(_.target.value),_.target.value.trim()&&b("search")},[]),j=g.useCallback(_=>s?_.filter(L=>L.id!==s):_,[s]);if(!e)return null;const k=n||(i==="all"?"选择实体":`选择${dd(i)}`),C=j(o),S=j(f);return t.jsx("div",{style:qx,children:t.jsxs("div",{style:Kx,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:k}),t.jsx("button",{onClick:c,style:Xx,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:u,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Zx}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),v&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),C.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs(Ta,{active:$==="recent",onClick:()=>b("recent"),children:["最近使用 (",C.length,")"]}),t.jsxs(Ta,{active:$==="search",onClick:()=>b("search"),children:["搜索结果 ",S.length>0&&`(${S.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:$==="recent"&&C.length>0?t.jsx(za,{entities:C,onSelect:d}):u.trim()?v?t.jsx(fr,{message:"搜索中..."}):S.length>0?t.jsx(za,{entities:S,onSelect:d}):t.jsx(fr,{message:"未找到匹配的结果"}):t.jsx(fr,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:Jx,children:l||"创建新实体"})]})]})})},Ta=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),za=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Yx,{entity:i,onClick:()=>n(i)},i.id))}),Yx=({entity:e,onClick:n})=>{const[i,o]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Vx(e.type)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.title,e.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:r("desc-fg"),marginLeft:"4px"},children:e.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[t.jsx("code",{style:{fontSize:"10px",background:r("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:e.id}),e.author&&t.jsx("span",{children:e.author}),e.dynasty&&t.jsx("span",{children:e.dynasty})]})]}),t.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:Gx(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:dd(e.type)})]})},fr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),qx={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Kx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},Xx={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Zx={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},Jx={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Qx={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},eb={work:"📜",collection:"📚",book:"📖",entity:"👤"},ud=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:u,onRelationsChange:m})=>{var re;const f=Ee(),[x,v]=g.useState(!1),[y,$]=g.useState("work"),[b,w]=g.useState(""),[j,k]=g.useState(""),[C,S]=g.useState([]),[_,L]=g.useState(!1),[z,T]=g.useState(!1),[B,W]=g.useState("work"),[N,R]=g.useState(""),[H,q]=g.useState(),[te,ae]=g.useState(!1),[V,G]=g.useState(null),[me,K]=g.useState([]);g.useRef(null);const le=e.type,Se=le==="work",A=le==="collection",je=le==="book",ce=g.useCallback((D,se)=>{n({...e,[D]:se})},[e,n]),ze=g.useCallback((D,se)=>{w(D),$(se),k(f.editor.selectToLink+f.indexType[se]),S([]),v(!0)},[f]),$e=g.useCallback(D=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,D)},[o,e.id]),Fe=g.useCallback(D=>{s==null||s(D.id,D.type)},[s]),ee=g.useCallback((D,se,_e)=>{const Ae={..._e,author:(_e==null?void 0:_e.author)||e.author,dynasty:_e==null?void 0:_e.dynasty};W(se),R(D),q(Ae),T(!0)},[e.author]),F=g.useCallback((D,se)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,N,{type:B,title:D,inheritData:se}),T(!1)},[o,e.id,N,B]),U=g.useCallback(D=>{if(!D.trim()){S([]);return}L(!0),o!=null&&o.searchEntities&&o.searchEntities(D,y).then(se=>{S(se),L(!1)}).catch(()=>{S([]),L(!1)})},[o,y]),he=g.useCallback(D=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,b,D.id),v(!1)},[o,e.id,b]),X=g.useCallback(()=>{i()},[i]),O=g.useCallback(D=>{G(()=>D),ae(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(K).catch(()=>{})},[o]),J=g.useCallback((D,se)=>o!=null&&o.searchEntities?o.searchEntities(D,se==="all"?void 0:se):Promise.resolve([]),[o]),oe=g.useCallback(D=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(D),K(se=>[D,...se.filter(_e=>_e.id!==D.id)].slice(0,10)),V==null||V(D),ae(!1),G(null)},[o,V]);return t.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${r("widget-border")}`,paddingBottom:"16px"},children:t.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:eb[le]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(ki,{children:e.id}),t.jsx(ki,{color:Qx[le],children:f.indexType[le]})]})}),t.jsx(wt,{title:f.section.basicInfo,onSave:i,onAskAI:d?()=>d("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[t.jsx(gi,{label:Se?f.editor.workTitle:A?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:D=>ce("title",D)}),je&&t.jsx(gi,{label:f.editor.belongsToWork,value:e.workName||"",onChange:D=>ce("workName",D)}),t.jsx(ft,{label:f.editor.authorLabel,value:e.author||"",onChange:D=>ce("author",D)}),t.jsx(ft,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:D=>ce("publicationYear",D)}),(je||A)&&t.jsx(gi,{label:f.editor.containedIn,value:e.collection||"",onChange:D=>ce("collection",D)}),(je||A)&&t.jsx(ft,{label:f.editor.holderLabel,value:e.holder||"",onChange:D=>ce("holder",D)}),(je||A)&&t.jsx(ft,{label:je?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:D=>ce("pages",D)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(ft,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:D=>ce("firstImage",D)})})]})}),t.jsx(wt,{title:f.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(on,{value:e.description||"",onChange:D=>ce("description",D),placeholder:f.editor.descriptionPlaceholder})}),(((re=e.additional_works)==null?void 0:re.length)||0)>0&&t.jsx(wt,{title:f.section.additionalWorks,onSave:i,children:t.jsx(tb,{items:e.additional_works||[],onChange:D=>ce("additional_works",D)})}),t.jsx(wt,{title:f.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(nb,{items:e.indexed_by||[],onChange:D=>ce("indexed_by",D)})}),t.jsx(wt,{title:f.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(ib,{items:e.emendated_by||[],onChange:D=>ce("emendated_by",D)})}),t.jsx(wt,{title:f.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(kr,{items:e.resources||[],onChange:D=>ce("resources",D),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(wt,{title:f.section.imageResources,onSave:i,children:t.jsx(kr,{items:e.resources||[],onChange:D=>ce("resources",D),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(wt,{title:f.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(id,{items:rd(e.sources||""),onChange:D=>ce("sources",od(D)),onOpenEntityPicker:O})}),(je||A)&&t.jsx(wt,{title:f.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(on,{value:e.provenance||"",onChange:D=>ce("provenance",D),placeholder:f.editor.provenancePlaceholder})}),je&&t.jsx(wt,{title:f.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(on,{value:e.otherEditions||"",onChange:D=>ce("otherEditions",D),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(sd,{entityType:le,entityId:e.id,entityTitle:e.title,parentWork:u==null?void 0:u.parentWork,parentCollection:u==null?void 0:u.parentCollection,belongsToWork:u==null?void 0:u.belongsToWork,belongsToCollection:u==null?void 0:u.belongsToCollection,childWorks:u==null?void 0:u.childWorks,childCollections:u==null?void 0:u.childCollections,containedBooks:u==null?void 0:u.containedBooks,siblingBooks:u==null?void 0:u.siblingBooks,onLinkEntity:ze,onUnlinkEntity:$e,onViewEntity:Fe,onCreateAndLink:ee,onSaveRelations:X}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${r("danger-soft-border")}`,background:r("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:r("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("danger")}`,borderRadius:"4px",background:"transparent",color:r("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),t.jsx(ld,{isOpen:x,entityType:y,title:j,onSelect:he,onCancel:()=>v(!1),onCreate:()=>{v(!1),ee(b,y)},searchResults:C,onSearch:U,isLoading:_,excludeId:e.id}),t.jsx(cd,{isOpen:z,entityType:B,relationField:N,inheritData:H,onConfirm:F,onCancel:()=>T(!1)}),t.jsx(pd,{isOpen:te,title:f.action.selectBookOrWork,filterType:"all",recentEntities:me,excludeId:e.id,onSelect:oe,onCancel:()=>{ae(!1),G(null)},onSearch:J})]})};function tb({items:e,onChange:n}){const i=Ee(),o=(l,d,c)=>{const p=e.map((h,u)=>u===l?{...h,[d]:c}:h);n(p)},s=l=>n(e.filter((d,c)=>c!==l)),a=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((l,d)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(ft,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(ft,{label:i.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>o(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(d),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("muted"),marginTop:"18px"},children:"✕"})]},d)),t.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:i.action.addAdditionalWork})]})}function md({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ee(),[a,l]=g.useState(null),d=(h,u,m)=>{const f=e.map((x,v)=>v===h?{...x,[u]:m||void 0}:x);n(f)},c=h=>{n(e.filter((u,m)=>m!==h)),a===h&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((h,u)=>{const m=a===u;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(m?null:u),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:h.source||s.editor.unnamedSource}),h.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(u)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!m&&i&&(h.title_info||h.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[h.title_info,h.title_info&&h.author_info&&" — ",h.author_info]}),m&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ft,{label:s.label.sourceName,value:h.source,onChange:f=>d(u,"source",f)}),t.jsx(ft,{label:s.label.sourceBid,value:h.source_bid||"",onChange:f=>d(u,"source_bid",f)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ft,{label:s.label.titleInfo,value:h.title_info||"",onChange:f=>d(u,"title_info",f)}),t.jsx(ft,{label:s.label.authorInfo,value:h.author_info||"",onChange:f=>d(u,"author_info",f)})]}),t.jsx(ft,{label:s.label.edition,value:h.edition||"",onChange:f=>d(u,"edition",f)})]}),t.jsx(on,{value:h.summary||"",onChange:f=>d(u,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(on,{value:h.comment||"",onChange:f=>d(u,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(on,{value:h.additional_comment||"",onChange:f=>d(u,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},u)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:o})]})}function nb({items:e,onChange:n}){const i=Ee();return t.jsx(md,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function ib({items:e,onChange:n}){const i=Ee();return t.jsx(md,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function hd(e){var d,c,p,h,u,m,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",i=((p=e.publication_info)==null?void 0:p.year)||"",o=((h=e.current_location)==null?void 0:h.name)||"",s=(u=e.page_count)!=null&&u.number?String(e.page_count.number):((m=e.page_count)==null?void 0:m.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:i,holder:o,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const v=x.related_works.find(y=>y.relation==="part_of");v&&(l.parentWorkId=v.id,l.parentWorkName=v.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(f=x.contained_in[0])==null?void 0:f.id)}return l}function rb(e){const n={id:e.id,title:e.title,type:e.type,description:e.description?{text:e.description}:void 0,authors:e.author?[{name:e.author}]:void 0,publication_info:e.publicationYear?{year:e.publicationYear}:void 0,current_location:e.holder?{name:e.holder}:void 0,page_count:e.pages?{number:parseInt(e.pages)||0,description:e.pages}:void 0,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};return e.type==="work"&&e.parentWorkId&&(n.related_works=[{id:e.parentWorkId,title:e.parentWorkName||"",relation:"part_of"}]),e.type==="book"&&(n.work_id=e.workId,e.collectionId&&(n.contained_in=[{id:e.collectionId}])),n}const ob=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:h,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:y,headerExtra:$,className:b,style:w}=e,j=Ee(),[k,C]=g.useState(s),S=a?s:k;g.useEffect(()=>{s!==k&&C(s)},[s]);const _=g.useCallback(()=>{const R=S==="view"?"edit":"view";a?a(R):C(R)},[S,a]),[L,z]=g.useState(null);g.useEffect(()=>{i&&o&&o.getItem(i).then(R=>{R&&z(R)})},[i,o]);const T=n||L,B=g.useMemo(()=>T?hd(T):null,[T]),W=a||!n?t.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:S==="edit"?r("accent-bg"):"transparent",color:r(S==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:S==="view"?j.common.switchToEdit:j.common.switchToView,children:S==="view"?j.common.modeEdit:j.common.modeView}):null,N=t.jsxs(t.Fragment,{children:[W,$]});return!T&&!B?t.jsx(sn,{}):S==="view"?t.jsx(io,{data:T,transport:o,onNavigate:p?R=>p(R):void 0,renderLink:h,headerExtra:N,className:b,style:w}):B?t.jsxs("div",{className:b,style:w,children:[N&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:N}),t.jsx(ud,{data:B,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:u,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:j.common.noData})},sb=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],gd=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=ne(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,h]=g.useState(""),[u,m]=g.useState("idle"),[f,x]=g.useState(""),v=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),h(""),m("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=v.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(u==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[u,n]),g.useEffect(()=>{if(!e)return;const b=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){m("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),m("success")}catch(b){m("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const $=a&&d.trim()&&u!=="submitting";return t.jsx("div",{style:ab,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:lb,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:cb,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:db,"aria-label":s("feedback.close"),children:"✕"})]}),u==="success"?t.jsxs("div",{style:gb,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),o&&t.jsx("a",{href:o,style:{fontSize:"13px",color:r("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:sb.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...pb,...a===b.value?ub:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:v,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||u==="submitting",style:{...mb,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>h(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||u==="submitting","aria-label":s("feedback.contactLabel"),style:xb}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),u==="error"&&t.jsx("div",{style:fb,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!$,style:{...hb,opacity:$?1:.6,cursor:$?"pointer":"not-allowed"},children:s(u==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},ab={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},lb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},cb={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},db={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},pb={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},ub={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},mb={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},hb={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},gb={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},fb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},xb={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},Fr="--bim-feedback-fab-offset",Hr=48,bb=16,yb=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=ne(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(Fr,`calc(${c+Hr+bb}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Fr)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...jb,zIndex:s??r("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":a("feedback.title"),title:a("feedback.title"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsx(gd,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},jb={position:"fixed",width:`${Hr}px`,height:`${Hr}px`,borderRadius:"50%",border:"none",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},vb=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],fd=({onSubmit:e})=>{const{t:n}=ne(),[i,o]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[h,u]=g.useState(""),m=g.useRef(null);g.useEffect(()=>{i&&setTimeout(()=>{var v;return(v=m.current)==null?void 0:v.focus()},100)},[i]);const f=async()=>{if(!(!i||!s.trim())){p("submitting"),u("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(v){p("error"),u(v instanceof Error?v.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Na,children:t.jsxs("div",{style:$b,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:Cb,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Na,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:vb.map(v=>t.jsxs("button",{onClick:()=>o(v.value),style:{...kb,...i===v.value?wb:{}},children:[t.jsx("span",{children:v.icon})," ",n(`feedback.submitType.${v.value}`)]},v.value))}),t.jsx("textarea",{ref:m,value:s,onChange:v=>a(v.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Sb}}),t.jsx("input",{type:"text",value:l,onChange:v=>d(v.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:zb}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:f,disabled:!x,style:{..._b,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:Tb,children:h})]})},Na={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},kb={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},wb={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Sb={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},_b={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},$b={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},Cb={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Tb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},zb={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Ia(e){return typeof e=="function"?e():e??"/api/feedback"}const xd=({resourceId:e,apiUrl:n})=>{const{t:i}=ne(),[o,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=Ia(n);l(!0);try{const u=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();u.success&&s(u.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const h=Ia(n),u=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!u.ok){const m=await u.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Wo,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(fd,{onSubmit:c})})]})},Oi=8;async function Wi(e,n,i,o){const s=Number.isFinite(n)?Math.max(1,Math.floor(n)):1,a=new Array(e.length);let l=0;const d=Array.from({length:Math.min(s,Math.max(1,e.length))},async()=>{for(;l<e.length&&!(o!=null&&o());){const c=l++;a[c]=await i(e[c],c)}});return await Promise.all(d),a}const Nb=_i["zh-Hant"].relation,Ib=_i["zh-Hant"].lossStatus,Eb=_i["zh-Hant"].resourceKind,Fi=vn("zh-Hant"),Fo=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Ea(e,n=Fi){return e?Fo(Nb,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function Rb(e,n=Fi){return Fo(Ib,e)?n(`detail.lossStatus.${e}`):e}function Lb(e,n=Fi){return Fo(Eb,e)?n(`detail.resourceKind.${e}`):""}function Ho({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=ne(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=uo(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(nt,{id:a.entity_id,label:o(a.name),onNavigate:n,renderLink:i,dense:!0}):o(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:o(d)})]},l)})}):null}function bd(e,n,i=Fi){var c,p;const o=co(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(u=>u.group_role!=="mirror"),mirrors:h.items.filter(u=>u.group_role==="mirror")})),a=o.buckets.filter(h=>h.key==="image"||h.key==="textImage").flatMap(h=>h.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(h=>h.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:i("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=o.buckets.find(h=>h.key==="text"))==null?void 0:p.items)??[],groups:s}}function yd(e,n){const i=(e.url?bn(e.url):void 0)||e.name,o=Ql(e,n);return o?`${i}(${o})`:i}function Do({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ne(),[a,l]=g.useState(!1),d=Si(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(yd(e,n)),h=yn(e),u=Ri(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const m=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:o("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?o("colorMode.color"):o("colorMode.bw")})]}):null;return h?t.jsxs("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,m]})})(),u&&t.jsx("span",{className:"bim-d-meta",children:s(u)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(yo,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(m=>!m),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function jd({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=ne();return t.jsx(t.Fragment,{children:e.map(s=>t.jsxs("div",{className:"bim-d-rg",children:[s.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:o(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:o(s.description)}),s.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:s.rows.map((a,l)=>t.jsx(Do,{item:a,siblings:s.rows,listedVolumeCounts:n},`${a.id||a.url||a.name}-${l}`))})}),s.mirrors.length>0&&t.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&t.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:i("detail.mirror")}),s.mirrors.map((a,l)=>{const d=yn(a),c=o(yd(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?o(a.details):void 0,children:[c," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]},l):t.jsx("span",{style:{marginRight:14},children:c},l)})]})]},s.key))})}const Bn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Dr(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Bn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const Ra=12,Ab=60,vd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var U,he,X;const{t:c,convert:p,messages:h}=ne(),u=g.useMemo(()=>mo({_books:e._books}),[e._books]),[m,f]=g.useState(new Map),[x,v]=g.useState(!1),[y,$]=g.useState(""),[b,w]=g.useState(!1),j=u.length<=Ab,k=j||x||!!y||b,C=g.useMemo(()=>k?u:u.slice(0,Ra),[u,k]);g.useEffect(()=>{if(!n||C.length===0)return;const O=C.filter(oe=>!m.has(oe));if(O.length===0)return;let J=!1;return Wi(O,Oi,oe=>n.getItem(oe).then(re=>{const D=re??{};return[oe,{id:oe,title:D.title,edition:D.edition,resources:D.resources,publication_info:D.publication_info,current_location:D.current_location,lineage:D.lineage,measure_info:D.measure_info}]}).catch(()=>[oe,{id:oe}]),()=>J).then(oe=>{J||f(re=>{const D=new Map(re);for(const[se,_e]of oe)D.set(se,_e);return D})}),()=>{J=!0}},[n,C,m]);const S=g.useMemo(()=>u.map(O=>m.get(O)??{id:O}),[u,m]),_=u.length>0&&u.every(O=>m.has(O)),L=!!n&&C.some(O=>!m.has(O)),z=j||k,T=g.useMemo(()=>tc(S,e.version_graph,{era:y,scanOnly:b,sort:z?"year":"default"}),[S,e.version_graph,y,b,z]),B=x?T.rows:T.rows.slice(0,Ra),W=T.allRows.filter(O=>O.hasImage).length,N=g.useMemo(()=>(e._related||[]).map(O=>({...O,title:O.title??""})),[e._related]),R=N.filter(O=>O.relation==="collected_in"),H=g.useMemo(()=>{const O=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],J=oe=>{const re=O.indexOf(oe??"");return re<0?O.length:re};return N.filter(oe=>oe.relation!=="collected_in").map((oe,re)=>({r:oe,i:re})).sort((oe,re)=>J(oe.r.relation)-J(re.r.relation)||oe.i-re.i).map(oe=>oe.r)},[N]),q=g.useMemo(()=>{const O=co(e.resources,e.resource_groups);return[...O.mirrors.flatMap(J=>J.items.map(oe=>({r:oe,kind:p(J.label)}))),...O.buckets.flatMap(J=>J.items.map(oe=>({r:oe,kind:p(Lb(J.key,c))})))]},[e.resources,e.resource_groups,p,c]),te=e.indexed_by||[],ae=e.emendated_by||[],V=g.useMemo(()=>{var M,ie,ve;const O=[],J=(ie=(M=e.authors)==null?void 0:M[0])==null?void 0:ie.dynasty;J&&O.push({label:c("workPage.fact.written"),value:p(J)});const oe=Wt(e,h.unit.juan);if(oe){const we=(ve=e.juan_count)==null?void 0:ve.description;O.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(oe),we&&we!==oe?t.jsxs("span",{className:"bim-d-meta",children:["(",p(we),")"]}):null]})})}e.loss_status&&O.push({label:c("workPage.fact.loss"),value:p(Rb(e.loss_status,c))});const re=T.allRows.filter(we=>we.sortYear!=null),D=re.length>0?re.reduce((we,P)=>we.sortYear<=P.sortYear?we:P):null;D!=null&&D.era.era?O.push({label:c("workPage.fact.earliest"),value:p([D.era.era,D.era.reign].filter(Boolean).join(" ")),title:D.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):L&&O.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),ae.length&&O.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:ae.length})});const se=La(e.additional_titles);se.length&&O.push({label:c("workPage.fact.alias"),value:se.map(p).join("、")});const _e=La(e.attached_texts);_e.length&&O.push({label:c("workPage.fact.attached"),value:_e.map(p).join("、")});const Ae=(e.additional_works||[]).map(we=>p(we.book_title)+(we.n_juan!=null?` ${we.n_juan}${h.unit.juan}`:""));return Ae.length&&O.push({label:c("workPage.fact.appendix"),value:Ae.join("、")}),O},[e,p,c,h,L,T.allRows,ae.length]),me=[{value:e._edition_count??u.length,label:c("workPage.stat.editions")},{value:_?W:0,label:c("workPage.stat.hasImage")},{value:te.length,label:c("workPage.stat.catalogs")}],K=ho(e),le=K?[K.l1,K.l2,K.l3,K.l4].filter(Boolean).map(O=>p(O)):[],Se=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",A=t.jsx(Dn,{title:p(e.title),byline:t.jsx(Ho,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(ot,{items:[...le,K!=null&&K.source?c("workPage.classifiedBy",{source:p(K.source.split("/")[0])}):"",Se]}),description:(U=e.description)!=null&&U.text?t.jsxs(t.Fragment,{children:[t.jsx(Ot,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(he=e.description.sources)!=null&&he.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(O=>({text:p(Ch(O)),href:Th(O)})).filter(O=>O.text).map((O,J)=>t.jsxs(g.Fragment,{children:[J>0?" · ":null,O.href?t.jsx("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",children:O.text}):O.text]},J))}):null]}):void 0,stats:me,facts:V,readAction:s,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(X=e.appendix)==null?void 0:X.map((O,J)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(O.title)}),t.jsx(Ot,{text:O.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},J))}),je=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(O=>({key:O,label:`${O} ${T.allRows.filter(J=>J.era.era===O).length}`}))]:[],ce=[];u.length&&ce.push({id:"versions",label:c("workPage.sec.versions"),count:u.length}),te.length&&ce.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:te.length}),R.length&&ce.push({id:"collected",label:c("workPage.sec.collected"),count:R.length}),H.length&&ce.push({id:"related",label:c("workPage.sec.related"),count:H.length}),q.length&&ce.push({id:"resources",label:c("workPage.sec.resources"),count:q.length});const ze=u.length===0&&te.length===0,$e=t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs(at,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(ot,{items:[c("workPage.versionsTotal",{n:u.length}),_&&W?c("workPage.versionsWithImage",{n:W}):"",T.rows.length!==T.allRows.length?c("workPage.versionsCurrent",{n:T.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":L&&je.length===0&&u.length>1?"":void 0,children:[je.length>0&&t.jsx(Ai,{items:je,value:y,onChange:O=>{$(O),v(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(mc,{label:c("workPage.scanOnly"),checked:b,onChange:O=>{w(O),v(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(z?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Mi(T.rows.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("workPage.col.edition")}),t.jsx("th",{children:c("workPage.col.era")}),t.jsx("th",{children:c("workPage.col.holder")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),t.jsx("tbody",{children:B.map(O=>{var J;return t.jsx(Mb,{row:O,measure:(J=m.get(O.id))==null?void 0:J.measure_info,loaded:m.has(O.id),onNavigate:i,renderLink:o},`${O.id}:${m.has(O.id)?"r":"p"}`)})})]}),B.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(go,{total:T.rows.length,shown:B.length,unit:c("workPage.moreUnit"),onClick:()=>v(!0)}),T.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),te.length>0&&t.jsx(Pb,{items:te,transport:n,onNavigate:i,renderLink:o}),ze&&t.jsx(at,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Fe=(O,J)=>t.jsx(nt,{id:O,label:p(J),onNavigate:i,renderLink:o,dense:!0}),ee=g.useMemo(()=>{const O=new Map;for(const J of H){const oe=Ea(J.relation,c);O.set(oe,(O.get(oe)??0)+1)}return O.size>1?[...O.entries()].sort((J,oe)=>oe[1]-J[1]).slice(0,4).map(([J,oe])=>`${p(J)} ${oe}`).join(" · "):void 0},[H,p,c]),F=t.jsxs(t.Fragment,{children:[t.jsx(rn,{id:"collected",title:c("workPage.sec.collected"),items:R.map(O=>Fe(O.id,O.title))}),t.jsx(rn,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:H.length}),sub:ee,items:H.map(O=>t.jsxs(t.Fragment,{children:[Fe(O.id,O.title),t.jsx("span",{className:"bim-d-meta",title:O.note?p(O.note):void 0,children:p(Ea(O.relation,c))})]}))}),t.jsx(rn,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:q.map(({r:O,kind:J})=>{const oe=p((O.url?bn(O.url):void 0)||O.name),re=yn(O);return t.jsxs(t.Fragment,{children:[re?t.jsxs("a",{href:re,target:"_blank",rel:"noopener noreferrer",children:[oe," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:oe}),J&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:J})]})})})]});return t.jsx(Hn,{railTop:a,back:l,nav:ce,railLinks:d,main:$e,card:A,side:F})};function La(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Aa(e,n){return n((e.url?bn(e.url):void 0)||e.name)}function Mb({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=ne(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],h=p?Aa(p,l):e.locationName?l(e.locationName):"",u=e.images[0],m=u?yn(u):void 0,f=e.images.map(x=>Aa(x,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:e.id,label:l(e.name),onNavigate:o,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?a("workPage.inferredFromEdition"):void 0,children:d?l(d):i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${h?"":" bim-d-zt-blank"}`,children:[h||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(m?t.jsx("a",{className:"bim-d-flag",href:m,target:"_blank",rel:"noopener noreferrer",title:f,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:f,children:a("workPage.hasImage")}))})]})}function Pb({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=ne(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[h,u]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const m=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(m.length===0)return;let f=!1;return Promise.all(m.map(x=>n.getItem(x).then(v=>{var y,$;return[x,(($=(y=v==null?void 0:v.authors)==null?void 0:y[0])==null?void 0:$.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||u(new Map(x.filter(([,v])=>v)))}),()=>{f=!0}},[n,e]),t.jsx(at,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(ot,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((m,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(m.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(m.source_bid??"")?a(h.get(m.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(m.source)].slice(0,9).map((x,v)=>t.jsx("span",{children:x},v))})]})},f))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[p.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:a(p.title_info)}),t.jsx(ot,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(nt,{id:p.source_bid,label:a(p.source),onNavigate:i,renderLink:o,dense:!0}):a(p.source),p.section?a(p.section):"",p.author_info?`${s("label.authorInfo")} ${a(p.author_info)}`:"",p.edition?`${s("label.edition")} ${a(p.edition)}`:"",p.page??""]}),p.summary&&t.jsx("p",{className:"bim-d-quote",children:bt(a(p.summary),void 0,{t:s})}),p.comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),t.jsx("p",{className:"bim-d-quote",children:bt(a(p.comment),void 0,{t:s})})]}),p.additional_comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),t.jsx("p",{className:"bim-d-quote",children:bt(a(p.additional_comment),void 0,{t:s})})]}),!p.summary&&!p.comment&&!p.additional_comment&&!p.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:a(e[c-1].source)}),onClick:()=>d(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",a(e[c-1].source)]})}):t.jsx("span",{"aria-hidden":"true"}),t.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",e.length]}),c<e.length-1?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:a(e[c+1].source)}),onClick:()=>d(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[a(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function Bb(e){var n;return{id:e.id,kind:"hypothetical",label:e.label,year:e.year??((n=e.year_range)==null?void 0:n[0]),year_range:e.year_range,year_uncertain:e.year_uncertain,group:e.group,note:e.note,description:e.description}}function Ob(e,n){if(!e.lineage)return null;const i=e.lineage;return{id:e.id,kind:"book",label:e.title,year:i.year,year_text:i.year_text,year_uncertain:i.year_uncertain,category:i.category,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function Ma(e,n,i){return{id:`derive:${n.ref}->${e}:${i}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Wb(e,n,i){const[o,s]=[e,n.book_id].sort();return{id:`sibling:${o}-${s}:${i}`,source:o,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Fb(e,n){var p;if(n==="all")return null;const i=(p=e.collections)==null?void 0:p[n],o=Array.isArray(i==null?void 0:i.groups)&&i.groups.length>0,s=Array.isArray(i==null?void 0:i.book_ids)&&i.book_ids.length>0,a=o||s||!!(i!=null&&i.hypothetical_ids);if(!a&&n==="core"&&Array.isArray(e.core_books)&&e.core_books.length>0)return{books:new Set(e.core_books),hypos:e.core_hypotheticals?new Set(e.core_hypotheticals):null};if(!i||!a)return null;const l=o?new Set(i.groups):null,d=new Set(i.book_ids??[]);if(l&&e.node_groups)for(const[h,u]of Object.entries(e.node_groups))l.has(u)&&d.add(h);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const h of e.hypothetical_nodes??[])h.group&&l.has(h.group)&&c.add(h.id)}return{books:d,hypos:c}}function fi(e,n,i){const o=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!o||!o.enabled)return s;const a=new Set(o.excluded_books??[]),l=o.node_groups??{},d=Fb(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,h=(d==null?void 0:d.hypos)??null,u=new Set,m=new Set;if(c){const j=new Map(n.map(z=>[z.id,z])),k=new Map((o.hypothetical_nodes??[]).map(z=>[z.id,z])),C=z=>{const T=j.get(z);if(T&&T.lineage)return(T.lineage.derived_from??[]).map(W=>W.ref);const B=k.get(z);return B?(B.derived_from??[]).map(W=>W.ref):[]},S=z=>k.has(z)?!h||h.has(z):!p||p.has(z),_=new Set,L=z=>{if(!_.has(z)){_.add(z);for(const T of C(z))a.has(T)||(S(T)||(k.has(T)?m.add(T):j.has(T)&&u.add(T)),L(T))}};for(const z of n)p&&p.has(z.id)&&!a.has(z.id)&&L(z.id);for(const z of o.hypothetical_nodes??[])h&&h.has(z.id)&&L(z.id)}const f=n.filter(j=>!a.has(j.id)).filter(j=>!p||p.has(j.id)||u.has(j.id)).map(j=>{const k=Ob(j,l);return k&&u.has(j.id)&&(k.bridge=!0),k}).filter(j=>j!==null),x=(o.hypothetical_nodes??[]).filter(j=>!h||h.has(j.id)||m.has(j.id)).map(j=>{const k=Bb(j);return m.has(j.id)&&(k.bridge=!0),k}),v=[...f,...x],y=new Set(v.map(j=>j.id)),$=new Set,b=[],w=j=>{$.has(j.id)||!y.has(j.source)||!y.has(j.target)||($.add(j.id),b.push(j))};for(const j of n)a.has(j.id)||!j.lineage||p&&!p.has(j.id)&&!u.has(j.id)||((j.lineage.derived_from??[]).forEach((k,C)=>{w(Ma(j.id,k,C))}),(j.lineage.related_to??[]).forEach((k,C)=>{w(Wb(j.id,k,C))}));for(const j of o.hypothetical_nodes??[])h&&!h.has(j.id)&&!m.has(j.id)||(j.derived_from??[]).forEach((k,C)=>{w(Ma(j.id,k,C))});return{nodes:v,edges:b,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function kd(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function Hb(e,n){const i=[],o=e.version_graph;if(!o)return i;const s=new Set(n.map(c=>c.id)),a=new Set((o.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||i.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const p=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(h=>d(p,h)),(c.lineage.related_to??[]).forEach(h=>{s.has(h.book_id)||i.push(`${p}: related_to.book_id "${h.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(h=>d(p,h))}return i}const wd=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ne();if(!e.nodes.length)return t.jsx("div",{style:{...ny,...o},className:i,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const f of e.edges)if(f.kind==="derive"){const x=l.get(f.target)??[];x.push(f),l.set(f.target,x)}else for(const x of[f.source,f.target]){const v=d.get(x)??[];v.push(f),d.set(x,v)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,h=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else h.push(f);const u=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(u)),h.sort(u);const m=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:i,style:{...Ub,...o},children:[e.title&&t.jsx("div",{style:Vb,children:a(e.title)}),e.description&&t.jsx("div",{style:Gb,children:a(e.description)}),m.map(f=>t.jsx(Pa,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),h.length>0&&t.jsx(Pa,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Pa=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ne();return t.jsxs("div",{style:Yb,children:[t.jsx("div",{style:{...qb,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(Db,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Db=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ne();return t.jsxs("div",{style:{...Kb,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?r("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:Xb,children:[t.jsx("span",{style:Zb,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Jb,children:kd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Qb,children:[e.category&&t.jsx(In,{children:c(e.category)}),e.status==="lost"&&t.jsx(In,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(In,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(In,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(In,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:ey,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:ty,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:Oa,children:[t.jsx("div",{style:Wa,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:Fa(p.confidence),children:[t.jsx("span",{style:Ha,children:c(p.relation)}),t.jsx("span",{children:(h==null?void 0:h.kind)==="book"&&s?s(h.id,c(h.label)):c((h==null?void 0:h.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(Ba,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Da,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:Oa,children:[t.jsx("div",{style:Wa,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,u=o.get(h);return t.jsxs("div",{style:Fa(p.confidence),children:[t.jsx("span",{style:Ha,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??h)}),t.jsx(Ba,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Da,children:["· ",c(p.evidence)]})]},p.id)})]})]})},In=({children:e,tone:n="default"})=>{const o={default:{bg:r("tag-bg"),fg:r("fg")},warn:{bg:r("warn-bg"),fg:r("warn-fg")},info:{bg:r("info-bg"),fg:r("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:o.bg,color:o.fg,marginRight:"4px"},children:e})},Ba=({level:e})=>{const{t:n}=ne(),o={certain:{key:"certain",color:r("confidence-certain")},consensus:{key:"consensus",color:r("confidence-consensus")},probable:{key:"probable",color:r("confidence-probable")},disputed:{key:"disputed",color:r("confidence-disputed")}}[e];return o?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${o.color}`,color:o.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${o.key}`)}):null},Ub={fontSize:"14px",color:r("fg")},Vb={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Gb={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},Yb={marginBottom:"16px"},qb={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},Kb={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},Xb={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Zb={fontSize:"15px",fontWeight:600},Jb={fontSize:"12px",color:r("muted")},Qb={marginBottom:"6px"},ey={fontSize:"12px",color:r("muted"),margin:"2px 0"},ty={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},Oa={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},Wa={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Fa=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),Ha={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},Da={fontSize:"11px",color:r("muted")},ny={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Sd=({selectedNodeId:e,...n})=>{const{t:i}=ne(),[o,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return iy().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:Va,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:Va,children:[t.jsx("div",{children:Ua(i("lineage.graphMissing"),{xyflow:t.jsx("code",{children:"@xyflow/react"}),dagre:t.jsx("code",{children:"@dagrejs/dagre"})})}),t.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:Ua(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(ry,{modules:a,selectedNodeId:e,...n})};function Ua(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function iy(){try{const[e,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let i=!1;try{await import("@xyflow/react/dist/style.css"),i=!0}catch{i=!1}return{ReactFlow:e.ReactFlow,Background:e.Background,Controls:e.Controls,Handle:e.Handle,Position:e.Position,BaseEdge:e.BaseEdge,EdgeLabelRenderer:e.EdgeLabelRenderer,getSmoothStepPath:e.getSmoothStepPath,dagre:n,cssLoaded:i}}catch{return null}}const ry=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:h,Position:u,BaseEdge:m,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:v}=l,y=g.useMemo(()=>({lineage:C=>{var H,q,te,ae;const S=((H=C.data)==null?void 0:H.stepPosition)??.85,[_,L,z]=x({sourceX:C.sourceX,sourceY:C.sourceY,sourcePosition:C.sourcePosition,targetX:C.targetX,targetY:C.targetY,targetPosition:C.targetPosition,stepPosition:S,borderRadius:5}),T=!!((q=C.data)!=null&&q.isSibling),B=T?L:C.targetX-18,W=T?z:C.targetY-12,N=(te=C.data)==null?void 0:te.labelStyle,R=(ae=C.data)==null?void 0:ae.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(m,{id:C.id,path:_,style:C.style,markerStart:C.markerStart,markerEnd:C.markerEnd}),C.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${B}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...R,...N},children:C.label})})]})}}),[m,f,x]),$=g.useMemo(()=>({version:C=>{const{t:S}=ne(),_=C.data,L=_.kind==="hypothetical",z=_.status==="lost",T=_.isSelected,B=_.bridge,W=_.borderColor??r("muted"),N=B||L?"dashed":"solid",R=B?.5:z?.6:1;return t.jsxs("div",{style:{background:r(B?"bg-subtle":"bg"),border:`2px ${N} ${T?r("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:R,boxShadow:T?r("shadow-node-selected"):L||B?"none":r("shadow-node")},title:B?S("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:u.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:L||!_.renderLink?_.label:_.renderLink(_.bookId,_.label)}),_.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:_.description}),_.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:kd(_.yearText,void 0,_.uncertain)}),z&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:S("lineage.lost")}),t.jsx(h,{type:"source",position:u.Right,style:{visibility:"hidden"}})]})}}),[h,u]),{convert:b}=ne(),{rfNodes:w,rfEdges:j}=g.useMemo(()=>oy(e,v,n,a,b),[e,v,n,a,b]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:j,nodeTypes:$,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[t.jsx(c,{gap:16}),t.jsx(p,{showInteractive:!1})]})})};function oy(e,n,i,o,s=a=>a??""){const d=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:d?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const p=new Map(e.groups.map($=>[$.id,$.color??r("muted")]));for(const $ of e.nodes)c.setNode($.id,{width:160,height:90});const h=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const $ of e.edges)$.kind==="derive"&&(h.has($.relation)||c.setEdge($.source,$.target));n.layout(c);const u=e.nodes.map($=>{const b=c.node($.id),w=o?$.id===o:void 0,j={kind:$.kind,label:s($.label),bookId:$.kind==="book"?$.id:void 0,yearText:s($.year_text??ay($)),uncertain:$.year_uncertain,category:$.category,status:$.status,borderColor:$.group?p.get($.group):void 0,renderLink:i,isSelected:w,description:s($.description),bridge:$.bridge};return{id:$.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:j,draggable:!1,selected:w}}),m=.78,f=.06,x=new Map;for(const $ of e.edges)$.kind==="derive"&&(x.has($.source)||x.set($.source,[]),x.get($.source).push($));const v=new Map;for(const[$,b]of x){if(b.length<=1)continue;const w=[...b].sort((k,C)=>{var L,z;const S=((L=c.node(k.target))==null?void 0:L.y)??0,_=((z=c.node(C.target))==null?void 0:z.y)??0;return S-_}),j=w.length;w.forEach((k,C)=>{const S=(C-(j-1)/2)*f;v.set(k.id,m+S)})}const y=e.edges.map($=>sy($,v.get($.id),s));return{rfNodes:u,rfEdges:y}}function sy(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=ly(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:i(e.relation),data:{labelStyle:{color:r("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":o?"6 4":void 0,opacity:o?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function ay(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function ly(e){switch(e){case"certain":return r("confidence-certain");case"consensus":return r("lineage-edge-consensus");case"probable":return r("confidence-probable");case"disputed":return r("confidence-disputed");default:return r("muted")}}const Va={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},Uo=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:h,style:u})=>{var j;const{t:m,convert:f}=ne(),[x,v]=g.useState(n),y=k=>{v(k),a==null||a(k)},$=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(d&&$.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:m("lineage.empty")});const w=l?(j=c==null?void 0:c[l])==null?void 0:j.description:void 0;return t.jsxs("div",{className:h,style:u,children:[t.jsxs("div",{style:cy,children:[t.jsx("button",{onClick:()=>y("list"),style:xr(x==="list"),children:m("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:xr(x==="graph"),children:m("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:m("lineage.collectionLabel")}),$.map(([k,C])=>{const S=p==null?void 0:p[k];return t.jsxs("button",{onClick:()=>d==null?void 0:d(k),style:xr(l===k),title:C.description?f(C.description):void 0,children:[f(C.label),S!=null?` ${S}`:""]},k)})]})]}),b&&w&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:f(w)}),x==="list"?t.jsx(wd,{graph:e,renderLink:i}):t.jsx(Sd,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},cy={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},xr=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${r("widget-border")}`,borderRadius:4,background:e?r("primary"):"transparent",color:r(e?"primary-fg":"fg"),cursor:"pointer"}),Ga=40,Ya=2,dy=9,py=new Set(["certain","consensus","probable","disputed"]);function br(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const _d=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var ve,we,P,fe,de,xe,Ce,Ue,Ke,Je,qe;const u=Ee(),{t:m,convert:f}=ne(),[x,v]=g.useState(null),[y,$]=g.useState(new Map),[b,w]=g.useState([]),[j,k]=g.useState(new Map),[C,S]=g.useState(!1),[_,L]=g.useState("flow"),[z,T]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){v(null);return}let I=!1;return n.getItem(e.work_id).then(Y=>{!I&&Y&&Y.type==="work"&&v(Y)}).catch(()=>{}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let I=!1;return n.getLineageGraph(e.work_id).then(Y=>{I||T(Y&&Y.nodes.length>1?Y:null)}).catch(()=>{I||T(null)}),()=>{I=!0}},[n,e.work_id]),g.useEffect(()=>{const I=e._collections||[];if(!n||I.length===0){$(new Map);return}let Y=!1;return Promise.all(I.map(pe=>{const be=pe.id;return n.getItem(be).then(Re=>[be,Re]).catch(()=>[be,null])})).then(pe=>{if(Y)return;const be=new Map;for(const[Re,ge]of pe)ge&&be.set(Re,ge);$(be)}),()=>{Y=!0}},[n,e._collections]);const B=g.useMemo(()=>{const I=new Set([...x?mo(x):[],...e.related_books||[]]);return I.add(e.id),[...I]},[x,e.related_books,e.id]),W=B.length-1;g.useEffect(()=>{if(!n||W<=0){w([]);return}const I=B.length<=Ga,Y=I?B:B.slice(0,8);let pe=!1;return Promise.all(Y.map(be=>be===e.id?Promise.resolve({id:be,title:e.title,edition:e.edition,year:yi(e)}):n.getItem(be).then(Re=>{const ge=Re??{};return{id:be,title:ge.title,edition:ge.edition,year:Re?yi(ge):void 0}}).catch(()=>({id:be})))).then(be=>{if(pe)return;const Re=be.filter(ge=>ge.id===e.id||ge.title||ge.edition);I&&Re.sort((ge,Me)=>(ge.year??1/0)-(Me.year??1/0)),w(Re)}),()=>{pe=!0}},[n,B,W,e]);const N=e.lineage,R=g.useMemo(()=>[...((N==null?void 0:N.derived_from)||[]).filter(I=>I.ref_type==="book").map(I=>I.ref),...((N==null?void 0:N.related_to)||[]).map(I=>I.book_id)].filter(Boolean),[N]);g.useEffect(()=>{if(!n||R.length===0){k(new Map);return}let I=!1;return Promise.all(R.map(Y=>n.getItem(Y).then(pe=>[Y,{id:Y,title:pe==null?void 0:pe.title,edition:pe==null?void 0:pe.edition}]).catch(()=>[Y,{id:Y}]))).then(Y=>{I||k(new Map(Y))}),()=>{I=!0}},[n,R]);const H=g.useMemo(()=>bd(e.resources,e.resource_groups,m),[e.resources,e.resource_groups,m]),q=H.groups.reduce((I,Y)=>I+Y.rows.length+Y.mirrors.length,0),te=H.groups.length>0&&H.groups.every(I=>I.key==="_physical"),ae=Fn(e),V=ac(e),G=Wt(e,u.unit.juan),me=new Set((e._collections||[]).map(I=>Mn(I.vol).length).filter(I=>I>0)),K=I=>{var be;const Y=(be=e.base_edition)==null?void 0:be.find(Re=>Re.book_id===I&&Re.name);if(Y!=null&&Y.name)return Y.name;const pe=j.get(I);return(pe==null?void 0:pe.edition)||(pe==null?void 0:pe.title)||""},le=g.useMemo(()=>{var ye,We,He,Ne,Pe;const I=[];V&&I.push({label:m("bookPage.fact.editionType"),value:f(V),title:e.edition_type||(ye=e.lineage)!=null&&ye.category?void 0:m("bookPage.inferredFromEdition")}),(We=e.publication_info)!=null&&We.details?I.push({label:m("bookPage.fact.publication"),value:f(e.publication_info.details)}):(ae.era||ae.reign)&&I.push({label:m("bookPage.fact.era"),value:f([ae.era,ae.reign].filter(Boolean).join(" ")),title:ae.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),G&&I.push({label:m("bookPage.fact.measure"),value:f(G)});const Y=(e._collections||[]).flatMap(Le=>Mn(Le.vol));Y.length&&I.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Li(Y,u.unit.volume),unit:u.unit.volume,n:Y.length})});const pe=(((He=e.lineage)==null?void 0:He.derived_from)||[]).find(Le=>Le.relation==="底本"&&Le.ref_type==="book");pe&&K(pe.ref)&&I.push({label:m("bookPage.fact.baseEdition"),value:t.jsx(nt,{id:pe.ref,label:f(K(pe.ref)),onNavigate:i,renderLink:o,dense:!0})});const be=(e.base_edition||[]).filter(Le=>Le&&Le.name);for(const Le of["底本","配補","參校"]){if(Le==="底本"&&pe&&K(pe.ref))continue;const Be=be.filter(Ie=>Ie.role===Le);Be.length&&I.push({label:f(Le),value:Be.map((Ie,De)=>t.jsxs(g.Fragment,{children:[De>0&&"、",Ie.book_id?t.jsx(nt,{id:Ie.book_id,label:f(Ie.name),onNavigate:i,renderLink:o,dense:!0}):f(Ie.name)]},De))})}const Re=(e.provenance||[]).filter(Le=>Le&&Le.institution),ge=(e.resources||[]).filter(Le=>Bt(Le).includes("physical"));if(Re.length){I.push({label:m("bookPage.fact.holdings"),value:Re.slice(0,2).map(Ie=>f(Ie.institution)).join("、")+(Re.length>2?m("bookPage.andMorePlaces",{n:Re.length}):"")});const Le=Re.filter(Ie=>Ie.call_number).slice(0,2).map(Ie=>`${f(Ie.institution)} ${Ie.call_number}`);Le.length&&I.push({label:m("bookPage.fact.callNumber"),value:Le.join(";")+(Re.filter(Ie=>Ie.call_number).length>2?"…":"")});const Be=Re.flatMap(Ie=>Ie.seals||[]).filter(Boolean);Be.length&&I.push({label:m("bookPage.fact.seals"),value:f(Be.join("、"))})}else ge.length?I.push({label:m("bookPage.fact.holdings"),value:ge.slice(0,2).map(Le=>f(Le.name)).join("、")+(ge.length>2?m("bookPage.andMorePlaces",{n:ge.length}):"")}):(Ne=e.current_location)!=null&&Ne.name&&I.push({label:m("bookPage.fact.holdings"),value:f(e.current_location.name)});const Me=e.physical_description;if(Me){const Le=[[m("bookPage.fact.leafStyle"),Me.leaf_style],[m("bookPage.fact.binding"),Me.binding],[m("bookPage.fact.dimensions"),Me.dimensions],[m("bookPage.fact.condition"),Me.condition]];for(const[Be,Ie]of Le)Ie&&Ie.trim()&&I.push({label:Be,value:f(Ie)})}(Pe=e.page_count)!=null&&Pe.description&&I.push({label:u.label.pageCount,value:f(e.page_count.description)});const Q=[...Lr(e.additional_titles),...Lr(e.attached_texts)];return Q.length&&I.push({label:m("bookPage.fact.aliases"),value:Q.map(f).join("、")}),I},[e,f,u,m,ae,V,G,j,i,o]),Se=f(e.title),A=e.edition?f(e.edition):void 0,je=((ve=e.lineage)==null?void 0:ve.year_text)||"",ce=t.jsx(Dn,{kind:m("bookPage.kind"),title:Se,subtitle:A,byline:t.jsx(Ho,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const I=[V?f(V):"",ae.era?f([ae.era,ae.reign].filter(Boolean).join("")):"",G?f(G):""].filter(Boolean);return I.length?t.jsx("span",{className:"bim-d-tags",children:I.map((Y,pe)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(pe,2)}`,children:Y},pe))}):null})(),description:(we=e.description)!=null&&we.text?t.jsx(Ot,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:xo((P=e.description)==null?void 0:P.text)?6:void 0,facts:le,readAction:s,secondaryAction:s&&q>0&&!te?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),ze=e._collections||[],$e=(a==null?void 0:a.chapters)||[],Fe=f($e[0]&&br($e[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),ee=m("bookPage.chapterCount",{n:$e.length,unit:Fe}),F=!!((fe=N==null?void 0:N.derived_from)!=null&&fe.length||(de=N==null?void 0:N.related_to)!=null&&de.length||(xe=e.appendix)!=null&&xe.length),U=[],he=m(te?"bookPage.sec.physical":"bookPage.sec.images");($e.length||H.text.length||l)&&U.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:$e.length?ee:void 0}),H.groups.length&&U.push({id:"images",label:he,count:q}),F&&U.push({id:"lineage",label:m("bookPage.sec.lineage")}),ze.length&&U.push({id:"collections",label:m("section.containedIn"),count:ze.length}),(Ce=e.location_history)!=null&&Ce.length&&U.push({id:"provenance",label:m("section.locationHistory")});const X=I=>(d==null?void 0:d(I))??null,O=$e[0],J=O?X(O.file):null,oe=C?$e:$e.slice(0,dy),re=(I,Y,pe)=>I?t.jsx("a",{className:pe,href:I.href??"#",onClick:I.onClick?be=>{be.metaKey||be.ctrlKey||(be.preventDefault(),I.onClick())}:void 0,children:Y}):t.jsx("span",{className:pe,children:Y}),D=t.jsxs(t.Fragment,{children:[($e.length>0||H.text.length>0||l)&&t.jsxs(at,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:$e.length>0?t.jsx(ot,{items:[ee,(Ue=a==null?void 0:a.source)!=null&&Ue.name?m("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!O&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[t.jsx("span",{className:"bim-d-ft-h",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "})]}),t.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),O&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:f(br(O.title)[0])||m("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((O.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),re(J,t.jsxs(t.Fragment,{children:[m("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),$e.length>1&&t.jsx("ul",{className:"bim-d-chap",children:oe.map(I=>{const[Y,pe]=br(I.title);return t.jsx("li",{children:re(X(I.file),t.jsxs(t.Fragment,{children:[Y&&t.jsx("b",{children:f(Y)}),f(pe||I.file)]}))},I.file)})}),$e.length>oe.length&&t.jsx(fo,{label:m("detail.expandRest",{n:$e.length-oe.length,unit:Fe}),onClick:()=>S(!0)}),H.text.length>0&&t.jsxs(t.Fragment,{children:[($e.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:H.text.map((I,Y)=>t.jsx(Do,{item:I,siblings:H.text,listedVolumeCounts:me},`${I.id||I.url||I.name}-${Y}`))})})]})]}),H.groups.length>0&&t.jsx(at,{id:"images",title:he,meta:t.jsx(ot,{items:[H.groups.length>1?m("bookPage.groupCount",{n:H.groups.length}):"",m("bookPage.placeCount",{n:q})]}),children:t.jsx(jd,{groups:H.groups,listedVolumeCounts:me})}),F&&t.jsx(at,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(Ke=N==null?void 0:N.derived_from)!=null&&Ke.length?m("bookPage.lineageMeta"):void 0,action:z?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":_==="flow",onClick:()=>L("flow"),children:m("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>L("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&z?t.jsx(Uo,{graph:z,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(I,Y)=>t.jsx(nt,{id:I,label:f(Y),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(my,{data:e,heading:A||Se,yearText:je,refName:K,onNavigate:i,renderLink:o})}),ze.length>0&&t.jsx(at,{id:"collections",title:m("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:ze.map((I,Y)=>{const pe=I.id,be=Mn(I.vol),Re=y.get(pe),ge=_h(Re);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:pe,label:Re?f(Re.title):pe,onNavigate:i,renderLink:o,dense:!0}),be.length>0&&t.jsx(uy,{volumes:be,unit:u.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ge?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ge>0&&m("bookPage.totalOf",{n:ge,unit:u.unit.bu})})]},`${pe}-${Y}`)})})})}),(Je=e.location_history)!=null&&Je.length?t.jsx(at,{id:"provenance",title:m("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((I,Y)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(I.name)}),([I.start_date,I.end_date].filter(Boolean).join("—")||I.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(ot,{items:[[I.start_date,I.end_date].filter(Boolean).join("—"),I.description?f(I.description):""]})})]},Y))})}):null,U.length===0&&t.jsx(at,{title:m("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),se=b.findIndex(I=>I.id===e.id),_e=B.length<=Ga,Ae=_e&&se>=0?b.slice(Math.max(0,se-Ya),se+Ya+1):b.filter(I=>I.id!==e.id),M=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(u.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(nt,{id:x.id,label:f(x.title),onNavigate:i,renderLink:o})}),t.jsx(ot,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(I=>`${I.dynasty?`〔${f(I.dynasty)}〕`:""}${f(I.name)}`),f(Wt(x,u.unit.juan)),x._edition_count?m("bookPage.editionCount",{n:x._edition_count}):""]}),((qe=x.description)==null?void 0:qe.text)&&t.jsx("p",{style:{fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc bim-d-side-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&Ae.length>0&&t.jsxs("div",{children:[t.jsx(rn,{id:"siblings",timeline:!0,title:_e?m("bookPage.siblings"):u.relation.siblingVersions,meta:_e?m("bookPage.byEra"):m("bookPage.kindCount",{n:W}),cap:Ae.length,items:Ae.map(I=>I.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(I.edition||I.title||I.id)}):t.jsx(nt,{id:I.id,label:f(I.edition||I.title||I.id),onNavigate:i,renderLink:o,dense:!0})),metas:Ae.map(I=>[I.year!=null?I.year<0?m("detail.bce",{n:-I.year}):String(I.year):"",I.id===e.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:Ae.findIndex(I=>I.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(nt,{id:x.id,label:m("bookPage.viewAllInWork",{n:B.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),ie=e.work_id?t.jsx(uc,{caption:u.section.belongsToWork,children:t.jsx(nt,{id:e.work_id,label:x?f(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(Hn,{railTop:c,back:p,up:ie,nav:U,railLinks:h,main:D,card:ce,side:M})};function uy({volumes:e,unit:n}){const{t:i}=ne();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Li(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),i("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function my({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var $;const{t:l,convert:d}=ne(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],h=p.filter(b=>b.ref_type!=="book"),u=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,v=b=>b&&py.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,w)=>t.jsx(nt,{id:b,label:d(w||b),onNavigate:s,renderLink:a,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[x&&t.jsxs("ol",{className:"bim-d-lf-list",children:[h.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),v(b.confidence)]})]})},`a-${w}`)),u.map((b,w)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]})},`b-${w}`)),t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[t.jsxs("div",{className:"bim-d-lf-here",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:l("bookPage.lineage.thisEdition")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),i&&t.jsx("span",{className:"bim-d-lf-yr",children:d(i)})]}),m.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:m.map((b,w)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,o(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]},w))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,o(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},w))})]})]}),($=e.appendix)==null?void 0:$.map((b,w)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Ot,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${w}`)),(c==null?void 0:c.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(c.note)})]})}const En=16,hy=200,gy=16,$d=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var se,_e,Ae,M,ie,ve,we;const{t:p,convert:h,messages:u}=ne(),[m,f]=g.useState(""),[x,v]=g.useState(!1),[y,$]=g.useState(null),[b,w]=g.useState(""),[j,k]=g.useState(!1),C=g.useMemo(()=>oc(e,n),[e,n]),S=g.useMemo(()=>rc(e),[e]),[_,L]=g.useState(new Map),z=!!i&&C.rows.length>0&&C.rows.length<=hy,T=z&&(C.rows.length<=En||j),B=T&&C.rows.every(P=>!P.id||_.has(P.id)),W=P=>{var fe;return Dr(P?(fe=_.get(P))==null?void 0:fe.l1:void 0)},N=g.useMemo(()=>{const P=m.trim(),fe=P?h(P):"";return C.rows.filter(de=>{var Ce,Ue;if(b&&Dr(de.id?(Ce=_.get(de.id))==null?void 0:Ce.l1:void 0)!==b)return!1;if(!fe)return!0;const xe=de.id&&((Ue=_.get(de.id))==null?void 0:Ue.title)||de.title;return h(xe).includes(fe)||(de.subItems||[]).some(Ke=>h(Ke).includes(fe))})},[C.rows,m,b,_,h]),R=x?N:N.slice(0,En),H=g.useMemo(()=>(T?C.rows:R).filter(P=>P.id&&!_.has(P.id)).map(P=>P.id),[T,C.rows,R,_]);g.useEffect(()=>{if(!i||H.length===0)return;let P=!1;const fe=H.slice(0,gy);return Wi(fe,Oi,de=>i.getItem(de).then(xe=>{var Ke,Je;const Ce=xe??{},Ue={title:Ce.title,edition:Ce.edition,authors:Ce.authors,measure:xe?Wt(xe,u.unit.juan):void 0,versionCount:Ce._edition_count??((Ke=Ce._books)==null?void 0:Ke.length),l1:((Je=ho(Ce))==null?void 0:Je.l1)||void 0};return[de,Ue]}).catch(()=>[de,{}]),()=>P).then(de=>{P||L(xe=>{const Ce=new Map(xe);for(const[Ue,Ke]of de)Ce.set(Ue,Ke);return Ce})}),()=>{P=!0}},[i,H,u.unit.juan]);const q=(se=(e.contained_in||[])[0])==null?void 0:se.id;g.useEffect(()=>{if(!q){$(null);return}if($({id:q}),!i)return;let P=!1;return i.getItem(q).then(fe=>{P||$({id:q,title:fe==null?void 0:fe.title})}).catch(()=>{}),()=>{P=!0}},[i,q]);const te=g.useMemo(()=>bd(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),ae=te.text.length+te.groups.reduce((P,fe)=>P+fe.rows.length+fe.mirrors.length,0),V=S.works,G=new Set(C.rows.map(P=>P.id).filter(Boolean)),me=V.length>0&&!V.every(P=>G.has(P.id)),K=(()=>{const P=C.rows.map(fe=>fe.edition).filter(Boolean);return P.length>1&&new Set(P).size===1})(),le=C.rows.some(P=>P.volumes.length>0||P.expected!=null),Se=S.total,A=S.truncated?Se:C.rows.length,je=Wt(e,u.unit.juan),ce=e.count,ze=P=>typeof P=="number"&&Number.isFinite(P)?P:null,$e=ze(ce==null?void 0:ce.juan)??ze((_e=e.juan_count)==null?void 0:_e.number),Fe=ze(ce==null?void 0:ce.ce)??(C.totalVolumes||null),ee=[{value:A,label:p("collectionPage.stat.titles")},{value:$e??0,label:u.unit.juan},{value:Fe??0,label:u.unit.volume}],F=g.useMemo(()=>{var de,xe;const P=[];if((de=e.publication_info)!=null&&de.details&&P.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),Se&&(Se!==C.rows.length||S.truncated)){const Ce=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");P.push({label:Ce,value:`${Se} ${u.unit.bu}`,title:p("collectionPage.memberNote")})}const fe=[ze(ce==null?void 0:ce.zhong)!=null?p("collectionPage.nZhong",{n:ce.zhong}):"",ze(ce==null?void 0:ce.han)!=null?p("collectionPage.nHan",{n:ce.han}):""].filter(Boolean);return fe.length&&P.push({label:p("collectionPage.fact.expected"),value:fe.join(" ")}),$e==null&&je&&P.push({label:p("collectionPage.fact.measure"),value:h(je),title:(xe=e.juan_count)!=null&&xe.description?h(e.juan_count.description):void 0}),P},[e,Se,S.truncated,C.rows.length,$e,je,ce,h,p,u]),U=g.useMemo(()=>{if(!B)return[];const P=new Map;for(const de of C.rows){const xe=W(de.id);xe&&P.set(xe,(P.get(xe)??0)+1)}const fe=Bn.filter(de=>(P.get(de.key)??0)>0);return fe.length<2?[]:[{key:"",label:`${u.catalog.all} ${A}`},...fe.map(de=>({key:de.key,label:`${de.label} ${P.get(de.key)}`}))]},[B,C.rows,_,u]),he=g.useMemo(()=>{if(!B||!C.rows.some(xe=>xe.volumes.length>0))return null;const P=[],fe=C.rows.filter(xe=>xe.volumes.length>0).map(xe=>({k:W(xe.id)??"",from:Math.min(...xe.volumes),to:Math.max(...xe.volumes)})).sort((xe,Ce)=>xe.from-Ce.from);for(const xe of fe){const Ce=xe.to-xe.from+1,Ue=P[P.length-1];Ue&&Ue.key===xe.k?(Ue.to=Math.max(Ue.to,xe.to),Ue.n+=Ce):P.push({key:xe.k,from:xe.from,to:xe.to,n:Ce})}const de=fe.reduce((xe,Ce)=>Math.max(xe,Ce.to),0);return P.length>1&&P.some(xe=>xe.key)?{segs:P,last:de}:null},[B,C.rows,_]),X=(Ae=e.description)==null?void 0:Ae.text,O=t.jsx(Dn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(Ho,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(ot,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(M=e.publication_info)!=null&&M.year?h(e.publication_info.year):""]}),description:X||(ie=e.history)!=null&&ie.length?t.jsxs(t.Fragment,{children:[X&&t.jsx(Ot,{text:X,style:{fontSize:15,lineHeight:1.85}}),(ve=e.history)!=null&&ve.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((P,fe)=>t.jsx("li",{children:h(P)},fe))}):null]}):void 0,clampDescription:xo(X)||(((we=e.history)==null?void 0:we.length)??0)>2?6:void 0,stats:ee,facts:F,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:he&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:p("collectionPage.dist.head")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":p("collectionPage.dist.head"),children:he.segs.map((P,fe)=>{const de=Bn.find(xe=>xe.key===P.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!de,title:de?p("collectionPage.dist.segTitle",{section:h(de.label),from:P.from,to:P.to}):void 0,"aria-label":de?p("collectionPage.dist.only",{section:h(de.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!de&&b===P.key,style:{flexGrow:P.n,background:r(de?de.token:"rule")},onClick:()=>{de&&(w(b===P.key?"":P.key),v(!1))}},fe)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:p("catalog.volume",{n:1})}),t.jsx("span",{children:p("collectionPage.dist.hint")}),t.jsx("span",{children:p("catalog.volume",{n:he.last})})]})]})}),J=[];C.rows.length&&J.push({id:"titles",label:p("collectionPage.sec.titles"),count:A}),ae&&J.push({id:"resources",label:p("collectionPage.sec.resources"),count:ae}),me&&J.push({id:"works",label:u.section.containedWorks,count:V.length});const oe=t.jsxs(t.Fragment,{children:[C.rows.length>0&&t.jsxs(at,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(ot,{items:[`${A} ${u.unit.items}`,C.totalVolumes?p("collectionPage.totalVolumes",{n:C.totalVolumes,unit:u.unit.volume}):"",N.length!==A?p("collectionPage.currentN",{n:N.length,unit:u.unit.items}):""]}),action:a,children:[(C.rows.length>En||U.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[U.length>0&&t.jsx(Ai,{items:U,value:b,onChange:P=>{w(P),v(!1)}}),z&&C.rows.length>En&&!B&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:j,onClick:()=>k(!0),title:p("collectionPage.loadAllTitle",{n:C.rows.length,unit:u.unit.items}),children:p(j?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),C.rows.length>En&&t.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:P=>{f(P.target.value),v(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Mi(N.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[le&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:R.map((P,fe)=>{var qe;const de=P.id?_.get(P.id):void 0,xe=de!=null&&de.title&&P.title===P.id?de.title:P.title,Ce=((de==null?void 0:de.authors)||[]).find(I=>I&&I.name),Ue=[Ce?`${Ce.dynasty?`〔${h(Ce.dynasty)}〕`:""}${h(Ce.name)}${Ce.role?` ${h(Ce.role)}`:""}`:"",de!=null&&de.measure?h(de.measure):"",(qe=P.subItems)!=null&&qe.length?P.subItems.map(I=>h(I)).join("、"):"",(de!=null&&de.edition||P.edition)&&!K?h((de==null?void 0:de.edition)||P.edition||""):""].filter(Boolean),Ke=Bn.find(I=>I.key===W(P.id)),Je=P.volumes.length>0?p("collectionPage.volumeRange",{range:Li(P.volumes,u.unit.volume),unit:u.unit.volume}):P.expected!=null?`${P.found??0}/${P.expected} ${u.unit.volume}`:"";return t.jsxs("tr",{children:[le&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Je?"":" bim-d-zt-blank"}`,children:[Ke&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(Ke.token)}}),Je||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[P.id?t.jsx(nt,{id:P.id,label:h(xe),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(xe)}),Ue.length>0?t.jsx(ot,{items:Ue}):P.id&&!de&&i?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${de!=null&&de.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:de!=null&&de.versionCount?p("collectionPage.nZhong",{n:de.versionCount}):""})]},`${P.id??P.title}-${fe}`)})})]}),R.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(go,{total:N.length,shown:R.length,unit:u.unit.items,onClick:()=>v(!0)})]}),ae>0&&t.jsxs(at,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:ae}),children:[te.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[te.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:te.text.map((P,fe)=>t.jsx(Do,{item:P,siblings:te.text},`${P.id||P.url||P.name}-${fe}`))})})]}),t.jsx(jd,{groups:te.groups})]}),C.rows.length===0&&ae===0&&t.jsx(at,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),re=me?t.jsx(rn,{id:"works",title:u.section.containedWorks,meta:p("collectionPage.nZhong",{n:V.length}),cap:12,items:V.map(P=>t.jsx(nt,{id:P.id,label:h(P.title),onNavigate:o,renderLink:s,dense:!0}))}):null,D=y?t.jsx(uc,{caption:p("collectionPage.parent"),children:t.jsx(nt,{id:y.id,label:h(y.title||y.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(Hn,{railTop:l,back:d,up:D,nav:J,railLinks:c,main:oe,card:O,side:re})},fy=16,yr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function qa(e){if(!e)return yr.length;const n=yr.indexOf(e);return n===-1?yr.length:n}function xy(e,n,i){if(n)return e[n]??i(n)}function by(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const yy={秦:[-221,-207],西漢:[-202,8],西汉:[-202,8],東漢:[25,220],东汉:[25,220],漢:[-202,220],汉:[-202,220],三國:[220,280],三国:[220,280],西晉:[265,316],西晋:[265,316],東晉:[317,420],东晋:[317,420],隋:[581,618],唐:[618,907],五代:[907,960],北宋:[960,1127],南宋:[1127,1279],宋:[960,1279],遼:[916,1125],辽:[916,1125],金:[1115,1234],元:[1271,1368],明:[1368,1644],清:[1636,1912]},Cd=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l})=>{var re,D,se,_e,Ae;const{t:d,convert:c,messages:p}=ne(),h=M=>by(M,d),[u,m]=g.useState("全部"),[f,x]=g.useState(!1),[v,y]=g.useState("default"),[$,b]=g.useState(new Map),w=g.useMemo(()=>e._works||[],[e._works]),j=g.useMemo(()=>w.map(M=>{const ie=$.get(M.work_id);return{id:M.work_id,title:(ie==null?void 0:ie.title)??M.title??M.work_id,role:M.role||"",cls:po(M.role),versionCount:ie==null?void 0:ie.versionCount,section:ie==null?void 0:ie.cls,l1:ie==null?void 0:ie.l1,measure:ie==null?void 0:ie.measure,hasImage:ie==null?void 0:ie.hasImage,loaded:!!(ie!=null&&ie.loaded)}}),[w,$]),k=g.useMemo(()=>ic(w.map(M=>M.role),d("detail.roleAll")),[w,d]),C=g.useMemo(()=>{const M=u==="全部"?j:j.filter(ie=>ie.cls===u);return v==="versions"?[...M].sort((ie,ve)=>(ve.versionCount??-1)-(ie.versionCount??-1)):M},[j,u,v]),S=f?C:C.slice(0,fy),_=g.useMemo(()=>S.filter(M=>!$.has(M.id)).map(M=>M.id),[S,$]);g.useEffect(()=>{if(!n||_.length===0)return;let M=!1;return Wi(_,Oi,ie=>n.getItem(ie).then(ve=>{var xe;const we=ve??{},P=we._edition_count??((xe=we._books)==null?void 0:xe.length)??0,fe=ho(we),de=[fe==null?void 0:fe.l1,fe==null?void 0:fe.l2].filter(Boolean).join(" ");return[ie,{id:ie,title:we.title,versionCount:P,loaded:!0,cls:de||void 0,l1:(fe==null?void 0:fe.l1)||void 0,measure:ve&&Wt(ve,p.unit.juan)||void 0,hasImage:!!we._has_image}]}).catch(()=>[ie,{id:ie,loaded:!0}]),()=>M).then(ie=>{M||b(ve=>{const we=new Map(ve);for(const[P,fe]of ie)we.set(P,fe);return we})}),()=>{M=!0}},[n,_,p.unit.juan]);const L=g.useMemo(()=>{const M=new Map;for(const ie of e.alt_names||[]){const ve=ie.type||p.section.aliases;M.has(ve)||M.set(ve,[]),M.get(ve).push(ie.name)}return[...M.entries()].sort((ie,ve)=>qa(ie[0])-qa(ve[0])).map(([ie,ve])=>({label:ie,names:ve}))},[e.alt_names,p]),z=((re=e.dates)==null?void 0:re.birth)??void 0,T=((D=e.dates)==null?void 0:D.death)??void 0,B=(se=e.dates)==null?void 0:se.floruit,W=z!=null||T!=null?`${h(z)||"?"}—${h(T)||"?"}`:Array.isArray(B)&&B.length===2&&B.every(M=>Number.isFinite(M))?d("entityPage.floruit",{from:h(B[0]),to:h(B[1])}):"",N=new Set(["本名","字","號","号"]),R=L.filter(M=>N.has(M.label)),H=L.filter(M=>!N.has(M.label)),q=H.reduce((M,ie)=>M+ie.names.length,0),te=g.useMemo(()=>{const M=[];for(const ve of R)M.push({label:ve.label,value:ve.names.map(we=>c(we)).join("、")});const ie=w.length;return ie&&M.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:ie})}),M},[w,R,c,d]),ae=M=>{var ie;return(ie=L.find(ve=>M.includes(ve.label)))==null?void 0:ie.names[0]},V=ae(["字"]),G=ae(["號","号"]),me=[V?d("entityPage.zi",{name:c(V)}):"",G?d("entityPage.hao",{name:c(G)}):""].filter(Boolean).join(","),K=e.native_place,le=e.dynasty?yy[e.dynasty]:void 0,Se=(()=>{if(!le||z==null||T==null||T<z)return null;const[M,ie]=le,ve=Math.max(z,M),we=Math.min(T,ie);if(we<=ve)return null;const P=ie-M;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":d("entityPage.lifeAria",{birth:h(z),death:h(T),years:T-z+1}),children:t.jsx("i",{style:{left:`${(ve-M)/P*100}%`,width:`${(we-ve)/P*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${h(M)} ${c(e.dynasty)}`}),t.jsx("span",{children:d("entityPage.lifeYears",{years:T-z+1})}),t.jsx("span",{children:h(ie)})]})]})})(),A=g.useMemo(()=>{if(!n||j.length===0||j.some(ve=>!ve.loaded))return null;const M=new Map;for(const ve of j){const we=Dr(ve.l1);we&&M.set(we,(M.get(we)??0)+1)}const ie=Bn.map(ve=>({...ve,n:M.get(ve.key)??0})).filter(ve=>ve.n>0);return ie.length?ie:null},[j,n]),je=t.jsxs(Dn,{kind:xy(p.entityPage.subtype,e.subtype,c),title:c(e.primary_name||e.title),subtitle:me||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(ot,{items:[e.dynasty?c(e.dynasty):"",W,K?d("entityPage.nativePlace",{place:c(K)}):""]}),Se]}),description:(_e=e.description)!=null&&_e.text?t.jsx(Ot,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:xo((Ae=e.description)==null?void 0:Ae.text)?6:void 0,facts:te,foot:t.jsx(Un,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[q>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:d("entityPage.moreNames",{n:q})}),t.jsx("dl",{children:H.map(M=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(M.label)}),t.jsx("dd",{children:M.names.map(ie=>c(ie)).join("、")})]},M.label))})]}),A&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:d("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:A.map(M=>t.jsx("i",{style:{flexGrow:M.n,background:r(M.token)}},M.key))}),t.jsx("div",{className:"bim-d-dist-key",children:A.map(M=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(M.token)}}),c(M.label)," ",M.n]},M.key))})]})]}),ce=g.useMemo(()=>j.filter(M=>M.loaded&&(M.versionCount??0)>0).sort((M,ie)=>(ie.versionCount??0)-(M.versionCount??0)).slice(0,3),[j]),ze=!!n&&j.length>=3&&S.some(M=>!M.loaded),$e=u==="全部"&&(ze||ce.length>=2),Fe=e.external_ids||{},ee=[];Fe.cbdb_id!=null&&ee.push({label:"CBDB",id:String(Fe.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${Fe.cbdb_id}`,note:Fe.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const F=Fe.wikidata_id;F&&ee.push({label:"Wikidata",id:F,href:`https://www.wikidata.org/wiki/${F}`});const U=Fe.viaf_id;U&&ee.push({label:"VIAF",id:U,href:`https://viaf.org/viaf/${U}`});const he=k.map(M=>({key:M.cls,label:`${M.label} ${M.count}`})),X=[...$e&&!ze?[{id:"featured",label:d("entityPage.sec.featured"),count:ce.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...ee.length?[{id:"external",label:d("entityPage.sec.external"),count:ee.length}]:[]],O=$e?t.jsxs(at,{id:"featured",title:d("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:d("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":ze||void 0,children:[ze&&[0,1,2].map(M=>t.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[t.jsx("span",{className:"bim-d-pick-t",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "}),t.jsx("div",{className:"bim-d-pick-n",children:" "})]},M)),!ze&&ce.map(M=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(nt,{id:M.id,label:c(M.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(ot,{items:[M.section?c(M.section):"",M.measure?c(M.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:M.versionCount}),t.jsx("span",{children:d("entityPage.versionsUnit")}),M.hasImage&&t.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},M.id))]})]}):null,J=j.length===0?t.jsx(at,{title:d("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[O,t.jsxs(at,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(ot,{items:[d("entityPage.total",{n:j.length}),C.length!==j.length?d("entityPage.current",{n:C.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[he.length>1&&t.jsx(Ai,{items:he,value:u,onChange:M=>{m(M),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":v==="versions",onClick:()=>{v==="default"&&x(!0),y(M=>M==="default"?"versions":"default")},children:d(v==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Mi(C.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:d("entityPage.col.work")}),t.jsx("th",{children:d("entityPage.col.section")}),t.jsx("th",{children:d("entityPage.col.role")}),t.jsx("th",{children:d("entityPage.col.versions")}),t.jsx("th",{"aria-label":d("entityPage.col.image")})]})}),t.jsx("tbody",{children:S.map(M=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:M.id,label:c(M.title),onNavigate:i,renderLink:o,dense:!0}),M.measure?t.jsx(ot,{items:[c(M.measure)]}):!M.loaded&&n?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.section||M.loaded?"":" bim-d-zt-blank"}`,children:M.section?c(M.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.role?"":" bim-d-zt-blank"}`,children:M.role?c(M.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.loaded?"":" bim-d-zt-blank"}`,children:M.loaded?M.versionCount?d("entityPage.nZhong",{n:M.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),t.jsx("td",{className:M.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:M.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},M.id))})]}),S.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("entityPage.emptyRole")}),!f&&t.jsx(go,{total:C.length,shown:S.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),oe=ee.length>0?t.jsx(rn,{id:"external",title:d("entityPage.sec.external"),items:ee.map(M=>t.jsxs("a",{href:M.href,target:"_blank",rel:"noopener noreferrer",children:[M.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:ee.map(M=>M.id),foot:Fe.cbdb_id!=null&&Fe.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Hn,{railTop:s,back:a,nav:X,railLinks:l,main:J,card:je,side:oe})},Vo="(max-width: 719px)",jy=`${Vo}, (pointer: coarse)`,Td=`
|
|
1354
1354
|
.bim-ct {
|
|
1355
1355
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1356
1356
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1739,7 +1739,7 @@ ${Ay.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1739
1739
|
}
|
|
1740
1740
|
|
|
1741
1741
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1742
|
-
`,My=Jr["zh-Hant"].period,Pd={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Yt(e){return{...Pd,...e??{}}}function Ko(e){var i;const n=(i=e.authors)==null?void 0:i.find(o=>o==null?void 0:o.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Hi(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Bd(e,n=Jr["zh-Hant"].shelfOther){var s;const i=[],o=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=o.get(l);d||(d={label:l,items:[]},o.set(l,d),i.push(d)),d.items.push(a)}return i}function Od(e){return Math.max(150,Array.from(e).length*18+44)}function Wd(e,n){if(n<=0||e<=0)return 0;const i=e/n;return i<.15?0:i<.35?1:i<.6?2:i<.85?3:4}const Fd=.04;function Xe(e){return e.toLocaleString("en-US")}function Hd({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function pt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=ne(),l=`${e}-h`;return t.jsxs("section",{className:"bim-rh-sec",id:e,"aria-labelledby":l,children:[t.jsxs("div",{className:"bim-rh-hd",children:[t.jsx("h2",{id:l,children:a(n)}),i&&t.jsx("span",{className:"bim-rh-sub",children:i}),o]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function Dd({counts:e}){const{t:n}=ne();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Xe(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Xe(e.pieces)}),n("readHome.pieces")]})]})}function Ud({picks:e,links:n}){const{t:i,convert:o}=ne(),s=Yt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Hi(a),d=[a.type_label,a.edition].filter(Boolean).join(" · ");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-pk",href:s.read(a.id),children:[t.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:t.jsx(Hd,{text:o(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:o(d)}),t.jsx("h3",{children:o(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:o(l)}),a.blurb&&t.jsx("p",{children:o(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:i("readHome.startReading")})]})]})},a.id)})}):null}function Vd(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Xo({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ne(),c=Yt(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=Bd(e.items,l("readHome.shelfOther")),u=m=>{const f=m.records?Xe(m.records):Vd(m.text_count,l),x=Ko(m),v=[d(m.title),m.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",m.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":v,title:v,style:{height:Od(m.title)},children:[t.jsx(Hd,{text:d(m.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:f})]})},m.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:i?d(i):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:h.map(m=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(m.label),children:m.items.map(u)}),t.jsx("span",{"aria-hidden":"true",children:d(m.label)})]},m.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(m=>t.jsx("span",{children:d(m)},m))]})]})}const Py=4,Wn=e=>e>Py+1;function Gd({topic:e,links:n}){const{t:i,convert:o}=ne(),s=Yt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":Wn(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nWorks",{n:Xe(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Vd(c.text_count,i),h=Ko(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),h&&t.jsx("small",{children:o(h)})]})},c.id)})}),Wn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?i("action.collapse"):i("readHome.allNWorks",{n:e.items.length})})]})}function Yd({topics:e,links:n}){const i=e.filter(s=>s.shelf&&s.items.length),o=e.filter(s=>!s.shelf&&s.items.length);return!i.length&&!o.length?null:t.jsxs(t.Fragment,{children:[i.map(s=>t.jsx(Xo,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(Gd,{topic:s,links:n},s.key))})]})}function qd({famous:e,links:n}){const{t:i,convert:o}=ne(),s=Yt(n);return e.length?t.jsx("ul",{className:"bim-rh-works",children:e.map(a=>t.jsx("li",{children:t.jsxs("article",{className:"bim-rh-wk",children:[t.jsxs("div",{className:"bim-rh-wk-h",children:[t.jsx("h3",{children:o(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:o(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:i("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?o(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:o(l.label)}),l.items.map(c=>t.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:o([c.title,c.edition].filter(Boolean).join(" · ")),children:o(c.short)},c.id))]},d)),a.work_id&&t.jsx("div",{className:"bim-rh-wk-f",children:t.jsx("a",{href:s.work(a.work_id),children:i("readHome.workPageLink",{title:o(a.title)})})})]})},a.work_id??a.title))}):null}function Zo({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ne(),l=Yt(i);return!e.length&&!n?null:t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-bu",children:e.map(d=>{var p;const c=((p=d.top[0])==null?void 0:p.count)||1;return t.jsxs("li",{className:"bim-rh-bu-c",children:[t.jsxs("a",{className:"bim-rh-bu-h",href:l.node(d.id),children:[t.jsx("b",{children:a(d.label)}),t.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Xe(d.count)})})]}),d.top.length>0&&t.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:a(d.label)}),children:d.top.map(h=>t.jsx("li",{children:t.jsxs("a",{href:l.node(h.id),children:[t.jsx("span",{children:a(h.label)}),t.jsx("small",{className:"bim-rh-num",children:Xe(h.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(h.count/c*100)}%`}})]})},h.id))}),d.children_total>d.top.length&&t.jsx("a",{className:"bim-rh-bu-more",href:l.node(d.id),children:s("readHome.allNClasses",{label:a(d.label),n:d.children_total})})]},d.id)})}),!!n&&t.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[t.jsx("b",{children:s("readHome.unclassified")}),t.jsx("span",{children:s("readHome.nWorks",{n:Xe(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Kd({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ne(),l=a.readHome.period,d=Yt(i),c=e.filter(u=>u.count>0);if(!c.length)return null;const p=c.reduce((u,m)=>u+m.count,0),h=Math.max(...c.map(u=>u.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(u=>{const m=u.label?s(u.label):l[u.key]??s(u.key),f=u.count/p,x=o("readHome.periodItem",{label:m,n:Xe(u.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(u.key),"data-k":Wd(u.count,h),"data-narrow":f<Fd?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:m}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),t.jsx("small",{className:"bim-rh-num",children:Xe(u.count)})]})},u.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:Xe(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Xd({authors:e,links:n}){const{t:i,convert:o}=ne(),s=Yt(n);return e.length?t.jsx("ul",{className:"bim-rh-authors",children:e.map(a=>t.jsxs("li",{className:"bim-rh-au",children:[t.jsxs("h3",{className:"bim-rh-au-h",children:[o(a.name),a.dynasty&&t.jsx("span",{children:o(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nPieces",{n:Xe(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:o(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:i("readHome.authorAll",{name:o(a.name),n:a.count})})]},a.name))}):null}const Zd={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function By({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ne(),l=e,d=Zd,c=l.topics.filter(m=>!m.shelf),p={picks:l.picks.length>0,topics:c.some(m=>m.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(m=>m.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(m=>p[m]),u=m=>a(`readHome.nav.${m}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:qo}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Dd,{counts:l.counts})]}),h.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:h.map(m=>t.jsx("li",{children:t.jsx("a",{href:`#${d[m]}`,children:u(m)})},m))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(pt,{id:d.picks,title:u("picks"),sub:a("readHome.picksSub"),children:t.jsx(Ud,{picks:l.picks,links:n})}),p.topics&&t.jsx(pt,{id:d.topics,title:u("topics"),sub:a("readHome.topicsSub"),children:t.jsx(Yd,{topics:c,links:n})}),p.famous&&t.jsx(pt,{id:d.famous,title:u("famous"),sub:a("readHome.famousSub"),children:t.jsx(qd,{famous:l.famous,links:n})}),p.sibu&&t.jsx(pt,{id:d.sibu,title:u("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Zo,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(pt,{id:d.period,title:u("period"),sub:a("readHome.periodSub"),children:t.jsx(Kd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(pt,{id:d.pieces,title:u("pieces"),sub:a("readHome.piecesSub"),more:o?t.jsx("a",{className:"bim-rh-more",href:o,children:a("readHome.piecesMore")}):void 0,children:t.jsx(Xd,{authors:l.pieces.authors,links:n})})]})]})}const Oy="(max-width: 1079px)",Wy=`${Yn}, (pointer: coarse)`,Jd=`
|
|
1742
|
+
`,My=Jr["zh-Hant"].period,Pd={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Yt(e){return{...Pd,...e??{}}}function Ko(e){var i;const n=(i=e.authors)==null?void 0:i.find(o=>o==null?void 0:o.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Hi(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Bd(e,n=Jr["zh-Hant"].shelfOther){var s;const i=[],o=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=o.get(l);d||(d={label:l,items:[]},o.set(l,d),i.push(d)),d.items.push(a)}return i}function Od(e){return Math.max(150,Array.from(e).length*18+44)}function Wd(e,n){if(n<=0||e<=0)return 0;const i=e/n;return i<.15?0:i<.35?1:i<.6?2:i<.85?3:4}const Fd=.04;function Xe(e){return e.toLocaleString("en-US")}function Hd({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function ut({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=ne(),l=`${e}-h`;return t.jsxs("section",{className:"bim-rh-sec",id:e,"aria-labelledby":l,children:[t.jsxs("div",{className:"bim-rh-hd",children:[t.jsx("h2",{id:l,children:a(n)}),i&&t.jsx("span",{className:"bim-rh-sub",children:i}),o]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function Dd({counts:e}){const{t:n}=ne();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Xe(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Xe(e.pieces)}),n("readHome.pieces")]})]})}function Ud({picks:e,links:n}){const{t:i,convert:o}=ne(),s=Yt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Hi(a),d=[a.type_label,a.edition].filter(Boolean).join(" · ");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-pk",href:s.read(a.id),children:[t.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:t.jsx(Hd,{text:o(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:o(d)}),t.jsx("h3",{children:o(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:o(l)}),a.blurb&&t.jsx("p",{children:o(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:i("readHome.startReading")})]})]})},a.id)})}):null}function Vd(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Xo({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ne(),c=Yt(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=Bd(e.items,l("readHome.shelfOther")),u=m=>{const f=m.records?Xe(m.records):Vd(m.text_count,l),x=Ko(m),v=[d(m.title),m.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",m.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":v,title:v,style:{height:Od(m.title)},children:[t.jsx(Hd,{text:d(m.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:f})]})},m.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:i?d(i):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:h.map(m=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(m.label),children:m.items.map(u)}),t.jsx("span",{"aria-hidden":"true",children:d(m.label)})]},m.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(m=>t.jsx("span",{children:d(m)},m))]})]})}const Py=4,Wn=e=>e>Py+1;function Gd({topic:e,links:n}){const{t:i,convert:o}=ne(),s=Yt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":Wn(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nWorks",{n:Xe(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Vd(c.text_count,i),h=Ko(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),h&&t.jsx("small",{children:o(h)})]})},c.id)})}),Wn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?i("action.collapse"):i("readHome.allNWorks",{n:e.items.length})})]})}function Yd({topics:e,links:n}){const i=e.filter(s=>s.shelf&&s.items.length),o=e.filter(s=>!s.shelf&&s.items.length);return!i.length&&!o.length?null:t.jsxs(t.Fragment,{children:[i.map(s=>t.jsx(Xo,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(Gd,{topic:s,links:n},s.key))})]})}function qd({famous:e,links:n}){const{t:i,convert:o}=ne(),s=Yt(n);return e.length?t.jsx("ul",{className:"bim-rh-works",children:e.map(a=>t.jsx("li",{children:t.jsxs("article",{className:"bim-rh-wk",children:[t.jsxs("div",{className:"bim-rh-wk-h",children:[t.jsx("h3",{children:o(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:o(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:i("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?o(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:o(l.label)}),l.items.map(c=>t.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:o([c.title,c.edition].filter(Boolean).join(" · ")),children:o(c.short)},c.id))]},d)),a.work_id&&t.jsx("div",{className:"bim-rh-wk-f",children:t.jsx("a",{href:s.work(a.work_id),children:i("readHome.workPageLink",{title:o(a.title)})})})]})},a.work_id??a.title))}):null}function Zo({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ne(),l=Yt(i);return!e.length&&!n?null:t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-bu",children:e.map(d=>{var p;const c=((p=d.top[0])==null?void 0:p.count)||1;return t.jsxs("li",{className:"bim-rh-bu-c",children:[t.jsxs("a",{className:"bim-rh-bu-h",href:l.node(d.id),children:[t.jsx("b",{children:a(d.label)}),t.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Xe(d.count)})})]}),d.top.length>0&&t.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:a(d.label)}),children:d.top.map(h=>t.jsx("li",{children:t.jsxs("a",{href:l.node(h.id),children:[t.jsx("span",{children:a(h.label)}),t.jsx("small",{className:"bim-rh-num",children:Xe(h.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(h.count/c*100)}%`}})]})},h.id))}),d.children_total>d.top.length&&t.jsx("a",{className:"bim-rh-bu-more",href:l.node(d.id),children:s("readHome.allNClasses",{label:a(d.label),n:d.children_total})})]},d.id)})}),!!n&&t.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[t.jsx("b",{children:s("readHome.unclassified")}),t.jsx("span",{children:s("readHome.nWorks",{n:Xe(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Kd({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ne(),l=a.readHome.period,d=Yt(i),c=e.filter(u=>u.count>0);if(!c.length)return null;const p=c.reduce((u,m)=>u+m.count,0),h=Math.max(...c.map(u=>u.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(u=>{const m=u.label?s(u.label):l[u.key]??s(u.key),f=u.count/p,x=o("readHome.periodItem",{label:m,n:Xe(u.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(u.key),"data-k":Wd(u.count,h),"data-narrow":f<Fd?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:m}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),t.jsx("small",{className:"bim-rh-num",children:Xe(u.count)})]})},u.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:Xe(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Xd({authors:e,links:n}){const{t:i,convert:o}=ne(),s=Yt(n);return e.length?t.jsx("ul",{className:"bim-rh-authors",children:e.map(a=>t.jsxs("li",{className:"bim-rh-au",children:[t.jsxs("h3",{className:"bim-rh-au-h",children:[o(a.name),a.dynasty&&t.jsx("span",{children:o(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nPieces",{n:Xe(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:o(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:i("readHome.authorAll",{name:o(a.name),n:a.count})})]},a.name))}):null}const Zd={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function By({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ne(),l=e,d=Zd,c=l.topics.filter(m=>!m.shelf),p={picks:l.picks.length>0,topics:c.some(m=>m.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(m=>m.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(m=>p[m]),u=m=>a(`readHome.nav.${m}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:qo}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Dd,{counts:l.counts})]}),h.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:h.map(m=>t.jsx("li",{children:t.jsx("a",{href:`#${d[m]}`,children:u(m)})},m))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(ut,{id:d.picks,title:u("picks"),sub:a("readHome.picksSub"),children:t.jsx(Ud,{picks:l.picks,links:n})}),p.topics&&t.jsx(ut,{id:d.topics,title:u("topics"),sub:a("readHome.topicsSub"),children:t.jsx(Yd,{topics:c,links:n})}),p.famous&&t.jsx(ut,{id:d.famous,title:u("famous"),sub:a("readHome.famousSub"),children:t.jsx(qd,{famous:l.famous,links:n})}),p.sibu&&t.jsx(ut,{id:d.sibu,title:u("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Zo,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(ut,{id:d.period,title:u("period"),sub:a("readHome.periodSub"),children:t.jsx(Kd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(ut,{id:d.pieces,title:u("pieces"),sub:a("readHome.piecesSub"),more:o?t.jsx("a",{className:"bim-rh-more",href:o,children:a("readHome.piecesMore")}):void 0,children:t.jsx(Xd,{authors:l.pieces.authors,links:n})})]})]})}const Oy="(max-width: 1079px)",Wy=`${Yn}, (pointer: coarse)`,Jd=`
|
|
1743
1743
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1744
1744
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1745
1745
|
.bim-mh-q { min-width: 0; }
|
|
@@ -1910,4 +1910,4 @@ ${Ay.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1910
1910
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
1911
1911
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
1912
1912
|
}
|
|
1913
|
-
`,Qd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function qt(e){return{...Qd,...e??{}}}function ep(e,n){if(e.lineage)return e.lineage(n);const i=e.item(n),o=i.indexOf("#"),[s,a]=o<0?[i,""]:[i.slice(0,o),i.slice(o)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function Jo(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function tp(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),i=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:i};const o=p=>{const h=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,u=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,u),Math.max(h,u)]},s=n.map(o),a=Math.min(...s.map(p=>p[0])),l=Math.max(...s.map(p=>p[1])),d=Math.max(1,l-a),c=n.map((p,h)=>({p,from:s[h][0],to:s[h][1]})).sort((p,h)=>p.from-h.from).map(p=>({...p,left:(p.from-a)/d*100,width:Math.max(.8,(p.to-p.from)/d*100)}));return{min:a,max:l,placed:c,missing:i}}function wi(e,n=vn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function Fy(e){return{read:e.item,work:e.item,node:e.node}}function np({counts:e,links:n}){const{t:i}=ne(),o=n==null?void 0:n.type;if(!o)return null;const s=[["all",i("metaHome.typeAll"),null],["work",i("metaHome.typeLabel.work"),e.works],["book",i("metaHome.typeLabel.book"),e.books],["collection",i("metaHome.typeLabel.collection"),e.collections],["entity",i("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":i("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:o(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Xe(d)})]})},a))})}function ip(e,n=5){const[i,o]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Gt().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>no(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{to(),o([])},[]);return{entries:i,clear:s}}function Hy(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):rp(e.type,n)}function rp(e,n){return n(`metaHome.typeLabel.${e}`)}function op({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ne(),a=qt(i);return t.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[t.jsxs("div",{className:"bim-mh-recent-h",children:[t.jsx("h2",{id:"bim-mh-recent-h",children:o("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:o("metaHome.recentClear")})]}),e&&e.length>0&&t.jsx("ol",{children:e.map(l=>t.jsx("li",{children:t.jsxs("a",{href:a.item(l.id),"aria-label":o("metaHome.recentItemLabel",{type:l.type?rp(l.type,o):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?o(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:Hy(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function sp(e,n,i,o=!1){return o&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):i(e)}function ap({rows:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":i("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[i("metaHome.catalogTitle"),t.jsx("small",{children:i("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:i("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:i("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:i("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=Jo(a.imported,a.total),d=a.work_id??a.collection_id,c=o(a.edition?`${a.name}·${a.edition}`:a.name);return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:d?t.jsx("a",{href:s.item(d),children:c}):c}),t.jsx("td",{className:"bim-mh-r",children:Xe(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Xe(a.imported)}),t.jsx("td",{children:t.jsxs("span",{className:"bim-mh-meter",children:[t.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[l,"%"]})]})}),t.jsx("td",{children:a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:sp(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function lp({items:e,links:n,label:i}){const{convert:o}=ne();return t.jsx("ul",{className:"bim-rh-rows","aria-label":i?o(i):void 0,children:e.map(s=>t.jsx("li",{children:t.jsxs("a",{href:n.item(s.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(s.title)}),s.sub&&t.jsx("small",{children:o(s.sub)})]})},s.id))})}function cp({works:e,links:n}){const{t:i}=ne(),[o,s]=g.useState(!1);if(!e.length)return null;const a=Wn(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":o?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[i("metaHome.relatedTitle"),t.jsx("small",{children:i("metaHome.relatedNote")})]}),t.jsx(lp,{items:e.map(l=>({id:l.id,title:l.title,sub:Hi(l)||void 0})),links:qt(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":o,onClick:()=>s(l=>!l),children:o?i("action.collapse"):i("metaHome.allNWorks",{n:e.length})})]})}const dp="siku_qige";function Dy({group:e,links:n}){const{t:i,convert:o}=ne(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Wn(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(lp,{items:e.items,links:n,label:e.label}),Wn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?i("action.collapse"):i("metaHome.allNKinds",{n:e.items.length})})]})}function pp({groups:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);if(!e.length)return null;const a=e.find(c=>c.key===dp),l=e.filter(c=>c!==a),d=c=>{var p;return((p=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:p[1])??c};return t.jsxs(t.Fragment,{children:[a&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(a.label),t.jsx("small",{children:o(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":o(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":o(c.title),title:o(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:o(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:i("metaHome.pavilion")})]})},c.id))})]}),l.length>0&&t.jsx("div",{className:"bim-mh-cg",style:a?void 0:{marginTop:0},children:l.map(c=>t.jsx(Dy,{group:c,links:s},c.key))})]})}const Ka=34,Xa=13;function Za(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?wi(e.birth_year,n):"?"}–${e.death_year!=null?wi(e.death_year,n):"?"}`}function Uy(e,n){const i=n-e,o=i>1200?300:i>400?100:50,s=[];for(let a=Math.ceil(e/o)*o;a<=n;a+=o)s.push(a);return s}function up({people:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=tp(e),p=[],h=d.map(m=>{const f=m.left>70,x=f?Math.min(m.left,m.left+m.width-Xa):m.left;let v=0;for(;p[v]!=null&&p[v]>x;)v++;return p[v]=f?m.left+m.width:m.left+Math.max(m.width,Xa),{...m,lane:v,end:f}}),u=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[h.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Ka+10},children:h.map(m=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*Ka+4,width:`${Math.max(m.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(m.p.id),children:[o(m.p.name),t.jsx("small",{className:"bim-rh-num",children:Za(m.p,i)})]})]},m.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Uy(a,l).map(m=>t.jsx("span",{style:{left:`${(m-a)/u*100}%`},children:wi(m,i)},m))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(m=>t.jsx("li",{children:t.jsxs("a",{href:s.item(m.id),children:[t.jsx("span",{children:o(m.name)}),t.jsx("small",{className:"bim-rh-num",children:[m.dynasty?o(m.dynasty):"",Za(m,i)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(m=>m.name).join("、"))})})]})}const Vy=t.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[t.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),t.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),t.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function mp({works:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Hi(a);return t.jsx("li",{children:t.jsxs("a",{href:ep(s,a.id),children:[Vy,t.jsx("b",{children:o(a.title)}),l&&t.jsx("small",{children:o(l)}),t.jsx("span",{children:i("metaHome.viewLineage")})]})},a.id)})}):null}function hp({sites:e}){const{t:n,convert:i}=ne(),o=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!o.includes(a));return e.length?t.jsxs(t.Fragment,{children:[o.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:o.map(a=>{const l=Jo(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:i(a.name)}):t.jsx("span",{children:i(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Xe(a.imported)} / ${Xe(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:sp(a.status,n,i,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:i(s.map(a=>a.name).join("、"))})})]}):null}const Ja=["extant","partially_extant","lost","unknown"];function gp({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=ne(),l=["works","books","collections","entities","has_image","has_text","article","poem"].map(p=>[e[p],a(`metaHome.stat.${p}`)]).filter(([p])=>p>0),d=n==null?void 0:n.loss,c=Ja.some(p=>{var h;return(((h=e.loss)==null?void 0:h[p])??0)>0});return t.jsxs("div",{className:"bim-mh-data",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.dataScale")}),t.jsx("ul",{className:"bim-mh-nums",children:l.map(([p,h])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Xe(p)}),t.jsx("span",{children:h})]},h))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Ja.map(p=>{var m;const h=((m=e.loss)==null?void 0:m[p])??0,u=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&h>0?a("metaHome.lossCount",{n:Xe(h),note:u}):u})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),o?t.jsx("a",{href:o,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),i&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:i})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const fp={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Gy({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:h}){var k,C;const{t:u}=ne(),m=e,f=qt(n),x=Fy(f),v=fp,y=ip(o),$={zhi:!!((k=m.shelf)!=null&&k.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(v).filter(S=>$[S]),w=S=>u(`metaHome.nav.${S}`),j=(S,_)=>S?t.jsx("a",{className:"bim-rh-more",href:S,children:_}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:qo+Jd}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(np,{counts:m.counts,links:n})]}),o&&t.jsx(op,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":u("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(S=>t.jsx("li",{children:t.jsx("a",{href:`#${v[S]}`,children:w(S)})},S))})}),t.jsxs("div",{className:"bim-rh-main",children:[$.zhi&&t.jsxs(pt,{id:v.zhi,title:w("zhi"),sub:u("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&t.jsx(Xo,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:x,showTitle:!1,legendCount:m.shelf.items.some(S=>S.records)?u("metaHome.shelfLegendCount"):null,legendExtra:[u("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(C=m.shelf)!=null&&C.items.length?void 0:{marginTop:0},children:[t.jsx(ap,{rows:m.catalog_progress,links:n}),t.jsx(cp,{works:m.related_catalogs,links:n})]})]}),$.sibu&&t.jsx(pt,{id:v.sibu,title:w("sibu"),sub:u("metaHome.sibuSub"),more:j(s,u("metaHome.toCatalog")),children:t.jsx(Zo,{bu:m.bu,unclassified:m.unclassified,links:x,unclassifiedNote:u("metaHome.unclassifiedNote")})}),$.cong&&t.jsx(pt,{id:v.cong,title:w("cong"),sub:u("metaHome.congSub"),more:j(a,u("metaHome.allNKindsMore",{n:Xe(m.counts.collections)})),children:t.jsx(pp,{groups:m.collection_groups,links:n})}),$.people&&t.jsx(pt,{id:v.people,title:w("people"),sub:u("metaHome.peopleSub"),more:j(l,u("metaHome.allNPeopleMore",{n:Xe(m.counts.entities)})),children:t.jsx(up,{people:m.bibliographers,links:n})}),$.lineage&&t.jsx(pt,{id:v.lineage,title:w("lineage"),sub:u("metaHome.lineageSub"),children:t.jsx(mp,{works:m.lineage,links:n})}),$.sites&&t.jsx(pt,{id:v.sites,title:w("sites"),sub:u("metaHome.sitesSub"),children:t.jsx(hp,{sites:m.sites})}),t.jsx(pt,{id:v.data,title:w("data"),sub:u("metaHome.dataSub"),children:t.jsx(gp,{stats:m.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const xp=["_related","_catalogs","_collections","_members","_children"],Yy=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ur=e=>Yy(e)&&!!e.h;function qy(e){return e?xp.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(Ur)}):!1}function Ky(e,n){const i={...e};if(!n)return i;for(const o of xp){const s=e[o];!Array.isArray(s)||!s.some(Ur)||(i[o]=s.map(a=>{var c;if(!Ur(a)||typeof a.title=="string"&&a.title)return a;const l=a.id??a.bid,d=l?(c=n[l])==null?void 0:c.title:void 0;return d?{...a,title:d}:a}))}return i}function Xy(e){let n=null;const i=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null);return new Proxy(e,{get(o,s){if(s==="getItem")return async l=>{const d=await o.getItem(l);return d&&Ky(d,qy(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const Vr=({style:e})=>{const n=g.useContext(Nt),{t:i}=ne();if(!n)return null;const{locale:o,setLocale:s}=n,a=o==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:i(a?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${r("border")}`,borderRadius:"4px",background:r("bg"),color:r("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?r("primary"):void 0,fontWeight:a?700:400},children:i("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:r("primary"),fontWeight:a?400:700},children:i("common.localeShortHans")})]})},Gr=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=ne(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:o,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i+8,height:i+8,borderRadius:4,color:r("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=r("fg")},onMouseLeave:d=>{d.currentTarget.style.color=r("desc-fg")},children:t.jsx("svg",{width:i,height:i,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})})};function jr(e){const n=e.text_count;return typeof n=="number"&&n>0}function vr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function Zy(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const Jy=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:u,initialPage:m=1,selectedLineageNodeId:f,onNavigate:x,onBack:v,backLabel:y,renderLink:$,enrichDetail:b,getSourceLink:w,readLink:j,railTop:k,extraTabs:C=[],showFeedbackTab:S=!0,feedbackApiUrl:_,height:L,footerExtra:z,hideHeaderControls:T=!1,className:B,style:W})=>{const N=g.useMemo(()=>Xy(n),[n]),R=Ee(),{t:H,convert:q}=ne(),[te]=g.useState(()=>{if(!Zy(e,i))return null;const Q={...i},ye=o??vr(e,Q);return b&&b(ye,Q),{id:e,entry:ye,detail:Q}}),[ae,V]=g.useState((te==null?void 0:te.entry)??null),[G,me]=g.useState((te==null?void 0:te.detail)??null),[K,le]=g.useState(!te),[Se,A]=g.useState(!1),[je,ce]=g.useState([]),[ze,$e]=g.useState(!1),[Fe,ee]=g.useState(null),[F,U]=g.useState(null),[he,X]=g.useState(null),[O,J]=g.useState(!1),oe=g.useRef(null),re=g.useRef(0),[D,se]=g.useState(null),_e=l!==void 0?l:D,Ae=g.useCallback(Q=>{d?d(Q):se(Q)},[d]),M=g.useCallback(async Q=>{if(!N.getCollectionCatalogs&&!N.getCollectionCatalog){ce([]);return}$e(!0);try{if(N.getCollectionCatalogs)ce(await N.getCollectionCatalogs(Q)||[]);else if(N.getCollectionCatalog){const ye=await N.getCollectionCatalog(Q);ce(ye?[{resource_id:"",data:ye}]:[])}}catch{ce([])}finally{$e(!1)}},[N]),ie=g.useCallback(async Q=>{var ye,We;if(!N.getTextManifest||!N.getTextIndex){ee(null),U(Q);return}try{const He=ke.pickTextVersion(await N.getTextManifest(Q)),Ne=He?await N.getTextIndex(Q,He.key):null;ee(Ne&&Ne.chapters.length>0?{chapters:Ne.chapters.map(Pe=>({n:Pe.n,title:Pe.title,file:Pe.file})),source:{name:((ye=Ne.source)==null?void 0:ye.name)??(He==null?void 0:He.source_name),license:((We=Ne.source)==null?void 0:We.license)??(He==null?void 0:He.license)??void 0}}:null)}catch{ee(null)}finally{U(Q)}},[N]),ve=g.useCallback(async(Q,ye)=>{const We=++re.current,He=()=>We!==re.current;J(!0);try{if(N.getLineageGraph){const Qe=await N.getLineageGraph(Q);if(He())return;Qe&&X(Qe)}const Ne=ye.version_graph;if(!Ne||!Ne.enabled){he||X(null),oe.current=null;return}const Pe=mo(ye),Be=(await Wi(Pe,Oi,async Qe=>{try{return await N.getItem(Qe)}catch{return null}},He)).filter(Boolean);if(He())return;oe.current={work:ye,books:Be};const Ie=h??Ne.default_collection??(Ne.core_books&&Ne.core_books.length>0?"core":"all"),De=Ie==="core"&&Array.isArray(Ne.core_books)&&Ne.core_books.length>0?"core":Ie??"all";X(fi(ye,Be,De))}catch{if(He())return;X(null),oe.current=null}finally{He()||J(!1)}},[N]),we=g.useRef({initialDetail:i,initialEntry:o});we.current={initialDetail:i,initialEntry:o},g.useEffect(()=>{let Q=!1;re.current++,J(!1);const ye=Pe=>{Pe.type==="collection"?M(e):Pe.type==="work"?(Pe.version_graph||N.getLineageGraph)&&ve(e,Pe):Pe.type==="book"&&jr(Pe)&&ie(e)},We=we.current;let He=null;if(te&&te.id===e)He=te;else if(We.initialDetail&&We.initialDetail.id===e){const Pe={...We.initialDetail},Le=We.initialEntry??vr(e,Pe);b&&b(Le,Pe),He={entry:Le,detail:Pe}}return He?(A(!1),ce(Pe=>Pe.length?[]:Pe),ee(null),X(null),oe.current=null,V(He.entry),me(He.detail),le(!1),ye(He.detail),()=>{Q=!0}):((async()=>{le(!0),A(!1),V(null),me(null),ce([]),ee(null),X(null),oe.current=null;try{const Pe=await N.getItem(e);if(Q)return;if(!Pe){A(!0);return}const Le=Pe;let Be=null;if(N.getEntry&&(Be=await N.getEntry(e),Q))return;Be||(Be=vr(e,Le)),b&&b(Be,Le),V(Be),me(Le),ye(Le)}catch{Q||A(!0)}finally{Q||le(!1)}})(),()=>{Q=!0})},[e,N,te,b,M,ve,ie]),g.useEffect(()=>{const Q=oe.current;!Q||!h||X(fi(Q.work,Q.books,h))},[h]);const P=[];if(G){if(P.push({key:"basic",label:R.detailTab.basicInfo}),G.type==="collection"){ze&&je.length===0&&P.push({key:"catalog:loading",label:`${R.detailTab.catalog}…`});for(const Q of je)P.push({key:`catalog:${Q.resource_id}`,label:Q.short_name?`${q(Q.short_name)}${R.detailTab.catalogSuffix}`:R.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&P.push({key:s,label:R.detailTab.fullText}),G.type==="work"&&(he||O)&&P.push({key:"lineage",label:O?`${R.detailTab.lineage}…`:R.detailTab.lineage});for(const Q of C)(Q.position??"before-feedback")==="before-feedback"&&Q.shouldShow(G)&&P.push({key:Q.key,label:Q.label});S&&s==="feedback"&&P.push({key:"feedback",label:R.detailTab.feedback});for(const Q of C)Q.position==="after-feedback"&&Q.shouldShow(G)&&P.push({key:Q.key,label:Q.label})}g.useEffect(()=>{if(s!=="emendated"||!G)return;a("basic");const Q=setTimeout(()=>{var ye;(ye=document.getElementById("studies"))==null||ye.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Q)},[s,G,a]);const fe=ae&&G&&w?w({activeTab:s,activeJuan:_e,entry:ae,detail:G}):null,de=g.useMemo(()=>{var Ne,Pe,Le,Be,Ie;if(!G)return null;const ye=(G.authors??[]).map(De=>{const Qe=uo(De.role);return`${De.dynasty?`〔${q(De.dynasty)}〕`:""}${q(De.name)}${Qe?` ${q(Qe)}`:""}`}).join(" · ");let We=!1;try{We=ke.extractStatus(G.id)==="draft"}catch{}if(G.type==="book"){const De=G;return{title:q(De.title),subtitle:De.edition?q(De.edition):ye||void 0,aside:[We?R.status.draft:"",ye&&De.edition?ye:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(G.type==="collection"){const De=G;return{title:q(De.title),subtitle:q(Wt(De,R.unit.juan))||void 0,aside:[(Ne=De.publication_info)==null?void 0:Ne.year,We?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ye||void 0}}if(G.type==="entity"){const De=G,Qe=yt=>yt==null?"":yt<0?H("detail.bce",{n:-yt}):String(yt),Ft=((Pe=De.dates)==null?void 0:Pe.birth)!=null||((Le=De.dates)==null?void 0:Le.death)!=null?`${Qe(((Be=De.dates)==null?void 0:Be.birth)??void 0)||"?"}—${Qe(((Ie=De.dates)==null?void 0:Ie.death)??void 0)||"?"}`:"";return{title:q(De.primary_name||De.title),subtitle:[De.dynasty?`〔${q(De.dynasty)}〕`:"",Ft].filter(Boolean).join(" ")||void 0,aside:We?R.status.draft:void 0,secondLine:void 0}}const He=q(Wt(G,R.unit.juan));return{title:q(G.title),subtitle:[He,ye].filter(Boolean).join(" · ")||void 0,aside:[e0(R,G.subtype),We?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[G,q,R,H]),xe=G&&jr(G)?"text":null,Ce=()=>{Ae(null),a("fulltext")};let Ue=null;if(G&&j){const Q=j({detail:G,kind:xe});Q&&(Ue=t.jsx(Ir,{href:Q}))}else xe&&(Ue=t.jsx(Ir,{onClick:Ce}));const Ke=Q=>{if(!G)return null;const ye=Q.replace(/\.[^.]+$/,"");if(j){const We=j({detail:G,kind:xe,juan:ye});return We?{href:We}:null}return{onClick:()=>{Ae(ye),a("fulltext")}}},Je=new Set(C.map(Q=>Q.key)),qe=P.filter(Q=>Q.key.startsWith("catalog:")&&Q.key!=="catalog:loading"||Q.key==="lineage"&&!!he&&!O||Je.has(Q.key)).map(Q=>({key:Q.key,label:Q.label,onClick:()=>a(Q.key)})),I=()=>{var Q;return G?G.type==="work"?t.jsx(vd,{data:G,transport:N,onNavigate:x,renderLink:$,readAction:Ue,railTop:k,railLinks:qe}):G.type==="book"?t.jsx(_d,{data:G,transport:N,onNavigate:x,renderLink:$,readAction:Ue,fullText:Fe,fullTextPending:jr(G)&&!!N.getTextManifest&&F!==G.id,chapterLink:Ke,railTop:k,railLinks:qe}):G.type==="collection"?t.jsx($d,{data:G,catalog:(Q=je[0])==null?void 0:Q.data,transport:N,onNavigate:x,renderLink:$,readAction:Ue,railTop:k,railLinks:qe,catalogAction:je.length>0?t.jsxs("a",{href:"#catalog",onClick:ye=>{ye.preventDefault(),a(`catalog:${je[0].resource_id}`)},children:[q(R.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Cd,{data:G,transport:N,onNavigate:x,renderLink:$,railTop:k,railLinks:qe}):null},Y=()=>{var ye,We,He;if(!ae||!G)return null;if(s==="basic"||s==="emendated")return I();if(typeof s=="string"&&s.startsWith("catalog:")){const Ne=(ye=je.find(Pe=>`catalog:${Pe.resource_id}`===s))==null?void 0:ye.data;return t.jsx(ro,{data:Ne,onNavigate:x,renderLink:$})}if(s==="collated"||s==="fulltext")return t.jsx(Oo,{id:e,transport:N,chapter:_e,onLocationChange:Ne=>Ae(Ne.chapter),onNavigate:x});if(s==="lineage"){if(!he)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:H(O?"detail.loading":"detail.noLineageGraph")});const Ne=G.type==="work"?G:null;return t.jsx(Uo,{graph:he,renderLink:$,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:h??((We=Ne==null?void 0:Ne.version_graph)==null?void 0:We.default_collection),onCollectionChange:u,collectionsAvailable:(He=Ne==null?void 0:Ne.version_graph)==null?void 0:He.collections,collectionCounts:(()=>{var Ie,De,Qe,Ft,yt,Kt,Ye;if(!Ne)return;const Pe={},Le=((Ie=oe.current)==null?void 0:Ie.books)??[];Pe.all=(((De=Ne._books)==null?void 0:De.length)??0)-(((Ft=(Qe=Ne.version_graph)==null?void 0:Qe.excluded_books)==null?void 0:Ft.length)??0);const Be=(yt=Ne.version_graph)==null?void 0:yt.collections;if(Be)for(const Z of Object.keys(Be))Pe[Z]=fi(Ne,Le,Z).nodes.filter(Ve=>Ve.kind==="book"&&!Ve.bridge).length;return Pe.core==null&&((Ye=(Kt=Ne.version_graph)==null?void 0:Kt.core_books)!=null&&Ye.length)&&(Pe.core=Ne.version_graph.core_books.length),Pe})()})}if(s==="feedback"&&S)return t.jsx(xd,{resourceId:e,apiUrl:_});const Q=C.find(Ne=>Ne.key===s);return Q?Q.render({detail:G,entry:ae,transport:N,onNavigate:x}):null};if(K)return t.jsx(Rn,{style:{minHeight:L,...W},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Q,ye)=>t.jsx("div",{style:{height:ye===1?40:16,width:Q,opacity:.35,background:r("rule")}},ye))})});if(Se||!G||!ae||!de)return t.jsx(Rn,{style:{minHeight:L,...W},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:H("detail.notFound")})});const pe=s==="basic"||s==="emendated",be=[{label:y??R.detailTab.backToIndex,onClick:v}];if(G.type==="book"&&G.work_id){const Q=G.work_id;be.push({label:R.indexType.work,id:Q,onClick:()=>x==null?void 0:x(Q)})}be.push({label:R.indexType[G.type]});const Re=s==="collated"||s==="fulltext",ge=typeof z=="string"?R.status[z.trim()]??z:z,Me=t.jsx(_c,{left:t.jsxs(t.Fragment,{children:[ge,ge?" · ":"",t.jsx(Qy,{id:G.id,label:R.label.id,copied:R.action.copied,copyLabel:R.action.copy})]}),right:t.jsxs(t.Fragment,{children:[S&&!pe&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:R.detailTab.submitVersion}),fe&&t.jsx("a",{href:fe.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:R.detailTab.dataLicense})]})});return pe?t.jsx("div",{className:B,children:t.jsxs(Rn,{grid:!0,style:{minHeight:L,...W},children:[t.jsx(Er,{breadcrumb:t.jsx(Rr,{items:be}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Vr,{style:{border:"none",background:"transparent"}}),!T&&fe&&t.jsx(Gr,{...fe})]})}),I(),Me]})}):t.jsx("div",{className:B,children:t.jsxs(Rn,{wide:Re,style:{minHeight:L,...W},children:[t.jsx(Er,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(bo,{char:"籍"}),t.jsx(Rr,{items:be})]}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Vr,{}),S&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:R.detailTab.feedback}),!T&&fe&&t.jsx(Gr,{...fe})]})}),t.jsx(fc,{...de,aside:Re?t.jsxs("button",{type:"button",onClick:()=>a("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("accent"),borderBottom:`1px solid ${r("rule")}`},children:[H("detail.workInfo")," →"]}):de.aside}),!Re&&P.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:P.map(Q=>t.jsx(xc,{label:Q.label,active:Q.key===s||pe&&Q.key==="basic",onClick:()=>a(Q.key)},Q.key))}),t.jsx("div",{style:{marginTop:!Re&&P.length>1?8:0},children:Y()}),Me]})})};function Qy({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?i:o,"aria-label":s?i:o,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:r("aux-fg")},children:s?"✓":"⧉"})]})}function e0(e,n){return n?e.workSubtype[n]??n:""}const bp=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Di="zhusha",Ui="bim-theme";function yp(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Vi(e){return yp(e)?e:Di}function t0(){try{return Vi(window.localStorage.getItem(Ui))}catch{return Di}}function jp(e){try{window.localStorage.setItem(Ui,e)}catch{}}function vp(e){const n=Vi(e);return document.documentElement.setAttribute("data-theme",n),n}function kp(){return Vi(document.documentElement.getAttribute("data-theme"))}const n0=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Qo="airy",Gi="bim-layout";function wp(e){return e==="airy"||e==="boxed"}function Yi(e){return wp(e)?e:Qo}function i0(){try{return Yi(window.localStorage.getItem(Gi))}catch{return Qo}}function r0(e){try{window.localStorage.setItem(Gi,e)}catch{}}function o0(e){const n=Yi(e);return document.documentElement.setAttribute("data-layout",n),n}function s0(){return Yi(document.documentElement.getAttribute("data-layout"))}const a0=`try{var t=localStorage.getItem(${JSON.stringify(Ui)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Gi)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,l0={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},c0=({onChange:e,style:n})=>{const{t:i}=ne(),[o,s]=g.useState(Di);g.useEffect(()=>{s(kp())},[]);const a=l=>{s(vp(l)),jp(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:bp.map(l=>{const d=o===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":i(`common.theme.${l.name}`),title:i(`common.theme.${l.name}`),onClick:()=>a(l.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:r(l0[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=ke.BidLink;exports.BookIndexError=ke.BookIndexError;exports.BookIndexManager=ke.BookIndexManager;exports.BookIndexStorage=ke.BookIndexStorage;exports.BundleStorage=ke.BundleStorage;exports.ConfigError=ke.ConfigError;exports.GithubStorage=ke.GithubStorage;exports.IdGenerationError=ke.IdGenerationError;exports.IdGenerator=ke.IdGenerator;exports.LocalStorage=ke.LocalStorage;exports.MigrationError=ke.MigrationError;exports.StorageError=ke.StorageError;exports.VARIANT_CHARS=ke.VARIANT_CHARS;exports.base36Decode=ke.base36Decode;exports.base36Encode=ke.base36Encode;exports.base58Decode=ke.base58Decode;exports.buildId=ke.buildId;exports.buildPromotionMap=ke.buildPromotionMap;exports.cleanName=ke.cleanName;exports.decodeId=ke.decodeId;exports.decodeIdString=ke.decodeIdString;exports.encodeId=ke.encodeId;exports.extractIdFromUrl=ke.extractIdFromUrl;exports.extractStatus=ke.extractStatus;exports.extractType=ke.extractType;exports.isChapterSegment=ke.isChapterSegment;exports.isTextKey=ke.isTextKey;exports.matchChapterAcrossVersions=ke.matchChapterAcrossVersions;exports.normalizeCatalog=ke.normalizeCatalog;exports.normalizeVariants=ke.normalizeVariants;exports.parseId=ke.parseId;exports.pickTextVersion=ke.pickTextVersion;exports.shardOf=ke.shardOf;exports.smartDecode=ke.smartDecode;exports.textVersionLabel=ke.textVersionLabel;exports.validateResource=ke.validateResource;exports.VARIANT_SUPPLEMENT=Qa.VARIANT_SUPPLEMENT;exports.Badge=ki;exports.BidUrlProvider=qp;exports.BookDetailLayout=Jy;exports.BookPage=_d;exports.Breadcrumb=Rr;exports.CATALOG_ALL_ID=Mt;exports.CATALOG_CSS=Td;exports.CATALOG_NARROW_QUERY=Vo;exports.CATALOG_PAGE_SIZE=Go;exports.CATALOG_UNCLASSIFIED_ID=nn;exports.CLASSIFICATIONS=zi;exports.COMMON_TRADITIONAL_CHARS=dl;exports.CardFoot=Un;exports.CatalogPage=Ey;exports.CatalogPager=Ad;exports.CatalogTree=Nd;exports.CheckFilter=mc;exports.Chip=bc;exports.ChipWall=Kh;exports.CollectionCatalog=ro;exports.CollectionPage=$d;exports.CreateEntityDialog=cd;exports.DEFAULT_LAYOUT=Qo;exports.DEFAULT_META_HOME_LINKS=Qd;exports.DEFAULT_READER_PREFS=so;exports.DEFAULT_READ_HOME_LINKS=Pd;exports.DEFAULT_THEME=Di;exports.DETAIL_CSS=gc;exports.DYNASTY_GROUPS=Ti;exports.Dash=tg;exports.DataTable=Zh;exports.DetailFooter=_c;exports.DetailGrid=Hn;exports.DetailHeader=fc;exports.EMPTY_FILTERS=Ci;exports.ENTITY_TEXT_CSS=Lo;exports.EmendatedBySection=El;exports.EmptyNote=lg;exports.EntityDetail=$l;exports.EntityMark=Mo;exports.EntityPage=Cd;exports.EntityPickerDialog=pd;exports.EntitySelector=ld;exports.EntityText=Cf;exports.ExpandRow=ng;exports.ExtLink=cg;exports.FEEDBACK_FAB_OFFSET_VAR=Fr;exports.FILTER_SUPPORT=xl;exports.FONT_SIZE_STEPS=At;exports.FactList=Vh;exports.FeedbackButton=yb;exports.FeedbackDialog=gd;exports.FeedbackForm=fd;exports.FeedbackList=Wo;exports.FeedbackTab=xd;exports.FilterChip=xc;exports.FormInput=ft;exports.FormTextArea=on;exports.GUJI_MARKDOWN_FIELD=Nh;exports.GUJI_TABLE_NOTATION=$c;exports.GlyphBadge=bo;exports.GujiInteractiveReader=hx;exports.GujiTable=vo;exports.GujiTextViewer=Po;exports.GujiWarpCanvas=Ro;exports.HomePage=Or;exports.ImagePanel=_r;exports.IndexApp=mx;exports.IndexBrowser=Sr;exports.IndexDetail=io;exports.IndexEditor=ud;exports.IndexView=ob;exports.IntroGrid=Uh;exports.LAYOUTS=n0;exports.LAYOUT_STORAGE_KEY=Gi;exports.LOSS_OPTIONS=fl;exports.LocaleContext=Nt;exports.LocaleProvider=ku;exports.LocaleToggle=Vr;exports.META_HOME_CSS=Jd;exports.META_HOME_SECTION_IDS=fp;exports.MetaCatalogTable=ap;exports.MetaCollectionGroups=pp;exports.MetaDataLicense=gp;exports.MetaHomeView=Gy;exports.MetaLine=ot;exports.MetaLineageCards=mp;exports.MetaOnlineSites=hp;exports.MetaPeopleTimeline=up;exports.MetaRecentPanel=op;exports.MetaRelatedCatalogs=cp;exports.MetaTypeChips=np;exports.ModeIndicator=ul;exports.MoreButton=qh;exports.MoreLink=fo;exports.PAGE_MAX_WIDTH=mi;exports.PERIOD_NARROW_SHARE=Fd;exports.PageFrame=Rn;exports.Quote=rg;exports.READER_CSS=Ol;exports.READ_HOME_CSS=qo;exports.READ_HOME_NARROW_QUERY=Yn;exports.READ_HOME_SECTION_IDS=Zd;exports.READ_PERIOD_LABELS=My;exports.RECENT_IDS_STORAGE_KEY=hn;exports.ROLE_CLASS_ORDER=nc;exports.ReadButton=Ir;exports.ReadFamousWorks=qd;exports.ReadHomeView=By;exports.ReadPeriodBand=Kd;exports.ReadPicks=Ud;exports.ReadPieces=Xd;exports.ReadSection=pt;exports.ReadShelf=Xo;exports.ReadSibu=Zo;exports.ReadStats=Dd;exports.ReadTopicGroup=Gd;exports.ReadTopics=Yd;exports.ReaderMdText=_o;exports.ReaderShell=Yl;exports.ReaderToc=Fl;exports.RelationPanel=sd;exports.RepoSourceLink=Gr;exports.ResourceEditor=kr;exports.ResourceGroup=og;exports.ResourceLine=sg;exports.ResourceList=Qr;exports.ResourceRow=wc;exports.SEARCH_VIEW_STORAGE_KEY=eo;exports.SEVEN_PAVILIONS_KEY=dp;exports.SNIPPET_MARK_END=nl;exports.SNIPPET_MARK_START=tl;exports.SORTABLE_TYPES=gl;exports.SearchInput=hl;exports.SearchResults=wl;exports.Sec=at;exports.Section=wt;exports.SectionHead=Gh;exports.SideList=rn;exports.SmartBidInput=gi;exports.SourceEditor=id;exports.StripWarpRenderer=Mr;exports.SummaryCard=Dn;exports.THEMES=bp;exports.THEME_INIT_SCRIPT=a0;exports.THEME_STORAGE_KEY=Ui;exports.TRADITIONAL_ALLOWLIST=pl;exports.TabFilter=Ai;exports.TableHead=Jh;exports.TableRow=Qh;exports.TagRow=Sc;exports.TagRows=ag;exports.TextButton=Yh;exports.TextReader=Oo;exports.ThemeToggle=c0;exports.TopStrip=Er;exports.VersionLineageGraph=Sd;exports.VersionLineageList=wd;exports.VersionLineageView=Uo;exports.VolumeChips=Xh;exports.VolumeLinks=yo;exports.WorkCard=Rd;exports.WorkCardGrid=Md;exports.WorkCatalog=Sx;exports.WorkPage=vd;exports.WorkRow=Ld;exports.adaptCharCord=wx;exports.adaptEntityJson=Bc;exports.adaptNorm=nd;exports.adaptNormDetailed=td;exports.adaptPunctJson=fx;exports.applyLayout=o0;exports.applyTheme=vp;exports.authorsLine=Hi;exports.bookIndexUriToId=Ar;exports.bookMarkingOf=So;exports.bucketResources=co;exports.buildCatalogTree=wy;exports.buildCollectionTable=oc;exports.buildLineageGraph=fi;exports.buildMeiliFilter=Wu;exports.buildPageUrl=Zr;exports.buildParagraphBlocks=Rc;exports.buildVersionRow=ec;exports.buildVersionTable=tc;exports.canParagraphize=ji;exports.catalogNodeIdOf=vy;exports.catalogNodeIdsOf=ky;exports.catalogPageCount=Cy;exports.catalogTotal=Yo;exports.classificationPath=Gn;exports.clearAllRecentIds=to;exports.compareCatalogCards=$y;exports.computeVersionPartition=wh;exports.countActiveFilters=Ni;exports.createTextApi=Ll;exports.currentLayout=s0;exports.currentTheme=kp;exports.defaultEntityHref=Yc;exports.defaultWorkLink=Id;exports.deriveDating=jh;exports.deriveEditionType=ac;exports.deriveEra=Fn;exports.deriveYear=Ei;exports.deriveYearRange=lo;exports.detailToEditor=hd;exports.detectGenre=Pi;exports.displayAuthorRole=uo;exports.editorToDetail=rb;exports.eraRank=zr;exports.filtersFromParams=Fu;exports.filtersToParams=xi;exports.findCatalogPath=mn;exports.findTraditionalChars=_u;exports.firstAuthorText=Ko;exports.flattenTitles=Lr;exports.flattenToc=Gl;exports.fmtCount=Xe;exports.formatHitCount=pi;exports.formatTemplate=xt;exports.formatVolumeRange=Li;exports.getDisplayNameFromUrl=bn;exports.getMessages=jn;exports.getStartPage=Xr;exports.getT=vn;exports.getTypeGroupKey=qr;exports.groupRelatedWorks=vh;exports.gujiInlineToPlain=pc;exports.hasActiveFilters=bl;exports.hasGujiMarkdownV02=Ih;exports.hasGujiTableNotation=dg;exports.hasSearchOptions=Pu;exports.iiifVolumeOf=xx;exports.isCountedChar=$o;exports.isLayoutName=wp;exports.isThemeName=yp;exports.lineageHref=ep;exports.loadRecentIds=Gt;exports.measureText=Wt;exports.mergeVolumeResources=Kr;exports.normalizeEra=rt;exports.normalizeLayout=Yi;exports.normalizeRole=po;exports.normalizeTheme=Vi;exports.normalizeVolumeIndex=Mn;exports.normalizeVolumes=ol;exports.numberToChinese=sc;exports.paginationItems=zd;exports.parseChineseNumber=bi;exports.parseGujiInline=dc;exports.parseGujiTable=Tc;exports.parseSourceString=rd;exports.pct=Jo;exports.periodLevel=Wd;exports.pickReaderVersion=Vl;exports.readStoredLayout=i0;exports.readStoredTheme=t0;exports.readerVersionOptionLabel=Cr;exports.remapPlainOffsets=Oc;exports.removeRecentId=Sl;exports.renderFullTextBody=jg;exports.renderProperNames=Mc;exports.renderReaderInline=Bi;exports.resolveRecentEntry=no;exports.resourceHref=yn;exports.resourceNote=Ri;exports.resultTabFromParam=Zu;exports.resultTabToParam=Ju;exports.roleFacets=ic;exports.rowNo=eg;exports.sameFilters=Hu;exports.saveRecentId=wr;exports.segmentEntities=Wc;exports.shelfColumns=Bd;exports.sortFor=Bu;exports.sortYear=yi;exports.spineHeight=Od;exports.splitFullTextTables=jo;exports.splitHighlightSnippet=Yr;exports.splitTableRow=Cc;exports.storeLayout=r0;exports.storeTheme=jp;exports.stringifySources=od;exports.summaryFromEntry=Vc;exports.summaryFromItem=Uc;exports.timelineLayout=tp;exports.toCatalogWorkCard=_y;exports.transportSummaryLoader=Gc;exports.typeSupportsFilters=yl;exports.useBidUrl=it;exports.useChapterWarpData=Xc;exports.useConvert=Oe;exports.useEntitySummaryLoader=Ao;exports.useI18n=ne;exports.useReaderPrefs=Ul;exports.useRecentEntries=ip;exports.useT=Ee;exports.validateLineageGraph=Hb;exports.volumeStats=Si;exports.withDefaultLinks=Yt;exports.withMetaLinks=qt;exports.yearText=wi;
|
|
1913
|
+
`,Qd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function qt(e){return{...Qd,...e??{}}}function ep(e,n){if(e.lineage)return e.lineage(n);const i=e.item(n),o=i.indexOf("#"),[s,a]=o<0?[i,""]:[i.slice(0,o),i.slice(o)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function Jo(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function tp(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),i=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:i};const o=p=>{const h=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,u=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,u),Math.max(h,u)]},s=n.map(o),a=Math.min(...s.map(p=>p[0])),l=Math.max(...s.map(p=>p[1])),d=Math.max(1,l-a),c=n.map((p,h)=>({p,from:s[h][0],to:s[h][1]})).sort((p,h)=>p.from-h.from).map(p=>({...p,left:(p.from-a)/d*100,width:Math.max(.8,(p.to-p.from)/d*100)}));return{min:a,max:l,placed:c,missing:i}}function wi(e,n=vn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function Fy(e){return{read:e.item,work:e.item,node:e.node}}function np({counts:e,links:n}){const{t:i}=ne(),o=n==null?void 0:n.type;if(!o)return null;const s=[["all",i("metaHome.typeAll"),null],["work",i("metaHome.typeLabel.work"),e.works],["book",i("metaHome.typeLabel.book"),e.books],["collection",i("metaHome.typeLabel.collection"),e.collections],["entity",i("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":i("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:o(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Xe(d)})]})},a))})}function ip(e,n=5){const[i,o]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Gt().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>no(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{to(),o([])},[]);return{entries:i,clear:s}}function Hy(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):rp(e.type,n)}function rp(e,n){return n(`metaHome.typeLabel.${e}`)}function op({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ne(),a=qt(i);return t.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[t.jsxs("div",{className:"bim-mh-recent-h",children:[t.jsx("h2",{id:"bim-mh-recent-h",children:o("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:o("metaHome.recentClear")})]}),e&&e.length>0&&t.jsx("ol",{children:e.map(l=>t.jsx("li",{children:t.jsxs("a",{href:a.item(l.id),"aria-label":o("metaHome.recentItemLabel",{type:l.type?rp(l.type,o):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?o(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:Hy(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function sp(e,n,i,o=!1){return o&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):i(e)}function ap({rows:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":i("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[i("metaHome.catalogTitle"),t.jsx("small",{children:i("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:i("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:i("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:i("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=Jo(a.imported,a.total),d=a.work_id??a.collection_id,c=o(a.edition?`${a.name}·${a.edition}`:a.name);return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:d?t.jsx("a",{href:s.item(d),children:c}):c}),t.jsx("td",{className:"bim-mh-r",children:Xe(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Xe(a.imported)}),t.jsx("td",{children:t.jsxs("span",{className:"bim-mh-meter",children:[t.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[l,"%"]})]})}),t.jsx("td",{children:a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:sp(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function lp({items:e,links:n,label:i}){const{convert:o}=ne();return t.jsx("ul",{className:"bim-rh-rows","aria-label":i?o(i):void 0,children:e.map(s=>t.jsx("li",{children:t.jsxs("a",{href:n.item(s.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(s.title)}),s.sub&&t.jsx("small",{children:o(s.sub)})]})},s.id))})}function cp({works:e,links:n}){const{t:i}=ne(),[o,s]=g.useState(!1);if(!e.length)return null;const a=Wn(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":o?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[i("metaHome.relatedTitle"),t.jsx("small",{children:i("metaHome.relatedNote")})]}),t.jsx(lp,{items:e.map(l=>({id:l.id,title:l.title,sub:Hi(l)||void 0})),links:qt(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":o,onClick:()=>s(l=>!l),children:o?i("action.collapse"):i("metaHome.allNWorks",{n:e.length})})]})}const dp="siku_qige";function Dy({group:e,links:n}){const{t:i,convert:o}=ne(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Wn(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(lp,{items:e.items,links:n,label:e.label}),Wn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?i("action.collapse"):i("metaHome.allNKinds",{n:e.items.length})})]})}function pp({groups:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);if(!e.length)return null;const a=e.find(c=>c.key===dp),l=e.filter(c=>c!==a),d=c=>{var p;return((p=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:p[1])??c};return t.jsxs(t.Fragment,{children:[a&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(a.label),t.jsx("small",{children:o(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":o(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":o(c.title),title:o(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:o(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:i("metaHome.pavilion")})]})},c.id))})]}),l.length>0&&t.jsx("div",{className:"bim-mh-cg",style:a?void 0:{marginTop:0},children:l.map(c=>t.jsx(Dy,{group:c,links:s},c.key))})]})}const Ka=34,Xa=13;function Za(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?wi(e.birth_year,n):"?"}–${e.death_year!=null?wi(e.death_year,n):"?"}`}function Uy(e,n){const i=n-e,o=i>1200?300:i>400?100:50,s=[];for(let a=Math.ceil(e/o)*o;a<=n;a+=o)s.push(a);return s}function up({people:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=tp(e),p=[],h=d.map(m=>{const f=m.left>70,x=f?Math.min(m.left,m.left+m.width-Xa):m.left;let v=0;for(;p[v]!=null&&p[v]>x;)v++;return p[v]=f?m.left+m.width:m.left+Math.max(m.width,Xa),{...m,lane:v,end:f}}),u=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[h.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Ka+10},children:h.map(m=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*Ka+4,width:`${Math.max(m.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(m.p.id),children:[o(m.p.name),t.jsx("small",{className:"bim-rh-num",children:Za(m.p,i)})]})]},m.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Uy(a,l).map(m=>t.jsx("span",{style:{left:`${(m-a)/u*100}%`},children:wi(m,i)},m))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(m=>t.jsx("li",{children:t.jsxs("a",{href:s.item(m.id),children:[t.jsx("span",{children:o(m.name)}),t.jsx("small",{className:"bim-rh-num",children:[m.dynasty?o(m.dynasty):"",Za(m,i)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(m=>m.name).join("、"))})})]})}const Vy=t.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[t.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),t.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),t.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function mp({works:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Hi(a);return t.jsx("li",{children:t.jsxs("a",{href:ep(s,a.id),children:[Vy,t.jsx("b",{children:o(a.title)}),l&&t.jsx("small",{children:o(l)}),t.jsx("span",{children:i("metaHome.viewLineage")})]})},a.id)})}):null}function hp({sites:e}){const{t:n,convert:i}=ne(),o=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!o.includes(a));return e.length?t.jsxs(t.Fragment,{children:[o.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:o.map(a=>{const l=Jo(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:i(a.name)}):t.jsx("span",{children:i(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Xe(a.imported)} / ${Xe(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:sp(a.status,n,i,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:i(s.map(a=>a.name).join("、"))})})]}):null}const Ja=["extant","partially_extant","lost","unknown"];function gp({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=ne(),l=["works","books","collections","entities","has_image","has_text","article","poem"].map(p=>[e[p],a(`metaHome.stat.${p}`)]).filter(([p])=>p>0),d=n==null?void 0:n.loss,c=Ja.some(p=>{var h;return(((h=e.loss)==null?void 0:h[p])??0)>0});return t.jsxs("div",{className:"bim-mh-data",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.dataScale")}),t.jsx("ul",{className:"bim-mh-nums",children:l.map(([p,h])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Xe(p)}),t.jsx("span",{children:h})]},h))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Ja.map(p=>{var m;const h=((m=e.loss)==null?void 0:m[p])??0,u=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&h>0?a("metaHome.lossCount",{n:Xe(h),note:u}):u})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),o?t.jsx("a",{href:o,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),i&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:i})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const fp={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Gy({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:h}){var k,C;const{t:u}=ne(),m=e,f=qt(n),x=Fy(f),v=fp,y=ip(o),$={zhi:!!((k=m.shelf)!=null&&k.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(v).filter(S=>$[S]),w=S=>u(`metaHome.nav.${S}`),j=(S,_)=>S?t.jsx("a",{className:"bim-rh-more",href:S,children:_}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:qo+Jd}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(np,{counts:m.counts,links:n})]}),o&&t.jsx(op,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":u("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(S=>t.jsx("li",{children:t.jsx("a",{href:`#${v[S]}`,children:w(S)})},S))})}),t.jsxs("div",{className:"bim-rh-main",children:[$.zhi&&t.jsxs(ut,{id:v.zhi,title:w("zhi"),sub:u("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&t.jsx(Xo,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:x,showTitle:!1,legendCount:m.shelf.items.some(S=>S.records)?u("metaHome.shelfLegendCount"):null,legendExtra:[u("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(C=m.shelf)!=null&&C.items.length?void 0:{marginTop:0},children:[t.jsx(ap,{rows:m.catalog_progress,links:n}),t.jsx(cp,{works:m.related_catalogs,links:n})]})]}),$.sibu&&t.jsx(ut,{id:v.sibu,title:w("sibu"),sub:u("metaHome.sibuSub"),more:j(s,u("metaHome.toCatalog")),children:t.jsx(Zo,{bu:m.bu,unclassified:m.unclassified,links:x,unclassifiedNote:u("metaHome.unclassifiedNote")})}),$.cong&&t.jsx(ut,{id:v.cong,title:w("cong"),sub:u("metaHome.congSub"),more:j(a,u("metaHome.allNKindsMore",{n:Xe(m.counts.collections)})),children:t.jsx(pp,{groups:m.collection_groups,links:n})}),$.people&&t.jsx(ut,{id:v.people,title:w("people"),sub:u("metaHome.peopleSub"),more:j(l,u("metaHome.allNPeopleMore",{n:Xe(m.counts.entities)})),children:t.jsx(up,{people:m.bibliographers,links:n})}),$.lineage&&t.jsx(ut,{id:v.lineage,title:w("lineage"),sub:u("metaHome.lineageSub"),children:t.jsx(mp,{works:m.lineage,links:n})}),$.sites&&t.jsx(ut,{id:v.sites,title:w("sites"),sub:u("metaHome.sitesSub"),children:t.jsx(hp,{sites:m.sites})}),t.jsx(ut,{id:v.data,title:w("data"),sub:u("metaHome.dataSub"),children:t.jsx(gp,{stats:m.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const xp=["_related","_catalogs","_collections","_members","_children"],Yy=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ur=e=>Yy(e)&&!!e.h;function qy(e){return e?xp.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(Ur)}):!1}function Ky(e,n){const i={...e};if(!n)return i;for(const o of xp){const s=e[o];!Array.isArray(s)||!s.some(Ur)||(i[o]=s.map(a=>{var c;if(!Ur(a)||typeof a.title=="string"&&a.title)return a;const l=a.id??a.bid,d=l?(c=n[l])==null?void 0:c.title:void 0;return d?{...a,title:d}:a}))}return i}function Xy(e){let n=null;const i=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null);return new Proxy(e,{get(o,s){if(s==="getItem")return async l=>{const d=await o.getItem(l);return d&&Ky(d,qy(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const Vr=({style:e})=>{const n=g.useContext(Nt),{t:i}=ne();if(!n)return null;const{locale:o,setLocale:s}=n,a=o==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:i(a?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${r("border")}`,borderRadius:"4px",background:r("bg"),color:r("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?r("primary"):void 0,fontWeight:a?700:400},children:i("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:r("primary"),fontWeight:a?400:700},children:i("common.localeShortHans")})]})},Gr=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=ne(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:o,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i+8,height:i+8,borderRadius:4,color:r("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=r("fg")},onMouseLeave:d=>{d.currentTarget.style.color=r("desc-fg")},children:t.jsx("svg",{width:i,height:i,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})})};function jr(e){const n=e.text_count;return typeof n=="number"&&n>0}function vr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function Zy(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const Jy=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:u,initialPage:m=1,selectedLineageNodeId:f,onNavigate:x,onBack:v,backLabel:y,renderLink:$,enrichDetail:b,getSourceLink:w,readLink:j,railTop:k,extraTabs:C=[],showFeedbackTab:S=!0,feedbackApiUrl:_,height:L,footerExtra:z,hideHeaderControls:T=!1,className:B,style:W})=>{const N=g.useMemo(()=>Xy(n),[n]),R=Ee(),{t:H,convert:q}=ne(),[te]=g.useState(()=>{if(!Zy(e,i))return null;const Q={...i},ye=o??vr(e,Q);return b&&b(ye,Q),{id:e,entry:ye,detail:Q}}),[ae,V]=g.useState((te==null?void 0:te.entry)??null),[G,me]=g.useState((te==null?void 0:te.detail)??null),[K,le]=g.useState(!te),[Se,A]=g.useState(!1),[je,ce]=g.useState([]),[ze,$e]=g.useState(!1),[Fe,ee]=g.useState(null),[F,U]=g.useState(null),[he,X]=g.useState(null),[O,J]=g.useState(!1),oe=g.useRef(null),re=g.useRef(0),[D,se]=g.useState(null),_e=l!==void 0?l:D,Ae=g.useCallback(Q=>{d?d(Q):se(Q)},[d]),M=g.useCallback(async Q=>{if(!N.getCollectionCatalogs&&!N.getCollectionCatalog){ce([]);return}$e(!0);try{if(N.getCollectionCatalogs)ce(await N.getCollectionCatalogs(Q)||[]);else if(N.getCollectionCatalog){const ye=await N.getCollectionCatalog(Q);ce(ye?[{resource_id:"",data:ye}]:[])}}catch{ce([])}finally{$e(!1)}},[N]),ie=g.useCallback(async Q=>{var ye,We;if(!N.getTextManifest||!N.getTextIndex){ee(null),U(Q);return}try{const He=ke.pickTextVersion(await N.getTextManifest(Q)),Ne=He?await N.getTextIndex(Q,He.key):null;ee(Ne&&Ne.chapters.length>0?{chapters:Ne.chapters.map(Pe=>({n:Pe.n,title:Pe.title,file:Pe.file})),source:{name:((ye=Ne.source)==null?void 0:ye.name)??(He==null?void 0:He.source_name),license:((We=Ne.source)==null?void 0:We.license)??(He==null?void 0:He.license)??void 0}}:null)}catch{ee(null)}finally{U(Q)}},[N]),ve=g.useCallback(async(Q,ye)=>{const We=++re.current,He=()=>We!==re.current;J(!0);try{if(N.getLineageGraph){const Qe=await N.getLineageGraph(Q);if(He())return;Qe&&X(Qe)}const Ne=ye.version_graph;if(!Ne||!Ne.enabled){he||X(null),oe.current=null;return}const Pe=mo(ye),Be=(await Wi(Pe,Oi,async Qe=>{try{return await N.getItem(Qe)}catch{return null}},He)).filter(Boolean);if(He())return;oe.current={work:ye,books:Be};const Ie=h??Ne.default_collection??(Ne.core_books&&Ne.core_books.length>0?"core":"all"),De=Ie==="core"&&Array.isArray(Ne.core_books)&&Ne.core_books.length>0?"core":Ie??"all";X(fi(ye,Be,De))}catch{if(He())return;X(null),oe.current=null}finally{He()||J(!1)}},[N]),we=g.useRef({initialDetail:i,initialEntry:o});we.current={initialDetail:i,initialEntry:o},g.useEffect(()=>{let Q=!1;re.current++,J(!1);const ye=Pe=>{Pe.type==="collection"?M(e):Pe.type==="work"?(Pe.version_graph||N.getLineageGraph)&&ve(e,Pe):Pe.type==="book"&&jr(Pe)&&ie(e)},We=we.current;let He=null;if(te&&te.id===e)He=te;else if(We.initialDetail&&We.initialDetail.id===e){const Pe={...We.initialDetail},Le=We.initialEntry??vr(e,Pe);b&&b(Le,Pe),He={entry:Le,detail:Pe}}return He?(A(!1),ce(Pe=>Pe.length?[]:Pe),ee(null),X(null),oe.current=null,V(He.entry),me(He.detail),le(!1),ye(He.detail),()=>{Q=!0}):((async()=>{le(!0),A(!1),V(null),me(null),ce([]),ee(null),X(null),oe.current=null;try{const Pe=await N.getItem(e);if(Q)return;if(!Pe){A(!0);return}const Le=Pe;let Be=null;if(N.getEntry&&(Be=await N.getEntry(e),Q))return;Be||(Be=vr(e,Le)),b&&b(Be,Le),V(Be),me(Le),ye(Le)}catch{Q||A(!0)}finally{Q||le(!1)}})(),()=>{Q=!0})},[e,N,te,b,M,ve,ie]),g.useEffect(()=>{const Q=oe.current;!Q||!h||X(fi(Q.work,Q.books,h))},[h]);const P=[];if(G){if(P.push({key:"basic",label:R.detailTab.basicInfo}),G.type==="collection"){ze&&je.length===0&&P.push({key:"catalog:loading",label:`${R.detailTab.catalog}…`});for(const Q of je)P.push({key:`catalog:${Q.resource_id}`,label:Q.short_name?`${q(Q.short_name)}${R.detailTab.catalogSuffix}`:R.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&P.push({key:s,label:R.detailTab.fullText}),G.type==="work"&&(he||O)&&P.push({key:"lineage",label:O?`${R.detailTab.lineage}…`:R.detailTab.lineage});for(const Q of C)(Q.position??"before-feedback")==="before-feedback"&&Q.shouldShow(G)&&P.push({key:Q.key,label:Q.label});S&&s==="feedback"&&P.push({key:"feedback",label:R.detailTab.feedback});for(const Q of C)Q.position==="after-feedback"&&Q.shouldShow(G)&&P.push({key:Q.key,label:Q.label})}g.useEffect(()=>{if(s!=="emendated"||!G)return;a("basic");const Q=setTimeout(()=>{var ye;(ye=document.getElementById("studies"))==null||ye.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Q)},[s,G,a]);const fe=ae&&G&&w?w({activeTab:s,activeJuan:_e,entry:ae,detail:G}):null,de=g.useMemo(()=>{var Ne,Pe,Le,Be,Ie;if(!G)return null;const ye=(G.authors??[]).map(De=>{const Qe=uo(De.role);return`${De.dynasty?`〔${q(De.dynasty)}〕`:""}${q(De.name)}${Qe?` ${q(Qe)}`:""}`}).join(" · ");let We=!1;try{We=ke.extractStatus(G.id)==="draft"}catch{}if(G.type==="book"){const De=G;return{title:q(De.title),subtitle:De.edition?q(De.edition):ye||void 0,aside:[We?R.status.draft:"",ye&&De.edition?ye:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(G.type==="collection"){const De=G;return{title:q(De.title),subtitle:q(Wt(De,R.unit.juan))||void 0,aside:[(Ne=De.publication_info)==null?void 0:Ne.year,We?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ye||void 0}}if(G.type==="entity"){const De=G,Qe=yt=>yt==null?"":yt<0?H("detail.bce",{n:-yt}):String(yt),Ft=((Pe=De.dates)==null?void 0:Pe.birth)!=null||((Le=De.dates)==null?void 0:Le.death)!=null?`${Qe(((Be=De.dates)==null?void 0:Be.birth)??void 0)||"?"}—${Qe(((Ie=De.dates)==null?void 0:Ie.death)??void 0)||"?"}`:"";return{title:q(De.primary_name||De.title),subtitle:[De.dynasty?`〔${q(De.dynasty)}〕`:"",Ft].filter(Boolean).join(" ")||void 0,aside:We?R.status.draft:void 0,secondLine:void 0}}const He=q(Wt(G,R.unit.juan));return{title:q(G.title),subtitle:[He,ye].filter(Boolean).join(" · ")||void 0,aside:[e0(R,G.subtype),We?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[G,q,R,H]),xe=G&&jr(G)?"text":null,Ce=()=>{Ae(null),a("fulltext")};let Ue=null;if(G&&j){const Q=j({detail:G,kind:xe});Q&&(Ue=t.jsx(Ir,{href:Q}))}else xe&&(Ue=t.jsx(Ir,{onClick:Ce}));const Ke=Q=>{if(!G)return null;const ye=Q.replace(/\.[^.]+$/,"");if(j){const We=j({detail:G,kind:xe,juan:ye});return We?{href:We}:null}return{onClick:()=>{Ae(ye),a("fulltext")}}},Je=new Set(C.map(Q=>Q.key)),qe=P.filter(Q=>Q.key.startsWith("catalog:")&&Q.key!=="catalog:loading"||Q.key==="lineage"&&!!he&&!O||Je.has(Q.key)).map(Q=>({key:Q.key,label:Q.label,onClick:()=>a(Q.key)})),I=()=>{var Q;return G?G.type==="work"?t.jsx(vd,{data:G,transport:N,onNavigate:x,renderLink:$,readAction:Ue,railTop:k,railLinks:qe}):G.type==="book"?t.jsx(_d,{data:G,transport:N,onNavigate:x,renderLink:$,readAction:Ue,fullText:Fe,fullTextPending:jr(G)&&!!N.getTextManifest&&F!==G.id,chapterLink:Ke,railTop:k,railLinks:qe}):G.type==="collection"?t.jsx($d,{data:G,catalog:(Q=je[0])==null?void 0:Q.data,transport:N,onNavigate:x,renderLink:$,readAction:Ue,railTop:k,railLinks:qe,catalogAction:je.length>0?t.jsxs("a",{href:"#catalog",onClick:ye=>{ye.preventDefault(),a(`catalog:${je[0].resource_id}`)},children:[q(R.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Cd,{data:G,transport:N,onNavigate:x,renderLink:$,railTop:k,railLinks:qe}):null},Y=()=>{var ye,We,He;if(!ae||!G)return null;if(s==="basic"||s==="emendated")return I();if(typeof s=="string"&&s.startsWith("catalog:")){const Ne=(ye=je.find(Pe=>`catalog:${Pe.resource_id}`===s))==null?void 0:ye.data;return t.jsx(ro,{data:Ne,onNavigate:x,renderLink:$})}if(s==="collated"||s==="fulltext")return t.jsx(Oo,{id:e,transport:N,chapter:_e,onLocationChange:Ne=>Ae(Ne.chapter),onNavigate:x});if(s==="lineage"){if(!he)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:H(O?"detail.loading":"detail.noLineageGraph")});const Ne=G.type==="work"?G:null;return t.jsx(Uo,{graph:he,renderLink:$,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:h??((We=Ne==null?void 0:Ne.version_graph)==null?void 0:We.default_collection),onCollectionChange:u,collectionsAvailable:(He=Ne==null?void 0:Ne.version_graph)==null?void 0:He.collections,collectionCounts:(()=>{var Ie,De,Qe,Ft,yt,Kt,Ye;if(!Ne)return;const Pe={},Le=((Ie=oe.current)==null?void 0:Ie.books)??[];Pe.all=(((De=Ne._books)==null?void 0:De.length)??0)-(((Ft=(Qe=Ne.version_graph)==null?void 0:Qe.excluded_books)==null?void 0:Ft.length)??0);const Be=(yt=Ne.version_graph)==null?void 0:yt.collections;if(Be)for(const Z of Object.keys(Be))Pe[Z]=fi(Ne,Le,Z).nodes.filter(Ve=>Ve.kind==="book"&&!Ve.bridge).length;return Pe.core==null&&((Ye=(Kt=Ne.version_graph)==null?void 0:Kt.core_books)!=null&&Ye.length)&&(Pe.core=Ne.version_graph.core_books.length),Pe})()})}if(s==="feedback"&&S)return t.jsx(xd,{resourceId:e,apiUrl:_});const Q=C.find(Ne=>Ne.key===s);return Q?Q.render({detail:G,entry:ae,transport:N,onNavigate:x}):null};if(K)return t.jsx(Rn,{style:{minHeight:L,...W},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Q,ye)=>t.jsx("div",{style:{height:ye===1?40:16,width:Q,opacity:.35,background:r("rule")}},ye))})});if(Se||!G||!ae||!de)return t.jsx(Rn,{style:{minHeight:L,...W},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:H("detail.notFound")})});const pe=s==="basic"||s==="emendated",be=[{label:y??R.detailTab.backToIndex,onClick:v}];if(G.type==="book"&&G.work_id){const Q=G.work_id;be.push({label:R.indexType.work,id:Q,onClick:()=>x==null?void 0:x(Q)})}be.push({label:R.indexType[G.type]});const Re=s==="collated"||s==="fulltext",ge=typeof z=="string"?R.status[z.trim()]??z:z,Me=t.jsx(_c,{left:t.jsxs(t.Fragment,{children:[ge,ge?" · ":"",t.jsx(Qy,{id:G.id,label:R.label.id,copied:R.action.copied,copyLabel:R.action.copy})]}),right:t.jsxs(t.Fragment,{children:[S&&!pe&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:R.detailTab.submitVersion}),fe&&t.jsx("a",{href:fe.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:R.detailTab.dataLicense})]})});return pe?t.jsx("div",{className:B,children:t.jsxs(Rn,{grid:!0,style:{minHeight:L,...W},children:[t.jsx(Er,{breadcrumb:t.jsx(Rr,{items:be}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Vr,{style:{border:"none",background:"transparent"}}),!T&&fe&&t.jsx(Gr,{...fe})]})}),I(),Me]})}):t.jsx("div",{className:B,children:t.jsxs(Rn,{wide:Re,style:{minHeight:L,...W},children:[t.jsx(Er,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(bo,{char:"籍"}),t.jsx(Rr,{items:be})]}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Vr,{}),S&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:R.detailTab.feedback}),!T&&fe&&t.jsx(Gr,{...fe})]})}),t.jsx(fc,{...de,aside:Re?t.jsxs("button",{type:"button",onClick:()=>a("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("accent"),borderBottom:`1px solid ${r("rule")}`},children:[H("detail.workInfo")," →"]}):de.aside}),!Re&&P.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:P.map(Q=>t.jsx(xc,{label:Q.label,active:Q.key===s||pe&&Q.key==="basic",onClick:()=>a(Q.key)},Q.key))}),t.jsx("div",{style:{marginTop:!Re&&P.length>1?8:0},children:Y()}),Me]})})};function Qy({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?i:o,"aria-label":s?i:o,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:r("aux-fg")},children:s?"✓":"⧉"})]})}function e0(e,n){return n?e.workSubtype[n]??n:""}const bp=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Di="zhusha",Ui="bim-theme";function yp(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Vi(e){return yp(e)?e:Di}function t0(){try{return Vi(window.localStorage.getItem(Ui))}catch{return Di}}function jp(e){try{window.localStorage.setItem(Ui,e)}catch{}}function vp(e){const n=Vi(e);return document.documentElement.setAttribute("data-theme",n),n}function kp(){return Vi(document.documentElement.getAttribute("data-theme"))}const n0=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Qo="airy",Gi="bim-layout";function wp(e){return e==="airy"||e==="boxed"}function Yi(e){return wp(e)?e:Qo}function i0(){try{return Yi(window.localStorage.getItem(Gi))}catch{return Qo}}function r0(e){try{window.localStorage.setItem(Gi,e)}catch{}}function o0(e){const n=Yi(e);return document.documentElement.setAttribute("data-layout",n),n}function s0(){return Yi(document.documentElement.getAttribute("data-layout"))}const a0=`try{var t=localStorage.getItem(${JSON.stringify(Ui)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Gi)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,l0={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},c0=({onChange:e,style:n})=>{const{t:i}=ne(),[o,s]=g.useState(Di);g.useEffect(()=>{s(kp())},[]);const a=l=>{s(vp(l)),jp(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:bp.map(l=>{const d=o===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":i(`common.theme.${l.name}`),title:i(`common.theme.${l.name}`),onClick:()=>a(l.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:r(l0[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=ke.BidLink;exports.BookIndexError=ke.BookIndexError;exports.BookIndexManager=ke.BookIndexManager;exports.BookIndexStorage=ke.BookIndexStorage;exports.BundleStorage=ke.BundleStorage;exports.ConfigError=ke.ConfigError;exports.GithubStorage=ke.GithubStorage;exports.IdGenerationError=ke.IdGenerationError;exports.IdGenerator=ke.IdGenerator;exports.LocalStorage=ke.LocalStorage;exports.MigrationError=ke.MigrationError;exports.StorageError=ke.StorageError;exports.VARIANT_CHARS=ke.VARIANT_CHARS;exports.base36Decode=ke.base36Decode;exports.base36Encode=ke.base36Encode;exports.base58Decode=ke.base58Decode;exports.buildId=ke.buildId;exports.buildPromotionMap=ke.buildPromotionMap;exports.cleanName=ke.cleanName;exports.decodeId=ke.decodeId;exports.decodeIdString=ke.decodeIdString;exports.encodeId=ke.encodeId;exports.extractIdFromUrl=ke.extractIdFromUrl;exports.extractStatus=ke.extractStatus;exports.extractType=ke.extractType;exports.isChapterSegment=ke.isChapterSegment;exports.isTextKey=ke.isTextKey;exports.matchChapterAcrossVersions=ke.matchChapterAcrossVersions;exports.normalizeCatalog=ke.normalizeCatalog;exports.normalizeVariants=ke.normalizeVariants;exports.parseId=ke.parseId;exports.pickTextVersion=ke.pickTextVersion;exports.shardOf=ke.shardOf;exports.smartDecode=ke.smartDecode;exports.textVersionLabel=ke.textVersionLabel;exports.validateResource=ke.validateResource;exports.VARIANT_SUPPLEMENT=Qa.VARIANT_SUPPLEMENT;exports.Badge=ki;exports.BidUrlProvider=qp;exports.BookDetailLayout=Jy;exports.BookPage=_d;exports.Breadcrumb=Rr;exports.CATALOG_ALL_ID=Mt;exports.CATALOG_CSS=Td;exports.CATALOG_NARROW_QUERY=Vo;exports.CATALOG_PAGE_SIZE=Go;exports.CATALOG_UNCLASSIFIED_ID=nn;exports.CLASSIFICATIONS=zi;exports.COMMON_TRADITIONAL_CHARS=dl;exports.CardFoot=Un;exports.CatalogPage=Ey;exports.CatalogPager=Ad;exports.CatalogTree=Nd;exports.CheckFilter=mc;exports.Chip=bc;exports.ChipWall=Kh;exports.CollectionCatalog=ro;exports.CollectionPage=$d;exports.CreateEntityDialog=cd;exports.DEFAULT_LAYOUT=Qo;exports.DEFAULT_META_HOME_LINKS=Qd;exports.DEFAULT_READER_PREFS=so;exports.DEFAULT_READ_HOME_LINKS=Pd;exports.DEFAULT_THEME=Di;exports.DETAIL_CSS=gc;exports.DYNASTY_GROUPS=Ti;exports.Dash=tg;exports.DataTable=Zh;exports.DetailFooter=_c;exports.DetailGrid=Hn;exports.DetailHeader=fc;exports.EMPTY_FILTERS=Ci;exports.ENTITY_TEXT_CSS=Lo;exports.EmendatedBySection=El;exports.EmptyNote=lg;exports.EntityDetail=$l;exports.EntityMark=Mo;exports.EntityPage=Cd;exports.EntityPickerDialog=pd;exports.EntitySelector=ld;exports.EntityText=Cf;exports.ExpandRow=ng;exports.ExtLink=cg;exports.FEEDBACK_FAB_OFFSET_VAR=Fr;exports.FILTER_SUPPORT=xl;exports.FONT_SIZE_STEPS=At;exports.FactList=Vh;exports.FeedbackButton=yb;exports.FeedbackDialog=gd;exports.FeedbackForm=fd;exports.FeedbackList=Wo;exports.FeedbackTab=xd;exports.FilterChip=xc;exports.FormInput=ft;exports.FormTextArea=on;exports.GUJI_MARKDOWN_FIELD=Nh;exports.GUJI_TABLE_NOTATION=$c;exports.GlyphBadge=bo;exports.GujiInteractiveReader=hx;exports.GujiTable=vo;exports.GujiTextViewer=Po;exports.GujiWarpCanvas=Ro;exports.HomePage=Or;exports.ImagePanel=_r;exports.IndexApp=mx;exports.IndexBrowser=Sr;exports.IndexDetail=io;exports.IndexEditor=ud;exports.IndexView=ob;exports.IntroGrid=Uh;exports.LAYOUTS=n0;exports.LAYOUT_STORAGE_KEY=Gi;exports.LOSS_OPTIONS=fl;exports.LocaleContext=Nt;exports.LocaleProvider=ku;exports.LocaleToggle=Vr;exports.META_HOME_CSS=Jd;exports.META_HOME_SECTION_IDS=fp;exports.MetaCatalogTable=ap;exports.MetaCollectionGroups=pp;exports.MetaDataLicense=gp;exports.MetaHomeView=Gy;exports.MetaLine=ot;exports.MetaLineageCards=mp;exports.MetaOnlineSites=hp;exports.MetaPeopleTimeline=up;exports.MetaRecentPanel=op;exports.MetaRelatedCatalogs=cp;exports.MetaTypeChips=np;exports.ModeIndicator=ul;exports.MoreButton=qh;exports.MoreLink=fo;exports.PAGE_MAX_WIDTH=mi;exports.PERIOD_NARROW_SHARE=Fd;exports.PageFrame=Rn;exports.Quote=rg;exports.READER_CSS=Ol;exports.READ_HOME_CSS=qo;exports.READ_HOME_NARROW_QUERY=Yn;exports.READ_HOME_SECTION_IDS=Zd;exports.READ_PERIOD_LABELS=My;exports.RECENT_IDS_STORAGE_KEY=hn;exports.ROLE_CLASS_ORDER=nc;exports.ReadButton=Ir;exports.ReadFamousWorks=qd;exports.ReadHomeView=By;exports.ReadPeriodBand=Kd;exports.ReadPicks=Ud;exports.ReadPieces=Xd;exports.ReadSection=ut;exports.ReadShelf=Xo;exports.ReadSibu=Zo;exports.ReadStats=Dd;exports.ReadTopicGroup=Gd;exports.ReadTopics=Yd;exports.ReaderMdText=_o;exports.ReaderShell=Yl;exports.ReaderToc=Fl;exports.RelationPanel=sd;exports.RepoSourceLink=Gr;exports.ResourceEditor=kr;exports.ResourceGroup=og;exports.ResourceLine=sg;exports.ResourceList=Qr;exports.ResourceRow=wc;exports.SEARCH_VIEW_STORAGE_KEY=eo;exports.SEVEN_PAVILIONS_KEY=dp;exports.SNIPPET_MARK_END=nl;exports.SNIPPET_MARK_START=tl;exports.SORTABLE_TYPES=gl;exports.SearchInput=hl;exports.SearchResults=wl;exports.Sec=at;exports.Section=wt;exports.SectionHead=Gh;exports.SideList=rn;exports.SmartBidInput=gi;exports.SourceEditor=id;exports.StripWarpRenderer=Mr;exports.SummaryCard=Dn;exports.THEMES=bp;exports.THEME_INIT_SCRIPT=a0;exports.THEME_STORAGE_KEY=Ui;exports.TRADITIONAL_ALLOWLIST=pl;exports.TabFilter=Ai;exports.TableHead=Jh;exports.TableRow=Qh;exports.TagRow=Sc;exports.TagRows=ag;exports.TextButton=Yh;exports.TextReader=Oo;exports.ThemeToggle=c0;exports.TopStrip=Er;exports.VersionLineageGraph=Sd;exports.VersionLineageList=wd;exports.VersionLineageView=Uo;exports.VolumeChips=Xh;exports.VolumeLinks=yo;exports.WorkCard=Rd;exports.WorkCardGrid=Md;exports.WorkCatalog=Sx;exports.WorkPage=vd;exports.WorkRow=Ld;exports.adaptCharCord=wx;exports.adaptEntityJson=Bc;exports.adaptNorm=nd;exports.adaptNormDetailed=td;exports.adaptPunctJson=fx;exports.applyLayout=o0;exports.applyTheme=vp;exports.authorsLine=Hi;exports.bookIndexUriToId=Ar;exports.bookMarkingOf=So;exports.bucketResources=co;exports.buildCatalogTree=wy;exports.buildCollectionTable=oc;exports.buildLineageGraph=fi;exports.buildMeiliFilter=Wu;exports.buildPageUrl=Zr;exports.buildParagraphBlocks=Rc;exports.buildVersionRow=ec;exports.buildVersionTable=tc;exports.canParagraphize=ji;exports.catalogNodeIdOf=vy;exports.catalogNodeIdsOf=ky;exports.catalogPageCount=Cy;exports.catalogTotal=Yo;exports.classificationPath=Gn;exports.clearAllRecentIds=to;exports.compareCatalogCards=$y;exports.computeVersionPartition=wh;exports.countActiveFilters=Ni;exports.createTextApi=Ll;exports.currentLayout=s0;exports.currentTheme=kp;exports.defaultEntityHref=Yc;exports.defaultWorkLink=Id;exports.deriveDating=jh;exports.deriveEditionType=ac;exports.deriveEra=Fn;exports.deriveYear=Ei;exports.deriveYearRange=lo;exports.detailToEditor=hd;exports.detectGenre=Pi;exports.displayAuthorRole=uo;exports.editorToDetail=rb;exports.eraRank=zr;exports.filtersFromParams=Fu;exports.filtersToParams=xi;exports.findCatalogPath=mn;exports.findTraditionalChars=_u;exports.firstAuthorText=Ko;exports.flattenTitles=Lr;exports.flattenToc=Gl;exports.fmtCount=Xe;exports.formatHitCount=pi;exports.formatTemplate=xt;exports.formatVolumeRange=Li;exports.getDisplayNameFromUrl=bn;exports.getMessages=jn;exports.getStartPage=Xr;exports.getT=vn;exports.getTypeGroupKey=qr;exports.groupRelatedWorks=vh;exports.gujiInlineToPlain=pc;exports.hasActiveFilters=bl;exports.hasGujiMarkdownV02=Ih;exports.hasGujiTableNotation=dg;exports.hasSearchOptions=Pu;exports.iiifVolumeOf=xx;exports.isCountedChar=$o;exports.isLayoutName=wp;exports.isThemeName=yp;exports.lineageHref=ep;exports.loadRecentIds=Gt;exports.measureText=Wt;exports.mergeVolumeResources=Kr;exports.normalizeEra=rt;exports.normalizeLayout=Yi;exports.normalizeRole=po;exports.normalizeTheme=Vi;exports.normalizeVolumeIndex=Mn;exports.normalizeVolumes=ol;exports.numberToChinese=sc;exports.paginationItems=zd;exports.parseChineseNumber=bi;exports.parseGujiInline=dc;exports.parseGujiTable=Tc;exports.parseSourceString=rd;exports.pct=Jo;exports.periodLevel=Wd;exports.pickReaderVersion=Vl;exports.readStoredLayout=i0;exports.readStoredTheme=t0;exports.readerVersionOptionLabel=Cr;exports.remapPlainOffsets=Oc;exports.removeRecentId=Sl;exports.renderFullTextBody=jg;exports.renderProperNames=Mc;exports.renderReaderInline=Bi;exports.resolveRecentEntry=no;exports.resourceHref=yn;exports.resourceNote=Ri;exports.resultTabFromParam=Zu;exports.resultTabToParam=Ju;exports.roleFacets=ic;exports.rowNo=eg;exports.sameFilters=Hu;exports.saveRecentId=wr;exports.segmentEntities=Wc;exports.shelfColumns=Bd;exports.sortFor=Bu;exports.sortYear=yi;exports.spineHeight=Od;exports.splitFullTextTables=jo;exports.splitHighlightSnippet=Yr;exports.splitTableRow=Cc;exports.storeLayout=r0;exports.storeTheme=jp;exports.stringifySources=od;exports.summaryFromEntry=Vc;exports.summaryFromItem=Uc;exports.timelineLayout=tp;exports.toCatalogWorkCard=_y;exports.transportSummaryLoader=Gc;exports.typeSupportsFilters=yl;exports.useBidUrl=it;exports.useChapterWarpData=Xc;exports.useConvert=Oe;exports.useEntitySummaryLoader=Ao;exports.useI18n=ne;exports.useReaderPrefs=Ul;exports.useRecentEntries=ip;exports.useT=Ee;exports.validateLineageGraph=Hb;exports.volumeStats=Si;exports.withDefaultLinks=Yt;exports.withMetaLinks=qt;exports.yearText=wi;
|