book-index-ui 0.37.0 → 0.39.0
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 +68 -64
- package/dist/index.d.ts +32 -1
- package/dist/index.js +5223 -5130
- package/dist/{storage-entry-CNa326RB.js → storage-entry-Di__HVfa.js} +1 -1
- package/dist/{storage-entry-jgHCyzLK.cjs → storage-entry-bLAVwtUr.cjs} +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var oc=Object.create;var Ro=Object.defineProperty;var rc=Object.getOwnPropertyDescriptor;var sc=Object.getOwnPropertyNames;var lc=Object.getPrototypeOf,ac=Object.prototype.hasOwnProperty;var cc=(t,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of sc(n))!ac.call(t,s)&&s!==o&&Ro(t,s,{get:()=>n[s],enumerable:!(r=rc(n,s))||r.enumerable});return t};var hn=(t,n,o)=>(o=t!=null?oc(lc(t)):{},cc(n||!t||!t.__esModule?Ro(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const he=require("./storage-entry-jgHCyzLK.cjs"),e=require("react/jsx-runtime"),x=require("react"),dc=require("opencc-js/t2cn"),pc=require("react-markdown"),uc=require("remark-gfm"),mc=t=>`/book-index?id=${t}`,is=x.createContext(mc);function gc({buildUrl:t,children:n}){const o=x.useMemo(()=>t,[t]);return e.jsx(is.Provider,{value:o,children:n})}function Ve(){return x.useContext(is)}const os="",rs="";function Li(t){const n=[];let o=!1,r=t;for(;r.length;){const s=o?rs:os,l=r.indexOf(s);if(l===-1){n.push({text:r,marked:o});break}l>0&&n.push({text:r.slice(0,l),marked:o}),r=r.slice(l+1),o=!o}return n}function Ze(t,n){return{title:t,tokens:n}}const Lo='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',hc=[Ze("基础(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"}}),Ze("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),Ze("提示与警告",{"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)"}}),Ze("遮罩与阴影",{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)"}}),Ze("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),Ze("资源",{"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"}}),Ze("整理本(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-published":{value:"#1b5e20",note:"文本质量等级(出版 / 精校 / 粗校 / OCR)"},"quality-fine":{value:"#2e7d32"},"quality-rough":{value:"#1565c0"},"quality-ocr":{value:"#e65100"}}),Ze("版本传承(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"}}),Ze("编辑器视图(主要在 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")'}}),Ze("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),Ze('版式(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"}}),Ze("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"}}),Ze("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),Ze("字体(全站无衬线,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:Lo,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Lo,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],xc=Object.assign({},...hc.map(t=>t.tokens)),ss={};for(const[t,n]of Object.entries(xc))ss[t]=`var(--bim-${t}, ${n.value})`;function i(t){const n=ss[t];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${t}`);return n}function zt(t){return t.types&&t.types.length>0?t.types:t.type?t.type==="text+image"?["text","image"]:[t.type]:[]}function fc(t,n){return zt(t).includes(n)}const bc={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Tt=x.createContext(null),ls=["曹霑"];function yc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jc(t,n=ls){const o=[...new Set(n.filter(Boolean))].sort((l,a)=>a.length-l.length);if(!o.length)return t;const r=new RegExp(`(${o.map(yc).join("|")})`,"g"),s=new Set(o);return l=>{if(!l)return t(l);const a=l.split(r);return a.length===1?t(l):a.map((d,c)=>c%2===1&&s.has(d)?d:d&&t(d)).join("")}}let Vt=null;function vc(){if(Vt)return Vt;try{const t=dc.Converter({from:"tw",to:"cn"});Vt=jc(n=>t(he.normalizeVariants(n)))}catch{Vt=t=>t}return Vt}const kc={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("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:"圖片資源"}},wc={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("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 Xe(t,n,o){return{"zh-Hant":t,"zh-Hans":n}}const Sc=Xe({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",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:"朝代",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),Nn=Xe({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:"作品信息"}),$c=Xe({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:"附记"}}),_c=Xe({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),Cc=Xe({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:"上级丛编"}),zc=Xe({subtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",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 为自动匹配,未经人工核对"}),Tc=Xe({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",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:"專名線",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",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:"专名线",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献"}),Nc=Xe({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:{published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"},qualityCriteria:{published:"達到出版、學術研究標準,錯誤率在萬分之一以內",fine:"通讀無障礙,錯誤率在百分之一以內",rough:"保證文意基本正確,錯誤率在百分之三以內",ocr:"保持大意和結構,錯誤率在百分之十以內"},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:{published:"出版",fine:"精校",rough:"粗校",ocr:"机器识别"},qualityCriteria:{published:"达到出版、学术研究标准,错误率在万分之一以内",fine:"通读无障碍,错误率在百分之一以内",rough:"保证文意基本正确,错误率在百分之三以内",ocr:"保持大意和结构,错误率在百分之十以内"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),Ic=Xe({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:"规模、存佚、许可与版本"}),Pi=Xe({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:"按作者浏览全部 →"}),Ec=Xe({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} 条"}),Rc=Xe({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:"搜索"}),Lc=Xe({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:"回复"}),Pc=Xe({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:"有争议"}}),Ac={common:Sc,detail:Nn,bookPage:$c,workPage:_c,collectionPage:Cc,entityPage:zc,reader:Tc,collated:Nc,metaHome:Ic,readHome:Pi,catalogPage:Ec,searchPage:Rc,feedback:Lc,lineage:Pc};function Bc(t){const n={};for(const[o,r]of Object.entries(Ac))n[o]=r[t];return n}function tt(t,n){return t.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Po=new Map;function Wt(t){let n=Po.get(t);return n||(n={...t==="zh-Hans"?wc:kc,...Bc(t)},Po.set(t,n)),n}function Ao(t,n){let o=t;for(const r of n.split(".")){if(o==null||typeof o!="object")return;o=o[r]}return typeof o=="string"?o:void 0}function as(t){return(n,o)=>{const r=Ao(t,n)??Ao(Wt("zh-Hant"),n)??n;return o?tt(r,o):r}}const Bo=new Map;function Ht(t){let n=Bo.get(t);return n||(n=as(Wt(t)),Bo.set(t,n)),n}const cs="bim-locale";function Mc(){try{const t=localStorage.getItem(cs);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function Wc(t){try{localStorage.setItem(cs,t)}catch{}}const Hc="zh-Hans",Oc=({locale:t,onLocaleChange:n,converter:o,children:r})=>{const[s,l]=x.useState(t??Hc),a=t??s;x.useEffect(()=>{if(t)return;const u=Mc();u&&u!==s&&l(u)},[]);const d=x.useMemo(()=>a==="zh-Hans"?o??vc():null,[a,o]),c=x.useCallback(u=>{l(u),Wc(u),n==null||n(u)},[n]),p=x.useMemo(()=>({locale:a,setLocale:c,messages:Wt(a),converter:d}),[a,c,d]);return e.jsx(Tt.Provider,{value:p,children:r})};function ke(){const t=x.useContext(Tt);return(t==null?void 0:t.messages)??Wt("zh-Hant")}const Fc=2e3;function Te(){const t=x.useContext(Tt),n=(t==null?void 0:t.locale)??"zh-Hant",o=(t==null?void 0:t.converter)??null,r=x.useRef(new Map),s=x.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const l=x.useCallback(a=>{if(!a)return"";if(!o)return a;const d=r.current.get(a);if(d!==void 0)return d;const c=o(a);if(r.current.size>=Fc){const p=r.current.keys().next().value;p!==void 0&&r.current.delete(p)}return r.current.set(a,c),c},[o]);return x.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function K(){const t=x.useContext(Tt),{convert:n,locale:o,isSimplified:r}=Te(),s=(t==null?void 0:t.messages)??Wt("zh-Hant"),l=x.useMemo(()=>t?as(s):Ht("zh-Hant"),[t,s]);return x.useMemo(()=>({t:l,convert:n,locale:o,isSimplified:r,messages:s}),[l,n,o,r,s])}const ds=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側抬","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Dc=new Set([...ds,...Object.keys(he.VARIANT_CHARS)]),ps=[...ls,"切換為繁體","漢籍リポジトリ"];function Uc(t,n=ps){let o=t;for(const l of n)l&&(o=o.split(l).join(" "));const r=[],s=Array.from(o);return s.forEach((l,a)=>{Dc.has(l)&&r.push({char:l,context:s.slice(Math.max(0,a-8),a+9).join("")})}),r}function Vc(t){if(!t)return"";try{const n=new URL(t).hostname,o={"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(o[n])return o[n];const r=n.split(".");return r.length>=2?r[r.length-2]:n}catch{return""}}function Gc(){return{id:"",name:"",url:"",type:"text",details:""}}const mi=({items:t,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const l=ke(),[a,d]=x.useState(null),c=[{value:"text",label:l.resourceTypeShort.text},{value:"image",label:l.resourceTypeShort.image},{value:"text+image",label:l.resourceTypeShort.textImage},{value:"physical",label:l.resourceTypeShort.physical}],p=[{value:"catalog",label:l.rootType.catalog},{value:"search",label:l.rootType.search}],u=b=>{if(!s)return!0;const j=zt(b);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},g=t.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>u(b)),m=()=>{const b=Gc();s&&(b.type=s),n([...t,b]),d(t.length)},h=b=>{n(t.filter((j,w)=>w!==b)),d(null)},f=(b,j,w)=>{const S=[...t];if(S[b]={...S[b],[j]:w},j==="url"&&!S[b].id){const $=Vc(w);$&&(S[b].id=$)}n(S)},v=(b,j,w)=>{const $={...t[b].metadata||{}};w?$[j]=w:delete $[j],f(b,"metadata",Object.keys($).length>0?$:void 0)},y=(b,j)=>{const w=j.trim()?j.split(/[,,、]/).map(S=>S.trim()).filter(Boolean):void 0;f(b,"structure",w)},k=(b,j,w)=>{const $=t[b].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(w)||1:$.ranges=w,f(b,"coverage",$.ranges?$:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[g.map(({item:b,originalIndex:j})=>{var w,S,$;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(a===j?null:j),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:a===j?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Yc(b.type??"text"),color:i("on-color-fg")},children:(()=>{var C,I;const _=zt(b);return _.length===0?b.type??"text":_.length===1?((C=c.find(T=>T.value===_[0]))==null?void 0:C.label)??_[0]:_.includes("text")&&_.includes("image")?((I=c.find(T=>T.value==="text+image"))==null?void 0:I.label)??"text+image":_.join("+")})()}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${l.editor.resourcePlaceholder} ${j+1}`}),b.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&e.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&Kc(j,r==null?void 0:r[j],o,l),e.jsx("button",{onClick:_=>{_.stopPropagation(),h(j)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),a===j&&e.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[fc(b,"image")&&b.url&&qc(b,l),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:Gt,children:[e.jsx("span",{style:Yt,children:l.label.type}),e.jsx("select",{value:b.type,onChange:_=>f(j,"type",_.target.value),style:{...at,flex:1},children:c.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))})]}),e.jsxs("label",{style:Gt,children:[e.jsx("span",{style:Yt,children:l.label.rootType}),e.jsx("select",{value:b.root_type||"catalog",onChange:_=>f(j,"root_type",_.target.value),style:{...at,flex:1},children:p.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:b.id,onChange:_=>f(j,"id",_.target.value),placeholder:l.editor.idAutoExtract,style:{...at,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:b.name,onChange:_=>f(j,"name",_.target.value),placeholder:l.editor.resourceName,style:{...at,flex:1}})]}),e.jsx("input",{type:"text",value:b.url,onChange:_=>f(j,"url",_.target.value),placeholder:l.editor.resourceUrl,style:at}),e.jsx("input",{type:"text",value:((w=b.structure)==null?void 0:w.join("、"))||"",onChange:_=>y(j,_.target.value),placeholder:l.editor.structurePlaceholder,style:at}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:Gt,children:[e.jsx("span",{style:Yt,children:l.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((S=b.coverage)==null?void 0:S.level)??"",onChange:_=>k(j,"level",_.target.value),placeholder:"1",style:{...at,width:"60px"}})]}),e.jsxs("label",{style:{...Gt,flex:1},children:[e.jsx("span",{style:Yt,children:l.label.coverageRange}),e.jsx("input",{type:"text",value:(($=b.coverage)==null?void 0:$.ranges)||"",onChange:_=>k(j,"ranges",_.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...at,flex:1}})]})]}),e.jsx("textarea",{value:b.details||"",onChange:_=>f(j,"details",_.target.value),placeholder:l.editor.detailsPlaceholder,style:{...at,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:l.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([_,C])=>{var I;return e.jsxs("label",{style:{...Gt,gap:"4px"},children:[e.jsx("span",{style:{...Yt,minWidth:"56px"},children:C}),e.jsx("input",{type:"text",value:((I=b.metadata)==null?void 0:I[_])||"",onChange:T=>v(j,_,T.target.value),placeholder:C,style:{...at,flex:1}})]},_)})})]})]})]})]},j)}),e.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:l.action.addResource})]})]})};function Yc(t){switch(t){case"text":return i("restype-text");case"image":return i("restype-image");case"text+image":return i("restype-text-image");case"physical":return i("restype-physical")}}function Kc(t,n,o,r){const s=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return e.jsx("button",{onClick:a=>{a.stopPropagation(),s||o(t,"")},disabled:s,style:{background:"transparent",border:"none",color:i(l?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:l?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:l?"✓":s?"⏳":"⬇"})}function qc(t,n){const o=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(t.url)||t.url.includes("iiif")||t.url.includes("image");return e.jsx("div",{style:{marginBottom:"12px"},children:o?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:e.jsx("img",{src:t.url,alt:t.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const at={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Gt={display:"flex",alignItems:"center",gap:"6px"},Yt={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},Zc={"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 Ot(t){try{return Zc[new URL(t).hostname]}catch{return}}const Mo={text:0,image:1,physical:2};function Ai(t){return t.length===0?"physical":[...t].sort((n,o)=>(Mo[n]??99)-(Mo[o]??99)).join("+")}function Bi(t){var a;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},o=new Map;for(let d=0;d<t.length;d++){const c=t[d];if(c.volumes&&c.volumes.length>0)continue;const p=n(c.name);if(!p)continue;const[u,g]=p,m=`${u}|${Ai(zt(c))}`;o.has(m)||o.set(m,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const h=o.get(m);h.volumes.push({volume:g,url:c.url||void 0,status:"found"}),h.indices.push(d)}const r=[],s=new Set;for(const d of o.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=((a=d.volumes.find(c=>c.url))==null?void 0:a.url)??""),r.push(d.base);for(const c of d.indices)s.add(c)}const l=[...r];for(let d=0;d<t.length;d++)s.has(d)||l.push(t[d]);return l}function us(t){if(t.url)return t.url;for(const[n,o]of Object.entries(t))if(n.endsWith("_url")&&typeof o=="string")return o}function ms(t){return!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(n=>({...n,url:n.url||us(n)}))}function In(t){const n=ms(t);if(!n)return null;const o=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,r=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:o,missing:r,expected:t.expected_volumes??o+r}}function Mi(t){if(!t)return;const n=t.file_page_range||t.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function Wi(t,n){try{if(new URL(t).hostname.includes("wikimedia.org")){const r=t.match(/\/wiki\/File:(.+?)(?:#|$)/);if(r)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(r[1]))}&page=${n}`;const s=new URL(t);return s.searchParams.set("page",String(n)),s.toString()}return t}catch{return t}}function Ft(t){if(!t.url)return;const n=Mi(t.metadata);return n?Wi(t.url,n):t.url}const Wo={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function Jc(t){return t.includes("text")&&t.includes("image")?Wo["text+image"]:Wo[t[0]||"physical"]}const Hi=({items:t,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const l=ke(),{convert:a}=Te(),d=x.useMemo(()=>Bi(t||[]),[t]),{mirrorGroups:c,ungroupedItems:p}=x.useMemo(()=>{const y=new Map,k=[];for(const b of d){const j=b.group;j?(y.has(j)||y.set(j,[]),y.get(j).push(b)):k.push(b)}for(const b of y.values())b.sort((j,w)=>{const S=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return S(j)-S(w)});return{mirrorGroups:y,ungroupedItems:k}},[d]),u={text:l.resourceType.text,image:l.resourceType.image,"text+image":l.resourceType.textImage,physical:l.resourceType.physical},g=y=>u[y]?u[y]:y.split("+").map(k=>u[k]||k).join("+");if(!d||d.length===0)return e.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:l.misc.noResources});if(!n)return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,k)=>e.jsx(Jn,{item:y},y.id||k))});const m=(y,k)=>{const b=o==null?void 0:o[y],j=(b==null?void 0:b.label)||y,w=b==null?void 0:b.description;return e.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(j)}),w&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:a(w)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:k.map((S,$)=>e.jsx(Jn,{item:S,onNavigate:r,renderLink:s},S.id||$))})]},`group-${y}`)},h=new Map;for(const y of p){const k=Ai(zt(y));h.has(k)||h.set(k,[]),h.get(k).push(y)}const f=["text","image","text+image","physical"],v=[...f.filter(y=>h.has(y)),...[...h.keys()].filter(y=>!f.includes(y)).sort()];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,k])=>m(y,k)),v.map(y=>{const k=h.get(y),b=Jc(y.split("+"));return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:g(y)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:k.map((j,w)=>e.jsx(Jn,{item:j,onNavigate:r,renderLink:s},j.id||w))})]},y)})]})},Xc={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Jn=({item:t})=>{const n=ke(),{convert:o}=Te(),[r,s]=x.useState(!1),l=x.useMemo(()=>(t.url?Ot(t.url):void 0)||o(t.name),[t.url,t.name,o]),a=x.useMemo(()=>!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(f=>({...f,url:f.url||us(f)})),[t.volumes]),d=a&&a.length>0,c=d?new Set(a.filter(f=>f.status!=="missing").map(f=>f.volume)).size:0,p=d?new Set(a.filter(f=>f.status==="missing").map(f=>f.volume)).size:0,u=t.expected_volumes??(d?c+p:0),g=t.color_mode?{...Xc[t.color_mode],label:n.colorMode[t.color_mode]}:null,m=t.details&&!d?o(t.details):null,h={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",background:i("input-bg"),fontSize:"12px",color:i("fg"),lineHeight:1.4,verticalAlign:"middle"};return e.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[e.jsxs("div",{style:h,children:[e.jsx("span",{style:{fontWeight:500},children:l}),g&&e.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:g.bg,color:g.fg},children:g.label}),m&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:m}),d&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,p>0&&e.jsx("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:tt(n.common.volumesMissing,{n:p})})]}),t.url&&e.jsx("a",{href:(()=>{const f=Mi(t.metadata);return f?Wi(t.url,f):t.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&e.jsx("button",{onClick:()=>s(!r),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",lineHeight:1.4},children:r?"▲":"▼"})]}),d&&r&&e.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:a.map(f=>{const v=f.status==="missing";return f.url&&!v?e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${i("widget-border")}`,color:i("link-fg"),textDecoration:"none"},children:f.volume},f.volume):e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(v?"missing-fg":"desc-fg"),textDecoration:v?"line-through":"none",opacity:v?.6:1},children:f.volume},f.volume)})})]})},gs=({indexSource:t,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:l,onSelectFolder:a})=>{const d=ke(),c=t==="local",p=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",g=u?u.split(/[/\\]/).pop()||u:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},h={onMouseOver:v=>v.currentTarget.style.opacity="0.8",onMouseOut:v=>v.currentTarget.style.opacity="1"},f=e.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...m,background:i(p?"warning":"success"),color:i("on-color-fg")},...h,children:[e.jsx("span",{children:p?"📝":"📚"}),e.jsx("span",{children:p?"draft":"official"})]});return o==="index-browser"?c?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[f,e.jsxs("div",{onClick:r,title:d.mode.switchToSync,style:m,...h,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:d.mode.localMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:a,title:u||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...h,children:[e.jsx("span",{children:"📂"}),g&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:r,title:d.mode.switchToLocal,style:m,...h,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:d.mode.syncMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:l,title:g||d.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...h,children:e.jsx("span",{children:"⚙️"})})]})]}):e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsxs("div",{onClick:r,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:m,...h,children:[e.jsx("span",{children:c?"📁":"🌐"}),e.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&e.jsxs("div",{onClick:a,title:u||d.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...h,children:[e.jsx("span",{children:"📂"}),g&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]}),!c&&g&&e.jsxs("div",{style:{...m,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:g})]})]})},En="bim-search-history",Ho=10,Oo=8;function tn(){try{const t=localStorage.getItem(En);return t?JSON.parse(t):[]}catch{return[]}}function hs(t){try{const n=tn().filter(o=>o!==t);n.unshift(t),n.length>Ho&&(n.length=Ho),localStorage.setItem(En,JSON.stringify(n))}catch{}}function Qc(t){try{const n=tn().filter(o=>o!==t);localStorage.setItem(En,JSON.stringify(n))}catch{}}function ed(){try{localStorage.removeItem(En)}catch{}}const xs=({transport:t,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:l})=>{const a=ke(),d=l??a.search.placeholder,c={work:a.indexType.work,book:a.indexType.book,collection:a.indexType.collection,entity:a.indexType.entity},[p,u]=x.useState(!1),[g,m]=x.useState([]),[h,f]=x.useState(-1),[v,y]=x.useState(tn),k=x.useRef(null),b=x.useRef(null),j=x.useRef(null),w=x.useRef(!1);x.useEffect(()=>{f(-1);const z=n.trim();if(!z){m(v.map(A=>({type:"history",text:A})));return}if(!t.searchAll){m([]);return}let H=!1;const W=setTimeout(()=>{t.searchAll(z,Oo).then(A=>{if(H)return;const Y=[...A.works,...A.books,...A.collections,...A.entities??[]];m(Y.slice(0,Oo).map(G=>({type:"entry",text:G.title||G.id,entry:G})))}).catch(()=>{H||m([])})},80);return()=>{H=!0,clearTimeout(W)}},[n,v,t]),x.useEffect(()=>{const z=H=>{j.current&&!j.current.contains(H.target)&&u(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]),x.useEffect(()=>{const z=H=>{var W,A;if(H.key==="/"&&document.activeElement!==k.current){const Y=(W=document.activeElement)==null?void 0:W.tagName;if(Y==="INPUT"||Y==="TEXTAREA"||Y==="SELECT")return;H.preventDefault(),(A=k.current)==null||A.focus()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const S=x.useCallback(z=>{z.trim()&&(hs(z.trim()),y(tn())),r(z),u(!1)},[r]),$=x.useCallback(z=>{z.type==="history"?(o(z.text),S(z.text)):z.entry&&(s?(s(z.entry),u(!1)):(o(z.text),S(z.text)))},[o,S,s]),_=x.useCallback(z=>{if(!p||g.length===0){z.key==="Enter"&&S(n);return}switch(z.key){case"ArrowDown":z.preventDefault(),f(H=>(H+1)%g.length);break;case"ArrowUp":z.preventDefault(),f(H=>(H-1+g.length)%g.length);break;case"Enter":z.preventDefault(),h>=0&&h<g.length?$(g[h]):S(n);break;case"Escape":z.preventDefault(),u(!1);break}},[p,g,h,n,S,$]),C=x.useCallback((z,H)=>{H.stopPropagation(),Qc(z),y(tn()),m(W=>W.filter(A=>!(A.type==="history"&&A.text===z)))},[]),I=x.useCallback(z=>{z.stopPropagation(),ed(),y([]),m([])},[]);x.useEffect(()=>{if(h>=0&&b.current){const z=b.current.children;z[h]&&z[h].scrollIntoView({block:"nearest"})}},[h]);const T=!n.trim()&&v.length>0;return e.jsxs("div",{ref:j,style:{position:"relative",flex:1},children:[e.jsx("input",{ref:k,type:"text",placeholder:d,value:n,onChange:z=>{o(z.target.value),u(!0)},onCompositionStart:()=>{w.current=!0},onCompositionEnd:()=>{w.current=!1},onFocus:()=>{u(!0)},onKeyDown:_,style:{width:"100%",padding:"8px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&g.length>0&&e.jsxs("div",{ref:b,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:i("input-bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"6px",boxShadow:i("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[T&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:i("desc-fg"),borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("span",{children:a.search.history}),e.jsx("button",{onClick:I,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:a.search.clearAll})]}),g.map((z,H)=>e.jsxs("div",{onClick:()=>$(z),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:H===h?i("list-active-bg"):"transparent"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:z.type==="history"?"🕐":"🔍"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.text}),z.entry&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[z.entry.type],z.entry.edition&&` · ${z.entry.edition}`,z.entry.author&&` · ${z.entry.author}`]}),z.type==="history"&&e.jsx("button",{onClick:W=>C(z.text,W),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:a.action.remove,children:"×"})]},`${z.type}-${z.text}-${H}`))]})]})},Dt=({type:t,size:n=9})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${t}`),verticalAlign:"middle"}}),Rn={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},fs=new Set(["work","book","entity"]);function td(t){return js(t)||!!t.sort}function nd(t,n){return n.sort&&fs.has(t)?n.sort:void 0}const Ln=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Pn=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],bs=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],ys={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function An(t){return t.dynasty.length+t.classification.length+(t.hasImage?1:0)+(t.hasText?1:0)+(t.hasCollated?1:0)+(t.loss?1:0)}function js(t){return An(t)>0}function id(t){const n=[];return t.dynasty.length&&n.push("dynasty"),t.classification.length&&n.push("classification"),t.hasImage&&n.push("hasImage"),t.hasText&&n.push("hasText"),t.hasCollated&&n.push("hasCollated"),t.loss&&n.push("loss"),n}function vs(t,n){const o=ys[t];return id(n).every(r=>o.has(r))}const Kt=t=>JSON.stringify(t);function od(t,n){if(!vs(n,t))return null;const o=[];if(t.dynasty.length){const r=Array.from(new Set(t.dynasty.flatMap(s=>{var l;return((l=Ln.find(a=>a.key===s))==null?void 0:l.values)??[]})));r.length===1?o.push(`dynasty = ${Kt(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(Kt).join(", ")}]`)}return t.classification.length&&o.push(t.classification.length===1?`classification = ${Kt(t.classification[0])}`:`classification IN [${t.classification.map(Kt).join(", ")}]`),t.hasImage&&o.push("has_image = true"),t.hasText&&o.push("has_text = true"),t.hasCollated&&o.push("has_collated = true"),t.loss&&o.push(`loss_status = ${Kt(t.loss)}`),o.join(" AND ")}const qe={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},ks="_";function wn(t,n=new URLSearchParams){for(const o of Object.values(qe))n.delete(o);return t.dynasty.length&&n.set(qe.dynasty,t.dynasty.join(",")),t.classification.length&&n.set(qe.classification,t.classification.map(o=>o||ks).join(",")),t.hasImage&&n.set(qe.hasImage,"1"),t.hasText&&n.set(qe.hasText,"1"),t.hasCollated&&n.set(qe.hasCollated,"1"),t.loss&&n.set(qe.loss,t.loss),t.sort&&n.set(qe.sort,t.sort),n}function rd(t){const n=l=>(t.get(l)??"").split(",").map(a=>a.trim()).filter(Boolean),o=new Set(Ln.map(l=>l.key)),r=new Set(Pn.map(l=>l.value)),s=t.get(qe.loss);return{dynasty:Array.from(new Set(n(qe.dynasty).filter(l=>o.has(l)))),classification:Array.from(new Set(n(qe.classification).map(l=>l===ks?"":l).filter(l=>r.has(l)))),hasImage:t.get(qe.hasImage)==="1",hasText:t.get(qe.hasText)==="1"||t.get(qe.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(l=>l===t.get(qe.sort))??""}}function sd(t,n){return JSON.stringify([t.dynasty.slice().sort(),t.classification.slice().sort(),t.hasImage,t.hasText,t.hasCollated,t.loss,t.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Fo(t,n){return t.includes(n)?t.filter(o=>o!==n):[...t,n]}const ld=({filters:t,onChange:n})=>{const o=ke(),r=o.searchV4,{convert:s}=Te(),[l,a]=x.useState(!1),d=x.useId(),c=An(t),p=u=>n({...t,...u});return e.jsxs("aside",{className:"bim-sr-aside","aria-label":s(r.filterTitle),children:[e.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":l,"aria-controls":d,onClick:()=>a(u=>!u),children:[e.jsxs("span",{children:[s(r.filterButton),c>0&&e.jsx("span",{className:"bim-sr-fn",children:s(tt(r.filterSelected,{n:c}))})]}),e.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(l?r.collapse:r.expand)," ",l?"▴":"▾"]})]}),e.jsxs("div",{className:"bim-sr-filters",id:d,"data-open":l?"true":"false",...l?{}:{"data-collapsed":"true"},children:[e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.dynasty)}),e.jsx("div",{className:"bim-sr-chips",children:Ln.map(u=>e.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":t.dynasty.includes(u.key),onClick:()=>p({dynasty:Fo(t.dynasty,u.key)}),children:s(u.key)},u.key))})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.classification)}),Pn.map(u=>e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.classification.includes(u.value),onChange:()=>p({classification:Fo(t.classification,u.value)})}),u.value?s(u.label):o.searchPage.unclassified]},u.value||"_"))]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.resources)}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasImage,onChange:u=>p({hasImage:u.target.checked})}),s(r.hasImage)]}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasText,onChange:u=>p({hasText:u.target.checked})}),s(r.hasText)]})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{id:`${d}-loss`,children:s(r.extant)}),e.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:bs.map(u=>e.jsx("button",{type:"button","aria-pressed":t.loss===u.value,onClick:()=>p({loss:u.value}),children:o.searchPage.loss[u.value||"all"]},u.value||"all"))})]}),c>0&&e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Rn,sort:t.sort}),children:s(r.clearAllFilters)})]})]})};function ws({text:t,query:n}){const o=(n??"").trim();if(!o||!t)return e.jsx(e.Fragment,{children:t});const r=t.toLowerCase(),s=o.toLowerCase(),l=[];let a=0,d=0;for(;a<t.length;){const c=r.indexOf(s,a);if(c<0){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{className:"bim-sr-hl",children:t.slice(c,c+s.length)},d++)),a=c+s.length}return e.jsx(e.Fragment,{children:l})}const Do=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=ke(),l=s.searchV4,{convert:a}=Te(),d=Ve();return e.jsx("div",{className:"bim-sr-tablewrap",children:e.jsxs("table",{className:"bim-sr-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"34%"}}),e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"19%"}}),e.jsx("col",{style:{width:"13%"}}),e.jsx("col",{style:{width:"12%"}}),e.jsx("col",{style:{width:"14%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:a(l.colTitle)}),e.jsx("th",{scope:"col",children:a(l.colType)}),e.jsx("th",{scope:"col",children:a(l.colAuthor)}),e.jsx("th",{scope:"col",children:a(l.colEra)}),e.jsx("th",{scope:"col",children:a(l.colClass)}),e.jsx("th",{scope:"col",style:{textAlign:"right"},children:a(l.colResource)})]})}),e.jsx("tbody",{children:t.map(c=>{const p=a(c.title||c.primary_name||c.id),u=c.measure_info?a(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",g=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${a(c.author)}${c.role&&c.role!=="author"?` ${a(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,h=m?a(m):"",f=c.classification?a(c.classification):"",v=[];c.has_image&&v.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&v.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&v.push({label:l.tagLost,cls:"bim-sr-tag--lost"});const y=[g,h,f].filter(Boolean).join(" · ");return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-sr-c-title",children:[e.jsxs("div",{className:"bim-sr-tl",children:[e.jsx("a",{href:d(c.id),onClick:k=>o(c,k),children:e.jsx(ws,{text:p,query:n?a(n):void 0})}),u&&e.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&e.jsx("span",{className:"bim-sr-sub",children:y})]}),e.jsxs("td",{className:"bim-sr-c-type",children:[e.jsx(Dt,{type:c.type,size:6})," ",r(c.type)]}),e.jsx("td",{className:"bim-sr-c-who",children:g||"—"}),e.jsx("td",{className:"bim-sr-c-era",children:h||"—"}),e.jsx("td",{className:"bim-sr-c-cls",children:f||"—"}),e.jsx("td",{className:"bim-sr-c-res",children:v.map(k=>e.jsx("span",{className:`bim-sr-tag ${k.cls}`,children:a(k.label)},k.label))})]},c.id)})})]})})},ad=`
|
|
1
|
+
"use strict";var pc=Object.create;var Ao=Object.defineProperty;var uc=Object.getOwnPropertyDescriptor;var mc=Object.getOwnPropertyNames;var gc=Object.getPrototypeOf,hc=Object.prototype.hasOwnProperty;var xc=(t,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of mc(n))!hc.call(t,s)&&s!==o&&Ao(t,s,{get:()=>n[s],enumerable:!(r=uc(n,s))||r.enumerable});return t};var bn=(t,n,o)=>(o=t!=null?pc(gc(t)):{},xc(n||!t||!t.__esModule?Ao(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const xe=require("./storage-entry-bLAVwtUr.cjs"),e=require("react/jsx-runtime"),x=require("react"),fc=require("opencc-js/t2cn"),bc=require("react-markdown"),yc=require("remark-gfm"),jc=t=>`/book-index?id=${t}`,ls=x.createContext(jc);function vc({buildUrl:t,children:n}){const o=x.useMemo(()=>t,[t]);return e.jsx(ls.Provider,{value:o,children:n})}function Ye(){return x.useContext(ls)}const as="",cs="";function Mi(t){const n=[];let o=!1,r=t;for(;r.length;){const s=o?cs:as,l=r.indexOf(s);if(l===-1){n.push({text:r,marked:o});break}l>0&&n.push({text:r.slice(0,l),marked:o}),r=r.slice(l+1),o=!o}return n}function Qe(t,n){return{title:t,tokens:n}}const Bo='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',kc=[Qe("基础(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"}}),Qe("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),Qe("提示与警告",{"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)"}}),Qe("遮罩与阴影",{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)"}}),Qe("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),Qe("资源",{"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"}}),Qe("整理本(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-published":{value:"#1b5e20",note:"文本质量等级(出版 / 精校 / 粗校 / OCR)"},"quality-fine":{value:"#2e7d32"},"quality-rough":{value:"#1565c0"},"quality-ocr":{value:"#e65100"}}),Qe("版本传承(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"}}),Qe("编辑器视图(主要在 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")'}}),Qe("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),Qe('版式(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"}}),Qe("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"}}),Qe("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),Qe("字体(全站无衬线,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:Bo,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Bo,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],wc=Object.assign({},...kc.map(t=>t.tokens)),ds={};for(const[t,n]of Object.entries(wc))ds[t]=`var(--bim-${t}, ${n.value})`;function i(t){const n=ds[t];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${t}`);return n}function Nt(t){return t.types&&t.types.length>0?t.types:t.type?t.type==="text+image"?["text","image"]:[t.type]:[]}function Sc(t,n){return Nt(t).includes(n)}const $c={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const It=x.createContext(null),ps=["曹霑"];function _c(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cc(t,n=ps){const o=[...new Set(n.filter(Boolean))].sort((l,a)=>a.length-l.length);if(!o.length)return t;const r=new RegExp(`(${o.map(_c).join("|")})`,"g"),s=new Set(o);return l=>{if(!l)return t(l);const a=l.split(r);return a.length===1?t(l):a.map((p,c)=>c%2===1&&s.has(p)?p:p&&t(p)).join("")}}let Kt=null;function zc(){if(Kt)return Kt;try{const t=fc.Converter({from:"t",to:"cn"});Kt=Cc(n=>t(xe.normalizeVariants(n)))}catch{Kt=t=>t}return Kt}const Tc={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("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:"圖片資源"}},Nc={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("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 tt(t,n,o){return{"zh-Hant":t,"zh-Hans":n}}const Ic=tt({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",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:"朝代",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),En=tt({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:"作品信息"}),Rc=tt({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:"附记"}}),Ec=tt({fact:{written:"成書",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考證",alias:"又名",attached:"附載",appendix:"附錄"},inferredFromEdition:"據版本題名推斷",loading:"載入中",emendationCount:"{n} 條",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著錄"},classifiedBy:"據《{source}》",sec:{versions:"版本",catalogs:"著錄",collected:"收入叢編",related:"相關書目",resources:"在線資源"},versionsTotal:"共 {n} 種",versionsWithImage:"{n} 種有影印",versionsCurrent:"當前 {n} 種",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著錄順序",col:{edition:"版本",era:"年代",holder:"館藏",image:"影印"},noVersionsFiltered:"當前篩選下沒有版本",noVersions:"暫無版本著錄",moreUnit:"種版本",inferredEraNote:"部分年代據版本題名推斷,非著錄原文",empty:"尚未著錄該作品的版本與書目收錄。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"歷代書目 {n} 家",tablist:"著錄書目",titleOnly:"僅著錄書名,無提要。",prev:"上一家:{name}",next:"下一家:{name}"}},{fact:{written:"成书",measure:"卷帙",loss:"存佚",earliest:"最早存世",emendation:"考证",alias:"又名",attached:"附载",appendix:"附录"},inferredFromEdition:"据版本题名推断",loading:"载入中",emendationCount:"{n} 条",stat:{editions:"版本",hasImage:"有影印",catalogs:"家著录"},classifiedBy:"据《{source}》",sec:{versions:"版本",catalogs:"著录",collected:"收入丛编",related:"相关书目",resources:"在线资源"},versionsTotal:"共 {n} 种",versionsWithImage:"{n} 种有影印",versionsCurrent:"当前 {n} 种",scanOnly:"只看有影印",sortByYear:"按年代排列",sortByCatalog:"按著录顺序",col:{edition:"版本",era:"年代",holder:"馆藏",image:"影印"},noVersionsFiltered:"当前筛选下没有版本",noVersions:"暂无版本著录",moreUnit:"种版本",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),Lc=tt({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:"上级丛编"}),Pc=tt({subtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",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 为自动匹配,未经人工核对"}),Ac=tt({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",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:"專名線",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",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:"专名线",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献"}),Bc=tt({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:{published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"},qualityCriteria:{published:"達到出版、學術研究標準,錯誤率在萬分之一以內",fine:"通讀無障礙,錯誤率在百分之一以內",rough:"保證文意基本正確,錯誤率在百分之三以內",ocr:"保持大意和結構,錯誤率在百分之十以內"},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:{published:"出版",fine:"精校",rough:"粗校",ocr:"机器识别"},qualityCriteria:{published:"达到出版、学术研究标准,错误率在万分之一以内",fine:"通读无障碍,错误率在百分之一以内",rough:"保证文意基本正确,错误率在百分之三以内",ocr:"保持大意和结构,错误率在百分之十以内"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),Mc=tt({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:"规模、存佚、许可与版本"}),Wi=tt({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:"按作者浏览全部 →"}),Wc=tt({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} 条"}),Hc=tt({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:"搜索"}),Oc=tt({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:"回复"}),Fc=tt({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:"有争议"}}),Dc={common:Ic,detail:En,bookPage:Rc,workPage:Ec,collectionPage:Lc,entityPage:Pc,reader:Ac,collated:Bc,metaHome:Mc,readHome:Wi,catalogPage:Wc,searchPage:Hc,feedback:Oc,lineage:Fc};function Uc(t){const n={};for(const[o,r]of Object.entries(Dc))n[o]=r[t];return n}function it(t,n){return t.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Mo=new Map;function Ft(t){let n=Mo.get(t);return n||(n={...t==="zh-Hans"?Nc:Tc,...Uc(t)},Mo.set(t,n)),n}function Wo(t,n){let o=t;for(const r of n.split(".")){if(o==null||typeof o!="object")return;o=o[r]}return typeof o=="string"?o:void 0}function us(t){return(n,o)=>{const r=Wo(t,n)??Wo(Ft("zh-Hant"),n)??n;return o?it(r,o):r}}const Ho=new Map;function Dt(t){let n=Ho.get(t);return n||(n=us(Ft(t)),Ho.set(t,n)),n}const ms="bim-locale";function Vc(){try{const t=localStorage.getItem(ms);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function Gc(t){try{localStorage.setItem(ms,t)}catch{}}const Yc="zh-Hans",Kc=({locale:t,onLocaleChange:n,converter:o,children:r})=>{const[s,l]=x.useState(t??Yc),a=t??s;x.useEffect(()=>{if(t)return;const u=Vc();u&&u!==s&&l(u)},[]);const p=x.useMemo(()=>a==="zh-Hans"?o??zc():null,[a,o]),c=x.useCallback(u=>{l(u),Gc(u),n==null||n(u)},[n]),d=x.useMemo(()=>({locale:a,setLocale:c,messages:Ft(a),converter:p}),[a,c,p]);return e.jsx(It.Provider,{value:d,children:r})};function ve(){const t=x.useContext(It);return(t==null?void 0:t.messages)??Ft("zh-Hant")}const qc=2e3;function Te(){const t=x.useContext(It),n=(t==null?void 0:t.locale)??"zh-Hant",o=(t==null?void 0:t.converter)??null,r=x.useRef(new Map),s=x.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const l=x.useCallback(a=>{if(!a)return"";if(!o)return a;const p=r.current.get(a);if(p!==void 0)return p;const c=o(a);if(r.current.size>=qc){const d=r.current.keys().next().value;d!==void 0&&r.current.delete(d)}return r.current.set(a,c),c},[o]);return x.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function G(){const t=x.useContext(It),{convert:n,locale:o,isSimplified:r}=Te(),s=(t==null?void 0:t.messages)??Ft("zh-Hant"),l=x.useMemo(()=>t?us(s):Dt("zh-Hant"),[t,s]);return x.useMemo(()=>({t:l,convert:n,locale:o,isSimplified:r,messages:s}),[l,n,o,r,s])}const gs=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Zc=new Set([...gs,...Object.keys(xe.VARIANT_CHARS)]),hs=[...ps,"切換為繁體","漢籍リポジトリ"];function Jc(t,n=hs){let o=t;for(const l of n)l&&(o=o.split(l).join(" "));const r=[],s=Array.from(o);return s.forEach((l,a)=>{Zc.has(l)&&r.push({char:l,context:s.slice(Math.max(0,a-8),a+9).join("")})}),r}function Xc(t){if(!t)return"";try{const n=new URL(t).hostname,o={"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(o[n])return o[n];const r=n.split(".");return r.length>=2?r[r.length-2]:n}catch{return""}}function Qc(){return{id:"",name:"",url:"",type:"text",details:""}}const fi=({items:t,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const l=ve(),[a,p]=x.useState(null),c=[{value:"text",label:l.resourceTypeShort.text},{value:"image",label:l.resourceTypeShort.image},{value:"text+image",label:l.resourceTypeShort.textImage},{value:"physical",label:l.resourceTypeShort.physical}],d=[{value:"catalog",label:l.rootType.catalog},{value:"search",label:l.rootType.search}],u=b=>{if(!s)return!0;const j=Nt(b);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},g=t.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>u(b)),m=()=>{const b=Qc();s&&(b.type=s),n([...t,b]),p(t.length)},h=b=>{n(t.filter((j,S)=>S!==b)),p(null)},f=(b,j,S)=>{const k=[...t];if(k[b]={...k[b],[j]:S},j==="url"&&!k[b].id){const $=Xc(S);$&&(k[b].id=$)}n(k)},v=(b,j,S)=>{const $={...t[b].metadata||{}};S?$[j]=S:delete $[j],f(b,"metadata",Object.keys($).length>0?$:void 0)},y=(b,j)=>{const S=j.trim()?j.split(/[,,、]/).map(k=>k.trim()).filter(Boolean):void 0;f(b,"structure",S)},w=(b,j,S)=>{const $=t[b].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(S)||1:$.ranges=S,f(b,"coverage",$.ranges?$:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[g.map(({item:b,originalIndex:j})=>{var S,k,$;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(a===j?null:j),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:a===j?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:ed(b.type??"text"),color:i("on-color-fg")},children:(()=>{var z,E;const _=Nt(b);return _.length===0?b.type??"text":_.length===1?((z=c.find(T=>T.value===_[0]))==null?void 0:z.label)??_[0]:_.includes("text")&&_.includes("image")?((E=c.find(T=>T.value==="text+image"))==null?void 0:E.label)??"text+image":_.join("+")})()}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${l.editor.resourcePlaceholder} ${j+1}`}),b.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&e.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&td(j,r==null?void 0:r[j],o,l),e.jsx("button",{onClick:_=>{_.stopPropagation(),h(j)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),a===j&&e.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[Sc(b,"image")&&b.url&&nd(b,l),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:qt,children:[e.jsx("span",{style:Zt,children:l.label.type}),e.jsx("select",{value:b.type,onChange:_=>f(j,"type",_.target.value),style:{...dt,flex:1},children:c.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))})]}),e.jsxs("label",{style:qt,children:[e.jsx("span",{style:Zt,children:l.label.rootType}),e.jsx("select",{value:b.root_type||"catalog",onChange:_=>f(j,"root_type",_.target.value),style:{...dt,flex:1},children:d.map(_=>e.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:b.id,onChange:_=>f(j,"id",_.target.value),placeholder:l.editor.idAutoExtract,style:{...dt,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:b.name,onChange:_=>f(j,"name",_.target.value),placeholder:l.editor.resourceName,style:{...dt,flex:1}})]}),e.jsx("input",{type:"text",value:b.url,onChange:_=>f(j,"url",_.target.value),placeholder:l.editor.resourceUrl,style:dt}),e.jsx("input",{type:"text",value:((S=b.structure)==null?void 0:S.join("、"))||"",onChange:_=>y(j,_.target.value),placeholder:l.editor.structurePlaceholder,style:dt}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:qt,children:[e.jsx("span",{style:Zt,children:l.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((k=b.coverage)==null?void 0:k.level)??"",onChange:_=>w(j,"level",_.target.value),placeholder:"1",style:{...dt,width:"60px"}})]}),e.jsxs("label",{style:{...qt,flex:1},children:[e.jsx("span",{style:Zt,children:l.label.coverageRange}),e.jsx("input",{type:"text",value:(($=b.coverage)==null?void 0:$.ranges)||"",onChange:_=>w(j,"ranges",_.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...dt,flex:1}})]})]}),e.jsx("textarea",{value:b.details||"",onChange:_=>f(j,"details",_.target.value),placeholder:l.editor.detailsPlaceholder,style:{...dt,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:l.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([_,z])=>{var E;return e.jsxs("label",{style:{...qt,gap:"4px"},children:[e.jsx("span",{style:{...Zt,minWidth:"56px"},children:z}),e.jsx("input",{type:"text",value:((E=b.metadata)==null?void 0:E[_])||"",onChange:T=>v(j,_,T.target.value),placeholder:z,style:{...dt,flex:1}})]},_)})})]})]})]})]},j)}),e.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:l.action.addResource})]})]})};function ed(t){switch(t){case"text":return i("restype-text");case"image":return i("restype-image");case"text+image":return i("restype-text-image");case"physical":return i("restype-physical")}}function td(t,n,o,r){const s=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return e.jsx("button",{onClick:a=>{a.stopPropagation(),s||o(t,"")},disabled:s,style:{background:"transparent",border:"none",color:i(l?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:l?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:l?"✓":s?"⏳":"⬇"})}function nd(t,n){const o=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(t.url)||t.url.includes("iiif")||t.url.includes("image");return e.jsx("div",{style:{marginBottom:"12px"},children:o?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:e.jsx("img",{src:t.url,alt:t.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const dt={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},qt={display:"flex",alignItems:"center",gap:"6px"},Zt={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},id={"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 Ut(t){try{return id[new URL(t).hostname]}catch{return}}const Oo={text:0,image:1,physical:2};function Hi(t){return t.length===0?"physical":[...t].sort((n,o)=>(Oo[n]??99)-(Oo[o]??99)).join("+")}function Oi(t){var a;const n=p=>{const c=p.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const d=p.match(/^(.+?)[·(](\d+)[)]?$/);return d?[d[1],parseInt(d[2])]:null},o=new Map;for(let p=0;p<t.length;p++){const c=t[p];if(c.volumes&&c.volumes.length>0)continue;const d=n(c.name);if(!d)continue;const[u,g]=d,m=`${u}|${Hi(Nt(c))}`;o.has(m)||o.set(m,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const h=o.get(m);h.volumes.push({volume:g,url:c.url||void 0,status:"found"}),h.indices.push(p)}const r=[],s=new Set;for(const p of o.values())if(!(p.volumes.length<2)){p.volumes.sort((c,d)=>c.volume-d.volume),p.base.volumes=p.volumes,p.base.expected_volumes=p.volumes.length,p.base.url||(p.base.url=((a=p.volumes.find(c=>c.url))==null?void 0:a.url)??""),r.push(p.base);for(const c of p.indices)s.add(c)}const l=[...r];for(let p=0;p<t.length;p++)s.has(p)||l.push(t[p]);return l}function xs(t){if(t.url)return t.url;for(const[n,o]of Object.entries(t))if(n.endsWith("_url")&&typeof o=="string")return o}function fs(t){return!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(n=>({...n,url:n.url||xs(n)}))}function Ln(t){const n=fs(t);if(!n)return null;const o=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,r=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:o,missing:r,expected:t.expected_volumes??o+r}}function Fi(t){if(!t)return;const n=t.file_page_range||t.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function Di(t,n){try{if(new URL(t).hostname.includes("wikimedia.org")){const r=t.match(/\/wiki\/File:(.+?)(?:#|$)/);if(r)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(r[1]))}&page=${n}`;const s=new URL(t);return s.searchParams.set("page",String(n)),s.toString()}return t}catch{return t}}function Vt(t){if(!t.url)return;const n=Fi(t.metadata);return n?Di(t.url,n):t.url}const Fo={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function od(t){return t.includes("text")&&t.includes("image")?Fo["text+image"]:Fo[t[0]||"physical"]}const Ui=({items:t,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const l=ve(),{convert:a}=Te(),p=x.useMemo(()=>Oi(t||[]),[t]),{mirrorGroups:c,ungroupedItems:d}=x.useMemo(()=>{const y=new Map,w=[];for(const b of p){const j=b.group;j?(y.has(j)||y.set(j,[]),y.get(j).push(b)):w.push(b)}for(const b of y.values())b.sort((j,S)=>{const k=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return k(j)-k(S)});return{mirrorGroups:y,ungroupedItems:w}},[p]),u={text:l.resourceType.text,image:l.resourceType.image,"text+image":l.resourceType.textImage,physical:l.resourceType.physical},g=y=>u[y]?u[y]:y.split("+").map(w=>u[w]||w).join("+");if(!p||p.length===0)return e.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:l.misc.noResources});if(!n)return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:p.map((y,w)=>e.jsx(ei,{item:y},y.id||w))});const m=(y,w)=>{const b=o==null?void 0:o[y],j=(b==null?void 0:b.label)||y,S=b==null?void 0:b.description;return e.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(j)}),S&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:a(S)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((k,$)=>e.jsx(ei,{item:k,onNavigate:r,renderLink:s},k.id||$))})]},`group-${y}`)},h=new Map;for(const y of d){const w=Hi(Nt(y));h.has(w)||h.set(w,[]),h.get(w).push(y)}const f=["text","image","text+image","physical"],v=[...f.filter(y=>h.has(y)),...[...h.keys()].filter(y=>!f.includes(y)).sort()];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,w])=>m(y,w)),v.map(y=>{const w=h.get(y),b=od(y.split("+"));return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:g(y)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((j,S)=>e.jsx(ei,{item:j,onNavigate:r,renderLink:s},j.id||S))})]},y)})]})},rd={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},ei=({item:t})=>{const n=ve(),{convert:o}=Te(),[r,s]=x.useState(!1),l=x.useMemo(()=>(t.url?Ut(t.url):void 0)||o(t.name),[t.url,t.name,o]),a=x.useMemo(()=>!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(f=>({...f,url:f.url||xs(f)})),[t.volumes]),p=a&&a.length>0,c=p?new Set(a.filter(f=>f.status!=="missing").map(f=>f.volume)).size:0,d=p?new Set(a.filter(f=>f.status==="missing").map(f=>f.volume)).size:0,u=t.expected_volumes??(p?c+d:0),g=t.color_mode?{...rd[t.color_mode],label:n.colorMode[t.color_mode]}:null,m=t.details&&!p?o(t.details):null,h={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",background:i("input-bg"),fontSize:"12px",color:i("fg"),lineHeight:1.4,verticalAlign:"middle"};return e.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[e.jsxs("div",{style:h,children:[e.jsx("span",{style:{fontWeight:500},children:l}),g&&e.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:g.bg,color:g.fg},children:g.label}),m&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:m}),p&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,d>0&&e.jsx("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:it(n.common.volumesMissing,{n:d})})]}),t.url&&e.jsx("a",{href:(()=>{const f=Fi(t.metadata);return f?Di(t.url,f):t.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),p&&e.jsx("button",{onClick:()=>s(!r),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",lineHeight:1.4},children:r?"▲":"▼"})]}),p&&r&&e.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:a.map(f=>{const v=f.status==="missing";return f.url&&!v?e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${i("widget-border")}`,color:i("link-fg"),textDecoration:"none"},children:f.volume},f.volume):e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(v?"missing-fg":"desc-fg"),textDecoration:v?"line-through":"none",opacity:v?.6:1},children:f.volume},f.volume)})})]})},bs=({indexSource:t,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:l,onSelectFolder:a})=>{const p=ve(),c=t==="local",d=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",g=u?u.split(/[/\\]/).pop()||u:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},h={onMouseOver:v=>v.currentTarget.style.opacity="0.8",onMouseOut:v=>v.currentTarget.style.opacity="1"},f=e.jsxs("div",{onClick:s,title:d?p.mode.switchToOfficial:p.mode.switchToDraft,style:{...m,background:i(d?"warning":"success"),color:i("on-color-fg")},...h,children:[e.jsx("span",{children:d?"📝":"📚"}),e.jsx("span",{children:d?"draft":"official"})]});return o==="index-browser"?c?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[f,e.jsxs("div",{onClick:r,title:p.mode.switchToSync,style:m,...h,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:p.mode.localMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...h,children:[e.jsx("span",{children:"📂"}),g&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:r,title:p.mode.switchToLocal,style:m,...h,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:p.mode.syncMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:l,title:g||p.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...h,children:e.jsx("span",{children:"⚙️"})})]})]}):e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsxs("div",{onClick:r,title:c?p.mode.switchToGithub:p.mode.switchToLocal,style:m,...h,children:[e.jsx("span",{children:c?"📁":"🌐"}),e.jsx("span",{children:c?p.mode.localMode:p.mode.githubSync}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...h,children:[e.jsx("span",{children:"📂"}),g&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]}),!c&&g&&e.jsxs("div",{style:{...m,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:g})]})]})},Pn="bim-search-history",Do=10,Uo=8;function on(){try{const t=localStorage.getItem(Pn);return t?JSON.parse(t):[]}catch{return[]}}function ys(t){try{const n=on().filter(o=>o!==t);n.unshift(t),n.length>Do&&(n.length=Do),localStorage.setItem(Pn,JSON.stringify(n))}catch{}}function sd(t){try{const n=on().filter(o=>o!==t);localStorage.setItem(Pn,JSON.stringify(n))}catch{}}function ld(){try{localStorage.removeItem(Pn)}catch{}}const js=({transport:t,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:l})=>{const a=ve(),p=l??a.search.placeholder,c={work:a.indexType.work,book:a.indexType.book,collection:a.indexType.collection,entity:a.indexType.entity},[d,u]=x.useState(!1),[g,m]=x.useState([]),[h,f]=x.useState(-1),[v,y]=x.useState(on),w=x.useRef(null),b=x.useRef(null),j=x.useRef(null),S=x.useRef(!1);x.useEffect(()=>{f(-1);const C=n.trim();if(!C){m(v.map(P=>({type:"history",text:P})));return}if(!t.searchAll){m([]);return}let O=!1;const W=setTimeout(()=>{t.searchAll(C,Uo).then(P=>{if(O)return;const Y=[...P.works,...P.books,...P.collections,...P.entities??[]];m(Y.slice(0,Uo).map(V=>({type:"entry",text:V.title||V.id,entry:V})))}).catch(()=>{O||m([])})},80);return()=>{O=!0,clearTimeout(W)}},[n,v,t]),x.useEffect(()=>{const C=O=>{j.current&&!j.current.contains(O.target)&&u(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]),x.useEffect(()=>{const C=O=>{var W,P;if(O.key==="/"&&document.activeElement!==w.current){const Y=(W=document.activeElement)==null?void 0:W.tagName;if(Y==="INPUT"||Y==="TEXTAREA"||Y==="SELECT")return;O.preventDefault(),(P=w.current)==null||P.focus()}};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const k=x.useCallback(C=>{C.trim()&&(ys(C.trim()),y(on())),r(C),u(!1)},[r]),$=x.useCallback(C=>{C.type==="history"?(o(C.text),k(C.text)):C.entry&&(s?(s(C.entry),u(!1)):(o(C.text),k(C.text)))},[o,k,s]),_=x.useCallback(C=>{if(!d||g.length===0){C.key==="Enter"&&k(n);return}switch(C.key){case"ArrowDown":C.preventDefault(),f(O=>(O+1)%g.length);break;case"ArrowUp":C.preventDefault(),f(O=>(O-1+g.length)%g.length);break;case"Enter":C.preventDefault(),h>=0&&h<g.length?$(g[h]):k(n);break;case"Escape":C.preventDefault(),u(!1);break}},[d,g,h,n,k,$]),z=x.useCallback((C,O)=>{O.stopPropagation(),sd(C),y(on()),m(W=>W.filter(P=>!(P.type==="history"&&P.text===C)))},[]),E=x.useCallback(C=>{C.stopPropagation(),ld(),y([]),m([])},[]);x.useEffect(()=>{if(h>=0&&b.current){const C=b.current.children;C[h]&&C[h].scrollIntoView({block:"nearest"})}},[h]);const T=!n.trim()&&v.length>0;return e.jsxs("div",{ref:j,style:{position:"relative",flex:1},children:[e.jsx("input",{ref:w,type:"text",placeholder:p,value:n,onChange:C=>{o(C.target.value),u(!0)},onCompositionStart:()=>{S.current=!0},onCompositionEnd:()=>{S.current=!1},onFocus:()=>{u(!0)},onKeyDown:_,style:{width:"100%",padding:"8px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),d&&g.length>0&&e.jsxs("div",{ref:b,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:i("input-bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"6px",boxShadow:i("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[T&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:i("desc-fg"),borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("span",{children:a.search.history}),e.jsx("button",{onClick:E,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:a.search.clearAll})]}),g.map((C,O)=>e.jsxs("div",{onClick:()=>$(C),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:O===h?i("list-active-bg"):"transparent"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:C.type==="history"?"🕐":"🔍"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.text}),C.entry&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[C.entry.type],C.entry.edition&&` · ${C.entry.edition}`,C.entry.author&&` · ${C.entry.author}`]}),C.type==="history"&&e.jsx("button",{onClick:W=>z(C.text,W),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:a.action.remove,children:"×"})]},`${C.type}-${C.text}-${O}`))]})]})},Gt=({type:t,size:n=9})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${t}`),verticalAlign:"middle"}}),An={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},vs=new Set(["work","book","entity"]);function ad(t){return Ss(t)||!!t.sort}function cd(t,n){return n.sort&&vs.has(t)?n.sort:void 0}const Bn=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Mn=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],ks=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],ws={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Wn(t){return t.dynasty.length+t.classification.length+(t.hasImage?1:0)+(t.hasText?1:0)+(t.hasCollated?1:0)+(t.loss?1:0)}function Ss(t){return Wn(t)>0}function dd(t){const n=[];return t.dynasty.length&&n.push("dynasty"),t.classification.length&&n.push("classification"),t.hasImage&&n.push("hasImage"),t.hasText&&n.push("hasText"),t.hasCollated&&n.push("hasCollated"),t.loss&&n.push("loss"),n}function $s(t,n){const o=ws[t];return dd(n).every(r=>o.has(r))}const Jt=t=>JSON.stringify(t);function pd(t,n){if(!$s(n,t))return null;const o=[];if(t.dynasty.length){const r=Array.from(new Set(t.dynasty.flatMap(s=>{var l;return((l=Bn.find(a=>a.key===s))==null?void 0:l.values)??[]})));r.length===1?o.push(`dynasty = ${Jt(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(Jt).join(", ")}]`)}return t.classification.length&&o.push(t.classification.length===1?`classification = ${Jt(t.classification[0])}`:`classification IN [${t.classification.map(Jt).join(", ")}]`),t.hasImage&&o.push("has_image = true"),t.hasText&&o.push("has_text = true"),t.hasCollated&&o.push("has_collated = true"),t.loss&&o.push(`loss_status = ${Jt(t.loss)}`),o.join(" AND ")}const Je={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},_s="_";function _n(t,n=new URLSearchParams){for(const o of Object.values(Je))n.delete(o);return t.dynasty.length&&n.set(Je.dynasty,t.dynasty.join(",")),t.classification.length&&n.set(Je.classification,t.classification.map(o=>o||_s).join(",")),t.hasImage&&n.set(Je.hasImage,"1"),t.hasText&&n.set(Je.hasText,"1"),t.hasCollated&&n.set(Je.hasCollated,"1"),t.loss&&n.set(Je.loss,t.loss),t.sort&&n.set(Je.sort,t.sort),n}function ud(t){const n=l=>(t.get(l)??"").split(",").map(a=>a.trim()).filter(Boolean),o=new Set(Bn.map(l=>l.key)),r=new Set(Mn.map(l=>l.value)),s=t.get(Je.loss);return{dynasty:Array.from(new Set(n(Je.dynasty).filter(l=>o.has(l)))),classification:Array.from(new Set(n(Je.classification).map(l=>l===_s?"":l).filter(l=>r.has(l)))),hasImage:t.get(Je.hasImage)==="1",hasText:t.get(Je.hasText)==="1"||t.get(Je.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(l=>l===t.get(Je.sort))??""}}function md(t,n){return JSON.stringify([t.dynasty.slice().sort(),t.classification.slice().sort(),t.hasImage,t.hasText,t.hasCollated,t.loss,t.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Vo(t,n){return t.includes(n)?t.filter(o=>o!==n):[...t,n]}const gd=({filters:t,onChange:n})=>{const o=ve(),r=o.searchV4,{convert:s}=Te(),[l,a]=x.useState(!1),p=x.useId(),c=Wn(t),d=u=>n({...t,...u});return e.jsxs("aside",{className:"bim-sr-aside","aria-label":s(r.filterTitle),children:[e.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":l,"aria-controls":p,onClick:()=>a(u=>!u),children:[e.jsxs("span",{children:[s(r.filterButton),c>0&&e.jsx("span",{className:"bim-sr-fn",children:s(it(r.filterSelected,{n:c}))})]}),e.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(l?r.collapse:r.expand)," ",l?"▴":"▾"]})]}),e.jsxs("div",{className:"bim-sr-filters",id:p,"data-open":l?"true":"false",...l?{}:{"data-collapsed":"true"},children:[e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.dynasty)}),e.jsx("div",{className:"bim-sr-chips",children:Bn.map(u=>e.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":t.dynasty.includes(u.key),onClick:()=>d({dynasty:Vo(t.dynasty,u.key)}),children:s(u.key)},u.key))})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.classification)}),Mn.map(u=>e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.classification.includes(u.value),onChange:()=>d({classification:Vo(t.classification,u.value)})}),u.value?s(u.label):o.searchPage.unclassified]},u.value||"_"))]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.resources)}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasImage,onChange:u=>d({hasImage:u.target.checked})}),s(r.hasImage)]}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasText,onChange:u=>d({hasText:u.target.checked})}),s(r.hasText)]})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{id:`${p}-loss`,children:s(r.extant)}),e.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${p}-loss`,children:ks.map(u=>e.jsx("button",{type:"button","aria-pressed":t.loss===u.value,onClick:()=>d({loss:u.value}),children:o.searchPage.loss[u.value||"all"]},u.value||"all"))})]}),c>0&&e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...An,sort:t.sort}),children:s(r.clearAllFilters)})]})]})};function Cs({text:t,query:n}){const o=(n??"").trim();if(!o||!t)return e.jsx(e.Fragment,{children:t});const r=t.toLowerCase(),s=o.toLowerCase(),l=[];let a=0,p=0;for(;a<t.length;){const c=r.indexOf(s,a);if(c<0){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{className:"bim-sr-hl",children:t.slice(c,c+s.length)},p++)),a=c+s.length}return e.jsx(e.Fragment,{children:l})}const Go=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=ve(),l=s.searchV4,{convert:a}=Te(),p=Ye();return e.jsx("div",{className:"bim-sr-tablewrap",children:e.jsxs("table",{className:"bim-sr-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"34%"}}),e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"19%"}}),e.jsx("col",{style:{width:"13%"}}),e.jsx("col",{style:{width:"12%"}}),e.jsx("col",{style:{width:"14%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:a(l.colTitle)}),e.jsx("th",{scope:"col",children:a(l.colType)}),e.jsx("th",{scope:"col",children:a(l.colAuthor)}),e.jsx("th",{scope:"col",children:a(l.colEra)}),e.jsx("th",{scope:"col",children:a(l.colClass)}),e.jsx("th",{scope:"col",style:{textAlign:"right"},children:a(l.colResource)})]})}),e.jsx("tbody",{children:t.map(c=>{const d=a(c.title||c.primary_name||c.id),u=c.measure_info?a(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",g=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${a(c.author)}${c.role&&c.role!=="author"?` ${a(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,h=m?a(m):"",f=c.classification?a(c.classification):"",v=[];c.has_image&&v.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&v.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&v.push({label:l.tagLost,cls:"bim-sr-tag--lost"});const y=[g,h,f].filter(Boolean).join(" · ");return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-sr-c-title",children:[e.jsxs("div",{className:"bim-sr-tl",children:[e.jsx("a",{href:p(c.id),onClick:w=>o(c,w),children:e.jsx(Cs,{text:d,query:n?a(n):void 0})}),u&&e.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&e.jsx("span",{className:"bim-sr-sub",children:y})]}),e.jsxs("td",{className:"bim-sr-c-type",children:[e.jsx(Gt,{type:c.type,size:6})," ",r(c.type)]}),e.jsx("td",{className:"bim-sr-c-who",children:g||"—"}),e.jsx("td",{className:"bim-sr-c-era",children:h||"—"}),e.jsx("td",{className:"bim-sr-c-cls",children:f||"—"}),e.jsx("td",{className:"bim-sr-c-res",children:v.map(w=>e.jsx("span",{className:`bim-sr-tag ${w.cls}`,children:a(w.label)},w.label))})]},c.id)})})]})})},hd=`
|
|
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 ${i("rule")}; background: ${i("card-bg")}; color: inherit; text-decoration: none; }
|
|
4
4
|
.bim-sc:hover { border-color: ${i("rule-dashed")}; box-shadow: ${i("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: ${i("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
|
-
`,
|
|
15
|
+
`,Yo=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=ve(),l=s.searchV4,{convert:a}=Te(),p=Ye();return e.jsxs("div",{className:"bim-sc-grid",children:[e.jsx("style",{children:hd}),t.map(c=>{const d=a(c.title||c.primary_name||c.id),u=c.measure_info?a(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??"?"}`:"":`${c.dynasty?`〔${a(c.dynasty)}〕`:""}${c.author?a(c.author):""}`,c.type==="book"&&c.edition?a(c.edition):"",u].filter(Boolean).join(" · "),h=[r(c.type),c.classification?a(c.classification):""].filter(Boolean).join(" · "),f=[];return c.has_image&&f.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&f.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&f.push({label:l.tagLost,cls:"bim-sr-tag--lost"}),e.jsxs("a",{className:"bim-sc",href:p(c.id),onClick:v=>o(c,v),children:[e.jsx("span",{className:"bim-sc-t",children:e.jsx(Cs,{text:d,query:n?a(n):void 0})}),m&&e.jsx("span",{className:"bim-sc-m",children:m}),c.descriptionSnippet&&e.jsx("p",{className:"bim-sc-s",children:Mi(c.descriptionSnippet).map((v,y)=>v.marked?e.jsx("mark",{children:a(v.text)},y):e.jsx(x.Fragment,{children:a(v.text)},y))}),e.jsx("span",{className:"bim-sc-sp"}),e.jsxs("div",{className:"bim-sc-f",children:[e.jsx("span",{className:"bim-sc-fl",children:h}),e.jsx("span",{className:"bim-sc-tags",children:f.map(v=>e.jsx("span",{className:`bim-sr-tag ${v.cls}`,children:a(v.label)},v.label))})]})]},c.id)})]})};function xd(t,n){const o=new Set([1,n,t-1,t,t+1].filter(l=>l>=1&&l<=n)),r=Array.from(o).sort((l,a)=>l-a),s=[];return r.forEach((l,a)=>{a>0&&l-r[a-1]>1&&s.push("gap"),s.push(l)}),s}function fd(t,n,o){const r=Math.max(1,Math.ceil(n/o));return Math.min(Math.max(1,t),r)}const bd=({page:t,pageSize:n,total:o,totalLabel:r,onPage:s})=>{const l=ve().searchV4,{convert:a}=Te(),p=Math.max(1,Math.ceil(o/n));return o<=0?null:e.jsxs("nav",{className:"bim-sr-pager","aria-label":a(l.pagerLabel),children:[e.jsx("span",{className:"bim-sr-info",children:a(it(l.pageInfo,{total:r??o.toLocaleString(),size:n,page:t,pages:p}))}),p>1&&e.jsxs("ul",{children:[e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t<=1,onClick:()=>s(t-1),children:a(l.prevPage)})}),xd(t,p).map((c,d)=>c==="gap"?e.jsx("li",{className:"bim-sr-gap","aria-hidden":"true",children:"…"},`g${d}`):e.jsx("li",{children:e.jsx("button",{type:"button","aria-current":c===t?"page":void 0,"aria-label":`${c}`,onClick:()=>s(c),children:c})},c)),e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t>=p,onClick:()=>s(t+1),children:a(l.nextPage)})})]})]})},zs="(max-width: 719px)",yd=`${zs}, (pointer: coarse)`,jd=`
|
|
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(${i("reader-top")} + 16px); padding-top: 2px; }
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
.bim-sr-pager .bim-sr-gap { color: ${i("aux-fg")}; padding: 0 2px; }
|
|
82
82
|
.bim-sr-empty { padding: 60px 0; text-align: center; font-size: 14px; color: ${i("meta-fg")}; }
|
|
83
83
|
|
|
84
|
-
@media ${
|
|
84
|
+
@media ${zs} {
|
|
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 ${
|
|
105
|
+
@media ${yd} {
|
|
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: ${i("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
|
-
`,Oi="bim-search-view",Xn=50,Vo=5,Go=1e3,Yo=["work","collection","book","entity"],gd={work:"works",collection:"collections",book:"books",entity:"entities"},hd={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function xd(){try{return window.localStorage.getItem(Oi)==="card"?"card":"table"}catch{return"table"}}function fd(t){try{window.localStorage.setItem(Oi,t)}catch{}}const qt=(t,n)=>(t==null?void 0:t[hd[n]])??0,Qn=(t,n)=>(t==null?void 0:t[gd[n]])??[],$s=({transport:t,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:l})=>{const a=ke(),d=a.searchV4,{convert:c}=Te(),p=!!t.supportsSearchFilters,u=x.useMemo(()=>p?o:Rn,[p,o]),[g,m]=x.useState("table");x.useEffect(()=>{m(xd())},[]);const h=L=>{m(L),fd(L)},[f,v]=x.useState("all"),[y,k]=x.useState(1),[b,j]=x.useState(null),[w,S]=x.useState(null),[$,_]=x.useState(!1),[C,I]=x.useState(""),T=wn(u).toString(),z=An(u)>0,H=wn({...u,sort:""}).toString(),W=x.useRef({query:n,filterOnlyKey:H,sort:u.sort});x.useEffect(()=>{const L=W.current;L.query!==n||L.filterOnlyKey!==H?(v("all"),k(1)):L.sort!==u.sort&&k(1),W.current={query:n,filterOnlyKey:H,sort:u.sort}},[n,H,u.sort]),x.useEffect(()=>{let L=!1;return _(!0),I(""),(async()=>{try{let U;if(t.searchAll)U=await t.searchAll(n,Vo,u);else{const de=["work","book","collection","entity"],ve=await Promise.all(de.map(Z=>t.search(n,Z,{page:1,pageSize:Vo,filters:u})));U={works:ve[0].entries,books:ve[1].entries,collections:ve[2].entries,entities:ve[3].entries,totalWorks:ve[0].total,totalBooks:ve[1].total,totalCollections:ve[2].total,totalEntities:ve[3].total}}L||j(U)}catch(U){L||(I(U instanceof Error?U.message:String(U)),j(null))}finally{L||_(!1)}})(),()=>{L=!0}},[t,n,T]),x.useEffect(()=>{if(f==="all"){S(null);return}let L=!1;return _(!0),(async()=>{try{const U=await t.search(n,f,{page:y,pageSize:Xn,filters:u});L||S({entries:U.entries,total:U.total})}catch(U){L||(I(U instanceof Error?U.message:String(U)),S(null))}finally{L||_(!1)}})(),()=>{L=!0}},[t,n,T,f,y]),x.useEffect(()=>{if(f==="all"||!w||$)return;const L=Math.min(w.total,Go),U=dd(y,L,Xn);w.entries.length===0&&L>0&&U!==y&&k(U)},[f,w,$,y]);const A=x.useMemo(()=>Yo.filter(L=>qt(b,L)>0),[b]),Y=A.reduce((L,U)=>L+qt(b,U),0),G=!$&&!C&&b!==null&&Y===0,te=x.useCallback(L=>{v(L),k(1)},[]),pe=x.useMemo(()=>{const L=[];return u.dynasty.forEach(U=>L.push({name:U,remove:()=>r({...u,dynasty:u.dynasty.filter(de=>de!==U)})})),u.classification.forEach(U=>{var de;return L.push({name:U?((de=Pn.find(ve=>ve.value===U))==null?void 0:de.label)??U:a.searchPage.unclassified,remove:()=>r({...u,classification:u.classification.filter(ve=>ve!==U)})})}),u.hasImage&&L.push({name:d.hasImage,remove:()=>r({...u,hasImage:!1})}),u.hasText&&L.push({name:d.hasText,remove:()=>r({...u,hasText:!1})}),u.hasCollated&&L.push({name:d.hasCollated,remove:()=>r({...u,hasCollated:!1})}),u.loss&&L.push({name:`${d.extant}:${a.searchPage.loss[u.loss]}`,remove:()=>r({...u,loss:""})}),L},[u,r,d,a]),B={query:n,onEntryLinkClick:s,typeName:l},E=L=>g==="table"?e.jsx(Do,{entries:L,...B}):e.jsx(Uo,{entries:L,...B}),ee=Yo.flatMap(L=>Qn(b,L));return e.jsxs("div",{className:"bim-sr-layout","data-nofilters":p?void 0:"true",children:[e.jsx("style",{children:md}),p&&e.jsx(ld,{filters:u,onChange:r}),e.jsxs("div",{className:"bim-sr-main","aria-busy":$,children:[A.length>0&&e.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":a.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${i("rule")}`},children:[e.jsxs(Ko,{on:f==="all",onClick:()=>te("all"),children:[a.search.allTab," ",e.jsx("small",{children:Y.toLocaleString()})]}),A.map(L=>e.jsxs(Ko,{on:f===L,onClick:()=>te(L),children:[l(L)," ",e.jsx("small",{children:qt(b,L).toLocaleString()})]},L))]}),e.jsxs("div",{className:"bim-sr-tools",children:[p&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":c(d.sortLabel),children:[e.jsx("button",{type:"button","aria-pressed":!u.sort,onClick:()=>r({...u,sort:""}),children:c(d.sortRelevance)}),["era","title"].map(L=>{const U=u.sort.startsWith(`${L}:`)?u.sort.endsWith("desc")?"desc":"asc":null,de=L==="era"?d.sortEra:d.sortTitle,ve=L==="era"?U==="desc"?d.sortEraDesc:d.sortEraAsc:U==="desc"?d.sortTitleDesc:d.sortTitleAsc;return e.jsxs("button",{type:"button","aria-pressed":U!==null,title:c(ve),onClick:()=>r({...u,sort:`${L}:${U==="asc"?"desc":"asc"}`}),children:[c(de),U?e.jsxs("span",{"aria-hidden":"true",children:[" ",U==="asc"?"↑":"↓"]}):null]},L)})]}),e.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),e.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":c(d.viewLabel),children:[e.jsx("button",{type:"button","aria-pressed":g==="table",onClick:()=>h("table"),children:c(d.viewTable)}),e.jsx("button",{type:"button","aria-pressed":g==="card",onClick:()=>h("card"),children:c(d.viewCard)})]})]}),z&&e.jsxs("div",{className:"bim-sr-chips-row",children:[e.jsx("span",{className:"bim-sr-count",role:"status",children:c(tt(d.filteredCount,{n:Y.toLocaleString()}))}),pe.map(L=>e.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":c(tt(d.removeFilter,{name:L.name})),onClick:L.remove,children:[c(L.name),e.jsx("span",{"aria-hidden":"true",children:"×"})]},L.name))]}),C&&e.jsx("div",{className:"bim-sr-empty",role:"alert",children:C}),G&&e.jsx("div",{className:"bim-sr-empty",children:c(z?d.emptyFiltered:tt(a.search.noResultsFor,{query:n}))}),!C&&!G&&f==="all"&&b&&(g==="table"?e.jsxs(e.Fragment,{children:[e.jsx(Do,{entries:ee,...B}),e.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:c(d.limitedNote)})]}):e.jsx(e.Fragment,{children:A.map(L=>e.jsxs("section",{style:{marginTop:22},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[e.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[e.jsx(Dt,{type:L,size:8}),l(L),e.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[qt(b,L).toLocaleString()," ",a.unit.items]})]}),qt(b,L)>Qn(b,L).length&&e.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>te(L),children:a.action.viewAll})]}),e.jsx(Uo,{entries:Qn(b,L),...B})]},L))})),!C&&f!=="all"&&w&&w.entries.length>0&&e.jsxs(e.Fragment,{children:[E(w.entries),e.jsx(pd,{page:y,pageSize:Xn,total:Math.min(w.total,Go),onPage:k})]}),!C&&f!=="all"&&w&&w.entries.length===0&&!$&&e.jsxs("div",{className:"bim-sr-empty",children:[c(z?d.emptyFiltered:tt(a.search.noResultsFor,{query:n})),e.jsx("div",{children:e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>te("all"),children:a.search.allTab})})]})]})]})};function Ko({on:t,onClick:n,children:o}){return e.jsx("button",{type:"button","aria-pressed":t,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:i(t?"ink":"meta-fg"),fontWeight:t?700:400,boxShadow:t?`inset 0 -2px 0 ${i("accent")}`:"none"},children:o})}const Pt="bim-recent-ids",qo="bim-recent-entries",Zo=50;function bt(){try{const t=localStorage.getItem(Pt);if(t)return JSON.parse(t);const n=localStorage.getItem(qo);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(Pt,JSON.stringify(o)),localStorage.removeItem(qo),o}return[]}catch{return[]}}function gi(t){try{const n=bt().filter(o=>o!==t);n.unshift(t),n.length>Zo&&(n.length=Zo),localStorage.setItem(Pt,JSON.stringify(n))}catch{}}function _s(t){try{const n=bt().filter(o=>o!==t);localStorage.setItem(Pt,JSON.stringify(n))}catch{}}function Fi(){try{localStorage.removeItem(Pt)}catch{}}async function Di(t,n){var o,r,s;try{if(t.getEntry){const a=await t.getEntry(n);if(a)return a}const l=await t.getItem(n);if(l){const a=l.authors;return{id:n,title:l.title||n,type:l.type||"work",author:(o=a==null?void 0:a[0])==null?void 0:o.name,dynasty:(r=a==null?void 0:a[0])==null?void 0:r.dynasty,role:(s=a==null?void 0:a[0])==null?void 0:s.role,edition:l.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const ei=5,bd=50,yd=200,Jo={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},hi=({transport:t,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:l,onToggleDraft:a,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:u="compact",renderEntry:g,initialQuery:m,onQueryChange:h,headerRight:f,reserveViewportHeight:v=!1,filtersEnabled:y=!1,filters:k=Rn,onFiltersChange:b})=>{const j=ke(),w=[{type:"work",name:j.indexType.work,key:"works"},{type:"book",name:j.indexType.book,key:"books"},{type:"collection",name:j.indexType.collection,key:"collections"},{type:"entity",name:j.indexType.entity,key:"entities"}],S=["work","collection","book","entity"],[$,_]=x.useState(m??""),[C,I]=x.useState(null),[T,z]=x.useState(m??""),H=wn(k).toString(),[W,A]=x.useState(k);x.useEffect(()=>{A(k)},[H]);const Y=X=>{A(X),b==null||b(X)},[G,te]=x.useState(null),[pe,B]=x.useState("all"),[E,ee]=x.useState(!1),[L,U]=x.useState(null),[de,ve]=x.useState(""),[Z,ce]=x.useState(!(m!=null&&m.trim())),[be,We]=x.useState(bt),[ye,_e]=x.useState([]),[He,Be]=x.useState(!1),[Re,ze]=x.useState(!1),[Ee,D]=x.useState(null),[ae,le]=x.useState(null),Se=x.useRef(void 0),F=x.useRef(!1),me=x.useCallback(async(X,Ie)=>{if(!X.trim()){ce(!0),I(null),te(null);return}if(ce(!1),y){z(X);return}ee(!0),ve("");try{if(t.searchAll){const fe=await t.searchAll(X,Ie??ei);I(fe)}else{const fe=["work","book","collection","entity"],Me=await Promise.all(fe.map(P=>t.search(X,P,{page:1,pageSize:Ie??ei})));I({works:Me[0].entries,books:Me[1].entries,collections:Me[2].entries,entities:Me[3].entries,totalWorks:Me[0].total,totalBooks:Me[1].total,totalCollections:Me[2].total,totalEntities:Me[3].total})}}catch(fe){ve(fe instanceof Error?fe.message:String(fe)),I(null)}finally{ee(!1)}},[t,y]);x.useEffect(()=>{let X=!1;const Ie=()=>{var se,ue;const fe=["work","book","collection","entity"],Me=Promise.all(fe.map(ie=>t.loadEntries(ie,{page:1,pageSize:1}).catch(()=>({total:0})))),P=((se=t.getResourceCounts)==null?void 0:se.call(t).catch(()=>null))??Promise.resolve(null),q=((ue=t.getSubtypeStats)==null?void 0:ue.call(t).catch(()=>null))??Promise.resolve(null);Promise.all([Me,P,q]).then(([ie,M,ge])=>{X||(D({works:ie[0].total,books:ie[1].total,collections:ie[2].total,entities:ie[3].total,hasText:M==null?void 0:M.hasText,hasImage:M==null?void 0:M.hasImage}),ge&&le(ge))})};return t.getCounts?t.getCounts().then(fe=>{var Me,P;X||(D({works:fe.works,books:fe.books,collections:fe.collections,entities:fe.entities,hasText:(Me=fe.resourceCounts)==null?void 0:Me.hasText,hasImage:(P=fe.resourceCounts)==null?void 0:P.hasImage}),fe.subtypeStats&&le(fe.subtypeStats))}).catch(()=>{X||Ie()}):Ie(),()=>{X=!0}},[t]),x.useEffect(()=>{F.current||!(m!=null&&m.trim())||(F.current=!0,me(m))},[m,me]);const Ae=x.useCallback(X=>{if(_(X),!X.trim()){h==null||h(X),ce(!0),I(null),te(null),B("all");return}Se.current&&clearTimeout(Se.current),Se.current=setTimeout(()=>{te(null),B("all"),h==null||h(X),me(X)},yd)},[me,h]),R=x.useCallback(X=>{Se.current&&clearTimeout(Se.current),B("all"),h==null||h(X),me(X)},[me,h]),Q=x.useCallback(X=>{te(X),me($,bd)},[$,me]);x.useEffect(()=>{if(!be.length){_e([]);return}let X=!1;return Be(!0),Promise.all(be.slice(0,10).map(Ie=>Di(t,Ie))).then(Ie=>{X||(_e(Ie),Be(!1))}),()=>{X=!0}},[be,t]);const xe=X=>{U(X.id),gi(X.id),We(bt()),r==null||r(X)},N=(X,Ie)=>{if(r&&vd(Ie)){Ie.preventDefault(),xe(X);return}gi(X.id),We(bt())},ne=X=>{_s(X),We(bt())},J=()=>{Fi(),We([])},re=X=>w.find(Ie=>Ie.type===X),Ce=!Z&&!C&&!de,Le=C&&(C.works.length>0||C.books.length>0||C.collections.length>0),$e=e.jsxs(e.Fragment,{children:[e.jsx(xs,{transport:t,value:$,onChange:Ae,onSearch:R,onEntrySelect:xe}),y&&e.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const X=$.trim();X&&hs(X),R($)},children:j.searchPage.submit}),s&&e.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${i("primary")}`,borderRadius:"6px",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"13px"},children:j.action.newEntry})]});return e.jsxs("div",{className:"bim-browser-container",style:v?{minHeight:"100svh"}:void 0,children:[e.jsx("style",{children:kd+(y?wd:"")}),(!y||f||!p)&&e.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?e.jsx("span",{}):e.jsx("h1",{style:{margin:0,fontSize:"18px",color:i("fg")},children:j.browser.title}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,!p&&e.jsx(gs,{variant:"index-browser",indexSource:n,syncConfig:o,onSwitchMode:l,onToggleDraft:a,onConfigurePath:d,onSelectFolder:c})]})]})}),y?e.jsxs("div",{className:"bim-ib-bar","data-nofilters":t.supportsSearchFilters?void 0:"true",children:[e.jsx("span",{"aria-hidden":"true"}),e.jsx("div",{className:"bim-ib-bar-main",children:$e})]}):e.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:$e}),Z&&e.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:Ee&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:ae?e.jsxs(e.Fragment,{children:[(ae.book??0)>0&&e.jsxs(e.Fragment,{children:[j.searchPage.statBook," ",e.jsx("strong",{style:{color:i("fg")},children:ae.book.toLocaleString()})," ",j.unit.bu,j.searchPage.statComma,e.jsx("strong",{style:{color:i("fg")},children:Ee.books.toLocaleString()})," ",j.searchPage.statBookCopies]}),ae.article?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),j.searchPage.statArticle," ",e.jsx("strong",{style:{color:i("fg")},children:ae.article.toLocaleString()})," ",j.searchPage.statArticleUnit]}):null,ae.poem?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),j.searchPage.statPoem," ",e.jsx("strong",{style:{color:i("fg")},children:ae.poem.toLocaleString()})," ",j.searchPage.statPoemUnit]}):null,e.jsx("span",{style:{margin:"0 6px"},children:"·"}),j.searchPage.statCollection," ",e.jsx("strong",{style:{color:i("fg")},children:Ee.collections.toLocaleString()})]}):e.jsxs(e.Fragment,{children:[j.indexType.work," ",e.jsx("strong",{style:{color:i("fg")},children:Ee.works.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),j.indexType.book," ",e.jsx("strong",{style:{color:i("fg")},children:Ee.books.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),j.indexType.collection," ",e.jsx("strong",{style:{color:i("fg")},children:Ee.collections.toLocaleString()}),Ee.entities>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),j.indexType.entity," ",e.jsx("strong",{style:{color:i("fg")},children:Ee.entities.toLocaleString()})]})]})}),Ee.hasImage!=null&&Ee.hasText!=null&&e.jsxs("span",{children:[j.resourceType.image," ",e.jsx("strong",{style:{color:i("fg")},children:Ee.hasImage.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),j.resourceType.text," ",e.jsx("strong",{style:{color:i("fg")},children:Ee.hasText.toLocaleString()})]})]})}),y&&!Z&&e.jsx($s,{transport:t,query:T,filters:W,onFiltersChange:Y,onEntryLinkClick:N,typeName:X=>re(X).name}),!(y&&!Z)&&e.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:E||Ce?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:jd,boxSizing:"border-box"},children:j.search.searching}):de?e.jsx("div",{style:{textAlign:"center",padding:"40px"},children:e.jsx("p",{style:{color:i("desc-fg")},children:de})}):Z?e.jsx("div",{style:{flex:1},children:He?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:j.search.loading}):ye.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{children:j.search.recentBrowse}),e.jsx("button",{onClick:J,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:j.search.clearRecent})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:ye.slice(0,Re?10:3).map(X=>X.notFound?e.jsx(Cd,{id:X.id,onRemove:ne,t:j},X.id):e.jsx(Xo,{entry:X,selected:L===X.id,onClick:N,getConfig:re,onRemove:ne},X.id))}),!Re&&ye.length>3&&e.jsx("button",{onClick:()=>ze(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:j.action.expandMore})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:j.search.searchTitle}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:j.search.searchSubtitle})]})}):Le?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsx("style",{children:Sd}),(()=>{const X=q=>C[Jo[q]]??0,Ie=S.map(q=>w.find(se=>se.type===q)).filter(q=>X(q.key)>0);if(Ie.length<2)return null;const fe=Ie.reduce((q,se)=>q+X(se.key),0),Me=q=>{if(B(q),q!=="all"&&G!==q){const se=w.find(ie=>ie.type===q),ue=(C[se.key]??[]).length;X(se.key)>ue&&Q(q)}},P=q=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(q?"fg":"desc-fg"),fontWeight:q?700:400,boxShadow:q?`inset 0 -2px 0 ${i("primary")}`:"none"});return e.jsxs("div",{role:"group","aria-label":j.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs("button",{type:"button","aria-pressed":pe==="all",style:P(pe==="all"),onClick:()=>Me("all"),children:[j.search.allTab," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:fe.toLocaleString()})]}),Ie.map(q=>e.jsxs("button",{type:"button","aria-pressed":pe===q.type,style:P(pe===q.type),onClick:()=>Me(q.type),children:[q.name," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:X(q.key).toLocaleString()})]},q.type))]})})(),w.map(({type:X,name:Ie,key:fe})=>{const Me=C[fe]??[],P=Jo[fe],q=C[P]??0;if(Me.length===0||pe!=="all"&&pe!==X)return null;const ue=pe==="all"&&!(G===X)&&q>ei;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[e.jsx(Dt,{type:X})," ",Ie,e.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[q," ",j.unit.items]})]}),ue&&e.jsx("button",{className:"bim-ib-viewall",onClick:()=>Q(X),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:j.action.viewAll})]}),e.jsx("div",{style:u==="list"?{display:"flex",flexDirection:"column",gap:0}:u==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:Me.map(ie=>{if(g)return e.jsx(x.Fragment,{children:g(ie)},ie.id);const M=u==="card"?_d:Xo;return e.jsx(M,{entry:ie,selected:L===ie.id,onClick:N,getConfig:re,query:$},ie.id)})})]},X)})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:tt(j.search.noResultsFor,{query:$})}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:j.search.tryOther})]})})]})},jd=240;function vd(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}const kd=`
|
|
120
|
+
`,Vi="bim-search-view",ti=50,Ko=5,rn=1e3;function kn(t){return t>=rn?`${rn.toLocaleString()}+`:t.toLocaleString()}const vd={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function kd(t){return t&&vd[t.toLowerCase()]||"all"}function wd(t){return t==="all"?null:t}const qo=["work","collection","book","entity"],Sd={work:"works",collection:"collections",book:"books",entity:"entities"},$d={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function _d(){try{return window.localStorage.getItem(Vi)==="card"?"card":"table"}catch{return"table"}}function Cd(t){try{window.localStorage.setItem(Vi,t)}catch{}}const Lt=(t,n)=>(t==null?void 0:t[$d[n]])??0,ni=(t,n)=>(t==null?void 0:t[Sd[n]])??[],Ts=({transport:t,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:l,tab:a,onTabChange:p})=>{const c=ve(),d=c.searchV4,{convert:u}=Te(),g=!!t.supportsSearchFilters,m=x.useMemo(()=>g?o:An,[g,o]),[h,f]=x.useState("table");x.useEffect(()=>{f(_d())},[]);const v=M=>{f(M),Cd(M)},[y,w]=x.useState(a??"all");x.useEffect(()=>{a!==void 0&&(w(a),j(1))},[a]);const[b,j]=x.useState(1),[S,k]=x.useState(null),[$,_]=x.useState(null),[z,E]=x.useState(!1),[T,C]=x.useState(""),O=_n(m).toString(),W=Wn(m)>0,P=_n({...m,sort:""}).toString(),Y=x.useRef({query:n,filterOnlyKey:P,sort:m.sort});x.useEffect(()=>{const M=Y.current;M.query!==n||M.filterOnlyKey!==P?(w("all"),j(1)):M.sort!==m.sort&&j(1),Y.current={query:n,filterOnlyKey:P,sort:m.sort}},[n,P,m.sort]),x.useEffect(()=>{let M=!1;return E(!0),C(""),(async()=>{try{let K;if(t.searchAll)K=await t.searchAll(n,Ko,m);else{const Re=["work","book","collection","entity"],se=await Promise.all(Re.map(ye=>t.search(n,ye,{page:1,pageSize:Ko,filters:m})));K={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}}M||k(K)}catch(K){M||(C(K instanceof Error?K.message:String(K)),k(null))}finally{M||E(!1)}})(),()=>{M=!0}},[t,n,O]);const V=y;x.useEffect(()=>{if(y==="all"){_(null);return}let M=!1;return E(!0),(async()=>{try{const K=await t.search(n,y,{page:b,pageSize:ti,filters:m});M||_({key:V,entries:K.entries,total:K.total})}catch(K){M||(C(K instanceof Error?K.message:String(K)),_(null))}finally{M||E(!1)}})(),()=>{M=!0}},[t,n,O,y,b]);const Q=$&&$.key===V?$:null;x.useEffect(()=>{if(y==="all"||!Q||z)return;const M=Math.min(Q.total,rn),K=fd(b,M,ti);Q.entries.length===0&&M>0&&K!==b&&j(K)},[y,Q,z,b]);const ge=x.useMemo(()=>qo.filter(M=>Lt(S,M)>0),[S]),A=ge.reduce((M,K)=>M+Lt(S,K),0),I=ge.some(M=>Lt(S,M)>=rn)?`${A.toLocaleString()}+`:A.toLocaleString(),Z=!z&&!T&&S!==null&&A===0,ee=x.useCallback(M=>{w(M),j(1),p==null||p(M)},[p]),ce=x.useMemo(()=>{const M=[];return m.dynasty.forEach(K=>M.push({name:K,remove:()=>r({...m,dynasty:m.dynasty.filter(Re=>Re!==K)})})),m.classification.forEach(K=>{var Re;return M.push({name:K?((Re=Mn.find(se=>se.value===K))==null?void 0:Re.label)??K:c.searchPage.unclassified,remove:()=>r({...m,classification:m.classification.filter(se=>se!==K)})})}),m.hasImage&&M.push({name:d.hasImage,remove:()=>r({...m,hasImage:!1})}),m.hasText&&M.push({name:d.hasText,remove:()=>r({...m,hasText:!1})}),m.hasCollated&&M.push({name:d.hasCollated,remove:()=>r({...m,hasCollated:!1})}),m.loss&&M.push({name:`${d.extant}:${c.searchPage.loss[m.loss]}`,remove:()=>r({...m,loss:""})}),M},[m,r,d,c]),fe={query:n,onEntryLinkClick:s,typeName:l},Ie=M=>h==="table"?e.jsx(Go,{entries:M,...fe}):e.jsx(Yo,{entries:M,...fe}),q=qo.flatMap(M=>ni(S,M));return e.jsxs("div",{className:"bim-sr-layout","data-nofilters":g?void 0:"true",children:[e.jsx("style",{children:jd}),g&&e.jsx(gd,{filters:m,onChange:r}),e.jsxs("div",{className:"bim-sr-main","aria-busy":z,children:[ge.length>0&&e.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":c.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${i("rule")}`},children:[e.jsxs(Zo,{on:y==="all",onClick:()=>ee("all"),children:[c.search.allTab," ",e.jsx("small",{children:I})]}),ge.map(M=>e.jsxs(Zo,{on:y===M,onClick:()=>ee(M),children:[l(M)," ",e.jsx("small",{children:kn(Lt(S,M))})]},M))]}),e.jsxs("div",{className:"bim-sr-tools",children:[g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(d.sortLabel),children:[e.jsx("button",{type:"button","aria-pressed":!m.sort,onClick:()=>r({...m,sort:""}),children:u(d.sortRelevance)}),["era","title"].map(M=>{const K=m.sort.startsWith(`${M}:`)?m.sort.endsWith("desc")?"desc":"asc":null,Re=M==="era"?d.sortEra:d.sortTitle,se=M==="era"?K==="desc"?d.sortEraDesc:d.sortEraAsc:K==="desc"?d.sortTitleDesc:d.sortTitleAsc;return e.jsxs("button",{type:"button","aria-pressed":K!==null,title:u(se),onClick:()=>r({...m,sort:`${M}:${K==="asc"?"desc":"asc"}`}),children:[u(Re),K?e.jsxs("span",{"aria-hidden":"true",children:[" ",K==="asc"?"↑":"↓"]}):null]},M)})]}),e.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),e.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(d.viewLabel),children:[e.jsx("button",{type:"button","aria-pressed":h==="table",onClick:()=>v("table"),children:u(d.viewTable)}),e.jsx("button",{type:"button","aria-pressed":h==="card",onClick:()=>v("card"),children:u(d.viewCard)})]})]}),W&&e.jsxs("div",{className:"bim-sr-chips-row",children:[e.jsx("span",{className:"bim-sr-count",role:"status",children:u(it(d.filteredCount,{n:I}))}),ce.map(M=>e.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(it(d.removeFilter,{name:M.name})),onClick:M.remove,children:[u(M.name),e.jsx("span",{"aria-hidden":"true",children:"×"})]},M.name))]}),T&&e.jsx("div",{className:"bim-sr-empty",role:"alert",children:T}),Z&&e.jsx("div",{className:"bim-sr-empty",children:u(W?d.emptyFiltered:it(c.search.noResultsFor,{query:n}))}),!T&&!Z&&y==="all"&&S&&(h==="table"?e.jsxs(e.Fragment,{children:[e.jsx(Go,{entries:q,...fe}),e.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(d.limitedNote)})]}):e.jsx(e.Fragment,{children:ge.map(M=>e.jsxs("section",{style:{marginTop:22},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[e.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[e.jsx(Gt,{type:M,size:8}),l(M),e.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[kn(Lt(S,M))," ",c.unit.items]})]}),Lt(S,M)>ni(S,M).length&&e.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>ee(M),children:c.action.viewAll})]}),e.jsx(Yo,{entries:ni(S,M),...fe})]},M))})),!T&&y!=="all"&&!Q&&e.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:c.search.loading}),!T&&y!=="all"&&Q&&Q.entries.length>0&&e.jsxs(e.Fragment,{children:[Ie(Q.entries),e.jsx(bd,{page:b,pageSize:ti,total:Math.min(Q.total,rn),totalLabel:kn(Q.total),onPage:j})]}),!T&&y!=="all"&&Q&&Q.entries.length===0&&!z&&e.jsxs("div",{className:"bim-sr-empty",children:[u(W?d.emptyFiltered:it(c.search.noResultsFor,{query:n})),e.jsx("div",{children:e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>ee("all"),children:c.search.allTab})})]})]})]})};function Zo({on:t,onClick:n,children:o}){return e.jsx("button",{type:"button","aria-pressed":t,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:i(t?"ink":"meta-fg"),fontWeight:t?700:400,boxShadow:t?`inset 0 -2px 0 ${i("accent")}`:"none"},children:o})}const Mt="bim-recent-ids",Jo="bim-recent-entries",Xo=50;function jt(){try{const t=localStorage.getItem(Mt);if(t)return JSON.parse(t);const n=localStorage.getItem(Jo);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(Mt,JSON.stringify(o)),localStorage.removeItem(Jo),o}return[]}catch{return[]}}function bi(t){try{const n=jt().filter(o=>o!==t);n.unshift(t),n.length>Xo&&(n.length=Xo),localStorage.setItem(Mt,JSON.stringify(n))}catch{}}function Ns(t){try{const n=jt().filter(o=>o!==t);localStorage.setItem(Mt,JSON.stringify(n))}catch{}}function Gi(){try{localStorage.removeItem(Mt)}catch{}}async function Yi(t,n){var o,r,s;try{if(t.getEntry){const a=await t.getEntry(n);if(a)return a}const l=await t.getItem(n);if(l){const a=l.authors;return{id:n,title:l.title||n,type:l.type||"work",author:(o=a==null?void 0:a[0])==null?void 0:o.name,dynasty:(r=a==null?void 0:a[0])==null?void 0:r.dynasty,role:(s=a==null?void 0:a[0])==null?void 0:s.role,edition:l.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const ii=5,zd=50,Td=200,Qo={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},yi=({transport:t,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c,hideModeIndicator:d,resultVariant:u="compact",renderEntry:g,initialQuery:m,onQueryChange:h,headerRight:f,reserveViewportHeight:v=!1,filtersEnabled:y=!1,filters:w=An,onFiltersChange:b,resultTab:j,onResultTabChange:S})=>{const k=ve(),$=[{type:"work",name:k.indexType.work,key:"works"},{type:"book",name:k.indexType.book,key:"books"},{type:"collection",name:k.indexType.collection,key:"collections"},{type:"entity",name:k.indexType.entity,key:"entities"}],_=["work","collection","book","entity"],[z,E]=x.useState(m??""),[T,C]=x.useState(null),[O,W]=x.useState(m??""),P=_n(w).toString(),[Y,V]=x.useState(w);x.useEffect(()=>{V(w)},[P]);const Q=J=>{V(J),b==null||b(J)},[ge,A]=x.useState(null),[I,Z]=x.useState("all"),[ee,ce]=x.useState(!1),[fe,Ie]=x.useState(null),[q,M]=x.useState(""),[K,Re]=x.useState(!(m!=null&&m.trim())),[se,ye]=x.useState(jt),[We,Be]=x.useState([]),[Ee,Ce]=x.useState(!1),[He,D]=x.useState(!1),[re,de]=x.useState(null),[ke,F]=x.useState(null),he=x.useRef(void 0),Ne=x.useRef(!1),R=x.useCallback(async(J,Pe)=>{if(!J.trim()){Re(!0),C(null),A(null);return}if(Re(!1),y){W(J);return}ce(!0),M("");try{if(t.searchAll){const N=await t.searchAll(J,Pe??ii);C(N)}else{const N=["work","book","collection","entity"],X=await Promise.all(N.map(ae=>t.search(J,ae,{page:1,pageSize:Pe??ii})));C({works:X[0].entries,books:X[1].entries,collections:X[2].entries,entities:X[3].entries,totalWorks:X[0].total,totalBooks:X[1].total,totalCollections:X[2].total,totalEntities:X[3].total})}}catch(N){M(N instanceof Error?N.message:String(N)),C(null)}finally{ce(!1)}},[t,y]);x.useEffect(()=>{let J=!1;const Pe=()=>{var pe,$e;const N=["work","book","collection","entity"],X=Promise.all(N.map(H=>t.loadEntries(H,{page:1,pageSize:1}).catch(()=>({total:0})))),ae=((pe=t.getResourceCounts)==null?void 0:pe.call(t).catch(()=>null))??Promise.resolve(null),ie=(($e=t.getSubtypeStats)==null?void 0:$e.call(t).catch(()=>null))??Promise.resolve(null);Promise.all([X,ae,ie]).then(([H,B,be])=>{J||(de({works:H[0].total,books:H[1].total,collections:H[2].total,entities:H[3].total,hasText:B==null?void 0:B.hasText,hasImage:B==null?void 0:B.hasImage}),be&&F(be))})};return t.getCounts?t.getCounts().then(N=>{var X,ae;J||(de({works:N.works,books:N.books,collections:N.collections,entities:N.entities,hasText:(X=N.resourceCounts)==null?void 0:X.hasText,hasImage:(ae=N.resourceCounts)==null?void 0:ae.hasImage}),N.subtypeStats&&F(N.subtypeStats))}).catch(()=>{J||Pe()}):Pe(),()=>{J=!0}},[t]),x.useEffect(()=>{Ne.current||!(m!=null&&m.trim())||(Ne.current=!0,R(m))},[m,R]);const ne=x.useCallback(J=>{if(E(J),!J.trim()){h==null||h(J),Re(!0),C(null),A(null),Z("all");return}he.current&&clearTimeout(he.current),he.current=setTimeout(()=>{A(null),Z("all"),h==null||h(J),R(J)},Td)},[R,h]),ue=x.useCallback(J=>{he.current&&clearTimeout(he.current),Z("all"),h==null||h(J),R(J)},[R,h]),L=x.useCallback(J=>{A(J),R(z,zd)},[z,R]);x.useEffect(()=>{if(!se.length){Be([]);return}let J=!1;return Ce(!0),Promise.all(se.slice(0,10).map(Pe=>Yi(t,Pe))).then(Pe=>{J||(Be(Pe),Ce(!1))}),()=>{J=!0}},[se,t]);const te=J=>{Ie(J.id),bi(J.id),ye(jt()),r==null||r(J)},U=(J,Pe)=>{if(r&&Id(Pe)){Pe.preventDefault(),te(J);return}bi(J.id),ye(jt())},le=J=>{Ns(J),ye(jt())},we=()=>{Gi(),ye([])},Le=J=>$.find(Pe=>Pe.type===J),Se=!K&&!T&&!q,Fe=T&&(T.works.length>0||T.books.length>0||T.collections.length>0),De=e.jsxs(e.Fragment,{children:[e.jsx(js,{transport:t,value:z,onChange:ne,onSearch:ue,onEntrySelect:te}),y&&e.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const J=z.trim();J&&ys(J),ue(z)},children:k.searchPage.submit}),s&&e.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${i("primary")}`,borderRadius:"6px",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"13px"},children:k.action.newEntry})]});return e.jsxs("div",{className:"bim-browser-container",style:v?{minHeight:"100svh"}:void 0,children:[e.jsx("style",{children:Rd+(y?Ed:"")}),(!y||f||!d)&&e.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?e.jsx("span",{}):e.jsx("h1",{style:{margin:0,fontSize:"18px",color:i("fg")},children:k.browser.title}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,!d&&e.jsx(bs,{variant:"index-browser",indexSource:n,syncConfig:o,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c})]})]})}),y?e.jsxs("div",{className:"bim-ib-bar","data-nofilters":t.supportsSearchFilters?void 0:"true",children:[e.jsx("span",{"aria-hidden":"true"}),e.jsx("div",{className:"bim-ib-bar-main",children:De})]}):e.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:De}),K&&e.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:re&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:ke?e.jsxs(e.Fragment,{children:[(ke.book??0)>0&&e.jsxs(e.Fragment,{children:[k.searchPage.statBook," ",e.jsx("strong",{style:{color:i("fg")},children:ke.book.toLocaleString()})," ",k.unit.bu,k.searchPage.statComma,e.jsx("strong",{style:{color:i("fg")},children:re.books.toLocaleString()})," ",k.searchPage.statBookCopies]}),ke.article?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.searchPage.statArticle," ",e.jsx("strong",{style:{color:i("fg")},children:ke.article.toLocaleString()})," ",k.searchPage.statArticleUnit]}):null,ke.poem?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.searchPage.statPoem," ",e.jsx("strong",{style:{color:i("fg")},children:ke.poem.toLocaleString()})," ",k.searchPage.statPoemUnit]}):null,e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.searchPage.statCollection," ",e.jsx("strong",{style:{color:i("fg")},children:re.collections.toLocaleString()})]}):e.jsxs(e.Fragment,{children:[k.indexType.work," ",e.jsx("strong",{style:{color:i("fg")},children:re.works.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.indexType.book," ",e.jsx("strong",{style:{color:i("fg")},children:re.books.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.indexType.collection," ",e.jsx("strong",{style:{color:i("fg")},children:re.collections.toLocaleString()}),re.entities>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.indexType.entity," ",e.jsx("strong",{style:{color:i("fg")},children:re.entities.toLocaleString()})]})]})}),re.hasImage!=null&&re.hasText!=null&&e.jsxs("span",{children:[k.resourceType.image," ",e.jsx("strong",{style:{color:i("fg")},children:re.hasImage.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),k.resourceType.text," ",e.jsx("strong",{style:{color:i("fg")},children:re.hasText.toLocaleString()})]})]})}),y&&!K&&e.jsx(Ts,{transport:t,query:O,filters:Y,onFiltersChange:Q,onEntryLinkClick:U,typeName:J=>Le(J).name,tab:j,onTabChange:S}),!(y&&!K)&&e.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ee||Se?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:Nd,boxSizing:"border-box"},children:k.search.searching}):q?e.jsx("div",{style:{textAlign:"center",padding:"40px"},children:e.jsx("p",{style:{color:i("desc-fg")},children:q})}):K?e.jsx("div",{style:{flex:1},children:Ee?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:k.search.loading}):We.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{children:k.search.recentBrowse}),e.jsx("button",{onClick:we,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:k.search.clearRecent})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:We.slice(0,He?10:3).map(J=>J.notFound?e.jsx(Bd,{id:J.id,onRemove:le,t:k},J.id):e.jsx(er,{entry:J,selected:fe===J.id,onClick:U,getConfig:Le,onRemove:le},J.id))}),!He&&We.length>3&&e.jsx("button",{onClick:()=>D(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:k.action.expandMore})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:k.search.searchTitle}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:k.search.searchSubtitle})]})}):Fe?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsx("style",{children:Ld}),(()=>{const J=ie=>T[Qo[ie]]??0,Pe=_.map(ie=>$.find(pe=>pe.type===ie)).filter(ie=>J(ie.key)>0);if(Pe.length<2)return null;const N=Pe.reduce((ie,pe)=>ie+J(pe.key),0),X=ie=>{if(Z(ie),ie!=="all"&&ge!==ie){const pe=$.find(H=>H.type===ie),$e=(T[pe.key]??[]).length;J(pe.key)>$e&&L(ie)}},ae=ie=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(ie?"fg":"desc-fg"),fontWeight:ie?700:400,boxShadow:ie?`inset 0 -2px 0 ${i("primary")}`:"none"});return e.jsxs("div",{role:"group","aria-label":k.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs("button",{type:"button","aria-pressed":I==="all",style:ae(I==="all"),onClick:()=>X("all"),children:[k.search.allTab," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:N.toLocaleString()})]}),Pe.map(ie=>e.jsxs("button",{type:"button","aria-pressed":I===ie.type,style:ae(I===ie.type),onClick:()=>X(ie.type),children:[ie.name," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:J(ie.key).toLocaleString()})]},ie.type))]})})(),$.map(({type:J,name:Pe,key:N})=>{const X=T[N]??[],ae=Qo[N],ie=T[ae]??0;if(X.length===0||I!=="all"&&I!==J)return null;const $e=I==="all"&&!(ge===J)&&ie>ii;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[e.jsx(Gt,{type:J})," ",Pe,e.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[ie," ",k.unit.items]})]}),$e&&e.jsx("button",{className:"bim-ib-viewall",onClick:()=>L(J),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:k.action.viewAll})]}),e.jsx("div",{style:u==="list"?{display:"flex",flexDirection:"column",gap:0}:u==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:X.map(H=>{if(g)return e.jsx(x.Fragment,{children:g(H)},H.id);const B=u==="card"?Ad:er;return e.jsx(B,{entry:H,selected:fe===H.id,onClick:U,getConfig:Le,query:z},H.id)})})]},J)})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:it(k.search.noResultsFor,{query:z})}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:k.search.tryOther})]})})]})},Nd=240;function Id(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}const Rd=`
|
|
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
|
-
`,
|
|
123
|
+
`,Ed=`
|
|
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,26 +135,26 @@
|
|
|
135
135
|
.bim-ib-bar-main { max-width: none; }
|
|
136
136
|
.bim-ib-submit { min-height: 44px; padding: 0 16px; }
|
|
137
137
|
}
|
|
138
|
-
`,
|
|
138
|
+
`,Ld=`
|
|
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
|
-
}`,Cs={color:"inherit",textDecoration:"none"},$d=({snippet:t})=>{const{convert:n}=Te();return e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:Li(t).map((o,r)=>o.marked?e.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):e.jsx(x.Fragment,{children:n(o.text)},r))})},_d=({entry:t,selected:n,onClick:o,getConfig:r,query:s})=>{const l=ke(),{convert:a}=Te(),d=a(t.title||t.primary_name||t.id),c=t.measure_info?a(t.measure_info):t.juan_count!=null&&t.juan_count>0?`${t.juan_count}${l.unit.juan}`:"",p=[...t.additional_titles||[],...t.attached_texts||[]],u=s&&p.length?p.find(h=>{const f=typeof h=="string"?h:h==null?void 0:h.book_title;return f==null?void 0:f.toLowerCase().includes(s.toLowerCase())}):void 0,g=i("cover-accent"),m=Ve();return e.jsxs("a",{href:m(t.id),onClick:h=>o(t,h),className:"bim-result-card",style:{...Cs,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:i("bg"),border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[e.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${g} 50%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${g} 14%, ${i("bg")}), color-mix(in srgb, ${g} 7%, ${i("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[e.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${g} 45%, transparent)`}}),e.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:g},children:Array.from(d).map((h,f)=>e.jsx("span",{children:h},f))})]}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:d}),c&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg")},children:[t.dynasty&&e.jsxs("span",{children:["〔",a(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:a(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",a(t.role)]})]}),(t.era||t.edition)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[t.era&&e.jsxs("span",{children:["〔",a(t.era),"〕"]}),t.edition&&e.jsx("span",{children:a(t.edition)})]}),u&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[l.search.alias,":",a(typeof u=="string"?u:u.book_title||"")]}),t.descriptionSnippet&&e.jsx($d,{snippet:t.descriptionSnippet}),e.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[e.jsx(Dt,{type:t.type,size:8})," ",r(t.type).name]}),t.has_text&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.textResource}),t.has_image&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.imageResource})]})]})]})},Xo=({entry:t,selected:n,onClick:o,getConfig:r,query:s,onRemove:l})=>{const a=ke(),{convert:d}=Te(),c=[...t.additional_titles||[],...t.attached_texts||[]],p=s&&c.length?c.find(g=>{const m=typeof g=="string"?g:g==null?void 0:g.book_title;return m==null?void 0:m.toLowerCase().includes(s.toLowerCase())}):void 0,u=Ve();return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("a",{href:u(t.id),onClick:g=>o(t,g),className:"bim-result-card",style:{...Cs,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:l?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[e.jsx(Dt,{type:t.type,size:12}),e.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(t.type).name})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:d(t.title||t.primary_name||t.id)}),e.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[t.has_text&&e.jsx("span",{children:a.misc.textResource}),t.has_image&&e.jsx("span",{children:a.misc.imageResource})]}),(t.era||t.edition)&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.era&&e.jsxs(e.Fragment,{children:["〔",d(t.era),"〕"]}),t.edition&&d(t.edition)]}),t.measure_info?e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:d(t.measure_info)}):t.juan_count!=null&&t.juan_count>0?e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.juan_count,a.unit.juan]}):null]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px"},children:[t.dynasty&&e.jsxs("span",{children:["〔",d(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:d(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",d(t.role)]}),t.type==="entity"&&(t.birth_year!=null||t.death_year!=null)&&e.jsxs("span",{style:{marginLeft:t.dynasty?"4px":0},children:[t.birth_year??"?","—",t.death_year??"?"]})]}),p&&e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:[a.search.alias,":",d(p)]})]}),!l&&e.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),l&&e.jsx("button",{type:"button",onClick:()=>l(t.id),title:a.search.removeFromRecent,"aria-label":a.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},Cd=({id:t,onRemove:n,t:o})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${i("widget-border")}`,background:i("input-bg"),opacity:.6},children:[e.jsx("span",{style:{fontSize:"16px"},children:"❓"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"13px",color:i("fg"),fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),e.jsx("button",{onClick:()=>n(t),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function zd(t){var n;return!t.dynasty&&!t.birth_year&&!t.death_year&&(!t.alt_names||t.alt_names.length===0)&&!((n=t.description)!=null&&n.text)}function Td({data:t}){const{convert:n}=Te(),{dynasty:o,birth_year:r,death_year:s}=t,l=[];return o&&l.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?l.push(`${r}—${s}`):r!==void 0?l.push(`${r}—?`):s!==void 0&&l.push(`?—${s}`),l.length===0?null:e.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:l.join(" ")})}function Nd({alt_names:t}){const{convert:n}=Te(),o=new Map;for(const l of t){const a=l.type||"別名";o.has(a)||o.set(a,[]),o.get(a).push(l.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((l,a)=>{const d=r.indexOf(l),c=r.indexOf(a);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return e.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(l=>{const a=o.get(l);return e.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(l)}),e.jsx("span",{children:a.map((d,c)=>e.jsxs("span",{children:[c>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},l)})})}function Id({data:t}){const n=ke(),o=t.external_ids;if(!o)return null;const r=[];return o.cbdb_id&&r.push(e.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${o.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:i("link-fg"),border:`1px solid ${i("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${i("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",o.cbdb_id]},"cbdb")),r.length===0?null:e.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:r})}function Ed({works:t,transport:n,onNavigate:o,renderLink:r}){const s=ke(),{convert:l}=Te(),a=Ve(),[d,c]=x.useState(new Map);x.useEffect(()=>{if(!n)return;let m=!1;const h=t.map(v=>v.work_id);return(async()=>{const v=new Map;if(n.getEntriesByIds)try{const j=await n.getEntriesByIds(h);let w=!0;for(let S=0;S<h.length;S++){const $=j[S];$!=null&&$.title?v.set(h[S],$.title):$!=null&&$.primary_name?v.set(h[S],$.primary_name):w=!1}if(w)return v}catch{}const y=[...h],k=8,b=new Array(k).fill(0).map(async()=>{for(;y.length;){const j=y.shift();if(!j)break;if(!v.has(j))try{if(n.getEntry){const $=await n.getEntry(j);if($!=null&&$.title){v.set(j,$.title);continue}}const w=await n.getItem(j),S=w&&(w.title||w.primary_name)||j;v.set(j,S)}catch{v.set(j,j)}}});return await Promise.all(b),v})().then(v=>{m||c(v)}),()=>{m=!0}},[t,n]);const p=new Map;for(const m of t){const h=m.role||"";p.has(h)||p.set(h,[]),p.get(h).push(m)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],g=[...p.keys()].sort((m,h)=>{const f=u.indexOf(m),v=u.indexOf(h);return f===-1&&v===-1?m.localeCompare(h):f===-1?1:v===-1?-1:f-v});return e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:i("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[s.label.relatedWorks," ",e.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",t.length,")"]})]}),g.map(m=>{const h=p.get(m);return e.jsxs("div",{style:{marginBottom:"8px"},children:[m&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[l(m)," ",e.jsxs("span",{style:{color:i("desc-fg")},children:["(",h.length,")"]})]}),e.jsx("ul",{style:{margin:0,paddingLeft:m?"16px":"0",listStyle:m?"disc":"none",fontSize:"14px",lineHeight:1.8},children:h.map((f,v)=>{const y=l(d.get(f.work_id)||f.work_id);return r?e.jsx("li",{children:r(f.work_id,y)},v):o?e.jsx("li",{children:e.jsx("a",{href:a(f.work_id),onClick:k=>{k.metaKey||k.ctrlKey||(k.preventDefault(),o(f.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},v):e.jsx("li",{children:y},v)})})]},m)})]})}const zs=({data:t,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:l})=>{var g;const a=ke(),{convert:d}=Te();let c=!1;try{c=he.extractStatus(t.id)==="draft"}catch{}const p=zd(t),u=t.subtype&&t.subtype in a.common.entitySubtype?a.common.entitySubtype[t.subtype]:d(t.subtype);return e.jsxs("div",{children:[!l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[e.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:i("fg")},children:[d(t.primary_name),e.jsx(Td,{data:t})]}),s]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:i("type-entity"),border:`1px solid color-mix(in srgb, ${i("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${i("type-entity")} 3%, transparent)`},children:a.indexType.entity}),u&&t.subtype!=="people"&&e.jsx("span",{children:u}),c&&e.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("warn-fg")},children:a.status.draft}),e.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:t.id})]})]}),p&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:i("widget-bg"),border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:a.common.entityPlaceholderNote}),t.alt_names&&t.alt_names.length>0&&e.jsx(Nd,{alt_names:t.alt_names}),e.jsx(Id,{data:t}),((g=t.description)==null?void 0:g.text)&&e.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(t.description.text)}),t.works&&t.works.length>0&&e.jsx(Ed,{works:t.works,transport:n,onNavigate:o,renderLink:r})]})},Rd=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Ld(t){const n=t.search(Rd);return n<0?[t,""]:[t.slice(0,n),t.slice(n)]}const Ts={p:({children:t})=>e.jsx("p",{style:{margin:"0 0 0.5em"},children:t}),ul:({children:t})=>e.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:t}),ol:({children:t})=>e.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:t}),li:({children:t})=>e.jsx("li",{style:{marginBottom:"2px"},children:t}),a:({href:t,children:n})=>{let o=t,r="",s=n;if(t&&typeof n=="string"&&(n===t||n===Pd(t))){const[l,a]=Ld(n);a&&(o=encodeURI(l),s=l,r=a)}return e.jsxs(e.Fragment,{children:[e.jsx("a",{href:o,target:o!=null&&o.startsWith("http")?"_blank":void 0,rel:o!=null&&o.startsWith("http")?"noopener noreferrer":void 0,style:{color:i("link")},children:s}),r]})},code:({children:t})=>e.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:t})};function Pd(t){try{return decodeURI(t)}catch{return t}}const Ad={...Ts,strong:({children:t})=>e.jsx(e.Fragment,{children:t})},ht=({text:t,plainStrong:n,style:o,className:r})=>{const{convert:s}=Te(),l=n?Ad:Ts;return e.jsx("div",{className:r,style:o,children:e.jsx(pc,{remarkPlugins:[uc],components:l,children:s(t)})})},Bd=["〇","一","二","三","四","五","六","七","八","九"],Qo=["","十","百","千"];function Ns(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),d=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&d===1&&l===0?r+=Qo[d]:r+=Bd[a]+Qo[d])}return r}function Is(t){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:t,border:`1px solid color-mix(in srgb, ${t} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${t} 3%, transparent)`}}const Md={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function Wd({type:t}){const n=ke();return e.jsx("span",{style:Is(Md[t]),children:n.indexType[t]})}function Hd({isDraft:t}){const n=ke(),o=i(t?"status-draft":"status-official");return e.jsx("span",{style:Is(o),children:t?n.status.draft:n.status.official})}function Od({id:t}){const n=ke(),[o,r]=x.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:i("desc-fg"),background:i("bg-subtle"),border:`1px solid ${i("widget-border")}`,borderRadius:"2px"},children:[e.jsx("span",{children:n.label.id}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:t}),e.jsx("span",{onClick:s,title:o?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:o?1:.5,transition:"opacity 0.15s"},onMouseEnter:l=>l.currentTarget.style.opacity="1",onMouseLeave:l=>l.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function ot({children:t,extra:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("desc-fg"),letterSpacing:"1px"},children:t}),e.jsx("span",{style:{flex:1}}),n]})}function ct({label:t,children:n}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:t}),e.jsx("span",{style:{color:i("fg")},children:n})]})}function Es({authors:t,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Te();return e.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:t.map((l,a)=>{const d=s(l.name),c=l.entity_id?e.jsx(lt,{id:l.entity_id,label:d,onNavigate:o,renderLink:r}):e.jsx("span",{style:{fontWeight:500},children:d});return e.jsxs("span",{children:[a>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),l.dynasty&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(l.dynasty),"〕"]}),c,l.role&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(l.role)]})]},a)})})}function lt({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ve();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{children:n||t})}function Fd({id:t,title:n,edition:o,type:r,isDraft:s,authors:l,volumeText:a,meta:d,headerExtra:c,onNavigate:p,renderLink:u}){return e.jsxs("div",{style:{marginBottom:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[e.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:i("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,o&&e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),a&&e.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:a})]}),c&&e.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[e.jsx(Wd,{type:r}),e.jsx(Hd,{isDraft:s}),e.jsx(Od,{id:t})]}),((l==null?void 0:l.length)||d.length>0)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[l&&l.length>0&&e.jsx(Es,{authors:l,type:r,onNavigate:p,renderLink:u}),d]})]})}function Rs({items:t,label:n,showMeta:o,onNavigate:r,renderLink:s}){const l=ke(),{convert:a}=Te();if(!t.length)return null;const[d,c]=x.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:n}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map((p,u)=>{const g=d===u;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...g?{boxShadow:i("shadow-card")}:{}},children:[e.jsxs("div",{onClick:()=>c(g?null:u),style:{padding:"8px 12px",background:i("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(p.source)}),!g&&o&&p.title_info&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a(p.title_info)}),p.source_bid&&e.jsx("span",{onClick:m=>m.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:e.jsx(lt,{id:p.source_bid,label:l.action.view,onNavigate:r,renderLink:s})})]}),g&&e.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(p.title_info||p.author_info||p.edition)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&e.jsx(ct,{label:l.label.titleInfo,children:a(p.title_info)}),p.author_info&&e.jsx(ct,{label:l.label.authorInfo,children:a(p.author_info)}),p.edition&&e.jsx(ct,{label:l.label.edition,children:a(p.edition)})]}),p.summary&&e.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.summary}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:a(p.summary)})]}),p.comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.comment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(p.comment)})]}),p.additional_comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.additionalComment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(p.additional_comment)})]})]})]},u)})})]})}function Dd({items:t,onNavigate:n,renderLink:o}){const r=ke();return e.jsx(Rs,{items:t,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function Ls({items:t,onNavigate:n,renderLink:o}){const r=ke();return e.jsx(Rs,{items:t,label:r.section.emendated,onNavigate:n,renderLink:o})}function Ps({label:t,items:n}){const{convert:o}=Te();return n.length?e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:t}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const l=typeof r=="string"?r:r.book_title;return e.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:o(l)},s)})})]}):null}function Ud({items:t}){const n=ke();return e.jsx(Ps,{label:n.section.aliases,items:t})}function Vd({items:t}){const n=ke();return e.jsx(Ps,{label:n.section.attachedTexts,items:t})}function Gd({items:t}){const n=ke(),{convert:o}=Te();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:n.section.appendix}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((r,s)=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:["《",o(r.book_title),"》",r.n_juan!=null&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function Yd({items:t}){const n=ke(),{convert:o}=Te();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:n.section.locationHistory}),e.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[e.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:i("widget-border")}}),t.map((r,s)=>e.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[e.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:i("primary"),border:`1.5px solid ${i("input-bg")}`}}),e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function Kd({items:t}){const n=ke(),{convert:o}=Te();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:n.section.historyOverview}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map((r,s)=>e.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[e.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function er({title:t,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:l}=Te(),[a,d]=x.useState([]);return x.useEffect(()=>{if(!n.length){d([]);return}if(!o){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>o.getItem(p).then(u=>({id:p,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,o]),n.length?e.jsxs(e.Fragment,{children:[e.jsxs(ot,{children:[t,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(a.length?a:n.map(c=>({id:c}))).map(c=>{const p=c.edition?`${l(c.title)||c.id}(${l(c.edition)})`:l(c.title)||void 0;return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),transition:"border-color 0.15s"},children:e.jsx(lt,{id:c.id,label:p,onNavigate:r,renderLink:s})},c.id)})})]}):null}function ti({book:t,onNavigate:n,renderLink:o}){const r=ke(),{convert:s}=Te(),[l,a]=x.useState(!1),d=t.resources&&t.resources.length>0,c=t.edition?s(t.edition):s(t.title)||void 0;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[e.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:e.jsx(lt,{id:t.id,label:c,onNavigate:n,renderLink:o})}),d&&e.jsx("span",{onClick:()=>a(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:l?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:l?r.action.expand:r.action.collapse,children:"▼"})]}),d&&!l&&e.jsx("div",{style:{padding:"10px 14px"},children:e.jsx(Hi,{items:t.resources,resourceGroups:t.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function qd({ids:t,workData:n,transport:o,onNavigate:r,renderLink:s,footer:l}){const a=ke(),{convert:d}=Te(),[c,p]=x.useState([]);if(x.useEffect(()=>{if(!t.length){p([]);return}if(!o){p(t.map(v=>({id:v})));return}let f=!1;return Promise.all(t.map(v=>o.getItem(v).then(y=>({id:v,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:v})))).then(v=>{f||p(v)}),()=>{f=!0}},[t,o]),!t.length)return null;const u=c.length?c:t.map(f=>({id:f})),g=new Map(u.map(f=>[f.id,f])),m=n==null?void 0:n.version_graph,h=Zd(t,m,a.common.otherVersions);return e.jsxs(e.Fragment,{children:[e.jsxs(ot,{children:[a.section.relatedVersions,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",t.length,")"]})]}),l,h.useGrouping?e.jsxs(e.Fragment,{children:[h.coreIds.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.coreIds.map(f=>{const v=g.get(f);return v?e.jsx(ti,{book:v,onNavigate:r,renderLink:s},f):null})}),h.groupedIds.map(f=>e.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[d(f.label),e.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",f.ids.length,")"]}),f.description&&e.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:d(f.description)})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:f.ids.map(v=>{const y=g.get(v);return y?e.jsx(ti,{book:y,onNavigate:r,renderLink:s},v):null})})]},f.id))]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(f=>e.jsx(ti,{book:f,onNavigate:r,renderLink:s},f.id))})]})}function Zd(t,n,o){var k,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,groupedIds:[]};const r=(k=n.collections)==null?void 0:k[n.default_collection],s=(r==null?void 0:r.groups)??[],l=(r==null?void 0:r.book_ids)??[],a=s.length>0||l.length>0,d=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&d.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const c=new Set(s),p=new Set([...l,...d]),u=j=>{if(p.has(j))return!0;const w=n.node_groups[j];return w!=null&&c.has(w)},g=[],m=new Map,h=[];for(const j of t)if(!((b=n.excluded_books)!=null&&b.includes(j)))if(u(j))g.push(j);else{const w=n.node_groups[j];w?(m.has(w)||m.set(w,[]),m.get(w).push(j)):h.push(j)}if(h.length+[...m.values()].reduce((j,w)=>j+w.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const v=new Map((n.groups??[]).map(j=>[j.id,j])),y=[...m.entries()].map(([j,w])=>{const S=v.get(j);return{id:j,label:(S==null?void 0:S.label)??j,description:S==null?void 0:S.description,ids:w}});return h.length>0&&y.push({id:"__other__",label:o,description:void 0,ids:h}),{useGrouping:!0,coreIds:g,groupedIds:y}}function Jd({workData:t,onNavigate:n,renderLink:o}){var a,d,c,p;const r=ke(),{convert:s}=Te(),l=!!((a=t.description)!=null&&a.text)||!!t.parent_work;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[e.jsxs("div",{style:{padding:"6px 14px",borderBottom:l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:e.jsx(lt,{id:t.id,label:s(t.title),onNavigate:n,renderLink:o})}),t.measure_info?e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:s(t.measure_info)}):((d=t.juan_count)==null?void 0:d.number)!=null&&t.juan_count.number>0?e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[Ns(t.juan_count.number),r.unit.juan]}):null,t.authors&&t.authors.length>0&&e.jsx("span",{style:{fontSize:"13px"},children:e.jsx(Es,{authors:t.authors,type:"work",onNavigate:n,renderLink:o})})]}),l&&e.jsxs("div",{style:{padding:"8px 14px"},children:[((c=t.description)==null?void 0:c.text)&&e.jsx(ht,{text:t.description.text,style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,textAlign:"justify"}}),t.parent_work&&e.jsx("div",{style:{marginTop:(p=t.description)!=null&&p.text?"8px":0,fontSize:"13px"},children:e.jsx(ct,{label:r.label.parentWork,children:e.jsx(lt,{id:t.parent_work.id,label:s(t.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function Xd({items:t,onNavigate:n,renderLink:o}){const r=ke(),{convert:s}=Te();return t.length?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:t.map(l=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${i("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${i("type-collection")} 3%, transparent)`},children:[e.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),e.jsx(lt,{id:l.id,label:s(l.title)||l.id,onNavigate:n,renderLink:o}),l.volume_index!=null&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:tt(r.catalog.volume,{n:l.volume_index})})]},l.id))}):null}const Ui=({data:t,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:l,relatedBooksFooter:a,className:d,style:c})=>{var H,W,A,Y,G,te,pe,B;const p=ke(),{convert:u}=Te(),[g,m]=x.useState(null),[h,f]=x.useState(!1),[v,y]=x.useState(null),[k,b]=x.useState(null),[j,w]=x.useState([]),S=t||g;if(x.useEffect(()=>{if(t||!n||!o)return;let E=!1;return f(!0),y(null),o.getItem(n).then(ee=>{E||(ee?m(ee):y(p.misc.notFoundEntry))}).catch(ee=>{E||y(ee instanceof Error?ee.message:p.misc.loadFailed)}).finally(()=>{E||f(!1)}),()=>{E=!0}},[t,n,o]),x.useEffect(()=>{if(!S||!o){b(null),w([]);return}let E=!1;const ee=S.type==="book"||S.type==="collection"?S.work_id:void 0;if(ee?o.getItem(ee).then(L=>{!E&&L&&L.type==="work"&&b(L)}).catch(()=>{}):b(null),S.type==="book"){const L=S;L.contained_in&&L.contained_in.length>0?Promise.all(L.contained_in.map(U=>{const de=typeof U=="string"?U:U.id,ve=typeof U=="string"?void 0:U.volume_index;return o.getItem(de).then(Z=>({id:de,title:Z&&Z.title||de,volume_index:ve})).catch(()=>({id:de,title:de,volume_index:ve}))})).then(U=>{E||w(U)}):w([])}else w([]);return()=>{E=!0}},[S,o]),h)return e.jsx("div",{className:d,style:{...c,padding:"24px"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((E,ee)=>e.jsx("div",{style:{height:ee===1?"32px":"16px",width:`${E}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},ee))})});if(v)return e.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:v});if(!S)return null;if(S.type==="entity")return e.jsx("div",{className:d,style:c,children:e.jsx(zs,{data:S,transport:o,onNavigate:r,renderLink:s,headerExtra:l})});const $=S.type==="book"?S:null,_=S.type==="collection"?S:null,C=S.type==="work"?S:null;let I=!1;try{I=he.extractStatus(S.id)==="draft"}catch{}let T="";S.measure_info?T=u(S.measure_info):(H=S.juan_count)!=null&&H.number?T=Ns(S.juan_count.number)+p.unit.juan:(W=S.juan_count)!=null&&W.description&&(T=u(S.juan_count.description));const z=[];return(A=S.publication_info)!=null&&A.year&&z.push(e.jsx(ct,{label:p.label.year,children:S.publication_info.year},"year")),(Y=S.current_location)!=null&&Y.name&&z.push(e.jsx(ct,{label:p.label.currentLocation,children:u(S.current_location.name)},"loc")),(G=S.page_count)!=null&&G.description&&z.push(e.jsx(ct,{label:p.label.pageCount,children:S.page_count.description},"page")),$!=null&&$.edition&&z.push(e.jsx(ct,{label:p.label.edition,children:u($.edition)},"ver")),C!=null&&C.parent_work&&z.push(e.jsx(ct,{label:p.label.parentWork,children:e.jsx(lt,{id:C.parent_work.id,label:u(C.parent_work.title),onNavigate:r,renderLink:s})},"pw")),C!=null&&C.parent_works&&C.parent_works.length>0&&!C.parent_work&&z.push(e.jsx(ct,{label:p.label.parentWork,children:C.parent_works.map((E,ee)=>e.jsxs("span",{children:[ee>0&&"、",e.jsx(lt,{id:E,onNavigate:r,renderLink:s})]},E))},"pws")),e.jsxs("div",{className:d,style:c,children:[e.jsx(Fd,{id:S.id,title:u(S.title),edition:S.edition?u(S.edition):void 0,type:S.type,isDraft:I,authors:S.authors,volumeText:T,meta:z,headerExtra:l,onNavigate:r,renderLink:s}),((te=S.description)==null?void 0:te.text)&&e.jsx(ht,{text:S.description.text,style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),S.appendix&&S.appendix.length>0&&e.jsx("div",{style:{marginTop:8,marginBottom:4},children:S.appendix.map((E,ee)=>e.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(E.title)}),e.jsx(ht,{text:E.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},ee))}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:p.section.containedIn}),e.jsx(Xd,{items:j,onNavigate:r,renderLink:s})]}),k&&e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:p.section.belongsToWork}),e.jsx(Jd,{workData:k,onNavigate:r,renderLink:s})]}),S.additional_works&&S.additional_works.length>0&&e.jsx(Gd,{items:S.additional_works}),S.additional_titles&&S.additional_titles.length>0&&e.jsx(Ud,{items:S.additional_titles}),S.attached_texts&&S.attached_texts.length>0&&e.jsx(Vd,{items:S.attached_texts}),S.indexed_by&&S.indexed_by.length>0&&e.jsx(Dd,{items:S.indexed_by,onNavigate:r,renderLink:s}),S.emendated_by&&S.emendated_by.length>0&&e.jsx(Ls,{items:S.emendated_by,onNavigate:r,renderLink:s}),S.resources&&S.resources.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:p.section.resources}),e.jsx(Hi,{items:S.resources,resourceGroups:S.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&e.jsx(Yd,{items:$.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&e.jsx(Kd,{items:_.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&e.jsx(er,{title:p.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&e.jsx(er,{title:p.section.containedBooks,ids:_.books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.contained_works)&&_.contained_works.length>0&&e.jsxs("div",{children:[e.jsxs(ot,{children:[p.section.containedWorks,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",_.contained_works.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.contained_works.map(E=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:e.jsx(lt,{id:E.id,label:u(E.title),onNavigate:r,renderLink:s})},E.id))})]}),(((pe=C==null?void 0:C.books)==null?void 0:pe.length)||0)+(((B=C==null?void 0:C.collections)==null?void 0:B.length)||0)>0&&e.jsx(qd,{ids:[...(C==null?void 0:C.books)||[],...(C==null?void 0:C.collections)||[]],workData:C??void 0,transport:o,onNavigate:r,renderLink:s,footer:a}),(C==null?void 0:C.related_works)&&C.related_works.length>0&&(()=>{const E=[],ee=C.related_works.filter(ce=>ce.relation==="part_of"),L=C.related_works.filter(ce=>ce.relation==="has_part"),U=C.related_works.filter(ce=>ce.relation==="has_adaptation"),de=C.related_works.filter(ce=>ce.relation==="text_carried_by"),ve=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),Z=C.related_works.filter(ce=>!ce.relation||!ve.has(ce.relation));return ee.length>0&&E.push({label:p.section.belongsToWork,items:ee}),L.length>0&&E.push({label:p.section.containedWorks,items:L}),U.length>0&&E.push({label:p.section.adaptations,items:U}),de.length>0&&E.push({label:p.section.derivativeWorks,items:de}),Z.length>0&&E.push({label:p.section.relatedWorks,items:Z}),E.map(ce=>e.jsxs("div",{children:[e.jsxs(ot,{children:[ce.label,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",ce.items.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ce.items.map(be=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:e.jsx(lt,{id:be.id,label:u(be.title),onNavigate:r,renderLink:s})},be.id))})]},ce.label))})()]})};function Qd({data:t}){const n=ke(),{convert:o}=Te(),{stats:r}=t,s=r.processed_volumes??r.total_found_volumes,l=s!=null&&t.total_volumes>0?Math.round(s/t.total_volumes*100):null;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:o(t.title)}),t.resource_name&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(t.resource_name)}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[e.jsxs("span",{children:[n.catalog.totalVolumes," ",e.jsx("strong",{style:{color:i("fg")},children:t.total_volumes})," ",n.unit.volume]}),l!=null&&e.jsxs("span",{children:[n.catalog.processed," ",e.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",l,"%)"]}),e.jsxs("span",{children:[n.catalog.contains," ",e.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&e.jsxs("span",{children:[n.catalog.matched," ",e.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&e.jsxs("span",{children:[n.catalog.unmatched," ",e.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),t.source&&e.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",t.source]})]})}function ep({sections:t,activeSection:n,onSelect:o}){const r=ke();return e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[e.jsx("button",{onClick:()=>o(null),style:tr(n===null),children:r.catalog.all}),t.map(s=>e.jsxs("button",{onClick:()=>o(s.name),style:tr(n===s.name),children:[s.name,s.volume_range&&e.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function tr(t){return{padding:"4px 12px",border:t?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:t?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(t?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}function tp({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ve();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:n||t})}function np(t,n){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=t[0],r=t[t.length-1];return r-o+1===t.length?`${o}–${r}`:t.length<=3?t.join(", "):`${o}–${r} (${t.length}${n})`}function nr({book:t,onNavigate:n,renderLink:o,showVolumes:r}){const s=ke(),{convert:l}=Te(),a=t.book_id||t.work_id,d=r&&t.volumes.length>0?np(t.volumes,s.unit.volume):null,c=t.missing_volumes&&t.missing_volumes.length>0;return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${i("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[r&&e.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:d}),e.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[l(t.title),t.sub_items&&t.sub_items.length>0&&e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",t.sub_items.map(p=>l(p)).join("、"),")"]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:l(t.edition)})]}),t.expected_volumes!=null&&e.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[t.found_volumes??0,"/",t.expected_volumes,s.unit.volume]}),a&&e.jsx(tp,{id:a,label:t.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!a&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const Vi=({data:t,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:l,style:a})=>{const d=ke(),[c,p]=x.useState(null),[u,g]=x.useState(!1),[m,h]=x.useState(null),[f,v]=x.useState(null),[y,k]=x.useState(""),b=t||c;x.useEffect(()=>{if(t||!n||!(o!=null&&o.getCollectionCatalog))return;let _=!1;return g(!0),h(null),o.getCollectionCatalog(n).then(C=>{_||(C?p(C):h(d.catalog.notFound))}).catch(C=>{_||h(C instanceof Error?C.message:d.catalog.loadFailed)}).finally(()=>{_||g(!1)}),()=>{_=!0}},[t,n,o,d]);const j=(b==null?void 0:b.sections)&&b.sections.length>0,w=x.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(I=>I.volumes[0]).filter(I=>I!=null);return new Set(_).size<_.length},[b]),S=x.useMemo(()=>{if(!b)return[];let _=b.books;if(f&&(_=_.filter(C=>C.section===f)),y.trim()){const C=y.trim().toLowerCase();_=_.filter(I=>I.title.toLowerCase().includes(C)||I.sub_items&&I.sub_items.some(T=>T.toLowerCase().includes(C))||I.edition&&I.edition.toLowerCase().includes(C))}return _},[b,f,y]),$=x.useMemo(()=>{if(!w)return null;const _=[],C=new Map;for(const T of S){if(!T.volumes||T.volumes.length===0)continue;const z=T.volumes[0];C.has(z)||C.set(z,[]),C.get(z).push(T)}const I=[...C.keys()].sort((T,z)=>T-z);for(const T of I)_.push({volume:T,books:C.get(T)});return _},[S,w]);return u?e.jsx("div",{className:l,style:{...a,padding:"24px"},children:e.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):m?e.jsx("div",{className:l,style:{...a,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:m}):b?e.jsxs("div",{className:l,style:a,children:[e.jsx(Qd,{data:b}),j&&e.jsx(ep,{sections:b.sections,activeSection:f,onSelect:v}),e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:_=>k(_.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),e.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[S.length," ",d.unit.bu]})]}),e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((_,C)=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"4px 12px",background:i("bg"),borderBottom:`1px solid ${i("widget-border")}`,fontSize:"12px",fontWeight:600,color:i("desc-fg"),position:"sticky",top:0,zIndex:1},children:tt(d.catalog.volume,{n:_.volume})}),_.books.map((I,T)=>e.jsx(nr,{book:I,onNavigate:r,renderLink:s,showVolumes:I.volumes.length>1},`${_.volume}-${T}`))]},`${_.volume}-${C}`)):S.map((_,C)=>e.jsx(nr,{book:_,onNavigate:r,renderLink:s,showVolumes:!0},C)),S.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},ip="guji_markdown";function xi(t){const n=t==null?void 0:t.guji_markdown;if(typeof n!="string")return!1;const o=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!o)return!1;const r=parseInt(o[1],10),s=parseInt(o[2],10);return r>0||s>=2}const op=/^□\{guess=([^\s{}]+)\}/;function rp(t,n){const o=t[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function As(t,n){let o=0;for(let r=n;r<t.length;r++){const s=t[r];if(s===`
|
|
146
|
-
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function
|
|
147
|
-
`)<0?{node:{type:"qw",label:t.slice(n+2,r)},end:r+2}:null}if(o===":"&&t.startsWith(":zi[",n)){const r=
|
|
148
|
-
`)return null}const c=
|
|
145
|
+
}`,Is={color:"inherit",textDecoration:"none"},Pd=({snippet:t})=>{const{convert:n}=Te();return e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:Mi(t).map((o,r)=>o.marked?e.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):e.jsx(x.Fragment,{children:n(o.text)},r))})},Ad=({entry:t,selected:n,onClick:o,getConfig:r,query:s})=>{const l=ve(),{convert:a}=Te(),p=a(t.title||t.primary_name||t.id),c=t.measure_info?a(t.measure_info):t.juan_count!=null&&t.juan_count>0?`${t.juan_count}${l.unit.juan}`:"",d=[...t.additional_titles||[],...t.attached_texts||[]],u=s&&d.length?d.find(h=>{const f=typeof h=="string"?h:h==null?void 0:h.book_title;return f==null?void 0:f.toLowerCase().includes(s.toLowerCase())}):void 0,g=i("cover-accent"),m=Ye();return e.jsxs("a",{href:m(t.id),onClick:h=>o(t,h),className:"bim-result-card",style:{...Is,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:i("bg"),border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[e.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${g} 50%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${g} 14%, ${i("bg")}), color-mix(in srgb, ${g} 7%, ${i("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[e.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${g} 45%, transparent)`}}),e.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:g},children:Array.from(p).map((h,f)=>e.jsx("span",{children:h},f))})]}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:p}),c&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg")},children:[t.dynasty&&e.jsxs("span",{children:["〔",a(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:a(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",a(t.role)]})]}),(t.era||t.edition)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[t.era&&e.jsxs("span",{children:["〔",a(t.era),"〕"]}),t.edition&&e.jsx("span",{children:a(t.edition)})]}),u&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[l.search.alias,":",a(typeof u=="string"?u:u.book_title||"")]}),t.descriptionSnippet&&e.jsx(Pd,{snippet:t.descriptionSnippet}),e.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[e.jsx(Gt,{type:t.type,size:8})," ",r(t.type).name]}),t.has_text&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.textResource}),t.has_image&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.imageResource})]})]})]})},er=({entry:t,selected:n,onClick:o,getConfig:r,query:s,onRemove:l})=>{const a=ve(),{convert:p}=Te(),c=[...t.additional_titles||[],...t.attached_texts||[]],d=s&&c.length?c.find(g=>{const m=typeof g=="string"?g:g==null?void 0:g.book_title;return m==null?void 0:m.toLowerCase().includes(s.toLowerCase())}):void 0,u=Ye();return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("a",{href:u(t.id),onClick:g=>o(t,g),className:"bim-result-card",style:{...Is,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:l?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[e.jsx(Gt,{type:t.type,size:12}),e.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(t.type).name})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:p(t.title||t.primary_name||t.id)}),e.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[t.has_text&&e.jsx("span",{children:a.misc.textResource}),t.has_image&&e.jsx("span",{children:a.misc.imageResource})]}),(t.era||t.edition)&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.era&&e.jsxs(e.Fragment,{children:["〔",p(t.era),"〕"]}),t.edition&&p(t.edition)]}),t.measure_info?e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:p(t.measure_info)}):t.juan_count!=null&&t.juan_count>0?e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.juan_count,a.unit.juan]}):null]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px"},children:[t.dynasty&&e.jsxs("span",{children:["〔",p(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:p(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",p(t.role)]}),t.type==="entity"&&(t.birth_year!=null||t.death_year!=null)&&e.jsxs("span",{style:{marginLeft:t.dynasty?"4px":0},children:[t.birth_year??"?","—",t.death_year??"?"]})]}),d&&e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:[a.search.alias,":",p(d)]})]}),!l&&e.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),l&&e.jsx("button",{type:"button",onClick:()=>l(t.id),title:a.search.removeFromRecent,"aria-label":a.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},Bd=({id:t,onRemove:n,t:o})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${i("widget-border")}`,background:i("input-bg"),opacity:.6},children:[e.jsx("span",{style:{fontSize:"16px"},children:"❓"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"13px",color:i("fg"),fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),e.jsx("button",{onClick:()=>n(t),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function Md(t){var n;return!t.dynasty&&!t.birth_year&&!t.death_year&&(!t.alt_names||t.alt_names.length===0)&&!((n=t.description)!=null&&n.text)}function Wd({data:t}){const{convert:n}=Te(),{dynasty:o,birth_year:r,death_year:s}=t,l=[];return o&&l.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?l.push(`${r}—${s}`):r!==void 0?l.push(`${r}—?`):s!==void 0&&l.push(`?—${s}`),l.length===0?null:e.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:l.join(" ")})}function Hd({alt_names:t}){const{convert:n}=Te(),o=new Map;for(const l of t){const a=l.type||"別名";o.has(a)||o.set(a,[]),o.get(a).push(l.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((l,a)=>{const p=r.indexOf(l),c=r.indexOf(a);return p===-1&&c===-1?0:p===-1?1:c===-1?-1:p-c});return e.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(l=>{const a=o.get(l);return e.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(l)}),e.jsx("span",{children:a.map((p,c)=>e.jsxs("span",{children:[c>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),n(p)]},c))})]},l)})})}function Od({data:t}){const n=ve(),o=t.external_ids;if(!o)return null;const r=[];return o.cbdb_id&&r.push(e.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${o.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:i("link-fg"),border:`1px solid ${i("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${i("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",o.cbdb_id]},"cbdb")),r.length===0?null:e.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:r})}function Fd({works:t,transport:n,onNavigate:o,renderLink:r}){const s=ve(),{convert:l}=Te(),a=Ye(),[p,c]=x.useState(new Map);x.useEffect(()=>{if(!n)return;let m=!1;const h=t.map(v=>v.work_id);return(async()=>{const v=new Map;if(n.getEntriesByIds)try{const j=await n.getEntriesByIds(h);let S=!0;for(let k=0;k<h.length;k++){const $=j[k];$!=null&&$.title?v.set(h[k],$.title):$!=null&&$.primary_name?v.set(h[k],$.primary_name):S=!1}if(S)return v}catch{}const y=[...h],w=8,b=new Array(w).fill(0).map(async()=>{for(;y.length;){const j=y.shift();if(!j)break;if(!v.has(j))try{if(n.getEntry){const $=await n.getEntry(j);if($!=null&&$.title){v.set(j,$.title);continue}}const S=await n.getItem(j),k=S&&(S.title||S.primary_name)||j;v.set(j,k)}catch{v.set(j,j)}}});return await Promise.all(b),v})().then(v=>{m||c(v)}),()=>{m=!0}},[t,n]);const d=new Map;for(const m of t){const h=m.role||"";d.has(h)||d.set(h,[]),d.get(h).push(m)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],g=[...d.keys()].sort((m,h)=>{const f=u.indexOf(m),v=u.indexOf(h);return f===-1&&v===-1?m.localeCompare(h):f===-1?1:v===-1?-1:f-v});return e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:i("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[s.label.relatedWorks," ",e.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",t.length,")"]})]}),g.map(m=>{const h=d.get(m);return e.jsxs("div",{style:{marginBottom:"8px"},children:[m&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[l(m)," ",e.jsxs("span",{style:{color:i("desc-fg")},children:["(",h.length,")"]})]}),e.jsx("ul",{style:{margin:0,paddingLeft:m?"16px":"0",listStyle:m?"disc":"none",fontSize:"14px",lineHeight:1.8},children:h.map((f,v)=>{const y=l(p.get(f.work_id)||f.work_id);return r?e.jsx("li",{children:r(f.work_id,y)},v):o?e.jsx("li",{children:e.jsx("a",{href:a(f.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),o(f.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},v):e.jsx("li",{children:y},v)})})]},m)})]})}const Rs=({data:t,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:l})=>{var g;const a=ve(),{convert:p}=Te();let c=!1;try{c=xe.extractStatus(t.id)==="draft"}catch{}const d=Md(t),u=t.subtype&&t.subtype in a.common.entitySubtype?a.common.entitySubtype[t.subtype]:p(t.subtype);return e.jsxs("div",{children:[!l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[e.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:i("fg")},children:[p(t.primary_name),e.jsx(Wd,{data:t})]}),s]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:i("type-entity"),border:`1px solid color-mix(in srgb, ${i("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${i("type-entity")} 3%, transparent)`},children:a.indexType.entity}),u&&t.subtype!=="people"&&e.jsx("span",{children:u}),c&&e.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("warn-fg")},children:a.status.draft}),e.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:t.id})]})]}),d&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:i("widget-bg"),border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:a.common.entityPlaceholderNote}),t.alt_names&&t.alt_names.length>0&&e.jsx(Hd,{alt_names:t.alt_names}),e.jsx(Od,{data:t}),((g=t.description)==null?void 0:g.text)&&e.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:p(t.description.text)}),t.works&&t.works.length>0&&e.jsx(Fd,{works:t.works,transport:n,onNavigate:o,renderLink:r})]})},Dd=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Ud(t){const n=t.search(Dd);return n<0?[t,""]:[t.slice(0,n),t.slice(n)]}const Es={p:({children:t})=>e.jsx("p",{style:{margin:"0 0 0.5em"},children:t}),ul:({children:t})=>e.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:t}),ol:({children:t})=>e.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:t}),li:({children:t})=>e.jsx("li",{style:{marginBottom:"2px"},children:t}),a:({href:t,children:n})=>{let o=t,r="",s=n;if(t&&typeof n=="string"&&(n===t||n===Vd(t))){const[l,a]=Ud(n);a&&(o=encodeURI(l),s=l,r=a)}return e.jsxs(e.Fragment,{children:[e.jsx("a",{href:o,target:o!=null&&o.startsWith("http")?"_blank":void 0,rel:o!=null&&o.startsWith("http")?"noopener noreferrer":void 0,style:{color:i("link")},children:s}),r]})},code:({children:t})=>e.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:t})};function Vd(t){try{return decodeURI(t)}catch{return t}}const Gd={...Es,strong:({children:t})=>e.jsx(e.Fragment,{children:t})},ft=({text:t,plainStrong:n,style:o,className:r})=>{const{convert:s}=Te(),l=n?Gd:Es;return e.jsx("div",{className:r,style:o,children:e.jsx(bc,{remarkPlugins:[yc],components:l,children:s(t)})})},Yd=["〇","一","二","三","四","五","六","七","八","九"],tr=["","十","百","千"];function Ls(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),p=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=tr[p]:r+=Yd[a]+tr[p])}return r}function Ps(t){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:t,border:`1px solid color-mix(in srgb, ${t} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${t} 3%, transparent)`}}const Kd={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function qd({type:t}){const n=ve();return e.jsx("span",{style:Ps(Kd[t]),children:n.indexType[t]})}function Zd({isDraft:t}){const n=ve(),o=i(t?"status-draft":"status-official");return e.jsx("span",{style:Ps(o),children:t?n.status.draft:n.status.official})}function Jd({id:t}){const n=ve(),[o,r]=x.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:i("desc-fg"),background:i("bg-subtle"),border:`1px solid ${i("widget-border")}`,borderRadius:"2px"},children:[e.jsx("span",{children:n.label.id}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:t}),e.jsx("span",{onClick:s,title:o?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:o?1:.5,transition:"opacity 0.15s"},onMouseEnter:l=>l.currentTarget.style.opacity="1",onMouseLeave:l=>l.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function rt({children:t,extra:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("desc-fg"),letterSpacing:"1px"},children:t}),e.jsx("span",{style:{flex:1}}),n]})}function pt({label:t,children:n}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:t}),e.jsx("span",{style:{color:i("fg")},children:n})]})}function As({authors:t,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Te();return e.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:t.map((l,a)=>{const p=s(l.name),c=l.entity_id?e.jsx(ct,{id:l.entity_id,label:p,onNavigate:o,renderLink:r}):e.jsx("span",{style:{fontWeight:500},children:p});return e.jsxs("span",{children:[a>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),l.dynasty&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(l.dynasty),"〕"]}),c,l.role&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(l.role)]})]},a)})})}function ct({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ye();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{children:n||t})}function Xd({id:t,title:n,edition:o,type:r,isDraft:s,authors:l,volumeText:a,meta:p,headerExtra:c,onNavigate:d,renderLink:u}){return e.jsxs("div",{style:{marginBottom:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[e.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:i("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,o&&e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),a&&e.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:a})]}),c&&e.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[e.jsx(qd,{type:r}),e.jsx(Zd,{isDraft:s}),e.jsx(Jd,{id:t})]}),((l==null?void 0:l.length)||p.length>0)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[l&&l.length>0&&e.jsx(As,{authors:l,type:r,onNavigate:d,renderLink:u}),p]})]})}function Bs({items:t,label:n,showMeta:o,onNavigate:r,renderLink:s}){const l=ve(),{convert:a}=Te();if(!t.length)return null;const[p,c]=x.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map((d,u)=>{const g=p===u;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...g?{boxShadow:i("shadow-card")}:{}},children:[e.jsxs("div",{onClick:()=>c(g?null:u),style:{padding:"8px 12px",background:i("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(d.source)}),!g&&o&&d.title_info&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a(d.title_info)}),d.source_bid&&e.jsx("span",{onClick:m=>m.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:e.jsx(ct,{id:d.source_bid,label:l.action.view,onNavigate:r,renderLink:s})})]}),g&&e.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(d.title_info||d.author_info||d.edition)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[d.title_info&&e.jsx(pt,{label:l.label.titleInfo,children:a(d.title_info)}),d.author_info&&e.jsx(pt,{label:l.label.authorInfo,children:a(d.author_info)}),d.edition&&e.jsx(pt,{label:l.label.edition,children:a(d.edition)})]}),d.summary&&e.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.summary}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:a(d.summary)})]}),d.comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.comment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.comment)})]}),d.additional_comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.additionalComment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.additional_comment)})]})]})]},u)})})]})}function Qd({items:t,onNavigate:n,renderLink:o}){const r=ve();return e.jsx(Bs,{items:t,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function Ms({items:t,onNavigate:n,renderLink:o}){const r=ve();return e.jsx(Bs,{items:t,label:r.section.emendated,onNavigate:n,renderLink:o})}function Ws({label:t,items:n}){const{convert:o}=Te();return n.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:t}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const l=typeof r=="string"?r:r.book_title;return e.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:o(l)},s)})})]}):null}function ep({items:t}){const n=ve();return e.jsx(Ws,{label:n.section.aliases,items:t})}function tp({items:t}){const n=ve();return e.jsx(Ws,{label:n.section.attachedTexts,items:t})}function np({items:t}){const n=ve(),{convert:o}=Te();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n.section.appendix}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((r,s)=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:["《",o(r.book_title),"》",r.n_juan!=null&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function ip({items:t}){const n=ve(),{convert:o}=Te();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n.section.locationHistory}),e.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[e.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:i("widget-border")}}),t.map((r,s)=>e.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[e.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:i("primary"),border:`1.5px solid ${i("input-bg")}`}}),e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function op({items:t}){const n=ve(),{convert:o}=Te();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:n.section.historyOverview}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map((r,s)=>e.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[e.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function nr({title:t,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:l}=Te(),[a,p]=x.useState([]);return x.useEffect(()=>{if(!n.length){p([]);return}if(!o){p(n.map(d=>({id:d})));return}let c=!1;return Promise.all(n.map(d=>o.getItem(d).then(u=>({id:d,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:d})))).then(d=>{c||p(d)}),()=>{c=!0}},[n,o]),n.length?e.jsxs(e.Fragment,{children:[e.jsxs(rt,{children:[t,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(a.length?a:n.map(c=>({id:c}))).map(c=>{const d=c.edition?`${l(c.title)||c.id}(${l(c.edition)})`:l(c.title)||void 0;return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),transition:"border-color 0.15s"},children:e.jsx(ct,{id:c.id,label:d,onNavigate:r,renderLink:s})},c.id)})})]}):null}function oi({book:t,onNavigate:n,renderLink:o}){const r=ve(),{convert:s}=Te(),[l,a]=x.useState(!1),p=t.resources&&t.resources.length>0,c=t.edition?s(t.edition):s(t.title)||void 0;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[e.jsxs("div",{style:{padding:"6px 12px",borderBottom:p&&!l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:e.jsx(ct,{id:t.id,label:c,onNavigate:n,renderLink:o})}),p&&e.jsx("span",{onClick:()=>a(d=>!d),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:l?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:l?r.action.expand:r.action.collapse,children:"▼"})]}),p&&!l&&e.jsx("div",{style:{padding:"10px 14px"},children:e.jsx(Ui,{items:t.resources,resourceGroups:t.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function rp({ids:t,workData:n,transport:o,onNavigate:r,renderLink:s,footer:l}){const a=ve(),{convert:p}=Te(),[c,d]=x.useState([]);if(x.useEffect(()=>{if(!t.length){d([]);return}if(!o){d(t.map(v=>({id:v})));return}let f=!1;return Promise.all(t.map(v=>o.getItem(v).then(y=>({id:v,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:v})))).then(v=>{f||d(v)}),()=>{f=!0}},[t,o]),!t.length)return null;const u=c.length?c:t.map(f=>({id:f})),g=new Map(u.map(f=>[f.id,f])),m=n==null?void 0:n.version_graph,h=sp(t,m,a.common.otherVersions);return e.jsxs(e.Fragment,{children:[e.jsxs(rt,{children:[a.section.relatedVersions,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",t.length,")"]})]}),l,h.useGrouping?e.jsxs(e.Fragment,{children:[h.coreIds.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.coreIds.map(f=>{const v=g.get(f);return v?e.jsx(oi,{book:v,onNavigate:r,renderLink:s},f):null})}),h.groupedIds.map(f=>e.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[p(f.label),e.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",f.ids.length,")"]}),f.description&&e.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:p(f.description)})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:f.ids.map(v=>{const y=g.get(v);return y?e.jsx(oi,{book:y,onNavigate:r,renderLink:s},v):null})})]},f.id))]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(f=>e.jsx(oi,{book:f,onNavigate:r,renderLink:s},f.id))})]})}function sp(t,n,o){var w,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,groupedIds:[]};const r=(w=n.collections)==null?void 0:w[n.default_collection],s=(r==null?void 0:r.groups)??[],l=(r==null?void 0:r.book_ids)??[],a=s.length>0||l.length>0,p=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&p.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const c=new Set(s),d=new Set([...l,...p]),u=j=>{if(d.has(j))return!0;const S=n.node_groups[j];return S!=null&&c.has(S)},g=[],m=new Map,h=[];for(const j of t)if(!((b=n.excluded_books)!=null&&b.includes(j)))if(u(j))g.push(j);else{const S=n.node_groups[j];S?(m.has(S)||m.set(S,[]),m.get(S).push(j)):h.push(j)}if(h.length+[...m.values()].reduce((j,S)=>j+S.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const v=new Map((n.groups??[]).map(j=>[j.id,j])),y=[...m.entries()].map(([j,S])=>{const k=v.get(j);return{id:j,label:(k==null?void 0:k.label)??j,description:k==null?void 0:k.description,ids:S}});return h.length>0&&y.push({id:"__other__",label:o,description:void 0,ids:h}),{useGrouping:!0,coreIds:g,groupedIds:y}}function lp({workData:t,onNavigate:n,renderLink:o}){var a,p,c,d;const r=ve(),{convert:s}=Te(),l=!!((a=t.description)!=null&&a.text)||!!t.parent_work;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[e.jsxs("div",{style:{padding:"6px 14px",borderBottom:l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:e.jsx(ct,{id:t.id,label:s(t.title),onNavigate:n,renderLink:o})}),t.measure_info?e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:s(t.measure_info)}):((p=t.juan_count)==null?void 0:p.number)!=null&&t.juan_count.number>0?e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[Ls(t.juan_count.number),r.unit.juan]}):null,t.authors&&t.authors.length>0&&e.jsx("span",{style:{fontSize:"13px"},children:e.jsx(As,{authors:t.authors,type:"work",onNavigate:n,renderLink:o})})]}),l&&e.jsxs("div",{style:{padding:"8px 14px"},children:[((c=t.description)==null?void 0:c.text)&&e.jsx(ft,{text:t.description.text,style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,textAlign:"justify"}}),t.parent_work&&e.jsx("div",{style:{marginTop:(d=t.description)!=null&&d.text?"8px":0,fontSize:"13px"},children:e.jsx(pt,{label:r.label.parentWork,children:e.jsx(ct,{id:t.parent_work.id,label:s(t.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function ap({items:t,onNavigate:n,renderLink:o}){const r=ve(),{convert:s}=Te();return t.length?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:t.map(l=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${i("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${i("type-collection")} 3%, transparent)`},children:[e.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),e.jsx(ct,{id:l.id,label:s(l.title)||l.id,onNavigate:n,renderLink:o}),l.volume_index!=null&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:it(r.catalog.volume,{n:l.volume_index})})]},l.id))}):null}const Ki=({data:t,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:l,relatedBooksFooter:a,className:p,style:c})=>{var O,W,P,Y,V,Q,ge,A;const d=ve(),{convert:u}=Te(),[g,m]=x.useState(null),[h,f]=x.useState(!1),[v,y]=x.useState(null),[w,b]=x.useState(null),[j,S]=x.useState([]),k=t||g;if(x.useEffect(()=>{if(t||!n||!o)return;let I=!1;return f(!0),y(null),o.getItem(n).then(Z=>{I||(Z?m(Z):y(d.misc.notFoundEntry))}).catch(Z=>{I||y(Z instanceof Error?Z.message:d.misc.loadFailed)}).finally(()=>{I||f(!1)}),()=>{I=!0}},[t,n,o]),x.useEffect(()=>{if(!k||!o){b(null),S([]);return}let I=!1;const Z=k.type==="book"||k.type==="collection"?k.work_id:void 0;if(Z?o.getItem(Z).then(ee=>{!I&&ee&&ee.type==="work"&&b(ee)}).catch(()=>{}):b(null),k.type==="book"){const ee=k;ee.contained_in&&ee.contained_in.length>0?Promise.all(ee.contained_in.map(ce=>{const fe=typeof ce=="string"?ce:ce.id,Ie=typeof ce=="string"?void 0:ce.volume_index;return o.getItem(fe).then(q=>({id:fe,title:q&&q.title||fe,volume_index:Ie})).catch(()=>({id:fe,title:fe,volume_index:Ie}))})).then(ce=>{I||S(ce)}):S([])}else S([]);return()=>{I=!0}},[k,o]),h)return e.jsx("div",{className:p,style:{...c,padding:"24px"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((I,Z)=>e.jsx("div",{style:{height:Z===1?"32px":"16px",width:`${I}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},Z))})});if(v)return e.jsx("div",{className:p,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:v});if(!k)return null;if(k.type==="entity")return e.jsx("div",{className:p,style:c,children:e.jsx(Rs,{data:k,transport:o,onNavigate:r,renderLink:s,headerExtra:l})});const $=k.type==="book"?k:null,_=k.type==="collection"?k:null,z=k.type==="work"?k:null;let E=!1;try{E=xe.extractStatus(k.id)==="draft"}catch{}let T="";k.measure_info?T=u(k.measure_info):(O=k.juan_count)!=null&&O.number?T=Ls(k.juan_count.number)+d.unit.juan:(W=k.juan_count)!=null&&W.description&&(T=u(k.juan_count.description));const C=[];return(P=k.publication_info)!=null&&P.year&&C.push(e.jsx(pt,{label:d.label.year,children:k.publication_info.year},"year")),(Y=k.current_location)!=null&&Y.name&&C.push(e.jsx(pt,{label:d.label.currentLocation,children:u(k.current_location.name)},"loc")),(V=k.page_count)!=null&&V.description&&C.push(e.jsx(pt,{label:d.label.pageCount,children:k.page_count.description},"page")),$!=null&&$.edition&&C.push(e.jsx(pt,{label:d.label.edition,children:u($.edition)},"ver")),z!=null&&z.parent_work&&C.push(e.jsx(pt,{label:d.label.parentWork,children:e.jsx(ct,{id:z.parent_work.id,label:u(z.parent_work.title),onNavigate:r,renderLink:s})},"pw")),z!=null&&z.parent_works&&z.parent_works.length>0&&!z.parent_work&&C.push(e.jsx(pt,{label:d.label.parentWork,children:z.parent_works.map((I,Z)=>e.jsxs("span",{children:[Z>0&&"、",e.jsx(ct,{id:I,onNavigate:r,renderLink:s})]},I))},"pws")),e.jsxs("div",{className:p,style:c,children:[e.jsx(Xd,{id:k.id,title:u(k.title),edition:k.edition?u(k.edition):void 0,type:k.type,isDraft:E,authors:k.authors,volumeText:T,meta:C,headerExtra:l,onNavigate:r,renderLink:s}),((Q=k.description)==null?void 0:Q.text)&&e.jsx(ft,{text:k.description.text,style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),k.appendix&&k.appendix.length>0&&e.jsx("div",{style:{marginTop:8,marginBottom:4},children:k.appendix.map((I,Z)=>e.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(I.title)}),e.jsx(ft,{text:I.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},Z))}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:d.section.containedIn}),e.jsx(ap,{items:j,onNavigate:r,renderLink:s})]}),w&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:d.section.belongsToWork}),e.jsx(lp,{workData:w,onNavigate:r,renderLink:s})]}),k.additional_works&&k.additional_works.length>0&&e.jsx(np,{items:k.additional_works}),k.additional_titles&&k.additional_titles.length>0&&e.jsx(ep,{items:k.additional_titles}),k.attached_texts&&k.attached_texts.length>0&&e.jsx(tp,{items:k.attached_texts}),k.indexed_by&&k.indexed_by.length>0&&e.jsx(Qd,{items:k.indexed_by,onNavigate:r,renderLink:s}),k.emendated_by&&k.emendated_by.length>0&&e.jsx(Ms,{items:k.emendated_by,onNavigate:r,renderLink:s}),k.resources&&k.resources.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:d.section.resources}),e.jsx(Ui,{items:k.resources,resourceGroups:k.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&e.jsx(ip,{items:$.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&e.jsx(op,{items:_.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&e.jsx(nr,{title:d.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&e.jsx(nr,{title:d.section.containedBooks,ids:_.books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.contained_works)&&_.contained_works.length>0&&e.jsxs("div",{children:[e.jsxs(rt,{children:[d.section.containedWorks,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",_.contained_works.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.contained_works.map(I=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:e.jsx(ct,{id:I.id,label:u(I.title),onNavigate:r,renderLink:s})},I.id))})]}),(((ge=z==null?void 0:z.books)==null?void 0:ge.length)||0)+(((A=z==null?void 0:z.collections)==null?void 0:A.length)||0)>0&&e.jsx(rp,{ids:[...(z==null?void 0:z.books)||[],...(z==null?void 0:z.collections)||[]],workData:z??void 0,transport:o,onNavigate:r,renderLink:s,footer:a}),(z==null?void 0:z.related_works)&&z.related_works.length>0&&(()=>{const I=[],Z=z.related_works.filter(M=>M.relation==="part_of"),ee=z.related_works.filter(M=>M.relation==="has_part"),ce=z.related_works.filter(M=>M.relation==="has_adaptation"),fe=z.related_works.filter(M=>M.relation==="text_carried_by"),Ie=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),q=z.related_works.filter(M=>!M.relation||!Ie.has(M.relation));return Z.length>0&&I.push({label:d.section.belongsToWork,items:Z}),ee.length>0&&I.push({label:d.section.containedWorks,items:ee}),ce.length>0&&I.push({label:d.section.adaptations,items:ce}),fe.length>0&&I.push({label:d.section.derivativeWorks,items:fe}),q.length>0&&I.push({label:d.section.relatedWorks,items:q}),I.map(M=>e.jsxs("div",{children:[e.jsxs(rt,{children:[M.label,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",M.items.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:M.items.map(K=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:e.jsx(ct,{id:K.id,label:u(K.title),onNavigate:r,renderLink:s})},K.id))})]},M.label))})()]})};function cp({data:t}){const n=ve(),{convert:o}=Te(),{stats:r}=t,s=r.processed_volumes??r.total_found_volumes,l=s!=null&&t.total_volumes>0?Math.round(s/t.total_volumes*100):null;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:o(t.title)}),t.resource_name&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(t.resource_name)}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[e.jsxs("span",{children:[n.catalog.totalVolumes," ",e.jsx("strong",{style:{color:i("fg")},children:t.total_volumes})," ",n.unit.volume]}),l!=null&&e.jsxs("span",{children:[n.catalog.processed," ",e.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",l,"%)"]}),e.jsxs("span",{children:[n.catalog.contains," ",e.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&e.jsxs("span",{children:[n.catalog.matched," ",e.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&e.jsxs("span",{children:[n.catalog.unmatched," ",e.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),t.source&&e.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",t.source]})]})}function dp({sections:t,activeSection:n,onSelect:o}){const r=ve();return e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[e.jsx("button",{onClick:()=>o(null),style:ir(n===null),children:r.catalog.all}),t.map(s=>e.jsxs("button",{onClick:()=>o(s.name),style:ir(n===s.name),children:[s.name,s.volume_range&&e.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function ir(t){return{padding:"4px 12px",border:t?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:t?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(t?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}function pp({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ye();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:n||t})}function up(t,n){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=t[0],r=t[t.length-1];return r-o+1===t.length?`${o}–${r}`:t.length<=3?t.join(", "):`${o}–${r} (${t.length}${n})`}function or({book:t,onNavigate:n,renderLink:o,showVolumes:r}){const s=ve(),{convert:l}=Te(),a=t.book_id||t.work_id,p=r&&t.volumes.length>0?up(t.volumes,s.unit.volume):null,c=t.missing_volumes&&t.missing_volumes.length>0;return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${i("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[r&&e.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:p}),e.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[l(t.title),t.sub_items&&t.sub_items.length>0&&e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",t.sub_items.map(d=>l(d)).join("、"),")"]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:l(t.edition)})]}),t.expected_volumes!=null&&e.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[t.found_volumes??0,"/",t.expected_volumes,s.unit.volume]}),a&&e.jsx(pp,{id:a,label:t.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!a&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const qi=({data:t,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:l,style:a})=>{const p=ve(),[c,d]=x.useState(null),[u,g]=x.useState(!1),[m,h]=x.useState(null),[f,v]=x.useState(null),[y,w]=x.useState(""),b=t||c;x.useEffect(()=>{if(t||!n||!(o!=null&&o.getCollectionCatalog))return;let _=!1;return g(!0),h(null),o.getCollectionCatalog(n).then(z=>{_||(z?d(z):h(p.catalog.notFound))}).catch(z=>{_||h(z instanceof Error?z.message:p.catalog.loadFailed)}).finally(()=>{_||g(!1)}),()=>{_=!0}},[t,n,o,p]);const j=(b==null?void 0:b.sections)&&b.sections.length>0,S=x.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(E=>E.volumes[0]).filter(E=>E!=null);return new Set(_).size<_.length},[b]),k=x.useMemo(()=>{if(!b)return[];let _=b.books;if(f&&(_=_.filter(z=>z.section===f)),y.trim()){const z=y.trim().toLowerCase();_=_.filter(E=>E.title.toLowerCase().includes(z)||E.sub_items&&E.sub_items.some(T=>T.toLowerCase().includes(z))||E.edition&&E.edition.toLowerCase().includes(z))}return _},[b,f,y]),$=x.useMemo(()=>{if(!S)return null;const _=[],z=new Map;for(const T of k){if(!T.volumes||T.volumes.length===0)continue;const C=T.volumes[0];z.has(C)||z.set(C,[]),z.get(C).push(T)}const E=[...z.keys()].sort((T,C)=>T-C);for(const T of E)_.push({volume:T,books:z.get(T)});return _},[k,S]);return u?e.jsx("div",{className:l,style:{...a,padding:"24px"},children:e.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:p.catalog.loading})}):m?e.jsx("div",{className:l,style:{...a,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:m}):b?e.jsxs("div",{className:l,style:a,children:[e.jsx(cp,{data:b}),j&&e.jsx(dp,{sections:b.sections,activeSection:f,onSelect:v}),e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("input",{type:"text",placeholder:p.search.searchBookName,value:y,onChange:_=>w(_.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),e.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[k.length," ",p.unit.bu]})]}),e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((_,z)=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"4px 12px",background:i("bg"),borderBottom:`1px solid ${i("widget-border")}`,fontSize:"12px",fontWeight:600,color:i("desc-fg"),position:"sticky",top:0,zIndex:1},children:it(p.catalog.volume,{n:_.volume})}),_.books.map((E,T)=>e.jsx(or,{book:E,onNavigate:r,renderLink:s,showVolumes:E.volumes.length>1},`${_.volume}-${T}`))]},`${_.volume}-${z}`)):k.map((_,z)=>e.jsx(or,{book:_,onNavigate:r,renderLink:s,showVolumes:!0},z)),k.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:p.catalog.noMatch})]})]}):null},mp="guji_markdown";function ji(t){const n=t==null?void 0:t.guji_markdown;if(typeof n!="string")return!1;const o=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!o)return!1;const r=parseInt(o[1],10),s=parseInt(o[2],10);return r>0||s>=2}const gp=/^□\{guess=([^\s{}]+)\}/;function hp(t,n){const o=t[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function Hs(t,n){let o=0;for(let r=n;r<t.length;r++){const s=t[r];if(s===`
|
|
146
|
+
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function xp(t){return t.replace(/\\([\\[\]<>|{}])/g,"$1")}function fp(t,n){const o=t[n];if(o==="["&&t[n+1]==="["){const r=t.indexOf("]]",n+2);return r>=0&&t.slice(n+2,r).indexOf(`
|
|
147
|
+
`)<0?{node:{type:"qw",label:t.slice(n+2,r)},end:r+2}:null}if(o===":"&&t.startsWith(":zi[",n)){const r=Hs(t,n+3);return r>n+4?{node:{type:"zi",label:xp(t.slice(n+4,r))},end:r+1}:null}if(o==="□"&&t[n+1]==="{"){const r=gp.exec(t.slice(n,n+64));if(r)return{node:{type:"qz",guess:r[1]},end:n+r[0].length}}return null}function Os(t,n,o,r){const s=[];let l="";const a=()=>{if(!l)return;const p=r?l.replace(/\\?\|/g,""):l;p&&s.push({type:"text",text:p}),l=""};for(;n<t.length;){const p=t[n];if(o!==null){if(p===o)return a(),{nodes:s,end:n};if(p===`
|
|
148
|
+
`)return null}const c=fp(t,n);if(c){a(),s.push(c.node),n=c.end;continue}let d=null;if(p==="⟨"?d="⟩":p==="<"&&hp(t,n)&&(d=">"),d){const u=Os(t,n+1,d,!0);if(u){a(),s.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return o!==null?null:(a(),{nodes:s,end:n})}function Fs(t){return Os(t,0,null,!1).nodes}function bp(t){return/[<⟨□]|\[\[|:zi\[/.test(t)}function Ds(t){return t.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Ds(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Us="guji-table-v1";function Vs(t){return!!t&&t.table_notation===Us}const yp=/^:::table(?:\{[^}]*\})?[ \t]*$/,jp=/^:::[ \t]*$/;function Gs(t){const n=[];let o="";for(let r=0;r<t.length;r++){const s=t[r];if(s===":"&&t.startsWith(":zi[",r)){const a=Hs(t,r+3);if(a>r+4){o+=t.slice(r,a+1),r=a;continue}}let l=null;if(s==="⟨")l="⟩";else if(s==="<"){const a=t[r+1];a!==void 0&&!/[A-Za-z/!?>\s]/.test(a)&&(l=">")}if(l){const a=t.indexOf(l,r+1);if(a>0){o+=t.slice(r,a+1),r=a;continue}}s==="|"?(n.push(o),o=""):o+=s}return n.push(o),n.map(r=>r.trim())}const vp=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function kp(t){if(t==="^")return{cont:!0};const n=vp.exec(t),o=n[1].trim(),r=n[2]?Math.max(1,parseInt(n[2],10)):1,s=n[3]?Math.max(1,parseInt(n[3],10)):1,l=o==="_";return{cont:!1,cell:{text:l?"":o,empty:l,colspan:r,rowspan:s}}}function Ys(t,n=1){const o=[],r=[],s=[];let l=[];t.forEach((p,c)=>{const d=c+n+1;let u=p.trim();if(!u)return;let g=!1;u.startsWith("!")&&(g=!0,u=u.slice(1));const m=Gs(u).map(kp),h=l.map(w=>w>0),f=l.map(w=>w>0?w-1:0),v=[];let y=0;for(const w of m){if(w.cont){h[y]||o.push(`第 ${d} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=w;for(let j=y;j<y+b.colspan;j++)if(h[j]){o.push(`第 ${d} 行第 ${j+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let j=y;j<y+b.colspan;j++)f[j]=b.rowspan-1;v.push(b),y+=b.colspan}for(let w=y;w<h.length;w++)h[w]&&o.push(`第 ${d} 行第 ${w+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let w=0;w<f.length;w++)f[w]===void 0&&(f[w]=0);l=f,r.push({header:g,cells:v}),s.push({width:y,line:d})});const a=s.reduce((p,c)=>Math.max(p,c.width),0);for(const p of s)p.width!==a&&o.push(`第 ${p.line} 行:占 ${p.width} 列,与总列数 ${a} 不符`);return l.some(p=>p>0)&&o.push("表尾:有跨行格超出了表的最后一行"),r.length===0&&o.push("空表"),{rows:r,columns:a,warnings:o}}function Zi(t){const n=t.split(`
|
|
149
149
|
`),o=[];let r=[];const s=()=>{if(r.length===0)return;const a=r.join(`
|
|
150
|
-
`);r=[],o.push({type:"text",text:a})};let l=0;for(;l<n.length;){if(
|
|
151
|
-
`)}),l=a+1;continue}}r.push(n[l]),l++}return s(),o.map((a,
|
|
150
|
+
`);r=[],o.push({type:"text",text:a})};let l=0;for(;l<n.length;){if(yp.test(n[l].trim())){let a=l+1;for(;a<n.length&&!jp.test(n[a].trim());)a++;if(a<n.length){s();const p=n.slice(l+1,a);o.push({type:"table",table:Ys(p,l+1),source:n.slice(l,a+1).join(`
|
|
151
|
+
`)}),l=a+1;continue}}r.push(n[l]),l++}return s(),o.map((a,p)=>{var d,u;if(a.type!=="text")return a;let c=a.text;return((d=o[p-1])==null?void 0:d.type)==="table"&&(c=c.replace(/^\n+/,"")),((u=o[p+1])==null?void 0:u.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(a=>a.type!=="text"||a.text!=="")}const ri=t=>t?t.catch(()=>null):Promise.resolve(null);function Ks(t){const n=new Map;function o(r){var l;let s=n.get(r);return s||(s=ri((l=t.getTextManifest)==null?void 0:l.call(t,r)).then(a=>{const p=a&&Array.isArray(a.versions)&&a.versions.length>0?a:null;return p||n.delete(r),p}),n.set(r,s)),s}return{getManifest(r){return xe.isSafeSegment(r)?o(r):Promise.resolve(null)},async getIndex(r,s){return!xe.isSafeSegment(r)||!xe.isSafeSegment(s)||!t.getTextIndex?null:ri(t.getTextIndex(r,s))},async getChapter(r,s,l,a){return!xe.isSafeSegment(r)||!xe.isSafeSegment(s)||!xe.isSafeSegment(l)||!t.getChapter?null:ri(t.getChapter(r,s,l,a))}}}const Rt=()=>{const{t}=G(),[n,o]=x.useState(1);return x.useEffect(()=>{const r=setInterval(()=>o(s=>s>=3?1:s+1),500);return()=>clearInterval(r)},[]),e.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:i("desc-fg"),fontSize:"14px"},children:t("common.loading")+".".repeat(n)})},si=String.raw`https?:\/\/[^\s()()<>"]+`,wp=new RegExp(String.raw`\[([^\]\n]+)\]\((${si})\)`+String.raw`|(《[^》\n]+》)\s?[((](${si})[))]`+`|(${si})`,"g");function Sp(t){try{return new URL(t).hostname.replace(/^www\./,"")}catch{return t}}function $p(t){const n=[];let o=0;for(const r of t.matchAll(wp)){const s=r.index??0;s>o&&n.push({text:t.slice(o,s)}),r[1]!==void 0?n.push({text:r[1],url:r[2]}):r[3]!==void 0?n.push({text:r[3],url:r[4]}):n.push({text:Sp(r[5]),url:r[5]}),o=s+r[0].length}return o<t.length&&n.push({text:t.slice(o)}),n}function qs({text:t,convert:n,className:o="bim-rd-link"}){return e.jsx(e.Fragment,{children:$p(t).map((r,s)=>r.url?e.jsx("a",{className:o,href:r.url,target:"_blank",rel:"noopener noreferrer",children:n(r.text)},s):e.jsx(x.Fragment,{children:n(r.text)},s))})}const Zs="(min-width: 1100px)",Js="(max-width: 719px)",Xs="(max-width: 859px)",_p=`${Js}, (pointer: coarse)`,yt=i("reader-top"),Cp="48px",Qs=`
|
|
152
152
|
.bim-rd {
|
|
153
153
|
position: relative;
|
|
154
154
|
background: ${i("page-bg")};
|
|
155
155
|
color: ${i("ink")};
|
|
156
156
|
font-family: ${i("font-ui")};
|
|
157
|
-
--bimrd-bar-h: ${
|
|
157
|
+
--bimrd-bar-h: ${Cp};
|
|
158
158
|
}
|
|
159
159
|
.bim-rd *, .bim-rd *::before, .bim-rd *::after { box-sizing: border-box; }
|
|
160
160
|
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
|
|
181
181
|
/* ── 工具条:文字 + 图标,不画按钮外框 ── */
|
|
182
182
|
.bim-rd-bar {
|
|
183
|
-
position: sticky; top: ${
|
|
183
|
+
position: sticky; top: ${yt}; z-index: 30;
|
|
184
184
|
height: var(--bimrd-bar-h);
|
|
185
185
|
display: flex; align-items: center; gap: 16px;
|
|
186
186
|
padding: 0 20px;
|
|
@@ -235,14 +235,14 @@
|
|
|
235
235
|
display: grid;
|
|
236
236
|
grid-template-columns: auto auto minmax(0, 1fr);
|
|
237
237
|
align-items: start;
|
|
238
|
-
min-height: calc(100vh - ${
|
|
238
|
+
min-height: calc(100vh - ${yt} - var(--bimrd-bar-h));
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
/* 目录:宽屏是侧栏 */
|
|
242
242
|
.bim-rd-toc {
|
|
243
243
|
grid-column: 1;
|
|
244
|
-
position: sticky; top: calc(${
|
|
245
|
-
width: 248px; height: calc(100vh - ${
|
|
244
|
+
position: sticky; top: calc(${yt} + var(--bimrd-bar-h));
|
|
245
|
+
width: 248px; height: calc(100vh - ${yt} - var(--bimrd-bar-h));
|
|
246
246
|
overflow-y: auto; overscroll-behavior: contain;
|
|
247
247
|
padding: 0 10px 40px;
|
|
248
248
|
background: ${i("sidebar-bg")};
|
|
@@ -279,8 +279,8 @@
|
|
|
279
279
|
/* 书影:正文左侧 */
|
|
280
280
|
.bim-rd-img {
|
|
281
281
|
grid-column: 2;
|
|
282
|
-
position: sticky; top: calc(${
|
|
283
|
-
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${
|
|
282
|
+
position: sticky; top: calc(${yt} + var(--bimrd-bar-h));
|
|
283
|
+
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${yt} - var(--bimrd-bar-h));
|
|
284
284
|
padding: 16px 0 16px 20px;
|
|
285
285
|
display: flex; flex-direction: column; gap: 8px;
|
|
286
286
|
}
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
display: flex; align-items: center; justify-content: center; overflow: hidden;
|
|
292
292
|
}
|
|
293
293
|
.bim-rd-img-fig { position: relative; margin: 0; max-width: 100%; max-height: 100%; }
|
|
294
|
-
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${
|
|
294
|
+
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${yt} - var(--bimrd-bar-h) - 80px); object-fit: contain; }
|
|
295
295
|
.bim-rd-img-fig svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
296
296
|
.bim-rd-img-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center; font-size: 13px; color: ${i("meta-fg")}; }
|
|
297
297
|
.bim-rd-img-empty b { font-size: 15px; font-weight: 500; color: ${i("quiet-fg")}; }
|
|
@@ -336,7 +336,7 @@
|
|
|
336
336
|
.bim-rd-kicker { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.2em; color: ${i("label-fg")}; font-family: ${i("font-ui")}; }
|
|
337
337
|
.bim-rd-kicker .bim-rd-dot::before { content: "·"; margin: 0 0.6em; }
|
|
338
338
|
.bim-rd-h1 { font-family: ${i("font-ui")}; font-size: 28px; font-weight: 700; letter-spacing: 0.12em; margin: 0; color: ${i("ink")}; line-height: 1.4; }
|
|
339
|
-
.bim-rd-meta { margin: 6px 0 0; font-size: 13px; line-height: 1.8; color: ${i("meta-fg")}; font-family: ${i("font-ui")}; }
|
|
339
|
+
.bim-rd-meta { margin: 6px 0 0; font-size: 13px; line-height: 1.8; color: ${i("meta-fg")}; font-family: ${i("font-ui")}; overflow-wrap: anywhere; }
|
|
340
340
|
.bim-rd-meta .bim-rd-dot::before { content: "·"; margin: 0 0.5em; }
|
|
341
341
|
.bim-rd-grade { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 11.5px; line-height: 1.7; background: ${i("band-bg")}; color: ${i("quiet-fg")}; }
|
|
342
342
|
.bim-rd-meta select { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
|
|
@@ -387,7 +387,7 @@
|
|
|
387
387
|
|
|
388
388
|
/* 竖排(预留):只在宿主打开 allowVertical 时可切换 */
|
|
389
389
|
.bim-rd-vertical .bim-rd-prose {
|
|
390
|
-
writing-mode: vertical-rl; max-height: calc(100vh - ${
|
|
390
|
+
writing-mode: vertical-rl; max-height: calc(100vh - ${yt} - var(--bimrd-bar-h) - 120px);
|
|
391
391
|
overflow-x: auto; text-align: start;
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -444,7 +444,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
444
444
|
.bim-rd-sheet-img .bim-rd-img-fig img { max-height: 60vh; }
|
|
445
445
|
.bim-rd-sheet-fs { display: flex; align-items: center; justify-content: center; gap: 24px; padding: 8px 0 12px; font-size: 15px; color: ${i("ink")}; }
|
|
446
446
|
.bim-rd-sheet-fs .bim-rd-t { min-width: 56px; min-height: 44px; justify-content: center; font-size: 17px; border: 1px solid ${i("rule")}; }
|
|
447
|
-
@media ${
|
|
447
|
+
@media ${Xs} {
|
|
448
448
|
.bim-rd[data-bb] .bim-rd-text { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom, 0px)); }
|
|
449
449
|
/* 底栏上已有的,工具条上不再重复(目录、字号) */
|
|
450
450
|
.bim-rd[data-bb] .bim-rd-bb-dup { display: none !important; }
|
|
@@ -454,7 +454,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
454
454
|
|
|
455
455
|
/* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
|
|
456
456
|
A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
|
|
457
|
-
@media ${
|
|
457
|
+
@media ${_p} {
|
|
458
458
|
.bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
|
|
459
459
|
.bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
|
|
460
460
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
@@ -467,7 +467,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
/* ── 中屏以下:目录改抽屉 ── */
|
|
470
|
-
@media not all and ${
|
|
470
|
+
@media not all and ${Zs} {
|
|
471
471
|
.bim-rd-toc {
|
|
472
472
|
position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
|
|
473
473
|
width: min(86vw, 320px);
|
|
@@ -481,7 +481,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
/* ── 窄屏:书影收起,只留正文 ── */
|
|
484
|
-
@media ${
|
|
484
|
+
@media ${Js} {
|
|
485
485
|
.bim-rd-bar { padding: 0 12px; gap: 10px; }
|
|
486
486
|
.bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
|
|
487
487
|
/* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
|
|
@@ -515,12 +515,12 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
515
515
|
:root[data-theme="ink"] .bim-rd-t[aria-pressed="true"], :root[data-theme="ink"] .bim-rd-t[aria-current="true"] {
|
|
516
516
|
text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px;
|
|
517
517
|
}
|
|
518
|
-
`;function Yi(t,n){var o;return n?t.key===n?!0:!!((o=t.children)!=null&&o.some(r=>Yi(r,n))):!1}const hp=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function xp({item:t,activeKey:n,onSelect:o,tabKey:r}){const s=Yi(t,n),[l,a]=x.useState(s||!!t.defaultExpanded);return x.useEffect(()=>{s&&a(!0)},[s]),x.useEffect(()=>{t.defaultExpanded&&a(!0)},[t.defaultExpanded]),e.jsxs("li",{children:[e.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":t.key,tabIndex:r===t.key?0:-1,onClick:()=>a(d=>!d),children:[e.jsx(hp,{}),e.jsx("span",{children:t.label}),t.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:t.hint})]}),l&&e.jsx(qs,{items:t.children,activeKey:n,onSelect:o,tabKey:r})]})}function qs({items:t,activeKey:n,onSelect:o,tabKey:r}){return e.jsx("ul",{children:t.map(s=>s.children&&s.children.length>0?e.jsx(xp,{item:s,activeKey:n,onSelect:o,tabKey:r},s.key):e.jsx("li",{children:e.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:r===s.key?0:-1,onClick:()=>o(s.key),children:[e.jsx("span",{children:s.label}),s.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function ir(t,n){var o;for(const r of t)if(r.key===n||Yi(r,n))return r.key;return((o=t[0])==null?void 0:o.key)??null}function Zs({items:t,activeKey:n,onSelect:o,label:r}){const{t:s}=K(),l=r??s("reader.toc"),a=x.useRef(null),[d,c]=x.useState(null);x.useEffect(()=>{c(null)},[n]);const p=x.useMemo(()=>d||(n??ir(t,n)),[d,n,t]);x.useEffect(()=>{const g=a.current;if(!g)return;const m=Array.from(g.querySelectorAll("[data-rd-toc-key]"));if(m.length===0)return;const h=m.find(f=>f.dataset.rdTocKey===p)??m.find(f=>f.dataset.rdTocKey===ir(t,n))??m.find(f=>!f.disabled)??m[0];for(const f of m)f.tabIndex=f===h?0:-1}),x.useEffect(()=>{const g=a.current,m=g==null?void 0:g.closest(".bim-rd-toc");if(!g||!m||!n)return;const h=Array.from(g.querySelectorAll("[data-rd-toc-key]")).find(v=>v.dataset.rdTocKey===n);if(!h)return;const f=h.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;(f<m.scrollTop+80||f>m.scrollTop+m.clientHeight-40)&&(m.scrollTop=Math.max(0,f-m.clientHeight/3))},[n]);const u=x.useCallback(g=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(g.key))return;const h=a.current;if(!h)return;const f=Array.from(h.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),v=f.indexOf(document.activeElement);let y=v;if(g.key==="ArrowDown"?y=Math.min(f.length-1,v+1):g.key==="ArrowUp"?y=Math.max(0,v-1):g.key==="Home"?y=0:g.key==="End"&&(y=f.length-1),y<0||y===v)return;g.preventDefault();const k=f[y];for(const b of f)b.tabIndex=-1;k.tabIndex=0,k.focus(),c(k.dataset.rdTocKey??null)},[]);return e.jsx("div",{ref:a,role:"navigation","aria-label":l,onKeyDown:u,children:e.jsx(qs,{items:t,activeKey:n,onSelect:o,tabKey:p})})}function fp({page:t}){var n;return!((n=t.boxes)!=null&&n.length)||!t.width||!t.height||t.boxFormat&&t.boxFormat!=="bim-charbox-v0"?null:e.jsx("svg",{viewBox:`0 0 ${t.width} ${t.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:t.boxes.map((o,r)=>e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:i("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},r))})}function fi({pages:t,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:l}=K(),[a,d]=x.useState(0),c=o??a,p=h=>{r?r(h):d(h)};if(x.useEffect(()=>{o===void 0&&d(0)},[t,o]),n)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!t||t.length===0)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("div",{className:"bim-rd-img-empty",children:[e.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),e.jsx("b",{children:l("reader.noImages")}),e.jsx("span",{children:l("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(t.length-1,c)),g=t[u],m=g.label??`${u+1}`;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("figure",{className:"bim-rd-img-fig",children:[e.jsx("img",{src:g.url,alt:g.alt??l("reader.imageAlt",{label:m}),width:g.width,height:g.height,loading:"lazy",decoding:"async"}),e.jsx(fp,{page:g}),s==null?void 0:s(g,u)]})}),t.length>1&&e.jsxs("div",{className:"bim-rd-img-pager",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:u===0,onClick:()=>p(u-1),children:"‹"}),e.jsx("span",{"aria-live":"polite",children:g.label??`${u+1} / ${t.length}`}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:u===t.length-1,onClick:()=>p(u+1),children:"›"})]})]})}const Ki={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},ut=[15,16,17,18,20,22,24],bi=18,Js="bim-reader-prefs",bp="bim-reading-mode";function yp(){const t={...Ki};try{const n=localStorage.getItem(Js),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&ut.includes(o.fontSize)&&(t.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(bp))==="paragraph"&&(t.readingMode="paragraph"),o.properNames===!0&&(t.properNames=!0),o.writingMode==="vertical"&&(t.writingMode="vertical"),o.workLinks===!1&&(t.workLinks=!1)}catch{}return t}function jp(t){try{localStorage.setItem(Js,JSON.stringify(t))}catch{}}function xn(t,n){const o=t??bi,r=ut;let s=r.indexOf(o);return s<0&&(s=r.indexOf(bi)),r[Math.max(0,Math.min(r.length-1,s+n))]}function Xs(){const[t,n]=x.useState(Ki);x.useEffect(()=>{n(yp())},[]);const o=x.useCallback(r=>{n(s=>{const l={...s,...r};return jp(l),l})},[]);return[t,o]}function yi(t){if(t.optionLabel)return t.optionLabel;const n=t.label||t.key;return!t.sourceName||n.includes(t.sourceName)?n:`${n} · ${t.sourceName}`}function Qs(t,n){if(!(!t||t.length===0))return(n!=null?t.find(o=>o.key===n):void 0)??t.find(o=>o.primary)??t[0]}function el(t){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(t),n}const or=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),vp=()=>e.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:e.jsx("path",{d:"M15 5l-7 7 7 7"})}),kp=()=>e.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:e.jsx("path",{d:"M9 5l7 7-7 7"})}),rr=()=>e.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:[e.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),e.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function sr(t,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(a=>a.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],l=document.activeElement;t.shiftKey&&(l===r||!n.contains(l))?(t.preventDefault(),s.focus()):!t.shiftKey&&(l===s||!n.contains(l))&&(t.preventDefault(),r.focus())}function lr(t,n){const[o,r]=x.useState(n);return x.useEffect(()=>{var a;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(t);r(s.matches);const l=()=>r(s.matches);return(a=s.addEventListener)==null||a.call(s,"change",l),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",l)}},[t]),o}function wp(){const t=x.useContext(Tt),{t:n}=K();if(!t)return null;const o=t.locale==="zh-Hant";return e.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>t.setLocale(o?"zh-Hans":"zh-Hant"),children:[e.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),e.jsx("span",{className:"bim-rd-off",children:"|"}),e.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function Sp(t,n){if(!t)return;let o;for(const r of Array.from(t.querySelectorAll('[id^="rd-e-"]')))if(r.getBoundingClientRect().top<=n+8)o=r.id;else break;return o}function $p(t){var l;if(typeof window>"u"||!t)return;const n=(l=window.getSelection)==null?void 0:l.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const o=t.querySelector(".bim-rd-col"),r=a=>{const d=(a==null?void 0:a.nodeType)===1?a:a==null?void 0:a.parentElement;return!!a&&!!(o!=null&&o.contains(a))&&!(d!=null&&d.closest(".bim-rd-src, .bim-rd-pager"))};if(!r(n.anchorNode)||!r(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function tl({title:t,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:l,tocCaption:a,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:u="auto",prefs:g,onPrefsChange:m,paragraphToggle:h,properNameToggle:f=!0,allowVertical:v,byline:y,current:k,workLinkToggle:b,rail:j,onReportError:w,revisedAt:S,backHref:$,backLabel:_,bottomBar:C=!0,pager:I=!0,pagerUnit:T,versions:z,currentVersionKey:H,onVersionChange:W,versionSource:A=!0,keepChapterOnVersionChange:Y=!1,children:G,className:te,style:pe}){const{t:B,convert:E}=K(),ee=_??B("reader.back"),L=E(T??B("reader.unitJuan")),U=x.useId().replace(/:/g,""),de=`bim-rd-toc-${U}`,ve=`bim-rd-text-${U}`,Z=x.useRef(null),ce=x.useRef(null),be=x.useRef(null),We=x.useRef(null),ye=lr(Vs,!0),_e=lr(Ys,!1),He=C&&_e,[Be,Re]=x.useState(null),ze=x.useRef(null),Ee=x.useRef(null),D=(O,we)=>{Ee.current=we,Re(je=>je===O?null:O)},ae=x.useCallback(()=>{var O;Re(null),(O=Ee.current)==null||O.focus()},[]);x.useEffect(()=>{He||Re(null)},[He]),x.useEffect(()=>{var O,we;Be&&((we=(O=ze.current)==null?void 0:O.querySelector("button:not([disabled])"))==null||we.focus())},[Be]);const[le,Se]=x.useState("auto"),F=le==="auto"?ye:le==="open",me=!ye,Ae=!!d&&d.length>0,[R,Q]=x.useState(u);x.useEffect(()=>{Q(u)},[u]);const xe=R==="auto"?Ae||!!c:R==="open",N=x.useCallback(O=>{var we;Se("auto"),O&&((we=We.current)==null||we.focus())},[]),ne=()=>Se(F?"closed":"open");x.useEffect(()=>{if(!me||le!=="open")return;const O=be.current,we=O==null?void 0:O.querySelector('input, [data-rd-toc-key][tabindex="0"]');we==null||we.focus()},[me,le]);const J=x.useCallback(O=>{s(O),me&&N(!1);const we=ce.current,je=Z.current;if(we&&je&&typeof window<"u"){const oe=we.getBoundingClientRect().top-je.getBoundingClientRect().bottom;oe<0&&window.scrollBy({top:oe})}},[s,me,N]),re=x.useMemo(()=>el(o),[o]),[Ce,Le]=x.useState(null),$e=Qs(z,H!==void 0?H:Ce),X=($e==null?void 0:$e.key)??null,Ie=x.useMemo(()=>re.map(O=>O.key).join(`
|
|
519
|
-
`),[re]),fe=x.useRef(null),Me=O=>{O!==X&&(Y||(fe.current={key:O,sig:Ie,done:!1}),H===void 0&&Le(O),W==null||W(O))};x.useEffect(()=>{const O=fe.current;if(!O||O.key!==X)return;const we=re.find(oe=>!oe.disabled);if(!we)return;const je=Ie!==O.sig;!je&&O.done||(je?fe.current=null:O.done=!0,we.key!==r&&J(we.key))},[X,Ie,re,r,J]);const P=re.find(O=>O.key===r),q=()=>{var O;w==null||w({chapterKey:r,chapterLabel:typeof(P==null?void 0:P.label)=="string"?P.label:void 0,anchor:Sp(ce.current,((O=Z.current)==null?void 0:O.getBoundingClientRect().bottom)??0),selectedText:$p(ce.current)})},se=re.findIndex(O=>O.key===r),ue=se>0?re.slice(0,se).reverse().find(O=>!O.disabled):void 0,ie=se>=0?re.slice(se+1).find(O=>!O.disabled):void 0,M=g.fontSize??bi,ge={...pe,...g.fontSize?{"--bimrd-fs":`${g.fontSize}px`}:null};return e.jsxs("div",{className:["bim-rd",g.writingMode==="vertical"&&v?"bim-rd-vertical":"",te].filter(Boolean).join(" "),"data-toc":le,"data-img":xe?"open":"closed","data-bb":He?"":void 0,style:ge,children:[e.jsx("style",{children:Ks}),e.jsx("a",{className:"bim-rd-skip",href:`#${ve}`,onClick:O=>{var we,je,oe;O.preventDefault(),(we=ce.current)==null||we.focus(),(oe=(je=ce.current)==null?void 0:je.scrollIntoView)==null||oe.call(je,{block:"start"})},children:B("reader.skipToText")}),e.jsxs("div",{className:"bim-rd-bar",ref:Z,children:[$&&e.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":B("reader.backAria",{label:ee}),children:[e.jsx("span",{"aria-hidden":"true",children:"‹"}),e.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:ee})]}),(t||n||y||k)&&e.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[t&&e.jsx("b",{children:t}),y&&e.jsx("span",{className:"bim-rd-by",children:y}),k&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-rd-cur",children:k})]}),n&&e.jsx("span",{children:n})]}),e.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":B("reader.settings"),children:[z&&z.length>1&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"bim-rd-ver",title:$e?E(yi($e)):void 0,children:[e.jsx("span",{className:"bim-rd-tlabel",children:B("reader.version")}),e.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:B("reader.versionShort")}),e.jsx("select",{"aria-label":B("reader.version"),value:X??"",onChange:O=>Me(O.target.value),children:z.map(O=>e.jsx("option",{value:O.key,children:E(yi(O))},O.key))})]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),I&&(ue||ie)&&e.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":B("reader.pagerGroup",{unit:L}),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.prevUnit",{unit:L}),title:ue?typeof ue.label=="string"&&ue.label?B("reader.prevUnitTitle",{unit:L,label:ue.label}):B("reader.prevUnit",{unit:L}):B("reader.firstUnit",{unit:L}),disabled:!ue,onClick:()=>ue&&J(ue.key),children:e.jsx(vp,{})}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.nextUnit",{unit:L}),title:ie?typeof ie.label=="string"&&ie.label?B("reader.nextUnitTitle",{unit:L,label:ie.label}):B("reader.nextUnit",{unit:L}):B("reader.lastUnit",{unit:L}),disabled:!ie,onClick:()=>ie&&J(ie.key),children:e.jsx(kp,{})})]}),I&&(ue||ie)&&e.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),e.jsxs("button",{ref:We,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":F,"aria-controls":de,onClick:ne,children:[e.jsx(or,{}),e.jsx("span",{className:"bim-rd-tlabel",children:B("reader.toc")})]}),e.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":xe,onClick:()=>Q(xe?"closed":"open"),children:[e.jsx(rr,{}),B("reader.images")]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx(wp,{}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":B("reader.fontSmaller"),disabled:M<=ut[0],onClick:()=>m({fontSize:xn(g.fontSize,-1)}),children:"A−"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":B("reader.fontLarger"),disabled:M>=ut[ut.length-1],onClick:()=>m({fontSize:xn(g.fontSize,1)}),children:"A+"}),(h||f||v)&&e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),h&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":g.readingMode==="paragraph",title:B("reader.paragraphTitle"),onClick:()=>m({readingMode:g.readingMode==="paragraph"?"line":"paragraph"}),children:B("reader.paragraph")}),b&&e.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[e.jsx("input",{type:"checkbox",checked:g.workLinks,onChange:O=>m({workLinks:O.target.checked})}),e.jsx("span",{children:B("reader.workLinks")})]}),f&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":g.properNames,title:B("reader.properNameTitle"),onClick:()=>m({properNames:!g.properNames}),children:B("reader.properName")}),v&&e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":g.writingMode==="vertical",onClick:()=>m({writingMode:g.writingMode==="vertical"?"horizontal":"vertical"}),children:B("reader.vertical")})]})]}),e.jsxs("div",{className:"bim-rd-body",children:[e.jsxs("div",{className:"bim-rd-toc",id:de,ref:be,role:me&&F?"dialog":void 0,"aria-modal":me&&F?!0:void 0,"aria-label":me&&F?B("reader.toc"):void 0,onKeyDown:O=>{if(!(!me||!F)){if(O.key==="Escape"){O.stopPropagation(),N(!0);return}O.key==="Tab"&&sr(O,be.current)}},children:[e.jsxs("div",{className:"bim-rd-toc-top",children:[e.jsxs("div",{className:"bim-rd-toc-head",children:[e.jsx("span",{children:a??B("reader.toc")}),me&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.closeToc"),onClick:()=>N(!0),children:"✕"})]}),l]}),e.jsx(Zs,{items:o,activeKey:r,onSelect:J})]}),e.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>N(!0)}),e.jsx("aside",{className:"bim-rd-img","aria-label":B("reader.images"),children:xe&&e.jsx(fi,{pages:d??null,loading:c,renderOverlay:p})}),e.jsxs("div",{className:"bim-rd-text",id:ve,ref:ce,tabIndex:-1,"data-rail":j||w?"true":void 0,children:[e.jsxs("div",{className:"bim-rd-col",children:[G,A&&$e&&($e.sourceName||$e.license)&&e.jsxs("p",{className:"bim-rd-src","data-version":$e.key,children:[$e.sourceName&&e.jsxs(e.Fragment,{children:[B("reader.sourceLabel")," ",$e.sourceUrl?e.jsx("a",{className:"bim-rd-link",href:$e.sourceUrl,target:"_blank",rel:"noreferrer",children:E($e.sourceName)}):E($e.sourceName)]}),$e.sourceName&&$e.license&&e.jsx("span",{className:"bim-rd-dot"}),$e.license&&e.jsx(e.Fragment,{children:B("reader.licenseOf",{license:$e.license})})]}),S&&e.jsx("p",{className:"bim-rd-src bim-rd-rev",children:B("reader.revisedAt",{date:S})}),w&&e.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:O=>O.preventDefault(),onClick:q,children:B("reader.reportError")})}),I&&(ue||ie)&&e.jsxs("nav",{className:"bim-rd-pager","aria-label":B("reader.pagerNav"),children:[ue?e.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>J(ue.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[e.jsx("span",{"aria-hidden":"true",children:"← "}),B("reader.prevUnit",{unit:L})]}),e.jsx("span",{className:"bim-rd-pglabel",children:ue.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",B("reader.firstUnit",{unit:L})]}),ie?e.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>J(ie.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[B("reader.nextUnit",{unit:L}),e.jsx("span",{"aria-hidden":"true",children:" →"})]}),e.jsx("span",{className:"bim-rd-pglabel",children:ie.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[B("reader.lastUnit",{unit:L})," →"]})]})]}),(j||w)&&e.jsxs("aside",{className:"bim-rd-rail","aria-label":B("reader.rail"),children:[j,w&&e.jsx("div",{className:"bim-rd-rail-acts",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:O=>O.preventDefault(),onClick:q,children:B("reader.reportError")})})]})]})]}),He&&e.jsxs("nav",{className:"bim-rd-bb","aria-label":B("reader.bottomBar"),children:[e.jsxs("button",{type:"button","aria-expanded":F,"aria-controls":de,onClick:()=>{Re(null),ne()},children:[e.jsx(or,{}),e.jsx("span",{children:B("reader.tocShort")})]}),e.jsxs("button",{type:"button","aria-expanded":Be==="img","aria-haspopup":"dialog",onClick:O=>D("img",O.currentTarget),children:[e.jsx(rr,{}),e.jsx("span",{children:B("reader.images")})]}),e.jsxs("button",{type:"button","aria-expanded":Be==="fs","aria-haspopup":"dialog",onClick:O=>D("fs",O.currentTarget),children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),e.jsx("span",{children:B("reader.fontSize")})]}),w&&e.jsxs("button",{type:"button",onMouseDown:O=>O.preventDefault(),onClick:()=>{Re(null),q()},children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),e.jsx("span",{children:B("reader.reportError")})]})]}),He&&Be&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:ae}),e.jsxs("div",{className:"bim-rd-sheet",ref:ze,role:"dialog","aria-modal":"true","aria-label":B(Be==="img"?"reader.images":"reader.fontSize"),onKeyDown:O=>{if(O.key==="Escape"){O.stopPropagation(),ae();return}O.key==="Tab"&&sr(O,ze.current)},children:[e.jsxs("div",{className:"bim-rd-sheet-head",children:[e.jsx("span",{children:B(Be==="img"?"reader.images":"reader.fontSize")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.close"),onClick:ae,children:"✕"})]}),Be==="img"?e.jsx("div",{className:"bim-rd-sheet-img",children:e.jsx(fi,{pages:d??null,loading:c,renderOverlay:p})}):e.jsxs("div",{className:"bim-rd-sheet-fs",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.fontSmaller"),disabled:M<=ut[0],onClick:()=>m({fontSize:xn(g.fontSize,-1)}),children:"A−"}),e.jsxs("output",{"aria-live":"polite",children:[M,"px"]}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.fontLarger"),disabled:M>=ut[ut.length-1],onClick:()=>m({fontSize:xn(g.fontSize,1)}),children:"A+"})]})]})]})]})}const nl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],_p={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Ge(t){return _p[t]??t}const At=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],Bt={熹平: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},il={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Bn(t){const n=t.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const o=parseInt(n[1],10);if(o<100||o>2100)return;const r=n[2]?parseInt(n[2],10):void 0;return{from:o,to:r!=null&&r>=o&&r<=2100?r:void 0}}function Cp(t){return t>=1950?"":t>=1912?"民國":t>=1645?"清":t>=1368?"明":t>=1279?"元":t>=960?"宋":t>=907?"五代":t>=618?"唐":t>=581?"隋":t>=420?"南北朝":t>=265?"晉":t>=220?"三國":t>=-202?"漢":""}const zp=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,ar={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function qi(t){const n=t.trim().replace(/[代朝]$/,"");for(const s of Object.keys(ar))if(n.startsWith(s))return ar[s];const o=Ge(n);if(wt[o]!=null)return o;const r=gt(n);if(r&&n.length<=r.length+1)return Ge(r)}function kt(t,n){if(n){const o=il[`${n}|${t}`];if(o!=null)return o}return Bt[t]}const Tp=1911;function Np(t){const n=Bt[t];if(n==null)return;const o=dt[t];let r;for(const[s,l]of Object.entries(Bt))dt[s]===o&&l>n&&(r==null||l<r)&&(r=l);return r!=null?r-1:void 0}const Ip={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Sn(t){if(!t)return;if(/^\d+$/.test(t))return parseInt(t,10);let n=0,o=0,r=!1;for(const l of t){const a=Ip[l];if(a===void 0)return;r=!0,l==="十"?o=(o||1)*10:l==="廿"||l==="卅"?(n+=a,o=0):o>=10?(n+=o+a,o=0):o=o*10+a}const s=n+o;return r&&s>0?s:void 0}function gt(t){for(const n of nl)if(t.startsWith(n))return n}const dt={};{const t=(n,o)=>{for(const r of o)dt[r]=n};t("東漢",["熹平","建安"]),t("三國",["黃初","正始"]),t("五代",["廣政"]),t("西晉",["太康"]),t("東晉",["永和"]),t("隋",["開皇"]),t("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),t("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),t("金",["大定","明昌"]),t("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),t("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),t("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),t("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function St(t,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(Bt))if(t.includes(r)&&!(o&&dt[r]&&dt[r]!==o&&il[`${o}|${r}`]==null))return r}function ln(t){var a,d,c;const n={era:"",reign:"",source:"none"},o=t.dating;if(o!=null&&o.era||o!=null&&o.reign)return{era:o.era??"",reign:o.reign??"",source:o.certainty==="attested"?"catalog":"edition"};const r=(a=t.lineage)==null?void 0:a.year_text;if(r){const p=gt(r)??"";return{era:Ge(p),reign:St(r,p)??"",source:"lineage"}}const s=(d=t.publication_info)==null?void 0:d.year;if(s){const p=Bn(s);if(p)return{era:Cp(p.from),reign:"",source:"publication"};const u=gt(s)??qi(s)??((c=At.find(h=>h.pattern.test(s)))==null?void 0:c.era)??"",g=St(s,u)??"",m=u||(g?dt[g]??"":"");if(m||g)return{era:Ge(m),reign:g,source:"publication"}}const l=t.edition||t.title||"";if(l){const p=gt(l);if(p)return{era:Ge(p),reign:St(l,p)??"",source:"edition"};const u=At.find(g=>g.pattern.test(l));if(u)return{era:Ge(u.era),reign:St(l,u.era)??u.reign??"",source:"edition"}}return n}function Mn(t){var r,s,l,a,d,c,p,u,g;if(((r=t.dating)==null?void 0:r.year)!=null)return t.dating.year;if(typeof((s=t.lineage)==null?void 0:s.year)=="number")return t.lineage.year;const n=(l=t.publication_info)==null?void 0:l.year;if(n){const m=Bn(n);if(m)return m.from}const o=[(a=t.lineage)==null?void 0:a.year_text,(d=t.publication_info)==null?void 0:d.year,t.edition,t.edition?void 0:t.title].filter(Boolean);for(const m of o){const h=((c=t.publication_info)==null?void 0:c.year)||((p=t.lineage)==null?void 0:p.year_text);if(h&&m!==h&&(gt(h)||qi(h)))break;const f=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(f){const j=parseInt(f[1],10);if(j>=100&&j<=2100)return j}const v=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(v){const j=gt(m);if(!j||Ge(j)==="民國"){const S=Sn(v[1]);if(S!=null&&S>=1&&S<=120)return Tp+S}}const y=gt(m)??((u=At.find(j=>j.pattern.test(m)))==null?void 0:u.era),k=y?Ge(y):void 0,b=St(m,k)??(gt(m)||(g=At.find(j=>j.pattern.test(m)))==null?void 0:g.reign);if(b){const j=kt(b,k);if(j==null)continue;const w=m.indexOf(b),S=w>=0?m.slice(w+b.length):"",$=S.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??S.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=$?Sn($[1]):void 0;return j+(_?_-1:0)}}}function Zi(t){var a,d,c,p,u,g;const n=(a=t.dating)==null?void 0:a.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const o=(d=t.lineage)==null?void 0:d.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=t.lineage)==null?void 0:c.year_text;if(r){const m=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const h=ji[Ge(m[1])],f=wt[Ge(m[2])];if(h!=null&&f!=null)return{from:Math.min(h,f)-20,to:Math.max(h,f)+40}}}const s=(p=t.publication_info)==null?void 0:p.year;if(s){const m=Bn(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const h=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const f=ji[Ge(h[1])],v=wt[Ge(h[2])];if(f!=null&&v!=null)return{from:Math.min(f,v)-20,to:Math.max(f,v)+40}}}const l=[(u=t.publication_info)==null?void 0:u.year,t.edition,t.title].filter(Boolean);for(const m of l){if(!/[間间]/.test(m))continue;const h=gt(m)??qi(m)??((g=At.find(y=>y.pattern.test(m)))==null?void 0:g.era),f=h?Ge(h):void 0,v=[];for(const y of Object.keys(Bt))m.includes(y)&&(f&&dt[y]&&dt[y]!==f||kt(y,f)!=null&&v.push(y));if(v.length===0){const y=m.match(/([一-鿿])([一-鿿])[間间]/);if(y&&f){for(const k of[y[1],y[2]])for(const b of Object.keys(Bt))if(dt[b]===f&&!(b[0]!==k&&b[b.length-1]!==k)&&kt(b,f)!=null){v.push(b);break}}}if(v.length>0){const y=v.map(w=>kt(w,f)).filter(w=>w!=null),k=Math.min(...y),b=v.reduce((w,S)=>kt(w,f)>=kt(S,f)?w:S),j=Np(b)??ii(f??"")??Math.max(...y);return{from:k,to:j>k?j:ii(f??dt[b]??"")??k}}if(f&&wt[f]!=null)return{from:wt[f],to:ii(f)??wt[f]}}}const wt={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Ep=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Rp=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,cr=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function dr(t,n){for(const o of nl){const r=t.indexOf(o);if(r<0)continue;if(o.length===1){const c=t[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!St(t.slice(r),Ge(o)))continue}const s=Ge(o);if(s===n)continue;const l=t.slice(r),a=St(l,s)??"";let d;if(a){const c=kt(a,s);if(c!=null){const u=l.slice(l.indexOf(a)+a.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),g=u?Sn(u[1]):void 0;d=c+(g?g-1:0)}}return{era:s,reign:a,year:d}}for(const o of At)if(o.pattern.test(t))return{era:Ge(o.era),reign:o.reign??""}}function Lp(t){var k,b,j,w,S;const n=ln(t),o=((k=t.publication_info)==null?void 0:k.year)??"",r=o?Bn(o):void 0;if(!n.era&&!n.reign&&!r)return;const s=t.edition||t.title||"",l=/[間间]/.test(s),a=((b=t.lineage)==null?void 0:b.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(a),c=n.source==="publication"&&zp.test(o),p=n.source==="publication"&&/[間间]/.test(o),u=a.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let g;l||d||c||p?g=void 0:u?g=parseInt(u[2],10):g=Mn(t);const m=g==null?Zi(t):void 0;let h;n.source==="publication"&&(c||cr.test(o))?h="uncertain":n.source==="lineage"||n.source==="publication"?h="attested":cr.test(s)||!n.reign&&g==null?h="uncertain":h="inferred";const f=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((j=t.lineage)==null?void 0:j.year_text)??((w=t.lineage)==null?void 0:w.year)??""}」`:`出版著錄「${((S=t.publication_info)==null?void 0:S.year)??""}」`,v={era:n.era,reign:n.reign,year:g,yearRange:m,certainty:h,source:n.source==="edition"?"edition":"catalog",basis:f};if(u){const $=a.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==v.era&&(v.laterRepair={era:$[1]})}if(!v.laterRepair&&Rp.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(v.laterRepair={era:$[1]})}const y=Ep.find($=>$.re.test(s));if(y){const $=s.search(y.re),_=s.slice($),C=dr(_,n.era)??dr(s,n.era);C&&(v.basedOn={era:C.era,reign:C.reign,year:C.year,relation:y.relation})}return v}const ji={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function ii(t){return ji[t]}function $n(t){const n=Mn(t);if(n!=null)return n;const o=Zi(t);if(o)return o.from;const r=ln(t).era;return r?wt[r]:void 0}const pr=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function vi(t){const n=pr.indexOf(t);return n===-1?pr.length:n}function Pp(t){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of t){const l=s.relation;l==="part_of"?n.belongsTo.push(s):l==="collected_in"?n.collected.push(s):l==="has_part"||l==="contains_text_of"?n.contains.push(s):l==="text_carried_by"||l==="studied_by"||l==="derived_from"||l==="followed_by"||l==="has_adaptation"?n.derivative.push(s):l==="studies"||l==="preceded_by"?n.studies.push(s):n.related.push(s)}const o=[],r=(s,l)=>{n[s].length&&o.push({key:s,labelKey:l,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function Ji(t,n){const o=Bi(t||[]),r=new Map,s=[];for(const p of o)p.group?(r.has(p.group)||r.set(p.group,[]),r.get(p.group).push(p)):s.push(p);for(const p of r.values())p.sort((u,g)=>{const m=h=>h.group_role==="origin"?0:h.group_role==="mirror"?1:2;return m(u)-m(g)});const l={text:[],image:[],textImage:[],physical:[]};for(const p of s){const u=zt(p),g=u.includes("text"),m=u.includes("image");g&&m?l.textImage.push(p):g?l.text.push(p):m?l.image.push(p):l.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>l[p].length>0).map(p=>({key:p,items:l[p]})),c=[...r.entries()].map(([p,u])=>{var g,m;return{key:p,label:((g=n==null?void 0:n[p])==null?void 0:g.label)||p,description:(m=n==null?void 0:n[p])==null?void 0:m.description,items:u}});return{buckets:d,mirrors:c,total:o.length}}function Wn(t,n=Ht("zh-Hant")){const o=[],r=t.metadata||{};r.edition&&o.push(String(r.edition)),t.source_label&&o.push(t.source_label),t.details&&o.push(t.details);const s=In(t);return s&&s.expected>0&&o.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})),r.version&&o.push(String(r.version)),o.join(" · ")}function ol(t,n){if(Wn(t)||n.filter(r=>r.name===t.name).length<2)return"";try{const r=new URL(t.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const l=r.pathname.split("/").filter(Boolean).pop();if(l)return decodeURIComponent(l)}catch{}return""}function rl(t,n){var l,a;const o=t.resources||[],r=[],s=[];for(const d of o){const c=zt(d);c.includes("image")&&r.push(d),c.includes("physical")&&s.push(d)}return{id:t.id,name:t.edition||t.title||t.id,era:ln(t),year:Mn(t),sortYear:$n(t),images:r,holders:s,locationName:(l=t.current_location)==null?void 0:l.name,important:Ap(t.id,n),group:(a=n==null?void 0:n.node_groups)==null?void 0:a[t.id],hasImage:r.length>0}}function Ap(t,n){var d,c;if(!n)return!1;const o=n.default_collection;if(!o)return!1;const r=(d=n.collections)==null?void 0:d[o];if(((r==null?void 0:r.book_ids)??(o==="core"?n.core_books??[]:[])).includes(t))return!0;const l=(r==null?void 0:r.groups)??[],a=(c=n.node_groups)==null?void 0:c[t];return!!a&&l.includes(a)}function sl(t,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=t.filter(c=>!r.has(c.id)).map(c=>rl(c,n));let l=s;o.era&&(l=l.filter(c=>c.era.era===o.era)),o.scanOnly&&(l=l.filter(c=>c.hasImage)),o.sort==="year"?l=l.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const u=c.r.sortYear,g=p.r.sortYear;return u!=null&&g!=null?u-g||c.i-p.i:u!=null?-1:g!=null?1:c.i-p.i}).map(c=>c.r):l=l.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const u=g=>(g.important?0:1)*2+(g.hasImage?0:1);return u(c.r)-u(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)=>vi(c)-vi(p));return{rows:l,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Bp(t,n){var y,k;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,groupedIds:[]};const o=(y=n.collections)==null?void 0:y[n.default_collection],r=(o==null?void 0:o.groups)??[],s=(o==null?void 0:o.book_ids)??[],l=r.length>0||s.length>0,a=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&a.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const d=new Set(r),c=new Set([...s,...a]),p=b=>{if(c.has(b))return!0;const j=n.node_groups[b];return j!=null&&d.has(j)},u=[],g=new Map,m=[];for(const b of t)if(!((k=n.excluded_books)!=null&&k.includes(b)))if(p(b))u.push(b);else{const j=n.node_groups[b];j?(g.has(j)||g.set(j,[]),g.get(j).push(b)):m.push(b)}if(m.length+[...g.values()].reduce((b,j)=>b+j.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const f=new Map((n.groups??[]).map(b=>[b.id,b])),v=[...g.entries()].map(([b,j])=>{const w=f.get(b);return{id:b,label:(w==null?void 0:w.label)??b,description:w==null?void 0:w.description,ids:j}});return m.length>0&&v.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:u,groupedIds:v}}const ll=["撰","編","注","校","譯","繪","其他"],Mp=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Xi(t){if(!t||!t.trim())return"撰";const n=t.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of Mp)if(r.test(n))return o;return"其他"}function Qi(t){if(!t)return"";const n=t.trim();return!n||!/[一-鿿]/.test(n)?"":n}function al(t,n="全部"){const o=new Map;for(const s of t){const l=Xi(s);o.set(l,(o.get(l)??0)+1)}const r=[{cls:"全部",label:n,count:t.length}];for(const s of ll){const l=o.get(s);l&&r.push({cls:s,label:s,count:l})}return r.length>2?r:[]}function cl(t,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(a=>({id:a.work_id||a.book_id||void 0,title:a.title,section:a.section,volumes:a.volumes||[],subItems:a.sub_items,edition:a.edition,found:a.found_volumes,expected:a.expected_volumes})),l=[...new Set(s.map(a=>a.section).filter(Boolean))];return{rows:s,source:"catalog",sections:l,totalVolumes:n.total_volumes}}return t.contained_works&&t.contained_works.length>0?{rows:t.contained_works.map(l=>({id:l.id,title:l.title,volumes:nn(l.volume_index)})),source:"works",sections:[]}:{rows:(t.books||[]).map(s=>{var l,a;return{id:s,title:((l=o==null?void 0:o.get(s))==null?void 0:l.title)||s,edition:(a=o==null?void 0:o.get(s))==null?void 0:a.edition,volumes:[]}}),source:"books",sections:[]}}function nn(t){if(t==null)return[];if(typeof t=="number")return[t];if(Array.isArray(t))return t.filter(n=>typeof n=="number");if(typeof t=="string"){const n=t.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[o,r]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,r-o+1)},(s,l)=>o+l)}return t.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function Hn(t,n="冊"){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=[...t].sort((l,a)=>l-a),r=o[0],s=o[o.length-1];return s-r+1===o.length?`${r}–${s}`:o.length<=3?o.join(", "):`${r}–${s} (${o.length}${n})`}const Wp=["〇","一","二","三","四","五","六","七","八","九"],ur=["","十","百","千"];function dl(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),d=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&d===1&&l===0?r+=ur[d]:r+=Wp[a]+ur[d])}return r}function Hp(t){return t==null?"":typeof t=="string"?t:t.title??""}function xt(t,n="卷"){var r,s;const o=t;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?dl(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function pl(t){var r;if(t.edition_type)return t.edition_type;if((r=t.lineage)!=null&&r.category)return t.lineage.category;const n=t.edition||t.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,l]of o)if(s.test(n))return l;return""}const Op=216,mr="clamp(280px, 23vw, 360px)",Fp=1440,ki="(max-width: 719px)",Dp=`${ki}, (pointer: coarse)`,Up=`
|
|
520
|
-
.bim-d-main.bim-d-main-grid { max-width: ${
|
|
518
|
+
`;function Ji(t,n){var o;return n?t.key===n?!0:!!((o=t.children)!=null&&o.some(r=>Ji(r,n))):!1}const zp=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Tp({item:t,activeKey:n,onSelect:o,tabKey:r}){const s=Ji(t,n),[l,a]=x.useState(s||!!t.defaultExpanded);return x.useEffect(()=>{s&&a(!0)},[s]),x.useEffect(()=>{t.defaultExpanded&&a(!0)},[t.defaultExpanded]),e.jsxs("li",{children:[e.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":t.key,tabIndex:r===t.key?0:-1,onClick:()=>a(p=>!p),children:[e.jsx(zp,{}),e.jsx("span",{children:t.label}),t.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:t.hint})]}),l&&e.jsx(el,{items:t.children,activeKey:n,onSelect:o,tabKey:r})]})}function el({items:t,activeKey:n,onSelect:o,tabKey:r}){return e.jsx("ul",{children:t.map(s=>s.children&&s.children.length>0?e.jsx(Tp,{item:s,activeKey:n,onSelect:o,tabKey:r},s.key):e.jsx("li",{children:e.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:r===s.key?0:-1,onClick:()=>o(s.key),children:[e.jsx("span",{children:s.label}),s.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function rr(t,n){var o;for(const r of t)if(r.key===n||Ji(r,n))return r.key;return((o=t[0])==null?void 0:o.key)??null}function tl({items:t,activeKey:n,onSelect:o,label:r}){const{t:s}=G(),l=r??s("reader.toc"),a=x.useRef(null),[p,c]=x.useState(null);x.useEffect(()=>{c(null)},[n]);const d=x.useMemo(()=>p||(n??rr(t,n)),[p,n,t]);x.useEffect(()=>{const g=a.current;if(!g)return;const m=Array.from(g.querySelectorAll("[data-rd-toc-key]"));if(m.length===0)return;const h=m.find(f=>f.dataset.rdTocKey===d)??m.find(f=>f.dataset.rdTocKey===rr(t,n))??m.find(f=>!f.disabled)??m[0];for(const f of m)f.tabIndex=f===h?0:-1}),x.useEffect(()=>{const g=a.current,m=g==null?void 0:g.closest(".bim-rd-toc");if(!g||!m||!n)return;const h=Array.from(g.querySelectorAll("[data-rd-toc-key]")).find(v=>v.dataset.rdTocKey===n);if(!h)return;const f=h.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;(f<m.scrollTop+80||f>m.scrollTop+m.clientHeight-40)&&(m.scrollTop=Math.max(0,f-m.clientHeight/3))},[n]);const u=x.useCallback(g=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(g.key))return;const h=a.current;if(!h)return;const f=Array.from(h.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),v=f.indexOf(document.activeElement);let y=v;if(g.key==="ArrowDown"?y=Math.min(f.length-1,v+1):g.key==="ArrowUp"?y=Math.max(0,v-1):g.key==="Home"?y=0:g.key==="End"&&(y=f.length-1),y<0||y===v)return;g.preventDefault();const w=f[y];for(const b of f)b.tabIndex=-1;w.tabIndex=0,w.focus(),c(w.dataset.rdTocKey??null)},[]);return e.jsx("div",{ref:a,role:"navigation","aria-label":l,onKeyDown:u,children:e.jsx(el,{items:t,activeKey:n,onSelect:o,tabKey:d})})}function Np({page:t}){var n;return!((n=t.boxes)!=null&&n.length)||!t.width||!t.height||t.boxFormat&&t.boxFormat!=="bim-charbox-v0"?null:e.jsx("svg",{viewBox:`0 0 ${t.width} ${t.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:t.boxes.map((o,r)=>e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:i("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},r))})}function vi({pages:t,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:l}=G(),[a,p]=x.useState(0),c=o??a,d=h=>{r?r(h):p(h)};if(x.useEffect(()=>{o===void 0&&p(0)},[t,o]),n)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!t||t.length===0)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("div",{className:"bim-rd-img-empty",children:[e.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),e.jsx("b",{children:l("reader.noImages")}),e.jsx("span",{children:l("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(t.length-1,c)),g=t[u],m=g.label??`${u+1}`;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("figure",{className:"bim-rd-img-fig",children:[e.jsx("img",{src:g.url,alt:g.alt??l("reader.imageAlt",{label:m}),width:g.width,height:g.height,loading:"lazy",decoding:"async"}),e.jsx(Np,{page:g}),s==null?void 0:s(g,u)]})}),t.length>1&&e.jsxs("div",{className:"bim-rd-img-pager",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:u===0,onClick:()=>d(u-1),children:"‹"}),e.jsx("span",{"aria-live":"polite",children:g.label??`${u+1} / ${t.length}`}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:u===t.length-1,onClick:()=>d(u+1),children:"›"})]})]})}const Xi={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},gt=[15,16,17,18,20,22,24],ki=18,nl="bim-reader-prefs",Ip="bim-reading-mode";function Rp(){const t={...Xi};try{const n=localStorage.getItem(nl),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&>.includes(o.fontSize)&&(t.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(Ip))==="paragraph"&&(t.readingMode="paragraph"),o.properNames===!0&&(t.properNames=!0),o.writingMode==="vertical"&&(t.writingMode="vertical"),o.workLinks===!1&&(t.workLinks=!1)}catch{}return t}function Ep(t){try{localStorage.setItem(nl,JSON.stringify(t))}catch{}}function yn(t,n){const o=t??ki,r=gt;let s=r.indexOf(o);return s<0&&(s=r.indexOf(ki)),r[Math.max(0,Math.min(r.length-1,s+n))]}function il(){const[t,n]=x.useState(Xi);x.useEffect(()=>{n(Rp())},[]);const o=x.useCallback(r=>{n(s=>{const l={...s,...r};return Ep(l),l})},[]);return[t,o]}function wi(t){if(t.optionLabel)return t.optionLabel;const n=t.label||t.key;return!t.sourceName||n.includes(t.sourceName)?n:`${n} · ${t.sourceName}`}function ol(t,n){if(!(!t||t.length===0))return(n!=null?t.find(o=>o.key===n):void 0)??t.find(o=>o.primary)??t[0]}function rl(t){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(t),n}const sr=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),Lp=()=>e.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:e.jsx("path",{d:"M15 5l-7 7 7 7"})}),Pp=()=>e.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:e.jsx("path",{d:"M9 5l7 7-7 7"})}),lr=()=>e.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:[e.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),e.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function ar(t,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(a=>a.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],l=document.activeElement;t.shiftKey&&(l===r||!n.contains(l))?(t.preventDefault(),s.focus()):!t.shiftKey&&(l===s||!n.contains(l))&&(t.preventDefault(),r.focus())}function cr(t,n){const[o,r]=x.useState(n);return x.useEffect(()=>{var a;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(t);r(s.matches);const l=()=>r(s.matches);return(a=s.addEventListener)==null||a.call(s,"change",l),()=>{var p;return(p=s.removeEventListener)==null?void 0:p.call(s,"change",l)}},[t]),o}function Ap(){const t=x.useContext(It),{t:n}=G();if(!t)return null;const o=t.locale==="zh-Hant";return e.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>t.setLocale(o?"zh-Hans":"zh-Hant"),children:[e.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),e.jsx("span",{className:"bim-rd-off",children:"|"}),e.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function Bp(t,n){if(!t)return;let o;for(const r of Array.from(t.querySelectorAll('[id^="rd-e-"]')))if(r.getBoundingClientRect().top<=n+8)o=r.id;else break;return o}function Mp(t){var l;if(typeof window>"u"||!t)return;const n=(l=window.getSelection)==null?void 0:l.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const o=t.querySelector(".bim-rd-col"),r=a=>{const p=(a==null?void 0:a.nodeType)===1?a:a==null?void 0:a.parentElement;return!!a&&!!(o!=null&&o.contains(a))&&!(p!=null&&p.closest(".bim-rd-src, .bim-rd-pager"))};if(!r(n.anchorNode)||!r(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function sl({title:t,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:l,tocCaption:a,images:p,imagesLoading:c,renderImageOverlay:d,imagePanel:u="auto",prefs:g,onPrefsChange:m,paragraphToggle:h,properNameToggle:f=!0,allowVertical:v,byline:y,current:w,workLinkToggle:b,rail:j,onReportError:S,revisedAt:k,backHref:$,backLabel:_,bottomBar:z=!0,pager:E=!0,pagerUnit:T,versions:C,currentVersionKey:O,onVersionChange:W,versionSource:P=!0,keepChapterOnVersionChange:Y=!1,children:V,className:Q,style:ge}){const{t:A,convert:I}=G(),Z=_??A("reader.back"),ee=I(T??A("reader.unitJuan")),ce=x.useId().replace(/:/g,""),fe=`bim-rd-toc-${ce}`,Ie=`bim-rd-text-${ce}`,q=x.useRef(null),M=x.useRef(null),K=x.useRef(null),Re=x.useRef(null),se=cr(Zs,!0),ye=cr(Xs,!1),We=z&&ye,[Be,Ee]=x.useState(null),Ce=x.useRef(null),He=x.useRef(null),D=(B,be)=>{He.current=be,Ee(_e=>_e===B?null:B)},re=x.useCallback(()=>{var B;Ee(null),(B=He.current)==null||B.focus()},[]);x.useEffect(()=>{We||Ee(null)},[We]),x.useEffect(()=>{var B,be;Be&&((be=(B=Ce.current)==null?void 0:B.querySelector("button:not([disabled])"))==null||be.focus())},[Be]);const[de,ke]=x.useState("auto"),F=de==="auto"?se:de==="open",he=!se,Ne=!!p&&p.length>0,[R,ne]=x.useState(u);x.useEffect(()=>{ne(u)},[u]);const ue=R==="auto"?Ne||!!c:R==="open",L=x.useCallback(B=>{var be;ke("auto"),B&&((be=Re.current)==null||be.focus())},[]),te=()=>ke(F?"closed":"open");x.useEffect(()=>{if(!he||de!=="open")return;const B=K.current,be=B==null?void 0:B.querySelector('input, [data-rd-toc-key][tabindex="0"]');be==null||be.focus()},[he,de]);const U=x.useCallback(B=>{s(B),he&&L(!1);const be=M.current,_e=q.current;if(be&&_e&&typeof window<"u"){const je=be.getBoundingClientRect().top-_e.getBoundingClientRect().bottom;je<0&&window.scrollBy({top:je})}},[s,he,L]),le=x.useMemo(()=>rl(o),[o]),[we,Le]=x.useState(null),Se=ol(C,O!==void 0?O:we),Fe=(Se==null?void 0:Se.key)??null,De=x.useMemo(()=>le.map(B=>B.key).join(`
|
|
519
|
+
`),[le]),J=x.useRef(null),Pe=B=>{B!==Fe&&(Y||(J.current={key:B,sig:De,done:!1}),O===void 0&&Le(B),W==null||W(B))};x.useEffect(()=>{const B=J.current;if(!B||B.key!==Fe)return;const be=le.find(je=>!je.disabled);if(!be)return;const _e=De!==B.sig;!_e&&B.done||(_e?J.current=null:B.done=!0,be.key!==r&&U(be.key))},[Fe,De,le,r,U]);const N=le.find(B=>B.key===r),X=()=>{var B;S==null||S({chapterKey:r,chapterLabel:typeof(N==null?void 0:N.label)=="string"?N.label:void 0,anchor:Bp(M.current,((B=q.current)==null?void 0:B.getBoundingClientRect().bottom)??0),selectedText:Mp(M.current)})},ae=le.findIndex(B=>B.key===r),ie=ae>0?le.slice(0,ae).reverse().find(B=>!B.disabled):void 0,pe=ae>=0?le.slice(ae+1).find(B=>!B.disabled):void 0,$e=g.fontSize??ki,H={...ge,...g.fontSize?{"--bimrd-fs":`${g.fontSize}px`}:null};return e.jsxs("div",{className:["bim-rd",g.writingMode==="vertical"&&v?"bim-rd-vertical":"",Q].filter(Boolean).join(" "),"data-toc":de,"data-img":ue?"open":"closed","data-bb":We?"":void 0,style:H,children:[e.jsx("style",{children:Qs}),e.jsx("a",{className:"bim-rd-skip",href:`#${Ie}`,onClick:B=>{var be,_e,je;B.preventDefault(),(be=M.current)==null||be.focus(),(je=(_e=M.current)==null?void 0:_e.scrollIntoView)==null||je.call(_e,{block:"start"})},children:A("reader.skipToText")}),e.jsxs("div",{className:"bim-rd-bar",ref:q,children:[$&&e.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":A("reader.backAria",{label:Z}),children:[e.jsx("span",{"aria-hidden":"true",children:"‹"}),e.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:Z})]}),(t||n||y||w)&&e.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[t&&e.jsx("b",{children:t}),y&&e.jsx("span",{className:"bim-rd-by",children:y}),w&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-rd-cur",children:w})]}),n&&e.jsx("span",{children:n})]}),e.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":A("reader.settings"),children:[C&&C.length>1&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"bim-rd-ver",title:Se?I(wi(Se)):void 0,children:[e.jsx("span",{className:"bim-rd-tlabel",children:A("reader.version")}),e.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:A("reader.versionShort")}),e.jsx("select",{"aria-label":A("reader.version"),value:Fe??"",onChange:B=>Pe(B.target.value),children:C.map(B=>e.jsx("option",{value:B.key,children:I(wi(B))},B.key))})]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),E&&(ie||pe)&&e.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":A("reader.pagerGroup",{unit:ee}),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.prevUnit",{unit:ee}),title:ie?typeof ie.label=="string"&&ie.label?A("reader.prevUnitTitle",{unit:ee,label:ie.label}):A("reader.prevUnit",{unit:ee}):A("reader.firstUnit",{unit:ee}),disabled:!ie,onClick:()=>ie&&U(ie.key),children:e.jsx(Lp,{})}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.nextUnit",{unit:ee}),title:pe?typeof pe.label=="string"&&pe.label?A("reader.nextUnitTitle",{unit:ee,label:pe.label}):A("reader.nextUnit",{unit:ee}):A("reader.lastUnit",{unit:ee}),disabled:!pe,onClick:()=>pe&&U(pe.key),children:e.jsx(Pp,{})})]}),E&&(ie||pe)&&e.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),e.jsxs("button",{ref:Re,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":F,"aria-controls":fe,onClick:te,children:[e.jsx(sr,{}),e.jsx("span",{className:"bim-rd-tlabel",children:A("reader.toc")})]}),e.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":ue,onClick:()=>ne(ue?"closed":"open"),children:[e.jsx(lr,{}),A("reader.images")]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx(Ap,{}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontSmaller"),disabled:$e<=gt[0],onClick:()=>m({fontSize:yn(g.fontSize,-1)}),children:"A−"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontLarger"),disabled:$e>=gt[gt.length-1],onClick:()=>m({fontSize:yn(g.fontSize,1)}),children:"A+"}),(h||f||v)&&e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),h&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":g.readingMode==="paragraph",title:A("reader.paragraphTitle"),onClick:()=>m({readingMode:g.readingMode==="paragraph"?"line":"paragraph"}),children:A("reader.paragraph")}),b&&e.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[e.jsx("input",{type:"checkbox",checked:g.workLinks,onChange:B=>m({workLinks:B.target.checked})}),e.jsx("span",{children:A("reader.workLinks")})]}),f&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":g.properNames,title:A("reader.properNameTitle"),onClick:()=>m({properNames:!g.properNames}),children:A("reader.properName")}),v&&e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":g.writingMode==="vertical",onClick:()=>m({writingMode:g.writingMode==="vertical"?"horizontal":"vertical"}),children:A("reader.vertical")})]})]}),e.jsxs("div",{className:"bim-rd-body",children:[e.jsxs("div",{className:"bim-rd-toc",id:fe,ref:K,role:he&&F?"dialog":void 0,"aria-modal":he&&F?!0:void 0,"aria-label":he&&F?A("reader.toc"):void 0,onKeyDown:B=>{if(!(!he||!F)){if(B.key==="Escape"){B.stopPropagation(),L(!0);return}B.key==="Tab"&&ar(B,K.current)}},children:[e.jsxs("div",{className:"bim-rd-toc-top",children:[e.jsxs("div",{className:"bim-rd-toc-head",children:[e.jsx("span",{children:a??A("reader.toc")}),he&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.closeToc"),onClick:()=>L(!0),children:"✕"})]}),l]}),e.jsx(tl,{items:o,activeKey:r,onSelect:U})]}),e.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>L(!0)}),e.jsx("aside",{className:"bim-rd-img","aria-label":A("reader.images"),children:ue&&e.jsx(vi,{pages:p??null,loading:c,renderOverlay:d})}),e.jsxs("div",{className:"bim-rd-text",id:Ie,ref:M,tabIndex:-1,"data-rail":j||S?"true":void 0,children:[e.jsxs("div",{className:"bim-rd-col",children:[V,P&&Se&&(Se.sourceName||Se.license)&&e.jsxs("p",{className:"bim-rd-src","data-version":Se.key,children:[Se.sourceName&&e.jsxs(e.Fragment,{children:[A("reader.sourceLabel")," ",Se.sourceUrl?e.jsx("a",{className:"bim-rd-link",href:Se.sourceUrl,target:"_blank",rel:"noreferrer",children:I(Se.sourceName)}):I(Se.sourceName)]}),Se.sourceName&&Se.license&&e.jsx("span",{className:"bim-rd-dot"}),Se.license&&e.jsx(e.Fragment,{children:A("reader.licenseOf",{license:Se.license})})]}),k&&e.jsx("p",{className:"bim-rd-src bim-rd-rev",children:A("reader.revisedAt",{date:k})}),S&&e.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:B=>B.preventDefault(),onClick:X,children:A("reader.reportError")})}),E&&(ie||pe)&&e.jsxs("nav",{className:"bim-rd-pager","aria-label":A("reader.pagerNav"),children:[ie?e.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>U(ie.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[e.jsx("span",{"aria-hidden":"true",children:"← "}),A("reader.prevUnit",{unit:ee})]}),e.jsx("span",{className:"bim-rd-pglabel",children:ie.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",A("reader.firstUnit",{unit:ee})]}),pe?e.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>U(pe.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[A("reader.nextUnit",{unit:ee}),e.jsx("span",{"aria-hidden":"true",children:" →"})]}),e.jsx("span",{className:"bim-rd-pglabel",children:pe.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[A("reader.lastUnit",{unit:ee})," →"]})]})]}),(j||S)&&e.jsxs("aside",{className:"bim-rd-rail","aria-label":A("reader.rail"),children:[j,S&&e.jsx("div",{className:"bim-rd-rail-acts",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:B=>B.preventDefault(),onClick:X,children:A("reader.reportError")})})]})]})]}),We&&e.jsxs("nav",{className:"bim-rd-bb","aria-label":A("reader.bottomBar"),children:[e.jsxs("button",{type:"button","aria-expanded":F,"aria-controls":fe,onClick:()=>{Ee(null),te()},children:[e.jsx(sr,{}),e.jsx("span",{children:A("reader.tocShort")})]}),e.jsxs("button",{type:"button","aria-expanded":Be==="img","aria-haspopup":"dialog",onClick:B=>D("img",B.currentTarget),children:[e.jsx(lr,{}),e.jsx("span",{children:A("reader.images")})]}),e.jsxs("button",{type:"button","aria-expanded":Be==="fs","aria-haspopup":"dialog",onClick:B=>D("fs",B.currentTarget),children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),e.jsx("span",{children:A("reader.fontSize")})]}),S&&e.jsxs("button",{type:"button",onMouseDown:B=>B.preventDefault(),onClick:()=>{Ee(null),X()},children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),e.jsx("span",{children:A("reader.reportError")})]})]}),We&&Be&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:re}),e.jsxs("div",{className:"bim-rd-sheet",ref:Ce,role:"dialog","aria-modal":"true","aria-label":A(Be==="img"?"reader.images":"reader.fontSize"),onKeyDown:B=>{if(B.key==="Escape"){B.stopPropagation(),re();return}B.key==="Tab"&&ar(B,Ce.current)},children:[e.jsxs("div",{className:"bim-rd-sheet-head",children:[e.jsx("span",{children:A(Be==="img"?"reader.images":"reader.fontSize")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.close"),onClick:re,children:"✕"})]}),Be==="img"?e.jsx("div",{className:"bim-rd-sheet-img",children:e.jsx(vi,{pages:p??null,loading:c,renderOverlay:d})}):e.jsxs("div",{className:"bim-rd-sheet-fs",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontSmaller"),disabled:$e<=gt[0],onClick:()=>m({fontSize:yn(g.fontSize,-1)}),children:"A−"}),e.jsxs("output",{"aria-live":"polite",children:[$e,"px"]}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontLarger"),disabled:$e>=gt[gt.length-1],onClick:()=>m({fontSize:yn(g.fontSize,1)}),children:"A+"})]})]})]})]})}const ll=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Wp={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Ke(t){return Wp[t]??t}const Wt=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],Ht={熹平: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},al={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Hn(t){const n=t.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const o=parseInt(n[1],10);if(o<100||o>2100)return;const r=n[2]?parseInt(n[2],10):void 0;return{from:o,to:r!=null&&r>=o&&r<=2100?r:void 0}}function Hp(t){return t>=1950?"":t>=1912?"民國":t>=1645?"清":t>=1368?"明":t>=1279?"元":t>=960?"宋":t>=907?"五代":t>=618?"唐":t>=581?"隋":t>=420?"南北朝":t>=265?"晉":t>=220?"三國":t>=-202?"漢":""}const Op=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,dr={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Qi(t){const n=t.trim().replace(/[代朝]$/,"");for(const s of Object.keys(dr))if(n.startsWith(s))return dr[s];const o=Ke(n);if($t[o]!=null)return o;const r=xt(n);if(r&&n.length<=r.length+1)return Ke(r)}function St(t,n){if(n){const o=al[`${n}|${t}`];if(o!=null)return o}return Ht[t]}const Fp=1911;function Dp(t){const n=Ht[t];if(n==null)return;const o=ut[t];let r;for(const[s,l]of Object.entries(Ht))ut[s]===o&&l>n&&(r==null||l<r)&&(r=l);return r!=null?r-1:void 0}const Up={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Cn(t){if(!t)return;if(/^\d+$/.test(t))return parseInt(t,10);let n=0,o=0,r=!1;for(const l of t){const a=Up[l];if(a===void 0)return;r=!0,l==="十"?o=(o||1)*10:l==="廿"||l==="卅"?(n+=a,o=0):o>=10?(n+=o+a,o=0):o=o*10+a}const s=n+o;return r&&s>0?s:void 0}function xt(t){for(const n of ll)if(t.startsWith(n))return n}const ut={};{const t=(n,o)=>{for(const r of o)ut[r]=n};t("東漢",["熹平","建安"]),t("三國",["黃初","正始"]),t("五代",["廣政"]),t("西晉",["太康"]),t("東晉",["永和"]),t("隋",["開皇"]),t("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),t("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),t("金",["大定","明昌"]),t("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),t("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),t("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),t("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function _t(t,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(Ht))if(t.includes(r)&&!(o&&ut[r]&&ut[r]!==o&&al[`${o}|${r}`]==null))return r}function dn(t){var a,p,c;const n={era:"",reign:"",source:"none"},o=t.dating;if(o!=null&&o.era||o!=null&&o.reign)return{era:o.era??"",reign:o.reign??"",source:o.certainty==="attested"?"catalog":"edition"};const r=(a=t.lineage)==null?void 0:a.year_text;if(r){const d=xt(r)??"";return{era:Ke(d),reign:_t(r,d)??"",source:"lineage"}}const s=(p=t.publication_info)==null?void 0:p.year;if(s){const d=Hn(s);if(d)return{era:Hp(d.from),reign:"",source:"publication"};const u=xt(s)??Qi(s)??((c=Wt.find(h=>h.pattern.test(s)))==null?void 0:c.era)??"",g=_t(s,u)??"",m=u||(g?ut[g]??"":"");if(m||g)return{era:Ke(m),reign:g,source:"publication"}}const l=t.edition||t.title||"";if(l){const d=xt(l);if(d)return{era:Ke(d),reign:_t(l,d)??"",source:"edition"};const u=Wt.find(g=>g.pattern.test(l));if(u)return{era:Ke(u.era),reign:_t(l,u.era)??u.reign??"",source:"edition"}}return n}function On(t){var r,s,l,a,p,c,d,u,g;if(((r=t.dating)==null?void 0:r.year)!=null)return t.dating.year;if(typeof((s=t.lineage)==null?void 0:s.year)=="number")return t.lineage.year;const n=(l=t.publication_info)==null?void 0:l.year;if(n){const m=Hn(n);if(m)return m.from}const o=[(a=t.lineage)==null?void 0:a.year_text,(p=t.publication_info)==null?void 0:p.year,t.edition,t.edition?void 0:t.title].filter(Boolean);for(const m of o){const h=((c=t.publication_info)==null?void 0:c.year)||((d=t.lineage)==null?void 0:d.year_text);if(h&&m!==h&&(xt(h)||Qi(h)))break;const f=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(f){const j=parseInt(f[1],10);if(j>=100&&j<=2100)return j}const v=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(v){const j=xt(m);if(!j||Ke(j)==="民國"){const k=Cn(v[1]);if(k!=null&&k>=1&&k<=120)return Fp+k}}const y=xt(m)??((u=Wt.find(j=>j.pattern.test(m)))==null?void 0:u.era),w=y?Ke(y):void 0,b=_t(m,w)??(xt(m)||(g=Wt.find(j=>j.pattern.test(m)))==null?void 0:g.reign);if(b){const j=St(b,w);if(j==null)continue;const S=m.indexOf(b),k=S>=0?m.slice(S+b.length):"",$=k.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??k.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=$?Cn($[1]):void 0;return j+(_?_-1:0)}}}function eo(t){var a,p,c,d,u,g;const n=(a=t.dating)==null?void 0:a.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const o=(p=t.lineage)==null?void 0:p.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=t.lineage)==null?void 0:c.year_text;if(r){const m=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const h=Si[Ke(m[1])],f=$t[Ke(m[2])];if(h!=null&&f!=null)return{from:Math.min(h,f)-20,to:Math.max(h,f)+40}}}const s=(d=t.publication_info)==null?void 0:d.year;if(s){const m=Hn(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const h=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const f=Si[Ke(h[1])],v=$t[Ke(h[2])];if(f!=null&&v!=null)return{from:Math.min(f,v)-20,to:Math.max(f,v)+40}}}const l=[(u=t.publication_info)==null?void 0:u.year,t.edition,t.title].filter(Boolean);for(const m of l){if(!/[間间]/.test(m))continue;const h=xt(m)??Qi(m)??((g=Wt.find(y=>y.pattern.test(m)))==null?void 0:g.era),f=h?Ke(h):void 0,v=[];for(const y of Object.keys(Ht))m.includes(y)&&(f&&ut[y]&&ut[y]!==f||St(y,f)!=null&&v.push(y));if(v.length===0){const y=m.match(/([一-鿿])([一-鿿])[間间]/);if(y&&f){for(const w of[y[1],y[2]])for(const b of Object.keys(Ht))if(ut[b]===f&&!(b[0]!==w&&b[b.length-1]!==w)&&St(b,f)!=null){v.push(b);break}}}if(v.length>0){const y=v.map(S=>St(S,f)).filter(S=>S!=null),w=Math.min(...y),b=v.reduce((S,k)=>St(S,f)>=St(k,f)?S:k),j=Dp(b)??li(f??"")??Math.max(...y);return{from:w,to:j>w?j:li(f??ut[b]??"")??w}}if(f&&$t[f]!=null)return{from:$t[f],to:li(f)??$t[f]}}}const $t={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Vp=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Gp=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,pr=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function ur(t,n){for(const o of ll){const r=t.indexOf(o);if(r<0)continue;if(o.length===1){const c=t[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!_t(t.slice(r),Ke(o)))continue}const s=Ke(o);if(s===n)continue;const l=t.slice(r),a=_t(l,s)??"";let p;if(a){const c=St(a,s);if(c!=null){const u=l.slice(l.indexOf(a)+a.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),g=u?Cn(u[1]):void 0;p=c+(g?g-1:0)}}return{era:s,reign:a,year:p}}for(const o of Wt)if(o.pattern.test(t))return{era:Ke(o.era),reign:o.reign??""}}function Yp(t){var w,b,j,S,k;const n=dn(t),o=((w=t.publication_info)==null?void 0:w.year)??"",r=o?Hn(o):void 0;if(!n.era&&!n.reign&&!r)return;const s=t.edition||t.title||"",l=/[間间]/.test(s),a=((b=t.lineage)==null?void 0:b.year_text)??"",p=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(a),c=n.source==="publication"&&Op.test(o),d=n.source==="publication"&&/[間间]/.test(o),u=a.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let g;l||p||c||d?g=void 0:u?g=parseInt(u[2],10):g=On(t);const m=g==null?eo(t):void 0;let h;n.source==="publication"&&(c||pr.test(o))?h="uncertain":n.source==="lineage"||n.source==="publication"?h="attested":pr.test(s)||!n.reign&&g==null?h="uncertain":h="inferred";const f=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((j=t.lineage)==null?void 0:j.year_text)??((S=t.lineage)==null?void 0:S.year)??""}」`:`出版著錄「${((k=t.publication_info)==null?void 0:k.year)??""}」`,v={era:n.era,reign:n.reign,year:g,yearRange:m,certainty:h,source:n.source==="edition"?"edition":"catalog",basis:f};if(u){const $=a.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==v.era&&(v.laterRepair={era:$[1]})}if(!v.laterRepair&&Gp.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(v.laterRepair={era:$[1]})}const y=Vp.find($=>$.re.test(s));if(y){const $=s.search(y.re),_=s.slice($),z=ur(_,n.era)??ur(s,n.era);z&&(v.basedOn={era:z.era,reign:z.reign,year:z.year,relation:y.relation})}return v}const Si={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function li(t){return Si[t]}function zn(t){const n=On(t);if(n!=null)return n;const o=eo(t);if(o)return o.from;const r=dn(t).era;return r?$t[r]:void 0}const mr=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function $i(t){const n=mr.indexOf(t);return n===-1?mr.length:n}function Kp(t){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of t){const l=s.relation;l==="part_of"?n.belongsTo.push(s):l==="collected_in"?n.collected.push(s):l==="has_part"||l==="contains_text_of"?n.contains.push(s):l==="text_carried_by"||l==="studied_by"||l==="derived_from"||l==="followed_by"||l==="has_adaptation"?n.derivative.push(s):l==="studies"||l==="preceded_by"?n.studies.push(s):n.related.push(s)}const o=[],r=(s,l)=>{n[s].length&&o.push({key:s,labelKey:l,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function to(t,n){const o=Oi(t||[]),r=new Map,s=[];for(const d of o)d.group?(r.has(d.group)||r.set(d.group,[]),r.get(d.group).push(d)):s.push(d);for(const d of r.values())d.sort((u,g)=>{const m=h=>h.group_role==="origin"?0:h.group_role==="mirror"?1:2;return m(u)-m(g)});const l={text:[],image:[],textImage:[],physical:[]};for(const d of s){const u=Nt(d),g=u.includes("text"),m=u.includes("image");g&&m?l.textImage.push(d):g?l.text.push(d):m?l.image.push(d):l.physical.push(d)}const p=["text","image","textImage","physical"].filter(d=>l[d].length>0).map(d=>({key:d,items:l[d]})),c=[...r.entries()].map(([d,u])=>{var g,m;return{key:d,label:((g=n==null?void 0:n[d])==null?void 0:g.label)||d,description:(m=n==null?void 0:n[d])==null?void 0:m.description,items:u}});return{buckets:p,mirrors:c,total:o.length}}function Fn(t,n=Dt("zh-Hant")){const o=[],r=t.metadata||{};r.edition&&o.push(String(r.edition)),t.source_label&&o.push(t.source_label),t.details&&o.push(t.details);const s=Ln(t);return s&&s.expected>0&&o.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})),r.version&&o.push(String(r.version)),o.join(" · ")}function cl(t,n){if(Fn(t)||n.filter(r=>r.name===t.name).length<2)return"";try{const r=new URL(t.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const l=r.pathname.split("/").filter(Boolean).pop();if(l)return decodeURIComponent(l)}catch{}return""}function dl(t,n){var l,a;const o=t.resources||[],r=[],s=[];for(const p of o){const c=Nt(p);c.includes("image")&&r.push(p),c.includes("physical")&&s.push(p)}return{id:t.id,name:t.edition||t.title||t.id,era:dn(t),year:On(t),sortYear:zn(t),images:r,holders:s,locationName:(l=t.current_location)==null?void 0:l.name,important:qp(t.id,n),group:(a=n==null?void 0:n.node_groups)==null?void 0:a[t.id],hasImage:r.length>0}}function qp(t,n){var p,c;if(!n)return!1;const o=n.default_collection;if(!o)return!1;const r=(p=n.collections)==null?void 0:p[o];if(((r==null?void 0:r.book_ids)??(o==="core"?n.core_books??[]:[])).includes(t))return!0;const l=(r==null?void 0:r.groups)??[],a=(c=n.node_groups)==null?void 0:c[t];return!!a&&l.includes(a)}function pl(t,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=t.filter(c=>!r.has(c.id)).map(c=>dl(c,n));let l=s;o.era&&(l=l.filter(c=>c.era.era===o.era)),o.scanOnly&&(l=l.filter(c=>c.hasImage)),o.sort==="year"?l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=c.r.sortYear,g=d.r.sortYear;return u!=null&&g!=null?u-g||c.i-d.i:u!=null?-1:g!=null?1:c.i-d.i}).map(c=>c.r):l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=g=>(g.important?0:1)*2+(g.hasImage?0:1);return u(c.r)-u(d.r)||c.i-d.i}).map(c=>c.r);const p=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,d)=>$i(c)-$i(d));return{rows:l,allRows:s,eras:p,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Zp(t,n){var y,w;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,groupedIds:[]};const o=(y=n.collections)==null?void 0:y[n.default_collection],r=(o==null?void 0:o.groups)??[],s=(o==null?void 0:o.book_ids)??[],l=r.length>0||s.length>0,a=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&a.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const p=new Set(r),c=new Set([...s,...a]),d=b=>{if(c.has(b))return!0;const j=n.node_groups[b];return j!=null&&p.has(j)},u=[],g=new Map,m=[];for(const b of t)if(!((w=n.excluded_books)!=null&&w.includes(b)))if(d(b))u.push(b);else{const j=n.node_groups[b];j?(g.has(j)||g.set(j,[]),g.get(j).push(b)):m.push(b)}if(m.length+[...g.values()].reduce((b,j)=>b+j.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const f=new Map((n.groups??[]).map(b=>[b.id,b])),v=[...g.entries()].map(([b,j])=>{const S=f.get(b);return{id:b,label:(S==null?void 0:S.label)??b,description:S==null?void 0:S.description,ids:j}});return m.length>0&&v.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:u,groupedIds:v}}const ul=["撰","編","注","校","譯","繪","其他"],Jp=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function no(t){if(!t||!t.trim())return"撰";const n=t.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of Jp)if(r.test(n))return o;return"其他"}function io(t){if(!t)return"";const n=t.trim();return!n||!/[一-鿿]/.test(n)?"":n}function ml(t,n="全部"){const o=new Map;for(const s of t){const l=no(s);o.set(l,(o.get(l)??0)+1)}const r=[{cls:"全部",label:n,count:t.length}];for(const s of ul){const l=o.get(s);l&&r.push({cls:s,label:s,count:l})}return r.length>2?r:[]}function gl(t,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(a=>({id:a.work_id||a.book_id||void 0,title:a.title,section:a.section,volumes:a.volumes||[],subItems:a.sub_items,edition:a.edition,found:a.found_volumes,expected:a.expected_volumes})),l=[...new Set(s.map(a=>a.section).filter(Boolean))];return{rows:s,source:"catalog",sections:l,totalVolumes:n.total_volumes}}return t.contained_works&&t.contained_works.length>0?{rows:t.contained_works.map(l=>({id:l.id,title:l.title,volumes:sn(l.volume_index)})),source:"works",sections:[]}:{rows:(t.books||[]).map(s=>{var l,a;return{id:s,title:((l=o==null?void 0:o.get(s))==null?void 0:l.title)||s,edition:(a=o==null?void 0:o.get(s))==null?void 0:a.edition,volumes:[]}}),source:"books",sections:[]}}function sn(t){if(t==null)return[];if(typeof t=="number")return[t];if(Array.isArray(t))return t.filter(n=>typeof n=="number");if(typeof t=="string"){const n=t.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[o,r]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,r-o+1)},(s,l)=>o+l)}return t.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function Dn(t,n="冊"){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=[...t].sort((l,a)=>l-a),r=o[0],s=o[o.length-1];return s-r+1===o.length?`${r}–${s}`:o.length<=3?o.join(", "):`${r}–${s} (${o.length}${n})`}const Xp=["〇","一","二","三","四","五","六","七","八","九"],gr=["","十","百","千"];function hl(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),p=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=gr[p]:r+=Xp[a]+gr[p])}return r}function Qp(t){return t==null?"":typeof t=="string"?t:t.title??""}function bt(t,n="卷"){var r,s;const o=t;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?hl(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function xl(t){var r;if(t.edition_type)return t.edition_type;if((r=t.lineage)!=null&&r.category)return t.lineage.category;const n=t.edition||t.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,l]of o)if(s.test(n))return l;return""}const eu=216,hr="clamp(280px, 23vw, 360px)",tu=1440,_i="(max-width: 719px)",nu=`${_i}, (pointer: coarse)`,iu=`
|
|
520
|
+
.bim-d-main.bim-d-main-grid { max-width: ${tu}px; padding: 16px 32px 0; }
|
|
521
521
|
.bim-d-grid {
|
|
522
522
|
display: grid;
|
|
523
|
-
grid-template-columns: ${
|
|
523
|
+
grid-template-columns: ${eu}px minmax(0, 1fr) ${hr};
|
|
524
524
|
grid-template-rows: auto 1fr;
|
|
525
525
|
grid-template-areas: "rail main card" "rail main side";
|
|
526
526
|
column-gap: 32px; row-gap: 28px; align-items: start;
|
|
@@ -854,7 +854,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
854
854
|
.bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
|
|
855
855
|
|
|
856
856
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
857
|
-
@media ${
|
|
857
|
+
@media ${nu} {
|
|
858
858
|
.bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
|
|
859
859
|
.bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
|
|
860
860
|
.bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
|
|
@@ -892,7 +892,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
892
892
|
/* 中等宽度:左栏折到顶部一行 */
|
|
893
893
|
@media (max-width: 1100px) {
|
|
894
894
|
.bim-d-grid {
|
|
895
|
-
grid-template-columns: minmax(0, 1fr) ${
|
|
895
|
+
grid-template-columns: minmax(0, 1fr) ${hr};
|
|
896
896
|
grid-template-rows: auto auto 1fr;
|
|
897
897
|
grid-template-areas: "rail rail" "main card" "main side";
|
|
898
898
|
}
|
|
@@ -906,7 +906,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
906
906
|
}
|
|
907
907
|
|
|
908
908
|
/* 手机:左栏收起,提要卡 → 正文 → 旁栏 */
|
|
909
|
-
@media ${
|
|
909
|
+
@media ${_i} {
|
|
910
910
|
.bim-d-main.bim-d-main-grid { padding: 8px 16px 0; }
|
|
911
911
|
.bim-d-grid {
|
|
912
912
|
grid-template-columns: minmax(0, 1fr);
|
|
@@ -981,7 +981,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
981
981
|
:root[data-layout="boxed"] .bim-d-g-rail { border: ${i("fr-bd")}; background: ${i("fr-bg")}; padding: 14px 8px; }
|
|
982
982
|
:root[data-layout="boxed"] .bim-d-filters { border-bottom: 1px solid ${i("fr-tab-bd")}; }
|
|
983
983
|
:root[data-layout="boxed"] .bim-d-filters .bim-d-tab { margin-bottom: -1px; }
|
|
984
|
-
@media ${
|
|
984
|
+
@media ${_i} {
|
|
985
985
|
:root[data-layout="boxed"] .bim-d-card { padding: 16px; }
|
|
986
986
|
:root[data-layout="boxed"] .bim-d-g-rail { border: 0; background: transparent; padding: 0; }
|
|
987
987
|
}
|
|
@@ -996,7 +996,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
996
996
|
: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 {
|
|
997
997
|
text-decoration-color: currentColor; text-decoration-thickness: 2px;
|
|
998
998
|
}
|
|
999
|
-
`;function
|
|
999
|
+
`;function pn({railTop:t,back:n,up:o,nav:r,railLinks:s,main:l,card:a,side:p}){const{t:c,convert:d}=G(),u=(r||[]).filter(Boolean);return e.jsxs("div",{className:"bim-d-grid",children:[e.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[t,n&&e.jsx("div",{style:{marginTop:t?12:0},children:n}),o,u.length>1&&e.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[e.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),e.jsx("ul",{className:"bim-d-rail-nav",children:u.map(g=>e.jsx("li",{children:e.jsxs("a",{href:`#${g.id}`,children:[e.jsx("span",{children:d(g.label)}),g.count!=null&&e.jsx("span",{className:"bim-d-meta",children:g.count})]})},g.id))})]}),s&&s.length>0&&e.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[e.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),e.jsx("ul",{className:"bim-d-rail-nav",children:s.map(g=>e.jsx("li",{children:e.jsxs("a",{href:g.href??"#",onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),g.onClick())},children:[e.jsx("span",{children:d(g.label)}),e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},g.key))})]})]}),e.jsx("div",{className:"bim-d-g-main",children:l}),e.jsx("div",{className:"bim-d-g-card",children:a}),e.jsx("div",{className:"bim-d-g-side",children:p})]})}function fl({caption:t,children:n}){const{convert:o}=G();return e.jsxs("div",{className:"bim-d-up bim-d-ui",children:[e.jsx("span",{className:"bim-d-up-cap",children:o(t)}),n]})}function Ze({id:t,title:n,meta:o,action:r,children:s}){const{convert:l}=G();return e.jsxs("section",{id:t,className:"bim-d-sec",children:[e.jsxs("div",{className:"bim-d-sec-head bim-d-ui",children:[e.jsx("h2",{children:l(n)}),o!=null&&o!==""&&e.jsx("span",{className:"bim-d-meta",children:o}),r&&e.jsx("span",{className:"bim-d-sec-act",children:r})]}),e.jsx("div",{className:"bim-d-sec-body",children:s})]})}function qe({items:t,className:n,style:o}){const r=t.filter(s=>s!=null&&s!==""&&s!==!1);return r.length?e.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:o,children:r.map((s,l)=>e.jsxs(x.Fragment,{children:[l>0&&e.jsx("span",{className:"bim-d-dot"}),e.jsx("span",{children:s})]},l))}):null}function Un({items:t,value:n,onChange:o}){const{convert:r}=G();return e.jsx(e.Fragment,{children:t.map(s=>e.jsx("button",{type:"button",className:[...r(s.label)].length===1?"bim-d-tab bim-d-tab-1":"bim-d-tab","aria-pressed":s.key===n,onClick:()=>o(s.key),children:r(s.label)},s.key))})}function bl({label:t,checked:n,onChange:o}){const{convert:r}=G();return e.jsxs("label",{className:"bim-d-check",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:s=>o(s.target.checked)}),r(t)]})}const yl=6,Vn=t=>t>yl+1;function oo({total:t,shown:n,unit:o,onClick:r}){const{t:s,convert:l}=G(),a=t-n,p=Vn(t)?t-Math.min(n,yl):a;return p<=0?null:e.jsxs("button",{type:"button",className:`bim-d-more bim-d-ui${a>0?"":" bim-d-more-ncap"}`,onClick:r,children:[a>0&&e.jsx("span",{className:"bim-d-more-w",children:s("detail.expandRest",{n:a,unit:l(o)})}),e.jsx("span",{className:"bim-d-more-n",children:s("detail.expandRest",{n:p,unit:l(o)})})]})}function ro({label:t,onClick:n}){const{convert:o}=G();return e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(t)})}function un({kind:t,title:n,subtitle:o,byline:r,meta:s,description:l,clampDescription:a,facts:p,stats:c,readAction:d,secondaryAction:u,children:g,foot:m}){const{t:h,convert:f}=G(),v=(p||[]).filter(S=>S.value!=null&&S.value!==""),y=(c||[]).filter(S=>S.value!=null&&S.value!==""&&S.value!==0),[w,b]=x.useState(!1),j=!!a&&!w;return e.jsxs("div",{className:"bim-d-card",children:[t&&e.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:f(t)}),e.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),o&&e.jsx("div",{className:"bim-d-card-sub",children:o}),r&&e.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:r}),s&&e.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),l&&e.jsx("div",{className:j?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:j?{"--detail-clamp":a}:void 0,children:l}),l&&!!a&&e.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":w,onClick:()=>b(S=>!S),children:h(w?"action.collapse":"action.expand")}),y.length>0&&e.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((S,k)=>e.jsxs("div",{children:[e.jsx("b",{children:S.value}),e.jsx("span",{children:f(S.label)})]},k))}),v.length>0&&e.jsx("dl",{className:"bim-d-ui",children:v.map((S,k)=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{children:f(S.label)}),e.jsx("dd",{title:S.title,children:S.value})]},k))}),g,d,u,m&&e.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:m})]})}function so(t){return!!t&&[...t.replace(/\s+/g,"")].length>110}function Ci({href:t,onClick:n,label:o}){const{t:r,convert:s}=G(),l=o??r("detail.read");return t?e.jsx("a",{className:"bim-d-btn",href:t,onClick:n?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),n())}:void 0,children:s(l)}):e.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:s(l)})}function zt({id:t,title:n,meta:o,items:r,metas:s,currentIndex:l,cap:a=8,moreLabel:p,foot:c,sub:d,timeline:u}){const{t:g,convert:m}=G(),[h,f]=x.useState(!1);if(!r.length)return null;const v=h?r:r.slice(0,a),y=r.length-v.length;return e.jsxs("div",{id:t,className:u?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[e.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[m(n),o!=null&&o!==""&&e.jsx("span",{className:"bim-d-meta",children:o})]}),d&&e.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:d}),e.jsx("ul",{children:v.map((w,b)=>e.jsxs("li",{className:b===l?"bim-d-side-cur":void 0,"aria-current":b===l?"page":void 0,children:[w,s!=null&&s[b]?e.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&e.jsx(ro,{label:p?p(y):g("detail.showMore",{n:y}),onClick:()=>f(!0)}),c&&e.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const ou=new Set(["reviewed","disputed","unreviewed","draft"]);function mn({revision:t,revisedAt:n,review:o,todo:r}){const{t:s,convert:l}=G(),a=o&&ou.has(o.status)?s(`detail.review.${o.status}`):void 0,p=o&&o.status!=="unreviewed"&&a?[a,o.by,o.date].filter(Boolean).join(" "):"",c=[t!=null&&t!==""?`${s("detail.dataVersion")} ${t}`:"",n??"",l(p)].filter(Boolean),d=(r||[]).filter(u=>u&&u.what);return!c.length&&!d.length?null:e.jsxs(e.Fragment,{children:[c.length>0&&e.jsx(qe,{items:c,style:{fontSize:12}}),d.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:s("detail.todoCount",{n:d.length})}),e.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:d.map((u,g)=>e.jsxs("li",{children:[l(u.what),(u.by||u.date)&&e.jsxs("span",{style:{marginLeft:6},children:["(",[u.by&&l(u.by),u.date].filter(Boolean).join(" · "),")"]})]},g))})]})]})}const wn=1e3,xr=208,ru=1440,su="(max-width: 719px)",jl=`
|
|
1000
1000
|
.bim-d-page {
|
|
1001
1001
|
background: ${i("page-bg")};
|
|
1002
1002
|
color: ${i("ink")};
|
|
@@ -1005,7 +1005,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1005
1005
|
padding-bottom: 64px;
|
|
1006
1006
|
}
|
|
1007
1007
|
.bim-d-main {
|
|
1008
|
-
max-width: ${
|
|
1008
|
+
max-width: ${wn}px;
|
|
1009
1009
|
margin: 0 auto;
|
|
1010
1010
|
padding: 24px clamp(16px, 4vw, 28px) 0;
|
|
1011
1011
|
}
|
|
@@ -1016,7 +1016,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1016
1016
|
* PAGE_MAX_WIDTH,读者的行宽体验不变。
|
|
1017
1017
|
*/
|
|
1018
1018
|
.bim-d-main.bim-d-main-wide {
|
|
1019
|
-
max-width: ${
|
|
1019
|
+
max-width: ${ru}px;
|
|
1020
1020
|
}
|
|
1021
1021
|
.bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
|
|
1022
1022
|
|
|
@@ -1048,9 +1048,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1048
1048
|
*/
|
|
1049
1049
|
.bim-d-reader {
|
|
1050
1050
|
display: grid;
|
|
1051
|
-
grid-template-columns: ${
|
|
1051
|
+
grid-template-columns: ${xr}px minmax(0, ${wn}px);
|
|
1052
1052
|
gap: 32px;
|
|
1053
|
-
max-width: ${
|
|
1053
|
+
max-width: ${xr+wn+32}px;
|
|
1054
1054
|
margin: 0 auto;
|
|
1055
1055
|
align-items: start;
|
|
1056
1056
|
}
|
|
@@ -1073,7 +1073,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1073
1073
|
align-items: start; margin-bottom: 48px; }
|
|
1074
1074
|
.bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
|
|
1075
1075
|
|
|
1076
|
-
@media ${
|
|
1076
|
+
@media ${su} {
|
|
1077
1077
|
.bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
|
|
1078
1078
|
.bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
|
|
1079
1079
|
/* 表格:meta 列折到第二行,表头隐藏 */
|
|
@@ -1091,18 +1091,22 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1091
1091
|
padding-right: 0; padding-bottom: 12px;
|
|
1092
1092
|
}
|
|
1093
1093
|
}
|
|
1094
|
-
${
|
|
1095
|
-
`)||(n.push({start:o,end:l+1,inner:a}),o=l)}return n}function
|
|
1096
|
-
`).map(n=>n.trim()).filter(n=>n&&!
|
|
1097
|
-
`)){const s=r.trim();if(!s||
|
|
1094
|
+
${iu}`;function nn({children:t,style:n,wide:o,grid:r}){return e.jsxs("div",{className:"bim-d-page",style:n,children:[e.jsx("style",{children:jl}),e.jsx("div",{className:r?"bim-d-main bim-d-main-grid":o?"bim-d-main bim-d-main-wide":"bim-d-main",children:t})]})}function zi({breadcrumb:t,actions:n}){return e.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:i("aux-fg")},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:t}),n&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function lo({char:t,tone:n="accent"}){return e.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:i(n==="accent"?"accent":"ink"),color:i("page-bg")},children:t})}function Ti({items:t}){const n=Ye();return e.jsx(e.Fragment,{children:t.map((o,r)=>{const s=r===t.length-1,l=r>0&&e.jsx("span",{style:{color:i("hint-fg")},children:"/"},`s${r}`),a=o.id?n(o.id):o.href,p=s||!o.onClick&&!a?e.jsx("span",{style:{color:i("ink")},children:o.label},r):e.jsx("a",{href:a??"#",onClick:o.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),o.onClick())}:void 0,style:{color:i("meta-fg")},children:o.label},r);return e.jsxs(x.Fragment,{children:[l,p]},r)})})}function vl({title:t,subtitle:n,aside:o,secondLine:r}){return e.jsxs("header",{style:{borderBottom:`2px solid ${i("rule-strong")}`,paddingBottom:18},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[e.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:t}),n&&e.jsx("span",{style:{fontSize:15,color:i("meta-fg"),letterSpacing:".06em"},children:n})]}),o&&e.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".06em"},children:o})]}),r&&e.jsx("div",{style:{marginTop:12,fontSize:13.5,color:i("quiet-fg")},children:r})]})}function lu({children:t,facts:n}){return!t&&n?e.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${i("rule")}`,marginBottom:40},children:n}):e.jsxs("div",{className:"bim-d-intro",children:[e.jsx("div",{style:{minWidth:0},children:t}),n]})}function au({items:t,horizontal:n}){const{convert:o}=Te();return t.length?e.jsx("div",{style:{borderLeft:`2px solid ${i("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:t.map((r,s)=>e.jsxs("div",{title:r.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[e.jsx("span",{className:"bim-d-ui",style:{color:i("label-fg"),letterSpacing:".08em",flex:"none"},children:o(r.label)}),e.jsx("span",{style:{color:i("body-fg"),textAlign:n?"left":"right",minWidth:0},children:r.value})]},s))}):null}function cu({glyph:t,tone:n,title:o,count:r,actions:s,id:l}){const{convert:a}=Te();return e.jsxs("div",{id:l,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx(lo,{char:t,tone:n}),e.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:a(o)}),r!=null&&e.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg")},children:r})]}),s&&e.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function kl({label:t,active:n,onClick:o,dashed:r}){const{convert:s}=Te();return e.jsx("button",{type:"button",onClick:o,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${r&&!n?"dashed":"solid"} ${i(n?"accent":"rule")}`,background:n?i("accent"):"transparent",color:i(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(t)})}function du({label:t,onClick:n}){const{convert:o}=Te();return e.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:i("meta-fg"),borderBottom:`1px solid ${i("rule")}`},children:o(t)})}function pu({label:t,onClick:n,inline:o}){const{convert:r}=Te();return e.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:o?0:12,width:o?void 0:"100%",padding:o?"4px 12px":9,background:"none",border:`1px dashed ${i("rule-dashed")}`,cursor:"pointer",fontSize:12,color:i("meta-fg"),letterSpacing:o?void 0:".08em"},children:r(t)})}function wl({children:t,href:n,onClick:o,title:r}){const s={display:"inline-block",padding:"4px 10px",border:`1px solid ${i("rule")}`,fontSize:13,color:i("body-fg"),lineHeight:1.5};return n||o?e.jsx("a",{href:n??"#",title:r,onClick:o?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o())}:void 0,style:s,children:t}):e.jsx("span",{title:r,style:s,children:t})}function uu({children:t}){return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:t})}function mu({volumes:t,unit:n,max:o=60}){const{t:r}=G(),s=n??r("unit.volume"),[l,a]=x.useState(!1);if(!t.length)return null;const p=l?t:t.slice(0,o);return e.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[p.map(c=>e.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${i("rule")}`,color:i("meta-fg")},children:c},c)),!l&&t.length>o&&e.jsxs("button",{type:"button",onClick:()=>a(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${i("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:i("meta-fg")},children:["+",t.length-o]}),e.jsx("span",{style:{padding:"2px 6px",color:i("hint-fg")},children:s})]})}function gu({children:t}){return e.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:t})}function hu({spec:t}){const{convert:n}=Te();return e.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${t.leadWidth}px 1fr ${t.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${i("rule-strong")}`,fontSize:11,color:i("label-fg"),letterSpacing:".1em"},children:[e.jsx("span",{}),e.jsx("span",{children:n(t.mainLabel)}),e.jsx("span",{style:{display:"grid",gridTemplateColumns:t.columns.map(o=>o.width).join(" "),gap:12},children:t.columns.map(o=>e.jsx("span",{children:n(o.label)},o.label))})]})}function xu({no:t,main:n,meta:o,spec:r}){return e.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${r.leadWidth}px 1fr ${r.metaWidth}px`,gap:12},children:[e.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("hint-fg"),textAlign:"right"},children:t}),e.jsx("span",{style:{minWidth:0},children:n}),e.jsx("span",{className:"bim-d-row-meta",style:{display:"grid",gridTemplateColumns:r.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:o})]})}function fu(t){return String(t+1).padStart(2,"0")}function bu(){return e.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function yu({open:t,onToggle:n,main:o,action:r,children:s}){return e.jsxs("div",{style:{borderBottom:`1px solid ${i("rule")}`},children:[e.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[e.jsx("button",{type:"button",onClick:n,"aria-expanded":t,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 ${i(t?"accent":"rule-dashed")}`,background:t?i("accent"):"transparent",color:i(t?"page-bg":"accent")},children:t?"-":"+"}),e.jsx("span",{style:{fontSize:14,minWidth:0},children:o}),r]}),t&&s&&e.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${i("rule-accent-soft")}`,marginLeft:12},children:s})]})}function Sl(t){const n=[];for(let o=0;o<t.length;o++){const r=t[o];let s;if(r==="⟨")s="⟩";else if(r==="<"){const p=t[o+1];if(p===void 0||/[A-Za-z/!?>\s]/.test(p))continue;s=">"}else continue;const l=t.indexOf(s,o+1);if(l<0)continue;const a=t.slice(o+1,l);a.includes(`
|
|
1095
|
+
`)||(n.push({start:o,end:l+1,inner:a}),o=l)}return n}function $l(t,n){if(t.length<=n)return t;let o=n;for(const r of Sl(t)){if(r.start>=o)break;if(r.end>o){o=r.start>0?r.start:r.end;break}}return t.slice(0,o)}const _l={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},ju={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 Cl(t,n,o,r){return t.map((s,l)=>{switch(s.type){case"text":return e.jsx(x.Fragment,{children:n(s.text)},l);case"jz":return e.jsx("span",{className:"bim-jiazhu",style:o===0?_l:void 0,children:Cl(s.children,n,o+1,r)},l);case"qw":return e.jsx("span",{className:"bim-qw guji-qw",title:s.label?r("detail.lacunaWith",{label:s.label}):r("detail.lacuna"),children:"□"},l);case"qz":return e.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":s.guess,children:"□"},l);case"zi":return e.jsx("span",{className:"bim-zi guji-zi",title:r("detail.composedChar",{label:s.label}),style:ju,children:s.label},l)}})}function ot(t,n=r=>r,o){if(!t)return"";if(o!=null&&o.gujiMarkdown)return bp(t)?Cl(Fs(t),n,0,o.t??Dt("zh-Hant")):n(t);if(t.indexOf("⟨")<0&&t.indexOf("<")<0)return n(t);const r=[];let s=0,l=0;for(const a of Sl(t))a.start>s&&r.push(e.jsx(x.Fragment,{children:n(t.slice(s,a.start))},l++)),r.push(e.jsx("span",{className:"bim-jiazhu",style:_l,children:n(a.inner)},l++)),s=a.end;return s<t.length&&r.push(e.jsx(x.Fragment,{children:n(t.slice(s))},l++)),r}function vu({label:t,children:n}){return e.jsxs("div",{style:{marginBottom:10},children:[t&&e.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:i("label-fg"),marginBottom:4},children:t}),e.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:i("quiet-fg"),textAlign:"justify"},children:n})]})}function ku({title:t,tag:n,children:o}){const{convert:r}=Te();return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${i("rule-strong")}`,marginBottom:2},children:[e.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:r(t)}),n&&e.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("accent"),letterSpacing:".06em"},children:r(n)})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:o})]})}function zl({name:t,note:n,href:o,extra:r}){const s=e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontSize:14,minWidth:0},children:t}),e.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:i("hint-fg"),flex:"none"},children:o?"↗":""}),n&&e.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:i("label-fg")},children:n})]}),l={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${i("rule")}`,color:i("body-fg"),alignItems:"baseline"};return e.jsxs(e.Fragment,{children:[o?e.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:l,children:s}):e.jsx("div",{style:l,children:s}),r]})}function wu({item:t,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{t:s,convert:l}=G(),[a,p]=x.useState(!1),c=Ln(t),d=o&&!!c&&c.expected>0,u=(t.url?Ut(t.url):void 0)||l(t.name),g=n?cl(t,n):"",m=g?`${u}(${g})`:u;return e.jsx(zl,{name:m,note:Fn(t,s)||r,href:Vt(t),extra:d?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>p(h=>!h),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:i("meta-fg"),borderBottom:`1px solid ${i("rule")}`},children:a?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),a&&e.jsx(ao,{item:t})]}):void 0})}function ao({item:t}){return e.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(t.volumes||[]).map((n,o)=>{const r=n.status==="missing";return n.url&&!r?e.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{padding:"4px 8px",borderRadius:4,background:i("zebra-bg")},children:n.volume},o):e.jsx("span",{style:{padding:"1px 5px",color:i(r?"missing-fg":"hint-fg"),textDecoration:r?"line-through":void 0},children:n.volume},o)})})}function Tl({label:t,items:n}){const{convert:o}=Te();return n.length?e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[e.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".08em"},children:t}),n.map((r,s)=>e.jsx(wl,{children:o(r)},s))]}):null}function Su({rows:t}){const n=t.filter(o=>o.items.length>0);return n.length?e.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(o=>e.jsx(Tl,{label:o.label,items:o.items},o.label))}):null}function Ni(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Nl({left:t,right:n}){return e.jsxs("footer",{className:"bim-d-ui",style:{marginTop:52,paddingTop:14,borderTop:`1px solid ${i("rule")}`,display:"flex",flexWrap:"wrap",justifyContent:"space-between",gap:"8px 16px",fontSize:11.5,color:i("aux-fg")},children:[e.jsx("span",{children:t}),n&&e.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function $u({children:t,action:n}){return e.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:i("aux-fg"),borderBottom:`1px solid ${i("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[e.jsx("span",{children:t}),n]})}function Ge({id:t,label:n,onNavigate:o,renderLink:r,style:s,dense:l}){const a=Ye();return r?e.jsx(e.Fragment,{children:r(t,typeof n=="string"?n:void 0,{dense:l})}):e.jsx("a",{href:a(t),onClick:o?p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(t))}:void 0,style:s,children:n??t})}function _u({href:t,children:n}){return e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:[n," ",e.jsx("span",{className:"bim-d-ui",style:{fontSize:11},children:"↗"})]})}const Cu={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},zu={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},Tu=`1px solid ${i("table-border")}`,Il={border:Tu,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},Nu={...Il,background:i("table-head-bg"),fontWeight:600};function co({table:t,opts:n}){return e.jsx("div",{className:"bim-guji-table-wrap",style:Cu,children:e.jsx("table",{className:"bim-guji-table",style:zu,children:e.jsx("tbody",{children:t.rows.map((o,r)=>e.jsx("tr",{children:o.cells.map((s,l)=>{const a=o.header?"th":"td";return e.jsx(a,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:o.header?Nu:Il,children:s.empty?null:ot(s.text,void 0,n)},l)})},r))})})})}function Iu(t,n){return t.indexOf("**")<0?ot(t,void 0,n):t.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?e.jsx("strong",{children:ot(r.trim().slice(2,-2),void 0,n)},s):e.jsx(x.Fragment,{children:ot(r,void 0,n)},s))}function Ru(t,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?Zi(t).map((s,l)=>s.type==="table"?e.jsx(co,{table:s.table,opts:r},l):e.jsx(x.Fragment,{children:Iu(s.text,r)},l)):ot(t,void 0,r)}const Eu=/^(#{1,6})\s+(.*)$/,Lu=/^\*\*([^*\n]+)\*\*\s*$/;function po(t){const n=t.match(Eu);if(n)return{level:n[1].length,text:n[2].trim()};const o=t.trim().match(Lu);return o?{level:3,text:o[1].trim()}:null}const uo=/^<!--.*-->$/;function Rl(t){return t.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function El(t){return t.split(`
|
|
1096
|
+
`).map(n=>n.trim()).filter(n=>n&&!uo.test(n))}const Pu=60;function Ll(t){let n=0,o=0;for(const r of t.split(`
|
|
1097
|
+
`)){const s=r.trim();if(!s||uo.test(s)||po(s))continue;const l=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=l,l>Pu&&(o+=l)}return n>0&&o*2>=n}function Au(t){return t.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Gn(t){if(t=Au(t),Ll(t))return"unknown";const n=Rl(t);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const o=n.map(s=>El(s).length).filter(s=>s>0);if(o.length===0)return"unknown";const r=o.reduce((s,l)=>s+l,0)/o.length;return r<=4?"record":r>=8?"catalog":"unknown"}function Bu(t){const n=t.split(`
|
|
1098
1098
|
`),o=[];let r=null,s=[];const l=()=>{o.push({heading:r,body:s.join(`
|
|
1099
|
-
`)}),s=[]};for(const a of n){const
|
|
1100
|
-
`)){const r=
|
|
1101
|
-
`)?"":n)}function
|
|
1102
|
-
`);let c=0;return e.jsx(e.Fragment,{children:d.map((p,u)=>{const g=p.match(oi);if(g){const h=c++;if(l(g[1].length,g[2],h))return null;const{Tag:f,className:v}=a(g[1].length);return e.jsx(f,{className:v,children:o(g[2])},u)}if(!p.trim())return u>=2&&!!d[u-1].trim()&&!!d[u-2].trim()&&!oi.test(d[u-1])&&!oi.test(d[u-2])?e.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if($u.test(p))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(p.trim())){const{Tag:h,className:f}=a(3);return e.jsx(h,{className:f,children:o(p.trim().slice(2,-2))},u)}return e.jsx("p",{className:fr(p),children:xr(p,o,u)},u)})})}function Tu(t){const{convert:n}=Te();return x.useMemo(()=>t?n(t):"",[t,n])}function co({text:t,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:l,dropTitle:a}){const d=Tu(t),{t:c,convert:p}=K(),u=h=>ao(h,{renderText:l,properNames:s,gujiMarkdown:r,t:c}),g=r?{gujiMarkdown:!0,t:c}:void 0,m=a?p(a):void 0;return!o||d.indexOf(":::")<0?e.jsx(br,{text:d,mode:n,inline:u,dropTitle:m}):e.jsx(e.Fragment,{children:Gi(d).map((h,f)=>h.type==="table"?e.jsx(ro,{table:h.table,opts:g},f):e.jsx(br,{text:h.text,mode:n,inline:u,dropTitle:f===0?m:void 0},f))})}function Nu(t,n){const[o,r]=x.useState(null),[s,l]=x.useState(!1),a=x.useRef(0);return x.useEffect(()=>{const d=++a.current;if(!t||!n){r(null),l(!1);return}let c;try{c=t(n)}catch{r(null),l(!1);return}if(!c||typeof c.then!="function"){r(c??null),l(!1);return}l(!0),c.then(p=>{d===a.current&&r(p??null)}).catch(()=>{d===a.current&&r(null)}).finally(()=>{d===a.current&&l(!1)})},[t,n]),{images:o,loading:s}}const yr={A:"fine",B:"rough",C:"rough",D:"ocr"};function Iu(t){return typeof t!="string"?null:t in bc?t:t in yr?yr[t]:null}const Eu={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},Ru={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"};function rt(t){return typeof t!="string"?"":Eu[t]??Ru[t]??t}const Lu=["〇","一","二","三","四","五","六","七","八","九"],jr=["","十","百","千"],Pu=["","萬","億"];function po(t){if(t===0)return"〇";if(t<0)return`負${po(-t)}`;const n=[];let o=t,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(Au(s,r>0)+Pu[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Au(t,n){const o=[];let r=t;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let l=0;l<o.length;l++){const a=o[l],d=o.length-1-l;a===0?s&&!s.endsWith("〇")&&(s+="〇"):a===1&&d===1&&l===0&&!n?s+=jr[d]:s+=Lu[a]+jr[d]}return s.replace(/〇$/,"")}let on=null,fn=null;const Cn=new Set;function Bu(){return on?Promise.resolve():fn||(fn=import("opencc-js/t2cn").then(t=>{const n=t.Converter({from:"tw",to:"cn"});on=o=>n(he.normalizeVariants(o)),Cn.forEach(o=>o())}).catch(()=>{on=t=>t,Cn.forEach(t=>t())}),fn)}const Mu=t=>t;function It(){const[,t]=x.useState(0);return x.useEffect(()=>{if(on)return;const n=()=>t(o=>o+1);return Cn.add(n),Bu(),()=>{Cn.delete(n)}},[]),on??Mu}function Mt(t,n){return n(t).toLowerCase()}const Wu=i("highlight-bg");function pn(t,n,o){if(!n)return t;const r=Mt(n,o);if(!r)return t;const s=Mt(t,o);if(s.length!==t.length)return t;const l=[];let a=0,d=0;for(;a<t.length;){const c=s.indexOf(r,a);if(c===-1){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{style:{background:Wu,padding:0,color:"inherit"},children:t.slice(c,c+r.length)},d++)),a=c+r.length}return e.jsx(e.Fragment,{children:l})}function uo(t,n,o,r){if(!n)return!0;const s=Mt(n,r);return(o?[t.title,t.header_line,t.content,t.comment]:[t.title,t.book_title,t.author,t.author_info,t.summary,t.content,t.comment,t.additional_comment]).some(a=>typeof a=="string"&&Mt(a,r).includes(s))}function Hu(t,n,o){return n?Mt(t,o).includes(Mt(n,o)):!0}const mo={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},Ou={考证:i("section-kaozhen")};function go(t,n,o){return t.collated.sectionType[n]??o(n)}function Ll(t){var r;const n=t.files.length,o=((r=t.children)==null?void 0:r.reduce((s,l)=>s+Ll(l),0))||0;return n+o}function Fu(t,n){const o=[],r=a=>{var d;o.push(...a.files),(d=a.children)==null||d.forEach(r)};if(r(t),o.length===0)return;const s=o.map(a=>n[a]);if(s.every(a=>a===void 0))return;if(s.some(a=>a==="loading"))return"loading";let l=0;for(const a of s)typeof a=="number"&&(l+=a);return l}const Du={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function ho({enabled:t,expanded:n,onClick:o,style:r,children:s}){return t?e.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...Du,...r},children:s}):e.jsx("span",{style:r,children:s})}function Uu({type:t}){const{convert:n,messages:o}=K(),r=rt(t),s=mo[r]||i("desc-fg");return e.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:go(o,r,n)})}function Vu({section:t,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:l}){const{t:a,convert:d}=K(),c=Ve(),p=It(),u=j=>j?nt(d(j),w=>o?pn(w,o,p):w,{t:a}):"",[g,m]=x.useState(!1),h=!!t.summary,f=!!t.comment,v=!!t.additional_comment,y=!!(t.content&&t.content.length>60),k=h||f||v||y;x.useEffect(()=>{o&&m(!0)},[o]);const b=!g&&y?jl(t.content.replace(/\n/g," "),80)+"…":null;return e.jsxs("div",{className:"bim-rd-row",id:l,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[e.jsxs("div",{onClick:()=>k&&m(!g),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[r!=null&&e.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),e.jsxs(ho,{enabled:k,expanded:g,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[k&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:[t.book_title?e.jsxs(e.Fragment,{children:["《",u(t.book_title),"》"]}):u(t.title),t.n_juan!=null&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:a("collated.nJuan",{n:d(po(t.n_juan))})}),(t.author_info||t.author)&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:u(t.author_info||t.author)})]}),!g&&b&&e.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:u(b)})]})]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u(t.edition)}),t.tag&&e.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:t.tag==="triangle"?"△":t.tag}),t.work_id&&n&&e.jsx("a",{href:c(t.work_id),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(t.work_id))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),"aria-label":a("collated.viewWorkOf",{title:d(t.book_title||t.title)}),children:a("collated.workArrow")}),s&&!t.work_id&&e.jsx("span",{style:{fontSize:"11px",color:i("label-fg"),flexShrink:0},children:a("collated.unlinked")})]}),g&&k&&e.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[t.author_info&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:u(t.author_info)}),t.summary&&e.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.summary")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:u(t.summary)})]}),t.comment&&e.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.comment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.comment)})]}),t.additional_comment&&e.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.additionalComment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.additional_comment)})]}),y&&!h&&!f&&!v&&e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)})]})]})}function Gu({section:t,highlightQuery:n=""}){const{t:o,convert:r}=K(),s=It(),l=p=>p?nt(r(p),u=>n?pn(u,n,s):u,{t:o}):"",[a,d]=x.useState(!1),c=!!t.content;return e.jsxs("div",{style:{padding:"12px 0 6px"},children:[e.jsxs(ho,{enabled:c,expanded:a,onClick:()=>d(!a),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[e.jsx(Uu,{type:t.type}),e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:l(t.title)}),c&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:a?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),a&&c&&e.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${mo[rt(t.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:l(t.content)})})]})}const Yu=100;function xo(t){return rt(t.type)!=="page_header"?!1:(t.content||"").length>=Yu}function Ku({section:t,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=K(),l=It();if(rt(t.type)==="page_header"&&!xo(t)||!t.content&&!t.title)return null;const a=r((t.content||t.title||"").replace(/\n{2,}/g,`
|
|
1103
|
-
`)),d=nt(a,g=>n?pn(g,n,l):g,{t:o}),c=rt(t.type),p=mo[c]||i("desc-fg"),u=c==="序"||c==="结语"||c==="注释";return e.jsxs("div",{style:{padding:u?"10px 12px":"6px 0",margin:u?"8px 0":void 0,fontSize:"13px",color:i("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:u?`3px solid ${p}40`:void 0,background:u?i("bg"):void 0,borderRadius:u?"0 4px 4px 0":void 0,position:"relative"},children:[u&&e.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:go(s,c,r)}),d]})}function qu(t,n,o){const[r,s]=x.useState({});return x.useEffect(()=>{var p;if(!n||t.length===0)return;let l=!1;const a=t.filter(u=>{var g;return!((g=o==null?void 0:o.current)!=null&&g.has(u))}),d={};for(const u of t)(p=o==null?void 0:o.current)!=null&&p.has(u)&&(d[u]=o.current.get(u));if(Object.keys(d).length>0&&s(d),a.length===0)return;const c=async u=>{var g;try{if(n.getEntry){const y=await n.getEntry(u);if(y)return{title:y.title,author:y.author}}const m=await n.getItem(u);if(!m)return null;const h=m.title||u,f=m.authors,v=(g=f==null?void 0:f[0])==null?void 0:g.name;return{title:h,author:v}}catch{return null}};return Promise.all(a.map(async u=>{var m;const g=await c(u);return(m=o==null?void 0:o.current)==null||m.set(u,g),[u,g]})).then(u=>{l||s(g=>{const m={...g};for(const[h,f]of u)m[h]=f;return m})}),()=>{l=!0}},[t.join(","),n]),r}function Zu({section:t,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:l,convert:a,messages:d}=K(),c=Ve(),p=It(),u=w=>w?nt(a(w),S=>s?pn(S,s,p):S,{t:l}):"",[g,m]=x.useState(!1);x.useEffect(()=>{s&&m(!0)},[s]);const h=rt(t.type),f=Ou[h]||i("desc-fg"),v=!!t.content,y=t.work_ids||[],k=y.length>1,b=qu(k?y:[],o,r),j=v&&!g&&t.content.length>80?jl(t.content,80)+"……":null;return e.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[e.jsxs("div",{onClick:()=>v&&m(!g),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:v?"pointer":"default",userSelect:"none"},children:[e.jsxs(ho,{enabled:v,expanded:g,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[v&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{display:"block",flex:1},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg"),lineHeight:1.6},children:t.header_line?u(t.header_line):u(t.title)}),!g&&j&&e.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:u(j)})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&e.jsx("a",{href:c(y[0]),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),children:l("collated.arrowWork")}),k&&e.jsx("span",{style:{fontSize:"11px",color:i("link-fg"),flexShrink:0},children:l("collated.nWorks",{n:y.length})}),e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:f,border:`1px solid ${f}40`,borderRadius:"2px",background:`${f}08`},children:go(d,h,a)})]})]}),k&&n&&e.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(w=>{const S=b[w],$=S?`${a(S.title)}${S.author?`(${a(S.author)})`:""}`:w.slice(0,8)+"…";return e.jsxs("a",{href:c(w),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),_.stopPropagation(),n(w))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:w,children:["→",$]},w)})}),g&&v&&e.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${f}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)}),t.comment&&e.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${i("widget-border")}`,fontSize:"12px",color:i("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:u(t.comment)})]})]})}function Ju({juan:t,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:l}=K(),a=It(),d=n.trim(),c=x.useMemo(()=>d?t.sections.filter(p=>uo(p,d,!0,a)):t.sections,[t.sections,d,a]);return e.jsxs("div",{children:[e.jsx("div",{children:c.map((p,u)=>e.jsx(Zu,{section:p,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:d},u))}),c.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:l("collated.noMatch")})]})}function Xu(){let t=!1;return n=>n==="类"?(t=!0,"h2"):t?"h3":"h2"}function Qu({sections:t,onNavigate:n,inline:o,workLinks:r=!0}){const s=Ve(),{t:l,convert:a}=K(),d=Xu();return e.jsx(e.Fragment,{children:t.map((c,p)=>{const u=rt(c.type);if(u==="page_header"&&!xo(c))return null;if(u==="类")return e.jsxs(x.Fragment,{children:[x.createElement(d("类"),null,o(a(c.title))),c.content&&e.jsx("p",{children:o(a(c.content))})]},p);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const g=c.book_title?`《${c.book_title}》${c.n_juan!=null?l("collated.nJuan",{n:po(c.n_juan)}):""}`:c.title,m=o(a(g));return e.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[x.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},title:l("collated.viewWork"),children:m}),e.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},"aria-label":l("collated.viewWorkOf",{title:a(g)}),children:l("collated.workArrow")})]}):m),c.author_info&&e.jsx("p",{className:"bim-rd-sub",children:o(a(c.author_info))}),c.content&&c.content.split(/\n+/).map((h,f)=>e.jsx("p",{children:o(a(h))},f)),c.summary&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.summary")}),o(a(c.summary))]}),c.comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.comment")}),o(a(c.comment))]}),c.additional_comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.additionalComment")}),o(a(c.additional_comment))]})]},p)}return c.content?e.jsx("p",{children:o(a(c.content))},p):null})})}function Pl(t){return t.some(n=>{const o=rt(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&xo(n)})}function em({juan:t,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:l,onNavigate:a,transport:d,workLabelCache:c,prefs:p,view:u,onViewChange:g}){var ee;const{t:m,convert:h,messages:f}=K(),v=It(),[y,k]=x.useState("text"),b=u??y,j=L=>{k(L),g==null||g(L)},w=l.trim(),S=(s==null?void 0:s.type)==="kaozhen",$=x.useCallback(L=>w?pn(L,w,v):L,[w,v]),_=L=>ao(L,{renderText:$,properNames:p.properNames,t:m}),C=x.useMemo(()=>w?t.sections.filter(L=>uo(L,w,S,v)):t.sections,[t.sections,w,S,v]),I=(L,U)=>U.filter(de=>rt(de.type)===L).length,T=I("书",t.sections),z=I("诗",t.sections),H=I("考证",t.sections);let W="";S?W=w?m("collated.countTiaoOf",{m:I("考证",C),n:H}):m("collated.countTiao",{n:H}):z>0?W=w?m("collated.countPoemsOf",{m:I("诗",C),n:z}):m("collated.countPoems",{n:z}):T>0&&(W=w?m("collated.countBooksOf",{m:I("书",C),n:T}):m("collated.countBooks",{n:T}));const A=s!=null&&s.text_quality?Iu(s.text_quality.grade):null,Y=[];W&&Y.push(W),S&&(s!=null&&s.target_source)&&Y.push(e.jsx(e.Fragment,{children:m("collated.kaozhenTarget",{target:h(s.target_source)})})),A&&Y.push(e.jsx("span",{title:f.collated.qualityCriteria[A],children:(ee=s==null?void 0:s.text_quality)!=null&&ee.source_note?e.jsxs(e.Fragment,{children:[m("collated.baseText",{note:h(s.text_quality.source_note)}),e.jsx("span",{className:"bim-rd-grade",children:f.collated.qualityLabel[A]})]}):e.jsxs(e.Fragment,{children:[m("collated.textQuality"),e.jsx("span",{className:"bim-rd-grade",children:f.collated.qualityLabel[A]})]})})),t.source_url&&Y.push(e.jsx("a",{className:"bim-rd-link",href:t.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const G=!S&&Pl(t.sections),te=!!n&&(!G||p.readingMode==="paragraph"&&_n(n)),pe=!S&&(G||!!n),B=S||!pe?"entries":b;let E=0;return e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[(o||r)&&e.jsxs("p",{className:"bim-rd-kicker",children:[o,o&&r&&e.jsx("span",{className:"bim-rd-dot"}),r&&h(r)]}),e.jsx("h1",{className:"bim-rd-h1",children:h(t.title)}),Y.length>0&&e.jsx("p",{className:"bim-rd-meta",children:Y.map((L,U)=>e.jsxs(x.Fragment,{children:[U>0&&e.jsx("span",{className:"bim-rd-dot"}),L]},U))}),pe&&t.sections.length>0&&e.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":m("collated.viewsGroup"),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":B==="text",onClick:()=>j("text"),children:m("collated.viewText")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":B==="entries",onClick:()=>j("entries"),children:m("collated.viewEntries")})]})]}),B==="text"&&e.jsx("article",{className:"bim-rd-prose",children:te?e.jsx(co,{text:n,mode:p.readingMode,properNames:p.properNames,renderText:$,dropTitle:t.title}):e.jsx(Qu,{sections:t.sections,onNavigate:a,inline:_,workLinks:p.workLinks})}),B==="entries"&&e.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:S?e.jsx(Ju,{juan:t,searchQuery:l,onNavigate:a,transport:d,workLabelCache:c}):e.jsxs(e.Fragment,{children:[C.some(L=>["书","诗","考证"].includes(rt(L.type)))&&e.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[e.jsx("span",{style:{width:28},children:m("collated.rowHeadNo")}),e.jsx("span",{style:{flex:1},children:m("collated.rowHeadTitle")}),e.jsx("span",{children:m("collated.rowHeadWork")})]}),C.map((L,U)=>{const de=rt(L.type);return de==="书"||de==="诗"||de==="考证"?(E+=1,e.jsx(Vu,{domId:`rd-e-${t.sections.indexOf(L)}`,section:L,onNavigate:p.workLinks?a:void 0,highlightQuery:w,no:E,showUnlinked:p.workLinks&&!!a},U)):de==="类"?e.jsx(Gu,{section:L,highlightQuery:w},U):e.jsx(Ku,{section:L,highlightQuery:w},U)}),C.length===0&&e.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function tm(t){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:l,activeRawText:a,query:d,isKaozhen:c}=t,p=It(),u=x.useRef(new Map),[g,m]=x.useState({}),[h,f]=x.useState({}),v=x.useCallback((k,b)=>{const j=b==null?void 0:b.title;j&&f(w=>w[k]===j?w:{...w,[k]:j})},[]);x.useEffect(()=>{s&&l&&(u.current.set(s,{juan:l,rawText:a}),v(s,l))},[s,l,a,v]),x.useEffect(()=>{u.current.clear(),m({}),f({})},[n]);const y=x.useCallback((k,b)=>{let j=0;if(k.juan)for(const w of k.juan.sections)uo(w,b,c,p)&&j++;return j===0&&k.rawText&&Hu(k.rawText,b,p)&&(j=1),j},[c,p]);return x.useEffect(()=>{const k=d.trim();if(!k){m({});return}if(!o||r.length===0)return;let b=!1;const j={},w=[];for(const I of r){const T=u.current.get(I);T?j[I]=y(T,k):(j[I]="loading",w.push(I))}m(j);const S=8;let $=0;const _=async()=>{for(;$<w.length;){if(b)return;const I=$++,T=w[I];try{const z=await o(T),H=z.juan;if(u.current.set(T,z),v(T,H),b)return;m(W=>({...W,[T]:y(z,k)}))}catch{if(b)return;m(z=>({...z,[T]:0}))}}},C=Array.from({length:Math.min(S,w.length)},()=>_());return Promise.all(C),()=>{b=!0}},[d,n,o,r.join(","),y,p,v]),{matchStates:g,titles:h}}function nm({juan:t,view:n,onView:o,textHasEntries:r}){const{t:s,convert:l}=K(),a=t.sections.map((u,g)=>({s:u,i:g,t:rt(u.type)})).filter(u=>u.t==="书"||u.t==="诗");if(a.length===0)return null;const d=a.filter(u=>!!u.s.work_id).length,c=a.every(u=>u.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=u=>{const g=()=>{var m,h;return(h=(m=document.getElementById(`rd-e-${u}`))==null?void 0:m.scrollIntoView)==null?void 0:h.call(m,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?setTimeout(g,0):g()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-rd-rail-card",children:[e.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),e.jsxs("div",{className:"bim-rd-rail-n",children:[e.jsx("b",{children:a.length}),e.jsx("span",{children:c}),e.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),e.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:a.length}),children:e.jsx("span",{style:{width:`${Math.round(d/a.length*100)}%`}})})]}),e.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[e.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),e.jsx("ul",{className:"bim-rd-rail-list",children:a.map(({s:u,i:g})=>e.jsx("li",{children:e.jsxs("a",{href:`#rd-e-${g}`,onClick:m=>{m.preventDefault(),p(g)},children:[e.jsx("span",{className:`bim-rd-rail-dot${u.work_id?" on":""}`,"aria-hidden":"true"}),e.jsx("span",{children:l(u.book_title||u.title)})]})},g))})]})]})}const bn={padding:24,color:i("desc-fg"),fontSize:14},vr=/^https?:\/\//i;function im(t){if(!t||typeof t!="object")return null;const n=l=>typeof l=="string"&&l.trim()?l.trim():void 0,o=n(t.url),r=n(t.license_url),s={name:n(t.name),url:o&&vr.test(o)?o:void 0,license:n(t.license),license_url:r&&vr.test(r)?r:void 0,note:n(t.note)};return s.name||s.license||s.note?s:null}function om(t,n){return{work_id:n.work_id??t,title:n.title,type:n.type,juan_files:n.chapters.map(o=>o.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 rm(t,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(o=>o.vol_label)?"冊":(t==null?void 0:t.kind)==="collated"?"卷":"章"}function Al(t,n,o,r=!1){const s=o(`${n}${t.n}`);if(!t.title)return s;const l=o(t.title);return r&&!/^[卷冊册章篇回第]/.test(t.title)?`${s} ${l}`:l}function sm(t,n,o,r,s){var p;const l=new Map(t.chapters.map(u=>[u.file,u])),a=u=>u==="loading"?"…":typeof u=="number"&&u>0?u:void 0,d=(u,g)=>{const m=l.get(u);return{key:u,label:g??(m?Al(m,o,r,s):u),hint:a(n[u]),disabled:n[u]===0}},c=(p=t.juan_groups)==null?void 0:p.filter(u=>{var g;return u.files.some(m=>l.has(m))||((g=u.children)==null?void 0:g.length)});if(c&&c.length>0){const u=(g,m)=>{var f;if(g.files.length===1&&!((f=g.children)!=null&&f.length))return d(g.files[0],r(g.label));const h=Fu(g,n);return{key:`group:${m}`,label:r(g.label),hint:h==="loading"?"…":typeof h=="number"&&h>0?`${h}`:Ll(g),defaultExpanded:typeof h=="number"&&h>0,children:[...g.files.filter(v=>l.has(v)).map(v=>d(v)),...(g.children??[]).map((v,y)=>u(v,`${m}.${y}`))]}};return c.map((g,m)=>u(g,`${m}`))}return t.chapters.map(u=>d(u.file))}const fo=({id:t,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:l,title:a,subtitle:d,resolveImages:c,renderImageOverlay:p,imagePanel:u,allowVertical:g,onReportError:m,revisedAt:h,backHref:f,backLabel:v,className:y,style:k})=>{var Fe,Ne,Qe;const{t:b,convert:j}=K(),w=x.useMemo(()=>Us(n),[n]),[S,$]=Xs(),_=Ve(),C=x.useRef(s);C.current=s;const[I,T]=x.useState(null),[z,H]=x.useState("loading");x.useEffect(()=>{let V=!1;return T(null),H("loading"),w.getManifest(t).then(Pe=>{V||(Pe?(T(Pe),H("ready")):H("missing"))}).catch(()=>{V||H("missing")}),()=>{V=!0}},[w,t]);const W=o!==void 0,A=r!==void 0,[Y,G]=x.useState(null),[te,pe]=x.useState(null);x.useEffect(()=>{G(null),pe(null)},[t]);const B=he.pickTextVersion(I,W?o:Y),E=((Fe=I==null?void 0:I.versions.find(V=>V.key==="default"))==null?void 0:Fe.key)??((Ne=I==null?void 0:I.versions[0])==null?void 0:Ne.key)??"default",ee=(B==null?void 0:B.key)??null,L=A?r:te,U=x.useCallback((V,Pe,it)=>{var vt;(vt=C.current)==null||vt.call(C,{key:V,chapter:Pe,isDefault:V===E},it)},[E]);x.useEffect(()=>{!I||!W||o==null||I.versions.some(V=>V.key===o)||U(E,null,"auto")},[I,W,o,E,U]);const de=x.useRef(new Map);x.useEffect(()=>{de.current.clear()},[w,t]);const ve=x.useCallback(async V=>{const Pe=`${t}
|
|
1104
|
-
${
|
|
1105
|
-
${ee??""}`,load:Ae,files:Q,activeFile:ye??null,activeJuan:(ze==null?void 0:ze.json)??null,activeRawText:(ze==null?void 0:ze.md)??null,query:F,isKaozhen:R}),N=x.useRef(new Map);x.useEffect(()=>{N.current.clear()},[t]);const ne=Nu(c,ye??null),{entryTitle:J,authors:re}=cm(t,n,a===void 0),[Ce,Le]=x.useState("text");if(x.useEffect(()=>{Le("text")},[ye,ee]),z==="loading")return e.jsx("div",{className:y,style:{...k,...bn},children:b("reader.loading")});if(z==="missing"||!I||!B)return e.jsx("div",{className:y,style:{...k,...bn},children:b("reader.noText")});if(be==="failed")return e.jsx("div",{className:y,style:{...k,...bn},children:b("reader.tocFailed")});if(!Z)return e.jsx("div",{className:y,style:{...k,...bn},children:b("reader.tocLoading")});const $e=rm(B,Z),X=sm(Z,xe,$e,j,Se),Ie=I.versions.map(V=>({key:V.key,label:he.textVersionLabel(V),optionLabel:j(he.textVersionLabel(V)),sourceName:V.source_name?j(V.source_name):void 0,license:V.license??void 0,sourceUrl:V.source_url??void 0,primary:V.key===E})),fe=im((Qe=Z.source)==null?void 0:Qe.upstream),Me=(typeof a=="string"?j(a):a)??(Z.title?j(Z.title):J?j(J):void 0),P=Me?e.jsx("a",{href:_(t),title:b("reader.viewEntry"),onClick:l?V=>{V.metaKey||V.ctrlKey||(V.preventDefault(),l(t))}:void 0,children:Me}):void 0,q=re.length>0?j(re.slice(0,2).map(V=>`${V.dynasty?`〔${V.dynasty}〕`:""}${V.name}${` ${V.role||b("reader.defaultRole")}`}`).join("、")):void 0,se=_e?Al(_e,$e,j,Se):void 0,ue=Se&&!!(ze!=null&&ze.json),ie=(ze==null?void 0:ze.json)??null,M=(ze==null?void 0:ze.md)??null,ge=ue&&!R&&Pl(ie.sections),O=ge&&!(M&&S.readingMode==="paragraph"&&_n(M)),we=ue&&ge?e.jsx(nm,{juan:ie,view:Ce,onView:Le,textHasEntries:O}):void 0,je=Os(Z)||xi(Z),oe=M?M.replace(/^##\s+[^\n]+\n+/,""):null,Oe=(typeof d=="string"?j(d):d)??(B.source_name?j(B.source_name):j(he.textVersionLabel(B)));return e.jsxs(tl,{className:y,style:k,title:P,subtitle:Oe,byline:q,current:se,pagerUnit:$e,rail:we,revisedAt:h,backHref:f,backLabel:v,onReportError:m?V=>m({...V,bookTitle:typeof Me=="string"?Me:void 0,entryId:t}):void 0,workLinkToggle:ue&&!R&&!!l&&!!(ie!=null&&ie.sections.some(V=>V.work_id)),toc:X,tocCaption:b("reader.tocCaption",{n:Z.chapters.length,unit:j($e)}),tocHeader:Se&&Z.chapters.length>1?e.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:R?b("reader.searchChaptersPlaceholder"):b("reader.searchUnitPlaceholder",{unit:j($e)}),"aria-label":R?b("reader.searchChapters"):b("reader.searchUnit",{unit:j($e)}),value:F,onChange:V=>me(V.target.value)}):void 0,activeKey:ye??null,onSelect:Re,images:ne.images,imagesLoading:ne.loading,renderImageOverlay:p,imagePanel:u,prefs:S,onPrefsChange:$,versions:Ie.length>1?Ie:void 0,currentVersionKey:Ie.length>1?B.key:void 0,onVersionChange:Be,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:_n(M),allowVertical:g,children:[D&&e.jsx(Nt,{}),!D&&ue&&ie&&e.jsx(em,{juan:ie,rawText:M,positionLabel:lm(_e,Z,$e,j),groupLabel:am(Z,ye??null),index:om(t,Z),searchQuery:F,onNavigate:l,transport:n,workLabelCache:N,prefs:S,view:Ce,onViewChange:Le},`${ee}/${ye}`),!D&&!ue&&oe!=null&&_e&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("h1",{className:"bim-rd-h1",children:_e.title?j(_e.title):se}),(B.source_name||B.license)&&e.jsxs("p",{className:"bim-rd-meta",children:[B.source_name&&e.jsxs(e.Fragment,{children:[b("reader.textSource")," ",B.source_url?e.jsx("a",{className:"bim-rd-link",href:B.source_url,target:"_blank",rel:"noreferrer",children:j(B.source_name)}):j(B.source_name)]}),B.source_name&&B.license&&e.jsx("span",{className:"bim-rd-dot"}),B.license]}),fe&&e.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[b("reader.upstream")," ",fe.url?e.jsx("a",{className:"bim-rd-link",href:fe.url,target:"_blank",rel:"noreferrer",children:j(fe.name??fe.url)}):j(fe.name??""),fe.license&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),fe.license_url?e.jsx("a",{className:"bim-rd-link",href:fe.license_url,target:"_blank",rel:"noreferrer",children:fe.license}):fe.license]}),fe.note&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),j(fe.note)]})]})]}),e.jsx("article",{className:"bim-rd-prose",children:e.jsx(co,{text:oe,mode:S.readingMode,tables:je,gujiMarkdown:xi(Z),properNames:S.properNames})})]}),!D&&!ue&&oe==null&&_e&&e.jsx("div",{className:"bim-rd-state",children:b("reader.chapterFailed")}),Z.references&&Z.references.length>0&&e.jsxs("section",{className:"bim-rd-refs",children:[e.jsx("h2",{children:b("reader.references")}),e.jsx("ol",{children:Z.references.map((V,Pe)=>e.jsxs("li",{children:[V.url?e.jsx("a",{className:"bim-rd-link",href:V.url,target:"_blank",rel:"noopener noreferrer",children:j(V.title)}):e.jsx("span",{children:j(V.title)}),V.author&&e.jsxs("span",{children:[",",j(V.author)]}),V.note&&e.jsxs("span",{children:["。",j(V.note)]})]},Pe))})]})]})};function lm(t,n,o,r){var l,a;if(!t)return;const s=(a=(l=n.juan_metadata)==null?void 0:l[t.file])==null?void 0:a.vol_label;return r(s?`${s}冊`:`${o}${t.n}`)}function am(t,n){if(!n)return;const o=r=>{var s;for(const l of r??[]){const a=o(l.children);if(a)return a;if((s=l.files)!=null&&s.includes(n))return l.label}};return o(t.juan_groups)}function cm(t,n,o){const[r,s]=x.useState({entryTitle:void 0,authors:[]});return x.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let l=!1;return Promise.resolve(n.getItem(t)).then(a=>{if(l||!a)return;const d=(a.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof a.title=="string"?a.title:void 0,authors:d})}).catch(()=>{}),()=>{l=!0}},[t,n,o]),r}const Bl={bug:{key:"bug",color:i("danger")},resource:{key:"resource",color:i("primary")},suggestion:{key:"suggestion",color:i("primary")},other:{key:"other",color:i("desc-fg")}},dm=Bl.other,Ml={pending:{key:"pending",color:i("warning")},in_progress:{key:"in_progress",color:i("primary")},resolved:{key:"resolved",color:i("success")},wontfix:{key:"wontfix",color:i("desc-fg")},duplicate:{key:"duplicate",color:i("desc-fg")}},pm=Ml.pending;function um(t){try{const n=new Date(t),o=r=>String(r).padStart(2,"0");return`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())} ${o(n.getHours())}:${o(n.getMinutes())}`}catch{return t}}function mm(t,n){if(!t)return!1;try{const o=new URL(t,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const bo=({items:t,loading:n})=>{const o=Ve(),{t:r,convert:s}=K();return n?e.jsx(Nt,{}):t.length===0?e.jsx("div",{style:gm,children:r("feedback.empty")}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:t.map(l=>{const a=Bl[l.type]||dm,d=Ml[l.status]||pm,c=typeof window<"u"&&mm(l.pageUrl,window.location.href);return e.jsxs("div",{style:hm,children:[e.jsxs("div",{style:xm,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{...kr,background:a.color},children:r(`feedback.listType.${a.key}`)}),e.jsx("span",{style:{...kr,background:d.color},children:r(`feedback.status.${d.key}`)})]}),e.jsx("span",{style:fm,children:um(l.createdAt)})]}),(l.resourceId||l.pageUrl)&&e.jsxs("div",{style:bm,children:[l.resourceId&&e.jsx("a",{href:o(l.resourceId),style:ri,children:l.resourceId}),l.pageUrl&&!l.resourceId&&(c?e.jsx("a",{href:l.pageUrl,style:ri,children:l.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):e.jsx("span",{style:ri,children:l.pageUrl}))]}),e.jsx("div",{style:ym,children:s(l.content)}),l.reply&&e.jsxs("div",{style:jm,children:[e.jsx("div",{style:vm,children:r("feedback.reply")}),e.jsx("div",{children:s(l.reply)})]})]},l.id)})})},gm={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},hm={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},xm={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},kr={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},fm={fontSize:"12px",color:i("desc-fg")},bm={fontSize:"12px",marginBottom:"6px"},ri={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},ym={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},jm={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},vm={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},Ci=({transport:t,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:l})=>{const a=ke(),[d,c]=x.useState(null),[p,u]=x.useState([]),[g,m]=x.useState("recommend"),[h,f]=x.useState([]),[v,y]=x.useState(!1),k=r??g,b=Y=>{m(Y),s==null||s(Y)},[j,w]=x.useState(!0),[S,$]=x.useState(null),[_,C]=x.useState(null),[I,T]=x.useState(null);x.useEffect(()=>{let Y=!1;if(t.getCounts)return t.getCounts().then(G=>{Y||c({works:G.works,books:G.books,collections:G.collections})}).catch(()=>{}),()=>{Y=!0}},[t]),x.useEffect(()=>{let Y=!1;return(async()=>{if(o)return o;if(t.getRecommended)try{const te=await t.getRecommended();if(te!=null&&te.groups)return te.groups.flatMap(pe=>pe.items.map(B=>({...B,group:pe.name})))}catch{}return[]})().then(async te=>{if(Y)return;const pe=te.filter(E=>E.id);if(pe.length===0){w(!1);return}const B=await Promise.all(pe.map(async E=>{if(E.type)return{id:E.id,title:E.title,type:E.type,author:E.author,dynasty:E.dynasty,role:E.role,edition:E.edition,has_text:E.has_text,has_image:E.has_image,has_collated:E.has_collated,subtype:E.subtype,primary_name:E.primary_name,group:E.group,fallbackDescription:E.description};try{let ee=null;if(t.getEntry)ee=await t.getEntry(E.id);else{const L=await t.getItem(E.id);L&&(ee={id:E.id,title:L.title||E.id,type:L.type||"work"})}if(ee)return{...ee,group:E.group,fallbackDescription:E.description}}catch{}return{id:E.id,title:E.title,type:he.extractType(E.id),group:E.group,fallbackDescription:E.description}}));Y||(u(B.filter(E=>E!==null)),w(!1))}),()=>{Y=!0}},[t,o]);const z=x.useRef(!1),H=x.useRef(!1),W=x.useRef(!1);x.useEffect(()=>{if(k!=="catalog"||z.current)return;const Y=t.getCatalogProgress??t.getResourceProgress;if(!Y)return;z.current=!0;let G=!1;return Y.call(t).then(te=>{G||$(te)}).catch(()=>{z.current=!1}),()=>{G=!0}},[t,k]),x.useEffect(()=>{if(k!=="collection"||H.current||!t.getCollectionProgress)return;H.current=!0;let Y=!1;return t.getCollectionProgress().then(G=>{Y||C(G)}).catch(()=>{H.current=!1}),()=>{Y=!0}},[t,k]),x.useEffect(()=>{if(k!=="site"||W.current||!t.getSiteProgress)return;W.current=!0;let Y=!1;return t.getSiteProgress().then(G=>{Y||T(G)}).catch(()=>{W.current=!1}),()=>{Y=!0}},[t,k]),x.useEffect(()=>{if(!l||k!=="feedback")return;let Y=!1;return y(!0),fetch(l).then(G=>G.json()).then(G=>{!Y&&G.success&&f(G.items||[])}).catch(()=>{}).finally(()=>{Y||y(!1)}),()=>{Y=!0}},[l,k]);const A=Y=>e.jsx(Dt,{type:Y,size:12});return e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:e.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[e.jsx(Zt,{label:a.home.recommendTab,active:k==="recommend",onClick:()=>b("recommend")}),e.jsx(Zt,{label:a.home.catalogTab,active:k==="catalog",onClick:()=>b("catalog")}),e.jsx(Zt,{label:a.home.collectionTab,active:k==="collection",onClick:()=>b("collection")}),e.jsx(Zt,{label:a.home.siteTab,active:k==="site",onClick:()=>b("site")}),l&&e.jsx(Zt,{label:a.home.feedbackTab,active:k==="feedback",onClick:()=>b("feedback")})]}),k==="recommend"&&e.jsx(km,{recommended:p,loading:j,onNavigate:n,getIcon:A,t:a}),k==="catalog"&&e.jsx(wr,{progress:S,t:a,onNavigate:n}),k==="collection"&&e.jsx(wr,{progress:_,t:a,onNavigate:n}),k==="site"&&e.jsx(Sm,{progress:I,t:a,totalWorks:(d==null?void 0:d.works)??0}),k==="feedback"&&l&&e.jsx(bo,{items:h,loading:v})]})})},Zt=({label:t,active:n,onClick:o})=>e.jsx("button",{onClick:o,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:i(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${i("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:t}),km=({recommended:t,loading:n,onNavigate:o,getIcon:r,t:s})=>{const l=Ve();if(n)return e.jsx(Nt,{});if(t.length===0)return null;const a=new Map;for(const d of t){const c=d.group||s.home.recommendedBrowse;a.has(c)||a.set(c,[]),a.get(c).push(d)}return e.jsx(e.Fragment,{children:Array.from(a.entries()).map(([d,c])=>e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:d}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(p=>{const u=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return e.jsxs("a",{href:l(p.id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),o==null||o(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,cursor:"pointer",background:i("input-bg"),textDecoration:"none",color:"inherit"},children:[e.jsx("span",{style:{fontSize:"20px"},children:r(p.type)}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.title,p.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:p.edition})]}),u&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},p.id)})})]},d))})},wr=({progress:t,t:n,onNavigate:o})=>{if(!t)return e.jsx(Nt,{});const r=[...t.resources].sort((d,c)=>d.priority-c.priority),s=["in_progress","done","todo"],l={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},a={in_progress:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return e.jsx("div",{children:s.map(d=>{const c=r.filter(p=>p.status===d);return c.length===0?null:e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:a[d]}}),l[d]," (",c.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(p=>e.jsx(wm,{item:p,t:n,statusColor:a[d],onNavigate:o},p.id))})]},d)})})},wm=({item:t,t:n,statusColor:o,onNavigate:r})=>{const s=Ve(),l=t.total>0?Math.round(t.imported/t.total*100):0,a=t.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const d=t.edition?`${t.name}·${t.edition}`:t.name,c=t.collection_id||t.work_id;return c&&r?e.jsx("a",{href:s(c),onClick:p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),r(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},onMouseEnter:p=>p.currentTarget.style.borderBottomStyle="solid",onMouseLeave:p=>p.currentTarget.style.borderBottomStyle="dashed",children:d}):t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:d}):d})()}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:i("widget-border"),color:i("desc-fg"),whiteSpace:"nowrap"},children:t.collection_id?n.indexType.collection:t.work_id?n.indexType.work:a})]}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.total>0?tt(n.home.progressFormat,{imported:String(t.imported),total:String(t.total)}):n.home.totalPending})]}),t.total>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${l}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},Sm=({progress:t,t:n,totalWorks:o})=>{if(!t)return e.jsx(Nt,{});const r=[...t.resources].sort((c,p)=>c.priority-p.priority),s=r.filter(c=>c.imported>0),l=r.filter(c=>c.imported===0),a=s.reduce((c,p)=>Math.max(c,p.imported),0),d=o>0?Math.round(a/o*100):0;return e.jsxs("div",{children:[o>0&&e.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${i("primary")} 6%, transparent)`,fontSize:"13px",color:i("fg")},children:[n.home.siteCoverage,": ",e.jsx("strong",{children:a.toLocaleString()})," / ",o.toLocaleString()," ",n.indexType.work," (",d,"%)"]}),s.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>e.jsx(Sr,{item:c,t:n,totalWorks:o},c.id))})]}),l.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",l.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:l.map(c=>e.jsx(Sr,{item:c,t:n,totalWorks:o},c.id))})]})]})},Sr=({item:t,t:n,totalWorks:o})=>{const r=o>0?Math.round(t.imported/o*100):0;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:t.name}):t.name})}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.imported>0?`${t.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),t.imported>0&&o>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},$r="(max-width: 768px)";function $m(){const[t,n]=x.useState(()=>typeof window>"u"?!1:window.matchMedia($r).matches);return x.useEffect(()=>{const o=window.matchMedia($r),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),t}const _m=({transport:t,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var H;const l=ke(),{convert:a}=Te(),d=$m(),[c,p]=x.useState(null),[u,g]=x.useState(null),[m,h]=x.useState(!1),[f,v]=x.useState("detail"),[y,k]=x.useState([]),[b,j]=x.useState(!1),w=x.useCallback(async W=>{if(!t.getCollectionCatalogs&&!t.getCollectionCatalog){k([]);return}j(!0);try{if(t.getCollectionCatalogs){const A=await t.getCollectionCatalogs(W);k(A||[])}else if(t.getCollectionCatalog){const A=await t.getCollectionCatalog(W);k(A?[{resource_id:"",data:A}]:[])}}catch{k([])}finally{j(!1)}},[t]),S=x.useCallback(async W=>{if(o){o(W);return}p(W),g(null),k([]),v("detail"),h(!0);try{const A=await t.getItem(W.id);A&&(g(A),A.type==="collection"&&w(W.id))}catch(A){console.error("加载详情失败:",A)}finally{h(!1)}},[t,o,w]),$=x.useCallback(async W=>{g(null),k([]),v("detail"),h(!0);try{const A=await t.getItem(W);A&&(g(A),p({id:W,title:A.title||W,type:A.type||"book"}),A.type==="collection"&&w(W))}catch(A){console.error("导航失败:",A)}finally{h(!1)}},[t,w]),_=typeof(u==null?void 0:u.text_count)=="number"&&u.text_count>0,C=(u==null?void 0:u.type)==="collection"&&(y.length>0||b)||(u==null?void 0:u.type)==="work"&&_,I=d&&(m||u),T=x.useCallback(()=>{p(null),g(null),k([]),v("detail")},[]),z=e.jsx(e.Fragment,{children:m?e.jsx(Nt,{}):u?e.jsxs(e.Fragment,{children:[(C||s)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${i("widget-border")}`,padding:d?"0 12px":"0 48px",background:i("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[C&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v("detail"),style:yn(f==="detail"),children:l.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&e.jsxs("button",{onClick:()=>{},style:yn(!1),children:[l.detailTab.catalog,e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&y.map(W=>e.jsx("button",{onClick:()=>v(`catalog:${W.resource_id}`),style:yn(f===`catalog:${W.resource_id}`),children:W.short_name?`${a(W.short_name)}${l.detailTab.catalogSuffix}`:l.detailTab.collectionCatalog},W.resource_id)),u.type==="work"&&_&&e.jsx("button",{onClick:()=>v("collated"),style:yn(f==="collated"),children:l.detailTab.collatedEdition})]}),s&&e.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),e.jsx("div",{style:{padding:d?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:f==="detail"?e.jsx(Ui,{data:u,transport:t,onNavigate:$}):f.startsWith("catalog:")?e.jsx(Vi,{data:(H=y.find(W=>`catalog:${W.resource_id}`===f))==null?void 0:H.data,onNavigate:$}):f==="collated"?e.jsx(fo,{id:u.id,transport:t,onNavigate:$}):null})]}):e.jsx(Ci,{transport:t,onNavigate:$,recommendedIds:r})});return d?e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:I?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:e.jsxs("button",{onClick:T,style:{padding:"4px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",l.detailTab.basicInfo]})}),e.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:z})]}):e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[e.jsx(hi,{transport:t,onEntryClick:S,hideModeIndicator:n}),!u&&e.jsx(Ci,{transport:t,onNavigate:$,recommendedIds:r})]})}):e.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:[e.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsx(hi,{transport:t,onEntryClick:S,hideModeIndicator:n})})}),e.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:z})]})};function yn(t){return{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}const Cm=({data:t,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:l}=K(),[a,d]=x.useState(((u=t.divisions[0])==null?void 0:u.name)??null),[c,p]=x.useState(null);return e.jsxs("div",{className:o,style:r,children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:l(t.title)}),t.stats&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg"),display:"flex",gap:"16px"},children:[t.total_volumes!=null&&e.jsxs("span",{children:[s("catalog.totalVolumes")," ",e.jsx("strong",{children:t.total_volumes})," ",s("unit.juan")]}),t.stats.zhulu!=null&&e.jsxs("span",{children:[s("catalogPage.zhulu")," ",e.jsx("strong",{children:t.stats.zhulu})," ",s("unit.bu")]}),t.stats.cunmu!=null&&e.jsxs("span",{children:[s("catalogPage.cunmu")," ",e.jsx("strong",{children:t.stats.cunmu})," ",s("unit.bu")]}),t.stats.categories!=null&&e.jsx("span",{children:s("catalogPage.categoriesN",{n:t.stats.categories})})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.divisions.map(g=>e.jsx(zm,{division:g,expanded:a===g.name,onToggle:()=>d(a===g.name?null:g.name),expandedCat:c,onCatToggle:m=>p(c===m?null:m),onNavigate:n},g.name))})]})},zm=({division:t,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:l})=>{const{t:a,convert:d}=K(),c=t.categories.reduce((p,u)=>{const g=u.stats||{zhulu:0,cunmu:0};return p+(g.zhulu||0)+(g.cunmu||0)},0);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${i("primary")} 6%, transparent)`:i("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:i("fg"),textAlign:"left"},children:[e.jsx("span",{children:d(t.name)}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg")},children:[a("catalogPage.divisionStat",{cats:t.categories.length,books:c}),e.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&e.jsx("div",{style:{padding:"4px 0"},children:t.categories.map(p=>{const u=`${t.name}/${p.name}`;return e.jsx(Tm,{category:p,expanded:r===u,onToggle:()=>s(u),onNavigate:l},p.name)})})]})},Tm=({category:t,expanded:n,onToggle:o,onNavigate:r})=>{var p,u,g,m;const{t:s,convert:l}=K(),a=((p=t.books)==null?void 0:p.zhulu)||[],d=((u=t.books)==null?void 0:u.cunmu)||[],c=(((g=t.stats)==null?void 0:g.zhulu)||a.length)+(((m=t.stats)==null?void 0:m.cunmu)||d.length);return e.jsxs("div",{children:[e.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?i("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:i("fg"),textAlign:"left"},children:[e.jsxs("span",{style:{fontWeight:500},children:[l(t.name),t.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:l(t.volumes)})})]}),e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(a.length>0||d.length>0)&&e.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[a.length>0&&e.jsx(_r,{label:s("catalogPage.zhulu"),books:a,onNavigate:r}),d.length>0&&e.jsx(_r,{label:s("catalogPage.cunmu"),books:d,onNavigate:r})]})]})},_r=({label:t,books:n,onNavigate:o})=>{const{t:r,convert:s}=K(),l=Ve(),[a,d]=x.useState(n.length<=20),c=a?n:n.slice(0,10);return e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[t," (",n.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[e.jsx("span",{style:{fontWeight:500,color:i("fg")},children:p.work_id&&o?e.jsx("a",{href:l(p.work_id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),o(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.volumes)}),p.author&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.author).slice(0,20)})]},u))}),!a&&e.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:r("catalogPage.expandAllN",{n:n.length})})]})},st=({title:t,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const l=ke();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:t}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&e.jsx("button",{onClick:o,style:Im,children:"AI"}),n&&e.jsx("button",{onClick:n,style:Nm,children:l.action.save})]})]}),s]})},Nm={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Im={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},et=({label:t,value:n,onChange:o,placeholder:r,disabled:s})=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:t}),e.jsx("input",{type:"text",value:n,onChange:l=>o(l.target.value),placeholder:r,disabled:s,style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),Ct=({value:t,onChange:n,placeholder:o})=>{const r=x.useRef(null);return x.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[t]),e.jsx("textarea",{ref:r,value:t||"",onChange:s=>n(s.target.value),placeholder:o,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},zn=({children:t,color:n,style:o})=>e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||i("primary-soft"),color:i(n?"on-color-fg":"fg"),...o},children:t});function Em(t){const n=t.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const vn=({value:t,onChange:n,label:o})=>{const[r,s]=x.useState(!1),l=x.useRef(null),a=Em(t||"");return x.useEffect(()=>{r&&l.current&&l.current.focus()},[r]),!r&&a?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Cr,children:o}),e.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${i("input-border")}`,borderRadius:"2px",background:i("input-bg"),cursor:"pointer",minHeight:"30px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:a.name}),e.jsx(zn,{children:a.id})]})]}):e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Cr,children:o}),e.jsx("input",{ref:l,type:"text",value:t||"",onChange:d=>n(d.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Cr={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function Rm(t){switch(t){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function Lm(t){switch(t){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Wl=({items:t,onChange:n,onOpenEntityPicker:o})=>{const r=ke(),[s,l]=x.useState(null),a=()=>{n([...t,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),l(t.length)},d=g=>{n(t.filter((m,h)=>h!==g)),s===g&&l(null)},c=(g,m,h)=>{const f=[...t];f[g]={...f[g],[m]:h},n(f)},p=(g,m)=>{const h=[...t];h[g]={...h[g],type:m,id:"",name:""},n(h),m==="bookID"&&o&&o(f=>{const v=[...t];v[g]={...v[g],id:f.id,name:f.title,type:"bookID"},n(v)})},u=g=>{o&&o(m=>{const h=[...t];h[g]={...h[g],id:m.id,name:m.title,type:"bookID"},n(h)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((g,m)=>e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>l(s===m?null:m),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:g.name||`${r.editor.sourcePlaceholder} ${m+1}`}),g.type&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Rm(g.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Lm(g.type)}),e.jsx("button",{onClick:h=>{h.stopPropagation(),d(m)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===m&&e.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!g.type&&e.jsxs("div",{children:[e.jsx("label",{style:pt,children:r.editor.selectSourceType}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsxs("button",{onClick:()=>p(m,"bookID"),style:{...zr,borderColor:i("source-bookid"),color:i("source-bookid")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"📚"}),e.jsx("span",{children:"Book ID"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.fromExistingBook})]}),e.jsxs("button",{onClick:()=>p(m,"url"),style:{...zr,borderColor:i("source-url"),color:i("source-url")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),e.jsx("span",{children:"URL"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.enterUrl})]})]})]}),g.type==="bookID"&&e.jsx(e.Fragment,{children:e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:pt,children:r.action.selectBookOrWork}),e.jsx("button",{onClick:()=>{const h=[...t];h[m]={...h[m],type:"",id:"",name:""},n(h)},style:Tr,children:r.action.changeType})]}),g.id&&g.name?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[e.jsx("span",{style:{color:i("source-bookid"),fontSize:"16px"},children:"✓"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:g.name}),e.jsx("code",{style:{fontSize:"11px",background:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:g.id})]}),e.jsx("button",{onClick:()=>u(m),style:{background:"transparent",border:`1px solid ${i("widget-border")}`,color:i("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:r.action.reselect})]}):e.jsxs("button",{onClick:()=>u(m),style:{width:"100%",padding:"14px",border:`2px dashed ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[e.jsx("span",{children:"🔍"}),e.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),g.type==="url"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:pt,children:r.label.sourceName}),e.jsx("button",{onClick:()=>{const h=[...t];h[m]={...h[m],type:"",id:"",name:""},n(h)},style:Tr,children:r.action.changeType})]}),e.jsx("input",{type:"text",value:g.name,onChange:h=>c(m,"name",h.target.value),placeholder:r.editor.sourceNamePlaceholder,style:Et})]}),e.jsxs("div",{children:[e.jsx("label",{style:pt,children:r.label.urlAddress}),e.jsx("input",{type:"text",value:g.id,onChange:h=>c(m,"id",h.target.value),placeholder:"https://...",style:Et})]})]}),g.type&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:e.jsx("label",{style:{...pt,opacity:.7},children:r.label.optionalInfo})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:pt,children:r.label.detailsOptional}),e.jsx("input",{type:"text",value:g.details,onChange:h=>c(m,"details",h.target.value),placeholder:r.editor.detailsPlaceholder,style:Et})]}),e.jsxs("div",{children:[e.jsx("label",{style:pt,children:r.label.positionOptional}),e.jsx("input",{type:"text",value:g.position,onChange:h=>c(m,"position",h.target.value),placeholder:"如: 卷三, p.52",style:Et})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:pt,children:r.label.dataVersionOptional}),e.jsx("input",{type:"text",value:g.version,onChange:h=>c(m,"version",h.target.value),placeholder:"如: v1.0, 2024-01",style:Et})]}),e.jsxs("div",{children:[e.jsx("label",{style:pt,children:r.label.processorVersionOptional}),e.jsx("input",{type:"text",value:g.processor_version,onChange:h=>c(m,"processor_version",h.target.value),placeholder:"如: v0.1",style:Et})]})]})]})]})})]},m)),e.jsxs("button",{onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:r.action.addSource})]})]})},pt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},Et={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},zr={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:i("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},Tr={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Hl(t){if(!t||!t.trim())return[];try{const n=JSON.parse(t);if(Array.isArray(n))return n.map(o=>({id:o.id||"",name:o.name||"",type:o.type||"",details:o.details||"",position:o.position||"",version:o.version||"",processor_version:o.processor_version||""}))}catch{}return[]}function Ol(t){return!t||t.length===0?"":JSON.stringify(t)}const Fl=({entityType:t,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:l,belongsToCollection:a,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:u,onLinkEntity:g,onUnlinkEntity:m,onViewEntity:h,onCreateAndLink:f,onSaveRelations:v})=>{const y=ke();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:y.section.relations})]}),v&&e.jsx("button",{onClick:v,style:Pm,children:y.action.save})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[t==="book"&&e.jsxs(e.Fragment,{children:[e.jsx(Jt,{direction:"up",title:y.relation.belongsToWork,entity:l,onView:h,onUnlink:()=>m("workId"),onLink:()=>g("workId","work"),onCreate:()=>f("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(Jt,{direction:"up",title:y.relation.containedInCollection,entity:a,onView:h,onUnlink:()=>m("collectionId"),onLink:()=>g("collectionId","collection"),onCreate:()=>f("collectionId","collection",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),l&&u&&u.length>0&&e.jsx(Rt,{direction:"horizontal",title:`${y.relation.siblingVersions} (${u.length})`,entities:u,onView:h,onAdd:()=>f("siblingBook","book",{workId:l.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),t==="work"&&e.jsxs(e.Fragment,{children:[e.jsx(Jt,{direction:"up",title:y.relation.parentWork,entity:r,onView:h,onUnlink:()=>m("parentWorkId"),onLink:()=>g("parentWorkId","work"),onCreate:()=>f("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),d&&d.length>0&&e.jsx(Rt,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:h,onAdd:()=>f("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&e.jsx(Rt,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:h,onAdd:()=>f("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),e.jsx(Rt,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:h,onAdd:()=>f("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),t==="collection"&&e.jsxs(e.Fragment,{children:[e.jsx(Jt,{direction:"up",title:y.relation.correspondingWork,entity:l,onView:h,onUnlink:()=>m("workId"),onLink:()=>g("workId","work"),onCreate:()=>f("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(Jt,{direction:"up",title:y.relation.parentCollection,entity:s,onView:h,onUnlink:()=>m("parentCollectionId"),onLink:()=>g("parentCollectionId","collection"),onCreate:()=>f("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(Rt,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:h,onAdd:()=>f("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),e.jsx(Rt,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:h,onAdd:()=>f("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},Jt=({direction:t,title:n,entity:o,onView:r,onUnlink:s,onLink:l,onCreate:a,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:u,unlinkLabel:g})=>{const m=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),h=t==="up"?"⬆️":t==="down"?"⬇️":"↔️";return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:h}),e.jsx("span",{children:n})]}),o?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:Dl(o.type)}),e.jsx("span",{style:{fontWeight:500},children:o.title}),e.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx(Nr,{onClick:()=>r(o),title:u,children:"👁️"}),e.jsx(Nr,{onClick:s,title:g,danger:!0,children:"✕"})]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsx(zi,{onClick:l,children:d}),e.jsx(zi,{onClick:a,primary:!0,children:c})]})]})},Rt=({direction:t,title:n,entities:o,onView:r,onAdd:s,addLabel:l,noneLabel:a,expandMoreLabel:d})=>{const[c,p]=x.useState(!1),u=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),g=t==="up"?"⬆️":t==="down"?"⬇️":"↔️",m=c?o:o.slice(0,5);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:g}),e.jsx("span",{children:n})]}),o.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(h=>e.jsxs("div",{onClick:()=>r(h),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:i("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[e.jsx("span",{children:Dl(h.type)}),e.jsx("span",{children:h.title})]},h.id)),o.length>5&&!c&&e.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[d," (",o.length-5,")"]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:a}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs(zi,{onClick:s,primary:!0,children:["+ ",l]})})]})},Nr=({onClick:t,title:n,danger:o,children:r})=>e.jsx("button",{onClick:s=>{s.stopPropagation(),t()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),zi=({onClick:t,primary:n,children:o})=>e.jsx("button",{onClick:t,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${i("widget-border")}`,borderRadius:"4px",background:n?i("primary"):"transparent",color:n?i("primary-fg"):"inherit",cursor:"pointer"},children:o});function Dl(t){switch(t){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Pm={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Ul=({isOpen:t,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:l,searchResults:a,onSearch:d,isLoading:c,excludeId:p})=>{const[u,g]=x.useState(""),m=p?a.filter(y=>y.id!==p):a;x.useEffect(()=>{t&&(g(""),d(""))},[t]);const h=y=>{g(y),d(y)};if(!t)return null;const f=n==="work"?"作品":n==="book"?"书籍":"丛编",v=n==="work"?"📜":n==="book"?"📖":"📚";return e.jsx("div",{style:Am,children:e.jsxs("div",{style:Bm,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),e.jsx("button",{onClick:s,style:Mm,children:"✕"})]}),e.jsx("div",{style:{padding:"12px 16px"},children:e.jsx("input",{type:"text",value:u,onChange:y=>h(y.target.value),placeholder:`搜索${f}名称或 ID...`,autoFocus:!0,style:Wm})}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?e.jsx("div",{style:si,children:"搜索中..."}):m.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>e.jsxs("div",{onClick:()=>r(y),style:Hm,children:[e.jsx("span",{style:{fontSize:"16px"},children:v}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):u?e.jsxs("div",{style:si,children:["未找到匹配的",f]}):e.jsxs("div",{style:si,children:["输入关键词搜索",f]})}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsxs("button",{onClick:l,style:Om,children:["创建新",f,"并关联"]})]})]})})},Am={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Bm={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},Mm={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Wm={width:"100%",padding:"10px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},Hm={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},si={padding:"20px",textAlign:"center",color:i("desc-fg")},Om={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Ir={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Fm={work:"📜",book:"📖",collection:"📚",entity:"👤"},Vl=({isOpen:t,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:l})=>{const[a,d]=x.useState(""),c=x.useRef(null);x.useEffect(()=>{t&&(d((r==null?void 0:r.title)||""),setTimeout(()=>{var m,h;(m=c.current)==null||m.focus(),(h=c.current)==null||h.select()},100))},[t,r==null?void 0:r.title]);const p=m=>{m.key==="Enter"&&a.trim()?u():m.key==="Escape"&&l()},u=()=>{a.trim()&&s(a.trim(),{...r,title:a.trim()})};if(!t)return null;const g=()=>{switch(o){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`创建新${Ir[n]}`}};return e.jsx("div",{style:Dm,onClick:m=>{m.target===m.currentTarget&&l()},children:e.jsxs("div",{style:Um,onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:Fm[n]}),e.jsx("span",{children:g()})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",e.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),e.jsx("input",{ref:c,type:"text",value:a,onChange:m=>d(m.target.value),onKeyDown:p,placeholder:`请输入${Ir[n]}名称...`,style:Vm})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[e.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&e.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&e.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{onClick:l,style:Gm,children:"取消"}),e.jsx("button",{onClick:u,disabled:!a.trim(),style:{...Ym,opacity:a.trim()?1:.6,cursor:a.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Dm={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Um={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:i("shadow-dialog")},Vm={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box"},Gm={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Ym={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function Km(t){switch(t){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Gl(t){switch(t){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function qm(t){switch(t){case"work":return i("editor-type-work");case"collection":return i("editor-type-collection");case"book":return i("editor-type-book");default:return i("desc-fg")}}const Yl=({isOpen:t,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:l=!1,createButtonText:a,onSelect:d,onCancel:c,onCreate:p,onSearch:u})=>{const[g,m]=x.useState(""),[h,f]=x.useState([]),[v,y]=x.useState(!1),[k,b]=x.useState("recent");x.useEffect(()=>{t&&(m(""),f([]),b(r.length>0?"recent":"search"))},[t,r.length]),x.useEffect(()=>{if(!g.trim()){f([]);return}const C=setTimeout(async()=>{y(!0);try{f(await u(g,o))}catch{f([])}finally{y(!1)}},300);return()=>clearTimeout(C)},[g,o,u]);const j=x.useCallback(C=>{m(C.target.value),C.target.value.trim()&&b("search")},[]),w=x.useCallback(C=>s?C.filter(I=>I.id!==s):C,[s]);if(!t)return null;const S=n||(o==="all"?"选择实体":`选择${Gl(o)}`),$=w(r),_=w(h);return e.jsx("div",{style:Jm,children:e.jsxs("div",{style:Xm,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:S}),e.jsx("button",{onClick:c,style:Qm,children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px 12px"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",value:g,onChange:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:eg}),e.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),v&&e.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&e.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs(Er,{active:k==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),e.jsxs(Er,{active:k==="search",onClick:()=>b("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:k==="recent"&&$.length>0?e.jsx(Rr,{entities:$,onSelect:d}):g.trim()?v?e.jsx(li,{message:"搜索中..."}):_.length>0?e.jsx(Rr,{entities:_,onSelect:d}):e.jsx(li,{message:"未找到匹配的结果"}):e.jsx(li,{message:"输入关键词开始搜索"})}),l&&p&&e.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsx("button",{onClick:p,style:tg,children:a||"创建新实体"})]})]})})},Er=({active:t,onClick:n,children:o})=>e.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:t?600:400,marginBottom:"-1px"},children:o}),Rr=({entities:t,onSelect:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map(o=>e.jsx(Zm,{entity:o,onClick:()=>n(o)},o.id))}),Zm=({entity:t,onClick:n})=>{const[o,r]=x.useState(!1);return e.jsxs("div",{onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:i("primary-soft"),transition:"background 0.1s"},children:[e.jsx("span",{style:{fontSize:"18px"},children:Km(t.type)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[t.title,t.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:t.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[e.jsx("code",{style:{fontSize:"10px",background:i("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:t.id}),t.author&&e.jsx("span",{children:t.author}),t.dynasty&&e.jsx("span",{children:t.dynasty})]})]}),e.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:qm(t.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Gl(t.type)})]})},li=({message:t})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:t}),Jm={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Xm={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},Qm={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},eg={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},tg={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},ng={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},ig={work:"📜",collection:"📚",book:"📖",entity:"👤"},Kl=({data:t,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:l,onDelete:a,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:u,relations:g,onRelationsChange:m})=>{var Se;const h=ke(),[f,v]=x.useState(!1),[y,k]=x.useState("work"),[b,j]=x.useState(""),[w,S]=x.useState(""),[$,_]=x.useState([]),[C,I]=x.useState(!1),[T,z]=x.useState(!1),[H,W]=x.useState("work"),[A,Y]=x.useState(""),[G,te]=x.useState(),[pe,B]=x.useState(!1),[E,ee]=x.useState(null),[L,U]=x.useState([]);x.useRef(null);const de=t.type,ve=de==="work",Z=de==="collection",ce=de==="book",be=x.useCallback((F,me)=>{n({...t,[F]:me})},[t,n]),We=x.useCallback((F,me)=>{j(F),k(me),S(h.editor.selectToLink+h.indexType[me]),_([]),v(!0)},[h]),ye=x.useCallback(F=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(t.id,F)},[r,t.id]),_e=x.useCallback(F=>{s==null||s(F.id,F.type)},[s]),He=x.useCallback((F,me,Ae)=>{const R={...Ae,author:(Ae==null?void 0:Ae.author)||t.author,dynasty:Ae==null?void 0:Ae.dynasty};W(me),Y(F),te(R),z(!0)},[t.author]),Be=x.useCallback((F,me)=>{r!=null&&r.createAndLink&&r.createAndLink(t.id,A,{type:H,title:F,inheritData:me}),z(!1)},[r,t.id,A,H]),Re=x.useCallback(F=>{if(!F.trim()){_([]);return}I(!0),r!=null&&r.searchEntities&&r.searchEntities(F,y).then(me=>{_(me),I(!1)}).catch(()=>{_([]),I(!1)})},[r,y]),ze=x.useCallback(F=>{r!=null&&r.linkEntity&&r.linkEntity(t.id,b,F.id),v(!1)},[r,t.id,b]),Ee=x.useCallback(()=>{o()},[o]),D=x.useCallback(F=>{ee(()=>F),B(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(U).catch(()=>{})},[r]),ae=x.useCallback((F,me)=>r!=null&&r.searchEntities?r.searchEntities(F,me==="all"?void 0:me):Promise.resolve([]),[r]),le=x.useCallback(F=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(F),U(me=>[F,...me.filter(Ae=>Ae.id!==F.id)].slice(0,10)),E==null||E(F),B(!1),ee(null)},[r,E]);return e.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${i("widget-border")}`,paddingBottom:"16px"},children:e.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:ig[de]}),e.jsx("span",{children:t.title||h.editor.untitled}),e.jsx(zn,{children:t.id}),e.jsx(zn,{color:ng[de],children:h.indexType[de]})]})}),e.jsx(st,{title:h.section.basicInfo,onSave:o,onAskAI:d?()=>d("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsx(vn,{label:ve?h.editor.workTitle:Z?h.editor.collectionTitle:h.editor.bookTitle,value:t.title,onChange:F=>be("title",F)}),ce&&e.jsx(vn,{label:h.editor.belongsToWork,value:t.workName||"",onChange:F=>be("workName",F)}),e.jsx(et,{label:h.editor.authorLabel,value:t.author||"",onChange:F=>be("author",F)}),e.jsx(et,{label:h.editor.publicationYearLabel,value:t.publicationYear||"",onChange:F=>be("publicationYear",F)}),(ce||Z)&&e.jsx(vn,{label:h.editor.containedIn,value:t.collection||"",onChange:F=>be("collection",F)}),(ce||Z)&&e.jsx(et,{label:h.editor.holderLabel,value:t.holder||"",onChange:F=>be("holder",F)}),(ce||Z)&&e.jsx(et,{label:ce?h.editor.pageLabel:h.editor.volumeLabel,value:t.pages||"",onChange:F=>be("pages",F)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(et,{label:h.editor.firstImageLabel,value:t.firstImage||"",onChange:F=>be("firstImage",F)})})]})}),e.jsx(st,{title:h.section.description,onSave:o,onAskAI:d?()=>d("介绍"):void 0,children:e.jsx(Ct,{value:t.description||"",onChange:F=>be("description",F),placeholder:h.editor.descriptionPlaceholder})}),(((Se=t.additional_works)==null?void 0:Se.length)||0)>0&&e.jsx(st,{title:h.section.additionalWorks,onSave:o,children:e.jsx(og,{items:t.additional_works||[],onChange:F=>be("additional_works",F)})}),e.jsx(st,{title:h.section.indexedBy,onSave:o,onAskAI:d?()=>d("收录于"):void 0,children:e.jsx(rg,{items:t.indexed_by||[],onChange:F=>be("indexed_by",F)})}),e.jsx(st,{title:h.section.emendatedBy,onSave:o,onAskAI:d?()=>d("考证"):void 0,children:e.jsx(sg,{items:t.emendated_by||[],onChange:F=>be("emendated_by",F)})}),e.jsx(st,{title:h.section.textResources,onSave:o,onAskAI:d?()=>d("资源"):void 0,children:e.jsx(mi,{items:t.resources||[],onChange:F=>be("resources",F),onDownload:p,downloadStatuses:u,filterType:"text"})}),e.jsx(st,{title:h.section.imageResources,onSave:o,children:e.jsx(mi,{items:t.resources||[],onChange:F=>be("resources",F),onDownload:p,downloadStatuses:u,filterType:"image"})}),e.jsx(st,{title:h.section.sources,onSave:o,onAskAI:d?()=>d("资料来源"):void 0,children:e.jsx(Wl,{items:Hl(t.sources||""),onChange:F=>be("sources",Ol(F)),onOpenEntityPicker:D})}),(ce||Z)&&e.jsx(st,{title:h.section.provenance,onSave:o,onAskAI:d?()=>d("收藏历史"):void 0,children:e.jsx(Ct,{value:t.provenance||"",onChange:F=>be("provenance",F),placeholder:h.editor.provenancePlaceholder})}),ce&&e.jsx(st,{title:h.section.otherEditions,onSave:o,onAskAI:d?()=>d("其他版本"):void 0,children:e.jsx(Ct,{value:t.otherEditions||"",onChange:F=>be("otherEditions",F),placeholder:h.editor.otherEditionsPlaceholder})}),e.jsx(Fl,{entityType:de,entityId:t.id,entityTitle:t.title,parentWork:g==null?void 0:g.parentWork,parentCollection:g==null?void 0:g.parentCollection,belongsToWork:g==null?void 0:g.belongsToWork,belongsToCollection:g==null?void 0:g.belongsToCollection,childWorks:g==null?void 0:g.childWorks,childCollections:g==null?void 0:g.childCollections,containedBooks:g==null?void 0:g.containedBooks,siblingBooks:g==null?void 0:g.siblingBooks,onLinkEntity:We,onUnlinkEntity:ye,onViewEntity:_e,onCreateAndLink:He,onSaveRelations:Ee}),l&&a&&e.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[e.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:h.section.dangerZone}),e.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:h.editor.dangerZoneDesc}),e.jsx("button",{onClick:a,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:h.editor.deleteEntity})]}),e.jsx(Ul,{isOpen:f,entityType:y,title:w,onSelect:ze,onCancel:()=>v(!1),onCreate:()=>{v(!1),He(b,y)},searchResults:$,onSearch:Re,isLoading:C,excludeId:t.id}),e.jsx(Vl,{isOpen:T,entityType:H,relationField:A,inheritData:G,onConfirm:Be,onCancel:()=>z(!1)}),e.jsx(Yl,{isOpen:pe,title:h.action.selectBookOrWork,filterType:"all",recentEntities:L,excludeId:t.id,onSelect:le,onCancel:()=>{B(!1),ee(null)},onSearch:ae})]})};function og({items:t,onChange:n}){const o=ke(),r=(a,d,c)=>{const p=t.map((u,g)=>g===a?{...u,[d]:c}:u);n(p)},s=a=>n(t.filter((d,c)=>c!==a)),l=()=>n([...t,{book_title:""}]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((a,d)=>e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(et,{label:o.editor.bookNameLabel,value:a.book_title,onChange:c=>r(d,"book_title",c)}),e.jsx("div",{style:{width:"100px"},children:e.jsx(et,{label:o.label.juanCount,value:a.n_juan!=null?String(a.n_juan):"",onChange:c=>r(d,"n_juan",c&&parseInt(c,10)||void 0)})}),e.jsx("button",{onClick:()=>s(d),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("muted"),marginTop:"18px"},children:"✕"})]},d)),e.jsx("button",{onClick:l,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:o.action.addAdditionalWork})]})}function ql({items:t,onChange:n,showMeta:o,addLabel:r}){const s=ke(),[l,a]=x.useState(null),d=(u,g,m)=>{const h=t.map((f,v)=>v===u?{...f,[g]:m||void 0}:f);n(h)},c=u=>{n(t.filter((g,m)=>m!==u)),l===u&&a(null)},p=()=>{n([...t,{source:""}]),a(t.length)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((u,g)=>{const m=l===g;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>a(m?null:g),children:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),e.jsx("button",{onClick:h=>{h.stopPropagation(),c(g)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!m&&o&&(u.title_info||u.author_info)&&e.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:i("desc-fg")},children:[u.title_info,u.title_info&&u.author_info&&" — ",u.author_info]}),m&&e.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(et,{label:s.label.sourceName,value:u.source,onChange:h=>d(g,"source",h)}),e.jsx(et,{label:s.label.sourceBid,value:u.source_bid||"",onChange:h=>d(g,"source_bid",h)})]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(et,{label:s.label.titleInfo,value:u.title_info||"",onChange:h=>d(g,"title_info",h)}),e.jsx(et,{label:s.label.authorInfo,value:u.author_info||"",onChange:h=>d(g,"author_info",h)})]}),e.jsx(et,{label:s.label.edition,value:u.edition||"",onChange:h=>d(g,"edition",h)})]}),e.jsx(Ct,{value:u.summary||"",onChange:h=>d(g,"summary",h),placeholder:s.editor.summaryPlaceholder}),e.jsx(Ct,{value:u.comment||"",onChange:h=>d(g,"comment",h),placeholder:s.editor.commentPlaceholder}),e.jsx(Ct,{value:u.additional_comment||"",onChange:h=>d(g,"additional_comment",h),placeholder:s.editor.additionalCommentPlaceholder})]})]},g)}),e.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:r})]})}function rg({items:t,onChange:n}){const o=ke();return e.jsx(ql,{items:t,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function sg({items:t,onChange:n}){const o=ke();return e.jsx(ql,{items:t,onChange:n,addLabel:o.action.addEmendatedBy})}function Zl(t){var d,c,p,u,g,m,h;const n=((c=(d=t.authors)==null?void 0:d[0])==null?void 0:c.name)||"",o=((p=t.publication_info)==null?void 0:p.year)||"",r=((u=t.current_location)==null?void 0:u.name)||"",s=(g=t.page_count)!=null&&g.number?String(t.page_count.number):((m=t.page_count)==null?void 0:m.description)||"",l=typeof t.description=="object"&&t.description!==null&&t.description.text||"",a={id:t.id,title:t.title,type:t.type,author:n,publicationYear:o,holder:r,pages:s,description:l,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};if(t.type==="work"){const f=t;if(Array.isArray(f.related_works)){const v=f.related_works.find(y=>y.relation==="part_of");v&&(a.parentWorkId=v.id,a.parentWorkName=v.title)}}if(t.type==="book"){const f=t;a.workId=f.work_id,Array.isArray(f.contained_in)&&f.contained_in.length>0&&(a.collectionId=(h=f.contained_in[0])==null?void 0:h.id)}return a}function lg(t){const n={id:t.id,title:t.title,type:t.type,description:t.description?{text:t.description}:void 0,authors:t.author?[{name:t.author}]:void 0,publication_info:t.publicationYear?{year:t.publicationYear}:void 0,current_location:t.holder?{name:t.holder}:void 0,page_count:t.pages?{number:parseInt(t.pages)||0,description:t.pages}:void 0,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};return t.type==="work"&&t.parentWorkId&&(n.related_works=[{id:t.parentWorkId,title:t.parentWorkName||"",relation:"part_of"}]),t.type==="book"&&(n.work_id=t.workId,t.collectionId&&(n.contained_in=[{id:t.collectionId}])),n}const ag=t=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:l,onChange:a,onSave:d,onDelete:c,onNavigate:p,renderLink:u,onAskAI:g,renderSectionActions:m,onDownloadResource:h,downloadStatuses:f,relations:v,onRelationsChange:y,headerExtra:k,className:b,style:j}=t,w=ke(),[S,$]=x.useState(s),_=l?s:S;x.useEffect(()=>{s!==S&&$(s)},[s]);const C=x.useCallback(()=>{const Y=_==="view"?"edit":"view";l?l(Y):$(Y)},[_,l]),[I,T]=x.useState(null);x.useEffect(()=>{o&&r&&r.getItem(o).then(Y=>{Y&&T(Y)})},[o,r]);const z=n||I,H=x.useMemo(()=>z?Zl(z):null,[z]),W=l||!n?e.jsx("button",{onClick:C,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:_==="edit"?i("accent-bg"):"transparent",color:i(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?w.common.switchToEdit:w.common.switchToView,children:_==="view"?w.common.modeEdit:w.common.modeView}):null,A=e.jsxs(e.Fragment,{children:[W,k]});return!z&&!H?e.jsx(Nt,{}):_==="view"?e.jsx(Ui,{data:z,transport:r,onNavigate:p?Y=>p(Y):void 0,renderLink:u,headerExtra:A,className:b,style:j}):H?e.jsxs("div",{className:b,style:j,children:[A&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:A}),e.jsx(Kl,{data:H,onChange:a||(()=>{}),onSave:d||(()=>{}),transport:r,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:g,renderSectionActions:m,onDownloadResource:h,downloadStatuses:f,relations:v,onRelationsChange:y})]}):e.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:w.common.noData})},cg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Jl=({isOpen:t,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=K(),[l,a]=x.useState(null),[d,c]=x.useState(""),[p,u]=x.useState(""),[g,m]=x.useState("idle"),[h,f]=x.useState(""),v=x.useRef(null);x.useEffect(()=>{t&&(a(null),c(""),u(""),m("idle"),f(""))},[t]),x.useEffect(()=>{l&&setTimeout(()=>{var b;return(b=v.current)==null?void 0:b.focus()},100)},[l]),x.useEffect(()=>{if(g==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[g,n]),x.useEffect(()=>{if(!t)return;const b=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[t,n]);const y=async()=>{if(!(!l||!d.trim())){m("submitting"),f("");try{await o({type:l,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),m("success")}catch(b){m("error"),f(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!t)return null;const k=l&&d.trim()&&g!=="submitting";return e.jsx("div",{style:dg,onClick:b=>{b.target===b.currentTarget&&n()},children:e.jsxs("div",{style:pg,onClick:b=>b.stopPropagation(),children:[e.jsxs("div",{style:ug,children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),e.jsx("button",{onClick:n,style:mg,"aria-label":s("feedback.close"),children:"✕"})]}),g==="success"?e.jsxs("div",{style:bg,children:[e.jsx("span",{style:{fontSize:"32px"},children:"✓"}),e.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),r&&e.jsx("a",{href:r,style:{fontSize:"13px",color:i("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:cg.map(b=>e.jsxs("button",{onClick:()=>a(b.value),style:{...gg,...l===b.value?hg:{}},children:[e.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),e.jsx("textarea",{ref:v,value:d,onChange:b=>c(b.target.value),placeholder:s(l?`feedback.placeholder.${l}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!l||g==="submitting",style:{...xg,opacity:l?1:.6}}),e.jsx("input",{type:"text",value:p,onChange:b=>u(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!l||g==="submitting","aria-label":s("feedback.contactLabel"),style:jg}),e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),g==="error"&&e.jsx("div",{style:yg,children:h}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{onClick:y,disabled:!k,style:{...fg,opacity:k?1:.6,cursor:k?"pointer":"not-allowed"},children:s(g==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},dg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},pg={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},ug={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},mg={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},gg={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},hg={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},xg={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},fg={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},bg={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},yg={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},jg={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},Ti="--bim-feedback-fab-offset",Ni=48,vg=16,kg=({onSubmit:t,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:l}=K(),[a,d]=x.useState(!1),c=n.bottom??24;return x.useEffect(()=>{if(r||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(Ti,`calc(${c+Ni+vg}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Ti)}},[r,c]),e.jsxs(e.Fragment,{children:[!r&&e.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...wg,zIndex:s??i("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":l("feedback.title"),title:l("feedback.title"),children:e.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:e.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"})})}),e.jsx(Jl,{isOpen:a,onClose:()=>d(!1),onSubmit:t,feedbackListUrl:o})]})},wg={position:"fixed",width:`${Ni}px`,height:`${Ni}px`,borderRadius:"50%",border:"none",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:i("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},Sg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Xl=({onSubmit:t})=>{const{t:n}=K(),[o,r]=x.useState("bug"),[s,l]=x.useState(""),[a,d]=x.useState(""),[c,p]=x.useState("idle"),[u,g]=x.useState(""),m=x.useRef(null);x.useEffect(()=>{o&&setTimeout(()=>{var v;return(v=m.current)==null?void 0:v.focus()},100)},[o]);const h=async()=>{if(!(!o||!s.trim())){p("submitting"),g("");try{await t({type:o,content:s.trim(),...a.trim()?{contact:a.trim()}:{}}),p("success"),l(""),d(""),r("bug")}catch(v){p("error"),g(v instanceof Error?v.message:n("feedback.submitFailedRetry"))}}},f=o&&s.trim()&&c!=="submitting";return c==="success"?e.jsx("div",{style:Lr,children:e.jsxs("div",{style:Tg,children:[e.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),e.jsx("button",{onClick:()=>p("idle"),style:Ng,children:n("feedback.continueSubmit")})]})}):e.jsxs("div",{style:Lr,children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Sg.map(v=>e.jsxs("button",{onClick:()=>r(v.value),style:{...$g,...o===v.value?_g:{}},children:[e.jsx("span",{children:v.icon})," ",n(`feedback.submitType.${v.value}`)]},v.value))}),e.jsx("textarea",{ref:m,value:s,onChange:v=>l(v.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Cg}}),e.jsx("input",{type:"text",value:a,onChange:v=>d(v.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:Eg}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[s.length," / 2000"]}),e.jsx("button",{onClick:h,disabled:!f,style:{...zg,opacity:f?1:.6,cursor:f?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&e.jsx("div",{style:Ig,children:u})]})},Lr={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},$g={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},_g={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Cg={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},zg={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Tg={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},Ng={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Ig={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},Eg={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Pr(t){return typeof t=="function"?t():t??"/api/feedback"}const Ql=({resourceId:t,apiUrl:n})=>{const{t:o}=K(),[r,s]=x.useState([]),[l,a]=x.useState(!0),d=x.useCallback(async()=>{const p=Pr(n);a(!0);try{const g=await(await fetch(`${p}?resourceId=${encodeURIComponent(t)}`)).json();g.success&&s(g.items)}catch{}finally{a(!1)}},[t,n]);x.useEffect(()=>{d()},[d]);const c=async p=>{const u=Pr(n),g=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:t})});if(!g.ok){const m=await g.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||o("feedback.submitFailed"))}setTimeout(()=>d(),500)};return e.jsxs("div",{children:[e.jsx(bo,{items:r,loading:l}),e.jsx("div",{style:{marginTop:"24px"},children:e.jsx(Xl,{onSubmit:c})})]})},Rg=Nn["zh-Hant"].relation,Lg=Nn["zh-Hant"].lossStatus,Pg=Nn["zh-Hant"].resourceKind,Un=Ht("zh-Hant"),yo=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function Ar(t,n=Un){return t?yo(Rg,t)?n(`detail.relation.${t}`):t:n("detail.relation.related")}function Ag(t,n=Un){return yo(Lg,t)?n(`detail.lossStatus.${t}`):t}function Bg(t,n=Un){return yo(Pg,t)?n(`detail.resourceKind.${t}`):""}function jo({authors:t,onNavigate:n,renderLink:o}){const{convert:r}=K(),s=(t||[]).filter(l=>l&&l.name);return s.length?e.jsx(e.Fragment,{children:s.map((l,a)=>{const d=Qi(l.role);return e.jsxs(x.Fragment,{children:[a>0&&" ",l.dynasty&&e.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(l.dynasty),"〕"]}),l.entity_id?e.jsx(Ue,{id:l.entity_id,label:r(l.name),onNavigate:n,renderLink:o,dense:!0}):r(l.name),d&&e.jsx("span",{style:{marginLeft:4},children:r(d)})]},a)})}):null}function ea(t,n,o=Un){var c,p;const r=Ji(t,n),s=r.mirrors.map(u=>({key:u.key,label:u.label,description:u.description,rows:u.items.filter(g=>g.group_role!=="mirror"),mirrors:u.items.filter(g=>g.group_role==="mirror")})),l=r.buckets.filter(u=>u.key==="image"||u.key==="textImage").flatMap(u=>u.items);l.length&&s.push({key:"_images",label:s.length?o("detail.otherImages"):void 0,rows:l,mirrors:[]});const a=((c=r.buckets.find(u=>u.key==="physical"))==null?void 0:c.items)??[];return a.length&&s.push({key:"_physical",label:o("detail.resourceKind.physical"),rows:a,mirrors:[]}),{text:((p=r.buckets.find(u=>u.key==="text"))==null?void 0:p.items)??[],groups:s}}function ta(t,n){const o=(t.url?Ot(t.url):void 0)||t.name,r=ol(t,n);return r?`${o}(${r})`:o}function vo({item:t,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=K(),[l,a]=x.useState(!1),d=In(t),c=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),p=s(ta(t,n)),u=Ft(t),g=Wn(t,r)||t.details;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var h,f;const m=(h=t.metadata)!=null&&h.fragment||t.color_mode?e.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((f=t.metadata)==null?void 0:f.fragment)&&e.jsx("span",{className:"bim-d-tag",children:r("detail.fragmentTag")}),t.color_mode&&e.jsx("span",{className:"bim-d-tag",children:t.color_mode==="color"?r("colorMode.color"):r("colorMode.bw")})]}):null;return u?e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[p," ",e.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):e.jsxs("span",{className:"bim-d-zt-name",children:[p,m]})})(),g&&e.jsx("span",{className:"bim-d-meta",children:s(g)}),c&&l&&e.jsx("div",{style:{padding:"0 12px 10px"},children:e.jsx(oo,{item:t})})]}),e.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":l,onClick:()=>a(m=>!m),children:l?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:d.expected})})})]})}function na({groups:t,listedVolumeCounts:n}){const{t:o,convert:r}=K();return e.jsx(e.Fragment,{children:t.map(s=>e.jsxs("div",{className:"bim-d-rg",children:[s.label&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:r(s.label)}),s.description&&e.jsx("p",{className:"bim-d-rg-d",children:r(s.description)}),s.rows.length>0&&e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:s.rows.map((l,a)=>e.jsx(vo,{item:l,siblings:s.rows,listedVolumeCounts:n},`${l.id||l.url||l.name}-${a}`))})}),s.mirrors.length>0&&e.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&e.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:o("detail.mirror")}),s.mirrors.map((l,a)=>{const d=Ft(l),c=r(ta(l,s.mirrors));return d?e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:l.details?r(l.details):void 0,children:[c," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]},a):e.jsx("span",{style:{marginRight:14},children:c},a)})]})]},s.key))})}const rn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Ii(t){var o;if(!t)return;const n=t.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=rn.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const Br=12,Mg=60,ia=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:l,back:a,railLinks:d})=>{var Re,ze,Ee;const{t:c,convert:p,messages:u}=K(),g=x.useMemo(()=>[...t.books||[],...t.collections||[]],[t.books,t.collections]),[m,h]=x.useState(new Map),[f,v]=x.useState(!1),[y,k]=x.useState(""),[b,j]=x.useState(!1),w=g.length<=Mg,S=w||f||!!y||b,$=x.useMemo(()=>S?g:g.slice(0,Br),[g,S]);x.useEffect(()=>{if(!n||$.length===0)return;const D=$.filter(le=>!m.has(le));if(D.length===0)return;let ae=!1;return Promise.all(D.map(le=>n.getItem(le).then(Se=>{const F=Se??{};return[le,{id:le,title:F.title,edition:F.edition,resources:F.resources,publication_info:F.publication_info,current_location:F.current_location,lineage:F.lineage,measure_info:F.measure_info}]}).catch(()=>[le,{id:le}]))).then(le=>{ae||h(Se=>{const F=new Map(Se);for(const[me,Ae]of le)F.set(me,Ae);return F})}),()=>{ae=!0}},[n,$,m]);const _=x.useMemo(()=>g.map(D=>m.get(D)??{id:D}),[g,m]),C=g.length>0&&g.every(D=>m.has(D)),I=!!n&&$.some(D=>!m.has(D)),T=w||S,z=x.useMemo(()=>sl(_,t.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[_,t.version_graph,y,b,T]),H=f?z.rows:z.rows.slice(0,Br),W=z.allRows.filter(D=>D.hasImage).length,A=t.related_works||[],Y=A.filter(D=>D.relation==="collected_in"),G=x.useMemo(()=>{const D=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],ae=le=>{const Se=D.indexOf(le??"");return Se<0?D.length:Se};return A.filter(le=>le.relation!=="collected_in").map((le,Se)=>({r:le,i:Se})).sort((le,Se)=>ae(le.r.relation)-ae(Se.r.relation)||le.i-Se.i).map(le=>le.r)},[A]),te=x.useMemo(()=>{const D=Ji(t.resources,t.resource_groups);return[...D.mirrors.flatMap(ae=>ae.items.map(le=>({r:le,kind:p(ae.label)}))),...D.buckets.flatMap(ae=>ae.items.map(le=>({r:le,kind:p(Bg(ae.key,c))})))]},[t.resources,t.resource_groups,p,c]),pe=t.indexed_by||[],B=t.emendated_by||[],E=x.useMemo(()=>{var Q,xe,N;const D=[],ae=(xe=(Q=t.authors)==null?void 0:Q[0])==null?void 0:xe.dynasty;ae&&D.push({label:c("workPage.fact.written"),value:p(ae)});const le=xt(t,u.unit.juan);if(le){const ne=(N=t.juan_count)==null?void 0:N.description;D.push({label:c("workPage.fact.measure"),value:e.jsxs(e.Fragment,{children:[p(le),ne&&ne!==le?e.jsxs("span",{className:"bim-d-meta",children:["(",p(ne),")"]}):null]})})}t.loss_status&&D.push({label:c("workPage.fact.loss"),value:p(Ag(t.loss_status,c))});const Se=z.allRows.filter(ne=>ne.sortYear!=null),F=Se.length>0?Se.reduce((ne,J)=>ne.sortYear<=J.sortYear?ne:J):null;F!=null&&F.era.era?D.push({label:c("workPage.fact.earliest"),value:p([F.era.era,F.era.reign].filter(Boolean).join(" ")),title:F.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):I&&D.push({label:c("workPage.fact.earliest"),value:e.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),B.length&&D.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:B.length})});const me=Mr(t.additional_titles);me.length&&D.push({label:c("workPage.fact.alias"),value:me.map(p).join("、")});const Ae=Mr(t.attached_texts);Ae.length&&D.push({label:c("workPage.fact.attached"),value:Ae.map(p).join("、")});const R=(t.additional_works||[]).map(ne=>p(ne.book_title)+(ne.n_juan!=null?` ${ne.n_juan}${u.unit.juan}`:""));return R.length&&D.push({label:c("workPage.fact.appendix"),value:R.join("、")}),D},[t,p,c,u,I,z.allRows,B.length]),L=[{value:t._edition_count??g.length,label:c("workPage.stat.editions")},{value:C?W:0,label:c("workPage.stat.hasImage")},{value:pe.length,label:c("workPage.stat.catalogs")}],U=t.classification,de=U?[U.l1,U.l2,U.l3,U.l4].filter(Boolean).map(D=>p(D)):[],ve=t.subtype?u.workSubtype[t.subtype]??p(t.subtype):"",Z=e.jsx(cn,{title:p(t.title),byline:e.jsx(jo,{authors:t.authors,onNavigate:o,renderLink:r}),meta:e.jsx(Ye,{items:[...de,U!=null&&U.source?c("workPage.classifiedBy",{source:p(U.source.split("/")[0])}):"",ve]}),description:(Re=t.description)!=null&&Re.text?e.jsxs(e.Fragment,{children:[e.jsx(ht,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}),(ze=t.description.sources)!=null&&ze.length?e.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:t.description.sources.map(D=>p(Hp(D))).filter(Boolean).join(" · ")}):null]}):void 0,stats:L,facts:E,readAction:s,foot:e.jsx(dn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:(Ee=t.appendix)==null?void 0:Ee.map((D,ae)=>e.jsxs("details",{style:{marginTop:12},children:[e.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(D.title)}),e.jsx(ht,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},ae))}),ce=z.eras.length>=2?[{key:"",label:c("catalog.all")},...z.eras.map(D=>({key:D,label:`${D} ${z.allRows.filter(ae=>ae.era.era===D).length}`}))]:[],be=[];g.length&&be.push({id:"versions",label:c("workPage.sec.versions"),count:g.length}),pe.length&&be.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:pe.length}),Y.length&&be.push({id:"collected",label:c("workPage.sec.collected"),count:Y.length}),G.length&&be.push({id:"related",label:c("workPage.sec.related"),count:G.length}),te.length&&be.push({id:"resources",label:c("workPage.sec.resources"),count:te.length});const We=g.length===0&&pe.length===0,ye=e.jsxs(e.Fragment,{children:[g.length>0&&e.jsxs(Ke,{id:"versions",title:c("workPage.sec.versions"),meta:e.jsx(Ye,{items:[c("workPage.versionsTotal",{n:g.length}),C&&W?c("workPage.versionsWithImage",{n:W}):"",z.rows.length!==z.allRows.length?c("workPage.versionsCurrent",{n:z.rows.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":I&&ce.length===0&&g.length>1?"":void 0,children:[ce.length>0&&e.jsx(On,{items:ce,value:y,onChange:D=>{k(D),v(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx(ml,{label:c("workPage.scanOnly"),checked:b,onChange:D=>{j(D),v(!1)}}),e.jsx("span",{className:"bim-d-meta",children:c(T?"workPage.sortByYear":"workPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!f&&Fn(z.rows.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:c("workPage.col.edition")}),e.jsx("th",{children:c("workPage.col.era")}),e.jsx("th",{children:c("workPage.col.holder")}),e.jsx("th",{children:e.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),e.jsx("tbody",{children:H.map(D=>{var ae;return e.jsx(Wg,{row:D,measure:(ae=m.get(D.id))==null?void 0:ae.measure_info,loaded:m.has(D.id),onNavigate:o,renderLink:r},`${D.id}:${m.has(D.id)?"r":"p"}`)})})]}),H.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!f&&e.jsx(eo,{total:z.rows.length,shown:H.length,unit:c("workPage.moreUnit"),onClick:()=>v(!0)}),z.hasInferredEra&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),pe.length>0&&e.jsx(Hg,{items:pe,transport:n,onNavigate:o,renderLink:r}),We&&e.jsx(Ke,{title:c("workPage.sec.versions"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),_e=(D,ae)=>e.jsx(Ue,{id:D,label:p(ae),onNavigate:o,renderLink:r,dense:!0}),He=x.useMemo(()=>{const D=new Map;for(const ae of G){const le=Ar(ae.relation,c);D.set(le,(D.get(le)??0)+1)}return D.size>1?[...D.entries()].sort((ae,le)=>le[1]-ae[1]).slice(0,4).map(([ae,le])=>`${p(ae)} ${le}`).join(" · "):void 0},[G,p,c]),Be=e.jsxs(e.Fragment,{children:[e.jsx(_t,{id:"collected",title:c("workPage.sec.collected"),items:Y.map(D=>_e(D.id,D.title))}),e.jsx(_t,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:G.length}),sub:He,items:G.map(D=>e.jsxs(e.Fragment,{children:[_e(D.id,D.title),e.jsx("span",{className:"bim-d-meta",title:D.note?p(D.note):void 0,children:p(Ar(D.relation,c))})]}))}),e.jsx(_t,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:te.map(({r:D,kind:ae})=>{const le=p((D.url?Ot(D.url):void 0)||D.name),Se=Ft(D);return e.jsxs(e.Fragment,{children:[Se?e.jsxs("a",{href:Se,target:"_blank",rel:"noopener noreferrer",children:[le," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}):e.jsx("span",{children:le}),ae&&e.jsx("span",{className:"bim-d-meta bim-d-kind",children:ae})]})})})]});return e.jsx(an,{railTop:l,back:a,nav:be,railLinks:d,main:ye,card:Z,side:Be})};function Mr(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Wr(t,n){return n((t.url?Ot(t.url):void 0)||t.name)}function Wg({row:t,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:l,convert:a}=K(),d=[t.era.era,t.era.reign].filter(Boolean).join(" "),c=t.era.source==="edition",p=t.holders[0],u=p?Wr(p,a):t.locationName?a(t.locationName):"",g=t.images[0],m=g?Ft(g):void 0,h=t.images.map(f=>Wr(f,a)).join("、");return e.jsxs("tr",{"data-loading":o?void 0:"",children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ue,{id:t.id,label:a(t.name),onNavigate:r,renderLink:s,dense:!0}),n?e.jsx("span",{className:"bim-d-meta",children:a(n)}):e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?l("workPage.inferredFromEdition"):void 0,children:d?a(d):o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),e.jsxs("td",{className:`bim-d-zt-sub${u?"":" bim-d-zt-blank"}`,children:[u||(o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),t.holders.length>1&&e.jsxs("span",{className:"bim-d-meta",children:[" +",t.holders.length-1]})]}),e.jsx("td",{className:t.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:t.hasImage&&(m?e.jsx("a",{className:"bim-d-flag",href:m,target:"_blank",rel:"noopener noreferrer",title:h,children:l("workPage.hasImage")}):e.jsx("span",{className:"bim-d-flag",title:h,children:l("workPage.hasImage")}))})]})}function Hg({items:t,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:l}=K(),[a,d]=x.useState(0),c=Math.min(a,t.length-1),p=t[c],[u,g]=x.useState(new Map);return x.useEffect(()=>{if(!n)return;const m=[...new Set(t.map(f=>f.source_bid).filter(f=>!!f))];if(m.length===0)return;let h=!1;return Promise.all(m.map(f=>n.getItem(f).then(v=>{var y,k;return[f,((k=(y=v==null?void 0:v.authors)==null?void 0:y[0])==null?void 0:k.dynasty)??""]}).catch(()=>[f,""]))).then(f=>{h||g(new Map(f.filter(([,v])=>v)))}),()=>{h=!0}},[n,t]),e.jsx(Ke,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:e.jsx(Ye,{items:[s("workPage.catalog.meta",{n:t.length}),s("workPage.sortByCatalog")]}),children:e.jsxs("div",{className:"bim-d-lu",children:[e.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:t.map((m,h)=>e.jsx("li",{role:"presentation",children:e.jsxs("button",{type:"button",role:"tab","aria-selected":h===c,"aria-label":l(m.source),onClick:()=>d(h),children:[e.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(m.source_bid??"")?l(u.get(m.source_bid??"")):" "}),e.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...l(m.source)].slice(0,9).map((f,v)=>e.jsx("span",{children:f},v))})]})},h))}),e.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[p.title_info&&e.jsx("div",{className:"bim-d-lu-title",children:l(p.title_info)}),e.jsx(Ye,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?e.jsx(Ue,{id:p.source_bid,label:l(p.source),onNavigate:o,renderLink:r,dense:!0}):l(p.source),p.section?l(p.section):"",p.author_info?`${s("label.authorInfo")} ${l(p.author_info)}`:"",p.edition?`${s("label.edition")} ${l(p.edition)}`:"",p.page??""]}),p.summary&&e.jsx("p",{className:"bim-d-quote",children:nt(l(p.summary),void 0,{t:s})}),p.comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),e.jsx("p",{className:"bim-d-quote",children:nt(l(p.comment),void 0,{t:s})})]}),p.additional_comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),e.jsx("p",{className:"bim-d-quote",children:nt(l(p.additional_comment),void 0,{t:s})})]}),!p.summary&&!p.comment&&!p.additional_comment&&!p.title_info&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),t.length>1&&e.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:l(t[c-1].source)}),onClick:()=>d(c-1),children:e.jsxs("span",{"aria-hidden":"true",children:["← ",l(t[c-1].source)]})}):e.jsx("span",{"aria-hidden":"true"}),e.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",t.length]}),c<t.length-1?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:l(t[c+1].source)}),onClick:()=>d(c+1),children:e.jsxs("span",{"aria-hidden":"true",children:[l(t[c+1].source)," →"]})}):e.jsx("span",{"aria-hidden":"true"})]})]})]})})}function Og(t){var n;return{id:t.id,kind:"hypothetical",label:t.label,year:t.year??((n=t.year_range)==null?void 0:n[0]),year_range:t.year_range,year_uncertain:t.year_uncertain,group:t.group,note:t.note,description:t.description}}function Fg(t,n){if(!t.lineage)return null;const o=t.lineage;return{id:t.id,kind:"book",label:t.title,year:o.year,year_text:o.year_text,year_uncertain:o.year_uncertain,category:o.category,status:o.status,extant_juan:o.extant_juan,group:n[t.id],note:o.note}}function Hr(t,n,o){return{id:`derive:${n.ref}->${t}:${o}`,source:n.ref,target:t,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Dg(t,n,o){const[r,s]=[t,n.book_id].sort();return{id:`sibling:${r}-${s}:${o}`,source:r,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Ug(t,n){var p;if(n==="all")return null;const o=(p=t.collections)==null?void 0:p[n],r=Array.isArray(o==null?void 0:o.groups)&&o.groups.length>0,s=Array.isArray(o==null?void 0:o.book_ids)&&o.book_ids.length>0,l=r||s||!!(o!=null&&o.hypothetical_ids);if(!l&&n==="core"&&Array.isArray(t.core_books)&&t.core_books.length>0)return{books:new Set(t.core_books),hypos:t.core_hypotheticals?new Set(t.core_hypotheticals):null};if(!o||!l)return null;const a=r?new Set(o.groups):null,d=new Set(o.book_ids??[]);if(a&&t.node_groups)for(const[u,g]of Object.entries(t.node_groups))a.has(g)&&d.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),a){c||(c=new Set);for(const u of t.hypothetical_nodes??[])u.group&&a.has(u.group)&&c.add(u.id)}return{books:d,hypos:c}}function kn(t,n,o){const r=t.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const l=new Set(r.excluded_books??[]),a=r.node_groups??{},d=Ug(r,o??r.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,u=(d==null?void 0:d.hypos)??null,g=new Set,m=new Set;if(c){const w=new Map(n.map(T=>[T.id,T])),S=new Map((r.hypothetical_nodes??[]).map(T=>[T.id,T])),$=T=>{const z=w.get(T);if(z&&z.lineage)return(z.lineage.derived_from??[]).map(W=>W.ref);const H=S.get(T);return H?(H.derived_from??[]).map(W=>W.ref):[]},_=T=>S.has(T)?!u||u.has(T):!p||p.has(T),C=new Set,I=T=>{if(!C.has(T)){C.add(T);for(const z of $(T))l.has(z)||(_(z)||(S.has(z)?m.add(z):w.has(z)&&g.add(z)),I(z))}};for(const T of n)p&&p.has(T.id)&&!l.has(T.id)&&I(T.id);for(const T of r.hypothetical_nodes??[])u&&u.has(T.id)&&I(T.id)}const h=n.filter(w=>!l.has(w.id)).filter(w=>!p||p.has(w.id)||g.has(w.id)).map(w=>{const S=Fg(w,a);return S&&g.has(w.id)&&(S.bridge=!0),S}).filter(w=>w!==null),f=(r.hypothetical_nodes??[]).filter(w=>!u||u.has(w.id)||m.has(w.id)).map(w=>{const S=Og(w);return m.has(w.id)&&(S.bridge=!0),S}),v=[...h,...f],y=new Set(v.map(w=>w.id)),k=new Set,b=[],j=w=>{k.has(w.id)||!y.has(w.source)||!y.has(w.target)||(k.add(w.id),b.push(w))};for(const w of n)l.has(w.id)||!w.lineage||p&&!p.has(w.id)&&!g.has(w.id)||((w.lineage.derived_from??[]).forEach((S,$)=>{j(Hr(w.id,S,$))}),(w.lineage.related_to??[]).forEach((S,$)=>{j(Dg(w.id,S,$))}));for(const w of r.hypothetical_nodes??[])u&&!u.has(w.id)&&!m.has(w.id)||(w.derived_from??[]).forEach((S,$)=>{j(Hr(w.id,S,$))});return{nodes:v,edges:b,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(l)}}function oa(t,n,o){const r=(t??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function Vg(t,n){const o=[],r=t.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),l=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),a=new Set([...s,...l]),d=(c,p)=>{a.has(p.ref)||o.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&o.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!l.has(p.ref)&&o.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(u=>d(p,u)),(c.lineage.related_to??[]).forEach(u=>{s.has(u.book_id)||o.push(`${p}: related_to.book_id "${u.book_id}" 不在 books 列表中`)})}for(const c of r.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(u=>d(p,u))}return o}const ra=({graph:t,renderLink:n,className:o,style:r})=>{const{t:s,convert:l}=K();if(!t.nodes.length)return e.jsx("div",{style:{...rh,...r},className:o,children:s("lineage.emptyGraph")});const a=new Map,d=new Map;for(const h of t.edges)if(h.kind==="derive"){const f=a.get(h.target)??[];f.push(h),a.set(h.target,f)}else for(const f of[h.source,h.target]){const v=d.get(f)??[];v.push(h),d.set(f,v)}const c=new Map(t.nodes.map(h=>[h.id,h])),p=new Map,u=[];for(const h of t.nodes)if(h.group){const f=p.get(h.group)??[];f.push(h),p.set(h.group,f)}else u.push(h);const g=(h,f)=>(h.year??9999)-(f.year??9999);p.forEach(h=>h.sort(g)),u.sort(g);const m=t.groups.filter(h=>p.has(h.id));return e.jsxs("div",{className:o,style:{...Yg,...r},children:[t.title&&e.jsx("div",{style:Kg,children:l(t.title)}),t.description&&e.jsx("div",{style:qg,children:l(t.description)}),m.map(h=>e.jsx(Or,{label:h.label,color:h.color,nodes:p.get(h.id),incomingMap:a,siblingMap:d,nodeMap:c,renderLink:n},h.id)),u.length>0&&e.jsx(Or,{label:s("lineage.otherGroup"),nodes:u,incomingMap:a,siblingMap:d,nodeMap:c,renderLink:n})]})},Or=({label:t,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:l,renderLink:a})=>{const{convert:d}=K();return e.jsxs("div",{style:Zg,children:[e.jsx("div",{style:{...Jg,borderLeftColor:n??i("widget-border")},children:d(t)}),o.map(c=>e.jsx(Gg,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:l,renderLink:a},c.id))]})},Gg=({node:t,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const l=t.kind==="hypothetical",a=t.bridge,{t:d,convert:c}=K();return e.jsxs("div",{style:{...Xg,borderStyle:l||a?"dashed":"solid",opacity:a?.55:t.status==="lost"?.7:1,background:a?i("bg-subtle"):void 0},title:a?d("lineage.bridgeTitle"):void 0,children:[e.jsxs("div",{style:Qg,children:[e.jsx("span",{style:eh,children:l||!s?c(t.label):s(t.id,c(t.label))}),(t.year_text||t.year!=null)&&e.jsx("span",{style:th,children:oa(c(t.year_text),t.year,t.year_uncertain)})]}),e.jsxs("div",{style:nh,children:[t.category&&e.jsx(Xt,{children:c(t.category)}),t.status==="lost"&&e.jsx(Xt,{tone:"warn",children:d("lineage.lost")}),t.status==="fragment"&&e.jsx(Xt,{tone:"warn",children:d("lineage.fragment")}),l&&e.jsx(Xt,{tone:"info",children:d("lineage.hypothetical")}),a&&e.jsx(Xt,{tone:"info",children:d("lineage.bridge")})]}),t.extant_juan&&e.jsx("div",{style:ih,children:d("lineage.extant",{juan:c(t.extant_juan)})}),t.note&&e.jsx("div",{style:oh,children:c(t.note)}),n.length>0&&e.jsxs("div",{style:Dr,children:[e.jsx("div",{style:Ur,children:d("lineage.sources")}),n.map(p=>{const u=r.get(p.source);return e.jsxs("div",{style:Vr(p.confidence),children:[e.jsx("span",{style:Gr,children:c(p.relation)}),e.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&e.jsx(Fr,{level:p.confidence}),p.evidence&&e.jsxs("span",{style:Yr,children:["· ",c(p.evidence)]})]},p.id)})]}),o.length>0&&e.jsxs("div",{style:Dr,children:[e.jsx("div",{style:Ur,children:d("lineage.related")}),o.map(p=>{const u=p.source===t.id?p.target:p.source,g=r.get(u);return e.jsxs("div",{style:Vr(p.confidence),children:[e.jsx("span",{style:Gr,children:c(p.relation)}),e.jsx("span",{children:(g==null?void 0:g.kind)==="book"&&s?s(g.id,c(g.label)):c((g==null?void 0:g.label)??u)}),e.jsx(Fr,{level:p.confidence}),p.evidence&&e.jsxs("span",{style:Yr,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Xt=({children:t,tone:n="default"})=>{const r={default:{bg:i("tag-bg"),fg:i("fg")},warn:{bg:i("warn-bg"),fg:i("warn-fg")},info:{bg:i("info-bg"),fg:i("info-fg")}}[n];return e.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:t})},Fr=({level:t})=>{const{t:n}=K(),r={certain:{key:"certain",color:i("confidence-certain")},consensus:{key:"consensus",color:i("confidence-consensus")},probable:{key:"probable",color:i("confidence-probable")},disputed:{key:"disputed",color:i("confidence-disputed")}}[t];return r?e.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${r.color}`,color:r.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${r.key}`)}):null},Yg={fontSize:"14px",color:i("fg")},Kg={fontSize:"16px",fontWeight:600,marginBottom:"8px"},qg={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},Zg={marginBottom:"16px"},Jg={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},Xg={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},Qg={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},eh={fontSize:"15px",fontWeight:600},th={fontSize:"12px",color:i("muted")},nh={marginBottom:"6px"},ih={fontSize:"12px",color:i("muted"),margin:"2px 0"},oh={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},Dr={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},Ur={fontSize:"11px",color:i("muted"),marginBottom:"2px"},Vr=t=>({fontSize:"12px",margin:"2px 0",opacity:t==="probable"||t==="disputed"?.85:1}),Gr={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},Yr={fontSize:"11px",color:i("muted")},rh={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},sa=({selectedNodeId:t,...n})=>{const{t:o}=K(),[r,s]=x.useState("loading"),[l,a]=x.useState(null);return x.useEffect(()=>{let d=!1;return sh().then(c=>{d||(c?(a(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),r==="loading"?e.jsx("div",{style:qr,children:o("lineage.graphLoading")}):r==="missing"||!l?e.jsxs("div",{style:qr,children:[e.jsx("div",{children:Kr(o("lineage.graphMissing"),{xyflow:e.jsx("code",{children:"@xyflow/react"}),dagre:e.jsx("code",{children:"@dagrejs/dagre"})})}),e.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:Kr(o("lineage.graphMissingHint"),{list:e.jsx("code",{children:"VersionLineageList"})})})]}):e.jsx(lh,{modules:l,selectedNodeId:t,...n})};function Kr(t,n){return t.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return e.jsx(x.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function sh(){try{const[t,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let o=!1;try{await import("@xyflow/react/dist/style.css"),o=!0}catch{o=!1}return{ReactFlow:t.ReactFlow,Background:t.Background,Controls:t.Controls,Handle:t.Handle,Position:t.Position,BaseEdge:t.BaseEdge,EdgeLabelRenderer:t.EdgeLabelRenderer,getSmoothStepPath:t.getSmoothStepPath,dagre:n,cssLoaded:o}}catch{return null}}const lh=({graph:t,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:l,modules:a})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:u,Position:g,BaseEdge:m,EdgeLabelRenderer:h,getSmoothStepPath:f,dagre:v}=a,y=x.useMemo(()=>({lineage:$=>{var G,te,pe,B;const _=((G=$.data)==null?void 0:G.stepPosition)??.85,[C,I,T]=f({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),z=!!((te=$.data)!=null&&te.isSibling),H=z?I:$.targetX-18,W=z?T:$.targetY-12,A=(pe=$.data)==null?void 0:pe.labelStyle,Y=(B=$.data)==null?void 0:B.labelBgStyle;return e.jsxs(e.Fragment,{children:[e.jsx(m,{id:$.id,path:C,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&e.jsx(h,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${H}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...Y,...A},children:$.label})})]})}}),[m,h,f]),k=x.useMemo(()=>({version:$=>{const{t:_}=K(),C=$.data,I=C.kind==="hypothetical",T=C.status==="lost",z=C.isSelected,H=C.bridge,W=C.borderColor??i("muted"),A=H||I?"dashed":"solid",Y=H?.5:T?.6:1;return e.jsxs("div",{style:{background:i(H?"bg-subtle":"bg"),border:`2px ${A} ${z?i("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:Y,boxShadow:z?i("shadow-node-selected"):I||H?"none":i("shadow-node")},title:H?_("lineage.bridgeTitle"):void 0,children:[e.jsx(u,{type:"target",position:g.Left,style:{visibility:"hidden"}}),e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:I||!C.renderLink?C.label:C.renderLink(C.bookId,C.label)}),C.description&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:C.description}),C.yearText&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:oa(C.yearText,void 0,C.uncertain)}),T&&e.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:_("lineage.lost")}),e.jsx(u,{type:"source",position:g.Right,style:{visibility:"hidden"}})]})}}),[u,g]),{convert:b}=K(),{rfNodes:j,rfEdges:w}=x.useMemo(()=>ah(t,v,n,l,b),[t,v,n,l,b]);return e.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:e.jsxs(d,{nodes:j,edges:w,nodeTypes:k,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[e.jsx(c,{gap:16}),e.jsx(p,{showInteractive:!1})]})})};function ah(t,n,o,r,s=l=>l??""){const d=t.layout==="LR"||!t.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(t.groups.map(k=>[k.id,k.color??i("muted")]));for(const k of t.nodes)c.setNode(k.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const k of t.edges)k.kind==="derive"&&(u.has(k.relation)||c.setEdge(k.source,k.target));n.layout(c);const g=t.nodes.map(k=>{const b=c.node(k.id),j=r?k.id===r:void 0,w={kind:k.kind,label:s(k.label),bookId:k.kind==="book"?k.id:void 0,yearText:s(k.year_text??dh(k)),uncertain:k.year_uncertain,category:k.category,status:k.status,borderColor:k.group?p.get(k.group):void 0,renderLink:o,isSelected:j,description:s(k.description),bridge:k.bridge};return{id:k.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:w,draggable:!1,selected:j}}),m=.78,h=.06,f=new Map;for(const k of t.edges)k.kind==="derive"&&(f.has(k.source)||f.set(k.source,[]),f.get(k.source).push(k));const v=new Map;for(const[k,b]of f){if(b.length<=1)continue;const j=[...b].sort((S,$)=>{var I,T;const _=((I=c.node(S.target))==null?void 0:I.y)??0,C=((T=c.node($.target))==null?void 0:T.y)??0;return _-C}),w=j.length;j.forEach((S,$)=>{const _=($-(w-1)/2)*h;v.set(S.id,m+_)})}const y=t.edges.map(k=>ch(k,v.get(k.id),s));return{rfNodes:g,rfEdges:y}}function ch(t,n,o=r=>r??""){const r=t.confidence==="probable"||t.confidence==="disputed",s=t.kind==="sibling",l=ph(t.confidence),a={type:"arrowclosed",color:l,width:14,height:14};return{id:t.id,source:t.source,target:t.target,type:"lineage",label:o(t.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:l,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:a,markerStart:s?a:void 0,zIndex:1e3}}function dh(t){if(t.year_range)return`~${t.year_range[0]}–${t.year_range[1]}`;if(typeof t.year=="number")return String(t.year)}function ph(t){switch(t){case"certain":return i("confidence-certain");case"consensus":return i("lineage-edge-consensus");case"probable":return i("confidence-probable");case"disputed":return i("confidence-disputed");default:return i("muted")}}const qr={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},ko=({graph:t,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:l,collection:a,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:u,style:g})=>{var w;const{t:m,convert:h}=K(),[f,v]=x.useState(n),y=S=>{v(S),l==null||l(S)},k=(()=>{if(!c)return[];const S=Object.entries(c);return S.length===0||c.all?S:[...S,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(d&&k.length>0);if(!t.nodes.length)return e.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:m("lineage.empty")});const j=a?(w=c==null?void 0:c[a])==null?void 0:w.description:void 0;return e.jsxs("div",{className:u,style:g,children:[e.jsxs("div",{style:uh,children:[e.jsx("button",{onClick:()=>y("list"),style:ai(f==="list"),children:m("lineage.modeList")}),e.jsx("button",{onClick:()=>y("graph"),style:ai(f==="graph"),children:m("lineage.modeGraph")}),b&&e.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:12,color:i("muted"),marginRight:4},children:m("lineage.collectionLabel")}),k.map(([S,$])=>{const _=p==null?void 0:p[S];return e.jsxs("button",{onClick:()=>d==null?void 0:d(S),style:ai(a===S),title:$.description?h($.description):void 0,children:[h($.label),_!=null?` ${_}`:""]},S)})]})]}),b&&j&&e.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:h(j)}),f==="list"?e.jsx(ra,{graph:t,renderLink:o}):e.jsx(sa,{graph:t,renderLink:o,height:r,selectedNodeId:s})]})},uh={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},ai=t=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:t?i("primary"):"transparent",color:i(t?"primary-fg":"fg"),cursor:"pointer"}),Zr=40,Jr=2,mh=9,gh=new Set(["certain","consensus","probable","disputed"]);function ci(t){if(!t)return["",""];const n=t.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",t]}const la=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:l,fullTextPending:a,chapterLink:d,railTop:c,back:p,railLinks:u})=>{var N,ne,J,re,Ce,Le,$e,X,Ie,fe,Me;const g=ke(),{t:m,convert:h}=K(),[f,v]=x.useState(null),[y,k]=x.useState(new Map),[b,j]=x.useState([]),[w,S]=x.useState(new Map),[$,_]=x.useState(!1),[C,I]=x.useState("flow"),[T,z]=x.useState(null);x.useEffect(()=>{if(!n||!t.work_id){v(null);return}let P=!1;return n.getItem(t.work_id).then(q=>{!P&&q&&q.type==="work"&&v(q)}).catch(()=>{}),()=>{P=!0}},[n,t.work_id]),x.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!t.work_id){z(null);return}let P=!1;return n.getLineageGraph(t.work_id).then(q=>{P||z(q&&q.nodes.length>1?q:null)}).catch(()=>{P||z(null)}),()=>{P=!0}},[n,t.work_id]),x.useEffect(()=>{const P=t.contained_in||[];if(!n||P.length===0){k(new Map);return}let q=!1;return Promise.all(P.map(se=>{const ue=typeof se=="string"?se:se.id;return n.getItem(ue).then(ie=>[ue,ie]).catch(()=>[ue,null])})).then(se=>{if(q)return;const ue=new Map;for(const[ie,M]of se)M&&ue.set(ie,M);k(ue)}),()=>{q=!0}},[n,t.contained_in]);const H=x.useMemo(()=>{const P=new Set([...(f==null?void 0:f.books)||[],...t.related_books||[]]);return P.add(t.id),[...P]},[f==null?void 0:f.books,t.related_books,t.id]),W=H.length-1;x.useEffect(()=>{if(!n||W<=0){j([]);return}const P=H.length<=Zr,q=P?H:H.slice(0,8);let se=!1;return Promise.all(q.map(ue=>ue===t.id?Promise.resolve({id:ue,title:t.title,edition:t.edition,year:$n(t)}):n.getItem(ue).then(ie=>{const M=ie??{};return{id:ue,title:M.title,edition:M.edition,year:ie?$n(M):void 0}}).catch(()=>({id:ue})))).then(ue=>{if(se)return;const ie=ue.filter(M=>M.id===t.id||M.title||M.edition);P&&ie.sort((M,ge)=>(M.year??1/0)-(ge.year??1/0)),j(ie)}),()=>{se=!0}},[n,H,W,t]);const A=t.lineage,Y=x.useMemo(()=>[...((A==null?void 0:A.derived_from)||[]).filter(P=>P.ref_type==="book").map(P=>P.ref),...((A==null?void 0:A.related_to)||[]).map(P=>P.book_id)].filter(Boolean),[A]);x.useEffect(()=>{if(!n||Y.length===0){S(new Map);return}let P=!1;return Promise.all(Y.map(q=>n.getItem(q).then(se=>[q,{id:q,title:se==null?void 0:se.title,edition:se==null?void 0:se.edition}]).catch(()=>[q,{id:q}]))).then(q=>{P||S(new Map(q))}),()=>{P=!0}},[n,Y]);const G=x.useMemo(()=>ea(t.resources,t.resource_groups,m),[t.resources,t.resource_groups,m]),te=G.groups.reduce((P,q)=>P+q.rows.length+q.mirrors.length,0),pe=G.groups.length>0&&G.groups.every(P=>P.key==="_physical"),B=ln(t),E=pl(t),ee=xt(t,g.unit.juan),L=new Set((t.contained_in||[]).map(P=>typeof P=="string"?0:nn(P.volume_index).length).filter(P=>P>0)),U=P=>{var ue;const q=(ue=t.base_edition)==null?void 0:ue.find(ie=>ie.book_id===P&&ie.name);if(q!=null&&q.name)return q.name;const se=w.get(P);return(se==null?void 0:se.edition)||(se==null?void 0:se.title)||""},de=x.useMemo(()=>{var we,je,oe,Oe,Fe;const P=[];E&&P.push({label:m("bookPage.fact.editionType"),value:h(E),title:t.edition_type||(we=t.lineage)!=null&&we.category?void 0:m("bookPage.inferredFromEdition")}),(je=t.publication_info)!=null&&je.details?P.push({label:m("bookPage.fact.publication"),value:h(t.publication_info.details)}):(B.era||B.reign)&&P.push({label:m("bookPage.fact.era"),value:h([B.era,B.reign].filter(Boolean).join(" ")),title:B.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),ee&&P.push({label:m("bookPage.fact.measure"),value:h(ee)});const q=(t.contained_in||[]).flatMap(Ne=>typeof Ne=="string"?[]:nn(Ne.volume_index));q.length&&P.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Hn(q,g.unit.volume),unit:g.unit.volume,n:q.length})});const se=(((oe=t.lineage)==null?void 0:oe.derived_from)||[]).find(Ne=>Ne.relation==="底本"&&Ne.ref_type==="book");se&&U(se.ref)&&P.push({label:m("bookPage.fact.baseEdition"),value:e.jsx(Ue,{id:se.ref,label:h(U(se.ref)),onNavigate:o,renderLink:r,dense:!0})});const ue=(t.base_edition||[]).filter(Ne=>Ne&&Ne.name);for(const Ne of["底本","配補","參校"]){if(Ne==="底本"&&se&&U(se.ref))continue;const Qe=ue.filter(V=>V.role===Ne);Qe.length&&P.push({label:h(Ne),value:Qe.map((V,Pe)=>e.jsxs(x.Fragment,{children:[Pe>0&&"、",V.book_id?e.jsx(Ue,{id:V.book_id,label:h(V.name),onNavigate:o,renderLink:r,dense:!0}):h(V.name)]},Pe))})}const ie=(t.provenance||[]).filter(Ne=>Ne&&Ne.institution),M=(t.resources||[]).filter(Ne=>(Ne.types||(Ne.type?[Ne.type]:[])).includes("physical"));if(ie.length){P.push({label:m("bookPage.fact.holdings"),value:ie.slice(0,2).map(V=>h(V.institution)).join("、")+(ie.length>2?m("bookPage.andMorePlaces",{n:ie.length}):"")});const Ne=ie.filter(V=>V.call_number).slice(0,2).map(V=>`${h(V.institution)} ${V.call_number}`);Ne.length&&P.push({label:m("bookPage.fact.callNumber"),value:Ne.join(";")+(ie.filter(V=>V.call_number).length>2?"…":"")});const Qe=ie.flatMap(V=>V.seals||[]).filter(Boolean);Qe.length&&P.push({label:m("bookPage.fact.seals"),value:h(Qe.join("、"))})}else M.length?P.push({label:m("bookPage.fact.holdings"),value:M.slice(0,2).map(Ne=>h(Ne.name)).join("、")+(M.length>2?m("bookPage.andMorePlaces",{n:M.length}):"")}):(Oe=t.current_location)!=null&&Oe.name&&P.push({label:m("bookPage.fact.holdings"),value:h(t.current_location.name)});const ge=t.physical_description;if(ge){const Ne=[[m("bookPage.fact.leafStyle"),ge.leaf_style],[m("bookPage.fact.binding"),ge.binding],[m("bookPage.fact.dimensions"),ge.dimensions],[m("bookPage.fact.condition"),ge.condition]];for(const[Qe,V]of Ne)V&&V.trim()&&P.push({label:Qe,value:h(V)})}(Fe=t.page_count)!=null&&Fe.description&&P.push({label:g.label.pageCount,value:h(t.page_count.description)});const O=[..._i(t.additional_titles),..._i(t.attached_texts)];return O.length&&P.push({label:m("bookPage.fact.aliases"),value:O.map(h).join("、")}),P},[t,h,g,m,B,E,ee,w,o,r]),ve=h(t.title),Z=t.edition?h(t.edition):void 0,ce=((N=t.lineage)==null?void 0:N.year_text)||"",be=e.jsx(cn,{kind:m("bookPage.kind"),title:ve,subtitle:Z,byline:e.jsx(jo,{authors:t.authors??(f==null?void 0:f.authors),onNavigate:o,renderLink:r}),meta:(()=>{const P=[E?h(E):"",B.era?h([B.era,B.reign].filter(Boolean).join("")):"",ee?h(ee):""].filter(Boolean);return P.length?e.jsx("span",{className:"bim-d-tags",children:P.map((q,se)=>e.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(se,2)}`,children:q},se))}):null})(),description:(ne=t.description)!=null&&ne.text?e.jsx(ht,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:no((J=t.description)==null?void 0:J.text)?6:void 0,facts:de,readAction:s,secondaryAction:s&&te>0&&!pe?e.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:e.jsx(dn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo})}),We=t.contained_in||[],ye=(l==null?void 0:l.chapters)||[],_e=h(ye[0]&&ci(ye[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),He=m("bookPage.chapterCount",{n:ye.length,unit:_e}),Be=!!((re=A==null?void 0:A.derived_from)!=null&&re.length||(Ce=A==null?void 0:A.related_to)!=null&&Ce.length||(Le=t.appendix)!=null&&Le.length),Re=[],ze=m(pe?"bookPage.sec.physical":"bookPage.sec.images");(ye.length||G.text.length||a)&&Re.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:ye.length?He:void 0}),G.groups.length&&Re.push({id:"images",label:ze,count:te}),Be&&Re.push({id:"lineage",label:m("bookPage.sec.lineage")}),We.length&&Re.push({id:"collections",label:m("section.containedIn"),count:We.length}),($e=t.location_history)!=null&&$e.length&&Re.push({id:"provenance",label:m("section.locationHistory")});const Ee=P=>(d==null?void 0:d(P))??null,D=ye[0],ae=D?Ee(D.file):null,le=$?ye:ye.slice(0,mh),Se=(P,q,se)=>P?e.jsx("a",{className:se,href:P.href??"#",onClick:P.onClick?ue=>{ue.metaKey||ue.ctrlKey||(ue.preventDefault(),P.onClick())}:void 0,children:q}):e.jsx("span",{className:se,children:q}),F=e.jsxs(e.Fragment,{children:[(ye.length>0||G.text.length>0||a)&&e.jsxs(Ke,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:ye.length>0?e.jsx(Ye,{items:[He,(X=l==null?void 0:l.source)!=null&&X.name?m("bookPage.sourceBy",{src:h(`${l.source.name}${l.source.license?` ${l.source.license}`:""}`)}):""]}):void 0,children:[a&&!D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[e.jsx("span",{className:"bim-d-ft-h",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "})]}),e.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),D&&e.jsxs("div",{className:"bim-d-ft",children:[e.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:h(ci(D.title)[0])||m("bookPage.firstChapter")})}),e.jsx("span",{className:"bim-d-meta",children:h((D.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),Se(ae,e.jsxs(e.Fragment,{children:[m("bookPage.enterReader")," ",e.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ye.length>1&&e.jsx("ul",{className:"bim-d-chap",children:le.map(P=>{const[q,se]=ci(P.title);return e.jsx("li",{children:Se(Ee(P.file),e.jsxs(e.Fragment,{children:[q&&e.jsx("b",{children:h(q)}),h(se||P.file)]}))},P.file)})}),ye.length>le.length&&e.jsx(to,{label:m("detail.expandRest",{n:ye.length-le.length,unit:_e}),onClick:()=>_(!0)}),G.text.length>0&&e.jsxs(e.Fragment,{children:[(ye.length>0||a)&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:G.text.map((P,q)=>e.jsx(vo,{item:P,siblings:G.text,listedVolumeCounts:L},`${P.id||P.url||P.name}-${q}`))})})]})]}),G.groups.length>0&&e.jsx(Ke,{id:"images",title:ze,meta:e.jsx(Ye,{items:[G.groups.length>1?m("bookPage.groupCount",{n:G.groups.length}):"",m("bookPage.placeCount",{n:te})]}),children:e.jsx(na,{groups:G.groups,listedVolumeCounts:L})}),Be&&e.jsx(Ke,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(Ie=A==null?void 0:A.derived_from)!=null&&Ie.length?m("bookPage.lineageMeta"):void 0,action:T?e.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[e.jsx("button",{type:"button","aria-pressed":C==="flow",onClick:()=>I("flow"),children:m("bookPage.viewCards")}),e.jsx("button",{type:"button","aria-pressed":C==="graph",onClick:()=>I("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:C==="graph"&&T?e.jsx(ko,{graph:T,defaultMode:"graph",selectedNodeId:t.id,graphHeight:480,renderLink:(P,q)=>e.jsx(Ue,{id:P,label:h(q),onNavigate:o,renderLink:r,dense:!0})}):e.jsx(xh,{data:t,heading:Z||ve,yearText:ce,refName:U,onNavigate:o,renderLink:r})}),We.length>0&&e.jsx(Ke,{id:"collections",title:m("section.containedIn"),children:e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:We.map((P,q)=>{var ge,O;const se=typeof P=="string"?P:P.id,ue=typeof P=="string"?[]:nn(P.volume_index),ie=y.get(se),M=(ie==null?void 0:ie._member_count)||((ge=ie==null?void 0:ie.books)==null?void 0:ge.length)||((O=ie==null?void 0:ie.contained_works)==null?void 0:O.length)||0;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ue,{id:se,label:ie?h(ie.title):se,onNavigate:o,renderLink:r,dense:!0}),ue.length>0&&e.jsx(hh,{volumes:ue,unit:g.unit.volume})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:M>0&&m("bookPage.totalOf",{n:M,unit:g.unit.bu})})]},`${se}-${q}`)})})})}),(fe=t.location_history)!=null&&fe.length?e.jsx(Ke,{id:"provenance",title:m("section.locationHistory"),children:e.jsx("ul",{className:"bim-d-tl",children:t.location_history.map((P,q)=>e.jsxs("li",{children:[e.jsx("span",{className:"bim-d-tl-t",children:h(P.name)}),([P.start_date,P.end_date].filter(Boolean).join("—")||P.description)&&e.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:e.jsx(Ye,{items:[[P.start_date,P.end_date].filter(Boolean).join("—"),P.description?h(P.description):""]})})]},q))})}):null,Re.length===0&&e.jsx(Ke,{title:m("bookPage.sec.empty"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),me=b.findIndex(P=>P.id===t.id),Ae=H.length<=Zr,R=Ae&&me>=0?b.slice(Math.max(0,me-Jr),me+Jr+1):b.filter(P=>P.id!==t.id),Q=e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[e.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:h(g.section.belongsToWork)}),e.jsx("div",{style:{fontSize:17,fontWeight:500},children:e.jsx(Ue,{id:f.id,label:h(f.title),onNavigate:o,renderLink:r})}),e.jsx(Ye,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(f.authors||[]).slice(0,2).map(P=>`${P.dynasty?`〔${h(P.dynasty)}〕`:""}${h(P.name)}`),h(xt(f,g.unit.juan)),f._edition_count?m("bookPage.editionCount",{n:f._edition_count}):""]}),((Me=f.description)==null?void 0:Me.text)&&e.jsx("p",{style:{margin:"8px 0 0",fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc",children:h(f.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&R.length>0&&e.jsxs("div",{children:[e.jsx(_t,{id:"siblings",timeline:!0,title:Ae?m("bookPage.siblings"):g.relation.siblingVersions,meta:Ae?m("bookPage.byEra"):m("bookPage.kindCount",{n:W}),cap:R.length,items:R.map(P=>P.id===t.id?e.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:h(P.edition||P.title||P.id)}):e.jsx(Ue,{id:P.id,label:h(P.edition||P.title||P.id),onNavigate:o,renderLink:r,dense:!0})),metas:R.map(P=>[P.year!=null?P.year<0?m("detail.bce",{n:-P.year}):String(P.year):"",P.id===t.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:R.findIndex(P=>P.id===t.id)}),f&&e.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:e.jsx(Ue,{id:f.id,label:m("bookPage.viewAllInWork",{n:H.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),xe=t.work_id?e.jsx(ul,{caption:g.section.belongsToWork,children:e.jsx(Ue,{id:t.work_id,label:f?h(f.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return e.jsx(an,{railTop:c,back:p,up:xe,nav:Re,railLinks:u,main:F,card:be,side:Q})};function hh({volumes:t,unit:n}){const{t:o}=K();return e.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:Hn(t,n),unit:n}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-d-dot"}),o("bookPage.volumeCount",{n:t.length,unit:n})]})]})}function xh({data:t,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:l}){var k;const{t:a,convert:d}=K(),c=t.lineage,p=(c==null?void 0:c.derived_from)||[],u=p.filter(b=>b.ref_type!=="book"),g=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),h=(c==null?void 0:c.related_to)||[],f=p.length>0||h.length>0,v=b=>b&&gh.has(b)?a("bookPage.confidenceNote",{c:a(`bookPage.confidence.${b}`)}):"",y=(b,j)=>e.jsx(Ue,{id:b,label:d(j||b),onNavigate:s,renderLink:l,dense:!0});return e.jsxs("div",{className:"bim-d-lf",children:[f&&e.jsxs("ol",{className:"bim-d-lf-list",children:[u.map((b,j)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):a("bookPage.lineage.ancestor")}),e.jsx("span",{className:"bim-d-lf-name",children:a("bookPage.lineage.reconstructed")}),b.evidence&&e.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),v(b.confidence)]})]})},`a-${j}`)),g.map((b,j)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-card",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]})},`b-${j}`)),e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[e.jsxs("div",{className:"bim-d-lf-here",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:a("bookPage.lineage.thisEdition")}),e.jsx("span",{className:"bim-d-lf-name",children:n}),o&&e.jsx("span",{className:"bim-d-lf-yr",children:d(o)})]}),m.length>0&&e.jsx("div",{className:"bim-d-lf-side",children:m.map((b,j)=>e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),v(b.confidence)]})]},j))})]}),h.length>0&&e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[e.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:a("bookPage.lineage.derivatives")}),e.jsx("span",{className:"bim-d-lf-chips",children:h.map((b,j)=>e.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,r(b.book_id)),e.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},j))})]})]}),(k=t.appendix)==null?void 0:k.map((b,j)=>e.jsxs("details",{className:"bim-d-lf-app",children:[e.jsxs("summary",{className:"bim-d-ui",children:[e.jsx("span",{className:"bim-d-meta",children:a("bookPage.lineage.appendix")})," ",d(b.title)]}),e.jsx(ht,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${j}`)),(c==null?void 0:c.note)&&e.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(c.note)})]})}const Qt=16,fh=200,bh=16,aa=({data:t,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:l,railTop:a,back:d,railLinks:c})=>{var Se,F,me,Ae,R,Q,xe;const{t:p,convert:u,messages:g}=K(),[m,h]=x.useState(""),[f,v]=x.useState(!1),[y,k]=x.useState(null),[b,j]=x.useState(""),[w,S]=x.useState(!1),$=x.useMemo(()=>cl(t,n),[t,n]),[_,C]=x.useState(new Map),I=!!o&&$.rows.length>0&&$.rows.length<=fh,T=I&&($.rows.length<=Qt||w),z=T&&$.rows.every(N=>!N.id||_.has(N.id)),H=N=>{var ne;return Ii(N?(ne=_.get(N))==null?void 0:ne.l1:void 0)},W=x.useMemo(()=>{const N=m.trim(),ne=N?u(N):"";return $.rows.filter(J=>{var Ce,Le;if(b&&Ii(J.id?(Ce=_.get(J.id))==null?void 0:Ce.l1:void 0)!==b)return!1;if(!ne)return!0;const re=J.id&&((Le=_.get(J.id))==null?void 0:Le.title)||J.title;return u(re).includes(ne)||(J.subItems||[]).some($e=>u($e).includes(ne))})},[$.rows,m,b,_,u]),A=f?W:W.slice(0,Qt),Y=x.useMemo(()=>(T?$.rows:A).filter(N=>N.id&&!_.has(N.id)).map(N=>N.id),[T,$.rows,A,_]);x.useEffect(()=>{if(!o||Y.length===0)return;let N=!1;const ne=Y.slice(0,bh);return Promise.all(ne.map(J=>o.getItem(J).then(re=>{var $e,X;const Ce=re??{},Le={title:Ce.title,edition:Ce.edition,authors:Ce.authors,measure:re?xt(re,g.unit.juan):void 0,versionCount:Ce._edition_count??(($e=Ce.books)==null?void 0:$e.length),l1:((X=Ce.classification)==null?void 0:X.l1)||void 0};return[J,Le]}).catch(()=>[J,{}]))).then(J=>{N||C(re=>{const Ce=new Map(re);for(const[Le,$e]of J)Ce.set(Le,$e);return Ce})}),()=>{N=!0}},[o,Y,g.unit.juan]);const G=(t.contained_in||[])[0];x.useEffect(()=>{if(!G){k(null);return}if(k({id:G}),!o)return;let N=!1;return o.getItem(G).then(ne=>{N||k({id:G,title:ne==null?void 0:ne.title})}).catch(()=>{}),()=>{N=!0}},[o,G]);const te=x.useMemo(()=>ea(t.resources,t.resource_groups,p),[t.resources,t.resource_groups,p]),pe=te.text.length+te.groups.reduce((N,ne)=>N+ne.rows.length+ne.mirrors.length,0),B=t.contained_works||[],E=new Set($.rows.map(N=>N.id).filter(Boolean)),ee=B.length>0&&!B.every(N=>E.has(N.id)),L=(()=>{const N=$.rows.map(ne=>ne.edition).filter(Boolean);return N.length>1&&new Set(N).size===1})(),U=$.rows.some(N=>N.volumes.length>0||N.expected!=null),de=t._member_count||((Se=t.books)==null?void 0:Se.length)||B.length,ve=xt(t,g.unit.juan),Z=t.count,ce=N=>typeof N=="number"&&Number.isFinite(N)?N:null,be=ce(Z==null?void 0:Z.juan)??ce((F=t.juan_count)==null?void 0:F.number),We=ce(Z==null?void 0:Z.ce)??($.totalVolumes||null),ye=[{value:$.rows.length,label:p("collectionPage.stat.titles")},{value:be??0,label:g.unit.juan},{value:We??0,label:g.unit.volume}],_e=x.useMemo(()=>{var J,re;const N=[];if((J=t.publication_info)!=null&&J.details&&N.push({label:p("collectionPage.fact.publication"),value:u(t.publication_info.details)}),de&&de!==$.rows.length){const Ce=t._member_type==="Book"?p("collectionPage.member.Book"):t._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");N.push({label:Ce,value:`${de} ${g.unit.bu}`,title:p("collectionPage.memberNote")})}const ne=[ce(Z==null?void 0:Z.zhong)!=null?p("collectionPage.nZhong",{n:Z.zhong}):"",ce(Z==null?void 0:Z.han)!=null?p("collectionPage.nHan",{n:Z.han}):""].filter(Boolean);return ne.length&&N.push({label:p("collectionPage.fact.expected"),value:ne.join(" ")}),be==null&&ve&&N.push({label:p("collectionPage.fact.measure"),value:u(ve),title:(re=t.juan_count)!=null&&re.description?u(t.juan_count.description):void 0}),N},[t,de,$.rows.length,be,ve,Z,u,p,g]),He=x.useMemo(()=>{if(!z)return[];const N=new Map;for(const J of $.rows){const re=H(J.id);re&&N.set(re,(N.get(re)??0)+1)}const ne=rn.filter(J=>(N.get(J.key)??0)>0);return ne.length<2?[]:[{key:"",label:`${g.catalog.all} ${$.rows.length}`},...ne.map(J=>({key:J.key,label:`${J.label} ${N.get(J.key)}`}))]},[z,$.rows,_,g]),Be=x.useMemo(()=>{if(!z||!$.rows.some(re=>re.volumes.length>0))return null;const N=[],ne=$.rows.filter(re=>re.volumes.length>0).map(re=>({k:H(re.id)??"",from:Math.min(...re.volumes),to:Math.max(...re.volumes)})).sort((re,Ce)=>re.from-Ce.from);for(const re of ne){const Ce=re.to-re.from+1,Le=N[N.length-1];Le&&Le.key===re.k?(Le.to=Math.max(Le.to,re.to),Le.n+=Ce):N.push({key:re.k,from:re.from,to:re.to,n:Ce})}const J=ne.reduce((re,Ce)=>Math.max(re,Ce.to),0);return N.length>1&&N.some(re=>re.key)?{segs:N,last:J}:null},[z,$.rows,_]),Re=(me=t.description)==null?void 0:me.text,ze=e.jsx(cn,{kind:p("collectionPage.kind"),title:u(t.title),byline:e.jsx(jo,{authors:t.authors,onNavigate:r,renderLink:s}),meta:e.jsx(Ye,{items:[t.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Ae=t.publication_info)!=null&&Ae.year?u(t.publication_info.year):""]}),description:Re||(R=t.history)!=null&&R.length?e.jsxs(e.Fragment,{children:[Re&&e.jsx(ht,{text:Re,style:{fontSize:15,lineHeight:1.85}}),(Q=t.history)!=null&&Q.length?e.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:t.history.map((N,ne)=>e.jsx("li",{children:u(N)},ne))}):null]}):void 0,clampDescription:no(Re)||(((xe=t.history)==null?void 0:xe.length)??0)>2?6:void 0,stats:ye,facts:_e,foot:e.jsx(dn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:Be&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:p("collectionPage.dist.head")})}),e.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":p("collectionPage.dist.head"),children:Be.segs.map((N,ne)=>{const J=rn.find(re=>re.key===N.key);return e.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!J,title:J?p("collectionPage.dist.segTitle",{section:u(J.label),from:N.from,to:N.to}):void 0,"aria-label":J?p("collectionPage.dist.only",{section:u(J.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!J&&b===N.key,style:{flexGrow:N.n,background:i(J?J.token:"rule")},onClick:()=>{J&&(j(b===N.key?"":N.key),v(!1))}},ne)})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:p("catalog.volume",{n:1})}),e.jsx("span",{children:p("collectionPage.dist.hint")}),e.jsx("span",{children:p("catalog.volume",{n:Be.last})})]})]})}),Ee=[];$.rows.length&&Ee.push({id:"titles",label:p("collectionPage.sec.titles"),count:$.rows.length}),pe&&Ee.push({id:"resources",label:p("collectionPage.sec.resources"),count:pe}),ee&&Ee.push({id:"works",label:g.section.containedWorks,count:B.length});const D=e.jsxs(e.Fragment,{children:[$.rows.length>0&&e.jsxs(Ke,{id:"titles",title:p("collectionPage.sec.titles"),meta:e.jsx(Ye,{items:[`${$.rows.length} ${g.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:g.unit.volume}):"",W.length!==$.rows.length?p("collectionPage.currentN",{n:W.length,unit:g.unit.items}):""]}),action:l,children:[($.rows.length>Qt||He.length>0)&&e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[He.length>0&&e.jsx(On,{items:He,value:b,onChange:N=>{j(N),v(!1)}}),I&&$.rows.length>Qt&&!z&&e.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:w,onClick:()=>S(!0),title:p("collectionPage.loadAllTitle",{n:$.rows.length,unit:g.unit.items}),children:p(w?"collectionPage.grouping":"collectionPage.groupBySection")}),e.jsx("span",{className:"bim-d-spacer"}),$.rows.length>Qt&&e.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:N=>{h(N.target.value),v(!1)}})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Fn(W.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[U&&e.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),e.jsx("th",{children:p("collectionPage.col.title")}),e.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),e.jsx("tbody",{children:A.map((N,ne)=>{var Ie;const J=N.id?_.get(N.id):void 0,re=J!=null&&J.title&&N.title===N.id?J.title:N.title,Ce=((J==null?void 0:J.authors)||[]).find(fe=>fe&&fe.name),Le=[Ce?`${Ce.dynasty?`〔${u(Ce.dynasty)}〕`:""}${u(Ce.name)}${Ce.role?` ${u(Ce.role)}`:""}`:"",J!=null&&J.measure?u(J.measure):"",(Ie=N.subItems)!=null&&Ie.length?N.subItems.map(fe=>u(fe)).join("、"):"",(J!=null&&J.edition||N.edition)&&!L?u((J==null?void 0:J.edition)||N.edition||""):""].filter(Boolean),$e=rn.find(fe=>fe.key===H(N.id)),X=N.volumes.length>0?p("collectionPage.volumeRange",{range:Hn(N.volumes,g.unit.volume),unit:g.unit.volume}):N.expected!=null?`${N.found??0}/${N.expected} ${g.unit.volume}`:"";return e.jsxs("tr",{children:[U&&e.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${X?"":" bim-d-zt-blank"}`,children:[$e&&e.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i($e.token)}}),X||e.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),e.jsxs("td",{className:"bim-d-zt-main",children:[N.id?e.jsx(Ue,{id:N.id,label:u(re),onNavigate:r,renderLink:s,dense:!0}):e.jsx("span",{className:"bim-d-zt-name",children:u(re)}),Le.length>0?e.jsx(Ye,{items:Le}):N.id&&!J&&o?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${J!=null&&J.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:J!=null&&J.versionCount?p("collectionPage.nZhong",{n:J.versionCount}):""})]},`${N.id??N.title}-${ne}`)})})]}),A.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!f&&e.jsx(eo,{total:W.length,shown:A.length,unit:g.unit.items,onClick:()=>v(!0)})]}),pe>0&&e.jsxs(Ke,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:pe}),children:[te.text.length>0&&e.jsxs("div",{className:"bim-d-rg",children:[te.groups.length>0&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:te.text.map((N,ne)=>e.jsx(vo,{item:N,siblings:te.text},`${N.id||N.url||N.name}-${ne}`))})})]}),e.jsx(na,{groups:te.groups})]}),$.rows.length===0&&pe===0&&e.jsx(Ke,{title:p("collectionPage.sec.titles"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),ae=ee?e.jsx(_t,{id:"works",title:g.section.containedWorks,meta:p("collectionPage.nZhong",{n:B.length}),cap:12,items:B.map(N=>e.jsx(Ue,{id:N.id,label:u(N.title),onNavigate:r,renderLink:s,dense:!0}))}):null,le=y?e.jsx(ul,{caption:p("collectionPage.parent"),children:e.jsx(Ue,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return e.jsx(an,{railTop:a,back:d,up:le,nav:Ee,railLinks:c,main:D,card:ze,side:ae})},yh=16,di=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function Xr(t){if(!t)return di.length;const n=di.indexOf(t);return n===-1?di.length:n}function jh(t,n){return t==null?"":t<0?n("entityPage.bce",{n:-t}):String(t)}const vh={秦:[-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]},ca=({data:t,transport:n,onNavigate:o,renderLink:r,railTop:s,back:l,railLinks:a})=>{var le,Se,F,me,Ae;const{t:d,convert:c,messages:p}=K(),u=R=>jh(R,d),[g,m]=x.useState("全部"),[h,f]=x.useState(!1),[v,y]=x.useState("default"),[k,b]=x.useState(new Map),j=x.useMemo(()=>(t.works||[]).map(R=>{const Q=k.get(R.work_id);return{id:R.work_id,title:(Q==null?void 0:Q.title)??R.title??R.work_id,role:R.role||"",cls:Xi(R.role),versionCount:Q==null?void 0:Q.versionCount,section:Q==null?void 0:Q.cls,l1:Q==null?void 0:Q.l1,measure:Q==null?void 0:Q.measure,hasImage:Q==null?void 0:Q.hasImage,loaded:!!(Q!=null&&Q.loaded)}}),[t.works,k]),w=x.useMemo(()=>al((t.works||[]).map(R=>R.role),d("detail.roleAll")),[t.works,d]),S=x.useMemo(()=>{const R=g==="全部"?j:j.filter(Q=>Q.cls===g);return v==="versions"?[...R].sort((Q,xe)=>(xe.versionCount??-1)-(Q.versionCount??-1)):R},[j,g,v]),$=h?S:S.slice(0,yh),_=x.useMemo(()=>$.filter(R=>!k.has(R.id)).map(R=>R.id),[$,k]);x.useEffect(()=>{if(!n||_.length===0)return;let R=!1;return Promise.all(_.map(Q=>n.getItem(Q).then(xe=>{var re,Ce,Le,$e,X;const N=xe??{},ne=N._edition_count??(((re=N.books)==null?void 0:re.length)??0)+(((Ce=N.collections)==null?void 0:Ce.length)??0),J=[(Le=N.classification)==null?void 0:Le.l1,($e=N.classification)==null?void 0:$e.l2].filter(Boolean).join(" ");return[Q,{id:Q,title:N.title,versionCount:ne,loaded:!0,cls:J||void 0,l1:((X=N.classification)==null?void 0:X.l1)||void 0,measure:xe&&xt(xe,p.unit.juan)||void 0,hasImage:!!(N.has_image??N._has_image)}]}).catch(()=>[Q,{id:Q,loaded:!0}]))).then(Q=>{R||b(xe=>{const N=new Map(xe);for(const[ne,J]of Q)N.set(ne,J);return N})}),()=>{R=!0}},[n,_,p.unit.juan]);const C=x.useMemo(()=>{const R=new Map;for(const Q of t.alt_names||[]){const xe=Q.type||p.section.aliases;R.has(xe)||R.set(xe,[]),R.get(xe).push(Q.name)}return[...R.entries()].sort((Q,xe)=>Xr(Q[0])-Xr(xe[0])).map(([Q,xe])=>({label:Q,names:xe}))},[t.alt_names,p]),I=t.birth_year??((le=t.dates)==null?void 0:le.birth)??void 0,T=t.death_year??((Se=t.dates)==null?void 0:Se.death)??void 0,z=(F=t.dates)==null?void 0:F.floruit,H=I!=null||T!=null?`${u(I)||"?"}—${u(T)||"?"}`:Array.isArray(z)&&z.length===2&&z.every(R=>Number.isFinite(R))?d("entityPage.floruit",{from:u(z[0]),to:u(z[1])}):"",W=new Set(["本名","字","號","号"]),A=C.filter(R=>W.has(R.label)),Y=C.filter(R=>!W.has(R.label)),G=Y.reduce((R,Q)=>R+Q.names.length,0),te=x.useMemo(()=>{const R=[];for(const xe of A)R.push({label:xe.label,value:xe.names.map(N=>c(N)).join("、")});const Q=(t.works||[]).length;return Q&&R.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:Q})}),R},[t.works,A,c,d]),pe=R=>{var Q;return(Q=C.find(xe=>R.includes(xe.label)))==null?void 0:Q.names[0]},B=pe(["字"]),E=pe(["號","号"]),ee=[B?d("entityPage.zi",{name:c(B)}):"",E?d("entityPage.hao",{name:c(E)}):""].filter(Boolean).join(","),L=t.native_place,U=t.dynasty?vh[t.dynasty]:void 0,de=(()=>{if(!U||I==null||T==null||T<I)return null;const[R,Q]=U,xe=Math.max(I,R),N=Math.min(T,Q);if(N<=xe)return null;const ne=Q-R;return e.jsxs("div",{className:"bim-d-life bim-d-ui",children:[e.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":d("entityPage.lifeAria",{birth:u(I),death:u(T),years:T-I+1}),children:e.jsx("i",{style:{left:`${(xe-R)/ne*100}%`,width:`${(N-xe)/ne*100}%`}})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:`${u(R)} ${c(t.dynasty)}`}),e.jsx("span",{children:d("entityPage.lifeYears",{years:T-I+1})}),e.jsx("span",{children:u(Q)})]})]})})(),ve=x.useMemo(()=>{if(!n||j.length===0||j.some(xe=>!xe.loaded))return null;const R=new Map;for(const xe of j){const N=Ii(xe.l1);N&&R.set(N,(R.get(N)??0)+1)}const Q=rn.map(xe=>({...xe,n:R.get(xe.key)??0})).filter(xe=>xe.n>0);return Q.length?Q:null},[j,n]),Z=e.jsxs(cn,{kind:p.entityPage.subtype[t.subtype]??d("entityPage.subtype.people"),title:c(t.primary_name||t.title),subtitle:ee||void 0,meta:e.jsxs(e.Fragment,{children:[e.jsx(Ye,{items:[t.dynasty?c(t.dynasty):"",H,L?d("entityPage.nativePlace",{place:c(L)}):""]}),de]}),description:(me=t.description)!=null&&me.text?e.jsx(ht,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:no((Ae=t.description)==null?void 0:Ae.text)?6:void 0,facts:te,foot:e.jsx(dn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:[G>0&&e.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[e.jsx("summary",{children:d("entityPage.moreNames",{n:G})}),e.jsx("dl",{children:Y.map(R=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{children:c(R.label)}),e.jsx("dd",{children:R.names.map(Q=>c(Q)).join("、")})]},R.label))})]}),ve&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:d("entityPage.dist")})}),e.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:ve.map(R=>e.jsx("i",{style:{flexGrow:R.n,background:i(R.token)}},R.key))}),e.jsx("div",{className:"bim-d-dist-key",children:ve.map(R=>e.jsxs("span",{children:[e.jsx("i",{style:{background:i(R.token)}}),c(R.label)," ",R.n]},R.key))})]})]}),ce=x.useMemo(()=>j.filter(R=>R.loaded&&(R.versionCount??0)>0).sort((R,Q)=>(Q.versionCount??0)-(R.versionCount??0)).slice(0,3),[j]),be=!!n&&j.length>=3&&$.some(R=>!R.loaded),We=g==="全部"&&(be||ce.length>=2),ye=t.external_ids||{},_e=[];ye.cbdb_id!=null&&_e.push({label:"CBDB",id:String(ye.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ye.cbdb_id}`,note:ye.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const He=ye.wikidata_id;He&&_e.push({label:"Wikidata",id:He,href:`https://www.wikidata.org/wiki/${He}`});const Be=ye.viaf_id;Be&&_e.push({label:"VIAF",id:Be,href:`https://viaf.org/viaf/${Be}`});const Re=w.map(R=>({key:R.cls,label:`${R.label} ${R.count}`})),ze=[...We&&!be?[{id:"featured",label:d("entityPage.sec.featured"),count:ce.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],..._e.length?[{id:"external",label:d("entityPage.sec.external"),count:_e.length}]:[]],Ee=We?e.jsxs(Ke,{id:"featured",title:d("entityPage.sec.featured"),children:[e.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:d("entityPage.featuredSub")}),e.jsxs("div",{className:"bim-d-picks","aria-busy":be||void 0,children:[be&&[0,1,2].map(R=>e.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[e.jsx("span",{className:"bim-d-pick-t",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "}),e.jsx("div",{className:"bim-d-pick-n",children:" "})]},R)),!be&&ce.map(R=>e.jsxs("div",{className:"bim-d-pick",children:[e.jsx("span",{className:"bim-d-pick-t",children:e.jsx(Ue,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0})}),e.jsx(Ye,{items:[R.section?c(R.section):"",R.measure?c(R.measure):""]}),e.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[e.jsx("span",{className:"bim-d-pick-num",children:R.versionCount}),e.jsx("span",{children:d("entityPage.versionsUnit")}),R.hasImage&&e.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},R.id))]})]}):null,D=j.length===0?e.jsx(Ke,{title:d("entityPage.sec.works"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("entityPage.empty")})}):e.jsxs(e.Fragment,{children:[Ee,e.jsxs(Ke,{id:"works",title:d("entityPage.sec.works"),meta:e.jsx(Ye,{items:[d("entityPage.total",{n:j.length}),S.length!==j.length?d("entityPage.current",{n:S.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Re.length>1&&e.jsx(On,{items:Re,value:g,onChange:R=>{m(R),f(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":v==="versions",onClick:()=>{v==="default"&&f(!0),y(R=>R==="default"?"versions":"default")},children:d(v==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!h&&Fn(S.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:d("entityPage.col.work")}),e.jsx("th",{children:d("entityPage.col.section")}),e.jsx("th",{children:d("entityPage.col.role")}),e.jsx("th",{children:d("entityPage.col.versions")}),e.jsx("th",{"aria-label":d("entityPage.col.image")})]})}),e.jsx("tbody",{children:$.map(R=>e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ue,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0}),R.measure?e.jsx(Ye,{items:[c(R.measure)]}):!R.loaded&&n?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.section||R.loaded?"":" bim-d-zt-blank"}`,children:R.section?c(R.section):null}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.role?"":" bim-d-zt-blank"}`,children:R.role?c(R.role):e.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.loaded?"":" bim-d-zt-blank"}`,children:R.loaded?R.versionCount?d("entityPage.nZhong",{n:R.versionCount}):e.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),e.jsx("td",{className:R.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:R.hasImage&&e.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},R.id))})]}),$.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("entityPage.emptyRole")}),!h&&e.jsx(eo,{total:S.length,shown:$.length,unit:d("entityPage.moreUnit"),onClick:()=>f(!0)})]})]}),ae=_e.length>0?e.jsx(_t,{id:"external",title:d("entityPage.sec.external"),items:_e.map(R=>e.jsxs("a",{href:R.href,target:"_blank",rel:"noopener noreferrer",children:[R.label," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:_e.map(R=>R.id),foot:ye.cbdb_id!=null&&ye.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return e.jsx(an,{railTop:s,back:l,nav:ze,railLinks:a,main:D,card:Z,side:ae})},wo="(max-width: 719px)",kh=`${wo}, (pointer: coarse)`,da=`
|
|
1099
|
+
`)}),s=[]};for(const a of n){const p=po(a);if(p){l(),r={kind:"heading",level:p.level,text:p.text};continue}s.push(a)}return l(),o}function fr(t){const n=[];for(const o of t.split(`
|
|
1100
|
+
`)){const r=po(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||uo.test(s)||n.push({kind:"body",text:o})}return n}function Pl(t){if(!t)return[];const n=Gn(t);if(n==="unknown")return fr(t);const o=[];for(const{heading:r,body:s}of Bu(t)){r&&o.push(r);const l=Rl(s);if(l.length!==0){if(Ll(s)){o.push(...fr(s));continue}if(n==="record"){const a=l.join(" ");a&&o.push({kind:"body",text:a})}else for(const a of l){const p=El(a);p.length&&o.push({kind:"body",text:p.join(" ")})}}}return o}const Al=t=>t;function Bl(t,n=Al){if(t.indexOf("《")<0)return n(t);const o=[],r=/《([^《》\n]+)》/g;let s=0,l=0,a;for(;a=r.exec(t);)a.index>s&&o.push(e.jsx(x.Fragment,{children:n(t.slice(s,a.index))},l++)),o.push(e.jsxs("span",{className:"bim-rd-pn",children:[e.jsx("span",{className:"bim-rd-sr",children:"《"}),n(a[1]),e.jsx("span",{className:"bim-rd-sr",children:"》"})]},l++)),s=a.index+a[0].length;return s===0?n(t):(s<t.length&&o.push(e.jsx(x.Fragment,{children:n(t.slice(s))},l++)),o)}function mo(t,n={}){const o=n.renderText??Al,r=n.properNames?l=>Bl(l,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return ot(t,r,s)}function br(t,n,o){return t.indexOf("**")<0?n(t):t.split(/(\*\*[^*]+\*\*)/g).map((s,l)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?e.jsx("strong",{children:n(s.slice(2,-2))},`${o}-${l}`):e.jsx(x.Fragment,{children:n(s)},`${o}-${l}`))}const ai=/^(#{1,6})\s+(.*)$/,Mu=/^\s*<!--.*-->\s*$/;function Ml(t){return t.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
1101
|
+
`)?"":n)}function Wu(t){return t<=1?2:t===2?3:4}function Hu(){let t=1;return n=>{const o=Wu(n),r=Math.min(o,t+1);return t=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function Tn(t){return t?Gn(Ml(t))!=="unknown":!1}function Ou(t){return/^\u3000{2}/.test(t)}const yr=t=>Ou(t)?"bim-rd-noindent":void 0;function jr({text:t,mode:n,inline:o,dropTitle:r}){const s=Ml(t),l=(d,u,g)=>!!r&&g<=1&&d<=2&&u.trim()===r.trim(),a=Hu();if(n==="paragraph"&&Gn(s)!=="unknown"){const d=Pl(s);return e.jsx(e.Fragment,{children:d.map((u,g)=>{if(u.kind==="heading"){if(l(u.level??1,u.text,g))return null;const{Tag:m,className:h}=a(u.level??1);return e.jsx(m,{className:h,children:o(u.text)},g)}return e.jsx("p",{className:yr(u.text),children:br(u.text,o,g)},g)})})}const p=s.split(`
|
|
1102
|
+
`);let c=0;return e.jsx(e.Fragment,{children:p.map((d,u)=>{const g=d.match(ai);if(g){const h=c++;if(l(g[1].length,g[2],h))return null;const{Tag:f,className:v}=a(g[1].length);return e.jsx(f,{className:v,children:o(g[2])},u)}if(!d.trim())return u>=2&&!!p[u-1].trim()&&!!p[u-2].trim()&&!ai.test(p[u-1])&&!ai.test(p[u-2])?e.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(Mu.test(d))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(d.trim())){const{Tag:h,className:f}=a(3);return e.jsx(h,{className:f,children:o(d.trim().slice(2,-2))},u)}return e.jsx("p",{className:yr(d),children:br(d,o,u)},u)})})}function Fu(t){const{convert:n}=Te();return x.useMemo(()=>t?n(t):"",[t,n])}function go({text:t,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:l,dropTitle:a}){const p=Fu(t),{t:c,convert:d}=G(),u=h=>mo(h,{renderText:l,properNames:s,gujiMarkdown:r,t:c}),g=r?{gujiMarkdown:!0,t:c}:void 0,m=a?d(a):void 0;return!o||p.indexOf(":::")<0?e.jsx(jr,{text:p,mode:n,inline:u,dropTitle:m}):e.jsx(e.Fragment,{children:Zi(p).map((h,f)=>h.type==="table"?e.jsx(co,{table:h.table,opts:g},f):e.jsx(jr,{text:h.text,mode:n,inline:u,dropTitle:f===0?m:void 0},f))})}function Du(t,n){const[o,r]=x.useState(null),[s,l]=x.useState(!1),a=x.useRef(0);return x.useEffect(()=>{const p=++a.current;if(!t||!n){r(null),l(!1);return}let c;try{c=t(n)}catch{r(null),l(!1);return}if(!c||typeof c.then!="function"){r(c??null),l(!1);return}l(!0),c.then(d=>{p===a.current&&r(d??null)}).catch(()=>{p===a.current&&r(null)}).finally(()=>{p===a.current&&l(!1)})},[t,n]),{images:o,loading:s}}const vr={A:"fine",B:"rough",C:"rough",D:"ocr"};function Uu(t){return typeof t!="string"?null:t in $c?t:t in vr?vr[t]:null}const Vu={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},Gu={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},Wl="\0";function Yu(t,n,o){const[r,s=""]=t.split(Wl);return e.jsxs(e.Fragment,{children:[r,e.jsx(qs,{text:n,convert:o}),s]})}function st(t){return typeof t!="string"?"":Vu[t]??Gu[t]??t}const Ku=["〇","一","二","三","四","五","六","七","八","九"],kr=["","十","百","千"],qu=["","萬","億"];function ho(t){if(t===0)return"〇";if(t<0)return`負${ho(-t)}`;const n=[];let o=t,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(Zu(s,r>0)+qu[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Zu(t,n){const o=[];let r=t;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let l=0;l<o.length;l++){const a=o[l],p=o.length-1-l;a===0?s&&!s.endsWith("〇")&&(s+="〇"):a===1&&p===1&&l===0&&!n?s+=kr[p]:s+=Ku[a]+kr[p]}return s.replace(/〇$/,"")}let ln=null,jn=null;const Nn=new Set;function Ju(){return ln?Promise.resolve():jn||(jn=import("opencc-js/t2cn").then(t=>{const n=t.Converter({from:"t",to:"cn"});ln=o=>n(xe.normalizeVariants(o)),Nn.forEach(o=>o())}).catch(()=>{ln=t=>t,Nn.forEach(t=>t())}),jn)}const Xu=t=>t;function Et(){const[,t]=x.useState(0);return x.useEffect(()=>{if(ln)return;const n=()=>t(o=>o+1);return Nn.add(n),Ju(),()=>{Nn.delete(n)}},[]),ln??Xu}function Ot(t,n){return n(t).toLowerCase()}const Qu=i("highlight-bg");function gn(t,n,o){if(!n)return t;const r=Ot(n,o);if(!r)return t;const s=Ot(t,o);if(s.length!==t.length)return t;const l=[];let a=0,p=0;for(;a<t.length;){const c=s.indexOf(r,a);if(c===-1){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{style:{background:Qu,padding:0,color:"inherit"},children:t.slice(c,c+r.length)},p++)),a=c+r.length}return e.jsx(e.Fragment,{children:l})}function xo(t,n,o,r){if(!n)return!0;const s=Ot(n,r);return(o?[t.title,t.header_line,t.content,t.comment]:[t.title,t.book_title,t.author,t.author_info,t.summary,t.content,t.comment,t.additional_comment]).some(a=>typeof a=="string"&&Ot(a,r).includes(s))}function em(t,n,o){return n?Ot(t,o).includes(Ot(n,o)):!0}const fo={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},tm={考证:i("section-kaozhen")};function bo(t,n,o){return t.collated.sectionType[n]??o(n)}function Hl(t){var r;const n=t.files.length,o=((r=t.children)==null?void 0:r.reduce((s,l)=>s+Hl(l),0))||0;return n+o}function nm(t,n){const o=[],r=a=>{var p;o.push(...a.files),(p=a.children)==null||p.forEach(r)};if(r(t),o.length===0)return;const s=o.map(a=>n[a]);if(s.every(a=>a===void 0))return;if(s.some(a=>a==="loading"))return"loading";let l=0;for(const a of s)typeof a=="number"&&(l+=a);return l}const im={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function yo({enabled:t,expanded:n,onClick:o,style:r,children:s}){return t?e.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...im,...r},children:s}):e.jsx("span",{style:r,children:s})}function om({type:t}){const{convert:n,messages:o}=G(),r=st(t),s=fo[r]||i("desc-fg");return e.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:bo(o,r,n)})}function rm({section:t,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:l}){const{t:a,convert:p}=G(),c=Ye(),d=Et(),u=j=>j?ot(p(j),S=>o?gn(S,o,d):S,{t:a}):"",[g,m]=x.useState(!1),h=!!t.summary,f=!!t.comment,v=!!t.additional_comment,y=!!(t.content&&t.content.length>60),w=h||f||v||y;x.useEffect(()=>{o&&m(!0)},[o]);const b=!g&&y?$l(t.content.replace(/\n/g," "),80)+"…":null;return e.jsxs("div",{className:"bim-rd-row",id:l,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[e.jsxs("div",{onClick:()=>w&&m(!g),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:w?"pointer":"default",userSelect:"none"},children:[r!=null&&e.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),e.jsxs(yo,{enabled:w,expanded:g,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[w&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:[t.book_title?e.jsxs(e.Fragment,{children:["《",u(t.book_title),"》"]}):u(t.title),t.n_juan!=null&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:a("collated.nJuan",{n:p(ho(t.n_juan))})}),(t.author_info||t.author)&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:u(t.author_info||t.author)})]}),!g&&b&&e.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:u(b)})]})]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u(t.edition)}),t.tag&&e.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:t.tag==="triangle"?"△":t.tag}),t.work_id&&n&&e.jsx("a",{href:c(t.work_id),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(t.work_id))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),"aria-label":a("collated.viewWorkOf",{title:p(t.book_title||t.title)}),children:a("collated.workArrow")}),s&&!t.work_id&&e.jsx("span",{style:{fontSize:"11px",color:i("label-fg"),flexShrink:0},children:a("collated.unlinked")})]}),g&&w&&e.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[t.author_info&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:u(t.author_info)}),t.summary&&e.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.summary")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:u(t.summary)})]}),t.comment&&e.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.comment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.comment)})]}),t.additional_comment&&e.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.additionalComment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.additional_comment)})]}),y&&!h&&!f&&!v&&e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)})]})]})}function sm({section:t,highlightQuery:n=""}){const{t:o,convert:r}=G(),s=Et(),l=d=>d?ot(r(d),u=>n?gn(u,n,s):u,{t:o}):"",[a,p]=x.useState(!1),c=!!t.content;return e.jsxs("div",{style:{padding:"12px 0 6px"},children:[e.jsxs(yo,{enabled:c,expanded:a,onClick:()=>p(!a),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[e.jsx(om,{type:t.type}),e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:l(t.title)}),c&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:a?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),a&&c&&e.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${fo[st(t.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:l(t.content)})})]})}const lm=100;function jo(t){return st(t.type)!=="page_header"?!1:(t.content||"").length>=lm}function am({section:t,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=G(),l=Et();if(st(t.type)==="page_header"&&!jo(t)||!t.content&&!t.title)return null;const a=r((t.content||t.title||"").replace(/\n{2,}/g,`
|
|
1103
|
+
`)),p=ot(a,g=>n?gn(g,n,l):g,{t:o}),c=st(t.type),d=fo[c]||i("desc-fg"),u=c==="序"||c==="结语"||c==="注释";return e.jsxs("div",{style:{padding:u?"10px 12px":"6px 0",margin:u?"8px 0":void 0,fontSize:"13px",color:i("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:u?`3px solid ${d}40`:void 0,background:u?i("bg"):void 0,borderRadius:u?"0 4px 4px 0":void 0,position:"relative"},children:[u&&e.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:d,marginRight:"8px",padding:"1px 5px",border:`1px solid ${d}40`,borderRadius:"2px",background:`${d}08`,verticalAlign:"middle"},children:bo(s,c,r)}),p]})}function cm(t,n,o){const[r,s]=x.useState({});return x.useEffect(()=>{var d;if(!n||t.length===0)return;let l=!1;const a=t.filter(u=>{var g;return!((g=o==null?void 0:o.current)!=null&&g.has(u))}),p={};for(const u of t)(d=o==null?void 0:o.current)!=null&&d.has(u)&&(p[u]=o.current.get(u));if(Object.keys(p).length>0&&s(p),a.length===0)return;const c=async u=>{var g;try{if(n.getEntry){const y=await n.getEntry(u);if(y)return{title:y.title,author:y.author}}const m=await n.getItem(u);if(!m)return null;const h=m.title||u,f=m.authors,v=(g=f==null?void 0:f[0])==null?void 0:g.name;return{title:h,author:v}}catch{return null}};return Promise.all(a.map(async u=>{var m;const g=await c(u);return(m=o==null?void 0:o.current)==null||m.set(u,g),[u,g]})).then(u=>{l||s(g=>{const m={...g};for(const[h,f]of u)m[h]=f;return m})}),()=>{l=!0}},[t.join(","),n]),r}function dm({section:t,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:l,convert:a,messages:p}=G(),c=Ye(),d=Et(),u=S=>S?ot(a(S),k=>s?gn(k,s,d):k,{t:l}):"",[g,m]=x.useState(!1);x.useEffect(()=>{s&&m(!0)},[s]);const h=st(t.type),f=tm[h]||i("desc-fg"),v=!!t.content,y=t.work_ids||[],w=y.length>1,b=cm(w?y:[],o,r),j=v&&!g&&t.content.length>80?$l(t.content,80)+"……":null;return e.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[e.jsxs("div",{onClick:()=>v&&m(!g),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:v?"pointer":"default",userSelect:"none"},children:[e.jsxs(yo,{enabled:v,expanded:g,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[v&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{display:"block",flex:1},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg"),lineHeight:1.6},children:t.header_line?u(t.header_line):u(t.title)}),!g&&j&&e.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:u(j)})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&e.jsx("a",{href:c(y[0]),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),children:l("collated.arrowWork")}),w&&e.jsx("span",{style:{fontSize:"11px",color:i("link-fg"),flexShrink:0},children:l("collated.nWorks",{n:y.length})}),e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:f,border:`1px solid ${f}40`,borderRadius:"2px",background:`${f}08`},children:bo(p,h,a)})]})]}),w&&n&&e.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(S=>{const k=b[S],$=k?`${a(k.title)}${k.author?`(${a(k.author)})`:""}`:S.slice(0,8)+"…";return e.jsxs("a",{href:c(S),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),_.stopPropagation(),n(S))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:S,children:["→",$]},S)})}),g&&v&&e.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${f}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)}),t.comment&&e.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${i("widget-border")}`,fontSize:"12px",color:i("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:u(t.comment)})]})]})}function pm({juan:t,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:l}=G(),a=Et(),p=n.trim(),c=x.useMemo(()=>p?t.sections.filter(d=>xo(d,p,!0,a)):t.sections,[t.sections,p,a]);return e.jsxs("div",{children:[e.jsx("div",{children:c.map((d,u)=>e.jsx(dm,{section:d,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:p},u))}),c.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:l("collated.noMatch")})]})}function um(){let t=!1;return n=>n==="类"?(t=!0,"h2"):t?"h3":"h2"}function mm({sections:t,onNavigate:n,inline:o,workLinks:r=!0}){const s=Ye(),{t:l,convert:a}=G(),p=um();return e.jsx(e.Fragment,{children:t.map((c,d)=>{const u=st(c.type);if(u==="page_header"&&!jo(c))return null;if(u==="类")return e.jsxs(x.Fragment,{children:[x.createElement(p("类"),null,o(a(c.title))),c.content&&e.jsx("p",{children:o(a(c.content))})]},d);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const g=c.book_title?`《${c.book_title}》${c.n_juan!=null?l("collated.nJuan",{n:ho(c.n_juan)}):""}`:c.title,m=o(a(g));return e.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${d}`,children:[x.createElement(p("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},title:l("collated.viewWork"),children:m}),e.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},"aria-label":l("collated.viewWorkOf",{title:a(g)}),children:l("collated.workArrow")})]}):m),c.author_info&&e.jsx("p",{className:"bim-rd-sub",children:o(a(c.author_info))}),c.content&&c.content.split(/\n+/).map((h,f)=>e.jsx("p",{children:o(a(h))},f)),c.summary&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.summary")}),o(a(c.summary))]}),c.comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.comment")}),o(a(c.comment))]}),c.additional_comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.additionalComment")}),o(a(c.additional_comment))]})]},d)}return c.content?e.jsx("p",{children:o(a(c.content))},d):null})})}function Ol(t){return t.some(n=>{const o=st(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&jo(n)})}function gm({juan:t,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:l,onNavigate:a,transport:p,workLabelCache:c,prefs:d,view:u,onViewChange:g}){var Z;const{t:m,convert:h,messages:f}=G(),v=Et(),[y,w]=x.useState("text"),b=u??y,j=ee=>{w(ee),g==null||g(ee)},S=l.trim(),k=(s==null?void 0:s.type)==="kaozhen",$=x.useCallback(ee=>S?gn(ee,S,v):ee,[S,v]),_=ee=>mo(ee,{renderText:$,properNames:d.properNames,t:m}),z=x.useMemo(()=>S?t.sections.filter(ee=>xo(ee,S,k,v)):t.sections,[t.sections,S,k,v]),E=(ee,ce)=>ce.filter(fe=>st(fe.type)===ee).length,T=E("书",t.sections),C=E("诗",t.sections),O=E("考证",t.sections);let W="";k?W=S?m("collated.countTiaoOf",{m:E("考证",z),n:O}):m("collated.countTiao",{n:O}):C>0?W=S?m("collated.countPoemsOf",{m:E("诗",z),n:C}):m("collated.countPoems",{n:C}):T>0&&(W=S?m("collated.countBooksOf",{m:E("书",z),n:T}):m("collated.countBooks",{n:T}));const P=s!=null&&s.text_quality?Uu(s.text_quality.grade):null,Y=[];W&&Y.push(W),k&&(s!=null&&s.target_source)&&Y.push(e.jsx(e.Fragment,{children:m("collated.kaozhenTarget",{target:h(s.target_source)})})),P&&Y.push(e.jsx("span",{title:f.collated.qualityCriteria[P],children:(Z=s==null?void 0:s.text_quality)!=null&&Z.source_note?e.jsxs(e.Fragment,{children:[Yu(m("collated.baseText",{note:Wl}),s.text_quality.source_note,h),e.jsx("span",{className:"bim-rd-grade",children:f.collated.qualityLabel[P]})]}):e.jsxs(e.Fragment,{children:[m("collated.textQuality"),e.jsx("span",{className:"bim-rd-grade",children:f.collated.qualityLabel[P]})]})})),t.source_url&&Y.push(e.jsx("a",{className:"bim-rd-link",href:t.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const V=!k&&Ol(t.sections),Q=!!n&&(!V||d.readingMode==="paragraph"&&Tn(n)),ge=!k&&(V||!!n),A=k||!ge?"entries":b;let I=0;return e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[(o||r)&&e.jsxs("p",{className:"bim-rd-kicker",children:[o,o&&r&&e.jsx("span",{className:"bim-rd-dot"}),r&&h(r)]}),e.jsx("h1",{className:"bim-rd-h1",children:h(t.title)}),Y.length>0&&e.jsx("p",{className:"bim-rd-meta",children:Y.map((ee,ce)=>e.jsxs(x.Fragment,{children:[ce>0&&e.jsx("span",{className:"bim-rd-dot"}),ee]},ce))}),ge&&t.sections.length>0&&e.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":m("collated.viewsGroup"),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":A==="text",onClick:()=>j("text"),children:m("collated.viewText")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":A==="entries",onClick:()=>j("entries"),children:m("collated.viewEntries")})]})]}),A==="text"&&e.jsx("article",{className:"bim-rd-prose",children:Q?e.jsx(go,{text:n,mode:d.readingMode,properNames:d.properNames,renderText:$,dropTitle:t.title}):e.jsx(mm,{sections:t.sections,onNavigate:a,inline:_,workLinks:d.workLinks})}),A==="entries"&&e.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:k?e.jsx(pm,{juan:t,searchQuery:l,onNavigate:a,transport:p,workLabelCache:c}):e.jsxs(e.Fragment,{children:[z.some(ee=>["书","诗","考证"].includes(st(ee.type)))&&e.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[e.jsx("span",{style:{width:28},children:m("collated.rowHeadNo")}),e.jsx("span",{style:{flex:1},children:m("collated.rowHeadTitle")}),e.jsx("span",{children:m("collated.rowHeadWork")})]}),z.map((ee,ce)=>{const fe=st(ee.type);return fe==="书"||fe==="诗"||fe==="考证"?(I+=1,e.jsx(rm,{domId:`rd-e-${t.sections.indexOf(ee)}`,section:ee,onNavigate:d.workLinks?a:void 0,highlightQuery:S,no:I,showUnlinked:d.workLinks&&!!a},ce)):fe==="类"?e.jsx(sm,{section:ee,highlightQuery:S},ce):e.jsx(am,{section:ee,highlightQuery:S},ce)}),z.length===0&&e.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function hm(t){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:l,activeRawText:a,query:p,isKaozhen:c}=t,d=Et(),u=x.useRef(new Map),[g,m]=x.useState({}),[h,f]=x.useState({}),v=x.useCallback((w,b)=>{const j=b==null?void 0:b.title;j&&f(S=>S[w]===j?S:{...S,[w]:j})},[]);x.useEffect(()=>{s&&l&&(u.current.set(s,{juan:l,rawText:a}),v(s,l))},[s,l,a,v]),x.useEffect(()=>{u.current.clear(),m({}),f({})},[n]);const y=x.useCallback((w,b)=>{let j=0;if(w.juan)for(const S of w.juan.sections)xo(S,b,c,d)&&j++;return j===0&&w.rawText&&em(w.rawText,b,d)&&(j=1),j},[c,d]);return x.useEffect(()=>{const w=p.trim();if(!w){m({});return}if(!o||r.length===0)return;let b=!1;const j={},S=[];for(const E of r){const T=u.current.get(E);T?j[E]=y(T,w):(j[E]="loading",S.push(E))}m(j);const k=8;let $=0;const _=async()=>{for(;$<S.length;){if(b)return;const E=$++,T=S[E];try{const C=await o(T),O=C.juan;if(u.current.set(T,C),v(T,O),b)return;m(W=>({...W,[T]:y(C,w)}))}catch{if(b)return;m(C=>({...C,[T]:0}))}}},z=Array.from({length:Math.min(k,S.length)},()=>_());return Promise.all(z),()=>{b=!0}},[p,n,o,r.join(","),y,d,v]),{matchStates:g,titles:h}}function xm({juan:t,view:n,onView:o,textHasEntries:r}){const{t:s,convert:l}=G(),a=t.sections.map((u,g)=>({s:u,i:g,t:st(u.type)})).filter(u=>u.t==="书"||u.t==="诗");if(a.length===0)return null;const p=a.filter(u=>!!u.s.work_id).length,c=a.every(u=>u.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),d=u=>{const g=()=>{var m,h;return(h=(m=document.getElementById(`rd-e-${u}`))==null?void 0:m.scrollIntoView)==null?void 0:h.call(m,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?setTimeout(g,0):g()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-rd-rail-card",children:[e.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),e.jsxs("div",{className:"bim-rd-rail-n",children:[e.jsx("b",{children:a.length}),e.jsx("span",{children:c}),e.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:p})})]}),e.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:p,total:a.length}),children:e.jsx("span",{style:{width:`${Math.round(p/a.length*100)}%`}})})]}),e.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[e.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),e.jsx("ul",{className:"bim-rd-rail-list",children:a.map(({s:u,i:g})=>e.jsx("li",{children:e.jsxs("a",{href:`#rd-e-${g}`,onClick:m=>{m.preventDefault(),d(g)},children:[e.jsx("span",{className:`bim-rd-rail-dot${u.work_id?" on":""}`,"aria-hidden":"true"}),e.jsx("span",{children:l(u.book_title||u.title)})]})},g))})]})]})}const wr={padding:24,color:i("desc-fg"),fontSize:14};function Sr({title:t,label:n,className:o,style:r}){const s=(l,a=14,p=14)=>({width:l,height:a,marginTop:p,borderRadius:3,background:i("rule")});return e.jsxs("div",{className:o,style:{...r,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[t&&e.jsx("div",{style:{fontSize:15,color:i("ink"),fontFamily:i("font-ui")},children:t}),e.jsx("div",{style:s("42%",24,28)}),e.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((l,a)=>e.jsx("div",{style:s(l,16,a===0?30:14)},a)),e.jsx("p",{role:"status",style:{marginTop:24,color:i("desc-fg"),fontSize:14,fontFamily:i("font-ui")},children:n})]})}const $r=/^https?:\/\//i;function fm(t){if(!t||typeof t!="object")return null;const n=l=>typeof l=="string"&&l.trim()?l.trim():void 0,o=n(t.url),r=n(t.license_url),s={name:n(t.name),url:o&&$r.test(o)?o:void 0,license:n(t.license),license_url:r&&$r.test(r)?r:void 0,note:n(t.note)};return s.name||s.license||s.note?s:null}function bm(t,n){return{work_id:n.work_id??t,title:n.title,type:n.type,juan_files:n.chapters.map(o=>o.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 ym(t,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(o=>o.vol_label)?"冊":(t==null?void 0:t.kind)==="collated"?"卷":"章"}function Fl(t,n,o,r=!1){const s=o(`${n}${t.n}`);if(!t.title)return s;const l=o(t.title);return r&&!/^[卷冊册章篇回第]/.test(t.title)?`${s} ${l}`:l}function jm(t,n,o,r,s){var d;const l=new Map(t.chapters.map(u=>[u.file,u])),a=u=>u==="loading"?"…":typeof u=="number"&&u>0?u:void 0,p=(u,g)=>{const m=l.get(u);return{key:u,label:g??(m?Fl(m,o,r,s):u),hint:a(n[u]),disabled:n[u]===0}},c=(d=t.juan_groups)==null?void 0:d.filter(u=>{var g;return u.files.some(m=>l.has(m))||((g=u.children)==null?void 0:g.length)});if(c&&c.length>0){const u=(g,m)=>{var f;if(g.files.length===1&&!((f=g.children)!=null&&f.length))return p(g.files[0],r(g.label));const h=nm(g,n);return{key:`group:${m}`,label:r(g.label),hint:h==="loading"?"…":typeof h=="number"&&h>0?`${h}`:Hl(g),defaultExpanded:typeof h=="number"&&h>0,children:[...g.files.filter(v=>l.has(v)).map(v=>p(v)),...(g.children??[]).map((v,y)=>u(v,`${m}.${y}`))]}};return c.map((g,m)=>u(g,`${m}`))}return t.chapters.map(u=>p(u.file))}const vo=({id:t,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:l,title:a,subtitle:p,resolveImages:c,renderImageOverlay:d,imagePanel:u,allowVertical:g,onReportError:m,revisedAt:h,backHref:f,backLabel:v,className:y,style:w})=>{var Ve,Ae,lt;const{t:b,convert:j}=G(),S=x.useMemo(()=>Ks(n),[n]),[k,$]=il(),_=Ye(),z=x.useRef(s);z.current=s;const[E,T]=x.useState(null),[C,O]=x.useState("loading");x.useEffect(()=>{let oe=!1;return T(null),O("loading"),S.getManifest(t).then(Me=>{oe||(Me?(T(Me),O("ready")):O("missing"))}).catch(()=>{oe||O("missing")}),()=>{oe=!0}},[S,t]);const W=o!==void 0,P=r!==void 0,[Y,V]=x.useState(null),[Q,ge]=x.useState(null);x.useEffect(()=>{V(null),ge(null)},[t]);const A=xe.pickTextVersion(E,W?o:Y),I=((Ve=E==null?void 0:E.versions.find(oe=>oe.key==="default"))==null?void 0:Ve.key)??((Ae=E==null?void 0:E.versions[0])==null?void 0:Ae.key)??"default",Z=(A==null?void 0:A.key)??null,ee=P?r:Q,ce=x.useCallback((oe,Me,Xe)=>{var wt;(wt=z.current)==null||wt.call(z,{key:oe,chapter:Me,isDefault:oe===I},Xe)},[I]);x.useEffect(()=>{!E||!W||o==null||E.versions.some(oe=>oe.key===o)||ce(I,null,"auto")},[E,W,o,I,ce]);const fe=x.useRef(new Map);x.useEffect(()=>{fe.current.clear()},[S,t]);const Ie=x.useCallback(async oe=>{const Me=`${t}
|
|
1104
|
+
${oe}`;if(fe.current.has(Me))return fe.current.get(Me)??null;const Xe=await S.getIndex(t,oe).catch(()=>null);return Xe&&fe.current.set(Me,Xe),Xe},[S,t]),[q,M]=x.useState(null),[K,Re]=x.useState("loading");x.useEffect(()=>{if(!Z)return;let oe=!1;return M(null),Re("loading"),Ie(Z).then(Me=>{oe||(Me&&Me.chapters.length>0?(M(Me),Re("ready")):Re("failed"))}),()=>{oe=!0}},[Z,Ie]),x.useEffect(()=>{if(!q||!Z||ee!=null&&q.chapters.some(Xe=>Xe.file===ee))return;const Me=q.chapters[0].file;P||ge(Me),ce(Z,Me,"auto")},[q,Z,ee,P,ce]);const se=q?ee!=null&&q.chapters.some(oe=>oe.file===ee)?ee:q.chapters[0].file:ee,ye=x.useMemo(()=>q&&se?q.chapters.find(oe=>oe.file===se)??null:null,[q,se]),We=x.useRef(0),Be=x.useCallback(async oe=>{if(!E||oe===Z||!E.versions.some(fn=>fn.key===oe))return;const Me=++We.current,Xe=await Ie(oe);if(Me!==We.current)return;const wt=ye??(se?{file:se}:null),Yt=xe.matchChapterAcrossVersions(wt,Xe);W||V(oe),P||ge(Yt),ce(oe,Yt,"version")},[E,Z,Ie,ye,se,W,P,ce]),Ee=x.useCallback(oe=>{Z&&(P||ge(oe),ce(Z,oe,"chapter"))},[Z,P,ce]),[Ce,He]=x.useState(null),D=Z&&ye?`${t}
|
|
1105
|
+
${Z}
|
|
1106
|
+
${ye.file}`:null,[re,de]=x.useState(null),ke=D!==null&&re!==D,F=x.useRef(0);x.useEffect(()=>{if(!Z||!ye)return;const oe=++F.current,Me=`${t}
|
|
1107
|
+
${Z}
|
|
1108
|
+
${ye.file}`;He(null),S.getChapter(t,Z,ye.file,{json:!!ye.has_json}).then(Xe=>{oe===F.current&&He(Xe)}).catch(()=>{oe===F.current&&He(null)}).finally(()=>{oe===F.current&&de(Me)})},[S,t,Z,ye]);const he=(A==null?void 0:A.kind)==="collated",[Ne,R]=x.useState("");x.useEffect(()=>{R("")},[t,Z]);const ne=x.useMemo(()=>Z&&he?async oe=>{const Me=await S.getChapter(t,Z,oe,{json:!0});return{juan:(Me==null?void 0:Me.json)??null,rawText:(Me==null?void 0:Me.md)??null}}:null,[S,t,Z,he]),ue=(q==null?void 0:q.type)==="kaozhen",L=x.useMemo(()=>(q==null?void 0:q.chapters.map(oe=>oe.file))??[],[q]),{matchStates:te}=hm({resetKey:`${t}
|
|
1109
|
+
${Z??""}`,load:ne,files:L,activeFile:se??null,activeJuan:(Ce==null?void 0:Ce.json)??null,activeRawText:(Ce==null?void 0:Ce.md)??null,query:Ne,isKaozhen:ue}),U=x.useRef(new Map);x.useEffect(()=>{U.current.clear()},[t]);const le=Du(c,se??null),{entryTitle:we,authors:Le}=wm(t,n,a===void 0),[Se,Fe]=x.useState("text");if(x.useEffect(()=>{Fe("text")},[se,Z]),C==="loading")return e.jsx(Sr,{className:y,style:w,title:a??we,label:b("reader.loading")});if(C==="missing"||!E||!A)return e.jsx("div",{className:y,style:{...w,...wr},children:b("reader.noText")});if(K==="failed")return e.jsx("div",{className:y,style:{...w,...wr},children:b("reader.tocFailed")});if(!q)return e.jsx(Sr,{className:y,style:w,title:a??we,label:b("reader.tocLoading")});const De=ym(A,q),J=jm(q,te,De,j,he),Pe=E.versions.map(oe=>({key:oe.key,label:xe.textVersionLabel(oe),optionLabel:j(xe.textVersionLabel(oe)),sourceName:oe.source_name?j(oe.source_name):void 0,license:oe.license??void 0,sourceUrl:oe.source_url??void 0,primary:oe.key===I})),N=fm((lt=q.source)==null?void 0:lt.upstream),X=(typeof a=="string"?j(a):a)??(q.title?j(q.title):we?j(we):void 0),ae=X?e.jsx("a",{href:_(t),title:b("reader.viewEntry"),onClick:l?oe=>{oe.metaKey||oe.ctrlKey||(oe.preventDefault(),l(t))}:void 0,children:X}):void 0,ie=Le.length>0?j(Le.slice(0,2).map(oe=>`${oe.dynasty?`〔${oe.dynasty}〕`:""}${oe.name}${` ${oe.role||b("reader.defaultRole")}`}`).join("、")):void 0,pe=ye?Fl(ye,De,j,he):void 0,$e=he&&!!(Ce!=null&&Ce.json),H=(Ce==null?void 0:Ce.json)??null,B=(Ce==null?void 0:Ce.md)??null,be=$e&&!ue&&Ol(H.sections),_e=be&&!(B&&k.readingMode==="paragraph"&&Tn(B)),je=$e&&be?e.jsx(xm,{juan:H,view:Se,onView:Fe,textHasEntries:_e}):void 0,me=Vs(q)||ji(q),Oe=B?B.replace(/^##\s+[^\n]+\n+/,""):null,ze=(typeof p=="string"?j(p):p)??(A.source_name?j(A.source_name):j(xe.textVersionLabel(A)));return e.jsxs(sl,{className:y,style:w,title:ae,subtitle:ze,byline:ie,current:pe,pagerUnit:De,rail:je,revisedAt:h,backHref:f,backLabel:v,onReportError:m?oe=>m({...oe,bookTitle:typeof X=="string"?X:void 0,entryId:t}):void 0,workLinkToggle:$e&&!ue&&!!l&&!!(H!=null&&H.sections.some(oe=>oe.work_id)),toc:J,tocCaption:b("reader.tocCaption",{n:q.chapters.length,unit:j(De)}),tocHeader:he&&q.chapters.length>1?e.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:ue?b("reader.searchChaptersPlaceholder"):b("reader.searchUnitPlaceholder",{unit:j(De)}),"aria-label":ue?b("reader.searchChapters"):b("reader.searchUnit",{unit:j(De)}),value:Ne,onChange:oe=>R(oe.target.value)}):void 0,activeKey:se??null,onSelect:Ee,images:le.images,imagesLoading:le.loading,renderImageOverlay:d,imagePanel:u,prefs:k,onPrefsChange:$,versions:Pe.length>1?Pe:void 0,currentVersionKey:Pe.length>1?A.key:void 0,onVersionChange:Be,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:Tn(B),allowVertical:g,children:[ke&&e.jsx(Rt,{}),!ke&&$e&&H&&e.jsx(gm,{juan:H,rawText:B,positionLabel:vm(ye,q,De,j),groupLabel:km(q,se??null),index:bm(t,q),searchQuery:Ne,onNavigate:l,transport:n,workLabelCache:U,prefs:k,view:Se,onViewChange:Fe},`${Z}/${se}`),!ke&&!$e&&Oe!=null&&ye&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("h1",{className:"bim-rd-h1",children:ye.title?j(ye.title):pe}),(A.source_name||A.license)&&e.jsxs("p",{className:"bim-rd-meta",children:[A.source_name&&e.jsxs(e.Fragment,{children:[b("reader.textSource")," ",A.source_url?e.jsx("a",{className:"bim-rd-link",href:A.source_url,target:"_blank",rel:"noreferrer",children:j(A.source_name)}):j(A.source_name)]}),A.source_name&&A.license&&e.jsx("span",{className:"bim-rd-dot"}),A.license]}),N&&e.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[b("reader.upstream")," ",N.url?e.jsx("a",{className:"bim-rd-link",href:N.url,target:"_blank",rel:"noreferrer",children:j(N.name??N.url)}):j(N.name??""),N.license&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),N.license_url?e.jsx("a",{className:"bim-rd-link",href:N.license_url,target:"_blank",rel:"noreferrer",children:N.license}):N.license]}),N.note&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),e.jsx(qs,{text:N.note,convert:j})]})]})]}),e.jsx("article",{className:"bim-rd-prose",children:e.jsx(go,{text:Oe,mode:k.readingMode,tables:me,gujiMarkdown:ji(q),properNames:k.properNames})})]}),!ke&&!$e&&Oe==null&&ye&&e.jsx("div",{className:"bim-rd-state",children:b("reader.chapterFailed")}),q.references&&q.references.length>0&&e.jsxs("section",{className:"bim-rd-refs",children:[e.jsx("h2",{children:b("reader.references")}),e.jsx("ol",{children:q.references.map((oe,Me)=>e.jsxs("li",{children:[oe.url?e.jsx("a",{className:"bim-rd-link",href:oe.url,target:"_blank",rel:"noopener noreferrer",children:j(oe.title)}):e.jsx("span",{children:j(oe.title)}),oe.author&&e.jsxs("span",{children:[",",j(oe.author)]}),oe.note&&e.jsxs("span",{children:["。",j(oe.note)]})]},Me))})]})]})};function vm(t,n,o,r){var l,a;if(!t)return;const s=(a=(l=n.juan_metadata)==null?void 0:l[t.file])==null?void 0:a.vol_label;return r(s?`${s}冊`:`${o}${t.n}`)}function km(t,n){if(!n)return;const o=r=>{var s;for(const l of r??[]){const a=o(l.children);if(a)return a;if((s=l.files)!=null&&s.includes(n))return l.label}};return o(t.juan_groups)}function wm(t,n,o){const[r,s]=x.useState({entryTitle:void 0,authors:[]});return x.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let l=!1;return Promise.resolve(n.getItem(t)).then(a=>{if(l||!a)return;const p=(a.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof a.title=="string"?a.title:void 0,authors:p})}).catch(()=>{}),()=>{l=!0}},[t,n,o]),r}const Dl={bug:{key:"bug",color:i("danger")},resource:{key:"resource",color:i("primary")},suggestion:{key:"suggestion",color:i("primary")},other:{key:"other",color:i("desc-fg")}},Sm=Dl.other,Ul={pending:{key:"pending",color:i("warning")},in_progress:{key:"in_progress",color:i("primary")},resolved:{key:"resolved",color:i("success")},wontfix:{key:"wontfix",color:i("desc-fg")},duplicate:{key:"duplicate",color:i("desc-fg")}},$m=Ul.pending;function _m(t){try{const n=new Date(t),o=r=>String(r).padStart(2,"0");return`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())} ${o(n.getHours())}:${o(n.getMinutes())}`}catch{return t}}function Cm(t,n){if(!t)return!1;try{const o=new URL(t,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const ko=({items:t,loading:n})=>{const o=Ye(),{t:r,convert:s}=G();return n?e.jsx(Rt,{}):t.length===0?e.jsx("div",{style:zm,children:r("feedback.empty")}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:t.map(l=>{const a=Dl[l.type]||Sm,p=Ul[l.status]||$m,c=typeof window<"u"&&Cm(l.pageUrl,window.location.href);return e.jsxs("div",{style:Tm,children:[e.jsxs("div",{style:Nm,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{..._r,background:a.color},children:r(`feedback.listType.${a.key}`)}),e.jsx("span",{style:{..._r,background:p.color},children:r(`feedback.status.${p.key}`)})]}),e.jsx("span",{style:Im,children:_m(l.createdAt)})]}),(l.resourceId||l.pageUrl)&&e.jsxs("div",{style:Rm,children:[l.resourceId&&e.jsx("a",{href:o(l.resourceId),style:ci,children:l.resourceId}),l.pageUrl&&!l.resourceId&&(c?e.jsx("a",{href:l.pageUrl,style:ci,children:l.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):e.jsx("span",{style:ci,children:l.pageUrl}))]}),e.jsx("div",{style:Em,children:s(l.content)}),l.reply&&e.jsxs("div",{style:Lm,children:[e.jsx("div",{style:Pm,children:r("feedback.reply")}),e.jsx("div",{children:s(l.reply)})]})]},l.id)})})},zm={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Tm={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Nm={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},_r={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Im={fontSize:"12px",color:i("desc-fg")},Rm={fontSize:"12px",marginBottom:"6px"},ci={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},Em={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},Lm={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},Pm={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},Ii=({transport:t,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:l})=>{const a=ve(),[p,c]=x.useState(null),[d,u]=x.useState([]),[g,m]=x.useState("recommend"),[h,f]=x.useState([]),[v,y]=x.useState(!1),w=r??g,b=Y=>{m(Y),s==null||s(Y)},[j,S]=x.useState(!0),[k,$]=x.useState(null),[_,z]=x.useState(null),[E,T]=x.useState(null);x.useEffect(()=>{let Y=!1;if(t.getCounts)return t.getCounts().then(V=>{Y||c({works:V.works,books:V.books,collections:V.collections})}).catch(()=>{}),()=>{Y=!0}},[t]),x.useEffect(()=>{let Y=!1;return(async()=>{if(o)return o;if(t.getRecommended)try{const Q=await t.getRecommended();if(Q!=null&&Q.groups)return Q.groups.flatMap(ge=>ge.items.map(A=>({...A,group:ge.name})))}catch{}return[]})().then(async Q=>{if(Y)return;const ge=Q.filter(I=>I.id);if(ge.length===0){S(!1);return}const A=await Promise.all(ge.map(async I=>{if(I.type)return{id:I.id,title:I.title,type:I.type,author:I.author,dynasty:I.dynasty,role:I.role,edition:I.edition,has_text:I.has_text,has_image:I.has_image,has_collated:I.has_collated,subtype:I.subtype,primary_name:I.primary_name,group:I.group,fallbackDescription:I.description};try{let Z=null;if(t.getEntry)Z=await t.getEntry(I.id);else{const ee=await t.getItem(I.id);ee&&(Z={id:I.id,title:ee.title||I.id,type:ee.type||"work"})}if(Z)return{...Z,group:I.group,fallbackDescription:I.description}}catch{}return{id:I.id,title:I.title,type:xe.extractType(I.id),group:I.group,fallbackDescription:I.description}}));Y||(u(A.filter(I=>I!==null)),S(!1))}),()=>{Y=!0}},[t,o]);const C=x.useRef(!1),O=x.useRef(!1),W=x.useRef(!1);x.useEffect(()=>{if(w!=="catalog"||C.current)return;const Y=t.getCatalogProgress??t.getResourceProgress;if(!Y)return;C.current=!0;let V=!1;return Y.call(t).then(Q=>{V||$(Q)}).catch(()=>{C.current=!1}),()=>{V=!0}},[t,w]),x.useEffect(()=>{if(w!=="collection"||O.current||!t.getCollectionProgress)return;O.current=!0;let Y=!1;return t.getCollectionProgress().then(V=>{Y||z(V)}).catch(()=>{O.current=!1}),()=>{Y=!0}},[t,w]),x.useEffect(()=>{if(w!=="site"||W.current||!t.getSiteProgress)return;W.current=!0;let Y=!1;return t.getSiteProgress().then(V=>{Y||T(V)}).catch(()=>{W.current=!1}),()=>{Y=!0}},[t,w]),x.useEffect(()=>{if(!l||w!=="feedback")return;let Y=!1;return y(!0),fetch(l).then(V=>V.json()).then(V=>{!Y&&V.success&&f(V.items||[])}).catch(()=>{}).finally(()=>{Y||y(!1)}),()=>{Y=!0}},[l,w]);const P=Y=>e.jsx(Gt,{type:Y,size:12});return e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:e.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[e.jsx(Xt,{label:a.home.recommendTab,active:w==="recommend",onClick:()=>b("recommend")}),e.jsx(Xt,{label:a.home.catalogTab,active:w==="catalog",onClick:()=>b("catalog")}),e.jsx(Xt,{label:a.home.collectionTab,active:w==="collection",onClick:()=>b("collection")}),e.jsx(Xt,{label:a.home.siteTab,active:w==="site",onClick:()=>b("site")}),l&&e.jsx(Xt,{label:a.home.feedbackTab,active:w==="feedback",onClick:()=>b("feedback")})]}),w==="recommend"&&e.jsx(Am,{recommended:d,loading:j,onNavigate:n,getIcon:P,t:a}),w==="catalog"&&e.jsx(Cr,{progress:k,t:a,onNavigate:n}),w==="collection"&&e.jsx(Cr,{progress:_,t:a,onNavigate:n}),w==="site"&&e.jsx(Mm,{progress:E,t:a,totalWorks:(p==null?void 0:p.works)??0}),w==="feedback"&&l&&e.jsx(ko,{items:h,loading:v})]})})},Xt=({label:t,active:n,onClick:o})=>e.jsx("button",{onClick:o,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:i(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${i("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:t}),Am=({recommended:t,loading:n,onNavigate:o,getIcon:r,t:s})=>{const l=Ye();if(n)return e.jsx(Rt,{});if(t.length===0)return null;const a=new Map;for(const p of t){const c=p.group||s.home.recommendedBrowse;a.has(c)||a.set(c,[]),a.get(c).push(p)}return e.jsx(e.Fragment,{children:Array.from(a.entries()).map(([p,c])=>e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:p}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(d=>{const u=d.dynasty||d.author?`${d.dynasty?`〔${d.dynasty}〕`:""}${d.author||""}`:d.fallbackDescription;return e.jsxs("a",{href:l(d.id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),o==null||o(d.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,cursor:"pointer",background:i("input-bg"),textDecoration:"none",color:"inherit"},children:[e.jsx("span",{style:{fontSize:"20px"},children:r(d.type)}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[d.title,d.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:d.edition})]}),u&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},d.id)})})]},p))})},Cr=({progress:t,t:n,onNavigate:o})=>{if(!t)return e.jsx(Rt,{});const r=[...t.resources].sort((p,c)=>p.priority-c.priority),s=["in_progress","done","todo"],l={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},a={in_progress:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return e.jsx("div",{children:s.map(p=>{const c=r.filter(d=>d.status===p);return c.length===0?null:e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:a[p]}}),l[p]," (",c.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(d=>e.jsx(Bm,{item:d,t:n,statusColor:a[p],onNavigate:o},d.id))})]},p)})})},Bm=({item:t,t:n,statusColor:o,onNavigate:r})=>{const s=Ye(),l=t.total>0?Math.round(t.imported/t.total*100):0,a=t.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const p=t.edition?`${t.name}·${t.edition}`:t.name,c=t.collection_id||t.work_id;return c&&r?e.jsx("a",{href:s(c),onClick:d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),r(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},onMouseEnter:d=>d.currentTarget.style.borderBottomStyle="solid",onMouseLeave:d=>d.currentTarget.style.borderBottomStyle="dashed",children:p}):t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:p}):p})()}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:i("widget-border"),color:i("desc-fg"),whiteSpace:"nowrap"},children:t.collection_id?n.indexType.collection:t.work_id?n.indexType.work:a})]}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.total>0?it(n.home.progressFormat,{imported:String(t.imported),total:String(t.total)}):n.home.totalPending})]}),t.total>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${l}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},Mm=({progress:t,t:n,totalWorks:o})=>{if(!t)return e.jsx(Rt,{});const r=[...t.resources].sort((c,d)=>c.priority-d.priority),s=r.filter(c=>c.imported>0),l=r.filter(c=>c.imported===0),a=s.reduce((c,d)=>Math.max(c,d.imported),0),p=o>0?Math.round(a/o*100):0;return e.jsxs("div",{children:[o>0&&e.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${i("primary")} 6%, transparent)`,fontSize:"13px",color:i("fg")},children:[n.home.siteCoverage,": ",e.jsx("strong",{children:a.toLocaleString()})," / ",o.toLocaleString()," ",n.indexType.work," (",p,"%)"]}),s.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>e.jsx(zr,{item:c,t:n,totalWorks:o},c.id))})]}),l.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",l.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:l.map(c=>e.jsx(zr,{item:c,t:n,totalWorks:o},c.id))})]})]})},zr=({item:t,t:n,totalWorks:o})=>{const r=o>0?Math.round(t.imported/o*100):0;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:t.name}):t.name})}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.imported>0?`${t.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),t.imported>0&&o>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},Tr="(max-width: 768px)";function Wm(){const[t,n]=x.useState(()=>typeof window>"u"?!1:window.matchMedia(Tr).matches);return x.useEffect(()=>{const o=window.matchMedia(Tr),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),t}const Hm=({transport:t,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var O;const l=ve(),{convert:a}=Te(),p=Wm(),[c,d]=x.useState(null),[u,g]=x.useState(null),[m,h]=x.useState(!1),[f,v]=x.useState("detail"),[y,w]=x.useState([]),[b,j]=x.useState(!1),S=x.useCallback(async W=>{if(!t.getCollectionCatalogs&&!t.getCollectionCatalog){w([]);return}j(!0);try{if(t.getCollectionCatalogs){const P=await t.getCollectionCatalogs(W);w(P||[])}else if(t.getCollectionCatalog){const P=await t.getCollectionCatalog(W);w(P?[{resource_id:"",data:P}]:[])}}catch{w([])}finally{j(!1)}},[t]),k=x.useCallback(async W=>{if(o){o(W);return}d(W),g(null),w([]),v("detail"),h(!0);try{const P=await t.getItem(W.id);P&&(g(P),P.type==="collection"&&S(W.id))}catch(P){console.error("加载详情失败:",P)}finally{h(!1)}},[t,o,S]),$=x.useCallback(async W=>{g(null),w([]),v("detail"),h(!0);try{const P=await t.getItem(W);P&&(g(P),d({id:W,title:P.title||W,type:P.type||"book"}),P.type==="collection"&&S(W))}catch(P){console.error("导航失败:",P)}finally{h(!1)}},[t,S]),_=typeof(u==null?void 0:u.text_count)=="number"&&u.text_count>0,z=(u==null?void 0:u.type)==="collection"&&(y.length>0||b)||(u==null?void 0:u.type)==="work"&&_,E=p&&(m||u),T=x.useCallback(()=>{d(null),g(null),w([]),v("detail")},[]),C=e.jsx(e.Fragment,{children:m?e.jsx(Rt,{}):u?e.jsxs(e.Fragment,{children:[(z||s)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${i("widget-border")}`,padding:p?"0 12px":"0 48px",background:i("input-bg"),flexShrink:0,overflowX:p?"auto":void 0},children:[z&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v("detail"),style:vn(f==="detail"),children:l.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&e.jsxs("button",{onClick:()=>{},style:vn(!1),children:[l.detailTab.catalog,e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&y.map(W=>e.jsx("button",{onClick:()=>v(`catalog:${W.resource_id}`),style:vn(f===`catalog:${W.resource_id}`),children:W.short_name?`${a(W.short_name)}${l.detailTab.catalogSuffix}`:l.detailTab.collectionCatalog},W.resource_id)),u.type==="work"&&_&&e.jsx("button",{onClick:()=>v("collated"),style:vn(f==="collated"),children:l.detailTab.collatedEdition})]}),s&&e.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),e.jsx("div",{style:{padding:p?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:f==="detail"?e.jsx(Ki,{data:u,transport:t,onNavigate:$}):f.startsWith("catalog:")?e.jsx(qi,{data:(O=y.find(W=>`catalog:${W.resource_id}`===f))==null?void 0:O.data,onNavigate:$}):f==="collated"?e.jsx(vo,{id:u.id,transport:t,onNavigate:$}):null})]}):e.jsx(Ii,{transport:t,onNavigate:$,recommendedIds:r})});return p?e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:E?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:e.jsxs("button",{onClick:T,style:{padding:"4px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",l.detailTab.basicInfo]})}),e.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:C})]}):e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[e.jsx(yi,{transport:t,onEntryClick:k,hideModeIndicator:n}),!u&&e.jsx(Ii,{transport:t,onNavigate:$,recommendedIds:r})]})}):e.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:[e.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsx(yi,{transport:t,onEntryClick:k,hideModeIndicator:n})})}),e.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:C})]})};function vn(t){return{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}const Om=({data:t,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:l}=G(),[a,p]=x.useState(((u=t.divisions[0])==null?void 0:u.name)??null),[c,d]=x.useState(null);return e.jsxs("div",{className:o,style:r,children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:l(t.title)}),t.stats&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg"),display:"flex",gap:"16px"},children:[t.total_volumes!=null&&e.jsxs("span",{children:[s("catalog.totalVolumes")," ",e.jsx("strong",{children:t.total_volumes})," ",s("unit.juan")]}),t.stats.zhulu!=null&&e.jsxs("span",{children:[s("catalogPage.zhulu")," ",e.jsx("strong",{children:t.stats.zhulu})," ",s("unit.bu")]}),t.stats.cunmu!=null&&e.jsxs("span",{children:[s("catalogPage.cunmu")," ",e.jsx("strong",{children:t.stats.cunmu})," ",s("unit.bu")]}),t.stats.categories!=null&&e.jsx("span",{children:s("catalogPage.categoriesN",{n:t.stats.categories})})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.divisions.map(g=>e.jsx(Fm,{division:g,expanded:a===g.name,onToggle:()=>p(a===g.name?null:g.name),expandedCat:c,onCatToggle:m=>d(c===m?null:m),onNavigate:n},g.name))})]})},Fm=({division:t,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:l})=>{const{t:a,convert:p}=G(),c=t.categories.reduce((d,u)=>{const g=u.stats||{zhulu:0,cunmu:0};return d+(g.zhulu||0)+(g.cunmu||0)},0);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${i("primary")} 6%, transparent)`:i("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:i("fg"),textAlign:"left"},children:[e.jsx("span",{children:p(t.name)}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg")},children:[a("catalogPage.divisionStat",{cats:t.categories.length,books:c}),e.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&e.jsx("div",{style:{padding:"4px 0"},children:t.categories.map(d=>{const u=`${t.name}/${d.name}`;return e.jsx(Dm,{category:d,expanded:r===u,onToggle:()=>s(u),onNavigate:l},d.name)})})]})},Dm=({category:t,expanded:n,onToggle:o,onNavigate:r})=>{var d,u,g,m;const{t:s,convert:l}=G(),a=((d=t.books)==null?void 0:d.zhulu)||[],p=((u=t.books)==null?void 0:u.cunmu)||[],c=(((g=t.stats)==null?void 0:g.zhulu)||a.length)+(((m=t.stats)==null?void 0:m.cunmu)||p.length);return e.jsxs("div",{children:[e.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?i("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:i("fg"),textAlign:"left"},children:[e.jsxs("span",{style:{fontWeight:500},children:[l(t.name),t.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:l(t.volumes)})})]}),e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(a.length>0||p.length>0)&&e.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[a.length>0&&e.jsx(Nr,{label:s("catalogPage.zhulu"),books:a,onNavigate:r}),p.length>0&&e.jsx(Nr,{label:s("catalogPage.cunmu"),books:p,onNavigate:r})]})]})},Nr=({label:t,books:n,onNavigate:o})=>{const{t:r,convert:s}=G(),l=Ye(),[a,p]=x.useState(n.length<=20),c=a?n:n.slice(0,10);return e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[t," (",n.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((d,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[e.jsx("span",{style:{fontWeight:500,color:i("fg")},children:d.work_id&&o?e.jsx("a",{href:l(d.work_id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),o(d.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},children:s(d.title)}):s(d.title)}),d.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(d.volumes)}),d.author&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(d.author).slice(0,20)})]},u))}),!a&&e.jsx("button",{onClick:()=>p(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:r("catalogPage.expandAllN",{n:n.length})})]})},at=({title:t,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const l=ve();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:t}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&e.jsx("button",{onClick:o,style:Vm,children:"AI"}),n&&e.jsx("button",{onClick:n,style:Um,children:l.action.save})]})]}),s]})},Um={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Vm={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},nt=({label:t,value:n,onChange:o,placeholder:r,disabled:s})=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:t}),e.jsx("input",{type:"text",value:n,onChange:l=>o(l.target.value),placeholder:r,disabled:s,style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),Tt=({value:t,onChange:n,placeholder:o})=>{const r=x.useRef(null);return x.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[t]),e.jsx("textarea",{ref:r,value:t||"",onChange:s=>n(s.target.value),placeholder:o,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},In=({children:t,color:n,style:o})=>e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||i("primary-soft"),color:i(n?"on-color-fg":"fg"),...o},children:t});function Gm(t){const n=t.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Sn=({value:t,onChange:n,label:o})=>{const[r,s]=x.useState(!1),l=x.useRef(null),a=Gm(t||"");return x.useEffect(()=>{r&&l.current&&l.current.focus()},[r]),!r&&a?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Ir,children:o}),e.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${i("input-border")}`,borderRadius:"2px",background:i("input-bg"),cursor:"pointer",minHeight:"30px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:a.name}),e.jsx(In,{children:a.id})]})]}):e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Ir,children:o}),e.jsx("input",{ref:l,type:"text",value:t||"",onChange:p=>n(p.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Ir={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function Ym(t){switch(t){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function Km(t){switch(t){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Vl=({items:t,onChange:n,onOpenEntityPicker:o})=>{const r=ve(),[s,l]=x.useState(null),a=()=>{n([...t,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),l(t.length)},p=g=>{n(t.filter((m,h)=>h!==g)),s===g&&l(null)},c=(g,m,h)=>{const f=[...t];f[g]={...f[g],[m]:h},n(f)},d=(g,m)=>{const h=[...t];h[g]={...h[g],type:m,id:"",name:""},n(h),m==="bookID"&&o&&o(f=>{const v=[...t];v[g]={...v[g],id:f.id,name:f.title,type:"bookID"},n(v)})},u=g=>{o&&o(m=>{const h=[...t];h[g]={...h[g],id:m.id,name:m.title,type:"bookID"},n(h)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((g,m)=>e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>l(s===m?null:m),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:g.name||`${r.editor.sourcePlaceholder} ${m+1}`}),g.type&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Ym(g.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Km(g.type)}),e.jsx("button",{onClick:h=>{h.stopPropagation(),p(m)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===m&&e.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!g.type&&e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.editor.selectSourceType}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsxs("button",{onClick:()=>d(m,"bookID"),style:{...Rr,borderColor:i("source-bookid"),color:i("source-bookid")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"📚"}),e.jsx("span",{children:"Book ID"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.fromExistingBook})]}),e.jsxs("button",{onClick:()=>d(m,"url"),style:{...Rr,borderColor:i("source-url"),color:i("source-url")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),e.jsx("span",{children:"URL"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.enterUrl})]})]})]}),g.type==="bookID"&&e.jsx(e.Fragment,{children:e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:mt,children:r.action.selectBookOrWork}),e.jsx("button",{onClick:()=>{const h=[...t];h[m]={...h[m],type:"",id:"",name:""},n(h)},style:Er,children:r.action.changeType})]}),g.id&&g.name?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[e.jsx("span",{style:{color:i("source-bookid"),fontSize:"16px"},children:"✓"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:g.name}),e.jsx("code",{style:{fontSize:"11px",background:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:g.id})]}),e.jsx("button",{onClick:()=>u(m),style:{background:"transparent",border:`1px solid ${i("widget-border")}`,color:i("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:r.action.reselect})]}):e.jsxs("button",{onClick:()=>u(m),style:{width:"100%",padding:"14px",border:`2px dashed ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[e.jsx("span",{children:"🔍"}),e.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),g.type==="url"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:mt,children:r.label.sourceName}),e.jsx("button",{onClick:()=>{const h=[...t];h[m]={...h[m],type:"",id:"",name:""},n(h)},style:Er,children:r.action.changeType})]}),e.jsx("input",{type:"text",value:g.name,onChange:h=>c(m,"name",h.target.value),placeholder:r.editor.sourceNamePlaceholder,style:Pt})]}),e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.urlAddress}),e.jsx("input",{type:"text",value:g.id,onChange:h=>c(m,"id",h.target.value),placeholder:"https://...",style:Pt})]})]}),g.type&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:e.jsx("label",{style:{...mt,opacity:.7},children:r.label.optionalInfo})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.detailsOptional}),e.jsx("input",{type:"text",value:g.details,onChange:h=>c(m,"details",h.target.value),placeholder:r.editor.detailsPlaceholder,style:Pt})]}),e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.positionOptional}),e.jsx("input",{type:"text",value:g.position,onChange:h=>c(m,"position",h.target.value),placeholder:"如: 卷三, p.52",style:Pt})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.dataVersionOptional}),e.jsx("input",{type:"text",value:g.version,onChange:h=>c(m,"version",h.target.value),placeholder:"如: v1.0, 2024-01",style:Pt})]}),e.jsxs("div",{children:[e.jsx("label",{style:mt,children:r.label.processorVersionOptional}),e.jsx("input",{type:"text",value:g.processor_version,onChange:h=>c(m,"processor_version",h.target.value),placeholder:"如: v0.1",style:Pt})]})]})]})]})})]},m)),e.jsxs("button",{onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:r.action.addSource})]})]})},mt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},Pt={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Rr={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:i("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},Er={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Gl(t){if(!t||!t.trim())return[];try{const n=JSON.parse(t);if(Array.isArray(n))return n.map(o=>({id:o.id||"",name:o.name||"",type:o.type||"",details:o.details||"",position:o.position||"",version:o.version||"",processor_version:o.processor_version||""}))}catch{}return[]}function Yl(t){return!t||t.length===0?"":JSON.stringify(t)}const Kl=({entityType:t,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:l,belongsToCollection:a,childWorks:p,childCollections:c,containedBooks:d,siblingBooks:u,onLinkEntity:g,onUnlinkEntity:m,onViewEntity:h,onCreateAndLink:f,onSaveRelations:v})=>{const y=ve();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:y.section.relations})]}),v&&e.jsx("button",{onClick:v,style:qm,children:y.action.save})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[t==="book"&&e.jsxs(e.Fragment,{children:[e.jsx(Qt,{direction:"up",title:y.relation.belongsToWork,entity:l,onView:h,onUnlink:()=>m("workId"),onLink:()=>g("workId","work"),onCreate:()=>f("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(Qt,{direction:"up",title:y.relation.containedInCollection,entity:a,onView:h,onUnlink:()=>m("collectionId"),onLink:()=>g("collectionId","collection"),onCreate:()=>f("collectionId","collection",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),l&&u&&u.length>0&&e.jsx(At,{direction:"horizontal",title:`${y.relation.siblingVersions} (${u.length})`,entities:u,onView:h,onAdd:()=>f("siblingBook","book",{workId:l.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),t==="work"&&e.jsxs(e.Fragment,{children:[e.jsx(Qt,{direction:"up",title:y.relation.parentWork,entity:r,onView:h,onUnlink:()=>m("parentWorkId"),onLink:()=>g("parentWorkId","work"),onCreate:()=>f("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),p&&p.length>0&&e.jsx(At,{direction:"down",title:`${y.relation.childWorks} (${p.length})`,entities:p,onView:h,onAdd:()=>f("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&e.jsx(At,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:h,onAdd:()=>f("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),e.jsx(At,{direction:"down",title:`${y.relation.allVersions} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:h,onAdd:()=>f("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),t==="collection"&&e.jsxs(e.Fragment,{children:[e.jsx(Qt,{direction:"up",title:y.relation.correspondingWork,entity:l,onView:h,onUnlink:()=>m("workId"),onLink:()=>g("workId","work"),onCreate:()=>f("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(Qt,{direction:"up",title:y.relation.parentCollection,entity:s,onView:h,onUnlink:()=>m("parentCollectionId"),onLink:()=>g("parentCollectionId","collection"),onCreate:()=>f("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(At,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:h,onAdd:()=>f("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),e.jsx(At,{direction:"down",title:`${y.relation.containedBooks} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:h,onAdd:()=>f("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},Qt=({direction:t,title:n,entity:o,onView:r,onUnlink:s,onLink:l,onCreate:a,linkLabel:p,createLabel:c,notLinkedLabel:d,viewLabel:u,unlinkLabel:g})=>{const m=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),h=t==="up"?"⬆️":t==="down"?"⬇️":"↔️";return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:m,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:h}),e.jsx("span",{children:n})]}),o?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:ql(o.type)}),e.jsx("span",{style:{fontWeight:500},children:o.title}),e.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx(Lr,{onClick:()=>r(o),title:u,children:"👁️"}),e.jsx(Lr,{onClick:s,title:g,danger:!0,children:"✕"})]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:d}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsx(Ri,{onClick:l,children:p}),e.jsx(Ri,{onClick:a,primary:!0,children:c})]})]})},At=({direction:t,title:n,entities:o,onView:r,onAdd:s,addLabel:l,noneLabel:a,expandMoreLabel:p})=>{const[c,d]=x.useState(!1),u=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),g=t==="up"?"⬆️":t==="down"?"⬇️":"↔️",m=c?o:o.slice(0,5);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:g}),e.jsx("span",{children:n})]}),o.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.map(h=>e.jsxs("div",{onClick:()=>r(h),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:i("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[e.jsx("span",{children:ql(h.type)}),e.jsx("span",{children:h.title})]},h.id)),o.length>5&&!c&&e.jsxs("div",{onClick:()=>d(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[p," (",o.length-5,")"]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:a}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs(Ri,{onClick:s,primary:!0,children:["+ ",l]})})]})},Lr=({onClick:t,title:n,danger:o,children:r})=>e.jsx("button",{onClick:s=>{s.stopPropagation(),t()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),Ri=({onClick:t,primary:n,children:o})=>e.jsx("button",{onClick:t,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${i("widget-border")}`,borderRadius:"4px",background:n?i("primary"):"transparent",color:n?i("primary-fg"):"inherit",cursor:"pointer"},children:o});function ql(t){switch(t){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const qm={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Zl=({isOpen:t,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:l,searchResults:a,onSearch:p,isLoading:c,excludeId:d})=>{const[u,g]=x.useState(""),m=d?a.filter(y=>y.id!==d):a;x.useEffect(()=>{t&&(g(""),p(""))},[t]);const h=y=>{g(y),p(y)};if(!t)return null;const f=n==="work"?"作品":n==="book"?"书籍":"丛编",v=n==="work"?"📜":n==="book"?"📖":"📚";return e.jsx("div",{style:Zm,children:e.jsxs("div",{style:Jm,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),e.jsx("button",{onClick:s,style:Xm,children:"✕"})]}),e.jsx("div",{style:{padding:"12px 16px"},children:e.jsx("input",{type:"text",value:u,onChange:y=>h(y.target.value),placeholder:`搜索${f}名称或 ID...`,autoFocus:!0,style:Qm})}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?e.jsx("div",{style:di,children:"搜索中..."}):m.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>e.jsxs("div",{onClick:()=>r(y),style:eg,children:[e.jsx("span",{style:{fontSize:"16px"},children:v}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):u?e.jsxs("div",{style:di,children:["未找到匹配的",f]}):e.jsxs("div",{style:di,children:["输入关键词搜索",f]})}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsxs("button",{onClick:l,style:tg,children:["创建新",f,"并关联"]})]})]})})},Zm={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Jm={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},Xm={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Qm={width:"100%",padding:"10px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},eg={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},di={padding:"20px",textAlign:"center",color:i("desc-fg")},tg={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Pr={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},ng={work:"📜",book:"📖",collection:"📚",entity:"👤"},Jl=({isOpen:t,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:l})=>{const[a,p]=x.useState(""),c=x.useRef(null);x.useEffect(()=>{t&&(p((r==null?void 0:r.title)||""),setTimeout(()=>{var m,h;(m=c.current)==null||m.focus(),(h=c.current)==null||h.select()},100))},[t,r==null?void 0:r.title]);const d=m=>{m.key==="Enter"&&a.trim()?u():m.key==="Escape"&&l()},u=()=>{a.trim()&&s(a.trim(),{...r,title:a.trim()})};if(!t)return null;const g=()=>{switch(o){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`创建新${Pr[n]}`}};return e.jsx("div",{style:ig,onClick:m=>{m.target===m.currentTarget&&l()},children:e.jsxs("div",{style:og,onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:ng[n]}),e.jsx("span",{children:g()})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",e.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),e.jsx("input",{ref:c,type:"text",value:a,onChange:m=>p(m.target.value),onKeyDown:d,placeholder:`请输入${Pr[n]}名称...`,style:rg})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[e.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&e.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&e.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{onClick:l,style:sg,children:"取消"}),e.jsx("button",{onClick:u,disabled:!a.trim(),style:{...lg,opacity:a.trim()?1:.6,cursor:a.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},ig={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},og={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:i("shadow-dialog")},rg={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box"},sg={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},lg={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function ag(t){switch(t){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Xl(t){switch(t){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function cg(t){switch(t){case"work":return i("editor-type-work");case"collection":return i("editor-type-collection");case"book":return i("editor-type-book");default:return i("desc-fg")}}const Ql=({isOpen:t,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:l=!1,createButtonText:a,onSelect:p,onCancel:c,onCreate:d,onSearch:u})=>{const[g,m]=x.useState(""),[h,f]=x.useState([]),[v,y]=x.useState(!1),[w,b]=x.useState("recent");x.useEffect(()=>{t&&(m(""),f([]),b(r.length>0?"recent":"search"))},[t,r.length]),x.useEffect(()=>{if(!g.trim()){f([]);return}const z=setTimeout(async()=>{y(!0);try{f(await u(g,o))}catch{f([])}finally{y(!1)}},300);return()=>clearTimeout(z)},[g,o,u]);const j=x.useCallback(z=>{m(z.target.value),z.target.value.trim()&&b("search")},[]),S=x.useCallback(z=>s?z.filter(E=>E.id!==s):z,[s]);if(!t)return null;const k=n||(o==="all"?"选择实体":`选择${Xl(o)}`),$=S(r),_=S(h);return e.jsx("div",{style:pg,children:e.jsxs("div",{style:ug,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:k}),e.jsx("button",{onClick:c,style:mg,children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px 12px"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",value:g,onChange:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:gg}),e.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),v&&e.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&e.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs(Ar,{active:w==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),e.jsxs(Ar,{active:w==="search",onClick:()=>b("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:w==="recent"&&$.length>0?e.jsx(Br,{entities:$,onSelect:p}):g.trim()?v?e.jsx(pi,{message:"搜索中..."}):_.length>0?e.jsx(Br,{entities:_,onSelect:p}):e.jsx(pi,{message:"未找到匹配的结果"}):e.jsx(pi,{message:"输入关键词开始搜索"})}),l&&d&&e.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsx("button",{onClick:d,style:hg,children:a||"创建新实体"})]})]})})},Ar=({active:t,onClick:n,children:o})=>e.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:t?600:400,marginBottom:"-1px"},children:o}),Br=({entities:t,onSelect:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map(o=>e.jsx(dg,{entity:o,onClick:()=>n(o)},o.id))}),dg=({entity:t,onClick:n})=>{const[o,r]=x.useState(!1);return e.jsxs("div",{onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:i("primary-soft"),transition:"background 0.1s"},children:[e.jsx("span",{style:{fontSize:"18px"},children:ag(t.type)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[t.title,t.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:t.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[e.jsx("code",{style:{fontSize:"10px",background:i("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:t.id}),t.author&&e.jsx("span",{children:t.author}),t.dynasty&&e.jsx("span",{children:t.dynasty})]})]}),e.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:cg(t.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Xl(t.type)})]})},pi=({message:t})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:t}),pg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ug={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},mg={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},gg={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},hg={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},xg={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},fg={work:"📜",collection:"📚",book:"📖",entity:"👤"},ea=({data:t,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:l,onDelete:a,onAskAI:p,renderSectionActions:c,onDownloadResource:d,downloadStatuses:u,relations:g,onRelationsChange:m})=>{var ke;const h=ve(),[f,v]=x.useState(!1),[y,w]=x.useState("work"),[b,j]=x.useState(""),[S,k]=x.useState(""),[$,_]=x.useState([]),[z,E]=x.useState(!1),[T,C]=x.useState(!1),[O,W]=x.useState("work"),[P,Y]=x.useState(""),[V,Q]=x.useState(),[ge,A]=x.useState(!1),[I,Z]=x.useState(null),[ee,ce]=x.useState([]);x.useRef(null);const fe=t.type,Ie=fe==="work",q=fe==="collection",M=fe==="book",K=x.useCallback((F,he)=>{n({...t,[F]:he})},[t,n]),Re=x.useCallback((F,he)=>{j(F),w(he),k(h.editor.selectToLink+h.indexType[he]),_([]),v(!0)},[h]),se=x.useCallback(F=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(t.id,F)},[r,t.id]),ye=x.useCallback(F=>{s==null||s(F.id,F.type)},[s]),We=x.useCallback((F,he,Ne)=>{const R={...Ne,author:(Ne==null?void 0:Ne.author)||t.author,dynasty:Ne==null?void 0:Ne.dynasty};W(he),Y(F),Q(R),C(!0)},[t.author]),Be=x.useCallback((F,he)=>{r!=null&&r.createAndLink&&r.createAndLink(t.id,P,{type:O,title:F,inheritData:he}),C(!1)},[r,t.id,P,O]),Ee=x.useCallback(F=>{if(!F.trim()){_([]);return}E(!0),r!=null&&r.searchEntities&&r.searchEntities(F,y).then(he=>{_(he),E(!1)}).catch(()=>{_([]),E(!1)})},[r,y]),Ce=x.useCallback(F=>{r!=null&&r.linkEntity&&r.linkEntity(t.id,b,F.id),v(!1)},[r,t.id,b]),He=x.useCallback(()=>{o()},[o]),D=x.useCallback(F=>{Z(()=>F),A(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(ce).catch(()=>{})},[r]),re=x.useCallback((F,he)=>r!=null&&r.searchEntities?r.searchEntities(F,he==="all"?void 0:he):Promise.resolve([]),[r]),de=x.useCallback(F=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(F),ce(he=>[F,...he.filter(Ne=>Ne.id!==F.id)].slice(0,10)),I==null||I(F),A(!1),Z(null)},[r,I]);return e.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${i("widget-border")}`,paddingBottom:"16px"},children:e.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:fg[fe]}),e.jsx("span",{children:t.title||h.editor.untitled}),e.jsx(In,{children:t.id}),e.jsx(In,{color:xg[fe],children:h.indexType[fe]})]})}),e.jsx(at,{title:h.section.basicInfo,onSave:o,onAskAI:p?()=>p("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsx(Sn,{label:Ie?h.editor.workTitle:q?h.editor.collectionTitle:h.editor.bookTitle,value:t.title,onChange:F=>K("title",F)}),M&&e.jsx(Sn,{label:h.editor.belongsToWork,value:t.workName||"",onChange:F=>K("workName",F)}),e.jsx(nt,{label:h.editor.authorLabel,value:t.author||"",onChange:F=>K("author",F)}),e.jsx(nt,{label:h.editor.publicationYearLabel,value:t.publicationYear||"",onChange:F=>K("publicationYear",F)}),(M||q)&&e.jsx(Sn,{label:h.editor.containedIn,value:t.collection||"",onChange:F=>K("collection",F)}),(M||q)&&e.jsx(nt,{label:h.editor.holderLabel,value:t.holder||"",onChange:F=>K("holder",F)}),(M||q)&&e.jsx(nt,{label:M?h.editor.pageLabel:h.editor.volumeLabel,value:t.pages||"",onChange:F=>K("pages",F)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(nt,{label:h.editor.firstImageLabel,value:t.firstImage||"",onChange:F=>K("firstImage",F)})})]})}),e.jsx(at,{title:h.section.description,onSave:o,onAskAI:p?()=>p("介绍"):void 0,children:e.jsx(Tt,{value:t.description||"",onChange:F=>K("description",F),placeholder:h.editor.descriptionPlaceholder})}),(((ke=t.additional_works)==null?void 0:ke.length)||0)>0&&e.jsx(at,{title:h.section.additionalWorks,onSave:o,children:e.jsx(bg,{items:t.additional_works||[],onChange:F=>K("additional_works",F)})}),e.jsx(at,{title:h.section.indexedBy,onSave:o,onAskAI:p?()=>p("收录于"):void 0,children:e.jsx(yg,{items:t.indexed_by||[],onChange:F=>K("indexed_by",F)})}),e.jsx(at,{title:h.section.emendatedBy,onSave:o,onAskAI:p?()=>p("考证"):void 0,children:e.jsx(jg,{items:t.emendated_by||[],onChange:F=>K("emendated_by",F)})}),e.jsx(at,{title:h.section.textResources,onSave:o,onAskAI:p?()=>p("资源"):void 0,children:e.jsx(fi,{items:t.resources||[],onChange:F=>K("resources",F),onDownload:d,downloadStatuses:u,filterType:"text"})}),e.jsx(at,{title:h.section.imageResources,onSave:o,children:e.jsx(fi,{items:t.resources||[],onChange:F=>K("resources",F),onDownload:d,downloadStatuses:u,filterType:"image"})}),e.jsx(at,{title:h.section.sources,onSave:o,onAskAI:p?()=>p("资料来源"):void 0,children:e.jsx(Vl,{items:Gl(t.sources||""),onChange:F=>K("sources",Yl(F)),onOpenEntityPicker:D})}),(M||q)&&e.jsx(at,{title:h.section.provenance,onSave:o,onAskAI:p?()=>p("收藏历史"):void 0,children:e.jsx(Tt,{value:t.provenance||"",onChange:F=>K("provenance",F),placeholder:h.editor.provenancePlaceholder})}),M&&e.jsx(at,{title:h.section.otherEditions,onSave:o,onAskAI:p?()=>p("其他版本"):void 0,children:e.jsx(Tt,{value:t.otherEditions||"",onChange:F=>K("otherEditions",F),placeholder:h.editor.otherEditionsPlaceholder})}),e.jsx(Kl,{entityType:fe,entityId:t.id,entityTitle:t.title,parentWork:g==null?void 0:g.parentWork,parentCollection:g==null?void 0:g.parentCollection,belongsToWork:g==null?void 0:g.belongsToWork,belongsToCollection:g==null?void 0:g.belongsToCollection,childWorks:g==null?void 0:g.childWorks,childCollections:g==null?void 0:g.childCollections,containedBooks:g==null?void 0:g.containedBooks,siblingBooks:g==null?void 0:g.siblingBooks,onLinkEntity:Re,onUnlinkEntity:se,onViewEntity:ye,onCreateAndLink:We,onSaveRelations:He}),l&&a&&e.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[e.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:h.section.dangerZone}),e.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:h.editor.dangerZoneDesc}),e.jsx("button",{onClick:a,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:h.editor.deleteEntity})]}),e.jsx(Zl,{isOpen:f,entityType:y,title:S,onSelect:Ce,onCancel:()=>v(!1),onCreate:()=>{v(!1),We(b,y)},searchResults:$,onSearch:Ee,isLoading:z,excludeId:t.id}),e.jsx(Jl,{isOpen:T,entityType:O,relationField:P,inheritData:V,onConfirm:Be,onCancel:()=>C(!1)}),e.jsx(Ql,{isOpen:ge,title:h.action.selectBookOrWork,filterType:"all",recentEntities:ee,excludeId:t.id,onSelect:de,onCancel:()=>{A(!1),Z(null)},onSearch:re})]})};function bg({items:t,onChange:n}){const o=ve(),r=(a,p,c)=>{const d=t.map((u,g)=>g===a?{...u,[p]:c}:u);n(d)},s=a=>n(t.filter((p,c)=>c!==a)),l=()=>n([...t,{book_title:""}]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((a,p)=>e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(nt,{label:o.editor.bookNameLabel,value:a.book_title,onChange:c=>r(p,"book_title",c)}),e.jsx("div",{style:{width:"100px"},children:e.jsx(nt,{label:o.label.juanCount,value:a.n_juan!=null?String(a.n_juan):"",onChange:c=>r(p,"n_juan",c&&parseInt(c,10)||void 0)})}),e.jsx("button",{onClick:()=>s(p),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("muted"),marginTop:"18px"},children:"✕"})]},p)),e.jsx("button",{onClick:l,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:o.action.addAdditionalWork})]})}function ta({items:t,onChange:n,showMeta:o,addLabel:r}){const s=ve(),[l,a]=x.useState(null),p=(u,g,m)=>{const h=t.map((f,v)=>v===u?{...f,[g]:m||void 0}:f);n(h)},c=u=>{n(t.filter((g,m)=>m!==u)),l===u&&a(null)},d=()=>{n([...t,{source:""}]),a(t.length)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((u,g)=>{const m=l===g;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:m?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>a(m?null:g),children:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:m?"rotate(90deg)":"none"},children:"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),e.jsx("button",{onClick:h=>{h.stopPropagation(),c(g)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!m&&o&&(u.title_info||u.author_info)&&e.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:i("desc-fg")},children:[u.title_info,u.title_info&&u.author_info&&" — ",u.author_info]}),m&&e.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(nt,{label:s.label.sourceName,value:u.source,onChange:h=>p(g,"source",h)}),e.jsx(nt,{label:s.label.sourceBid,value:u.source_bid||"",onChange:h=>p(g,"source_bid",h)})]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(nt,{label:s.label.titleInfo,value:u.title_info||"",onChange:h=>p(g,"title_info",h)}),e.jsx(nt,{label:s.label.authorInfo,value:u.author_info||"",onChange:h=>p(g,"author_info",h)})]}),e.jsx(nt,{label:s.label.edition,value:u.edition||"",onChange:h=>p(g,"edition",h)})]}),e.jsx(Tt,{value:u.summary||"",onChange:h=>p(g,"summary",h),placeholder:s.editor.summaryPlaceholder}),e.jsx(Tt,{value:u.comment||"",onChange:h=>p(g,"comment",h),placeholder:s.editor.commentPlaceholder}),e.jsx(Tt,{value:u.additional_comment||"",onChange:h=>p(g,"additional_comment",h),placeholder:s.editor.additionalCommentPlaceholder})]})]},g)}),e.jsx("button",{onClick:d,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:r})]})}function yg({items:t,onChange:n}){const o=ve();return e.jsx(ta,{items:t,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function jg({items:t,onChange:n}){const o=ve();return e.jsx(ta,{items:t,onChange:n,addLabel:o.action.addEmendatedBy})}function na(t){var p,c,d,u,g,m,h;const n=((c=(p=t.authors)==null?void 0:p[0])==null?void 0:c.name)||"",o=((d=t.publication_info)==null?void 0:d.year)||"",r=((u=t.current_location)==null?void 0:u.name)||"",s=(g=t.page_count)!=null&&g.number?String(t.page_count.number):((m=t.page_count)==null?void 0:m.description)||"",l=typeof t.description=="object"&&t.description!==null&&t.description.text||"",a={id:t.id,title:t.title,type:t.type,author:n,publicationYear:o,holder:r,pages:s,description:l,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};if(t.type==="work"){const f=t;if(Array.isArray(f.related_works)){const v=f.related_works.find(y=>y.relation==="part_of");v&&(a.parentWorkId=v.id,a.parentWorkName=v.title)}}if(t.type==="book"){const f=t;a.workId=f.work_id,Array.isArray(f.contained_in)&&f.contained_in.length>0&&(a.collectionId=(h=f.contained_in[0])==null?void 0:h.id)}return a}function vg(t){const n={id:t.id,title:t.title,type:t.type,description:t.description?{text:t.description}:void 0,authors:t.author?[{name:t.author}]:void 0,publication_info:t.publicationYear?{year:t.publicationYear}:void 0,current_location:t.holder?{name:t.holder}:void 0,page_count:t.pages?{number:parseInt(t.pages)||0,description:t.pages}:void 0,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};return t.type==="work"&&t.parentWorkId&&(n.related_works=[{id:t.parentWorkId,title:t.parentWorkName||"",relation:"part_of"}]),t.type==="book"&&(n.work_id=t.workId,t.collectionId&&(n.contained_in=[{id:t.collectionId}])),n}const kg=t=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:l,onChange:a,onSave:p,onDelete:c,onNavigate:d,renderLink:u,onAskAI:g,renderSectionActions:m,onDownloadResource:h,downloadStatuses:f,relations:v,onRelationsChange:y,headerExtra:w,className:b,style:j}=t,S=ve(),[k,$]=x.useState(s),_=l?s:k;x.useEffect(()=>{s!==k&&$(s)},[s]);const z=x.useCallback(()=>{const Y=_==="view"?"edit":"view";l?l(Y):$(Y)},[_,l]),[E,T]=x.useState(null);x.useEffect(()=>{o&&r&&r.getItem(o).then(Y=>{Y&&T(Y)})},[o,r]);const C=n||E,O=x.useMemo(()=>C?na(C):null,[C]),W=l||!n?e.jsx("button",{onClick:z,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:_==="edit"?i("accent-bg"):"transparent",color:i(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?S.common.switchToEdit:S.common.switchToView,children:_==="view"?S.common.modeEdit:S.common.modeView}):null,P=e.jsxs(e.Fragment,{children:[W,w]});return!C&&!O?e.jsx(Rt,{}):_==="view"?e.jsx(Ki,{data:C,transport:r,onNavigate:d?Y=>d(Y):void 0,renderLink:u,headerExtra:P,className:b,style:j}):O?e.jsxs("div",{className:b,style:j,children:[P&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:P}),e.jsx(ea,{data:O,onChange:a||(()=>{}),onSave:p||(()=>{}),transport:r,onNavigate:d,showDelete:!!c,onDelete:c,onAskAI:g,renderSectionActions:m,onDownloadResource:h,downloadStatuses:f,relations:v,onRelationsChange:y})]}):e.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},wg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],ia=({isOpen:t,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=G(),[l,a]=x.useState(null),[p,c]=x.useState(""),[d,u]=x.useState(""),[g,m]=x.useState("idle"),[h,f]=x.useState(""),v=x.useRef(null);x.useEffect(()=>{t&&(a(null),c(""),u(""),m("idle"),f(""))},[t]),x.useEffect(()=>{l&&setTimeout(()=>{var b;return(b=v.current)==null?void 0:b.focus()},100)},[l]),x.useEffect(()=>{if(g==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[g,n]),x.useEffect(()=>{if(!t)return;const b=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[t,n]);const y=async()=>{if(!(!l||!p.trim())){m("submitting"),f("");try{await o({type:l,content:p.trim(),...d.trim()?{contact:d.trim()}:{}}),m("success")}catch(b){m("error"),f(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!t)return null;const w=l&&p.trim()&&g!=="submitting";return e.jsx("div",{style:Sg,onClick:b=>{b.target===b.currentTarget&&n()},children:e.jsxs("div",{style:$g,onClick:b=>b.stopPropagation(),children:[e.jsxs("div",{style:_g,children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),e.jsx("button",{onClick:n,style:Cg,"aria-label":s("feedback.close"),children:"✕"})]}),g==="success"?e.jsxs("div",{style:Rg,children:[e.jsx("span",{style:{fontSize:"32px"},children:"✓"}),e.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),r&&e.jsx("a",{href:r,style:{fontSize:"13px",color:i("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:wg.map(b=>e.jsxs("button",{onClick:()=>a(b.value),style:{...zg,...l===b.value?Tg:{}},children:[e.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),e.jsx("textarea",{ref:v,value:p,onChange:b=>c(b.target.value),placeholder:s(l?`feedback.placeholder.${l}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!l||g==="submitting",style:{...Ng,opacity:l?1:.6}}),e.jsx("input",{type:"text",value:d,onChange:b=>u(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!l||g==="submitting","aria-label":s("feedback.contactLabel"),style:Lg}),e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[p.length," / 2000"]}),g==="error"&&e.jsx("div",{style:Eg,children:h}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{onClick:y,disabled:!w,style:{...Ig,opacity:w?1:.6,cursor:w?"pointer":"not-allowed"},children:s(g==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Sg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},$g={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},_g={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Cg={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},zg={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Tg={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Ng={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},Ig={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Rg={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},Eg={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},Lg={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},Ei="--bim-feedback-fab-offset",Li=48,Pg=16,Ag=({onSubmit:t,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:l}=G(),[a,p]=x.useState(!1),c=n.bottom??24;return x.useEffect(()=>{if(r||typeof document>"u")return;const d=document.documentElement;return d.style.setProperty(Ei,`calc(${c+Li+Pg}px + env(safe-area-inset-bottom, 0px))`),()=>{d.style.removeProperty(Ei)}},[r,c]),e.jsxs(e.Fragment,{children:[!r&&e.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>p(!0),style:{...Bg,zIndex:s??i("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":l("feedback.title"),title:l("feedback.title"),children:e.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:e.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"})})}),e.jsx(ia,{isOpen:a,onClose:()=>p(!1),onSubmit:t,feedbackListUrl:o})]})},Bg={position:"fixed",width:`${Li}px`,height:`${Li}px`,borderRadius:"50%",border:"none",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:i("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},Mg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],oa=({onSubmit:t})=>{const{t:n}=G(),[o,r]=x.useState("bug"),[s,l]=x.useState(""),[a,p]=x.useState(""),[c,d]=x.useState("idle"),[u,g]=x.useState(""),m=x.useRef(null);x.useEffect(()=>{o&&setTimeout(()=>{var v;return(v=m.current)==null?void 0:v.focus()},100)},[o]);const h=async()=>{if(!(!o||!s.trim())){d("submitting"),g("");try{await t({type:o,content:s.trim(),...a.trim()?{contact:a.trim()}:{}}),d("success"),l(""),p(""),r("bug")}catch(v){d("error"),g(v instanceof Error?v.message:n("feedback.submitFailedRetry"))}}},f=o&&s.trim()&&c!=="submitting";return c==="success"?e.jsx("div",{style:Mr,children:e.jsxs("div",{style:Dg,children:[e.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),e.jsx("button",{onClick:()=>d("idle"),style:Ug,children:n("feedback.continueSubmit")})]})}):e.jsxs("div",{style:Mr,children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Mg.map(v=>e.jsxs("button",{onClick:()=>r(v.value),style:{...Wg,...o===v.value?Hg:{}},children:[e.jsx("span",{children:v.icon})," ",n(`feedback.submitType.${v.value}`)]},v.value))}),e.jsx("textarea",{ref:m,value:s,onChange:v=>l(v.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Og}}),e.jsx("input",{type:"text",value:a,onChange:v=>p(v.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:Gg}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[s.length," / 2000"]}),e.jsx("button",{onClick:h,disabled:!f,style:{...Fg,opacity:f?1:.6,cursor:f?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&e.jsx("div",{style:Vg,children:u})]})},Mr={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},Wg={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Hg={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Og={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},Fg={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Dg={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},Ug={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Vg={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},Gg={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Wr(t){return typeof t=="function"?t():t??"/api/feedback"}const ra=({resourceId:t,apiUrl:n})=>{const{t:o}=G(),[r,s]=x.useState([]),[l,a]=x.useState(!0),p=x.useCallback(async()=>{const d=Wr(n);a(!0);try{const g=await(await fetch(`${d}?resourceId=${encodeURIComponent(t)}`)).json();g.success&&s(g.items)}catch{}finally{a(!1)}},[t,n]);x.useEffect(()=>{p()},[p]);const c=async d=>{const u=Wr(n),g=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...d,pageUrl:typeof window<"u"?window.location.href:"",resourceId:t})});if(!g.ok){const m=await g.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||o("feedback.submitFailed"))}setTimeout(()=>p(),500)};return e.jsxs("div",{children:[e.jsx(ko,{items:r,loading:l}),e.jsx("div",{style:{marginTop:"24px"},children:e.jsx(oa,{onSubmit:c})})]})},Yg=En["zh-Hant"].relation,Kg=En["zh-Hant"].lossStatus,qg=En["zh-Hant"].resourceKind,Yn=Dt("zh-Hant"),wo=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function Hr(t,n=Yn){return t?wo(Yg,t)?n(`detail.relation.${t}`):t:n("detail.relation.related")}function Zg(t,n=Yn){return wo(Kg,t)?n(`detail.lossStatus.${t}`):t}function Jg(t,n=Yn){return wo(qg,t)?n(`detail.resourceKind.${t}`):""}function So({authors:t,onNavigate:n,renderLink:o}){const{convert:r}=G(),s=(t||[]).filter(l=>l&&l.name);return s.length?e.jsx(e.Fragment,{children:s.map((l,a)=>{const p=io(l.role);return e.jsxs(x.Fragment,{children:[a>0&&" ",l.dynasty&&e.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(l.dynasty),"〕"]}),l.entity_id?e.jsx(Ge,{id:l.entity_id,label:r(l.name),onNavigate:n,renderLink:o,dense:!0}):r(l.name),p&&e.jsx("span",{style:{marginLeft:4},children:r(p)})]},a)})}):null}function sa(t,n,o=Yn){var c,d;const r=to(t,n),s=r.mirrors.map(u=>({key:u.key,label:u.label,description:u.description,rows:u.items.filter(g=>g.group_role!=="mirror"),mirrors:u.items.filter(g=>g.group_role==="mirror")})),l=r.buckets.filter(u=>u.key==="image"||u.key==="textImage").flatMap(u=>u.items);l.length&&s.push({key:"_images",label:s.length?o("detail.otherImages"):void 0,rows:l,mirrors:[]});const a=((c=r.buckets.find(u=>u.key==="physical"))==null?void 0:c.items)??[];return a.length&&s.push({key:"_physical",label:o("detail.resourceKind.physical"),rows:a,mirrors:[]}),{text:((d=r.buckets.find(u=>u.key==="text"))==null?void 0:d.items)??[],groups:s}}function la(t,n){const o=(t.url?Ut(t.url):void 0)||t.name,r=cl(t,n);return r?`${o}(${r})`:o}function $o({item:t,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=G(),[l,a]=x.useState(!1),p=Ln(t),c=!!p&&p.expected>0&&!(o!=null&&o.has(p.expected)),d=s(la(t,n)),u=Vt(t),g=Fn(t,r)||t.details;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var h,f;const m=(h=t.metadata)!=null&&h.fragment||t.color_mode?e.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((f=t.metadata)==null?void 0:f.fragment)&&e.jsx("span",{className:"bim-d-tag",children:r("detail.fragmentTag")}),t.color_mode&&e.jsx("span",{className:"bim-d-tag",children:t.color_mode==="color"?r("colorMode.color"):r("colorMode.bw")})]}):null;return u?e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[d," ",e.jsx("span",{"aria-hidden":"true",children:"↗"}),m]}):e.jsxs("span",{className:"bim-d-zt-name",children:[d,m]})})(),g&&e.jsx("span",{className:"bim-d-meta",children:s(g)}),c&&l&&e.jsx("div",{style:{padding:"0 12px 10px"},children:e.jsx(ao,{item:t})})]}),e.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":l,onClick:()=>a(m=>!m),children:l?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:p.expected})})})]})}function aa({groups:t,listedVolumeCounts:n}){const{t:o,convert:r}=G();return e.jsx(e.Fragment,{children:t.map(s=>e.jsxs("div",{className:"bim-d-rg",children:[s.label&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:r(s.label)}),s.description&&e.jsx("p",{className:"bim-d-rg-d",children:r(s.description)}),s.rows.length>0&&e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:s.rows.map((l,a)=>e.jsx($o,{item:l,siblings:s.rows,listedVolumeCounts:n},`${l.id||l.url||l.name}-${a}`))})}),s.mirrors.length>0&&e.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&e.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:o("detail.mirror")}),s.mirrors.map((l,a)=>{const p=Vt(l),c=r(la(l,s.mirrors));return p?e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",title:l.details?r(l.details):void 0,children:[c," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]},a):e.jsx("span",{style:{marginRight:14},children:c},a)})]})]},s.key))})}const an=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Pi(t){var o;if(!t)return;const n=t.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=an.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const Or=12,Xg=60,ca=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:l,back:a,railLinks:p})=>{var Ee,Ce,He;const{t:c,convert:d,messages:u}=G(),g=x.useMemo(()=>[...t.books||[],...t.collections||[]],[t.books,t.collections]),[m,h]=x.useState(new Map),[f,v]=x.useState(!1),[y,w]=x.useState(""),[b,j]=x.useState(!1),S=g.length<=Xg,k=S||f||!!y||b,$=x.useMemo(()=>k?g:g.slice(0,Or),[g,k]);x.useEffect(()=>{if(!n||$.length===0)return;const D=$.filter(de=>!m.has(de));if(D.length===0)return;let re=!1;return Promise.all(D.map(de=>n.getItem(de).then(ke=>{const F=ke??{};return[de,{id:de,title:F.title,edition:F.edition,resources:F.resources,publication_info:F.publication_info,current_location:F.current_location,lineage:F.lineage,measure_info:F.measure_info}]}).catch(()=>[de,{id:de}]))).then(de=>{re||h(ke=>{const F=new Map(ke);for(const[he,Ne]of de)F.set(he,Ne);return F})}),()=>{re=!0}},[n,$,m]);const _=x.useMemo(()=>g.map(D=>m.get(D)??{id:D}),[g,m]),z=g.length>0&&g.every(D=>m.has(D)),E=!!n&&$.some(D=>!m.has(D)),T=S||k,C=x.useMemo(()=>pl(_,t.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[_,t.version_graph,y,b,T]),O=f?C.rows:C.rows.slice(0,Or),W=C.allRows.filter(D=>D.hasImage).length,P=t.related_works||[],Y=P.filter(D=>D.relation==="collected_in"),V=x.useMemo(()=>{const D=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],re=de=>{const ke=D.indexOf(de??"");return ke<0?D.length:ke};return P.filter(de=>de.relation!=="collected_in").map((de,ke)=>({r:de,i:ke})).sort((de,ke)=>re(de.r.relation)-re(ke.r.relation)||de.i-ke.i).map(de=>de.r)},[P]),Q=x.useMemo(()=>{const D=to(t.resources,t.resource_groups);return[...D.mirrors.flatMap(re=>re.items.map(de=>({r:de,kind:d(re.label)}))),...D.buckets.flatMap(re=>re.items.map(de=>({r:de,kind:d(Jg(re.key,c))})))]},[t.resources,t.resource_groups,d,c]),ge=t.indexed_by||[],A=t.emendated_by||[],I=x.useMemo(()=>{var ne,ue,L;const D=[],re=(ue=(ne=t.authors)==null?void 0:ne[0])==null?void 0:ue.dynasty;re&&D.push({label:c("workPage.fact.written"),value:d(re)});const de=bt(t,u.unit.juan);if(de){const te=(L=t.juan_count)==null?void 0:L.description;D.push({label:c("workPage.fact.measure"),value:e.jsxs(e.Fragment,{children:[d(de),te&&te!==de?e.jsxs("span",{className:"bim-d-meta",children:["(",d(te),")"]}):null]})})}t.loss_status&&D.push({label:c("workPage.fact.loss"),value:d(Zg(t.loss_status,c))});const ke=C.allRows.filter(te=>te.sortYear!=null),F=ke.length>0?ke.reduce((te,U)=>te.sortYear<=U.sortYear?te:U):null;F!=null&&F.era.era?D.push({label:c("workPage.fact.earliest"),value:d([F.era.era,F.era.reign].filter(Boolean).join(" ")),title:F.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):E&&D.push({label:c("workPage.fact.earliest"),value:e.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),A.length&&D.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:A.length})});const he=Fr(t.additional_titles);he.length&&D.push({label:c("workPage.fact.alias"),value:he.map(d).join("、")});const Ne=Fr(t.attached_texts);Ne.length&&D.push({label:c("workPage.fact.attached"),value:Ne.map(d).join("、")});const R=(t.additional_works||[]).map(te=>d(te.book_title)+(te.n_juan!=null?` ${te.n_juan}${u.unit.juan}`:""));return R.length&&D.push({label:c("workPage.fact.appendix"),value:R.join("、")}),D},[t,d,c,u,E,C.allRows,A.length]),ee=[{value:t._edition_count??g.length,label:c("workPage.stat.editions")},{value:z?W:0,label:c("workPage.stat.hasImage")},{value:ge.length,label:c("workPage.stat.catalogs")}],ce=t.classification,fe=ce?[ce.l1,ce.l2,ce.l3,ce.l4].filter(Boolean).map(D=>d(D)):[],Ie=t.subtype?u.workSubtype[t.subtype]??d(t.subtype):"",q=e.jsx(un,{title:d(t.title),byline:e.jsx(So,{authors:t.authors,onNavigate:o,renderLink:r}),meta:e.jsx(qe,{items:[...fe,ce!=null&&ce.source?c("workPage.classifiedBy",{source:d(ce.source.split("/")[0])}):"",Ie]}),description:(Ee=t.description)!=null&&Ee.text?e.jsxs(e.Fragment,{children:[e.jsx(ft,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}),(Ce=t.description.sources)!=null&&Ce.length?e.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:t.description.sources.map(D=>d(Qp(D))).filter(Boolean).join(" · ")}):null]}):void 0,stats:ee,facts:I,readAction:s,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:(He=t.appendix)==null?void 0:He.map((D,re)=>e.jsxs("details",{style:{marginTop:12},children:[e.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:d(D.title)}),e.jsx(ft,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},re))}),M=C.eras.length>=2?[{key:"",label:c("catalog.all")},...C.eras.map(D=>({key:D,label:`${D} ${C.allRows.filter(re=>re.era.era===D).length}`}))]:[],K=[];g.length&&K.push({id:"versions",label:c("workPage.sec.versions"),count:g.length}),ge.length&&K.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:ge.length}),Y.length&&K.push({id:"collected",label:c("workPage.sec.collected"),count:Y.length}),V.length&&K.push({id:"related",label:c("workPage.sec.related"),count:V.length}),Q.length&&K.push({id:"resources",label:c("workPage.sec.resources"),count:Q.length});const Re=g.length===0&&ge.length===0,se=e.jsxs(e.Fragment,{children:[g.length>0&&e.jsxs(Ze,{id:"versions",title:c("workPage.sec.versions"),meta:e.jsx(qe,{items:[c("workPage.versionsTotal",{n:g.length}),z&&W?c("workPage.versionsWithImage",{n:W}):"",C.rows.length!==C.allRows.length?c("workPage.versionsCurrent",{n:C.rows.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":E&&M.length===0&&g.length>1?"":void 0,children:[M.length>0&&e.jsx(Un,{items:M,value:y,onChange:D=>{w(D),v(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx(bl,{label:c("workPage.scanOnly"),checked:b,onChange:D=>{j(D),v(!1)}}),e.jsx("span",{className:"bim-d-meta",children:c(T?"workPage.sortByYear":"workPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!f&&Vn(C.rows.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:c("workPage.col.edition")}),e.jsx("th",{children:c("workPage.col.era")}),e.jsx("th",{children:c("workPage.col.holder")}),e.jsx("th",{children:e.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),e.jsx("tbody",{children:O.map(D=>{var re;return e.jsx(Qg,{row:D,measure:(re=m.get(D.id))==null?void 0:re.measure_info,loaded:m.has(D.id),onNavigate:o,renderLink:r},`${D.id}:${m.has(D.id)?"r":"p"}`)})})]}),O.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!f&&e.jsx(oo,{total:C.rows.length,shown:O.length,unit:c("workPage.moreUnit"),onClick:()=>v(!0)}),C.hasInferredEra&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),ge.length>0&&e.jsx(eh,{items:ge,transport:n,onNavigate:o,renderLink:r}),Re&&e.jsx(Ze,{title:c("workPage.sec.versions"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),ye=(D,re)=>e.jsx(Ge,{id:D,label:d(re),onNavigate:o,renderLink:r,dense:!0}),We=x.useMemo(()=>{const D=new Map;for(const re of V){const de=Hr(re.relation,c);D.set(de,(D.get(de)??0)+1)}return D.size>1?[...D.entries()].sort((re,de)=>de[1]-re[1]).slice(0,4).map(([re,de])=>`${d(re)} ${de}`).join(" · "):void 0},[V,d,c]),Be=e.jsxs(e.Fragment,{children:[e.jsx(zt,{id:"collected",title:c("workPage.sec.collected"),items:Y.map(D=>ye(D.id,D.title))}),e.jsx(zt,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:V.length}),sub:We,items:V.map(D=>e.jsxs(e.Fragment,{children:[ye(D.id,D.title),e.jsx("span",{className:"bim-d-meta",title:D.note?d(D.note):void 0,children:d(Hr(D.relation,c))})]}))}),e.jsx(zt,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:Q.map(({r:D,kind:re})=>{const de=d((D.url?Ut(D.url):void 0)||D.name),ke=Vt(D);return e.jsxs(e.Fragment,{children:[ke?e.jsxs("a",{href:ke,target:"_blank",rel:"noopener noreferrer",children:[de," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}):e.jsx("span",{children:de}),re&&e.jsx("span",{className:"bim-d-meta bim-d-kind",children:re})]})})})]});return e.jsx(pn,{railTop:l,back:a,nav:K,railLinks:p,main:se,card:q,side:Be})};function Fr(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Dr(t,n){return n((t.url?Ut(t.url):void 0)||t.name)}function Qg({row:t,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:l,convert:a}=G(),p=[t.era.era,t.era.reign].filter(Boolean).join(" "),c=t.era.source==="edition",d=t.holders[0],u=d?Dr(d,a):t.locationName?a(t.locationName):"",g=t.images[0],m=g?Vt(g):void 0,h=t.images.map(f=>Dr(f,a)).join("、");return e.jsxs("tr",{"data-loading":o?void 0:"",children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ge,{id:t.id,label:a(t.name),onNavigate:r,renderLink:s,dense:!0}),n?e.jsx("span",{className:"bim-d-meta",children:a(n)}):e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${p?"":" bim-d-zt-blank"}`,title:c?l("workPage.inferredFromEdition"):void 0,children:p?a(p):o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),e.jsxs("td",{className:`bim-d-zt-sub${u?"":" bim-d-zt-blank"}`,children:[u||(o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),t.holders.length>1&&e.jsxs("span",{className:"bim-d-meta",children:[" +",t.holders.length-1]})]}),e.jsx("td",{className:t.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:t.hasImage&&(m?e.jsx("a",{className:"bim-d-flag",href:m,target:"_blank",rel:"noopener noreferrer",title:h,children:l("workPage.hasImage")}):e.jsx("span",{className:"bim-d-flag",title:h,children:l("workPage.hasImage")}))})]})}function eh({items:t,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:l}=G(),[a,p]=x.useState(0),c=Math.min(a,t.length-1),d=t[c],[u,g]=x.useState(new Map);return x.useEffect(()=>{if(!n)return;const m=[...new Set(t.map(f=>f.source_bid).filter(f=>!!f))];if(m.length===0)return;let h=!1;return Promise.all(m.map(f=>n.getItem(f).then(v=>{var y,w;return[f,((w=(y=v==null?void 0:v.authors)==null?void 0:y[0])==null?void 0:w.dynasty)??""]}).catch(()=>[f,""]))).then(f=>{h||g(new Map(f.filter(([,v])=>v)))}),()=>{h=!0}},[n,t]),e.jsx(Ze,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:e.jsx(qe,{items:[s("workPage.catalog.meta",{n:t.length}),s("workPage.sortByCatalog")]}),children:e.jsxs("div",{className:"bim-d-lu",children:[e.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:t.map((m,h)=>e.jsx("li",{role:"presentation",children:e.jsxs("button",{type:"button",role:"tab","aria-selected":h===c,"aria-label":l(m.source),onClick:()=>p(h),children:[e.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(m.source_bid??"")?l(u.get(m.source_bid??"")):" "}),e.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...l(m.source)].slice(0,9).map((f,v)=>e.jsx("span",{children:f},v))})]})},h))}),e.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[d.title_info&&e.jsx("div",{className:"bim-d-lu-title",children:l(d.title_info)}),e.jsx(qe,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[d.source_bid?e.jsx(Ge,{id:d.source_bid,label:l(d.source),onNavigate:o,renderLink:r,dense:!0}):l(d.source),d.section?l(d.section):"",d.author_info?`${s("label.authorInfo")} ${l(d.author_info)}`:"",d.edition?`${s("label.edition")} ${l(d.edition)}`:"",d.page??""]}),d.summary&&e.jsx("p",{className:"bim-d-quote",children:ot(l(d.summary),void 0,{t:s})}),d.comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),e.jsx("p",{className:"bim-d-quote",children:ot(l(d.comment),void 0,{t:s})})]}),d.additional_comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),e.jsx("p",{className:"bim-d-quote",children:ot(l(d.additional_comment),void 0,{t:s})})]}),!d.summary&&!d.comment&&!d.additional_comment&&!d.title_info&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),t.length>1&&e.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:l(t[c-1].source)}),onClick:()=>p(c-1),children:e.jsxs("span",{"aria-hidden":"true",children:["← ",l(t[c-1].source)]})}):e.jsx("span",{"aria-hidden":"true"}),e.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",t.length]}),c<t.length-1?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:l(t[c+1].source)}),onClick:()=>p(c+1),children:e.jsxs("span",{"aria-hidden":"true",children:[l(t[c+1].source)," →"]})}):e.jsx("span",{"aria-hidden":"true"})]})]})]})})}function th(t){var n;return{id:t.id,kind:"hypothetical",label:t.label,year:t.year??((n=t.year_range)==null?void 0:n[0]),year_range:t.year_range,year_uncertain:t.year_uncertain,group:t.group,note:t.note,description:t.description}}function nh(t,n){if(!t.lineage)return null;const o=t.lineage;return{id:t.id,kind:"book",label:t.title,year:o.year,year_text:o.year_text,year_uncertain:o.year_uncertain,category:o.category,status:o.status,extant_juan:o.extant_juan,group:n[t.id],note:o.note}}function Ur(t,n,o){return{id:`derive:${n.ref}->${t}:${o}`,source:n.ref,target:t,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function ih(t,n,o){const[r,s]=[t,n.book_id].sort();return{id:`sibling:${r}-${s}:${o}`,source:r,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function oh(t,n){var d;if(n==="all")return null;const o=(d=t.collections)==null?void 0:d[n],r=Array.isArray(o==null?void 0:o.groups)&&o.groups.length>0,s=Array.isArray(o==null?void 0:o.book_ids)&&o.book_ids.length>0,l=r||s||!!(o!=null&&o.hypothetical_ids);if(!l&&n==="core"&&Array.isArray(t.core_books)&&t.core_books.length>0)return{books:new Set(t.core_books),hypos:t.core_hypotheticals?new Set(t.core_hypotheticals):null};if(!o||!l)return null;const a=r?new Set(o.groups):null,p=new Set(o.book_ids??[]);if(a&&t.node_groups)for(const[u,g]of Object.entries(t.node_groups))a.has(g)&&p.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),a){c||(c=new Set);for(const u of t.hypothetical_nodes??[])u.group&&a.has(u.group)&&c.add(u.id)}return{books:p,hypos:c}}function $n(t,n,o){const r=t.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const l=new Set(r.excluded_books??[]),a=r.node_groups??{},p=oh(r,o??r.default_collection??"all"),c=p!==null,d=(p==null?void 0:p.books)??null,u=(p==null?void 0:p.hypos)??null,g=new Set,m=new Set;if(c){const S=new Map(n.map(T=>[T.id,T])),k=new Map((r.hypothetical_nodes??[]).map(T=>[T.id,T])),$=T=>{const C=S.get(T);if(C&&C.lineage)return(C.lineage.derived_from??[]).map(W=>W.ref);const O=k.get(T);return O?(O.derived_from??[]).map(W=>W.ref):[]},_=T=>k.has(T)?!u||u.has(T):!d||d.has(T),z=new Set,E=T=>{if(!z.has(T)){z.add(T);for(const C of $(T))l.has(C)||(_(C)||(k.has(C)?m.add(C):S.has(C)&&g.add(C)),E(C))}};for(const T of n)d&&d.has(T.id)&&!l.has(T.id)&&E(T.id);for(const T of r.hypothetical_nodes??[])u&&u.has(T.id)&&E(T.id)}const h=n.filter(S=>!l.has(S.id)).filter(S=>!d||d.has(S.id)||g.has(S.id)).map(S=>{const k=nh(S,a);return k&&g.has(S.id)&&(k.bridge=!0),k}).filter(S=>S!==null),f=(r.hypothetical_nodes??[]).filter(S=>!u||u.has(S.id)||m.has(S.id)).map(S=>{const k=th(S);return m.has(S.id)&&(k.bridge=!0),k}),v=[...h,...f],y=new Set(v.map(S=>S.id)),w=new Set,b=[],j=S=>{w.has(S.id)||!y.has(S.source)||!y.has(S.target)||(w.add(S.id),b.push(S))};for(const S of n)l.has(S.id)||!S.lineage||d&&!d.has(S.id)&&!g.has(S.id)||((S.lineage.derived_from??[]).forEach((k,$)=>{j(Ur(S.id,k,$))}),(S.lineage.related_to??[]).forEach((k,$)=>{j(ih(S.id,k,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!m.has(S.id)||(S.derived_from??[]).forEach((k,$)=>{j(Ur(S.id,k,$))});return{nodes:v,edges:b,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(l)}}function da(t,n,o){const r=(t??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function rh(t,n){const o=[],r=t.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),l=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),a=new Set([...s,...l]),p=(c,d)=>{a.has(d.ref)||o.push(`${c}: derived_from.ref "${d.ref}" 未在 books 或 hypothetical_nodes 中找到`),d.ref_type==="book"&&!s.has(d.ref)&&o.push(`${c}: derived_from.ref "${d.ref}" 标记为 book 但不在 books 列表中`),d.ref_type==="hypothetical"&&!l.has(d.ref)&&o.push(`${c}: derived_from.ref "${d.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const d=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(u=>p(d,u)),(c.lineage.related_to??[]).forEach(u=>{s.has(u.book_id)||o.push(`${d}: related_to.book_id "${u.book_id}" 不在 books 列表中`)})}for(const c of r.hypothetical_nodes??[]){const d=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(u=>p(d,u))}return o}const pa=({graph:t,renderLink:n,className:o,style:r})=>{const{t:s,convert:l}=G();if(!t.nodes.length)return e.jsx("div",{style:{...yh,...r},className:o,children:s("lineage.emptyGraph")});const a=new Map,p=new Map;for(const h of t.edges)if(h.kind==="derive"){const f=a.get(h.target)??[];f.push(h),a.set(h.target,f)}else for(const f of[h.source,h.target]){const v=p.get(f)??[];v.push(h),p.set(f,v)}const c=new Map(t.nodes.map(h=>[h.id,h])),d=new Map,u=[];for(const h of t.nodes)if(h.group){const f=d.get(h.group)??[];f.push(h),d.set(h.group,f)}else u.push(h);const g=(h,f)=>(h.year??9999)-(f.year??9999);d.forEach(h=>h.sort(g)),u.sort(g);const m=t.groups.filter(h=>d.has(h.id));return e.jsxs("div",{className:o,style:{...lh,...r},children:[t.title&&e.jsx("div",{style:ah,children:l(t.title)}),t.description&&e.jsx("div",{style:ch,children:l(t.description)}),m.map(h=>e.jsx(Vr,{label:h.label,color:h.color,nodes:d.get(h.id),incomingMap:a,siblingMap:p,nodeMap:c,renderLink:n},h.id)),u.length>0&&e.jsx(Vr,{label:s("lineage.otherGroup"),nodes:u,incomingMap:a,siblingMap:p,nodeMap:c,renderLink:n})]})},Vr=({label:t,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:l,renderLink:a})=>{const{convert:p}=G();return e.jsxs("div",{style:dh,children:[e.jsx("div",{style:{...ph,borderLeftColor:n??i("widget-border")},children:p(t)}),o.map(c=>e.jsx(sh,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:l,renderLink:a},c.id))]})},sh=({node:t,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const l=t.kind==="hypothetical",a=t.bridge,{t:p,convert:c}=G();return e.jsxs("div",{style:{...uh,borderStyle:l||a?"dashed":"solid",opacity:a?.55:t.status==="lost"?.7:1,background:a?i("bg-subtle"):void 0},title:a?p("lineage.bridgeTitle"):void 0,children:[e.jsxs("div",{style:mh,children:[e.jsx("span",{style:gh,children:l||!s?c(t.label):s(t.id,c(t.label))}),(t.year_text||t.year!=null)&&e.jsx("span",{style:hh,children:da(c(t.year_text),t.year,t.year_uncertain)})]}),e.jsxs("div",{style:xh,children:[t.category&&e.jsx(en,{children:c(t.category)}),t.status==="lost"&&e.jsx(en,{tone:"warn",children:p("lineage.lost")}),t.status==="fragment"&&e.jsx(en,{tone:"warn",children:p("lineage.fragment")}),l&&e.jsx(en,{tone:"info",children:p("lineage.hypothetical")}),a&&e.jsx(en,{tone:"info",children:p("lineage.bridge")})]}),t.extant_juan&&e.jsx("div",{style:fh,children:p("lineage.extant",{juan:c(t.extant_juan)})}),t.note&&e.jsx("div",{style:bh,children:c(t.note)}),n.length>0&&e.jsxs("div",{style:Yr,children:[e.jsx("div",{style:Kr,children:p("lineage.sources")}),n.map(d=>{const u=r.get(d.source);return e.jsxs("div",{style:qr(d.confidence),children:[e.jsx("span",{style:Zr,children:c(d.relation)}),e.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??d.source)}),d.confidence!=="consensus"&&d.confidence!=="certain"&&e.jsx(Gr,{level:d.confidence}),d.evidence&&e.jsxs("span",{style:Jr,children:["· ",c(d.evidence)]})]},d.id)})]}),o.length>0&&e.jsxs("div",{style:Yr,children:[e.jsx("div",{style:Kr,children:p("lineage.related")}),o.map(d=>{const u=d.source===t.id?d.target:d.source,g=r.get(u);return e.jsxs("div",{style:qr(d.confidence),children:[e.jsx("span",{style:Zr,children:c(d.relation)}),e.jsx("span",{children:(g==null?void 0:g.kind)==="book"&&s?s(g.id,c(g.label)):c((g==null?void 0:g.label)??u)}),e.jsx(Gr,{level:d.confidence}),d.evidence&&e.jsxs("span",{style:Jr,children:["· ",c(d.evidence)]})]},d.id)})]})]})},en=({children:t,tone:n="default"})=>{const r={default:{bg:i("tag-bg"),fg:i("fg")},warn:{bg:i("warn-bg"),fg:i("warn-fg")},info:{bg:i("info-bg"),fg:i("info-fg")}}[n];return e.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:t})},Gr=({level:t})=>{const{t:n}=G(),r={certain:{key:"certain",color:i("confidence-certain")},consensus:{key:"consensus",color:i("confidence-consensus")},probable:{key:"probable",color:i("confidence-probable")},disputed:{key:"disputed",color:i("confidence-disputed")}}[t];return r?e.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${r.color}`,color:r.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${r.key}`)}):null},lh={fontSize:"14px",color:i("fg")},ah={fontSize:"16px",fontWeight:600,marginBottom:"8px"},ch={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},dh={marginBottom:"16px"},ph={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},uh={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},mh={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},gh={fontSize:"15px",fontWeight:600},hh={fontSize:"12px",color:i("muted")},xh={marginBottom:"6px"},fh={fontSize:"12px",color:i("muted"),margin:"2px 0"},bh={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},Yr={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},Kr={fontSize:"11px",color:i("muted"),marginBottom:"2px"},qr=t=>({fontSize:"12px",margin:"2px 0",opacity:t==="probable"||t==="disputed"?.85:1}),Zr={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},Jr={fontSize:"11px",color:i("muted")},yh={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},ua=({selectedNodeId:t,...n})=>{const{t:o}=G(),[r,s]=x.useState("loading"),[l,a]=x.useState(null);return x.useEffect(()=>{let p=!1;return jh().then(c=>{p||(c?(a(c),s("ready")):s("missing"))}),()=>{p=!0}},[]),r==="loading"?e.jsx("div",{style:Qr,children:o("lineage.graphLoading")}):r==="missing"||!l?e.jsxs("div",{style:Qr,children:[e.jsx("div",{children:Xr(o("lineage.graphMissing"),{xyflow:e.jsx("code",{children:"@xyflow/react"}),dagre:e.jsx("code",{children:"@dagrejs/dagre"})})}),e.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:Xr(o("lineage.graphMissingHint"),{list:e.jsx("code",{children:"VersionLineageList"})})})]}):e.jsx(vh,{modules:l,selectedNodeId:t,...n})};function Xr(t,n){return t.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return e.jsx(x.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function jh(){try{const[t,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let o=!1;try{await import("@xyflow/react/dist/style.css"),o=!0}catch{o=!1}return{ReactFlow:t.ReactFlow,Background:t.Background,Controls:t.Controls,Handle:t.Handle,Position:t.Position,BaseEdge:t.BaseEdge,EdgeLabelRenderer:t.EdgeLabelRenderer,getSmoothStepPath:t.getSmoothStepPath,dagre:n,cssLoaded:o}}catch{return null}}const vh=({graph:t,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:l,modules:a})=>{const{ReactFlow:p,Background:c,Controls:d,Handle:u,Position:g,BaseEdge:m,EdgeLabelRenderer:h,getSmoothStepPath:f,dagre:v}=a,y=x.useMemo(()=>({lineage:$=>{var V,Q,ge,A;const _=((V=$.data)==null?void 0:V.stepPosition)??.85,[z,E,T]=f({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),C=!!((Q=$.data)!=null&&Q.isSibling),O=C?E:$.targetX-18,W=C?T:$.targetY-12,P=(ge=$.data)==null?void 0:ge.labelStyle,Y=(A=$.data)==null?void 0:A.labelBgStyle;return e.jsxs(e.Fragment,{children:[e.jsx(m,{id:$.id,path:z,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&e.jsx(h,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${O}px,${W}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...Y,...P},children:$.label})})]})}}),[m,h,f]),w=x.useMemo(()=>({version:$=>{const{t:_}=G(),z=$.data,E=z.kind==="hypothetical",T=z.status==="lost",C=z.isSelected,O=z.bridge,W=z.borderColor??i("muted"),P=O||E?"dashed":"solid",Y=O?.5:T?.6:1;return e.jsxs("div",{style:{background:i(O?"bg-subtle":"bg"),border:`2px ${P} ${C?i("primary"):W}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:Y,boxShadow:C?i("shadow-node-selected"):E||O?"none":i("shadow-node")},title:O?_("lineage.bridgeTitle"):void 0,children:[e.jsx(u,{type:"target",position:g.Left,style:{visibility:"hidden"}}),e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:E||!z.renderLink?z.label:z.renderLink(z.bookId,z.label)}),z.description&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:z.description}),z.yearText&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:da(z.yearText,void 0,z.uncertain)}),T&&e.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:_("lineage.lost")}),e.jsx(u,{type:"source",position:g.Right,style:{visibility:"hidden"}})]})}}),[u,g]),{convert:b}=G(),{rfNodes:j,rfEdges:S}=x.useMemo(()=>kh(t,v,n,l,b),[t,v,n,l,b]);return e.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:e.jsxs(p,{nodes:j,edges:S,nodeTypes:w,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[e.jsx(c,{gap:16}),e.jsx(d,{showInteractive:!1})]})})};function kh(t,n,o,r,s=l=>l??""){const p=t.layout==="LR"||!t.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:p?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const d=new Map(t.groups.map(w=>[w.id,w.color??i("muted")]));for(const w of t.nodes)c.setNode(w.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const w of t.edges)w.kind==="derive"&&(u.has(w.relation)||c.setEdge(w.source,w.target));n.layout(c);const g=t.nodes.map(w=>{const b=c.node(w.id),j=r?w.id===r:void 0,S={kind:w.kind,label:s(w.label),bookId:w.kind==="book"?w.id:void 0,yearText:s(w.year_text??Sh(w)),uncertain:w.year_uncertain,category:w.category,status:w.status,borderColor:w.group?d.get(w.group):void 0,renderLink:o,isSelected:j,description:s(w.description),bridge:w.bridge};return{id:w.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:S,draggable:!1,selected:j}}),m=.78,h=.06,f=new Map;for(const w of t.edges)w.kind==="derive"&&(f.has(w.source)||f.set(w.source,[]),f.get(w.source).push(w));const v=new Map;for(const[w,b]of f){if(b.length<=1)continue;const j=[...b].sort((k,$)=>{var E,T;const _=((E=c.node(k.target))==null?void 0:E.y)??0,z=((T=c.node($.target))==null?void 0:T.y)??0;return _-z}),S=j.length;j.forEach((k,$)=>{const _=($-(S-1)/2)*h;v.set(k.id,m+_)})}const y=t.edges.map(w=>wh(w,v.get(w.id),s));return{rfNodes:g,rfEdges:y}}function wh(t,n,o=r=>r??""){const r=t.confidence==="probable"||t.confidence==="disputed",s=t.kind==="sibling",l=$h(t.confidence),a={type:"arrowclosed",color:l,width:14,height:14};return{id:t.id,source:t.source,target:t.target,type:"lineage",label:o(t.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:l,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:a,markerStart:s?a:void 0,zIndex:1e3}}function Sh(t){if(t.year_range)return`~${t.year_range[0]}–${t.year_range[1]}`;if(typeof t.year=="number")return String(t.year)}function $h(t){switch(t){case"certain":return i("confidence-certain");case"consensus":return i("lineage-edge-consensus");case"probable":return i("confidence-probable");case"disputed":return i("confidence-disputed");default:return i("muted")}}const Qr={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},_o=({graph:t,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:l,collection:a,onCollectionChange:p,collectionsAvailable:c,collectionCounts:d,className:u,style:g})=>{var S;const{t:m,convert:h}=G(),[f,v]=x.useState(n),y=k=>{v(k),l==null||l(k)},w=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(p&&w.length>0);if(!t.nodes.length)return e.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:m("lineage.empty")});const j=a?(S=c==null?void 0:c[a])==null?void 0:S.description:void 0;return e.jsxs("div",{className:u,style:g,children:[e.jsxs("div",{style:_h,children:[e.jsx("button",{onClick:()=>y("list"),style:ui(f==="list"),children:m("lineage.modeList")}),e.jsx("button",{onClick:()=>y("graph"),style:ui(f==="graph"),children:m("lineage.modeGraph")}),b&&e.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:12,color:i("muted"),marginRight:4},children:m("lineage.collectionLabel")}),w.map(([k,$])=>{const _=d==null?void 0:d[k];return e.jsxs("button",{onClick:()=>p==null?void 0:p(k),style:ui(a===k),title:$.description?h($.description):void 0,children:[h($.label),_!=null?` ${_}`:""]},k)})]})]}),b&&j&&e.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:h(j)}),f==="list"?e.jsx(pa,{graph:t,renderLink:o}):e.jsx(ua,{graph:t,renderLink:o,height:r,selectedNodeId:s})]})},_h={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},ui=t=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:t?i("primary"):"transparent",color:i(t?"primary-fg":"fg"),cursor:"pointer"}),es=40,ts=2,Ch=9,zh=new Set(["certain","consensus","probable","disputed"]);function mi(t){if(!t)return["",""];const n=t.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",t]}const ma=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:l,fullTextPending:a,chapterLink:p,railTop:c,back:d,railLinks:u})=>{var L,te,U,le,we,Le,Se,Fe,De,J,Pe;const g=ve(),{t:m,convert:h}=G(),[f,v]=x.useState(null),[y,w]=x.useState(new Map),[b,j]=x.useState([]),[S,k]=x.useState(new Map),[$,_]=x.useState(!1),[z,E]=x.useState("flow"),[T,C]=x.useState(null);x.useEffect(()=>{if(!n||!t.work_id){v(null);return}let N=!1;return n.getItem(t.work_id).then(X=>{!N&&X&&X.type==="work"&&v(X)}).catch(()=>{}),()=>{N=!0}},[n,t.work_id]),x.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!t.work_id){C(null);return}let N=!1;return n.getLineageGraph(t.work_id).then(X=>{N||C(X&&X.nodes.length>1?X:null)}).catch(()=>{N||C(null)}),()=>{N=!0}},[n,t.work_id]),x.useEffect(()=>{const N=t.contained_in||[];if(!n||N.length===0){w(new Map);return}let X=!1;return Promise.all(N.map(ae=>{const ie=typeof ae=="string"?ae:ae.id;return n.getItem(ie).then(pe=>[ie,pe]).catch(()=>[ie,null])})).then(ae=>{if(X)return;const ie=new Map;for(const[pe,$e]of ae)$e&&ie.set(pe,$e);w(ie)}),()=>{X=!0}},[n,t.contained_in]);const O=x.useMemo(()=>{const N=new Set([...(f==null?void 0:f.books)||[],...t.related_books||[]]);return N.add(t.id),[...N]},[f==null?void 0:f.books,t.related_books,t.id]),W=O.length-1;x.useEffect(()=>{if(!n||W<=0){j([]);return}const N=O.length<=es,X=N?O:O.slice(0,8);let ae=!1;return Promise.all(X.map(ie=>ie===t.id?Promise.resolve({id:ie,title:t.title,edition:t.edition,year:zn(t)}):n.getItem(ie).then(pe=>{const $e=pe??{};return{id:ie,title:$e.title,edition:$e.edition,year:pe?zn($e):void 0}}).catch(()=>({id:ie})))).then(ie=>{if(ae)return;const pe=ie.filter($e=>$e.id===t.id||$e.title||$e.edition);N&&pe.sort(($e,H)=>($e.year??1/0)-(H.year??1/0)),j(pe)}),()=>{ae=!0}},[n,O,W,t]);const P=t.lineage,Y=x.useMemo(()=>[...((P==null?void 0:P.derived_from)||[]).filter(N=>N.ref_type==="book").map(N=>N.ref),...((P==null?void 0:P.related_to)||[]).map(N=>N.book_id)].filter(Boolean),[P]);x.useEffect(()=>{if(!n||Y.length===0){k(new Map);return}let N=!1;return Promise.all(Y.map(X=>n.getItem(X).then(ae=>[X,{id:X,title:ae==null?void 0:ae.title,edition:ae==null?void 0:ae.edition}]).catch(()=>[X,{id:X}]))).then(X=>{N||k(new Map(X))}),()=>{N=!0}},[n,Y]);const V=x.useMemo(()=>sa(t.resources,t.resource_groups,m),[t.resources,t.resource_groups,m]),Q=V.groups.reduce((N,X)=>N+X.rows.length+X.mirrors.length,0),ge=V.groups.length>0&&V.groups.every(N=>N.key==="_physical"),A=dn(t),I=xl(t),Z=bt(t,g.unit.juan),ee=new Set((t.contained_in||[]).map(N=>typeof N=="string"?0:sn(N.volume_index).length).filter(N=>N>0)),ce=N=>{var ie;const X=(ie=t.base_edition)==null?void 0:ie.find(pe=>pe.book_id===N&&pe.name);if(X!=null&&X.name)return X.name;const ae=S.get(N);return(ae==null?void 0:ae.edition)||(ae==null?void 0:ae.title)||""},fe=x.useMemo(()=>{var be,_e,je,me,Oe;const N=[];I&&N.push({label:m("bookPage.fact.editionType"),value:h(I),title:t.edition_type||(be=t.lineage)!=null&&be.category?void 0:m("bookPage.inferredFromEdition")}),(_e=t.publication_info)!=null&&_e.details?N.push({label:m("bookPage.fact.publication"),value:h(t.publication_info.details)}):(A.era||A.reign)&&N.push({label:m("bookPage.fact.era"),value:h([A.era,A.reign].filter(Boolean).join(" ")),title:A.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),Z&&N.push({label:m("bookPage.fact.measure"),value:h(Z)});const X=(t.contained_in||[]).flatMap(ze=>typeof ze=="string"?[]:sn(ze.volume_index));X.length&&N.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Dn(X,g.unit.volume),unit:g.unit.volume,n:X.length})});const ae=(((je=t.lineage)==null?void 0:je.derived_from)||[]).find(ze=>ze.relation==="底本"&&ze.ref_type==="book");ae&&ce(ae.ref)&&N.push({label:m("bookPage.fact.baseEdition"),value:e.jsx(Ge,{id:ae.ref,label:h(ce(ae.ref)),onNavigate:o,renderLink:r,dense:!0})});const ie=(t.base_edition||[]).filter(ze=>ze&&ze.name);for(const ze of["底本","配補","參校"]){if(ze==="底本"&&ae&&ce(ae.ref))continue;const Ve=ie.filter(Ae=>Ae.role===ze);Ve.length&&N.push({label:h(ze),value:Ve.map((Ae,lt)=>e.jsxs(x.Fragment,{children:[lt>0&&"、",Ae.book_id?e.jsx(Ge,{id:Ae.book_id,label:h(Ae.name),onNavigate:o,renderLink:r,dense:!0}):h(Ae.name)]},lt))})}const pe=(t.provenance||[]).filter(ze=>ze&&ze.institution),$e=(t.resources||[]).filter(ze=>(ze.types||(ze.type?[ze.type]:[])).includes("physical"));if(pe.length){N.push({label:m("bookPage.fact.holdings"),value:pe.slice(0,2).map(Ae=>h(Ae.institution)).join("、")+(pe.length>2?m("bookPage.andMorePlaces",{n:pe.length}):"")});const ze=pe.filter(Ae=>Ae.call_number).slice(0,2).map(Ae=>`${h(Ae.institution)} ${Ae.call_number}`);ze.length&&N.push({label:m("bookPage.fact.callNumber"),value:ze.join(";")+(pe.filter(Ae=>Ae.call_number).length>2?"…":"")});const Ve=pe.flatMap(Ae=>Ae.seals||[]).filter(Boolean);Ve.length&&N.push({label:m("bookPage.fact.seals"),value:h(Ve.join("、"))})}else $e.length?N.push({label:m("bookPage.fact.holdings"),value:$e.slice(0,2).map(ze=>h(ze.name)).join("、")+($e.length>2?m("bookPage.andMorePlaces",{n:$e.length}):"")}):(me=t.current_location)!=null&&me.name&&N.push({label:m("bookPage.fact.holdings"),value:h(t.current_location.name)});const H=t.physical_description;if(H){const ze=[[m("bookPage.fact.leafStyle"),H.leaf_style],[m("bookPage.fact.binding"),H.binding],[m("bookPage.fact.dimensions"),H.dimensions],[m("bookPage.fact.condition"),H.condition]];for(const[Ve,Ae]of ze)Ae&&Ae.trim()&&N.push({label:Ve,value:h(Ae)})}(Oe=t.page_count)!=null&&Oe.description&&N.push({label:g.label.pageCount,value:h(t.page_count.description)});const B=[...Ni(t.additional_titles),...Ni(t.attached_texts)];return B.length&&N.push({label:m("bookPage.fact.aliases"),value:B.map(h).join("、")}),N},[t,h,g,m,A,I,Z,S,o,r]),Ie=h(t.title),q=t.edition?h(t.edition):void 0,M=((L=t.lineage)==null?void 0:L.year_text)||"",K=e.jsx(un,{kind:m("bookPage.kind"),title:Ie,subtitle:q,byline:e.jsx(So,{authors:t.authors??(f==null?void 0:f.authors),onNavigate:o,renderLink:r}),meta:(()=>{const N=[I?h(I):"",A.era?h([A.era,A.reign].filter(Boolean).join("")):"",Z?h(Z):""].filter(Boolean);return N.length?e.jsx("span",{className:"bim-d-tags",children:N.map((X,ae)=>e.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(ae,2)}`,children:X},ae))}):null})(),description:(te=t.description)!=null&&te.text?e.jsx(ft,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:so((U=t.description)==null?void 0:U.text)?6:void 0,facts:fe,readAction:s,secondaryAction:s&&Q>0&&!ge?e.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo})}),Re=t.contained_in||[],se=(l==null?void 0:l.chapters)||[],ye=h(se[0]&&mi(se[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),We=m("bookPage.chapterCount",{n:se.length,unit:ye}),Be=!!((le=P==null?void 0:P.derived_from)!=null&&le.length||(we=P==null?void 0:P.related_to)!=null&&we.length||(Le=t.appendix)!=null&&Le.length),Ee=[],Ce=m(ge?"bookPage.sec.physical":"bookPage.sec.images");(se.length||V.text.length||a)&&Ee.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:se.length?We:void 0}),V.groups.length&&Ee.push({id:"images",label:Ce,count:Q}),Be&&Ee.push({id:"lineage",label:m("bookPage.sec.lineage")}),Re.length&&Ee.push({id:"collections",label:m("section.containedIn"),count:Re.length}),(Se=t.location_history)!=null&&Se.length&&Ee.push({id:"provenance",label:m("section.locationHistory")});const He=N=>(p==null?void 0:p(N))??null,D=se[0],re=D?He(D.file):null,de=$?se:se.slice(0,Ch),ke=(N,X,ae)=>N?e.jsx("a",{className:ae,href:N.href??"#",onClick:N.onClick?ie=>{ie.metaKey||ie.ctrlKey||(ie.preventDefault(),N.onClick())}:void 0,children:X}):e.jsx("span",{className:ae,children:X}),F=e.jsxs(e.Fragment,{children:[(se.length>0||V.text.length>0||a)&&e.jsxs(Ze,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:se.length>0?e.jsx(qe,{items:[We,(Fe=l==null?void 0:l.source)!=null&&Fe.name?m("bookPage.sourceBy",{src:h(`${l.source.name}${l.source.license?` ${l.source.license}`:""}`)}):""]}):void 0,children:[a&&!D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[e.jsx("span",{className:"bim-d-ft-h",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "})]}),e.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),D&&e.jsxs("div",{className:"bim-d-ft",children:[e.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:h(mi(D.title)[0])||m("bookPage.firstChapter")})}),e.jsx("span",{className:"bim-d-meta",children:h((D.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),ke(re,e.jsxs(e.Fragment,{children:[m("bookPage.enterReader")," ",e.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),se.length>1&&e.jsx("ul",{className:"bim-d-chap",children:de.map(N=>{const[X,ae]=mi(N.title);return e.jsx("li",{children:ke(He(N.file),e.jsxs(e.Fragment,{children:[X&&e.jsx("b",{children:h(X)}),h(ae||N.file)]}))},N.file)})}),se.length>de.length&&e.jsx(ro,{label:m("detail.expandRest",{n:se.length-de.length,unit:ye}),onClick:()=>_(!0)}),V.text.length>0&&e.jsxs(e.Fragment,{children:[(se.length>0||a)&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:V.text.map((N,X)=>e.jsx($o,{item:N,siblings:V.text,listedVolumeCounts:ee},`${N.id||N.url||N.name}-${X}`))})})]})]}),V.groups.length>0&&e.jsx(Ze,{id:"images",title:Ce,meta:e.jsx(qe,{items:[V.groups.length>1?m("bookPage.groupCount",{n:V.groups.length}):"",m("bookPage.placeCount",{n:Q})]}),children:e.jsx(aa,{groups:V.groups,listedVolumeCounts:ee})}),Be&&e.jsx(Ze,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(De=P==null?void 0:P.derived_from)!=null&&De.length?m("bookPage.lineageMeta"):void 0,action:T?e.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[e.jsx("button",{type:"button","aria-pressed":z==="flow",onClick:()=>E("flow"),children:m("bookPage.viewCards")}),e.jsx("button",{type:"button","aria-pressed":z==="graph",onClick:()=>E("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:z==="graph"&&T?e.jsx(_o,{graph:T,defaultMode:"graph",selectedNodeId:t.id,graphHeight:480,renderLink:(N,X)=>e.jsx(Ge,{id:N,label:h(X),onNavigate:o,renderLink:r,dense:!0})}):e.jsx(Nh,{data:t,heading:q||Ie,yearText:M,refName:ce,onNavigate:o,renderLink:r})}),Re.length>0&&e.jsx(Ze,{id:"collections",title:m("section.containedIn"),children:e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:Re.map((N,X)=>{var H,B;const ae=typeof N=="string"?N:N.id,ie=typeof N=="string"?[]:sn(N.volume_index),pe=y.get(ae),$e=(pe==null?void 0:pe._member_count)||((H=pe==null?void 0:pe.books)==null?void 0:H.length)||((B=pe==null?void 0:pe.contained_works)==null?void 0:B.length)||0;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ge,{id:ae,label:pe?h(pe.title):ae,onNavigate:o,renderLink:r,dense:!0}),ie.length>0&&e.jsx(Th,{volumes:ie,unit:g.unit.volume})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${$e?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:$e>0&&m("bookPage.totalOf",{n:$e,unit:g.unit.bu})})]},`${ae}-${X}`)})})})}),(J=t.location_history)!=null&&J.length?e.jsx(Ze,{id:"provenance",title:m("section.locationHistory"),children:e.jsx("ul",{className:"bim-d-tl",children:t.location_history.map((N,X)=>e.jsxs("li",{children:[e.jsx("span",{className:"bim-d-tl-t",children:h(N.name)}),([N.start_date,N.end_date].filter(Boolean).join("—")||N.description)&&e.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:e.jsx(qe,{items:[[N.start_date,N.end_date].filter(Boolean).join("—"),N.description?h(N.description):""]})})]},X))})}):null,Ee.length===0&&e.jsx(Ze,{title:m("bookPage.sec.empty"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),he=b.findIndex(N=>N.id===t.id),Ne=O.length<=es,R=Ne&&he>=0?b.slice(Math.max(0,he-ts),he+ts+1):b.filter(N=>N.id!==t.id),ne=e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[e.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:h(g.section.belongsToWork)}),e.jsx("div",{style:{fontSize:17,fontWeight:500},children:e.jsx(Ge,{id:f.id,label:h(f.title),onNavigate:o,renderLink:r})}),e.jsx(qe,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(f.authors||[]).slice(0,2).map(N=>`${N.dynasty?`〔${h(N.dynasty)}〕`:""}${h(N.name)}`),h(bt(f,g.unit.juan)),f._edition_count?m("bookPage.editionCount",{n:f._edition_count}):""]}),((Pe=f.description)==null?void 0:Pe.text)&&e.jsx("p",{style:{margin:"8px 0 0",fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc",children:h(f.description.text.replace(/[#*_>`[\]]/g,""))})]}),W>0&&R.length>0&&e.jsxs("div",{children:[e.jsx(zt,{id:"siblings",timeline:!0,title:Ne?m("bookPage.siblings"):g.relation.siblingVersions,meta:Ne?m("bookPage.byEra"):m("bookPage.kindCount",{n:W}),cap:R.length,items:R.map(N=>N.id===t.id?e.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:h(N.edition||N.title||N.id)}):e.jsx(Ge,{id:N.id,label:h(N.edition||N.title||N.id),onNavigate:o,renderLink:r,dense:!0})),metas:R.map(N=>[N.year!=null?N.year<0?m("detail.bce",{n:-N.year}):String(N.year):"",N.id===t.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:R.findIndex(N=>N.id===t.id)}),f&&e.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:e.jsx(Ge,{id:f.id,label:m("bookPage.viewAllInWork",{n:O.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),ue=t.work_id?e.jsx(fl,{caption:g.section.belongsToWork,children:e.jsx(Ge,{id:t.work_id,label:f?h(f.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return e.jsx(pn,{railTop:c,back:d,up:ue,nav:Ee,railLinks:u,main:F,card:K,side:ne})};function Th({volumes:t,unit:n}){const{t:o}=G();return e.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:Dn(t,n),unit:n}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-d-dot"}),o("bookPage.volumeCount",{n:t.length,unit:n})]})]})}function Nh({data:t,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:l}){var w;const{t:a,convert:p}=G(),c=t.lineage,d=(c==null?void 0:c.derived_from)||[],u=d.filter(b=>b.ref_type!=="book"),g=d.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=d.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),h=(c==null?void 0:c.related_to)||[],f=d.length>0||h.length>0,v=b=>b&&zh.has(b)?a("bookPage.confidenceNote",{c:a(`bookPage.confidence.${b}`)}):"",y=(b,j)=>e.jsx(Ge,{id:b,label:p(j||b),onNavigate:s,renderLink:l,dense:!0});return e.jsxs("div",{className:"bim-d-lf",children:[f&&e.jsxs("ol",{className:"bim-d-lf-list",children:[u.map((b,j)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?p(b.relation):a("bookPage.lineage.ancestor")}),e.jsx("span",{className:"bim-d-lf-name",children:a("bookPage.lineage.reconstructed")}),b.evidence&&e.jsxs("span",{className:"bim-d-meta",children:[p(b.evidence),v(b.confidence)]})]})},`a-${j}`)),g.map((b,j)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-card",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:p(b.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[p(b.evidence),v(b.confidence)]})]})},`b-${j}`)),e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[e.jsxs("div",{className:"bim-d-lf-here",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:a("bookPage.lineage.thisEdition")}),e.jsx("span",{className:"bim-d-lf-name",children:n}),o&&e.jsx("span",{className:"bim-d-lf-yr",children:p(o)})]}),m.length>0&&e.jsx("div",{className:"bim-d-lf-side",children:m.map((b,j)=>e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:p(b.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[p(b.evidence),v(b.confidence)]})]},j))})]}),h.length>0&&e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[e.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:a("bookPage.lineage.derivatives")}),e.jsx("span",{className:"bim-d-lf-chips",children:h.map((b,j)=>e.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?p(b.evidence):void 0,children:[y(b.book_id,r(b.book_id)),e.jsx("span",{className:"bim-d-meta",children:p(b.relation)})]},j))})]})]}),(w=t.appendix)==null?void 0:w.map((b,j)=>e.jsxs("details",{className:"bim-d-lf-app",children:[e.jsxs("summary",{className:"bim-d-ui",children:[e.jsx("span",{className:"bim-d-meta",children:a("bookPage.lineage.appendix")})," ",p(b.title)]}),e.jsx(ft,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${j}`)),(c==null?void 0:c.note)&&e.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:p(c.note)})]})}const tn=16,Ih=200,Rh=16,ga=({data:t,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:l,railTop:a,back:p,railLinks:c})=>{var ke,F,he,Ne,R,ne,ue;const{t:d,convert:u,messages:g}=G(),[m,h]=x.useState(""),[f,v]=x.useState(!1),[y,w]=x.useState(null),[b,j]=x.useState(""),[S,k]=x.useState(!1),$=x.useMemo(()=>gl(t,n),[t,n]),[_,z]=x.useState(new Map),E=!!o&&$.rows.length>0&&$.rows.length<=Ih,T=E&&($.rows.length<=tn||S),C=T&&$.rows.every(L=>!L.id||_.has(L.id)),O=L=>{var te;return Pi(L?(te=_.get(L))==null?void 0:te.l1:void 0)},W=x.useMemo(()=>{const L=m.trim(),te=L?u(L):"";return $.rows.filter(U=>{var we,Le;if(b&&Pi(U.id?(we=_.get(U.id))==null?void 0:we.l1:void 0)!==b)return!1;if(!te)return!0;const le=U.id&&((Le=_.get(U.id))==null?void 0:Le.title)||U.title;return u(le).includes(te)||(U.subItems||[]).some(Se=>u(Se).includes(te))})},[$.rows,m,b,_,u]),P=f?W:W.slice(0,tn),Y=x.useMemo(()=>(T?$.rows:P).filter(L=>L.id&&!_.has(L.id)).map(L=>L.id),[T,$.rows,P,_]);x.useEffect(()=>{if(!o||Y.length===0)return;let L=!1;const te=Y.slice(0,Rh);return Promise.all(te.map(U=>o.getItem(U).then(le=>{var Se,Fe;const we=le??{},Le={title:we.title,edition:we.edition,authors:we.authors,measure:le?bt(le,g.unit.juan):void 0,versionCount:we._edition_count??((Se=we.books)==null?void 0:Se.length),l1:((Fe=we.classification)==null?void 0:Fe.l1)||void 0};return[U,Le]}).catch(()=>[U,{}]))).then(U=>{L||z(le=>{const we=new Map(le);for(const[Le,Se]of U)we.set(Le,Se);return we})}),()=>{L=!0}},[o,Y,g.unit.juan]);const V=(t.contained_in||[])[0];x.useEffect(()=>{if(!V){w(null);return}if(w({id:V}),!o)return;let L=!1;return o.getItem(V).then(te=>{L||w({id:V,title:te==null?void 0:te.title})}).catch(()=>{}),()=>{L=!0}},[o,V]);const Q=x.useMemo(()=>sa(t.resources,t.resource_groups,d),[t.resources,t.resource_groups,d]),ge=Q.text.length+Q.groups.reduce((L,te)=>L+te.rows.length+te.mirrors.length,0),A=t.contained_works||[],I=new Set($.rows.map(L=>L.id).filter(Boolean)),Z=A.length>0&&!A.every(L=>I.has(L.id)),ee=(()=>{const L=$.rows.map(te=>te.edition).filter(Boolean);return L.length>1&&new Set(L).size===1})(),ce=$.rows.some(L=>L.volumes.length>0||L.expected!=null),fe=t._member_count||((ke=t.books)==null?void 0:ke.length)||A.length,Ie=bt(t,g.unit.juan),q=t.count,M=L=>typeof L=="number"&&Number.isFinite(L)?L:null,K=M(q==null?void 0:q.juan)??M((F=t.juan_count)==null?void 0:F.number),Re=M(q==null?void 0:q.ce)??($.totalVolumes||null),se=[{value:$.rows.length,label:d("collectionPage.stat.titles")},{value:K??0,label:g.unit.juan},{value:Re??0,label:g.unit.volume}],ye=x.useMemo(()=>{var U,le;const L=[];if((U=t.publication_info)!=null&&U.details&&L.push({label:d("collectionPage.fact.publication"),value:u(t.publication_info.details)}),fe&&fe!==$.rows.length){const we=t._member_type==="Book"?d("collectionPage.member.Book"):t._member_type==="Work"?d("collectionPage.member.Work"):d("collectionPage.member.other");L.push({label:we,value:`${fe} ${g.unit.bu}`,title:d("collectionPage.memberNote")})}const te=[M(q==null?void 0:q.zhong)!=null?d("collectionPage.nZhong",{n:q.zhong}):"",M(q==null?void 0:q.han)!=null?d("collectionPage.nHan",{n:q.han}):""].filter(Boolean);return te.length&&L.push({label:d("collectionPage.fact.expected"),value:te.join(" ")}),K==null&&Ie&&L.push({label:d("collectionPage.fact.measure"),value:u(Ie),title:(le=t.juan_count)!=null&&le.description?u(t.juan_count.description):void 0}),L},[t,fe,$.rows.length,K,Ie,q,u,d,g]),We=x.useMemo(()=>{if(!C)return[];const L=new Map;for(const U of $.rows){const le=O(U.id);le&&L.set(le,(L.get(le)??0)+1)}const te=an.filter(U=>(L.get(U.key)??0)>0);return te.length<2?[]:[{key:"",label:`${g.catalog.all} ${$.rows.length}`},...te.map(U=>({key:U.key,label:`${U.label} ${L.get(U.key)}`}))]},[C,$.rows,_,g]),Be=x.useMemo(()=>{if(!C||!$.rows.some(le=>le.volumes.length>0))return null;const L=[],te=$.rows.filter(le=>le.volumes.length>0).map(le=>({k:O(le.id)??"",from:Math.min(...le.volumes),to:Math.max(...le.volumes)})).sort((le,we)=>le.from-we.from);for(const le of te){const we=le.to-le.from+1,Le=L[L.length-1];Le&&Le.key===le.k?(Le.to=Math.max(Le.to,le.to),Le.n+=we):L.push({key:le.k,from:le.from,to:le.to,n:we})}const U=te.reduce((le,we)=>Math.max(le,we.to),0);return L.length>1&&L.some(le=>le.key)?{segs:L,last:U}:null},[C,$.rows,_]),Ee=(he=t.description)==null?void 0:he.text,Ce=e.jsx(un,{kind:d("collectionPage.kind"),title:u(t.title),byline:e.jsx(So,{authors:t.authors,onNavigate:r,renderLink:s}),meta:e.jsx(qe,{items:[t.subtype==="work_collection"?d("collectionPage.workCollection"):"",(Ne=t.publication_info)!=null&&Ne.year?u(t.publication_info.year):""]}),description:Ee||(R=t.history)!=null&&R.length?e.jsxs(e.Fragment,{children:[Ee&&e.jsx(ft,{text:Ee,style:{fontSize:15,lineHeight:1.85}}),(ne=t.history)!=null&&ne.length?e.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:t.history.map((L,te)=>e.jsx("li",{children:u(L)},te))}):null]}):void 0,clampDescription:so(Ee)||(((ue=t.history)==null?void 0:ue.length)??0)>2?6:void 0,stats:se,facts:ye,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:Be&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:d("collectionPage.dist.head")})}),e.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":d("collectionPage.dist.head"),children:Be.segs.map((L,te)=>{const U=an.find(le=>le.key===L.key);return e.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!U,title:U?d("collectionPage.dist.segTitle",{section:u(U.label),from:L.from,to:L.to}):void 0,"aria-label":U?d("collectionPage.dist.only",{section:u(U.label)}):d("collectionPage.dist.unclassified"),"aria-pressed":!!U&&b===L.key,style:{flexGrow:L.n,background:i(U?U.token:"rule")},onClick:()=>{U&&(j(b===L.key?"":L.key),v(!1))}},te)})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:d("catalog.volume",{n:1})}),e.jsx("span",{children:d("collectionPage.dist.hint")}),e.jsx("span",{children:d("catalog.volume",{n:Be.last})})]})]})}),He=[];$.rows.length&&He.push({id:"titles",label:d("collectionPage.sec.titles"),count:$.rows.length}),ge&&He.push({id:"resources",label:d("collectionPage.sec.resources"),count:ge}),Z&&He.push({id:"works",label:g.section.containedWorks,count:A.length});const D=e.jsxs(e.Fragment,{children:[$.rows.length>0&&e.jsxs(Ze,{id:"titles",title:d("collectionPage.sec.titles"),meta:e.jsx(qe,{items:[`${$.rows.length} ${g.unit.items}`,$.totalVolumes?d("collectionPage.totalVolumes",{n:$.totalVolumes,unit:g.unit.volume}):"",W.length!==$.rows.length?d("collectionPage.currentN",{n:W.length,unit:g.unit.items}):""]}),action:l,children:[($.rows.length>tn||We.length>0)&&e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[We.length>0&&e.jsx(Un,{items:We,value:b,onChange:L=>{j(L),v(!1)}}),E&&$.rows.length>tn&&!C&&e.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:S,onClick:()=>k(!0),title:d("collectionPage.loadAllTitle",{n:$.rows.length,unit:g.unit.items}),children:d(S?"collectionPage.grouping":"collectionPage.groupBySection")}),e.jsx("span",{className:"bim-d-spacer"}),$.rows.length>tn&&e.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:d("collectionPage.find"),"aria-label":d("collectionPage.find"),onChange:L=>{h(L.target.value),v(!1)}})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Vn(W.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[ce&&e.jsx("th",{style:{width:"8.5em"},children:d("collectionPage.col.volumes")}),e.jsx("th",{children:d("collectionPage.col.title")}),e.jsx("th",{style:{textAlign:"right"},children:d("collectionPage.col.versions")})]})}),e.jsx("tbody",{children:P.map((L,te)=>{var De;const U=L.id?_.get(L.id):void 0,le=U!=null&&U.title&&L.title===L.id?U.title:L.title,we=((U==null?void 0:U.authors)||[]).find(J=>J&&J.name),Le=[we?`${we.dynasty?`〔${u(we.dynasty)}〕`:""}${u(we.name)}${we.role?` ${u(we.role)}`:""}`:"",U!=null&&U.measure?u(U.measure):"",(De=L.subItems)!=null&&De.length?L.subItems.map(J=>u(J)).join("、"):"",(U!=null&&U.edition||L.edition)&&!ee?u((U==null?void 0:U.edition)||L.edition||""):""].filter(Boolean),Se=an.find(J=>J.key===O(L.id)),Fe=L.volumes.length>0?d("collectionPage.volumeRange",{range:Dn(L.volumes,g.unit.volume),unit:g.unit.volume}):L.expected!=null?`${L.found??0}/${L.expected} ${g.unit.volume}`:"";return e.jsxs("tr",{children:[ce&&e.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Fe?"":" bim-d-zt-blank"}`,children:[Se&&e.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(Se.token)}}),Fe||e.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),e.jsxs("td",{className:"bim-d-zt-main",children:[L.id?e.jsx(Ge,{id:L.id,label:u(le),onNavigate:r,renderLink:s,dense:!0}):e.jsx("span",{className:"bim-d-zt-name",children:u(le)}),Le.length>0?e.jsx(qe,{items:Le}):L.id&&!U&&o?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${U!=null&&U.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:U!=null&&U.versionCount?d("collectionPage.nZhong",{n:U.versionCount}):""})]},`${L.id??L.title}-${te}`)})})]}),P.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("catalog.noMatch")}),!f&&e.jsx(oo,{total:W.length,shown:P.length,unit:g.unit.items,onClick:()=>v(!0)})]}),ge>0&&e.jsxs(Ze,{id:"resources",title:d("collectionPage.sec.resources"),meta:d("collectionPage.resourcesCount",{n:ge}),children:[Q.text.length>0&&e.jsxs("div",{className:"bim-d-rg",children:[Q.groups.length>0&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:d("collectionPage.text")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:Q.text.map((L,te)=>e.jsx($o,{item:L,siblings:Q.text},`${L.id||L.url||L.name}-${te}`))})})]}),e.jsx(aa,{groups:Q.groups})]}),$.rows.length===0&&ge===0&&e.jsx(Ze,{title:d("collectionPage.sec.titles"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("collectionPage.empty")})})]}),re=Z?e.jsx(zt,{id:"works",title:g.section.containedWorks,meta:d("collectionPage.nZhong",{n:A.length}),cap:12,items:A.map(L=>e.jsx(Ge,{id:L.id,label:u(L.title),onNavigate:r,renderLink:s,dense:!0}))}):null,de=y?e.jsx(fl,{caption:d("collectionPage.parent"),children:e.jsx(Ge,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return e.jsx(pn,{railTop:a,back:p,up:de,nav:He,railLinks:c,main:D,card:Ce,side:re})},Eh=16,gi=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function ns(t){if(!t)return gi.length;const n=gi.indexOf(t);return n===-1?gi.length:n}function Lh(t,n){return t==null?"":t<0?n("entityPage.bce",{n:-t}):String(t)}const Ph={秦:[-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]},ha=({data:t,transport:n,onNavigate:o,renderLink:r,railTop:s,back:l,railLinks:a})=>{var de,ke,F,he,Ne;const{t:p,convert:c,messages:d}=G(),u=R=>Lh(R,p),[g,m]=x.useState("全部"),[h,f]=x.useState(!1),[v,y]=x.useState("default"),[w,b]=x.useState(new Map),j=x.useMemo(()=>(t.works||[]).map(R=>{const ne=w.get(R.work_id);return{id:R.work_id,title:(ne==null?void 0:ne.title)??R.title??R.work_id,role:R.role||"",cls:no(R.role),versionCount:ne==null?void 0:ne.versionCount,section:ne==null?void 0:ne.cls,l1:ne==null?void 0:ne.l1,measure:ne==null?void 0:ne.measure,hasImage:ne==null?void 0:ne.hasImage,loaded:!!(ne!=null&&ne.loaded)}}),[t.works,w]),S=x.useMemo(()=>ml((t.works||[]).map(R=>R.role),p("detail.roleAll")),[t.works,p]),k=x.useMemo(()=>{const R=g==="全部"?j:j.filter(ne=>ne.cls===g);return v==="versions"?[...R].sort((ne,ue)=>(ue.versionCount??-1)-(ne.versionCount??-1)):R},[j,g,v]),$=h?k:k.slice(0,Eh),_=x.useMemo(()=>$.filter(R=>!w.has(R.id)).map(R=>R.id),[$,w]);x.useEffect(()=>{if(!n||_.length===0)return;let R=!1;return Promise.all(_.map(ne=>n.getItem(ne).then(ue=>{var le,we,Le,Se,Fe;const L=ue??{},te=L._edition_count??(((le=L.books)==null?void 0:le.length)??0)+(((we=L.collections)==null?void 0:we.length)??0),U=[(Le=L.classification)==null?void 0:Le.l1,(Se=L.classification)==null?void 0:Se.l2].filter(Boolean).join(" ");return[ne,{id:ne,title:L.title,versionCount:te,loaded:!0,cls:U||void 0,l1:((Fe=L.classification)==null?void 0:Fe.l1)||void 0,measure:ue&&bt(ue,d.unit.juan)||void 0,hasImage:!!(L.has_image??L._has_image)}]}).catch(()=>[ne,{id:ne,loaded:!0}]))).then(ne=>{R||b(ue=>{const L=new Map(ue);for(const[te,U]of ne)L.set(te,U);return L})}),()=>{R=!0}},[n,_,d.unit.juan]);const z=x.useMemo(()=>{const R=new Map;for(const ne of t.alt_names||[]){const ue=ne.type||d.section.aliases;R.has(ue)||R.set(ue,[]),R.get(ue).push(ne.name)}return[...R.entries()].sort((ne,ue)=>ns(ne[0])-ns(ue[0])).map(([ne,ue])=>({label:ne,names:ue}))},[t.alt_names,d]),E=t.birth_year??((de=t.dates)==null?void 0:de.birth)??void 0,T=t.death_year??((ke=t.dates)==null?void 0:ke.death)??void 0,C=(F=t.dates)==null?void 0:F.floruit,O=E!=null||T!=null?`${u(E)||"?"}—${u(T)||"?"}`:Array.isArray(C)&&C.length===2&&C.every(R=>Number.isFinite(R))?p("entityPage.floruit",{from:u(C[0]),to:u(C[1])}):"",W=new Set(["本名","字","號","号"]),P=z.filter(R=>W.has(R.label)),Y=z.filter(R=>!W.has(R.label)),V=Y.reduce((R,ne)=>R+ne.names.length,0),Q=x.useMemo(()=>{const R=[];for(const ue of P)R.push({label:ue.label,value:ue.names.map(L=>c(L)).join("、")});const ne=(t.works||[]).length;return ne&&R.push({label:p("entityPage.fact.works"),value:p("entityPage.nZhong",{n:ne})}),R},[t.works,P,c,p]),ge=R=>{var ne;return(ne=z.find(ue=>R.includes(ue.label)))==null?void 0:ne.names[0]},A=ge(["字"]),I=ge(["號","号"]),Z=[A?p("entityPage.zi",{name:c(A)}):"",I?p("entityPage.hao",{name:c(I)}):""].filter(Boolean).join(","),ee=t.native_place,ce=t.dynasty?Ph[t.dynasty]:void 0,fe=(()=>{if(!ce||E==null||T==null||T<E)return null;const[R,ne]=ce,ue=Math.max(E,R),L=Math.min(T,ne);if(L<=ue)return null;const te=ne-R;return e.jsxs("div",{className:"bim-d-life bim-d-ui",children:[e.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":p("entityPage.lifeAria",{birth:u(E),death:u(T),years:T-E+1}),children:e.jsx("i",{style:{left:`${(ue-R)/te*100}%`,width:`${(L-ue)/te*100}%`}})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:`${u(R)} ${c(t.dynasty)}`}),e.jsx("span",{children:p("entityPage.lifeYears",{years:T-E+1})}),e.jsx("span",{children:u(ne)})]})]})})(),Ie=x.useMemo(()=>{if(!n||j.length===0||j.some(ue=>!ue.loaded))return null;const R=new Map;for(const ue of j){const L=Pi(ue.l1);L&&R.set(L,(R.get(L)??0)+1)}const ne=an.map(ue=>({...ue,n:R.get(ue.key)??0})).filter(ue=>ue.n>0);return ne.length?ne:null},[j,n]),q=e.jsxs(un,{kind:d.entityPage.subtype[t.subtype]??p("entityPage.subtype.people"),title:c(t.primary_name||t.title),subtitle:Z||void 0,meta:e.jsxs(e.Fragment,{children:[e.jsx(qe,{items:[t.dynasty?c(t.dynasty):"",O,ee?p("entityPage.nativePlace",{place:c(ee)}):""]}),fe]}),description:(he=t.description)!=null&&he.text?e.jsx(ft,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:so((Ne=t.description)==null?void 0:Ne.text)?6:void 0,facts:Q,foot:e.jsx(mn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:[V>0&&e.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[e.jsx("summary",{children:p("entityPage.moreNames",{n:V})}),e.jsx("dl",{children:Y.map(R=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{children:c(R.label)}),e.jsx("dd",{children:R.names.map(ne=>c(ne)).join("、")})]},R.label))})]}),Ie&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:p("entityPage.dist")})}),e.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:Ie.map(R=>e.jsx("i",{style:{flexGrow:R.n,background:i(R.token)}},R.key))}),e.jsx("div",{className:"bim-d-dist-key",children:Ie.map(R=>e.jsxs("span",{children:[e.jsx("i",{style:{background:i(R.token)}}),c(R.label)," ",R.n]},R.key))})]})]}),M=x.useMemo(()=>j.filter(R=>R.loaded&&(R.versionCount??0)>0).sort((R,ne)=>(ne.versionCount??0)-(R.versionCount??0)).slice(0,3),[j]),K=!!n&&j.length>=3&&$.some(R=>!R.loaded),Re=g==="全部"&&(K||M.length>=2),se=t.external_ids||{},ye=[];se.cbdb_id!=null&&ye.push({label:"CBDB",id:String(se.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${se.cbdb_id}`,note:se.cbdb_match==="auto"?p("entityPage.autoMatch"):void 0});const We=se.wikidata_id;We&&ye.push({label:"Wikidata",id:We,href:`https://www.wikidata.org/wiki/${We}`});const Be=se.viaf_id;Be&&ye.push({label:"VIAF",id:Be,href:`https://viaf.org/viaf/${Be}`});const Ee=S.map(R=>({key:R.cls,label:`${R.label} ${R.count}`})),Ce=[...Re&&!K?[{id:"featured",label:p("entityPage.sec.featured"),count:M.length}]:[],...j.length?[{id:"works",label:p("entityPage.sec.allWorks"),count:j.length}]:[],...ye.length?[{id:"external",label:p("entityPage.sec.external"),count:ye.length}]:[]],He=Re?e.jsxs(Ze,{id:"featured",title:p("entityPage.sec.featured"),children:[e.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:p("entityPage.featuredSub")}),e.jsxs("div",{className:"bim-d-picks","aria-busy":K||void 0,children:[K&&[0,1,2].map(R=>e.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[e.jsx("span",{className:"bim-d-pick-t",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "}),e.jsx("div",{className:"bim-d-pick-n",children:" "})]},R)),!K&&M.map(R=>e.jsxs("div",{className:"bim-d-pick",children:[e.jsx("span",{className:"bim-d-pick-t",children:e.jsx(Ge,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0})}),e.jsx(qe,{items:[R.section?c(R.section):"",R.measure?c(R.measure):""]}),e.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[e.jsx("span",{className:"bim-d-pick-num",children:R.versionCount}),e.jsx("span",{children:p("entityPage.versionsUnit")}),R.hasImage&&e.jsx("span",{className:"bim-d-flag",children:p("entityPage.hasImage")})]})]},R.id))]})]}):null,D=j.length===0?e.jsx(Ze,{title:p("entityPage.sec.works"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("entityPage.empty")})}):e.jsxs(e.Fragment,{children:[He,e.jsxs(Ze,{id:"works",title:p("entityPage.sec.works"),meta:e.jsx(qe,{items:[p("entityPage.total",{n:j.length}),k.length!==j.length?p("entityPage.current",{n:k.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Ee.length>1&&e.jsx(Un,{items:Ee,value:g,onChange:R=>{m(R),f(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":v==="versions",onClick:()=>{v==="default"&&f(!0),y(R=>R==="default"?"versions":"default")},children:p(v==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!h&&Vn(k.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:p("entityPage.col.work")}),e.jsx("th",{children:p("entityPage.col.section")}),e.jsx("th",{children:p("entityPage.col.role")}),e.jsx("th",{children:p("entityPage.col.versions")}),e.jsx("th",{"aria-label":p("entityPage.col.image")})]})}),e.jsx("tbody",{children:$.map(R=>e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ge,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0}),R.measure?e.jsx(qe,{items:[c(R.measure)]}):!R.loaded&&n?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.section||R.loaded?"":" bim-d-zt-blank"}`,children:R.section?c(R.section):null}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.role?"":" bim-d-zt-blank"}`,children:R.role?c(R.role):e.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.loaded?"":" bim-d-zt-blank"}`,children:R.loaded?R.versionCount?p("entityPage.nZhong",{n:R.versionCount}):e.jsx("span",{className:"bim-d-zt-empty",children:p("entityPage.notRecorded")}):""}),e.jsx("td",{className:R.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:R.hasImage&&e.jsx("span",{className:"bim-d-flag bim-d-ui",children:p("entityPage.hasImage")})})]},R.id))})]}),$.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("entityPage.emptyRole")}),!h&&e.jsx(oo,{total:k.length,shown:$.length,unit:p("entityPage.moreUnit"),onClick:()=>f(!0)})]})]}),re=ye.length>0?e.jsx(zt,{id:"external",title:p("entityPage.sec.external"),items:ye.map(R=>e.jsxs("a",{href:R.href,target:"_blank",rel:"noopener noreferrer",children:[R.label," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:ye.map(R=>R.id),foot:se.cbdb_id!=null&&se.cbdb_match==="auto"?p("entityPage.cbdbAuto"):void 0}):null;return e.jsx(pn,{railTop:s,back:l,nav:Ce,railLinks:a,main:D,card:q,side:re})},Co="(max-width: 719px)",Ah=`${Co}, (pointer: coarse)`,xa=`
|
|
1106
1110
|
.bim-ct {
|
|
1107
1111
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1108
1112
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1210,7 +1214,7 @@ ${ee??""}`,load:Ae,files:Q,activeFile:ye??null,activeJuan:(ze==null?void 0:ze.js
|
|
|
1210
1214
|
.bim-ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1211
1215
|
}
|
|
1212
1216
|
|
|
1213
|
-
@media ${
|
|
1217
|
+
@media ${Co} {
|
|
1214
1218
|
.bim-ct { display: block; padding: 12px 16px 40px; }
|
|
1215
1219
|
.bim-ct-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
|
1216
1220
|
.bim-ct-lrow > a { grid-template-columns: minmax(0, 1fr); }
|
|
@@ -1235,7 +1239,7 @@ ${ee??""}`,load:Ae,files:Q,activeFile:ye??null,activeJuan:(ze==null?void 0:ze.js
|
|
|
1235
1239
|
}
|
|
1236
1240
|
|
|
1237
1241
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1238
|
-
@media ${
|
|
1242
|
+
@media ${Ah} {
|
|
1239
1243
|
.bim-ct-row { min-height: 44px; }
|
|
1240
1244
|
.bim-ct-tw { width: 44px; }
|
|
1241
1245
|
.bim-ct-pg { min-width: 44px; height: 44px; }
|
|
@@ -1261,7 +1265,7 @@ ${ee??""}`,load:Ae,files:Q,activeFile:ye??null,activeJuan:(ze==null?void 0:ze.js
|
|
|
1261
1265
|
/* 窄屏分类抽屉:界栏下按钮和面板都有框 */
|
|
1262
1266
|
:root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${i("fr-bd")}; background: ${i("fr-bg")}; }
|
|
1263
1267
|
:root[data-layout="boxed"] .bim-ct-drawer { border: ${i("fr-bd")}; }
|
|
1264
|
-
`,$t="未分類",mt="all",So=20;function un(t){if(!t)return[];const n=[];for(const o of[t.l1,t.l2,t.l3,t.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function wh(t){const n=un(t);return n.length?n.join("/"):$t}function Sh(t){const n=un(t);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[$t]}function $h(t,n=[]){const o=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(u=>!!u);p.forEach((u,g)=>{const m=p.slice(0,g+1).join("/");o.has(m)||o.set(m,c)})});const r=new Map;let s=0;for(const d of t){const c=un(d.classification);if(!c.length){s++;continue}let p=r;c.forEach((u,g)=>{const m=c.slice(0,g+1).join("/");let h=p.get(u);h||(h={id:m,label:u,count:0,children:new Map},p.set(u,h)),h.count++,p=h.children})}const l=d=>[...d.values()].sort((c,p)=>{const u=c.label===$t?1:0,g=p.label===$t?1:0;if(u!==g)return u-g;const m=o.get(c.id)??1/0,h=o.get(p.id)??1/0;return m!==h?m-h: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=l(c.children)),p}),a=l(r);return s>0&&a.push({id:$t,label:$t,count:s}),a}function Lt(t,n){if(!n)return[];for(const o of t){if(o.id===n)return[o];if(o.children){const r=Lt(o.children,n);if(r.length)return[o,...r]}}return[]}function $o(t){return t.reduce((n,o)=>n+o.count,0)}function _h(t){return(t??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function Ch(t){var d;const n={id:t.id,title:t.title||t.id},o=t.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r:t.measure_info&&(n.juan=t.measure_info);const s=(t.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const p=c.dynasty||(t.authors.length===1?t.dynasty:void 0);return p?{name:c.name,dynasty:p}:{name:c.name}});s.length&&(n.authors=s);const l=_h(typeof t.description=="string"?t.description:(d=t.description)==null?void 0:d.text);l&&(n.summary=l);const a=un(t.classification);return a.length&&(n.classification=a),n}function zh(t,n){const o=t.summary?0:1,r=n.summary?0:1;return o!==r?o-r:t.title.localeCompare(n.title,"zh")}function Th(t,n=So){return Math.max(1,Math.ceil(t/n))}function pa(t,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let a=t-o;a<=t+o;a++)a>=1&&a<=n&&r.add(a);const s=[...r].sort((a,d)=>a-d),l=[];return s.forEach((a,d)=>{if(d>0){const c=a-s[d-1];c===2?l.push(a-1):c>2&&l.push(null)}l.push(a)}),l}const Nh=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Ih(t,n,o){const r=[];o&&r.push({id:mt,parentId:null,hasChildren:!1,firstChildId:null});const s=(l,a)=>{var d;for(const c of l){const p=(d=c.children)!=null&&d.length?c.children:null;r.push({id:c.id,parentId:a,hasChildren:!!p,firstChildId:p?p[0].id:null}),p&&n.has(c.id)&&s(p,c.id)}};return s(t,null),r}function ua({tree:t,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:l,convert:a}=K(),d=r===void 0?l("catalogPage.all"):r,c=s??l("catalogPage.classification"),p=x.useRef(null),u=n&&n!==mt?n:null,g=d!==null,[m,h]=x.useState(()=>{const C=new Set;for(const I of Lt(t,u))C.add(I.id);return C});x.useEffect(()=>{const C=Lt(t,u);C.length&&h(I=>{if(C.every(z=>I.has(z.id)))return I;const T=new Set(I);for(const z of C)T.add(z.id);return T})},[t,u]);const f=x.useMemo(()=>Ih(t,m,g),[t,m,g]),[v,y]=x.useState(null);x.useEffect(()=>{y(null)},[n]);const k=u??(g?mt:null),b=x.useMemo(()=>{var T;const C=new Set(f.map(z=>z.id));if(v&&C.has(v))return v;if(k&&C.has(k))return k;const I=Lt(t,u).map(z=>z.id).filter(z=>C.has(z));return I.length?I[I.length-1]:((T=f[0])==null?void 0:T.id)??null},[f,v,k,t,u]),j=x.useCallback((C,I)=>{h(T=>{const z=T.has(C),H=I??!z;if(H===z)return T;const W=new Set(T);return H?W.add(C):W.delete(C),W})},[]),w=x.useCallback(C=>{y(C),requestAnimationFrame(()=>{var T;const I=Array.from(((T=p.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===C);I==null||I.focus()})},[]),S=x.useCallback((C,I)=>{I&&j(C,!0),o(C)},[o,j]),$=x.useCallback(C=>{const I=C.target.closest("[data-ct-id]");if(!I)return;const T=I.dataset.ctId,z=f.findIndex(A=>A.id===T);if(z<0)return;const H=f[z];let W=null;switch(C.key){case"ArrowDown":W=f[Math.min(f.length-1,z+1)].id;break;case"ArrowUp":W=f[Math.max(0,z-1)].id;break;case"Home":W=f[0].id;break;case"End":W=f[f.length-1].id;break;case"ArrowRight":if(!H.hasChildren)break;m.has(T)?W=H.firstChildId:j(T,!0);break;case"ArrowLeft":H.hasChildren&&m.has(T)?j(T,!1):W=H.parentId;break;case"Enter":case" ":C.preventDefault(),S(T,H.hasChildren);return;default:return}C.preventDefault(),W&&W!==T&&w(W)},[f,m,j,w,S]),_=(C,I)=>C.map((T,z)=>{var G;const H=(G=T.children)!=null&&G.length?T.children:null,W=!!H&&m.has(T.id),A=T.id===u,Y=I===1&&C.length>1&&z===C.length-1;return e.jsxs("li",{role:"treeitem","aria-level":I,"aria-expanded":H?W:void 0,"aria-selected":A,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:Y?"bim-ct-last":void 0,children:[e.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":I-1},onClick:()=>{y(T.id),S(T.id,!!H)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:H?te=>{te.stopPropagation(),y(T.id),j(T.id)}:void 0,children:H?e.jsx(Nh,{}):null}),e.jsx("span",{className:"bim-ct-lb",children:a(T.label)}),e.jsx("span",{className:"bim-ct-n",children:T.count.toLocaleString("en-US")})]}),W&&e.jsx("ul",{role:"group",children:_(H,I+1)})]},T.id)});return e.jsxs("ul",{ref:p,role:"tree","aria-label":a(c),className:"bim-ct-tree",onKeyDown:$,children:[g&&e.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:b===mt?0:-1,"data-ct-id":mt,children:e.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(mt),o(mt)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),e.jsx("span",{className:"bim-ct-lb",children:a(d)}),e.jsx("span",{className:"bim-ct-n",children:$o(t).toLocaleString("en-US")})]})}),_(t,1)]})}const ma=t=>`/item/${encodeURIComponent(t)}`;function Eh(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}function ga(t,n){return t==null||t===""?null:typeof t=="number"?n("catalogPage.juanN",{n:t}):t}function ha({work:t,href:n}){var d,c;const{t:o,convert:r}=K(),s=ga(t.juan,o),l=((d=t.authors)==null?void 0:d.filter(p=>p.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-card",children:e.jsxs("a",{href:n,children:[e.jsxs("div",{className:"bim-ct-ch",children:[e.jsx("h2",{className:"bim-ct-ct",children:r(t.title)}),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),l.length>0&&e.jsx("span",{className:"bim-ct-by",children:l.map((p,u)=>e.jsxs(x.Fragment,{children:[u>0&&"、",p.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),t.summary&&e.jsx("p",{className:"bim-ct-sum",children:r(t.summary)}),a.length>0&&e.jsx("span",{className:"bim-ct-cls",children:a.map(p=>r(p)).join(" · ")})]})})}function xa({work:t,href:n}){var d,c;const{t:o,convert:r}=K(),s=ga(t.juan,o),l=((d=t.authors)==null?void 0:d.filter(p=>p.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-lrow",children:e.jsxs("a",{href:n,children:[e.jsxs("span",{className:"bim-ct-lt",children:[r(t.title),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),e.jsx("span",{className:"bim-ct-by",children:l.map((p,u)=>e.jsxs(x.Fragment,{children:[u>0&&"、",p.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),e.jsx("span",{className:"bim-ct-cls",children:a.map(p=>r(p)).join(" · ")})]})})}function fa({page:t,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:l,convert:a}=K();if(n<=1)return null;const d=p=>u=>{o&&(r&&!Eh(u)||(u.preventDefault(),o(p)))},c=(p,u,g)=>{if(g.disabled)return e.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const m={className:"bim-ct-pg","aria-current":g.current?"page":void 0,"aria-label":g.aria};return r?e.jsx("a",{...m,href:r(p),onClick:d(p),children:u}):e.jsx("button",{type:"button",...m,onClick:g.current?void 0:d(p),children:u})};return e.jsxs("nav",{className:"bim-ct-pager","aria-label":s?a(s):l("catalogPage.pagerLabel"),children:[c(t-1,l("catalogPage.prevPage"),{disabled:t<=1}),e.jsx("ol",{children:pa(t,n).map((p,u)=>e.jsx("li",{style:{display:"contents"},children:p===null?e.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(p,p,{current:p===t,aria:l("catalogPage.pageN",{n:p})})},p??`gap${u}`))}),e.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[t," / ",n]}),c(t+1,l("catalogPage.nextPage"),{disabled:t>=n})]})}function ba({works:t,workLink:n=ma,emptyText:o,view:r="card",...s}){const{t:l,convert:a}=K();return e.jsxs("div",{className:"bim-ct-works",children:[t.length===0?e.jsx("p",{className:"bim-ct-empty",children:o===void 0?l("catalogPage.emptyWorks"):typeof o=="string"?a(o):o}):r==="list"?e.jsx("ul",{className:"bim-ct-list",children:t.map(d=>e.jsx(xa,{work:d,href:n(d.id)},d.id))}):e.jsx("ul",{className:"bim-ct-grid",children:t.map(d=>e.jsx(ha,{work:d,href:n(d.id)},d.id))}),e.jsx(fa,{...s})]})}const Rh=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:e.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Lh({tree:t,selectedId:n,page:o,pageCount:r,works:s,onSelect:l,onPage:a,searchSlot:d,workLink:c,pageHref:p,allLabel:u,allTitle:g,pageSize:m=So,className:h,view:f,onViewChange:v}){const{t:y,convert:k}=K(),b=u===void 0?y("catalogPage.all"):u,j=g??y("catalogPage.allTitle"),S=`bim-ct-drawer-${x.useId().replace(/:/g,"")}`,[$,_]=x.useState(!1),[C,I]=x.useState("card"),T=f??C,z=te=>{I(te),v==null||v(te)},H=Lt(t,n&&n!==mt?n:null),W=H.length?H[H.length-1]:null,A=W?W.label:j,Y=W?W.count:$o(t),G=x.useCallback(te=>{_(!1),l(te)},[l]);return e.jsxs("div",{className:h?`bim-ct ${h}`:"bim-ct","data-drawer":$?"open":"closed",children:[e.jsx("style",{children:da}),e.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[e.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":S,onClick:()=>_(te=>!te),children:[e.jsx("span",{children:y("catalogPage.drawerLabel",{path:k(H.length?H.map(te=>te.label).join(" › "):b??j)})}),e.jsx(Rh,{})]}),e.jsxs("div",{className:"bim-ct-drawer",id:S,children:[e.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),e.jsx(ua,{tree:t,selectedId:n,onSelect:G,allLabel:b})]})]}),e.jsxs("div",{className:"bim-ct-main",children:[e.jsxs("header",{className:"bim-ct-head",children:[e.jsx("h1",{className:"bim-ct-title",children:k(A)}),H.length>1&&e.jsx("span",{className:"bim-ct-crumb",children:k(H.slice(0,-1).map(te=>te.label).join(" › "))}),e.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:Y.toLocaleString("en-US"),size:m}),r>1&&y("catalogPage.statPage",{page:o,pages:r})]}),e.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[e.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>z("card"),children:y("catalogPage.viewCard")}),e.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>z("list"),children:y("catalogPage.viewList")})]})]}),d&&e.jsx("div",{className:"bim-ct-search",children:d}),e.jsx(ba,{works:s,view:T,workLink:c,page:o,pageCount:r,onPage:a,pageHref:p})]})]})}const mn="(max-width: 719px)",Ph="(max-width: 1079px)",Ah=`${mn}, (pointer: coarse)`,Bh=[8,18,30,42,88],_o=`
|
|
1268
|
+
`,Ct="未分類",ht="all",zo=20;function hn(t){if(!t)return[];const n=[];for(const o of[t.l1,t.l2,t.l3,t.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function Bh(t){const n=hn(t);return n.length?n.join("/"):Ct}function Mh(t){const n=hn(t);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Ct]}function Wh(t,n=[]){const o=new Map;n.forEach((p,c)=>{const d=[p.cata_l1,p.cata_l2,p.cata_l3,p.cata_l4].filter(u=>!!u);d.forEach((u,g)=>{const m=d.slice(0,g+1).join("/");o.has(m)||o.set(m,c)})});const r=new Map;let s=0;for(const p of t){const c=hn(p.classification);if(!c.length){s++;continue}let d=r;c.forEach((u,g)=>{const m=c.slice(0,g+1).join("/");let h=d.get(u);h||(h={id:m,label:u,count:0,children:new Map},d.set(u,h)),h.count++,d=h.children})}const l=p=>[...p.values()].sort((c,d)=>{const u=c.label===Ct?1:0,g=d.label===Ct?1:0;if(u!==g)return u-g;const m=o.get(c.id)??1/0,h=o.get(d.id)??1/0;return m!==h?m-h:c.label.localeCompare(d.label,"zh")}).map(c=>{const d={id:c.id,label:c.label,count:c.count};return c.children.size&&(d.children=l(c.children)),d}),a=l(r);return s>0&&a.push({id:Ct,label:Ct,count:s}),a}function Bt(t,n){if(!n)return[];for(const o of t){if(o.id===n)return[o];if(o.children){const r=Bt(o.children,n);if(r.length)return[o,...r]}}return[]}function To(t){return t.reduce((n,o)=>n+o.count,0)}function Hh(t){return(t??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function Oh(t){var p;const n={id:t.id,title:t.title||t.id},o=t.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r:t.measure_info&&(n.juan=t.measure_info);const s=(t.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const d=c.dynasty||(t.authors.length===1?t.dynasty:void 0);return d?{name:c.name,dynasty:d}:{name:c.name}});s.length&&(n.authors=s);const l=Hh(typeof t.description=="string"?t.description:(p=t.description)==null?void 0:p.text);l&&(n.summary=l);const a=hn(t.classification);return a.length&&(n.classification=a),n}function Fh(t,n){const o=t.summary?0:1,r=n.summary?0:1;return o!==r?o-r:t.title.localeCompare(n.title,"zh")}function Dh(t,n=zo){return Math.max(1,Math.ceil(t/n))}function fa(t,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let a=t-o;a<=t+o;a++)a>=1&&a<=n&&r.add(a);const s=[...r].sort((a,p)=>a-p),l=[];return s.forEach((a,p)=>{if(p>0){const c=a-s[p-1];c===2?l.push(a-1):c>2&&l.push(null)}l.push(a)}),l}const Uh=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Vh(t,n,o){const r=[];o&&r.push({id:ht,parentId:null,hasChildren:!1,firstChildId:null});const s=(l,a)=>{var p;for(const c of l){const d=(p=c.children)!=null&&p.length?c.children:null;r.push({id:c.id,parentId:a,hasChildren:!!d,firstChildId:d?d[0].id:null}),d&&n.has(c.id)&&s(d,c.id)}};return s(t,null),r}function ba({tree:t,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:l,convert:a}=G(),p=r===void 0?l("catalogPage.all"):r,c=s??l("catalogPage.classification"),d=x.useRef(null),u=n&&n!==ht?n:null,g=p!==null,[m,h]=x.useState(()=>{const z=new Set;for(const E of Bt(t,u))z.add(E.id);return z});x.useEffect(()=>{const z=Bt(t,u);z.length&&h(E=>{if(z.every(C=>E.has(C.id)))return E;const T=new Set(E);for(const C of z)T.add(C.id);return T})},[t,u]);const f=x.useMemo(()=>Vh(t,m,g),[t,m,g]),[v,y]=x.useState(null);x.useEffect(()=>{y(null)},[n]);const w=u??(g?ht:null),b=x.useMemo(()=>{var T;const z=new Set(f.map(C=>C.id));if(v&&z.has(v))return v;if(w&&z.has(w))return w;const E=Bt(t,u).map(C=>C.id).filter(C=>z.has(C));return E.length?E[E.length-1]:((T=f[0])==null?void 0:T.id)??null},[f,v,w,t,u]),j=x.useCallback((z,E)=>{h(T=>{const C=T.has(z),O=E??!C;if(O===C)return T;const W=new Set(T);return O?W.add(z):W.delete(z),W})},[]),S=x.useCallback(z=>{y(z),requestAnimationFrame(()=>{var T;const E=Array.from(((T=d.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(C=>C.dataset.ctId===z);E==null||E.focus()})},[]),k=x.useCallback((z,E)=>{E&&j(z,!0),o(z)},[o,j]),$=x.useCallback(z=>{const E=z.target.closest("[data-ct-id]");if(!E)return;const T=E.dataset.ctId,C=f.findIndex(P=>P.id===T);if(C<0)return;const O=f[C];let W=null;switch(z.key){case"ArrowDown":W=f[Math.min(f.length-1,C+1)].id;break;case"ArrowUp":W=f[Math.max(0,C-1)].id;break;case"Home":W=f[0].id;break;case"End":W=f[f.length-1].id;break;case"ArrowRight":if(!O.hasChildren)break;m.has(T)?W=O.firstChildId:j(T,!0);break;case"ArrowLeft":O.hasChildren&&m.has(T)?j(T,!1):W=O.parentId;break;case"Enter":case" ":z.preventDefault(),k(T,O.hasChildren);return;default:return}z.preventDefault(),W&&W!==T&&S(W)},[f,m,j,S,k]),_=(z,E)=>z.map((T,C)=>{var V;const O=(V=T.children)!=null&&V.length?T.children:null,W=!!O&&m.has(T.id),P=T.id===u,Y=E===1&&z.length>1&&C===z.length-1;return e.jsxs("li",{role:"treeitem","aria-level":E,"aria-expanded":O?W:void 0,"aria-selected":P,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:Y?"bim-ct-last":void 0,children:[e.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":E-1},onClick:()=>{y(T.id),k(T.id,!!O)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:O?Q=>{Q.stopPropagation(),y(T.id),j(T.id)}:void 0,children:O?e.jsx(Uh,{}):null}),e.jsx("span",{className:"bim-ct-lb",children:a(T.label)}),e.jsx("span",{className:"bim-ct-n",children:T.count.toLocaleString("en-US")})]}),W&&e.jsx("ul",{role:"group",children:_(O,E+1)})]},T.id)});return e.jsxs("ul",{ref:d,role:"tree","aria-label":a(c),className:"bim-ct-tree",onKeyDown:$,children:[g&&e.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:b===ht?0:-1,"data-ct-id":ht,children:e.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(ht),o(ht)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),e.jsx("span",{className:"bim-ct-lb",children:a(p)}),e.jsx("span",{className:"bim-ct-n",children:To(t).toLocaleString("en-US")})]})}),_(t,1)]})}const ya=t=>`/item/${encodeURIComponent(t)}`;function Gh(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}function ja(t,n){return t==null||t===""?null:typeof t=="number"?n("catalogPage.juanN",{n:t}):t}function va({work:t,href:n}){var p,c;const{t:o,convert:r}=G(),s=ja(t.juan,o),l=((p=t.authors)==null?void 0:p.filter(d=>d.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-card",children:e.jsxs("a",{href:n,children:[e.jsxs("div",{className:"bim-ct-ch",children:[e.jsx("h2",{className:"bim-ct-ct",children:r(t.title)}),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),l.length>0&&e.jsx("span",{className:"bim-ct-by",children:l.map((d,u)=>e.jsxs(x.Fragment,{children:[u>0&&"、",d.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(d.dynasty),"〕"]}),r(d.name)]},u))}),t.summary&&e.jsx("p",{className:"bim-ct-sum",children:r(t.summary)}),a.length>0&&e.jsx("span",{className:"bim-ct-cls",children:a.map(d=>r(d)).join(" · ")})]})})}function ka({work:t,href:n}){var p,c;const{t:o,convert:r}=G(),s=ja(t.juan,o),l=((p=t.authors)==null?void 0:p.filter(d=>d.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-lrow",children:e.jsxs("a",{href:n,children:[e.jsxs("span",{className:"bim-ct-lt",children:[r(t.title),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),e.jsx("span",{className:"bim-ct-by",children:l.map((d,u)=>e.jsxs(x.Fragment,{children:[u>0&&"、",d.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(d.dynasty),"〕"]}),r(d.name)]},u))}),e.jsx("span",{className:"bim-ct-cls",children:a.map(d=>r(d)).join(" · ")})]})})}function wa({page:t,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:l,convert:a}=G();if(n<=1)return null;const p=d=>u=>{o&&(r&&!Gh(u)||(u.preventDefault(),o(d)))},c=(d,u,g)=>{if(g.disabled)return e.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const m={className:"bim-ct-pg","aria-current":g.current?"page":void 0,"aria-label":g.aria};return r?e.jsx("a",{...m,href:r(d),onClick:p(d),children:u}):e.jsx("button",{type:"button",...m,onClick:g.current?void 0:p(d),children:u})};return e.jsxs("nav",{className:"bim-ct-pager","aria-label":s?a(s):l("catalogPage.pagerLabel"),children:[c(t-1,l("catalogPage.prevPage"),{disabled:t<=1}),e.jsx("ol",{children:fa(t,n).map((d,u)=>e.jsx("li",{style:{display:"contents"},children:d===null?e.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(d,d,{current:d===t,aria:l("catalogPage.pageN",{n:d})})},d??`gap${u}`))}),e.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[t," / ",n]}),c(t+1,l("catalogPage.nextPage"),{disabled:t>=n})]})}function Sa({works:t,workLink:n=ya,emptyText:o,view:r="card",...s}){const{t:l,convert:a}=G();return e.jsxs("div",{className:"bim-ct-works",children:[t.length===0?e.jsx("p",{className:"bim-ct-empty",children:o===void 0?l("catalogPage.emptyWorks"):typeof o=="string"?a(o):o}):r==="list"?e.jsx("ul",{className:"bim-ct-list",children:t.map(p=>e.jsx(ka,{work:p,href:n(p.id)},p.id))}):e.jsx("ul",{className:"bim-ct-grid",children:t.map(p=>e.jsx(va,{work:p,href:n(p.id)},p.id))}),e.jsx(wa,{...s})]})}const Yh=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:e.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Kh({tree:t,selectedId:n,page:o,pageCount:r,works:s,onSelect:l,onPage:a,searchSlot:p,workLink:c,pageHref:d,allLabel:u,allTitle:g,pageSize:m=zo,className:h,view:f,onViewChange:v}){const{t:y,convert:w}=G(),b=u===void 0?y("catalogPage.all"):u,j=g??y("catalogPage.allTitle"),k=`bim-ct-drawer-${x.useId().replace(/:/g,"")}`,[$,_]=x.useState(!1),[z,E]=x.useState("card"),T=f??z,C=Q=>{E(Q),v==null||v(Q)},O=Bt(t,n&&n!==ht?n:null),W=O.length?O[O.length-1]:null,P=W?W.label:j,Y=W?W.count:To(t),V=x.useCallback(Q=>{_(!1),l(Q)},[l]);return e.jsxs("div",{className:h?`bim-ct ${h}`:"bim-ct","data-drawer":$?"open":"closed",children:[e.jsx("style",{children:xa}),e.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[e.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":k,onClick:()=>_(Q=>!Q),children:[e.jsx("span",{children:y("catalogPage.drawerLabel",{path:w(O.length?O.map(Q=>Q.label).join(" › "):b??j)})}),e.jsx(Yh,{})]}),e.jsxs("div",{className:"bim-ct-drawer",id:k,children:[e.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),e.jsx(ba,{tree:t,selectedId:n,onSelect:V,allLabel:b})]})]}),e.jsxs("div",{className:"bim-ct-main",children:[e.jsxs("header",{className:"bim-ct-head",children:[e.jsx("h1",{className:"bim-ct-title",children:w(P)}),O.length>1&&e.jsx("span",{className:"bim-ct-crumb",children:w(O.slice(0,-1).map(Q=>Q.label).join(" › "))}),e.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:Y.toLocaleString("en-US"),size:m}),r>1&&y("catalogPage.statPage",{page:o,pages:r})]}),e.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[e.jsx("button",{type:"button","aria-pressed":T==="card",onClick:()=>C("card"),children:y("catalogPage.viewCard")}),e.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>C("list"),children:y("catalogPage.viewList")})]})]}),p&&e.jsx("div",{className:"bim-ct-search",children:p}),e.jsx(Sa,{works:s,view:T,workLink:c,page:o,pageCount:r,onPage:a,pageHref:d})]})]})}const xn="(max-width: 719px)",qh="(max-width: 1079px)",Zh=`${xn}, (pointer: coarse)`,Jh=[8,18,30,42,88],No=`
|
|
1265
1269
|
.bim-rh { color: ${i("ink")}; font-family: ${i("font-ui")}; font-size: 14px; line-height: 1.6; }
|
|
1266
1270
|
.bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
|
|
1267
1271
|
.bim-rh a { color: ${i("accent")}; text-decoration: none; }
|
|
@@ -1409,7 +1413,7 @@ ${ee??""}`,load:Ae,files:Q,activeFile:ye??null,activeJuan:(ze==null?void 0:ze.js
|
|
|
1409
1413
|
flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
|
|
1410
1414
|
color: ${i("ink")} !important; font-size: 13px;
|
|
1411
1415
|
}
|
|
1412
|
-
${
|
|
1416
|
+
${Jh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${i("accent")} ${t}%, ${i("card-bg")}); }`).join(`
|
|
1413
1417
|
`)}
|
|
1414
1418
|
.bim-rh-band a[data-k="4"] { color: ${i("page-bg")} !important; }
|
|
1415
1419
|
.bim-rh-band a:hover { outline: 2px solid ${i("ink")}; outline-offset: -2px; }
|
|
@@ -1437,13 +1441,13 @@ ${Bh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1437
1441
|
}
|
|
1438
1442
|
|
|
1439
1443
|
/* ── 中屏 ── */
|
|
1440
|
-
@media ${
|
|
1444
|
+
@media ${qh} {
|
|
1441
1445
|
.bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1442
1446
|
.bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1443
1447
|
}
|
|
1444
1448
|
|
|
1445
1449
|
/* ── 手机 ── */
|
|
1446
|
-
@media ${
|
|
1450
|
+
@media ${xn} {
|
|
1447
1451
|
.bim-rh-main { padding-top: 24px; }
|
|
1448
1452
|
.bim-rh-stats { gap: 4px 18px; }
|
|
1449
1453
|
.bim-rh-stats b { font-size: 16px; }
|
|
@@ -1480,7 +1484,7 @@ ${Bh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1480
1484
|
}
|
|
1481
1485
|
|
|
1482
1486
|
/* 触屏或窄屏:点击目标放大到 44px */
|
|
1483
|
-
@media ${
|
|
1487
|
+
@media ${Zh} {
|
|
1484
1488
|
.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; }
|
|
1485
1489
|
.bim-rh-chip { display: inline-flex; }
|
|
1486
1490
|
}
|
|
@@ -1491,7 +1495,7 @@ ${Bh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1491
1495
|
}
|
|
1492
1496
|
|
|
1493
1497
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1494
|
-
`,Mh=Pi["zh-Hant"].period,ya={read:t=>`/read/${encodeURIComponent(t)}`,node:t=>`/read?node=${encodeURIComponent(t)}`,period:t=>`/read?period=${encodeURIComponent(t)}`,work:t=>`/item/${encodeURIComponent(t)}`};function yt(t){return{...ya,...t??{}}}function Co(t){var o;const n=(o=t.authors)==null?void 0:o.find(r=>r==null?void 0:r.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Vn(t){return(t.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function ja(t,n=Pi["zh-Hant"].shelfOther){var s;const o=[],r=new Map;for(const l of t){const a=((s=l.period_of)==null?void 0:s.trim())||n;let d=r.get(a);d||(d={label:a,items:[]},r.set(a,d),o.push(d)),d.items.push(l)}return o}function va(t){return Math.max(150,Array.from(t).length*18+44)}function ka(t,n){if(n<=0||t<=0)return 0;const o=t/n;return o<.15?0:o<.35?1:o<.6?2:o<.85?3:4}const wa=.04;function De(t){return t.toLocaleString("en-US")}function Sa({text:t}){return e.jsx(e.Fragment,{children:Array.from(t).map((n,o)=>e.jsx("span",{children:n},o))})}function Je({id:t,title:n,sub:o,more:r,children:s}){const{convert:l}=K(),a=`${t}-h`;return e.jsxs("section",{className:"bim-rh-sec",id:t,"aria-labelledby":a,children:[e.jsxs("div",{className:"bim-rh-hd",children:[e.jsx("h2",{id:a,children:l(n)}),o&&e.jsx("span",{className:"bim-rh-sub",children:o}),r]}),e.jsx("div",{className:"bim-rh-bd",children:s})]})}function $a({counts:t}){const{t:n}=K();return e.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[e.jsxs("span",{children:[e.jsx("b",{children:De(t.readable)}),n("readHome.readable")]}),t.pieces>0&&e.jsxs("span",{children:[e.jsx("b",{children:De(t.pieces)}),n("readHome.pieces")]})]})}function _a({picks:t,links:n}){const{t:o,convert:r}=K(),s=yt(n);return t.length?e.jsx("ul",{className:"bim-rh-picks",children:t.map(l=>{const a=Vn(l),d=[l.type_label,l.edition].filter(Boolean).join(" · ");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-pk",href:s.read(l.id),children:[e.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:e.jsx(Sa,{text:r(l.slip||l.title)})}),e.jsxs("span",{className:"bim-rh-pk-body",children:[d&&e.jsx("span",{className:"bim-rh-badge",children:r(d)}),e.jsx("h3",{children:r(l.title)}),a&&e.jsx("span",{className:"bim-rh-by",children:r(a)}),l.blurb&&e.jsx("p",{children:r(l.blurb)}),e.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:o("readHome.startReading")})]})]})},l.id)})}):null}function Ca(t,n){return t&&t>1?n("readHome.nCopies",{n:t}):null}function zo({topic:t,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:l}){const{t:a,convert:d}=K(),c=yt(n);if(!t.items.length)return null;const p=r===void 0?a("readHome.shelfLegendCount"):r,u=ja(t.items,a("readHome.shelfOther")),g=m=>{const h=m.records?De(m.records):Ca(m.text_count,a),f=Co(m),v=[d(m.title),m.orig?a("readHome.origZhi"):"",f?a("readHome.spineBy",{name:d(f)}):"",m.records?a("readHome.spineRecords",{n:h}):h?a("readHome.spineOnSite",{n:h}):""].filter(Boolean).join(",");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":v,title:v,style:{height:va(m.title)},children:[e.jsx(Sa,{text:d(m.title)}),h&&e.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:h})]})},m.id)};return e.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&e.jsxs("h3",{className:"bim-rh-gt",children:[d(t.label),e.jsx("small",{children:o?d(o):a("readHome.shelfHint")})]}),e.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":a("readHome.shelfRegion",{label:d(t.label)}),children:e.jsx("ul",{className:"bim-rh-shelf",children:u.map(m=>e.jsxs("li",{className:"bim-rh-era",children:[e.jsx("ul",{className:"bim-rh-spines","aria-label":d(m.label),children:m.items.map(g)}),e.jsx("span",{"aria-hidden":"true",children:d(m.label)})]},m.label))})}),e.jsxs("p",{className:"bim-rh-legend",children:[e.jsxs("span",{children:[e.jsx("i",{"data-orig":"","aria-hidden":"true"}),a("readHome.origZhi")]}),e.jsxs("span",{children:[e.jsx("i",{"aria-hidden":"true"}),a("readHome.laterZhi")]}),p&&e.jsx("span",{children:d(p)}),l==null?void 0:l.map(m=>e.jsx("span",{children:d(m)},m))]})]})}const Wh=4,sn=t=>t>Wh+1;function za({topic:t,links:n}){const{t:o,convert:r}=K(),s=yt(n),[l,a]=x.useState(!1);if(!t.items.length)return null;const d=`bim-rh-g-${t.key}`;return e.jsxs("div",{className:"bim-rh-grp","data-cap":sn(t.items.length)?"":void 0,"data-open":l?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",id:d,children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nWorks",{n:De(t.items.length)})})]}),e.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:t.items.map(c=>{const p=Ca(c.text_count,o),u=Co(c);return e.jsx("li",{children:e.jsxs("a",{href:s.read(c.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(c.title)}),p&&e.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),u&&e.jsx("small",{children:r(u)})]})},c.id)})}),sn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":l,onClick:()=>a(c=>!c),children:l?o("action.collapse"):o("readHome.allNWorks",{n:t.items.length})})]})}function Ta({topics:t,links:n}){const o=t.filter(s=>s.shelf&&s.items.length),r=t.filter(s=>!s.shelf&&s.items.length);return!o.length&&!r.length?null:e.jsxs(e.Fragment,{children:[o.map(s=>e.jsx(zo,{topic:s,links:n},s.key)),r.length>0&&e.jsx("div",{className:"bim-rh-groups",children:r.map(s=>e.jsx(za,{topic:s,links:n},s.key))})]})}function Na({famous:t,links:n}){const{t:o,convert:r}=K(),s=yt(n);return t.length?e.jsx("ul",{className:"bim-rh-works",children:t.map(l=>e.jsx("li",{children:e.jsxs("article",{className:"bim-rh-wk",children:[e.jsxs("div",{className:"bim-rh-wk-h",children:[e.jsx("h3",{children:r(l.title)}),l.authors&&e.jsx("span",{className:"bim-rh-by",children:r(l.authors)}),e.jsx("span",{className:"bim-rh-c bim-rh-num",children:o("readHome.nCopiesCard",{n:l.text_count})})]}),l.systems.map((a,d)=>e.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":a.label?r(a.label):void 0,children:[a.label&&e.jsx("small",{"aria-hidden":"true",children:r(a.label)}),a.items.map(c=>e.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:r([c.title,c.edition].filter(Boolean).join(" · ")),children:r(c.short)},c.id))]},d)),l.work_id&&e.jsx("div",{className:"bim-rh-wk-f",children:e.jsx("a",{href:s.work(l.work_id),children:o("readHome.workPageLink",{title:r(l.title)})})})]})},l.work_id??l.title))}):null}function To({bu:t,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:l}=K(),a=yt(o);return!t.length&&!n?null:e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-bu",children:t.map(d=>{var p;const c=((p=d.top[0])==null?void 0:p.count)||1;return e.jsxs("li",{className:"bim-rh-bu-c",children:[e.jsxs("a",{className:"bim-rh-bu-h",href:a.node(d.id),children:[e.jsx("b",{children:l(d.label)}),e.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:De(d.count)})})]}),d.top.length>0&&e.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:l(d.label)}),children:d.top.map(u=>e.jsx("li",{children:e.jsxs("a",{href:a.node(u.id),children:[e.jsx("span",{children:l(u.label)}),e.jsx("small",{className:"bim-rh-num",children:De(u.count)}),e.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(u.count/c*100)}%`}})]})},u.id))}),d.children_total>d.top.length&&e.jsx("a",{className:"bim-rh-bu-more",href:a.node(d.id),children:s("readHome.allNClasses",{label:l(d.label),n:d.children_total})})]},d.id)})}),!!n&&e.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[e.jsx("b",{children:s("readHome.unclassified")}),e.jsx("span",{children:s("readHome.nWorks",{n:De(n)})}),e.jsx("span",{children:r?l(r):s("readHome.sibuUnclassifiedNote")}),e.jsx("a",{href:a.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Ia({periods:t,unknown:n,links:o}){const{t:r,convert:s,messages:l}=K(),a=l.readHome.period,d=yt(o),c=t.filter(g=>g.count>0);if(!c.length)return null;const p=c.reduce((g,m)=>g+m.count,0),u=Math.max(...c.map(g=>g.count));return e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-band",children:c.map(g=>{const m=g.label?s(g.label):a[g.key]??s(g.key),h=g.count/p,f=r("readHome.periodItem",{label:m,n:De(g.count)});return e.jsx("li",{style:{flex:`0 0 ${(h*100).toFixed(3)}%`},children:e.jsxs("a",{href:d.period(g.key),"data-k":ka(g.count,u),"data-narrow":h<wa?"":void 0,"aria-label":f,title:f,children:[e.jsx("span",{className:"bim-rh-pl",children:m}),e.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),e.jsx("small",{className:"bim-rh-num",children:De(g.count)})]})},g.key)})}),e.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&e.jsx("span",{children:r("readHome.periodUnknown",{n:De(n)})}),e.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function Ea({authors:t,links:n}){const{t:o,convert:r}=K(),s=yt(n);return t.length?e.jsx("ul",{className:"bim-rh-authors",children:t.map(l=>e.jsxs("li",{className:"bim-rh-au",children:[e.jsxs("h3",{className:"bim-rh-au-h",children:[r(l.name),l.dynasty&&e.jsx("span",{children:r(l.dynasty)}),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nPieces",{n:De(l.count)})})]}),e.jsx("ul",{children:l.items.map(a=>e.jsx("li",{children:e.jsx("a",{href:s.read(a.id),children:r(a.title)})},a.id))}),s.author&&e.jsx("a",{className:"bim-rh-more",href:s.author(l.name),children:o("readHome.authorAll",{name:r(l.name),n:l.count})})]},l.name))}):null}const Ra={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function Hh({sections:t,links:n,head:o,piecesMoreHref:r,className:s}){const{t:l}=K(),a=t,d=Ra,c=a.topics.filter(m=>!m.shelf),p={picks:a.picks.length>0,topics:c.some(m=>m.items.length>0),famous:a.famous.length>0,sibu:a.bu.length>0||a.unclassified>0,period:a.periods.some(m=>m.count>0),pieces:a.pieces.authors.length>0},u=Object.keys(d).filter(m=>p[m]),g=m=>l(`readHome.nav.${m}`);return e.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[e.jsx("style",{children:_o}),e.jsxs("div",{className:"bim-rh-head",children:[o,e.jsx($a,{counts:a.counts})]}),u.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":l("readHome.navLabel"),children:e.jsx("ul",{children:u.map(m=>e.jsx("li",{children:e.jsx("a",{href:`#${d[m]}`,children:g(m)})},m))})}),e.jsxs("div",{className:"bim-rh-main",children:[p.picks&&e.jsx(Je,{id:d.picks,title:g("picks"),sub:l("readHome.picksSub"),children:e.jsx(_a,{picks:a.picks,links:n})}),p.topics&&e.jsx(Je,{id:d.topics,title:g("topics"),sub:l("readHome.topicsSub"),children:e.jsx(Ta,{topics:c,links:n})}),p.famous&&e.jsx(Je,{id:d.famous,title:g("famous"),sub:l("readHome.famousSub"),children:e.jsx(Na,{famous:a.famous,links:n})}),p.sibu&&e.jsx(Je,{id:d.sibu,title:g("sibu"),sub:l("readHome.sibuSub"),children:e.jsx(To,{bu:a.bu,unclassified:a.unclassified,links:n})}),p.period&&e.jsx(Je,{id:d.period,title:g("period"),sub:l("readHome.periodSub"),children:e.jsx(Ia,{periods:a.periods,unknown:a.period_unknown,links:n})}),p.pieces&&e.jsx(Je,{id:d.pieces,title:g("pieces"),sub:l("readHome.piecesSub"),more:r?e.jsx("a",{className:"bim-rh-more",href:r,children:l("readHome.piecesMore")}):void 0,children:e.jsx(Ea,{authors:a.pieces.authors,links:n})})]})]})}const Oh="(max-width: 1079px)",Fh=`${mn}, (pointer: coarse)`,La=`
|
|
1498
|
+
`,Xh=Wi["zh-Hant"].period,$a={read:t=>`/read/${encodeURIComponent(t)}`,node:t=>`/read?node=${encodeURIComponent(t)}`,period:t=>`/read?period=${encodeURIComponent(t)}`,work:t=>`/item/${encodeURIComponent(t)}`};function vt(t){return{...$a,...t??{}}}function Io(t){var o;const n=(o=t.authors)==null?void 0:o.find(r=>r==null?void 0:r.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Kn(t){return(t.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function _a(t,n=Wi["zh-Hant"].shelfOther){var s;const o=[],r=new Map;for(const l of t){const a=((s=l.period_of)==null?void 0:s.trim())||n;let p=r.get(a);p||(p={label:a,items:[]},r.set(a,p),o.push(p)),p.items.push(l)}return o}function Ca(t){return Math.max(150,Array.from(t).length*18+44)}function za(t,n){if(n<=0||t<=0)return 0;const o=t/n;return o<.15?0:o<.35?1:o<.6?2:o<.85?3:4}const Ta=.04;function Ue(t){return t.toLocaleString("en-US")}function Na({text:t}){return e.jsx(e.Fragment,{children:Array.from(t).map((n,o)=>e.jsx("span",{children:n},o))})}function et({id:t,title:n,sub:o,more:r,children:s}){const{convert:l}=G(),a=`${t}-h`;return e.jsxs("section",{className:"bim-rh-sec",id:t,"aria-labelledby":a,children:[e.jsxs("div",{className:"bim-rh-hd",children:[e.jsx("h2",{id:a,children:l(n)}),o&&e.jsx("span",{className:"bim-rh-sub",children:o}),r]}),e.jsx("div",{className:"bim-rh-bd",children:s})]})}function Ia({counts:t}){const{t:n}=G();return e.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[e.jsxs("span",{children:[e.jsx("b",{children:Ue(t.readable)}),n("readHome.readable")]}),t.pieces>0&&e.jsxs("span",{children:[e.jsx("b",{children:Ue(t.pieces)}),n("readHome.pieces")]})]})}function Ra({picks:t,links:n}){const{t:o,convert:r}=G(),s=vt(n);return t.length?e.jsx("ul",{className:"bim-rh-picks",children:t.map(l=>{const a=Kn(l),p=[l.type_label,l.edition].filter(Boolean).join(" · ");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-pk",href:s.read(l.id),children:[e.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:e.jsx(Na,{text:r(l.slip||l.title)})}),e.jsxs("span",{className:"bim-rh-pk-body",children:[p&&e.jsx("span",{className:"bim-rh-badge",children:r(p)}),e.jsx("h3",{children:r(l.title)}),a&&e.jsx("span",{className:"bim-rh-by",children:r(a)}),l.blurb&&e.jsx("p",{children:r(l.blurb)}),e.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:o("readHome.startReading")})]})]})},l.id)})}):null}function Ea(t,n){return t&&t>1?n("readHome.nCopies",{n:t}):null}function Ro({topic:t,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:l}){const{t:a,convert:p}=G(),c=vt(n);if(!t.items.length)return null;const d=r===void 0?a("readHome.shelfLegendCount"):r,u=_a(t.items,a("readHome.shelfOther")),g=m=>{const h=m.records?Ue(m.records):Ea(m.text_count,a),f=Io(m),v=[p(m.title),m.orig?a("readHome.origZhi"):"",f?a("readHome.spineBy",{name:p(f)}):"",m.records?a("readHome.spineRecords",{n:h}):h?a("readHome.spineOnSite",{n:h}):""].filter(Boolean).join(",");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-spine",href:c.read(m.id),"data-orig":m.orig?"":void 0,"aria-label":v,title:v,style:{height:Ca(m.title)},children:[e.jsx(Na,{text:p(m.title)}),h&&e.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:h})]})},m.id)};return e.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&e.jsxs("h3",{className:"bim-rh-gt",children:[p(t.label),e.jsx("small",{children:o?p(o):a("readHome.shelfHint")})]}),e.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":a("readHome.shelfRegion",{label:p(t.label)}),children:e.jsx("ul",{className:"bim-rh-shelf",children:u.map(m=>e.jsxs("li",{className:"bim-rh-era",children:[e.jsx("ul",{className:"bim-rh-spines","aria-label":p(m.label),children:m.items.map(g)}),e.jsx("span",{"aria-hidden":"true",children:p(m.label)})]},m.label))})}),e.jsxs("p",{className:"bim-rh-legend",children:[e.jsxs("span",{children:[e.jsx("i",{"data-orig":"","aria-hidden":"true"}),a("readHome.origZhi")]}),e.jsxs("span",{children:[e.jsx("i",{"aria-hidden":"true"}),a("readHome.laterZhi")]}),d&&e.jsx("span",{children:p(d)}),l==null?void 0:l.map(m=>e.jsx("span",{children:p(m)},m))]})]})}const Qh=4,cn=t=>t>Qh+1;function La({topic:t,links:n}){const{t:o,convert:r}=G(),s=vt(n),[l,a]=x.useState(!1);if(!t.items.length)return null;const p=`bim-rh-g-${t.key}`;return e.jsxs("div",{className:"bim-rh-grp","data-cap":cn(t.items.length)?"":void 0,"data-open":l?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",id:p,children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nWorks",{n:Ue(t.items.length)})})]}),e.jsx("ul",{className:"bim-rh-rows","aria-labelledby":p,children:t.items.map(c=>{const d=Ea(c.text_count,o),u=Io(c);return e.jsx("li",{children:e.jsxs("a",{href:s.read(c.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(c.title)}),d&&e.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:d}),u&&e.jsx("small",{children:r(u)})]})},c.id)})}),cn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":l,onClick:()=>a(c=>!c),children:l?o("action.collapse"):o("readHome.allNWorks",{n:t.items.length})})]})}function Pa({topics:t,links:n}){const o=t.filter(s=>s.shelf&&s.items.length),r=t.filter(s=>!s.shelf&&s.items.length);return!o.length&&!r.length?null:e.jsxs(e.Fragment,{children:[o.map(s=>e.jsx(Ro,{topic:s,links:n},s.key)),r.length>0&&e.jsx("div",{className:"bim-rh-groups",children:r.map(s=>e.jsx(La,{topic:s,links:n},s.key))})]})}function Aa({famous:t,links:n}){const{t:o,convert:r}=G(),s=vt(n);return t.length?e.jsx("ul",{className:"bim-rh-works",children:t.map(l=>e.jsx("li",{children:e.jsxs("article",{className:"bim-rh-wk",children:[e.jsxs("div",{className:"bim-rh-wk-h",children:[e.jsx("h3",{children:r(l.title)}),l.authors&&e.jsx("span",{className:"bim-rh-by",children:r(l.authors)}),e.jsx("span",{className:"bim-rh-c bim-rh-num",children:o("readHome.nCopiesCard",{n:l.text_count})})]}),l.systems.map((a,p)=>e.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":a.label?r(a.label):void 0,children:[a.label&&e.jsx("small",{"aria-hidden":"true",children:r(a.label)}),a.items.map(c=>e.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:r([c.title,c.edition].filter(Boolean).join(" · ")),children:r(c.short)},c.id))]},p)),l.work_id&&e.jsx("div",{className:"bim-rh-wk-f",children:e.jsx("a",{href:s.work(l.work_id),children:o("readHome.workPageLink",{title:r(l.title)})})})]})},l.work_id??l.title))}):null}function Eo({bu:t,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:l}=G(),a=vt(o);return!t.length&&!n?null:e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-bu",children:t.map(p=>{var d;const c=((d=p.top[0])==null?void 0:d.count)||1;return e.jsxs("li",{className:"bim-rh-bu-c",children:[e.jsxs("a",{className:"bim-rh-bu-h",href:a.node(p.id),children:[e.jsx("b",{children:l(p.label)}),e.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ue(p.count)})})]}),p.top.length>0&&e.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:l(p.label)}),children:p.top.map(u=>e.jsx("li",{children:e.jsxs("a",{href:a.node(u.id),children:[e.jsx("span",{children:l(u.label)}),e.jsx("small",{className:"bim-rh-num",children:Ue(u.count)}),e.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(u.count/c*100)}%`}})]})},u.id))}),p.children_total>p.top.length&&e.jsx("a",{className:"bim-rh-bu-more",href:a.node(p.id),children:s("readHome.allNClasses",{label:l(p.label),n:p.children_total})})]},p.id)})}),!!n&&e.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[e.jsx("b",{children:s("readHome.unclassified")}),e.jsx("span",{children:s("readHome.nWorks",{n:Ue(n)})}),e.jsx("span",{children:r?l(r):s("readHome.sibuUnclassifiedNote")}),e.jsx("a",{href:a.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Ba({periods:t,unknown:n,links:o}){const{t:r,convert:s,messages:l}=G(),a=l.readHome.period,p=vt(o),c=t.filter(g=>g.count>0);if(!c.length)return null;const d=c.reduce((g,m)=>g+m.count,0),u=Math.max(...c.map(g=>g.count));return e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-band",children:c.map(g=>{const m=g.label?s(g.label):a[g.key]??s(g.key),h=g.count/d,f=r("readHome.periodItem",{label:m,n:Ue(g.count)});return e.jsx("li",{style:{flex:`0 0 ${(h*100).toFixed(3)}%`},children:e.jsxs("a",{href:p.period(g.key),"data-k":za(g.count,u),"data-narrow":h<Ta?"":void 0,"aria-label":f,title:f,children:[e.jsx("span",{className:"bim-rh-pl",children:m}),e.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),e.jsx("small",{className:"bim-rh-num",children:Ue(g.count)})]})},g.key)})}),e.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&e.jsx("span",{children:r("readHome.periodUnknown",{n:Ue(n)})}),e.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function Ma({authors:t,links:n}){const{t:o,convert:r}=G(),s=vt(n);return t.length?e.jsx("ul",{className:"bim-rh-authors",children:t.map(l=>e.jsxs("li",{className:"bim-rh-au",children:[e.jsxs("h3",{className:"bim-rh-au-h",children:[r(l.name),l.dynasty&&e.jsx("span",{children:r(l.dynasty)}),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nPieces",{n:Ue(l.count)})})]}),e.jsx("ul",{children:l.items.map(a=>e.jsx("li",{children:e.jsx("a",{href:s.read(a.id),children:r(a.title)})},a.id))}),s.author&&e.jsx("a",{className:"bim-rh-more",href:s.author(l.name),children:o("readHome.authorAll",{name:r(l.name),n:l.count})})]},l.name))}):null}const Wa={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function ex({sections:t,links:n,head:o,piecesMoreHref:r,className:s}){const{t:l}=G(),a=t,p=Wa,c=a.topics.filter(m=>!m.shelf),d={picks:a.picks.length>0,topics:c.some(m=>m.items.length>0),famous:a.famous.length>0,sibu:a.bu.length>0||a.unclassified>0,period:a.periods.some(m=>m.count>0),pieces:a.pieces.authors.length>0},u=Object.keys(p).filter(m=>d[m]),g=m=>l(`readHome.nav.${m}`);return e.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[e.jsx("style",{children:No}),e.jsxs("div",{className:"bim-rh-head",children:[o,e.jsx(Ia,{counts:a.counts})]}),u.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":l("readHome.navLabel"),children:e.jsx("ul",{children:u.map(m=>e.jsx("li",{children:e.jsx("a",{href:`#${p[m]}`,children:g(m)})},m))})}),e.jsxs("div",{className:"bim-rh-main",children:[d.picks&&e.jsx(et,{id:p.picks,title:g("picks"),sub:l("readHome.picksSub"),children:e.jsx(Ra,{picks:a.picks,links:n})}),d.topics&&e.jsx(et,{id:p.topics,title:g("topics"),sub:l("readHome.topicsSub"),children:e.jsx(Pa,{topics:c,links:n})}),d.famous&&e.jsx(et,{id:p.famous,title:g("famous"),sub:l("readHome.famousSub"),children:e.jsx(Aa,{famous:a.famous,links:n})}),d.sibu&&e.jsx(et,{id:p.sibu,title:g("sibu"),sub:l("readHome.sibuSub"),children:e.jsx(Eo,{bu:a.bu,unclassified:a.unclassified,links:n})}),d.period&&e.jsx(et,{id:p.period,title:g("period"),sub:l("readHome.periodSub"),children:e.jsx(Ba,{periods:a.periods,unknown:a.period_unknown,links:n})}),d.pieces&&e.jsx(et,{id:p.pieces,title:g("pieces"),sub:l("readHome.piecesSub"),more:r?e.jsx("a",{className:"bim-rh-more",href:r,children:l("readHome.piecesMore")}):void 0,children:e.jsx(Ma,{authors:a.pieces.authors,links:n})})]})]})}const tx="(max-width: 1079px)",nx=`${xn}, (pointer: coarse)`,Ha=`
|
|
1495
1499
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1496
1500
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1497
1501
|
.bim-mh-q { min-width: 0; }
|
|
@@ -1631,7 +1635,7 @@ ${Bh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1631
1635
|
.bim-mh-cc0 { display: inline-block; margin-right: 8px; padding: 1px 7px; font-size: 11.5px; letter-spacing: 0.08em; background: ${i("check-fine-bg")}; color: ${i("check-fine-fg")}; }
|
|
1632
1636
|
|
|
1633
1637
|
/* ── 中屏 ── */
|
|
1634
|
-
@media ${
|
|
1638
|
+
@media ${tx} {
|
|
1635
1639
|
.bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
|
|
1636
1640
|
.bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1637
1641
|
.bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
@@ -1641,7 +1645,7 @@ ${Bh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1641
1645
|
}
|
|
1642
1646
|
|
|
1643
1647
|
/* ── 手机 ── */
|
|
1644
|
-
@media ${
|
|
1648
|
+
@media ${xn} {
|
|
1645
1649
|
.bim-mh-cg, .bim-mh-data { grid-template-columns: minmax(0, 1fr); }
|
|
1646
1650
|
.bim-mh-ge { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
1647
1651
|
.bim-mh-lin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
@@ -1658,8 +1662,8 @@ ${Bh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1658
1662
|
.bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
|
|
1659
1663
|
}
|
|
1660
1664
|
|
|
1661
|
-
@media ${
|
|
1665
|
+
@media ${nx} {
|
|
1662
1666
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
1663
1667
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
1664
1668
|
}
|
|
1665
|
-
`,Pa={item:t=>`/item/${encodeURIComponent(t)}`,node:t=>`/catalog?node=${encodeURIComponent(t)}`};function jt(t){return{...Pa,...t??{}}}function No(t,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(t/n*100)))}function Aa(t){const n=t.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),o=t.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:o};const r=p=>{const u=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,g=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(u,g),Math.max(u,g)]},s=n.map(r),l=Math.min(...s.map(p=>p[0])),a=Math.max(...s.map(p=>p[1])),d=Math.max(1,a-l),c=n.map((p,u)=>({p,from:s[u][0],to:s[u][1]})).sort((p,u)=>p.from-u.from).map(p=>({...p,left:(p.from-l)/d*100,width:Math.max(.8,(p.to-p.from)/d*100)}));return{min:l,max:a,placed:c,missing:o}}function Tn(t,n=Ht("zh-Hant")){return t<0?n("metaHome.yearBC",{n:-t}):String(t)}function Dh(t){return{read:t.item,work:t.item,node:t.node}}function Ba({counts:t,links:n}){const{t:o}=K(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),t.works],["book",o("metaHome.typeLabel.book"),t.books],["collection",o("metaHome.typeLabel.collection"),t.collections],["entity",o("metaHome.typeLabel.entity"),t.entities]];return e.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([l,a,d])=>e.jsx("li",{children:e.jsxs("a",{href:r(l),children:[e.jsx("b",{children:a}),d!=null&&d>0&&e.jsx("small",{children:De(d)})]})},l))})}function Ma(t,n=5){const[o,r]=x.useState(null);x.useEffect(()=>{let l=!1;const a=bt().slice(0,n);if(!a.length||!t){r([]);return}return Promise.all(a.map(d=>Di(t,d))).then(d=>{l||r(d.filter(c=>!c.notFound))}),()=>{l=!0}},[t,n]);const s=x.useCallback(()=>{Fi(),r([])},[]);return{entries:o,clear:s}}function Uh(t,n,o){const r=t.type==="book"?t.edition||t.era:t.type==="collection"?"":t.dynasty;return r?o(r):Wa(t.type,n)}function Wa(t,n){return n(`metaHome.typeLabel.${t}`)}function Ha({entries:t,onClear:n,links:o}){const{t:r,convert:s}=K(),l=jt(o);return e.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[e.jsxs("div",{className:"bim-mh-recent-h",children:[e.jsx("h2",{id:"bim-mh-recent-h",children:r("metaHome.recentTitle")}),t&&t.length>0&&n&&e.jsx("button",{type:"button",onClick:n,children:r("metaHome.recentClear")})]}),t&&t.length>0&&e.jsx("ol",{children:t.map(a=>e.jsx("li",{children:e.jsxs("a",{href:l.item(a.id),"aria-label":r("metaHome.recentItemLabel",{type:a.type?Wa(a.type,r):"",title:s(a.title)}),children:[e.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:a.type?r(`metaHome.typeShort.${a.type}`):""}),e.jsx("span",{children:s(a.title)}),e.jsx("small",{"aria-hidden":"true",children:Uh(a,r,s)})]})},a.id))}),t&&t.length===0&&e.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function Oa(t,n,o,r=!1){return r&&(t==="done"||t==="in_progress")?n(`metaHome.siteStatus.${t}`):t==="done"||t==="in_progress"||t==="todo"?n(`metaHome.status.${t}`):o(t)}function Fa({rows:t,links:n}){const{t:o,convert:r}=K(),s=jt(n);return t.length?e.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":o("metaHome.catalogTitle"),children:e.jsxs("table",{className:"bim-mh-tbl",children:[e.jsxs("caption",{children:[o("metaHome.catalogTitle"),e.jsx("small",{children:o("metaHome.catalogNote")})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:o("metaHome.colCatalog")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colRecords")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colMatched")}),e.jsx("th",{scope:"col",children:o("metaHome.colProgress")}),e.jsx("th",{scope:"col",children:o("metaHome.colStatus")})]})}),e.jsx("tbody",{children:t.map(l=>{const a=No(l.imported,l.total),d=l.work_id??l.collection_id,c=r(l.edition?`${l.name}·${l.edition}`:l.name);return e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:d?e.jsx("a",{href:s.item(d),children:c}):c}),e.jsx("td",{className:"bim-mh-r",children:De(l.total)}),e.jsx("td",{className:"bim-mh-r",children:De(l.imported)}),e.jsx("td",{children:e.jsxs("span",{className:"bim-mh-meter",children:[e.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[a,"%"]})]})}),e.jsx("td",{children:l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:Oa(l.status,o,r)})})]},l.id||l.name)})})]})}):null}function Da({items:t,links:n,label:o}){const{convert:r}=K();return e.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):void 0,children:t.map(s=>e.jsx("li",{children:e.jsxs("a",{href:n.item(s.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(s.title)}),s.sub&&e.jsx("small",{children:r(s.sub)})]})},s.id))})}function Ua({works:t,links:n}){const{t:o}=K(),[r,s]=x.useState(!1);if(!t.length)return null;const l=sn(t.length);return e.jsxs("div",{className:"bim-rh-grp","data-cap":l?"":void 0,"data-open":r?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[o("metaHome.relatedTitle"),e.jsx("small",{children:o("metaHome.relatedNote")})]}),e.jsx(Da,{items:t.map(a=>({id:a.id,title:a.title,sub:Vn(a)||void 0})),links:jt(n)}),l&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":r,onClick:()=>s(a=>!a),children:r?o("action.collapse"):o("metaHome.allNWorks",{n:t.length})})]})}const Va="siku_qige";function Vh({group:t,links:n}){const{t:o,convert:r}=K(),[s,l]=x.useState(!1);return e.jsxs("div",{className:"bim-rh-grp","data-cap":sn(t.items.length)?"":void 0,"data-open":s?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("metaHome.nKinds",{n:t.items.length})})]}),e.jsx(Da,{items:t.items,links:n,label:t.label}),sn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>l(a=>!a),children:s?o("action.collapse"):o("metaHome.allNKinds",{n:t.items.length})})]})}function Ga({groups:t,links:n}){const{t:o,convert:r}=K(),s=jt(n);if(!t.length)return null;const l=t.find(c=>c.key===Va),a=t.filter(c=>c!==l),d=c=>{var p;return((p=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:p[1])??c};return e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(l.label),e.jsx("small",{children:r(l.items.map(c=>d(c.title)).join("、"))})]}),e.jsx("ul",{className:"bim-mh-ge","aria-label":r(l.label),children:l.items.map(c=>e.jsx("li",{children:e.jsxs("a",{href:s.item(c.id),"aria-label":r(c.title),title:r(c.title),children:[e.jsx("span",{"aria-hidden":"true",children:r(d(c.title))}),d(c.title)!==c.title&&e.jsx("small",{"aria-hidden":"true",children:o("metaHome.pavilion")})]})},c.id))})]}),a.length>0&&e.jsx("div",{className:"bim-mh-cg",style:l?void 0:{marginTop:0},children:a.map(c=>e.jsx(Vh,{group:c,links:s},c.key))})]})}const Qr=34,es=13;function ts(t,n){return t.birth_year==null&&t.death_year==null?"":`${t.birth_year!=null?Tn(t.birth_year,n):"?"}–${t.death_year!=null?Tn(t.death_year,n):"?"}`}function Gh(t,n){const o=n-t,r=o>1200?300:o>400?100:50,s=[];for(let l=Math.ceil(t/r)*r;l<=n;l+=r)s.push(l);return s}function Ya({people:t,links:n}){const{t:o,convert:r}=K(),s=jt(n);if(!t.length)return null;const{min:l,max:a,placed:d,missing:c}=Aa(t),p=[],u=d.map(m=>{const h=m.left>70,f=h?Math.min(m.left,m.left+m.width-es):m.left;let v=0;for(;p[v]!=null&&p[v]>f;)v++;return p[v]=h?m.left+m.width:m.left+Math.max(m.width,es),{...m,lane:v,end:h}}),g=Math.max(1,a-l);return e.jsxs(e.Fragment,{children:[u.length>0&&e.jsxs("div",{className:"bim-mh-tl",children:[e.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Qr+10},children:u.map(m=>e.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*Qr+4,width:`${Math.max(m.width,.5)}%`},children:[e.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),e.jsxs("a",{href:s.item(m.p.id),children:[r(m.p.name),e.jsx("small",{className:"bim-rh-num",children:ts(m.p,o)})]})]},m.p.id))}),e.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Gh(l,a).map(m=>e.jsx("span",{style:{left:`${(m-l)/g*100}%`},children:Tn(m,o)},m))})]}),e.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?t:c).map(m=>e.jsx("li",{children:e.jsxs("a",{href:s.item(m.id),children:[e.jsx("span",{children:r(m.name)}),e.jsx("small",{className:"bim-rh-num",children:[m.dynasty?r(m.dynasty):"",ts(m,o)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&u.length>0&&e.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(m=>m.name).join("、"))})})]})}const Yh=e.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[e.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),e.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),e.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function Ka({works:t,links:n}){const{t:o,convert:r}=K(),s=jt(n);return t.length?e.jsx("ul",{className:"bim-mh-lin",children:t.map(l=>{const a=Vn(l);return e.jsx("li",{children:e.jsxs("a",{href:s.item(l.id),children:[Yh,e.jsx("b",{children:r(l.title)}),a&&e.jsx("small",{children:r(a)}),e.jsx("span",{children:o("metaHome.viewLineage")})]})},l.id)})}):null}function qa({sites:t}){const{t:n,convert:o}=K(),r=t.filter(l=>l.status!=="todo"&&l.total>0),s=t.filter(l=>!r.includes(l));return t.length?e.jsxs(e.Fragment,{children:[r.length>0&&e.jsx("ul",{className:"bim-mh-cov",children:r.map(l=>{const a=No(l.imported,l.total);return e.jsxs("li",{children:[l.url?e.jsx("a",{href:l.url,rel:"noopener noreferrer",target:"_blank",children:o(l.name)}):e.jsx("span",{children:o(l.name)}),e.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[`${De(l.imported)} / ${De(l.total)} ${a}% `,l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:Oa(l.status,n,o,!0)})]})]},l.id||l.name)})}),s.length>0&&e.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:o(s.map(l=>l.name).join("、"))})})]}):null}const ns=["extant","partially_extant","lost","unknown"];function Za({stats:t,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:l}=K(),a=["works","books","collections","entities","has_image","has_text","article","poem"].map(p=>[t[p],l(`metaHome.stat.${p}`)]).filter(([p])=>p>0),d=n==null?void 0:n.loss,c=ns.some(p=>{var u;return(((u=t.loss)==null?void 0:u[p])??0)>0});return e.jsxs("div",{className:"bim-mh-data",children:[a.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.dataScale")}),e.jsx("ul",{className:"bim-mh-nums",children:a.map(([p,u])=>e.jsxs("li",{children:[e.jsx("b",{className:"bim-rh-num",children:De(p)}),e.jsx("span",{children:u})]},u))})]}),d&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.byLoss")}),e.jsx("ul",{className:"bim-mh-loss",children:ns.map(p=>{var m;const u=((m=t.loss)==null?void 0:m[p])??0,g=l(`metaHome.lossNote.${p}`);return e.jsx("li",{children:e.jsxs("a",{href:d(p),children:[l(`metaHome.loss.${p}`),e.jsx("small",{className:"bim-rh-num",children:c&&u>0?l("metaHome.lossCount",{n:De(u),note:g}):g})]})},p)})})]}),e.jsxs("div",{className:"bim-mh-lic",children:[e.jsxs("p",{children:[e.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),l("metaHome.license")]}),e.jsxs("p",{children:[l("metaHome.repo"),r?e.jsx("a",{href:r,children:e.jsx("code",{children:"book-index"})}):e.jsx("code",{children:"book-index"}),l("metaHome.repoNote")]}),o&&e.jsxs("p",{children:[l("metaHome.version"),e.jsx("code",{children:o})]}),s&&e.jsx("p",{children:e.jsx("a",{href:s,children:l("metaHome.download")})})]})]})}const Ja={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Kh({sections:t,links:n,head:o,transport:r,catalogHref:s,collectionsHref:l,entitiesHref:a,version:d,repoUrl:c,downloadHref:p,className:u}){var S,$;const{t:g}=K(),m=t,h=jt(n),f=Dh(h),v=Ja,y=Ma(r),k={zhi:!!((S=m.shelf)!=null&&S.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(v).filter(_=>k[_]),j=_=>g(`metaHome.nav.${_}`),w=(_,C)=>_?e.jsx("a",{className:"bim-rh-more",href:_,children:C}):void 0;return e.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[e.jsx("style",{children:_o+La}),e.jsxs("div",{className:"bim-mh-head",children:[e.jsxs("div",{className:"bim-mh-q",children:[o,e.jsx(Ba,{counts:m.counts,links:n})]}),r&&e.jsx(Ha,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":g("metaHome.navLabel"),children:e.jsx("ul",{children:b.map(_=>e.jsx("li",{children:e.jsx("a",{href:`#${v[_]}`,children:j(_)})},_))})}),e.jsxs("div",{className:"bim-rh-main",children:[k.zhi&&e.jsxs(Je,{id:v.zhi,title:j("zhi"),sub:g("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&e.jsx(zo,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:f,showTitle:!1,legendCount:m.shelf.items.some(_=>_.records)?g("metaHome.shelfLegendCount"):null,legendExtra:[g("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&e.jsxs("div",{className:"bim-mh-zhi",style:($=m.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[e.jsx(Fa,{rows:m.catalog_progress,links:n}),e.jsx(Ua,{works:m.related_catalogs,links:n})]})]}),k.sibu&&e.jsx(Je,{id:v.sibu,title:j("sibu"),sub:g("metaHome.sibuSub"),more:w(s,g("metaHome.toCatalog")),children:e.jsx(To,{bu:m.bu,unclassified:m.unclassified,links:f,unclassifiedNote:g("metaHome.unclassifiedNote")})}),k.cong&&e.jsx(Je,{id:v.cong,title:j("cong"),sub:g("metaHome.congSub"),more:w(l,g("metaHome.allNKindsMore",{n:De(m.counts.collections)})),children:e.jsx(Ga,{groups:m.collection_groups,links:n})}),k.people&&e.jsx(Je,{id:v.people,title:j("people"),sub:g("metaHome.peopleSub"),more:w(a,g("metaHome.allNPeopleMore",{n:De(m.counts.entities)})),children:e.jsx(Ya,{people:m.bibliographers,links:n})}),k.lineage&&e.jsx(Je,{id:v.lineage,title:j("lineage"),sub:g("metaHome.lineageSub"),children:e.jsx(Ka,{works:m.lineage,links:n})}),k.sites&&e.jsx(Je,{id:v.sites,title:j("sites"),sub:g("metaHome.sitesSub"),children:e.jsx(qa,{sites:m.sites})}),e.jsx(Je,{id:v.data,title:j("data"),sub:g("metaHome.dataSub"),children:e.jsx(Za,{stats:m.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const Ei=({style:t})=>{const n=x.useContext(Tt),{t:o}=K();if(!n)return null;const{locale:r,setLocale:s}=n,l=r==="zh-Hant",a=()=>s(l?"zh-Hans":"zh-Hant");return e.jsxs("button",{type:"button",onClick:a,title:o(l?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${i("border")}`,borderRadius:"4px",background:i("bg"),color:i("fg"),cursor:"pointer",userSelect:"none",...t},children:[e.jsx("span",{style:{color:l?i("primary"):void 0,fontWeight:l?700:400},children:o("common.localeShortHant")}),e.jsx("span",{style:{opacity:.3},children:"/"}),e.jsx("span",{style:{color:l?void 0:i("primary"),fontWeight:l?400:700},children:o("common.localeShortHans")})]})},Ri=({href:t,label:n,size:o=16,className:r,style:s})=>{const{t:l}=K(),a=n??l("common.repoSourceLink");return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:a,"aria-label":a,className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:o+8,height:o+8,borderRadius:4,color:i("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=i("fg")},onMouseLeave:d=>{d.currentTarget.style.color=i("desc-fg")},children:e.jsx("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.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 pi(t){const n=t.text_count;return typeof n=="number"&&n>0}function ui(t,n){return{id:t,title:n.title??n.primary_name??t,type:n.type??"book"}}function qh(t,n){if(!n)return!1;const o=n.id;return o===void 0||o===t}const Zh=({id:t,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:l,activeJuan:a,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:u,onLineageCollectionChange:g,initialPage:m=1,selectedLineageNodeId:h,onNavigate:f,onBack:v,backLabel:y,renderLink:k,enrichDetail:b,getSourceLink:j,readLink:w,railTop:S,extraTabs:$=[],showFeedbackTab:_=!0,feedbackApiUrl:C,height:I,footerExtra:T,hideHeaderControls:z=!1,className:H,style:W})=>{const A=ke(),{t:Y,convert:G}=K(),[te]=x.useState(()=>{if(!qh(t,o))return null;const M={...o},ge=r??ui(t,M);return b&&b(ge,M),{id:t,entry:ge,detail:M}}),[pe,B]=x.useState((te==null?void 0:te.entry)??null),[E,ee]=x.useState((te==null?void 0:te.detail)??null),[L,U]=x.useState(!te),[de,ve]=x.useState(!1),[Z,ce]=x.useState([]),[be,We]=x.useState(!1),[ye,_e]=x.useState(null),[He,Be]=x.useState(null),[Re,ze]=x.useState(null),[Ee,D]=x.useState(!1),ae=x.useRef(null),[le,Se]=x.useState(null),F=a!==void 0?a:le,me=x.useCallback(M=>{d?d(M):Se(M)},[d]),Ae=x.useCallback(async M=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){ce([]);return}We(!0);try{if(n.getCollectionCatalogs)ce(await n.getCollectionCatalogs(M)||[]);else if(n.getCollectionCatalog){const ge=await n.getCollectionCatalog(M);ce(ge?[{resource_id:"",data:ge}]:[])}}catch{ce([])}finally{We(!1)}},[n]),R=x.useCallback(async M=>{var ge,O;if(!n.getTextManifest||!n.getTextIndex){_e(null),Be(M);return}try{const we=he.pickTextVersion(await n.getTextManifest(M)),je=we?await n.getTextIndex(M,we.key):null;_e(je&&je.chapters.length>0?{chapters:je.chapters.map(oe=>({n:oe.n,title:oe.title,file:oe.file})),source:{name:((ge=je.source)==null?void 0:ge.name)??(we==null?void 0:we.source_name),license:((O=je.source)==null?void 0:O.license)??(we==null?void 0:we.license)??void 0}}:null)}catch{_e(null)}finally{Be(M)}},[n]),Q=x.useCallback(async(M,ge)=>{D(!0);try{if(n.getLineageGraph){const Fe=await n.getLineageGraph(M);Fe&&ze(Fe)}const O=ge.version_graph;if(!O||!O.enabled){Re||ze(null),ae.current=null;return}const we=ge.books??[],je=[];for(const Fe of we)try{const Ne=await n.getItem(Fe);Ne&&je.push(Ne)}catch{}ae.current={work:ge,books:je};const oe=u??O.default_collection??(O.core_books&&O.core_books.length>0?"core":"all"),Oe=oe==="core"&&Array.isArray(O.core_books)&&O.core_books.length>0?"core":oe??"all";ze(kn(ge,je,Oe))}catch{ze(null),ae.current=null}finally{D(!1)}},[n]),xe=x.useRef({initialDetail:o,initialEntry:r});xe.current={initialDetail:o,initialEntry:r},x.useEffect(()=>{let M=!1;const ge=oe=>{oe.type==="collection"?Ae(t):oe.type==="work"?(oe.version_graph||n.getLineageGraph)&&Q(t,oe):oe.type==="book"&&pi(oe)&&R(t)},O=xe.current;let we=null;if(te&&te.id===t)we=te;else if(O.initialDetail&&O.initialDetail.id===t){const oe={...O.initialDetail},Oe=O.initialEntry??ui(t,oe);b&&b(Oe,oe),we={entry:Oe,detail:oe}}return we?(ve(!1),ce(oe=>oe.length?[]:oe),_e(null),ze(null),ae.current=null,B(we.entry),ee(we.detail),U(!1),ge(we.detail),()=>{M=!0}):((async()=>{U(!0),ve(!1),B(null),ee(null),ce([]),_e(null),ze(null),ae.current=null;try{const oe=await n.getItem(t);if(M)return;if(!oe){ve(!0);return}const Oe=oe;let Fe=null;if(n.getEntry&&(Fe=await n.getEntry(t),M))return;Fe||(Fe=ui(t,Oe)),b&&b(Fe,Oe),B(Fe),ee(Oe),ge(Oe)}catch{M||ve(!0)}finally{M||U(!1)}})(),()=>{M=!0})},[t,n,te,b,Ae,Q,R]),x.useEffect(()=>{const M=ae.current;!M||!u||ze(kn(M.work,M.books,u))},[u]);const N=[];if(E){if(N.push({key:"basic",label:A.detailTab.basicInfo}),E.type==="collection"){be&&Z.length===0&&N.push({key:"catalog:loading",label:`${A.detailTab.catalog}…`});for(const M of Z)N.push({key:`catalog:${M.resource_id}`,label:M.short_name?`${G(M.short_name)}${A.detailTab.catalogSuffix}`:A.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&N.push({key:s,label:A.detailTab.fullText}),E.type==="work"&&(Re||Ee)&&N.push({key:"lineage",label:Ee?`${A.detailTab.lineage}…`:A.detailTab.lineage});for(const M of $)(M.position??"before-feedback")==="before-feedback"&&M.shouldShow(E)&&N.push({key:M.key,label:M.label});_&&s==="feedback"&&N.push({key:"feedback",label:A.detailTab.feedback});for(const M of $)M.position==="after-feedback"&&M.shouldShow(E)&&N.push({key:M.key,label:M.label})}x.useEffect(()=>{if(s!=="emendated"||!E)return;l("basic");const M=setTimeout(()=>{var ge;(ge=document.getElementById("studies"))==null||ge.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(M)},[s,E,l]);const ne=pe&&E&&j?j({activeTab:s,activeJuan:F,entry:pe,detail:E}):null,J=x.useMemo(()=>{var je;if(!E)return null;const ge=(E.authors??[]).map(oe=>{const Oe=Qi(oe.role);return`${oe.dynasty?`〔${G(oe.dynasty)}〕`:""}${G(oe.name)}${Oe?` ${G(Oe)}`:""}`}).join(" · ");let O=!1;try{O=he.extractStatus(E.id)==="draft"}catch{}if(E.type==="book"){const oe=E;return{title:G(oe.title),subtitle:oe.edition?G(oe.edition):ge||void 0,aside:[O?A.status.draft:"",ge&&oe.edition?ge:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(E.type==="collection"){const oe=E;return{title:G(oe.title),subtitle:G(xt(oe,A.unit.juan))||void 0,aside:[(je=oe.publication_info)==null?void 0:je.year,O?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ge||void 0}}if(E.type==="entity"){const oe=E,Oe=Ne=>Ne==null?"":Ne<0?Y("detail.bce",{n:-Ne}):String(Ne),Fe=oe.birth_year!=null||oe.death_year!=null?`${Oe(oe.birth_year)||"?"}—${Oe(oe.death_year)||"?"}`:"";return{title:G(oe.primary_name||oe.title),subtitle:[oe.dynasty?`〔${G(oe.dynasty)}〕`:"",Fe].filter(Boolean).join(" ")||void 0,aside:O?A.status.draft:void 0,secondLine:void 0}}const we=G(xt(E,A.unit.juan));return{title:G(E.title),subtitle:[we,ge].filter(Boolean).join(" · ")||void 0,aside:[Xh(A,E.subtype),O?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[E,G,A,Y]),re=E&&pi(E)?"text":null,Ce=()=>{me(null),l("fulltext")};let Le=null;if(E&&w){const M=w({detail:E,kind:re});M&&(Le=e.jsx(wi,{href:M}))}else re&&(Le=e.jsx(wi,{onClick:Ce}));const $e=M=>{if(!E)return null;const ge=M.replace(/\.[^.]+$/,"");if(w){const O=w({detail:E,kind:re,juan:ge});return O?{href:O}:null}return{onClick:()=>{me(ge),l("fulltext")}}},X=new Set($.map(M=>M.key)),Ie=N.filter(M=>M.key.startsWith("catalog:")&&M.key!=="catalog:loading"||X.has(M.key)).map(M=>({key:M.key,label:M.label,onClick:()=>l(M.key)})),fe=()=>{var M;return E?E.type==="work"?e.jsx(ia,{data:E,transport:n,onNavigate:f,renderLink:k,readAction:Le,railTop:S,railLinks:Ie}):E.type==="book"?e.jsx(la,{data:E,transport:n,onNavigate:f,renderLink:k,readAction:Le,fullText:ye,fullTextPending:pi(E)&&!!n.getTextManifest&&He!==E.id,chapterLink:$e,railTop:S,railLinks:Ie}):E.type==="collection"?e.jsx(aa,{data:E,catalog:(M=Z[0])==null?void 0:M.data,transport:n,onNavigate:f,renderLink:k,readAction:Le,railTop:S,railLinks:Ie,catalogAction:Z.length>0?e.jsxs("a",{href:"#catalog",onClick:ge=>{ge.preventDefault(),l(`catalog:${Z[0].resource_id}`)},children:[G(A.detailTab.collectionCatalog)," →"]}):null}):e.jsx(ca,{data:E,transport:n,onNavigate:f,renderLink:k,railTop:S,railLinks:Ie}):null},Me=()=>{var ge,O,we;if(!pe||!E)return null;if(s==="basic"||s==="emendated")return fe();if(typeof s=="string"&&s.startsWith("catalog:")){const je=(ge=Z.find(oe=>`catalog:${oe.resource_id}`===s))==null?void 0:ge.data;return e.jsx(Vi,{data:je,onNavigate:f,renderLink:k})}if(s==="collated"||s==="fulltext")return e.jsx(fo,{id:t,transport:n,chapter:F,onLocationChange:je=>me(je.chapter),onNavigate:f});if(s==="lineage"){if(!Re)return e.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:Y(Ee?"detail.loading":"detail.noLineageGraph")});const je=E.type==="work"?E:null;return e.jsx(ko,{graph:Re,renderLink:k,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:h,collection:u??((O=je==null?void 0:je.version_graph)==null?void 0:O.default_collection),onCollectionChange:g,collectionsAvailable:(we=je==null?void 0:je.version_graph)==null?void 0:we.collections,collectionCounts:(()=>{var Ne,Qe,V,Pe,it,vt,Ut;if(!je)return;const oe={},Oe=((Ne=ae.current)==null?void 0:Ne.books)??[];oe.all=(((Qe=je.books)==null?void 0:Qe.length)??0)-(((Pe=(V=je.version_graph)==null?void 0:V.excluded_books)==null?void 0:Pe.length)??0);const Fe=(it=je.version_graph)==null?void 0:it.collections;if(Fe)for(const gn of Object.keys(Fe))oe[gn]=kn(je,Oe,gn).nodes.filter(Eo=>Eo.kind==="book"&&!Eo.bridge).length;return oe.core==null&&((Ut=(vt=je.version_graph)==null?void 0:vt.core_books)!=null&&Ut.length)&&(oe.core=je.version_graph.core_books.length),oe})()})}if(s==="feedback"&&_)return e.jsx(Ql,{resourceId:t,apiUrl:C});const M=$.find(je=>je.key===s);return M?M.render({detail:E,entry:pe,transport:n,onNavigate:f}):null};if(L)return e.jsx(en,{style:{minHeight:I,...W},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((M,ge)=>e.jsx("div",{style:{height:ge===1?40:16,width:M,opacity:.35,background:i("rule")}},ge))})});if(de||!E||!pe||!J)return e.jsx(en,{style:{minHeight:I,...W},children:e.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:Y("detail.notFound")})});const P=s==="basic"||s==="emendated",q=[{label:y??A.detailTab.backToIndex,onClick:v}];if(E.type==="book"&&E.work_id){const M=E.work_id;q.push({label:A.indexType.work,id:M,onClick:()=>f==null?void 0:f(M)})}q.push({label:A.indexType[E.type]});const se=s==="collated"||s==="fulltext",ue=typeof T=="string"?A.status[T.trim()]??T:T,ie=e.jsx($l,{left:e.jsxs(e.Fragment,{children:[ue,ue?" · ":"",e.jsx(Jh,{id:E.id,label:A.label.id,copied:A.action.copied,copyLabel:A.action.copy})]}),right:e.jsxs(e.Fragment,{children:[_&&!P&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:A.detailTab.submitVersion}),ne&&e.jsx("a",{href:ne.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:A.detailTab.dataLicense})]})});return P?e.jsx("div",{className:H,children:e.jsxs(en,{grid:!0,style:{minHeight:I,...W},children:[e.jsx(Si,{breadcrumb:e.jsx($i,{items:q}),actions:e.jsxs(e.Fragment,{children:[!z&&e.jsx(Ei,{style:{border:"none",background:"transparent"}}),!z&&ne&&e.jsx(Ri,{...ne})]})}),fe(),ie]})}):e.jsx("div",{className:H,children:e.jsxs(en,{wide:se,style:{minHeight:I,...W},children:[e.jsx(Si,{breadcrumb:e.jsxs(e.Fragment,{children:[e.jsx(io,{char:"籍"}),e.jsx($i,{items:q})]}),actions:e.jsxs(e.Fragment,{children:[!z&&e.jsx(Ei,{}),_&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:A.detailTab.feedback}),!z&&ne&&e.jsx(Ri,{...ne})]})}),e.jsx(xl,{...J,aside:se?e.jsxs("button",{type:"button",onClick:()=>l("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[Y("detail.workInfo")," →"]}):J.aside}),!se&&N.length>1&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:N.map(M=>e.jsx(fl,{label:M.label,active:M.key===s||P&&M.key==="basic",onClick:()=>l(M.key)},M.key))}),e.jsx("div",{style:{marginTop:!se&&N.length>1?8:0},children:Me()}),ie]})})};function Jh({id:t,label:n,copied:o,copyLabel:r}){const[s,l]=x.useState(!1);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[e.jsxs("span",{children:[n," ",t]}),e.jsx("button",{type:"button",onClick:()=>{var a;(a=navigator.clipboard)==null||a.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1500)}).catch(()=>{})},title:s?o:r,"aria-label":s?o:r,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:i("aux-fg")},children:s?"✓":"⧉"})]})}function Xh(t,n){return n?t.workSubtype[n]??n:""}const Xa=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Gn="zhusha",Yn="bim-theme";function Qa(t){return t==="zhusha"||t==="indigo"||t==="ink"}function Kn(t){return Qa(t)?t:Gn}function Qh(){try{return Kn(window.localStorage.getItem(Yn))}catch{return Gn}}function ec(t){try{window.localStorage.setItem(Yn,t)}catch{}}function tc(t){const n=Kn(t);return document.documentElement.setAttribute("data-theme",n),n}function nc(){return Kn(document.documentElement.getAttribute("data-theme"))}const ex=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Io="airy",qn="bim-layout";function ic(t){return t==="airy"||t==="boxed"}function Zn(t){return ic(t)?t:Io}function tx(){try{return Zn(window.localStorage.getItem(qn))}catch{return Io}}function nx(t){try{window.localStorage.setItem(qn,t)}catch{}}function ix(t){const n=Zn(t);return document.documentElement.setAttribute("data-layout",n),n}function ox(){return Zn(document.documentElement.getAttribute("data-layout"))}const rx=`try{var t=localStorage.getItem(${JSON.stringify(Yn)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(qn)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,sx={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},lx=({onChange:t,style:n})=>{const{t:o}=K(),[r,s]=x.useState(Gn);x.useEffect(()=>{s(nc())},[]);const l=a=>{s(tc(a)),ec(a),t==null||t(a)};return e.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Xa.map(a=>{const d=r===a.name;return e.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":o(`common.theme.${a.name}`),title:o(`common.theme.${a.name}`),onClick:()=>l(a.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:i(sx[a.name]),boxShadow:d?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},a.name)})})};exports.BidLink=he.BidLink;exports.BookIndexError=he.BookIndexError;exports.BookIndexManager=he.BookIndexManager;exports.BookIndexStorage=he.BookIndexStorage;exports.BundleStorage=he.BundleStorage;exports.ConfigError=he.ConfigError;exports.GithubStorage=he.GithubStorage;exports.IdGenerationError=he.IdGenerationError;exports.IdGenerator=he.IdGenerator;exports.LocalStorage=he.LocalStorage;exports.MigrationError=he.MigrationError;exports.StorageError=he.StorageError;exports.VARIANT_CHARS=he.VARIANT_CHARS;exports.base36Decode=he.base36Decode;exports.base36Encode=he.base36Encode;exports.base58Decode=he.base58Decode;exports.buildId=he.buildId;exports.buildPromotionMap=he.buildPromotionMap;exports.cleanName=he.cleanName;exports.decodeId=he.decodeId;exports.decodeIdString=he.decodeIdString;exports.encodeId=he.encodeId;exports.extractIdFromUrl=he.extractIdFromUrl;exports.extractStatus=he.extractStatus;exports.extractType=he.extractType;exports.isChapterSegment=he.isChapterSegment;exports.isTextKey=he.isTextKey;exports.matchChapterAcrossVersions=he.matchChapterAcrossVersions;exports.normalizeCatalog=he.normalizeCatalog;exports.normalizeVariants=he.normalizeVariants;exports.parseId=he.parseId;exports.pickTextVersion=he.pickTextVersion;exports.shardOf=he.shardOf;exports.smartDecode=he.smartDecode;exports.textVersionLabel=he.textVersionLabel;exports.validateResource=he.validateResource;exports.Badge=zn;exports.BidUrlProvider=gc;exports.BookDetailLayout=Zh;exports.BookPage=la;exports.Breadcrumb=$i;exports.CATALOG_ALL_ID=mt;exports.CATALOG_CSS=da;exports.CATALOG_NARROW_QUERY=wo;exports.CATALOG_PAGE_SIZE=So;exports.CATALOG_UNCLASSIFIED_ID=$t;exports.CLASSIFICATIONS=Pn;exports.COMMON_TRADITIONAL_CHARS=ds;exports.CardFoot=dn;exports.CatalogPage=Lh;exports.CatalogPager=fa;exports.CatalogTree=ua;exports.CheckFilter=ml;exports.Chip=bl;exports.ChipWall=Qp;exports.CollectionCatalog=Vi;exports.CollectionPage=aa;exports.CreateEntityDialog=Vl;exports.DEFAULT_LAYOUT=Io;exports.DEFAULT_META_HOME_LINKS=Pa;exports.DEFAULT_READER_PREFS=Ki;exports.DEFAULT_READ_HOME_LINKS=ya;exports.DEFAULT_THEME=Gn;exports.DETAIL_CSS=hl;exports.DYNASTY_GROUPS=Ln;exports.Dash=ru;exports.DataTable=tu;exports.DetailFooter=$l;exports.DetailGrid=an;exports.DetailHeader=xl;exports.EMPTY_FILTERS=Rn;exports.EmendatedBySection=Ls;exports.EmptyNote=uu;exports.EntityDetail=zs;exports.EntityPage=ca;exports.EntityPickerDialog=Yl;exports.EntitySelector=Ul;exports.ExpandRow=su;exports.ExtLink=mu;exports.FEEDBACK_FAB_OFFSET_VAR=Ti;exports.FILTER_SUPPORT=ys;exports.FONT_SIZE_STEPS=ut;exports.FactList=qp;exports.FeedbackButton=kg;exports.FeedbackDialog=Jl;exports.FeedbackForm=Xl;exports.FeedbackList=bo;exports.FeedbackTab=Ql;exports.FilterChip=fl;exports.FormInput=et;exports.FormTextArea=Ct;exports.GUJI_MARKDOWN_FIELD=ip;exports.GUJI_TABLE_NOTATION=Hs;exports.GlyphBadge=io;exports.GujiTable=ro;exports.HomePage=Ci;exports.ImagePanel=fi;exports.IndexApp=_m;exports.IndexBrowser=hi;exports.IndexDetail=Ui;exports.IndexEditor=Kl;exports.IndexView=ag;exports.IntroGrid=Kp;exports.LAYOUTS=ex;exports.LAYOUT_STORAGE_KEY=qn;exports.LOSS_OPTIONS=bs;exports.LocaleContext=Tt;exports.LocaleProvider=Oc;exports.LocaleToggle=Ei;exports.META_HOME_CSS=La;exports.META_HOME_SECTION_IDS=Ja;exports.MetaCatalogTable=Fa;exports.MetaCollectionGroups=Ga;exports.MetaDataLicense=Za;exports.MetaHomeView=Kh;exports.MetaLine=Ye;exports.MetaLineageCards=Ka;exports.MetaOnlineSites=qa;exports.MetaPeopleTimeline=Ya;exports.MetaRecentPanel=Ha;exports.MetaRelatedCatalogs=Ua;exports.MetaTypeChips=Ba;exports.ModeIndicator=gs;exports.MoreButton=Xp;exports.MoreLink=to;exports.PAGE_MAX_WIDTH=jn;exports.PERIOD_NARROW_SHARE=wa;exports.PageFrame=en;exports.Quote=au;exports.READER_CSS=Ks;exports.READ_HOME_CSS=_o;exports.READ_HOME_NARROW_QUERY=mn;exports.READ_HOME_SECTION_IDS=Ra;exports.READ_PERIOD_LABELS=Mh;exports.RECENT_IDS_STORAGE_KEY=Pt;exports.ROLE_CLASS_ORDER=ll;exports.ReadButton=wi;exports.ReadFamousWorks=Na;exports.ReadHomeView=Hh;exports.ReadPeriodBand=Ia;exports.ReadPicks=_a;exports.ReadPieces=Ea;exports.ReadSection=Je;exports.ReadShelf=zo;exports.ReadSibu=To;exports.ReadStats=$a;exports.ReadTopicGroup=za;exports.ReadTopics=Ta;exports.ReaderMdText=co;exports.ReaderShell=tl;exports.ReaderToc=Zs;exports.RelationPanel=Fl;exports.RepoSourceLink=Ri;exports.ResourceEditor=mi;exports.ResourceGroup=cu;exports.ResourceLine=du;exports.ResourceList=Hi;exports.ResourceRow=wl;exports.SEARCH_VIEW_STORAGE_KEY=Oi;exports.SEVEN_PAVILIONS_KEY=Va;exports.SNIPPET_MARK_END=rs;exports.SNIPPET_MARK_START=os;exports.SORTABLE_TYPES=fs;exports.SearchInput=xs;exports.SearchResults=$s;exports.Sec=Ke;exports.Section=st;exports.SectionHead=Zp;exports.SideList=_t;exports.SmartBidInput=vn;exports.SourceEditor=Wl;exports.SummaryCard=cn;exports.THEMES=Xa;exports.THEME_INIT_SCRIPT=rx;exports.THEME_STORAGE_KEY=Yn;exports.TRADITIONAL_ALLOWLIST=ps;exports.TabFilter=On;exports.TableHead=nu;exports.TableRow=iu;exports.TagRow=Sl;exports.TagRows=pu;exports.TextButton=Jp;exports.TextReader=fo;exports.ThemeToggle=lx;exports.TopStrip=Si;exports.VersionLineageGraph=sa;exports.VersionLineageList=ra;exports.VersionLineageView=ko;exports.VolumeChips=eu;exports.VolumeLinks=oo;exports.WorkCard=ha;exports.WorkCardGrid=ba;exports.WorkCatalog=Cm;exports.WorkPage=ia;exports.WorkRow=xa;exports.applyLayout=ix;exports.applyTheme=tc;exports.authorsLine=Vn;exports.bucketResources=Ji;exports.buildCatalogTree=$h;exports.buildCollectionTable=cl;exports.buildLineageGraph=kn;exports.buildMeiliFilter=od;exports.buildPageUrl=Wi;exports.buildParagraphBlocks=Nl;exports.buildVersionRow=rl;exports.buildVersionTable=sl;exports.canParagraphize=_n;exports.catalogNodeIdOf=wh;exports.catalogNodeIdsOf=Sh;exports.catalogPageCount=Th;exports.catalogTotal=$o;exports.classificationPath=un;exports.clearAllRecentIds=Fi;exports.compareCatalogCards=zh;exports.computeVersionPartition=Bp;exports.countActiveFilters=An;exports.createTextApi=Us;exports.currentLayout=ox;exports.currentTheme=nc;exports.defaultWorkLink=ma;exports.deriveDating=Lp;exports.deriveEditionType=pl;exports.deriveEra=ln;exports.deriveYear=Mn;exports.deriveYearRange=Zi;exports.detailToEditor=Zl;exports.detectGenre=Dn;exports.displayAuthorRole=Qi;exports.editorToDetail=lg;exports.eraRank=vi;exports.filtersFromParams=rd;exports.filtersToParams=wn;exports.findCatalogPath=Lt;exports.findTraditionalChars=Uc;exports.firstAuthorText=Co;exports.flattenTitles=_i;exports.flattenToc=el;exports.fmtCount=De;exports.formatTemplate=tt;exports.formatVolumeRange=Hn;exports.getDisplayNameFromUrl=Ot;exports.getMessages=Wt;exports.getStartPage=Mi;exports.getT=Ht;exports.getTypeGroupKey=Ai;exports.groupRelatedWorks=Pp;exports.gujiInlineToPlain=Ws;exports.hasActiveFilters=js;exports.hasGujiMarkdownV02=xi;exports.hasGujiTableNotation=Os;exports.hasSearchOptions=td;exports.isLayoutName=ic;exports.isThemeName=Qa;exports.loadRecentIds=bt;exports.measureText=xt;exports.mergeVolumeResources=Bi;exports.normalizeEra=Ge;exports.normalizeLayout=Zn;exports.normalizeRole=Xi;exports.normalizeTheme=Kn;exports.normalizeVolumeIndex=nn;exports.normalizeVolumes=ms;exports.numberToChinese=dl;exports.paginationItems=pa;exports.parseChineseNumber=Sn;exports.parseGujiInline=Ms;exports.parseGujiTable=Ds;exports.parseSourceString=Hl;exports.pct=No;exports.periodLevel=ka;exports.pickReaderVersion=Qs;exports.readStoredLayout=tx;exports.readStoredTheme=Qh;exports.readerVersionOptionLabel=yi;exports.removeRecentId=_s;exports.renderFullTextBody=yu;exports.renderProperNames=El;exports.renderReaderInline=ao;exports.resolveRecentEntry=Di;exports.resourceHref=Ft;exports.resourceNote=Wn;exports.roleFacets=al;exports.rowNo=ou;exports.sameFilters=sd;exports.saveRecentId=gi;exports.shelfColumns=ja;exports.sortFor=nd;exports.sortYear=$n;exports.spineHeight=va;exports.splitFullTextTables=Gi;exports.splitHighlightSnippet=Li;exports.splitTableRow=Fs;exports.storeLayout=nx;exports.storeTheme=ec;exports.stringifySources=Ol;exports.timelineLayout=Aa;exports.toCatalogWorkCard=Ch;exports.typeSupportsFilters=vs;exports.useBidUrl=Ve;exports.useConvert=Te;exports.useI18n=K;exports.useReaderPrefs=Xs;exports.useRecentEntries=Ma;exports.useT=ke;exports.validateLineageGraph=Vg;exports.volumeStats=In;exports.withDefaultLinks=yt;exports.withMetaLinks=jt;exports.yearText=Tn;
|
|
1669
|
+
`,Oa={item:t=>`/item/${encodeURIComponent(t)}`,node:t=>`/catalog?node=${encodeURIComponent(t)}`};function kt(t){return{...Oa,...t??{}}}function Fa(t,n){if(t.lineage)return t.lineage(n);const o=t.item(n),r=o.indexOf("#"),[s,l]=r<0?[o,""]:[o.slice(0,r),o.slice(r)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${l}`}function Lo(t,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(t/n*100)))}function Da(t){const n=t.filter(d=>Number.isFinite(d.birth_year)||Number.isFinite(d.death_year)),o=t.filter(d=>!n.includes(d));if(!n.length)return{min:0,max:0,placed:[],missing:o};const r=d=>{const u=Number.isFinite(d.birth_year)?d.birth_year:d.death_year-50,g=Number.isFinite(d.death_year)?d.death_year:d.birth_year+50;return[Math.min(u,g),Math.max(u,g)]},s=n.map(r),l=Math.min(...s.map(d=>d[0])),a=Math.max(...s.map(d=>d[1])),p=Math.max(1,a-l),c=n.map((d,u)=>({p:d,from:s[u][0],to:s[u][1]})).sort((d,u)=>d.from-u.from).map(d=>({...d,left:(d.from-l)/p*100,width:Math.max(.8,(d.to-d.from)/p*100)}));return{min:l,max:a,placed:c,missing:o}}function Rn(t,n=Dt("zh-Hant")){return t<0?n("metaHome.yearBC",{n:-t}):String(t)}function ix(t){return{read:t.item,work:t.item,node:t.node}}function Ua({counts:t,links:n}){const{t:o}=G(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),t.works],["book",o("metaHome.typeLabel.book"),t.books],["collection",o("metaHome.typeLabel.collection"),t.collections],["entity",o("metaHome.typeLabel.entity"),t.entities]];return e.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([l,a,p])=>e.jsx("li",{children:e.jsxs("a",{href:r(l),children:[e.jsx("b",{children:a}),p!=null&&p>0&&e.jsx("small",{children:Ue(p)})]})},l))})}function Va(t,n=5){const[o,r]=x.useState(null);x.useEffect(()=>{let l=!1;const a=jt().slice(0,n);if(!a.length||!t){r([]);return}return Promise.all(a.map(p=>Yi(t,p))).then(p=>{l||r(p.filter(c=>!c.notFound))}),()=>{l=!0}},[t,n]);const s=x.useCallback(()=>{Gi(),r([])},[]);return{entries:o,clear:s}}function ox(t,n,o){const r=t.type==="book"?t.edition||t.era:t.type==="collection"?"":t.dynasty;return r?o(r):Ga(t.type,n)}function Ga(t,n){return n(`metaHome.typeLabel.${t}`)}function Ya({entries:t,onClear:n,links:o}){const{t:r,convert:s}=G(),l=kt(o);return e.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[e.jsxs("div",{className:"bim-mh-recent-h",children:[e.jsx("h2",{id:"bim-mh-recent-h",children:r("metaHome.recentTitle")}),t&&t.length>0&&n&&e.jsx("button",{type:"button",onClick:n,children:r("metaHome.recentClear")})]}),t&&t.length>0&&e.jsx("ol",{children:t.map(a=>e.jsx("li",{children:e.jsxs("a",{href:l.item(a.id),"aria-label":r("metaHome.recentItemLabel",{type:a.type?Ga(a.type,r):"",title:s(a.title)}),children:[e.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:a.type?r(`metaHome.typeShort.${a.type}`):""}),e.jsx("span",{children:s(a.title)}),e.jsx("small",{"aria-hidden":"true",children:ox(a,r,s)})]})},a.id))}),t&&t.length===0&&e.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function Ka(t,n,o,r=!1){return r&&(t==="done"||t==="in_progress")?n(`metaHome.siteStatus.${t}`):t==="done"||t==="in_progress"||t==="todo"?n(`metaHome.status.${t}`):o(t)}function qa({rows:t,links:n}){const{t:o,convert:r}=G(),s=kt(n);return t.length?e.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":o("metaHome.catalogTitle"),children:e.jsxs("table",{className:"bim-mh-tbl",children:[e.jsxs("caption",{children:[o("metaHome.catalogTitle"),e.jsx("small",{children:o("metaHome.catalogNote")})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:o("metaHome.colCatalog")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colRecords")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colMatched")}),e.jsx("th",{scope:"col",children:o("metaHome.colProgress")}),e.jsx("th",{scope:"col",children:o("metaHome.colStatus")})]})}),e.jsx("tbody",{children:t.map(l=>{const a=Lo(l.imported,l.total),p=l.work_id??l.collection_id,c=r(l.edition?`${l.name}·${l.edition}`:l.name);return e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:p?e.jsx("a",{href:s.item(p),children:c}):c}),e.jsx("td",{className:"bim-mh-r",children:Ue(l.total)}),e.jsx("td",{className:"bim-mh-r",children:Ue(l.imported)}),e.jsx("td",{children:e.jsxs("span",{className:"bim-mh-meter",children:[e.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[a,"%"]})]})}),e.jsx("td",{children:l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:Ka(l.status,o,r)})})]},l.id||l.name)})})]})}):null}function Za({items:t,links:n,label:o}){const{convert:r}=G();return e.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):void 0,children:t.map(s=>e.jsx("li",{children:e.jsxs("a",{href:n.item(s.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(s.title)}),s.sub&&e.jsx("small",{children:r(s.sub)})]})},s.id))})}function Ja({works:t,links:n}){const{t:o}=G(),[r,s]=x.useState(!1);if(!t.length)return null;const l=cn(t.length);return e.jsxs("div",{className:"bim-rh-grp","data-cap":l?"":void 0,"data-open":r?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[o("metaHome.relatedTitle"),e.jsx("small",{children:o("metaHome.relatedNote")})]}),e.jsx(Za,{items:t.map(a=>({id:a.id,title:a.title,sub:Kn(a)||void 0})),links:kt(n)}),l&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":r,onClick:()=>s(a=>!a),children:r?o("action.collapse"):o("metaHome.allNWorks",{n:t.length})})]})}const Xa="siku_qige";function rx({group:t,links:n}){const{t:o,convert:r}=G(),[s,l]=x.useState(!1);return e.jsxs("div",{className:"bim-rh-grp","data-cap":cn(t.items.length)?"":void 0,"data-open":s?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("metaHome.nKinds",{n:t.items.length})})]}),e.jsx(Za,{items:t.items,links:n,label:t.label}),cn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>l(a=>!a),children:s?o("action.collapse"):o("metaHome.allNKinds",{n:t.items.length})})]})}function Qa({groups:t,links:n}){const{t:o,convert:r}=G(),s=kt(n);if(!t.length)return null;const l=t.find(c=>c.key===Xa),a=t.filter(c=>c!==l),p=c=>{var d;return((d=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:d[1])??c};return e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(l.label),e.jsx("small",{children:r(l.items.map(c=>p(c.title)).join("、"))})]}),e.jsx("ul",{className:"bim-mh-ge","aria-label":r(l.label),children:l.items.map(c=>e.jsx("li",{children:e.jsxs("a",{href:s.item(c.id),"aria-label":r(c.title),title:r(c.title),children:[e.jsx("span",{"aria-hidden":"true",children:r(p(c.title))}),p(c.title)!==c.title&&e.jsx("small",{"aria-hidden":"true",children:o("metaHome.pavilion")})]})},c.id))})]}),a.length>0&&e.jsx("div",{className:"bim-mh-cg",style:l?void 0:{marginTop:0},children:a.map(c=>e.jsx(rx,{group:c,links:s},c.key))})]})}const is=34,os=13;function rs(t,n){return t.birth_year==null&&t.death_year==null?"":`${t.birth_year!=null?Rn(t.birth_year,n):"?"}–${t.death_year!=null?Rn(t.death_year,n):"?"}`}function sx(t,n){const o=n-t,r=o>1200?300:o>400?100:50,s=[];for(let l=Math.ceil(t/r)*r;l<=n;l+=r)s.push(l);return s}function ec({people:t,links:n}){const{t:o,convert:r}=G(),s=kt(n);if(!t.length)return null;const{min:l,max:a,placed:p,missing:c}=Da(t),d=[],u=p.map(m=>{const h=m.left>70,f=h?Math.min(m.left,m.left+m.width-os):m.left;let v=0;for(;d[v]!=null&&d[v]>f;)v++;return d[v]=h?m.left+m.width:m.left+Math.max(m.width,os),{...m,lane:v,end:h}}),g=Math.max(1,a-l);return e.jsxs(e.Fragment,{children:[u.length>0&&e.jsxs("div",{className:"bim-mh-tl",children:[e.jsx("ul",{className:"bim-mh-tl-rows",style:{height:d.length*is+10},children:u.map(m=>e.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*is+4,width:`${Math.max(m.width,.5)}%`},children:[e.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),e.jsxs("a",{href:s.item(m.p.id),children:[r(m.p.name),e.jsx("small",{className:"bim-rh-num",children:rs(m.p,o)})]})]},m.p.id))}),e.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:sx(l,a).map(m=>e.jsx("span",{style:{left:`${(m-l)/g*100}%`},children:Rn(m,o)},m))})]}),e.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?t:c).map(m=>e.jsx("li",{children:e.jsxs("a",{href:s.item(m.id),children:[e.jsx("span",{children:r(m.name)}),e.jsx("small",{className:"bim-rh-num",children:[m.dynasty?r(m.dynasty):"",rs(m,o)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&u.length>0&&e.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(m=>m.name).join("、"))})})]})}const lx=e.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[e.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),e.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),e.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function tc({works:t,links:n}){const{t:o,convert:r}=G(),s=kt(n);return t.length?e.jsx("ul",{className:"bim-mh-lin",children:t.map(l=>{const a=Kn(l);return e.jsx("li",{children:e.jsxs("a",{href:Fa(s,l.id),children:[lx,e.jsx("b",{children:r(l.title)}),a&&e.jsx("small",{children:r(a)}),e.jsx("span",{children:o("metaHome.viewLineage")})]})},l.id)})}):null}function nc({sites:t}){const{t:n,convert:o}=G(),r=t.filter(l=>l.status!=="todo"&&l.total>0),s=t.filter(l=>!r.includes(l));return t.length?e.jsxs(e.Fragment,{children:[r.length>0&&e.jsx("ul",{className:"bim-mh-cov",children:r.map(l=>{const a=Lo(l.imported,l.total);return e.jsxs("li",{children:[l.url?e.jsx("a",{href:l.url,rel:"noopener noreferrer",target:"_blank",children:o(l.name)}):e.jsx("span",{children:o(l.name)}),e.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[`${Ue(l.imported)} / ${Ue(l.total)} ${a}% `,l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:Ka(l.status,n,o,!0)})]})]},l.id||l.name)})}),s.length>0&&e.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:o(s.map(l=>l.name).join("、"))})})]}):null}const ss=["extant","partially_extant","lost","unknown"];function ic({stats:t,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:l}=G(),a=["works","books","collections","entities","has_image","has_text","article","poem"].map(d=>[t[d],l(`metaHome.stat.${d}`)]).filter(([d])=>d>0),p=n==null?void 0:n.loss,c=ss.some(d=>{var u;return(((u=t.loss)==null?void 0:u[d])??0)>0});return e.jsxs("div",{className:"bim-mh-data",children:[a.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.dataScale")}),e.jsx("ul",{className:"bim-mh-nums",children:a.map(([d,u])=>e.jsxs("li",{children:[e.jsx("b",{className:"bim-rh-num",children:Ue(d)}),e.jsx("span",{children:u})]},u))})]}),p&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.byLoss")}),e.jsx("ul",{className:"bim-mh-loss",children:ss.map(d=>{var m;const u=((m=t.loss)==null?void 0:m[d])??0,g=l(`metaHome.lossNote.${d}`);return e.jsx("li",{children:e.jsxs("a",{href:p(d),children:[l(`metaHome.loss.${d}`),e.jsx("small",{className:"bim-rh-num",children:c&&u>0?l("metaHome.lossCount",{n:Ue(u),note:g}):g})]})},d)})})]}),e.jsxs("div",{className:"bim-mh-lic",children:[e.jsxs("p",{children:[e.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),l("metaHome.license")]}),e.jsxs("p",{children:[l("metaHome.repo"),r?e.jsx("a",{href:r,children:e.jsx("code",{children:"book-index"})}):e.jsx("code",{children:"book-index"}),l("metaHome.repoNote")]}),o&&e.jsxs("p",{children:[l("metaHome.version"),e.jsx("code",{children:o})]}),s&&e.jsx("p",{children:e.jsx("a",{href:s,children:l("metaHome.download")})})]})]})}const oc={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function ax({sections:t,links:n,head:o,transport:r,catalogHref:s,collectionsHref:l,entitiesHref:a,version:p,repoUrl:c,downloadHref:d,className:u}){var k,$;const{t:g}=G(),m=t,h=kt(n),f=ix(h),v=oc,y=Va(r),w={zhi:!!((k=m.shelf)!=null&&k.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(v).filter(_=>w[_]),j=_=>g(`metaHome.nav.${_}`),S=(_,z)=>_?e.jsx("a",{className:"bim-rh-more",href:_,children:z}):void 0;return e.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[e.jsx("style",{children:No+Ha}),e.jsxs("div",{className:"bim-mh-head",children:[e.jsxs("div",{className:"bim-mh-q",children:[o,e.jsx(Ua,{counts:m.counts,links:n})]}),r&&e.jsx(Ya,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":g("metaHome.navLabel"),children:e.jsx("ul",{children:b.map(_=>e.jsx("li",{children:e.jsx("a",{href:`#${v[_]}`,children:j(_)})},_))})}),e.jsxs("div",{className:"bim-rh-main",children:[w.zhi&&e.jsxs(et,{id:v.zhi,title:j("zhi"),sub:g("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&e.jsx(Ro,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:f,showTitle:!1,legendCount:m.shelf.items.some(_=>_.records)?g("metaHome.shelfLegendCount"):null,legendExtra:[g("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&e.jsxs("div",{className:"bim-mh-zhi",style:($=m.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[e.jsx(qa,{rows:m.catalog_progress,links:n}),e.jsx(Ja,{works:m.related_catalogs,links:n})]})]}),w.sibu&&e.jsx(et,{id:v.sibu,title:j("sibu"),sub:g("metaHome.sibuSub"),more:S(s,g("metaHome.toCatalog")),children:e.jsx(Eo,{bu:m.bu,unclassified:m.unclassified,links:f,unclassifiedNote:g("metaHome.unclassifiedNote")})}),w.cong&&e.jsx(et,{id:v.cong,title:j("cong"),sub:g("metaHome.congSub"),more:S(l,g("metaHome.allNKindsMore",{n:Ue(m.counts.collections)})),children:e.jsx(Qa,{groups:m.collection_groups,links:n})}),w.people&&e.jsx(et,{id:v.people,title:j("people"),sub:g("metaHome.peopleSub"),more:S(a,g("metaHome.allNPeopleMore",{n:Ue(m.counts.entities)})),children:e.jsx(ec,{people:m.bibliographers,links:n})}),w.lineage&&e.jsx(et,{id:v.lineage,title:j("lineage"),sub:g("metaHome.lineageSub"),children:e.jsx(tc,{works:m.lineage,links:n})}),w.sites&&e.jsx(et,{id:v.sites,title:j("sites"),sub:g("metaHome.sitesSub"),children:e.jsx(nc,{sites:m.sites})}),e.jsx(et,{id:v.data,title:j("data"),sub:g("metaHome.dataSub"),children:e.jsx(ic,{stats:m.stats,links:n,version:p,repoUrl:c,downloadHref:d})})]})]})}const Ai=({style:t})=>{const n=x.useContext(It),{t:o}=G();if(!n)return null;const{locale:r,setLocale:s}=n,l=r==="zh-Hant",a=()=>s(l?"zh-Hans":"zh-Hant");return e.jsxs("button",{type:"button",onClick:a,title:o(l?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${i("border")}`,borderRadius:"4px",background:i("bg"),color:i("fg"),cursor:"pointer",userSelect:"none",...t},children:[e.jsx("span",{style:{color:l?i("primary"):void 0,fontWeight:l?700:400},children:o("common.localeShortHant")}),e.jsx("span",{style:{opacity:.3},children:"/"}),e.jsx("span",{style:{color:l?void 0:i("primary"),fontWeight:l?400:700},children:o("common.localeShortHans")})]})},Bi=({href:t,label:n,size:o=16,className:r,style:s})=>{const{t:l}=G(),a=n??l("common.repoSourceLink");return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:a,"aria-label":a,className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:o+8,height:o+8,borderRadius:4,color:i("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:p=>{p.currentTarget.style.color=i("fg")},onMouseLeave:p=>{p.currentTarget.style.color=i("desc-fg")},children:e.jsx("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.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 hi(t){const n=t.text_count;return typeof n=="number"&&n>0}function xi(t,n){return{id:t,title:n.title??n.primary_name??t,type:n.type??"book"}}function cx(t,n){if(!n)return!1;const o=n.id;return o===void 0||o===t}const dx=({id:t,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:l,activeJuan:a,onJuanChange:p,lineageMode:c="list",onLineageModeChange:d,lineageCollection:u,onLineageCollectionChange:g,initialPage:m=1,selectedLineageNodeId:h,onNavigate:f,onBack:v,backLabel:y,renderLink:w,enrichDetail:b,getSourceLink:j,readLink:S,railTop:k,extraTabs:$=[],showFeedbackTab:_=!0,feedbackApiUrl:z,height:E,footerExtra:T,hideHeaderControls:C=!1,className:O,style:W})=>{const P=ve(),{t:Y,convert:V}=G(),[Q]=x.useState(()=>{if(!cx(t,o))return null;const H={...o},B=r??xi(t,H);return b&&b(B,H),{id:t,entry:B,detail:H}}),[ge,A]=x.useState((Q==null?void 0:Q.entry)??null),[I,Z]=x.useState((Q==null?void 0:Q.detail)??null),[ee,ce]=x.useState(!Q),[fe,Ie]=x.useState(!1),[q,M]=x.useState([]),[K,Re]=x.useState(!1),[se,ye]=x.useState(null),[We,Be]=x.useState(null),[Ee,Ce]=x.useState(null),[He,D]=x.useState(!1),re=x.useRef(null),de=x.useRef(0),[ke,F]=x.useState(null),he=a!==void 0?a:ke,Ne=x.useCallback(H=>{p?p(H):F(H)},[p]),R=x.useCallback(async H=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){M([]);return}Re(!0);try{if(n.getCollectionCatalogs)M(await n.getCollectionCatalogs(H)||[]);else if(n.getCollectionCatalog){const B=await n.getCollectionCatalog(H);M(B?[{resource_id:"",data:B}]:[])}}catch{M([])}finally{Re(!1)}},[n]),ne=x.useCallback(async H=>{var B,be;if(!n.getTextManifest||!n.getTextIndex){ye(null),Be(H);return}try{const _e=xe.pickTextVersion(await n.getTextManifest(H)),je=_e?await n.getTextIndex(H,_e.key):null;ye(je&&je.chapters.length>0?{chapters:je.chapters.map(me=>({n:me.n,title:me.title,file:me.file})),source:{name:((B=je.source)==null?void 0:B.name)??(_e==null?void 0:_e.source_name),license:((be=je.source)==null?void 0:be.license)??(_e==null?void 0:_e.license)??void 0}}:null)}catch{ye(null)}finally{Be(H)}},[n]),ue=x.useCallback(async(H,B)=>{const be=++de.current,_e=()=>be!==de.current;D(!0);try{if(n.getLineageGraph){const Ae=await n.getLineageGraph(H);if(_e())return;Ae&&Ce(Ae)}const je=B.version_graph;if(!je||!je.enabled){Ee||Ce(null),re.current=null;return}const me=B.books??[],Oe=[];for(const Ae of me)try{const lt=await n.getItem(Ae);lt&&Oe.push(lt)}catch{}if(_e())return;re.current={work:B,books:Oe};const ze=u??je.default_collection??(je.core_books&&je.core_books.length>0?"core":"all"),Ve=ze==="core"&&Array.isArray(je.core_books)&&je.core_books.length>0?"core":ze??"all";Ce($n(B,Oe,Ve))}catch{if(_e())return;Ce(null),re.current=null}finally{_e()||D(!1)}},[n]),L=x.useRef({initialDetail:o,initialEntry:r});L.current={initialDetail:o,initialEntry:r},x.useEffect(()=>{let H=!1;de.current++,D(!1);const B=me=>{me.type==="collection"?R(t):me.type==="work"?(me.version_graph||n.getLineageGraph)&&ue(t,me):me.type==="book"&&hi(me)&&ne(t)},be=L.current;let _e=null;if(Q&&Q.id===t)_e=Q;else if(be.initialDetail&&be.initialDetail.id===t){const me={...be.initialDetail},Oe=be.initialEntry??xi(t,me);b&&b(Oe,me),_e={entry:Oe,detail:me}}return _e?(Ie(!1),M(me=>me.length?[]:me),ye(null),Ce(null),re.current=null,A(_e.entry),Z(_e.detail),ce(!1),B(_e.detail),()=>{H=!0}):((async()=>{ce(!0),Ie(!1),A(null),Z(null),M([]),ye(null),Ce(null),re.current=null;try{const me=await n.getItem(t);if(H)return;if(!me){Ie(!0);return}const Oe=me;let ze=null;if(n.getEntry&&(ze=await n.getEntry(t),H))return;ze||(ze=xi(t,Oe)),b&&b(ze,Oe),A(ze),Z(Oe),B(Oe)}catch{H||Ie(!0)}finally{H||ce(!1)}})(),()=>{H=!0})},[t,n,Q,b,R,ue,ne]),x.useEffect(()=>{const H=re.current;!H||!u||Ce($n(H.work,H.books,u))},[u]);const te=[];if(I){if(te.push({key:"basic",label:P.detailTab.basicInfo}),I.type==="collection"){K&&q.length===0&&te.push({key:"catalog:loading",label:`${P.detailTab.catalog}…`});for(const H of q)te.push({key:`catalog:${H.resource_id}`,label:H.short_name?`${V(H.short_name)}${P.detailTab.catalogSuffix}`:P.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&te.push({key:s,label:P.detailTab.fullText}),I.type==="work"&&(Ee||He)&&te.push({key:"lineage",label:He?`${P.detailTab.lineage}…`:P.detailTab.lineage});for(const H of $)(H.position??"before-feedback")==="before-feedback"&&H.shouldShow(I)&&te.push({key:H.key,label:H.label});_&&s==="feedback"&&te.push({key:"feedback",label:P.detailTab.feedback});for(const H of $)H.position==="after-feedback"&&H.shouldShow(I)&&te.push({key:H.key,label:H.label})}x.useEffect(()=>{if(s!=="emendated"||!I)return;l("basic");const H=setTimeout(()=>{var B;(B=document.getElementById("studies"))==null||B.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(H)},[s,I,l]);const U=ge&&I&&j?j({activeTab:s,activeJuan:he,entry:ge,detail:I}):null,le=x.useMemo(()=>{var je;if(!I)return null;const B=(I.authors??[]).map(me=>{const Oe=io(me.role);return`${me.dynasty?`〔${V(me.dynasty)}〕`:""}${V(me.name)}${Oe?` ${V(Oe)}`:""}`}).join(" · ");let be=!1;try{be=xe.extractStatus(I.id)==="draft"}catch{}if(I.type==="book"){const me=I;return{title:V(me.title),subtitle:me.edition?V(me.edition):B||void 0,aside:[be?P.status.draft:"",B&&me.edition?B:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(I.type==="collection"){const me=I;return{title:V(me.title),subtitle:V(bt(me,P.unit.juan))||void 0,aside:[(je=me.publication_info)==null?void 0:je.year,be?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:B||void 0}}if(I.type==="entity"){const me=I,Oe=Ve=>Ve==null?"":Ve<0?Y("detail.bce",{n:-Ve}):String(Ve),ze=me.birth_year!=null||me.death_year!=null?`${Oe(me.birth_year)||"?"}—${Oe(me.death_year)||"?"}`:"";return{title:V(me.primary_name||me.title),subtitle:[me.dynasty?`〔${V(me.dynasty)}〕`:"",ze].filter(Boolean).join(" ")||void 0,aside:be?P.status.draft:void 0,secondLine:void 0}}const _e=V(bt(I,P.unit.juan));return{title:V(I.title),subtitle:[_e,B].filter(Boolean).join(" · ")||void 0,aside:[ux(P,I.subtype),be?P.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[I,V,P,Y]),we=I&&hi(I)?"text":null,Le=()=>{Ne(null),l("fulltext")};let Se=null;if(I&&S){const H=S({detail:I,kind:we});H&&(Se=e.jsx(Ci,{href:H}))}else we&&(Se=e.jsx(Ci,{onClick:Le}));const Fe=H=>{if(!I)return null;const B=H.replace(/\.[^.]+$/,"");if(S){const be=S({detail:I,kind:we,juan:B});return be?{href:be}:null}return{onClick:()=>{Ne(B),l("fulltext")}}},De=new Set($.map(H=>H.key)),J=te.filter(H=>H.key.startsWith("catalog:")&&H.key!=="catalog:loading"||H.key==="lineage"&&!!Ee&&!He||De.has(H.key)).map(H=>({key:H.key,label:H.label,onClick:()=>l(H.key)})),Pe=()=>{var H;return I?I.type==="work"?e.jsx(ca,{data:I,transport:n,onNavigate:f,renderLink:w,readAction:Se,railTop:k,railLinks:J}):I.type==="book"?e.jsx(ma,{data:I,transport:n,onNavigate:f,renderLink:w,readAction:Se,fullText:se,fullTextPending:hi(I)&&!!n.getTextManifest&&We!==I.id,chapterLink:Fe,railTop:k,railLinks:J}):I.type==="collection"?e.jsx(ga,{data:I,catalog:(H=q[0])==null?void 0:H.data,transport:n,onNavigate:f,renderLink:w,readAction:Se,railTop:k,railLinks:J,catalogAction:q.length>0?e.jsxs("a",{href:"#catalog",onClick:B=>{B.preventDefault(),l(`catalog:${q[0].resource_id}`)},children:[V(P.detailTab.collectionCatalog)," →"]}):null}):e.jsx(ha,{data:I,transport:n,onNavigate:f,renderLink:w,railTop:k,railLinks:J}):null},N=()=>{var B,be,_e;if(!ge||!I)return null;if(s==="basic"||s==="emendated")return Pe();if(typeof s=="string"&&s.startsWith("catalog:")){const je=(B=q.find(me=>`catalog:${me.resource_id}`===s))==null?void 0:B.data;return e.jsx(qi,{data:je,onNavigate:f,renderLink:w})}if(s==="collated"||s==="fulltext")return e.jsx(vo,{id:t,transport:n,chapter:he,onLocationChange:je=>Ne(je.chapter),onNavigate:f});if(s==="lineage"){if(!Ee)return e.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:Y(He?"detail.loading":"detail.noLineageGraph")});const je=I.type==="work"?I:null;return e.jsx(_o,{graph:Ee,renderLink:w,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:d,selectedNodeId:h,collection:u??((be=je==null?void 0:je.version_graph)==null?void 0:be.default_collection),onCollectionChange:g,collectionsAvailable:(_e=je==null?void 0:je.version_graph)==null?void 0:_e.collections,collectionCounts:(()=>{var Ve,Ae,lt,oe,Me,Xe,wt;if(!je)return;const me={},Oe=((Ve=re.current)==null?void 0:Ve.books)??[];me.all=(((Ae=je.books)==null?void 0:Ae.length)??0)-(((oe=(lt=je.version_graph)==null?void 0:lt.excluded_books)==null?void 0:oe.length)??0);const ze=(Me=je.version_graph)==null?void 0:Me.collections;if(ze)for(const Yt of Object.keys(ze))me[Yt]=$n(je,Oe,Yt).nodes.filter(fn=>fn.kind==="book"&&!fn.bridge).length;return me.core==null&&((wt=(Xe=je.version_graph)==null?void 0:Xe.core_books)!=null&&wt.length)&&(me.core=je.version_graph.core_books.length),me})()})}if(s==="feedback"&&_)return e.jsx(ra,{resourceId:t,apiUrl:z});const H=$.find(je=>je.key===s);return H?H.render({detail:I,entry:ge,transport:n,onNavigate:f}):null};if(ee)return e.jsx(nn,{style:{minHeight:E,...W},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((H,B)=>e.jsx("div",{style:{height:B===1?40:16,width:H,opacity:.35,background:i("rule")}},B))})});if(fe||!I||!ge||!le)return e.jsx(nn,{style:{minHeight:E,...W},children:e.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:Y("detail.notFound")})});const X=s==="basic"||s==="emendated",ae=[{label:y??P.detailTab.backToIndex,onClick:v}];if(I.type==="book"&&I.work_id){const H=I.work_id;ae.push({label:P.indexType.work,id:H,onClick:()=>f==null?void 0:f(H)})}ae.push({label:P.indexType[I.type]});const ie=s==="collated"||s==="fulltext",pe=typeof T=="string"?P.status[T.trim()]??T:T,$e=e.jsx(Nl,{left:e.jsxs(e.Fragment,{children:[pe,pe?" · ":"",e.jsx(px,{id:I.id,label:P.label.id,copied:P.action.copied,copyLabel:P.action.copy})]}),right:e.jsxs(e.Fragment,{children:[_&&!X&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:P.detailTab.submitVersion}),U&&e.jsx("a",{href:U.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:P.detailTab.dataLicense})]})});return X?e.jsx("div",{className:O,children:e.jsxs(nn,{grid:!0,style:{minHeight:E,...W},children:[e.jsx(zi,{breadcrumb:e.jsx(Ti,{items:ae}),actions:e.jsxs(e.Fragment,{children:[!C&&e.jsx(Ai,{style:{border:"none",background:"transparent"}}),!C&&U&&e.jsx(Bi,{...U})]})}),Pe(),$e]})}):e.jsx("div",{className:O,children:e.jsxs(nn,{wide:ie,style:{minHeight:E,...W},children:[e.jsx(zi,{breadcrumb:e.jsxs(e.Fragment,{children:[e.jsx(lo,{char:"籍"}),e.jsx(Ti,{items:ae})]}),actions:e.jsxs(e.Fragment,{children:[!C&&e.jsx(Ai,{}),_&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:P.detailTab.feedback}),!C&&U&&e.jsx(Bi,{...U})]})}),e.jsx(vl,{...le,aside:ie?e.jsxs("button",{type:"button",onClick:()=>l("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[Y("detail.workInfo")," →"]}):le.aside}),!ie&&te.length>1&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:te.map(H=>e.jsx(kl,{label:H.label,active:H.key===s||X&&H.key==="basic",onClick:()=>l(H.key)},H.key))}),e.jsx("div",{style:{marginTop:!ie&&te.length>1?8:0},children:N()}),$e]})})};function px({id:t,label:n,copied:o,copyLabel:r}){const[s,l]=x.useState(!1);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[e.jsxs("span",{children:[n," ",t]}),e.jsx("button",{type:"button",onClick:()=>{var a;(a=navigator.clipboard)==null||a.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1500)}).catch(()=>{})},title:s?o:r,"aria-label":s?o:r,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:i("aux-fg")},children:s?"✓":"⧉"})]})}function ux(t,n){return n?t.workSubtype[n]??n:""}const rc=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],qn="zhusha",Zn="bim-theme";function sc(t){return t==="zhusha"||t==="indigo"||t==="ink"}function Jn(t){return sc(t)?t:qn}function mx(){try{return Jn(window.localStorage.getItem(Zn))}catch{return qn}}function lc(t){try{window.localStorage.setItem(Zn,t)}catch{}}function ac(t){const n=Jn(t);return document.documentElement.setAttribute("data-theme",n),n}function cc(){return Jn(document.documentElement.getAttribute("data-theme"))}const gx=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Po="airy",Xn="bim-layout";function dc(t){return t==="airy"||t==="boxed"}function Qn(t){return dc(t)?t:Po}function hx(){try{return Qn(window.localStorage.getItem(Xn))}catch{return Po}}function xx(t){try{window.localStorage.setItem(Xn,t)}catch{}}function fx(t){const n=Qn(t);return document.documentElement.setAttribute("data-layout",n),n}function bx(){return Qn(document.documentElement.getAttribute("data-layout"))}const yx=`try{var t=localStorage.getItem(${JSON.stringify(Zn)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Xn)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,jx={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},vx=({onChange:t,style:n})=>{const{t:o}=G(),[r,s]=x.useState(qn);x.useEffect(()=>{s(cc())},[]);const l=a=>{s(ac(a)),lc(a),t==null||t(a)};return e.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:rc.map(a=>{const p=r===a.name;return e.jsx("button",{type:"button",role:"radio","aria-checked":p,"aria-label":o(`common.theme.${a.name}`),title:o(`common.theme.${a.name}`),onClick:()=>l(a.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:i(jx[a.name]),boxShadow:p?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},a.name)})})};exports.BidLink=xe.BidLink;exports.BookIndexError=xe.BookIndexError;exports.BookIndexManager=xe.BookIndexManager;exports.BookIndexStorage=xe.BookIndexStorage;exports.BundleStorage=xe.BundleStorage;exports.ConfigError=xe.ConfigError;exports.GithubStorage=xe.GithubStorage;exports.IdGenerationError=xe.IdGenerationError;exports.IdGenerator=xe.IdGenerator;exports.LocalStorage=xe.LocalStorage;exports.MigrationError=xe.MigrationError;exports.StorageError=xe.StorageError;exports.VARIANT_CHARS=xe.VARIANT_CHARS;exports.base36Decode=xe.base36Decode;exports.base36Encode=xe.base36Encode;exports.base58Decode=xe.base58Decode;exports.buildId=xe.buildId;exports.buildPromotionMap=xe.buildPromotionMap;exports.cleanName=xe.cleanName;exports.decodeId=xe.decodeId;exports.decodeIdString=xe.decodeIdString;exports.encodeId=xe.encodeId;exports.extractIdFromUrl=xe.extractIdFromUrl;exports.extractStatus=xe.extractStatus;exports.extractType=xe.extractType;exports.isChapterSegment=xe.isChapterSegment;exports.isTextKey=xe.isTextKey;exports.matchChapterAcrossVersions=xe.matchChapterAcrossVersions;exports.normalizeCatalog=xe.normalizeCatalog;exports.normalizeVariants=xe.normalizeVariants;exports.parseId=xe.parseId;exports.pickTextVersion=xe.pickTextVersion;exports.shardOf=xe.shardOf;exports.smartDecode=xe.smartDecode;exports.textVersionLabel=xe.textVersionLabel;exports.validateResource=xe.validateResource;exports.Badge=In;exports.BidUrlProvider=vc;exports.BookDetailLayout=dx;exports.BookPage=ma;exports.Breadcrumb=Ti;exports.CATALOG_ALL_ID=ht;exports.CATALOG_CSS=xa;exports.CATALOG_NARROW_QUERY=Co;exports.CATALOG_PAGE_SIZE=zo;exports.CATALOG_UNCLASSIFIED_ID=Ct;exports.CLASSIFICATIONS=Mn;exports.COMMON_TRADITIONAL_CHARS=gs;exports.CardFoot=mn;exports.CatalogPage=Kh;exports.CatalogPager=wa;exports.CatalogTree=ba;exports.CheckFilter=bl;exports.Chip=wl;exports.ChipWall=uu;exports.CollectionCatalog=qi;exports.CollectionPage=ga;exports.CreateEntityDialog=Jl;exports.DEFAULT_LAYOUT=Po;exports.DEFAULT_META_HOME_LINKS=Oa;exports.DEFAULT_READER_PREFS=Xi;exports.DEFAULT_READ_HOME_LINKS=$a;exports.DEFAULT_THEME=qn;exports.DETAIL_CSS=jl;exports.DYNASTY_GROUPS=Bn;exports.Dash=bu;exports.DataTable=gu;exports.DetailFooter=Nl;exports.DetailGrid=pn;exports.DetailHeader=vl;exports.EMPTY_FILTERS=An;exports.EmendatedBySection=Ms;exports.EmptyNote=$u;exports.EntityDetail=Rs;exports.EntityPage=ha;exports.EntityPickerDialog=Ql;exports.EntitySelector=Zl;exports.ExpandRow=yu;exports.ExtLink=_u;exports.FEEDBACK_FAB_OFFSET_VAR=Ei;exports.FILTER_SUPPORT=ws;exports.FONT_SIZE_STEPS=gt;exports.FactList=au;exports.FeedbackButton=Ag;exports.FeedbackDialog=ia;exports.FeedbackForm=oa;exports.FeedbackList=ko;exports.FeedbackTab=ra;exports.FilterChip=kl;exports.FormInput=nt;exports.FormTextArea=Tt;exports.GUJI_MARKDOWN_FIELD=mp;exports.GUJI_TABLE_NOTATION=Us;exports.GlyphBadge=lo;exports.GujiTable=co;exports.HomePage=Ii;exports.ImagePanel=vi;exports.IndexApp=Hm;exports.IndexBrowser=yi;exports.IndexDetail=Ki;exports.IndexEditor=ea;exports.IndexView=kg;exports.IntroGrid=lu;exports.LAYOUTS=gx;exports.LAYOUT_STORAGE_KEY=Xn;exports.LOSS_OPTIONS=ks;exports.LocaleContext=It;exports.LocaleProvider=Kc;exports.LocaleToggle=Ai;exports.META_HOME_CSS=Ha;exports.META_HOME_SECTION_IDS=oc;exports.MetaCatalogTable=qa;exports.MetaCollectionGroups=Qa;exports.MetaDataLicense=ic;exports.MetaHomeView=ax;exports.MetaLine=qe;exports.MetaLineageCards=tc;exports.MetaOnlineSites=nc;exports.MetaPeopleTimeline=ec;exports.MetaRecentPanel=Ya;exports.MetaRelatedCatalogs=Ja;exports.MetaTypeChips=Ua;exports.ModeIndicator=bs;exports.MoreButton=pu;exports.MoreLink=ro;exports.PAGE_MAX_WIDTH=wn;exports.PERIOD_NARROW_SHARE=Ta;exports.PageFrame=nn;exports.Quote=vu;exports.READER_CSS=Qs;exports.READ_HOME_CSS=No;exports.READ_HOME_NARROW_QUERY=xn;exports.READ_HOME_SECTION_IDS=Wa;exports.READ_PERIOD_LABELS=Xh;exports.RECENT_IDS_STORAGE_KEY=Mt;exports.ROLE_CLASS_ORDER=ul;exports.ReadButton=Ci;exports.ReadFamousWorks=Aa;exports.ReadHomeView=ex;exports.ReadPeriodBand=Ba;exports.ReadPicks=Ra;exports.ReadPieces=Ma;exports.ReadSection=et;exports.ReadShelf=Ro;exports.ReadSibu=Eo;exports.ReadStats=Ia;exports.ReadTopicGroup=La;exports.ReadTopics=Pa;exports.ReaderMdText=go;exports.ReaderShell=sl;exports.ReaderToc=tl;exports.RelationPanel=Kl;exports.RepoSourceLink=Bi;exports.ResourceEditor=fi;exports.ResourceGroup=ku;exports.ResourceLine=wu;exports.ResourceList=Ui;exports.ResourceRow=zl;exports.SEARCH_VIEW_STORAGE_KEY=Vi;exports.SEVEN_PAVILIONS_KEY=Xa;exports.SNIPPET_MARK_END=cs;exports.SNIPPET_MARK_START=as;exports.SORTABLE_TYPES=vs;exports.SearchInput=js;exports.SearchResults=Ts;exports.Sec=Ze;exports.Section=at;exports.SectionHead=cu;exports.SideList=zt;exports.SmartBidInput=Sn;exports.SourceEditor=Vl;exports.SummaryCard=un;exports.THEMES=rc;exports.THEME_INIT_SCRIPT=yx;exports.THEME_STORAGE_KEY=Zn;exports.TRADITIONAL_ALLOWLIST=hs;exports.TabFilter=Un;exports.TableHead=hu;exports.TableRow=xu;exports.TagRow=Tl;exports.TagRows=Su;exports.TextButton=du;exports.TextReader=vo;exports.ThemeToggle=vx;exports.TopStrip=zi;exports.VersionLineageGraph=ua;exports.VersionLineageList=pa;exports.VersionLineageView=_o;exports.VolumeChips=mu;exports.VolumeLinks=ao;exports.WorkCard=va;exports.WorkCardGrid=Sa;exports.WorkCatalog=Om;exports.WorkPage=ca;exports.WorkRow=ka;exports.applyLayout=fx;exports.applyTheme=ac;exports.authorsLine=Kn;exports.bucketResources=to;exports.buildCatalogTree=Wh;exports.buildCollectionTable=gl;exports.buildLineageGraph=$n;exports.buildMeiliFilter=pd;exports.buildPageUrl=Di;exports.buildParagraphBlocks=Pl;exports.buildVersionRow=dl;exports.buildVersionTable=pl;exports.canParagraphize=Tn;exports.catalogNodeIdOf=Bh;exports.catalogNodeIdsOf=Mh;exports.catalogPageCount=Dh;exports.catalogTotal=To;exports.classificationPath=hn;exports.clearAllRecentIds=Gi;exports.compareCatalogCards=Fh;exports.computeVersionPartition=Zp;exports.countActiveFilters=Wn;exports.createTextApi=Ks;exports.currentLayout=bx;exports.currentTheme=cc;exports.defaultWorkLink=ya;exports.deriveDating=Yp;exports.deriveEditionType=xl;exports.deriveEra=dn;exports.deriveYear=On;exports.deriveYearRange=eo;exports.detailToEditor=na;exports.detectGenre=Gn;exports.displayAuthorRole=io;exports.editorToDetail=vg;exports.eraRank=$i;exports.filtersFromParams=ud;exports.filtersToParams=_n;exports.findCatalogPath=Bt;exports.findTraditionalChars=Jc;exports.firstAuthorText=Io;exports.flattenTitles=Ni;exports.flattenToc=rl;exports.fmtCount=Ue;exports.formatHitCount=kn;exports.formatTemplate=it;exports.formatVolumeRange=Dn;exports.getDisplayNameFromUrl=Ut;exports.getMessages=Ft;exports.getStartPage=Fi;exports.getT=Dt;exports.getTypeGroupKey=Hi;exports.groupRelatedWorks=Kp;exports.gujiInlineToPlain=Ds;exports.hasActiveFilters=Ss;exports.hasGujiMarkdownV02=ji;exports.hasGujiTableNotation=Vs;exports.hasSearchOptions=ad;exports.isLayoutName=dc;exports.isThemeName=sc;exports.lineageHref=Fa;exports.loadRecentIds=jt;exports.measureText=bt;exports.mergeVolumeResources=Oi;exports.normalizeEra=Ke;exports.normalizeLayout=Qn;exports.normalizeRole=no;exports.normalizeTheme=Jn;exports.normalizeVolumeIndex=sn;exports.normalizeVolumes=fs;exports.numberToChinese=hl;exports.paginationItems=fa;exports.parseChineseNumber=Cn;exports.parseGujiInline=Fs;exports.parseGujiTable=Ys;exports.parseSourceString=Gl;exports.pct=Lo;exports.periodLevel=za;exports.pickReaderVersion=ol;exports.readStoredLayout=hx;exports.readStoredTheme=mx;exports.readerVersionOptionLabel=wi;exports.removeRecentId=Ns;exports.renderFullTextBody=Ru;exports.renderProperNames=Bl;exports.renderReaderInline=mo;exports.resolveRecentEntry=Yi;exports.resourceHref=Vt;exports.resourceNote=Fn;exports.resultTabFromParam=kd;exports.resultTabToParam=wd;exports.roleFacets=ml;exports.rowNo=fu;exports.sameFilters=md;exports.saveRecentId=bi;exports.shelfColumns=_a;exports.sortFor=cd;exports.sortYear=zn;exports.spineHeight=Ca;exports.splitFullTextTables=Zi;exports.splitHighlightSnippet=Mi;exports.splitTableRow=Gs;exports.storeLayout=xx;exports.storeTheme=lc;exports.stringifySources=Yl;exports.timelineLayout=Da;exports.toCatalogWorkCard=Oh;exports.typeSupportsFilters=$s;exports.useBidUrl=Ye;exports.useConvert=Te;exports.useI18n=G;exports.useReaderPrefs=il;exports.useRecentEntries=Va;exports.useT=ve;exports.validateLineageGraph=rh;exports.volumeStats=Ln;exports.withDefaultLinks=vt;exports.withMetaLinks=kt;exports.yearText=Rn;
|