book-index-ui 0.34.0 → 0.35.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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var nc=Object.create;var Ro=Object.defineProperty;var ic=Object.getOwnPropertyDescriptor;var oc=Object.getOwnPropertyNames;var rc=Object.getPrototypeOf,sc=Object.prototype.hasOwnProperty;var lc=(t,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of oc(n))!sc.call(t,s)&&s!==o&&Ro(t,s,{get:()=>n[s],enumerable:!(r=ic(n,s))||r.enumerable});return t};var hn=(t,n,o)=>(o=t!=null?nc(rc(t)):{},lc(n||!t||!t.__esModule?Ro(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ve=require("./storage-entry-DPsx0DgD.cjs"),e=require("react/jsx-runtime"),x=require("react"),ac=require("opencc-js/t2cn"),cc=require("react-markdown"),dc=require("remark-gfm"),pc=t=>`/book-index?id=${t}`,ns=x.createContext(pc);function uc({buildUrl:t,children:n}){const o=x.useMemo(()=>t,[t]);return e.jsx(ns.Provider,{value:o,children:n})}function Ve(){return x.useContext(ns)}const is="",os="";function Li(t){const n=[];let o=!1,r=t;for(;r.length;){const s=o?os:is,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',mc=[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:"#222221",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,只需覆盖那一个就同时换掉"}})],gc=Object.assign({},...mc.map(t=>t.tokens)),rs={};for(const[t,n]of Object.entries(gc))rs[t]=`var(--bim-${t}, ${n.value})`;function i(t){const n=rs[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 hc(t,n){return zt(t).includes(n)}const xc={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Tt=x.createContext(null),ss=["曹霑"];function fc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function bc(t,n=ss){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(fc).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 yc(){if(Vt)return Vt;try{Vt=bc(ac.Converter({from:"tw",to:"cn"}))}catch{Vt=t=>t}return Vt}const jc={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",onlyWorksNote:"部類、存佚只適用於作品;選了它們,版本、叢編、人物不參與。"},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:"圖片資源"}},vc={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",onlyWorksNote:"部类、存佚只适用于作品;选了它们,版本、丛编、人物不参与。"},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 kc=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:"作品信息"}),wc=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:"附记"}}),Sc=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}"}}),$c=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:"上级丛编"}),_c=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 为自动匹配,未经人工核对"}),Cc=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:"参考文献"}),zc=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:"本卷条目"}),Tc=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:"外部數字圖書館與本站條目的對接",sitesSubDen:"外部數字圖書館與本站條目的對接,以 {n} 種為分母",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:"外部数字图书馆与本站条目的对接",sitesSubDen:"外部数字图书馆与本站条目的对接,以 {n} 种为分母",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:"按作者浏览全部 →"}),Nc=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} 条"}),Ic=Xe({loss:{all:"全部",extant:"存",partially_extant:"殘",lost:"佚"},unclassified:"未分類",statBook:"書",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"詩詞",statPoemUnit:"首",statCollection:"叢編"},{loss:{all:"全部",extant:"存",partially_extant:"残",lost:"佚"},unclassified:"未分类",statBook:"书",statComma:",",statBookCopies:"本",statArticle:"文章",statArticleUnit:"篇",statPoem:"诗词",statPoemUnit:"首",statCollection:"丛编"}),Ec=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:"回复"}),Rc=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:"有争议"}}),Lc={common:kc,detail:Nn,bookPage:wc,workPage:Sc,collectionPage:$c,entityPage:_c,reader:Cc,collated:zc,metaHome:Tc,readHome:Pi,catalogPage:Nc,searchPage:Ic,feedback:Ec,lineage:Rc};function Pc(t){const n={};for(const[o,r]of Object.entries(Lc))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"?vc:jc,...Pc(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 ls(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=ls(Wt(t)),Bo.set(t,n)),n}const as="bim-locale";function Ac(){try{const t=localStorage.getItem(as);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function Bc(t){try{localStorage.setItem(as,t)}catch{}}const Mc="zh-Hans",Wc=({locale:t,onLocaleChange:n,converter:o,children:r})=>{const[s,l]=x.useState(t??Mc),a=t??s;x.useEffect(()=>{if(t)return;const u=Ac();u&&u!==s&&l(u)},[]);const d=x.useMemo(()=>a==="zh-Hans"?o??yc():null,[a,o]),c=x.useCallback(u=>{l(u),Bc(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 Hc=2e3;function Ne(){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>=Hc){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 q(){const t=x.useContext(Tt),{convert:n,locale:o,isSimplified:r}=Ne(),s=(t==null?void 0:t.messages)??Wt("zh-Hant"),l=x.useMemo(()=>t?ls(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 cs=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側抬","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Oc=new Set(cs),ds=[...ss,"切換為繁體","漢籍リポジトリ"];function Fc(t,n=ds){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)=>{Oc.has(l)&&r.push({char:l,context:s.slice(Math.max(0,a-8),a+9).join("")})}),r}function Dc(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 Uc(){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=Uc();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 $=Dc(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:Vc(b.type??"text"),color:i("on-color-fg")},children:(()=>{var _,E;const z=zt(b);return z.length===0?b.type??"text":z.length===1?((_=c.find(T=>T.value===z[0]))==null?void 0:_.label)??z[0]:z.includes("text")&&z.includes("image")?((E=c.find(T=>T.value==="text+image"))==null?void 0:E.label)??"text+image":z.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:z=>z.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&Gc(j,r==null?void 0:r[j],o,l),e.jsx("button",{onClick:z=>{z.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:[hc(b,"image")&&b.url&&Yc(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:z=>f(j,"type",z.target.value),style:{...at,flex:1},children:c.map(z=>e.jsx("option",{value:z.value,children:z.label},z.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:z=>f(j,"root_type",z.target.value),style:{...at,flex:1},children:p.map(z=>e.jsx("option",{value:z.value,children:z.label},z.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:b.id,onChange:z=>f(j,"id",z.target.value),placeholder:l.editor.idAutoExtract,style:{...at,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:b.name,onChange:z=>f(j,"name",z.target.value),placeholder:l.editor.resourceName,style:{...at,flex:1}})]}),e.jsx("input",{type:"text",value:b.url,onChange:z=>f(j,"url",z.target.value),placeholder:l.editor.resourceUrl,style:at}),e.jsx("input",{type:"text",value:((w=b.structure)==null?void 0:w.join("、"))||"",onChange:z=>y(j,z.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:z=>k(j,"level",z.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:z=>k(j,"ranges",z.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...at,flex:1}})]})]}),e.jsx("textarea",{value:b.details||"",onChange:z=>f(j,"details",z.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(([z,_])=>{var E;return e.jsxs("label",{style:{...Gt,gap:"4px"},children:[e.jsx("span",{style:{...Yt,minWidth:"56px"},children:_}),e.jsx("input",{type:"text",value:((E=b.metadata)==null?void 0:E[z])||"",onChange:T=>v(j,z,T.target.value),placeholder:_,style:{...at,flex:1}})]},z)})})]})]})]})]},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 Vc(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 Gc(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 Yc(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"},Kc={"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 Kc[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 ps(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 us(t){return!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(n=>({...n,url:n.url||ps(n)}))}function In(t){const n=us(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 qc(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}=Ne(),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=qc(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)})]})},Zc={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}=Ne(),[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||ps(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?{...Zc[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)})})]})},ms=({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 Jc(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 Xc(t){try{const n=tn().filter(o=>o!==t);localStorage.setItem(En,JSON.stringify(n))}catch{}}function Qc(){try{localStorage.removeItem(En)}catch{}}const gs=({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 C=n.trim();if(!C){m(v.map(A=>({type:"history",text:A})));return}if(!t.searchAll){m([]);return}let H=!1;const M=setTimeout(()=>{t.searchAll(C,Oo).then(A=>{if(H)return;const K=[...A.works,...A.books,...A.collections,...A.entities??[]];m(K.slice(0,Oo).map(Y=>({type:"entry",text:Y.title||Y.id,entry:Y})))}).catch(()=>{H||m([])})},80);return()=>{H=!0,clearTimeout(M)}},[n,v,t]),x.useEffect(()=>{const C=H=>{j.current&&!j.current.contains(H.target)&&u(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]),x.useEffect(()=>{const C=H=>{var M,A;if(H.key==="/"&&document.activeElement!==k.current){const K=(M=document.activeElement)==null?void 0:M.tagName;if(K==="INPUT"||K==="TEXTAREA"||K==="SELECT")return;H.preventDefault(),(A=k.current)==null||A.focus()}};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const S=x.useCallback(C=>{C.trim()&&(Jc(C.trim()),y(tn())),r(C),u(!1)},[r]),$=x.useCallback(C=>{C.type==="history"?(o(C.text),S(C.text)):C.entry&&(s?(s(C.entry),u(!1)):(o(C.text),S(C.text)))},[o,S,s]),z=x.useCallback(C=>{if(!p||g.length===0){C.key==="Enter"&&S(n);return}switch(C.key){case"ArrowDown":C.preventDefault(),f(H=>(H+1)%g.length);break;case"ArrowUp":C.preventDefault(),f(H=>(H-1+g.length)%g.length);break;case"Enter":C.preventDefault(),h>=0&&h<g.length?$(g[h]):S(n);break;case"Escape":C.preventDefault(),u(!1);break}},[p,g,h,n,S,$]),_=x.useCallback((C,H)=>{H.stopPropagation(),Xc(C),y(tn()),m(M=>M.filter(A=>!(A.type==="history"&&A.text===C)))},[]),E=x.useCallback(C=>{C.stopPropagation(),Qc(),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:k,type:"text",placeholder:d,value:n,onChange:C=>{o(C.target.value),u(!0)},onCompositionStart:()=>{w.current=!0},onCompositionEnd:()=>{w.current=!1},onFocus:()=>{u(!0)},onKeyDown:z,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:E,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:a.search.clearAll})]}),g.map((C,H)=>e.jsxs("div",{onClick:()=>$(C),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: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:M=>_(C.text,M),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}-${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:""},hs=new Set(["work","book","entity"]);function ed(t){return bs(t)||!!t.sort}function td(t,n){return n.sort&&hs.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:"未分類"}],xs=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],fs={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 bs(t){return An(t)>0}function nd(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 ys(t,n){const o=fs[t];return nd(n).every(r=>o.has(r))}const Kt=t=>JSON.stringify(t);function id(t,n){if(!ys(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"},js="_";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||js).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 od(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===js?"":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 rd(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 sd=({filters:t,onChange:n})=>{const o=ke(),r=o.searchV4,{convert:s}=Ne(),[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:xs.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"))})]}),e.jsx("p",{className:"bim-sr-note",children:s(r.onlyWorksNote)}),c>0&&e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Rn,sort:t.sort}),children:s(r.clearAllFilters)})]})]})};function vs({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}=Ne(),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(vs,{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)})})]})})},ld=`
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 ve=require("./storage-entry-DPsx0DgD.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:"#222221",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{Vt=jc(dc.Converter({from:"tw",to:"cn"}))}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),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=`
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
- `,Uo=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=ke(),l=s.searchV4,{convert:a}=Ne(),d=Ve();return e.jsxs("div",{className:"bim-sc-grid",children:[e.jsx("style",{children:ld}),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}`:"",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:d(c.id),onClick:v=>o(c,v),children:[e.jsx("span",{className:"bim-sc-t",children:e.jsx(vs,{text:p,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:Li(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 ad(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 cd(t,n,o){const r=Math.max(1,Math.ceil(n/o));return Math.min(Math.max(1,t),r)}const dd=({page:t,pageSize:n,total:o,onPage:r})=>{const s=ke().searchV4,{convert:l}=Ne(),a=Math.max(1,Math.ceil(o/n));return o<=0?null:e.jsxs("nav",{className:"bim-sr-pager","aria-label":l(s.pagerLabel),children:[e.jsx("span",{className:"bim-sr-info",children:l(tt(s.pageInfo,{total:o.toLocaleString(),size:n,page:t,pages:a}))}),a>1&&e.jsxs("ul",{children:[e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t<=1,onClick:()=>r(t-1),children:l(s.prevPage)})}),ad(t,a).map((d,c)=>d==="gap"?e.jsx("li",{className:"bim-sr-gap","aria-hidden":"true",children:"…"},`g${c}`):e.jsx("li",{children:e.jsx("button",{type:"button","aria-current":d===t?"page":void 0,"aria-label":`${d}`,onClick:()=>r(d),children:d})},d)),e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t>=a,onClick:()=>r(t+1),children:l(s.nextPage)})})]})]})},ks="(max-width: 719px)",pd=`${ks}, (pointer: coarse)`,ud=`
15
+ `,Uo=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=ke(),l=s.searchV4,{convert:a}=Te(),d=Ve();return e.jsxs("div",{className:"bim-sc-grid",children:[e.jsx("style",{children:ad}),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}`:"",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:d(c.id),onClick:v=>o(c,v),children:[e.jsx("span",{className:"bim-sc-t",children:e.jsx(ws,{text:p,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:Li(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 cd(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 dd(t,n,o){const r=Math.max(1,Math.ceil(n/o));return Math.min(Math.max(1,t),r)}const pd=({page:t,pageSize:n,total:o,onPage:r})=>{const s=ke().searchV4,{convert:l}=Te(),a=Math.max(1,Math.ceil(o/n));return o<=0?null:e.jsxs("nav",{className:"bim-sr-pager","aria-label":l(s.pagerLabel),children:[e.jsx("span",{className:"bim-sr-info",children:l(tt(s.pageInfo,{total:o.toLocaleString(),size:n,page:t,pages:a}))}),a>1&&e.jsxs("ul",{children:[e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t<=1,onClick:()=>r(t-1),children:l(s.prevPage)})}),cd(t,a).map((d,c)=>d==="gap"?e.jsx("li",{className:"bim-sr-gap","aria-hidden":"true",children:"…"},`g${c}`):e.jsx("li",{children:e.jsx("button",{type:"button","aria-current":d===t?"page":void 0,"aria-label":`${d}`,onClick:()=>r(d),children:d})},d)),e.jsx("li",{children:e.jsx("button",{type:"button",disabled:t>=a,onClick:()=>r(t+1),children:l(s.nextPage)})})]})]})},Ss="(max-width: 719px)",ud=`${Ss}, (pointer: coarse)`,md=`
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 ${ks} {
84
+ @media ${Ss} {
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 ${pd} {
105
+ @media ${ud} {
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,29 +117,44 @@
117
117
  :root[data-layout="boxed"] .bim-sr-table th { background: ${i("fr-bg")}; }
118
118
  /* 墨:强调色≈正文色,标题链接另加下划线 */
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"],md={work:"works",collection:"collections",book:"books",entity:"entities"},gd={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function hd(){try{return window.localStorage.getItem(Oi)==="card"?"card":"table"}catch{return"table"}}function xd(t){try{window.localStorage.setItem(Oi,t)}catch{}}const qt=(t,n)=>(t==null?void 0:t[gd[n]])??0,Qn=(t,n)=>(t==null?void 0:t[md[n]])??[],ws=({transport:t,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:l})=>{const a=ke(),d=a.searchV4,{convert:c}=Ne(),p=!!t.supportsSearchFilters,u=x.useMemo(()=>p?o:Rn,[p,o]),[g,m]=x.useState("table");x.useEffect(()=>{m(hd())},[]);const h=P=>{m(P),xd(P)},[f,v]=x.useState("all"),[y,k]=x.useState(1),[b,j]=x.useState(null),[w,S]=x.useState(null),[$,z]=x.useState(!1),[_,E]=x.useState(""),T=wn(u).toString(),C=An(u)>0,H=wn({...u,sort:""}).toString(),M=x.useRef({query:n,filterOnlyKey:H,sort:u.sort});x.useEffect(()=>{const P=M.current;P.query!==n||P.filterOnlyKey!==H?(v("all"),k(1)):P.sort!==u.sort&&k(1),M.current={query:n,filterOnlyKey:H,sort:u.sort}},[n,H,u.sort]),x.useEffect(()=>{let P=!1;return z(!0),E(""),(async()=>{try{let V;if(t.searchAll)V=await t.searchAll(n,Vo,u);else{const pe=["work","book","collection","entity"],ye=await Promise.all(pe.map(Z=>t.search(n,Z,{page:1,pageSize:Vo,filters:u})));V={works:ye[0].entries,books:ye[1].entries,collections:ye[2].entries,entities:ye[3].entries,totalWorks:ye[0].total,totalBooks:ye[1].total,totalCollections:ye[2].total,totalEntities:ye[3].total}}P||j(V)}catch(V){P||(E(V instanceof Error?V.message:String(V)),j(null))}finally{P||z(!1)}})(),()=>{P=!0}},[t,n,T]),x.useEffect(()=>{if(f==="all"){S(null);return}let P=!1;return z(!0),(async()=>{try{const V=await t.search(n,f,{page:y,pageSize:Xn,filters:u});P||S({entries:V.entries,total:V.total})}catch(V){P||(E(V instanceof Error?V.message:String(V)),S(null))}finally{P||z(!1)}})(),()=>{P=!0}},[t,n,T,f,y]),x.useEffect(()=>{if(f==="all"||!w||$)return;const P=Math.min(w.total,Go),V=cd(y,P,Xn);w.entries.length===0&&P>0&&V!==y&&k(V)},[f,w,$,y]);const A=x.useMemo(()=>Yo.filter(P=>qt(b,P)>0),[b]),K=A.reduce((P,V)=>P+qt(b,V),0),Y=!$&&!_&&b!==null&&K===0,ee=x.useCallback(P=>{v(P),k(1)},[]),ue=x.useMemo(()=>{const P=[];return u.dynasty.forEach(V=>P.push({name:V,remove:()=>r({...u,dynasty:u.dynasty.filter(pe=>pe!==V)})})),u.classification.forEach(V=>{var pe;return P.push({name:V?((pe=Pn.find(ye=>ye.value===V))==null?void 0:pe.label)??V:a.searchPage.unclassified,remove:()=>r({...u,classification:u.classification.filter(ye=>ye!==V)})})}),u.hasImage&&P.push({name:d.hasImage,remove:()=>r({...u,hasImage:!1})}),u.hasText&&P.push({name:d.hasText,remove:()=>r({...u,hasText:!1})}),u.hasCollated&&P.push({name:d.hasCollated,remove:()=>r({...u,hasCollated:!1})}),u.loss&&P.push({name:`${d.extant}:${a.searchPage.loss[u.loss]}`,remove:()=>r({...u,loss:""})}),P},[u,r,d,a]),B={query:n,onEntryLinkClick:s,typeName:l},R=P=>g==="table"?e.jsx(Do,{entries:P,...B}):e.jsx(Uo,{entries:P,...B}),Q=Yo.flatMap(P=>Qn(b,P));return e.jsxs("div",{className:"bim-sr-layout","data-nofilters":p?void 0:"true",children:[e.jsx("style",{children:ud}),p&&e.jsx(sd,{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:()=>ee("all"),children:[a.search.allTab," ",e.jsx("small",{children:K.toLocaleString()})]}),A.map(P=>e.jsxs(Ko,{on:f===P,onClick:()=>ee(P),children:[l(P)," ",e.jsx("small",{children:qt(b,P).toLocaleString()})]},P))]}),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(P=>{const V=u.sort.startsWith(`${P}:`)?u.sort.endsWith("desc")?"desc":"asc":null,pe=P==="era"?d.sortEra:d.sortTitle,ye=P==="era"?V==="desc"?d.sortEraDesc:d.sortEraAsc:V==="desc"?d.sortTitleDesc:d.sortTitleAsc;return e.jsxs("button",{type:"button","aria-pressed":V!==null,title:c(ye),onClick:()=>r({...u,sort:`${P}:${V==="asc"?"desc":"asc"}`}),children:[c(pe),V?e.jsxs("span",{"aria-hidden":"true",children:[" ",V==="asc"?"↑":"↓"]}):null]},P)})]}),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)})]})]}),C&&e.jsxs("div",{className:"bim-sr-chips-row",children:[e.jsx("span",{className:"bim-sr-count",role:"status",children:c(tt(d.filteredCount,{n:K.toLocaleString()}))}),ue.map(P=>e.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":c(tt(d.removeFilter,{name:P.name})),onClick:P.remove,children:[c(P.name),e.jsx("span",{"aria-hidden":"true",children:"×"})]},P.name))]}),_&&e.jsx("div",{className:"bim-sr-empty",role:"alert",children:_}),Y&&e.jsx("div",{className:"bim-sr-empty",children:c(C?d.emptyFiltered:tt(a.search.noResultsFor,{query:n}))}),!_&&!Y&&f==="all"&&b&&(g==="table"?e.jsxs(e.Fragment,{children:[e.jsx(Do,{entries:Q,...B}),e.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:c(d.limitedNote)})]}):e.jsx(e.Fragment,{children:A.map(P=>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:P,size:8}),l(P),e.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[qt(b,P).toLocaleString()," ",a.unit.items]})]}),qt(b,P)>Qn(b,P).length&&e.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>ee(P),children:a.action.viewAll})]}),e.jsx(Uo,{entries:Qn(b,P),...B})]},P))})),!_&&f!=="all"&&w&&w.entries.length>0&&e.jsxs(e.Fragment,{children:[R(w.entries),e.jsx(dd,{page:y,pageSize:Xn,total:Math.min(w.total,Go),onPage:k})]}),!_&&f!=="all"&&w&&w.entries.length===0&&!$&&e.jsxs("div",{className:"bim-sr-empty",children:[c(C?d.emptyFiltered:tt(a.search.noResultsFor,{query:n})),e.jsx("div",{children:e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>ee("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 Ss(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,fd=50,bd=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"],[$,z]=x.useState(m??""),[_,E]=x.useState(null),[T,C]=x.useState(m??""),H=wn(k).toString(),[M,A]=x.useState(k);x.useEffect(()=>{A(k)},[H]);const K=D=>{A(D),b==null||b(D)},[Y,ee]=x.useState(null),[ue,B]=x.useState("all"),[R,Q]=x.useState(!1),[P,V]=x.useState(null),[pe,ye]=x.useState(""),[Z,de]=x.useState(!(m!=null&&m.trim())),[he,Me]=x.useState(bt),[fe,$e]=x.useState([]),[We,Be]=x.useState(!1),[Re,ze]=x.useState(!1),[Ee,U]=x.useState(null),[ae,se]=x.useState(null),Se=x.useRef(void 0),F=x.useRef(!1),me=x.useCallback(async(D,Te)=>{if(!D.trim()){de(!0),E(null),ee(null);return}if(de(!1),y){C(D);return}Q(!0),ye("");try{if(t.searchAll){const Ce=await t.searchAll(D,Te??ei);E(Ce)}else{const Ce=["work","book","collection","entity"],je=await Promise.all(Ce.map(He=>t.search(D,He,{page:1,pageSize:Te??ei})));E({works:je[0].entries,books:je[1].entries,collections:je[2].entries,entities:je[3].entries,totalWorks:je[0].total,totalBooks:je[1].total,totalCollections:je[2].total,totalEntities:je[3].total})}}catch(Ce){ye(Ce instanceof Error?Ce.message:String(Ce)),E(null)}finally{Q(!1)}},[t,y]);x.useEffect(()=>{let D=!1;const Te=()=>{var ne,ce;const Ce=["work","book","collection","entity"],je=Promise.all(Ce.map(le=>t.loadEntries(le,{page:1,pageSize:1}).catch(()=>({total:0})))),He=((ne=t.getResourceCounts)==null?void 0:ne.call(t).catch(()=>null))??Promise.resolve(null),N=((ce=t.getSubtypeStats)==null?void 0:ce.call(t).catch(()=>null))??Promise.resolve(null);Promise.all([je,He,N]).then(([le,re,W])=>{D||(U({works:le[0].total,books:le[1].total,collections:le[2].total,entities:le[3].total,hasText:re==null?void 0:re.hasText,hasImage:re==null?void 0:re.hasImage}),W&&se(W))})};return t.getCounts?t.getCounts().then(Ce=>{var je,He;D||(U({works:Ce.works,books:Ce.books,collections:Ce.collections,entities:Ce.entities,hasText:(je=Ce.resourceCounts)==null?void 0:je.hasText,hasImage:(He=Ce.resourceCounts)==null?void 0:He.hasImage}),Ce.subtypeStats&&se(Ce.subtypeStats))}).catch(()=>{D||Te()}):Te(),()=>{D=!0}},[t]),x.useEffect(()=>{F.current||!(m!=null&&m.trim())||(F.current=!0,me(m))},[m,me]);const Ae=x.useCallback(D=>{if(z(D),!D.trim()){h==null||h(D),de(!0),E(null),ee(null),B("all");return}Se.current&&clearTimeout(Se.current),Se.current=setTimeout(()=>{ee(null),B("all"),h==null||h(D),me(D)},bd)},[me,h]),L=x.useCallback(D=>{Se.current&&clearTimeout(Se.current),B("all"),h==null||h(D),me(D)},[me,h]),X=x.useCallback(D=>{ee(D),me($,fd)},[$,me]);x.useEffect(()=>{if(!he.length){$e([]);return}let D=!1;return Be(!0),Promise.all(he.slice(0,10).map(Te=>Di(t,Te))).then(Te=>{D||($e(Te),Be(!1))}),()=>{D=!0}},[he,t]);const ge=D=>{V(D.id),gi(D.id),Me(bt()),r==null||r(D)},I=(D,Te)=>{if(r&&jd(Te)){Te.preventDefault(),ge(D);return}gi(D.id),Me(bt())},te=D=>{Ss(D),Me(bt())},J=()=>{Fi(),Me([])},oe=D=>w.find(Te=>Te.type===D),_e=!Z&&!_&&!pe,Le=_&&(_.works.length>0||_.books.length>0||_.collections.length>0);return e.jsxs("div",{className:"bim-browser-container",style:v?{minHeight:"100svh"}:void 0,children:[e.jsx("style",{children:vd}),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:[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(ms,{variant:"index-browser",indexSource:n,syncConfig:o,onSwitchMode:l,onToggleDraft:a,onConfigurePath:d,onSelectFolder:c})]})]})}),e.jsxs("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:[e.jsx(gs,{transport:t,value:$,onChange:Ae,onSearch:L,onEntrySelect:ge}),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})]}),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(ws,{transport:t,query:T,filters:M,onFiltersChange:K,onEntryLinkClick:I,typeName:D=>oe(D).name}),!(y&&!Z)&&e.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:R||_e?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:yd,boxSizing:"border-box"},children:j.search.searching}):pe?e.jsx("div",{style:{textAlign:"center",padding:"40px"},children:e.jsx("p",{style:{color:i("desc-fg")},children:pe})}):Z?e.jsx("div",{style:{flex:1},children:We?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:j.search.loading}):fe.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:fe.slice(0,Re?10:3).map(D=>D.notFound?e.jsx($d,{id:D.id,onRemove:te,t:j},D.id):e.jsx(Xo,{entry:D,selected:P===D.id,onClick:I,getConfig:oe,onRemove:te},D.id))}),!Re&&fe.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:kd}),(()=>{const D=N=>_[Jo[N]]??0,Te=S.map(N=>w.find(ne=>ne.type===N)).filter(N=>D(N.key)>0);if(Te.length<2)return null;const Ce=Te.reduce((N,ne)=>N+D(ne.key),0),je=N=>{if(B(N),N!=="all"&&Y!==N){const ne=w.find(le=>le.type===N),ce=(_[ne.key]??[]).length;D(ne.key)>ce&&X(N)}},He=N=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(N?"fg":"desc-fg"),fontWeight:N?700:400,boxShadow:N?`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":ue==="all",style:He(ue==="all"),onClick:()=>je("all"),children:[j.search.allTab," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:Ce.toLocaleString()})]}),Te.map(N=>e.jsxs("button",{type:"button","aria-pressed":ue===N.type,style:He(ue===N.type),onClick:()=>je(N.type),children:[N.name," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:D(N.key).toLocaleString()})]},N.type))]})})(),w.map(({type:D,name:Te,key:Ce})=>{const je=_[Ce]??[],He=Jo[Ce],N=_[He]??0;if(je.length===0||ue!=="all"&&ue!==D)return null;const ce=ue==="all"&&!(Y===D)&&N>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:D})," ",Te,e.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[N," ",j.unit.items]})]}),ce&&e.jsx("button",{className:"bim-ib-viewall",onClick:()=>X(D),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:je.map(le=>{if(g)return e.jsx(x.Fragment,{children:g(le)},le.id);const re=u==="card"?Sd:Xo;return e.jsx(re,{entry:le,selected:P===le.id,onClick:I,getConfig:oe,query:$},le.id)})})]},D)})]}):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})]})})]})},yd=240;function jd(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}const vd=`
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"],je=await Promise.all(de.map(Z=>t.search(n,Z,{page:1,pageSize:Vo,filters:u})));U={works:je[0].entries,books:je[1].entries,collections:je[2].entries,entities:je[3].entries,totalWorks:je[0].total,totalBooks:je[1].total,totalCollections:je[2].total,totalEntities:je[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(je=>je.value===U))==null?void 0:de.label)??U:a.searchPage.unclassified,remove:()=>r({...u,classification:u.classification.filter(je=>je!==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,je=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(je),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,je]=x.useState(""),[Z,ce]=x.useState(!(m!=null&&m.trim())),[fe,We]=x.useState(bt),[be,_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),je("");try{if(t.searchAll){const xe=await t.searchAll(X,Ie??ei);I(xe)}else{const xe=["work","book","collection","entity"],Me=await Promise.all(xe.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(xe){je(xe instanceof Error?xe.message:String(xe)),I(null)}finally{ee(!1)}},[t,y]);x.useEffect(()=>{let X=!1;const Ie=()=>{var se,ue;const xe=["work","book","collection","entity"],Me=Promise.all(xe.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(xe=>{var Me,P;X||(D({works:xe.works,books:xe.books,collections:xe.collections,entities:xe.entities,hasText:(Me=xe.resourceCounts)==null?void 0:Me.hasText,hasImage:(P=xe.resourceCounts)==null?void 0:P.hasImage}),xe.subtypeStats&&le(xe.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(!fe.length){_e([]);return}let X=!1;return Be(!0),Promise.all(fe.slice(0,10).map(Ie=>Di(t,Ie))).then(Ie=>{X||(_e(Ie),Be(!1))}),()=>{X=!0}},[fe,t]);const he=X=>{U(X.id),gi(X.id),We(bt()),r==null||r(X)},N=(X,Ie)=>{if(r&&vd(Ie)){Ie.preventDefault(),he(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:he}),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}):be.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:be.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&&be.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 xe=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:xe.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:xe})=>{const Me=C[xe]??[],P=Jo[xe],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=`
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
- `,kd=`
123
+ `,wd=`
124
+ .bim-ib-bar { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; padding: 0 20px 16px; }
125
+ .bim-ib-bar[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
126
+ .bim-ib-bar[data-nofilters] > [aria-hidden] { display: none; }
127
+ .bim-ib-bar-main { display: flex; gap: 8px; align-items: stretch; max-width: 720px; min-width: 0; }
128
+ .bim-ib-submit { flex: none; min-height: 40px; padding: 0 20px; border: 0; border-radius: 6px; background: ${i("accent")};
129
+ color: ${i("on-color-fg")}; font: inherit; font-size: 14px; letter-spacing: .1em; cursor: pointer; }
130
+ .bim-ib-submit:hover { filter: brightness(1.1); }
131
+ .bim-ib-submit:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 2px; }
132
+ @media (max-width: 719px) {
133
+ .bim-ib-bar { grid-template-columns: minmax(0, 1fr); padding: 0 16px 12px; }
134
+ .bim-ib-bar > [aria-hidden] { display: none; }
135
+ .bim-ib-bar-main { max-width: none; }
136
+ .bim-ib-submit { min-height: 44px; padding: 0 16px; }
137
+ }
138
+ `,Sd=`
124
139
  @media (max-width: 719px), (pointer: coarse) {
125
140
  .bim-ib-viewall { position: relative; }
126
141
  .bim-ib-viewall::after {
127
142
  content: ""; position: absolute; left: 50%; top: 50%;
128
143
  width: max(calc(100% + 8px), 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
129
144
  }
130
- }`,$s={color:"inherit",textDecoration:"none"},wd=({snippet:t})=>{const{convert:n}=Ne();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))})},Sd=({entry:t,selected:n,onClick:o,getConfig:r,query:s})=>{const l=ke(),{convert:a}=Ne(),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:{...$s,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(wd,{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}=Ne(),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:{...$s,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:"×"})]})},$d=({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 _d(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 Cd({data:t}){const{convert:n}=Ne(),{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 zd({alt_names:t}){const{convert:n}=Ne(),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 Td({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 Nd({works:t,transport:n,onNavigate:o,renderLink:r}){const s=ke(),{convert:l}=Ne(),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 _s=({data:t,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:l})=>{var g;const a=ke(),{convert:d}=Ne();let c=!1;try{c=ve.extractStatus(t.id)==="draft"}catch{}const p=_d(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(Cd,{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(zd,{alt_names:t.alt_names}),e.jsx(Td,{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(Nd,{works:t.works,transport:n,onNavigate:o,renderLink:r})]})},Id=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Ed(t){const n=t.search(Id);return n<0?[t,""]:[t.slice(0,n),t.slice(n)]}const Cs={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===Rd(t))){const[l,a]=Ed(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 Rd(t){try{return decodeURI(t)}catch{return t}}const Ld={...Cs,strong:({children:t})=>e.jsx(e.Fragment,{children:t})},ht=({text:t,plainStrong:n,style:o,className:r})=>{const{convert:s}=Ne(),l=n?Ld:Cs;return e.jsx("div",{className:r,style:o,children:e.jsx(cc,{remarkPlugins:[dc],components:l,children:s(t)})})},Pd=["〇","一","二","三","四","五","六","七","八","九"],Qo=["","十","百","千"];function zs(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+=Pd[a]+Qo[d])}return r}function Ts(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 Ad={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function Bd({type:t}){const n=ke();return e.jsx("span",{style:Ts(Ad[t]),children:n.indexType[t]})}function Md({isDraft:t}){const n=ke(),o=i(t?"status-draft":"status-official");return e.jsx("span",{style:Ts(o),children:t?n.status.draft:n.status.official})}function Wd({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 Ns({authors:t,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Ne();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 Hd({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(Bd,{type:r}),e.jsx(Md,{isDraft:s}),e.jsx(Wd,{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(Ns,{authors:l,type:r,onNavigate:p,renderLink:u}),d]})]})}function Is({items:t,label:n,showMeta:o,onNavigate:r,renderLink:s}){const l=ke(),{convert:a}=Ne();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 Od({items:t,onNavigate:n,renderLink:o}){const r=ke();return e.jsx(Is,{items:t,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function Es({items:t,onNavigate:n,renderLink:o}){const r=ke();return e.jsx(Is,{items:t,label:r.section.emendated,onNavigate:n,renderLink:o})}function Rs({label:t,items:n}){const{convert:o}=Ne();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 Fd({items:t}){const n=ke();return e.jsx(Rs,{label:n.section.aliases,items:t})}function Dd({items:t}){const n=ke();return e.jsx(Rs,{label:n.section.attachedTexts,items:t})}function Ud({items:t}){const n=ke(),{convert:o}=Ne();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 Vd({items:t}){const n=ke(),{convert:o}=Ne();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 Gd({items:t}){const n=ke(),{convert:o}=Ne();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}=Ne(),[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}=Ne(),[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 Yd({ids:t,workData:n,transport:o,onNavigate:r,renderLink:s,footer:l}){const a=ke(),{convert:d}=Ne(),[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=Kd(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 Kd(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 qd({workData:t,onNavigate:n,renderLink:o}){var a,d,c,p;const r=ke(),{convert:s}=Ne(),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:[zs(t.juan_count.number),r.unit.juan]}):null,t.authors&&t.authors.length>0&&e.jsx("span",{style:{fontSize:"13px"},children:e.jsx(Ns,{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 Zd({items:t,onNavigate:n,renderLink:o}){const r=ke(),{convert:s}=Ne();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,M,A,K,Y,ee,ue,B;const p=ke(),{convert:u}=Ne(),[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 R=!1;return f(!0),y(null),o.getItem(n).then(Q=>{R||(Q?m(Q):y(p.misc.notFoundEntry))}).catch(Q=>{R||y(Q instanceof Error?Q.message:p.misc.loadFailed)}).finally(()=>{R||f(!1)}),()=>{R=!0}},[t,n,o]),x.useEffect(()=>{if(!S||!o){b(null),w([]);return}let R=!1;const Q=S.type==="book"||S.type==="collection"?S.work_id:void 0;if(Q?o.getItem(Q).then(P=>{!R&&P&&P.type==="work"&&b(P)}).catch(()=>{}):b(null),S.type==="book"){const P=S;P.contained_in&&P.contained_in.length>0?Promise.all(P.contained_in.map(V=>{const pe=typeof V=="string"?V:V.id,ye=typeof V=="string"?void 0:V.volume_index;return o.getItem(pe).then(Z=>({id:pe,title:Z&&Z.title||pe,volume_index:ye})).catch(()=>({id:pe,title:pe,volume_index:ye}))})).then(V=>{R||w(V)}):w([])}else w([]);return()=>{R=!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((R,Q)=>e.jsx("div",{style:{height:Q===1?"32px":"16px",width:`${R}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},Q))})});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(_s,{data:S,transport:o,onNavigate:r,renderLink:s,headerExtra:l})});const $=S.type==="book"?S:null,z=S.type==="collection"?S:null,_=S.type==="work"?S:null;let E=!1;try{E=ve.extractStatus(S.id)==="draft"}catch{}let T="";S.measure_info?T=u(S.measure_info):(H=S.juan_count)!=null&&H.number?T=zs(S.juan_count.number)+p.unit.juan:(M=S.juan_count)!=null&&M.description&&(T=u(S.juan_count.description));const C=[];return(A=S.publication_info)!=null&&A.year&&C.push(e.jsx(ct,{label:p.label.year,children:S.publication_info.year},"year")),(K=S.current_location)!=null&&K.name&&C.push(e.jsx(ct,{label:p.label.currentLocation,children:u(S.current_location.name)},"loc")),(Y=S.page_count)!=null&&Y.description&&C.push(e.jsx(ct,{label:p.label.pageCount,children:S.page_count.description},"page")),$!=null&&$.edition&&C.push(e.jsx(ct,{label:p.label.edition,children:u($.edition)},"ver")),_!=null&&_.parent_work&&C.push(e.jsx(ct,{label:p.label.parentWork,children:e.jsx(lt,{id:_.parent_work.id,label:u(_.parent_work.title),onNavigate:r,renderLink:s})},"pw")),_!=null&&_.parent_works&&_.parent_works.length>0&&!_.parent_work&&C.push(e.jsx(ct,{label:p.label.parentWork,children:_.parent_works.map((R,Q)=>e.jsxs("span",{children:[Q>0&&"、",e.jsx(lt,{id:R,onNavigate:r,renderLink:s})]},R))},"pws")),e.jsxs("div",{className:d,style:c,children:[e.jsx(Hd,{id:S.id,title:u(S.title),edition:S.edition?u(S.edition):void 0,type:S.type,isDraft:E,authors:S.authors,volumeText:T,meta:C,headerExtra:l,onNavigate:r,renderLink:s}),((ee=S.description)==null?void 0:ee.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((R,Q)=>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(R.title)}),e.jsx(ht,{text:R.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},Q))}),j.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:p.section.containedIn}),e.jsx(Zd,{items:j,onNavigate:r,renderLink:s})]}),k&&e.jsxs(e.Fragment,{children:[e.jsx(ot,{children:p.section.belongsToWork}),e.jsx(qd,{workData:k,onNavigate:r,renderLink:s})]}),S.additional_works&&S.additional_works.length>0&&e.jsx(Ud,{items:S.additional_works}),S.additional_titles&&S.additional_titles.length>0&&e.jsx(Fd,{items:S.additional_titles}),S.attached_texts&&S.attached_texts.length>0&&e.jsx(Dd,{items:S.attached_texts}),S.indexed_by&&S.indexed_by.length>0&&e.jsx(Od,{items:S.indexed_by,onNavigate:r,renderLink:s}),S.emendated_by&&S.emendated_by.length>0&&e.jsx(Es,{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(Vd,{items:$.location_history}),(z==null?void 0:z.history)&&z.history.length>0&&e.jsx(Gd,{items:z.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}),(z==null?void 0:z.books)&&z.books.length>0&&e.jsx(er,{title:p.section.containedBooks,ids:z.books,transport:o,onNavigate:r,renderLink:s}),(z==null?void 0:z.contained_works)&&z.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:["(",z.contained_works.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:z.contained_works.map(R=>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:R.id,label:u(R.title),onNavigate:r,renderLink:s})},R.id))})]}),(((ue=_==null?void 0:_.books)==null?void 0:ue.length)||0)+(((B=_==null?void 0:_.collections)==null?void 0:B.length)||0)>0&&e.jsx(Yd,{ids:[...(_==null?void 0:_.books)||[],...(_==null?void 0:_.collections)||[]],workData:_??void 0,transport:o,onNavigate:r,renderLink:s,footer:a}),(_==null?void 0:_.related_works)&&_.related_works.length>0&&(()=>{const R=[],Q=_.related_works.filter(de=>de.relation==="part_of"),P=_.related_works.filter(de=>de.relation==="has_part"),V=_.related_works.filter(de=>de.relation==="has_adaptation"),pe=_.related_works.filter(de=>de.relation==="text_carried_by"),ye=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),Z=_.related_works.filter(de=>!de.relation||!ye.has(de.relation));return Q.length>0&&R.push({label:p.section.belongsToWork,items:Q}),P.length>0&&R.push({label:p.section.containedWorks,items:P}),V.length>0&&R.push({label:p.section.adaptations,items:V}),pe.length>0&&R.push({label:p.section.derivativeWorks,items:pe}),Z.length>0&&R.push({label:p.section.relatedWorks,items:Z}),R.map(de=>e.jsxs("div",{children:[e.jsxs(ot,{children:[de.label,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",de.items.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:de.items.map(he=>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:he.id,label:u(he.title),onNavigate:r,renderLink:s})},he.id))})]},de.label))})()]})};function Jd({data:t}){const n=ke(),{convert:o}=Ne(),{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 Xd({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 Qd({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 ep(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}=Ne(),a=t.book_id||t.work_id,d=r&&t.volumes.length>0?ep(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(Qd,{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 z=!1;return g(!0),h(null),o.getCollectionCatalog(n).then(_=>{z||(_?p(_):h(d.catalog.notFound))}).catch(_=>{z||h(_ instanceof Error?_.message:d.catalog.loadFailed)}).finally(()=>{z||g(!1)}),()=>{z=!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 z=b.books.map(E=>E.volumes[0]).filter(E=>E!=null);return new Set(z).size<z.length},[b]),S=x.useMemo(()=>{if(!b)return[];let z=b.books;if(f&&(z=z.filter(_=>_.section===f)),y.trim()){const _=y.trim().toLowerCase();z=z.filter(E=>E.title.toLowerCase().includes(_)||E.sub_items&&E.sub_items.some(T=>T.toLowerCase().includes(_))||E.edition&&E.edition.toLowerCase().includes(_))}return z},[b,f,y]),$=x.useMemo(()=>{if(!w)return null;const z=[],_=new Map;for(const T of S){if(!T.volumes||T.volumes.length===0)continue;const C=T.volumes[0];_.has(C)||_.set(C,[]),_.get(C).push(T)}const E=[..._.keys()].sort((T,C)=>T-C);for(const T of E)z.push({volume:T,books:_.get(T)});return z},[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(Jd,{data:b}),j&&e.jsx(Xd,{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:z=>k(z.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((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:tt(d.catalog.volume,{n:z.volume})}),z.books.map((E,T)=>e.jsx(nr,{book:E,onNavigate:r,renderLink:s,showVolumes:E.volumes.length>1},`${z.volume}-${T}`))]},`${z.volume}-${_}`)):S.map((z,_)=>e.jsx(nr,{book:z,onNavigate:r,renderLink:s,showVolumes:!0},_)),S.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},tp="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 np=/^□\{guess=([^\s{}]+)\}/;function ip(t,n){const o=t[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function Ls(t,n){let o=0;for(let r=n;r<t.length;r++){const s=t[r];if(s===`
131
- `)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function op(t){return t.replace(/\\([\\[\]<>|{}])/g,"$1")}function rp(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(`
132
- `)<0?{node:{type:"qw",label:t.slice(n+2,r)},end:r+2}:null}if(o===":"&&t.startsWith(":zi[",n)){const r=Ls(t,n+3);return r>n+4?{node:{type:"zi",label:op(t.slice(n+4,r))},end:r+1}:null}if(o==="□"&&t[n+1]==="{"){const r=np.exec(t.slice(n,n+64));if(r)return{node:{type:"qz",guess:r[1]},end:n+r[0].length}}return null}function Ps(t,n,o,r){const s=[];let l="";const a=()=>{if(!l)return;const d=r?l.replace(/\\?\|/g,""):l;d&&s.push({type:"text",text:d}),l=""};for(;n<t.length;){const d=t[n];if(o!==null){if(d===o)return a(),{nodes:s,end:n};if(d===`
133
- `)return null}const c=rp(t,n);if(c){a(),s.push(c.node),n=c.end;continue}let p=null;if(d==="⟨"?p="⟩":d==="<"&&ip(t,n)&&(p=">"),p){const u=Ps(t,n+1,p,!0);if(u){a(),s.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=d,n++}return o!==null?null:(a(),{nodes:s,end:n})}function As(t){return Ps(t,0,null,!1).nodes}function sp(t){return/[<⟨□]|\[\[|:zi\[/.test(t)}function Bs(t){return t.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Bs(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Ms="guji-table-v1";function Ws(t){return!!t&&t.table_notation===Ms}const lp=/^:::table(?:\{[^}]*\})?[ \t]*$/,ap=/^:::[ \t]*$/;function Hs(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=Ls(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 cp=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function dp(t){if(t==="^")return{cont:!0};const n=cp.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 Os(t,n=1){const o=[],r=[],s=[];let l=[];t.forEach((d,c)=>{const p=c+n+1;let u=d.trim();if(!u)return;let g=!1;u.startsWith("!")&&(g=!0,u=u.slice(1));const m=Hs(u).map(dp),h=l.map(k=>k>0),f=l.map(k=>k>0?k-1:0),v=[];let y=0;for(const k of m){if(k.cont){h[y]||o.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=k;for(let j=y;j<y+b.colspan;j++)if(h[j]){o.push(`第 ${p} 行第 ${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 k=y;k<h.length;k++)h[k]&&o.push(`第 ${p} 行第 ${k+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let k=0;k<f.length;k++)f[k]===void 0&&(f[k]=0);l=f,r.push({header:g,cells:v}),s.push({width:y,line:p})});const a=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==a&&o.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${a} 不符`);return l.some(d=>d>0)&&o.push("表尾:有跨行格超出了表的最后一行"),r.length===0&&o.push("空表"),{rows:r,columns:a,warnings:o}}function Gi(t){const n=t.split(`
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=ve.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,je=typeof U=="string"?void 0:U.volume_index;return o.getItem(de).then(Z=>({id:de,title:Z&&Z.title||de,volume_index:je})).catch(()=>({id:de,title:de,volume_index:je}))})).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=ve.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"),je=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),Z=C.related_works.filter(ce=>!ce.relation||!je.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(fe=>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:fe.id,label:u(fe.title),onNavigate:r,renderLink:s})},fe.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 sp(t){return t.replace(/\\([\\[\]<>|{}])/g,"$1")}function lp(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=As(t,n+3);return r>n+4?{node:{type:"zi",label:sp(t.slice(n+4,r))},end:r+1}:null}if(o==="□"&&t[n+1]==="{"){const r=op.exec(t.slice(n,n+64));if(r)return{node:{type:"qz",guess:r[1]},end:n+r[0].length}}return null}function Bs(t,n,o,r){const s=[];let l="";const a=()=>{if(!l)return;const d=r?l.replace(/\\?\|/g,""):l;d&&s.push({type:"text",text:d}),l=""};for(;n<t.length;){const d=t[n];if(o!==null){if(d===o)return a(),{nodes:s,end:n};if(d===`
148
+ `)return null}const c=lp(t,n);if(c){a(),s.push(c.node),n=c.end;continue}let p=null;if(d==="⟨"?p="⟩":d==="<"&&rp(t,n)&&(p=">"),p){const u=Bs(t,n+1,p,!0);if(u){a(),s.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=d,n++}return o!==null?null:(a(),{nodes:s,end:n})}function Ms(t){return Bs(t,0,null,!1).nodes}function ap(t){return/[<⟨□]|\[\[|:zi\[/.test(t)}function Ws(t){return t.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Ws(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Hs="guji-table-v1";function Os(t){return!!t&&t.table_notation===Hs}const cp=/^:::table(?:\{[^}]*\})?[ \t]*$/,dp=/^:::[ \t]*$/;function Fs(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=As(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 pp=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function up(t){if(t==="^")return{cont:!0};const n=pp.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 Ds(t,n=1){const o=[],r=[],s=[];let l=[];t.forEach((d,c)=>{const p=c+n+1;let u=d.trim();if(!u)return;let g=!1;u.startsWith("!")&&(g=!0,u=u.slice(1));const m=Fs(u).map(up),h=l.map(k=>k>0),f=l.map(k=>k>0?k-1:0),v=[];let y=0;for(const k of m){if(k.cont){h[y]||o.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=k;for(let j=y;j<y+b.colspan;j++)if(h[j]){o.push(`第 ${p} 行第 ${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 k=y;k<h.length;k++)h[k]&&o.push(`第 ${p} 行第 ${k+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let k=0;k<f.length;k++)f[k]===void 0&&(f[k]=0);l=f,r.push({header:g,cells:v}),s.push({width:y,line:p})});const a=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==a&&o.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${a} 不符`);return l.some(d=>d>0)&&o.push("表尾:有跨行格超出了表的最后一行"),r.length===0&&o.push("空表"),{rows:r,columns:a,warnings:o}}function Gi(t){const n=t.split(`
134
149
  `),o=[];let r=[];const s=()=>{if(r.length===0)return;const a=r.join(`
135
- `);r=[],o.push({type:"text",text:a})};let l=0;for(;l<n.length;){if(lp.test(n[l].trim())){let a=l+1;for(;a<n.length&&!ap.test(n[a].trim());)a++;if(a<n.length){s();const d=n.slice(l+1,a);o.push({type:"table",table:Os(d,l+1),source:n.slice(l,a+1).join(`
136
- `)}),l=a+1;continue}}r.push(n[l]),l++}return s(),o.map((a,d)=>{var p,u;if(a.type!=="text")return a;let c=a.text;return((p=o[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((u=o[d+1])==null?void 0:u.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(a=>a.type!=="text"||a.text!=="")}const ni=t=>t?t.catch(()=>null):Promise.resolve(null);function Fs(t){const n=new Map;function o(r){var l;let s=n.get(r);return s||(s=ni((l=t.getTextManifest)==null?void 0:l.call(t,r)).then(a=>{const d=a&&Array.isArray(a.versions)&&a.versions.length>0?a:null;return d||n.delete(r),d}),n.set(r,s)),s}return{getManifest(r){return ve.isSafeSegment(r)?o(r):Promise.resolve(null)},async getIndex(r,s){return!ve.isSafeSegment(r)||!ve.isSafeSegment(s)||!t.getTextIndex?null:ni(t.getTextIndex(r,s))},async getChapter(r,s,l,a){return!ve.isSafeSegment(r)||!ve.isSafeSegment(s)||!ve.isSafeSegment(l)||!t.getChapter?null:ni(t.getChapter(r,s,l,a))}}}const Nt=()=>{const{t}=q(),[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)})},Ds="(min-width: 1100px)",Us="(max-width: 719px)",Vs="(max-width: 859px)",pp=`${Us}, (pointer: coarse)`,ft=i("reader-top"),up="48px",Gs=`
150
+ `);r=[],o.push({type:"text",text:a})};let l=0;for(;l<n.length;){if(cp.test(n[l].trim())){let a=l+1;for(;a<n.length&&!dp.test(n[a].trim());)a++;if(a<n.length){s();const d=n.slice(l+1,a);o.push({type:"table",table:Ds(d,l+1),source:n.slice(l,a+1).join(`
151
+ `)}),l=a+1;continue}}r.push(n[l]),l++}return s(),o.map((a,d)=>{var p,u;if(a.type!=="text")return a;let c=a.text;return((p=o[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((u=o[d+1])==null?void 0:u.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(a=>a.type!=="text"||a.text!=="")}const ni=t=>t?t.catch(()=>null):Promise.resolve(null);function Us(t){const n=new Map;function o(r){var l;let s=n.get(r);return s||(s=ni((l=t.getTextManifest)==null?void 0:l.call(t,r)).then(a=>{const d=a&&Array.isArray(a.versions)&&a.versions.length>0?a:null;return d||n.delete(r),d}),n.set(r,s)),s}return{getManifest(r){return ve.isSafeSegment(r)?o(r):Promise.resolve(null)},async getIndex(r,s){return!ve.isSafeSegment(r)||!ve.isSafeSegment(s)||!t.getTextIndex?null:ni(t.getTextIndex(r,s))},async getChapter(r,s,l,a){return!ve.isSafeSegment(r)||!ve.isSafeSegment(s)||!ve.isSafeSegment(l)||!t.getChapter?null:ni(t.getChapter(r,s,l,a))}}}const Nt=()=>{const{t}=K(),[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)})},Vs="(min-width: 1100px)",Gs="(max-width: 719px)",Ys="(max-width: 859px)",mp=`${Gs}, (pointer: coarse)`,ft=i("reader-top"),gp="48px",Ks=`
137
152
  .bim-rd {
138
153
  position: relative;
139
154
  background: ${i("page-bg")};
140
155
  color: ${i("ink")};
141
156
  font-family: ${i("font-ui")};
142
- --bimrd-bar-h: ${up};
157
+ --bimrd-bar-h: ${gp};
143
158
  }
144
159
  .bim-rd *, .bim-rd *::before, .bim-rd *::after { box-sizing: border-box; }
145
160
 
@@ -429,7 +444,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
429
444
  .bim-rd-sheet-img .bim-rd-img-fig img { max-height: 60vh; }
430
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")}; }
431
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")}; }
432
- @media ${Vs} {
447
+ @media ${Ys} {
433
448
  .bim-rd[data-bb] .bim-rd-text { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom, 0px)); }
434
449
  /* 底栏上已有的,工具条上不再重复(目录、字号) */
435
450
  .bim-rd[data-bb] .bim-rd-bb-dup { display: none !important; }
@@ -439,7 +454,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
439
454
 
440
455
  /* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
441
456
  A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
442
- @media ${pp} {
457
+ @media ${mp} {
443
458
  .bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
444
459
  .bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
445
460
  content: ""; position: absolute; left: 50%; top: 50%;
@@ -452,7 +467,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
452
467
  }
453
468
 
454
469
  /* ── 中屏以下:目录改抽屉 ── */
455
- @media not all and ${Ds} {
470
+ @media not all and ${Vs} {
456
471
  .bim-rd-toc {
457
472
  position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
458
473
  width: min(86vw, 320px);
@@ -466,7 +481,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
466
481
  }
467
482
 
468
483
  /* ── 窄屏:书影收起,只留正文 ── */
469
- @media ${Us} {
484
+ @media ${Gs} {
470
485
  .bim-rd-bar { padding: 0 12px; gap: 10px; }
471
486
  .bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
472
487
  /* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
@@ -500,12 +515,12 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
500
515
  :root[data-theme="ink"] .bim-rd-t[aria-pressed="true"], :root[data-theme="ink"] .bim-rd-t[aria-current="true"] {
501
516
  text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px;
502
517
  }
503
- `;function Yi(t,n){var o;return n?t.key===n?!0:!!((o=t.children)!=null&&o.some(r=>Yi(r,n))):!1}const mp=()=>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 gp({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(mp,{}),e.jsx("span",{children:t.label}),t.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:t.hint})]}),l&&e.jsx(Ys,{items:t.children,activeKey:n,onSelect:o,tabKey:r})]})}function Ys({items:t,activeKey:n,onSelect:o,tabKey:r}){return e.jsx("ul",{children:t.map(s=>s.children&&s.children.length>0?e.jsx(gp,{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 Ks({items:t,activeKey:n,onSelect:o,label:r}){const{t:s}=q(),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(Ys,{items:t,activeKey:n,onSelect:o,tabKey:p})})}function hp({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}=q(),[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(hp,{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,qs="bim-reader-prefs",xp="bim-reading-mode";function fp(){const t={...Ki};try{const n=localStorage.getItem(qs),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&ut.includes(o.fontSize)&&(t.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(xp))==="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 bp(t){try{localStorage.setItem(qs,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 Zs(){const[t,n]=x.useState(Ki);x.useEffect(()=>{n(fp())},[]);const o=x.useCallback(r=>{n(s=>{const l={...s,...r};return bp(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 Js(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 Xs(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"})}),yp=()=>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"})}),jp=()=>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 vp(){const t=x.useContext(Tt),{t:n}=q();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 kp(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 wp(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 Qs({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:z,bottomBar:_=!0,pager:E=!0,pagerUnit:T,versions:C,currentVersionKey:H,onVersionChange:M,versionSource:A=!0,keepChapterOnVersionChange:K=!1,children:Y,className:ee,style:ue}){const{t:B,convert:R}=q(),Q=z??B("reader.back"),P=R(T??B("reader.unitJuan")),V=x.useId().replace(/:/g,""),pe=`bim-rd-toc-${V}`,ye=`bim-rd-text-${V}`,Z=x.useRef(null),de=x.useRef(null),he=x.useRef(null),Me=x.useRef(null),fe=lr(Ds,!0),$e=lr(Vs,!1),We=_&&$e,[Be,Re]=x.useState(null),ze=x.useRef(null),Ee=x.useRef(null),U=(O,we)=>{Ee.current=we,Re(be=>be===O?null:O)},ae=x.useCallback(()=>{var O;Re(null),(O=Ee.current)==null||O.focus()},[]);x.useEffect(()=>{We||Re(null)},[We]),x.useEffect(()=>{var O,we;Be&&((we=(O=ze.current)==null?void 0:O.querySelector("button:not([disabled])"))==null||we.focus())},[Be]);const[se,Se]=x.useState("auto"),F=se==="auto"?fe:se==="open",me=!fe,Ae=!!d&&d.length>0,[L,X]=x.useState(u);x.useEffect(()=>{X(u)},[u]);const ge=L==="auto"?Ae||!!c:L==="open",I=x.useCallback(O=>{var we;Se("auto"),O&&((we=Me.current)==null||we.focus())},[]),te=()=>Se(F?"closed":"open");x.useEffect(()=>{if(!me||se!=="open")return;const O=he.current,we=O==null?void 0:O.querySelector('input, [data-rd-toc-key][tabindex="0"]');we==null||we.focus()},[me,se]);const J=x.useCallback(O=>{s(O),me&&I(!1);const we=de.current,be=Z.current;if(we&&be&&typeof window<"u"){const ie=we.getBoundingClientRect().top-be.getBoundingClientRect().bottom;ie<0&&window.scrollBy({top:ie})}},[s,me,I]),oe=x.useMemo(()=>Xs(o),[o]),[_e,Le]=x.useState(null),D=Js(C,H!==void 0?H:_e),Te=(D==null?void 0:D.key)??null,Ce=x.useMemo(()=>oe.map(O=>O.key).join(`
504
- `),[oe]),je=x.useRef(null),He=O=>{O!==Te&&(K||(je.current={key:O,sig:Ce,done:!1}),H===void 0&&Le(O),M==null||M(O))};x.useEffect(()=>{const O=je.current;if(!O||O.key!==Te)return;const we=oe.find(ie=>!ie.disabled);if(!we)return;const be=Ce!==O.sig;!be&&O.done||(be?je.current=null:O.done=!0,we.key!==r&&J(we.key))},[Te,Ce,oe,r,J]);const N=oe.find(O=>O.key===r),ne=()=>{var O;w==null||w({chapterKey:r,chapterLabel:typeof(N==null?void 0:N.label)=="string"?N.label:void 0,anchor:kp(de.current,((O=Z.current)==null?void 0:O.getBoundingClientRect().bottom)??0),selectedText:wp(de.current)})},ce=oe.findIndex(O=>O.key===r),le=ce>0?oe.slice(0,ce).reverse().find(O=>!O.disabled):void 0,re=ce>=0?oe.slice(ce+1).find(O=>!O.disabled):void 0,W=g.fontSize??bi,xe={...ue,...g.fontSize?{"--bimrd-fs":`${g.fontSize}px`}:null};return e.jsxs("div",{className:["bim-rd",g.writingMode==="vertical"&&v?"bim-rd-vertical":"",ee].filter(Boolean).join(" "),"data-toc":se,"data-img":ge?"open":"closed","data-bb":We?"":void 0,style:xe,children:[e.jsx("style",{children:Gs}),e.jsx("a",{className:"bim-rd-skip",href:`#${ye}`,onClick:O=>{var we,be,ie;O.preventDefault(),(we=de.current)==null||we.focus(),(ie=(be=de.current)==null?void 0:be.scrollIntoView)==null||ie.call(be,{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:Q}),children:[e.jsx("span",{"aria-hidden":"true",children:"‹"}),e.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:Q})]}),(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:[C&&C.length>1&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"bim-rd-ver",title:D?R(yi(D)):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:Te??"",onChange:O=>He(O.target.value),children:C.map(O=>e.jsx("option",{value:O.key,children:R(yi(O))},O.key))})]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),E&&(le||re)&&e.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":B("reader.pagerGroup",{unit:P}),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.prevUnit",{unit:P}),title:le?typeof le.label=="string"&&le.label?B("reader.prevUnitTitle",{unit:P,label:le.label}):B("reader.prevUnit",{unit:P}):B("reader.firstUnit",{unit:P}),disabled:!le,onClick:()=>le&&J(le.key),children:e.jsx(yp,{})}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.nextUnit",{unit:P}),title:re?typeof re.label=="string"&&re.label?B("reader.nextUnitTitle",{unit:P,label:re.label}):B("reader.nextUnit",{unit:P}):B("reader.lastUnit",{unit:P}),disabled:!re,onClick:()=>re&&J(re.key),children:e.jsx(jp,{})})]}),E&&(le||re)&&e.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),e.jsxs("button",{ref:Me,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":F,"aria-controls":pe,onClick:te,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":ge,onClick:()=>X(ge?"closed":"open"),children:[e.jsx(rr,{}),B("reader.images")]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx(vp,{}),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:W<=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:W>=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:pe,ref:he,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(),I(!0);return}O.key==="Tab"&&sr(O,he.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:()=>I(!0),children:"✕"})]}),l]}),e.jsx(Ks,{items:o,activeKey:r,onSelect:J})]}),e.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>I(!0)}),e.jsx("aside",{className:"bim-rd-img","aria-label":B("reader.images"),children:ge&&e.jsx(fi,{pages:d??null,loading:c,renderOverlay:p})}),e.jsxs("div",{className:"bim-rd-text",id:ye,ref:de,tabIndex:-1,"data-rail":j||w?"true":void 0,children:[e.jsxs("div",{className:"bim-rd-col",children:[Y,A&&D&&(D.sourceName||D.license)&&e.jsxs("p",{className:"bim-rd-src","data-version":D.key,children:[D.sourceName&&e.jsxs(e.Fragment,{children:[B("reader.sourceLabel")," ",D.sourceUrl?e.jsx("a",{className:"bim-rd-link",href:D.sourceUrl,target:"_blank",rel:"noreferrer",children:R(D.sourceName)}):R(D.sourceName)]}),D.sourceName&&D.license&&e.jsx("span",{className:"bim-rd-dot"}),D.license&&e.jsx(e.Fragment,{children:B("reader.licenseOf",{license:D.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:ne,children:B("reader.reportError")})}),E&&(le||re)&&e.jsxs("nav",{className:"bim-rd-pager","aria-label":B("reader.pagerNav"),children:[le?e.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>J(le.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[e.jsx("span",{"aria-hidden":"true",children:"← "}),B("reader.prevUnit",{unit:P})]}),e.jsx("span",{className:"bim-rd-pglabel",children:le.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",B("reader.firstUnit",{unit:P})]}),re?e.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>J(re.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[B("reader.nextUnit",{unit:P}),e.jsx("span",{"aria-hidden":"true",children:" →"})]}),e.jsx("span",{className:"bim-rd-pglabel",children:re.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[B("reader.lastUnit",{unit:P})," →"]})]})]}),(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:ne,children:B("reader.reportError")})})]})]})]}),We&&e.jsxs("nav",{className:"bim-rd-bb","aria-label":B("reader.bottomBar"),children:[e.jsxs("button",{type:"button","aria-expanded":F,"aria-controls":pe,onClick:()=>{Re(null),te()},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=>U("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=>U("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),ne()},children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),e.jsx("span",{children:B("reader.reportError")})]})]}),We&&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:W<=ut[0],onClick:()=>m({fontSize:xn(g.fontSize,-1)}),children:"A−"}),e.jsxs("output",{"aria-live":"polite",children:[W,"px"]}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":B("reader.fontLarger"),disabled:W>=ut[ut.length-1],onClick:()=>m({fontSize:xn(g.fontSize,1)}),children:"A+"})]})]})]})]})}const el=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Sp={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Ge(t){return Sp[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},tl={"唐|元和":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 $p(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 _p=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,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=tl[`${n}|${t}`];if(o!=null)return o}return Bt[t]}const Cp=1911;function zp(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 Tp={零: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=Tp[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 el)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&&tl[`${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:$p(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 Cp+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*[))]/),z=$?Sn($[1]):void 0;return j+(z?z-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=zp(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},Np=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Ip=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,cr=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function dr(t,n){for(const o of el){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 Ep(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"&&_p.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&&Ip.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(v.laterRepair={era:$[1]})}const y=Np.find($=>$.re.test(s));if(y){const $=s.search(y.re),z=s.slice($),_=dr(z,n.era)??dr(s,n.era);_&&(v.basedOn={era:_.era,reign:_.reign,year:_.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 Rp(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 nl(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 il(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:Lp(t.id,n),group:(a=n==null?void 0:n.node_groups)==null?void 0:a[t.id],hasImage:r.length>0}}function Lp(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 ol(t,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=t.filter(c=>!r.has(c.id)).map(c=>il(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 Pp(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 rl=["撰","編","注","校","譯","繪","其他"],Ap=[{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 Ap)if(r.test(n))return o;return"其他"}function Qi(t){if(!t)return"";const n=t.trim();return!n||!/[一-鿿]/.test(n)?"":n}function sl(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 rl){const l=o.get(s);l&&r.push({cls:s,label:s,count:l})}return r.length>2?r:[]}function ll(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 Bp=["〇","一","二","三","四","五","六","七","八","九"],ur=["","十","百","千"];function al(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+=Bp[a]+ur[d])}return r}function Mp(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?al(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function cl(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 Wp=216,mr="clamp(280px, 23vw, 360px)",Hp=1440,ki="(max-width: 719px)",Op=`${ki}, (pointer: coarse)`,Fp=`
505
- .bim-d-main.bim-d-main-grid { max-width: ${Hp}px; padding: 16px 32px 0; }
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}`,je=`bim-rd-text-${U}`,Z=x.useRef(null),ce=x.useRef(null),fe=x.useRef(null),We=x.useRef(null),be=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(ye=>ye===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"?be:le==="open",me=!be,Ae=!!d&&d.length>0,[R,Q]=x.useState(u);x.useEffect(()=>{Q(u)},[u]);const he=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=fe.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,ye=Z.current;if(we&&ye&&typeof window<"u"){const oe=we.getBoundingClientRect().top-ye.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]),xe=x.useRef(null),Me=O=>{O!==X&&(Y||(xe.current={key:O,sig:Ie,done:!1}),H===void 0&&Le(O),W==null||W(O))};x.useEffect(()=>{const O=xe.current;if(!O||O.key!==X)return;const we=re.find(oe=>!oe.disabled);if(!we)return;const ye=Ie!==O.sig;!ye&&O.done||(ye?xe.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":he?"open":"closed","data-bb":He?"":void 0,style:ge,children:[e.jsx("style",{children:Ks}),e.jsx("a",{className:"bim-rd-skip",href:`#${je}`,onClick:O=>{var we,ye,oe;O.preventDefault(),(we=ce.current)==null||we.focus(),(oe=(ye=ce.current)==null?void 0:ye.scrollIntoView)==null||oe.call(ye,{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":he,onClick:()=>Q(he?"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:fe,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,fe.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:he&&e.jsx(fi,{pages:d??null,loading:c,renderOverlay:p})}),e.jsxs("div",{className:"bim-rd-text",id:je,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: ${Fp}px; padding: 16px 32px 0; }
506
521
  .bim-d-grid {
507
522
  display: grid;
508
- grid-template-columns: ${Wp}px minmax(0, 1fr) ${mr};
523
+ grid-template-columns: ${Op}px minmax(0, 1fr) ${mr};
509
524
  grid-template-rows: auto 1fr;
510
525
  grid-template-areas: "rail main card" "rail main side";
511
526
  column-gap: 32px; row-gap: 28px; align-items: start;
@@ -782,12 +797,19 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
782
797
  .bim-d-rg { padding: 14px 16px 10px; border-radius: 10px; background: ${i("card-bg")}; box-shadow: inset 0 0 0 1px ${i("rule")}; }
783
798
  .bim-d-rg .bim-d-zt tbody tr:nth-child(odd) td { background: none; }
784
799
 
785
- /* 旁栏:时间轴点(同作品版本) */
786
- .bim-d-side-tl ul { position: relative; padding-left: 16px; }
787
- .bim-d-side-tl ul::before { content: ""; position: absolute; left: 3px; top: 12px; bottom: 12px; width: 1px; background: ${i("rule")}; }
800
+ /* 旁栏:时间轴点(同作品版本)。
801
+ 选择器写成 .bim-d-side.bim-d-side-tl:后面的通用规则 .bim-d-side ul { padding: 0 } 与单类选择器同权、又在后,
802
+ 曾把这里的 padding-left 盖掉,竖线落在字下、圆点在左边 16px 外,两者错开(用户 10-01 反馈,overview#337 B7)。
803
+ 竖线按行画:每行画满本行高度,首行从圆点中心起、末行到圆点中心止,行高不一(手机 44px 点击区、长书名折行)也连得上;
804
+ 圆点、竖线都按行高垂直居中,水平中心同在 left -12.5px。 */
805
+ .bim-d-side.bim-d-side-tl ul { padding-left: 16px; }
788
806
  .bim-d-side-tl li { position: relative; }
789
- .bim-d-side-tl li::before { content: ""; position: absolute; left: -16px; top: 14px; width: 7px; height: 7px; border-radius: 50%;
807
+ .bim-d-side-tl li::before { content: ""; position: absolute; z-index: 1; left: -16px; top: 50%; margin-top: -3.5px; width: 7px; height: 7px; border-radius: 50%;
790
808
  box-sizing: border-box; background: ${i("page-bg")}; border: 1px solid ${i("aux-fg")}; }
809
+ .bim-d-side-tl li::after { content: ""; position: absolute; left: -13px; top: 0; bottom: 0; width: 1px; background: ${i("rule")}; }
810
+ .bim-d-side-tl li:first-child::after { top: 50%; }
811
+ .bim-d-side-tl li:last-child::after { bottom: 50%; }
812
+ .bim-d-side-tl li:only-child::after { display: none; }
791
813
  .bim-d-side-tl li.bim-d-side-cur::before { background: ${i("accent")}; border-color: ${i("accent")}; }
792
814
 
793
815
  /* 本页内检索(丛编子目) */
@@ -832,7 +854,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
832
854
  .bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
833
855
 
834
856
  /* 点击目标 ≥44px(Q5):触屏与窄屏 */
835
- @media ${Op} {
857
+ @media ${Dp} {
836
858
  .bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
837
859
  .bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
838
860
  .bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
@@ -974,7 +996,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
974
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 {
975
997
  text-decoration-color: currentColor; text-decoration-thickness: 2px;
976
998
  }
977
- `;function an({railTop:t,back:n,up:o,nav:r,railLinks:s,main:l,card:a,side:d}){const{t:c,convert:p}=q(),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:p(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:p(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:d})]})}function dl({caption:t,children:n}){const{convert:o}=q();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 Ke({id:t,title:n,meta:o,action:r,children:s}){const{convert:l}=q();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 Ye({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 On({items:t,value:n,onChange:o}){const{convert:r}=q();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 pl({label:t,checked:n,onChange:o}){const{convert:r}=q();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 ul=6,Fn=t=>t>ul+1;function eo({total:t,shown:n,unit:o,onClick:r}){const{t:s,convert:l}=q(),a=t-n,d=Fn(t)?t-Math.min(n,ul):a;return d<=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:d,unit:l(o)})})]})}function to({label:t,onClick:n}){const{convert:o}=q();return e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(t)})}function cn({kind:t,title:n,subtitle:o,byline:r,meta:s,description:l,clampDescription:a,facts:d,stats:c,readAction:p,secondaryAction:u,children:g,foot:m}){const{t:h,convert:f}=q(),v=(d||[]).filter(w=>w.value!=null&&w.value!==""),y=(c||[]).filter(w=>w.value!=null&&w.value!==""&&w.value!==0),[k,b]=x.useState(!1),j=!!a&&!k;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":k,onClick:()=>b(w=>!w),children:h(k?"action.collapse":"action.expand")}),y.length>0&&e.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((w,S)=>e.jsxs("div",{children:[e.jsx("b",{children:w.value}),e.jsx("span",{children:f(w.label)})]},S))}),v.length>0&&e.jsx("dl",{className:"bim-d-ui",children:v.map((w,S)=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{children:f(w.label)}),e.jsx("dd",{title:w.title,children:w.value})]},S))}),g,p,u,m&&e.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:m})]})}function no(t){return!!t&&[...t.replace(/\s+/g,"")].length>110}function wi({href:t,onClick:n,label:o}){const{t:r,convert:s}=q(),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 _t({id:t,title:n,meta:o,items:r,metas:s,currentIndex:l,cap:a=8,moreLabel:d,foot:c,sub:p,timeline:u}){const{t:g,convert:m}=q(),[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})]}),p&&e.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),e.jsx("ul",{children:v.map((k,b)=>e.jsxs("li",{className:b===l?"bim-d-side-cur":void 0,"aria-current":b===l?"page":void 0,children:[k,s!=null&&s[b]?e.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&e.jsx(to,{label:d?d(y):g("detail.showMore",{n:y}),onClick:()=>f(!0)}),c&&e.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const Dp=new Set(["reviewed","disputed","unreviewed","draft"]);function dn({revision:t,revisedAt:n,review:o,todo:r}){const{t:s,convert:l}=q(),a=o&&Dp.has(o.status)?s(`detail.review.${o.status}`):void 0,d=o&&o.status!=="unreviewed"&&a?[a,o.by,o.date].filter(Boolean).join(" "):"",c=[t!=null&&t!==""?`${s("detail.dataVersion")} ${t}`:"",n??"",l(d)].filter(Boolean),p=(r||[]).filter(u=>u&&u.what);return!c.length&&!p.length?null:e.jsxs(e.Fragment,{children:[c.length>0&&e.jsx(Ye,{items:c,style:{fontSize:12}}),p.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:s("detail.todoCount",{n:p.length})}),e.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:p.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 jn=1e3,gr=208,Up=1440,Vp="(max-width: 719px)",ml=`
999
+ `;function an({railTop:t,back:n,up:o,nav:r,railLinks:s,main:l,card:a,side:d}){const{t:c,convert:p}=K(),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:p(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:p(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:d})]})}function ul({caption:t,children:n}){const{convert:o}=K();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 Ke({id:t,title:n,meta:o,action:r,children:s}){const{convert:l}=K();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 Ye({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 On({items:t,value:n,onChange:o}){const{convert:r}=K();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 ml({label:t,checked:n,onChange:o}){const{convert:r}=K();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 gl=6,Fn=t=>t>gl+1;function eo({total:t,shown:n,unit:o,onClick:r}){const{t:s,convert:l}=K(),a=t-n,d=Fn(t)?t-Math.min(n,gl):a;return d<=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:d,unit:l(o)})})]})}function to({label:t,onClick:n}){const{convert:o}=K();return e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(t)})}function cn({kind:t,title:n,subtitle:o,byline:r,meta:s,description:l,clampDescription:a,facts:d,stats:c,readAction:p,secondaryAction:u,children:g,foot:m}){const{t:h,convert:f}=K(),v=(d||[]).filter(w=>w.value!=null&&w.value!==""),y=(c||[]).filter(w=>w.value!=null&&w.value!==""&&w.value!==0),[k,b]=x.useState(!1),j=!!a&&!k;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":k,onClick:()=>b(w=>!w),children:h(k?"action.collapse":"action.expand")}),y.length>0&&e.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((w,S)=>e.jsxs("div",{children:[e.jsx("b",{children:w.value}),e.jsx("span",{children:f(w.label)})]},S))}),v.length>0&&e.jsx("dl",{className:"bim-d-ui",children:v.map((w,S)=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{children:f(w.label)}),e.jsx("dd",{title:w.title,children:w.value})]},S))}),g,p,u,m&&e.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:m})]})}function no(t){return!!t&&[...t.replace(/\s+/g,"")].length>110}function wi({href:t,onClick:n,label:o}){const{t:r,convert:s}=K(),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 _t({id:t,title:n,meta:o,items:r,metas:s,currentIndex:l,cap:a=8,moreLabel:d,foot:c,sub:p,timeline:u}){const{t:g,convert:m}=K(),[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})]}),p&&e.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),e.jsx("ul",{children:v.map((k,b)=>e.jsxs("li",{className:b===l?"bim-d-side-cur":void 0,"aria-current":b===l?"page":void 0,children:[k,s!=null&&s[b]?e.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&e.jsx(to,{label:d?d(y):g("detail.showMore",{n:y}),onClick:()=>f(!0)}),c&&e.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const Vp=new Set(["reviewed","disputed","unreviewed","draft"]);function dn({revision:t,revisedAt:n,review:o,todo:r}){const{t:s,convert:l}=K(),a=o&&Vp.has(o.status)?s(`detail.review.${o.status}`):void 0,d=o&&o.status!=="unreviewed"&&a?[a,o.by,o.date].filter(Boolean).join(" "):"",c=[t!=null&&t!==""?`${s("detail.dataVersion")} ${t}`:"",n??"",l(d)].filter(Boolean),p=(r||[]).filter(u=>u&&u.what);return!c.length&&!p.length?null:e.jsxs(e.Fragment,{children:[c.length>0&&e.jsx(Ye,{items:c,style:{fontSize:12}}),p.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:s("detail.todoCount",{n:p.length})}),e.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:p.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 jn=1e3,gr=208,Gp=1440,Yp="(max-width: 719px)",hl=`
978
1000
  .bim-d-page {
979
1001
  background: ${i("page-bg")};
980
1002
  color: ${i("ink")};
@@ -994,7 +1016,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
994
1016
  * PAGE_MAX_WIDTH,读者的行宽体验不变。
995
1017
  */
996
1018
  .bim-d-main.bim-d-main-wide {
997
- max-width: ${Up}px;
1019
+ max-width: ${Gp}px;
998
1020
  }
999
1021
  .bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
1000
1022
 
@@ -1051,7 +1073,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
1051
1073
  align-items: start; margin-bottom: 48px; }
1052
1074
  .bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
1053
1075
 
1054
- @media ${Vp} {
1076
+ @media ${Yp} {
1055
1077
  .bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
1056
1078
  .bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
1057
1079
  /* 表格:meta 列折到第二行,表头隐藏 */
@@ -1069,18 +1091,18 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
1069
1091
  padding-right: 0; padding-bottom: 12px;
1070
1092
  }
1071
1093
  }
1072
- ${Fp}`;function en({children:t,style:n,wide:o,grid:r}){return e.jsxs("div",{className:"bim-d-page",style:n,children:[e.jsx("style",{children:ml}),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 Si({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 io({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 $i({items:t}){const n=Ve();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,d=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,d]},r)})})}function gl({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 Gp({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 Yp({items:t,horizontal:n}){const{convert:o}=Ne();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 Kp({glyph:t,tone:n,title:o,count:r,actions:s,id:l}){const{convert:a}=Ne();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(io,{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 hl({label:t,active:n,onClick:o,dashed:r}){const{convert:s}=Ne();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 qp({label:t,onClick:n}){const{convert:o}=Ne();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 Zp({label:t,onClick:n,inline:o}){const{convert:r}=Ne();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 xl({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 Jp({children:t}){return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:t})}function Xp({volumes:t,unit:n,max:o=60}){const{t:r}=q(),s=n??r("unit.volume"),[l,a]=x.useState(!1);if(!t.length)return null;const d=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:[d.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 Qp({children:t}){return e.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:t})}function eu({spec:t}){const{convert:n}=Ne();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 tu({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 nu(t){return String(t+1).padStart(2,"0")}function iu(){return e.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function ou({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 fl(t){const n=[];for(let o=0;o<t.length;o++){const r=t[o];let s;if(r==="⟨")s="⟩";else if(r==="<"){const d=t[o+1];if(d===void 0||/[A-Za-z/!?>\s]/.test(d))continue;s=">"}else continue;const l=t.indexOf(s,o+1);if(l<0)continue;const a=t.slice(o+1,l);a.includes(`
1073
- `)||(n.push({start:o,end:l+1,inner:a}),o=l)}return n}function bl(t,n){if(t.length<=n)return t;let o=n;for(const r of fl(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 yl={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},ru={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 jl(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?yl:void 0,children:jl(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:ru,children:s.label},l)}})}function nt(t,n=r=>r,o){if(!t)return"";if(o!=null&&o.gujiMarkdown)return sp(t)?jl(As(t),n,0,o.t??Ht("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 fl(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:yl,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 su({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 lu({title:t,tag:n,children:o}){const{convert:r}=Ne();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 vl({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 au({item:t,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{t:s,convert:l}=q(),[a,d]=x.useState(!1),c=In(t),p=o&&!!c&&c.expected>0,u=(t.url?Ot(t.url):void 0)||l(t.name),g=n?nl(t,n):"",m=g?`${u}(${g})`:u;return e.jsx(vl,{name:m,note:Wn(t,s)||r,href:Ft(t),extra:p?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>d(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(oo,{item:t})]}):void 0})}function oo({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 kl({label:t,items:n}){const{convert:o}=Ne();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(xl,{children:o(r)},s))]}):null}function cu({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(kl,{label:o.label,items:o.items},o.label))}):null}function _i(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function wl({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 du({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 Ue({id:t,label:n,onNavigate:o,renderLink:r,style:s,dense:l}){const a=Ve();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?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),o(t))}:void 0,style:s,children:n??t})}function pu({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 uu={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},mu={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},gu=`1px solid ${i("table-border")}`,Sl={border:gu,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},hu={...Sl,background:i("table-head-bg"),fontWeight:600};function ro({table:t,opts:n}){return e.jsx("div",{className:"bim-guji-table-wrap",style:uu,children:e.jsx("table",{className:"bim-guji-table",style:mu,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?hu:Sl,children:s.empty?null:nt(s.text,void 0,n)},l)})},r))})})})}function xu(t,n){return t.indexOf("**")<0?nt(t,void 0,n):t.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?e.jsx("strong",{children:nt(r.trim().slice(2,-2),void 0,n)},s):e.jsx(x.Fragment,{children:nt(r,void 0,n)},s))}function fu(t,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?Gi(t).map((s,l)=>s.type==="table"?e.jsx(ro,{table:s.table,opts:r},l):e.jsx(x.Fragment,{children:xu(s.text,r)},l)):nt(t,void 0,r)}const bu=/^(#{1,6})\s+(.*)$/,yu=/^\*\*([^*\n]+)\*\*\s*$/;function so(t){const n=t.match(bu);if(n)return{level:n[1].length,text:n[2].trim()};const o=t.trim().match(yu);return o?{level:3,text:o[1].trim()}:null}const lo=/^<!--.*-->$/;function $l(t){return t.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function _l(t){return t.split(`
1074
- `).map(n=>n.trim()).filter(n=>n&&!lo.test(n))}const ju=60;function Cl(t){let n=0,o=0;for(const r of t.split(`
1075
- `)){const s=r.trim();if(!s||lo.test(s)||so(s))continue;const l=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=l,l>ju&&(o+=l)}return n>0&&o*2>=n}function vu(t){return t.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Dn(t){if(t=vu(t),Cl(t))return"unknown";const n=$l(t);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const o=n.map(s=>_l(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 ku(t){const n=t.split(`
1094
+ ${Up}`;function en({children:t,style:n,wide:o,grid:r}){return e.jsxs("div",{className:"bim-d-page",style:n,children:[e.jsx("style",{children:hl}),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 Si({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 io({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 $i({items:t}){const n=Ve();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,d=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,d]},r)})})}function xl({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 Kp({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 qp({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 Zp({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(io,{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 fl({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 Jp({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 Xp({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 bl({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 Qp({children:t}){return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:t})}function eu({volumes:t,unit:n,max:o=60}){const{t:r}=K(),s=n??r("unit.volume"),[l,a]=x.useState(!1);if(!t.length)return null;const d=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:[d.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 tu({children:t}){return e.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:t})}function nu({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 iu({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 ou(t){return String(t+1).padStart(2,"0")}function ru(){return e.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function su({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 yl(t){const n=[];for(let o=0;o<t.length;o++){const r=t[o];let s;if(r==="⟨")s="⟩";else if(r==="<"){const d=t[o+1];if(d===void 0||/[A-Za-z/!?>\s]/.test(d))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 jl(t,n){if(t.length<=n)return t;let o=n;for(const r of yl(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 vl={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},lu={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 kl(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?vl:void 0,children:kl(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:lu,children:s.label},l)}})}function nt(t,n=r=>r,o){if(!t)return"";if(o!=null&&o.gujiMarkdown)return ap(t)?kl(Ms(t),n,0,o.t??Ht("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 yl(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:vl,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 au({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 cu({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 wl({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 du({item:t,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{t:s,convert:l}=K(),[a,d]=x.useState(!1),c=In(t),p=o&&!!c&&c.expected>0,u=(t.url?Ot(t.url):void 0)||l(t.name),g=n?ol(t,n):"",m=g?`${u}(${g})`:u;return e.jsx(wl,{name:m,note:Wn(t,s)||r,href:Ft(t),extra:p?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>d(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(oo,{item:t})]}):void 0})}function oo({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 Sl({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(bl,{children:o(r)},s))]}):null}function pu({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(Sl,{label:o.label,items:o.items},o.label))}):null}function _i(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function $l({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 uu({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 Ue({id:t,label:n,onNavigate:o,renderLink:r,style:s,dense:l}){const a=Ve();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?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),o(t))}:void 0,style:s,children:n??t})}function mu({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 gu={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},hu={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},xu=`1px solid ${i("table-border")}`,_l={border:xu,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},fu={..._l,background:i("table-head-bg"),fontWeight:600};function ro({table:t,opts:n}){return e.jsx("div",{className:"bim-guji-table-wrap",style:gu,children:e.jsx("table",{className:"bim-guji-table",style:hu,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?fu:_l,children:s.empty?null:nt(s.text,void 0,n)},l)})},r))})})})}function bu(t,n){return t.indexOf("**")<0?nt(t,void 0,n):t.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?e.jsx("strong",{children:nt(r.trim().slice(2,-2),void 0,n)},s):e.jsx(x.Fragment,{children:nt(r,void 0,n)},s))}function yu(t,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?Gi(t).map((s,l)=>s.type==="table"?e.jsx(ro,{table:s.table,opts:r},l):e.jsx(x.Fragment,{children:bu(s.text,r)},l)):nt(t,void 0,r)}const ju=/^(#{1,6})\s+(.*)$/,vu=/^\*\*([^*\n]+)\*\*\s*$/;function so(t){const n=t.match(ju);if(n)return{level:n[1].length,text:n[2].trim()};const o=t.trim().match(vu);return o?{level:3,text:o[1].trim()}:null}const lo=/^<!--.*-->$/;function Cl(t){return t.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function zl(t){return t.split(`
1096
+ `).map(n=>n.trim()).filter(n=>n&&!lo.test(n))}const ku=60;function Tl(t){let n=0,o=0;for(const r of t.split(`
1097
+ `)){const s=r.trim();if(!s||lo.test(s)||so(s))continue;const l=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=l,l>ku&&(o+=l)}return n>0&&o*2>=n}function wu(t){return t.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Dn(t){if(t=wu(t),Tl(t))return"unknown";const n=Cl(t);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const o=n.map(s=>zl(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 Su(t){const n=t.split(`
1076
1098
  `),o=[];let r=null,s=[];const l=()=>{o.push({heading:r,body:s.join(`
1077
1099
  `)}),s=[]};for(const a of n){const d=so(a);if(d){l(),r={kind:"heading",level:d.level,text:d.text};continue}s.push(a)}return l(),o}function hr(t){const n=[];for(const o of t.split(`
1078
- `)){const r=so(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||lo.test(s)||n.push({kind:"body",text:o})}return n}function zl(t){if(!t)return[];const n=Dn(t);if(n==="unknown")return hr(t);const o=[];for(const{heading:r,body:s}of ku(t)){r&&o.push(r);const l=$l(s);if(l.length!==0){if(Cl(s)){o.push(...hr(s));continue}if(n==="record"){const a=l.join(" ");a&&o.push({kind:"body",text:a})}else for(const a of l){const d=_l(a);d.length&&o.push({kind:"body",text:d.join(" ")})}}}return o}const Tl=t=>t;function Nl(t,n=Tl){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 ao(t,n={}){const o=n.renderText??Tl,r=n.properNames?l=>Nl(l,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return nt(t,r,s)}function xr(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 oi=/^(#{1,6})\s+(.*)$/,wu=/^\s*<!--.*-->\s*$/;function Il(t){return t.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
1079
- `)?"":n)}function Su(t){return t<=1?2:t===2?3:4}function $u(){let t=1;return n=>{const o=Su(n),r=Math.min(o,t+1);return t=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function _n(t){return t?Dn(Il(t))!=="unknown":!1}function fr({text:t,mode:n,inline:o,dropTitle:r}){const s=Il(t),l=(p,u,g)=>!!r&&g<=1&&p<=2&&u.trim()===r.trim(),a=$u();if(n==="paragraph"&&Dn(s)!=="unknown"){const p=zl(s);return e.jsx(e.Fragment,{children:p.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",{children:xr(u.text,o,g)},g)})})}const d=s.split(`
1080
- `);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(wu.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",{children:xr(p,o,u)},u)})})}function _u(t){const{convert:n}=Ne();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=_u(t),{t:c,convert:p}=q(),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(fr,{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(fr,{text:h.text,mode:n,inline:u,dropTitle:f===0?m:void 0},f))})}function Cu(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 br={A:"fine",B:"rough",C:"rough",D:"ocr"};function zu(t){return typeof t!="string"?null:t in xc?t:t in br?br[t]:null}const Tu={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},Nu={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"};function rt(t){return typeof t!="string"?"":Tu[t]??Nu[t]??t}const Iu=["〇","一","二","三","四","五","六","七","八","九"],yr=["","十","百","千"],Eu=["","萬","億"];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(Ru(s,r>0)+Eu[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Ru(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+=yr[d]:s+=Iu[a]+yr[d]}return s.replace(/〇$/,"")}let on=null,fn=null;const Cn=new Set;function Lu(){return on?Promise.resolve():fn||(fn=import("opencc-js/t2cn").then(t=>{on=t.Converter({from:"tw",to:"cn"}),Cn.forEach(n=>n())}).catch(()=>{on=t=>t,Cn.forEach(t=>t())}),fn)}const Pu=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),Lu(),()=>{Cn.delete(n)}},[]),on??Pu}function Mt(t,n){return n(t).toLowerCase()}const Au=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:Au,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 Bu(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")},Mu={考证:i("section-kaozhen")};function go(t,n,o){return t.collated.sectionType[n]??o(n)}function El(t){var r;const n=t.files.length,o=((r=t.children)==null?void 0:r.reduce((s,l)=>s+El(l),0))||0;return n+o}function Wu(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 Hu={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:{...Hu,...r},children:s}):e.jsx("span",{style:r,children:s})}function Ou({type:t}){const{convert:n,messages:o}=q(),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 Fu({section:t,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:l}){const{t:a,convert:d}=q(),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?bl(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 Du({section:t,highlightQuery:n=""}){const{t:o,convert:r}=q(),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(Ou,{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 Uu=100;function xo(t){return rt(t.type)!=="page_header"?!1:(t.content||"").length>=Uu}function Vu({section:t,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=q(),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,`
1081
- `)),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 Gu(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 Yu({section:t,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:l,convert:a,messages:d}=q(),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=Mu[h]||i("desc-fg"),v=!!t.content,y=t.work_ids||[],k=y.length>1,b=Gu(k?y:[],o,r),j=v&&!g&&t.content.length>80?bl(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:z=>{z.metaKey||z.ctrlKey||(z.preventDefault(),z.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 Ku({juan:t,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:l}=q(),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(Yu,{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 qu(){let t=!1;return n=>n==="类"?(t=!0,"h2"):t?"h3":"h2"}function Zu({sections:t,onNavigate:n,inline:o,workLinks:r=!0}){const s=Ve(),{t:l,convert:a}=q(),d=qu();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 Rl(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 Ju({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 Q;const{t:m,convert:h,messages:f}=q(),v=It(),[y,k]=x.useState("text"),b=u??y,j=P=>{k(P),g==null||g(P)},w=l.trim(),S=(s==null?void 0:s.type)==="kaozhen",$=x.useCallback(P=>w?pn(P,w,v):P,[w,v]),z=P=>ao(P,{renderText:$,properNames:p.properNames,t:m}),_=x.useMemo(()=>w?t.sections.filter(P=>uo(P,w,S,v)):t.sections,[t.sections,w,S,v]),E=(P,V)=>V.filter(pe=>rt(pe.type)===P).length,T=E("书",t.sections),C=E("诗",t.sections),H=E("考证",t.sections);let M="";S?M=w?m("collated.countTiaoOf",{m:E("考证",_),n:H}):m("collated.countTiao",{n:H}):C>0?M=w?m("collated.countPoemsOf",{m:E("诗",_),n:C}):m("collated.countPoems",{n:C}):T>0&&(M=w?m("collated.countBooksOf",{m:E("书",_),n:T}):m("collated.countBooks",{n:T}));const A=s!=null&&s.text_quality?zu(s.text_quality.grade):null,K=[];M&&K.push(M),S&&(s!=null&&s.target_source)&&K.push(e.jsx(e.Fragment,{children:m("collated.kaozhenTarget",{target:h(s.target_source)})})),A&&K.push(e.jsx("span",{title:f.collated.qualityCriteria[A],children:(Q=s==null?void 0:s.text_quality)!=null&&Q.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&&K.push(e.jsx("a",{className:"bim-rd-link",href:t.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const Y=!S&&Rl(t.sections),ee=!!n&&(!Y||p.readingMode==="paragraph"&&_n(n)),ue=!S&&(Y||!!n),B=S||!ue?"entries":b;let R=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)}),K.length>0&&e.jsx("p",{className:"bim-rd-meta",children:K.map((P,V)=>e.jsxs(x.Fragment,{children:[V>0&&e.jsx("span",{className:"bim-rd-dot"}),P]},V))}),ue&&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:ee?e.jsx(co,{text:n,mode:p.readingMode,properNames:p.properNames,renderText:$,dropTitle:t.title}):e.jsx(Zu,{sections:t.sections,onNavigate:a,inline:z,workLinks:p.workLinks})}),B==="entries"&&e.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:S?e.jsx(Ku,{juan:t,searchQuery:l,onNavigate:a,transport:d,workLabelCache:c}):e.jsxs(e.Fragment,{children:[_.some(P=>["书","诗","考证"].includes(rt(P.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")})]}),_.map((P,V)=>{const pe=rt(P.type);return pe==="书"||pe==="诗"||pe==="考证"?(R+=1,e.jsx(Fu,{domId:`rd-e-${t.sections.indexOf(P)}`,section:P,onNavigate:p.workLinks?a:void 0,highlightQuery:w,no:R,showUnlinked:p.workLinks&&!!a},V)):pe==="类"?e.jsx(Du,{section:P,highlightQuery:w},V):e.jsx(Vu,{section:P,highlightQuery:w},V)}),_.length===0&&e.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function Xu(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&&Bu(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 E of r){const T=u.current.get(E);T?j[E]=y(T,k):(j[E]="loading",w.push(E))}m(j);const S=8;let $=0;const z=async()=>{for(;$<w.length;){if(b)return;const E=$++,T=w[E];try{const C=await o(T),H=C.juan;if(u.current.set(T,C),v(T,H),b)return;m(M=>({...M,[T]:y(C,k)}))}catch{if(b)return;m(C=>({...C,[T]:0}))}}},_=Array.from({length:Math.min(S,w.length)},()=>z());return Promise.all(_),()=>{b=!0}},[d,n,o,r.join(","),y,p,v]),{matchStates:g,titles:h}}function Qu({juan:t,view:n,onView:o,textHasEntries:r}){const{t:s,convert:l}=q(),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},jr=/^https?:\/\//i;function em(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&&jr.test(o)?o:void 0,license:n(t.license),license_url:r&&jr.test(r)?r:void 0,note:n(t.note)};return s.name||s.license||s.note?s:null}function tm(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 nm(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 Ll(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 im(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?Ll(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=Wu(g,n);return{key:`group:${m}`,label:r(g.label),hint:h==="loading"?"…":typeof h=="number"&&h>0?`${h}`:El(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 De,Ie,Qe;const{t:b,convert:j}=q(),w=x.useMemo(()=>Fs(n),[n]),[S,$]=Zs(),z=Ve(),_=x.useRef(s);_.current=s;const[E,T]=x.useState(null),[C,H]=x.useState("loading");x.useEffect(()=>{let G=!1;return T(null),H("loading"),w.getManifest(t).then(Pe=>{G||(Pe?(T(Pe),H("ready")):H("missing"))}).catch(()=>{G||H("missing")}),()=>{G=!0}},[w,t]);const M=o!==void 0,A=r!==void 0,[K,Y]=x.useState(null),[ee,ue]=x.useState(null);x.useEffect(()=>{Y(null),ue(null)},[t]);const B=ve.pickTextVersion(E,M?o:K),R=((De=E==null?void 0:E.versions.find(G=>G.key==="default"))==null?void 0:De.key)??((Ie=E==null?void 0:E.versions[0])==null?void 0:Ie.key)??"default",Q=(B==null?void 0:B.key)??null,P=A?r:ee,V=x.useCallback((G,Pe,it)=>{var vt;(vt=_.current)==null||vt.call(_,{key:G,chapter:Pe,isDefault:G===R},it)},[R]);x.useEffect(()=>{!E||!M||o==null||E.versions.some(G=>G.key===o)||V(R,null,"auto")},[E,M,o,R,V]);const pe=x.useRef(new Map);x.useEffect(()=>{pe.current.clear()},[w,t]);const ye=x.useCallback(async G=>{const Pe=`${t}
1082
- ${G}`;if(pe.current.has(Pe))return pe.current.get(Pe)??null;const it=await w.getIndex(t,G).catch(()=>null);return it&&pe.current.set(Pe,it),it},[w,t]),[Z,de]=x.useState(null),[he,Me]=x.useState("loading");x.useEffect(()=>{if(!Q)return;let G=!1;return de(null),Me("loading"),ye(Q).then(Pe=>{G||(Pe&&Pe.chapters.length>0?(de(Pe),Me("ready")):Me("failed"))}),()=>{G=!0}},[Q,ye]),x.useEffect(()=>{if(!Z||!Q||P!=null&&Z.chapters.some(it=>it.file===P))return;const Pe=Z.chapters[0].file;A||ue(Pe),V(Q,Pe,"auto")},[Z,Q,P,A,V]);const fe=Z?P!=null&&Z.chapters.some(G=>G.file===P)?P:Z.chapters[0].file:P,$e=x.useMemo(()=>Z&&fe?Z.chapters.find(G=>G.file===fe)??null:null,[Z,fe]),We=x.useRef(0),Be=x.useCallback(async G=>{if(!E||G===Q||!E.versions.some(gn=>gn.key===G))return;const Pe=++We.current,it=await ye(G);if(Pe!==We.current)return;const vt=$e??(fe?{file:fe}:null),Ut=ve.matchChapterAcrossVersions(vt,it);M||Y(G),A||ue(Ut),V(G,Ut,"version")},[E,Q,ye,$e,fe,M,A,V]),Re=x.useCallback(G=>{Q&&(A||ue(G),V(Q,G,"chapter"))},[Q,A,V]),[ze,Ee]=x.useState(null),[U,ae]=x.useState(!1),se=x.useRef(0);x.useEffect(()=>{if(!Q||!$e)return;const G=++se.current;ae(!0),Ee(null),w.getChapter(t,Q,$e.file,{json:!!$e.has_json}).then(Pe=>{G===se.current&&Ee(Pe)}).catch(()=>{G===se.current&&Ee(null)}).finally(()=>{G===se.current&&ae(!1)})},[w,t,Q,$e]);const Se=(B==null?void 0:B.kind)==="collated",[F,me]=x.useState("");x.useEffect(()=>{me("")},[t,Q]);const Ae=x.useMemo(()=>Q&&Se?async G=>{const Pe=await w.getChapter(t,Q,G,{json:!0});return{juan:(Pe==null?void 0:Pe.json)??null,rawText:(Pe==null?void 0:Pe.md)??null}}:null,[w,t,Q,Se]),L=(Z==null?void 0:Z.type)==="kaozhen",X=x.useMemo(()=>(Z==null?void 0:Z.chapters.map(G=>G.file))??[],[Z]),{matchStates:ge}=Xu({resetKey:`${t}
1083
- ${Q??""}`,load:Ae,files:X,activeFile:fe??null,activeJuan:(ze==null?void 0:ze.json)??null,activeRawText:(ze==null?void 0:ze.md)??null,query:F,isKaozhen:L}),I=x.useRef(new Map);x.useEffect(()=>{I.current.clear()},[t]);const te=Cu(c,fe??null),{entryTitle:J,authors:oe}=sm(t,n,a===void 0),[_e,Le]=x.useState("text");if(x.useEffect(()=>{Le("text")},[fe,Q]),C==="loading")return e.jsx("div",{className:y,style:{...k,...bn},children:b("reader.loading")});if(C==="missing"||!E||!B)return e.jsx("div",{className:y,style:{...k,...bn},children:b("reader.noText")});if(he==="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 D=nm(B,Z),Te=im(Z,ge,D,j,Se),Ce=E.versions.map(G=>({key:G.key,label:ve.textVersionLabel(G),optionLabel:j(ve.textVersionLabel(G)),sourceName:G.source_name?j(G.source_name):void 0,license:G.license??void 0,sourceUrl:G.source_url??void 0,primary:G.key===R})),je=em((Qe=Z.source)==null?void 0:Qe.upstream),He=(typeof a=="string"?j(a):a)??(Z.title?j(Z.title):J?j(J):void 0),N=He?e.jsx("a",{href:z(t),title:b("reader.viewEntry"),onClick:l?G=>{G.metaKey||G.ctrlKey||(G.preventDefault(),l(t))}:void 0,children:He}):void 0,ne=oe.length>0?j(oe.slice(0,2).map(G=>`${G.dynasty?`〔${G.dynasty}〕`:""}${G.name}${` ${G.role||b("reader.defaultRole")}`}`).join("、")):void 0,ce=$e?Ll($e,D,j,Se):void 0,le=Se&&!!(ze!=null&&ze.json),re=(ze==null?void 0:ze.json)??null,W=(ze==null?void 0:ze.md)??null,xe=le&&!L&&Rl(re.sections),O=xe&&!(W&&S.readingMode==="paragraph"&&_n(W)),we=le&&xe?e.jsx(Qu,{juan:re,view:_e,onView:Le,textHasEntries:O}):void 0,be=Ws(Z)||xi(Z),ie=W?W.replace(/^##\s+[^\n]+\n+/,""):null,Oe=(typeof d=="string"?j(d):d)??(B.source_name?j(B.source_name):j(ve.textVersionLabel(B)));return e.jsxs(Qs,{className:y,style:k,title:N,subtitle:Oe,byline:ne,current:ce,pagerUnit:D,rail:we,revisedAt:h,backHref:f,backLabel:v,onReportError:m?G=>m({...G,bookTitle:typeof He=="string"?He:void 0,entryId:t}):void 0,workLinkToggle:le&&!L&&!!l&&!!(re!=null&&re.sections.some(G=>G.work_id)),toc:Te,tocCaption:b("reader.tocCaption",{n:Z.chapters.length,unit:j(D)}),tocHeader:Se&&Z.chapters.length>1?e.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:L?b("reader.searchChaptersPlaceholder"):b("reader.searchUnitPlaceholder",{unit:j(D)}),"aria-label":L?b("reader.searchChapters"):b("reader.searchUnit",{unit:j(D)}),value:F,onChange:G=>me(G.target.value)}):void 0,activeKey:fe??null,onSelect:Re,images:te.images,imagesLoading:te.loading,renderImageOverlay:p,imagePanel:u,prefs:S,onPrefsChange:$,versions:Ce.length>1?Ce:void 0,currentVersionKey:Ce.length>1?B.key:void 0,onVersionChange:Be,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:_n(W),allowVertical:g,children:[U&&e.jsx(Nt,{}),!U&&le&&re&&e.jsx(Ju,{juan:re,rawText:W,positionLabel:om($e,Z,D,j),groupLabel:rm(Z,fe??null),index:tm(t,Z),searchQuery:F,onNavigate:l,transport:n,workLabelCache:I,prefs:S,view:_e,onViewChange:Le},`${Q}/${fe}`),!U&&!le&&ie!=null&&$e&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("h1",{className:"bim-rd-h1",children:$e.title?j($e.title):ce}),(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]}),je&&e.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[b("reader.upstream")," ",je.url?e.jsx("a",{className:"bim-rd-link",href:je.url,target:"_blank",rel:"noreferrer",children:j(je.name??je.url)}):j(je.name??""),je.license&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),je.license_url?e.jsx("a",{className:"bim-rd-link",href:je.license_url,target:"_blank",rel:"noreferrer",children:je.license}):je.license]}),je.note&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),j(je.note)]})]})]}),e.jsx("article",{className:"bim-rd-prose",children:e.jsx(co,{text:ie,mode:S.readingMode,tables:be,gujiMarkdown:xi(Z),properNames:S.properNames})})]}),!U&&!le&&ie==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((G,Pe)=>e.jsxs("li",{children:[G.url?e.jsx("a",{className:"bim-rd-link",href:G.url,target:"_blank",rel:"noopener noreferrer",children:j(G.title)}):e.jsx("span",{children:j(G.title)}),G.author&&e.jsxs("span",{children:[",",j(G.author)]}),G.note&&e.jsxs("span",{children:["。",j(G.note)]})]},Pe))})]})]})};function om(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 rm(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 sm(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 Pl={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")}},lm=Pl.other,Al={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")}},am=Al.pending;function cm(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 dm(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}=q();return n?e.jsx(Nt,{}):t.length===0?e.jsx("div",{style:pm,children:r("feedback.empty")}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:t.map(l=>{const a=Pl[l.type]||lm,d=Al[l.status]||am,c=typeof window<"u"&&dm(l.pageUrl,window.location.href);return e.jsxs("div",{style:um,children:[e.jsxs("div",{style:mm,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{...vr,background:a.color},children:r(`feedback.listType.${a.key}`)}),e.jsx("span",{style:{...vr,background:d.color},children:r(`feedback.status.${d.key}`)})]}),e.jsx("span",{style:gm,children:cm(l.createdAt)})]}),(l.resourceId||l.pageUrl)&&e.jsxs("div",{style:hm,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:xm,children:s(l.content)}),l.reply&&e.jsxs("div",{style:fm,children:[e.jsx("div",{style:bm,children:r("feedback.reply")}),e.jsx("div",{children:s(l.reply)})]})]},l.id)})})},pm={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},um={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},mm={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},vr={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},gm={fontSize:"12px",color:i("desc-fg")},hm={fontSize:"12px",marginBottom:"6px"},ri={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},xm={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},fm={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},bm={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=K=>{m(K),s==null||s(K)},[j,w]=x.useState(!0),[S,$]=x.useState(null),[z,_]=x.useState(null),[E,T]=x.useState(null);x.useEffect(()=>{let K=!1;if(t.getCounts)return t.getCounts().then(Y=>{K||c({works:Y.works,books:Y.books,collections:Y.collections})}).catch(()=>{}),()=>{K=!0}},[t]),x.useEffect(()=>{let K=!1;return(async()=>{if(o)return o;if(t.getRecommended)try{const ee=await t.getRecommended();if(ee!=null&&ee.groups)return ee.groups.flatMap(ue=>ue.items.map(B=>({...B,group:ue.name})))}catch{}return[]})().then(async ee=>{if(K)return;const ue=ee.filter(R=>R.id);if(ue.length===0){w(!1);return}const B=await Promise.all(ue.map(async R=>{if(R.type)return{id:R.id,title:R.title,type:R.type,author:R.author,dynasty:R.dynasty,role:R.role,edition:R.edition,has_text:R.has_text,has_image:R.has_image,has_collated:R.has_collated,subtype:R.subtype,primary_name:R.primary_name,group:R.group,fallbackDescription:R.description};try{let Q=null;if(t.getEntry)Q=await t.getEntry(R.id);else{const P=await t.getItem(R.id);P&&(Q={id:R.id,title:P.title||R.id,type:P.type||"work"})}if(Q)return{...Q,group:R.group,fallbackDescription:R.description}}catch{}return{id:R.id,title:R.title,type:ve.extractType(R.id),group:R.group,fallbackDescription:R.description}}));K||(u(B.filter(R=>R!==null)),w(!1))}),()=>{K=!0}},[t,o]);const C=x.useRef(!1),H=x.useRef(!1),M=x.useRef(!1);x.useEffect(()=>{if(k!=="catalog"||C.current)return;const K=t.getCatalogProgress??t.getResourceProgress;if(!K)return;C.current=!0;let Y=!1;return K.call(t).then(ee=>{Y||$(ee)}).catch(()=>{C.current=!1}),()=>{Y=!0}},[t,k]),x.useEffect(()=>{if(k!=="collection"||H.current||!t.getCollectionProgress)return;H.current=!0;let K=!1;return t.getCollectionProgress().then(Y=>{K||_(Y)}).catch(()=>{H.current=!1}),()=>{K=!0}},[t,k]),x.useEffect(()=>{if(k!=="site"||M.current||!t.getSiteProgress)return;M.current=!0;let K=!1;return t.getSiteProgress().then(Y=>{K||T(Y)}).catch(()=>{M.current=!1}),()=>{K=!0}},[t,k]),x.useEffect(()=>{if(!l||k!=="feedback")return;let K=!1;return y(!0),fetch(l).then(Y=>Y.json()).then(Y=>{!K&&Y.success&&f(Y.items||[])}).catch(()=>{}).finally(()=>{K||y(!1)}),()=>{K=!0}},[l,k]);const A=K=>e.jsx(Dt,{type:K,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(ym,{recommended:p,loading:j,onNavigate:n,getIcon:A,t:a}),k==="catalog"&&e.jsx(kr,{progress:S,t:a,onNavigate:n}),k==="collection"&&e.jsx(kr,{progress:z,t:a,onNavigate:n}),k==="site"&&e.jsx(vm,{progress:E,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}),ym=({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))})},kr=({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(jm,{item:p,t:n,statusColor:a[d],onNavigate:o},p.id))})]},d)})})},jm=({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})]})},vm=({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(wr,{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(wr,{item:c,t:n,totalWorks:o},c.id))})]})]})},wr=({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})]})},Sr="(max-width: 768px)";function km(){const[t,n]=x.useState(()=>typeof window>"u"?!1:window.matchMedia(Sr).matches);return x.useEffect(()=>{const o=window.matchMedia(Sr),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),t}const wm=({transport:t,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var H;const l=ke(),{convert:a}=Ne(),d=km(),[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 M=>{if(!t.getCollectionCatalogs&&!t.getCollectionCatalog){k([]);return}j(!0);try{if(t.getCollectionCatalogs){const A=await t.getCollectionCatalogs(M);k(A||[])}else if(t.getCollectionCatalog){const A=await t.getCollectionCatalog(M);k(A?[{resource_id:"",data:A}]:[])}}catch{k([])}finally{j(!1)}},[t]),S=x.useCallback(async M=>{if(o){o(M);return}p(M),g(null),k([]),v("detail"),h(!0);try{const A=await t.getItem(M.id);A&&(g(A),A.type==="collection"&&w(M.id))}catch(A){console.error("加载详情失败:",A)}finally{h(!1)}},[t,o,w]),$=x.useCallback(async M=>{g(null),k([]),v("detail"),h(!0);try{const A=await t.getItem(M);A&&(g(A),p({id:M,title:A.title||M,type:A.type||"book"}),A.type==="collection"&&w(M))}catch(A){console.error("导航失败:",A)}finally{h(!1)}},[t,w]),z=typeof(u==null?void 0:u.text_count)=="number"&&u.text_count>0,_=(u==null?void 0:u.type)==="collection"&&(y.length>0||b)||(u==null?void 0:u.type)==="work"&&z,E=d&&(m||u),T=x.useCallback(()=>{p(null),g(null),k([]),v("detail")},[]),C=e.jsx(e.Fragment,{children:m?e.jsx(Nt,{}):u?e.jsxs(e.Fragment,{children:[(_||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:[_&&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(M=>e.jsx("button",{onClick:()=>v(`catalog:${M.resource_id}`),style:yn(f===`catalog:${M.resource_id}`),children:M.short_name?`${a(M.short_name)}${l.detailTab.catalogSuffix}`:l.detailTab.collectionCatalog},M.resource_id)),u.type==="work"&&z&&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(M=>`catalog:${M.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: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(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:C})]})};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 Sm=({data:t,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:l}=q(),[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($m,{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))})]})},$m=({division:t,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:l})=>{const{t:a,convert:d}=q(),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(_m,{category:p,expanded:r===u,onToggle:()=>s(u),onNavigate:l},p.name)})})]})},_m=({category:t,expanded:n,onToggle:o,onNavigate:r})=>{var p,u,g,m;const{t:s,convert:l}=q(),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}=q(),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:zm,children:"AI"}),n&&e.jsx("button",{onClick:n,style:Cm,children:l.action.save})]})]}),s]})},Cm={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},zm={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 Tm(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=Tm(t||"");return x.useEffect(()=>{r&&l.current&&l.current.focus()},[r]),!r&&a?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:_r,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:_r,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"}})]})},_r={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function Nm(t){switch(t){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function Im(t){switch(t){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Bl=({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:Nm(g.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Im(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:{...Cr,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:{...Cr,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:zr,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:zr,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"},Cr={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"},zr={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Ml(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 Wl(t){return!t||t.length===0?"":JSON.stringify(t)}const Hl=({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:Em,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:Ol(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(Tr,{onClick:()=>r(o),title:u,children:"👁️"}),e.jsx(Tr,{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:Ol(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]})})]})},Tr=({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 Ol(t){switch(t){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Em={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Fl=({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:Rm,children:e.jsxs("div",{style:Lm,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:Pm,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:Am})}),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:Bm,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:Mm,children:["创建新",f,"并关联"]})]})]})})},Rm={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Lm={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")},Pm={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Am={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"},Bm={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")},Mm={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Nr={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Wm={work:"📜",book:"📖",collection:"📚",entity:"👤"},Dl=({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`创建新${Nr[n]}`}};return e.jsx("div",{style:Hm,onClick:m=>{m.target===m.currentTarget&&l()},children:e.jsxs("div",{style:Om,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:Wm[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:`请输入${Nr[n]}名称...`,style:Fm})]}),((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:Dm,children:"取消"}),e.jsx("button",{onClick:u,disabled:!a.trim(),style:{...Um,opacity:a.trim()?1:.6,cursor:a.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Hm={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Om={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")},Fm={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"},Dm={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Um={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function Vm(t){switch(t){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Ul(t){switch(t){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Gm(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 Vl=({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 _=setTimeout(async()=>{y(!0);try{f(await u(g,o))}catch{f([])}finally{y(!1)}},300);return()=>clearTimeout(_)},[g,o,u]);const j=x.useCallback(_=>{m(_.target.value),_.target.value.trim()&&b("search")},[]),w=x.useCallback(_=>s?_.filter(E=>E.id!==s):_,[s]);if(!t)return null;const S=n||(o==="all"?"选择实体":`选择${Ul(o)}`),$=w(r),z=w(h);return e.jsx("div",{style:Km,children:e.jsxs("div",{style:qm,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:Zm,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:Jm}),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(Ir,{active:k==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),e.jsxs(Ir,{active:k==="search",onClick:()=>b("search"),children:["搜索结果 ",z.length>0&&`(${z.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:k==="recent"&&$.length>0?e.jsx(Er,{entities:$,onSelect:d}):g.trim()?v?e.jsx(li,{message:"搜索中..."}):z.length>0?e.jsx(Er,{entities:z,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:Xm,children:a||"创建新实体"})]})]})})},Ir=({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}),Er=({entities:t,onSelect:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map(o=>e.jsx(Ym,{entity:o,onClick:()=>n(o)},o.id))}),Ym=({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:Vm(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:Gm(t.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Ul(t.type)})]})},li=({message:t})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:t}),Km={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},qm={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")},Zm={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Jm={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"},Xm={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Qm={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},eg={work:"📜",collection:"📚",book:"📖",entity:"👤"},Gl=({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(""),[$,z]=x.useState([]),[_,E]=x.useState(!1),[T,C]=x.useState(!1),[H,M]=x.useState("work"),[A,K]=x.useState(""),[Y,ee]=x.useState(),[ue,B]=x.useState(!1),[R,Q]=x.useState(null),[P,V]=x.useState([]);x.useRef(null);const pe=t.type,ye=pe==="work",Z=pe==="collection",de=pe==="book",he=x.useCallback((F,me)=>{n({...t,[F]:me})},[t,n]),Me=x.useCallback((F,me)=>{j(F),k(me),S(h.editor.selectToLink+h.indexType[me]),z([]),v(!0)},[h]),fe=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]),We=x.useCallback((F,me,Ae)=>{const L={...Ae,author:(Ae==null?void 0:Ae.author)||t.author,dynasty:Ae==null?void 0:Ae.dynasty};M(me),K(F),ee(L),C(!0)},[t.author]),Be=x.useCallback((F,me)=>{r!=null&&r.createAndLink&&r.createAndLink(t.id,A,{type:H,title:F,inheritData:me}),C(!1)},[r,t.id,A,H]),Re=x.useCallback(F=>{if(!F.trim()){z([]);return}E(!0),r!=null&&r.searchEntities&&r.searchEntities(F,y).then(me=>{z(me),E(!1)}).catch(()=>{z([]),E(!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]),U=x.useCallback(F=>{Q(()=>F),B(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(V).catch(()=>{})},[r]),ae=x.useCallback((F,me)=>r!=null&&r.searchEntities?r.searchEntities(F,me==="all"?void 0:me):Promise.resolve([]),[r]),se=x.useCallback(F=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(F),V(me=>[F,...me.filter(Ae=>Ae.id!==F.id)].slice(0,10)),R==null||R(F),B(!1),Q(null)},[r,R]);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:eg[pe]}),e.jsx("span",{children:t.title||h.editor.untitled}),e.jsx(zn,{children:t.id}),e.jsx(zn,{color:Qm[pe],children:h.indexType[pe]})]})}),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:ye?h.editor.workTitle:Z?h.editor.collectionTitle:h.editor.bookTitle,value:t.title,onChange:F=>he("title",F)}),de&&e.jsx(vn,{label:h.editor.belongsToWork,value:t.workName||"",onChange:F=>he("workName",F)}),e.jsx(et,{label:h.editor.authorLabel,value:t.author||"",onChange:F=>he("author",F)}),e.jsx(et,{label:h.editor.publicationYearLabel,value:t.publicationYear||"",onChange:F=>he("publicationYear",F)}),(de||Z)&&e.jsx(vn,{label:h.editor.containedIn,value:t.collection||"",onChange:F=>he("collection",F)}),(de||Z)&&e.jsx(et,{label:h.editor.holderLabel,value:t.holder||"",onChange:F=>he("holder",F)}),(de||Z)&&e.jsx(et,{label:de?h.editor.pageLabel:h.editor.volumeLabel,value:t.pages||"",onChange:F=>he("pages",F)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(et,{label:h.editor.firstImageLabel,value:t.firstImage||"",onChange:F=>he("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=>he("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(tg,{items:t.additional_works||[],onChange:F=>he("additional_works",F)})}),e.jsx(st,{title:h.section.indexedBy,onSave:o,onAskAI:d?()=>d("收录于"):void 0,children:e.jsx(ng,{items:t.indexed_by||[],onChange:F=>he("indexed_by",F)})}),e.jsx(st,{title:h.section.emendatedBy,onSave:o,onAskAI:d?()=>d("考证"):void 0,children:e.jsx(ig,{items:t.emendated_by||[],onChange:F=>he("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=>he("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=>he("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(Bl,{items:Ml(t.sources||""),onChange:F=>he("sources",Wl(F)),onOpenEntityPicker:U})}),(de||Z)&&e.jsx(st,{title:h.section.provenance,onSave:o,onAskAI:d?()=>d("收藏历史"):void 0,children:e.jsx(Ct,{value:t.provenance||"",onChange:F=>he("provenance",F),placeholder:h.editor.provenancePlaceholder})}),de&&e.jsx(st,{title:h.section.otherEditions,onSave:o,onAskAI:d?()=>d("其他版本"):void 0,children:e.jsx(Ct,{value:t.otherEditions||"",onChange:F=>he("otherEditions",F),placeholder:h.editor.otherEditionsPlaceholder})}),e.jsx(Hl,{entityType:pe,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:Me,onUnlinkEntity:fe,onViewEntity:$e,onCreateAndLink:We,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(Fl,{isOpen:f,entityType:y,title:w,onSelect:ze,onCancel:()=>v(!1),onCreate:()=>{v(!1),We(b,y)},searchResults:$,onSearch:Re,isLoading:_,excludeId:t.id}),e.jsx(Dl,{isOpen:T,entityType:H,relationField:A,inheritData:Y,onConfirm:Be,onCancel:()=>C(!1)}),e.jsx(Vl,{isOpen:ue,title:h.action.selectBookOrWork,filterType:"all",recentEntities:P,excludeId:t.id,onSelect:se,onCancel:()=>{B(!1),Q(null)},onSearch:ae})]})};function tg({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 Yl({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 ng({items:t,onChange:n}){const o=ke();return e.jsx(Yl,{items:t,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function ig({items:t,onChange:n}){const o=ke();return e.jsx(Yl,{items:t,onChange:n,addLabel:o.action.addEmendatedBy})}function Kl(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 og(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 rg=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),z=l?s:S;x.useEffect(()=>{s!==S&&$(s)},[s]);const _=x.useCallback(()=>{const K=z==="view"?"edit":"view";l?l(K):$(K)},[z,l]),[E,T]=x.useState(null);x.useEffect(()=>{o&&r&&r.getItem(o).then(K=>{K&&T(K)})},[o,r]);const C=n||E,H=x.useMemo(()=>C?Kl(C):null,[C]),M=l||!n?e.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:z==="edit"?i("accent-bg"):"transparent",color:i(z==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:z==="view"?w.common.switchToEdit:w.common.switchToView,children:z==="view"?w.common.modeEdit:w.common.modeView}):null,A=e.jsxs(e.Fragment,{children:[M,k]});return!C&&!H?e.jsx(Nt,{}):z==="view"?e.jsx(Ui,{data:C,transport:r,onNavigate:p?K=>p(K):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(Gl,{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})},sg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],ql=({isOpen:t,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=q(),[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:lg,onClick:b=>{b.target===b.currentTarget&&n()},children:e.jsxs("div",{style:ag,onClick:b=>b.stopPropagation(),children:[e.jsxs("div",{style:cg,children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),e.jsx("button",{onClick:n,style:dg,"aria-label":s("feedback.close"),children:"✕"})]}),g==="success"?e.jsxs("div",{style:hg,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:sg.map(b=>e.jsxs("button",{onClick:()=>a(b.value),style:{...pg,...l===b.value?ug:{}},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:{...mg,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:fg}),e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),g==="error"&&e.jsx("div",{style:xg,children:h}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{onClick:y,disabled:!k,style:{...gg,opacity:k?1:.6,cursor:k?"pointer":"not-allowed"},children:s(g==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},lg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ag={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},cg={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},dg={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},pg={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"},ug={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},mg={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"},gg={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},hg={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},xg={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},fg={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,bg=16,yg=({onSubmit:t,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:l}=q(),[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+bg}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:{...jg,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(ql,{isOpen:a,onClose:()=>d(!1),onSubmit:t,feedbackListUrl:o})]})},jg={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"},vg=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Zl=({onSubmit:t})=>{const{t:n}=q(),[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:Rr,children:e.jsxs("div",{style:_g,children:[e.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),e.jsx("button",{onClick:()=>p("idle"),style:Cg,children:n("feedback.continueSubmit")})]})}):e.jsxs("div",{style:Rr,children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:vg.map(v=>e.jsxs("button",{onClick:()=>r(v.value),style:{...kg,...o===v.value?wg:{}},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:{...Sg}}),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:Tg}),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:{...$g,opacity:f?1:.6,cursor:f?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&e.jsx("div",{style:zg,children:u})]})},Rr={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},kg={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"},wg={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Sg={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"},$g={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},_g={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},Cg={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},zg={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},Tg={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 Lr(t){return typeof t=="function"?t():t??"/api/feedback"}const Jl=({resourceId:t,apiUrl:n})=>{const{t:o}=q(),[r,s]=x.useState([]),[l,a]=x.useState(!0),d=x.useCallback(async()=>{const p=Lr(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=Lr(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(Zl,{onSubmit:c})})]})},Ng=Nn["zh-Hant"].relation,Ig=Nn["zh-Hant"].lossStatus,Eg=Nn["zh-Hant"].resourceKind,Un=Ht("zh-Hant"),yo=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function Pr(t,n=Un){return t?yo(Ng,t)?n(`detail.relation.${t}`):t:n("detail.relation.related")}function Rg(t,n=Un){return yo(Ig,t)?n(`detail.lossStatus.${t}`):t}function Lg(t,n=Un){return yo(Eg,t)?n(`detail.resourceKind.${t}`):""}function jo({authors:t,onNavigate:n,renderLink:o}){const{convert:r}=q(),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 Xl(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 Ql(t,n){const o=(t.url?Ot(t.url):void 0)||t.name,r=nl(t,n);return r?`${o}(${r})`:o}function vo({item:t,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=q(),[l,a]=x.useState(!1),d=In(t),c=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),p=s(Ql(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 ea({groups:t,listedVolumeCounts:n}){const{t:o,convert:r}=q();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(Ql(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 Ar=12,Pg=60,ta=({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}=q(),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<=Pg,S=w||f||!!y||b,$=x.useMemo(()=>S?g:g.slice(0,Ar),[g,S]);x.useEffect(()=>{if(!n||$.length===0)return;const U=$.filter(se=>!m.has(se));if(U.length===0)return;let ae=!1;return Promise.all(U.map(se=>n.getItem(se).then(Se=>{const F=Se??{};return[se,{id:se,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(()=>[se,{id:se}]))).then(se=>{ae||h(Se=>{const F=new Map(Se);for(const[me,Ae]of se)F.set(me,Ae);return F})}),()=>{ae=!0}},[n,$,m]);const z=x.useMemo(()=>g.map(U=>m.get(U)??{id:U}),[g,m]),_=g.length>0&&g.every(U=>m.has(U)),E=!!n&&$.some(U=>!m.has(U)),T=w||S,C=x.useMemo(()=>ol(z,t.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[z,t.version_graph,y,b,T]),H=f?C.rows:C.rows.slice(0,Ar),M=C.allRows.filter(U=>U.hasImage).length,A=t.related_works||[],K=A.filter(U=>U.relation==="collected_in"),Y=x.useMemo(()=>{const U=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],ae=se=>{const Se=U.indexOf(se??"");return Se<0?U.length:Se};return A.filter(se=>se.relation!=="collected_in").map((se,Se)=>({r:se,i:Se})).sort((se,Se)=>ae(se.r.relation)-ae(Se.r.relation)||se.i-Se.i).map(se=>se.r)},[A]),ee=x.useMemo(()=>{const U=Ji(t.resources,t.resource_groups);return[...U.mirrors.flatMap(ae=>ae.items.map(se=>({r:se,kind:p(ae.label)}))),...U.buckets.flatMap(ae=>ae.items.map(se=>({r:se,kind:p(Lg(ae.key,c))})))]},[t.resources,t.resource_groups,p,c]),ue=t.indexed_by||[],B=t.emendated_by||[],R=x.useMemo(()=>{var X,ge,I;const U=[],ae=(ge=(X=t.authors)==null?void 0:X[0])==null?void 0:ge.dynasty;ae&&U.push({label:c("workPage.fact.written"),value:p(ae)});const se=xt(t,u.unit.juan);if(se){const te=(I=t.juan_count)==null?void 0:I.description;U.push({label:c("workPage.fact.measure"),value:e.jsxs(e.Fragment,{children:[p(se),te&&te!==se?e.jsxs("span",{className:"bim-d-meta",children:["(",p(te),")"]}):null]})})}t.loss_status&&U.push({label:c("workPage.fact.loss"),value:p(Rg(t.loss_status,c))});const Se=C.allRows.filter(te=>te.sortYear!=null),F=Se.length>0?Se.reduce((te,J)=>te.sortYear<=J.sortYear?te:J):null;F!=null&&F.era.era?U.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}):E&&U.push({label:c("workPage.fact.earliest"),value:e.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),B.length&&U.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:B.length})});const me=Br(t.additional_titles);me.length&&U.push({label:c("workPage.fact.alias"),value:me.map(p).join("、")});const Ae=Br(t.attached_texts);Ae.length&&U.push({label:c("workPage.fact.attached"),value:Ae.map(p).join("、")});const L=(t.additional_works||[]).map(te=>p(te.book_title)+(te.n_juan!=null?` ${te.n_juan}${u.unit.juan}`:""));return L.length&&U.push({label:c("workPage.fact.appendix"),value:L.join("、")}),U},[t,p,c,u,E,C.allRows,B.length]),P=[{value:t._edition_count??g.length,label:c("workPage.stat.editions")},{value:_?M:0,label:c("workPage.stat.hasImage")},{value:ue.length,label:c("workPage.stat.catalogs")}],V=t.classification,pe=V?[V.l1,V.l2,V.l3,V.l4].filter(Boolean).map(U=>p(U)):[],ye=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:[...pe,V!=null&&V.source?c("workPage.classifiedBy",{source:p(V.source.split("/")[0])}):"",ye]}),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(U=>p(Mp(U))).filter(Boolean).join(" · ")}):null]}):void 0,stats:P,facts:R,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((U,ae)=>e.jsxs("details",{style:{marginTop:12},children:[e.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(U.title)}),e.jsx(ht,{text:U.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},ae))}),de=C.eras.length>=2?[{key:"",label:c("catalog.all")},...C.eras.map(U=>({key:U,label:`${U} ${C.allRows.filter(ae=>ae.era.era===U).length}`}))]:[],he=[];g.length&&he.push({id:"versions",label:c("workPage.sec.versions"),count:g.length}),ue.length&&he.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:ue.length}),K.length&&he.push({id:"collected",label:c("workPage.sec.collected"),count:K.length}),Y.length&&he.push({id:"related",label:c("workPage.sec.related"),count:Y.length}),ee.length&&he.push({id:"resources",label:c("workPage.sec.resources"),count:ee.length});const Me=g.length===0&&ue.length===0,fe=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}),_&&M?c("workPage.versionsWithImage",{n:M}):"",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&&de.length===0&&g.length>1?"":void 0,children:[de.length>0&&e.jsx(On,{items:de,value:y,onChange:U=>{k(U),v(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx(pl,{label:c("workPage.scanOnly"),checked:b,onChange:U=>{j(U),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(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:H.map(U=>{var ae;return e.jsx(Ag,{row:U,measure:(ae=m.get(U.id))==null?void 0:ae.measure_info,loaded:m.has(U.id),onNavigate:o,renderLink:r},`${U.id}:${m.has(U.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:C.rows.length,shown:H.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")})]}),ue.length>0&&e.jsx(Bg,{items:ue,transport:n,onNavigate:o,renderLink:r}),Me&&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=(U,ae)=>e.jsx(Ue,{id:U,label:p(ae),onNavigate:o,renderLink:r,dense:!0}),We=x.useMemo(()=>{const U=new Map;for(const ae of Y){const se=Pr(ae.relation,c);U.set(se,(U.get(se)??0)+1)}return U.size>1?[...U.entries()].sort((ae,se)=>se[1]-ae[1]).slice(0,4).map(([ae,se])=>`${p(ae)} ${se}`).join(" · "):void 0},[Y,p,c]),Be=e.jsxs(e.Fragment,{children:[e.jsx(_t,{id:"collected",title:c("workPage.sec.collected"),items:K.map(U=>$e(U.id,U.title))}),e.jsx(_t,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:Y.length}),sub:We,items:Y.map(U=>e.jsxs(e.Fragment,{children:[$e(U.id,U.title),e.jsx("span",{className:"bim-d-meta",title:U.note?p(U.note):void 0,children:p(Pr(U.relation,c))})]}))}),e.jsx(_t,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:ee.map(({r:U,kind:ae})=>{const se=p((U.url?Ot(U.url):void 0)||U.name),Se=Ft(U);return e.jsxs(e.Fragment,{children:[Se?e.jsxs("a",{href:Se,target:"_blank",rel:"noopener noreferrer",children:[se," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}):e.jsx("span",{children:se}),ae&&e.jsx("span",{className:"bim-d-meta bim-d-kind",children:ae})]})})})]});return e.jsx(an,{railTop:l,back:a,nav:he,railLinks:d,main:fe,card:Z,side:Be})};function Br(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Mr(t,n){return n((t.url?Ot(t.url):void 0)||t.name)}function Ag({row:t,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:l,convert:a}=q(),d=[t.era.era,t.era.reign].filter(Boolean).join(" "),c=t.era.source==="edition",p=t.holders[0],u=p?Mr(p,a):t.locationName?a(t.locationName):"",g=t.images[0],m=g?Ft(g):void 0,h=t.images.map(f=>Mr(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 Bg({items:t,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:l}=q(),[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 Mg(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 Wg(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 Wr(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 Hg(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 Og(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=Og(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 C=w.get(T);if(C&&C.lineage)return(C.lineage.derived_from??[]).map(M=>M.ref);const H=S.get(T);return H?(H.derived_from??[]).map(M=>M.ref):[]},z=T=>S.has(T)?!u||u.has(T):!p||p.has(T),_=new Set,E=T=>{if(!_.has(T)){_.add(T);for(const C of $(T))l.has(C)||(z(C)||(S.has(C)?m.add(C):w.has(C)&&g.add(C)),E(C))}};for(const T of n)p&&p.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(w=>!l.has(w.id)).filter(w=>!p||p.has(w.id)||g.has(w.id)).map(w=>{const S=Wg(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=Mg(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(Wr(w.id,S,$))}),(w.lineage.related_to??[]).forEach((S,$)=>{j(Hg(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(Wr(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 na(t,n,o){const r=(t??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function Fg(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 ia=({graph:t,renderLink:n,className:o,style:r})=>{const{t:s,convert:l}=q();if(!t.nodes.length)return e.jsx("div",{style:{...nh,...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:{...Ug,...r},children:[t.title&&e.jsx("div",{style:Vg,children:l(t.title)}),t.description&&e.jsx("div",{style:Gg,children:l(t.description)}),m.map(h=>e.jsx(Hr,{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(Hr,{label:s("lineage.otherGroup"),nodes:u,incomingMap:a,siblingMap:d,nodeMap:c,renderLink:n})]})},Hr=({label:t,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:l,renderLink:a})=>{const{convert:d}=q();return e.jsxs("div",{style:Yg,children:[e.jsx("div",{style:{...Kg,borderLeftColor:n??i("widget-border")},children:d(t)}),o.map(c=>e.jsx(Dg,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:l,renderLink:a},c.id))]})},Dg=({node:t,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const l=t.kind==="hypothetical",a=t.bridge,{t:d,convert:c}=q();return e.jsxs("div",{style:{...qg,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:Zg,children:[e.jsx("span",{style:Jg,children:l||!s?c(t.label):s(t.id,c(t.label))}),(t.year_text||t.year!=null)&&e.jsx("span",{style:Xg,children:na(c(t.year_text),t.year,t.year_uncertain)})]}),e.jsxs("div",{style:Qg,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:eh,children:d("lineage.extant",{juan:c(t.extant_juan)})}),t.note&&e.jsx("div",{style:th,children:c(t.note)}),n.length>0&&e.jsxs("div",{style:Fr,children:[e.jsx("div",{style:Dr,children:d("lineage.sources")}),n.map(p=>{const u=r.get(p.source);return e.jsxs("div",{style:Ur(p.confidence),children:[e.jsx("span",{style:Vr,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(Or,{level:p.confidence}),p.evidence&&e.jsxs("span",{style:Gr,children:["· ",c(p.evidence)]})]},p.id)})]}),o.length>0&&e.jsxs("div",{style:Fr,children:[e.jsx("div",{style:Dr,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:Ur(p.confidence),children:[e.jsx("span",{style:Vr,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(Or,{level:p.confidence}),p.evidence&&e.jsxs("span",{style:Gr,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})},Or=({level:t})=>{const{t:n}=q(),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},Ug={fontSize:"14px",color:i("fg")},Vg={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Gg={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},Yg={marginBottom:"16px"},Kg={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},qg={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},Zg={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Jg={fontSize:"15px",fontWeight:600},Xg={fontSize:"12px",color:i("muted")},Qg={marginBottom:"6px"},eh={fontSize:"12px",color:i("muted"),margin:"2px 0"},th={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},Fr={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},Dr={fontSize:"11px",color:i("muted"),marginBottom:"2px"},Ur=t=>({fontSize:"12px",margin:"2px 0",opacity:t==="probable"||t==="disputed"?.85:1}),Vr={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},Gr={fontSize:"11px",color:i("muted")},nh={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},oa=({selectedNodeId:t,...n})=>{const{t:o}=q(),[r,s]=x.useState("loading"),[l,a]=x.useState(null);return x.useEffect(()=>{let d=!1;return ih().then(c=>{d||(c?(a(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),r==="loading"?e.jsx("div",{style:Kr,children:o("lineage.graphLoading")}):r==="missing"||!l?e.jsxs("div",{style:Kr,children:[e.jsx("div",{children:Yr(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:Yr(o("lineage.graphMissingHint"),{list:e.jsx("code",{children:"VersionLineageList"})})})]}):e.jsx(oh,{modules:l,selectedNodeId:t,...n})};function Yr(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 ih(){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 oh=({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 Y,ee,ue,B;const z=((Y=$.data)==null?void 0:Y.stepPosition)??.85,[_,E,T]=f({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:z,borderRadius:5}),C=!!((ee=$.data)!=null&&ee.isSibling),H=C?E:$.targetX-18,M=C?T:$.targetY-12,A=(ue=$.data)==null?void 0:ue.labelStyle,K=(B=$.data)==null?void 0:B.labelBgStyle;return e.jsxs(e.Fragment,{children:[e.jsx(m,{id:$.id,path:_,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&e.jsx(h,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${H}px,${M}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...K,...A},children:$.label})})]})}}),[m,h,f]),k=x.useMemo(()=>({version:$=>{const{t:z}=q(),_=$.data,E=_.kind==="hypothetical",T=_.status==="lost",C=_.isSelected,H=_.bridge,M=_.borderColor??i("muted"),A=H||E?"dashed":"solid",K=H?.5:T?.6:1;return e.jsxs("div",{style:{background:i(H?"bg-subtle":"bg"),border:`2px ${A} ${C?i("primary"):M}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:K,boxShadow:C?i("shadow-node-selected"):E||H?"none":i("shadow-node")},title:H?z("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||!_.renderLink?_.label:_.renderLink(_.bookId,_.label)}),_.description&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:_.description}),_.yearText&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:na(_.yearText,void 0,_.uncertain)}),T&&e.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:z("lineage.lost")}),e.jsx(u,{type:"source",position:g.Right,style:{visibility:"hidden"}})]})}}),[u,g]),{convert:b}=q(),{rfNodes:j,rfEdges:w}=x.useMemo(()=>rh(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 rh(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??lh(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 E,T;const z=((E=c.node(S.target))==null?void 0:E.y)??0,_=((T=c.node($.target))==null?void 0:T.y)??0;return z-_}),w=j.length;j.forEach((S,$)=>{const z=($-(w-1)/2)*h;v.set(S.id,m+z)})}const y=t.edges.map(k=>sh(k,v.get(k.id),s));return{rfNodes:g,rfEdges:y}}function sh(t,n,o=r=>r??""){const r=t.confidence==="probable"||t.confidence==="disputed",s=t.kind==="sibling",l=ah(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 lh(t){if(t.year_range)return`~${t.year_range[0]}–${t.year_range[1]}`;if(typeof t.year=="number")return String(t.year)}function ah(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 Kr={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}=q(),[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:ch,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 z=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),z!=null?` ${z}`:""]},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(ia,{graph:t,renderLink:o}):e.jsx(oa,{graph:t,renderLink:o,height:r,selectedNodeId:s})]})},ch={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"}),qr=40,Zr=2,dh=9,ph=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 ra=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:l,fullTextPending:a,chapterLink:d,railTop:c,back:p,railLinks:u})=>{var I,te,J,oe,_e,Le,D,Te,Ce,je,He;const g=ke(),{t:m,convert:h}=q(),[f,v]=x.useState(null),[y,k]=x.useState(new Map),[b,j]=x.useState([]),[w,S]=x.useState(new Map),[$,z]=x.useState(!1),[_,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(ne=>{!N&&ne&&ne.type==="work"&&v(ne)}).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(ne=>{N||C(ne&&ne.nodes.length>1?ne:null)}).catch(()=>{N||C(null)}),()=>{N=!0}},[n,t.work_id]),x.useEffect(()=>{const N=t.contained_in||[];if(!n||N.length===0){k(new Map);return}let ne=!1;return Promise.all(N.map(ce=>{const le=typeof ce=="string"?ce:ce.id;return n.getItem(le).then(re=>[le,re]).catch(()=>[le,null])})).then(ce=>{if(ne)return;const le=new Map;for(const[re,W]of ce)W&&le.set(re,W);k(le)}),()=>{ne=!0}},[n,t.contained_in]);const H=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]),M=H.length-1;x.useEffect(()=>{if(!n||M<=0){j([]);return}const N=H.length<=qr,ne=N?H:H.slice(0,8);let ce=!1;return Promise.all(ne.map(le=>le===t.id?Promise.resolve({id:le,title:t.title,edition:t.edition,year:$n(t)}):n.getItem(le).then(re=>{const W=re??{};return{id:le,title:W.title,edition:W.edition,year:re?$n(W):void 0}}).catch(()=>({id:le})))).then(le=>{if(ce)return;const re=le.filter(W=>W.id===t.id||W.title||W.edition);N&&re.sort((W,xe)=>(W.year??1/0)-(xe.year??1/0)),j(re)}),()=>{ce=!0}},[n,H,M,t]);const A=t.lineage,K=x.useMemo(()=>[...((A==null?void 0:A.derived_from)||[]).filter(N=>N.ref_type==="book").map(N=>N.ref),...((A==null?void 0:A.related_to)||[]).map(N=>N.book_id)].filter(Boolean),[A]);x.useEffect(()=>{if(!n||K.length===0){S(new Map);return}let N=!1;return Promise.all(K.map(ne=>n.getItem(ne).then(ce=>[ne,{id:ne,title:ce==null?void 0:ce.title,edition:ce==null?void 0:ce.edition}]).catch(()=>[ne,{id:ne}]))).then(ne=>{N||S(new Map(ne))}),()=>{N=!0}},[n,K]);const Y=x.useMemo(()=>Xl(t.resources,t.resource_groups,m),[t.resources,t.resource_groups,m]),ee=Y.groups.reduce((N,ne)=>N+ne.rows.length+ne.mirrors.length,0),ue=Y.groups.length>0&&Y.groups.every(N=>N.key==="_physical"),B=ln(t),R=cl(t),Q=xt(t,g.unit.juan),P=new Set((t.contained_in||[]).map(N=>typeof N=="string"?0:nn(N.volume_index).length).filter(N=>N>0)),V=N=>{var le;const ne=(le=t.base_edition)==null?void 0:le.find(re=>re.book_id===N&&re.name);if(ne!=null&&ne.name)return ne.name;const ce=w.get(N);return(ce==null?void 0:ce.edition)||(ce==null?void 0:ce.title)||""},pe=x.useMemo(()=>{var we,be,ie,Oe,De;const N=[];R&&N.push({label:m("bookPage.fact.editionType"),value:h(R),title:t.edition_type||(we=t.lineage)!=null&&we.category?void 0:m("bookPage.inferredFromEdition")}),(be=t.publication_info)!=null&&be.details?N.push({label:m("bookPage.fact.publication"),value:h(t.publication_info.details)}):(B.era||B.reign)&&N.push({label:m("bookPage.fact.era"),value:h([B.era,B.reign].filter(Boolean).join(" ")),title:B.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),Q&&N.push({label:m("bookPage.fact.measure"),value:h(Q)});const ne=(t.contained_in||[]).flatMap(Ie=>typeof Ie=="string"?[]:nn(Ie.volume_index));ne.length&&N.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:Hn(ne,g.unit.volume),unit:g.unit.volume,n:ne.length})});const ce=(((ie=t.lineage)==null?void 0:ie.derived_from)||[]).find(Ie=>Ie.relation==="底本"&&Ie.ref_type==="book");ce&&V(ce.ref)&&N.push({label:m("bookPage.fact.baseEdition"),value:e.jsx(Ue,{id:ce.ref,label:h(V(ce.ref)),onNavigate:o,renderLink:r,dense:!0})});const le=(t.base_edition||[]).filter(Ie=>Ie&&Ie.name);for(const Ie of["底本","配補","參校"]){if(Ie==="底本"&&ce&&V(ce.ref))continue;const Qe=le.filter(G=>G.role===Ie);Qe.length&&N.push({label:h(Ie),value:Qe.map((G,Pe)=>e.jsxs(x.Fragment,{children:[Pe>0&&"、",G.book_id?e.jsx(Ue,{id:G.book_id,label:h(G.name),onNavigate:o,renderLink:r,dense:!0}):h(G.name)]},Pe))})}const re=(t.provenance||[]).filter(Ie=>Ie&&Ie.institution),W=(t.resources||[]).filter(Ie=>(Ie.types||(Ie.type?[Ie.type]:[])).includes("physical"));if(re.length){N.push({label:m("bookPage.fact.holdings"),value:re.slice(0,2).map(G=>h(G.institution)).join("、")+(re.length>2?m("bookPage.andMorePlaces",{n:re.length}):"")});const Ie=re.filter(G=>G.call_number).slice(0,2).map(G=>`${h(G.institution)} ${G.call_number}`);Ie.length&&N.push({label:m("bookPage.fact.callNumber"),value:Ie.join(";")+(re.filter(G=>G.call_number).length>2?"…":"")});const Qe=re.flatMap(G=>G.seals||[]).filter(Boolean);Qe.length&&N.push({label:m("bookPage.fact.seals"),value:h(Qe.join("、"))})}else W.length?N.push({label:m("bookPage.fact.holdings"),value:W.slice(0,2).map(Ie=>h(Ie.name)).join("、")+(W.length>2?m("bookPage.andMorePlaces",{n:W.length}):"")}):(Oe=t.current_location)!=null&&Oe.name&&N.push({label:m("bookPage.fact.holdings"),value:h(t.current_location.name)});const xe=t.physical_description;if(xe){const Ie=[[m("bookPage.fact.leafStyle"),xe.leaf_style],[m("bookPage.fact.binding"),xe.binding],[m("bookPage.fact.dimensions"),xe.dimensions],[m("bookPage.fact.condition"),xe.condition]];for(const[Qe,G]of Ie)G&&G.trim()&&N.push({label:Qe,value:h(G)})}(De=t.page_count)!=null&&De.description&&N.push({label:g.label.pageCount,value:h(t.page_count.description)});const O=[..._i(t.additional_titles),..._i(t.attached_texts)];return O.length&&N.push({label:m("bookPage.fact.aliases"),value:O.map(h).join("、")}),N},[t,h,g,m,B,R,Q,w,o,r]),ye=h(t.title),Z=t.edition?h(t.edition):void 0,de=((I=t.lineage)==null?void 0:I.year_text)||"",he=e.jsx(cn,{kind:m("bookPage.kind"),title:ye,subtitle:Z,byline:e.jsx(jo,{authors:t.authors??(f==null?void 0:f.authors),onNavigate:o,renderLink:r}),meta:(()=>{const N=[R?h(R):"",B.era?h([B.era,B.reign].filter(Boolean).join("")):"",Q?h(Q):""].filter(Boolean);return N.length?e.jsx("span",{className:"bim-d-tags",children:N.map((ne,ce)=>e.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(ce,2)}`,children:ne},ce))}):null})(),description:(te=t.description)!=null&&te.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:pe,readAction:s,secondaryAction:s&&ee>0&&!ue?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})}),Me=t.contained_in||[],fe=(l==null?void 0:l.chapters)||[],$e=h(fe[0]&&ci(fe[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),We=m("bookPage.chapterCount",{n:fe.length,unit:$e}),Be=!!((oe=A==null?void 0:A.derived_from)!=null&&oe.length||(_e=A==null?void 0:A.related_to)!=null&&_e.length||(Le=t.appendix)!=null&&Le.length),Re=[],ze=m(ue?"bookPage.sec.physical":"bookPage.sec.images");(fe.length||Y.text.length||a)&&Re.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:fe.length?We:void 0}),Y.groups.length&&Re.push({id:"images",label:ze,count:ee}),Be&&Re.push({id:"lineage",label:m("bookPage.sec.lineage")}),Me.length&&Re.push({id:"collections",label:m("section.containedIn"),count:Me.length}),(D=t.location_history)!=null&&D.length&&Re.push({id:"provenance",label:m("section.locationHistory")});const Ee=N=>(d==null?void 0:d(N))??null,U=fe[0],ae=U?Ee(U.file):null,se=$?fe:fe.slice(0,dh),Se=(N,ne,ce)=>N?e.jsx("a",{className:ce,href:N.href??"#",onClick:N.onClick?le=>{le.metaKey||le.ctrlKey||(le.preventDefault(),N.onClick())}:void 0,children:ne}):e.jsx("span",{className:ce,children:ne}),F=e.jsxs(e.Fragment,{children:[(fe.length>0||Y.text.length>0||a)&&e.jsxs(Ke,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:fe.length>0?e.jsx(Ye,{items:[We,(Te=l==null?void 0:l.source)!=null&&Te.name?m("bookPage.sourceBy",{src:h(`${l.source.name}${l.source.license?` ${l.source.license}`:""}`)}):""]}):void 0,children:[a&&!U&&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"})]}),U&&e.jsxs("div",{className:"bim-d-ft",children:[e.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:h(ci(U.title)[0])||m("bookPage.firstChapter")})}),e.jsx("span",{className:"bim-d-meta",children:h((U.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")]}),fe.length>1&&e.jsx("ul",{className:"bim-d-chap",children:se.map(N=>{const[ne,ce]=ci(N.title);return e.jsx("li",{children:Se(Ee(N.file),e.jsxs(e.Fragment,{children:[ne&&e.jsx("b",{children:h(ne)}),h(ce||N.file)]}))},N.file)})}),fe.length>se.length&&e.jsx(to,{label:m("detail.expandRest",{n:fe.length-se.length,unit:$e}),onClick:()=>z(!0)}),Y.text.length>0&&e.jsxs(e.Fragment,{children:[(fe.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:Y.text.map((N,ne)=>e.jsx(vo,{item:N,siblings:Y.text,listedVolumeCounts:P},`${N.id||N.url||N.name}-${ne}`))})})]})]}),Y.groups.length>0&&e.jsx(Ke,{id:"images",title:ze,meta:e.jsx(Ye,{items:[Y.groups.length>1?m("bookPage.groupCount",{n:Y.groups.length}):"",m("bookPage.placeCount",{n:ee})]}),children:e.jsx(ea,{groups:Y.groups,listedVolumeCounts:P})}),Be&&e.jsx(Ke,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(Ce=A==null?void 0:A.derived_from)!=null&&Ce.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":_==="flow",onClick:()=>E("flow"),children:m("bookPage.viewCards")}),e.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>E("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&T?e.jsx(ko,{graph:T,defaultMode:"graph",selectedNodeId:t.id,graphHeight:480,renderLink:(N,ne)=>e.jsx(Ue,{id:N,label:h(ne),onNavigate:o,renderLink:r,dense:!0})}):e.jsx(mh,{data:t,heading:Z||ye,yearText:de,refName:V,onNavigate:o,renderLink:r})}),Me.length>0&&e.jsx(Ke,{id:"collections",title:m("section.containedIn"),children:e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:Me.map((N,ne)=>{var xe,O;const ce=typeof N=="string"?N:N.id,le=typeof N=="string"?[]:nn(N.volume_index),re=y.get(ce),W=(re==null?void 0:re._member_count)||((xe=re==null?void 0:re.books)==null?void 0:xe.length)||((O=re==null?void 0:re.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:ce,label:re?h(re.title):ce,onNavigate:o,renderLink:r,dense:!0}),le.length>0&&e.jsx(uh,{volumes:le,unit:g.unit.volume})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${W?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:W>0&&m("bookPage.totalOf",{n:W,unit:g.unit.bu})})]},`${ce}-${ne}`)})})})}),(je=t.location_history)!=null&&je.length?e.jsx(Ke,{id:"provenance",title:m("section.locationHistory"),children:e.jsx("ul",{className:"bim-d-tl",children:t.location_history.map((N,ne)=>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(Ye,{items:[[N.start_date,N.end_date].filter(Boolean).join("—"),N.description?h(N.description):""]})})]},ne))})}):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(N=>N.id===t.id),Ae=H.length<=qr,L=Ae&&me>=0?b.slice(Math.max(0,me-Zr),me+Zr+1):b.filter(N=>N.id!==t.id),X=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(N=>`${N.dynasty?`〔${h(N.dynasty)}〕`:""}${h(N.name)}`),h(xt(f,g.unit.juan)),f._edition_count?m("bookPage.editionCount",{n:f._edition_count}):""]}),((He=f.description)==null?void 0:He.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,""))})]}),M>0&&L.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:M}),cap:L.length,items:L.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(Ue,{id:N.id,label:h(N.edition||N.title||N.id),onNavigate:o,renderLink:r,dense:!0})),metas:L.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:L.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(Ue,{id:f.id,label:m("bookPage.viewAllInWork",{n:H.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),ge=t.work_id?e.jsx(dl,{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:ge,nav:Re,railLinks:u,main:F,card:he,side:X})};function uh({volumes:t,unit:n}){const{t:o}=q();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 mh({data:t,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:l}){var k;const{t:a,convert:d}=q(),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&&ph.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,gh=200,hh=16,sa=({data:t,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:l,railTop:a,back:d,railLinks:c})=>{var Se,F,me,Ae,L,X,ge;const{t:p,convert:u,messages:g}=q(),[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(()=>ll(t,n),[t,n]),[z,_]=x.useState(new Map),E=!!o&&$.rows.length>0&&$.rows.length<=gh,T=E&&($.rows.length<=Qt||w),C=T&&$.rows.every(I=>!I.id||z.has(I.id)),H=I=>{var te;return Ii(I?(te=z.get(I))==null?void 0:te.l1:void 0)},M=x.useMemo(()=>{const I=m.trim(),te=I?u(I):"";return $.rows.filter(J=>{var _e,Le;if(b&&Ii(J.id?(_e=z.get(J.id))==null?void 0:_e.l1:void 0)!==b)return!1;if(!te)return!0;const oe=J.id&&((Le=z.get(J.id))==null?void 0:Le.title)||J.title;return u(oe).includes(te)||(J.subItems||[]).some(D=>u(D).includes(te))})},[$.rows,m,b,z,u]),A=f?M:M.slice(0,Qt),K=x.useMemo(()=>(T?$.rows:A).filter(I=>I.id&&!z.has(I.id)).map(I=>I.id),[T,$.rows,A,z]);x.useEffect(()=>{if(!o||K.length===0)return;let I=!1;const te=K.slice(0,hh);return Promise.all(te.map(J=>o.getItem(J).then(oe=>{var D,Te;const _e=oe??{},Le={title:_e.title,edition:_e.edition,authors:_e.authors,measure:oe?xt(oe,g.unit.juan):void 0,versionCount:_e._edition_count??((D=_e.books)==null?void 0:D.length),l1:((Te=_e.classification)==null?void 0:Te.l1)||void 0};return[J,Le]}).catch(()=>[J,{}]))).then(J=>{I||_(oe=>{const _e=new Map(oe);for(const[Le,D]of J)_e.set(Le,D);return _e})}),()=>{I=!0}},[o,K,g.unit.juan]);const Y=(t.contained_in||[])[0];x.useEffect(()=>{if(!Y){k(null);return}if(k({id:Y}),!o)return;let I=!1;return o.getItem(Y).then(te=>{I||k({id:Y,title:te==null?void 0:te.title})}).catch(()=>{}),()=>{I=!0}},[o,Y]);const ee=x.useMemo(()=>Xl(t.resources,t.resource_groups,p),[t.resources,t.resource_groups,p]),ue=ee.text.length+ee.groups.reduce((I,te)=>I+te.rows.length+te.mirrors.length,0),B=t.contained_works||[],R=new Set($.rows.map(I=>I.id).filter(Boolean)),Q=B.length>0&&!B.every(I=>R.has(I.id)),P=(()=>{const I=$.rows.map(te=>te.edition).filter(Boolean);return I.length>1&&new Set(I).size===1})(),V=$.rows.some(I=>I.volumes.length>0||I.expected!=null),pe=t._member_count||((Se=t.books)==null?void 0:Se.length)||B.length,ye=xt(t,g.unit.juan),Z=t.count,de=I=>typeof I=="number"&&Number.isFinite(I)?I:null,he=de(Z==null?void 0:Z.juan)??de((F=t.juan_count)==null?void 0:F.number),Me=de(Z==null?void 0:Z.ce)??($.totalVolumes||null),fe=[{value:$.rows.length,label:p("collectionPage.stat.titles")},{value:he??0,label:g.unit.juan},{value:Me??0,label:g.unit.volume}],$e=x.useMemo(()=>{var J,oe;const I=[];if((J=t.publication_info)!=null&&J.details&&I.push({label:p("collectionPage.fact.publication"),value:u(t.publication_info.details)}),pe&&pe!==$.rows.length){const _e=t._member_type==="Book"?p("collectionPage.member.Book"):t._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");I.push({label:_e,value:`${pe} ${g.unit.bu}`,title:p("collectionPage.memberNote")})}const te=[de(Z==null?void 0:Z.zhong)!=null?p("collectionPage.nZhong",{n:Z.zhong}):"",de(Z==null?void 0:Z.han)!=null?p("collectionPage.nHan",{n:Z.han}):""].filter(Boolean);return te.length&&I.push({label:p("collectionPage.fact.expected"),value:te.join(" ")}),he==null&&ye&&I.push({label:p("collectionPage.fact.measure"),value:u(ye),title:(oe=t.juan_count)!=null&&oe.description?u(t.juan_count.description):void 0}),I},[t,pe,$.rows.length,he,ye,Z,u,p,g]),We=x.useMemo(()=>{if(!C)return[];const I=new Map;for(const J of $.rows){const oe=H(J.id);oe&&I.set(oe,(I.get(oe)??0)+1)}const te=rn.filter(J=>(I.get(J.key)??0)>0);return te.length<2?[]:[{key:"",label:`${g.catalog.all} ${$.rows.length}`},...te.map(J=>({key:J.key,label:`${J.label} ${I.get(J.key)}`}))]},[C,$.rows,z,g]),Be=x.useMemo(()=>{if(!C||!$.rows.some(oe=>oe.volumes.length>0))return null;const I=[],te=$.rows.filter(oe=>oe.volumes.length>0).map(oe=>({k:H(oe.id)??"",from:Math.min(...oe.volumes),to:Math.max(...oe.volumes)})).sort((oe,_e)=>oe.from-_e.from);for(const oe of te){const _e=oe.to-oe.from+1,Le=I[I.length-1];Le&&Le.key===oe.k?(Le.to=Math.max(Le.to,oe.to),Le.n+=_e):I.push({key:oe.k,from:oe.from,to:oe.to,n:_e})}const J=te.reduce((oe,_e)=>Math.max(oe,_e.to),0);return I.length>1&&I.some(oe=>oe.key)?{segs:I,last:J}:null},[C,$.rows,z]),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||(L=t.history)!=null&&L.length?e.jsxs(e.Fragment,{children:[Re&&e.jsx(ht,{text:Re,style:{fontSize:15,lineHeight:1.85}}),(X=t.history)!=null&&X.length?e.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:t.history.map((I,te)=>e.jsx("li",{children:u(I)},te))}):null]}):void 0,clampDescription:no(Re)||(((ge=t.history)==null?void 0:ge.length)??0)>2?6:void 0,stats:fe,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((I,te)=>{const J=rn.find(oe=>oe.key===I.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:I.from,to:I.to}):void 0,"aria-label":J?p("collectionPage.dist.only",{section:u(J.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!J&&b===I.key,style:{flexGrow:I.n,background:i(J?J.token:"rule")},onClick:()=>{J&&(j(b===I.key?"":I.key),v(!1))}},te)})}),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}),ue&&Ee.push({id:"resources",label:p("collectionPage.sec.resources"),count:ue}),Q&&Ee.push({id:"works",label:g.section.containedWorks,count:B.length});const U=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}):"",M.length!==$.rows.length?p("collectionPage.currentN",{n:M.length,unit:g.unit.items}):""]}),action:l,children:[($.rows.length>Qt||We.length>0)&&e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[We.length>0&&e.jsx(On,{items:We,value:b,onChange:I=>{j(I),v(!1)}}),E&&$.rows.length>Qt&&!C&&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:I=>{h(I.target.value),v(!1)}})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Fn(M.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[V&&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((I,te)=>{var Ce;const J=I.id?z.get(I.id):void 0,oe=J!=null&&J.title&&I.title===I.id?J.title:I.title,_e=((J==null?void 0:J.authors)||[]).find(je=>je&&je.name),Le=[_e?`${_e.dynasty?`〔${u(_e.dynasty)}〕`:""}${u(_e.name)}${_e.role?` ${u(_e.role)}`:""}`:"",J!=null&&J.measure?u(J.measure):"",(Ce=I.subItems)!=null&&Ce.length?I.subItems.map(je=>u(je)).join("、"):"",(J!=null&&J.edition||I.edition)&&!P?u((J==null?void 0:J.edition)||I.edition||""):""].filter(Boolean),D=rn.find(je=>je.key===H(I.id)),Te=I.volumes.length>0?p("collectionPage.volumeRange",{range:Hn(I.volumes,g.unit.volume),unit:g.unit.volume}):I.expected!=null?`${I.found??0}/${I.expected} ${g.unit.volume}`:"";return e.jsxs("tr",{children:[V&&e.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Te?"":" bim-d-zt-blank"}`,children:[D&&e.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(D.token)}}),Te||e.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),e.jsxs("td",{className:"bim-d-zt-main",children:[I.id?e.jsx(Ue,{id:I.id,label:u(oe),onNavigate:r,renderLink:s,dense:!0}):e.jsx("span",{className:"bim-d-zt-name",children:u(oe)}),Le.length>0?e.jsx(Ye,{items:Le}):I.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}):""})]},`${I.id??I.title}-${te}`)})})]}),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:M.length,shown:A.length,unit:g.unit.items,onClick:()=>v(!0)})]}),ue>0&&e.jsxs(Ke,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:ue}),children:[ee.text.length>0&&e.jsxs("div",{className:"bim-d-rg",children:[ee.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:ee.text.map((I,te)=>e.jsx(vo,{item:I,siblings:ee.text},`${I.id||I.url||I.name}-${te}`))})})]}),e.jsx(ea,{groups:ee.groups})]}),$.rows.length===0&&ue===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=Q?e.jsx(_t,{id:"works",title:g.section.containedWorks,meta:p("collectionPage.nZhong",{n:B.length}),cap:12,items:B.map(I=>e.jsx(Ue,{id:I.id,label:u(I.title),onNavigate:r,renderLink:s,dense:!0}))}):null,se=y?e.jsx(dl,{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:se,nav:Ee,railLinks:c,main:U,card:ze,side:ae})},xh=16,di=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function Jr(t){if(!t)return di.length;const n=di.indexOf(t);return n===-1?di.length:n}function fh(t,n){return t==null?"":t<0?n("entityPage.bce",{n:-t}):String(t)}const bh={秦:[-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]},la=({data:t,transport:n,onNavigate:o,renderLink:r,railTop:s,back:l,railLinks:a})=>{var se,Se,F,me,Ae;const{t:d,convert:c,messages:p}=q(),u=L=>fh(L,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(L=>{const X=k.get(L.work_id);return{id:L.work_id,title:(X==null?void 0:X.title)??L.title??L.work_id,role:L.role||"",cls:Xi(L.role),versionCount:X==null?void 0:X.versionCount,section:X==null?void 0:X.cls,l1:X==null?void 0:X.l1,measure:X==null?void 0:X.measure,hasImage:X==null?void 0:X.hasImage,loaded:!!(X!=null&&X.loaded)}}),[t.works,k]),w=x.useMemo(()=>sl((t.works||[]).map(L=>L.role),d("detail.roleAll")),[t.works,d]),S=x.useMemo(()=>{const L=g==="全部"?j:j.filter(X=>X.cls===g);return v==="versions"?[...L].sort((X,ge)=>(ge.versionCount??-1)-(X.versionCount??-1)):L},[j,g,v]),$=h?S:S.slice(0,xh),z=x.useMemo(()=>$.filter(L=>!k.has(L.id)).map(L=>L.id),[$,k]);x.useEffect(()=>{if(!n||z.length===0)return;let L=!1;return Promise.all(z.map(X=>n.getItem(X).then(ge=>{var oe,_e,Le,D,Te;const I=ge??{},te=I._edition_count??(((oe=I.books)==null?void 0:oe.length)??0)+(((_e=I.collections)==null?void 0:_e.length)??0),J=[(Le=I.classification)==null?void 0:Le.l1,(D=I.classification)==null?void 0:D.l2].filter(Boolean).join(" ");return[X,{id:X,title:I.title,versionCount:te,loaded:!0,cls:J||void 0,l1:((Te=I.classification)==null?void 0:Te.l1)||void 0,measure:ge&&xt(ge,p.unit.juan)||void 0,hasImage:!!(I.has_image??I._has_image)}]}).catch(()=>[X,{id:X,loaded:!0}]))).then(X=>{L||b(ge=>{const I=new Map(ge);for(const[te,J]of X)I.set(te,J);return I})}),()=>{L=!0}},[n,z,p.unit.juan]);const _=x.useMemo(()=>{const L=new Map;for(const X of t.alt_names||[]){const ge=X.type||p.section.aliases;L.has(ge)||L.set(ge,[]),L.get(ge).push(X.name)}return[...L.entries()].sort((X,ge)=>Jr(X[0])-Jr(ge[0])).map(([X,ge])=>({label:X,names:ge}))},[t.alt_names,p]),E=t.birth_year??((se=t.dates)==null?void 0:se.birth)??void 0,T=t.death_year??((Se=t.dates)==null?void 0:Se.death)??void 0,C=(F=t.dates)==null?void 0:F.floruit,H=E!=null||T!=null?`${u(E)||"?"}—${u(T)||"?"}`:Array.isArray(C)&&C.length===2&&C.every(L=>Number.isFinite(L))?d("entityPage.floruit",{from:u(C[0]),to:u(C[1])}):"",M=new Set(["本名","字","號","号"]),A=_.filter(L=>M.has(L.label)),K=_.filter(L=>!M.has(L.label)),Y=K.reduce((L,X)=>L+X.names.length,0),ee=x.useMemo(()=>{const L=[];for(const ge of A)L.push({label:ge.label,value:ge.names.map(I=>c(I)).join("、")});const X=(t.works||[]).length;return X&&L.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:X})}),L},[t.works,A,c,d]),ue=L=>{var X;return(X=_.find(ge=>L.includes(ge.label)))==null?void 0:X.names[0]},B=ue(["字"]),R=ue(["號","号"]),Q=[B?d("entityPage.zi",{name:c(B)}):"",R?d("entityPage.hao",{name:c(R)}):""].filter(Boolean).join(","),P=t.native_place,V=t.dynasty?bh[t.dynasty]:void 0,pe=(()=>{if(!V||E==null||T==null||T<E)return null;const[L,X]=V,ge=Math.max(E,L),I=Math.min(T,X);if(I<=ge)return null;const te=X-L;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(E),death:u(T),years:T-E+1}),children:e.jsx("i",{style:{left:`${(ge-L)/te*100}%`,width:`${(I-ge)/te*100}%`}})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:`${u(L)} ${c(t.dynasty)}`}),e.jsx("span",{children:d("entityPage.lifeYears",{years:T-E+1})}),e.jsx("span",{children:u(X)})]})]})})(),ye=x.useMemo(()=>{if(!n||j.length===0||j.some(ge=>!ge.loaded))return null;const L=new Map;for(const ge of j){const I=Ii(ge.l1);I&&L.set(I,(L.get(I)??0)+1)}const X=rn.map(ge=>({...ge,n:L.get(ge.key)??0})).filter(ge=>ge.n>0);return X.length?X: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:Q||void 0,meta:e.jsxs(e.Fragment,{children:[e.jsx(Ye,{items:[t.dynasty?c(t.dynasty):"",H,P?d("entityPage.nativePlace",{place:c(P)}):""]}),pe]}),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:ee,foot:e.jsx(dn,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:[Y>0&&e.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[e.jsx("summary",{children:d("entityPage.moreNames",{n:Y})}),e.jsx("dl",{children:K.map(L=>e.jsxs(x.Fragment,{children:[e.jsx("dt",{children:c(L.label)}),e.jsx("dd",{children:L.names.map(X=>c(X)).join("、")})]},L.label))})]}),ye&&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:ye.map(L=>e.jsx("i",{style:{flexGrow:L.n,background:i(L.token)}},L.key))}),e.jsx("div",{className:"bim-d-dist-key",children:ye.map(L=>e.jsxs("span",{children:[e.jsx("i",{style:{background:i(L.token)}}),c(L.label)," ",L.n]},L.key))})]})]}),de=x.useMemo(()=>j.filter(L=>L.loaded&&(L.versionCount??0)>0).sort((L,X)=>(X.versionCount??0)-(L.versionCount??0)).slice(0,3),[j]),he=!!n&&j.length>=3&&$.some(L=>!L.loaded),Me=g==="全部"&&(he||de.length>=2),fe=t.external_ids||{},$e=[];fe.cbdb_id!=null&&$e.push({label:"CBDB",id:String(fe.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${fe.cbdb_id}`,note:fe.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const We=fe.wikidata_id;We&&$e.push({label:"Wikidata",id:We,href:`https://www.wikidata.org/wiki/${We}`});const Be=fe.viaf_id;Be&&$e.push({label:"VIAF",id:Be,href:`https://viaf.org/viaf/${Be}`});const Re=w.map(L=>({key:L.cls,label:`${L.label} ${L.count}`})),ze=[...Me&&!he?[{id:"featured",label:d("entityPage.sec.featured"),count:de.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=Me?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":he||void 0,children:[he&&[0,1,2].map(L=>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:" "})]},L)),!he&&de.map(L=>e.jsxs("div",{className:"bim-d-pick",children:[e.jsx("span",{className:"bim-d-pick-t",children:e.jsx(Ue,{id:L.id,label:c(L.title),onNavigate:o,renderLink:r,dense:!0})}),e.jsx(Ye,{items:[L.section?c(L.section):"",L.measure?c(L.measure):""]}),e.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[e.jsx("span",{className:"bim-d-pick-num",children:L.versionCount}),e.jsx("span",{children:d("entityPage.versionsUnit")}),L.hasImage&&e.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},L.id))]})]}):null,U=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:L=>{m(L),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(L=>L==="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(L=>e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ue,{id:L.id,label:c(L.title),onNavigate:o,renderLink:r,dense:!0}),L.measure?e.jsx(Ye,{items:[c(L.measure)]}):!L.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${L.section||L.loaded?"":" bim-d-zt-blank"}`,children:L.section?c(L.section):null}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${L.role?"":" bim-d-zt-blank"}`,children:L.role?c(L.role):e.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${L.loaded?"":" bim-d-zt-blank"}`,children:L.loaded?L.versionCount?d("entityPage.nZhong",{n:L.versionCount}):e.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),e.jsx("td",{className:L.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:L.hasImage&&e.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},L.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(L=>e.jsxs("a",{href:L.href,target:"_blank",rel:"noopener noreferrer",children:[L.label," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:$e.map(L=>L.id),foot:fe.cbdb_id!=null&&fe.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return e.jsx(an,{railTop:s,back:l,nav:ze,railLinks:a,main:U,card:Z,side:ae})},wo="(max-width: 719px)",yh=`${wo}, (pointer: coarse)`,aa=`
1100
+ `)){const r=so(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||lo.test(s)||n.push({kind:"body",text:o})}return n}function Nl(t){if(!t)return[];const n=Dn(t);if(n==="unknown")return hr(t);const o=[];for(const{heading:r,body:s}of Su(t)){r&&o.push(r);const l=Cl(s);if(l.length!==0){if(Tl(s)){o.push(...hr(s));continue}if(n==="record"){const a=l.join(" ");a&&o.push({kind:"body",text:a})}else for(const a of l){const d=zl(a);d.length&&o.push({kind:"body",text:d.join(" ")})}}}return o}const Il=t=>t;function El(t,n=Il){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 ao(t,n={}){const o=n.renderText??Il,r=n.properNames?l=>El(l,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return nt(t,r,s)}function xr(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 oi=/^(#{1,6})\s+(.*)$/,$u=/^\s*<!--.*-->\s*$/;function Rl(t){return t.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
1101
+ `)?"":n)}function _u(t){return t<=1?2:t===2?3:4}function Cu(){let t=1;return n=>{const o=_u(n),r=Math.min(o,t+1);return t=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function _n(t){return t?Dn(Rl(t))!=="unknown":!1}function zu(t){return/^\u3000{2}/.test(t)}const fr=t=>zu(t)?"bim-rd-noindent":void 0;function br({text:t,mode:n,inline:o,dropTitle:r}){const s=Rl(t),l=(p,u,g)=>!!r&&g<=1&&p<=2&&u.trim()===r.trim(),a=Cu();if(n==="paragraph"&&Dn(s)!=="unknown"){const p=Nl(s);return e.jsx(e.Fragment,{children:p.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:fr(u.text),children:xr(u.text,o,g)},g)})})}const d=s.split(`
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=>{on=t.Converter({from:"tw",to:"cn"}),Cn.forEach(n=>n())}).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=ve.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 je=x.useCallback(async V=>{const Pe=`${t}
1104
+ ${V}`;if(de.current.has(Pe))return de.current.get(Pe)??null;const it=await w.getIndex(t,V).catch(()=>null);return it&&de.current.set(Pe,it),it},[w,t]),[Z,ce]=x.useState(null),[fe,We]=x.useState("loading");x.useEffect(()=>{if(!ee)return;let V=!1;return ce(null),We("loading"),je(ee).then(Pe=>{V||(Pe&&Pe.chapters.length>0?(ce(Pe),We("ready")):We("failed"))}),()=>{V=!0}},[ee,je]),x.useEffect(()=>{if(!Z||!ee||L!=null&&Z.chapters.some(it=>it.file===L))return;const Pe=Z.chapters[0].file;A||pe(Pe),U(ee,Pe,"auto")},[Z,ee,L,A,U]);const be=Z?L!=null&&Z.chapters.some(V=>V.file===L)?L:Z.chapters[0].file:L,_e=x.useMemo(()=>Z&&be?Z.chapters.find(V=>V.file===be)??null:null,[Z,be]),He=x.useRef(0),Be=x.useCallback(async V=>{if(!I||V===ee||!I.versions.some(gn=>gn.key===V))return;const Pe=++He.current,it=await je(V);if(Pe!==He.current)return;const vt=_e??(be?{file:be}:null),Ut=ve.matchChapterAcrossVersions(vt,it);W||G(V),A||pe(Ut),U(V,Ut,"version")},[I,ee,je,_e,be,W,A,U]),Re=x.useCallback(V=>{ee&&(A||pe(V),U(ee,V,"chapter"))},[ee,A,U]),[ze,Ee]=x.useState(null),[D,ae]=x.useState(!1),le=x.useRef(0);x.useEffect(()=>{if(!ee||!_e)return;const V=++le.current;ae(!0),Ee(null),w.getChapter(t,ee,_e.file,{json:!!_e.has_json}).then(Pe=>{V===le.current&&Ee(Pe)}).catch(()=>{V===le.current&&Ee(null)}).finally(()=>{V===le.current&&ae(!1)})},[w,t,ee,_e]);const Se=(B==null?void 0:B.kind)==="collated",[F,me]=x.useState("");x.useEffect(()=>{me("")},[t,ee]);const Ae=x.useMemo(()=>ee&&Se?async V=>{const Pe=await w.getChapter(t,ee,V,{json:!0});return{juan:(Pe==null?void 0:Pe.json)??null,rawText:(Pe==null?void 0:Pe.md)??null}}:null,[w,t,ee,Se]),R=(Z==null?void 0:Z.type)==="kaozhen",Q=x.useMemo(()=>(Z==null?void 0:Z.chapters.map(V=>V.file))??[],[Z]),{matchStates:he}=tm({resetKey:`${t}
1105
+ ${ee??""}`,load:Ae,files:Q,activeFile:be??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,be??null),{entryTitle:J,authors:re}=cm(t,n,a===void 0),[Ce,Le]=x.useState("text");if(x.useEffect(()=>{Le("text")},[be,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(fe==="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,he,$e,j,Se),Ie=I.versions.map(V=>({key:V.key,label:ve.textVersionLabel(V),optionLabel:j(ve.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})),xe=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,ye=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(ve.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:be??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,be??null),index:om(t,Z),searchQuery:F,onNavigate:l,transport:n,workLabelCache:N,prefs:S,view:Ce,onViewChange:Le},`${ee}/${be}`),!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]}),xe&&e.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[b("reader.upstream")," ",xe.url?e.jsx("a",{className:"bim-rd-link",href:xe.url,target:"_blank",rel:"noreferrer",children:j(xe.name??xe.url)}):j(xe.name??""),xe.license&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),xe.license_url?e.jsx("a",{className:"bim-rd-link",href:xe.license_url,target:"_blank",rel:"noreferrer",children:xe.license}):xe.license]}),xe.note&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),j(xe.note)]})]})]}),e.jsx("article",{className:"bim-rd-prose",children:e.jsx(co,{text:oe,mode:S.readingMode,tables:ye,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:ve.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,je=de==="work",Z=de==="collection",ce=de==="book",fe=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]),be=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:je?h.editor.workTitle:Z?h.editor.collectionTitle:h.editor.bookTitle,value:t.title,onChange:F=>fe("title",F)}),ce&&e.jsx(vn,{label:h.editor.belongsToWork,value:t.workName||"",onChange:F=>fe("workName",F)}),e.jsx(et,{label:h.editor.authorLabel,value:t.author||"",onChange:F=>fe("author",F)}),e.jsx(et,{label:h.editor.publicationYearLabel,value:t.publicationYear||"",onChange:F=>fe("publicationYear",F)}),(ce||Z)&&e.jsx(vn,{label:h.editor.containedIn,value:t.collection||"",onChange:F=>fe("collection",F)}),(ce||Z)&&e.jsx(et,{label:h.editor.holderLabel,value:t.holder||"",onChange:F=>fe("holder",F)}),(ce||Z)&&e.jsx(et,{label:ce?h.editor.pageLabel:h.editor.volumeLabel,value:t.pages||"",onChange:F=>fe("pages",F)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(et,{label:h.editor.firstImageLabel,value:t.firstImage||"",onChange:F=>fe("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=>fe("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=>fe("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=>fe("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=>fe("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=>fe("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=>fe("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=>fe("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=>fe("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=>fe("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:be,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,he,N;const D=[],ae=(he=(Q=t.authors)==null?void 0:Q[0])==null?void 0:he.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)):[],je=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])}):"",je]}),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}`}))]:[],fe=[];g.length&&fe.push({id:"versions",label:c("workPage.sec.versions"),count:g.length}),pe.length&&fe.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:pe.length}),Y.length&&fe.push({id:"collected",label:c("workPage.sec.collected"),count:Y.length}),G.length&&fe.push({id:"related",label:c("workPage.sec.related"),count:G.length}),te.length&&fe.push({id:"resources",label:c("workPage.sec.resources"),count:te.length});const We=g.length===0&&pe.length===0,be=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:fe,railLinks:d,main:be,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,xe,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,ye,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")}),(ye=t.publication_info)!=null&&ye.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]),je=h(t.title),Z=t.edition?h(t.edition):void 0,ce=((N=t.lineage)==null?void 0:N.year_text)||"",fe=e.jsx(cn,{kind:m("bookPage.kind"),title:je,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||[],be=(l==null?void 0:l.chapters)||[],_e=h(be[0]&&ci(be[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),He=m("bookPage.chapterCount",{n:be.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");(be.length||G.text.length||a)&&Re.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:be.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=be[0],ae=D?Ee(D.file):null,le=$?be:be.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:[(be.length>0||G.text.length>0||a)&&e.jsxs(Ke,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:be.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")]}),be.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)})}),be.length>le.length&&e.jsx(to,{label:m("detail.expandRest",{n:be.length-le.length,unit:_e}),onClick:()=>_(!0)}),G.text.length>0&&e.jsxs(e.Fragment,{children:[(be.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||je,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}`)})})})}),(xe=t.location_history)!=null&&xe.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})})]})]}),he=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:he,nav:Re,railLinks:u,main:F,card:fe,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,he;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,je=xt(t,g.unit.juan),Z=t.count,ce=N=>typeof N=="number"&&Number.isFinite(N)?N:null,fe=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),be=[{value:$.rows.length,label:p("collectionPage.stat.titles")},{value:fe??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(" ")}),fe==null&&je&&N.push({label:p("collectionPage.fact.measure"),value:u(je),title:(re=t.juan_count)!=null&&re.description?u(t.juan_count.description):void 0}),N},[t,de,$.rows.length,fe,je,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)||(((he=t.history)==null?void 0:he.length)??0)>2?6:void 0,stats:be,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(xe=>xe&&xe.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(xe=>u(xe)).join("、"):"",(J!=null&&J.edition||N.edition)&&!L?u((J==null?void 0:J.edition)||N.edition||""):""].filter(Boolean),$e=rn.find(xe=>xe.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,he)=>(he.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(he=>{var re,Ce,Le,$e,X;const N=he??{},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:he&&xt(he,p.unit.juan)||void 0,hasImage:!!(N.has_image??N._has_image)}]}).catch(()=>[Q,{id:Q,loaded:!0}]))).then(Q=>{R||b(he=>{const N=new Map(he);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 he=Q.type||p.section.aliases;R.has(he)||R.set(he,[]),R.get(he).push(Q.name)}return[...R.entries()].sort((Q,he)=>Xr(Q[0])-Xr(he[0])).map(([Q,he])=>({label:Q,names:he}))},[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 he of A)R.push({label:he.label,value:he.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(he=>R.includes(he.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,he=Math.max(I,R),N=Math.min(T,Q);if(N<=he)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:`${(he-R)/ne*100}%`,width:`${(N-he)/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)})]})]})})(),je=x.useMemo(()=>{if(!n||j.length===0||j.some(he=>!he.loaded))return null;const R=new Map;for(const he of j){const N=Ii(he.l1);N&&R.set(N,(R.get(N)??0)+1)}const Q=rn.map(he=>({...he,n:R.get(he.key)??0})).filter(he=>he.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))})]}),je&&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:je.map(R=>e.jsx("i",{style:{flexGrow:R.n,background:i(R.token)}},R.key))}),e.jsx("div",{className:"bim-d-dist-key",children:je.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]),fe=!!n&&j.length>=3&&$.some(R=>!R.loaded),We=g==="全部"&&(fe||ce.length>=2),be=t.external_ids||{},_e=[];be.cbdb_id!=null&&_e.push({label:"CBDB",id:String(be.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${be.cbdb_id}`,note:be.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const He=be.wikidata_id;He&&_e.push({label:"Wikidata",id:He,href:`https://www.wikidata.org/wiki/${He}`});const Be=be.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&&!fe?[{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":fe||void 0,children:[fe&&[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)),!fe&&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:be.cbdb_id!=null&&be.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=`
1084
1106
  .bim-ct {
1085
1107
  display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
1086
1108
  max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
@@ -1213,7 +1235,7 @@ ${Q??""}`,load:Ae,files:X,activeFile:fe??null,activeJuan:(ze==null?void 0:ze.jso
1213
1235
  }
1214
1236
 
1215
1237
  /* 点击目标 ≥44px(Q5):触屏与窄屏 */
1216
- @media ${yh} {
1238
+ @media ${kh} {
1217
1239
  .bim-ct-row { min-height: 44px; }
1218
1240
  .bim-ct-tw { width: 44px; }
1219
1241
  .bim-ct-pg { min-width: 44px; height: 44px; }
@@ -1239,7 +1261,7 @@ ${Q??""}`,load:Ae,files:X,activeFile:fe??null,activeJuan:(ze==null?void 0:ze.jso
1239
1261
  /* 窄屏分类抽屉:界栏下按钮和面板都有框 */
1240
1262
  :root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${i("fr-bd")}; background: ${i("fr-bg")}; }
1241
1263
  :root[data-layout="boxed"] .bim-ct-drawer { border: ${i("fr-bd")}; }
1242
- `,$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 jh(t){const n=un(t);return n.length?n.join("/"):$t}function vh(t){const n=un(t);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[$t]}function kh(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 wh(t){return(t??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function Sh(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=wh(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 $h(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 _h(t,n=So){return Math.max(1,Math.ceil(t/n))}function ca(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 Ch=()=>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 zh(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 da({tree:t,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:l,convert:a}=q(),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 _=new Set;for(const E of Lt(t,u))_.add(E.id);return _});x.useEffect(()=>{const _=Lt(t,u);_.length&&h(E=>{if(_.every(C=>E.has(C.id)))return E;const T=new Set(E);for(const C of _)T.add(C.id);return T})},[t,u]);const f=x.useMemo(()=>zh(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 _=new Set(f.map(C=>C.id));if(v&&_.has(v))return v;if(k&&_.has(k))return k;const E=Lt(t,u).map(C=>C.id).filter(C=>_.has(C));return E.length?E[E.length-1]:((T=f[0])==null?void 0:T.id)??null},[f,v,k,t,u]),j=x.useCallback((_,E)=>{h(T=>{const C=T.has(_),H=E??!C;if(H===C)return T;const M=new Set(T);return H?M.add(_):M.delete(_),M})},[]),w=x.useCallback(_=>{y(_),requestAnimationFrame(()=>{var T;const E=Array.from(((T=p.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(C=>C.dataset.ctId===_);E==null||E.focus()})},[]),S=x.useCallback((_,E)=>{E&&j(_,!0),o(_)},[o,j]),$=x.useCallback(_=>{const E=_.target.closest("[data-ct-id]");if(!E)return;const T=E.dataset.ctId,C=f.findIndex(A=>A.id===T);if(C<0)return;const H=f[C];let M=null;switch(_.key){case"ArrowDown":M=f[Math.min(f.length-1,C+1)].id;break;case"ArrowUp":M=f[Math.max(0,C-1)].id;break;case"Home":M=f[0].id;break;case"End":M=f[f.length-1].id;break;case"ArrowRight":if(!H.hasChildren)break;m.has(T)?M=H.firstChildId:j(T,!0);break;case"ArrowLeft":H.hasChildren&&m.has(T)?j(T,!1):M=H.parentId;break;case"Enter":case" ":_.preventDefault(),S(T,H.hasChildren);return;default:return}_.preventDefault(),M&&M!==T&&w(M)},[f,m,j,w,S]),z=(_,E)=>_.map((T,C)=>{var Y;const H=(Y=T.children)!=null&&Y.length?T.children:null,M=!!H&&m.has(T.id),A=T.id===u,K=E===1&&_.length>1&&C===_.length-1;return e.jsxs("li",{role:"treeitem","aria-level":E,"aria-expanded":H?M:void 0,"aria-selected":A,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:K?"bim-ct-last":void 0,children:[e.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":E-1},onClick:()=>{y(T.id),S(T.id,!!H)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:H?ee=>{ee.stopPropagation(),y(T.id),j(T.id)}:void 0,children:H?e.jsx(Ch,{}):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")})]}),M&&e.jsx("ul",{role:"group",children:z(H,E+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")})]})}),z(t,1)]})}const pa=t=>`/item/${encodeURIComponent(t)}`;function Th(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}function ua(t,n){return t==null||t===""?null:typeof t=="number"?n("catalogPage.juanN",{n:t}):t}function ma({work:t,href:n}){var d,c;const{t:o,convert:r}=q(),s=ua(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 ga({work:t,href:n}){var d,c;const{t:o,convert:r}=q(),s=ua(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 ha({page:t,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:l,convert:a}=q();if(n<=1)return null;const d=p=>u=>{o&&(r&&!Th(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:ca(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 xa({works:t,workLink:n=pa,emptyText:o,view:r="card",...s}){const{t:l,convert:a}=q();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(ga,{work:d,href:n(d.id)},d.id))}):e.jsx("ul",{className:"bim-ct-grid",children:t.map(d=>e.jsx(ma,{work:d,href:n(d.id)},d.id))}),e.jsx(ha,{...s})]})}const Nh=()=>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 Ih({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}=q(),b=u===void 0?y("catalogPage.all"):u,j=g??y("catalogPage.allTitle"),S=`bim-ct-drawer-${x.useId().replace(/:/g,"")}`,[$,z]=x.useState(!1),[_,E]=x.useState("card"),T=f??_,C=ee=>{E(ee),v==null||v(ee)},H=Lt(t,n&&n!==mt?n:null),M=H.length?H[H.length-1]:null,A=M?M.label:j,K=M?M.count:$o(t),Y=x.useCallback(ee=>{z(!1),l(ee)},[l]);return e.jsxs("div",{className:h?`bim-ct ${h}`:"bim-ct","data-drawer":$?"open":"closed",children:[e.jsx("style",{children:aa}),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:()=>z(ee=>!ee),children:[e.jsx("span",{children:y("catalogPage.drawerLabel",{path:k(H.length?H.map(ee=>ee.label).join(" › "):b??j)})}),e.jsx(Nh,{})]}),e.jsxs("div",{className:"bim-ct-drawer",id:S,children:[e.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),e.jsx(da,{tree:t,selectedId:n,onSelect:Y,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(ee=>ee.label).join(" › "))}),e.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:K.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")})]})]}),d&&e.jsx("div",{className:"bim-ct-search",children:d}),e.jsx(xa,{works:s,view:T,workLink:c,page:o,pageCount:r,onPage:a,pageHref:p})]})]})}const mn="(max-width: 719px)",Eh="(max-width: 1079px)",Rh=`${mn}, (pointer: coarse)`,Lh=[8,18,30,42,88],_o=`
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=`
1243
1265
  .bim-rh { color: ${i("ink")}; font-family: ${i("font-ui")}; font-size: 14px; line-height: 1.6; }
1244
1266
  .bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
1245
1267
  .bim-rh a { color: ${i("accent")}; text-decoration: none; }
@@ -1387,7 +1409,7 @@ ${Q??""}`,load:Ae,files:X,activeFile:fe??null,activeJuan:(ze==null?void 0:ze.jso
1387
1409
  flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
1388
1410
  color: ${i("ink")} !important; font-size: 13px;
1389
1411
  }
1390
- ${Lh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${i("accent")} ${t}%, ${i("card-bg")}); }`).join(`
1412
+ ${Bh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${i("accent")} ${t}%, ${i("card-bg")}); }`).join(`
1391
1413
  `)}
1392
1414
  .bim-rh-band a[data-k="4"] { color: ${i("page-bg")} !important; }
1393
1415
  .bim-rh-band a:hover { outline: 2px solid ${i("ink")}; outline-offset: -2px; }
@@ -1415,7 +1437,7 @@ ${Lh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1415
1437
  }
1416
1438
 
1417
1439
  /* ── 中屏 ── */
1418
- @media ${Eh} {
1440
+ @media ${Ph} {
1419
1441
  .bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1420
1442
  .bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
1421
1443
  }
@@ -1458,7 +1480,7 @@ ${Lh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1458
1480
  }
1459
1481
 
1460
1482
  /* 触屏或窄屏:点击目标放大到 44px */
1461
- @media ${Rh} {
1483
+ @media ${Ah} {
1462
1484
  .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; }
1463
1485
  .bim-rh-chip { display: inline-flex; }
1464
1486
  }
@@ -1469,7 +1491,7 @@ ${Lh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1469
1491
  }
1470
1492
 
1471
1493
  @media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
1472
- `,Ph=Pi["zh-Hant"].period,fa={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{...fa,...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 ba(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 ya(t){return Math.max(150,Array.from(t).length*18+44)}function ja(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 va=.04;function Fe(t){return t.toLocaleString("en-US")}function ka({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}=q(),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 wa({counts:t}){const{t:n}=q();return e.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[e.jsxs("span",{children:[e.jsx("b",{children:Fe(t.readable)}),n("readHome.readable")]}),t.pieces>0&&e.jsxs("span",{children:[e.jsx("b",{children:Fe(t.pieces)}),n("readHome.pieces")]})]})}function Sa({picks:t,links:n}){const{t:o,convert:r}=q(),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(ka,{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 $a(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}=q(),c=yt(n);if(!t.items.length)return null;const p=r===void 0?a("readHome.shelfLegendCount"):r,u=ba(t.items,a("readHome.shelfOther")),g=m=>{const h=m.records?Fe(m.records):$a(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:ya(m.title)},children:[e.jsx(ka,{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 Ah=4,sn=t=>t>Ah+1;function _a({topic:t,links:n}){const{t:o,convert:r}=q(),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:Fe(t.items.length)})})]}),e.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:t.items.map(c=>{const p=$a(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 Ca({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(_a,{topic:s,links:n},s.key))})]})}function za({famous:t,links:n}){const{t:o,convert:r}=q(),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}=q(),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:Fe(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:Fe(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:Fe(n)})}),e.jsx("span",{children:r?l(r):s("readHome.sibuUnclassifiedNote")}),e.jsx("a",{href:a.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Ta({periods:t,unknown:n,links:o}){const{t:r,convert:s,messages:l}=q(),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:Fe(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":ja(g.count,u),"data-narrow":h<va?"":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:Fe(g.count)})]})},g.key)})}),e.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&e.jsx("span",{children:r("readHome.periodUnknown",{n:Fe(n)})}),e.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function Na({authors:t,links:n}){const{t:o,convert:r}=q(),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:Fe(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 Ia={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function Bh({sections:t,links:n,head:o,piecesMoreHref:r,className:s}){const{t:l}=q(),a=t,d=Ia,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(wa,{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(Sa,{picks:a.picks,links:n})}),p.topics&&e.jsx(Je,{id:d.topics,title:g("topics"),sub:l("readHome.topicsSub"),children:e.jsx(Ca,{topics:c,links:n})}),p.famous&&e.jsx(Je,{id:d.famous,title:g("famous"),sub:l("readHome.famousSub"),children:e.jsx(za,{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(Ta,{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(Na,{authors:a.pieces.authors,links:n})})]})]})}const Mh="(max-width: 1079px)",Wh=`${mn}, (pointer: coarse)`,Ea=`
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=`
1473
1495
  /* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
1474
1496
  .bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
1475
1497
  .bim-mh-q { min-width: 0; }
@@ -1609,7 +1631,7 @@ ${Lh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1609
1631
  .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")}; }
1610
1632
 
1611
1633
  /* ── 中屏 ── */
1612
- @media ${Mh} {
1634
+ @media ${Oh} {
1613
1635
  .bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
1614
1636
  .bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
1615
1637
  .bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@@ -1636,8 +1658,8 @@ ${Lh.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
1636
1658
  .bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
1637
1659
  }
1638
1660
 
1639
- @media ${Wh} {
1661
+ @media ${Fh} {
1640
1662
  .bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
1641
1663
  .bim-mh-recent-h button { min-height: 44px; }
1642
1664
  }
1643
- `,Ra={item:t=>`/item/${encodeURIComponent(t)}`,node:t=>`/catalog?node=${encodeURIComponent(t)}`};function jt(t){return{...Ra,...t??{}}}function No(t,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(t/n*100)))}function La(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 Hh(t){return{read:t.item,work:t.item,node:t.node}}function Pa({counts:t,links:n}){const{t:o}=q(),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:Fe(d)})]})},l))})}function Aa(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 Oh(t,n,o){const r=t.type==="book"?t.edition||t.era:t.type==="collection"?"":t.dynasty;return r?o(r):Ba(t.type,n)}function Ba(t,n){return n(`metaHome.typeLabel.${t}`)}function Ma({entries:t,onClear:n,links:o}){const{t:r,convert:s}=q(),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?Ba(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:Oh(a,r,s)})]})},a.id))}),t&&t.length===0&&e.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function Wa(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 Ha({rows:t,links:n}){const{t:o,convert:r}=q(),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:Fe(l.total)}),e.jsx("td",{className:"bim-mh-r",children:Fe(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:Wa(l.status,o,r)})})]},l.id||l.name)})})]})}):null}function Oa({items:t,links:n,label:o}){const{convert:r}=q();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 Fa({works:t,links:n}){const{t:o}=q(),[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(Oa,{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 Da="siku_qige";function Fh({group:t,links:n}){const{t:o,convert:r}=q(),[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(Oa,{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 Ua({groups:t,links:n}){const{t:o,convert:r}=q(),s=jt(n);if(!t.length)return null;const l=t.find(c=>c.key===Da),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(Fh,{group:c,links:s},c.key))})]})}const Xr=34,Qr=13;function es(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 Dh(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 Va({people:t,links:n}){const{t:o,convert:r}=q(),s=jt(n);if(!t.length)return null;const{min:l,max:a,placed:d,missing:c}=La(t),p=[],u=d.map(m=>{const h=m.left>70,f=h?Math.min(m.left,m.left+m.width-Qr):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,Qr),{...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*Xr+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*Xr+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:es(m.p,o)})]})]},m.p.id))}),e.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Dh(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):"",es(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 Uh=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 Ga({works:t,links:n}){const{t:o,convert:r}=q(),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:[Uh,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 Ya({sites:t}){const{t:n,convert:o}=q(),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:[`${Fe(l.imported)} / ${Fe(l.total)} ${a}% `,l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:Wa(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 ts=["extant","partially_extant","lost","unknown"];function Ka({stats:t,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:l}=q(),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=ts.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:Fe(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:ts.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:Fe(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 qa={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Vh({sections:t,links:n,head:o,transport:r,catalogHref:s,collectionsHref:l,entitiesHref:a,version:d,repoUrl:c,downloadHref:p,className:u}){var z,_,E;const{t:g}=q(),m=t,h=jt(n),f=Hh(h),v=qa,y=Aa(r),k={zhi:!!((z=m.shelf)!=null&&z.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(T=>k[T]),j=T=>g(`metaHome.nav.${T}`),w=(T,C)=>T?e.jsx("a",{className:"bim-rh-more",href:T,children:C}):void 0,S=(_=m.sites.find(T=>T.total>0))==null?void 0:_.total,$=S!=null&&m.sites.every(T=>T.total===0||T.total===S);return e.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[e.jsx("style",{children:_o+Ea}),e.jsxs("div",{className:"bim-mh-head",children:[e.jsxs("div",{className:"bim-mh-q",children:[o,e.jsx(Pa,{counts:m.counts,links:n})]}),r&&e.jsx(Ma,{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(T=>e.jsx("li",{children:e.jsx("a",{href:`#${v[T]}`,children:j(T)})},T))})}),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(T=>T.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:(E=m.shelf)!=null&&E.items.length?void 0:{marginTop:0},children:[e.jsx(Ha,{rows:m.catalog_progress,links:n}),e.jsx(Fa,{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:Fe(m.counts.collections)})),children:e.jsx(Ua,{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:Fe(m.counts.entities)})),children:e.jsx(Va,{people:m.bibliographers,links:n})}),k.lineage&&e.jsx(Je,{id:v.lineage,title:j("lineage"),sub:g("metaHome.lineageSub"),children:e.jsx(Ga,{works:m.lineage,links:n})}),k.sites&&e.jsx(Je,{id:v.sites,title:j("sites"),sub:$?g("metaHome.sitesSubDen",{n:Fe(S)}):g("metaHome.sitesSub"),children:e.jsx(Ya,{sites:m.sites})}),e.jsx(Je,{id:v.data,title:j("data"),sub:g("metaHome.dataSub"),children:e.jsx(Ka,{stats:m.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const Ei=({style:t})=>{const n=x.useContext(Tt),{t:o}=q();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}=q(),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 Gh(t,n){if(!n)return!1;const o=n.id;return o===void 0||o===t}const Yh=({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:z=!0,feedbackApiUrl:_,height:E,footerExtra:T,hideHeaderControls:C=!1,className:H,style:M})=>{const A=ke(),{t:K,convert:Y}=q(),[ee]=x.useState(()=>{if(!Gh(t,o))return null;const W={...o},xe=r??ui(t,W);return b&&b(xe,W),{id:t,entry:xe,detail:W}}),[ue,B]=x.useState((ee==null?void 0:ee.entry)??null),[R,Q]=x.useState((ee==null?void 0:ee.detail)??null),[P,V]=x.useState(!ee),[pe,ye]=x.useState(!1),[Z,de]=x.useState([]),[he,Me]=x.useState(!1),[fe,$e]=x.useState(null),[We,Be]=x.useState(null),[Re,ze]=x.useState(null),[Ee,U]=x.useState(!1),ae=x.useRef(null),[se,Se]=x.useState(null),F=a!==void 0?a:se,me=x.useCallback(W=>{d?d(W):Se(W)},[d]),Ae=x.useCallback(async W=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){de([]);return}Me(!0);try{if(n.getCollectionCatalogs)de(await n.getCollectionCatalogs(W)||[]);else if(n.getCollectionCatalog){const xe=await n.getCollectionCatalog(W);de(xe?[{resource_id:"",data:xe}]:[])}}catch{de([])}finally{Me(!1)}},[n]),L=x.useCallback(async W=>{var xe,O;if(!n.getTextManifest||!n.getTextIndex){$e(null),Be(W);return}try{const we=ve.pickTextVersion(await n.getTextManifest(W)),be=we?await n.getTextIndex(W,we.key):null;$e(be&&be.chapters.length>0?{chapters:be.chapters.map(ie=>({n:ie.n,title:ie.title,file:ie.file})),source:{name:((xe=be.source)==null?void 0:xe.name)??(we==null?void 0:we.source_name),license:((O=be.source)==null?void 0:O.license)??(we==null?void 0:we.license)??void 0}}:null)}catch{$e(null)}finally{Be(W)}},[n]),X=x.useCallback(async(W,xe)=>{U(!0);try{if(n.getLineageGraph){const De=await n.getLineageGraph(W);De&&ze(De)}const O=xe.version_graph;if(!O||!O.enabled){Re||ze(null),ae.current=null;return}const we=xe.books??[],be=[];for(const De of we)try{const Ie=await n.getItem(De);Ie&&be.push(Ie)}catch{}ae.current={work:xe,books:be};const ie=u??O.default_collection??(O.core_books&&O.core_books.length>0?"core":"all"),Oe=ie==="core"&&Array.isArray(O.core_books)&&O.core_books.length>0?"core":ie??"all";ze(kn(xe,be,Oe))}catch{ze(null),ae.current=null}finally{U(!1)}},[n]),ge=x.useRef({initialDetail:o,initialEntry:r});ge.current={initialDetail:o,initialEntry:r},x.useEffect(()=>{let W=!1;const xe=ie=>{ie.type==="collection"?Ae(t):ie.type==="work"?(ie.version_graph||n.getLineageGraph)&&X(t,ie):ie.type==="book"&&pi(ie)&&L(t)},O=ge.current;let we=null;if(ee&&ee.id===t)we=ee;else if(O.initialDetail&&O.initialDetail.id===t){const ie={...O.initialDetail},Oe=O.initialEntry??ui(t,ie);b&&b(Oe,ie),we={entry:Oe,detail:ie}}return we?(ye(!1),de(ie=>ie.length?[]:ie),$e(null),ze(null),ae.current=null,B(we.entry),Q(we.detail),V(!1),xe(we.detail),()=>{W=!0}):((async()=>{V(!0),ye(!1),B(null),Q(null),de([]),$e(null),ze(null),ae.current=null;try{const ie=await n.getItem(t);if(W)return;if(!ie){ye(!0);return}const Oe=ie;let De=null;if(n.getEntry&&(De=await n.getEntry(t),W))return;De||(De=ui(t,Oe)),b&&b(De,Oe),B(De),Q(Oe),xe(Oe)}catch{W||ye(!0)}finally{W||V(!1)}})(),()=>{W=!0})},[t,n,ee,b,Ae,X,L]),x.useEffect(()=>{const W=ae.current;!W||!u||ze(kn(W.work,W.books,u))},[u]);const I=[];if(R){if(I.push({key:"basic",label:A.detailTab.basicInfo}),R.type==="collection"){he&&Z.length===0&&I.push({key:"catalog:loading",label:`${A.detailTab.catalog}…`});for(const W of Z)I.push({key:`catalog:${W.resource_id}`,label:W.short_name?`${Y(W.short_name)}${A.detailTab.catalogSuffix}`:A.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&I.push({key:s,label:A.detailTab.fullText}),R.type==="work"&&(Re||Ee)&&I.push({key:"lineage",label:Ee?`${A.detailTab.lineage}…`:A.detailTab.lineage});for(const W of $)(W.position??"before-feedback")==="before-feedback"&&W.shouldShow(R)&&I.push({key:W.key,label:W.label});z&&s==="feedback"&&I.push({key:"feedback",label:A.detailTab.feedback});for(const W of $)W.position==="after-feedback"&&W.shouldShow(R)&&I.push({key:W.key,label:W.label})}x.useEffect(()=>{if(s!=="emendated"||!R)return;l("basic");const W=setTimeout(()=>{var xe;(xe=document.getElementById("studies"))==null||xe.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(W)},[s,R,l]);const te=ue&&R&&j?j({activeTab:s,activeJuan:F,entry:ue,detail:R}):null,J=x.useMemo(()=>{var be;if(!R)return null;const xe=(R.authors??[]).map(ie=>{const Oe=Qi(ie.role);return`${ie.dynasty?`〔${Y(ie.dynasty)}〕`:""}${Y(ie.name)}${Oe?` ${Y(Oe)}`:""}`}).join(" · ");let O=!1;try{O=ve.extractStatus(R.id)==="draft"}catch{}if(R.type==="book"){const ie=R;return{title:Y(ie.title),subtitle:ie.edition?Y(ie.edition):xe||void 0,aside:[O?A.status.draft:"",xe&&ie.edition?xe:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(R.type==="collection"){const ie=R;return{title:Y(ie.title),subtitle:Y(xt(ie,A.unit.juan))||void 0,aside:[(be=ie.publication_info)==null?void 0:be.year,O?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:xe||void 0}}if(R.type==="entity"){const ie=R,Oe=Ie=>Ie==null?"":Ie<0?K("detail.bce",{n:-Ie}):String(Ie),De=ie.birth_year!=null||ie.death_year!=null?`${Oe(ie.birth_year)||"?"}—${Oe(ie.death_year)||"?"}`:"";return{title:Y(ie.primary_name||ie.title),subtitle:[ie.dynasty?`〔${Y(ie.dynasty)}〕`:"",De].filter(Boolean).join(" ")||void 0,aside:O?A.status.draft:void 0,secondLine:void 0}}const we=Y(xt(R,A.unit.juan));return{title:Y(R.title),subtitle:[we,xe].filter(Boolean).join(" · ")||void 0,aside:[qh(A,R.subtype),O?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[R,Y,A,K]),oe=R&&pi(R)?"text":null,_e=()=>{me(null),l("fulltext")};let Le=null;if(R&&w){const W=w({detail:R,kind:oe});W&&(Le=e.jsx(wi,{href:W}))}else oe&&(Le=e.jsx(wi,{onClick:_e}));const D=W=>{if(!R)return null;const xe=W.replace(/\.[^.]+$/,"");if(w){const O=w({detail:R,kind:oe,juan:xe});return O?{href:O}:null}return{onClick:()=>{me(xe),l("fulltext")}}},Te=new Set($.map(W=>W.key)),Ce=I.filter(W=>W.key.startsWith("catalog:")&&W.key!=="catalog:loading"||Te.has(W.key)).map(W=>({key:W.key,label:W.label,onClick:()=>l(W.key)})),je=()=>{var W;return R?R.type==="work"?e.jsx(ta,{data:R,transport:n,onNavigate:f,renderLink:k,readAction:Le,railTop:S,railLinks:Ce}):R.type==="book"?e.jsx(ra,{data:R,transport:n,onNavigate:f,renderLink:k,readAction:Le,fullText:fe,fullTextPending:pi(R)&&!!n.getTextManifest&&We!==R.id,chapterLink:D,railTop:S,railLinks:Ce}):R.type==="collection"?e.jsx(sa,{data:R,catalog:(W=Z[0])==null?void 0:W.data,transport:n,onNavigate:f,renderLink:k,readAction:Le,railTop:S,railLinks:Ce,catalogAction:Z.length>0?e.jsxs("a",{href:"#catalog",onClick:xe=>{xe.preventDefault(),l(`catalog:${Z[0].resource_id}`)},children:[Y(A.detailTab.collectionCatalog)," →"]}):null}):e.jsx(la,{data:R,transport:n,onNavigate:f,renderLink:k,railTop:S,railLinks:Ce}):null},He=()=>{var xe,O,we;if(!ue||!R)return null;if(s==="basic"||s==="emendated")return je();if(typeof s=="string"&&s.startsWith("catalog:")){const be=(xe=Z.find(ie=>`catalog:${ie.resource_id}`===s))==null?void 0:xe.data;return e.jsx(Vi,{data:be,onNavigate:f,renderLink:k})}if(s==="collated"||s==="fulltext")return e.jsx(fo,{id:t,transport:n,chapter:F,onLocationChange:be=>me(be.chapter),onNavigate:f});if(s==="lineage"){if(!Re)return e.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:K(Ee?"detail.loading":"detail.noLineageGraph")});const be=R.type==="work"?R: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=be==null?void 0:be.version_graph)==null?void 0:O.default_collection),onCollectionChange:g,collectionsAvailable:(we=be==null?void 0:be.version_graph)==null?void 0:we.collections,collectionCounts:(()=>{var Ie,Qe,G,Pe,it,vt,Ut;if(!be)return;const ie={},Oe=((Ie=ae.current)==null?void 0:Ie.books)??[];ie.all=(((Qe=be.books)==null?void 0:Qe.length)??0)-(((Pe=(G=be.version_graph)==null?void 0:G.excluded_books)==null?void 0:Pe.length)??0);const De=(it=be.version_graph)==null?void 0:it.collections;if(De)for(const gn of Object.keys(De))ie[gn]=kn(be,Oe,gn).nodes.filter(Eo=>Eo.kind==="book"&&!Eo.bridge).length;return ie.core==null&&((Ut=(vt=be.version_graph)==null?void 0:vt.core_books)!=null&&Ut.length)&&(ie.core=be.version_graph.core_books.length),ie})()})}if(s==="feedback"&&z)return e.jsx(Jl,{resourceId:t,apiUrl:_});const W=$.find(be=>be.key===s);return W?W.render({detail:R,entry:ue,transport:n,onNavigate:f}):null};if(P)return e.jsx(en,{style:{minHeight:E,...M},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((W,xe)=>e.jsx("div",{style:{height:xe===1?40:16,width:W,opacity:.35,background:i("rule")}},xe))})});if(pe||!R||!ue||!J)return e.jsx(en,{style:{minHeight:E,...M},children:e.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:K("detail.notFound")})});const N=s==="basic"||s==="emendated",ne=[{label:y??A.detailTab.backToIndex,onClick:v}];if(R.type==="book"&&R.work_id){const W=R.work_id;ne.push({label:A.indexType.work,id:W,onClick:()=>f==null?void 0:f(W)})}ne.push({label:A.indexType[R.type]});const ce=s==="collated"||s==="fulltext",le=typeof T=="string"?A.status[T.trim()]??T:T,re=e.jsx(wl,{left:e.jsxs(e.Fragment,{children:[le,le?" · ":"",e.jsx(Kh,{id:R.id,label:A.label.id,copied:A.action.copied,copyLabel:A.action.copy})]}),right:e.jsxs(e.Fragment,{children:[z&&!N&&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}),te&&e.jsx("a",{href:te.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:A.detailTab.dataLicense})]})});return N?e.jsx("div",{className:H,children:e.jsxs(en,{grid:!0,style:{minHeight:E,...M},children:[e.jsx(Si,{breadcrumb:e.jsx($i,{items:ne}),actions:e.jsxs(e.Fragment,{children:[!C&&e.jsx(Ei,{style:{border:"none",background:"transparent"}}),!C&&te&&e.jsx(Ri,{...te})]})}),je(),re]})}):e.jsx("div",{className:H,children:e.jsxs(en,{wide:ce,style:{minHeight:E,...M},children:[e.jsx(Si,{breadcrumb:e.jsxs(e.Fragment,{children:[e.jsx(io,{char:"籍"}),e.jsx($i,{items:ne})]}),actions:e.jsxs(e.Fragment,{children:[!C&&e.jsx(Ei,{}),z&&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}),!C&&te&&e.jsx(Ri,{...te})]})}),e.jsx(gl,{...J,aside:ce?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:[K("detail.workInfo")," →"]}):J.aside}),!ce&&I.length>1&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:I.map(W=>e.jsx(hl,{label:W.label,active:W.key===s||N&&W.key==="basic",onClick:()=>l(W.key)},W.key))}),e.jsx("div",{style:{marginTop:!ce&&I.length>1?8:0},children:He()}),re]})})};function Kh({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 qh(t,n){return n?t.workSubtype[n]??n:""}const Za=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Gn="zhusha",Yn="bim-theme";function Ja(t){return t==="zhusha"||t==="indigo"||t==="ink"}function Kn(t){return Ja(t)?t:Gn}function Zh(){try{return Kn(window.localStorage.getItem(Yn))}catch{return Gn}}function Xa(t){try{window.localStorage.setItem(Yn,t)}catch{}}function Qa(t){const n=Kn(t);return document.documentElement.setAttribute("data-theme",n),n}function ec(){return Kn(document.documentElement.getAttribute("data-theme"))}const Jh=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Io="airy",qn="bim-layout";function tc(t){return t==="airy"||t==="boxed"}function Zn(t){return tc(t)?t:Io}function Xh(){try{return Zn(window.localStorage.getItem(qn))}catch{return Io}}function Qh(t){try{window.localStorage.setItem(qn,t)}catch{}}function ex(t){const n=Zn(t);return document.documentElement.setAttribute("data-layout",n),n}function tx(){return Zn(document.documentElement.getAttribute("data-layout"))}const nx=`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){}`,ix={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},ox=({onChange:t,style:n})=>{const{t:o}=q(),[r,s]=x.useState(Gn);x.useEffect(()=>{s(ec())},[]);const l=a=>{s(Qa(a)),Xa(a),t==null||t(a)};return e.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Za.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(ix[a.name]),boxShadow:d?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},a.name)})})};exports.BidLink=ve.BidLink;exports.BookIndexError=ve.BookIndexError;exports.BookIndexManager=ve.BookIndexManager;exports.BookIndexStorage=ve.BookIndexStorage;exports.BundleStorage=ve.BundleStorage;exports.ConfigError=ve.ConfigError;exports.GithubStorage=ve.GithubStorage;exports.IdGenerationError=ve.IdGenerationError;exports.IdGenerator=ve.IdGenerator;exports.LocalStorage=ve.LocalStorage;exports.MigrationError=ve.MigrationError;exports.StorageError=ve.StorageError;exports.base36Decode=ve.base36Decode;exports.base36Encode=ve.base36Encode;exports.base58Decode=ve.base58Decode;exports.buildId=ve.buildId;exports.buildPromotionMap=ve.buildPromotionMap;exports.cleanName=ve.cleanName;exports.decodeId=ve.decodeId;exports.decodeIdString=ve.decodeIdString;exports.encodeId=ve.encodeId;exports.extractIdFromUrl=ve.extractIdFromUrl;exports.extractStatus=ve.extractStatus;exports.extractType=ve.extractType;exports.isChapterSegment=ve.isChapterSegment;exports.isTextKey=ve.isTextKey;exports.matchChapterAcrossVersions=ve.matchChapterAcrossVersions;exports.normalizeCatalog=ve.normalizeCatalog;exports.parseId=ve.parseId;exports.pickTextVersion=ve.pickTextVersion;exports.shardOf=ve.shardOf;exports.smartDecode=ve.smartDecode;exports.textVersionLabel=ve.textVersionLabel;exports.validateResource=ve.validateResource;exports.Badge=zn;exports.BidUrlProvider=uc;exports.BookDetailLayout=Yh;exports.BookPage=ra;exports.Breadcrumb=$i;exports.CATALOG_ALL_ID=mt;exports.CATALOG_CSS=aa;exports.CATALOG_NARROW_QUERY=wo;exports.CATALOG_PAGE_SIZE=So;exports.CATALOG_UNCLASSIFIED_ID=$t;exports.CLASSIFICATIONS=Pn;exports.COMMON_TRADITIONAL_CHARS=cs;exports.CardFoot=dn;exports.CatalogPage=Ih;exports.CatalogPager=ha;exports.CatalogTree=da;exports.CheckFilter=pl;exports.Chip=xl;exports.ChipWall=Jp;exports.CollectionCatalog=Vi;exports.CollectionPage=sa;exports.CreateEntityDialog=Dl;exports.DEFAULT_LAYOUT=Io;exports.DEFAULT_META_HOME_LINKS=Ra;exports.DEFAULT_READER_PREFS=Ki;exports.DEFAULT_READ_HOME_LINKS=fa;exports.DEFAULT_THEME=Gn;exports.DETAIL_CSS=ml;exports.DYNASTY_GROUPS=Ln;exports.Dash=iu;exports.DataTable=Qp;exports.DetailFooter=wl;exports.DetailGrid=an;exports.DetailHeader=gl;exports.EMPTY_FILTERS=Rn;exports.EmendatedBySection=Es;exports.EmptyNote=du;exports.EntityDetail=_s;exports.EntityPage=la;exports.EntityPickerDialog=Vl;exports.EntitySelector=Fl;exports.ExpandRow=ou;exports.ExtLink=pu;exports.FEEDBACK_FAB_OFFSET_VAR=Ti;exports.FILTER_SUPPORT=fs;exports.FONT_SIZE_STEPS=ut;exports.FactList=Yp;exports.FeedbackButton=yg;exports.FeedbackDialog=ql;exports.FeedbackForm=Zl;exports.FeedbackList=bo;exports.FeedbackTab=Jl;exports.FilterChip=hl;exports.FormInput=et;exports.FormTextArea=Ct;exports.GUJI_MARKDOWN_FIELD=tp;exports.GUJI_TABLE_NOTATION=Ms;exports.GlyphBadge=io;exports.GujiTable=ro;exports.HomePage=Ci;exports.ImagePanel=fi;exports.IndexApp=wm;exports.IndexBrowser=hi;exports.IndexDetail=Ui;exports.IndexEditor=Gl;exports.IndexView=rg;exports.IntroGrid=Gp;exports.LAYOUTS=Jh;exports.LAYOUT_STORAGE_KEY=qn;exports.LOSS_OPTIONS=xs;exports.LocaleContext=Tt;exports.LocaleProvider=Wc;exports.LocaleToggle=Ei;exports.META_HOME_CSS=Ea;exports.META_HOME_SECTION_IDS=qa;exports.MetaCatalogTable=Ha;exports.MetaCollectionGroups=Ua;exports.MetaDataLicense=Ka;exports.MetaHomeView=Vh;exports.MetaLine=Ye;exports.MetaLineageCards=Ga;exports.MetaOnlineSites=Ya;exports.MetaPeopleTimeline=Va;exports.MetaRecentPanel=Ma;exports.MetaRelatedCatalogs=Fa;exports.MetaTypeChips=Pa;exports.ModeIndicator=ms;exports.MoreButton=Zp;exports.MoreLink=to;exports.PAGE_MAX_WIDTH=jn;exports.PERIOD_NARROW_SHARE=va;exports.PageFrame=en;exports.Quote=su;exports.READER_CSS=Gs;exports.READ_HOME_CSS=_o;exports.READ_HOME_NARROW_QUERY=mn;exports.READ_HOME_SECTION_IDS=Ia;exports.READ_PERIOD_LABELS=Ph;exports.RECENT_IDS_STORAGE_KEY=Pt;exports.ROLE_CLASS_ORDER=rl;exports.ReadButton=wi;exports.ReadFamousWorks=za;exports.ReadHomeView=Bh;exports.ReadPeriodBand=Ta;exports.ReadPicks=Sa;exports.ReadPieces=Na;exports.ReadSection=Je;exports.ReadShelf=zo;exports.ReadSibu=To;exports.ReadStats=wa;exports.ReadTopicGroup=_a;exports.ReadTopics=Ca;exports.ReaderMdText=co;exports.ReaderShell=Qs;exports.ReaderToc=Ks;exports.RelationPanel=Hl;exports.RepoSourceLink=Ri;exports.ResourceEditor=mi;exports.ResourceGroup=lu;exports.ResourceLine=au;exports.ResourceList=Hi;exports.ResourceRow=vl;exports.SEARCH_VIEW_STORAGE_KEY=Oi;exports.SEVEN_PAVILIONS_KEY=Da;exports.SNIPPET_MARK_END=os;exports.SNIPPET_MARK_START=is;exports.SORTABLE_TYPES=hs;exports.SearchInput=gs;exports.SearchResults=ws;exports.Sec=Ke;exports.Section=st;exports.SectionHead=Kp;exports.SideList=_t;exports.SmartBidInput=vn;exports.SourceEditor=Bl;exports.SummaryCard=cn;exports.THEMES=Za;exports.THEME_INIT_SCRIPT=nx;exports.THEME_STORAGE_KEY=Yn;exports.TRADITIONAL_ALLOWLIST=ds;exports.TabFilter=On;exports.TableHead=eu;exports.TableRow=tu;exports.TagRow=kl;exports.TagRows=cu;exports.TextButton=qp;exports.TextReader=fo;exports.ThemeToggle=ox;exports.TopStrip=Si;exports.VersionLineageGraph=oa;exports.VersionLineageList=ia;exports.VersionLineageView=ko;exports.VolumeChips=Xp;exports.VolumeLinks=oo;exports.WorkCard=ma;exports.WorkCardGrid=xa;exports.WorkCatalog=Sm;exports.WorkPage=ta;exports.WorkRow=ga;exports.applyLayout=ex;exports.applyTheme=Qa;exports.authorsLine=Vn;exports.bucketResources=Ji;exports.buildCatalogTree=kh;exports.buildCollectionTable=ll;exports.buildLineageGraph=kn;exports.buildMeiliFilter=id;exports.buildPageUrl=Wi;exports.buildParagraphBlocks=zl;exports.buildVersionRow=il;exports.buildVersionTable=ol;exports.canParagraphize=_n;exports.catalogNodeIdOf=jh;exports.catalogNodeIdsOf=vh;exports.catalogPageCount=_h;exports.catalogTotal=$o;exports.classificationPath=un;exports.clearAllRecentIds=Fi;exports.compareCatalogCards=$h;exports.computeVersionPartition=Pp;exports.countActiveFilters=An;exports.createTextApi=Fs;exports.currentLayout=tx;exports.currentTheme=ec;exports.defaultWorkLink=pa;exports.deriveDating=Ep;exports.deriveEditionType=cl;exports.deriveEra=ln;exports.deriveYear=Mn;exports.deriveYearRange=Zi;exports.detailToEditor=Kl;exports.detectGenre=Dn;exports.displayAuthorRole=Qi;exports.editorToDetail=og;exports.eraRank=vi;exports.filtersFromParams=od;exports.filtersToParams=wn;exports.findCatalogPath=Lt;exports.findTraditionalChars=Fc;exports.firstAuthorText=Co;exports.flattenTitles=_i;exports.flattenToc=Xs;exports.fmtCount=Fe;exports.formatTemplate=tt;exports.formatVolumeRange=Hn;exports.getDisplayNameFromUrl=Ot;exports.getMessages=Wt;exports.getStartPage=Mi;exports.getT=Ht;exports.getTypeGroupKey=Ai;exports.groupRelatedWorks=Rp;exports.gujiInlineToPlain=Bs;exports.hasActiveFilters=bs;exports.hasGujiMarkdownV02=xi;exports.hasGujiTableNotation=Ws;exports.hasSearchOptions=ed;exports.isLayoutName=tc;exports.isThemeName=Ja;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=us;exports.numberToChinese=al;exports.paginationItems=ca;exports.parseChineseNumber=Sn;exports.parseGujiInline=As;exports.parseGujiTable=Os;exports.parseSourceString=Ml;exports.pct=No;exports.periodLevel=ja;exports.pickReaderVersion=Js;exports.readStoredLayout=Xh;exports.readStoredTheme=Zh;exports.readerVersionOptionLabel=yi;exports.removeRecentId=Ss;exports.renderFullTextBody=fu;exports.renderProperNames=Nl;exports.renderReaderInline=ao;exports.resolveRecentEntry=Di;exports.resourceHref=Ft;exports.resourceNote=Wn;exports.roleFacets=sl;exports.rowNo=nu;exports.sameFilters=rd;exports.saveRecentId=gi;exports.shelfColumns=ba;exports.sortFor=td;exports.sortYear=$n;exports.spineHeight=ya;exports.splitFullTextTables=Gi;exports.splitHighlightSnippet=Li;exports.splitTableRow=Hs;exports.storeLayout=Qh;exports.storeTheme=Xa;exports.stringifySources=Wl;exports.timelineLayout=La;exports.toCatalogWorkCard=Sh;exports.typeSupportsFilters=ys;exports.useBidUrl=Ve;exports.useConvert=Ne;exports.useI18n=q;exports.useReaderPrefs=Zs;exports.useRecentEntries=Aa;exports.useT=ke;exports.validateLineageGraph=Fg;exports.volumeStats=In;exports.withDefaultLinks=yt;exports.withMetaLinks=jt;exports.yearText=Tn;
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,je]=x.useState(!1),[Z,ce]=x.useState([]),[fe,We]=x.useState(!1),[be,_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=ve.pickTextVersion(await n.getTextManifest(M)),ye=we?await n.getTextIndex(M,we.key):null;_e(ye&&ye.chapters.length>0?{chapters:ye.chapters.map(oe=>({n:oe.n,title:oe.title,file:oe.file})),source:{name:((ge=ye.source)==null?void 0:ge.name)??(we==null?void 0:we.source_name),license:((O=ye.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??[],ye=[];for(const Fe of we)try{const Ne=await n.getItem(Fe);Ne&&ye.push(Ne)}catch{}ae.current={work:ge,books:ye};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,ye,Oe))}catch{ze(null),ae.current=null}finally{D(!1)}},[n]),he=x.useRef({initialDetail:o,initialEntry:r});he.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=he.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?(je(!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),je(!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){je(!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||je(!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"){fe&&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 ye;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=ve.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:[(ye=oe.publication_info)==null?void 0:ye.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)})),xe=()=>{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:be,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 xe();if(typeof s=="string"&&s.startsWith("catalog:")){const ye=(ge=Z.find(oe=>`catalog:${oe.resource_id}`===s))==null?void 0:ge.data;return e.jsx(Vi,{data:ye,onNavigate:f,renderLink:k})}if(s==="collated"||s==="fulltext")return e.jsx(fo,{id:t,transport:n,chapter:F,onLocationChange:ye=>me(ye.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 ye=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=ye==null?void 0:ye.version_graph)==null?void 0:O.default_collection),onCollectionChange:g,collectionsAvailable:(we=ye==null?void 0:ye.version_graph)==null?void 0:we.collections,collectionCounts:(()=>{var Ne,Qe,V,Pe,it,vt,Ut;if(!ye)return;const oe={},Oe=((Ne=ae.current)==null?void 0:Ne.books)??[];oe.all=(((Qe=ye.books)==null?void 0:Qe.length)??0)-(((Pe=(V=ye.version_graph)==null?void 0:V.excluded_books)==null?void 0:Pe.length)??0);const Fe=(it=ye.version_graph)==null?void 0:it.collections;if(Fe)for(const gn of Object.keys(Fe))oe[gn]=kn(ye,Oe,gn).nodes.filter(Eo=>Eo.kind==="book"&&!Eo.bridge).length;return oe.core==null&&((Ut=(vt=ye.version_graph)==null?void 0:vt.core_books)!=null&&Ut.length)&&(oe.core=ye.version_graph.core_books.length),oe})()})}if(s==="feedback"&&_)return e.jsx(Ql,{resourceId:t,apiUrl:C});const M=$.find(ye=>ye.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})]})}),xe(),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=ve.BidLink;exports.BookIndexError=ve.BookIndexError;exports.BookIndexManager=ve.BookIndexManager;exports.BookIndexStorage=ve.BookIndexStorage;exports.BundleStorage=ve.BundleStorage;exports.ConfigError=ve.ConfigError;exports.GithubStorage=ve.GithubStorage;exports.IdGenerationError=ve.IdGenerationError;exports.IdGenerator=ve.IdGenerator;exports.LocalStorage=ve.LocalStorage;exports.MigrationError=ve.MigrationError;exports.StorageError=ve.StorageError;exports.base36Decode=ve.base36Decode;exports.base36Encode=ve.base36Encode;exports.base58Decode=ve.base58Decode;exports.buildId=ve.buildId;exports.buildPromotionMap=ve.buildPromotionMap;exports.cleanName=ve.cleanName;exports.decodeId=ve.decodeId;exports.decodeIdString=ve.decodeIdString;exports.encodeId=ve.encodeId;exports.extractIdFromUrl=ve.extractIdFromUrl;exports.extractStatus=ve.extractStatus;exports.extractType=ve.extractType;exports.isChapterSegment=ve.isChapterSegment;exports.isTextKey=ve.isTextKey;exports.matchChapterAcrossVersions=ve.matchChapterAcrossVersions;exports.normalizeCatalog=ve.normalizeCatalog;exports.parseId=ve.parseId;exports.pickTextVersion=ve.pickTextVersion;exports.shardOf=ve.shardOf;exports.smartDecode=ve.smartDecode;exports.textVersionLabel=ve.textVersionLabel;exports.validateResource=ve.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;