book-index-ui 0.47.1 → 0.47.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +68 -68
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2530 -2530
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Xd=Object.create;var Xr=Object.defineProperty;var Zd=Object.getOwnPropertyDescriptor;var Jd=Object.getOwnPropertyNames;var Qd=Object.getPrototypeOf,ep=Object.prototype.hasOwnProperty;var tp=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Jd(n))!ep.call(e,s)&&s!==o&&Xr(e,s,{get:()=>n[s],enumerable:!(r=Zd(n,s))||r.enumerable});return e};var Zn=(e,n,o)=>(o=e!=null?Xd(Qd(e)):{},tp(n||!e||!e.__esModule?Xr(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _e=require("./storage-entry-BDcJjAiW.cjs"),t=require("react/jsx-runtime"),g=require("react"),np=require("opencc-js/t2cn"),ip=require("react-markdown"),op=require("remark-gfm"),rp=e=>`/book-index?id=${e}`,_a=g.createContext(rp);function sp({buildUrl:e,children:n}){const o=g.useMemo(()=>e,[e]);return t.jsx(_a.Provider,{value:o,children:n})}function Ze(){return g.useContext(_a)}const $a="",Ca="";function Lo(e){const n=[];let o=!1,r=e;for(;r.length;){const s=o?Ca:$a,a=r.indexOf(s);if(a===-1){n.push({text:r,marked:o});break}a>0&&n.push({text:r.slice(0,a),marked:o}),r=r.slice(a+1),o=!o}return n}function rt(e,n){return{title:e,tokens:n}}const Zr='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',ap=[rt("基础(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"}}),rt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),rt("提示与警告",{"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)"}}),rt("遮罩与阴影",{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)"}}),rt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),rt("资源",{"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"}}),rt("整理本(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"}}),rt("版本传承(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"}}),rt("编辑器视图(主要在 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")'}}),rt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#3b4a58",note:"主题切换控件的色点:墨"},"sect-jing":{value:"#2e5266",note:"四部分布条:經部(人物页提要卡;无别处使用)"},"sect-shi":{value:"#9a7a3b",note:"四部分布条:史部"},"sect-zi":{value:"#4f7a5c",note:"四部分布条:子部"},"sect-ji":{value:"#9fb3bc",note:"四部分布条:集部"},"table-border":{value:"color-mix(in srgb, currentColor 28%, transparent)",root:!1,note:"古籍表格(跟随当前文字色)"},"table-head-bg":{value:"color-mix(in srgb, currentColor 8%, transparent)",root:!1}}),rt('版式(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"}}),rt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),rt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),rt("字体(全站无衬线,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:Zr,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Zr,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],lp=Object.assign({},...ap.map(e=>e.tokens)),za={};for(const[e,n]of Object.entries(lp))za[e]=`var(--bim-${e}, ${n.value})`;function i(e){const n=za[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function qt(e){return e.types&&e.types.length>0?e.types:e.type?e.type==="text+image"?["text","image"]:[e.type]:[]}function cp(e,n){return qt(e).includes(n)}const dp={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Xt=g.createContext(null),Ta=["曹霑"];function pp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function up(e,n=Ta){const o=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!o.length)return e;const r=new RegExp(`(${o.map(pp).join("|")})`,"g"),s=new Set(o);return a=>{if(!a)return e(a);const l=a.split(r);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let vn=null;function mp(){if(vn)return vn;try{const e=np.Converter({from:"t",to:"cn"});vn=up(n=>e(_e.normalizeVariants(n)))}catch{vn=e=>e}return vn}const hp={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:"圖片資源"}},gp={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 at(e,n,o){return{"zh-Hant":e,"zh-Hans":n}}const fp=at({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:"无数据"}),gi=at({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:"作品信息"}),xp=at({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:"附记"}}),bp=at({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}"}}),yp=at({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:"上级丛编"}),jp=at({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 为自动匹配,未经人工核对"}),vp=at({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:"参考文献"}),kp=at({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:"本卷条目"}),wp=at({typeShort:{work:"作",book:"版",collection:"叢",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"叢編",entity:"人物"},typeAll:"全部",typeChipsLabel:"按類型檢索",recentTitle:"最近瀏覽",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"還沒有瀏覽記錄。打開任一條目後會出現在這裏。",status:{done:"已完成",in_progress:"進行中",todo:"計劃中"},siteStatus:{done:"已對接",in_progress:"進行中"},catalogTitle:"書目著錄進度",catalogNote:"每條著錄對到作品條目",colCatalog:"書目",colRecords:"著錄條目",colMatched:"已對上作品",colProgress:"進度",colStatus:"狀態",relatedTitle:"同類書目與考證",relatedNote:"不在書架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 種",allNKinds:"全部 {n} 種",pavilion:"閣",yearBC:"前{n}",missingLife:"生卒年未錄、未上軸:{names}",viewLineage:"看版本譜系 →",plannedSites:"計劃接入:{names}",loss:{extant:"存",partially_extant:"殘",lost:"佚",unknown:"未詳"},lossNote:{extant:"今有傳本",partially_extant:"部分存世",lost:"僅見著錄",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"叢編",entities:"人物",has_image:"有影印",has_text:"有文本",article:"單篇文",poem:"單篇詩"},dataScale:"數據規模",byLoss:"按存佚檢索",license:"古籍元數據以 CC0 公有領域發布,可自由複製、改編、再發布。",repo:"數據倉庫:",repoNote:"(GitHub,CC0)",version:"當前數據版本:",download:"引用方式與數據下載 →",navLabel:"元數據首頁分區",nav:{zhi:"歷代史志",sibu:"四部",cong:"叢編",people:"人物",lineage:"版本譜系",sites:"在線資源",data:"數據與授權"},zhiSub:"正史藝文志、經籍志與後人補志,按所志朝代排列;每部志的著錄逐條對到作品",shelfLegendCount:"脊下數字=著錄條目",shelfLegendClick:"點書脊進作品頁",sibuSub:"全部作品按經史子集分類;與「目錄」頁同一棵分類樹",toCatalog:"進入目錄 →",unclassifiedNote:"多為只見於史志著錄、尚未歸類的書",congSub:"大型叢書、影印彙編、出土文獻與館藏,逐種列到版本",allNKindsMore:"全部 {n} 種 →",peopleSub:"歷代目錄學家,按生卒年排在一條時間軸上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流與異同",sitesSub:"外部數字圖書館與本站條目的對接",dataSub:"規模、存佚、許可與版本"},{typeShort:{work:"作",book:"版",collection:"丛",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"丛编",entity:"人物"},typeAll:"全部",typeChipsLabel:"按类型检索",recentTitle:"最近浏览",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"还没有浏览记录。打开任一条目后会出现在这里。",status:{done:"已完成",in_progress:"进行中",todo:"计划中"},siteStatus:{done:"已对接",in_progress:"进行中"},catalogTitle:"书目著录进度",catalogNote:"每条著录对到作品条目",colCatalog:"书目",colRecords:"著录条目",colMatched:"已对上作品",colProgress:"进度",colStatus:"状态",relatedTitle:"同类书目与考证",relatedNote:"不在书架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 种",allNKinds:"全部 {n} 种",pavilion:"阁",yearBC:"前{n}",missingLife:"生卒年未录、未上轴:{names}",viewLineage:"看版本谱系 →",plannedSites:"计划接入:{names}",loss:{extant:"存",partially_extant:"残",lost:"佚",unknown:"未详"},lossNote:{extant:"今有传本",partially_extant:"部分存世",lost:"仅见著录",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"丛编",entities:"人物",has_image:"有影印",has_text:"有文本",article:"单篇文",poem:"单篇诗"},dataScale:"数据规模",byLoss:"按存佚检索",license:"古籍元数据以 CC0 公有领域发布,可自由复制、改编、再发布。",repo:"数据仓库:",repoNote:"(GitHub,CC0)",version:"当前数据版本:",download:"引用方式与数据下载 →",navLabel:"元数据首页分区",nav:{zhi:"历代史志",sibu:"四部",cong:"丛编",people:"人物",lineage:"版本谱系",sites:"在线资源",data:"数据与授权"},zhiSub:"正史艺文志、经籍志与后人补志,按所志朝代排列;每部志的著录逐条对到作品",shelfLegendCount:"脊下数字=著录条目",shelfLegendClick:"点书脊进作品页",sibuSub:"全部作品按经史子集分类;与「目录」页同一棵分类树",toCatalog:"进入目录 →",unclassifiedNote:"多为只见于史志著录、尚未归类的书",congSub:"大型丛书、影印汇编、出土文献与馆藏,逐种列到版本",allNKindsMore:"全部 {n} 种 →",peopleSub:"历代目录学家,按生卒年排在一条时间轴上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流与异同",sitesSub:"外部数字图书馆与本站条目的对接",dataSub:"规模、存佚、许可与版本"}),Ao=at({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:"按作者浏览全部 →"}),Sp=at({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} 条"}),_p=at({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:"搜索"}),$p=at({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:"回复"}),Cp=at({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:"有争议"}}),zp={common:fp,detail:gi,bookPage:xp,workPage:bp,collectionPage:yp,entityPage:jp,reader:vp,collated:kp,metaHome:wp,readHome:Ao,catalogPage:Sp,searchPage:_p,feedback:$p,lineage:Cp};function Tp(e){const n={};for(const[o,r]of Object.entries(zp))n[o]=r[e];return n}function mt(e,n){return e.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Jr=new Map;function un(e){let n=Jr.get(e);return n||(n={...e==="zh-Hans"?gp:hp,...Tp(e)},Jr.set(e,n)),n}function Qr(e,n){let o=e;for(const r of n.split(".")){if(o==null||typeof o!="object")return;o=o[r]}return typeof o=="string"?o:void 0}function Na(e){return(n,o)=>{const r=Qr(e,n)??Qr(un("zh-Hant"),n)??n;return o?mt(r,o):r}}const es=new Map;function mn(e){let n=es.get(e);return n||(n=Na(un(e)),es.set(e,n)),n}const Ra="bim-locale";function Np(){try{const e=localStorage.getItem(Ra);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Rp(e){try{localStorage.setItem(Ra,e)}catch{}}const Ep="zh-Hans",Ip=({locale:e,onLocaleChange:n,converter:o,children:r})=>{const[s,a]=g.useState(e??Ep),l=e??s;g.useEffect(()=>{if(e)return;const u=Np();u&&u!==s&&a(u)},[]);const d=g.useMemo(()=>l==="zh-Hans"?o??mp():null,[l,o]),c=g.useCallback(u=>{a(u),Rp(u),n==null||n(u)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:un(l),converter:d}),[l,c,d]);return t.jsx(Xt.Provider,{value:p,children:r})};function Te(){const e=g.useContext(Xt);return(e==null?void 0:e.messages)??un("zh-Hant")}const Lp=2e3;function Ae(){const e=g.useContext(Xt),n=(e==null?void 0:e.locale)??"zh-Hant",o=(e==null?void 0:e.converter)??null,r=g.useRef(new Map),s=g.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const a=g.useCallback(l=>{if(!l)return"";if(!o)return l;const d=r.current.get(l);if(d!==void 0)return d;const c=o(l);if(r.current.size>=Lp){const p=r.current.keys().next().value;p!==void 0&&r.current.delete(p)}return r.current.set(l,c),c},[o]);return g.useMemo(()=>({convert:a,locale:n,isSimplified:n==="zh-Hans"}),[a,n])}function J(){const e=g.useContext(Xt),{convert:n,locale:o,isSimplified:r}=Ae(),s=(e==null?void 0:e.messages)??un("zh-Hant"),a=g.useMemo(()=>e?Na(s):mn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:o,isSimplified:r,messages:s}),[a,n,o,r,s])}const Ea=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Ap=new Set([...Ea,...Object.keys(_e.VARIANT_CHARS)]),Ia=[...Ta,"切換為繁體","漢籍リポジトリ"];function Pp(e,n=Ia){let o=e;for(const a of n)a&&(o=o.split(a).join(" "));const r=[],s=Array.from(o);return s.forEach((a,l)=>{Ap.has(a)&&r.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),r}function Mp(e){if(!e)return"";try{const n=new URL(e).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 Bp(){return{id:"",name:"",url:"",type:"text",details:""}}const lo=({items:e,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const a=Te(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],u=b=>{if(!s)return!0;const j=qt(b);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},m=e.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>u(b)),h=()=>{const b=Bp();s&&(b.type=s),n([...e,b]),d(e.length)},f=b=>{n(e.filter((j,S)=>S!==b)),d(null)},x=(b,j,S)=>{const v=[...e];if(v[b]={...v[b],[j]:S},j==="url"&&!v[b].id){const $=Mp(S);$&&(v[b].id=$)}n(v)},k=(b,j,S)=>{const $={...e[b].metadata||{}};S?$[j]=S:delete $[j],x(b,"metadata",Object.keys($).length>0?$:void 0)},y=(b,j)=>{const S=j.trim()?j.split(/[,,、]/).map(v=>v.trim()).filter(Boolean):void 0;x(b,"structure",S)},w=(b,j,S)=>{const $=e[b].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(S)||1:$.ranges=S,x(b,"coverage",$.ranges?$:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:b,originalIndex:j})=>{var S,v,$;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===j?null:j),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===j?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Wp(b.type??"text"),color:i("on-color-fg")},children:(()=>{var C,M;const _=qt(b);return _.length===0?b.type??"text":_.length===1?((C=c.find(N=>N.value===_[0]))==null?void 0:C.label)??_[0]:_.includes("text")&&_.includes("image")?((M=c.find(N=>N.value==="text+image"))==null?void 0:M.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${a.editor.resourcePlaceholder} ${j+1}`}),b.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&t.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&Op(j,r==null?void 0:r[j],o,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(j)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===j&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[cp(b,"image")&&b.url&&Hp(b,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:kn,children:[t.jsx("span",{style:wn,children:a.label.type}),t.jsx("select",{value:b.type,onChange:_=>x(j,"type",_.target.value),style:{...jt,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:kn,children:[t.jsx("span",{style:wn,children:a.label.rootType}),t.jsx("select",{value:b.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{...jt,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:b.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...jt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:b.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{...jt,flex:1}})]}),t.jsx("input",{type:"text",value:b.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:jt}),t.jsx("input",{type:"text",value:((S=b.structure)==null?void 0:S.join("、"))||"",onChange:_=>y(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:jt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:kn,children:[t.jsx("span",{style:wn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((v=b.coverage)==null?void 0:v.level)??"",onChange:_=>w(j,"level",_.target.value),placeholder:"1",style:{...jt,width:"60px"}})]}),t.jsxs("label",{style:{...kn,flex:1},children:[t.jsx("span",{style:wn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:(($=b.coverage)==null?void 0:$.ranges)||"",onChange:_=>w(j,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...jt,flex:1}})]})]}),t.jsx("textarea",{value:b.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...jt,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:a.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(a.metadata).map(([_,C])=>{var M;return t.jsxs("label",{style:{...kn,gap:"4px"},children:[t.jsx("span",{style:{...wn,minWidth:"56px"},children:C}),t.jsx("input",{type:"text",value:((M=b.metadata)==null?void 0:M[_])||"",onChange:N=>k(j,_,N.target.value),placeholder:C,style:{...jt,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:h,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:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function Wp(e){switch(e){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 Op(e,n,o,r){const s=(n==null?void 0:n.status)==="downloading",a=(n==null?void 0:n.status)==="completed";return t.jsx("button",{onClick:l=>{l.stopPropagation(),s||o(e,"")},disabled:s,style:{background:"transparent",border:"none",color:i(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function Hp(e,n){const o=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.url)||e.url.includes("iiif")||e.url.includes("image");return t.jsx("div",{style:{marginBottom:"12px"},children:o?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const jt={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"},kn={display:"flex",alignItems:"center",gap:"6px"},wn={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},Fp={"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 hn(e){try{return Fp[new URL(e).hostname]}catch{return}}const ts={text:0,image:1,physical:2};function Po(e){return e.length===0?"physical":[...e].sort((n,o)=>(ts[n]??99)-(ts[o]??99)).join("+")}function Mo(e){var l;const n=d=>{const c=d.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const p=d.match(/^(.+?)[·(](\d+)[)]?$/);return p?[p[1],parseInt(p[2])]:null},o=new Map;for(let d=0;d<e.length;d++){const c=e[d];if(c.volumes&&c.volumes.length>0)continue;const p=n(c.name);if(!p)continue;const[u,m]=p,h=`${u}|${Po(qt(c))}`;o.has(h)||o.set(h,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const f=o.get(h);f.volumes.push({volume:m,url:c.url||void 0,status:"found"}),f.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=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),r.push(d.base);for(const c of d.indices)s.add(c)}const a=[...r];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function La(e){if(e.url)return e.url;for(const[n,o]of Object.entries(e))if(n.endsWith("_url")&&typeof o=="string")return o}function Aa(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||La(n)}))}function fi(e){const n=Aa(e);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:e.expected_volumes??o+r}}function Bo(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function Wo(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const r=e.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(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function gn(e){if(!e.url)return;const n=Bo(e.metadata);return n?Wo(e.url,n):e.url}const ns={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function Dp(e){return e.includes("text")&&e.includes("image")?ns["text+image"]:ns[e[0]||"physical"]}const Oo=({items:e,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const a=Te(),{convert:l}=Ae(),d=g.useMemo(()=>Mo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,w=[];for(const b of d){const j=b.group;j?(y.has(j)||y.set(j,[]),y.get(j).push(b)):w.push(b)}for(const b of y.values())b.sort((j,S)=>{const v=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return v(j)-v(S)});return{mirrorGroups:y,ungroupedItems:w}},[d]),u={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=y=>u[y]?u[y]:y.split("+").map(w=>u[w]||w).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,w)=>t.jsx(Ui,{item:y},y.id||w))});const h=(y,w)=>{const b=o==null?void 0:o[y],j=(b==null?void 0:b.label)||y,S=b==null?void 0:b.description;return t.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:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:l(j)}),S&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:l(S)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((v,$)=>t.jsx(Ui,{item:v,onNavigate:r,renderLink:s},v.id||$))})]},`group-${y}`)},f=new Map;for(const y of p){const w=Po(qt(y));f.has(w)||f.set(w,[]),f.get(w).push(y)}const x=["text","image","text+image","physical"],k=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,w])=>h(y,w)),k.map(y=>{const w=f.get(y),b=Dp(y.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:m(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((j,S)=>t.jsx(Ui,{item:j,onNavigate:r,renderLink:s},j.id||S))})]},y)})]})},Up={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Ui=({item:e})=>{const n=Te(),{convert:o}=Ae(),[r,s]=g.useState(!1),a=g.useMemo(()=>(e.url?hn(e.url):void 0)||o(e.name),[e.url,e.name,o]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||La(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,u=e.expected_volumes??(d?c+p:0),m=e.color_mode?{...Up[e.color_mode],label:n.colorMode[e.color_mode]}:null,h=e.details&&!d?o(e.details):null,f={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 t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),h&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:h}),d&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,p>0&&t.jsx("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:mt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Bo(e.metadata);return x?Wo(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.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&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const k=x.status==="missing";return x.url&&!k?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${i("widget-border")}`,color:i("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(k?"missing-fg":"desc-fg"),textDecoration:k?"line-through":"none",opacity:k?.6:1},children:x.volume},x.volume)})})]})},Pa=({indexSource:e,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Te(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",m=u?u.split(/[/\\]/).pop()||u:"",h={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")},f={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...h,background:i(p?"warning":"success"),color:i("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return o==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:r,title:d.mode.switchToSync,style:h,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:u||d.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:r,title:d.mode.switchToLocal,style:h,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:m||d.mode.configurePath,style:{...h,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:r,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:h,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:u||d.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...h,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:m})]})]})},xi="bim-search-history",is=10,os=8;function Rn(){try{const e=localStorage.getItem(xi);return e?JSON.parse(e):[]}catch{return[]}}function Ma(e){try{const n=Rn().filter(o=>o!==e);n.unshift(e),n.length>is&&(n.length=is),localStorage.setItem(xi,JSON.stringify(n))}catch{}}function Vp(e){try{const n=Rn().filter(o=>o!==e);localStorage.setItem(xi,JSON.stringify(n))}catch{}}function Gp(){try{localStorage.removeItem(xi)}catch{}}const Ba=({transport:e,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:a})=>{const l=Te(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,u]=g.useState(!1),[m,h]=g.useState([]),[f,x]=g.useState(-1),[k,y]=g.useState(Rn),w=g.useRef(null),b=g.useRef(null),j=g.useRef(null),S=g.useRef(!1);g.useEffect(()=>{x(-1);const T=n.trim();if(!T){h(k.map(E=>({type:"history",text:E})));return}if(!e.searchAll){h([]);return}let F=!1;const R=setTimeout(()=>{e.searchAll(T,os).then(E=>{if(F)return;const L=[...E.works,...E.books,...E.collections,...E.entities??[]];h(L.slice(0,os).map(I=>({type:"entry",text:I.title||I.id,entry:I})))}).catch(()=>{F||h([])})},80);return()=>{F=!0,clearTimeout(R)}},[n,k,e]),g.useEffect(()=>{const T=F=>{j.current&&!j.current.contains(F.target)&&u(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),g.useEffect(()=>{const T=F=>{var R,E;if(F.key==="/"&&document.activeElement!==w.current){const L=(R=document.activeElement)==null?void 0:R.tagName;if(L==="INPUT"||L==="TEXTAREA"||L==="SELECT")return;F.preventDefault(),(E=w.current)==null||E.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const v=g.useCallback(T=>{T.trim()&&(Ma(T.trim()),y(Rn())),r(T),u(!1)},[r]),$=g.useCallback(T=>{T.type==="history"?(o(T.text),v(T.text)):T.entry&&(s?(s(T.entry),u(!1)):(o(T.text),v(T.text)))},[o,v,s]),_=g.useCallback(T=>{if(!p||m.length===0){T.key==="Enter"&&v(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(F=>(F+1)%m.length);break;case"ArrowUp":T.preventDefault(),x(F=>(F-1+m.length)%m.length);break;case"Enter":T.preventDefault(),f>=0&&f<m.length?$(m[f]):v(n);break;case"Escape":T.preventDefault(),u(!1);break}},[p,m,f,n,v,$]),C=g.useCallback((T,F)=>{F.stopPropagation(),Vp(T),y(Rn()),h(R=>R.filter(E=>!(E.type==="history"&&E.text===T)))},[]),M=g.useCallback(T=>{T.stopPropagation(),Gp(),y([]),h([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const T=b.current.children;T[f]&&T[f].scrollIntoView({block:"nearest"})}},[f]);const N=!n.trim()&&k.length>0;return t.jsxs("div",{ref:j,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:w,type:"text",placeholder:d,value:n,onChange:T=>{o(T.target.value),u(!0)},onCompositionStart:()=>{S.current=!0},onCompositionEnd:()=>{S.current=!1},onFocus:()=>{u(!0)},onKeyDown:_,style:{width:"100%",padding:"8px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&m.length>0&&t.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:[N&&t.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:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:M,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((T,F)=>t.jsxs("div",{onClick:()=>$(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:F===f?i("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:T.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.text}),T.entry&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[T.entry.type],T.entry.edition&&` · ${T.entry.edition}`,T.entry.author&&` · ${T.entry.author}`]}),T.type==="history"&&t.jsx("button",{onClick:R=>C(T.text,R),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${T.type}-${T.text}-${F}`))]})]})},fn=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${e}`),verticalAlign:"middle"}}),bi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Wa=new Set(["work","book","entity"]);function Yp(e){return Fa(e)||!!e.sort}function Kp(e,n){return n.sort&&Wa.has(e)?n.sort:void 0}const yi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],ji=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Oa=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Ha={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function vi(e){return e.dynasty.length+e.classification.length+(e.hasImage?1:0)+(e.hasText?1:0)+(e.hasCollated?1:0)+(e.loss?1:0)}function Fa(e){return vi(e)>0}function qp(e){const n=[];return e.dynasty.length&&n.push("dynasty"),e.classification.length&&n.push("classification"),e.hasImage&&n.push("hasImage"),e.hasText&&n.push("hasText"),e.hasCollated&&n.push("hasCollated"),e.loss&&n.push("loss"),n}function Da(e,n){const o=Ha[e];return qp(n).every(r=>o.has(r))}const Sn=e=>JSON.stringify(e);function Xp(e,n){if(!Da(n,e))return null;const o=[];if(e.dynasty.length){const r=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=yi.find(l=>l.key===s))==null?void 0:a.values)??[]})));r.length===1?o.push(`dynasty = ${Sn(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(Sn).join(", ")}]`)}return e.classification.length&&o.push(e.classification.length===1?`classification = ${Sn(e.classification[0])}`:`classification IN [${e.classification.map(Sn).join(", ")}]`),e.hasImage&&o.push("has_image = true"),e.hasText&&o.push("has_text = true"),e.hasCollated&&o.push("has_collated = true"),e.loss&&o.push(`loss_status = ${Sn(e.loss)}`),o.join(" AND ")}const it={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},Ua="_";function li(e,n=new URLSearchParams){for(const o of Object.values(it))n.delete(o);return e.dynasty.length&&n.set(it.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(it.classification,e.classification.map(o=>o||Ua).join(",")),e.hasImage&&n.set(it.hasImage,"1"),e.hasText&&n.set(it.hasText,"1"),e.hasCollated&&n.set(it.hasCollated,"1"),e.loss&&n.set(it.loss,e.loss),e.sort&&n.set(it.sort,e.sort),n}function Zp(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),o=new Set(yi.map(a=>a.key)),r=new Set(ji.map(a=>a.value)),s=e.get(it.loss);return{dynasty:Array.from(new Set(n(it.dynasty).filter(a=>o.has(a)))),classification:Array.from(new Set(n(it.classification).map(a=>a===Ua?"":a).filter(a=>r.has(a)))),hasImage:e.get(it.hasImage)==="1",hasText:e.get(it.hasText)==="1"||e.get(it.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(a=>a===e.get(it.sort))??""}}function Jp(e,n){return JSON.stringify([e.dynasty.slice().sort(),e.classification.slice().sort(),e.hasImage,e.hasText,e.hasCollated,e.loss,e.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function rs(e,n){return e.includes(n)?e.filter(o=>o!==n):[...e,n]}const Qp=({filters:e,onChange:n})=>{const o=Te(),r=o.searchV4,{convert:s}=Ae(),[a,l]=g.useState(!1),d=g.useId(),c=vi(e),p=u=>n({...e,...u});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(r.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(u=>!u),children:[t.jsxs("span",{children:[s(r.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(mt(r.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?r.collapse:r.expand)," ",a?"▴":"▾"]})]}),t.jsxs("div",{className:"bim-sr-filters",id:d,"data-open":a?"true":"false",...a?{}:{"data-collapsed":"true"},children:[t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:yi.map(u=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(u.key),onClick:()=>p({dynasty:rs(e.dynasty,u.key)}),children:s(u.key)},u.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.classification)}),ji.map(u=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(u.value),onChange:()=>p({classification:rs(e.classification,u.value)})}),u.value?s(u.label):o.searchPage.unclassified]},u.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:u=>p({hasImage:u.target.checked})}),s(r.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:u=>p({hasText:u.target.checked})}),s(r.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(r.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:Oa.map(u=>t.jsx("button",{type:"button","aria-pressed":e.loss===u.value,onClick:()=>p({loss:u.value}),children:o.searchPage.loss[u.value||"all"]},u.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...bi,sort:e.sort}),children:s(r.clearAllFilters)})]})]})};function Va({text:e,query:n}){const o=(n??"").trim();if(!o||!e)return t.jsx(t.Fragment,{children:e});const r=e.toLowerCase(),s=o.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=r.indexOf(s,l);if(c<0){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{className:"bim-sr-hl",children:e.slice(c,c+s.length)},d++)),l=c+s.length}return t.jsx(t.Fragment,{children:a})}const ss=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=Te(),a=s.searchV4,{convert:l}=Ae(),d=Ze();return t.jsx("div",{className:"bim-sr-tablewrap",children:t.jsxs("table",{className:"bim-sr-table",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"34%"}}),t.jsx("col",{style:{width:"8%"}}),t.jsx("col",{style:{width:"19%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"14%"}})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:l(a.colTitle)}),t.jsx("th",{scope:"col",children:l(a.colType)}),t.jsx("th",{scope:"col",children:l(a.colAuthor)}),t.jsx("th",{scope:"col",children:l(a.colEra)}),t.jsx("th",{scope:"col",children:l(a.colClass)}),t.jsx("th",{scope:"col",style:{textAlign:"right"},children:l(a.colResource)})]})}),t.jsx("tbody",{children:e.map(c=>{const p=l(c.title||c.primary_name||c.id),u=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",h=c.type==="book"?c.era??c.dynasty:c.dynasty,f=h?l(h):"",x=c.classification?l(c.classification):"",k=[];c.has_image&&k.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&k.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&k.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[m,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:w=>o(c,w),children:t.jsx(Va,{text:p,query:n?l(n):void 0})}),u&&t.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(fn,{type:c.type,size:6})," ",r(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:k.map(w=>t.jsx("span",{className:`bim-sr-tag ${w.cls}`,children:l(w.label)},w.label))})]},c.id)})})]})})},eu=`
|
|
1
|
+
"use strict";var Jd=Object.create;var Zr=Object.defineProperty;var Qd=Object.getOwnPropertyDescriptor;var ep=Object.getOwnPropertyNames;var tp=Object.getPrototypeOf,np=Object.prototype.hasOwnProperty;var ip=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of ep(n))!np.call(e,s)&&s!==o&&Zr(e,s,{get:()=>n[s],enumerable:!(r=Qd(n,s))||r.enumerable});return e};var Zn=(e,n,o)=>(o=e!=null?Jd(tp(e)):{},ip(n||!e||!e.__esModule?Zr(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _e=require("./storage-entry-BDcJjAiW.cjs"),t=require("react/jsx-runtime"),g=require("react"),op=require("opencc-js/t2cn"),rp=require("react-markdown"),sp=require("remark-gfm"),ap=e=>`/book-index?id=${e}`,$a=g.createContext(ap);function lp({buildUrl:e,children:n}){const o=g.useMemo(()=>e,[e]);return t.jsx($a.Provider,{value:o,children:n})}function Ze(){return g.useContext($a)}const Ca="",za="";function Lo(e){const n=[];let o=!1,r=e;for(;r.length;){const s=o?za:Ca,a=r.indexOf(s);if(a===-1){n.push({text:r,marked:o});break}a>0&&n.push({text:r.slice(0,a),marked:o}),r=r.slice(a+1),o=!o}return n}function rt(e,n){return{title:e,tokens:n}}const Jr='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',cp=[rt("基础(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"}}),rt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),rt("提示与警告",{"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)"}}),rt("遮罩与阴影",{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)"}}),rt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),rt("资源",{"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"}}),rt("整理本(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"}}),rt("版本传承(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"}}),rt("编辑器视图(主要在 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")'}}),rt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#3b4a58",note:"主题切换控件的色点:墨"},"sect-jing":{value:"#2e5266",note:"四部分布条:經部(人物页提要卡;无别处使用)"},"sect-shi":{value:"#9a7a3b",note:"四部分布条:史部"},"sect-zi":{value:"#4f7a5c",note:"四部分布条:子部"},"sect-ji":{value:"#9fb3bc",note:"四部分布条:集部"},"table-border":{value:"color-mix(in srgb, currentColor 28%, transparent)",root:!1,note:"古籍表格(跟随当前文字色)"},"table-head-bg":{value:"color-mix(in srgb, currentColor 8%, transparent)",root:!1}}),rt('版式(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"}}),rt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),rt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),rt("字体(全站无衬线,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:Jr,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Jr,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],dp=Object.assign({},...cp.map(e=>e.tokens)),Ta={};for(const[e,n]of Object.entries(dp))Ta[e]=`var(--bim-${e}, ${n.value})`;function i(e){const n=Ta[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function qt(e){return e.types&&e.types.length>0?e.types:e.type?e.type==="text+image"?["text","image"]:[e.type]:[]}function pp(e,n){return qt(e).includes(n)}const up={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Xt=g.createContext(null),Na=["曹霑"];function mp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hp(e,n=Na){const o=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!o.length)return e;const r=new RegExp(`(${o.map(mp).join("|")})`,"g"),s=new Set(o);return a=>{if(!a)return e(a);const l=a.split(r);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let kn=null;function gp(){if(kn)return kn;try{const e=op.Converter({from:"t",to:"cn"});kn=hp(n=>e(_e.normalizeVariants(n)))}catch{kn=e=>e}return kn}const fp={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:"圖片資源"}},xp={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 at(e,n,o){return{"zh-Hant":e,"zh-Hans":n}}const bp=at({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:"无数据"}),gi=at({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:"作品信息"}),yp=at({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:"附记"}}),jp=at({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}"}}),vp=at({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:"上级丛编"}),kp=at({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 为自动匹配,未经人工核对"}),wp=at({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:"参考文献"}),Sp=at({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:"本卷条目"}),_p=at({typeShort:{work:"作",book:"版",collection:"叢",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"叢編",entity:"人物"},typeAll:"全部",typeChipsLabel:"按類型檢索",recentTitle:"最近瀏覽",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"還沒有瀏覽記錄。打開任一條目後會出現在這裏。",status:{done:"已完成",in_progress:"進行中",todo:"計劃中"},siteStatus:{done:"已對接",in_progress:"進行中"},catalogTitle:"書目著錄進度",catalogNote:"每條著錄對到作品條目",colCatalog:"書目",colRecords:"著錄條目",colMatched:"已對上作品",colProgress:"進度",colStatus:"狀態",relatedTitle:"同類書目與考證",relatedNote:"不在書架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 種",allNKinds:"全部 {n} 種",pavilion:"閣",yearBC:"前{n}",missingLife:"生卒年未錄、未上軸:{names}",viewLineage:"看版本譜系 →",plannedSites:"計劃接入:{names}",loss:{extant:"存",partially_extant:"殘",lost:"佚",unknown:"未詳"},lossNote:{extant:"今有傳本",partially_extant:"部分存世",lost:"僅見著錄",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"叢編",entities:"人物",has_image:"有影印",has_text:"有文本",article:"單篇文",poem:"單篇詩"},dataScale:"數據規模",byLoss:"按存佚檢索",license:"古籍元數據以 CC0 公有領域發布,可自由複製、改編、再發布。",repo:"數據倉庫:",repoNote:"(GitHub,CC0)",version:"當前數據版本:",download:"引用方式與數據下載 →",navLabel:"元數據首頁分區",nav:{zhi:"歷代史志",sibu:"四部",cong:"叢編",people:"人物",lineage:"版本譜系",sites:"在線資源",data:"數據與授權"},zhiSub:"正史藝文志、經籍志與後人補志,按所志朝代排列;每部志的著錄逐條對到作品",shelfLegendCount:"脊下數字=著錄條目",shelfLegendClick:"點書脊進作品頁",sibuSub:"全部作品按經史子集分類;與「目錄」頁同一棵分類樹",toCatalog:"進入目錄 →",unclassifiedNote:"多為只見於史志著錄、尚未歸類的書",congSub:"大型叢書、影印彙編、出土文獻與館藏,逐種列到版本",allNKindsMore:"全部 {n} 種 →",peopleSub:"歷代目錄學家,按生卒年排在一條時間軸上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流與異同",sitesSub:"外部數字圖書館與本站條目的對接",dataSub:"規模、存佚、許可與版本"},{typeShort:{work:"作",book:"版",collection:"丛",entity:"人"},typeLabel:{work:"作品",book:"版本",collection:"丛编",entity:"人物"},typeAll:"全部",typeChipsLabel:"按类型检索",recentTitle:"最近浏览",recentClear:"清除",recentItemLabel:"{type} {title}",recentEmpty:"还没有浏览记录。打开任一条目后会出现在这里。",status:{done:"已完成",in_progress:"进行中",todo:"计划中"},siteStatus:{done:"已对接",in_progress:"进行中"},catalogTitle:"书目著录进度",catalogNote:"每条著录对到作品条目",colCatalog:"书目",colRecords:"著录条目",colMatched:"已对上作品",colProgress:"进度",colStatus:"状态",relatedTitle:"同类书目与考证",relatedNote:"不在书架上的",allNWorks:"全部 {n} 部",nKinds:"{n} 种",allNKinds:"全部 {n} 种",pavilion:"阁",yearBC:"前{n}",missingLife:"生卒年未录、未上轴:{names}",viewLineage:"看版本谱系 →",plannedSites:"计划接入:{names}",loss:{extant:"存",partially_extant:"残",lost:"佚",unknown:"未详"},lossNote:{extant:"今有传本",partially_extant:"部分存世",lost:"仅见著录",unknown:"尚未判定"},lossCount:"{n} 部 · {note}",stat:{works:"作品",books:"版本",collections:"丛编",entities:"人物",has_image:"有影印",has_text:"有文本",article:"单篇文",poem:"单篇诗"},dataScale:"数据规模",byLoss:"按存佚检索",license:"古籍元数据以 CC0 公有领域发布,可自由复制、改编、再发布。",repo:"数据仓库:",repoNote:"(GitHub,CC0)",version:"当前数据版本:",download:"引用方式与数据下载 →",navLabel:"元数据首页分区",nav:{zhi:"历代史志",sibu:"四部",cong:"丛编",people:"人物",lineage:"版本谱系",sites:"在线资源",data:"数据与授权"},zhiSub:"正史艺文志、经籍志与后人补志,按所志朝代排列;每部志的著录逐条对到作品",shelfLegendCount:"脊下数字=著录条目",shelfLegendClick:"点书脊进作品页",sibuSub:"全部作品按经史子集分类;与「目录」页同一棵分类树",toCatalog:"进入目录 →",unclassifiedNote:"多为只见于史志著录、尚未归类的书",congSub:"大型丛书、影印汇编、出土文献与馆藏,逐种列到版本",allNKindsMore:"全部 {n} 种 →",peopleSub:"历代目录学家,按生卒年排在一条时间轴上",allNPeopleMore:"全部 {n} 人 →",lineageSub:"版本多的作品,看各本的源流与异同",sitesSub:"外部数字图书馆与本站条目的对接",dataSub:"规模、存佚、许可与版本"}),Ao=at({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:"按作者浏览全部 →"}),$p=at({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} 条"}),Cp=at({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:"搜索"}),zp=at({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:"回复"}),Tp=at({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:"有争议"}}),Np={common:bp,detail:gi,bookPage:yp,workPage:jp,collectionPage:vp,entityPage:kp,reader:wp,collated:Sp,metaHome:_p,readHome:Ao,catalogPage:$p,searchPage:Cp,feedback:zp,lineage:Tp};function Rp(e){const n={};for(const[o,r]of Object.entries(Np))n[o]=r[e];return n}function ut(e,n){return e.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Qr=new Map;function un(e){let n=Qr.get(e);return n||(n={...e==="zh-Hans"?xp:fp,...Rp(e)},Qr.set(e,n)),n}function es(e,n){let o=e;for(const r of n.split(".")){if(o==null||typeof o!="object")return;o=o[r]}return typeof o=="string"?o:void 0}function Ra(e){return(n,o)=>{const r=es(e,n)??es(un("zh-Hant"),n)??n;return o?ut(r,o):r}}const ts=new Map;function mn(e){let n=ts.get(e);return n||(n=Ra(un(e)),ts.set(e,n)),n}const Ea="bim-locale";function Ep(){try{const e=localStorage.getItem(Ea);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Ip(e){try{localStorage.setItem(Ea,e)}catch{}}const Lp="zh-Hans",Ap=({locale:e,onLocaleChange:n,converter:o,children:r})=>{const[s,a]=g.useState(e??Lp),l=e??s;g.useEffect(()=>{if(e)return;const u=Ep();u&&u!==s&&a(u)},[]);const d=g.useMemo(()=>l==="zh-Hans"?o??gp():null,[l,o]),c=g.useCallback(u=>{a(u),Ip(u),n==null||n(u)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:un(l),converter:d}),[l,c,d]);return t.jsx(Xt.Provider,{value:p,children:r})};function Te(){const e=g.useContext(Xt);return(e==null?void 0:e.messages)??un("zh-Hant")}const Pp=2e3;function Le(){const e=g.useContext(Xt),n=(e==null?void 0:e.locale)??"zh-Hant",o=(e==null?void 0:e.converter)??null,r=g.useRef(new Map),s=g.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const a=g.useCallback(l=>{if(!l)return"";if(!o)return l;const d=r.current.get(l);if(d!==void 0)return d;const c=o(l);if(r.current.size>=Pp){const p=r.current.keys().next().value;p!==void 0&&r.current.delete(p)}return r.current.set(l,c),c},[o]);return g.useMemo(()=>({convert:a,locale:n,isSimplified:n==="zh-Hans"}),[a,n])}function J(){const e=g.useContext(Xt),{convert:n,locale:o,isSimplified:r}=Le(),s=(e==null?void 0:e.messages)??un("zh-Hant"),a=g.useMemo(()=>e?Ra(s):mn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:o,isSimplified:r,messages:s}),[a,n,o,r,s])}const Ia=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Mp=new Set([...Ia,...Object.keys(_e.VARIANT_CHARS)]),La=[...Na,"切換為繁體","漢籍リポジトリ"];function Bp(e,n=La){let o=e;for(const a of n)a&&(o=o.split(a).join(" "));const r=[],s=Array.from(o);return s.forEach((a,l)=>{Mp.has(a)&&r.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),r}function Wp(e){if(!e)return"";try{const n=new URL(e).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 Op(){return{id:"",name:"",url:"",type:"text",details:""}}const lo=({items:e,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const a=Te(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],u=b=>{if(!s)return!0;const j=qt(b);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},m=e.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>u(b)),h=()=>{const b=Op();s&&(b.type=s),n([...e,b]),d(e.length)},f=b=>{n(e.filter((j,S)=>S!==b)),d(null)},x=(b,j,S)=>{const v=[...e];if(v[b]={...v[b],[j]:S},j==="url"&&!v[b].id){const $=Wp(S);$&&(v[b].id=$)}n(v)},k=(b,j,S)=>{const $={...e[b].metadata||{}};S?$[j]=S:delete $[j],x(b,"metadata",Object.keys($).length>0?$:void 0)},y=(b,j)=>{const S=j.trim()?j.split(/[,,、]/).map(v=>v.trim()).filter(Boolean):void 0;x(b,"structure",S)},w=(b,j,S)=>{const $=e[b].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(S)||1:$.ranges=S,x(b,"coverage",$.ranges?$:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:b,originalIndex:j})=>{var S,v,$;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===j?null:j),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===j?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Hp(b.type??"text"),color:i("on-color-fg")},children:(()=>{var C,M;const _=qt(b);return _.length===0?b.type??"text":_.length===1?((C=c.find(N=>N.value===_[0]))==null?void 0:C.label)??_[0]:_.includes("text")&&_.includes("image")?((M=c.find(N=>N.value==="text+image"))==null?void 0:M.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${a.editor.resourcePlaceholder} ${j+1}`}),b.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&t.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&Fp(j,r==null?void 0:r[j],o,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),f(j)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===j&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[pp(b,"image")&&b.url&&Dp(b,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:wn,children:[t.jsx("span",{style:Sn,children:a.label.type}),t.jsx("select",{value:b.type,onChange:_=>x(j,"type",_.target.value),style:{...jt,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:wn,children:[t.jsx("span",{style:Sn,children:a.label.rootType}),t.jsx("select",{value:b.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{...jt,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:b.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...jt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:b.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{...jt,flex:1}})]}),t.jsx("input",{type:"text",value:b.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:jt}),t.jsx("input",{type:"text",value:((S=b.structure)==null?void 0:S.join("、"))||"",onChange:_=>y(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:jt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:wn,children:[t.jsx("span",{style:Sn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((v=b.coverage)==null?void 0:v.level)??"",onChange:_=>w(j,"level",_.target.value),placeholder:"1",style:{...jt,width:"60px"}})]}),t.jsxs("label",{style:{...wn,flex:1},children:[t.jsx("span",{style:Sn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:(($=b.coverage)==null?void 0:$.ranges)||"",onChange:_=>w(j,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...jt,flex:1}})]})]}),t.jsx("textarea",{value:b.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...jt,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:a.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(a.metadata).map(([_,C])=>{var M;return t.jsxs("label",{style:{...wn,gap:"4px"},children:[t.jsx("span",{style:{...Sn,minWidth:"56px"},children:C}),t.jsx("input",{type:"text",value:((M=b.metadata)==null?void 0:M[_])||"",onChange:N=>k(j,_,N.target.value),placeholder:C,style:{...jt,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:h,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:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function Hp(e){switch(e){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 Fp(e,n,o,r){const s=(n==null?void 0:n.status)==="downloading",a=(n==null?void 0:n.status)==="completed";return t.jsx("button",{onClick:l=>{l.stopPropagation(),s||o(e,"")},disabled:s,style:{background:"transparent",border:"none",color:i(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function Dp(e,n){const o=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.url)||e.url.includes("iiif")||e.url.includes("image");return t.jsx("div",{style:{marginBottom:"12px"},children:o?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const jt={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"},wn={display:"flex",alignItems:"center",gap:"6px"},Sn={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},Up={"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 hn(e){try{return Up[new URL(e).hostname]}catch{return}}const ns={text:0,image:1,physical:2};function Po(e){return e.length===0?"physical":[...e].sort((n,o)=>(ns[n]??99)-(ns[o]??99)).join("+")}function Mo(e){var l;const n=d=>{const c=d.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const p=d.match(/^(.+?)[·(](\d+)[)]?$/);return p?[p[1],parseInt(p[2])]:null},o=new Map;for(let d=0;d<e.length;d++){const c=e[d];if(c.volumes&&c.volumes.length>0)continue;const p=n(c.name);if(!p)continue;const[u,m]=p,h=`${u}|${Po(qt(c))}`;o.has(h)||o.set(h,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const f=o.get(h);f.volumes.push({volume:m,url:c.url||void 0,status:"found"}),f.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=((l=d.volumes.find(c=>c.url))==null?void 0:l.url)??""),r.push(d.base);for(const c of d.indices)s.add(c)}const a=[...r];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function Aa(e){if(e.url)return e.url;for(const[n,o]of Object.entries(e))if(n.endsWith("_url")&&typeof o=="string")return o}function Pa(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||Aa(n)}))}function fi(e){const n=Pa(e);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:e.expected_volumes??o+r}}function Bo(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function Wo(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const r=e.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(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function gn(e){if(!e.url)return;const n=Bo(e.metadata);return n?Wo(e.url,n):e.url}const is={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function Vp(e){return e.includes("text")&&e.includes("image")?is["text+image"]:is[e[0]||"physical"]}const Oo=({items:e,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const a=Te(),{convert:l}=Le(),d=g.useMemo(()=>Mo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,w=[];for(const b of d){const j=b.group;j?(y.has(j)||y.set(j,[]),y.get(j).push(b)):w.push(b)}for(const b of y.values())b.sort((j,S)=>{const v=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return v(j)-v(S)});return{mirrorGroups:y,ungroupedItems:w}},[d]),u={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=y=>u[y]?u[y]:y.split("+").map(w=>u[w]||w).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:a.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:d.map((y,w)=>t.jsx(Ui,{item:y},y.id||w))});const h=(y,w)=>{const b=o==null?void 0:o[y],j=(b==null?void 0:b.label)||y,S=b==null?void 0:b.description;return t.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:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:l(j)}),S&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:l(S)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((v,$)=>t.jsx(Ui,{item:v,onNavigate:r,renderLink:s},v.id||$))})]},`group-${y}`)},f=new Map;for(const y of p){const w=Po(qt(y));f.has(w)||f.set(w,[]),f.get(w).push(y)}const x=["text","image","text+image","physical"],k=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,w])=>h(y,w)),k.map(y=>{const w=f.get(y),b=Vp(y.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:m(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.map((j,S)=>t.jsx(Ui,{item:j,onNavigate:r,renderLink:s},j.id||S))})]},y)})]})},Gp={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Ui=({item:e})=>{const n=Te(),{convert:o}=Le(),[r,s]=g.useState(!1),a=g.useMemo(()=>(e.url?hn(e.url):void 0)||o(e.name),[e.url,e.name,o]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||Aa(x)})),[e.volumes]),d=l&&l.length>0,c=d?new Set(l.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,p=d?new Set(l.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,u=e.expected_volumes??(d?c+p:0),m=e.color_mode?{...Gp[e.color_mode],label:n.colorMode[e.color_mode]}:null,h=e.details&&!d?o(e.details):null,f={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 t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontWeight:500},children:a}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),h&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:h}),d&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,p>0&&t.jsx("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:ut(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Bo(e.metadata);return x?Wo(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.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&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const k=x.status==="missing";return x.url&&!k?t.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${i("widget-border")}`,color:i("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(k?"missing-fg":"desc-fg"),textDecoration:k?"line-through":"none",opacity:k?.6:1},children:x.volume},x.volume)})})]})},Ma=({indexSource:e,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Te(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",m=u?u.split(/[/\\]/).pop()||u:"",h={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")},f={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...h,background:i(p?"warning":"success"),color:i("on-color-fg")},...f,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return o==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:r,title:d.mode.switchToSync,style:h,...f,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:d.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:l,title:u||d.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:r,title:d.mode.switchToLocal,style:h,...f,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:m||d.mode.configurePath,style:{...h,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:r,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:h,...f,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?d.mode.localMode:d.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:l,title:u||d.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...h,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:m})]})]})},xi="bim-search-history",os=10,rs=8;function En(){try{const e=localStorage.getItem(xi);return e?JSON.parse(e):[]}catch{return[]}}function Ba(e){try{const n=En().filter(o=>o!==e);n.unshift(e),n.length>os&&(n.length=os),localStorage.setItem(xi,JSON.stringify(n))}catch{}}function Yp(e){try{const n=En().filter(o=>o!==e);localStorage.setItem(xi,JSON.stringify(n))}catch{}}function Kp(){try{localStorage.removeItem(xi)}catch{}}const Wa=({transport:e,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:a})=>{const l=Te(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,u]=g.useState(!1),[m,h]=g.useState([]),[f,x]=g.useState(-1),[k,y]=g.useState(En),w=g.useRef(null),b=g.useRef(null),j=g.useRef(null),S=g.useRef(!1);g.useEffect(()=>{x(-1);const T=n.trim();if(!T){h(k.map(E=>({type:"history",text:E})));return}if(!e.searchAll){h([]);return}let F=!1;const R=setTimeout(()=>{e.searchAll(T,rs).then(E=>{if(F)return;const L=[...E.works,...E.books,...E.collections,...E.entities??[]];h(L.slice(0,rs).map(I=>({type:"entry",text:I.title||I.id,entry:I})))}).catch(()=>{F||h([])})},80);return()=>{F=!0,clearTimeout(R)}},[n,k,e]),g.useEffect(()=>{const T=F=>{j.current&&!j.current.contains(F.target)&&u(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),g.useEffect(()=>{const T=F=>{var R,E;if(F.key==="/"&&document.activeElement!==w.current){const L=(R=document.activeElement)==null?void 0:R.tagName;if(L==="INPUT"||L==="TEXTAREA"||L==="SELECT")return;F.preventDefault(),(E=w.current)==null||E.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const v=g.useCallback(T=>{T.trim()&&(Ba(T.trim()),y(En())),r(T),u(!1)},[r]),$=g.useCallback(T=>{T.type==="history"?(o(T.text),v(T.text)):T.entry&&(s?(s(T.entry),u(!1)):(o(T.text),v(T.text)))},[o,v,s]),_=g.useCallback(T=>{if(!p||m.length===0){T.key==="Enter"&&v(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(F=>(F+1)%m.length);break;case"ArrowUp":T.preventDefault(),x(F=>(F-1+m.length)%m.length);break;case"Enter":T.preventDefault(),f>=0&&f<m.length?$(m[f]):v(n);break;case"Escape":T.preventDefault(),u(!1);break}},[p,m,f,n,v,$]),C=g.useCallback((T,F)=>{F.stopPropagation(),Yp(T),y(En()),h(R=>R.filter(E=>!(E.type==="history"&&E.text===T)))},[]),M=g.useCallback(T=>{T.stopPropagation(),Kp(),y([]),h([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const T=b.current.children;T[f]&&T[f].scrollIntoView({block:"nearest"})}},[f]);const N=!n.trim()&&k.length>0;return t.jsxs("div",{ref:j,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:w,type:"text",placeholder:d,value:n,onChange:T=>{o(T.target.value),u(!0)},onCompositionStart:()=>{S.current=!0},onCompositionEnd:()=>{S.current=!1},onFocus:()=>{u(!0)},onKeyDown:_,style:{width:"100%",padding:"8px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&m.length>0&&t.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:[N&&t.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:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:M,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((T,F)=>t.jsxs("div",{onClick:()=>$(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:F===f?i("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:T.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:T.text}),T.entry&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[T.entry.type],T.entry.edition&&` · ${T.entry.edition}`,T.entry.author&&` · ${T.entry.author}`]}),T.type==="history"&&t.jsx("button",{onClick:R=>C(T.text,R),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${T.type}-${T.text}-${F}`))]})]})},fn=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${e}`),verticalAlign:"middle"}}),bi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Oa=new Set(["work","book","entity"]);function qp(e){return Da(e)||!!e.sort}function Xp(e,n){return n.sort&&Oa.has(e)?n.sort:void 0}const yi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],ji=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Ha=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Fa={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function vi(e){return e.dynasty.length+e.classification.length+(e.hasImage?1:0)+(e.hasText?1:0)+(e.hasCollated?1:0)+(e.loss?1:0)}function Da(e){return vi(e)>0}function Zp(e){const n=[];return e.dynasty.length&&n.push("dynasty"),e.classification.length&&n.push("classification"),e.hasImage&&n.push("hasImage"),e.hasText&&n.push("hasText"),e.hasCollated&&n.push("hasCollated"),e.loss&&n.push("loss"),n}function Ua(e,n){const o=Fa[e];return Zp(n).every(r=>o.has(r))}const _n=e=>JSON.stringify(e);function Jp(e,n){if(!Ua(n,e))return null;const o=[];if(e.dynasty.length){const r=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=yi.find(l=>l.key===s))==null?void 0:a.values)??[]})));r.length===1?o.push(`dynasty = ${_n(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(_n).join(", ")}]`)}return e.classification.length&&o.push(e.classification.length===1?`classification = ${_n(e.classification[0])}`:`classification IN [${e.classification.map(_n).join(", ")}]`),e.hasImage&&o.push("has_image = true"),e.hasText&&o.push("has_text = true"),e.hasCollated&&o.push("has_collated = true"),e.loss&&o.push(`loss_status = ${_n(e.loss)}`),o.join(" AND ")}const it={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},Va="_";function li(e,n=new URLSearchParams){for(const o of Object.values(it))n.delete(o);return e.dynasty.length&&n.set(it.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(it.classification,e.classification.map(o=>o||Va).join(",")),e.hasImage&&n.set(it.hasImage,"1"),e.hasText&&n.set(it.hasText,"1"),e.hasCollated&&n.set(it.hasCollated,"1"),e.loss&&n.set(it.loss,e.loss),e.sort&&n.set(it.sort,e.sort),n}function Qp(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),o=new Set(yi.map(a=>a.key)),r=new Set(ji.map(a=>a.value)),s=e.get(it.loss);return{dynasty:Array.from(new Set(n(it.dynasty).filter(a=>o.has(a)))),classification:Array.from(new Set(n(it.classification).map(a=>a===Va?"":a).filter(a=>r.has(a)))),hasImage:e.get(it.hasImage)==="1",hasText:e.get(it.hasText)==="1"||e.get(it.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(a=>a===e.get(it.sort))??""}}function eu(e,n){return JSON.stringify([e.dynasty.slice().sort(),e.classification.slice().sort(),e.hasImage,e.hasText,e.hasCollated,e.loss,e.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function ss(e,n){return e.includes(n)?e.filter(o=>o!==n):[...e,n]}const tu=({filters:e,onChange:n})=>{const o=Te(),r=o.searchV4,{convert:s}=Le(),[a,l]=g.useState(!1),d=g.useId(),c=vi(e),p=u=>n({...e,...u});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(r.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(u=>!u),children:[t.jsxs("span",{children:[s(r.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(ut(r.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?r.collapse:r.expand)," ",a?"▴":"▾"]})]}),t.jsxs("div",{className:"bim-sr-filters",id:d,"data-open":a?"true":"false",...a?{}:{"data-collapsed":"true"},children:[t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:yi.map(u=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(u.key),onClick:()=>p({dynasty:ss(e.dynasty,u.key)}),children:s(u.key)},u.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.classification)}),ji.map(u=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(u.value),onChange:()=>p({classification:ss(e.classification,u.value)})}),u.value?s(u.label):o.searchPage.unclassified]},u.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(r.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:u=>p({hasImage:u.target.checked})}),s(r.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:u=>p({hasText:u.target.checked})}),s(r.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(r.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:Ha.map(u=>t.jsx("button",{type:"button","aria-pressed":e.loss===u.value,onClick:()=>p({loss:u.value}),children:o.searchPage.loss[u.value||"all"]},u.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...bi,sort:e.sort}),children:s(r.clearAllFilters)})]})]})};function Ga({text:e,query:n}){const o=(n??"").trim();if(!o||!e)return t.jsx(t.Fragment,{children:e});const r=e.toLowerCase(),s=o.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=r.indexOf(s,l);if(c<0){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{className:"bim-sr-hl",children:e.slice(c,c+s.length)},d++)),l=c+s.length}return t.jsx(t.Fragment,{children:a})}const as=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=Te(),a=s.searchV4,{convert:l}=Le(),d=Ze();return t.jsx("div",{className:"bim-sr-tablewrap",children:t.jsxs("table",{className:"bim-sr-table",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"34%"}}),t.jsx("col",{style:{width:"8%"}}),t.jsx("col",{style:{width:"19%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"12%"}}),t.jsx("col",{style:{width:"14%"}})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:l(a.colTitle)}),t.jsx("th",{scope:"col",children:l(a.colType)}),t.jsx("th",{scope:"col",children:l(a.colAuthor)}),t.jsx("th",{scope:"col",children:l(a.colEra)}),t.jsx("th",{scope:"col",children:l(a.colClass)}),t.jsx("th",{scope:"col",style:{textAlign:"right"},children:l(a.colResource)})]})}),t.jsx("tbody",{children:e.map(c=>{const p=l(c.title||c.primary_name||c.id),u=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",h=c.type==="book"?c.era??c.dynasty:c.dynasty,f=h?l(h):"",x=c.classification?l(c.classification):"",k=[];c.has_image&&k.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&k.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&k.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const y=[m,f,x].filter(Boolean).join(" · ");return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-sr-c-title",children:[t.jsxs("div",{className:"bim-sr-tl",children:[t.jsx("a",{href:d(c.id),onClick:w=>o(c,w),children:t.jsx(Ga,{text:p,query:n?l(n):void 0})}),u&&t.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&t.jsx("span",{className:"bim-sr-sub",children:y})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(fn,{type:c.type,size:6})," ",r(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:k.map(w=>t.jsx("span",{className:`bim-sr-tag ${w.cls}`,children:l(w.label)},w.label))})]},c.id)})})]})})},nu=`
|
|
2
2
|
.bim-sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 10px; }
|
|
3
3
|
.bim-sc { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 12px; border: 1px solid ${i("rule")}; background: ${i("card-bg")}; color: inherit; text-decoration: none; }
|
|
4
4
|
.bim-sc:hover { border-color: ${i("rule-dashed")}; box-shadow: ${i("fr-shadow")}; }
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
.bim-sc-fl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: ${i("aux-fg")}; }
|
|
13
13
|
.bim-sc-tags { display: flex; gap: 4px; flex: none; }
|
|
14
14
|
:root[data-layout="boxed"] .bim-sc { box-shadow: none; }
|
|
15
|
-
`,
|
|
15
|
+
`,ls=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=Te(),a=s.searchV4,{convert:l}=Le(),d=Ze();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:nu}),e.map(c=>{const p=l(c.title||c.primary_name||c.id),u=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",h=[c.type==="entity"?c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:"":`${c.dynasty?`〔${l(c.dynasty)}〕`:""}${c.author?l(c.author):""}`,c.type==="book"&&c.edition?l(c.edition):"",u].filter(Boolean).join(" · "),f=[r(c.type),c.classification?l(c.classification):""].filter(Boolean).join(" · "),x=[];return c.has_image&&x.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&x.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&x.push({label:a.tagLost,cls:"bim-sr-tag--lost"}),t.jsxs("a",{className:"bim-sc",href:d(c.id),onClick:k=>o(c,k),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(Ga,{text:p,query:n?l(n):void 0})}),h&&t.jsx("span",{className:"bim-sc-m",children:h}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:Lo(c.descriptionSnippet).map((k,y)=>k.marked?t.jsx("mark",{children:l(k.text)},y):t.jsx(g.Fragment,{children:l(k.text)},y))}),t.jsx("span",{className:"bim-sc-sp"}),t.jsxs("div",{className:"bim-sc-f",children:[t.jsx("span",{className:"bim-sc-fl",children:f}),t.jsx("span",{className:"bim-sc-tags",children:x.map(k=>t.jsx("span",{className:`bim-sr-tag ${k.cls}`,children:l(k.label)},k.label))})]})]},c.id)})]})};function iu(e,n){const o=new Set([1,n,e-1,e,e+1].filter(a=>a>=1&&a<=n)),r=Array.from(o).sort((a,l)=>a-l),s=[];return r.forEach((a,l)=>{l>0&&a-r[l-1]>1&&s.push("gap"),s.push(a)}),s}function ou(e,n,o){const r=Math.max(1,Math.ceil(n/o));return Math.min(Math.max(1,e),r)}const ru=({page:e,pageSize:n,total:o,totalLabel:r,onPage:s})=>{const a=Te().searchV4,{convert:l}=Le(),d=Math.max(1,Math.ceil(o/n));return o<=0?null:t.jsxs("nav",{className:"bim-sr-pager","aria-label":l(a.pagerLabel),children:[t.jsx("span",{className:"bim-sr-info",children:l(ut(a.pageInfo,{total:r??o.toLocaleString(),size:n,page:e,pages:d}))}),d>1&&t.jsxs("ul",{children:[t.jsx("li",{children:t.jsx("button",{type:"button",disabled:e<=1,onClick:()=>s(e-1),children:l(a.prevPage)})}),iu(e,d).map((c,p)=>c==="gap"?t.jsx("li",{className:"bim-sr-gap","aria-hidden":"true",children:"…"},`g${p}`):t.jsx("li",{children:t.jsx("button",{type:"button","aria-current":c===e?"page":void 0,"aria-label":`${c}`,onClick:()=>s(c),children:c})},c)),t.jsx("li",{children:t.jsx("button",{type:"button",disabled:e>=d,onClick:()=>s(e+1),children:l(a.nextPage)})})]})]})},Ya="(max-width: 719px)",su=`${Ya}, (pointer: coarse)`,au=`
|
|
16
16
|
.bim-sr-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; align-items: start; padding: 0 20px; }
|
|
17
17
|
.bim-sr-layout[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
|
|
18
18
|
.bim-sr-aside { position: sticky; top: calc(${i("reader-top")} + 16px); padding-top: 2px; }
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
.bim-sr-pager .bim-sr-gap { color: ${i("aux-fg")}; padding: 0 2px; }
|
|
82
82
|
.bim-sr-empty { padding: 60px 0; text-align: center; font-size: 14px; color: ${i("meta-fg")}; }
|
|
83
83
|
|
|
84
|
-
@media ${
|
|
84
|
+
@media ${Ya} {
|
|
85
85
|
.bim-sr-layout { grid-template-columns: minmax(0, 1fr); row-gap: 16px; padding: 0 16px; }
|
|
86
86
|
.bim-sr-aside { position: static; }
|
|
87
87
|
.bim-sr-fbtn {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
.bim-sr-table td.bim-sr-c-res { text-align: left; padding-bottom: 2px; }
|
|
103
103
|
.bim-sr-table td.bim-sr-c-res:empty { display: none; }
|
|
104
104
|
}
|
|
105
|
-
@media ${
|
|
105
|
+
@media ${su} {
|
|
106
106
|
.bim-sr-chip { min-height: 36px; }
|
|
107
107
|
.bim-sr-opt { min-height: 44px; }
|
|
108
108
|
.bim-sr-seg button { min-height: 44px; }
|
|
@@ -117,10 +117,10 @@
|
|
|
117
117
|
:root[data-layout="boxed"] .bim-sr-table th { background: ${i("fr-bg")}; }
|
|
118
118
|
/* 墨:主色与正文对比不到 3:1,标题链接另加下划线 */
|
|
119
119
|
:root[data-theme="ink"] .bim-sr-table td.bim-sr-c-title a { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; }
|
|
120
|
-
`,Ho="bim-search-view",Vi=50,ls=5,En=1e3;function ii(e){return e>=En?`${En.toLocaleString()}+`:e.toLocaleString()}const su={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function au(e){return e&&su[e.toLowerCase()]||"all"}function lu(e){return e==="all"?null:e}const cs=["work","collection","book","entity"],cu={work:"works",collection:"collections",book:"books",entity:"entities"},du={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function pu(){try{return window.localStorage.getItem(Ho)==="card"?"card":"table"}catch{return"table"}}function uu(e){try{window.localStorage.setItem(Ho,e)}catch{}}const nn=(e,n)=>(e==null?void 0:e[du[n]])??0,Gi=(e,n)=>(e==null?void 0:e[cu[n]])??[],Ya=({transport:e,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const u=Te(),m=u.searchV4,{convert:h}=Ae(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?o:bi,[f,o]),[k,y]=g.useState("table");g.useEffect(()=>{y(pu())},[]);const w=Z=>{y(Z),uu(Z)},[b,j]=g.useState(l??"all"),S=g.useRef(b);S.current=b,g.useEffect(()=>{l!==void 0&&l!==S.current&&(j(l),$(1))},[l]);const[v,$]=g.useState(c&&c>0?c:1),_=g.useRef(v);_.current=v,g.useEffect(()=>{c!==void 0&&c>0&&c!==_.current&&$(c)},[c]);const C=g.useRef(null),M=g.useCallback(Z=>{var oe;$(Z),p==null||p(Z);const le=C.current;le&&le.getBoundingClientRect().top<0&&((oe=le.scrollIntoView)==null||oe.call(le,{block:"start",behavior:"instant"}))},[p]),[N,T]=g.useState(null),[F,R]=g.useState(null),[E,L]=g.useState(!1),[I,P]=g.useState(""),V=li(x).toString(),X=vi(x)>0,D=li({...x,sort:""}).toString(),O=g.useRef({query:n,filterOnlyKey:D,sort:x.sort});g.useEffect(()=>{const Z=O.current;Z.query!==n||Z.filterOnlyKey!==D?(j("all"),$(1)):Z.sort!==x.sort&&$(1),O.current={query:n,filterOnlyKey:D,sort:x.sort}},[n,D,x.sort]),g.useEffect(()=>{let Z=!1;return L(!0),P(""),(async()=>{try{let le;if(e.searchAll)le=await e.searchAll(n,ls,x);else{const oe=["work","book","collection","entity"],he=await Promise.all(oe.map(U=>e.search(n,U,{page:1,pageSize:ls,filters:x})));le={works:he[0].entries,books:he[1].entries,collections:he[2].entries,entities:he[3].entries,totalWorks:he[0].total,totalBooks:he[1].total,totalCollections:he[2].total,totalEntities:he[3].total}}Z||T(le)}catch(le){Z||(P(le instanceof Error?le.message:String(le)),T(null))}finally{Z||L(!1)}})(),()=>{Z=!0}},[e,n,V]);const A=b;g.useEffect(()=>{if(b==="all"){R(null);return}let Z=!1;return L(!0),(async()=>{try{const le=await e.search(n,b,{page:v,pageSize:Vi,filters:x});Z||R({key:A,entries:le.entries,total:le.total})}catch(le){Z||(P(le instanceof Error?le.message:String(le)),R(null))}finally{Z||L(!1)}})(),()=>{Z=!0}},[e,n,V,b,v]);const G=F&&F.key===A?F:null;g.useEffect(()=>{if(b==="all"||!G||E)return;const Z=Math.min(G.total,En),le=nu(v,Z,Vi);G.entries.length===0&&Z>0&&le!==v&&($(le),p==null||p(le))},[b,G,E,v]);const se=g.useMemo(()=>cs.filter(Z=>nn(N,Z)>0),[N]),Q=se.reduce((Z,le)=>Z+nn(N,le),0),ve=se.some(Z=>nn(N,Z)>=En)?`${Q.toLocaleString()}+`:Q.toLocaleString(),ne=!E&&!I&&N!==null&&Q===0,ce=g.useCallback(Z=>{j(Z),$(1),d==null||d(Z)},[d]),We=g.useMemo(()=>{const Z=[];return x.dynasty.forEach(le=>Z.push({name:le,remove:()=>r({...x,dynasty:x.dynasty.filter(oe=>oe!==le)})})),x.classification.forEach(le=>{var oe;return Z.push({name:le?((oe=ji.find(he=>he.value===le))==null?void 0:oe.label)??le:u.searchPage.unclassified,remove:()=>r({...x,classification:x.classification.filter(he=>he!==le)})})}),x.hasImage&&Z.push({name:m.hasImage,remove:()=>r({...x,hasImage:!1})}),x.hasText&&Z.push({name:m.hasText,remove:()=>r({...x,hasText:!1})}),x.hasCollated&&Z.push({name:m.hasCollated,remove:()=>r({...x,hasCollated:!1})}),x.loss&&Z.push({name:`${m.extant}:${u.searchPage.loss[x.loss]}`,remove:()=>r({...x,loss:""})}),Z},[x,r,m,u]),ke={query:n,onEntryLinkClick:s,typeName:a},Pe=Z=>k==="table"?t.jsx(ss,{entries:Z,...ke}):t.jsx(as,{entries:Z,...ke}),Ee=cs.flatMap(Z=>Gi(N,Z));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:ru}),f&&t.jsx(Qp,{filters:x,onChange:r}),t.jsxs("div",{className:"bim-sr-main","aria-busy":E,ref:C,children:[se.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":u.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${i("rule")}`},children:[t.jsxs(ds,{on:b==="all",onClick:()=>ce("all"),children:[u.search.allTab," ",t.jsx("small",{children:ve})]}),se.map(Z=>t.jsxs(ds,{on:b===Z,onClick:()=>ce(Z),children:[a(Z)," ",t.jsx("small",{children:ii(nn(N,Z))})]},Z))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":h(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>r({...x,sort:""}),children:h(m.sortRelevance)}),["era","title"].map(Z=>{const le=x.sort.startsWith(`${Z}:`)?x.sort.endsWith("desc")?"desc":"asc":null,oe=Z==="era"?m.sortEra:m.sortTitle,he=Z==="era"?le==="desc"?m.sortEraDesc:m.sortEraAsc:le==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":le!==null,title:h(he),onClick:()=>r({...x,sort:`${Z}:${le==="asc"?"desc":"asc"}`}),children:[h(oe),le?t.jsxs("span",{"aria-hidden":"true",children:[" ",le==="asc"?"↑":"↓"]}):null]},Z)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":h(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":k==="table",onClick:()=>w("table"),children:h(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":k==="card",onClick:()=>w("card"),children:h(m.viewCard)})]})]}),X&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:h(mt(m.filteredCount,{n:ve}))}),We.map(Z=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":h(mt(m.removeFilter,{name:Z.name})),onClick:Z.remove,children:[h(Z.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},Z.name))]}),I&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:I}),ne&&t.jsx("div",{className:"bim-sr-empty",children:h(X?m.emptyFiltered:mt(u.search.noResultsFor,{query:n}))}),!I&&!ne&&b==="all"&&N&&(k==="table"?t.jsxs(t.Fragment,{children:[t.jsx(ss,{entries:Ee,...ke}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:h(m.limitedNote)})]}):t.jsx(t.Fragment,{children:se.map(Z=>t.jsxs("section",{style:{marginTop:22},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[t.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[t.jsx(fn,{type:Z,size:8}),a(Z),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[ii(nn(N,Z))," ",u.unit.items]})]}),nn(N,Z)>Gi(N,Z).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>ce(Z),children:u.action.viewAll})]}),t.jsx(as,{entries:Gi(N,Z),...ke})]},Z))})),!I&&b!=="all"&&!G&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:u.search.loading}),!I&&b!=="all"&&G&&G.entries.length>0&&t.jsxs(t.Fragment,{children:[Pe(G.entries),t.jsx(iu,{page:v,pageSize:Vi,total:Math.min(G.total,En),totalLabel:ii(G.total),onPage:M})]}),!I&&b!=="all"&&G&&G.entries.length===0&&!E&&t.jsxs("div",{className:"bim-sr-empty",children:[h(X?m.emptyFiltered:mt(u.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>ce("all"),children:u.search.allTab})})]})]})]})};function ds({on:e,onClick:n,children:o}){return t.jsx("button",{type:"button","aria-pressed":e,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:i(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${i("accent")}`:"none"},children:o})}const ln="bim-recent-ids",ps="bim-recent-entries",us=50;function Mt(){try{const e=localStorage.getItem(ln);if(e)return JSON.parse(e);const n=localStorage.getItem(ps);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(ln,JSON.stringify(o)),localStorage.removeItem(ps),o}return[]}catch{return[]}}function co(e){try{const n=Mt().filter(o=>o!==e);n.unshift(e),n.length>us&&(n.length=us),localStorage.setItem(ln,JSON.stringify(n))}catch{}}function Ka(e){try{const n=Mt().filter(o=>o!==e);localStorage.setItem(ln,JSON.stringify(n))}catch{}}function Fo(){try{localStorage.removeItem(ln)}catch{}}async function Do(e,n){var o,r,s;try{if(e.getEntry){const l=await e.getEntry(n);if(l)return l}const a=await e.getItem(n);if(a){const l=a.authors;return{id:n,title:a.title||n,type:a.type||"work",author:(o=l==null?void 0:l[0])==null?void 0:o.name,dynasty:(r=l==null?void 0:l[0])==null?void 0:r.dynasty,role:(s=l==null?void 0:l[0])==null?void 0:s.role,edition:a.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const Yi=5,mu=50,hu=200,ms={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},po=({transport:e,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:u="compact",renderEntry:m,initialQuery:h,onQueryChange:f,headerRight:x,reserveViewportHeight:k=!1,filtersEnabled:y=!1,filters:w=bi,onFiltersChange:b,resultTab:j,onResultTabChange:S,resultPage:v,onResultPageChange:$})=>{const _=Te(),C=[{type:"work",name:_.indexType.work,key:"works"},{type:"book",name:_.indexType.book,key:"books"},{type:"collection",name:_.indexType.collection,key:"collections"},{type:"entity",name:_.indexType.entity,key:"entities"}],M=["work","collection","book","entity"],[N,T]=g.useState(h??""),[F,R]=g.useState(null),[E,L]=g.useState(h??""),I=li(w).toString(),[P,V]=g.useState(w);g.useEffect(()=>{V(w)},[I]);const X=z=>{V(z),b==null||b(z)},[D,O]=g.useState(null),[A,G]=g.useState("all"),[se,Q]=g.useState(!1),[ve,ne]=g.useState(null),[ce,We]=g.useState(""),[ke,Pe]=g.useState(!(h!=null&&h.trim())),[Ee,Z]=g.useState(Mt),[le,oe]=g.useState([]),[he,U]=g.useState(!1),[$e,me]=g.useState(!1),[Ce,Y]=g.useState(null),[ze,Me]=g.useState(null),B=g.useRef(void 0),te=g.useRef(!1),xe=g.useCallback(async(z,ie)=>{if(!z.trim()){Pe(!0),R(null),O(null);return}if(Pe(!1),y){L(z);return}Q(!0),We("");try{if(e.searchAll){const ae=await e.searchAll(z,ie??Yi);R(ae)}else{const ae=["work","book","collection","entity"],be=await Promise.all(ae.map(je=>e.search(z,je,{page:1,pageSize:ie??Yi})));R({works:be[0].entries,books:be[1].entries,collections:be[2].entries,entities:be[3].entries,totalWorks:be[0].total,totalBooks:be[1].total,totalCollections:be[2].total,totalEntities:be[3].total})}}catch(ae){We(ae instanceof Error?ae.message:String(ae)),R(null)}finally{Q(!1)}},[e,y]);g.useEffect(()=>{let z=!1;const ie=()=>{var Ie,K;const ae=["work","book","collection","entity"],be=Promise.all(ae.map(fe=>e.loadEntries(fe,{page:1,pageSize:1}).catch(()=>({total:0})))),je=((Ie=e.getResourceCounts)==null?void 0:Ie.call(e).catch(()=>null))??Promise.resolve(null),ge=((K=e.getSubtypeStats)==null?void 0:K.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([be,je,ge]).then(([fe,Ne,q])=>{z||(Y({works:fe[0].total,books:fe[1].total,collections:fe[2].total,entities:fe[3].total,hasText:Ne==null?void 0:Ne.hasText,hasImage:Ne==null?void 0:Ne.hasImage}),q&&Me(q))})};return e.getCounts?e.getCounts().then(ae=>{var be,je;z||(Y({works:ae.works,books:ae.books,collections:ae.collections,entities:ae.entities,hasText:(be=ae.resourceCounts)==null?void 0:be.hasText,hasImage:(je=ae.resourceCounts)==null?void 0:je.hasImage}),ae.subtypeStats&&Me(ae.subtypeStats))}).catch(()=>{z||ie()}):ie(),()=>{z=!0}},[e]),g.useEffect(()=>{te.current||!(h!=null&&h.trim())||(te.current=!0,xe(h))},[h,xe]);const Re=g.useCallback(z=>{if(T(z),!z.trim()){f==null||f(z),Pe(!0),R(null),O(null),G("all");return}B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{O(null),G("all"),f==null||f(z),xe(z)},hu)},[xe,f]),H=g.useCallback(z=>{B.current&&clearTimeout(B.current),G("all"),f==null||f(z),xe(z)},[xe,f]),de=g.useCallback(z=>{O(z),xe(N,mu)},[N,xe]);g.useEffect(()=>{if(!Ee.length){oe([]);return}let z=!1;return U(!0),Promise.all(Ee.slice(0,10).map(ie=>Do(e,ie))).then(ie=>{z||(oe(ie),U(!1))}),()=>{z=!0}},[Ee,e]);const ee=z=>{ne(z.id),co(z.id),Z(Mt()),r==null||r(z)},ye=(z,ie)=>{if(r&&fu(ie)){ie.preventDefault(),ee(z);return}co(z.id),Z(Mt())},Se=z=>{Ka(z),Z(Mt())},Be=()=>{Fo(),Z([])},De=z=>C.find(ie=>ie.type===z),Je=!ke&&!F&&!ce,He=F&&(F.works.length>0||F.books.length>0||F.collections.length>0),Ue=t.jsxs(t.Fragment,{children:[t.jsx(Ba,{transport:e,value:N,onChange:Re,onSearch:H,onEntrySelect:ee}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const z=N.trim();z&&Ma(z),H(N)},children:_.searchPage.submit}),s&&t.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:_.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:k?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:xu+(y?bu:"")}),(!y||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:i("fg")},children:_.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(Pa,{variant:"index-browser",indexSource:n,syncConfig:o,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),y?t.jsxs("div",{className:"bim-ib-bar","data-nofilters":e.supportsSearchFilters?void 0:"true",children:[t.jsx("span",{"aria-hidden":"true"}),t.jsx("div",{className:"bim-ib-bar-main",children:Ue})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Ue}),ke&&t.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:Ce&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:ze?t.jsxs(t.Fragment,{children:[(ze.book??0)>0&&t.jsxs(t.Fragment,{children:[_.searchPage.statBook," ",t.jsx("strong",{style:{color:i("fg")},children:ze.book.toLocaleString()})," ",_.unit.bu,_.searchPage.statComma,t.jsx("strong",{style:{color:i("fg")},children:Ce.books.toLocaleString()})," ",_.searchPage.statBookCopies]}),ze.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statArticle," ",t.jsx("strong",{style:{color:i("fg")},children:ze.article.toLocaleString()})," ",_.searchPage.statArticleUnit]}):null,ze.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statPoem," ",t.jsx("strong",{style:{color:i("fg")},children:ze.poem.toLocaleString()})," ",_.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statCollection," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[_.indexType.work," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.book," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.collection," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.collections.toLocaleString()}),Ce.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.entity," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.entities.toLocaleString()})]})]})}),Ce.hasImage!=null&&Ce.hasText!=null&&t.jsxs("span",{children:[_.resourceType.image," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.resourceType.text," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.hasText.toLocaleString()})]})]})}),y&&!ke&&t.jsx(Ya,{transport:e,query:E,filters:P,onFiltersChange:X,onEntryLinkClick:ye,typeName:z=>De(z).name,tab:j,onTabChange:S,page:v,onPageChange:$}),!(y&&!ke)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:se||Je?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:gu,boxSizing:"border-box"},children:_.search.searching}):ce?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:i("desc-fg")},children:ce})}):ke?t.jsx("div",{style:{flex:1},children:he?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:_.search.loading}):le.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:_.search.recentBrowse}),t.jsx("button",{onClick:Be,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:_.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:le.slice(0,$e?10:3).map(z=>z.notFound?t.jsx(ku,{id:z.id,onRemove:Se,t:_},z.id):t.jsx(hs,{entry:z,selected:ve===z.id,onClick:ye,getConfig:De,onRemove:Se},z.id))}),!$e&&le.length>3&&t.jsx("button",{onClick:()=>me(!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:_.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:_.search.searchTitle}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.searchSubtitle})]})}):He?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:yu}),(()=>{const z=ge=>F[ms[ge]]??0,ie=M.map(ge=>C.find(Ie=>Ie.type===ge)).filter(ge=>z(ge.key)>0);if(ie.length<2)return null;const ae=ie.reduce((ge,Ie)=>ge+z(Ie.key),0),be=ge=>{if(G(ge),ge!=="all"&&D!==ge){const Ie=C.find(fe=>fe.type===ge),K=(F[Ie.key]??[]).length;z(Ie.key)>K&&de(ge)}},je=ge=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(ge?"fg":"desc-fg"),fontWeight:ge?700:400,boxShadow:ge?`inset 0 -2px 0 ${i("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":_.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":A==="all",style:je(A==="all"),onClick:()=>be("all"),children:[_.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:ae.toLocaleString()})]}),ie.map(ge=>t.jsxs("button",{type:"button","aria-pressed":A===ge.type,style:je(A===ge.type),onClick:()=>be(ge.type),children:[ge.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:z(ge.key).toLocaleString()})]},ge.type))]})})(),C.map(({type:z,name:ie,key:ae})=>{const be=F[ae]??[],je=ms[ae],ge=F[je]??0;if(be.length===0||A!=="all"&&A!==z)return null;const K=A==="all"&&!(D===z)&&ge>Yi;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[t.jsx(fn,{type:z})," ",ie,t.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[ge," ",_.unit.items]})]}),K&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>de(z),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:_.action.viewAll})]}),t.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:be.map(fe=>{if(m)return t.jsx(g.Fragment,{children:m(fe)},fe.id);const Ne=u==="card"?vu:hs;return t.jsx(Ne,{entry:fe,selected:ve===fe.id,onClick:ye,getConfig:De,query:N},fe.id)})})]},z)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:mt(_.search.noResultsFor,{query:N})}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.tryOther})]})})]})},gu=240;function fu(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const xu=`
|
|
120
|
+
`,Ho="bim-search-view",Vi=50,cs=5,In=1e3;function ii(e){return e>=In?`${In.toLocaleString()}+`:e.toLocaleString()}const lu={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function cu(e){return e&&lu[e.toLowerCase()]||"all"}function du(e){return e==="all"?null:e}const ds=["work","collection","book","entity"],pu={work:"works",collection:"collections",book:"books",entity:"entities"},uu={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function mu(){try{return window.localStorage.getItem(Ho)==="card"?"card":"table"}catch{return"table"}}function hu(e){try{window.localStorage.setItem(Ho,e)}catch{}}const nn=(e,n)=>(e==null?void 0:e[uu[n]])??0,Gi=(e,n)=>(e==null?void 0:e[pu[n]])??[],Ka=({transport:e,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const u=Te(),m=u.searchV4,{convert:h}=Le(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?o:bi,[f,o]),[k,y]=g.useState("table");g.useEffect(()=>{y(mu())},[]);const w=Z=>{y(Z),hu(Z)},[b,j]=g.useState(l??"all"),S=g.useRef(b);S.current=b,g.useEffect(()=>{l!==void 0&&l!==S.current&&(j(l),$(1))},[l]);const[v,$]=g.useState(c&&c>0?c:1),_=g.useRef(v);_.current=v,g.useEffect(()=>{c!==void 0&&c>0&&c!==_.current&&$(c)},[c]);const C=g.useRef(null),M=g.useCallback(Z=>{var oe;$(Z),p==null||p(Z);const ae=C.current;ae&&ae.getBoundingClientRect().top<0&&((oe=ae.scrollIntoView)==null||oe.call(ae,{block:"start",behavior:"instant"}))},[p]),[N,T]=g.useState(null),[F,R]=g.useState(null),[E,L]=g.useState(!1),[I,P]=g.useState(""),V=li(x).toString(),X=vi(x)>0,D=li({...x,sort:""}).toString(),O=g.useRef({query:n,filterOnlyKey:D,sort:x.sort});g.useEffect(()=>{const Z=O.current;Z.query!==n||Z.filterOnlyKey!==D?(j("all"),$(1)):Z.sort!==x.sort&&$(1),O.current={query:n,filterOnlyKey:D,sort:x.sort}},[n,D,x.sort]),g.useEffect(()=>{let Z=!1;return L(!0),P(""),(async()=>{try{let ae;if(e.searchAll)ae=await e.searchAll(n,cs,x);else{const oe=["work","book","collection","entity"],fe=await Promise.all(oe.map(U=>e.search(n,U,{page:1,pageSize:cs,filters:x})));ae={works:fe[0].entries,books:fe[1].entries,collections:fe[2].entries,entities:fe[3].entries,totalWorks:fe[0].total,totalBooks:fe[1].total,totalCollections:fe[2].total,totalEntities:fe[3].total}}Z||T(ae)}catch(ae){Z||(P(ae instanceof Error?ae.message:String(ae)),T(null))}finally{Z||L(!1)}})(),()=>{Z=!0}},[e,n,V]);const A=b;g.useEffect(()=>{if(b==="all"){R(null);return}let Z=!1;return L(!0),(async()=>{try{const ae=await e.search(n,b,{page:v,pageSize:Vi,filters:x});Z||R({key:A,entries:ae.entries,total:ae.total})}catch(ae){Z||(P(ae instanceof Error?ae.message:String(ae)),R(null))}finally{Z||L(!1)}})(),()=>{Z=!0}},[e,n,V,b,v]);const G=F&&F.key===A?F:null;g.useEffect(()=>{if(b==="all"||!G||E)return;const Z=Math.min(G.total,In),ae=ou(v,Z,Vi);G.entries.length===0&&Z>0&&ae!==v&&($(ae),p==null||p(ae))},[b,G,E,v]);const se=g.useMemo(()=>ds.filter(Z=>nn(N,Z)>0),[N]),Q=se.reduce((Z,ae)=>Z+nn(N,ae),0),ke=se.some(Z=>nn(N,Z)>=In)?`${Q.toLocaleString()}+`:Q.toLocaleString(),ne=!E&&!I&&N!==null&&Q===0,de=g.useCallback(Z=>{j(Z),$(1),d==null||d(Z)},[d]),We=g.useMemo(()=>{const Z=[];return x.dynasty.forEach(ae=>Z.push({name:ae,remove:()=>r({...x,dynasty:x.dynasty.filter(oe=>oe!==ae)})})),x.classification.forEach(ae=>{var oe;return Z.push({name:ae?((oe=ji.find(fe=>fe.value===ae))==null?void 0:oe.label)??ae:u.searchPage.unclassified,remove:()=>r({...x,classification:x.classification.filter(fe=>fe!==ae)})})}),x.hasImage&&Z.push({name:m.hasImage,remove:()=>r({...x,hasImage:!1})}),x.hasText&&Z.push({name:m.hasText,remove:()=>r({...x,hasText:!1})}),x.hasCollated&&Z.push({name:m.hasCollated,remove:()=>r({...x,hasCollated:!1})}),x.loss&&Z.push({name:`${m.extant}:${u.searchPage.loss[x.loss]}`,remove:()=>r({...x,loss:""})}),Z},[x,r,m,u]),we={query:n,onEntryLinkClick:s,typeName:a},Pe=Z=>k==="table"?t.jsx(as,{entries:Z,...we}):t.jsx(ls,{entries:Z,...we}),Ee=ds.flatMap(Z=>Gi(N,Z));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:au}),f&&t.jsx(tu,{filters:x,onChange:r}),t.jsxs("div",{className:"bim-sr-main","aria-busy":E,ref:C,children:[se.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":u.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${i("rule")}`},children:[t.jsxs(ps,{on:b==="all",onClick:()=>de("all"),children:[u.search.allTab," ",t.jsx("small",{children:ke})]}),se.map(Z=>t.jsxs(ps,{on:b===Z,onClick:()=>de(Z),children:[a(Z)," ",t.jsx("small",{children:ii(nn(N,Z))})]},Z))]}),t.jsxs("div",{className:"bim-sr-tools",children:[f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":h(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>r({...x,sort:""}),children:h(m.sortRelevance)}),["era","title"].map(Z=>{const ae=x.sort.startsWith(`${Z}:`)?x.sort.endsWith("desc")?"desc":"asc":null,oe=Z==="era"?m.sortEra:m.sortTitle,fe=Z==="era"?ae==="desc"?m.sortEraDesc:m.sortEraAsc:ae==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":ae!==null,title:h(fe),onClick:()=>r({...x,sort:`${Z}:${ae==="asc"?"desc":"asc"}`}),children:[h(oe),ae?t.jsxs("span",{"aria-hidden":"true",children:[" ",ae==="asc"?"↑":"↓"]}):null]},Z)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":h(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":k==="table",onClick:()=>w("table"),children:h(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":k==="card",onClick:()=>w("card"),children:h(m.viewCard)})]})]}),X&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:h(ut(m.filteredCount,{n:ke}))}),We.map(Z=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":h(ut(m.removeFilter,{name:Z.name})),onClick:Z.remove,children:[h(Z.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},Z.name))]}),I&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:I}),ne&&t.jsx("div",{className:"bim-sr-empty",children:h(X?m.emptyFiltered:ut(u.search.noResultsFor,{query:n}))}),!I&&!ne&&b==="all"&&N&&(k==="table"?t.jsxs(t.Fragment,{children:[t.jsx(as,{entries:Ee,...we}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:h(m.limitedNote)})]}):t.jsx(t.Fragment,{children:se.map(Z=>t.jsxs("section",{style:{marginTop:22},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[t.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[t.jsx(fn,{type:Z,size:8}),a(Z),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[ii(nn(N,Z))," ",u.unit.items]})]}),nn(N,Z)>Gi(N,Z).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>de(Z),children:u.action.viewAll})]}),t.jsx(ls,{entries:Gi(N,Z),...we})]},Z))})),!I&&b!=="all"&&!G&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:u.search.loading}),!I&&b!=="all"&&G&&G.entries.length>0&&t.jsxs(t.Fragment,{children:[Pe(G.entries),t.jsx(ru,{page:v,pageSize:Vi,total:Math.min(G.total,In),totalLabel:ii(G.total),onPage:M})]}),!I&&b!=="all"&&G&&G.entries.length===0&&!E&&t.jsxs("div",{className:"bim-sr-empty",children:[h(X?m.emptyFiltered:ut(u.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>de("all"),children:u.search.allTab})})]})]})]})};function ps({on:e,onClick:n,children:o}){return t.jsx("button",{type:"button","aria-pressed":e,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:i(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${i("accent")}`:"none"},children:o})}const ln="bim-recent-ids",us="bim-recent-entries",ms=50;function Pt(){try{const e=localStorage.getItem(ln);if(e)return JSON.parse(e);const n=localStorage.getItem(us);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(ln,JSON.stringify(o)),localStorage.removeItem(us),o}return[]}catch{return[]}}function co(e){try{const n=Pt().filter(o=>o!==e);n.unshift(e),n.length>ms&&(n.length=ms),localStorage.setItem(ln,JSON.stringify(n))}catch{}}function qa(e){try{const n=Pt().filter(o=>o!==e);localStorage.setItem(ln,JSON.stringify(n))}catch{}}function Fo(){try{localStorage.removeItem(ln)}catch{}}async function Do(e,n){var o,r,s;try{if(e.getEntry){const l=await e.getEntry(n);if(l)return l}const a=await e.getItem(n);if(a){const l=a.authors;return{id:n,title:a.title||n,type:a.type||"work",author:(o=l==null?void 0:l[0])==null?void 0:o.name,dynasty:(r=l==null?void 0:l[0])==null?void 0:r.dynasty,role:(s=l==null?void 0:l[0])==null?void 0:s.role,edition:a.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const Yi=5,gu=50,fu=200,hs={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},po=({transport:e,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:u="compact",renderEntry:m,initialQuery:h,onQueryChange:f,headerRight:x,reserveViewportHeight:k=!1,filtersEnabled:y=!1,filters:w=bi,onFiltersChange:b,resultTab:j,onResultTabChange:S,resultPage:v,onResultPageChange:$})=>{const _=Te(),C=[{type:"work",name:_.indexType.work,key:"works"},{type:"book",name:_.indexType.book,key:"books"},{type:"collection",name:_.indexType.collection,key:"collections"},{type:"entity",name:_.indexType.entity,key:"entities"}],M=["work","collection","book","entity"],[N,T]=g.useState(h??""),[F,R]=g.useState(null),[E,L]=g.useState(h??""),I=li(w).toString(),[P,V]=g.useState(w);g.useEffect(()=>{V(w)},[I]);const X=z=>{V(z),b==null||b(z)},[D,O]=g.useState(null),[A,G]=g.useState("all"),[se,Q]=g.useState(!1),[ke,ne]=g.useState(null),[de,We]=g.useState(""),[we,Pe]=g.useState(!(h!=null&&h.trim())),[Ee,Z]=g.useState(Pt),[ae,oe]=g.useState([]),[fe,U]=g.useState(!1),[$e,me]=g.useState(!1),[Ce,Y]=g.useState(null),[ze,Me]=g.useState(null),B=g.useRef(void 0),te=g.useRef(!1),xe=g.useCallback(async(z,ie)=>{if(!z.trim()){Pe(!0),R(null),O(null);return}if(Pe(!1),y){L(z);return}Q(!0),We("");try{if(e.searchAll){const re=await e.searchAll(z,ie??Yi);R(re)}else{const re=["work","book","collection","entity"],je=await Promise.all(re.map(ye=>e.search(z,ye,{page:1,pageSize:ie??Yi})));R({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(re){We(re instanceof Error?re.message:String(re)),R(null)}finally{Q(!1)}},[e,y]);g.useEffect(()=>{let z=!1;const ie=()=>{var Ne,K;const re=["work","book","collection","entity"],je=Promise.all(re.map(ge=>e.loadEntries(ge,{page:1,pageSize:1}).catch(()=>({total:0})))),ye=((Ne=e.getResourceCounts)==null?void 0:Ne.call(e).catch(()=>null))??Promise.resolve(null),he=((K=e.getSubtypeStats)==null?void 0:K.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([je,ye,he]).then(([ge,Ae,q])=>{z||(Y({works:ge[0].total,books:ge[1].total,collections:ge[2].total,entities:ge[3].total,hasText:Ae==null?void 0:Ae.hasText,hasImage:Ae==null?void 0:Ae.hasImage}),q&&Me(q))})};return e.getCounts?e.getCounts().then(re=>{var je,ye;z||(Y({works:re.works,books:re.books,collections:re.collections,entities:re.entities,hasText:(je=re.resourceCounts)==null?void 0:je.hasText,hasImage:(ye=re.resourceCounts)==null?void 0:ye.hasImage}),re.subtypeStats&&Me(re.subtypeStats))}).catch(()=>{z||ie()}):ie(),()=>{z=!0}},[e]),g.useEffect(()=>{te.current||!(h!=null&&h.trim())||(te.current=!0,xe(h))},[h,xe]);const Re=g.useCallback(z=>{if(T(z),!z.trim()){f==null||f(z),Pe(!0),R(null),O(null),G("all");return}B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{O(null),G("all"),f==null||f(z),xe(z)},fu)},[xe,f]),H=g.useCallback(z=>{B.current&&clearTimeout(B.current),G("all"),f==null||f(z),xe(z)},[xe,f]),pe=g.useCallback(z=>{O(z),xe(N,gu)},[N,xe]);g.useEffect(()=>{if(!Ee.length){oe([]);return}let z=!1;return U(!0),Promise.all(Ee.slice(0,10).map(ie=>Do(e,ie))).then(ie=>{z||(oe(ie),U(!1))}),()=>{z=!0}},[Ee,e]);const ee=z=>{ne(z.id),co(z.id),Z(Pt()),r==null||r(z)},be=(z,ie)=>{if(r&&bu(ie)){ie.preventDefault(),ee(z);return}co(z.id),Z(Pt())},Se=z=>{qa(z),Z(Pt())},Be=()=>{Fo(),Z([])},De=z=>C.find(ie=>ie.type===z),Je=!we&&!F&&!de,He=F&&(F.works.length>0||F.books.length>0||F.collections.length>0),Ue=t.jsxs(t.Fragment,{children:[t.jsx(Wa,{transport:e,value:N,onChange:Re,onSearch:H,onEntrySelect:ee}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const z=N.trim();z&&Ba(z),H(N)},children:_.searchPage.submit}),s&&t.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:_.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:k?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:yu+(y?ju:"")}),(!y||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:i("fg")},children:_.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(Ma,{variant:"index-browser",indexSource:n,syncConfig:o,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),y?t.jsxs("div",{className:"bim-ib-bar","data-nofilters":e.supportsSearchFilters?void 0:"true",children:[t.jsx("span",{"aria-hidden":"true"}),t.jsx("div",{className:"bim-ib-bar-main",children:Ue})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Ue}),we&&t.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:Ce&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:ze?t.jsxs(t.Fragment,{children:[(ze.book??0)>0&&t.jsxs(t.Fragment,{children:[_.searchPage.statBook," ",t.jsx("strong",{style:{color:i("fg")},children:ze.book.toLocaleString()})," ",_.unit.bu,_.searchPage.statComma,t.jsx("strong",{style:{color:i("fg")},children:Ce.books.toLocaleString()})," ",_.searchPage.statBookCopies]}),ze.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statArticle," ",t.jsx("strong",{style:{color:i("fg")},children:ze.article.toLocaleString()})," ",_.searchPage.statArticleUnit]}):null,ze.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statPoem," ",t.jsx("strong",{style:{color:i("fg")},children:ze.poem.toLocaleString()})," ",_.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statCollection," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[_.indexType.work," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.book," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.collection," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.collections.toLocaleString()}),Ce.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.entity," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.entities.toLocaleString()})]})]})}),Ce.hasImage!=null&&Ce.hasText!=null&&t.jsxs("span",{children:[_.resourceType.image," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.resourceType.text," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.hasText.toLocaleString()})]})]})}),y&&!we&&t.jsx(Ka,{transport:e,query:E,filters:P,onFiltersChange:X,onEntryLinkClick:be,typeName:z=>De(z).name,tab:j,onTabChange:S,page:v,onPageChange:$}),!(y&&!we)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:se||Je?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:xu,boxSizing:"border-box"},children:_.search.searching}):de?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:i("desc-fg")},children:de})}):we?t.jsx("div",{style:{flex:1},children:fe?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:_.search.loading}):ae.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:_.search.recentBrowse}),t.jsx("button",{onClick:Be,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:_.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:ae.slice(0,$e?10:3).map(z=>z.notFound?t.jsx(Su,{id:z.id,onRemove:Se,t:_},z.id):t.jsx(gs,{entry:z,selected:ke===z.id,onClick:be,getConfig:De,onRemove:Se},z.id))}),!$e&&ae.length>3&&t.jsx("button",{onClick:()=>me(!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:_.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:_.search.searchTitle}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.searchSubtitle})]})}):He?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:vu}),(()=>{const z=he=>F[hs[he]]??0,ie=M.map(he=>C.find(Ne=>Ne.type===he)).filter(he=>z(he.key)>0);if(ie.length<2)return null;const re=ie.reduce((he,Ne)=>he+z(Ne.key),0),je=he=>{if(G(he),he!=="all"&&D!==he){const Ne=C.find(ge=>ge.type===he),K=(F[Ne.key]??[]).length;z(Ne.key)>K&&pe(he)}},ye=he=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(he?"fg":"desc-fg"),fontWeight:he?700:400,boxShadow:he?`inset 0 -2px 0 ${i("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":_.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":A==="all",style:ye(A==="all"),onClick:()=>je("all"),children:[_.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:re.toLocaleString()})]}),ie.map(he=>t.jsxs("button",{type:"button","aria-pressed":A===he.type,style:ye(A===he.type),onClick:()=>je(he.type),children:[he.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:z(he.key).toLocaleString()})]},he.type))]})})(),C.map(({type:z,name:ie,key:re})=>{const je=F[re]??[],ye=hs[re],he=F[ye]??0;if(je.length===0||A!=="all"&&A!==z)return null;const K=A==="all"&&!(D===z)&&he>Yi;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[t.jsx(fn,{type:z})," ",ie,t.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[he," ",_.unit.items]})]}),K&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>pe(z),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:_.action.viewAll})]}),t.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(ge=>{if(m)return t.jsx(g.Fragment,{children:m(ge)},ge.id);const Ae=u==="card"?wu:gs;return t.jsx(Ae,{entry:ge,selected:ke===ge.id,onClick:be,getConfig:De,query:N},ge.id)})})]},z)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:ut(_.search.noResultsFor,{query:N})}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.tryOther})]})})]})},xu=240;function bu(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const yu=`
|
|
121
121
|
.bim-ib-stats { min-height: 25px; box-sizing: content-box; }
|
|
122
122
|
@media (max-width: 719px) { .bim-ib-stats { min-height: 46px; } }
|
|
123
|
-
`,
|
|
123
|
+
`,ju=`
|
|
124
124
|
.bim-ib-bar { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; padding: 0 20px 16px; }
|
|
125
125
|
.bim-ib-bar[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
|
|
126
126
|
.bim-ib-bar[data-nofilters] > [aria-hidden] { display: none; }
|
|
@@ -135,26 +135,26 @@
|
|
|
135
135
|
.bim-ib-bar-main { max-width: none; }
|
|
136
136
|
.bim-ib-submit { min-height: 44px; padding: 0 16px; }
|
|
137
137
|
}
|
|
138
|
-
`,
|
|
138
|
+
`,vu=`
|
|
139
139
|
@media (max-width: 719px), (pointer: coarse) {
|
|
140
140
|
.bim-ib-viewall { position: relative; }
|
|
141
141
|
.bim-ib-viewall::after {
|
|
142
142
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
143
143
|
width: max(calc(100% + 8px), 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
|
|
144
144
|
}
|
|
145
|
-
}`,qa={color:"inherit",textDecoration:"none"},ju=({snippet:e})=>{const{convert:n}=Ae();return t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:Lo(e).map((o,r)=>o.marked?t.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):t.jsx(g.Fragment,{children:n(o.text)},r))})},vu=({entry:e,selected:n,onClick:o,getConfig:r,query:s})=>{const a=Te(),{convert:l}=Ae(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],u=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=i("cover-accent"),h=Ze();return t.jsxs("a",{href:h(e.id),onClick:f=>o(e,f),className:"bim-result-card",style:{...qa,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:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${m} 50%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${i("bg")}), color-mix(in srgb, ${m} 7%, ${i("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${m} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:m},children:Array.from(d).map((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",l(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:l(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",l(e.role)]})]}),(e.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),u&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[a.search.alias,":",l(typeof u=="string"?u:u.book_title||"")]}),e.descriptionSnippet&&t.jsx(ju,{snippet:e.descriptionSnippet}),t.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[t.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[t.jsx(fn,{type:e.type,size:8})," ",r(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:a.misc.imageResource})]})]})]})},hs=({entry:e,selected:n,onClick:o,getConfig:r,query:s,onRemove:a})=>{const l=Te(),{convert:d}=Ae(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const h=typeof m=="string"?m:m==null?void 0:m.book_title;return h==null?void 0:h.toLowerCase().includes(s.toLowerCase())}):void 0,u=Ze();return t.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:[t.jsxs("a",{href:u(e.id),onClick:m=>o(e,m),className:"bim-result-card",style:{...qa,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:a?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[t.jsx(fn,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:d(e.title||e.primary_name||e.id)}),t.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[e.has_text&&t.jsx("span",{children:l.misc.textResource}),e.has_image&&t.jsx("span",{children:l.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",d(e.era),"〕"]}),e.edition&&d(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[e.juan_count,l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",d(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:d(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",d(e.role)]}),e.type==="entity"&&(e.birth_year!=null||e.death_year!=null)&&t.jsxs("span",{style:{marginLeft:e.dynasty?"4px":0},children:[e.birth_year??"?","—",e.death_year??"?"]})]}),p&&t.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:[l.search.alias,":",d(p)]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),a&&t.jsx("button",{type:"button",onClick:()=>a(e.id),title:l.search.removeFromRecent,"aria-label":l.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},ku=({id:e,onRemove:n,t:o})=>t.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:[t.jsx("span",{style:{fontSize:"16px"},children:"❓"}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:"13px",color:i("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function wu(e){var n;return!e.dynasty&&!e.birth_year&&!e.death_year&&(!e.alt_names||e.alt_names.length===0)&&!((n=e.description)!=null&&n.text)}function Su({data:e}){const{convert:n}=Ae(),{dynasty:o,birth_year:r,death_year:s}=e,a=[];return o&&a.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?a.push(`${r}—${s}`):r!==void 0?a.push(`${r}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function _u({alt_names:e}){const{convert:n}=Ae(),o=new Map;for(const a of e){const l=a.type||"別名";o.has(l)||o.set(l,[]),o.get(l).push(a.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((a,l)=>{const d=r.indexOf(a),c=r.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=o.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(a)}),t.jsx("span",{children:l.map((d,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function $u({data:e}){const n=Te(),o=e.external_ids;if(!o)return null;const r=[];return o.cbdb_id&&r.push(t.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:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:r})}function Cu({works:e,transport:n,onNavigate:o,renderLink:r}){const s=Te(),{convert:a}=Ae(),l=Ze(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let h=!1;const f=e.map(k=>k.work_id);return(async()=>{const k=new Map;if(n.getEntriesByIds)try{const j=await n.getEntriesByIds(f);let S=!0;for(let v=0;v<f.length;v++){const $=j[v];$!=null&&$.title?k.set(f[v],$.title):$!=null&&$.primary_name?k.set(f[v],$.primary_name):S=!1}if(S)return k}catch{}const y=[...f],w=8,b=new Array(w).fill(0).map(async()=>{for(;y.length;){const j=y.shift();if(!j)break;if(!k.has(j))try{if(n.getEntry){const $=await n.getEntry(j);if($!=null&&$.title){k.set(j,$.title);continue}}const S=await n.getItem(j),v=S&&(S.title||S.primary_name)||j;k.set(j,v)}catch{k.set(j,j)}}});return await Promise.all(b),k})().then(k=>{h||c(k)}),()=>{h=!0}},[e,n]);const p=new Map;for(const h of e){const f=h.role||"";p.has(f)||p.set(f,[]),p.get(f).push(h)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((h,f)=>{const x=u.indexOf(h),k=u.indexOf(f);return x===-1&&k===-1?h.localeCompare(f):x===-1?1:k===-1?-1:x-k});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.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," ",t.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(h=>{const f=p.get(h);return t.jsxs("div",{style:{marginBottom:"8px"},children:[h&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[a(h)," ",t.jsxs("span",{style:{color:i("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:h?"16px":"0",listStyle:h?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,k)=>{const y=a(d.get(x.work_id)||x.work_id);return r?t.jsx("li",{children:r(x.work_id,y)},k):o?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),o(x.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},k):t.jsx("li",{children:y},k)})})]},h)})]})}const Xa=({data:e,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:a})=>{var m;const l=Te(),{convert:d}=Ae();let c=!1;try{c=_e.extractStatus(e.id)==="draft"}catch{}const p=wu(e),u=e.subtype&&e.subtype in l.common.entitySubtype?l.common.entitySubtype[e.subtype]:d(e.subtype);return t.jsxs("div",{children:[!a&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:i("fg")},children:[d(e.primary_name),t.jsx(Su,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[t.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:l.indexType.entity}),u&&e.subtype!=="people"&&t.jsx("span",{children:u}),c&&t.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("warn-fg")},children:l.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),p&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:i("widget-bg"),border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(_u,{alt_names:e.alt_names}),t.jsx($u,{data:e}),((m=e.description)==null?void 0:m.text)&&t.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(Cu,{works:e.works,transport:n,onNavigate:o,renderLink:r})]})},zu=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Tu(e){const n=e.search(zu);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Za={p:({children:e})=>t.jsx("p",{style:{margin:"0 0 0.5em"},children:e}),ul:({children:e})=>t.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:e}),ol:({children:e})=>t.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:e}),li:({children:e})=>t.jsx("li",{style:{marginBottom:"2px"},children:e}),a:({href:e,children:n})=>{let o=e,r="",s=n;if(e&&typeof n=="string"&&(n===e||n===Nu(e))){const[a,l]=Tu(n);l&&(o=encodeURI(a),s=a,r=l)}return t.jsxs(t.Fragment,{children:[t.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:e})=>t.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function Nu(e){try{return decodeURI(e)}catch{return e}}const Ru={...Za,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Tt=({text:e,plainStrong:n,style:o,className:r})=>{const{convert:s}=Ae(),a=n?Ru:Za;return t.jsx("div",{className:r,style:o,children:t.jsx(ip,{remarkPlugins:[op],components:a,children:s(e)})})},Eu=["〇","一","二","三","四","五","六","七","八","九"],gs=["","十","百","千"];function Ja(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let a=0;a<o;a++){const l=parseInt(n[a]),d=o-1-a;l===0?s=!0:(s&&r&&(r+="〇"),s=!1,l===1&&d===1&&a===0?r+=gs[d]:r+=Eu[l]+gs[d])}return r}function Qa(e){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:e,border:`1px solid color-mix(in srgb, ${e} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${e} 3%, transparent)`}}const Iu={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function Lu({type:e}){const n=Te();return t.jsx("span",{style:Qa(Iu[e]),children:n.indexType[e]})}function Au({isDraft:e}){const n=Te(),o=i(e?"status-draft":"status-official");return t.jsx("span",{style:Qa(o),children:e?n.status.draft:n.status.official})}function Pu({id:e}){const n=Te(),[o,r]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return t.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:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:e}),t.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:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function ft({children:e,extra:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function kt({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:i("fg")},children:n})]})}function el({authors:e,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Ae();return t.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(yt,{id:a.entity_id,label:d,onNavigate:o,renderLink:r}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function yt({id:e,label:n,onNavigate:o,renderLink:r}){const s=Ze();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{children:n||e})}function Mu({id:e,title:n,edition:o,type:r,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:u}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:i("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,o&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:l})]}),c&&t.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[t.jsx(Lu,{type:r}),t.jsx(Au,{isDraft:s}),t.jsx(Pu,{id:e})]}),((a==null?void 0:a.length)||d.length>0)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[a&&a.length>0&&t.jsx(el,{authors:a,type:r,onNavigate:p,renderLink:u}),d]})]})}function tl({items:e,label:n,showMeta:o,onNavigate:r,renderLink:s}){const a=Te(),{convert:l}=Ae();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,u)=>{const m=d===u;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:i("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?null:u),style:{padding:"8px 12px",background:i("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:l(p.source)}),!m&&o&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:h=>h.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(yt,{id:p.source_bid,label:a.action.view,onNavigate:r,renderLink:s})})]}),m&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(p.title_info||p.author_info||p.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&t.jsx(kt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(kt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(kt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.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:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:l(p.summary)})]}),p.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.comment)})]}),p.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},u)})})]})}function Bu({items:e,onNavigate:n,renderLink:o}){const r=Te();return t.jsx(tl,{items:e,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function nl({items:e,onNavigate:n,renderLink:o}){const r=Te();return t.jsx(tl,{items:e,label:r.section.emendated,onNavigate:n,renderLink:o})}function il({label:e,items:n}){const{convert:o}=Ae();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const a=typeof r=="string"?r:r.book_title;return t.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(a)},s)})})]}):null}function Wu({items:e}){const n=Te();return t.jsx(il,{label:n.section.aliases,items:e})}function Ou({items:e}){const n=Te();return t.jsx(il,{label:n.section.attachedTexts,items:e})}function Hu({items:e}){const n=Te(),{convert:o}=Ae();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((r,s)=>t.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&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function Fu({items:e}){const n=Te(),{convert:o}=Ae();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:n.section.locationHistory}),t.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[t.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:i("widget-border")}}),e.map((r,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:i("primary"),border:`1.5px solid ${i("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function Du({items:e}){const n=Te(),{convert:o}=Ae();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((r,s)=>t.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function fs({title:e,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:a}=Ae(),[l,d]=g.useState([]);return g.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?t.jsxs(t.Fragment,{children:[t.jsxs(ft,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(l.length?l:n.map(c=>({id:c}))).map(c=>{const p=c.edition?`${a(c.title)||c.id}(${a(c.edition)})`:a(c.title)||void 0;return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),transition:"border-color 0.15s"},children:t.jsx(yt,{id:c.id,label:p,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Ki({book:e,onNavigate:n,renderLink:o}){const r=Te(),{convert:s}=Ae(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(yt,{id:e.id,label:c,onNavigate:n,renderLink:o})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?r.action.expand:r.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(Oo,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function Uu({ids:e,workData:n,transport:o,onNavigate:r,renderLink:s,footer:a}){const l=Te(),{convert:d}=Ae(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!o){p(e.map(k=>({id:k})));return}let x=!1;return Promise.all(e.map(k=>o.getItem(k).then(y=>({id:k,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:k})))).then(k=>{x||p(k)}),()=>{x=!0}},[e,o]),!e.length)return null;const u=c.length?c:e.map(x=>({id:x})),m=new Map(u.map(x=>[x.id,x])),h=n==null?void 0:n.version_graph,f=Vu(e,h,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(ft,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,f.useGrouping?t.jsxs(t.Fragment,{children:[f.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:f.coreIds.map(x=>{const k=m.get(x);return k?t.jsx(Ki,{book:k,onNavigate:r,renderLink:s},x):null})}),f.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(k=>{const y=m.get(k);return y?t.jsx(Ki,{book:y,onNavigate:r,renderLink:s},k):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(x=>t.jsx(Ki,{book:x,onNavigate:r,renderLink:s},x.id))})]})}function Vu(e,n,o){var w,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const r=(w=n.collections)==null?void 0:w[n.default_collection],s=(r==null?void 0:r.groups)??[],a=(r==null?void 0:r.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),u=j=>{if(p.has(j))return!0;const S=n.node_groups[j];return S!=null&&c.has(S)},m=[],h=new Map,f=[];for(const j of e)if(!((b=n.excluded_books)!=null&&b.includes(j)))if(u(j))m.push(j);else{const S=n.node_groups[j];S?(h.has(S)||h.set(S,[]),h.get(S).push(j)):f.push(j)}if(f.length+[...h.values()].reduce((j,S)=>j+S.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const k=new Map((n.groups??[]).map(j=>[j.id,j])),y=[...h.entries()].map(([j,S])=>{const v=k.get(j);return{id:j,label:(v==null?void 0:v.label)??j,description:v==null?void 0:v.description,ids:S}});return f.length>0&&y.push({id:"__other__",label:o,description:void 0,ids:f}),{useGrouping:!0,coreIds:m,groupedIds:y}}function Gu({workData:e,onNavigate:n,renderLink:o}){var l,d,c,p;const r=Te(),{convert:s}=Ae(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:t.jsx(yt,{id:e.id,label:s(e.title),onNavigate:n,renderLink:o})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:s(e.measure_info)}):((d=e.juan_count)==null?void 0:d.number)!=null&&e.juan_count.number>0?t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[Ja(e.juan_count.number),r.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(el,{authors:e.authors,type:"work",onNavigate:n,renderLink:o})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(Tt,{text:e.description.text,style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,textAlign:"justify"}}),e.parent_work&&t.jsx("div",{style:{marginTop:(p=e.description)!=null&&p.text?"8px":0,fontSize:"13px"},children:t.jsx(kt,{label:r.label.parentWork,children:t.jsx(yt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function Yu({items:e,onNavigate:n,renderLink:o}){const r=Te(),{convert:s}=Ae();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(a=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${i("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${i("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),t.jsx(yt,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:o}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:mt(r.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Uo=({data:e,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var F,R,E,L,I,P,V,X;const p=Te(),{convert:u}=Ae(),[m,h]=g.useState(null),[f,x]=g.useState(!1),[k,y]=g.useState(null),[w,b]=g.useState(null),[j,S]=g.useState([]),v=e||m;if(g.useEffect(()=>{if(e||!n||!o)return;let D=!1;return x(!0),y(null),o.getItem(n).then(O=>{D||(O?h(O):y(p.misc.notFoundEntry))}).catch(O=>{D||y(O instanceof Error?O.message:p.misc.loadFailed)}).finally(()=>{D||x(!1)}),()=>{D=!0}},[e,n,o]),g.useEffect(()=>{if(!v||!o){b(null),S([]);return}let D=!1;const O=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(O?o.getItem(O).then(A=>{!D&&A&&A.type==="work"&&b(A)}).catch(()=>{}):b(null),v.type==="book"){const A=v;A.contained_in&&A.contained_in.length>0?Promise.all(A.contained_in.map(G=>{const se=typeof G=="string"?G:G.id,Q=typeof G=="string"?void 0:G.volume_index;return o.getItem(se).then(ve=>({id:se,title:ve&&ve.title||se,volume_index:Q})).catch(()=>({id:se,title:se,volume_index:Q}))})).then(G=>{D||S(G)}):S([])}else S([]);return()=>{D=!0}},[v,o]),f)return t.jsx("div",{className:d,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((D,O)=>t.jsx("div",{style:{height:O===1?"32px":"16px",width:`${D}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},O))})});if(k)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:k});if(!v)return null;if(v.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(Xa,{data:v,transport:o,onNavigate:r,renderLink:s,headerExtra:a})});const $=v.type==="book"?v:null,_=v.type==="collection"?v:null,C=v.type==="work"?v:null;let M=!1;try{M=_e.extractStatus(v.id)==="draft"}catch{}let N="";v.measure_info?N=u(v.measure_info):(F=v.juan_count)!=null&&F.number?N=Ja(v.juan_count.number)+p.unit.juan:(R=v.juan_count)!=null&&R.description&&(N=u(v.juan_count.description));const T=[];return(E=v.publication_info)!=null&&E.year&&T.push(t.jsx(kt,{label:p.label.year,children:v.publication_info.year},"year")),(L=v.current_location)!=null&&L.name&&T.push(t.jsx(kt,{label:p.label.currentLocation,children:u(v.current_location.name)},"loc")),(I=v.page_count)!=null&&I.description&&T.push(t.jsx(kt,{label:p.label.pageCount,children:v.page_count.description},"page")),$!=null&&$.edition&&T.push(t.jsx(kt,{label:p.label.edition,children:u($.edition)},"ver")),C!=null&&C.parent_work&&T.push(t.jsx(kt,{label:p.label.parentWork,children:t.jsx(yt,{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&&T.push(t.jsx(kt,{label:p.label.parentWork,children:C.parent_works.map((D,O)=>t.jsxs("span",{children:[O>0&&"、",t.jsx(yt,{id:D,onNavigate:r,renderLink:s})]},D))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Mu,{id:v.id,title:u(v.title),edition:v.edition?u(v.edition):void 0,type:v.type,isDraft:M,authors:v.authors,volumeText:N,meta:T,headerExtra:a,onNavigate:r,renderLink:s}),((P=v.description)==null?void 0:P.text)&&t.jsx(Tt,{text:v.description.text,style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),v.appendix&&v.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:v.appendix.map((D,O)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(D.title)}),t.jsx(Tt,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},O))}),j.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:p.section.containedIn}),t.jsx(Yu,{items:j,onNavigate:r,renderLink:s})]}),w&&t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:p.section.belongsToWork}),t.jsx(Gu,{workData:w,onNavigate:r,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Hu,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Wu,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(Ou,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(Bu,{items:v.indexed_by,onNavigate:r,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(nl,{items:v.emendated_by,onNavigate:r,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:p.section.resources}),t.jsx(Oo,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(Fu,{items:$.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&t.jsx(Du,{items:_.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(fs,{title:p.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&t.jsx(fs,{title:p.section.containedBooks,ids:_.books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.contained_works)&&_.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(ft,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",_.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.contained_works.map(D=>t.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:t.jsx(yt,{id:D.id,label:u(D.title),onNavigate:r,renderLink:s})},D.id))})]}),(((V=C==null?void 0:C.books)==null?void 0:V.length)||0)+(((X=C==null?void 0:C.collections)==null?void 0:X.length)||0)>0&&t.jsx(Uu,{ids:[...(C==null?void 0:C.books)||[],...(C==null?void 0:C.collections)||[]],workData:C??void 0,transport:o,onNavigate:r,renderLink:s,footer:l}),(C==null?void 0:C.related_works)&&C.related_works.length>0&&(()=>{const D=[],O=C.related_works.filter(ne=>ne.relation==="part_of"),A=C.related_works.filter(ne=>ne.relation==="has_part"),G=C.related_works.filter(ne=>ne.relation==="has_adaptation"),se=C.related_works.filter(ne=>ne.relation==="text_carried_by"),Q=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),ve=C.related_works.filter(ne=>!ne.relation||!Q.has(ne.relation));return O.length>0&&D.push({label:p.section.belongsToWork,items:O}),A.length>0&&D.push({label:p.section.containedWorks,items:A}),G.length>0&&D.push({label:p.section.adaptations,items:G}),se.length>0&&D.push({label:p.section.derivativeWorks,items:se}),ve.length>0&&D.push({label:p.section.relatedWorks,items:ve}),D.map(ne=>t.jsxs("div",{children:[t.jsxs(ft,{children:[ne.label,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",ne.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ne.items.map(ce=>t.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:t.jsx(yt,{id:ce.id,label:u(ce.title),onNavigate:r,renderLink:s})},ce.id))})]},ne.label))})()]})};function Ku({data:e}){const n=Te(),{convert:o}=Ae(),{stats:r}=e,s=r.processed_volumes??r.total_found_volumes,a=s!=null&&e.total_volumes>0?Math.round(s/e.total_volumes*100):null;return t.jsxs("div",{style:{marginBottom:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:o(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:i("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function qu({sections:e,activeSection:n,onSelect:o}){const r=Te();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>o(null),style:xs(n===null),children:r.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>o(s.name),style:xs(n===s.name),children:[s.name,s.volume_range&&t.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function xs(e){return{padding:"4px 12px",border:e?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Xu({id:e,label:n,onNavigate:o,renderLink:r}){const s=Ze();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:n||e})}function Zu(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=e[0],r=e[e.length-1];return r-o+1===e.length?`${o}–${r}`:e.length<=3?e.join(", "):`${o}–${r} (${e.length}${n})`}function bs({book:e,onNavigate:n,renderLink:o,showVolumes:r}){const s=Te(),{convert:a}=Ae(),l=e.book_id||e.work_id,d=r&&e.volumes.length>0?Zu(e.volumes,s.unit.volume):null,c=e.missing_volumes&&e.missing_volumes.length>0;return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${i("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[r&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(Xu,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!l&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const Vo=({data:e,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:a,style:l})=>{const d=Te(),[c,p]=g.useState(null),[u,m]=g.useState(!1),[h,f]=g.useState(null),[x,k]=g.useState(null),[y,w]=g.useState(""),b=e||c;g.useEffect(()=>{if(e||!n||!(o!=null&&o.getCollectionCatalog))return;let _=!1;return m(!0),f(null),o.getCollectionCatalog(n).then(C=>{_||(C?p(C):f(d.catalog.notFound))}).catch(C=>{_||f(C instanceof Error?C.message:d.catalog.loadFailed)}).finally(()=>{_||m(!1)}),()=>{_=!0}},[e,n,o,d]);const j=(b==null?void 0:b.sections)&&b.sections.length>0,S=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(M=>M.volumes[0]).filter(M=>M!=null);return new Set(_).size<_.length},[b]),v=g.useMemo(()=>{if(!b)return[];let _=b.books;if(x&&(_=_.filter(C=>C.section===x)),y.trim()){const C=y.trim().toLowerCase();_=_.filter(M=>M.title.toLowerCase().includes(C)||M.sub_items&&M.sub_items.some(N=>N.toLowerCase().includes(C))||M.edition&&M.edition.toLowerCase().includes(C))}return _},[b,x,y]),$=g.useMemo(()=>{if(!S)return null;const _=[],C=new Map;for(const N of v){if(!N.volumes||N.volumes.length===0)continue;const T=N.volumes[0];C.has(T)||C.set(T,[]),C.get(T).push(N)}const M=[...C.keys()].sort((N,T)=>N-T);for(const N of M)_.push({volume:N,books:C.get(N)});return _},[v,S]);return u?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):h?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:h}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Ku,{data:b}),j&&t.jsx(qu,{sections:b.sections,activeSection:x,onSelect:k}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:_=>w(_.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[v.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((_,C)=>t.jsxs("div",{children:[t.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:mt(d.catalog.volume,{n:_.volume})}),_.books.map((M,N)=>t.jsx(bs,{book:M,onNavigate:r,renderLink:s,showVolumes:M.volumes.length>1},`${_.volume}-${N}`))]},`${_.volume}-${C}`)):v.map((_,C)=>t.jsx(bs,{book:_,onNavigate:r,renderLink:s,showVolumes:!0},C)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},Ju="guji_markdown";function uo(e){const n=e==null?void 0:e.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 Qu=/^□\{guess=([^\s{}]+)\}/;function em(e,n){const o=e[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function ol(e,n){let o=0;for(let r=n;r<e.length;r++){const s=e[r];if(s===`
|
|
146
|
-
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function
|
|
147
|
-
`)<0?{node:{type:"qw",label:e.slice(n+2,r)},end:r+2}:null}if(o===":"&&e.startsWith(":zi[",n)){const r=
|
|
148
|
-
`)return null}const c=
|
|
145
|
+
}`,Xa={color:"inherit",textDecoration:"none"},ku=({snippet:e})=>{const{convert:n}=Le();return t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:Lo(e).map((o,r)=>o.marked?t.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):t.jsx(g.Fragment,{children:n(o.text)},r))})},wu=({entry:e,selected:n,onClick:o,getConfig:r,query:s})=>{const a=Te(),{convert:l}=Le(),d=l(e.title||e.primary_name||e.id),c=e.measure_info?l(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],u=s&&p.length?p.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=i("cover-accent"),h=Ze();return t.jsxs("a",{href:h(e.id),onClick:f=>o(e,f),className:"bim-result-card",style:{...Xa,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:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${m} 50%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${i("bg")}), color-mix(in srgb, ${m} 7%, ${i("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${m} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:m},children:Array.from(d).map((f,x)=>t.jsx("span",{children:f},x))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",l(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:l(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",l(e.role)]})]}),(e.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),u&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[a.search.alias,":",l(typeof u=="string"?u:u.book_title||"")]}),e.descriptionSnippet&&t.jsx(ku,{snippet:e.descriptionSnippet}),t.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[t.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[t.jsx(fn,{type:e.type,size:8})," ",r(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:a.misc.imageResource})]})]})]})},gs=({entry:e,selected:n,onClick:o,getConfig:r,query:s,onRemove:a})=>{const l=Te(),{convert:d}=Le(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const h=typeof m=="string"?m:m==null?void 0:m.book_title;return h==null?void 0:h.toLowerCase().includes(s.toLowerCase())}):void 0,u=Ze();return t.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:[t.jsxs("a",{href:u(e.id),onClick:m=>o(e,m),className:"bim-result-card",style:{...Xa,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:a?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[t.jsx(fn,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:d(e.title||e.primary_name||e.id)}),t.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[e.has_text&&t.jsx("span",{children:l.misc.textResource}),e.has_image&&t.jsx("span",{children:l.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",d(e.era),"〕"]}),e.edition&&d(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[e.juan_count,l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",d(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:d(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",d(e.role)]}),e.type==="entity"&&(e.birth_year!=null||e.death_year!=null)&&t.jsxs("span",{style:{marginLeft:e.dynasty?"4px":0},children:[e.birth_year??"?","—",e.death_year??"?"]})]}),p&&t.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:[l.search.alias,":",d(p)]})]}),!a&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),a&&t.jsx("button",{type:"button",onClick:()=>a(e.id),title:l.search.removeFromRecent,"aria-label":l.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},Su=({id:e,onRemove:n,t:o})=>t.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:[t.jsx("span",{style:{fontSize:"16px"},children:"❓"}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:"13px",color:i("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function _u(e){var n;return!e.dynasty&&!e.birth_year&&!e.death_year&&(!e.alt_names||e.alt_names.length===0)&&!((n=e.description)!=null&&n.text)}function $u({data:e}){const{convert:n}=Le(),{dynasty:o,birth_year:r,death_year:s}=e,a=[];return o&&a.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?a.push(`${r}—${s}`):r!==void 0?a.push(`${r}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function Cu({alt_names:e}){const{convert:n}=Le(),o=new Map;for(const a of e){const l=a.type||"別名";o.has(l)||o.set(l,[]),o.get(l).push(a.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((a,l)=>{const d=r.indexOf(a),c=r.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=o.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(a)}),t.jsx("span",{children:l.map((d,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function zu({data:e}){const n=Te(),o=e.external_ids;if(!o)return null;const r=[];return o.cbdb_id&&r.push(t.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:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:r})}function Tu({works:e,transport:n,onNavigate:o,renderLink:r}){const s=Te(),{convert:a}=Le(),l=Ze(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let h=!1;const f=e.map(k=>k.work_id);return(async()=>{const k=new Map;if(n.getEntriesByIds)try{const j=await n.getEntriesByIds(f);let S=!0;for(let v=0;v<f.length;v++){const $=j[v];$!=null&&$.title?k.set(f[v],$.title):$!=null&&$.primary_name?k.set(f[v],$.primary_name):S=!1}if(S)return k}catch{}const y=[...f],w=8,b=new Array(w).fill(0).map(async()=>{for(;y.length;){const j=y.shift();if(!j)break;if(!k.has(j))try{if(n.getEntry){const $=await n.getEntry(j);if($!=null&&$.title){k.set(j,$.title);continue}}const S=await n.getItem(j),v=S&&(S.title||S.primary_name)||j;k.set(j,v)}catch{k.set(j,j)}}});return await Promise.all(b),k})().then(k=>{h||c(k)}),()=>{h=!0}},[e,n]);const p=new Map;for(const h of e){const f=h.role||"";p.has(f)||p.set(f,[]),p.get(f).push(h)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((h,f)=>{const x=u.indexOf(h),k=u.indexOf(f);return x===-1&&k===-1?h.localeCompare(f):x===-1?1:k===-1?-1:x-k});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.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," ",t.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(h=>{const f=p.get(h);return t.jsxs("div",{style:{marginBottom:"8px"},children:[h&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[a(h)," ",t.jsxs("span",{style:{color:i("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:h?"16px":"0",listStyle:h?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,k)=>{const y=a(d.get(x.work_id)||x.work_id);return r?t.jsx("li",{children:r(x.work_id,y)},k):o?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),o(x.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},k):t.jsx("li",{children:y},k)})})]},h)})]})}const Za=({data:e,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:a})=>{var m;const l=Te(),{convert:d}=Le();let c=!1;try{c=_e.extractStatus(e.id)==="draft"}catch{}const p=_u(e),u=e.subtype&&e.subtype in l.common.entitySubtype?l.common.entitySubtype[e.subtype]:d(e.subtype);return t.jsxs("div",{children:[!a&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:i("fg")},children:[d(e.primary_name),t.jsx($u,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[t.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:l.indexType.entity}),u&&e.subtype!=="people"&&t.jsx("span",{children:u}),c&&t.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("warn-fg")},children:l.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),p&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:i("widget-bg"),border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(Cu,{alt_names:e.alt_names}),t.jsx(zu,{data:e}),((m=e.description)==null?void 0:m.text)&&t.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(Tu,{works:e.works,transport:n,onNavigate:o,renderLink:r})]})},Nu=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Ru(e){const n=e.search(Nu);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Ja={p:({children:e})=>t.jsx("p",{style:{margin:"0 0 0.5em"},children:e}),ul:({children:e})=>t.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:e}),ol:({children:e})=>t.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:e}),li:({children:e})=>t.jsx("li",{style:{marginBottom:"2px"},children:e}),a:({href:e,children:n})=>{let o=e,r="",s=n;if(e&&typeof n=="string"&&(n===e||n===Eu(e))){const[a,l]=Ru(n);l&&(o=encodeURI(a),s=a,r=l)}return t.jsxs(t.Fragment,{children:[t.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:e})=>t.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function Eu(e){try{return decodeURI(e)}catch{return e}}const Iu={...Ja,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},Tt=({text:e,plainStrong:n,style:o,className:r})=>{const{convert:s}=Le(),a=n?Iu:Ja;return t.jsx("div",{className:r,style:o,children:t.jsx(rp,{remarkPlugins:[sp],components:a,children:s(e)})})},Lu=["〇","一","二","三","四","五","六","七","八","九"],fs=["","十","百","千"];function Qa(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let a=0;a<o;a++){const l=parseInt(n[a]),d=o-1-a;l===0?s=!0:(s&&r&&(r+="〇"),s=!1,l===1&&d===1&&a===0?r+=fs[d]:r+=Lu[l]+fs[d])}return r}function el(e){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:e,border:`1px solid color-mix(in srgb, ${e} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${e} 3%, transparent)`}}const Au={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function Pu({type:e}){const n=Te();return t.jsx("span",{style:el(Au[e]),children:n.indexType[e]})}function Mu({isDraft:e}){const n=Te(),o=i(e?"status-draft":"status-official");return t.jsx("span",{style:el(o),children:e?n.status.draft:n.status.official})}function Bu({id:e}){const n=Te(),[o,r]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return t.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:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:e}),t.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:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function ft({children:e,extra:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function kt({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:i("fg")},children:n})]})}function tl({authors:e,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Le();return t.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(yt,{id:a.entity_id,label:d,onNavigate:o,renderLink:r}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function yt({id:e,label:n,onNavigate:o,renderLink:r}){const s=Ze();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{children:n||e})}function Wu({id:e,title:n,edition:o,type:r,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:u}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:i("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,o&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:l})]}),c&&t.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[t.jsx(Pu,{type:r}),t.jsx(Mu,{isDraft:s}),t.jsx(Bu,{id:e})]}),((a==null?void 0:a.length)||d.length>0)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[a&&a.length>0&&t.jsx(tl,{authors:a,type:r,onNavigate:p,renderLink:u}),d]})]})}function nl({items:e,label:n,showMeta:o,onNavigate:r,renderLink:s}){const a=Te(),{convert:l}=Le();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,u)=>{const m=d===u;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:i("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?null:u),style:{padding:"8px 12px",background:i("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:l(p.source)}),!m&&o&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:h=>h.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(yt,{id:p.source_bid,label:a.action.view,onNavigate:r,renderLink:s})})]}),m&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(p.title_info||p.author_info||p.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&t.jsx(kt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(kt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(kt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.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:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:l(p.summary)})]}),p.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.comment)})]}),p.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},u)})})]})}function Ou({items:e,onNavigate:n,renderLink:o}){const r=Te();return t.jsx(nl,{items:e,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function il({items:e,onNavigate:n,renderLink:o}){const r=Te();return t.jsx(nl,{items:e,label:r.section.emendated,onNavigate:n,renderLink:o})}function ol({label:e,items:n}){const{convert:o}=Le();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const a=typeof r=="string"?r:r.book_title;return t.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(a)},s)})})]}):null}function Hu({items:e}){const n=Te();return t.jsx(ol,{label:n.section.aliases,items:e})}function Fu({items:e}){const n=Te();return t.jsx(ol,{label:n.section.attachedTexts,items:e})}function Du({items:e}){const n=Te(),{convert:o}=Le();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((r,s)=>t.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&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function Uu({items:e}){const n=Te(),{convert:o}=Le();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:n.section.locationHistory}),t.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[t.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:i("widget-border")}}),e.map((r,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:i("primary"),border:`1.5px solid ${i("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function Vu({items:e}){const n=Te(),{convert:o}=Le();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((r,s)=>t.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function xs({title:e,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:a}=Le(),[l,d]=g.useState([]);return g.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?t.jsxs(t.Fragment,{children:[t.jsxs(ft,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(l.length?l:n.map(c=>({id:c}))).map(c=>{const p=c.edition?`${a(c.title)||c.id}(${a(c.edition)})`:a(c.title)||void 0;return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),transition:"border-color 0.15s"},children:t.jsx(yt,{id:c.id,label:p,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Ki({book:e,onNavigate:n,renderLink:o}){const r=Te(),{convert:s}=Le(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(yt,{id:e.id,label:c,onNavigate:n,renderLink:o})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?r.action.expand:r.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(Oo,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function Gu({ids:e,workData:n,transport:o,onNavigate:r,renderLink:s,footer:a}){const l=Te(),{convert:d}=Le(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!o){p(e.map(k=>({id:k})));return}let x=!1;return Promise.all(e.map(k=>o.getItem(k).then(y=>({id:k,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:k})))).then(k=>{x||p(k)}),()=>{x=!0}},[e,o]),!e.length)return null;const u=c.length?c:e.map(x=>({id:x})),m=new Map(u.map(x=>[x.id,x])),h=n==null?void 0:n.version_graph,f=Yu(e,h,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(ft,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,f.useGrouping?t.jsxs(t.Fragment,{children:[f.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:f.coreIds.map(x=>{const k=m.get(x);return k?t.jsx(Ki,{book:k,onNavigate:r,renderLink:s},x):null})}),f.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:d(x.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(k=>{const y=m.get(k);return y?t.jsx(Ki,{book:y,onNavigate:r,renderLink:s},k):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(x=>t.jsx(Ki,{book:x,onNavigate:r,renderLink:s},x.id))})]})}function Yu(e,n,o){var w,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const r=(w=n.collections)==null?void 0:w[n.default_collection],s=(r==null?void 0:r.groups)??[],a=(r==null?void 0:r.book_ids)??[],l=s.length>0||a.length>0,d=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&d.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const c=new Set(s),p=new Set([...a,...d]),u=j=>{if(p.has(j))return!0;const S=n.node_groups[j];return S!=null&&c.has(S)},m=[],h=new Map,f=[];for(const j of e)if(!((b=n.excluded_books)!=null&&b.includes(j)))if(u(j))m.push(j);else{const S=n.node_groups[j];S?(h.has(S)||h.set(S,[]),h.get(S).push(j)):f.push(j)}if(f.length+[...h.values()].reduce((j,S)=>j+S.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const k=new Map((n.groups??[]).map(j=>[j.id,j])),y=[...h.entries()].map(([j,S])=>{const v=k.get(j);return{id:j,label:(v==null?void 0:v.label)??j,description:v==null?void 0:v.description,ids:S}});return f.length>0&&y.push({id:"__other__",label:o,description:void 0,ids:f}),{useGrouping:!0,coreIds:m,groupedIds:y}}function Ku({workData:e,onNavigate:n,renderLink:o}){var l,d,c,p;const r=Te(),{convert:s}=Le(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:t.jsx(yt,{id:e.id,label:s(e.title),onNavigate:n,renderLink:o})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:s(e.measure_info)}):((d=e.juan_count)==null?void 0:d.number)!=null&&e.juan_count.number>0?t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[Qa(e.juan_count.number),r.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(tl,{authors:e.authors,type:"work",onNavigate:n,renderLink:o})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(Tt,{text:e.description.text,style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,textAlign:"justify"}}),e.parent_work&&t.jsx("div",{style:{marginTop:(p=e.description)!=null&&p.text?"8px":0,fontSize:"13px"},children:t.jsx(kt,{label:r.label.parentWork,children:t.jsx(yt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function qu({items:e,onNavigate:n,renderLink:o}){const r=Te(),{convert:s}=Le();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(a=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${i("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${i("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),t.jsx(yt,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:o}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:ut(r.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Uo=({data:e,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var F,R,E,L,I,P,V,X;const p=Te(),{convert:u}=Le(),[m,h]=g.useState(null),[f,x]=g.useState(!1),[k,y]=g.useState(null),[w,b]=g.useState(null),[j,S]=g.useState([]),v=e||m;if(g.useEffect(()=>{if(e||!n||!o)return;let D=!1;return x(!0),y(null),o.getItem(n).then(O=>{D||(O?h(O):y(p.misc.notFoundEntry))}).catch(O=>{D||y(O instanceof Error?O.message:p.misc.loadFailed)}).finally(()=>{D||x(!1)}),()=>{D=!0}},[e,n,o]),g.useEffect(()=>{if(!v||!o){b(null),S([]);return}let D=!1;const O=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(O?o.getItem(O).then(A=>{!D&&A&&A.type==="work"&&b(A)}).catch(()=>{}):b(null),v.type==="book"){const A=v;A.contained_in&&A.contained_in.length>0?Promise.all(A.contained_in.map(G=>{const se=typeof G=="string"?G:G.id,Q=typeof G=="string"?void 0:G.volume_index;return o.getItem(se).then(ke=>({id:se,title:ke&&ke.title||se,volume_index:Q})).catch(()=>({id:se,title:se,volume_index:Q}))})).then(G=>{D||S(G)}):S([])}else S([]);return()=>{D=!0}},[v,o]),f)return t.jsx("div",{className:d,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((D,O)=>t.jsx("div",{style:{height:O===1?"32px":"16px",width:`${D}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},O))})});if(k)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:k});if(!v)return null;if(v.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(Za,{data:v,transport:o,onNavigate:r,renderLink:s,headerExtra:a})});const $=v.type==="book"?v:null,_=v.type==="collection"?v:null,C=v.type==="work"?v:null;let M=!1;try{M=_e.extractStatus(v.id)==="draft"}catch{}let N="";v.measure_info?N=u(v.measure_info):(F=v.juan_count)!=null&&F.number?N=Qa(v.juan_count.number)+p.unit.juan:(R=v.juan_count)!=null&&R.description&&(N=u(v.juan_count.description));const T=[];return(E=v.publication_info)!=null&&E.year&&T.push(t.jsx(kt,{label:p.label.year,children:v.publication_info.year},"year")),(L=v.current_location)!=null&&L.name&&T.push(t.jsx(kt,{label:p.label.currentLocation,children:u(v.current_location.name)},"loc")),(I=v.page_count)!=null&&I.description&&T.push(t.jsx(kt,{label:p.label.pageCount,children:v.page_count.description},"page")),$!=null&&$.edition&&T.push(t.jsx(kt,{label:p.label.edition,children:u($.edition)},"ver")),C!=null&&C.parent_work&&T.push(t.jsx(kt,{label:p.label.parentWork,children:t.jsx(yt,{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&&T.push(t.jsx(kt,{label:p.label.parentWork,children:C.parent_works.map((D,O)=>t.jsxs("span",{children:[O>0&&"、",t.jsx(yt,{id:D,onNavigate:r,renderLink:s})]},D))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Wu,{id:v.id,title:u(v.title),edition:v.edition?u(v.edition):void 0,type:v.type,isDraft:M,authors:v.authors,volumeText:N,meta:T,headerExtra:a,onNavigate:r,renderLink:s}),((P=v.description)==null?void 0:P.text)&&t.jsx(Tt,{text:v.description.text,style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),v.appendix&&v.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:v.appendix.map((D,O)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(D.title)}),t.jsx(Tt,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},O))}),j.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:p.section.containedIn}),t.jsx(qu,{items:j,onNavigate:r,renderLink:s})]}),w&&t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:p.section.belongsToWork}),t.jsx(Ku,{workData:w,onNavigate:r,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Du,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Hu,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(Fu,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(Ou,{items:v.indexed_by,onNavigate:r,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(il,{items:v.emendated_by,onNavigate:r,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(ft,{children:p.section.resources}),t.jsx(Oo,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(Uu,{items:$.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&t.jsx(Vu,{items:_.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(xs,{title:p.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&t.jsx(xs,{title:p.section.containedBooks,ids:_.books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.contained_works)&&_.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(ft,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",_.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.contained_works.map(D=>t.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:t.jsx(yt,{id:D.id,label:u(D.title),onNavigate:r,renderLink:s})},D.id))})]}),(((V=C==null?void 0:C.books)==null?void 0:V.length)||0)+(((X=C==null?void 0:C.collections)==null?void 0:X.length)||0)>0&&t.jsx(Gu,{ids:[...(C==null?void 0:C.books)||[],...(C==null?void 0:C.collections)||[]],workData:C??void 0,transport:o,onNavigate:r,renderLink:s,footer:l}),(C==null?void 0:C.related_works)&&C.related_works.length>0&&(()=>{const D=[],O=C.related_works.filter(ne=>ne.relation==="part_of"),A=C.related_works.filter(ne=>ne.relation==="has_part"),G=C.related_works.filter(ne=>ne.relation==="has_adaptation"),se=C.related_works.filter(ne=>ne.relation==="text_carried_by"),Q=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),ke=C.related_works.filter(ne=>!ne.relation||!Q.has(ne.relation));return O.length>0&&D.push({label:p.section.belongsToWork,items:O}),A.length>0&&D.push({label:p.section.containedWorks,items:A}),G.length>0&&D.push({label:p.section.adaptations,items:G}),se.length>0&&D.push({label:p.section.derivativeWorks,items:se}),ke.length>0&&D.push({label:p.section.relatedWorks,items:ke}),D.map(ne=>t.jsxs("div",{children:[t.jsxs(ft,{children:[ne.label,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",ne.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ne.items.map(de=>t.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:t.jsx(yt,{id:de.id,label:u(de.title),onNavigate:r,renderLink:s})},de.id))})]},ne.label))})()]})};function Xu({data:e}){const n=Te(),{convert:o}=Le(),{stats:r}=e,s=r.processed_volumes??r.total_found_volumes,a=s!=null&&e.total_volumes>0?Math.round(s/e.total_volumes*100):null;return t.jsxs("div",{style:{marginBottom:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:o(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:i("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Zu({sections:e,activeSection:n,onSelect:o}){const r=Te();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>o(null),style:bs(n===null),children:r.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>o(s.name),style:bs(n===s.name),children:[s.name,s.volume_range&&t.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function bs(e){return{padding:"4px 12px",border:e?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Ju({id:e,label:n,onNavigate:o,renderLink:r}){const s=Ze();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:n||e})}function Qu(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=e[0],r=e[e.length-1];return r-o+1===e.length?`${o}–${r}`:e.length<=3?e.join(", "):`${o}–${r} (${e.length}${n})`}function ys({book:e,onNavigate:n,renderLink:o,showVolumes:r}){const s=Te(),{convert:a}=Le(),l=e.book_id||e.work_id,d=r&&e.volumes.length>0?Qu(e.volumes,s.unit.volume):null,c=e.missing_volumes&&e.missing_volumes.length>0;return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${i("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[r&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(Ju,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!l&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const Vo=({data:e,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:a,style:l})=>{const d=Te(),[c,p]=g.useState(null),[u,m]=g.useState(!1),[h,f]=g.useState(null),[x,k]=g.useState(null),[y,w]=g.useState(""),b=e||c;g.useEffect(()=>{if(e||!n||!(o!=null&&o.getCollectionCatalog))return;let _=!1;return m(!0),f(null),o.getCollectionCatalog(n).then(C=>{_||(C?p(C):f(d.catalog.notFound))}).catch(C=>{_||f(C instanceof Error?C.message:d.catalog.loadFailed)}).finally(()=>{_||m(!1)}),()=>{_=!0}},[e,n,o,d]);const j=(b==null?void 0:b.sections)&&b.sections.length>0,S=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(M=>M.volumes[0]).filter(M=>M!=null);return new Set(_).size<_.length},[b]),v=g.useMemo(()=>{if(!b)return[];let _=b.books;if(x&&(_=_.filter(C=>C.section===x)),y.trim()){const C=y.trim().toLowerCase();_=_.filter(M=>M.title.toLowerCase().includes(C)||M.sub_items&&M.sub_items.some(N=>N.toLowerCase().includes(C))||M.edition&&M.edition.toLowerCase().includes(C))}return _},[b,x,y]),$=g.useMemo(()=>{if(!S)return null;const _=[],C=new Map;for(const N of v){if(!N.volumes||N.volumes.length===0)continue;const T=N.volumes[0];C.has(T)||C.set(T,[]),C.get(T).push(N)}const M=[...C.keys()].sort((N,T)=>N-T);for(const N of M)_.push({volume:N,books:C.get(N)});return _},[v,S]);return u?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):h?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:h}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Xu,{data:b}),j&&t.jsx(Zu,{sections:b.sections,activeSection:x,onSelect:k}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:y,onChange:_=>w(_.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[v.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((_,C)=>t.jsxs("div",{children:[t.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:ut(d.catalog.volume,{n:_.volume})}),_.books.map((M,N)=>t.jsx(ys,{book:M,onNavigate:r,renderLink:s,showVolumes:M.volumes.length>1},`${_.volume}-${N}`))]},`${_.volume}-${C}`)):v.map((_,C)=>t.jsx(ys,{book:_,onNavigate:r,renderLink:s,showVolumes:!0},C)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},em="guji_markdown";function uo(e){const n=e==null?void 0:e.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 tm=/^□\{guess=([^\s{}]+)\}/;function nm(e,n){const o=e[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function rl(e,n){let o=0;for(let r=n;r<e.length;r++){const s=e[r];if(s===`
|
|
146
|
+
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function im(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function om(e,n){const o=e[n];if(o==="["&&e[n+1]==="["){const r=e.indexOf("]]",n+2);return r>=0&&e.slice(n+2,r).indexOf(`
|
|
147
|
+
`)<0?{node:{type:"qw",label:e.slice(n+2,r)},end:r+2}:null}if(o===":"&&e.startsWith(":zi[",n)){const r=rl(e,n+3);return r>n+4?{node:{type:"zi",label:im(e.slice(n+4,r))},end:r+1}:null}if(o==="□"&&e[n+1]==="{"){const r=tm.exec(e.slice(n,n+64));if(r)return{node:{type:"qz",guess:r[1]},end:n+r[0].length}}return null}function sl(e,n,o,r){const s=[];let a="";const l=()=>{if(!a)return;const d=r?a.replace(/\\?\|/g,""):a;d&&s.push({type:"text",text:d}),a=""};for(;n<e.length;){const d=e[n];if(o!==null){if(d===o)return l(),{nodes:s,end:n};if(d===`
|
|
148
|
+
`)return null}const c=om(e,n);if(c){l(),s.push(c.node),n=c.end;continue}let p=null;if(d==="⟨"?p="⟩":d==="<"&&nm(e,n)&&(p=">"),p){const u=sl(e,n+1,p,!0);if(u){l(),s.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}a+=d,n++}return o!==null?null:(l(),{nodes:s,end:n})}function al(e){return sl(e,0,null,!1).nodes}function rm(e){return/[<⟨□]|\[\[|:zi\[/.test(e)}function ll(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${ll(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const cl="guji-table-v1";function dl(e){return!!e&&e.table_notation===cl}const sm=/^:::table(?:\{[^}]*\})?[ \t]*$/,am=/^:::[ \t]*$/;function pl(e){const n=[];let o="";for(let r=0;r<e.length;r++){const s=e[r];if(s===":"&&e.startsWith(":zi[",r)){const l=rl(e,r+3);if(l>r+4){o+=e.slice(r,l+1),r=l;continue}}let a=null;if(s==="⟨")a="⟩";else if(s==="<"){const l=e[r+1];l!==void 0&&!/[A-Za-z/!?>\s]/.test(l)&&(a=">")}if(a){const l=e.indexOf(a,r+1);if(l>0){o+=e.slice(r,l+1),r=l;continue}}s==="|"?(n.push(o),o=""):o+=s}return n.push(o),n.map(r=>r.trim())}const lm=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function cm(e){if(e==="^")return{cont:!0};const n=lm.exec(e),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,a=o==="_";return{cont:!1,cell:{text:a?"":o,empty:a,colspan:r,rowspan:s}}}function ul(e,n=1){const o=[],r=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let u=d.trim();if(!u)return;let m=!1;u.startsWith("!")&&(m=!0,u=u.slice(1));const h=pl(u).map(cm),f=a.map(w=>w>0),x=a.map(w=>w>0?w-1:0),k=[];let y=0;for(const w of h){if(w.cont){f[y]||o.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=w;for(let j=y;j<y+b.colspan;j++)if(f[j]){o.push(`第 ${p} 行第 ${j+1} 列:此处被上方跨行格占住,应写 ^`);break}if(b.rowspan>1)for(let j=y;j<y+b.colspan;j++)x[j]=b.rowspan-1;k.push(b),y+=b.colspan}for(let w=y;w<f.length;w++)f[w]&&o.push(`第 ${p} 行第 ${w+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let w=0;w<x.length;w++)x[w]===void 0&&(x[w]=0);a=x,r.push({header:m,cells:k}),s.push({width:y,line:p})});const l=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==l&&o.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${l} 不符`);return a.some(d=>d>0)&&o.push("表尾:有跨行格超出了表的最后一行"),r.length===0&&o.push("空表"),{rows:r,columns:l,warnings:o}}function Go(e){const n=e.split(`
|
|
149
149
|
`),o=[];let r=[];const s=()=>{if(r.length===0)return;const l=r.join(`
|
|
150
|
-
`);r=[],o.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(
|
|
151
|
-
`)}),a=l+1;continue}}r.push(n[a]),a++}return s(),o.map((l,d)=>{var p,u;if(l.type!=="text")return l;let c=l.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(l=>l.type!=="text"||l.text!=="")}const qi=e=>e?e.catch(()=>null):Promise.resolve(null);function
|
|
150
|
+
`);r=[],o.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(sm.test(n[a].trim())){let l=a+1;for(;l<n.length&&!am.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);o.push({type:"table",table:ul(d,a+1),source:n.slice(a,l+1).join(`
|
|
151
|
+
`)}),a=l+1;continue}}r.push(n[a]),a++}return s(),o.map((l,d)=>{var p,u;if(l.type!=="text")return l;let c=l.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(l=>l.type!=="text"||l.text!=="")}const qi=e=>e?e.catch(()=>null):Promise.resolve(null);function ml(e){const n=new Map;function o(r){var a;let s=n.get(r);return s||(s=qi((a=e.getTextManifest)==null?void 0:a.call(e,r)).then(l=>{const d=l&&Array.isArray(l.versions)&&l.versions.length>0?l:null;return d||n.delete(r),d}),n.set(r,s)),s}return{getManifest(r){return _e.isSafeSegment(r)?o(r):Promise.resolve(null)},async getIndex(r,s){return!_e.isSafeSegment(r)||!_e.isSafeSegment(s)||!e.getTextIndex?null:qi(e.getTextIndex(r,s))},async getChapter(r,s,a,l){return!_e.isSafeSegment(r)||!_e.isSafeSegment(s)||!_e.isSafeSegment(a)||!e.getChapter?null:qi(e.getChapter(r,s,a,l))}}}const Zt=()=>{const{t:e}=J(),[n,o]=g.useState(1);return g.useEffect(()=>{const r=setInterval(()=>o(s=>s>=3?1:s+1),500);return()=>clearInterval(r)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:i("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},Xi=String.raw`https?:\/\/[^\s()()<>"]+`,dm=new RegExp(String.raw`\[([^\]\n]+)\]\((${Xi})\)`+String.raw`|(《[^》\n]+》)\s?[((](${Xi})[))]`+`|(${Xi})`,"g");function pm(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function um(e){const n=[];let o=0;for(const r of e.matchAll(dm)){const s=r.index??0;s>o&&n.push({text:e.slice(o,s)}),r[1]!==void 0?n.push({text:r[1],url:r[2]}):r[3]!==void 0?n.push({text:r[3],url:r[4]}):n.push({text:pm(r[5]),url:r[5]}),o=s+r[0].length}return o<e.length&&n.push({text:e.slice(o)}),n}function hl({text:e,convert:n,className:o="bim-rd-link"}){return t.jsx(t.Fragment,{children:um(e).map((r,s)=>r.url?t.jsx("a",{className:o,href:r.url,target:"_blank",rel:"noopener noreferrer",children:n(r.text)},s):t.jsx(g.Fragment,{children:n(r.text)},s))})}const gl="(min-width: 1100px)",fl="(max-width: 719px)",xl="(max-width: 859px)",mm=`${fl}, (pointer: coarse)`,It=i("reader-top"),hm="48px",bl=`
|
|
152
152
|
.bim-rd {
|
|
153
153
|
position: relative;
|
|
154
154
|
background: ${i("page-bg")};
|
|
155
155
|
color: ${i("ink")};
|
|
156
156
|
font-family: ${i("font-ui")};
|
|
157
|
-
--bimrd-bar-h: ${
|
|
157
|
+
--bimrd-bar-h: ${hm};
|
|
158
158
|
}
|
|
159
159
|
.bim-rd *, .bim-rd *::before, .bim-rd *::after { box-sizing: border-box; }
|
|
160
160
|
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
|
|
181
181
|
/* ── 工具条:文字 + 图标,不画按钮外框 ── */
|
|
182
182
|
.bim-rd-bar {
|
|
183
|
-
position: sticky; top: ${
|
|
183
|
+
position: sticky; top: ${It}; z-index: 30;
|
|
184
184
|
height: var(--bimrd-bar-h);
|
|
185
185
|
display: flex; align-items: center; gap: 16px;
|
|
186
186
|
padding: 0 20px;
|
|
@@ -235,14 +235,14 @@
|
|
|
235
235
|
display: grid;
|
|
236
236
|
grid-template-columns: auto auto minmax(0, 1fr);
|
|
237
237
|
align-items: start;
|
|
238
|
-
min-height: calc(100vh - ${
|
|
238
|
+
min-height: calc(100vh - ${It} - var(--bimrd-bar-h));
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
/* 目录:宽屏是侧栏 */
|
|
242
242
|
.bim-rd-toc {
|
|
243
243
|
grid-column: 1;
|
|
244
|
-
position: sticky; top: calc(${
|
|
245
|
-
width: 248px; height: calc(100vh - ${
|
|
244
|
+
position: sticky; top: calc(${It} + var(--bimrd-bar-h));
|
|
245
|
+
width: 248px; height: calc(100vh - ${It} - var(--bimrd-bar-h));
|
|
246
246
|
overflow-y: auto; overscroll-behavior: contain;
|
|
247
247
|
padding: 0 10px 40px;
|
|
248
248
|
background: ${i("sidebar-bg")};
|
|
@@ -279,8 +279,8 @@
|
|
|
279
279
|
/* 书影:正文左侧 */
|
|
280
280
|
.bim-rd-img {
|
|
281
281
|
grid-column: 2;
|
|
282
|
-
position: sticky; top: calc(${
|
|
283
|
-
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${
|
|
282
|
+
position: sticky; top: calc(${It} + var(--bimrd-bar-h));
|
|
283
|
+
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${It} - var(--bimrd-bar-h));
|
|
284
284
|
padding: 16px 0 16px 20px;
|
|
285
285
|
display: flex; flex-direction: column; gap: 8px;
|
|
286
286
|
}
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
display: flex; align-items: center; justify-content: center; overflow: hidden;
|
|
292
292
|
}
|
|
293
293
|
.bim-rd-img-fig { position: relative; margin: 0; max-width: 100%; max-height: 100%; }
|
|
294
|
-
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${
|
|
294
|
+
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${It} - var(--bimrd-bar-h) - 80px); object-fit: contain; }
|
|
295
295
|
.bim-rd-img-fig svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
296
296
|
.bim-rd-img-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center; font-size: 13px; color: ${i("meta-fg")}; }
|
|
297
297
|
.bim-rd-img-empty b { font-size: 15px; font-weight: 500; color: ${i("quiet-fg")}; }
|
|
@@ -387,7 +387,7 @@
|
|
|
387
387
|
|
|
388
388
|
/* 竖排(预留):只在宿主打开 allowVertical 时可切换 */
|
|
389
389
|
.bim-rd-vertical .bim-rd-prose {
|
|
390
|
-
writing-mode: vertical-rl; max-height: calc(100vh - ${
|
|
390
|
+
writing-mode: vertical-rl; max-height: calc(100vh - ${It} - var(--bimrd-bar-h) - 120px);
|
|
391
391
|
overflow-x: auto; text-align: start;
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -444,7 +444,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
444
444
|
.bim-rd-sheet-img .bim-rd-img-fig img { max-height: 60vh; }
|
|
445
445
|
.bim-rd-sheet-fs { display: flex; align-items: center; justify-content: center; gap: 24px; padding: 8px 0 12px; font-size: 15px; color: ${i("ink")}; }
|
|
446
446
|
.bim-rd-sheet-fs .bim-rd-t { min-width: 56px; min-height: 44px; justify-content: center; font-size: 17px; border: 1px solid ${i("rule")}; }
|
|
447
|
-
@media ${
|
|
447
|
+
@media ${xl} {
|
|
448
448
|
.bim-rd[data-bb] .bim-rd-text { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom, 0px)); }
|
|
449
449
|
/* 底栏上已有的,工具条上不再重复(目录、字号) */
|
|
450
450
|
.bim-rd[data-bb] .bim-rd-bb-dup { display: none !important; }
|
|
@@ -454,7 +454,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
454
454
|
|
|
455
455
|
/* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
|
|
456
456
|
A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
|
|
457
|
-
@media ${
|
|
457
|
+
@media ${mm} {
|
|
458
458
|
.bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
|
|
459
459
|
.bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
|
|
460
460
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
@@ -467,7 +467,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
/* ── 中屏以下:目录改抽屉 ── */
|
|
470
|
-
@media not all and ${
|
|
470
|
+
@media not all and ${gl} {
|
|
471
471
|
.bim-rd-toc {
|
|
472
472
|
position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
|
|
473
473
|
width: min(86vw, 320px);
|
|
@@ -481,7 +481,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
/* ── 窄屏:书影收起,只留正文 ── */
|
|
484
|
-
@media ${
|
|
484
|
+
@media ${fl} {
|
|
485
485
|
.bim-rd-bar { padding: 0 12px; gap: 10px; }
|
|
486
486
|
.bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
|
|
487
487
|
/* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
|
|
@@ -634,12 +634,12 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
634
634
|
letter-spacing: 0.05em;
|
|
635
635
|
margin-left: 6px;
|
|
636
636
|
}
|
|
637
|
-
`;function Yo(e,n){var o;return n?e.key===n?!0:!!((o=e.children)!=null&&o.some(r=>Yo(r,n))):!1}const mm=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function hm({item:e,activeKey:n,onSelect:o,tabKey:r}){const s=Yo(e,n),[a,l]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&l(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&l(!0)},[e.defaultExpanded]),t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":a,"data-rd-toc-key":e.key,tabIndex:r===e.key?0:-1,onClick:()=>l(d=>!d),children:[t.jsx(mm,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(bl,{items:e.children,activeKey:n,onSelect:o,tabKey:r})]})}function bl({items:e,activeKey:n,onSelect:o,tabKey:r}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(hm,{item:s,activeKey:n,onSelect:o,tabKey:r},s.key):t.jsx("li",{children:t.jsxs("button",{type:"button",className:"bim-rd-ti","aria-current":s.key===n?"true":void 0,disabled:s.disabled,"data-rd-toc-key":s.key,tabIndex:r===s.key?0:-1,onClick:()=>o(s.key),children:[t.jsx("span",{children:s.label}),s.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function ys(e,n){var o;for(const r of e)if(r.key===n||Yo(r,n))return r.key;return((o=e[0])==null?void 0:o.key)??null}function yl({items:e,activeKey:n,onSelect:o,label:r}){const{t:s}=J(),a=r??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??ys(e,n)),[d,n,e]);g.useEffect(()=>{const m=l.current;if(!m)return;const h=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(h.length===0)return;const f=h.find(x=>x.dataset.rdTocKey===p)??h.find(x=>x.dataset.rdTocKey===ys(e,n))??h.find(x=>!x.disabled)??h[0];for(const x of h)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const m=l.current,h=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!h||!n)return;const f=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(k=>k.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-h.getBoundingClientRect().top+h.scrollTop;(x<h.scrollTop+80||x>h.scrollTop+h.clientHeight-40)&&(h.scrollTop=Math.max(0,x-h.clientHeight/3))},[n]);const u=g.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),k=x.indexOf(document.activeElement);let y=k;if(m.key==="ArrowDown"?y=Math.min(x.length-1,k+1):m.key==="ArrowUp"?y=Math.max(0,k-1):m.key==="Home"?y=0:m.key==="End"&&(y=x.length-1),y<0||y===k)return;m.preventDefault();const w=x[y];for(const b of x)b.tabIndex=-1;w.tabIndex=0,w.focus(),c(w.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:u,children:t.jsx(bl,{items:e,activeKey:n,onSelect:o,tabKey:p})})}function gm({page:e}){var n;return!((n=e.boxes)!=null&&n.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,r)=>t.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 mo({pages:e,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:a}=J(),[l,d]=g.useState(0),c=o??l,p=f=>{r?r(f):d(f)};if(g.useEffect(()=>{o===void 0&&d(0)},[e,o]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:a("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:a("reader.noImages")}),t.jsx("span",{children:a("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(e.length-1,c)),m=e[u],h=m.label??`${u+1}`;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:m.url,alt:m.alt??a("reader.imageAlt",{label:h}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(gm,{page:m}),s==null?void 0:s(m,u)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":a("reader.prevImage"),disabled:u===0,onClick:()=>p(u-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:m.label??`${u+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":a("reader.nextImage"),disabled:u===e.length-1,onClick:()=>p(u+1),children:"›"})]})]})}const Ko={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},$t=[15,16,17,18,20,22,24],ho=18,jl="bim-reader-prefs",fm="bim-reading-mode";function xm(){const e={...Ko};try{const n=localStorage.getItem(jl),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&$t.includes(o.fontSize)&&(e.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(fm))==="paragraph"&&(e.readingMode="paragraph"),o.properNames===!0&&(e.properNames=!0),o.writingMode==="vertical"&&(e.writingMode="vertical"),o.workLinks===!1&&(e.workLinks=!1)}catch{}return e}function bm(e){try{localStorage.setItem(jl,JSON.stringify(e))}catch{}}function Jn(e,n){const o=e??ho,r=$t;let s=r.indexOf(o);return s<0&&(s=r.indexOf(ho)),r[Math.max(0,Math.min(r.length-1,s+n))]}function vl(){const[e,n]=g.useState(Ko);g.useEffect(()=>{n(xm())},[]);const o=g.useCallback(r=>{n(s=>{const a={...s,...r};return bm(a),a})},[]);return[e,o]}function go(e){if(e.optionLabel)return e.optionLabel;const n=e.label||e.key;return!e.sourceName||n.includes(e.sourceName)?n:`${n} · ${e.sourceName}`}function kl(e,n){if(!(!e||e.length===0))return(n!=null?e.find(o=>o.key===n):void 0)??e.find(o=>o.primary)??e[0]}function wl(e){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(e),n}const js=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),ym=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M15 5l-7 7 7 7"})}),jm=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M9 5l7 7-7 7"})}),vs=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),t.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function ks(e,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],a=document.activeElement;e.shiftKey&&(a===r||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),r.focus())}function ws(e,n){const[o,r]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);r(s.matches);const a=()=>r(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),o}function vm(){const e=g.useContext(Xt),{t:n}=J();if(!e)return null;const o=e.locale==="zh-Hant";return t.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>e.setLocale(o?"zh-Hans":"zh-Hant"),children:[t.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),t.jsx("span",{className:"bim-rd-off",children:"|"}),t.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function km(e,n){if(!e)return;let o;for(const r of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(r.getBoundingClientRect().top<=n+8)o=r.id;else break;return o}function wm(e){var a;if(typeof window>"u"||!e)return;const n=(a=window.getSelection)==null?void 0:a.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const o=e.querySelector(".bim-rd-col"),r=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(o!=null&&o.contains(l))&&!(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 Sl({title:e,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:a,tocCaption:l,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:u="auto",prefs:m,onPrefsChange:h,paragraphToggle:f,properNameToggle:x=!0,allowVertical:k,byline:y,current:w,workLinkToggle:b,rail:j,onReportError:S,revisedAt:v,backHref:$,backLabel:_,bottomBar:C=!0,pager:M=!0,pagerUnit:N,versions:T,currentVersionKey:F,onVersionChange:R,versionSource:E=!0,keepChapterOnVersionChange:L=!1,customImagePanel:I,toolbarExtra:P,isWarpMode:V,children:X,className:D,style:O}){const{t:A,convert:G}=J(),se=_??A("reader.back"),Q=G(N??A("reader.unitJuan")),ve=g.useId().replace(/:/g,""),ne=`bim-rd-toc-${ve}`,ce=`bim-rd-text-${ve}`,We=g.useRef(null),ke=g.useRef(null),Pe=g.useRef(null),Ee=g.useRef(null),Z=ws(hl,!0),le=ws(fl,!1),oe=C&&le,[he,U]=g.useState(null),$e=g.useRef(null),me=g.useRef(null),Ce=(q,ue)=>{me.current=ue,U(re=>re===q?null:q)},Y=g.useCallback(()=>{var q;U(null),(q=me.current)==null||q.focus()},[]);g.useEffect(()=>{oe||U(null)},[oe]),g.useEffect(()=>{var q,ue;he&&((ue=(q=$e.current)==null?void 0:q.querySelector("button:not([disabled])"))==null||ue.focus())},[he]);const[ze,Me]=g.useState("auto"),B=ze==="auto"?Z:ze==="open",te=!Z,xe=!!I||!!d&&d.length>0,[Re,H]=g.useState(u);g.useEffect(()=>{H(u)},[u]);const de=Re==="auto"?xe||!!c:Re==="open",ee=g.useCallback(q=>{var ue;Me("auto"),q&&((ue=Ee.current)==null||ue.focus())},[]),ye=()=>Me(B?"closed":"open");g.useEffect(()=>{if(!te||ze!=="open")return;const q=Pe.current,ue=q==null?void 0:q.querySelector('input, [data-rd-toc-key][tabindex="0"]');ue==null||ue.focus()},[te,ze]);const Se=g.useCallback(q=>{s(q),te&&ee(!1);const ue=ke.current,re=We.current;if(ue&&re&&typeof window<"u"){const we=ue.getBoundingClientRect().top-re.getBoundingClientRect().bottom;we<0&&window.scrollBy({top:we})}},[s,te,ee]),Be=g.useMemo(()=>wl(o),[o]),[De,Je]=g.useState(null),He=kl(T,F!==void 0?F:De),Ue=(He==null?void 0:He.key)??null,z=g.useMemo(()=>Be.map(q=>q.key).join(`
|
|
638
|
-
`),[Be]),ie=g.useRef(null),ae=q=>{q!==Ue&&(L||(ie.current={key:q,sig:z,done:!1}),F===void 0&&Je(q),R==null||R(q))};g.useEffect(()=>{const q=ie.current;if(!q||q.key!==Ue)return;const ue=Be.find(we=>!we.disabled);if(!ue)return;const re=z!==q.sig;!re&&q.done||(re?ie.current=null:q.done=!0,ue.key!==r&&Se(ue.key))},[Ue,z,Be,r,Se]);const be=Be.find(q=>q.key===r),je=()=>{var q;S==null||S({chapterKey:r,chapterLabel:typeof(be==null?void 0:be.label)=="string"?be.label:void 0,anchor:km(ke.current,((q=We.current)==null?void 0:q.getBoundingClientRect().bottom)??0),selectedText:wm(ke.current)})},ge=Be.findIndex(q=>q.key===r),Ie=ge>0?Be.slice(0,ge).reverse().find(q=>!q.disabled):void 0,K=ge>=0?Be.slice(ge+1).find(q=>!q.disabled):void 0,fe=m.fontSize??ho,Ne={...O,...m.fontSize?{"--bimrd-fs":`${m.fontSize}px`}:null};return t.jsxs("div",{className:["bim-rd",m.writingMode==="vertical"&&k?"bim-rd-vertical":"",D].filter(Boolean).join(" "),"data-toc":ze,"data-img":de?"open":"closed","data-bb":oe?"":void 0,"data-warp":V?"true":void 0,style:Ne,children:[t.jsx("style",{children:xl}),t.jsx("a",{className:"bim-rd-skip",href:`#${ce}`,onClick:q=>{var ue,re,we;q.preventDefault(),(ue=ke.current)==null||ue.focus(),(we=(re=ke.current)==null?void 0:re.scrollIntoView)==null||we.call(re,{block:"start"})},children:A("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:We,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":A("reader.backAria",{label:se}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:se})]}),(e||n||y||w)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),y&&t.jsx("span",{className:"bim-rd-by",children:y}),w&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:w})]}),n&&t.jsx("span",{children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":A("reader.settings"),children:[T&&T.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:He?G(go(He)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:A("reader.versionShort")}),t.jsx("select",{"aria-label":A("reader.version"),value:Ue??"",onChange:q=>ae(q.target.value),children:T.map(q=>t.jsx("option",{value:q.key,children:G(go(q))},q.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),M&&(Ie||K)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":A("reader.pagerGroup",{unit:Q}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.prevUnit",{unit:Q}),title:Ie?typeof Ie.label=="string"&&Ie.label?A("reader.prevUnitTitle",{unit:Q,label:Ie.label}):A("reader.prevUnit",{unit:Q}):A("reader.firstUnit",{unit:Q}),disabled:!Ie,onClick:()=>Ie&&Se(Ie.key),children:t.jsx(ym,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.nextUnit",{unit:Q}),title:K?typeof K.label=="string"&&K.label?A("reader.nextUnitTitle",{unit:Q,label:K.label}):A("reader.nextUnit",{unit:Q}):A("reader.lastUnit",{unit:Q}),disabled:!K,onClick:()=>K&&Se(K.key),children:t.jsx(jm,{})})]}),M&&(Ie||K)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:Ee,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":B,"aria-controls":ne,onClick:ye,children:[t.jsx(js,{}),t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":de,onClick:()=>H(de?"closed":"open"),children:[t.jsx(vs,{}),A("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(vm,{}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontSmaller"),disabled:fe<=$t[0],onClick:()=>h({fontSize:Jn(m.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontLarger"),disabled:fe>=$t[$t.length-1],onClick:()=>h({fontSize:Jn(m.fontSize,1)}),children:"A+"}),(f||x||k)&&t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),f&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":m.readingMode==="paragraph",title:A("reader.paragraphTitle"),onClick:()=>h({readingMode:m.readingMode==="paragraph"?"line":"paragraph"}),children:A("reader.paragraph")}),b&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[t.jsx("input",{type:"checkbox",checked:m.workLinks,onChange:q=>h({workLinks:q.target.checked})}),t.jsx("span",{children:A("reader.workLinks")})]}),x&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":m.properNames,title:A("reader.properNameTitle"),onClick:()=>h({properNames:!m.properNames}),children:A("reader.properName")}),k&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":m.writingMode==="vertical",onClick:()=>h({writingMode:m.writingMode==="vertical"?"horizontal":"vertical"}),children:A("reader.vertical")}),P]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:ne,ref:Pe,role:te&&B?"dialog":void 0,"aria-modal":te&&B?!0:void 0,"aria-label":te&&B?A("reader.toc"):void 0,onKeyDown:q=>{if(!(!te||!B)){if(q.key==="Escape"){q.stopPropagation(),ee(!0);return}q.key==="Tab"&&ks(q,Pe.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??A("reader.toc")}),te&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.closeToc"),onClick:()=>ee(!0),children:"✕"})]}),a]}),t.jsx(yl,{items:o,activeKey:r,onSelect:Se})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>ee(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":A("reader.images"),children:de&&(I||t.jsx(mo,{pages:d??null,loading:c,renderOverlay:p}))}),t.jsxs("div",{className:"bim-rd-text",id:ce,ref:ke,tabIndex:-1,"data-rail":(j||S)&&!V?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[X,E&&He&&(He.sourceName||He.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":He.key,children:[He.sourceName&&t.jsxs(t.Fragment,{children:[A("reader.sourceLabel")," ",He.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:He.sourceUrl,target:"_blank",rel:"noreferrer",children:G(He.sourceName)}):G(He.sourceName)]}),He.sourceName&&He.license&&t.jsx("span",{className:"bim-rd-dot"}),He.license&&t.jsx(t.Fragment,{children:A("reader.licenseOf",{license:He.license})})]}),v&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:A("reader.revisedAt",{date:v})}),S&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:q=>q.preventDefault(),onClick:je,children:A("reader.reportError")})}),M&&(Ie||K)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":A("reader.pagerNav"),children:[Ie?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>Se(Ie.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),A("reader.prevUnit",{unit:Q})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Ie.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",A("reader.firstUnit",{unit:Q})]}),K?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>Se(K.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[A("reader.nextUnit",{unit:Q}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:K.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[A("reader.lastUnit",{unit:Q})," →"]})]})]}),(j||S)&&!V&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":A("reader.rail"),children:[j,S&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:q=>q.preventDefault(),onClick:je,children:A("reader.reportError")})})]})]})]}),oe&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":A("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":B,"aria-controls":ne,onClick:()=>{U(null),ye()},children:[t.jsx(js,{}),t.jsx("span",{children:A("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":he==="img","aria-haspopup":"dialog",onClick:q=>Ce("img",q.currentTarget),children:[t.jsx(vs,{}),t.jsx("span",{children:A("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":he==="fs","aria-haspopup":"dialog",onClick:q=>Ce("fs",q.currentTarget),children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),t.jsx("span",{children:A("reader.fontSize")})]}),S&&t.jsxs("button",{type:"button",onMouseDown:q=>q.preventDefault(),onClick:()=>{U(null),je()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:A("reader.reportError")})]})]}),oe&&he&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:Y}),t.jsxs("div",{className:"bim-rd-sheet",ref:$e,role:"dialog","aria-modal":"true","aria-label":A(he==="img"?"reader.images":"reader.fontSize"),onKeyDown:q=>{if(q.key==="Escape"){q.stopPropagation(),Y();return}q.key==="Tab"&&ks(q,$e.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:A(he==="img"?"reader.images":"reader.fontSize")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.close"),onClick:Y,children:"✕"})]}),he==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(mo,{pages:d??null,loading:c,renderOverlay:p})}):t.jsxs("div",{className:"bim-rd-sheet-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontSmaller"),disabled:fe<=$t[0],onClick:()=>h({fontSize:Jn(m.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[fe,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontLarger"),disabled:fe>=$t[$t.length-1],onClick:()=>h({fontSize:Jn(m.fontSize,1)}),children:"A+"})]})]})]})]})}const _l=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Sm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Qe(e){return Sm[e]??e}const cn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],dn={熹平: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},$l={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function ki(e){const n=e.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 _m(e){return e>=1950?"":e>=1912?"民國":e>=1645?"清":e>=1368?"明":e>=1279?"元":e>=960?"宋":e>=907?"五代":e>=618?"唐":e>=581?"隋":e>=420?"南北朝":e>=265?"晉":e>=220?"三國":e>=-202?"漢":""}const $m=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,Ss={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function qo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(Ss))if(n.startsWith(s))return Ss[s];const o=Qe(n);if(Ut[o]!=null)return o;const r=zt(n);if(r&&n.length<=r.length+1)return Qe(r)}function Dt(e,n){if(n){const o=$l[`${n}|${e}`];if(o!=null)return o}return dn[e]}const Cm=1911;function zm(e){const n=dn[e];if(n==null)return;const o=wt[e];let r;for(const[s,a]of Object.entries(dn))wt[s]===o&&a>n&&(r==null||a<r)&&(r=a);return r!=null?r-1:void 0}const Tm={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function ci(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,o=0,r=!1;for(const a of e){const l=Tm[a];if(l===void 0)return;r=!0,a==="十"?o=(o||1)*10:a==="廿"||a==="卅"?(n+=l,o=0):o>=10?(n+=o+l,o=0):o=o*10+l}const s=n+o;return r&&s>0?s:void 0}function zt(e){for(const n of _l)if(e.startsWith(n))return n}const wt={};{const e=(n,o)=>{for(const r of o)wt[r]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Vt(e,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(dn))if(e.includes(r)&&!(o&&wt[r]&&wt[r]!==o&&$l[`${o}|${r}`]==null))return r}function Mn(e){var l,d,c;const n={era:"",reign:"",source:"none"},o=e.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=(l=e.lineage)==null?void 0:l.year_text;if(r){const p=zt(r)??"";return{era:Qe(p),reign:Vt(r,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=ki(s);if(p)return{era:_m(p.from),reign:"",source:"publication"};const u=zt(s)??qo(s)??((c=cn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",m=Vt(s,u)??"",h=u||(m?wt[m]??"":"");if(h||m)return{era:Qe(h),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=zt(a);if(p)return{era:Qe(p),reign:Vt(a,p)??"",source:"edition"};const u=cn.find(m=>m.pattern.test(a));if(u)return{era:Qe(u.era),reign:Vt(a,u.era)??u.reign??"",source:"edition"}}return n}function wi(e){var r,s,a,l,d,c,p,u,m;if(((r=e.dating)==null?void 0:r.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(a=e.publication_info)==null?void 0:a.year;if(n){const h=ki(n);if(h)return h.from}const o=[(l=e.lineage)==null?void 0:l.year_text,(d=e.publication_info)==null?void 0:d.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const h of o){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&h!==f&&(zt(f)||qo(f)))break;const x=h.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??h.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const j=parseInt(x[1],10);if(j>=100&&j<=2100)return j}const k=h.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const j=zt(h);if(!j||Qe(j)==="民國"){const v=ci(k[1]);if(v!=null&&v>=1&&v<=120)return Cm+v}}const y=zt(h)??((u=cn.find(j=>j.pattern.test(h)))==null?void 0:u.era),w=y?Qe(y):void 0,b=Vt(h,w)??(zt(h)||(m=cn.find(j=>j.pattern.test(h)))==null?void 0:m.reign);if(b){const j=Dt(b,w);if(j==null)continue;const S=h.indexOf(b),v=S>=0?h.slice(S+b.length):"",$=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=$?ci($[1]):void 0;return j+(_?_-1:0)}}}function Xo(e){var l,d,c,p,u,m;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const o=(d=e.lineage)==null?void 0:d.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=e.lineage)==null?void 0:c.year_text;if(r){const h=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const f=fo[Qe(h[1])],x=Ut[Qe(h[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const h=ki(s);if((h==null?void 0:h.to)!=null)return{from:h.from,to:h.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=fo[Qe(f[1])],k=Ut[Qe(f[2])];if(x!=null&&k!=null)return{from:Math.min(x,k)-20,to:Math.max(x,k)+40}}}const a=[(u=e.publication_info)==null?void 0:u.year,e.edition,e.title].filter(Boolean);for(const h of a){if(!/[間间]/.test(h))continue;const f=zt(h)??qo(h)??((m=cn.find(y=>y.pattern.test(h)))==null?void 0:m.era),x=f?Qe(f):void 0,k=[];for(const y of Object.keys(dn))h.includes(y)&&(x&&wt[y]&&wt[y]!==x||Dt(y,x)!=null&&k.push(y));if(k.length===0){const y=h.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const w of[y[1],y[2]])for(const b of Object.keys(dn))if(wt[b]===x&&!(b[0]!==w&&b[b.length-1]!==w)&&Dt(b,x)!=null){k.push(b);break}}}if(k.length>0){const y=k.map(S=>Dt(S,x)).filter(S=>S!=null),w=Math.min(...y),b=k.reduce((S,v)=>Dt(S,x)>=Dt(v,x)?S:v),j=zm(b)??Zi(x??"")??Math.max(...y);return{from:w,to:j>w?j:Zi(x??wt[b]??"")??w}}if(x&&Ut[x]!=null)return{from:Ut[x],to:Zi(x)??Ut[x]}}}const Ut={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Nm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Rm=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,_s=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function $s(e,n){for(const o of _l){const r=e.indexOf(o);if(r<0)continue;if(o.length===1){const c=e[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Vt(e.slice(r),Qe(o)))continue}const s=Qe(o);if(s===n)continue;const a=e.slice(r),l=Vt(a,s)??"";let d;if(l){const c=Dt(l,s);if(c!=null){const u=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=u?ci(u[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const o of cn)if(o.pattern.test(e))return{era:Qe(o.era),reign:o.reign??""}}function Em(e){var w,b,j,S,v;const n=Mn(e),o=((w=e.publication_info)==null?void 0:w.year)??"",r=o?ki(o):void 0;if(!n.era&&!n.reign&&!r)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((b=e.lineage)==null?void 0:b.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&$m.test(o),p=n.source==="publication"&&/[間间]/.test(o),u=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:u?m=parseInt(u[2],10):m=wi(e);const h=m==null?Xo(e):void 0;let f;n.source==="publication"&&(c||_s.test(o))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":_s.test(s)||!n.reign&&m==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((j=e.lineage)==null?void 0:j.year_text)??((S=e.lineage)==null?void 0:S.year)??""}」`:`出版著錄「${((v=e.publication_info)==null?void 0:v.year)??""}」`,k={era:n.era,reign:n.reign,year:m,yearRange:h,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(u){const $=l.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==k.era&&(k.laterRepair={era:$[1]})}if(!k.laterRepair&&Rm.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(k.laterRepair={era:$[1]})}const y=Nm.find($=>$.re.test(s));if(y){const $=s.search(y.re),_=s.slice($),C=$s(_,n.era)??$s(s,n.era);C&&(k.basedOn={era:C.era,reign:C.reign,year:C.year,relation:y.relation})}return k}const fo={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Zi(e){return fo[e]}function di(e){const n=wi(e);if(n!=null)return n;const o=Xo(e);if(o)return o.from;const r=Mn(e).era;return r?Ut[r]:void 0}const Cs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function xo(e){const n=Cs.indexOf(e);return n===-1?Cs.length:n}function Im(e){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of e){const a=s.relation;a==="part_of"?n.belongsTo.push(s):a==="collected_in"?n.collected.push(s):a==="has_part"||a==="contains_text_of"?n.contains.push(s):a==="text_carried_by"||a==="studied_by"||a==="derived_from"||a==="followed_by"||a==="has_adaptation"?n.derivative.push(s):a==="studies"||a==="preceded_by"?n.studies.push(s):n.related.push(s)}const o=[],r=(s,a)=>{n[s].length&&o.push({key:s,labelKey:a,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function Zo(e,n){const o=Mo(e||[]),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,m)=>{const h=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return h(u)-h(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const u=qt(p),m=u.includes("text"),h=u.includes("image");m&&h?a.textImage.push(p):m?a.text.push(p):h?a.image.push(p):a.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>a[p].length>0).map(p=>({key:p,items:a[p]})),c=[...r.entries()].map(([p,u])=>{var m,h;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(h=n==null?void 0:n[p])==null?void 0:h.description,items:u}});return{buckets:d,mirrors:c,total:o.length}}function Si(e,n=mn("zh-Hant")){const o=[],r=e.metadata||{};r.edition&&o.push(String(r.edition)),e.source_label&&o.push(e.source_label),e.details&&o.push(e.details);const s=fi(e);return s&&s.expected>0&&o.push(s.missing>0?n("detail.volumeStatsMissing",{found:s.found,expected:s.expected,missing:s.missing}):n("detail.volumeStats",{found:s.found,expected:s.expected})),r.version&&o.push(String(r.version)),o.join(" · ")}function Cl(e,n){if(Si(e)||n.filter(r=>r.name===e.name).length<2)return"";try{const r=new URL(e.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const a=r.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}function zl(e,n){var a,l;const o=e.resources||[],r=[],s=[];for(const d of o){const c=qt(d);c.includes("image")&&r.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Mn(e),year:wi(e),sortYear:di(e),images:r,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:Lm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:r.length>0}}function Lm(e,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(e))return!0;const a=(r==null?void 0:r.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function Tl(e,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!r.has(c.id)).map(c=>zl(c,n));let a=s;o.era&&(a=a.filter(c=>c.era.era===o.era)),o.scanOnly&&(a=a.filter(c=>c.hasImage)),o.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const u=c.r.sortYear,m=p.r.sortYear;return u!=null&&m!=null?u-m||c.i-p.i:u!=null?-1:m!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const u=m=>(m.important?0:1)*2+(m.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)=>xo(c)-xo(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Am(e,n){var y,w;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,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)??[],a=r.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(r),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const j=n.node_groups[b];return j!=null&&d.has(j)},u=[],m=new Map,h=[];for(const b of e)if(!((w=n.excluded_books)!=null&&w.includes(b)))if(p(b))u.push(b);else{const j=n.node_groups[b];j?(m.has(j)||m.set(j,[]),m.get(j).push(b)):h.push(b)}if(h.length+[...m.values()].reduce((b,j)=>b+j.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),k=[...m.entries()].map(([b,j])=>{const S=x.get(b);return{id:b,label:(S==null?void 0:S.label)??b,description:S==null?void 0:S.description,ids:j}});return h.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:h}),{useGrouping:!0,coreIds:u,groupedIds:k}}const Nl=["撰","編","注","校","譯","繪","其他"],Pm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Jo(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of Pm)if(r.test(n))return o;return"其他"}function Qo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Rl(e,n="全部"){const o=new Map;for(const s of e){const a=Jo(s);o.set(a,(o.get(a)??0)+1)}const r=[{cls:"全部",label:n,count:e.length}];for(const s of Nl){const a=o.get(s);a&&r.push({cls:s,label:s,count:a})}return r.length>2?r:[]}function El(e,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(l=>({id:l.work_id||l.book_id||void 0,title:l.title,section:l.section,volumes:l.volumes||[],subItems:l.sub_items,edition:l.edition,found:l.found_volumes,expected:l.expected_volumes})),a=[...new Set(s.map(l=>l.section).filter(Boolean))];return{rows:s,source:"catalog",sections:a,totalVolumes:n.total_volumes}}return e.contained_works&&e.contained_works.length>0?{rows:e.contained_works.map(a=>({id:a.id,title:a.title,volumes:In(a.volume_index)})),source:"works",sections:[]}:{rows:(e.books||[]).map(s=>{var a,l;return{id:s,title:((a=o==null?void 0:o.get(s))==null?void 0:a.title)||s,edition:(l=o==null?void 0:o.get(s))==null?void 0:l.edition,volumes:[]}}),source:"books",sections:[]}}function In(e){if(e==null)return[];if(typeof e=="number")return[e];if(Array.isArray(e))return e.filter(n=>typeof n=="number");if(typeof e=="string"){const n=e.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[o,r]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,r-o+1)},(s,a)=>o+a)}return e.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function _i(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=[...e].sort((a,l)=>a-l),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 Mm=["〇","一","二","三","四","五","六","七","八","九"],zs=["","十","百","千"];function Il(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let a=0;a<o;a++){const l=parseInt(n[a]),d=o-1-a;l===0?s=!0:(s&&r&&(r+="〇"),s=!1,l===1&&d===1&&a===0?r+=zs[d]:r+=Mm[l]+zs[d])}return r}function Bm(e){return e==null?"":typeof e=="string"?e:e.title??""}function Nt(e,n="卷"){var r,s;const o=e;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?Il(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function Ll(e){var r;if(e.edition_type)return e.edition_type;if((r=e.lineage)!=null&&r.category)return e.lineage.category;const n=e.edition||e.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of o)if(s.test(n))return a;return""}const Wm=216,Ts="clamp(280px, 23vw, 360px)",Om=1440,bo="(max-width: 719px)",Hm=`${bo}, (pointer: coarse)`,Fm=`
|
|
639
|
-
.bim-d-main.bim-d-main-grid { max-width: ${
|
|
637
|
+
`;function Yo(e,n){var o;return n?e.key===n?!0:!!((o=e.children)!=null&&o.some(r=>Yo(r,n))):!1}const gm=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function fm({item:e,activeKey:n,onSelect:o,tabKey:r}){const s=Yo(e,n),[a,l]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&l(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&l(!0)},[e.defaultExpanded]),t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":a,"data-rd-toc-key":e.key,tabIndex:r===e.key?0:-1,onClick:()=>l(d=>!d),children:[t.jsx(gm,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(yl,{items:e.children,activeKey:n,onSelect:o,tabKey:r})]})}function yl({items:e,activeKey:n,onSelect:o,tabKey:r}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(fm,{item:s,activeKey:n,onSelect:o,tabKey:r},s.key):t.jsx("li",{children:t.jsxs("button",{type:"button",className:"bim-rd-ti","aria-current":s.key===n?"true":void 0,disabled:s.disabled,"data-rd-toc-key":s.key,tabIndex:r===s.key?0:-1,onClick:()=>o(s.key),children:[t.jsx("span",{children:s.label}),s.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function js(e,n){var o;for(const r of e)if(r.key===n||Yo(r,n))return r.key;return((o=e[0])==null?void 0:o.key)??null}function jl({items:e,activeKey:n,onSelect:o,label:r}){const{t:s}=J(),a=r??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??js(e,n)),[d,n,e]);g.useEffect(()=>{const m=l.current;if(!m)return;const h=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(h.length===0)return;const f=h.find(x=>x.dataset.rdTocKey===p)??h.find(x=>x.dataset.rdTocKey===js(e,n))??h.find(x=>!x.disabled)??h[0];for(const x of h)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const m=l.current,h=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!h||!n)return;const f=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(k=>k.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-h.getBoundingClientRect().top+h.scrollTop;(x<h.scrollTop+80||x>h.scrollTop+h.clientHeight-40)&&(h.scrollTop=Math.max(0,x-h.clientHeight/3))},[n]);const u=g.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const f=l.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),k=x.indexOf(document.activeElement);let y=k;if(m.key==="ArrowDown"?y=Math.min(x.length-1,k+1):m.key==="ArrowUp"?y=Math.max(0,k-1):m.key==="Home"?y=0:m.key==="End"&&(y=x.length-1),y<0||y===k)return;m.preventDefault();const w=x[y];for(const b of x)b.tabIndex=-1;w.tabIndex=0,w.focus(),c(w.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:u,children:t.jsx(yl,{items:e,activeKey:n,onSelect:o,tabKey:p})})}function xm({page:e}){var n;return!((n=e.boxes)!=null&&n.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,r)=>t.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 mo({pages:e,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:a}=J(),[l,d]=g.useState(0),c=o??l,p=f=>{r?r(f):d(f)};if(g.useEffect(()=>{o===void 0&&d(0)},[e,o]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:a("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:a("reader.noImages")}),t.jsx("span",{children:a("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(e.length-1,c)),m=e[u],h=m.label??`${u+1}`;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:m.url,alt:m.alt??a("reader.imageAlt",{label:h}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(xm,{page:m}),s==null?void 0:s(m,u)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":a("reader.prevImage"),disabled:u===0,onClick:()=>p(u-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:m.label??`${u+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":a("reader.nextImage"),disabled:u===e.length-1,onClick:()=>p(u+1),children:"›"})]})]})}const Ko={fontSize:null,readingMode:"line",properNames:null,writingMode:"horizontal",workLinks:!0},$t=[15,16,17,18,20,22,24],ho=18,vl="bim-reader-prefs",bm="bim-reading-mode";function ym(){const e={...Ko};try{const n=localStorage.getItem(vl),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&$t.includes(o.fontSize)&&(e.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(bm))==="paragraph"&&(e.readingMode="paragraph"),(o.properNames===!0||o.properNames===!1)&&(e.properNames=o.properNames),o.writingMode==="vertical"&&(e.writingMode="vertical"),o.workLinks===!1&&(e.workLinks=!1)}catch{}return e}function jm(e){try{localStorage.setItem(vl,JSON.stringify(e))}catch{}}function Jn(e,n){const o=e??ho,r=$t;let s=r.indexOf(o);return s<0&&(s=r.indexOf(ho)),r[Math.max(0,Math.min(r.length-1,s+n))]}function kl(){const[e,n]=g.useState(Ko);g.useEffect(()=>{n(ym())},[]);const o=g.useCallback(r=>{n(s=>{const a={...s,...r};return jm(a),a})},[]);return[e,o]}function go(e){if(e.optionLabel)return e.optionLabel;const n=e.label||e.key;return!e.sourceName||n.includes(e.sourceName)?n:`${n} · ${e.sourceName}`}function wl(e,n){if(!(!e||e.length===0))return(n!=null?e.find(o=>o.key===n):void 0)??e.find(o=>o.primary)??e[0]}function Sl(e){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(e),n}const vs=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),vm=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M15 5l-7 7 7 7"})}),km=()=>t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M9 5l7 7-7 7"})}),ks=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),t.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function ws(e,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],a=document.activeElement;e.shiftKey&&(a===r||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),r.focus())}function Ss(e,n){const[o,r]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);r(s.matches);const a=()=>r(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),o}function wm(){const e=g.useContext(Xt),{t:n}=J();if(!e)return null;const o=e.locale==="zh-Hant";return t.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>e.setLocale(o?"zh-Hans":"zh-Hant"),children:[t.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),t.jsx("span",{className:"bim-rd-off",children:"|"}),t.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function Sm(e,n){if(!e)return;let o;for(const r of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(r.getBoundingClientRect().top<=n+8)o=r.id;else break;return o}function _m(e){var a;if(typeof window>"u"||!e)return;const n=(a=window.getSelection)==null?void 0:a.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const o=e.querySelector(".bim-rd-col"),r=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(o!=null&&o.contains(l))&&!(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 _l({title:e,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:a,tocCaption:l,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:u="auto",prefs:m,onPrefsChange:h,paragraphToggle:f,properNameToggle:x=!0,allowVertical:k,byline:y,current:w,workLinkToggle:b,rail:j,onReportError:S,revisedAt:v,backHref:$,backLabel:_,bottomBar:C=!0,pager:M=!0,pagerUnit:N,versions:T,currentVersionKey:F,onVersionChange:R,versionSource:E=!0,keepChapterOnVersionChange:L=!1,customImagePanel:I,toolbarExtra:P,isWarpMode:V,children:X,className:D,style:O}){const{t:A,convert:G}=J(),se=_??A("reader.back"),Q=G(N??A("reader.unitJuan")),ke=g.useId().replace(/:/g,""),ne=`bim-rd-toc-${ke}`,de=`bim-rd-text-${ke}`,We=g.useRef(null),we=g.useRef(null),Pe=g.useRef(null),Ee=g.useRef(null),Z=Ss(gl,!0),ae=Ss(xl,!1),oe=C&&ae,[fe,U]=g.useState(null),$e=g.useRef(null),me=g.useRef(null),Ce=(q,le)=>{me.current=le,U(ce=>ce===q?null:q)},Y=g.useCallback(()=>{var q;U(null),(q=me.current)==null||q.focus()},[]);g.useEffect(()=>{oe||U(null)},[oe]),g.useEffect(()=>{var q,le;fe&&((le=(q=$e.current)==null?void 0:q.querySelector("button:not([disabled])"))==null||le.focus())},[fe]);const[ze,Me]=g.useState("auto"),B=ze==="auto"?Z:ze==="open",te=!Z,xe=!!I||!!d&&d.length>0,[Re,H]=g.useState(u);g.useEffect(()=>{H(u)},[u]);const pe=Re==="auto"?xe||!!c:Re==="open",ee=g.useCallback(q=>{var le;Me("auto"),q&&((le=Ee.current)==null||le.focus())},[]),be=()=>Me(B?"closed":"open");g.useEffect(()=>{if(!te||ze!=="open")return;const q=Pe.current,le=q==null?void 0:q.querySelector('input, [data-rd-toc-key][tabindex="0"]');le==null||le.focus()},[te,ze]);const Se=g.useCallback(q=>{s(q),te&&ee(!1);const le=we.current,ce=We.current;if(le&&ce&&typeof window<"u"){const ve=le.getBoundingClientRect().top-ce.getBoundingClientRect().bottom;ve<0&&window.scrollBy({top:ve})}},[s,te,ee]),Be=g.useMemo(()=>Sl(o),[o]),[De,Je]=g.useState(null),He=wl(T,F!==void 0?F:De),Ue=(He==null?void 0:He.key)??null,z=g.useMemo(()=>Be.map(q=>q.key).join(`
|
|
638
|
+
`),[Be]),ie=g.useRef(null),re=q=>{q!==Ue&&(L||(ie.current={key:q,sig:z,done:!1}),F===void 0&&Je(q),R==null||R(q))};g.useEffect(()=>{const q=ie.current;if(!q||q.key!==Ue)return;const le=Be.find(ve=>!ve.disabled);if(!le)return;const ce=z!==q.sig;!ce&&q.done||(ce?ie.current=null:q.done=!0,le.key!==r&&Se(le.key))},[Ue,z,Be,r,Se]);const je=Be.find(q=>q.key===r),ye=()=>{var q;S==null||S({chapterKey:r,chapterLabel:typeof(je==null?void 0:je.label)=="string"?je.label:void 0,anchor:Sm(we.current,((q=We.current)==null?void 0:q.getBoundingClientRect().bottom)??0),selectedText:_m(we.current)})},he=Be.findIndex(q=>q.key===r),Ne=he>0?Be.slice(0,he).reverse().find(q=>!q.disabled):void 0,K=he>=0?Be.slice(he+1).find(q=>!q.disabled):void 0,ge=m.fontSize??ho,Ae={...O,...m.fontSize?{"--bimrd-fs":`${m.fontSize}px`}:null};return t.jsxs("div",{className:["bim-rd",m.writingMode==="vertical"&&k?"bim-rd-vertical":"",D].filter(Boolean).join(" "),"data-toc":ze,"data-img":pe?"open":"closed","data-bb":oe?"":void 0,"data-warp":V?"true":void 0,style:Ae,children:[t.jsx("style",{children:bl}),t.jsx("a",{className:"bim-rd-skip",href:`#${de}`,onClick:q=>{var le,ce,ve;q.preventDefault(),(le=we.current)==null||le.focus(),(ve=(ce=we.current)==null?void 0:ce.scrollIntoView)==null||ve.call(ce,{block:"start"})},children:A("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:We,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":A("reader.backAria",{label:se}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:se})]}),(e||n||y||w)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),y&&t.jsx("span",{className:"bim-rd-by",children:y}),w&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:w})]}),n&&t.jsx("span",{children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":A("reader.settings"),children:[T&&T.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:He?G(go(He)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:A("reader.versionShort")}),t.jsx("select",{"aria-label":A("reader.version"),value:Ue??"",onChange:q=>re(q.target.value),children:T.map(q=>t.jsx("option",{value:q.key,children:G(go(q))},q.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),M&&(Ne||K)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":A("reader.pagerGroup",{unit:Q}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.prevUnit",{unit:Q}),title:Ne?typeof Ne.label=="string"&&Ne.label?A("reader.prevUnitTitle",{unit:Q,label:Ne.label}):A("reader.prevUnit",{unit:Q}):A("reader.firstUnit",{unit:Q}),disabled:!Ne,onClick:()=>Ne&&Se(Ne.key),children:t.jsx(vm,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.nextUnit",{unit:Q}),title:K?typeof K.label=="string"&&K.label?A("reader.nextUnitTitle",{unit:Q,label:K.label}):A("reader.nextUnit",{unit:Q}):A("reader.lastUnit",{unit:Q}),disabled:!K,onClick:()=>K&&Se(K.key),children:t.jsx(km,{})})]}),M&&(Ne||K)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:Ee,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":B,"aria-controls":ne,onClick:be,children:[t.jsx(vs,{}),t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":pe,onClick:()=>H(pe?"closed":"open"),children:[t.jsx(ks,{}),A("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(wm,{}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontSmaller"),disabled:ge<=$t[0],onClick:()=>h({fontSize:Jn(m.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontLarger"),disabled:ge>=$t[$t.length-1],onClick:()=>h({fontSize:Jn(m.fontSize,1)}),children:"A+"}),(f||x||k)&&t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),f&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":m.readingMode==="paragraph",title:A("reader.paragraphTitle"),onClick:()=>h({readingMode:m.readingMode==="paragraph"?"line":"paragraph"}),children:A("reader.paragraph")}),b&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[t.jsx("input",{type:"checkbox",checked:m.workLinks,onChange:q=>h({workLinks:q.target.checked})}),t.jsx("span",{children:A("reader.workLinks")})]}),x&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":!!m.properNames,title:A("reader.properNameTitle"),onClick:()=>h({properNames:!m.properNames}),children:A("reader.properName")}),k&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":m.writingMode==="vertical",onClick:()=>h({writingMode:m.writingMode==="vertical"?"horizontal":"vertical"}),children:A("reader.vertical")}),P]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:ne,ref:Pe,role:te&&B?"dialog":void 0,"aria-modal":te&&B?!0:void 0,"aria-label":te&&B?A("reader.toc"):void 0,onKeyDown:q=>{if(!(!te||!B)){if(q.key==="Escape"){q.stopPropagation(),ee(!0);return}q.key==="Tab"&&ws(q,Pe.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??A("reader.toc")}),te&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.closeToc"),onClick:()=>ee(!0),children:"✕"})]}),a]}),t.jsx(jl,{items:o,activeKey:r,onSelect:Se})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>ee(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":A("reader.images"),children:pe&&(I||t.jsx(mo,{pages:d??null,loading:c,renderOverlay:p}))}),t.jsxs("div",{className:"bim-rd-text",id:de,ref:we,tabIndex:-1,"data-rail":(j||S)&&!V?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[X,E&&He&&(He.sourceName||He.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":He.key,children:[He.sourceName&&t.jsxs(t.Fragment,{children:[A("reader.sourceLabel")," ",He.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:He.sourceUrl,target:"_blank",rel:"noreferrer",children:G(He.sourceName)}):G(He.sourceName)]}),He.sourceName&&He.license&&t.jsx("span",{className:"bim-rd-dot"}),He.license&&t.jsx(t.Fragment,{children:A("reader.licenseOf",{license:He.license})})]}),v&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:A("reader.revisedAt",{date:v})}),S&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:q=>q.preventDefault(),onClick:ye,children:A("reader.reportError")})}),M&&(Ne||K)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":A("reader.pagerNav"),children:[Ne?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>Se(Ne.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),A("reader.prevUnit",{unit:Q})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Ne.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",A("reader.firstUnit",{unit:Q})]}),K?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>Se(K.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[A("reader.nextUnit",{unit:Q}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:K.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[A("reader.lastUnit",{unit:Q})," →"]})]})]}),(j||S)&&!V&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":A("reader.rail"),children:[j,S&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:q=>q.preventDefault(),onClick:ye,children:A("reader.reportError")})})]})]})]}),oe&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":A("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":B,"aria-controls":ne,onClick:()=>{U(null),be()},children:[t.jsx(vs,{}),t.jsx("span",{children:A("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":fe==="img","aria-haspopup":"dialog",onClick:q=>Ce("img",q.currentTarget),children:[t.jsx(ks,{}),t.jsx("span",{children:A("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":fe==="fs","aria-haspopup":"dialog",onClick:q=>Ce("fs",q.currentTarget),children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),t.jsx("span",{children:A("reader.fontSize")})]}),S&&t.jsxs("button",{type:"button",onMouseDown:q=>q.preventDefault(),onClick:()=>{U(null),ye()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:A("reader.reportError")})]})]}),oe&&fe&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:Y}),t.jsxs("div",{className:"bim-rd-sheet",ref:$e,role:"dialog","aria-modal":"true","aria-label":A(fe==="img"?"reader.images":"reader.fontSize"),onKeyDown:q=>{if(q.key==="Escape"){q.stopPropagation(),Y();return}q.key==="Tab"&&ws(q,$e.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:A(fe==="img"?"reader.images":"reader.fontSize")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.close"),onClick:Y,children:"✕"})]}),fe==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(mo,{pages:d??null,loading:c,renderOverlay:p})}):t.jsxs("div",{className:"bim-rd-sheet-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontSmaller"),disabled:ge<=$t[0],onClick:()=>h({fontSize:Jn(m.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[ge,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontLarger"),disabled:ge>=$t[$t.length-1],onClick:()=>h({fontSize:Jn(m.fontSize,1)}),children:"A+"})]})]})]})]})}const $l=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],$m={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Qe(e){return $m[e]??e}const cn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],dn={熹平: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},Cl={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function ki(e){const n=e.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 Cm(e){return e>=1950?"":e>=1912?"民國":e>=1645?"清":e>=1368?"明":e>=1279?"元":e>=960?"宋":e>=907?"五代":e>=618?"唐":e>=581?"隋":e>=420?"南北朝":e>=265?"晉":e>=220?"三國":e>=-202?"漢":""}const zm=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,_s={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function qo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(_s))if(n.startsWith(s))return _s[s];const o=Qe(n);if(Ut[o]!=null)return o;const r=zt(n);if(r&&n.length<=r.length+1)return Qe(r)}function Dt(e,n){if(n){const o=Cl[`${n}|${e}`];if(o!=null)return o}return dn[e]}const Tm=1911;function Nm(e){const n=dn[e];if(n==null)return;const o=wt[e];let r;for(const[s,a]of Object.entries(dn))wt[s]===o&&a>n&&(r==null||a<r)&&(r=a);return r!=null?r-1:void 0}const Rm={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function ci(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,o=0,r=!1;for(const a of e){const l=Rm[a];if(l===void 0)return;r=!0,a==="十"?o=(o||1)*10:a==="廿"||a==="卅"?(n+=l,o=0):o>=10?(n+=o+l,o=0):o=o*10+l}const s=n+o;return r&&s>0?s:void 0}function zt(e){for(const n of $l)if(e.startsWith(n))return n}const wt={};{const e=(n,o)=>{for(const r of o)wt[r]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Vt(e,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(dn))if(e.includes(r)&&!(o&&wt[r]&&wt[r]!==o&&Cl[`${o}|${r}`]==null))return r}function Bn(e){var l,d,c;const n={era:"",reign:"",source:"none"},o=e.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=(l=e.lineage)==null?void 0:l.year_text;if(r){const p=zt(r)??"";return{era:Qe(p),reign:Vt(r,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=ki(s);if(p)return{era:Cm(p.from),reign:"",source:"publication"};const u=zt(s)??qo(s)??((c=cn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",m=Vt(s,u)??"",h=u||(m?wt[m]??"":"");if(h||m)return{era:Qe(h),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=zt(a);if(p)return{era:Qe(p),reign:Vt(a,p)??"",source:"edition"};const u=cn.find(m=>m.pattern.test(a));if(u)return{era:Qe(u.era),reign:Vt(a,u.era)??u.reign??"",source:"edition"}}return n}function wi(e){var r,s,a,l,d,c,p,u,m;if(((r=e.dating)==null?void 0:r.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(a=e.publication_info)==null?void 0:a.year;if(n){const h=ki(n);if(h)return h.from}const o=[(l=e.lineage)==null?void 0:l.year_text,(d=e.publication_info)==null?void 0:d.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const h of o){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&h!==f&&(zt(f)||qo(f)))break;const x=h.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??h.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const j=parseInt(x[1],10);if(j>=100&&j<=2100)return j}const k=h.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const j=zt(h);if(!j||Qe(j)==="民國"){const v=ci(k[1]);if(v!=null&&v>=1&&v<=120)return Tm+v}}const y=zt(h)??((u=cn.find(j=>j.pattern.test(h)))==null?void 0:u.era),w=y?Qe(y):void 0,b=Vt(h,w)??(zt(h)||(m=cn.find(j=>j.pattern.test(h)))==null?void 0:m.reign);if(b){const j=Dt(b,w);if(j==null)continue;const S=h.indexOf(b),v=S>=0?h.slice(S+b.length):"",$=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=$?ci($[1]):void 0;return j+(_?_-1:0)}}}function Xo(e){var l,d,c,p,u,m;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const o=(d=e.lineage)==null?void 0:d.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=e.lineage)==null?void 0:c.year_text;if(r){const h=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const f=fo[Qe(h[1])],x=Ut[Qe(h[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const h=ki(s);if((h==null?void 0:h.to)!=null)return{from:h.from,to:h.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=fo[Qe(f[1])],k=Ut[Qe(f[2])];if(x!=null&&k!=null)return{from:Math.min(x,k)-20,to:Math.max(x,k)+40}}}const a=[(u=e.publication_info)==null?void 0:u.year,e.edition,e.title].filter(Boolean);for(const h of a){if(!/[間间]/.test(h))continue;const f=zt(h)??qo(h)??((m=cn.find(y=>y.pattern.test(h)))==null?void 0:m.era),x=f?Qe(f):void 0,k=[];for(const y of Object.keys(dn))h.includes(y)&&(x&&wt[y]&&wt[y]!==x||Dt(y,x)!=null&&k.push(y));if(k.length===0){const y=h.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const w of[y[1],y[2]])for(const b of Object.keys(dn))if(wt[b]===x&&!(b[0]!==w&&b[b.length-1]!==w)&&Dt(b,x)!=null){k.push(b);break}}}if(k.length>0){const y=k.map(S=>Dt(S,x)).filter(S=>S!=null),w=Math.min(...y),b=k.reduce((S,v)=>Dt(S,x)>=Dt(v,x)?S:v),j=Nm(b)??Zi(x??"")??Math.max(...y);return{from:w,to:j>w?j:Zi(x??wt[b]??"")??w}}if(x&&Ut[x]!=null)return{from:Ut[x],to:Zi(x)??Ut[x]}}}const Ut={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Em=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Im=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,$s=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Cs(e,n){for(const o of $l){const r=e.indexOf(o);if(r<0)continue;if(o.length===1){const c=e[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Vt(e.slice(r),Qe(o)))continue}const s=Qe(o);if(s===n)continue;const a=e.slice(r),l=Vt(a,s)??"";let d;if(l){const c=Dt(l,s);if(c!=null){const u=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=u?ci(u[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const o of cn)if(o.pattern.test(e))return{era:Qe(o.era),reign:o.reign??""}}function Lm(e){var w,b,j,S,v;const n=Bn(e),o=((w=e.publication_info)==null?void 0:w.year)??"",r=o?ki(o):void 0;if(!n.era&&!n.reign&&!r)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((b=e.lineage)==null?void 0:b.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&zm.test(o),p=n.source==="publication"&&/[間间]/.test(o),u=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:u?m=parseInt(u[2],10):m=wi(e);const h=m==null?Xo(e):void 0;let f;n.source==="publication"&&(c||$s.test(o))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":$s.test(s)||!n.reign&&m==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((j=e.lineage)==null?void 0:j.year_text)??((S=e.lineage)==null?void 0:S.year)??""}」`:`出版著錄「${((v=e.publication_info)==null?void 0:v.year)??""}」`,k={era:n.era,reign:n.reign,year:m,yearRange:h,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(u){const $=l.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==k.era&&(k.laterRepair={era:$[1]})}if(!k.laterRepair&&Im.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(k.laterRepair={era:$[1]})}const y=Em.find($=>$.re.test(s));if(y){const $=s.search(y.re),_=s.slice($),C=Cs(_,n.era)??Cs(s,n.era);C&&(k.basedOn={era:C.era,reign:C.reign,year:C.year,relation:y.relation})}return k}const fo={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Zi(e){return fo[e]}function di(e){const n=wi(e);if(n!=null)return n;const o=Xo(e);if(o)return o.from;const r=Bn(e).era;return r?Ut[r]:void 0}const zs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function xo(e){const n=zs.indexOf(e);return n===-1?zs.length:n}function Am(e){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of e){const a=s.relation;a==="part_of"?n.belongsTo.push(s):a==="collected_in"?n.collected.push(s):a==="has_part"||a==="contains_text_of"?n.contains.push(s):a==="text_carried_by"||a==="studied_by"||a==="derived_from"||a==="followed_by"||a==="has_adaptation"?n.derivative.push(s):a==="studies"||a==="preceded_by"?n.studies.push(s):n.related.push(s)}const o=[],r=(s,a)=>{n[s].length&&o.push({key:s,labelKey:a,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function Zo(e,n){const o=Mo(e||[]),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,m)=>{const h=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return h(u)-h(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const u=qt(p),m=u.includes("text"),h=u.includes("image");m&&h?a.textImage.push(p):m?a.text.push(p):h?a.image.push(p):a.physical.push(p)}const d=["text","image","textImage","physical"].filter(p=>a[p].length>0).map(p=>({key:p,items:a[p]})),c=[...r.entries()].map(([p,u])=>{var m,h;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(h=n==null?void 0:n[p])==null?void 0:h.description,items:u}});return{buckets:d,mirrors:c,total:o.length}}function Si(e,n=mn("zh-Hant")){const o=[],r=e.metadata||{};r.edition&&o.push(String(r.edition)),e.source_label&&o.push(e.source_label),e.details&&o.push(e.details);const s=fi(e);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 zl(e,n){if(Si(e)||n.filter(r=>r.name===e.name).length<2)return"";try{const r=new URL(e.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const a=r.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}function Tl(e,n){var a,l;const o=e.resources||[],r=[],s=[];for(const d of o){const c=qt(d);c.includes("image")&&r.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:Bn(e),year:wi(e),sortYear:di(e),images:r,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:Pm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:r.length>0}}function Pm(e,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(e))return!0;const a=(r==null?void 0:r.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function Nl(e,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!r.has(c.id)).map(c=>Tl(c,n));let a=s;o.era&&(a=a.filter(c=>c.era.era===o.era)),o.scanOnly&&(a=a.filter(c=>c.hasImage)),o.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const u=c.r.sortYear,m=p.r.sortYear;return u!=null&&m!=null?u-m||c.i-p.i:u!=null?-1:m!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const u=m=>(m.important?0:1)*2+(m.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)=>xo(c)-xo(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Mm(e,n){var y,w;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,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)??[],a=r.length>0||s.length>0,l=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&l.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const d=new Set(r),c=new Set([...s,...l]),p=b=>{if(c.has(b))return!0;const j=n.node_groups[b];return j!=null&&d.has(j)},u=[],m=new Map,h=[];for(const b of e)if(!((w=n.excluded_books)!=null&&w.includes(b)))if(p(b))u.push(b);else{const j=n.node_groups[b];j?(m.has(j)||m.set(j,[]),m.get(j).push(b)):h.push(b)}if(h.length+[...m.values()].reduce((b,j)=>b+j.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),k=[...m.entries()].map(([b,j])=>{const S=x.get(b);return{id:b,label:(S==null?void 0:S.label)??b,description:S==null?void 0:S.description,ids:j}});return h.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:h}),{useGrouping:!0,coreIds:u,groupedIds:k}}const Rl=["撰","編","注","校","譯","繪","其他"],Bm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Jo(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of Bm)if(r.test(n))return o;return"其他"}function Qo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function El(e,n="全部"){const o=new Map;for(const s of e){const a=Jo(s);o.set(a,(o.get(a)??0)+1)}const r=[{cls:"全部",label:n,count:e.length}];for(const s of Rl){const a=o.get(s);a&&r.push({cls:s,label:s,count:a})}return r.length>2?r:[]}function Il(e,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(l=>({id:l.work_id||l.book_id||void 0,title:l.title,section:l.section,volumes:l.volumes||[],subItems:l.sub_items,edition:l.edition,found:l.found_volumes,expected:l.expected_volumes})),a=[...new Set(s.map(l=>l.section).filter(Boolean))];return{rows:s,source:"catalog",sections:a,totalVolumes:n.total_volumes}}return e.contained_works&&e.contained_works.length>0?{rows:e.contained_works.map(a=>({id:a.id,title:a.title,volumes:Ln(a.volume_index)})),source:"works",sections:[]}:{rows:(e.books||[]).map(s=>{var a,l;return{id:s,title:((a=o==null?void 0:o.get(s))==null?void 0:a.title)||s,edition:(l=o==null?void 0:o.get(s))==null?void 0:l.edition,volumes:[]}}),source:"books",sections:[]}}function Ln(e){if(e==null)return[];if(typeof e=="number")return[e];if(Array.isArray(e))return e.filter(n=>typeof n=="number");if(typeof e=="string"){const n=e.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[o,r]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,r-o+1)},(s,a)=>o+a)}return e.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function _i(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=[...e].sort((a,l)=>a-l),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 Wm=["〇","一","二","三","四","五","六","七","八","九"],Ts=["","十","百","千"];function Ll(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let a=0;a<o;a++){const l=parseInt(n[a]),d=o-1-a;l===0?s=!0:(s&&r&&(r+="〇"),s=!1,l===1&&d===1&&a===0?r+=Ts[d]:r+=Wm[l]+Ts[d])}return r}function Om(e){return e==null?"":typeof e=="string"?e:e.title??""}function Nt(e,n="卷"){var r,s;const o=e;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?Ll(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function Al(e){var r;if(e.edition_type)return e.edition_type;if((r=e.lineage)!=null&&r.category)return e.lineage.category;const n=e.edition||e.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of o)if(s.test(n))return a;return""}const Hm=216,Ns="clamp(280px, 23vw, 360px)",Fm=1440,bo="(max-width: 719px)",Dm=`${bo}, (pointer: coarse)`,Um=`
|
|
639
|
+
.bim-d-main.bim-d-main-grid { max-width: ${Fm}px; padding: 16px 32px 0; }
|
|
640
640
|
.bim-d-grid {
|
|
641
641
|
display: grid;
|
|
642
|
-
grid-template-columns: ${
|
|
642
|
+
grid-template-columns: ${Hm}px minmax(0, 1fr) ${Ns};
|
|
643
643
|
grid-template-rows: auto 1fr;
|
|
644
644
|
grid-template-areas: "rail main card" "rail main side";
|
|
645
645
|
column-gap: 32px; row-gap: 28px; align-items: start;
|
|
@@ -977,7 +977,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
977
977
|
.bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
|
|
978
978
|
|
|
979
979
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
980
|
-
@media ${
|
|
980
|
+
@media ${Dm} {
|
|
981
981
|
.bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
|
|
982
982
|
.bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
|
|
983
983
|
.bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
|
|
@@ -1015,7 +1015,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1015
1015
|
/* 中等宽度:左栏折到顶部一行 */
|
|
1016
1016
|
@media (max-width: 1100px) {
|
|
1017
1017
|
.bim-d-grid {
|
|
1018
|
-
grid-template-columns: minmax(0, 1fr) ${
|
|
1018
|
+
grid-template-columns: minmax(0, 1fr) ${Ns};
|
|
1019
1019
|
grid-template-rows: auto auto 1fr;
|
|
1020
1020
|
grid-template-areas: "rail rail" "main card" "main side";
|
|
1021
1021
|
}
|
|
@@ -1119,7 +1119,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1119
1119
|
: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 {
|
|
1120
1120
|
text-decoration-color: currentColor; text-decoration-thickness: 2px;
|
|
1121
1121
|
}
|
|
1122
|
-
`;function
|
|
1122
|
+
`;function Wn({railTop:e,back:n,up:o,nav:r,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=J(),u=(r||[]).filter(Boolean);return t.jsxs("div",{className:"bim-d-grid",children:[t.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[e,n&&t.jsx("div",{style:{marginTop:e?12:0},children:n}),o,u.length>1&&t.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[t.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),t.jsx("ul",{className:"bim-d-rail-nav",children:u.map(m=>t.jsx("li",{children:t.jsxs("a",{href:`#${m.id}`,children:[t.jsx("span",{children:p(m.label)}),m.count!=null&&t.jsx("span",{className:"bim-d-meta",children:m.count})]})},m.id))})]}),s&&s.length>0&&t.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[t.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),t.jsx("ul",{className:"bim-d-rail-nav",children:s.map(m=>t.jsx("li",{children:t.jsxs("a",{href:m.href??"#",onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),m.onClick())},children:[t.jsx("span",{children:p(m.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},m.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:a}),t.jsx("div",{className:"bim-d-g-card",children:l}),t.jsx("div",{className:"bim-d-g-side",children:d})]})}function Pl({caption:e,children:n}){const{convert:o}=J();return t.jsxs("div",{className:"bim-d-up bim-d-ui",children:[t.jsx("span",{className:"bim-d-up-cap",children:o(e)}),n]})}function tt({id:e,title:n,meta:o,action:r,children:s}){const{convert:a}=J();return t.jsxs("section",{id:e,className:"bim-d-sec",children:[t.jsxs("div",{className:"bim-d-sec-head bim-d-ui",children:[t.jsx("h2",{children:a(n)}),o!=null&&o!==""&&t.jsx("span",{className:"bim-d-meta",children:o}),r&&t.jsx("span",{className:"bim-d-sec-act",children:r})]}),t.jsx("div",{className:"bim-d-sec-body",children:s})]})}function et({items:e,className:n,style:o}){const r=e.filter(s=>s!=null&&s!==""&&s!==!1);return r.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:o,children:r.map((s,a)=>t.jsxs(g.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function $i({items:e,value:n,onChange:o}){const{convert:r}=J();return t.jsx(t.Fragment,{children:e.map(s=>t.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:e,checked:n,onChange:o}){const{convert:r}=J();return t.jsxs("label",{className:"bim-d-check",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:s=>o(s.target.checked)}),r(e)]})}const Bl=6,Ci=e=>e>Bl+1;function er({total:e,shown:n,unit:o,onClick:r}){const{t:s,convert:a}=J(),l=e-n,d=Ci(e)?e-Math.min(n,Bl):l;return d<=0?null:t.jsxs("button",{type:"button",className:`bim-d-more bim-d-ui${l>0?"":" bim-d-more-ncap"}`,onClick:r,children:[l>0&&t.jsx("span",{className:"bim-d-more-w",children:s("detail.expandRest",{n:l,unit:a(o)})}),t.jsx("span",{className:"bim-d-more-n",children:s("detail.expandRest",{n:d,unit:a(o)})})]})}function tr({label:e,onClick:n}){const{convert:o}=J();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(e)})}function On({kind:e,title:n,subtitle:o,byline:r,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:u,children:m,foot:h}){const{t:f,convert:x}=J(),k=(d||[]).filter(S=>S.value!=null&&S.value!==""),y=(c||[]).filter(S=>S.value!=null&&S.value!==""&&S.value!==0),[w,b]=g.useState(!1),j=!!l&&!w;return t.jsxs("div",{className:"bim-d-card",children:[e&&t.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:x(e)}),t.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),o&&t.jsx("div",{className:"bim-d-card-sub",children:o}),r&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:r}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),a&&t.jsx("div",{className:j?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:j?{"--detail-clamp":l}:void 0,children:a}),a&&!!l&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":w,onClick:()=>b(S=>!S),children:f(w?"action.collapse":"action.expand")}),y.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((S,v)=>t.jsxs("div",{children:[t.jsx("b",{children:S.value}),t.jsx("span",{children:x(S.label)})]},v))}),k.length>0&&t.jsx("dl",{className:"bim-d-ui",children:k.map((S,v)=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:x(S.label)}),t.jsx("dd",{title:S.title,children:S.value})]},v))}),m,p,u,h&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:h})]})}function nr(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function yo({href:e,onClick:n,label:o}){const{t:r,convert:s}=J(),a=o??r("detail.read");return e?t.jsx("a",{className:"bim-d-btn",href:e,onClick:n?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),n())}:void 0,children:s(a)}):t.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:s(a)})}function Yt({id:e,title:n,meta:o,items:r,metas:s,currentIndex:a,cap:l=8,moreLabel:d,foot:c,sub:p,timeline:u}){const{t:m,convert:h}=J(),[f,x]=g.useState(!1);if(!r.length)return null;const k=f?r:r.slice(0,l),y=r.length-k.length;return t.jsxs("div",{id:e,className:u?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[t.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[h(n),o!=null&&o!==""&&t.jsx("span",{className:"bim-d-meta",children:o})]}),p&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),t.jsx("ul",{children:k.map((w,b)=>t.jsxs("li",{className:b===a?"bim-d-side-cur":void 0,"aria-current":b===a?"page":void 0,children:[w,s!=null&&s[b]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&t.jsx(tr,{label:d?d(y):m("detail.showMore",{n:y}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const Vm=new Set(["reviewed","disputed","unreviewed","draft"]);function Hn({revision:e,revisedAt:n,review:o,todo:r}){const{t:s,convert:a}=J(),l=o&&Vm.has(o.status)?s(`detail.review.${o.status}`):void 0,d=o&&o.status!=="unreviewed"&&l?[l,o.by,o.date].filter(Boolean).join(" "):"",c=[e!=null&&e!==""?`${s("detail.dataVersion")} ${e}`:"",n??"",a(d)].filter(Boolean),p=(r||[]).filter(u=>u&&u.what);return!c.length&&!p.length?null:t.jsxs(t.Fragment,{children:[c.length>0&&t.jsx(et,{items:c,style:{fontSize:12}}),p.length>0&&t.jsxs("details",{children:[t.jsx("summary",{children:s("detail.todoCount",{n:p.length})}),t.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:p.map((u,m)=>t.jsxs("li",{children:[a(u.what),(u.by||u.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[u.by&&a(u.by),u.date].filter(Boolean).join(" · "),")"]})]},m))})]})]})}const oi=1e3,Rs=208,Gm=1440,Ym="(max-width: 719px)",Wl=`
|
|
1123
1123
|
.bim-d-page {
|
|
1124
1124
|
background: ${i("page-bg")};
|
|
1125
1125
|
color: ${i("ink")};
|
|
@@ -1139,7 +1139,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1139
1139
|
* PAGE_MAX_WIDTH,读者的行宽体验不变。
|
|
1140
1140
|
*/
|
|
1141
1141
|
.bim-d-main.bim-d-main-wide {
|
|
1142
|
-
max-width: ${
|
|
1142
|
+
max-width: ${Gm}px;
|
|
1143
1143
|
}
|
|
1144
1144
|
.bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
|
|
1145
1145
|
|
|
@@ -1171,9 +1171,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1171
1171
|
*/
|
|
1172
1172
|
.bim-d-reader {
|
|
1173
1173
|
display: grid;
|
|
1174
|
-
grid-template-columns: ${
|
|
1174
|
+
grid-template-columns: ${Rs}px minmax(0, ${oi}px);
|
|
1175
1175
|
gap: 32px;
|
|
1176
|
-
max-width: ${
|
|
1176
|
+
max-width: ${Rs+oi+32}px;
|
|
1177
1177
|
margin: 0 auto;
|
|
1178
1178
|
align-items: start;
|
|
1179
1179
|
}
|
|
@@ -1196,7 +1196,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1196
1196
|
align-items: start; margin-bottom: 48px; }
|
|
1197
1197
|
.bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
|
|
1198
1198
|
|
|
1199
|
-
@media ${
|
|
1199
|
+
@media ${Ym} {
|
|
1200
1200
|
.bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
|
|
1201
1201
|
.bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
|
|
1202
1202
|
/* 表格:meta 列折到第二行,表头隐藏 */
|
|
@@ -1214,16 +1214,16 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1214
1214
|
padding-right: 0; padding-bottom: 12px;
|
|
1215
1215
|
}
|
|
1216
1216
|
}
|
|
1217
|
-
${
|
|
1218
|
-
`)||(n.push({start:o,end:a+1,inner:l}),o=a)}return n}function
|
|
1219
|
-
`).map(n=>n.trim()).filter(n=>n&&!ar.test(n))}const
|
|
1220
|
-
`)){const s=r.trim();if(!s||ar.test(s)||sr(s))continue;const a=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=a,a>
|
|
1217
|
+
${Um}`;function Rn({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:Wl}),t.jsx("div",{className:r?"bim-d-main bim-d-main-grid":o?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function jo({breadcrumb:e,actions:n}){return t.jsxs("div",{className:"bim-d-ui bim-d-top",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:"8px 16px",marginBottom:24,fontSize:12,color:i("aux-fg")},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:e}),n&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function ir({char:e,tone:n="accent"}){return t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,flex:"none",fontSize:11,fontFamily:"var(--bim-font-ui, system-ui, sans-serif)",background:i(n==="accent"?"accent":"ink"),color:i("page-bg")},children:e})}function vo({items:e}){const n=Ze();return t.jsx(t.Fragment,{children:e.map((o,r)=>{const s=r===e.length-1,a=r>0&&t.jsx("span",{style:{color:i("hint-fg")},children:"/"},`s${r}`),l=o.id?n(o.id):o.href,d=s||!o.onClick&&!l?t.jsx("span",{style:{color:i("ink")},children:o.label},r):t.jsx("a",{href:l??"#",onClick:o.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),o.onClick())}:void 0,style:{color:i("meta-fg")},children:o.label},r);return t.jsxs(g.Fragment,{children:[a,d]},r)})})}function Ol({title:e,subtitle:n,aside:o,secondLine:r}){return t.jsxs("header",{style:{borderBottom:`2px solid ${i("rule-strong")}`,paddingBottom:18},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[t.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:e}),n&&t.jsx("span",{style:{fontSize:15,color:i("meta-fg"),letterSpacing:".06em"},children:n})]}),o&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".06em"},children:o})]}),r&&t.jsx("div",{style:{marginTop:12,fontSize:13.5,color:i("quiet-fg")},children:r})]})}function Km({children:e,facts:n}){return!e&&n?t.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${i("rule")}`,marginBottom:40},children:n}):t.jsxs("div",{className:"bim-d-intro",children:[t.jsx("div",{style:{minWidth:0},children:e}),n]})}function qm({items:e,horizontal:n}){const{convert:o}=Le();return e.length?t.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:e.map((r,s)=>t.jsxs("div",{title:r.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[t.jsx("span",{className:"bim-d-ui",style:{color:i("label-fg"),letterSpacing:".08em",flex:"none"},children:o(r.label)}),t.jsx("span",{style:{color:i("body-fg"),textAlign:n?"left":"right",minWidth:0},children:r.value})]},s))}):null}function Xm({glyph:e,tone:n,title:o,count:r,actions:s,id:a}){const{convert:l}=Le();return t.jsxs("div",{id:a,style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",justifyContent:"space-between",gap:"10px 16px",marginBottom:14,scrollMarginTop:16},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx(ir,{char:e,tone:n}),t.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:l(o)}),r!=null&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg")},children:r})]}),s&&t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function Hl({label:e,active:n,onClick:o,dashed:r}){const{convert:s}=Le();return t.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(e)})}function Zm({label:e,onClick:n}){const{convert:o}=Le();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg"),borderBottom:`1px solid ${i("rule")}`},children:o(e)})}function Jm({label:e,onClick:n,inline:o}){const{convert:r}=Le();return t.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(e)})}function Fl({children:e,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?t.jsx("a",{href:n??"#",title:r,onClick:o?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o())}:void 0,style:s,children:e}):t.jsx("span",{title:r,style:s,children:e})}function Qm({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function eh({volumes:e,unit:n,max:o=60}){const{t:r}=J(),s=n??r("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,o);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[d.map(c=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${i("rule")}`,color:i("meta-fg")},children:c},c)),!a&&e.length>o&&t.jsxs("button",{type:"button",onClick:()=>l(!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:["+",e.length-o]}),t.jsx("span",{style:{padding:"2px 6px",color:i("hint-fg")},children:s})]})}function th({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:e})}function nh({spec:e}){const{convert:n}=Le();return t.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${e.leadWidth}px 1fr ${e.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${i("rule-strong")}`,fontSize:11,color:i("label-fg"),letterSpacing:".1em"},children:[t.jsx("span",{}),t.jsx("span",{children:n(e.mainLabel)}),t.jsx("span",{style:{display:"grid",gridTemplateColumns:e.columns.map(o=>o.width).join(" "),gap:12},children:e.columns.map(o=>t.jsx("span",{children:n(o.label)},o.label))})]})}function ih({no:e,main:n,meta:o,spec:r}){return t.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${r.leadWidth}px 1fr ${r.metaWidth}px`,gap:12},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("hint-fg"),textAlign:"right"},children:e}),t.jsx("span",{style:{minWidth:0},children:n}),t.jsx("span",{className:"bim-d-row-meta",style:{display:"grid",gridTemplateColumns:r.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:o})]})}function oh(e){return String(e+1).padStart(2,"0")}function rh(){return t.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function sh({open:e,onToggle:n,main:o,action:r,children:s}){return t.jsxs("div",{style:{borderBottom:`1px solid ${i("rule")}`},children:[t.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[t.jsx("button",{type:"button",onClick:n,"aria-expanded":e,className:"bim-d-ui",style:{width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",fontSize:12,lineHeight:1,border:`1px solid ${i(e?"accent":"rule-dashed")}`,background:e?i("accent"):"transparent",color:i(e?"page-bg":"accent")},children:e?"-":"+"}),t.jsx("span",{style:{fontSize:14,minWidth:0},children:o}),r]}),e&&s&&t.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${i("rule-accent-soft")}`,marginLeft:12},children:s})]})}function Dl(e){const n=[];for(let o=0;o<e.length;o++){const r=e[o];let s;if(r==="⟨")s="⟩";else if(r==="<"){const d=e[o+1];if(d===void 0||/[A-Za-z/!?>\s]/.test(d))continue;s=">"}else continue;const a=e.indexOf(s,o+1);if(a<0)continue;const l=e.slice(o+1,a);l.includes(`
|
|
1218
|
+
`)||(n.push({start:o,end:a+1,inner:l}),o=a)}return n}function Ul(e,n){if(e.length<=n)return e;let o=n;for(const r of Dl(e)){if(r.start>=o)break;if(r.end>o){o=r.start>0?r.start:r.end;break}}return e.slice(0,o)}const Vl={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},ah={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 Gl(e,n,o,r){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:o===0?Vl:void 0,children:Gl(s.children,n,o+1,r)},a);case"qw":return t.jsx("span",{className:"bim-qw guji-qw",title:s.label?r("detail.lacunaWith",{label:s.label}):r("detail.lacuna"),children:"□"},a);case"qz":return t.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":s.guess,children:"□"},a);case"zi":return t.jsx("span",{className:"bim-zi guji-zi",title:r("detail.composedChar",{label:s.label}),style:ah,children:s.label},a)}})}function mt(e,n=r=>r,o){if(!e)return"";if(o!=null&&o.gujiMarkdown)return rm(e)?Gl(al(e),n,0,o.t??mn("zh-Hant")):n(e);if(e.indexOf("⟨")<0&&e.indexOf("<")<0)return n(e);const r=[];let s=0,a=0;for(const l of Dl(e))l.start>s&&r.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),r.push(t.jsx("span",{className:"bim-jiazhu",style:Vl,children:n(l.inner)},a++)),s=l.end;return s<e.length&&r.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),r}function lh({label:e,children:n}){return t.jsxs("div",{style:{marginBottom:10},children:[e&&t.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:i("label-fg"),marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:i("quiet-fg"),textAlign:"justify"},children:n})]})}function ch({title:e,tag:n,children:o}){const{convert:r}=Le();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${i("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:r(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("accent"),letterSpacing:".06em"},children:r(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:o})]})}function Yl({name:e,note:n,href:o,extra:r}){const s=t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:14,minWidth:0},children:e}),t.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:i("hint-fg"),flex:"none"},children:o?"↗":""}),n&&t.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:i("label-fg")},children:n})]}),a={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${i("rule")}`,color:i("body-fg"),alignItems:"baseline"};return t.jsxs(t.Fragment,{children:[o?t.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:a,children:s}):t.jsx("div",{style:a,children:s}),r]})}function dh({item:e,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{t:s,convert:a}=J(),[l,d]=g.useState(!1),c=fi(e),p=o&&!!c&&c.expected>0,u=(e.url?hn(e.url):void 0)||a(e.name),m=n?zl(e,n):"",h=m?`${u}(${m})`:u;return t.jsx(Yl,{name:h,note:Si(e,s)||r,href:gn(e),extra:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(f=>!f),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:i("meta-fg"),borderBottom:`1px solid ${i("rule")}`},children:l?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),l&&t.jsx(or,{item:e})]}):void 0})}function or({item:e}){return t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(e.volumes||[]).map((n,o)=>{const r=n.status==="missing";return n.url&&!r?t.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):t.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:e,items:n}){const{convert:o}=Le();return n.length?t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".08em"},children:e}),n.map((r,s)=>t.jsx(Fl,{children:o(r)},s))]}):null}function ph({rows:e}){const n=e.filter(o=>o.items.length>0);return n.length?t.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(o=>t.jsx(Kl,{label:o.label,items:o.items},o.label))}):null}function ko(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function ql({left:e,right:n}){return t.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:[t.jsx("span",{children:e}),n&&t.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function uh({children:e,action:n}){return t.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:[t.jsx("span",{children:e}),n]})}function Xe({id:e,label:n,onNavigate:o,renderLink:r,style:s,dense:a}){const l=Ze();return r?t.jsx(t.Fragment,{children:r(e,typeof n=="string"?n:void 0,{dense:a})}):t.jsx("a",{href:l(e),onClick:o?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),o(e))}:void 0,style:s,children:n??e})}function mh({href:e,children:n}){return t.jsxs("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:[n," ",t.jsx("span",{className:"bim-d-ui",style:{fontSize:11},children:"↗"})]})}const hh={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},gh={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},fh=`1px solid ${i("table-border")}`,Xl={border:fh,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},xh={...Xl,background:i("table-head-bg"),fontWeight:600};function rr({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:hh,children:t.jsx("table",{className:"bim-guji-table",style:gh,children:t.jsx("tbody",{children:e.rows.map((o,r)=>t.jsx("tr",{children:o.cells.map((s,a)=>{const l=o.header?"th":"td";return t.jsx(l,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:o.header?xh:Xl,children:s.empty?null:mt(s.text,void 0,n)},a)})},r))})})})}function bh(e,n){return e.indexOf("**")<0?mt(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?t.jsx("strong",{children:mt(r.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:mt(r,void 0,n)},s))}function yh(e,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?Go(e).map((s,a)=>s.type==="table"?t.jsx(rr,{table:s.table,opts:r},a):t.jsx(g.Fragment,{children:bh(s.text,r)},a)):mt(e,void 0,r)}const jh=/^(#{1,6})\s+(.*)$/,vh=/^\*\*([^*\n]+)\*\*\s*$/;function sr(e){const n=e.match(jh);if(n)return{level:n[1].length,text:n[2].trim()};const o=e.trim().match(vh);return o?{level:3,text:o[1].trim()}:null}const ar=/^<!--.*-->$/;function Zl(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Jl(e){return e.split(`
|
|
1219
|
+
`).map(n=>n.trim()).filter(n=>n&&!ar.test(n))}const kh=60;function Ql(e){let n=0,o=0;for(const r of e.split(`
|
|
1220
|
+
`)){const s=r.trim();if(!s||ar.test(s)||sr(s))continue;const a=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=a,a>kh&&(o+=a)}return n>0&&o*2>=n}function wh(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function zi(e){if(e=wh(e),Ql(e))return"unknown";const n=Zl(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const o=n.map(s=>Jl(s).length).filter(s=>s>0);if(o.length===0)return"unknown";const r=o.reduce((s,a)=>s+a,0)/o.length;return r<=4?"record":r>=8?"catalog":"unknown"}function Sh(e){const n=e.split(`
|
|
1221
1221
|
`),o=[];let r=null,s=[];const a=()=>{o.push({heading:r,body:s.join(`
|
|
1222
|
-
`)}),s=[]};for(const l of n){const d=sr(l);if(d){a(),r={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),o}function
|
|
1223
|
-
`)){const r=sr(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||ar.test(s)||n.push({kind:"body",text:o})}return n}function
|
|
1224
|
-
`)?"":n)}function
|
|
1225
|
-
`);let c=0;return t.jsx(t.Fragment,{children:d.map((p,u)=>{const m=p.match(Ji);if(m){const f=c++;if(a(m[1].length,m[2],f))return null;const{Tag:x,className:k}=l(m[1].length);return t.jsx(x,{className:k,children:o(m[2])},u)}if(!p.trim())return u>=2&&!!d[u-1].trim()&&!!d[u-2].trim()&&!Ji.test(d[u-1])&&!Ji.test(d[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(wh.test(p))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(p.trim())){const{Tag:f,className:x}=l(3);return t.jsx(f,{className:x,children:o(p.trim().slice(2,-2))},u)}return t.jsx("p",{className:Is(p),children:Es(p,o,u)},u)})})}function Ch(e){const{convert:n}=Ae();return g.useMemo(()=>e?n(e):"",[e,n])}function cr({text:e,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:a,dropTitle:l}){const d=Ch(e),{t:c,convert:p}=J(),u=f=>lr(f,{renderText:a,properNames:s,gujiMarkdown:r,t:c}),m=r?{gujiMarkdown:!0,t:c}:void 0,h=l?p(l):void 0;return!o||d.indexOf(":::")<0?t.jsx(Ls,{text:d,mode:n,inline:u,dropTitle:h}):t.jsx(t.Fragment,{children:Go(d).map((f,x)=>f.type==="table"?t.jsx(rr,{table:f.table,opts:m},x):t.jsx(Ls,{text:f.text,mode:n,inline:u,dropTitle:x===0?h:void 0},x))})}function zh(e,n,o){const[r,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,o)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(u=>{c===d.current&&s(u??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,o]),{images:r,loading:a}}const As={A:"fine",B:"rough",C:"rough",D:"ocr"};function Th(e){return typeof e!="string"?null:e in dp?e:e in As?As[e]:null}const Nh={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},Rh={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},ic="\0";function Eh(e,n,o){const[r,s=""]=e.split(ic);return t.jsxs(t.Fragment,{children:[r,t.jsx(ml,{text:n,convert:o}),s]})}function xt(e){return typeof e!="string"?"":Nh[e]??Rh[e]??e}const Ih=["〇","一","二","三","四","五","六","七","八","九"],Ps=["","十","百","千"],Lh=["","萬","億"];function dr(e){if(e===0)return"〇";if(e<0)return`負${dr(-e)}`;const n=[];let o=e,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(Ah(s,r>0)+Lh[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Ah(e,n){const o=[];let r=e;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let a=0;a<o.length;a++){const l=o[a],d=o.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=Ps[d]:s+=Ih[l]+Ps[d]}return s.replace(/〇$/,"")}let Ln=null,Qn=null;const ui=new Set;function Ph(){return Ln?Promise.resolve():Qn||(Qn=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Ln=o=>n(_e.normalizeVariants(o)),ui.forEach(o=>o())}).catch(()=>{Ln=e=>e,ui.forEach(e=>e())}),Qn)}const Mh=e=>e;function Jt(){const[,e]=g.useState(0);return g.useEffect(()=>{if(Ln)return;const n=()=>e(o=>o+1);return ui.add(n),Ph(),()=>{ui.delete(n)}},[]),Ln??Mh}function pn(e,n){return n(e).toLowerCase()}const Bh=i("highlight-bg");function Hn(e,n,o){if(!n)return e;const r=pn(n,o);if(!r)return e;const s=pn(e,o);if(s.length!==e.length)return e;const a=[];let l=0,d=0;for(;l<e.length;){const c=s.indexOf(r,l);if(c===-1){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{style:{background:Bh,padding:0,color:"inherit"},children:e.slice(c,c+r.length)},d++)),l=c+r.length}return t.jsx(t.Fragment,{children:a})}function pr(e,n,o,r){if(!n)return!0;const s=pn(n,r);return(o?[e.title,e.header_line,e.content,e.comment]:[e.title,e.book_title,e.author,e.author_info,e.summary,e.content,e.comment,e.additional_comment]).some(l=>typeof l=="string"&&pn(l,r).includes(s))}function Wh(e,n,o){return n?pn(e,o).includes(pn(n,o)):!0}const ur={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},Oh={考证:i("section-kaozhen")};function mr(e,n,o){return e.collated.sectionType[n]??o(n)}function oc(e){var r;const n=e.files.length,o=((r=e.children)==null?void 0:r.reduce((s,a)=>s+oc(a),0))||0;return n+o}function Hh(e,n){const o=[],r=l=>{var d;o.push(...l.files),(d=l.children)==null||d.forEach(r)};if(r(e),o.length===0)return;const s=o.map(l=>n[l]);if(s.every(l=>l===void 0))return;if(s.some(l=>l==="loading"))return"loading";let a=0;for(const l of s)typeof l=="number"&&(a+=l);return a}const Fh={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function hr({enabled:e,expanded:n,onClick:o,style:r,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...Fh,...r},children:s}):t.jsx("span",{style:r,children:s})}function Dh({type:e}){const{convert:n,messages:o}=J(),r=xt(e),s=ur[r]||i("desc-fg");return t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:s,border:`1px solid ${s}40`,borderRadius:"2px",background:`${s}08`,flexShrink:0},children:mr(o,r,n)})}function Uh({section:e,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=J(),c=Ze(),p=Jt(),u=j=>j?ht(d(j),S=>o?Hn(S,o,p):S,{t:l}):"",[m,h]=g.useState(!1),f=!!e.summary,x=!!e.comment,k=!!e.additional_comment,y=!!(e.content&&e.content.length>60),w=f||x||k||y;g.useEffect(()=>{o&&h(!0)},[o]);const b=!m&&y?Dl(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>w&&h(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:w?"pointer":"default",userSelect:"none"},children:[r!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),t.jsxs(hr,{enabled:w,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[w&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",u(e.book_title),"》"]}):u(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(dr(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:u(e.author_info||e.author)})]}),!m&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:u(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),"aria-label":l("collated.viewWorkOf",{title:d(e.book_title||e.title)}),children:l("collated.workArrow")}),s&&!e.work_id&&t.jsx("span",{style:{fontSize:"11px",color:i("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),m&&w&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:u(e.author_info)}),e.summary&&t.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:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:u(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(e.additional_comment)})]}),y&&!f&&!x&&!k&&t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(e.content)})]})]})}function Vh({section:e,highlightQuery:n=""}){const{t:o,convert:r}=J(),s=Jt(),a=p=>p?ht(r(p),u=>n?Hn(u,n,s):u,{t:o}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(hr,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Dh,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),l&&c&&t.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${ur[xt(e.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const Gh=100;function gr(e){return xt(e.type)!=="page_header"?!1:(e.content||"").length>=Gh}function Yh({section:e,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=J(),a=Jt();if(xt(e.type)==="page_header"&&!gr(e)||!e.content&&!e.title)return null;const l=r((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1226
|
-
`)),d=ht(l,m=>n?Hn(m,n,a):m,{t:o}),c=xt(e.type),p=ur[c]||i("desc-fg"),u=c==="序"||c==="结语"||c==="注释";return t.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&&t.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:p,marginRight:"8px",padding:"1px 5px",border:`1px solid ${p}40`,borderRadius:"2px",background:`${p}08`,verticalAlign:"middle"},children:mr(s,c,r)}),d]})}function Kh(e,n,o){const[r,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(u=>{var m;return!((m=o==null?void 0:o.current)!=null&&m.has(u))}),d={};for(const u of e)(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),l.length===0)return;const c=async u=>{var m;try{if(n.getEntry){const y=await n.getEntry(u);if(y)return{title:y.title,author:y.author}}const h=await n.getItem(u);if(!h)return null;const f=h.title||u,x=h.authors,k=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:f,author:k}}catch{return null}};return Promise.all(l.map(async u=>{var h;const m=await c(u);return(h=o==null?void 0:o.current)==null||h.set(u,m),[u,m]})).then(u=>{a||s(m=>{const h={...m};for(const[f,x]of u)h[f]=x;return h})}),()=>{a=!0}},[e.join(","),n]),r}function qh({section:e,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=J(),c=Ze(),p=Jt(),u=S=>S?ht(l(S),v=>s?Hn(v,s,p):v,{t:a}):"",[m,h]=g.useState(!1);g.useEffect(()=>{s&&h(!0)},[s]);const f=xt(e.type),x=Oh[f]||i("desc-fg"),k=!!e.content,y=e.work_ids||[],w=y.length>1,b=Kh(w?y:[],o,r),j=k&&!m&&e.content.length>80?Dl(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>k&&h(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[t.jsxs(hr,{enabled:k,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[k&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg"),lineHeight:1.6},children:e.header_line?u(e.header_line):u(e.title)}),!m&&j&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:u(j)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&t.jsx("a",{href:c(y[0]),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),w&&t.jsx("span",{style:{fontSize:"11px",color:i("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:y.length})}),t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:x,border:`1px solid ${x}40`,borderRadius:"2px",background:`${x}08`},children:mr(d,f,l)})]})]}),w&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(S=>{const v=b[S],$=v?`${l(v.title)}${v.author?`(${l(v.author)})`:""}`:S.slice(0,8)+"…";return t.jsxs("a",{href:c(S),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),_.stopPropagation(),n(S))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:S,children:["→",$]},S)})}),m&&k&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(e.content)}),e.comment&&t.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(e.comment)})]})]})}function Xh({juan:e,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:a}=J(),l=Jt(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>pr(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,u)=>t.jsx(qh,{section:p,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:d},u))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Zh(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Jh({sections:e,onNavigate:n,inline:o,workLinks:r=!0}){const s=Ze(),{t:a,convert:l}=J(),d=Zh();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const u=xt(c.type);if(u==="page_header"&&!gr(c))return null;if(u==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,o(l(c.title))),c.content&&t.jsx("p",{children:o(l(c.content))})]},p);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:dr(c.n_juan)}):""}`:c.title,h=o(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:h}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):h),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:o(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:o(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),o(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),o(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),o(l(c.additional_comment))]})]},p)}return c.content?t.jsx("p",{children:o(l(c.content))},p):null})})}function rc(e){return e.some(n=>{const o=xt(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&gr(n)})}function Qh({juan:e,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:u,onViewChange:m}){var O;const{t:h,convert:f,messages:x}=J(),k=Jt(),[y,w]=g.useState("text"),b=u??y,j=A=>{w(A),m==null||m(A)},S=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",$=g.useCallback(A=>S?Hn(A,S,k):A,[S,k]),_=A=>lr(A,{renderText:$,properNames:p.properNames,t:h}),C=g.useMemo(()=>S?e.sections.filter(A=>pr(A,S,v,k)):e.sections,[e.sections,S,v,k]),M=(A,G)=>G.filter(se=>xt(se.type)===A).length,N=M("书",e.sections),T=M("诗",e.sections),F=M("考证",e.sections);let R="";v?R=S?h("collated.countTiaoOf",{m:M("考证",C),n:F}):h("collated.countTiao",{n:F}):T>0?R=S?h("collated.countPoemsOf",{m:M("诗",C),n:T}):h("collated.countPoems",{n:T}):N>0&&(R=S?h("collated.countBooksOf",{m:M("书",C),n:N}):h("collated.countBooks",{n:N}));const E=s!=null&&s.text_quality?Th(s.text_quality.grade):null,L=[];R&&L.push(R),v&&(s!=null&&s.target_source)&&L.push(t.jsx(t.Fragment,{children:h("collated.kaozhenTarget",{target:f(s.target_source)})})),E&&L.push(t.jsx("span",{title:x.collated.qualityCriteria[E],children:(O=s==null?void 0:s.text_quality)!=null&&O.source_note?t.jsxs(t.Fragment,{children:[Eh(h("collated.baseText",{note:ic}),s.text_quality.source_note,f),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[E]})]}):t.jsxs(t.Fragment,{children:[h("collated.textQuality"),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[E]})]})})),e.source_url&&L.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:h("collated.originalSource")}));const I=!v&&rc(e.sections),P=!!n&&(!I||p.readingMode==="paragraph"&&pi(n)),V=!v&&(I||!!n),X=v||!V?"entries":b;let D=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(o||r)&&t.jsxs("p",{className:"bim-rd-kicker",children:[o,o&&r&&t.jsx("span",{className:"bim-rd-dot"}),r&&f(r)]}),t.jsx("h1",{className:"bim-rd-h1",children:f(e.title)}),L.length>0&&t.jsx("p",{className:"bim-rd-meta",children:L.map((A,G)=>t.jsxs(g.Fragment,{children:[G>0&&t.jsx("span",{className:"bim-rd-dot"}),A]},G))}),V&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":h("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":X==="text",onClick:()=>j("text"),children:h("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":X==="entries",onClick:()=>j("entries"),children:h("collated.viewEntries")})]})]}),X==="text"&&t.jsx("article",{className:"bim-rd-prose",children:P?t.jsx(cr,{text:n,mode:p.readingMode,properNames:p.properNames,renderText:$,dropTitle:e.title}):t.jsx(Jh,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),X==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?t.jsx(Xh,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[C.some(A=>["书","诗","考证"].includes(xt(A.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:h("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:h("collated.rowHeadTitle")}),t.jsx("span",{children:h("collated.rowHeadWork")})]}),C.map((A,G)=>{const se=xt(A.type);return se==="书"||se==="诗"||se==="考证"?(D+=1,t.jsx(Uh,{domId:`rd-e-${e.sections.indexOf(A)}`,section:A,onNavigate:p.workLinks?l:void 0,highlightQuery:S,no:D,showUnlinked:p.workLinks&&!!l},G)):se==="类"?t.jsx(Vh,{section:A,highlightQuery:S},G):t.jsx(Yh,{section:A,highlightQuery:S},G)}),C.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:h("collated.noMatch")})]})})]})}function eg(e){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=Jt(),u=g.useRef(new Map),[m,h]=g.useState({}),[f,x]=g.useState({}),k=g.useCallback((w,b)=>{const j=b==null?void 0:b.title;j&&x(S=>S[w]===j?S:{...S,[w]:j})},[]);g.useEffect(()=>{s&&a&&(u.current.set(s,{juan:a,rawText:l}),k(s,a))},[s,a,l,k]),g.useEffect(()=>{u.current.clear(),h({}),x({})},[n]);const y=g.useCallback((w,b)=>{let j=0;if(w.juan)for(const S of w.juan.sections)pr(S,b,c,p)&&j++;return j===0&&w.rawText&&Wh(w.rawText,b,p)&&(j=1),j},[c,p]);return g.useEffect(()=>{const w=d.trim();if(!w){h({});return}if(!o||r.length===0)return;let b=!1;const j={},S=[];for(const M of r){const N=u.current.get(M);N?j[M]=y(N,w):(j[M]="loading",S.push(M))}h(j);const v=8;let $=0;const _=async()=>{for(;$<S.length;){if(b)return;const M=$++,N=S[M];try{const T=await o(N),F=T.juan;if(u.current.set(N,T),k(N,F),b)return;h(R=>({...R,[N]:y(T,w)}))}catch{if(b)return;h(T=>({...T,[N]:0}))}}},C=Array.from({length:Math.min(v,S.length)},()=>_());return Promise.all(C),()=>{b=!0}},[d,n,o,r.join(","),y,p,k]),{matchStates:m,titles:f}}function tg({juan:e,view:n,onView:o,textHasEntries:r}){const{t:s,convert:a}=J(),l=e.sections.map((u,m)=>({s:u,i:m,t:xt(u.type)})).filter(u=>u.t==="书"||u.t==="诗");if(l.length===0)return null;const d=l.filter(u=>!!u.s.work_id).length,c=l.every(u=>u.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=u=>{const m=()=>{var h,f;return(f=(h=document.getElementById(`rd-e-${u}`))==null?void 0:h.scrollIntoView)==null?void 0:f.call(h,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?setTimeout(m,0):m()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:u,i:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:h=>{h.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${u.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:a(u.book_title||u.title)})]})},m))})]})]})}const ng=`
|
|
1222
|
+
`)}),s=[]};for(const l of n){const d=sr(l);if(d){a(),r={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),o}function Es(e){const n=[];for(const o of e.split(`
|
|
1223
|
+
`)){const r=sr(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||ar.test(s)||n.push({kind:"body",text:o})}return n}function ec(e){if(!e)return[];const n=zi(e);if(n==="unknown")return Es(e);const o=[];for(const{heading:r,body:s}of Sh(e)){r&&o.push(r);const a=Zl(s);if(a.length!==0){if(Ql(s)){o.push(...Es(s));continue}if(n==="record"){const l=a.join(" ");l&&o.push({kind:"body",text:l})}else for(const l of a){const d=Jl(l);d.length&&o.push({kind:"body",text:d.join(" ")})}}}return o}const tc=e=>e;function nc(e,n=tc){if(e.indexOf("《")<0)return n(e);const o=[],r=/《([^《》\n]+)》/g;let s=0,a=0,l;for(;l=r.exec(e);)l.index>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.index))},a++)),o.push(t.jsxs("span",{className:"bim-rd-pn",children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(l[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]},a++)),s=l.index+l[0].length;return s===0?n(e):(s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o)}function lr(e,n={}){const o=n.renderText??tc,r=n.properNames?a=>nc(a,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return mt(e,r,s)}function Is(e,n,o){return e.indexOf("**")<0?n(e):e.split(/(\*\*[^*]+\*\*)/g).map((s,a)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{children:n(s.slice(2,-2))},`${o}-${a}`):t.jsx(g.Fragment,{children:n(s)},`${o}-${a}`))}const Ji=/^(#{1,6})\s+(.*)$/,_h=/^\s*<!--.*-->\s*$/;function ic(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
1224
|
+
`)?"":n)}function $h(e){return e<=1?2:e===2?3:4}function Ch(){let e=1;return n=>{const o=$h(n),r=Math.min(o,e+1);return e=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function pi(e){return e?zi(ic(e))!=="unknown":!1}function zh(e){return/^\u3000{2}/.test(e)}const Ls=e=>zh(e)?"bim-rd-noindent":void 0;function As({text:e,mode:n,inline:o,dropTitle:r}){const s=ic(e),a=(p,u,m)=>!!r&&m<=1&&p<=2&&u.trim()===r.trim(),l=Ch();if(n==="paragraph"&&zi(s)!=="unknown"){const p=ec(s);return t.jsx(t.Fragment,{children:p.map((u,m)=>{if(u.kind==="heading"){if(a(u.level??1,u.text,m))return null;const{Tag:h,className:f}=l(u.level??1);return t.jsx(h,{className:f,children:o(u.text)},m)}return t.jsx("p",{className:Ls(u.text),children:Is(u.text,o,m)},m)})})}const d=s.split(`
|
|
1225
|
+
`);let c=0;return t.jsx(t.Fragment,{children:d.map((p,u)=>{const m=p.match(Ji);if(m){const f=c++;if(a(m[1].length,m[2],f))return null;const{Tag:x,className:k}=l(m[1].length);return t.jsx(x,{className:k,children:o(m[2])},u)}if(!p.trim())return u>=2&&!!d[u-1].trim()&&!!d[u-2].trim()&&!Ji.test(d[u-1])&&!Ji.test(d[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(_h.test(p))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(p.trim())){const{Tag:f,className:x}=l(3);return t.jsx(f,{className:x,children:o(p.trim().slice(2,-2))},u)}return t.jsx("p",{className:Ls(p),children:Is(p,o,u)},u)})})}function Th(e){const{convert:n}=Le();return g.useMemo(()=>e?n(e):"",[e,n])}function cr({text:e,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:a,dropTitle:l}){const d=Th(e),{t:c,convert:p}=J(),u=f=>lr(f,{renderText:a,properNames:s,gujiMarkdown:r,t:c}),m=r?{gujiMarkdown:!0,t:c}:void 0,h=l?p(l):void 0;return!o||d.indexOf(":::")<0?t.jsx(As,{text:d,mode:n,inline:u,dropTitle:h}):t.jsx(t.Fragment,{children:Go(d).map((f,x)=>f.type==="table"?t.jsx(rr,{table:f.table,opts:m},x):t.jsx(As,{text:f.text,mode:n,inline:u,dropTitle:x===0?h:void 0},x))})}function Nh(e,n,o){const[r,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,o)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(u=>{c===d.current&&s(u??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,o]),{images:r,loading:a}}const Ps={A:"fine",B:"rough",C:"rough",D:"ocr"};function Rh(e){return typeof e!="string"?null:e in up?e:e in Ps?Ps[e]:null}const Eh={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},Ih={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},oc="\0";function Lh(e,n,o){const[r,s=""]=e.split(oc);return t.jsxs(t.Fragment,{children:[r,t.jsx(hl,{text:n,convert:o}),s]})}function xt(e){return typeof e!="string"?"":Eh[e]??Ih[e]??e}const Ah=["〇","一","二","三","四","五","六","七","八","九"],Ms=["","十","百","千"],Ph=["","萬","億"];function dr(e){if(e===0)return"〇";if(e<0)return`負${dr(-e)}`;const n=[];let o=e,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(Mh(s,r>0)+Ph[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Mh(e,n){const o=[];let r=e;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let a=0;a<o.length;a++){const l=o[a],d=o.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=Ms[d]:s+=Ah[l]+Ms[d]}return s.replace(/〇$/,"")}let An=null,Qn=null;const ui=new Set;function Bh(){return An?Promise.resolve():Qn||(Qn=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});An=o=>n(_e.normalizeVariants(o)),ui.forEach(o=>o())}).catch(()=>{An=e=>e,ui.forEach(e=>e())}),Qn)}const Wh=e=>e;function Jt(){const[,e]=g.useState(0);return g.useEffect(()=>{if(An)return;const n=()=>e(o=>o+1);return ui.add(n),Bh(),()=>{ui.delete(n)}},[]),An??Wh}function pn(e,n){return n(e).toLowerCase()}const Oh=i("highlight-bg");function Fn(e,n,o){if(!n)return e;const r=pn(n,o);if(!r)return e;const s=pn(e,o);if(s.length!==e.length)return e;const a=[];let l=0,d=0;for(;l<e.length;){const c=s.indexOf(r,l);if(c===-1){a.push(e.slice(l));break}c>l&&a.push(e.slice(l,c)),a.push(t.jsx("mark",{style:{background:Oh,padding:0,color:"inherit"},children:e.slice(c,c+r.length)},d++)),l=c+r.length}return t.jsx(t.Fragment,{children:a})}function pr(e,n,o,r){if(!n)return!0;const s=pn(n,r);return(o?[e.title,e.header_line,e.content,e.comment]:[e.title,e.book_title,e.author,e.author_info,e.summary,e.content,e.comment,e.additional_comment]).some(l=>typeof l=="string"&&pn(l,r).includes(s))}function Hh(e,n,o){return n?pn(e,o).includes(pn(n,o)):!0}const ur={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},Fh={考证:i("section-kaozhen")};function mr(e,n,o){return e.collated.sectionType[n]??o(n)}function rc(e){var r;const n=e.files.length,o=((r=e.children)==null?void 0:r.reduce((s,a)=>s+rc(a),0))||0;return n+o}function Dh(e,n){const o=[],r=l=>{var d;o.push(...l.files),(d=l.children)==null||d.forEach(r)};if(r(e),o.length===0)return;const s=o.map(l=>n[l]);if(s.every(l=>l===void 0))return;if(s.some(l=>l==="loading"))return"loading";let a=0;for(const l of s)typeof l=="number"&&(a+=l);return a}const Uh={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function hr({enabled:e,expanded:n,onClick:o,style:r,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...Uh,...r},children:s}):t.jsx("span",{style:r,children:s})}function Vh({type:e}){const{convert:n,messages:o}=J(),r=xt(e),s=ur[r]||i("desc-fg");return t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:s,border:`1px solid ${s}40`,borderRadius:"2px",background:`${s}08`,flexShrink:0},children:mr(o,r,n)})}function Gh({section:e,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=J(),c=Ze(),p=Jt(),u=j=>j?mt(d(j),S=>o?Fn(S,o,p):S,{t:l}):"",[m,h]=g.useState(!1),f=!!e.summary,x=!!e.comment,k=!!e.additional_comment,y=!!(e.content&&e.content.length>60),w=f||x||k||y;g.useEffect(()=>{o&&h(!0)},[o]);const b=!m&&y?Ul(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>w&&h(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:w?"pointer":"default",userSelect:"none"},children:[r!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),t.jsxs(hr,{enabled:w,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[w&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",u(e.book_title),"》"]}):u(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(dr(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:u(e.author_info||e.author)})]}),!m&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:u(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),"aria-label":l("collated.viewWorkOf",{title:d(e.book_title||e.title)}),children:l("collated.workArrow")}),s&&!e.work_id&&t.jsx("span",{style:{fontSize:"11px",color:i("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),m&&w&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:u(e.author_info)}),e.summary&&t.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:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:u(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(e.additional_comment)})]}),y&&!f&&!x&&!k&&t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(e.content)})]})]})}function Yh({section:e,highlightQuery:n=""}){const{t:o,convert:r}=J(),s=Jt(),a=p=>p?mt(r(p),u=>n?Fn(u,n,s):u,{t:o}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(hr,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Vh,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),l&&c&&t.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${ur[xt(e.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const Kh=100;function gr(e){return xt(e.type)!=="page_header"?!1:(e.content||"").length>=Kh}function qh({section:e,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=J(),a=Jt();if(xt(e.type)==="page_header"&&!gr(e)||!e.content&&!e.title)return null;const l=r((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1226
|
+
`)),d=mt(l,m=>n?Fn(m,n,a):m,{t:o}),c=xt(e.type),p=ur[c]||i("desc-fg"),u=c==="序"||c==="结语"||c==="注释";return t.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&&t.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:p,marginRight:"8px",padding:"1px 5px",border:`1px solid ${p}40`,borderRadius:"2px",background:`${p}08`,verticalAlign:"middle"},children:mr(s,c,r)}),d]})}function Xh(e,n,o){const[r,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(u=>{var m;return!((m=o==null?void 0:o.current)!=null&&m.has(u))}),d={};for(const u of e)(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),l.length===0)return;const c=async u=>{var m;try{if(n.getEntry){const y=await n.getEntry(u);if(y)return{title:y.title,author:y.author}}const h=await n.getItem(u);if(!h)return null;const f=h.title||u,x=h.authors,k=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:f,author:k}}catch{return null}};return Promise.all(l.map(async u=>{var h;const m=await c(u);return(h=o==null?void 0:o.current)==null||h.set(u,m),[u,m]})).then(u=>{a||s(m=>{const h={...m};for(const[f,x]of u)h[f]=x;return h})}),()=>{a=!0}},[e.join(","),n]),r}function Zh({section:e,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=J(),c=Ze(),p=Jt(),u=S=>S?mt(l(S),v=>s?Fn(v,s,p):v,{t:a}):"",[m,h]=g.useState(!1);g.useEffect(()=>{s&&h(!0)},[s]);const f=xt(e.type),x=Fh[f]||i("desc-fg"),k=!!e.content,y=e.work_ids||[],w=y.length>1,b=Xh(w?y:[],o,r),j=k&&!m&&e.content.length>80?Ul(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>k&&h(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[t.jsxs(hr,{enabled:k,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[k&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg"),lineHeight:1.6},children:e.header_line?u(e.header_line):u(e.title)}),!m&&j&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:u(j)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&t.jsx("a",{href:c(y[0]),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),w&&t.jsx("span",{style:{fontSize:"11px",color:i("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:y.length})}),t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:x,border:`1px solid ${x}40`,borderRadius:"2px",background:`${x}08`},children:mr(d,f,l)})]})]}),w&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(S=>{const v=b[S],$=v?`${l(v.title)}${v.author?`(${l(v.author)})`:""}`:S.slice(0,8)+"…";return t.jsxs("a",{href:c(S),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),_.stopPropagation(),n(S))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:S,children:["→",$]},S)})}),m&&k&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(e.content)}),e.comment&&t.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(e.comment)})]})]})}function Jh({juan:e,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:a}=J(),l=Jt(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>pr(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,u)=>t.jsx(Zh,{section:p,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:d},u))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function Qh(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function eg({sections:e,onNavigate:n,inline:o,workLinks:r=!0}){const s=Ze(),{t:a,convert:l}=J(),d=Qh();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const u=xt(c.type);if(u==="page_header"&&!gr(c))return null;if(u==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,o(l(c.title))),c.content&&t.jsx("p",{children:o(l(c.content))})]},p);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:dr(c.n_juan)}):""}`:c.title,h=o(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:h}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):h),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:o(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>t.jsx("p",{children:o(l(f))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),o(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),o(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),o(l(c.additional_comment))]})]},p)}return c.content?t.jsx("p",{children:o(l(c.content))},p):null})})}function sc(e){return e.some(n=>{const o=xt(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&gr(n)})}function tg({juan:e,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:u,onViewChange:m}){var O;const{t:h,convert:f,messages:x}=J(),k=Jt(),[y,w]=g.useState("text"),b=u??y,j=A=>{w(A),m==null||m(A)},S=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",$=g.useCallback(A=>S?Fn(A,S,k):A,[S,k]),_=A=>lr(A,{renderText:$,properNames:!!p.properNames,t:h}),C=g.useMemo(()=>S?e.sections.filter(A=>pr(A,S,v,k)):e.sections,[e.sections,S,v,k]),M=(A,G)=>G.filter(se=>xt(se.type)===A).length,N=M("书",e.sections),T=M("诗",e.sections),F=M("考证",e.sections);let R="";v?R=S?h("collated.countTiaoOf",{m:M("考证",C),n:F}):h("collated.countTiao",{n:F}):T>0?R=S?h("collated.countPoemsOf",{m:M("诗",C),n:T}):h("collated.countPoems",{n:T}):N>0&&(R=S?h("collated.countBooksOf",{m:M("书",C),n:N}):h("collated.countBooks",{n:N}));const E=s!=null&&s.text_quality?Rh(s.text_quality.grade):null,L=[];R&&L.push(R),v&&(s!=null&&s.target_source)&&L.push(t.jsx(t.Fragment,{children:h("collated.kaozhenTarget",{target:f(s.target_source)})})),E&&L.push(t.jsx("span",{title:x.collated.qualityCriteria[E],children:(O=s==null?void 0:s.text_quality)!=null&&O.source_note?t.jsxs(t.Fragment,{children:[Lh(h("collated.baseText",{note:oc}),s.text_quality.source_note,f),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[E]})]}):t.jsxs(t.Fragment,{children:[h("collated.textQuality"),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[E]})]})})),e.source_url&&L.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:h("collated.originalSource")}));const I=!v&&sc(e.sections),P=!!n&&(!I||p.readingMode==="paragraph"&&pi(n)),V=!v&&(I||!!n),X=v||!V?"entries":b;let D=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(o||r)&&t.jsxs("p",{className:"bim-rd-kicker",children:[o,o&&r&&t.jsx("span",{className:"bim-rd-dot"}),r&&f(r)]}),t.jsx("h1",{className:"bim-rd-h1",children:f(e.title)}),L.length>0&&t.jsx("p",{className:"bim-rd-meta",children:L.map((A,G)=>t.jsxs(g.Fragment,{children:[G>0&&t.jsx("span",{className:"bim-rd-dot"}),A]},G))}),V&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":h("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":X==="text",onClick:()=>j("text"),children:h("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":X==="entries",onClick:()=>j("entries"),children:h("collated.viewEntries")})]})]}),X==="text"&&t.jsx("article",{className:"bim-rd-prose",children:P?t.jsx(cr,{text:n,mode:p.readingMode,properNames:!!p.properNames,renderText:$,dropTitle:e.title}):t.jsx(eg,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),X==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?t.jsx(Jh,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[C.some(A=>["书","诗","考证"].includes(xt(A.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:h("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:h("collated.rowHeadTitle")}),t.jsx("span",{children:h("collated.rowHeadWork")})]}),C.map((A,G)=>{const se=xt(A.type);return se==="书"||se==="诗"||se==="考证"?(D+=1,t.jsx(Gh,{domId:`rd-e-${e.sections.indexOf(A)}`,section:A,onNavigate:p.workLinks?l:void 0,highlightQuery:S,no:D,showUnlinked:p.workLinks&&!!l},G)):se==="类"?t.jsx(Yh,{section:A,highlightQuery:S},G):t.jsx(qh,{section:A,highlightQuery:S},G)}),C.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:h("collated.noMatch")})]})})]})}function ng(e){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=Jt(),u=g.useRef(new Map),[m,h]=g.useState({}),[f,x]=g.useState({}),k=g.useCallback((w,b)=>{const j=b==null?void 0:b.title;j&&x(S=>S[w]===j?S:{...S,[w]:j})},[]);g.useEffect(()=>{s&&a&&(u.current.set(s,{juan:a,rawText:l}),k(s,a))},[s,a,l,k]),g.useEffect(()=>{u.current.clear(),h({}),x({})},[n]);const y=g.useCallback((w,b)=>{let j=0;if(w.juan)for(const S of w.juan.sections)pr(S,b,c,p)&&j++;return j===0&&w.rawText&&Hh(w.rawText,b,p)&&(j=1),j},[c,p]);return g.useEffect(()=>{const w=d.trim();if(!w){h({});return}if(!o||r.length===0)return;let b=!1;const j={},S=[];for(const M of r){const N=u.current.get(M);N?j[M]=y(N,w):(j[M]="loading",S.push(M))}h(j);const v=8;let $=0;const _=async()=>{for(;$<S.length;){if(b)return;const M=$++,N=S[M];try{const T=await o(N),F=T.juan;if(u.current.set(N,T),k(N,F),b)return;h(R=>({...R,[N]:y(T,w)}))}catch{if(b)return;h(T=>({...T,[N]:0}))}}},C=Array.from({length:Math.min(v,S.length)},()=>_());return Promise.all(C),()=>{b=!0}},[d,n,o,r.join(","),y,p,k]),{matchStates:m,titles:f}}function ig({juan:e,view:n,onView:o,textHasEntries:r}){const{t:s,convert:a}=J(),l=e.sections.map((u,m)=>({s:u,i:m,t:xt(u.type)})).filter(u=>u.t==="书"||u.t==="诗");if(l.length===0)return null;const d=l.filter(u=>!!u.s.work_id).length,c=l.every(u=>u.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=u=>{const m=()=>{var h,f;return(f=(h=document.getElementById(`rd-e-${u}`))==null?void 0:h.scrollIntoView)==null?void 0:f.call(h,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?setTimeout(m,0):m()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:u,i:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:h=>{h.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${u.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:a(u.book_title||u.title)})]})},m))})]})]})}const og=`
|
|
1227
1227
|
attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
|
|
1228
1228
|
attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
|
|
1229
1229
|
|
|
@@ -1241,7 +1241,7 @@ ${Fm}`;function Nn({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{clas
|
|
|
1241
1241
|
// 纹理坐标归一化 [0, 1]
|
|
1242
1242
|
v_texCoord = a_texCoord / u_imgResolution;
|
|
1243
1243
|
}
|
|
1244
|
-
`,
|
|
1244
|
+
`,rg=`
|
|
1245
1245
|
precision mediump float;
|
|
1246
1246
|
uniform sampler2D u_image;
|
|
1247
1247
|
uniform float u_alpha;
|
|
@@ -1251,8 +1251,8 @@ ${Fm}`;function Nn({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{clas
|
|
|
1251
1251
|
vec4 tex = texture2D(u_image, v_texCoord);
|
|
1252
1252
|
gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
|
|
1253
1253
|
}
|
|
1254
|
-
`;function Ms(e,n,o){const r=e.createShader(n);return r?(e.shaderSource(r,o),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error("Shader compile error:",e.getShaderInfoLog(r)),e.deleteShader(r),null)):null}class wo{constructor(n){const o=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!o)throw new Error("WebGL not supported");this.gl=o;const r=Ms(o,o.VERTEX_SHADER,ng),s=Ms(o,o.FRAGMENT_SHADER,ig);if(!r||!s)throw new Error("Failed to create shaders");const a=o.createProgram();if(!a)throw new Error("Failed to create program");if(o.attachShader(a,r),o.attachShader(a,s),o.linkProgram(a),!o.getProgramParameter(a,o.LINK_STATUS))throw new Error("Program link error: "+o.getProgramInfoLog(a));this.program=a,this.positionBuffer=o.createBuffer(),this.texCoordBuffer=o.createBuffer(),this.uResolutionLoc=o.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=o.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=o.getUniformLocation(a,"u_alpha"),this.aPositionLoc=o.getAttribLocation(a,"a_position"),this.aTexCoordLoc=o.getAttribLocation(a,"a_texCoord"),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,o){const r=this.gl;r.viewport(0,0,n,o),r.clearColor(.98,.97,.95,1),r.clear(r.COLOR_BUFFER_BIT)}createTexture(n){const o=this.gl,r=o.createTexture();return o.bindTexture(o.TEXTURE_2D,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,n),r}renderStripsWithTexture(n,o,r,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,o,r),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,o,r),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],u=[],m=8;for(const h of l){const f=h.colOffsetX||0,x=h.colOffsetY||0,{srcQuad:k,dstRect:y}=h.strip,[w,b,j,S]=y,v=f+w,$=x+b,[_,C,M,N]=k;for(let T=0;T<m;T++){const F=T/m,R=(T+1)/m,E=$+S*F,L=$+S*R,I=[_[0]+(N[0]-_[0])*F,_[1]+(N[1]-_[1])*F],P=[_[0]+(N[0]-_[0])*R,_[1]+(N[1]-_[1])*R],V=[C[0]+(M[0]-C[0])*F,C[1]+(M[1]-C[1])*F],X=[C[0]+(M[0]-C[0])*R,C[1]+(M[1]-C[1])*R],D=[v,E],O=[v+j,E],A=[v,L],G=[v+j,L];p.push(D[0],D[1],O[0],O[1],A[0],A[1]),u.push(I[0],I[1],V[0],V[1],P[0],P[1]),p.push(O[0],O[1],G[0],G[1],A[0],A[1]),u.push(V[0],V[1],X[0],X[1],P[0],P[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW),c.enableVertexAttribArray(this.aPositionLoc),c.vertexAttribPointer(this.aPositionLoc,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.texCoordBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(u),c.STATIC_DRAW),c.enableVertexAttribArray(this.aTexCoordLoc),c.vertexAttribPointer(this.aTexCoordLoc,2,c.FLOAT,!1,0,0),c.bindTexture(c.TEXTURE_2D,n),c.drawArrays(c.TRIANGLES,0,p.length/2)}deleteTexture(n){n&&this.gl.deleteTexture(n)}destroy(){const n=this.gl;n.deleteProgram(this.program),n.deleteBuffer(this.positionBuffer),n.deleteBuffer(this.texCoordBuffer)}}const At=new Map,og=24;function So(e){let n=At.get(e);if(n)return At.delete(e),At.set(e,n),n;for(n=new Promise(o=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{(r.decode?r.decode().catch(()=>{}):Promise.resolve()).then(()=>o(r))},r.onerror=()=>{At.delete(e),o(null)},r.src=e}),At.set(e,n);At.size>og;)At.delete(At.keys().next().value);return n}const fr=({imageUrl:e,pageData:n,selectedCharIds:o,hoveredCharId:r,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),u=g.useRef(null),m=g.useRef(null),h=g.useRef(null),[f,x]=g.useState(0),[k,y]=g.useState(0),w=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(R=>R.warped_h),2440),[n]),j=n.total_warped_w,S=n.banxin,v=g.useMemo(()=>{var X;if(!s)return{top:0,bottom:0,left:0,right:0};const[R,E]=n.image_size||[2386,3082];let L=1/0,I=-1/0,P=1/0,V=-1/0;for(const D of n.columns)for(const O of D.strips||[])for(const A of O.srcQuad)A[0]<L&&(L=A[0]),A[0]>I&&(I=A[0]),A[1]<P&&(P=A[1]),A[1]>V&&(V=A[1]);if((X=n.banxin)!=null&&X.current_page_strips)for(const D of n.banxin.current_page_strips)for(const O of D.srcQuad)O[0]<L&&(L=O[0]),O[0]>I&&(I=O[0]),O[1]<P&&(P=O[1]),O[1]>V&&(V=O[1]);return isFinite(L)||(L=0),isFinite(I)||(I=R),isFinite(P)||(P=0),isFinite(V)||(V=E),{top:Math.max(0,Math.round(P)),bottom:Math.max(0,Math.round(E-V)),left:Math.max(0,Math.round(L)),right:Math.max(0,Math.round(R-I)),rawMinX:L,rawMaxX:I,rawMinY:P,rawMaxY:V,imgW:R,imgH:E}},[n,s]),$=j+(S?S.total_w:0),_=$+v.left+v.right,C=b+v.top+v.bottom,M=g.useCallback(()=>{const R=c.current;if(!(!R||!d.current)&&!(e&&w.current!==e)){if(R.clear(_,C),s&&v.rawMinX!==void 0&&m.current&&p.current){const{rawMinX:E,rawMaxX:L,rawMinY:I,rawMaxY:P,imgW:V,imgH:X,top:D,bottom:O,left:A,right:G}=v,se=[];A>0&&se.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[E,0],[E,X],[0,X]],dstRect:[0,0,A,C]}}),D>0&&se.push({colOffsetX:A,colOffsetY:0,strip:{srcQuad:[[E,0],[L,0],[L,I],[E,I]],dstRect:[0,0,$,D]}}),O>0&&se.push({colOffsetX:A,colOffsetY:D+b,strip:{srcQuad:[[E,P],[L,P],[L,X],[E,X]],dstRect:[0,0,$,O]}}),G>0&&se.push({colOffsetX:A+$,colOffsetY:0,strip:{srcQuad:[[L,0],[V,0],[V,X],[L,X]],dstRect:[0,0,G,C]}}),R.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],se,1)}if(m.current&&p.current){const E=n.columns.flatMap(L=>(L.strips||[]).map(I=>({colOffsetX:v.left+L.offset_x,colOffsetY:v.top,strip:I})));if(E.length>0?R.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],E,1):R.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,_,C]}}],1),S&&S.current_page_strips.length>0){const L=S.current_page_strips.map(I=>({colOffsetX:v.left+j,colOffsetY:v.top,strip:I}));R.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],L,1)}}if(S&&h.current&&u.current&&S.mate_page_strips.length>0){const E=S.mate_page_strips.map(L=>({colOffsetX:v.left+j+S.half_w,colOffsetY:v.top,strip:L}));R.renderStripsWithTexture(h.current,_,C,S.mate_img_size[0],S.mate_img_size[1],E,.65)}}},[e,n,S,_,C,j,b,$,v,s]),N=g.useRef(M);N.current=M,g.useEffect(()=>{const R=d.current;if(!R)return;const E=P=>{m.current=p.current?P.createTexture(p.current):null,h.current=u.current?P.createTexture(u.current):null,N.current()};try{const P=new wo(R);c.current=P,E(P)}catch(P){console.error("Failed to init WebGL renderer:",P)}const L=P=>{P.preventDefault(),console.warn("WebGL context lost")},I=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new wo(d.current),E(c.current))};return R.addEventListener("webglcontextlost",L,!1),R.addEventListener("webglcontextrestored",I,!1),()=>{R.removeEventListener("webglcontextlost",L),R.removeEventListener("webglcontextrestored",I),c.current&&(c.current.deleteTexture(m.current),c.current.deleteTexture(h.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let R=!0;return So(e).then(E=>{if(!R||!E)return;p.current=E,w.current=e;const L=c.current;L&&(L.deleteTexture(m.current),m.current=L.createTexture(E)),x(I=>I+1)}),()=>{R=!1}},[e]);const T=S==null?void 0:S.mate_image_url;g.useEffect(()=>{if(!T)return;let R=!0;return So(T).then(E=>{if(!R||!E)return;u.current=E;const L=c.current;L&&(L.deleteTexture(h.current),h.current=L.createTexture(E)),y(I=>I+1)}),()=>{R=!1}},[T]),g.useEffect(()=>{M()},[M,f,k]);const F=g.useMemo(()=>{const R=[];for(const E of n.columns)for(const L of E.chars){const[I,P,V,X]=L.bbox_col;R.push({id:L.id,char:L.char,x:v.left+E.offset_x+I,y:v.top+P,w:Math.max(V-I,1),h:Math.max(X-P,1)})}return R},[n,v]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${C}`,backgroundColor:i("warp-bg"),boxShadow:i("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:C,style:{width:"100%",height:"100%",display:"block",backgroundColor:i("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${C}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[F.map(R=>{const E=o.has(R.id),L=r===R.id;return t.jsx("rect",{"data-selected":E?"true":void 0,x:R.x,y:R.y,width:R.w,height:R.h,fill:E?i("warp-sel-bg"):L?i("warp-hover-bg"):"transparent",stroke:E?i("warp-sel-stroke"):L?i("warp-hover-stroke"):"transparent",strokeWidth:E?3.5:L?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(R.id),onMouseEnter:()=>l==null?void 0:l(R.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:R.char})},R.id)}),S&&t.jsxs("g",{children:[t.jsx("line",{x1:v.left+j,y1:v.top,x2:v.left+j,y2:v.top+b,stroke:i("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:v.left+j+S.half_w,y1:v.top,x2:v.left+j+S.half_w,y2:v.top+b,stroke:i("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:v.left+$,y1:v.top,x2:v.left+$,y2:v.top+b,stroke:i("warp-banxin-outer"),strokeWidth:1})]})]})]})},rg={work:"work",book:"work",people:"person",person:"person",place:"place",office:"office",dynasty:"dynasty"};function sg(e){return typeof e=="string"&&rg[e]||"other"}function _o(e){if(!e)return null;const n=e.trim(),o=/^book-index:\/\/(?:[A-Za-z]+\/)*([0-9A-Za-z]+)\/?$/.exec(n);if(o)return o[1];const r=/^bid:\\{1,2}([0-9A-Za-z]+)$/.exec(n);return r?r[1]:/^[0-9A-Za-z]+$/.test(n)?n:null}function _n(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Pt(e){return typeof e=="string"&&e?e:void 0}function sc(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.entities)?e.entities:[],o=[];return n.forEach((r,s)=>{if(!r||typeof r!="object")return;const a=r,l=a.span??{},d=a.target??{},c=_n(l.start_offset)??_n(a.start_offset),p=_n(l.end_offset)??_n(a.end_offset);if(c===void 0||p===void 0||c<0||p<=c)return;const u=Pt(d.status),m=u===void 0||u==="matched"?_o(Pt(d.entity_id))??_o(Pt(d.href))??void 0:void 0,h=a.anchor??{},f=Pt(h.start),x=Pt(h.end);o.push({...f&&x?{anchor:{start:f,end:x}}:{},key:Pt(a.id)??`e${s}`,kind:sg(a.type),start:c,end:p,text:Pt(a.text),targetId:m,canonicalName:Pt(d.canonical_name),confidence:_n(a.confidence)})}),o.sort((r,s)=>r.start-s.start||s.end-r.end)}const ag=new Set(Array.from(`《》/<>\r
|
|
1255
|
-
,。、;:?!「」『』()…—·`));function xr(e){return!
|
|
1254
|
+
`;function Bs(e,n,o){const r=e.createShader(n);return r?(e.shaderSource(r,o),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error("Shader compile error:",e.getShaderInfoLog(r)),e.deleteShader(r),null)):null}class wo{constructor(n){const o=n.getContext("webgl",{alpha:!0,antialias:!0,preserveDrawingBuffer:!0,premultipliedAlpha:!1});if(!o)throw new Error("WebGL not supported");this.gl=o;const r=Bs(o,o.VERTEX_SHADER,og),s=Bs(o,o.FRAGMENT_SHADER,rg);if(!r||!s)throw new Error("Failed to create shaders");const a=o.createProgram();if(!a)throw new Error("Failed to create program");if(o.attachShader(a,r),o.attachShader(a,s),o.linkProgram(a),!o.getProgramParameter(a,o.LINK_STATUS))throw new Error("Program link error: "+o.getProgramInfoLog(a));this.program=a,this.positionBuffer=o.createBuffer(),this.texCoordBuffer=o.createBuffer(),this.uResolutionLoc=o.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=o.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=o.getUniformLocation(a,"u_alpha"),this.aPositionLoc=o.getAttribLocation(a,"a_position"),this.aTexCoordLoc=o.getAttribLocation(a,"a_texCoord"),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,o){const r=this.gl;r.viewport(0,0,n,o),r.clearColor(.98,.97,.95,1),r.clear(r.COLOR_BUFFER_BIT)}createTexture(n){const o=this.gl,r=o.createTexture();return o.bindTexture(o.TEXTURE_2D,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,n),r}renderStripsWithTexture(n,o,r,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,o,r),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,o,r),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],u=[],m=8;for(const h of l){const f=h.colOffsetX||0,x=h.colOffsetY||0,{srcQuad:k,dstRect:y}=h.strip,[w,b,j,S]=y,v=f+w,$=x+b,[_,C,M,N]=k;for(let T=0;T<m;T++){const F=T/m,R=(T+1)/m,E=$+S*F,L=$+S*R,I=[_[0]+(N[0]-_[0])*F,_[1]+(N[1]-_[1])*F],P=[_[0]+(N[0]-_[0])*R,_[1]+(N[1]-_[1])*R],V=[C[0]+(M[0]-C[0])*F,C[1]+(M[1]-C[1])*F],X=[C[0]+(M[0]-C[0])*R,C[1]+(M[1]-C[1])*R],D=[v,E],O=[v+j,E],A=[v,L],G=[v+j,L];p.push(D[0],D[1],O[0],O[1],A[0],A[1]),u.push(I[0],I[1],V[0],V[1],P[0],P[1]),p.push(O[0],O[1],G[0],G[1],A[0],A[1]),u.push(V[0],V[1],X[0],X[1],P[0],P[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW),c.enableVertexAttribArray(this.aPositionLoc),c.vertexAttribPointer(this.aPositionLoc,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.texCoordBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(u),c.STATIC_DRAW),c.enableVertexAttribArray(this.aTexCoordLoc),c.vertexAttribPointer(this.aTexCoordLoc,2,c.FLOAT,!1,0,0),c.bindTexture(c.TEXTURE_2D,n),c.drawArrays(c.TRIANGLES,0,p.length/2)}deleteTexture(n){n&&this.gl.deleteTexture(n)}destroy(){const n=this.gl;n.deleteProgram(this.program),n.deleteBuffer(this.positionBuffer),n.deleteBuffer(this.texCoordBuffer)}}const Lt=new Map,sg=24;function So(e){let n=Lt.get(e);if(n)return Lt.delete(e),Lt.set(e,n),n;for(n=new Promise(o=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{(r.decode?r.decode().catch(()=>{}):Promise.resolve()).then(()=>o(r))},r.onerror=()=>{Lt.delete(e),o(null)},r.src=e}),Lt.set(e,n);Lt.size>sg;)Lt.delete(Lt.keys().next().value);return n}const fr=({imageUrl:e,pageData:n,selectedCharIds:o,hoveredCharId:r,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),u=g.useRef(null),m=g.useRef(null),h=g.useRef(null),[f,x]=g.useState(0),[k,y]=g.useState(0),w=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(R=>R.warped_h),2440),[n]),j=n.total_warped_w,S=n.banxin,v=g.useMemo(()=>{var X;if(!s)return{top:0,bottom:0,left:0,right:0};const[R,E]=n.image_size||[2386,3082];let L=1/0,I=-1/0,P=1/0,V=-1/0;for(const D of n.columns)for(const O of D.strips||[])for(const A of O.srcQuad)A[0]<L&&(L=A[0]),A[0]>I&&(I=A[0]),A[1]<P&&(P=A[1]),A[1]>V&&(V=A[1]);if((X=n.banxin)!=null&&X.current_page_strips)for(const D of n.banxin.current_page_strips)for(const O of D.srcQuad)O[0]<L&&(L=O[0]),O[0]>I&&(I=O[0]),O[1]<P&&(P=O[1]),O[1]>V&&(V=O[1]);return isFinite(L)||(L=0),isFinite(I)||(I=R),isFinite(P)||(P=0),isFinite(V)||(V=E),{top:Math.max(0,Math.round(P)),bottom:Math.max(0,Math.round(E-V)),left:Math.max(0,Math.round(L)),right:Math.max(0,Math.round(R-I)),rawMinX:L,rawMaxX:I,rawMinY:P,rawMaxY:V,imgW:R,imgH:E}},[n,s]),$=j+(S?S.total_w:0),_=$+v.left+v.right,C=b+v.top+v.bottom,M=g.useCallback(()=>{const R=c.current;if(!(!R||!d.current)&&!(e&&w.current!==e)){if(R.clear(_,C),s&&v.rawMinX!==void 0&&m.current&&p.current){const{rawMinX:E,rawMaxX:L,rawMinY:I,rawMaxY:P,imgW:V,imgH:X,top:D,bottom:O,left:A,right:G}=v,se=[];A>0&&se.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[E,0],[E,X],[0,X]],dstRect:[0,0,A,C]}}),D>0&&se.push({colOffsetX:A,colOffsetY:0,strip:{srcQuad:[[E,0],[L,0],[L,I],[E,I]],dstRect:[0,0,$,D]}}),O>0&&se.push({colOffsetX:A,colOffsetY:D+b,strip:{srcQuad:[[E,P],[L,P],[L,X],[E,X]],dstRect:[0,0,$,O]}}),G>0&&se.push({colOffsetX:A+$,colOffsetY:0,strip:{srcQuad:[[L,0],[V,0],[V,X],[L,X]],dstRect:[0,0,G,C]}}),R.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],se,1)}if(m.current&&p.current){const E=n.columns.flatMap(L=>(L.strips||[]).map(I=>({colOffsetX:v.left+L.offset_x,colOffsetY:v.top,strip:I})));if(E.length>0?R.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],E,1):R.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,_,C]}}],1),S&&S.current_page_strips.length>0){const L=S.current_page_strips.map(I=>({colOffsetX:v.left+j,colOffsetY:v.top,strip:I}));R.renderStripsWithTexture(m.current,_,C,n.image_size[0],n.image_size[1],L,1)}}if(S&&h.current&&u.current&&S.mate_page_strips.length>0){const E=S.mate_page_strips.map(L=>({colOffsetX:v.left+j+S.half_w,colOffsetY:v.top,strip:L}));R.renderStripsWithTexture(h.current,_,C,S.mate_img_size[0],S.mate_img_size[1],E,.65)}}},[e,n,S,_,C,j,b,$,v,s]),N=g.useRef(M);N.current=M,g.useEffect(()=>{const R=d.current;if(!R)return;const E=P=>{m.current=p.current?P.createTexture(p.current):null,h.current=u.current?P.createTexture(u.current):null,N.current()};try{const P=new wo(R);c.current=P,E(P)}catch(P){console.error("Failed to init WebGL renderer:",P)}const L=P=>{P.preventDefault(),console.warn("WebGL context lost")},I=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new wo(d.current),E(c.current))};return R.addEventListener("webglcontextlost",L,!1),R.addEventListener("webglcontextrestored",I,!1),()=>{R.removeEventListener("webglcontextlost",L),R.removeEventListener("webglcontextrestored",I),c.current&&(c.current.deleteTexture(m.current),c.current.deleteTexture(h.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let R=!0;return So(e).then(E=>{if(!R||!E)return;p.current=E,w.current=e;const L=c.current;L&&(L.deleteTexture(m.current),m.current=L.createTexture(E)),x(I=>I+1)}),()=>{R=!1}},[e]);const T=S==null?void 0:S.mate_image_url;g.useEffect(()=>{if(!T)return;let R=!0;return So(T).then(E=>{if(!R||!E)return;u.current=E;const L=c.current;L&&(L.deleteTexture(h.current),h.current=L.createTexture(E)),y(I=>I+1)}),()=>{R=!1}},[T]),g.useEffect(()=>{M()},[M,f,k]);const F=g.useMemo(()=>{const R=[];for(const E of n.columns)for(const L of E.chars){const[I,P,V,X]=L.bbox_col;R.push({id:L.id,char:L.char,x:v.left+E.offset_x+I,y:v.top+P,w:Math.max(V-I,1),h:Math.max(X-P,1)})}return R},[n,v]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${C}`,backgroundColor:i("warp-bg"),boxShadow:i("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:C,style:{width:"100%",height:"100%",display:"block",backgroundColor:i("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${C}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[F.map(R=>{const E=o.has(R.id),L=r===R.id;return t.jsx("rect",{"data-selected":E?"true":void 0,x:R.x,y:R.y,width:R.w,height:R.h,fill:E?i("warp-sel-bg"):L?i("warp-hover-bg"):"transparent",stroke:E?i("warp-sel-stroke"):L?i("warp-hover-stroke"):"transparent",strokeWidth:E?3.5:L?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(R.id),onMouseEnter:()=>l==null?void 0:l(R.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:R.char})},R.id)}),S&&t.jsxs("g",{children:[t.jsx("line",{x1:v.left+j,y1:v.top,x2:v.left+j,y2:v.top+b,stroke:i("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:v.left+j+S.half_w,y1:v.top,x2:v.left+j+S.half_w,y2:v.top+b,stroke:i("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:v.left+$,y1:v.top,x2:v.left+$,y2:v.top+b,stroke:i("warp-banxin-outer"),strokeWidth:1})]})]})]})},ag={work:"work",book:"work",people:"person",person:"person",place:"place",office:"office",dynasty:"dynasty"};function lg(e){return typeof e=="string"&&ag[e]||"other"}function _o(e){if(!e)return null;const n=e.trim(),o=/^book-index:\/\/(?:[A-Za-z]+\/)*([0-9A-Za-z]+)\/?$/.exec(n);if(o)return o[1];const r=/^bid:\\{1,2}([0-9A-Za-z]+)$/.exec(n);return r?r[1]:/^[0-9A-Za-z]+$/.test(n)?n:null}function $n(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function At(e){return typeof e=="string"&&e?e:void 0}function ac(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.entities)?e.entities:[],o=[];return n.forEach((r,s)=>{if(!r||typeof r!="object")return;const a=r,l=a.span??{},d=a.target??{},c=$n(l.start_offset)??$n(a.start_offset),p=$n(l.end_offset)??$n(a.end_offset);if(c===void 0||p===void 0||c<0||p<=c)return;const u=At(d.status),m=u===void 0||u==="matched"?_o(At(d.entity_id))??_o(At(d.href))??void 0:void 0,h=a.anchor??{},f=At(h.start),x=At(h.end);o.push({...f&&x?{anchor:{start:f,end:x}}:{},key:At(a.id)??`e${s}`,kind:lg(a.type),start:c,end:p,text:At(a.text),targetId:m,canonicalName:At(d.canonical_name),confidence:$n(a.confidence)})}),o.sort((r,s)=>r.start-s.start||s.end-r.end)}const cg=new Set(Array.from(`《》/<>\r
|
|
1255
|
+
,。、;:?!「」『』()…—·`));function xr(e){return!cg.has(e)}function lc(e,n,o=0){const r=[],s=Array.from(e);let a=0;for(const d of s)xr(d)&&r.push(a),a+=d.length;const l=[];for(const d of n){const c=d.start-o,p=d.end-o;if(c<0||p>r.length||p<=c)continue;const u=r[p-1],m=e.codePointAt(u)>65535?2:1;l.push({...d,start:r[c],end:u+m})}return l}function dg(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(xr).join("")===n.text:!0}function pg(e,n,o){if(!n.text)return null;let r=-1,s=Math.max(0,n.start-o);const a=n.start+o;for(;s<=a;){const l=e.indexOf(n.text,s);if(l<0||l>a)break;(r<0||Math.abs(l-n.start)<Math.abs(r-n.start))&&(r=l),s=l+1}return r<0?null:{...n,start:r,end:r+n.text.length}}function cc(e,n,o=16){const r=[];for(const l of n){let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!dg(e,d))&&(d=pg(e,l,o)),d&&r.push(d)}r.sort((l,d)=>l.start-d.start||d.end-l.end);const s=[];let a=0;for(const l of r)l.start<a||(l.start>a&&s.push({type:"text",text:e.slice(a,l.start),start:a}),s.push({type:"entity",text:e.slice(l.start,l.end),start:l.start,span:l}),a=l.end);return a<e.length&&s.push({type:"text",text:e.slice(a),start:a}),s}const br=`
|
|
1256
1256
|
.bim-et-w { position: relative; display: inline; }
|
|
1257
1257
|
.bim-et {
|
|
1258
1258
|
color: inherit; text-decoration-line: underline;
|
|
@@ -1292,17 +1292,17 @@ a.bim-et:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 2px;
|
|
|
1292
1292
|
.bim-et-card { animation: bim-et-in 120ms ease-out; }
|
|
1293
1293
|
@keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
|
|
1294
1294
|
}
|
|
1295
|
-
`,dg=120;function pt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function pg(e,n=dg){if(!e)return;const o=e.replace(/\s+/g," ").trim(),r=Array.from(o);return r.length>n?r.slice(0,n).join("")+"…":o}function ug(e){const n=typeof e.birth_year=="number"?e.birth_year:void 0,o=typeof e.death_year=="number"?e.death_year:void 0;if(!(n===void 0&&o===void 0))return`${n??"?"}–${o??"?"}`}function mg(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(o=>{if(!o||typeof o!="object")return"";const r=o,s=pt(r.name);return s?[pt(r.dynasty)&&`〔${pt(r.dynasty)}〕`,s,pt(r.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function cc(e,n){const o=pt(n.type),r=pt(n.primary_name)??pt(n.title)??e,s=o==="entity"?[pt(n.dynasty),ug(n),pt(n.native_place)].filter(Boolean).join(" · "):[mg(n),pt(n.edition),pt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?pt(n.description.text):pt(n.description);return{id:e,type:o,title:r,meta:s||void 0,description:pg(a)}}function dc(e){const n=[e.dynasty,e.author,e.edition].filter(Boolean).join(" · ");return{id:e.id,type:e.type,title:e.title,meta:n||void 0}}function pc(e){return async n=>{const o=await e.getItem(n);if(o)return cc(n,o);if(e.getEntry){const r=await e.getEntry(n);if(r)return dc(r)}return null}}const Bs=new WeakMap;function hg(e,n,o){let r=Bs.get(e);r||(r=new Map,Bs.set(e,r));const s=r.get(o);if(s)return s;const a=n(o);return r.set(o,a),a.catch(()=>r.delete(o)),a}const uc=e=>`/item/${encodeURIComponent(e)}`,gg={work:"書名",person:"人名",place:"地名",office:"官職",dynasty:"朝代",other:"專名"},fg=typeof window>"u"?g.useEffect:g.useLayoutEffect;function yr(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:pc(e)}:null,[n,e])}const xg=e=>e,bg=({text:e,entities:n,offsets:o="text",plainBase:r=0,transport:s,loadSummary:a,buildHref:l=uc,onNavigate:d,renderText:c=xg,hoverDelayMs:p=250,injectStyles:u=!0,className:m})=>{const h=g.useMemo(()=>{const x=o==="plain"?ac(e,n,r):n;return lc(e,x)},[e,n,o,r]),f=yr(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:br}),h.map(x=>x.type==="text"?t.jsx(g.Fragment,{children:c(x.text)},`t${x.start}`):t.jsx(jr,{span:x.span,label:x.text,hasBrackets:e[x.start-1]==="《"&&e[x.start+x.text.length]==="》",loader:f,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p},`${x.span.key}@${x.start}`))]})},jr=({span:e,label:n,hasBrackets:o,loader:r,buildHref:s,onNavigate:a,renderText:l,hoverDelayMs:d})=>{const c=g.useId(),[p,u]=g.useState(!1),m=g.useRef(null),h=`bim-et bim-et-${e.kind}`,f=e.kind==="work"&&!o,x=t.jsxs(t.Fragment,{children:[f&&t.jsx("span",{className:"bim-et-sr",children:"《"}),l(n),f&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),k=()=>{m.current&&(clearTimeout(m.current),m.current=null)};g.useEffect(()=>k,[]);const y=g.useCallback(j=>{k(),j<=0?u(!0):m.current=setTimeout(()=>u(!0),j)},[]),w=g.useCallback(()=>{k(),u(!1)},[]);if(!e.targetId)return t.jsx("span",{className:h,children:x});const b=e.targetId;return t.jsxs("span",{className:"bim-et-w",onMouseEnter:()=>y(d),onMouseLeave:w,onKeyDown:j=>{j.key==="Escape"&&p&&(j.stopPropagation(),w())},children:[t.jsx("a",{className:h,href:s(b),"data-entity-id":b,"aria-describedby":p?c:void 0,onFocus:()=>y(0),onBlur:w,onClick:a?j=>a(b,j):void 0,children:x}),p&&t.jsx(yg,{id:c,entityId:b,span:e,loader:r})]})},yg=({id:e,entityId:n,span:o,loader:r})=>{const{convert:s}=J(),a=g.useRef(null),[l,d]=g.useState("start"),[c,p]=g.useState(r?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!r)return;let h=!1;return p({status:"loading"}),hg(r.owner,r.load,n).then(f=>{h||p({status:"ready",summary:f})}).catch(()=>{h||p({status:"error"})}),()=>{h=!0}},[r,n]),fg(()=>{const h=a.current;if(!h||typeof window>"u")return;const f=h.getBoundingClientRect(),x=document.documentElement.clientWidth||window.innerWidth;f.right>x-8&&l==="start"&&d("end")},[c,l]);const u=c.status==="ready"?c.summary:null,m=(u==null?void 0:u.title)??o.canonicalName??o.text;return t.jsxs("span",{ref:a,id:e,role:"tooltip",className:"bim-et-card","data-align":l,children:[t.jsx("span",{className:"bim-et-card-k",children:s(gg[o.kind])}),m&&t.jsx("span",{className:"bim-et-card-t",children:s(m)}),(u==null?void 0:u.meta)&&t.jsx("span",{className:"bim-et-card-m",children:s(u.meta)}),(u==null?void 0:u.description)&&t.jsx("span",{className:"bim-et-card-d",children:s(u.description)}),c.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:s("載入中…")}),c.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:s("摘要載入失敗")})]})},jg=e=>`/item/${encodeURIComponent(e)}`;function vg(e){const n=e.filter(o=>o.kind!=="break");return{before:n.filter(o=>o.pos==="before"),after:n.filter(o=>o.pos!=="before")}}function kg(e,n){const o=[];for(const r of e){const s=n.get(r.charData.id)??null,a=o[o.length-1];a&&a.entity===s?a.chars.push(r):o.push({entity:s,chars:[r]})}return o}const vr=({pageData:e,pages:n,punctuations:o=Sg,selectedCharIds:r,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:u,convert:m,scrollToPage:h,entities:f,entityTransport:x,loadEntitySummary:k,buildEntityHref:y,onEntityNavigate:w})=>{const b=g.useRef(null),j=g.useRef(0),S=g.useMemo(()=>{const I=new Map;return p&&o.forEach((P,V)=>{const X=P.id?P:{...P,id:`${P.anchor}#${V}`},D=I.get(X.anchor)||[];D.push(X),I.set(X.anchor,D)}),I},[o,p]),v=g.useMemo(()=>(n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}]).filter(P=>P.columns.some(V=>V.chars.length>0)).map(P=>{const V=[...P.columns].sort((O,A)=>O.col-A.col),X=[];let D=[];for(const O of V)for(const A of O.chars){const{before:G,after:se}=vg(S.get(A.id)||[]),Q=(S.get(A.id)||[]).some(ve=>ve.kind==="break");D.push({charData:A,col:O.col,beforePuncts:G,afterPuncts:se}),Q&&(X.push({id:`para-p${P.page}-${X.length}`,chars:D}),D=[])}return D.length>0&&X.push({id:`para-p${P.page}-${X.length}`,chars:D}),{page:P.page,paragraphs:X}}),[n,e,S]),$=g.useMemo(()=>{const I=[];for(const P of v)for(const V of P.paragraphs)for(const X of V.chars)I.push(X.charData.id);return I},[v]),_=g.useMemo(()=>{const I=new Map;if(!f||f.length===0)return I;const P=new Map($.map((V,X)=>[V,X]));for(const V of f){if(!V.anchor)continue;const X=P.get(V.anchor.start),D=P.get(V.anchor.end);if(!(X===void 0||D===void 0||D<X))for(let O=X;O<=D;O++)I.has($[O])||I.set($[O],V)}return I},[f,$]),C=yr(x,k),M=_.size>0,N=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:w});N.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:w};const T=g.useMemo(()=>({click:I=>{var P,V;j.current=Date.now()+1200,(V=(P=N.current).onCharClick)==null||V.call(P,I)},enter:I=>{var P,V;return(V=(P=N.current).onCharHover)==null?void 0:V.call(P,I)},leave:()=>{var I,P;return(P=(I=N.current).onCharHover)==null?void 0:P.call(I,null)},navigate:(I,P)=>{var X,D;if(!(P.detail===0||P.ctrlKey||P.metaKey||P.shiftKey)){P.preventDefault();return}(D=(X=N.current).onEntityNavigate)==null||D.call(X,I,P)}}),[]),F=_g(r),R=g.useRef(null);g.useEffect(()=>{var P,V;if((P=R.current)==null||P.classList.remove("is-hovered"),R.current=null,!s)return;const I=(V=b.current)==null?void 0:V.querySelector(`span[data-char-id="${s}"]`);I&&(I.classList.add("is-hovered"),R.current=I)},[s]),g.useEffect(()=>{let I=null;const P=()=>{var ke,Pe;I=null;const X=window.getSelection(),D=b.current;if(!X||X.isCollapsed||X.rangeCount===0||!D)return;const O=X.getRangeAt(0),A=O.commonAncestorContainer,G=A.nodeType===3?A.parentElement:A;if(!G||!D.contains(G))return;const se=D.querySelectorAll("span[data-char-id]");let Q=0,ve=se.length;for(;Q<ve;){const Ee=Q+ve>>1;O.comparePoint(se[Ee],0)<0?Q=Ee+1:ve=Ee}const ne=Q;for(ve=se.length;Q<ve;){const Ee=Q+ve>>1;O.comparePoint(se[Ee],0)<=0?Q=Ee+1:ve=Ee}const ce=Q-1;if(ce<ne)return;const We=[];for(let Ee=ne;Ee<=ce;Ee++)We.push(se[Ee].getAttribute("data-char-id"));We.length>0&&(j.current=Date.now()+1200,(Pe=(ke=N.current).onSelectionChange)==null||Pe.call(ke,We))},V=()=>{I&&clearTimeout(I),I=setTimeout(P,120)};return document.addEventListener("selectionchange",V),()=>{document.removeEventListener("selectionchange",V),I&&clearTimeout(I)}},[]),g.useEffect(()=>{var I;if(r.size===1){const P=Array.from(r)[0],V=(I=b.current)==null?void 0:I.querySelector(`span[data-char-id="${P}"]`);V&&V.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[r]);const E=h==null?void 0:h.nonce;g.useEffect(()=>{var P;if(!h)return;const I=(P=b.current)==null?void 0:P.querySelector(`[data-page-section="${h.page}"]`);I&&(j.current=Date.now()+800,I.scrollIntoView({behavior:"auto",block:"start"}))},[E]);const L=!!u;return g.useEffect(()=>{var O;if(!L)return;const I=Array.from(((O=b.current)==null?void 0:O.querySelectorAll("[data-page-section]"))??[]);if(I.length===0)return;const P=120;let V=0;const X=()=>{var Q,ve;if(V=0,Date.now()<j.current)return;let A=0,G=I.length-1;for(;A<G;){const ne=A+G+1>>1;I[ne].getBoundingClientRect().top<=P?A=ne:G=ne-1}const se=parseInt(I[A].getAttribute("data-page-section")||"",10);isNaN(se)||(ve=(Q=N.current).onVisiblePageChange)==null||ve.call(Q,se)},D=()=>{V||(V=requestAnimationFrame(X))};return window.addEventListener("scroll",D,{passive:!0}),X(),()=>{window.removeEventListener("scroll",D),V&&cancelAnimationFrame(V)}},[L,v]),t.jsxs("div",{ref:b,className:"guji-text-pane-content",children:[M&&t.jsx("style",{children:br}),t.jsx("div",{className:"guji-text-reflow-view",children:v.map((I,P)=>t.jsx(Cg,{pGroup:I,first:P===0,selected:F.get(I.page)??wg,entityOfChar:_,entityLoader:C,convert:m,buildHref:y??jg,handlers:T},`page-sec-${I.page}`))})]})},wg=new Set,Sg=[];function _g(e){const n=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(s=>{const a=parseInt(s.split(":")[0],10);let l=o.get(a);l||o.set(a,l=new Set),l.add(s)});const r=new Map;return o.forEach((s,a)=>{const l=n.current.get(a),d=l&&l.size===s.size&&Array.from(s).every(c=>l.has(c));r.set(a,d?l:s)}),n.current=r,r},[e])}function $g(e,n){const o=Array.from(n(e.join("")));return o.length===e.length&&e.every(r=>Array.from(r).length===1)?o:e.map(r=>n(r))}const Cg=g.memo(function({pGroup:n,first:o,selected:r,entityOfChar:s,entityLoader:a,convert:l,buildHref:d,handlers:c}){const p=g.useMemo(()=>{const m=new Map;if(!l)return m;for(const h of n.paragraphs){const f=$g(h.chars.map(x=>x.charData.char),l);h.chars.forEach((x,k)=>m.set(x.charData.id,f[k]))}return m},[n,l]),u=m=>p.get(m.id)??m.char;return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:i("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},children:["第 ",n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}})]}),n.paragraphs.map(m=>t.jsx("p",{className:"guji-reflow-paragraph",children:kg(m.chars,s).map((h,f)=>{const x=h.chars.map(({charData:w,col:b,beforePuncts:j,afterPuncts:S},v)=>{const $=!!h.entity&&v===0,_=!!h.entity&&v===h.chars.length-1,C=$?[]:j,M=_?[]:S;return t.jsxs(g.Fragment,{children:[C.map(N=>t.jsx("span",{className:"guji-text-punct","data-punct-id":N.id,children:N.mark},N.id)),t.jsx("span",{"data-char-id":w.id,onClick:()=>c.click(w.id),onMouseEnter:()=>c.enter(w.id),onMouseLeave:c.leave,className:`guji-text-char${r.has(w.id)?" is-selected":""}${w.sub?" is-sub":""}`,title:`[第${n.page}葉·第${b}列·第${w.slot||w.pos}字] ${u(w)}`,children:u(w)}),M.map(N=>t.jsx("span",{className:"guji-text-punct","data-punct-id":N.id,children:N.mark},N.id))]},w.id)});if(!h.entity)return t.jsx(g.Fragment,{children:x},`r${f}`);const k=h.chars[0].beforePuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id)),y=h.chars[h.chars.length-1].afterPuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id));return t.jsxs(g.Fragment,{children:[k,t.jsx(jr,{span:h.entity,label:h.chars.map(w=>u(w.charData)).join(""),hasBrackets:!0,loader:a,buildHref:d,onNavigate:c.navigate,renderText:()=>x,hoverDelayMs:250}),y]},`${h.entity.key}@${f}`)})},m.id))]})}),mc=1,hc=6,ei={s:1,x:0,y:0},ri=(e,n,o)=>Math.min(o,Math.max(n,e));function kr(e,n,o){const r=ri(e.s,mc,hc);return{s:r,x:ri(e.x,n*(1-r),0),y:ri(e.y,o*(1-r),0)}}function Qi(e,n,o,r,s,a){const l=ri(e.s*r,mc,hc),d=l/e.s;return kr({s:l,x:n-(n-e.x)*d,y:o-(o-e.y)*d},s,a)}function zg(e,n,o,r,s){return kr({s:e.s,x:e.x+n,y:e.y+o},r,s)}function Tg(e,n,o){const r=n===1?e*16:n===2?e*400:e;return Math.exp(-r*(o?.01:.0015))}const Ws=4,Ng=g.forwardRef(function({children:n,onScaleChange:o,resetKey:r,style:s},a){const l=g.useRef(null),[d,c]=g.useState(ei),p=g.useRef(d),u=g.useRef(o);u.current=o;const m=b=>{var S;const j=p.current;p.current=b,c(b),b.s!==j.s&&((S=u.current)==null||S.call(u,b.s))},h=()=>{var j;const b=(j=l.current)==null?void 0:j.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w:j,h:S}=h();m(Qi(p.current,j/2,S/2,b,j,S))},reset(){m(ei)}})),g.useEffect(()=>{m(ei)},[r]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{const{w:S,h:v}=h(),$=kr(p.current,S,v);($.x!==p.current.x||$.y!==p.current.y)&&m($)});return j.observe(b),()=>j.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const j=S=>{const v=Tg(S.deltaY,S.deltaMode,S.ctrlKey);if(p.current.s<=1&&v<1)return;S.preventDefault();const{w:$,h:_,left:C,top:M}=h();m(Qi(p.current,S.clientX-C,S.clientY-M,v,$,_))};return b.addEventListener("wheel",j,{passive:!1}),()=>b.removeEventListener("wheel",j)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),k=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const j=x.current;if(j.swallowClick=!1,f.current.size===1&&(j.moved=0,j.dragging=!1),f.current.size===2){const[S,v]=[...f.current.values()];j.pinchDist=Math.hypot(S.x-v.x,S.y-v.y),j.moved=Ws+1}},y=b=>{var F;const j=f.current.get(b.pointerId);if(!j)return;const S={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,S);const v=x.current,{w:$,h:_,left:C,top:M}=h();if(f.current.size>=2){const[R,E]=[...f.current.values()],L=Math.hypot(R.x-E.x,R.y-E.y);if(v.pinchDist>0&&L>0){const I=(R.x+E.x)/2-C,P=(R.y+E.y)/2-M;m(Qi(p.current,I,P,L/v.pinchDist,$,_))}v.pinchDist=L,v.swallowClick=!0;return}const N=S.x-j.x,T=S.y-j.y;if(v.moved+=Math.abs(N)+Math.abs(T),!(v.moved<=Ws)){if(!v.dragging){v.dragging=!0;try{(F=l.current)==null||F.setPointerCapture(b.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&m(zg(p.current,N,T,$,_))}},w=b=>{f.current.delete(b.pointerId);const j=x.current;j.pinchDist=0,f.current.size===0&&(j.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:k,onPointerMove:y,onPointerUp:w,onPointerCancel:w,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>m(ei),style:{position:"relative",overflow:"hidden",touchAction:"none",cursor:d.s>1?"grab":void 0,...s},children:t.jsx("div",{className:"bim-zp-inner",style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transformOrigin:"0 0",transform:`translate(${d.x}px, ${d.y}px) scale(${d.s})`,willChange:d.s>1?"transform":void 0},children:n})})});function gc(e,n,o,r,s){const[a,l]=g.useState(n??null),[d,c]=g.useState(!1),p=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){l(n);return}const u=++p.current;if(!o){l(null),c(!1);return}if(e){let m;try{m=e(o,s)}catch{l(null),c(!1);return}if(!m||typeof m.then!="function"){l(m??null),c(!1);return}c(!0),m.then(h=>{u===p.current&&l(h??null)}).catch(()=>{u===p.current&&l(null)}).finally(()=>{u===p.current&&c(!1)});return}if(r!=null&&r.warp_data){if(typeof r.warp_data=="object"){l(r.warp_data);return}if(typeof r.warp_data=="string"){c(!0),fetch(r.warp_data).then(m=>m.ok?m.json():null).then(m=>{u===p.current&&l(m)}).catch(()=>{u===p.current&&l(null)}).finally(()=>{u===p.current&&c(!1)});return}}l(null),c(!1)},[e,n,o,r,s]),{warpData:a,loading:d}}function Rg(e,n,o){const[r,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,o)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?sc(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,o]),r}const Os={padding:24,color:i("desc-fg"),fontSize:14};function Hs({title:e,label:n,className:o,style:r}){const s=(a,l=14,d=14)=>({width:a,height:l,marginTop:d,borderRadius:3,background:i("rule")});return t.jsxs("div",{className:o,style:{...r,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[e&&t.jsx("div",{style:{fontSize:15,color:i("ink"),fontFamily:i("font-ui")},children:e}),t.jsx("div",{style:s("42%",24,28)}),t.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((a,l)=>t.jsx("div",{style:s(a,16,l===0?30:14)},l)),t.jsx("p",{role:"status",style:{marginTop:24,color:i("desc-fg"),fontSize:14,fontFamily:i("font-ui")},children:n})]})}const Fs=/^https?:\/\//i;function Eg(e){if(!e||typeof e!="object")return null;const n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,o=n(e.url),r=n(e.license_url),s={name:n(e.name),url:o&&Fs.test(o)?o:void 0,license:n(e.license),license_url:r&&Fs.test(r)?r:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Ig(e,n){return{work_id:n.work_id??e,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 Lg(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(o=>o.vol_label)?"冊":(e==null?void 0:e.kind)==="collated"?"卷":"章"}function fc(e,n,o,r=!1){const s=o(`${n}${e.n}`);if(!e.title)return s;const a=o(e.title);return r&&!/^[卷冊册章篇回第]/.test(e.title)?`${s} ${a}`:a}function Ag(e,n,o,r,s){var p;const a=new Map(e.chapters.map(u=>[u.file,u])),l=u=>u==="loading"?"…":typeof u=="number"&&u>0?u:void 0,d=(u,m)=>{const h=a.get(u);return{key:u,label:m??(h?fc(h,o,r,s):u),hint:l(n[u]),disabled:n[u]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(u=>{var m;return u.files.some(h=>a.has(h))||((m=u.children)==null?void 0:m.length)});if(c&&c.length>0){const u=(m,h)=>{var x;if(m.files.length===1&&!((x=m.children)!=null&&x.length))return d(m.files[0],r(m.label));const f=Hh(m,n);return{key:`group:${h}`,label:r(m.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:oc(m),defaultExpanded:typeof f=="number"&&f>0,children:[...m.files.filter(k=>a.has(k)).map(k=>d(k)),...(m.children??[]).map((k,y)=>u(k,`${h}.${y}`))]}};return c.map((m,h)=>u(m,`${h}`))}return e.chapters.map(u=>d(u.file))}const wr=({id:e,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:a,title:l,subtitle:d,resolveImages:c,renderImageOverlay:p,imagePanel:u,allowVertical:m,onReportError:h,revisedAt:f,backHref:x,backLabel:k,resolveWarpData:y,warpData:w,resolveEntities:b,onEntityNavigate:j,className:S,style:v})=>{var Dr,Ur,Vr;const{t:$,convert:_}=J(),C=g.useMemo(()=>ul(n),[n]),[M,N]=vl(),T=Ze(),F=g.useRef(s);F.current=s;const[R,E]=g.useState(null),[L,I]=g.useState("loading");g.useEffect(()=>{let W=!1;return E(null),I("loading"),C.getManifest(e).then(pe=>{W||(pe?(E(pe),I("ready")):I("missing"))}).catch(()=>{W||I("missing")}),()=>{W=!0}},[C,e]);const P=o!==void 0,V=r!==void 0,[X,D]=g.useState(null),[O,A]=g.useState(null);g.useEffect(()=>{D(null),A(null)},[e]);const G=_e.pickTextVersion(R,P?o:X),se=((Dr=R==null?void 0:R.versions.find(W=>W.key==="default"))==null?void 0:Dr.key)??((Ur=R==null?void 0:R.versions[0])==null?void 0:Ur.key)??"default",Q=(G==null?void 0:G.key)??null,ve=V?r:O,ne=g.useCallback((W,pe,Le)=>{var Fe;(Fe=F.current)==null||Fe.call(F,{key:W,chapter:pe,isDefault:W===se},Le)},[se]);g.useEffect(()=>{!R||!P||o==null||R.versions.some(W=>W.key===o)||ne(se,null,"auto")},[R,P,o,se,ne]);const ce=g.useRef(new Map);g.useEffect(()=>{ce.current.clear()},[C,e]);const We=g.useCallback(async W=>{const pe=`${e}
|
|
1296
|
-
${W}`;if(
|
|
1297
|
-
${Q}`:null,oe=
|
|
1298
|
-
${Q}`;return Pe(null),Z("loading"),We(Q).then(
|
|
1295
|
+
`,ug=120;function dt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function mg(e,n=ug){if(!e)return;const o=e.replace(/\s+/g," ").trim(),r=Array.from(o);return r.length>n?r.slice(0,n).join("")+"…":o}function hg(e){const n=typeof e.birth_year=="number"?e.birth_year:void 0,o=typeof e.death_year=="number"?e.death_year:void 0;if(!(n===void 0&&o===void 0))return`${n??"?"}–${o??"?"}`}function gg(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(o=>{if(!o||typeof o!="object")return"";const r=o,s=dt(r.name);return s?[dt(r.dynasty)&&`〔${dt(r.dynasty)}〕`,s,dt(r.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function dc(e,n){const o=dt(n.type),r=dt(n.primary_name)??dt(n.title)??e,s=o==="entity"?[dt(n.dynasty),hg(n),dt(n.native_place)].filter(Boolean).join(" · "):[gg(n),dt(n.edition),dt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?dt(n.description.text):dt(n.description);return{id:e,type:o,title:r,meta:s||void 0,description:mg(a)}}function pc(e){const n=[e.dynasty,e.author,e.edition].filter(Boolean).join(" · ");return{id:e.id,type:e.type,title:e.title,meta:n||void 0}}function uc(e){return async n=>{const o=await e.getItem(n);if(o)return dc(n,o);if(e.getEntry){const r=await e.getEntry(n);if(r)return pc(r)}return null}}const Ws=new WeakMap;function fg(e,n,o){let r=Ws.get(e);r||(r=new Map,Ws.set(e,r));const s=r.get(o);if(s)return s;const a=n(o);return r.set(o,a),a.catch(()=>r.delete(o)),a}const mc=e=>`/item/${encodeURIComponent(e)}`,xg={work:"書名",person:"人名",place:"地名",office:"官職",dynasty:"朝代",other:"專名"},bg=typeof window>"u"?g.useEffect:g.useLayoutEffect;function yr(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:uc(e)}:null,[n,e])}const yg=e=>e,jg=({text:e,entities:n,offsets:o="text",plainBase:r=0,transport:s,loadSummary:a,buildHref:l=mc,onNavigate:d,renderText:c=yg,hoverDelayMs:p=250,injectStyles:u=!0,className:m})=>{const h=g.useMemo(()=>{const x=o==="plain"?lc(e,n,r):n;return cc(e,x)},[e,n,o,r]),f=yr(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:br}),h.map(x=>x.type==="text"?t.jsx(g.Fragment,{children:c(x.text)},`t${x.start}`):t.jsx(jr,{span:x.span,label:x.text,hasBrackets:e[x.start-1]==="《"&&e[x.start+x.text.length]==="》",loader:f,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p},`${x.span.key}@${x.start}`))]})},jr=({span:e,label:n,hasBrackets:o,loader:r,buildHref:s,onNavigate:a,renderText:l,hoverDelayMs:d})=>{const c=g.useId(),[p,u]=g.useState(!1),m=g.useRef(null),h=`bim-et bim-et-${e.kind}`,f=e.kind==="work"&&!o,x=t.jsxs(t.Fragment,{children:[f&&t.jsx("span",{className:"bim-et-sr",children:"《"}),l(n),f&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),k=()=>{m.current&&(clearTimeout(m.current),m.current=null)};g.useEffect(()=>k,[]);const y=g.useCallback(j=>{k(),j<=0?u(!0):m.current=setTimeout(()=>u(!0),j)},[]),w=g.useCallback(()=>{k(),u(!1)},[]);if(!e.targetId)return t.jsx("span",{className:h,children:x});const b=e.targetId;return t.jsxs("span",{className:"bim-et-w",onMouseEnter:()=>y(d),onMouseLeave:w,onKeyDown:j=>{j.key==="Escape"&&p&&(j.stopPropagation(),w())},children:[t.jsx("a",{className:h,href:s(b),"data-entity-id":b,"aria-describedby":p?c:void 0,onFocus:()=>y(0),onBlur:w,onClick:a?j=>a(b,j):void 0,children:x}),p&&t.jsx(vg,{id:c,entityId:b,span:e,loader:r})]})},vg=({id:e,entityId:n,span:o,loader:r})=>{const{convert:s}=J(),a=g.useRef(null),[l,d]=g.useState("start"),[c,p]=g.useState(r?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!r)return;let h=!1;return p({status:"loading"}),fg(r.owner,r.load,n).then(f=>{h||p({status:"ready",summary:f})}).catch(()=>{h||p({status:"error"})}),()=>{h=!0}},[r,n]),bg(()=>{const h=a.current;if(!h||typeof window>"u")return;const f=h.getBoundingClientRect(),x=document.documentElement.clientWidth||window.innerWidth;f.right>x-8&&l==="start"&&d("end")},[c,l]);const u=c.status==="ready"?c.summary:null,m=(u==null?void 0:u.title)??o.canonicalName??o.text;return t.jsxs("span",{ref:a,id:e,role:"tooltip",className:"bim-et-card","data-align":l,children:[t.jsx("span",{className:"bim-et-card-k",children:s(xg[o.kind])}),m&&t.jsx("span",{className:"bim-et-card-t",children:s(m)}),(u==null?void 0:u.meta)&&t.jsx("span",{className:"bim-et-card-m",children:s(u.meta)}),(u==null?void 0:u.description)&&t.jsx("span",{className:"bim-et-card-d",children:s(u.description)}),c.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:s("載入中…")}),c.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:s("摘要載入失敗")})]})},kg=e=>`/item/${encodeURIComponent(e)}`;function wg(e){const n=e.filter(o=>o.kind!=="break");return{before:n.filter(o=>o.pos==="before"),after:n.filter(o=>o.pos!=="before")}}function Sg(e,n){const o=[];for(const r of e){const s=n.get(r.charData.id)??null,a=o[o.length-1];a&&a.entity===s?a.chars.push(r):o.push({entity:s,chars:[r]})}return o}const vr=({pageData:e,pages:n,punctuations:o=$g,selectedCharIds:r,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:u,convert:m,scrollToPage:h,entities:f,entityTransport:x,loadEntitySummary:k,buildEntityHref:y,onEntityNavigate:w})=>{const b=g.useRef(null),j=g.useRef(0),S=g.useMemo(()=>{const I=new Map;return p&&o.forEach((P,V)=>{const X=P.id?P:{...P,id:`${P.anchor}#${V}`},D=I.get(X.anchor)||[];D.push(X),I.set(X.anchor,D)}),I},[o,p]),v=g.useMemo(()=>(n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}]).filter(P=>P.columns.some(V=>V.chars.length>0)).map(P=>{const V=[...P.columns].sort((O,A)=>O.col-A.col),X=[];let D=[];for(const O of V)for(const A of O.chars){const{before:G,after:se}=wg(S.get(A.id)||[]),Q=(S.get(A.id)||[]).some(ke=>ke.kind==="break");D.push({charData:A,col:O.col,beforePuncts:G,afterPuncts:se}),Q&&(X.push({id:`para-p${P.page}-${X.length}`,chars:D}),D=[])}return D.length>0&&X.push({id:`para-p${P.page}-${X.length}`,chars:D}),{page:P.page,paragraphs:X}}),[n,e,S]),$=g.useMemo(()=>{const I=[];for(const P of v)for(const V of P.paragraphs)for(const X of V.chars)I.push(X.charData.id);return I},[v]),_=g.useMemo(()=>{const I=new Map;if(!f||f.length===0)return I;const P=new Map($.map((V,X)=>[V,X]));for(const V of f){if(!V.anchor)continue;const X=P.get(V.anchor.start),D=P.get(V.anchor.end);if(!(X===void 0||D===void 0||D<X))for(let O=X;O<=D;O++)I.has($[O])||I.set($[O],V)}return I},[f,$]),C=yr(x,k),M=_.size>0,N=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:w});N.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:w};const T=g.useMemo(()=>({click:I=>{var P,V;j.current=Date.now()+1200,(V=(P=N.current).onCharClick)==null||V.call(P,I)},enter:I=>{var P,V;return(V=(P=N.current).onCharHover)==null?void 0:V.call(P,I)},leave:()=>{var I,P;return(P=(I=N.current).onCharHover)==null?void 0:P.call(I,null)},navigate:(I,P)=>{var X,D;if(!(P.detail===0||P.ctrlKey||P.metaKey||P.shiftKey)){P.preventDefault();return}(D=(X=N.current).onEntityNavigate)==null||D.call(X,I,P)}}),[]),F=Cg(r),R=g.useRef(null);g.useEffect(()=>{var P,V;if((P=R.current)==null||P.classList.remove("is-hovered"),R.current=null,!s)return;const I=(V=b.current)==null?void 0:V.querySelector(`span[data-char-id="${s}"]`);I&&(I.classList.add("is-hovered"),R.current=I)},[s]),g.useEffect(()=>{let I=null;const P=()=>{var we,Pe;I=null;const X=window.getSelection(),D=b.current;if(!X||X.isCollapsed||X.rangeCount===0||!D)return;const O=X.getRangeAt(0),A=O.commonAncestorContainer,G=A.nodeType===3?A.parentElement:A;if(!G||!D.contains(G))return;const se=D.querySelectorAll("span[data-char-id]");let Q=0,ke=se.length;for(;Q<ke;){const Ee=Q+ke>>1;O.comparePoint(se[Ee],0)<0?Q=Ee+1:ke=Ee}const ne=Q;for(ke=se.length;Q<ke;){const Ee=Q+ke>>1;O.comparePoint(se[Ee],0)<=0?Q=Ee+1:ke=Ee}const de=Q-1;if(de<ne)return;const We=[];for(let Ee=ne;Ee<=de;Ee++)We.push(se[Ee].getAttribute("data-char-id"));We.length>0&&(j.current=Date.now()+1200,(Pe=(we=N.current).onSelectionChange)==null||Pe.call(we,We))},V=()=>{I&&clearTimeout(I),I=setTimeout(P,120)};return document.addEventListener("selectionchange",V),()=>{document.removeEventListener("selectionchange",V),I&&clearTimeout(I)}},[]),g.useEffect(()=>{var I;if(r.size===1){const P=Array.from(r)[0],V=(I=b.current)==null?void 0:I.querySelector(`span[data-char-id="${P}"]`);V&&V.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[r]);const E=h==null?void 0:h.nonce;g.useEffect(()=>{var P;if(!h)return;const I=(P=b.current)==null?void 0:P.querySelector(`[data-page-section="${h.page}"]`);I&&(j.current=Date.now()+800,I.scrollIntoView({behavior:"auto",block:"start"}))},[E]);const L=!!u;return g.useEffect(()=>{var O;if(!L)return;const I=Array.from(((O=b.current)==null?void 0:O.querySelectorAll("[data-page-section]"))??[]);if(I.length===0)return;const P=120;let V=0;const X=()=>{var Q,ke;if(V=0,Date.now()<j.current)return;let A=0,G=I.length-1;for(;A<G;){const ne=A+G+1>>1;I[ne].getBoundingClientRect().top<=P?A=ne:G=ne-1}const se=parseInt(I[A].getAttribute("data-page-section")||"",10);isNaN(se)||(ke=(Q=N.current).onVisiblePageChange)==null||ke.call(Q,se)},D=()=>{V||(V=requestAnimationFrame(X))};return window.addEventListener("scroll",D,{passive:!0}),X(),()=>{window.removeEventListener("scroll",D),V&&cancelAnimationFrame(V)}},[L,v]),t.jsxs("div",{ref:b,className:"guji-text-pane-content",children:[M&&t.jsx("style",{children:br}),t.jsx("div",{className:"guji-text-reflow-view",children:v.map((I,P)=>t.jsx(Tg,{pGroup:I,first:P===0,selected:F.get(I.page)??_g,entityOfChar:_,entityLoader:C,convert:m,buildHref:y??kg,handlers:T},`page-sec-${I.page}`))})]})},_g=new Set,$g=[];function Cg(e){const n=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(s=>{const a=parseInt(s.split(":")[0],10);let l=o.get(a);l||o.set(a,l=new Set),l.add(s)});const r=new Map;return o.forEach((s,a)=>{const l=n.current.get(a),d=l&&l.size===s.size&&Array.from(s).every(c=>l.has(c));r.set(a,d?l:s)}),n.current=r,r},[e])}function zg(e,n){const o=Array.from(n(e.join("")));return o.length===e.length&&e.every(r=>Array.from(r).length===1)?o:e.map(r=>n(r))}const Tg=g.memo(function({pGroup:n,first:o,selected:r,entityOfChar:s,entityLoader:a,convert:l,buildHref:d,handlers:c}){const p=g.useMemo(()=>{const m=new Map;if(!l)return m;for(const h of n.paragraphs){const f=zg(h.chars.map(x=>x.charData.char),l);h.chars.forEach((x,k)=>m.set(x.charData.id,f[k]))}return m},[n,l]),u=m=>p.get(m.id)??m.char;return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96},children:[!o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:i("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},children:["第 ",n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}})]}),n.paragraphs.map(m=>t.jsx("p",{className:"guji-reflow-paragraph",children:Sg(m.chars,s).map((h,f)=>{const x=h.chars.map(({charData:w,col:b,beforePuncts:j,afterPuncts:S},v)=>{const $=!!h.entity&&v===0,_=!!h.entity&&v===h.chars.length-1,C=$?[]:j,M=_?[]:S;return t.jsxs(g.Fragment,{children:[C.map(N=>t.jsx("span",{className:"guji-text-punct","data-punct-id":N.id,children:N.mark},N.id)),t.jsx("span",{"data-char-id":w.id,onClick:()=>c.click(w.id),onMouseEnter:()=>c.enter(w.id),onMouseLeave:c.leave,className:`guji-text-char${r.has(w.id)?" is-selected":""}${w.sub?" is-sub":""}`,title:`[第${n.page}葉·第${b}列·第${w.slot||w.pos}字] ${u(w)}`,children:u(w)}),M.map(N=>t.jsx("span",{className:"guji-text-punct","data-punct-id":N.id,children:N.mark},N.id))]},w.id)});if(!h.entity)return t.jsx(g.Fragment,{children:x},`r${f}`);const k=h.chars[0].beforePuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id)),y=h.chars[h.chars.length-1].afterPuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id));return t.jsxs(g.Fragment,{children:[k,t.jsx(jr,{span:h.entity,label:h.chars.map(w=>u(w.charData)).join(""),hasBrackets:!0,loader:a,buildHref:d,onNavigate:c.navigate,renderText:()=>x,hoverDelayMs:250}),y]},`${h.entity.key}@${f}`)})},m.id))]})}),hc=1,gc=6,ei={s:1,x:0,y:0},ri=(e,n,o)=>Math.min(o,Math.max(n,e));function kr(e,n,o){const r=ri(e.s,hc,gc);return{s:r,x:ri(e.x,n*(1-r),0),y:ri(e.y,o*(1-r),0)}}function Qi(e,n,o,r,s,a){const l=ri(e.s*r,hc,gc),d=l/e.s;return kr({s:l,x:n-(n-e.x)*d,y:o-(o-e.y)*d},s,a)}function Ng(e,n,o,r,s){return kr({s:e.s,x:e.x+n,y:e.y+o},r,s)}function Rg(e,n,o){const r=n===1?e*16:n===2?e*400:e;return Math.exp(-r*(o?.01:.0015))}const Os=4,Eg=g.forwardRef(function({children:n,onScaleChange:o,resetKey:r,style:s},a){const l=g.useRef(null),[d,c]=g.useState(ei),p=g.useRef(d),u=g.useRef(o);u.current=o;const m=b=>{var S;const j=p.current;p.current=b,c(b),b.s!==j.s&&((S=u.current)==null||S.call(u,b.s))},h=()=>{var j;const b=(j=l.current)==null?void 0:j.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w:j,h:S}=h();m(Qi(p.current,j/2,S/2,b,j,S))},reset(){m(ei)}})),g.useEffect(()=>{m(ei)},[r]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{const{w:S,h:v}=h(),$=kr(p.current,S,v);($.x!==p.current.x||$.y!==p.current.y)&&m($)});return j.observe(b),()=>j.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const j=S=>{const v=Rg(S.deltaY,S.deltaMode,S.ctrlKey);if(p.current.s<=1&&v<1)return;S.preventDefault();const{w:$,h:_,left:C,top:M}=h();m(Qi(p.current,S.clientX-C,S.clientY-M,v,$,_))};return b.addEventListener("wheel",j,{passive:!1}),()=>b.removeEventListener("wheel",j)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),k=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const j=x.current;if(j.swallowClick=!1,f.current.size===1&&(j.moved=0,j.dragging=!1),f.current.size===2){const[S,v]=[...f.current.values()];j.pinchDist=Math.hypot(S.x-v.x,S.y-v.y),j.moved=Os+1}},y=b=>{var F;const j=f.current.get(b.pointerId);if(!j)return;const S={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,S);const v=x.current,{w:$,h:_,left:C,top:M}=h();if(f.current.size>=2){const[R,E]=[...f.current.values()],L=Math.hypot(R.x-E.x,R.y-E.y);if(v.pinchDist>0&&L>0){const I=(R.x+E.x)/2-C,P=(R.y+E.y)/2-M;m(Qi(p.current,I,P,L/v.pinchDist,$,_))}v.pinchDist=L,v.swallowClick=!0;return}const N=S.x-j.x,T=S.y-j.y;if(v.moved+=Math.abs(N)+Math.abs(T),!(v.moved<=Os)){if(!v.dragging){v.dragging=!0;try{(F=l.current)==null||F.setPointerCapture(b.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&m(Ng(p.current,N,T,$,_))}},w=b=>{f.current.delete(b.pointerId);const j=x.current;j.pinchDist=0,f.current.size===0&&(j.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:k,onPointerMove:y,onPointerUp:w,onPointerCancel:w,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>m(ei),style:{position:"relative",overflow:"hidden",touchAction:"none",cursor:d.s>1?"grab":void 0,...s},children:t.jsx("div",{className:"bim-zp-inner",style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transformOrigin:"0 0",transform:`translate(${d.x}px, ${d.y}px) scale(${d.s})`,willChange:d.s>1?"transform":void 0},children:n})})});function fc(e,n,o,r,s){const[a,l]=g.useState(n??null),[d,c]=g.useState(!1),p=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){l(n);return}const u=++p.current;if(!o){l(null),c(!1);return}if(e){let m;try{m=e(o,s)}catch{l(null),c(!1);return}if(!m||typeof m.then!="function"){l(m??null),c(!1);return}c(!0),m.then(h=>{u===p.current&&l(h??null)}).catch(()=>{u===p.current&&l(null)}).finally(()=>{u===p.current&&c(!1)});return}if(r!=null&&r.warp_data){if(typeof r.warp_data=="object"){l(r.warp_data);return}if(typeof r.warp_data=="string"){c(!0),fetch(r.warp_data).then(m=>m.ok?m.json():null).then(m=>{u===p.current&&l(m)}).catch(()=>{u===p.current&&l(null)}).finally(()=>{u===p.current&&c(!1)});return}}l(null),c(!1)},[e,n,o,r,s]),{warpData:a,loading:d}}function Ig(e,n,o){const[r,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,o)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?ac(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,o]),r}const Hs={padding:24,color:i("desc-fg"),fontSize:14};function Fs({title:e,label:n,className:o,style:r}){const s=(a,l=14,d=14)=>({width:a,height:l,marginTop:d,borderRadius:3,background:i("rule")});return t.jsxs("div",{className:o,style:{...r,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[e&&t.jsx("div",{style:{fontSize:15,color:i("ink"),fontFamily:i("font-ui")},children:e}),t.jsx("div",{style:s("42%",24,28)}),t.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((a,l)=>t.jsx("div",{style:s(a,16,l===0?30:14)},l)),t.jsx("p",{role:"status",style:{marginTop:24,color:i("desc-fg"),fontSize:14,fontFamily:i("font-ui")},children:n})]})}const Ds=/^https?:\/\//i;function Lg(e){if(!e||typeof e!="object")return null;const n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,o=n(e.url),r=n(e.license_url),s={name:n(e.name),url:o&&Ds.test(o)?o:void 0,license:n(e.license),license_url:r&&Ds.test(r)?r:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Ag(e,n){return{work_id:n.work_id??e,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 Pg(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(o=>o.vol_label)?"冊":(e==null?void 0:e.kind)==="collated"?"卷":"章"}function xc(e,n,o,r=!1){const s=o(`${n}${e.n}`);if(!e.title)return s;const a=o(e.title);return r&&!/^[卷冊册章篇回第]/.test(e.title)?`${s} ${a}`:a}function Mg(e,n,o,r,s){var p;const a=new Map(e.chapters.map(u=>[u.file,u])),l=u=>u==="loading"?"…":typeof u=="number"&&u>0?u:void 0,d=(u,m)=>{const h=a.get(u);return{key:u,label:m??(h?xc(h,o,r,s):u),hint:l(n[u]),disabled:n[u]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(u=>{var m;return u.files.some(h=>a.has(h))||((m=u.children)==null?void 0:m.length)});if(c&&c.length>0){const u=(m,h)=>{var x;if(m.files.length===1&&!((x=m.children)!=null&&x.length))return d(m.files[0],r(m.label));const f=Dh(m,n);return{key:`group:${h}`,label:r(m.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:rc(m),defaultExpanded:typeof f=="number"&&f>0,children:[...m.files.filter(k=>a.has(k)).map(k=>d(k)),...(m.children??[]).map((k,y)=>u(k,`${h}.${y}`))]}};return c.map((m,h)=>u(m,`${h}`))}return e.chapters.map(u=>d(u.file))}const wr=({id:e,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:a,title:l,subtitle:d,resolveImages:c,renderImageOverlay:p,imagePanel:u,allowVertical:m,onReportError:h,revisedAt:f,backHref:x,backLabel:k,resolveWarpData:y,warpData:w,resolveEntities:b,onEntityNavigate:j,className:S,style:v})=>{var Ur,Vr,Gr;const{t:$,convert:_}=J(),C=g.useMemo(()=>ml(n),[n]),[M,N]=kl(),T=Ze(),F=g.useRef(s);F.current=s;const[R,E]=g.useState(null),[L,I]=g.useState("loading");g.useEffect(()=>{let W=!1;return E(null),I("loading"),C.getManifest(e).then(ue=>{W||(ue?(E(ue),I("ready")):I("missing"))}).catch(()=>{W||I("missing")}),()=>{W=!0}},[C,e]);const P=o!==void 0,V=r!==void 0,[X,D]=g.useState(null),[O,A]=g.useState(null);g.useEffect(()=>{D(null),A(null)},[e]);const G=_e.pickTextVersion(R,P?o:X),se=((Ur=R==null?void 0:R.versions.find(W=>W.key==="default"))==null?void 0:Ur.key)??((Vr=R==null?void 0:R.versions[0])==null?void 0:Vr.key)??"default",Q=(G==null?void 0:G.key)??null,ke=V?r:O,ne=g.useCallback((W,ue,Ie)=>{var Fe;(Fe=F.current)==null||Fe.call(F,{key:W,chapter:ue,isDefault:W===se},Ie)},[se]);g.useEffect(()=>{!R||!P||o==null||R.versions.some(W=>W.key===o)||ne(se,null,"auto")},[R,P,o,se,ne]);const de=g.useRef(new Map);g.useEffect(()=>{de.current.clear()},[C,e]);const We=g.useCallback(async W=>{const ue=`${e}
|
|
1296
|
+
${W}`;if(de.current.has(ue))return de.current.get(ue)??null;const Ie=await C.getIndex(e,W).catch(()=>null);return Ie&&de.current.set(ue,Ie),Ie},[C,e]),[we,Pe]=g.useState(null),[Ee,Z]=g.useState("loading"),ae=Q?`${e}
|
|
1297
|
+
${Q}`:null,oe=we&&we.owner===ae?we.idx:null;g.useEffect(()=>{if(!Q)return;let W=!1;const ue=`${e}
|
|
1298
|
+
${Q}`;return Pe(null),Z("loading"),We(Q).then(Ie=>{W||(Ie&&Ie.chapters.length>0?(Pe({owner:ue,idx:Ie}),Z("ready")):Z("failed"))}),()=>{W=!0}},[e,Q,We]),g.useEffect(()=>{if(!oe||!Q||ke!=null&&oe.chapters.some(Ie=>Ie.file===ke))return;const ue=oe.chapters[0].file;V||A(ue),ne(Q,ue,"auto")},[oe,Q,ke,V,ne]);const fe=oe?ke!=null&&oe.chapters.some(W=>W.file===ke)?ke:oe.chapters[0].file:ke,U=g.useMemo(()=>oe&&fe?oe.chapters.find(W=>W.file===fe)??null:null,[oe,fe]),$e=g.useRef(0),me=g.useCallback(async W=>{if(!R||W===Q||!R.versions.some(ot=>ot.key===W))return;const ue=++$e.current,Ie=await We(W);if(ue!==$e.current)return;const Fe=U??(fe?{file:fe}:null),qe=_e.matchChapterAcrossVersions(Fe,Ie);P||D(W),V||A(qe),ne(W,qe,"version")},[R,Q,We,U,fe,P,V,ne]),Ce=g.useCallback(W=>{Q&&(V||A(W),ne(Q,W,"chapter"))},[Q,V,ne]),[Y,ze]=g.useState(null),Me=Q&&U?`${e}
|
|
1299
1299
|
${Q}
|
|
1300
|
-
${U.file}`:null,[B,te]=g.useState(null),xe=Me!==null&&B!==Me,Re=g.useRef(0);g.useEffect(()=>{if(!Q||!U)return;const W=++Re.current,
|
|
1300
|
+
${U.file}`:null,[B,te]=g.useState(null),xe=Me!==null&&B!==Me,Re=g.useRef(0);g.useEffect(()=>{if(!Q||!U)return;const W=++Re.current,ue=`${e}
|
|
1301
1301
|
${Q}
|
|
1302
|
-
${U.file}`;ze(null),C.getChapter(e,Q,U.file,{json:!!U.has_json}).then(
|
|
1303
|
-
${Q??""}`,load:
|
|
1302
|
+
${U.file}`;ze(null),C.getChapter(e,Q,U.file,{json:!!U.has_json}).then(Ie=>{W===Re.current&&ze(Ie)}).catch(()=>{W===Re.current&&ze(null)}).finally(()=>{W===Re.current&&te(ue)})},[C,e,Q,U]);const H=(G==null?void 0:G.kind)==="collated",[pe,ee]=g.useState("");g.useEffect(()=>{ee("")},[e,Q]);const be=g.useMemo(()=>Q&&H?async W=>{const ue=await C.getChapter(e,Q,W,{json:!0});return{juan:(ue==null?void 0:ue.json)??null,rawText:(ue==null?void 0:ue.md)??null}}:null,[C,e,Q,H]),Se=(oe==null?void 0:oe.type)==="kaozhen",Be=g.useMemo(()=>(oe==null?void 0:oe.chapters.map(W=>W.file))??[],[oe]),{matchStates:De}=ng({resetKey:`${e}
|
|
1303
|
+
${Q??""}`,load:be,files:Be,activeFile:fe??null,activeJuan:(Y==null?void 0:Y.json)??null,activeRawText:(Y==null?void 0:Y.md)??null,query:pe,isKaozhen:Se}),Je=g.useRef(new Map);g.useEffect(()=>{Je.current.clear()},[e]);const He=g.useMemo(()=>({versionKey:Q,chapter:U??null}),[Q,U]),Ue=Nh(c,fe??null,He),{warpData:z,loading:ie}=fc(y,w,fe??null,U,He),re=Ig(b,fe??null,He),je=M.properNames??re.length>0,ye=g.useMemo(()=>({...M,properNames:je}),[M,je]),[he,Ne]=g.useState(new Set),[K,ge]=g.useState(null),[Ae,q]=g.useState(!0),[le,ce]=g.useState(!0),ve=g.useRef(null),[Ve,Oe]=g.useState(1),[ht,Wt]=g.useState(null),xn=W=>{var Ie;const ue=parseInt(((Ie=W==null?void 0:W.page_id)==null?void 0:Ie.split(":")[1])??"",10);return isNaN(ue)?null:ue},bn=W=>{var Ie,Fe;const ue=(W==null?void 0:W.pages)??[];return xn(W)??((Ie=ue.find(qe=>qe.columns.some(ot=>ot.chars.length>0)))==null?void 0:Ie.page)??((Fe=ue[0])==null?void 0:Fe.page)??1},[Ge,Rt]=g.useState(()=>bn(z)),Ot=`${e}
|
|
1304
1304
|
${Q}
|
|
1305
|
-
${he??""}`,[Qt,xn]=g.useState({key:Ot,data:z,started:!!z});if(Qt.key!==Ot)xn({key:Ot,data:z,started:!1});else if(z!==Qt.data&&(xn({key:Ot,data:z,started:!!z}),z)){const W=z.pages??[];(!Qt.started||!W.some(pe=>pe.page===Ge))&&Et(Rt(z))}g.useEffect(()=>{je(new Set),Ie(null)},[he,Q]);const Un=g.useCallback(W=>{if(je(new Set(W)),W.length>0){const pe=W[0],Le=parseInt(pe.split(":")[0],10);isNaN(Le)||Et(Le)}},[]),It=g.useMemo(()=>{const W=new Map;for(const pe of(z==null?void 0:z.pages)??[])W.set(pe.page,pe);return W},[z]),bn=lt(z),Vn=g.useCallback(W=>{var Fe;const pe=Ue.images;if(!pe||pe.length===0)return;const Le=(Fe=It.get(W))==null?void 0:Fe.seq;return(Le?pe.find(qe=>qe.seq===Le):void 0)??pe.find(qe=>qe.pageNo===W)??pe[W-1]},[Ue.images,It]),Br=re>1.5,Gn=g.useCallback((W,pe=!1)=>{const Le=Vn(W);return Le?W===bn||pe?Le.hiresUrl??Le.url:Le.url:W===bn?(z==null?void 0:z.imageUrl)??"":""},[Vn,z,bn]),Wd=g.useMemo(()=>Gn(Ge,Br),[Gn,Ge,Br]),yn=g.useMemo(()=>[...It.keys()].sort((W,pe)=>W-pe),[It]),Pi=g.useRef(Ge);Pi.current=Ge;const jn=g.useCallback(W=>{var qe;const pe=Pi.current,Le=yn.indexOf(pe),Fe=yn[Le<0?0:Le+W];Fe===void 0||Fe===pe||(Pi.current=Fe,Et(Fe),(qe=It.get(Fe))!=null&&qe.columns.some(ot=>ot.chars.length>0)&&Oe(ot=>({page:Fe,nonce:((ot==null?void 0:ot.nonce)??0)+1})))},[yn,It]),Mi=yn.indexOf(Ge),Od=g.useCallback(W=>{if(W.altKey||W.ctrlKey||W.metaKey)return;const pe=W.target.tagName;pe==="INPUT"||pe==="TEXTAREA"||pe==="SELECT"||(W.key==="ArrowLeft"||W.key==="PageUp"?(W.preventDefault(),jn(-1)):(W.key==="ArrowRight"||W.key==="PageDown")&&(W.preventDefault(),jn(1)))},[jn]);g.useEffect(()=>{if(z)for(const W of[1,-1,2,3]){const pe=Gn(Ge+W);pe&&So(pe)}},[z,Ge,Gn]);const Wr=g.useMemo(()=>{var qr;if(!z)return null;if(Ge===bn)return z;const W=It.get(Ge);if(W&&W.width>0&&W.height>0)return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[W.width,W.height],total_warped_w:W.width,columns:[{col:1,warped_w:W.width,warped_h:W.height,offset_x:0,strips:[],chars:W.columns.flatMap(Ke=>Ke.chars).map(Ke=>({id:Ke.id,char:Ke.char,slot:Ke.slot,pos:Ke.pos,sub:Ke.sub,bbox_col:Ke.bbox??[0,0,0,0]}))}]};const pe=(qr=z.pages)==null?void 0:qr.find(Ke=>Ke.page===Ge),[Le,Fe]=z.image_size||[2386,3082],qe=Vn(Ge),ot=(qe==null?void 0:qe.width)??Le,Fi=(qe==null?void 0:qe.height)??Fe,Gr=ot/Le,Yr=Fi/Fe,Kr=new Map;for(const Ke of z.columns){const dt=(Ke.strips||[]).flatMap(qn=>qn.srcQuad.map(Xn=>Xn[0]));if(dt.length===0)continue;const St=Ke.top_y??0,Di=Ke.bottom_y??St+Ke.warped_h;Kr.set(Ke.col,{x0:Math.min(...dt),x1:Math.max(...dt),top:St,slotH:(Di-St)/21})}return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[ot,Fi],total_warped_w:ot,columns:pe?pe.columns.map(Ke=>{const dt=Kr.get(Ke.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ke.col,warped_w:ot,warped_h:Fi,offset_x:0,strips:[],chars:Ke.chars.map(St=>{const Di=St.slot??St.pos??0,qn=(dt.top+(Di-1)*dt.slotH)*Yr,Xn=(dt.x0+dt.x1)/2,[Kd,qd]=St.sub==="a"?[Xn,dt.x1]:St.sub==="b"?[dt.x0,Xn]:[dt.x0,dt.x1];return{...St,bbox_col:[Kd*Gr,qn,qd*Gr,qn+dt.slotH*Yr]}})}}):[]}},[z,Ge,bn,It,Vn]),{entryTitle:Yn,authors:Or}=Bg(e,n,l===void 0),[Hr,Bi]=g.useState("text");if(g.useEffect(()=>{Bi("text")},[he,Q]),L==="loading")return t.jsx(Hs,{className:S,style:v,title:l??Yn,label:$("reader.loading")});if(L==="missing"||!R||!G)return t.jsx("div",{className:S,style:{...v,...Os},children:$("reader.noText")});if(Ee==="failed")return t.jsx("div",{className:S,style:{...v,...Os},children:$("reader.tocFailed")});if(!oe)return t.jsx(Hs,{className:S,style:v,title:l??Yn,label:$("reader.tocLoading")});const Ht=Lg(G,oe),Hd=Ag(oe,De,Ht,_,H),Wi=R.versions.map(W=>({key:W.key,label:_e.textVersionLabel(W),optionLabel:_(_e.textVersionLabel(W)),sourceName:W.source_name?_(W.source_name):void 0,license:W.license??void 0,sourceUrl:W.source_url??void 0,primary:W.key===se})),ct=Eg((Vr=oe.source)==null?void 0:Vr.upstream),Kn=(typeof l=="string"?_(l):l)??(oe.title?_(oe.title):Yn?_(Yn):void 0),Fd=Kn?t.jsx("a",{href:T(e),title:$("reader.viewEntry"),onClick:a?W=>{W.metaKey||W.ctrlKey||(W.preventDefault(),a(e))}:void 0,children:Kn}):void 0,Dd=Or.length>0?_(Or.slice(0,2).map(W=>`${W.dynasty?`〔${W.dynasty}〕`:""}${W.name}${` ${W.role||$("reader.defaultRole")}`}`).join("、")):void 0,Oi=U?fc(U,Ht,_,H):void 0,en=H&&!!(Y!=null&&Y.json),Ft=(Y==null?void 0:Y.json)??null,tn=(Y==null?void 0:Y.md)??null,Fr=en&&!Se&&rc(Ft.sections),Ud=Fr&&!(tn&&M.readingMode==="paragraph"&&pi(tn)),Vd=en&&Fr?t.jsx(tg,{juan:Ft,view:Hr,onView:Bi,textHasEntries:Ud}):void 0,Gd=cl(oe)||uo(oe),Hi=tn?tn.replace(/^##\s+[^\n]+\n+/,""):null,Yd=(typeof d=="string"?_(d):d)??(G.source_name?_(G.source_name):_(_e.textVersionLabel(G)));return t.jsxs(Sl,{className:S,style:v,title:Fd,subtitle:Yd,byline:Dd,current:Oi,pagerUnit:Ht,rail:Vd,revisedAt:f,backHref:x,backLabel:k,onReportError:h?W=>h({...W,bookTitle:typeof Kn=="string"?Kn:void 0,entryId:e}):void 0,workLinkToggle:en&&!Se&&!!a&&!!(Ft!=null&&Ft.sections.some(W=>W.work_id)),toc:Hd,tocCaption:$("reader.tocCaption",{n:oe.chapters.length,unit:_(Ht)}),tocHeader:H&&oe.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:Se?$("reader.searchChaptersPlaceholder"):$("reader.searchUnitPlaceholder",{unit:_(Ht)}),"aria-label":Se?$("reader.searchChapters"):$("reader.searchUnit",{unit:_(Ht)}),value:de,onChange:W=>ee(W.target.value)}):void 0,activeKey:he??null,onSelect:Ce,images:Ue.images,imagesLoading:Ue.loading||ie,renderImageOverlay:p,imagePanel:z?"open":u,isWarpMode:!!z,customImagePanel:z&&Wr?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Od,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",outline:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px 6px",fontSize:12,color:i("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",disabled:Mi<=0,onClick:()=>jn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Ge,style:{fontSize:11,padding:"1px 6px",background:i("rule"),borderRadius:10},children:["第 ",Ge," 葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",disabled:Mi<0||Mi>=yn.length-1,onClick:()=>jn(1),children:"›"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[be.size>0&&t.jsxs("button",{type:"button",onClick:()=>je(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${i("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",be.size,")"]}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2},"data-testid":"facsimile-zoom-tools",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"缩小",title:"缩小",disabled:re<=1,onClick:()=>{var W;return(W=ue.current)==null?void 0:W.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(re*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:re>=6,onClick:()=>{var W;return(W=ue.current)==null?void 0:W.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:re===1,onClick:()=>{var W;return(W=ue.current)==null?void 0:W.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Ng,{ref:ue,resetKey:Ge,onScaleChange:we,style:{flex:1,minHeight:0},children:t.jsx(fr,{imageUrl:Wd,pageData:Wr,selectedCharIds:be,hoveredCharId:ge,preserveMargins:Ne,onCharClick:W=>{je(Le=>{const Fe=new Set(Le);return Fe.has(W)?Fe.delete(W):(Fe.clear(),Fe.add(W)),Fe});const pe=document.querySelector(`[data-char-id="${W}"]`);pe&&pe.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:Ie})}),t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0 2px"},children:t.jsxs("div",{style:{display:"inline-flex",border:`1px solid ${i("rule")}`,borderRadius:4,overflow:"hidden"},children:[t.jsx("button",{type:"button",onClick:()=>q(!1),"aria-pressed":!Ne,className:`bim-rd-t ${Ne?"":"bim-rd-on"}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:Ne?"transparent":i("accent-bg"),color:Ne?"inherit":i("accent")},title:"去空白:紧凑裁切版心",children:"去空白"}),t.jsx("button",{type:"button",onClick:()=>q(!0),"aria-pressed":Ne,className:`bim-rd-t ${Ne?"bim-rd-on":""}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:Ne?i("accent-bg"):"transparent",color:Ne?i("accent"):"inherit"},title:"保留空白:完整呈现古籍天头地脚与白边",children:"保留空白"})]})})]}):void 0,toolbarExtra:z?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-badge-warp",children:"图文对读"}),t.jsx("button",{type:"button",className:`bim-rd-t ${K?"bim-rd-on":""}`,"aria-pressed":K,title:"切换外挂现代断句标点",onClick:()=>fe(W=>!W),children:K?"标点":"无标点"})]}):void 0,prefs:M,onPrefsChange:N,versions:Wi.length>1?Wi:void 0,currentVersionKey:Wi.length>1?G.key:void 0,onVersionChange:me,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:pi(tn),allowVertical:m,children:[xe&&t.jsx(Zt,{}),!xe&&z&&t.jsxs("article",{className:"bim-rd-prose",style:{marginTop:0},children:[t.jsxs("header",{style:{marginBottom:16},children:[t.jsx("h1",{className:"bim-rd-h1",children:U!=null&&U.title?_(U.title):Oi}),(G.source_name||G.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[G.source_name&&_(G.source_name),G.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),G.license]})]})]}),t.jsx(vr,{pageData:z,pages:z.pages,punctuations:z.punctuations||[],selectedCharIds:be,hoveredCharId:ge,onSelectionChange:Un,onCharClick:W=>{je(Le=>{const Fe=new Set(Le);return Fe.has(W)?Fe.delete(W):(Fe.clear(),Fe.add(W)),Fe});const pe=parseInt(W.split(":")[0],10);isNaN(pe)||Et(pe)},onCharHover:Ie,mode:"horizontal",showPunctuation:K,entities:M.properNames?ae:void 0,entityTransport:n,onEntityNavigate:j,onVisiblePageChange:W=>Et(W),convert:_,scrollToPage:Ve})]}),!xe&&!z&&en&&Ft&&t.jsx(Qh,{juan:Ft,rawText:tn,positionLabel:Pg(U,oe,Ht,_),groupLabel:Mg(oe,he??null),index:Ig(e,oe),searchQuery:de,onNavigate:a,transport:n,workLabelCache:Je,prefs:M,view:Hr,onViewChange:Bi},`${Q}/${he}`),!xe&&!z&&!en&&Hi!=null&&U&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:U.title?_(U.title):Oi}),(G.source_name||G.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[G.source_name&&t.jsxs(t.Fragment,{children:[$("reader.textSource")," ",G.source_url?t.jsx("a",{className:"bim-rd-link",href:G.source_url,target:"_blank",rel:"noreferrer",children:_(G.source_name)}):_(G.source_name)]}),G.source_name&&G.license&&t.jsx("span",{className:"bim-rd-dot"}),G.license]}),ct&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[$("reader.upstream")," ",ct.url?t.jsx("a",{className:"bim-rd-link",href:ct.url,target:"_blank",rel:"noreferrer",children:_(ct.name??ct.url)}):_(ct.name??""),ct.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),ct.license_url?t.jsx("a",{className:"bim-rd-link",href:ct.license_url,target:"_blank",rel:"noreferrer",children:ct.license}):ct.license]}),ct.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(ml,{text:ct.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(cr,{text:Hi,mode:M.readingMode,tables:Gd,gujiMarkdown:uo(oe),properNames:M.properNames})})]}),!xe&&!z&&!en&&Hi==null&&U&&t.jsx("div",{className:"bim-rd-state",children:$("reader.chapterFailed")}),oe.references&&oe.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:$("reader.references")}),t.jsx("ol",{children:oe.references.map((W,pe)=>t.jsxs("li",{children:[W.url?t.jsx("a",{className:"bim-rd-link",href:W.url,target:"_blank",rel:"noopener noreferrer",children:_(W.title)}):t.jsx("span",{children:_(W.title)}),W.author&&t.jsxs("span",{children:[",",_(W.author)]}),W.note&&t.jsxs("span",{children:["。",_(W.note)]})]},pe))})]})]})};function Pg(e,n,o,r){var a,l;if(!e)return;const s=(l=(a=n.juan_metadata)==null?void 0:a[e.file])==null?void 0:l.vol_label;return r(s?`${s}冊`:`${o}${e.n}`)}function Mg(e,n){if(!n)return;const o=r=>{var s;for(const a of r??[]){const l=o(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return o(e.juan_groups)}function Bg(e,n,o){const[r,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,o]),r}const xc={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")}},Wg=xc.other,bc={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")}},Og=bc.pending;function Hg(e){try{const n=new Date(e),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 e}}function Fg(e,n){if(!e)return!1;try{const o=new URL(e,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const Sr=({items:e,loading:n})=>{const o=Ze(),{t:r,convert:s}=J();return n?t.jsx(Zt,{}):e.length===0?t.jsx("div",{style:Dg,children:r("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=xc[a.type]||Wg,d=bc[a.status]||Og,c=typeof window<"u"&&Fg(a.pageUrl,window.location.href);return t.jsxs("div",{style:Ug,children:[t.jsxs("div",{style:Vg,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Ds,background:l.color},children:r(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Ds,background:d.color},children:r(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Gg,children:Hg(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Yg,children:[a.resourceId&&t.jsx("a",{href:o(a.resourceId),style:eo,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:eo,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:eo,children:a.pageUrl}))]}),t.jsx("div",{style:Kg,children:s(a.content)}),a.reply&&t.jsxs("div",{style:qg,children:[t.jsx("div",{style:Xg,children:r("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Dg={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Ug={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Vg={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Ds={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Gg={fontSize:"12px",color:i("desc-fg")},Yg={fontSize:"12px",marginBottom:"6px"},eo={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},Kg={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},qg={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},Xg={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},$o=({transport:e,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:a})=>{const l=Te(),[d,c]=g.useState(null),[p,u]=g.useState([]),[m,h]=g.useState("recommend"),[f,x]=g.useState([]),[k,y]=g.useState(!1),w=r??m,b=L=>{h(L),s==null||s(L)},[j,S]=g.useState(!0),[v,$]=g.useState(null),[_,C]=g.useState(null),[M,N]=g.useState(null);g.useEffect(()=>{let L=!1;if(e.getCounts)return e.getCounts().then(I=>{L||c({works:I.works,books:I.books,collections:I.collections})}).catch(()=>{}),()=>{L=!0}},[e]),g.useEffect(()=>{let L=!1;return(async()=>{if(o)return o;if(e.getRecommended)try{const P=await e.getRecommended();if(P!=null&&P.groups)return P.groups.flatMap(V=>V.items.map(X=>({...X,group:V.name})))}catch{}return[]})().then(async P=>{if(L)return;const V=P.filter(D=>D.id);if(V.length===0){S(!1);return}const X=await Promise.all(V.map(async D=>{if(D.type)return{id:D.id,title:D.title,type:D.type,author:D.author,dynasty:D.dynasty,role:D.role,edition:D.edition,has_text:D.has_text,has_image:D.has_image,has_collated:D.has_collated,subtype:D.subtype,primary_name:D.primary_name,group:D.group,fallbackDescription:D.description};try{let O=null;if(e.getEntry)O=await e.getEntry(D.id);else{const A=await e.getItem(D.id);A&&(O={id:D.id,title:A.title||D.id,type:A.type||"work"})}if(O)return{...O,group:D.group,fallbackDescription:D.description}}catch{}return{id:D.id,title:D.title,type:_e.extractType(D.id),group:D.group,fallbackDescription:D.description}}));L||(u(X.filter(D=>D!==null)),S(!1))}),()=>{L=!0}},[e,o]);const T=g.useRef(!1),F=g.useRef(!1),R=g.useRef(!1);g.useEffect(()=>{if(w!=="catalog"||T.current)return;const L=e.getCatalogProgress??e.getResourceProgress;if(!L)return;T.current=!0;let I=!1;return L.call(e).then(P=>{I||$(P)}).catch(()=>{T.current=!1}),()=>{I=!0}},[e,w]),g.useEffect(()=>{if(w!=="collection"||F.current||!e.getCollectionProgress)return;F.current=!0;let L=!1;return e.getCollectionProgress().then(I=>{L||C(I)}).catch(()=>{F.current=!1}),()=>{L=!0}},[e,w]),g.useEffect(()=>{if(w!=="site"||R.current||!e.getSiteProgress)return;R.current=!0;let L=!1;return e.getSiteProgress().then(I=>{L||N(I)}).catch(()=>{R.current=!1}),()=>{L=!0}},[e,w]),g.useEffect(()=>{if(!a||w!=="feedback")return;let L=!1;return y(!0),fetch(a).then(I=>I.json()).then(I=>{!L&&I.success&&x(I.items||[])}).catch(()=>{}).finally(()=>{L||y(!1)}),()=>{L=!0}},[a,w]);const E=L=>t.jsx(fn,{type:L,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[t.jsx($n,{label:l.home.recommendTab,active:w==="recommend",onClick:()=>b("recommend")}),t.jsx($n,{label:l.home.catalogTab,active:w==="catalog",onClick:()=>b("catalog")}),t.jsx($n,{label:l.home.collectionTab,active:w==="collection",onClick:()=>b("collection")}),t.jsx($n,{label:l.home.siteTab,active:w==="site",onClick:()=>b("site")}),a&&t.jsx($n,{label:l.home.feedbackTab,active:w==="feedback",onClick:()=>b("feedback")})]}),w==="recommend"&&t.jsx(Zg,{recommended:p,loading:j,onNavigate:n,getIcon:E,t:l}),w==="catalog"&&t.jsx(Us,{progress:v,t:l,onNavigate:n}),w==="collection"&&t.jsx(Us,{progress:_,t:l,onNavigate:n}),w==="site"&&t.jsx(Qg,{progress:M,t:l,totalWorks:(d==null?void 0:d.works)??0}),w==="feedback"&&a&&t.jsx(Sr,{items:f,loading:k})]})})},$n=({label:e,active:n,onClick:o})=>t.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:e}),Zg=({recommended:e,loading:n,onNavigate:o,getIcon:r,t:s})=>{const a=Ze();if(n)return t.jsx(Zt,{});if(e.length===0)return null;const l=new Map;for(const d of e){const c=d.group||s.home.recommendedBrowse;l.has(c)||l.set(c,[]),l.get(c).push(d)}return t.jsx(t.Fragment,{children:Array.from(l.entries()).map(([d,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:d}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(p=>{const u=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),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:[t.jsx("span",{style:{fontSize:"20px"},children:r(p.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.title,p.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:p.edition})]}),u&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},p.id)})})]},d))})},Us=({progress:e,t:n,onNavigate:o})=>{if(!e)return t.jsx(Zt,{});const r=[...e.resources].sort((d,c)=>d.priority-c.priority),s=["in_progress","done","todo"],a={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},l={in_progress:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=r.filter(p=>p.status===d);return c.length===0?null:t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:l[d]}}),a[d]," (",c.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(p=>t.jsx(Jg,{item:p,t:n,statusColor:l[d],onNavigate:o},p.id))})]},d)})})},Jg=({item:e,t:n,statusColor:o,onNavigate:r})=>{const s=Ze(),a=e.total>0?Math.round(e.imported/e.total*100):0,l=e.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const d=e.edition?`${e.name}·${e.edition}`:e.name,c=e.collection_id||e.work_id;return c&&r?t.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}):e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:d}):d})()}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:i("widget-border"),color:i("desc-fg"),whiteSpace:"nowrap"},children:e.collection_id?n.indexType.collection:e.work_id?n.indexType.work:l})]}),t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?mt(n.home.progressFormat,{imported:String(e.imported),total:String(e.total)}):n.home.totalPending})]}),e.total>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},Qg=({progress:e,t:n,totalWorks:o})=>{if(!e)return t.jsx(Zt,{});const r=[...e.resources].sort((c,p)=>c.priority-p.priority),s=r.filter(c=>c.imported>0),a=r.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=o>0?Math.round(l/o*100):0;return t.jsxs("div",{children:[o>0&&t.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,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",o.toLocaleString()," ",n.indexType.work," (",d,"%)"]}),s.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(Vs,{item:c,t:n,totalWorks:o},c.id))})]}),a.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(Vs,{item:c,t:n,totalWorks:o},c.id))})]})]})},Vs=({item:e,t:n,totalWorks:o})=>{const r=o>0?Math.round(e.imported/o*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:t.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:e.name}):e.name})}),t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),e.imported>0&&o>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},Gs="(max-width: 768px)";function ef(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(Gs).matches);return g.useEffect(()=>{const o=window.matchMedia(Gs),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e}const tf=({transport:e,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var F;const a=Te(),{convert:l}=Ae(),d=ef(),[c,p]=g.useState(null),[u,m]=g.useState(null),[h,f]=g.useState(!1),[x,k]=g.useState("detail"),[y,w]=g.useState([]),[b,j]=g.useState(!1),S=g.useCallback(async R=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){w([]);return}j(!0);try{if(e.getCollectionCatalogs){const E=await e.getCollectionCatalogs(R);w(E||[])}else if(e.getCollectionCatalog){const E=await e.getCollectionCatalog(R);w(E?[{resource_id:"",data:E}]:[])}}catch{w([])}finally{j(!1)}},[e]),v=g.useCallback(async R=>{if(o){o(R);return}p(R),m(null),w([]),k("detail"),f(!0);try{const E=await e.getItem(R.id);E&&(m(E),E.type==="collection"&&S(R.id))}catch(E){console.error("加载详情失败:",E)}finally{f(!1)}},[e,o,S]),$=g.useCallback(async R=>{m(null),w([]),k("detail"),f(!0);try{const E=await e.getItem(R);E&&(m(E),p({id:R,title:E.title||R,type:E.type||"book"}),E.type==="collection"&&S(R))}catch(E){console.error("导航失败:",E)}finally{f(!1)}},[e,S]),_=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"&&_,M=d&&(h||u),N=g.useCallback(()=>{p(null),m(null),w([]),k("detail")},[]),T=t.jsx(t.Fragment,{children:h?t.jsx(Zt,{}):u?t.jsxs(t.Fragment,{children:[(C||s)&&t.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&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:ti(x==="detail"),children:a.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:ti(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&y.map(R=>t.jsx("button",{onClick:()=>k(`catalog:${R.resource_id}`),style:ti(x===`catalog:${R.resource_id}`),children:R.short_name?`${l(R.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},R.resource_id)),u.type==="work"&&_&&t.jsx("button",{onClick:()=>k("collated"),style:ti(x==="collated"),children:a.detailTab.collatedEdition})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),t.jsx("div",{style:{padding:d?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:x==="detail"?t.jsx(Uo,{data:u,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(Vo,{data:(F=y.find(R=>`catalog:${R.resource_id}`===x))==null?void 0:F.data,onNavigate:$}):x==="collated"?t.jsx(wr,{id:u.id,transport:e,onNavigate:$}):null})]}):t.jsx($o,{transport:e,onNavigate:$,recommendedIds:r})});return d?t.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:M?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:N,style:{padding:"4px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",a.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:T})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(po,{transport:e,onEntryClick:v,hideModeIndicator:n}),!u&&t.jsx($o,{transport:e,onNavigate:$,recommendedIds:r})]})}):t.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:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(po,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:T})]})};function ti(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const nf=({pageData:e,rawImageUrl:n="",punctuations:o=[],title:r,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[u,m]=g.useState(null),[h,f]=g.useState("horizontal"),[x,k]=g.useState(!0),y=g.useRef(null),w=g.useCallback(v=>{p(new Set(v))},[]),b=g.useCallback(v=>{if(p($=>{const _=new Set($);return _.has(v)?_.delete(v):(_.clear(),_.add(v)),_}),y.current){const $=y.current.querySelector(`[data-char-id="${v}"]`);$&&$.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),j=()=>{var v;p(new Set),window.getSelection&&((v=window.getSelection())==null||v.removeAllRanges())},S=o.length>0?o:e.punctuations||[];return t.jsxs("div",{className:`guji-reader-container ${l}`,style:d,children:[t.jsxs("header",{className:"guji-reader-header",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&t.jsx("button",{type:"button",onClick:a,className:"guji-reader-btn",style:{marginRight:6},children:"‹ 返回"}),t.jsx("span",{className:"guji-reader-title",children:r||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:i("meta-fg")},children:s}),t.jsx("span",{className:"guji-reader-tag",children:"WebGL 客户端透视矫正对读"})]}),t.jsxs("div",{className:"guji-reader-actions",children:[t.jsxs("span",{style:{fontSize:"0.85rem",color:i("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:i("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:j,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>k(v=>!v),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(v=>v==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:h==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(fr,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:u,onCharClick:b,onCharHover:m})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:h==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(vr,{pageData:e,punctuations:S,selectedCharIds:c,hoveredCharId:u,onSelectionChange:w,onCharClick:b,onCharHover:m,mode:h,showPunctuation:x})]})]})]})},of=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function on(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function rf(e){var r,s,a,l,d,c;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return[];const o=[];for(const p of n){if(!p||typeof p!="object")continue;const u=p,m=on((r=u.page)==null?void 0:r.index),h=Array.isArray(u.cells)?u.cells:[];if(m===void 0||h.length===0)continue;const f=new Map;for(const x of h){if(!x||typeof x!="object")continue;const k=x,y=of.exec(String(k.a??""));if(!y||typeof k.c!="string")continue;const w=parseInt(y[2],10),b=parseInt(y[3],10),j=Array.isArray(k.box)&&k.box.length===4&&k.box.every($=>on($)!==void 0)?k.box:null,S={id:String(k.a),char:k.c,slot:b,pos:b,sub:y[4]||null,bbox:j?[j[0],j[1],j[0]+j[2],j[1]+j[3]]:null};let v=f.get(w);v||f.set(w,v=[]),v.push(S)}o.push({page:m,seq:String(((s=u.canvas)==null?void 0:s.seq)??""),width:on((a=u.canvas)==null?void 0:a.width)??on((l=u.image)==null?void 0:l.width)??0,height:on((d=u.canvas)==null?void 0:d.height)??on((c=u.image)==null?void 0:c.height)??0,columns:Array.from(f.entries()).sort((x,k)=>x[0]-k[0]).map(([x,k])=>({col:x,chars:k}))})}return o}function sf(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],o=[];for(const r of n){if(!r||typeof r!="object")continue;const s=r;typeof s.anchor!="string"||typeof s.mark!="string"||o.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char})}return o}function af(e){var o;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const r of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((o=r==null?void 0:r.canvas)==null?void 0:o.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const lf=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function gt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Ys(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(o=>!!o&&typeof o=="object"):[]}function cf(e,n){var l,d,c,p,u,m,h,f,x,k;const o=new Map,r=new Map;for(const y of Ys(n)){const w=gt(y.page);if(w!==void 0){o.set(w,y);for(const b of Array.isArray(y.cells)?y.cells:[]){const j=b==null?void 0:b.box;typeof(b==null?void 0:b.a)=="string"&&Array.isArray(j)&&j.length===4&&j.every(S=>gt(S)!==void 0)&&r.set(b.a,[j[0],j[1],j[0]+j[2],j[1]+j[3]])}}}const s=[];for(const y of Ys(e)){const w=gt(y.page);if(w===void 0)continue;const b=[];for(const S of Array.isArray(y.columns)?y.columns:[]){const v=gt(S==null?void 0:S.col);if(v===void 0)continue;const $=[];for(const _ of Array.isArray(S.cells)?S.cells:[]){const C=lf.exec(String((_==null?void 0:_.a)??""));if(!C||typeof _.c!="string")continue;const M=parseInt(C[3],10);$.push({id:_.a,char:_.c,slot:M,pos:M,sub:C[4]||null,bbox:r.get(_.a)??null})}$.length>0&&b.push({col:v,chars:$})}if(b.length===0)continue;b.sort((S,v)=>S.col-v.col);const j=o.get(w);s.push({page:w,seq:String(((l=j==null?void 0:j.canvas)==null?void 0:l.seq)??""),width:gt((d=j==null?void 0:j.canvas)==null?void 0:d.width)??gt((c=j==null?void 0:j.image)==null?void 0:c.width)??0,height:gt((p=j==null?void 0:j.canvas)==null?void 0:p.height)??gt((u=j==null?void 0:j.image)==null?void 0:u.height)??0,columns:b})}const a=new Set(s.map(y=>y.page));for(const[y,w]of o){const b=(m=w==null?void 0:w.canvas)==null?void 0:m.seq;a.has(y)||typeof b!="string"&&typeof b!="number"||String(b)===""||s.push({page:y,seq:String(b),width:gt((h=w.canvas)==null?void 0:h.width)??gt((f=w.image)==null?void 0:f.width)??0,height:gt((x=w.canvas)==null?void 0:x.height)??gt((k=w.image)==null?void 0:k.height)??0,columns:[]})}return s.sort((y,w)=>y.page-w.page)}const df=({data:e,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:a}=J(),[l,d]=g.useState(((u=e.divisions[0])==null?void 0:u.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:o,style:r,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(m=>t.jsx(pf,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:h=>p(c===h?null:h),onNavigate:n},m.name))})]})},pf=({division:e,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=J(),c=e.categories.reduce((p,u)=>{const m=u.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.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:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg")},children:[l("catalogPage.divisionStat",{cats:e.categories.length,books:c}),t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(p=>{const u=`${e.name}/${p.name}`;return t.jsx(uf,{category:p,expanded:r===u,onToggle:()=>s(u),onNavigate:a},p.name)})})]})},uf=({category:e,expanded:n,onToggle:o,onNavigate:r})=>{var p,u,m,h;const{t:s,convert:a}=J(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((u=e.books)==null?void 0:u.cunmu)||[],c=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((h=e.stats)==null?void 0:h.cunmu)||d.length);return t.jsxs("div",{children:[t.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:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(Ks,{label:s("catalogPage.zhulu"),books:l,onNavigate:r}),d.length>0&&t.jsx(Ks,{label:s("catalogPage.cunmu"),books:d,onNavigate:r})]})]})},Ks=({label:e,books:n,onNavigate:o})=>{const{t:r,convert:s}=J(),a=Ze(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,u)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:i("fg")},children:p.work_id&&o?t.jsx("a",{href:a(p.work_id),onClick:m=>{m.metaKey||m.ctrlKey||(m.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&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.author).slice(0,20)})]},u))}),!l&&t.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})})]})},bt=({title:e,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const a=Te();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&t.jsx("button",{onClick:o,style:hf,children:"AI"}),n&&t.jsx("button",{onClick:n,style:mf,children:a.action.save})]})]}),s]})},mf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},hf={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},ut=({label:e,value:n,onChange:o,placeholder:r,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>o(a.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"}})]}),Kt=({value:e,onChange:n,placeholder:o})=>{const r=g.useRef(null);return g.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:r,value:e||"",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"}})},mi=({children:e,color:n,style:o})=>t.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:e});function gf(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const si=({value:e,onChange:n,label:o})=>{const[r,s]=g.useState(!1),a=g.useRef(null),l=gf(e||"");return g.useEffect(()=>{r&&a.current&&a.current.focus()},[r]),!r&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:qs,children:o}),t.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:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:l.name}),t.jsx(mi,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:qs,children:o}),t.jsx("input",{ref:a,type:"text",value:e||"",onChange:d=>n(d.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},qs={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function ff(e){switch(e){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function xf(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const yc=({items:e,onChange:n,onOpenEntityPicker:o})=>{const r=Te(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((h,f)=>f!==m)),s===m&&a(null)},c=(m,h,f)=>{const x=[...e];x[m]={...x[m],[h]:f},n(x)},p=(m,h)=>{const f=[...e];f[m]={...f[m],type:h,id:"",name:""},n(f),h==="bookID"&&o&&o(x=>{const k=[...e];k[m]={...k[m],id:x.id,name:x.title,type:"bookID"},n(k)})},u=m=>{o&&o(h=>{const f=[...e];f[m]={...f[m],id:h.id,name:h.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,h)=>t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===h?null:h),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===h?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:m.name||`${r.editor.sourcePlaceholder} ${h+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:ff(m.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:xf(m.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(h)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===h&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(h,"bookID"),style:{...Xs,borderColor:i("source-bookid"),color:i("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(h,"url"),style:{...Xs,borderColor:i("source-url"),color:i("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.enterUrl})]})]})]}),m.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:_t,children:r.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:Zs,children:r.action.changeType})]}),m.id&&m.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:i("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:m.name}),t.jsx("code",{style:{fontSize:"11px",background:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>u(h),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})]}):t.jsxs("button",{onClick:()=>u(h),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:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),m.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:_t,children:r.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:Zs,children:r.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:f=>c(h,"name",f.target.value),placeholder:r.editor.sourceNamePlaceholder,style:rn})]}),t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:f=>c(h,"id",f.target.value),placeholder:"https://...",style:rn})]})]}),m.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{..._t,opacity:.7},children:r.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:f=>c(h,"details",f.target.value),placeholder:r.editor.detailsPlaceholder,style:rn})]}),t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:f=>c(h,"position",f.target.value),placeholder:"如: 卷三, p.52",style:rn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:f=>c(h,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:rn})]}),t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:f=>c(h,"processor_version",f.target.value),placeholder:"如: v0.1",style:rn})]})]})]})]})})]},h)),t.jsxs("button",{onClick:l,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:[t.jsx("span",{children:"+"}),t.jsx("span",{children:r.action.addSource})]})]})},_t={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},rn={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"},Xs={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"},Zs={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function jc(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);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 vc(e){return!e||e.length===0?"":JSON.stringify(e)}const kc=({entityType:e,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:u,onLinkEntity:m,onUnlinkEntity:h,onViewEntity:f,onCreateAndLink:x,onSaveRelations:k})=>{const y=Te();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),k&&t.jsx("button",{onClick:k,style:bf,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Cn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Cn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>h("collectionId"),onLink:()=>m("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&u&&u.length>0&&t.jsx(sn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${u.length})`,entities:u,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Cn,{direction:"up",title:y.relation.parentWork,entity:r,onView:f,onUnlink:()=>h("parentWorkId"),onLink:()=>m("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),d&&d.length>0&&t.jsx(sn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(sn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(sn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Cn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(Cn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>h("parentCollectionId"),onLink:()=>m("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(sn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(sn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},Cn=({direction:e,title:n,entity:o,onView:r,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:u,unlinkLabel:m})=>{const h=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:f}),t.jsx("span",{children:n})]}),o?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:wc(o.type)}),t.jsx("span",{style:{fontWeight:500},children:o.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx(Js,{onClick:()=>r(o),title:u,children:"👁️"}),t.jsx(Js,{onClick:s,title:m,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(Co,{onClick:a,children:d}),t.jsx(Co,{onClick:l,primary:!0,children:c})]})]})},sn=({direction:e,title:n,entities:o,onView:r,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),u=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",h=c?o:o.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:m}),t.jsx("span",{children:n})]}),o.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[h.map(f=>t.jsxs("div",{onClick:()=>r(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:i("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:wc(f.type)}),t.jsx("span",{children:f.title})]},f.id)),o.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[d," (",o.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(Co,{onClick:s,primary:!0,children:["+ ",a]})})]})},Js=({onClick:e,title:n,danger:o,children:r})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),Co=({onClick:e,primary:n,children:o})=>t.jsx("button",{onClick:e,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 wc(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const bf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Sc=({isOpen:e,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[u,m]=g.useState(""),h=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(m(""),d(""))},[e]);const f=y=>{m(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",k=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:yf,children:t.jsxs("div",{style:jf,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),t.jsx("button",{onClick:s,style:vf,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:u,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:kf})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:to,children:"搜索中..."}):h.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:h.map(y=>t.jsxs("div",{onClick:()=>r(y),style:wf,children:[t.jsx("span",{style:{fontSize:"16px"},children:k}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):u?t.jsxs("div",{style:to,children:["未找到匹配的",x]}):t.jsxs("div",{style:to,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:Sf,children:["创建新",x,"并关联"]})]})]})})},yf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},jf={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")},vf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},kf={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"},wf={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},to={padding:"20px",textAlign:"center",color:i("desc-fg")},Sf={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Qs={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},_f={work:"📜",book:"📖",collection:"📚",entity:"👤"},_c=({isOpen:e,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((r==null?void 0:r.title)||""),setTimeout(()=>{var h,f;(h=c.current)==null||h.focus(),(f=c.current)==null||f.select()},100))},[e,r==null?void 0:r.title]);const p=h=>{h.key==="Enter"&&l.trim()?u():h.key==="Escape"&&a()},u=()=>{l.trim()&&s(l.trim(),{...r,title:l.trim()})};if(!e)return null;const m=()=>{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`创建新${Qs[n]}`}};return t.jsx("div",{style:$f,onClick:h=>{h.target===h.currentTarget&&a()},children:t.jsxs("div",{style:Cf,onClick:h=>h.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:_f[n]}),t.jsx("span",{children:m()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:h=>d(h.target.value),onKeyDown:p,placeholder:`请输入${Qs[n]}名称...`,style:zf})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&t.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:Tf,children:"取消"}),t.jsx("button",{onClick:u,disabled:!l.trim(),style:{...Nf,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},$f={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Cf={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")},zf={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"},Tf={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Nf={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function Rf(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function $c(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Ef(e){switch(e){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 Cc=({isOpen:e,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:u})=>{const[m,h]=g.useState(""),[f,x]=g.useState([]),[k,y]=g.useState(!1),[w,b]=g.useState("recent");g.useEffect(()=>{e&&(h(""),x([]),b(r.length>0?"recent":"search"))},[e,r.length]),g.useEffect(()=>{if(!m.trim()){x([]);return}const C=setTimeout(async()=>{y(!0);try{x(await u(m,o))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(C)},[m,o,u]);const j=g.useCallback(C=>{h(C.target.value),C.target.value.trim()&&b("search")},[]),S=g.useCallback(C=>s?C.filter(M=>M.id!==s):C,[s]);if(!e)return null;const v=n||(o==="all"?"选择实体":`选择${$c(o)}`),$=S(r),_=S(f);return t.jsx("div",{style:Lf,children:t.jsxs("div",{style:Af,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:v}),t.jsx("button",{onClick:c,style:Pf,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:m,onChange:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Mf}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),k&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs(ea,{active:w==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(ea,{active:w==="search",onClick:()=>b("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:w==="recent"&&$.length>0?t.jsx(ta,{entities:$,onSelect:d}):m.trim()?k?t.jsx(no,{message:"搜索中..."}):_.length>0?t.jsx(ta,{entities:_,onSelect:d}):t.jsx(no,{message:"未找到匹配的结果"}):t.jsx(no,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:Bf,children:l||"创建新实体"})]})]})})},ea=({active:e,onClick:n,children:o})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:o}),ta=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(o=>t.jsx(If,{entity:o,onClick:()=>n(o)},o.id))}),If=({entity:e,onClick:n})=>{const[o,r]=g.useState(!1);return t.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:[t.jsx("span",{style:{fontSize:"18px"},children:Rf(e.type)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.title,e.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:e.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[t.jsx("code",{style:{fontSize:"10px",background:i("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:e.id}),e.author&&t.jsx("span",{children:e.author}),e.dynasty&&t.jsx("span",{children:e.dynasty})]})]}),t.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:Ef(e.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:$c(e.type)})]})},no=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:e}),Lf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Af={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")},Pf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Mf={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"},Bf={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Wf={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},Of={work:"📜",collection:"📚",book:"📖",entity:"👤"},zc=({data:e,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:u,relations:m,onRelationsChange:h})=>{var Ce;const f=Te(),[x,k]=g.useState(!1),[y,w]=g.useState("work"),[b,j]=g.useState(""),[S,v]=g.useState(""),[$,_]=g.useState([]),[C,M]=g.useState(!1),[N,T]=g.useState(!1),[F,R]=g.useState("work"),[E,L]=g.useState(""),[I,P]=g.useState(),[V,X]=g.useState(!1),[D,O]=g.useState(null),[A,G]=g.useState([]);g.useRef(null);const se=e.type,Q=se==="work",ve=se==="collection",ne=se==="book",ce=g.useCallback((Y,ze)=>{n({...e,[Y]:ze})},[e,n]),We=g.useCallback((Y,ze)=>{j(Y),w(ze),v(f.editor.selectToLink+f.indexType[ze]),_([]),k(!0)},[f]),ke=g.useCallback(Y=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(e.id,Y)},[r,e.id]),Pe=g.useCallback(Y=>{s==null||s(Y.id,Y.type)},[s]),Ee=g.useCallback((Y,ze,Me)=>{const B={...Me,author:(Me==null?void 0:Me.author)||e.author,dynasty:Me==null?void 0:Me.dynasty};R(ze),L(Y),P(B),T(!0)},[e.author]),Z=g.useCallback((Y,ze)=>{r!=null&&r.createAndLink&&r.createAndLink(e.id,E,{type:F,title:Y,inheritData:ze}),T(!1)},[r,e.id,E,F]),le=g.useCallback(Y=>{if(!Y.trim()){_([]);return}M(!0),r!=null&&r.searchEntities&&r.searchEntities(Y,y).then(ze=>{_(ze),M(!1)}).catch(()=>{_([]),M(!1)})},[r,y]),oe=g.useCallback(Y=>{r!=null&&r.linkEntity&&r.linkEntity(e.id,b,Y.id),k(!1)},[r,e.id,b]),he=g.useCallback(()=>{o()},[o]),U=g.useCallback(Y=>{O(()=>Y),X(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(G).catch(()=>{})},[r]),$e=g.useCallback((Y,ze)=>r!=null&&r.searchEntities?r.searchEntities(Y,ze==="all"?void 0:ze):Promise.resolve([]),[r]),me=g.useCallback(Y=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(Y),G(ze=>[Y,...ze.filter(Me=>Me.id!==Y.id)].slice(0,10)),D==null||D(Y),X(!1),O(null)},[r,D]);return t.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${i("widget-border")}`,paddingBottom:"16px"},children:t.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Of[se]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(mi,{children:e.id}),t.jsx(mi,{color:Wf[se],children:f.indexType[se]})]})}),t.jsx(bt,{title:f.section.basicInfo,onSave:o,onAskAI:d?()=>d("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[t.jsx(si,{label:Q?f.editor.workTitle:ve?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:Y=>ce("title",Y)}),ne&&t.jsx(si,{label:f.editor.belongsToWork,value:e.workName||"",onChange:Y=>ce("workName",Y)}),t.jsx(ut,{label:f.editor.authorLabel,value:e.author||"",onChange:Y=>ce("author",Y)}),t.jsx(ut,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:Y=>ce("publicationYear",Y)}),(ne||ve)&&t.jsx(si,{label:f.editor.containedIn,value:e.collection||"",onChange:Y=>ce("collection",Y)}),(ne||ve)&&t.jsx(ut,{label:f.editor.holderLabel,value:e.holder||"",onChange:Y=>ce("holder",Y)}),(ne||ve)&&t.jsx(ut,{label:ne?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:Y=>ce("pages",Y)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(ut,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:Y=>ce("firstImage",Y)})})]})}),t.jsx(bt,{title:f.section.description,onSave:o,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(Kt,{value:e.description||"",onChange:Y=>ce("description",Y),placeholder:f.editor.descriptionPlaceholder})}),(((Ce=e.additional_works)==null?void 0:Ce.length)||0)>0&&t.jsx(bt,{title:f.section.additionalWorks,onSave:o,children:t.jsx(Hf,{items:e.additional_works||[],onChange:Y=>ce("additional_works",Y)})}),t.jsx(bt,{title:f.section.indexedBy,onSave:o,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Ff,{items:e.indexed_by||[],onChange:Y=>ce("indexed_by",Y)})}),t.jsx(bt,{title:f.section.emendatedBy,onSave:o,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Df,{items:e.emendated_by||[],onChange:Y=>ce("emendated_by",Y)})}),t.jsx(bt,{title:f.section.textResources,onSave:o,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(lo,{items:e.resources||[],onChange:Y=>ce("resources",Y),onDownload:p,downloadStatuses:u,filterType:"text"})}),t.jsx(bt,{title:f.section.imageResources,onSave:o,children:t.jsx(lo,{items:e.resources||[],onChange:Y=>ce("resources",Y),onDownload:p,downloadStatuses:u,filterType:"image"})}),t.jsx(bt,{title:f.section.sources,onSave:o,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(yc,{items:jc(e.sources||""),onChange:Y=>ce("sources",vc(Y)),onOpenEntityPicker:U})}),(ne||ve)&&t.jsx(bt,{title:f.section.provenance,onSave:o,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(Kt,{value:e.provenance||"",onChange:Y=>ce("provenance",Y),placeholder:f.editor.provenancePlaceholder})}),ne&&t.jsx(bt,{title:f.section.otherEditions,onSave:o,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(Kt,{value:e.otherEditions||"",onChange:Y=>ce("otherEditions",Y),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(kc,{entityType:se,entityId:e.id,entityTitle:e.title,parentWork:m==null?void 0:m.parentWork,parentCollection:m==null?void 0:m.parentCollection,belongsToWork:m==null?void 0:m.belongsToWork,belongsToCollection:m==null?void 0:m.belongsToCollection,childWorks:m==null?void 0:m.childWorks,childCollections:m==null?void 0:m.childCollections,containedBooks:m==null?void 0:m.containedBooks,siblingBooks:m==null?void 0:m.siblingBooks,onLinkEntity:We,onUnlinkEntity:ke,onViewEntity:Pe,onCreateAndLink:Ee,onSaveRelations:he}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),t.jsx(Sc,{isOpen:x,entityType:y,title:S,onSelect:oe,onCancel:()=>k(!1),onCreate:()=>{k(!1),Ee(b,y)},searchResults:$,onSearch:le,isLoading:C,excludeId:e.id}),t.jsx(_c,{isOpen:N,entityType:F,relationField:E,inheritData:I,onConfirm:Z,onCancel:()=>T(!1)}),t.jsx(Cc,{isOpen:V,title:f.action.selectBookOrWork,filterType:"all",recentEntities:A,excludeId:e.id,onSelect:me,onCancel:()=>{X(!1),O(null)},onSearch:$e})]})};function Hf({items:e,onChange:n}){const o=Te(),r=(l,d,c)=>{const p=e.map((u,m)=>m===l?{...u,[d]:c}:u);n(p)},s=l=>n(e.filter((d,c)=>c!==l)),a=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((l,d)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(ut,{label:o.editor.bookNameLabel,value:l.book_title,onChange:c=>r(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(ut,{label:o.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>r(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.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)),t.jsx("button",{onClick:a,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 Tc({items:e,onChange:n,showMeta:o,addLabel:r}){const s=Te(),[a,l]=g.useState(null),d=(u,m,h)=>{const f=e.map((x,k)=>k===u?{...x,[m]:h||void 0}:x);n(f)},c=u=>{n(e.filter((m,h)=>h!==u)),a===u&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>{const h=a===m;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:h?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(h?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:h?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!h&&o&&(u.title_info||u.author_info)&&t.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]}),h&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ut,{label:s.label.sourceName,value:u.source,onChange:f=>d(m,"source",f)}),t.jsx(ut,{label:s.label.sourceBid,value:u.source_bid||"",onChange:f=>d(m,"source_bid",f)})]}),o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ut,{label:s.label.titleInfo,value:u.title_info||"",onChange:f=>d(m,"title_info",f)}),t.jsx(ut,{label:s.label.authorInfo,value:u.author_info||"",onChange:f=>d(m,"author_info",f)})]}),t.jsx(ut,{label:s.label.edition,value:u.edition||"",onChange:f=>d(m,"edition",f)})]}),t.jsx(Kt,{value:u.summary||"",onChange:f=>d(m,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(Kt,{value:u.comment||"",onChange:f=>d(m,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(Kt,{value:u.additional_comment||"",onChange:f=>d(m,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:r})]})}function Ff({items:e,onChange:n}){const o=Te();return t.jsx(Tc,{items:e,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function Df({items:e,onChange:n}){const o=Te();return t.jsx(Tc,{items:e,onChange:n,addLabel:o.action.addEmendatedBy})}function Nc(e){var d,c,p,u,m,h,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",o=((p=e.publication_info)==null?void 0:p.year)||"",r=((u=e.current_location)==null?void 0:u.name)||"",s=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((h=e.page_count)==null?void 0:h.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:o,holder:r,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const k=x.related_works.find(y=>y.relation==="part_of");k&&(l.parentWorkId=k.id,l.parentWorkName=k.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(f=x.contained_in[0])==null?void 0:f.id)}return l}function Uf(e){const n={id:e.id,title:e.title,type:e.type,description:e.description?{text:e.description}:void 0,authors:e.author?[{name:e.author}]:void 0,publication_info:e.publicationYear?{year:e.publicationYear}:void 0,current_location:e.holder?{name:e.holder}:void 0,page_count:e.pages?{number:parseInt(e.pages)||0,description:e.pages}:void 0,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};return e.type==="work"&&e.parentWorkId&&(n.related_works=[{id:e.parentWorkId,title:e.parentWorkName||"",relation:"part_of"}]),e.type==="book"&&(n.work_id=e.workId,e.collectionId&&(n.contained_in=[{id:e.collectionId}])),n}const Vf=e=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:u,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y,headerExtra:w,className:b,style:j}=e,S=Te(),[v,$]=g.useState(s),_=a?s:v;g.useEffect(()=>{s!==v&&$(s)},[s]);const C=g.useCallback(()=>{const L=_==="view"?"edit":"view";a?a(L):$(L)},[_,a]),[M,N]=g.useState(null);g.useEffect(()=>{o&&r&&r.getItem(o).then(L=>{L&&N(L)})},[o,r]);const T=n||M,F=g.useMemo(()=>T?Nc(T):null,[T]),R=a||!n?t.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"?S.common.switchToEdit:S.common.switchToView,children:_==="view"?S.common.modeEdit:S.common.modeView}):null,E=t.jsxs(t.Fragment,{children:[R,w]});return!T&&!F?t.jsx(Zt,{}):_==="view"?t.jsx(Uo,{data:T,transport:r,onNavigate:p?L=>p(L):void 0,renderLink:u,headerExtra:E,className:b,style:j}):F?t.jsxs("div",{className:b,style:j,children:[E&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:E}),t.jsx(zc,{data:F,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:r,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},Gf=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Rc=({isOpen:e,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=J(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,u]=g.useState(""),[m,h]=g.useState("idle"),[f,x]=g.useState(""),k=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),u(""),h("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=k.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(m==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[m,n]),g.useEffect(()=>{if(!e)return;const b=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){h("submitting"),x("");try{await o({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),h("success")}catch(b){h("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const w=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:Yf,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:Kf,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:qf,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Xf,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:tx,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),r&&t.jsx("a",{href:r,style:{fontSize:"13px",color:i("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:Gf.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...Zf,...a===b.value?Jf:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:k,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...Qf,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>u(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||m==="submitting","aria-label":s("feedback.contactLabel"),style:ix}),t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:nx,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!w,style:{...ex,opacity:w?1:.6,cursor:w?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Yf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Kf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},qf={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Xf={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Zf={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"},Jf={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Qf={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"},ex={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},tx={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},nx={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},ix={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"},zo="--bim-feedback-fab-offset",To=48,ox=16,rx=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:a}=J(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(r||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(zo,`calc(${c+To+ox}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(zo)}},[r,c]),t.jsxs(t.Fragment,{children:[!r&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...sx,zIndex:s??i("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":a("feedback.title"),title:a("feedback.title"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsx(Rc,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:o})]})},sx={position:"fixed",width:`${To}px`,height:`${To}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"},ax=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Ec=({onSubmit:e})=>{const{t:n}=J(),[o,r]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[u,m]=g.useState(""),h=g.useRef(null);g.useEffect(()=>{o&&setTimeout(()=>{var k;return(k=h.current)==null?void 0:k.focus()},100)},[o]);const f=async()=>{if(!(!o||!s.trim())){p("submitting"),m("");try{await e({type:o,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),r("bug")}catch(k){p("error"),m(k instanceof Error?k.message:n("feedback.submitFailedRetry"))}}},x=o&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:na,children:t.jsxs("div",{style:ux,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:mx,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:na,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:ax.map(k=>t.jsxs("button",{onClick:()=>r(k.value),style:{...lx,...o===k.value?cx:{}},children:[t.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),t.jsx("textarea",{ref:h,value:s,onChange:k=>a(k.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...dx}}),t.jsx("input",{type:"text",value:l,onChange:k=>d(k.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:gx}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:f,disabled:!x,style:{...px,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:hx,children:u})]})},na={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},lx={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"},cx={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},dx={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"},px={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},ux={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},mx={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},hx={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},gx={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 ia(e){return typeof e=="function"?e():e??"/api/feedback"}const Ic=({resourceId:e,apiUrl:n})=>{const{t:o}=J(),[r,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=ia(n);l(!0);try{const m=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();m.success&&s(m.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const u=ia(n),m=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const h=await m.json().catch(()=>null);throw new Error((h==null?void 0:h.error)||o("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Sr,{items:r,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Ec,{onSubmit:c})})]})},fx=gi["zh-Hant"].relation,xx=gi["zh-Hant"].lossStatus,bx=gi["zh-Hant"].resourceKind,Ti=mn("zh-Hant"),_r=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function oa(e,n=Ti){return e?_r(fx,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function yx(e,n=Ti){return _r(xx,e)?n(`detail.lossStatus.${e}`):e}function jx(e,n=Ti){return _r(bx,e)?n(`detail.resourceKind.${e}`):""}function $r({authors:e,onNavigate:n,renderLink:o}){const{convert:r}=J(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=Qo(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(a.dynasty),"〕"]}),a.entity_id?t.jsx(Xe,{id:a.entity_id,label:r(a.name),onNavigate:n,renderLink:o,dense:!0}):r(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:r(d)})]},l)})}):null}function Lc(e,n,o=Ti){var c,p;const r=Zo(e,n),s=r.mirrors.map(u=>({key:u.key,label:u.label,description:u.description,rows:u.items.filter(m=>m.group_role!=="mirror"),mirrors:u.items.filter(m=>m.group_role==="mirror")})),a=r.buckets.filter(u=>u.key==="image"||u.key==="textImage").flatMap(u=>u.items);a.length&&s.push({key:"_images",label:s.length?o("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=r.buckets.find(u=>u.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:o("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=r.buckets.find(u=>u.key==="text"))==null?void 0:p.items)??[],groups:s}}function Ac(e,n){const o=(e.url?hn(e.url):void 0)||e.name,r=Cl(e,n);return r?`${o}(${r})`:o}function Cr({item:e,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=J(),[a,l]=g.useState(!1),d=fi(e),c=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),p=s(Ac(e,n)),u=gn(e),m=Si(e,r)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const h=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:r("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?r("colorMode.color"):r("colorMode.bw")})]}):null;return u?t.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),h]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,h]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(or,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(h=>!h),children:a?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:d.expected})})})]})}function Pc({groups:e,listedVolumeCounts:n}){const{t:o,convert:r}=J();return t.jsx(t.Fragment,{children:e.map(s=>t.jsxs("div",{className:"bim-d-rg",children:[s.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:r(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:r(s.description)}),s.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:s.rows.map((a,l)=>t.jsx(Cr,{item:a,siblings:s.rows,listedVolumeCounts:n},`${a.id||a.url||a.name}-${l}`))})}),s.mirrors.length>0&&t.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&t.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:o("detail.mirror")}),s.mirrors.map((a,l)=>{const d=gn(a),c=r(Ac(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?r(a.details):void 0,children:[c," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]},l):t.jsx("span",{style:{marginRight:14},children:c},l)})]})]},s.key))})}const An=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function No(e){var o;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=An.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const ra=12,vx=60,Mc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:a,back:l,railLinks:d})=>{var le,oe,he;const{t:c,convert:p,messages:u}=J(),m=g.useMemo(()=>[...e.books||[],...e.collections||[]],[e.books,e.collections]),[h,f]=g.useState(new Map),[x,k]=g.useState(!1),[y,w]=g.useState(""),[b,j]=g.useState(!1),S=m.length<=vx,v=S||x||!!y||b,$=g.useMemo(()=>v?m:m.slice(0,ra),[m,v]);g.useEffect(()=>{if(!n||$.length===0)return;const U=$.filter(me=>!h.has(me));if(U.length===0)return;let $e=!1;return Promise.all(U.map(me=>n.getItem(me).then(Ce=>{const Y=Ce??{};return[me,{id:me,title:Y.title,edition:Y.edition,resources:Y.resources,publication_info:Y.publication_info,current_location:Y.current_location,lineage:Y.lineage,measure_info:Y.measure_info}]}).catch(()=>[me,{id:me}]))).then(me=>{$e||f(Ce=>{const Y=new Map(Ce);for(const[ze,Me]of me)Y.set(ze,Me);return Y})}),()=>{$e=!0}},[n,$,h]);const _=g.useMemo(()=>m.map(U=>h.get(U)??{id:U}),[m,h]),C=m.length>0&&m.every(U=>h.has(U)),M=!!n&&$.some(U=>!h.has(U)),N=S||v,T=g.useMemo(()=>Tl(_,e.version_graph,{era:y,scanOnly:b,sort:N?"year":"default"}),[_,e.version_graph,y,b,N]),F=x?T.rows:T.rows.slice(0,ra),R=T.allRows.filter(U=>U.hasImage).length,E=e.related_works||[],L=E.filter(U=>U.relation==="collected_in"),I=g.useMemo(()=>{const U=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],$e=me=>{const Ce=U.indexOf(me??"");return Ce<0?U.length:Ce};return E.filter(me=>me.relation!=="collected_in").map((me,Ce)=>({r:me,i:Ce})).sort((me,Ce)=>$e(me.r.relation)-$e(Ce.r.relation)||me.i-Ce.i).map(me=>me.r)},[E]),P=g.useMemo(()=>{const U=Zo(e.resources,e.resource_groups);return[...U.mirrors.flatMap($e=>$e.items.map(me=>({r:me,kind:p($e.label)}))),...U.buckets.flatMap($e=>$e.items.map(me=>({r:me,kind:p(jx($e.key,c))})))]},[e.resources,e.resource_groups,p,c]),V=e.indexed_by||[],X=e.emendated_by||[],D=g.useMemo(()=>{var te,xe,Re;const U=[],$e=(xe=(te=e.authors)==null?void 0:te[0])==null?void 0:xe.dynasty;$e&&U.push({label:c("workPage.fact.written"),value:p($e)});const me=Nt(e,u.unit.juan);if(me){const H=(Re=e.juan_count)==null?void 0:Re.description;U.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(me),H&&H!==me?t.jsxs("span",{className:"bim-d-meta",children:["(",p(H),")"]}):null]})})}e.loss_status&&U.push({label:c("workPage.fact.loss"),value:p(yx(e.loss_status,c))});const Ce=T.allRows.filter(H=>H.sortYear!=null),Y=Ce.length>0?Ce.reduce((H,de)=>H.sortYear<=de.sortYear?H:de):null;Y!=null&&Y.era.era?U.push({label:c("workPage.fact.earliest"),value:p([Y.era.era,Y.era.reign].filter(Boolean).join(" ")),title:Y.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):M&&U.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),X.length&&U.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:X.length})});const ze=sa(e.additional_titles);ze.length&&U.push({label:c("workPage.fact.alias"),value:ze.map(p).join("、")});const Me=sa(e.attached_texts);Me.length&&U.push({label:c("workPage.fact.attached"),value:Me.map(p).join("、")});const B=(e.additional_works||[]).map(H=>p(H.book_title)+(H.n_juan!=null?` ${H.n_juan}${u.unit.juan}`:""));return B.length&&U.push({label:c("workPage.fact.appendix"),value:B.join("、")}),U},[e,p,c,u,M,T.allRows,X.length]),A=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:C?R:0,label:c("workPage.stat.hasImage")},{value:V.length,label:c("workPage.stat.catalogs")}],G=e.classification,se=G?[G.l1,G.l2,G.l3,G.l4].filter(Boolean).map(U=>p(U)):[],Q=e.subtype?u.workSubtype[e.subtype]??p(e.subtype):"",ve=t.jsx(Wn,{title:p(e.title),byline:t.jsx($r,{authors:e.authors,onNavigate:o,renderLink:r}),meta:t.jsx(et,{items:[...se,G!=null&&G.source?c("workPage.classifiedBy",{source:p(G.source.split("/")[0])}):"",Q]}),description:(le=e.description)!=null&&le.text?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(oe=e.description.sources)!=null&&oe.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(U=>p(Bm(U))).filter(Boolean).join(" · ")}):null]}):void 0,stats:A,facts:D,readAction:s,foot:t.jsx(On,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(he=e.appendix)==null?void 0:he.map((U,$e)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(U.title)}),t.jsx(Tt,{text:U.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},$e))}),ne=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(U=>({key:U,label:`${U} ${T.allRows.filter($e=>$e.era.era===U).length}`}))]:[],ce=[];m.length&&ce.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),V.length&&ce.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:V.length}),L.length&&ce.push({id:"collected",label:c("workPage.sec.collected"),count:L.length}),I.length&&ce.push({id:"related",label:c("workPage.sec.related"),count:I.length}),P.length&&ce.push({id:"resources",label:c("workPage.sec.resources"),count:P.length});const We=m.length===0&&V.length===0,ke=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(tt,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(et,{items:[c("workPage.versionsTotal",{n:m.length}),C&&R?c("workPage.versionsWithImage",{n:R}):"",T.rows.length!==T.allRows.length?c("workPage.versionsCurrent",{n:T.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":M&&ne.length===0&&m.length>1?"":void 0,children:[ne.length>0&&t.jsx($i,{items:ne,value:y,onChange:U=>{w(U),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Pl,{label:c("workPage.scanOnly"),checked:b,onChange:U=>{j(U),k(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(N?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Ci(T.rows.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("workPage.col.edition")}),t.jsx("th",{children:c("workPage.col.era")}),t.jsx("th",{children:c("workPage.col.holder")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),t.jsx("tbody",{children:F.map(U=>{var $e;return t.jsx(kx,{row:U,measure:($e=h.get(U.id))==null?void 0:$e.measure_info,loaded:h.has(U.id),onNavigate:o,renderLink:r},`${U.id}:${h.has(U.id)?"r":"p"}`)})})]}),F.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(er,{total:T.rows.length,shown:F.length,unit:c("workPage.moreUnit"),onClick:()=>k(!0)}),T.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),V.length>0&&t.jsx(wx,{items:V,transport:n,onNavigate:o,renderLink:r}),We&&t.jsx(tt,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Pe=(U,$e)=>t.jsx(Xe,{id:U,label:p($e),onNavigate:o,renderLink:r,dense:!0}),Ee=g.useMemo(()=>{const U=new Map;for(const $e of I){const me=oa($e.relation,c);U.set(me,(U.get(me)??0)+1)}return U.size>1?[...U.entries()].sort(($e,me)=>me[1]-$e[1]).slice(0,4).map(([$e,me])=>`${p($e)} ${me}`).join(" · "):void 0},[I,p,c]),Z=t.jsxs(t.Fragment,{children:[t.jsx(Yt,{id:"collected",title:c("workPage.sec.collected"),items:L.map(U=>Pe(U.id,U.title))}),t.jsx(Yt,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:I.length}),sub:Ee,items:I.map(U=>t.jsxs(t.Fragment,{children:[Pe(U.id,U.title),t.jsx("span",{className:"bim-d-meta",title:U.note?p(U.note):void 0,children:p(oa(U.relation,c))})]}))}),t.jsx(Yt,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:P.map(({r:U,kind:$e})=>{const me=p((U.url?hn(U.url):void 0)||U.name),Ce=gn(U);return t.jsxs(t.Fragment,{children:[Ce?t.jsxs("a",{href:Ce,target:"_blank",rel:"noopener noreferrer",children:[me," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:me}),$e&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:$e})]})})})]});return t.jsx(Bn,{railTop:a,back:l,nav:ce,railLinks:d,main:ke,card:ve,side:Z})};function sa(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function aa(e,n){return n((e.url?hn(e.url):void 0)||e.name)}function kx({row:e,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:a,convert:l}=J(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],u=p?aa(p,l):e.locationName?l(e.locationName):"",m=e.images[0],h=m?gn(m):void 0,f=e.images.map(x=>aa(x,l)).join("、");return t.jsxs("tr",{"data-loading":o?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Xe,{id:e.id,label:l(e.name),onNavigate:r,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?a("workPage.inferredFromEdition"):void 0,children:d?l(d):o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${u?"":" bim-d-zt-blank"}`,children:[u||(o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(h?t.jsx("a",{className:"bim-d-flag",href:h,target:"_blank",rel:"noopener noreferrer",title:f,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:f,children:a("workPage.hasImage")}))})]})}function wx({items:e,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:a}=J(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[u,m]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const h=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(h.length===0)return;let f=!1;return Promise.all(h.map(x=>n.getItem(x).then(k=>{var y,w;return[x,((w=(y=k==null?void 0:k.authors)==null?void 0:y[0])==null?void 0:w.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||m(new Map(x.filter(([,k])=>k)))}),()=>{f=!0}},[n,e]),t.jsx(tt,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(et,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((h,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(h.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(h.source_bid??"")?a(u.get(h.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(h.source)].slice(0,9).map((x,k)=>t.jsx("span",{children:x},k))})]})},f))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[p.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:a(p.title_info)}),t.jsx(et,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(Xe,{id:p.source_bid,label:a(p.source),onNavigate:o,renderLink:r,dense:!0}):a(p.source),p.section?a(p.section):"",p.author_info?`${s("label.authorInfo")} ${a(p.author_info)}`:"",p.edition?`${s("label.edition")} ${a(p.edition)}`:"",p.page??""]}),p.summary&&t.jsx("p",{className:"bim-d-quote",children:ht(a(p.summary),void 0,{t:s})}),p.comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),t.jsx("p",{className:"bim-d-quote",children:ht(a(p.comment),void 0,{t:s})})]}),p.additional_comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),t.jsx("p",{className:"bim-d-quote",children:ht(a(p.additional_comment),void 0,{t:s})})]}),!p.summary&&!p.comment&&!p.additional_comment&&!p.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:a(e[c-1].source)}),onClick:()=>d(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",a(e[c-1].source)]})}):t.jsx("span",{"aria-hidden":"true"}),t.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",e.length]}),c<e.length-1?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:a(e[c+1].source)}),onClick:()=>d(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[a(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function Sx(e){var n;return{id:e.id,kind:"hypothetical",label:e.label,year:e.year??((n=e.year_range)==null?void 0:n[0]),year_range:e.year_range,year_uncertain:e.year_uncertain,group:e.group,note:e.note,description:e.description}}function _x(e,n){if(!e.lineage)return null;const o=e.lineage;return{id:e.id,kind:"book",label:e.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[e.id],note:o.note}}function la(e,n,o){return{id:`derive:${n.ref}->${e}:${o}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function $x(e,n,o){const[r,s]=[e,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 Cx(e,n){var p;if(n==="all")return null;const o=(p=e.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,a=r||s||!!(o!=null&&o.hypothetical_ids);if(!a&&n==="core"&&Array.isArray(e.core_books)&&e.core_books.length>0)return{books:new Set(e.core_books),hypos:e.core_hypotheticals?new Set(e.core_hypotheticals):null};if(!o||!a)return null;const l=r?new Set(o.groups):null,d=new Set(o.book_ids??[]);if(l&&e.node_groups)for(const[u,m]of Object.entries(e.node_groups))l.has(m)&&d.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),l){c||(c=new Set);for(const u of e.hypothetical_nodes??[])u.group&&l.has(u.group)&&c.add(u.id)}return{books:d,hypos:c}}function ai(e,n,o){const r=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const a=new Set(r.excluded_books??[]),l=r.node_groups??{},d=Cx(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,m=new Set,h=new Set;if(c){const S=new Map(n.map(N=>[N.id,N])),v=new Map((r.hypothetical_nodes??[]).map(N=>[N.id,N])),$=N=>{const T=S.get(N);if(T&&T.lineage)return(T.lineage.derived_from??[]).map(R=>R.ref);const F=v.get(N);return F?(F.derived_from??[]).map(R=>R.ref):[]},_=N=>v.has(N)?!u||u.has(N):!p||p.has(N),C=new Set,M=N=>{if(!C.has(N)){C.add(N);for(const T of $(N))a.has(T)||(_(T)||(v.has(T)?h.add(T):S.has(T)&&m.add(T)),M(T))}};for(const N of n)p&&p.has(N.id)&&!a.has(N.id)&&M(N.id);for(const N of r.hypothetical_nodes??[])u&&u.has(N.id)&&M(N.id)}const f=n.filter(S=>!a.has(S.id)).filter(S=>!p||p.has(S.id)||m.has(S.id)).map(S=>{const v=_x(S,l);return v&&m.has(S.id)&&(v.bridge=!0),v}).filter(S=>S!==null),x=(r.hypothetical_nodes??[]).filter(S=>!u||u.has(S.id)||h.has(S.id)).map(S=>{const v=Sx(S);return h.has(S.id)&&(v.bridge=!0),v}),k=[...f,...x],y=new Set(k.map(S=>S.id)),w=new Set,b=[],j=S=>{w.has(S.id)||!y.has(S.source)||!y.has(S.target)||(w.add(S.id),b.push(S))};for(const S of n)a.has(S.id)||!S.lineage||p&&!p.has(S.id)&&!m.has(S.id)||((S.lineage.derived_from??[]).forEach((v,$)=>{j(la(S.id,v,$))}),(S.lineage.related_to??[]).forEach((v,$)=>{j($x(S.id,v,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!h.has(S.id)||(S.derived_from??[]).forEach((v,$)=>{j(la(S.id,v,$))});return{nodes:k,edges:b,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(a)}}function Bc(e,n,o){const r=(e??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function zx(e,n){const o=[],r=e.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),a=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.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"&&!a.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 Wc=({graph:e,renderLink:n,className:o,style:r})=>{const{t:s,convert:a}=J();if(!e.nodes.length)return t.jsx("div",{style:{...Fx,...r},className:o,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const f of e.edges)if(f.kind==="derive"){const x=l.get(f.target)??[];x.push(f),l.set(f.target,x)}else for(const x of[f.source,f.target]){const k=d.get(x)??[];k.push(f),d.set(x,k)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,u=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else u.push(f);const m=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(m)),u.sort(m);const h=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:o,style:{...Nx,...r},children:[e.title&&t.jsx("div",{style:Rx,children:a(e.title)}),e.description&&t.jsx("div",{style:Ex,children:a(e.description)}),h.map(f=>t.jsx(ca,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),u.length>0&&t.jsx(ca,{label:s("lineage.otherGroup"),nodes:u,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},ca=({label:e,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=J();return t.jsxs("div",{style:Ix,children:[t.jsx("div",{style:{...Lx,borderLeftColor:n??i("widget-border")},children:d(e)}),o.map(c=>t.jsx(Tx,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Tx=({node:e,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=J();return t.jsxs("div",{style:{...Ax,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?i("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:Px,children:[t.jsx("span",{style:Mx,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Bx,children:Bc(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Wx,children:[e.category&&t.jsx(zn,{children:c(e.category)}),e.status==="lost"&&t.jsx(zn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(zn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(zn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(zn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Ox,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Hx,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:pa,children:[t.jsx("div",{style:ua,children:d("lineage.sources")}),n.map(p=>{const u=r.get(p.source);return t.jsxs("div",{style:ma(p.confidence),children:[t.jsx("span",{style:ha,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(da,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ga,children:["· ",c(p.evidence)]})]},p.id)})]}),o.length>0&&t.jsxs("div",{style:pa,children:[t.jsx("div",{style:ua,children:d("lineage.related")}),o.map(p=>{const u=p.source===e.id?p.target:p.source,m=r.get(u);return t.jsxs("div",{style:ma(p.confidence),children:[t.jsx("span",{style:ha,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??u)}),t.jsx(da,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ga,children:["· ",c(p.evidence)]})]},p.id)})]})]})},zn=({children:e,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 t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:e})},da=({level:e})=>{const{t:n}=J(),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")}}[e];return r?t.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},Nx={fontSize:"14px",color:i("fg")},Rx={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Ex={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},Ix={marginBottom:"16px"},Lx={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},Ax={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},Px={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Mx={fontSize:"15px",fontWeight:600},Bx={fontSize:"12px",color:i("muted")},Wx={marginBottom:"6px"},Ox={fontSize:"12px",color:i("muted"),margin:"2px 0"},Hx={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},pa={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},ua={fontSize:"11px",color:i("muted"),marginBottom:"2px"},ma=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),ha={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},ga={fontSize:"11px",color:i("muted")},Fx={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},Oc=({selectedNodeId:e,...n})=>{const{t:o}=J(),[r,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return Dx().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),r==="loading"?t.jsx("div",{style:xa,children:o("lineage.graphLoading")}):r==="missing"||!a?t.jsxs("div",{style:xa,children:[t.jsx("div",{children:fa(o("lineage.graphMissing"),{xyflow:t.jsx("code",{children:"@xyflow/react"}),dagre:t.jsx("code",{children:"@dagrejs/dagre"})})}),t.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:fa(o("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Ux,{modules:a,selectedNodeId:e,...n})};function fa(e,n){return e.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function Dx(){try{const[e,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:e.ReactFlow,Background:e.Background,Controls:e.Controls,Handle:e.Handle,Position:e.Position,BaseEdge:e.BaseEdge,EdgeLabelRenderer:e.EdgeLabelRenderer,getSmoothStepPath:e.getSmoothStepPath,dagre:n,cssLoaded:o}}catch{return null}}const Ux=({graph:e,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:u,Position:m,BaseEdge:h,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:k}=l,y=g.useMemo(()=>({lineage:$=>{var I,P,V,X;const _=((I=$.data)==null?void 0:I.stepPosition)??.85,[C,M,N]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),T=!!((P=$.data)!=null&&P.isSibling),F=T?M:$.targetX-18,R=T?N:$.targetY-12,E=(V=$.data)==null?void 0:V.labelStyle,L=(X=$.data)==null?void 0:X.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(h,{id:$.id,path:C,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F}px,${R}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...L,...E},children:$.label})})]})}}),[h,f,x]),w=g.useMemo(()=>({version:$=>{const{t:_}=J(),C=$.data,M=C.kind==="hypothetical",N=C.status==="lost",T=C.isSelected,F=C.bridge,R=C.borderColor??i("muted"),E=F||M?"dashed":"solid",L=F?.5:N?.6:1;return t.jsxs("div",{style:{background:i(F?"bg-subtle":"bg"),border:`2px ${E} ${T?i("primary"):R}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:L,boxShadow:T?i("shadow-node-selected"):M||F?"none":i("shadow-node")},title:F?_("lineage.bridgeTitle"):void 0,children:[t.jsx(u,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:M||!C.renderLink?C.label:C.renderLink(C.bookId,C.label)}),C.description&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:C.description}),C.yearText&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:Bc(C.yearText,void 0,C.uncertain)}),N&&t.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:_("lineage.lost")}),t.jsx(u,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[u,m]),{convert:b}=J(),{rfNodes:j,rfEdges:S}=g.useMemo(()=>Vx(e,k,n,a,b),[e,k,n,a,b]);return t.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:t.jsxs(d,{nodes:j,edges:S,nodeTypes:w,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[t.jsx(c,{gap:16}),t.jsx(p,{showInteractive:!1})]})})};function Vx(e,n,o,r,s=a=>a??""){const d=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:d?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const p=new Map(e.groups.map(w=>[w.id,w.color??i("muted")]));for(const w of e.nodes)c.setNode(w.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const w of e.edges)w.kind==="derive"&&(u.has(w.relation)||c.setEdge(w.source,w.target));n.layout(c);const m=e.nodes.map(w=>{const b=c.node(w.id),j=r?w.id===r:void 0,S={kind:w.kind,label:s(w.label),bookId:w.kind==="book"?w.id:void 0,yearText:s(w.year_text??Yx(w)),uncertain:w.year_uncertain,category:w.category,status:w.status,borderColor:w.group?p.get(w.group):void 0,renderLink:o,isSelected:j,description:s(w.description),bridge:w.bridge};return{id:w.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:S,draggable:!1,selected:j}}),h=.78,f=.06,x=new Map;for(const w of e.edges)w.kind==="derive"&&(x.has(w.source)||x.set(w.source,[]),x.get(w.source).push(w));const k=new Map;for(const[w,b]of x){if(b.length<=1)continue;const j=[...b].sort((v,$)=>{var M,N;const _=((M=c.node(v.target))==null?void 0:M.y)??0,C=((N=c.node($.target))==null?void 0:N.y)??0;return _-C}),S=j.length;j.forEach((v,$)=>{const _=($-(S-1)/2)*f;k.set(v.id,h+_)})}const y=e.edges.map(w=>Gx(w,k.get(w.id),s));return{rfNodes:m,rfEdges:y}}function Gx(e,n,o=r=>r??""){const r=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Kx(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:o(e.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function Yx(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Kx(e){switch(e){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 xa={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},zr=({graph:e,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:u,style:m})=>{var S;const{t:h,convert:f}=J(),[x,k]=g.useState(n),y=v=>{k(v),a==null||a(v)},w=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:h("lineage.collectionAll"),description:h("lineage.collectionAllDesc")}]]})(),b=!!(d&&w.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:h("lineage.empty")});const j=l?(S=c==null?void 0:c[l])==null?void 0:S.description:void 0;return t.jsxs("div",{className:u,style:m,children:[t.jsxs("div",{style:qx,children:[t.jsx("button",{onClick:()=>y("list"),style:io(x==="list"),children:h("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:io(x==="graph"),children:h("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:i("muted"),marginRight:4},children:h("lineage.collectionLabel")}),w.map(([v,$])=>{const _=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:io(l===v),title:$.description?f($.description):void 0,children:[f($.label),_!=null?` ${_}`:""]},v)})]})]}),b&&j&&t.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:f(j)}),x==="list"?t.jsx(Wc,{graph:e,renderLink:o}):t.jsx(Oc,{graph:e,renderLink:o,height:r,selectedNodeId:s})]})},qx={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},io=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:e?i("primary"):"transparent",color:i(e?"primary-fg":"fg"),cursor:"pointer"}),ba=40,ya=2,Xx=9,Zx=new Set(["certain","consensus","probable","disputed"]);function oo(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Hc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:u})=>{var Re,H,de,ee,ye,Se,Be,De,Je,He,Ue;const m=Te(),{t:h,convert:f}=J(),[x,k]=g.useState(null),[y,w]=g.useState(new Map),[b,j]=g.useState([]),[S,v]=g.useState(new Map),[$,_]=g.useState(!1),[C,M]=g.useState("flow"),[N,T]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){k(null);return}let z=!1;return n.getItem(e.work_id).then(ie=>{!z&&ie&&ie.type==="work"&&k(ie)}).catch(()=>{}),()=>{z=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let z=!1;return n.getLineageGraph(e.work_id).then(ie=>{z||T(ie&&ie.nodes.length>1?ie:null)}).catch(()=>{z||T(null)}),()=>{z=!0}},[n,e.work_id]),g.useEffect(()=>{const z=e.contained_in||[];if(!n||z.length===0){w(new Map);return}let ie=!1;return Promise.all(z.map(ae=>{const be=typeof ae=="string"?ae:ae.id;return n.getItem(be).then(je=>[be,je]).catch(()=>[be,null])})).then(ae=>{if(ie)return;const be=new Map;for(const[je,ge]of ae)ge&&be.set(je,ge);w(be)}),()=>{ie=!0}},[n,e.contained_in]);const F=g.useMemo(()=>{const z=new Set([...(x==null?void 0:x.books)||[],...e.related_books||[]]);return z.add(e.id),[...z]},[x==null?void 0:x.books,e.related_books,e.id]),R=F.length-1;g.useEffect(()=>{if(!n||R<=0){j([]);return}const z=F.length<=ba,ie=z?F:F.slice(0,8);let ae=!1;return Promise.all(ie.map(be=>be===e.id?Promise.resolve({id:be,title:e.title,edition:e.edition,year:di(e)}):n.getItem(be).then(je=>{const ge=je??{};return{id:be,title:ge.title,edition:ge.edition,year:je?di(ge):void 0}}).catch(()=>({id:be})))).then(be=>{if(ae)return;const je=be.filter(ge=>ge.id===e.id||ge.title||ge.edition);z&&je.sort((ge,Ie)=>(ge.year??1/0)-(Ie.year??1/0)),j(je)}),()=>{ae=!0}},[n,F,R,e]);const E=e.lineage,L=g.useMemo(()=>[...((E==null?void 0:E.derived_from)||[]).filter(z=>z.ref_type==="book").map(z=>z.ref),...((E==null?void 0:E.related_to)||[]).map(z=>z.book_id)].filter(Boolean),[E]);g.useEffect(()=>{if(!n||L.length===0){v(new Map);return}let z=!1;return Promise.all(L.map(ie=>n.getItem(ie).then(ae=>[ie,{id:ie,title:ae==null?void 0:ae.title,edition:ae==null?void 0:ae.edition}]).catch(()=>[ie,{id:ie}]))).then(ie=>{z||v(new Map(ie))}),()=>{z=!0}},[n,L]);const I=g.useMemo(()=>Lc(e.resources,e.resource_groups,h),[e.resources,e.resource_groups,h]),P=I.groups.reduce((z,ie)=>z+ie.rows.length+ie.mirrors.length,0),V=I.groups.length>0&&I.groups.every(z=>z.key==="_physical"),X=Mn(e),D=Ll(e),O=Nt(e,m.unit.juan),A=new Set((e.contained_in||[]).map(z=>typeof z=="string"?0:In(z.volume_index).length).filter(z=>z>0)),G=z=>{var be;const ie=(be=e.base_edition)==null?void 0:be.find(je=>je.book_id===z&&je.name);if(ie!=null&&ie.name)return ie.name;const ae=S.get(z);return(ae==null?void 0:ae.edition)||(ae==null?void 0:ae.title)||""},se=g.useMemo(()=>{var fe,Ne,q,ue,re;const z=[];D&&z.push({label:h("bookPage.fact.editionType"),value:f(D),title:e.edition_type||(fe=e.lineage)!=null&&fe.category?void 0:h("bookPage.inferredFromEdition")}),(Ne=e.publication_info)!=null&&Ne.details?z.push({label:h("bookPage.fact.publication"),value:f(e.publication_info.details)}):(X.era||X.reign)&&z.push({label:h("bookPage.fact.era"),value:f([X.era,X.reign].filter(Boolean).join(" ")),title:X.source==="edition"?h("bookPage.inferredFromEdition"):void 0}),O&&z.push({label:h("bookPage.fact.measure"),value:f(O)});const ie=(e.contained_in||[]).flatMap(we=>typeof we=="string"?[]:In(we.volume_index));ie.length&&z.push({label:h("bookPage.fact.volumes"),value:h("bookPage.volumesValue",{range:_i(ie,m.unit.volume),unit:m.unit.volume,n:ie.length})});const ae=(((q=e.lineage)==null?void 0:q.derived_from)||[]).find(we=>we.relation==="底本"&&we.ref_type==="book");ae&&G(ae.ref)&&z.push({label:h("bookPage.fact.baseEdition"),value:t.jsx(Xe,{id:ae.ref,label:f(G(ae.ref)),onNavigate:o,renderLink:r,dense:!0})});const be=(e.base_edition||[]).filter(we=>we&&we.name);for(const we of["底本","配補","參校"]){if(we==="底本"&&ae&&G(ae.ref))continue;const Ve=be.filter(Oe=>Oe.role===we);Ve.length&&z.push({label:f(we),value:Ve.map((Oe,lt)=>t.jsxs(g.Fragment,{children:[lt>0&&"、",Oe.book_id?t.jsx(Xe,{id:Oe.book_id,label:f(Oe.name),onNavigate:o,renderLink:r,dense:!0}):f(Oe.name)]},lt))})}const je=(e.provenance||[]).filter(we=>we&&we.institution),ge=(e.resources||[]).filter(we=>(we.types||(we.type?[we.type]:[])).includes("physical"));if(je.length){z.push({label:h("bookPage.fact.holdings"),value:je.slice(0,2).map(Oe=>f(Oe.institution)).join("、")+(je.length>2?h("bookPage.andMorePlaces",{n:je.length}):"")});const we=je.filter(Oe=>Oe.call_number).slice(0,2).map(Oe=>`${f(Oe.institution)} ${Oe.call_number}`);we.length&&z.push({label:h("bookPage.fact.callNumber"),value:we.join(";")+(je.filter(Oe=>Oe.call_number).length>2?"…":"")});const Ve=je.flatMap(Oe=>Oe.seals||[]).filter(Boolean);Ve.length&&z.push({label:h("bookPage.fact.seals"),value:f(Ve.join("、"))})}else ge.length?z.push({label:h("bookPage.fact.holdings"),value:ge.slice(0,2).map(we=>f(we.name)).join("、")+(ge.length>2?h("bookPage.andMorePlaces",{n:ge.length}):"")}):(ue=e.current_location)!=null&&ue.name&&z.push({label:h("bookPage.fact.holdings"),value:f(e.current_location.name)});const Ie=e.physical_description;if(Ie){const we=[[h("bookPage.fact.leafStyle"),Ie.leaf_style],[h("bookPage.fact.binding"),Ie.binding],[h("bookPage.fact.dimensions"),Ie.dimensions],[h("bookPage.fact.condition"),Ie.condition]];for(const[Ve,Oe]of we)Oe&&Oe.trim()&&z.push({label:Ve,value:f(Oe)})}(re=e.page_count)!=null&&re.description&&z.push({label:m.label.pageCount,value:f(e.page_count.description)});const K=[...ko(e.additional_titles),...ko(e.attached_texts)];return K.length&&z.push({label:h("bookPage.fact.aliases"),value:K.map(f).join("、")}),z},[e,f,m,h,X,D,O,S,o,r]),Q=f(e.title),ve=e.edition?f(e.edition):void 0,ne=((Re=e.lineage)==null?void 0:Re.year_text)||"",ce=t.jsx(Wn,{kind:h("bookPage.kind"),title:Q,subtitle:ve,byline:t.jsx($r,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:o,renderLink:r}),meta:(()=>{const z=[D?f(D):"",X.era?f([X.era,X.reign].filter(Boolean).join("")):"",O?f(O):""].filter(Boolean);return z.length?t.jsx("span",{className:"bim-d-tags",children:z.map((ie,ae)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(ae,2)}`,children:ie},ae))}):null})(),description:(H=e.description)!=null&&H.text?t.jsx(Tt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:nr((de=e.description)==null?void 0:de.text)?6:void 0,facts:se,readAction:s,secondaryAction:s&&P>0&&!V?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:h("bookPage.viewImages")}):void 0,foot:t.jsx(On,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),We=e.contained_in||[],ke=(a==null?void 0:a.chapters)||[],Pe=f(ke[0]&&oo(ke[0].title)[0].slice(-1)||"")||h("bookPage.chapterUnit"),Ee=h("bookPage.chapterCount",{n:ke.length,unit:Pe}),Z=!!((ee=E==null?void 0:E.derived_from)!=null&&ee.length||(ye=E==null?void 0:E.related_to)!=null&&ye.length||(Se=e.appendix)!=null&&Se.length),le=[],oe=h(V?"bookPage.sec.physical":"bookPage.sec.images");(ke.length||I.text.length||l)&&le.push({id:"fulltext",label:h("bookPage.sec.fulltext"),count:ke.length?Ee:void 0}),I.groups.length&&le.push({id:"images",label:oe,count:P}),Z&&le.push({id:"lineage",label:h("bookPage.sec.lineage")}),We.length&&le.push({id:"collections",label:h("section.containedIn"),count:We.length}),(Be=e.location_history)!=null&&Be.length&&le.push({id:"provenance",label:h("section.locationHistory")});const he=z=>(d==null?void 0:d(z))??null,U=ke[0],$e=U?he(U.file):null,me=$?ke:ke.slice(0,Xx),Ce=(z,ie,ae)=>z?t.jsx("a",{className:ae,href:z.href??"#",onClick:z.onClick?be=>{be.metaKey||be.ctrlKey||(be.preventDefault(),z.onClick())}:void 0,children:ie}):t.jsx("span",{className:ae,children:ie}),Y=t.jsxs(t.Fragment,{children:[(ke.length>0||I.text.length>0||l)&&t.jsxs(tt,{id:"fulltext",title:h("bookPage.sec.fulltext"),meta:ke.length>0?t.jsx(et,{items:[Ee,(De=a==null?void 0:a.source)!=null&&De.name?h("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!U&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[t.jsx("span",{className:"bim-d-ft-h",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "})]}),t.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),U&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:h("bookPage.readFrom",{ch:f(oo(U.title)[0])||h("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((U.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),Ce($e,t.jsxs(t.Fragment,{children:[h("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ke.length>1&&t.jsx("ul",{className:"bim-d-chap",children:me.map(z=>{const[ie,ae]=oo(z.title);return t.jsx("li",{children:Ce(he(z.file),t.jsxs(t.Fragment,{children:[ie&&t.jsx("b",{children:f(ie)}),f(ae||z.file)]}))},z.file)})}),ke.length>me.length&&t.jsx(tr,{label:h("detail.expandRest",{n:ke.length-me.length,unit:Pe}),onClick:()=>_(!0)}),I.text.length>0&&t.jsxs(t.Fragment,{children:[(ke.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:h("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:I.text.map((z,ie)=>t.jsx(Cr,{item:z,siblings:I.text,listedVolumeCounts:A},`${z.id||z.url||z.name}-${ie}`))})})]})]}),I.groups.length>0&&t.jsx(tt,{id:"images",title:oe,meta:t.jsx(et,{items:[I.groups.length>1?h("bookPage.groupCount",{n:I.groups.length}):"",h("bookPage.placeCount",{n:P})]}),children:t.jsx(Pc,{groups:I.groups,listedVolumeCounts:A})}),Z&&t.jsx(tt,{id:"lineage",title:h("bookPage.sec.lineage"),meta:(Je=E==null?void 0:E.derived_from)!=null&&Je.length?h("bookPage.lineageMeta"):void 0,action:N?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":h("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":C==="flow",onClick:()=>M("flow"),children:h("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":C==="graph",onClick:()=>M("graph"),children:h("bookPage.viewGraph")})]}):void 0,children:C==="graph"&&N?t.jsx(zr,{graph:N,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(z,ie)=>t.jsx(Xe,{id:z,label:f(ie),onNavigate:o,renderLink:r,dense:!0})}):t.jsx(Qx,{data:e,heading:ve||Q,yearText:ne,refName:G,onNavigate:o,renderLink:r})}),We.length>0&&t.jsx(tt,{id:"collections",title:h("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:We.map((z,ie)=>{var Ie,K;const ae=typeof z=="string"?z:z.id,be=typeof z=="string"?[]:In(z.volume_index),je=y.get(ae),ge=(je==null?void 0:je._member_count)||((Ie=je==null?void 0:je.books)==null?void 0:Ie.length)||((K=je==null?void 0:je.contained_works)==null?void 0:K.length)||0;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Xe,{id:ae,label:je?f(je.title):ae,onNavigate:o,renderLink:r,dense:!0}),be.length>0&&t.jsx(Jx,{volumes:be,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ge?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ge>0&&h("bookPage.totalOf",{n:ge,unit:m.unit.bu})})]},`${ae}-${ie}`)})})})}),(He=e.location_history)!=null&&He.length?t.jsx(tt,{id:"provenance",title:h("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((z,ie)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(z.name)}),([z.start_date,z.end_date].filter(Boolean).join("—")||z.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(et,{items:[[z.start_date,z.end_date].filter(Boolean).join("—"),z.description?f(z.description):""]})})]},ie))})}):null,le.length===0&&t.jsx(tt,{title:h("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:h("bookPage.emptyText")})})]}),ze=b.findIndex(z=>z.id===e.id),Me=F.length<=ba,B=Me&&ze>=0?b.slice(Math.max(0,ze-ya),ze+ya+1):b.filter(z=>z.id!==e.id),te=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(m.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(Xe,{id:x.id,label:f(x.title),onNavigate:o,renderLink:r})}),t.jsx(et,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(z=>`${z.dynasty?`〔${f(z.dynasty)}〕`:""}${f(z.name)}`),f(Nt(x,m.unit.juan)),x._edition_count?h("bookPage.editionCount",{n:x._edition_count}):""]}),((Ue=x.description)==null?void 0:Ue.text)&&t.jsx("p",{style:{fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc bim-d-side-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),R>0&&B.length>0&&t.jsxs("div",{children:[t.jsx(Yt,{id:"siblings",timeline:!0,title:Me?h("bookPage.siblings"):m.relation.siblingVersions,meta:Me?h("bookPage.byEra"):h("bookPage.kindCount",{n:R}),cap:B.length,items:B.map(z=>z.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(z.edition||z.title||z.id)}):t.jsx(Xe,{id:z.id,label:f(z.edition||z.title||z.id),onNavigate:o,renderLink:r,dense:!0})),metas:B.map(z=>[z.year!=null?z.year<0?h("detail.bce",{n:-z.year}):String(z.year):"",z.id===e.id?h("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:B.findIndex(z=>z.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(Xe,{id:x.id,label:h("bookPage.viewAllInWork",{n:F.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),xe=e.work_id?t.jsx(Al,{caption:m.section.belongsToWork,children:t.jsx(Xe,{id:e.work_id,label:x?f(x.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return t.jsx(Bn,{railTop:c,back:p,up:xe,nav:le,railLinks:u,main:Y,card:ce,side:te})};function Jx({volumes:e,unit:n}){const{t:o}=J();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:_i(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),o("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function Qx({data:e,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:a}){var w;const{t:l,convert:d}=J(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],u=p.filter(b=>b.ref_type!=="book"),m=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),h=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,k=b=>b&&Zx.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,j)=>t.jsx(Xe,{id:b,label:d(j||b),onNavigate:s,renderLink:a,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[x&&t.jsxs("ol",{className:"bim-d-lf-list",children:[u.map((b,j)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),k(b.confidence)]})]})},`a-${j}`)),m.map((b,j)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]})},`b-${j}`)),t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[t.jsxs("div",{className:"bim-d-lf-here",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:l("bookPage.lineage.thisEdition")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),o&&t.jsx("span",{className:"bim-d-lf-yr",children:d(o)})]}),h.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:h.map((b,j)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]},j))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,j)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,r(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},j))})]})]}),(w=e.appendix)==null?void 0:w.map((b,j)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Tt,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${j}`)),(c==null?void 0:c.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(c.note)})]})}const Tn=16,eb=200,tb=16,Fc=({data:e,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var Y,ze,Me,B,te,xe,Re;const{t:p,convert:u,messages:m}=J(),[h,f]=g.useState(""),[x,k]=g.useState(!1),[y,w]=g.useState(null),[b,j]=g.useState(""),[S,v]=g.useState(!1),$=g.useMemo(()=>El(e,n),[e,n]),[_,C]=g.useState(new Map),M=!!o&&$.rows.length>0&&$.rows.length<=eb,N=M&&($.rows.length<=Tn||S),T=N&&$.rows.every(H=>!H.id||_.has(H.id)),F=H=>{var de;return No(H?(de=_.get(H))==null?void 0:de.l1:void 0)},R=g.useMemo(()=>{const H=h.trim(),de=H?u(H):"";return $.rows.filter(ee=>{var Se,Be;if(b&&No(ee.id?(Se=_.get(ee.id))==null?void 0:Se.l1:void 0)!==b)return!1;if(!de)return!0;const ye=ee.id&&((Be=_.get(ee.id))==null?void 0:Be.title)||ee.title;return u(ye).includes(de)||(ee.subItems||[]).some(De=>u(De).includes(de))})},[$.rows,h,b,_,u]),E=x?R:R.slice(0,Tn),L=g.useMemo(()=>(N?$.rows:E).filter(H=>H.id&&!_.has(H.id)).map(H=>H.id),[N,$.rows,E,_]);g.useEffect(()=>{if(!o||L.length===0)return;let H=!1;const de=L.slice(0,tb);return Promise.all(de.map(ee=>o.getItem(ee).then(ye=>{var De,Je;const Se=ye??{},Be={title:Se.title,edition:Se.edition,authors:Se.authors,measure:ye?Nt(ye,m.unit.juan):void 0,versionCount:Se._edition_count??((De=Se.books)==null?void 0:De.length),l1:((Je=Se.classification)==null?void 0:Je.l1)||void 0};return[ee,Be]}).catch(()=>[ee,{}]))).then(ee=>{H||C(ye=>{const Se=new Map(ye);for(const[Be,De]of ee)Se.set(Be,De);return Se})}),()=>{H=!0}},[o,L,m.unit.juan]);const I=(e.contained_in||[])[0];g.useEffect(()=>{if(!I){w(null);return}if(w({id:I}),!o)return;let H=!1;return o.getItem(I).then(de=>{H||w({id:I,title:de==null?void 0:de.title})}).catch(()=>{}),()=>{H=!0}},[o,I]);const P=g.useMemo(()=>Lc(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),V=P.text.length+P.groups.reduce((H,de)=>H+de.rows.length+de.mirrors.length,0),X=e.contained_works||[],D=new Set($.rows.map(H=>H.id).filter(Boolean)),O=X.length>0&&!X.every(H=>D.has(H.id)),A=(()=>{const H=$.rows.map(de=>de.edition).filter(Boolean);return H.length>1&&new Set(H).size===1})(),G=$.rows.some(H=>H.volumes.length>0||H.expected!=null),se=e._member_count||((Y=e.books)==null?void 0:Y.length)||X.length,Q=e._members_truncated?se:$.rows.length,ve=Nt(e,m.unit.juan),ne=e.count,ce=H=>typeof H=="number"&&Number.isFinite(H)?H:null,We=ce(ne==null?void 0:ne.juan)??ce((ze=e.juan_count)==null?void 0:ze.number),ke=ce(ne==null?void 0:ne.ce)??($.totalVolumes||null),Pe=[{value:Q,label:p("collectionPage.stat.titles")},{value:We??0,label:m.unit.juan},{value:ke??0,label:m.unit.volume}],Ee=g.useMemo(()=>{var ee,ye;const H=[];if((ee=e.publication_info)!=null&&ee.details&&H.push({label:p("collectionPage.fact.publication"),value:u(e.publication_info.details)}),se&&(se!==$.rows.length||e._members_truncated)){const Se=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");H.push({label:Se,value:`${se} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const de=[ce(ne==null?void 0:ne.zhong)!=null?p("collectionPage.nZhong",{n:ne.zhong}):"",ce(ne==null?void 0:ne.han)!=null?p("collectionPage.nHan",{n:ne.han}):""].filter(Boolean);return de.length&&H.push({label:p("collectionPage.fact.expected"),value:de.join(" ")}),We==null&&ve&&H.push({label:p("collectionPage.fact.measure"),value:u(ve),title:(ye=e.juan_count)!=null&&ye.description?u(e.juan_count.description):void 0}),H},[e,se,$.rows.length,We,ve,ne,u,p,m]),Z=g.useMemo(()=>{if(!T)return[];const H=new Map;for(const ee of $.rows){const ye=F(ee.id);ye&&H.set(ye,(H.get(ye)??0)+1)}const de=An.filter(ee=>(H.get(ee.key)??0)>0);return de.length<2?[]:[{key:"",label:`${m.catalog.all} ${Q}`},...de.map(ee=>({key:ee.key,label:`${ee.label} ${H.get(ee.key)}`}))]},[T,$.rows,_,m]),le=g.useMemo(()=>{if(!T||!$.rows.some(ye=>ye.volumes.length>0))return null;const H=[],de=$.rows.filter(ye=>ye.volumes.length>0).map(ye=>({k:F(ye.id)??"",from:Math.min(...ye.volumes),to:Math.max(...ye.volumes)})).sort((ye,Se)=>ye.from-Se.from);for(const ye of de){const Se=ye.to-ye.from+1,Be=H[H.length-1];Be&&Be.key===ye.k?(Be.to=Math.max(Be.to,ye.to),Be.n+=Se):H.push({key:ye.k,from:ye.from,to:ye.to,n:Se})}const ee=de.reduce((ye,Se)=>Math.max(ye,Se.to),0);return H.length>1&&H.some(ye=>ye.key)?{segs:H,last:ee}:null},[T,$.rows,_]),oe=(Me=e.description)==null?void 0:Me.text,he=t.jsx(Wn,{kind:p("collectionPage.kind"),title:u(e.title),byline:t.jsx($r,{authors:e.authors,onNavigate:r,renderLink:s}),meta:t.jsx(et,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(B=e.publication_info)!=null&&B.year?u(e.publication_info.year):""]}),description:oe||(te=e.history)!=null&&te.length?t.jsxs(t.Fragment,{children:[oe&&t.jsx(Tt,{text:oe,style:{fontSize:15,lineHeight:1.85}}),(xe=e.history)!=null&&xe.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((H,de)=>t.jsx("li",{children:u(H)},de))}):null]}):void 0,clampDescription:nr(oe)||(((Re=e.history)==null?void 0:Re.length)??0)>2?6:void 0,stats:Pe,facts:Ee,foot:t.jsx(On,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:le&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:p("collectionPage.dist.head")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":p("collectionPage.dist.head"),children:le.segs.map((H,de)=>{const ee=An.find(ye=>ye.key===H.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!ee,title:ee?p("collectionPage.dist.segTitle",{section:u(ee.label),from:H.from,to:H.to}):void 0,"aria-label":ee?p("collectionPage.dist.only",{section:u(ee.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!ee&&b===H.key,style:{flexGrow:H.n,background:i(ee?ee.token:"rule")},onClick:()=>{ee&&(j(b===H.key?"":H.key),k(!1))}},de)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:p("catalog.volume",{n:1})}),t.jsx("span",{children:p("collectionPage.dist.hint")}),t.jsx("span",{children:p("catalog.volume",{n:le.last})})]})]})}),U=[];$.rows.length&&U.push({id:"titles",label:p("collectionPage.sec.titles"),count:Q}),V&&U.push({id:"resources",label:p("collectionPage.sec.resources"),count:V}),O&&U.push({id:"works",label:m.section.containedWorks,count:X.length});const $e=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(tt,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(et,{items:[`${Q} ${m.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:m.unit.volume}):"",R.length!==Q?p("collectionPage.currentN",{n:R.length,unit:m.unit.items}):""]}),action:a,children:[($.rows.length>Tn||Z.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Z.length>0&&t.jsx($i,{items:Z,value:b,onChange:H=>{j(H),k(!1)}}),M&&$.rows.length>Tn&&!T&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:S,onClick:()=>v(!0),title:p("collectionPage.loadAllTitle",{n:$.rows.length,unit:m.unit.items}),children:p(S?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),$.rows.length>Tn&&t.jsx("input",{type:"search",className:"bim-d-find",value:h,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:H=>{f(H.target.value),k(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Ci(R.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[G&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:E.map((H,de)=>{var He;const ee=H.id?_.get(H.id):void 0,ye=ee!=null&&ee.title&&H.title===H.id?ee.title:H.title,Se=((ee==null?void 0:ee.authors)||[]).find(Ue=>Ue&&Ue.name),Be=[Se?`${Se.dynasty?`〔${u(Se.dynasty)}〕`:""}${u(Se.name)}${Se.role?` ${u(Se.role)}`:""}`:"",ee!=null&&ee.measure?u(ee.measure):"",(He=H.subItems)!=null&&He.length?H.subItems.map(Ue=>u(Ue)).join("、"):"",(ee!=null&&ee.edition||H.edition)&&!A?u((ee==null?void 0:ee.edition)||H.edition||""):""].filter(Boolean),De=An.find(Ue=>Ue.key===F(H.id)),Je=H.volumes.length>0?p("collectionPage.volumeRange",{range:_i(H.volumes,m.unit.volume),unit:m.unit.volume}):H.expected!=null?`${H.found??0}/${H.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[G&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Je?"":" bim-d-zt-blank"}`,children:[De&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(De.token)}}),Je||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[H.id?t.jsx(Xe,{id:H.id,label:u(ye),onNavigate:r,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:u(ye)}),Be.length>0?t.jsx(et,{items:Be}):H.id&&!ee&&o?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ee!=null&&ee.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ee!=null&&ee.versionCount?p("collectionPage.nZhong",{n:ee.versionCount}):""})]},`${H.id??H.title}-${de}`)})})]}),E.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(er,{total:R.length,shown:E.length,unit:m.unit.items,onClick:()=>k(!0)})]}),V>0&&t.jsxs(tt,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:V}),children:[P.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[P.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:P.text.map((H,de)=>t.jsx(Cr,{item:H,siblings:P.text},`${H.id||H.url||H.name}-${de}`))})})]}),t.jsx(Pc,{groups:P.groups})]}),$.rows.length===0&&V===0&&t.jsx(tt,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),me=O?t.jsx(Yt,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:X.length}),cap:12,items:X.map(H=>t.jsx(Xe,{id:H.id,label:u(H.title),onNavigate:r,renderLink:s,dense:!0}))}):null,Ce=y?t.jsx(Al,{caption:p("collectionPage.parent"),children:t.jsx(Xe,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return t.jsx(Bn,{railTop:l,back:d,up:Ce,nav:U,railLinks:c,main:$e,card:he,side:me})},nb=16,ro=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function ja(e){if(!e)return ro.length;const n=ro.indexOf(e);return n===-1?ro.length:n}function ib(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const ob={秦:[-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]},Dc=({data:e,transport:n,onNavigate:o,renderLink:r,railTop:s,back:a,railLinks:l})=>{var me,Ce,Y,ze,Me;const{t:d,convert:c,messages:p}=J(),u=B=>ib(B,d),[m,h]=g.useState("全部"),[f,x]=g.useState(!1),[k,y]=g.useState("default"),[w,b]=g.useState(new Map),j=g.useMemo(()=>(e.works||[]).map(B=>{const te=w.get(B.work_id);return{id:B.work_id,title:(te==null?void 0:te.title)??B.title??B.work_id,role:B.role||"",cls:Jo(B.role),versionCount:te==null?void 0:te.versionCount,section:te==null?void 0:te.cls,l1:te==null?void 0:te.l1,measure:te==null?void 0:te.measure,hasImage:te==null?void 0:te.hasImage,loaded:!!(te!=null&&te.loaded)}}),[e.works,w]),S=g.useMemo(()=>Rl((e.works||[]).map(B=>B.role),d("detail.roleAll")),[e.works,d]),v=g.useMemo(()=>{const B=m==="全部"?j:j.filter(te=>te.cls===m);return k==="versions"?[...B].sort((te,xe)=>(xe.versionCount??-1)-(te.versionCount??-1)):B},[j,m,k]),$=f?v:v.slice(0,nb),_=g.useMemo(()=>$.filter(B=>!w.has(B.id)).map(B=>B.id),[$,w]);g.useEffect(()=>{if(!n||_.length===0)return;let B=!1;return Promise.all(_.map(te=>n.getItem(te).then(xe=>{var ee,ye,Se,Be,De;const Re=xe??{},H=Re._edition_count??(((ee=Re.books)==null?void 0:ee.length)??0)+(((ye=Re.collections)==null?void 0:ye.length)??0),de=[(Se=Re.classification)==null?void 0:Se.l1,(Be=Re.classification)==null?void 0:Be.l2].filter(Boolean).join(" ");return[te,{id:te,title:Re.title,versionCount:H,loaded:!0,cls:de||void 0,l1:((De=Re.classification)==null?void 0:De.l1)||void 0,measure:xe&&Nt(xe,p.unit.juan)||void 0,hasImage:!!(Re.has_image??Re._has_image)}]}).catch(()=>[te,{id:te,loaded:!0}]))).then(te=>{B||b(xe=>{const Re=new Map(xe);for(const[H,de]of te)Re.set(H,de);return Re})}),()=>{B=!0}},[n,_,p.unit.juan]);const C=g.useMemo(()=>{const B=new Map;for(const te of e.alt_names||[]){const xe=te.type||p.section.aliases;B.has(xe)||B.set(xe,[]),B.get(xe).push(te.name)}return[...B.entries()].sort((te,xe)=>ja(te[0])-ja(xe[0])).map(([te,xe])=>({label:te,names:xe}))},[e.alt_names,p]),M=e.birth_year??((me=e.dates)==null?void 0:me.birth)??void 0,N=e.death_year??((Ce=e.dates)==null?void 0:Ce.death)??void 0,T=(Y=e.dates)==null?void 0:Y.floruit,F=M!=null||N!=null?`${u(M)||"?"}—${u(N)||"?"}`:Array.isArray(T)&&T.length===2&&T.every(B=>Number.isFinite(B))?d("entityPage.floruit",{from:u(T[0]),to:u(T[1])}):"",R=new Set(["本名","字","號","号"]),E=C.filter(B=>R.has(B.label)),L=C.filter(B=>!R.has(B.label)),I=L.reduce((B,te)=>B+te.names.length,0),P=g.useMemo(()=>{const B=[];for(const xe of E)B.push({label:xe.label,value:xe.names.map(Re=>c(Re)).join("、")});const te=(e.works||[]).length;return te&&B.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:te})}),B},[e.works,E,c,d]),V=B=>{var te;return(te=C.find(xe=>B.includes(xe.label)))==null?void 0:te.names[0]},X=V(["字"]),D=V(["號","号"]),O=[X?d("entityPage.zi",{name:c(X)}):"",D?d("entityPage.hao",{name:c(D)}):""].filter(Boolean).join(","),A=e.native_place,G=e.dynasty?ob[e.dynasty]:void 0,se=(()=>{if(!G||M==null||N==null||N<M)return null;const[B,te]=G,xe=Math.max(M,B),Re=Math.min(N,te);if(Re<=xe)return null;const H=te-B;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":d("entityPage.lifeAria",{birth:u(M),death:u(N),years:N-M+1}),children:t.jsx("i",{style:{left:`${(xe-B)/H*100}%`,width:`${(Re-xe)/H*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${u(B)} ${c(e.dynasty)}`}),t.jsx("span",{children:d("entityPage.lifeYears",{years:N-M+1})}),t.jsx("span",{children:u(te)})]})]})})(),Q=g.useMemo(()=>{if(!n||j.length===0||j.some(xe=>!xe.loaded))return null;const B=new Map;for(const xe of j){const Re=No(xe.l1);Re&&B.set(Re,(B.get(Re)??0)+1)}const te=An.map(xe=>({...xe,n:B.get(xe.key)??0})).filter(xe=>xe.n>0);return te.length?te:null},[j,n]),ve=t.jsxs(Wn,{kind:p.entityPage.subtype[e.subtype]??d("entityPage.subtype.people"),title:c(e.primary_name||e.title),subtitle:O||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(et,{items:[e.dynasty?c(e.dynasty):"",F,A?d("entityPage.nativePlace",{place:c(A)}):""]}),se]}),description:(ze=e.description)!=null&&ze.text?t.jsx(Tt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:nr((Me=e.description)==null?void 0:Me.text)?6:void 0,facts:P,foot:t.jsx(On,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[I>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:d("entityPage.moreNames",{n:I})}),t.jsx("dl",{children:L.map(B=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(B.label)}),t.jsx("dd",{children:B.names.map(te=>c(te)).join("、")})]},B.label))})]}),Q&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:d("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:Q.map(B=>t.jsx("i",{style:{flexGrow:B.n,background:i(B.token)}},B.key))}),t.jsx("div",{className:"bim-d-dist-key",children:Q.map(B=>t.jsxs("span",{children:[t.jsx("i",{style:{background:i(B.token)}}),c(B.label)," ",B.n]},B.key))})]})]}),ne=g.useMemo(()=>j.filter(B=>B.loaded&&(B.versionCount??0)>0).sort((B,te)=>(te.versionCount??0)-(B.versionCount??0)).slice(0,3),[j]),ce=!!n&&j.length>=3&&$.some(B=>!B.loaded),We=m==="全部"&&(ce||ne.length>=2),ke=e.external_ids||{},Pe=[];ke.cbdb_id!=null&&Pe.push({label:"CBDB",id:String(ke.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ke.cbdb_id}`,note:ke.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const Ee=ke.wikidata_id;Ee&&Pe.push({label:"Wikidata",id:Ee,href:`https://www.wikidata.org/wiki/${Ee}`});const Z=ke.viaf_id;Z&&Pe.push({label:"VIAF",id:Z,href:`https://viaf.org/viaf/${Z}`});const le=S.map(B=>({key:B.cls,label:`${B.label} ${B.count}`})),oe=[...We&&!ce?[{id:"featured",label:d("entityPage.sec.featured"),count:ne.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...Pe.length?[{id:"external",label:d("entityPage.sec.external"),count:Pe.length}]:[]],he=We?t.jsxs(tt,{id:"featured",title:d("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:d("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":ce||void 0,children:[ce&&[0,1,2].map(B=>t.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[t.jsx("span",{className:"bim-d-pick-t",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "}),t.jsx("div",{className:"bim-d-pick-n",children:" "})]},B)),!ce&&ne.map(B=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(Xe,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0})}),t.jsx(et,{items:[B.section?c(B.section):"",B.measure?c(B.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:B.versionCount}),t.jsx("span",{children:d("entityPage.versionsUnit")}),B.hasImage&&t.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},B.id))]})]}):null,U=j.length===0?t.jsx(tt,{title:d("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[he,t.jsxs(tt,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(et,{items:[d("entityPage.total",{n:j.length}),v.length!==j.length?d("entityPage.current",{n:v.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[le.length>1&&t.jsx($i,{items:le,value:m,onChange:B=>{h(B),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":k==="versions",onClick:()=>{k==="default"&&x(!0),y(B=>B==="default"?"versions":"default")},children:d(k==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Ci(v.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:d("entityPage.col.work")}),t.jsx("th",{children:d("entityPage.col.section")}),t.jsx("th",{children:d("entityPage.col.role")}),t.jsx("th",{children:d("entityPage.col.versions")}),t.jsx("th",{"aria-label":d("entityPage.col.image")})]})}),t.jsx("tbody",{children:$.map(B=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Xe,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0}),B.measure?t.jsx(et,{items:[c(B.measure)]}):!B.loaded&&n?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.section||B.loaded?"":" bim-d-zt-blank"}`,children:B.section?c(B.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.role?"":" bim-d-zt-blank"}`,children:B.role?c(B.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.loaded?"":" bim-d-zt-blank"}`,children:B.loaded?B.versionCount?d("entityPage.nZhong",{n:B.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),t.jsx("td",{className:B.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:B.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},B.id))})]}),$.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("entityPage.emptyRole")}),!f&&t.jsx(er,{total:v.length,shown:$.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),$e=Pe.length>0?t.jsx(Yt,{id:"external",title:d("entityPage.sec.external"),items:Pe.map(B=>t.jsxs("a",{href:B.href,target:"_blank",rel:"noopener noreferrer",children:[B.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Pe.map(B=>B.id),foot:ke.cbdb_id!=null&&ke.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Bn,{railTop:s,back:a,nav:oe,railLinks:l,main:U,card:ve,side:$e})},Tr="(max-width: 719px)",rb=`${Tr}, (pointer: coarse)`,Uc=`
|
|
1305
|
+
${fe??""}`,[Qt,Br]=g.useState({key:Ot,data:z,started:!!z});if(Qt.key!==Ot)Br({key:Ot,data:z,started:!1});else if(z!==Qt.data&&(Br({key:Ot,data:z,started:!!z}),z)){const W=z.pages??[];(!Qt.started||!W.some(ue=>ue.page===Ge))&&Rt(bn(z))}g.useEffect(()=>{Ne(new Set),ge(null)},[fe,Q]);const Od=g.useCallback(W=>{if(Ne(new Set(W)),W.length>0){const ue=W[0],Ie=parseInt(ue.split(":")[0],10);isNaN(Ie)||Rt(Ie)}},[]),Et=g.useMemo(()=>{const W=new Map;for(const ue of(z==null?void 0:z.pages)??[])W.set(ue.page,ue);return W},[z]),yn=xn(z),Vn=g.useCallback(W=>{var Fe;const ue=Ue.images;if(!ue||ue.length===0)return;const Ie=(Fe=Et.get(W))==null?void 0:Fe.seq;return(Ie?ue.find(qe=>qe.seq===Ie):void 0)??ue.find(qe=>qe.pageNo===W)??ue[W-1]},[Ue.images,Et]),Wr=Ve>1.5,Gn=g.useCallback((W,ue=!1)=>{const Ie=Vn(W);return Ie?W===yn||ue?Ie.hiresUrl??Ie.url:Ie.url:W===yn?(z==null?void 0:z.imageUrl)??"":""},[Vn,z,yn]),Hd=g.useMemo(()=>Gn(Ge,Wr),[Gn,Ge,Wr]),jn=g.useMemo(()=>[...Et.keys()].sort((W,ue)=>W-ue),[Et]),Pi=g.useRef(Ge);Pi.current=Ge;const vn=g.useCallback(W=>{var qe;const ue=Pi.current,Ie=jn.indexOf(ue),Fe=jn[Ie<0?0:Ie+W];Fe===void 0||Fe===ue||(Pi.current=Fe,Rt(Fe),(qe=Et.get(Fe))!=null&&qe.columns.some(ot=>ot.chars.length>0)&&Wt(ot=>({page:Fe,nonce:((ot==null?void 0:ot.nonce)??0)+1})))},[jn,Et]),Mi=jn.indexOf(Ge),Fd=g.useCallback(W=>{if(W.altKey||W.ctrlKey||W.metaKey)return;const ue=W.target.tagName;ue==="INPUT"||ue==="TEXTAREA"||ue==="SELECT"||(W.key==="ArrowLeft"||W.key==="PageUp"?(W.preventDefault(),vn(-1)):(W.key==="ArrowRight"||W.key==="PageDown")&&(W.preventDefault(),vn(1)))},[vn]);g.useEffect(()=>{if(z)for(const W of[1,-1,2,3]){const ue=Gn(Ge+W);ue&&So(ue)}},[z,Ge,Gn]);const Or=g.useMemo(()=>{var Xr;if(!z)return null;if(Ge===yn)return z;const W=Et.get(Ge);if(W&&W.width>0&&W.height>0)return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[W.width,W.height],total_warped_w:W.width,columns:[{col:1,warped_w:W.width,warped_h:W.height,offset_x:0,strips:[],chars:W.columns.flatMap(Ke=>Ke.chars).map(Ke=>({id:Ke.id,char:Ke.char,slot:Ke.slot,pos:Ke.pos,sub:Ke.sub,bbox_col:Ke.bbox??[0,0,0,0]}))}]};const ue=(Xr=z.pages)==null?void 0:Xr.find(Ke=>Ke.page===Ge),[Ie,Fe]=z.image_size||[2386,3082],qe=Vn(Ge),ot=(qe==null?void 0:qe.width)??Ie,Fi=(qe==null?void 0:qe.height)??Fe,Yr=ot/Ie,Kr=Fi/Fe,qr=new Map;for(const Ke of z.columns){const ct=(Ke.strips||[]).flatMap(qn=>qn.srcQuad.map(Xn=>Xn[0]));if(ct.length===0)continue;const St=Ke.top_y??0,Di=Ke.bottom_y??St+Ke.warped_h;qr.set(Ke.col,{x0:Math.min(...ct),x1:Math.max(...ct),top:St,slotH:(Di-St)/21})}return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[ot,Fi],total_warped_w:ot,columns:ue?ue.columns.map(Ke=>{const ct=qr.get(Ke.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ke.col,warped_w:ot,warped_h:Fi,offset_x:0,strips:[],chars:Ke.chars.map(St=>{const Di=St.slot??St.pos??0,qn=(ct.top+(Di-1)*ct.slotH)*Kr,Xn=(ct.x0+ct.x1)/2,[Xd,Zd]=St.sub==="a"?[Xn,ct.x1]:St.sub==="b"?[ct.x0,Xn]:[ct.x0,ct.x1];return{...St,bbox_col:[Xd*Yr,qn,Zd*Yr,qn+ct.slotH*Kr]}})}}):[]}},[z,Ge,yn,Et,Vn]),{entryTitle:Yn,authors:Hr}=Og(e,n,l===void 0),[Fr,Bi]=g.useState("text");if(g.useEffect(()=>{Bi("text")},[fe,Q]),L==="loading")return t.jsx(Fs,{className:S,style:v,title:l??Yn,label:$("reader.loading")});if(L==="missing"||!R||!G)return t.jsx("div",{className:S,style:{...v,...Hs},children:$("reader.noText")});if(Ee==="failed")return t.jsx("div",{className:S,style:{...v,...Hs},children:$("reader.tocFailed")});if(!oe)return t.jsx(Fs,{className:S,style:v,title:l??Yn,label:$("reader.tocLoading")});const Ht=Pg(G,oe),Dd=Mg(oe,De,Ht,_,H),Wi=R.versions.map(W=>({key:W.key,label:_e.textVersionLabel(W),optionLabel:_(_e.textVersionLabel(W)),sourceName:W.source_name?_(W.source_name):void 0,license:W.license??void 0,sourceUrl:W.source_url??void 0,primary:W.key===se})),lt=Lg((Gr=oe.source)==null?void 0:Gr.upstream),Kn=(typeof l=="string"?_(l):l)??(oe.title?_(oe.title):Yn?_(Yn):void 0),Ud=Kn?t.jsx("a",{href:T(e),title:$("reader.viewEntry"),onClick:a?W=>{W.metaKey||W.ctrlKey||(W.preventDefault(),a(e))}:void 0,children:Kn}):void 0,Vd=Hr.length>0?_(Hr.slice(0,2).map(W=>`${W.dynasty?`〔${W.dynasty}〕`:""}${W.name}${` ${W.role||$("reader.defaultRole")}`}`).join("、")):void 0,Oi=U?xc(U,Ht,_,H):void 0,en=H&&!!(Y!=null&&Y.json),Ft=(Y==null?void 0:Y.json)??null,tn=(Y==null?void 0:Y.md)??null,Dr=en&&!Se&&sc(Ft.sections),Gd=Dr&&!(tn&&ye.readingMode==="paragraph"&&pi(tn)),Yd=en&&Dr?t.jsx(ig,{juan:Ft,view:Fr,onView:Bi,textHasEntries:Gd}):void 0,Kd=dl(oe)||uo(oe),Hi=tn?tn.replace(/^##\s+[^\n]+\n+/,""):null,qd=(typeof d=="string"?_(d):d)??(G.source_name?_(G.source_name):_(_e.textVersionLabel(G)));return t.jsxs(_l,{className:S,style:v,title:Ud,subtitle:qd,byline:Vd,current:Oi,pagerUnit:Ht,rail:Yd,revisedAt:f,backHref:x,backLabel:k,onReportError:h?W=>h({...W,bookTitle:typeof Kn=="string"?Kn:void 0,entryId:e}):void 0,workLinkToggle:en&&!Se&&!!a&&!!(Ft!=null&&Ft.sections.some(W=>W.work_id)),toc:Dd,tocCaption:$("reader.tocCaption",{n:oe.chapters.length,unit:_(Ht)}),tocHeader:H&&oe.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:Se?$("reader.searchChaptersPlaceholder"):$("reader.searchUnitPlaceholder",{unit:_(Ht)}),"aria-label":Se?$("reader.searchChapters"):$("reader.searchUnit",{unit:_(Ht)}),value:pe,onChange:W=>ee(W.target.value)}):void 0,activeKey:fe??null,onSelect:Ce,images:Ue.images,imagesLoading:Ue.loading||ie,renderImageOverlay:p,imagePanel:z?"open":u,isWarpMode:!!z,customImagePanel:z&&Or?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Fd,style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",outline:"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px 6px",fontSize:12,color:i("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",disabled:Mi<=0,onClick:()=>vn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Ge,style:{fontSize:11,padding:"1px 6px",background:i("rule"),borderRadius:10},children:["第 ",Ge," 葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",disabled:Mi<0||Mi>=jn.length-1,onClick:()=>vn(1),children:"›"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[he.size>0&&t.jsxs("button",{type:"button",onClick:()=>Ne(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${i("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",he.size,")"]}),t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2},"data-testid":"facsimile-zoom-tools",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"缩小",title:"缩小",disabled:Ve<=1,onClick:()=>{var W;return(W=ve.current)==null?void 0:W.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Ve*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Ve>=6,onClick:()=>{var W;return(W=ve.current)==null?void 0:W.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Ve===1,onClick:()=>{var W;return(W=ve.current)==null?void 0:W.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Eg,{ref:ve,resetKey:Ge,onScaleChange:Oe,style:{flex:1,minHeight:0},children:t.jsx(fr,{imageUrl:Hd,pageData:Or,selectedCharIds:he,hoveredCharId:K,preserveMargins:le,onCharClick:W=>{Ne(Ie=>{const Fe=new Set(Ie);return Fe.has(W)?Fe.delete(W):(Fe.clear(),Fe.add(W)),Fe});const ue=document.querySelector(`[data-char-id="${W}"]`);ue&&ue.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ge})}),t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0 2px"},children:t.jsxs("div",{style:{display:"inline-flex",border:`1px solid ${i("rule")}`,borderRadius:4,overflow:"hidden"},children:[t.jsx("button",{type:"button",onClick:()=>ce(!1),"aria-pressed":!le,className:`bim-rd-t ${le?"":"bim-rd-on"}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:le?"transparent":i("accent-bg"),color:le?"inherit":i("accent")},title:"去空白:紧凑裁切版心",children:"去空白"}),t.jsx("button",{type:"button",onClick:()=>ce(!0),"aria-pressed":le,className:`bim-rd-t ${le?"bim-rd-on":""}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:le?i("accent-bg"):"transparent",color:le?i("accent"):"inherit"},title:"保留空白:完整呈现古籍天头地脚与白边",children:"保留空白"})]})})]}):void 0,toolbarExtra:z?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-badge-warp",children:"图文对读"}),t.jsx("button",{type:"button",className:`bim-rd-t ${Ae?"bim-rd-on":""}`,"aria-pressed":Ae,title:"切换外挂现代断句标点",onClick:()=>q(W=>!W),children:Ae?"标点":"无标点"})]}):void 0,prefs:ye,onPrefsChange:N,versions:Wi.length>1?Wi:void 0,currentVersionKey:Wi.length>1?G.key:void 0,onVersionChange:me,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:pi(tn),allowVertical:m,children:[xe&&t.jsx(Zt,{}),!xe&&z&&t.jsxs("article",{className:"bim-rd-prose",style:{marginTop:0},children:[t.jsxs("header",{style:{marginBottom:16},children:[t.jsx("h1",{className:"bim-rd-h1",children:U!=null&&U.title?_(U.title):Oi}),(G.source_name||G.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[G.source_name&&_(G.source_name),G.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),G.license]})]})]}),t.jsx(vr,{pageData:z,pages:z.pages,punctuations:z.punctuations||[],selectedCharIds:he,hoveredCharId:K,onSelectionChange:Od,onCharClick:W=>{Ne(Ie=>{const Fe=new Set(Ie);return Fe.has(W)?Fe.delete(W):(Fe.clear(),Fe.add(W)),Fe});const ue=parseInt(W.split(":")[0],10);isNaN(ue)||Rt(ue)},onCharHover:ge,mode:"horizontal",showPunctuation:Ae,entities:ye.properNames?re:void 0,entityTransport:n,onEntityNavigate:j,onVisiblePageChange:W=>Rt(W),convert:_,scrollToPage:ht})]}),!xe&&!z&&en&&Ft&&t.jsx(tg,{juan:Ft,rawText:tn,positionLabel:Bg(U,oe,Ht,_),groupLabel:Wg(oe,fe??null),index:Ag(e,oe),searchQuery:pe,onNavigate:a,transport:n,workLabelCache:Je,prefs:ye,view:Fr,onViewChange:Bi},`${Q}/${fe}`),!xe&&!z&&!en&&Hi!=null&&U&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:U.title?_(U.title):Oi}),(G.source_name||G.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[G.source_name&&t.jsxs(t.Fragment,{children:[$("reader.textSource")," ",G.source_url?t.jsx("a",{className:"bim-rd-link",href:G.source_url,target:"_blank",rel:"noreferrer",children:_(G.source_name)}):_(G.source_name)]}),G.source_name&&G.license&&t.jsx("span",{className:"bim-rd-dot"}),G.license]}),lt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[$("reader.upstream")," ",lt.url?t.jsx("a",{className:"bim-rd-link",href:lt.url,target:"_blank",rel:"noreferrer",children:_(lt.name??lt.url)}):_(lt.name??""),lt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),lt.license_url?t.jsx("a",{className:"bim-rd-link",href:lt.license_url,target:"_blank",rel:"noreferrer",children:lt.license}):lt.license]}),lt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(hl,{text:lt.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(cr,{text:Hi,mode:ye.readingMode,tables:Kd,gujiMarkdown:uo(oe),properNames:ye.properNames})})]}),!xe&&!z&&!en&&Hi==null&&U&&t.jsx("div",{className:"bim-rd-state",children:$("reader.chapterFailed")}),oe.references&&oe.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:$("reader.references")}),t.jsx("ol",{children:oe.references.map((W,ue)=>t.jsxs("li",{children:[W.url?t.jsx("a",{className:"bim-rd-link",href:W.url,target:"_blank",rel:"noopener noreferrer",children:_(W.title)}):t.jsx("span",{children:_(W.title)}),W.author&&t.jsxs("span",{children:[",",_(W.author)]}),W.note&&t.jsxs("span",{children:["。",_(W.note)]})]},ue))})]})]})};function Bg(e,n,o,r){var a,l;if(!e)return;const s=(l=(a=n.juan_metadata)==null?void 0:a[e.file])==null?void 0:l.vol_label;return r(s?`${s}冊`:`${o}${e.n}`)}function Wg(e,n){if(!n)return;const o=r=>{var s;for(const a of r??[]){const l=o(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return o(e.juan_groups)}function Og(e,n,o){const[r,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,o]),r}const bc={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")}},Hg=bc.other,yc={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")}},Fg=yc.pending;function Dg(e){try{const n=new Date(e),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 e}}function Ug(e,n){if(!e)return!1;try{const o=new URL(e,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const Sr=({items:e,loading:n})=>{const o=Ze(),{t:r,convert:s}=J();return n?t.jsx(Zt,{}):e.length===0?t.jsx("div",{style:Vg,children:r("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=bc[a.type]||Hg,d=yc[a.status]||Fg,c=typeof window<"u"&&Ug(a.pageUrl,window.location.href);return t.jsxs("div",{style:Gg,children:[t.jsxs("div",{style:Yg,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Us,background:l.color},children:r(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Us,background:d.color},children:r(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Kg,children:Dg(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:qg,children:[a.resourceId&&t.jsx("a",{href:o(a.resourceId),style:eo,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:eo,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:eo,children:a.pageUrl}))]}),t.jsx("div",{style:Xg,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Zg,children:[t.jsx("div",{style:Jg,children:r("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Vg={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Gg={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Yg={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Us={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Kg={fontSize:"12px",color:i("desc-fg")},qg={fontSize:"12px",marginBottom:"6px"},eo={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},Xg={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},Zg={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},Jg={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},$o=({transport:e,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:a})=>{const l=Te(),[d,c]=g.useState(null),[p,u]=g.useState([]),[m,h]=g.useState("recommend"),[f,x]=g.useState([]),[k,y]=g.useState(!1),w=r??m,b=L=>{h(L),s==null||s(L)},[j,S]=g.useState(!0),[v,$]=g.useState(null),[_,C]=g.useState(null),[M,N]=g.useState(null);g.useEffect(()=>{let L=!1;if(e.getCounts)return e.getCounts().then(I=>{L||c({works:I.works,books:I.books,collections:I.collections})}).catch(()=>{}),()=>{L=!0}},[e]),g.useEffect(()=>{let L=!1;return(async()=>{if(o)return o;if(e.getRecommended)try{const P=await e.getRecommended();if(P!=null&&P.groups)return P.groups.flatMap(V=>V.items.map(X=>({...X,group:V.name})))}catch{}return[]})().then(async P=>{if(L)return;const V=P.filter(D=>D.id);if(V.length===0){S(!1);return}const X=await Promise.all(V.map(async D=>{if(D.type)return{id:D.id,title:D.title,type:D.type,author:D.author,dynasty:D.dynasty,role:D.role,edition:D.edition,has_text:D.has_text,has_image:D.has_image,has_collated:D.has_collated,subtype:D.subtype,primary_name:D.primary_name,group:D.group,fallbackDescription:D.description};try{let O=null;if(e.getEntry)O=await e.getEntry(D.id);else{const A=await e.getItem(D.id);A&&(O={id:D.id,title:A.title||D.id,type:A.type||"work"})}if(O)return{...O,group:D.group,fallbackDescription:D.description}}catch{}return{id:D.id,title:D.title,type:_e.extractType(D.id),group:D.group,fallbackDescription:D.description}}));L||(u(X.filter(D=>D!==null)),S(!1))}),()=>{L=!0}},[e,o]);const T=g.useRef(!1),F=g.useRef(!1),R=g.useRef(!1);g.useEffect(()=>{if(w!=="catalog"||T.current)return;const L=e.getCatalogProgress??e.getResourceProgress;if(!L)return;T.current=!0;let I=!1;return L.call(e).then(P=>{I||$(P)}).catch(()=>{T.current=!1}),()=>{I=!0}},[e,w]),g.useEffect(()=>{if(w!=="collection"||F.current||!e.getCollectionProgress)return;F.current=!0;let L=!1;return e.getCollectionProgress().then(I=>{L||C(I)}).catch(()=>{F.current=!1}),()=>{L=!0}},[e,w]),g.useEffect(()=>{if(w!=="site"||R.current||!e.getSiteProgress)return;R.current=!0;let L=!1;return e.getSiteProgress().then(I=>{L||N(I)}).catch(()=>{R.current=!1}),()=>{L=!0}},[e,w]),g.useEffect(()=>{if(!a||w!=="feedback")return;let L=!1;return y(!0),fetch(a).then(I=>I.json()).then(I=>{!L&&I.success&&x(I.items||[])}).catch(()=>{}).finally(()=>{L||y(!1)}),()=>{L=!0}},[a,w]);const E=L=>t.jsx(fn,{type:L,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[t.jsx(Cn,{label:l.home.recommendTab,active:w==="recommend",onClick:()=>b("recommend")}),t.jsx(Cn,{label:l.home.catalogTab,active:w==="catalog",onClick:()=>b("catalog")}),t.jsx(Cn,{label:l.home.collectionTab,active:w==="collection",onClick:()=>b("collection")}),t.jsx(Cn,{label:l.home.siteTab,active:w==="site",onClick:()=>b("site")}),a&&t.jsx(Cn,{label:l.home.feedbackTab,active:w==="feedback",onClick:()=>b("feedback")})]}),w==="recommend"&&t.jsx(Qg,{recommended:p,loading:j,onNavigate:n,getIcon:E,t:l}),w==="catalog"&&t.jsx(Vs,{progress:v,t:l,onNavigate:n}),w==="collection"&&t.jsx(Vs,{progress:_,t:l,onNavigate:n}),w==="site"&&t.jsx(tf,{progress:M,t:l,totalWorks:(d==null?void 0:d.works)??0}),w==="feedback"&&a&&t.jsx(Sr,{items:f,loading:k})]})})},Cn=({label:e,active:n,onClick:o})=>t.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:e}),Qg=({recommended:e,loading:n,onNavigate:o,getIcon:r,t:s})=>{const a=Ze();if(n)return t.jsx(Zt,{});if(e.length===0)return null;const l=new Map;for(const d of e){const c=d.group||s.home.recommendedBrowse;l.has(c)||l.set(c,[]),l.get(c).push(d)}return t.jsx(t.Fragment,{children:Array.from(l.entries()).map(([d,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:d}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(p=>{const u=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),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:[t.jsx("span",{style:{fontSize:"20px"},children:r(p.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[p.title,p.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:p.edition})]}),u&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},p.id)})})]},d))})},Vs=({progress:e,t:n,onNavigate:o})=>{if(!e)return t.jsx(Zt,{});const r=[...e.resources].sort((d,c)=>d.priority-c.priority),s=["in_progress","done","todo"],a={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},l={in_progress:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=r.filter(p=>p.status===d);return c.length===0?null:t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:l[d]}}),a[d]," (",c.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(p=>t.jsx(ef,{item:p,t:n,statusColor:l[d],onNavigate:o},p.id))})]},d)})})},ef=({item:e,t:n,statusColor:o,onNavigate:r})=>{const s=Ze(),a=e.total>0?Math.round(e.imported/e.total*100):0,l=e.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const d=e.edition?`${e.name}·${e.edition}`:e.name,c=e.collection_id||e.work_id;return c&&r?t.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}):e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:d}):d})()}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:i("widget-border"),color:i("desc-fg"),whiteSpace:"nowrap"},children:e.collection_id?n.indexType.collection:e.work_id?n.indexType.work:l})]}),t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?ut(n.home.progressFormat,{imported:String(e.imported),total:String(e.total)}):n.home.totalPending})]}),e.total>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},tf=({progress:e,t:n,totalWorks:o})=>{if(!e)return t.jsx(Zt,{});const r=[...e.resources].sort((c,p)=>c.priority-p.priority),s=r.filter(c=>c.imported>0),a=r.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=o>0?Math.round(l/o*100):0;return t.jsxs("div",{children:[o>0&&t.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,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",o.toLocaleString()," ",n.indexType.work," (",d,"%)"]}),s.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(Gs,{item:c,t:n,totalWorks:o},c.id))})]}),a.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(Gs,{item:c,t:n,totalWorks:o},c.id))})]})]})},Gs=({item:e,t:n,totalWorks:o})=>{const r=o>0?Math.round(e.imported/o*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:t.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:e.name}):e.name})}),t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),e.imported>0&&o>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},Ys="(max-width: 768px)";function nf(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(Ys).matches);return g.useEffect(()=>{const o=window.matchMedia(Ys),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e}const of=({transport:e,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var F;const a=Te(),{convert:l}=Le(),d=nf(),[c,p]=g.useState(null),[u,m]=g.useState(null),[h,f]=g.useState(!1),[x,k]=g.useState("detail"),[y,w]=g.useState([]),[b,j]=g.useState(!1),S=g.useCallback(async R=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){w([]);return}j(!0);try{if(e.getCollectionCatalogs){const E=await e.getCollectionCatalogs(R);w(E||[])}else if(e.getCollectionCatalog){const E=await e.getCollectionCatalog(R);w(E?[{resource_id:"",data:E}]:[])}}catch{w([])}finally{j(!1)}},[e]),v=g.useCallback(async R=>{if(o){o(R);return}p(R),m(null),w([]),k("detail"),f(!0);try{const E=await e.getItem(R.id);E&&(m(E),E.type==="collection"&&S(R.id))}catch(E){console.error("加载详情失败:",E)}finally{f(!1)}},[e,o,S]),$=g.useCallback(async R=>{m(null),w([]),k("detail"),f(!0);try{const E=await e.getItem(R);E&&(m(E),p({id:R,title:E.title||R,type:E.type||"book"}),E.type==="collection"&&S(R))}catch(E){console.error("导航失败:",E)}finally{f(!1)}},[e,S]),_=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"&&_,M=d&&(h||u),N=g.useCallback(()=>{p(null),m(null),w([]),k("detail")},[]),T=t.jsx(t.Fragment,{children:h?t.jsx(Zt,{}):u?t.jsxs(t.Fragment,{children:[(C||s)&&t.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&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:ti(x==="detail"),children:a.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:ti(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&y.map(R=>t.jsx("button",{onClick:()=>k(`catalog:${R.resource_id}`),style:ti(x===`catalog:${R.resource_id}`),children:R.short_name?`${l(R.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},R.resource_id)),u.type==="work"&&_&&t.jsx("button",{onClick:()=>k("collated"),style:ti(x==="collated"),children:a.detailTab.collatedEdition})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),t.jsx("div",{style:{padding:d?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:x==="detail"?t.jsx(Uo,{data:u,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(Vo,{data:(F=y.find(R=>`catalog:${R.resource_id}`===x))==null?void 0:F.data,onNavigate:$}):x==="collated"?t.jsx(wr,{id:u.id,transport:e,onNavigate:$}):null})]}):t.jsx($o,{transport:e,onNavigate:$,recommendedIds:r})});return d?t.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:M?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:N,style:{padding:"4px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",a.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:T})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(po,{transport:e,onEntryClick:v,hideModeIndicator:n}),!u&&t.jsx($o,{transport:e,onNavigate:$,recommendedIds:r})]})}):t.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:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(po,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:T})]})};function ti(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const rf=({pageData:e,rawImageUrl:n="",punctuations:o=[],title:r,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[u,m]=g.useState(null),[h,f]=g.useState("horizontal"),[x,k]=g.useState(!0),y=g.useRef(null),w=g.useCallback(v=>{p(new Set(v))},[]),b=g.useCallback(v=>{if(p($=>{const _=new Set($);return _.has(v)?_.delete(v):(_.clear(),_.add(v)),_}),y.current){const $=y.current.querySelector(`[data-char-id="${v}"]`);$&&$.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),j=()=>{var v;p(new Set),window.getSelection&&((v=window.getSelection())==null||v.removeAllRanges())},S=o.length>0?o:e.punctuations||[];return t.jsxs("div",{className:`guji-reader-container ${l}`,style:d,children:[t.jsxs("header",{className:"guji-reader-header",children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[a&&t.jsx("button",{type:"button",onClick:a,className:"guji-reader-btn",style:{marginRight:6},children:"‹ 返回"}),t.jsx("span",{className:"guji-reader-title",children:r||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:i("meta-fg")},children:s}),t.jsx("span",{className:"guji-reader-tag",children:"WebGL 客户端透视矫正对读"})]}),t.jsxs("div",{className:"guji-reader-actions",children:[t.jsxs("span",{style:{fontSize:"0.85rem",color:i("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:i("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:j,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>k(v=>!v),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>f(v=>v==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:h==="horizontal"?"切换竖排":"切换横排"})]})]}),t.jsxs("div",{className:"guji-reader-body",children:[t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),t.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),t.jsx("div",{className:"guji-pane-content",children:t.jsx(fr,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:u,onCharClick:b,onCharHover:m})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:h==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(vr,{pageData:e,punctuations:S,selectedCharIds:c,hoveredCharId:u,onSelectionChange:w,onCharClick:b,onCharHover:m,mode:h,showPunctuation:x})]})]})]})},sf=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function on(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function af(e){var r,s,a,l,d,c;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return[];const o=[];for(const p of n){if(!p||typeof p!="object")continue;const u=p,m=on((r=u.page)==null?void 0:r.index),h=Array.isArray(u.cells)?u.cells:[];if(m===void 0||h.length===0)continue;const f=new Map;for(const x of h){if(!x||typeof x!="object")continue;const k=x,y=sf.exec(String(k.a??""));if(!y||typeof k.c!="string")continue;const w=parseInt(y[2],10),b=parseInt(y[3],10),j=Array.isArray(k.box)&&k.box.length===4&&k.box.every($=>on($)!==void 0)?k.box:null,S={id:String(k.a),char:k.c,slot:b,pos:b,sub:y[4]||null,bbox:j?[j[0],j[1],j[0]+j[2],j[1]+j[3]]:null};let v=f.get(w);v||f.set(w,v=[]),v.push(S)}o.push({page:m,seq:String(((s=u.canvas)==null?void 0:s.seq)??""),width:on((a=u.canvas)==null?void 0:a.width)??on((l=u.image)==null?void 0:l.width)??0,height:on((d=u.canvas)==null?void 0:d.height)??on((c=u.image)==null?void 0:c.height)??0,columns:Array.from(f.entries()).sort((x,k)=>x[0]-k[0]).map(([x,k])=>({col:x,chars:k}))})}return o}function lf(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],o=[];for(const r of n){if(!r||typeof r!="object")continue;const s=r;typeof s.anchor!="string"||typeof s.mark!="string"||o.push({id:typeof s.id=="string"?s.id:void 0,anchor:s.anchor,mark:s.mark,kind:s.kind,pos:s.pos,pre_char:s.pre_char})}return o}function cf(e){var o;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const r of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((o=r==null?void 0:r.canvas)==null?void 0:o.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const df=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function gt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Ks(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(o=>!!o&&typeof o=="object"):[]}function pf(e,n){var l,d,c,p,u,m,h,f,x,k;const o=new Map,r=new Map;for(const y of Ks(n)){const w=gt(y.page);if(w!==void 0){o.set(w,y);for(const b of Array.isArray(y.cells)?y.cells:[]){const j=b==null?void 0:b.box;typeof(b==null?void 0:b.a)=="string"&&Array.isArray(j)&&j.length===4&&j.every(S=>gt(S)!==void 0)&&r.set(b.a,[j[0],j[1],j[0]+j[2],j[1]+j[3]])}}}const s=[];for(const y of Ks(e)){const w=gt(y.page);if(w===void 0)continue;const b=[];for(const S of Array.isArray(y.columns)?y.columns:[]){const v=gt(S==null?void 0:S.col);if(v===void 0)continue;const $=[];for(const _ of Array.isArray(S.cells)?S.cells:[]){const C=df.exec(String((_==null?void 0:_.a)??""));if(!C||typeof _.c!="string")continue;const M=parseInt(C[3],10);$.push({id:_.a,char:_.c,slot:M,pos:M,sub:C[4]||null,bbox:r.get(_.a)??null})}$.length>0&&b.push({col:v,chars:$})}if(b.length===0)continue;b.sort((S,v)=>S.col-v.col);const j=o.get(w);s.push({page:w,seq:String(((l=j==null?void 0:j.canvas)==null?void 0:l.seq)??""),width:gt((d=j==null?void 0:j.canvas)==null?void 0:d.width)??gt((c=j==null?void 0:j.image)==null?void 0:c.width)??0,height:gt((p=j==null?void 0:j.canvas)==null?void 0:p.height)??gt((u=j==null?void 0:j.image)==null?void 0:u.height)??0,columns:b})}const a=new Set(s.map(y=>y.page));for(const[y,w]of o){const b=(m=w==null?void 0:w.canvas)==null?void 0:m.seq;a.has(y)||typeof b!="string"&&typeof b!="number"||String(b)===""||s.push({page:y,seq:String(b),width:gt((h=w.canvas)==null?void 0:h.width)??gt((f=w.image)==null?void 0:f.width)??0,height:gt((x=w.canvas)==null?void 0:x.height)??gt((k=w.image)==null?void 0:k.height)??0,columns:[]})}return s.sort((y,w)=>y.page-w.page)}const uf=({data:e,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:a}=J(),[l,d]=g.useState(((u=e.divisions[0])==null?void 0:u.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:o,style:r,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(m=>t.jsx(mf,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:h=>p(c===h?null:h),onNavigate:n},m.name))})]})},mf=({division:e,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=J(),c=e.categories.reduce((p,u)=>{const m=u.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.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:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg")},children:[l("catalogPage.divisionStat",{cats:e.categories.length,books:c}),t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(p=>{const u=`${e.name}/${p.name}`;return t.jsx(hf,{category:p,expanded:r===u,onToggle:()=>s(u),onNavigate:a},p.name)})})]})},hf=({category:e,expanded:n,onToggle:o,onNavigate:r})=>{var p,u,m,h;const{t:s,convert:a}=J(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((u=e.books)==null?void 0:u.cunmu)||[],c=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((h=e.stats)==null?void 0:h.cunmu)||d.length);return t.jsxs("div",{children:[t.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:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(qs,{label:s("catalogPage.zhulu"),books:l,onNavigate:r}),d.length>0&&t.jsx(qs,{label:s("catalogPage.cunmu"),books:d,onNavigate:r})]})]})},qs=({label:e,books:n,onNavigate:o})=>{const{t:r,convert:s}=J(),a=Ze(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,u)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:i("fg")},children:p.work_id&&o?t.jsx("a",{href:a(p.work_id),onClick:m=>{m.metaKey||m.ctrlKey||(m.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&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(p.author).slice(0,20)})]},u))}),!l&&t.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})})]})},bt=({title:e,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const a=Te();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&t.jsx("button",{onClick:o,style:ff,children:"AI"}),n&&t.jsx("button",{onClick:n,style:gf,children:a.action.save})]})]}),s]})},gf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},ff={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},pt=({label:e,value:n,onChange:o,placeholder:r,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>o(a.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"}})]}),Kt=({value:e,onChange:n,placeholder:o})=>{const r=g.useRef(null);return g.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:r,value:e||"",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"}})},mi=({children:e,color:n,style:o})=>t.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:e});function xf(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const si=({value:e,onChange:n,label:o})=>{const[r,s]=g.useState(!1),a=g.useRef(null),l=xf(e||"");return g.useEffect(()=>{r&&a.current&&a.current.focus()},[r]),!r&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Xs,children:o}),t.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:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:l.name}),t.jsx(mi,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Xs,children:o}),t.jsx("input",{ref:a,type:"text",value:e||"",onChange:d=>n(d.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Xs={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function bf(e){switch(e){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function yf(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const jc=({items:e,onChange:n,onOpenEntityPicker:o})=>{const r=Te(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((h,f)=>f!==m)),s===m&&a(null)},c=(m,h,f)=>{const x=[...e];x[m]={...x[m],[h]:f},n(x)},p=(m,h)=>{const f=[...e];f[m]={...f[m],type:h,id:"",name:""},n(f),h==="bookID"&&o&&o(x=>{const k=[...e];k[m]={...k[m],id:x.id,name:x.title,type:"bookID"},n(k)})},u=m=>{o&&o(h=>{const f=[...e];f[m]={...f[m],id:h.id,name:h.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,h)=>t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===h?null:h),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===h?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:m.name||`${r.editor.sourcePlaceholder} ${h+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:bf(m.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:yf(m.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(h)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===h&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(h,"bookID"),style:{...Zs,borderColor:i("source-bookid"),color:i("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(h,"url"),style:{...Zs,borderColor:i("source-url"),color:i("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.enterUrl})]})]})]}),m.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:_t,children:r.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:Js,children:r.action.changeType})]}),m.id&&m.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:i("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:m.name}),t.jsx("code",{style:{fontSize:"11px",background:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>u(h),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})]}):t.jsxs("button",{onClick:()=>u(h),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:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),m.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:_t,children:r.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:Js,children:r.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:f=>c(h,"name",f.target.value),placeholder:r.editor.sourceNamePlaceholder,style:rn})]}),t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:f=>c(h,"id",f.target.value),placeholder:"https://...",style:rn})]})]}),m.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{..._t,opacity:.7},children:r.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:f=>c(h,"details",f.target.value),placeholder:r.editor.detailsPlaceholder,style:rn})]}),t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:f=>c(h,"position",f.target.value),placeholder:"如: 卷三, p.52",style:rn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:f=>c(h,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:rn})]}),t.jsxs("div",{children:[t.jsx("label",{style:_t,children:r.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:f=>c(h,"processor_version",f.target.value),placeholder:"如: v0.1",style:rn})]})]})]})]})})]},h)),t.jsxs("button",{onClick:l,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:[t.jsx("span",{children:"+"}),t.jsx("span",{children:r.action.addSource})]})]})},_t={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},rn={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"},Zs={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"},Js={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function vc(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);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 kc(e){return!e||e.length===0?"":JSON.stringify(e)}const wc=({entityType:e,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:u,onLinkEntity:m,onUnlinkEntity:h,onViewEntity:f,onCreateAndLink:x,onSaveRelations:k})=>{const y=Te();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.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:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:y.section.relations})]}),k&&t.jsx("button",{onClick:k,style:jf,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(zn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(zn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>h("collectionId"),onLink:()=>m("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),a&&u&&u.length>0&&t.jsx(sn,{direction:"horizontal",title:`${y.relation.siblingVersions} (${u.length})`,entities:u,onView:f,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(zn,{direction:"up",title:y.relation.parentWork,entity:r,onView:f,onUnlink:()=>h("parentWorkId"),onLink:()=>m("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),d&&d.length>0&&t.jsx(sn,{direction:"down",title:`${y.relation.childWorks} (${d.length})`,entities:d,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&t.jsx(sn,{direction:"down",title:`${y.relation.collectionImpl} (${c.length})`,entities:c,onView:f,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:y.action.addCollectionImpl,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(sn,{direction:"down",title:`${y.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(zn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(zn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>h("parentCollectionId"),onLink:()=>m("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),t.jsx(sn,{direction:"down",title:`${y.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:f,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:y.action.addSubCollection,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),t.jsx(sn,{direction:"down",title:`${y.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},zn=({direction:e,title:n,entity:o,onView:r,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:u,unlinkLabel:m})=>{const h=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:f}),t.jsx("span",{children:n})]}),o?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Sc(o.type)}),t.jsx("span",{style:{fontWeight:500},children:o.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx(Qs,{onClick:()=>r(o),title:u,children:"👁️"}),t.jsx(Qs,{onClick:s,title:m,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(Co,{onClick:a,children:d}),t.jsx(Co,{onClick:l,primary:!0,children:c})]})]})},sn=({direction:e,title:n,entities:o,onView:r,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),u=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",h=c?o:o.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:m}),t.jsx("span",{children:n})]}),o.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[h.map(f=>t.jsxs("div",{onClick:()=>r(f),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:i("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:Sc(f.type)}),t.jsx("span",{children:f.title})]},f.id)),o.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[d," (",o.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(Co,{onClick:s,primary:!0,children:["+ ",a]})})]})},Qs=({onClick:e,title:n,danger:o,children:r})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),Co=({onClick:e,primary:n,children:o})=>t.jsx("button",{onClick:e,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 Sc(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const jf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},_c=({isOpen:e,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[u,m]=g.useState(""),h=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(m(""),d(""))},[e]);const f=y=>{m(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",k=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:vf,children:t.jsxs("div",{style:kf,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),t.jsx("button",{onClick:s,style:wf,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:u,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:Sf})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:to,children:"搜索中..."}):h.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:h.map(y=>t.jsxs("div",{onClick:()=>r(y),style:_f,children:[t.jsx("span",{style:{fontSize:"16px"},children:k}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):u?t.jsxs("div",{style:to,children:["未找到匹配的",x]}):t.jsxs("div",{style:to,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:$f,children:["创建新",x,"并关联"]})]})]})})},vf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},kf={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")},wf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Sf={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"},_f={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},to={padding:"20px",textAlign:"center",color:i("desc-fg")},$f={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},ea={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Cf={work:"📜",book:"📖",collection:"📚",entity:"👤"},$c=({isOpen:e,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((r==null?void 0:r.title)||""),setTimeout(()=>{var h,f;(h=c.current)==null||h.focus(),(f=c.current)==null||f.select()},100))},[e,r==null?void 0:r.title]);const p=h=>{h.key==="Enter"&&l.trim()?u():h.key==="Escape"&&a()},u=()=>{l.trim()&&s(l.trim(),{...r,title:l.trim()})};if(!e)return null;const m=()=>{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`创建新${ea[n]}`}};return t.jsx("div",{style:zf,onClick:h=>{h.target===h.currentTarget&&a()},children:t.jsxs("div",{style:Tf,onClick:h=>h.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Cf[n]}),t.jsx("span",{children:m()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:h=>d(h.target.value),onKeyDown:p,placeholder:`请输入${ea[n]}名称...`,style:Nf})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&t.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:Rf,children:"取消"}),t.jsx("button",{onClick:u,disabled:!l.trim(),style:{...Ef,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},zf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Tf={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")},Nf={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"},Rf={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Ef={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function If(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Cc(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Lf(e){switch(e){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 zc=({isOpen:e,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:u})=>{const[m,h]=g.useState(""),[f,x]=g.useState([]),[k,y]=g.useState(!1),[w,b]=g.useState("recent");g.useEffect(()=>{e&&(h(""),x([]),b(r.length>0?"recent":"search"))},[e,r.length]),g.useEffect(()=>{if(!m.trim()){x([]);return}const C=setTimeout(async()=>{y(!0);try{x(await u(m,o))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(C)},[m,o,u]);const j=g.useCallback(C=>{h(C.target.value),C.target.value.trim()&&b("search")},[]),S=g.useCallback(C=>s?C.filter(M=>M.id!==s):C,[s]);if(!e)return null;const v=n||(o==="all"?"选择实体":`选择${Cc(o)}`),$=S(r),_=S(f);return t.jsx("div",{style:Pf,children:t.jsxs("div",{style:Mf,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:v}),t.jsx("button",{onClick:c,style:Bf,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:m,onChange:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Wf}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),k&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs(ta,{active:w==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(ta,{active:w==="search",onClick:()=>b("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:w==="recent"&&$.length>0?t.jsx(na,{entities:$,onSelect:d}):m.trim()?k?t.jsx(no,{message:"搜索中..."}):_.length>0?t.jsx(na,{entities:_,onSelect:d}):t.jsx(no,{message:"未找到匹配的结果"}):t.jsx(no,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:Of,children:l||"创建新实体"})]})]})})},ta=({active:e,onClick:n,children:o})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:o}),na=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(o=>t.jsx(Af,{entity:o,onClick:()=>n(o)},o.id))}),Af=({entity:e,onClick:n})=>{const[o,r]=g.useState(!1);return t.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:[t.jsx("span",{style:{fontSize:"18px"},children:If(e.type)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.title,e.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:e.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[t.jsx("code",{style:{fontSize:"10px",background:i("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:e.id}),e.author&&t.jsx("span",{children:e.author}),e.dynasty&&t.jsx("span",{children:e.dynasty})]})]}),t.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:Lf(e.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Cc(e.type)})]})},no=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:e}),Pf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Mf={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")},Bf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Wf={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"},Of={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Hf={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},Ff={work:"📜",collection:"📚",book:"📖",entity:"👤"},Tc=({data:e,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:u,relations:m,onRelationsChange:h})=>{var Ce;const f=Te(),[x,k]=g.useState(!1),[y,w]=g.useState("work"),[b,j]=g.useState(""),[S,v]=g.useState(""),[$,_]=g.useState([]),[C,M]=g.useState(!1),[N,T]=g.useState(!1),[F,R]=g.useState("work"),[E,L]=g.useState(""),[I,P]=g.useState(),[V,X]=g.useState(!1),[D,O]=g.useState(null),[A,G]=g.useState([]);g.useRef(null);const se=e.type,Q=se==="work",ke=se==="collection",ne=se==="book",de=g.useCallback((Y,ze)=>{n({...e,[Y]:ze})},[e,n]),We=g.useCallback((Y,ze)=>{j(Y),w(ze),v(f.editor.selectToLink+f.indexType[ze]),_([]),k(!0)},[f]),we=g.useCallback(Y=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(e.id,Y)},[r,e.id]),Pe=g.useCallback(Y=>{s==null||s(Y.id,Y.type)},[s]),Ee=g.useCallback((Y,ze,Me)=>{const B={...Me,author:(Me==null?void 0:Me.author)||e.author,dynasty:Me==null?void 0:Me.dynasty};R(ze),L(Y),P(B),T(!0)},[e.author]),Z=g.useCallback((Y,ze)=>{r!=null&&r.createAndLink&&r.createAndLink(e.id,E,{type:F,title:Y,inheritData:ze}),T(!1)},[r,e.id,E,F]),ae=g.useCallback(Y=>{if(!Y.trim()){_([]);return}M(!0),r!=null&&r.searchEntities&&r.searchEntities(Y,y).then(ze=>{_(ze),M(!1)}).catch(()=>{_([]),M(!1)})},[r,y]),oe=g.useCallback(Y=>{r!=null&&r.linkEntity&&r.linkEntity(e.id,b,Y.id),k(!1)},[r,e.id,b]),fe=g.useCallback(()=>{o()},[o]),U=g.useCallback(Y=>{O(()=>Y),X(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(G).catch(()=>{})},[r]),$e=g.useCallback((Y,ze)=>r!=null&&r.searchEntities?r.searchEntities(Y,ze==="all"?void 0:ze):Promise.resolve([]),[r]),me=g.useCallback(Y=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(Y),G(ze=>[Y,...ze.filter(Me=>Me.id!==Y.id)].slice(0,10)),D==null||D(Y),X(!1),O(null)},[r,D]);return t.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${i("widget-border")}`,paddingBottom:"16px"},children:t.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ff[se]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(mi,{children:e.id}),t.jsx(mi,{color:Hf[se],children:f.indexType[se]})]})}),t.jsx(bt,{title:f.section.basicInfo,onSave:o,onAskAI:d?()=>d("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[t.jsx(si,{label:Q?f.editor.workTitle:ke?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:Y=>de("title",Y)}),ne&&t.jsx(si,{label:f.editor.belongsToWork,value:e.workName||"",onChange:Y=>de("workName",Y)}),t.jsx(pt,{label:f.editor.authorLabel,value:e.author||"",onChange:Y=>de("author",Y)}),t.jsx(pt,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:Y=>de("publicationYear",Y)}),(ne||ke)&&t.jsx(si,{label:f.editor.containedIn,value:e.collection||"",onChange:Y=>de("collection",Y)}),(ne||ke)&&t.jsx(pt,{label:f.editor.holderLabel,value:e.holder||"",onChange:Y=>de("holder",Y)}),(ne||ke)&&t.jsx(pt,{label:ne?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:Y=>de("pages",Y)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(pt,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:Y=>de("firstImage",Y)})})]})}),t.jsx(bt,{title:f.section.description,onSave:o,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(Kt,{value:e.description||"",onChange:Y=>de("description",Y),placeholder:f.editor.descriptionPlaceholder})}),(((Ce=e.additional_works)==null?void 0:Ce.length)||0)>0&&t.jsx(bt,{title:f.section.additionalWorks,onSave:o,children:t.jsx(Df,{items:e.additional_works||[],onChange:Y=>de("additional_works",Y)})}),t.jsx(bt,{title:f.section.indexedBy,onSave:o,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Uf,{items:e.indexed_by||[],onChange:Y=>de("indexed_by",Y)})}),t.jsx(bt,{title:f.section.emendatedBy,onSave:o,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Vf,{items:e.emendated_by||[],onChange:Y=>de("emendated_by",Y)})}),t.jsx(bt,{title:f.section.textResources,onSave:o,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(lo,{items:e.resources||[],onChange:Y=>de("resources",Y),onDownload:p,downloadStatuses:u,filterType:"text"})}),t.jsx(bt,{title:f.section.imageResources,onSave:o,children:t.jsx(lo,{items:e.resources||[],onChange:Y=>de("resources",Y),onDownload:p,downloadStatuses:u,filterType:"image"})}),t.jsx(bt,{title:f.section.sources,onSave:o,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(jc,{items:vc(e.sources||""),onChange:Y=>de("sources",kc(Y)),onOpenEntityPicker:U})}),(ne||ke)&&t.jsx(bt,{title:f.section.provenance,onSave:o,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(Kt,{value:e.provenance||"",onChange:Y=>de("provenance",Y),placeholder:f.editor.provenancePlaceholder})}),ne&&t.jsx(bt,{title:f.section.otherEditions,onSave:o,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(Kt,{value:e.otherEditions||"",onChange:Y=>de("otherEditions",Y),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(wc,{entityType:se,entityId:e.id,entityTitle:e.title,parentWork:m==null?void 0:m.parentWork,parentCollection:m==null?void 0:m.parentCollection,belongsToWork:m==null?void 0:m.belongsToWork,belongsToCollection:m==null?void 0:m.belongsToCollection,childWorks:m==null?void 0:m.childWorks,childCollections:m==null?void 0:m.childCollections,containedBooks:m==null?void 0:m.containedBooks,siblingBooks:m==null?void 0:m.siblingBooks,onLinkEntity:We,onUnlinkEntity:we,onViewEntity:Pe,onCreateAndLink:Ee,onSaveRelations:fe}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),t.jsx(_c,{isOpen:x,entityType:y,title:S,onSelect:oe,onCancel:()=>k(!1),onCreate:()=>{k(!1),Ee(b,y)},searchResults:$,onSearch:ae,isLoading:C,excludeId:e.id}),t.jsx($c,{isOpen:N,entityType:F,relationField:E,inheritData:I,onConfirm:Z,onCancel:()=>T(!1)}),t.jsx(zc,{isOpen:V,title:f.action.selectBookOrWork,filterType:"all",recentEntities:A,excludeId:e.id,onSelect:me,onCancel:()=>{X(!1),O(null)},onSearch:$e})]})};function Df({items:e,onChange:n}){const o=Te(),r=(l,d,c)=>{const p=e.map((u,m)=>m===l?{...u,[d]:c}:u);n(p)},s=l=>n(e.filter((d,c)=>c!==l)),a=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((l,d)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(pt,{label:o.editor.bookNameLabel,value:l.book_title,onChange:c=>r(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(pt,{label:o.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>r(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.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)),t.jsx("button",{onClick:a,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 Nc({items:e,onChange:n,showMeta:o,addLabel:r}){const s=Te(),[a,l]=g.useState(null),d=(u,m,h)=>{const f=e.map((x,k)=>k===u?{...x,[m]:h||void 0}:x);n(f)},c=u=>{n(e.filter((m,h)=>h!==u)),a===u&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,m)=>{const h=a===m;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:h?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(h?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:h?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),t.jsx("button",{onClick:f=>{f.stopPropagation(),c(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!h&&o&&(u.title_info||u.author_info)&&t.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]}),h&&t.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(pt,{label:s.label.sourceName,value:u.source,onChange:f=>d(m,"source",f)}),t.jsx(pt,{label:s.label.sourceBid,value:u.source_bid||"",onChange:f=>d(m,"source_bid",f)})]}),o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(pt,{label:s.label.titleInfo,value:u.title_info||"",onChange:f=>d(m,"title_info",f)}),t.jsx(pt,{label:s.label.authorInfo,value:u.author_info||"",onChange:f=>d(m,"author_info",f)})]}),t.jsx(pt,{label:s.label.edition,value:u.edition||"",onChange:f=>d(m,"edition",f)})]}),t.jsx(Kt,{value:u.summary||"",onChange:f=>d(m,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(Kt,{value:u.comment||"",onChange:f=>d(m,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(Kt,{value:u.additional_comment||"",onChange:f=>d(m,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:r})]})}function Uf({items:e,onChange:n}){const o=Te();return t.jsx(Nc,{items:e,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function Vf({items:e,onChange:n}){const o=Te();return t.jsx(Nc,{items:e,onChange:n,addLabel:o.action.addEmendatedBy})}function Rc(e){var d,c,p,u,m,h,f;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",o=((p=e.publication_info)==null?void 0:p.year)||"",r=((u=e.current_location)==null?void 0:u.name)||"",s=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((h=e.page_count)==null?void 0:h.description)||"",a=typeof e.description=="object"&&e.description!==null&&e.description.text||"",l={id:e.id,title:e.title,type:e.type,author:n,publicationYear:o,holder:r,pages:s,description:a,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const x=e;if(Array.isArray(x.related_works)){const k=x.related_works.find(y=>y.relation==="part_of");k&&(l.parentWorkId=k.id,l.parentWorkName=k.title)}}if(e.type==="book"){const x=e;l.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(l.collectionId=(f=x.contained_in[0])==null?void 0:f.id)}return l}function Gf(e){const n={id:e.id,title:e.title,type:e.type,description:e.description?{text:e.description}:void 0,authors:e.author?[{name:e.author}]:void 0,publication_info:e.publicationYear?{year:e.publicationYear}:void 0,current_location:e.holder?{name:e.holder}:void 0,page_count:e.pages?{number:parseInt(e.pages)||0,description:e.pages}:void 0,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};return e.type==="work"&&e.parentWorkId&&(n.related_works=[{id:e.parentWorkId,title:e.parentWorkName||"",relation:"part_of"}]),e.type==="book"&&(n.work_id=e.workId,e.collectionId&&(n.contained_in=[{id:e.collectionId}])),n}const Yf=e=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:u,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y,headerExtra:w,className:b,style:j}=e,S=Te(),[v,$]=g.useState(s),_=a?s:v;g.useEffect(()=>{s!==v&&$(s)},[s]);const C=g.useCallback(()=>{const L=_==="view"?"edit":"view";a?a(L):$(L)},[_,a]),[M,N]=g.useState(null);g.useEffect(()=>{o&&r&&r.getItem(o).then(L=>{L&&N(L)})},[o,r]);const T=n||M,F=g.useMemo(()=>T?Rc(T):null,[T]),R=a||!n?t.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"?S.common.switchToEdit:S.common.switchToView,children:_==="view"?S.common.modeEdit:S.common.modeView}):null,E=t.jsxs(t.Fragment,{children:[R,w]});return!T&&!F?t.jsx(Zt,{}):_==="view"?t.jsx(Uo,{data:T,transport:r,onNavigate:p?L=>p(L):void 0,renderLink:u,headerExtra:E,className:b,style:j}):F?t.jsxs("div",{className:b,style:j,children:[E&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:E}),t.jsx(Tc,{data:F,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:r,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},Kf=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Ec=({isOpen:e,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=J(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,u]=g.useState(""),[m,h]=g.useState("idle"),[f,x]=g.useState(""),k=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),u(""),h("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=k.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(m==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[m,n]),g.useEffect(()=>{if(!e)return;const b=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){h("submitting"),x("");try{await o({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),h("success")}catch(b){h("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const w=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:qf,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:Xf,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:Zf,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Jf,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:ix,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),r&&t.jsx("a",{href:r,style:{fontSize:"13px",color:i("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:Kf.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...Qf,...a===b.value?ex:{}},children:[t.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),t.jsx("textarea",{ref:k,value:d,onChange:b=>c(b.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...tx,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:b=>u(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||m==="submitting","aria-label":s("feedback.contactLabel"),style:rx}),t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:ox,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!w,style:{...nx,opacity:w?1:.6,cursor:w?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},qf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Xf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},Zf={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Jf={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Qf={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"},ex={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},tx={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"},nx={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},ix={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},ox={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},rx={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"},zo="--bim-feedback-fab-offset",To=48,sx=16,ax=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:a}=J(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(r||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(zo,`calc(${c+To+sx}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(zo)}},[r,c]),t.jsxs(t.Fragment,{children:[!r&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...lx,zIndex:s??i("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":a("feedback.title"),title:a("feedback.title"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsx(Ec,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:o})]})},lx={position:"fixed",width:`${To}px`,height:`${To}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"},cx=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Ic=({onSubmit:e})=>{const{t:n}=J(),[o,r]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[u,m]=g.useState(""),h=g.useRef(null);g.useEffect(()=>{o&&setTimeout(()=>{var k;return(k=h.current)==null?void 0:k.focus()},100)},[o]);const f=async()=>{if(!(!o||!s.trim())){p("submitting"),m("");try{await e({type:o,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),r("bug")}catch(k){p("error"),m(k instanceof Error?k.message:n("feedback.submitFailedRetry"))}}},x=o&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:ia,children:t.jsxs("div",{style:hx,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:gx,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:ia,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:cx.map(k=>t.jsxs("button",{onClick:()=>r(k.value),style:{...dx,...o===k.value?px:{}},children:[t.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),t.jsx("textarea",{ref:h,value:s,onChange:k=>a(k.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...ux}}),t.jsx("input",{type:"text",value:l,onChange:k=>d(k.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:xx}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:f,disabled:!x,style:{...mx,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:fx,children:u})]})},ia={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},dx={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"},px={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},ux={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"},mx={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},hx={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},gx={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},fx={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},xx={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 oa(e){return typeof e=="function"?e():e??"/api/feedback"}const Lc=({resourceId:e,apiUrl:n})=>{const{t:o}=J(),[r,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=oa(n);l(!0);try{const m=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();m.success&&s(m.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const u=oa(n),m=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const h=await m.json().catch(()=>null);throw new Error((h==null?void 0:h.error)||o("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Sr,{items:r,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Ic,{onSubmit:c})})]})},bx=gi["zh-Hant"].relation,yx=gi["zh-Hant"].lossStatus,jx=gi["zh-Hant"].resourceKind,Ti=mn("zh-Hant"),_r=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function ra(e,n=Ti){return e?_r(bx,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function vx(e,n=Ti){return _r(yx,e)?n(`detail.lossStatus.${e}`):e}function kx(e,n=Ti){return _r(jx,e)?n(`detail.resourceKind.${e}`):""}function $r({authors:e,onNavigate:n,renderLink:o}){const{convert:r}=J(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=Qo(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(a.dynasty),"〕"]}),a.entity_id?t.jsx(Xe,{id:a.entity_id,label:r(a.name),onNavigate:n,renderLink:o,dense:!0}):r(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:r(d)})]},l)})}):null}function Ac(e,n,o=Ti){var c,p;const r=Zo(e,n),s=r.mirrors.map(u=>({key:u.key,label:u.label,description:u.description,rows:u.items.filter(m=>m.group_role!=="mirror"),mirrors:u.items.filter(m=>m.group_role==="mirror")})),a=r.buckets.filter(u=>u.key==="image"||u.key==="textImage").flatMap(u=>u.items);a.length&&s.push({key:"_images",label:s.length?o("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=r.buckets.find(u=>u.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:o("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=r.buckets.find(u=>u.key==="text"))==null?void 0:p.items)??[],groups:s}}function Pc(e,n){const o=(e.url?hn(e.url):void 0)||e.name,r=zl(e,n);return r?`${o}(${r})`:o}function Cr({item:e,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=J(),[a,l]=g.useState(!1),d=fi(e),c=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),p=s(Pc(e,n)),u=gn(e),m=Si(e,r)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const h=(f=e.metadata)!=null&&f.fragment||e.color_mode?t.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=e.metadata)==null?void 0:x.fragment)&&t.jsx("span",{className:"bim-d-tag",children:r("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?r("colorMode.color"):r("colorMode.bw")})]}):null;return u?t.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),h]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,h]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(or,{item:e})})]}),t.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":a,onClick:()=>l(h=>!h),children:a?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:d.expected})})})]})}function Mc({groups:e,listedVolumeCounts:n}){const{t:o,convert:r}=J();return t.jsx(t.Fragment,{children:e.map(s=>t.jsxs("div",{className:"bim-d-rg",children:[s.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:r(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:r(s.description)}),s.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:s.rows.map((a,l)=>t.jsx(Cr,{item:a,siblings:s.rows,listedVolumeCounts:n},`${a.id||a.url||a.name}-${l}`))})}),s.mirrors.length>0&&t.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&t.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:o("detail.mirror")}),s.mirrors.map((a,l)=>{const d=gn(a),c=r(Pc(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?r(a.details):void 0,children:[c," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]},l):t.jsx("span",{style:{marginRight:14},children:c},l)})]})]},s.key))})}const Pn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function No(e){var o;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=Pn.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const sa=12,wx=60,Bc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:a,back:l,railLinks:d})=>{var ae,oe,fe;const{t:c,convert:p,messages:u}=J(),m=g.useMemo(()=>[...e.books||[],...e.collections||[]],[e.books,e.collections]),[h,f]=g.useState(new Map),[x,k]=g.useState(!1),[y,w]=g.useState(""),[b,j]=g.useState(!1),S=m.length<=wx,v=S||x||!!y||b,$=g.useMemo(()=>v?m:m.slice(0,sa),[m,v]);g.useEffect(()=>{if(!n||$.length===0)return;const U=$.filter(me=>!h.has(me));if(U.length===0)return;let $e=!1;return Promise.all(U.map(me=>n.getItem(me).then(Ce=>{const Y=Ce??{};return[me,{id:me,title:Y.title,edition:Y.edition,resources:Y.resources,publication_info:Y.publication_info,current_location:Y.current_location,lineage:Y.lineage,measure_info:Y.measure_info}]}).catch(()=>[me,{id:me}]))).then(me=>{$e||f(Ce=>{const Y=new Map(Ce);for(const[ze,Me]of me)Y.set(ze,Me);return Y})}),()=>{$e=!0}},[n,$,h]);const _=g.useMemo(()=>m.map(U=>h.get(U)??{id:U}),[m,h]),C=m.length>0&&m.every(U=>h.has(U)),M=!!n&&$.some(U=>!h.has(U)),N=S||v,T=g.useMemo(()=>Nl(_,e.version_graph,{era:y,scanOnly:b,sort:N?"year":"default"}),[_,e.version_graph,y,b,N]),F=x?T.rows:T.rows.slice(0,sa),R=T.allRows.filter(U=>U.hasImage).length,E=e.related_works||[],L=E.filter(U=>U.relation==="collected_in"),I=g.useMemo(()=>{const U=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],$e=me=>{const Ce=U.indexOf(me??"");return Ce<0?U.length:Ce};return E.filter(me=>me.relation!=="collected_in").map((me,Ce)=>({r:me,i:Ce})).sort((me,Ce)=>$e(me.r.relation)-$e(Ce.r.relation)||me.i-Ce.i).map(me=>me.r)},[E]),P=g.useMemo(()=>{const U=Zo(e.resources,e.resource_groups);return[...U.mirrors.flatMap($e=>$e.items.map(me=>({r:me,kind:p($e.label)}))),...U.buckets.flatMap($e=>$e.items.map(me=>({r:me,kind:p(kx($e.key,c))})))]},[e.resources,e.resource_groups,p,c]),V=e.indexed_by||[],X=e.emendated_by||[],D=g.useMemo(()=>{var te,xe,Re;const U=[],$e=(xe=(te=e.authors)==null?void 0:te[0])==null?void 0:xe.dynasty;$e&&U.push({label:c("workPage.fact.written"),value:p($e)});const me=Nt(e,u.unit.juan);if(me){const H=(Re=e.juan_count)==null?void 0:Re.description;U.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(me),H&&H!==me?t.jsxs("span",{className:"bim-d-meta",children:["(",p(H),")"]}):null]})})}e.loss_status&&U.push({label:c("workPage.fact.loss"),value:p(vx(e.loss_status,c))});const Ce=T.allRows.filter(H=>H.sortYear!=null),Y=Ce.length>0?Ce.reduce((H,pe)=>H.sortYear<=pe.sortYear?H:pe):null;Y!=null&&Y.era.era?U.push({label:c("workPage.fact.earliest"),value:p([Y.era.era,Y.era.reign].filter(Boolean).join(" ")),title:Y.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):M&&U.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),X.length&&U.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:X.length})});const ze=aa(e.additional_titles);ze.length&&U.push({label:c("workPage.fact.alias"),value:ze.map(p).join("、")});const Me=aa(e.attached_texts);Me.length&&U.push({label:c("workPage.fact.attached"),value:Me.map(p).join("、")});const B=(e.additional_works||[]).map(H=>p(H.book_title)+(H.n_juan!=null?` ${H.n_juan}${u.unit.juan}`:""));return B.length&&U.push({label:c("workPage.fact.appendix"),value:B.join("、")}),U},[e,p,c,u,M,T.allRows,X.length]),A=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:C?R:0,label:c("workPage.stat.hasImage")},{value:V.length,label:c("workPage.stat.catalogs")}],G=e.classification,se=G?[G.l1,G.l2,G.l3,G.l4].filter(Boolean).map(U=>p(U)):[],Q=e.subtype?u.workSubtype[e.subtype]??p(e.subtype):"",ke=t.jsx(On,{title:p(e.title),byline:t.jsx($r,{authors:e.authors,onNavigate:o,renderLink:r}),meta:t.jsx(et,{items:[...se,G!=null&&G.source?c("workPage.classifiedBy",{source:p(G.source.split("/")[0])}):"",Q]}),description:(ae=e.description)!=null&&ae.text?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(oe=e.description.sources)!=null&&oe.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(U=>p(Om(U))).filter(Boolean).join(" · ")}):null]}):void 0,stats:A,facts:D,readAction:s,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(fe=e.appendix)==null?void 0:fe.map((U,$e)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(U.title)}),t.jsx(Tt,{text:U.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},$e))}),ne=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(U=>({key:U,label:`${U} ${T.allRows.filter($e=>$e.era.era===U).length}`}))]:[],de=[];m.length&&de.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),V.length&&de.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:V.length}),L.length&&de.push({id:"collected",label:c("workPage.sec.collected"),count:L.length}),I.length&&de.push({id:"related",label:c("workPage.sec.related"),count:I.length}),P.length&&de.push({id:"resources",label:c("workPage.sec.resources"),count:P.length});const We=m.length===0&&V.length===0,we=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(tt,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(et,{items:[c("workPage.versionsTotal",{n:m.length}),C&&R?c("workPage.versionsWithImage",{n:R}):"",T.rows.length!==T.allRows.length?c("workPage.versionsCurrent",{n:T.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":M&&ne.length===0&&m.length>1?"":void 0,children:[ne.length>0&&t.jsx($i,{items:ne,value:y,onChange:U=>{w(U),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Ml,{label:c("workPage.scanOnly"),checked:b,onChange:U=>{j(U),k(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(N?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Ci(T.rows.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("workPage.col.edition")}),t.jsx("th",{children:c("workPage.col.era")}),t.jsx("th",{children:c("workPage.col.holder")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),t.jsx("tbody",{children:F.map(U=>{var $e;return t.jsx(Sx,{row:U,measure:($e=h.get(U.id))==null?void 0:$e.measure_info,loaded:h.has(U.id),onNavigate:o,renderLink:r},`${U.id}:${h.has(U.id)?"r":"p"}`)})})]}),F.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(er,{total:T.rows.length,shown:F.length,unit:c("workPage.moreUnit"),onClick:()=>k(!0)}),T.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),V.length>0&&t.jsx(_x,{items:V,transport:n,onNavigate:o,renderLink:r}),We&&t.jsx(tt,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Pe=(U,$e)=>t.jsx(Xe,{id:U,label:p($e),onNavigate:o,renderLink:r,dense:!0}),Ee=g.useMemo(()=>{const U=new Map;for(const $e of I){const me=ra($e.relation,c);U.set(me,(U.get(me)??0)+1)}return U.size>1?[...U.entries()].sort(($e,me)=>me[1]-$e[1]).slice(0,4).map(([$e,me])=>`${p($e)} ${me}`).join(" · "):void 0},[I,p,c]),Z=t.jsxs(t.Fragment,{children:[t.jsx(Yt,{id:"collected",title:c("workPage.sec.collected"),items:L.map(U=>Pe(U.id,U.title))}),t.jsx(Yt,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:I.length}),sub:Ee,items:I.map(U=>t.jsxs(t.Fragment,{children:[Pe(U.id,U.title),t.jsx("span",{className:"bim-d-meta",title:U.note?p(U.note):void 0,children:p(ra(U.relation,c))})]}))}),t.jsx(Yt,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:P.map(({r:U,kind:$e})=>{const me=p((U.url?hn(U.url):void 0)||U.name),Ce=gn(U);return t.jsxs(t.Fragment,{children:[Ce?t.jsxs("a",{href:Ce,target:"_blank",rel:"noopener noreferrer",children:[me," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:me}),$e&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:$e})]})})})]});return t.jsx(Wn,{railTop:a,back:l,nav:de,railLinks:d,main:we,card:ke,side:Z})};function aa(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function la(e,n){return n((e.url?hn(e.url):void 0)||e.name)}function Sx({row:e,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:a,convert:l}=J(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],u=p?la(p,l):e.locationName?l(e.locationName):"",m=e.images[0],h=m?gn(m):void 0,f=e.images.map(x=>la(x,l)).join("、");return t.jsxs("tr",{"data-loading":o?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Xe,{id:e.id,label:l(e.name),onNavigate:r,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:c?a("workPage.inferredFromEdition"):void 0,children:d?l(d):o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${u?"":" bim-d-zt-blank"}`,children:[u||(o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(h?t.jsx("a",{className:"bim-d-flag",href:h,target:"_blank",rel:"noopener noreferrer",title:f,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:f,children:a("workPage.hasImage")}))})]})}function _x({items:e,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:a}=J(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[u,m]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const h=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(h.length===0)return;let f=!1;return Promise.all(h.map(x=>n.getItem(x).then(k=>{var y,w;return[x,((w=(y=k==null?void 0:k.authors)==null?void 0:y[0])==null?void 0:w.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||m(new Map(x.filter(([,k])=>k)))}),()=>{f=!0}},[n,e]),t.jsx(tt,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(et,{items:[s("workPage.catalog.meta",{n:e.length}),s("workPage.sortByCatalog")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:e.map((h,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(h.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(h.source_bid??"")?a(u.get(h.source_bid??"")):" "}),t.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...a(h.source)].slice(0,9).map((x,k)=>t.jsx("span",{children:x},k))})]})},f))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[p.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:a(p.title_info)}),t.jsx(et,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(Xe,{id:p.source_bid,label:a(p.source),onNavigate:o,renderLink:r,dense:!0}):a(p.source),p.section?a(p.section):"",p.author_info?`${s("label.authorInfo")} ${a(p.author_info)}`:"",p.edition?`${s("label.edition")} ${a(p.edition)}`:"",p.page??""]}),p.summary&&t.jsx("p",{className:"bim-d-quote",children:mt(a(p.summary),void 0,{t:s})}),p.comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),t.jsx("p",{className:"bim-d-quote",children:mt(a(p.comment),void 0,{t:s})})]}),p.additional_comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),t.jsx("p",{className:"bim-d-quote",children:mt(a(p.additional_comment),void 0,{t:s})})]}),!p.summary&&!p.comment&&!p.additional_comment&&!p.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:a(e[c-1].source)}),onClick:()=>d(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",a(e[c-1].source)]})}):t.jsx("span",{"aria-hidden":"true"}),t.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",e.length]}),c<e.length-1?t.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:a(e[c+1].source)}),onClick:()=>d(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[a(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function $x(e){var n;return{id:e.id,kind:"hypothetical",label:e.label,year:e.year??((n=e.year_range)==null?void 0:n[0]),year_range:e.year_range,year_uncertain:e.year_uncertain,group:e.group,note:e.note,description:e.description}}function Cx(e,n){if(!e.lineage)return null;const o=e.lineage;return{id:e.id,kind:"book",label:e.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[e.id],note:o.note}}function ca(e,n,o){return{id:`derive:${n.ref}->${e}:${o}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function zx(e,n,o){const[r,s]=[e,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 Tx(e,n){var p;if(n==="all")return null;const o=(p=e.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,a=r||s||!!(o!=null&&o.hypothetical_ids);if(!a&&n==="core"&&Array.isArray(e.core_books)&&e.core_books.length>0)return{books:new Set(e.core_books),hypos:e.core_hypotheticals?new Set(e.core_hypotheticals):null};if(!o||!a)return null;const l=r?new Set(o.groups):null,d=new Set(o.book_ids??[]);if(l&&e.node_groups)for(const[u,m]of Object.entries(e.node_groups))l.has(m)&&d.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),l){c||(c=new Set);for(const u of e.hypothetical_nodes??[])u.group&&l.has(u.group)&&c.add(u.id)}return{books:d,hypos:c}}function ai(e,n,o){const r=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const a=new Set(r.excluded_books??[]),l=r.node_groups??{},d=Tx(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,m=new Set,h=new Set;if(c){const S=new Map(n.map(N=>[N.id,N])),v=new Map((r.hypothetical_nodes??[]).map(N=>[N.id,N])),$=N=>{const T=S.get(N);if(T&&T.lineage)return(T.lineage.derived_from??[]).map(R=>R.ref);const F=v.get(N);return F?(F.derived_from??[]).map(R=>R.ref):[]},_=N=>v.has(N)?!u||u.has(N):!p||p.has(N),C=new Set,M=N=>{if(!C.has(N)){C.add(N);for(const T of $(N))a.has(T)||(_(T)||(v.has(T)?h.add(T):S.has(T)&&m.add(T)),M(T))}};for(const N of n)p&&p.has(N.id)&&!a.has(N.id)&&M(N.id);for(const N of r.hypothetical_nodes??[])u&&u.has(N.id)&&M(N.id)}const f=n.filter(S=>!a.has(S.id)).filter(S=>!p||p.has(S.id)||m.has(S.id)).map(S=>{const v=Cx(S,l);return v&&m.has(S.id)&&(v.bridge=!0),v}).filter(S=>S!==null),x=(r.hypothetical_nodes??[]).filter(S=>!u||u.has(S.id)||h.has(S.id)).map(S=>{const v=$x(S);return h.has(S.id)&&(v.bridge=!0),v}),k=[...f,...x],y=new Set(k.map(S=>S.id)),w=new Set,b=[],j=S=>{w.has(S.id)||!y.has(S.source)||!y.has(S.target)||(w.add(S.id),b.push(S))};for(const S of n)a.has(S.id)||!S.lineage||p&&!p.has(S.id)&&!m.has(S.id)||((S.lineage.derived_from??[]).forEach((v,$)=>{j(ca(S.id,v,$))}),(S.lineage.related_to??[]).forEach((v,$)=>{j(zx(S.id,v,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!h.has(S.id)||(S.derived_from??[]).forEach((v,$)=>{j(ca(S.id,v,$))});return{nodes:k,edges:b,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(a)}}function Wc(e,n,o){const r=(e??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function Nx(e,n){const o=[],r=e.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),a=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.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"&&!a.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 Oc=({graph:e,renderLink:n,className:o,style:r})=>{const{t:s,convert:a}=J();if(!e.nodes.length)return t.jsx("div",{style:{...Ux,...r},className:o,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const f of e.edges)if(f.kind==="derive"){const x=l.get(f.target)??[];x.push(f),l.set(f.target,x)}else for(const x of[f.source,f.target]){const k=d.get(x)??[];k.push(f),d.set(x,k)}const c=new Map(e.nodes.map(f=>[f.id,f])),p=new Map,u=[];for(const f of e.nodes)if(f.group){const x=p.get(f.group)??[];x.push(f),p.set(f.group,x)}else u.push(f);const m=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(m)),u.sort(m);const h=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:o,style:{...Ex,...r},children:[e.title&&t.jsx("div",{style:Ix,children:a(e.title)}),e.description&&t.jsx("div",{style:Lx,children:a(e.description)}),h.map(f=>t.jsx(da,{label:f.label,color:f.color,nodes:p.get(f.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},f.id)),u.length>0&&t.jsx(da,{label:s("lineage.otherGroup"),nodes:u,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},da=({label:e,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=J();return t.jsxs("div",{style:Ax,children:[t.jsx("div",{style:{...Px,borderLeftColor:n??i("widget-border")},children:d(e)}),o.map(c=>t.jsx(Rx,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Rx=({node:e,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=J();return t.jsxs("div",{style:{...Mx,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?i("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:Bx,children:[t.jsx("span",{style:Wx,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Ox,children:Wc(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Hx,children:[e.category&&t.jsx(Tn,{children:c(e.category)}),e.status==="lost"&&t.jsx(Tn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(Tn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(Tn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(Tn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Fx,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Dx,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:ua,children:[t.jsx("div",{style:ma,children:d("lineage.sources")}),n.map(p=>{const u=r.get(p.source);return t.jsxs("div",{style:ha(p.confidence),children:[t.jsx("span",{style:ga,children:c(p.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(pa,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:fa,children:["· ",c(p.evidence)]})]},p.id)})]}),o.length>0&&t.jsxs("div",{style:ua,children:[t.jsx("div",{style:ma,children:d("lineage.related")}),o.map(p=>{const u=p.source===e.id?p.target:p.source,m=r.get(u);return t.jsxs("div",{style:ha(p.confidence),children:[t.jsx("span",{style:ga,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??u)}),t.jsx(pa,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:fa,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Tn=({children:e,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 t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:e})},pa=({level:e})=>{const{t:n}=J(),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")}}[e];return r?t.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},Ex={fontSize:"14px",color:i("fg")},Ix={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Lx={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},Ax={marginBottom:"16px"},Px={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},Mx={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},Bx={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Wx={fontSize:"15px",fontWeight:600},Ox={fontSize:"12px",color:i("muted")},Hx={marginBottom:"6px"},Fx={fontSize:"12px",color:i("muted"),margin:"2px 0"},Dx={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},ua={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},ma={fontSize:"11px",color:i("muted"),marginBottom:"2px"},ha=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),ga={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},fa={fontSize:"11px",color:i("muted")},Ux={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},Hc=({selectedNodeId:e,...n})=>{const{t:o}=J(),[r,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return Vx().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),r==="loading"?t.jsx("div",{style:ba,children:o("lineage.graphLoading")}):r==="missing"||!a?t.jsxs("div",{style:ba,children:[t.jsx("div",{children:xa(o("lineage.graphMissing"),{xyflow:t.jsx("code",{children:"@xyflow/react"}),dagre:t.jsx("code",{children:"@dagrejs/dagre"})})}),t.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:xa(o("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Gx,{modules:a,selectedNodeId:e,...n})};function xa(e,n){return e.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function Vx(){try{const[e,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:e.ReactFlow,Background:e.Background,Controls:e.Controls,Handle:e.Handle,Position:e.Position,BaseEdge:e.BaseEdge,EdgeLabelRenderer:e.EdgeLabelRenderer,getSmoothStepPath:e.getSmoothStepPath,dagre:n,cssLoaded:o}}catch{return null}}const Gx=({graph:e,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:u,Position:m,BaseEdge:h,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:k}=l,y=g.useMemo(()=>({lineage:$=>{var I,P,V,X;const _=((I=$.data)==null?void 0:I.stepPosition)??.85,[C,M,N]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),T=!!((P=$.data)!=null&&P.isSibling),F=T?M:$.targetX-18,R=T?N:$.targetY-12,E=(V=$.data)==null?void 0:V.labelStyle,L=(X=$.data)==null?void 0:X.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(h,{id:$.id,path:C,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F}px,${R}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...L,...E},children:$.label})})]})}}),[h,f,x]),w=g.useMemo(()=>({version:$=>{const{t:_}=J(),C=$.data,M=C.kind==="hypothetical",N=C.status==="lost",T=C.isSelected,F=C.bridge,R=C.borderColor??i("muted"),E=F||M?"dashed":"solid",L=F?.5:N?.6:1;return t.jsxs("div",{style:{background:i(F?"bg-subtle":"bg"),border:`2px ${E} ${T?i("primary"):R}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:L,boxShadow:T?i("shadow-node-selected"):M||F?"none":i("shadow-node")},title:F?_("lineage.bridgeTitle"):void 0,children:[t.jsx(u,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:M||!C.renderLink?C.label:C.renderLink(C.bookId,C.label)}),C.description&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:C.description}),C.yearText&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:Wc(C.yearText,void 0,C.uncertain)}),N&&t.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:_("lineage.lost")}),t.jsx(u,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[u,m]),{convert:b}=J(),{rfNodes:j,rfEdges:S}=g.useMemo(()=>Yx(e,k,n,a,b),[e,k,n,a,b]);return t.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:t.jsxs(d,{nodes:j,edges:S,nodeTypes:w,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[t.jsx(c,{gap:16}),t.jsx(p,{showInteractive:!1})]})})};function Yx(e,n,o,r,s=a=>a??""){const d=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:d?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const p=new Map(e.groups.map(w=>[w.id,w.color??i("muted")]));for(const w of e.nodes)c.setNode(w.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const w of e.edges)w.kind==="derive"&&(u.has(w.relation)||c.setEdge(w.source,w.target));n.layout(c);const m=e.nodes.map(w=>{const b=c.node(w.id),j=r?w.id===r:void 0,S={kind:w.kind,label:s(w.label),bookId:w.kind==="book"?w.id:void 0,yearText:s(w.year_text??qx(w)),uncertain:w.year_uncertain,category:w.category,status:w.status,borderColor:w.group?p.get(w.group):void 0,renderLink:o,isSelected:j,description:s(w.description),bridge:w.bridge};return{id:w.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:S,draggable:!1,selected:j}}),h=.78,f=.06,x=new Map;for(const w of e.edges)w.kind==="derive"&&(x.has(w.source)||x.set(w.source,[]),x.get(w.source).push(w));const k=new Map;for(const[w,b]of x){if(b.length<=1)continue;const j=[...b].sort((v,$)=>{var M,N;const _=((M=c.node(v.target))==null?void 0:M.y)??0,C=((N=c.node($.target))==null?void 0:N.y)??0;return _-C}),S=j.length;j.forEach((v,$)=>{const _=($-(S-1)/2)*f;k.set(v.id,h+_)})}const y=e.edges.map(w=>Kx(w,k.get(w.id),s));return{rfNodes:m,rfEdges:y}}function Kx(e,n,o=r=>r??""){const r=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Xx(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:o(e.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function qx(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Xx(e){switch(e){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 ba={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},zr=({graph:e,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:u,style:m})=>{var S;const{t:h,convert:f}=J(),[x,k]=g.useState(n),y=v=>{k(v),a==null||a(v)},w=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:h("lineage.collectionAll"),description:h("lineage.collectionAllDesc")}]]})(),b=!!(d&&w.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:h("lineage.empty")});const j=l?(S=c==null?void 0:c[l])==null?void 0:S.description:void 0;return t.jsxs("div",{className:u,style:m,children:[t.jsxs("div",{style:Zx,children:[t.jsx("button",{onClick:()=>y("list"),style:io(x==="list"),children:h("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:io(x==="graph"),children:h("lineage.modeGraph")}),b&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:i("muted"),marginRight:4},children:h("lineage.collectionLabel")}),w.map(([v,$])=>{const _=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:io(l===v),title:$.description?f($.description):void 0,children:[f($.label),_!=null?` ${_}`:""]},v)})]})]}),b&&j&&t.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:f(j)}),x==="list"?t.jsx(Oc,{graph:e,renderLink:o}):t.jsx(Hc,{graph:e,renderLink:o,height:r,selectedNodeId:s})]})},Zx={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},io=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:e?i("primary"):"transparent",color:i(e?"primary-fg":"fg"),cursor:"pointer"}),ya=40,ja=2,Jx=9,Qx=new Set(["certain","consensus","probable","disputed"]);function oo(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Fc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:u})=>{var Re,H,pe,ee,be,Se,Be,De,Je,He,Ue;const m=Te(),{t:h,convert:f}=J(),[x,k]=g.useState(null),[y,w]=g.useState(new Map),[b,j]=g.useState([]),[S,v]=g.useState(new Map),[$,_]=g.useState(!1),[C,M]=g.useState("flow"),[N,T]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){k(null);return}let z=!1;return n.getItem(e.work_id).then(ie=>{!z&&ie&&ie.type==="work"&&k(ie)}).catch(()=>{}),()=>{z=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let z=!1;return n.getLineageGraph(e.work_id).then(ie=>{z||T(ie&&ie.nodes.length>1?ie:null)}).catch(()=>{z||T(null)}),()=>{z=!0}},[n,e.work_id]),g.useEffect(()=>{const z=e.contained_in||[];if(!n||z.length===0){w(new Map);return}let ie=!1;return Promise.all(z.map(re=>{const je=typeof re=="string"?re:re.id;return n.getItem(je).then(ye=>[je,ye]).catch(()=>[je,null])})).then(re=>{if(ie)return;const je=new Map;for(const[ye,he]of re)he&&je.set(ye,he);w(je)}),()=>{ie=!0}},[n,e.contained_in]);const F=g.useMemo(()=>{const z=new Set([...(x==null?void 0:x.books)||[],...e.related_books||[]]);return z.add(e.id),[...z]},[x==null?void 0:x.books,e.related_books,e.id]),R=F.length-1;g.useEffect(()=>{if(!n||R<=0){j([]);return}const z=F.length<=ya,ie=z?F:F.slice(0,8);let re=!1;return Promise.all(ie.map(je=>je===e.id?Promise.resolve({id:je,title:e.title,edition:e.edition,year:di(e)}):n.getItem(je).then(ye=>{const he=ye??{};return{id:je,title:he.title,edition:he.edition,year:ye?di(he):void 0}}).catch(()=>({id:je})))).then(je=>{if(re)return;const ye=je.filter(he=>he.id===e.id||he.title||he.edition);z&&ye.sort((he,Ne)=>(he.year??1/0)-(Ne.year??1/0)),j(ye)}),()=>{re=!0}},[n,F,R,e]);const E=e.lineage,L=g.useMemo(()=>[...((E==null?void 0:E.derived_from)||[]).filter(z=>z.ref_type==="book").map(z=>z.ref),...((E==null?void 0:E.related_to)||[]).map(z=>z.book_id)].filter(Boolean),[E]);g.useEffect(()=>{if(!n||L.length===0){v(new Map);return}let z=!1;return Promise.all(L.map(ie=>n.getItem(ie).then(re=>[ie,{id:ie,title:re==null?void 0:re.title,edition:re==null?void 0:re.edition}]).catch(()=>[ie,{id:ie}]))).then(ie=>{z||v(new Map(ie))}),()=>{z=!0}},[n,L]);const I=g.useMemo(()=>Ac(e.resources,e.resource_groups,h),[e.resources,e.resource_groups,h]),P=I.groups.reduce((z,ie)=>z+ie.rows.length+ie.mirrors.length,0),V=I.groups.length>0&&I.groups.every(z=>z.key==="_physical"),X=Bn(e),D=Al(e),O=Nt(e,m.unit.juan),A=new Set((e.contained_in||[]).map(z=>typeof z=="string"?0:Ln(z.volume_index).length).filter(z=>z>0)),G=z=>{var je;const ie=(je=e.base_edition)==null?void 0:je.find(ye=>ye.book_id===z&&ye.name);if(ie!=null&&ie.name)return ie.name;const re=S.get(z);return(re==null?void 0:re.edition)||(re==null?void 0:re.title)||""},se=g.useMemo(()=>{var ge,Ae,q,le,ce;const z=[];D&&z.push({label:h("bookPage.fact.editionType"),value:f(D),title:e.edition_type||(ge=e.lineage)!=null&&ge.category?void 0:h("bookPage.inferredFromEdition")}),(Ae=e.publication_info)!=null&&Ae.details?z.push({label:h("bookPage.fact.publication"),value:f(e.publication_info.details)}):(X.era||X.reign)&&z.push({label:h("bookPage.fact.era"),value:f([X.era,X.reign].filter(Boolean).join(" ")),title:X.source==="edition"?h("bookPage.inferredFromEdition"):void 0}),O&&z.push({label:h("bookPage.fact.measure"),value:f(O)});const ie=(e.contained_in||[]).flatMap(ve=>typeof ve=="string"?[]:Ln(ve.volume_index));ie.length&&z.push({label:h("bookPage.fact.volumes"),value:h("bookPage.volumesValue",{range:_i(ie,m.unit.volume),unit:m.unit.volume,n:ie.length})});const re=(((q=e.lineage)==null?void 0:q.derived_from)||[]).find(ve=>ve.relation==="底本"&&ve.ref_type==="book");re&&G(re.ref)&&z.push({label:h("bookPage.fact.baseEdition"),value:t.jsx(Xe,{id:re.ref,label:f(G(re.ref)),onNavigate:o,renderLink:r,dense:!0})});const je=(e.base_edition||[]).filter(ve=>ve&&ve.name);for(const ve of["底本","配補","參校"]){if(ve==="底本"&&re&&G(re.ref))continue;const Ve=je.filter(Oe=>Oe.role===ve);Ve.length&&z.push({label:f(ve),value:Ve.map((Oe,ht)=>t.jsxs(g.Fragment,{children:[ht>0&&"、",Oe.book_id?t.jsx(Xe,{id:Oe.book_id,label:f(Oe.name),onNavigate:o,renderLink:r,dense:!0}):f(Oe.name)]},ht))})}const ye=(e.provenance||[]).filter(ve=>ve&&ve.institution),he=(e.resources||[]).filter(ve=>(ve.types||(ve.type?[ve.type]:[])).includes("physical"));if(ye.length){z.push({label:h("bookPage.fact.holdings"),value:ye.slice(0,2).map(Oe=>f(Oe.institution)).join("、")+(ye.length>2?h("bookPage.andMorePlaces",{n:ye.length}):"")});const ve=ye.filter(Oe=>Oe.call_number).slice(0,2).map(Oe=>`${f(Oe.institution)} ${Oe.call_number}`);ve.length&&z.push({label:h("bookPage.fact.callNumber"),value:ve.join(";")+(ye.filter(Oe=>Oe.call_number).length>2?"…":"")});const Ve=ye.flatMap(Oe=>Oe.seals||[]).filter(Boolean);Ve.length&&z.push({label:h("bookPage.fact.seals"),value:f(Ve.join("、"))})}else he.length?z.push({label:h("bookPage.fact.holdings"),value:he.slice(0,2).map(ve=>f(ve.name)).join("、")+(he.length>2?h("bookPage.andMorePlaces",{n:he.length}):"")}):(le=e.current_location)!=null&&le.name&&z.push({label:h("bookPage.fact.holdings"),value:f(e.current_location.name)});const Ne=e.physical_description;if(Ne){const ve=[[h("bookPage.fact.leafStyle"),Ne.leaf_style],[h("bookPage.fact.binding"),Ne.binding],[h("bookPage.fact.dimensions"),Ne.dimensions],[h("bookPage.fact.condition"),Ne.condition]];for(const[Ve,Oe]of ve)Oe&&Oe.trim()&&z.push({label:Ve,value:f(Oe)})}(ce=e.page_count)!=null&&ce.description&&z.push({label:m.label.pageCount,value:f(e.page_count.description)});const K=[...ko(e.additional_titles),...ko(e.attached_texts)];return K.length&&z.push({label:h("bookPage.fact.aliases"),value:K.map(f).join("、")}),z},[e,f,m,h,X,D,O,S,o,r]),Q=f(e.title),ke=e.edition?f(e.edition):void 0,ne=((Re=e.lineage)==null?void 0:Re.year_text)||"",de=t.jsx(On,{kind:h("bookPage.kind"),title:Q,subtitle:ke,byline:t.jsx($r,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:o,renderLink:r}),meta:(()=>{const z=[D?f(D):"",X.era?f([X.era,X.reign].filter(Boolean).join("")):"",O?f(O):""].filter(Boolean);return z.length?t.jsx("span",{className:"bim-d-tags",children:z.map((ie,re)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(re,2)}`,children:ie},re))}):null})(),description:(H=e.description)!=null&&H.text?t.jsx(Tt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:nr((pe=e.description)==null?void 0:pe.text)?6:void 0,facts:se,readAction:s,secondaryAction:s&&P>0&&!V?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:h("bookPage.viewImages")}):void 0,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),We=e.contained_in||[],we=(a==null?void 0:a.chapters)||[],Pe=f(we[0]&&oo(we[0].title)[0].slice(-1)||"")||h("bookPage.chapterUnit"),Ee=h("bookPage.chapterCount",{n:we.length,unit:Pe}),Z=!!((ee=E==null?void 0:E.derived_from)!=null&&ee.length||(be=E==null?void 0:E.related_to)!=null&&be.length||(Se=e.appendix)!=null&&Se.length),ae=[],oe=h(V?"bookPage.sec.physical":"bookPage.sec.images");(we.length||I.text.length||l)&&ae.push({id:"fulltext",label:h("bookPage.sec.fulltext"),count:we.length?Ee:void 0}),I.groups.length&&ae.push({id:"images",label:oe,count:P}),Z&&ae.push({id:"lineage",label:h("bookPage.sec.lineage")}),We.length&&ae.push({id:"collections",label:h("section.containedIn"),count:We.length}),(Be=e.location_history)!=null&&Be.length&&ae.push({id:"provenance",label:h("section.locationHistory")});const fe=z=>(d==null?void 0:d(z))??null,U=we[0],$e=U?fe(U.file):null,me=$?we:we.slice(0,Jx),Ce=(z,ie,re)=>z?t.jsx("a",{className:re,href:z.href??"#",onClick:z.onClick?je=>{je.metaKey||je.ctrlKey||(je.preventDefault(),z.onClick())}:void 0,children:ie}):t.jsx("span",{className:re,children:ie}),Y=t.jsxs(t.Fragment,{children:[(we.length>0||I.text.length>0||l)&&t.jsxs(tt,{id:"fulltext",title:h("bookPage.sec.fulltext"),meta:we.length>0?t.jsx(et,{items:[Ee,(De=a==null?void 0:a.source)!=null&&De.name?h("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!U&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[t.jsx("span",{className:"bim-d-ft-h",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "})]}),t.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),U&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:h("bookPage.readFrom",{ch:f(oo(U.title)[0])||h("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((U.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),Ce($e,t.jsxs(t.Fragment,{children:[h("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),we.length>1&&t.jsx("ul",{className:"bim-d-chap",children:me.map(z=>{const[ie,re]=oo(z.title);return t.jsx("li",{children:Ce(fe(z.file),t.jsxs(t.Fragment,{children:[ie&&t.jsx("b",{children:f(ie)}),f(re||z.file)]}))},z.file)})}),we.length>me.length&&t.jsx(tr,{label:h("detail.expandRest",{n:we.length-me.length,unit:Pe}),onClick:()=>_(!0)}),I.text.length>0&&t.jsxs(t.Fragment,{children:[(we.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:h("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:I.text.map((z,ie)=>t.jsx(Cr,{item:z,siblings:I.text,listedVolumeCounts:A},`${z.id||z.url||z.name}-${ie}`))})})]})]}),I.groups.length>0&&t.jsx(tt,{id:"images",title:oe,meta:t.jsx(et,{items:[I.groups.length>1?h("bookPage.groupCount",{n:I.groups.length}):"",h("bookPage.placeCount",{n:P})]}),children:t.jsx(Mc,{groups:I.groups,listedVolumeCounts:A})}),Z&&t.jsx(tt,{id:"lineage",title:h("bookPage.sec.lineage"),meta:(Je=E==null?void 0:E.derived_from)!=null&&Je.length?h("bookPage.lineageMeta"):void 0,action:N?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":h("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":C==="flow",onClick:()=>M("flow"),children:h("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":C==="graph",onClick:()=>M("graph"),children:h("bookPage.viewGraph")})]}):void 0,children:C==="graph"&&N?t.jsx(zr,{graph:N,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(z,ie)=>t.jsx(Xe,{id:z,label:f(ie),onNavigate:o,renderLink:r,dense:!0})}):t.jsx(tb,{data:e,heading:ke||Q,yearText:ne,refName:G,onNavigate:o,renderLink:r})}),We.length>0&&t.jsx(tt,{id:"collections",title:h("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:We.map((z,ie)=>{var Ne,K;const re=typeof z=="string"?z:z.id,je=typeof z=="string"?[]:Ln(z.volume_index),ye=y.get(re),he=(ye==null?void 0:ye._member_count)||((Ne=ye==null?void 0:ye.books)==null?void 0:Ne.length)||((K=ye==null?void 0:ye.contained_works)==null?void 0:K.length)||0;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Xe,{id:re,label:ye?f(ye.title):re,onNavigate:o,renderLink:r,dense:!0}),je.length>0&&t.jsx(eb,{volumes:je,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${he?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:he>0&&h("bookPage.totalOf",{n:he,unit:m.unit.bu})})]},`${re}-${ie}`)})})})}),(He=e.location_history)!=null&&He.length?t.jsx(tt,{id:"provenance",title:h("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((z,ie)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(z.name)}),([z.start_date,z.end_date].filter(Boolean).join("—")||z.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(et,{items:[[z.start_date,z.end_date].filter(Boolean).join("—"),z.description?f(z.description):""]})})]},ie))})}):null,ae.length===0&&t.jsx(tt,{title:h("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:h("bookPage.emptyText")})})]}),ze=b.findIndex(z=>z.id===e.id),Me=F.length<=ya,B=Me&&ze>=0?b.slice(Math.max(0,ze-ja),ze+ja+1):b.filter(z=>z.id!==e.id),te=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(m.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(Xe,{id:x.id,label:f(x.title),onNavigate:o,renderLink:r})}),t.jsx(et,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(z=>`${z.dynasty?`〔${f(z.dynasty)}〕`:""}${f(z.name)}`),f(Nt(x,m.unit.juan)),x._edition_count?h("bookPage.editionCount",{n:x._edition_count}):""]}),((Ue=x.description)==null?void 0:Ue.text)&&t.jsx("p",{style:{fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc bim-d-side-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),R>0&&B.length>0&&t.jsxs("div",{children:[t.jsx(Yt,{id:"siblings",timeline:!0,title:Me?h("bookPage.siblings"):m.relation.siblingVersions,meta:Me?h("bookPage.byEra"):h("bookPage.kindCount",{n:R}),cap:B.length,items:B.map(z=>z.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(z.edition||z.title||z.id)}):t.jsx(Xe,{id:z.id,label:f(z.edition||z.title||z.id),onNavigate:o,renderLink:r,dense:!0})),metas:B.map(z=>[z.year!=null?z.year<0?h("detail.bce",{n:-z.year}):String(z.year):"",z.id===e.id?h("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:B.findIndex(z=>z.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(Xe,{id:x.id,label:h("bookPage.viewAllInWork",{n:F.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),xe=e.work_id?t.jsx(Pl,{caption:m.section.belongsToWork,children:t.jsx(Xe,{id:e.work_id,label:x?f(x.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return t.jsx(Wn,{railTop:c,back:p,up:xe,nav:ae,railLinks:u,main:Y,card:de,side:te})};function eb({volumes:e,unit:n}){const{t:o}=J();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:_i(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),o("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function tb({data:e,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:a}){var w;const{t:l,convert:d}=J(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],u=p.filter(b=>b.ref_type!=="book"),m=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),h=p.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=p.length>0||f.length>0,k=b=>b&&Qx.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,j)=>t.jsx(Xe,{id:b,label:d(j||b),onNavigate:s,renderLink:a,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[x&&t.jsxs("ol",{className:"bim-d-lf-list",children:[u.map((b,j)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?d(b.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),k(b.confidence)]})]})},`a-${j}`)),m.map((b,j)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]})},`b-${j}`)),t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[t.jsxs("div",{className:"bim-d-lf-here",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:l("bookPage.lineage.thisEdition")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),o&&t.jsx("span",{className:"bim-d-lf-yr",children:d(o)})]}),h.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:h.map((b,j)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),k(b.confidence)]})]},j))})]}),f.length>0&&t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[t.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:l("bookPage.lineage.derivatives")}),t.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,j)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[y(b.book_id,r(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},j))})]})]}),(w=e.appendix)==null?void 0:w.map((b,j)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:l("bookPage.lineage.appendix")})," ",d(b.title)]}),t.jsx(Tt,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${j}`)),(c==null?void 0:c.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(c.note)})]})}const Nn=16,nb=200,ib=16,Dc=({data:e,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var Y,ze,Me,B,te,xe,Re;const{t:p,convert:u,messages:m}=J(),[h,f]=g.useState(""),[x,k]=g.useState(!1),[y,w]=g.useState(null),[b,j]=g.useState(""),[S,v]=g.useState(!1),$=g.useMemo(()=>Il(e,n),[e,n]),[_,C]=g.useState(new Map),M=!!o&&$.rows.length>0&&$.rows.length<=nb,N=M&&($.rows.length<=Nn||S),T=N&&$.rows.every(H=>!H.id||_.has(H.id)),F=H=>{var pe;return No(H?(pe=_.get(H))==null?void 0:pe.l1:void 0)},R=g.useMemo(()=>{const H=h.trim(),pe=H?u(H):"";return $.rows.filter(ee=>{var Se,Be;if(b&&No(ee.id?(Se=_.get(ee.id))==null?void 0:Se.l1:void 0)!==b)return!1;if(!pe)return!0;const be=ee.id&&((Be=_.get(ee.id))==null?void 0:Be.title)||ee.title;return u(be).includes(pe)||(ee.subItems||[]).some(De=>u(De).includes(pe))})},[$.rows,h,b,_,u]),E=x?R:R.slice(0,Nn),L=g.useMemo(()=>(N?$.rows:E).filter(H=>H.id&&!_.has(H.id)).map(H=>H.id),[N,$.rows,E,_]);g.useEffect(()=>{if(!o||L.length===0)return;let H=!1;const pe=L.slice(0,ib);return Promise.all(pe.map(ee=>o.getItem(ee).then(be=>{var De,Je;const Se=be??{},Be={title:Se.title,edition:Se.edition,authors:Se.authors,measure:be?Nt(be,m.unit.juan):void 0,versionCount:Se._edition_count??((De=Se.books)==null?void 0:De.length),l1:((Je=Se.classification)==null?void 0:Je.l1)||void 0};return[ee,Be]}).catch(()=>[ee,{}]))).then(ee=>{H||C(be=>{const Se=new Map(be);for(const[Be,De]of ee)Se.set(Be,De);return Se})}),()=>{H=!0}},[o,L,m.unit.juan]);const I=(e.contained_in||[])[0];g.useEffect(()=>{if(!I){w(null);return}if(w({id:I}),!o)return;let H=!1;return o.getItem(I).then(pe=>{H||w({id:I,title:pe==null?void 0:pe.title})}).catch(()=>{}),()=>{H=!0}},[o,I]);const P=g.useMemo(()=>Ac(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),V=P.text.length+P.groups.reduce((H,pe)=>H+pe.rows.length+pe.mirrors.length,0),X=e.contained_works||[],D=new Set($.rows.map(H=>H.id).filter(Boolean)),O=X.length>0&&!X.every(H=>D.has(H.id)),A=(()=>{const H=$.rows.map(pe=>pe.edition).filter(Boolean);return H.length>1&&new Set(H).size===1})(),G=$.rows.some(H=>H.volumes.length>0||H.expected!=null),se=e._member_count||((Y=e.books)==null?void 0:Y.length)||X.length,Q=e._members_truncated?se:$.rows.length,ke=Nt(e,m.unit.juan),ne=e.count,de=H=>typeof H=="number"&&Number.isFinite(H)?H:null,We=de(ne==null?void 0:ne.juan)??de((ze=e.juan_count)==null?void 0:ze.number),we=de(ne==null?void 0:ne.ce)??($.totalVolumes||null),Pe=[{value:Q,label:p("collectionPage.stat.titles")},{value:We??0,label:m.unit.juan},{value:we??0,label:m.unit.volume}],Ee=g.useMemo(()=>{var ee,be;const H=[];if((ee=e.publication_info)!=null&&ee.details&&H.push({label:p("collectionPage.fact.publication"),value:u(e.publication_info.details)}),se&&(se!==$.rows.length||e._members_truncated)){const Se=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");H.push({label:Se,value:`${se} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const pe=[de(ne==null?void 0:ne.zhong)!=null?p("collectionPage.nZhong",{n:ne.zhong}):"",de(ne==null?void 0:ne.han)!=null?p("collectionPage.nHan",{n:ne.han}):""].filter(Boolean);return pe.length&&H.push({label:p("collectionPage.fact.expected"),value:pe.join(" ")}),We==null&&ke&&H.push({label:p("collectionPage.fact.measure"),value:u(ke),title:(be=e.juan_count)!=null&&be.description?u(e.juan_count.description):void 0}),H},[e,se,$.rows.length,We,ke,ne,u,p,m]),Z=g.useMemo(()=>{if(!T)return[];const H=new Map;for(const ee of $.rows){const be=F(ee.id);be&&H.set(be,(H.get(be)??0)+1)}const pe=Pn.filter(ee=>(H.get(ee.key)??0)>0);return pe.length<2?[]:[{key:"",label:`${m.catalog.all} ${Q}`},...pe.map(ee=>({key:ee.key,label:`${ee.label} ${H.get(ee.key)}`}))]},[T,$.rows,_,m]),ae=g.useMemo(()=>{if(!T||!$.rows.some(be=>be.volumes.length>0))return null;const H=[],pe=$.rows.filter(be=>be.volumes.length>0).map(be=>({k:F(be.id)??"",from:Math.min(...be.volumes),to:Math.max(...be.volumes)})).sort((be,Se)=>be.from-Se.from);for(const be of pe){const Se=be.to-be.from+1,Be=H[H.length-1];Be&&Be.key===be.k?(Be.to=Math.max(Be.to,be.to),Be.n+=Se):H.push({key:be.k,from:be.from,to:be.to,n:Se})}const ee=pe.reduce((be,Se)=>Math.max(be,Se.to),0);return H.length>1&&H.some(be=>be.key)?{segs:H,last:ee}:null},[T,$.rows,_]),oe=(Me=e.description)==null?void 0:Me.text,fe=t.jsx(On,{kind:p("collectionPage.kind"),title:u(e.title),byline:t.jsx($r,{authors:e.authors,onNavigate:r,renderLink:s}),meta:t.jsx(et,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(B=e.publication_info)!=null&&B.year?u(e.publication_info.year):""]}),description:oe||(te=e.history)!=null&&te.length?t.jsxs(t.Fragment,{children:[oe&&t.jsx(Tt,{text:oe,style:{fontSize:15,lineHeight:1.85}}),(xe=e.history)!=null&&xe.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((H,pe)=>t.jsx("li",{children:u(H)},pe))}):null]}):void 0,clampDescription:nr(oe)||(((Re=e.history)==null?void 0:Re.length)??0)>2?6:void 0,stats:Pe,facts:Ee,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:ae&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:p("collectionPage.dist.head")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":p("collectionPage.dist.head"),children:ae.segs.map((H,pe)=>{const ee=Pn.find(be=>be.key===H.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!ee,title:ee?p("collectionPage.dist.segTitle",{section:u(ee.label),from:H.from,to:H.to}):void 0,"aria-label":ee?p("collectionPage.dist.only",{section:u(ee.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!ee&&b===H.key,style:{flexGrow:H.n,background:i(ee?ee.token:"rule")},onClick:()=>{ee&&(j(b===H.key?"":H.key),k(!1))}},pe)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:p("catalog.volume",{n:1})}),t.jsx("span",{children:p("collectionPage.dist.hint")}),t.jsx("span",{children:p("catalog.volume",{n:ae.last})})]})]})}),U=[];$.rows.length&&U.push({id:"titles",label:p("collectionPage.sec.titles"),count:Q}),V&&U.push({id:"resources",label:p("collectionPage.sec.resources"),count:V}),O&&U.push({id:"works",label:m.section.containedWorks,count:X.length});const $e=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(tt,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(et,{items:[`${Q} ${m.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:m.unit.volume}):"",R.length!==Q?p("collectionPage.currentN",{n:R.length,unit:m.unit.items}):""]}),action:a,children:[($.rows.length>Nn||Z.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Z.length>0&&t.jsx($i,{items:Z,value:b,onChange:H=>{j(H),k(!1)}}),M&&$.rows.length>Nn&&!T&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:S,onClick:()=>v(!0),title:p("collectionPage.loadAllTitle",{n:$.rows.length,unit:m.unit.items}),children:p(S?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),$.rows.length>Nn&&t.jsx("input",{type:"search",className:"bim-d-find",value:h,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:H=>{f(H.target.value),k(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Ci(R.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[G&&t.jsx("th",{style:{width:"8.5em"},children:p("collectionPage.col.volumes")}),t.jsx("th",{children:p("collectionPage.col.title")}),t.jsx("th",{style:{textAlign:"right"},children:p("collectionPage.col.versions")})]})}),t.jsx("tbody",{children:E.map((H,pe)=>{var He;const ee=H.id?_.get(H.id):void 0,be=ee!=null&&ee.title&&H.title===H.id?ee.title:H.title,Se=((ee==null?void 0:ee.authors)||[]).find(Ue=>Ue&&Ue.name),Be=[Se?`${Se.dynasty?`〔${u(Se.dynasty)}〕`:""}${u(Se.name)}${Se.role?` ${u(Se.role)}`:""}`:"",ee!=null&&ee.measure?u(ee.measure):"",(He=H.subItems)!=null&&He.length?H.subItems.map(Ue=>u(Ue)).join("、"):"",(ee!=null&&ee.edition||H.edition)&&!A?u((ee==null?void 0:ee.edition)||H.edition||""):""].filter(Boolean),De=Pn.find(Ue=>Ue.key===F(H.id)),Je=H.volumes.length>0?p("collectionPage.volumeRange",{range:_i(H.volumes,m.unit.volume),unit:m.unit.volume}):H.expected!=null?`${H.found??0}/${H.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[G&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Je?"":" bim-d-zt-blank"}`,children:[De&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(De.token)}}),Je||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[H.id?t.jsx(Xe,{id:H.id,label:u(be),onNavigate:r,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:u(be)}),Be.length>0?t.jsx(et,{items:Be}):H.id&&!ee&&o?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ee!=null&&ee.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ee!=null&&ee.versionCount?p("collectionPage.nZhong",{n:ee.versionCount}):""})]},`${H.id??H.title}-${pe}`)})})]}),E.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(er,{total:R.length,shown:E.length,unit:m.unit.items,onClick:()=>k(!0)})]}),V>0&&t.jsxs(tt,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:V}),children:[P.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[P.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:P.text.map((H,pe)=>t.jsx(Cr,{item:H,siblings:P.text},`${H.id||H.url||H.name}-${pe}`))})})]}),t.jsx(Mc,{groups:P.groups})]}),$.rows.length===0&&V===0&&t.jsx(tt,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),me=O?t.jsx(Yt,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:X.length}),cap:12,items:X.map(H=>t.jsx(Xe,{id:H.id,label:u(H.title),onNavigate:r,renderLink:s,dense:!0}))}):null,Ce=y?t.jsx(Pl,{caption:p("collectionPage.parent"),children:t.jsx(Xe,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return t.jsx(Wn,{railTop:l,back:d,up:Ce,nav:U,railLinks:c,main:$e,card:fe,side:me})},ob=16,ro=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function va(e){if(!e)return ro.length;const n=ro.indexOf(e);return n===-1?ro.length:n}function rb(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const sb={秦:[-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]},Uc=({data:e,transport:n,onNavigate:o,renderLink:r,railTop:s,back:a,railLinks:l})=>{var me,Ce,Y,ze,Me;const{t:d,convert:c,messages:p}=J(),u=B=>rb(B,d),[m,h]=g.useState("全部"),[f,x]=g.useState(!1),[k,y]=g.useState("default"),[w,b]=g.useState(new Map),j=g.useMemo(()=>(e.works||[]).map(B=>{const te=w.get(B.work_id);return{id:B.work_id,title:(te==null?void 0:te.title)??B.title??B.work_id,role:B.role||"",cls:Jo(B.role),versionCount:te==null?void 0:te.versionCount,section:te==null?void 0:te.cls,l1:te==null?void 0:te.l1,measure:te==null?void 0:te.measure,hasImage:te==null?void 0:te.hasImage,loaded:!!(te!=null&&te.loaded)}}),[e.works,w]),S=g.useMemo(()=>El((e.works||[]).map(B=>B.role),d("detail.roleAll")),[e.works,d]),v=g.useMemo(()=>{const B=m==="全部"?j:j.filter(te=>te.cls===m);return k==="versions"?[...B].sort((te,xe)=>(xe.versionCount??-1)-(te.versionCount??-1)):B},[j,m,k]),$=f?v:v.slice(0,ob),_=g.useMemo(()=>$.filter(B=>!w.has(B.id)).map(B=>B.id),[$,w]);g.useEffect(()=>{if(!n||_.length===0)return;let B=!1;return Promise.all(_.map(te=>n.getItem(te).then(xe=>{var ee,be,Se,Be,De;const Re=xe??{},H=Re._edition_count??(((ee=Re.books)==null?void 0:ee.length)??0)+(((be=Re.collections)==null?void 0:be.length)??0),pe=[(Se=Re.classification)==null?void 0:Se.l1,(Be=Re.classification)==null?void 0:Be.l2].filter(Boolean).join(" ");return[te,{id:te,title:Re.title,versionCount:H,loaded:!0,cls:pe||void 0,l1:((De=Re.classification)==null?void 0:De.l1)||void 0,measure:xe&&Nt(xe,p.unit.juan)||void 0,hasImage:!!(Re.has_image??Re._has_image)}]}).catch(()=>[te,{id:te,loaded:!0}]))).then(te=>{B||b(xe=>{const Re=new Map(xe);for(const[H,pe]of te)Re.set(H,pe);return Re})}),()=>{B=!0}},[n,_,p.unit.juan]);const C=g.useMemo(()=>{const B=new Map;for(const te of e.alt_names||[]){const xe=te.type||p.section.aliases;B.has(xe)||B.set(xe,[]),B.get(xe).push(te.name)}return[...B.entries()].sort((te,xe)=>va(te[0])-va(xe[0])).map(([te,xe])=>({label:te,names:xe}))},[e.alt_names,p]),M=e.birth_year??((me=e.dates)==null?void 0:me.birth)??void 0,N=e.death_year??((Ce=e.dates)==null?void 0:Ce.death)??void 0,T=(Y=e.dates)==null?void 0:Y.floruit,F=M!=null||N!=null?`${u(M)||"?"}—${u(N)||"?"}`:Array.isArray(T)&&T.length===2&&T.every(B=>Number.isFinite(B))?d("entityPage.floruit",{from:u(T[0]),to:u(T[1])}):"",R=new Set(["本名","字","號","号"]),E=C.filter(B=>R.has(B.label)),L=C.filter(B=>!R.has(B.label)),I=L.reduce((B,te)=>B+te.names.length,0),P=g.useMemo(()=>{const B=[];for(const xe of E)B.push({label:xe.label,value:xe.names.map(Re=>c(Re)).join("、")});const te=(e.works||[]).length;return te&&B.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:te})}),B},[e.works,E,c,d]),V=B=>{var te;return(te=C.find(xe=>B.includes(xe.label)))==null?void 0:te.names[0]},X=V(["字"]),D=V(["號","号"]),O=[X?d("entityPage.zi",{name:c(X)}):"",D?d("entityPage.hao",{name:c(D)}):""].filter(Boolean).join(","),A=e.native_place,G=e.dynasty?sb[e.dynasty]:void 0,se=(()=>{if(!G||M==null||N==null||N<M)return null;const[B,te]=G,xe=Math.max(M,B),Re=Math.min(N,te);if(Re<=xe)return null;const H=te-B;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":d("entityPage.lifeAria",{birth:u(M),death:u(N),years:N-M+1}),children:t.jsx("i",{style:{left:`${(xe-B)/H*100}%`,width:`${(Re-xe)/H*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${u(B)} ${c(e.dynasty)}`}),t.jsx("span",{children:d("entityPage.lifeYears",{years:N-M+1})}),t.jsx("span",{children:u(te)})]})]})})(),Q=g.useMemo(()=>{if(!n||j.length===0||j.some(xe=>!xe.loaded))return null;const B=new Map;for(const xe of j){const Re=No(xe.l1);Re&&B.set(Re,(B.get(Re)??0)+1)}const te=Pn.map(xe=>({...xe,n:B.get(xe.key)??0})).filter(xe=>xe.n>0);return te.length?te:null},[j,n]),ke=t.jsxs(On,{kind:p.entityPage.subtype[e.subtype]??d("entityPage.subtype.people"),title:c(e.primary_name||e.title),subtitle:O||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(et,{items:[e.dynasty?c(e.dynasty):"",F,A?d("entityPage.nativePlace",{place:c(A)}):""]}),se]}),description:(ze=e.description)!=null&&ze.text?t.jsx(Tt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:nr((Me=e.description)==null?void 0:Me.text)?6:void 0,facts:P,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[I>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:d("entityPage.moreNames",{n:I})}),t.jsx("dl",{children:L.map(B=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(B.label)}),t.jsx("dd",{children:B.names.map(te=>c(te)).join("、")})]},B.label))})]}),Q&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:d("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:Q.map(B=>t.jsx("i",{style:{flexGrow:B.n,background:i(B.token)}},B.key))}),t.jsx("div",{className:"bim-d-dist-key",children:Q.map(B=>t.jsxs("span",{children:[t.jsx("i",{style:{background:i(B.token)}}),c(B.label)," ",B.n]},B.key))})]})]}),ne=g.useMemo(()=>j.filter(B=>B.loaded&&(B.versionCount??0)>0).sort((B,te)=>(te.versionCount??0)-(B.versionCount??0)).slice(0,3),[j]),de=!!n&&j.length>=3&&$.some(B=>!B.loaded),We=m==="全部"&&(de||ne.length>=2),we=e.external_ids||{},Pe=[];we.cbdb_id!=null&&Pe.push({label:"CBDB",id:String(we.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${we.cbdb_id}`,note:we.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const Ee=we.wikidata_id;Ee&&Pe.push({label:"Wikidata",id:Ee,href:`https://www.wikidata.org/wiki/${Ee}`});const Z=we.viaf_id;Z&&Pe.push({label:"VIAF",id:Z,href:`https://viaf.org/viaf/${Z}`});const ae=S.map(B=>({key:B.cls,label:`${B.label} ${B.count}`})),oe=[...We&&!de?[{id:"featured",label:d("entityPage.sec.featured"),count:ne.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...Pe.length?[{id:"external",label:d("entityPage.sec.external"),count:Pe.length}]:[]],fe=We?t.jsxs(tt,{id:"featured",title:d("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:d("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":de||void 0,children:[de&&[0,1,2].map(B=>t.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[t.jsx("span",{className:"bim-d-pick-t",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "}),t.jsx("div",{className:"bim-d-pick-n",children:" "})]},B)),!de&&ne.map(B=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(Xe,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0})}),t.jsx(et,{items:[B.section?c(B.section):"",B.measure?c(B.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:B.versionCount}),t.jsx("span",{children:d("entityPage.versionsUnit")}),B.hasImage&&t.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},B.id))]})]}):null,U=j.length===0?t.jsx(tt,{title:d("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[fe,t.jsxs(tt,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(et,{items:[d("entityPage.total",{n:j.length}),v.length!==j.length?d("entityPage.current",{n:v.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[ae.length>1&&t.jsx($i,{items:ae,value:m,onChange:B=>{h(B),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":k==="versions",onClick:()=>{k==="default"&&x(!0),y(B=>B==="default"?"versions":"default")},children:d(k==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&Ci(v.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:d("entityPage.col.work")}),t.jsx("th",{children:d("entityPage.col.section")}),t.jsx("th",{children:d("entityPage.col.role")}),t.jsx("th",{children:d("entityPage.col.versions")}),t.jsx("th",{"aria-label":d("entityPage.col.image")})]})}),t.jsx("tbody",{children:$.map(B=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Xe,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0}),B.measure?t.jsx(et,{items:[c(B.measure)]}):!B.loaded&&n?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.section||B.loaded?"":" bim-d-zt-blank"}`,children:B.section?c(B.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.role?"":" bim-d-zt-blank"}`,children:B.role?c(B.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${B.loaded?"":" bim-d-zt-blank"}`,children:B.loaded?B.versionCount?d("entityPage.nZhong",{n:B.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),t.jsx("td",{className:B.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:B.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},B.id))})]}),$.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("entityPage.emptyRole")}),!f&&t.jsx(er,{total:v.length,shown:$.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),$e=Pe.length>0?t.jsx(Yt,{id:"external",title:d("entityPage.sec.external"),items:Pe.map(B=>t.jsxs("a",{href:B.href,target:"_blank",rel:"noopener noreferrer",children:[B.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Pe.map(B=>B.id),foot:we.cbdb_id!=null&&we.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Wn,{railTop:s,back:a,nav:oe,railLinks:l,main:U,card:ke,side:$e})},Tr="(max-width: 719px)",ab=`${Tr}, (pointer: coarse)`,Vc=`
|
|
1306
1306
|
.bim-ct {
|
|
1307
1307
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1308
1308
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1435,7 +1435,7 @@ ${he??""}`,[Qt,xn]=g.useState({key:Ot,data:z,started:!!z});if(Qt.key!==Ot)xn({ke
|
|
|
1435
1435
|
}
|
|
1436
1436
|
|
|
1437
1437
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1438
|
-
@media ${
|
|
1438
|
+
@media ${ab} {
|
|
1439
1439
|
.bim-ct-row { min-height: 44px; }
|
|
1440
1440
|
.bim-ct-tw { width: 44px; }
|
|
1441
1441
|
.bim-ct-pg { min-width: 44px; height: 44px; }
|
|
@@ -1461,7 +1461,7 @@ ${he??""}`,[Qt,xn]=g.useState({key:Ot,data:z,started:!!z});if(Qt.key!==Ot)xn({ke
|
|
|
1461
1461
|
/* 窄屏分类抽屉:界栏下按钮和面板都有框 */
|
|
1462
1462
|
:root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${i("fr-bd")}; background: ${i("fr-bg")}; }
|
|
1463
1463
|
:root[data-layout="boxed"] .bim-ct-drawer { border: ${i("fr-bd")}; }
|
|
1464
|
-
`,Gt="未分類",Ct="all",Nr=20;function Fn(e){if(!e)return[];const n=[];for(const o of[e.l1,e.l2,e.l3,e.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function sb(e){const n=Fn(e);return n.length?n.join("/"):Gt}function ab(e){const n=Fn(e);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Gt]}function lb(e,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,m)=>{const h=p.slice(0,m+1).join("/");o.has(h)||o.set(h,c)})});const r=new Map;let s=0;for(const d of e){const c=Fn(d.classification);if(!c.length){s++;continue}let p=r;c.forEach((u,m)=>{const h=c.slice(0,m+1).join("/");let f=p.get(u);f||(f={id:h,label:u,count:0,children:new Map},p.set(u,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const u=c.label===Gt?1:0,m=p.label===Gt?1:0;if(u!==m)return u-m;const h=o.get(c.id)??1/0,f=o.get(p.id)??1/0;return h!==f?h-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(r);return s>0&&l.push({id:Gt,label:Gt,count:s}),l}function an(e,n){if(!n)return[];for(const o of e){if(o.id===n)return[o];if(o.children){const r=an(o.children,n);if(r.length)return[o,...r]}}return[]}function Rr(e){return e.reduce((n,o)=>n+o.count,0)}function cb(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function db(e){var d;const n={id:e.id,title:e.title||e.id},o=e.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const p=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return p?{name:c.name,dynasty:p}:{name:c.name}});s.length&&(n.authors=s);const a=cb(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Fn(e.classification);return l.length&&(n.classification=l),n}function pb(e,n){const o=e.summary?0:1,r=n.summary?0:1;return o!==r?o-r:e.title.localeCompare(n.title,"zh")}function ub(e,n=Nr){return Math.max(1,Math.ceil(e/n))}function Vc(e,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let l=e-o;l<=e+o;l++)l>=1&&l<=n&&r.add(l);const s=[...r].sort((l,d)=>l-d),a=[];return s.forEach((l,d)=>{if(d>0){const c=l-s[d-1];c===2?a.push(l-1):c>2&&a.push(null)}a.push(l)}),a}const mb=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function hb(e,n,o){const r=[];o&&r.push({id:Ct,parentId:null,hasChildren:!1,firstChildId:null});const s=(a,l)=>{var d;for(const c of a){const p=(d=c.children)!=null&&d.length?c.children:null;r.push({id:c.id,parentId:l,hasChildren:!!p,firstChildId:p?p[0].id:null}),p&&n.has(c.id)&&s(p,c.id)}};return s(e,null),r}function Gc({tree:e,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:a,convert:l}=J(),d=r===void 0?a("catalogPage.all"):r,c=s??a("catalogPage.classification"),p=g.useRef(null),u=n&&n!==Ct?n:null,m=d!==null,[h,f]=g.useState(()=>{const C=new Set;for(const M of an(e,u))C.add(M.id);return C});g.useEffect(()=>{const C=an(e,u);C.length&&f(M=>{if(C.every(T=>M.has(T.id)))return M;const N=new Set(M);for(const T of C)N.add(T.id);return N})},[e,u]);const x=g.useMemo(()=>hb(e,h,m),[e,h,m]),[k,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const w=u??(m?Ct:null),b=g.useMemo(()=>{var N;const C=new Set(x.map(T=>T.id));if(k&&C.has(k))return k;if(w&&C.has(w))return w;const M=an(e,u).map(T=>T.id).filter(T=>C.has(T));return M.length?M[M.length-1]:((N=x[0])==null?void 0:N.id)??null},[x,k,w,e,u]),j=g.useCallback((C,M)=>{f(N=>{const T=N.has(C),F=M??!T;if(F===T)return N;const R=new Set(N);return F?R.add(C):R.delete(C),R})},[]),S=g.useCallback(C=>{y(C),requestAnimationFrame(()=>{var N;const M=Array.from(((N=p.current)==null?void 0:N.querySelectorAll("[data-ct-id]"))??[]).find(T=>T.dataset.ctId===C);M==null||M.focus()})},[]),v=g.useCallback((C,M)=>{M&&j(C,!0),o(C)},[o,j]),$=g.useCallback(C=>{const M=C.target.closest("[data-ct-id]");if(!M)return;const N=M.dataset.ctId,T=x.findIndex(E=>E.id===N);if(T<0)return;const F=x[T];let R=null;switch(C.key){case"ArrowDown":R=x[Math.min(x.length-1,T+1)].id;break;case"ArrowUp":R=x[Math.max(0,T-1)].id;break;case"Home":R=x[0].id;break;case"End":R=x[x.length-1].id;break;case"ArrowRight":if(!F.hasChildren)break;h.has(N)?R=F.firstChildId:j(N,!0);break;case"ArrowLeft":F.hasChildren&&h.has(N)?j(N,!1):R=F.parentId;break;case"Enter":case" ":C.preventDefault(),v(N,F.hasChildren);return;default:return}C.preventDefault(),R&&R!==N&&S(R)},[x,h,j,S,v]),_=(C,M)=>C.map((N,T)=>{var I;const F=(I=N.children)!=null&&I.length?N.children:null,R=!!F&&h.has(N.id),E=N.id===u,L=M===1&&C.length>1&&T===C.length-1;return t.jsxs("li",{role:"treeitem","aria-level":M,"aria-expanded":F?R:void 0,"aria-selected":E,tabIndex:b===N.id?0:-1,"data-ct-id":N.id,className:L?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":M-1},onClick:()=>{y(N.id),v(N.id,!!F)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:F?P=>{P.stopPropagation(),y(N.id),j(N.id)}:void 0,children:F?t.jsx(mb,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(N.label)}),t.jsx("span",{className:"bim-ct-n",children:N.count.toLocaleString("en-US")})]}),R&&t.jsx("ul",{role:"group",children:_(F,M+1)})]},N.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:$,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:b===Ct?0:-1,"data-ct-id":Ct,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(Ct),o(Ct)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),t.jsx("span",{className:"bim-ct-lb",children:l(d)}),t.jsx("span",{className:"bim-ct-n",children:Rr(e).toLocaleString("en-US")})]})}),_(e,1)]})}const Yc=e=>`/item/${encodeURIComponent(e)}`;function gb(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Kc(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function qc({work:e,href:n}){var d,c;const{t:o,convert:r}=J(),s=Kc(e.juan,o),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-card",children:t.jsxs("a",{href:n,children:[t.jsxs("div",{className:"bim-ct-ch",children:[t.jsx("h2",{className:"bim-ct-ct",children:r(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:r(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Xc({work:e,href:n}){var d,c;const{t:o,convert:r}=J(),s=Kc(e.juan,o),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-lrow",children:t.jsxs("a",{href:n,children:[t.jsxs("span",{className:"bim-ct-lt",children:[r(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Zc({page:e,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:a,convert:l}=J();if(n<=1)return null;const d=p=>u=>{o&&(r&&!gb(u)||(u.preventDefault(),o(p)))},c=(p,u,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const h={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return r?t.jsx("a",{...h,href:r(p),onClick:d(p),children:u}):t.jsx("button",{type:"button",...h,onClick:m.current?void 0:d(p),children:u})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":s?l(s):a("catalogPage.pagerLabel"),children:[c(e-1,a("catalogPage.prevPage"),{disabled:e<=1}),t.jsx("ol",{children:Vc(e,n).map((p,u)=>t.jsx("li",{style:{display:"contents"},children:p===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(p,p,{current:p===e,aria:a("catalogPage.pageN",{n:p})})},p??`gap${u}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function Jc({works:e,workLink:n=Yc,emptyText:o,view:r="card",...s}){const{t:a,convert:l}=J();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:o===void 0?a("catalogPage.emptyWorks"):typeof o=="string"?l(o):o}):r==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(Xc,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(qc,{work:d,href:n(d.id)},d.id))}),t.jsx(Zc,{...s})]})}const fb=()=>t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function xb({tree:e,selectedId:n,page:o,pageCount:r,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:u,allTitle:m,pageSize:h=Nr,className:f,view:x,onViewChange:k}){const{t:y,convert:w}=J(),b=u===void 0?y("catalogPage.all"):u,j=m??y("catalogPage.allTitle"),v=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[$,_]=g.useState(!1),[C,M]=g.useState("card"),N=x??C,T=P=>{M(P),k==null||k(P)},F=an(e,n&&n!==Ct?n:null),R=F.length?F[F.length-1]:null,E=R?R.label:j,L=R?R.count:Rr(e),I=g.useCallback(P=>{_(!1),a(P)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:Uc}),t.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":v,onClick:()=>_(P=>!P),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:w(F.length?F.map(P=>P.label).join(" › "):b??j)})}),t.jsx(fb,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Gc,{tree:e,selectedId:n,onSelect:I,allLabel:b})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:w(E)}),F.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:w(F.slice(0,-1).map(P=>P.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:L.toLocaleString("en-US"),size:h}),r>1&&y("catalogPage.statPage",{page:o,pages:r})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":N==="card",onClick:()=>T("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":N==="list",onClick:()=>T("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Jc,{works:s,view:N,workLink:c,page:o,pageCount:r,onPage:l,pageHref:p})]})]})}const Dn="(max-width: 719px)",bb="(max-width: 1079px)",yb=`${Dn}, (pointer: coarse)`,jb=[8,18,30,42,88],Er=`
|
|
1464
|
+
`,Gt="未分類",Ct="all",Nr=20;function Dn(e){if(!e)return[];const n=[];for(const o of[e.l1,e.l2,e.l3,e.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function lb(e){const n=Dn(e);return n.length?n.join("/"):Gt}function cb(e){const n=Dn(e);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Gt]}function db(e,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,m)=>{const h=p.slice(0,m+1).join("/");o.has(h)||o.set(h,c)})});const r=new Map;let s=0;for(const d of e){const c=Dn(d.classification);if(!c.length){s++;continue}let p=r;c.forEach((u,m)=>{const h=c.slice(0,m+1).join("/");let f=p.get(u);f||(f={id:h,label:u,count:0,children:new Map},p.set(u,f)),f.count++,p=f.children})}const a=d=>[...d.values()].sort((c,p)=>{const u=c.label===Gt?1:0,m=p.label===Gt?1:0;if(u!==m)return u-m;const h=o.get(c.id)??1/0,f=o.get(p.id)??1/0;return h!==f?h-f:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(r);return s>0&&l.push({id:Gt,label:Gt,count:s}),l}function an(e,n){if(!n)return[];for(const o of e){if(o.id===n)return[o];if(o.children){const r=an(o.children,n);if(r.length)return[o,...r]}}return[]}function Rr(e){return e.reduce((n,o)=>n+o.count,0)}function pb(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function ub(e){var d;const n={id:e.id,title:e.title||e.id},o=e.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const p=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return p?{name:c.name,dynasty:p}:{name:c.name}});s.length&&(n.authors=s);const a=pb(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Dn(e.classification);return l.length&&(n.classification=l),n}function mb(e,n){const o=e.summary?0:1,r=n.summary?0:1;return o!==r?o-r:e.title.localeCompare(n.title,"zh")}function hb(e,n=Nr){return Math.max(1,Math.ceil(e/n))}function Gc(e,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let l=e-o;l<=e+o;l++)l>=1&&l<=n&&r.add(l);const s=[...r].sort((l,d)=>l-d),a=[];return s.forEach((l,d)=>{if(d>0){const c=l-s[d-1];c===2?a.push(l-1):c>2&&a.push(null)}a.push(l)}),a}const gb=()=>t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function fb(e,n,o){const r=[];o&&r.push({id:Ct,parentId:null,hasChildren:!1,firstChildId:null});const s=(a,l)=>{var d;for(const c of a){const p=(d=c.children)!=null&&d.length?c.children:null;r.push({id:c.id,parentId:l,hasChildren:!!p,firstChildId:p?p[0].id:null}),p&&n.has(c.id)&&s(p,c.id)}};return s(e,null),r}function Yc({tree:e,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:a,convert:l}=J(),d=r===void 0?a("catalogPage.all"):r,c=s??a("catalogPage.classification"),p=g.useRef(null),u=n&&n!==Ct?n:null,m=d!==null,[h,f]=g.useState(()=>{const C=new Set;for(const M of an(e,u))C.add(M.id);return C});g.useEffect(()=>{const C=an(e,u);C.length&&f(M=>{if(C.every(T=>M.has(T.id)))return M;const N=new Set(M);for(const T of C)N.add(T.id);return N})},[e,u]);const x=g.useMemo(()=>fb(e,h,m),[e,h,m]),[k,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const w=u??(m?Ct:null),b=g.useMemo(()=>{var N;const C=new Set(x.map(T=>T.id));if(k&&C.has(k))return k;if(w&&C.has(w))return w;const M=an(e,u).map(T=>T.id).filter(T=>C.has(T));return M.length?M[M.length-1]:((N=x[0])==null?void 0:N.id)??null},[x,k,w,e,u]),j=g.useCallback((C,M)=>{f(N=>{const T=N.has(C),F=M??!T;if(F===T)return N;const R=new Set(N);return F?R.add(C):R.delete(C),R})},[]),S=g.useCallback(C=>{y(C),requestAnimationFrame(()=>{var N;const M=Array.from(((N=p.current)==null?void 0:N.querySelectorAll("[data-ct-id]"))??[]).find(T=>T.dataset.ctId===C);M==null||M.focus()})},[]),v=g.useCallback((C,M)=>{M&&j(C,!0),o(C)},[o,j]),$=g.useCallback(C=>{const M=C.target.closest("[data-ct-id]");if(!M)return;const N=M.dataset.ctId,T=x.findIndex(E=>E.id===N);if(T<0)return;const F=x[T];let R=null;switch(C.key){case"ArrowDown":R=x[Math.min(x.length-1,T+1)].id;break;case"ArrowUp":R=x[Math.max(0,T-1)].id;break;case"Home":R=x[0].id;break;case"End":R=x[x.length-1].id;break;case"ArrowRight":if(!F.hasChildren)break;h.has(N)?R=F.firstChildId:j(N,!0);break;case"ArrowLeft":F.hasChildren&&h.has(N)?j(N,!1):R=F.parentId;break;case"Enter":case" ":C.preventDefault(),v(N,F.hasChildren);return;default:return}C.preventDefault(),R&&R!==N&&S(R)},[x,h,j,S,v]),_=(C,M)=>C.map((N,T)=>{var I;const F=(I=N.children)!=null&&I.length?N.children:null,R=!!F&&h.has(N.id),E=N.id===u,L=M===1&&C.length>1&&T===C.length-1;return t.jsxs("li",{role:"treeitem","aria-level":M,"aria-expanded":F?R:void 0,"aria-selected":E,tabIndex:b===N.id?0:-1,"data-ct-id":N.id,className:L?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":M-1},onClick:()=>{y(N.id),v(N.id,!!F)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:F?P=>{P.stopPropagation(),y(N.id),j(N.id)}:void 0,children:F?t.jsx(gb,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(N.label)}),t.jsx("span",{className:"bim-ct-n",children:N.count.toLocaleString("en-US")})]}),R&&t.jsx("ul",{role:"group",children:_(F,M+1)})]},N.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:$,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:b===Ct?0:-1,"data-ct-id":Ct,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(Ct),o(Ct)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),t.jsx("span",{className:"bim-ct-lb",children:l(d)}),t.jsx("span",{className:"bim-ct-n",children:Rr(e).toLocaleString("en-US")})]})}),_(e,1)]})}const Kc=e=>`/item/${encodeURIComponent(e)}`;function xb(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function qc(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function Xc({work:e,href:n}){var d,c;const{t:o,convert:r}=J(),s=qc(e.juan,o),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-card",children:t.jsxs("a",{href:n,children:[t.jsxs("div",{className:"bim-ct-ch",children:[t.jsx("h2",{className:"bim-ct-ct",children:r(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:r(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Zc({work:e,href:n}){var d,c;const{t:o,convert:r}=J(),s=qc(e.juan,o),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-lrow",children:t.jsxs("a",{href:n,children:[t.jsxs("span",{className:"bim-ct-lt",children:[r(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Jc({page:e,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:a,convert:l}=J();if(n<=1)return null;const d=p=>u=>{o&&(r&&!xb(u)||(u.preventDefault(),o(p)))},c=(p,u,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const h={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return r?t.jsx("a",{...h,href:r(p),onClick:d(p),children:u}):t.jsx("button",{type:"button",...h,onClick:m.current?void 0:d(p),children:u})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":s?l(s):a("catalogPage.pagerLabel"),children:[c(e-1,a("catalogPage.prevPage"),{disabled:e<=1}),t.jsx("ol",{children:Gc(e,n).map((p,u)=>t.jsx("li",{style:{display:"contents"},children:p===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(p,p,{current:p===e,aria:a("catalogPage.pageN",{n:p})})},p??`gap${u}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function Qc({works:e,workLink:n=Kc,emptyText:o,view:r="card",...s}){const{t:a,convert:l}=J();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:o===void 0?a("catalogPage.emptyWorks"):typeof o=="string"?l(o):o}):r==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(Zc,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(Xc,{work:d,href:n(d.id)},d.id))}),t.jsx(Jc,{...s})]})}const bb=()=>t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:t.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function yb({tree:e,selectedId:n,page:o,pageCount:r,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:u,allTitle:m,pageSize:h=Nr,className:f,view:x,onViewChange:k}){const{t:y,convert:w}=J(),b=u===void 0?y("catalogPage.all"):u,j=m??y("catalogPage.allTitle"),v=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[$,_]=g.useState(!1),[C,M]=g.useState("card"),N=x??C,T=P=>{M(P),k==null||k(P)},F=an(e,n&&n!==Ct?n:null),R=F.length?F[F.length-1]:null,E=R?R.label:j,L=R?R.count:Rr(e),I=g.useCallback(P=>{_(!1),a(P)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:Vc}),t.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":v,onClick:()=>_(P=>!P),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:w(F.length?F.map(P=>P.label).join(" › "):b??j)})}),t.jsx(bb,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Yc,{tree:e,selectedId:n,onSelect:I,allLabel:b})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:w(E)}),F.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:w(F.slice(0,-1).map(P=>P.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:L.toLocaleString("en-US"),size:h}),r>1&&y("catalogPage.statPage",{page:o,pages:r})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":N==="card",onClick:()=>T("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":N==="list",onClick:()=>T("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Qc,{works:s,view:N,workLink:c,page:o,pageCount:r,onPage:l,pageHref:p})]})]})}const Un="(max-width: 719px)",jb="(max-width: 1079px)",vb=`${Un}, (pointer: coarse)`,kb=[8,18,30,42,88],Er=`
|
|
1465
1465
|
.bim-rh { color: ${i("ink")}; font-family: ${i("font-ui")}; font-size: 14px; line-height: 1.6; }
|
|
1466
1466
|
.bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
|
|
1467
1467
|
.bim-rh a { color: ${i("accent")}; text-decoration: none; }
|
|
@@ -1609,7 +1609,7 @@ ${he??""}`,[Qt,xn]=g.useState({key:Ot,data:z,started:!!z});if(Qt.key!==Ot)xn({ke
|
|
|
1609
1609
|
flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
|
|
1610
1610
|
color: ${i("ink")} !important; font-size: 13px;
|
|
1611
1611
|
}
|
|
1612
|
-
${
|
|
1612
|
+
${kb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${i("accent")} ${e}%, ${i("card-bg")}); }`).join(`
|
|
1613
1613
|
`)}
|
|
1614
1614
|
.bim-rh-band a[data-k="4"] { color: ${i("page-bg")} !important; }
|
|
1615
1615
|
.bim-rh-band a:hover { outline: 2px solid ${i("ink")}; outline-offset: -2px; }
|
|
@@ -1637,13 +1637,13 @@ ${jb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1637
1637
|
}
|
|
1638
1638
|
|
|
1639
1639
|
/* ── 中屏 ── */
|
|
1640
|
-
@media ${
|
|
1640
|
+
@media ${jb} {
|
|
1641
1641
|
.bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1642
1642
|
.bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1643
1643
|
}
|
|
1644
1644
|
|
|
1645
1645
|
/* ── 手机 ── */
|
|
1646
|
-
@media ${
|
|
1646
|
+
@media ${Un} {
|
|
1647
1647
|
.bim-rh-main { padding-top: 24px; }
|
|
1648
1648
|
.bim-rh-stats { gap: 4px 18px; }
|
|
1649
1649
|
.bim-rh-stats b { font-size: 16px; }
|
|
@@ -1680,7 +1680,7 @@ ${jb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1680
1680
|
}
|
|
1681
1681
|
|
|
1682
1682
|
/* 触屏或窄屏:点击目标放大到 44px */
|
|
1683
|
-
@media ${
|
|
1683
|
+
@media ${vb} {
|
|
1684
1684
|
.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; }
|
|
1685
1685
|
.bim-rh-chip { display: inline-flex; }
|
|
1686
1686
|
}
|
|
@@ -1691,7 +1691,7 @@ ${jb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1691
1691
|
}
|
|
1692
1692
|
|
|
1693
1693
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1694
|
-
`,vb=Ao["zh-Hant"].period,Qc={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Bt(e){return{...Qc,...e??{}}}function Ir(e){var o;const n=(o=e.authors)==null?void 0:o.find(r=>r==null?void 0:r.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Ni(e){return(e.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function ed(e,n=Ao["zh-Hant"].shelfOther){var s;const o=[],r=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=r.get(l);d||(d={label:l,items:[]},r.set(l,d),o.push(d)),d.items.push(a)}return o}function td(e){return Math.max(150,Array.from(e).length*18+44)}function nd(e,n){if(n<=0||e<=0)return 0;const o=e/n;return o<.15?0:o<.35?1:o<.6?2:o<.85?3:4}const id=.04;function Ye(e){return e.toLocaleString("en-US")}function od({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,o)=>t.jsx("span",{children:n},o))})}function st({id:e,title:n,sub:o,more:r,children:s}){const{convert:a}=J(),l=`${e}-h`;return t.jsxs("section",{className:"bim-rh-sec",id:e,"aria-labelledby":l,children:[t.jsxs("div",{className:"bim-rh-hd",children:[t.jsx("h2",{id:l,children:a(n)}),o&&t.jsx("span",{className:"bim-rh-sub",children:o}),r]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function rd({counts:e}){const{t:n}=J();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ye(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ye(e.pieces)}),n("readHome.pieces")]})]})}function sd({picks:e,links:n}){const{t:o,convert:r}=J(),s=Bt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Ni(a),d=[a.type_label,a.edition].filter(Boolean).join(" · ");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-pk",href:s.read(a.id),children:[t.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:t.jsx(od,{text:r(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:r(d)}),t.jsx("h3",{children:r(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:r(l)}),a.blurb&&t.jsx("p",{children:r(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:o("readHome.startReading")})]})]})},a.id)})}):null}function ad(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Lr({topic:e,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=J(),c=Bt(n);if(!e.items.length)return null;const p=r===void 0?l("readHome.shelfLegendCount"):r,u=ed(e.items,l("readHome.shelfOther")),m=h=>{const f=h.records?Ye(h.records):ad(h.text_count,l),x=Ir(h),k=[d(h.title),h.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",h.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(h.id),"data-orig":h.orig?"":void 0,"aria-label":k,title:k,style:{height:td(h.title)},children:[t.jsx(od,{text:d(h.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":h.records?"":void 0,children:f})]})},h.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:o?d(o):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:u.map(h=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(h.label),children:h.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(h.label)})]},h.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(h=>t.jsx("span",{children:d(h)},h))]})]})}const kb=4,Pn=e=>e>kb+1;function ld({topic:e,links:n}){const{t:o,convert:r}=J(),s=Bt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":Pn(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[r(e.label),t.jsx("small",{className:"bim-rh-num",children:o("readHome.nWorks",{n:Ye(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=ad(c.text_count,o),u=Ir(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:r(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),u&&t.jsx("small",{children:r(u)})]})},c.id)})}),Pn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?o("action.collapse"):o("readHome.allNWorks",{n:e.items.length})})]})}function cd({topics:e,links:n}){const o=e.filter(s=>s.shelf&&s.items.length),r=e.filter(s=>!s.shelf&&s.items.length);return!o.length&&!r.length?null:t.jsxs(t.Fragment,{children:[o.map(s=>t.jsx(Lr,{topic:s,links:n},s.key)),r.length>0&&t.jsx("div",{className:"bim-rh-groups",children:r.map(s=>t.jsx(ld,{topic:s,links:n},s.key))})]})}function dd({famous:e,links:n}){const{t:o,convert:r}=J(),s=Bt(n);return e.length?t.jsx("ul",{className:"bim-rh-works",children:e.map(a=>t.jsx("li",{children:t.jsxs("article",{className:"bim-rh-wk",children:[t.jsxs("div",{className:"bim-rh-wk-h",children:[t.jsx("h3",{children:r(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:r(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:o("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?r(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:r(l.label)}),l.items.map(c=>t.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)),a.work_id&&t.jsx("div",{className:"bim-rh-wk-f",children:t.jsx("a",{href:s.work(a.work_id),children:o("readHome.workPageLink",{title:r(a.title)})})})]})},a.work_id??a.title))}):null}function Ar({bu:e,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:a}=J(),l=Bt(o);return!e.length&&!n?null:t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-bu",children:e.map(d=>{var p;const c=((p=d.top[0])==null?void 0:p.count)||1;return t.jsxs("li",{className:"bim-rh-bu-c",children:[t.jsxs("a",{className:"bim-rh-bu-h",href:l.node(d.id),children:[t.jsx("b",{children:a(d.label)}),t.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ye(d.count)})})]}),d.top.length>0&&t.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:a(d.label)}),children:d.top.map(u=>t.jsx("li",{children:t.jsxs("a",{href:l.node(u.id),children:[t.jsx("span",{children:a(u.label)}),t.jsx("small",{className:"bim-rh-num",children:Ye(u.count)}),t.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&&t.jsx("a",{className:"bim-rh-bu-more",href:l.node(d.id),children:s("readHome.allNClasses",{label:a(d.label),n:d.children_total})})]},d.id)})}),!!n&&t.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[t.jsx("b",{children:s("readHome.unclassified")}),t.jsx("span",{children:s("readHome.nWorks",{n:Ye(n)})}),t.jsx("span",{children:r?a(r):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function pd({periods:e,unknown:n,links:o}){const{t:r,convert:s,messages:a}=J(),l=a.readHome.period,d=Bt(o),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,h)=>m+h.count,0),u=Math.max(...c.map(m=>m.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(m=>{const h=m.label?s(m.label):l[m.key]??s(m.key),f=m.count/p,x=r("readHome.periodItem",{label:h,n:Ye(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":nd(m.count,u),"data-narrow":f<id?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:h}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(h)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ye(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:r("readHome.periodUnknown",{n:Ye(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function ud({authors:e,links:n}){const{t:o,convert:r}=J(),s=Bt(n);return e.length?t.jsx("ul",{className:"bim-rh-authors",children:e.map(a=>t.jsxs("li",{className:"bim-rh-au",children:[t.jsxs("h3",{className:"bim-rh-au-h",children:[r(a.name),a.dynasty&&t.jsx("span",{children:r(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:o("readHome.nPieces",{n:Ye(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:r(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:o("readHome.authorAll",{name:r(a.name),n:a.count})})]},a.name))}):null}const md={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function wb({sections:e,links:n,head:o,piecesMoreHref:r,className:s}){const{t:a}=J(),l=e,d=md,c=l.topics.filter(h=>!h.shelf),p={picks:l.picks.length>0,topics:c.some(h=>h.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(h=>h.count>0),pieces:l.pieces.authors.length>0},u=Object.keys(d).filter(h=>p[h]),m=h=>a(`readHome.nav.${h}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:Er}),t.jsxs("div",{className:"bim-rh-head",children:[o,t.jsx(rd,{counts:l.counts})]}),u.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:u.map(h=>t.jsx("li",{children:t.jsx("a",{href:`#${d[h]}`,children:m(h)})},h))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(st,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(sd,{picks:l.picks,links:n})}),p.topics&&t.jsx(st,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(cd,{topics:c,links:n})}),p.famous&&t.jsx(st,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(dd,{famous:l.famous,links:n})}),p.sibu&&t.jsx(st,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Ar,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(st,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(pd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(st,{id:d.pieces,title:m("pieces"),sub:a("readHome.piecesSub"),more:r?t.jsx("a",{className:"bim-rh-more",href:r,children:a("readHome.piecesMore")}):void 0,children:t.jsx(ud,{authors:l.pieces.authors,links:n})})]})]})}const Sb="(max-width: 1079px)",_b=`${Dn}, (pointer: coarse)`,hd=`
|
|
1694
|
+
`,wb=Ao["zh-Hant"].period,ed={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Mt(e){return{...ed,...e??{}}}function Ir(e){var o;const n=(o=e.authors)==null?void 0:o.find(r=>r==null?void 0:r.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function Ni(e){return(e.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function td(e,n=Ao["zh-Hant"].shelfOther){var s;const o=[],r=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=r.get(l);d||(d={label:l,items:[]},r.set(l,d),o.push(d)),d.items.push(a)}return o}function nd(e){return Math.max(150,Array.from(e).length*18+44)}function id(e,n){if(n<=0||e<=0)return 0;const o=e/n;return o<.15?0:o<.35?1:o<.6?2:o<.85?3:4}const od=.04;function Ye(e){return e.toLocaleString("en-US")}function rd({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,o)=>t.jsx("span",{children:n},o))})}function st({id:e,title:n,sub:o,more:r,children:s}){const{convert:a}=J(),l=`${e}-h`;return t.jsxs("section",{className:"bim-rh-sec",id:e,"aria-labelledby":l,children:[t.jsxs("div",{className:"bim-rh-hd",children:[t.jsx("h2",{id:l,children:a(n)}),o&&t.jsx("span",{className:"bim-rh-sub",children:o}),r]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function sd({counts:e}){const{t:n}=J();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ye(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ye(e.pieces)}),n("readHome.pieces")]})]})}function ad({picks:e,links:n}){const{t:o,convert:r}=J(),s=Mt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Ni(a),d=[a.type_label,a.edition].filter(Boolean).join(" · ");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-pk",href:s.read(a.id),children:[t.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:t.jsx(rd,{text:r(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:r(d)}),t.jsx("h3",{children:r(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:r(l)}),a.blurb&&t.jsx("p",{children:r(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:o("readHome.startReading")})]})]})},a.id)})}):null}function ld(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Lr({topic:e,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=J(),c=Mt(n);if(!e.items.length)return null;const p=r===void 0?l("readHome.shelfLegendCount"):r,u=td(e.items,l("readHome.shelfOther")),m=h=>{const f=h.records?Ye(h.records):ld(h.text_count,l),x=Ir(h),k=[d(h.title),h.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",h.records?l("readHome.spineRecords",{n:f}):f?l("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(h.id),"data-orig":h.orig?"":void 0,"aria-label":k,title:k,style:{height:nd(h.title)},children:[t.jsx(rd,{text:d(h.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":h.records?"":void 0,children:f})]})},h.id)};return t.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&t.jsxs("h3",{className:"bim-rh-gt",children:[d(e.label),t.jsx("small",{children:o?d(o):l("readHome.shelfHint")})]}),t.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":l("readHome.shelfRegion",{label:d(e.label)}),children:t.jsx("ul",{className:"bim-rh-shelf",children:u.map(h=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(h.label),children:h.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(h.label)})]},h.label))})}),t.jsxs("p",{className:"bim-rh-legend",children:[t.jsxs("span",{children:[t.jsx("i",{"data-orig":"","aria-hidden":"true"}),l("readHome.origZhi")]}),t.jsxs("span",{children:[t.jsx("i",{"aria-hidden":"true"}),l("readHome.laterZhi")]}),p&&t.jsx("span",{children:d(p)}),a==null?void 0:a.map(h=>t.jsx("span",{children:d(h)},h))]})]})}const Sb=4,Mn=e=>e>Sb+1;function cd({topic:e,links:n}){const{t:o,convert:r}=J(),s=Mt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":Mn(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[r(e.label),t.jsx("small",{className:"bim-rh-num",children:o("readHome.nWorks",{n:Ye(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=ld(c.text_count,o),u=Ir(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:r(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),u&&t.jsx("small",{children:r(u)})]})},c.id)})}),Mn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?o("action.collapse"):o("readHome.allNWorks",{n:e.items.length})})]})}function dd({topics:e,links:n}){const o=e.filter(s=>s.shelf&&s.items.length),r=e.filter(s=>!s.shelf&&s.items.length);return!o.length&&!r.length?null:t.jsxs(t.Fragment,{children:[o.map(s=>t.jsx(Lr,{topic:s,links:n},s.key)),r.length>0&&t.jsx("div",{className:"bim-rh-groups",children:r.map(s=>t.jsx(cd,{topic:s,links:n},s.key))})]})}function pd({famous:e,links:n}){const{t:o,convert:r}=J(),s=Mt(n);return e.length?t.jsx("ul",{className:"bim-rh-works",children:e.map(a=>t.jsx("li",{children:t.jsxs("article",{className:"bim-rh-wk",children:[t.jsxs("div",{className:"bim-rh-wk-h",children:[t.jsx("h3",{children:r(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:r(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:o("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?r(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:r(l.label)}),l.items.map(c=>t.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)),a.work_id&&t.jsx("div",{className:"bim-rh-wk-f",children:t.jsx("a",{href:s.work(a.work_id),children:o("readHome.workPageLink",{title:r(a.title)})})})]})},a.work_id??a.title))}):null}function Ar({bu:e,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:a}=J(),l=Mt(o);return!e.length&&!n?null:t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-bu",children:e.map(d=>{var p;const c=((p=d.top[0])==null?void 0:p.count)||1;return t.jsxs("li",{className:"bim-rh-bu-c",children:[t.jsxs("a",{className:"bim-rh-bu-h",href:l.node(d.id),children:[t.jsx("b",{children:a(d.label)}),t.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ye(d.count)})})]}),d.top.length>0&&t.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:a(d.label)}),children:d.top.map(u=>t.jsx("li",{children:t.jsxs("a",{href:l.node(u.id),children:[t.jsx("span",{children:a(u.label)}),t.jsx("small",{className:"bim-rh-num",children:Ye(u.count)}),t.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&&t.jsx("a",{className:"bim-rh-bu-more",href:l.node(d.id),children:s("readHome.allNClasses",{label:a(d.label),n:d.children_total})})]},d.id)})}),!!n&&t.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[t.jsx("b",{children:s("readHome.unclassified")}),t.jsx("span",{children:s("readHome.nWorks",{n:Ye(n)})}),t.jsx("span",{children:r?a(r):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function ud({periods:e,unknown:n,links:o}){const{t:r,convert:s,messages:a}=J(),l=a.readHome.period,d=Mt(o),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,h)=>m+h.count,0),u=Math.max(...c.map(m=>m.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(m=>{const h=m.label?s(m.label):l[m.key]??s(m.key),f=m.count/p,x=r("readHome.periodItem",{label:h,n:Ye(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":id(m.count,u),"data-narrow":f<od?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:h}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(h)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ye(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:r("readHome.periodUnknown",{n:Ye(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function md({authors:e,links:n}){const{t:o,convert:r}=J(),s=Mt(n);return e.length?t.jsx("ul",{className:"bim-rh-authors",children:e.map(a=>t.jsxs("li",{className:"bim-rh-au",children:[t.jsxs("h3",{className:"bim-rh-au-h",children:[r(a.name),a.dynasty&&t.jsx("span",{children:r(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:o("readHome.nPieces",{n:Ye(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:r(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:o("readHome.authorAll",{name:r(a.name),n:a.count})})]},a.name))}):null}const hd={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function _b({sections:e,links:n,head:o,piecesMoreHref:r,className:s}){const{t:a}=J(),l=e,d=hd,c=l.topics.filter(h=>!h.shelf),p={picks:l.picks.length>0,topics:c.some(h=>h.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(h=>h.count>0),pieces:l.pieces.authors.length>0},u=Object.keys(d).filter(h=>p[h]),m=h=>a(`readHome.nav.${h}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:Er}),t.jsxs("div",{className:"bim-rh-head",children:[o,t.jsx(sd,{counts:l.counts})]}),u.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:u.map(h=>t.jsx("li",{children:t.jsx("a",{href:`#${d[h]}`,children:m(h)})},h))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(st,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(ad,{picks:l.picks,links:n})}),p.topics&&t.jsx(st,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(dd,{topics:c,links:n})}),p.famous&&t.jsx(st,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(pd,{famous:l.famous,links:n})}),p.sibu&&t.jsx(st,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Ar,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(st,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(ud,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(st,{id:d.pieces,title:m("pieces"),sub:a("readHome.piecesSub"),more:r?t.jsx("a",{className:"bim-rh-more",href:r,children:a("readHome.piecesMore")}):void 0,children:t.jsx(md,{authors:l.pieces.authors,links:n})})]})]})}const $b="(max-width: 1079px)",Cb=`${Un}, (pointer: coarse)`,gd=`
|
|
1695
1695
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1696
1696
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1697
1697
|
.bim-mh-q { min-width: 0; }
|
|
@@ -1831,7 +1831,7 @@ ${jb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1831
1831
|
.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")}; }
|
|
1832
1832
|
|
|
1833
1833
|
/* ── 中屏 ── */
|
|
1834
|
-
@media ${
|
|
1834
|
+
@media ${$b} {
|
|
1835
1835
|
.bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
|
|
1836
1836
|
.bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1837
1837
|
.bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
@@ -1841,7 +1841,7 @@ ${jb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1841
1841
|
}
|
|
1842
1842
|
|
|
1843
1843
|
/* ── 手机 ── */
|
|
1844
|
-
@media ${
|
|
1844
|
+
@media ${Un} {
|
|
1845
1845
|
.bim-mh-cg, .bim-mh-data { grid-template-columns: minmax(0, 1fr); }
|
|
1846
1846
|
.bim-mh-ge { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
1847
1847
|
.bim-mh-lin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
@@ -1858,8 +1858,8 @@ ${jb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1858
1858
|
.bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
|
|
1859
1859
|
}
|
|
1860
1860
|
|
|
1861
|
-
@media ${
|
|
1861
|
+
@media ${Cb} {
|
|
1862
1862
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
1863
1863
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
1864
1864
|
}
|
|
1865
|
-
`,gd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Wt(e){return{...gd,...e??{}}}function fd(e,n){if(e.lineage)return e.lineage(n);const o=e.item(n),r=o.indexOf("#"),[s,a]=r<0?[o,""]:[o.slice(0,r),o.slice(r)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function Pr(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function xd(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),o=e.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,m=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(u,m),Math.max(u,m)]},s=n.map(r),a=Math.min(...s.map(p=>p[0])),l=Math.max(...s.map(p=>p[1])),d=Math.max(1,l-a),c=n.map((p,u)=>({p,from:s[u][0],to:s[u][1]})).sort((p,u)=>p.from-u.from).map(p=>({...p,left:(p.from-a)/d*100,width:Math.max(.8,(p.to-p.from)/d*100)}));return{min:a,max:l,placed:c,missing:o}}function hi(e,n=mn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function $b(e){return{read:e.item,work:e.item,node:e.node}}function bd({counts:e,links:n}){const{t:o}=J(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),e.works],["book",o("metaHome.typeLabel.book"),e.books],["collection",o("metaHome.typeLabel.collection"),e.collections],["entity",o("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:r(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Ye(d)})]})},a))})}function yd(e,n=5){const[o,r]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Mt().slice(0,n);if(!l.length||!e){r([]);return}return Promise.all(l.map(d=>Do(e,d))).then(d=>{a||r(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{Fo(),r([])},[]);return{entries:o,clear:s}}function Cb(e,n,o){const r=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return r?o(r):jd(e.type,n)}function jd(e,n){return n(`metaHome.typeLabel.${e}`)}function vd({entries:e,onClear:n,links:o}){const{t:r,convert:s}=J(),a=Wt(o);return t.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[t.jsxs("div",{className:"bim-mh-recent-h",children:[t.jsx("h2",{id:"bim-mh-recent-h",children:r("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:r("metaHome.recentClear")})]}),e&&e.length>0&&t.jsx("ol",{children:e.map(l=>t.jsx("li",{children:t.jsxs("a",{href:a.item(l.id),"aria-label":r("metaHome.recentItemLabel",{type:l.type?jd(l.type,r):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?r(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:Cb(l,r,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function kd(e,n,o,r=!1){return r&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):o(e)}function wd({rows:e,links:n}){const{t:o,convert:r}=J(),s=Wt(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":o("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[o("metaHome.catalogTitle"),t.jsx("small",{children:o("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:o("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:o("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:o("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=Pr(a.imported,a.total),d=a.work_id??a.collection_id,c=r(a.edition?`${a.name}·${a.edition}`:a.name);return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:d?t.jsx("a",{href:s.item(d),children:c}):c}),t.jsx("td",{className:"bim-mh-r",children:Ye(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ye(a.imported)}),t.jsx("td",{children:t.jsxs("span",{className:"bim-mh-meter",children:[t.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[l,"%"]})]})}),t.jsx("td",{children:a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:kd(a.status,o,r)})})]},a.id||a.name)})})]})}):null}function Sd({items:e,links:n,label:o}){const{convert:r}=J();return t.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):void 0,children:e.map(s=>t.jsx("li",{children:t.jsxs("a",{href:n.item(s.id),children:[t.jsx("span",{className:"bim-rh-t",children:r(s.title)}),s.sub&&t.jsx("small",{children:r(s.sub)})]})},s.id))})}function _d({works:e,links:n}){const{t:o}=J(),[r,s]=g.useState(!1);if(!e.length)return null;const a=Pn(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":r?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o("metaHome.relatedTitle"),t.jsx("small",{children:o("metaHome.relatedNote")})]}),t.jsx(Sd,{items:e.map(l=>({id:l.id,title:l.title,sub:Ni(l)||void 0})),links:Wt(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":r,onClick:()=>s(l=>!l),children:r?o("action.collapse"):o("metaHome.allNWorks",{n:e.length})})]})}const $d="siku_qige";function zb({group:e,links:n}){const{t:o,convert:r}=J(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Pn(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[r(e.label),t.jsx("small",{className:"bim-rh-num",children:o("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(Sd,{items:e.items,links:n,label:e.label}),Pn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?o("action.collapse"):o("metaHome.allNKinds",{n:e.items.length})})]})}function Cd({groups:e,links:n}){const{t:o,convert:r}=J(),s=Wt(n);if(!e.length)return null;const a=e.find(c=>c.key===$d),l=e.filter(c=>c!==a),d=c=>{var p;return((p=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:p[1])??c};return t.jsxs(t.Fragment,{children:[a&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:"bim-rh-gt",children:[r(a.label),t.jsx("small",{children:r(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":r(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":r(c.title),title:r(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:r(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:o("metaHome.pavilion")})]})},c.id))})]}),l.length>0&&t.jsx("div",{className:"bim-mh-cg",style:a?void 0:{marginTop:0},children:l.map(c=>t.jsx(zb,{group:c,links:s},c.key))})]})}const va=34,ka=13;function wa(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?hi(e.birth_year,n):"?"}–${e.death_year!=null?hi(e.death_year,n):"?"}`}function Tb(e,n){const o=n-e,r=o>1200?300:o>400?100:50,s=[];for(let a=Math.ceil(e/r)*r;a<=n;a+=r)s.push(a);return s}function zd({people:e,links:n}){const{t:o,convert:r}=J(),s=Wt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=xd(e),p=[],u=d.map(h=>{const f=h.left>70,x=f?Math.min(h.left,h.left+h.width-ka):h.left;let k=0;for(;p[k]!=null&&p[k]>x;)k++;return p[k]=f?h.left+h.width:h.left+Math.max(h.width,ka),{...h,lane:k,end:f}}),m=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*va+10},children:u.map(h=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":h.end?"":void 0,style:{left:`${h.left}%`,top:h.lane*va+4,width:`${Math.max(h.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(h.p.id),children:[r(h.p.name),t.jsx("small",{className:"bim-rh-num",children:wa(h.p,o)})]})]},h.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Tb(a,l).map(h=>t.jsx("span",{style:{left:`${(h-a)/m*100}%`},children:hi(h,o)},h))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?e:c).map(h=>t.jsx("li",{children:t.jsxs("a",{href:s.item(h.id),children:[t.jsx("span",{children:r(h.name)}),t.jsx("small",{className:"bim-rh-num",children:[h.dynasty?r(h.dynasty):"",wa(h,o)].filter(Boolean).join(" ")})]})},h.id))}),c.length>0&&u.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(h=>h.name).join("、"))})})]})}const Nb=t.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[t.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),t.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),t.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function Td({works:e,links:n}){const{t:o,convert:r}=J(),s=Wt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Ni(a);return t.jsx("li",{children:t.jsxs("a",{href:fd(s,a.id),children:[Nb,t.jsx("b",{children:r(a.title)}),l&&t.jsx("small",{children:r(l)}),t.jsx("span",{children:o("metaHome.viewLineage")})]})},a.id)})}):null}function Nd({sites:e}){const{t:n,convert:o}=J(),r=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!r.includes(a));return e.length?t.jsxs(t.Fragment,{children:[r.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:r.map(a=>{const l=Pr(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:o(a.name)}):t.jsx("span",{children:o(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Ye(a.imported)} / ${Ye(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:kd(a.status,n,o,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:o(s.map(a=>a.name).join("、"))})})]}):null}const Sa=["extant","partially_extant","lost","unknown"];function Rd({stats:e,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:a}=J(),l=["works","books","collections","entities","has_image","has_text","article","poem"].map(p=>[e[p],a(`metaHome.stat.${p}`)]).filter(([p])=>p>0),d=n==null?void 0:n.loss,c=Sa.some(p=>{var u;return(((u=e.loss)==null?void 0:u[p])??0)>0});return t.jsxs("div",{className:"bim-mh-data",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.dataScale")}),t.jsx("ul",{className:"bim-mh-nums",children:l.map(([p,u])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Ye(p)}),t.jsx("span",{children:u})]},u))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Sa.map(p=>{var h;const u=((h=e.loss)==null?void 0:h[p])??0,m=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&u>0?a("metaHome.lossCount",{n:Ye(u),note:m}):m})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),r?t.jsx("a",{href:r,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),o&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:o})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const Ed={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Rb({sections:e,links:n,head:o,transport:r,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:u}){var v,$;const{t:m}=J(),h=e,f=Wt(n),x=$b(f),k=Ed,y=yd(r),w={zhi:!!((v=h.shelf)!=null&&v.items.length)||h.catalog_progress.length>0||h.related_catalogs.length>0,sibu:h.bu.length>0||h.unclassified>0,cong:h.collection_groups.length>0,people:h.bibliographers.length>0,lineage:h.lineage.length>0,sites:h.sites.length>0,data:!0},b=Object.keys(k).filter(_=>w[_]),j=_=>m(`metaHome.nav.${_}`),S=(_,C)=>_?t.jsx("a",{className:"bim-rh-more",href:_,children:C}):void 0;return t.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[t.jsx("style",{children:Er+hd}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[o,t.jsx(bd,{counts:h.counts,links:n})]}),r&&t.jsx(vd,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":m("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(_=>t.jsx("li",{children:t.jsx("a",{href:`#${k[_]}`,children:j(_)})},_))})}),t.jsxs("div",{className:"bim-rh-main",children:[w.zhi&&t.jsxs(st,{id:k.zhi,title:j("zhi"),sub:m("metaHome.zhiSub"),children:[h.shelf&&h.shelf.items.length>0&&t.jsx(Lr,{topic:{key:"shelf",label:h.shelf.label,shelf:!0,items:h.shelf.items},links:x,showTitle:!1,legendCount:h.shelf.items.some(_=>_.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(h.catalog_progress.length>0||h.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=h.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(wd,{rows:h.catalog_progress,links:n}),t.jsx(_d,{works:h.related_catalogs,links:n})]})]}),w.sibu&&t.jsx(st,{id:k.sibu,title:j("sibu"),sub:m("metaHome.sibuSub"),more:S(s,m("metaHome.toCatalog")),children:t.jsx(Ar,{bu:h.bu,unclassified:h.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),w.cong&&t.jsx(st,{id:k.cong,title:j("cong"),sub:m("metaHome.congSub"),more:S(a,m("metaHome.allNKindsMore",{n:Ye(h.counts.collections)})),children:t.jsx(Cd,{groups:h.collection_groups,links:n})}),w.people&&t.jsx(st,{id:k.people,title:j("people"),sub:m("metaHome.peopleSub"),more:S(l,m("metaHome.allNPeopleMore",{n:Ye(h.counts.entities)})),children:t.jsx(zd,{people:h.bibliographers,links:n})}),w.lineage&&t.jsx(st,{id:k.lineage,title:j("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(Td,{works:h.lineage,links:n})}),w.sites&&t.jsx(st,{id:k.sites,title:j("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(Nd,{sites:h.sites})}),t.jsx(st,{id:k.data,title:j("data"),sub:m("metaHome.dataSub"),children:t.jsx(Rd,{stats:h.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const vt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),nt=e=>Array.isArray(e),Eb=e=>vt(e)&&!!e.h;function Ib(e){if(!e)return!1;for(const n of["_related","_catalogs","_collections","_works","_members","_children"]){const o=e[n];if(nt(o)&&o.some(Eb))return!0}return!1}function ni(e,n){var r;if(typeof e.title=="string"&&e.title)return e.title;const o=e.id??e.bid;return e.h&&o&&((r=n==null?void 0:n[o])!=null&&r.title)?n[o].title:""}function Lb(e){const n=e.filter(vt);return n.find(o=>o.scheme==="zongmu")??n[0]??null}const Ab=e=>typeof e=="number"?e:nt(e)&&typeof e[0]=="number"?e[0]:void 0;function Ro(e,n){if(!vt(e))return e;const o={...e},r=e.type;if(r==="work"){if(!nt(e.books)&&nt(e._books)&&(o.books=e._books.filter(vt).map(s=>s.id).filter(s=>typeof s=="string")),!vt(e.classification)&&nt(e._classifications)){const s=Lb(e._classifications);s&&(o.classification={l1:s.l1??"",l2:s.l2??"",l3:s.l3??"",l4:s.l4??"",...s.source?{source:s.source}:{}})}nt(e._related)&&(o.related_works=e._related.filter(vt).map(s=>{const a=s;return{id:a.id,title:ni(a,n),...a.relation?{relation:a.relation}:{},...a.note?{note:a.note}:{}}})),!nt(e.indexed_by)&&nt(e._catalogs)&&e._catalogs.length&&(o.indexed_by=e._catalogs.filter(vt).map(s=>{const a=s;return{source:ni(a,n)||String(a.bid??""),...a.bid?{source_bid:a.bid}:{},...a.section?{section:a.section}:{}}}))}if((r==="work"||r==="book")&&!nt(e.contained_in)&&nt(e._collections)&&e._collections.length&&(o.contained_in=e._collections.filter(vt).map(s=>{const a=s;return{id:a.id,...a.vol!=null?{volume_index:a.vol}:{},...a.sub!=null?{sub_items:a.sub}:{}}})),r==="collection"&&nt(e._members)){const s=e._members.filter(vt),a=typeof e._member_count=="number"?e._member_count:s.length,l=d=>d.t==="work";if(!nt(e.books)){const d=s.filter(c=>!l(c)).map(c=>c.id).filter(c=>typeof c=="string");d.length&&(o.books=d)}if(!nt(e.contained_works)){const d=s.filter(l).map(c=>{const p=Ab(c.vol);return{id:c.id,title:ni(c,n),...p!=null?{volume_index:p}:{}}});d.length&&(o.contained_works=d)}a>s.length&&(o._members_truncated=!0)}return r==="entity"&&!nt(e.works)&&nt(e._works)&&(o.works=e._works.filter(vt).map(s=>{const a=s,l=ni({...a,id:a.work_id},n);return{...a,work_id:a.work_id,...l?{title:l}:{}}})),o}function Pb(e){let n=null;const o=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null),r=async s=>s&&Ro(s,Ib(s)?await o():null);return new Proxy(e,{get(s,a,l){if(a==="getItem")return async c=>r(await s.getItem(c));const d=Reflect.get(s,a,s);return typeof d=="function"?d.bind(s):d}})}const Eo=({style:e})=>{const n=g.useContext(Xt),{t:o}=J();if(!n)return null;const{locale:r,setLocale:s}=n,a=r==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:o(a?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${i("border")}`,borderRadius:"4px",background:i("bg"),color:i("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?i("primary"):void 0,fontWeight:a?700:400},children:o("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:i("primary"),fontWeight:a?400:700},children:o("common.localeShortHans")})]})},Io=({href:e,label:n,size:o=16,className:r,style:s})=>{const{t:a}=J(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,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:t.jsx("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})})};function so(e){const n=e.text_count;return typeof n=="number"&&n>0}function ao(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function Mb(e,n){if(!n)return!1;const o=n.id;return o===void 0||o===e}const Bb=({id:e,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:u,onLineageCollectionChange:m,initialPage:h=1,selectedLineageNodeId:f,onNavigate:x,onBack:k,backLabel:y,renderLink:w,enrichDetail:b,getSourceLink:j,readLink:S,railTop:v,extraTabs:$=[],showFeedbackTab:_=!0,feedbackApiUrl:C,height:M,footerExtra:N,hideHeaderControls:T=!1,className:F,style:R})=>{const E=g.useMemo(()=>Pb(n),[n]),L=Te(),{t:I,convert:P}=J(),[V]=g.useState(()=>{if(!Mb(e,o))return null;const K=Ro({...o}),fe=r??ao(e,K);return b&&b(fe,K),{id:e,entry:fe,detail:K}}),[X,D]=g.useState((V==null?void 0:V.entry)??null),[O,A]=g.useState((V==null?void 0:V.detail)??null),[G,se]=g.useState(!V),[Q,ve]=g.useState(!1),[ne,ce]=g.useState([]),[We,ke]=g.useState(!1),[Pe,Ee]=g.useState(null),[Z,le]=g.useState(null),[oe,he]=g.useState(null),[U,$e]=g.useState(!1),me=g.useRef(null),Ce=g.useRef(0),[Y,ze]=g.useState(null),Me=l!==void 0?l:Y,B=g.useCallback(K=>{d?d(K):ze(K)},[d]),te=g.useCallback(async K=>{if(!E.getCollectionCatalogs&&!E.getCollectionCatalog){ce([]);return}ke(!0);try{if(E.getCollectionCatalogs)ce(await E.getCollectionCatalogs(K)||[]);else if(E.getCollectionCatalog){const fe=await E.getCollectionCatalog(K);ce(fe?[{resource_id:"",data:fe}]:[])}}catch{ce([])}finally{ke(!1)}},[E]),xe=g.useCallback(async K=>{var fe,Ne;if(!E.getTextManifest||!E.getTextIndex){Ee(null),le(K);return}try{const q=_e.pickTextVersion(await E.getTextManifest(K)),ue=q?await E.getTextIndex(K,q.key):null;Ee(ue&&ue.chapters.length>0?{chapters:ue.chapters.map(re=>({n:re.n,title:re.title,file:re.file})),source:{name:((fe=ue.source)==null?void 0:fe.name)??(q==null?void 0:q.source_name),license:((Ne=ue.source)==null?void 0:Ne.license)??(q==null?void 0:q.license)??void 0}}:null)}catch{Ee(null)}finally{le(K)}},[E]),Re=g.useCallback(async(K,fe)=>{const Ne=++Ce.current,q=()=>Ne!==Ce.current;$e(!0);try{if(E.getLineageGraph){const lt=await E.getLineageGraph(K);if(q())return;lt&&he(lt)}const ue=fe.version_graph;if(!ue||!ue.enabled){oe||he(null),me.current=null;return}const re=fe.books??[],we=[];for(const lt of re)try{const Rt=await E.getItem(lt);Rt&&we.push(Rt)}catch{}if(q())return;me.current={work:fe,books:we};const Ve=u??ue.default_collection??(ue.core_books&&ue.core_books.length>0?"core":"all"),Oe=Ve==="core"&&Array.isArray(ue.core_books)&&ue.core_books.length>0?"core":Ve??"all";he(ai(fe,we,Oe))}catch{if(q())return;he(null),me.current=null}finally{q()||$e(!1)}},[E]),H=g.useRef({initialDetail:o,initialEntry:r});H.current={initialDetail:o,initialEntry:r},g.useEffect(()=>{let K=!1;Ce.current++,$e(!1);const fe=re=>{re.type==="collection"?te(e):re.type==="work"?(re.version_graph||E.getLineageGraph)&&Re(e,re):re.type==="book"&&so(re)&&xe(e)},Ne=H.current;let q=null;if(V&&V.id===e)q=V;else if(Ne.initialDetail&&Ne.initialDetail.id===e){const re=Ro({...Ne.initialDetail}),we=Ne.initialEntry??ao(e,re);b&&b(we,re),q={entry:we,detail:re}}return q?(ve(!1),ce(re=>re.length?[]:re),Ee(null),he(null),me.current=null,D(q.entry),A(q.detail),se(!1),fe(q.detail),()=>{K=!0}):((async()=>{se(!0),ve(!1),D(null),A(null),ce([]),Ee(null),he(null),me.current=null;try{const re=await E.getItem(e);if(K)return;if(!re){ve(!0);return}const we=re;let Ve=null;if(E.getEntry&&(Ve=await E.getEntry(e),K))return;Ve||(Ve=ao(e,we)),b&&b(Ve,we),D(Ve),A(we),fe(we)}catch{K||ve(!0)}finally{K||se(!1)}})(),()=>{K=!0})},[e,E,V,b,te,Re,xe]),g.useEffect(()=>{const K=me.current;!K||!u||he(ai(K.work,K.books,u))},[u]);const de=[];if(O){if(de.push({key:"basic",label:L.detailTab.basicInfo}),O.type==="collection"){We&&ne.length===0&&de.push({key:"catalog:loading",label:`${L.detailTab.catalog}…`});for(const K of ne)de.push({key:`catalog:${K.resource_id}`,label:K.short_name?`${P(K.short_name)}${L.detailTab.catalogSuffix}`:L.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&de.push({key:s,label:L.detailTab.fullText}),O.type==="work"&&(oe||U)&&de.push({key:"lineage",label:U?`${L.detailTab.lineage}…`:L.detailTab.lineage});for(const K of $)(K.position??"before-feedback")==="before-feedback"&&K.shouldShow(O)&&de.push({key:K.key,label:K.label});_&&s==="feedback"&&de.push({key:"feedback",label:L.detailTab.feedback});for(const K of $)K.position==="after-feedback"&&K.shouldShow(O)&&de.push({key:K.key,label:K.label})}g.useEffect(()=>{if(s!=="emendated"||!O)return;a("basic");const K=setTimeout(()=>{var fe;(fe=document.getElementById("studies"))==null||fe.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(K)},[s,O,a]);const ee=X&&O&&j?j({activeTab:s,activeJuan:Me,entry:X,detail:O}):null,ye=g.useMemo(()=>{var ue;if(!O)return null;const fe=(O.authors??[]).map(re=>{const we=Qo(re.role);return`${re.dynasty?`〔${P(re.dynasty)}〕`:""}${P(re.name)}${we?` ${P(we)}`:""}`}).join(" · ");let Ne=!1;try{Ne=_e.extractStatus(O.id)==="draft"}catch{}if(O.type==="book"){const re=O;return{title:P(re.title),subtitle:re.edition?P(re.edition):fe||void 0,aside:[Ne?L.status.draft:"",fe&&re.edition?fe:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(O.type==="collection"){const re=O;return{title:P(re.title),subtitle:P(Nt(re,L.unit.juan))||void 0,aside:[(ue=re.publication_info)==null?void 0:ue.year,Ne?L.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:fe||void 0}}if(O.type==="entity"){const re=O,we=Oe=>Oe==null?"":Oe<0?I("detail.bce",{n:-Oe}):String(Oe),Ve=re.birth_year!=null||re.death_year!=null?`${we(re.birth_year)||"?"}—${we(re.death_year)||"?"}`:"";return{title:P(re.primary_name||re.title),subtitle:[re.dynasty?`〔${P(re.dynasty)}〕`:"",Ve].filter(Boolean).join(" ")||void 0,aside:Ne?L.status.draft:void 0,secondLine:void 0}}const q=P(Nt(O,L.unit.juan));return{title:P(O.title),subtitle:[q,fe].filter(Boolean).join(" · ")||void 0,aside:[Ob(L,O.subtype),Ne?L.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[O,P,L,I]),Se=O&&so(O)?"text":null,Be=()=>{B(null),a("fulltext")};let De=null;if(O&&S){const K=S({detail:O,kind:Se});K&&(De=t.jsx(yo,{href:K}))}else Se&&(De=t.jsx(yo,{onClick:Be}));const Je=K=>{if(!O)return null;const fe=K.replace(/\.[^.]+$/,"");if(S){const Ne=S({detail:O,kind:Se,juan:fe});return Ne?{href:Ne}:null}return{onClick:()=>{B(fe),a("fulltext")}}},He=new Set($.map(K=>K.key)),Ue=de.filter(K=>K.key.startsWith("catalog:")&&K.key!=="catalog:loading"||K.key==="lineage"&&!!oe&&!U||He.has(K.key)).map(K=>({key:K.key,label:K.label,onClick:()=>a(K.key)})),z=()=>{var K;return O?O.type==="work"?t.jsx(Mc,{data:O,transport:E,onNavigate:x,renderLink:w,readAction:De,railTop:v,railLinks:Ue}):O.type==="book"?t.jsx(Hc,{data:O,transport:E,onNavigate:x,renderLink:w,readAction:De,fullText:Pe,fullTextPending:so(O)&&!!E.getTextManifest&&Z!==O.id,chapterLink:Je,railTop:v,railLinks:Ue}):O.type==="collection"?t.jsx(Fc,{data:O,catalog:(K=ne[0])==null?void 0:K.data,transport:E,onNavigate:x,renderLink:w,readAction:De,railTop:v,railLinks:Ue,catalogAction:ne.length>0?t.jsxs("a",{href:"#catalog",onClick:fe=>{fe.preventDefault(),a(`catalog:${ne[0].resource_id}`)},children:[P(L.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Dc,{data:O,transport:E,onNavigate:x,renderLink:w,railTop:v,railLinks:Ue}):null},ie=()=>{var fe,Ne,q;if(!X||!O)return null;if(s==="basic"||s==="emendated")return z();if(typeof s=="string"&&s.startsWith("catalog:")){const ue=(fe=ne.find(re=>`catalog:${re.resource_id}`===s))==null?void 0:fe.data;return t.jsx(Vo,{data:ue,onNavigate:x,renderLink:w})}if(s==="collated"||s==="fulltext")return t.jsx(wr,{id:e,transport:E,chapter:Me,onLocationChange:ue=>B(ue.chapter),onNavigate:x});if(s==="lineage"){if(!oe)return t.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:I(U?"detail.loading":"detail.noLineageGraph")});const ue=O.type==="work"?O:null;return t.jsx(zr,{graph:oe,renderLink:w,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:u??((Ne=ue==null?void 0:ue.version_graph)==null?void 0:Ne.default_collection),onCollectionChange:m,collectionsAvailable:(q=ue==null?void 0:ue.version_graph)==null?void 0:q.collections,collectionCounts:(()=>{var Oe,lt,Rt,Ge,Et,Ot,Qt;if(!ue)return;const re={},we=((Oe=me.current)==null?void 0:Oe.books)??[];re.all=(((lt=ue.books)==null?void 0:lt.length)??0)-(((Ge=(Rt=ue.version_graph)==null?void 0:Rt.excluded_books)==null?void 0:Ge.length)??0);const Ve=(Et=ue.version_graph)==null?void 0:Et.collections;if(Ve)for(const xn of Object.keys(Ve))re[xn]=ai(ue,we,xn).nodes.filter(Un=>Un.kind==="book"&&!Un.bridge).length;return re.core==null&&((Qt=(Ot=ue.version_graph)==null?void 0:Ot.core_books)!=null&&Qt.length)&&(re.core=ue.version_graph.core_books.length),re})()})}if(s==="feedback"&&_)return t.jsx(Ic,{resourceId:e,apiUrl:C});const K=$.find(ue=>ue.key===s);return K?K.render({detail:O,entry:X,transport:E,onNavigate:x}):null};if(G)return t.jsx(Nn,{style:{minHeight:M,...R},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((K,fe)=>t.jsx("div",{style:{height:fe===1?40:16,width:K,opacity:.35,background:i("rule")}},fe))})});if(Q||!O||!X||!ye)return t.jsx(Nn,{style:{minHeight:M,...R},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:I("detail.notFound")})});const ae=s==="basic"||s==="emendated",be=[{label:y??L.detailTab.backToIndex,onClick:k}];if(O.type==="book"&&O.work_id){const K=O.work_id;be.push({label:L.indexType.work,id:K,onClick:()=>x==null?void 0:x(K)})}be.push({label:L.indexType[O.type]});const je=s==="collated"||s==="fulltext",ge=typeof N=="string"?L.status[N.trim()]??N:N,Ie=t.jsx(Kl,{left:t.jsxs(t.Fragment,{children:[ge,ge?" · ":"",t.jsx(Wb,{id:O.id,label:L.label.id,copied:L.action.copied,copyLabel:L.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!ae&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:L.detailTab.submitVersion}),ee&&t.jsx("a",{href:ee.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:L.detailTab.dataLicense})]})});return ae?t.jsx("div",{className:F,children:t.jsxs(Nn,{grid:!0,style:{minHeight:M,...R},children:[t.jsx(jo,{breadcrumb:t.jsx(vo,{items:be}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Eo,{style:{border:"none",background:"transparent"}}),!T&&ee&&t.jsx(Io,{...ee})]})}),z(),Ie]})}):t.jsx("div",{className:F,children:t.jsxs(Nn,{wide:je,style:{minHeight:M,...R},children:[t.jsx(jo,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(ir,{char:"籍"}),t.jsx(vo,{items:be})]}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Eo,{}),_&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:L.detailTab.feedback}),!T&&ee&&t.jsx(Io,{...ee})]})}),t.jsx(Wl,{...ye,aside:je?t.jsxs("button",{type:"button",onClick:()=>a("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[I("detail.workInfo")," →"]}):ye.aside}),!je&&de.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:de.map(K=>t.jsx(Ol,{label:K.label,active:K.key===s||ae&&K.key==="basic",onClick:()=>a(K.key)},K.key))}),t.jsx("div",{style:{marginTop:!je&&de.length>1?8:0},children:ie()}),Ie]})})};function Wb({id:e,label:n,copied:o,copyLabel:r}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?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 Ob(e,n){return n?e.workSubtype[n]??n:""}const Id=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Ri="zhusha",Ei="bim-theme";function Ld(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Ii(e){return Ld(e)?e:Ri}function Hb(){try{return Ii(window.localStorage.getItem(Ei))}catch{return Ri}}function Ad(e){try{window.localStorage.setItem(Ei,e)}catch{}}function Pd(e){const n=Ii(e);return document.documentElement.setAttribute("data-theme",n),n}function Md(){return Ii(document.documentElement.getAttribute("data-theme"))}const Fb=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Mr="airy",Li="bim-layout";function Bd(e){return e==="airy"||e==="boxed"}function Ai(e){return Bd(e)?e:Mr}function Db(){try{return Ai(window.localStorage.getItem(Li))}catch{return Mr}}function Ub(e){try{window.localStorage.setItem(Li,e)}catch{}}function Vb(e){const n=Ai(e);return document.documentElement.setAttribute("data-layout",n),n}function Gb(){return Ai(document.documentElement.getAttribute("data-layout"))}const Yb=`try{var t=localStorage.getItem(${JSON.stringify(Ei)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Li)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,Kb={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},qb=({onChange:e,style:n})=>{const{t:o}=J(),[r,s]=g.useState(Ri);g.useEffect(()=>{s(Md())},[]);const a=l=>{s(Pd(l)),Ad(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Id.map(l=>{const d=r===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":o(`common.theme.${l.name}`),title:o(`common.theme.${l.name}`),onClick:()=>a(l.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:i(Kb[l.name]),boxShadow:d?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=_e.BidLink;exports.BookIndexError=_e.BookIndexError;exports.BookIndexManager=_e.BookIndexManager;exports.BookIndexStorage=_e.BookIndexStorage;exports.BundleStorage=_e.BundleStorage;exports.ConfigError=_e.ConfigError;exports.GithubStorage=_e.GithubStorage;exports.IdGenerationError=_e.IdGenerationError;exports.IdGenerator=_e.IdGenerator;exports.LocalStorage=_e.LocalStorage;exports.MigrationError=_e.MigrationError;exports.StorageError=_e.StorageError;exports.VARIANT_CHARS=_e.VARIANT_CHARS;exports.base36Decode=_e.base36Decode;exports.base36Encode=_e.base36Encode;exports.base58Decode=_e.base58Decode;exports.buildId=_e.buildId;exports.buildPromotionMap=_e.buildPromotionMap;exports.cleanName=_e.cleanName;exports.decodeId=_e.decodeId;exports.decodeIdString=_e.decodeIdString;exports.encodeId=_e.encodeId;exports.extractIdFromUrl=_e.extractIdFromUrl;exports.extractStatus=_e.extractStatus;exports.extractType=_e.extractType;exports.isChapterSegment=_e.isChapterSegment;exports.isTextKey=_e.isTextKey;exports.matchChapterAcrossVersions=_e.matchChapterAcrossVersions;exports.normalizeCatalog=_e.normalizeCatalog;exports.normalizeVariants=_e.normalizeVariants;exports.parseId=_e.parseId;exports.pickTextVersion=_e.pickTextVersion;exports.shardOf=_e.shardOf;exports.smartDecode=_e.smartDecode;exports.textVersionLabel=_e.textVersionLabel;exports.validateResource=_e.validateResource;exports.Badge=mi;exports.BidUrlProvider=sp;exports.BookDetailLayout=Bb;exports.BookPage=Hc;exports.Breadcrumb=vo;exports.CATALOG_ALL_ID=Ct;exports.CATALOG_CSS=Uc;exports.CATALOG_NARROW_QUERY=Tr;exports.CATALOG_PAGE_SIZE=Nr;exports.CATALOG_UNCLASSIFIED_ID=Gt;exports.CLASSIFICATIONS=ji;exports.COMMON_TRADITIONAL_CHARS=Ea;exports.CardFoot=On;exports.CatalogPage=xb;exports.CatalogPager=Zc;exports.CatalogTree=Gc;exports.CheckFilter=Pl;exports.Chip=Hl;exports.ChipWall=Zm;exports.CollectionCatalog=Vo;exports.CollectionPage=Fc;exports.CreateEntityDialog=_c;exports.DEFAULT_LAYOUT=Mr;exports.DEFAULT_META_HOME_LINKS=gd;exports.DEFAULT_READER_PREFS=Ko;exports.DEFAULT_READ_HOME_LINKS=Qc;exports.DEFAULT_THEME=Ri;exports.DETAIL_CSS=Bl;exports.DYNASTY_GROUPS=yi;exports.Dash=ih;exports.DataTable=Qm;exports.DetailFooter=Kl;exports.DetailGrid=Bn;exports.DetailHeader=Wl;exports.EMPTY_FILTERS=bi;exports.ENTITY_TEXT_CSS=br;exports.EmendatedBySection=nl;exports.EmptyNote=dh;exports.EntityDetail=Xa;exports.EntityMark=jr;exports.EntityPage=Dc;exports.EntityPickerDialog=Cc;exports.EntitySelector=Sc;exports.EntityText=bg;exports.ExpandRow=oh;exports.ExtLink=ph;exports.FEEDBACK_FAB_OFFSET_VAR=zo;exports.FILTER_SUPPORT=Ha;exports.FONT_SIZE_STEPS=$t;exports.FactList=Ym;exports.FeedbackButton=rx;exports.FeedbackDialog=Rc;exports.FeedbackForm=Ec;exports.FeedbackList=Sr;exports.FeedbackTab=Ic;exports.FilterChip=Ol;exports.FormInput=ut;exports.FormTextArea=Kt;exports.GUJI_MARKDOWN_FIELD=Ju;exports.GUJI_TABLE_NOTATION=ll;exports.GlyphBadge=ir;exports.GujiInteractiveReader=nf;exports.GujiTable=rr;exports.GujiTextViewer=vr;exports.GujiWarpCanvas=fr;exports.HomePage=$o;exports.ImagePanel=mo;exports.IndexApp=tf;exports.IndexBrowser=po;exports.IndexDetail=Uo;exports.IndexEditor=zc;exports.IndexView=Vf;exports.IntroGrid=Gm;exports.LAYOUTS=Fb;exports.LAYOUT_STORAGE_KEY=Li;exports.LOSS_OPTIONS=Oa;exports.LocaleContext=Xt;exports.LocaleProvider=Ip;exports.LocaleToggle=Eo;exports.META_HOME_CSS=hd;exports.META_HOME_SECTION_IDS=Ed;exports.MetaCatalogTable=wd;exports.MetaCollectionGroups=Cd;exports.MetaDataLicense=Rd;exports.MetaHomeView=Rb;exports.MetaLine=et;exports.MetaLineageCards=Td;exports.MetaOnlineSites=Nd;exports.MetaPeopleTimeline=zd;exports.MetaRecentPanel=vd;exports.MetaRelatedCatalogs=_d;exports.MetaTypeChips=bd;exports.ModeIndicator=Pa;exports.MoreButton=Xm;exports.MoreLink=tr;exports.PAGE_MAX_WIDTH=oi;exports.PERIOD_NARROW_SHARE=id;exports.PageFrame=Nn;exports.Quote=sh;exports.READER_CSS=xl;exports.READ_HOME_CSS=Er;exports.READ_HOME_NARROW_QUERY=Dn;exports.READ_HOME_SECTION_IDS=md;exports.READ_PERIOD_LABELS=vb;exports.RECENT_IDS_STORAGE_KEY=ln;exports.ROLE_CLASS_ORDER=Nl;exports.ReadButton=yo;exports.ReadFamousWorks=dd;exports.ReadHomeView=wb;exports.ReadPeriodBand=pd;exports.ReadPicks=sd;exports.ReadPieces=ud;exports.ReadSection=st;exports.ReadShelf=Lr;exports.ReadSibu=Ar;exports.ReadStats=rd;exports.ReadTopicGroup=ld;exports.ReadTopics=cd;exports.ReaderMdText=cr;exports.ReaderShell=Sl;exports.ReaderToc=yl;exports.RelationPanel=kc;exports.RepoSourceLink=Io;exports.ResourceEditor=lo;exports.ResourceGroup=ah;exports.ResourceLine=lh;exports.ResourceList=Oo;exports.ResourceRow=Gl;exports.SEARCH_VIEW_STORAGE_KEY=Ho;exports.SEVEN_PAVILIONS_KEY=$d;exports.SNIPPET_MARK_END=Ca;exports.SNIPPET_MARK_START=$a;exports.SORTABLE_TYPES=Wa;exports.SearchInput=Ba;exports.SearchResults=Ya;exports.Sec=tt;exports.Section=bt;exports.SectionHead=Km;exports.SideList=Yt;exports.SmartBidInput=si;exports.SourceEditor=yc;exports.StripWarpRenderer=wo;exports.SummaryCard=Wn;exports.THEMES=Id;exports.THEME_INIT_SCRIPT=Yb;exports.THEME_STORAGE_KEY=Ei;exports.TRADITIONAL_ALLOWLIST=Ia;exports.TabFilter=$i;exports.TableHead=eh;exports.TableRow=th;exports.TagRow=Yl;exports.TagRows=ch;exports.TextButton=qm;exports.TextReader=wr;exports.ThemeToggle=qb;exports.TopStrip=jo;exports.VersionLineageGraph=Oc;exports.VersionLineageList=Wc;exports.VersionLineageView=zr;exports.VolumeChips=Jm;exports.VolumeLinks=or;exports.WorkCard=qc;exports.WorkCardGrid=Jc;exports.WorkCatalog=df;exports.WorkPage=Mc;exports.WorkRow=Xc;exports.adaptCharCord=cf;exports.adaptEntityJson=sc;exports.adaptGujiPages=rf;exports.adaptPunctJson=sf;exports.applyLayout=Vb;exports.applyTheme=Pd;exports.authorsLine=Ni;exports.bookIndexUriToId=_o;exports.bucketResources=Zo;exports.buildCatalogTree=lb;exports.buildCollectionTable=El;exports.buildLineageGraph=ai;exports.buildMeiliFilter=Xp;exports.buildPageUrl=Wo;exports.buildParagraphBlocks=Ql;exports.buildVersionRow=zl;exports.buildVersionTable=Tl;exports.canParagraphize=pi;exports.catalogNodeIdOf=sb;exports.catalogNodeIdsOf=ab;exports.catalogPageCount=ub;exports.catalogTotal=Rr;exports.classificationPath=Fn;exports.clearAllRecentIds=Fo;exports.compareCatalogCards=pb;exports.computeVersionPartition=Am;exports.countActiveFilters=vi;exports.createTextApi=ul;exports.currentLayout=Gb;exports.currentTheme=Md;exports.defaultEntityHref=uc;exports.defaultWorkLink=Yc;exports.deriveDating=Em;exports.deriveEditionType=Ll;exports.deriveEra=Mn;exports.deriveYear=wi;exports.deriveYearRange=Xo;exports.detailToEditor=Nc;exports.detectGenre=zi;exports.displayAuthorRole=Qo;exports.editorToDetail=Uf;exports.eraRank=xo;exports.filtersFromParams=Zp;exports.filtersToParams=li;exports.findCatalogPath=an;exports.findTraditionalChars=Pp;exports.firstAuthorText=Ir;exports.flattenTitles=ko;exports.flattenToc=wl;exports.fmtCount=Ye;exports.formatHitCount=ii;exports.formatTemplate=mt;exports.formatVolumeRange=_i;exports.getDisplayNameFromUrl=hn;exports.getMessages=un;exports.getStartPage=Bo;exports.getT=mn;exports.getTypeGroupKey=Po;exports.groupRelatedWorks=Im;exports.gujiInlineToPlain=al;exports.hasActiveFilters=Fa;exports.hasGujiMarkdownV02=uo;exports.hasGujiTableNotation=cl;exports.hasSearchOptions=Yp;exports.iiifVolumeOf=af;exports.isCountedChar=xr;exports.isLayoutName=Bd;exports.isThemeName=Ld;exports.lineageHref=fd;exports.loadRecentIds=Mt;exports.measureText=Nt;exports.mergeVolumeResources=Mo;exports.normalizeEra=Qe;exports.normalizeLayout=Ai;exports.normalizeRole=Jo;exports.normalizeTheme=Ii;exports.normalizeVolumeIndex=In;exports.normalizeVolumes=Aa;exports.numberToChinese=Il;exports.paginationItems=Vc;exports.parseChineseNumber=ci;exports.parseGujiInline=sl;exports.parseGujiTable=pl;exports.parseSourceString=jc;exports.pct=Pr;exports.periodLevel=nd;exports.pickReaderVersion=kl;exports.readStoredLayout=Db;exports.readStoredTheme=Hb;exports.readerVersionOptionLabel=go;exports.remapPlainOffsets=ac;exports.removeRecentId=Ka;exports.renderFullTextBody=xh;exports.renderProperNames=tc;exports.renderReaderInline=lr;exports.resolveRecentEntry=Do;exports.resourceHref=gn;exports.resourceNote=Si;exports.resultTabFromParam=au;exports.resultTabToParam=lu;exports.roleFacets=Rl;exports.rowNo=nh;exports.sameFilters=Jp;exports.saveRecentId=co;exports.segmentEntities=lc;exports.shelfColumns=ed;exports.sortFor=Kp;exports.sortYear=di;exports.spineHeight=td;exports.splitFullTextTables=Go;exports.splitHighlightSnippet=Lo;exports.splitTableRow=dl;exports.storeLayout=Ub;exports.storeTheme=Ad;exports.stringifySources=vc;exports.summaryFromEntry=dc;exports.summaryFromItem=cc;exports.timelineLayout=xd;exports.toCatalogWorkCard=db;exports.transportSummaryLoader=pc;exports.typeSupportsFilters=Da;exports.useBidUrl=Ze;exports.useChapterWarpData=gc;exports.useConvert=Ae;exports.useEntitySummaryLoader=yr;exports.useI18n=J;exports.useReaderPrefs=vl;exports.useRecentEntries=yd;exports.useT=Te;exports.validateLineageGraph=zx;exports.volumeStats=fi;exports.withDefaultLinks=Bt;exports.withMetaLinks=Wt;exports.yearText=hi;
|
|
1865
|
+
`,fd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Bt(e){return{...fd,...e??{}}}function xd(e,n){if(e.lineage)return e.lineage(n);const o=e.item(n),r=o.indexOf("#"),[s,a]=r<0?[o,""]:[o.slice(0,r),o.slice(r)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function Pr(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function bd(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),o=e.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,m=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(u,m),Math.max(u,m)]},s=n.map(r),a=Math.min(...s.map(p=>p[0])),l=Math.max(...s.map(p=>p[1])),d=Math.max(1,l-a),c=n.map((p,u)=>({p,from:s[u][0],to:s[u][1]})).sort((p,u)=>p.from-u.from).map(p=>({...p,left:(p.from-a)/d*100,width:Math.max(.8,(p.to-p.from)/d*100)}));return{min:a,max:l,placed:c,missing:o}}function hi(e,n=mn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function zb(e){return{read:e.item,work:e.item,node:e.node}}function yd({counts:e,links:n}){const{t:o}=J(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),e.works],["book",o("metaHome.typeLabel.book"),e.books],["collection",o("metaHome.typeLabel.collection"),e.collections],["entity",o("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:r(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Ye(d)})]})},a))})}function jd(e,n=5){const[o,r]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Pt().slice(0,n);if(!l.length||!e){r([]);return}return Promise.all(l.map(d=>Do(e,d))).then(d=>{a||r(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{Fo(),r([])},[]);return{entries:o,clear:s}}function Tb(e,n,o){const r=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return r?o(r):vd(e.type,n)}function vd(e,n){return n(`metaHome.typeLabel.${e}`)}function kd({entries:e,onClear:n,links:o}){const{t:r,convert:s}=J(),a=Bt(o);return t.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[t.jsxs("div",{className:"bim-mh-recent-h",children:[t.jsx("h2",{id:"bim-mh-recent-h",children:r("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:r("metaHome.recentClear")})]}),e&&e.length>0&&t.jsx("ol",{children:e.map(l=>t.jsx("li",{children:t.jsxs("a",{href:a.item(l.id),"aria-label":r("metaHome.recentItemLabel",{type:l.type?vd(l.type,r):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?r(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:Tb(l,r,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function wd(e,n,o,r=!1){return r&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):o(e)}function Sd({rows:e,links:n}){const{t:o,convert:r}=J(),s=Bt(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":o("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[o("metaHome.catalogTitle"),t.jsx("small",{children:o("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:o("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:o("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:o("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=Pr(a.imported,a.total),d=a.work_id??a.collection_id,c=r(a.edition?`${a.name}·${a.edition}`:a.name);return t.jsxs("tr",{children:[t.jsx("th",{scope:"row",children:d?t.jsx("a",{href:s.item(d),children:c}):c}),t.jsx("td",{className:"bim-mh-r",children:Ye(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ye(a.imported)}),t.jsx("td",{children:t.jsxs("span",{className:"bim-mh-meter",children:[t.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[l,"%"]})]})}),t.jsx("td",{children:a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:wd(a.status,o,r)})})]},a.id||a.name)})})]})}):null}function _d({items:e,links:n,label:o}){const{convert:r}=J();return t.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):void 0,children:e.map(s=>t.jsx("li",{children:t.jsxs("a",{href:n.item(s.id),children:[t.jsx("span",{className:"bim-rh-t",children:r(s.title)}),s.sub&&t.jsx("small",{children:r(s.sub)})]})},s.id))})}function $d({works:e,links:n}){const{t:o}=J(),[r,s]=g.useState(!1);if(!e.length)return null;const a=Mn(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":r?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o("metaHome.relatedTitle"),t.jsx("small",{children:o("metaHome.relatedNote")})]}),t.jsx(_d,{items:e.map(l=>({id:l.id,title:l.title,sub:Ni(l)||void 0})),links:Bt(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":r,onClick:()=>s(l=>!l),children:r?o("action.collapse"):o("metaHome.allNWorks",{n:e.length})})]})}const Cd="siku_qige";function Nb({group:e,links:n}){const{t:o,convert:r}=J(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Mn(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[r(e.label),t.jsx("small",{className:"bim-rh-num",children:o("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(_d,{items:e.items,links:n,label:e.label}),Mn(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?o("action.collapse"):o("metaHome.allNKinds",{n:e.items.length})})]})}function zd({groups:e,links:n}){const{t:o,convert:r}=J(),s=Bt(n);if(!e.length)return null;const a=e.find(c=>c.key===Cd),l=e.filter(c=>c!==a),d=c=>{var p;return((p=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:p[1])??c};return t.jsxs(t.Fragment,{children:[a&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:"bim-rh-gt",children:[r(a.label),t.jsx("small",{children:r(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":r(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":r(c.title),title:r(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:r(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:o("metaHome.pavilion")})]})},c.id))})]}),l.length>0&&t.jsx("div",{className:"bim-mh-cg",style:a?void 0:{marginTop:0},children:l.map(c=>t.jsx(Nb,{group:c,links:s},c.key))})]})}const ka=34,wa=13;function Sa(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?hi(e.birth_year,n):"?"}–${e.death_year!=null?hi(e.death_year,n):"?"}`}function Rb(e,n){const o=n-e,r=o>1200?300:o>400?100:50,s=[];for(let a=Math.ceil(e/r)*r;a<=n;a+=r)s.push(a);return s}function Td({people:e,links:n}){const{t:o,convert:r}=J(),s=Bt(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=bd(e),p=[],u=d.map(h=>{const f=h.left>70,x=f?Math.min(h.left,h.left+h.width-wa):h.left;let k=0;for(;p[k]!=null&&p[k]>x;)k++;return p[k]=f?h.left+h.width:h.left+Math.max(h.width,wa),{...h,lane:k,end:f}}),m=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*ka+10},children:u.map(h=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":h.end?"":void 0,style:{left:`${h.left}%`,top:h.lane*ka+4,width:`${Math.max(h.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(h.p.id),children:[r(h.p.name),t.jsx("small",{className:"bim-rh-num",children:Sa(h.p,o)})]})]},h.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Rb(a,l).map(h=>t.jsx("span",{style:{left:`${(h-a)/m*100}%`},children:hi(h,o)},h))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?e:c).map(h=>t.jsx("li",{children:t.jsxs("a",{href:s.item(h.id),children:[t.jsx("span",{children:r(h.name)}),t.jsx("small",{className:"bim-rh-num",children:[h.dynasty?r(h.dynasty):"",Sa(h,o)].filter(Boolean).join(" ")})]})},h.id))}),c.length>0&&u.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(h=>h.name).join("、"))})})]})}const Eb=t.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[t.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),t.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),t.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),t.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function Nd({works:e,links:n}){const{t:o,convert:r}=J(),s=Bt(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Ni(a);return t.jsx("li",{children:t.jsxs("a",{href:xd(s,a.id),children:[Eb,t.jsx("b",{children:r(a.title)}),l&&t.jsx("small",{children:r(l)}),t.jsx("span",{children:o("metaHome.viewLineage")})]})},a.id)})}):null}function Rd({sites:e}){const{t:n,convert:o}=J(),r=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!r.includes(a));return e.length?t.jsxs(t.Fragment,{children:[r.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:r.map(a=>{const l=Pr(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:o(a.name)}):t.jsx("span",{children:o(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${Ye(a.imported)} / ${Ye(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:wd(a.status,n,o,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:o(s.map(a=>a.name).join("、"))})})]}):null}const _a=["extant","partially_extant","lost","unknown"];function Ed({stats:e,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:a}=J(),l=["works","books","collections","entities","has_image","has_text","article","poem"].map(p=>[e[p],a(`metaHome.stat.${p}`)]).filter(([p])=>p>0),d=n==null?void 0:n.loss,c=_a.some(p=>{var u;return(((u=e.loss)==null?void 0:u[p])??0)>0});return t.jsxs("div",{className:"bim-mh-data",children:[l.length>0&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.dataScale")}),t.jsx("ul",{className:"bim-mh-nums",children:l.map(([p,u])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:Ye(p)}),t.jsx("span",{children:u})]},u))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:_a.map(p=>{var h;const u=((h=e.loss)==null?void 0:h[p])??0,m=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&u>0?a("metaHome.lossCount",{n:Ye(u),note:m}):m})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),r?t.jsx("a",{href:r,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),o&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:o})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const Id={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Ib({sections:e,links:n,head:o,transport:r,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:u}){var v,$;const{t:m}=J(),h=e,f=Bt(n),x=zb(f),k=Id,y=jd(r),w={zhi:!!((v=h.shelf)!=null&&v.items.length)||h.catalog_progress.length>0||h.related_catalogs.length>0,sibu:h.bu.length>0||h.unclassified>0,cong:h.collection_groups.length>0,people:h.bibliographers.length>0,lineage:h.lineage.length>0,sites:h.sites.length>0,data:!0},b=Object.keys(k).filter(_=>w[_]),j=_=>m(`metaHome.nav.${_}`),S=(_,C)=>_?t.jsx("a",{className:"bim-rh-more",href:_,children:C}):void 0;return t.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[t.jsx("style",{children:Er+gd}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[o,t.jsx(yd,{counts:h.counts,links:n})]}),r&&t.jsx(kd,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":m("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(_=>t.jsx("li",{children:t.jsx("a",{href:`#${k[_]}`,children:j(_)})},_))})}),t.jsxs("div",{className:"bim-rh-main",children:[w.zhi&&t.jsxs(st,{id:k.zhi,title:j("zhi"),sub:m("metaHome.zhiSub"),children:[h.shelf&&h.shelf.items.length>0&&t.jsx(Lr,{topic:{key:"shelf",label:h.shelf.label,shelf:!0,items:h.shelf.items},links:x,showTitle:!1,legendCount:h.shelf.items.some(_=>_.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(h.catalog_progress.length>0||h.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=h.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(Sd,{rows:h.catalog_progress,links:n}),t.jsx($d,{works:h.related_catalogs,links:n})]})]}),w.sibu&&t.jsx(st,{id:k.sibu,title:j("sibu"),sub:m("metaHome.sibuSub"),more:S(s,m("metaHome.toCatalog")),children:t.jsx(Ar,{bu:h.bu,unclassified:h.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),w.cong&&t.jsx(st,{id:k.cong,title:j("cong"),sub:m("metaHome.congSub"),more:S(a,m("metaHome.allNKindsMore",{n:Ye(h.counts.collections)})),children:t.jsx(zd,{groups:h.collection_groups,links:n})}),w.people&&t.jsx(st,{id:k.people,title:j("people"),sub:m("metaHome.peopleSub"),more:S(l,m("metaHome.allNPeopleMore",{n:Ye(h.counts.entities)})),children:t.jsx(Td,{people:h.bibliographers,links:n})}),w.lineage&&t.jsx(st,{id:k.lineage,title:j("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(Nd,{works:h.lineage,links:n})}),w.sites&&t.jsx(st,{id:k.sites,title:j("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(Rd,{sites:h.sites})}),t.jsx(st,{id:k.data,title:j("data"),sub:m("metaHome.dataSub"),children:t.jsx(Ed,{stats:h.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const vt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),nt=e=>Array.isArray(e),Lb=e=>vt(e)&&!!e.h;function Ab(e){if(!e)return!1;for(const n of["_related","_catalogs","_collections","_works","_members","_children"]){const o=e[n];if(nt(o)&&o.some(Lb))return!0}return!1}function ni(e,n){var r;if(typeof e.title=="string"&&e.title)return e.title;const o=e.id??e.bid;return e.h&&o&&((r=n==null?void 0:n[o])!=null&&r.title)?n[o].title:""}function Pb(e){const n=e.filter(vt);return n.find(o=>o.scheme==="zongmu")??n[0]??null}const Mb=e=>typeof e=="number"?e:nt(e)&&typeof e[0]=="number"?e[0]:void 0;function Ro(e,n){if(!vt(e))return e;const o={...e},r=e.type;if(r==="work"){if(!nt(e.books)&&nt(e._books)&&(o.books=e._books.filter(vt).map(s=>s.id).filter(s=>typeof s=="string")),!vt(e.classification)&&nt(e._classifications)){const s=Pb(e._classifications);s&&(o.classification={l1:s.l1??"",l2:s.l2??"",l3:s.l3??"",l4:s.l4??"",...s.source?{source:s.source}:{}})}nt(e._related)&&(o.related_works=e._related.filter(vt).map(s=>{const a=s;return{id:a.id,title:ni(a,n),...a.relation?{relation:a.relation}:{},...a.note?{note:a.note}:{}}})),!nt(e.indexed_by)&&nt(e._catalogs)&&e._catalogs.length&&(o.indexed_by=e._catalogs.filter(vt).map(s=>{const a=s;return{source:ni(a,n)||String(a.bid??""),...a.bid?{source_bid:a.bid}:{},...a.section?{section:a.section}:{}}}))}if((r==="work"||r==="book")&&!nt(e.contained_in)&&nt(e._collections)&&e._collections.length&&(o.contained_in=e._collections.filter(vt).map(s=>{const a=s;return{id:a.id,...a.vol!=null?{volume_index:a.vol}:{},...a.sub!=null?{sub_items:a.sub}:{}}})),r==="collection"&&nt(e._members)){const s=e._members.filter(vt),a=typeof e._member_count=="number"?e._member_count:s.length,l=d=>d.t==="work";if(!nt(e.books)){const d=s.filter(c=>!l(c)).map(c=>c.id).filter(c=>typeof c=="string");d.length&&(o.books=d)}if(!nt(e.contained_works)){const d=s.filter(l).map(c=>{const p=Mb(c.vol);return{id:c.id,title:ni(c,n),...p!=null?{volume_index:p}:{}}});d.length&&(o.contained_works=d)}a>s.length&&(o._members_truncated=!0)}return r==="entity"&&!nt(e.works)&&nt(e._works)&&(o.works=e._works.filter(vt).map(s=>{const a=s,l=ni({...a,id:a.work_id},n);return{...a,work_id:a.work_id,...l?{title:l}:{}}})),o}function Bb(e){let n=null;const o=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null),r=async s=>s&&Ro(s,Ab(s)?await o():null);return new Proxy(e,{get(s,a,l){if(a==="getItem")return async c=>r(await s.getItem(c));const d=Reflect.get(s,a,s);return typeof d=="function"?d.bind(s):d}})}const Eo=({style:e})=>{const n=g.useContext(Xt),{t:o}=J();if(!n)return null;const{locale:r,setLocale:s}=n,a=r==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:o(a?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${i("border")}`,borderRadius:"4px",background:i("bg"),color:i("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?i("primary"):void 0,fontWeight:a?700:400},children:o("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:i("primary"),fontWeight:a?400:700},children:o("common.localeShortHans")})]})},Io=({href:e,label:n,size:o=16,className:r,style:s})=>{const{t:a}=J(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,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:t.jsx("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})})};function so(e){const n=e.text_count;return typeof n=="number"&&n>0}function ao(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function Wb(e,n){if(!n)return!1;const o=n.id;return o===void 0||o===e}const Ob=({id:e,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:u,onLineageCollectionChange:m,initialPage:h=1,selectedLineageNodeId:f,onNavigate:x,onBack:k,backLabel:y,renderLink:w,enrichDetail:b,getSourceLink:j,readLink:S,railTop:v,extraTabs:$=[],showFeedbackTab:_=!0,feedbackApiUrl:C,height:M,footerExtra:N,hideHeaderControls:T=!1,className:F,style:R})=>{const E=g.useMemo(()=>Bb(n),[n]),L=Te(),{t:I,convert:P}=J(),[V]=g.useState(()=>{if(!Wb(e,o))return null;const K=Ro({...o}),ge=r??ao(e,K);return b&&b(ge,K),{id:e,entry:ge,detail:K}}),[X,D]=g.useState((V==null?void 0:V.entry)??null),[O,A]=g.useState((V==null?void 0:V.detail)??null),[G,se]=g.useState(!V),[Q,ke]=g.useState(!1),[ne,de]=g.useState([]),[We,we]=g.useState(!1),[Pe,Ee]=g.useState(null),[Z,ae]=g.useState(null),[oe,fe]=g.useState(null),[U,$e]=g.useState(!1),me=g.useRef(null),Ce=g.useRef(0),[Y,ze]=g.useState(null),Me=l!==void 0?l:Y,B=g.useCallback(K=>{d?d(K):ze(K)},[d]),te=g.useCallback(async K=>{if(!E.getCollectionCatalogs&&!E.getCollectionCatalog){de([]);return}we(!0);try{if(E.getCollectionCatalogs)de(await E.getCollectionCatalogs(K)||[]);else if(E.getCollectionCatalog){const ge=await E.getCollectionCatalog(K);de(ge?[{resource_id:"",data:ge}]:[])}}catch{de([])}finally{we(!1)}},[E]),xe=g.useCallback(async K=>{var ge,Ae;if(!E.getTextManifest||!E.getTextIndex){Ee(null),ae(K);return}try{const q=_e.pickTextVersion(await E.getTextManifest(K)),le=q?await E.getTextIndex(K,q.key):null;Ee(le&&le.chapters.length>0?{chapters:le.chapters.map(ce=>({n:ce.n,title:ce.title,file:ce.file})),source:{name:((ge=le.source)==null?void 0:ge.name)??(q==null?void 0:q.source_name),license:((Ae=le.source)==null?void 0:Ae.license)??(q==null?void 0:q.license)??void 0}}:null)}catch{Ee(null)}finally{ae(K)}},[E]),Re=g.useCallback(async(K,ge)=>{const Ae=++Ce.current,q=()=>Ae!==Ce.current;$e(!0);try{if(E.getLineageGraph){const ht=await E.getLineageGraph(K);if(q())return;ht&&fe(ht)}const le=ge.version_graph;if(!le||!le.enabled){oe||fe(null),me.current=null;return}const ce=ge.books??[],ve=[];for(const ht of ce)try{const Wt=await E.getItem(ht);Wt&&ve.push(Wt)}catch{}if(q())return;me.current={work:ge,books:ve};const Ve=u??le.default_collection??(le.core_books&&le.core_books.length>0?"core":"all"),Oe=Ve==="core"&&Array.isArray(le.core_books)&&le.core_books.length>0?"core":Ve??"all";fe(ai(ge,ve,Oe))}catch{if(q())return;fe(null),me.current=null}finally{q()||$e(!1)}},[E]),H=g.useRef({initialDetail:o,initialEntry:r});H.current={initialDetail:o,initialEntry:r},g.useEffect(()=>{let K=!1;Ce.current++,$e(!1);const ge=ce=>{ce.type==="collection"?te(e):ce.type==="work"?(ce.version_graph||E.getLineageGraph)&&Re(e,ce):ce.type==="book"&&so(ce)&&xe(e)},Ae=H.current;let q=null;if(V&&V.id===e)q=V;else if(Ae.initialDetail&&Ae.initialDetail.id===e){const ce=Ro({...Ae.initialDetail}),ve=Ae.initialEntry??ao(e,ce);b&&b(ve,ce),q={entry:ve,detail:ce}}return q?(ke(!1),de(ce=>ce.length?[]:ce),Ee(null),fe(null),me.current=null,D(q.entry),A(q.detail),se(!1),ge(q.detail),()=>{K=!0}):((async()=>{se(!0),ke(!1),D(null),A(null),de([]),Ee(null),fe(null),me.current=null;try{const ce=await E.getItem(e);if(K)return;if(!ce){ke(!0);return}const ve=ce;let Ve=null;if(E.getEntry&&(Ve=await E.getEntry(e),K))return;Ve||(Ve=ao(e,ve)),b&&b(Ve,ve),D(Ve),A(ve),ge(ve)}catch{K||ke(!0)}finally{K||se(!1)}})(),()=>{K=!0})},[e,E,V,b,te,Re,xe]),g.useEffect(()=>{const K=me.current;!K||!u||fe(ai(K.work,K.books,u))},[u]);const pe=[];if(O){if(pe.push({key:"basic",label:L.detailTab.basicInfo}),O.type==="collection"){We&&ne.length===0&&pe.push({key:"catalog:loading",label:`${L.detailTab.catalog}…`});for(const K of ne)pe.push({key:`catalog:${K.resource_id}`,label:K.short_name?`${P(K.short_name)}${L.detailTab.catalogSuffix}`:L.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&pe.push({key:s,label:L.detailTab.fullText}),O.type==="work"&&(oe||U)&&pe.push({key:"lineage",label:U?`${L.detailTab.lineage}…`:L.detailTab.lineage});for(const K of $)(K.position??"before-feedback")==="before-feedback"&&K.shouldShow(O)&&pe.push({key:K.key,label:K.label});_&&s==="feedback"&&pe.push({key:"feedback",label:L.detailTab.feedback});for(const K of $)K.position==="after-feedback"&&K.shouldShow(O)&&pe.push({key:K.key,label:K.label})}g.useEffect(()=>{if(s!=="emendated"||!O)return;a("basic");const K=setTimeout(()=>{var ge;(ge=document.getElementById("studies"))==null||ge.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(K)},[s,O,a]);const ee=X&&O&&j?j({activeTab:s,activeJuan:Me,entry:X,detail:O}):null,be=g.useMemo(()=>{var le;if(!O)return null;const ge=(O.authors??[]).map(ce=>{const ve=Qo(ce.role);return`${ce.dynasty?`〔${P(ce.dynasty)}〕`:""}${P(ce.name)}${ve?` ${P(ve)}`:""}`}).join(" · ");let Ae=!1;try{Ae=_e.extractStatus(O.id)==="draft"}catch{}if(O.type==="book"){const ce=O;return{title:P(ce.title),subtitle:ce.edition?P(ce.edition):ge||void 0,aside:[Ae?L.status.draft:"",ge&&ce.edition?ge:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(O.type==="collection"){const ce=O;return{title:P(ce.title),subtitle:P(Nt(ce,L.unit.juan))||void 0,aside:[(le=ce.publication_info)==null?void 0:le.year,Ae?L.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ge||void 0}}if(O.type==="entity"){const ce=O,ve=Oe=>Oe==null?"":Oe<0?I("detail.bce",{n:-Oe}):String(Oe),Ve=ce.birth_year!=null||ce.death_year!=null?`${ve(ce.birth_year)||"?"}—${ve(ce.death_year)||"?"}`:"";return{title:P(ce.primary_name||ce.title),subtitle:[ce.dynasty?`〔${P(ce.dynasty)}〕`:"",Ve].filter(Boolean).join(" ")||void 0,aside:Ae?L.status.draft:void 0,secondLine:void 0}}const q=P(Nt(O,L.unit.juan));return{title:P(O.title),subtitle:[q,ge].filter(Boolean).join(" · ")||void 0,aside:[Fb(L,O.subtype),Ae?L.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[O,P,L,I]),Se=O&&so(O)?"text":null,Be=()=>{B(null),a("fulltext")};let De=null;if(O&&S){const K=S({detail:O,kind:Se});K&&(De=t.jsx(yo,{href:K}))}else Se&&(De=t.jsx(yo,{onClick:Be}));const Je=K=>{if(!O)return null;const ge=K.replace(/\.[^.]+$/,"");if(S){const Ae=S({detail:O,kind:Se,juan:ge});return Ae?{href:Ae}:null}return{onClick:()=>{B(ge),a("fulltext")}}},He=new Set($.map(K=>K.key)),Ue=pe.filter(K=>K.key.startsWith("catalog:")&&K.key!=="catalog:loading"||K.key==="lineage"&&!!oe&&!U||He.has(K.key)).map(K=>({key:K.key,label:K.label,onClick:()=>a(K.key)})),z=()=>{var K;return O?O.type==="work"?t.jsx(Bc,{data:O,transport:E,onNavigate:x,renderLink:w,readAction:De,railTop:v,railLinks:Ue}):O.type==="book"?t.jsx(Fc,{data:O,transport:E,onNavigate:x,renderLink:w,readAction:De,fullText:Pe,fullTextPending:so(O)&&!!E.getTextManifest&&Z!==O.id,chapterLink:Je,railTop:v,railLinks:Ue}):O.type==="collection"?t.jsx(Dc,{data:O,catalog:(K=ne[0])==null?void 0:K.data,transport:E,onNavigate:x,renderLink:w,readAction:De,railTop:v,railLinks:Ue,catalogAction:ne.length>0?t.jsxs("a",{href:"#catalog",onClick:ge=>{ge.preventDefault(),a(`catalog:${ne[0].resource_id}`)},children:[P(L.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Uc,{data:O,transport:E,onNavigate:x,renderLink:w,railTop:v,railLinks:Ue}):null},ie=()=>{var ge,Ae,q;if(!X||!O)return null;if(s==="basic"||s==="emendated")return z();if(typeof s=="string"&&s.startsWith("catalog:")){const le=(ge=ne.find(ce=>`catalog:${ce.resource_id}`===s))==null?void 0:ge.data;return t.jsx(Vo,{data:le,onNavigate:x,renderLink:w})}if(s==="collated"||s==="fulltext")return t.jsx(wr,{id:e,transport:E,chapter:Me,onLocationChange:le=>B(le.chapter),onNavigate:x});if(s==="lineage"){if(!oe)return t.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:I(U?"detail.loading":"detail.noLineageGraph")});const le=O.type==="work"?O:null;return t.jsx(zr,{graph:oe,renderLink:w,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:u??((Ae=le==null?void 0:le.version_graph)==null?void 0:Ae.default_collection),onCollectionChange:m,collectionsAvailable:(q=le==null?void 0:le.version_graph)==null?void 0:q.collections,collectionCounts:(()=>{var Oe,ht,Wt,xn,bn,Ge,Rt;if(!le)return;const ce={},ve=((Oe=me.current)==null?void 0:Oe.books)??[];ce.all=(((ht=le.books)==null?void 0:ht.length)??0)-(((xn=(Wt=le.version_graph)==null?void 0:Wt.excluded_books)==null?void 0:xn.length)??0);const Ve=(bn=le.version_graph)==null?void 0:bn.collections;if(Ve)for(const Ot of Object.keys(Ve))ce[Ot]=ai(le,ve,Ot).nodes.filter(Qt=>Qt.kind==="book"&&!Qt.bridge).length;return ce.core==null&&((Rt=(Ge=le.version_graph)==null?void 0:Ge.core_books)!=null&&Rt.length)&&(ce.core=le.version_graph.core_books.length),ce})()})}if(s==="feedback"&&_)return t.jsx(Lc,{resourceId:e,apiUrl:C});const K=$.find(le=>le.key===s);return K?K.render({detail:O,entry:X,transport:E,onNavigate:x}):null};if(G)return t.jsx(Rn,{style:{minHeight:M,...R},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((K,ge)=>t.jsx("div",{style:{height:ge===1?40:16,width:K,opacity:.35,background:i("rule")}},ge))})});if(Q||!O||!X||!be)return t.jsx(Rn,{style:{minHeight:M,...R},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:I("detail.notFound")})});const re=s==="basic"||s==="emendated",je=[{label:y??L.detailTab.backToIndex,onClick:k}];if(O.type==="book"&&O.work_id){const K=O.work_id;je.push({label:L.indexType.work,id:K,onClick:()=>x==null?void 0:x(K)})}je.push({label:L.indexType[O.type]});const ye=s==="collated"||s==="fulltext",he=typeof N=="string"?L.status[N.trim()]??N:N,Ne=t.jsx(ql,{left:t.jsxs(t.Fragment,{children:[he,he?" · ":"",t.jsx(Hb,{id:O.id,label:L.label.id,copied:L.action.copied,copyLabel:L.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!re&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:L.detailTab.submitVersion}),ee&&t.jsx("a",{href:ee.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:L.detailTab.dataLicense})]})});return re?t.jsx("div",{className:F,children:t.jsxs(Rn,{grid:!0,style:{minHeight:M,...R},children:[t.jsx(jo,{breadcrumb:t.jsx(vo,{items:je}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Eo,{style:{border:"none",background:"transparent"}}),!T&&ee&&t.jsx(Io,{...ee})]})}),z(),Ne]})}):t.jsx("div",{className:F,children:t.jsxs(Rn,{wide:ye,style:{minHeight:M,...R},children:[t.jsx(jo,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(ir,{char:"籍"}),t.jsx(vo,{items:je})]}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Eo,{}),_&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:L.detailTab.feedback}),!T&&ee&&t.jsx(Io,{...ee})]})}),t.jsx(Ol,{...be,aside:ye?t.jsxs("button",{type:"button",onClick:()=>a("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[I("detail.workInfo")," →"]}):be.aside}),!ye&&pe.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:pe.map(K=>t.jsx(Hl,{label:K.label,active:K.key===s||re&&K.key==="basic",onClick:()=>a(K.key)},K.key))}),t.jsx("div",{style:{marginTop:!ye&&pe.length>1?8:0},children:ie()}),Ne]})})};function Hb({id:e,label:n,copied:o,copyLabel:r}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?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 Fb(e,n){return n?e.workSubtype[n]??n:""}const Ld=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Ri="zhusha",Ei="bim-theme";function Ad(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Ii(e){return Ad(e)?e:Ri}function Db(){try{return Ii(window.localStorage.getItem(Ei))}catch{return Ri}}function Pd(e){try{window.localStorage.setItem(Ei,e)}catch{}}function Md(e){const n=Ii(e);return document.documentElement.setAttribute("data-theme",n),n}function Bd(){return Ii(document.documentElement.getAttribute("data-theme"))}const Ub=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Mr="airy",Li="bim-layout";function Wd(e){return e==="airy"||e==="boxed"}function Ai(e){return Wd(e)?e:Mr}function Vb(){try{return Ai(window.localStorage.getItem(Li))}catch{return Mr}}function Gb(e){try{window.localStorage.setItem(Li,e)}catch{}}function Yb(e){const n=Ai(e);return document.documentElement.setAttribute("data-layout",n),n}function Kb(){return Ai(document.documentElement.getAttribute("data-layout"))}const qb=`try{var t=localStorage.getItem(${JSON.stringify(Ei)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Li)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,Xb={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},Zb=({onChange:e,style:n})=>{const{t:o}=J(),[r,s]=g.useState(Ri);g.useEffect(()=>{s(Bd())},[]);const a=l=>{s(Md(l)),Pd(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Ld.map(l=>{const d=r===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":o(`common.theme.${l.name}`),title:o(`common.theme.${l.name}`),onClick:()=>a(l.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:i(Xb[l.name]),boxShadow:d?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=_e.BidLink;exports.BookIndexError=_e.BookIndexError;exports.BookIndexManager=_e.BookIndexManager;exports.BookIndexStorage=_e.BookIndexStorage;exports.BundleStorage=_e.BundleStorage;exports.ConfigError=_e.ConfigError;exports.GithubStorage=_e.GithubStorage;exports.IdGenerationError=_e.IdGenerationError;exports.IdGenerator=_e.IdGenerator;exports.LocalStorage=_e.LocalStorage;exports.MigrationError=_e.MigrationError;exports.StorageError=_e.StorageError;exports.VARIANT_CHARS=_e.VARIANT_CHARS;exports.base36Decode=_e.base36Decode;exports.base36Encode=_e.base36Encode;exports.base58Decode=_e.base58Decode;exports.buildId=_e.buildId;exports.buildPromotionMap=_e.buildPromotionMap;exports.cleanName=_e.cleanName;exports.decodeId=_e.decodeId;exports.decodeIdString=_e.decodeIdString;exports.encodeId=_e.encodeId;exports.extractIdFromUrl=_e.extractIdFromUrl;exports.extractStatus=_e.extractStatus;exports.extractType=_e.extractType;exports.isChapterSegment=_e.isChapterSegment;exports.isTextKey=_e.isTextKey;exports.matchChapterAcrossVersions=_e.matchChapterAcrossVersions;exports.normalizeCatalog=_e.normalizeCatalog;exports.normalizeVariants=_e.normalizeVariants;exports.parseId=_e.parseId;exports.pickTextVersion=_e.pickTextVersion;exports.shardOf=_e.shardOf;exports.smartDecode=_e.smartDecode;exports.textVersionLabel=_e.textVersionLabel;exports.validateResource=_e.validateResource;exports.Badge=mi;exports.BidUrlProvider=lp;exports.BookDetailLayout=Ob;exports.BookPage=Fc;exports.Breadcrumb=vo;exports.CATALOG_ALL_ID=Ct;exports.CATALOG_CSS=Vc;exports.CATALOG_NARROW_QUERY=Tr;exports.CATALOG_PAGE_SIZE=Nr;exports.CATALOG_UNCLASSIFIED_ID=Gt;exports.CLASSIFICATIONS=ji;exports.COMMON_TRADITIONAL_CHARS=Ia;exports.CardFoot=Hn;exports.CatalogPage=yb;exports.CatalogPager=Jc;exports.CatalogTree=Yc;exports.CheckFilter=Ml;exports.Chip=Fl;exports.ChipWall=Qm;exports.CollectionCatalog=Vo;exports.CollectionPage=Dc;exports.CreateEntityDialog=$c;exports.DEFAULT_LAYOUT=Mr;exports.DEFAULT_META_HOME_LINKS=fd;exports.DEFAULT_READER_PREFS=Ko;exports.DEFAULT_READ_HOME_LINKS=ed;exports.DEFAULT_THEME=Ri;exports.DETAIL_CSS=Wl;exports.DYNASTY_GROUPS=yi;exports.Dash=rh;exports.DataTable=th;exports.DetailFooter=ql;exports.DetailGrid=Wn;exports.DetailHeader=Ol;exports.EMPTY_FILTERS=bi;exports.ENTITY_TEXT_CSS=br;exports.EmendatedBySection=il;exports.EmptyNote=uh;exports.EntityDetail=Za;exports.EntityMark=jr;exports.EntityPage=Uc;exports.EntityPickerDialog=zc;exports.EntitySelector=_c;exports.EntityText=jg;exports.ExpandRow=sh;exports.ExtLink=mh;exports.FEEDBACK_FAB_OFFSET_VAR=zo;exports.FILTER_SUPPORT=Fa;exports.FONT_SIZE_STEPS=$t;exports.FactList=qm;exports.FeedbackButton=ax;exports.FeedbackDialog=Ec;exports.FeedbackForm=Ic;exports.FeedbackList=Sr;exports.FeedbackTab=Lc;exports.FilterChip=Hl;exports.FormInput=pt;exports.FormTextArea=Kt;exports.GUJI_MARKDOWN_FIELD=em;exports.GUJI_TABLE_NOTATION=cl;exports.GlyphBadge=ir;exports.GujiInteractiveReader=rf;exports.GujiTable=rr;exports.GujiTextViewer=vr;exports.GujiWarpCanvas=fr;exports.HomePage=$o;exports.ImagePanel=mo;exports.IndexApp=of;exports.IndexBrowser=po;exports.IndexDetail=Uo;exports.IndexEditor=Tc;exports.IndexView=Yf;exports.IntroGrid=Km;exports.LAYOUTS=Ub;exports.LAYOUT_STORAGE_KEY=Li;exports.LOSS_OPTIONS=Ha;exports.LocaleContext=Xt;exports.LocaleProvider=Ap;exports.LocaleToggle=Eo;exports.META_HOME_CSS=gd;exports.META_HOME_SECTION_IDS=Id;exports.MetaCatalogTable=Sd;exports.MetaCollectionGroups=zd;exports.MetaDataLicense=Ed;exports.MetaHomeView=Ib;exports.MetaLine=et;exports.MetaLineageCards=Nd;exports.MetaOnlineSites=Rd;exports.MetaPeopleTimeline=Td;exports.MetaRecentPanel=kd;exports.MetaRelatedCatalogs=$d;exports.MetaTypeChips=yd;exports.ModeIndicator=Ma;exports.MoreButton=Jm;exports.MoreLink=tr;exports.PAGE_MAX_WIDTH=oi;exports.PERIOD_NARROW_SHARE=od;exports.PageFrame=Rn;exports.Quote=lh;exports.READER_CSS=bl;exports.READ_HOME_CSS=Er;exports.READ_HOME_NARROW_QUERY=Un;exports.READ_HOME_SECTION_IDS=hd;exports.READ_PERIOD_LABELS=wb;exports.RECENT_IDS_STORAGE_KEY=ln;exports.ROLE_CLASS_ORDER=Rl;exports.ReadButton=yo;exports.ReadFamousWorks=pd;exports.ReadHomeView=_b;exports.ReadPeriodBand=ud;exports.ReadPicks=ad;exports.ReadPieces=md;exports.ReadSection=st;exports.ReadShelf=Lr;exports.ReadSibu=Ar;exports.ReadStats=sd;exports.ReadTopicGroup=cd;exports.ReadTopics=dd;exports.ReaderMdText=cr;exports.ReaderShell=_l;exports.ReaderToc=jl;exports.RelationPanel=wc;exports.RepoSourceLink=Io;exports.ResourceEditor=lo;exports.ResourceGroup=ch;exports.ResourceLine=dh;exports.ResourceList=Oo;exports.ResourceRow=Yl;exports.SEARCH_VIEW_STORAGE_KEY=Ho;exports.SEVEN_PAVILIONS_KEY=Cd;exports.SNIPPET_MARK_END=za;exports.SNIPPET_MARK_START=Ca;exports.SORTABLE_TYPES=Oa;exports.SearchInput=Wa;exports.SearchResults=Ka;exports.Sec=tt;exports.Section=bt;exports.SectionHead=Xm;exports.SideList=Yt;exports.SmartBidInput=si;exports.SourceEditor=jc;exports.StripWarpRenderer=wo;exports.SummaryCard=On;exports.THEMES=Ld;exports.THEME_INIT_SCRIPT=qb;exports.THEME_STORAGE_KEY=Ei;exports.TRADITIONAL_ALLOWLIST=La;exports.TabFilter=$i;exports.TableHead=nh;exports.TableRow=ih;exports.TagRow=Kl;exports.TagRows=ph;exports.TextButton=Zm;exports.TextReader=wr;exports.ThemeToggle=Zb;exports.TopStrip=jo;exports.VersionLineageGraph=Hc;exports.VersionLineageList=Oc;exports.VersionLineageView=zr;exports.VolumeChips=eh;exports.VolumeLinks=or;exports.WorkCard=Xc;exports.WorkCardGrid=Qc;exports.WorkCatalog=uf;exports.WorkPage=Bc;exports.WorkRow=Zc;exports.adaptCharCord=pf;exports.adaptEntityJson=ac;exports.adaptGujiPages=af;exports.adaptPunctJson=lf;exports.applyLayout=Yb;exports.applyTheme=Md;exports.authorsLine=Ni;exports.bookIndexUriToId=_o;exports.bucketResources=Zo;exports.buildCatalogTree=db;exports.buildCollectionTable=Il;exports.buildLineageGraph=ai;exports.buildMeiliFilter=Jp;exports.buildPageUrl=Wo;exports.buildParagraphBlocks=ec;exports.buildVersionRow=Tl;exports.buildVersionTable=Nl;exports.canParagraphize=pi;exports.catalogNodeIdOf=lb;exports.catalogNodeIdsOf=cb;exports.catalogPageCount=hb;exports.catalogTotal=Rr;exports.classificationPath=Dn;exports.clearAllRecentIds=Fo;exports.compareCatalogCards=mb;exports.computeVersionPartition=Mm;exports.countActiveFilters=vi;exports.createTextApi=ml;exports.currentLayout=Kb;exports.currentTheme=Bd;exports.defaultEntityHref=mc;exports.defaultWorkLink=Kc;exports.deriveDating=Lm;exports.deriveEditionType=Al;exports.deriveEra=Bn;exports.deriveYear=wi;exports.deriveYearRange=Xo;exports.detailToEditor=Rc;exports.detectGenre=zi;exports.displayAuthorRole=Qo;exports.editorToDetail=Gf;exports.eraRank=xo;exports.filtersFromParams=Qp;exports.filtersToParams=li;exports.findCatalogPath=an;exports.findTraditionalChars=Bp;exports.firstAuthorText=Ir;exports.flattenTitles=ko;exports.flattenToc=Sl;exports.fmtCount=Ye;exports.formatHitCount=ii;exports.formatTemplate=ut;exports.formatVolumeRange=_i;exports.getDisplayNameFromUrl=hn;exports.getMessages=un;exports.getStartPage=Bo;exports.getT=mn;exports.getTypeGroupKey=Po;exports.groupRelatedWorks=Am;exports.gujiInlineToPlain=ll;exports.hasActiveFilters=Da;exports.hasGujiMarkdownV02=uo;exports.hasGujiTableNotation=dl;exports.hasSearchOptions=qp;exports.iiifVolumeOf=cf;exports.isCountedChar=xr;exports.isLayoutName=Wd;exports.isThemeName=Ad;exports.lineageHref=xd;exports.loadRecentIds=Pt;exports.measureText=Nt;exports.mergeVolumeResources=Mo;exports.normalizeEra=Qe;exports.normalizeLayout=Ai;exports.normalizeRole=Jo;exports.normalizeTheme=Ii;exports.normalizeVolumeIndex=Ln;exports.normalizeVolumes=Pa;exports.numberToChinese=Ll;exports.paginationItems=Gc;exports.parseChineseNumber=ci;exports.parseGujiInline=al;exports.parseGujiTable=ul;exports.parseSourceString=vc;exports.pct=Pr;exports.periodLevel=id;exports.pickReaderVersion=wl;exports.readStoredLayout=Vb;exports.readStoredTheme=Db;exports.readerVersionOptionLabel=go;exports.remapPlainOffsets=lc;exports.removeRecentId=qa;exports.renderFullTextBody=yh;exports.renderProperNames=nc;exports.renderReaderInline=lr;exports.resolveRecentEntry=Do;exports.resourceHref=gn;exports.resourceNote=Si;exports.resultTabFromParam=cu;exports.resultTabToParam=du;exports.roleFacets=El;exports.rowNo=oh;exports.sameFilters=eu;exports.saveRecentId=co;exports.segmentEntities=cc;exports.shelfColumns=td;exports.sortFor=Xp;exports.sortYear=di;exports.spineHeight=nd;exports.splitFullTextTables=Go;exports.splitHighlightSnippet=Lo;exports.splitTableRow=pl;exports.storeLayout=Gb;exports.storeTheme=Pd;exports.stringifySources=kc;exports.summaryFromEntry=pc;exports.summaryFromItem=dc;exports.timelineLayout=bd;exports.toCatalogWorkCard=ub;exports.transportSummaryLoader=uc;exports.typeSupportsFilters=Ua;exports.useBidUrl=Ze;exports.useChapterWarpData=fc;exports.useConvert=Le;exports.useEntitySummaryLoader=yr;exports.useI18n=J;exports.useReaderPrefs=kl;exports.useRecentEntries=jd;exports.useT=Te;exports.validateLineageGraph=Nx;exports.volumeStats=fi;exports.withDefaultLinks=Mt;exports.withMetaLinks=Bt;exports.yearText=hi;
|