book-index-ui 0.59.0 → 0.60.1

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var au=Object.create;var Es=Object.defineProperty;var lu=Object.getOwnPropertyDescriptor;var cu=Object.getOwnPropertyNames;var du=Object.getPrototypeOf,pu=Object.prototype.hasOwnProperty;var uu=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of cu(n))!pu.call(e,s)&&s!==i&&Es(e,s,{get:()=>n[s],enumerable:!(o=lu(n,s))||o.enumerable});return e};var di=(e,n,i)=>(i=e!=null?au(du(e)):{},uu(n||!e||!e.__esModule?Es(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _e=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),g=require("react"),mu=require("opencc-js/t2cn"),fl=require("./variant-supplement.cjs"),hu=require("react-markdown"),gu=require("remark-gfm"),fu=e=>`/item/${e}`,xl=g.createContext(fu);function xu({buildUrl:e,children:n}){const i=g.useMemo(()=>e,[e]);return t.jsx(xl.Provider,{value:i,children:n})}function rt(){return g.useContext(xl)}const bl="",yl="";function no(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?yl:bl,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 pt(e,n){return{title:e,tokens:n}}const Rs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',bu=[pt("基础(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"}}),pt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),pt("提示与警告",{"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)"}}),pt("遮罩与阴影",{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)"}}),pt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),pt("资源",{"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"}}),pt("整理本(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:"中性灰:占位"}}),pt("版本传承(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"}}),pt("编辑器视图(主要在 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")'}}),pt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),pt('版式(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"}}),pt("阅读器(整理本 / 全文)",{"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:"版心外边线"}}),pt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),pt("字体(全站无衬线,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:Rs,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Rs,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],yu=Object.assign({},...bu.map(e=>e.tokens)),jl={};for(const[e,n]of Object.entries(yu))jl[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=jl[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Ft(e){return e.types&&e.types.length>0?e.types:[]}function ju(e,n){return Ft(e).includes(n)}const vu={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 ku={"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 jn(e){try{return ku[new URL(e).hostname]}catch{return}}const Ls={text:0,image:1,physical:2};function io(e){return e.length===0?"physical":[...e].sort((n,i)=>(Ls[n]??99)-(Ls[i]??99)).join("+")}function wu(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function ro(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,m]=p,u=`${h}|${io(Ft(c))}`;i.has(u)||i.set(u,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const f=i.get(u);f.volumes.push({volume:m,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 vl(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 kl(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||vl(n)}))}function Ti(e){const n=kl(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 oo(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 so(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 vn(e){if(!e.url)return;const n=oo(e.metadata);return n?so(e.url,n):e.url}const Et=g.createContext(null),wl=["曹霑"];function Su(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _u(e,n=wl){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(Su).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 Tn=null;function Sl(){if(Tn)return Tn;try{const e=mu.Converter({from:"t",to:"cn"});Tn=_u(n=>e(_e.normalizeVariants(n)))}catch{Tn=e=>e}return Tn}const $u={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:"圖片資源"}},Cu={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 ht(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const zu=ht({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:"无数据"}),Ii=ht({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:"作品信息"}),Nu=ht({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:"附记"}}),Tu=ht({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:"種版本",sameEditionCopies:"同版另藏 {n} 部:",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:"种版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),Iu=ht({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:"上级丛编"}),Eu=ht({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 為自動匹配,未經人工核對",sealAlt:"{name}印影",imgCredit:"圖像:{credit}",imgLicense:"授權:{license}",imgSource:"來源"},{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 为自动匹配,未经人工核对",sealAlt:"{name}印影",imgCredit:"图像:{credit}",imgLicense:"授权:{license}",imgSource:"来源"}),Ru=ht({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}",tocExpand:"展開",tocCollapse:"收起",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}",tocExpand:"展开",tocCollapse:"收起",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),Lu=ht({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:"本卷条目"}),Au=ht({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:"规模、存佚、许可与版本"}),ao=ht({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=ht({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} 条"}),Pu=ht({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:"搜索"}),Bu=ht({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:"回复"}),Ou=ht({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:"有争议"}}),Wu={common:zu,detail:Ii,bookPage:Nu,workPage:Tu,collectionPage:Iu,entityPage:Eu,reader:Ru,collated:Lu,metaHome:Au,readHome:ao,catalogPage:Mu,searchPage:Pu,feedback:Bu,lineage:Ou};function Fu(e){const n={};for(const[i,o]of Object.entries(Wu))n[i]=o[e];return n}function bt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const As=new Map;function kn(e){let n=As.get(e);return n||(n={...e==="zh-Hans"?Cu:$u,...Fu(e)},As.set(e,n)),n}function Ms(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 _l(e){return(n,i)=>{const o=Ms(e,n)??Ms(kn("zh-Hant"),n)??n;return i?bt(o,i):o}}const Ps=new Map;function wn(e){let n=Ps.get(e);return n||(n=_l(kn(e)),Ps.set(e,n)),n}const $l="bim-locale";function Hu(){try{const e=localStorage.getItem($l);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Du(e){try{localStorage.setItem($l,e)}catch{}}const Uu="zh-Hans",Vu=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=g.useState(e??Uu),l=e??s;g.useEffect(()=>{if(e)return;const h=Hu();h&&h!==s&&a(h)},[]);const d=g.useMemo(()=>l==="zh-Hans"?i??Sl():null,[l,i]),c=g.useCallback(h=>{a(h),Du(h),n==null||n(h)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:kn(l),converter:d}),[l,c,d]);return t.jsx(Et.Provider,{value:p,children:o})};function Ee(){const e=g.useContext(Et);return(e==null?void 0:e.messages)??kn("zh-Hant")}const Gu=2e3;function Me(){const e=g.useContext(Et),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>=Gu){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 ie(){const e=g.useContext(Et),{convert:n,locale:i,isSimplified:o}=Me(),s=(e==null?void 0:e.messages)??kn("zh-Hant"),a=g.useMemo(()=>e?_l(s):wn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const Cl=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Yu=new Set([...Cl,...Object.keys(_e.VARIANT_CHARS),...Object.keys(fl.VARIANT_SUPPLEMENT)]),zl=[...wl,"切換為繁體","漢籍リポジトリ"];function Ku(e,n=zl){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)=>{Yu.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function qu(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??Sl():e==="hant"?_e.normalizeVariants:i:n==="zh-Hans"?i:_e.normalizeVariants}const Xu=({mode:e,children:n})=>{const i=g.useContext(Et),o=g.useMemo(()=>i&&{...i,converter:qu(e,i.locale,i.converter)},[i,e]);return t.jsx(Et.Provider,{value:o,children:n})};function Zu(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 Bs(e){return e==="text+image"?["text","image"]:[e]}function Os(e){const n=Ft(e);return n.length===0?"text":wu(n)}function Ju(){return{id:"",name:"",url:"",types:["text"],details:""}}const Nr=({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 k=Ft(w);return s==="text"?k.includes("text"):s==="image"?k.includes("image")||k.includes("physical"):s==="physical"?k.includes("physical"):k.includes(s)},m=e.map((w,k)=>({item:w,originalIndex:k})).filter(({item:w})=>h(w)),u=()=>{const w=Ju();s&&(w.types=Bs(s)),n([...e,w]),d(e.length)},f=w=>{n(e.filter((k,j)=>j!==w)),d(null)},x=(w,k,j)=>{const C=[...e];if(C[w]={...C[w],[k]:j},k==="url"&&!C[w].id){const _=Zu(j);_&&(C[w].id=_)}n(C)},v=(w,k)=>{const j=[...e],{type:C,..._}=j[w];j[w]={..._,types:Bs(k)},n(j)},b=(w,k,j)=>{const _={...e[w].metadata||{}};j?_[k]=j:delete _[k],x(w,"metadata",Object.keys(_).length>0?_:void 0)},$=(w,k)=>{const j=k.trim()?k.split(/[,,、]/).map(C=>C.trim()).filter(Boolean):void 0;x(w,"structure",j)},y=(w,k,j)=>{const _=e[w].coverage||{level:1,ranges:""};k==="level"?_.level=parseInt(j)||1:_.ranges=j,x(w,"coverage",_.ranges?_:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:w,originalIndex:k})=>{var j,C,_;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===k?null:k),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===k?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Qu(Os(w)),color:r("on-color-fg")},children:(()=>{var R,N;const S=Ft(w);return S.length===0?"text":S.length===1?((R=c.find(z=>z.value===S[0]))==null?void 0:R.label)??S[0]:S.includes("text")&&S.includes("image")?((N=c.find(z=>z.value==="text+image"))==null?void 0:N.label)??"text+image":S.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:w.name||`${a.editor.resourcePlaceholder} ${k+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:S=>S.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&w.url&&em(k,o==null?void 0:o[k],i,a),t.jsx("button",{onClick:S=>{S.stopPropagation(),f(k)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===k&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[ju(w,"image")&&w.url&&tm(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:In,children:[t.jsx("span",{style:En,children:a.label.type}),t.jsx("select",{value:Os(w),onChange:S=>v(k,S.target.value),style:{...zt,flex:1},children:c.map(S=>t.jsx("option",{value:S.value,children:S.label},S.value))})]}),t.jsxs("label",{style:In,children:[t.jsx("span",{style:En,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:S=>x(k,"root_type",S.target.value),style:{...zt,flex:1},children:p.map(S=>t.jsx("option",{value:S.value,children:S.label},S.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:w.id,onChange:S=>x(k,"id",S.target.value),placeholder:a.editor.idAutoExtract,style:{...zt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:S=>x(k,"name",S.target.value),placeholder:a.editor.resourceName,style:{...zt,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:S=>x(k,"url",S.target.value),placeholder:a.editor.resourceUrl,style:zt}),t.jsx("input",{type:"text",value:((j=w.structure)==null?void 0:j.join("、"))||"",onChange:S=>$(k,S.target.value),placeholder:a.editor.structurePlaceholder,style:zt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:In,children:[t.jsx("span",{style:En,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((C=w.coverage)==null?void 0:C.level)??"",onChange:S=>y(k,"level",S.target.value),placeholder:"1",style:{...zt,width:"60px"}})]}),t.jsxs("label",{style:{...In,flex:1},children:[t.jsx("span",{style:En,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((_=w.coverage)==null?void 0:_.ranges)||"",onChange:S=>y(k,"ranges",S.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...zt,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:S=>x(k,"details",S.target.value),placeholder:a.editor.detailsPlaceholder,style:{...zt,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(([S,R])=>{var N;return t.jsxs("label",{style:{...In,gap:"4px"},children:[t.jsx("span",{style:{...En,minWidth:"56px"},children:R}),t.jsx("input",{type:"text",value:((N=w.metadata)==null?void 0:N[S])||"",onChange:z=>b(k,S,z.target.value),placeholder:R,style:{...zt,flex:1}})]},S)})})]})]})]})]},k)}),t.jsxs("button",{onClick:u,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 Qu(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 em(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 tm(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 zt={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"},In={display:"flex",alignItems:"center",gap:"6px"},En={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},Ws={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function nm(e){return e.includes("text")&&e.includes("image")?Ws["text+image"]:Ws[e[0]||"physical"]}const lo=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ee(),{convert:l}=Me(),d=g.useMemo(()=>ro(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const b=new Map,$=[];for(const y of d){const w=y.group;w?(b.has(w)||b.set(w,[]),b.get(w).push(y)):$.push(y)}for(const y of b.values())y.sort((w,k)=>{const j=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return j(w)-j(k)});return{mirrorGroups:b,ungroupedItems:$}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=b=>h[b]?h[b]:b.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((b,$)=>t.jsx(dr,{item:b},b.id||$))});const u=(b,$)=>{const y=i==null?void 0:i[b],w=(y==null?void 0:y.label)||b,k=y==null?void 0:y.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)}),k&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.5},children:l(k)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((j,C)=>t.jsx(dr,{item:j,onNavigate:o,renderLink:s},j.id||C))})]},`group-${b}`)},f=new Map;for(const b of p){const $=io(Ft(b));f.has($)||f.set($,[]),f.get($).push(b)}const x=["text","image","text+image","physical"],v=[...x.filter(b=>f.has(b)),...[...f.keys()].filter(b=>!x.includes(b)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([b,$])=>u(b,$)),v.map(b=>{const $=f.get(b),y=nm(b.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:y,whiteSpace:"nowrap",flexShrink:0},children:m(b)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((w,k)=>t.jsx(dr,{item:w,onNavigate:o,renderLink:s},w.id||k))})]},b)})]})},im={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},dr=({item:e})=>{const n=Ee(),{convert:i}=Me(),[o,s]=g.useState(!1),a=g.useMemo(()=>(e.url?jn(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||vl(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),m=e.color_mode?{...im[e.color_mode],label:n.colorMode[e.color_mode]}:null,u=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}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),u&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:u}),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:bt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=oo(e.metadata);return x?so(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)})})]})},Nl=({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)||"",m=h?h.split(/[/\\]/).pop()||h:"",u={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:{...u,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:u,...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:{...u,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]})]}):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:u,...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:m||d.mode.configurePath,style:{...u,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:u,...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:{...u,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...u,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:m})]})]})},Ei="bim-search-history",Fs=10,Hs=8;function On(){try{const e=localStorage.getItem(Ei);return e?JSON.parse(e):[]}catch{return[]}}function Tl(e){try{const n=On().filter(i=>i!==e);n.unshift(e),n.length>Fs&&(n.length=Fs),localStorage.setItem(Ei,JSON.stringify(n))}catch{}}function rm(e){try{const n=On().filter(i=>i!==e);localStorage.setItem(Ei,JSON.stringify(n))}catch{}}function om(){try{localStorage.removeItem(Ei)}catch{}}const Il=({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),[m,u]=g.useState([]),[f,x]=g.useState(-1),[v,b]=g.useState(On),$=g.useRef(null),y=g.useRef(null),w=g.useRef(null),k=g.useRef(!1);g.useEffect(()=>{x(-1);const z=n.trim();if(!z){u(v.map(L=>({type:"history",text:L})));return}if(!e.searchAll){u([]);return}let M=!1;const F=setTimeout(()=>{e.searchAll(z,Hs).then(L=>{if(M)return;const E=[...L.works,...L.books,...L.collections,...L.entities??[]];u(E.slice(0,Hs).map(P=>({type:"entry",text:P.title||P.id,entry:P})))}).catch(()=>{M||u([])})},80);return()=>{M=!0,clearTimeout(F)}},[n,v,e]),g.useEffect(()=>{const z=M=>{w.current&&!w.current.contains(M.target)&&h(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]),g.useEffect(()=>{const z=M=>{var F,L;if(M.key==="/"&&document.activeElement!==$.current){const E=(F=document.activeElement)==null?void 0:F.tagName;if(E==="INPUT"||E==="TEXTAREA"||E==="SELECT")return;M.preventDefault(),(L=$.current)==null||L.focus()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const j=g.useCallback(z=>{z.trim()&&(Tl(z.trim()),b(On())),o(z),h(!1)},[o]),C=g.useCallback(z=>{z.type==="history"?(i(z.text),j(z.text)):z.entry&&(s?(s(z.entry),h(!1)):(i(z.text),j(z.text)))},[i,j,s]),_=g.useCallback(z=>{if(!p||m.length===0){z.key==="Enter"&&j(n);return}switch(z.key){case"ArrowDown":z.preventDefault(),x(M=>(M+1)%m.length);break;case"ArrowUp":z.preventDefault(),x(M=>(M-1+m.length)%m.length);break;case"Enter":z.preventDefault(),f>=0&&f<m.length?C(m[f]):j(n);break;case"Escape":z.preventDefault(),h(!1);break}},[p,m,f,n,j,C]),S=g.useCallback((z,M)=>{M.stopPropagation(),rm(z),b(On()),u(F=>F.filter(L=>!(L.type==="history"&&L.text===z)))},[]),R=g.useCallback(z=>{z.stopPropagation(),om(),b([]),u([])},[]);g.useEffect(()=>{if(f>=0&&y.current){const z=y.current.children;z[f]&&z[f].scrollIntoView({block:"nearest"})}},[f]);const N=!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:z=>{i(z.target.value),h(!0)},onCompositionStart:()=>{k.current=!0},onCompositionEnd:()=>{k.current=!1},onFocus:()=>{h(!0)},onKeyDown:_,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&&m.length>0&&t.jsxs("div",{ref:y,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:[N&&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:R,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((z,M)=>t.jsxs("div",{onClick:()=>C(z),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:M===f?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:z.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.text}),z.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[z.entry.type],z.entry.edition&&` · ${z.entry.edition}`,z.entry.author&&` · ${z.entry.author}`]}),z.type==="history"&&t.jsx("button",{onClick:F=>S(z.text,F),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${z.type}-${z.text}-${M}`))]})]})},Sn=({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"}}),Ri={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},El=new Set(["work","book","entity"]);function sm(e){return Al(e)||!!e.sort}function am(e,n){return n.sort&&El.has(e)?n.sort:void 0}const Li=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Ai=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Rl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Ll={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Mi(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 Al(e){return Mi(e)>0}function lm(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 Ml(e,n){const i=Ll[e];return lm(n).every(o=>i.has(o))}const Rn=e=>JSON.stringify(e);function cm(e,n){if(!Ml(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=Li.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${Rn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(Rn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${Rn(e.classification[0])}`:`classification IN [${e.classification.map(Rn).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 = ${Rn(e.loss)}`),i.join(" AND ")}const ct={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},Pl="_";function wi(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||Pl).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 dm(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(Li.map(a=>a.key)),o=new Set(Ai.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===Pl?"":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 pm(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 Ds(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const um=({filters:e,onChange:n})=>{const i=Ee(),o=i.searchV4,{convert:s}=Me(),[a,l]=g.useState(!1),d=g.useId(),c=Mi(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(bt(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:Li.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:Ds(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)}),Ai.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:Ds(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:Rl.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({...Ri,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function Bl({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 Us=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ee(),a=s.searchV4,{convert:l}=Me(),d=rt();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}`:"",m=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)}`:""}`:"",u=c.type==="book"?c.era??c.dynasty:c.dynasty,f=u?l(u):"",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 b=[m,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(Bl,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sr-measure",children:h})]}),b&&t.jsx("span",{className:"bim-sr-sub",children:b})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(Sn,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),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)})})]})})},mm=`
1
+ "use strict";var su=Object.create;var Ls=Object.defineProperty;var au=Object.getOwnPropertyDescriptor;var lu=Object.getOwnPropertyNames;var cu=Object.getPrototypeOf,du=Object.prototype.hasOwnProperty;var pu=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of lu(n))!du.call(e,s)&&s!==i&&Ls(e,s,{get:()=>n[s],enumerable:!(o=au(n,s))||o.enumerable});return e};var ui=(e,n,i)=>(i=e!=null?su(cu(e)):{},pu(n||!e||!e.__esModule?Ls(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),g=require("react"),uu=require("opencc-js/t2cn"),xl=require("./variant-supplement.cjs"),mu=require("react-markdown"),hu=require("remark-gfm"),gu=e=>`/item/${e}`,bl=g.createContext(gu);function fu({buildUrl:e,children:n}){const i=g.useMemo(()=>e,[e]);return t.jsx(bl.Provider,{value:i,children:n})}function rt(){return g.useContext(bl)}const yl="",jl="";function ro(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?jl:yl,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 pt(e,n){return{title:e,tokens:n}}const As='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',xu=[pt("基础(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"}}),pt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),pt("提示与警告",{"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)"}}),pt("遮罩与阴影",{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)"}}),pt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),pt("资源",{"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"}}),pt("整理本(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:"中性灰:占位"}}),pt("版本传承(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"}}),pt("编辑器视图(主要在 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")'}}),pt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),pt('版式(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"}}),pt("阅读器(整理本 / 全文)",{"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:"版心外边线"}}),pt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),pt("字体(全站无衬线,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:As,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:As,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],bu=Object.assign({},...xu.map(e=>e.tokens)),vl={};for(const[e,n]of Object.entries(bu))vl[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=vl[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Ft(e){return e.types&&e.types.length>0?e.types:[]}function yu(e,n){return Ft(e).includes(n)}const ju={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 vu={"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 vn(e){try{return vu[new URL(e).hostname]}catch{return}}const Ms={text:0,image:1,physical:2};function oo(e){return e.length===0?"physical":[...e].sort((n,i)=>(Ms[n]??99)-(Ms[i]??99)).join("+")}function ku(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function so(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,m]=p,u=`${h}|${oo(Ft(c))}`;i.has(u)||i.set(u,{base:{...c,name:h,url:"",volumes:[]},volumes:[],indices:[]});const f=i.get(u);f.volumes.push({volume:m,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 kl(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 wl(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||kl(n)}))}function Ii(e){const n=wl(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 ao(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 lo(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 kn(e){if(!e.url)return;const n=ao(e.metadata);return n?lo(e.url,n):e.url}const Rt=g.createContext(null),Sl=["曹霑"];function wu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Su(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(wu).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 Rn=null;function _l(){if(Rn)return Rn;try{const e=uu.Converter({from:"t",to:"cn"});Rn=Su(n=>e($e.normalizeVariants(n)))}catch{Rn=e=>e}return Rn}const _u={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:"圖片資源"}},$u={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 ht(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const Cu=ht({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:"无数据"}),Ri=ht({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:"作品信息"}),zu=ht({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:"附记"}}),Nu=ht({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:"種版本",sameEditionCopies:"同版另藏 {n} 部:",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:"种版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),Tu=ht({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:"上级丛编"}),Iu=ht({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 為自動匹配,未經人工核對",sealAlt:"{name}印影",imgCredit:"圖像:{credit}",imgLicense:"授權:{license}",imgSource:"來源"},{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 为自动匹配,未经人工核对",sealAlt:"{name}印影",imgCredit:"图像:{credit}",imgLicense:"授权:{license}",imgSource:"来源"}),Ru=ht({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}",tocExpand:"展開",tocCollapse:"收起",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}",tocExpand:"展开",tocCollapse:"收起",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),Eu=ht({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:"本卷条目"}),Lu=ht({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:"规模、存佚、许可与版本"}),co=ht({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:"按作者浏览全部 →"}),Au=ht({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} 条"}),Mu=ht({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:"搜索"}),Pu=ht({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:"回复"}),Bu=ht({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:"有争议"}}),Ou={common:Cu,detail:Ri,bookPage:zu,workPage:Nu,collectionPage:Tu,entityPage:Iu,reader:Ru,collated:Eu,metaHome:Lu,readHome:co,catalogPage:Au,searchPage:Mu,feedback:Pu,lineage:Bu};function Wu(e){const n={};for(const[i,o]of Object.entries(Ou))n[i]=o[e];return n}function bt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const Ps=new Map;function wn(e){let n=Ps.get(e);return n||(n={...e==="zh-Hans"?$u:_u,...Wu(e)},Ps.set(e,n)),n}function Bs(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 $l(e){return(n,i)=>{const o=Bs(e,n)??Bs(wn("zh-Hant"),n)??n;return i?bt(o,i):o}}const Os=new Map;function Sn(e){let n=Os.get(e);return n||(n=$l(wn(e)),Os.set(e,n)),n}const Cl="bim-locale";function Fu(){try{const e=localStorage.getItem(Cl);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Hu(e){try{localStorage.setItem(Cl,e)}catch{}}const Du="zh-Hans",Uu=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=g.useState(e??Du),l=e??s;g.useEffect(()=>{if(e)return;const h=Fu();h&&h!==s&&a(h)},[]);const d=g.useMemo(()=>l==="zh-Hans"?i??_l():null,[l,i]),c=g.useCallback(h=>{a(h),Hu(h),n==null||n(h)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:wn(l),converter:d}),[l,c,d]);return t.jsx(Rt.Provider,{value:p,children:o})};function Ee(){const e=g.useContext(Rt);return(e==null?void 0:e.messages)??wn("zh-Hant")}const Vu=2e3;function Me(){const e=g.useContext(Rt),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>=Vu){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(Rt),{convert:n,locale:i,isSimplified:o}=Me(),s=(e==null?void 0:e.messages)??wn("zh-Hant"),a=g.useMemo(()=>e?$l(s):Sn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const zl=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Gu=new Set([...zl,...Object.keys($e.VARIANT_CHARS),...Object.keys(xl.VARIANT_SUPPLEMENT)]),Nl=[...Sl,"切換為繁體","漢籍リポジトリ"];function Yu(e,n=Nl){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)=>{Gu.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function Ku(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??_l():e==="hant"?$e.normalizeVariants:i:n==="zh-Hans"?i:$e.normalizeVariants}const qu=({mode:e,children:n})=>{const i=g.useContext(Rt),o=g.useMemo(()=>i&&{...i,converter:Ku(e,i.locale,i.converter)},[i,e]);return t.jsx(Rt.Provider,{value:o,children:n})};function Xu(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 Ws(e){return e==="text+image"?["text","image"]:[e]}function Fs(e){const n=Ft(e);return n.length===0?"text":ku(n)}function Zu(){return{id:"",name:"",url:"",types:["text"],details:""}}const Ir=({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=Ft(w);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},m=e.map((w,j)=>({item:w,originalIndex:j})).filter(({item:w})=>h(w)),u=()=>{const w=Zu();s&&(w.types=Ws(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 $=Xu(k);$&&(C[w].id=$)}n(C)},v=(w,j)=>{const k=[...e],{type:C,...$}=k[w];k[w]={...$,types:Ws(j)},n(k)},b=(w,j,k)=>{const $={...e[w].metadata||{}};k?$[j]=k:delete $[j],x(w,"metadata",Object.keys($).length>0?$:void 0)},_=(w,j)=>{const k=j.trim()?j.split(/[,,、]/).map(C=>C.trim()).filter(Boolean):void 0;x(w,"structure",k)},y=(w,j,k)=>{const $=e[w].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(k)||1:$.ranges=k,x(w,"coverage",$.ranges?$:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:w,originalIndex:j})=>{var k,C,$;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:Ju(Fs(w)),color:r("on-color-fg")},children:(()=>{var E,N;const S=Ft(w);return S.length===0?"text":S.length===1?((E=c.find(z=>z.value===S[0]))==null?void 0:E.label)??S[0]:S.includes("text")&&S.includes("image")?((N=c.find(z=>z.value==="text+image"))==null?void 0:N.label)??"text+image":S.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:S=>S.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&w.url&&Qu(j,o==null?void 0:o[j],i,a),t.jsx("button",{onClick:S=>{S.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:[yu(w,"image")&&w.url&&em(w,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:En,children:[t.jsx("span",{style:Ln,children:a.label.type}),t.jsx("select",{value:Fs(w),onChange:S=>v(j,S.target.value),style:{...zt,flex:1},children:c.map(S=>t.jsx("option",{value:S.value,children:S.label},S.value))})]}),t.jsxs("label",{style:En,children:[t.jsx("span",{style:Ln,children:a.label.rootType}),t.jsx("select",{value:w.root_type||"catalog",onChange:S=>x(j,"root_type",S.target.value),style:{...zt,flex:1},children:p.map(S=>t.jsx("option",{value:S.value,children:S.label},S.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:w.id,onChange:S=>x(j,"id",S.target.value),placeholder:a.editor.idAutoExtract,style:{...zt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:w.name,onChange:S=>x(j,"name",S.target.value),placeholder:a.editor.resourceName,style:{...zt,flex:1}})]}),t.jsx("input",{type:"text",value:w.url,onChange:S=>x(j,"url",S.target.value),placeholder:a.editor.resourceUrl,style:zt}),t.jsx("input",{type:"text",value:((k=w.structure)==null?void 0:k.join("、"))||"",onChange:S=>_(j,S.target.value),placeholder:a.editor.structurePlaceholder,style:zt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:En,children:[t.jsx("span",{style:Ln,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((C=w.coverage)==null?void 0:C.level)??"",onChange:S=>y(j,"level",S.target.value),placeholder:"1",style:{...zt,width:"60px"}})]}),t.jsxs("label",{style:{...En,flex:1},children:[t.jsx("span",{style:Ln,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:(($=w.coverage)==null?void 0:$.ranges)||"",onChange:S=>y(j,"ranges",S.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...zt,flex:1}})]})]}),t.jsx("textarea",{value:w.details||"",onChange:S=>x(j,"details",S.target.value),placeholder:a.editor.detailsPlaceholder,style:{...zt,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(([S,E])=>{var N;return t.jsxs("label",{style:{...En,gap:"4px"},children:[t.jsx("span",{style:{...Ln,minWidth:"56px"},children:E}),t.jsx("input",{type:"text",value:((N=w.metadata)==null?void 0:N[S])||"",onChange:z=>b(j,S,z.target.value),placeholder:E,style:{...zt,flex:1}})]},S)})})]})]})]})]},j)}),t.jsxs("button",{onClick:u,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 Ju(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 Qu(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 em(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 zt={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"},En={display:"flex",alignItems:"center",gap:"6px"},Ln={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},Hs={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function tm(e){return e.includes("text")&&e.includes("image")?Hs["text+image"]:Hs[e[0]||"physical"]}const po=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Ee(),{convert:l}=Me(),d=g.useMemo(()=>so(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const b=new Map,_=[];for(const y of d){const w=y.group;w?(b.has(w)||b.set(w,[]),b.get(w).push(y)):_.push(y)}for(const y of b.values())y.sort((w,j)=>{const k=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return k(w)-k(j)});return{mirrorGroups:b,ungroupedItems:_}},[d]),h={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=b=>h[b]?h[b]:b.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((b,_)=>t.jsx(pr,{item:b},b.id||_))});const u=(b,_)=>{const y=i==null?void 0:i[b],w=(y==null?void 0:y.label)||b,j=y==null?void 0:y.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(pr,{item:k,onNavigate:o,renderLink:s},k.id||C))})]},`group-${b}`)},f=new Map;for(const b of p){const _=oo(Ft(b));f.has(_)||f.set(_,[]),f.get(_).push(b)}const x=["text","image","text+image","physical"],v=[...x.filter(b=>f.has(b)),...[...f.keys()].filter(b=>!x.includes(b)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([b,_])=>u(b,_)),v.map(b=>{const _=f.get(b),y=tm(b.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:y,whiteSpace:"nowrap",flexShrink:0},children:m(b)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.map((w,j)=>t.jsx(pr,{item:w,onNavigate:o,renderLink:s},w.id||j))})]},b)})]})},nm={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},pr=({item:e})=>{const n=Ee(),{convert:i}=Me(),[o,s]=g.useState(!1),a=g.useMemo(()=>(e.url?vn(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||kl(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),m=e.color_mode?{...nm[e.color_mode],label:n.colorMode[e.color_mode]}:null,u=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}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),u&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:u}),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:bt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=ao(e.metadata);return x?lo(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)})})]})},Tl=({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)||"",m=h?h.split(/[/\\]/).pop()||h:"",u={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:{...u,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:u,...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:{...u,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]})]}):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:u,...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:m||d.mode.configurePath,style:{...u,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:u,...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:{...u,paddingLeft:"8px",paddingRight:"8px",minWidth:h?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...u,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:m})]})]})},Ei="bim-search-history",Ds=10,Us=8;function Fn(){try{const e=localStorage.getItem(Ei);return e?JSON.parse(e):[]}catch{return[]}}function Il(e){try{const n=Fn().filter(i=>i!==e);n.unshift(e),n.length>Ds&&(n.length=Ds),localStorage.setItem(Ei,JSON.stringify(n))}catch{}}function im(e){try{const n=Fn().filter(i=>i!==e);localStorage.setItem(Ei,JSON.stringify(n))}catch{}}function rm(){try{localStorage.removeItem(Ei)}catch{}}const Rl=({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),[m,u]=g.useState([]),[f,x]=g.useState(-1),[v,b]=g.useState(Fn),_=g.useRef(null),y=g.useRef(null),w=g.useRef(null),j=g.useRef(!1);g.useEffect(()=>{x(-1);const z=n.trim();if(!z){u(v.map(A=>({type:"history",text:A})));return}if(!e.searchAll){u([]);return}let O=!1;const F=setTimeout(()=>{e.searchAll(z,Us).then(A=>{if(O)return;const I=[...A.works,...A.books,...A.collections,...A.entities??[]];u(I.slice(0,Us).map(P=>({type:"entry",text:P.title||P.id,entry:P})))}).catch(()=>{O||u([])})},80);return()=>{O=!0,clearTimeout(F)}},[n,v,e]),g.useEffect(()=>{const z=O=>{w.current&&!w.current.contains(O.target)&&h(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]),g.useEffect(()=>{const z=O=>{var F,A;if(O.key==="/"&&document.activeElement!==_.current){const I=(F=document.activeElement)==null?void 0:F.tagName;if(I==="INPUT"||I==="TEXTAREA"||I==="SELECT")return;O.preventDefault(),(A=_.current)==null||A.focus()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const k=g.useCallback(z=>{z.trim()&&(Il(z.trim()),b(Fn())),o(z),h(!1)},[o]),C=g.useCallback(z=>{z.type==="history"?(i(z.text),k(z.text)):z.entry&&(s?(s(z.entry),h(!1)):(i(z.text),k(z.text)))},[i,k,s]),$=g.useCallback(z=>{if(!p||m.length===0){z.key==="Enter"&&k(n);return}switch(z.key){case"ArrowDown":z.preventDefault(),x(O=>(O+1)%m.length);break;case"ArrowUp":z.preventDefault(),x(O=>(O-1+m.length)%m.length);break;case"Enter":z.preventDefault(),f>=0&&f<m.length?C(m[f]):k(n);break;case"Escape":z.preventDefault(),h(!1);break}},[p,m,f,n,k,C]),S=g.useCallback((z,O)=>{O.stopPropagation(),im(z),b(Fn()),u(F=>F.filter(A=>!(A.type==="history"&&A.text===z)))},[]),E=g.useCallback(z=>{z.stopPropagation(),rm(),b([]),u([])},[]);g.useEffect(()=>{if(f>=0&&y.current){const z=y.current.children;z[f]&&z[f].scrollIntoView({block:"nearest"})}},[f]);const N=!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:z=>{i(z.target.value),h(!0)},onCompositionStart:()=>{j.current=!0},onCompositionEnd:()=>{j.current=!1},onFocus:()=>{h(!0)},onKeyDown:$,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&&m.length>0&&t.jsxs("div",{ref:y,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:[N&&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:E,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((z,O)=>t.jsxs("div",{onClick:()=>C(z),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:O===f?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:z.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.text}),z.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[z.entry.type],z.entry.edition&&` · ${z.entry.edition}`,z.entry.author&&` · ${z.entry.author}`]}),z.type==="history"&&t.jsx("button",{onClick:F=>S(z.text,F),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${z.type}-${z.text}-${O}`))]})]})},_n=({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"}}),El=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],om={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function ot(e){return om[e]??e}const xn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],bn={熹平:172,建安:196,黃初:220,正始:240,廣政:938,太康:280,永和:345,開皇:581,貞觀:627,開元:713,天寶:742,貞元:785,元和:806,開成:836,會昌:841,咸通:860,建隆:960,太平興國:976,咸平:998,天禧:1017,慶曆:1041,皇祐:1049,嘉祐:1056,治平:1064,熙寧:1068,元豐:1078,元祐:1086,紹聖:1094,崇寧:1102,大觀:1107,政和:1111,宣和:1119,建炎:1127,紹興:1131,隆興:1163,乾道:1165,淳熙:1174,紹熙:1190,慶元:1195,嘉泰:1201,開禧:1205,嘉定:1208,寶慶:1225,紹定:1228,端平:1234,嘉熙:1237,淳祐:1241,寶祐:1253,開慶:1259,景定:1260,咸淳:1265,大定:1161,明昌:1190,至元:1264,大德:1297,皇慶:1312,延祐:1314,泰定:1324,天曆:1328,至順:1330,至正:1341,洪武:1368,永樂:1403,宣德:1426,正統:1436,景泰:1450,天順:1457,成化:1465,弘治:1488,正德:1506,嘉靖:1522,隆慶:1567,萬曆:1573,泰昌:1620,天啟:1621,崇禎:1628,弘光:1645,隆武:1645,紹武:1646,永曆:1647,順治:1644,康熙:1662,雍正:1723,乾隆:1736,嘉慶:1796,道光:1821,咸豐:1851,同治:1862,光緒:1875,宣統:1909,慶長:1596,寬永:1624,正保:1644,慶安:1648,承應:1652,明曆:1655,萬治:1658,寬文:1661,延寶:1673,天和:1681,貞享:1684,元祿:1688,寶永:1704,享保:1716,元文:1736,寬保:1741,延享:1744,寬延:1748,寶曆:1751,明和:1764,安永:1772,天明:1781,寬政:1789,享和:1801,文化:1804,文政:1818,天保:1830,弘化:1844,嘉永:1848,安政:1854,萬延:1860,文久:1861,元治:1864,慶應:1865,明治:1868,大正:1912,昭和:1926,天正:1573,文祿:1592,永祿:1558,天文:1532},Ll={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Li(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const i=parseInt(n[1],10);if(i<100||i>2100)return;const o=n[2]?parseInt(n[2],10):void 0;return{from:i,to:o!=null&&o>=i&&o<=2100?o:void 0}}function sm(e){return e>=1950?"":e>=1912?"民國":e>=1645?"清":e>=1368?"明":e>=1279?"元":e>=960?"宋":e>=907?"五代":e>=618?"唐":e>=581?"隋":e>=420?"南北朝":e>=265?"晉":e>=220?"三國":e>=-202?"漢":""}const am=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,Vs={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function uo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(Vs))if(n.startsWith(s))return Vs[s];const i=ot(n);if(tn[i]!=null)return i;const o=Wt(n);if(o&&n.length<=o.length+1)return ot(o)}function en(e,n){if(n){const i=Ll[`${n}|${e}`];if(i!=null)return i}return bn[e]}const lm=1911;function cm(e){const n=bn[e];if(n==null)return;const i=It[e];let o;for(const[s,a]of Object.entries(bn))It[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const dm={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Si(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,i=0,o=!1;for(const a of e){const l=dm[a];if(l===void 0)return;o=!0,a==="十"?i=(i||1)*10:a==="廿"||a==="卅"?(n+=l,i=0):i>=10?(n+=i+l,i=0):i=i*10+l}const s=n+i;return o&&s>0?s:void 0}function Wt(e){for(const n of El)if(e.startsWith(n))return n}const It={};{const e=(n,i)=>{for(const o of i)It[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function nn(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(bn))if(e.includes(o)&&!(i&&It[o]&&It[o]!==i&&Ll[`${i}|${o}`]==null))return o}function Kn(e){var l,d,c;const n={era:"",reign:"",source:"none"},i=e.dating;if(i!=null&&i.era||i!=null&&i.reign)return{era:i.era??"",reign:i.reign??"",source:i.certainty==="attested"?"catalog":"edition"};const o=(l=e.lineage)==null?void 0:l.year_text;if(o){const p=Wt(o)??"";return{era:ot(p),reign:nn(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=Li(s);if(p)return{era:sm(p.from),reign:"",source:"publication"};const h=Wt(s)??uo(s)??((c=xn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",m=nn(s,h)??"",u=h||(m?It[m]??"":"");if(u||m)return{era:ot(u),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Wt(a);if(p)return{era:ot(p),reign:nn(a,p)??"",source:"edition"};const h=xn.find(m=>m.pattern.test(a));if(h)return{era:ot(h.era),reign:nn(a,h.era)??h.reign??"",source:"edition"}}return n}function Ai(e){var o,s,a,l,d,c,p,h,m;if(((o=e.dating)==null?void 0:o.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(a=e.publication_info)==null?void 0:a.year;if(n){const u=Li(n);if(u)return u.from}const i=[(l=e.lineage)==null?void 0:l.year_text,(d=e.publication_info)==null?void 0:d.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const u of i){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&u!==f&&(Wt(f)||uo(f)))break;const x=u.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??u.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const w=parseInt(x[1],10);if(w>=100&&w<=2100)return w}const v=u.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(v){const w=Wt(u);if(!w||ot(w)==="民國"){const k=Si(v[1]);if(k!=null&&k>=1&&k<=120)return lm+k}}const b=Wt(u)??((h=xn.find(w=>w.pattern.test(u)))==null?void 0:h.era),_=b?ot(b):void 0,y=nn(u,_)??(Wt(u)||(m=xn.find(w=>w.pattern.test(u)))==null?void 0:m.reign);if(y){const w=en(y,_);if(w==null)continue;const j=u.indexOf(y),k=j>=0?u.slice(j+y.length):"",C=k.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??k.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),$=C?Si(C[1]):void 0;return w+($?$-1:0)}}}function mo(e){var l,d,c,p,h,m;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(d=e.lineage)==null?void 0:d.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const o=(c=e.lineage)==null?void 0:c.year_text;if(o){const u=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(u){const f=Rr[ot(u[1])],x=tn[ot(u[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const u=Li(s);if((u==null?void 0:u.to)!=null)return{from:u.from,to:u.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=Rr[ot(f[1])],v=tn[ot(f[2])];if(x!=null&&v!=null)return{from:Math.min(x,v)-20,to:Math.max(x,v)+40}}}const a=[(h=e.publication_info)==null?void 0:h.year,e.edition,e.title].filter(Boolean);for(const u of a){if(!/[間间]/.test(u))continue;const f=Wt(u)??uo(u)??((m=xn.find(b=>b.pattern.test(u)))==null?void 0:m.era),x=f?ot(f):void 0,v=[];for(const b of Object.keys(bn))u.includes(b)&&(x&&It[b]&&It[b]!==x||en(b,x)!=null&&v.push(b));if(v.length===0){const b=u.match(/([一-鿿])([一-鿿])[間间]/);if(b&&x){for(const _ of[b[1],b[2]])for(const y of Object.keys(bn))if(It[y]===x&&!(y[0]!==_&&y[y.length-1]!==_)&&en(y,x)!=null){v.push(y);break}}}if(v.length>0){const b=v.map(j=>en(j,x)).filter(j=>j!=null),_=Math.min(...b),y=v.reduce((j,k)=>en(j,x)>=en(k,x)?j:k),w=cm(y)??ur(x??"")??Math.max(...b);return{from:_,to:w>_?w:ur(x??It[y]??"")??_}}if(x&&tn[x]!=null)return{from:tn[x],to:ur(x)??tn[x]}}}const tn={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},pm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],um=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,Gs=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Ys(e,n){for(const i of El){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!nn(e.slice(o),ot(i)))continue}const s=ot(i);if(s===n)continue;const a=e.slice(o),l=nn(a,s)??"";let d;if(l){const c=en(l,s);if(c!=null){const h=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=h?Si(h[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const i of xn)if(i.pattern.test(e))return{era:ot(i.era),reign:i.reign??""}}function mm(e){var _,y,w,j,k;const n=Kn(e),i=((_=e.publication_info)==null?void 0:_.year)??"",o=i?Li(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((y=e.lineage)==null?void 0:y.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&am.test(i),p=n.source==="publication"&&/[間间]/.test(i),h=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:h?m=parseInt(h[2],10):m=Ai(e);const u=m==null?mo(e):void 0;let f;n.source==="publication"&&(c||Gs.test(i))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":Gs.test(s)||!n.reign&&m==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((w=e.lineage)==null?void 0:w.year_text)??((j=e.lineage)==null?void 0:j.year)??""}」`:`出版著錄「${((k=e.publication_info)==null?void 0:k.year)??""}」`,v={era:n.era,reign:n.reign,year:m,yearRange:u,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(h){const C=l.match(/[、,,]\s*([宋元明清])/);C&&C[1]!==v.era&&(v.laterRepair={era:C[1]})}if(!v.laterRepair&&um.test(s)){const C=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);C&&C[1]!==n.era&&(v.laterRepair={era:C[1]})}const b=pm.find(C=>C.re.test(s));if(b){const C=s.search(b.re),$=s.slice(C),S=Ys($,n.era)??Ys(s,n.era);S&&(v.basedOn={era:S.era,reign:S.reign,year:S.year,relation:b.relation})}return v}const Rr={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function ur(e){return Rr[e]}function _i(e){const n=Ai(e);if(n!=null)return n;const i=mo(e);if(i)return i.from;const o=Kn(e).era;return o?tn[o]:void 0}const Ks=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Er(e){const n=Ks.indexOf(e);return n===-1?Ks.length:n}function hm(e){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of e){const a=s.relation;a==="part_of"?n.belongsTo.push(s):a==="collected_in"?n.collected.push(s):a==="has_part"||a==="contains_text_of"?n.contains.push(s):a==="text_carried_by"||a==="studied_by"||a==="derived_from"||a==="followed_by"||a==="has_adaptation"?n.derivative.push(s):a==="studies"||a==="preceded_by"?n.studies.push(s):n.related.push(s)}const i=[],o=(s,a)=>{n[s].length&&i.push({key:s,labelKey:a,items:n[s]})};return o("belongsTo","belongsToWork"),o("collected","collectedIn"),o("contains","containedWorks"),o("derivative","derivativeWorks"),o("studies","studies"),o("related","relatedWorks"),i}function ho(e,n){const i=so(e||[]),o=new Map,s=[];for(const p of i)p.group?(o.has(p.group)||o.set(p.group,[]),o.get(p.group).push(p)):s.push(p);for(const p of o.values())p.sort((h,m)=>{const u=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return u(h)-u(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const h=Ft(p),m=h.includes("text"),u=h.includes("image");m&&u?a.textImage.push(p):m?a.text.push(p):u?a.image.push(p):a.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>a[p].length>0).map(p=>({key:p,items:a[p]})),c=[...o.entries()].map(([p,h])=>{var m,u;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(u=n==null?void 0:n[p])==null?void 0:u.description,items:h}});return{buckets:d,mirrors:c,total:i.length}}function Mi(e,n=Sn("zh-Hant")){const i=[],o=e.metadata||{};o.edition&&i.push(String(o.edition)),e.source_label&&i.push(e.source_label),e.details&&i.push(e.details);const s=Ii(e);return s&&s.expected>0&&i.push(s.missing>0?n("detail.volumeStatsMissing",{found:s.found,expected:s.expected,missing:s.missing}):n("detail.volumeStats",{found:s.found,expected:s.expected})),o.version&&i.push(String(o.version)),i.join(" · ")}function Al(e,n){if(Mi(e)||n.filter(o=>o.name===e.name).length<2)return"";try{const o=new URL(e.url),s=o.searchParams.get("res")||o.searchParams.get("id");if(s)return s;const a=o.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}const gm="同版";function fm(e){const n=e==null?void 0:e.metadata;return((n==null?void 0:n.item_id)||(n==null?void 0:n.call_number)||"").trim()||void 0}function xm(e){var n;for(const i of((n=e.lineage)==null?void 0:n.related_to)??[]){const o=i.ref??i.book_id;if(i.relation===gm&&o&&o!==e.id)return o}}function bm(e){const n=new Map(e.map(a=>[a.id,a])),i=a=>{const l=n.get(a);return!!l&&!l.copyOf},o=new Map;for(const a of e)if(a.copyOf&&i(a.copyOf)){const l=o.get(a.copyOf)??[];l.push(a),o.set(a.copyOf,l)}if(o.size===0)return e;const s=[];for(const a of e){if(a.copyOf&&i(a.copyOf))continue;const l=o.get(a.id);if(!l){s.push(a);continue}const d=[...l].sort((c,p)=>(c.callNumber??c.id).localeCompare(p.callNumber??p.id));s.push({...a,copies:d,hasImage:a.hasImage||d.some(c=>c.hasImage)})}return s}function Ml(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Ft(d);c.includes("image")&&o.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Kn(e),year:Ai(e),sortYear:_i(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,callNumber:fm(s[0]),copyOf:xm(e),summary:e.summary,important:ym(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function ym(e,n){var d,c;if(!n)return!1;const i=n.default_collection;if(!i)return!1;const o=(d=n.collections)==null?void 0:d[i];if(((o==null?void 0:o.book_ids)??(i==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(o==null?void 0:o.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function Pl(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=bm(e.filter(c=>!o.has(c.id)).map(c=>Ml(c,n)));let a=s;i.era&&(a=a.filter(c=>c.era.era===i.era)),i.scanOnly&&(a=a.filter(c=>c.hasImage)),i.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=c.r.sortYear,m=p.r.sortYear;return h!=null&&m!=null?h-m||c.i-p.i:h!=null?-1:m!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=m=>(m.important?0:1)*2+(m.hasImage?0:1);return h(c.r)-h(p.r)||c.i-p.i}).map(c=>c.r);const d=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,p)=>Er(c)-Er(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function jm(e,n){var b,_;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(b=n.collections)==null?void 0:b[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(o),c=new Set([...s,...l]),p=y=>{if(c.has(y))return!0;const w=n.node_groups[y];return w!=null&&d.has(w)},h=[],m=new Map,u=[];for(const y of e)if(!((_=n.excluded_books)!=null&&_.includes(y)))if(p(y))h.push(y);else{const w=n.node_groups[y];w?(m.has(w)||m.set(w,[]),m.get(w).push(y)):u.push(y)}if(u.length+[...m.values()].reduce((y,w)=>y+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(y=>[y.id,y])),v=[...m.entries()].map(([y,w])=>{const j=x.get(y);return{id:y,label:(j==null?void 0:j.label)??y,description:j==null?void 0:j.description,ids:w}});return u.length>0&&v.push({id:"__other__",label:"其他版本",description:void 0,ids:u}),{useGrouping:!0,coreIds:h,groupedIds:v}}const Bl=["撰","編","注","校","譯","繪","其他"],vm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function go(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of vm)if(o.test(n))return i;return"其他"}function fo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Ol(e,n="全部"){const i=new Map;for(const s of e){const a=go(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of Bl){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function xo(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function bo(e){const n=e._classifications??[],i=n.find(o=>o.scheme==="zongmu")??n[0];if(i)return{l1:i.l1??"",l2:i.l2??"",l3:i.l3??"",l4:i.l4??"",...i.source?{source:i.source}:{}}}function Wl(e){const n=e._members??[],i=typeof e._member_count=="number"?e._member_count:n.length;return{works:n.filter(o=>o.t==="work").map(o=>({id:o.id,title:o.title??"",volumes:Hn(o.vol)})),bookIds:n.filter(o=>o.t!=="work").map(o=>o.id).filter(o=>typeof o=="string"),total:i,truncated:i>n.length}}function km(e){var n;return(e==null?void 0:e._member_count)||((n=e==null?void 0:e._members)==null?void 0:n.length)||0}function Fl(e,n,i){if(n&&n.books&&n.books.length>0){const l=n.books.map(c=>({id:c.work_id||c.book_id||void 0,title:c.title,section:c.section,volumes:c.volumes||[],subItems:c.sub_items,edition:c.edition,found:c.found_volumes,expected:c.expected_volumes})),d=[...new Set(l.map(c=>c.section).filter(Boolean))];return{rows:l,source:"catalog",sections:d,totalVolumes:n.total_volumes}}const{works:o,bookIds:s}=Wl(e);return o.length>0?{rows:o.map(d=>({id:d.id,title:d.title,volumes:d.volumes})),source:"works",sections:[]}:{rows:s.map(l=>{var d,c;return{id:l,title:((d=i==null?void 0:i.get(l))==null?void 0:d.title)||l,edition:(c=i==null?void 0:i.get(l))==null?void 0:c.edition,volumes:[]}}),source:"books",sections:[]}}function Hn(e){if(e==null)return[];if(typeof e=="number")return[e];if(Array.isArray(e))return e.filter(n=>typeof n=="number");if(typeof e=="string"){const n=e.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[i,o]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,o-i+1)},(s,a)=>i+a)}return e.split(/[,、]/).map(i=>parseInt(i.trim())).filter(i=>!isNaN(i))}return[]}function Pi(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=[...e].sort((a,l)=>a-l),o=i[0],s=i[i.length-1];return s-o+1===i.length?`${o}–${s}`:i.length<=3?i.join(", "):`${o}–${s} (${i.length}${n})`}const wm=["〇","一","二","三","四","五","六","七","八","九"],qs=["","十","百","千"];function $n(e){if(!Number.isInteger(e)||e<=0)return"";if(e>=1e8)return String(e);if(e<1e4)return mr(e,!0);const n=Math.floor(e/1e4),i=e%1e4;let o=mr(n,!0)+"萬";return i>0&&(o+=(i<1e3?"〇":"")+mr(i,!1)),o}function mr(e,n){const i=String(e),o=i.length;let s="",a=!1;for(let l=0;l<o;l++){const d=parseInt(i[l]),c=o-1-l;d===0?a=!0:(a&&s&&(s+="〇"),a=!1,n&&d===1&&c===1&&l===0?s+=qs[c]:s+=wm[d]+qs[c])}return s}function Sm(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function _m(e){if(e==null||typeof e=="string")return;const n="url"in e&&e.url?e.url:"type"in e&&e.type==="url"?e.details:void 0;return n&&/^https?:\/\//i.test(n)?n:void 0}function Ht(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?$n(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function Hl(e){var o;if(e.edition_type)return e.edition_type;if((o=e.lineage)!=null&&o.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/油印/,"油印本"],[/曬印|晒印/,"曬印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of i)if(s.test(n))return a;return""}const Bi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Dl=new Set(["work","book","entity"]);function $m(e){return Gl(e)||!!e.sort}function Cm(e,n){return n.sort&&Dl.has(e)?n.sort:void 0}const Oi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Wi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Ul=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Vl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Fi(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 Gl(e){return Fi(e)>0}function zm(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=Vl[e];return zm(n).every(o=>i.has(o))}const An=e=>JSON.stringify(e);function Nm(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=Oi.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${An(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(An).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${An(e.classification[0])}`:`classification IN [${e.classification.map(An).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 = ${An(e.loss)}`),i.join(" AND ")}const ct={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},Kl="_";function $i(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||Kl).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 Tm(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(Oi.map(a=>a.key)),o=new Set(Wi.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===Kl?"":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 Im(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 Xs(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const Rm=({filters:e,onChange:n})=>{const i=Ee(),o=i.searchV4,{convert:s}=Me(),[a,l]=g.useState(!1),d=g.useId(),c=Fi(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(bt(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:Oi.map(h=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(h.key),onClick:()=>p({dynasty:Xs(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)}),Wi.map(h=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(h.value),onChange:()=>p({classification:Xs(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:Ul.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({...Bi,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function ql({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 Zs=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ee(),a=s.searchV4,{convert:l}=Me(),d=rt();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}`:"",m=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)}`:""}`:"",u=c.type==="book"?c.era??c.dynasty:c.dynasty,f=u?l(u):"",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 b=[m,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(ql,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sr-measure",children:h})]}),b&&t.jsx("span",{className:"bim-sr-sub",children:b})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(_n,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),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)})})]})})},Em=`
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")}; }
@@ -12,7 +12,7 @@
12
12
  .bim-sc-fl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: ${r("aux-fg")}; }
13
13
  .bim-sc-tags { display: flex; gap: 4px; flex: none; }
14
14
  :root[data-layout="boxed"] .bim-sc { box-shadow: none; }
15
- `,Vs=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ee(),a=s.searchV4,{convert:l}=Me(),d=rt();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:mm}),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??"?"}`:"":`${c.dynasty?`〔${l(c.dynasty)}〕`:""}${c.author?l(c.author):""}`,c.type==="book"&&c.edition?l(c.edition):"",h].filter(Boolean).join(" · "),f=[o(c.type),c.classification?l(c.classification):""].filter(Boolean).join(" · "),x=[];return c.has_image&&x.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&x.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&x.push({label:a.tagLost,cls:"bim-sr-tag--lost"}),t.jsxs("a",{className:"bim-sc",href:d(c.id),onClick:v=>i(c,v),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(Bl,{text:p,query:n?l(n):void 0})}),u&&t.jsx("span",{className:"bim-sc-m",children:u}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:no(c.descriptionSnippet).map((v,b)=>v.marked?t.jsx("mark",{children:l(v.text)},b):t.jsx(g.Fragment,{children:l(v.text)},b))}),t.jsx("span",{className:"bim-sc-sp"}),t.jsxs("div",{className:"bim-sc-f",children:[t.jsx("span",{className:"bim-sc-fl",children:f}),t.jsx("span",{className:"bim-sc-tags",children:x.map(v=>t.jsx("span",{className:`bim-sr-tag ${v.cls}`,children:l(v.label)},v.label))})]})]},c.id)})]})};function hm(e,n){const i=new Set([1,n,e-1,e,e+1].filter(a=>a>=1&&a<=n)),o=Array.from(i).sort((a,l)=>a-l),s=[];return o.forEach((a,l)=>{l>0&&a-o[l-1]>1&&s.push("gap"),s.push(a)}),s}function gm(e,n,i){const o=Math.max(1,Math.ceil(n/i));return Math.min(Math.max(1,e),o)}const fm=({page:e,pageSize:n,total:i,totalLabel:o,onPage:s})=>{const a=Ee().searchV4,{convert:l}=Me(),d=Math.max(1,Math.ceil(i/n));return i<=0?null:t.jsxs("nav",{className:"bim-sr-pager","aria-label":l(a.pagerLabel),children:[t.jsx("span",{className:"bim-sr-info",children:l(bt(a.pageInfo,{total:o??i.toLocaleString(),size:n,page:e,pages:d}))}),d>1&&t.jsxs("ul",{children:[t.jsx("li",{children:t.jsx("button",{type:"button",disabled:e<=1,onClick:()=>s(e-1),children:l(a.prevPage)})}),hm(e,d).map((c,p)=>c==="gap"?t.jsx("li",{className:"bim-sr-gap","aria-hidden":"true",children:"…"},`g${p}`):t.jsx("li",{children:t.jsx("button",{type:"button","aria-current":c===e?"page":void 0,"aria-label":`${c}`,onClick:()=>s(c),children:c})},c)),t.jsx("li",{children:t.jsx("button",{type:"button",disabled:e>=d,onClick:()=>s(e+1),children:l(a.nextPage)})})]})]})},Ol="(max-width: 719px)",xm=`${Ol}, (pointer: coarse)`,bm=`
15
+ `,Js=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Ee(),a=s.searchV4,{convert:l}=Me(),d=rt();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:Em}),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??"?"}`:"":`${c.dynasty?`〔${l(c.dynasty)}〕`:""}${c.author?l(c.author):""}`,c.type==="book"&&c.edition?l(c.edition):"",h].filter(Boolean).join(" · "),f=[o(c.type),c.classification?l(c.classification):""].filter(Boolean).join(" · "),x=[];return c.has_image&&x.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&x.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&x.push({label:a.tagLost,cls:"bim-sr-tag--lost"}),t.jsxs("a",{className:"bim-sc",href:d(c.id),onClick:v=>i(c,v),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(ql,{text:p,query:n?l(n):void 0})}),u&&t.jsx("span",{className:"bim-sc-m",children:u}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:ro(c.descriptionSnippet).map((v,b)=>v.marked?t.jsx("mark",{children:l(v.text)},b):t.jsx(g.Fragment,{children:l(v.text)},b))}),t.jsx("span",{className:"bim-sc-sp"}),t.jsxs("div",{className:"bim-sc-f",children:[t.jsx("span",{className:"bim-sc-fl",children:f}),t.jsx("span",{className:"bim-sc-tags",children:x.map(v=>t.jsx("span",{className:`bim-sr-tag ${v.cls}`,children:l(v.label)},v.label))})]})]},c.id)})]})};function Lm(e,n){const i=new Set([1,n,e-1,e,e+1].filter(a=>a>=1&&a<=n)),o=Array.from(i).sort((a,l)=>a-l),s=[];return o.forEach((a,l)=>{l>0&&a-o[l-1]>1&&s.push("gap"),s.push(a)}),s}function Am(e,n,i){const o=Math.max(1,Math.ceil(n/i));return Math.min(Math.max(1,e),o)}const Mm=({page:e,pageSize:n,total:i,totalLabel:o,onPage:s})=>{const a=Ee().searchV4,{convert:l}=Me(),d=Math.max(1,Math.ceil(i/n));return i<=0?null:t.jsxs("nav",{className:"bim-sr-pager","aria-label":l(a.pagerLabel),children:[t.jsx("span",{className:"bim-sr-info",children:l(bt(a.pageInfo,{total:o??i.toLocaleString(),size:n,page:e,pages:d}))}),d>1&&t.jsxs("ul",{children:[t.jsx("li",{children:t.jsx("button",{type:"button",disabled:e<=1,onClick:()=>s(e-1),children:l(a.prevPage)})}),Lm(e,d).map((c,p)=>c==="gap"?t.jsx("li",{className:"bim-sr-gap","aria-hidden":"true",children:"…"},`g${p}`):t.jsx("li",{children:t.jsx("button",{type:"button","aria-current":c===e?"page":void 0,"aria-label":`${c}`,onClick:()=>s(c),children:c})},c)),t.jsx("li",{children:t.jsx("button",{type:"button",disabled:e>=d,onClick:()=>s(e+1),children:l(a.nextPage)})})]})]})},Xl="(max-width: 719px)",Pm=`${Xl}, (pointer: coarse)`,Bm=`
16
16
  .bim-sr-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; align-items: start; padding: 0 20px; }
17
17
  .bim-sr-layout[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
18
18
  .bim-sr-aside { position: sticky; top: calc(${r("reader-top")} + 16px); padding-top: 2px; }
@@ -81,7 +81,7 @@
81
81
  .bim-sr-pager .bim-sr-gap { color: ${r("aux-fg")}; padding: 0 2px; }
82
82
  .bim-sr-empty { padding: 60px 0; text-align: center; font-size: 14px; color: ${r("meta-fg")}; }
83
83
 
84
- @media ${Ol} {
84
+ @media ${Xl} {
85
85
  .bim-sr-layout { grid-template-columns: minmax(0, 1fr); row-gap: 16px; padding: 0 16px; }
86
86
  .bim-sr-aside { position: static; }
87
87
  .bim-sr-fbtn {
@@ -102,7 +102,7 @@
102
102
  .bim-sr-table td.bim-sr-c-res { text-align: left; padding-bottom: 2px; }
103
103
  .bim-sr-table td.bim-sr-c-res:empty { display: none; }
104
104
  }
105
- @media ${xm} {
105
+ @media ${Pm} {
106
106
  .bim-sr-chip { min-height: 36px; }
107
107
  .bim-sr-opt { min-height: 44px; }
108
108
  .bim-sr-seg button { min-height: 44px; }
@@ -117,10 +117,10 @@
117
117
  :root[data-layout="boxed"] .bim-sr-table th { background: ${r("fr-bg")}; }
118
118
  /* 墨:主色与正文对比不到 3:1,标题链接另加下划线 */
119
119
  :root[data-theme="ink"] .bim-sr-table td.bim-sr-c-title a { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; }
120
- `,co="bim-search-view",pr=50,Gs=5,Wn=1e3;function fi(e){return e>=Wn?`${Wn.toLocaleString()}+`:e.toLocaleString()}const ym={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function jm(e){return e&&ym[e.toLowerCase()]||"all"}function vm(e){return e==="all"?null:e}const Ys=["work","collection","book","entity"],km={work:"works",collection:"collections",book:"books",entity:"entities"},wm={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function Sm(){try{return window.localStorage.getItem(co)==="card"?"card":"table"}catch{return"table"}}function _m(e){try{window.localStorage.setItem(co,e)}catch{}}const pn=(e,n)=>(e==null?void 0:e[wm[n]])??0,ur=(e,n)=>(e==null?void 0:e[km[n]])??[],Wl=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const h=Ee(),m=h.searchV4,{convert:u}=Me(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?i:Ri,[f,i]),[v,b]=g.useState("table");g.useEffect(()=>{b(Sm())},[]);const $=G=>{b(G),_m(G)},[y,w]=g.useState(l??"all"),k=g.useRef(y);k.current=y,g.useEffect(()=>{l!==void 0&&l!==k.current&&(w(l),C(1))},[l]);const[j,C]=g.useState(c&&c>0?c:1),_=g.useRef(j);_.current=j,g.useEffect(()=>{c!==void 0&&c>0&&c!==_.current&&C(c)},[c]);const S=g.useRef(null),R=g.useCallback(G=>{var Y;C(G),p==null||p(G);const he=S.current;he&&he.getBoundingClientRect().top<0&&((Y=he.scrollIntoView)==null||Y.call(he,{block:"start",behavior:"instant"}))},[p]),[N,z]=g.useState(null),[M,F]=g.useState(null),[L,E]=g.useState(!1),[P,Z]=g.useState(""),oe=wi(x).toString(),ae=Mi(x)>0,H=wi({...x,sort:""}).toString(),ce=g.useRef({query:n,filterOnlyKey:H,sort:x.sort});g.useEffect(()=>{const G=ce.current;G.query!==n||G.filterOnlyKey!==H?(w("all"),C(1)):G.sort!==x.sort&&C(1),ce.current={query:n,filterOnlyKey:H,sort:x.sort}},[n,H,x.sort]),g.useEffect(()=>{let G=!1;return E(!0),Z(""),(async()=>{try{let he;if(e.searchAll)he=await e.searchAll(n,Gs,x);else{const Y=["work","book","collection","entity"],re=await Promise.all(Y.map(K=>e.search(n,K,{page:1,pageSize:Gs,filters:x})));he={works:re[0].entries,books:re[1].entries,collections:re[2].entries,entities:re[3].entries,totalWorks:re[0].total,totalBooks:re[1].total,totalCollections:re[2].total,totalEntities:re[3].total}}G||z(he)}catch(he){G||(Z(he instanceof Error?he.message:String(he)),z(null))}finally{G||E(!1)}})(),()=>{G=!0}},[e,n,oe]);const V=y;g.useEffect(()=>{if(y==="all"){F(null);return}let G=!1;return E(!0),(async()=>{try{const he=await e.search(n,y,{page:j,pageSize:pr,filters:x});G||F({key:V,entries:he.entries,total:he.total})}catch(he){G||(Z(he instanceof Error?he.message:String(he)),F(null))}finally{G||E(!1)}})(),()=>{G=!0}},[e,n,oe,y,j]);const ne=M&&M.key===V?M:null;g.useEffect(()=>{if(y==="all"||!ne||L)return;const G=Math.min(ne.total,Wn),he=gm(j,G,pr);ne.entries.length===0&&G>0&&he!==j&&(C(he),p==null||p(he))},[y,ne,L,j]);const je=g.useMemo(()=>Ys.filter(G=>pn(N,G)>0),[N]),ge=je.reduce((G,he)=>G+pn(N,he),0),Le=je.some(G=>pn(N,G)>=Wn)?`${ge.toLocaleString()}+`:ge.toLocaleString(),B=!L&&!P&&N!==null&&ge===0,me=g.useCallback(G=>{w(G),C(1),d==null||d(G)},[d]),ze=g.useMemo(()=>{const G=[];return x.dynasty.forEach(he=>G.push({name:he,remove:()=>o({...x,dynasty:x.dynasty.filter(Y=>Y!==he)})})),x.classification.forEach(he=>{var Y;return G.push({name:he?((Y=Ai.find(re=>re.value===he))==null?void 0:Y.label)??he:h.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(re=>re!==he)})})}),x.hasImage&&G.push({name:m.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&G.push({name:m.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&G.push({name:m.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&G.push({name:`${m.extant}:${h.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),G},[x,o,m,h]),we={query:n,onEntryLinkClick:s,typeName:a},De=G=>v==="table"?t.jsx(Us,{entries:G,...we}):t.jsx(Vs,{entries:G,...we}),Pe=Ys.flatMap(G=>ur(N,G));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:bm}),f&&t.jsx(um,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":L,ref:S,children:[je.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":h.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs(Ks,{on:y==="all",onClick:()=>me("all"),children:[h.search.allTab," ",t.jsx("small",{children:Le})]}),je.map(G=>t.jsxs(Ks,{on:y===G,onClick:()=>me(G),children:[a(G)," ",t.jsx("small",{children:fi(pn(N,G))})]},G))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:u(m.sortRelevance)}),["era","title"].map(G=>{const he=x.sort.startsWith(`${G}:`)?x.sort.endsWith("desc")?"desc":"asc":null,Y=G==="era"?m.sortEra:m.sortTitle,re=G==="era"?he==="desc"?m.sortEraDesc:m.sortEraAsc:he==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":he!==null,title:u(re),onClick:()=>o({...x,sort:`${G}:${he==="asc"?"desc":"asc"}`}),children:[u(Y),he?t.jsxs("span",{"aria-hidden":"true",children:[" ",he==="asc"?"↑":"↓"]}):null]},G)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":v==="table",onClick:()=>$("table"),children:u(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":v==="card",onClick:()=>$("card"),children:u(m.viewCard)})]})]}),ae&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:u(bt(m.filteredCount,{n:Le}))}),ze.map(G=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(bt(m.removeFilter,{name:G.name})),onClick:G.remove,children:[u(G.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},G.name))]}),P&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:P}),B&&t.jsx("div",{className:"bim-sr-empty",children:u(ae?m.emptyFiltered:bt(h.search.noResultsFor,{query:n}))}),!P&&!B&&y==="all"&&N&&(v==="table"?t.jsxs(t.Fragment,{children:[t.jsx(Us,{entries:Pe,...we}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(m.limitedNote)})]}):t.jsx(t.Fragment,{children:je.map(G=>t.jsxs("section",{style:{marginTop:22},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[t.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[t.jsx(Sn,{type:G,size:8}),a(G),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[fi(pn(N,G))," ",h.unit.items]})]}),pn(N,G)>ur(N,G).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>me(G),children:h.action.viewAll})]}),t.jsx(Vs,{entries:ur(N,G),...we})]},G))})),!P&&y!=="all"&&!ne&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:h.search.loading}),!P&&y!=="all"&&ne&&ne.entries.length>0&&t.jsxs(t.Fragment,{children:[De(ne.entries),t.jsx(fm,{page:j,pageSize:pr,total:Math.min(ne.total,Wn),totalLabel:fi(ne.total),onPage:R})]}),!P&&y!=="all"&&ne&&ne.entries.length===0&&!L&&t.jsxs("div",{className:"bim-sr-empty",children:[u(ae?m.emptyFiltered:bt(h.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>me("all"),children:h.search.allTab})})]})]})]})};function Ks({on:e,onClick:n,children:i}){return t.jsx("button",{type:"button","aria-pressed":e,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:r(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${r("accent")}`:"none"},children:i})}const fn="bim-recent-ids",qs="bim-recent-entries",Xs=50;function Kt(){try{const e=localStorage.getItem(fn);if(e)return JSON.parse(e);const n=localStorage.getItem(qs);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(fn,JSON.stringify(i)),localStorage.removeItem(qs),i}return[]}catch{return[]}}function Tr(e){try{const n=Kt().filter(i=>i!==e);n.unshift(e),n.length>Xs&&(n.length=Xs),localStorage.setItem(fn,JSON.stringify(n))}catch{}}function Fl(e){try{const n=Kt().filter(i=>i!==e);localStorage.setItem(fn,JSON.stringify(n))}catch{}}function po(){try{localStorage.removeItem(fn)}catch{}}async function uo(e,n){var i,o,s;try{if(e.getEntry){const l=await e.getEntry(n);if(l)return l}const a=await e.getItem(n);if(a){const l=a.authors;return{id:n,title:a.title||n,type:a.type||"work",author:(i=l==null?void 0:l[0])==null?void 0:i.name,dynasty:(o=l==null?void 0:l[0])==null?void 0:o.dynasty,role:(s=l==null?void 0:l[0])==null?void 0:s.role,edition:a.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const mr=5,$m=50,Cm=200,Zs={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Ir=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:h="compact",renderEntry:m,initialQuery:u,onQueryChange:f,headerRight:x,reserveViewportHeight:v=!1,filtersEnabled:b=!1,filters:$=Ri,onFiltersChange:y,resultTab:w,onResultTabChange:k,resultPage:j,onResultPageChange:C})=>{const _=Ee(),S=[{type:"work",name:_.indexType.work,key:"works"},{type:"book",name:_.indexType.book,key:"books"},{type:"collection",name:_.indexType.collection,key:"collections"},{type:"entity",name:_.indexType.entity,key:"entities"}],R=["work","collection","book","entity"],[N,z]=g.useState(u??""),[M,F]=g.useState(null),[L,E]=g.useState(u??""),P=wi($).toString(),[Z,oe]=g.useState($);g.useEffect(()=>{oe($)},[P]);const ae=T=>{oe(T),y==null||y(T)},[H,ce]=g.useState(null),[V,ne]=g.useState("all"),[je,ge]=g.useState(!1),[Le,B]=g.useState(null),[me,ze]=g.useState(""),[we,De]=g.useState(!(u!=null&&u.trim())),[Pe,G]=g.useState(Kt),[he,Y]=g.useState([]),[re,K]=g.useState(!1),[A,U]=g.useState(!1),[q,D]=g.useState(null),[de,be]=g.useState(null),ve=g.useRef(void 0),Re=g.useRef(!1),O=g.useCallback(async(T,ue)=>{if(!T.trim()){De(!0),F(null),ce(null);return}if(De(!1),b){E(T);return}ge(!0),ze("");try{if(e.searchAll){const ye=await e.searchAll(T,ue??mr);F(ye)}else{const ye=["work","book","collection","entity"],ke=await Promise.all(ye.map(Ne=>e.search(T,Ne,{page:1,pageSize:ue??mr})));F({works:ke[0].entries,books:ke[1].entries,collections:ke[2].entries,entities:ke[3].entries,totalWorks:ke[0].total,totalBooks:ke[1].total,totalCollections:ke[2].total,totalEntities:ke[3].total})}}catch(ye){ze(ye instanceof Error?ye.message:String(ye)),F(null)}finally{ge(!1)}},[e,b]);g.useEffect(()=>{let T=!1;const ue=()=>{var Ke,We;const ye=["work","book","collection","entity"],ke=Promise.all(ye.map(ee=>e.loadEntries(ee,{page:1,pageSize:1}).catch(()=>({total:0})))),Ne=((Ke=e.getResourceCounts)==null?void 0:Ke.call(e).catch(()=>null))??Promise.resolve(null),Se=((We=e.getSubtypeStats)==null?void 0:We.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([ke,Ne,Se]).then(([ee,te,He])=>{T||(D({works:ee[0].total,books:ee[1].total,collections:ee[2].total,entities:ee[3].total,hasText:te==null?void 0:te.hasText,hasImage:te==null?void 0:te.hasImage}),He&&be(He))})};return e.getCounts?e.getCounts().then(ye=>{var ke,Ne;T||(D({works:ye.works,books:ye.books,collections:ye.collections,entities:ye.entities,hasText:(ke=ye.resourceCounts)==null?void 0:ke.hasText,hasImage:(Ne=ye.resourceCounts)==null?void 0:Ne.hasImage}),ye.subtypeStats&&be(ye.subtypeStats))}).catch(()=>{T||ue()}):ue(),()=>{T=!0}},[e]),g.useEffect(()=>{Re.current||!(u!=null&&u.trim())||(Re.current=!0,O(u))},[u,O]);const J=g.useCallback(T=>{if(z(T),!T.trim()){f==null||f(T),De(!0),F(null),ce(null),ne("all");return}ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{ce(null),ne("all"),f==null||f(T),O(T)},Cm)},[O,f]),fe=g.useCallback(T=>{ve.current&&clearTimeout(ve.current),ne("all"),f==null||f(T),O(T)},[O,f]),W=g.useCallback(T=>{ce(T),O(N,$m)},[N,O]);g.useEffect(()=>{if(!Pe.length){Y([]);return}let T=!1;return K(!0),Promise.all(Pe.slice(0,10).map(ue=>uo(e,ue))).then(ue=>{T||(Y(ue),K(!1))}),()=>{T=!0}},[Pe,e]);const se=T=>{B(T.id),Tr(T.id),G(Kt()),o==null||o(T)},X=(T,ue)=>{if(o&&Nm(ue)){ue.preventDefault(),se(T);return}Tr(T.id),G(Kt())},pe=T=>{Fl(T),G(Kt())},$e=()=>{po(),G([])},Ae=T=>S.find(ue=>ue.type===T),Oe=!we&&!M&&!me,Je=M&&(M.works.length>0||M.books.length>0||M.collections.length>0),Qe=t.jsxs(t.Fragment,{children:[t.jsx(Il,{transport:e,value:N,onChange:J,onSearch:fe,onEntrySelect:se}),b&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const T=N.trim();T&&Tl(T),fe(N)},children:_.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${r("primary")}`,borderRadius:"6px",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"13px"},children:_.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:v?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:Tm+(b?Im:"")}),(!b||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:r("fg")},children:_.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(Nl,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),b?t.jsxs("div",{className:"bim-ib-bar","data-nofilters":e.supportsSearchFilters?void 0:"true",children:[t.jsx("span",{"aria-hidden":"true"}),t.jsx("div",{className:"bim-ib-bar-main",children:Qe})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Qe}),we&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:q&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:de?t.jsxs(t.Fragment,{children:[(de.book??0)>0&&t.jsxs(t.Fragment,{children:[_.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:de.book.toLocaleString()})," ",_.unit.bu,_.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:q.books.toLocaleString()})," ",_.searchPage.statBookCopies]}),de.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:de.article.toLocaleString()})," ",_.searchPage.statArticleUnit]}):null,de.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:de.poem.toLocaleString()})," ",_.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:q.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[_.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:q.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:q.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:q.collections.toLocaleString()}),q.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:q.entities.toLocaleString()})]})]})}),q.hasImage!=null&&q.hasText!=null&&t.jsxs("span",{children:[_.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:q.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:q.hasText.toLocaleString()})]})]})}),b&&!we&&t.jsx(Wl,{transport:e,query:L,filters:Z,onFiltersChange:ae,onEntryLinkClick:X,typeName:T=>Ae(T).name,tab:w,onTabChange:k,page:j,onPageChange:C}),!(b&&!we)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:je||Oe?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:zm,boxSizing:"border-box"},children:_.search.searching}):me?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:me})}):we?t.jsx("div",{style:{flex:1},children:re?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:_.search.loading}):he.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:_.search.recentBrowse}),t.jsx("button",{onClick:$e,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:_.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:he.slice(0,A?10:3).map(T=>T.notFound?t.jsx(Am,{id:T.id,onRemove:pe,t:_},T.id):t.jsx(Js,{entry:T,selected:Le===T.id,onClick:X,getConfig:Ae,onRemove:pe},T.id))}),!A&&he.length>3&&t.jsx("button",{onClick:()=>U(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:_.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:_.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:_.search.searchSubtitle})]})}):Je?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:Em}),(()=>{const T=Se=>M[Zs[Se]]??0,ue=R.map(Se=>S.find(Ke=>Ke.type===Se)).filter(Se=>T(Se.key)>0);if(ue.length<2)return null;const ye=ue.reduce((Se,Ke)=>Se+T(Ke.key),0),ke=Se=>{if(ne(Se),Se!=="all"&&H!==Se){const Ke=S.find(ee=>ee.type===Se),We=(M[Ke.key]??[]).length;T(Ke.key)>We&&W(Se)}},Ne=Se=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(Se?"fg":"desc-fg"),fontWeight:Se?700:400,boxShadow:Se?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":_.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":V==="all",style:Ne(V==="all"),onClick:()=>ke("all"),children:[_.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:ye.toLocaleString()})]}),ue.map(Se=>t.jsxs("button",{type:"button","aria-pressed":V===Se.type,style:Ne(V===Se.type),onClick:()=>ke(Se.type),children:[Se.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:T(Se.key).toLocaleString()})]},Se.type))]})})(),S.map(({type:T,name:ue,key:ye})=>{const ke=M[ye]??[],Ne=Zs[ye],Se=M[Ne]??0;if(ke.length===0||V!=="all"&&V!==T)return null;const We=V==="all"&&!(H===T)&&Se>mr;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:[t.jsx(Sn,{type:T})," ",ue,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[Se," ",_.unit.items]})]}),We&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>W(T),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:_.action.viewAll})]}),t.jsx("div",{style:h==="list"?{display:"flex",flexDirection:"column",gap:0}:h==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:ke.map(ee=>{if(m)return t.jsx(g.Fragment,{children:m(ee)},ee.id);const te=h==="card"?Lm:Js;return t.jsx(te,{entry:ee,selected:Le===ee.id,onClick:X,getConfig:Ae,query:N},ee.id)})})]},T)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:bt(_.search.noResultsFor,{query:N})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:_.search.tryOther})]})})]})},zm=240;function Nm(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const Tm=`
120
+ `,yo="bim-search-view",hr=50,Qs=5,Dn=1e3;function xi(e){return e>=Dn?`${Dn.toLocaleString()}+`:e.toLocaleString()}const Om={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Wm(e){return e&&Om[e.toLowerCase()]||"all"}function Fm(e){return e==="all"?null:e}const ea=["work","collection","book","entity"],Hm={work:"works",collection:"collections",book:"books",entity:"entities"},Dm={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function Um(){try{return window.localStorage.getItem(yo)==="card"?"card":"table"}catch{return"table"}}function Vm(e){try{window.localStorage.setItem(yo,e)}catch{}}const pn=(e,n)=>(e==null?void 0:e[Dm[n]])??0,gr=(e,n)=>(e==null?void 0:e[Hm[n]])??[],Zl=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const h=Ee(),m=h.searchV4,{convert:u}=Me(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?i:Bi,[f,i]),[v,b]=g.useState("table");g.useEffect(()=>{b(Um())},[]);const _=G=>{b(G),Vm(G)},[y,w]=g.useState(l??"all"),j=g.useRef(y);j.current=y,g.useEffect(()=>{l!==void 0&&l!==j.current&&(w(l),C(1))},[l]);const[k,C]=g.useState(c&&c>0?c:1),$=g.useRef(k);$.current=k,g.useEffect(()=>{c!==void 0&&c>0&&c!==$.current&&C(c)},[c]);const S=g.useRef(null),E=g.useCallback(G=>{var q;C(G),p==null||p(G);const he=S.current;he&&he.getBoundingClientRect().top<0&&((q=he.scrollIntoView)==null||q.call(he,{block:"start",behavior:"instant"}))},[p]),[N,z]=g.useState(null),[O,F]=g.useState(null),[A,I]=g.useState(!1),[P,K]=g.useState(""),oe=$i(x).toString(),le=Fi(x)>0,H=$i({...x,sort:""}).toString(),de=g.useRef({query:n,filterOnlyKey:H,sort:x.sort});g.useEffect(()=>{const G=de.current;G.query!==n||G.filterOnlyKey!==H?(w("all"),C(1)):G.sort!==x.sort&&C(1),de.current={query:n,filterOnlyKey:H,sort:x.sort}},[n,H,x.sort]),g.useEffect(()=>{let G=!1;return I(!0),K(""),(async()=>{try{let he;if(e.searchAll)he=await e.searchAll(n,Qs,x);else{const q=["work","book","collection","entity"],se=await Promise.all(q.map(Y=>e.search(n,Y,{page:1,pageSize:Qs,filters:x})));he={works:se[0].entries,books:se[1].entries,collections:se[2].entries,entities:se[3].entries,totalWorks:se[0].total,totalBooks:se[1].total,totalCollections:se[2].total,totalEntities:se[3].total}}G||z(he)}catch(he){G||(K(he instanceof Error?he.message:String(he)),z(null))}finally{G||I(!1)}})(),()=>{G=!0}},[e,n,oe]);const U=y;g.useEffect(()=>{if(y==="all"){F(null);return}let G=!1;return I(!0),(async()=>{try{const he=await e.search(n,y,{page:k,pageSize:hr,filters:x});G||F({key:U,entries:he.entries,total:he.total})}catch(he){G||(K(he instanceof Error?he.message:String(he)),F(null))}finally{G||I(!1)}})(),()=>{G=!0}},[e,n,oe,y,k]);const te=O&&O.key===U?O:null;g.useEffect(()=>{if(y==="all"||!te||A)return;const G=Math.min(te.total,Dn),he=Am(k,G,hr);te.entries.length===0&&G>0&&he!==k&&(C(he),p==null||p(he))},[y,te,A,k]);const ve=g.useMemo(()=>ea.filter(G=>pn(N,G)>0),[N]),fe=ve.reduce((G,he)=>G+pn(N,he),0),Ae=ve.some(G=>pn(N,G)>=Dn)?`${fe.toLocaleString()}+`:fe.toLocaleString(),B=!A&&!P&&N!==null&&fe===0,me=g.useCallback(G=>{w(G),C(1),d==null||d(G)},[d]),ze=g.useMemo(()=>{const G=[];return x.dynasty.forEach(he=>G.push({name:he,remove:()=>o({...x,dynasty:x.dynasty.filter(q=>q!==he)})})),x.classification.forEach(he=>{var q;return G.push({name:he?((q=Wi.find(se=>se.value===he))==null?void 0:q.label)??he:h.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(se=>se!==he)})})}),x.hasImage&&G.push({name:m.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&G.push({name:m.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&G.push({name:m.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&G.push({name:`${m.extant}:${h.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),G},[x,o,m,h]),we={query:n,onEntryLinkClick:s,typeName:a},De=G=>v==="table"?t.jsx(Zs,{entries:G,...we}):t.jsx(Js,{entries:G,...we}),Pe=ea.flatMap(G=>gr(N,G));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:Bm}),f&&t.jsx(Rm,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":A,ref:S,children:[ve.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":h.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs(ta,{on:y==="all",onClick:()=>me("all"),children:[h.search.allTab," ",t.jsx("small",{children:Ae})]}),ve.map(G=>t.jsxs(ta,{on:y===G,onClick:()=>me(G),children:[a(G)," ",t.jsx("small",{children:xi(pn(N,G))})]},G))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:u(m.sortRelevance)}),["era","title"].map(G=>{const he=x.sort.startsWith(`${G}:`)?x.sort.endsWith("desc")?"desc":"asc":null,q=G==="era"?m.sortEra:m.sortTitle,se=G==="era"?he==="desc"?m.sortEraDesc:m.sortEraAsc:he==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":he!==null,title:u(se),onClick:()=>o({...x,sort:`${G}:${he==="asc"?"desc":"asc"}`}),children:[u(q),he?t.jsxs("span",{"aria-hidden":"true",children:[" ",he==="asc"?"↑":"↓"]}):null]},G)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":v==="table",onClick:()=>_("table"),children:u(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":v==="card",onClick:()=>_("card"),children:u(m.viewCard)})]})]}),le&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:u(bt(m.filteredCount,{n:Ae}))}),ze.map(G=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(bt(m.removeFilter,{name:G.name})),onClick:G.remove,children:[u(G.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},G.name))]}),P&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:P}),B&&t.jsx("div",{className:"bim-sr-empty",children:u(le?m.emptyFiltered:bt(h.search.noResultsFor,{query:n}))}),!P&&!B&&y==="all"&&N&&(v==="table"?t.jsxs(t.Fragment,{children:[t.jsx(Zs,{entries:Pe,...we}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(m.limitedNote)})]}):t.jsx(t.Fragment,{children:ve.map(G=>t.jsxs("section",{style:{marginTop:22},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[t.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[t.jsx(_n,{type:G,size:8}),a(G),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[xi(pn(N,G))," ",h.unit.items]})]}),pn(N,G)>gr(N,G).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>me(G),children:h.action.viewAll})]}),t.jsx(Js,{entries:gr(N,G),...we})]},G))})),!P&&y!=="all"&&!te&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:h.search.loading}),!P&&y!=="all"&&te&&te.entries.length>0&&t.jsxs(t.Fragment,{children:[De(te.entries),t.jsx(Mm,{page:k,pageSize:hr,total:Math.min(te.total,Dn),totalLabel:xi(te.total),onPage:E})]}),!P&&y!=="all"&&te&&te.entries.length===0&&!A&&t.jsxs("div",{className:"bim-sr-empty",children:[u(le?m.emptyFiltered:bt(h.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>me("all"),children:h.search.allTab})})]})]})]})};function ta({on:e,onClick:n,children:i}){return t.jsx("button",{type:"button","aria-pressed":e,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:r(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${r("accent")}`:"none"},children:i})}const yn="bim-recent-ids",na="bim-recent-entries",ia=50;function Kt(){try{const e=localStorage.getItem(yn);if(e)return JSON.parse(e);const n=localStorage.getItem(na);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(yn,JSON.stringify(i)),localStorage.removeItem(na),i}return[]}catch{return[]}}function Lr(e){try{const n=Kt().filter(i=>i!==e);n.unshift(e),n.length>ia&&(n.length=ia),localStorage.setItem(yn,JSON.stringify(n))}catch{}}function Jl(e){try{const n=Kt().filter(i=>i!==e);localStorage.setItem(yn,JSON.stringify(n))}catch{}}function jo(){try{localStorage.removeItem(yn)}catch{}}async function vo(e,n){var i,o,s;try{if(e.getEntry){const l=await e.getEntry(n);if(l)return l}const a=await e.getItem(n);if(a){const l=a.authors;return{id:n,title:a.title||n,type:a.type||"work",author:(i=l==null?void 0:l[0])==null?void 0:i.name,dynasty:(o=l==null?void 0:l[0])==null?void 0:o.dynasty,role:(s=l==null?void 0:l[0])==null?void 0:s.role,edition:a.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const fr=5,Gm=50,Ym=200,ra={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Ar=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:h="compact",renderEntry:m,initialQuery:u,onQueryChange:f,headerRight:x,reserveViewportHeight:v=!1,filtersEnabled:b=!1,filters:_=Bi,onFiltersChange:y,resultTab:w,onResultTabChange:j,resultPage:k,onResultPageChange:C})=>{const $=Ee(),S=[{type:"work",name:$.indexType.work,key:"works"},{type:"book",name:$.indexType.book,key:"books"},{type:"collection",name:$.indexType.collection,key:"collections"},{type:"entity",name:$.indexType.entity,key:"entities"}],E=["work","collection","book","entity"],[N,z]=g.useState(u??""),[O,F]=g.useState(null),[A,I]=g.useState(u??""),P=$i(_).toString(),[K,oe]=g.useState(_);g.useEffect(()=>{oe(_)},[P]);const le=T=>{oe(T),y==null||y(T)},[H,de]=g.useState(null),[U,te]=g.useState("all"),[ve,fe]=g.useState(!1),[Ae,B]=g.useState(null),[me,ze]=g.useState(""),[we,De]=g.useState(!(u!=null&&u.trim())),[Pe,G]=g.useState(Kt),[he,q]=g.useState([]),[se,Y]=g.useState(!1),[M,X]=g.useState(!1),[J,D]=g.useState(null),[ye,ue]=g.useState(null),ge=g.useRef(void 0),Ie=g.useRef(!1),L=g.useCallback(async(T,pe)=>{if(!T.trim()){De(!0),F(null),de(null);return}if(De(!1),b){I(T);return}fe(!0),ze("");try{if(e.searchAll){const xe=await e.searchAll(T,pe??fr);F(xe)}else{const xe=["work","book","collection","entity"],ke=await Promise.all(xe.map(Ne=>e.search(T,Ne,{page:1,pageSize:pe??fr})));F({works:ke[0].entries,books:ke[1].entries,collections:ke[2].entries,entities:ke[3].entries,totalWorks:ke[0].total,totalBooks:ke[1].total,totalCollections:ke[2].total,totalEntities:ke[3].total})}}catch(xe){ze(xe instanceof Error?xe.message:String(xe)),F(null)}finally{fe(!1)}},[e,b]);g.useEffect(()=>{let T=!1;const pe=()=>{var Ke,Oe;const xe=["work","book","collection","entity"],ke=Promise.all(xe.map(Q=>e.loadEntries(Q,{page:1,pageSize:1}).catch(()=>({total:0})))),Ne=((Ke=e.getResourceCounts)==null?void 0:Ke.call(e).catch(()=>null))??Promise.resolve(null),Se=((Oe=e.getSubtypeStats)==null?void 0:Oe.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([ke,Ne,Se]).then(([Q,ee,Fe])=>{T||(D({works:Q[0].total,books:Q[1].total,collections:Q[2].total,entities:Q[3].total,hasText:ee==null?void 0:ee.hasText,hasImage:ee==null?void 0:ee.hasImage}),Fe&&ue(Fe))})};return e.getCounts?e.getCounts().then(xe=>{var ke,Ne;T||(D({works:xe.works,books:xe.books,collections:xe.collections,entities:xe.entities,hasText:(ke=xe.resourceCounts)==null?void 0:ke.hasText,hasImage:(Ne=xe.resourceCounts)==null?void 0:Ne.hasImage}),xe.subtypeStats&&ue(xe.subtypeStats))}).catch(()=>{T||pe()}):pe(),()=>{T=!0}},[e]),g.useEffect(()=>{Ie.current||!(u!=null&&u.trim())||(Ie.current=!0,L(u))},[u,L]);const ie=g.useCallback(T=>{if(z(T),!T.trim()){f==null||f(T),De(!0),F(null),de(null),te("all");return}ge.current&&clearTimeout(ge.current),ge.current=setTimeout(()=>{de(null),te("all"),f==null||f(T),L(T)},Ym)},[L,f]),je=g.useCallback(T=>{ge.current&&clearTimeout(ge.current),te("all"),f==null||f(T),L(T)},[L,f]),W=g.useCallback(T=>{de(T),L(N,Gm)},[N,L]);g.useEffect(()=>{if(!Pe.length){q([]);return}let T=!1;return Y(!0),Promise.all(Pe.slice(0,10).map(pe=>vo(e,pe))).then(pe=>{T||(q(pe),Y(!1))}),()=>{T=!0}},[Pe,e]);const ae=T=>{B(T.id),Lr(T.id),G(Kt()),o==null||o(T)},V=(T,pe)=>{if(o&&qm(pe)){pe.preventDefault(),ae(T);return}Lr(T.id),G(Kt())},re=T=>{Jl(T),G(Kt())},_e=()=>{jo(),G([])},Le=T=>S.find(pe=>pe.type===T),He=!we&&!O&&!me,qe=O&&(O.works.length>0||O.books.length>0||O.collections.length>0),Xe=t.jsxs(t.Fragment,{children:[t.jsx(Rl,{transport:e,value:N,onChange:ie,onSearch:je,onEntrySelect:ae}),b&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const T=N.trim();T&&Il(T),je(N)},children:$.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${r("primary")}`,borderRadius:"6px",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"13px"},children:$.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:v?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:Xm+(b?Zm:"")}),(!b||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:r("fg")},children:$.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(Tl,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),b?t.jsxs("div",{className:"bim-ib-bar","data-nofilters":e.supportsSearchFilters?void 0:"true",children:[t.jsx("span",{"aria-hidden":"true"}),t.jsx("div",{className:"bim-ib-bar-main",children:Xe})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Xe}),we&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:J&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:ye?t.jsxs(t.Fragment,{children:[(ye.book??0)>0&&t.jsxs(t.Fragment,{children:[$.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:ye.book.toLocaleString()})," ",$.unit.bu,$.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:J.books.toLocaleString()})," ",$.searchPage.statBookCopies]}),ye.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:ye.article.toLocaleString()})," ",$.searchPage.statArticleUnit]}):null,ye.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:ye.poem.toLocaleString()})," ",$.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:J.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[$.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:J.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:J.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:J.collections.toLocaleString()}),J.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:J.entities.toLocaleString()})]})]})}),J.hasImage!=null&&J.hasText!=null&&t.jsxs("span",{children:[$.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:J.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),$.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:J.hasText.toLocaleString()})]})]})}),b&&!we&&t.jsx(Zl,{transport:e,query:A,filters:K,onFiltersChange:le,onEntryLinkClick:V,typeName:T=>Le(T).name,tab:w,onTabChange:j,page:k,onPageChange:C}),!(b&&!we)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ve||He?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:Km,boxSizing:"border-box"},children:$.search.searching}):me?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:me})}):we?t.jsx("div",{style:{flex:1},children:se?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:$.search.loading}):he.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:$.search.recentBrowse}),t.jsx("button",{onClick:_e,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:$.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:he.slice(0,M?10:3).map(T=>T.notFound?t.jsx(th,{id:T.id,onRemove:re,t:$},T.id):t.jsx(oa,{entry:T,selected:Ae===T.id,onClick:V,getConfig:Le,onRemove:re},T.id))}),!M&&he.length>3&&t.jsx("button",{onClick:()=>X(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:$.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:$.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:$.search.searchSubtitle})]})}):qe?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:Jm}),(()=>{const T=Se=>O[ra[Se]]??0,pe=E.map(Se=>S.find(Ke=>Ke.type===Se)).filter(Se=>T(Se.key)>0);if(pe.length<2)return null;const xe=pe.reduce((Se,Ke)=>Se+T(Ke.key),0),ke=Se=>{if(te(Se),Se!=="all"&&H!==Se){const Ke=S.find(Q=>Q.type===Se),Oe=(O[Ke.key]??[]).length;T(Ke.key)>Oe&&W(Se)}},Ne=Se=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(Se?"fg":"desc-fg"),fontWeight:Se?700:400,boxShadow:Se?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":$.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":U==="all",style:Ne(U==="all"),onClick:()=>ke("all"),children:[$.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:xe.toLocaleString()})]}),pe.map(Se=>t.jsxs("button",{type:"button","aria-pressed":U===Se.type,style:Ne(U===Se.type),onClick:()=>ke(Se.type),children:[Se.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:T(Se.key).toLocaleString()})]},Se.type))]})})(),S.map(({type:T,name:pe,key:xe})=>{const ke=O[xe]??[],Ne=ra[xe],Se=O[Ne]??0;if(ke.length===0||U!=="all"&&U!==T)return null;const Oe=U==="all"&&!(H===T)&&Se>fr;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:[t.jsx(_n,{type:T})," ",pe,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[Se," ",$.unit.items]})]}),Oe&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>W(T),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:$.action.viewAll})]}),t.jsx("div",{style:h==="list"?{display:"flex",flexDirection:"column",gap:0}:h==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:ke.map(Q=>{if(m)return t.jsx(g.Fragment,{children:m(Q)},Q.id);const ee=h==="card"?eh:oa;return t.jsx(ee,{entry:Q,selected:Ae===Q.id,onClick:V,getConfig:Le,query:N},Q.id)})})]},T)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:bt($.search.noResultsFor,{query:N})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:$.search.tryOther})]})})]})},Km=240;function qm(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const Xm=`
121
121
  .bim-ib-stats { min-height: 25px; box-sizing: content-box; }
122
122
  @media (max-width: 719px) { .bim-ib-stats { min-height: 46px; } }
123
- `,Im=`
123
+ `,Zm=`
124
124
  .bim-ib-bar { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; padding: 0 20px 16px; }
125
125
  .bim-ib-bar[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
126
126
  .bim-ib-bar[data-nofilters] > [aria-hidden] { display: none; }
@@ -135,20 +135,20 @@
135
135
  .bim-ib-bar-main { max-width: none; }
136
136
  .bim-ib-submit { min-height: 44px; padding: 0 16px; }
137
137
  }
138
- `,Em=`
138
+ `,Jm=`
139
139
  @media (max-width: 719px), (pointer: coarse) {
140
140
  .bim-ib-viewall { position: relative; }
141
141
  .bim-ib-viewall::after {
142
142
  content: ""; position: absolute; left: 50%; top: 50%;
143
143
  width: max(calc(100% + 8px), 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
144
144
  }
145
- }`,Hl={color:"inherit",textDecoration:"none"},Rm=({snippet:e})=>{const{convert:n}=Me();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:no(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(g.Fragment,{children:n(i.text)},o))})},Lm=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Ee(),{convert:l}=Me(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],h=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=r("cover-accent"),u=rt();return t.jsxs("a",{href:u(e.id),onClick:f=>i(e,f),className:"bim-result-card",style:{...Hl,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:r("bg"),border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${m} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${r("bg")}), color-mix(in srgb, ${m} 7%, ${r("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${m} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:m},children:Array.from(d).map((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:r("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",l(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:l(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",l(e.role)]})]}),(e.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),h&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof h=="string"?h:h.book_title||"")]}),e.descriptionSnippet&&t.jsx(Rm,{snippet:e.descriptionSnippet}),t.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[t.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:[t.jsx(Sn,{type:e.type,size:8})," ",o(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.imageResource})]})]})]})},Js=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Ee(),{convert:d}=Me(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const u=typeof m=="string"?m:m==null?void 0:m.book_title;return u==null?void 0:u.toLowerCase().includes(s.toLowerCase())}):void 0,h=rt();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("a",{href:h(e.id),onClick:m=>i(e,m),className:"bim-result-card",style:{...Hl,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:a?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[t.jsx(Sn,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:r("desc-fg"),lineHeight:1},children:o(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:d(e.title||e.primary_name||e.id)}),t.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[e.has_text&&t.jsx("span",{children:l.misc.textResource}),e.has_image&&t.jsx("span",{children:l.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",d(e.era),"〕"]}),e.edition&&d(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.juan_count,l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",d(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:d(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",d(e.role)]}),e.type==="entity"&&(e.birth_year!=null||e.death_year!=null)&&t.jsxs("span",{style:{marginLeft:e.dynasty?"4px":0},children:[e.birth_year??"?","—",e.death_year??"?"]})]}),p&&t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:[l.search.alias,":",d(p)]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),a&&t.jsx("button",{type:"button",onClick:()=>a(e.id),title:l.search.removeFromRecent,"aria-label":l.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},Am=({id:e,onRemove:n,t:i})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${r("widget-border")}`,background:r("input-bg"),opacity:.6},children:[t.jsx("span",{style:{fontSize:"16px"},children:"❓"}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:"13px",color:r("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:i.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:i.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function Mm(e){var n,i,o;return!e.dynasty&&((n=e.dates)==null?void 0:n.birth)==null&&((i=e.dates)==null?void 0:i.death)==null&&(!e.alt_names||e.alt_names.length===0)&&!((o=e.description)!=null&&o.text)}function Pm({data:e}){var l,d;const{convert:n}=Me(),{dynasty:i}=e,o=((l=e.dates)==null?void 0:l.birth)??void 0,s=((d=e.dates)==null?void 0:d.death)??void 0,a=[];return i&&a.push(`〔${n(i)}〕`),o!==void 0&&s!==void 0?a.push(`${o}—${s}`):o!==void 0?a.push(`${o}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:r("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function Bm({alt_names:e}){const{convert:n}=Me(),i=new Map;for(const a of e){const l=a.type||"別名";i.has(l)||i.set(l,[]),i.get(l).push(a.name)}const o=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...i.keys()].sort((a,l)=>{const d=o.indexOf(a),c=o.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=i.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(a)}),t.jsx("span",{children:l.map((d,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function Om({data:e}){const n=Ee(),i=e.external_ids;if(!i)return null;const o=[];return i.cbdb_id&&o.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${i.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:r("link-fg"),border:`1px solid ${r("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${r("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",i.cbdb_id]},"cbdb")),o.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:o})}function Wm({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Ee(),{convert:a}=Me(),l=rt(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let u=!1;const f=e.map(v=>v.work_id);return(async()=>{const v=new Map;if(n.getEntriesByIds)try{const w=await n.getEntriesByIds(f);let k=!0;for(let j=0;j<f.length;j++){const C=w[j];C!=null&&C.title?v.set(f[j],C.title):C!=null&&C.primary_name?v.set(f[j],C.primary_name):k=!1}if(k)return v}catch{}const b=[...f],$=8,y=new Array($).fill(0).map(async()=>{for(;b.length;){const w=b.shift();if(!w)break;if(!v.has(w))try{if(n.getEntry){const C=await n.getEntry(w);if(C!=null&&C.title){v.set(w,C.title);continue}}const k=await n.getItem(w),j=k&&(k.title||k.primary_name)||w;v.set(w,j)}catch{v.set(w,w)}}});return await Promise.all(y),v})().then(v=>{u||c(v)}),()=>{u=!0}},[e,n]);const p=new Map;for(const u of e){const f=u.role||"";p.has(f)||p.set(f,[]),p.get(f).push(u)}const h=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((u,f)=>{const x=h.indexOf(u),v=h.indexOf(f);return x===-1&&v===-1?u.localeCompare(f):x===-1?1:v===-1?-1:x-v});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(u=>{const f=p.get(u);return t.jsxs("div",{style:{marginBottom:"8px"},children:[u&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(u)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:u?"16px":"0",listStyle:u?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,v)=>{const b=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,b)},v):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:$=>{$.metaKey||$.ctrlKey||($.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:b})},v):t.jsx("li",{children:b},v)})})]},u)})]})}const Dl=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var m;const l=Ee(),{convert:d}=Me();let c=!1;try{c=_e.extractStatus(e.id)==="draft"}catch{}const p=Mm(e),h=e.subtype&&e.subtype in l.common.entitySubtype?l.common.entitySubtype[e.subtype]:d(e.subtype);return t.jsxs("div",{children:[!a&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:r("fg")},children:[d(e.primary_name),t.jsx(Pm,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:r("type-entity"),border:`1px solid color-mix(in srgb, ${r("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${r("type-entity")} 3%, transparent)`},children:l.indexType.entity}),h&&e.subtype!=="people"&&t.jsx("span",{children:h}),c&&t.jsx("span",{style:{padding:"1px 6px",background:r("warn-bg"),border:`1px solid ${r("warn-border")}`,borderRadius:"2px",color:r("warn-fg")},children:l.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),p&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:r("widget-bg"),border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(Bm,{alt_names:e.alt_names}),t.jsx(Om,{data:e}),((m=e.description)==null?void 0:m.text)&&t.jsx("p",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(Wm,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},Fm=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Hm(e){const n=e.search(Fm);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Ul={p:({children:e})=>t.jsx("p",{style:{margin:"0 0 0.5em"},children:e}),ul:({children:e})=>t.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:e}),ol:({children:e})=>t.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:e}),li:({children:e})=>t.jsx("li",{style:{marginBottom:"2px"},children:e}),a:({href:e,children:n})=>{let i=e,o="",s=n;if(e&&typeof n=="string"&&(n===e||n===Dm(e))){const[a,l]=Hm(n);l&&(i=encodeURI(a),s=a,o=l)}return t.jsxs(t.Fragment,{children:[t.jsx("a",{href:i,target:i!=null&&i.startsWith("http")?"_blank":void 0,rel:i!=null&&i.startsWith("http")?"noopener noreferrer":void 0,style:{color:r("link")},children:s}),o]})},code:({children:e})=>t.jsx("code",{style:{background:r("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function Dm(e){try{return decodeURI(e)}catch{return e}}const Um={...Ul,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Ht=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Me(),a=n?Um:Ul;return t.jsx("div",{className:o,style:i,children:t.jsx(hu,{remarkPlugins:[gu],components:a,children:s(e)})})},Vm=["〇","一","二","三","四","五","六","七","八","九"],Qs=["","十","百","千"];function Vl(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=Qs[d]:o+=Vm[l]+Qs[d])}return o}function Gl(e){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:e,border:`1px solid color-mix(in srgb, ${e} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${e} 3%, transparent)`}}const Gm={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function Ym({type:e}){const n=Ee();return t.jsx("span",{style:Gl(Gm[e]),children:n.indexType[e]})}function Km({isDraft:e}){const n=Ee(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:Gl(i),children:e?n.status.draft:n.status.official})}function qm({id:e}){const n=Ee(),[i,o]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function jt({children:e,extra:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function Tt({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:r("fg")},children:n})]})}function Yl({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Me();return t.jsx("span",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx($t,{id:a.entity_id,label:d,onNavigate:i,renderLink:o}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function $t({id:e,label:n,onNavigate:i,renderLink:o}){const s=rt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`,paddingBottom:"1px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{children:n||e})}function Xm({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:h}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:r("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,i&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:i}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:l})]}),c&&t.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[t.jsx(Ym,{type:o}),t.jsx(Km,{isDraft:s}),t.jsx(qm,{id:e})]}),((a==null?void 0:a.length)||d.length>0)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[a&&a.length>0&&t.jsx(Yl,{authors:a,type:o,onNavigate:p,renderLink:h}),d]})]})}function Kl({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Ee(),{convert:l}=Me();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,h)=>{const m=d===h;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?null:h),style:{padding:"8px 12px",background:r("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!m&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:u=>u.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx($t,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),m&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${r("widget-border")}`},children:[i&&(p.title_info||p.author_info||p.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&t.jsx(Tt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Tt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Tt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:l(p.summary)})]}),p.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.comment)})]}),p.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},h)})})]})}function Zm({items:e,onNavigate:n,renderLink:i}){const o=Ee();return t.jsx(Kl,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function ql({items:e,onNavigate:n,renderLink:i}){const o=Ee();return t.jsx(Kl,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function Xl({label:e,items:n}){const{convert:i}=Me();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((o,s)=>{const a=typeof o=="string"?o:o.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:i(a)},s)})})]}):null}function Jm({items:e}){const n=Ee();return t.jsx(Xl,{label:n.section.aliases,items:e})}function Qm({items:e}){const n=Ee();return t.jsx(Xl,{label:n.section.attachedTexts,items:e})}function eh({items:e}){const n=Ee(),{convert:i}=Me();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((o,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:["《",i(o.book_title),"》",o.n_juan!=null&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:[o.n_juan,n.unit.juan]})]},s))})]}):null}function th({items:e}){const n=Ee(),{convert:i}=Me();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:n.section.locationHistory}),t.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[t.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:r("widget-border")}}),e.map((o,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:r("primary"),border:`1.5px solid ${r("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:r("fg")},children:i(o.name)}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function nh({items:e}){const n=Ee(),{convert:i}=Me();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((o,s)=>t.jsxs("div",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:r("desc-fg")},children:"·"}),i(o)]},s))})]}):null}function ea({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Me(),[l,d]=g.useState([]);return g.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(h=>({id:p,title:h?h.title:void 0,edition:h?h.edition:void 0,type:h?h.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(jt,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(l.length?l:n.map(c=>({id:c}))).map(c=>{const p=c.edition?`${a(c.title)||c.id}(${a(c.edition)})`:a(c.title)||void 0;return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),transition:"border-color 0.15s"},children:t.jsx($t,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function hr({book:e,onNavigate:n,renderLink:i}){const o=Ee(),{convert:s}=Me(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx($t,{id:e.id,label:c,onNavigate:n,renderLink:i})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:r("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?o.action.expand:o.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(lo,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function ih({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Ee(),{convert:d}=Me(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(v=>({id:v})));return}let x=!1;return Promise.all(e.map(v=>i.getItem(v).then(b=>({id:v,title:b?b.title:void 0,edition:b?b.edition:void 0,resources:b?b.resources:void 0,resource_groups:b?b.resource_groups:void 0})).catch(()=>({id:v})))).then(v=>{x||p(v)}),()=>{x=!0}},[e,i]),!e.length)return null;const h=c.length?c:e.map(x=>({id:x})),m=new Map(h.map(x=>[x.id,x])),u=n==null?void 0:n.version_graph,f=rh(e,u,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(jt,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,f.useGrouping?t.jsxs(t.Fragment,{children:[f.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:f.coreIds.map(x=>{const v=m.get(x);return v?t.jsx(hr,{book:v,onNavigate:o,renderLink:s},x):null})}),f.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${r("widget-border")}`,borderRadius:6,background:r("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:r("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:r("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:r("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(v=>{const b=m.get(v);return b?t.jsx(hr,{book:b,onNavigate:o,renderLink:s},v):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.map(x=>t.jsx(hr,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function rh(e,n,i){var $,y;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=($=n.collections)==null?void 0:$[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),h=w=>{if(p.has(w))return!0;const k=n.node_groups[w];return k!=null&&c.has(k)},m=[],u=new Map,f=[];for(const w of e)if(!((y=n.excluded_books)!=null&&y.includes(w)))if(h(w))m.push(w);else{const k=n.node_groups[w];k?(u.has(k)||u.set(k,[]),u.get(k).push(w)):f.push(w)}if(f.length+[...u.values()].reduce((w,k)=>w+k.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const v=new Map((n.groups??[]).map(w=>[w.id,w])),b=[...u.entries()].map(([w,k])=>{const j=v.get(w);return{id:w,label:(j==null?void 0:j.label)??w,description:j==null?void 0:j.description,ids:k}});return f.length>0&&b.push({id:"__other__",label:i,description:void 0,ids:f}),{useGrouping:!0,coreIds:m,groupedIds:b}}function oh({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Ee(),{convert:s}=Me(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:r("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:t.jsx($t,{id:e.id,label:s(e.title),onNavigate:n,renderLink:i})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:s(e.measure_info)}):((d=e.juan_count)==null?void 0:d.number)!=null&&e.juan_count.number>0?t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[Vl(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Yl,{authors:e.authors,type:"work",onNavigate:n,renderLink:i})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(Ht,{text:e.description.text,style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,textAlign:"justify"}}),e.parent_work&&t.jsx("div",{style:{marginTop:(p=e.description)!=null&&p.text?"8px":0,fontSize:"13px"},children:t.jsx(Tt,{label:o.label.parentWork,children:t.jsx($t,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function sh({items:e,onNavigate:n,renderLink:i}){const o=Ee(),{convert:s}=Me();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(a=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${r("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${r("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:r("type-collection")},children:o.indexType.collection}),t.jsx($t,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:i}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"2px"},children:bt(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const mo=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var M,F,L,E,P,Z,oe,ae;const p=Ee(),{convert:h}=Me(),[m,u]=g.useState(null),[f,x]=g.useState(!1),[v,b]=g.useState(null),[$,y]=g.useState(null),[w,k]=g.useState([]),j=e||m;if(g.useEffect(()=>{if(e||!n||!i)return;let H=!1;return x(!0),b(null),i.getItem(n).then(ce=>{H||(ce?u(ce):b(p.misc.notFoundEntry))}).catch(ce=>{H||b(ce instanceof Error?ce.message:p.misc.loadFailed)}).finally(()=>{H||x(!1)}),()=>{H=!0}},[e,n,i]),g.useEffect(()=>{if(!j||!i){y(null),k([]);return}let H=!1;const ce=j.type==="book"||j.type==="collection"?j.work_id:void 0;if(ce?i.getItem(ce).then(V=>{!H&&V&&V.type==="work"&&y(V)}).catch(()=>{}):y(null),j.type==="book"){const V=j;V.contained_in&&V.contained_in.length>0?Promise.all(V.contained_in.map(ne=>{const je=typeof ne=="string"?ne:ne.id,ge=typeof ne=="string"?void 0:ne.volume_index;return i.getItem(je).then(Le=>({id:je,title:Le&&Le.title||je,volume_index:ge})).catch(()=>({id:je,title:je,volume_index:ge}))})).then(ne=>{H||k(ne)}):k([])}else k([]);return()=>{H=!0}},[j,i]),f)return t.jsx("div",{className:d,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((H,ce)=>t.jsx("div",{style:{height:ce===1?"32px":"16px",width:`${H}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},ce))})});if(v)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:v});if(!j)return null;if(j.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(Dl,{data:j,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const C=j.type==="book"?j:null,_=j.type==="collection"?j:null,S=j.type==="work"?j:null;let R=!1;try{R=_e.extractStatus(j.id)==="draft"}catch{}let N="";j.measure_info?N=h(j.measure_info):(M=j.juan_count)!=null&&M.number?N=Vl(j.juan_count.number)+p.unit.juan:(F=j.juan_count)!=null&&F.description&&(N=h(j.juan_count.description));const z=[];return(L=j.publication_info)!=null&&L.year&&z.push(t.jsx(Tt,{label:p.label.year,children:j.publication_info.year},"year")),(E=j.current_location)!=null&&E.name&&z.push(t.jsx(Tt,{label:p.label.currentLocation,children:h(j.current_location.name)},"loc")),(P=j.page_count)!=null&&P.description&&z.push(t.jsx(Tt,{label:p.label.pageCount,children:j.page_count.description},"page")),C!=null&&C.edition&&z.push(t.jsx(Tt,{label:p.label.edition,children:h(C.edition)},"ver")),S!=null&&S.parent_work&&z.push(t.jsx(Tt,{label:p.label.parentWork,children:t.jsx($t,{id:S.parent_work.id,label:h(S.parent_work.title),onNavigate:o,renderLink:s})},"pw")),S!=null&&S.parent_works&&S.parent_works.length>0&&!S.parent_work&&z.push(t.jsx(Tt,{label:p.label.parentWork,children:S.parent_works.map((H,ce)=>t.jsxs("span",{children:[ce>0&&"、",t.jsx($t,{id:H,onNavigate:o,renderLink:s})]},H))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Xm,{id:j.id,title:h(j.title),edition:j.edition?h(j.edition):void 0,type:j.type,isDraft:R,authors:j.authors,volumeText:N,meta:z,headerExtra:a,onNavigate:o,renderLink:s}),((Z=j.description)==null?void 0:Z.text)&&t.jsx(Ht,{text:j.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),j.appendix&&j.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:j.appendix.map((H,ce)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:r("bg-subtle"),borderRadius:4,border:`1px solid ${r("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:r("muted")},children:h(H.title)}),t.jsx(Ht,{text:H.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},ce))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:p.section.containedIn}),t.jsx(sh,{items:w,onNavigate:o,renderLink:s})]}),$&&t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:p.section.belongsToWork}),t.jsx(oh,{workData:$,onNavigate:o,renderLink:s})]}),j.additional_works&&j.additional_works.length>0&&t.jsx(eh,{items:j.additional_works}),j.additional_titles&&j.additional_titles.length>0&&t.jsx(Jm,{items:j.additional_titles}),j.attached_texts&&j.attached_texts.length>0&&t.jsx(Qm,{items:j.attached_texts}),j.indexed_by&&j.indexed_by.length>0&&t.jsx(Zm,{items:j.indexed_by,onNavigate:o,renderLink:s}),j.emendated_by&&j.emendated_by.length>0&&t.jsx(ql,{items:j.emendated_by,onNavigate:o,renderLink:s}),j.resources&&j.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:p.section.resources}),t.jsx(lo,{items:j.resources,resourceGroups:j.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),(C==null?void 0:C.location_history)&&C.location_history.length>0&&t.jsx(th,{items:C.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&t.jsx(nh,{items:_.history}),(C==null?void 0:C.related_books)&&C.related_books.length>0&&t.jsx(ea,{title:p.section.relatedVersions,ids:C.related_books,transport:i,onNavigate:o,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&t.jsx(ea,{title:p.section.containedBooks,ids:_.books,transport:i,onNavigate:o,renderLink:s}),(_==null?void 0:_.contained_works)&&_.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(jt,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",_.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.contained_works.map(H=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx($t,{id:H.id,label:h(H.title),onNavigate:o,renderLink:s})},H.id))})]}),(((oe=S==null?void 0:S.books)==null?void 0:oe.length)||0)+(((ae=S==null?void 0:S.collections)==null?void 0:ae.length)||0)>0&&t.jsx(ih,{ids:[...(S==null?void 0:S.books)||[],...(S==null?void 0:S.collections)||[]],workData:S??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),(S==null?void 0:S.related_works)&&S.related_works.length>0&&(()=>{const H=[],ce=S.related_works.filter(B=>B.relation==="part_of"),V=S.related_works.filter(B=>B.relation==="has_part"),ne=S.related_works.filter(B=>B.relation==="has_adaptation"),je=S.related_works.filter(B=>B.relation==="text_carried_by"),ge=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),Le=S.related_works.filter(B=>!B.relation||!ge.has(B.relation));return ce.length>0&&H.push({label:p.section.belongsToWork,items:ce}),V.length>0&&H.push({label:p.section.containedWorks,items:V}),ne.length>0&&H.push({label:p.section.adaptations,items:ne}),je.length>0&&H.push({label:p.section.derivativeWorks,items:je}),Le.length>0&&H.push({label:p.section.relatedWorks,items:Le}),H.map(B=>t.jsxs("div",{children:[t.jsxs(jt,{children:[B.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",B.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:B.items.map(me=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx($t,{id:me.id,label:h(me.title),onNavigate:o,renderLink:s})},me.id))})]},B.label))})()]})};function ah({data:e}){const n=Ee(),{convert:i}=Me(),{stats:o}=e,s=o.processed_volumes??o.total_found_volumes,a=s!=null&&e.total_volumes>0?Math.round(s/e.total_volumes*100):null;return t.jsxs("div",{style:{marginBottom:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:i(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"6px"},children:i(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:r("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:r("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:r("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:r("fg")},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:r("fg")},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:r("missing-fg")},children:o.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:r("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function lh({sections:e,activeSection:n,onSelect:i}){const o=Ee();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:ta(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:ta(n===s.name),children:[s.name,s.volume_range&&t.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function ta(e){return{padding:"4px 12px",border:e?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${r("primary")} 8%, transparent)`:"transparent",color:r(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function ch({id:e,label:n,onNavigate:i,renderLink:o}){const s=rt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:n||e})}function dh(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=e[0],o=e[e.length-1];return o-i+1===e.length?`${i}–${o}`:e.length<=3?e.join(", "):`${i}–${o} (${e.length}${n})`}function na({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Ee(),{convert:a}=Me(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?dh(e.volumes,s.unit.volume):null,c=e.missing_volumes&&e.missing_volumes.length>0;return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${r("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[o&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:r("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:r("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:r(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(ch,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:i}),!l&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const ho=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Ee(),[c,p]=g.useState(null),[h,m]=g.useState(!1),[u,f]=g.useState(null),[x,v]=g.useState(null),[b,$]=g.useState(""),y=e||c;g.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let _=!1;return m(!0),f(null),i.getCollectionCatalog(n).then(S=>{_||(S?p(S):f(d.catalog.notFound))}).catch(S=>{_||f(S instanceof Error?S.message:d.catalog.loadFailed)}).finally(()=>{_||m(!1)}),()=>{_=!0}},[e,n,i,d]);const w=(y==null?void 0:y.sections)&&y.sections.length>0,k=g.useMemo(()=>{if(!y)return!1;if(y.volume_index&&Object.keys(y.volume_index).length>0)return!0;const _=y.books.map(R=>R.volumes[0]).filter(R=>R!=null);return new Set(_).size<_.length},[y]),j=g.useMemo(()=>{if(!y)return[];let _=y.books;if(x&&(_=_.filter(S=>S.section===x)),b.trim()){const S=b.trim().toLowerCase();_=_.filter(R=>R.title.toLowerCase().includes(S)||R.sub_items&&R.sub_items.some(N=>N.toLowerCase().includes(S))||R.edition&&R.edition.toLowerCase().includes(S))}return _},[y,x,b]),C=g.useMemo(()=>{if(!k)return null;const _=[],S=new Map;for(const N of j){if(!N.volumes||N.volumes.length===0)continue;const z=N.volumes[0];S.has(z)||S.set(z,[]),S.get(z).push(N)}const R=[...S.keys()].sort((N,z)=>N-z);for(const N of R)_.push({volume:N,books:S.get(N)});return _},[j,k]);return h?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):u?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:u}):y?t.jsxs("div",{className:a,style:l,children:[t.jsx(ah,{data:y}),w&&t.jsx(lh,{sections:y.sections,activeSection:x,onSelect:v}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:b,onChange:_=>$(_.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:r("desc-fg")},children:[j.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[C?C.map((_,S)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:r("bg"),borderBottom:`1px solid ${r("widget-border")}`,fontSize:"12px",fontWeight:600,color:r("desc-fg"),position:"sticky",top:0,zIndex:1},children:bt(d.catalog.volume,{n:_.volume})}),_.books.map((R,N)=>t.jsx(na,{book:R,onNavigate:o,renderLink:s,showVolumes:R.volumes.length>1},`${_.volume}-${N}`))]},`${_.volume}-${S}`)):j.map((_,S)=>t.jsx(na,{book:_,onNavigate:o,renderLink:s,showVolumes:!0},S)),j.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},gr=e=>e?e.catch(()=>null):Promise.resolve(null);function Zl(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=gr((a=e.getTextManifest)==null?void 0:a.call(e,o)).then(l=>{const d=l&&Array.isArray(l.versions)&&l.versions.length>0?l:null;return d||n.delete(o),d}),n.set(o,s)),s}return{getManifest(o){return _e.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!_e.isSafeSegment(o)||!_e.isSafeSegment(s)||!e.getTextIndex?null:gr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!_e.isSafeSegment(o)||!_e.isSafeSegment(s)||!_e.isSafeSegment(a)||!e.getChapter?null:gr(e.getChapter(o,s,a,l))}}}const an=()=>{const{t:e}=ie(),[n,i]=g.useState(1);return g.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},fr=String.raw`https?:\/\/[^\s()()<>"]+`,ph=new RegExp(String.raw`\[([^\]\n]+)\]\((${fr})\)`+String.raw`|(《[^》\n]+》)\s?[((](${fr})[))]`+`|(${fr})`,"g");function uh(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function mh(e){const n=[];let i=0;for(const o of e.matchAll(ph)){const s=o.index??0;s>i&&n.push({text:e.slice(i,s)}),o[1]!==void 0?n.push({text:o[1],url:o[2]}):o[3]!==void 0?n.push({text:o[3],url:o[4]}):n.push({text:uh(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function Jl({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:mh(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(g.Fragment,{children:n(o.text)},s))})}const Ql="(min-width: 1100px)",xi="(max-width: 719px)",ec="(max-width: 859px)",hh=`${xi}, (pointer: coarse)`,Nt=r("reader-top"),gh="48px",tc=`
145
+ }`,Ql={color:"inherit",textDecoration:"none"},Qm=({snippet:e})=>{const{convert:n}=Me();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:ro(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(g.Fragment,{children:n(i.text)},o))})},eh=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Ee(),{convert:l}=Me(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${$n(e.juan_count)}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],h=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=r("cover-accent"),u=rt();return t.jsxs("a",{href:u(e.id),onClick:f=>i(e,f),className:"bim-result-card",style:{...Ql,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:r("bg"),border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${m} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${r("bg")}), color-mix(in srgb, ${m} 7%, ${r("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${m} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:m},children:Array.from(d).map((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:r("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",l(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:l(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",l(e.role)]})]}),(e.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),h&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof h=="string"?h:h.book_title||"")]}),e.descriptionSnippet&&t.jsx(Qm,{snippet:e.descriptionSnippet}),t.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[t.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:[t.jsx(_n,{type:e.type,size:8})," ",o(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.imageResource})]})]})]})},oa=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Ee(),{convert:d}=Me(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const u=typeof m=="string"?m:m==null?void 0:m.book_title;return u==null?void 0:u.toLowerCase().includes(s.toLowerCase())}):void 0,h=rt();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("a",{href:h(e.id),onClick:m=>i(e,m),className:"bim-result-card",style:{...Ql,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:a?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[t.jsx(_n,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:r("desc-fg"),lineHeight:1},children:o(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:d(e.title||e.primary_name||e.id)}),t.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[e.has_text&&t.jsx("span",{children:l.misc.textResource}),e.has_image&&t.jsx("span",{children:l.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",d(e.era),"〕"]}),e.edition&&d(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[$n(e.juan_count),l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",d(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:d(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",d(e.role)]}),e.type==="entity"&&(e.birth_year!=null||e.death_year!=null)&&t.jsxs("span",{style:{marginLeft:e.dynasty?"4px":0},children:[e.birth_year??"?","—",e.death_year??"?"]})]}),p&&t.jsxs("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:[l.search.alias,":",d(p)]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),a&&t.jsx("button",{type:"button",onClick:()=>a(e.id),title:l.search.removeFromRecent,"aria-label":l.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},th=({id:e,onRemove:n,t:i})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${r("widget-border")}`,background:r("input-bg"),opacity:.6},children:[t.jsx("span",{style:{fontSize:"16px"},children:"❓"}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:"13px",color:r("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:i.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:i.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function nh(e){var n,i,o;return!e.dynasty&&((n=e.dates)==null?void 0:n.birth)==null&&((i=e.dates)==null?void 0:i.death)==null&&(!e.alt_names||e.alt_names.length===0)&&!((o=e.description)!=null&&o.text)}function ih({data:e}){var l,d;const{convert:n}=Me(),{dynasty:i}=e,o=((l=e.dates)==null?void 0:l.birth)??void 0,s=((d=e.dates)==null?void 0:d.death)??void 0,a=[];return i&&a.push(`〔${n(i)}〕`),o!==void 0&&s!==void 0?a.push(`${o}—${s}`):o!==void 0?a.push(`${o}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:r("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function rh({alt_names:e}){const{convert:n}=Me(),i=new Map;for(const a of e){const l=a.type||"別名";i.has(l)||i.set(l,[]),i.get(l).push(a.name)}const o=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...i.keys()].sort((a,l)=>{const d=o.indexOf(a),c=o.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=i.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(a)}),t.jsx("span",{children:l.map((d,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function oh({data:e}){const n=Ee(),i=e.external_ids;if(!i)return null;const o=[];return i.cbdb_id&&o.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${i.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:r("link-fg"),border:`1px solid ${r("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${r("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",i.cbdb_id]},"cbdb")),o.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:o})}function sh({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Ee(),{convert:a}=Me(),l=rt(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let u=!1;const f=e.map(v=>v.work_id);return(async()=>{const v=new Map;if(n.getEntriesByIds)try{const w=await n.getEntriesByIds(f);let j=!0;for(let k=0;k<f.length;k++){const C=w[k];C!=null&&C.title?v.set(f[k],C.title):C!=null&&C.primary_name?v.set(f[k],C.primary_name):j=!1}if(j)return v}catch{}const b=[...f],_=8,y=new Array(_).fill(0).map(async()=>{for(;b.length;){const w=b.shift();if(!w)break;if(!v.has(w))try{if(n.getEntry){const C=await n.getEntry(w);if(C!=null&&C.title){v.set(w,C.title);continue}}const j=await n.getItem(w),k=j&&(j.title||j.primary_name)||w;v.set(w,k)}catch{v.set(w,w)}}});return await Promise.all(y),v})().then(v=>{u||c(v)}),()=>{u=!0}},[e,n]);const p=new Map;for(const u of e){const f=u.role||"";p.has(f)||p.set(f,[]),p.get(f).push(u)}const h=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((u,f)=>{const x=h.indexOf(u),v=h.indexOf(f);return x===-1&&v===-1?u.localeCompare(f):x===-1?1:v===-1?-1:x-v});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(u=>{const f=p.get(u);return t.jsxs("div",{style:{marginBottom:"8px"},children:[u&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(u)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:u?"16px":"0",listStyle:u?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,v)=>{const b=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,b)},v):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:b})},v):t.jsx("li",{children:b},v)})})]},u)})]})}const ec=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var m;const l=Ee(),{convert:d}=Me();let c=!1;try{c=$e.extractStatus(e.id)==="draft"}catch{}const p=nh(e),h=e.subtype&&e.subtype in l.common.entitySubtype?l.common.entitySubtype[e.subtype]:d(e.subtype);return t.jsxs("div",{children:[!a&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:r("fg")},children:[d(e.primary_name),t.jsx(ih,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:r("type-entity"),border:`1px solid color-mix(in srgb, ${r("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${r("type-entity")} 3%, transparent)`},children:l.indexType.entity}),h&&e.subtype!=="people"&&t.jsx("span",{children:h}),c&&t.jsx("span",{style:{padding:"1px 6px",background:r("warn-bg"),border:`1px solid ${r("warn-border")}`,borderRadius:"2px",color:r("warn-fg")},children:l.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),p&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:r("widget-bg"),border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(rh,{alt_names:e.alt_names}),t.jsx(oh,{data:e}),((m=e.description)==null?void 0:m.text)&&t.jsx("p",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(sh,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},ah=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function lh(e){const n=e.search(ah);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const tc={p:({children:e})=>t.jsx("p",{style:{margin:"0 0 0.5em"},children:e}),ul:({children:e})=>t.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:e}),ol:({children:e})=>t.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:e}),li:({children:e})=>t.jsx("li",{style:{marginBottom:"2px"},children:e}),a:({href:e,children:n})=>{let i=e,o="",s=n;if(e&&typeof n=="string"&&(n===e||n===ch(e))){const[a,l]=lh(n);l&&(i=encodeURI(a),s=a,o=l)}return t.jsxs(t.Fragment,{children:[t.jsx("a",{href:i,target:i!=null&&i.startsWith("http")?"_blank":void 0,rel:i!=null&&i.startsWith("http")?"noopener noreferrer":void 0,style:{color:r("link")},children:s}),o]})},code:({children:e})=>t.jsx("code",{style:{background:r("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function ch(e){try{return decodeURI(e)}catch{return e}}const dh={...tc,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Dt=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Me(),a=n?dh:tc;return t.jsx("div",{className:o,style:i,children:t.jsx(mu,{remarkPlugins:[hu],components:a,children:s(e)})})};function nc(e){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:e,border:`1px solid color-mix(in srgb, ${e} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${e} 3%, transparent)`}}const ph={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function uh({type:e}){const n=Ee();return t.jsx("span",{style:nc(ph[e]),children:n.indexType[e]})}function mh({isDraft:e}){const n=Ee(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:nc(i),children:e?n.status.draft:n.status.official})}function hh({id:e}){const n=Ee(),[i,o]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function jt({children:e,extra:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function Tt({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:r("fg")},children:n})]})}function ic({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Me();return t.jsx("span",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx($t,{id:a.entity_id,label:d,onNavigate:i,renderLink:o}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function $t({id:e,label:n,onNavigate:i,renderLink:o}){const s=rt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`,paddingBottom:"1px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{children:n||e})}function gh({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:h}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:r("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,i&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:i}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:l})]}),c&&t.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[t.jsx(uh,{type:o}),t.jsx(mh,{isDraft:s}),t.jsx(hh,{id:e})]}),((a==null?void 0:a.length)||d.length>0)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[a&&a.length>0&&t.jsx(ic,{authors:a,type:o,onNavigate:p,renderLink:h}),d]})]})}function rc({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Ee(),{convert:l}=Me();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,h)=>{const m=d===h;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?null:h),style:{padding:"8px 12px",background:r("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!m&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:u=>u.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx($t,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),m&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${r("widget-border")}`},children:[i&&(p.title_info||p.author_info||p.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&t.jsx(Tt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Tt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Tt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:l(p.summary)})]}),p.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.comment)})]}),p.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},h)})})]})}function fh({items:e,onNavigate:n,renderLink:i}){const o=Ee();return t.jsx(rc,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function oc({items:e,onNavigate:n,renderLink:i}){const o=Ee();return t.jsx(rc,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function sc({label:e,items:n}){const{convert:i}=Me();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((o,s)=>{const a=typeof o=="string"?o:o.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:i(a)},s)})})]}):null}function xh({items:e}){const n=Ee();return t.jsx(sc,{label:n.section.aliases,items:e})}function bh({items:e}){const n=Ee();return t.jsx(sc,{label:n.section.attachedTexts,items:e})}function yh({items:e}){const n=Ee(),{convert:i}=Me();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((o,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:["《",i(o.book_title),"》",o.n_juan!=null&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:[o.n_juan,n.unit.juan]})]},s))})]}):null}function jh({items:e}){const n=Ee(),{convert:i}=Me();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:n.section.locationHistory}),t.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[t.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:r("widget-border")}}),e.map((o,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:r("primary"),border:`1.5px solid ${r("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:r("fg")},children:i(o.name)}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function vh({items:e}){const n=Ee(),{convert:i}=Me();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((o,s)=>t.jsxs("div",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:r("desc-fg")},children:"·"}),i(o)]},s))})]}):null}function sa({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Me(),[l,d]=g.useState([]);return g.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(h=>({id:p,title:h?h.title:void 0,edition:h?h.edition:void 0,type:h?h.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(jt,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(l.length?l:n.map(c=>({id:c}))).map(c=>{const p=c.edition?`${a(c.title)||c.id}(${a(c.edition)})`:a(c.title)||void 0;return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),transition:"border-color 0.15s"},children:t.jsx($t,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function xr({book:e,onNavigate:n,renderLink:i}){const o=Ee(),{convert:s}=Me(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx($t,{id:e.id,label:c,onNavigate:n,renderLink:i})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:r("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?o.action.expand:o.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(po,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function kh({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Ee(),{convert:d}=Me(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(v=>({id:v})));return}let x=!1;return Promise.all(e.map(v=>i.getItem(v).then(b=>({id:v,title:b?b.title:void 0,edition:b?b.edition:void 0,resources:b?b.resources:void 0,resource_groups:b?b.resource_groups:void 0})).catch(()=>({id:v})))).then(v=>{x||p(v)}),()=>{x=!0}},[e,i]),!e.length)return null;const h=c.length?c:e.map(x=>({id:x})),m=new Map(h.map(x=>[x.id,x])),u=n==null?void 0:n.version_graph,f=wh(e,u,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(jt,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,f.useGrouping?t.jsxs(t.Fragment,{children:[f.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:f.coreIds.map(x=>{const v=m.get(x);return v?t.jsx(xr,{book:v,onNavigate:o,renderLink:s},x):null})}),f.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${r("widget-border")}`,borderRadius:6,background:r("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:r("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:r("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:r("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(v=>{const b=m.get(v);return b?t.jsx(xr,{book:b,onNavigate:o,renderLink:s},v):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.map(x=>t.jsx(xr,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function wh(e,n,i){var _,y;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(_=n.collections)==null?void 0:_[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),h=w=>{if(p.has(w))return!0;const j=n.node_groups[w];return j!=null&&c.has(j)},m=[],u=new Map,f=[];for(const w of e)if(!((y=n.excluded_books)!=null&&y.includes(w)))if(h(w))m.push(w);else{const j=n.node_groups[w];j?(u.has(j)||u.set(j,[]),u.get(j).push(w)):f.push(w)}if(f.length+[...u.values()].reduce((w,j)=>w+j.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const v=new Map((n.groups??[]).map(w=>[w.id,w])),b=[...u.entries()].map(([w,j])=>{const k=v.get(w);return{id:w,label:(k==null?void 0:k.label)??w,description:k==null?void 0:k.description,ids:j}});return f.length>0&&b.push({id:"__other__",label:i,description:void 0,ids:f}),{useGrouping:!0,coreIds:m,groupedIds:b}}function Sh({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Ee(),{convert:s}=Me(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:r("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:t.jsx($t,{id:e.id,label:s(e.title),onNavigate:n,renderLink:i})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:s(e.measure_info)}):((d=e.juan_count)==null?void 0:d.number)!=null&&e.juan_count.number>0?t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[$n(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(ic,{authors:e.authors,type:"work",onNavigate:n,renderLink:i})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(Dt,{text:e.description.text,style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,textAlign:"justify"}}),e.parent_work&&t.jsx("div",{style:{marginTop:(p=e.description)!=null&&p.text?"8px":0,fontSize:"13px"},children:t.jsx(Tt,{label:o.label.parentWork,children:t.jsx($t,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function _h({items:e,onNavigate:n,renderLink:i}){const o=Ee(),{convert:s}=Me();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(a=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${r("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${r("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:r("type-collection")},children:o.indexType.collection}),t.jsx($t,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:i}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"2px"},children:bt(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const ko=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var O,F,A,I,P,K,oe,le;const p=Ee(),{convert:h}=Me(),[m,u]=g.useState(null),[f,x]=g.useState(!1),[v,b]=g.useState(null),[_,y]=g.useState(null),[w,j]=g.useState([]),k=e||m;if(g.useEffect(()=>{if(e||!n||!i)return;let H=!1;return x(!0),b(null),i.getItem(n).then(de=>{H||(de?u(de):b(p.misc.notFoundEntry))}).catch(de=>{H||b(de instanceof Error?de.message:p.misc.loadFailed)}).finally(()=>{H||x(!1)}),()=>{H=!0}},[e,n,i]),g.useEffect(()=>{if(!k||!i){y(null),j([]);return}let H=!1;const de=k.type==="book"||k.type==="collection"?k.work_id:void 0;if(de?i.getItem(de).then(U=>{!H&&U&&U.type==="work"&&y(U)}).catch(()=>{}):y(null),k.type==="book"){const U=k;U.contained_in&&U.contained_in.length>0?Promise.all(U.contained_in.map(te=>{const ve=typeof te=="string"?te:te.id,fe=typeof te=="string"?void 0:te.volume_index;return i.getItem(ve).then(Ae=>({id:ve,title:Ae&&Ae.title||ve,volume_index:fe})).catch(()=>({id:ve,title:ve,volume_index:fe}))})).then(te=>{H||j(te)}):j([])}else j([]);return()=>{H=!0}},[k,i]),f)return t.jsx("div",{className:d,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((H,de)=>t.jsx("div",{style:{height:de===1?"32px":"16px",width:`${H}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},de))})});if(v)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:v});if(!k)return null;if(k.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(ec,{data:k,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const C=k.type==="book"?k:null,$=k.type==="collection"?k:null,S=k.type==="work"?k:null;let E=!1;try{E=$e.extractStatus(k.id)==="draft"}catch{}let N="";k.measure_info?N=h(k.measure_info):(O=k.juan_count)!=null&&O.number?N=$n(k.juan_count.number)+p.unit.juan:(F=k.juan_count)!=null&&F.description&&(N=h(k.juan_count.description));const z=[];return(A=k.publication_info)!=null&&A.year&&z.push(t.jsx(Tt,{label:p.label.year,children:k.publication_info.year},"year")),(I=k.current_location)!=null&&I.name&&z.push(t.jsx(Tt,{label:p.label.currentLocation,children:h(k.current_location.name)},"loc")),(P=k.page_count)!=null&&P.description&&z.push(t.jsx(Tt,{label:p.label.pageCount,children:k.page_count.description},"page")),C!=null&&C.edition&&z.push(t.jsx(Tt,{label:p.label.edition,children:h(C.edition)},"ver")),S!=null&&S.parent_work&&z.push(t.jsx(Tt,{label:p.label.parentWork,children:t.jsx($t,{id:S.parent_work.id,label:h(S.parent_work.title),onNavigate:o,renderLink:s})},"pw")),S!=null&&S.parent_works&&S.parent_works.length>0&&!S.parent_work&&z.push(t.jsx(Tt,{label:p.label.parentWork,children:S.parent_works.map((H,de)=>t.jsxs("span",{children:[de>0&&"、",t.jsx($t,{id:H,onNavigate:o,renderLink:s})]},H))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(gh,{id:k.id,title:h(k.title),edition:k.edition?h(k.edition):void 0,type:k.type,isDraft:E,authors:k.authors,volumeText:N,meta:z,headerExtra:a,onNavigate:o,renderLink:s}),((K=k.description)==null?void 0:K.text)&&t.jsx(Dt,{text:k.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),k.appendix&&k.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:k.appendix.map((H,de)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:r("bg-subtle"),borderRadius:4,border:`1px solid ${r("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:r("muted")},children:h(H.title)}),t.jsx(Dt,{text:H.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},de))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:p.section.containedIn}),t.jsx(_h,{items:w,onNavigate:o,renderLink:s})]}),_&&t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:p.section.belongsToWork}),t.jsx(Sh,{workData:_,onNavigate:o,renderLink:s})]}),k.additional_works&&k.additional_works.length>0&&t.jsx(yh,{items:k.additional_works}),k.additional_titles&&k.additional_titles.length>0&&t.jsx(xh,{items:k.additional_titles}),k.attached_texts&&k.attached_texts.length>0&&t.jsx(bh,{items:k.attached_texts}),k.indexed_by&&k.indexed_by.length>0&&t.jsx(fh,{items:k.indexed_by,onNavigate:o,renderLink:s}),k.emendated_by&&k.emendated_by.length>0&&t.jsx(oc,{items:k.emendated_by,onNavigate:o,renderLink:s}),k.resources&&k.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(jt,{children:p.section.resources}),t.jsx(po,{items:k.resources,resourceGroups:k.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),(C==null?void 0:C.location_history)&&C.location_history.length>0&&t.jsx(jh,{items:C.location_history}),($==null?void 0:$.history)&&$.history.length>0&&t.jsx(vh,{items:$.history}),(C==null?void 0:C.related_books)&&C.related_books.length>0&&t.jsx(sa,{title:p.section.relatedVersions,ids:C.related_books,transport:i,onNavigate:o,renderLink:s}),($==null?void 0:$.books)&&$.books.length>0&&t.jsx(sa,{title:p.section.containedBooks,ids:$.books,transport:i,onNavigate:o,renderLink:s}),($==null?void 0:$.contained_works)&&$.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(jt,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",$.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.contained_works.map(H=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx($t,{id:H.id,label:h(H.title),onNavigate:o,renderLink:s})},H.id))})]}),(((oe=S==null?void 0:S.books)==null?void 0:oe.length)||0)+(((le=S==null?void 0:S.collections)==null?void 0:le.length)||0)>0&&t.jsx(kh,{ids:[...(S==null?void 0:S.books)||[],...(S==null?void 0:S.collections)||[]],workData:S??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),(S==null?void 0:S.related_works)&&S.related_works.length>0&&(()=>{const H=[],de=S.related_works.filter(B=>B.relation==="part_of"),U=S.related_works.filter(B=>B.relation==="has_part"),te=S.related_works.filter(B=>B.relation==="has_adaptation"),ve=S.related_works.filter(B=>B.relation==="text_carried_by"),fe=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),Ae=S.related_works.filter(B=>!B.relation||!fe.has(B.relation));return de.length>0&&H.push({label:p.section.belongsToWork,items:de}),U.length>0&&H.push({label:p.section.containedWorks,items:U}),te.length>0&&H.push({label:p.section.adaptations,items:te}),ve.length>0&&H.push({label:p.section.derivativeWorks,items:ve}),Ae.length>0&&H.push({label:p.section.relatedWorks,items:Ae}),H.map(B=>t.jsxs("div",{children:[t.jsxs(jt,{children:[B.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",B.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:B.items.map(me=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx($t,{id:me.id,label:h(me.title),onNavigate:o,renderLink:s})},me.id))})]},B.label))})()]})};function $h({data:e}){const n=Ee(),{convert:i}=Me(),{stats:o}=e,s=o.processed_volumes??o.total_found_volumes,a=s!=null&&e.total_volumes>0?Math.round(s/e.total_volumes*100):null;return t.jsxs("div",{style:{marginBottom:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:i(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"6px"},children:i(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:r("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:r("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:r("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:r("fg")},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:r("fg")},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:r("missing-fg")},children:o.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:r("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Ch({sections:e,activeSection:n,onSelect:i}){const o=Ee();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:aa(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:aa(n===s.name),children:[s.name,s.volume_range&&t.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function aa(e){return{padding:"4px 12px",border:e?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${r("primary")} 8%, transparent)`:"transparent",color:r(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function zh({id:e,label:n,onNavigate:i,renderLink:o}){const s=rt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:n||e})}function Nh(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=e[0],o=e[e.length-1];return o-i+1===e.length?`${i}–${o}`:e.length<=3?e.join(", "):`${i}–${o} (${e.length}${n})`}function la({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Ee(),{convert:a}=Me(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?Nh(e.volumes,s.unit.volume):null,c=e.missing_volumes&&e.missing_volumes.length>0;return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${r("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[o&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:r("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:r("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:r(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(zh,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:i}),!l&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const wo=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Ee(),[c,p]=g.useState(null),[h,m]=g.useState(!1),[u,f]=g.useState(null),[x,v]=g.useState(null),[b,_]=g.useState(""),y=e||c;g.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let $=!1;return m(!0),f(null),i.getCollectionCatalog(n).then(S=>{$||(S?p(S):f(d.catalog.notFound))}).catch(S=>{$||f(S instanceof Error?S.message:d.catalog.loadFailed)}).finally(()=>{$||m(!1)}),()=>{$=!0}},[e,n,i,d]);const w=(y==null?void 0:y.sections)&&y.sections.length>0,j=g.useMemo(()=>{if(!y)return!1;if(y.volume_index&&Object.keys(y.volume_index).length>0)return!0;const $=y.books.map(E=>E.volumes[0]).filter(E=>E!=null);return new Set($).size<$.length},[y]),k=g.useMemo(()=>{if(!y)return[];let $=y.books;if(x&&($=$.filter(S=>S.section===x)),b.trim()){const S=b.trim().toLowerCase();$=$.filter(E=>E.title.toLowerCase().includes(S)||E.sub_items&&E.sub_items.some(N=>N.toLowerCase().includes(S))||E.edition&&E.edition.toLowerCase().includes(S))}return $},[y,x,b]),C=g.useMemo(()=>{if(!j)return null;const $=[],S=new Map;for(const N of k){if(!N.volumes||N.volumes.length===0)continue;const z=N.volumes[0];S.has(z)||S.set(z,[]),S.get(z).push(N)}const E=[...S.keys()].sort((N,z)=>N-z);for(const N of E)$.push({volume:N,books:S.get(N)});return $},[k,j]);return h?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):u?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:u}):y?t.jsxs("div",{className:a,style:l,children:[t.jsx($h,{data:y}),w&&t.jsx(Ch,{sections:y.sections,activeSection:x,onSelect:v}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:b,onChange:$=>_($.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:r("desc-fg")},children:[k.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[C?C.map(($,S)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:r("bg"),borderBottom:`1px solid ${r("widget-border")}`,fontSize:"12px",fontWeight:600,color:r("desc-fg"),position:"sticky",top:0,zIndex:1},children:bt(d.catalog.volume,{n:$.volume})}),$.books.map((E,N)=>t.jsx(la,{book:E,onNavigate:o,renderLink:s,showVolumes:E.volumes.length>1},`${$.volume}-${N}`))]},`${$.volume}-${S}`)):k.map(($,S)=>t.jsx(la,{book:$,onNavigate:o,renderLink:s,showVolumes:!0},S)),k.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},br=e=>e?e.catch(()=>null):Promise.resolve(null);function ac(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=br((a=e.getTextManifest)==null?void 0:a.call(e,o)).then(l=>{const d=l&&Array.isArray(l.versions)&&l.versions.length>0?l:null;return d||n.delete(o),d}),n.set(o,s)),s}return{getManifest(o){return $e.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!$e.isSafeSegment(o)||!$e.isSafeSegment(s)||!e.getTextIndex?null:br(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!$e.isSafeSegment(o)||!$e.isSafeSegment(s)||!$e.isSafeSegment(a)||!e.getChapter?null:br(e.getChapter(o,s,a,l))}}}const an=()=>{const{t:e}=ne(),[n,i]=g.useState(1);return g.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},yr=String.raw`https?:\/\/[^\s()()<>"]+`,Th=new RegExp(String.raw`\[([^\]\n]+)\]\((${yr})\)`+String.raw`|(《[^》\n]+》)\s?[((](${yr})[))]`+`|(${yr})`,"g");function Ih(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function Rh(e){const n=[];let i=0;for(const o of e.matchAll(Th)){const s=o.index??0;s>i&&n.push({text:e.slice(i,s)}),o[1]!==void 0?n.push({text:o[1],url:o[2]}):o[3]!==void 0?n.push({text:o[3],url:o[4]}):n.push({text:Ih(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function lc({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:Rh(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(g.Fragment,{children:n(o.text)},s))})}const cc="(min-width: 1100px)",bi="(max-width: 719px)",dc="(max-width: 859px)",Eh=`${bi}, (pointer: coarse)`,Nt=r("reader-top"),Lh="48px",pc=`
146
146
  .bim-rd {
147
147
  position: relative;
148
148
  background: ${r("page-bg")};
149
149
  color: ${r("ink")};
150
150
  font-family: ${r("font-ui")};
151
- --bimrd-bar-h: ${gh};
151
+ --bimrd-bar-h: ${Lh};
152
152
  /* 设置侧栏的暖黄:与朱/靛/墨三套主色都不冲,只做底色与选中态 */
153
153
  --bimrd-warm: ${r("reader-warm")};
154
154
  --bimrd-warm-bg: color-mix(in srgb, var(--bimrd-warm) 8%, ${r("page-bg")});
@@ -451,7 +451,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
451
451
  .bim-rd-sheet-head .bim-rd-t { margin-left: auto; min-width: 44px; min-height: 44px; justify-content: center; letter-spacing: 0; }
452
452
  .bim-rd-sheet-img { display: flex; flex-direction: column; gap: 8px; min-height: 40vh; }
453
453
  .bim-rd-sheet-img .bim-rd-img-fig img { max-height: 60vh; }
454
- @media ${ec} {
454
+ @media ${dc} {
455
455
  .bim-rd[data-bb] .bim-rd-text { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom, 0px)); }
456
456
  /* 底栏上已有的,工具条上不再重复(目录、字号) */
457
457
  .bim-rd[data-bb] .bim-rd-bb-dup { display: none !important; }
@@ -496,7 +496,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
496
496
 
497
497
  /* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
498
498
  A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
499
- @media ${hh} {
499
+ @media ${Eh} {
500
500
  .bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
501
501
  .bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
502
502
  content: ""; position: absolute; left: 50%; top: 50%;
@@ -509,7 +509,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
509
509
  }
510
510
 
511
511
  /* ── 中屏以下:目录改抽屉 ── */
512
- @media not all and ${Ql} {
512
+ @media not all and ${cc} {
513
513
  .bim-rd-toc {
514
514
  position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
515
515
  width: min(86vw, 320px);
@@ -523,7 +523,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
523
523
  }
524
524
 
525
525
  /* ── 窄屏:书影收起,只留正文 ── */
526
- @media ${xi} {
526
+ @media ${bi} {
527
527
  .bim-rd-bar { padding: 0 12px; gap: 10px; }
528
528
  .bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
529
529
  /* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
@@ -699,25 +699,28 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
699
699
  }
700
700
 
701
701
  /* ── 手机:正文两侧不留白(放在对读、界栏规则之后才压得过它们) ── */
702
- @media ${xi} {
702
+ @media ${bi} {
703
703
  .bim-rd-text, .bim-rd[data-warp="true"] .bim-rd-text { padding-left: 0; padding-right: 0; }
704
704
  .bim-rd-col, :root[data-layout="boxed"] .bim-rd-col { padding-left: 14px; padding-right: 14px; }
705
705
  :root[data-layout="boxed"] .bim-rd-col { border-left: 0; border-right: 0; }
706
706
  .guji-text-pane-content { padding-left: 0; padding-right: 0; border-radius: 0; }
707
707
  }
708
- /* 页指示三角只为对照书影:书影栏收起或手机上(书影栏不出)都不画 */
708
+ /* 页指示箭头只为对照书影:书影栏收起或手机上(书影栏不出)都不画 */
709
709
  .bim-rd:not([data-img="open"]) .guji-page-indicator { display: none; }
710
- @media ${xi} { .guji-page-indicator { display: none; } }
711
- `;function go(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>go(o,n))):!1}const ia=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function fh({item:e,activeKey:n,onSelect:i,tabKey:o}){const{t:s}=ie(),a=go(e,n),[l,d]=g.useState(a||!!e.defaultExpanded);return g.useEffect(()=>{a&&d(!0)},[a]),g.useEffect(()=>{e.defaultExpanded&&d(!0)},[e.defaultExpanded]),e.selectable?t.jsxs("li",{children:[t.jsxs("div",{className:"bim-rd-ti-row",children:[t.jsx("button",{type:"button",className:"bim-rd-ti-tw","aria-expanded":l,"aria-label":s(l?"reader.tocCollapse":"reader.tocExpand"),tabIndex:-1,onClick:()=>d(c=>!c),children:t.jsx(ia,{})}),t.jsxs("button",{type:"button",className:`bim-rd-ti${e.inChapter?"":" bim-rd-ti-group"}`,"aria-current":e.key===n?"true":void 0,disabled:e.disabled,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>{d(!0),i(e.key)},onKeyDown:c=>{c.key==="ArrowRight"&&!l?(c.preventDefault(),d(!0)):c.key==="ArrowLeft"&&l&&(c.preventDefault(),d(!1))},children:[t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]})]}),l&&t.jsx(Er,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]}):t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>d(c=>!c),children:[t.jsx(ia,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),l&&t.jsx(Er,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Er({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(fh,{item:s,activeKey:n,onSelect:i,tabKey:o},s.key):t.jsx("li",{children:t.jsxs("button",{type:"button",className:"bim-rd-ti","aria-current":s.key===n?"true":void 0,disabled:s.disabled,"data-rd-toc-key":s.key,tabIndex:o===s.key?0:-1,onClick:()=>i(s.key),children:[t.jsx("span",{children:s.label}),s.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function ra(e,n){var i;for(const o of e)if(o.key===n||go(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function nc({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=ie(),a=o??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??ra(e,n)),[d,n,e]);g.useEffect(()=>{const m=l.current;if(!m)return;const u=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(u.length===0)return;const f=u.find(x=>x.dataset.rdTocKey===p)??u.find(x=>x.dataset.rdTocKey===ra(e,n))??u.find(x=>!x.disabled)??u[0];for(const x of u)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const m=l.current,u=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!u||!n)return;const f=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(v=>v.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-u.getBoundingClientRect().top+u.scrollTop;(x<u.scrollTop+80||x>u.scrollTop+u.clientHeight-40)&&(u.scrollTop=Math.max(0,x-u.clientHeight/3))},[n]);const h=g.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(y=>!y.disabled),v=x.indexOf(document.activeElement);let b=v;if(m.key==="ArrowDown"?b=Math.min(x.length-1,v+1):m.key==="ArrowUp"?b=Math.max(0,v-1):m.key==="Home"?b=0:m.key==="End"&&(b=x.length-1),b<0||b===v)return;m.preventDefault();const $=x[b];for(const y of x)y.tabIndex=-1;$.tabIndex=0,$.focus(),c($.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:h,children:t.jsx(Er,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function oa({page:e,crop:n}){var i;return!((i=e.boxes)!=null&&i.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:n?`${n.x} ${n.y} ${n.w} ${n.h}`:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,s)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:r("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},s))})}function xh(e){const{boxes:n,width:i,height:o}=e;if(!(n!=null&&n.length)||!i||!o||e.boxFormat&&e.boxFormat!=="bim-charbox-v0")return null;let s=1/0,a=1/0,l=-1/0,d=-1/0;for(const f of n)[f.x,f.y,f.w,f.h].every(Number.isFinite)&&(s=Math.min(s,f.x),a=Math.min(a,f.y),l=Math.max(l,f.x+f.w),d=Math.max(d,f.y+f.h));if(!(l>s)||!(d>a))return null;const c=Math.min(i,o)*.03,p=Math.min(i,Math.max(0,s-c)),h=Math.min(o,Math.max(0,a-c)),m=Math.min(i,Math.max(0,l+c))-p,u=Math.min(o,Math.max(0,d+c))-h;return!(m>0)||!(u>0)||m>=i*.98&&u>=o*.98?null:{x:p,y:h,w:m,h:u}}function Rr({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=ie(),[d,c]=g.useState(0),p=i??d,h=v=>{o?o(v):c(v)};if(g.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const m=Math.max(0,Math.min(e.length-1,p)),u=e[m],f=u.label??`${m+1}`,x=!a&&!s?xh(u):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:f}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${u.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(oa,{page:u,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:f}),width:u.width,height:u.height,loading:"lazy",decoding:"async"}),t.jsx(oa,{page:u}),s==null?void 0:s(u,m)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:m===0,onClick:()=>h(m-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:u.label??`${m+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:m===e.length-1,onClick:()=>h(m+1),children:"›"})]})]})}function bh(e){return e==="lite"||e==="full"}const Un=[.1,.9],ic=[{key:"song",stack:null},{key:"kai",stack:'"Kaiti SC", "Kaiti TC", STKaiti, "KaiTi", "AR PL UKai CN", "Noto Serif CJK SC", serif'},{key:"system",stack:"var(--bim-font-ui)"}];function yh(e){var n;return((n=ic.find(i=>i.key===e))==null?void 0:n.stack)??null}const fo={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!1,pageIndicatorY:.33,bookTitleStyle:"bracket",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Bt=[15,16,17,18,20,22,24],Lr=18,rc="bim-reader-prefs",oc=2,jh="bim-reading-mode";function vh(){const e={...fo};try{const n=localStorage.getItem(rc),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Bt.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(jh))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily);const s=i.v===oc;s&&typeof i.pageBreaks=="boolean"&&(e.pageBreaks=i.pageBreaks),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=Un[0]&&i.pageIndicatorY<=Un[1]&&(e.pageIndicatorY=i.pageIndicatorY),s&&(i.bookTitleStyle==="wavy"||i.bookTitleStyle==="bracket")&&(e.bookTitleStyle=i.bookTitleStyle),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function kh(e){try{localStorage.setItem(rc,JSON.stringify({...e,v:oc}))}catch{}}function pi(e,n){const i=e??Lr,o=Bt;let s=o.indexOf(i);return s<0&&(s=o.indexOf(Lr)),o[Math.max(0,Math.min(o.length-1,s+n))]}function sc(){const[e,n]=g.useState(fo);g.useEffect(()=>{n(vh())},[]);const i=g.useCallback(o=>{n(s=>{const a={...s,...o};return kh(a),a})},[]);return[e,i]}function Ar(e){if(e.optionLabel)return e.optionLabel;const n=e.label||e.key;return!e.sourceName||n.includes(e.sourceName)?n:`${n} · ${e.sourceName}`}function ac(e,n){if(!(!e||e.length===0))return(n!=null?e.find(i=>i.key===n):void 0)??e.find(i=>i.primary)??e[0]}function lc(e){const n=[],i=o=>{for(const s of o){if(s.inChapter)continue;const a=!!s.children&&s.children.length>0;(!a||s.selectable)&&n.push(s),a&&i(s.children)}};return i(e),n}const sa=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),wh=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M15 5l-7 7 7 7"})}),Sh=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M9 5l7 7-7 7"})}),aa=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),la=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),t.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function ca(e,n){if(!n)return;const i=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(i.length===0)return;const o=i[0],s=i[i.length-1],a=document.activeElement;e.shiftKey&&(a===o||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),o.focus())}function da(e,n){const[i,o]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),i}function _h({prefs:e,onPrefsChange:n,origAvailable:i}){const o=g.useContext(Et),{t:s}=ie();if(!o)return null;const a=o.locale==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a,d=[{key:"orig",short:s("reader.scriptOrigShort"),title:s(i?"reader.scriptOrig":"reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",short:s("common.localeShortHant"),title:s("reader.scriptHant")},{key:"hans",short:s("common.localeShortHans"),title:s("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":s("reader.scriptQuick"),children:d.map((c,p)=>t.jsxs(g.Fragment,{children:[p>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":l===c.key,title:c.title,"aria-label":c.title,disabled:c.disabled,onClick:()=>{c.disabled||(n({scriptMode:c.key}),c.key==="hant"?o.setLocale("zh-Hant"):c.key==="hans"&&o.setLocale("zh-Hans"))},children:c.short})]},c.key))})}function bi({label:e,value:n,options:i,onPick:o,title:s}){return t.jsxs("div",{className:"bim-rd-sp-row",role:"group","aria-label":e,title:s,children:[t.jsx("span",{className:"bim-rd-sp-l",children:e}),t.jsx("span",{className:"bim-rd-sp-fs",children:i.map(a=>t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":n===a.key,title:a.title,disabled:a.disabled,onClick:()=>{a.disabled||o(a.key)},children:a.label},a.key))})]})}function $h({prefs:e,onPrefsChange:n,origAvailable:i}){const o=g.useContext(Et),{t:s}=ie(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx(bi,{label:s("reader.script"),value:l,options:[{key:"orig",label:s("reader.scriptOrig"),title:i?void 0:s("reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",label:s("reader.scriptHant")},{key:"hans",label:s("reader.scriptHans")}],onPick:d=>{n({scriptMode:d}),d==="hant"?o==null||o.setLocale("zh-Hant"):d==="hans"&&(o==null||o.setLocale("zh-Hans"))}})}function Ch(e,n){if(!e)return;let i;for(const o of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(o.getBoundingClientRect().top<=n+8)i=o.id;else break;return i}function zh(e){var a;if(typeof window>"u"||!e)return;const n=(a=window.getSelection)==null?void 0:a.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const i=e.querySelector(".bim-rd-col"),o=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(i!=null&&i.contains(l))&&!(d!=null&&d.closest(".bim-rd-src, .bim-rd-pager"))};if(!o(n.anchorNode)||!o(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function cc({title:e,subtitle:n,toc:i,activeKey:o,tocActiveKey:s,onSelect:a,tocHeader:l,tocCaption:d,images:c,imagesLoading:p,renderImageOverlay:h,imagePanel:m="auto",prefs:u,onPrefsChange:f,paragraphToggle:x,properNameToggle:v=!0,allowVertical:b,origScriptAvailable:$=!0,byline:y,current:w,workLinkToggle:k,rail:j,onReportError:C,revisedAt:_,backHref:S,backLabel:R,bottomBar:N=!0,pager:z=!0,contentLoading:M=!1,pagerUnit:F,versions:L,currentVersionKey:E,onVersionChange:P,versionSource:Z=!0,keepChapterOnVersionChange:oe=!1,customImagePanel:ae,toolbarExtra:H,settingsAnnotate:ce,settingsLayout:V,isWarpMode:ne,children:je,className:ge,style:Le}){const{t:B,convert:me}=ie(),ze=R??B("reader.back"),we=me(F??B("reader.unitJuan")),De=g.useId().replace(/:/g,""),Pe=`bim-rd-toc-${De}`,G=`bim-rd-text-${De}`,he=g.useRef(null),Y=g.useRef(null),re=g.useRef(null),K=g.useRef(null),A=da(Ql,!0),U=da(ec,!1),q=N&&U,[D,de]=g.useState(null),[be,ve]=g.useState(!1),Re=g.useRef(null),O=`bim-rd-set-${De}`,J=g.useRef(null),fe=g.useRef(null),W=(Q,Ge)=>{fe.current=Ge,de(dt=>dt===Q?null:Q)},se=g.useCallback(()=>{var Q;de(null),(Q=fe.current)==null||Q.focus()},[]);g.useEffect(()=>{q||de(null)},[q]),g.useEffect(()=>{var Q,Ge;D&&((Ge=(Q=J.current)==null?void 0:Q.querySelector("button:not([disabled])"))==null||Ge.focus())},[D]);const[X,pe]=g.useState("auto"),$e=X==="auto"?A:X==="open",Ae=!A,Oe=!!ae||!!c&&c.length>0,[Je,Qe]=g.useState(m);g.useEffect(()=>{Qe(m)},[m]);const T=Je==="auto"?Oe||!!p:Je==="open",ue=g.useCallback(Q=>{var Ge;pe("auto"),Q&&((Ge=K.current)==null||Ge.focus())},[]),ye=()=>pe($e?"closed":"open");g.useEffect(()=>{if(!Ae||X!=="open")return;const Q=re.current,Ge=Q==null?void 0:Q.querySelector('input, [data-rd-toc-key][tabindex="0"]');Ge==null||Ge.focus()},[Ae,X]);const ke=g.useCallback(Q=>{a(Q),Ae&&ue(!1);const Ge=Y.current,dt=he.current;if(Ge&&dt&&typeof window<"u"){const Rt=Ge.getBoundingClientRect().top-dt.getBoundingClientRect().bottom;Rt<0&&window.scrollBy({top:Rt})}},[a,Ae,ue]),Ne=g.useMemo(()=>lc(i),[i]),[Se,Ke]=g.useState(null),We=ac(L,E!==void 0?E:Se),ee=(We==null?void 0:We.key)??null,te=g.useMemo(()=>Ne.map(Q=>Q.key).join(`
712
- `),[Ne]),He=g.useRef(null),Fe=Q=>{Q!==ee&&(oe||(He.current={key:Q,sig:te,done:!1}),E===void 0&&Ke(Q),P==null||P(Q))};g.useEffect(()=>{const Q=He.current;if(!Q||Q.key!==ee)return;const Ge=Ne.find(Rt=>!Rt.disabled);if(!Ge)return;const dt=te!==Q.sig;!dt&&Q.done||(dt?He.current=null:Q.done=!0,Ge.key!==o&&ke(Ge.key))},[ee,te,Ne,o,ke]);const Ie=Ne.find(Q=>Q.key===o),xe=()=>{var Q;C==null||C({chapterKey:o,chapterLabel:typeof(Ie==null?void 0:Ie.label)=="string"?Ie.label:void 0,anchor:Ch(Y.current,((Q=he.current)==null?void 0:Q.getBoundingClientRect().bottom)??0),selectedText:zh(Y.current)})},Ye=Ne.findIndex(Q=>Q.key===o),Ce=Ye>0?Ne.slice(0,Ye).reverse().find(Q=>!Q.disabled):void 0,Ve=Ye>=0?Ne.slice(Ye+1).find(Q=>!Q.disabled):void 0,Be=u.fontSize??Lr,et=yh(u.fontFamily),kt={...Le,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...et?{"--bimrd-ff":et}:null},wt={song:B("reader.fontSong"),kai:B("reader.fontKai"),system:B("reader.fontSystem")},cn=v||!!ce,Ct=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${O}-g1`,children:[t.jsx("h3",{id:`${O}-g1`,className:"bim-rd-sp-h",children:B("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:B("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":B("reader.font"),value:u.fontFamily,onChange:Q=>f({fontFamily:Q.target.value}),children:ic.map(Q=>t.jsx("option",{value:Q.key,children:wt[Q.key]},Q.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:B("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.fontSmaller"),disabled:Be<=Bt[0],onClick:()=>f({fontSize:pi(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Be,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.fontLarger"),disabled:Be>=Bt[Bt.length-1],onClick:()=>f({fontSize:pi(u.fontSize,1)}),children:"A+"})]})]}),t.jsx($h,{prefs:u,onPrefsChange:f,origAvailable:$}),t.jsx(bi,{label:B("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:B("reader.quoteModern")},{key:"classic",label:B("reader.quoteClassic")},{key:"original",label:B("reader.quoteOriginal")}],onPick:Q=>f({quoteStyle:Q})})]}),cn&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${O}-g2`,children:[t.jsx("h3",{id:`${O}-g2`,className:"bim-rd-sp-h",children:B("reader.groupMark")}),v&&t.jsxs(t.Fragment,{children:[t.jsx(bi,{label:B("reader.properName"),value:u.properNameMode,title:B("reader.properNameTitle"),options:[{key:"off",label:B("reader.properNameOff")},{key:"lite",label:B("reader.properNameLite"),title:B("reader.properNameLiteTitle")},{key:"full",label:B("reader.properNameFull")}],onPick:Q=>f({properNameMode:Q})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:Q=>f({showWorks:Q.target.checked})}),t.jsx("span",{children:B("reader.showWorks")})]}),t.jsx(bi,{label:B("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:B("reader.bookTitleWavy")},{key:"bracket",label:B("reader.bookTitleBracket")}],onPick:Q=>f({bookTitleStyle:Q})})]}),ce]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${O}-g3`,children:[t.jsx("h3",{id:`${O}-g3`,className:"bim-rd-sp-h",children:B("reader.groupLayout")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:B("reader.paragraphTitle"),onClick:()=>f({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:B("reader.paragraph")}),k&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:Q=>f({workLinks:Q.target.checked})}),t.jsx("span",{children:B("reader.workLinks")})]}),b&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>f({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:B("reader.vertical")}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.pageBreaks,onChange:Q=>f({pageBreaks:Q.target.checked})}),t.jsx("span",{children:B("reader.pageBreaks")})]}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:Q=>f({preserveMargins:Q.target.checked})}),t.jsx("span",{children:B("reader.preserveMargins")})]}),V]})]});return t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&b?"bim-rd-vertical":"",ge].filter(Boolean).join(" "),"data-toc":X,"data-img":T?"open":"closed","data-bb":q?"":void 0,"data-set":!q&&be?"open":void 0,"data-warp":ne?"true":void 0,style:kt,children:[t.jsx("style",{children:tc}),t.jsx("a",{className:"bim-rd-skip",href:`#${G}`,onClick:Q=>{var Ge,dt,Rt;Q.preventDefault(),(Ge=Y.current)==null||Ge.focus(),(Rt=(dt=Y.current)==null?void 0:dt.scrollIntoView)==null||Rt.call(dt,{block:"start"})},children:B("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:he,children:[S&&t.jsxs("a",{className:"bim-rd-back",href:S,"aria-label":B("reader.backAria",{label:ze}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:ze})]}),(e||n||y||w)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),y&&t.jsx("span",{className:"bim-rd-by",children:y}),w&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:w})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":B("reader.settings"),children:[L&&L.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:We?me(Ar(We)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:B("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:B("reader.versionShort")}),t.jsx("select",{"aria-label":B("reader.version"),value:ee??"",onChange:Q=>Fe(Q.target.value),children:L.map(Q=>t.jsx("option",{value:Q.key,children:me(Ar(Q))},Q.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),z&&(Ce||Ve)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":B("reader.pagerGroup",{unit:we}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.prevUnit",{unit:we}),title:Ce?typeof Ce.label=="string"&&Ce.label?B("reader.prevUnitTitle",{unit:we,label:Ce.label}):B("reader.prevUnit",{unit:we}):B("reader.firstUnit",{unit:we}),disabled:!Ce,onClick:()=>Ce&&ke(Ce.key),children:t.jsx(wh,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.nextUnit",{unit:we}),title:Ve?typeof Ve.label=="string"&&Ve.label?B("reader.nextUnitTitle",{unit:we,label:Ve.label}):B("reader.nextUnit",{unit:we}):B("reader.lastUnit",{unit:we}),disabled:!Ve,onClick:()=>Ve&&ke(Ve.key),children:t.jsx(Sh,{})})]}),z&&(Ce||Ve)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:K,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":$e,"aria-controls":Pe,onClick:ye,children:[t.jsx(sa,{}),t.jsx("span",{className:"bim-rd-tlabel",children:B("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":T,onClick:()=>Qe(T?"closed":"open"),children:[t.jsx(la,{}),B("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(_h,{prefs:u,onPrefsChange:f,origAvailable:$}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":B("reader.fontSmaller"),disabled:Be<=Bt[0],onClick:()=>f({fontSize:pi(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":B("reader.fontLarger"),disabled:Be>=Bt[Bt.length-1],onClick:()=>f({fontSize:pi(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:Re,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":be,"aria-controls":O,onClick:()=>ve(Q=>!Q),children:[t.jsx(aa,{}),t.jsx("span",{className:"bim-rd-tlabel",children:B("reader.settings")})]}),H]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Pe,ref:re,role:Ae&&$e?"dialog":void 0,"aria-modal":Ae&&$e?!0:void 0,"aria-label":Ae&&$e?B("reader.toc"):void 0,onKeyDown:Q=>{if(!(!Ae||!$e)){if(Q.key==="Escape"){Q.stopPropagation(),ue(!0);return}Q.key==="Tab"&&ca(Q,re.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:d??B("reader.toc")}),Ae&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.closeToc"),onClick:()=>ue(!0),children:"✕"})]}),l]}),t.jsx(nc,{items:i,activeKey:s!==void 0?s:o,onSelect:ke})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>ue(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":B("reader.images"),children:T&&(ae||t.jsx(Rr,{pages:c??null,loading:p,renderOverlay:h,preserveMargins:u.preserveMargins}))}),!q&&be&&t.jsxs("aside",{className:"bim-rd-set",id:O,"aria-label":B("reader.settings"),onKeyDown:Q=>{var Ge;Q.key==="Escape"&&(Q.stopPropagation(),ve(!1),(Ge=Re.current)==null||Ge.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:B("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.closeSettings"),onClick:()=>{var Q;ve(!1),(Q=Re.current)==null||Q.focus()},children:"✕"})]}),Ct]}),t.jsxs("div",{className:"bim-rd-text",id:G,ref:Y,tabIndex:-1,"data-rail":(j||C)&&!ne?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[je,Z&&We&&(We.sourceName||We.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":We.key,children:[We.sourceName&&t.jsxs(t.Fragment,{children:[B("reader.sourceLabel")," ",We.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:We.sourceUrl,target:"_blank",rel:"noreferrer",children:me(We.sourceName)}):me(We.sourceName)]}),We.sourceName&&We.license&&t.jsx("span",{className:"bim-rd-dot"}),We.license&&t.jsx(t.Fragment,{children:B("reader.licenseOf",{license:We.license})})]}),_&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:B("reader.revisedAt",{date:_})}),C&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:Q=>Q.preventDefault(),onClick:xe,children:B("reader.reportError")})}),z&&!M&&(Ce||Ve)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":B("reader.pagerNav"),children:[Ce?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>ke(Ce.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),B("reader.prevUnit",{unit:we})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Ce.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",B("reader.firstUnit",{unit:we})]}),Ve?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>ke(Ve.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[B("reader.nextUnit",{unit:we}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Ve.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[B("reader.lastUnit",{unit:we})," →"]})]})]}),(j||C)&&!ne&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":B("reader.rail"),children:[j,C&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:Q=>Q.preventDefault(),onClick:xe,children:B("reader.reportError")})})]})]})]}),q&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":B("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":$e,"aria-controls":Pe,onClick:()=>{de(null),ye()},children:[t.jsx(sa,{}),t.jsx("span",{children:B("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":D==="img","aria-haspopup":"dialog",onClick:Q=>W("img",Q.currentTarget),children:[t.jsx(la,{}),t.jsx("span",{children:B("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":D==="set","aria-haspopup":"dialog",onClick:Q=>W("set",Q.currentTarget),children:[t.jsx(aa,{}),t.jsx("span",{children:B("reader.settingsShort")})]}),C&&t.jsxs("button",{type:"button",onMouseDown:Q=>Q.preventDefault(),onClick:()=>{de(null),xe()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:B("reader.reportError")})]})]}),q&&D&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:se}),t.jsxs("div",{className:"bim-rd-sheet",ref:J,role:"dialog","aria-modal":"true","aria-label":B(D==="img"?"reader.images":"reader.settings"),onKeyDown:Q=>{if(Q.key==="Escape"){Q.stopPropagation(),se();return}Q.key==="Tab"&&ca(Q,J.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:B(D==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.close"),onClick:se,children:"✕"})]}),D==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(Rr,{pages:c??null,loading:p,renderOverlay:h,preserveMargins:u.preserveMargins})}):Ct]})]})]})}function Nh(e,n,i){return i?dc(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function dc(e){return e.replace(/\r\n/g,`
713
- `)}const pa=2,Th=400,Ih=6,pc=e=>e==="*"||e==="#"||e==="<"||e===">"||/\s/.test(e);function uc(e,n){if(e[n]!=="<"||e[n+1]!=="!"||e[n+2]!=="-"||e[n+3]!=="-")return-1;for(let i=n+4;i+2<e.length;i++)if(e[i]==="-"&&e[i+1]==="-"&&e[i+2]===">")return i+2;return-1}function Eh(e,n,i){let o=n;for(let s=0;s<i.length;){if(o>=e.length)return-1;if(i[s]===e[o]){s++,o++;continue}const a=uc(e,o);if(a>=0){o=a+1;continue}if(pc(e[o])){o++;continue}if(i[s]===" "){s++;continue}return-1}return o}function Rh(e){const n=Array.from(dc(e));let i=0;return{align(o){if(!o)return;const s=Array.from(o);if(s.every(d=>d===" "||/\s/.test(d)))return;const a=s.length>=Ih;let l=0;for(let d=i;d<n.length&&d-i<=(a?Th:pa+64);d++){const c=uc(n,d);if(c>=0){d=c;continue}if(!pc(n[d])){const h=Eh(n,d,s);if(h>=0)return i=h,d;if(l++,!a&&l>pa)return}}}}}const mc=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Lh={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function ot(e){return Lh[e]??e}const xn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],bn={熹平:172,建安:196,黃初:220,正始:240,廣政:938,太康:280,永和:345,開皇:581,貞觀:627,開元:713,天寶:742,貞元:785,元和:806,開成:836,會昌:841,咸通:860,建隆:960,太平興國:976,咸平:998,天禧:1017,慶曆:1041,皇祐:1049,嘉祐:1056,治平:1064,熙寧:1068,元豐:1078,元祐:1086,紹聖:1094,崇寧:1102,大觀:1107,政和:1111,宣和:1119,建炎:1127,紹興:1131,隆興:1163,乾道:1165,淳熙:1174,紹熙:1190,慶元:1195,嘉泰:1201,開禧:1205,嘉定:1208,寶慶:1225,紹定:1228,端平:1234,嘉熙:1237,淳祐:1241,寶祐:1253,開慶:1259,景定:1260,咸淳:1265,大定:1161,明昌:1190,至元:1264,大德:1297,皇慶:1312,延祐:1314,泰定:1324,天曆:1328,至順:1330,至正:1341,洪武:1368,永樂:1403,宣德:1426,正統:1436,景泰:1450,天順:1457,成化:1465,弘治:1488,正德:1506,嘉靖:1522,隆慶:1567,萬曆:1573,泰昌:1620,天啟:1621,崇禎:1628,弘光:1645,隆武:1645,紹武:1646,永曆:1647,順治:1644,康熙:1662,雍正:1723,乾隆:1736,嘉慶:1796,道光:1821,咸豐:1851,同治:1862,光緒:1875,宣統:1909,慶長:1596,寬永:1624,正保:1644,慶安:1648,承應:1652,明曆:1655,萬治:1658,寬文:1661,延寶:1673,天和:1681,貞享:1684,元祿:1688,寶永:1704,享保:1716,元文:1736,寬保:1741,延享:1744,寬延:1748,寶曆:1751,明和:1764,安永:1772,天明:1781,寬政:1789,享和:1801,文化:1804,文政:1818,天保:1830,弘化:1844,嘉永:1848,安政:1854,萬延:1860,文久:1861,元治:1864,慶應:1865,明治:1868,大正:1912,昭和:1926,天正:1573,文祿:1592,永祿:1558,天文:1532},hc={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Pi(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const i=parseInt(n[1],10);if(i<100||i>2100)return;const o=n[2]?parseInt(n[2],10):void 0;return{from:i,to:o!=null&&o>=i&&o<=2100?o:void 0}}function Ah(e){return e>=1950?"":e>=1912?"民國":e>=1645?"清":e>=1368?"明":e>=1279?"元":e>=960?"宋":e>=907?"五代":e>=618?"唐":e>=581?"隋":e>=420?"南北朝":e>=265?"晉":e>=220?"三國":e>=-202?"漢":""}const Mh=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,ua={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function xo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(ua))if(n.startsWith(s))return ua[s];const i=ot(n);if(tn[i]!=null)return i;const o=Wt(n);if(o&&n.length<=o.length+1)return ot(o)}function en(e,n){if(n){const i=hc[`${n}|${e}`];if(i!=null)return i}return bn[e]}const Ph=1911;function Bh(e){const n=bn[e];if(n==null)return;const i=It[e];let o;for(const[s,a]of Object.entries(bn))It[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const Oh={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Si(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,i=0,o=!1;for(const a of e){const l=Oh[a];if(l===void 0)return;o=!0,a==="十"?i=(i||1)*10:a==="廿"||a==="卅"?(n+=l,i=0):i>=10?(n+=i+l,i=0):i=i*10+l}const s=n+i;return o&&s>0?s:void 0}function Wt(e){for(const n of mc)if(e.startsWith(n))return n}const It={};{const e=(n,i)=>{for(const o of i)It[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function nn(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(bn))if(e.includes(o)&&!(i&&It[o]&&It[o]!==i&&hc[`${i}|${o}`]==null))return o}function Gn(e){var l,d,c;const n={era:"",reign:"",source:"none"},i=e.dating;if(i!=null&&i.era||i!=null&&i.reign)return{era:i.era??"",reign:i.reign??"",source:i.certainty==="attested"?"catalog":"edition"};const o=(l=e.lineage)==null?void 0:l.year_text;if(o){const p=Wt(o)??"";return{era:ot(p),reign:nn(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=Pi(s);if(p)return{era:Ah(p.from),reign:"",source:"publication"};const h=Wt(s)??xo(s)??((c=xn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",m=nn(s,h)??"",u=h||(m?It[m]??"":"");if(u||m)return{era:ot(u),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Wt(a);if(p)return{era:ot(p),reign:nn(a,p)??"",source:"edition"};const h=xn.find(m=>m.pattern.test(a));if(h)return{era:ot(h.era),reign:nn(a,h.era)??h.reign??"",source:"edition"}}return n}function Bi(e){var o,s,a,l,d,c,p,h,m;if(((o=e.dating)==null?void 0:o.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(a=e.publication_info)==null?void 0:a.year;if(n){const u=Pi(n);if(u)return u.from}const i=[(l=e.lineage)==null?void 0:l.year_text,(d=e.publication_info)==null?void 0:d.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const u of i){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&u!==f&&(Wt(f)||xo(f)))break;const x=u.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??u.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const w=parseInt(x[1],10);if(w>=100&&w<=2100)return w}const v=u.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(v){const w=Wt(u);if(!w||ot(w)==="民國"){const j=Si(v[1]);if(j!=null&&j>=1&&j<=120)return Ph+j}}const b=Wt(u)??((h=xn.find(w=>w.pattern.test(u)))==null?void 0:h.era),$=b?ot(b):void 0,y=nn(u,$)??(Wt(u)||(m=xn.find(w=>w.pattern.test(u)))==null?void 0:m.reign);if(y){const w=en(y,$);if(w==null)continue;const k=u.indexOf(y),j=k>=0?u.slice(k+y.length):"",C=j.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??j.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=C?Si(C[1]):void 0;return w+(_?_-1:0)}}}function bo(e){var l,d,c,p,h,m;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(d=e.lineage)==null?void 0:d.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const o=(c=e.lineage)==null?void 0:c.year_text;if(o){const u=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(u){const f=Mr[ot(u[1])],x=tn[ot(u[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const u=Pi(s);if((u==null?void 0:u.to)!=null)return{from:u.from,to:u.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=Mr[ot(f[1])],v=tn[ot(f[2])];if(x!=null&&v!=null)return{from:Math.min(x,v)-20,to:Math.max(x,v)+40}}}const a=[(h=e.publication_info)==null?void 0:h.year,e.edition,e.title].filter(Boolean);for(const u of a){if(!/[間间]/.test(u))continue;const f=Wt(u)??xo(u)??((m=xn.find(b=>b.pattern.test(u)))==null?void 0:m.era),x=f?ot(f):void 0,v=[];for(const b of Object.keys(bn))u.includes(b)&&(x&&It[b]&&It[b]!==x||en(b,x)!=null&&v.push(b));if(v.length===0){const b=u.match(/([一-鿿])([一-鿿])[間间]/);if(b&&x){for(const $ of[b[1],b[2]])for(const y of Object.keys(bn))if(It[y]===x&&!(y[0]!==$&&y[y.length-1]!==$)&&en(y,x)!=null){v.push(y);break}}}if(v.length>0){const b=v.map(k=>en(k,x)).filter(k=>k!=null),$=Math.min(...b),y=v.reduce((k,j)=>en(k,x)>=en(j,x)?k:j),w=Bh(y)??xr(x??"")??Math.max(...b);return{from:$,to:w>$?w:xr(x??It[y]??"")??$}}if(x&&tn[x]!=null)return{from:tn[x],to:xr(x)??tn[x]}}}const tn={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Wh=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Fh=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,ma=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function ha(e,n){for(const i of mc){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!nn(e.slice(o),ot(i)))continue}const s=ot(i);if(s===n)continue;const a=e.slice(o),l=nn(a,s)??"";let d;if(l){const c=en(l,s);if(c!=null){const h=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=h?Si(h[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const i of xn)if(i.pattern.test(e))return{era:ot(i.era),reign:i.reign??""}}function Hh(e){var $,y,w,k,j;const n=Gn(e),i=(($=e.publication_info)==null?void 0:$.year)??"",o=i?Pi(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((y=e.lineage)==null?void 0:y.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&Mh.test(i),p=n.source==="publication"&&/[間间]/.test(i),h=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:h?m=parseInt(h[2],10):m=Bi(e);const u=m==null?bo(e):void 0;let f;n.source==="publication"&&(c||ma.test(i))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":ma.test(s)||!n.reign&&m==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((w=e.lineage)==null?void 0:w.year_text)??((k=e.lineage)==null?void 0:k.year)??""}」`:`出版著錄「${((j=e.publication_info)==null?void 0:j.year)??""}」`,v={era:n.era,reign:n.reign,year:m,yearRange:u,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(h){const C=l.match(/[、,,]\s*([宋元明清])/);C&&C[1]!==v.era&&(v.laterRepair={era:C[1]})}if(!v.laterRepair&&Fh.test(s)){const C=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);C&&C[1]!==n.era&&(v.laterRepair={era:C[1]})}const b=Wh.find(C=>C.re.test(s));if(b){const C=s.search(b.re),_=s.slice(C),S=ha(_,n.era)??ha(s,n.era);S&&(v.basedOn={era:S.era,reign:S.reign,year:S.year,relation:b.relation})}return v}const Mr={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function xr(e){return Mr[e]}function _i(e){const n=Bi(e);if(n!=null)return n;const i=bo(e);if(i)return i.from;const o=Gn(e).era;return o?tn[o]:void 0}const ga=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Pr(e){const n=ga.indexOf(e);return n===-1?ga.length:n}function Dh(e){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of e){const a=s.relation;a==="part_of"?n.belongsTo.push(s):a==="collected_in"?n.collected.push(s):a==="has_part"||a==="contains_text_of"?n.contains.push(s):a==="text_carried_by"||a==="studied_by"||a==="derived_from"||a==="followed_by"||a==="has_adaptation"?n.derivative.push(s):a==="studies"||a==="preceded_by"?n.studies.push(s):n.related.push(s)}const i=[],o=(s,a)=>{n[s].length&&i.push({key:s,labelKey:a,items:n[s]})};return o("belongsTo","belongsToWork"),o("collected","collectedIn"),o("contains","containedWorks"),o("derivative","derivativeWorks"),o("studies","studies"),o("related","relatedWorks"),i}function yo(e,n){const i=ro(e||[]),o=new Map,s=[];for(const p of i)p.group?(o.has(p.group)||o.set(p.group,[]),o.get(p.group).push(p)):s.push(p);for(const p of o.values())p.sort((h,m)=>{const u=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return u(h)-u(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const h=Ft(p),m=h.includes("text"),u=h.includes("image");m&&u?a.textImage.push(p):m?a.text.push(p):u?a.image.push(p):a.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>a[p].length>0).map(p=>({key:p,items:a[p]})),c=[...o.entries()].map(([p,h])=>{var m,u;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(u=n==null?void 0:n[p])==null?void 0:u.description,items:h}});return{buckets:d,mirrors:c,total:i.length}}function Oi(e,n=wn("zh-Hant")){const i=[],o=e.metadata||{};o.edition&&i.push(String(o.edition)),e.source_label&&i.push(e.source_label),e.details&&i.push(e.details);const s=Ti(e);return s&&s.expected>0&&i.push(s.missing>0?n("detail.volumeStatsMissing",{found:s.found,expected:s.expected,missing:s.missing}):n("detail.volumeStats",{found:s.found,expected:s.expected})),o.version&&i.push(String(o.version)),i.join(" · ")}function gc(e,n){if(Oi(e)||n.filter(o=>o.name===e.name).length<2)return"";try{const o=new URL(e.url),s=o.searchParams.get("res")||o.searchParams.get("id");if(s)return s;const a=o.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}const Uh="同版";function Vh(e){const n=e==null?void 0:e.metadata;return((n==null?void 0:n.item_id)||(n==null?void 0:n.call_number)||"").trim()||void 0}function Gh(e){var n;for(const i of((n=e.lineage)==null?void 0:n.related_to)??[]){const o=i.ref??i.book_id;if(i.relation===Uh&&o&&o!==e.id)return o}}function Yh(e){const n=new Map(e.map(a=>[a.id,a])),i=a=>{const l=n.get(a);return!!l&&!l.copyOf},o=new Map;for(const a of e)if(a.copyOf&&i(a.copyOf)){const l=o.get(a.copyOf)??[];l.push(a),o.set(a.copyOf,l)}if(o.size===0)return e;const s=[];for(const a of e){if(a.copyOf&&i(a.copyOf))continue;const l=o.get(a.id);if(!l){s.push(a);continue}const d=[...l].sort((c,p)=>(c.callNumber??c.id).localeCompare(p.callNumber??p.id));s.push({...a,copies:d,hasImage:a.hasImage||d.some(c=>c.hasImage)})}return s}function fc(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Ft(d);c.includes("image")&&o.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Gn(e),year:Bi(e),sortYear:_i(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,callNumber:Vh(s[0]),copyOf:Gh(e),summary:e.summary,important:Kh(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function Kh(e,n){var d,c;if(!n)return!1;const i=n.default_collection;if(!i)return!1;const o=(d=n.collections)==null?void 0:d[i];if(((o==null?void 0:o.book_ids)??(i==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(o==null?void 0:o.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function xc(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=Yh(e.filter(c=>!o.has(c.id)).map(c=>fc(c,n)));let a=s;i.era&&(a=a.filter(c=>c.era.era===i.era)),i.scanOnly&&(a=a.filter(c=>c.hasImage)),i.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=c.r.sortYear,m=p.r.sortYear;return h!=null&&m!=null?h-m||c.i-p.i:h!=null?-1:m!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const h=m=>(m.important?0:1)*2+(m.hasImage?0:1);return h(c.r)-h(p.r)||c.i-p.i}).map(c=>c.r);const d=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,p)=>Pr(c)-Pr(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function qh(e,n){var b,$;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(b=n.collections)==null?void 0:b[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(o),c=new Set([...s,...l]),p=y=>{if(c.has(y))return!0;const w=n.node_groups[y];return w!=null&&d.has(w)},h=[],m=new Map,u=[];for(const y of e)if(!(($=n.excluded_books)!=null&&$.includes(y)))if(p(y))h.push(y);else{const w=n.node_groups[y];w?(m.has(w)||m.set(w,[]),m.get(w).push(y)):u.push(y)}if(u.length+[...m.values()].reduce((y,w)=>y+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(y=>[y.id,y])),v=[...m.entries()].map(([y,w])=>{const k=x.get(y);return{id:y,label:(k==null?void 0:k.label)??y,description:k==null?void 0:k.description,ids:w}});return u.length>0&&v.push({id:"__other__",label:"其他版本",description:void 0,ids:u}),{useGrouping:!0,coreIds:h,groupedIds:v}}const bc=["撰","編","注","校","譯","繪","其他"],Xh=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function jo(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of Xh)if(o.test(n))return i;return"其他"}function vo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function yc(e,n="全部"){const i=new Map;for(const s of e){const a=jo(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of bc){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function ko(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function wo(e){const n=e._classifications??[],i=n.find(o=>o.scheme==="zongmu")??n[0];if(i)return{l1:i.l1??"",l2:i.l2??"",l3:i.l3??"",l4:i.l4??"",...i.source?{source:i.source}:{}}}function jc(e){const n=e._members??[],i=typeof e._member_count=="number"?e._member_count:n.length;return{works:n.filter(o=>o.t==="work").map(o=>({id:o.id,title:o.title??"",volumes:Fn(o.vol)})),bookIds:n.filter(o=>o.t!=="work").map(o=>o.id).filter(o=>typeof o=="string"),total:i,truncated:i>n.length}}function Zh(e){var n;return(e==null?void 0:e._member_count)||((n=e==null?void 0:e._members)==null?void 0:n.length)||0}function vc(e,n,i){if(n&&n.books&&n.books.length>0){const l=n.books.map(c=>({id:c.work_id||c.book_id||void 0,title:c.title,section:c.section,volumes:c.volumes||[],subItems:c.sub_items,edition:c.edition,found:c.found_volumes,expected:c.expected_volumes})),d=[...new Set(l.map(c=>c.section).filter(Boolean))];return{rows:l,source:"catalog",sections:d,totalVolumes:n.total_volumes}}const{works:o,bookIds:s}=jc(e);return o.length>0?{rows:o.map(d=>({id:d.id,title:d.title,volumes:d.volumes})),source:"works",sections:[]}:{rows:s.map(l=>{var d,c;return{id:l,title:((d=i==null?void 0:i.get(l))==null?void 0:d.title)||l,edition:(c=i==null?void 0:i.get(l))==null?void 0:c.edition,volumes:[]}}),source:"books",sections:[]}}function Fn(e){if(e==null)return[];if(typeof e=="number")return[e];if(Array.isArray(e))return e.filter(n=>typeof n=="number");if(typeof e=="string"){const n=e.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[i,o]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,o-i+1)},(s,a)=>i+a)}return e.split(/[,、]/).map(i=>parseInt(i.trim())).filter(i=>!isNaN(i))}return[]}function Wi(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=[...e].sort((a,l)=>a-l),o=i[0],s=i[i.length-1];return s-o+1===i.length?`${o}–${s}`:i.length<=3?i.join(", "):`${o}–${s} (${i.length}${n})`}const Jh=["〇","一","二","三","四","五","六","七","八","九"],fa=["","十","百","千"];function kc(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let o="",s=!1;for(let a=0;a<i;a++){const l=parseInt(n[a]),d=i-1-a;l===0?s=!0:(s&&o&&(o+="〇"),s=!1,l===1&&d===1&&a===0?o+=fa[d]:o+=Jh[l]+fa[d])}return o}function Qh(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function eg(e){if(e==null||typeof e=="string")return;const n="url"in e&&e.url?e.url:"type"in e&&e.type==="url"?e.details:void 0;return n&&/^https?:\/\//i.test(n)?n:void 0}function Dt(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?kc(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function wc(e){var o;if(e.edition_type)return e.edition_type;if((o=e.lineage)!=null&&o.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/油印/,"油印本"],[/曬印|晒印/,"曬印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of i)if(s.test(n))return a;return""}const tg=65536,ng="guji_markdown";function ig(e){const n=e==null?void 0:e.guji_markdown;if(typeof n!="string")return!1;const i=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!i)return!1;const o=parseInt(i[1],10),s=parseInt(i[2],10);return o>0||s>=2}const rg=/^□\{guess=([^\s{}]+)\}/;function og(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function Sc(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
714
- `)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function sg(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function ag(e,n){const i=e[n];if(i==="["&&e[n+1]==="["){const o=e.indexOf("]]",n+2);return o>=0&&e.slice(n+2,o).indexOf(`
715
- `)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=Sc(e,n+3);return o>n+4?{node:{type:"zi",label:sg(e.slice(n+4,o))},end:o+1}:null}if(i==="□"&&e[n+1]==="{"){const o=rg.exec(e.slice(n,n+64));if(o)return{node:{type:"qz",guess:o[1]},end:n+o[0].length}}return null}function _c(e,n,i,o,s){const a=[];let l="",d=!1;const c=()=>{if(!l)return;let p=l;o&&(p=l.replace(/\\?\|/g,h=>d?"|":(d=!0,""))),p&&a.push({type:"text",text:p}),l=""};for(;n<e.length;){const p=e[n];if(p==="\\"&&(e[n+1]==="<"||e[n+1]===">")){l+=e[n+1],n+=2;continue}if(i!==null){if(p===i)return c(),{nodes:a,end:n};if(p===`
716
- `)return null}const h=ag(e,n);if(h){c(),a.push(h.node),n=h.end;continue}let m=null;if(p==="<"&&og(e,n)&&(m=">"),m){const u=_c(e,n+1,m,!0,s);if(u&&!(u.end-(n+1)>s)){c(),a.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function $c(e,n){return _c(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??tg).nodes}function lg(e){return/[<□]|\[\[|:zi\[/.test(e)}function Cc(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Cc(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const cg=216,xa="clamp(280px, 23vw, 360px)",dg=1440,Br="(max-width: 719px)",pg=`${Br}, (pointer: coarse)`,ug=`
717
- .bim-d-main.bim-d-main-grid { max-width: ${dg}px; padding: 16px 32px 0; }
710
+ .guji-page-indicator { opacity: 0.55; transition: opacity 0.15s; outline: none; }
711
+ .guji-page-indicator:hover, .guji-page-indicator:focus-visible { opacity: 1; }
712
+ .guji-page-indicator:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 1px; border-radius: 3px; }
713
+ @media ${bi} { .guji-page-indicator { display: none; } }
714
+ `;function So(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>So(o,n))):!1}const ca=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Ah({item:e,activeKey:n,onSelect:i,tabKey:o}){const{t:s}=ne(),a=So(e,n),[l,d]=g.useState(a||!!e.defaultExpanded);return g.useEffect(()=>{a&&d(!0)},[a]),g.useEffect(()=>{e.defaultExpanded&&d(!0)},[e.defaultExpanded]),e.selectable?t.jsxs("li",{children:[t.jsxs("div",{className:"bim-rd-ti-row",children:[t.jsx("button",{type:"button",className:"bim-rd-ti-tw","aria-expanded":l,"aria-label":s(l?"reader.tocCollapse":"reader.tocExpand"),tabIndex:-1,onClick:()=>d(c=>!c),children:t.jsx(ca,{})}),t.jsxs("button",{type:"button",className:`bim-rd-ti${e.inChapter?"":" bim-rd-ti-group"}`,"aria-current":e.key===n?"true":void 0,disabled:e.disabled,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>{d(!0),i(e.key)},onKeyDown:c=>{c.key==="ArrowRight"&&!l?(c.preventDefault(),d(!0)):c.key==="ArrowLeft"&&l&&(c.preventDefault(),d(!1))},children:[t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]})]}),l&&t.jsx(Mr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]}):t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>d(c=>!c),children:[t.jsx(ca,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),l&&t.jsx(Mr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Mr({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Ah,{item:s,activeKey:n,onSelect:i,tabKey:o},s.key):t.jsx("li",{children:t.jsxs("button",{type:"button",className:"bim-rd-ti","aria-current":s.key===n?"true":void 0,disabled:s.disabled,"data-rd-toc-key":s.key,tabIndex:o===s.key?0:-1,onClick:()=>i(s.key),children:[t.jsx("span",{children:s.label}),s.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function da(e,n){var i;for(const o of e)if(o.key===n||So(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function uc({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=ne(),a=o??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??da(e,n)),[d,n,e]);g.useEffect(()=>{const m=l.current;if(!m)return;const u=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(u.length===0)return;const f=u.find(x=>x.dataset.rdTocKey===p)??u.find(x=>x.dataset.rdTocKey===da(e,n))??u.find(x=>!x.disabled)??u[0];for(const x of u)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const m=l.current,u=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!u||!n)return;const f=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(v=>v.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-u.getBoundingClientRect().top+u.scrollTop;(x<u.scrollTop+80||x>u.scrollTop+u.clientHeight-40)&&(u.scrollTop=Math.max(0,x-u.clientHeight/3))},[n]);const h=g.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(y=>!y.disabled),v=x.indexOf(document.activeElement);let b=v;if(m.key==="ArrowDown"?b=Math.min(x.length-1,v+1):m.key==="ArrowUp"?b=Math.max(0,v-1):m.key==="Home"?b=0:m.key==="End"&&(b=x.length-1),b<0||b===v)return;m.preventDefault();const _=x[b];for(const y of x)y.tabIndex=-1;_.tabIndex=0,_.focus(),c(_.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:h,children:t.jsx(Mr,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function pa({page:e,crop:n}){var i;return!((i=e.boxes)!=null&&i.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:n?`${n.x} ${n.y} ${n.w} ${n.h}`:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,s)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:r("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},s))})}function Mh(e){const{boxes:n,width:i,height:o}=e;if(!(n!=null&&n.length)||!i||!o||e.boxFormat&&e.boxFormat!=="bim-charbox-v0")return null;let s=1/0,a=1/0,l=-1/0,d=-1/0;for(const f of n)[f.x,f.y,f.w,f.h].every(Number.isFinite)&&(s=Math.min(s,f.x),a=Math.min(a,f.y),l=Math.max(l,f.x+f.w),d=Math.max(d,f.y+f.h));if(!(l>s)||!(d>a))return null;const c=Math.min(i,o)*.03,p=Math.min(i,Math.max(0,s-c)),h=Math.min(o,Math.max(0,a-c)),m=Math.min(i,Math.max(0,l+c))-p,u=Math.min(o,Math.max(0,d+c))-h;return!(m>0)||!(u>0)||m>=i*.98&&u>=o*.98?null:{x:p,y:h,w:m,h:u}}function Pr({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=ne(),[d,c]=g.useState(0),p=i??d,h=v=>{o?o(v):c(v)};if(g.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const m=Math.max(0,Math.min(e.length-1,p)),u=e[m],f=u.label??`${m+1}`,x=!a&&!s?Mh(u):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:f}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${u.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(pa,{page:u,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:f}),width:u.width,height:u.height,loading:"lazy",decoding:"async"}),t.jsx(pa,{page:u}),s==null?void 0:s(u,m)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:m===0,onClick:()=>h(m-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:u.label??`${m+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:m===e.length-1,onClick:()=>h(m+1),children:"›"})]})]})}function Ph(e){return e==="lite"||e==="full"}const Gn=[.1,.9],mc=[{key:"song",stack:null},{key:"kai",stack:'"Kaiti SC", "Kaiti TC", STKaiti, "KaiTi", "AR PL UKai CN", "Noto Serif CJK SC", serif'},{key:"system",stack:"var(--bim-font-ui)"}];function Bh(e){var n;return((n=mc.find(i=>i.key===e))==null?void 0:n.stack)??null}const _o={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!1,pageIndicatorY:.33,bookTitleStyle:"bracket",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Bt=[15,16,17,18,20,22,24],Br=18,hc="bim-reader-prefs",gc=2,Oh="bim-reading-mode";function Wh(){const e={..._o};try{const n=localStorage.getItem(hc),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Bt.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(Oh))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily);const s=i.v===gc;s&&typeof i.pageBreaks=="boolean"&&(e.pageBreaks=i.pageBreaks),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=Gn[0]&&i.pageIndicatorY<=Gn[1]&&(e.pageIndicatorY=i.pageIndicatorY),s&&(i.bookTitleStyle==="wavy"||i.bookTitleStyle==="bracket")&&(e.bookTitleStyle=i.bookTitleStyle),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function Fh(e){try{localStorage.setItem(hc,JSON.stringify({...e,v:gc}))}catch{}}function mi(e,n){const i=e??Br,o=Bt;let s=o.indexOf(i);return s<0&&(s=o.indexOf(Br)),o[Math.max(0,Math.min(o.length-1,s+n))]}function fc(){const[e,n]=g.useState(_o);g.useEffect(()=>{n(Wh())},[]);const i=g.useCallback(o=>{n(s=>{const a={...s,...o};return Fh(a),a})},[]);return[e,i]}function Or(e){if(e.optionLabel)return e.optionLabel;const n=e.label||e.key;return!e.sourceName||n.includes(e.sourceName)?n:`${n} · ${e.sourceName}`}function xc(e,n){if(!(!e||e.length===0))return(n!=null?e.find(i=>i.key===n):void 0)??e.find(i=>i.primary)??e[0]}function bc(e){const n=[],i=o=>{for(const s of o){if(s.inChapter)continue;const a=!!s.children&&s.children.length>0;(!a||s.selectable)&&n.push(s),a&&i(s.children)}};return i(e),n}const ua=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),Hh=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M15 5l-7 7 7 7"})}),Dh=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M9 5l7 7-7 7"})}),ma=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),ha=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),t.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function ga(e,n){if(!n)return;const i=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(i.length===0)return;const o=i[0],s=i[i.length-1],a=document.activeElement;e.shiftKey&&(a===o||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),o.focus())}function fa(e,n){const[i,o]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),i}function Uh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=g.useContext(Rt),{t:s}=ne();if(!o)return null;const a=o.locale==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a,d=[{key:"orig",short:s("reader.scriptOrigShort"),title:s(i?"reader.scriptOrig":"reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",short:s("common.localeShortHant"),title:s("reader.scriptHant")},{key:"hans",short:s("common.localeShortHans"),title:s("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":s("reader.scriptQuick"),children:d.map((c,p)=>t.jsxs(g.Fragment,{children:[p>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":l===c.key,title:c.title,"aria-label":c.title,disabled:c.disabled,onClick:()=>{c.disabled||(n({scriptMode:c.key}),c.key==="hant"?o.setLocale("zh-Hant"):c.key==="hans"&&o.setLocale("zh-Hans"))},children:c.short})]},c.key))})}function yi({label:e,value:n,options:i,onPick:o,title:s}){return t.jsxs("div",{className:"bim-rd-sp-row",role:"group","aria-label":e,title:s,children:[t.jsx("span",{className:"bim-rd-sp-l",children:e}),t.jsx("span",{className:"bim-rd-sp-fs",children:i.map(a=>t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":n===a.key,title:a.title,disabled:a.disabled,onClick:()=>{a.disabled||o(a.key)},children:a.label},a.key))})]})}function Vh({prefs:e,onPrefsChange:n,origAvailable:i}){const o=g.useContext(Rt),{t:s}=ne(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx(yi,{label:s("reader.script"),value:l,options:[{key:"orig",label:s("reader.scriptOrig"),title:i?void 0:s("reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",label:s("reader.scriptHant")},{key:"hans",label:s("reader.scriptHans")}],onPick:d=>{n({scriptMode:d}),d==="hant"?o==null||o.setLocale("zh-Hant"):d==="hans"&&(o==null||o.setLocale("zh-Hans"))}})}function Gh(e,n){if(!e)return;let i;for(const o of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(o.getBoundingClientRect().top<=n+8)i=o.id;else break;return i}function Yh(e){var a;if(typeof window>"u"||!e)return;const n=(a=window.getSelection)==null?void 0:a.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const i=e.querySelector(".bim-rd-col"),o=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(i!=null&&i.contains(l))&&!(d!=null&&d.closest(".bim-rd-src, .bim-rd-pager"))};if(!o(n.anchorNode)||!o(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function yc({title:e,subtitle:n,toc:i,activeKey:o,tocActiveKey:s,onSelect:a,tocHeader:l,tocCaption:d,images:c,imagesLoading:p,renderImageOverlay:h,imagePanel:m="auto",prefs:u,onPrefsChange:f,paragraphToggle:x,properNameToggle:v=!0,allowVertical:b,origScriptAvailable:_=!0,byline:y,current:w,workLinkToggle:j,rail:k,onReportError:C,revisedAt:$,backHref:S,backLabel:E,bottomBar:N=!0,pager:z=!0,contentLoading:O=!1,pagerUnit:F,versions:A,currentVersionKey:I,onVersionChange:P,versionSource:K=!0,keepChapterOnVersionChange:oe=!1,customImagePanel:le,toolbarExtra:H,settingsAnnotate:de,settingsLayout:U,isWarpMode:te,children:ve,className:fe,style:Ae}){const{t:B,convert:me}=ne(),ze=E??B("reader.back"),we=me(F??B("reader.unitJuan")),De=g.useId().replace(/:/g,""),Pe=`bim-rd-toc-${De}`,G=`bim-rd-text-${De}`,he=g.useRef(null),q=g.useRef(null),se=g.useRef(null),Y=g.useRef(null),M=fa(cc,!0),X=fa(dc,!1),J=N&&X,[D,ye]=g.useState(null),[ue,ge]=g.useState(!1),Ie=g.useRef(null),L=`bim-rd-set-${De}`,ie=g.useRef(null),je=g.useRef(null),W=(Z,Ge)=>{je.current=Ge,ye(dt=>dt===Z?null:Z)},ae=g.useCallback(()=>{var Z;ye(null),(Z=je.current)==null||Z.focus()},[]);g.useEffect(()=>{J||ye(null)},[J]),g.useEffect(()=>{var Z,Ge;D&&((Ge=(Z=ie.current)==null?void 0:Z.querySelector("button:not([disabled])"))==null||Ge.focus())},[D]);const[V,re]=g.useState("auto"),_e=V==="auto"?M:V==="open",Le=!M,He=!!le||!!c&&c.length>0,[qe,Xe]=g.useState(m);g.useEffect(()=>{Xe(m)},[m]);const T=qe==="auto"?He||!!p:qe==="open",pe=g.useCallback(Z=>{var Ge;re("auto"),Z&&((Ge=Y.current)==null||Ge.focus())},[]),xe=()=>re(_e?"closed":"open");g.useEffect(()=>{if(!Le||V!=="open")return;const Z=se.current,Ge=Z==null?void 0:Z.querySelector('input, [data-rd-toc-key][tabindex="0"]');Ge==null||Ge.focus()},[Le,V]);const ke=g.useCallback(Z=>{a(Z),Le&&pe(!1);const Ge=q.current,dt=he.current;if(Ge&&dt&&typeof window<"u"){const Et=Ge.getBoundingClientRect().top-dt.getBoundingClientRect().bottom;Et<0&&window.scrollBy({top:Et})}},[a,Le,pe]),Ne=g.useMemo(()=>bc(i),[i]),[Se,Ke]=g.useState(null),Oe=xc(A,I!==void 0?I:Se),Q=(Oe==null?void 0:Oe.key)??null,ee=g.useMemo(()=>Ne.map(Z=>Z.key).join(`
715
+ `),[Ne]),Fe=g.useRef(null),We=Z=>{Z!==Q&&(oe||(Fe.current={key:Z,sig:ee,done:!1}),I===void 0&&Ke(Z),P==null||P(Z))};g.useEffect(()=>{const Z=Fe.current;if(!Z||Z.key!==Q)return;const Ge=Ne.find(Et=>!Et.disabled);if(!Ge)return;const dt=ee!==Z.sig;!dt&&Z.done||(dt?Fe.current=null:Z.done=!0,Ge.key!==o&&ke(Ge.key))},[Q,ee,Ne,o,ke]);const Re=Ne.find(Z=>Z.key===o),be=()=>{var Z;C==null||C({chapterKey:o,chapterLabel:typeof(Re==null?void 0:Re.label)=="string"?Re.label:void 0,anchor:Gh(q.current,((Z=he.current)==null?void 0:Z.getBoundingClientRect().bottom)??0),selectedText:Yh(q.current)})},Ye=Ne.findIndex(Z=>Z.key===o),Ce=Ye>0?Ne.slice(0,Ye).reverse().find(Z=>!Z.disabled):void 0,Ve=Ye>=0?Ne.slice(Ye+1).find(Z=>!Z.disabled):void 0,Be=u.fontSize??Br,et=Bh(u.fontFamily),kt={...Ae,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...et?{"--bimrd-ff":et}:null},wt={song:B("reader.fontSong"),kai:B("reader.fontKai"),system:B("reader.fontSystem")},cn=v||!!de,Ct=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${L}-g1`,children:[t.jsx("h3",{id:`${L}-g1`,className:"bim-rd-sp-h",children:B("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:B("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":B("reader.font"),value:u.fontFamily,onChange:Z=>f({fontFamily:Z.target.value}),children:mc.map(Z=>t.jsx("option",{value:Z.key,children:wt[Z.key]},Z.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:B("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.fontSmaller"),disabled:Be<=Bt[0],onClick:()=>f({fontSize:mi(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Be,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.fontLarger"),disabled:Be>=Bt[Bt.length-1],onClick:()=>f({fontSize:mi(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(Vh,{prefs:u,onPrefsChange:f,origAvailable:_}),t.jsx(yi,{label:B("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:B("reader.quoteModern")},{key:"classic",label:B("reader.quoteClassic")},{key:"original",label:B("reader.quoteOriginal")}],onPick:Z=>f({quoteStyle:Z})})]}),cn&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${L}-g2`,children:[t.jsx("h3",{id:`${L}-g2`,className:"bim-rd-sp-h",children:B("reader.groupMark")}),v&&t.jsxs(t.Fragment,{children:[t.jsx(yi,{label:B("reader.properName"),value:u.properNameMode,title:B("reader.properNameTitle"),options:[{key:"off",label:B("reader.properNameOff")},{key:"lite",label:B("reader.properNameLite"),title:B("reader.properNameLiteTitle")},{key:"full",label:B("reader.properNameFull")}],onPick:Z=>f({properNameMode:Z})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:Z=>f({showWorks:Z.target.checked})}),t.jsx("span",{children:B("reader.showWorks")})]}),t.jsx(yi,{label:B("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:B("reader.bookTitleWavy")},{key:"bracket",label:B("reader.bookTitleBracket")}],onPick:Z=>f({bookTitleStyle:Z})})]}),de]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${L}-g3`,children:[t.jsx("h3",{id:`${L}-g3`,className:"bim-rd-sp-h",children:B("reader.groupLayout")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:B("reader.paragraphTitle"),onClick:()=>f({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:B("reader.paragraph")}),j&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:Z=>f({workLinks:Z.target.checked})}),t.jsx("span",{children:B("reader.workLinks")})]}),b&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>f({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:B("reader.vertical")}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.pageBreaks,onChange:Z=>f({pageBreaks:Z.target.checked})}),t.jsx("span",{children:B("reader.pageBreaks")})]}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:Z=>f({preserveMargins:Z.target.checked})}),t.jsx("span",{children:B("reader.preserveMargins")})]}),U]})]});return t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&b?"bim-rd-vertical":"",fe].filter(Boolean).join(" "),"data-toc":V,"data-img":T?"open":"closed","data-bb":J?"":void 0,"data-set":!J&&ue?"open":void 0,"data-warp":te?"true":void 0,style:kt,children:[t.jsx("style",{children:pc}),t.jsx("a",{className:"bim-rd-skip",href:`#${G}`,onClick:Z=>{var Ge,dt,Et;Z.preventDefault(),(Ge=q.current)==null||Ge.focus(),(Et=(dt=q.current)==null?void 0:dt.scrollIntoView)==null||Et.call(dt,{block:"start"})},children:B("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:he,children:[S&&t.jsxs("a",{className:"bim-rd-back",href:S,"aria-label":B("reader.backAria",{label:ze}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:ze})]}),(e||n||y||w)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),y&&t.jsx("span",{className:"bim-rd-by",children:y}),w&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:w})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":B("reader.settings"),children:[A&&A.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:Oe?me(Or(Oe)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:B("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:B("reader.versionShort")}),t.jsx("select",{"aria-label":B("reader.version"),value:Q??"",onChange:Z=>We(Z.target.value),children:A.map(Z=>t.jsx("option",{value:Z.key,children:me(Or(Z))},Z.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),z&&(Ce||Ve)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":B("reader.pagerGroup",{unit:we}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.prevUnit",{unit:we}),title:Ce?typeof Ce.label=="string"&&Ce.label?B("reader.prevUnitTitle",{unit:we,label:Ce.label}):B("reader.prevUnit",{unit:we}):B("reader.firstUnit",{unit:we}),disabled:!Ce,onClick:()=>Ce&&ke(Ce.key),children:t.jsx(Hh,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.nextUnit",{unit:we}),title:Ve?typeof Ve.label=="string"&&Ve.label?B("reader.nextUnitTitle",{unit:we,label:Ve.label}):B("reader.nextUnit",{unit:we}):B("reader.lastUnit",{unit:we}),disabled:!Ve,onClick:()=>Ve&&ke(Ve.key),children:t.jsx(Dh,{})})]}),z&&(Ce||Ve)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:Y,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":_e,"aria-controls":Pe,onClick:xe,children:[t.jsx(ua,{}),t.jsx("span",{className:"bim-rd-tlabel",children:B("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":T,onClick:()=>Xe(T?"closed":"open"),children:[t.jsx(ha,{}),B("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(Uh,{prefs:u,onPrefsChange:f,origAvailable:_}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":B("reader.fontSmaller"),disabled:Be<=Bt[0],onClick:()=>f({fontSize:mi(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":B("reader.fontLarger"),disabled:Be>=Bt[Bt.length-1],onClick:()=>f({fontSize:mi(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:Ie,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":ue,"aria-controls":L,onClick:()=>ge(Z=>!Z),children:[t.jsx(ma,{}),t.jsx("span",{className:"bim-rd-tlabel",children:B("reader.settings")})]}),H]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Pe,ref:se,role:Le&&_e?"dialog":void 0,"aria-modal":Le&&_e?!0:void 0,"aria-label":Le&&_e?B("reader.toc"):void 0,onKeyDown:Z=>{if(!(!Le||!_e)){if(Z.key==="Escape"){Z.stopPropagation(),pe(!0);return}Z.key==="Tab"&&ga(Z,se.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:d??B("reader.toc")}),Le&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.closeToc"),onClick:()=>pe(!0),children:"✕"})]}),l]}),t.jsx(uc,{items:i,activeKey:s!==void 0?s:o,onSelect:ke})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>pe(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":B("reader.images"),children:T&&(le||t.jsx(Pr,{pages:c??null,loading:p,renderOverlay:h,preserveMargins:u.preserveMargins}))}),!J&&ue&&t.jsxs("aside",{className:"bim-rd-set",id:L,"aria-label":B("reader.settings"),onKeyDown:Z=>{var Ge;Z.key==="Escape"&&(Z.stopPropagation(),ge(!1),(Ge=Ie.current)==null||Ge.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:B("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.closeSettings"),onClick:()=>{var Z;ge(!1),(Z=Ie.current)==null||Z.focus()},children:"✕"})]}),Ct]}),t.jsxs("div",{className:"bim-rd-text",id:G,ref:q,tabIndex:-1,"data-rail":(k||C)&&!te?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[ve,K&&Oe&&(Oe.sourceName||Oe.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":Oe.key,children:[Oe.sourceName&&t.jsxs(t.Fragment,{children:[B("reader.sourceLabel")," ",Oe.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:Oe.sourceUrl,target:"_blank",rel:"noreferrer",children:me(Oe.sourceName)}):me(Oe.sourceName)]}),Oe.sourceName&&Oe.license&&t.jsx("span",{className:"bim-rd-dot"}),Oe.license&&t.jsx(t.Fragment,{children:B("reader.licenseOf",{license:Oe.license})})]}),$&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:B("reader.revisedAt",{date:$})}),C&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:Z=>Z.preventDefault(),onClick:be,children:B("reader.reportError")})}),z&&!O&&(Ce||Ve)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":B("reader.pagerNav"),children:[Ce?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>ke(Ce.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),B("reader.prevUnit",{unit:we})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Ce.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",B("reader.firstUnit",{unit:we})]}),Ve?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>ke(Ve.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[B("reader.nextUnit",{unit:we}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Ve.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[B("reader.lastUnit",{unit:we})," →"]})]})]}),(k||C)&&!te&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":B("reader.rail"),children:[k,C&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:Z=>Z.preventDefault(),onClick:be,children:B("reader.reportError")})})]})]})]}),J&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":B("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":_e,"aria-controls":Pe,onClick:()=>{ye(null),xe()},children:[t.jsx(ua,{}),t.jsx("span",{children:B("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":D==="img","aria-haspopup":"dialog",onClick:Z=>W("img",Z.currentTarget),children:[t.jsx(ha,{}),t.jsx("span",{children:B("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":D==="set","aria-haspopup":"dialog",onClick:Z=>W("set",Z.currentTarget),children:[t.jsx(ma,{}),t.jsx("span",{children:B("reader.settingsShort")})]}),C&&t.jsxs("button",{type:"button",onMouseDown:Z=>Z.preventDefault(),onClick:()=>{ye(null),be()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:B("reader.reportError")})]})]}),J&&D&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:ae}),t.jsxs("div",{className:"bim-rd-sheet",ref:ie,role:"dialog","aria-modal":"true","aria-label":B(D==="img"?"reader.images":"reader.settings"),onKeyDown:Z=>{if(Z.key==="Escape"){Z.stopPropagation(),ae();return}Z.key==="Tab"&&ga(Z,ie.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:B(D==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.close"),onClick:ae,children:"✕"})]}),D==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(Pr,{pages:c??null,loading:p,renderOverlay:h,preserveMargins:u.preserveMargins})}):Ct]})]})]})}function Kh(e,n,i){return i?jc(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function jc(e){return e.replace(/\r\n/g,`
716
+ `)}const xa=2,qh=400,Xh=6,vc=e=>e==="*"||e==="#"||e==="<"||e===">"||/\s/.test(e);function kc(e,n){if(e[n]!=="<"||e[n+1]!=="!"||e[n+2]!=="-"||e[n+3]!=="-")return-1;for(let i=n+4;i+2<e.length;i++)if(e[i]==="-"&&e[i+1]==="-"&&e[i+2]===">")return i+2;return-1}function Zh(e,n,i){let o=n;for(let s=0;s<i.length;){if(o>=e.length)return-1;if(i[s]===e[o]){s++,o++;continue}const a=kc(e,o);if(a>=0){o=a+1;continue}if(vc(e[o])){o++;continue}if(i[s]===" "){s++;continue}return-1}return o}function Jh(e){const n=Array.from(jc(e));let i=0;return{align(o){if(!o)return;const s=Array.from(o);if(s.every(d=>d===" "||/\s/.test(d)))return;const a=s.length>=Xh;let l=0;for(let d=i;d<n.length&&d-i<=(a?qh:xa+64);d++){const c=kc(n,d);if(c>=0){d=c;continue}if(!vc(n[d])){const h=Zh(n,d,s);if(h>=0)return i=h,d;if(l++,!a&&l>xa)return}}}}}const Qh=65536,eg="guji_markdown";function tg(e){const n=e==null?void 0:e.guji_markdown;if(typeof n!="string")return!1;const i=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!i)return!1;const o=parseInt(i[1],10),s=parseInt(i[2],10);return o>0||s>=2}const ng=/^□\{guess=([^\s{}]+)\}/;function ig(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function wc(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
717
+ `)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function rg(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function og(e,n){const i=e[n];if(i==="["&&e[n+1]==="["){const o=e.indexOf("]]",n+2);return o>=0&&e.slice(n+2,o).indexOf(`
718
+ `)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=wc(e,n+3);return o>n+4?{node:{type:"zi",label:rg(e.slice(n+4,o))},end:o+1}:null}if(i==="□"&&e[n+1]==="{"){const o=ng.exec(e.slice(n,n+64));if(o)return{node:{type:"qz",guess:o[1]},end:n+o[0].length}}return null}function Sc(e,n,i,o,s){const a=[];let l="",d=!1;const c=()=>{if(!l)return;let p=l;o&&(p=l.replace(/\\?\|/g,h=>d?"|":(d=!0,""))),p&&a.push({type:"text",text:p}),l=""};for(;n<e.length;){const p=e[n];if(p==="\\"&&(e[n+1]==="<"||e[n+1]===">")){l+=e[n+1],n+=2;continue}if(i!==null){if(p===i)return c(),{nodes:a,end:n};if(p===`
719
+ `)return null}const h=og(e,n);if(h){c(),a.push(h.node),n=h.end;continue}let m=null;if(p==="<"&&ig(e,n)&&(m=">"),m){const u=Sc(e,n+1,m,!0,s);if(u&&!(u.end-(n+1)>s)){c(),a.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function _c(e,n){return Sc(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??Qh).nodes}function sg(e){return/[<□]|\[\[|:zi\[/.test(e)}function $c(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${$c(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const ag=216,ba="clamp(280px, 23vw, 360px)",lg=1440,Wr="(max-width: 719px)",cg=`${Wr}, (pointer: coarse)`,dg=`
720
+ .bim-d-main.bim-d-main-grid { max-width: ${lg}px; padding: 16px 32px 0; }
718
721
  .bim-d-grid {
719
722
  display: grid;
720
- grid-template-columns: ${cg}px minmax(0, 1fr) ${xa};
723
+ grid-template-columns: ${ag}px minmax(0, 1fr) ${ba};
721
724
  grid-template-rows: auto 1fr;
722
725
  grid-template-areas: "rail main card" "rail main side";
723
726
  column-gap: 32px; row-gap: 28px; align-items: start;
@@ -1070,7 +1073,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1070
1073
  .bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
1071
1074
 
1072
1075
  /* 点击目标 ≥44px(Q5):触屏与窄屏 */
1073
- @media ${pg} {
1076
+ @media ${cg} {
1074
1077
  .bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
1075
1078
  .bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
1076
1079
  .bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
@@ -1108,7 +1111,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1108
1111
  /* 中等宽度:左栏折到顶部一行 */
1109
1112
  @media (max-width: 1100px) {
1110
1113
  .bim-d-grid {
1111
- grid-template-columns: minmax(0, 1fr) ${xa};
1114
+ grid-template-columns: minmax(0, 1fr) ${ba};
1112
1115
  grid-template-rows: auto auto 1fr;
1113
1116
  grid-template-areas: "rail rail" "main card" "main side";
1114
1117
  }
@@ -1122,7 +1125,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1122
1125
  }
1123
1126
 
1124
1127
  /* 手机:左栏收起,提要卡 → 正文 → 旁栏 */
1125
- @media ${Br} {
1128
+ @media ${Wr} {
1126
1129
  .bim-d-main.bim-d-main-grid { padding: 8px 16px 0; }
1127
1130
  .bim-d-grid {
1128
1131
  grid-template-columns: minmax(0, 1fr);
@@ -1197,7 +1200,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1197
1200
  :root[data-layout="boxed"] .bim-d-g-rail { border: ${r("fr-bd")}; background: ${r("fr-bg")}; padding: 14px 8px; }
1198
1201
  :root[data-layout="boxed"] .bim-d-filters { border-bottom: 1px solid ${r("fr-tab-bd")}; }
1199
1202
  :root[data-layout="boxed"] .bim-d-filters .bim-d-tab { margin-bottom: -1px; }
1200
- @media ${Br} {
1203
+ @media ${Wr} {
1201
1204
  :root[data-layout="boxed"] .bim-d-card { padding: 16px; }
1202
1205
  :root[data-layout="boxed"] .bim-d-g-rail { border: 0; background: transparent; padding: 0; }
1203
1206
  }
@@ -1212,7 +1215,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1212
1215
  :root[data-theme="ink"] :is(.bim-d-zt, .bim-d-side li, .bim-d-card-desc, .bim-d-desc, .bim-d-lf-card) a:hover {
1213
1216
  text-decoration-color: currentColor; text-decoration-thickness: 2px;
1214
1217
  }
1215
- `;function Yn({railTop:e,back:n,up:i,nav:o,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=ie(),h=(o||[]).filter(Boolean);return t.jsxs("div",{className:"bim-d-grid",children:[t.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[e,n&&t.jsx("div",{style:{marginTop:e?12:0},children:n}),i,h.length>1&&t.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[t.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),t.jsx("ul",{className:"bim-d-rail-nav",children:h.map(m=>t.jsx("li",{children:t.jsxs("a",{href:`#${m.id}`,children:[t.jsx("span",{children:p(m.label)}),m.count!=null&&t.jsx("span",{className:"bim-d-meta",children:m.count})]})},m.id))})]}),s&&s.length>0&&t.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[t.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),t.jsx("ul",{className:"bim-d-rail-nav",children:s.map(m=>t.jsx("li",{children:t.jsxs("a",{href:m.href??"#",onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),m.onClick())},children:[t.jsx("span",{children:p(m.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},m.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:a}),t.jsx("div",{className:"bim-d-g-card",children:l}),t.jsx("div",{className:"bim-d-g-side",children:d})]})}function zc({caption:e,children:n}){const{convert:i}=ie();return t.jsxs("div",{className:"bim-d-up bim-d-ui",children:[t.jsx("span",{className:"bim-d-up-cap",children:i(e)}),n]})}function at({id:e,title:n,meta:i,action:o,children:s}){const{convert:a}=ie();return t.jsxs("section",{id:e,className:"bim-d-sec",children:[t.jsxs("div",{className:"bim-d-sec-head bim-d-ui",children:[t.jsx("h2",{children:a(n)}),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i}),o&&t.jsx("span",{className:"bim-d-sec-act",children:o})]}),t.jsx("div",{className:"bim-d-sec-body",children:s})]})}function st({items:e,className:n,style:i}){const o=e.filter(s=>s!=null&&s!==""&&s!==!1);return o.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:i,children:o.map((s,a)=>t.jsxs(g.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function Fi({items:e,value:n,onChange:i}){const{convert:o}=ie();return t.jsx(t.Fragment,{children:e.map(s=>t.jsx("button",{type:"button",className:[...o(s.label)].length===1?"bim-d-tab bim-d-tab-1":"bim-d-tab","aria-pressed":s.key===n,onClick:()=>i(s.key),children:o(s.label)},s.key))})}function Nc({label:e,checked:n,onChange:i}){const{convert:o}=ie();return t.jsxs("label",{className:"bim-d-check",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:s=>i(s.target.checked)}),o(e)]})}const Tc=6,Hi=e=>e>Tc+1;function So({total:e,shown:n,unit:i,onClick:o}){const{t:s,convert:a}=ie(),l=e-n,d=Hi(e)?e-Math.min(n,Tc):l;return d<=0?null:t.jsxs("button",{type:"button",className:`bim-d-more bim-d-ui${l>0?"":" bim-d-more-ncap"}`,onClick:o,children:[l>0&&t.jsx("span",{className:"bim-d-more-w",children:s("detail.expandRest",{n:l,unit:a(i)})}),t.jsx("span",{className:"bim-d-more-n",children:s("detail.expandRest",{n:d,unit:a(i)})})]})}function _o({label:e,onClick:n}){const{convert:i}=ie();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:i(e)})}function Kn({kind:e,title:n,subtitle:i,byline:o,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:h,children:m,foot:u}){const{t:f,convert:x}=ie(),v=(d||[]).filter(k=>k.value!=null&&k.value!==""),b=(c||[]).filter(k=>k.value!=null&&k.value!==""&&k.value!==0),[$,y]=g.useState(!1),w=!!l&&!$;return t.jsxs("div",{className:"bim-d-card",children:[e&&t.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:x(e)}),t.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),i&&t.jsx("div",{className:"bim-d-card-sub",children:i}),o&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:o}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),a&&t.jsx("div",{className:w?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:w?{"--detail-clamp":l}:void 0,children:a}),a&&!!l&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":$,onClick:()=>y(k=>!k),children:f($?"action.collapse":"action.expand")}),b.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:b.map((k,j)=>t.jsxs("div",{children:[t.jsx("b",{children:k.value}),t.jsx("span",{children:x(k.label)})]},j))}),v.length>0&&t.jsx("dl",{className:"bim-d-ui",children:v.map((k,j)=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:x(k.label)}),t.jsx("dd",{title:k.title,children:k.value})]},j))}),m,p,h,u&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:u})]})}function $o(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function Or({href:e,onClick:n,label:i}){const{t:o,convert:s}=ie(),a=i??o("detail.read");return e?t.jsx("a",{className:"bim-d-btn",href:e,onClick:n?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),n())}:void 0,children:s(a)}):t.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:s(a)})}function on({id:e,title:n,meta:i,items:o,metas:s,currentIndex:a,cap:l=8,moreLabel:d,foot:c,sub:p,timeline:h}){const{t:m,convert:u}=ie(),[f,x]=g.useState(!1);if(!o.length)return null;const v=f?o:o.slice(0,l),b=o.length-v.length;return t.jsxs("div",{id:e,className:h?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[t.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[u(n),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i})]}),p&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),t.jsx("ul",{children:v.map(($,y)=>t.jsxs("li",{className:y===a?"bim-d-side-cur":void 0,"aria-current":y===a?"page":void 0,children:[$,s!=null&&s[y]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[y]}):null]},y))}),b>0&&t.jsx(_o,{label:d?d(b):m("detail.showMore",{n:b}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const mg=new Set(["reviewed","disputed","unreviewed","draft"]);function qn({revision:e,revisedAt:n,review:i,todo:o}){const{t:s,convert:a}=ie(),l=i&&mg.has(i.status)?s(`detail.review.${i.status}`):void 0,d=i&&i.status!=="unreviewed"&&l?[l,i.by,i.date].filter(Boolean).join(" "):"",c=[e!=null&&e!==""?`${s("detail.dataVersion")} ${e}`:"",n??"",a(d)].filter(Boolean),p=(o||[]).filter(h=>h&&h.what);return!c.length&&!p.length?null:t.jsxs(t.Fragment,{children:[c.length>0&&t.jsx(st,{items:c,style:{fontSize:12}}),p.length>0&&t.jsxs("details",{children:[t.jsx("summary",{children:s("detail.todoCount",{n:p.length})}),t.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:p.map((h,m)=>t.jsxs("li",{children:[a(h.what),(h.by||h.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[h.by&&a(h.by),h.date].filter(Boolean).join(" · "),")"]})]},m))})]})]})}const yi=1e3,ba=208,hg=1440,gg="(max-width: 719px)",Ic=`
1218
+ `;function qn({railTop:e,back:n,up:i,nav:o,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=ne(),h=(o||[]).filter(Boolean);return t.jsxs("div",{className:"bim-d-grid",children:[t.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[e,n&&t.jsx("div",{style:{marginTop:e?12:0},children:n}),i,h.length>1&&t.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[t.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),t.jsx("ul",{className:"bim-d-rail-nav",children:h.map(m=>t.jsx("li",{children:t.jsxs("a",{href:`#${m.id}`,children:[t.jsx("span",{children:p(m.label)}),m.count!=null&&t.jsx("span",{className:"bim-d-meta",children:m.count})]})},m.id))})]}),s&&s.length>0&&t.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[t.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),t.jsx("ul",{className:"bim-d-rail-nav",children:s.map(m=>t.jsx("li",{children:t.jsxs("a",{href:m.href??"#",onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),m.onClick())},children:[t.jsx("span",{children:p(m.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},m.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:a}),t.jsx("div",{className:"bim-d-g-card",children:l}),t.jsx("div",{className:"bim-d-g-side",children:d})]})}function Cc({caption:e,children:n}){const{convert:i}=ne();return t.jsxs("div",{className:"bim-d-up bim-d-ui",children:[t.jsx("span",{className:"bim-d-up-cap",children:i(e)}),n]})}function at({id:e,title:n,meta:i,action:o,children:s}){const{convert:a}=ne();return t.jsxs("section",{id:e,className:"bim-d-sec",children:[t.jsxs("div",{className:"bim-d-sec-head bim-d-ui",children:[t.jsx("h2",{children:a(n)}),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i}),o&&t.jsx("span",{className:"bim-d-sec-act",children:o})]}),t.jsx("div",{className:"bim-d-sec-body",children:s})]})}function st({items:e,className:n,style:i}){const o=e.filter(s=>s!=null&&s!==""&&s!==!1);return o.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:i,children:o.map((s,a)=>t.jsxs(g.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function Hi({items:e,value:n,onChange:i}){const{convert:o}=ne();return t.jsx(t.Fragment,{children:e.map(s=>t.jsx("button",{type:"button",className:[...o(s.label)].length===1?"bim-d-tab bim-d-tab-1":"bim-d-tab","aria-pressed":s.key===n,onClick:()=>i(s.key),children:o(s.label)},s.key))})}function zc({label:e,checked:n,onChange:i}){const{convert:o}=ne();return t.jsxs("label",{className:"bim-d-check",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:s=>i(s.target.checked)}),o(e)]})}const Nc=6,Di=e=>e>Nc+1;function $o({total:e,shown:n,unit:i,onClick:o}){const{t:s,convert:a}=ne(),l=e-n,d=Di(e)?e-Math.min(n,Nc):l;return d<=0?null:t.jsxs("button",{type:"button",className:`bim-d-more bim-d-ui${l>0?"":" bim-d-more-ncap"}`,onClick:o,children:[l>0&&t.jsx("span",{className:"bim-d-more-w",children:s("detail.expandRest",{n:l,unit:a(i)})}),t.jsx("span",{className:"bim-d-more-n",children:s("detail.expandRest",{n:d,unit:a(i)})})]})}function Co({label:e,onClick:n}){const{convert:i}=ne();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:i(e)})}function Xn({kind:e,title:n,subtitle:i,byline:o,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:h,children:m,foot:u}){const{t:f,convert:x}=ne(),v=(d||[]).filter(j=>j.value!=null&&j.value!==""),b=(c||[]).filter(j=>j.value!=null&&j.value!==""&&j.value!==0),[_,y]=g.useState(!1),w=!!l&&!_;return t.jsxs("div",{className:"bim-d-card",children:[e&&t.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:x(e)}),t.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),i&&t.jsx("div",{className:"bim-d-card-sub",children:i}),o&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:o}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),a&&t.jsx("div",{className:w?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:w?{"--detail-clamp":l}:void 0,children:a}),a&&!!l&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":_,onClick:()=>y(j=>!j),children:f(_?"action.collapse":"action.expand")}),b.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:b.map((j,k)=>t.jsxs("div",{children:[t.jsx("b",{children:j.value}),t.jsx("span",{children:x(j.label)})]},k))}),v.length>0&&t.jsx("dl",{className:"bim-d-ui",children:v.map((j,k)=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:x(j.label)}),t.jsx("dd",{title:j.title,children:j.value})]},k))}),m,p,h,u&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:u})]})}function zo(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function Fr({href:e,onClick:n,label:i}){const{t:o,convert:s}=ne(),a=i??o("detail.read");return e?t.jsx("a",{className:"bim-d-btn",href:e,onClick:n?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),n())}:void 0,children:s(a)}):t.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:s(a)})}function on({id:e,title:n,meta:i,items:o,metas:s,currentIndex:a,cap:l=8,moreLabel:d,foot:c,sub:p,timeline:h}){const{t:m,convert:u}=ne(),[f,x]=g.useState(!1);if(!o.length)return null;const v=f?o:o.slice(0,l),b=o.length-v.length;return t.jsxs("div",{id:e,className:h?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[t.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[u(n),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i})]}),p&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),t.jsx("ul",{children:v.map((_,y)=>t.jsxs("li",{className:y===a?"bim-d-side-cur":void 0,"aria-current":y===a?"page":void 0,children:[_,s!=null&&s[y]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[y]}):null]},y))}),b>0&&t.jsx(Co,{label:d?d(b):m("detail.showMore",{n:b}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const pg=new Set(["reviewed","disputed","unreviewed","draft"]);function Zn({revision:e,revisedAt:n,review:i,todo:o}){const{t:s,convert:a}=ne(),l=i&&pg.has(i.status)?s(`detail.review.${i.status}`):void 0,d=i&&i.status!=="unreviewed"&&l?[l,i.by,i.date].filter(Boolean).join(" "):"",c=[e!=null&&e!==""?`${s("detail.dataVersion")} ${e}`:"",n??"",a(d)].filter(Boolean),p=(o||[]).filter(h=>h&&h.what);return!c.length&&!p.length?null:t.jsxs(t.Fragment,{children:[c.length>0&&t.jsx(st,{items:c,style:{fontSize:12}}),p.length>0&&t.jsxs("details",{children:[t.jsx("summary",{children:s("detail.todoCount",{n:p.length})}),t.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:p.map((h,m)=>t.jsxs("li",{children:[a(h.what),(h.by||h.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[h.by&&a(h.by),h.date].filter(Boolean).join(" · "),")"]})]},m))})]})]})}const ji=1e3,ya=208,ug=1440,mg="(max-width: 719px)",Tc=`
1216
1219
  .bim-d-page {
1217
1220
  background: ${r("page-bg")};
1218
1221
  color: ${r("ink")};
@@ -1221,7 +1224,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1221
1224
  padding-bottom: 64px;
1222
1225
  }
1223
1226
  .bim-d-main {
1224
- max-width: ${yi}px;
1227
+ max-width: ${ji}px;
1225
1228
  margin: 0 auto;
1226
1229
  padding: 24px clamp(16px, 4vw, 28px) 0;
1227
1230
  }
@@ -1232,7 +1235,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1232
1235
  * PAGE_MAX_WIDTH,读者的行宽体验不变。
1233
1236
  */
1234
1237
  .bim-d-main.bim-d-main-wide {
1235
- max-width: ${hg}px;
1238
+ max-width: ${ug}px;
1236
1239
  }
1237
1240
  .bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
1238
1241
 
@@ -1264,9 +1267,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1264
1267
  */
1265
1268
  .bim-d-reader {
1266
1269
  display: grid;
1267
- grid-template-columns: ${ba}px minmax(0, ${yi}px);
1270
+ grid-template-columns: ${ya}px minmax(0, ${ji}px);
1268
1271
  gap: 32px;
1269
- max-width: ${ba+yi+32}px;
1272
+ max-width: ${ya+ji+32}px;
1270
1273
  margin: 0 auto;
1271
1274
  align-items: start;
1272
1275
  }
@@ -1289,7 +1292,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1289
1292
  align-items: start; margin-bottom: 48px; }
1290
1293
  .bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
1291
1294
 
1292
- @media ${gg} {
1295
+ @media ${mg} {
1293
1296
  .bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
1294
1297
  .bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
1295
1298
  /* 表格:meta 列折到第二行,表头隐藏 */
@@ -1307,20 +1310,20 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
1307
1310
  padding-right: 0; padding-bottom: 12px;
1308
1311
  }
1309
1312
  }
1310
- ${ug}`;function Bn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:Ic}),t.jsx("div",{className:o?"bim-d-main bim-d-main-grid":i?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function Wr({breadcrumb:e,actions:n}){return t.jsxs("div",{className:"bim-d-ui bim-d-top",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:"8px 16px",marginBottom:24,fontSize:12,color:r("aux-fg")},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:e}),n&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function Co({char:e,tone:n="accent"}){return t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,flex:"none",fontSize:11,fontFamily:"var(--bim-font-ui, system-ui, sans-serif)",background:r(n==="accent"?"accent":"ink"),color:r("page-bg")},children:e})}function Fr({items:e}){const n=rt();return t.jsx(t.Fragment,{children:e.map((i,o)=>{const s=o===e.length-1,a=o>0&&t.jsx("span",{style:{color:r("hint-fg")},children:"/"},`s${o}`),l=i.id?n(i.id):i.href,d=s||!i.onClick&&!l?t.jsx("span",{style:{color:r("ink")},children:i.label},o):t.jsx("a",{href:l??"#",onClick:i.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),i.onClick())}:void 0,style:{color:r("meta-fg")},children:i.label},o);return t.jsxs(g.Fragment,{children:[a,d]},o)})})}function Ec({title:e,subtitle:n,aside:i,secondLine:o}){return t.jsxs("header",{style:{borderBottom:`2px solid ${r("rule-strong")}`,paddingBottom:18},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[t.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:e}),n&&t.jsx("span",{style:{fontSize:15,color:r("meta-fg"),letterSpacing:".06em"},children:n})]}),i&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".06em"},children:i})]}),o&&t.jsx("div",{style:{marginTop:12,fontSize:13.5,color:r("quiet-fg")},children:o})]})}function fg({children:e,facts:n}){return!e&&n?t.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${r("rule")}`,marginBottom:40},children:n}):t.jsxs("div",{className:"bim-d-intro",children:[t.jsx("div",{style:{minWidth:0},children:e}),n]})}function xg({items:e,horizontal:n}){const{convert:i}=Me();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${r("accent")}`,paddingLeft:16,display:n?"grid":"flex",gridTemplateColumns:n?"repeat(auto-fit, minmax(150px, max-content))":void 0,flexDirection:n?void 0:"column",gap:n?"14px 40px":10,fontSize:13},children:e.map((o,s)=>t.jsxs("div",{title:o.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[t.jsx("span",{className:"bim-d-ui",style:{color:r("label-fg"),letterSpacing:".08em",flex:"none"},children:i(o.label)}),t.jsx("span",{style:{color:r("body-fg"),textAlign:n?"left":"right",minWidth:0},children:o.value})]},s))}):null}function bg({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Me();return t.jsxs("div",{id:a,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(Co,{char:e,tone:n}),t.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:l(i)}),o!=null&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg")},children:o})]}),s&&t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function Rc({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Me();return t.jsx("button",{type:"button",onClick:i,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${o&&!n?"dashed":"solid"} ${r(n?"accent":"rule")}`,background:n?r("accent"):"transparent",color:r(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function yg({label:e,onClick:n}){const{convert:i}=Me();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:i(e)})}function jg({label:e,onClick:n,inline:i}){const{convert:o}=Me();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:i?0:12,width:i?void 0:"100%",padding:i?"4px 12px":9,background:"none",border:`1px dashed ${r("rule-dashed")}`,cursor:"pointer",fontSize:12,color:r("meta-fg"),letterSpacing:i?void 0:".08em"},children:o(e)})}function Lc({children:e,href:n,onClick:i,title:o}){const s={display:"inline-block",padding:"4px 10px",border:`1px solid ${r("rule")}`,fontSize:13,color:r("body-fg"),lineHeight:1.5};return n||i?t.jsx("a",{href:n??"#",title:o,onClick:i?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i())}:void 0,style:s,children:e}):t.jsx("span",{title:o,style:s,children:e})}function vg({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function kg({volumes:e,unit:n,max:i=60}){const{t:o}=ie(),s=n??o("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,i);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[d.map(c=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${r("rule")}`,color:r("meta-fg")},children:c},c)),!a&&e.length>i&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${r("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:r("meta-fg")},children:["+",e.length-i]}),t.jsx("span",{style:{padding:"2px 6px",color:r("hint-fg")},children:s})]})}function wg({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function Sg({spec:e}){const{convert:n}=Me();return t.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${e.leadWidth}px 1fr ${e.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${r("rule-strong")}`,fontSize:11,color:r("label-fg"),letterSpacing:".1em"},children:[t.jsx("span",{}),t.jsx("span",{children:n(e.mainLabel)}),t.jsx("span",{style:{display:"grid",gridTemplateColumns:e.columns.map(i=>i.width).join(" "),gap:12},children:e.columns.map(i=>t.jsx("span",{children:n(i.label)},i.label))})]})}function _g({no:e,main:n,meta:i,spec:o}){return t.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${o.leadWidth}px 1fr ${o.metaWidth}px`,gap:12},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("hint-fg"),textAlign:"right"},children:e}),t.jsx("span",{style:{minWidth:0},children:n}),t.jsx("span",{className:"bim-d-row-meta",style:{display:"grid",gridTemplateColumns:o.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:i})]})}function $g(e){return String(e+1).padStart(2,"0")}function Cg(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function zg({open:e,onToggle:n,main:i,action:o,children:s}){return t.jsxs("div",{style:{borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[t.jsx("button",{type:"button",onClick:n,"aria-expanded":e,className:"bim-d-ui",style:{width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",fontSize:12,lineHeight:1,border:`1px solid ${r(e?"accent":"rule-dashed")}`,background:e?r("accent"):"transparent",color:r(e?"page-bg":"accent")},children:e?"-":"+"}),t.jsx("span",{style:{fontSize:14,minWidth:0},children:i}),o]}),e&&s&&t.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${r("rule-accent-soft")}`,marginLeft:12},children:s})]})}function Ac(e){const n=[];for(let i=0;i<e.length;i++){if(e[i]!=="<")continue;const s=e[i+1];if(s===void 0||/[A-Za-z/!?>\s]/.test(s))continue;const l=e.indexOf(">",i+1);if(l<0)continue;const d=e.slice(i+1,l);d.includes(`
1311
- `)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function Mc(e,n){if(e.length<=n)return e;let i=n;for(const o of Ac(e)){if(o.start>=i)break;if(o.end>i){i=o.start>0?o.start:o.end;break}}return e.slice(0,i)}const Pc={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},Ng={display:"inline-block",fontSize:"1em",lineHeight:1.15,padding:"0 .12em",margin:"0 .05em",border:"1px solid color-mix(in srgb, currentColor 40%, transparent)",borderRadius:2,verticalAlign:"baseline",whiteSpace:"nowrap"};function Bc(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?Pc:void 0,children:Bc(s.children,n,i+1,o)},a);case"qw":return t.jsx("span",{className:"bim-qw guji-qw",title:s.label?o("detail.lacunaWith",{label:s.label}):o("detail.lacuna"),children:"□"},a);case"qz":return t.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":s.guess,children:"□"},a);case"zi":return t.jsx("span",{className:"bim-zi guji-zi",title:o("detail.composedChar",{label:s.label}),style:Ng,children:s.label},a)}})}function yt(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return lg(e)?Bc($c(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??wn("zh-Hant")):n(e);if(e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of Ac(e))l.start>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:Pc,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o}function Tg({label:e,children:n}){return t.jsxs("div",{style:{marginBottom:10},children:[e&&t.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:r("label-fg"),marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:r("quiet-fg"),textAlign:"justify"},children:n})]})}function Ig({title:e,tag:n,children:i}){const{convert:o}=Me();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${r("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:o(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("accent"),letterSpacing:".06em"},children:o(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:i})]})}function Oc({name:e,note:n,href:i,extra:o}){const s=t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:14,minWidth:0},children:e}),t.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:r("hint-fg"),flex:"none"},children:i?"↗":""}),n&&t.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:r("label-fg")},children:n})]}),a={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${r("rule")}`,color:r("body-fg"),alignItems:"baseline"};return t.jsxs(t.Fragment,{children:[i?t.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:a,children:s}):t.jsx("div",{style:a,children:s}),o]})}function Eg({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=ie(),[l,d]=g.useState(!1),c=Ti(e),p=i&&!!c&&c.expected>0,h=(e.url?jn(e.url):void 0)||a(e.name),m=n?gc(e,n):"",u=m?`${h}(${m})`:h;return t.jsx(Oc,{name:u,note:Oi(e,s)||o,href:vn(e),extra:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(f=>!f),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:l?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),l&&t.jsx(zo,{item:e})]}):void 0})}function zo({item:e}){return t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(e.volumes||[]).map((n,i)=>{const o=n.status==="missing";return n.url&&!o?t.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{padding:"4px 8px",borderRadius:4,background:r("zebra-bg")},children:n.volume},i):t.jsx("span",{style:{padding:"1px 5px",color:r(o?"missing-fg":"hint-fg"),textDecoration:o?"line-through":void 0},children:n.volume},i)})})}function Wc({label:e,items:n}){const{convert:i}=Me();return n.length?t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".08em"},children:e}),n.map((o,s)=>t.jsx(Lc,{children:i(o)},s))]}):null}function Rg({rows:e}){const n=e.filter(i=>i.items.length>0);return n.length?t.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(i=>t.jsx(Wc,{label:i.label,items:i.items},i.label))}):null}function Hr(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Fc({left:e,right:n}){return t.jsxs("footer",{className:"bim-d-ui",style:{marginTop:52,paddingTop:14,borderTop:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",justifyContent:"space-between",gap:"8px 16px",fontSize:11.5,color:r("aux-fg")},children:[t.jsx("span",{children:e}),n&&t.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function Lg({children:e,action:n}){return t.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:r("aux-fg"),borderBottom:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[t.jsx("span",{children:e}),n]})}function nt({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=rt();return o?t.jsx(t.Fragment,{children:o(e,typeof n=="string"?n:void 0,{dense:a})}):t.jsx("a",{href:l(e),onClick:i?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),i(e))}:void 0,style:s,children:n??e})}function Ag({href:e,children:n}){return t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[n," ",t.jsx("span",{className:"bim-d-ui",style:{fontSize:11},children:"↗"})]})}const Hc="guji-table-v1";function Mg(e){return!!e&&e.table_notation===Hc}const Pg=/^:::table(?:\{[^}]*\})?[ \t]*$/,Bg=/^:::[ \t]*$/;function Dc(e){const n=[];let i="";for(let o=0;o<e.length;o++){const s=e[o];if(s===":"&&e.startsWith(":zi[",o)){const l=Sc(e,o+3);if(l>o+4){i+=e.slice(o,l+1),o=l;continue}}let a=null;if(s==="<"){const l=e[o+1];l!==void 0&&!/[A-Za-z/!?>\s]/.test(l)&&(a=">")}if(a){const l=e.indexOf(a,o+1);if(l>0){i+=e.slice(o,l+1),o=l;continue}}s==="|"?(n.push(i),i=""):i+=s}return n.push(i),n.map(o=>o.trim())}const Og=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function Wg(e){if(e==="^")return{cont:!0};const n=Og.exec(e),i=n[1].trim(),o=n[2]?Math.max(1,parseInt(n[2],10)):1,s=n[3]?Math.max(1,parseInt(n[3],10)):1,a=i==="_";return{cont:!1,cell:{text:a?"":i,empty:a,colspan:o,rowspan:s}}}function Uc(e,n=1){const i=[],o=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let h=d.trim();if(!h)return;let m=!1;h.startsWith("!")&&(m=!0,h=h.slice(1));const u=Dc(h).map(Wg),f=a.map($=>$>0),x=a.map($=>$>0?$-1:0),v=[];let b=0;for(const $ of u){if($.cont){f[b]||i.push(`第 ${p} 行第 ${b+1} 列:续格 ^ 上方没有跨行格`),b+=1;continue}const{cell:y}=$;for(let w=b;w<b+y.colspan;w++)if(f[w]){i.push(`第 ${p} 行第 ${w+1} 列:此处被上方跨行格占住,应写 ^`);break}if(y.rowspan>1)for(let w=b;w<b+y.colspan;w++)x[w]=y.rowspan-1;v.push(y),b+=y.colspan}for(let $=b;$<f.length;$++)f[$]&&i.push(`第 ${p} 行第 ${$+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let $=0;$<x.length;$++)x[$]===void 0&&(x[$]=0);a=x,o.push({header:m,cells:v}),s.push({width:b,line:p})});const l=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==l&&i.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${l} 不符`);return a.some(d=>d>0)&&i.push("表尾:有跨行格超出了表的最后一行"),o.length===0&&i.push("空表"),{rows:o,columns:l,warnings:i}}function No(e){const n=e.split(`
1313
+ ${dg}`;function Wn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:Tc}),t.jsx("div",{className:o?"bim-d-main bim-d-main-grid":i?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function Hr({breadcrumb:e,actions:n}){return t.jsxs("div",{className:"bim-d-ui bim-d-top",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:"8px 16px",marginBottom:24,fontSize:12,color:r("aux-fg")},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:e}),n&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function No({char:e,tone:n="accent"}){return t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,flex:"none",fontSize:11,fontFamily:"var(--bim-font-ui, system-ui, sans-serif)",background:r(n==="accent"?"accent":"ink"),color:r("page-bg")},children:e})}function Dr({items:e}){const n=rt();return t.jsx(t.Fragment,{children:e.map((i,o)=>{const s=o===e.length-1,a=o>0&&t.jsx("span",{style:{color:r("hint-fg")},children:"/"},`s${o}`),l=i.id?n(i.id):i.href,d=s||!i.onClick&&!l?t.jsx("span",{style:{color:r("ink")},children:i.label},o):t.jsx("a",{href:l??"#",onClick:i.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),i.onClick())}:void 0,style:{color:r("meta-fg")},children:i.label},o);return t.jsxs(g.Fragment,{children:[a,d]},o)})})}function Ic({title:e,subtitle:n,aside:i,secondLine:o}){return t.jsxs("header",{style:{borderBottom:`2px solid ${r("rule-strong")}`,paddingBottom:18},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[t.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:e}),n&&t.jsx("span",{style:{fontSize:15,color:r("meta-fg"),letterSpacing:".06em"},children:n})]}),i&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".06em"},children:i})]}),o&&t.jsx("div",{style:{marginTop:12,fontSize:13.5,color:r("quiet-fg")},children:o})]})}function hg({children:e,facts:n}){return!e&&n?t.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${r("rule")}`,marginBottom:40},children:n}):t.jsxs("div",{className:"bim-d-intro",children:[t.jsx("div",{style:{minWidth:0},children:e}),n]})}function gg({items:e,horizontal:n}){const{convert:i}=Me();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${r("accent")}`,paddingLeft:16,display:n?"grid":"flex",gridTemplateColumns:n?"repeat(auto-fit, minmax(150px, max-content))":void 0,flexDirection:n?void 0:"column",gap:n?"14px 40px":10,fontSize:13},children:e.map((o,s)=>t.jsxs("div",{title:o.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[t.jsx("span",{className:"bim-d-ui",style:{color:r("label-fg"),letterSpacing:".08em",flex:"none"},children:i(o.label)}),t.jsx("span",{style:{color:r("body-fg"),textAlign:n?"left":"right",minWidth:0},children:o.value})]},s))}):null}function fg({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Me();return t.jsxs("div",{id:a,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(No,{char:e,tone:n}),t.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:l(i)}),o!=null&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg")},children:o})]}),s&&t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function Rc({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Me();return t.jsx("button",{type:"button",onClick:i,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${o&&!n?"dashed":"solid"} ${r(n?"accent":"rule")}`,background:n?r("accent"):"transparent",color:r(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function xg({label:e,onClick:n}){const{convert:i}=Me();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:i(e)})}function bg({label:e,onClick:n,inline:i}){const{convert:o}=Me();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:i?0:12,width:i?void 0:"100%",padding:i?"4px 12px":9,background:"none",border:`1px dashed ${r("rule-dashed")}`,cursor:"pointer",fontSize:12,color:r("meta-fg"),letterSpacing:i?void 0:".08em"},children:o(e)})}function Ec({children:e,href:n,onClick:i,title:o}){const s={display:"inline-block",padding:"4px 10px",border:`1px solid ${r("rule")}`,fontSize:13,color:r("body-fg"),lineHeight:1.5};return n||i?t.jsx("a",{href:n??"#",title:o,onClick:i?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i())}:void 0,style:s,children:e}):t.jsx("span",{title:o,style:s,children:e})}function yg({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function jg({volumes:e,unit:n,max:i=60}){const{t:o}=ne(),s=n??o("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,i);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[d.map(c=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${r("rule")}`,color:r("meta-fg")},children:c},c)),!a&&e.length>i&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${r("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:r("meta-fg")},children:["+",e.length-i]}),t.jsx("span",{style:{padding:"2px 6px",color:r("hint-fg")},children:s})]})}function vg({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function kg({spec:e}){const{convert:n}=Me();return t.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${e.leadWidth}px 1fr ${e.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${r("rule-strong")}`,fontSize:11,color:r("label-fg"),letterSpacing:".1em"},children:[t.jsx("span",{}),t.jsx("span",{children:n(e.mainLabel)}),t.jsx("span",{style:{display:"grid",gridTemplateColumns:e.columns.map(i=>i.width).join(" "),gap:12},children:e.columns.map(i=>t.jsx("span",{children:n(i.label)},i.label))})]})}function wg({no:e,main:n,meta:i,spec:o}){return t.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${o.leadWidth}px 1fr ${o.metaWidth}px`,gap:12},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("hint-fg"),textAlign:"right"},children:e}),t.jsx("span",{style:{minWidth:0},children:n}),t.jsx("span",{className:"bim-d-row-meta",style:{display:"grid",gridTemplateColumns:o.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:i})]})}function Sg(e){return String(e+1).padStart(2,"0")}function _g(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function $g({open:e,onToggle:n,main:i,action:o,children:s}){return t.jsxs("div",{style:{borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[t.jsx("button",{type:"button",onClick:n,"aria-expanded":e,className:"bim-d-ui",style:{width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",fontSize:12,lineHeight:1,border:`1px solid ${r(e?"accent":"rule-dashed")}`,background:e?r("accent"):"transparent",color:r(e?"page-bg":"accent")},children:e?"-":"+"}),t.jsx("span",{style:{fontSize:14,minWidth:0},children:i}),o]}),e&&s&&t.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${r("rule-accent-soft")}`,marginLeft:12},children:s})]})}function Lc(e){const n=[];for(let i=0;i<e.length;i++){if(e[i]!=="<")continue;const s=e[i+1];if(s===void 0||/[A-Za-z/!?>\s]/.test(s))continue;const l=e.indexOf(">",i+1);if(l<0)continue;const d=e.slice(i+1,l);d.includes(`
1314
+ `)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function Ac(e,n){if(e.length<=n)return e;let i=n;for(const o of Lc(e)){if(o.start>=i)break;if(o.end>i){i=o.start>0?o.start:o.end;break}}return e.slice(0,i)}const Mc={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},Cg={display:"inline-block",fontSize:"1em",lineHeight:1.15,padding:"0 .12em",margin:"0 .05em",border:"1px solid color-mix(in srgb, currentColor 40%, transparent)",borderRadius:2,verticalAlign:"baseline",whiteSpace:"nowrap"};function Pc(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?Mc:void 0,children:Pc(s.children,n,i+1,o)},a);case"qw":return t.jsx("span",{className:"bim-qw guji-qw",title:s.label?o("detail.lacunaWith",{label:s.label}):o("detail.lacuna"),children:"□"},a);case"qz":return t.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":s.guess,children:"□"},a);case"zi":return t.jsx("span",{className:"bim-zi guji-zi",title:o("detail.composedChar",{label:s.label}),style:Cg,children:s.label},a)}})}function yt(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return sg(e)?Pc(_c(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??Sn("zh-Hant")):n(e);if(e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of Lc(e))l.start>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:Mc,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o}function zg({label:e,children:n}){return t.jsxs("div",{style:{marginBottom:10},children:[e&&t.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:r("label-fg"),marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:r("quiet-fg"),textAlign:"justify"},children:n})]})}function Ng({title:e,tag:n,children:i}){const{convert:o}=Me();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${r("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:o(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("accent"),letterSpacing:".06em"},children:o(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:i})]})}function Bc({name:e,note:n,href:i,extra:o}){const s=t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:14,minWidth:0},children:e}),t.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:r("hint-fg"),flex:"none"},children:i?"↗":""}),n&&t.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:r("label-fg")},children:n})]}),a={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${r("rule")}`,color:r("body-fg"),alignItems:"baseline"};return t.jsxs(t.Fragment,{children:[i?t.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:a,children:s}):t.jsx("div",{style:a,children:s}),o]})}function Tg({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=ne(),[l,d]=g.useState(!1),c=Ii(e),p=i&&!!c&&c.expected>0,h=(e.url?vn(e.url):void 0)||a(e.name),m=n?Al(e,n):"",u=m?`${h}(${m})`:h;return t.jsx(Bc,{name:u,note:Mi(e,s)||o,href:kn(e),extra:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(f=>!f),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:l?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),l&&t.jsx(To,{item:e})]}):void 0})}function To({item:e}){return t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(e.volumes||[]).map((n,i)=>{const o=n.status==="missing";return n.url&&!o?t.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{padding:"4px 8px",borderRadius:4,background:r("zebra-bg")},children:n.volume},i):t.jsx("span",{style:{padding:"1px 5px",color:r(o?"missing-fg":"hint-fg"),textDecoration:o?"line-through":void 0},children:n.volume},i)})})}function Oc({label:e,items:n}){const{convert:i}=Me();return n.length?t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".08em"},children:e}),n.map((o,s)=>t.jsx(Ec,{children:i(o)},s))]}):null}function Ig({rows:e}){const n=e.filter(i=>i.items.length>0);return n.length?t.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(i=>t.jsx(Oc,{label:i.label,items:i.items},i.label))}):null}function Ur(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Wc({left:e,right:n}){return t.jsxs("footer",{className:"bim-d-ui",style:{marginTop:52,paddingTop:14,borderTop:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",justifyContent:"space-between",gap:"8px 16px",fontSize:11.5,color:r("aux-fg")},children:[t.jsx("span",{children:e}),n&&t.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function Rg({children:e,action:n}){return t.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:r("aux-fg"),borderBottom:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[t.jsx("span",{children:e}),n]})}function nt({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=rt();return o?t.jsx(t.Fragment,{children:o(e,typeof n=="string"?n:void 0,{dense:a})}):t.jsx("a",{href:l(e),onClick:i?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),i(e))}:void 0,style:s,children:n??e})}function Eg({href:e,children:n}){return t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[n," ",t.jsx("span",{className:"bim-d-ui",style:{fontSize:11},children:"↗"})]})}const Fc="guji-table-v1";function Lg(e){return!!e&&e.table_notation===Fc}const Ag=/^:::table(?:\{[^}]*\})?[ \t]*$/,Mg=/^:::[ \t]*$/;function Hc(e){const n=[];let i="";for(let o=0;o<e.length;o++){const s=e[o];if(s===":"&&e.startsWith(":zi[",o)){const l=wc(e,o+3);if(l>o+4){i+=e.slice(o,l+1),o=l;continue}}let a=null;if(s==="<"){const l=e[o+1];l!==void 0&&!/[A-Za-z/!?>\s]/.test(l)&&(a=">")}if(a){const l=e.indexOf(a,o+1);if(l>0){i+=e.slice(o,l+1),o=l;continue}}s==="|"?(n.push(i),i=""):i+=s}return n.push(i),n.map(o=>o.trim())}const Pg=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function Bg(e){if(e==="^")return{cont:!0};const n=Pg.exec(e),i=n[1].trim(),o=n[2]?Math.max(1,parseInt(n[2],10)):1,s=n[3]?Math.max(1,parseInt(n[3],10)):1,a=i==="_";return{cont:!1,cell:{text:a?"":i,empty:a,colspan:o,rowspan:s}}}function Dc(e,n=1){const i=[],o=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let h=d.trim();if(!h)return;let m=!1;h.startsWith("!")&&(m=!0,h=h.slice(1));const u=Hc(h).map(Bg),f=a.map(_=>_>0),x=a.map(_=>_>0?_-1:0),v=[];let b=0;for(const _ of u){if(_.cont){f[b]||i.push(`第 ${p} 行第 ${b+1} 列:续格 ^ 上方没有跨行格`),b+=1;continue}const{cell:y}=_;for(let w=b;w<b+y.colspan;w++)if(f[w]){i.push(`第 ${p} 行第 ${w+1} 列:此处被上方跨行格占住,应写 ^`);break}if(y.rowspan>1)for(let w=b;w<b+y.colspan;w++)x[w]=y.rowspan-1;v.push(y),b+=y.colspan}for(let _=b;_<f.length;_++)f[_]&&i.push(`第 ${p} 行第 ${_+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let _=0;_<x.length;_++)x[_]===void 0&&(x[_]=0);a=x,o.push({header:m,cells:v}),s.push({width:b,line:p})});const l=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==l&&i.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${l} 不符`);return a.some(d=>d>0)&&i.push("表尾:有跨行格超出了表的最后一行"),o.length===0&&i.push("空表"),{rows:o,columns:l,warnings:i}}function Io(e){const n=e.split(`
1312
1315
  `),i=[];let o=[];const s=()=>{if(o.length===0)return;const l=o.join(`
1313
- `);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(Pg.test(n[a].trim())){let l=a+1;for(;l<n.length&&!Bg.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);i.push({type:"table",table:Uc(d,a+1),source:n.slice(a,l+1).join(`
1314
- `)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,h;if(l.type!=="text")return l;let c=l.text;return((p=i[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((h=i[d+1])==null?void 0:h.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const Fg={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},Hg={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},Dg=`1px solid ${r("table-border")}`,Vc={border:Dg,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},Ug={...Vc,background:r("table-head-bg"),fontWeight:600};function To({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:Fg,children:t.jsx("table",{className:"bim-guji-table",style:Hg,children:t.jsx("tbody",{children:e.rows.map((i,o)=>t.jsx("tr",{children:i.cells.map((s,a)=>{const l=i.header?"th":"td";return t.jsx(l,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:i.header?Ug:Vc,children:s.empty?null:yt(s.text,void 0,n)},a)})},o))})})})}function Vg(e,n){return e.indexOf("**")<0?yt(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((o,s)=>s%2===1?t.jsx("strong",{children:yt(o.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:yt(o,void 0,n)},s))}function Gg(e,n,i=!1){const o=i?{gujiMarkdown:!0}:void 0;return n?No(e).map((s,a)=>s.type==="table"?t.jsx(To,{table:s.table,opts:o},a):t.jsx(g.Fragment,{children:Vg(s.text,o)},a)):yt(e,void 0,o)}const Yg=/^(#{1,6})\s+(.*)$/,Kg=/^\*\*([^*\n]+)\*\*\s*$/;function Io(e){const n=e.match(Yg);if(n)return{level:n[1].length,text:n[2].trim()};const i=e.trim().match(Kg);return i?{level:3,text:i[1].trim()}:null}const Eo=/^<!--.*-->$/;function Gc(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Yc(e){return e.split(`
1315
- `).map(n=>n.trim()).filter(n=>n&&!Eo.test(n))}const qg=60;function Kc(e){let n=0,i=0;for(const o of e.split(`
1316
- `)){const s=o.trim();if(!s||Eo.test(s)||Io(s))continue;const a=s.replace(/<[^<>\n]*>/g,"").replace(/\s/g,"").length;n+=a,a>qg&&(i+=a)}return n>0&&i*2>=n}function Xg(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Di(e){if(e=Xg(e),Kc(e))return"unknown";const n=Gc(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>Yc(s).length).filter(s=>s>0);if(i.length===0)return"unknown";const o=i.reduce((s,a)=>s+a,0)/i.length;return o<=4?"record":o>=8?"catalog":"unknown"}function Zg(e){const n=e.split(`
1316
+ `);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(Ag.test(n[a].trim())){let l=a+1;for(;l<n.length&&!Mg.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);i.push({type:"table",table:Dc(d,a+1),source:n.slice(a,l+1).join(`
1317
+ `)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,h;if(l.type!=="text")return l;let c=l.text;return((p=i[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((h=i[d+1])==null?void 0:h.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const Og={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},Wg={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},Fg=`1px solid ${r("table-border")}`,Uc={border:Fg,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},Hg={...Uc,background:r("table-head-bg"),fontWeight:600};function Ro({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:Og,children:t.jsx("table",{className:"bim-guji-table",style:Wg,children:t.jsx("tbody",{children:e.rows.map((i,o)=>t.jsx("tr",{children:i.cells.map((s,a)=>{const l=i.header?"th":"td";return t.jsx(l,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:i.header?Hg:Uc,children:s.empty?null:yt(s.text,void 0,n)},a)})},o))})})})}function Dg(e,n){return e.indexOf("**")<0?yt(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((o,s)=>s%2===1?t.jsx("strong",{children:yt(o.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:yt(o,void 0,n)},s))}function Ug(e,n,i=!1){const o=i?{gujiMarkdown:!0}:void 0;return n?Io(e).map((s,a)=>s.type==="table"?t.jsx(Ro,{table:s.table,opts:o},a):t.jsx(g.Fragment,{children:Dg(s.text,o)},a)):yt(e,void 0,o)}const Vg=/^(#{1,6})\s+(.*)$/,Gg=/^\*\*([^*\n]+)\*\*\s*$/;function Eo(e){const n=e.match(Vg);if(n)return{level:n[1].length,text:n[2].trim()};const i=e.trim().match(Gg);return i?{level:3,text:i[1].trim()}:null}const Lo=/^<!--.*-->$/;function Vc(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Gc(e){return e.split(`
1318
+ `).map(n=>n.trim()).filter(n=>n&&!Lo.test(n))}const Yg=60;function Yc(e){let n=0,i=0;for(const o of e.split(`
1319
+ `)){const s=o.trim();if(!s||Lo.test(s)||Eo(s))continue;const a=s.replace(/<[^<>\n]*>/g,"").replace(/\s/g,"").length;n+=a,a>Yg&&(i+=a)}return n>0&&i*2>=n}function Kg(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Ui(e){if(e=Kg(e),Yc(e))return"unknown";const n=Vc(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>Gc(s).length).filter(s=>s>0);if(i.length===0)return"unknown";const o=i.reduce((s,a)=>s+a,0)/i.length;return o<=4?"record":o>=8?"catalog":"unknown"}function qg(e){const n=e.split(`
1317
1320
  `),i=[];let o=null,s=[];const a=()=>{i.push({heading:o,body:s.join(`
1318
- `)}),s=[]};for(const l of n){const d=Io(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function ya(e){const n=[];for(const i of e.split(`
1319
- `)){const o=Io(i);if(o){n.push({kind:"heading",level:o.level,text:o.text});continue}const s=i.trim();!s||Eo.test(s)||n.push({kind:"body",text:i})}return n}function qc(e){if(!e)return[];const n=Di(e);if(n==="unknown")return ya(e);const i=[];for(const{heading:o,body:s}of Zg(e)){o&&i.push(o);const a=Gc(s);if(a.length!==0){if(Kc(s)){i.push(...ya(s));continue}if(n==="record"){const l=a.join(" ");l&&i.push({kind:"body",text:l})}else for(const l of a){const d=Yc(l);d.length&&i.push({kind:"body",text:d.join(" ")})}}}return i}const Jg={"「":"“","」":"”","『":"‘","』":"’"},Qg={"“":"「","”":"」","‘":"『","’":"』"},ef=new Set(["《","》","〈","〉"]);function Xc(e,n){const i=n.quoteStyle==="modern"?Jg:n.quoteStyle==="classic"?Qg:null;let o="";for(const s of e)n.hideBookBrackets&&ef.has(s)||(o+=(i==null?void 0:i[s])??s);return o}const Zc=e=>e;function Ro(e){return e.showWorks?e.bookTitleStyle==="bracket"?"bracket":bh(e.properNameMode)?"wavy":"bracket":"none"}function Jc(e,n=Zc,i="wavy"){if(e.indexOf("《")<0)return n(e);const o=[],s=/《([^《》\n]+)》/g;let a=0,l=0,d;for(;d=s.exec(e);){d.index>a&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a,d.index))},l++));const c=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(d[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]});o.push(i==="wavy"?t.jsx("span",{className:"bim-rd-pn",children:c},l++):t.jsx(g.Fragment,{children:c},l++)),a=d.index+d[0].length}return a===0?n(e):(a<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a))},l++)),o)}function Ui(e,n={}){let i=n.renderText??Zc;const o=n.quoteStyle;if(o&&o!=="original"){const d=i;i=c=>d(Xc(c,{quoteStyle:o}))}const s=n.bookMarking??(n.properNames?"wavy":"bracket"),a=s==="bracket"?i:d=>Jc(d,i,s),l=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return yt(e,a,l)}function ja(e,n,i){return e.indexOf("**")<0?n(e):e.split(/(\*\*[^*]+\*\*)/g).map((s,a)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{children:n(s.slice(2,-2))},`${i}-${a}`):t.jsx(g.Fragment,{children:n(s)},`${i}-${a}`))}const br=/^(#{1,6})\s+(.*)$/,tf=/^\s*<!--.*-->\s*$/;function Qc(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
1320
- `)?"":n)}function nf(e){return e<=1?2:e===2?3:4}function rf(){let e=1;return n=>{const i=nf(n),o=Math.min(i,e+1);return e=o,{Tag:`h${o}`,className:`bim-rd-hl${i}`}}}function $i(e){return e?Di(Qc(e))!=="unknown":!1}function of(e){return/^\u3000{2}/.test(e)}const va=e=>of(e)?"bim-rd-noindent":void 0;function ka({text:e,mode:n,inline:i,dropTitle:o,onStart:s}){s==null||s();const a=Qc(e),l=(h,m,u)=>!!o&&u<=1&&h<=2&&m.trim()===o.trim(),d=rf();if(n==="paragraph"&&Di(a)!=="unknown"){const h=qc(a);return t.jsx(t.Fragment,{children:h.map((m,u)=>{if(m.kind==="heading"){if(l(m.level??1,m.text,u))return null;const{Tag:f,className:x}=d(m.level??1);return t.jsx(f,{className:x,children:i(m.text)},u)}return t.jsx("p",{className:va(m.text),children:ja(m.text,i,u)},u)})})}const c=a.split(`
1321
- `);let p=0;return t.jsx(t.Fragment,{children:c.map((h,m)=>{const u=h.match(br);if(u){const x=p++;if(l(u[1].length,u[2],x))return null;const{Tag:v,className:b}=d(u[1].length);return t.jsx(v,{className:b,children:i(u[2])},m)}if(!h.trim())return m>=2&&!!c[m-1].trim()&&!!c[m-2].trim()&&!br.test(c[m-1])&&!br.test(c[m-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},m):null;if(tf.test(h))return null;if(p++,/^\*\*[^*]+\*\*\s*$/.test(h.trim())){const{Tag:x,className:v}=d(3);return t.jsx(x,{className:v,children:i(h.trim().slice(2,-2))},m)}return t.jsx("p",{className:va(h),children:ja(h,i,m)},m)})})}function sf(e){const{convert:n}=Me();return g.useMemo(()=>e?n(e):"",[e,n])}function Lo({text:e,mode:n,tables:i=!1,gujiMarkdown:o=!1,properNames:s=!1,bookMarking:a,quoteStyle:l,renderText:d,dropTitle:c}){const p=sf(e),{t:h,convert:m}=ie();let u=null;const f=!!d&&!Nh(e,p,!l||l==="original"),x=d&&f?w=>d(w,{mdStart:u==null?void 0:u.align(w)}):d,v=f?()=>{u=Rh(e)}:void 0,b=w=>Ui(w,{renderText:x,properNames:s,bookMarking:a,quoteStyle:l,gujiMarkdown:o,t:h}),$=o?{gujiMarkdown:!0,t:h}:void 0,y=c?m(c):void 0;return!i||p.indexOf(":::")<0?t.jsx(ka,{text:p,mode:n,inline:b,dropTitle:y,onStart:v}):t.jsx(t.Fragment,{children:No(p).map((w,k)=>w.type==="table"?t.jsx(To,{table:w.table,opts:$},k):t.jsx(ka,{text:w.text,mode:n,inline:b,dropTitle:k===0?y:void 0},k))})}const wa={work:"work",book:"work",people:"people",person:"people",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function af(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(wa,e)&&wa[e]||"other"}function Dr(e){if(!e)return null;const n=e.trim(),i=/^book-index:\/\/(?:[A-Za-z]+\/)*([0-9A-Za-z]+)\/?$/.exec(n);if(i)return i[1];const o=/^bid:\\{1,2}([0-9A-Za-z]+)$/.exec(n);return o?o[1]:/^[0-9A-Za-z]+$/.test(n)?n:null}function Yt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function it(e){return typeof e=="string"&&e?e:void 0}function lf(e){const n=e&&typeof e=="object"?e.candidates:void 0;if(!Array.isArray(n))return;const i=[];for(const o of n){if(!o||typeof o!="object"||Array.isArray(o))continue;const s=o,a={};it(s.entity_id)!==void 0&&(a.entity_id=it(s.entity_id)),it(s.canonical_name)!==void 0&&(a.canonical_name=it(s.canonical_name)),Yt(s.confidence)!==void 0&&(a.confidence=Yt(s.confidence)),i.push(a)}return i}const hn=e=>e.start!==void 0&&e.end!==void 0;function ed(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.entities)?e.entities:[],i=[];return n.forEach((o,s)=>{if(!o||typeof o!="object")return;const a=o,l=a.span??{},d=a.target??{},c=Yt(l.start_offset)??Yt(a.start_offset),p=Yt(l.end_offset)??Yt(a.end_offset),h=c!==void 0&&p!==void 0&&c>=0&&p>c,m=a.anchor??{},u=it(m.start),f=it(m.end);if(!h&&!!!(u&&f))return;const v=it(d.status),b=v===void 0||v==="matched"?Dr(it(d.entity_id))??Dr(it(d.href))??void 0:void 0,$=Yt(d.confidence),y=lf(a.ambiguous);i.push({...u&&f?{anchor:{start:u,end:f}}:{},key:it(a.id)??`e${s}`,kind:af(a.type),...h?{start:c,end:p}:{},text:it(a.text),targetId:b,canonicalName:it(d.canonical_name),confidence:Yt(a.confidence)??$,...$!==void 0?{targetConfidence:$}:{},...it(d.level)!==void 0?{targetLevel:it(d.level)}:{},...it(d.note)!==void 0?{targetNote:it(d.note)}:{},...it(a.group)!==void 0?{group:it(a.group)}:{},...y!==void 0?{candidates:y}:{}})}),i.sort((o,s)=>!hn(o)||!hn(s)?+!hn(o)-+!hn(s):o.start-s.start||s.end-o.end)}const cf=new Set(Array.from(`《》/<>\r
1322
-  ,。、;:?!「」『』()…—·`));function Ao(e){return!cf.has(e)}function td(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)Ao(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!hn(d))continue;const c=d.start-i,p=d.end-i;if(c<0||p>o.length||p<=c)continue;const h=o[p-1],m=e.codePointAt(h)>65535?2:1;l.push({...d,start:o[c],end:h+m})}return l}function df(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(Ao).join("")===n.text:!0}function pf(e,n,i){if(!n.text)return null;let o=-1,s=Math.max(0,n.start-i);const a=n.start+i;for(;s<=a;){const l=e.indexOf(n.text,s);if(l<0||l>a)break;(o<0||Math.abs(l-n.start)<Math.abs(o-n.start))&&(o=l),s=l+1}return o<0?null:{...n,start:o,end:o+n.text.length}}function nd(e,n,i=16){const o=[];for(const l of n){if(!hn(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!df(e,d))&&(d=pf(e,l,i)),d&&o.push(d)}o.sort((l,d)=>l.start-d.start||d.end-l.end);const s=[];let a=0;for(const l of o)l.start<a||(l.start>a&&s.push({type:"text",text:e.slice(a,l.start),start:a}),s.push({type:"entity",text:e.slice(l.start,l.end),start:l.start,span:l}),a=l.end);return a<e.length&&s.push({type:"text",text:e.slice(a),start:a}),s}const uf={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function mf(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set(uf[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function hf(e,n,i){const[o,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,i)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(h=>{c===d.current&&s(h??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,i]),{images:o,loading:a}}function gf(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(vu,e)?e:null}function ff(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const xf={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},id="\0";function bf(e,n,i){const[o,s=""]=e.split(id);return t.jsxs(t.Fragment,{children:[o,t.jsx(Jl,{text:n,convert:i}),s]})}function vt(e){return typeof e!="string"?"":xf[e]??e}const yf=["〇","一","二","三","四","五","六","七","八","九"],Sa=["","十","百","千"],jf=["","萬","億"];function Mo(e){if(e===0)return"〇";if(e<0)return`負${Mo(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(vf(s,o>0)+jf[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function vf(e,n){const i=[];let o=e;for(;o>0;)i.unshift(o%10),o=Math.floor(o/10);let s="";for(let a=0;a<i.length;a++){const l=i[a],d=i.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=Sa[d]:s+=yf[l]+Sa[d]}return s.replace(/〇$/,"")}let Hn=null,ui=null;const Ci=new Set;function kf(){return Hn?Promise.resolve():ui||(ui=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Hn=i=>n(_e.normalizeVariants(i)),Ci.forEach(i=>i())}).catch(()=>{Hn=e=>e,Ci.forEach(e=>e())}),ui)}const wf=e=>e;function ln(){const[,e]=g.useState(0);return g.useEffect(()=>{if(Hn)return;const n=()=>e(i=>i+1);return Ci.add(n),kf(),()=>{Ci.delete(n)}},[]),Hn??wf}function yn(e,n){return n(e).toLowerCase()}const Sf=r("highlight-bg");function Xn(e,n,i){if(!n)return e;const o=yn(n,i);if(!o)return e;const s=yn(e,i),a=Array.from(e),l=Array.from(s);if(l.length!==a.length)return e;const d=new Map;let c=0;l.forEach((x,v)=>{d.set(c,v),c+=x.length});const p=Array.from(o).length,h=[];let m=0,u=0,f=0;for(;m<a.length;){const x=s.indexOf(o,u),v=x===-1?void 0:d.get(x);if(x===-1){h.push(a.slice(m).join(""));break}if(v===void 0){u=x+1;continue}v>m&&h.push(a.slice(m,v).join("")),h.push(t.jsx("mark",{style:{background:Sf,padding:0,color:"inherit"},children:a.slice(v,v+p).join("")},f++)),m=v+p,u=x+o.length}return t.jsx(t.Fragment,{children:h})}function Po(e,n,i,o){if(!n)return!0;const s=yn(n,o);return(i?[e.title,e.header_line,e.content,e.comment]:[e.title,e.book_title,e.author,e.author_info,e.summary,e.content,e.comment,e.additional_comment]).some(l=>typeof l=="string"&&yn(l,o).includes(s))}function _f(e,n,i){return n?yn(e,i).includes(yn(n,i)):!0}const Bo={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},$f={考证:r("section-kaozhen")};function Oo(e,n,i){return e.collated.sectionType[n]??i(n)}function rd(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+rd(a),0))||0;return n+i}function Cf(e,n){const i=[],o=l=>{var d;i.push(...l.files),(d=l.children)==null||d.forEach(o)};if(o(e),i.length===0)return;const s=i.map(l=>n[l]);if(s.every(l=>l===void 0))return;if(s.some(l=>l==="loading"))return"loading";let a=0;for(const l of s)typeof l=="number"&&(a+=l);return a}const zf={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function Wo({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...zf,...o},children:s}):t.jsx("span",{style:o,children:s})}function Nf({type:e}){const{convert:n,messages:i}=ie(),o=vt(e),s=Bo[o]||r("desc-fg");return t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:s,border:`1px solid ${s}40`,borderRadius:"2px",background:`${s}08`,flexShrink:0},children:Oo(i,o,n)})}function Tf({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=ie(),c=rt(),p=ln(),h=w=>w?yt(d(w),k=>i?Xn(k,i,p):k,{t:l}):"",[m,u]=g.useState(!1),f=!!e.summary,x=!!e.comment,v=!!e.additional_comment,b=!!(e.content&&e.content.length>60),$=f||x||v||b;g.useEffect(()=>{i&&u(!0)},[i]);const y=!m&&b?Mc(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${r("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>$&&u(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:$?"pointer":"default",userSelect:"none"},children:[o!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:r("label-fg")},children:o}),t.jsxs(Wo,{enabled:$,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[$&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",h(e.book_title),"》"]}):h(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(Mo(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:h(e.author_info||e.author)})]}),!m&&y&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:h(y)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:r("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),"aria-label":l("collated.viewWorkOf",{title:d(e.book_title||e.title)}),children:l("collated.workArrow")}),s&&!e.work_id&&t.jsx("span",{style:{fontSize:"11px",color:r("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),m&&$&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:h(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:h(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.additional_comment)})]}),b&&!f&&!x&&!v&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)})]})]})}function If({section:e,highlightQuery:n=""}){const{t:i,convert:o}=ie(),s=ln(),a=p=>p?yt(o(p),h=>n?Xn(h,n,s):h,{t:i}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(Wo,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Nf,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),l&&c&&t.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${Bo[vt(e.type)]||r("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:r("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const Ef=100;function Fo(e){return vt(e.type)!=="page_header"?!1:(e.content||"").length>=Ef}function Rf({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=ie(),a=ln();if(vt(e.type)==="page_header"&&!Fo(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
1323
- `)),d=yt(l,m=>n?Xn(m,n,a):m,{t:i}),c=vt(e.type),p=Bo[c]||r("desc-fg"),h=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:h?"10px 12px":"6px 0",margin:h?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:h?`3px solid ${p}40`:void 0,background:h?r("bg"):void 0,borderRadius:h?"0 4px 4px 0":void 0,position:"relative"},children:[h&&t.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:p,marginRight:"8px",padding:"1px 5px",border:`1px solid ${p}40`,borderRadius:"2px",background:`${p}08`,verticalAlign:"middle"},children:Oo(s,c,o)}),d]})}function Lf(e,n,i){const[o,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(h=>{var m;return!((m=i==null?void 0:i.current)!=null&&m.has(h))}),d={};for(const h of e)(p=i==null?void 0:i.current)!=null&&p.has(h)&&(d[h]=i.current.get(h));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async h=>{var m;try{if(n.getEntry){const b=await n.getEntry(h);if(b)return{title:b.title,author:b.author}}const u=await n.getItem(h);if(!u)return null;const f=u.title||h,x=u.authors,v=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:f,author:v}}catch{return null}};return Promise.all(l.map(async h=>{var u;const m=await c(h);return(u=i==null?void 0:i.current)==null||u.set(h,m),[h,m]})).then(h=>{a||s(m=>{const u={...m};for(const[f,x]of h)u[f]=x;return u})}),()=>{a=!0}},[e.join(","),n]),o}function Af({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=ie(),c=rt(),p=ln(),h=k=>k?yt(l(k),j=>s?Xn(j,s,p):j,{t:a}):"",[m,u]=g.useState(!1);g.useEffect(()=>{s&&u(!0)},[s]);const f=vt(e.type),x=$f[f]||r("desc-fg"),v=!!e.content,b=e.work_ids||[],$=b.length>1,y=Lf($?b:[],i,o),w=v&&!m&&e.content.length>80?Mc(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>v&&u(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:v?"pointer":"default",userSelect:"none"},children:[t.jsxs(Wo,{enabled:v,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[v&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg"),lineHeight:1.6},children:e.header_line?h(e.header_line):h(e.title)}),!m&&w&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:h(w)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[b.length===1&&n&&t.jsx("a",{href:c(b[0]),onClick:k=>{k.metaKey||k.ctrlKey||(k.preventDefault(),k.stopPropagation(),n(b[0]))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),$&&t.jsx("span",{style:{fontSize:"11px",color:r("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:b.length})}),t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:x,border:`1px solid ${x}40`,borderRadius:"2px",background:`${x}08`},children:Oo(d,f,l)})]})]}),$&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:b.map(k=>{const j=y[k],C=j?`${l(j.title)}${j.author?`(${l(j.author)})`:""}`:k.slice(0,8)+"…";return t.jsxs("a",{href:c(k),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),_.stopPropagation(),n(k))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:k,children:["→",C]},k)})}),m&&v&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${r("widget-border")}`,fontSize:"12px",color:r("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:h(e.comment)})]})]})}function Mf({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=ie(),l=ln(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>Po(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,h)=>t.jsx(Af,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},h))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Pf(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Bf({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=rt(),{t:a,convert:l}=ie(),d=Pf();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const h=vt(c.type);if(h==="page_header"&&!Fo(c))return null;if(h==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(h==="书"||h==="诗"||h==="考证"||h==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:Mo(c.n_juan)}):""}`:c.title,u=i(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:u}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):u),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:i(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),i(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),i(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),i(l(c.additional_comment))]})]},p)}return h==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function od(e){return e.some(n=>{const i=vt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&Fo(n)})}function Of({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:h,onViewChange:m}){var V;const{t:u,convert:f,messages:x}=ie(),v=ln(),[b,$]=g.useState("text"),y=h??b,w=ne=>{$(ne),m==null||m(ne)},k=a.trim(),j=(s==null?void 0:s.type)==="kaozhen",C=g.useCallback(ne=>k?Xn(ne,k,v):ne,[k,v]),_=Ro(p),S=ne=>Ui(ne,{renderText:C,bookMarking:_,quoteStyle:p.quoteStyle,t:u}),R=g.useMemo(()=>k?e.sections.filter(ne=>Po(ne,k,j,v)):e.sections,[e.sections,k,j,v]),N=(ne,je)=>je.filter(ge=>vt(ge.type)===ne).length,z=N("书",e.sections),M=N("诗",e.sections),F=N("考证",e.sections);let L="";j?L=k?u("collated.countTiaoOf",{m:N("考证",R),n:F}):u("collated.countTiao",{n:F}):M>0?L=k?u("collated.countPoemsOf",{m:N("诗",R),n:M}):u("collated.countPoems",{n:M}):z>0&&(L=k?u("collated.countBooksOf",{m:N("书",R),n:z}):u("collated.countBooks",{n:z}));const E=s!=null&&s.text_quality?gf(s.text_quality.grade):null,P=[];if(L&&P.push(L),j&&(s!=null&&s.target_source)&&P.push(t.jsx(t.Fragment,{children:u("collated.kaozhenTarget",{target:f(s.target_source)})})),E){const ne=t.jsx("span",{className:"bim-rd-grade",style:ff(E),children:x.collated.qualityLabel[E]});P.push(t.jsx("span",{title:x.collated.qualityCriteria[E],children:(V=s==null?void 0:s.text_quality)!=null&&V.source_note?t.jsxs(t.Fragment,{children:[bf(u("collated.baseText",{note:id}),s.text_quality.source_note,f),ne]}):t.jsxs(t.Fragment,{children:[u("collated.textQuality"),ne]})}))}e.source_url&&P.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:u("collated.originalSource")}));const Z=!j&&od(e.sections),oe=!!n&&(!Z||p.readingMode==="paragraph"&&$i(n)),ae=!j&&(Z||!!n),H=j||!ae?"entries":y;let ce=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(i||o)&&t.jsxs("p",{className:"bim-rd-kicker",children:[i,i&&o&&t.jsx("span",{className:"bim-rd-dot"}),o&&f(o)]}),t.jsx("h1",{className:"bim-rd-h1",children:f(e.title)}),P.length>0&&t.jsx("p",{className:"bim-rd-meta",children:P.map((ne,je)=>t.jsxs(g.Fragment,{children:[je>0&&t.jsx("span",{className:"bim-rd-dot"}),ne]},je))}),ae&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":u("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":H==="text",onClick:()=>w("text"),children:u("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":H==="entries",onClick:()=>w("entries"),children:u("collated.viewEntries")})]})]}),H==="text"&&t.jsx("article",{className:"bim-rd-prose",children:oe?t.jsx(Lo,{text:n,mode:p.readingMode,bookMarking:_,quoteStyle:p.quoteStyle,renderText:C,dropTitle:e.title}):t.jsx(Bf,{sections:e.sections,onNavigate:l,inline:S,workLinks:p.workLinks})}),H==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:j?t.jsx(Mf,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[R.some(ne=>["书","诗","考证"].includes(vt(ne.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:u("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:u("collated.rowHeadTitle")}),t.jsx("span",{children:u("collated.rowHeadWork")})]}),R.map((ne,je)=>{const ge=vt(ne.type);return ge==="书"||ge==="诗"||ge==="考证"?(ce+=1,t.jsx(Tf,{domId:`rd-e-${e.sections.indexOf(ne)}`,section:ne,onNavigate:p.workLinks?l:void 0,highlightQuery:k,no:ce,showUnlinked:p.workLinks&&!!l},je)):ge==="类"?t.jsx(If,{section:ne,highlightQuery:k},je):t.jsx(Rf,{section:ne,highlightQuery:k},je)}),R.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:u("collated.noMatch")})]})})]})}function Wf(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=ln(),h=g.useRef(new Map),[m,u]=g.useState({}),[f,x]=g.useState({}),v=g.useCallback(($,y)=>{const w=y==null?void 0:y.title;w&&x(k=>k[$]===w?k:{...k,[$]:w})},[]);g.useEffect(()=>{s&&a&&(h.current.set(s,{juan:a,rawText:l}),v(s,a))},[s,a,l,v]),g.useEffect(()=>{h.current.clear(),u({}),x({})},[n]);const b=g.useCallback(($,y)=>{let w=0;if($.juan)for(const k of $.juan.sections)Po(k,y,c,p)&&w++;return w===0&&$.rawText&&_f($.rawText,y,p)&&(w=1),w},[c,p]);return g.useEffect(()=>{const $=d.trim();if(!$){u({});return}if(!i||o.length===0)return;let y=!1;const w={},k=[];for(const R of o){const N=h.current.get(R);N?w[R]=b(N,$):(w[R]="loading",k.push(R))}u(w);const j=8;let C=0;const _=async()=>{for(;C<k.length;){if(y)return;const R=C++,N=k[R];try{const z=await i(N),M=z.juan;if(h.current.set(N,z),v(N,M),y)return;u(F=>({...F,[N]:b(z,$)}))}catch{if(y)return;u(z=>({...z,[N]:0}))}}},S=Array.from({length:Math.min(j,k.length)},()=>_());return Promise.all(S),()=>{y=!0}},[d,n,i,o.join(","),b,p,v]),{matchStates:m,titles:f}}function Ff({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=ie(),l=e.sections.map((h,m)=>({s:h,i:m,t:vt(h.type)})).filter(h=>h.t==="书"||h.t==="诗");if(l.length===0)return null;const d=l.filter(h=>!!h.s.work_id).length,c=l.every(h=>h.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=h=>{const m=()=>{var u,f;return(f=(u=document.getElementById(`rd-e-${h}`))==null?void 0:u.scrollIntoView)==null?void 0:f.call(u,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(m,0):m()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:h,i:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:u=>{u.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${h.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:Ui(a(h.book_title||h.title),{t:s})})]})},m))})]})]})}const Hf=`
1321
+ `)}),s=[]};for(const l of n){const d=Eo(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function ja(e){const n=[];for(const i of e.split(`
1322
+ `)){const o=Eo(i);if(o){n.push({kind:"heading",level:o.level,text:o.text});continue}const s=i.trim();!s||Lo.test(s)||n.push({kind:"body",text:i})}return n}function Kc(e){if(!e)return[];const n=Ui(e);if(n==="unknown")return ja(e);const i=[];for(const{heading:o,body:s}of qg(e)){o&&i.push(o);const a=Vc(s);if(a.length!==0){if(Yc(s)){i.push(...ja(s));continue}if(n==="record"){const l=a.join(" ");l&&i.push({kind:"body",text:l})}else for(const l of a){const d=Gc(l);d.length&&i.push({kind:"body",text:d.join(" ")})}}}return i}const Xg={"「":"“","」":"”","『":"‘","』":"’"},Zg={"“":"「","”":"」","‘":"『","’":"』"},Jg=new Set(["《","》","〈","〉"]);function qc(e,n){const i=n.quoteStyle==="modern"?Xg:n.quoteStyle==="classic"?Zg:null;let o="";for(const s of e)n.hideBookBrackets&&Jg.has(s)||(o+=(i==null?void 0:i[s])??s);return o}const Xc=e=>e;function Ao(e){return e.showWorks?e.bookTitleStyle==="bracket"?"bracket":Ph(e.properNameMode)?"wavy":"bracket":"none"}function Zc(e,n=Xc,i="wavy"){if(e.indexOf("《")<0)return n(e);const o=[],s=/《([^《》\n]+)》/g;let a=0,l=0,d;for(;d=s.exec(e);){d.index>a&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a,d.index))},l++));const c=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(d[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]});o.push(i==="wavy"?t.jsx("span",{className:"bim-rd-pn",children:c},l++):t.jsx(g.Fragment,{children:c},l++)),a=d.index+d[0].length}return a===0?n(e):(a<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(a))},l++)),o)}function Vi(e,n={}){let i=n.renderText??Xc;const o=n.quoteStyle;if(o&&o!=="original"){const d=i;i=c=>d(qc(c,{quoteStyle:o}))}const s=n.bookMarking??(n.properNames?"wavy":"bracket"),a=s==="bracket"?i:d=>Zc(d,i,s),l=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return yt(e,a,l)}function va(e,n,i){return e.indexOf("**")<0?n(e):e.split(/(\*\*[^*]+\*\*)/g).map((s,a)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{children:n(s.slice(2,-2))},`${i}-${a}`):t.jsx(g.Fragment,{children:n(s)},`${i}-${a}`))}const jr=/^(#{1,6})\s+(.*)$/,Qg=/^\s*<!--.*-->\s*$/;function Jc(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
1323
+ `)?"":n)}function ef(e){return e<=1?2:e===2?3:4}function tf(){let e=1;return n=>{const i=ef(n),o=Math.min(i,e+1);return e=o,{Tag:`h${o}`,className:`bim-rd-hl${i}`}}}function Ci(e){return e?Ui(Jc(e))!=="unknown":!1}function nf(e){return/^\u3000{2}/.test(e)}const ka=e=>nf(e)?"bim-rd-noindent":void 0;function wa({text:e,mode:n,inline:i,dropTitle:o,onStart:s}){s==null||s();const a=Jc(e),l=(h,m,u)=>!!o&&u<=1&&h<=2&&m.trim()===o.trim(),d=tf();if(n==="paragraph"&&Ui(a)!=="unknown"){const h=Kc(a);return t.jsx(t.Fragment,{children:h.map((m,u)=>{if(m.kind==="heading"){if(l(m.level??1,m.text,u))return null;const{Tag:f,className:x}=d(m.level??1);return t.jsx(f,{className:x,children:i(m.text)},u)}return t.jsx("p",{className:ka(m.text),children:va(m.text,i,u)},u)})})}const c=a.split(`
1324
+ `);let p=0;return t.jsx(t.Fragment,{children:c.map((h,m)=>{const u=h.match(jr);if(u){const x=p++;if(l(u[1].length,u[2],x))return null;const{Tag:v,className:b}=d(u[1].length);return t.jsx(v,{className:b,children:i(u[2])},m)}if(!h.trim())return m>=2&&!!c[m-1].trim()&&!!c[m-2].trim()&&!jr.test(c[m-1])&&!jr.test(c[m-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},m):null;if(Qg.test(h))return null;if(p++,/^\*\*[^*]+\*\*\s*$/.test(h.trim())){const{Tag:x,className:v}=d(3);return t.jsx(x,{className:v,children:i(h.trim().slice(2,-2))},m)}return t.jsx("p",{className:ka(h),children:va(h,i,m)},m)})})}function rf(e){const{convert:n}=Me();return g.useMemo(()=>e?n(e):"",[e,n])}function Mo({text:e,mode:n,tables:i=!1,gujiMarkdown:o=!1,properNames:s=!1,bookMarking:a,quoteStyle:l,renderText:d,dropTitle:c}){const p=rf(e),{t:h,convert:m}=ne();let u=null;const f=!!d&&!Kh(e,p,!l||l==="original"),x=d&&f?w=>d(w,{mdStart:u==null?void 0:u.align(w)}):d,v=f?()=>{u=Jh(e)}:void 0,b=w=>Vi(w,{renderText:x,properNames:s,bookMarking:a,quoteStyle:l,gujiMarkdown:o,t:h}),_=o?{gujiMarkdown:!0,t:h}:void 0,y=c?m(c):void 0;return!i||p.indexOf(":::")<0?t.jsx(wa,{text:p,mode:n,inline:b,dropTitle:y,onStart:v}):t.jsx(t.Fragment,{children:Io(p).map((w,j)=>w.type==="table"?t.jsx(Ro,{table:w.table,opts:_},j):t.jsx(wa,{text:w.text,mode:n,inline:b,dropTitle:j===0?y:void 0},j))})}const Sa={work:"work",book:"work",people:"people",person:"people",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function of(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(Sa,e)&&Sa[e]||"other"}function Vr(e){if(!e)return null;const n=e.trim(),i=/^book-index:\/\/(?:[A-Za-z]+\/)*([0-9A-Za-z]+)\/?$/.exec(n);if(i)return i[1];const o=/^bid:\\{1,2}([0-9A-Za-z]+)$/.exec(n);return o?o[1]:/^[0-9A-Za-z]+$/.test(n)?n:null}function Yt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function it(e){return typeof e=="string"&&e?e:void 0}function sf(e){const n=e&&typeof e=="object"?e.candidates:void 0;if(!Array.isArray(n))return;const i=[];for(const o of n){if(!o||typeof o!="object"||Array.isArray(o))continue;const s=o,a={};it(s.entity_id)!==void 0&&(a.entity_id=it(s.entity_id)),it(s.canonical_name)!==void 0&&(a.canonical_name=it(s.canonical_name)),Yt(s.confidence)!==void 0&&(a.confidence=Yt(s.confidence)),i.push(a)}return i}const gn=e=>e.start!==void 0&&e.end!==void 0;function Qc(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.entities)?e.entities:[],i=[];return n.forEach((o,s)=>{if(!o||typeof o!="object")return;const a=o,l=a.span??{},d=a.target??{},c=Yt(l.start_offset)??Yt(a.start_offset),p=Yt(l.end_offset)??Yt(a.end_offset),h=c!==void 0&&p!==void 0&&c>=0&&p>c,m=a.anchor??{},u=it(m.start),f=it(m.end);if(!h&&!!!(u&&f))return;const v=it(d.status),b=v===void 0||v==="matched"?Vr(it(d.entity_id))??Vr(it(d.href))??void 0:void 0,_=Yt(d.confidence),y=sf(a.ambiguous);i.push({...u&&f?{anchor:{start:u,end:f}}:{},key:it(a.id)??`e${s}`,kind:of(a.type),...h?{start:c,end:p}:{},text:it(a.text),targetId:b,canonicalName:it(d.canonical_name),confidence:Yt(a.confidence)??_,..._!==void 0?{targetConfidence:_}:{},...it(d.level)!==void 0?{targetLevel:it(d.level)}:{},...it(d.note)!==void 0?{targetNote:it(d.note)}:{},...it(a.group)!==void 0?{group:it(a.group)}:{},...y!==void 0?{candidates:y}:{}})}),i.sort((o,s)=>!gn(o)||!gn(s)?+!gn(o)-+!gn(s):o.start-s.start||s.end-o.end)}const af=new Set(Array.from(`《》/<>\r
1325
+  ,。、;:?!「」『』()…—·`));function Po(e){return!af.has(e)}function ed(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)Po(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!gn(d))continue;const c=d.start-i,p=d.end-i;if(c<0||p>o.length||p<=c)continue;const h=o[p-1],m=e.codePointAt(h)>65535?2:1;l.push({...d,start:o[c],end:h+m})}return l}function lf(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(Po).join("")===n.text:!0}function cf(e,n,i){if(!n.text)return null;let o=-1,s=Math.max(0,n.start-i);const a=n.start+i;for(;s<=a;){const l=e.indexOf(n.text,s);if(l<0||l>a)break;(o<0||Math.abs(l-n.start)<Math.abs(o-n.start))&&(o=l),s=l+1}return o<0?null:{...n,start:o,end:o+n.text.length}}function td(e,n,i=16){const o=[];for(const l of n){if(!gn(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!lf(e,d))&&(d=cf(e,l,i)),d&&o.push(d)}o.sort((l,d)=>l.start-d.start||d.end-l.end);const s=[];let a=0;for(const l of o)l.start<a||(l.start>a&&s.push({type:"text",text:e.slice(a,l.start),start:a}),s.push({type:"entity",text:e.slice(l.start,l.end),start:l.start,span:l}),a=l.end);return a<e.length&&s.push({type:"text",text:e.slice(a),start:a}),s}const df={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function pf(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set(df[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function uf(e,n,i){const[o,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,i)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(h=>{c===d.current&&s(h??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,i]),{images:o,loading:a}}function mf(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(ju,e)?e:null}function hf(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const gf={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},nd="\0";function ff(e,n,i){const[o,s=""]=e.split(nd);return t.jsxs(t.Fragment,{children:[o,t.jsx(lc,{text:n,convert:i}),s]})}function vt(e){return typeof e!="string"?"":gf[e]??e}const xf=["〇","一","二","三","四","五","六","七","八","九"],_a=["","十","百","千"],bf=["","萬","億"];function Bo(e){if(e===0)return"〇";if(e<0)return`負${Bo(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(yf(s,o>0)+bf[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function yf(e,n){const i=[];let o=e;for(;o>0;)i.unshift(o%10),o=Math.floor(o/10);let s="";for(let a=0;a<i.length;a++){const l=i[a],d=i.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=_a[d]:s+=xf[l]+_a[d]}return s.replace(/〇$/,"")}let Un=null,hi=null;const zi=new Set;function jf(){return Un?Promise.resolve():hi||(hi=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Un=i=>n($e.normalizeVariants(i)),zi.forEach(i=>i())}).catch(()=>{Un=e=>e,zi.forEach(e=>e())}),hi)}const vf=e=>e;function ln(){const[,e]=g.useState(0);return g.useEffect(()=>{if(Un)return;const n=()=>e(i=>i+1);return zi.add(n),jf(),()=>{zi.delete(n)}},[]),Un??vf}function jn(e,n){return n(e).toLowerCase()}const kf=r("highlight-bg");function Jn(e,n,i){if(!n)return e;const o=jn(n,i);if(!o)return e;const s=jn(e,i),a=Array.from(e),l=Array.from(s);if(l.length!==a.length)return e;const d=new Map;let c=0;l.forEach((x,v)=>{d.set(c,v),c+=x.length});const p=Array.from(o).length,h=[];let m=0,u=0,f=0;for(;m<a.length;){const x=s.indexOf(o,u),v=x===-1?void 0:d.get(x);if(x===-1){h.push(a.slice(m).join(""));break}if(v===void 0){u=x+1;continue}v>m&&h.push(a.slice(m,v).join("")),h.push(t.jsx("mark",{style:{background:kf,padding:0,color:"inherit"},children:a.slice(v,v+p).join("")},f++)),m=v+p,u=x+o.length}return t.jsx(t.Fragment,{children:h})}function Oo(e,n,i,o){if(!n)return!0;const s=jn(n,o);return(i?[e.title,e.header_line,e.content,e.comment]:[e.title,e.book_title,e.author,e.author_info,e.summary,e.content,e.comment,e.additional_comment]).some(l=>typeof l=="string"&&jn(l,o).includes(s))}function wf(e,n,i){return n?jn(e,i).includes(jn(n,i)):!0}const Wo={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},Sf={考证:r("section-kaozhen")};function Fo(e,n,i){return e.collated.sectionType[n]??i(n)}function id(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+id(a),0))||0;return n+i}function _f(e,n){const i=[],o=l=>{var d;i.push(...l.files),(d=l.children)==null||d.forEach(o)};if(o(e),i.length===0)return;const s=i.map(l=>n[l]);if(s.every(l=>l===void 0))return;if(s.some(l=>l==="loading"))return"loading";let a=0;for(const l of s)typeof l=="number"&&(a+=l);return a}const $f={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function Ho({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...$f,...o},children:s}):t.jsx("span",{style:o,children:s})}function Cf({type:e}){const{convert:n,messages:i}=ne(),o=vt(e),s=Wo[o]||r("desc-fg");return t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:s,border:`1px solid ${s}40`,borderRadius:"2px",background:`${s}08`,flexShrink:0},children:Fo(i,o,n)})}function zf({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=ne(),c=rt(),p=ln(),h=w=>w?yt(d(w),j=>i?Jn(j,i,p):j,{t:l}):"",[m,u]=g.useState(!1),f=!!e.summary,x=!!e.comment,v=!!e.additional_comment,b=!!(e.content&&e.content.length>60),_=f||x||v||b;g.useEffect(()=>{i&&u(!0)},[i]);const y=!m&&b?Ac(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${r("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>_&&u(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:_?"pointer":"default",userSelect:"none"},children:[o!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:r("label-fg")},children:o}),t.jsxs(Ho,{enabled:_,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[_&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",h(e.book_title),"》"]}):h(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(Bo(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:h(e.author_info||e.author)})]}),!m&&y&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:h(y)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:h(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:r("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),"aria-label":l("collated.viewWorkOf",{title:d(e.book_title||e.title)}),children:l("collated.workArrow")}),s&&!e.work_id&&t.jsx("span",{style:{fontSize:"11px",color:r("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),m&&_&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:h(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:h(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:h(e.additional_comment)})]}),b&&!f&&!x&&!v&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)})]})]})}function Nf({section:e,highlightQuery:n=""}){const{t:i,convert:o}=ne(),s=ln(),a=p=>p?yt(o(p),h=>n?Jn(h,n,s):h,{t:i}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(Ho,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Cf,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),l&&c&&t.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${Wo[vt(e.type)]||r("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:r("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const Tf=100;function Do(e){return vt(e.type)!=="page_header"?!1:(e.content||"").length>=Tf}function If({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=ne(),a=ln();if(vt(e.type)==="page_header"&&!Do(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
1326
+ `)),d=yt(l,m=>n?Jn(m,n,a):m,{t:i}),c=vt(e.type),p=Wo[c]||r("desc-fg"),h=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:h?"10px 12px":"6px 0",margin:h?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:h?`3px solid ${p}40`:void 0,background:h?r("bg"):void 0,borderRadius:h?"0 4px 4px 0":void 0,position:"relative"},children:[h&&t.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:p,marginRight:"8px",padding:"1px 5px",border:`1px solid ${p}40`,borderRadius:"2px",background:`${p}08`,verticalAlign:"middle"},children:Fo(s,c,o)}),d]})}function Rf(e,n,i){const[o,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(h=>{var m;return!((m=i==null?void 0:i.current)!=null&&m.has(h))}),d={};for(const h of e)(p=i==null?void 0:i.current)!=null&&p.has(h)&&(d[h]=i.current.get(h));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async h=>{var m;try{if(n.getEntry){const b=await n.getEntry(h);if(b)return{title:b.title,author:b.author}}const u=await n.getItem(h);if(!u)return null;const f=u.title||h,x=u.authors,v=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:f,author:v}}catch{return null}};return Promise.all(l.map(async h=>{var u;const m=await c(h);return(u=i==null?void 0:i.current)==null||u.set(h,m),[h,m]})).then(h=>{a||s(m=>{const u={...m};for(const[f,x]of h)u[f]=x;return u})}),()=>{a=!0}},[e.join(","),n]),o}function Ef({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=ne(),c=rt(),p=ln(),h=j=>j?yt(l(j),k=>s?Jn(k,s,p):k,{t:a}):"",[m,u]=g.useState(!1);g.useEffect(()=>{s&&u(!0)},[s]);const f=vt(e.type),x=Sf[f]||r("desc-fg"),v=!!e.content,b=e.work_ids||[],_=b.length>1,y=Rf(_?b:[],i,o),w=v&&!m&&e.content.length>80?Ac(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>v&&u(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:v?"pointer":"default",userSelect:"none"},children:[t.jsxs(Ho,{enabled:v,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[v&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg"),lineHeight:1.6},children:e.header_line?h(e.header_line):h(e.title)}),!m&&w&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:h(w)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[b.length===1&&n&&t.jsx("a",{href:c(b[0]),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(b[0]))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),_&&t.jsx("span",{style:{fontSize:"11px",color:r("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:b.length})}),t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:x,border:`1px solid ${x}40`,borderRadius:"2px",background:`${x}08`},children:Fo(d,f,l)})]})]}),_&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:b.map(j=>{const k=y[j],C=k?`${l(k.title)}${k.author?`(${l(k.author)})`:""}`:j.slice(0,8)+"…";return t.jsxs("a",{href:c(j),onClick:$=>{$.metaKey||$.ctrlKey||($.preventDefault(),$.stopPropagation(),n(j))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:j,children:["→",C]},j)})}),m&&v&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:h(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${r("widget-border")}`,fontSize:"12px",color:r("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:h(e.comment)})]})]})}function Lf({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=ne(),l=ln(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>Oo(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,h)=>t.jsx(Ef,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},h))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Af(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Mf({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=rt(),{t:a,convert:l}=ne(),d=Af();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const h=vt(c.type);if(h==="page_header"&&!Do(c))return null;if(h==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(h==="书"||h==="诗"||h==="考证"||h==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:Bo(c.n_juan)}):""}`:c.title,u=i(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:u}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):u),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:i(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),i(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),i(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),i(l(c.additional_comment))]})]},p)}return h==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function rd(e){return e.some(n=>{const i=vt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&Do(n)})}function Pf({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:h,onViewChange:m}){var U;const{t:u,convert:f,messages:x}=ne(),v=ln(),[b,_]=g.useState("text"),y=h??b,w=te=>{_(te),m==null||m(te)},j=a.trim(),k=(s==null?void 0:s.type)==="kaozhen",C=g.useCallback(te=>j?Jn(te,j,v):te,[j,v]),$=Ao(p),S=te=>Vi(te,{renderText:C,bookMarking:$,quoteStyle:p.quoteStyle,t:u}),E=g.useMemo(()=>j?e.sections.filter(te=>Oo(te,j,k,v)):e.sections,[e.sections,j,k,v]),N=(te,ve)=>ve.filter(fe=>vt(fe.type)===te).length,z=N("书",e.sections),O=N("诗",e.sections),F=N("考证",e.sections);let A="";k?A=j?u("collated.countTiaoOf",{m:N("考证",E),n:F}):u("collated.countTiao",{n:F}):O>0?A=j?u("collated.countPoemsOf",{m:N("诗",E),n:O}):u("collated.countPoems",{n:O}):z>0&&(A=j?u("collated.countBooksOf",{m:N("书",E),n:z}):u("collated.countBooks",{n:z}));const I=s!=null&&s.text_quality?mf(s.text_quality.grade):null,P=[];if(A&&P.push(A),k&&(s!=null&&s.target_source)&&P.push(t.jsx(t.Fragment,{children:u("collated.kaozhenTarget",{target:f(s.target_source)})})),I){const te=t.jsx("span",{className:"bim-rd-grade",style:hf(I),children:x.collated.qualityLabel[I]});P.push(t.jsx("span",{title:x.collated.qualityCriteria[I],children:(U=s==null?void 0:s.text_quality)!=null&&U.source_note?t.jsxs(t.Fragment,{children:[ff(u("collated.baseText",{note:nd}),s.text_quality.source_note,f),te]}):t.jsxs(t.Fragment,{children:[u("collated.textQuality"),te]})}))}e.source_url&&P.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:u("collated.originalSource")}));const K=!k&&rd(e.sections),oe=!!n&&(!K||p.readingMode==="paragraph"&&Ci(n)),le=!k&&(K||!!n),H=k||!le?"entries":y;let de=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(i||o)&&t.jsxs("p",{className:"bim-rd-kicker",children:[i,i&&o&&t.jsx("span",{className:"bim-rd-dot"}),o&&f(o)]}),t.jsx("h1",{className:"bim-rd-h1",children:f(e.title)}),P.length>0&&t.jsx("p",{className:"bim-rd-meta",children:P.map((te,ve)=>t.jsxs(g.Fragment,{children:[ve>0&&t.jsx("span",{className:"bim-rd-dot"}),te]},ve))}),le&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":u("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":H==="text",onClick:()=>w("text"),children:u("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":H==="entries",onClick:()=>w("entries"),children:u("collated.viewEntries")})]})]}),H==="text"&&t.jsx("article",{className:"bim-rd-prose",children:oe?t.jsx(Mo,{text:n,mode:p.readingMode,bookMarking:$,quoteStyle:p.quoteStyle,renderText:C,dropTitle:e.title}):t.jsx(Mf,{sections:e.sections,onNavigate:l,inline:S,workLinks:p.workLinks})}),H==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:k?t.jsx(Lf,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[E.some(te=>["书","诗","考证"].includes(vt(te.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:u("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:u("collated.rowHeadTitle")}),t.jsx("span",{children:u("collated.rowHeadWork")})]}),E.map((te,ve)=>{const fe=vt(te.type);return fe==="书"||fe==="诗"||fe==="考证"?(de+=1,t.jsx(zf,{domId:`rd-e-${e.sections.indexOf(te)}`,section:te,onNavigate:p.workLinks?l:void 0,highlightQuery:j,no:de,showUnlinked:p.workLinks&&!!l},ve)):fe==="类"?t.jsx(Nf,{section:te,highlightQuery:j},ve):t.jsx(If,{section:te,highlightQuery:j},ve)}),E.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:u("collated.noMatch")})]})})]})}function Bf(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=ln(),h=g.useRef(new Map),[m,u]=g.useState({}),[f,x]=g.useState({}),v=g.useCallback((_,y)=>{const w=y==null?void 0:y.title;w&&x(j=>j[_]===w?j:{...j,[_]:w})},[]);g.useEffect(()=>{s&&a&&(h.current.set(s,{juan:a,rawText:l}),v(s,a))},[s,a,l,v]),g.useEffect(()=>{h.current.clear(),u({}),x({})},[n]);const b=g.useCallback((_,y)=>{let w=0;if(_.juan)for(const j of _.juan.sections)Oo(j,y,c,p)&&w++;return w===0&&_.rawText&&wf(_.rawText,y,p)&&(w=1),w},[c,p]);return g.useEffect(()=>{const _=d.trim();if(!_){u({});return}if(!i||o.length===0)return;let y=!1;const w={},j=[];for(const E of o){const N=h.current.get(E);N?w[E]=b(N,_):(w[E]="loading",j.push(E))}u(w);const k=8;let C=0;const $=async()=>{for(;C<j.length;){if(y)return;const E=C++,N=j[E];try{const z=await i(N),O=z.juan;if(h.current.set(N,z),v(N,O),y)return;u(F=>({...F,[N]:b(z,_)}))}catch{if(y)return;u(z=>({...z,[N]:0}))}}},S=Array.from({length:Math.min(k,j.length)},()=>$());return Promise.all(S),()=>{y=!0}},[d,n,i,o.join(","),b,p,v]),{matchStates:m,titles:f}}function Of({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=ne(),l=e.sections.map((h,m)=>({s:h,i:m,t:vt(h.type)})).filter(h=>h.t==="书"||h.t==="诗");if(l.length===0)return null;const d=l.filter(h=>!!h.s.work_id).length,c=l.every(h=>h.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=h=>{const m=()=>{var u,f;return(f=(u=document.getElementById(`rd-e-${h}`))==null?void 0:u.scrollIntoView)==null?void 0:f.call(u,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(m,0):m()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:h,i:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:u=>{u.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${h.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:Vi(a(h.book_title||h.title),{t:s})})]})},m))})]})]})}const Wf=`
1324
1327
  attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
1325
1328
  attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
1326
1329
 
@@ -1338,7 +1341,7 @@ ${ug}`;function Bn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{clas
1338
1341
  // 纹理坐标归一化 [0, 1]
1339
1342
  v_texCoord = a_texCoord / u_imgResolution;
1340
1343
  }
1341
- `,Df=`
1344
+ `,Ff=`
1342
1345
  precision mediump float;
1343
1346
  uniform sampler2D u_image;
1344
1347
  uniform float u_alpha;
@@ -1348,7 +1351,7 @@ ${ug}`;function Bn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{clas
1348
1351
  vec4 tex = texture2D(u_image, v_texCoord);
1349
1352
  gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
1350
1353
  }
1351
- `;function _a(e,n,i){const o=e.createShader(n);return o?(e.shaderSource(o,i),e.compileShader(o),e.getShaderParameter(o,e.COMPILE_STATUS)?o:(console.error("Shader compile error:",e.getShaderInfoLog(o)),e.deleteShader(o),null)):null}class Ur{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=_a(i,i.VERTEX_SHADER,Hf),s=_a(i,i.FRAGMENT_SHADER,Df);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,n,i),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,i,o),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],h=[],m=8;for(const u of l){const f=u.colOffsetX||0,x=u.colOffsetY||0,{srcQuad:v,dstRect:b}=u.strip,[$,y,w,k]=b,j=f+$,C=x+y,[_,S,R,N]=v;for(let z=0;z<m;z++){const M=z/m,F=(z+1)/m,L=C+k*M,E=C+k*F,P=[_[0]+(N[0]-_[0])*M,_[1]+(N[1]-_[1])*M],Z=[_[0]+(N[0]-_[0])*F,_[1]+(N[1]-_[1])*F],oe=[S[0]+(R[0]-S[0])*M,S[1]+(R[1]-S[1])*M],ae=[S[0]+(R[0]-S[0])*F,S[1]+(R[1]-S[1])*F],H=[j,L],ce=[j+w,L],V=[j,E],ne=[j+w,E];p.push(H[0],H[1],ce[0],ce[1],V[0],V[1]),h.push(P[0],P[1],oe[0],oe[1],Z[0],Z[1]),p.push(ce[0],ce[1],ne[0],ne[1],V[0],V[1]),h.push(oe[0],oe[1],ae[0],ae[1],Z[0],Z[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW),c.enableVertexAttribArray(this.aPositionLoc),c.vertexAttribPointer(this.aPositionLoc,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.texCoordBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(h),c.STATIC_DRAW),c.enableVertexAttribArray(this.aTexCoordLoc),c.vertexAttribPointer(this.aTexCoordLoc,2,c.FLOAT,!1,0,0),c.bindTexture(c.TEXTURE_2D,n),c.drawArrays(c.TRIANGLES,0,p.length/2)}deleteTexture(n){n&&this.gl.deleteTexture(n)}destroy(){const n=this.gl;n.deleteProgram(this.program),n.deleteBuffer(this.positionBuffer),n.deleteBuffer(this.texCoordBuffer)}}function Uf(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(u=>{var f;return(((f=u.strips)==null?void 0:f.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const u of e.columns)for(const f of u.chars){const[x,v,b,$]=f.bbox_col;![x,v,b,$].every(Number.isFinite)||!(b>x)||!($>v)||(o=Math.min(o,u.offset_x+x),s=Math.min(s,v),a=Math.max(a,u.offset_x+b),l=Math.max(l,$))}if(!(a>o)||!(l>s))return null;const d=Math.min(n,i)*.03,c=Math.min(n,Math.max(0,o-d)),p=Math.min(i,Math.max(0,s-d)),h=Math.min(n,Math.max(0,a+d))-c,m=Math.min(i,Math.max(0,l+d))-p;return!(h>0)||!(m>0)||h>=n*.98&&m>=i*.98?null:{x:c,y:p,w:h,h:m}}const Vt=new Map,Vf=24;function Vr(e){let n=Vt.get(e);if(n)return Vt.delete(e),Vt.set(e,n),n;for(n=new Promise(i=>{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{(o.decode?o.decode().catch(()=>{}):Promise.resolve()).then(()=>i(o))},o.onerror=()=>{Vt.delete(e),i(null)},o.src=e}),Vt.set(e,n);Vt.size>Vf;)Vt.delete(Vt.keys().next().value);return n}const Ho=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),h=g.useRef(null),m=g.useRef(null),u=g.useRef(null),[f,x]=g.useState(0),[v,b]=g.useState(0),$=g.useRef(""),y=g.useMemo(()=>Math.max(...n.columns.map(L=>L.warped_h),2440),[n]),w=n.total_warped_w,k=n.banxin,j=g.useMemo(()=>{var H;if(!s)return{top:0,bottom:0,left:0,right:0};const[L,E]=n.image_size||[2386,3082];let P=1/0,Z=-1/0,oe=1/0,ae=-1/0;for(const ce of n.columns)for(const V of ce.strips||[])for(const ne of V.srcQuad)ne[0]<P&&(P=ne[0]),ne[0]>Z&&(Z=ne[0]),ne[1]<oe&&(oe=ne[1]),ne[1]>ae&&(ae=ne[1]);if((H=n.banxin)!=null&&H.current_page_strips)for(const ce of n.banxin.current_page_strips)for(const V of ce.srcQuad)V[0]<P&&(P=V[0]),V[0]>Z&&(Z=V[0]),V[1]<oe&&(oe=V[1]),V[1]>ae&&(ae=V[1]);return isFinite(P)||(P=0),isFinite(Z)||(Z=L),isFinite(oe)||(oe=0),isFinite(ae)||(ae=E),{top:Math.max(0,Math.round(oe)),bottom:Math.max(0,Math.round(E-ae)),left:Math.max(0,Math.round(P)),right:Math.max(0,Math.round(L-Z)),rawMinX:P,rawMaxX:Z,rawMinY:oe,rawMaxY:ae,imgW:L,imgH:E}},[n,s]),C=g.useMemo(()=>s?null:Uf(n),[n,s]),_=w+(k?k.total_w:0),S=C?C.w:_+j.left+j.right,R=C?C.h:y+j.top+j.bottom,N=g.useCallback(()=>{const L=c.current;if(!(!L||!d.current)&&!(e&&$.current!==e)){if(L.clear(S,R),s&&j.rawMinX!==void 0&&m.current&&p.current){const{rawMinX:E,rawMaxX:P,rawMinY:Z,rawMaxY:oe,imgW:ae,imgH:H,top:ce,bottom:V,left:ne,right:je}=j,ge=[];ne>0&&ge.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[E,0],[E,H],[0,H]],dstRect:[0,0,ne,R]}}),ce>0&&ge.push({colOffsetX:ne,colOffsetY:0,strip:{srcQuad:[[E,0],[P,0],[P,Z],[E,Z]],dstRect:[0,0,_,ce]}}),V>0&&ge.push({colOffsetX:ne,colOffsetY:ce+y,strip:{srcQuad:[[E,oe],[P,oe],[P,H],[E,H]],dstRect:[0,0,_,V]}}),je>0&&ge.push({colOffsetX:ne+_,colOffsetY:0,strip:{srcQuad:[[P,0],[ae,0],[ae,H],[P,H]],dstRect:[0,0,je,R]}}),L.renderStripsWithTexture(m.current,S,R,n.image_size[0],n.image_size[1],ge,1)}if(m.current&&p.current){const E=n.columns.flatMap(P=>(P.strips||[]).map(Z=>({colOffsetX:j.left+P.offset_x,colOffsetY:j.top,strip:Z})));if(E.length>0?L.renderStripsWithTexture(m.current,S,R,n.image_size[0],n.image_size[1],E,1):L.renderStripsWithTexture(m.current,S,R,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:C?[[C.x,C.y],[C.x+C.w,C.y],[C.x+C.w,C.y+C.h],[C.x,C.y+C.h]]:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,S,R]}}],1),k&&k.current_page_strips.length>0){const P=k.current_page_strips.map(Z=>({colOffsetX:j.left+w,colOffsetY:j.top,strip:Z}));L.renderStripsWithTexture(m.current,S,R,n.image_size[0],n.image_size[1],P,1)}}if(k&&u.current&&h.current&&k.mate_page_strips.length>0){const E=k.mate_page_strips.map(P=>({colOffsetX:j.left+w+k.half_w,colOffsetY:j.top,strip:P}));L.renderStripsWithTexture(u.current,S,R,k.mate_img_size[0],k.mate_img_size[1],E,.65)}}},[e,n,k,S,R,w,y,_,j,s,C]),z=g.useRef(N);z.current=N,g.useEffect(()=>{const L=d.current;if(!L)return;const E=oe=>{m.current=p.current?oe.createTexture(p.current):null,u.current=h.current?oe.createTexture(h.current):null,z.current()};try{const oe=new Ur(L);c.current=oe,E(oe)}catch(oe){console.error("Failed to init WebGL renderer:",oe)}const P=oe=>{oe.preventDefault(),console.warn("WebGL context lost")},Z=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new Ur(d.current),E(c.current))};return L.addEventListener("webglcontextlost",P,!1),L.addEventListener("webglcontextrestored",Z,!1),()=>{L.removeEventListener("webglcontextlost",P),L.removeEventListener("webglcontextrestored",Z),c.current&&(c.current.deleteTexture(m.current),c.current.deleteTexture(u.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let L=!0;return Vr(e).then(E=>{if(!L||!E)return;p.current=E,$.current=e;const P=c.current;P&&(P.deleteTexture(m.current),m.current=P.createTexture(E)),x(Z=>Z+1)}),()=>{L=!1}},[e]);const M=k==null?void 0:k.mate_image_url;g.useEffect(()=>{if(!M)return;let L=!0;return Vr(M).then(E=>{if(!L||!E)return;h.current=E;const P=c.current;P&&(P.deleteTexture(u.current),u.current=P.createTexture(E)),b(Z=>Z+1)}),()=>{L=!1}},[M]),g.useEffect(()=>{N()},[N,f,v]);const F=g.useMemo(()=>{const L=[];for(const E of n.columns)for(const P of E.chars){const[Z,oe,ae,H]=P.bbox_col;L.push({id:P.id,char:P.char,x:j.left+E.offset_x+Z-((C==null?void 0:C.x)??0),y:j.top+oe-((C==null?void 0:C.y)??0),w:Math.max(ae-Z,1),h:Math.max(H-oe,1)})}return L},[n,j,C]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${S} / ${R}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:S,height:R,style:{width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${S} ${R}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[F.map(L=>{const E=i.has(L.id),P=o===L.id;return t.jsx("rect",{"data-selected":E?"true":void 0,x:L.x,y:L.y,width:L.w,height:L.h,fill:E?r("warp-sel-bg"):P?r("warp-hover-bg"):"transparent",stroke:E?r("warp-sel-stroke"):P?r("warp-hover-stroke"):"transparent",strokeWidth:E?3.5:P?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(L.id),onMouseEnter:()=>l==null?void 0:l(L.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:L.char})},L.id)}),k&&t.jsxs("g",{children:[t.jsx("line",{x1:j.left+w,y1:j.top,x2:j.left+w,y2:j.top+y,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:j.left+w+k.half_w,y1:j.top,x2:j.left+w+k.half_w,y2:j.top+y,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:j.left+_,y1:j.top,x2:j.left+_,y2:j.top+y,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},Do=`
1354
+ `;function $a(e,n,i){const o=e.createShader(n);return o?(e.shaderSource(o,i),e.compileShader(o),e.getShaderParameter(o,e.COMPILE_STATUS)?o:(console.error("Shader compile error:",e.getShaderInfoLog(o)),e.deleteShader(o),null)):null}class Gr{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=$a(i,i.VERTEX_SHADER,Wf),s=$a(i,i.FRAGMENT_SHADER,Ff);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,n,i),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,i,o),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],h=[],m=8;for(const u of l){const f=u.colOffsetX||0,x=u.colOffsetY||0,{srcQuad:v,dstRect:b}=u.strip,[_,y,w,j]=b,k=f+_,C=x+y,[$,S,E,N]=v;for(let z=0;z<m;z++){const O=z/m,F=(z+1)/m,A=C+j*O,I=C+j*F,P=[$[0]+(N[0]-$[0])*O,$[1]+(N[1]-$[1])*O],K=[$[0]+(N[0]-$[0])*F,$[1]+(N[1]-$[1])*F],oe=[S[0]+(E[0]-S[0])*O,S[1]+(E[1]-S[1])*O],le=[S[0]+(E[0]-S[0])*F,S[1]+(E[1]-S[1])*F],H=[k,A],de=[k+w,A],U=[k,I],te=[k+w,I];p.push(H[0],H[1],de[0],de[1],U[0],U[1]),h.push(P[0],P[1],oe[0],oe[1],K[0],K[1]),p.push(de[0],de[1],te[0],te[1],U[0],U[1]),h.push(oe[0],oe[1],le[0],le[1],K[0],K[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW),c.enableVertexAttribArray(this.aPositionLoc),c.vertexAttribPointer(this.aPositionLoc,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.texCoordBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(h),c.STATIC_DRAW),c.enableVertexAttribArray(this.aTexCoordLoc),c.vertexAttribPointer(this.aTexCoordLoc,2,c.FLOAT,!1,0,0),c.bindTexture(c.TEXTURE_2D,n),c.drawArrays(c.TRIANGLES,0,p.length/2)}deleteTexture(n){n&&this.gl.deleteTexture(n)}destroy(){const n=this.gl;n.deleteProgram(this.program),n.deleteBuffer(this.positionBuffer),n.deleteBuffer(this.texCoordBuffer)}}function Hf(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(u=>{var f;return(((f=u.strips)==null?void 0:f.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const u of e.columns)for(const f of u.chars){const[x,v,b,_]=f.bbox_col;![x,v,b,_].every(Number.isFinite)||!(b>x)||!(_>v)||(o=Math.min(o,u.offset_x+x),s=Math.min(s,v),a=Math.max(a,u.offset_x+b),l=Math.max(l,_))}if(!(a>o)||!(l>s))return null;const d=Math.min(n,i)*.03,c=Math.min(n,Math.max(0,o-d)),p=Math.min(i,Math.max(0,s-d)),h=Math.min(n,Math.max(0,a+d))-c,m=Math.min(i,Math.max(0,l+d))-p;return!(h>0)||!(m>0)||h>=n*.98&&m>=i*.98?null:{x:c,y:p,w:h,h:m}}const Vt=new Map,Df=24;function Yr(e){let n=Vt.get(e);if(n)return Vt.delete(e),Vt.set(e,n),n;for(n=new Promise(i=>{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{(o.decode?o.decode().catch(()=>{}):Promise.resolve()).then(()=>i(o))},o.onerror=()=>{Vt.delete(e),i(null)},o.src=e}),Vt.set(e,n);Vt.size>Df;)Vt.delete(Vt.keys().next().value);return n}const Uo=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),h=g.useRef(null),m=g.useRef(null),u=g.useRef(null),[f,x]=g.useState(0),[v,b]=g.useState(0),_=g.useRef(""),y=g.useMemo(()=>Math.max(...n.columns.map(A=>A.warped_h),2440),[n]),w=n.total_warped_w,j=n.banxin,k=g.useMemo(()=>{var H;if(!s)return{top:0,bottom:0,left:0,right:0};const[A,I]=n.image_size||[2386,3082];let P=1/0,K=-1/0,oe=1/0,le=-1/0;for(const de of n.columns)for(const U of de.strips||[])for(const te of U.srcQuad)te[0]<P&&(P=te[0]),te[0]>K&&(K=te[0]),te[1]<oe&&(oe=te[1]),te[1]>le&&(le=te[1]);if((H=n.banxin)!=null&&H.current_page_strips)for(const de of n.banxin.current_page_strips)for(const U of de.srcQuad)U[0]<P&&(P=U[0]),U[0]>K&&(K=U[0]),U[1]<oe&&(oe=U[1]),U[1]>le&&(le=U[1]);return isFinite(P)||(P=0),isFinite(K)||(K=A),isFinite(oe)||(oe=0),isFinite(le)||(le=I),{top:Math.max(0,Math.round(oe)),bottom:Math.max(0,Math.round(I-le)),left:Math.max(0,Math.round(P)),right:Math.max(0,Math.round(A-K)),rawMinX:P,rawMaxX:K,rawMinY:oe,rawMaxY:le,imgW:A,imgH:I}},[n,s]),C=g.useMemo(()=>s?null:Hf(n),[n,s]),$=w+(j?j.total_w:0),S=C?C.w:$+k.left+k.right,E=C?C.h:y+k.top+k.bottom,N=g.useCallback(()=>{const A=c.current;if(!(!A||!d.current)&&!(e&&_.current!==e)){if(A.clear(S,E),s&&k.rawMinX!==void 0&&m.current&&p.current){const{rawMinX:I,rawMaxX:P,rawMinY:K,rawMaxY:oe,imgW:le,imgH:H,top:de,bottom:U,left:te,right:ve}=k,fe=[];te>0&&fe.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[I,0],[I,H],[0,H]],dstRect:[0,0,te,E]}}),de>0&&fe.push({colOffsetX:te,colOffsetY:0,strip:{srcQuad:[[I,0],[P,0],[P,K],[I,K]],dstRect:[0,0,$,de]}}),U>0&&fe.push({colOffsetX:te,colOffsetY:de+y,strip:{srcQuad:[[I,oe],[P,oe],[P,H],[I,H]],dstRect:[0,0,$,U]}}),ve>0&&fe.push({colOffsetX:te+$,colOffsetY:0,strip:{srcQuad:[[P,0],[le,0],[le,H],[P,H]],dstRect:[0,0,ve,E]}}),A.renderStripsWithTexture(m.current,S,E,n.image_size[0],n.image_size[1],fe,1)}if(m.current&&p.current){const I=n.columns.flatMap(P=>(P.strips||[]).map(K=>({colOffsetX:k.left+P.offset_x,colOffsetY:k.top,strip:K})));if(I.length>0?A.renderStripsWithTexture(m.current,S,E,n.image_size[0],n.image_size[1],I,1):A.renderStripsWithTexture(m.current,S,E,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:C?[[C.x,C.y],[C.x+C.w,C.y],[C.x+C.w,C.y+C.h],[C.x,C.y+C.h]]:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,S,E]}}],1),j&&j.current_page_strips.length>0){const P=j.current_page_strips.map(K=>({colOffsetX:k.left+w,colOffsetY:k.top,strip:K}));A.renderStripsWithTexture(m.current,S,E,n.image_size[0],n.image_size[1],P,1)}}if(j&&u.current&&h.current&&j.mate_page_strips.length>0){const I=j.mate_page_strips.map(P=>({colOffsetX:k.left+w+j.half_w,colOffsetY:k.top,strip:P}));A.renderStripsWithTexture(u.current,S,E,j.mate_img_size[0],j.mate_img_size[1],I,.65)}}},[e,n,j,S,E,w,y,$,k,s,C]),z=g.useRef(N);z.current=N,g.useEffect(()=>{const A=d.current;if(!A)return;const I=oe=>{m.current=p.current?oe.createTexture(p.current):null,u.current=h.current?oe.createTexture(h.current):null,z.current()};try{const oe=new Gr(A);c.current=oe,I(oe)}catch(oe){console.error("Failed to init WebGL renderer:",oe)}const P=oe=>{oe.preventDefault(),console.warn("WebGL context lost")},K=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new Gr(d.current),I(c.current))};return A.addEventListener("webglcontextlost",P,!1),A.addEventListener("webglcontextrestored",K,!1),()=>{A.removeEventListener("webglcontextlost",P),A.removeEventListener("webglcontextrestored",K),c.current&&(c.current.deleteTexture(m.current),c.current.deleteTexture(u.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let A=!0;return Yr(e).then(I=>{if(!A||!I)return;p.current=I,_.current=e;const P=c.current;P&&(P.deleteTexture(m.current),m.current=P.createTexture(I)),x(K=>K+1)}),()=>{A=!1}},[e]);const O=j==null?void 0:j.mate_image_url;g.useEffect(()=>{if(!O)return;let A=!0;return Yr(O).then(I=>{if(!A||!I)return;h.current=I;const P=c.current;P&&(P.deleteTexture(u.current),u.current=P.createTexture(I)),b(K=>K+1)}),()=>{A=!1}},[O]),g.useEffect(()=>{N()},[N,f,v]);const F=g.useMemo(()=>{const A=[];for(const I of n.columns)for(const P of I.chars){const[K,oe,le,H]=P.bbox_col;A.push({id:P.id,char:P.char,x:k.left+I.offset_x+K-((C==null?void 0:C.x)??0),y:k.top+oe-((C==null?void 0:C.y)??0),w:Math.max(le-K,1),h:Math.max(H-oe,1)})}return A},[n,k,C]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${S} / ${E}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:S,height:E,style:{width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${S} ${E}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[F.map(A=>{const I=i.has(A.id),P=o===A.id;return t.jsx("rect",{"data-selected":I?"true":void 0,x:A.x,y:A.y,width:A.w,height:A.h,fill:I?r("warp-sel-bg"):P?r("warp-hover-bg"):"transparent",stroke:I?r("warp-sel-stroke"):P?r("warp-hover-stroke"):"transparent",strokeWidth:I?3.5:P?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(A.id),onMouseEnter:()=>l==null?void 0:l(A.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:A.char})},A.id)}),j&&t.jsxs("g",{children:[t.jsx("line",{x1:k.left+w,y1:k.top,x2:k.left+w,y2:k.top+y,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:k.left+w+j.half_w,y1:k.top,x2:k.left+w+j.half_w,y2:k.top+y,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:k.left+$,y1:k.top,x2:k.left+$,y2:k.top+y,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},Vo=`
1352
1355
  .bim-et-w { position: relative; display: inline; }
1353
1356
  .bim-et {
1354
1357
  color: inherit; text-decoration-line: underline;
@@ -1390,17 +1393,17 @@ a.bim-et:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 2px;
1390
1393
  .bim-et-card { animation: bim-et-in 120ms ease-out; }
1391
1394
  @keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
1392
1395
  }
1393
- `,Gf=120;function ut(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function Yf(e,n=Gf){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 qf(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=ut(o.name);return s?[ut(o.dynasty)&&`〔${ut(o.dynasty)}〕`,s,ut(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function sd(e,n){const i=ut(n.type),o=ut(n.primary_name)??ut(n.title)??e,s=i==="entity"?[ut(n.dynasty),Kf(n),ut(n.native_place)].filter(Boolean).join(" · "):[qf(n),ut(n.edition),ut(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?ut(n.description.text):ut(n.description);return{id:ut(n.id)??e,type:i,title:o,meta:s||void 0,description:Yf(a)}}function ad(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 ld(e){return async n=>{const i=await e.getItem(n);if(i)return sd(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return ad(o)}return null}}const $a=new WeakMap;function Xf(e,n,i){let o=$a.get(e);o||(o=new Map,$a.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 cd=e=>`/item/${encodeURIComponent(e)}`,Ca={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},Zf=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Uo(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:ld(e)}:null,[n,e])}const Jf=e=>e,Qf=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=cd,onNavigate:d,renderText:c=Jf,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:m=!0,className:u})=>{const f=g.useMemo(()=>{const v=i==="plain"?td(e,n,o):n;return nd(e,v)},[e,n,i,o]),x=Uo(s,a);return t.jsxs("span",{className:u?`bim-et-root ${u}`:"bim-et-root",children:[m&&t.jsx("style",{children:Do}),f.map(v=>v.type==="text"?t.jsx(g.Fragment,{children:c(v.text)},`t${v.start}`):t.jsx(Vo,{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 Gt=null;const Vo=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,renderText:c,hoverDelayMs:p,closeDelayMs:h=280})=>{const m=g.useId(),[u,f]=g.useState(!1),[x,v]=g.useState(!1),b=g.useRef(null),$=g.useRef(null),y=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,w=e.kind==="work"&&!i,k=t.jsxs(t.Fragment,{children:[w&&t.jsx("span",{className:"bim-et-sr",children:"《"}),c(n),w&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),j=()=>{b.current&&(clearTimeout(b.current),b.current=null)},C=()=>{$.current&&(clearTimeout($.current),$.current=null)},_=g.useCallback(()=>{j(),C(),f(!1),v(!1),Gt===_&&(Gt=null)},[]);g.useEffect(()=>()=>{j(),C(),Gt===_&&(Gt=null)},[_]);const S=g.useCallback(()=>{Gt&&Gt!==_&&Gt(),Gt=_,f(!0)},[_]),R=g.useCallback(L=>{C(),v(!0),!u&&(j(),L<=0?S():b.current=setTimeout(S,L))},[u,S]),N=g.useCallback(()=>{j(),C(),$.current=setTimeout(_,h)},[_,h]),z=!!e.targetId,M=e.targetId,F={className:"bim-et-w","data-active":x?"":void 0,onMouseEnter:()=>R(p),onMouseLeave:N,onBlur:L=>{L.currentTarget.contains(L.relatedTarget)||_()},onKeyDown:L=>{L.key==="Escape"&&u&&(L.stopPropagation(),_())}};return!z||!M?t.jsxs("span",{...F,children:[t.jsx("span",{className:y,children:k}),u&&t.jsx(za,{id:m,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...F,children:[t.jsx("a",{className:y,href:a(M),"data-entity-id":M,"aria-describedby":u?m:void 0,onFocus:()=>R(0),onClick:l?L=>l(M,L):void 0,children:k}),u&&t.jsx(za,{id:m,entityId:M,span:e,loader:s,buildHref:a,onNavigate:d})]})},za=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a})=>{const{convert:l,t:d}=ie(),c=g.useRef(null),[p,h]=g.useState("start"),[m,u]=g.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!o||!n)return;let v=!1;return u({status:"loading"}),Xf(o.owner,o.load,n).then(b=>{v||u({status:"ready",summary:b})}).catch(()=>{v||u({status:"error"})}),()=>{v=!0}},[o,n]),Zf(()=>{const v=c.current;if(!v||typeof window>"u")return;const b=v.getBoundingClientRect(),$=document.documentElement.clientWidth||window.innerWidth;b.right>$-8&&p==="start"&&h("end")},[m,p]);const f=m.status==="ready"?m.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(Ca[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)}),m.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),m.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(Ca[i.kind])})})},ex=e=>`/item/${encodeURIComponent(e)}`;function tx(e){const n=e.filter(i=>i.kind==null||i.kind==="point");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function nx(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 Go=({pageData:e,pages:n,punctuations:i=rx,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:m,scrollToPage:u,scrollToAnchor:f,onVisibleHeadingChange:x,entities:v,entityTransport:b,loadEntitySummary:$,buildEntityHref:y,onEntityNavigate:w,pageBreaks:k=!0,pageIndicatorY:j,onPageIndicatorYChange:C,quoteStyle:_,bookTitleStyle:S,showWorks:R})=>{const N=g.useRef(null),z=g.useRef(0),M=g.useMemo(()=>{const Y=new Map;return p&&i.forEach((re,K)=>{const A=re.id?re:{...re,id:`${re.anchor}#${K}`},U=Y.get(A.anchor)||[];U.push(A),Y.set(A.anchor,U)}),Y},[i,p]),F=g.useMemo(()=>_===void 0&&S===void 0&&R===void 0?null:{quoteStyle:_??"original",hideBookBrackets:S==="wavy"||R===!1},[_,S,R]),L=S==="bracket",E=g.useMemo(()=>{var A;const Y=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],re=Y.filter(U=>U.columns.some(q=>q.chars.length>0)).map(U=>{const q=[...U.columns].sort((J,fe)=>J.col-fe.col),D=[];let de=[];const be=()=>{const J=sx(M.get(de[0].charData.id));D.push({id:`para-p${U.page}-${D.length}`,chars:de,...J?{heading:{level:J.mark.length,anchor:de[0].charData.id,...J.toc===!1?{toc:!1}:{}}}:{}}),de=[]};let ve=!1,Re=0;for(const J of q){if(J.chars.length===0){J.kind==="blank"&&Re++;continue}const fe=J.raised||J.lead_blank||Re?{raised:J.raised,leadBlank:J.lead_blank,blankBefore:Re}:void 0;Re=0;let W=!0;for(const se of J.chars){const X=M.get(se.id)||[],{before:pe,after:$e}=tx(X),Ae=X.some(Oe=>Oe.kind==="break"&&Oe.pos!=="before");X.some(Oe=>Oe.kind==="heading")&&(de.length>0?be():D.length===0&&(ve=!0)),de.push({charData:se,col:J.col,beforePuncts:pe,afterPuncts:$e,...W&&fe?{start:fe}:{}}),W=!1,Ae&&be()}}const O=de.length>0;return O&&be(),{page:U.page,paragraphs:D,endsOpen:O,...ve?{leadStarts:ve}:{},...U.label?{label:U.label}:{},...Re>0?{trailingBlank:Re}:{}}}),K=new Map;if(!k){const U=new Map;for(const be of Y)for(const ve of be.columns)ve.chars.length>0&&U.set(ve.lead_blank||0,(U.get(ve.lead_blank||0)||0)+1);let q=0,D=-1;for(const[be,ve]of U)(ve>D||ve===D&&be<q)&&(q=be,D=ve);let de=null;for(const be of re){const ve=be.paragraphs[0],Re=(A=ve==null?void 0:ve.chars[0])==null?void 0:A.start,O=!!be.leadStarts||!!Re&&!!(Re.raised||(Re.leadBlank||0)>q||Re.blankBefore),J=be.paragraphs.length===1&&!!be.trailingBlank;if(de&&ve&&!O&&!J){for(const fe of ve.chars)K.set(fe.charData.id,de.owner);de.para.chars=de.para.chars.concat(ve.chars),be.leadFirstId=ve.chars[0].charData.id,be.paragraphs=be.paragraphs.slice(1)}if(be.endsOpen&&!be.trailingBlank){const fe=be.paragraphs[be.paragraphs.length-1];fe&&(de={para:fe,owner:be.page})}else de=null}}return{pages:re,mergedOwner:K}},[n,e,M,k]),P=E.pages,Z=g.useMemo(()=>{const Y=[];for(const re of P)for(const K of re.paragraphs)for(const A of K.chars)Y.push(A.charData.id);return Y},[P]),oe=g.useMemo(()=>{const Y=new Map;if(!v||v.length===0)return Y;const re=new Map(Z.map((K,A)=>[K,A]));for(const K of v){if(!K.anchor)continue;const A=re.get(K.anchor.start),U=re.get(K.anchor.end);if(!(A===void 0||U===void 0||U<A))for(let q=A;q<=U;q++)Y.has(Z[q])||Y.set(Z[q],K)}return Y},[v,Z]),ae=Uo(b,$),H=oe.size>0,ce=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:w,onVisibleHeadingChange:x});ce.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:w,onVisibleHeadingChange:x};const V=g.useMemo(()=>({click:Y=>{var re,K;z.current=Date.now()+1200,(K=(re=ce.current).onCharClick)==null||K.call(re,Y)},enter:Y=>{var re,K;return(K=(re=ce.current).onCharHover)==null?void 0:K.call(re,Y)},leave:()=>{var Y,re;return(re=(Y=ce.current).onCharHover)==null?void 0:re.call(Y,null)},navigate:(Y,re)=>{var A,U;if(!(re.detail===0||re.ctrlKey||re.metaKey||re.shiftKey)){re.preventDefault();return}(U=(A=ce.current).onEntityNavigate)==null||U.call(A,Y,re)},detail:(Y,re)=>{var K,A;return(A=(K=ce.current).onEntityNavigate)==null?void 0:A.call(K,Y,re)}}),[]),ne=ox(o,E.mergedOwner),je=g.useRef(null);g.useEffect(()=>{var re,K;if((re=je.current)==null||re.classList.remove("is-hovered"),je.current=null,!s)return;const Y=(K=N.current)==null?void 0:K.querySelector(`span[data-char-id="${s}"]`);Y&&(Y.classList.add("is-hovered"),je.current=Y)},[s]),g.useEffect(()=>{let Y=null;const re=()=>{var se,X;Y=null;const A=window.getSelection(),U=N.current;if(!A||A.isCollapsed||A.rangeCount===0||!U)return;const q=A.getRangeAt(0),D=q.commonAncestorContainer,de=D.nodeType===3?D.parentElement:D;if(!de||!U.contains(de))return;const be=U.querySelectorAll("span[data-char-id]"),ve=pe=>pe.firstChild??pe;let Re=0,O=be.length;for(;Re<O;){const pe=Re+O>>1;q.comparePoint(ve(be[pe]),0)<0?Re=pe+1:O=pe}const J=Re;for(O=be.length;Re<O;){const pe=Re+O>>1;q.comparePoint(ve(be[pe]),0)<=0?Re=pe+1:O=pe}let fe=Re-1;if(fe>=J&&q.endOffset===0&&q.endContainer===ve(be[fe])&&fe--,fe<J)return;const W=[];for(let pe=J;pe<=fe;pe++)W.push(be[pe].getAttribute("data-char-id"));W.length>0&&(z.current=Date.now()+1200,(X=(se=ce.current).onSelectionChange)==null||X.call(se,W))},K=()=>{Y&&clearTimeout(Y),Y=setTimeout(re,120)};return document.addEventListener("selectionchange",K),()=>{document.removeEventListener("selectionchange",K),Y&&clearTimeout(Y)}},[]),g.useEffect(()=>{var Y;if(o.size===1){const re=Array.from(o)[0],K=(Y=N.current)==null?void 0:Y.querySelector(`span[data-char-id="${re}"]`);K&&K.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[o]);const ge=Y=>{var A;const re=N.current;if(!re)return null;const K=(A=P.find(U=>U.page===Y))==null?void 0:A.leadFirstId;return K?re.querySelector(`span[data-char-id="${K}"]`):re.querySelector(`[data-page-section="${Y}"]`)},Le=u==null?void 0:u.nonce;g.useEffect(()=>{if(!u)return;const Y=ge(u.page);Y&&(z.current=Date.now()+800,Y.scrollIntoView({behavior:"auto",block:"start"}))},[Le]);const B=g.useRef(null);g.useEffect(()=>{var U,q;if(!f||B.current===f.nonce)return;const Y=N.current,re=Y==null?void 0:Y.querySelector(`span[data-char-id="${lx(f.anchor)}"]`);if(!re)return;B.current=f.nonce;const K=re.closest(".guji-reflow-paragraph")??re;z.current=Date.now()+800,K.scrollIntoView({behavior:"auto",block:"start"});const A=parseInt(f.anchor.split(":")[0],10);isNaN(A)||(q=(U=ce.current).onVisiblePageChange)==null||q.call(U,A)},[f,P]);const me=!!h||!!x,ze=!!h&&typeof j=="number",[we,De]=g.useState(null),Pe=Gr(we??j??0),G=g.useRef(null);G.current=ze?Pe:null;const he=g.useRef(()=>{});return g.useEffect(()=>{var de;if(!me)return;const Y=[],re=[];for(const be of P){const ve=ge(be.page);ve&&(Y.push(ve),re.push(be.page))}if(Y.length===0)return;const K=Array.from(((de=N.current)==null?void 0:de.querySelectorAll('.guji-reflow-heading:not([data-heading-toc="0"])'))??[]);let A,U=0;const q=()=>{var O,J;if(U=0,Date.now()<z.current)return;if(K.length>0&&ce.current.onVisibleHeadingChange){const fe=G.current===null?120:G.current*window.innerHeight,W=K[0].getBoundingClientRect().top;if(!(K.length>1&&W===K[K.length-1].getBoundingClientRect().top)){let X=null;if(W<=fe){let pe=0,$e=K.length-1;for(;pe<$e;){const Ae=pe+$e+1>>1;K[Ae].getBoundingClientRect().top<=fe?pe=Ae:$e=Ae-1}X=ax(K[pe])}X!==A&&(A=X,ce.current.onVisibleHeadingChange(X))}}if(Y.length>1&&Y[0].getBoundingClientRect().top===Y[Y.length-1].getBoundingClientRect().top)return;const be=G.current===null?120:G.current*window.innerHeight;let ve=0,Re=Y.length-1;for(;ve<Re;){const fe=ve+Re+1>>1;Y[fe].getBoundingClientRect().top<=be?ve=fe:Re=fe-1}(J=(O=ce.current).onVisiblePageChange)==null||J.call(O,re[ve])},D=()=>{U||(U=requestAnimationFrame(q))};return he.current=()=>{U||(U=requestAnimationFrame(q))},window.addEventListener("scroll",D,{passive:!0}),q(),()=>{window.removeEventListener("scroll",D),U&&cancelAnimationFrame(U),he.current=()=>{}}},[me,P]),g.useEffect(()=>{ze&&he.current()},[ze,Pe]),t.jsxs("div",{ref:N,className:"guji-text-pane-content",children:[H&&t.jsx("style",{children:Do}),ze&&t.jsx(mx,{y:Pe,containerRef:N,onDrag:De,onCommit:Y=>{De(null),C==null||C(Y)}}),t.jsx("div",{className:"guji-text-reflow-view",children:P.map((Y,re)=>t.jsx(px,{pGroup:Y,first:re===0,pageBreaks:k,markOpts:F,plainBooks:L,selected:ne.get(Y.page)??ix,entityOfChar:oe,entityLoader:ae,convert:m,buildHref:y??ex,handlers:V},`page-sec-${Y.page}`))})]})},ix=new Set,rx=[];function ox(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 sx(e){return e==null?void 0:e.find(n=>n.kind==="heading"&&/^#{1,6}$/.test(n.mark))}function ax(e){return e.getAttribute("data-heading-anchor")}function lx(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function Na({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 cx(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))}function dx({heading:e,children:n}){if(!e)return t.jsx("p",{className:"guji-reflow-paragraph",children:n});const i=`h${Math.min(6,e.level+1)}`;return t.jsx(i,{className:`guji-reflow-paragraph guji-reflow-heading guji-reflow-h${e.level}`,"data-heading-anchor":e.anchor,"data-heading-level":e.level,"data-heading-toc":e.toc===!1?"0":void 0,children:n})}const px=g.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:m}){const u=g.useMemo(()=>{const b=new Map;if(!p)return b;for(const $ of n.paragraphs){const y=cx($.chars.map(w=>w.charData.norm??w.charData.char),p);$.chars.forEach((w,k)=>b.set(w.charData.id,y[k]))}return b},[n,p]),f=b=>u.get(b.id)??b.char,{t:x}=ie(),v=b=>{const $=s?Xc(b.mark,s):b.mark;return $?t.jsx("span",{className:"guji-text-punct","data-punct-id":b.id,children:$},b.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((b,$)=>t.jsxs(dx,{heading:b.heading,children:[nx(b.chars,d).map((y,w)=>{const k=y.chars.map(({charData:_,beforePuncts:S,afterPuncts:R,start:N},z)=>{const M=!!y.entity&&z===0,F=!!y.entity&&z===y.chars.length-1,L=M?[]:S,E=F?[]:R;return t.jsxs(g.Fragment,{children:[N&&N.blankBefore>0&&t.jsx(Na,{n:N.blankBefore}),L.map(v),t.jsx("span",{"data-char-id":_.id,onClick:()=>m.click(_.id),onMouseEnter:()=>m.enter(_.id),onMouseLeave:m.leave,className:`guji-text-char${l.has(_.id)?" is-selected":""}${_.sub?" is-sub":""}${_.lane==="solo"?" is-solo":""}${_.lacuna?" is-lacuna":""}${_.guess?" is-guess":""}${_.zi?" is-zi":""}${N!=null&&N.raised?" is-raised":""}`,"data-raised":(N==null?void 0:N.raised)||void 0,title:_.lacuna?x("detail.lacuna"):_.zi?x("detail.composedChar",{label:_.zi}):_.guess?x("reader.charGuess"):void 0,children:f(_)}),E.map(v)]},_.id)});if(!y.entity)return t.jsx(g.Fragment,{children:k},`r${w}`);const j=y.chars[0].beforePuncts.map(v),C=y.chars[y.chars.length-1].afterPuncts.map(v);return t.jsxs(g.Fragment,{children:[j,t.jsx(Vo,{span:y.entity,label:y.chars.map(_=>f(_.charData)).join(""),hasBrackets:!0,plain:a&&y.entity.kind==="work",loader:c,buildHref:h,onNavigate:m.navigate,onCardNavigate:m.detail,renderText:()=>k,hoverDelayMs:250}),C]},`${y.entity.key}@${w}`)}),$===n.paragraphs.length-1&&n.trailingBlank?t.jsx(Na,{n:n.trailingBlank}):null]},b.id))]})});function Gr(e){const[n,i]=Un,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const ux=.02,mi=16;function mx({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ie(),[a,l]=g.useState(0),d=g.useRef(!1),c=g.useRef(e);c.current=e;const p=g.useCallback(()=>{var f,x;const u=(x=((f=n.current)==null?void 0:f.querySelector(".guji-text-reflow-view"))??n.current)==null?void 0:x.getBoundingClientRect();l(Math.max(0,((u==null?void 0:u.left)??0)-mi-2))},[n]);g.useLayoutEffect(()=>(p(),window.addEventListener("resize",p),()=>window.removeEventListener("resize",p)),[p]);const h=m=>Gr(m/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(Un[0]*100),"aria-valuemax":Math.round(Un[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${mi/2}px)`,width:mi,height:mi,zIndex:20,cursor:"ns-resize",touchAction:"none",background:r("accent"),clipPath:"polygon(0 0, 100% 50%, 0 100%)",outline:"none"},onPointerDown:m=>{d.current=!0;try{m.currentTarget.setPointerCapture(m.pointerId)}catch{}m.preventDefault()},onPointerMove:m=>{if(!d.current)return;const u=h(m.clientY);c.current=u,i(u)},onPointerUp:m=>{if(d.current){d.current=!1;try{m.currentTarget.releasePointerCapture(m.pointerId)}catch{}o(h(m.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(c.current))},onKeyDown:m=>{const u=m.key==="ArrowUp"?-1:m.key==="ArrowDown"?1:0;u&&(m.preventDefault(),o(Gr(e+u*(m.shiftKey?5:1)*ux)))}})}const dd=1,pd=6,hi={s:1,x:0,y:0},ji=(e,n,i)=>Math.min(i,Math.max(n,e));function Yo(e,n,i){const o=ji(e.s,dd,pd);return{s:o,x:ji(e.x,n*(1-o),0),y:ji(e.y,i*(1-o),0)}}function yr(e,n,i,o,s,a){const l=ji(e.s*o,dd,pd),d=l/e.s;return Yo({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function hx(e,n,i,o,s){return Yo({s:e.s,x:e.x+n,y:e.y+i},o,s)}function gx(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const Ta=4,fx=g.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=g.useRef(null),[d,c]=g.useState(hi),p=g.useRef(d),h=g.useRef(i);h.current=i;const m=y=>{var k;const w=p.current;p.current=y,c(y),y.s!==w.s&&((k=h.current)==null||k.call(h,y.s))},u=()=>{var w;const y=(w=l.current)==null?void 0:w.getBoundingClientRect();return{w:(y==null?void 0:y.width)??0,h:(y==null?void 0:y.height)??0,left:(y==null?void 0:y.left)??0,top:(y==null?void 0:y.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(y){const{w,h:k}=u();m(yr(p.current,w/2,k/2,y,w,k))},reset(){m(hi)}})),g.useEffect(()=>{m(hi)},[o]),g.useEffect(()=>{const y=l.current;if(!y||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:k,h:j}=u(),C=Yo(p.current,k,j);(C.x!==p.current.x||C.y!==p.current.y)&&m(C)});return w.observe(y),()=>w.disconnect()},[]),g.useEffect(()=>{const y=l.current;if(!y)return;const w=k=>{const j=gx(k.deltaY,k.deltaMode,k.ctrlKey);if(p.current.s<=1&&j<1)return;k.preventDefault();const{w:C,h:_,left:S,top:R}=u();m(yr(p.current,k.clientX-S,k.clientY-R,j,C,_))};return y.addEventListener("wheel",w,{passive:!1}),()=>y.removeEventListener("wheel",w)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),v=y=>{if(y.pointerType==="mouse"&&y.button!==0)return;f.current.set(y.pointerId,{x:y.clientX,y:y.clientY});const w=x.current;if(w.swallowClick=!1,f.current.size===1&&(w.moved=0,w.dragging=!1),f.current.size===2){const[k,j]=[...f.current.values()];w.pinchDist=Math.hypot(k.x-j.x,k.y-j.y),w.moved=Ta+1}},b=y=>{var M;const w=f.current.get(y.pointerId);if(!w)return;const k={x:y.clientX,y:y.clientY};f.current.set(y.pointerId,k);const j=x.current,{w:C,h:_,left:S,top:R}=u();if(f.current.size>=2){const[F,L]=[...f.current.values()],E=Math.hypot(F.x-L.x,F.y-L.y);if(j.pinchDist>0&&E>0){const P=(F.x+L.x)/2-S,Z=(F.y+L.y)/2-R;m(yr(p.current,P,Z,E/j.pinchDist,C,_))}j.pinchDist=E,j.swallowClick=!0;return}const N=k.x-w.x,z=k.y-w.y;if(j.moved+=Math.abs(N)+Math.abs(z),!(j.moved<=Ta)){if(!j.dragging){j.dragging=!0;try{(M=l.current)==null||M.setPointerCapture(y.pointerId)}catch{}}j.swallowClick=!0,p.current.s>1&&m(hx(p.current,N,z,C,_))}},$=y=>{f.current.delete(y.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:b,onPointerUp:$,onPointerCancel:$,onClickCapture:y=>{x.current.swallowClick&&(x.current.swallowClick=!1,y.stopPropagation(),y.preventDefault())},onDoubleClick:()=>m(hi),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 ud(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(m=>{p===c.current&&a(m??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 xx(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?ed(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const bx=/^#{1,6}$/,Ia=e=>e.kind==null||e.kind==="point";function md(e,n){var d;if(!e||!n||n.length===0)return[];const i=new Map;let o=!1;for(const c of n){c.kind==="heading"&&(o=!0);const p=i.get(c.anchor);p?p.push(c):i.set(c.anchor,[c])}if(!o)return[];const s=[];let a=null;const l=()=>{a&&(a.fixed||(a.h.label=a.text.trim()),a.h.label&&s.push(a.h)),a=null};for(const c of e){const p=[...c.columns].sort((h,m)=>h.col-m.col);for(const h of p)for(const m of h.chars){const u=i.get(m.id)??[],f=u.find(x=>x.kind==="heading"&&x.pos==="before"&&bx.test(x.mark));if(f&&l(),f&&f.toc!==!1){const x=(d=f.label)==null?void 0:d.trim();a={h:{level:f.mark.length,label:x??"",anchor:m.id},text:"",fixed:!!x}}if(a&&!a.fixed){for(const x of u)Ia(x)&&x.pos==="before"&&(a.text+=x.mark);a.text+=m.char;for(const x of u)Ia(x)&&x.pos!=="before"&&(a.text+=x.mark)}u.some(x=>x.kind==="break"&&x.pos!=="before")&&l()}}return l(),s}function hd(e){if(!Array.isArray(e))return[];const n=[];for(const i of e){if(!i||typeof i!="object")continue;const{level:o,label:s,anchor:a}=i;typeof o!="number"||!Number.isInteger(o)||o<1||o>6||typeof s!="string"||!s.trim()||typeof a!="string"||!a||n.push({level:o,label:s.trim(),anchor:a})}return n}function Ko(e,n){return`${e}#${n}`}function gd(e){const n=e.indexOf("#");return n<=0||n===e.length-1?null:{chapter:e.slice(0,n),anchor:e.slice(n+1)}}function fd(e){const n=[],i=[];for(const o of e){const s={...o,children:[]};for(;i.length>0&&i[i.length-1].level>=o.level;)i.pop();i.length===0?n.push(s):i[i.length-1].children.push(s),i.push(s)}return n}const Ea={padding:24,color:r("desc-fg"),fontSize:14};function Ra({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 La=/^https?:\/\//i,yx=[];function jx(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&&La.test(i)?i:void 0,license:n(e.license),license_url:o&&La.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function vx(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 kx(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)||Array.isArray(n==null?void 0:n.heading_levels)&&n.heading_levels.length>0?"冊":_e.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function xd(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 bd(e,n,i){return n.map(o=>({key:Ko(e,o.anchor),label:i(o.label),inChapter:!0,...o.children.length>0?{selectable:!0,children:bd(e,o.children,i)}:{}}))}function wx(e,n,i,o,s,a=()=>[]){var h;const l=new Map(e.chapters.map(m=>[m.file,m])),d=m=>m==="loading"?"…":typeof m=="number"&&m>0?m:void 0,c=(m,u)=>{const f=l.get(m),x=f?a(f):[];return{key:m,label:u??(f?xd(f,i,o,s):m),hint:d(n[m]),disabled:n[m]===0,...x.length>0?{selectable:!0,children:bd(m,fd(x),o)}:{}}},p=(h=e.juan_groups)==null?void 0:h.filter(m=>{var u;return m.files.some(f=>l.has(f))||((u=m.children)==null?void 0:u.length)});if(p&&p.length>0){const m=(u,f)=>{var v;if(u.files.length===1&&!((v=u.children)!=null&&v.length))return c(u.files[0],o(u.label));const x=Cf(u,n);return{key:`group:${f}`,label:o(u.label),hint:x==="loading"?"…":typeof x=="number"&&x>0?`${x}`:rd(u),defaultExpanded:typeof x=="number"&&x>0,children:[...u.files.filter(b=>l.has(b)).map(b=>c(b)),...(u.children??[]).map((b,$)=>m(b,`${f}.${$}`))]}};return p.map((u,f)=>m(u,`${f}`))}return e.chapters.map(m=>c(m.file))}const qo=e=>{const n=sc();return t.jsx(Xu,{mode:n[0].scriptMode,children:t.jsx(Sx,{...e,prefsState:n})})},Sx=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,anchor:d,title:c,subtitle:p,resolveImages:h,renderImageOverlay:m,imagePanel:u,allowVertical:f,onReportError:x,revisedAt:v,backHref:b,backLabel:$,resolveWarpData:y,warpData:w,resolveEntities:k,onEntityNavigate:j,className:C,style:_})=>{var _s,$s,Cs;const{t:S,convert:R}=ie(),N=g.useMemo(()=>Zl(i),[i]),[z,M]=e,F=rt(),L=g.useRef(a);L.current=a;const[E,P]=g.useState(null),[Z,oe]=g.useState("loading");g.useEffect(()=>{let I=!1;return P(null),oe("loading"),N.getManifest(n).then(le=>{I||(le?(P(le),oe("ready")):oe("missing"))}).catch(()=>{I||oe("missing")}),()=>{I=!0}},[N,n]);const ae=o!==void 0,H=s!==void 0,[ce,V]=g.useState(null),[ne,je]=g.useState(null);g.useEffect(()=>{V(null),je(null)},[n]);const ge=_e.pickTextVersion(E,ae?o:ce),Le=((_s=E==null?void 0:E.versions.find(I=>I.key==="default"))==null?void 0:_s.key)??(($s=E==null?void 0:E.versions[0])==null?void 0:$s.key)??"default",B=(ge==null?void 0:ge.key)??null,me=H?s:ne,ze=g.useCallback((I,le,Te,Ue)=>{var Xe;(Xe=L.current)==null||Xe.call(L,{key:I,chapter:le,isDefault:I===Le,...Ue?{anchor:Ue}:{}},Te)},[Le]);g.useEffect(()=>{!E||!ae||o==null||E.versions.some(I=>I.key===o)||ze(Le,null,"auto")},[E,ae,o,Le,ze]);const we=g.useRef(new Map);g.useEffect(()=>{we.current.clear()},[N,n]);const De=g.useCallback(async I=>{const le=`${n}
1394
- ${I}`;if(we.current.has(le))return we.current.get(le)??null;const Te=await N.getIndex(n,I).catch(()=>null);return Te&&we.current.set(le,Te),Te},[N,n]),[Pe,G]=g.useState(null),[he,Y]=g.useState("loading"),re=B?`${n}
1395
- ${B}`:null,K=Pe&&Pe.owner===re?Pe.idx:null;g.useEffect(()=>{if(!B)return;let I=!1;const le=`${n}
1396
- ${B}`;return G(null),Y("loading"),De(B).then(Te=>{I||(Te&&Te.chapters.length>0?(G({owner:le,idx:Te}),Y("ready")):Y("failed"))}),()=>{I=!0}},[n,B,De]),g.useEffect(()=>{if(!K||!B||me!=null&&K.chapters.some(Te=>Te.file===me))return;const le=K.chapters[0].file;H||je(le),ze(B,le,"auto")},[K,B,me,H,ze]);const A=K?me!=null&&K.chapters.some(I=>I.file===me)?me:K.chapters[0].file:me,U=g.useMemo(()=>K&&A?K.chapters.find(I=>I.file===A)??null:null,[K,A]),q=g.useRef(0),D=g.useCallback(async I=>{if(!E||I===B||!E.versions.some(St=>St.key===I))return;const le=++q.current,Te=await De(I);if(le!==q.current)return;const Ue=U??(A?{file:A}:null),Xe=_e.matchChapterAcrossVersions(Ue,Te);ae||V(I),H||je(Xe),ze(I,Xe,"version")},[E,B,De,U,A,ae,H,ze]),[de,be]=g.useState(null),[ve,Re]=g.useState(null),O=g.useRef(0),J=g.useCallback((I,le)=>{be({chapter:I,anchor:le,nonce:++O.current}),Re({chapter:I,anchor:le})},[]),fe=g.useCallback(I=>{if(!B)return;const le=gd(I);if(le){J(le.chapter,le.anchor),H||je(le.chapter),ze(B,le.chapter,"chapter",le.anchor);return}H||je(I),ze(B,I,"chapter")},[B,H,ze,J]),W=g.useRef(null);g.useEffect(()=>{!d||!A||d===W.current||(W.current=d,J(A,d))},[d,A,J]),g.useEffect(()=>{d||(W.current=null)},[d]);const[se,X]=g.useState(null),pe=B&&U?`${n}
1396
+ `,Uf=120;function ut(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function Vf(e,n=Uf){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 Gf(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 Yf(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=ut(o.name);return s?[ut(o.dynasty)&&`〔${ut(o.dynasty)}〕`,s,ut(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function od(e,n){const i=ut(n.type),o=ut(n.primary_name)??ut(n.title)??e,s=i==="entity"?[ut(n.dynasty),Gf(n),ut(n.native_place)].filter(Boolean).join(" · "):[Yf(n),ut(n.edition),ut(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?ut(n.description.text):ut(n.description);return{id:ut(n.id)??e,type:i,title:o,meta:s||void 0,description:Vf(a)}}function sd(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 ad(e){return async n=>{const i=await e.getItem(n);if(i)return od(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return sd(o)}return null}}const Ca=new WeakMap;function Kf(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 ld=e=>`/item/${encodeURIComponent(e)}`,za={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},qf=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Go(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:ad(e)}:null,[n,e])}const Xf=e=>e,Zf=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=ld,onNavigate:d,renderText:c=Xf,hoverDelayMs:p=250,closeDelayMs:h,injectStyles:m=!0,className:u})=>{const f=g.useMemo(()=>{const v=i==="plain"?ed(e,n,o):n;return td(e,v)},[e,n,i,o]),x=Go(s,a);return t.jsxs("span",{className:u?`bim-et-root ${u}`:"bim-et-root",children:[m&&t.jsx("style",{children:Vo}),f.map(v=>v.type==="text"?t.jsx(g.Fragment,{children:c(v.text)},`t${v.start}`):t.jsx(Yo,{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 Gt=null;const Yo=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,cardNewTab:c,renderText:p,hoverDelayMs:h,closeDelayMs:m=280})=>{const u=g.useId(),[f,x]=g.useState(!1),[v,b]=g.useState(!1),_=g.useRef(null),y=g.useRef(null),w=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,j=e.kind==="work"&&!i,k=t.jsxs(t.Fragment,{children:[j&&t.jsx("span",{className:"bim-et-sr",children:"《"}),p(n),j&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),C=()=>{_.current&&(clearTimeout(_.current),_.current=null)},$=()=>{y.current&&(clearTimeout(y.current),y.current=null)},S=g.useCallback(()=>{C(),$(),x(!1),b(!1),Gt===S&&(Gt=null)},[]);g.useEffect(()=>()=>{C(),$(),Gt===S&&(Gt=null)},[S]);const E=g.useCallback(()=>{Gt&&Gt!==S&&Gt(),Gt=S,x(!0)},[S]),N=g.useCallback(I=>{$(),b(!0),!f&&(C(),I<=0?E():_.current=setTimeout(E,I))},[f,E]),z=g.useCallback(()=>{C(),$(),y.current=setTimeout(S,m)},[S,m]),O=!!e.targetId,F=e.targetId,A={className:"bim-et-w","data-active":v?"":void 0,onMouseEnter:()=>N(h),onMouseLeave:z,onBlur:I=>{I.currentTarget.contains(I.relatedTarget)||S()},onKeyDown:I=>{I.key==="Escape"&&f&&(I.stopPropagation(),S())}};return!O||!F?t.jsxs("span",{...A,children:[t.jsx("span",{className:w,children:k}),f&&t.jsx(Na,{id:u,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...A,children:[t.jsx("a",{className:w,href:a(F),"data-entity-id":F,"aria-describedby":f?u:void 0,onFocus:()=>N(0),onClick:l?I=>l(F,I):void 0,children:k}),f&&t.jsx(Na,{id:u,entityId:F,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c})]})},Na=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a,newTab:l})=>{const{convert:d,t:c}=ne(),p=g.useRef(null),[h,m]=g.useState("start"),[u,f]=g.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!o||!n)return;let b=!1;return f({status:"loading"}),Kf(o.owner,o.load,n).then(_=>{b||f({status:"ready",summary:_})}).catch(()=>{b||f({status:"error"})}),()=>{b=!0}},[o,n]),qf(()=>{const b=p.current;if(!b||typeof window>"u")return;const _=b.getBoundingClientRect(),y=document.documentElement.clientWidth||window.innerWidth;_.right>y-8&&h==="start"&&m("end")},[u,h]);const x=u.status==="ready"?u.summary:null,v=(x==null?void 0:x.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:p,id:e,role:"tooltip",className:"bim-et-card","data-align":h,children:[t.jsx("span",{className:"bim-et-card-k",children:d(za[i.kind])}),v&&t.jsx("span",{className:"bim-et-card-t",children:d(v)}),(x==null?void 0:x.meta)&&t.jsx("span",{className:"bim-et-card-m",children:d(x.meta)}),(x==null?void 0:x.description)&&t.jsx("span",{className:"bim-et-card-d",children:d(x.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:d("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:d("摘要載入失敗")}),x&&t.jsx("a",{className:"bim-et-card-a",href:s(x.id||n),...l?{target:"_blank",rel:"noopener"}:{},onClick:a?b=>a(x.id||n,b):void 0,children:c("reader.entityDetail")})]}):t.jsx("span",{ref:p,id:e,role:"tooltip",className:"bim-et-card","data-align":h,children:t.jsx("span",{className:"bim-et-card-k",children:d(za[i.kind])})})},Jf=e=>`/item/${encodeURIComponent(e)}`;function Qf(e){const n=e.filter(i=>i.kind==null||i.kind==="point");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function ex(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 Ko=({pageData:e,pages:n,punctuations:i=nx,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:h,convert:m,scrollToPage:u,scrollToAnchor:f,onVisibleHeadingChange:x,entities:v,entityTransport:b,loadEntitySummary:_,buildEntityHref:y,onEntityNavigate:w,pageBreaks:j=!0,pageIndicatorY:k,onPageIndicatorYChange:C,quoteStyle:$,bookTitleStyle:S,showWorks:E})=>{const N=g.useRef(null),z=g.useRef(0),O=g.useMemo(()=>{const q=new Map;return p&&i.forEach((se,Y)=>{const M=se.id?se:{...se,id:`${se.anchor}#${Y}`},X=q.get(M.anchor)||[];X.push(M),q.set(M.anchor,X)}),q},[i,p]),F=g.useMemo(()=>$===void 0&&S===void 0&&E===void 0?null:{quoteStyle:$??"original",hideBookBrackets:S==="wavy"||E===!1},[$,S,E]),A=S==="bracket",I=g.useMemo(()=>{var ye;const q=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],se=new Map;for(const ue of q)for(const ge of ue.columns)ge.chars.length>0&&!ge.raised&&se.set(ge.lead_blank||0,(se.get(ge.lead_blank||0)||0)+1);let Y=0,M=-1;for(const[ue,ge]of se)(ge>M||ge===M&&ue<Y)&&(Y=ue,M=ge);const X=ue=>!!ue.raised||(ue.lead_blank||0)<Y,J=q.filter(ue=>ue.columns.some(ge=>ge.chars.length>0)).map(ue=>{const ge=[...ue.columns].sort((re,_e)=>re.col-_e.col),Ie=[];let L=[];const ie=()=>{const re=rx(O.get(L[0].charData.id));Ie.push({id:`para-p${ue.page}-${Ie.length}`,chars:L,...re?{heading:{level:re.mark.length,anchor:L[0].charData.id,...re.toc===!1?{toc:!1}:{}}}:{}}),L=[]};let je=!1,W=0,ae;for(const re of ge){if(re.chars.length===0){re.kind==="blank"&&W++;continue}const _e=re.raised||re.lead_blank||W?{raised:re.raised,leadBlank:re.lead_blank,blankBefore:W}:void 0;W=0,X(re)||(ae=re.lead_blank||0);let Le=!0;for(const He of re.chars){const qe=O.get(He.id)||[],{before:Xe,after:T}=Qf(qe),pe=qe.some(xe=>xe.kind==="break"&&xe.pos!=="before");qe.some(xe=>xe.kind==="heading")&&(L.length>0?ie():Ie.length===0&&(je=!0)),L.push({charData:He,col:re.col,beforePuncts:Xe,afterPuncts:T,...Le&&_e?{start:_e}:{}}),Le=!1,pe&&ie()}}const V=L.length>0;return V&&ie(),{page:ue.page,paragraphs:Ie,endsOpen:V,...ae!==void 0?{tailLead:ae}:{},...je?{leadStarts:je}:{},...ue.label?{label:ue.label}:{},...W>0?{trailingBlank:W}:{}}}),D=new Map;if(!j){let ue=null;for(const ge of J){const Ie=ge.paragraphs[0],L=(ye=Ie==null?void 0:Ie.chars[0])==null?void 0:ye.start,ie=(L==null?void 0:L.leadBlank)||0,je=!!L&&!L.raised&&ie>=Y&&ie>((ue==null?void 0:ue.tailLead)??Y),W=!!ge.leadStarts||!!(L!=null&&L.blankBefore)||je,ae=ge.paragraphs.length===1&&!!ge.trailingBlank;if(ue&&Ie&&!W&&!ae){for(const V of Ie.chars)D.set(V.charData.id,ue.owner);ue.para.chars=ue.para.chars.concat(Ie.chars),ge.leadFirstId=Ie.chars[0].charData.id,ge.paragraphs=ge.paragraphs.slice(1)}if(ge.endsOpen&&!ge.trailingBlank){const V=ge.paragraphs[ge.paragraphs.length-1];V?ue={para:V,owner:ge.page,tailLead:ge.tailLead??(ue==null?void 0:ue.tailLead)??Y}:ue&&ge.tailLead!==void 0&&(ue.tailLead=ge.tailLead)}else ue=null}}return{pages:J,mergedOwner:D}},[n,e,O,j]),P=I.pages,K=g.useMemo(()=>{const q=[];for(const se of P)for(const Y of se.paragraphs)for(const M of Y.chars)q.push(M.charData.id);return q},[P]),oe=g.useMemo(()=>{const q=new Map;if(!v||v.length===0)return q;const se=new Map(K.map((Y,M)=>[Y,M]));for(const Y of v){if(!Y.anchor)continue;const M=se.get(Y.anchor.start),X=se.get(Y.anchor.end);if(!(M===void 0||X===void 0||X<M))for(let J=M;J<=X;J++)q.has(K[J])||q.set(K[J],Y)}return q},[v,K]),le=Go(b,_),H=oe.size>0,de=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:w,onVisibleHeadingChange:x});de.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:h,onEntityNavigate:w,onVisibleHeadingChange:x};const U=g.useMemo(()=>({click:q=>{var se,Y;z.current=Date.now()+1200,(Y=(se=de.current).onCharClick)==null||Y.call(se,q)},enter:q=>{var se,Y;return(Y=(se=de.current).onCharHover)==null?void 0:Y.call(se,q)},leave:()=>{var q,se;return(se=(q=de.current).onCharHover)==null?void 0:se.call(q,null)},navigate:(q,se)=>{se.ctrlKey||se.metaKey||se.shiftKey||(se.preventDefault(),se.detail===0&&window.open(se.currentTarget.href,"_blank","noopener"))}}),[]),te=ix(o,I.mergedOwner),ve=g.useRef(null);g.useEffect(()=>{var se,Y;if((se=ve.current)==null||se.classList.remove("is-hovered"),ve.current=null,!s)return;const q=(Y=N.current)==null?void 0:Y.querySelector(`span[data-char-id="${s}"]`);q&&(q.classList.add("is-hovered"),ve.current=q)},[s]),g.useEffect(()=>{let q=null;const se=()=>{var ae,V;q=null;const M=window.getSelection(),X=N.current;if(!M||M.isCollapsed||M.rangeCount===0||!X)return;const J=M.getRangeAt(0),D=J.commonAncestorContainer,ye=D.nodeType===3?D.parentElement:D;if(!ye||!X.contains(ye))return;const ue=X.querySelectorAll("span[data-char-id]"),ge=re=>re.firstChild??re;let Ie=0,L=ue.length;for(;Ie<L;){const re=Ie+L>>1;J.comparePoint(ge(ue[re]),0)<0?Ie=re+1:L=re}const ie=Ie;for(L=ue.length;Ie<L;){const re=Ie+L>>1;J.comparePoint(ge(ue[re]),0)<=0?Ie=re+1:L=re}let je=Ie-1;if(je>=ie&&J.endOffset===0&&J.endContainer===ge(ue[je])&&je--,je<ie)return;const W=[];for(let re=ie;re<=je;re++)W.push(ue[re].getAttribute("data-char-id"));W.length>0&&(z.current=Date.now()+1200,(V=(ae=de.current).onSelectionChange)==null||V.call(ae,W))},Y=()=>{q&&clearTimeout(q),q=setTimeout(se,120)};return document.addEventListener("selectionchange",Y),()=>{document.removeEventListener("selectionchange",Y),q&&clearTimeout(q)}},[]),g.useEffect(()=>{var q;if(o.size===1){const se=Array.from(o)[0],Y=(q=N.current)==null?void 0:q.querySelector(`span[data-char-id="${se}"]`);Y&&Y.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[o]);const fe=q=>{var M;const se=N.current;if(!se)return null;const Y=(M=P.find(X=>X.page===q))==null?void 0:M.leadFirstId;return Y?se.querySelector(`span[data-char-id="${Y}"]`):se.querySelector(`[data-page-section="${q}"]`)},Ae=u==null?void 0:u.nonce;g.useEffect(()=>{if(!u)return;const q=fe(u.page);q&&(z.current=Date.now()+800,q.scrollIntoView({behavior:"auto",block:"start"}))},[Ae]);const B=g.useRef(null);g.useEffect(()=>{var X,J;if(!f||B.current===f.nonce)return;const q=N.current,se=q==null?void 0:q.querySelector(`span[data-char-id="${sx(f.anchor)}"]`);if(!se)return;B.current=f.nonce;const Y=se.closest(".guji-reflow-paragraph")??se;z.current=Date.now()+800,Y.scrollIntoView({behavior:"auto",block:"start"});const M=parseInt(f.anchor.split(":")[0],10);isNaN(M)||(J=(X=de.current).onVisiblePageChange)==null||J.call(X,M)},[f,P]);const me=!!h||!!x,ze=!!h&&typeof k=="number",[we,De]=g.useState(null),Pe=Kr(we??k??0),G=g.useRef(null);G.current=ze?Pe:null;const he=g.useRef(()=>{});return g.useEffect(()=>{var ye;if(!me)return;const q=[],se=[];for(const ue of P){const ge=fe(ue.page);ge&&(q.push(ge),se.push(ue.page))}if(q.length===0)return;const Y=Array.from(((ye=N.current)==null?void 0:ye.querySelectorAll('.guji-reflow-heading:not([data-heading-toc="0"])'))??[]);let M,X=0;const J=()=>{var L,ie;if(X=0,Date.now()<z.current)return;if(Y.length>0&&de.current.onVisibleHeadingChange){const je=G.current===null?120:G.current*window.innerHeight,W=Y[0].getBoundingClientRect().top;if(!(Y.length>1&&W===Y[Y.length-1].getBoundingClientRect().top)){let V=null;if(W<=je){let re=0,_e=Y.length-1;for(;re<_e;){const Le=re+_e+1>>1;Y[Le].getBoundingClientRect().top<=je?re=Le:_e=Le-1}V=ox(Y[re])}V!==M&&(M=V,de.current.onVisibleHeadingChange(V))}}if(q.length>1&&q[0].getBoundingClientRect().top===q[q.length-1].getBoundingClientRect().top)return;const ue=G.current===null?120:G.current*window.innerHeight;let ge=0,Ie=q.length-1;for(;ge<Ie;){const je=ge+Ie+1>>1;q[je].getBoundingClientRect().top<=ue?ge=je:Ie=je-1}(ie=(L=de.current).onVisiblePageChange)==null||ie.call(L,se[ge])},D=()=>{X||(X=requestAnimationFrame(J))};return he.current=()=>{X||(X=requestAnimationFrame(J))},window.addEventListener("scroll",D,{passive:!0}),J(),()=>{window.removeEventListener("scroll",D),X&&cancelAnimationFrame(X),he.current=()=>{}}},[me,P]),g.useEffect(()=>{ze&&he.current()},[ze,Pe]),t.jsxs("div",{ref:N,className:"guji-text-pane-content",children:[H&&t.jsx("style",{children:Vo}),ze&&t.jsx(ux,{y:Pe,containerRef:N,onDrag:De,onCommit:q=>{De(null),C==null||C(q)}}),t.jsx("div",{className:"guji-text-reflow-view",children:P.map((q,se)=>t.jsx(cx,{pGroup:q,first:se===0,pageBreaks:j,markOpts:F,plainBooks:A,selected:te.get(q.page)??tx,entityOfChar:oe,entityLoader:le,convert:m,buildHref:y??Jf,handlers:U},`page-sec-${q.page}`))})]})},tx=new Set,nx=[];function ix(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 rx(e){return e==null?void 0:e.find(n=>n.kind==="heading"&&/^#{1,6}$/.test(n.mark))}function ox(e){return e.getAttribute("data-heading-anchor")}function sx(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function Ta({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 ax(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))}function lx({heading:e,children:n}){if(!e)return t.jsx("p",{className:"guji-reflow-paragraph",children:n});const i=`h${Math.min(6,e.level+1)}`;return t.jsx(i,{className:`guji-reflow-paragraph guji-reflow-heading guji-reflow-h${e.level}`,"data-heading-anchor":e.anchor,"data-heading-level":e.level,"data-heading-toc":e.toc===!1?"0":void 0,children:n})}const cx=g.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:h,handlers:m}){const u=g.useMemo(()=>{const b=new Map;if(!p)return b;for(const _ of n.paragraphs){const y=ax(_.chars.map(w=>w.charData.norm??w.charData.char),p);_.chars.forEach((w,j)=>b.set(w.charData.id,y[j]))}return b},[n,p]),f=b=>u.get(b.id)??b.char,{t:x}=ne(),v=b=>{const _=s?qc(b.mark,s):b.mark;return _?t.jsx("span",{className:"guji-text-punct","data-punct-id":b.id,children:_},b.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((b,_)=>t.jsxs(lx,{heading:b.heading,children:[ex(b.chars,d).map((y,w)=>{const j=y.chars.map(({charData:$,beforePuncts:S,afterPuncts:E,start:N},z)=>{const O=!!y.entity&&z===0,F=!!y.entity&&z===y.chars.length-1,A=O?[]:S,I=F?[]:E;return t.jsxs(g.Fragment,{children:[N&&N.blankBefore>0&&t.jsx(Ta,{n:N.blankBefore}),A.map(v),t.jsx("span",{"data-char-id":$.id,onClick:()=>m.click($.id),onMouseEnter:()=>m.enter($.id),onMouseLeave:m.leave,className:`guji-text-char${l.has($.id)?" is-selected":""}${$.sub?" is-sub":""}${$.lane==="solo"?" is-solo":""}${$.lacuna?" is-lacuna":""}${$.guess?" is-guess":""}${$.zi?" is-zi":""}${N!=null&&N.raised?" is-raised":""}`,"data-raised":(N==null?void 0:N.raised)||void 0,title:$.lacuna?x("detail.lacuna"):$.zi?x("detail.composedChar",{label:$.zi}):$.guess?x("reader.charGuess"):void 0,children:f($)}),I.map(v)]},$.id)});if(!y.entity)return t.jsx(g.Fragment,{children:j},`r${w}`);const k=y.chars[0].beforePuncts.map(v),C=y.chars[y.chars.length-1].afterPuncts.map(v);return t.jsxs(g.Fragment,{children:[k,t.jsx(Yo,{span:y.entity,label:y.chars.map($=>f($.charData)).join(""),hasBrackets:!0,plain:a&&y.entity.kind==="work",loader:c,buildHref:h,onNavigate:m.navigate,cardNewTab:!0,renderText:()=>j,hoverDelayMs:250}),C]},`${y.entity.key}@${w}`)}),_===n.paragraphs.length-1&&n.trailingBlank?t.jsx(Ta,{n:n.trailingBlank}):null]},b.id))]})});function Kr(e){const[n,i]=Gn,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const dx=.02,un=16,px=4;function ux({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ne(),[a,l]=g.useState(0),d=g.useRef(!1),c=g.useRef(null),p=g.useRef(e);p.current=e;const h=g.useCallback(()=>{var v;const u=((v=c.current)==null?void 0:v.parentElement)??n.current,f=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=f==null?void 0:f.getBoundingClientRect();l(Math.max(0,((x==null?void 0:x.left)??0)-un-px))},[n]);g.useLayoutEffect(()=>{var v;h(),window.addEventListener("resize",h);const u=((v=c.current)==null?void 0:v.parentElement)??n.current,f=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=typeof ResizeObserver<"u"?new ResizeObserver(()=>h()):null;for(const b of[f,u==null?void 0:u.closest(".bim-rd-text"),u==null?void 0:u.closest(".bim-rd-body")])b&&(x==null||x.observe(b));return()=>{window.removeEventListener("resize",h),x==null||x.disconnect()}},[h,n]);const m=u=>Kr(u/Math.max(1,window.innerHeight));return t.jsx("div",{ref:c,role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(Gn[0]*100),"aria-valuemax":Math.round(Gn[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${un/2}px)`,width:un,height:un,zIndex:20,cursor:"ns-resize",touchAction:"none",display:"flex",alignItems:"center",justifyContent:"center",color:r("meta-fg")},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const f=m(u.clientY);p.current=f,i(f)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(m(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(p.current))},onKeyDown:u=>{const f=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;f&&(u.preventDefault(),o(Kr(e+f*(u.shiftKey?5:1)*dx)))},children:t.jsx("svg",{width:un,height:un,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M2 8h11M9 4l4 4-4 4"})})})}const cd=1,dd=6,gi={s:1,x:0,y:0},vi=(e,n,i)=>Math.min(i,Math.max(n,e));function qo(e,n,i){const o=vi(e.s,cd,dd);return{s:o,x:vi(e.x,n*(1-o),0),y:vi(e.y,i*(1-o),0)}}function vr(e,n,i,o,s,a){const l=vi(e.s*o,cd,dd),d=l/e.s;return qo({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function mx(e,n,i,o,s){return qo({s:e.s,x:e.x+n,y:e.y+i},o,s)}function hx(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const Ia=4,gx=g.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=g.useRef(null),[d,c]=g.useState(gi),p=g.useRef(d),h=g.useRef(i);h.current=i;const m=y=>{var j;const w=p.current;p.current=y,c(y),y.s!==w.s&&((j=h.current)==null||j.call(h,y.s))},u=()=>{var w;const y=(w=l.current)==null?void 0:w.getBoundingClientRect();return{w:(y==null?void 0:y.width)??0,h:(y==null?void 0:y.height)??0,left:(y==null?void 0:y.left)??0,top:(y==null?void 0:y.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(y){const{w,h:j}=u();m(vr(p.current,w/2,j/2,y,w,j))},reset(){m(gi)}})),g.useEffect(()=>{m(gi)},[o]),g.useEffect(()=>{const y=l.current;if(!y||typeof ResizeObserver>"u")return;const w=new ResizeObserver(()=>{const{w:j,h:k}=u(),C=qo(p.current,j,k);(C.x!==p.current.x||C.y!==p.current.y)&&m(C)});return w.observe(y),()=>w.disconnect()},[]),g.useEffect(()=>{const y=l.current;if(!y)return;const w=j=>{const k=hx(j.deltaY,j.deltaMode,j.ctrlKey);if(p.current.s<=1&&k<1)return;j.preventDefault();const{w:C,h:$,left:S,top:E}=u();m(vr(p.current,j.clientX-S,j.clientY-E,k,C,$))};return y.addEventListener("wheel",w,{passive:!1}),()=>y.removeEventListener("wheel",w)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),v=y=>{if(y.pointerType==="mouse"&&y.button!==0)return;f.current.set(y.pointerId,{x:y.clientX,y:y.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=Ia+1}},b=y=>{var O;const w=f.current.get(y.pointerId);if(!w)return;const j={x:y.clientX,y:y.clientY};f.current.set(y.pointerId,j);const k=x.current,{w:C,h:$,left:S,top:E}=u();if(f.current.size>=2){const[F,A]=[...f.current.values()],I=Math.hypot(F.x-A.x,F.y-A.y);if(k.pinchDist>0&&I>0){const P=(F.x+A.x)/2-S,K=(F.y+A.y)/2-E;m(vr(p.current,P,K,I/k.pinchDist,C,$))}k.pinchDist=I,k.swallowClick=!0;return}const N=j.x-w.x,z=j.y-w.y;if(k.moved+=Math.abs(N)+Math.abs(z),!(k.moved<=Ia)){if(!k.dragging){k.dragging=!0;try{(O=l.current)==null||O.setPointerCapture(y.pointerId)}catch{}}k.swallowClick=!0,p.current.s>1&&m(mx(p.current,N,z,C,$))}},_=y=>{f.current.delete(y.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:b,onPointerUp:_,onPointerCancel:_,onClickCapture:y=>{x.current.swallowClick&&(x.current.swallowClick=!1,y.stopPropagation(),y.preventDefault())},onDoubleClick:()=>m(gi),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 pd(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(m=>{p===c.current&&a(m??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 fx(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?Qc(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,i]),o}const xx=/^#{1,6}$/,bx=/^([^《》]*)《([^《》]+)》\s*(?:[〇零一二三四五六七八九十百千]+|不分|無|无)卷/;function yx(e){let n=e.trim();const i=bx.exec(n);return i&&(n=i[1]+i[2]),n.replace(/[《》〈〉]/g,"").trim()}const Ra=e=>e.kind==null||e.kind==="point";function ud(e,n){var d;if(!e||!n||n.length===0)return[];const i=new Map;let o=!1;for(const c of n){c.kind==="heading"&&(o=!0);const p=i.get(c.anchor);p?p.push(c):i.set(c.anchor,[c])}if(!o)return[];const s=[];let a=null;const l=()=>{a&&(a.fixed||(a.h.label=yx(a.text)),a.h.label&&s.push(a.h)),a=null};for(const c of e){const p=[...c.columns].sort((h,m)=>h.col-m.col);for(const h of p)for(const m of h.chars){const u=i.get(m.id)??[],f=u.find(x=>x.kind==="heading"&&x.pos==="before"&&xx.test(x.mark));if(f&&l(),f&&f.toc!==!1){const x=(d=f.label)==null?void 0:d.trim();a={h:{level:f.mark.length,label:x??"",anchor:m.id},text:"",fixed:!!x}}if(a&&!a.fixed){for(const x of u)Ra(x)&&x.pos==="before"&&(a.text+=x.mark);a.text+=m.char;for(const x of u)Ra(x)&&x.pos!=="before"&&(a.text+=x.mark)}u.some(x=>x.kind==="break"&&x.pos!=="before")&&l()}}return l(),s}function md(e){if(!Array.isArray(e))return[];const n=[];for(const i of e){if(!i||typeof i!="object")continue;const{level:o,label:s,anchor:a}=i;typeof o!="number"||!Number.isInteger(o)||o<1||o>6||typeof s!="string"||!s.trim()||typeof a!="string"||!a||n.push({level:o,label:s.trim(),anchor:a})}return n}function Xo(e,n){return`${e}#${n}`}function hd(e){const n=e.indexOf("#");return n<=0||n===e.length-1?null:{chapter:e.slice(0,n),anchor:e.slice(n+1)}}function gd(e){const n=[],i=[];for(const o of e){const s={...o,children:[]};for(;i.length>0&&i[i.length-1].level>=o.level;)i.pop();i.length===0?n.push(s):i[i.length-1].children.push(s),i.push(s)}return n}const Ea={padding:24,color:r("desc-fg"),fontSize:14};function La({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 Aa=/^https?:\/\//i,jx=[];function vx(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&&Aa.test(i)?i:void 0,license:n(e.license),license_url:o&&Aa.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function kx(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 wx(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)||Array.isArray(n==null?void 0:n.heading_levels)&&n.heading_levels.length>0?"冊":$e.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function fd(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 xd(e,n,i){return n.map(o=>({key:Xo(e,o.anchor),label:i(o.label),inChapter:!0,...o.children.length>0?{selectable:!0,children:xd(e,o.children,i)}:{}}))}function Sx(e,n,i,o,s,a=()=>[]){var h;const l=new Map(e.chapters.map(m=>[m.file,m])),d=m=>m==="loading"?"…":typeof m=="number"&&m>0?m:void 0,c=(m,u)=>{const f=l.get(m),x=f?a(f):[];return{key:m,label:u??(f?fd(f,i,o,s):m),hint:d(n[m]),disabled:n[m]===0,...x.length>0?{selectable:!0,children:xd(m,gd(x),o)}:{}}},p=(h=e.juan_groups)==null?void 0:h.filter(m=>{var u;return m.files.some(f=>l.has(f))||((u=m.children)==null?void 0:u.length)});if(p&&p.length>0){const m=(u,f)=>{var v;if(u.files.length===1&&!((v=u.children)!=null&&v.length))return c(u.files[0],o(u.label));const x=_f(u,n);return{key:`group:${f}`,label:o(u.label),hint:x==="loading"?"…":typeof x=="number"&&x>0?`${x}`:id(u),defaultExpanded:typeof x=="number"&&x>0,children:[...u.files.filter(b=>l.has(b)).map(b=>c(b)),...(u.children??[]).map((b,_)=>m(b,`${f}.${_}`))]}};return p.map((u,f)=>m(u,`${f}`))}return e.chapters.map(m=>c(m.file))}const Zo=e=>{const n=fc();return t.jsx(qu,{mode:n[0].scriptMode,children:t.jsx(_x,{...e,prefsState:n})})},_x=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,anchor:d,title:c,subtitle:p,resolveImages:h,renderImageOverlay:m,imagePanel:u,allowVertical:f,onReportError:x,revisedAt:v,backHref:b,backLabel:_,resolveWarpData:y,warpData:w,resolveEntities:j,onEntityNavigate:k,className:C,style:$})=>{var Cs,zs,Ns;const{t:S,convert:E}=ne(),N=g.useMemo(()=>ac(i),[i]),[z,O]=e,F=rt(),A=g.useRef(a);A.current=a;const[I,P]=g.useState(null),[K,oe]=g.useState("loading");g.useEffect(()=>{let R=!1;return P(null),oe("loading"),N.getManifest(n).then(ce=>{R||(ce?(P(ce),oe("ready")):oe("missing"))}).catch(()=>{R||oe("missing")}),()=>{R=!0}},[N,n]);const le=o!==void 0,H=s!==void 0,[de,U]=g.useState(null),[te,ve]=g.useState(null);g.useEffect(()=>{U(null),ve(null)},[n]);const fe=$e.pickTextVersion(I,le?o:de),Ae=((Cs=I==null?void 0:I.versions.find(R=>R.key==="default"))==null?void 0:Cs.key)??((zs=I==null?void 0:I.versions[0])==null?void 0:zs.key)??"default",B=(fe==null?void 0:fe.key)??null,me=H?s:te,ze=g.useCallback((R,ce,Te,Ue)=>{var Je;(Je=A.current)==null||Je.call(A,{key:R,chapter:ce,isDefault:R===Ae,...Ue?{anchor:Ue}:{}},Te)},[Ae]);g.useEffect(()=>{!I||!le||o==null||I.versions.some(R=>R.key===o)||ze(Ae,null,"auto")},[I,le,o,Ae,ze]);const we=g.useRef(new Map);g.useEffect(()=>{we.current.clear()},[N,n]);const De=g.useCallback(async R=>{const ce=`${n}
1397
+ ${R}`;if(we.current.has(ce))return we.current.get(ce)??null;const Te=await N.getIndex(n,R).catch(()=>null);return Te&&we.current.set(ce,Te),Te},[N,n]),[Pe,G]=g.useState(null),[he,q]=g.useState("loading"),se=B?`${n}
1398
+ ${B}`:null,Y=Pe&&Pe.owner===se?Pe.idx:null;g.useEffect(()=>{if(!B)return;let R=!1;const ce=`${n}
1399
+ ${B}`;return G(null),q("loading"),De(B).then(Te=>{R||(Te&&Te.chapters.length>0?(G({owner:ce,idx:Te}),q("ready")):q("failed"))}),()=>{R=!0}},[n,B,De]),g.useEffect(()=>{if(!Y||!B||me!=null&&Y.chapters.some(Te=>Te.file===me))return;const ce=Y.chapters[0].file;H||ve(ce),ze(B,ce,"auto")},[Y,B,me,H,ze]);const M=Y?me!=null&&Y.chapters.some(R=>R.file===me)?me:Y.chapters[0].file:me,X=g.useMemo(()=>Y&&M?Y.chapters.find(R=>R.file===M)??null:null,[Y,M]),J=g.useRef(0),D=g.useCallback(async R=>{if(!I||R===B||!I.versions.some(St=>St.key===R))return;const ce=++J.current,Te=await De(R);if(ce!==J.current)return;const Ue=X??(M?{file:M}:null),Je=$e.matchChapterAcrossVersions(Ue,Te);le||U(R),H||ve(Je),ze(R,Je,"version")},[I,B,De,X,M,le,H,ze]),[ye,ue]=g.useState(null),[ge,Ie]=g.useState(null),L=g.useRef(0),ie=g.useCallback((R,ce)=>{ue({chapter:R,anchor:ce,nonce:++L.current}),Ie({chapter:R,anchor:ce})},[]),je=g.useCallback(R=>{if(!B)return;const ce=hd(R);if(ce){ie(ce.chapter,ce.anchor),H||ve(ce.chapter),ze(B,ce.chapter,"chapter",ce.anchor);return}H||ve(R),ze(B,R,"chapter")},[B,H,ze,ie]),W=g.useRef(null);g.useEffect(()=>{!d||!M||d===W.current||(W.current=d,ie(M,d))},[d,M,ie]),g.useEffect(()=>{d||(W.current=null)},[d]);const[ae,V]=g.useState(null),re=B&&X?`${n}
1397
1400
  ${B}
1398
- ${U.file}`:null,[$e,Ae]=g.useState(null),Oe=pe!==null&&$e!==pe,Je=g.useRef(0);g.useEffect(()=>{if(!B||!U)return;const I=++Je.current,le=`${n}
1401
+ ${X.file}`:null,[_e,Le]=g.useState(null),He=re!==null&&_e!==re,qe=g.useRef(0);g.useEffect(()=>{if(!B||!X)return;const R=++qe.current,ce=`${n}
1399
1402
  ${B}
1400
- ${U.file}`;X(null),N.getChapter(n,B,U.file,{json:!!U.has_json}).then(Te=>{I===Je.current&&X(Te)}).catch(()=>{I===Je.current&&X(null)}).finally(()=>{I===Je.current&&Ae(le)})},[N,n,B,U]);const Qe=_e.isCollatedKind(ge==null?void 0:ge.kind),[T,ue]=g.useState("");g.useEffect(()=>{ue("")},[n,B]);const ye=g.useMemo(()=>B&&Qe?async I=>{const le=await N.getChapter(n,B,I,{json:!0});return{juan:(le==null?void 0:le.json)??null,rawText:(le==null?void 0:le.md)??null}}:null,[N,n,B,Qe]),ke=(K==null?void 0:K.type)==="kaozhen",Ne=g.useMemo(()=>(K==null?void 0:K.chapters.map(I=>I.file))??[],[K]),{matchStates:Se}=Wf({resetKey:`${n}
1401
- ${B??""}`,load:ye,files:Ne,activeFile:A??null,activeJuan:(se==null?void 0:se.json)??null,activeRawText:(se==null?void 0:se.md)??null,query:T,isKaozhen:ke}),Ke=g.useRef(new Map);g.useEffect(()=>{Ke.current.clear()},[n]);const We=g.useMemo(()=>({versionKey:B,chapter:U??null}),[B,U]),ee=hf(h,A??null,We),{warpData:te,loading:He}=ud(y,w,A??null,We),Fe=xx(k,A??null,We),Ie=z.properNameMode??(Fe.length>0?"full":"off"),xe=g.useMemo(()=>({...z,properNameMode:Ie}),[z,Ie]),Ye=g.useMemo(()=>mf(Fe,Ie,{showWorks:xe.showWorks}),[Fe,Ie,xe.showWorks]),[Ce,Ve]=g.useState(new Set),[Be,et]=g.useState(null),[kt,wt]=g.useState(!0),cn=z.preserveMargins;g.useCallback(I=>M({preserveMargins:I}),[M]);const Ct=g.useRef(null),[Q,Ge]=g.useState(1),[dt,Rt]=g.useState(null),ds=I=>{var Te;const le=parseInt(((Te=I==null?void 0:I.page_id)==null?void 0:Te.split(":")[1])??"",10);return isNaN(le)?null:le},ps=I=>{var Te,Ue;const le=(I==null?void 0:I.pages)??[];return ds(I)??((Te=le.find(Xe=>Xe.columns.some(St=>St.chars.length>0)))==null?void 0:Te.page)??((Ue=le[0])==null?void 0:Ue.page)??1},[qe,_n]=g.useState(()=>ps(te)),$n=`${n}
1403
+ ${X.file}`;V(null),N.getChapter(n,B,X.file,{json:!!X.has_json}).then(Te=>{R===qe.current&&V(Te)}).catch(()=>{R===qe.current&&V(null)}).finally(()=>{R===qe.current&&Le(ce)})},[N,n,B,X]);const Xe=$e.isCollatedKind(fe==null?void 0:fe.kind),[T,pe]=g.useState("");g.useEffect(()=>{pe("")},[n,B]);const xe=g.useMemo(()=>B&&Xe?async R=>{const ce=await N.getChapter(n,B,R,{json:!0});return{juan:(ce==null?void 0:ce.json)??null,rawText:(ce==null?void 0:ce.md)??null}}:null,[N,n,B,Xe]),ke=(Y==null?void 0:Y.type)==="kaozhen",Ne=g.useMemo(()=>(Y==null?void 0:Y.chapters.map(R=>R.file))??[],[Y]),{matchStates:Se}=Bf({resetKey:`${n}
1404
+ ${B??""}`,load:xe,files:Ne,activeFile:M??null,activeJuan:(ae==null?void 0:ae.json)??null,activeRawText:(ae==null?void 0:ae.md)??null,query:T,isKaozhen:ke}),Ke=g.useRef(new Map);g.useEffect(()=>{Ke.current.clear()},[n]);const Oe=g.useMemo(()=>({versionKey:B,chapter:X??null}),[B,X]),Q=uf(h,M??null,Oe),{warpData:ee,loading:Fe}=pd(y,w,M??null,Oe),We=fx(j,M??null,Oe),Re=z.properNameMode??(We.length>0?"full":"off"),be=g.useMemo(()=>({...z,properNameMode:Re}),[z,Re]),Ye=g.useMemo(()=>pf(We,Re,{showWorks:be.showWorks}),[We,Re,be.showWorks]),[Ce,Ve]=g.useState(new Set),[Be,et]=g.useState(null),[kt,wt]=g.useState(!0),cn=z.preserveMargins;g.useCallback(R=>O({preserveMargins:R}),[O]);const Ct=g.useRef(null),[Z,Ge]=g.useState(1),[dt,Et]=g.useState(null),us=R=>{var Te;const ce=parseInt(((Te=R==null?void 0:R.page_id)==null?void 0:Te.split(":")[1])??"",10);return isNaN(ce)?null:ce},ms=R=>{var Te,Ue;const ce=(R==null?void 0:R.pages)??[];return us(R)??((Te=ce.find(Je=>Je.columns.some(St=>St.chars.length>0)))==null?void 0:Te.page)??((Ue=ce[0])==null?void 0:Ue.page)??1},[Ze,Cn]=g.useState(()=>ms(ee)),zn=`${n}
1402
1405
  ${B}
1403
- ${A??""}`,[Cn,us]=g.useState({key:$n,data:te,started:!!te});if(Cn.key!==$n)us({key:$n,data:te,started:!1});else if(te!==Cn.data&&(us({key:$n,data:te,started:!!te}),te)){const I=te.pages??[];(!Cn.started||!I.some(le=>le.page===qe))&&_n(ps(te))}g.useEffect(()=>{Ve(new Set),et(null)},[A,B]);const er=Cn.key===$n&&Cn.started,ms=g.useMemo(()=>er&&te?md(te.pages,te.punctuations):[],[er,te]),hs=g.useCallback(I=>{const le=hd(I.headings);return le.length>0?le:I.file===A?ms:[]},[A,ms]),Gp=g.useCallback(I=>{if(Ve(new Set(I)),I.length>0){const le=I[0],Te=parseInt(le.split(":")[0],10);isNaN(Te)||_n(Te)}},[]),Lt=g.useMemo(()=>{const I=new Map;for(const le of(te==null?void 0:te.pages)??[])I.set(le.page,le);return I},[te]),zn=ds(te),Qn=g.useCallback(I=>{var Ue;const le=ee.images;if(!le||le.length===0)return;const Te=(Ue=Lt.get(I))==null?void 0:Ue.seq;return(Te?le.find(Xe=>Xe.seq===Te):void 0)??le.find(Xe=>Xe.pageNo===I)??le[I-1]},[ee.images,Lt]),gs=Q>1.5,ei=g.useCallback((I,le=!1)=>{const Te=Qn(I);return Te?I===zn||le?Te.hiresUrl??Te.url:Te.url:I===zn?(te==null?void 0:te.imageUrl)??"":""},[Qn,te,zn]),Yp=g.useMemo(()=>ei(qe,gs),[ei,qe,gs]),At=g.useMemo(()=>[...Lt.keys()].sort((I,le)=>I-le),[Lt]),ti=g.useRef(qe);ti.current=qe;const fs=g.useRef(0),ni=g.useCallback(I=>{var le;ti.current===I||!Lt.has(I)||(fs.current=Date.now()+1e3,ti.current=I,_n(I),(le=Lt.get(I))!=null&&le.columns.some(Te=>Te.chars.length>0)&&Rt(Te=>({page:I,nonce:((Te==null?void 0:Te.nonce)??0)+1})))},[Lt]),Nn=g.useCallback(I=>{const le=ti.current,Te=At.indexOf(le),Ue=At[Te<0?0:Te+I];Ue===void 0||Ue===le||ni(Ue)},[At,ni]),xs=g.useCallback(I=>{if(!I.trim().match(/^\d+$/)||At.length===0)return null;const Te=parseInt(I.trim(),10),Ue=Number.isFinite(Te)?Te:Number.MAX_SAFE_INTEGER;return At.reduce((Xe,St)=>Math.abs(St-Ue)<Math.abs(Xe-Ue)?St:Xe,At[0])},[At]),[tr,nr]=g.useState(null),ii=g.useRef(null),Kp=g.useCallback(I=>{ii.current=I,nr(I)},[]),bs=g.useCallback(()=>{const I=ii.current;if(ii.current=null,nr(null),I===null)return;const le=xs(I);le!==null&&ni(le)},[xs,ni]),ir=At.indexOf(qe),qp=g.useCallback(I=>{if(I.altKey||I.ctrlKey||I.metaKey)return;const le=I.target.tagName;le==="INPUT"||le==="TEXTAREA"||le==="SELECT"||(I.key==="ArrowLeft"||I.key==="PageUp"?(I.preventDefault(),Nn(-1)):(I.key==="ArrowRight"||I.key==="PageDown")&&(I.preventDefault(),Nn(1)))},[Nn]);g.useEffect(()=>{if(te)for(const I of[1,-1,2,3]){const le=ei(qe+I);le&&Vr(le)}},[te,qe,ei]);const ys=g.useMemo(()=>{var Is;if(!te)return null;if(qe===zn)return te;const I=Lt.get(qe);if(I&&I.width>0&&I.height>0)return{page_id:`p:${qe}`,title:`第${qe}葉`,image_size:[I.width,I.height],total_warped_w:I.width,columns:[{col:1,warped_w:I.width,warped_h:I.height,offset_x:0,strips:[],chars:I.columns.flatMap(tt=>tt.chars).map(tt=>({id:tt.id,char:tt.char,slot:tt.slot,pos:tt.pos,sub:tt.sub,bbox_col:tt.bbox??[0,0,0,0]}))}]};const le=(Is=te.pages)==null?void 0:Is.find(tt=>tt.page===qe),[Te,Ue]=te.image_size||[2386,3082],Xe=Qn(qe),St=(Xe==null?void 0:Xe.width)??Te,lr=(Xe==null?void 0:Xe.height)??Ue,zs=St/Te,Ns=lr/Ue,Ts=new Map;for(const tt of te.columns){const ft=(tt.strips||[]).flatMap(li=>li.srcQuad.map(ci=>ci[0]));if(ft.length===0)continue;const Mt=tt.top_y??0,cr=tt.bottom_y??Mt+tt.warped_h;Ts.set(tt.col,{x0:Math.min(...ft),x1:Math.max(...ft),top:Mt,slotH:(cr-Mt)/21})}return{page_id:`p:${qe}`,title:`第${qe}葉`,image_size:[St,lr],total_warped_w:St,columns:le?le.columns.map(tt=>{const ft=Ts.get(tt.col)??{x0:0,x1:0,top:0,slotH:118};return{col:tt.col,warped_w:St,warped_h:lr,offset_x:0,strips:[],chars:tt.chars.map(Mt=>{const cr=Mt.slot??Mt.pos??0,li=(ft.top+(cr-1)*ft.slotH)*Ns,ci=(ft.x0+ft.x1)/2,[ou,su]=Mt.sub==="a"?[ci,ft.x1]:Mt.sub==="b"?[ft.x0,ci]:[ft.x0,ft.x1];return{...Mt,bbox_col:[ou*zs,li,su*zs,li+ft.slotH*Ns]}})}}):[]}},[te,qe,zn,Lt,Qn]),{entryTitle:ri,authors:js}=Cx(n,i,c===void 0),[vs,rr]=g.useState("text");if(g.useEffect(()=>{rr("text")},[A,B]),Z==="loading")return t.jsx(Ra,{className:C,style:_,title:c??ri,label:S("reader.loading")});if(Z==="missing"||!E||!ge)return t.jsx("div",{className:C,style:{..._,...Ea},children:S("reader.noText")});if(he==="failed")return t.jsx("div",{className:C,style:{..._,...Ea},children:S("reader.tocFailed")});if(!K)return t.jsx(Ra,{className:C,style:_,title:c??ri,label:S("reader.tocLoading")});const Zt=kx(ge,K),Xp=wx(K,Se,Zt,R,Qe,hs),ks=ve&&A&&ve.chapter===A?Ko(A,ve.anchor):null,Zp=ks&&U&&hs(U).some(I=>I.anchor===ve.anchor)?ks:A??null,or=E.versions.map(I=>({key:I.key,label:_e.textVersionLabel(I),optionLabel:R(_e.textVersionLabel(I)),sourceName:Aa(I)?S("reader.originalSource"):I.source_name?R(I.source_name):void 0,license:I.license??void 0,sourceUrl:I.source_url??void 0,primary:I.key===Le})),gt=jx((Cs=K.source)==null?void 0:Cs.upstream),oi=(typeof c=="string"?R(c):c)??(K.title?R(K.title):ri?R(ri):void 0),ws=ge.edition_label?R(ge.edition_label):void 0,sr=oi?t.jsx("a",{href:F(n),title:S("reader.viewEntry"),onClick:l?I=>{I.metaKey||I.ctrlKey||(I.preventDefault(),l(n))}:void 0,children:oi}):void 0,Jp=sr&&ws?t.jsxs(t.Fragment,{children:[sr,t.jsxs("span",{className:"bim-rd-ed",children:["·",ws]})]}):sr,Qp=js.length>0?R(js.slice(0,2).map(I=>`${I.dynasty?`〔${I.dynasty}〕`:""}${I.name}${` ${I.role||S("reader.defaultRole")}`}`).join("、")):void 0,ar=U?xd(U,Zt,R,Qe):void 0,Jt=Qe&&!!(se!=null&&se.json),Qt=(se==null?void 0:se.json)??null,dn=(se==null?void 0:se.md)??null,Ss=Jt&&!ke&&od(Qt.sections),eu=Ss&&!(dn&&xe.readingMode==="paragraph"&&$i(dn)),tu=Jt&&Ss?t.jsx(Ff,{juan:Qt,view:vs,onView:rr,textHasEntries:eu}):void 0,nu=!0,si=dn?dn.replace(/^##\s+[^\n]+\n+/,""):null,ai=Aa(ge),Ut=ai?S("reader.originalSource"):ge.source_name?R(ge.source_name):void 0,iu=(typeof p=="string"?R(p):p)??(ai?void 0:Ut??R(_e.textVersionLabel(ge))),ru=(te==null?void 0:te.hasNorm)===!0;return t.jsxs(cc,{className:C,style:_,title:Jp,subtitle:iu,byline:Qp,current:ar,pagerUnit:Zt,rail:tu,revisedAt:v,backHref:b,backLabel:$,onReportError:x?I=>x({...I,bookTitle:typeof oi=="string"?oi:void 0,entryId:n}):void 0,workLinkToggle:Jt&&!ke&&!!l&&!!(Qt!=null&&Qt.sections.some(I=>I.work_id)),toc:Xp,tocCaption:S("reader.tocCaption",{n:K.chapters.length,unit:R(Zt)}),tocHeader:Qe&&K.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:ke?S("reader.searchChaptersPlaceholder"):S("reader.searchUnitPlaceholder",{unit:R(Zt)}),"aria-label":ke?S("reader.searchChapters"):S("reader.searchUnit",{unit:R(Zt)}),value:T,onChange:I=>ue(I.target.value)}):void 0,activeKey:A??null,tocActiveKey:Zp,onSelect:fe,images:ee.images,renderImageOverlay:m,imagePanel:te?"open":u,isWarpMode:!!te,customImagePanel:te&&ys?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:qp,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:[Ce.size>0&&t.jsxs("button",{type:"button",onClick:()=>Ve(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",Ce.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:Q<=1,onClick:()=>{var I;return(I=Ct.current)==null?void 0:I.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Q*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Q>=6,onClick:()=>{var I;return(I=Ct.current)==null?void 0:I.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Q===1,onClick:()=>{var I;return(I=Ct.current)==null?void 0:I.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(fx,{ref:Ct,resetKey:qe,onScaleChange:Ge,style:{flex:1,minHeight:0},children:t.jsx(Ho,{imageUrl:Yp,pageData:ys,selectedCharIds:Ce,hoveredCharId:Be,preserveMargins:cn,onCharClick:I=>{Ve(Te=>{const Ue=new Set(Te);return Ue.has(I)?Ue.delete(I):(Ue.clear(),Ue.add(I)),Ue});const le=document.querySelector(`[data-char-id="${I}"]`);le&&le.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:et})}),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:ir<=0,onClick:()=>Nn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":qe,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(tr??qe).length),value:tr??String(qe),onFocus:I=>I.currentTarget.select(),onChange:I=>Kp(I.target.value),onKeyDown:I=>{I.key==="Enter"?(I.preventDefault(),bs()):I.key==="Escape"&&(ii.current=null,nr(null)),I.stopPropagation()},onBlur:bs,style:{width:`${Math.max(2,String(tr??qe).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:ir<0||ir>=At.length-1,onClick:()=>Nn(1),children:"›"})]})]}):void 0,settingsAnnotate:te?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${kt?"bim-rd-on":""}`,"aria-pressed":kt,title:"切换外挂现代断句标点",onClick:()=>wt(I=>!I),children:kt?"标点":"无标点"}):void 0,prefs:xe,onPrefsChange:M,versions:or.length>1?or:void 0,currentVersionKey:or.length>1?ge.key:void 0,onVersionChange:D,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:$i(dn),allowVertical:f,origScriptAvailable:ru,contentLoading:Oe,children:[(Oe||He&&!te&&!Jt&&si==null)&&t.jsx(an,{}),!Oe&&te&&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:U!=null&&U.title?R(U.title):ar}),(Ut||ge.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Ut,ge.license&&t.jsxs(t.Fragment,{children:[Ut&&t.jsx("span",{className:"bim-rd-dot"}),ge.license]})]})]}),t.jsx(Go,{pageData:te,pages:te.pages,punctuations:te.punctuations||yx,selectedCharIds:Ce,hoveredCharId:Be,onSelectionChange:Gp,onCharClick:I=>{Ve(Te=>{const Ue=new Set(Te);return Ue.has(I)?Ue.delete(I):(Ue.clear(),Ue.add(I)),Ue});const le=parseInt(I.split(":")[0],10);isNaN(le)||_n(le)},onCharHover:et,mode:"horizontal",showPunctuation:kt,entities:Ye,entityTransport:i,onEntityNavigate:j,onVisiblePageChange:I=>{Date.now()>=fs.current&&_n(I)},convert:R,scrollToPage:dt,scrollToAnchor:de&&de.chapter===A&&er?de:null,onVisibleHeadingChange:I=>Re(I&&A?{chapter:A,anchor:I}:null),pageBreaks:xe.pageBreaks,pageIndicatorY:xe.pageIndicatorY,onPageIndicatorYChange:I=>M({pageIndicatorY:I}),quoteStyle:xe.quoteStyle,bookTitleStyle:xe.bookTitleStyle,showWorks:xe.showWorks})]}),!Oe&&!te&&Jt&&Qt&&t.jsx(Of,{juan:Qt,rawText:dn,positionLabel:_x(U,K,Zt,R),groupLabel:$x(K,A??null),index:vx(n,K),searchQuery:T,onNavigate:l,transport:i,workLabelCache:Ke,prefs:xe,view:vs,onViewChange:rr},`${B}/${A}`),!Oe&&!te&&!Jt&&si!=null&&U&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:U.title?R(U.title):ar}),(Ut||ge.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ai&&Ut&&t.jsx(t.Fragment,{children:Ut}),!ai&&ge.source_name&&t.jsxs(t.Fragment,{children:[S("reader.textSource")," ",ge.source_url?t.jsx("a",{className:"bim-rd-link",href:ge.source_url,target:"_blank",rel:"noreferrer",children:R(ge.source_name)}):R(ge.source_name)]}),Ut&&ge.license&&t.jsx("span",{className:"bim-rd-dot"}),ge.license]}),gt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[S("reader.upstream")," ",gt.url?t.jsx("a",{className:"bim-rd-link",href:gt.url,target:"_blank",rel:"noreferrer",children:R(gt.name??gt.url)}):R(gt.name??""),gt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),gt.license_url?t.jsx("a",{className:"bim-rd-link",href:gt.license_url,target:"_blank",rel:"noreferrer",children:gt.license}):gt.license]}),gt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Jl,{text:gt.note,convert:R})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(Lo,{text:si,mode:xe.readingMode,tables:nu,gujiMarkdown:!0,bookMarking:Ro(xe),quoteStyle:xe.quoteStyle})})]}),!Oe&&!He&&!te&&!Jt&&si==null&&U&&t.jsx("div",{className:"bim-rd-state",children:S("reader.chapterFailed")}),!Oe&&K.references&&K.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:S("reader.references")}),t.jsx("ol",{children:K.references.map((I,le)=>t.jsxs("li",{children:[I.url?t.jsx("a",{className:"bim-rd-link",href:I.url,target:"_blank",rel:"noopener noreferrer",children:R(I.title)}):t.jsx("span",{children:R(I.title)}),I.author&&t.jsxs("span",{children:[",",R(I.author)]}),I.note&&t.jsxs("span",{children:["。",R(I.note)]})]},le))})]})]})};function Aa(e){return e.is_original===!0||e.source==="original"}function _x(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 $x(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 Cx(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 yd={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")}},zx=yd.other,jd={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")}},Nx=jd.pending;function Tx(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 Ix(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 Xo=({items:e,loading:n})=>{const i=rt(),{t:o,convert:s}=ie();return n?t.jsx(an,{}):e.length===0?t.jsx("div",{style:Ex,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=yd[a.type]||zx,d=jd[a.status]||Nx,c=typeof window<"u"&&Ix(a.pageUrl,window.location.href);return t.jsxs("div",{style:Rx,children:[t.jsxs("div",{style:Lx,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Ma,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Ma,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Ax,children:Tx(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Mx,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:jr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:jr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:jr,children:a.pageUrl}))]}),t.jsx("div",{style:Px,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Bx,children:[t.jsx("div",{style:Ox,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Ex={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},Rx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},Lx={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Ma={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Ax={fontSize:"12px",color:r("desc-fg")},Mx={fontSize:"12px",marginBottom:"6px"},jr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},Px={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},Bx={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},Ox={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},Yr=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ee(),[d,c]=g.useState(null),[p,h]=g.useState([]),[m,u]=g.useState("recommend"),[f,x]=g.useState([]),[v,b]=g.useState(!1),$=o??m,y=E=>{u(E),s==null||s(E)},[w,k]=g.useState(!0),[j,C]=g.useState(null),[_,S]=g.useState(null),[R,N]=g.useState(null);g.useEffect(()=>{let E=!1;if(e.getCounts)return e.getCounts().then(P=>{E||c({works:P.works,books:P.books,collections:P.collections})}).catch(()=>{}),()=>{E=!0}},[e]),g.useEffect(()=>{let E=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const Z=await e.getRecommended();if(Z!=null&&Z.groups)return Z.groups.flatMap(oe=>oe.items.map(ae=>({...ae,group:oe.name})))}catch{}return[]})().then(async Z=>{if(E)return;const oe=Z.filter(H=>H.id);if(oe.length===0){k(!1);return}const ae=await Promise.all(oe.map(async H=>{if(H.type)return{id:H.id,title:H.title,type:H.type,author:H.author,dynasty:H.dynasty,role:H.role,edition:H.edition,has_text:H.has_text,has_image:H.has_image,has_collated:H.has_collated,subtype:H.subtype,primary_name:H.primary_name,group:H.group,fallbackDescription:H.description};try{let ce=null;if(e.getEntry)ce=await e.getEntry(H.id);else{const V=await e.getItem(H.id);V&&(ce={id:H.id,title:V.title||H.id,type:V.type||"work"})}if(ce)return{...ce,group:H.group,fallbackDescription:H.description}}catch{}return{id:H.id,title:H.title,type:_e.extractType(H.id),group:H.group,fallbackDescription:H.description}}));E||(h(ae.filter(H=>H!==null)),k(!1))}),()=>{E=!0}},[e,i]);const z=g.useRef(!1),M=g.useRef(!1),F=g.useRef(!1);g.useEffect(()=>{if($!=="catalog"||z.current)return;const E=e.getCatalogProgress??e.getResourceProgress;if(!E)return;z.current=!0;let P=!1;return E.call(e).then(Z=>{P||C(Z)}).catch(()=>{z.current=!1}),()=>{P=!0}},[e,$]),g.useEffect(()=>{if($!=="collection"||M.current||!e.getCollectionProgress)return;M.current=!0;let E=!1;return e.getCollectionProgress().then(P=>{E||S(P)}).catch(()=>{M.current=!1}),()=>{E=!0}},[e,$]),g.useEffect(()=>{if($!=="site"||F.current||!e.getSiteProgress)return;F.current=!0;let E=!1;return e.getSiteProgress().then(P=>{E||N(P)}).catch(()=>{F.current=!1}),()=>{E=!0}},[e,$]),g.useEffect(()=>{if(!a||$!=="feedback")return;let E=!1;return b(!0),fetch(a).then(P=>P.json()).then(P=>{!E&&P.success&&x(P.items||[])}).catch(()=>{}).finally(()=>{E||b(!1)}),()=>{E=!0}},[a,$]);const L=E=>t.jsx(Sn,{type:E,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(Ln,{label:l.home.recommendTab,active:$==="recommend",onClick:()=>y("recommend")}),t.jsx(Ln,{label:l.home.catalogTab,active:$==="catalog",onClick:()=>y("catalog")}),t.jsx(Ln,{label:l.home.collectionTab,active:$==="collection",onClick:()=>y("collection")}),t.jsx(Ln,{label:l.home.siteTab,active:$==="site",onClick:()=>y("site")}),a&&t.jsx(Ln,{label:l.home.feedbackTab,active:$==="feedback",onClick:()=>y("feedback")})]}),$==="recommend"&&t.jsx(Wx,{recommended:p,loading:w,onNavigate:n,getIcon:L,t:l}),$==="catalog"&&t.jsx(Pa,{progress:j,t:l,onNavigate:n}),$==="collection"&&t.jsx(Pa,{progress:_,t:l,onNavigate:n}),$==="site"&&t.jsx(Hx,{progress:R,t:l,totalWorks:(d==null?void 0:d.works)??0}),$==="feedback"&&a&&t.jsx(Xo,{items:f,loading:v})]})})},Ln=({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}),Wx=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=rt();if(n)return t.jsx(an,{});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:m=>{m.metaKey||m.ctrlKey||(m.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))})},Pa=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(an,{});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(Fx,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},Fx=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=rt(),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?bt(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})]})},Hx=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(an,{});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(Ba,{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(Ba,{item:c,t:n,totalWorks:i},c.id))})]})]})},Ba=({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})]})},Oa="(max-width: 768px)";function Dx(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(Oa).matches);return g.useEffect(()=>{const i=window.matchMedia(Oa),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const Ux=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var M;const a=Ee(),{convert:l}=Me(),d=Dx(),[c,p]=g.useState(null),[h,m]=g.useState(null),[u,f]=g.useState(!1),[x,v]=g.useState("detail"),[b,$]=g.useState([]),[y,w]=g.useState(!1),k=g.useCallback(async F=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){$([]);return}w(!0);try{if(e.getCollectionCatalogs){const L=await e.getCollectionCatalogs(F);$(L||[])}else if(e.getCollectionCatalog){const L=await e.getCollectionCatalog(F);$(L?[{resource_id:"",data:L}]:[])}}catch{$([])}finally{w(!1)}},[e]),j=g.useCallback(async F=>{if(i){i(F);return}p(F),m(null),$([]),v("detail"),f(!0);try{const L=await e.getItem(F.id);L&&(m(L),L.type==="collection"&&k(F.id))}catch(L){console.error("加载详情失败:",L)}finally{f(!1)}},[e,i,k]),C=g.useCallback(async F=>{m(null),$([]),v("detail"),f(!0);try{const L=await e.getItem(F);L&&(m(L),p({id:F,title:L.title||F,type:L.type||"book"}),L.type==="collection"&&k(F))}catch(L){console.error("导航失败:",L)}finally{f(!1)}},[e,k]),_=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,S=(h==null?void 0:h.type)==="collection"&&(b.length>0||y)||(h==null?void 0:h.type)==="work"&&_,R=d&&(u||h),N=g.useCallback(()=>{p(null),m(null),$([]),v("detail")},[]),z=t.jsx(t.Fragment,{children:u?t.jsx(an,{}):h?t.jsxs(t.Fragment,{children:[(S||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:[S&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>v("detail"),style:gi(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&y&&b.length===0&&t.jsxs("button",{onClick:()=>{},style:gi(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&b.map(F=>t.jsx("button",{onClick:()=>v(`catalog:${F.resource_id}`),style:gi(x===`catalog:${F.resource_id}`),children:F.short_name?`${l(F.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},F.resource_id)),h.type==="work"&&_&&t.jsx("button",{onClick:()=>v("collated"),style:gi(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(mo,{data:h,transport:e,onNavigate:C}):x.startsWith("catalog:")?t.jsx(ho,{data:(M=b.find(F=>`catalog:${F.resource_id}`===x))==null?void 0:M.data,onNavigate:C}):x==="collated"?t.jsx(qo,{id:h.id,transport:e,onNavigate:C}):null})]}):t.jsx(Yr,{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:R?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:N,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:z})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Ir,{transport:e,onEntryClick:j,hideModeIndicator:n}),!h&&t.jsx(Yr,{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(Ir,{transport:e,onEntryClick:j,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:z})]})};function gi(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 Vx=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[h,m]=g.useState(null),[u,f]=g.useState("horizontal"),[x,v]=g.useState(!0),b=g.useRef(null),$=g.useCallback(j=>{p(new Set(j))},[]),y=g.useCallback(j=>{if(p(C=>{const _=new Set(C);return _.has(j)?_.delete(j):(_.clear(),_.add(j)),_}),b.current){const C=b.current.querySelector(`[data-char-id="${j}"]`);C&&C.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),w=()=>{var j;p(new Set),window.getSelection&&((j=window.getSelection())==null||j.removeAllRanges())},k=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(j=>!j),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(j=>j==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:u==="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(Ho,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:y,onCharHover:m})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:b,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:u==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Go,{pageData:e,punctuations:k,selectedCharIds:c,hoveredCharId:h,onSelectionChange:$,onCharClick:y,onCharHover:m,mode:u,showPunctuation:x})]})]})]})},Gx=e=>typeof e=="string"&&Array.from(e).length===1,Yx=new Set(["point","break","heading"]),Kx=/^#{1,6}$/;function qx(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;if(typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!Gx(s.pre_char)||s.kind!=null&&!Yx.has(s.kind)||s.pos!=null&&s.pos!=="after"&&s.pos!=="before")continue;const a={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};if(!(s.kind==="break"&&s.pos==="before")){if(s.kind==="heading"){if(s.pos!=="before"||!Kx.test(s.mark))continue;typeof s.label=="string"&&s.label.trim()&&(a.label=s.label.trim()),s.toc===!1&&(a.toc=!1)}i.push(a)}}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 vd=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function lt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const Zx=new Set(["main","solo","jz_r","jz_l"]),Jx=new Set(["body","banxin","blank"]);function Qx(e){const n={};return typeof e.lane=="string"&&Zx.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 eb(e){const n={};typeof e.kind=="string"&&Jx.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 vr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function tb(e){return typeof e=="string"&&Array.from(e).length===1}function kd(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"||!vd.test(a)){i.badAnchor++;continue}if(!tb(l)){i.badChar++;continue}if(d!==void 0&&d!=="异体"){i.badWhy++;continue}n.set(a,l)}return{map:n,dropped:i}}function wd(e){return kd(e).map}function nb(e,n,i){var h,m,u,f,x,v,b,$,y,w;const o=i==null?null:wd(i),s=new Map,a=new Map;for(const k of vr(n)){const j=lt(k.page);if(j!==void 0){s.set(j,k);for(const C of Array.isArray(k.cells)?k.cells:[]){const _=C==null?void 0:C.box;typeof(C==null?void 0:C.a)=="string"&&Array.isArray(_)&&_.length===4&&_.every(S=>lt(S)!==void 0)&&a.set(C.a,[_[0],_[1],_[0]+_[2],_[1]+_[3]])}}}const l=[],d=new Map,c=new Map;for(const k of vr(e)){const j=lt(k.page);j!==void 0&&typeof k.label=="string"&&k.label&&d.set(j,k.label)}for(const k of vr(e)){const j=lt(k.page);if(j===void 0)continue;const C=[];for(const S of Array.isArray(k.columns)?k.columns:[]){const R=lt(S==null?void 0:S.col);if(R===void 0)continue;const N=[];for(const M of Array.isArray(S.cells)?S.cells:[]){const F=vd.exec(String((M==null?void 0:M.a)??""));if(!F||typeof M.c!="string")continue;const L=parseInt(F[3],10),E=o==null?void 0:o.get(M.a);N.push({id:M.a,char:M.c,slot:L,pos:L,sub:F[4]||null,bbox:a.get(M.a)??null,...Qx(M),...E!==void 0&&E!==M.c?{norm:E}:{}})}const z=eb(S);(N.length>0||z.kind==="blank")&&C.push({col:R,chars:N,...z})}if(!C.some(S=>S.chars.length>0)){C.length>0&&c.set(j,C);continue}C.sort((S,R)=>S.col-R.col);const _=s.get(j);l.push({page:j,seq:String(((h=_==null?void 0:_.canvas)==null?void 0:h.seq)??""),width:lt((m=_==null?void 0:_.canvas)==null?void 0:m.width)??lt((u=_==null?void 0:_.image)==null?void 0:u.width)??0,height:lt((f=_==null?void 0:_.canvas)==null?void 0:f.height)??lt((x=_==null?void 0:_.image)==null?void 0:x.height)??0,...typeof k.label=="string"&&k.label?{label:k.label}:{},columns:C})}const p=new Set(l.map(k=>k.page));for(const[k,j]of s){const C=(v=j==null?void 0:j.canvas)==null?void 0:v.seq;p.has(k)||typeof C!="string"&&typeof C!="number"||String(C)===""||l.push({page:k,seq:String(C),width:lt((b=j.canvas)==null?void 0:b.width)??lt(($=j.image)==null?void 0:$.width)??0,height:lt((y=j.canvas)==null?void 0:y.height)??lt((w=j.image)==null?void 0:w.height)??0,...d.has(k)?{label:d.get(k)}:{},columns:c.get(k)??[]})}return l.sort((k,j)=>k.page-j.page)}const ib=({data:e,onNavigate:n,className:i,style:o})=>{var h;const{t:s,convert:a}=ie(),[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(m=>t.jsx(rb,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:u=>p(c===u?null:u),onNavigate:n},m.name))})]})},rb=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ie(),c=e.categories.reduce((p,h)=>{const m=h.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.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(ob,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},ob=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,m,u;const{t:s,convert:a}=ie(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((h=e.books)==null?void 0:h.cunmu)||[],c=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((u=e.stats)==null?void 0:u.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(Wa,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(Wa,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},Wa=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ie(),a=rt(),[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:m=>{m.metaKey||m.ctrlKey||(m.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})})]})},_t=({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:ab,children:"AI"}),n&&t.jsx("button",{onClick:n,style:sb,children:a.action.save})]})]}),s]})},sb={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},ab={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},xt=({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"}})]}),sn=({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"}})},zi=({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 lb(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const vi=({value:e,onChange:n,label:i})=>{const[o,s]=g.useState(!1),a=g.useRef(null),l=lb(e||"");return g.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Fa,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(zi,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Fa,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"}})]})},Fa={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function cb(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function db(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Sd=({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=m=>{n(e.filter((u,f)=>f!==m)),s===m&&a(null)},c=(m,u,f)=>{const x=[...e];x[m]={...x[m],[u]:f},n(x)},p=(m,u)=>{const f=[...e];f[m]={...f[m],type:u,id:"",name:""},n(f),u==="bookID"&&i&&i(x=>{const v=[...e];v[m]={...v[m],id:x.id,name:x.title,type:"bookID"},n(v)})},h=m=>{i&&i(u=>{const f=[...e];f[m]={...f[m],id:u.id,name:u.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,u)=>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===u?null:u),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===u?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:m.name||`${o.editor.sourcePlaceholder} ${u+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:cb(m.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:db(m.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(u)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===u&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(u,"bookID"),style:{...Ha,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(u,"url"),style:{...Ha,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})]})]})]}),m.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:Pt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[u]={...f[u],type:"",id:"",name:""},n(f)},style:Da,children:o.action.changeType})]}),m.id&&m.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:m.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>h(u),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(u),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})]})]})}),m.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:Pt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[u]={...f[u],type:"",id:"",name:""},n(f)},style:Da,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:f=>c(u,"name",f.target.value),placeholder:o.editor.sourceNamePlaceholder,style:un})]}),t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:f=>c(u,"id",f.target.value),placeholder:"https://...",style:un})]})]}),m.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:{...Pt,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:Pt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:f=>c(u,"details",f.target.value),placeholder:o.editor.detailsPlaceholder,style:un})]}),t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:f=>c(u,"position",f.target.value),placeholder:"如: 卷三, p.52",style:un})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:f=>c(u,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:un})]}),t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:f=>c(u,"processor_version",f.target.value),placeholder:"如: v0.1",style:un})]})]})]})]})})]},u)),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})]})]})},Pt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},un={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"},Ha={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"},Da={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function _d(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 $d(e){return!e||e.length===0?"":JSON.stringify(e)}const Cd=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:m,onUnlinkEntity:u,onViewEntity:f,onCreateAndLink:x,onSaveRelations:v})=>{const b=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:b.section.relations})]}),v&&t.jsx("button",{onClick:v,style:pb,children:b.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(An,{direction:"up",title:b.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>u("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(An,{direction:"up",title:b.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>u("collectionId"),onLink:()=>m("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),a&&h&&h.length>0&&t.jsx(mn,{direction:"horizontal",title:`${b.relation.siblingVersions} (${h.length})`,entities:h,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:b.relation.addVersionForWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(An,{direction:"up",title:b.relation.parentWork,entity:o,onView:f,onUnlink:()=>u("parentWorkId"),onLink:()=>m("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),d&&d.length>0&&t.jsx(mn,{direction:"down",title:`${b.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:b.action.addSubWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),c&&c.length>0&&t.jsx(mn,{direction:"down",title:`${b.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:b.action.addCollectionImpl,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),t.jsx(mn,{direction:"down",title:`${b.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:b.action.addVersion,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(An,{direction:"up",title:b.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>u("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(An,{direction:"up",title:b.relation.parentCollection,entity:s,onView:f,onUnlink:()=>u("parentCollectionId"),onLink:()=>m("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(mn,{direction:"down",title:`${b.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:b.action.addSubCollection,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),t.jsx(mn,{direction:"down",title:`${b.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:b.action.addBook,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]})]})]})},An=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:m})=>{const u=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:u,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:zd(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(Ua,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx(Ua,{onClick:s,title:m,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(Kr,{onClick:a,children:d}),t.jsx(Kr,{onClick:l,primary:!0,children:c})]})]})},mn=({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"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",u=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:m}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[u.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:zd(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(Kr,{onClick:s,primary:!0,children:["+ ",a]})})]})},Ua=({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}),Kr=({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 zd(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const pb={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Nd=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,m]=g.useState(""),u=p?l.filter(b=>b.id!==p):l;g.useEffect(()=>{e&&(m(""),d(""))},[e]);const f=b=>{m(b),d(b)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",v=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:ub,children:t.jsxs("div",{style:mb,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:hb,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:b=>f(b.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:gb})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:kr,children:"搜索中..."}):u.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:u.map(b=>t.jsxs("div",{onClick:()=>o(b),style:fb,children:[t.jsx("span",{style:{fontSize:"16px"},children:v}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[b.title,b.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:b.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[b.id,b.author&&` · ${b.author}`,b.dynasty&&` · ${b.dynasty}`]})]})]},b.id))}):h?t.jsxs("div",{style:kr,children:["未找到匹配的",x]}):t.jsxs("div",{style:kr,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:xb,children:["创建新",x,"并关联"]})]})]})})},ub={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},mb={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")},hb={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},gb={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"},fb={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},kr={padding:"20px",textAlign:"center",color:r("desc-fg")},xb={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Va={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},bb={work:"📜",book:"📖",collection:"📚",entity:"👤"},Td=({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 u,f;(u=c.current)==null||u.focus(),(f=c.current)==null||f.select()},100))},[e,o==null?void 0:o.title]);const p=u=>{u.key==="Enter"&&l.trim()?h():u.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const m=()=>{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`创建新${Va[n]}`}};return t.jsx("div",{style:yb,onClick:u=>{u.target===u.currentTarget&&a()},children:t.jsxs("div",{style:jb,onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:bb[n]}),t.jsx("span",{children:m()})]}),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:u=>d(u.target.value),onKeyDown:p,placeholder:`请输入${Va[n]}名称...`,style:vb})]}),((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:kb,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...wb,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},yb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},jb={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")},vb={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"},kb={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},wb={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function Sb(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Id(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function _b(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 Ed=({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[m,u]=g.useState(""),[f,x]=g.useState([]),[v,b]=g.useState(!1),[$,y]=g.useState("recent");g.useEffect(()=>{e&&(u(""),x([]),y(o.length>0?"recent":"search"))},[e,o.length]),g.useEffect(()=>{if(!m.trim()){x([]);return}const S=setTimeout(async()=>{b(!0);try{x(await h(m,i))}catch{x([])}finally{b(!1)}},300);return()=>clearTimeout(S)},[m,i,h]);const w=g.useCallback(S=>{u(S.target.value),S.target.value.trim()&&y("search")},[]),k=g.useCallback(S=>s?S.filter(R=>R.id!==s):S,[s]);if(!e)return null;const j=n||(i==="all"?"选择实体":`选择${Id(i)}`),C=k(o),_=k(f);return t.jsx("div",{style:Cb,children:t.jsxs("div",{style:zb,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:j}),t.jsx("button",{onClick:c,style:Nb,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:m,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Tb}),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(Ga,{active:$==="recent",onClick:()=>y("recent"),children:["最近使用 (",C.length,")"]}),t.jsxs(Ga,{active:$==="search",onClick:()=>y("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:$==="recent"&&C.length>0?t.jsx(Ya,{entities:C,onSelect:d}):m.trim()?v?t.jsx(wr,{message:"搜索中..."}):_.length>0?t.jsx(Ya,{entities:_,onSelect:d}):t.jsx(wr,{message:"未找到匹配的结果"}):t.jsx(wr,{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:Ib,children:l||"创建新实体"})]})]})})},Ga=({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}),Ya=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx($b,{entity:i,onClick:()=>n(i)},i.id))}),$b=({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:Sb(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:_b(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Id(e.type)})]})},wr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),Cb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},zb={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")},Nb={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Tb={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"},Ib={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Eb={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},Rb={work:"📜",collection:"📚",book:"📖",entity:"👤"},Rd=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:m,onRelationsChange:u})=>{var q;const f=Ee(),[x,v]=g.useState(!1),[b,$]=g.useState("work"),[y,w]=g.useState(""),[k,j]=g.useState(""),[C,_]=g.useState([]),[S,R]=g.useState(!1),[N,z]=g.useState(!1),[M,F]=g.useState("work"),[L,E]=g.useState(""),[P,Z]=g.useState(),[oe,ae]=g.useState(!1),[H,ce]=g.useState(null),[V,ne]=g.useState([]);g.useRef(null);const je=e.type,ge=je==="work",Le=je==="collection",B=je==="book",me=g.useCallback((D,de)=>{n({...e,[D]:de})},[e,n]),ze=g.useCallback((D,de)=>{w(D),$(de),j(f.editor.selectToLink+f.indexType[de]),_([]),v(!0)},[f]),we=g.useCallback(D=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,D)},[o,e.id]),De=g.useCallback(D=>{s==null||s(D.id,D.type)},[s]),Pe=g.useCallback((D,de,be)=>{const ve={...be,author:(be==null?void 0:be.author)||e.author,dynasty:be==null?void 0:be.dynasty};F(de),E(D),Z(ve),z(!0)},[e.author]),G=g.useCallback((D,de)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,L,{type:M,title:D,inheritData:de}),z(!1)},[o,e.id,L,M]),he=g.useCallback(D=>{if(!D.trim()){_([]);return}R(!0),o!=null&&o.searchEntities&&o.searchEntities(D,b).then(de=>{_(de),R(!1)}).catch(()=>{_([]),R(!1)})},[o,b]),Y=g.useCallback(D=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,y,D.id),v(!1)},[o,e.id,y]),re=g.useCallback(()=>{i()},[i]),K=g.useCallback(D=>{ce(()=>D),ae(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(ne).catch(()=>{})},[o]),A=g.useCallback((D,de)=>o!=null&&o.searchEntities?o.searchEntities(D,de==="all"?void 0:de):Promise.resolve([]),[o]),U=g.useCallback(D=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(D),ne(de=>[D,...de.filter(be=>be.id!==D.id)].slice(0,10)),H==null||H(D),ae(!1),ce(null)},[o,H]);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:Rb[je]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(zi,{children:e.id}),t.jsx(zi,{color:Eb[je],children:f.indexType[je]})]})}),t.jsx(_t,{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(vi,{label:ge?f.editor.workTitle:Le?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:D=>me("title",D)}),B&&t.jsx(vi,{label:f.editor.belongsToWork,value:e.workName||"",onChange:D=>me("workName",D)}),t.jsx(xt,{label:f.editor.authorLabel,value:e.author||"",onChange:D=>me("author",D)}),t.jsx(xt,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:D=>me("publicationYear",D)}),(B||Le)&&t.jsx(vi,{label:f.editor.containedIn,value:e.collection||"",onChange:D=>me("collection",D)}),(B||Le)&&t.jsx(xt,{label:f.editor.holderLabel,value:e.holder||"",onChange:D=>me("holder",D)}),(B||Le)&&t.jsx(xt,{label:B?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:D=>me("pages",D)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(xt,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:D=>me("firstImage",D)})})]})}),t.jsx(_t,{title:f.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(sn,{value:e.description||"",onChange:D=>me("description",D),placeholder:f.editor.descriptionPlaceholder})}),(((q=e.additional_works)==null?void 0:q.length)||0)>0&&t.jsx(_t,{title:f.section.additionalWorks,onSave:i,children:t.jsx(Lb,{items:e.additional_works||[],onChange:D=>me("additional_works",D)})}),t.jsx(_t,{title:f.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Ab,{items:e.indexed_by||[],onChange:D=>me("indexed_by",D)})}),t.jsx(_t,{title:f.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Mb,{items:e.emendated_by||[],onChange:D=>me("emendated_by",D)})}),t.jsx(_t,{title:f.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(Nr,{items:e.resources||[],onChange:D=>me("resources",D),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(_t,{title:f.section.imageResources,onSave:i,children:t.jsx(Nr,{items:e.resources||[],onChange:D=>me("resources",D),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(_t,{title:f.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(Sd,{items:_d(e.sources||""),onChange:D=>me("sources",$d(D)),onOpenEntityPicker:K})}),(B||Le)&&t.jsx(_t,{title:f.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(sn,{value:e.provenance||"",onChange:D=>me("provenance",D),placeholder:f.editor.provenancePlaceholder})}),B&&t.jsx(_t,{title:f.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(sn,{value:e.otherEditions||"",onChange:D=>me("otherEditions",D),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(Cd,{entityType:je,entityId:e.id,entityTitle:e.title,parentWork:m==null?void 0:m.parentWork,parentCollection:m==null?void 0:m.parentCollection,belongsToWork:m==null?void 0:m.belongsToWork,belongsToCollection:m==null?void 0:m.belongsToCollection,childWorks:m==null?void 0:m.childWorks,childCollections:m==null?void 0:m.childCollections,containedBooks:m==null?void 0:m.containedBooks,siblingBooks:m==null?void 0:m.siblingBooks,onLinkEntity:ze,onUnlinkEntity:we,onViewEntity:De,onCreateAndLink:Pe,onSaveRelations:re}),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(Nd,{isOpen:x,entityType:b,title:k,onSelect:Y,onCancel:()=>v(!1),onCreate:()=>{v(!1),Pe(y,b)},searchResults:C,onSearch:he,isLoading:S,excludeId:e.id}),t.jsx(Td,{isOpen:N,entityType:M,relationField:L,inheritData:P,onConfirm:G,onCancel:()=>z(!1)}),t.jsx(Ed,{isOpen:oe,title:f.action.selectBookOrWork,filterType:"all",recentEntities:V,excludeId:e.id,onSelect:U,onCancel:()=>{ae(!1),ce(null)},onSearch:A})]})};function Lb({items:e,onChange:n}){const i=Ee(),o=(l,d,c)=>{const p=e.map((h,m)=>m===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(xt,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(xt,{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 Ld({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ee(),[a,l]=g.useState(null),d=(h,m,u)=>{const f=e.map((x,v)=>v===h?{...x,[m]:u||void 0}:x);n(f)},c=h=>{n(e.filter((m,u)=>u!==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,m)=>{const u=a===m;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:u?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(u?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:u?"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(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!u&&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]}),u&&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(xt,{label:s.label.sourceName,value:h.source,onChange:f=>d(m,"source",f)}),t.jsx(xt,{label:s.label.sourceBid,value:h.source_bid||"",onChange:f=>d(m,"source_bid",f)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(xt,{label:s.label.titleInfo,value:h.title_info||"",onChange:f=>d(m,"title_info",f)}),t.jsx(xt,{label:s.label.authorInfo,value:h.author_info||"",onChange:f=>d(m,"author_info",f)})]}),t.jsx(xt,{label:s.label.edition,value:h.edition||"",onChange:f=>d(m,"edition",f)})]}),t.jsx(sn,{value:h.summary||"",onChange:f=>d(m,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(sn,{value:h.comment||"",onChange:f=>d(m,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(sn,{value:h.additional_comment||"",onChange:f=>d(m,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),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 Ab({items:e,onChange:n}){const i=Ee();return t.jsx(Ld,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Mb({items:e,onChange:n}){const i=Ee();return t.jsx(Ld,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function Ad(e){var d,c,p,h,m,u,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=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((u=e.page_count)==null?void 0:u.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(b=>b.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 Pb(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 Bb=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:h,onAskAI:m,renderSectionActions:u,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:b,headerExtra:$,className:y,style:w}=e,k=Ee(),[j,C]=g.useState(s),_=a?s:j;g.useEffect(()=>{s!==j&&C(s)},[s]);const S=g.useCallback(()=>{const E=_==="view"?"edit":"view";a?a(E):C(E)},[_,a]),[R,N]=g.useState(null);g.useEffect(()=>{i&&o&&o.getItem(i).then(E=>{E&&N(E)})},[i,o]);const z=n||R,M=g.useMemo(()=>z?Ad(z):null,[z]),F=a||!n?t.jsx("button",{onClick:S,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:_==="edit"?r("accent-bg"):"transparent",color:r(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?k.common.switchToEdit:k.common.switchToView,children:_==="view"?k.common.modeEdit:k.common.modeView}):null,L=t.jsxs(t.Fragment,{children:[F,$]});return!z&&!M?t.jsx(an,{}):_==="view"?t.jsx(mo,{data:z,transport:o,onNavigate:p?E=>p(E):void 0,renderLink:h,headerExtra:L,className:y,style:w}):M?t.jsxs("div",{className:y,style:w,children:[L&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:L}),t.jsx(Rd,{data:M,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:u,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:b})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:k.common.noData})},Ob=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Md=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=ie(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,h]=g.useState(""),[m,u]=g.useState("idle"),[f,x]=g.useState(""),v=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),h(""),u("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var y;return(y=v.current)==null?void 0:y.focus()},100)},[a]),g.useEffect(()=>{if(m==="success"){const y=setTimeout(n,2e3);return()=>clearTimeout(y)}},[m,n]),g.useEffect(()=>{if(!e)return;const y=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[e,n]);const b=async()=>{if(!(!a||!d.trim())){u("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),u("success")}catch(y){u("error"),x(y instanceof Error?y.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const $=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:Wb,onClick:y=>{y.target===y.currentTarget&&n()},children:t.jsxs("div",{style:Fb,onClick:y=>y.stopPropagation(),children:[t.jsxs("div",{style:Hb,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:"✕"})]}),m==="success"?t.jsxs("div",{style:Kb,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:Ob.map(y=>t.jsxs("button",{onClick:()=>l(y.value),style:{...Ub,...a===y.value?Vb:{}},children:[t.jsx("span",{children:y.icon})," ",s(`feedback.submitType.${y.value}`)]},y.value))}),t.jsx("textarea",{ref:v,value:d,onChange:y=>c(y.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...Gb,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:y=>h(y.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||m==="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"]}),m==="error"&&t.jsx("div",{style:qb,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:b,disabled:!$,style:{...Yb,opacity:$?1:.6,cursor:$?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Wb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Fb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},Hb={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"},Ub={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"},Vb={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Gb={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"},Yb={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},Kb={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},qb={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"},qr="--bim-feedback-fab-offset",Xr=48,Zb=16,Jb=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=ie(),[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(qr,`calc(${c+Xr+Zb}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(qr)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...Qb,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(Md,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},Qb={position:"fixed",width:`${Xr}px`,height:`${Xr}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"},ey=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Pd=({onSubmit:e})=>{const{t:n}=ie(),[i,o]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[h,m]=g.useState(""),u=g.useRef(null);g.useEffect(()=>{i&&setTimeout(()=>{var v;return(v=u.current)==null?void 0:v.focus()},100)},[i]);const f=async()=>{if(!(!i||!s.trim())){p("submitting"),m("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(v){p("error"),m(v instanceof Error?v.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Ka,children:t.jsxs("div",{style:oy,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:sy,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Ka,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:ey.map(v=>t.jsxs("button",{onClick:()=>o(v.value),style:{...ty,...i===v.value?ny:{}},children:[t.jsx("span",{children:v.icon})," ",n(`feedback.submitType.${v.value}`)]},v.value))}),t.jsx("textarea",{ref:u,value:s,onChange:v=>a(v.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...iy}}),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:ly}),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:{...ry,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:ay,children:h})]})},Ka={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},ty={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"},ny={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},iy={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"},ry={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},oy={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},sy={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},ay={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},ly={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 qa(e){return typeof e=="function"?e():e??"/api/feedback"}const Bd=({resourceId:e,apiUrl:n})=>{const{t:i}=ie(),[o,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=qa(n);l(!0);try{const m=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();m.success&&s(m.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const h=qa(n),m=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const u=await m.json().catch(()=>null);throw new Error((u==null?void 0:u.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Xo,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Pd,{onSubmit:c})})]})},Vi=8;async function Gi(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 cy=Ii["zh-Hant"].relation,dy=Ii["zh-Hant"].lossStatus,py=Ii["zh-Hant"].resourceKind,Yi=wn("zh-Hant"),Zo=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Xa(e,n=Yi){return e?Zo(cy,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function uy(e,n=Yi){return Zo(dy,e)?n(`detail.lossStatus.${e}`):e}function my(e,n=Yi){return Zo(py,e)?n(`detail.resourceKind.${e}`):""}function Jo({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=ie(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=vo(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 Od(e,n,i=Yi){var c,p;const o=yo(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(m=>m.group_role!=="mirror"),mirrors:h.items.filter(m=>m.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 Wd(e,n){const i=(e.url?jn(e.url):void 0)||e.name,o=gc(e,n);return o?`${i}(${o})`:i}function Qo({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ie(),[a,l]=g.useState(!1),d=Ti(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(Wd(e,n)),h=vn(e),m=Oi(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const u=(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:"↗"}),u]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,u]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(zo,{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(u=>!u),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function Fd({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=ie();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(Qo,{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=vn(a),c=o(Wd(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 Dn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Zr(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Dn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const Za=12,hy=60,Hd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var Y,re,K;const{t:c,convert:p,messages:h}=ie(),m=g.useMemo(()=>ko({_books:e._books}),[e._books]),[u,f]=g.useState(new Map),[x,v]=g.useState(!1),[b,$]=g.useState(""),[y,w]=g.useState(!1),k=m.length<=hy,j=k||x||!!b||y,C=g.useMemo(()=>j?m:m.slice(0,Za),[m,j]);g.useEffect(()=>{if(!n||C.length===0)return;const A=C.filter(q=>!u.has(q));if(A.length===0)return;let U=!1;return Gi(A,Vi,q=>n.getItem(q).then(D=>{var be;const de=D??{};return[q,{id:q,title:de.title,edition:de.edition,resources:de.resources,publication_info:de.publication_info,current_location:de.current_location,lineage:de.lineage,measure_info:de.measure_info,summary:gy((be=D==null?void 0:D.description)==null?void 0:be.text)}]}).catch(()=>[q,{id:q}]),()=>U).then(q=>{U||f(D=>{const de=new Map(D);for(const[be,ve]of q)de.set(be,ve);return de})}),()=>{U=!0}},[n,C,u]);const _=g.useMemo(()=>m.map(A=>u.get(A)??{id:A}),[m,u]),S=m.length>0&&m.every(A=>u.has(A)),R=!!n&&C.some(A=>!u.has(A)),N=k||j,z=g.useMemo(()=>xc(_,e.version_graph,{era:b,scanOnly:y,sort:N?"year":"default"}),[_,e.version_graph,b,y,N]),M=x?z.rows:z.rows.slice(0,Za),F=z.allRows.filter(A=>A.hasImage).length,L=z.allRows.reduce((A,U)=>{var q;return A+(((q=U.copies)==null?void 0:q.length)??0)},0),E=g.useMemo(()=>(e._related||[]).map(A=>({...A,title:A.title??""})),[e._related]),P=E.filter(A=>A.relation==="collected_in"),Z=g.useMemo(()=>{const A=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],U=q=>{const D=A.indexOf(q??"");return D<0?A.length:D};return E.filter(q=>q.relation!=="collected_in").map((q,D)=>({r:q,i:D})).sort((q,D)=>U(q.r.relation)-U(D.r.relation)||q.i-D.i).map(q=>q.r)},[E]),oe=g.useMemo(()=>{const A=yo(e.resources,e.resource_groups);return[...A.mirrors.flatMap(U=>U.items.map(q=>({r:q,kind:p(U.label)}))),...A.buckets.flatMap(U=>U.items.map(q=>({r:q,kind:p(my(U.key,c))})))]},[e.resources,e.resource_groups,p,c]),ae=e.indexed_by||[],H=e.emendated_by||[],ce=g.useMemo(()=>{var O,J,fe;const A=[],U=(J=(O=e.authors)==null?void 0:O[0])==null?void 0:J.dynasty;U&&A.push({label:c("workPage.fact.written"),value:p(U)});const q=Dt(e,h.unit.juan);if(q){const W=(fe=e.juan_count)==null?void 0:fe.description;A.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(q),W&&W!==q?t.jsxs("span",{className:"bim-d-meta",children:["(",p(W),")"]}):null]})})}e.loss_status&&A.push({label:c("workPage.fact.loss"),value:p(uy(e.loss_status,c))});const D=z.allRows.filter(W=>W.sortYear!=null),de=D.length>0?D.reduce((W,se)=>W.sortYear<=se.sortYear?W:se):null;de!=null&&de.era.era?A.push({label:c("workPage.fact.earliest"),value:p([de.era.era,de.era.reign].filter(Boolean).join(" ")),title:de.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):R&&A.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),H.length&&A.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:H.length})});const be=Ja(e.additional_titles);be.length&&A.push({label:c("workPage.fact.alias"),value:be.map(p).join("、")});const ve=Ja(e.attached_texts);ve.length&&A.push({label:c("workPage.fact.attached"),value:ve.map(p).join("、")});const Re=(e.additional_works||[]).map(W=>p(W.book_title)+(W.n_juan!=null?` ${W.n_juan}${h.unit.juan}`:""));return Re.length&&A.push({label:c("workPage.fact.appendix"),value:Re.join("、")}),A},[e,p,c,h,R,z.allRows,H.length]),ne=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:S?F:0,label:c("workPage.stat.hasImage")},{value:ae.length,label:c("workPage.stat.catalogs")}],je=wo(e),ge=je?[je.l1,je.l2,je.l3,je.l4].filter(Boolean).map(A=>p(A)):[],Le=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",B=t.jsx(Kn,{title:p(e.title),byline:t.jsx(Jo,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(st,{items:[...ge,je!=null&&je.source?c("workPage.classifiedBy",{source:p(je.source.split("/")[0])}):"",Le]}),description:(Y=e.description)!=null&&Y.text?t.jsxs(t.Fragment,{children:[t.jsx(Ht,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(re=e.description.sources)!=null&&re.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(A=>({text:p(Qh(A)),href:eg(A)})).filter(A=>A.text).map((A,U)=>t.jsxs(g.Fragment,{children:[U>0?" · ":null,A.href?t.jsx("a",{href:A.href,target:"_blank",rel:"noopener noreferrer",children:A.text}):A.text]},U))}):null]}):void 0,stats:ne,facts:ce,readAction:s,foot:t.jsx(qn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(K=e.appendix)==null?void 0:K.map((A,U)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(A.title)}),t.jsx(Ht,{text:A.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},U))}),me=z.eras.length>=2?[{key:"",label:c("catalog.all")},...z.eras.map(A=>({key:A,label:`${A} ${z.allRows.filter(U=>U.era.era===A).length}`}))]:[],ze=[];m.length&&ze.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),ae.length&&ze.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:ae.length}),P.length&&ze.push({id:"collected",label:c("workPage.sec.collected"),count:P.length}),Z.length&&ze.push({id:"related",label:c("workPage.sec.related"),count:Z.length}),oe.length&&ze.push({id:"resources",label:c("workPage.sec.resources"),count:oe.length});const we=m.length===0&&ae.length===0,De=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(at,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(st,{items:[c("workPage.versionsTotal",{n:m.length-L}),S&&F?c("workPage.versionsWithImage",{n:F}):"",z.rows.length!==z.allRows.length?c("workPage.versionsCurrent",{n:z.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":R&&me.length===0&&m.length>1?"":void 0,children:[me.length>0&&t.jsx(Fi,{items:me,value:b,onChange:A=>{$(A),v(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Nc,{label:c("workPage.scanOnly"),checked:y,onChange:A=>{w(A),v(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(N?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Hi(z.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:M.map(A=>{var U;return t.jsx(xy,{row:A,measure:(U=u.get(A.id))==null?void 0:U.measure_info,loaded:u.has(A.id),onNavigate:i,renderLink:o},`${A.id}:${u.has(A.id)?"r":"p"}`)})})]}),M.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(b||y?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(So,{total:z.rows.length,shown:M.length,unit:c("workPage.moreUnit"),onClick:()=>v(!0)}),z.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),ae.length>0&&t.jsx(by,{items:ae,transport:n,onNavigate:i,renderLink:o}),we&&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")})})]}),Pe=(A,U)=>t.jsx(nt,{id:A,label:p(U),onNavigate:i,renderLink:o,dense:!0}),G=g.useMemo(()=>{const A=new Map;for(const U of Z){const q=Xa(U.relation,c);A.set(q,(A.get(q)??0)+1)}return A.size>1?[...A.entries()].sort((U,q)=>q[1]-U[1]).slice(0,4).map(([U,q])=>`${p(U)} ${q}`).join(" · "):void 0},[Z,p,c]),he=t.jsxs(t.Fragment,{children:[t.jsx(on,{id:"collected",title:c("workPage.sec.collected"),items:P.map(A=>Pe(A.id,A.title))}),t.jsx(on,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:Z.length}),sub:G,items:Z.map(A=>t.jsxs(t.Fragment,{children:[Pe(A.id,A.title),t.jsx("span",{className:"bim-d-meta",title:A.note?p(A.note):void 0,children:p(Xa(A.relation,c))})]}))}),t.jsx(on,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:oe.map(({r:A,kind:U})=>{const q=p((A.url?jn(A.url):void 0)||A.name),D=vn(A);return t.jsxs(t.Fragment,{children:[D?t.jsxs("a",{href:D,target:"_blank",rel:"noopener noreferrer",children:[q," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:q}),U&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:U})]})})})]});return t.jsx(Yn,{railTop:a,back:l,nav:ze,railLinks:d,main:De,card:B,side:he})};function Ja(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Jr(e,n){return n((e.url?jn(e.url):void 0)||e.name)}function gy(e){var a;if(!e)return;const i=e.replace(/\*\*/g,"").split(/\n/)[0].trim().match(/[^。]+。?/g)??[],s=((i.length>1&&((a=i[0])!=null&&a.startsWith("《"))?i[1]:i[0])??"").trim();return s?s.length>120?`${s.slice(0,120)}…`:s:void 0}function fy({copies:e,onNavigate:n,renderLink:i}){const{t:o,convert:s}=ie(),a=new Map;for(const l of e){const d=l.locationName||(l.holders[0]?Jr(l.holders[0],s):"")||"",c=a.get(d)??[];c.push(l),a.set(d,c)}return t.jsxs("span",{className:"bim-d-zt-copies",children:[o("workPage.sameEditionCopies",{n:e.length}),[...a].map(([l,d],c)=>t.jsxs(g.Fragment,{children:[c>0?";":"",l?`${s(l)} `:"",d.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0?" · ":"",t.jsx(nt,{id:p.id,label:p.callNumber||p.id,onNavigate:n,renderLink:i,dense:!0})]},p.id))]},l||c))]})}function xy({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=ie(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],h=e.copies??[],m=h.length&&e.locationName?l(e.locationName):p?Jr(p,l):e.locationName?l(e.locationName):"",u=e.images[0],f=u?vn(u):void 0,x=e.images.map(v=>Jr(v,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",className:h.length?"bim-d-zt-group":void 0,children:[t.jsxs("td",{className:h.length?"bim-d-zt-main bim-d-zt-rep":"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:" "}),h.length>0&&e.summary&&t.jsx("span",{className:"bim-d-zt-summary",children:l(e.summary)}),h.length>0&&t.jsx(fy,{copies:h,onNavigate:o,renderLink:s})]}),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${m?"":" bim-d-zt-blank"}`,children:[m||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),h.length>0&&e.callNumber&&t.jsx("span",{className:"bim-d-meta",style:{display:"block",fontSize:12},children:e.callNumber}),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&&(f?t.jsx("a",{className:"bim-d-flag",href:f,target:"_blank",rel:"noopener noreferrer",title:x,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:x,children:a("workPage.hasImage")}))})]})}function by({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=ie(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[h,m]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const u=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(u.length===0)return;let f=!1;return Promise.all(u.map(x=>n.getItem(x).then(v=>{var b,$;return[x,(($=(b=v==null?void 0:v.authors)==null?void 0:b[0])==null?void 0:$.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||m(new Map(x.filter(([,v])=>v)))}),()=>{f=!0}},[n,e]),t.jsx(at,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(st,{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((u,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(u.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(u.source_bid??"")?a(h.get(u.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(u.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(st,{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:yt(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:yt(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:yt(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 yy(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 jy(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 Qa(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 vy(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 ky(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,m]of Object.entries(e.node_groups))l.has(m)&&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 ki(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=ky(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,m=new Set,u=new Set;if(c){const k=new Map(n.map(N=>[N.id,N])),j=new Map((o.hypothetical_nodes??[]).map(N=>[N.id,N])),C=N=>{const z=k.get(N);if(z&&z.lineage)return(z.lineage.derived_from??[]).map(F=>F.ref);const M=j.get(N);return M?(M.derived_from??[]).map(F=>F.ref):[]},_=N=>j.has(N)?!h||h.has(N):!p||p.has(N),S=new Set,R=N=>{if(!S.has(N)){S.add(N);for(const z of C(N))a.has(z)||(_(z)||(j.has(z)?u.add(z):k.has(z)&&m.add(z)),R(z))}};for(const N of n)p&&p.has(N.id)&&!a.has(N.id)&&R(N.id);for(const N of o.hypothetical_nodes??[])h&&h.has(N.id)&&R(N.id)}const f=n.filter(k=>!a.has(k.id)).filter(k=>!p||p.has(k.id)||m.has(k.id)).map(k=>{const j=jy(k,l);return j&&m.has(k.id)&&(j.bridge=!0),j}).filter(k=>k!==null),x=(o.hypothetical_nodes??[]).filter(k=>!h||h.has(k.id)||u.has(k.id)).map(k=>{const j=yy(k);return u.has(k.id)&&(j.bridge=!0),j}),v=[...f,...x],b=new Set(v.map(k=>k.id)),$=new Set,y=[],w=k=>{$.has(k.id)||!b.has(k.source)||!b.has(k.target)||($.add(k.id),y.push(k))};for(const k of n)a.has(k.id)||!k.lineage||p&&!p.has(k.id)&&!m.has(k.id)||((k.lineage.derived_from??[]).forEach((j,C)=>{w(Qa(k.id,j,C))}),(k.lineage.related_to??[]).forEach((j,C)=>{w(vy(k.id,j,C))}));for(const k of o.hypothetical_nodes??[])h&&!h.has(k.id)&&!u.has(k.id)||(k.derived_from??[]).forEach((j,C)=>{w(Qa(k.id,j,C))});return{nodes:v,edges:y,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function Dd(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function wy(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 Ud=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ie();if(!e.nodes.length)return t.jsx("div",{style:{...Py,...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 m=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(m)),h.sort(m);const u=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:i,style:{..._y,...o},children:[e.title&&t.jsx("div",{style:$y,children:a(e.title)}),e.description&&t.jsx("div",{style:Cy,children:a(e.description)}),u.map(f=>t.jsx(el,{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(el,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},el=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ie();return t.jsxs("div",{style:zy,children:[t.jsx("div",{style:{...Ny,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(Sy,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Sy=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ie();return t.jsxs("div",{style:{...Ty,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:Iy,children:[t.jsx("span",{style:Ey,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Ry,children:Dd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Ly,children:[e.category&&t.jsx(Mn,{children:c(e.category)}),e.status==="lost"&&t.jsx(Mn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(Mn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(Mn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(Mn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Ay,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:My,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:nl,children:[t.jsx("div",{style:il,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:rl(p.confidence),children:[t.jsx("span",{style:ol,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(tl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:sl,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:nl,children:[t.jsx("div",{style:il,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,m=o.get(h);return t.jsxs("div",{style:rl(p.confidence),children:[t.jsx("span",{style:ol,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??h)}),t.jsx(tl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:sl,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Mn=({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})},tl=({level:e})=>{const{t:n}=ie(),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},_y={fontSize:"14px",color:r("fg")},$y={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Cy={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},zy={marginBottom:"16px"},Ny={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},Ty={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},Iy={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Ey={fontSize:"15px",fontWeight:600},Ry={fontSize:"12px",color:r("muted")},Ly={marginBottom:"6px"},Ay={fontSize:"12px",color:r("muted"),margin:"2px 0"},My={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},nl={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},il={fontSize:"11px",color:r("muted"),marginBottom:"2px"},rl=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),ol={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},sl={fontSize:"11px",color:r("muted")},Py={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Vd=({selectedNodeId:e,...n})=>{const{t:i}=ie(),[o,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return By().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:ll,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:ll,children:[t.jsx("div",{children:al(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:al(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Oy,{modules:a,selectedNodeId:e,...n})};function al(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 By(){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 Oy=({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:m,BaseEdge:u,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:v}=l,b=g.useMemo(()=>({lineage:C=>{var P,Z,oe,ae;const _=((P=C.data)==null?void 0:P.stepPosition)??.85,[S,R,N]=x({sourceX:C.sourceX,sourceY:C.sourceY,sourcePosition:C.sourcePosition,targetX:C.targetX,targetY:C.targetY,targetPosition:C.targetPosition,stepPosition:_,borderRadius:5}),z=!!((Z=C.data)!=null&&Z.isSibling),M=z?R:C.targetX-18,F=z?N:C.targetY-12,L=(oe=C.data)==null?void 0:oe.labelStyle,E=(ae=C.data)==null?void 0:ae.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(u,{id:C.id,path:S,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(${M}px,${F}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...E,...L},children:C.label})})]})}}),[u,f,x]),$=g.useMemo(()=>({version:C=>{const{t:_}=ie(),S=C.data,R=S.kind==="hypothetical",N=S.status==="lost",z=S.isSelected,M=S.bridge,F=S.borderColor??r("muted"),L=M||R?"dashed":"solid",E=M?.5:N?.6:1;return t.jsxs("div",{style:{background:r(M?"bg-subtle":"bg"),border:`2px ${L} ${z?r("primary"):F}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:E,boxShadow:z?r("shadow-node-selected"):R||M?"none":r("shadow-node")},title:M?_("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:R||!S.renderLink?S.label:S.renderLink(S.bookId,S.label)}),S.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:S.description}),S.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:Dd(S.yearText,void 0,S.uncertain)}),N&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:_("lineage.lost")}),t.jsx(h,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[h,m]),{convert:y}=ie(),{rfNodes:w,rfEdges:k}=g.useMemo(()=>Wy(e,v,n,a,y),[e,v,n,a,y]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:k,nodeTypes:$,edgeTypes:b,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 Wy(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 m=e.nodes.map($=>{const y=c.node($.id),w=o?$.id===o:void 0,k={kind:$.kind,label:s($.label),bookId:$.kind==="book"?$.id:void 0,yearText:s($.year_text??Hy($)),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:y.x-160/2,y:y.y-90/2},data:k,draggable:!1,selected:w}}),u=.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[$,y]of x){if(y.length<=1)continue;const w=[...y].sort((j,C)=>{var R,N;const _=((R=c.node(j.target))==null?void 0:R.y)??0,S=((N=c.node(C.target))==null?void 0:N.y)??0;return _-S}),k=w.length;w.forEach((j,C)=>{const _=(C-(k-1)/2)*f;v.set(j.id,u+_)})}const b=e.edges.map($=>Fy($,v.get($.id),s));return{rfNodes:m,rfEdges:b}}function Fy(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Dy(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 Hy(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Dy(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 ll={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},es=({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:m})=>{var k;const{t:u,convert:f}=ie(),[x,v]=g.useState(n),b=j=>{v(j),a==null||a(j)},$=(()=>{if(!c)return[];const j=Object.entries(c);return j.length===0||c.all?j:[...j,["all",{label:u("lineage.collectionAll"),description:u("lineage.collectionAllDesc")}]]})(),y=!!(d&&$.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:u("lineage.empty")});const w=l?(k=c==null?void 0:c[l])==null?void 0:k.description:void 0;return t.jsxs("div",{className:h,style:m,children:[t.jsxs("div",{style:Uy,children:[t.jsx("button",{onClick:()=>b("list"),style:Sr(x==="list"),children:u("lineage.modeList")}),t.jsx("button",{onClick:()=>b("graph"),style:Sr(x==="graph"),children:u("lineage.modeGraph")}),y&&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:u("lineage.collectionLabel")}),$.map(([j,C])=>{const _=p==null?void 0:p[j];return t.jsxs("button",{onClick:()=>d==null?void 0:d(j),style:Sr(l===j),title:C.description?f(C.description):void 0,children:[f(C.label),_!=null?` ${_}`:""]},j)})]})]}),y&&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(Ud,{graph:e,renderLink:i}):t.jsx(Vd,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},Uy={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Sr=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"}),cl=40,dl=2,Vy=9,Gy=new Set(["certain","consensus","probable","disputed"]);function _r(e){if(!e)return["",""];const n=e.split(/[  ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Gd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var J,fe,W,se,X,pe,$e,Ae,Oe,Je,Qe;const m=Ee(),{t:u,convert:f}=ie(),[x,v]=g.useState(null),[b,$]=g.useState(new Map),[y,w]=g.useState([]),[k,j]=g.useState(new Map),[C,_]=g.useState(!1),[S,R]=g.useState("flow"),[N,z]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){v(null);return}let T=!1;return n.getItem(e.work_id).then(ue=>{!T&&ue&&ue.type==="work"&&v(ue)}).catch(()=>{}),()=>{T=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){z(null);return}let T=!1;return n.getLineageGraph(e.work_id).then(ue=>{T||z(ue&&ue.nodes.length>1?ue:null)}).catch(()=>{T||z(null)}),()=>{T=!0}},[n,e.work_id]),g.useEffect(()=>{const T=e._collections||[];if(!n||T.length===0){$(new Map);return}let ue=!1;return Promise.all(T.map(ye=>{const ke=ye.id;return n.getItem(ke).then(Ne=>[ke,Ne]).catch(()=>[ke,null])})).then(ye=>{if(ue)return;const ke=new Map;for(const[Ne,Se]of ye)Se&&ke.set(Ne,Se);$(ke)}),()=>{ue=!0}},[n,e._collections]);const M=g.useMemo(()=>{const T=new Set([...x?ko(x):[],...e.related_books||[]]);return T.add(e.id),[...T]},[x,e.related_books,e.id]),F=M.length-1;g.useEffect(()=>{if(!n||F<=0){w([]);return}const T=M.length<=cl,ue=T?M:M.slice(0,8);let ye=!1;return Promise.all(ue.map(ke=>ke===e.id?Promise.resolve({id:ke,title:e.title,edition:e.edition,year:_i(e)}):n.getItem(ke).then(Ne=>{const Se=Ne??{};return{id:ke,title:Se.title,edition:Se.edition,year:Ne?_i(Se):void 0}}).catch(()=>({id:ke})))).then(ke=>{if(ye)return;const Ne=ke.filter(Se=>Se.id===e.id||Se.title||Se.edition);T&&Ne.sort((Se,Ke)=>(Se.year??1/0)-(Ke.year??1/0)),w(Ne)}),()=>{ye=!0}},[n,M,F,e]);const L=e.lineage,E=g.useMemo(()=>[...((L==null?void 0:L.derived_from)||[]).filter(T=>T.ref_type==="book").map(T=>T.ref),...((L==null?void 0:L.related_to)||[]).map(T=>T.book_id)].filter(Boolean),[L]);g.useEffect(()=>{if(!n||E.length===0){j(new Map);return}let T=!1;return Promise.all(E.map(ue=>n.getItem(ue).then(ye=>[ue,{id:ue,title:ye==null?void 0:ye.title,edition:ye==null?void 0:ye.edition}]).catch(()=>[ue,{id:ue}]))).then(ue=>{T||j(new Map(ue))}),()=>{T=!0}},[n,E]);const P=g.useMemo(()=>Od(e.resources,e.resource_groups,u),[e.resources,e.resource_groups,u]),Z=P.groups.reduce((T,ue)=>T+ue.rows.length+ue.mirrors.length,0),oe=P.groups.length>0&&P.groups.every(T=>T.key==="_physical"),ae=Gn(e),H=wc(e),ce=Dt(e,m.unit.juan),V=new Set((e._collections||[]).map(T=>Fn(T.vol).length).filter(T=>T>0)),ne=T=>{var ke;const ue=(ke=e.base_edition)==null?void 0:ke.find(Ne=>Ne.book_id===T&&Ne.name);if(ue!=null&&ue.name)return ue.name;const ye=k.get(T);return(ye==null?void 0:ye.edition)||(ye==null?void 0:ye.title)||""},je=g.useMemo(()=>{var ee,te,He,Fe,Ie;const T=[];H&&T.push({label:u("bookPage.fact.editionType"),value:f(H),title:e.edition_type||(ee=e.lineage)!=null&&ee.category?void 0:u("bookPage.inferredFromEdition")}),(te=e.publication_info)!=null&&te.details?T.push({label:u("bookPage.fact.publication"),value:f(e.publication_info.details)}):(ae.era||ae.reign)&&T.push({label:u("bookPage.fact.era"),value:f([ae.era,ae.reign].filter(Boolean).join(" ")),title:ae.source==="edition"?u("bookPage.inferredFromEdition"):void 0}),ce&&T.push({label:u("bookPage.fact.measure"),value:f(ce)});const ue=(e._collections||[]).flatMap(xe=>Fn(xe.vol));ue.length&&T.push({label:u("bookPage.fact.volumes"),value:u("bookPage.volumesValue",{range:Wi(ue,m.unit.volume),unit:m.unit.volume,n:ue.length})});const ye=(((He=e.lineage)==null?void 0:He.derived_from)||[]).find(xe=>xe.relation==="底本"&&xe.ref_type==="book");ye&&ne(ye.ref)&&T.push({label:u("bookPage.fact.baseEdition"),value:t.jsx(nt,{id:ye.ref,label:f(ne(ye.ref)),onNavigate:i,renderLink:o,dense:!0})});const ke=(e.base_edition||[]).filter(xe=>xe&&xe.name);for(const xe of["底本","配補","參校"]){if(xe==="底本"&&ye&&ne(ye.ref))continue;const Ye=ke.filter(Ce=>Ce.role===xe);Ye.length&&T.push({label:f(xe),value:Ye.map((Ce,Ve)=>t.jsxs(g.Fragment,{children:[Ve>0&&"、",Ce.book_id?t.jsx(nt,{id:Ce.book_id,label:f(Ce.name),onNavigate:i,renderLink:o,dense:!0}):f(Ce.name)]},Ve))})}const Ne=(e.provenance||[]).filter(xe=>xe&&xe.institution),Se=(e.resources||[]).filter(xe=>Ft(xe).includes("physical"));if(Ne.length){T.push({label:u("bookPage.fact.holdings"),value:Ne.slice(0,2).map(Ce=>f(Ce.institution)).join("、")+(Ne.length>2?u("bookPage.andMorePlaces",{n:Ne.length}):"")});const xe=Ne.filter(Ce=>Ce.call_number).slice(0,2).map(Ce=>`${f(Ce.institution)} ${Ce.call_number}`);xe.length&&T.push({label:u("bookPage.fact.callNumber"),value:xe.join(";")+(Ne.filter(Ce=>Ce.call_number).length>2?"…":"")});const Ye=Ne.flatMap(Ce=>Ce.seals||[]).filter(Boolean);Ye.length&&T.push({label:u("bookPage.fact.seals"),value:f(Ye.join("、"))})}else Se.length?T.push({label:u("bookPage.fact.holdings"),value:Se.slice(0,2).map(xe=>f(xe.name)).join("、")+(Se.length>2?u("bookPage.andMorePlaces",{n:Se.length}):"")}):(Fe=e.current_location)!=null&&Fe.name&&T.push({label:u("bookPage.fact.holdings"),value:f(e.current_location.name)});const Ke=e.physical_description;if(Ke){const xe=[[u("bookPage.fact.leafStyle"),Ke.leaf_style],[u("bookPage.fact.binding"),Ke.binding],[u("bookPage.fact.dimensions"),Ke.dimensions],[u("bookPage.fact.condition"),Ke.condition]];for(const[Ye,Ce]of xe)Ce&&Ce.trim()&&T.push({label:Ye,value:f(Ce)})}(Ie=e.page_count)!=null&&Ie.description&&T.push({label:m.label.pageCount,value:f(e.page_count.description)});const We=[...Hr(e.additional_titles),...Hr(e.attached_texts)];return We.length&&T.push({label:u("bookPage.fact.aliases"),value:We.map(f).join("、")}),T},[e,f,m,u,ae,H,ce,k,i,o]),ge=f(e.title),Le=e.edition?f(e.edition):void 0,B=((J=e.lineage)==null?void 0:J.year_text)||"",me=t.jsx(Kn,{kind:u("bookPage.kind"),title:ge,subtitle:Le,byline:t.jsx(Jo,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const T=[H?f(H):"",ae.era?f([ae.era,ae.reign].filter(Boolean).join("")):"",ce?f(ce):""].filter(Boolean);return T.length?t.jsx("span",{className:"bim-d-tags",children:T.map((ue,ye)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(ye,2)}`,children:ue},ye))}):null})(),description:(fe=e.description)!=null&&fe.text?t.jsx(Ht,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:$o((W=e.description)==null?void 0:W.text)?6:void 0,facts:je,readAction:s,secondaryAction:s&&Z>0&&!oe?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:u("bookPage.viewImages")}):void 0,foot:t.jsx(qn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),ze=e._collections||[],we=(a==null?void 0:a.chapters)||[],De=f(we[0]&&_r(we[0].title)[0].slice(-1)||"")||u("bookPage.chapterUnit"),Pe=u("bookPage.chapterCount",{n:we.length,unit:De}),G=!!((se=L==null?void 0:L.derived_from)!=null&&se.length||(X=L==null?void 0:L.related_to)!=null&&X.length||(pe=e.appendix)!=null&&pe.length),he=[],Y=u(oe?"bookPage.sec.physical":"bookPage.sec.images");(we.length||P.text.length||l)&&he.push({id:"fulltext",label:u("bookPage.sec.fulltext"),count:we.length?Pe:void 0}),P.groups.length&&he.push({id:"images",label:Y,count:Z}),G&&he.push({id:"lineage",label:u("bookPage.sec.lineage")}),ze.length&&he.push({id:"collections",label:u("section.containedIn"),count:ze.length}),($e=e.location_history)!=null&&$e.length&&he.push({id:"provenance",label:u("section.locationHistory")});const re=T=>(d==null?void 0:d(T))??null,K=we[0],A=K?re(K.file):null,U=C?we:we.slice(0,Vy),q=(T,ue,ye)=>T?t.jsx("a",{className:ye,href:T.href??"#",onClick:T.onClick?ke=>{ke.metaKey||ke.ctrlKey||(ke.preventDefault(),T.onClick())}:void 0,children:ue}):t.jsx("span",{className:ye,children:ue}),D=t.jsxs(t.Fragment,{children:[(we.length>0||P.text.length>0||l)&&t.jsxs(at,{id:"fulltext",title:u("bookPage.sec.fulltext"),meta:we.length>0?t.jsx(st,{items:[Pe,(Ae=a==null?void 0:a.source)!=null&&Ae.name?u("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!K&&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"})]}),K&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:u("bookPage.readFrom",{ch:f(_r(K.title)[0])||u("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((K.title||"").replace(/^第.+?[回章卷篇節节][  ]*/,""))}),q(A,t.jsxs(t.Fragment,{children:[u("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),we.length>1&&t.jsx("ul",{className:"bim-d-chap",children:U.map(T=>{const[ue,ye]=_r(T.title);return t.jsx("li",{children:q(re(T.file),t.jsxs(t.Fragment,{children:[ue&&t.jsx("b",{children:f(ue)}),f(ye||T.file)]}))},T.file)})}),we.length>U.length&&t.jsx(_o,{label:u("detail.expandRest",{n:we.length-U.length,unit:De}),onClick:()=>_(!0)}),P.text.length>0&&t.jsxs(t.Fragment,{children:[(we.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:u("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:P.text.map((T,ue)=>t.jsx(Qo,{item:T,siblings:P.text,listedVolumeCounts:V},`${T.id||T.url||T.name}-${ue}`))})})]})]}),P.groups.length>0&&t.jsx(at,{id:"images",title:Y,meta:t.jsx(st,{items:[P.groups.length>1?u("bookPage.groupCount",{n:P.groups.length}):"",u("bookPage.placeCount",{n:Z})]}),children:t.jsx(Fd,{groups:P.groups,listedVolumeCounts:V})}),G&&t.jsx(at,{id:"lineage",title:u("bookPage.sec.lineage"),meta:(Oe=L==null?void 0:L.derived_from)!=null&&Oe.length?u("bookPage.lineageMeta"):void 0,action:N?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":u("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":S==="flow",onClick:()=>R("flow"),children:u("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":S==="graph",onClick:()=>R("graph"),children:u("bookPage.viewGraph")})]}):void 0,children:S==="graph"&&N?t.jsx(es,{graph:N,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(T,ue)=>t.jsx(nt,{id:T,label:f(ue),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(Ky,{data:e,heading:Le||ge,yearText:B,refName:ne,onNavigate:i,renderLink:o})}),ze.length>0&&t.jsx(at,{id:"collections",title:u("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:ze.map((T,ue)=>{const ye=T.id,ke=Fn(T.vol),Ne=b.get(ye),Se=Zh(Ne);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:ye,label:Ne?f(Ne.title):ye,onNavigate:i,renderLink:o,dense:!0}),ke.length>0&&t.jsx(Yy,{volumes:ke,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Se?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:Se>0&&u("bookPage.totalOf",{n:Se,unit:m.unit.bu})})]},`${ye}-${ue}`)})})})}),(Je=e.location_history)!=null&&Je.length?t.jsx(at,{id:"provenance",title:u("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((T,ue)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(T.name)}),([T.start_date,T.end_date].filter(Boolean).join("—")||T.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(st,{items:[[T.start_date,T.end_date].filter(Boolean).join("—"),T.description?f(T.description):""]})})]},ue))})}):null,he.length===0&&t.jsx(at,{title:u("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("bookPage.emptyText")})})]}),de=y.findIndex(T=>T.id===e.id),be=M.length<=cl,ve=be&&de>=0?y.slice(Math.max(0,de-dl),de+dl+1):y.filter(T=>T.id!==e.id),Re=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(m.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(st,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(T=>`${T.dynasty?`〔${f(T.dynasty)}〕`:""}${f(T.name)}`),f(Dt(x,m.unit.juan)),x._edition_count?u("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,""))})]}),F>0&&ve.length>0&&t.jsxs("div",{children:[t.jsx(on,{id:"siblings",timeline:!0,title:be?u("bookPage.siblings"):m.relation.siblingVersions,meta:be?u("bookPage.byEra"):u("bookPage.kindCount",{n:F}),cap:ve.length,items:ve.map(T=>T.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(T.edition||T.title||T.id)}):t.jsx(nt,{id:T.id,label:f(T.edition||T.title||T.id),onNavigate:i,renderLink:o,dense:!0})),metas:ve.map(T=>[T.year!=null?T.year<0?u("detail.bce",{n:-T.year}):String(T.year):"",T.id===e.id?u("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:ve.findIndex(T=>T.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:u("bookPage.viewAllInWork",{n:M.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),O=e.work_id?t.jsx(zc,{caption:m.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(Yn,{railTop:c,back:p,up:O,nav:he,railLinks:h,main:D,card:me,side:Re})};function Yy({volumes:e,unit:n}){const{t:i}=ie();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Wi(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 Ky({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var $;const{t:l,convert:d}=ie(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],h=p.filter(y=>y.ref_type!=="book"),m=p.filter(y=>y.ref_type==="book"&&y.relation==="底本"),u=p.filter(y=>y.ref_type==="book"&&y.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,v=y=>y&&Gy.has(y)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${y}`)}):"",b=(y,w)=>t.jsx(nt,{id:y,label:d(w||y),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((y,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:y.relation?d(y.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),y.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(y.evidence),v(y.confidence)]})]})},`a-${w}`)),m.map((y,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(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,o(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(y.evidence),v(y.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)})]}),u.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:u.map((y,w)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,o(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(y.evidence),v(y.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((y,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:y.evidence?d(y.evidence):void 0,children:[b(y.book_id,o(y.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(y.relation)})]},w))})]})]}),($=e.appendix)==null?void 0:$.map((y,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(y.title)]}),t.jsx(Ht,{text:y.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 Pn=16,qy=200,Xy=16,Yd=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var de,be,ve,Re,O,J,fe;const{t:p,convert:h,messages:m}=ie(),[u,f]=g.useState(""),[x,v]=g.useState(!1),[b,$]=g.useState(null),[y,w]=g.useState(""),[k,j]=g.useState(!1),C=g.useMemo(()=>vc(e,n),[e,n]),_=g.useMemo(()=>jc(e),[e]),[S,R]=g.useState(new Map),N=!!i&&C.rows.length>0&&C.rows.length<=qy,z=N&&(C.rows.length<=Pn||k),M=z&&C.rows.every(W=>!W.id||S.has(W.id)),F=W=>{var se;return Zr(W?(se=S.get(W))==null?void 0:se.l1:void 0)},L=g.useMemo(()=>{const W=u.trim(),se=W?h(W):"";return C.rows.filter(X=>{var $e,Ae;if(y&&Zr(X.id?($e=S.get(X.id))==null?void 0:$e.l1:void 0)!==y)return!1;if(!se)return!0;const pe=X.id&&((Ae=S.get(X.id))==null?void 0:Ae.title)||X.title;return h(pe).includes(se)||(X.subItems||[]).some(Oe=>h(Oe).includes(se))})},[C.rows,u,y,S,h]),E=x?L:L.slice(0,Pn),P=g.useMemo(()=>(z?C.rows:E).filter(W=>W.id&&!S.has(W.id)).map(W=>W.id),[z,C.rows,E,S]);g.useEffect(()=>{if(!i||P.length===0)return;let W=!1;const se=P.slice(0,Xy);return Gi(se,Vi,X=>i.getItem(X).then(pe=>{var Oe,Je;const $e=pe??{},Ae={title:$e.title,edition:$e.edition,authors:$e.authors,measure:pe?Dt(pe,m.unit.juan):void 0,versionCount:$e._edition_count??((Oe=$e._books)==null?void 0:Oe.length),l1:((Je=wo($e))==null?void 0:Je.l1)||void 0};return[X,Ae]}).catch(()=>[X,{}]),()=>W).then(X=>{W||R(pe=>{const $e=new Map(pe);for(const[Ae,Oe]of X)$e.set(Ae,Oe);return $e})}),()=>{W=!0}},[i,P,m.unit.juan]);const Z=(de=(e.contained_in||[])[0])==null?void 0:de.id;g.useEffect(()=>{if(!Z){$(null);return}if($({id:Z}),!i)return;let W=!1;return i.getItem(Z).then(se=>{W||$({id:Z,title:se==null?void 0:se.title})}).catch(()=>{}),()=>{W=!0}},[i,Z]);const oe=g.useMemo(()=>Od(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),ae=oe.text.length+oe.groups.reduce((W,se)=>W+se.rows.length+se.mirrors.length,0),H=_.works,ce=new Set(C.rows.map(W=>W.id).filter(Boolean)),V=H.length>0&&!H.every(W=>ce.has(W.id)),ne=(()=>{const W=C.rows.map(se=>se.edition).filter(Boolean);return W.length>1&&new Set(W).size===1})(),je=C.rows.some(W=>W.volumes.length>0||W.expected!=null),ge=_.total,Le=_.truncated?ge:C.rows.length,B=Dt(e,m.unit.juan),me=e.count,ze=W=>typeof W=="number"&&Number.isFinite(W)?W:null,we=ze(me==null?void 0:me.juan)??ze((be=e.juan_count)==null?void 0:be.number),De=ze(me==null?void 0:me.ce)??(C.totalVolumes||null),Pe=[{value:Le,label:p("collectionPage.stat.titles")},{value:we??0,label:m.unit.juan},{value:De??0,label:m.unit.volume}],G=g.useMemo(()=>{var X,pe;const W=[];if((X=e.publication_info)!=null&&X.details&&W.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),ge&&(ge!==C.rows.length||_.truncated)){const $e=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");W.push({label:$e,value:`${ge} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const se=[ze(me==null?void 0:me.zhong)!=null?p("collectionPage.nZhong",{n:me.zhong}):"",ze(me==null?void 0:me.han)!=null?p("collectionPage.nHan",{n:me.han}):""].filter(Boolean);return se.length&&W.push({label:p("collectionPage.fact.expected"),value:se.join(" ")}),we==null&&B&&W.push({label:p("collectionPage.fact.measure"),value:h(B),title:(pe=e.juan_count)!=null&&pe.description?h(e.juan_count.description):void 0}),W},[e,ge,_.truncated,C.rows.length,we,B,me,h,p,m]),he=g.useMemo(()=>{if(!M)return[];const W=new Map;for(const X of C.rows){const pe=F(X.id);pe&&W.set(pe,(W.get(pe)??0)+1)}const se=Dn.filter(X=>(W.get(X.key)??0)>0);return se.length<2?[]:[{key:"",label:`${m.catalog.all} ${Le}`},...se.map(X=>({key:X.key,label:`${X.label} ${W.get(X.key)}`}))]},[M,C.rows,S,m]),Y=g.useMemo(()=>{if(!M||!C.rows.some(pe=>pe.volumes.length>0))return null;const W=[],se=C.rows.filter(pe=>pe.volumes.length>0).map(pe=>({k:F(pe.id)??"",from:Math.min(...pe.volumes),to:Math.max(...pe.volumes)})).sort((pe,$e)=>pe.from-$e.from);for(const pe of se){const $e=pe.to-pe.from+1,Ae=W[W.length-1];Ae&&Ae.key===pe.k?(Ae.to=Math.max(Ae.to,pe.to),Ae.n+=$e):W.push({key:pe.k,from:pe.from,to:pe.to,n:$e})}const X=se.reduce((pe,$e)=>Math.max(pe,$e.to),0);return W.length>1&&W.some(pe=>pe.key)?{segs:W,last:X}:null},[M,C.rows,S]),re=(ve=e.description)==null?void 0:ve.text,K=t.jsx(Kn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(Jo,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(st,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Re=e.publication_info)!=null&&Re.year?h(e.publication_info.year):""]}),description:re||(O=e.history)!=null&&O.length?t.jsxs(t.Fragment,{children:[re&&t.jsx(Ht,{text:re,style:{fontSize:15,lineHeight:1.85}}),(J=e.history)!=null&&J.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((W,se)=>t.jsx("li",{children:h(W)},se))}):null]}):void 0,clampDescription:$o(re)||(((fe=e.history)==null?void 0:fe.length)??0)>2?6:void 0,stats:Pe,facts:G,foot:t.jsx(qn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:Y&&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:Y.segs.map((W,se)=>{const X=Dn.find(pe=>pe.key===W.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!X,title:X?p("collectionPage.dist.segTitle",{section:h(X.label),from:W.from,to:W.to}):void 0,"aria-label":X?p("collectionPage.dist.only",{section:h(X.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!X&&y===W.key,style:{flexGrow:W.n,background:r(X?X.token:"rule")},onClick:()=>{X&&(w(y===W.key?"":W.key),v(!1))}},se)})}),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:Y.last})})]})]})}),A=[];C.rows.length&&A.push({id:"titles",label:p("collectionPage.sec.titles"),count:Le}),ae&&A.push({id:"resources",label:p("collectionPage.sec.resources"),count:ae}),V&&A.push({id:"works",label:m.section.containedWorks,count:H.length});const U=t.jsxs(t.Fragment,{children:[C.rows.length>0&&t.jsxs(at,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(st,{items:[`${Le} ${m.unit.items}`,C.totalVolumes?p("collectionPage.totalVolumes",{n:C.totalVolumes,unit:m.unit.volume}):"",L.length!==Le?p("collectionPage.currentN",{n:L.length,unit:m.unit.items}):""]}),action:a,children:[(C.rows.length>Pn||he.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[he.length>0&&t.jsx(Fi,{items:he,value:y,onChange:W=>{w(W),v(!1)}}),N&&C.rows.length>Pn&&!M&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:k,onClick:()=>j(!0),title:p("collectionPage.loadAllTitle",{n:C.rows.length,unit:m.unit.items}),children:p(k?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),C.rows.length>Pn&&t.jsx("input",{type:"search",className:"bim-d-find",value:u,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:W=>{f(W.target.value),v(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Hi(L.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[je&&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:E.map((W,se)=>{var Qe;const X=W.id?S.get(W.id):void 0,pe=X!=null&&X.title&&W.title===W.id?X.title:W.title,$e=((X==null?void 0:X.authors)||[]).find(T=>T&&T.name),Ae=[$e?`${$e.dynasty?`〔${h($e.dynasty)}〕`:""}${h($e.name)}${$e.role?` ${h($e.role)}`:""}`:"",X!=null&&X.measure?h(X.measure):"",(Qe=W.subItems)!=null&&Qe.length?W.subItems.map(T=>h(T)).join("、"):"",(X!=null&&X.edition||W.edition)&&!ne?h((X==null?void 0:X.edition)||W.edition||""):""].filter(Boolean),Oe=Dn.find(T=>T.key===F(W.id)),Je=W.volumes.length>0?p("collectionPage.volumeRange",{range:Wi(W.volumes,m.unit.volume),unit:m.unit.volume}):W.expected!=null?`${W.found??0}/${W.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[je&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Je?"":" bim-d-zt-blank"}`,children:[Oe&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(Oe.token)}}),Je||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[W.id?t.jsx(nt,{id:W.id,label:h(pe),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(pe)}),Ae.length>0?t.jsx(st,{items:Ae}):W.id&&!X&&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${X!=null&&X.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:X!=null&&X.versionCount?p("collectionPage.nZhong",{n:X.versionCount}):""})]},`${W.id??W.title}-${se}`)})})]}),E.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(So,{total:L.length,shown:E.length,unit:m.unit.items,onClick:()=>v(!0)})]}),ae>0&&t.jsxs(at,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:ae}),children:[oe.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[oe.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:oe.text.map((W,se)=>t.jsx(Qo,{item:W,siblings:oe.text},`${W.id||W.url||W.name}-${se}`))})})]}),t.jsx(Fd,{groups:oe.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")})})]}),q=V?t.jsx(on,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:H.length}),cap:12,items:H.map(W=>t.jsx(nt,{id:W.id,label:h(W.title),onNavigate:o,renderLink:s,dense:!0}))}):null,D=b?t.jsx(zc,{caption:p("collectionPage.parent"),children:t.jsx(nt,{id:b.id,label:h(b.title||b.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(Yn,{railTop:l,back:d,up:D,nav:A,railLinks:c,main:U,card:K,side:q})},Zy=8;function Kd(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function Jy(e){return(e||[]).filter(n=>{var i,o;return Kd(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,Zy)}function Qy({images:e,assetBase:n,name:i}){const{t:o,convert:s}=ie(),[a,l]=g.useState(0),[d,c]=g.useState(!1),p=n?Jy(e):[];if(!n||d||p.length===0)return null;const h=n.endsWith("/")?n:n+"/",m=p[Math.min(a,p.length-1)],u=m.width&&m.height&&m.width>0&&m.height>0?`${m.width} / ${m.height}`:void 0,f=x=>h+Kd(x.file).split("/").map(encodeURIComponent).join("/");return t.jsxs("figure",{className:"bim-d-seal bim-d-ui",children:[t.jsx("img",{className:"bim-d-seal-main",src:f(m),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:u?{"--seal-ar":u}:void 0,width:m.width,height:m.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},m.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,v)=>t.jsx("button",{type:"button","aria-pressed":v===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${v+1}`,onClick:()=>l(v),children:t.jsx("img",{src:f(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(m.credit)})," · ",o("entityPage.imgLicense",{license:s(m.license)}),m.source_url&&/^https?:\/\//i.test(m.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:m.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),m.note&&t.jsxs(t.Fragment,{children:[" · ",s(m.note)]})]})]})}const e0=16,$r=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function pl(e){if(!e)return $r.length;const n=$r.indexOf(e);return n===-1?$r.length:n}function t0(e,n,i){if(n)return e[n]??i(n)}function n0(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const i0={秦:[-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]},qd=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var D,de,be,ve,Re;const{t:c,convert:p,messages:h}=ie(),m=O=>n0(O,c),[u,f]=g.useState("全部"),[x,v]=g.useState(!1),[b,$]=g.useState("default"),[y,w]=g.useState(new Map),k=g.useMemo(()=>e._works||[],[e._works]),j=g.useMemo(()=>k.map(O=>{const J=y.get(O.work_id);return{id:O.work_id,title:(J==null?void 0:J.title)??O.title??O.work_id,role:O.role||"",cls:jo(O.role),versionCount:J==null?void 0:J.versionCount,section:J==null?void 0:J.cls,l1:J==null?void 0:J.l1,measure:J==null?void 0:J.measure,hasImage:J==null?void 0:J.hasImage,loaded:!!(J!=null&&J.loaded)}}),[k,y]),C=g.useMemo(()=>yc(k.map(O=>O.role),c("detail.roleAll")),[k,c]),_=g.useMemo(()=>{const O=u==="全部"?j:j.filter(J=>J.cls===u);return b==="versions"?[...O].sort((J,fe)=>(fe.versionCount??-1)-(J.versionCount??-1)):O},[j,u,b]),S=x?_:_.slice(0,e0),R=g.useMemo(()=>S.filter(O=>!y.has(O.id)).map(O=>O.id),[S,y]);g.useEffect(()=>{if(!n||R.length===0)return;let O=!1;return Gi(R,Vi,J=>n.getItem(J).then(fe=>{var $e;const W=fe??{},se=W._edition_count??(($e=W._books)==null?void 0:$e.length)??0,X=wo(W),pe=[X==null?void 0:X.l1,X==null?void 0:X.l2].filter(Boolean).join(" ");return[J,{id:J,title:W.title,versionCount:se,loaded:!0,cls:pe||void 0,l1:(X==null?void 0:X.l1)||void 0,measure:fe&&Dt(fe,h.unit.juan)||void 0,hasImage:!!W._has_image}]}).catch(()=>[J,{id:J,loaded:!0}]),()=>O).then(J=>{O||w(fe=>{const W=new Map(fe);for(const[se,X]of J)W.set(se,X);return W})}),()=>{O=!0}},[n,R,h.unit.juan]);const N=g.useMemo(()=>{const O=new Map;for(const J of e.alt_names||[]){const fe=J.type||h.section.aliases;O.has(fe)||O.set(fe,[]),O.get(fe).push(J.name)}return[...O.entries()].sort((J,fe)=>pl(J[0])-pl(fe[0])).map(([J,fe])=>({label:J,names:fe}))},[e.alt_names,h]),z=((D=e.dates)==null?void 0:D.birth)??void 0,M=((de=e.dates)==null?void 0:de.death)??void 0,F=(be=e.dates)==null?void 0:be.floruit,L=z!=null||M!=null?`${m(z)||"?"}—${m(M)||"?"}`:Array.isArray(F)&&F.length===2&&F.every(O=>Number.isFinite(O))?c("entityPage.floruit",{from:m(F[0]),to:m(F[1])}):"",E=new Set(["本名","字","號","号"]),P=N.filter(O=>E.has(O.label)),Z=N.filter(O=>!E.has(O.label)),oe=Z.reduce((O,J)=>O+J.names.length,0),ae=g.useMemo(()=>{const O=[];for(const fe of P)O.push({label:fe.label,value:fe.names.map(W=>p(W)).join("、")});const J=k.length;return J&&O.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:J})}),O},[k,P,p,c]),H=O=>{var J;return(J=N.find(fe=>O.includes(fe.label)))==null?void 0:J.names[0]},ce=H(["字"]),V=H(["號","号"]),ne=[ce?c("entityPage.zi",{name:p(ce)}):"",V?c("entityPage.hao",{name:p(V)}):""].filter(Boolean).join(","),je=e.native_place,ge=e.dynasty?i0[e.dynasty]:void 0,Le=(()=>{if(!ge||z==null||M==null||M<z)return null;const[O,J]=ge,fe=Math.max(z,O),W=Math.min(M,J);if(W<=fe)return null;const se=J-O;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":c("entityPage.lifeAria",{birth:m(z),death:m(M),years:M-z+1}),children:t.jsx("i",{style:{left:`${(fe-O)/se*100}%`,width:`${(W-fe)/se*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${m(O)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:M-z+1})}),t.jsx("span",{children:m(J)})]})]})})(),B=g.useMemo(()=>{if(!n||j.length===0||j.some(fe=>!fe.loaded))return null;const O=new Map;for(const fe of j){const W=Zr(fe.l1);W&&O.set(W,(O.get(W)??0)+1)}const J=Dn.map(fe=>({...fe,n:O.get(fe.key)??0})).filter(fe=>fe.n>0);return J.length?J:null},[j,n]),me=t.jsxs(Kn,{kind:t0(h.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:ne||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(st,{items:[e.dynasty?p(e.dynasty):"",L,je?c("entityPage.nativePlace",{place:p(je)}):""]}),Le,t.jsx(Qy,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(ve=e.description)!=null&&ve.text?t.jsx(Ht,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:$o((Re=e.description)==null?void 0:Re.text)?6:void 0,facts:ae,foot:t.jsx(qn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[oe>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:oe})}),t.jsx("dl",{children:Z.map(O=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:p(O.label)}),t.jsx("dd",{children:O.names.map(J=>p(J)).join("、")})]},O.label))})]}),B&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:c("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:B.map(O=>t.jsx("i",{style:{flexGrow:O.n,background:r(O.token)}},O.key))}),t.jsx("div",{className:"bim-d-dist-key",children:B.map(O=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(O.token)}}),p(O.label)," ",O.n]},O.key))})]})]}),ze=g.useMemo(()=>j.filter(O=>O.loaded&&(O.versionCount??0)>0).sort((O,J)=>(J.versionCount??0)-(O.versionCount??0)).slice(0,3),[j]),we=!!n&&j.length>=3&&S.some(O=>!O.loaded),De=u==="全部"&&(we||ze.length>=2),Pe=e.external_ids||{},G=[];Pe.cbdb_id!=null&&G.push({label:"CBDB",id:String(Pe.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${Pe.cbdb_id}`,note:Pe.cbdb_match==="auto"?c("entityPage.autoMatch"):void 0});const he=Pe.wikidata_id;he&&G.push({label:"Wikidata",id:he,href:`https://www.wikidata.org/wiki/${he}`});const Y=Pe.viaf_id;Y&&G.push({label:"VIAF",id:Y,href:`https://viaf.org/viaf/${Y}`});const re=C.map(O=>({key:O.cls,label:`${O.label} ${O.count}`})),K=[...De&&!we?[{id:"featured",label:c("entityPage.sec.featured"),count:ze.length}]:[],...j.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:j.length}]:[],...G.length?[{id:"external",label:c("entityPage.sec.external"),count:G.length}]:[]],A=De?t.jsxs(at,{id:"featured",title:c("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:c("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":we||void 0,children:[we&&[0,1,2].map(O=>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:" "})]},O)),!we&&ze.map(O=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(nt,{id:O.id,label:p(O.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(st,{items:[O.section?p(O.section):"",O.measure?p(O.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:O.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),O.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},O.id))]})]}):null,U=j.length===0?t.jsx(at,{title:c("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[A,t.jsxs(at,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(st,{items:[c("entityPage.total",{n:j.length}),_.length!==j.length?c("entityPage.current",{n:_.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[re.length>1&&t.jsx(Fi,{items:re,value:u,onChange:O=>{f(O),v(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":b==="versions",onClick:()=>{b==="default"&&v(!0),$(O=>O==="default"?"versions":"default")},children:c(b==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Hi(_.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("entityPage.col.work")}),t.jsx("th",{children:c("entityPage.col.section")}),t.jsx("th",{children:c("entityPage.col.role")}),t.jsx("th",{children:c("entityPage.col.versions")}),t.jsx("th",{"aria-label":c("entityPage.col.image")})]})}),t.jsx("tbody",{children:S.map(O=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:O.id,label:p(O.title),onNavigate:i,renderLink:o,dense:!0}),O.measure?t.jsx(st,{items:[p(O.measure)]}):!O.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${O.section||O.loaded?"":" bim-d-zt-blank"}`,children:O.section?p(O.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.role?"":" bim-d-zt-blank"}`,children:O.role?p(O.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${O.loaded?"":" bim-d-zt-blank"}`,children:O.loaded?O.versionCount?c("entityPage.nZhong",{n:O.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:O.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:O.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},O.id))})]}),S.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("entityPage.emptyRole")}),!x&&t.jsx(So,{total:_.length,shown:S.length,unit:c("entityPage.moreUnit"),onClick:()=>v(!0)})]})]}),q=G.length>0?t.jsx(on,{id:"external",title:c("entityPage.sec.external"),items:G.map(O=>t.jsxs("a",{href:O.href,target:"_blank",rel:"noopener noreferrer",children:[O.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:G.map(O=>O.id),foot:Pe.cbdb_id!=null&&Pe.cbdb_match==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Yn,{railTop:s,back:a,nav:K,railLinks:l,main:U,card:me,side:q})},ts="(max-width: 719px)",r0=`${ts}, (pointer: coarse)`,Xd=`
1406
+ ${M??""}`,[Nn,hs]=g.useState({key:zn,data:ee,started:!!ee});if(Nn.key!==zn)hs({key:zn,data:ee,started:!1});else if(ee!==Nn.data&&(hs({key:zn,data:ee,started:!!ee}),ee)){const R=ee.pages??[];(!Nn.started||!R.some(ce=>ce.page===Ze))&&Cn(ms(ee))}g.useEffect(()=>{Ve(new Set),et(null)},[M,B]);const tr=Nn.key===zn&&Nn.started,gs=g.useMemo(()=>tr&&ee?ud(ee.pages,ee.punctuations):[],[tr,ee]),fs=g.useCallback(R=>{const ce=md(R.headings);return ce.length>0?ce:R.file===M?gs:[]},[M,gs]),Vp=g.useCallback(R=>{if(Ve(new Set(R)),R.length>0){const ce=R[0],Te=parseInt(ce.split(":")[0],10);isNaN(Te)||Cn(Te)}},[]),Lt=g.useMemo(()=>{const R=new Map;for(const ce of(ee==null?void 0:ee.pages)??[])R.set(ce.page,ce);return R},[ee]),Tn=us(ee),ti=g.useCallback(R=>{var Ue;const ce=Q.images;if(!ce||ce.length===0)return;const Te=(Ue=Lt.get(R))==null?void 0:Ue.seq;return(Te?ce.find(Je=>Je.seq===Te):void 0)??ce.find(Je=>Je.pageNo===R)??ce[R-1]},[Q.images,Lt]),xs=Z>1.5,ni=g.useCallback((R,ce=!1)=>{const Te=ti(R);return Te?R===Tn||ce?Te.hiresUrl??Te.url:Te.url:R===Tn?(ee==null?void 0:ee.imageUrl)??"":""},[ti,ee,Tn]),Gp=g.useMemo(()=>ni(Ze,xs),[ni,Ze,xs]),At=g.useMemo(()=>[...Lt.keys()].sort((R,ce)=>R-ce),[Lt]),ii=g.useRef(Ze);ii.current=Ze;const bs=g.useRef(0),ri=g.useCallback(R=>{var ce;ii.current===R||!Lt.has(R)||(bs.current=Date.now()+1e3,ii.current=R,Cn(R),(ce=Lt.get(R))!=null&&ce.columns.some(Te=>Te.chars.length>0)&&Et(Te=>({page:R,nonce:((Te==null?void 0:Te.nonce)??0)+1})))},[Lt]),In=g.useCallback(R=>{const ce=ii.current,Te=At.indexOf(ce),Ue=At[Te<0?0:Te+R];Ue===void 0||Ue===ce||ri(Ue)},[At,ri]),ys=g.useCallback(R=>{if(!R.trim().match(/^\d+$/)||At.length===0)return null;const Te=parseInt(R.trim(),10),Ue=Number.isFinite(Te)?Te:Number.MAX_SAFE_INTEGER;return At.reduce((Je,St)=>Math.abs(St-Ue)<Math.abs(Je-Ue)?St:Je,At[0])},[At]),[nr,ir]=g.useState(null),oi=g.useRef(null),Yp=g.useCallback(R=>{oi.current=R,ir(R)},[]),js=g.useCallback(()=>{const R=oi.current;if(oi.current=null,ir(null),R===null)return;const ce=ys(R);ce!==null&&ri(ce)},[ys,ri]),rr=At.indexOf(Ze),Kp=g.useCallback(R=>{if(R.altKey||R.ctrlKey||R.metaKey)return;const ce=R.target.tagName;ce==="INPUT"||ce==="TEXTAREA"||ce==="SELECT"||(R.key==="ArrowLeft"||R.key==="PageUp"?(R.preventDefault(),In(-1)):(R.key==="ArrowRight"||R.key==="PageDown")&&(R.preventDefault(),In(1)))},[In]);g.useEffect(()=>{if(ee)for(const R of[1,-1,2,3]){const ce=ni(Ze+R);ce&&Yr(ce)}},[ee,Ze,ni]);const vs=g.useMemo(()=>{var Es;if(!ee)return null;if(Ze===Tn)return ee;const R=Lt.get(Ze);if(R&&R.width>0&&R.height>0)return{page_id:`p:${Ze}`,title:`第${Ze}葉`,image_size:[R.width,R.height],total_warped_w:R.width,columns:[{col:1,warped_w:R.width,warped_h:R.height,offset_x:0,strips:[],chars:R.columns.flatMap(tt=>tt.chars).map(tt=>({id:tt.id,char:tt.char,slot:tt.slot,pos:tt.pos,sub:tt.sub,bbox_col:tt.bbox??[0,0,0,0]}))}]};const ce=(Es=ee.pages)==null?void 0:Es.find(tt=>tt.page===Ze),[Te,Ue]=ee.image_size||[2386,3082],Je=ti(Ze),St=(Je==null?void 0:Je.width)??Te,cr=(Je==null?void 0:Je.height)??Ue,Ts=St/Te,Is=cr/Ue,Rs=new Map;for(const tt of ee.columns){const ft=(tt.strips||[]).flatMap(di=>di.srcQuad.map(pi=>pi[0]));if(ft.length===0)continue;const Mt=tt.top_y??0,dr=tt.bottom_y??Mt+tt.warped_h;Rs.set(tt.col,{x0:Math.min(...ft),x1:Math.max(...ft),top:Mt,slotH:(dr-Mt)/21})}return{page_id:`p:${Ze}`,title:`第${Ze}葉`,image_size:[St,cr],total_warped_w:St,columns:ce?ce.columns.map(tt=>{const ft=Rs.get(tt.col)??{x0:0,x1:0,top:0,slotH:118};return{col:tt.col,warped_w:St,warped_h:cr,offset_x:0,strips:[],chars:tt.chars.map(Mt=>{const dr=Mt.slot??Mt.pos??0,di=(ft.top+(dr-1)*ft.slotH)*Is,pi=(ft.x0+ft.x1)/2,[ru,ou]=Mt.sub==="a"?[pi,ft.x1]:Mt.sub==="b"?[ft.x0,pi]:[ft.x0,ft.x1];return{...Mt,bbox_col:[ru*Ts,di,ou*Ts,di+ft.slotH*Is]}})}}):[]}},[ee,Ze,Tn,Lt,ti]),{entryTitle:si,authors:ks}=zx(n,i,c===void 0),[ws,or]=g.useState("text");if(g.useEffect(()=>{or("text")},[M,B]),K==="loading")return t.jsx(La,{className:C,style:$,title:c??si,label:S("reader.loading")});if(K==="missing"||!I||!fe)return t.jsx("div",{className:C,style:{...$,...Ea},children:S("reader.noText")});if(he==="failed")return t.jsx("div",{className:C,style:{...$,...Ea},children:S("reader.tocFailed")});if(!Y)return t.jsx(La,{className:C,style:$,title:c??si,label:S("reader.tocLoading")});const Zt=wx(fe,Y),qp=Sx(Y,Se,Zt,E,Xe,fs),Ss=ge&&M&&ge.chapter===M?Xo(M,ge.anchor):null,Xp=Ss&&X&&fs(X).some(R=>R.anchor===ge.anchor)?Ss:M??null,sr=I.versions.map(R=>({key:R.key,label:$e.textVersionLabel(R),optionLabel:E($e.textVersionLabel(R)),sourceName:Ma(R)?S("reader.originalSource"):R.source_name?E(R.source_name):void 0,license:R.license??void 0,sourceUrl:R.source_url??void 0,primary:R.key===Ae})),gt=vx((Ns=Y.source)==null?void 0:Ns.upstream),ai=(typeof c=="string"?E(c):c)??(Y.title?E(Y.title):si?E(si):void 0),_s=fe.edition_label?E(fe.edition_label):void 0,ar=ai?t.jsx("a",{href:F(n),title:S("reader.viewEntry"),onClick:l?R=>{R.metaKey||R.ctrlKey||(R.preventDefault(),l(n))}:void 0,children:ai}):void 0,Zp=ar&&_s?t.jsxs(t.Fragment,{children:[ar,t.jsxs("span",{className:"bim-rd-ed",children:["·",_s]})]}):ar,Jp=ks.length>0?E(ks.slice(0,2).map(R=>`${R.dynasty?`〔${R.dynasty}〕`:""}${R.name}${` ${R.role||S("reader.defaultRole")}`}`).join("、")):void 0,lr=X?fd(X,Zt,E,Xe):void 0,Jt=Xe&&!!(ae!=null&&ae.json),Qt=(ae==null?void 0:ae.json)??null,dn=(ae==null?void 0:ae.md)??null,$s=Jt&&!ke&&rd(Qt.sections),Qp=$s&&!(dn&&be.readingMode==="paragraph"&&Ci(dn)),eu=Jt&&$s?t.jsx(Of,{juan:Qt,view:ws,onView:or,textHasEntries:Qp}):void 0,tu=!0,li=dn?dn.replace(/^##\s+[^\n]+\n+/,""):null,ci=Ma(fe),Ut=ci?S("reader.originalSource"):fe.source_name?E(fe.source_name):void 0,nu=(typeof p=="string"?E(p):p)??(ci?void 0:Ut??E($e.textVersionLabel(fe))),iu=(ee==null?void 0:ee.hasNorm)===!0;return t.jsxs(yc,{className:C,style:$,title:Zp,subtitle:nu,byline:Jp,current:lr,pagerUnit:Zt,rail:eu,revisedAt:v,backHref:b,backLabel:_,onReportError:x?R=>x({...R,bookTitle:typeof ai=="string"?ai:void 0,entryId:n}):void 0,workLinkToggle:Jt&&!ke&&!!l&&!!(Qt!=null&&Qt.sections.some(R=>R.work_id)),toc:qp,tocCaption:S("reader.tocCaption",{n:Y.chapters.length,unit:E(Zt)}),tocHeader:Xe&&Y.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:ke?S("reader.searchChaptersPlaceholder"):S("reader.searchUnitPlaceholder",{unit:E(Zt)}),"aria-label":ke?S("reader.searchChapters"):S("reader.searchUnit",{unit:E(Zt)}),value:T,onChange:R=>pe(R.target.value)}):void 0,activeKey:M??null,tocActiveKey:Xp,onSelect:je,images:Q.images,renderImageOverlay:m,imagePanel:ee?"open":u,isWarpMode:!!ee,customImagePanel:ee&&vs?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Kp,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:[Ce.size>0&&t.jsxs("button",{type:"button",onClick:()=>Ve(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",Ce.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:Z<=1,onClick:()=>{var R;return(R=Ct.current)==null?void 0:R.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Z*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Z>=6,onClick:()=>{var R;return(R=Ct.current)==null?void 0:R.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Z===1,onClick:()=>{var R;return(R=Ct.current)==null?void 0:R.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(gx,{ref:Ct,resetKey:Ze,onScaleChange:Ge,style:{flex:1,minHeight:0},children:t.jsx(Uo,{imageUrl:Gp,pageData:vs,selectedCharIds:Ce,hoveredCharId:Be,preserveMargins:cn,onCharClick:R=>{Ve(Te=>{const Ue=new Set(Te);return Ue.has(R)?Ue.delete(R):(Ue.clear(),Ue.add(R)),Ue});const ce=document.querySelector(`[data-char-id="${R}"]`);ce&&ce.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:et})}),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:rr<=0,onClick:()=>In(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Ze,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(nr??Ze).length),value:nr??String(Ze),onFocus:R=>R.currentTarget.select(),onChange:R=>Yp(R.target.value),onKeyDown:R=>{R.key==="Enter"?(R.preventDefault(),js()):R.key==="Escape"&&(oi.current=null,ir(null)),R.stopPropagation()},onBlur:js,style:{width:`${Math.max(2,String(nr??Ze).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:rr<0||rr>=At.length-1,onClick:()=>In(1),children:"›"})]})]}):void 0,settingsAnnotate:ee?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${kt?"bim-rd-on":""}`,"aria-pressed":kt,title:"切换外挂现代断句标点",onClick:()=>wt(R=>!R),children:kt?"标点":"无标点"}):void 0,prefs:be,onPrefsChange:O,versions:sr.length>1?sr:void 0,currentVersionKey:sr.length>1?fe.key:void 0,onVersionChange:D,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:Ci(dn),allowVertical:f,origScriptAvailable:iu,contentLoading:He,children:[(He||Fe&&!ee&&!Jt&&li==null)&&t.jsx(an,{}),!He&&ee&&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:X!=null&&X.title?E(X.title):lr}),(Ut||fe.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Ut,fe.license&&t.jsxs(t.Fragment,{children:[Ut&&t.jsx("span",{className:"bim-rd-dot"}),fe.license]})]})]}),t.jsx(Ko,{pageData:ee,pages:ee.pages,punctuations:ee.punctuations||jx,selectedCharIds:Ce,hoveredCharId:Be,onSelectionChange:Vp,onCharClick:R=>{Ve(Te=>{const Ue=new Set(Te);return Ue.has(R)?Ue.delete(R):(Ue.clear(),Ue.add(R)),Ue});const ce=parseInt(R.split(":")[0],10);isNaN(ce)||Cn(ce)},onCharHover:et,mode:"horizontal",showPunctuation:kt,entities:Ye,entityTransport:i,onEntityNavigate:k,onVisiblePageChange:R=>{Date.now()>=bs.current&&Cn(R)},convert:E,scrollToPage:dt,scrollToAnchor:ye&&ye.chapter===M&&tr?ye:null,onVisibleHeadingChange:R=>Ie(R&&M?{chapter:M,anchor:R}:null),pageBreaks:be.pageBreaks,pageIndicatorY:be.pageIndicatorY,onPageIndicatorYChange:R=>O({pageIndicatorY:R}),quoteStyle:be.quoteStyle,bookTitleStyle:be.bookTitleStyle,showWorks:be.showWorks})]}),!He&&!ee&&Jt&&Qt&&t.jsx(Pf,{juan:Qt,rawText:dn,positionLabel:$x(X,Y,Zt,E),groupLabel:Cx(Y,M??null),index:kx(n,Y),searchQuery:T,onNavigate:l,transport:i,workLabelCache:Ke,prefs:be,view:ws,onViewChange:or},`${B}/${M}`),!He&&!ee&&!Jt&&li!=null&&X&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:X.title?E(X.title):lr}),(Ut||fe.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[ci&&Ut&&t.jsx(t.Fragment,{children:Ut}),!ci&&fe.source_name&&t.jsxs(t.Fragment,{children:[S("reader.textSource")," ",fe.source_url?t.jsx("a",{className:"bim-rd-link",href:fe.source_url,target:"_blank",rel:"noreferrer",children:E(fe.source_name)}):E(fe.source_name)]}),Ut&&fe.license&&t.jsx("span",{className:"bim-rd-dot"}),fe.license]}),gt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[S("reader.upstream")," ",gt.url?t.jsx("a",{className:"bim-rd-link",href:gt.url,target:"_blank",rel:"noreferrer",children:E(gt.name??gt.url)}):E(gt.name??""),gt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),gt.license_url?t.jsx("a",{className:"bim-rd-link",href:gt.license_url,target:"_blank",rel:"noreferrer",children:gt.license}):gt.license]}),gt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(lc,{text:gt.note,convert:E})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(Mo,{text:li,mode:be.readingMode,tables:tu,gujiMarkdown:!0,bookMarking:Ao(be),quoteStyle:be.quoteStyle})})]}),!He&&!Fe&&!ee&&!Jt&&li==null&&X&&t.jsx("div",{className:"bim-rd-state",children:S("reader.chapterFailed")}),!He&&Y.references&&Y.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:S("reader.references")}),t.jsx("ol",{children:Y.references.map((R,ce)=>t.jsxs("li",{children:[R.url?t.jsx("a",{className:"bim-rd-link",href:R.url,target:"_blank",rel:"noopener noreferrer",children:E(R.title)}):t.jsx("span",{children:E(R.title)}),R.author&&t.jsxs("span",{children:[",",E(R.author)]}),R.note&&t.jsxs("span",{children:["。",E(R.note)]})]},ce))})]})]})};function Ma(e){return e.is_original===!0||e.source==="original"}function $x(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 Cx(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 zx(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 bd={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")}},Nx=bd.other,yd={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")}},Tx=yd.pending;function Ix(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 Rx(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 Jo=({items:e,loading:n})=>{const i=rt(),{t:o,convert:s}=ne();return n?t.jsx(an,{}):e.length===0?t.jsx("div",{style:Ex,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=bd[a.type]||Nx,d=yd[a.status]||Tx,c=typeof window<"u"&&Rx(a.pageUrl,window.location.href);return t.jsxs("div",{style:Lx,children:[t.jsxs("div",{style:Ax,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Pa,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Pa,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Mx,children:Ix(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Px,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:kr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:kr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:kr,children:a.pageUrl}))]}),t.jsx("div",{style:Bx,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Ox,children:[t.jsx("div",{style:Wx,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Ex={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},Lx={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},Ax={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Pa={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Mx={fontSize:"12px",color:r("desc-fg")},Px={fontSize:"12px",marginBottom:"6px"},kr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},Bx={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},Ox={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},Wx={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},qr=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Ee(),[d,c]=g.useState(null),[p,h]=g.useState([]),[m,u]=g.useState("recommend"),[f,x]=g.useState([]),[v,b]=g.useState(!1),_=o??m,y=I=>{u(I),s==null||s(I)},[w,j]=g.useState(!0),[k,C]=g.useState(null),[$,S]=g.useState(null),[E,N]=g.useState(null);g.useEffect(()=>{let I=!1;if(e.getCounts)return e.getCounts().then(P=>{I||c({works:P.works,books:P.books,collections:P.collections})}).catch(()=>{}),()=>{I=!0}},[e]),g.useEffect(()=>{let I=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const K=await e.getRecommended();if(K!=null&&K.groups)return K.groups.flatMap(oe=>oe.items.map(le=>({...le,group:oe.name})))}catch{}return[]})().then(async K=>{if(I)return;const oe=K.filter(H=>H.id);if(oe.length===0){j(!1);return}const le=await Promise.all(oe.map(async H=>{if(H.type)return{id:H.id,title:H.title,type:H.type,author:H.author,dynasty:H.dynasty,role:H.role,edition:H.edition,has_text:H.has_text,has_image:H.has_image,has_collated:H.has_collated,subtype:H.subtype,primary_name:H.primary_name,group:H.group,fallbackDescription:H.description};try{let de=null;if(e.getEntry)de=await e.getEntry(H.id);else{const U=await e.getItem(H.id);U&&(de={id:H.id,title:U.title||H.id,type:U.type||"work"})}if(de)return{...de,group:H.group,fallbackDescription:H.description}}catch{}return{id:H.id,title:H.title,type:$e.extractType(H.id),group:H.group,fallbackDescription:H.description}}));I||(h(le.filter(H=>H!==null)),j(!1))}),()=>{I=!0}},[e,i]);const z=g.useRef(!1),O=g.useRef(!1),F=g.useRef(!1);g.useEffect(()=>{if(_!=="catalog"||z.current)return;const I=e.getCatalogProgress??e.getResourceProgress;if(!I)return;z.current=!0;let P=!1;return I.call(e).then(K=>{P||C(K)}).catch(()=>{z.current=!1}),()=>{P=!0}},[e,_]),g.useEffect(()=>{if(_!=="collection"||O.current||!e.getCollectionProgress)return;O.current=!0;let I=!1;return e.getCollectionProgress().then(P=>{I||S(P)}).catch(()=>{O.current=!1}),()=>{I=!0}},[e,_]),g.useEffect(()=>{if(_!=="site"||F.current||!e.getSiteProgress)return;F.current=!0;let I=!1;return e.getSiteProgress().then(P=>{I||N(P)}).catch(()=>{F.current=!1}),()=>{I=!0}},[e,_]),g.useEffect(()=>{if(!a||_!=="feedback")return;let I=!1;return b(!0),fetch(a).then(P=>P.json()).then(P=>{!I&&P.success&&x(P.items||[])}).catch(()=>{}).finally(()=>{I||b(!1)}),()=>{I=!0}},[a,_]);const A=I=>t.jsx(_n,{type:I,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(Mn,{label:l.home.recommendTab,active:_==="recommend",onClick:()=>y("recommend")}),t.jsx(Mn,{label:l.home.catalogTab,active:_==="catalog",onClick:()=>y("catalog")}),t.jsx(Mn,{label:l.home.collectionTab,active:_==="collection",onClick:()=>y("collection")}),t.jsx(Mn,{label:l.home.siteTab,active:_==="site",onClick:()=>y("site")}),a&&t.jsx(Mn,{label:l.home.feedbackTab,active:_==="feedback",onClick:()=>y("feedback")})]}),_==="recommend"&&t.jsx(Fx,{recommended:p,loading:w,onNavigate:n,getIcon:A,t:l}),_==="catalog"&&t.jsx(Ba,{progress:k,t:l,onNavigate:n}),_==="collection"&&t.jsx(Ba,{progress:$,t:l,onNavigate:n}),_==="site"&&t.jsx(Dx,{progress:E,t:l,totalWorks:(d==null?void 0:d.works)??0}),_==="feedback"&&a&&t.jsx(Jo,{items:f,loading:v})]})})},Mn=({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}),Fx=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=rt();if(n)return t.jsx(an,{});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:m=>{m.metaKey||m.ctrlKey||(m.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))})},Ba=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(an,{});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(Hx,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},Hx=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=rt(),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?bt(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})]})},Dx=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(an,{});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(Oa,{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(Oa,{item:c,t:n,totalWorks:i},c.id))})]})]})},Oa=({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})]})},Wa="(max-width: 768px)";function Ux(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(Wa).matches);return g.useEffect(()=>{const i=window.matchMedia(Wa),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const Vx=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var O;const a=Ee(),{convert:l}=Me(),d=Ux(),[c,p]=g.useState(null),[h,m]=g.useState(null),[u,f]=g.useState(!1),[x,v]=g.useState("detail"),[b,_]=g.useState([]),[y,w]=g.useState(!1),j=g.useCallback(async F=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){_([]);return}w(!0);try{if(e.getCollectionCatalogs){const A=await e.getCollectionCatalogs(F);_(A||[])}else if(e.getCollectionCatalog){const A=await e.getCollectionCatalog(F);_(A?[{resource_id:"",data:A}]:[])}}catch{_([])}finally{w(!1)}},[e]),k=g.useCallback(async F=>{if(i){i(F);return}p(F),m(null),_([]),v("detail"),f(!0);try{const A=await e.getItem(F.id);A&&(m(A),A.type==="collection"&&j(F.id))}catch(A){console.error("加载详情失败:",A)}finally{f(!1)}},[e,i,j]),C=g.useCallback(async F=>{m(null),_([]),v("detail"),f(!0);try{const A=await e.getItem(F);A&&(m(A),p({id:F,title:A.title||F,type:A.type||"book"}),A.type==="collection"&&j(F))}catch(A){console.error("导航失败:",A)}finally{f(!1)}},[e,j]),$=typeof(h==null?void 0:h.text_count)=="number"&&h.text_count>0,S=(h==null?void 0:h.type)==="collection"&&(b.length>0||y)||(h==null?void 0:h.type)==="work"&&$,E=d&&(u||h),N=g.useCallback(()=>{p(null),m(null),_([]),v("detail")},[]),z=t.jsx(t.Fragment,{children:u?t.jsx(an,{}):h?t.jsxs(t.Fragment,{children:[(S||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:[S&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>v("detail"),style:fi(x==="detail"),children:a.detailTab.basicInfo}),h.type==="collection"&&y&&b.length===0&&t.jsxs("button",{onClick:()=>{},style:fi(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),h.type==="collection"&&b.map(F=>t.jsx("button",{onClick:()=>v(`catalog:${F.resource_id}`),style:fi(x===`catalog:${F.resource_id}`),children:F.short_name?`${l(F.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},F.resource_id)),h.type==="work"&&$&&t.jsx("button",{onClick:()=>v("collated"),style:fi(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(ko,{data:h,transport:e,onNavigate:C}):x.startsWith("catalog:")?t.jsx(wo,{data:(O=b.find(F=>`catalog:${F.resource_id}`===x))==null?void 0:O.data,onNavigate:C}):x==="collated"?t.jsx(Zo,{id:h.id,transport:e,onNavigate:C}):null})]}):t.jsx(qr,{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:E?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:N,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:z})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Ar,{transport:e,onEntryClick:k,hideModeIndicator:n}),!h&&t.jsx(qr,{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(Ar,{transport:e,onEntryClick:k,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:z})]})};function fi(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 Gx=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[h,m]=g.useState(null),[u,f]=g.useState("horizontal"),[x,v]=g.useState(!0),b=g.useRef(null),_=g.useCallback(k=>{p(new Set(k))},[]),y=g.useCallback(k=>{if(p(C=>{const $=new Set(C);return $.has(k)?$.delete(k):($.clear(),$.add(k)),$}),b.current){const C=b.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:u==="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(Uo,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:h,onCharClick:y,onCharHover:m})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:b,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:u==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Ko,{pageData:e,punctuations:j,selectedCharIds:c,hoveredCharId:h,onSelectionChange:_,onCharClick:y,onCharHover:m,mode:u,showPunctuation:x})]})]})]})},Yx=e=>typeof e=="string"&&Array.from(e).length===1,Kx=new Set(["point","break","heading"]),qx=/^#{1,6}$/;function Xx(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;if(typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!Yx(s.pre_char)||s.kind!=null&&!Kx.has(s.kind)||s.pos!=null&&s.pos!=="after"&&s.pos!=="before")continue;const a={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};if(!(s.kind==="break"&&s.pos==="before")){if(s.kind==="heading"){if(s.pos!=="before"||!qx.test(s.mark))continue;typeof s.label=="string"&&s.label.trim()&&(a.label=s.label.trim()),s.toc===!1&&(a.toc=!1)}i.push(a)}}return i}function Zx(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 jd=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function lt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const Jx=new Set(["main","solo","jz_r","jz_l"]),Qx=new Set(["body","banxin","blank"]);function eb(e){const n={};return typeof e.lane=="string"&&Jx.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 tb(e){const n={};typeof e.kind=="string"&&Qx.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 wr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function nb(e){return typeof e=="string"&&Array.from(e).length===1}function vd(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"||!jd.test(a)){i.badAnchor++;continue}if(!nb(l)){i.badChar++;continue}if(d!==void 0&&d!=="异体"){i.badWhy++;continue}n.set(a,l)}return{map:n,dropped:i}}function kd(e){return vd(e).map}function ib(e,n,i){var h,m,u,f,x,v,b,_,y,w;const o=i==null?null:kd(i),s=new Map,a=new Map;for(const j of wr(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 $=C==null?void 0:C.box;typeof(C==null?void 0:C.a)=="string"&&Array.isArray($)&&$.length===4&&$.every(S=>lt(S)!==void 0)&&a.set(C.a,[$[0],$[1],$[0]+$[2],$[1]+$[3]])}}}const l=[],d=new Map,c=new Map;for(const j of wr(e)){const k=lt(j.page);k!==void 0&&typeof j.label=="string"&&j.label&&d.set(k,j.label)}for(const j of wr(e)){const k=lt(j.page);if(k===void 0)continue;const C=[];for(const S of Array.isArray(j.columns)?j.columns:[]){const E=lt(S==null?void 0:S.col);if(E===void 0)continue;const N=[];for(const O of Array.isArray(S.cells)?S.cells:[]){const F=jd.exec(String((O==null?void 0:O.a)??""));if(!F||typeof O.c!="string")continue;const A=parseInt(F[3],10),I=o==null?void 0:o.get(O.a);N.push({id:O.a,char:O.c,slot:A,pos:A,sub:F[4]||null,bbox:a.get(O.a)??null,...eb(O),...I!==void 0&&I!==O.c?{norm:I}:{}})}const z=tb(S);(N.length>0||z.kind==="blank")&&C.push({col:E,chars:N,...z})}if(!C.some(S=>S.chars.length>0)){C.length>0&&c.set(k,C);continue}C.sort((S,E)=>S.col-E.col);const $=s.get(k);l.push({page:k,seq:String(((h=$==null?void 0:$.canvas)==null?void 0:h.seq)??""),width:lt((m=$==null?void 0:$.canvas)==null?void 0:m.width)??lt((u=$==null?void 0:$.image)==null?void 0:u.width)??0,height:lt((f=$==null?void 0:$.canvas)==null?void 0:f.height)??lt((x=$==null?void 0:$.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((b=k.canvas)==null?void 0:b.width)??lt((_=k.image)==null?void 0:_.width)??0,height:lt((y=k.canvas)==null?void 0:y.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 rb=({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(m=>t.jsx(ob,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:u=>p(c===u?null:u),onNavigate:n},m.name))})]})},ob=({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 m=h.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.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(sb,{category:p,expanded:o===h,onToggle:()=>s(h),onNavigate:a},p.name)})})]})},sb=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,h,m,u;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=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((u=e.stats)==null?void 0:u.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(Fa,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(Fa,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},Fa=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ne(),a=rt(),[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:m=>{m.metaKey||m.ctrlKey||(m.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})})]})},_t=({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:lb,children:"AI"}),n&&t.jsx("button",{onClick:n,style:ab,children:a.action.save})]})]}),s]})},ab={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},lb={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},xt=({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"}})]}),sn=({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"}})},Ni=({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 cb(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const ki=({value:e,onChange:n,label:i})=>{const[o,s]=g.useState(!1),a=g.useRef(null),l=cb(e||"");return g.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ha,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(Ni,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ha,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"}})]})},Ha={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function db(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function pb(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const wd=({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=m=>{n(e.filter((u,f)=>f!==m)),s===m&&a(null)},c=(m,u,f)=>{const x=[...e];x[m]={...x[m],[u]:f},n(x)},p=(m,u)=>{const f=[...e];f[m]={...f[m],type:u,id:"",name:""},n(f),u==="bookID"&&i&&i(x=>{const v=[...e];v[m]={...v[m],id:x.id,name:x.title,type:"bookID"},n(v)})},h=m=>{i&&i(u=>{const f=[...e];f[m]={...f[m],id:u.id,name:u.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,u)=>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===u?null:u),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===u?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:m.name||`${o.editor.sourcePlaceholder} ${u+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:db(m.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:pb(m.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(u)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===u&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(u,"bookID"),style:{...Da,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(u,"url"),style:{...Da,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})]})]})]}),m.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:Pt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[u]={...f[u],type:"",id:"",name:""},n(f)},style:Ua,children:o.action.changeType})]}),m.id&&m.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:m.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>h(u),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(u),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})]})]})}),m.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:Pt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[u]={...f[u],type:"",id:"",name:""},n(f)},style:Ua,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:f=>c(u,"name",f.target.value),placeholder:o.editor.sourceNamePlaceholder,style:mn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:f=>c(u,"id",f.target.value),placeholder:"https://...",style:mn})]})]}),m.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:{...Pt,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:Pt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:f=>c(u,"details",f.target.value),placeholder:o.editor.detailsPlaceholder,style:mn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:f=>c(u,"position",f.target.value),placeholder:"如: 卷三, p.52",style:mn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:f=>c(u,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:mn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Pt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:f=>c(u,"processor_version",f.target.value),placeholder:"如: v0.1",style:mn})]})]})]})]})})]},u)),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})]})]})},Pt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},mn={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"},Da={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"},Ua={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Sd(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 _d(e){return!e||e.length===0?"":JSON.stringify(e)}const $d=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:h,onLinkEntity:m,onUnlinkEntity:u,onViewEntity:f,onCreateAndLink:x,onSaveRelations:v})=>{const b=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:b.section.relations})]}),v&&t.jsx("button",{onClick:v,style:ub,children:b.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Pn,{direction:"up",title:b.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>u("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(Pn,{direction:"up",title:b.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>u("collectionId"),onLink:()=>m("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),a&&h&&h.length>0&&t.jsx(hn,{direction:"horizontal",title:`${b.relation.siblingVersions} (${h.length})`,entities:h,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:b.relation.addVersionForWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Pn,{direction:"up",title:b.relation.parentWork,entity:o,onView:f,onUnlink:()=>u("parentWorkId"),onLink:()=>m("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),d&&d.length>0&&t.jsx(hn,{direction:"down",title:`${b.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:b.action.addSubWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),c&&c.length>0&&t.jsx(hn,{direction:"down",title:`${b.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:b.action.addCollectionImpl,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),t.jsx(hn,{direction:"down",title:`${b.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:b.action.addVersion,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Pn,{direction:"up",title:b.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>u("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(Pn,{direction:"up",title:b.relation.parentCollection,entity:s,onView:f,onUnlink:()=>u("parentCollectionId"),onLink:()=>m("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(hn,{direction:"down",title:`${b.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:b.action.addSubCollection,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),t.jsx(hn,{direction:"down",title:`${b.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:b.action.addBook,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]})]})]})},Pn=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:h,unlinkLabel:m})=>{const u=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:u,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:Cd(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(Va,{onClick:()=>o(i),title:h,children:"👁️"}),t.jsx(Va,{onClick:s,title:m,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(Xr,{onClick:a,children:d}),t.jsx(Xr,{onClick:l,primary:!0,children:c})]})]})},hn=({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"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",u=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:m}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[u.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:Cd(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(Xr,{onClick:s,primary:!0,children:["+ ",a]})})]})},Va=({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}),Xr=({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 Cd(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const ub={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},zd=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[h,m]=g.useState(""),u=p?l.filter(b=>b.id!==p):l;g.useEffect(()=>{e&&(m(""),d(""))},[e]);const f=b=>{m(b),d(b)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",v=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:mb,children:t.jsxs("div",{style:hb,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:gb,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:h,onChange:b=>f(b.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:fb})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:Sr,children:"搜索中..."}):u.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:u.map(b=>t.jsxs("div",{onClick:()=>o(b),style:xb,children:[t.jsx("span",{style:{fontSize:"16px"},children:v}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[b.title,b.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:b.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[b.id,b.author&&` · ${b.author}`,b.dynasty&&` · ${b.dynasty}`]})]})]},b.id))}):h?t.jsxs("div",{style:Sr,children:["未找到匹配的",x]}):t.jsxs("div",{style:Sr,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:bb,children:["创建新",x,"并关联"]})]})]})})},mb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},hb={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")},gb={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},fb={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"},xb={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},Sr={padding:"20px",textAlign:"center",color:r("desc-fg")},bb={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Ga={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},yb={work:"📜",book:"📖",collection:"📚",entity:"👤"},Nd=({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 u,f;(u=c.current)==null||u.focus(),(f=c.current)==null||f.select()},100))},[e,o==null?void 0:o.title]);const p=u=>{u.key==="Enter"&&l.trim()?h():u.key==="Escape"&&a()},h=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const m=()=>{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`创建新${Ga[n]}`}};return t.jsx("div",{style:jb,onClick:u=>{u.target===u.currentTarget&&a()},children:t.jsxs("div",{style:vb,onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:yb[n]}),t.jsx("span",{children:m()})]}),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:u=>d(u.target.value),onKeyDown:p,placeholder:`请输入${Ga[n]}名称...`,style:kb})]}),((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:wb,children:"取消"}),t.jsx("button",{onClick:h,disabled:!l.trim(),style:{...Sb,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},jb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},vb={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")},kb={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"},wb={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Sb={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function _b(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Td(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function $b(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 Id=({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[m,u]=g.useState(""),[f,x]=g.useState([]),[v,b]=g.useState(!1),[_,y]=g.useState("recent");g.useEffect(()=>{e&&(u(""),x([]),y(o.length>0?"recent":"search"))},[e,o.length]),g.useEffect(()=>{if(!m.trim()){x([]);return}const S=setTimeout(async()=>{b(!0);try{x(await h(m,i))}catch{x([])}finally{b(!1)}},300);return()=>clearTimeout(S)},[m,i,h]);const w=g.useCallback(S=>{u(S.target.value),S.target.value.trim()&&y("search")},[]),j=g.useCallback(S=>s?S.filter(E=>E.id!==s):S,[s]);if(!e)return null;const k=n||(i==="all"?"选择实体":`选择${Td(i)}`),C=j(o),$=j(f);return t.jsx("div",{style:zb,children:t.jsxs("div",{style:Nb,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:Tb,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:m,onChange:w,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Ib}),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(Ya,{active:_==="recent",onClick:()=>y("recent"),children:["最近使用 (",C.length,")"]}),t.jsxs(Ya,{active:_==="search",onClick:()=>y("search"),children:["搜索结果 ",$.length>0&&`(${$.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:_==="recent"&&C.length>0?t.jsx(Ka,{entities:C,onSelect:d}):m.trim()?v?t.jsx(_r,{message:"搜索中..."}):$.length>0?t.jsx(Ka,{entities:$,onSelect:d}):t.jsx(_r,{message:"未找到匹配的结果"}):t.jsx(_r,{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:Rb,children:l||"创建新实体"})]})]})})},Ya=({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}),Ka=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Cb,{entity:i,onClick:()=>n(i)},i.id))}),Cb=({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:_b(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:$b(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Td(e.type)})]})},_r=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),zb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Nb={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")},Tb={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Ib={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"},Rb={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Eb={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},Lb={work:"📜",collection:"📚",book:"📖",entity:"👤"},Rd=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:h,relations:m,onRelationsChange:u})=>{var J;const f=Ee(),[x,v]=g.useState(!1),[b,_]=g.useState("work"),[y,w]=g.useState(""),[j,k]=g.useState(""),[C,$]=g.useState([]),[S,E]=g.useState(!1),[N,z]=g.useState(!1),[O,F]=g.useState("work"),[A,I]=g.useState(""),[P,K]=g.useState(),[oe,le]=g.useState(!1),[H,de]=g.useState(null),[U,te]=g.useState([]);g.useRef(null);const ve=e.type,fe=ve==="work",Ae=ve==="collection",B=ve==="book",me=g.useCallback((D,ye)=>{n({...e,[D]:ye})},[e,n]),ze=g.useCallback((D,ye)=>{w(D),_(ye),k(f.editor.selectToLink+f.indexType[ye]),$([]),v(!0)},[f]),we=g.useCallback(D=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,D)},[o,e.id]),De=g.useCallback(D=>{s==null||s(D.id,D.type)},[s]),Pe=g.useCallback((D,ye,ue)=>{const ge={...ue,author:(ue==null?void 0:ue.author)||e.author,dynasty:ue==null?void 0:ue.dynasty};F(ye),I(D),K(ge),z(!0)},[e.author]),G=g.useCallback((D,ye)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,A,{type:O,title:D,inheritData:ye}),z(!1)},[o,e.id,A,O]),he=g.useCallback(D=>{if(!D.trim()){$([]);return}E(!0),o!=null&&o.searchEntities&&o.searchEntities(D,b).then(ye=>{$(ye),E(!1)}).catch(()=>{$([]),E(!1)})},[o,b]),q=g.useCallback(D=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,y,D.id),v(!1)},[o,e.id,y]),se=g.useCallback(()=>{i()},[i]),Y=g.useCallback(D=>{de(()=>D),le(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(te).catch(()=>{})},[o]),M=g.useCallback((D,ye)=>o!=null&&o.searchEntities?o.searchEntities(D,ye==="all"?void 0:ye):Promise.resolve([]),[o]),X=g.useCallback(D=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(D),te(ye=>[D,...ye.filter(ue=>ue.id!==D.id)].slice(0,10)),H==null||H(D),le(!1),de(null)},[o,H]);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:Lb[ve]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(Ni,{children:e.id}),t.jsx(Ni,{color:Eb[ve],children:f.indexType[ve]})]})}),t.jsx(_t,{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(ki,{label:fe?f.editor.workTitle:Ae?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:D=>me("title",D)}),B&&t.jsx(ki,{label:f.editor.belongsToWork,value:e.workName||"",onChange:D=>me("workName",D)}),t.jsx(xt,{label:f.editor.authorLabel,value:e.author||"",onChange:D=>me("author",D)}),t.jsx(xt,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:D=>me("publicationYear",D)}),(B||Ae)&&t.jsx(ki,{label:f.editor.containedIn,value:e.collection||"",onChange:D=>me("collection",D)}),(B||Ae)&&t.jsx(xt,{label:f.editor.holderLabel,value:e.holder||"",onChange:D=>me("holder",D)}),(B||Ae)&&t.jsx(xt,{label:B?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:D=>me("pages",D)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(xt,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:D=>me("firstImage",D)})})]})}),t.jsx(_t,{title:f.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(sn,{value:e.description||"",onChange:D=>me("description",D),placeholder:f.editor.descriptionPlaceholder})}),(((J=e.additional_works)==null?void 0:J.length)||0)>0&&t.jsx(_t,{title:f.section.additionalWorks,onSave:i,children:t.jsx(Ab,{items:e.additional_works||[],onChange:D=>me("additional_works",D)})}),t.jsx(_t,{title:f.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Mb,{items:e.indexed_by||[],onChange:D=>me("indexed_by",D)})}),t.jsx(_t,{title:f.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Pb,{items:e.emendated_by||[],onChange:D=>me("emendated_by",D)})}),t.jsx(_t,{title:f.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(Ir,{items:e.resources||[],onChange:D=>me("resources",D),onDownload:p,downloadStatuses:h,filterType:"text"})}),t.jsx(_t,{title:f.section.imageResources,onSave:i,children:t.jsx(Ir,{items:e.resources||[],onChange:D=>me("resources",D),onDownload:p,downloadStatuses:h,filterType:"image"})}),t.jsx(_t,{title:f.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(wd,{items:Sd(e.sources||""),onChange:D=>me("sources",_d(D)),onOpenEntityPicker:Y})}),(B||Ae)&&t.jsx(_t,{title:f.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(sn,{value:e.provenance||"",onChange:D=>me("provenance",D),placeholder:f.editor.provenancePlaceholder})}),B&&t.jsx(_t,{title:f.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(sn,{value:e.otherEditions||"",onChange:D=>me("otherEditions",D),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx($d,{entityType:ve,entityId:e.id,entityTitle:e.title,parentWork:m==null?void 0:m.parentWork,parentCollection:m==null?void 0:m.parentCollection,belongsToWork:m==null?void 0:m.belongsToWork,belongsToCollection:m==null?void 0:m.belongsToCollection,childWorks:m==null?void 0:m.childWorks,childCollections:m==null?void 0:m.childCollections,containedBooks:m==null?void 0:m.containedBooks,siblingBooks:m==null?void 0:m.siblingBooks,onLinkEntity:ze,onUnlinkEntity:we,onViewEntity:De,onCreateAndLink:Pe,onSaveRelations:se}),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(zd,{isOpen:x,entityType:b,title:j,onSelect:q,onCancel:()=>v(!1),onCreate:()=>{v(!1),Pe(y,b)},searchResults:C,onSearch:he,isLoading:S,excludeId:e.id}),t.jsx(Nd,{isOpen:N,entityType:O,relationField:A,inheritData:P,onConfirm:G,onCancel:()=>z(!1)}),t.jsx(Id,{isOpen:oe,title:f.action.selectBookOrWork,filterType:"all",recentEntities:U,excludeId:e.id,onSelect:X,onCancel:()=>{le(!1),de(null)},onSearch:M})]})};function Ab({items:e,onChange:n}){const i=Ee(),o=(l,d,c)=>{const p=e.map((h,m)=>m===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(xt,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(xt,{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 Ed({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Ee(),[a,l]=g.useState(null),d=(h,m,u)=>{const f=e.map((x,v)=>v===h?{...x,[m]:u||void 0}:x);n(f)},c=h=>{n(e.filter((m,u)=>u!==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,m)=>{const u=a===m;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:u?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(u?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:u?"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(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!u&&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]}),u&&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(xt,{label:s.label.sourceName,value:h.source,onChange:f=>d(m,"source",f)}),t.jsx(xt,{label:s.label.sourceBid,value:h.source_bid||"",onChange:f=>d(m,"source_bid",f)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(xt,{label:s.label.titleInfo,value:h.title_info||"",onChange:f=>d(m,"title_info",f)}),t.jsx(xt,{label:s.label.authorInfo,value:h.author_info||"",onChange:f=>d(m,"author_info",f)})]}),t.jsx(xt,{label:s.label.edition,value:h.edition||"",onChange:f=>d(m,"edition",f)})]}),t.jsx(sn,{value:h.summary||"",onChange:f=>d(m,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(sn,{value:h.comment||"",onChange:f=>d(m,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(sn,{value:h.additional_comment||"",onChange:f=>d(m,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),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 Mb({items:e,onChange:n}){const i=Ee();return t.jsx(Ed,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Pb({items:e,onChange:n}){const i=Ee();return t.jsx(Ed,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function Ld(e){var d,c,p,h,m,u,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=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((u=e.page_count)==null?void 0:u.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(b=>b.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 Bb(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:m,renderSectionActions:u,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:b,headerExtra:_,className:y,style:w}=e,j=Ee(),[k,C]=g.useState(s),$=a?s:k;g.useEffect(()=>{s!==k&&C(s)},[s]);const S=g.useCallback(()=>{const I=$==="view"?"edit":"view";a?a(I):C(I)},[$,a]),[E,N]=g.useState(null);g.useEffect(()=>{i&&o&&o.getItem(i).then(I=>{I&&N(I)})},[i,o]);const z=n||E,O=g.useMemo(()=>z?Ld(z):null,[z]),F=a||!n?t.jsx("button",{onClick:S,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:$==="edit"?r("accent-bg"):"transparent",color:r($==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:$==="view"?j.common.switchToEdit:j.common.switchToView,children:$==="view"?j.common.modeEdit:j.common.modeView}):null,A=t.jsxs(t.Fragment,{children:[F,_]});return!z&&!O?t.jsx(an,{}):$==="view"?t.jsx(ko,{data:z,transport:o,onNavigate:p?I=>p(I):void 0,renderLink:h,headerExtra:A,className:y,style:w}):O?t.jsxs("div",{className:y,style:w,children:[A&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:A}),t.jsx(Rd,{data:O,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:u,onDownloadResource:f,downloadStatuses:x,relations:v,onRelationsChange:b})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:j.common.noData})},Wb=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Ad=({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(""),[m,u]=g.useState("idle"),[f,x]=g.useState(""),v=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),h(""),u("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var y;return(y=v.current)==null?void 0:y.focus()},100)},[a]),g.useEffect(()=>{if(m==="success"){const y=setTimeout(n,2e3);return()=>clearTimeout(y)}},[m,n]),g.useEffect(()=>{if(!e)return;const y=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[e,n]);const b=async()=>{if(!(!a||!d.trim())){u("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),u("success")}catch(y){u("error"),x(y instanceof Error?y.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const _=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:Fb,onClick:y=>{y.target===y.currentTarget&&n()},children:t.jsxs("div",{style:Hb,onClick:y=>y.stopPropagation(),children:[t.jsxs("div",{style:Db,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Ub,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:qb,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:Wb.map(y=>t.jsxs("button",{onClick:()=>l(y.value),style:{...Vb,...a===y.value?Gb:{}},children:[t.jsx("span",{children:y.icon})," ",s(`feedback.submitType.${y.value}`)]},y.value))}),t.jsx("textarea",{ref:v,value:d,onChange:y=>c(y.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...Yb,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:y=>h(y.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||m==="submitting","aria-label":s("feedback.contactLabel"),style:Zb}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:Xb,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:b,disabled:!_,style:{...Kb,opacity:_?1:.6,cursor:_?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Fb={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Hb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},Db={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Ub={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Vb={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"},Gb={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Yb={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"},Kb={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},qb={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},Xb={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},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"},Zr="--bim-feedback-fab-offset",Jr=48,Jb=16,Qb=({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(Zr,`calc(${c+Jr+Jb}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Zr)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...ey,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(Ad,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},ey={position:"fixed",width:`${Jr}px`,height:`${Jr}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"},ty=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Md=({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,m]=g.useState(""),u=g.useRef(null);g.useEffect(()=>{i&&setTimeout(()=>{var v;return(v=u.current)==null?void 0:v.focus()},100)},[i]);const f=async()=>{if(!(!i||!s.trim())){p("submitting"),m("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(v){p("error"),m(v instanceof Error?v.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:qa,children:t.jsxs("div",{style:sy,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:ay,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:qa,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:ty.map(v=>t.jsxs("button",{onClick:()=>o(v.value),style:{...ny,...i===v.value?iy:{}},children:[t.jsx("span",{children:v.icon})," ",n(`feedback.submitType.${v.value}`)]},v.value))}),t.jsx("textarea",{ref:u,value:s,onChange:v=>a(v.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...ry}}),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:cy}),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:{...oy,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:ly,children:h})]})},qa={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},ny={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"},iy={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},ry={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"},oy={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},sy={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},ay={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},ly={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},cy={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 Xa(e){return typeof e=="function"?e():e??"/api/feedback"}const Pd=({resourceId:e,apiUrl:n})=>{const{t:i}=ne(),[o,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=Xa(n);l(!0);try{const m=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();m.success&&s(m.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const h=Xa(n),m=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const u=await m.json().catch(()=>null);throw new Error((u==null?void 0:u.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Jo,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Md,{onSubmit:c})})]})},Gi=8;async function Yi(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 dy=Ri["zh-Hant"].relation,py=Ri["zh-Hant"].lossStatus,uy=Ri["zh-Hant"].resourceKind,Ki=Sn("zh-Hant"),Qo=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Za(e,n=Ki){return e?Qo(dy,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function my(e,n=Ki){return Qo(py,e)?n(`detail.lossStatus.${e}`):e}function hy(e,n=Ki){return Qo(uy,e)?n(`detail.resourceKind.${e}`):""}function es({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=fo(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=Ki){var c,p;const o=ho(e,n),s=o.mirrors.map(h=>({key:h.key,label:h.label,description:h.description,rows:h.items.filter(m=>m.group_role!=="mirror"),mirrors:h.items.filter(m=>m.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 Od(e,n){const i=(e.url?vn(e.url):void 0)||e.name,o=Al(e,n);return o?`${i}(${o})`:i}function ts({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ne(),[a,l]=g.useState(!1),d=Ii(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(Od(e,n)),h=kn(e),m=Mi(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const u=(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:"↗"}),u]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,u]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(To,{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(u=>!u),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function Wd({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(ts,{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=kn(a),c=o(Od(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 Vn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Qr(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Vn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const Ja=12,gy=60,Fd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var q,se,Y;const{t:c,convert:p,messages:h}=ne(),m=g.useMemo(()=>xo({_books:e._books}),[e._books]),[u,f]=g.useState(new Map),[x,v]=g.useState(!1),[b,_]=g.useState(""),[y,w]=g.useState(!1),j=m.length<=gy,k=j||x||!!b||y,C=g.useMemo(()=>k?m:m.slice(0,Ja),[m,k]);g.useEffect(()=>{if(!n||C.length===0)return;const M=C.filter(J=>!u.has(J));if(M.length===0)return;let X=!1;return Yi(M,Gi,J=>n.getItem(J).then(D=>{var ue;const ye=D??{};return[J,{id:J,title:ye.title,edition:ye.edition,resources:ye.resources,publication_info:ye.publication_info,current_location:ye.current_location,lineage:ye.lineage,measure_info:ye.measure_info,summary:fy((ue=D==null?void 0:D.description)==null?void 0:ue.text)}]}).catch(()=>[J,{id:J}]),()=>X).then(J=>{X||f(D=>{const ye=new Map(D);for(const[ue,ge]of J)ye.set(ue,ge);return ye})}),()=>{X=!0}},[n,C,u]);const $=g.useMemo(()=>m.map(M=>u.get(M)??{id:M}),[m,u]),S=m.length>0&&m.every(M=>u.has(M)),E=!!n&&C.some(M=>!u.has(M)),N=j||k,z=g.useMemo(()=>Pl($,e.version_graph,{era:b,scanOnly:y,sort:N?"year":"default"}),[$,e.version_graph,b,y,N]),O=x?z.rows:z.rows.slice(0,Ja),F=z.allRows.filter(M=>M.hasImage).length,A=z.allRows.reduce((M,X)=>{var J;return M+(((J=X.copies)==null?void 0:J.length)??0)},0),I=g.useMemo(()=>(e._related||[]).map(M=>({...M,title:M.title??""})),[e._related]),P=I.filter(M=>M.relation==="collected_in"),K=g.useMemo(()=>{const M=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],X=J=>{const D=M.indexOf(J??"");return D<0?M.length:D};return I.filter(J=>J.relation!=="collected_in").map((J,D)=>({r:J,i:D})).sort((J,D)=>X(J.r.relation)-X(D.r.relation)||J.i-D.i).map(J=>J.r)},[I]),oe=g.useMemo(()=>{const M=ho(e.resources,e.resource_groups);return[...M.mirrors.flatMap(X=>X.items.map(J=>({r:J,kind:p(X.label)}))),...M.buckets.flatMap(X=>X.items.map(J=>({r:J,kind:p(hy(X.key,c))})))]},[e.resources,e.resource_groups,p,c]),le=e.indexed_by||[],H=e.emendated_by||[],de=g.useMemo(()=>{var L,ie,je;const M=[],X=(ie=(L=e.authors)==null?void 0:L[0])==null?void 0:ie.dynasty;X&&M.push({label:c("workPage.fact.written"),value:p(X)});const J=Ht(e,h.unit.juan);if(J){const W=(je=e.juan_count)==null?void 0:je.description;M.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(J),W&&W!==J?t.jsxs("span",{className:"bim-d-meta",children:["(",p(W),")"]}):null]})})}e.loss_status&&M.push({label:c("workPage.fact.loss"),value:p(my(e.loss_status,c))});const D=z.allRows.filter(W=>W.sortYear!=null),ye=D.length>0?D.reduce((W,ae)=>W.sortYear<=ae.sortYear?W:ae):null;ye!=null&&ye.era.era?M.push({label:c("workPage.fact.earliest"),value:p([ye.era.era,ye.era.reign].filter(Boolean).join(" ")),title:ye.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):E&&M.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),H.length&&M.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:H.length})});const ue=Qa(e.additional_titles);ue.length&&M.push({label:c("workPage.fact.alias"),value:ue.map(p).join("、")});const ge=Qa(e.attached_texts);ge.length&&M.push({label:c("workPage.fact.attached"),value:ge.map(p).join("、")});const Ie=(e.additional_works||[]).map(W=>p(W.book_title)+(W.n_juan!=null?` ${W.n_juan}${h.unit.juan}`:""));return Ie.length&&M.push({label:c("workPage.fact.appendix"),value:Ie.join("、")}),M},[e,p,c,h,E,z.allRows,H.length]),te=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:S?F:0,label:c("workPage.stat.hasImage")},{value:le.length,label:c("workPage.stat.catalogs")}],ve=bo(e),fe=ve?[ve.l1,ve.l2,ve.l3,ve.l4].filter(Boolean).map(M=>p(M)):[],Ae=e.subtype?h.workSubtype[e.subtype]??p(e.subtype):"",B=t.jsx(Xn,{title:p(e.title),byline:t.jsx(es,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(st,{items:[...fe,ve!=null&&ve.source?c("workPage.classifiedBy",{source:p(ve.source.split("/")[0])}):"",Ae]}),description:(q=e.description)!=null&&q.text?t.jsxs(t.Fragment,{children:[t.jsx(Dt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(se=e.description.sources)!=null&&se.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(M=>({text:p(Sm(M)),href:_m(M)})).filter(M=>M.text).map((M,X)=>t.jsxs(g.Fragment,{children:[X>0?" · ":null,M.href?t.jsx("a",{href:M.href,target:"_blank",rel:"noopener noreferrer",children:M.text}):M.text]},X))}):null]}):void 0,stats:te,facts:de,readAction:s,foot:t.jsx(Zn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(Y=e.appendix)==null?void 0:Y.map((M,X)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(M.title)}),t.jsx(Dt,{text:M.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},X))}),me=z.eras.length>=2?[{key:"",label:c("catalog.all")},...z.eras.map(M=>({key:M,label:`${M} ${z.allRows.filter(X=>X.era.era===M).length}`}))]:[],ze=[];m.length&&ze.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),le.length&&ze.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:le.length}),P.length&&ze.push({id:"collected",label:c("workPage.sec.collected"),count:P.length}),K.length&&ze.push({id:"related",label:c("workPage.sec.related"),count:K.length}),oe.length&&ze.push({id:"resources",label:c("workPage.sec.resources"),count:oe.length});const we=m.length===0&&le.length===0,De=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(at,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(st,{items:[c("workPage.versionsTotal",{n:m.length-A}),S&&F?c("workPage.versionsWithImage",{n:F}):"",z.rows.length!==z.allRows.length?c("workPage.versionsCurrent",{n:z.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":E&&me.length===0&&m.length>1?"":void 0,children:[me.length>0&&t.jsx(Hi,{items:me,value:b,onChange:M=>{_(M),v(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(zc,{label:c("workPage.scanOnly"),checked:y,onChange:M=>{w(M),v(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(N?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Di(z.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:O.map(M=>{var X;return t.jsx(by,{row:M,measure:(X=u.get(M.id))==null?void 0:X.measure_info,loaded:u.has(M.id),onNavigate:i,renderLink:o},`${M.id}:${u.has(M.id)?"r":"p"}`)})})]}),O.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(b||y?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx($o,{total:z.rows.length,shown:O.length,unit:c("workPage.moreUnit"),onClick:()=>v(!0)}),z.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),le.length>0&&t.jsx(yy,{items:le,transport:n,onNavigate:i,renderLink:o}),we&&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")})})]}),Pe=(M,X)=>t.jsx(nt,{id:M,label:p(X),onNavigate:i,renderLink:o,dense:!0}),G=g.useMemo(()=>{const M=new Map;for(const X of K){const J=Za(X.relation,c);M.set(J,(M.get(J)??0)+1)}return M.size>1?[...M.entries()].sort((X,J)=>J[1]-X[1]).slice(0,4).map(([X,J])=>`${p(X)} ${J}`).join(" · "):void 0},[K,p,c]),he=t.jsxs(t.Fragment,{children:[t.jsx(on,{id:"collected",title:c("workPage.sec.collected"),items:P.map(M=>Pe(M.id,M.title))}),t.jsx(on,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:K.length}),sub:G,items:K.map(M=>t.jsxs(t.Fragment,{children:[Pe(M.id,M.title),t.jsx("span",{className:"bim-d-meta",title:M.note?p(M.note):void 0,children:p(Za(M.relation,c))})]}))}),t.jsx(on,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:oe.map(({r:M,kind:X})=>{const J=p((M.url?vn(M.url):void 0)||M.name),D=kn(M);return t.jsxs(t.Fragment,{children:[D?t.jsxs("a",{href:D,target:"_blank",rel:"noopener noreferrer",children:[J," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:J}),X&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:X})]})})})]});return t.jsx(qn,{railTop:a,back:l,nav:ze,railLinks:d,main:De,card:B,side:he})};function Qa(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function eo(e,n){return n((e.url?vn(e.url):void 0)||e.name)}function fy(e){var a;if(!e)return;const i=e.replace(/\*\*/g,"").split(/\n/)[0].trim().match(/[^。]+。?/g)??[],s=((i.length>1&&((a=i[0])!=null&&a.startsWith("《"))?i[1]:i[0])??"").trim();return s?s.length>120?`${s.slice(0,120)}…`:s:void 0}function xy({copies:e,onNavigate:n,renderLink:i}){const{t:o,convert:s}=ne(),a=new Map;for(const l of e){const d=l.locationName||(l.holders[0]?eo(l.holders[0],s):"")||"",c=a.get(d)??[];c.push(l),a.set(d,c)}return t.jsxs("span",{className:"bim-d-zt-copies",children:[o("workPage.sameEditionCopies",{n:e.length}),[...a].map(([l,d],c)=>t.jsxs(g.Fragment,{children:[c>0?";":"",l?`${s(l)} `:"",d.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0?" · ":"",t.jsx(nt,{id:p.id,label:p.callNumber||p.id,onNavigate:n,renderLink:i,dense:!0})]},p.id))]},l||c))]})}function by({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=e.copies??[],m=h.length&&e.locationName?l(e.locationName):p?eo(p,l):e.locationName?l(e.locationName):"",u=e.images[0],f=u?kn(u):void 0,x=e.images.map(v=>eo(v,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",className:h.length?"bim-d-zt-group":void 0,children:[t.jsxs("td",{className:h.length?"bim-d-zt-main bim-d-zt-rep":"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:" "}),h.length>0&&e.summary&&t.jsx("span",{className:"bim-d-zt-summary",children:l(e.summary)}),h.length>0&&t.jsx(xy,{copies:h,onNavigate:o,renderLink:s})]}),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${m?"":" bim-d-zt-blank"}`,children:[m||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),h.length>0&&e.callNumber&&t.jsx("span",{className:"bim-d-meta",style:{display:"block",fontSize:12},children:e.callNumber}),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&&(f?t.jsx("a",{className:"bim-d-flag",href:f,target:"_blank",rel:"noopener noreferrer",title:x,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:x,children:a("workPage.hasImage")}))})]})}function yy({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,m]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const u=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(u.length===0)return;let f=!1;return Promise.all(u.map(x=>n.getItem(x).then(v=>{var b,_;return[x,((_=(b=v==null?void 0:v.authors)==null?void 0:b[0])==null?void 0:_.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||m(new Map(x.filter(([,v])=>v)))}),()=>{f=!0}},[n,e]),t.jsx(at,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(st,{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((u,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(u.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:h.get(u.source_bid??"")?a(h.get(u.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(u.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(st,{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:yt(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:yt(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:yt(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 jy(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 vy(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 el(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 ky(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 wy(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,m]of Object.entries(e.node_groups))l.has(m)&&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 wi(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=wy(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,m=new Set,u=new Set;if(c){const j=new Map(n.map(N=>[N.id,N])),k=new Map((o.hypothetical_nodes??[]).map(N=>[N.id,N])),C=N=>{const z=j.get(N);if(z&&z.lineage)return(z.lineage.derived_from??[]).map(F=>F.ref);const O=k.get(N);return O?(O.derived_from??[]).map(F=>F.ref):[]},$=N=>k.has(N)?!h||h.has(N):!p||p.has(N),S=new Set,E=N=>{if(!S.has(N)){S.add(N);for(const z of C(N))a.has(z)||($(z)||(k.has(z)?u.add(z):j.has(z)&&m.add(z)),E(z))}};for(const N of n)p&&p.has(N.id)&&!a.has(N.id)&&E(N.id);for(const N of o.hypothetical_nodes??[])h&&h.has(N.id)&&E(N.id)}const f=n.filter(j=>!a.has(j.id)).filter(j=>!p||p.has(j.id)||m.has(j.id)).map(j=>{const k=vy(j,l);return k&&m.has(j.id)&&(k.bridge=!0),k}).filter(j=>j!==null),x=(o.hypothetical_nodes??[]).filter(j=>!h||h.has(j.id)||u.has(j.id)).map(j=>{const k=jy(j);return u.has(j.id)&&(k.bridge=!0),k}),v=[...f,...x],b=new Set(v.map(j=>j.id)),_=new Set,y=[],w=j=>{_.has(j.id)||!b.has(j.source)||!b.has(j.target)||(_.add(j.id),y.push(j))};for(const j of n)a.has(j.id)||!j.lineage||p&&!p.has(j.id)&&!m.has(j.id)||((j.lineage.derived_from??[]).forEach((k,C)=>{w(el(j.id,k,C))}),(j.lineage.related_to??[]).forEach((k,C)=>{w(ky(j.id,k,C))}));for(const j of o.hypothetical_nodes??[])h&&!h.has(j.id)&&!u.has(j.id)||(j.derived_from??[]).forEach((k,C)=>{w(el(j.id,k,C))});return{nodes:v,edges:y,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function Hd(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function Sy(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 Dd=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ne();if(!e.nodes.length)return t.jsx("div",{style:{...By,...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 m=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(m)),h.sort(m);const u=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:i,style:{...$y,...o},children:[e.title&&t.jsx("div",{style:Cy,children:a(e.title)}),e.description&&t.jsx("div",{style:zy,children:a(e.description)}),u.map(f=>t.jsx(tl,{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(tl,{label:s("lineage.otherGroup"),nodes:h,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},tl=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ne();return t.jsxs("div",{style:Ny,children:[t.jsx("div",{style:{...Ty,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(_y,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},_y=({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:{...Iy,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:Ry,children:[t.jsx("span",{style:Ey,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Ly,children:Hd(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Ay,children:[e.category&&t.jsx(Bn,{children:c(e.category)}),e.status==="lost"&&t.jsx(Bn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(Bn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(Bn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(Bn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:My,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Py,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:il,children:[t.jsx("div",{style:rl,children:d("lineage.sources")}),n.map(p=>{const h=o.get(p.source);return t.jsxs("div",{style:ol(p.confidence),children:[t.jsx("span",{style:sl,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(nl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:al,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:il,children:[t.jsx("div",{style:rl,children:d("lineage.related")}),i.map(p=>{const h=p.source===e.id?p.target:p.source,m=o.get(h);return t.jsxs("div",{style:ol(p.confidence),children:[t.jsx("span",{style:sl,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??h)}),t.jsx(nl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:al,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Bn=({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})},nl=({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},$y={fontSize:"14px",color:r("fg")},Cy={fontSize:"16px",fontWeight:600,marginBottom:"8px"},zy={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},Ny={marginBottom:"16px"},Ty={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},Iy={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},Ry={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Ey={fontSize:"15px",fontWeight:600},Ly={fontSize:"12px",color:r("muted")},Ay={marginBottom:"6px"},My={fontSize:"12px",color:r("muted"),margin:"2px 0"},Py={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},il={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},rl={fontSize:"11px",color:r("muted"),marginBottom:"2px"},ol=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),sl={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},al={fontSize:"11px",color:r("muted")},By={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},Ud=({selectedNodeId:e,...n})=>{const{t:i}=ne(),[o,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return Oy().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:cl,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:cl,children:[t.jsx("div",{children:ll(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:ll(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Wy,{modules:a,selectedNodeId:e,...n})};function ll(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 Oy(){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 Wy=({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:m,BaseEdge:u,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:v}=l,b=g.useMemo(()=>({lineage:C=>{var P,K,oe,le;const $=((P=C.data)==null?void 0:P.stepPosition)??.85,[S,E,N]=x({sourceX:C.sourceX,sourceY:C.sourceY,sourcePosition:C.sourcePosition,targetX:C.targetX,targetY:C.targetY,targetPosition:C.targetPosition,stepPosition:$,borderRadius:5}),z=!!((K=C.data)!=null&&K.isSibling),O=z?E:C.targetX-18,F=z?N:C.targetY-12,A=(oe=C.data)==null?void 0:oe.labelStyle,I=(le=C.data)==null?void 0:le.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(u,{id:C.id,path:S,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(${O}px,${F}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...I,...A},children:C.label})})]})}}),[u,f,x]),_=g.useMemo(()=>({version:C=>{const{t:$}=ne(),S=C.data,E=S.kind==="hypothetical",N=S.status==="lost",z=S.isSelected,O=S.bridge,F=S.borderColor??r("muted"),A=O||E?"dashed":"solid",I=O?.5:N?.6:1;return t.jsxs("div",{style:{background:r(O?"bg-subtle":"bg"),border:`2px ${A} ${z?r("primary"):F}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:I,boxShadow:z?r("shadow-node-selected"):E||O?"none":r("shadow-node")},title:O?$("lineage.bridgeTitle"):void 0,children:[t.jsx(h,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:E||!S.renderLink?S.label:S.renderLink(S.bookId,S.label)}),S.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:S.description}),S.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:Hd(S.yearText,void 0,S.uncertain)}),N&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:$("lineage.lost")}),t.jsx(h,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[h,m]),{convert:y}=ne(),{rfNodes:w,rfEdges:j}=g.useMemo(()=>Fy(e,v,n,a,y),[e,v,n,a,y]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:w,edges:j,nodeTypes:_,edgeTypes:b,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 Fy(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 m=e.nodes.map(_=>{const y=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??Dy(_)),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:y.x-160/2,y:y.y-90/2},data:j,draggable:!1,selected:w}}),u=.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[_,y]of x){if(y.length<=1)continue;const w=[...y].sort((k,C)=>{var E,N;const $=((E=c.node(k.target))==null?void 0:E.y)??0,S=((N=c.node(C.target))==null?void 0:N.y)??0;return $-S}),j=w.length;w.forEach((k,C)=>{const $=(C-(j-1)/2)*f;v.set(k.id,u+$)})}const b=e.edges.map(_=>Hy(_,v.get(_.id),s));return{rfNodes:m,rfEdges:b}}function Hy(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Uy(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 Dy(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Uy(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 cl={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},ns=({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:m})=>{var j;const{t:u,convert:f}=ne(),[x,v]=g.useState(n),b=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:u("lineage.collectionAll"),description:u("lineage.collectionAllDesc")}]]})(),y=!!(d&&_.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:u("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:m,children:[t.jsxs("div",{style:Vy,children:[t.jsx("button",{onClick:()=>b("list"),style:$r(x==="list"),children:u("lineage.modeList")}),t.jsx("button",{onClick:()=>b("graph"),style:$r(x==="graph"),children:u("lineage.modeGraph")}),y&&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:u("lineage.collectionLabel")}),_.map(([k,C])=>{const $=p==null?void 0:p[k];return t.jsxs("button",{onClick:()=>d==null?void 0:d(k),style:$r(l===k),title:C.description?f(C.description):void 0,children:[f(C.label),$!=null?` ${$}`:""]},k)})]})]}),y&&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(Dd,{graph:e,renderLink:i}):t.jsx(Ud,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},Vy={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},$r=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"}),dl=40,pl=2,Gy=9,Yy=new Set(["certain","consensus","probable","disputed"]);function Cr(e){if(!e)return["",""];const n=e.split(/[  ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Vd=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:h})=>{var ie,je,W,ae,V,re,_e,Le,He,qe,Xe;const m=Ee(),{t:u,convert:f}=ne(),[x,v]=g.useState(null),[b,_]=g.useState(new Map),[y,w]=g.useState([]),[j,k]=g.useState(new Map),[C,$]=g.useState(!1),[S,E]=g.useState("flow"),[N,z]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){v(null);return}let T=!1;return n.getItem(e.work_id).then(pe=>{!T&&pe&&pe.type==="work"&&v(pe)}).catch(()=>{}),()=>{T=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){z(null);return}let T=!1;return n.getLineageGraph(e.work_id).then(pe=>{T||z(pe&&pe.nodes.length>1?pe:null)}).catch(()=>{T||z(null)}),()=>{T=!0}},[n,e.work_id]),g.useEffect(()=>{const T=e._collections||[];if(!n||T.length===0){_(new Map);return}let pe=!1;return Promise.all(T.map(xe=>{const ke=xe.id;return n.getItem(ke).then(Ne=>[ke,Ne]).catch(()=>[ke,null])})).then(xe=>{if(pe)return;const ke=new Map;for(const[Ne,Se]of xe)Se&&ke.set(Ne,Se);_(ke)}),()=>{pe=!0}},[n,e._collections]);const O=g.useMemo(()=>{const T=new Set([...x?xo(x):[],...e.related_books||[]]);return T.add(e.id),[...T]},[x,e.related_books,e.id]),F=O.length-1;g.useEffect(()=>{if(!n||F<=0){w([]);return}const T=O.length<=dl,pe=T?O:O.slice(0,8);let xe=!1;return Promise.all(pe.map(ke=>ke===e.id?Promise.resolve({id:ke,title:e.title,edition:e.edition,year:_i(e)}):n.getItem(ke).then(Ne=>{const Se=Ne??{};return{id:ke,title:Se.title,edition:Se.edition,year:Ne?_i(Se):void 0}}).catch(()=>({id:ke})))).then(ke=>{if(xe)return;const Ne=ke.filter(Se=>Se.id===e.id||Se.title||Se.edition);T&&Ne.sort((Se,Ke)=>(Se.year??1/0)-(Ke.year??1/0)),w(Ne)}),()=>{xe=!0}},[n,O,F,e]);const A=e.lineage,I=g.useMemo(()=>[...((A==null?void 0:A.derived_from)||[]).filter(T=>T.ref_type==="book").map(T=>T.ref),...((A==null?void 0:A.related_to)||[]).map(T=>T.book_id)].filter(Boolean),[A]);g.useEffect(()=>{if(!n||I.length===0){k(new Map);return}let T=!1;return Promise.all(I.map(pe=>n.getItem(pe).then(xe=>[pe,{id:pe,title:xe==null?void 0:xe.title,edition:xe==null?void 0:xe.edition}]).catch(()=>[pe,{id:pe}]))).then(pe=>{T||k(new Map(pe))}),()=>{T=!0}},[n,I]);const P=g.useMemo(()=>Bd(e.resources,e.resource_groups,u),[e.resources,e.resource_groups,u]),K=P.groups.reduce((T,pe)=>T+pe.rows.length+pe.mirrors.length,0),oe=P.groups.length>0&&P.groups.every(T=>T.key==="_physical"),le=Kn(e),H=Hl(e),de=Ht(e,m.unit.juan),U=new Set((e._collections||[]).map(T=>Hn(T.vol).length).filter(T=>T>0)),te=T=>{var ke;const pe=(ke=e.base_edition)==null?void 0:ke.find(Ne=>Ne.book_id===T&&Ne.name);if(pe!=null&&pe.name)return pe.name;const xe=j.get(T);return(xe==null?void 0:xe.edition)||(xe==null?void 0:xe.title)||""},ve=g.useMemo(()=>{var Q,ee,Fe,We,Re;const T=[];H&&T.push({label:u("bookPage.fact.editionType"),value:f(H),title:e.edition_type||(Q=e.lineage)!=null&&Q.category?void 0:u("bookPage.inferredFromEdition")}),(ee=e.publication_info)!=null&&ee.details?T.push({label:u("bookPage.fact.publication"),value:f(e.publication_info.details)}):(le.era||le.reign)&&T.push({label:u("bookPage.fact.era"),value:f([le.era,le.reign].filter(Boolean).join(" ")),title:le.source==="edition"?u("bookPage.inferredFromEdition"):void 0}),de&&T.push({label:u("bookPage.fact.measure"),value:f(de)});const pe=(e._collections||[]).flatMap(be=>Hn(be.vol));pe.length&&T.push({label:u("bookPage.fact.volumes"),value:u("bookPage.volumesValue",{range:Pi(pe,m.unit.volume),unit:m.unit.volume,n:pe.length})});const xe=(((Fe=e.lineage)==null?void 0:Fe.derived_from)||[]).find(be=>be.relation==="底本"&&be.ref_type==="book");xe&&te(xe.ref)&&T.push({label:u("bookPage.fact.baseEdition"),value:t.jsx(nt,{id:xe.ref,label:f(te(xe.ref)),onNavigate:i,renderLink:o,dense:!0})});const ke=(e.base_edition||[]).filter(be=>be&&be.name);for(const be of["底本","配補","參校"]){if(be==="底本"&&xe&&te(xe.ref))continue;const Ye=ke.filter(Ce=>Ce.role===be);Ye.length&&T.push({label:f(be),value:Ye.map((Ce,Ve)=>t.jsxs(g.Fragment,{children:[Ve>0&&"、",Ce.book_id?t.jsx(nt,{id:Ce.book_id,label:f(Ce.name),onNavigate:i,renderLink:o,dense:!0}):f(Ce.name)]},Ve))})}const Ne=(e.provenance||[]).filter(be=>be&&be.institution),Se=(e.resources||[]).filter(be=>Ft(be).includes("physical"));if(Ne.length){T.push({label:u("bookPage.fact.holdings"),value:Ne.slice(0,2).map(Ce=>f(Ce.institution)).join("、")+(Ne.length>2?u("bookPage.andMorePlaces",{n:Ne.length}):"")});const be=Ne.filter(Ce=>Ce.call_number).slice(0,2).map(Ce=>`${f(Ce.institution)} ${Ce.call_number}`);be.length&&T.push({label:u("bookPage.fact.callNumber"),value:be.join(";")+(Ne.filter(Ce=>Ce.call_number).length>2?"…":"")});const Ye=Ne.flatMap(Ce=>Ce.seals||[]).filter(Boolean);Ye.length&&T.push({label:u("bookPage.fact.seals"),value:f(Ye.join("、"))})}else Se.length?T.push({label:u("bookPage.fact.holdings"),value:Se.slice(0,2).map(be=>f(be.name)).join("、")+(Se.length>2?u("bookPage.andMorePlaces",{n:Se.length}):"")}):(We=e.current_location)!=null&&We.name&&T.push({label:u("bookPage.fact.holdings"),value:f(e.current_location.name)});const Ke=e.physical_description;if(Ke){const be=[[u("bookPage.fact.leafStyle"),Ke.leaf_style],[u("bookPage.fact.binding"),Ke.binding],[u("bookPage.fact.dimensions"),Ke.dimensions],[u("bookPage.fact.condition"),Ke.condition]];for(const[Ye,Ce]of be)Ce&&Ce.trim()&&T.push({label:Ye,value:f(Ce)})}(Re=e.page_count)!=null&&Re.description&&T.push({label:m.label.pageCount,value:f(e.page_count.description)});const Oe=[...Ur(e.additional_titles),...Ur(e.attached_texts)];return Oe.length&&T.push({label:u("bookPage.fact.aliases"),value:Oe.map(f).join("、")}),T},[e,f,m,u,le,H,de,j,i,o]),fe=f(e.title),Ae=e.edition?f(e.edition):void 0,B=((ie=e.lineage)==null?void 0:ie.year_text)||"",me=t.jsx(Xn,{kind:u("bookPage.kind"),title:fe,subtitle:Ae,byline:t.jsx(es,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const T=[H?f(H):"",le.era?f([le.era,le.reign].filter(Boolean).join("")):"",de?f(de):""].filter(Boolean);return T.length?t.jsx("span",{className:"bim-d-tags",children:T.map((pe,xe)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(xe,2)}`,children:pe},xe))}):null})(),description:(je=e.description)!=null&&je.text?t.jsx(Dt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:zo((W=e.description)==null?void 0:W.text)?6:void 0,facts:ve,readAction:s,secondaryAction:s&&K>0&&!oe?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:u("bookPage.viewImages")}):void 0,foot:t.jsx(Zn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),ze=e._collections||[],we=(a==null?void 0:a.chapters)||[],De=f(we[0]&&Cr(we[0].title)[0].slice(-1)||"")||u("bookPage.chapterUnit"),Pe=u("bookPage.chapterCount",{n:we.length,unit:De}),G=!!((ae=A==null?void 0:A.derived_from)!=null&&ae.length||(V=A==null?void 0:A.related_to)!=null&&V.length||(re=e.appendix)!=null&&re.length),he=[],q=u(oe?"bookPage.sec.physical":"bookPage.sec.images");(we.length||P.text.length||l)&&he.push({id:"fulltext",label:u("bookPage.sec.fulltext"),count:we.length?Pe:void 0}),P.groups.length&&he.push({id:"images",label:q,count:K}),G&&he.push({id:"lineage",label:u("bookPage.sec.lineage")}),ze.length&&he.push({id:"collections",label:u("section.containedIn"),count:ze.length}),(_e=e.location_history)!=null&&_e.length&&he.push({id:"provenance",label:u("section.locationHistory")});const se=T=>(d==null?void 0:d(T))??null,Y=we[0],M=Y?se(Y.file):null,X=C?we:we.slice(0,Gy),J=(T,pe,xe)=>T?t.jsx("a",{className:xe,href:T.href??"#",onClick:T.onClick?ke=>{ke.metaKey||ke.ctrlKey||(ke.preventDefault(),T.onClick())}:void 0,children:pe}):t.jsx("span",{className:xe,children:pe}),D=t.jsxs(t.Fragment,{children:[(we.length>0||P.text.length>0||l)&&t.jsxs(at,{id:"fulltext",title:u("bookPage.sec.fulltext"),meta:we.length>0?t.jsx(st,{items:[Pe,(Le=a==null?void 0:a.source)!=null&&Le.name?u("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!Y&&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"})]}),Y&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:u("bookPage.readFrom",{ch:f(Cr(Y.title)[0])||u("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((Y.title||"").replace(/^第.+?[回章卷篇節节][  ]*/,""))}),J(M,t.jsxs(t.Fragment,{children:[u("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),we.length>1&&t.jsx("ul",{className:"bim-d-chap",children:X.map(T=>{const[pe,xe]=Cr(T.title);return t.jsx("li",{children:J(se(T.file),t.jsxs(t.Fragment,{children:[pe&&t.jsx("b",{children:f(pe)}),f(xe||T.file)]}))},T.file)})}),we.length>X.length&&t.jsx(Co,{label:u("detail.expandRest",{n:we.length-X.length,unit:De}),onClick:()=>$(!0)}),P.text.length>0&&t.jsxs(t.Fragment,{children:[(we.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:u("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:P.text.map((T,pe)=>t.jsx(ts,{item:T,siblings:P.text,listedVolumeCounts:U},`${T.id||T.url||T.name}-${pe}`))})})]})]}),P.groups.length>0&&t.jsx(at,{id:"images",title:q,meta:t.jsx(st,{items:[P.groups.length>1?u("bookPage.groupCount",{n:P.groups.length}):"",u("bookPage.placeCount",{n:K})]}),children:t.jsx(Wd,{groups:P.groups,listedVolumeCounts:U})}),G&&t.jsx(at,{id:"lineage",title:u("bookPage.sec.lineage"),meta:(He=A==null?void 0:A.derived_from)!=null&&He.length?u("bookPage.lineageMeta"):void 0,action:N?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":u("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":S==="flow",onClick:()=>E("flow"),children:u("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":S==="graph",onClick:()=>E("graph"),children:u("bookPage.viewGraph")})]}):void 0,children:S==="graph"&&N?t.jsx(ns,{graph:N,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(T,pe)=>t.jsx(nt,{id:T,label:f(pe),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(qy,{data:e,heading:Ae||fe,yearText:B,refName:te,onNavigate:i,renderLink:o})}),ze.length>0&&t.jsx(at,{id:"collections",title:u("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:ze.map((T,pe)=>{const xe=T.id,ke=Hn(T.vol),Ne=b.get(xe),Se=km(Ne);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:xe,label:Ne?f(Ne.title):xe,onNavigate:i,renderLink:o,dense:!0}),ke.length>0&&t.jsx(Ky,{volumes:ke,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Se?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:Se>0&&u("bookPage.totalOf",{n:Se,unit:m.unit.bu})})]},`${xe}-${pe}`)})})})}),(qe=e.location_history)!=null&&qe.length?t.jsx(at,{id:"provenance",title:u("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((T,pe)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(T.name)}),([T.start_date,T.end_date].filter(Boolean).join("—")||T.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(st,{items:[[T.start_date,T.end_date].filter(Boolean).join("—"),T.description?f(T.description):""]})})]},pe))})}):null,he.length===0&&t.jsx(at,{title:u("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("bookPage.emptyText")})})]}),ye=y.findIndex(T=>T.id===e.id),ue=O.length<=dl,ge=ue&&ye>=0?y.slice(Math.max(0,ye-pl),ye+pl+1):y.filter(T=>T.id!==e.id),Ie=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(m.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(st,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(T=>`${T.dynasty?`〔${f(T.dynasty)}〕`:""}${f(T.name)}`),f(Ht(x,m.unit.juan)),x._edition_count?u("bookPage.editionCount",{n:x._edition_count}):""]}),((Xe=x.description)==null?void 0:Xe.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,""))})]}),F>0&&ge.length>0&&t.jsxs("div",{children:[t.jsx(on,{id:"siblings",timeline:!0,title:ue?u("bookPage.siblings"):m.relation.siblingVersions,meta:ue?u("bookPage.byEra"):u("bookPage.kindCount",{n:F}),cap:ge.length,items:ge.map(T=>T.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(T.edition||T.title||T.id)}):t.jsx(nt,{id:T.id,label:f(T.edition||T.title||T.id),onNavigate:i,renderLink:o,dense:!0})),metas:ge.map(T=>[T.year!=null?T.year<0?u("detail.bce",{n:-T.year}):String(T.year):"",T.id===e.id?u("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:ge.findIndex(T=>T.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:u("bookPage.viewAllInWork",{n:O.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),L=e.work_id?t.jsx(Cc,{caption:m.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(qn,{railTop:c,back:p,up:L,nav:he,railLinks:h,main:D,card:me,side:Ie})};function Ky({volumes:e,unit:n}){const{t:i}=ne();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Pi(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 qy({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(y=>y.ref_type!=="book"),m=p.filter(y=>y.ref_type==="book"&&y.relation==="底本"),u=p.filter(y=>y.ref_type==="book"&&y.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,v=y=>y&&Yy.has(y)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${y}`)}):"",b=(y,w)=>t.jsx(nt,{id:y,label:d(w||y),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((y,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:y.relation?d(y.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),y.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(y.evidence),v(y.confidence)]})]})},`a-${w}`)),m.map((y,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(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,o(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(y.evidence),v(y.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)})]}),u.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:u.map((y,w)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,o(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(y.evidence),v(y.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((y,w)=>t.jsxs("span",{className:"bim-d-lf-chip",title:y.evidence?d(y.evidence):void 0,children:[b(y.book_id,o(y.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(y.relation)})]},w))})]})]}),(_=e.appendix)==null?void 0:_.map((y,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(y.title)]}),t.jsx(Dt,{text:y.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 On=16,Xy=200,Zy=16,Gd=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var ye,ue,ge,Ie,L,ie,je;const{t:p,convert:h,messages:m}=ne(),[u,f]=g.useState(""),[x,v]=g.useState(!1),[b,_]=g.useState(null),[y,w]=g.useState(""),[j,k]=g.useState(!1),C=g.useMemo(()=>Fl(e,n),[e,n]),$=g.useMemo(()=>Wl(e),[e]),[S,E]=g.useState(new Map),N=!!i&&C.rows.length>0&&C.rows.length<=Xy,z=N&&(C.rows.length<=On||j),O=z&&C.rows.every(W=>!W.id||S.has(W.id)),F=W=>{var ae;return Qr(W?(ae=S.get(W))==null?void 0:ae.l1:void 0)},A=g.useMemo(()=>{const W=u.trim(),ae=W?h(W):"";return C.rows.filter(V=>{var _e,Le;if(y&&Qr(V.id?(_e=S.get(V.id))==null?void 0:_e.l1:void 0)!==y)return!1;if(!ae)return!0;const re=V.id&&((Le=S.get(V.id))==null?void 0:Le.title)||V.title;return h(re).includes(ae)||(V.subItems||[]).some(He=>h(He).includes(ae))})},[C.rows,u,y,S,h]),I=x?A:A.slice(0,On),P=g.useMemo(()=>(z?C.rows:I).filter(W=>W.id&&!S.has(W.id)).map(W=>W.id),[z,C.rows,I,S]);g.useEffect(()=>{if(!i||P.length===0)return;let W=!1;const ae=P.slice(0,Zy);return Yi(ae,Gi,V=>i.getItem(V).then(re=>{var He,qe;const _e=re??{},Le={title:_e.title,edition:_e.edition,authors:_e.authors,measure:re?Ht(re,m.unit.juan):void 0,versionCount:_e._edition_count??((He=_e._books)==null?void 0:He.length),l1:((qe=bo(_e))==null?void 0:qe.l1)||void 0};return[V,Le]}).catch(()=>[V,{}]),()=>W).then(V=>{W||E(re=>{const _e=new Map(re);for(const[Le,He]of V)_e.set(Le,He);return _e})}),()=>{W=!0}},[i,P,m.unit.juan]);const K=(ye=(e.contained_in||[])[0])==null?void 0:ye.id;g.useEffect(()=>{if(!K){_(null);return}if(_({id:K}),!i)return;let W=!1;return i.getItem(K).then(ae=>{W||_({id:K,title:ae==null?void 0:ae.title})}).catch(()=>{}),()=>{W=!0}},[i,K]);const oe=g.useMemo(()=>Bd(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),le=oe.text.length+oe.groups.reduce((W,ae)=>W+ae.rows.length+ae.mirrors.length,0),H=$.works,de=new Set(C.rows.map(W=>W.id).filter(Boolean)),U=H.length>0&&!H.every(W=>de.has(W.id)),te=(()=>{const W=C.rows.map(ae=>ae.edition).filter(Boolean);return W.length>1&&new Set(W).size===1})(),ve=C.rows.some(W=>W.volumes.length>0||W.expected!=null),fe=$.total,Ae=$.truncated?fe:C.rows.length,B=Ht(e,m.unit.juan),me=e.count,ze=W=>typeof W=="number"&&Number.isFinite(W)?W:null,we=ze(me==null?void 0:me.juan)??ze((ue=e.juan_count)==null?void 0:ue.number),De=ze(me==null?void 0:me.ce)??(C.totalVolumes||null),Pe=[{value:Ae,label:p("collectionPage.stat.titles")},{value:we??0,label:m.unit.juan},{value:De??0,label:m.unit.volume}],G=g.useMemo(()=>{var V,re;const W=[];if((V=e.publication_info)!=null&&V.details&&W.push({label:p("collectionPage.fact.publication"),value:h(e.publication_info.details)}),fe&&(fe!==C.rows.length||$.truncated)){const _e=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");W.push({label:_e,value:`${fe} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const ae=[ze(me==null?void 0:me.zhong)!=null?p("collectionPage.nZhong",{n:me.zhong}):"",ze(me==null?void 0:me.han)!=null?p("collectionPage.nHan",{n:me.han}):""].filter(Boolean);return ae.length&&W.push({label:p("collectionPage.fact.expected"),value:ae.join(" ")}),we==null&&B&&W.push({label:p("collectionPage.fact.measure"),value:h(B),title:(re=e.juan_count)!=null&&re.description?h(e.juan_count.description):void 0}),W},[e,fe,$.truncated,C.rows.length,we,B,me,h,p,m]),he=g.useMemo(()=>{if(!O)return[];const W=new Map;for(const V of C.rows){const re=F(V.id);re&&W.set(re,(W.get(re)??0)+1)}const ae=Vn.filter(V=>(W.get(V.key)??0)>0);return ae.length<2?[]:[{key:"",label:`${m.catalog.all} ${Ae}`},...ae.map(V=>({key:V.key,label:`${V.label} ${W.get(V.key)}`}))]},[O,C.rows,S,m]),q=g.useMemo(()=>{if(!O||!C.rows.some(re=>re.volumes.length>0))return null;const W=[],ae=C.rows.filter(re=>re.volumes.length>0).map(re=>({k:F(re.id)??"",from:Math.min(...re.volumes),to:Math.max(...re.volumes)})).sort((re,_e)=>re.from-_e.from);for(const re of ae){const _e=re.to-re.from+1,Le=W[W.length-1];Le&&Le.key===re.k?(Le.to=Math.max(Le.to,re.to),Le.n+=_e):W.push({key:re.k,from:re.from,to:re.to,n:_e})}const V=ae.reduce((re,_e)=>Math.max(re,_e.to),0);return W.length>1&&W.some(re=>re.key)?{segs:W,last:V}:null},[O,C.rows,S]),se=(ge=e.description)==null?void 0:ge.text,Y=t.jsx(Xn,{kind:p("collectionPage.kind"),title:h(e.title),byline:t.jsx(es,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(st,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Ie=e.publication_info)!=null&&Ie.year?h(e.publication_info.year):""]}),description:se||(L=e.history)!=null&&L.length?t.jsxs(t.Fragment,{children:[se&&t.jsx(Dt,{text:se,style:{fontSize:15,lineHeight:1.85}}),(ie=e.history)!=null&&ie.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((W,ae)=>t.jsx("li",{children:h(W)},ae))}):null]}):void 0,clampDescription:zo(se)||(((je=e.history)==null?void 0:je.length)??0)>2?6:void 0,stats:Pe,facts:G,foot:t.jsx(Zn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:q&&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:q.segs.map((W,ae)=>{const V=Vn.find(re=>re.key===W.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!V,title:V?p("collectionPage.dist.segTitle",{section:h(V.label),from:W.from,to:W.to}):void 0,"aria-label":V?p("collectionPage.dist.only",{section:h(V.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!V&&y===W.key,style:{flexGrow:W.n,background:r(V?V.token:"rule")},onClick:()=>{V&&(w(y===W.key?"":W.key),v(!1))}},ae)})}),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:q.last})})]})]})}),M=[];C.rows.length&&M.push({id:"titles",label:p("collectionPage.sec.titles"),count:Ae}),le&&M.push({id:"resources",label:p("collectionPage.sec.resources"),count:le}),U&&M.push({id:"works",label:m.section.containedWorks,count:H.length});const X=t.jsxs(t.Fragment,{children:[C.rows.length>0&&t.jsxs(at,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(st,{items:[`${Ae} ${m.unit.items}`,C.totalVolumes?p("collectionPage.totalVolumes",{n:C.totalVolumes,unit:m.unit.volume}):"",A.length!==Ae?p("collectionPage.currentN",{n:A.length,unit:m.unit.items}):""]}),action:a,children:[(C.rows.length>On||he.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[he.length>0&&t.jsx(Hi,{items:he,value:y,onChange:W=>{w(W),v(!1)}}),N&&C.rows.length>On&&!O&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:j,onClick:()=>k(!0),title:p("collectionPage.loadAllTitle",{n:C.rows.length,unit:m.unit.items}),children:p(j?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),C.rows.length>On&&t.jsx("input",{type:"search",className:"bim-d-find",value:u,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:W=>{f(W.target.value),v(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Di(A.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[ve&&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:I.map((W,ae)=>{var Xe;const V=W.id?S.get(W.id):void 0,re=V!=null&&V.title&&W.title===W.id?V.title:W.title,_e=((V==null?void 0:V.authors)||[]).find(T=>T&&T.name),Le=[_e?`${_e.dynasty?`〔${h(_e.dynasty)}〕`:""}${h(_e.name)}${_e.role?` ${h(_e.role)}`:""}`:"",V!=null&&V.measure?h(V.measure):"",(Xe=W.subItems)!=null&&Xe.length?W.subItems.map(T=>h(T)).join("、"):"",(V!=null&&V.edition||W.edition)&&!te?h((V==null?void 0:V.edition)||W.edition||""):""].filter(Boolean),He=Vn.find(T=>T.key===F(W.id)),qe=W.volumes.length>0?p("collectionPage.volumeRange",{range:Pi(W.volumes,m.unit.volume),unit:m.unit.volume}):W.expected!=null?`${W.found??0}/${W.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[ve&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${qe?"":" bim-d-zt-blank"}`,children:[He&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(He.token)}}),qe||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[W.id?t.jsx(nt,{id:W.id,label:h(re),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:h(re)}),Le.length>0?t.jsx(st,{items:Le}):W.id&&!V&&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${V!=null&&V.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:V!=null&&V.versionCount?p("collectionPage.nZhong",{n:V.versionCount}):""})]},`${W.id??W.title}-${ae}`)})})]}),I.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx($o,{total:A.length,shown:I.length,unit:m.unit.items,onClick:()=>v(!0)})]}),le>0&&t.jsxs(at,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:le}),children:[oe.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[oe.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:oe.text.map((W,ae)=>t.jsx(ts,{item:W,siblings:oe.text},`${W.id||W.url||W.name}-${ae}`))})})]}),t.jsx(Wd,{groups:oe.groups})]}),C.rows.length===0&&le===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")})})]}),J=U?t.jsx(on,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:H.length}),cap:12,items:H.map(W=>t.jsx(nt,{id:W.id,label:h(W.title),onNavigate:o,renderLink:s,dense:!0}))}):null,D=b?t.jsx(Cc,{caption:p("collectionPage.parent"),children:t.jsx(nt,{id:b.id,label:h(b.title||b.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(qn,{railTop:l,back:d,up:D,nav:M,railLinks:c,main:X,card:Y,side:J})},Jy=8;function Yd(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function Qy(e){return(e||[]).filter(n=>{var i,o;return Yd(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,Jy)}function e0({images:e,assetBase:n,name:i}){const{t:o,convert:s}=ne(),[a,l]=g.useState(0),[d,c]=g.useState(!1),p=n?Qy(e):[];if(!n||d||p.length===0)return null;const h=n.endsWith("/")?n:n+"/",m=p[Math.min(a,p.length-1)],u=m.width&&m.height&&m.width>0&&m.height>0?`${m.width} / ${m.height}`:void 0,f=x=>h+Yd(x.file).split("/").map(encodeURIComponent).join("/");return t.jsxs("figure",{className:"bim-d-seal bim-d-ui",children:[t.jsx("img",{className:"bim-d-seal-main",src:f(m),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:u?{"--seal-ar":u}:void 0,width:m.width,height:m.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},m.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,v)=>t.jsx("button",{type:"button","aria-pressed":v===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${v+1}`,onClick:()=>l(v),children:t.jsx("img",{src:f(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(m.credit)})," · ",o("entityPage.imgLicense",{license:s(m.license)}),m.source_url&&/^https?:\/\//i.test(m.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:m.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),m.note&&t.jsxs(t.Fragment,{children:[" · ",s(m.note)]})]})]})}const t0=16,zr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function ul(e){if(!e)return zr.length;const n=zr.indexOf(e);return n===-1?zr.length:n}function n0(e,n,i){if(n)return e[n]??i(n)}function i0(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const r0={秦:[-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]},Kd=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var D,ye,ue,ge,Ie;const{t:c,convert:p,messages:h}=ne(),m=L=>i0(L,c),[u,f]=g.useState("全部"),[x,v]=g.useState(!1),[b,_]=g.useState("default"),[y,w]=g.useState(new Map),j=g.useMemo(()=>e._works||[],[e._works]),k=g.useMemo(()=>j.map(L=>{const ie=y.get(L.work_id);return{id:L.work_id,title:(ie==null?void 0:ie.title)??L.title??L.work_id,role:L.role||"",cls:go(L.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)}}),[j,y]),C=g.useMemo(()=>Ol(j.map(L=>L.role),c("detail.roleAll")),[j,c]),$=g.useMemo(()=>{const L=u==="全部"?k:k.filter(ie=>ie.cls===u);return b==="versions"?[...L].sort((ie,je)=>(je.versionCount??-1)-(ie.versionCount??-1)):L},[k,u,b]),S=x?$:$.slice(0,t0),E=g.useMemo(()=>S.filter(L=>!y.has(L.id)).map(L=>L.id),[S,y]);g.useEffect(()=>{if(!n||E.length===0)return;let L=!1;return Yi(E,Gi,ie=>n.getItem(ie).then(je=>{var _e;const W=je??{},ae=W._edition_count??((_e=W._books)==null?void 0:_e.length)??0,V=bo(W),re=[V==null?void 0:V.l1,V==null?void 0:V.l2].filter(Boolean).join(" ");return[ie,{id:ie,title:W.title,versionCount:ae,loaded:!0,cls:re||void 0,l1:(V==null?void 0:V.l1)||void 0,measure:je&&Ht(je,h.unit.juan)||void 0,hasImage:!!W._has_image}]}).catch(()=>[ie,{id:ie,loaded:!0}]),()=>L).then(ie=>{L||w(je=>{const W=new Map(je);for(const[ae,V]of ie)W.set(ae,V);return W})}),()=>{L=!0}},[n,E,h.unit.juan]);const N=g.useMemo(()=>{const L=new Map;for(const ie of e.alt_names||[]){const je=ie.type||h.section.aliases;L.has(je)||L.set(je,[]),L.get(je).push(ie.name)}return[...L.entries()].sort((ie,je)=>ul(ie[0])-ul(je[0])).map(([ie,je])=>({label:ie,names:je}))},[e.alt_names,h]),z=((D=e.dates)==null?void 0:D.birth)??void 0,O=((ye=e.dates)==null?void 0:ye.death)??void 0,F=(ue=e.dates)==null?void 0:ue.floruit,A=z!=null||O!=null?`${m(z)||"?"}—${m(O)||"?"}`:Array.isArray(F)&&F.length===2&&F.every(L=>Number.isFinite(L))?c("entityPage.floruit",{from:m(F[0]),to:m(F[1])}):"",I=new Set(["本名","字","號","号"]),P=N.filter(L=>I.has(L.label)),K=N.filter(L=>!I.has(L.label)),oe=K.reduce((L,ie)=>L+ie.names.length,0),le=g.useMemo(()=>{const L=[];for(const je of P)L.push({label:je.label,value:je.names.map(W=>p(W)).join("、")});const ie=j.length;return ie&&L.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:ie})}),L},[j,P,p,c]),H=L=>{var ie;return(ie=N.find(je=>L.includes(je.label)))==null?void 0:ie.names[0]},de=H(["字"]),U=H(["號","号"]),te=[de?c("entityPage.zi",{name:p(de)}):"",U?c("entityPage.hao",{name:p(U)}):""].filter(Boolean).join(","),ve=e.native_place,fe=e.dynasty?r0[e.dynasty]:void 0,Ae=(()=>{if(!fe||z==null||O==null||O<z)return null;const[L,ie]=fe,je=Math.max(z,L),W=Math.min(O,ie);if(W<=je)return null;const ae=ie-L;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":c("entityPage.lifeAria",{birth:m(z),death:m(O),years:O-z+1}),children:t.jsx("i",{style:{left:`${(je-L)/ae*100}%`,width:`${(W-je)/ae*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${m(L)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:O-z+1})}),t.jsx("span",{children:m(ie)})]})]})})(),B=g.useMemo(()=>{if(!n||k.length===0||k.some(je=>!je.loaded))return null;const L=new Map;for(const je of k){const W=Qr(je.l1);W&&L.set(W,(L.get(W)??0)+1)}const ie=Vn.map(je=>({...je,n:L.get(je.key)??0})).filter(je=>je.n>0);return ie.length?ie:null},[k,n]),me=t.jsxs(Xn,{kind:n0(h.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:te||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(st,{items:[e.dynasty?p(e.dynasty):"",A,ve?c("entityPage.nativePlace",{place:p(ve)}):""]}),Ae,t.jsx(e0,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(ge=e.description)!=null&&ge.text?t.jsx(Dt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:zo((Ie=e.description)==null?void 0:Ie.text)?6:void 0,facts:le,foot:t.jsx(Zn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[oe>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:oe})}),t.jsx("dl",{children:K.map(L=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:p(L.label)}),t.jsx("dd",{children:L.names.map(ie=>p(ie)).join("、")})]},L.label))})]}),B&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:c("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:B.map(L=>t.jsx("i",{style:{flexGrow:L.n,background:r(L.token)}},L.key))}),t.jsx("div",{className:"bim-d-dist-key",children:B.map(L=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(L.token)}}),p(L.label)," ",L.n]},L.key))})]})]}),ze=g.useMemo(()=>k.filter(L=>L.loaded&&(L.versionCount??0)>0).sort((L,ie)=>(ie.versionCount??0)-(L.versionCount??0)).slice(0,3),[k]),we=!!n&&k.length>=3&&S.some(L=>!L.loaded),De=u==="全部"&&(we||ze.length>=2),Pe=e.external_ids||{},G=[];Pe.cbdb_id!=null&&G.push({label:"CBDB",id:String(Pe.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${Pe.cbdb_id}`,note:Pe.cbdb_match==="auto"?c("entityPage.autoMatch"):void 0});const he=Pe.wikidata_id;he&&G.push({label:"Wikidata",id:he,href:`https://www.wikidata.org/wiki/${he}`});const q=Pe.viaf_id;q&&G.push({label:"VIAF",id:q,href:`https://viaf.org/viaf/${q}`});const se=C.map(L=>({key:L.cls,label:`${L.label} ${L.count}`})),Y=[...De&&!we?[{id:"featured",label:c("entityPage.sec.featured"),count:ze.length}]:[],...k.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:k.length}]:[],...G.length?[{id:"external",label:c("entityPage.sec.external"),count:G.length}]:[]],M=De?t.jsxs(at,{id:"featured",title:c("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:c("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":we||void 0,children:[we&&[0,1,2].map(L=>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:" "})]},L)),!we&&ze.map(L=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(nt,{id:L.id,label:p(L.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(st,{items:[L.section?p(L.section):"",L.measure?p(L.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:L.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),L.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},L.id))]})]}):null,X=k.length===0?t.jsx(at,{title:c("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[M,t.jsxs(at,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(st,{items:[c("entityPage.total",{n:k.length}),$.length!==k.length?c("entityPage.current",{n:$.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[se.length>1&&t.jsx(Hi,{items:se,value:u,onChange:L=>{f(L),v(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":b==="versions",onClick:()=>{b==="default"&&v(!0),_(L=>L==="default"?"versions":"default")},children:c(b==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Di($.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("entityPage.col.work")}),t.jsx("th",{children:c("entityPage.col.section")}),t.jsx("th",{children:c("entityPage.col.role")}),t.jsx("th",{children:c("entityPage.col.versions")}),t.jsx("th",{"aria-label":c("entityPage.col.image")})]})}),t.jsx("tbody",{children:S.map(L=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(nt,{id:L.id,label:p(L.title),onNavigate:i,renderLink:o,dense:!0}),L.measure?t.jsx(st,{items:[p(L.measure)]}):!L.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${L.section||L.loaded?"":" bim-d-zt-blank"}`,children:L.section?p(L.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${L.role?"":" bim-d-zt-blank"}`,children:L.role?p(L.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${L.loaded?"":" bim-d-zt-blank"}`,children:L.loaded?L.versionCount?c("entityPage.nZhong",{n:L.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:L.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:L.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},L.id))})]}),S.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("entityPage.emptyRole")}),!x&&t.jsx($o,{total:$.length,shown:S.length,unit:c("entityPage.moreUnit"),onClick:()=>v(!0)})]})]}),J=G.length>0?t.jsx(on,{id:"external",title:c("entityPage.sec.external"),items:G.map(L=>t.jsxs("a",{href:L.href,target:"_blank",rel:"noopener noreferrer",children:[L.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:G.map(L=>L.id),foot:Pe.cbdb_id!=null&&Pe.cbdb_match==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(qn,{railTop:s,back:a,nav:Y,railLinks:l,main:X,card:me,side:J})},is="(max-width: 719px)",o0=`${is}, (pointer: coarse)`,qd=`
1404
1407
  .bim-ct {
1405
1408
  display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
1406
1409
  max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
@@ -1508,7 +1511,7 @@ ${A??""}`,[Cn,us]=g.useState({key:$n,data:te,started:!!te});if(Cn.key!==$n)us({k
1508
1511
  .bim-ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1509
1512
  }
1510
1513
 
1511
- @media ${ts} {
1514
+ @media ${is} {
1512
1515
  .bim-ct { display: block; padding: 12px 16px 40px; }
1513
1516
  .bim-ct-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
1514
1517
  .bim-ct-lrow > a { grid-template-columns: minmax(0, 1fr); }
@@ -1533,7 +1536,7 @@ ${A??""}`,[Cn,us]=g.useState({key:$n,data:te,started:!!te});if(Cn.key!==$n)us({k
1533
1536
  }
1534
1537
 
1535
1538
  /* 点击目标 ≥44px(Q5):触屏与窄屏 */
1536
- @media ${r0} {
1539
+ @media ${o0} {
1537
1540
  .bim-ct-row { min-height: 44px; }
1538
1541
  .bim-ct-tw { width: 44px; }
1539
1542
  .bim-ct-pg { min-width: 44px; height: 44px; }
@@ -1559,7 +1562,7 @@ ${A??""}`,[Cn,us]=g.useState({key:$n,data:te,started:!!te});if(Cn.key!==$n)us({k
1559
1562
  /* 窄屏分类抽屉:界栏下按钮和面板都有框 */
1560
1563
  :root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${r("fr-bd")}; background: ${r("fr-bg")}; }
1561
1564
  :root[data-layout="boxed"] .bim-ct-drawer { border: ${r("fr-bd")}; }
1562
- `,rn="未分類",Ot="all",ns=20;function Zn(e){if(!e)return[];const n=[];for(const i of[e.l1,e.l2,e.l3,e.l4]){const o=(i??"").trim();if(!o)break;n.push(o)}return n}function o0(e){const n=Zn(e);return n.length?n.join("/"):rn}function s0(e){const n=Zn(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[rn]}function a0(e,n=[]){const i=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(h=>!!h);p.forEach((h,m)=>{const u=p.slice(0,m+1).join("/");i.has(u)||i.set(u,c)})});const o=new Map;let s=0;for(const d of e){const c=Zn(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((h,m)=>{const u=c.slice(0,m+1).join("/");let f=p.get(h);f||(f={id:u,label:h,count:0,children:new Map},p.set(h,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const h=c.label===rn?1:0,m=p.label===rn?1:0;if(h!==m)return h-m;const u=i.get(c.id)??1/0,f=i.get(p.id)??1/0;return u!==f?u-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(o);return s>0&&l.push({id:rn,label:rn,count:s}),l}function gn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=gn(i.children,n);if(o.length)return[i,...o]}}return[]}function is(e){return e.reduce((n,i)=>n+i.count,0)}function l0(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function c0(e){var d;const n={id:e.id,title:e.title||e.id},i=e.juan_count,o=typeof i=="number"?i:i==null?void 0:i.number;typeof o=="number"&&o>0?n.juan=o:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const p=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return p?{name:c.name,dynasty:p}:{name:c.name}});s.length&&(n.authors=s);const a=l0(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Zn(e.classification);return l.length&&(n.classification=l),n}function d0(e,n){const i=e.summary?0:1,o=n.summary?0:1;return i!==o?i-o:e.title.localeCompare(n.title,"zh")}function p0(e,n=ns){return Math.max(1,Math.ceil(e/n))}function Zd(e,n,i=2){if(n<=1)return[1];const o=new Set([1,n]);for(let l=e-i;l<=e+i;l++)l>=1&&l<=n&&o.add(l);const s=[...o].sort((l,d)=>l-d),a=[];return s.forEach((l,d)=>{if(d>0){const c=l-s[d-1];c===2?a.push(l-1):c>2&&a.push(null)}a.push(l)}),a}const u0=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function m0(e,n,i){const o=[];i&&o.push({id:Ot,parentId:null,hasChildren:!1,firstChildId:null});const s=(a,l)=>{var d;for(const c of a){const p=(d=c.children)!=null&&d.length?c.children:null;o.push({id:c.id,parentId:l,hasChildren:!!p,firstChildId:p?p[0].id:null}),p&&n.has(c.id)&&s(p,c.id)}};return s(e,null),o}function Jd({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=ie(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=g.useRef(null),h=n&&n!==Ot?n:null,m=d!==null,[u,f]=g.useState(()=>{const S=new Set;for(const R of gn(e,h))S.add(R.id);return S});g.useEffect(()=>{const S=gn(e,h);S.length&&f(R=>{if(S.every(z=>R.has(z.id)))return R;const N=new Set(R);for(const z of S)N.add(z.id);return N})},[e,h]);const x=g.useMemo(()=>m0(e,u,m),[e,u,m]),[v,b]=g.useState(null);g.useEffect(()=>{b(null)},[n]);const $=h??(m?Ot:null),y=g.useMemo(()=>{var N;const S=new Set(x.map(z=>z.id));if(v&&S.has(v))return v;if($&&S.has($))return $;const R=gn(e,h).map(z=>z.id).filter(z=>S.has(z));return R.length?R[R.length-1]:((N=x[0])==null?void 0:N.id)??null},[x,v,$,e,h]),w=g.useCallback((S,R)=>{f(N=>{const z=N.has(S),M=R??!z;if(M===z)return N;const F=new Set(N);return M?F.add(S):F.delete(S),F})},[]),k=g.useCallback(S=>{b(S),requestAnimationFrame(()=>{var N;const R=Array.from(((N=p.current)==null?void 0:N.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===S);R==null||R.focus()})},[]),j=g.useCallback((S,R)=>{R&&w(S,!0),i(S)},[i,w]),C=g.useCallback(S=>{const R=S.target.closest("[data-ct-id]");if(!R)return;const N=R.dataset.ctId,z=x.findIndex(L=>L.id===N);if(z<0)return;const M=x[z];let F=null;switch(S.key){case"ArrowDown":F=x[Math.min(x.length-1,z+1)].id;break;case"ArrowUp":F=x[Math.max(0,z-1)].id;break;case"Home":F=x[0].id;break;case"End":F=x[x.length-1].id;break;case"ArrowRight":if(!M.hasChildren)break;u.has(N)?F=M.firstChildId:w(N,!0);break;case"ArrowLeft":M.hasChildren&&u.has(N)?w(N,!1):F=M.parentId;break;case"Enter":case" ":S.preventDefault(),j(N,M.hasChildren);return;default:return}S.preventDefault(),F&&F!==N&&k(F)},[x,u,w,k,j]),_=(S,R)=>S.map((N,z)=>{var P;const M=(P=N.children)!=null&&P.length?N.children:null,F=!!M&&u.has(N.id),L=N.id===h,E=R===1&&S.length>1&&z===S.length-1;return t.jsxs("li",{role:"treeitem","aria-level":R,"aria-expanded":M?F:void 0,"aria-selected":L,tabIndex:y===N.id?0:-1,"data-ct-id":N.id,className:E?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":R-1},onClick:()=>{b(N.id),j(N.id,!!M)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:M?Z=>{Z.stopPropagation(),b(N.id),w(N.id)}:void 0,children:M?t.jsx(u0,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(N.label)}),t.jsx("span",{className:"bim-ct-n",children:N.count.toLocaleString("en-US")})]}),F&&t.jsx("ul",{role:"group",children:_(M,R+1)})]},N.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:C,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!h,tabIndex:y===Ot?0:-1,"data-ct-id":Ot,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{b(Ot),i(Ot)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),t.jsx("span",{className:"bim-ct-lb",children:l(d)}),t.jsx("span",{className:"bim-ct-n",children:is(e).toLocaleString("en-US")})]})}),_(e,1)]})}const Qd=e=>`/item/${encodeURIComponent(e)}`;function h0(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function ep(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function tp({work:e,href:n}){var d,c;const{t:i,convert:o}=ie(),s=ep(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-card",children:t.jsxs("a",{href:n,children:[t.jsxs("div",{className:"bim-ct-ch",children:[t.jsx("h2",{className:"bim-ct-ct",children:o(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:o(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function np({work:e,href:n}){var d,c;const{t:i,convert:o}=ie(),s=ep(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-lrow",children:t.jsxs("a",{href:n,children:[t.jsxs("span",{className:"bim-ct-lt",children:[o(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function ip({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=ie();if(n<=1)return null;const d=p=>h=>{i&&(o&&!h0(h)||(h.preventDefault(),i(p)))},c=(p,h,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:h});const u={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return o?t.jsx("a",{...u,href:o(p),onClick:d(p),children:h}):t.jsx("button",{type:"button",...u,onClick:m.current?void 0:d(p),children:h})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":s?l(s):a("catalogPage.pagerLabel"),children:[c(e-1,a("catalogPage.prevPage"),{disabled:e<=1}),t.jsx("ol",{children:Zd(e,n).map((p,h)=>t.jsx("li",{style:{display:"contents"},children:p===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(p,p,{current:p===e,aria:a("catalogPage.pageN",{n:p})})},p??`gap${h}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function rp({works:e,workLink:n=Qd,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=ie();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:i===void 0?a("catalogPage.emptyWorks"):typeof i=="string"?l(i):i}):o==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(np,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(tp,{work:d,href:n(d.id)},d.id))}),t.jsx(ip,{...s})]})}const g0=()=>t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function f0({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:h,allTitle:m,pageSize:u=ns,className:f,view:x,onViewChange:v}){const{t:b,convert:$}=ie(),y=h===void 0?b("catalogPage.all"):h,w=m??b("catalogPage.allTitle"),j=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[C,_]=g.useState(!1),[S,R]=g.useState("card"),N=x??S,z=Z=>{R(Z),v==null||v(Z)},M=gn(e,n&&n!==Ot?n:null),F=M.length?M[M.length-1]:null,L=F?F.label:w,E=F?F.count:is(e),P=g.useCallback(Z=>{_(!1),a(Z)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":C?"open":"closed",children:[t.jsx("style",{children:Xd}),t.jsxs("aside",{className:"bim-ct-side","aria-label":b("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":C,"aria-controls":j,onClick:()=>_(Z=>!Z),children:[t.jsx("span",{children:b("catalogPage.drawerLabel",{path:$(M.length?M.map(Z=>Z.label).join(" › "):y??w)})}),t.jsx(g0,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:j,children:[t.jsx("h2",{className:"bim-ct-side-h",children:b("catalogPage.classification")}),t.jsx(Jd,{tree:e,selectedId:n,onSelect:P,allLabel:y})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:$(L)}),M.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:$(M.slice(0,-1).map(Z=>Z.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[b("catalogPage.stat",{total:E.toLocaleString("en-US"),size:u}),o>1&&b("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":b("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":N==="card",onClick:()=>z("card"),children:b("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":N==="list",onClick:()=>z("list"),children:b("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(rp,{works:s,view:N,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const Jn="(max-width: 719px)",x0="(max-width: 1079px)",b0=`${Jn}, (pointer: coarse)`,y0=[8,18,30,42,88],rs=`
1565
+ `,rn="未分類",Ot="all",rs=20;function Qn(e){if(!e)return[];const n=[];for(const i of[e.l1,e.l2,e.l3,e.l4]){const o=(i??"").trim();if(!o)break;n.push(o)}return n}function s0(e){const n=Qn(e);return n.length?n.join("/"):rn}function a0(e){const n=Qn(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[rn]}function l0(e,n=[]){const i=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(h=>!!h);p.forEach((h,m)=>{const u=p.slice(0,m+1).join("/");i.has(u)||i.set(u,c)})});const o=new Map;let s=0;for(const d of e){const c=Qn(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((h,m)=>{const u=c.slice(0,m+1).join("/");let f=p.get(h);f||(f={id:u,label:h,count:0,children:new Map},p.set(h,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const h=c.label===rn?1:0,m=p.label===rn?1:0;if(h!==m)return h-m;const u=i.get(c.id)??1/0,f=i.get(p.id)??1/0;return u!==f?u-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(o);return s>0&&l.push({id:rn,label:rn,count:s}),l}function fn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=fn(i.children,n);if(o.length)return[i,...o]}}return[]}function os(e){return e.reduce((n,i)=>n+i.count,0)}function c0(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function d0(e){var d;const n={id:e.id,title:e.title||e.id},i=e.juan_count,o=typeof i=="number"?i:i==null?void 0:i.number;typeof o=="number"&&o>0?n.juan=o:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const p=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return p?{name:c.name,dynasty:p}:{name:c.name}});s.length&&(n.authors=s);const a=c0(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Qn(e.classification);return l.length&&(n.classification=l),n}function p0(e,n){const i=e.summary?0:1,o=n.summary?0:1;return i!==o?i-o:e.title.localeCompare(n.title,"zh")}function u0(e,n=rs){return Math.max(1,Math.ceil(e/n))}function Xd(e,n,i=2){if(n<=1)return[1];const o=new Set([1,n]);for(let l=e-i;l<=e+i;l++)l>=1&&l<=n&&o.add(l);const s=[...o].sort((l,d)=>l-d),a=[];return s.forEach((l,d)=>{if(d>0){const c=l-s[d-1];c===2?a.push(l-1):c>2&&a.push(null)}a.push(l)}),a}const m0=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function h0(e,n,i){const o=[];i&&o.push({id:Ot,parentId:null,hasChildren:!1,firstChildId:null});const s=(a,l)=>{var d;for(const c of a){const p=(d=c.children)!=null&&d.length?c.children:null;o.push({id:c.id,parentId:l,hasChildren:!!p,firstChildId:p?p[0].id:null}),p&&n.has(c.id)&&s(p,c.id)}};return s(e,null),o}function Zd({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=ne(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=g.useRef(null),h=n&&n!==Ot?n:null,m=d!==null,[u,f]=g.useState(()=>{const S=new Set;for(const E of fn(e,h))S.add(E.id);return S});g.useEffect(()=>{const S=fn(e,h);S.length&&f(E=>{if(S.every(z=>E.has(z.id)))return E;const N=new Set(E);for(const z of S)N.add(z.id);return N})},[e,h]);const x=g.useMemo(()=>h0(e,u,m),[e,u,m]),[v,b]=g.useState(null);g.useEffect(()=>{b(null)},[n]);const _=h??(m?Ot:null),y=g.useMemo(()=>{var N;const S=new Set(x.map(z=>z.id));if(v&&S.has(v))return v;if(_&&S.has(_))return _;const E=fn(e,h).map(z=>z.id).filter(z=>S.has(z));return E.length?E[E.length-1]:((N=x[0])==null?void 0:N.id)??null},[x,v,_,e,h]),w=g.useCallback((S,E)=>{f(N=>{const z=N.has(S),O=E??!z;if(O===z)return N;const F=new Set(N);return O?F.add(S):F.delete(S),F})},[]),j=g.useCallback(S=>{b(S),requestAnimationFrame(()=>{var N;const E=Array.from(((N=p.current)==null?void 0:N.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===S);E==null||E.focus()})},[]),k=g.useCallback((S,E)=>{E&&w(S,!0),i(S)},[i,w]),C=g.useCallback(S=>{const E=S.target.closest("[data-ct-id]");if(!E)return;const N=E.dataset.ctId,z=x.findIndex(A=>A.id===N);if(z<0)return;const O=x[z];let F=null;switch(S.key){case"ArrowDown":F=x[Math.min(x.length-1,z+1)].id;break;case"ArrowUp":F=x[Math.max(0,z-1)].id;break;case"Home":F=x[0].id;break;case"End":F=x[x.length-1].id;break;case"ArrowRight":if(!O.hasChildren)break;u.has(N)?F=O.firstChildId:w(N,!0);break;case"ArrowLeft":O.hasChildren&&u.has(N)?w(N,!1):F=O.parentId;break;case"Enter":case" ":S.preventDefault(),k(N,O.hasChildren);return;default:return}S.preventDefault(),F&&F!==N&&j(F)},[x,u,w,j,k]),$=(S,E)=>S.map((N,z)=>{var P;const O=(P=N.children)!=null&&P.length?N.children:null,F=!!O&&u.has(N.id),A=N.id===h,I=E===1&&S.length>1&&z===S.length-1;return t.jsxs("li",{role:"treeitem","aria-level":E,"aria-expanded":O?F:void 0,"aria-selected":A,tabIndex:y===N.id?0:-1,"data-ct-id":N.id,className:I?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":E-1},onClick:()=>{b(N.id),k(N.id,!!O)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:O?K=>{K.stopPropagation(),b(N.id),w(N.id)}:void 0,children:O?t.jsx(m0,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(N.label)}),t.jsx("span",{className:"bim-ct-n",children:N.count.toLocaleString("en-US")})]}),F&&t.jsx("ul",{role:"group",children:$(O,E+1)})]},N.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:C,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!h,tabIndex:y===Ot?0:-1,"data-ct-id":Ot,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{b(Ot),i(Ot)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),t.jsx("span",{className:"bim-ct-lb",children:l(d)}),t.jsx("span",{className:"bim-ct-n",children:os(e).toLocaleString("en-US")})]})}),$(e,1)]})}const Jd=e=>`/item/${encodeURIComponent(e)}`;function g0(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Qd(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function ep({work:e,href:n}){var d,c;const{t:i,convert:o}=ne(),s=Qd(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-card",children:t.jsxs("a",{href:n,children:[t.jsxs("div",{className:"bim-ct-ch",children:[t.jsx("h2",{className:"bim-ct-ct",children:o(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:o(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function tp({work:e,href:n}){var d,c;const{t:i,convert:o}=ne(),s=Qd(e.juan,i),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-lrow",children:t.jsxs("a",{href:n,children:[t.jsxs("span",{className:"bim-ct-lt",children:[o(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,h)=>t.jsxs(g.Fragment,{children:[h>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},h))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function np({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=ne();if(n<=1)return null;const d=p=>h=>{i&&(o&&!g0(h)||(h.preventDefault(),i(p)))},c=(p,h,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:h});const u={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return o?t.jsx("a",{...u,href:o(p),onClick:d(p),children:h}):t.jsx("button",{type:"button",...u,onClick:m.current?void 0:d(p),children:h})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":s?l(s):a("catalogPage.pagerLabel"),children:[c(e-1,a("catalogPage.prevPage"),{disabled:e<=1}),t.jsx("ol",{children:Xd(e,n).map((p,h)=>t.jsx("li",{style:{display:"contents"},children:p===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(p,p,{current:p===e,aria:a("catalogPage.pageN",{n:p})})},p??`gap${h}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function ip({works:e,workLink:n=Jd,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=ne();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:i===void 0?a("catalogPage.emptyWorks"):typeof i=="string"?l(i):i}):o==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(tp,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(ep,{work:d,href:n(d.id)},d.id))}),t.jsx(np,{...s})]})}const f0=()=>t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function x0({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:h,allTitle:m,pageSize:u=rs,className:f,view:x,onViewChange:v}){const{t:b,convert:_}=ne(),y=h===void 0?b("catalogPage.all"):h,w=m??b("catalogPage.allTitle"),k=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[C,$]=g.useState(!1),[S,E]=g.useState("card"),N=x??S,z=K=>{E(K),v==null||v(K)},O=fn(e,n&&n!==Ot?n:null),F=O.length?O[O.length-1]:null,A=F?F.label:w,I=F?F.count:os(e),P=g.useCallback(K=>{$(!1),a(K)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":C?"open":"closed",children:[t.jsx("style",{children:qd}),t.jsxs("aside",{className:"bim-ct-side","aria-label":b("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":C,"aria-controls":k,onClick:()=>$(K=>!K),children:[t.jsx("span",{children:b("catalogPage.drawerLabel",{path:_(O.length?O.map(K=>K.label).join(" › "):y??w)})}),t.jsx(f0,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:k,children:[t.jsx("h2",{className:"bim-ct-side-h",children:b("catalogPage.classification")}),t.jsx(Zd,{tree:e,selectedId:n,onSelect:P,allLabel:y})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:_(A)}),O.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:_(O.slice(0,-1).map(K=>K.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[b("catalogPage.stat",{total:I.toLocaleString("en-US"),size:u}),o>1&&b("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":b("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":N==="card",onClick:()=>z("card"),children:b("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":N==="list",onClick:()=>z("list"),children:b("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(ip,{works:s,view:N,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const ei="(max-width: 719px)",b0="(max-width: 1079px)",y0=`${ei}, (pointer: coarse)`,j0=[8,18,30,42,88],ss=`
1563
1566
  .bim-rh { color: ${r("ink")}; font-family: ${r("font-ui")}; font-size: 14px; line-height: 1.6; }
1564
1567
  .bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
1565
1568
  .bim-rh a { color: ${r("accent")}; text-decoration: none; }
@@ -1707,7 +1710,7 @@ ${A??""}`,[Cn,us]=g.useState({key:$n,data:te,started:!!te});if(Cn.key!==$n)us({k
1707
1710
  flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
1708
1711
  color: ${r("ink")} !important; font-size: 13px;
1709
1712
  }
1710
- ${y0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${r("accent")} ${e}%, ${r("card-bg")}); }`).join(`
1713
+ ${j0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${r("accent")} ${e}%, ${r("card-bg")}); }`).join(`
1711
1714
  `)}
1712
1715
  .bim-rh-band a[data-k="4"] { color: ${r("page-bg")} !important; }
1713
1716
  .bim-rh-band a:hover { outline: 2px solid ${r("ink")}; outline-offset: -2px; }
@@ -1735,13 +1738,13 @@ ${y0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1735
1738
  }
1736
1739
 
1737
1740
  /* ── 中屏 ── */
1738
- @media ${x0} {
1741
+ @media ${b0} {
1739
1742
  .bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1740
1743
  .bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
1741
1744
  }
1742
1745
 
1743
1746
  /* ── 手机 ── */
1744
- @media ${Jn} {
1747
+ @media ${ei} {
1745
1748
  .bim-rh-main { padding-top: 24px; }
1746
1749
  .bim-rh-stats { gap: 4px 18px; }
1747
1750
  .bim-rh-stats b { font-size: 16px; }
@@ -1778,7 +1781,7 @@ ${y0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1778
1781
  }
1779
1782
 
1780
1783
  /* 触屏或窄屏:点击目标放大到 44px */
1781
- @media ${b0} {
1784
+ @media ${y0} {
1782
1785
  .bim-rh-rows a, .bim-rh-bu-l a, .bim-rh-au li a, .bim-rh-chip, .bim-rh-secnav a, .bim-rh-expand { min-height: 44px; display: flex; align-items: center; }
1783
1786
  .bim-rh-chip { display: inline-flex; }
1784
1787
  }
@@ -1789,7 +1792,7 @@ ${y0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1789
1792
  }
1790
1793
 
1791
1794
  @media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
1792
- `,j0=ao["zh-Hant"].period,op={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function qt(e){return{...op,...e??{}}}function os(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 Ki(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function sp(e,n=ao["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 ap(e){return Math.max(150,Array.from(e).length*18+44)}function lp(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 cp=.04;function Ze(e){return e.toLocaleString("en-US")}function dp({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function mt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=ie(),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 pp({counts:e}){const{t:n}=ie();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ze(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ze(e.pieces)}),n("readHome.pieces")]})]})}function up({picks:e,links:n}){const{t:i,convert:o}=ie(),s=qt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Ki(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(dp,{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 mp(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function ss({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ie(),c=qt(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=sp(e.items,l("readHome.shelfOther")),m=u=>{const f=u.records?Ze(u.records):mp(u.text_count,l),x=os(u),v=[d(u.title),u.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",u.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(u.id),"data-orig":u.orig?"":void 0,"aria-label":v,title:v,style:{height:ap(u.title)},children:[t.jsx(dp,{text:d(u.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":u.records?"":void 0,children:f})]})},u.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(u=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(u.label),children:u.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(u.label)})]},u.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(u=>t.jsx("span",{children:d(u)},u))]})]})}const v0=4,Vn=e=>e>v0+1;function hp({topic:e,links:n}){const{t:i,convert:o}=ie(),s=qt(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":Vn(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:Ze(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=mp(c.text_count,i),h=os(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)})}),Vn(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 gp({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(ss,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(hp,{topic:s,links:n},s.key))})]})}function fp({famous:e,links:n}){const{t:i,convert:o}=ie(),s=qt(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 as({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ie(),l=qt(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:Ze(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:Ze(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:Ze(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function xp({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ie(),l=a.readHome.period,d=qt(i),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,u)=>m+u.count,0),h=Math.max(...c.map(m=>m.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(m=>{const u=m.label?s(m.label):l[m.key]??s(m.key),f=m.count/p,x=o("readHome.periodItem",{label:u,n:Ze(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":lp(m.count,h),"data-narrow":f<cp?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:u}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(u)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ze(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:Ze(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function bp({authors:e,links:n}){const{t:i,convert:o}=ie(),s=qt(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:Ze(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 yp={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function k0({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ie(),l=e,d=yp,c=l.topics.filter(u=>!u.shelf),p={picks:l.picks.length>0,topics:c.some(u=>u.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(u=>u.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(u=>p[u]),m=u=>a(`readHome.nav.${u}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:rs}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(pp,{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(u=>t.jsx("li",{children:t.jsx("a",{href:`#${d[u]}`,children:m(u)})},u))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(mt,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(up,{picks:l.picks,links:n})}),p.topics&&t.jsx(mt,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(gp,{topics:c,links:n})}),p.famous&&t.jsx(mt,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(fp,{famous:l.famous,links:n})}),p.sibu&&t.jsx(mt,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(as,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(mt,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(xp,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(mt,{id:d.pieces,title:m("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(bp,{authors:l.pieces.authors,links:n})})]})]})}const w0="(max-width: 1079px)",S0=`${Jn}, (pointer: coarse)`,jp=`
1795
+ `,v0=co["zh-Hant"].period,rp={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function qt(e){return{...rp,...e??{}}}function as(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 qi(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function op(e,n=co["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 sp(e){return Math.max(150,Array.from(e).length*18+44)}function ap(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 lp=.04;function Qe(e){return e.toLocaleString("en-US")}function cp({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function mt({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 dp({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:Qe(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Qe(e.pieces)}),n("readHome.pieces")]})]})}function pp({picks:e,links:n}){const{t:i,convert:o}=ne(),s=qt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=qi(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(cp,{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 up(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function ls({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ne(),c=qt(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,h=op(e.items,l("readHome.shelfOther")),m=u=>{const f=u.records?Qe(u.records):up(u.text_count,l),x=as(u),v=[d(u.title),u.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",u.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(u.id),"data-orig":u.orig?"":void 0,"aria-label":v,title:v,style:{height:sp(u.title)},children:[t.jsx(cp,{text:d(u.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":u.records?"":void 0,children:f})]})},u.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(u=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(u.label),children:u.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(u.label)})]},u.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(u=>t.jsx("span",{children:d(u)},u))]})]})}const k0=4,Yn=e=>e>k0+1;function mp({topic:e,links:n}){const{t:i,convert:o}=ne(),s=qt(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":Yn(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:Qe(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=up(c.text_count,i),h=as(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)})}),Yn(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 hp({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(ls,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(mp,{topic:s,links:n},s.key))})]})}function gp({famous:e,links:n}){const{t:i,convert:o}=ne(),s=qt(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 cs({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ne(),l=qt(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:Qe(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:Qe(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:Qe(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function fp({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ne(),l=a.readHome.period,d=qt(i),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,u)=>m+u.count,0),h=Math.max(...c.map(m=>m.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(m=>{const u=m.label?s(m.label):l[m.key]??s(m.key),f=m.count/p,x=o("readHome.periodItem",{label:u,n:Qe(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":ap(m.count,h),"data-narrow":f<lp?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:u}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(u)[0]}),t.jsx("small",{className:"bim-rh-num",children:Qe(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:Qe(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function xp({authors:e,links:n}){const{t:i,convert:o}=ne(),s=qt(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:Qe(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 bp={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function w0({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ne(),l=e,d=bp,c=l.topics.filter(u=>!u.shelf),p={picks:l.picks.length>0,topics:c.some(u=>u.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(u=>u.count>0),pieces:l.pieces.authors.length>0},h=Object.keys(d).filter(u=>p[u]),m=u=>a(`readHome.nav.${u}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:ss}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(dp,{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(u=>t.jsx("li",{children:t.jsx("a",{href:`#${d[u]}`,children:m(u)})},u))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(mt,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(pp,{picks:l.picks,links:n})}),p.topics&&t.jsx(mt,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(hp,{topics:c,links:n})}),p.famous&&t.jsx(mt,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(gp,{famous:l.famous,links:n})}),p.sibu&&t.jsx(mt,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(cs,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(mt,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(fp,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(mt,{id:d.pieces,title:m("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(xp,{authors:l.pieces.authors,links:n})})]})]})}const S0="(max-width: 1079px)",_0=`${ei}, (pointer: coarse)`,yp=`
1793
1796
  /* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
1794
1797
  .bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
1795
1798
  .bim-mh-q { min-width: 0; }
@@ -1929,7 +1932,7 @@ ${y0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1929
1932
  .bim-mh-cc0 { display: inline-block; margin-right: 8px; padding: 1px 7px; font-size: 11.5px; letter-spacing: 0.08em; background: ${r("check-fine-bg")}; color: ${r("check-fine-fg")}; }
1930
1933
 
1931
1934
  /* ── 中屏 ── */
1932
- @media ${w0} {
1935
+ @media ${S0} {
1933
1936
  .bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
1934
1937
  .bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1935
1938
  .bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@@ -1939,7 +1942,7 @@ ${y0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1939
1942
  }
1940
1943
 
1941
1944
  /* ── 手机 ── */
1942
- @media ${Jn} {
1945
+ @media ${ei} {
1943
1946
  .bim-mh-cg, .bim-mh-data { grid-template-columns: minmax(0, 1fr); }
1944
1947
  .bim-mh-ge { grid-template-columns: repeat(4, minmax(0, 1fr)); }
1945
1948
  .bim-mh-lin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@@ -1956,8 +1959,8 @@ ${y0.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1956
1959
  .bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
1957
1960
  }
1958
1961
 
1959
- @media ${S0} {
1962
+ @media ${_0} {
1960
1963
  .bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
1961
1964
  .bim-mh-recent-h button { min-height: 44px; }
1962
1965
  }
1963
- `,vp={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Xt(e){return{...vp,...e??{}}}function kp(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 ls(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function wp(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,m=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,m),Math.max(h,m)]},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 Ni(e,n=wn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function _0(e){return{read:e.item,work:e.item,node:e.node}}function Sp({counts:e,links:n}){const{t:i}=ie(),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:Ze(d)})]})},a))})}function _p(e,n=5){const[i,o]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Kt().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>uo(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{po(),o([])},[]);return{entries:i,clear:s}}function $0(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):$p(e.type,n)}function $p(e,n){return n(`metaHome.typeLabel.${e}`)}function Cp({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ie(),a=Xt(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?$p(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:$0(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function zp(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 Np({rows:e,links:n}){const{t:i,convert:o}=ie(),s=Xt(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=ls(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:Ze(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ze(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:zp(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function Tp({items:e,links:n,label:i}){const{convert:o}=ie();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 Ip({works:e,links:n}){const{t:i}=ie(),[o,s]=g.useState(!1);if(!e.length)return null;const a=Vn(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(Tp,{items:e.map(l=>({id:l.id,title:l.title,sub:Ki(l)||void 0})),links:Xt(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 Ep="siku_qige";function C0({group:e,links:n}){const{t:i,convert:o}=ie(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Vn(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(Tp,{items:e.items,links:n,label:e.label}),Vn(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 Rp({groups:e,links:n}){const{t:i,convert:o}=ie(),s=Xt(n);if(!e.length)return null;const a=e.find(c=>c.key===Ep),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(C0,{group:c,links:s},c.key))})]})}const ul=34,ml=13;function hl(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?Ni(e.birth_year,n):"?"}–${e.death_year!=null?Ni(e.death_year,n):"?"}`}function z0(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 Lp({people:e,links:n}){const{t:i,convert:o}=ie(),s=Xt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=wp(e),p=[],h=d.map(u=>{const f=u.left>70,x=f?Math.min(u.left,u.left+u.width-ml):u.left;let v=0;for(;p[v]!=null&&p[v]>x;)v++;return p[v]=f?u.left+u.width:u.left+Math.max(u.width,ml),{...u,lane:v,end:f}}),m=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*ul+10},children:h.map(u=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":u.end?"":void 0,style:{left:`${u.left}%`,top:u.lane*ul+4,width:`${Math.max(u.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(u.p.id),children:[o(u.p.name),t.jsx("small",{className:"bim-rh-num",children:hl(u.p,i)})]})]},u.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:z0(a,l).map(u=>t.jsx("span",{style:{left:`${(u-a)/m*100}%`},children:Ni(u,i)},u))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(u=>t.jsx("li",{children:t.jsxs("a",{href:s.item(u.id),children:[t.jsx("span",{children:o(u.name)}),t.jsx("small",{className:"bim-rh-num",children:[u.dynasty?o(u.dynasty):"",hl(u,i)].filter(Boolean).join(" ")})]})},u.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(u=>u.name).join("、"))})})]})}const N0=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 Ap({works:e,links:n}){const{t:i,convert:o}=ie(),s=Xt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Ki(a);return t.jsx("li",{children:t.jsxs("a",{href:kp(s,a.id),children:[N0,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 Mp({sites:e}){const{t:n,convert:i}=ie(),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=ls(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:[`${Ze(a.imported)} / ${Ze(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:zp(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 gl=["extant","partially_extant","lost","unknown"];function Pp({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=ie(),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=gl.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:Ze(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:gl.map(p=>{var u;const h=((u=e.loss)==null?void 0:u[p])??0,m=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:Ze(h),note:m}):m})]})},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 Bp={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function T0({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:h}){var j,C;const{t:m}=ie(),u=e,f=Xt(n),x=_0(f),v=Bp,b=_p(o),$={zhi:!!((j=u.shelf)!=null&&j.items.length)||u.catalog_progress.length>0||u.related_catalogs.length>0,sibu:u.bu.length>0||u.unclassified>0,cong:u.collection_groups.length>0,people:u.bibliographers.length>0,lineage:u.lineage.length>0,sites:u.sites.length>0,data:!0},y=Object.keys(v).filter(_=>$[_]),w=_=>m(`metaHome.nav.${_}`),k=(_,S)=>_?t.jsx("a",{className:"bim-rh-more",href:_,children:S}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:rs+jp}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(Sp,{counts:u.counts,links:n})]}),o&&t.jsx(Cp,{entries:b.entries,onClear:b.clear,links:n})]}),y.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":m("metaHome.navLabel"),children:t.jsx("ul",{children:y.map(_=>t.jsx("li",{children:t.jsx("a",{href:`#${v[_]}`,children:w(_)})},_))})}),t.jsxs("div",{className:"bim-rh-main",children:[$.zhi&&t.jsxs(mt,{id:v.zhi,title:w("zhi"),sub:m("metaHome.zhiSub"),children:[u.shelf&&u.shelf.items.length>0&&t.jsx(ss,{topic:{key:"shelf",label:u.shelf.label,shelf:!0,items:u.shelf.items},links:x,showTitle:!1,legendCount:u.shelf.items.some(_=>_.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(u.catalog_progress.length>0||u.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(C=u.shelf)!=null&&C.items.length?void 0:{marginTop:0},children:[t.jsx(Np,{rows:u.catalog_progress,links:n}),t.jsx(Ip,{works:u.related_catalogs,links:n})]})]}),$.sibu&&t.jsx(mt,{id:v.sibu,title:w("sibu"),sub:m("metaHome.sibuSub"),more:k(s,m("metaHome.toCatalog")),children:t.jsx(as,{bu:u.bu,unclassified:u.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),$.cong&&t.jsx(mt,{id:v.cong,title:w("cong"),sub:m("metaHome.congSub"),more:k(a,m("metaHome.allNKindsMore",{n:Ze(u.counts.collections)})),children:t.jsx(Rp,{groups:u.collection_groups,links:n})}),$.people&&t.jsx(mt,{id:v.people,title:w("people"),sub:m("metaHome.peopleSub"),more:k(l,m("metaHome.allNPeopleMore",{n:Ze(u.counts.entities)})),children:t.jsx(Lp,{people:u.bibliographers,links:n})}),$.lineage&&t.jsx(mt,{id:v.lineage,title:w("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(Ap,{works:u.lineage,links:n})}),$.sites&&t.jsx(mt,{id:v.sites,title:w("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(Mp,{sites:u.sites})}),t.jsx(mt,{id:v.data,title:w("data"),sub:m("metaHome.dataSub"),children:t.jsx(Pp,{stats:u.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const Op=["_related","_catalogs","_collections","_members","_children"],I0=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Qr=e=>I0(e)&&!!e.h;function E0(e){return e?Op.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(Qr)}):!1}function R0(e,n){const i={...e};if(!n)return i;for(const o of Op){const s=e[o];!Array.isArray(s)||!s.some(Qr)||(i[o]=s.map(a=>{var c;if(!Qr(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 L0(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&&R0(d,E0(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const eo=({style:e})=>{const n=g.useContext(Et),{t:i}=ie();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")})]})},to=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=ie(),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 Cr(e){const n=e.text_count;return typeof n=="number"&&n>0}function zr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function A0(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const M0=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:m,initialPage:u=1,selectedLineageNodeId:f,onNavigate:x,onBack:v,backLabel:b,renderLink:$,assetBase:y,enrichDetail:w,getSourceLink:k,readLink:j,railTop:C,extraTabs:_=[],showFeedbackTab:S=!0,feedbackApiUrl:R,height:N,footerExtra:z,hideHeaderControls:M=!1,className:F,style:L})=>{const E=g.useMemo(()=>L0(n),[n]),P=Ee(),{t:Z,convert:oe}=ie(),[ae]=g.useState(()=>{if(!A0(e,i))return null;const ee={...i},te=o??zr(e,ee);return w&&w(te,ee),{id:e,entry:te,detail:ee}}),[H,ce]=g.useState((ae==null?void 0:ae.entry)??null),[V,ne]=g.useState((ae==null?void 0:ae.detail)??null),[je,ge]=g.useState(!ae),[Le,B]=g.useState(!1),[me,ze]=g.useState([]),[we,De]=g.useState(!1),[Pe,G]=g.useState(null),[he,Y]=g.useState(null),[re,K]=g.useState(null),[A,U]=g.useState(!1),q=g.useRef(null),D=g.useRef(0),[de,be]=g.useState(null),ve=l!==void 0?l:de,Re=g.useCallback(ee=>{d?d(ee):be(ee)},[d]),O=g.useCallback(async ee=>{if(!E.getCollectionCatalogs&&!E.getCollectionCatalog){ze([]);return}De(!0);try{if(E.getCollectionCatalogs)ze(await E.getCollectionCatalogs(ee)||[]);else if(E.getCollectionCatalog){const te=await E.getCollectionCatalog(ee);ze(te?[{resource_id:"",data:te}]:[])}}catch{ze([])}finally{De(!1)}},[E]),J=g.useCallback(async ee=>{var te,He;if(!E.getTextManifest||!E.getTextIndex){G(null),Y(ee);return}try{const Fe=_e.pickTextVersion(await E.getTextManifest(ee)),Ie=Fe?await E.getTextIndex(ee,Fe.key):null;G(Ie&&Ie.chapters.length>0?{chapters:Ie.chapters.map(xe=>({n:xe.n,title:xe.title,file:xe.file})),source:{name:((te=Ie.source)==null?void 0:te.name)??(Fe==null?void 0:Fe.source_name),license:((He=Ie.source)==null?void 0:He.license)??(Fe==null?void 0:Fe.license)??void 0}}:null)}catch{G(null)}finally{Y(ee)}},[E]),fe=g.useCallback(async(ee,te)=>{const He=++D.current,Fe=()=>He!==D.current;U(!0);try{if(E.getLineageGraph){const et=await E.getLineageGraph(ee);if(Fe())return;et&&K(et)}const Ie=te.version_graph;if(!Ie||!Ie.enabled){re||K(null),q.current=null;return}const xe=ko(te),Ce=(await Gi(xe,Vi,async et=>{try{return await E.getItem(et)}catch{return null}},Fe)).filter(Boolean);if(Fe())return;q.current={work:te,books:Ce};const Ve=h??Ie.default_collection??(Ie.core_books&&Ie.core_books.length>0?"core":"all"),Be=Ve==="core"&&Array.isArray(Ie.core_books)&&Ie.core_books.length>0?"core":Ve??"all";K(ki(te,Ce,Be))}catch{if(Fe())return;K(null),q.current=null}finally{Fe()||U(!1)}},[E]),W=g.useRef({initialDetail:i,initialEntry:o});W.current={initialDetail:i,initialEntry:o},g.useEffect(()=>{let ee=!1;D.current++,U(!1);const te=xe=>{xe.type==="collection"?O(e):xe.type==="work"?(xe.version_graph||E.getLineageGraph)&&fe(e,xe):xe.type==="book"&&Cr(xe)&&J(e)},He=W.current;let Fe=null;if(ae&&ae.id===e)Fe=ae;else if(He.initialDetail&&He.initialDetail.id===e){const xe={...He.initialDetail},Ye=He.initialEntry??zr(e,xe);w&&w(Ye,xe),Fe={entry:Ye,detail:xe}}return Fe?(B(!1),ze(xe=>xe.length?[]:xe),G(null),K(null),q.current=null,ce(Fe.entry),ne(Fe.detail),ge(!1),te(Fe.detail),()=>{ee=!0}):((async()=>{ge(!0),B(!1),ce(null),ne(null),ze([]),G(null),K(null),q.current=null;try{const xe=await E.getItem(e);if(ee)return;if(!xe){B(!0);return}const Ye=xe;let Ce=null;if(E.getEntry&&(Ce=await E.getEntry(e),ee))return;Ce||(Ce=zr(e,Ye)),w&&w(Ce,Ye),ce(Ce),ne(Ye),te(Ye)}catch{ee||B(!0)}finally{ee||ge(!1)}})(),()=>{ee=!0})},[e,E,ae,w,O,fe,J]),g.useEffect(()=>{const ee=q.current;!ee||!h||K(ki(ee.work,ee.books,h))},[h]);const se=[];if(V){if(se.push({key:"basic",label:P.detailTab.basicInfo}),V.type==="collection"){we&&me.length===0&&se.push({key:"catalog:loading",label:`${P.detailTab.catalog}…`});for(const ee of me)se.push({key:`catalog:${ee.resource_id}`,label:ee.short_name?`${oe(ee.short_name)}${P.detailTab.catalogSuffix}`:P.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&se.push({key:s,label:P.detailTab.fullText}),V.type==="work"&&(re||A)&&se.push({key:"lineage",label:A?`${P.detailTab.lineage}…`:P.detailTab.lineage});for(const ee of _)(ee.position??"before-feedback")==="before-feedback"&&ee.shouldShow(V)&&se.push({key:ee.key,label:ee.label});S&&s==="feedback"&&se.push({key:"feedback",label:P.detailTab.feedback});for(const ee of _)ee.position==="after-feedback"&&ee.shouldShow(V)&&se.push({key:ee.key,label:ee.label})}g.useEffect(()=>{if(s!=="emendated"||!V)return;a("basic");const ee=setTimeout(()=>{var te;(te=document.getElementById("studies"))==null||te.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(ee)},[s,V,a]);const X=H&&V&&k?k({activeTab:s,activeJuan:ve,entry:H,detail:V}):null,pe=g.useMemo(()=>{var Ie,xe,Ye,Ce,Ve;if(!V)return null;const te=(V.authors??[]).map(Be=>{const et=vo(Be.role);return`${Be.dynasty?`〔${oe(Be.dynasty)}〕`:""}${oe(Be.name)}${et?` ${oe(et)}`:""}`}).join(" · ");let He=!1;try{He=_e.extractStatus(V.id)==="draft"}catch{}if(V.type==="book"){const Be=V;return{title:oe(Be.title),subtitle:Be.edition?oe(Be.edition):te||void 0,aside:[He?P.status.draft:"",te&&Be.edition?te:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(V.type==="collection"){const Be=V;return{title:oe(Be.title),subtitle:oe(Dt(Be,P.unit.juan))||void 0,aside:[(Ie=Be.publication_info)==null?void 0:Ie.year,He?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:te||void 0}}if(V.type==="entity"){const Be=V,et=wt=>wt==null?"":wt<0?Z("detail.bce",{n:-wt}):String(wt),kt=((xe=Be.dates)==null?void 0:xe.birth)!=null||((Ye=Be.dates)==null?void 0:Ye.death)!=null?`${et(((Ce=Be.dates)==null?void 0:Ce.birth)??void 0)||"?"}—${et(((Ve=Be.dates)==null?void 0:Ve.death)??void 0)||"?"}`:"";return{title:oe(Be.primary_name||Be.title),subtitle:[Be.dynasty?`〔${oe(Be.dynasty)}〕`:"",kt].filter(Boolean).join(" ")||void 0,aside:He?P.status.draft:void 0,secondLine:void 0}}const Fe=oe(Dt(V,P.unit.juan));return{title:oe(V.title),subtitle:[Fe,te].filter(Boolean).join(" · ")||void 0,aside:[B0(P,V.subtype),He?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[V,oe,P,Z]),$e=V&&Cr(V)?"text":null,Ae=()=>{Re(null),a("fulltext")};let Oe=null;if(V&&j){const ee=j({detail:V,kind:$e});ee&&(Oe=t.jsx(Or,{href:ee}))}else $e&&(Oe=t.jsx(Or,{onClick:Ae}));const Je=ee=>{if(!V)return null;const te=ee.replace(/\.[^.]+$/,"");if(j){const He=j({detail:V,kind:$e,juan:te});return He?{href:He}:null}return{onClick:()=>{Re(te),a("fulltext")}}},Qe=new Set(_.map(ee=>ee.key)),T=se.filter(ee=>ee.key.startsWith("catalog:")&&ee.key!=="catalog:loading"||ee.key==="lineage"&&!!re&&!A||Qe.has(ee.key)).map(ee=>({key:ee.key,label:ee.label,onClick:()=>a(ee.key)})),ue=()=>{var ee;return V?V.type==="work"?t.jsx(Hd,{data:V,transport:E,onNavigate:x,renderLink:$,readAction:Oe,railTop:C,railLinks:T}):V.type==="book"?t.jsx(Gd,{data:V,transport:E,onNavigate:x,renderLink:$,readAction:Oe,fullText:Pe,fullTextPending:Cr(V)&&!!E.getTextManifest&&he!==V.id,chapterLink:Je,railTop:C,railLinks:T}):V.type==="collection"?t.jsx(Yd,{data:V,catalog:(ee=me[0])==null?void 0:ee.data,transport:E,onNavigate:x,renderLink:$,readAction:Oe,railTop:C,railLinks:T,catalogAction:me.length>0?t.jsxs("a",{href:"#catalog",onClick:te=>{te.preventDefault(),a(`catalog:${me[0].resource_id}`)},children:[oe(P.detailTab.collectionCatalog)," →"]}):null}):t.jsx(qd,{data:V,transport:E,onNavigate:x,renderLink:$,railTop:C,railLinks:T,assetBase:y}):null},ye=()=>{var te,He,Fe;if(!H||!V)return null;if(s==="basic"||s==="emendated")return ue();if(typeof s=="string"&&s.startsWith("catalog:")){const Ie=(te=me.find(xe=>`catalog:${xe.resource_id}`===s))==null?void 0:te.data;return t.jsx(ho,{data:Ie,onNavigate:x,renderLink:$})}if(s==="collated"||s==="fulltext")return t.jsx(qo,{id:e,transport:E,chapter:ve,onLocationChange:Ie=>Re(Ie.chapter),onNavigate:x});if(s==="lineage"){if(!re)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:Z(A?"detail.loading":"detail.noLineageGraph")});const Ie=V.type==="work"?V:null;return t.jsx(es,{graph:re,renderLink:$,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:h??((He=Ie==null?void 0:Ie.version_graph)==null?void 0:He.default_collection),onCollectionChange:m,collectionsAvailable:(Fe=Ie==null?void 0:Ie.version_graph)==null?void 0:Fe.collections,collectionCounts:(()=>{var Ve,Be,et,kt,wt,cn,Ct;if(!Ie)return;const xe={},Ye=((Ve=q.current)==null?void 0:Ve.books)??[];xe.all=(((Be=Ie._books)==null?void 0:Be.length)??0)-(((kt=(et=Ie.version_graph)==null?void 0:et.excluded_books)==null?void 0:kt.length)??0);const Ce=(wt=Ie.version_graph)==null?void 0:wt.collections;if(Ce)for(const Q of Object.keys(Ce))xe[Q]=ki(Ie,Ye,Q).nodes.filter(Ge=>Ge.kind==="book"&&!Ge.bridge).length;return xe.core==null&&((Ct=(cn=Ie.version_graph)==null?void 0:cn.core_books)!=null&&Ct.length)&&(xe.core=Ie.version_graph.core_books.length),xe})()})}if(s==="feedback"&&S)return t.jsx(Bd,{resourceId:e,apiUrl:R});const ee=_.find(Ie=>Ie.key===s);return ee?ee.render({detail:V,entry:H,transport:E,onNavigate:x}):null};if(je)return t.jsx(Bn,{style:{minHeight:N,...L},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((ee,te)=>t.jsx("div",{style:{height:te===1?40:16,width:ee,opacity:.35,background:r("rule")}},te))})});if(Le||!V||!H||!pe)return t.jsx(Bn,{style:{minHeight:N,...L},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:Z("detail.notFound")})});const ke=s==="basic"||s==="emendated",Ne=[{label:b??P.detailTab.backToIndex,onClick:v}];if(V.type==="book"&&V.work_id){const ee=V.work_id;Ne.push({label:P.indexType.work,id:ee,onClick:()=>x==null?void 0:x(ee)})}Ne.push({label:P.indexType[V.type]});const Se=s==="collated"||s==="fulltext",Ke=typeof z=="string"?P.status[z.trim()]??z:z,We=t.jsx(Fc,{left:t.jsxs(t.Fragment,{children:[Ke,Ke?" · ":"",t.jsx(P0,{id:V.id,label:P.label.id,copied:P.action.copied,copyLabel:P.action.copy})]}),right:t.jsxs(t.Fragment,{children:[S&&!ke&&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:P.detailTab.submitVersion}),X&&t.jsx("a",{href:X.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:P.detailTab.dataLicense})]})});return ke?t.jsx("div",{className:F,children:t.jsxs(Bn,{grid:!0,style:{minHeight:N,...L},children:[t.jsx(Wr,{breadcrumb:t.jsx(Fr,{items:Ne}),actions:t.jsxs(t.Fragment,{children:[!M&&t.jsx(eo,{style:{border:"none",background:"transparent"}}),!M&&X&&t.jsx(to,{...X})]})}),ue(),We]})}):t.jsx("div",{className:F,children:t.jsxs(Bn,{wide:Se,style:{minHeight:N,...L},children:[t.jsx(Wr,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(Co,{char:"籍"}),t.jsx(Fr,{items:Ne})]}),actions:t.jsxs(t.Fragment,{children:[!M&&t.jsx(eo,{}),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:P.detailTab.feedback}),!M&&X&&t.jsx(to,{...X})]})}),t.jsx(Ec,{...pe,aside:Se?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:[Z("detail.workInfo")," →"]}):pe.aside}),!Se&&se.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:se.map(ee=>t.jsx(Rc,{label:ee.label,active:ee.key===s||ke&&ee.key==="basic",onClick:()=>a(ee.key)},ee.key))}),t.jsx("div",{style:{marginTop:!Se&&se.length>1?8:0},children:ye()}),We]})})};function P0({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 B0(e,n){return n?e.workSubtype[n]??n:""}const Wp=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],qi="zhusha",Xi="bim-theme";function Fp(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Zi(e){return Fp(e)?e:qi}function O0(){try{return Zi(window.localStorage.getItem(Xi))}catch{return qi}}function Hp(e){try{window.localStorage.setItem(Xi,e)}catch{}}function Dp(e){const n=Zi(e);return document.documentElement.setAttribute("data-theme",n),n}function Up(){return Zi(document.documentElement.getAttribute("data-theme"))}const W0=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],cs="airy",Ji="bim-layout";function Vp(e){return e==="airy"||e==="boxed"}function Qi(e){return Vp(e)?e:cs}function F0(){try{return Qi(window.localStorage.getItem(Ji))}catch{return cs}}function H0(e){try{window.localStorage.setItem(Ji,e)}catch{}}function D0(e){const n=Qi(e);return document.documentElement.setAttribute("data-layout",n),n}function U0(){return Qi(document.documentElement.getAttribute("data-layout"))}const V0=`try{var t=localStorage.getItem(${JSON.stringify(Xi)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Ji)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,G0={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},Y0=({onChange:e,style:n})=>{const{t:i}=ie(),[o,s]=g.useState(qi);g.useEffect(()=>{s(Up())},[]);const a=l=>{s(Dp(l)),Hp(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Wp.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(G0[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=_e.BidLink;exports.BookIndexError=_e.BookIndexError;exports.BookIndexManager=_e.BookIndexManager;exports.BookIndexStorage=_e.BookIndexStorage;exports.BundleStorage=_e.BundleStorage;exports.ConfigError=_e.ConfigError;exports.GithubStorage=_e.GithubStorage;exports.IdGenerationError=_e.IdGenerationError;exports.IdGenerator=_e.IdGenerator;exports.LocalStorage=_e.LocalStorage;exports.MigrationError=_e.MigrationError;exports.StorageError=_e.StorageError;exports.VARIANT_CHARS=_e.VARIANT_CHARS;exports.base36Decode=_e.base36Decode;exports.base36Encode=_e.base36Encode;exports.base58Decode=_e.base58Decode;exports.buildId=_e.buildId;exports.buildPromotionMap=_e.buildPromotionMap;exports.cleanName=_e.cleanName;exports.decodeId=_e.decodeId;exports.decodeIdString=_e.decodeIdString;exports.encodeId=_e.encodeId;exports.extractIdFromUrl=_e.extractIdFromUrl;exports.extractStatus=_e.extractStatus;exports.extractType=_e.extractType;exports.isChapterSegment=_e.isChapterSegment;exports.isTextKey=_e.isTextKey;exports.matchChapterAcrossVersions=_e.matchChapterAcrossVersions;exports.normalizeCatalog=_e.normalizeCatalog;exports.normalizeVariants=_e.normalizeVariants;exports.parseId=_e.parseId;exports.pickTextVersion=_e.pickTextVersion;exports.shardOf=_e.shardOf;exports.smartDecode=_e.smartDecode;exports.textVersionLabel=_e.textVersionLabel;exports.validateResource=_e.validateResource;exports.VARIANT_SUPPLEMENT=fl.VARIANT_SUPPLEMENT;exports.Badge=zi;exports.BidUrlProvider=xu;exports.BookDetailLayout=M0;exports.BookPage=Gd;exports.Breadcrumb=Fr;exports.CATALOG_ALL_ID=Ot;exports.CATALOG_CSS=Xd;exports.CATALOG_NARROW_QUERY=ts;exports.CATALOG_PAGE_SIZE=ns;exports.CATALOG_UNCLASSIFIED_ID=rn;exports.CLASSIFICATIONS=Ai;exports.COMMON_TRADITIONAL_CHARS=Cl;exports.CardFoot=qn;exports.CatalogPage=f0;exports.CatalogPager=ip;exports.CatalogTree=Jd;exports.CheckFilter=Nc;exports.Chip=Lc;exports.ChipWall=vg;exports.CollectionCatalog=ho;exports.CollectionPage=Yd;exports.CreateEntityDialog=Td;exports.DEFAULT_LAYOUT=cs;exports.DEFAULT_META_HOME_LINKS=vp;exports.DEFAULT_READER_PREFS=fo;exports.DEFAULT_READ_HOME_LINKS=op;exports.DEFAULT_THEME=qi;exports.DETAIL_CSS=Ic;exports.DYNASTY_GROUPS=Li;exports.Dash=Cg;exports.DataTable=wg;exports.DetailFooter=Fc;exports.DetailGrid=Yn;exports.DetailHeader=Ec;exports.EMPTY_FILTERS=Ri;exports.ENTITY_TEXT_CSS=Do;exports.EmendatedBySection=ql;exports.EmptyNote=Lg;exports.EntityDetail=Dl;exports.EntityMark=Vo;exports.EntityPage=qd;exports.EntityPickerDialog=Ed;exports.EntitySelector=Nd;exports.EntityText=Qf;exports.ExpandRow=zg;exports.ExtLink=Ag;exports.FEEDBACK_FAB_OFFSET_VAR=qr;exports.FILTER_SUPPORT=Ll;exports.FONT_SIZE_STEPS=Bt;exports.FactList=xg;exports.FeedbackButton=Jb;exports.FeedbackDialog=Md;exports.FeedbackForm=Pd;exports.FeedbackList=Xo;exports.FeedbackTab=Bd;exports.FilterChip=Rc;exports.FormInput=xt;exports.FormTextArea=sn;exports.GUJI_MARKDOWN_FIELD=ng;exports.GUJI_TABLE_NOTATION=Hc;exports.GlyphBadge=Co;exports.GujiInteractiveReader=Vx;exports.GujiTable=To;exports.GujiTextViewer=Go;exports.GujiWarpCanvas=Ho;exports.HomePage=Yr;exports.ImagePanel=Rr;exports.IndexApp=Ux;exports.IndexBrowser=Ir;exports.IndexDetail=mo;exports.IndexEditor=Rd;exports.IndexView=Bb;exports.IntroGrid=fg;exports.LAYOUTS=W0;exports.LAYOUT_STORAGE_KEY=Ji;exports.LOSS_OPTIONS=Rl;exports.LocaleContext=Et;exports.LocaleProvider=Vu;exports.LocaleToggle=eo;exports.META_HOME_CSS=jp;exports.META_HOME_SECTION_IDS=Bp;exports.MetaCatalogTable=Np;exports.MetaCollectionGroups=Rp;exports.MetaDataLicense=Pp;exports.MetaHomeView=T0;exports.MetaLine=st;exports.MetaLineageCards=Ap;exports.MetaOnlineSites=Mp;exports.MetaPeopleTimeline=Lp;exports.MetaRecentPanel=Cp;exports.MetaRelatedCatalogs=Ip;exports.MetaTypeChips=Sp;exports.ModeIndicator=Nl;exports.MoreButton=jg;exports.MoreLink=_o;exports.PAGE_MAX_WIDTH=yi;exports.PERIOD_NARROW_SHARE=cp;exports.PageFrame=Bn;exports.Quote=Tg;exports.READER_CSS=tc;exports.READ_HOME_CSS=rs;exports.READ_HOME_NARROW_QUERY=Jn;exports.READ_HOME_SECTION_IDS=yp;exports.READ_PERIOD_LABELS=j0;exports.RECENT_IDS_STORAGE_KEY=fn;exports.ROLE_CLASS_ORDER=bc;exports.ReadButton=Or;exports.ReadFamousWorks=fp;exports.ReadHomeView=k0;exports.ReadPeriodBand=xp;exports.ReadPicks=up;exports.ReadPieces=bp;exports.ReadSection=mt;exports.ReadShelf=ss;exports.ReadSibu=as;exports.ReadStats=pp;exports.ReadTopicGroup=hp;exports.ReadTopics=gp;exports.ReaderMdText=Lo;exports.ReaderShell=cc;exports.ReaderToc=nc;exports.RelationPanel=Cd;exports.RepoSourceLink=to;exports.ResourceEditor=Nr;exports.ResourceGroup=Ig;exports.ResourceLine=Eg;exports.ResourceList=lo;exports.ResourceRow=Oc;exports.SEARCH_VIEW_STORAGE_KEY=co;exports.SEVEN_PAVILIONS_KEY=Ep;exports.SNIPPET_MARK_END=yl;exports.SNIPPET_MARK_START=bl;exports.SORTABLE_TYPES=El;exports.SearchInput=Il;exports.SearchResults=Wl;exports.Sec=at;exports.Section=_t;exports.SectionHead=bg;exports.SideList=on;exports.SmartBidInput=vi;exports.SourceEditor=Sd;exports.StripWarpRenderer=Ur;exports.SummaryCard=Kn;exports.THEMES=Wp;exports.THEME_INIT_SCRIPT=V0;exports.THEME_STORAGE_KEY=Xi;exports.TRADITIONAL_ALLOWLIST=zl;exports.TabFilter=Fi;exports.TableHead=Sg;exports.TableRow=_g;exports.TagRow=Wc;exports.TagRows=Rg;exports.TextButton=yg;exports.TextReader=qo;exports.ThemeToggle=Y0;exports.TopStrip=Wr;exports.VersionLineageGraph=Vd;exports.VersionLineageList=Ud;exports.VersionLineageView=es;exports.VolumeChips=kg;exports.VolumeLinks=zo;exports.WorkCard=tp;exports.WorkCardGrid=rp;exports.WorkCatalog=ib;exports.WorkPage=Hd;exports.WorkRow=np;exports.adaptCharCord=nb;exports.adaptEntityJson=ed;exports.adaptNorm=wd;exports.adaptNormDetailed=kd;exports.adaptPunctJson=qx;exports.applyLayout=D0;exports.applyTheme=Dp;exports.authorsLine=Ki;exports.bookIndexUriToId=Dr;exports.bookMarkingOf=Ro;exports.bucketResources=yo;exports.buildCatalogTree=a0;exports.buildCollectionTable=vc;exports.buildLineageGraph=ki;exports.buildMeiliFilter=cm;exports.buildPageUrl=so;exports.buildParagraphBlocks=qc;exports.buildVersionRow=fc;exports.buildVersionTable=xc;exports.canParagraphize=$i;exports.catalogNodeIdOf=o0;exports.catalogNodeIdsOf=s0;exports.catalogPageCount=p0;exports.catalogTotal=is;exports.classificationPath=Zn;exports.clearAllRecentIds=po;exports.compareCatalogCards=d0;exports.computeVersionPartition=qh;exports.countActiveFilters=Mi;exports.createTextApi=Zl;exports.currentLayout=U0;exports.currentTheme=Up;exports.defaultEntityHref=cd;exports.defaultWorkLink=Qd;exports.deriveDating=Hh;exports.deriveEditionType=wc;exports.deriveEra=Gn;exports.deriveYear=Bi;exports.deriveYearRange=bo;exports.detailToEditor=Ad;exports.detectGenre=Di;exports.displayAuthorRole=vo;exports.editorToDetail=Pb;exports.eraRank=Pr;exports.filtersFromParams=dm;exports.filtersToParams=wi;exports.findCatalogPath=gn;exports.findTraditionalChars=Ku;exports.firstAuthorText=os;exports.flattenTitles=Hr;exports.flattenToc=lc;exports.fmtCount=Ze;exports.formatHitCount=fi;exports.formatTemplate=bt;exports.formatVolumeRange=Wi;exports.getDisplayNameFromUrl=jn;exports.getMessages=kn;exports.getStartPage=oo;exports.getT=wn;exports.getTypeGroupKey=io;exports.groupRelatedWorks=Dh;exports.gujiInlineToPlain=Cc;exports.hasActiveFilters=Al;exports.hasGujiMarkdownV02=ig;exports.hasGujiTableNotation=Mg;exports.hasSearchOptions=sm;exports.headingKey=Ko;exports.headingsFromPunct=md;exports.iiifVolumeOf=Xx;exports.isCountedChar=Ao;exports.isLayoutName=Vp;exports.isThemeName=Fp;exports.lineageHref=kp;exports.loadRecentIds=Kt;exports.measureText=Dt;exports.mergeVolumeResources=ro;exports.nestHeadings=fd;exports.normalizeEra=ot;exports.normalizeLayout=Qi;exports.normalizeRole=jo;exports.normalizeTheme=Zi;exports.normalizeVolumeIndex=Fn;exports.normalizeVolumes=kl;exports.numberToChinese=kc;exports.paginationItems=Zd;exports.parseChineseNumber=Si;exports.parseGujiInline=$c;exports.parseGujiTable=Uc;exports.parseHeadingKey=gd;exports.parseSourceString=_d;exports.pct=ls;exports.periodLevel=lp;exports.pickReaderVersion=ac;exports.readStoredLayout=F0;exports.readStoredTheme=O0;exports.readerVersionOptionLabel=Ar;exports.remapPlainOffsets=td;exports.removeRecentId=Fl;exports.renderFullTextBody=Gg;exports.renderProperNames=Jc;exports.renderReaderInline=Ui;exports.resolveRecentEntry=uo;exports.resourceHref=vn;exports.resourceNote=Oi;exports.resultTabFromParam=jm;exports.resultTabToParam=vm;exports.roleFacets=yc;exports.rowNo=$g;exports.sameFilters=pm;exports.sanitizeHeadings=hd;exports.saveRecentId=Tr;exports.segmentEntities=nd;exports.shelfColumns=sp;exports.sortFor=am;exports.sortYear=_i;exports.spineHeight=ap;exports.splitFullTextTables=No;exports.splitHighlightSnippet=no;exports.splitTableRow=Dc;exports.storeLayout=H0;exports.storeTheme=Hp;exports.stringifySources=$d;exports.summaryFromEntry=ad;exports.summaryFromItem=sd;exports.timelineLayout=wp;exports.toCatalogWorkCard=c0;exports.transportSummaryLoader=ld;exports.typeSupportsFilters=Ml;exports.useBidUrl=rt;exports.useChapterWarpData=ud;exports.useConvert=Me;exports.useEntitySummaryLoader=Uo;exports.useI18n=ie;exports.useReaderPrefs=sc;exports.useRecentEntries=_p;exports.useT=Ee;exports.validateLineageGraph=wy;exports.volumeStats=Ti;exports.withDefaultLinks=qt;exports.withMetaLinks=Xt;exports.yearText=Ni;
1966
+ `,jp={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Xt(e){return{...jp,...e??{}}}function vp(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 ds(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function kp(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,m=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(h,m),Math.max(h,m)]},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 Ti(e,n=Sn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function $0(e){return{read:e.item,work:e.item,node:e.node}}function wp({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:Qe(d)})]})},a))})}function Sp(e,n=5){const[i,o]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Kt().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>vo(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{jo(),o([])},[]);return{entries:i,clear:s}}function C0(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):_p(e.type,n)}function _p(e,n){return n(`metaHome.typeLabel.${e}`)}function $p({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ne(),a=Xt(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?_p(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:C0(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function Cp(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 zp({rows:e,links:n}){const{t:i,convert:o}=ne(),s=Xt(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=ds(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:Qe(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Qe(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:Cp(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function Np({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 Tp({works:e,links:n}){const{t:i}=ne(),[o,s]=g.useState(!1);if(!e.length)return null;const a=Yn(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(Np,{items:e.map(l=>({id:l.id,title:l.title,sub:qi(l)||void 0})),links:Xt(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 Ip="siku_qige";function z0({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":Yn(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(Np,{items:e.items,links:n,label:e.label}),Yn(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 Rp({groups:e,links:n}){const{t:i,convert:o}=ne(),s=Xt(n);if(!e.length)return null;const a=e.find(c=>c.key===Ip),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(z0,{group:c,links:s},c.key))})]})}const ml=34,hl=13;function gl(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?Ti(e.birth_year,n):"?"}–${e.death_year!=null?Ti(e.death_year,n):"?"}`}function N0(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 Ep({people:e,links:n}){const{t:i,convert:o}=ne(),s=Xt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=kp(e),p=[],h=d.map(u=>{const f=u.left>70,x=f?Math.min(u.left,u.left+u.width-hl):u.left;let v=0;for(;p[v]!=null&&p[v]>x;)v++;return p[v]=f?u.left+u.width:u.left+Math.max(u.width,hl),{...u,lane:v,end:f}}),m=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*ml+10},children:h.map(u=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":u.end?"":void 0,style:{left:`${u.left}%`,top:u.lane*ml+4,width:`${Math.max(u.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(u.p.id),children:[o(u.p.name),t.jsx("small",{className:"bim-rh-num",children:gl(u.p,i)})]})]},u.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:N0(a,l).map(u=>t.jsx("span",{style:{left:`${(u-a)/m*100}%`},children:Ti(u,i)},u))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":h.length?void 0:"",children:(h.length?e:c).map(u=>t.jsx("li",{children:t.jsxs("a",{href:s.item(u.id),children:[t.jsx("span",{children:o(u.name)}),t.jsx("small",{className:"bim-rh-num",children:[u.dynasty?o(u.dynasty):"",gl(u,i)].filter(Boolean).join(" ")})]})},u.id))}),c.length>0&&h.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(u=>u.name).join("、"))})})]})}const T0=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 Lp({works:e,links:n}){const{t:i,convert:o}=ne(),s=Xt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=qi(a);return t.jsx("li",{children:t.jsxs("a",{href:vp(s,a.id),children:[T0,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 Ap({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=ds(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:[`${Qe(a.imported)} / ${Qe(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:Cp(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 fl=["extant","partially_extant","lost","unknown"];function Mp({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=fl.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:Qe(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:fl.map(p=>{var u;const h=((u=e.loss)==null?void 0:u[p])??0,m=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:Qe(h),note:m}):m})]})},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 Pp={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function I0({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:m}=ne(),u=e,f=Xt(n),x=$0(f),v=Pp,b=Sp(o),_={zhi:!!((k=u.shelf)!=null&&k.items.length)||u.catalog_progress.length>0||u.related_catalogs.length>0,sibu:u.bu.length>0||u.unclassified>0,cong:u.collection_groups.length>0,people:u.bibliographers.length>0,lineage:u.lineage.length>0,sites:u.sites.length>0,data:!0},y=Object.keys(v).filter($=>_[$]),w=$=>m(`metaHome.nav.${$}`),j=($,S)=>$?t.jsx("a",{className:"bim-rh-more",href:$,children:S}):void 0;return t.jsxs("div",{className:h?`bim-rh bim-mh ${h}`:"bim-rh bim-mh",children:[t.jsx("style",{children:ss+yp}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(wp,{counts:u.counts,links:n})]}),o&&t.jsx($p,{entries:b.entries,onClear:b.clear,links:n})]}),y.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":m("metaHome.navLabel"),children:t.jsx("ul",{children:y.map($=>t.jsx("li",{children:t.jsx("a",{href:`#${v[$]}`,children:w($)})},$))})}),t.jsxs("div",{className:"bim-rh-main",children:[_.zhi&&t.jsxs(mt,{id:v.zhi,title:w("zhi"),sub:m("metaHome.zhiSub"),children:[u.shelf&&u.shelf.items.length>0&&t.jsx(ls,{topic:{key:"shelf",label:u.shelf.label,shelf:!0,items:u.shelf.items},links:x,showTitle:!1,legendCount:u.shelf.items.some($=>$.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(u.catalog_progress.length>0||u.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(C=u.shelf)!=null&&C.items.length?void 0:{marginTop:0},children:[t.jsx(zp,{rows:u.catalog_progress,links:n}),t.jsx(Tp,{works:u.related_catalogs,links:n})]})]}),_.sibu&&t.jsx(mt,{id:v.sibu,title:w("sibu"),sub:m("metaHome.sibuSub"),more:j(s,m("metaHome.toCatalog")),children:t.jsx(cs,{bu:u.bu,unclassified:u.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),_.cong&&t.jsx(mt,{id:v.cong,title:w("cong"),sub:m("metaHome.congSub"),more:j(a,m("metaHome.allNKindsMore",{n:Qe(u.counts.collections)})),children:t.jsx(Rp,{groups:u.collection_groups,links:n})}),_.people&&t.jsx(mt,{id:v.people,title:w("people"),sub:m("metaHome.peopleSub"),more:j(l,m("metaHome.allNPeopleMore",{n:Qe(u.counts.entities)})),children:t.jsx(Ep,{people:u.bibliographers,links:n})}),_.lineage&&t.jsx(mt,{id:v.lineage,title:w("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(Lp,{works:u.lineage,links:n})}),_.sites&&t.jsx(mt,{id:v.sites,title:w("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(Ap,{sites:u.sites})}),t.jsx(mt,{id:v.data,title:w("data"),sub:m("metaHome.dataSub"),children:t.jsx(Mp,{stats:u.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const Bp=["_related","_catalogs","_collections","_members","_children"],R0=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),to=e=>R0(e)&&!!e.h;function E0(e){return e?Bp.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(to)}):!1}function L0(e,n){const i={...e};if(!n)return i;for(const o of Bp){const s=e[o];!Array.isArray(s)||!s.some(to)||(i[o]=s.map(a=>{var c;if(!to(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 A0(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&&L0(d,E0(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const no=({style:e})=>{const n=g.useContext(Rt),{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")})]})},io=({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 Nr(e){const n=e.text_count;return typeof n=="number"&&n>0}function Tr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function M0(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const P0=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:h,onLineageCollectionChange:m,initialPage:u=1,selectedLineageNodeId:f,onNavigate:x,onBack:v,backLabel:b,renderLink:_,assetBase:y,enrichDetail:w,getSourceLink:j,readLink:k,railTop:C,extraTabs:$=[],showFeedbackTab:S=!0,feedbackApiUrl:E,height:N,footerExtra:z,hideHeaderControls:O=!1,className:F,style:A})=>{const I=g.useMemo(()=>A0(n),[n]),P=Ee(),{t:K,convert:oe}=ne(),[le]=g.useState(()=>{if(!M0(e,i))return null;const Q={...i},ee=o??Tr(e,Q);return w&&w(ee,Q),{id:e,entry:ee,detail:Q}}),[H,de]=g.useState((le==null?void 0:le.entry)??null),[U,te]=g.useState((le==null?void 0:le.detail)??null),[ve,fe]=g.useState(!le),[Ae,B]=g.useState(!1),[me,ze]=g.useState([]),[we,De]=g.useState(!1),[Pe,G]=g.useState(null),[he,q]=g.useState(null),[se,Y]=g.useState(null),[M,X]=g.useState(!1),J=g.useRef(null),D=g.useRef(0),[ye,ue]=g.useState(null),ge=l!==void 0?l:ye,Ie=g.useCallback(Q=>{d?d(Q):ue(Q)},[d]),L=g.useCallback(async Q=>{if(!I.getCollectionCatalogs&&!I.getCollectionCatalog){ze([]);return}De(!0);try{if(I.getCollectionCatalogs)ze(await I.getCollectionCatalogs(Q)||[]);else if(I.getCollectionCatalog){const ee=await I.getCollectionCatalog(Q);ze(ee?[{resource_id:"",data:ee}]:[])}}catch{ze([])}finally{De(!1)}},[I]),ie=g.useCallback(async Q=>{var ee,Fe;if(!I.getTextManifest||!I.getTextIndex){G(null),q(Q);return}try{const We=$e.pickTextVersion(await I.getTextManifest(Q)),Re=We?await I.getTextIndex(Q,We.key):null;G(Re&&Re.chapters.length>0?{chapters:Re.chapters.map(be=>({n:be.n,title:be.title,file:be.file})),source:{name:((ee=Re.source)==null?void 0:ee.name)??(We==null?void 0:We.source_name),license:((Fe=Re.source)==null?void 0:Fe.license)??(We==null?void 0:We.license)??void 0}}:null)}catch{G(null)}finally{q(Q)}},[I]),je=g.useCallback(async(Q,ee)=>{const Fe=++D.current,We=()=>Fe!==D.current;X(!0);try{if(I.getLineageGraph){const et=await I.getLineageGraph(Q);if(We())return;et&&Y(et)}const Re=ee.version_graph;if(!Re||!Re.enabled){se||Y(null),J.current=null;return}const be=xo(ee),Ce=(await Yi(be,Gi,async et=>{try{return await I.getItem(et)}catch{return null}},We)).filter(Boolean);if(We())return;J.current={work:ee,books:Ce};const Ve=h??Re.default_collection??(Re.core_books&&Re.core_books.length>0?"core":"all"),Be=Ve==="core"&&Array.isArray(Re.core_books)&&Re.core_books.length>0?"core":Ve??"all";Y(wi(ee,Ce,Be))}catch{if(We())return;Y(null),J.current=null}finally{We()||X(!1)}},[I]),W=g.useRef({initialDetail:i,initialEntry:o});W.current={initialDetail:i,initialEntry:o},g.useEffect(()=>{let Q=!1;D.current++,X(!1);const ee=be=>{be.type==="collection"?L(e):be.type==="work"?(be.version_graph||I.getLineageGraph)&&je(e,be):be.type==="book"&&Nr(be)&&ie(e)},Fe=W.current;let We=null;if(le&&le.id===e)We=le;else if(Fe.initialDetail&&Fe.initialDetail.id===e){const be={...Fe.initialDetail},Ye=Fe.initialEntry??Tr(e,be);w&&w(Ye,be),We={entry:Ye,detail:be}}return We?(B(!1),ze(be=>be.length?[]:be),G(null),Y(null),J.current=null,de(We.entry),te(We.detail),fe(!1),ee(We.detail),()=>{Q=!0}):((async()=>{fe(!0),B(!1),de(null),te(null),ze([]),G(null),Y(null),J.current=null;try{const be=await I.getItem(e);if(Q)return;if(!be){B(!0);return}const Ye=be;let Ce=null;if(I.getEntry&&(Ce=await I.getEntry(e),Q))return;Ce||(Ce=Tr(e,Ye)),w&&w(Ce,Ye),de(Ce),te(Ye),ee(Ye)}catch{Q||B(!0)}finally{Q||fe(!1)}})(),()=>{Q=!0})},[e,I,le,w,L,je,ie]),g.useEffect(()=>{const Q=J.current;!Q||!h||Y(wi(Q.work,Q.books,h))},[h]);const ae=[];if(U){if(ae.push({key:"basic",label:P.detailTab.basicInfo}),U.type==="collection"){we&&me.length===0&&ae.push({key:"catalog:loading",label:`${P.detailTab.catalog}…`});for(const Q of me)ae.push({key:`catalog:${Q.resource_id}`,label:Q.short_name?`${oe(Q.short_name)}${P.detailTab.catalogSuffix}`:P.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&ae.push({key:s,label:P.detailTab.fullText}),U.type==="work"&&(se||M)&&ae.push({key:"lineage",label:M?`${P.detailTab.lineage}…`:P.detailTab.lineage});for(const Q of $)(Q.position??"before-feedback")==="before-feedback"&&Q.shouldShow(U)&&ae.push({key:Q.key,label:Q.label});S&&s==="feedback"&&ae.push({key:"feedback",label:P.detailTab.feedback});for(const Q of $)Q.position==="after-feedback"&&Q.shouldShow(U)&&ae.push({key:Q.key,label:Q.label})}g.useEffect(()=>{if(s!=="emendated"||!U)return;a("basic");const Q=setTimeout(()=>{var ee;(ee=document.getElementById("studies"))==null||ee.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Q)},[s,U,a]);const V=H&&U&&j?j({activeTab:s,activeJuan:ge,entry:H,detail:U}):null,re=g.useMemo(()=>{var Re,be,Ye,Ce,Ve;if(!U)return null;const ee=(U.authors??[]).map(Be=>{const et=fo(Be.role);return`${Be.dynasty?`〔${oe(Be.dynasty)}〕`:""}${oe(Be.name)}${et?` ${oe(et)}`:""}`}).join(" · ");let Fe=!1;try{Fe=$e.extractStatus(U.id)==="draft"}catch{}if(U.type==="book"){const Be=U;return{title:oe(Be.title),subtitle:Be.edition?oe(Be.edition):ee||void 0,aside:[Fe?P.status.draft:"",ee&&Be.edition?ee:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(U.type==="collection"){const Be=U;return{title:oe(Be.title),subtitle:oe(Ht(Be,P.unit.juan))||void 0,aside:[(Re=Be.publication_info)==null?void 0:Re.year,Fe?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ee||void 0}}if(U.type==="entity"){const Be=U,et=wt=>wt==null?"":wt<0?K("detail.bce",{n:-wt}):String(wt),kt=((be=Be.dates)==null?void 0:be.birth)!=null||((Ye=Be.dates)==null?void 0:Ye.death)!=null?`${et(((Ce=Be.dates)==null?void 0:Ce.birth)??void 0)||"?"}—${et(((Ve=Be.dates)==null?void 0:Ve.death)??void 0)||"?"}`:"";return{title:oe(Be.primary_name||Be.title),subtitle:[Be.dynasty?`〔${oe(Be.dynasty)}〕`:"",kt].filter(Boolean).join(" ")||void 0,aside:Fe?P.status.draft:void 0,secondLine:void 0}}const We=oe(Ht(U,P.unit.juan));return{title:oe(U.title),subtitle:[We,ee].filter(Boolean).join(" · ")||void 0,aside:[O0(P,U.subtype),Fe?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[U,oe,P,K]),_e=U&&Nr(U)?"text":null,Le=()=>{Ie(null),a("fulltext")};let He=null;if(U&&k){const Q=k({detail:U,kind:_e});Q&&(He=t.jsx(Fr,{href:Q}))}else _e&&(He=t.jsx(Fr,{onClick:Le}));const qe=Q=>{if(!U)return null;const ee=Q.replace(/\.[^.]+$/,"");if(k){const Fe=k({detail:U,kind:_e,juan:ee});return Fe?{href:Fe}:null}return{onClick:()=>{Ie(ee),a("fulltext")}}},Xe=new Set($.map(Q=>Q.key)),T=ae.filter(Q=>Q.key.startsWith("catalog:")&&Q.key!=="catalog:loading"||Q.key==="lineage"&&!!se&&!M||Xe.has(Q.key)).map(Q=>({key:Q.key,label:Q.label,onClick:()=>a(Q.key)})),pe=()=>{var Q;return U?U.type==="work"?t.jsx(Fd,{data:U,transport:I,onNavigate:x,renderLink:_,readAction:He,railTop:C,railLinks:T}):U.type==="book"?t.jsx(Vd,{data:U,transport:I,onNavigate:x,renderLink:_,readAction:He,fullText:Pe,fullTextPending:Nr(U)&&!!I.getTextManifest&&he!==U.id,chapterLink:qe,railTop:C,railLinks:T}):U.type==="collection"?t.jsx(Gd,{data:U,catalog:(Q=me[0])==null?void 0:Q.data,transport:I,onNavigate:x,renderLink:_,readAction:He,railTop:C,railLinks:T,catalogAction:me.length>0?t.jsxs("a",{href:"#catalog",onClick:ee=>{ee.preventDefault(),a(`catalog:${me[0].resource_id}`)},children:[oe(P.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Kd,{data:U,transport:I,onNavigate:x,renderLink:_,railTop:C,railLinks:T,assetBase:y}):null},xe=()=>{var ee,Fe,We;if(!H||!U)return null;if(s==="basic"||s==="emendated")return pe();if(typeof s=="string"&&s.startsWith("catalog:")){const Re=(ee=me.find(be=>`catalog:${be.resource_id}`===s))==null?void 0:ee.data;return t.jsx(wo,{data:Re,onNavigate:x,renderLink:_})}if(s==="collated"||s==="fulltext")return t.jsx(Zo,{id:e,transport:I,chapter:ge,onLocationChange:Re=>Ie(Re.chapter),onNavigate:x});if(s==="lineage"){if(!se)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:K(M?"detail.loading":"detail.noLineageGraph")});const Re=U.type==="work"?U:null;return t.jsx(ns,{graph:se,renderLink:_,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:h??((Fe=Re==null?void 0:Re.version_graph)==null?void 0:Fe.default_collection),onCollectionChange:m,collectionsAvailable:(We=Re==null?void 0:Re.version_graph)==null?void 0:We.collections,collectionCounts:(()=>{var Ve,Be,et,kt,wt,cn,Ct;if(!Re)return;const be={},Ye=((Ve=J.current)==null?void 0:Ve.books)??[];be.all=(((Be=Re._books)==null?void 0:Be.length)??0)-(((kt=(et=Re.version_graph)==null?void 0:et.excluded_books)==null?void 0:kt.length)??0);const Ce=(wt=Re.version_graph)==null?void 0:wt.collections;if(Ce)for(const Z of Object.keys(Ce))be[Z]=wi(Re,Ye,Z).nodes.filter(Ge=>Ge.kind==="book"&&!Ge.bridge).length;return be.core==null&&((Ct=(cn=Re.version_graph)==null?void 0:cn.core_books)!=null&&Ct.length)&&(be.core=Re.version_graph.core_books.length),be})()})}if(s==="feedback"&&S)return t.jsx(Pd,{resourceId:e,apiUrl:E});const Q=$.find(Re=>Re.key===s);return Q?Q.render({detail:U,entry:H,transport:I,onNavigate:x}):null};if(ve)return t.jsx(Wn,{style:{minHeight:N,...A},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Q,ee)=>t.jsx("div",{style:{height:ee===1?40:16,width:Q,opacity:.35,background:r("rule")}},ee))})});if(Ae||!U||!H||!re)return t.jsx(Wn,{style:{minHeight:N,...A},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:K("detail.notFound")})});const ke=s==="basic"||s==="emendated",Ne=[{label:b??P.detailTab.backToIndex,onClick:v}];if(U.type==="book"&&U.work_id){const Q=U.work_id;Ne.push({label:P.indexType.work,id:Q,onClick:()=>x==null?void 0:x(Q)})}Ne.push({label:P.indexType[U.type]});const Se=s==="collated"||s==="fulltext",Ke=typeof z=="string"?P.status[z.trim()]??z:z,Oe=t.jsx(Wc,{left:t.jsxs(t.Fragment,{children:[Ke,Ke?" · ":"",t.jsx(B0,{id:U.id,label:P.label.id,copied:P.action.copied,copyLabel:P.action.copy})]}),right:t.jsxs(t.Fragment,{children:[S&&!ke&&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:P.detailTab.submitVersion}),V&&t.jsx("a",{href:V.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:P.detailTab.dataLicense})]})});return ke?t.jsx("div",{className:F,children:t.jsxs(Wn,{grid:!0,style:{minHeight:N,...A},children:[t.jsx(Hr,{breadcrumb:t.jsx(Dr,{items:Ne}),actions:t.jsxs(t.Fragment,{children:[!O&&t.jsx(no,{style:{border:"none",background:"transparent"}}),!O&&V&&t.jsx(io,{...V})]})}),pe(),Oe]})}):t.jsx("div",{className:F,children:t.jsxs(Wn,{wide:Se,style:{minHeight:N,...A},children:[t.jsx(Hr,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(No,{char:"籍"}),t.jsx(Dr,{items:Ne})]}),actions:t.jsxs(t.Fragment,{children:[!O&&t.jsx(no,{}),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:P.detailTab.feedback}),!O&&V&&t.jsx(io,{...V})]})}),t.jsx(Ic,{...re,aside:Se?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:[K("detail.workInfo")," →"]}):re.aside}),!Se&&ae.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:ae.map(Q=>t.jsx(Rc,{label:Q.label,active:Q.key===s||ke&&Q.key==="basic",onClick:()=>a(Q.key)},Q.key))}),t.jsx("div",{style:{marginTop:!Se&&ae.length>1?8:0},children:xe()}),Oe]})})};function B0({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 O0(e,n){return n?e.workSubtype[n]??n:""}const Op=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Xi="zhusha",Zi="bim-theme";function Wp(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Ji(e){return Wp(e)?e:Xi}function W0(){try{return Ji(window.localStorage.getItem(Zi))}catch{return Xi}}function Fp(e){try{window.localStorage.setItem(Zi,e)}catch{}}function Hp(e){const n=Ji(e);return document.documentElement.setAttribute("data-theme",n),n}function Dp(){return Ji(document.documentElement.getAttribute("data-theme"))}const F0=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],ps="airy",Qi="bim-layout";function Up(e){return e==="airy"||e==="boxed"}function er(e){return Up(e)?e:ps}function H0(){try{return er(window.localStorage.getItem(Qi))}catch{return ps}}function D0(e){try{window.localStorage.setItem(Qi,e)}catch{}}function U0(e){const n=er(e);return document.documentElement.setAttribute("data-layout",n),n}function V0(){return er(document.documentElement.getAttribute("data-layout"))}const G0=`try{var t=localStorage.getItem(${JSON.stringify(Zi)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Qi)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,Y0={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},K0=({onChange:e,style:n})=>{const{t:i}=ne(),[o,s]=g.useState(Xi);g.useEffect(()=>{s(Dp())},[]);const a=l=>{s(Hp(l)),Fp(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Op.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(Y0[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=$e.BidLink;exports.BookIndexError=$e.BookIndexError;exports.BookIndexManager=$e.BookIndexManager;exports.BookIndexStorage=$e.BookIndexStorage;exports.BundleStorage=$e.BundleStorage;exports.ConfigError=$e.ConfigError;exports.GithubStorage=$e.GithubStorage;exports.IdGenerationError=$e.IdGenerationError;exports.IdGenerator=$e.IdGenerator;exports.LocalStorage=$e.LocalStorage;exports.MigrationError=$e.MigrationError;exports.StorageError=$e.StorageError;exports.VARIANT_CHARS=$e.VARIANT_CHARS;exports.base36Decode=$e.base36Decode;exports.base36Encode=$e.base36Encode;exports.base58Decode=$e.base58Decode;exports.buildId=$e.buildId;exports.buildPromotionMap=$e.buildPromotionMap;exports.cleanName=$e.cleanName;exports.decodeId=$e.decodeId;exports.decodeIdString=$e.decodeIdString;exports.encodeId=$e.encodeId;exports.extractIdFromUrl=$e.extractIdFromUrl;exports.extractStatus=$e.extractStatus;exports.extractType=$e.extractType;exports.isChapterSegment=$e.isChapterSegment;exports.isTextKey=$e.isTextKey;exports.matchChapterAcrossVersions=$e.matchChapterAcrossVersions;exports.normalizeCatalog=$e.normalizeCatalog;exports.normalizeVariants=$e.normalizeVariants;exports.parseId=$e.parseId;exports.pickTextVersion=$e.pickTextVersion;exports.shardOf=$e.shardOf;exports.smartDecode=$e.smartDecode;exports.textVersionLabel=$e.textVersionLabel;exports.validateResource=$e.validateResource;exports.VARIANT_SUPPLEMENT=xl.VARIANT_SUPPLEMENT;exports.Badge=Ni;exports.BidUrlProvider=fu;exports.BookDetailLayout=P0;exports.BookPage=Vd;exports.Breadcrumb=Dr;exports.CATALOG_ALL_ID=Ot;exports.CATALOG_CSS=qd;exports.CATALOG_NARROW_QUERY=is;exports.CATALOG_PAGE_SIZE=rs;exports.CATALOG_UNCLASSIFIED_ID=rn;exports.CLASSIFICATIONS=Wi;exports.COMMON_TRADITIONAL_CHARS=zl;exports.CardFoot=Zn;exports.CatalogPage=x0;exports.CatalogPager=np;exports.CatalogTree=Zd;exports.CheckFilter=zc;exports.Chip=Ec;exports.ChipWall=yg;exports.CollectionCatalog=wo;exports.CollectionPage=Gd;exports.CreateEntityDialog=Nd;exports.DEFAULT_LAYOUT=ps;exports.DEFAULT_META_HOME_LINKS=jp;exports.DEFAULT_READER_PREFS=_o;exports.DEFAULT_READ_HOME_LINKS=rp;exports.DEFAULT_THEME=Xi;exports.DETAIL_CSS=Tc;exports.DYNASTY_GROUPS=Oi;exports.Dash=_g;exports.DataTable=vg;exports.DetailFooter=Wc;exports.DetailGrid=qn;exports.DetailHeader=Ic;exports.EMPTY_FILTERS=Bi;exports.ENTITY_TEXT_CSS=Vo;exports.EmendatedBySection=oc;exports.EmptyNote=Rg;exports.EntityDetail=ec;exports.EntityMark=Yo;exports.EntityPage=Kd;exports.EntityPickerDialog=Id;exports.EntitySelector=zd;exports.EntityText=Zf;exports.ExpandRow=$g;exports.ExtLink=Eg;exports.FEEDBACK_FAB_OFFSET_VAR=Zr;exports.FILTER_SUPPORT=Vl;exports.FONT_SIZE_STEPS=Bt;exports.FactList=gg;exports.FeedbackButton=Qb;exports.FeedbackDialog=Ad;exports.FeedbackForm=Md;exports.FeedbackList=Jo;exports.FeedbackTab=Pd;exports.FilterChip=Rc;exports.FormInput=xt;exports.FormTextArea=sn;exports.GUJI_MARKDOWN_FIELD=eg;exports.GUJI_TABLE_NOTATION=Fc;exports.GlyphBadge=No;exports.GujiInteractiveReader=Gx;exports.GujiTable=Ro;exports.GujiTextViewer=Ko;exports.GujiWarpCanvas=Uo;exports.HomePage=qr;exports.ImagePanel=Pr;exports.IndexApp=Vx;exports.IndexBrowser=Ar;exports.IndexDetail=ko;exports.IndexEditor=Rd;exports.IndexView=Ob;exports.IntroGrid=hg;exports.LAYOUTS=F0;exports.LAYOUT_STORAGE_KEY=Qi;exports.LOSS_OPTIONS=Ul;exports.LocaleContext=Rt;exports.LocaleProvider=Uu;exports.LocaleToggle=no;exports.META_HOME_CSS=yp;exports.META_HOME_SECTION_IDS=Pp;exports.MetaCatalogTable=zp;exports.MetaCollectionGroups=Rp;exports.MetaDataLicense=Mp;exports.MetaHomeView=I0;exports.MetaLine=st;exports.MetaLineageCards=Lp;exports.MetaOnlineSites=Ap;exports.MetaPeopleTimeline=Ep;exports.MetaRecentPanel=$p;exports.MetaRelatedCatalogs=Tp;exports.MetaTypeChips=wp;exports.ModeIndicator=Tl;exports.MoreButton=bg;exports.MoreLink=Co;exports.PAGE_MAX_WIDTH=ji;exports.PERIOD_NARROW_SHARE=lp;exports.PageFrame=Wn;exports.Quote=zg;exports.READER_CSS=pc;exports.READ_HOME_CSS=ss;exports.READ_HOME_NARROW_QUERY=ei;exports.READ_HOME_SECTION_IDS=bp;exports.READ_PERIOD_LABELS=v0;exports.RECENT_IDS_STORAGE_KEY=yn;exports.ROLE_CLASS_ORDER=Bl;exports.ReadButton=Fr;exports.ReadFamousWorks=gp;exports.ReadHomeView=w0;exports.ReadPeriodBand=fp;exports.ReadPicks=pp;exports.ReadPieces=xp;exports.ReadSection=mt;exports.ReadShelf=ls;exports.ReadSibu=cs;exports.ReadStats=dp;exports.ReadTopicGroup=mp;exports.ReadTopics=hp;exports.ReaderMdText=Mo;exports.ReaderShell=yc;exports.ReaderToc=uc;exports.RelationPanel=$d;exports.RepoSourceLink=io;exports.ResourceEditor=Ir;exports.ResourceGroup=Ng;exports.ResourceLine=Tg;exports.ResourceList=po;exports.ResourceRow=Bc;exports.SEARCH_VIEW_STORAGE_KEY=yo;exports.SEVEN_PAVILIONS_KEY=Ip;exports.SNIPPET_MARK_END=jl;exports.SNIPPET_MARK_START=yl;exports.SORTABLE_TYPES=Dl;exports.SearchInput=Rl;exports.SearchResults=Zl;exports.Sec=at;exports.Section=_t;exports.SectionHead=fg;exports.SideList=on;exports.SmartBidInput=ki;exports.SourceEditor=wd;exports.StripWarpRenderer=Gr;exports.SummaryCard=Xn;exports.THEMES=Op;exports.THEME_INIT_SCRIPT=G0;exports.THEME_STORAGE_KEY=Zi;exports.TRADITIONAL_ALLOWLIST=Nl;exports.TabFilter=Hi;exports.TableHead=kg;exports.TableRow=wg;exports.TagRow=Oc;exports.TagRows=Ig;exports.TextButton=xg;exports.TextReader=Zo;exports.ThemeToggle=K0;exports.TopStrip=Hr;exports.VersionLineageGraph=Ud;exports.VersionLineageList=Dd;exports.VersionLineageView=ns;exports.VolumeChips=jg;exports.VolumeLinks=To;exports.WorkCard=ep;exports.WorkCardGrid=ip;exports.WorkCatalog=rb;exports.WorkPage=Fd;exports.WorkRow=tp;exports.adaptCharCord=ib;exports.adaptEntityJson=Qc;exports.adaptNorm=kd;exports.adaptNormDetailed=vd;exports.adaptPunctJson=Xx;exports.applyLayout=U0;exports.applyTheme=Hp;exports.authorsLine=qi;exports.bookIndexUriToId=Vr;exports.bookMarkingOf=Ao;exports.bucketResources=ho;exports.buildCatalogTree=l0;exports.buildCollectionTable=Fl;exports.buildLineageGraph=wi;exports.buildMeiliFilter=Nm;exports.buildPageUrl=lo;exports.buildParagraphBlocks=Kc;exports.buildVersionRow=Ml;exports.buildVersionTable=Pl;exports.canParagraphize=Ci;exports.catalogNodeIdOf=s0;exports.catalogNodeIdsOf=a0;exports.catalogPageCount=u0;exports.catalogTotal=os;exports.classificationPath=Qn;exports.clearAllRecentIds=jo;exports.compareCatalogCards=p0;exports.computeVersionPartition=jm;exports.countActiveFilters=Fi;exports.createTextApi=ac;exports.currentLayout=V0;exports.currentTheme=Dp;exports.defaultEntityHref=ld;exports.defaultWorkLink=Jd;exports.deriveDating=mm;exports.deriveEditionType=Hl;exports.deriveEra=Kn;exports.deriveYear=Ai;exports.deriveYearRange=mo;exports.detailToEditor=Ld;exports.detectGenre=Ui;exports.displayAuthorRole=fo;exports.editorToDetail=Bb;exports.eraRank=Er;exports.filtersFromParams=Tm;exports.filtersToParams=$i;exports.findCatalogPath=fn;exports.findTraditionalChars=Yu;exports.firstAuthorText=as;exports.flattenTitles=Ur;exports.flattenToc=bc;exports.fmtCount=Qe;exports.formatHitCount=xi;exports.formatTemplate=bt;exports.formatVolumeRange=Pi;exports.getDisplayNameFromUrl=vn;exports.getMessages=wn;exports.getStartPage=ao;exports.getT=Sn;exports.getTypeGroupKey=oo;exports.groupRelatedWorks=hm;exports.gujiInlineToPlain=$c;exports.hasActiveFilters=Gl;exports.hasGujiMarkdownV02=tg;exports.hasGujiTableNotation=Lg;exports.hasSearchOptions=$m;exports.headingKey=Xo;exports.headingsFromPunct=ud;exports.iiifVolumeOf=Zx;exports.isCountedChar=Po;exports.isLayoutName=Up;exports.isThemeName=Wp;exports.lineageHref=vp;exports.loadRecentIds=Kt;exports.measureText=Ht;exports.mergeVolumeResources=so;exports.nestHeadings=gd;exports.normalizeEra=ot;exports.normalizeLayout=er;exports.normalizeRole=go;exports.normalizeTheme=Ji;exports.normalizeVolumeIndex=Hn;exports.normalizeVolumes=wl;exports.numberToChinese=$n;exports.paginationItems=Xd;exports.parseChineseNumber=Si;exports.parseGujiInline=_c;exports.parseGujiTable=Dc;exports.parseHeadingKey=hd;exports.parseSourceString=Sd;exports.pct=ds;exports.periodLevel=ap;exports.pickReaderVersion=xc;exports.readStoredLayout=H0;exports.readStoredTheme=W0;exports.readerVersionOptionLabel=Or;exports.remapPlainOffsets=ed;exports.removeRecentId=Jl;exports.renderFullTextBody=Ug;exports.renderProperNames=Zc;exports.renderReaderInline=Vi;exports.resolveRecentEntry=vo;exports.resourceHref=kn;exports.resourceNote=Mi;exports.resultTabFromParam=Wm;exports.resultTabToParam=Fm;exports.roleFacets=Ol;exports.rowNo=Sg;exports.sameFilters=Im;exports.sanitizeHeadings=md;exports.saveRecentId=Lr;exports.segmentEntities=td;exports.shelfColumns=op;exports.sortFor=Cm;exports.sortYear=_i;exports.spineHeight=sp;exports.splitFullTextTables=Io;exports.splitHighlightSnippet=ro;exports.splitTableRow=Hc;exports.storeLayout=D0;exports.storeTheme=Fp;exports.stringifySources=_d;exports.summaryFromEntry=sd;exports.summaryFromItem=od;exports.timelineLayout=kp;exports.toCatalogWorkCard=d0;exports.transportSummaryLoader=ad;exports.typeSupportsFilters=Yl;exports.useBidUrl=rt;exports.useChapterWarpData=pd;exports.useConvert=Me;exports.useEntitySummaryLoader=Go;exports.useI18n=ne;exports.useReaderPrefs=fc;exports.useRecentEntries=Sp;exports.useT=Ee;exports.validateLineageGraph=Sy;exports.volumeStats=Ii;exports.withDefaultLinks=qt;exports.withMetaLinks=Xt;exports.yearText=Ti;