book-index-ui 0.48.2 → 0.48.4
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 +27 -27
- package/dist/index.d.ts +5 -18
- package/dist/index.js +1571 -1571
- package/dist/{storage-entry-BFVAZmvt.cjs → storage-entry-BNx9e7zn.cjs} +2 -2
- package/dist/{storage-entry-DQ9kOLVb.js → storage-entry-BdyLwZMZ.js} +172 -161
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.ts +5 -2
- package/dist/storage.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ip=Object.create;var Qr=Object.defineProperty;var op=Object.getOwnPropertyDescriptor;var rp=Object.getOwnPropertyNames;var sp=Object.getPrototypeOf,ap=Object.prototype.hasOwnProperty;var lp=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of rp(n))!ap.call(e,s)&&s!==o&&Qr(e,s,{get:()=>n[s],enumerable:!(r=op(n,s))||r.enumerable});return e};var Jn=(e,n,o)=>(o=e!=null?ip(sp(e)):{},lp(n||!e||!e.__esModule?Qr(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Se=require("./storage-entry-BFVAZmvt.cjs"),t=require("react/jsx-runtime"),h=require("react"),cp=require("opencc-js/t2cn"),dp=require("react-markdown"),pp=require("remark-gfm"),up=e=>`/book-index?id=${e}`,Na=h.createContext(up);function mp({buildUrl:e,children:n}){const o=h.useMemo(()=>e,[e]);return t.jsx(Na.Provider,{value:o,children:n})}function tt(){return h.useContext(Na)}const Ra="",Ea="";function Mo(e){const n=[];let o=!1,r=e;for(;r.length;){const s=o?Ea:Ra,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 lt(e,n){return{title:e,tokens:n}}const es='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',gp=[lt("基础(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"}}),lt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),lt("提示与警告",{"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)"}}),lt("遮罩与阴影",{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)"}}),lt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),lt("资源",{"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"}}),lt("整理本(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"}}),lt("版本传承(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"}}),lt("编辑器视图(主要在 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")'}}),lt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),lt('版式(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"}}),lt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"reader-warm":{value:"#c9a24a",note:"阅读设置侧栏的暖黄:只做底色(8%)与选中态(24%),与朱/靛/墨三套主色都不冲"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),lt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),lt("字体(全站无衬线,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:es,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:es,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],hp=Object.assign({},...gp.map(e=>e.tokens)),Ia={};for(const[e,n]of Object.entries(hp))Ia[e]=`var(--bim-${e}, ${n.value})`;function i(e){const n=Ia[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 fp(e,n){return Qt(e).includes(n)}const xp={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const en=h.createContext(null),La=["曹霑"];function bp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yp(e,n=La){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(bp).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 wn=null;function jp(){if(wn)return wn;try{const e=cp.Converter({from:"t",to:"cn"});wn=yp(n=>e(Se.normalizeVariants(n)))}catch{wn=e=>e}return wn}const vp={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:"圖片資源"}},kp={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 dt(e,n,o){return{"zh-Hant":e,"zh-Hans":n}}const wp=dt({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官名",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官名",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),fi=dt({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:"作品信息"}),Sp=dt({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:"附记"}}),_p=dt({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}"}}),$p=dt({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:"上级丛编"}),Cp=dt({subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官名",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官名",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对"}),zp=dt({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",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:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",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:"参考文献"}),Tp=dt({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:"本卷条目"}),Np=dt({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:"规模、存佚、许可与版本"}),Bo=dt({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:"按作者浏览全部 →"}),Rp=dt({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} 条"}),Ep=dt({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:"搜索"}),Ip=dt({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:"回复"}),Lp=dt({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:"有争议"}}),Ap={common:wp,detail:fi,bookPage:Sp,workPage:_p,collectionPage:$p,entityPage:Cp,reader:zp,collated:Tp,metaHome:Np,readHome:Bo,catalogPage:Rp,searchPage:Ep,feedback:Ip,lineage:Lp};function Pp(e){const n={};for(const[o,r]of Object.entries(Ap))n[o]=r[e];return n}function ht(e,n){return e.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const ts=new Map;function hn(e){let n=ts.get(e);return n||(n={...e==="zh-Hans"?kp:vp,...Pp(e)},ts.set(e,n)),n}function ns(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 Aa(e){return(n,o)=>{const r=ns(e,n)??ns(hn("zh-Hant"),n)??n;return o?ht(r,o):r}}const is=new Map;function fn(e){let n=is.get(e);return n||(n=Aa(hn(e)),is.set(e,n)),n}const Pa="bim-locale";function Mp(){try{const e=localStorage.getItem(Pa);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Bp(e){try{localStorage.setItem(Pa,e)}catch{}}const Wp="zh-Hans",Op=({locale:e,onLocaleChange:n,converter:o,children:r})=>{const[s,a]=h.useState(e??Wp),l=e??s;h.useEffect(()=>{if(e)return;const u=Mp();u&&u!==s&&a(u)},[]);const d=h.useMemo(()=>l==="zh-Hans"?o??jp():null,[l,o]),c=h.useCallback(u=>{a(u),Bp(u),n==null||n(u)},[n]),p=h.useMemo(()=>({locale:l,setLocale:c,messages:hn(l),converter:d}),[l,c,d]);return t.jsx(en.Provider,{value:p,children:r})};function Ce(){const e=h.useContext(en);return(e==null?void 0:e.messages)??hn("zh-Hant")}const Fp=2e3;function Ae(){const e=h.useContext(en),n=(e==null?void 0:e.locale)??"zh-Hant",o=(e==null?void 0:e.converter)??null,r=h.useRef(new Map),s=h.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const a=h.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>=Fp){const p=r.current.keys().next().value;p!==void 0&&r.current.delete(p)}return r.current.set(l,c),c},[o]);return h.useMemo(()=>({convert:a,locale:n,isSimplified:n==="zh-Hans"}),[a,n])}function ee(){const e=h.useContext(en),{convert:n,locale:o,isSimplified:r}=Ae(),s=(e==null?void 0:e.messages)??hn("zh-Hant"),a=h.useMemo(()=>e?Aa(s):fn("zh-Hant"),[e,s]);return h.useMemo(()=>({t:a,convert:n,locale:o,isSimplified:r,messages:s}),[a,n,o,r,s])}const Ma=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Hp=new Set([...Ma,...Object.keys(Se.VARIANT_CHARS)]),Ba=[...La,"切換為繁體","漢籍リポジトリ"];function Dp(e,n=Ba){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)=>{Hp.has(a)&&r.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),r}function Up(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 Vp(){return{id:"",name:"",url:"",type:"text",details:""}}const uo=({items:e,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const a=Ce(),[l,d]=h.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)),g=()=>{const b=Vp();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 $=Up(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:Gp(b.type??"text"),color:i("on-color-fg")},children:(()=>{var z,P;const _=Qt(b);return _.length===0?b.type??"text":_.length===1?((z=c.find(N=>N.value===_[0]))==null?void 0:z.label)??_[0]:_.includes("text")&&_.includes("image")?((P=c.find(N=>N.value==="text+image"))==null?void 0:P.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&&Yp(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:[fp(b,"image")&&b.url&&Kp(b,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.type}),t.jsx("select",{value:b.type,onChange:_=>x(j,"type",_.target.value),style:{..._t,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.rootType}),t.jsx("select",{value:b.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{..._t,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:b.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{..._t,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:b.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{..._t,flex:1}})]}),t.jsx("input",{type:"text",value:b.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:_t}),t.jsx("input",{type:"text",value:((S=b.structure)==null?void 0:S.join("、"))||"",onChange:_=>y(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:_t}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,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:{..._t,width:"60px"}})]}),t.jsxs("label",{style:{...Sn,flex:1},children:[t.jsx("span",{style:_n,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:{..._t,flex:1}})]})]}),t.jsx("textarea",{value:b.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{..._t,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(([_,z])=>{var P;return t.jsxs("label",{style:{...Sn,gap:"4px"},children:[t.jsx("span",{style:{..._n,minWidth:"56px"},children:z}),t.jsx("input",{type:"text",value:((P=b.metadata)==null?void 0:P[_])||"",onChange:N=>k(j,_,N.target.value),placeholder:z,style:{..._t,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:g,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 Gp(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 Yp(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 Kp(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 _t={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"},Sn={display:"flex",alignItems:"center",gap:"6px"},_n={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},qp={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃","www.shidianguji.com":"識典古籍","shidianguji.com":"識典古籍","archive.org":"Internet Archive","www.shuge.org":"書格","shuge.org":"書格","pan.baidu.com":"百度網盤"};function xn(e){try{return qp[new URL(e).hostname]}catch{return}}const os={text:0,image:1,physical:2};function Wo(e){return e.length===0?"physical":[...e].sort((n,o)=>(os[n]??99)-(os[o]??99)).join("+")}function Oo(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,g=`${u}|${Wo(Qt(c))}`;o.has(g)||o.set(g,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const f=o.get(g);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 Wa(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 Oa(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||Wa(n)}))}function xi(e){const n=Oa(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 Fo(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 Ho(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 bn(e){if(!e.url)return;const n=Fo(e.metadata);return n?Ho(e.url,n):e.url}const rs={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function Xp(e){return e.includes("text")&&e.includes("image")?rs["text+image"]:rs[e[0]||"physical"]}const Do=({items:e,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const a=Ce(),{convert:l}=Ae(),d=h.useMemo(()=>Oo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=h.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(Yi,{item:y},y.id||w))});const g=(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(Yi,{item:v,onNavigate:r,renderLink:s},v.id||$))})]},`group-${y}`)},f=new Map;for(const y of p){const w=Wo(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])=>g(y,w)),k.map(y=>{const w=f.get(y),b=Xp(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(Yi,{item:j,onNavigate:r,renderLink:s},j.id||S))})]},y)})]})},Zp={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Yi=({item:e})=>{const n=Ce(),{convert:o}=Ae(),[r,s]=h.useState(!1),a=h.useMemo(()=>(e.url?xn(e.url):void 0)||o(e.name),[e.url,e.name,o]),l=h.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||Wa(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?{...Zp[e.color_mode],label:n.colorMode[e.color_mode]}:null,g=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}),g&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:g}),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:ht(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Fo(e.metadata);return x?Ho(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)})})]})},Fa=({indexSource:e,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ce(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",m=u?u.split(/[/\\]/).pop()||u:"",g={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:{...g,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:g,...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:{...g,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:g,...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:{...g,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:g,...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:{...g,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:{...g,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})]})]})},bi="bim-search-history",ss=10,as=8;function In(){try{const e=localStorage.getItem(bi);return e?JSON.parse(e):[]}catch{return[]}}function Ha(e){try{const n=In().filter(o=>o!==e);n.unshift(e),n.length>ss&&(n.length=ss),localStorage.setItem(bi,JSON.stringify(n))}catch{}}function Jp(e){try{const n=In().filter(o=>o!==e);localStorage.setItem(bi,JSON.stringify(n))}catch{}}function Qp(){try{localStorage.removeItem(bi)}catch{}}const Da=({transport:e,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:a})=>{const l=Ce(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,u]=h.useState(!1),[m,g]=h.useState([]),[f,x]=h.useState(-1),[k,y]=h.useState(In),w=h.useRef(null),b=h.useRef(null),j=h.useRef(null),S=h.useRef(!1);h.useEffect(()=>{x(-1);const T=n.trim();if(!T){g(k.map(E=>({type:"history",text:E})));return}if(!e.searchAll){g([]);return}let D=!1;const R=setTimeout(()=>{e.searchAll(T,as).then(E=>{if(D)return;const L=[...E.works,...E.books,...E.collections,...E.entities??[]];g(L.slice(0,as).map(I=>({type:"entry",text:I.title||I.id,entry:I})))}).catch(()=>{D||g([])})},80);return()=>{D=!0,clearTimeout(R)}},[n,k,e]),h.useEffect(()=>{const T=D=>{j.current&&!j.current.contains(D.target)&&u(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),h.useEffect(()=>{const T=D=>{var R,E;if(D.key==="/"&&document.activeElement!==w.current){const L=(R=document.activeElement)==null?void 0:R.tagName;if(L==="INPUT"||L==="TEXTAREA"||L==="SELECT")return;D.preventDefault(),(E=w.current)==null||E.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const v=h.useCallback(T=>{T.trim()&&(Ha(T.trim()),y(In())),r(T),u(!1)},[r]),$=h.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]),_=h.useCallback(T=>{if(!p||m.length===0){T.key==="Enter"&&v(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(D=>(D+1)%m.length);break;case"ArrowUp":T.preventDefault(),x(D=>(D-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,$]),z=h.useCallback((T,D)=>{D.stopPropagation(),Jp(T),y(In()),g(R=>R.filter(E=>!(E.type==="history"&&E.text===T)))},[]),P=h.useCallback(T=>{T.stopPropagation(),Qp(),y([]),g([])},[]);h.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:P,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((T,D)=>t.jsxs("div",{onClick:()=>$(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:D===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=>z(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}-${D}`))]})]})},yn=({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"}}),yi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Ua=new Set(["work","book","entity"]);function eu(e){return Ya(e)||!!e.sort}function tu(e,n){return n.sort&&Ua.has(e)?n.sort:void 0}const ji=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],vi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Va=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Ga={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function ki(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 Ya(e){return ki(e)>0}function nu(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 Ka(e,n){const o=Ga[e];return nu(n).every(r=>o.has(r))}const $n=e=>JSON.stringify(e);function iu(e,n){if(!Ka(n,e))return null;const o=[];if(e.dynasty.length){const r=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=ji.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 st={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},qa="_";function ci(e,n=new URLSearchParams){for(const o of Object.values(st))n.delete(o);return e.dynasty.length&&n.set(st.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(st.classification,e.classification.map(o=>o||qa).join(",")),e.hasImage&&n.set(st.hasImage,"1"),e.hasText&&n.set(st.hasText,"1"),e.hasCollated&&n.set(st.hasCollated,"1"),e.loss&&n.set(st.loss,e.loss),e.sort&&n.set(st.sort,e.sort),n}function ou(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),o=new Set(ji.map(a=>a.key)),r=new Set(vi.map(a=>a.value)),s=e.get(st.loss);return{dynasty:Array.from(new Set(n(st.dynasty).filter(a=>o.has(a)))),classification:Array.from(new Set(n(st.classification).map(a=>a===qa?"":a).filter(a=>r.has(a)))),hasImage:e.get(st.hasImage)==="1",hasText:e.get(st.hasText)==="1"||e.get(st.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(st.sort))??""}}function ru(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 ls(e,n){return e.includes(n)?e.filter(o=>o!==n):[...e,n]}const su=({filters:e,onChange:n})=>{const o=Ce(),r=o.searchV4,{convert:s}=Ae(),[a,l]=h.useState(!1),d=h.useId(),c=ki(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(ht(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:ji.map(u=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(u.key),onClick:()=>p({dynasty:ls(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)}),vi.map(u=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(u.value),onChange:()=>p({classification:ls(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:Va.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({...yi,sort:e.sort}),children:s(r.clearAllFilters)})]})]})};function Xa({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 cs=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=Ce(),a=s.searchV4,{convert:l}=Ae(),d=tt();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)}`:""}`:"",g=c.type==="book"?c.era??c.dynasty:c.dynasty,f=g?l(g):"",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(Xa,{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(yn,{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)})})]})})},au=`
|
|
1
|
+
"use strict";var ip=Object.create;var Qr=Object.defineProperty;var op=Object.getOwnPropertyDescriptor;var rp=Object.getOwnPropertyNames;var sp=Object.getPrototypeOf,ap=Object.prototype.hasOwnProperty;var lp=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of rp(n))!ap.call(e,s)&&s!==o&&Qr(e,s,{get:()=>n[s],enumerable:!(r=op(n,s))||r.enumerable});return e};var Jn=(e,n,o)=>(o=e!=null?ip(sp(e)):{},lp(n||!e||!e.__esModule?Qr(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _e=require("./storage-entry-BNx9e7zn.cjs"),t=require("react/jsx-runtime"),h=require("react"),cp=require("opencc-js/t2cn"),dp=require("react-markdown"),pp=require("remark-gfm"),up=e=>`/book-index?id=${e}`,Na=h.createContext(up);function mp({buildUrl:e,children:n}){const o=h.useMemo(()=>e,[e]);return t.jsx(Na.Provider,{value:o,children:n})}function tt(){return h.useContext(Na)}const Ra="",Ea="";function Mo(e){const n=[];let o=!1,r=e;for(;r.length;){const s=o?Ea:Ra,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 lt(e,n){return{title:e,tokens:n}}const es='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',gp=[lt("基础(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"}}),lt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),lt("提示与警告",{"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)"}}),lt("遮罩与阴影",{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)"}}),lt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),lt("资源",{"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"}}),lt("整理本(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"}}),lt("版本传承(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"}}),lt("编辑器视图(主要在 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")'}}),lt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),lt('版式(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"}}),lt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"reader-warm":{value:"#c9a24a",note:"阅读设置侧栏的暖黄:只做底色(8%)与选中态(24%),与朱/靛/墨三套主色都不冲"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),lt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),lt("字体(全站无衬线,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:es,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:es,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],hp=Object.assign({},...gp.map(e=>e.tokens)),Ia={};for(const[e,n]of Object.entries(hp))Ia[e]=`var(--bim-${e}, ${n.value})`;function i(e){const n=Ia[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 fp(e,n){return Qt(e).includes(n)}const xp={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const en=h.createContext(null),La=["曹霑"];function bp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yp(e,n=La){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(bp).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 wn=null;function jp(){if(wn)return wn;try{const e=cp.Converter({from:"t",to:"cn"});wn=yp(n=>e(_e.normalizeVariants(n)))}catch{wn=e=>e}return wn}const vp={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:"圖片資源"}},kp={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 dt(e,n,o){return{"zh-Hant":e,"zh-Hans":n}}const wp=dt({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官名",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官名",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),fi=dt({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:"作品信息"}),Sp=dt({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:"附记"}}),_p=dt({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}"}}),$p=dt({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:"上级丛编"}),Cp=dt({subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官名",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官名",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对"}),zp=dt({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",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:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",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:"参考文献"}),Tp=dt({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:"本卷条目"}),Np=dt({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:"规模、存佚、许可与版本"}),Bo=dt({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:"按作者浏览全部 →"}),Rp=dt({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} 条"}),Ep=dt({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:"搜索"}),Ip=dt({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:"回复"}),Lp=dt({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:"有争议"}}),Ap={common:wp,detail:fi,bookPage:Sp,workPage:_p,collectionPage:$p,entityPage:Cp,reader:zp,collated:Tp,metaHome:Np,readHome:Bo,catalogPage:Rp,searchPage:Ep,feedback:Ip,lineage:Lp};function Pp(e){const n={};for(const[o,r]of Object.entries(Ap))n[o]=r[e];return n}function ht(e,n){return e.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const ts=new Map;function hn(e){let n=ts.get(e);return n||(n={...e==="zh-Hans"?kp:vp,...Pp(e)},ts.set(e,n)),n}function ns(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 Aa(e){return(n,o)=>{const r=ns(e,n)??ns(hn("zh-Hant"),n)??n;return o?ht(r,o):r}}const is=new Map;function fn(e){let n=is.get(e);return n||(n=Aa(hn(e)),is.set(e,n)),n}const Pa="bim-locale";function Mp(){try{const e=localStorage.getItem(Pa);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Bp(e){try{localStorage.setItem(Pa,e)}catch{}}const Wp="zh-Hans",Op=({locale:e,onLocaleChange:n,converter:o,children:r})=>{const[s,a]=h.useState(e??Wp),l=e??s;h.useEffect(()=>{if(e)return;const u=Mp();u&&u!==s&&a(u)},[]);const d=h.useMemo(()=>l==="zh-Hans"?o??jp():null,[l,o]),c=h.useCallback(u=>{a(u),Bp(u),n==null||n(u)},[n]),p=h.useMemo(()=>({locale:l,setLocale:c,messages:hn(l),converter:d}),[l,c,d]);return t.jsx(en.Provider,{value:p,children:r})};function Ce(){const e=h.useContext(en);return(e==null?void 0:e.messages)??hn("zh-Hant")}const Fp=2e3;function Pe(){const e=h.useContext(en),n=(e==null?void 0:e.locale)??"zh-Hant",o=(e==null?void 0:e.converter)??null,r=h.useRef(new Map),s=h.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const a=h.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>=Fp){const p=r.current.keys().next().value;p!==void 0&&r.current.delete(p)}return r.current.set(l,c),c},[o]);return h.useMemo(()=>({convert:a,locale:n,isSimplified:n==="zh-Hans"}),[a,n])}function Q(){const e=h.useContext(en),{convert:n,locale:o,isSimplified:r}=Pe(),s=(e==null?void 0:e.messages)??hn("zh-Hant"),a=h.useMemo(()=>e?Aa(s):fn("zh-Hant"),[e,s]);return h.useMemo(()=>({t:a,convert:n,locale:o,isSimplified:r,messages:s}),[a,n,o,r,s])}const Ma=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),Hp=new Set([...Ma,...Object.keys(_e.VARIANT_CHARS)]),Ba=[...La,"切換為繁體","漢籍リポジトリ"];function Dp(e,n=Ba){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)=>{Hp.has(a)&&r.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),r}function Up(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 Vp(){return{id:"",name:"",url:"",type:"text",details:""}}const uo=({items:e,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const a=Ce(),[l,d]=h.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)),g=()=>{const b=Vp();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 $=Up(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:Gp(b.type??"text"),color:i("on-color-fg")},children:(()=>{var z,P;const _=Qt(b);return _.length===0?b.type??"text":_.length===1?((z=c.find(N=>N.value===_[0]))==null?void 0:z.label)??_[0]:_.includes("text")&&_.includes("image")?((P=c.find(N=>N.value==="text+image"))==null?void 0:P.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&&Yp(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:[fp(b,"image")&&b.url&&Kp(b,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.type}),t.jsx("select",{value:b.type,onChange:_=>x(j,"type",_.target.value),style:{..._t,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,children:a.label.rootType}),t.jsx("select",{value:b.root_type||"catalog",onChange:_=>x(j,"root_type",_.target.value),style:{..._t,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:b.id,onChange:_=>x(j,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{..._t,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:b.name,onChange:_=>x(j,"name",_.target.value),placeholder:a.editor.resourceName,style:{..._t,flex:1}})]}),t.jsx("input",{type:"text",value:b.url,onChange:_=>x(j,"url",_.target.value),placeholder:a.editor.resourceUrl,style:_t}),t.jsx("input",{type:"text",value:((S=b.structure)==null?void 0:S.join("、"))||"",onChange:_=>y(j,_.target.value),placeholder:a.editor.structurePlaceholder,style:_t}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Sn,children:[t.jsx("span",{style:_n,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:{..._t,width:"60px"}})]}),t.jsxs("label",{style:{...Sn,flex:1},children:[t.jsx("span",{style:_n,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:{..._t,flex:1}})]})]}),t.jsx("textarea",{value:b.details||"",onChange:_=>x(j,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{..._t,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(([_,z])=>{var P;return t.jsxs("label",{style:{...Sn,gap:"4px"},children:[t.jsx("span",{style:{..._n,minWidth:"56px"},children:z}),t.jsx("input",{type:"text",value:((P=b.metadata)==null?void 0:P[_])||"",onChange:N=>k(j,_,N.target.value),placeholder:z,style:{..._t,flex:1}})]},_)})})]})]})]})]},j)}),t.jsxs("button",{onClick:g,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 Gp(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 Yp(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 Kp(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 _t={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"},Sn={display:"flex",alignItems:"center",gap:"6px"},_n={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},qp={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃","www.shidianguji.com":"識典古籍","shidianguji.com":"識典古籍","archive.org":"Internet Archive","www.shuge.org":"書格","shuge.org":"書格","pan.baidu.com":"百度網盤"};function xn(e){try{return qp[new URL(e).hostname]}catch{return}}const os={text:0,image:1,physical:2};function Wo(e){return e.length===0?"physical":[...e].sort((n,o)=>(os[n]??99)-(os[o]??99)).join("+")}function Oo(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,g=`${u}|${Wo(Qt(c))}`;o.has(g)||o.set(g,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const f=o.get(g);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 Wa(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 Oa(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||Wa(n)}))}function xi(e){const n=Oa(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 Fo(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 Ho(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 bn(e){if(!e.url)return;const n=Fo(e.metadata);return n?Ho(e.url,n):e.url}const rs={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function Xp(e){return e.includes("text")&&e.includes("image")?rs["text+image"]:rs[e[0]||"physical"]}const Do=({items:e,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const a=Ce(),{convert:l}=Pe(),d=h.useMemo(()=>Oo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=h.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(Yi,{item:y},y.id||w))});const g=(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(Yi,{item:v,onNavigate:r,renderLink:s},v.id||$))})]},`group-${y}`)},f=new Map;for(const y of p){const w=Wo(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])=>g(y,w)),k.map(y=>{const w=f.get(y),b=Xp(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(Yi,{item:j,onNavigate:r,renderLink:s},j.id||S))})]},y)})]})},Zp={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Yi=({item:e})=>{const n=Ce(),{convert:o}=Pe(),[r,s]=h.useState(!1),a=h.useMemo(()=>(e.url?xn(e.url):void 0)||o(e.name),[e.url,e.name,o]),l=h.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||Wa(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?{...Zp[e.color_mode],label:n.colorMode[e.color_mode]}:null,g=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}),g&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:g}),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:ht(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=Fo(e.metadata);return x?Ho(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)})})]})},Fa=({indexSource:e,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Ce(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",m=u?u.split(/[/\\]/).pop()||u:"",g={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:{...g,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:g,...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:{...g,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:g,...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:{...g,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:g,...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:{...g,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:{...g,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})]})]})},bi="bim-search-history",ss=10,as=8;function In(){try{const e=localStorage.getItem(bi);return e?JSON.parse(e):[]}catch{return[]}}function Ha(e){try{const n=In().filter(o=>o!==e);n.unshift(e),n.length>ss&&(n.length=ss),localStorage.setItem(bi,JSON.stringify(n))}catch{}}function Jp(e){try{const n=In().filter(o=>o!==e);localStorage.setItem(bi,JSON.stringify(n))}catch{}}function Qp(){try{localStorage.removeItem(bi)}catch{}}const Da=({transport:e,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:a})=>{const l=Ce(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,u]=h.useState(!1),[m,g]=h.useState([]),[f,x]=h.useState(-1),[k,y]=h.useState(In),w=h.useRef(null),b=h.useRef(null),j=h.useRef(null),S=h.useRef(!1);h.useEffect(()=>{x(-1);const T=n.trim();if(!T){g(k.map(E=>({type:"history",text:E})));return}if(!e.searchAll){g([]);return}let D=!1;const R=setTimeout(()=>{e.searchAll(T,as).then(E=>{if(D)return;const L=[...E.works,...E.books,...E.collections,...E.entities??[]];g(L.slice(0,as).map(I=>({type:"entry",text:I.title||I.id,entry:I})))}).catch(()=>{D||g([])})},80);return()=>{D=!0,clearTimeout(R)}},[n,k,e]),h.useEffect(()=>{const T=D=>{j.current&&!j.current.contains(D.target)&&u(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),h.useEffect(()=>{const T=D=>{var R,E;if(D.key==="/"&&document.activeElement!==w.current){const L=(R=document.activeElement)==null?void 0:R.tagName;if(L==="INPUT"||L==="TEXTAREA"||L==="SELECT")return;D.preventDefault(),(E=w.current)==null||E.focus()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[]);const v=h.useCallback(T=>{T.trim()&&(Ha(T.trim()),y(In())),r(T),u(!1)},[r]),$=h.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]),_=h.useCallback(T=>{if(!p||m.length===0){T.key==="Enter"&&v(n);return}switch(T.key){case"ArrowDown":T.preventDefault(),x(D=>(D+1)%m.length);break;case"ArrowUp":T.preventDefault(),x(D=>(D-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,$]),z=h.useCallback((T,D)=>{D.stopPropagation(),Jp(T),y(In()),g(R=>R.filter(E=>!(E.type==="history"&&E.text===T)))},[]),P=h.useCallback(T=>{T.stopPropagation(),Qp(),y([]),g([])},[]);h.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:P,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((T,D)=>t.jsxs("div",{onClick:()=>$(T),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:D===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=>z(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}-${D}`))]})]})},yn=({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"}}),yi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Ua=new Set(["work","book","entity"]);function eu(e){return Ya(e)||!!e.sort}function tu(e,n){return n.sort&&Ua.has(e)?n.sort:void 0}const ji=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],vi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Va=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Ga={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function ki(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 Ya(e){return ki(e)>0}function nu(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 Ka(e,n){const o=Ga[e];return nu(n).every(r=>o.has(r))}const $n=e=>JSON.stringify(e);function iu(e,n){if(!Ka(n,e))return null;const o=[];if(e.dynasty.length){const r=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=ji.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 st={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},qa="_";function ci(e,n=new URLSearchParams){for(const o of Object.values(st))n.delete(o);return e.dynasty.length&&n.set(st.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(st.classification,e.classification.map(o=>o||qa).join(",")),e.hasImage&&n.set(st.hasImage,"1"),e.hasText&&n.set(st.hasText,"1"),e.hasCollated&&n.set(st.hasCollated,"1"),e.loss&&n.set(st.loss,e.loss),e.sort&&n.set(st.sort,e.sort),n}function ou(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),o=new Set(ji.map(a=>a.key)),r=new Set(vi.map(a=>a.value)),s=e.get(st.loss);return{dynasty:Array.from(new Set(n(st.dynasty).filter(a=>o.has(a)))),classification:Array.from(new Set(n(st.classification).map(a=>a===qa?"":a).filter(a=>r.has(a)))),hasImage:e.get(st.hasImage)==="1",hasText:e.get(st.hasText)==="1"||e.get(st.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(st.sort))??""}}function ru(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 ls(e,n){return e.includes(n)?e.filter(o=>o!==n):[...e,n]}const su=({filters:e,onChange:n})=>{const o=Ce(),r=o.searchV4,{convert:s}=Pe(),[a,l]=h.useState(!1),d=h.useId(),c=ki(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(ht(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:ji.map(u=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(u.key),onClick:()=>p({dynasty:ls(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)}),vi.map(u=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(u.value),onChange:()=>p({classification:ls(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:Va.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({...yi,sort:e.sort}),children:s(r.clearAllFilters)})]})]})};function Xa({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 cs=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=Ce(),a=s.searchV4,{convert:l}=Pe(),d=tt();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)}`:""}`:"",g=c.type==="book"?c.era??c.dynasty:c.dynasty,f=g?l(g):"",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(Xa,{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(yn,{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)})})]})})},au=`
|
|
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
|
-
`,ds=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=Ce(),a=s.searchV4,{convert:l}=
|
|
15
|
+
`,ds=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=Ce(),a=s.searchV4,{convert:l}=Pe(),d=tt();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:au}),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}`:"",g=[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(Xa,{text:p,query:n?l(n):void 0})}),g&&t.jsx("span",{className:"bim-sc-m",children:g}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:Mo(c.descriptionSnippet).map((k,y)=>k.marked?t.jsx("mark",{children:l(k.text)},y):t.jsx(h.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 lu(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 cu(e,n,o){const r=Math.max(1,Math.ceil(n/o));return Math.min(Math.max(1,e),r)}const du=({page:e,pageSize:n,total:o,totalLabel:r,onPage:s})=>{const a=Ce().searchV4,{convert:l}=Pe(),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(ht(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)})}),lu(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)})})]})]})},Za="(max-width: 719px)",pu=`${Za}, (pointer: coarse)`,uu=`
|
|
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; }
|
|
@@ -117,7 +117,7 @@
|
|
|
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
|
-
`,Uo="bim-search-view",Ki=50,ps=5,Ln=1e3;function oi(e){return e>=Ln?`${Ln.toLocaleString()}+`:e.toLocaleString()}const mu={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function gu(e){return e&&mu[e.toLowerCase()]||"all"}function hu(e){return e==="all"?null:e}const us=["work","collection","book","entity"],fu={work:"works",collection:"collections",book:"books",entity:"entities"},xu={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function bu(){try{return window.localStorage.getItem(Uo)==="card"?"card":"table"}catch{return"table"}}function yu(e){try{window.localStorage.setItem(Uo,e)}catch{}}const sn=(e,n)=>(e==null?void 0:e[xu[n]])??0,qi=(e,n)=>(e==null?void 0:e[fu[n]])??[],Ja=({transport:e,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const u=Ce(),m=u.searchV4,{convert:g}=Ae(),f=!!e.supportsSearchFilters,x=h.useMemo(()=>f?o:yi,[f,o]),[k,y]=h.useState("table");h.useEffect(()=>{y(bu())},[]);const w=X=>{y(X),yu(X)},[b,j]=h.useState(l??"all"),S=h.useRef(b);S.current=b,h.useEffect(()=>{l!==void 0&&l!==S.current&&(j(l),$(1))},[l]);const[v,$]=h.useState(c&&c>0?c:1),_=h.useRef(v);_.current=v,h.useEffect(()=>{c!==void 0&&c>0&&c!==_.current&&$(c)},[c]);const z=h.useRef(null),P=h.useCallback(X=>{var le;$(X),p==null||p(X);const ae=z.current;ae&&ae.getBoundingClientRect().top<0&&((le=ae.scrollIntoView)==null||le.call(ae,{block:"start",behavior:"instant"}))},[p]),[N,T]=h.useState(null),[D,R]=h.useState(null),[E,L]=h.useState(!1),[I,A]=h.useState(""),V=ci(x).toString(),q=ki(x)>0,U=ci({...x,sort:""}).toString(),O=h.useRef({query:n,filterOnlyKey:U,sort:x.sort});h.useEffect(()=>{const X=O.current;X.query!==n||X.filterOnlyKey!==U?(j("all"),$(1)):X.sort!==x.sort&&$(1),O.current={query:n,filterOnlyKey:U,sort:x.sort}},[n,U,x.sort]),h.useEffect(()=>{let X=!1;return L(!0),A(""),(async()=>{try{let ae;if(e.searchAll)ae=await e.searchAll(n,ps,x);else{const le=["work","book","collection","entity"],ke=await Promise.all(le.map(H=>e.search(n,H,{page:1,pageSize:ps,filters:x})));ae={works:ke[0].entries,books:ke[1].entries,collections:ke[2].entries,entities:ke[3].entries,totalWorks:ke[0].total,totalBooks:ke[1].total,totalCollections:ke[2].total,totalEntities:ke[3].total}}X||T(ae)}catch(ae){X||(A(ae instanceof Error?ae.message:String(ae)),T(null))}finally{X||L(!1)}})(),()=>{X=!0}},[e,n,V]);const K=b;h.useEffect(()=>{if(b==="all"){R(null);return}let X=!1;return L(!0),(async()=>{try{const ae=await e.search(n,b,{page:v,pageSize:Ki,filters:x});X||R({key:K,entries:ae.entries,total:ae.total})}catch(ae){X||(A(ae instanceof Error?ae.message:String(ae)),R(null))}finally{X||L(!1)}})(),()=>{X=!0}},[e,n,V,b,v]);const Y=D&&D.key===K?D:null;h.useEffect(()=>{if(b==="all"||!Y||E)return;const X=Math.min(Y.total,Ln),ae=cu(v,X,Ki);Y.entries.length===0&&X>0&&ae!==v&&($(ae),p==null||p(ae))},[b,Y,E,v]);const W=h.useMemo(()=>us.filter(X=>sn(N,X)>0),[N]),ne=W.reduce((X,ae)=>X+sn(N,ae),0),je=W.some(X=>sn(N,X)>=Ln)?`${ne.toLocaleString()}+`:ne.toLocaleString(),Q=!E&&!I&&N!==null&&ne===0,de=h.useCallback(X=>{j(X),$(1),d==null||d(X)},[d]),We=h.useMemo(()=>{const X=[];return x.dynasty.forEach(ae=>X.push({name:ae,remove:()=>r({...x,dynasty:x.dynasty.filter(le=>le!==ae)})})),x.classification.forEach(ae=>{var le;return X.push({name:ae?((le=vi.find(ke=>ke.value===ae))==null?void 0:le.label)??ae:u.searchPage.unclassified,remove:()=>r({...x,classification:x.classification.filter(ke=>ke!==ae)})})}),x.hasImage&&X.push({name:m.hasImage,remove:()=>r({...x,hasImage:!1})}),x.hasText&&X.push({name:m.hasText,remove:()=>r({...x,hasText:!1})}),x.hasCollated&&X.push({name:m.hasCollated,remove:()=>r({...x,hasCollated:!1})}),x.loss&&X.push({name:`${m.extant}:${u.searchPage.loss[x.loss]}`,remove:()=>r({...x,loss:""})}),X},[x,r,m,u]),_e={query:n,onEntryLinkClick:s,typeName:a},Be=X=>k==="table"?t.jsx(cs,{entries:X,..._e}):t.jsx(ds,{entries:X,..._e}),Ne=us.flatMap(X=>qi(N,X));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:uu}),f&&t.jsx(su,{filters:x,onChange:r}),t.jsxs("div",{className:"bim-sr-main","aria-busy":E,ref:z,children:[W.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(ms,{on:b==="all",onClick:()=>de("all"),children:[u.search.allTab," ",t.jsx("small",{children:je})]}),W.map(X=>t.jsxs(ms,{on:b===X,onClick:()=>de(X),children:[a(X)," ",t.jsx("small",{children:oi(sn(N,X))})]},X))]}),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":g(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>r({...x,sort:""}),children:g(m.sortRelevance)}),["era","title"].map(X=>{const ae=x.sort.startsWith(`${X}:`)?x.sort.endsWith("desc")?"desc":"asc":null,le=X==="era"?m.sortEra:m.sortTitle,ke=X==="era"?ae==="desc"?m.sortEraDesc:m.sortEraAsc:ae==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":ae!==null,title:g(ke),onClick:()=>r({...x,sort:`${X}:${ae==="asc"?"desc":"asc"}`}),children:[g(le),ae?t.jsxs("span",{"aria-hidden":"true",children:[" ",ae==="asc"?"↑":"↓"]}):null]},X)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":g(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":k==="table",onClick:()=>w("table"),children:g(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":k==="card",onClick:()=>w("card"),children:g(m.viewCard)})]})]}),q&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:g(ht(m.filteredCount,{n:je}))}),We.map(X=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":g(ht(m.removeFilter,{name:X.name})),onClick:X.remove,children:[g(X.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},X.name))]}),I&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:I}),Q&&t.jsx("div",{className:"bim-sr-empty",children:g(q?m.emptyFiltered:ht(u.search.noResultsFor,{query:n}))}),!I&&!Q&&b==="all"&&N&&(k==="table"?t.jsxs(t.Fragment,{children:[t.jsx(cs,{entries:Ne,..._e}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:g(m.limitedNote)})]}):t.jsx(t.Fragment,{children:W.map(X=>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(yn,{type:X,size:8}),a(X),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[oi(sn(N,X))," ",u.unit.items]})]}),sn(N,X)>qi(N,X).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>de(X),children:u.action.viewAll})]}),t.jsx(ds,{entries:qi(N,X),..._e})]},X))})),!I&&b!=="all"&&!Y&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:u.search.loading}),!I&&b!=="all"&&Y&&Y.entries.length>0&&t.jsxs(t.Fragment,{children:[Be(Y.entries),t.jsx(du,{page:v,pageSize:Ki,total:Math.min(Y.total,Ln),totalLabel:oi(Y.total),onPage:P})]}),!I&&b!=="all"&&Y&&Y.entries.length===0&&!E&&t.jsxs("div",{className:"bim-sr-empty",children:[g(q?m.emptyFiltered:ht(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 ms({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 pn="bim-recent-ids",gs="bim-recent-entries",hs=50;function Ot(){try{const e=localStorage.getItem(pn);if(e)return JSON.parse(e);const n=localStorage.getItem(gs);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(pn,JSON.stringify(o)),localStorage.removeItem(gs),o}return[]}catch{return[]}}function mo(e){try{const n=Ot().filter(o=>o!==e);n.unshift(e),n.length>hs&&(n.length=hs),localStorage.setItem(pn,JSON.stringify(n))}catch{}}function Qa(e){try{const n=Ot().filter(o=>o!==e);localStorage.setItem(pn,JSON.stringify(n))}catch{}}function Vo(){try{localStorage.removeItem(pn)}catch{}}async function Go(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 Xi=5,ju=50,vu=200,fs={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},go=({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:g,onQueryChange:f,headerRight:x,reserveViewportHeight:k=!1,filtersEnabled:y=!1,filters:w=yi,onFiltersChange:b,resultTab:j,onResultTabChange:S,resultPage:v,onResultPageChange:$})=>{const _=Ce(),z=[{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"}],P=["work","collection","book","entity"],[N,T]=h.useState(g??""),[D,R]=h.useState(null),[E,L]=h.useState(g??""),I=ci(w).toString(),[A,V]=h.useState(w);h.useEffect(()=>{V(w)},[I]);const q=C=>{V(C),b==null||b(C)},[U,O]=h.useState(null),[K,Y]=h.useState("all"),[W,ne]=h.useState(!1),[je,Q]=h.useState(null),[de,We]=h.useState(""),[_e,Be]=h.useState(!(g!=null&&g.trim())),[Ne,X]=h.useState(Ot),[ae,le]=h.useState([]),[ke,H]=h.useState(!1),[fe,ue]=h.useState(!1),[$e,G]=h.useState(null),[Te,Ie]=h.useState(null),B=h.useRef(void 0),oe=h.useRef(!1),xe=h.useCallback(async(C,ie)=>{if(!C.trim()){Be(!0),R(null),O(null);return}if(Be(!1),y){L(C);return}ne(!0),We("");try{if(e.searchAll){const re=await e.searchAll(C,ie??Xi);R(re)}else{const re=["work","book","collection","entity"],ve=await Promise.all(re.map(se=>e.search(C,se,{page:1,pageSize:ie??Xi})));R({works:ve[0].entries,books:ve[1].entries,collections:ve[2].entries,entities:ve[3].entries,totalWorks:ve[0].total,totalBooks:ve[1].total,totalCollections:ve[2].total,totalEntities:ve[3].total})}}catch(re){We(re instanceof Error?re.message:String(re)),R(null)}finally{ne(!1)}},[e,y]);h.useEffect(()=>{let C=!1;const ie=()=>{var Oe,Z;const re=["work","book","collection","entity"],ve=Promise.all(re.map(ye=>e.loadEntries(ye,{page:1,pageSize:1}).catch(()=>({total:0})))),se=((Oe=e.getResourceCounts)==null?void 0:Oe.call(e).catch(()=>null))??Promise.resolve(null),he=((Z=e.getSubtypeStats)==null?void 0:Z.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([ve,se,he]).then(([ye,Ee,Pe])=>{C||(G({works:ye[0].total,books:ye[1].total,collections:ye[2].total,entities:ye[3].total,hasText:Ee==null?void 0:Ee.hasText,hasImage:Ee==null?void 0:Ee.hasImage}),Pe&&Ie(Pe))})};return e.getCounts?e.getCounts().then(re=>{var ve,se;C||(G({works:re.works,books:re.books,collections:re.collections,entities:re.entities,hasText:(ve=re.resourceCounts)==null?void 0:ve.hasText,hasImage:(se=re.resourceCounts)==null?void 0:se.hasImage}),re.subtypeStats&&Ie(re.subtypeStats))}).catch(()=>{C||ie()}):ie(),()=>{C=!0}},[e]),h.useEffect(()=>{oe.current||!(g!=null&&g.trim())||(oe.current=!0,xe(g))},[g,xe]);const Re=h.useCallback(C=>{if(T(C),!C.trim()){f==null||f(C),Be(!0),R(null),O(null),Y("all");return}B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{O(null),Y("all"),f==null||f(C),xe(C)},vu)},[xe,f]),F=h.useCallback(C=>{B.current&&clearTimeout(B.current),Y("all"),f==null||f(C),xe(C)},[xe,f]),me=h.useCallback(C=>{O(C),xe(N,ju)},[N,xe]);h.useEffect(()=>{if(!Ne.length){le([]);return}let C=!1;return H(!0),Promise.all(Ne.slice(0,10).map(ie=>Go(e,ie))).then(ie=>{C||(le(ie),H(!1))}),()=>{C=!0}},[Ne,e]);const te=C=>{Q(C.id),mo(C.id),X(Ot()),r==null||r(C)},ge=(C,ie)=>{if(r&&wu(ie)){ie.preventDefault(),te(C);return}mo(C.id),X(Ot())},ze=C=>{Qa(C),X(Ot())},Ue=()=>{Vo(),X([])},Ve=C=>z.find(ie=>ie.type===C),qe=!_e&&!D&&!de,Ze=D&&(D.works.length>0||D.books.length>0||D.collections.length>0),Ye=t.jsxs(t.Fragment,{children:[t.jsx(Da,{transport:e,value:N,onChange:Re,onSearch:F,onEntrySelect:te}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const C=N.trim();C&&Ha(C),F(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:Su+(y?_u:"")}),(!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(Fa,{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:Ye})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Ye}),_e&&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:$e&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:Te?t.jsxs(t.Fragment,{children:[(Te.book??0)>0&&t.jsxs(t.Fragment,{children:[_.searchPage.statBook," ",t.jsx("strong",{style:{color:i("fg")},children:Te.book.toLocaleString()})," ",_.unit.bu,_.searchPage.statComma,t.jsx("strong",{style:{color:i("fg")},children:$e.books.toLocaleString()})," ",_.searchPage.statBookCopies]}),Te.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statArticle," ",t.jsx("strong",{style:{color:i("fg")},children:Te.article.toLocaleString()})," ",_.searchPage.statArticleUnit]}):null,Te.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statPoem," ",t.jsx("strong",{style:{color:i("fg")},children:Te.poem.toLocaleString()})," ",_.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statCollection," ",t.jsx("strong",{style:{color:i("fg")},children:$e.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[_.indexType.work," ",t.jsx("strong",{style:{color:i("fg")},children:$e.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.book," ",t.jsx("strong",{style:{color:i("fg")},children:$e.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.collection," ",t.jsx("strong",{style:{color:i("fg")},children:$e.collections.toLocaleString()}),$e.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:$e.entities.toLocaleString()})]})]})}),$e.hasImage!=null&&$e.hasText!=null&&t.jsxs("span",{children:[_.resourceType.image," ",t.jsx("strong",{style:{color:i("fg")},children:$e.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.resourceType.text," ",t.jsx("strong",{style:{color:i("fg")},children:$e.hasText.toLocaleString()})]})]})}),y&&!_e&&t.jsx(Ja,{transport:e,query:E,filters:A,onFiltersChange:q,onEntryLinkClick:ge,typeName:C=>Ve(C).name,tab:j,onTabChange:S,page:v,onPageChange:$}),!(y&&!_e)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:W||qe?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:ku,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})}):_e?t.jsx("div",{style:{flex:1},children:ke?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:Ue,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,fe?10:3).map(C=>C.notFound?t.jsx(Tu,{id:C.id,onRemove:ze,t:_},C.id):t.jsx(xs,{entry:C,selected:je===C.id,onClick:ge,getConfig:Ve,onRemove:ze},C.id))}),!fe&&ae.length>3&&t.jsx("button",{onClick:()=>ue(!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})]})}):Ze?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:$u}),(()=>{const C=he=>D[fs[he]]??0,ie=P.map(he=>z.find(Oe=>Oe.type===he)).filter(he=>C(he.key)>0);if(ie.length<2)return null;const re=ie.reduce((he,Oe)=>he+C(Oe.key),0),ve=he=>{if(Y(he),he!=="all"&&U!==he){const Oe=z.find(ye=>ye.type===he),Z=(D[Oe.key]??[]).length;C(Oe.key)>Z&&me(he)}},se=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":K==="all",style:se(K==="all"),onClick:()=>ve("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":K===he.type,style:se(K===he.type),onClick:()=>ve(he.type),children:[he.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:C(he.key).toLocaleString()})]},he.type))]})})(),z.map(({type:C,name:ie,key:re})=>{const ve=D[re]??[],se=fs[re],he=D[se]??0;if(ve.length===0||K!=="all"&&K!==C)return null;const Z=K==="all"&&!(U===C)&&he>Xi;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(yn,{type:C})," ",ie,t.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[he," ",_.unit.items]})]}),Z&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>me(C),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:ve.map(ye=>{if(m)return t.jsx(h.Fragment,{children:m(ye)},ye.id);const Ee=u==="card"?zu:xs;return t.jsx(Ee,{entry:ye,selected:je===ye.id,onClick:ge,getConfig:Ve,query:N},ye.id)})})]},C)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:ht(_.search.noResultsFor,{query:N})}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.tryOther})]})})]})},ku=240;function wu(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const Su=`
|
|
120
|
+
`,Uo="bim-search-view",Ki=50,ps=5,Ln=1e3;function oi(e){return e>=Ln?`${Ln.toLocaleString()}+`:e.toLocaleString()}const mu={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function gu(e){return e&&mu[e.toLowerCase()]||"all"}function hu(e){return e==="all"?null:e}const us=["work","collection","book","entity"],fu={work:"works",collection:"collections",book:"books",entity:"entities"},xu={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function bu(){try{return window.localStorage.getItem(Uo)==="card"?"card":"table"}catch{return"table"}}function yu(e){try{window.localStorage.setItem(Uo,e)}catch{}}const sn=(e,n)=>(e==null?void 0:e[xu[n]])??0,qi=(e,n)=>(e==null?void 0:e[fu[n]])??[],Ja=({transport:e,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const u=Ce(),m=u.searchV4,{convert:g}=Pe(),f=!!e.supportsSearchFilters,x=h.useMemo(()=>f?o:yi,[f,o]),[k,y]=h.useState("table");h.useEffect(()=>{y(bu())},[]);const w=X=>{y(X),yu(X)},[b,j]=h.useState(l??"all"),S=h.useRef(b);S.current=b,h.useEffect(()=>{l!==void 0&&l!==S.current&&(j(l),$(1))},[l]);const[v,$]=h.useState(c&&c>0?c:1),_=h.useRef(v);_.current=v,h.useEffect(()=>{c!==void 0&&c>0&&c!==_.current&&$(c)},[c]);const z=h.useRef(null),P=h.useCallback(X=>{var de;$(X),p==null||p(X);const le=z.current;le&&le.getBoundingClientRect().top<0&&((de=le.scrollIntoView)==null||de.call(le,{block:"start",behavior:"instant"}))},[p]),[N,T]=h.useState(null),[D,R]=h.useState(null),[E,L]=h.useState(!1),[I,A]=h.useState(""),V=ci(x).toString(),q=ki(x)>0,O=ci({...x,sort:""}).toString(),W=h.useRef({query:n,filterOnlyKey:O,sort:x.sort});h.useEffect(()=>{const X=W.current;X.query!==n||X.filterOnlyKey!==O?(j("all"),$(1)):X.sort!==x.sort&&$(1),W.current={query:n,filterOnlyKey:O,sort:x.sort}},[n,O,x.sort]),h.useEffect(()=>{let X=!1;return L(!0),A(""),(async()=>{try{let le;if(e.searchAll)le=await e.searchAll(n,ps,x);else{const de=["work","book","collection","entity"],ve=await Promise.all(de.map(H=>e.search(n,H,{page:1,pageSize:ps,filters:x})));le={works:ve[0].entries,books:ve[1].entries,collections:ve[2].entries,entities:ve[3].entries,totalWorks:ve[0].total,totalBooks:ve[1].total,totalCollections:ve[2].total,totalEntities:ve[3].total}}X||T(le)}catch(le){X||(A(le instanceof Error?le.message:String(le)),T(null))}finally{X||L(!1)}})(),()=>{X=!0}},[e,n,V]);const K=b;h.useEffect(()=>{if(b==="all"){R(null);return}let X=!1;return L(!0),(async()=>{try{const le=await e.search(n,b,{page:v,pageSize:Ki,filters:x});X||R({key:K,entries:le.entries,total:le.total})}catch(le){X||(A(le instanceof Error?le.message:String(le)),R(null))}finally{X||L(!1)}})(),()=>{X=!0}},[e,n,V,b,v]);const Y=D&&D.key===K?D:null;h.useEffect(()=>{if(b==="all"||!Y||E)return;const X=Math.min(Y.total,Ln),le=cu(v,X,Ki);Y.entries.length===0&&X>0&&le!==v&&($(le),p==null||p(le))},[b,Y,E,v]);const F=h.useMemo(()=>us.filter(X=>sn(N,X)>0),[N]),te=F.reduce((X,le)=>X+sn(N,le),0),je=F.some(X=>sn(N,X)>=Ln)?`${te.toLocaleString()}+`:te.toLocaleString(),oe=!E&&!I&&N!==null&&te===0,ie=h.useCallback(X=>{j(X),$(1),d==null||d(X)},[d]),Be=h.useMemo(()=>{const X=[];return x.dynasty.forEach(le=>X.push({name:le,remove:()=>r({...x,dynasty:x.dynasty.filter(de=>de!==le)})})),x.classification.forEach(le=>{var de;return X.push({name:le?((de=vi.find(ve=>ve.value===le))==null?void 0:de.label)??le:u.searchPage.unclassified,remove:()=>r({...x,classification:x.classification.filter(ve=>ve!==le)})})}),x.hasImage&&X.push({name:m.hasImage,remove:()=>r({...x,hasImage:!1})}),x.hasText&&X.push({name:m.hasText,remove:()=>r({...x,hasText:!1})}),x.hasCollated&&X.push({name:m.hasCollated,remove:()=>r({...x,hasCollated:!1})}),x.loss&&X.push({name:`${m.extant}:${u.searchPage.loss[x.loss]}`,remove:()=>r({...x,loss:""})}),X},[x,r,m,u]),we={query:n,onEntryLinkClick:s,typeName:a},Oe=X=>k==="table"?t.jsx(cs,{entries:X,...we}):t.jsx(ds,{entries:X,...we}),Te=us.flatMap(X=>qi(N,X));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:uu}),f&&t.jsx(su,{filters:x,onChange:r}),t.jsxs("div",{className:"bim-sr-main","aria-busy":E,ref:z,children:[F.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(ms,{on:b==="all",onClick:()=>ie("all"),children:[u.search.allTab," ",t.jsx("small",{children:je})]}),F.map(X=>t.jsxs(ms,{on:b===X,onClick:()=>ie(X),children:[a(X)," ",t.jsx("small",{children:oi(sn(N,X))})]},X))]}),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":g(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>r({...x,sort:""}),children:g(m.sortRelevance)}),["era","title"].map(X=>{const le=x.sort.startsWith(`${X}:`)?x.sort.endsWith("desc")?"desc":"asc":null,de=X==="era"?m.sortEra:m.sortTitle,ve=X==="era"?le==="desc"?m.sortEraDesc:m.sortEraAsc:le==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":le!==null,title:g(ve),onClick:()=>r({...x,sort:`${X}:${le==="asc"?"desc":"asc"}`}),children:[g(de),le?t.jsxs("span",{"aria-hidden":"true",children:[" ",le==="asc"?"↑":"↓"]}):null]},X)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":g(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":k==="table",onClick:()=>w("table"),children:g(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":k==="card",onClick:()=>w("card"),children:g(m.viewCard)})]})]}),q&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:g(ht(m.filteredCount,{n:je}))}),Be.map(X=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":g(ht(m.removeFilter,{name:X.name})),onClick:X.remove,children:[g(X.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},X.name))]}),I&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:I}),oe&&t.jsx("div",{className:"bim-sr-empty",children:g(q?m.emptyFiltered:ht(u.search.noResultsFor,{query:n}))}),!I&&!oe&&b==="all"&&N&&(k==="table"?t.jsxs(t.Fragment,{children:[t.jsx(cs,{entries:Te,...we}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:g(m.limitedNote)})]}):t.jsx(t.Fragment,{children:F.map(X=>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(yn,{type:X,size:8}),a(X),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[oi(sn(N,X))," ",u.unit.items]})]}),sn(N,X)>qi(N,X).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>ie(X),children:u.action.viewAll})]}),t.jsx(ds,{entries:qi(N,X),...we})]},X))})),!I&&b!=="all"&&!Y&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:u.search.loading}),!I&&b!=="all"&&Y&&Y.entries.length>0&&t.jsxs(t.Fragment,{children:[Oe(Y.entries),t.jsx(du,{page:v,pageSize:Ki,total:Math.min(Y.total,Ln),totalLabel:oi(Y.total),onPage:P})]}),!I&&b!=="all"&&Y&&Y.entries.length===0&&!E&&t.jsxs("div",{className:"bim-sr-empty",children:[g(q?m.emptyFiltered:ht(u.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>ie("all"),children:u.search.allTab})})]})]})]})};function ms({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 pn="bim-recent-ids",gs="bim-recent-entries",hs=50;function Ot(){try{const e=localStorage.getItem(pn);if(e)return JSON.parse(e);const n=localStorage.getItem(gs);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(pn,JSON.stringify(o)),localStorage.removeItem(gs),o}return[]}catch{return[]}}function mo(e){try{const n=Ot().filter(o=>o!==e);n.unshift(e),n.length>hs&&(n.length=hs),localStorage.setItem(pn,JSON.stringify(n))}catch{}}function Qa(e){try{const n=Ot().filter(o=>o!==e);localStorage.setItem(pn,JSON.stringify(n))}catch{}}function Vo(){try{localStorage.removeItem(pn)}catch{}}async function Go(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 Xi=5,ju=50,vu=200,fs={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},go=({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:g,onQueryChange:f,headerRight:x,reserveViewportHeight:k=!1,filtersEnabled:y=!1,filters:w=yi,onFiltersChange:b,resultTab:j,onResultTabChange:S,resultPage:v,onResultPageChange:$})=>{const _=Ce(),z=[{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"}],P=["work","collection","book","entity"],[N,T]=h.useState(g??""),[D,R]=h.useState(null),[E,L]=h.useState(g??""),I=ci(w).toString(),[A,V]=h.useState(w);h.useEffect(()=>{V(w)},[I]);const q=C=>{V(C),b==null||b(C)},[O,W]=h.useState(null),[K,Y]=h.useState("all"),[F,te]=h.useState(!1),[je,oe]=h.useState(null),[ie,Be]=h.useState(""),[we,Oe]=h.useState(!(g!=null&&g.trim())),[Te,X]=h.useState(Ot),[le,de]=h.useState([]),[ve,H]=h.useState(!1),[me,ue]=h.useState(!1),[$e,G]=h.useState(null),[ze,Le]=h.useState(null),B=h.useRef(void 0),re=h.useRef(!1),he=h.useCallback(async(C,ne)=>{if(!C.trim()){Oe(!0),R(null),W(null);return}if(Oe(!1),y){L(C);return}te(!0),Be("");try{if(e.searchAll){const se=await e.searchAll(C,ne??Xi);R(se)}else{const se=["work","book","collection","entity"],ke=await Promise.all(se.map(ae=>e.search(C,ae,{page:1,pageSize:ne??Xi})));R({works:ke[0].entries,books:ke[1].entries,collections:ke[2].entries,entities:ke[3].entries,totalWorks:ke[0].total,totalBooks:ke[1].total,totalCollections:ke[2].total,totalEntities:ke[3].total})}}catch(se){Be(se instanceof Error?se.message:String(se)),R(null)}finally{te(!1)}},[e,y]);h.useEffect(()=>{let C=!1;const ne=()=>{var He,Z;const se=["work","book","collection","entity"],ke=Promise.all(se.map(ye=>e.loadEntries(ye,{page:1,pageSize:1}).catch(()=>({total:0})))),ae=((He=e.getResourceCounts)==null?void 0:He.call(e).catch(()=>null))??Promise.resolve(null),ge=((Z=e.getSubtypeStats)==null?void 0:Z.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([ke,ae,ge]).then(([ye,Ie,Me])=>{C||(G({works:ye[0].total,books:ye[1].total,collections:ye[2].total,entities:ye[3].total,hasText:Ie==null?void 0:Ie.hasText,hasImage:Ie==null?void 0:Ie.hasImage}),Me&&Le(Me))})};return e.getCounts?e.getCounts().then(se=>{var ke,ae;C||(G({works:se.works,books:se.books,collections:se.collections,entities:se.entities,hasText:(ke=se.resourceCounts)==null?void 0:ke.hasText,hasImage:(ae=se.resourceCounts)==null?void 0:ae.hasImage}),se.subtypeStats&&Le(se.subtypeStats))}).catch(()=>{C||ne()}):ne(),()=>{C=!0}},[e]),h.useEffect(()=>{re.current||!(g!=null&&g.trim())||(re.current=!0,he(g))},[g,he]);const Ne=h.useCallback(C=>{if(T(C),!C.trim()){f==null||f(C),Oe(!0),R(null),W(null),Y("all");return}B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{W(null),Y("all"),f==null||f(C),he(C)},vu)},[he,f]),Re=h.useCallback(C=>{B.current&&clearTimeout(B.current),Y("all"),f==null||f(C),he(C)},[he,f]),U=h.useCallback(C=>{W(C),he(N,ju)},[N,he]);h.useEffect(()=>{if(!Te.length){de([]);return}let C=!1;return H(!0),Promise.all(Te.slice(0,10).map(ne=>Go(e,ne))).then(ne=>{C||(de(ne),H(!1))}),()=>{C=!0}},[Te,e]);const be=C=>{oe(C.id),mo(C.id),X(Ot()),r==null||r(C)},ee=(C,ne)=>{if(r&&wu(ne)){ne.preventDefault(),be(C);return}mo(C.id),X(Ot())},fe=C=>{Qa(C),X(Ot())},Ee=()=>{Vo(),X([])},Fe=C=>z.find(ne=>ne.type===C),Ye=!we&&!D&&!ie,Ke=D&&(D.works.length>0||D.books.length>0||D.collections.length>0),qe=t.jsxs(t.Fragment,{children:[t.jsx(Da,{transport:e,value:N,onChange:Ne,onSearch:Re,onEntrySelect:be}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const C=N.trim();C&&Ha(C),Re(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:Su+(y?_u:"")}),(!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(Fa,{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:qe})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:qe}),we&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:$e&&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:$e.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:$e.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[_.indexType.work," ",t.jsx("strong",{style:{color:i("fg")},children:$e.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.book," ",t.jsx("strong",{style:{color:i("fg")},children:$e.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.collection," ",t.jsx("strong",{style:{color:i("fg")},children:$e.collections.toLocaleString()}),$e.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:$e.entities.toLocaleString()})]})]})}),$e.hasImage!=null&&$e.hasText!=null&&t.jsxs("span",{children:[_.resourceType.image," ",t.jsx("strong",{style:{color:i("fg")},children:$e.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.resourceType.text," ",t.jsx("strong",{style:{color:i("fg")},children:$e.hasText.toLocaleString()})]})]})}),y&&!we&&t.jsx(Ja,{transport:e,query:E,filters:A,onFiltersChange:q,onEntryLinkClick:ee,typeName:C=>Fe(C).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:F||Ye?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:ku,boxSizing:"border-box"},children:_.search.searching}):ie?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:i("desc-fg")},children:ie})}):we?t.jsx("div",{style:{flex:1},children:ve?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:Ee,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,me?10:3).map(C=>C.notFound?t.jsx(Tu,{id:C.id,onRemove:fe,t:_},C.id):t.jsx(xs,{entry:C,selected:je===C.id,onClick:ee,getConfig:Fe,onRemove:fe},C.id))}),!me&&le.length>3&&t.jsx("button",{onClick:()=>ue(!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})]})}):Ke?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:$u}),(()=>{const C=ge=>D[fs[ge]]??0,ne=P.map(ge=>z.find(He=>He.type===ge)).filter(ge=>C(ge.key)>0);if(ne.length<2)return null;const se=ne.reduce((ge,He)=>ge+C(He.key),0),ke=ge=>{if(Y(ge),ge!=="all"&&O!==ge){const He=z.find(ye=>ye.type===ge),Z=(D[He.key]??[]).length;C(He.key)>Z&&U(ge)}},ae=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":K==="all",style:ae(K==="all"),onClick:()=>ke("all"),children:[_.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:se.toLocaleString()})]}),ne.map(ge=>t.jsxs("button",{type:"button","aria-pressed":K===ge.type,style:ae(K===ge.type),onClick:()=>ke(ge.type),children:[ge.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:C(ge.key).toLocaleString()})]},ge.type))]})})(),z.map(({type:C,name:ne,key:se})=>{const ke=D[se]??[],ae=fs[se],ge=D[ae]??0;if(ke.length===0||K!=="all"&&K!==C)return null;const Z=K==="all"&&!(O===C)&&ge>Xi;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(yn,{type:C})," ",ne,t.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[ge," ",_.unit.items]})]}),Z&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>U(C),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:ke.map(ye=>{if(m)return t.jsx(h.Fragment,{children:m(ye)},ye.id);const Ie=u==="card"?zu:xs;return t.jsx(Ie,{entry:ye,selected:je===ye.id,onClick:ee,getConfig:Fe,query:N},ye.id)})})]},C)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:ht(_.search.noResultsFor,{query:N})}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:_.search.tryOther})]})})]})},ku=240;function wu(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const Su=`
|
|
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
|
`,_u=`
|
|
@@ -142,13 +142,13 @@
|
|
|
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
|
-
}`,el={color:"inherit",textDecoration:"none"},Cu=({snippet:e})=>{const{convert:n}=Ae();return t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:Mo(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(h.Fragment,{children:n(o.text)},r))})},zu=({entry:e,selected:n,onClick:o,getConfig:r,query:s})=>{const a=Ce(),{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"),g=tt();return t.jsxs("a",{href:g(e.id),onClick:f=>o(e,f),className:"bim-result-card",style:{...el,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(Cu,{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(yn,{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})]})]})]})},xs=({entry:e,selected:n,onClick:o,getConfig:r,query:s,onRemove:a})=>{const l=Ce(),{convert:d}=Ae(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const g=typeof m=="string"?m:m==null?void 0:m.book_title;return g==null?void 0:g.toLowerCase().includes(s.toLowerCase())}):void 0,u=tt();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:{...el,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(yn,{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:"×"})]})},Tu=({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 Nu(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 Ru({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 Eu({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 Iu({data:e}){const n=Ce(),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 Lu({works:e,transport:n,onNavigate:o,renderLink:r}){const s=Ce(),{convert:a}=Ae(),l=tt(),[d,c]=h.useState(new Map);h.useEffect(()=>{if(!n)return;let g=!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=>{g||c(k)}),()=>{g=!0}},[e,n]);const p=new Map;for(const g of e){const f=g.role||"";p.has(f)||p.set(f,[]),p.get(f).push(g)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((g,f)=>{const x=u.indexOf(g),k=u.indexOf(f);return x===-1&&k===-1?g.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(g=>{const f=p.get(g);return t.jsxs("div",{style:{marginBottom:"8px"},children:[g&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[a(g)," ",t.jsxs("span",{style:{color:i("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:g?"16px":"0",listStyle:g?"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)})})]},g)})]})}const tl=({data:e,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:a})=>{var m;const l=Ce(),{convert:d}=Ae();let c=!1;try{c=Se.extractStatus(e.id)==="draft"}catch{}const p=Nu(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(Ru,{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(Eu,{alt_names:e.alt_names}),t.jsx(Iu,{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(Lu,{works:e.works,transport:n,onNavigate:o,renderLink:r})]})},Au=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Pu(e){const n=e.search(Au);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const nl={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===Mu(e))){const[a,l]=Pu(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 Mu(e){try{return decodeURI(e)}catch{return e}}const Bu={...nl,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},At=({text:e,plainStrong:n,style:o,className:r})=>{const{convert:s}=Ae(),a=n?Bu:nl;return t.jsx("div",{className:r,style:o,children:t.jsx(dp,{remarkPlugins:[pp],components:a,children:s(e)})})},Wu=["〇","一","二","三","四","五","六","七","八","九"],bs=["","十","百","千"];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+=bs[d]:r+=Wu[l]+bs[d])}return r}function ol(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 Ou={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function Fu({type:e}){const n=Ce();return t.jsx("span",{style:ol(Ou[e]),children:n.indexType[e]})}function Hu({isDraft:e}){const n=Ce(),o=i(e?"status-draft":"status-official");return t.jsx("span",{style:ol(o),children:e?n.status.draft:n.status.official})}function Du({id:e}){const n=Ce(),[o,r]=h.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 bt({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 zt({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 rl({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(wt,{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 wt({id:e,label:n,onNavigate:o,renderLink:r}){const s=tt();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 Uu({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(Fu,{type:r}),t.jsx(Hu,{isDraft:s}),t.jsx(Du,{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(rl,{authors:a,type:r,onNavigate:p,renderLink:u}),d]})]})}function sl({items:e,label:n,showMeta:o,onNavigate:r,renderLink:s}){const a=Ce(),{convert:l}=Ae();if(!e.length)return null;const[d,c]=h.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(bt,{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:g=>g.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(wt,{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(zt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(zt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(zt,{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 Vu({items:e,onNavigate:n,renderLink:o}){const r=Ce();return t.jsx(sl,{items:e,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function al({items:e,onNavigate:n,renderLink:o}){const r=Ce();return t.jsx(sl,{items:e,label:r.section.emendated,onNavigate:n,renderLink:o})}function ll({label:e,items:n}){const{convert:o}=Ae();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(bt,{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 Gu({items:e}){const n=Ce();return t.jsx(ll,{label:n.section.aliases,items:e})}function Yu({items:e}){const n=Ce();return t.jsx(ll,{label:n.section.attachedTexts,items:e})}function Ku({items:e}){const n=Ce(),{convert:o}=Ae();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(bt,{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 qu({items:e}){const n=Ce(),{convert:o}=Ae();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(bt,{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 Xu({items:e}){const n=Ce(),{convert:o}=Ae();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(bt,{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 ys({title:e,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:a}=Ae(),[l,d]=h.useState([]);return h.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(bt,{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(wt,{id:c.id,label:p,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Zi({book:e,onNavigate:n,renderLink:o}){const r=Ce(),{convert:s}=Ae(),[a,l]=h.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(wt,{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(Do,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function Zu({ids:e,workData:n,transport:o,onNavigate:r,renderLink:s,footer:a}){const l=Ce(),{convert:d}=Ae(),[c,p]=h.useState([]);if(h.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])),g=n==null?void 0:n.version_graph,f=Ju(e,g,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(bt,{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(Zi,{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(Zi,{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(Zi,{book:x,onNavigate:r,renderLink:s},x.id))})]})}function Ju(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=[],g=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?(g.has(S)||g.set(S,[]),g.get(S).push(j)):f.push(j)}if(f.length+[...g.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=[...g.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 Qu({workData:e,onNavigate:n,renderLink:o}){var l,d,c,p;const r=Ce(),{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(wt,{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:[il(e.juan_count.number),r.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(rl,{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(At,{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(zt,{label:r.label.parentWork,children:t.jsx(wt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function em({items:e,onNavigate:n,renderLink:o}){const r=Ce(),{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(wt,{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:ht(r.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Yo=({data:e,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var D,R,E,L,I,A,V,q;const p=Ce(),{convert:u}=Ae(),[m,g]=h.useState(null),[f,x]=h.useState(!1),[k,y]=h.useState(null),[w,b]=h.useState(null),[j,S]=h.useState([]),v=e||m;if(h.useEffect(()=>{if(e||!n||!o)return;let U=!1;return x(!0),y(null),o.getItem(n).then(O=>{U||(O?g(O):y(p.misc.notFoundEntry))}).catch(O=>{U||y(O instanceof Error?O.message:p.misc.loadFailed)}).finally(()=>{U||x(!1)}),()=>{U=!0}},[e,n,o]),h.useEffect(()=>{if(!v||!o){b(null),S([]);return}let U=!1;const O=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(O?o.getItem(O).then(K=>{!U&&K&&K.type==="work"&&b(K)}).catch(()=>{}):b(null),v.type==="book"){const K=v;K.contained_in&&K.contained_in.length>0?Promise.all(K.contained_in.map(Y=>{const W=typeof Y=="string"?Y:Y.id,ne=typeof Y=="string"?void 0:Y.volume_index;return o.getItem(W).then(je=>({id:W,title:je&&je.title||W,volume_index:ne})).catch(()=>({id:W,title:W,volume_index:ne}))})).then(Y=>{U||S(Y)}):S([])}else S([]);return()=>{U=!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((U,O)=>t.jsx("div",{style:{height:O===1?"32px":"16px",width:`${U}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(tl,{data:v,transport:o,onNavigate:r,renderLink:s,headerExtra:a})});const $=v.type==="book"?v:null,_=v.type==="collection"?v:null,z=v.type==="work"?v:null;let P=!1;try{P=Se.extractStatus(v.id)==="draft"}catch{}let N="";v.measure_info?N=u(v.measure_info):(D=v.juan_count)!=null&&D.number?N=il(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(zt,{label:p.label.year,children:v.publication_info.year},"year")),(L=v.current_location)!=null&&L.name&&T.push(t.jsx(zt,{label:p.label.currentLocation,children:u(v.current_location.name)},"loc")),(I=v.page_count)!=null&&I.description&&T.push(t.jsx(zt,{label:p.label.pageCount,children:v.page_count.description},"page")),$!=null&&$.edition&&T.push(t.jsx(zt,{label:p.label.edition,children:u($.edition)},"ver")),z!=null&&z.parent_work&&T.push(t.jsx(zt,{label:p.label.parentWork,children:t.jsx(wt,{id:z.parent_work.id,label:u(z.parent_work.title),onNavigate:r,renderLink:s})},"pw")),z!=null&&z.parent_works&&z.parent_works.length>0&&!z.parent_work&&T.push(t.jsx(zt,{label:p.label.parentWork,children:z.parent_works.map((U,O)=>t.jsxs("span",{children:[O>0&&"、",t.jsx(wt,{id:U,onNavigate:r,renderLink:s})]},U))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Uu,{id:v.id,title:u(v.title),edition:v.edition?u(v.edition):void 0,type:v.type,isDraft:P,authors:v.authors,volumeText:N,meta:T,headerExtra:a,onNavigate:r,renderLink:s}),((A=v.description)==null?void 0:A.text)&&t.jsx(At,{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((U,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(U.title)}),t.jsx(At,{text:U.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(bt,{children:p.section.containedIn}),t.jsx(em,{items:j,onNavigate:r,renderLink:s})]}),w&&t.jsxs(t.Fragment,{children:[t.jsx(bt,{children:p.section.belongsToWork}),t.jsx(Qu,{workData:w,onNavigate:r,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Ku,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Gu,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(Yu,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(Vu,{items:v.indexed_by,onNavigate:r,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(al,{items:v.emendated_by,onNavigate:r,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(bt,{children:p.section.resources}),t.jsx(Do,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(qu,{items:$.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&t.jsx(Xu,{items:_.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(ys,{title:p.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&t.jsx(ys,{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(bt,{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(U=>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(wt,{id:U.id,label:u(U.title),onNavigate:r,renderLink:s})},U.id))})]}),(((V=z==null?void 0:z.books)==null?void 0:V.length)||0)+(((q=z==null?void 0:z.collections)==null?void 0:q.length)||0)>0&&t.jsx(Zu,{ids:[...(z==null?void 0:z.books)||[],...(z==null?void 0:z.collections)||[]],workData:z??void 0,transport:o,onNavigate:r,renderLink:s,footer:l}),(z==null?void 0:z.related_works)&&z.related_works.length>0&&(()=>{const U=[],O=z.related_works.filter(Q=>Q.relation==="part_of"),K=z.related_works.filter(Q=>Q.relation==="has_part"),Y=z.related_works.filter(Q=>Q.relation==="has_adaptation"),W=z.related_works.filter(Q=>Q.relation==="text_carried_by"),ne=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),je=z.related_works.filter(Q=>!Q.relation||!ne.has(Q.relation));return O.length>0&&U.push({label:p.section.belongsToWork,items:O}),K.length>0&&U.push({label:p.section.containedWorks,items:K}),Y.length>0&&U.push({label:p.section.adaptations,items:Y}),W.length>0&&U.push({label:p.section.derivativeWorks,items:W}),je.length>0&&U.push({label:p.section.relatedWorks,items:je}),U.map(Q=>t.jsxs("div",{children:[t.jsxs(bt,{children:[Q.label,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",Q.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:Q.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(wt,{id:de.id,label:u(de.title),onNavigate:r,renderLink:s})},de.id))})]},Q.label))})()]})};function tm({data:e}){const n=Ce(),{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 nm({sections:e,activeSection:n,onSelect:o}){const r=Ce();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>o(null),style:js(n===null),children:r.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>o(s.name),style:js(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 js(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 im({id:e,label:n,onNavigate:o,renderLink:r}){const s=tt();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 om(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 vs({book:e,onNavigate:n,renderLink:o,showVolumes:r}){const s=Ce(),{convert:a}=Ae(),l=e.book_id||e.work_id,d=r&&e.volumes.length>0?om(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(im,{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 Ko=({data:e,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:a,style:l})=>{const d=Ce(),[c,p]=h.useState(null),[u,m]=h.useState(!1),[g,f]=h.useState(null),[x,k]=h.useState(null),[y,w]=h.useState(""),b=e||c;h.useEffect(()=>{if(e||!n||!(o!=null&&o.getCollectionCatalog))return;let _=!1;return m(!0),f(null),o.getCollectionCatalog(n).then(z=>{_||(z?p(z):f(d.catalog.notFound))}).catch(z=>{_||f(z instanceof Error?z.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=h.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(P=>P.volumes[0]).filter(P=>P!=null);return new Set(_).size<_.length},[b]),v=h.useMemo(()=>{if(!b)return[];let _=b.books;if(x&&(_=_.filter(z=>z.section===x)),y.trim()){const z=y.trim().toLowerCase();_=_.filter(P=>P.title.toLowerCase().includes(z)||P.sub_items&&P.sub_items.some(N=>N.toLowerCase().includes(z))||P.edition&&P.edition.toLowerCase().includes(z))}return _},[b,x,y]),$=h.useMemo(()=>{if(!S)return null;const _=[],z=new Map;for(const N of v){if(!N.volumes||N.volumes.length===0)continue;const T=N.volumes[0];z.has(T)||z.set(T,[]),z.get(T).push(N)}const P=[...z.keys()].sort((N,T)=>N-T);for(const N of P)_.push({volume:N,books:z.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})}):g?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:g}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(tm,{data:b}),j&&t.jsx(nm,{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((_,z)=>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:ht(d.catalog.volume,{n:_.volume})}),_.books.map((P,N)=>t.jsx(vs,{book:P,onNavigate:r,renderLink:s,showVolumes:P.volumes.length>1},`${_.volume}-${N}`))]},`${_.volume}-${z}`)):v.map((_,z)=>t.jsx(vs,{book:_,onNavigate:r,renderLink:s,showVolumes:!0},z)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},rm="guji_markdown";function ho(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 sm=/^□\{guess=([^\s{}]+)\}/;function am(e,n){const o=e[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function cl(e,n){let o=0;for(let r=n;r<e.length;r++){const s=e[r];if(s===`
|
|
145
|
+
}`,el={color:"inherit",textDecoration:"none"},Cu=({snippet:e})=>{const{convert:n}=Pe();return t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:Mo(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(h.Fragment,{children:n(o.text)},r))})},zu=({entry:e,selected:n,onClick:o,getConfig:r,query:s})=>{const a=Ce(),{convert:l}=Pe(),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"),g=tt();return t.jsxs("a",{href:g(e.id),onClick:f=>o(e,f),className:"bim-result-card",style:{...el,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(Cu,{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(yn,{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})]})]})]})},xs=({entry:e,selected:n,onClick:o,getConfig:r,query:s,onRemove:a})=>{const l=Ce(),{convert:d}=Pe(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const g=typeof m=="string"?m:m==null?void 0:m.book_title;return g==null?void 0:g.toLowerCase().includes(s.toLowerCase())}):void 0,u=tt();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:{...el,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(yn,{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:"×"})]})},Tu=({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 Nu(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 Ru({data:e}){const{convert:n}=Pe(),{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 Eu({alt_names:e}){const{convert:n}=Pe(),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 Iu({data:e}){const n=Ce(),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 Lu({works:e,transport:n,onNavigate:o,renderLink:r}){const s=Ce(),{convert:a}=Pe(),l=tt(),[d,c]=h.useState(new Map);h.useEffect(()=>{if(!n)return;let g=!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=>{g||c(k)}),()=>{g=!0}},[e,n]);const p=new Map;for(const g of e){const f=g.role||"";p.has(f)||p.set(f,[]),p.get(f).push(g)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((g,f)=>{const x=u.indexOf(g),k=u.indexOf(f);return x===-1&&k===-1?g.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(g=>{const f=p.get(g);return t.jsxs("div",{style:{marginBottom:"8px"},children:[g&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[a(g)," ",t.jsxs("span",{style:{color:i("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:g?"16px":"0",listStyle:g?"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)})})]},g)})]})}const tl=({data:e,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:a})=>{var m;const l=Ce(),{convert:d}=Pe();let c=!1;try{c=_e.extractStatus(e.id)==="draft"}catch{}const p=Nu(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(Ru,{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(Eu,{alt_names:e.alt_names}),t.jsx(Iu,{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(Lu,{works:e.works,transport:n,onNavigate:o,renderLink:r})]})},Au=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Pu(e){const n=e.search(Au);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const nl={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===Mu(e))){const[a,l]=Pu(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 Mu(e){try{return decodeURI(e)}catch{return e}}const Bu={...nl,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},At=({text:e,plainStrong:n,style:o,className:r})=>{const{convert:s}=Pe(),a=n?Bu:nl;return t.jsx("div",{className:r,style:o,children:t.jsx(dp,{remarkPlugins:[pp],components:a,children:s(e)})})},Wu=["〇","一","二","三","四","五","六","七","八","九"],bs=["","十","百","千"];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+=bs[d]:r+=Wu[l]+bs[d])}return r}function ol(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 Ou={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function Fu({type:e}){const n=Ce();return t.jsx("span",{style:ol(Ou[e]),children:n.indexType[e]})}function Hu({isDraft:e}){const n=Ce(),o=i(e?"status-draft":"status-official");return t.jsx("span",{style:ol(o),children:e?n.status.draft:n.status.official})}function Du({id:e}){const n=Ce(),[o,r]=h.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 bt({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 zt({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 rl({authors:e,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Pe();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(wt,{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 wt({id:e,label:n,onNavigate:o,renderLink:r}){const s=tt();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 Uu({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(Fu,{type:r}),t.jsx(Hu,{isDraft:s}),t.jsx(Du,{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(rl,{authors:a,type:r,onNavigate:p,renderLink:u}),d]})]})}function sl({items:e,label:n,showMeta:o,onNavigate:r,renderLink:s}){const a=Ce(),{convert:l}=Pe();if(!e.length)return null;const[d,c]=h.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(bt,{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:g=>g.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(wt,{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(zt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(zt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(zt,{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 Vu({items:e,onNavigate:n,renderLink:o}){const r=Ce();return t.jsx(sl,{items:e,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function al({items:e,onNavigate:n,renderLink:o}){const r=Ce();return t.jsx(sl,{items:e,label:r.section.emendated,onNavigate:n,renderLink:o})}function ll({label:e,items:n}){const{convert:o}=Pe();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(bt,{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 Gu({items:e}){const n=Ce();return t.jsx(ll,{label:n.section.aliases,items:e})}function Yu({items:e}){const n=Ce();return t.jsx(ll,{label:n.section.attachedTexts,items:e})}function Ku({items:e}){const n=Ce(),{convert:o}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(bt,{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 qu({items:e}){const n=Ce(),{convert:o}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(bt,{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 Xu({items:e}){const n=Ce(),{convert:o}=Pe();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(bt,{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 ys({title:e,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:a}=Pe(),[l,d]=h.useState([]);return h.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(bt,{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(wt,{id:c.id,label:p,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Zi({book:e,onNavigate:n,renderLink:o}){const r=Ce(),{convert:s}=Pe(),[a,l]=h.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(wt,{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(Do,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function Zu({ids:e,workData:n,transport:o,onNavigate:r,renderLink:s,footer:a}){const l=Ce(),{convert:d}=Pe(),[c,p]=h.useState([]);if(h.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])),g=n==null?void 0:n.version_graph,f=Ju(e,g,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(bt,{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(Zi,{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(Zi,{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(Zi,{book:x,onNavigate:r,renderLink:s},x.id))})]})}function Ju(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=[],g=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?(g.has(S)||g.set(S,[]),g.get(S).push(j)):f.push(j)}if(f.length+[...g.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=[...g.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 Qu({workData:e,onNavigate:n,renderLink:o}){var l,d,c,p;const r=Ce(),{convert:s}=Pe(),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(wt,{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:[il(e.juan_count.number),r.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(rl,{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(At,{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(zt,{label:r.label.parentWork,children:t.jsx(wt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function em({items:e,onNavigate:n,renderLink:o}){const r=Ce(),{convert:s}=Pe();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(wt,{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:ht(r.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Yo=({data:e,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var D,R,E,L,I,A,V,q;const p=Ce(),{convert:u}=Pe(),[m,g]=h.useState(null),[f,x]=h.useState(!1),[k,y]=h.useState(null),[w,b]=h.useState(null),[j,S]=h.useState([]),v=e||m;if(h.useEffect(()=>{if(e||!n||!o)return;let O=!1;return x(!0),y(null),o.getItem(n).then(W=>{O||(W?g(W):y(p.misc.notFoundEntry))}).catch(W=>{O||y(W instanceof Error?W.message:p.misc.loadFailed)}).finally(()=>{O||x(!1)}),()=>{O=!0}},[e,n,o]),h.useEffect(()=>{if(!v||!o){b(null),S([]);return}let O=!1;const W=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(W?o.getItem(W).then(K=>{!O&&K&&K.type==="work"&&b(K)}).catch(()=>{}):b(null),v.type==="book"){const K=v;K.contained_in&&K.contained_in.length>0?Promise.all(K.contained_in.map(Y=>{const F=typeof Y=="string"?Y:Y.id,te=typeof Y=="string"?void 0:Y.volume_index;return o.getItem(F).then(je=>({id:F,title:je&&je.title||F,volume_index:te})).catch(()=>({id:F,title:F,volume_index:te}))})).then(Y=>{O||S(Y)}):S([])}else S([]);return()=>{O=!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((O,W)=>t.jsx("div",{style:{height:W===1?"32px":"16px",width:`${O}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},W))})});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(tl,{data:v,transport:o,onNavigate:r,renderLink:s,headerExtra:a})});const $=v.type==="book"?v:null,_=v.type==="collection"?v:null,z=v.type==="work"?v:null;let P=!1;try{P=_e.extractStatus(v.id)==="draft"}catch{}let N="";v.measure_info?N=u(v.measure_info):(D=v.juan_count)!=null&&D.number?N=il(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(zt,{label:p.label.year,children:v.publication_info.year},"year")),(L=v.current_location)!=null&&L.name&&T.push(t.jsx(zt,{label:p.label.currentLocation,children:u(v.current_location.name)},"loc")),(I=v.page_count)!=null&&I.description&&T.push(t.jsx(zt,{label:p.label.pageCount,children:v.page_count.description},"page")),$!=null&&$.edition&&T.push(t.jsx(zt,{label:p.label.edition,children:u($.edition)},"ver")),z!=null&&z.parent_work&&T.push(t.jsx(zt,{label:p.label.parentWork,children:t.jsx(wt,{id:z.parent_work.id,label:u(z.parent_work.title),onNavigate:r,renderLink:s})},"pw")),z!=null&&z.parent_works&&z.parent_works.length>0&&!z.parent_work&&T.push(t.jsx(zt,{label:p.label.parentWork,children:z.parent_works.map((O,W)=>t.jsxs("span",{children:[W>0&&"、",t.jsx(wt,{id:O,onNavigate:r,renderLink:s})]},O))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Uu,{id:v.id,title:u(v.title),edition:v.edition?u(v.edition):void 0,type:v.type,isDraft:P,authors:v.authors,volumeText:N,meta:T,headerExtra:a,onNavigate:r,renderLink:s}),((A=v.description)==null?void 0:A.text)&&t.jsx(At,{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((O,W)=>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(O.title)}),t.jsx(At,{text:O.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},W))}),j.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(bt,{children:p.section.containedIn}),t.jsx(em,{items:j,onNavigate:r,renderLink:s})]}),w&&t.jsxs(t.Fragment,{children:[t.jsx(bt,{children:p.section.belongsToWork}),t.jsx(Qu,{workData:w,onNavigate:r,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Ku,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Gu,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(Yu,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(Vu,{items:v.indexed_by,onNavigate:r,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(al,{items:v.emendated_by,onNavigate:r,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(bt,{children:p.section.resources}),t.jsx(Do,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(qu,{items:$.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&t.jsx(Xu,{items:_.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(ys,{title:p.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&t.jsx(ys,{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(bt,{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(O=>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(wt,{id:O.id,label:u(O.title),onNavigate:r,renderLink:s})},O.id))})]}),(((V=z==null?void 0:z.books)==null?void 0:V.length)||0)+(((q=z==null?void 0:z.collections)==null?void 0:q.length)||0)>0&&t.jsx(Zu,{ids:[...(z==null?void 0:z.books)||[],...(z==null?void 0:z.collections)||[]],workData:z??void 0,transport:o,onNavigate:r,renderLink:s,footer:l}),(z==null?void 0:z.related_works)&&z.related_works.length>0&&(()=>{const O=[],W=z.related_works.filter(oe=>oe.relation==="part_of"),K=z.related_works.filter(oe=>oe.relation==="has_part"),Y=z.related_works.filter(oe=>oe.relation==="has_adaptation"),F=z.related_works.filter(oe=>oe.relation==="text_carried_by"),te=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),je=z.related_works.filter(oe=>!oe.relation||!te.has(oe.relation));return W.length>0&&O.push({label:p.section.belongsToWork,items:W}),K.length>0&&O.push({label:p.section.containedWorks,items:K}),Y.length>0&&O.push({label:p.section.adaptations,items:Y}),F.length>0&&O.push({label:p.section.derivativeWorks,items:F}),je.length>0&&O.push({label:p.section.relatedWorks,items:je}),O.map(oe=>t.jsxs("div",{children:[t.jsxs(bt,{children:[oe.label,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",oe.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:oe.items.map(ie=>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(wt,{id:ie.id,label:u(ie.title),onNavigate:r,renderLink:s})},ie.id))})]},oe.label))})()]})};function tm({data:e}){const n=Ce(),{convert:o}=Pe(),{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 nm({sections:e,activeSection:n,onSelect:o}){const r=Ce();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>o(null),style:js(n===null),children:r.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>o(s.name),style:js(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 js(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 im({id:e,label:n,onNavigate:o,renderLink:r}){const s=tt();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 om(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 vs({book:e,onNavigate:n,renderLink:o,showVolumes:r}){const s=Ce(),{convert:a}=Pe(),l=e.book_id||e.work_id,d=r&&e.volumes.length>0?om(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(im,{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 Ko=({data:e,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:a,style:l})=>{const d=Ce(),[c,p]=h.useState(null),[u,m]=h.useState(!1),[g,f]=h.useState(null),[x,k]=h.useState(null),[y,w]=h.useState(""),b=e||c;h.useEffect(()=>{if(e||!n||!(o!=null&&o.getCollectionCatalog))return;let _=!1;return m(!0),f(null),o.getCollectionCatalog(n).then(z=>{_||(z?p(z):f(d.catalog.notFound))}).catch(z=>{_||f(z instanceof Error?z.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=h.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const _=b.books.map(P=>P.volumes[0]).filter(P=>P!=null);return new Set(_).size<_.length},[b]),v=h.useMemo(()=>{if(!b)return[];let _=b.books;if(x&&(_=_.filter(z=>z.section===x)),y.trim()){const z=y.trim().toLowerCase();_=_.filter(P=>P.title.toLowerCase().includes(z)||P.sub_items&&P.sub_items.some(N=>N.toLowerCase().includes(z))||P.edition&&P.edition.toLowerCase().includes(z))}return _},[b,x,y]),$=h.useMemo(()=>{if(!S)return null;const _=[],z=new Map;for(const N of v){if(!N.volumes||N.volumes.length===0)continue;const T=N.volumes[0];z.has(T)||z.set(T,[]),z.get(T).push(N)}const P=[...z.keys()].sort((N,T)=>N-T);for(const N of P)_.push({volume:N,books:z.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})}):g?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:g}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(tm,{data:b}),j&&t.jsx(nm,{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((_,z)=>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:ht(d.catalog.volume,{n:_.volume})}),_.books.map((P,N)=>t.jsx(vs,{book:P,onNavigate:r,renderLink:s,showVolumes:P.volumes.length>1},`${_.volume}-${N}`))]},`${_.volume}-${z}`)):v.map((_,z)=>t.jsx(vs,{book:_,onNavigate:r,renderLink:s,showVolumes:!0},z)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},rm="guji_markdown";function ho(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 sm=/^□\{guess=([^\s{}]+)\}/;function am(e,n){const o=e[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function cl(e,n){let o=0;for(let r=n;r<e.length;r++){const s=e[r];if(s===`
|
|
146
146
|
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function lm(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function cm(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
147
|
`)<0?{node:{type:"qw",label:e.slice(n+2,r)},end:r+2}:null}if(o===":"&&e.startsWith(":zi[",n)){const r=cl(e,n+3);return r>n+4?{node:{type:"zi",label:lm(e.slice(n+4,r))},end:r+1}:null}if(o==="□"&&e[n+1]==="{"){const r=sm.exec(e.slice(n,n+64));if(r)return{node:{type:"qz",guess:r[1]},end:n+r[0].length}}return null}function dl(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
148
|
`)return null}const c=cm(e,n);if(c){l(),s.push(c.node),n=c.end;continue}let p=null;if(d==="⟨"?p="⟩":d==="<"&&am(e,n)&&(p=">"),p){const u=dl(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 pl(e){return dl(e,0,null,!1).nodes}function dm(e){return/[<⟨□]|\[\[|:zi\[/.test(e)}function ul(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${ul(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const ml="guji-table-v1";function gl(e){return!!e&&e.table_notation===ml}const pm=/^:::table(?:\{[^}]*\})?[ \t]*$/,um=/^:::[ \t]*$/;function hl(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=cl(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 mm=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function gm(e){if(e==="^")return{cont:!0};const n=mm.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 fl(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 g=hl(u).map(gm),f=a.map(w=>w>0),x=a.map(w=>w>0?w-1:0),k=[];let y=0;for(const w of g){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 qo(e){const n=e.split(`
|
|
149
149
|
`),o=[];let r=[];const s=()=>{if(r.length===0)return;const l=r.join(`
|
|
150
150
|
`);r=[],o.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(pm.test(n[a].trim())){let l=a+1;for(;l<n.length&&!um.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);o.push({type:"table",table:fl(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 Ji=e=>e?e.catch(()=>null):Promise.resolve(null);function xl(e){const n=new Map;function o(r){var a;let s=n.get(r);return s||(s=Ji((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
|
|
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 Ji=e=>e?e.catch(()=>null):Promise.resolve(null);function xl(e){const n=new Map;function o(r){var a;let s=n.get(r);return s||(s=Ji((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:Ji(e.getTextIndex(r,s))},async getChapter(r,s,a,l){return!_e.isSafeSegment(r)||!_e.isSafeSegment(s)||!_e.isSafeSegment(a)||!e.getChapter?null:Ji(e.getChapter(r,s,a,l))}}}const tn=()=>{const{t:e}=Q(),[n,o]=h.useState(1);return h.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)})},Qi=String.raw`https?:\/\/[^\s()()<>"]+`,hm=new RegExp(String.raw`\[([^\]\n]+)\]\((${Qi})\)`+String.raw`|(《[^》\n]+》)\s?[((](${Qi})[))]`+`|(${Qi})`,"g");function fm(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function xm(e){const n=[];let o=0;for(const r of e.matchAll(hm)){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:fm(r[5]),url:r[5]}),o=s+r[0].length}return o<e.length&&n.push({text:e.slice(o)}),n}function bl({text:e,convert:n,className:o="bim-rd-link"}){return t.jsx(t.Fragment,{children:xm(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(h.Fragment,{children:n(r.text)},s))})}const yl="(min-width: 1100px)",jl="(max-width: 719px)",vl="(max-width: 859px)",bm=`${jl}, (pointer: coarse)`,$t=i("reader-top"),ym="48px",kl=`
|
|
152
152
|
.bim-rd {
|
|
153
153
|
position: relative;
|
|
154
154
|
background: ${i("page-bg")};
|
|
@@ -671,8 +671,8 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
671
671
|
letter-spacing: 0.05em;
|
|
672
672
|
margin-left: 6px;
|
|
673
673
|
}
|
|
674
|
-
`;function Xo(e,n){var o;return n?e.key===n?!0:!!((o=e.children)!=null&&o.some(r=>Xo(r,n))):!1}const jm=()=>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 vm({item:e,activeKey:n,onSelect:o,tabKey:r}){const s=Xo(e,n),[a,l]=h.useState(s||!!e.defaultExpanded);return h.useEffect(()=>{s&&l(!0)},[s]),h.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(jm,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(wl,{items:e.children,activeKey:n,onSelect:o,tabKey:r})]})}function wl({items:e,activeKey:n,onSelect:o,tabKey:r}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(vm,{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 ks(e,n){var o;for(const r of e)if(r.key===n||Xo(r,n))return r.key;return((o=e[0])==null?void 0:o.key)??null}function Sl({items:e,activeKey:n,onSelect:o,label:r}){const{t:s}=ee(),a=r??s("reader.toc"),l=h.useRef(null),[d,c]=h.useState(null);h.useEffect(()=>{c(null)},[n]);const p=h.useMemo(()=>d||(n??ks(e,n)),[d,n,e]);h.useEffect(()=>{const m=l.current;if(!m)return;const g=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(g.length===0)return;const f=g.find(x=>x.dataset.rdTocKey===p)??g.find(x=>x.dataset.rdTocKey===ks(e,n))??g.find(x=>!x.disabled)??g[0];for(const x of g)x.tabIndex=x===f?0:-1}),h.useEffect(()=>{const m=l.current,g=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!g||!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-g.getBoundingClientRect().top+g.scrollTop;(x<g.scrollTop+80||x>g.scrollTop+g.clientHeight-40)&&(g.scrollTop=Math.max(0,x-g.clientHeight/3))},[n]);const u=h.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(wl,{items:e,activeKey:n,onSelect:o,tabKey:p})})}function km({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 fo({pages:e,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:a}=ee(),[l,d]=h.useState(0),c=o??l,p=f=>{r?r(f):d(f)};if(h.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],g=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:g}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(km,{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 _l=[{key:"song",stack:null},{key:"kai",stack:'"Kaiti SC", "Kaiti TC", STKaiti, "KaiTi", "AR PL UKai CN", "Noto Serif CJK SC", serif'},{key:"system",stack:"var(--bim-font-ui)"}];function wm(e){var n;return((n=_l.find(o=>o.key===e))==null?void 0:n.stack)??null}const Zo={fontSize:null,readingMode:"line",properNames:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song"},Et=[15,16,17,18,20,22,24],xo=18,$l="bim-reader-prefs",Sm="bim-reading-mode";function _m(){const e={...Zo};try{const n=localStorage.getItem($l),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&Et.includes(o.fontSize)&&(e.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(Sm))==="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),(o.fontFamily==="kai"||o.fontFamily==="system")&&(e.fontFamily=o.fontFamily)}catch{}return e}function $m(e){try{localStorage.setItem($l,JSON.stringify(e))}catch{}}function Qn(e,n){const o=e??xo,r=Et;let s=r.indexOf(o);return s<0&&(s=r.indexOf(xo)),r[Math.max(0,Math.min(r.length-1,s+n))]}function Cl(){const[e,n]=h.useState(Zo);h.useEffect(()=>{n(_m())},[]);const o=h.useCallback(r=>{n(s=>{const a={...s,...r};return $m(a),a})},[]);return[e,o]}function bo(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 zl(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 Tl(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 ws=()=>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"})}),Cm=()=>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"})}),zm=()=>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"})}),Ss=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),_s=()=>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 $s(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 Cs(e,n){const[o,r]=h.useState(n);return h.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 zs(){const e=h.useContext(en),{t:n}=ee();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 Tm(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 Nm(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 Nl({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:g,paragraphToggle:f,properNameToggle:x=!0,allowVertical:k,byline:y,current:w,workLinkToggle:b,rail:j,onReportError:S,revisedAt:v,backHref:$,backLabel:_,bottomBar:z=!0,pager:P=!0,pagerUnit:N,versions:T,currentVersionKey:D,onVersionChange:R,versionSource:E=!0,keepChapterOnVersionChange:L=!1,customImagePanel:I,toolbarExtra:A,settingsAnnotate:V,settingsLayout:q,isWarpMode:U,children:O,className:K,style:Y}){const{t:W,convert:ne}=ee(),je=_??W("reader.back"),Q=ne(N??W("reader.unitJuan")),de=h.useId().replace(/:/g,""),We=`bim-rd-toc-${de}`,_e=`bim-rd-text-${de}`,Be=h.useRef(null),Ne=h.useRef(null),X=h.useRef(null),ae=h.useRef(null),le=Cs(yl,!0),ke=Cs(vl,!1),H=z&&ke,[fe,ue]=h.useState(null),[$e,G]=h.useState(!1),Te=h.useRef(null),Ie=`bim-rd-set-${de}`,B=h.useRef(null),oe=h.useRef(null),xe=(J,He)=>{oe.current=He,ue(Je=>Je===J?null:J)},Re=h.useCallback(()=>{var J;ue(null),(J=oe.current)==null||J.focus()},[]);h.useEffect(()=>{H||ue(null)},[H]),h.useEffect(()=>{var J,He;fe&&((He=(J=B.current)==null?void 0:J.querySelector("button:not([disabled])"))==null||He.focus())},[fe]);const[F,me]=h.useState("auto"),te=F==="auto"?le:F==="open",ge=!le,ze=!!I||!!d&&d.length>0,[Ue,Ve]=h.useState(u);h.useEffect(()=>{Ve(u)},[u]);const qe=Ue==="auto"?ze||!!c:Ue==="open",Ze=h.useCallback(J=>{var He;me("auto"),J&&((He=ae.current)==null||He.focus())},[]),Ye=()=>me(te?"closed":"open");h.useEffect(()=>{if(!ge||F!=="open")return;const J=X.current,He=J==null?void 0:J.querySelector('input, [data-rd-toc-key][tabindex="0"]');He==null||He.focus()},[ge,F]);const C=h.useCallback(J=>{s(J),ge&&Ze(!1);const He=Ne.current,Je=Be.current;if(He&&Je&&typeof window<"u"){const St=He.getBoundingClientRect().top-Je.getBoundingClientRect().bottom;St<0&&window.scrollBy({top:St})}},[s,ge,Ze]),ie=h.useMemo(()=>Tl(o),[o]),[re,ve]=h.useState(null),se=zl(T,D!==void 0?D:re),he=(se==null?void 0:se.key)??null,Oe=h.useMemo(()=>ie.map(J=>J.key).join(`
|
|
675
|
-
`),[ie]),Z=h.useRef(null),ye=J=>{J!==he&&(L||(Z.current={key:J,sig:Oe,done:!1}),D===void 0&&ve(J),R==null||R(J))};h.useEffect(()=>{const J=Z.current;if(!J||J.key!==he)return;const He=ie.find(St=>!St.disabled);if(!He)return;const Je=Oe!==J.sig;!Je&&J.done||(Je?Z.current=null:J.done=!0,He.key!==r&&C(He.key))},[he,Oe,ie,r,C]);const Ee=ie.find(J=>J.key===r),Pe=()=>{var J;S==null||S({chapterKey:r,chapterLabel:typeof(Ee==null?void 0:Ee.label)=="string"?Ee.label:void 0,anchor:Tm(Ne.current,((J=Be.current)==null?void 0:J.getBoundingClientRect().bottom)??0),selectedText:Nm(Ne.current)})},we=ie.findIndex(J=>J.key===r),ce=we>0?ie.slice(0,we).reverse().find(J=>!J.disabled):void 0,be=we>=0?ie.slice(we+1).find(J=>!J.disabled):void 0,Fe=m.fontSize??xo,Me=wm(m.fontFamily),jt={...Y,...m.fontSize?{"--bimrd-fs":`${m.fontSize}px`}:null,...Me?{"--bimrd-ff":Me}:null},vt={song:W("reader.fontSong"),kai:W("reader.fontKai"),system:W("reader.fontSystem")},Dt=x||!!V,Ut=!!f||!!b||!!k||!!q,Ge=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ie}-g1`,children:[t.jsx("h3",{id:`${Ie}-g1`,className:"bim-rd-sp-h",children:W("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:W("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":W("reader.font"),value:m.fontFamily,onChange:J=>g({fontFamily:J.target.value}),children:_l.map(J=>t.jsx("option",{value:J.key,children:vt[J.key]},J.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:W("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":W("reader.fontSmaller"),disabled:Fe<=Et[0],onClick:()=>g({fontSize:Qn(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":W("reader.fontLarger"),disabled:Fe>=Et[Et.length-1],onClick:()=>g({fontSize:Qn(m.fontSize,1)}),children:"A+"})]})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:W("reader.script")}),t.jsx(zs,{})]})]}),Dt&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ie}-g2`,children:[t.jsx("h3",{id:`${Ie}-g2`,className:"bim-rd-sp-h",children:W("reader.groupMark")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":!!m.properNames,title:W("reader.properNameTitle"),onClick:()=>g({properNames:!m.properNames}),children:W("reader.properName")}),V]}),Ut&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Ie}-g3`,children:[t.jsx("h3",{id:`${Ie}-g3`,className:"bim-rd-sp-h",children:W("reader.groupLayout")}),f&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":m.readingMode==="paragraph",title:W("reader.paragraphTitle"),onClick:()=>g({readingMode:m.readingMode==="paragraph"?"line":"paragraph"}),children:W("reader.paragraph")}),b&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:m.workLinks,onChange:J=>g({workLinks:J.target.checked})}),t.jsx("span",{children:W("reader.workLinks")})]}),k&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":m.writingMode==="vertical",onClick:()=>g({writingMode:m.writingMode==="vertical"?"horizontal":"vertical"}),children:W("reader.vertical")}),q]})]});return t.jsxs("div",{className:["bim-rd",m.writingMode==="vertical"&&k?"bim-rd-vertical":"",K].filter(Boolean).join(" "),"data-toc":F,"data-img":qe?"open":"closed","data-bb":H?"":void 0,"data-set":!H&&$e?"open":void 0,"data-warp":U?"true":void 0,style:jt,children:[t.jsx("style",{children:kl}),t.jsx("a",{className:"bim-rd-skip",href:`#${_e}`,onClick:J=>{var He,Je,St;J.preventDefault(),(He=Ne.current)==null||He.focus(),(St=(Je=Ne.current)==null?void 0:Je.scrollIntoView)==null||St.call(Je,{block:"start"})},children:W("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Be,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":W("reader.backAria",{label:je}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:je})]}),(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":W("reader.settings"),children:[T&&T.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:se?ne(bo(se)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:W("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:W("reader.versionShort")}),t.jsx("select",{"aria-label":W("reader.version"),value:he??"",onChange:J=>ye(J.target.value),children:T.map(J=>t.jsx("option",{value:J.key,children:ne(bo(J))},J.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),P&&(ce||be)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":W("reader.pagerGroup",{unit:Q}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":W("reader.prevUnit",{unit:Q}),title:ce?typeof ce.label=="string"&&ce.label?W("reader.prevUnitTitle",{unit:Q,label:ce.label}):W("reader.prevUnit",{unit:Q}):W("reader.firstUnit",{unit:Q}),disabled:!ce,onClick:()=>ce&&C(ce.key),children:t.jsx(Cm,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":W("reader.nextUnit",{unit:Q}),title:be?typeof be.label=="string"&&be.label?W("reader.nextUnitTitle",{unit:Q,label:be.label}):W("reader.nextUnit",{unit:Q}):W("reader.lastUnit",{unit:Q}),disabled:!be,onClick:()=>be&&C(be.key),children:t.jsx(zm,{})})]}),P&&(ce||be)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:ae,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":te,"aria-controls":We,onClick:Ye,children:[t.jsx(ws,{}),t.jsx("span",{className:"bim-rd-tlabel",children:W("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":qe,onClick:()=>Ve(qe?"closed":"open"),children:[t.jsx(_s,{}),W("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(zs,{}),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":W("reader.fontSmaller"),disabled:Fe<=Et[0],onClick:()=>g({fontSize:Qn(m.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":W("reader.fontLarger"),disabled:Fe>=Et[Et.length-1],onClick:()=>g({fontSize:Qn(m.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:Te,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":$e,"aria-controls":Ie,onClick:()=>G(J=>!J),children:[t.jsx(Ss,{}),t.jsx("span",{className:"bim-rd-tlabel",children:W("reader.settings")})]}),A]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:We,ref:X,role:ge&&te?"dialog":void 0,"aria-modal":ge&&te?!0:void 0,"aria-label":ge&&te?W("reader.toc"):void 0,onKeyDown:J=>{if(!(!ge||!te)){if(J.key==="Escape"){J.stopPropagation(),Ze(!0);return}J.key==="Tab"&&$s(J,X.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??W("reader.toc")}),ge&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":W("reader.closeToc"),onClick:()=>Ze(!0),children:"✕"})]}),a]}),t.jsx(Sl,{items:o,activeKey:r,onSelect:C})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>Ze(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":W("reader.images"),children:qe&&(I||t.jsx(fo,{pages:d??null,loading:c,renderOverlay:p}))}),!H&&$e&&t.jsxs("aside",{className:"bim-rd-set",id:Ie,"aria-label":W("reader.settings"),onKeyDown:J=>{var He;J.key==="Escape"&&(J.stopPropagation(),G(!1),(He=Te.current)==null||He.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:W("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":W("reader.closeSettings"),onClick:()=>{var J;G(!1),(J=Te.current)==null||J.focus()},children:"✕"})]}),Ge]}),t.jsxs("div",{className:"bim-rd-text",id:_e,ref:Ne,tabIndex:-1,"data-rail":(j||S)&&!U?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[O,E&&se&&(se.sourceName||se.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":se.key,children:[se.sourceName&&t.jsxs(t.Fragment,{children:[W("reader.sourceLabel")," ",se.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:se.sourceUrl,target:"_blank",rel:"noreferrer",children:ne(se.sourceName)}):ne(se.sourceName)]}),se.sourceName&&se.license&&t.jsx("span",{className:"bim-rd-dot"}),se.license&&t.jsx(t.Fragment,{children:W("reader.licenseOf",{license:se.license})})]}),v&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:W("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:J=>J.preventDefault(),onClick:Pe,children:W("reader.reportError")})}),P&&(ce||be)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":W("reader.pagerNav"),children:[ce?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>C(ce.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),W("reader.prevUnit",{unit:Q})]}),t.jsx("span",{className:"bim-rd-pglabel",children:ce.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",W("reader.firstUnit",{unit:Q})]}),be?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>C(be.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[W("reader.nextUnit",{unit:Q}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:be.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[W("reader.lastUnit",{unit:Q})," →"]})]})]}),(j||S)&&!U&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":W("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:J=>J.preventDefault(),onClick:Pe,children:W("reader.reportError")})})]})]})]}),H&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":W("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":te,"aria-controls":We,onClick:()=>{ue(null),Ye()},children:[t.jsx(ws,{}),t.jsx("span",{children:W("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":fe==="img","aria-haspopup":"dialog",onClick:J=>xe("img",J.currentTarget),children:[t.jsx(_s,{}),t.jsx("span",{children:W("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":fe==="set","aria-haspopup":"dialog",onClick:J=>xe("set",J.currentTarget),children:[t.jsx(Ss,{}),t.jsx("span",{children:W("reader.settingsShort")})]}),S&&t.jsxs("button",{type:"button",onMouseDown:J=>J.preventDefault(),onClick:()=>{ue(null),Pe()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:W("reader.reportError")})]})]}),H&&fe&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:Re}),t.jsxs("div",{className:"bim-rd-sheet",ref:B,role:"dialog","aria-modal":"true","aria-label":W(fe==="img"?"reader.images":"reader.settings"),onKeyDown:J=>{if(J.key==="Escape"){J.stopPropagation(),Re();return}J.key==="Tab"&&$s(J,B.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:W(fe==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":W("reader.close"),onClick:Re,children:"✕"})]}),fe==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(fo,{pages:d??null,loading:c,renderOverlay:p})}):Ge]})]})]})}const Rl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Rm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function nt(e){return Rm[e]??e}const un=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],mn={熹平: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},El={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function wi(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 Em(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 Im=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,Ts={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Jo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(Ts))if(n.startsWith(s))return Ts[s];const o=nt(n);if(Kt[o]!=null)return o;const r=Lt(n);if(r&&n.length<=r.length+1)return nt(r)}function Yt(e,n){if(n){const o=El[`${n}|${e}`];if(o!=null)return o}return mn[e]}const Lm=1911;function Am(e){const n=mn[e];if(n==null)return;const o=Tt[e];let r;for(const[s,a]of Object.entries(mn))Tt[s]===o&&a>n&&(r==null||a<r)&&(r=a);return r!=null?r-1:void 0}const Pm={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function di(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=Pm[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 Lt(e){for(const n of Rl)if(e.startsWith(n))return n}const Tt={};{const e=(n,o)=>{for(const r of o)Tt[r]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function qt(e,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(mn))if(e.includes(r)&&!(o&&Tt[r]&&Tt[r]!==o&&El[`${o}|${r}`]==null))return r}function Wn(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=Lt(r)??"";return{era:nt(p),reign:qt(r,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=wi(s);if(p)return{era:Em(p.from),reign:"",source:"publication"};const u=Lt(s)??Jo(s)??((c=un.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",m=qt(s,u)??"",g=u||(m?Tt[m]??"":"");if(g||m)return{era:nt(g),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Lt(a);if(p)return{era:nt(p),reign:qt(a,p)??"",source:"edition"};const u=un.find(m=>m.pattern.test(a));if(u)return{era:nt(u.era),reign:qt(a,u.era)??u.reign??"",source:"edition"}}return n}function Si(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 g=wi(n);if(g)return g.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 g of o){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&g!==f&&(Lt(f)||Jo(f)))break;const x=g.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??g.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=g.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const j=Lt(g);if(!j||nt(j)==="民國"){const v=di(k[1]);if(v!=null&&v>=1&&v<=120)return Lm+v}}const y=Lt(g)??((u=un.find(j=>j.pattern.test(g)))==null?void 0:u.era),w=y?nt(y):void 0,b=qt(g,w)??(Lt(g)||(m=un.find(j=>j.pattern.test(g)))==null?void 0:m.reign);if(b){const j=Yt(b,w);if(j==null)continue;const S=g.indexOf(b),v=S>=0?g.slice(S+b.length):"",$=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=$?di($[1]):void 0;return j+(_?_-1:0)}}}function Qo(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 g=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(g){const f=yo[nt(g[1])],x=Kt[nt(g[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 g=wi(s);if((g==null?void 0:g.to)!=null)return{from:g.from,to:g.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=yo[nt(f[1])],k=Kt[nt(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 g of a){if(!/[間间]/.test(g))continue;const f=Lt(g)??Jo(g)??((m=un.find(y=>y.pattern.test(g)))==null?void 0:m.era),x=f?nt(f):void 0,k=[];for(const y of Object.keys(mn))g.includes(y)&&(x&&Tt[y]&&Tt[y]!==x||Yt(y,x)!=null&&k.push(y));if(k.length===0){const y=g.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const w of[y[1],y[2]])for(const b of Object.keys(mn))if(Tt[b]===x&&!(b[0]!==w&&b[b.length-1]!==w)&&Yt(b,x)!=null){k.push(b);break}}}if(k.length>0){const y=k.map(S=>Yt(S,x)).filter(S=>S!=null),w=Math.min(...y),b=k.reduce((S,v)=>Yt(S,x)>=Yt(v,x)?S:v),j=Am(b)??eo(x??"")??Math.max(...y);return{from:w,to:j>w?j:eo(x??Tt[b]??"")??w}}if(x&&Kt[x]!=null)return{from:Kt[x],to:eo(x)??Kt[x]}}}const Kt={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Mm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Bm=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,Ns=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Rs(e,n){for(const o of Rl){const r=e.indexOf(o);if(r<0)continue;if(o.length===1){const c=e[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!qt(e.slice(r),nt(o)))continue}const s=nt(o);if(s===n)continue;const a=e.slice(r),l=qt(a,s)??"";let d;if(l){const c=Yt(l,s);if(c!=null){const u=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=u?di(u[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const o of un)if(o.pattern.test(e))return{era:nt(o.era),reign:o.reign??""}}function Wm(e){var w,b,j,S,v;const n=Wn(e),o=((w=e.publication_info)==null?void 0:w.year)??"",r=o?wi(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"&&Im.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=Si(e);const g=m==null?Qo(e):void 0;let f;n.source==="publication"&&(c||Ns.test(o))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":Ns.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:g,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&&Bm.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(k.laterRepair={era:$[1]})}const y=Mm.find($=>$.re.test(s));if(y){const $=s.search(y.re),_=s.slice($),z=Rs(_,n.era)??Rs(s,n.era);z&&(k.basedOn={era:z.era,reign:z.reign,year:z.year,relation:y.relation})}return k}const yo={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function eo(e){return yo[e]}function pi(e){const n=Si(e);if(n!=null)return n;const o=Qo(e);if(o)return o.from;const r=Wn(e).era;return r?Kt[r]:void 0}const Es=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function jo(e){const n=Es.indexOf(e);return n===-1?Es.length:n}function Om(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 er(e,n){const o=Oo(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 g=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return g(u)-g(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const u=Qt(p),m=u.includes("text"),g=u.includes("image");m&&g?a.textImage.push(p):m?a.text.push(p):g?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,g;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(g=n==null?void 0:n[p])==null?void 0:g.description,items:u}});return{buckets:d,mirrors:c,total:o.length}}function _i(e,n=fn("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=xi(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 Il(e,n){if(_i(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 Ll(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:Wn(e),year:Si(e),sortYear:pi(e),images:r,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:Fm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:r.length>0}}function Fm(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 Al(e,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!r.has(c.id)).map(c=>Ll(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)=>jo(c)-jo(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Hm(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,g=[];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)):g.push(b)}if(g.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 g.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:g}),{useGrouping:!0,coreIds:u,groupedIds:k}}const Pl=["撰","編","注","校","譯","繪","其他"],Dm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function tr(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of Dm)if(r.test(n))return o;return"其他"}function nr(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Ml(e,n="全部"){const o=new Map;for(const s of e){const a=tr(s);o.set(a,(o.get(a)??0)+1)}const r=[{cls:"全部",label:n,count:e.length}];for(const s of Pl){const a=o.get(s);a&&r.push({cls:s,label:s,count:a})}return r.length>2?r:[]}function Bl(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:An(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 An(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 Um=["〇","一","二","三","四","五","六","七","八","九"],Is=["","十","百","千"];function Wl(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+=Is[d]:r+=Um[l]+Is[d])}return r}function Vm(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function Gm(e){if(e==null||typeof e=="string")return;const n="url"in e&&e.url?e.url:"type"in e&&e.type==="url"?e.details:void 0;return n&&/^https?:\/\//i.test(n)?n:void 0}function Pt(e,n="卷"){var r,s;const o=e;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?Wl(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function Ol(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 Ym=216,Ls="clamp(280px, 23vw, 360px)",Km=1440,vo="(max-width: 719px)",qm=`${vo}, (pointer: coarse)`,Xm=`
|
|
674
|
+
`;function Xo(e,n){var o;return n?e.key===n?!0:!!((o=e.children)!=null&&o.some(r=>Xo(r,n))):!1}const jm=()=>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 vm({item:e,activeKey:n,onSelect:o,tabKey:r}){const s=Xo(e,n),[a,l]=h.useState(s||!!e.defaultExpanded);return h.useEffect(()=>{s&&l(!0)},[s]),h.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(jm,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(wl,{items:e.children,activeKey:n,onSelect:o,tabKey:r})]})}function wl({items:e,activeKey:n,onSelect:o,tabKey:r}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(vm,{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 ks(e,n){var o;for(const r of e)if(r.key===n||Xo(r,n))return r.key;return((o=e[0])==null?void 0:o.key)??null}function Sl({items:e,activeKey:n,onSelect:o,label:r}){const{t:s}=Q(),a=r??s("reader.toc"),l=h.useRef(null),[d,c]=h.useState(null);h.useEffect(()=>{c(null)},[n]);const p=h.useMemo(()=>d||(n??ks(e,n)),[d,n,e]);h.useEffect(()=>{const m=l.current;if(!m)return;const g=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(g.length===0)return;const f=g.find(x=>x.dataset.rdTocKey===p)??g.find(x=>x.dataset.rdTocKey===ks(e,n))??g.find(x=>!x.disabled)??g[0];for(const x of g)x.tabIndex=x===f?0:-1}),h.useEffect(()=>{const m=l.current,g=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!g||!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-g.getBoundingClientRect().top+g.scrollTop;(x<g.scrollTop+80||x>g.scrollTop+g.clientHeight-40)&&(g.scrollTop=Math.max(0,x-g.clientHeight/3))},[n]);const u=h.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(wl,{items:e,activeKey:n,onSelect:o,tabKey:p})})}function km({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 fo({pages:e,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:a}=Q(),[l,d]=h.useState(0),c=o??l,p=f=>{r?r(f):d(f)};if(h.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],g=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:g}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),t.jsx(km,{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 _l=[{key:"song",stack:null},{key:"kai",stack:'"Kaiti SC", "Kaiti TC", STKaiti, "KaiTi", "AR PL UKai CN", "Noto Serif CJK SC", serif'},{key:"system",stack:"var(--bim-font-ui)"}];function wm(e){var n;return((n=_l.find(o=>o.key===e))==null?void 0:n.stack)??null}const Zo={fontSize:null,readingMode:"line",properNames:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song"},Et=[15,16,17,18,20,22,24],xo=18,$l="bim-reader-prefs",Sm="bim-reading-mode";function _m(){const e={...Zo};try{const n=localStorage.getItem($l),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&Et.includes(o.fontSize)&&(e.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(Sm))==="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),(o.fontFamily==="kai"||o.fontFamily==="system")&&(e.fontFamily=o.fontFamily)}catch{}return e}function $m(e){try{localStorage.setItem($l,JSON.stringify(e))}catch{}}function Qn(e,n){const o=e??xo,r=Et;let s=r.indexOf(o);return s<0&&(s=r.indexOf(xo)),r[Math.max(0,Math.min(r.length-1,s+n))]}function Cl(){const[e,n]=h.useState(Zo);h.useEffect(()=>{n(_m())},[]);const o=h.useCallback(r=>{n(s=>{const a={...s,...r};return $m(a),a})},[]);return[e,o]}function bo(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 zl(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 Tl(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 ws=()=>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"})}),Cm=()=>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"})}),zm=()=>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"})}),Ss=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),_s=()=>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 $s(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 Cs(e,n){const[o,r]=h.useState(n);return h.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 zs(){const e=h.useContext(en),{t:n}=Q();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 Tm(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 Nm(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 Nl({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:g,paragraphToggle:f,properNameToggle:x=!0,allowVertical:k,byline:y,current:w,workLinkToggle:b,rail:j,onReportError:S,revisedAt:v,backHref:$,backLabel:_,bottomBar:z=!0,pager:P=!0,pagerUnit:N,versions:T,currentVersionKey:D,onVersionChange:R,versionSource:E=!0,keepChapterOnVersionChange:L=!1,customImagePanel:I,toolbarExtra:A,settingsAnnotate:V,settingsLayout:q,isWarpMode:O,children:W,className:K,style:Y}){const{t:F,convert:te}=Q(),je=_??F("reader.back"),oe=te(N??F("reader.unitJuan")),ie=h.useId().replace(/:/g,""),Be=`bim-rd-toc-${ie}`,we=`bim-rd-text-${ie}`,Oe=h.useRef(null),Te=h.useRef(null),X=h.useRef(null),le=h.useRef(null),de=Cs(yl,!0),ve=Cs(vl,!1),H=z&&ve,[me,ue]=h.useState(null),[$e,G]=h.useState(!1),ze=h.useRef(null),Le=`bim-rd-set-${ie}`,B=h.useRef(null),re=h.useRef(null),he=(J,Ue)=>{re.current=Ue,ue(Je=>Je===J?null:J)},Ne=h.useCallback(()=>{var J;ue(null),(J=re.current)==null||J.focus()},[]);h.useEffect(()=>{H||ue(null)},[H]),h.useEffect(()=>{var J,Ue;me&&((Ue=(J=B.current)==null?void 0:J.querySelector("button:not([disabled])"))==null||Ue.focus())},[me]);const[Re,U]=h.useState("auto"),be=Re==="auto"?de:Re==="open",ee=!de,fe=!!I||!!d&&d.length>0,[Ee,Fe]=h.useState(u);h.useEffect(()=>{Fe(u)},[u]);const Ye=Ee==="auto"?fe||!!c:Ee==="open",Ke=h.useCallback(J=>{var Ue;U("auto"),J&&((Ue=le.current)==null||Ue.focus())},[]),qe=()=>U(be?"closed":"open");h.useEffect(()=>{if(!ee||Re!=="open")return;const J=X.current,Ue=J==null?void 0:J.querySelector('input, [data-rd-toc-key][tabindex="0"]');Ue==null||Ue.focus()},[ee,Re]);const C=h.useCallback(J=>{s(J),ee&&Ke(!1);const Ue=Te.current,Je=Oe.current;if(Ue&&Je&&typeof window<"u"){const St=Ue.getBoundingClientRect().top-Je.getBoundingClientRect().bottom;St<0&&window.scrollBy({top:St})}},[s,ee,Ke]),ne=h.useMemo(()=>Tl(o),[o]),[se,ke]=h.useState(null),ae=zl(T,D!==void 0?D:se),ge=(ae==null?void 0:ae.key)??null,He=h.useMemo(()=>ne.map(J=>J.key).join(`
|
|
675
|
+
`),[ne]),Z=h.useRef(null),ye=J=>{J!==ge&&(L||(Z.current={key:J,sig:He,done:!1}),D===void 0&&ke(J),R==null||R(J))};h.useEffect(()=>{const J=Z.current;if(!J||J.key!==ge)return;const Ue=ne.find(St=>!St.disabled);if(!Ue)return;const Je=He!==J.sig;!Je&&J.done||(Je?Z.current=null:J.done=!0,Ue.key!==r&&C(Ue.key))},[ge,He,ne,r,C]);const Ie=ne.find(J=>J.key===r),Me=()=>{var J;S==null||S({chapterKey:r,chapterLabel:typeof(Ie==null?void 0:Ie.label)=="string"?Ie.label:void 0,anchor:Tm(Te.current,((J=Oe.current)==null?void 0:J.getBoundingClientRect().bottom)??0),selectedText:Nm(Te.current)})},Se=ne.findIndex(J=>J.key===r),ce=Se>0?ne.slice(0,Se).reverse().find(J=>!J.disabled):void 0,xe=Se>=0?ne.slice(Se+1).find(J=>!J.disabled):void 0,De=m.fontSize??xo,We=wm(m.fontFamily),jt={...Y,...m.fontSize?{"--bimrd-fs":`${m.fontSize}px`}:null,...We?{"--bimrd-ff":We}:null},vt={song:F("reader.fontSong"),kai:F("reader.fontKai"),system:F("reader.fontSystem")},Dt=x||!!V,Ut=!!f||!!b||!!k||!!q,Ge=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Le}-g1`,children:[t.jsx("h3",{id:`${Le}-g1`,className:"bim-rd-sp-h",children:F("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:F("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":F("reader.font"),value:m.fontFamily,onChange:J=>g({fontFamily:J.target.value}),children:_l.map(J=>t.jsx("option",{value:J.key,children:vt[J.key]},J.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:F("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":F("reader.fontSmaller"),disabled:De<=Et[0],onClick:()=>g({fontSize:Qn(m.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[De,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":F("reader.fontLarger"),disabled:De>=Et[Et.length-1],onClick:()=>g({fontSize:Qn(m.fontSize,1)}),children:"A+"})]})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:F("reader.script")}),t.jsx(zs,{})]})]}),Dt&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Le}-g2`,children:[t.jsx("h3",{id:`${Le}-g2`,className:"bim-rd-sp-h",children:F("reader.groupMark")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":!!m.properNames,title:F("reader.properNameTitle"),onClick:()=>g({properNames:!m.properNames}),children:F("reader.properName")}),V]}),Ut&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${Le}-g3`,children:[t.jsx("h3",{id:`${Le}-g3`,className:"bim-rd-sp-h",children:F("reader.groupLayout")}),f&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":m.readingMode==="paragraph",title:F("reader.paragraphTitle"),onClick:()=>g({readingMode:m.readingMode==="paragraph"?"line":"paragraph"}),children:F("reader.paragraph")}),b&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:m.workLinks,onChange:J=>g({workLinks:J.target.checked})}),t.jsx("span",{children:F("reader.workLinks")})]}),k&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":m.writingMode==="vertical",onClick:()=>g({writingMode:m.writingMode==="vertical"?"horizontal":"vertical"}),children:F("reader.vertical")}),q]})]});return t.jsxs("div",{className:["bim-rd",m.writingMode==="vertical"&&k?"bim-rd-vertical":"",K].filter(Boolean).join(" "),"data-toc":Re,"data-img":Ye?"open":"closed","data-bb":H?"":void 0,"data-set":!H&&$e?"open":void 0,"data-warp":O?"true":void 0,style:jt,children:[t.jsx("style",{children:kl}),t.jsx("a",{className:"bim-rd-skip",href:`#${we}`,onClick:J=>{var Ue,Je,St;J.preventDefault(),(Ue=Te.current)==null||Ue.focus(),(St=(Je=Te.current)==null?void 0:Je.scrollIntoView)==null||St.call(Je,{block:"start"})},children:F("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Oe,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":F("reader.backAria",{label:je}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:je})]}),(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":F("reader.settings"),children:[T&&T.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:ae?te(bo(ae)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:F("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:F("reader.versionShort")}),t.jsx("select",{"aria-label":F("reader.version"),value:ge??"",onChange:J=>ye(J.target.value),children:T.map(J=>t.jsx("option",{value:J.key,children:te(bo(J))},J.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),P&&(ce||xe)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":F("reader.pagerGroup",{unit:oe}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":F("reader.prevUnit",{unit:oe}),title:ce?typeof ce.label=="string"&&ce.label?F("reader.prevUnitTitle",{unit:oe,label:ce.label}):F("reader.prevUnit",{unit:oe}):F("reader.firstUnit",{unit:oe}),disabled:!ce,onClick:()=>ce&&C(ce.key),children:t.jsx(Cm,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":F("reader.nextUnit",{unit:oe}),title:xe?typeof xe.label=="string"&&xe.label?F("reader.nextUnitTitle",{unit:oe,label:xe.label}):F("reader.nextUnit",{unit:oe}):F("reader.lastUnit",{unit:oe}),disabled:!xe,onClick:()=>xe&&C(xe.key),children:t.jsx(zm,{})})]}),P&&(ce||xe)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:le,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":be,"aria-controls":Be,onClick:qe,children:[t.jsx(ws,{}),t.jsx("span",{className:"bim-rd-tlabel",children:F("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":Ye,onClick:()=>Fe(Ye?"closed":"open"),children:[t.jsx(_s,{}),F("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(zs,{}),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":F("reader.fontSmaller"),disabled:De<=Et[0],onClick:()=>g({fontSize:Qn(m.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":F("reader.fontLarger"),disabled:De>=Et[Et.length-1],onClick:()=>g({fontSize:Qn(m.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:ze,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":$e,"aria-controls":Le,onClick:()=>G(J=>!J),children:[t.jsx(Ss,{}),t.jsx("span",{className:"bim-rd-tlabel",children:F("reader.settings")})]}),A]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Be,ref:X,role:ee&&be?"dialog":void 0,"aria-modal":ee&&be?!0:void 0,"aria-label":ee&&be?F("reader.toc"):void 0,onKeyDown:J=>{if(!(!ee||!be)){if(J.key==="Escape"){J.stopPropagation(),Ke(!0);return}J.key==="Tab"&&$s(J,X.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??F("reader.toc")}),ee&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":F("reader.closeToc"),onClick:()=>Ke(!0),children:"✕"})]}),a]}),t.jsx(Sl,{items:o,activeKey:r,onSelect:C})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>Ke(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":F("reader.images"),children:Ye&&(I||t.jsx(fo,{pages:d??null,loading:c,renderOverlay:p}))}),!H&&$e&&t.jsxs("aside",{className:"bim-rd-set",id:Le,"aria-label":F("reader.settings"),onKeyDown:J=>{var Ue;J.key==="Escape"&&(J.stopPropagation(),G(!1),(Ue=ze.current)==null||Ue.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:F("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":F("reader.closeSettings"),onClick:()=>{var J;G(!1),(J=ze.current)==null||J.focus()},children:"✕"})]}),Ge]}),t.jsxs("div",{className:"bim-rd-text",id:we,ref:Te,tabIndex:-1,"data-rail":(j||S)&&!O?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[W,E&&ae&&(ae.sourceName||ae.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":ae.key,children:[ae.sourceName&&t.jsxs(t.Fragment,{children:[F("reader.sourceLabel")," ",ae.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:ae.sourceUrl,target:"_blank",rel:"noreferrer",children:te(ae.sourceName)}):te(ae.sourceName)]}),ae.sourceName&&ae.license&&t.jsx("span",{className:"bim-rd-dot"}),ae.license&&t.jsx(t.Fragment,{children:F("reader.licenseOf",{license:ae.license})})]}),v&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:F("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:J=>J.preventDefault(),onClick:Me,children:F("reader.reportError")})}),P&&(ce||xe)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":F("reader.pagerNav"),children:[ce?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>C(ce.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),F("reader.prevUnit",{unit:oe})]}),t.jsx("span",{className:"bim-rd-pglabel",children:ce.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",F("reader.firstUnit",{unit:oe})]}),xe?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>C(xe.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[F("reader.nextUnit",{unit:oe}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:xe.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[F("reader.lastUnit",{unit:oe})," →"]})]})]}),(j||S)&&!O&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":F("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:J=>J.preventDefault(),onClick:Me,children:F("reader.reportError")})})]})]})]}),H&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":F("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":be,"aria-controls":Be,onClick:()=>{ue(null),qe()},children:[t.jsx(ws,{}),t.jsx("span",{children:F("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":me==="img","aria-haspopup":"dialog",onClick:J=>he("img",J.currentTarget),children:[t.jsx(_s,{}),t.jsx("span",{children:F("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":me==="set","aria-haspopup":"dialog",onClick:J=>he("set",J.currentTarget),children:[t.jsx(Ss,{}),t.jsx("span",{children:F("reader.settingsShort")})]}),S&&t.jsxs("button",{type:"button",onMouseDown:J=>J.preventDefault(),onClick:()=>{ue(null),Me()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:F("reader.reportError")})]})]}),H&&me&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:Ne}),t.jsxs("div",{className:"bim-rd-sheet",ref:B,role:"dialog","aria-modal":"true","aria-label":F(me==="img"?"reader.images":"reader.settings"),onKeyDown:J=>{if(J.key==="Escape"){J.stopPropagation(),Ne();return}J.key==="Tab"&&$s(J,B.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:F(me==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":F("reader.close"),onClick:Ne,children:"✕"})]}),me==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(fo,{pages:d??null,loading:c,renderOverlay:p})}):Ge]})]})]})}const Rl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Rm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function nt(e){return Rm[e]??e}const un=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],mn={熹平: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},El={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function wi(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 Em(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 Im=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,Ts={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Jo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(Ts))if(n.startsWith(s))return Ts[s];const o=nt(n);if(Kt[o]!=null)return o;const r=Lt(n);if(r&&n.length<=r.length+1)return nt(r)}function Yt(e,n){if(n){const o=El[`${n}|${e}`];if(o!=null)return o}return mn[e]}const Lm=1911;function Am(e){const n=mn[e];if(n==null)return;const o=Tt[e];let r;for(const[s,a]of Object.entries(mn))Tt[s]===o&&a>n&&(r==null||a<r)&&(r=a);return r!=null?r-1:void 0}const Pm={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function di(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=Pm[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 Lt(e){for(const n of Rl)if(e.startsWith(n))return n}const Tt={};{const e=(n,o)=>{for(const r of o)Tt[r]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function qt(e,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(mn))if(e.includes(r)&&!(o&&Tt[r]&&Tt[r]!==o&&El[`${o}|${r}`]==null))return r}function Wn(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=Lt(r)??"";return{era:nt(p),reign:qt(r,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=wi(s);if(p)return{era:Em(p.from),reign:"",source:"publication"};const u=Lt(s)??Jo(s)??((c=un.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",m=qt(s,u)??"",g=u||(m?Tt[m]??"":"");if(g||m)return{era:nt(g),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Lt(a);if(p)return{era:nt(p),reign:qt(a,p)??"",source:"edition"};const u=un.find(m=>m.pattern.test(a));if(u)return{era:nt(u.era),reign:qt(a,u.era)??u.reign??"",source:"edition"}}return n}function Si(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 g=wi(n);if(g)return g.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 g of o){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&g!==f&&(Lt(f)||Jo(f)))break;const x=g.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??g.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=g.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const j=Lt(g);if(!j||nt(j)==="民國"){const v=di(k[1]);if(v!=null&&v>=1&&v<=120)return Lm+v}}const y=Lt(g)??((u=un.find(j=>j.pattern.test(g)))==null?void 0:u.era),w=y?nt(y):void 0,b=qt(g,w)??(Lt(g)||(m=un.find(j=>j.pattern.test(g)))==null?void 0:m.reign);if(b){const j=Yt(b,w);if(j==null)continue;const S=g.indexOf(b),v=S>=0?g.slice(S+b.length):"",$=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=$?di($[1]):void 0;return j+(_?_-1:0)}}}function Qo(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 g=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(g){const f=yo[nt(g[1])],x=Kt[nt(g[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 g=wi(s);if((g==null?void 0:g.to)!=null)return{from:g.from,to:g.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=yo[nt(f[1])],k=Kt[nt(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 g of a){if(!/[間间]/.test(g))continue;const f=Lt(g)??Jo(g)??((m=un.find(y=>y.pattern.test(g)))==null?void 0:m.era),x=f?nt(f):void 0,k=[];for(const y of Object.keys(mn))g.includes(y)&&(x&&Tt[y]&&Tt[y]!==x||Yt(y,x)!=null&&k.push(y));if(k.length===0){const y=g.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const w of[y[1],y[2]])for(const b of Object.keys(mn))if(Tt[b]===x&&!(b[0]!==w&&b[b.length-1]!==w)&&Yt(b,x)!=null){k.push(b);break}}}if(k.length>0){const y=k.map(S=>Yt(S,x)).filter(S=>S!=null),w=Math.min(...y),b=k.reduce((S,v)=>Yt(S,x)>=Yt(v,x)?S:v),j=Am(b)??eo(x??"")??Math.max(...y);return{from:w,to:j>w?j:eo(x??Tt[b]??"")??w}}if(x&&Kt[x]!=null)return{from:Kt[x],to:eo(x)??Kt[x]}}}const Kt={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Mm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Bm=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,Ns=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function Rs(e,n){for(const o of Rl){const r=e.indexOf(o);if(r<0)continue;if(o.length===1){const c=e[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!qt(e.slice(r),nt(o)))continue}const s=nt(o);if(s===n)continue;const a=e.slice(r),l=qt(a,s)??"";let d;if(l){const c=Yt(l,s);if(c!=null){const u=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=u?di(u[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const o of un)if(o.pattern.test(e))return{era:nt(o.era),reign:o.reign??""}}function Wm(e){var w,b,j,S,v;const n=Wn(e),o=((w=e.publication_info)==null?void 0:w.year)??"",r=o?wi(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"&&Im.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=Si(e);const g=m==null?Qo(e):void 0;let f;n.source==="publication"&&(c||Ns.test(o))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":Ns.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:g,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&&Bm.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(k.laterRepair={era:$[1]})}const y=Mm.find($=>$.re.test(s));if(y){const $=s.search(y.re),_=s.slice($),z=Rs(_,n.era)??Rs(s,n.era);z&&(k.basedOn={era:z.era,reign:z.reign,year:z.year,relation:y.relation})}return k}const yo={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function eo(e){return yo[e]}function pi(e){const n=Si(e);if(n!=null)return n;const o=Qo(e);if(o)return o.from;const r=Wn(e).era;return r?Kt[r]:void 0}const Es=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function jo(e){const n=Es.indexOf(e);return n===-1?Es.length:n}function Om(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 er(e,n){const o=Oo(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 g=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return g(u)-g(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const u=Qt(p),m=u.includes("text"),g=u.includes("image");m&&g?a.textImage.push(p):m?a.text.push(p):g?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,g;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(g=n==null?void 0:n[p])==null?void 0:g.description,items:u}});return{buckets:d,mirrors:c,total:o.length}}function _i(e,n=fn("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=xi(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 Il(e,n){if(_i(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 Ll(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:Wn(e),year:Si(e),sortYear:pi(e),images:r,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:Fm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:r.length>0}}function Fm(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 Al(e,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!r.has(c.id)).map(c=>Ll(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)=>jo(c)-jo(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Hm(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,g=[];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)):g.push(b)}if(g.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 g.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:g}),{useGrouping:!0,coreIds:u,groupedIds:k}}const Pl=["撰","編","注","校","譯","繪","其他"],Dm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function tr(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of Dm)if(r.test(n))return o;return"其他"}function nr(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Ml(e,n="全部"){const o=new Map;for(const s of e){const a=tr(s);o.set(a,(o.get(a)??0)+1)}const r=[{cls:"全部",label:n,count:e.length}];for(const s of Pl){const a=o.get(s);a&&r.push({cls:s,label:s,count:a})}return r.length>2?r:[]}function Bl(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:An(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 An(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 Um=["〇","一","二","三","四","五","六","七","八","九"],Is=["","十","百","千"];function Wl(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+=Is[d]:r+=Um[l]+Is[d])}return r}function Vm(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function Gm(e){if(e==null||typeof e=="string")return;const n="url"in e&&e.url?e.url:"type"in e&&e.type==="url"?e.details:void 0;return n&&/^https?:\/\//i.test(n)?n:void 0}function Pt(e,n="卷"){var r,s;const o=e;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?Wl(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function Ol(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 Ym=216,Ls="clamp(280px, 23vw, 360px)",Km=1440,vo="(max-width: 719px)",qm=`${vo}, (pointer: coarse)`,Xm=`
|
|
676
676
|
.bim-d-main.bim-d-main-grid { max-width: ${Km}px; padding: 16px 32px 0; }
|
|
677
677
|
.bim-d-grid {
|
|
678
678
|
display: grid;
|
|
@@ -1156,7 +1156,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1156
1156
|
: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 {
|
|
1157
1157
|
text-decoration-color: currentColor; text-decoration-thickness: 2px;
|
|
1158
1158
|
}
|
|
1159
|
-
`;function On({railTop:e,back:n,up:o,nav:r,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=
|
|
1159
|
+
`;function On({railTop:e,back:n,up:o,nav:r,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=Q(),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:g=>{g.metaKey||g.ctrlKey||(g.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 Fl({caption:e,children:n}){const{convert:o}=Q();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 ot({id:e,title:n,meta:o,action:r,children:s}){const{convert:a}=Q();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 it({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(h.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function Ci({items:e,value:n,onChange:o}){const{convert:r}=Q();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 Hl({label:e,checked:n,onChange:o}){const{convert:r}=Q();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 Dl=6,zi=e=>e>Dl+1;function ir({total:e,shown:n,unit:o,onClick:r}){const{t:s,convert:a}=Q(),l=e-n,d=zi(e)?e-Math.min(n,Dl):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 or({label:e,onClick:n}){const{convert:o}=Q();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(e)})}function Fn({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:g}){const{t:f,convert:x}=Q(),k=(d||[]).filter(S=>S.value!=null&&S.value!==""),y=(c||[]).filter(S=>S.value!=null&&S.value!==""&&S.value!==0),[w,b]=h.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(h.Fragment,{children:[t.jsx("dt",{children:x(S.label)}),t.jsx("dd",{title:S.title,children:S.value})]},v))}),m,p,u,g&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:g})]})}function rr(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function ko({href:e,onClick:n,label:o}){const{t:r,convert:s}=Q(),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 Zt({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:g}=Q(),[f,x]=h.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:[g(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(or,{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 Zm=new Set(["reviewed","disputed","unreviewed","draft"]);function Hn({revision:e,revisedAt:n,review:o,todo:r}){const{t:s,convert:a}=Q(),l=o&&Zm.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(it,{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 ri=1e3,As=208,Jm=1440,Qm="(max-width: 719px)",Ul=`
|
|
1160
1160
|
.bim-d-page {
|
|
1161
1161
|
background: ${i("page-bg")};
|
|
1162
1162
|
color: ${i("ink")};
|
|
@@ -1251,16 +1251,16 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1251
1251
|
padding-right: 0; padding-bottom: 12px;
|
|
1252
1252
|
}
|
|
1253
1253
|
}
|
|
1254
|
-
${Xm}`;function En({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:Ul}),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 wo({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 sr({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 So({items:e}){const n=tt();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(h.Fragment,{children:[a,d]},r)})})}function Vl({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 eg({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 tg({items:e,horizontal:n}){const{convert:o}=
|
|
1255
|
-
`)||(n.push({start:o,end:a+1,inner:l}),o=a)}return n}function ql(e,n){if(e.length<=n)return e;let o=n;for(const r of Kl(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 Xl={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},mg={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 Zl(e,n,o,r){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(h.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:o===0?Xl:void 0,children:Zl(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:mg,children:s.label},a)}})}function ft(e,n=r=>r,o){if(!e)return"";if(o!=null&&o.gujiMarkdown)return dm(e)?Zl(pl(e),n,0,o.t??fn("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 Kl(e))l.start>s&&r.push(t.jsx(h.Fragment,{children:n(e.slice(s,l.start))},a++)),r.push(t.jsx("span",{className:"bim-jiazhu",style:Xl,children:n(l.inner)},a++)),s=l.end;return s<e.length&&r.push(t.jsx(h.Fragment,{children:n(e.slice(s))},a++)),r}function gg({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 hg({title:e,tag:n,children:o}){const{convert:r}=
|
|
1254
|
+
${Xm}`;function En({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:Ul}),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 wo({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 sr({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 So({items:e}){const n=tt();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(h.Fragment,{children:[a,d]},r)})})}function Vl({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 eg({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 tg({items:e,horizontal:n}){const{convert:o}=Pe();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 ng({glyph:e,tone:n,title:o,count:r,actions:s,id:a}){const{convert:l}=Pe();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(sr,{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 Gl({label:e,active:n,onClick:o,dashed:r}){const{convert:s}=Pe();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 ig({label:e,onClick:n}){const{convert:o}=Pe();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 og({label:e,onClick:n,inline:o}){const{convert:r}=Pe();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 Yl({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 rg({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function sg({volumes:e,unit:n,max:o=60}){const{t:r}=Q(),s=n??r("unit.volume"),[a,l]=h.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 ag({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:e})}function lg({spec:e}){const{convert:n}=Pe();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 cg({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 dg(e){return String(e+1).padStart(2,"0")}function pg(){return t.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function ug({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 Kl(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(`
|
|
1255
|
+
`)||(n.push({start:o,end:a+1,inner:l}),o=a)}return n}function ql(e,n){if(e.length<=n)return e;let o=n;for(const r of Kl(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 Xl={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},mg={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 Zl(e,n,o,r){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(h.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:o===0?Xl:void 0,children:Zl(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:mg,children:s.label},a)}})}function ft(e,n=r=>r,o){if(!e)return"";if(o!=null&&o.gujiMarkdown)return dm(e)?Zl(pl(e),n,0,o.t??fn("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 Kl(e))l.start>s&&r.push(t.jsx(h.Fragment,{children:n(e.slice(s,l.start))},a++)),r.push(t.jsx("span",{className:"bim-jiazhu",style:Xl,children:n(l.inner)},a++)),s=l.end;return s<e.length&&r.push(t.jsx(h.Fragment,{children:n(e.slice(s))},a++)),r}function gg({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 hg({title:e,tag:n,children:o}){const{convert:r}=Pe();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 Jl({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 fg({item:e,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{t:s,convert:a}=Q(),[l,d]=h.useState(!1),c=xi(e),p=o&&!!c&&c.expected>0,u=(e.url?xn(e.url):void 0)||a(e.name),m=n?Il(e,n):"",g=m?`${u}(${m})`:u;return t.jsx(Jl,{name:g,note:_i(e,s)||r,href:bn(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(ar,{item:e})]}):void 0})}function ar({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 Ql({label:e,items:n}){const{convert:o}=Pe();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(Yl,{children:o(r)},s))]}):null}function xg({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(Ql,{label:o.label,items:o.items},o.label))}):null}function _o(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function ec({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 bg({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 et({id:e,label:n,onNavigate:o,renderLink:r,style:s,dense:a}){const l=tt();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 yg({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 jg={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},vg={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},kg=`1px solid ${i("table-border")}`,tc={border:kg,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},wg={...tc,background:i("table-head-bg"),fontWeight:600};function lr({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:jg,children:t.jsx("table",{className:"bim-guji-table",style:vg,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?wg:tc,children:s.empty?null:ft(s.text,void 0,n)},a)})},r))})})})}function Sg(e,n){return e.indexOf("**")<0?ft(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?t.jsx("strong",{children:ft(r.trim().slice(2,-2),void 0,n)},s):t.jsx(h.Fragment,{children:ft(r,void 0,n)},s))}function _g(e,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?qo(e).map((s,a)=>s.type==="table"?t.jsx(lr,{table:s.table,opts:r},a):t.jsx(h.Fragment,{children:Sg(s.text,r)},a)):ft(e,void 0,r)}const $g=/^(#{1,6})\s+(.*)$/,Cg=/^\*\*([^*\n]+)\*\*\s*$/;function cr(e){const n=e.match($g);if(n)return{level:n[1].length,text:n[2].trim()};const o=e.trim().match(Cg);return o?{level:3,text:o[1].trim()}:null}const dr=/^<!--.*-->$/;function nc(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function ic(e){return e.split(`
|
|
1256
1256
|
`).map(n=>n.trim()).filter(n=>n&&!dr.test(n))}const zg=60;function oc(e){let n=0,o=0;for(const r of e.split(`
|
|
1257
1257
|
`)){const s=r.trim();if(!s||dr.test(s)||cr(s))continue;const a=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=a,a>zg&&(o+=a)}return n>0&&o*2>=n}function Tg(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function Ti(e){if(e=Tg(e),oc(e))return"unknown";const n=nc(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const o=n.map(s=>ic(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 Ng(e){const n=e.split(`
|
|
1258
1258
|
`),o=[];let r=null,s=[];const a=()=>{o.push({heading:r,body:s.join(`
|
|
1259
1259
|
`)}),s=[]};for(const l of n){const d=cr(l);if(d){a(),r={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),o}function Ps(e){const n=[];for(const o of e.split(`
|
|
1260
1260
|
`)){const r=cr(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||dr.test(s)||n.push({kind:"body",text:o})}return n}function rc(e){if(!e)return[];const n=Ti(e);if(n==="unknown")return Ps(e);const o=[];for(const{heading:r,body:s}of Ng(e)){r&&o.push(r);const a=nc(s);if(a.length!==0){if(oc(s)){o.push(...Ps(s));continue}if(n==="record"){const l=a.join(" ");l&&o.push({kind:"body",text:l})}else for(const l of a){const d=ic(l);d.length&&o.push({kind:"body",text:d.join(" ")})}}}return o}const sc=e=>e;function ac(e,n=sc){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(h.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(h.Fragment,{children:n(e.slice(s))},a++)),o)}function pr(e,n={}){const o=n.renderText??sc,r=n.properNames?a=>ac(a,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return ft(e,r,s)}function Ms(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(h.Fragment,{children:n(s)},`${o}-${a}`))}const to=/^(#{1,6})\s+(.*)$/,Rg=/^\s*<!--.*-->\s*$/;function lc(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
1261
1261
|
`)?"":n)}function Eg(e){return e<=1?2:e===2?3:4}function Ig(){let e=1;return n=>{const o=Eg(n),r=Math.min(o,e+1);return e=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function ui(e){return e?Ti(lc(e))!=="unknown":!1}function Lg(e){return/^\u3000{2}/.test(e)}const Bs=e=>Lg(e)?"bim-rd-noindent":void 0;function Ws({text:e,mode:n,inline:o,dropTitle:r}){const s=lc(e),a=(p,u,m)=>!!r&&m<=1&&p<=2&&u.trim()===r.trim(),l=Ig();if(n==="paragraph"&&Ti(s)!=="unknown"){const p=rc(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:g,className:f}=l(u.level??1);return t.jsx(g,{className:f,children:o(u.text)},m)}return t.jsx("p",{className:Bs(u.text),children:Ms(u.text,o,m)},m)})})}const d=s.split(`
|
|
1262
|
-
`);let c=0;return t.jsx(t.Fragment,{children:d.map((p,u)=>{const m=p.match(to);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()&&!to.test(d[u-1])&&!to.test(d[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(Rg.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:Bs(p),children:Ms(p,o,u)},u)})})}function Ag(e){const{convert:n}=Ae();return h.useMemo(()=>e?n(e):"",[e,n])}function ur({text:e,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:a,dropTitle:l}){const d=Ag(e),{t:c,convert:p}=ee(),u=f=>pr(f,{renderText:a,properNames:s,gujiMarkdown:r,t:c}),m=r?{gujiMarkdown:!0,t:c}:void 0,g=l?p(l):void 0;return!o||d.indexOf(":::")<0?t.jsx(Ws,{text:d,mode:n,inline:u,dropTitle:g}):t.jsx(t.Fragment,{children:qo(d).map((f,x)=>f.type==="table"?t.jsx(lr,{table:f.table,opts:m},x):t.jsx(Ws,{text:f.text,mode:n,inline:u,dropTitle:x===0?g:void 0},x))})}function Pg(e,n,o){const[r,s]=h.useState(null),[a,l]=h.useState(!1),d=h.useRef(0);return h.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 Os={A:"fine",B:"rough",C:"rough",D:"ocr"};function Mg(e){return typeof e!="string"?null:e in xp?e:e in Os?Os[e]:null}const Bg={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},Wg={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},cc="\0";function Og(e,n,o){const[r,s=""]=e.split(cc);return t.jsxs(t.Fragment,{children:[r,t.jsx(bl,{text:n,convert:o}),s]})}function yt(e){return typeof e!="string"?"":Bg[e]??Wg[e]??e}const Fg=["〇","一","二","三","四","五","六","七","八","九"],Fs=["","十","百","千"],Hg=["","萬","億"];function mr(e){if(e===0)return"〇";if(e<0)return`負${mr(-e)}`;const n=[];let o=e,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(Dg(s,r>0)+Hg[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Dg(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+=Fs[d]:s+=Fg[l]+Fs[d]}return s.replace(/〇$/,"")}let Pn=null,ei=null;const mi=new Set;function Ug(){return Pn?Promise.resolve():ei||(ei=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Pn=o=>n(Se.normalizeVariants(o)),mi.forEach(o=>o())}).catch(()=>{Pn=e=>e,mi.forEach(e=>e())}),ei)}const Vg=e=>e;function nn(){const[,e]=h.useState(0);return h.useEffect(()=>{if(Pn)return;const n=()=>e(o=>o+1);return mi.add(n),Ug(),()=>{mi.delete(n)}},[]),Pn??Vg}function gn(e,n){return n(e).toLowerCase()}const Gg=i("highlight-bg");function Dn(e,n,o){if(!n)return e;const r=gn(n,o);if(!r)return e;const s=gn(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:Gg,padding:0,color:"inherit"},children:e.slice(c,c+r.length)},d++)),l=c+r.length}return t.jsx(t.Fragment,{children:a})}function gr(e,n,o,r){if(!n)return!0;const s=gn(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"&&gn(l,r).includes(s))}function Yg(e,n,o){return n?gn(e,o).includes(gn(n,o)):!0}const hr={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},Kg={考证:i("section-kaozhen")};function fr(e,n,o){return e.collated.sectionType[n]??o(n)}function dc(e){var r;const n=e.files.length,o=((r=e.children)==null?void 0:r.reduce((s,a)=>s+dc(a),0))||0;return n+o}function qg(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 Xg={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function xr({enabled:e,expanded:n,onClick:o,style:r,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...Xg,...r},children:s}):t.jsx("span",{style:r,children:s})}function Zg({type:e}){const{convert:n,messages:o}=ee(),r=yt(e),s=hr[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:fr(o,r,n)})}function Jg({section:e,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=ee(),c=tt(),p=nn(),u=j=>j?ft(d(j),S=>o?Dn(S,o,p):S,{t:l}):"",[m,g]=h.useState(!1),f=!!e.summary,x=!!e.comment,k=!!e.additional_comment,y=!!(e.content&&e.content.length>60),w=f||x||k||y;h.useEffect(()=>{o&&g(!0)},[o]);const b=!m&&y?ql(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&&g(!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(xr,{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(mr(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 Qg({section:e,highlightQuery:n=""}){const{t:o,convert:r}=ee(),s=nn(),a=p=>p?ft(r(p),u=>n?Dn(u,n,s):u,{t:o}):"",[l,d]=h.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(xr,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Zg,{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, ${hr[yt(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 eh=100;function br(e){return yt(e.type)!=="page_header"?!1:(e.content||"").length>=eh}function th({section:e,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=ee(),a=nn();if(yt(e.type)==="page_header"&&!br(e)||!e.content&&!e.title)return null;const l=r((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1263
|
-
`)),d=ft(l,m=>n?Dn(m,n,a):m,{t:o}),c=yt(e.type),p=hr[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:fr(s,c,r)}),d]})}function nh(e,n,o){const[r,s]=h.useState({});return h.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 g=await n.getItem(u);if(!g)return null;const f=g.title||u,x=g.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 g;const m=await c(u);return(g=o==null?void 0:o.current)==null||g.set(u,m),[u,m]})).then(u=>{a||s(m=>{const g={...m};for(const[f,x]of u)g[f]=x;return g})}),()=>{a=!0}},[e.join(","),n]),r}function ih({section:e,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=ee(),c=tt(),p=nn(),u=S=>S?ft(l(S),v=>s?Dn(v,s,p):v,{t:a}):"",[m,g]=h.useState(!1);h.useEffect(()=>{s&&g(!0)},[s]);const f=yt(e.type),x=Kg[f]||i("desc-fg"),k=!!e.content,y=e.work_ids||[],w=y.length>1,b=nh(w?y:[],o,r),j=k&&!m&&e.content.length>80?ql(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>k&&g(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[t.jsxs(xr,{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:fr(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 oh({juan:e,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:a}=ee(),l=nn(),d=n.trim(),c=h.useMemo(()=>d?e.sections.filter(p=>gr(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(ih,{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 rh(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function sh({sections:e,onNavigate:n,inline:o,workLinks:r=!0}){const s=tt(),{t:a,convert:l}=ee(),d=rh();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const u=yt(c.type);if(u==="page_header"&&!br(c))return null;if(u==="类")return t.jsxs(h.Fragment,{children:[h.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:mr(c.n_juan)}):""}`:c.title,g=o(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[h.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:g}),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")})]}):g),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 pc(e){return e.some(n=>{const o=yt(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&br(n)})}function ah({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:g,convert:f,messages:x}=ee(),k=nn(),[y,w]=h.useState("text"),b=u??y,j=K=>{w(K),m==null||m(K)},S=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",$=h.useCallback(K=>S?Dn(K,S,k):K,[S,k]),_=K=>pr(K,{renderText:$,properNames:!!p.properNames,t:g}),z=h.useMemo(()=>S?e.sections.filter(K=>gr(K,S,v,k)):e.sections,[e.sections,S,v,k]),P=(K,Y)=>Y.filter(W=>yt(W.type)===K).length,N=P("书",e.sections),T=P("诗",e.sections),D=P("考证",e.sections);let R="";v?R=S?g("collated.countTiaoOf",{m:P("考证",z),n:D}):g("collated.countTiao",{n:D}):T>0?R=S?g("collated.countPoemsOf",{m:P("诗",z),n:T}):g("collated.countPoems",{n:T}):N>0&&(R=S?g("collated.countBooksOf",{m:P("书",z),n:N}):g("collated.countBooks",{n:N}));const E=s!=null&&s.text_quality?Mg(s.text_quality.grade):null,L=[];R&&L.push(R),v&&(s!=null&&s.target_source)&&L.push(t.jsx(t.Fragment,{children:g("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:[Og(g("collated.baseText",{note:cc}),s.text_quality.source_note,f),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[E]})]}):t.jsxs(t.Fragment,{children:[g("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:g("collated.originalSource")}));const I=!v&&pc(e.sections),A=!!n&&(!I||p.readingMode==="paragraph"&&ui(n)),V=!v&&(I||!!n),q=v||!V?"entries":b;let U=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((K,Y)=>t.jsxs(h.Fragment,{children:[Y>0&&t.jsx("span",{className:"bim-rd-dot"}),K]},Y))}),V&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":g("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":q==="text",onClick:()=>j("text"),children:g("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":q==="entries",onClick:()=>j("entries"),children:g("collated.viewEntries")})]})]}),q==="text"&&t.jsx("article",{className:"bim-rd-prose",children:A?t.jsx(ur,{text:n,mode:p.readingMode,properNames:!!p.properNames,renderText:$,dropTitle:e.title}):t.jsx(sh,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),q==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?t.jsx(oh,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[z.some(K=>["书","诗","考证"].includes(yt(K.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:g("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:g("collated.rowHeadTitle")}),t.jsx("span",{children:g("collated.rowHeadWork")})]}),z.map((K,Y)=>{const W=yt(K.type);return W==="书"||W==="诗"||W==="考证"?(U+=1,t.jsx(Jg,{domId:`rd-e-${e.sections.indexOf(K)}`,section:K,onNavigate:p.workLinks?l:void 0,highlightQuery:S,no:U,showUnlinked:p.workLinks&&!!l},Y)):W==="类"?t.jsx(Qg,{section:K,highlightQuery:S},Y):t.jsx(th,{section:K,highlightQuery:S},Y)}),z.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:g("collated.noMatch")})]})})]})}function lh(e){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=nn(),u=h.useRef(new Map),[m,g]=h.useState({}),[f,x]=h.useState({}),k=h.useCallback((w,b)=>{const j=b==null?void 0:b.title;j&&x(S=>S[w]===j?S:{...S,[w]:j})},[]);h.useEffect(()=>{s&&a&&(u.current.set(s,{juan:a,rawText:l}),k(s,a))},[s,a,l,k]),h.useEffect(()=>{u.current.clear(),g({}),x({})},[n]);const y=h.useCallback((w,b)=>{let j=0;if(w.juan)for(const S of w.juan.sections)gr(S,b,c,p)&&j++;return j===0&&w.rawText&&Yg(w.rawText,b,p)&&(j=1),j},[c,p]);return h.useEffect(()=>{const w=d.trim();if(!w){g({});return}if(!o||r.length===0)return;let b=!1;const j={},S=[];for(const P of r){const N=u.current.get(P);N?j[P]=y(N,w):(j[P]="loading",S.push(P))}g(j);const v=8;let $=0;const _=async()=>{for(;$<S.length;){if(b)return;const P=$++,N=S[P];try{const T=await o(N),D=T.juan;if(u.current.set(N,T),k(N,D),b)return;g(R=>({...R,[N]:y(T,w)}))}catch{if(b)return;g(T=>({...T,[N]:0}))}}},z=Array.from({length:Math.min(v,S.length)},()=>_());return Promise.all(z),()=>{b=!0}},[d,n,o,r.join(","),y,p,k]),{matchStates:m,titles:f}}function ch({juan:e,view:n,onView:o,textHasEntries:r}){const{t:s,convert:a}=ee(),l=e.sections.map((u,m)=>({s:u,i:m,t:yt(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 g,f;return(f=(g=document.getElementById(`rd-e-${u}`))==null?void 0:g.scrollIntoView)==null?void 0:f.call(g,{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:g=>{g.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 dh=`
|
|
1262
|
+
`);let c=0;return t.jsx(t.Fragment,{children:d.map((p,u)=>{const m=p.match(to);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()&&!to.test(d[u-1])&&!to.test(d[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(Rg.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:Bs(p),children:Ms(p,o,u)},u)})})}function Ag(e){const{convert:n}=Pe();return h.useMemo(()=>e?n(e):"",[e,n])}function ur({text:e,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:a,dropTitle:l}){const d=Ag(e),{t:c,convert:p}=Q(),u=f=>pr(f,{renderText:a,properNames:s,gujiMarkdown:r,t:c}),m=r?{gujiMarkdown:!0,t:c}:void 0,g=l?p(l):void 0;return!o||d.indexOf(":::")<0?t.jsx(Ws,{text:d,mode:n,inline:u,dropTitle:g}):t.jsx(t.Fragment,{children:qo(d).map((f,x)=>f.type==="table"?t.jsx(lr,{table:f.table,opts:m},x):t.jsx(Ws,{text:f.text,mode:n,inline:u,dropTitle:x===0?g:void 0},x))})}function Pg(e,n,o){const[r,s]=h.useState(null),[a,l]=h.useState(!1),d=h.useRef(0);return h.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 Os={A:"fine",B:"rough",C:"rough",D:"ocr"};function Mg(e){return typeof e!="string"?null:e in xp?e:e in Os?Os[e]:null}const Bg={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},Wg={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},cc="\0";function Og(e,n,o){const[r,s=""]=e.split(cc);return t.jsxs(t.Fragment,{children:[r,t.jsx(bl,{text:n,convert:o}),s]})}function yt(e){return typeof e!="string"?"":Bg[e]??Wg[e]??e}const Fg=["〇","一","二","三","四","五","六","七","八","九"],Fs=["","十","百","千"],Hg=["","萬","億"];function mr(e){if(e===0)return"〇";if(e<0)return`負${mr(-e)}`;const n=[];let o=e,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(Dg(s,r>0)+Hg[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Dg(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+=Fs[d]:s+=Fg[l]+Fs[d]}return s.replace(/〇$/,"")}let Pn=null,ei=null;const mi=new Set;function Ug(){return Pn?Promise.resolve():ei||(ei=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Pn=o=>n(_e.normalizeVariants(o)),mi.forEach(o=>o())}).catch(()=>{Pn=e=>e,mi.forEach(e=>e())}),ei)}const Vg=e=>e;function nn(){const[,e]=h.useState(0);return h.useEffect(()=>{if(Pn)return;const n=()=>e(o=>o+1);return mi.add(n),Ug(),()=>{mi.delete(n)}},[]),Pn??Vg}function gn(e,n){return n(e).toLowerCase()}const Gg=i("highlight-bg");function Dn(e,n,o){if(!n)return e;const r=gn(n,o);if(!r)return e;const s=gn(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:Gg,padding:0,color:"inherit"},children:e.slice(c,c+r.length)},d++)),l=c+r.length}return t.jsx(t.Fragment,{children:a})}function gr(e,n,o,r){if(!n)return!0;const s=gn(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"&&gn(l,r).includes(s))}function Yg(e,n,o){return n?gn(e,o).includes(gn(n,o)):!0}const hr={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},Kg={考证:i("section-kaozhen")};function fr(e,n,o){return e.collated.sectionType[n]??o(n)}function dc(e){var r;const n=e.files.length,o=((r=e.children)==null?void 0:r.reduce((s,a)=>s+dc(a),0))||0;return n+o}function qg(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 Xg={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function xr({enabled:e,expanded:n,onClick:o,style:r,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...Xg,...r},children:s}):t.jsx("span",{style:r,children:s})}function Zg({type:e}){const{convert:n,messages:o}=Q(),r=yt(e),s=hr[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:fr(o,r,n)})}function Jg({section:e,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=Q(),c=tt(),p=nn(),u=j=>j?ft(d(j),S=>o?Dn(S,o,p):S,{t:l}):"",[m,g]=h.useState(!1),f=!!e.summary,x=!!e.comment,k=!!e.additional_comment,y=!!(e.content&&e.content.length>60),w=f||x||k||y;h.useEffect(()=>{o&&g(!0)},[o]);const b=!m&&y?ql(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&&g(!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(xr,{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(mr(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 Qg({section:e,highlightQuery:n=""}){const{t:o,convert:r}=Q(),s=nn(),a=p=>p?ft(r(p),u=>n?Dn(u,n,s):u,{t:o}):"",[l,d]=h.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(xr,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Zg,{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, ${hr[yt(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 eh=100;function br(e){return yt(e.type)!=="page_header"?!1:(e.content||"").length>=eh}function th({section:e,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=Q(),a=nn();if(yt(e.type)==="page_header"&&!br(e)||!e.content&&!e.title)return null;const l=r((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1263
|
+
`)),d=ft(l,m=>n?Dn(m,n,a):m,{t:o}),c=yt(e.type),p=hr[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:fr(s,c,r)}),d]})}function nh(e,n,o){const[r,s]=h.useState({});return h.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 g=await n.getItem(u);if(!g)return null;const f=g.title||u,x=g.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 g;const m=await c(u);return(g=o==null?void 0:o.current)==null||g.set(u,m),[u,m]})).then(u=>{a||s(m=>{const g={...m};for(const[f,x]of u)g[f]=x;return g})}),()=>{a=!0}},[e.join(","),n]),r}function ih({section:e,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=Q(),c=tt(),p=nn(),u=S=>S?ft(l(S),v=>s?Dn(v,s,p):v,{t:a}):"",[m,g]=h.useState(!1);h.useEffect(()=>{s&&g(!0)},[s]);const f=yt(e.type),x=Kg[f]||i("desc-fg"),k=!!e.content,y=e.work_ids||[],w=y.length>1,b=nh(w?y:[],o,r),j=k&&!m&&e.content.length>80?ql(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>k&&g(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[t.jsxs(xr,{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:fr(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 oh({juan:e,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:a}=Q(),l=nn(),d=n.trim(),c=h.useMemo(()=>d?e.sections.filter(p=>gr(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(ih,{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 rh(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function sh({sections:e,onNavigate:n,inline:o,workLinks:r=!0}){const s=tt(),{t:a,convert:l}=Q(),d=rh();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const u=yt(c.type);if(u==="page_header"&&!br(c))return null;if(u==="类")return t.jsxs(h.Fragment,{children:[h.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:mr(c.n_juan)}):""}`:c.title,g=o(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[h.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:g}),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")})]}):g),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 pc(e){return e.some(n=>{const o=yt(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&br(n)})}function ah({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 W;const{t:g,convert:f,messages:x}=Q(),k=nn(),[y,w]=h.useState("text"),b=u??y,j=K=>{w(K),m==null||m(K)},S=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",$=h.useCallback(K=>S?Dn(K,S,k):K,[S,k]),_=K=>pr(K,{renderText:$,properNames:!!p.properNames,t:g}),z=h.useMemo(()=>S?e.sections.filter(K=>gr(K,S,v,k)):e.sections,[e.sections,S,v,k]),P=(K,Y)=>Y.filter(F=>yt(F.type)===K).length,N=P("书",e.sections),T=P("诗",e.sections),D=P("考证",e.sections);let R="";v?R=S?g("collated.countTiaoOf",{m:P("考证",z),n:D}):g("collated.countTiao",{n:D}):T>0?R=S?g("collated.countPoemsOf",{m:P("诗",z),n:T}):g("collated.countPoems",{n:T}):N>0&&(R=S?g("collated.countBooksOf",{m:P("书",z),n:N}):g("collated.countBooks",{n:N}));const E=s!=null&&s.text_quality?Mg(s.text_quality.grade):null,L=[];R&&L.push(R),v&&(s!=null&&s.target_source)&&L.push(t.jsx(t.Fragment,{children:g("collated.kaozhenTarget",{target:f(s.target_source)})})),E&&L.push(t.jsx("span",{title:x.collated.qualityCriteria[E],children:(W=s==null?void 0:s.text_quality)!=null&&W.source_note?t.jsxs(t.Fragment,{children:[Og(g("collated.baseText",{note:cc}),s.text_quality.source_note,f),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[E]})]}):t.jsxs(t.Fragment,{children:[g("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:g("collated.originalSource")}));const I=!v&&pc(e.sections),A=!!n&&(!I||p.readingMode==="paragraph"&&ui(n)),V=!v&&(I||!!n),q=v||!V?"entries":b;let O=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((K,Y)=>t.jsxs(h.Fragment,{children:[Y>0&&t.jsx("span",{className:"bim-rd-dot"}),K]},Y))}),V&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":g("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":q==="text",onClick:()=>j("text"),children:g("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":q==="entries",onClick:()=>j("entries"),children:g("collated.viewEntries")})]})]}),q==="text"&&t.jsx("article",{className:"bim-rd-prose",children:A?t.jsx(ur,{text:n,mode:p.readingMode,properNames:!!p.properNames,renderText:$,dropTitle:e.title}):t.jsx(sh,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),q==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?t.jsx(oh,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[z.some(K=>["书","诗","考证"].includes(yt(K.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:g("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:g("collated.rowHeadTitle")}),t.jsx("span",{children:g("collated.rowHeadWork")})]}),z.map((K,Y)=>{const F=yt(K.type);return F==="书"||F==="诗"||F==="考证"?(O+=1,t.jsx(Jg,{domId:`rd-e-${e.sections.indexOf(K)}`,section:K,onNavigate:p.workLinks?l:void 0,highlightQuery:S,no:O,showUnlinked:p.workLinks&&!!l},Y)):F==="类"?t.jsx(Qg,{section:K,highlightQuery:S},Y):t.jsx(th,{section:K,highlightQuery:S},Y)}),z.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:g("collated.noMatch")})]})})]})}function lh(e){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=nn(),u=h.useRef(new Map),[m,g]=h.useState({}),[f,x]=h.useState({}),k=h.useCallback((w,b)=>{const j=b==null?void 0:b.title;j&&x(S=>S[w]===j?S:{...S,[w]:j})},[]);h.useEffect(()=>{s&&a&&(u.current.set(s,{juan:a,rawText:l}),k(s,a))},[s,a,l,k]),h.useEffect(()=>{u.current.clear(),g({}),x({})},[n]);const y=h.useCallback((w,b)=>{let j=0;if(w.juan)for(const S of w.juan.sections)gr(S,b,c,p)&&j++;return j===0&&w.rawText&&Yg(w.rawText,b,p)&&(j=1),j},[c,p]);return h.useEffect(()=>{const w=d.trim();if(!w){g({});return}if(!o||r.length===0)return;let b=!1;const j={},S=[];for(const P of r){const N=u.current.get(P);N?j[P]=y(N,w):(j[P]="loading",S.push(P))}g(j);const v=8;let $=0;const _=async()=>{for(;$<S.length;){if(b)return;const P=$++,N=S[P];try{const T=await o(N),D=T.juan;if(u.current.set(N,T),k(N,D),b)return;g(R=>({...R,[N]:y(T,w)}))}catch{if(b)return;g(T=>({...T,[N]:0}))}}},z=Array.from({length:Math.min(v,S.length)},()=>_());return Promise.all(z),()=>{b=!0}},[d,n,o,r.join(","),y,p,k]),{matchStates:m,titles:f}}function ch({juan:e,view:n,onView:o,textHasEntries:r}){const{t:s,convert:a}=Q(),l=e.sections.map((u,m)=>({s:u,i:m,t:yt(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 g,f;return(f=(g=document.getElementById(`rd-e-${u}`))==null?void 0:g.scrollIntoView)==null?void 0:f.call(g,{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:g=>{g.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 dh=`
|
|
1264
1264
|
attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
|
|
1265
1265
|
attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
|
|
1266
1266
|
|
|
@@ -1288,7 +1288,7 @@ ${Xm}`;function En({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{clas
|
|
|
1288
1288
|
vec4 tex = texture2D(u_image, v_texCoord);
|
|
1289
1289
|
gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
|
|
1290
1290
|
}
|
|
1291
|
-
`;function Hs(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 $o{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=Hs(o,o.VERTEX_SHADER,dh),s=Hs(o,o.FRAGMENT_SHADER,ph);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 g of l){const f=g.colOffsetX||0,x=g.colOffsetY||0,{srcQuad:k,dstRect:y}=g.strip,[w,b,j,S]=y,v=f+w,$=x+b,[_,z,P,N]=k;for(let T=0;T<m;T++){const D=T/m,R=(T+1)/m,E=$+S*D,L=$+S*R,I=[_[0]+(N[0]-_[0])*D,_[1]+(N[1]-_[1])*D],A=[_[0]+(N[0]-_[0])*R,_[1]+(N[1]-_[1])*R],V=[z[0]+(P[0]-z[0])*D,z[1]+(P[1]-z[1])*D],q=[z[0]+(P[0]-z[0])*R,z[1]+(P[1]-z[1])*R],U=[v,E],O=[v+j,E],K=[v,L],Y=[v+j,L];p.push(U[0],U[1],O[0],O[1],K[0],K[1]),u.push(I[0],I[1],V[0],V[1],A[0],A[1]),p.push(O[0],O[1],Y[0],Y[1],K[0],K[1]),u.push(V[0],V[1],q[0],q[1],A[0],A[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 Bt=new Map,uh=24;function Co(e){let n=Bt.get(e);if(n)return Bt.delete(e),Bt.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=()=>{Bt.delete(e),o(null)},r.src=e}),Bt.set(e,n);Bt.size>uh;)Bt.delete(Bt.keys().next().value);return n}const yr=({imageUrl:e,pageData:n,selectedCharIds:o,hoveredCharId:r,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=h.useRef(null),c=h.useRef(null),p=h.useRef(null),u=h.useRef(null),m=h.useRef(null),g=h.useRef(null),[f,x]=h.useState(0),[k,y]=h.useState(0),w=h.useRef(""),b=h.useMemo(()=>Math.max(...n.columns.map(R=>R.warped_h),2440),[n]),j=n.total_warped_w,S=n.banxin,v=h.useMemo(()=>{var q;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,A=1/0,V=-1/0;for(const U of n.columns)for(const O of U.strips||[])for(const K of O.srcQuad)K[0]<L&&(L=K[0]),K[0]>I&&(I=K[0]),K[1]<A&&(A=K[1]),K[1]>V&&(V=K[1]);if((q=n.banxin)!=null&&q.current_page_strips)for(const U of n.banxin.current_page_strips)for(const O of U.srcQuad)O[0]<L&&(L=O[0]),O[0]>I&&(I=O[0]),O[1]<A&&(A=O[1]),O[1]>V&&(V=O[1]);return isFinite(L)||(L=0),isFinite(I)||(I=R),isFinite(A)||(A=0),isFinite(V)||(V=E),{top:Math.max(0,Math.round(A)),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:A,rawMaxY:V,imgW:R,imgH:E}},[n,s]),$=j+(S?S.total_w:0),_=$+v.left+v.right,z=b+v.top+v.bottom,P=h.useCallback(()=>{const R=c.current;if(!(!R||!d.current)&&!(e&&w.current!==e)){if(R.clear(_,z),s&&v.rawMinX!==void 0&&m.current&&p.current){const{rawMinX:E,rawMaxX:L,rawMinY:I,rawMaxY:A,imgW:V,imgH:q,top:U,bottom:O,left:K,right:Y}=v,W=[];K>0&&W.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[E,0],[E,q],[0,q]],dstRect:[0,0,K,z]}}),U>0&&W.push({colOffsetX:K,colOffsetY:0,strip:{srcQuad:[[E,0],[L,0],[L,I],[E,I]],dstRect:[0,0,$,U]}}),O>0&&W.push({colOffsetX:K,colOffsetY:U+b,strip:{srcQuad:[[E,A],[L,A],[L,q],[E,q]],dstRect:[0,0,$,O]}}),Y>0&&W.push({colOffsetX:K+$,colOffsetY:0,strip:{srcQuad:[[L,0],[V,0],[V,q],[L,q]],dstRect:[0,0,Y,z]}}),R.renderStripsWithTexture(m.current,_,z,n.image_size[0],n.image_size[1],W,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,_,z,n.image_size[0],n.image_size[1],E,1):R.renderStripsWithTexture(m.current,_,z,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,_,z]}}],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,_,z,n.image_size[0],n.image_size[1],L,1)}}if(S&&g.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(g.current,_,z,S.mate_img_size[0],S.mate_img_size[1],E,.65)}}},[e,n,S,_,z,j,b,$,v,s]),N=h.useRef(P);N.current=P,h.useEffect(()=>{const R=d.current;if(!R)return;const E=A=>{m.current=p.current?A.createTexture(p.current):null,g.current=u.current?A.createTexture(u.current):null,N.current()};try{const A=new $o(R);c.current=A,E(A)}catch(A){console.error("Failed to init WebGL renderer:",A)}const L=A=>{A.preventDefault(),console.warn("WebGL context lost")},I=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new $o(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(g.current),c.current.destroy(),c.current=null)}},[]),h.useEffect(()=>{if(!e)return;let R=!0;return Co(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;h.useEffect(()=>{if(!T)return;let R=!0;return Co(T).then(E=>{if(!R||!E)return;u.current=E;const L=c.current;L&&(L.deleteTexture(g.current),g.current=L.createTexture(E)),y(I=>I+1)}),()=>{R=!1}},[T]),h.useEffect(()=>{P()},[P,f,k]);const D=h.useMemo(()=>{const R=[];for(const E of n.columns)for(const L of E.chars){const[I,A,V,q]=L.bbox_col;R.push({id:L.id,char:L.char,x:v.left+E.offset_x+I,y:v.top+A,w:Math.max(V-I,1),h:Math.max(q-A,1)})}return R},[n,v]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${z}`,backgroundColor:i("warp-bg"),boxShadow:i("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:z,style:{width:"100%",height:"100%",display:"block",backgroundColor:i("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${z}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[D.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})]})]})]})},mh={work:"work",book:"work",people:"person",person:"person",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function gh(e){return typeof e=="string"&&mh[e]||"other"}function zo(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 Cn(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Wt(e){return typeof e=="string"&&e?e:void 0}function uc(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=Cn(l.start_offset)??Cn(a.start_offset),p=Cn(l.end_offset)??Cn(a.end_offset);if(c===void 0||p===void 0||c<0||p<=c)return;const u=Wt(d.status),m=u===void 0||u==="matched"?zo(Wt(d.entity_id))??zo(Wt(d.href))??void 0:void 0,g=a.anchor??{},f=Wt(g.start),x=Wt(g.end);o.push({...f&&x?{anchor:{start:f,end:x}}:{},key:Wt(a.id)??`e${s}`,kind:gh(a.type),start:c,end:p,text:Wt(a.text),targetId:m,canonicalName:Wt(d.canonical_name),confidence:Cn(a.confidence)})}),o.sort((r,s)=>r.start-s.start||s.end-r.end)}const hh=new Set(Array.from(`《》/<>\r
|
|
1291
|
+
`;function Hs(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 $o{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=Hs(o,o.VERTEX_SHADER,dh),s=Hs(o,o.FRAGMENT_SHADER,ph);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 g of l){const f=g.colOffsetX||0,x=g.colOffsetY||0,{srcQuad:k,dstRect:y}=g.strip,[w,b,j,S]=y,v=f+w,$=x+b,[_,z,P,N]=k;for(let T=0;T<m;T++){const D=T/m,R=(T+1)/m,E=$+S*D,L=$+S*R,I=[_[0]+(N[0]-_[0])*D,_[1]+(N[1]-_[1])*D],A=[_[0]+(N[0]-_[0])*R,_[1]+(N[1]-_[1])*R],V=[z[0]+(P[0]-z[0])*D,z[1]+(P[1]-z[1])*D],q=[z[0]+(P[0]-z[0])*R,z[1]+(P[1]-z[1])*R],O=[v,E],W=[v+j,E],K=[v,L],Y=[v+j,L];p.push(O[0],O[1],W[0],W[1],K[0],K[1]),u.push(I[0],I[1],V[0],V[1],A[0],A[1]),p.push(W[0],W[1],Y[0],Y[1],K[0],K[1]),u.push(V[0],V[1],q[0],q[1],A[0],A[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 Bt=new Map,uh=24;function Co(e){let n=Bt.get(e);if(n)return Bt.delete(e),Bt.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=()=>{Bt.delete(e),o(null)},r.src=e}),Bt.set(e,n);Bt.size>uh;)Bt.delete(Bt.keys().next().value);return n}const yr=({imageUrl:e,pageData:n,selectedCharIds:o,hoveredCharId:r,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=h.useRef(null),c=h.useRef(null),p=h.useRef(null),u=h.useRef(null),m=h.useRef(null),g=h.useRef(null),[f,x]=h.useState(0),[k,y]=h.useState(0),w=h.useRef(""),b=h.useMemo(()=>Math.max(...n.columns.map(R=>R.warped_h),2440),[n]),j=n.total_warped_w,S=n.banxin,v=h.useMemo(()=>{var q;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,A=1/0,V=-1/0;for(const O of n.columns)for(const W of O.strips||[])for(const K of W.srcQuad)K[0]<L&&(L=K[0]),K[0]>I&&(I=K[0]),K[1]<A&&(A=K[1]),K[1]>V&&(V=K[1]);if((q=n.banxin)!=null&&q.current_page_strips)for(const O of n.banxin.current_page_strips)for(const W of O.srcQuad)W[0]<L&&(L=W[0]),W[0]>I&&(I=W[0]),W[1]<A&&(A=W[1]),W[1]>V&&(V=W[1]);return isFinite(L)||(L=0),isFinite(I)||(I=R),isFinite(A)||(A=0),isFinite(V)||(V=E),{top:Math.max(0,Math.round(A)),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:A,rawMaxY:V,imgW:R,imgH:E}},[n,s]),$=j+(S?S.total_w:0),_=$+v.left+v.right,z=b+v.top+v.bottom,P=h.useCallback(()=>{const R=c.current;if(!(!R||!d.current)&&!(e&&w.current!==e)){if(R.clear(_,z),s&&v.rawMinX!==void 0&&m.current&&p.current){const{rawMinX:E,rawMaxX:L,rawMinY:I,rawMaxY:A,imgW:V,imgH:q,top:O,bottom:W,left:K,right:Y}=v,F=[];K>0&&F.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[E,0],[E,q],[0,q]],dstRect:[0,0,K,z]}}),O>0&&F.push({colOffsetX:K,colOffsetY:0,strip:{srcQuad:[[E,0],[L,0],[L,I],[E,I]],dstRect:[0,0,$,O]}}),W>0&&F.push({colOffsetX:K,colOffsetY:O+b,strip:{srcQuad:[[E,A],[L,A],[L,q],[E,q]],dstRect:[0,0,$,W]}}),Y>0&&F.push({colOffsetX:K+$,colOffsetY:0,strip:{srcQuad:[[L,0],[V,0],[V,q],[L,q]],dstRect:[0,0,Y,z]}}),R.renderStripsWithTexture(m.current,_,z,n.image_size[0],n.image_size[1],F,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,_,z,n.image_size[0],n.image_size[1],E,1):R.renderStripsWithTexture(m.current,_,z,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,_,z]}}],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,_,z,n.image_size[0],n.image_size[1],L,1)}}if(S&&g.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(g.current,_,z,S.mate_img_size[0],S.mate_img_size[1],E,.65)}}},[e,n,S,_,z,j,b,$,v,s]),N=h.useRef(P);N.current=P,h.useEffect(()=>{const R=d.current;if(!R)return;const E=A=>{m.current=p.current?A.createTexture(p.current):null,g.current=u.current?A.createTexture(u.current):null,N.current()};try{const A=new $o(R);c.current=A,E(A)}catch(A){console.error("Failed to init WebGL renderer:",A)}const L=A=>{A.preventDefault(),console.warn("WebGL context lost")},I=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new $o(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(g.current),c.current.destroy(),c.current=null)}},[]),h.useEffect(()=>{if(!e)return;let R=!0;return Co(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;h.useEffect(()=>{if(!T)return;let R=!0;return Co(T).then(E=>{if(!R||!E)return;u.current=E;const L=c.current;L&&(L.deleteTexture(g.current),g.current=L.createTexture(E)),y(I=>I+1)}),()=>{R=!1}},[T]),h.useEffect(()=>{P()},[P,f,k]);const D=h.useMemo(()=>{const R=[];for(const E of n.columns)for(const L of E.chars){const[I,A,V,q]=L.bbox_col;R.push({id:L.id,char:L.char,x:v.left+E.offset_x+I,y:v.top+A,w:Math.max(V-I,1),h:Math.max(q-A,1)})}return R},[n,v]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${_} / ${z}`,backgroundColor:i("warp-bg"),boxShadow:i("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:_,height:z,style:{width:"100%",height:"100%",display:"block",backgroundColor:i("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${_} ${z}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[D.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})]})]})]})},mh={work:"work",book:"work",people:"person",person:"person",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function gh(e){return typeof e=="string"&&mh[e]||"other"}function zo(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 Cn(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Wt(e){return typeof e=="string"&&e?e:void 0}function uc(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=Cn(l.start_offset)??Cn(a.start_offset),p=Cn(l.end_offset)??Cn(a.end_offset);if(c===void 0||p===void 0||c<0||p<=c)return;const u=Wt(d.status),m=u===void 0||u==="matched"?zo(Wt(d.entity_id))??zo(Wt(d.href))??void 0:void 0,g=a.anchor??{},f=Wt(g.start),x=Wt(g.end);o.push({...f&&x?{anchor:{start:f,end:x}}:{},key:Wt(a.id)??`e${s}`,kind:gh(a.type),start:c,end:p,text:Wt(a.text),targetId:m,canonicalName:Wt(d.canonical_name),confidence:Cn(a.confidence)})}),o.sort((r,s)=>r.start-s.start||s.end-r.end)}const hh=new Set(Array.from(`《》/<>\r
|
|
1292
1292
|
,。、;:?!「」『』()…—·`));function jr(e){return!hh.has(e)}function mc(e,n,o=0){const r=[],s=Array.from(e);let a=0;for(const d of s)jr(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 fh(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(jr).join("")===n.text:!0}function xh(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 gc(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||!fh(e,d))&&(d=xh(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 vr=`
|
|
1293
1293
|
.bim-et-w { position: relative; display: inline; }
|
|
1294
1294
|
.bim-et {
|
|
@@ -1329,17 +1329,17 @@ a.bim-et:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 2px;
|
|
|
1329
1329
|
.bim-et-card { animation: bim-et-in 120ms ease-out; }
|
|
1330
1330
|
@keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
|
|
1331
1331
|
}
|
|
1332
|
-
`,bh=120;function mt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function yh(e,n=bh){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 jh(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 vh(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(o=>{if(!o||typeof o!="object")return"";const r=o,s=mt(r.name);return s?[mt(r.dynasty)&&`〔${mt(r.dynasty)}〕`,s,mt(r.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function hc(e,n){const o=mt(n.type),r=mt(n.primary_name)??mt(n.title)??e,s=o==="entity"?[mt(n.dynasty),jh(n),mt(n.native_place)].filter(Boolean).join(" · "):[vh(n),mt(n.edition),mt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?mt(n.description.text):mt(n.description);return{id:e,type:o,title:r,meta:s||void 0,description:yh(a)}}function fc(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 xc(e){return async n=>{const o=await e.getItem(n);if(o)return hc(n,o);if(e.getEntry){const r=await e.getEntry(n);if(r)return fc(r)}return null}}const Ds=new WeakMap;function kh(e,n,o){let r=Ds.get(e);r||(r=new Map,Ds.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 bc=e=>`/item/${encodeURIComponent(e)}`,wh={work:"書名",person:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},Sh=typeof window>"u"?h.useEffect:h.useLayoutEffect;function kr(e,n){return h.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:xc(e)}:null,[n,e])}const _h=e=>e,$h=({text:e,entities:n,offsets:o="text",plainBase:r=0,transport:s,loadSummary:a,buildHref:l=bc,onNavigate:d,renderText:c=_h,hoverDelayMs:p=250,injectStyles:u=!0,className:m})=>{const g=h.useMemo(()=>{const x=o==="plain"?mc(e,n,r):n;return gc(e,x)},[e,n,o,r]),f=kr(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:vr}),g.map(x=>x.type==="text"?t.jsx(h.Fragment,{children:c(x.text)},`t${x.start}`):t.jsx(wr,{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}`))]})},wr=({span:e,label:n,hasBrackets:o,loader:r,buildHref:s,onNavigate:a,renderText:l,hoverDelayMs:d})=>{const c=h.useId(),[p,u]=h.useState(!1),m=h.useRef(null),g=`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)};h.useEffect(()=>k,[]);const y=h.useCallback(j=>{k(),j<=0?u(!0):m.current=setTimeout(()=>u(!0),j)},[]),w=h.useCallback(()=>{k(),u(!1)},[]);if(!e.targetId)return t.jsx("span",{className:g,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:g,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(Ch,{id:c,entityId:b,span:e,loader:r})]})},Ch=({id:e,entityId:n,span:o,loader:r})=>{const{convert:s}=ee(),a=h.useRef(null),[l,d]=h.useState("start"),[c,p]=h.useState(r?{status:"loading"}:{status:"ready",summary:null});h.useEffect(()=>{if(!r)return;let g=!1;return p({status:"loading"}),kh(r.owner,r.load,n).then(f=>{g||p({status:"ready",summary:f})}).catch(()=>{g||p({status:"error"})}),()=>{g=!0}},[r,n]),Sh(()=>{const g=a.current;if(!g||typeof window>"u")return;const f=g.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(wh[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("摘要載入失敗")})]})},zh=e=>`/item/${encodeURIComponent(e)}`;function Th(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 Nh(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 Sr=({pageData:e,pages:n,punctuations:o=Eh,selectedCharIds:r,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:u,convert:m,scrollToPage:g,entities:f,entityTransport:x,loadEntitySummary:k,buildEntityHref:y,onEntityNavigate:w})=>{const b=h.useRef(null),j=h.useRef(0),S=h.useMemo(()=>{const I=new Map;return p&&o.forEach((A,V)=>{const q=A.id?A:{...A,id:`${A.anchor}#${V}`},U=I.get(q.anchor)||[];U.push(q),I.set(q.anchor,U)}),I},[o,p]),v=h.useMemo(()=>(n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}]).filter(A=>A.columns.some(V=>V.chars.length>0)).map(A=>{const V=[...A.columns].sort((O,K)=>O.col-K.col),q=[];let U=[];for(const O of V)for(const K of O.chars){const{before:Y,after:W}=Th(S.get(K.id)||[]),ne=(S.get(K.id)||[]).some(je=>je.kind==="break");U.push({charData:K,col:O.col,beforePuncts:Y,afterPuncts:W}),ne&&(q.push({id:`para-p${A.page}-${q.length}`,chars:U}),U=[])}return U.length>0&&q.push({id:`para-p${A.page}-${q.length}`,chars:U}),{page:A.page,paragraphs:q}}),[n,e,S]),$=h.useMemo(()=>{const I=[];for(const A of v)for(const V of A.paragraphs)for(const q of V.chars)I.push(q.charData.id);return I},[v]),_=h.useMemo(()=>{const I=new Map;if(!f||f.length===0)return I;const A=new Map($.map((V,q)=>[V,q]));for(const V of f){if(!V.anchor)continue;const q=A.get(V.anchor.start),U=A.get(V.anchor.end);if(!(q===void 0||U===void 0||U<q))for(let O=q;O<=U;O++)I.has($[O])||I.set($[O],V)}return I},[f,$]),z=kr(x,k),P=_.size>0,N=h.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=h.useMemo(()=>({click:I=>{var A,V;j.current=Date.now()+1200,(V=(A=N.current).onCharClick)==null||V.call(A,I)},enter:I=>{var A,V;return(V=(A=N.current).onCharHover)==null?void 0:V.call(A,I)},leave:()=>{var I,A;return(A=(I=N.current).onCharHover)==null?void 0:A.call(I,null)},navigate:(I,A)=>{var q,U;if(!(A.detail===0||A.ctrlKey||A.metaKey||A.shiftKey)){A.preventDefault();return}(U=(q=N.current).onEntityNavigate)==null||U.call(q,I,A)}}),[]),D=Ih(r),R=h.useRef(null);h.useEffect(()=>{var A,V;if((A=R.current)==null||A.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]),h.useEffect(()=>{let I=null;const A=()=>{var _e,Be;I=null;const q=window.getSelection(),U=b.current;if(!q||q.isCollapsed||q.rangeCount===0||!U)return;const O=q.getRangeAt(0),K=O.commonAncestorContainer,Y=K.nodeType===3?K.parentElement:K;if(!Y||!U.contains(Y))return;const W=U.querySelectorAll("span[data-char-id]");let ne=0,je=W.length;for(;ne<je;){const Ne=ne+je>>1;O.comparePoint(W[Ne],0)<0?ne=Ne+1:je=Ne}const Q=ne;for(je=W.length;ne<je;){const Ne=ne+je>>1;O.comparePoint(W[Ne],0)<=0?ne=Ne+1:je=Ne}const de=ne-1;if(de<Q)return;const We=[];for(let Ne=Q;Ne<=de;Ne++)We.push(W[Ne].getAttribute("data-char-id"));We.length>0&&(j.current=Date.now()+1200,(Be=(_e=N.current).onSelectionChange)==null||Be.call(_e,We))},V=()=>{I&&clearTimeout(I),I=setTimeout(A,120)};return document.addEventListener("selectionchange",V),()=>{document.removeEventListener("selectionchange",V),I&&clearTimeout(I)}},[]),h.useEffect(()=>{var I;if(r.size===1){const A=Array.from(r)[0],V=(I=b.current)==null?void 0:I.querySelector(`span[data-char-id="${A}"]`);V&&V.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[r]);const E=g==null?void 0:g.nonce;h.useEffect(()=>{var A;if(!g)return;const I=(A=b.current)==null?void 0:A.querySelector(`[data-page-section="${g.page}"]`);I&&(j.current=Date.now()+800,I.scrollIntoView({behavior:"auto",block:"start"}))},[E]);const L=!!u;return h.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 A=120;let V=0;const q=()=>{var ne,je;if(V=0,Date.now()<j.current)return;let K=0,Y=I.length-1;for(;K<Y;){const Q=K+Y+1>>1;I[Q].getBoundingClientRect().top<=A?K=Q:Y=Q-1}const W=parseInt(I[K].getAttribute("data-page-section")||"",10);isNaN(W)||(je=(ne=N.current).onVisiblePageChange)==null||je.call(ne,W)},U=()=>{V||(V=requestAnimationFrame(q))};return window.addEventListener("scroll",U,{passive:!0}),q(),()=>{window.removeEventListener("scroll",U),V&&cancelAnimationFrame(V)}},[L,v]),t.jsxs("div",{ref:b,className:"guji-text-pane-content",children:[P&&t.jsx("style",{children:vr}),t.jsx("div",{className:"guji-text-reflow-view",children:v.map((I,A)=>t.jsx(Ah,{pGroup:I,first:A===0,selected:D.get(I.page)??Rh,entityOfChar:_,entityLoader:z,convert:m,buildHref:y??zh,handlers:T},`page-sec-${I.page}`))})]})},Rh=new Set,Eh=[];function Ih(e){const n=h.useRef(new Map);return h.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 Lh(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 Ah=h.memo(function({pGroup:n,first:o,selected:r,entityOfChar:s,entityLoader:a,convert:l,buildHref:d,handlers:c}){const p=h.useMemo(()=>{const m=new Map;if(!l)return m;for(const g of n.paragraphs){const f=Lh(g.chars.map(x=>x.charData.char),l);g.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:Nh(m.chars,s).map((g,f)=>{const x=g.chars.map(({charData:w,col:b,beforePuncts:j,afterPuncts:S},v)=>{const $=!!g.entity&&v===0,_=!!g.entity&&v===g.chars.length-1,z=$?[]:j,P=_?[]:S;return t.jsxs(h.Fragment,{children:[z.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)}),P.map(N=>t.jsx("span",{className:"guji-text-punct","data-punct-id":N.id,children:N.mark},N.id))]},w.id)});if(!g.entity)return t.jsx(h.Fragment,{children:x},`r${f}`);const k=g.chars[0].beforePuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id)),y=g.chars[g.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(h.Fragment,{children:[k,t.jsx(wr,{span:g.entity,label:g.chars.map(w=>u(w.charData)).join(""),hasBrackets:!0,loader:a,buildHref:d,onNavigate:c.navigate,renderText:()=>x,hoverDelayMs:250}),y]},`${g.entity.key}@${f}`)})},m.id))]})}),yc=1,jc=6,ti={s:1,x:0,y:0},si=(e,n,o)=>Math.min(o,Math.max(n,e));function _r(e,n,o){const r=si(e.s,yc,jc);return{s:r,x:si(e.x,n*(1-r),0),y:si(e.y,o*(1-r),0)}}function no(e,n,o,r,s,a){const l=si(e.s*r,yc,jc),d=l/e.s;return _r({s:l,x:n-(n-e.x)*d,y:o-(o-e.y)*d},s,a)}function Ph(e,n,o,r,s){return _r({s:e.s,x:e.x+n,y:e.y+o},r,s)}function Mh(e,n,o){const r=n===1?e*16:n===2?e*400:e;return Math.exp(-r*(o?.01:.0015))}const Us=4,Bh=h.forwardRef(function({children:n,onScaleChange:o,resetKey:r,style:s},a){const l=h.useRef(null),[d,c]=h.useState(ti),p=h.useRef(d),u=h.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))},g=()=>{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}};h.useImperativeHandle(a,()=>({zoomBy(b){const{w:j,h:S}=g();m(no(p.current,j/2,S/2,b,j,S))},reset(){m(ti)}})),h.useEffect(()=>{m(ti)},[r]),h.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{const{w:S,h:v}=g(),$=_r(p.current,S,v);($.x!==p.current.x||$.y!==p.current.y)&&m($)});return j.observe(b),()=>j.disconnect()},[]),h.useEffect(()=>{const b=l.current;if(!b)return;const j=S=>{const v=Mh(S.deltaY,S.deltaMode,S.ctrlKey);if(p.current.s<=1&&v<1)return;S.preventDefault();const{w:$,h:_,left:z,top:P}=g();m(no(p.current,S.clientX-z,S.clientY-P,v,$,_))};return b.addEventListener("wheel",j,{passive:!1}),()=>b.removeEventListener("wheel",j)},[]);const f=h.useRef(new Map),x=h.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=Us+1}},y=b=>{var D;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:z,top:P}=g();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-z,A=(R.y+E.y)/2-P;m(no(p.current,I,A,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<=Us)){if(!v.dragging){v.dragging=!0;try{(D=l.current)==null||D.setPointerCapture(b.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&m(Ph(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(ti),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 vc(e,n,o,r,s){const[a,l]=h.useState(n??null),[d,c]=h.useState(!1),p=h.useRef(0);return h.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(g=>{u===p.current&&l(g??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 Wh(e,n,o){const[r,s]=h.useState([]),a=h.useRef(0);return h.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?uc(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,o]),r}const Vs={padding:24,color:i("desc-fg"),fontSize:14};function Gs({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 Ys=/^https?:\/\//i;function Oh(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&&Ys.test(o)?o:void 0,license:n(e.license),license_url:r&&Ys.test(r)?r:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Fh(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 Hh(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 kc(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 Dh(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 g=a.get(u);return{key:u,label:m??(g?kc(g,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(g=>a.has(g))||((m=u.children)==null?void 0:m.length)});if(c&&c.length>0){const u=(m,g)=>{var x;if(m.files.length===1&&!((x=m.children)!=null&&x.length))return d(m.files[0],r(m.label));const f=qg(m,n);return{key:`group:${g}`,label:r(m.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:dc(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,`${g}.${y}`))]}};return c.map((m,g)=>u(m,`${g}`))}return e.chapters.map(u=>d(u.file))}const $r=({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:g,revisedAt:f,backHref:x,backLabel:k,resolveWarpData:y,warpData:w,resolveEntities:b,onEntityNavigate:j,className:S,style:v})=>{var Gr,Yr,Kr;const{t:$,convert:_}=ee(),z=h.useMemo(()=>xl(n),[n]),[P,N]=Cl(),T=tt(),D=h.useRef(s);D.current=s;const[R,E]=h.useState(null),[L,I]=h.useState("loading");h.useEffect(()=>{let M=!1;return E(null),I("loading"),z.getManifest(e).then(pe=>{M||(pe?(E(pe),I("ready")):I("missing"))}).catch(()=>{M||I("missing")}),()=>{M=!0}},[z,e]);const A=o!==void 0,V=r!==void 0,[q,U]=h.useState(null),[O,K]=h.useState(null);h.useEffect(()=>{U(null),K(null)},[e]);const Y=Se.pickTextVersion(R,A?o:q),W=((Gr=R==null?void 0:R.versions.find(M=>M.key==="default"))==null?void 0:Gr.key)??((Yr=R==null?void 0:R.versions[0])==null?void 0:Yr.key)??"default",ne=(Y==null?void 0:Y.key)??null,je=V?r:O,Q=h.useCallback((M,pe,Le)=>{var De;(De=D.current)==null||De.call(D,{key:M,chapter:pe,isDefault:M===W},Le)},[W]);h.useEffect(()=>{!R||!A||o==null||R.versions.some(M=>M.key===o)||Q(W,null,"auto")},[R,A,o,W,Q]);const de=h.useRef(new Map);h.useEffect(()=>{de.current.clear()},[z,e]);const We=h.useCallback(async M=>{const pe=`${e}
|
|
1333
|
-
${M}`;if(
|
|
1334
|
-
${
|
|
1335
|
-
${
|
|
1336
|
-
${
|
|
1337
|
-
${H.file}`:null,[B,
|
|
1338
|
-
${
|
|
1339
|
-
${H.file}`;
|
|
1340
|
-
${
|
|
1341
|
-
${
|
|
1342
|
-
${ke??""}`,[Je,St]=h.useState({key:He,data:C,started:!!C});if(Je.key!==He)St({key:He,data:C,started:!1});else if(C!==Je.data&&(St({key:He,data:C,started:!!C}),C)){const M=C.pages??[];(!Je.started||!M.some(pe=>pe.page===Ge))&&J(Ut(C))}h.useEffect(()=>{Oe(new Set),ye(null)},[ke,ne]);const Vd=h.useCallback(M=>{if(Oe(new Set(M)),M.length>0){const pe=M[0],Le=parseInt(pe.split(":")[0],10);isNaN(Le)||J(Le)}},[]),Mt=h.useMemo(()=>{const M=new Map;for(const pe of(C==null?void 0:C.pages)??[])M.set(pe.page,pe);return M},[C]),jn=Dt(C),Gn=h.useCallback(M=>{var De;const pe=Ye.images;if(!pe||pe.length===0)return;const Le=(De=Mt.get(M))==null?void 0:De.seq;return(Le?pe.find(Qe=>Qe.seq===Le):void 0)??pe.find(Qe=>Qe.pageNo===M)??pe[M-1]},[Ye.images,Mt]),Fr=Fe>1.5,Yn=h.useCallback((M,pe=!1)=>{const Le=Gn(M);return Le?M===jn||pe?Le.hiresUrl??Le.url:Le.url:M===jn?(C==null?void 0:C.imageUrl)??"":""},[Gn,C,jn]),Gd=h.useMemo(()=>Yn(Ge,Fr),[Yn,Ge,Fr]),vn=h.useMemo(()=>[...Mt.keys()].sort((M,pe)=>M-pe),[Mt]),Wi=h.useRef(Ge);Wi.current=Ge;const kn=h.useCallback(M=>{var Qe;const pe=Wi.current,Le=vn.indexOf(pe),De=vn[Le<0?0:Le+M];De===void 0||De===pe||(Wi.current=De,J(De),(Qe=Mt.get(De))!=null&&Qe.columns.some(at=>at.chars.length>0)&&vt(at=>({page:De,nonce:((at==null?void 0:at.nonce)??0)+1})))},[vn,Mt]),Oi=vn.indexOf(Ge),Yd=h.useCallback(M=>{if(M.altKey||M.ctrlKey||M.metaKey)return;const pe=M.target.tagName;pe==="INPUT"||pe==="TEXTAREA"||pe==="SELECT"||(M.key==="ArrowLeft"||M.key==="PageUp"?(M.preventDefault(),kn(-1)):(M.key==="ArrowRight"||M.key==="PageDown")&&(M.preventDefault(),kn(1)))},[kn]);h.useEffect(()=>{if(C)for(const M of[1,-1,2,3]){const pe=Yn(Ge+M);pe&&Co(pe)}},[C,Ge,Yn]);const Hr=h.useMemo(()=>{var Jr;if(!C)return null;if(Ge===jn)return C;const M=Mt.get(Ge);if(M&&M.width>0&&M.height>0)return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[M.width,M.height],total_warped_w:M.width,columns:[{col:1,warped_w:M.width,warped_h:M.height,offset_x:0,strips:[],chars:M.columns.flatMap(Xe=>Xe.chars).map(Xe=>({id:Xe.id,char:Xe.char,slot:Xe.slot,pos:Xe.pos,sub:Xe.sub,bbox_col:Xe.bbox??[0,0,0,0]}))}]};const pe=(Jr=C.pages)==null?void 0:Jr.find(Xe=>Xe.page===Ge),[Le,De]=C.image_size||[2386,3082],Qe=Gn(Ge),at=(Qe==null?void 0:Qe.width)??Le,Vi=(Qe==null?void 0:Qe.height)??De,qr=at/Le,Xr=Vi/De,Zr=new Map;for(const Xe of C.columns){const ut=(Xe.strips||[]).flatMap(Xn=>Xn.srcQuad.map(Zn=>Zn[0]));if(ut.length===0)continue;const Nt=Xe.top_y??0,Gi=Xe.bottom_y??Nt+Xe.warped_h;Zr.set(Xe.col,{x0:Math.min(...ut),x1:Math.max(...ut),top:Nt,slotH:(Gi-Nt)/21})}return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[at,Vi],total_warped_w:at,columns:pe?pe.columns.map(Xe=>{const ut=Zr.get(Xe.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Xe.col,warped_w:at,warped_h:Vi,offset_x:0,strips:[],chars:Xe.chars.map(Nt=>{const Gi=Nt.slot??Nt.pos??0,Xn=(ut.top+(Gi-1)*ut.slotH)*Xr,Zn=(ut.x0+ut.x1)/2,[tp,np]=Nt.sub==="a"?[Zn,ut.x1]:Nt.sub==="b"?[ut.x0,Zn]:[ut.x0,ut.x1];return{...Nt,bbox_col:[tp*qr,Xn,np*qr,Xn+ut.slotH*Xr]}})}}):[]}},[C,Ge,jn,Mt,Gn]),{entryTitle:Kn,authors:Dr}=Gh(e,n,l===void 0),[Ur,Fi]=h.useState("text");if(h.useEffect(()=>{Fi("text")},[ke,ne]),L==="loading")return t.jsx(Gs,{className:S,style:v,title:l??Kn,label:$("reader.loading")});if(L==="missing"||!R||!Y)return t.jsx("div",{className:S,style:{...v,...Vs},children:$("reader.noText")});if(Ne==="failed")return t.jsx("div",{className:S,style:{...v,...Vs},children:$("reader.tocFailed")});if(!le)return t.jsx(Gs,{className:S,style:v,title:l??Kn,label:$("reader.tocLoading")});const Vt=Hh(Y,le),Kd=Dh(le,Ve,Vt,_,F),Hi=R.versions.map(M=>({key:M.key,label:Se.textVersionLabel(M),optionLabel:_(Se.textVersionLabel(M)),sourceName:M.source_name?_(M.source_name):void 0,license:M.license??void 0,sourceUrl:M.source_url??void 0,primary:M.key===W})),pt=Oh((Kr=le.source)==null?void 0:Kr.upstream),qn=(typeof l=="string"?_(l):l)??(le.title?_(le.title):Kn?_(Kn):void 0),qd=qn?t.jsx("a",{href:T(e),title:$("reader.viewEntry"),onClick:a?M=>{M.metaKey||M.ctrlKey||(M.preventDefault(),a(e))}:void 0,children:qn}):void 0,Xd=Dr.length>0?_(Dr.slice(0,2).map(M=>`${M.dynasty?`〔${M.dynasty}〕`:""}${M.name}${` ${M.role||$("reader.defaultRole")}`}`).join("、")):void 0,Di=H?kc(H,Vt,_,F):void 0,on=F&&!!(G!=null&&G.json),Gt=(G==null?void 0:G.json)??null,rn=(G==null?void 0:G.md)??null,Vr=on&&!ze&&pc(Gt.sections),Zd=Vr&&!(rn&&se.readingMode==="paragraph"&&ui(rn)),Jd=on&&Vr?t.jsx(ch,{juan:Gt,view:Ur,onView:Fi,textHasEntries:Zd}):void 0,Qd=gl(le)||ho(le),Ui=rn?rn.replace(/^##\s+[^\n]+\n+/,""):null,ep=(typeof d=="string"?_(d):d)??(Y.source_name?_(Y.source_name):_(Se.textVersionLabel(Y)));return t.jsxs(Nl,{className:S,style:v,title:qd,subtitle:ep,byline:Xd,current:Di,pagerUnit:Vt,rail:Jd,revisedAt:f,backHref:x,backLabel:k,onReportError:g?M=>g({...M,bookTitle:typeof qn=="string"?qn:void 0,entryId:e}):void 0,workLinkToggle:on&&!ze&&!!a&&!!(Gt!=null&&Gt.sections.some(M=>M.work_id)),toc:Kd,tocCaption:$("reader.tocCaption",{n:le.chapters.length,unit:_(Vt)}),tocHeader:F&&le.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:ze?$("reader.searchChaptersPlaceholder"):$("reader.searchUnitPlaceholder",{unit:_(Vt)}),"aria-label":ze?$("reader.searchChapters"):$("reader.searchUnit",{unit:_(Vt)}),value:me,onChange:M=>te(M.target.value)}):void 0,activeKey:ke??null,onSelect:$e,images:Ye.images,imagesLoading:Ye.loading||ie,renderImageOverlay:p,imagePanel:C?"open":u,isWarpMode:!!C,customImagePanel:C&&Hr?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Yd,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:Oi<=0,onClick:()=>kn(-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:Oi<0||Oi>=vn.length-1,onClick:()=>kn(1),children:"›"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[he.size>0&&t.jsxs("button",{type:"button",onClick:()=>Oe(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:Fe<=1,onClick:()=>{var M;return(M=be.current)==null?void 0:M.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(Fe*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:Fe>=6,onClick:()=>{var M;return(M=be.current)==null?void 0:M.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:Fe===1,onClick:()=>{var M;return(M=be.current)==null?void 0:M.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Bh,{ref:be,resetKey:Ge,onScaleChange:Me,style:{flex:1,minHeight:0},children:t.jsx(yr,{imageUrl:Gd,pageData:Hr,selectedCharIds:he,hoveredCharId:Z,preserveMargins:we,onCharClick:M=>{Oe(Le=>{const De=new Set(Le);return De.has(M)?De.delete(M):(De.clear(),De.add(M)),De});const pe=document.querySelector(`[data-char-id="${M}"]`);pe&&pe.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ye})})]}):void 0,settingsAnnotate:C?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${Ee?"bim-rd-on":""}`,"aria-pressed":Ee,title:"切换外挂现代断句标点",onClick:()=>Pe(M=>!M),children:Ee?"标点":"无标点"}):void 0,settingsLayout:C?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-badge-warp",children:"图文对读"}),t.jsxs("div",{role:"group","aria-label":"书影留白",style:{display:"inline-flex",border:`1px solid ${i("rule")}`,borderRadius:4,overflow:"hidden"},children:[t.jsx("button",{type:"button",onClick:()=>ce(!1),"aria-pressed":!we,className:`bim-rd-t ${we?"":"bim-rd-on"}`,style:{padding:"6px 12px",border:"none",borderRadius:0,background:we?"transparent":"var(--bimrd-on-bg)",color:we?"inherit":i("ink")},title:"去空白:紧凑裁切版心",children:"去空白"}),t.jsx("button",{type:"button",onClick:()=>ce(!0),"aria-pressed":we,className:`bim-rd-t ${we?"bim-rd-on":""}`,style:{padding:"6px 12px",border:"none",borderRadius:0,background:we?"var(--bimrd-on-bg)":"transparent",color:we?i("ink"):"inherit"},title:"保留空白:完整呈现古籍天头地脚与白边",children:"保留空白"})]})]}):void 0,prefs:se,onPrefsChange:N,versions:Hi.length>1?Hi:void 0,currentVersionKey:Hi.length>1?Y.key:void 0,onVersionChange:ue,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:ui(rn),allowVertical:m,children:[xe&&t.jsx(tn,{}),!xe&&C&&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:H!=null&&H.title?_(H.title):Di}),(Y.source_name||Y.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[Y.source_name&&_(Y.source_name),Y.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),Y.license]})]})]}),t.jsx(Sr,{pageData:C,pages:C.pages,punctuations:C.punctuations||[],selectedCharIds:he,hoveredCharId:Z,onSelectionChange:Vd,onCharClick:M=>{Oe(Le=>{const De=new Set(Le);return De.has(M)?De.delete(M):(De.clear(),De.add(M)),De});const pe=parseInt(M.split(":")[0],10);isNaN(pe)||J(pe)},onCharHover:ye,mode:"horizontal",showPunctuation:Ee,entities:se.properNames?re:void 0,entityTransport:n,onEntityNavigate:j,onVisiblePageChange:M=>J(M),convert:_,scrollToPage:jt})]}),!xe&&!C&&on&&Gt&&t.jsx(ah,{juan:Gt,rawText:rn,positionLabel:Uh(H,le,Vt,_),groupLabel:Vh(le,ke??null),index:Fh(e,le),searchQuery:me,onNavigate:a,transport:n,workLabelCache:qe,prefs:se,view:Ur,onViewChange:Fi},`${ne}/${ke}`),!xe&&!C&&!on&&Ui!=null&&H&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:H.title?_(H.title):Di}),(Y.source_name||Y.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[Y.source_name&&t.jsxs(t.Fragment,{children:[$("reader.textSource")," ",Y.source_url?t.jsx("a",{className:"bim-rd-link",href:Y.source_url,target:"_blank",rel:"noreferrer",children:_(Y.source_name)}):_(Y.source_name)]}),Y.source_name&&Y.license&&t.jsx("span",{className:"bim-rd-dot"}),Y.license]}),pt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[$("reader.upstream")," ",pt.url?t.jsx("a",{className:"bim-rd-link",href:pt.url,target:"_blank",rel:"noreferrer",children:_(pt.name??pt.url)}):_(pt.name??""),pt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),pt.license_url?t.jsx("a",{className:"bim-rd-link",href:pt.license_url,target:"_blank",rel:"noreferrer",children:pt.license}):pt.license]}),pt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(bl,{text:pt.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(ur,{text:Ui,mode:se.readingMode,tables:Qd,gujiMarkdown:ho(le),properNames:se.properNames})})]}),!xe&&!C&&!on&&Ui==null&&H&&t.jsx("div",{className:"bim-rd-state",children:$("reader.chapterFailed")}),le.references&&le.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:$("reader.references")}),t.jsx("ol",{children:le.references.map((M,pe)=>t.jsxs("li",{children:[M.url?t.jsx("a",{className:"bim-rd-link",href:M.url,target:"_blank",rel:"noopener noreferrer",children:_(M.title)}):t.jsx("span",{children:_(M.title)}),M.author&&t.jsxs("span",{children:[",",_(M.author)]}),M.note&&t.jsxs("span",{children:["。",_(M.note)]})]},pe))})]})]})};function Uh(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 Vh(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 Gh(e,n,o){const[r,s]=h.useState({entryTitle:void 0,authors:[]});return h.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 wc={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")}},Yh=wc.other,Sc={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")}},Kh=Sc.pending;function qh(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 Xh(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 Cr=({items:e,loading:n})=>{const o=tt(),{t:r,convert:s}=ee();return n?t.jsx(tn,{}):e.length===0?t.jsx("div",{style:Zh,children:r("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=wc[a.type]||Yh,d=Sc[a.status]||Kh,c=typeof window<"u"&&Xh(a.pageUrl,window.location.href);return t.jsxs("div",{style:Jh,children:[t.jsxs("div",{style:Qh,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Ks,background:l.color},children:r(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Ks,background:d.color},children:r(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:ef,children:qh(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:tf,children:[a.resourceId&&t.jsx("a",{href:o(a.resourceId),style:io,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:io,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:io,children:a.pageUrl}))]}),t.jsx("div",{style:nf,children:s(a.content)}),a.reply&&t.jsxs("div",{style:of,children:[t.jsx("div",{style:rf,children:r("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Zh={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Jh={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Qh={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Ks={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},ef={fontSize:"12px",color:i("desc-fg")},tf={fontSize:"12px",marginBottom:"6px"},io={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},nf={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},of={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},rf={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},To=({transport:e,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:a})=>{const l=Ce(),[d,c]=h.useState(null),[p,u]=h.useState([]),[m,g]=h.useState("recommend"),[f,x]=h.useState([]),[k,y]=h.useState(!1),w=r??m,b=L=>{g(L),s==null||s(L)},[j,S]=h.useState(!0),[v,$]=h.useState(null),[_,z]=h.useState(null),[P,N]=h.useState(null);h.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]),h.useEffect(()=>{let L=!1;return(async()=>{if(o)return o;if(e.getRecommended)try{const A=await e.getRecommended();if(A!=null&&A.groups)return A.groups.flatMap(V=>V.items.map(q=>({...q,group:V.name})))}catch{}return[]})().then(async A=>{if(L)return;const V=A.filter(U=>U.id);if(V.length===0){S(!1);return}const q=await Promise.all(V.map(async U=>{if(U.type)return{id:U.id,title:U.title,type:U.type,author:U.author,dynasty:U.dynasty,role:U.role,edition:U.edition,has_text:U.has_text,has_image:U.has_image,has_collated:U.has_collated,subtype:U.subtype,primary_name:U.primary_name,group:U.group,fallbackDescription:U.description};try{let O=null;if(e.getEntry)O=await e.getEntry(U.id);else{const K=await e.getItem(U.id);K&&(O={id:U.id,title:K.title||U.id,type:K.type||"work"})}if(O)return{...O,group:U.group,fallbackDescription:U.description}}catch{}return{id:U.id,title:U.title,type:Se.extractType(U.id),group:U.group,fallbackDescription:U.description}}));L||(u(q.filter(U=>U!==null)),S(!1))}),()=>{L=!0}},[e,o]);const T=h.useRef(!1),D=h.useRef(!1),R=h.useRef(!1);h.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(A=>{I||$(A)}).catch(()=>{T.current=!1}),()=>{I=!0}},[e,w]),h.useEffect(()=>{if(w!=="collection"||D.current||!e.getCollectionProgress)return;D.current=!0;let L=!1;return e.getCollectionProgress().then(I=>{L||z(I)}).catch(()=>{D.current=!1}),()=>{L=!0}},[e,w]),h.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]),h.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(yn,{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(zn,{label:l.home.recommendTab,active:w==="recommend",onClick:()=>b("recommend")}),t.jsx(zn,{label:l.home.catalogTab,active:w==="catalog",onClick:()=>b("catalog")}),t.jsx(zn,{label:l.home.collectionTab,active:w==="collection",onClick:()=>b("collection")}),t.jsx(zn,{label:l.home.siteTab,active:w==="site",onClick:()=>b("site")}),a&&t.jsx(zn,{label:l.home.feedbackTab,active:w==="feedback",onClick:()=>b("feedback")})]}),w==="recommend"&&t.jsx(sf,{recommended:p,loading:j,onNavigate:n,getIcon:E,t:l}),w==="catalog"&&t.jsx(qs,{progress:v,t:l,onNavigate:n}),w==="collection"&&t.jsx(qs,{progress:_,t:l,onNavigate:n}),w==="site"&&t.jsx(lf,{progress:P,t:l,totalWorks:(d==null?void 0:d.works)??0}),w==="feedback"&&a&&t.jsx(Cr,{items:f,loading:k})]})})},zn=({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}),sf=({recommended:e,loading:n,onNavigate:o,getIcon:r,t:s})=>{const a=tt();if(n)return t.jsx(tn,{});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))})},qs=({progress:e,t:n,onNavigate:o})=>{if(!e)return t.jsx(tn,{});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(af,{item:p,t:n,statusColor:l[d],onNavigate:o},p.id))})]},d)})})},af=({item:e,t:n,statusColor:o,onNavigate:r})=>{const s=tt(),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?ht(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})]})},lf=({progress:e,t:n,totalWorks:o})=>{if(!e)return t.jsx(tn,{});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(Xs,{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(Xs,{item:c,t:n,totalWorks:o},c.id))})]})]})},Xs=({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})]})},Zs="(max-width: 768px)";function cf(){const[e,n]=h.useState(()=>typeof window>"u"?!1:window.matchMedia(Zs).matches);return h.useEffect(()=>{const o=window.matchMedia(Zs),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e}const df=({transport:e,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var D;const a=Ce(),{convert:l}=Ae(),d=cf(),[c,p]=h.useState(null),[u,m]=h.useState(null),[g,f]=h.useState(!1),[x,k]=h.useState("detail"),[y,w]=h.useState([]),[b,j]=h.useState(!1),S=h.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=h.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]),$=h.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,z=(u==null?void 0:u.type)==="collection"&&(y.length>0||b)||(u==null?void 0:u.type)==="work"&&_,P=d&&(g||u),N=h.useCallback(()=>{p(null),m(null),w([]),k("detail")},[]),T=t.jsx(t.Fragment,{children:g?t.jsx(tn,{}):u?t.jsxs(t.Fragment,{children:[(z||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:[z&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:ni(x==="detail"),children:a.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:ni(!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:ni(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:ni(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(Yo,{data:u,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(Ko,{data:(D=y.find(R=>`catalog:${R.resource_id}`===x))==null?void 0:D.data,onNavigate:$}):x==="collated"?t.jsx($r,{id:u.id,transport:e,onNavigate:$}):null})]}):t.jsx(To,{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:P?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(go,{transport:e,onEntryClick:v,hideModeIndicator:n}),!u&&t.jsx(To,{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(go,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:T})]})};function ni(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 pf=({pageData:e,rawImageUrl:n="",punctuations:o=[],title:r,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=h.useState(new Set),[u,m]=h.useState(null),[g,f]=h.useState("horizontal"),[x,k]=h.useState(!0),y=h.useRef(null),w=h.useCallback(v=>{p(new Set(v))},[]),b=h.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:g==="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(yr,{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:g==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Sr,{pageData:e,punctuations:S,selectedCharIds:c,hoveredCharId:u,onSelectionChange:w,onCharClick:b,onCharHover:m,mode:g,showPunctuation:x})]})]})]})},uf=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function an(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function mf(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=an((r=u.page)==null?void 0:r.index),g=Array.isArray(u.cells)?u.cells:[];if(m===void 0||g.length===0)continue;const f=new Map;for(const x of g){if(!x||typeof x!="object")continue;const k=x,y=uf.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($=>an($)!==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:an((a=u.canvas)==null?void 0:a.width)??an((l=u.image)==null?void 0:l.width)??0,height:an((d=u.canvas)==null?void 0:d.height)??an((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 gf(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 hf(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 ff=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function xt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Js(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(o=>!!o&&typeof o=="object"):[]}function xf(e,n){var l,d,c,p,u,m,g,f,x,k;const o=new Map,r=new Map;for(const y of Js(n)){const w=xt(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=>xt(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 Js(e)){const w=xt(y.page);if(w===void 0)continue;const b=[];for(const S of Array.isArray(y.columns)?y.columns:[]){const v=xt(S==null?void 0:S.col);if(v===void 0)continue;const $=[];for(const _ of Array.isArray(S.cells)?S.cells:[]){const z=ff.exec(String((_==null?void 0:_.a)??""));if(!z||typeof _.c!="string")continue;const P=parseInt(z[3],10);$.push({id:_.a,char:_.c,slot:P,pos:P,sub:z[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:xt((d=j==null?void 0:j.canvas)==null?void 0:d.width)??xt((c=j==null?void 0:j.image)==null?void 0:c.width)??0,height:xt((p=j==null?void 0:j.canvas)==null?void 0:p.height)??xt((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:xt((g=w.canvas)==null?void 0:g.width)??xt((f=w.image)==null?void 0:f.width)??0,height:xt((x=w.canvas)==null?void 0:x.height)??xt((k=w.image)==null?void 0:k.height)??0,columns:[]})}return s.sort((y,w)=>y.page-w.page)}const bf=({data:e,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:a}=ee(),[l,d]=h.useState(((u=e.divisions[0])==null?void 0:u.name)??null),[c,p]=h.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(yf,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:g=>p(c===g?null:g),onNavigate:n},m.name))})]})},yf=({division:e,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ee(),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(jf,{category:p,expanded:r===u,onToggle:()=>s(u),onNavigate:a},p.name)})})]})},jf=({category:e,expanded:n,onToggle:o,onNavigate:r})=>{var p,u,m,g;const{t:s,convert:a}=ee(),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)+(((g=e.stats)==null?void 0:g.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}=ee(),a=tt(),[l,d]=h.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})})]})},kt=({title:e,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const a=Ce();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:kf,children:"AI"}),n&&t.jsx("button",{onClick:n,style:vf,children:a.action.save})]})]}),s]})},vf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},kf={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},gt=({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"}})]}),Jt=({value:e,onChange:n,placeholder:o})=>{const r=h.useRef(null);return h.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"}})},gi=({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 wf(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const ai=({value:e,onChange:n,label:o})=>{const[r,s]=h.useState(!1),a=h.useRef(null),l=wf(e||"");return h.useEffect(()=>{r&&a.current&&a.current.focus()},[r]),!r&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:ea,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(gi,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:ea,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"}})]})},ea={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function Sf(e){switch(e){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function _f(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const _c=({items:e,onChange:n,onOpenEntityPicker:o})=>{const r=Ce(),[s,a]=h.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((g,f)=>f!==m)),s===m&&a(null)},c=(m,g,f)=>{const x=[...e];x[m]={...x[m],[g]:f},n(x)},p=(m,g)=>{const f=[...e];f[m]={...f[m],type:g,id:"",name:""},n(f),g==="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(g=>{const f=[...e];f[m]={...f[m],id:g.id,name:g.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,g)=>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===g?null:g),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===g?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:m.name||`${r.editor.sourcePlaceholder} ${g+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Sf(m.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:_f(m.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(g)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===g&&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:Rt,children:r.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(g,"bookID"),style:{...ta,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(g,"url"),style:{...ta,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:Rt,children:r.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[g]={...f[g],type:"",id:"",name:""},n(f)},style:na,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(g),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(g),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:Rt,children:r.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[g]={...f[g],type:"",id:"",name:""},n(f)},style:na,children:r.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:f=>c(g,"name",f.target.value),placeholder:r.editor.sourceNamePlaceholder,style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:r.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:f=>c(g,"id",f.target.value),placeholder:"https://...",style:ln})]})]}),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:{...Rt,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:Rt,children:r.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:f=>c(g,"details",f.target.value),placeholder:r.editor.detailsPlaceholder,style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:r.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:f=>c(g,"position",f.target.value),placeholder:"如: 卷三, p.52",style:ln})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:r.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:f=>c(g,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:r.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:f=>c(g,"processor_version",f.target.value),placeholder:"如: v0.1",style:ln})]})]})]})]})})]},g)),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})]})]})},Rt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},ln={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"},ta={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"},na={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function $c(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 Cc(e){return!e||e.length===0?"":JSON.stringify(e)}const zc=({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:g,onViewEntity:f,onCreateAndLink:x,onSaveRelations:k})=>{const y=Ce();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:$f,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Tn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>g("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(Tn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>g("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(cn,{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(Tn,{direction:"up",title:y.relation.parentWork,entity:r,onView:f,onUnlink:()=>g("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(cn,{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(cn,{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(cn,{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(Tn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>g("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(Tn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>g("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(cn,{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(cn,{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})]})]})]})},Tn=({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 g=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:g,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:Tc(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(ia,{onClick:()=>r(o),title:u,children:"👁️"}),t.jsx(ia,{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(No,{onClick:a,children:d}),t.jsx(No,{onClick:l,primary:!0,children:c})]})]})},cn=({direction:e,title:n,entities:o,onView:r,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=h.useState(!1),u=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",g=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:[g.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:Tc(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(No,{onClick:s,primary:!0,children:["+ ",a]})})]})},ia=({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}),No=({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 Tc(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const $f={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Nc=({isOpen:e,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[u,m]=h.useState(""),g=p?l.filter(y=>y.id!==p):l;h.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:Cf,children:t.jsxs("div",{style:zf,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:Tf,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:Nf})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:oo,children:"搜索中..."}):g.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:g.map(y=>t.jsxs("div",{onClick:()=>r(y),style:Rf,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:oo,children:["未找到匹配的",x]}):t.jsxs("div",{style:oo,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:Ef,children:["创建新",x,"并关联"]})]})]})})},Cf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},zf={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")},Tf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Nf={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"},Rf={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},oo={padding:"20px",textAlign:"center",color:i("desc-fg")},Ef={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},oa={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},If={work:"📜",book:"📖",collection:"📚",entity:"👤"},Rc=({isOpen:e,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:a})=>{const[l,d]=h.useState(""),c=h.useRef(null);h.useEffect(()=>{e&&(d((r==null?void 0:r.title)||""),setTimeout(()=>{var g,f;(g=c.current)==null||g.focus(),(f=c.current)==null||f.select()},100))},[e,r==null?void 0:r.title]);const p=g=>{g.key==="Enter"&&l.trim()?u():g.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`创建新${oa[n]}`}};return t.jsx("div",{style:Lf,onClick:g=>{g.target===g.currentTarget&&a()},children:t.jsxs("div",{style:Af,onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:If[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:g=>d(g.target.value),onKeyDown:p,placeholder:`请输入${oa[n]}名称...`,style:Pf})]}),((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:Mf,children:"取消"}),t.jsx("button",{onClick:u,disabled:!l.trim(),style:{...Bf,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},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",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:i("shadow-dialog")},Pf={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"},Mf={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Bf={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function Wf(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Ec(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Of(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 Ic=({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,g]=h.useState(""),[f,x]=h.useState([]),[k,y]=h.useState(!1),[w,b]=h.useState("recent");h.useEffect(()=>{e&&(g(""),x([]),b(r.length>0?"recent":"search"))},[e,r.length]),h.useEffect(()=>{if(!m.trim()){x([]);return}const z=setTimeout(async()=>{y(!0);try{x(await u(m,o))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(z)},[m,o,u]);const j=h.useCallback(z=>{g(z.target.value),z.target.value.trim()&&b("search")},[]),S=h.useCallback(z=>s?z.filter(P=>P.id!==s):z,[s]);if(!e)return null;const v=n||(o==="all"?"选择实体":`选择${Ec(o)}`),$=S(r),_=S(f);return t.jsx("div",{style:Hf,children:t.jsxs("div",{style:Df,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:Uf,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:Vf}),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(ra,{active:w==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(ra,{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(sa,{entities:$,onSelect:d}):m.trim()?k?t.jsx(ro,{message:"搜索中..."}):_.length>0?t.jsx(sa,{entities:_,onSelect:d}):t.jsx(ro,{message:"未找到匹配的结果"}):t.jsx(ro,{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:Gf,children:l||"创建新实体"})]})]})})},ra=({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}),sa=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(o=>t.jsx(Ff,{entity:o,onClick:()=>n(o)},o.id))}),Ff=({entity:e,onClick:n})=>{const[o,r]=h.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:Wf(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:Of(e.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Ec(e.type)})]})},ro=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:e}),Hf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Df={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")},Uf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Vf={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"},Gf={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Yf={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},Kf={work:"📜",collection:"📚",book:"📖",entity:"👤"},Lc=({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:g})=>{var $e;const f=Ce(),[x,k]=h.useState(!1),[y,w]=h.useState("work"),[b,j]=h.useState(""),[S,v]=h.useState(""),[$,_]=h.useState([]),[z,P]=h.useState(!1),[N,T]=h.useState(!1),[D,R]=h.useState("work"),[E,L]=h.useState(""),[I,A]=h.useState(),[V,q]=h.useState(!1),[U,O]=h.useState(null),[K,Y]=h.useState([]);h.useRef(null);const W=e.type,ne=W==="work",je=W==="collection",Q=W==="book",de=h.useCallback((G,Te)=>{n({...e,[G]:Te})},[e,n]),We=h.useCallback((G,Te)=>{j(G),w(Te),v(f.editor.selectToLink+f.indexType[Te]),_([]),k(!0)},[f]),_e=h.useCallback(G=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(e.id,G)},[r,e.id]),Be=h.useCallback(G=>{s==null||s(G.id,G.type)},[s]),Ne=h.useCallback((G,Te,Ie)=>{const B={...Ie,author:(Ie==null?void 0:Ie.author)||e.author,dynasty:Ie==null?void 0:Ie.dynasty};R(Te),L(G),A(B),T(!0)},[e.author]),X=h.useCallback((G,Te)=>{r!=null&&r.createAndLink&&r.createAndLink(e.id,E,{type:D,title:G,inheritData:Te}),T(!1)},[r,e.id,E,D]),ae=h.useCallback(G=>{if(!G.trim()){_([]);return}P(!0),r!=null&&r.searchEntities&&r.searchEntities(G,y).then(Te=>{_(Te),P(!1)}).catch(()=>{_([]),P(!1)})},[r,y]),le=h.useCallback(G=>{r!=null&&r.linkEntity&&r.linkEntity(e.id,b,G.id),k(!1)},[r,e.id,b]),ke=h.useCallback(()=>{o()},[o]),H=h.useCallback(G=>{O(()=>G),q(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(Y).catch(()=>{})},[r]),fe=h.useCallback((G,Te)=>r!=null&&r.searchEntities?r.searchEntities(G,Te==="all"?void 0:Te):Promise.resolve([]),[r]),ue=h.useCallback(G=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(G),Y(Te=>[G,...Te.filter(Ie=>Ie.id!==G.id)].slice(0,10)),U==null||U(G),q(!1),O(null)},[r,U]);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:Kf[W]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(gi,{children:e.id}),t.jsx(gi,{color:Yf[W],children:f.indexType[W]})]})}),t.jsx(kt,{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(ai,{label:ne?f.editor.workTitle:je?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:G=>de("title",G)}),Q&&t.jsx(ai,{label:f.editor.belongsToWork,value:e.workName||"",onChange:G=>de("workName",G)}),t.jsx(gt,{label:f.editor.authorLabel,value:e.author||"",onChange:G=>de("author",G)}),t.jsx(gt,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:G=>de("publicationYear",G)}),(Q||je)&&t.jsx(ai,{label:f.editor.containedIn,value:e.collection||"",onChange:G=>de("collection",G)}),(Q||je)&&t.jsx(gt,{label:f.editor.holderLabel,value:e.holder||"",onChange:G=>de("holder",G)}),(Q||je)&&t.jsx(gt,{label:Q?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:G=>de("pages",G)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(gt,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:G=>de("firstImage",G)})})]})}),t.jsx(kt,{title:f.section.description,onSave:o,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(Jt,{value:e.description||"",onChange:G=>de("description",G),placeholder:f.editor.descriptionPlaceholder})}),((($e=e.additional_works)==null?void 0:$e.length)||0)>0&&t.jsx(kt,{title:f.section.additionalWorks,onSave:o,children:t.jsx(qf,{items:e.additional_works||[],onChange:G=>de("additional_works",G)})}),t.jsx(kt,{title:f.section.indexedBy,onSave:o,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Xf,{items:e.indexed_by||[],onChange:G=>de("indexed_by",G)})}),t.jsx(kt,{title:f.section.emendatedBy,onSave:o,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Zf,{items:e.emendated_by||[],onChange:G=>de("emendated_by",G)})}),t.jsx(kt,{title:f.section.textResources,onSave:o,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(uo,{items:e.resources||[],onChange:G=>de("resources",G),onDownload:p,downloadStatuses:u,filterType:"text"})}),t.jsx(kt,{title:f.section.imageResources,onSave:o,children:t.jsx(uo,{items:e.resources||[],onChange:G=>de("resources",G),onDownload:p,downloadStatuses:u,filterType:"image"})}),t.jsx(kt,{title:f.section.sources,onSave:o,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(_c,{items:$c(e.sources||""),onChange:G=>de("sources",Cc(G)),onOpenEntityPicker:H})}),(Q||je)&&t.jsx(kt,{title:f.section.provenance,onSave:o,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(Jt,{value:e.provenance||"",onChange:G=>de("provenance",G),placeholder:f.editor.provenancePlaceholder})}),Q&&t.jsx(kt,{title:f.section.otherEditions,onSave:o,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(Jt,{value:e.otherEditions||"",onChange:G=>de("otherEditions",G),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(zc,{entityType:W,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:_e,onViewEntity:Be,onCreateAndLink:Ne,onSaveRelations:ke}),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(Nc,{isOpen:x,entityType:y,title:S,onSelect:le,onCancel:()=>k(!1),onCreate:()=>{k(!1),Ne(b,y)},searchResults:$,onSearch:ae,isLoading:z,excludeId:e.id}),t.jsx(Rc,{isOpen:N,entityType:D,relationField:E,inheritData:I,onConfirm:X,onCancel:()=>T(!1)}),t.jsx(Ic,{isOpen:V,title:f.action.selectBookOrWork,filterType:"all",recentEntities:K,excludeId:e.id,onSelect:ue,onCancel:()=>{q(!1),O(null)},onSearch:fe})]})};function qf({items:e,onChange:n}){const o=Ce(),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(gt,{label:o.editor.bookNameLabel,value:l.book_title,onChange:c=>r(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(gt,{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 Ac({items:e,onChange:n,showMeta:o,addLabel:r}){const s=Ce(),[a,l]=h.useState(null),d=(u,m,g)=>{const f=e.map((x,k)=>k===u?{...x,[m]:g||void 0}:x);n(f)},c=u=>{n(e.filter((m,g)=>g!==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 g=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:g?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(g?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:g?"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:"✕"})]}),!g&&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]}),g&&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(gt,{label:s.label.sourceName,value:u.source,onChange:f=>d(m,"source",f)}),t.jsx(gt,{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(gt,{label:s.label.titleInfo,value:u.title_info||"",onChange:f=>d(m,"title_info",f)}),t.jsx(gt,{label:s.label.authorInfo,value:u.author_info||"",onChange:f=>d(m,"author_info",f)})]}),t.jsx(gt,{label:s.label.edition,value:u.edition||"",onChange:f=>d(m,"edition",f)})]}),t.jsx(Jt,{value:u.summary||"",onChange:f=>d(m,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(Jt,{value:u.comment||"",onChange:f=>d(m,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(Jt,{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 Xf({items:e,onChange:n}){const o=Ce();return t.jsx(Ac,{items:e,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function Zf({items:e,onChange:n}){const o=Ce();return t.jsx(Ac,{items:e,onChange:n,addLabel:o.action.addEmendatedBy})}function Pc(e){var d,c,p,u,m,g,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):((g=e.page_count)==null?void 0:g.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 Jf(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 Qf=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:g,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y,headerExtra:w,className:b,style:j}=e,S=Ce(),[v,$]=h.useState(s),_=a?s:v;h.useEffect(()=>{s!==v&&$(s)},[s]);const z=h.useCallback(()=>{const L=_==="view"?"edit":"view";a?a(L):$(L)},[_,a]),[P,N]=h.useState(null);h.useEffect(()=>{o&&r&&r.getItem(o).then(L=>{L&&N(L)})},[o,r]);const T=n||P,D=h.useMemo(()=>T?Pc(T):null,[T]),R=a||!n?t.jsx("button",{onClick:z,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:_==="edit"?i("accent-bg"):"transparent",color:i(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?S.common.switchToEdit:S.common.switchToView,children:_==="view"?S.common.modeEdit:S.common.modeView}):null,E=t.jsxs(t.Fragment,{children:[R,w]});return!T&&!D?t.jsx(tn,{}):_==="view"?t.jsx(Yo,{data:T,transport:r,onNavigate:p?L=>p(L):void 0,renderLink:u,headerExtra:E,className:b,style:j}):D?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(Lc,{data:D,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:r,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:g,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},ex=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Mc=({isOpen:e,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=ee(),[a,l]=h.useState(null),[d,c]=h.useState(""),[p,u]=h.useState(""),[m,g]=h.useState("idle"),[f,x]=h.useState(""),k=h.useRef(null);h.useEffect(()=>{e&&(l(null),c(""),u(""),g("idle"),x(""))},[e]),h.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=k.current)==null?void 0:b.focus()},100)},[a]),h.useEffect(()=>{if(m==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[m,n]),h.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())){g("submitting"),x("");try{await o({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),g("success")}catch(b){g("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:tx,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:nx,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:ix,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:ox,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:cx,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:ex.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...rx,...a===b.value?sx:{}},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:{...ax,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:px}),t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:dx,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!w,style:{...lx,opacity:w?1:.6,cursor:w?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},tx={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},nx={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},ix={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},ox={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},rx={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"},sx={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},ax={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"},lx={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},cx={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},dx={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},px={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"},Ro="--bim-feedback-fab-offset",Eo=48,ux=16,mx=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:a}=ee(),[l,d]=h.useState(!1),c=n.bottom??24;return h.useEffect(()=>{if(r||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(Ro,`calc(${c+Eo+ux}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Ro)}},[r,c]),t.jsxs(t.Fragment,{children:[!r&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...gx,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(Mc,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:o})]})},gx={position:"fixed",width:`${Eo}px`,height:`${Eo}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"},hx=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Bc=({onSubmit:e})=>{const{t:n}=ee(),[o,r]=h.useState("bug"),[s,a]=h.useState(""),[l,d]=h.useState(""),[c,p]=h.useState("idle"),[u,m]=h.useState(""),g=h.useRef(null);h.useEffect(()=>{o&&setTimeout(()=>{var k;return(k=g.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:aa,children:t.jsxs("div",{style:jx,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:vx,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:aa,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:hx.map(k=>t.jsxs("button",{onClick:()=>r(k.value),style:{...fx,...o===k.value?xx:{}},children:[t.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),t.jsx("textarea",{ref:g,value:s,onChange:k=>a(k.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...bx}}),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:wx}),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:{...yx,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:kx,children:u})]})},aa={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},fx={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"},xx={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},bx={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"},yx={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},jx={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},vx={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},kx={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},wx={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 la(e){return typeof e=="function"?e():e??"/api/feedback"}const Wc=({resourceId:e,apiUrl:n})=>{const{t:o}=ee(),[r,s]=h.useState([]),[a,l]=h.useState(!0),d=h.useCallback(async()=>{const p=la(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]);h.useEffect(()=>{d()},[d]);const c=async p=>{const u=la(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 g=await m.json().catch(()=>null);throw new Error((g==null?void 0:g.error)||o("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Cr,{items:r,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Bc,{onSubmit:c})})]})},Ni=8;async function Ri(e,n,o,r){const s=Number.isFinite(n)?Math.max(1,Math.floor(n)):1,a=new Array(e.length);let l=0;const d=Array.from({length:Math.min(s,Math.max(1,e.length))},async()=>{for(;l<e.length&&!(r!=null&&r());){const c=l++;a[c]=await o(e[c],c)}});return await Promise.all(d),a}const Sx=fi["zh-Hant"].relation,_x=fi["zh-Hant"].lossStatus,$x=fi["zh-Hant"].resourceKind,Ei=fn("zh-Hant"),zr=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function ca(e,n=Ei){return e?zr(Sx,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function Cx(e,n=Ei){return zr(_x,e)?n(`detail.lossStatus.${e}`):e}function zx(e,n=Ei){return zr($x,e)?n(`detail.resourceKind.${e}`):""}function Tr({authors:e,onNavigate:n,renderLink:o}){const{convert:r}=ee(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=nr(a.role);return t.jsxs(h.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(et,{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 Oc(e,n,o=Ei){var c,p;const r=er(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 Fc(e,n){const o=(e.url?xn(e.url):void 0)||e.name,r=Il(e,n);return r?`${o}(${r})`:o}function Nr({item:e,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=ee(),[a,l]=h.useState(!1),d=xi(e),c=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),p=s(Fc(e,n)),u=bn(e),m=_i(e,r)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const g=(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:"↗"}),g]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,g]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(ar,{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(g=>!g),children:a?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:d.expected})})})]})}function Hc({groups:e,listedVolumeCounts:n}){const{t:o,convert:r}=ee();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(Nr,{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=bn(a),c=r(Fc(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 Mn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Io(e){var o;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=Mn.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const da=12,Tx=60,Dc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:a,back:l,railLinks:d})=>{var ae,le,ke;const{t:c,convert:p,messages:u}=ee(),m=h.useMemo(()=>[...e.books||[],...e.collections||[]],[e.books,e.collections]),[g,f]=h.useState(new Map),[x,k]=h.useState(!1),[y,w]=h.useState(""),[b,j]=h.useState(!1),S=m.length<=Tx,v=S||x||!!y||b,$=h.useMemo(()=>v?m:m.slice(0,da),[m,v]);h.useEffect(()=>{if(!n||$.length===0)return;const H=$.filter(ue=>!g.has(ue));if(H.length===0)return;let fe=!1;return Ri(H,Ni,ue=>n.getItem(ue).then($e=>{const G=$e??{};return[ue,{id:ue,title:G.title,edition:G.edition,resources:G.resources,publication_info:G.publication_info,current_location:G.current_location,lineage:G.lineage,measure_info:G.measure_info}]}).catch(()=>[ue,{id:ue}]),()=>fe).then(ue=>{fe||f($e=>{const G=new Map($e);for(const[Te,Ie]of ue)G.set(Te,Ie);return G})}),()=>{fe=!0}},[n,$,g]);const _=h.useMemo(()=>m.map(H=>g.get(H)??{id:H}),[m,g]),z=m.length>0&&m.every(H=>g.has(H)),P=!!n&&$.some(H=>!g.has(H)),N=S||v,T=h.useMemo(()=>Al(_,e.version_graph,{era:y,scanOnly:b,sort:N?"year":"default"}),[_,e.version_graph,y,b,N]),D=x?T.rows:T.rows.slice(0,da),R=T.allRows.filter(H=>H.hasImage).length,E=e.related_works||[],L=E.filter(H=>H.relation==="collected_in"),I=h.useMemo(()=>{const H=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],fe=ue=>{const $e=H.indexOf(ue??"");return $e<0?H.length:$e};return E.filter(ue=>ue.relation!=="collected_in").map((ue,$e)=>({r:ue,i:$e})).sort((ue,$e)=>fe(ue.r.relation)-fe($e.r.relation)||ue.i-$e.i).map(ue=>ue.r)},[E]),A=h.useMemo(()=>{const H=er(e.resources,e.resource_groups);return[...H.mirrors.flatMap(fe=>fe.items.map(ue=>({r:ue,kind:p(fe.label)}))),...H.buckets.flatMap(fe=>fe.items.map(ue=>({r:ue,kind:p(zx(fe.key,c))})))]},[e.resources,e.resource_groups,p,c]),V=e.indexed_by||[],q=e.emendated_by||[],U=h.useMemo(()=>{var oe,xe,Re;const H=[],fe=(xe=(oe=e.authors)==null?void 0:oe[0])==null?void 0:xe.dynasty;fe&&H.push({label:c("workPage.fact.written"),value:p(fe)});const ue=Pt(e,u.unit.juan);if(ue){const F=(Re=e.juan_count)==null?void 0:Re.description;H.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(ue),F&&F!==ue?t.jsxs("span",{className:"bim-d-meta",children:["(",p(F),")"]}):null]})})}e.loss_status&&H.push({label:c("workPage.fact.loss"),value:p(Cx(e.loss_status,c))});const $e=T.allRows.filter(F=>F.sortYear!=null),G=$e.length>0?$e.reduce((F,me)=>F.sortYear<=me.sortYear?F:me):null;G!=null&&G.era.era?H.push({label:c("workPage.fact.earliest"),value:p([G.era.era,G.era.reign].filter(Boolean).join(" ")),title:G.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):P&&H.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),q.length&&H.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:q.length})});const Te=pa(e.additional_titles);Te.length&&H.push({label:c("workPage.fact.alias"),value:Te.map(p).join("、")});const Ie=pa(e.attached_texts);Ie.length&&H.push({label:c("workPage.fact.attached"),value:Ie.map(p).join("、")});const B=(e.additional_works||[]).map(F=>p(F.book_title)+(F.n_juan!=null?` ${F.n_juan}${u.unit.juan}`:""));return B.length&&H.push({label:c("workPage.fact.appendix"),value:B.join("、")}),H},[e,p,c,u,P,T.allRows,q.length]),K=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:z?R:0,label:c("workPage.stat.hasImage")},{value:V.length,label:c("workPage.stat.catalogs")}],Y=e.classification,W=Y?[Y.l1,Y.l2,Y.l3,Y.l4].filter(Boolean).map(H=>p(H)):[],ne=e.subtype?u.workSubtype[e.subtype]??p(e.subtype):"",je=t.jsx(Fn,{title:p(e.title),byline:t.jsx(Tr,{authors:e.authors,onNavigate:o,renderLink:r}),meta:t.jsx(it,{items:[...W,Y!=null&&Y.source?c("workPage.classifiedBy",{source:p(Y.source.split("/")[0])}):"",ne]}),description:(ae=e.description)!=null&&ae.text?t.jsxs(t.Fragment,{children:[t.jsx(At,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(le=e.description.sources)!=null&&le.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(H=>({text:p(Vm(H)),href:Gm(H)})).filter(H=>H.text).map((H,fe)=>t.jsxs(h.Fragment,{children:[fe>0?" · ":null,H.href?t.jsx("a",{href:H.href,target:"_blank",rel:"noopener noreferrer",children:H.text}):H.text]},fe))}):null]}):void 0,stats:K,facts:U,readAction:s,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(ke=e.appendix)==null?void 0:ke.map((H,fe)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(H.title)}),t.jsx(At,{text:H.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},fe))}),Q=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(H=>({key:H,label:`${H} ${T.allRows.filter(fe=>fe.era.era===H).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}),A.length&&de.push({id:"resources",label:c("workPage.sec.resources"),count:A.length});const We=m.length===0&&V.length===0,_e=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(ot,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(it,{items:[c("workPage.versionsTotal",{n:m.length}),z&&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":P&&Q.length===0&&m.length>1?"":void 0,children:[Q.length>0&&t.jsx(Ci,{items:Q,value:y,onChange:H=>{w(H),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Hl,{label:c("workPage.scanOnly"),checked:b,onChange:H=>{j(H),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&&zi(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:D.map(H=>{var fe;return t.jsx(Nx,{row:H,measure:(fe=g.get(H.id))==null?void 0:fe.measure_info,loaded:g.has(H.id),onNavigate:o,renderLink:r},`${H.id}:${g.has(H.id)?"r":"p"}`)})})]}),D.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(ir,{total:T.rows.length,shown:D.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(Rx,{items:V,transport:n,onNavigate:o,renderLink:r}),We&&t.jsx(ot,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Be=(H,fe)=>t.jsx(et,{id:H,label:p(fe),onNavigate:o,renderLink:r,dense:!0}),Ne=h.useMemo(()=>{const H=new Map;for(const fe of I){const ue=ca(fe.relation,c);H.set(ue,(H.get(ue)??0)+1)}return H.size>1?[...H.entries()].sort((fe,ue)=>ue[1]-fe[1]).slice(0,4).map(([fe,ue])=>`${p(fe)} ${ue}`).join(" · "):void 0},[I,p,c]),X=t.jsxs(t.Fragment,{children:[t.jsx(Zt,{id:"collected",title:c("workPage.sec.collected"),items:L.map(H=>Be(H.id,H.title))}),t.jsx(Zt,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:I.length}),sub:Ne,items:I.map(H=>t.jsxs(t.Fragment,{children:[Be(H.id,H.title),t.jsx("span",{className:"bim-d-meta",title:H.note?p(H.note):void 0,children:p(ca(H.relation,c))})]}))}),t.jsx(Zt,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:A.map(({r:H,kind:fe})=>{const ue=p((H.url?xn(H.url):void 0)||H.name),$e=bn(H);return t.jsxs(t.Fragment,{children:[$e?t.jsxs("a",{href:$e,target:"_blank",rel:"noopener noreferrer",children:[ue," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:ue}),fe&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:fe})]})})})]});return t.jsx(On,{railTop:a,back:l,nav:de,railLinks:d,main:_e,card:je,side:X})};function pa(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function ua(e,n){return n((e.url?xn(e.url):void 0)||e.name)}function Nx({row:e,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:a,convert:l}=ee(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],u=p?ua(p,l):e.locationName?l(e.locationName):"",m=e.images[0],g=m?bn(m):void 0,f=e.images.map(x=>ua(x,l)).join("、");return t.jsxs("tr",{"data-loading":o?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{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&&(g?t.jsx("a",{className:"bim-d-flag",href:g,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 Rx({items:e,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:a}=ee(),[l,d]=h.useState(0),c=Math.min(l,e.length-1),p=e[c],[u,m]=h.useState(new Map);return h.useEffect(()=>{if(!n)return;const g=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(g.length===0)return;let f=!1;return Promise.all(g.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(ot,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(it,{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((g,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(g.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(g.source_bid??"")?a(u.get(g.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(g.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(it,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(et,{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:ft(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:ft(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:ft(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 Ex(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 Ix(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 ma(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 Lx(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 Ax(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 li(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=Ax(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,g=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 D=v.get(N);return D?(D.derived_from??[]).map(R=>R.ref):[]},_=N=>v.has(N)?!u||u.has(N):!p||p.has(N),z=new Set,P=N=>{if(!z.has(N)){z.add(N);for(const T of $(N))a.has(T)||(_(T)||(v.has(T)?g.add(T):S.has(T)&&m.add(T)),P(T))}};for(const N of n)p&&p.has(N.id)&&!a.has(N.id)&&P(N.id);for(const N of r.hypothetical_nodes??[])u&&u.has(N.id)&&P(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=Ix(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)||g.has(S.id)).map(S=>{const v=Ex(S);return g.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(ma(S.id,v,$))}),(S.lineage.related_to??[]).forEach((v,$)=>{j(Lx(S.id,v,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!g.has(S.id)||(S.derived_from??[]).forEach((v,$)=>{j(ma(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 Uc(e,n,o){const r=(e??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function Px(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 Vc=({graph:e,renderLink:n,className:o,style:r})=>{const{t:s,convert:a}=ee();if(!e.nodes.length)return t.jsx("div",{style:{...Xx,...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 g=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:o,style:{...Bx,...r},children:[e.title&&t.jsx("div",{style:Wx,children:a(e.title)}),e.description&&t.jsx("div",{style:Ox,children:a(e.description)}),g.map(f=>t.jsx(ga,{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(ga,{label:s("lineage.otherGroup"),nodes:u,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},ga=({label:e,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ee();return t.jsxs("div",{style:Fx,children:[t.jsx("div",{style:{...Hx,borderLeftColor:n??i("widget-border")},children:d(e)}),o.map(c=>t.jsx(Mx,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Mx=({node:e,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ee();return t.jsxs("div",{style:{...Dx,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:Ux,children:[t.jsx("span",{style:Vx,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Gx,children:Uc(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Yx,children:[e.category&&t.jsx(Nn,{children:c(e.category)}),e.status==="lost"&&t.jsx(Nn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(Nn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(Nn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(Nn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Kx,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:qx,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:fa,children:[t.jsx("div",{style:xa,children:d("lineage.sources")}),n.map(p=>{const u=r.get(p.source);return t.jsxs("div",{style:ba(p.confidence),children:[t.jsx("span",{style:ya,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(ha,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ja,children:["· ",c(p.evidence)]})]},p.id)})]}),o.length>0&&t.jsxs("div",{style:fa,children:[t.jsx("div",{style:xa,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:ba(p.confidence),children:[t.jsx("span",{style:ya,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(ha,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ja,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Nn=({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})},ha=({level:e})=>{const{t:n}=ee(),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},Bx={fontSize:"14px",color:i("fg")},Wx={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Ox={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},Fx={marginBottom:"16px"},Hx={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},Dx={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},Ux={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Vx={fontSize:"15px",fontWeight:600},Gx={fontSize:"12px",color:i("muted")},Yx={marginBottom:"6px"},Kx={fontSize:"12px",color:i("muted"),margin:"2px 0"},qx={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},fa={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},xa={fontSize:"11px",color:i("muted"),marginBottom:"2px"},ba=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),ya={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},ja={fontSize:"11px",color:i("muted")},Xx={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},Gc=({selectedNodeId:e,...n})=>{const{t:o}=ee(),[r,s]=h.useState("loading"),[a,l]=h.useState(null);return h.useEffect(()=>{let d=!1;return Zx().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),r==="loading"?t.jsx("div",{style:ka,children:o("lineage.graphLoading")}):r==="missing"||!a?t.jsxs("div",{style:ka,children:[t.jsx("div",{children:va(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:va(o("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Jx,{modules:a,selectedNodeId:e,...n})};function va(e,n){return e.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return t.jsx(h.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function Zx(){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 Jx=({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:g,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:k}=l,y=h.useMemo(()=>({lineage:$=>{var I,A,V,q;const _=((I=$.data)==null?void 0:I.stepPosition)??.85,[z,P,N]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),T=!!((A=$.data)!=null&&A.isSibling),D=T?P:$.targetX-18,R=T?N:$.targetY-12,E=(V=$.data)==null?void 0:V.labelStyle,L=(q=$.data)==null?void 0:q.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(g,{id:$.id,path:z,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${D}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})})]})}}),[g,f,x]),w=h.useMemo(()=>({version:$=>{const{t:_}=ee(),z=$.data,P=z.kind==="hypothetical",N=z.status==="lost",T=z.isSelected,D=z.bridge,R=z.borderColor??i("muted"),E=D||P?"dashed":"solid",L=D?.5:N?.6:1;return t.jsxs("div",{style:{background:i(D?"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"):P||D?"none":i("shadow-node")},title:D?_("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:P||!z.renderLink?z.label:z.renderLink(z.bookId,z.label)}),z.description&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:z.description}),z.yearText&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:Uc(z.yearText,void 0,z.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}=ee(),{rfNodes:j,rfEdges:S}=h.useMemo(()=>Qx(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 Qx(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??tb(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}}),g=.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 P,N;const _=((P=c.node(v.target))==null?void 0:P.y)??0,z=((N=c.node($.target))==null?void 0:N.y)??0;return _-z}),S=j.length;j.forEach((v,$)=>{const _=($-(S-1)/2)*f;k.set(v.id,g+_)})}const y=e.edges.map(w=>eb(w,k.get(w.id),s));return{rfNodes:m,rfEdges:y}}function eb(e,n,o=r=>r??""){const r=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=nb(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 tb(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function nb(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 ka={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},Rr=({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:g,convert:f}=ee(),[x,k]=h.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:g("lineage.collectionAll"),description:g("lineage.collectionAllDesc")}]]})(),b=!!(d&&w.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:g("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:ib,children:[t.jsx("button",{onClick:()=>y("list"),style:so(x==="list"),children:g("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:so(x==="graph"),children:g("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:g("lineage.collectionLabel")}),w.map(([v,$])=>{const _=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:so(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(Vc,{graph:e,renderLink:o}):t.jsx(Gc,{graph:e,renderLink:o,height:r,selectedNodeId:s})]})},ib={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},so=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"}),wa=40,Sa=2,ob=9,rb=new Set(["certain","consensus","probable","disputed"]);function ao(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Yc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:u})=>{var Re,F,me,te,ge,ze,Ue,Ve,qe,Ze,Ye;const m=Ce(),{t:g,convert:f}=ee(),[x,k]=h.useState(null),[y,w]=h.useState(new Map),[b,j]=h.useState([]),[S,v]=h.useState(new Map),[$,_]=h.useState(!1),[z,P]=h.useState("flow"),[N,T]=h.useState(null);h.useEffect(()=>{if(!n||!e.work_id){k(null);return}let C=!1;return n.getItem(e.work_id).then(ie=>{!C&&ie&&ie.type==="work"&&k(ie)}).catch(()=>{}),()=>{C=!0}},[n,e.work_id]),h.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let C=!1;return n.getLineageGraph(e.work_id).then(ie=>{C||T(ie&&ie.nodes.length>1?ie:null)}).catch(()=>{C||T(null)}),()=>{C=!0}},[n,e.work_id]),h.useEffect(()=>{const C=e.contained_in||[];if(!n||C.length===0){w(new Map);return}let ie=!1;return Promise.all(C.map(re=>{const ve=typeof re=="string"?re:re.id;return n.getItem(ve).then(se=>[ve,se]).catch(()=>[ve,null])})).then(re=>{if(ie)return;const ve=new Map;for(const[se,he]of re)he&&ve.set(se,he);w(ve)}),()=>{ie=!0}},[n,e.contained_in]);const D=h.useMemo(()=>{const C=new Set([...(x==null?void 0:x.books)||[],...e.related_books||[]]);return C.add(e.id),[...C]},[x==null?void 0:x.books,e.related_books,e.id]),R=D.length-1;h.useEffect(()=>{if(!n||R<=0){j([]);return}const C=D.length<=wa,ie=C?D:D.slice(0,8);let re=!1;return Promise.all(ie.map(ve=>ve===e.id?Promise.resolve({id:ve,title:e.title,edition:e.edition,year:pi(e)}):n.getItem(ve).then(se=>{const he=se??{};return{id:ve,title:he.title,edition:he.edition,year:se?pi(he):void 0}}).catch(()=>({id:ve})))).then(ve=>{if(re)return;const se=ve.filter(he=>he.id===e.id||he.title||he.edition);C&&se.sort((he,Oe)=>(he.year??1/0)-(Oe.year??1/0)),j(se)}),()=>{re=!0}},[n,D,R,e]);const E=e.lineage,L=h.useMemo(()=>[...((E==null?void 0:E.derived_from)||[]).filter(C=>C.ref_type==="book").map(C=>C.ref),...((E==null?void 0:E.related_to)||[]).map(C=>C.book_id)].filter(Boolean),[E]);h.useEffect(()=>{if(!n||L.length===0){v(new Map);return}let C=!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=>{C||v(new Map(ie))}),()=>{C=!0}},[n,L]);const I=h.useMemo(()=>Oc(e.resources,e.resource_groups,g),[e.resources,e.resource_groups,g]),A=I.groups.reduce((C,ie)=>C+ie.rows.length+ie.mirrors.length,0),V=I.groups.length>0&&I.groups.every(C=>C.key==="_physical"),q=Wn(e),U=Ol(e),O=Pt(e,m.unit.juan),K=new Set((e.contained_in||[]).map(C=>typeof C=="string"?0:An(C.volume_index).length).filter(C=>C>0)),Y=C=>{var ve;const ie=(ve=e.base_edition)==null?void 0:ve.find(se=>se.book_id===C&&se.name);if(ie!=null&&ie.name)return ie.name;const re=S.get(C);return(re==null?void 0:re.edition)||(re==null?void 0:re.title)||""},W=h.useMemo(()=>{var ye,Ee,Pe,we,ce;const C=[];U&&C.push({label:g("bookPage.fact.editionType"),value:f(U),title:e.edition_type||(ye=e.lineage)!=null&&ye.category?void 0:g("bookPage.inferredFromEdition")}),(Ee=e.publication_info)!=null&&Ee.details?C.push({label:g("bookPage.fact.publication"),value:f(e.publication_info.details)}):(q.era||q.reign)&&C.push({label:g("bookPage.fact.era"),value:f([q.era,q.reign].filter(Boolean).join(" ")),title:q.source==="edition"?g("bookPage.inferredFromEdition"):void 0}),O&&C.push({label:g("bookPage.fact.measure"),value:f(O)});const ie=(e.contained_in||[]).flatMap(be=>typeof be=="string"?[]:An(be.volume_index));ie.length&&C.push({label:g("bookPage.fact.volumes"),value:g("bookPage.volumesValue",{range:$i(ie,m.unit.volume),unit:m.unit.volume,n:ie.length})});const re=(((Pe=e.lineage)==null?void 0:Pe.derived_from)||[]).find(be=>be.relation==="底本"&&be.ref_type==="book");re&&Y(re.ref)&&C.push({label:g("bookPage.fact.baseEdition"),value:t.jsx(et,{id:re.ref,label:f(Y(re.ref)),onNavigate:o,renderLink:r,dense:!0})});const ve=(e.base_edition||[]).filter(be=>be&&be.name);for(const be of["底本","配補","參校"]){if(be==="底本"&&re&&Y(re.ref))continue;const Fe=ve.filter(Me=>Me.role===be);Fe.length&&C.push({label:f(be),value:Fe.map((Me,jt)=>t.jsxs(h.Fragment,{children:[jt>0&&"、",Me.book_id?t.jsx(et,{id:Me.book_id,label:f(Me.name),onNavigate:o,renderLink:r,dense:!0}):f(Me.name)]},jt))})}const se=(e.provenance||[]).filter(be=>be&&be.institution),he=(e.resources||[]).filter(be=>(be.types||(be.type?[be.type]:[])).includes("physical"));if(se.length){C.push({label:g("bookPage.fact.holdings"),value:se.slice(0,2).map(Me=>f(Me.institution)).join("、")+(se.length>2?g("bookPage.andMorePlaces",{n:se.length}):"")});const be=se.filter(Me=>Me.call_number).slice(0,2).map(Me=>`${f(Me.institution)} ${Me.call_number}`);be.length&&C.push({label:g("bookPage.fact.callNumber"),value:be.join(";")+(se.filter(Me=>Me.call_number).length>2?"…":"")});const Fe=se.flatMap(Me=>Me.seals||[]).filter(Boolean);Fe.length&&C.push({label:g("bookPage.fact.seals"),value:f(Fe.join("、"))})}else he.length?C.push({label:g("bookPage.fact.holdings"),value:he.slice(0,2).map(be=>f(be.name)).join("、")+(he.length>2?g("bookPage.andMorePlaces",{n:he.length}):"")}):(we=e.current_location)!=null&&we.name&&C.push({label:g("bookPage.fact.holdings"),value:f(e.current_location.name)});const Oe=e.physical_description;if(Oe){const be=[[g("bookPage.fact.leafStyle"),Oe.leaf_style],[g("bookPage.fact.binding"),Oe.binding],[g("bookPage.fact.dimensions"),Oe.dimensions],[g("bookPage.fact.condition"),Oe.condition]];for(const[Fe,Me]of be)Me&&Me.trim()&&C.push({label:Fe,value:f(Me)})}(ce=e.page_count)!=null&&ce.description&&C.push({label:m.label.pageCount,value:f(e.page_count.description)});const Z=[..._o(e.additional_titles),..._o(e.attached_texts)];return Z.length&&C.push({label:g("bookPage.fact.aliases"),value:Z.map(f).join("、")}),C},[e,f,m,g,q,U,O,S,o,r]),ne=f(e.title),je=e.edition?f(e.edition):void 0,Q=((Re=e.lineage)==null?void 0:Re.year_text)||"",de=t.jsx(Fn,{kind:g("bookPage.kind"),title:ne,subtitle:je,byline:t.jsx(Tr,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:o,renderLink:r}),meta:(()=>{const C=[U?f(U):"",q.era?f([q.era,q.reign].filter(Boolean).join("")):"",O?f(O):""].filter(Boolean);return C.length?t.jsx("span",{className:"bim-d-tags",children:C.map((ie,re)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(re,2)}`,children:ie},re))}):null})(),description:(F=e.description)!=null&&F.text?t.jsx(At,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:rr((me=e.description)==null?void 0:me.text)?6:void 0,facts:W,readAction:s,secondaryAction:s&&A>0&&!V?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:g("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||[],_e=(a==null?void 0:a.chapters)||[],Be=f(_e[0]&&ao(_e[0].title)[0].slice(-1)||"")||g("bookPage.chapterUnit"),Ne=g("bookPage.chapterCount",{n:_e.length,unit:Be}),X=!!((te=E==null?void 0:E.derived_from)!=null&&te.length||(ge=E==null?void 0:E.related_to)!=null&&ge.length||(ze=e.appendix)!=null&&ze.length),ae=[],le=g(V?"bookPage.sec.physical":"bookPage.sec.images");(_e.length||I.text.length||l)&&ae.push({id:"fulltext",label:g("bookPage.sec.fulltext"),count:_e.length?Ne:void 0}),I.groups.length&&ae.push({id:"images",label:le,count:A}),X&&ae.push({id:"lineage",label:g("bookPage.sec.lineage")}),We.length&&ae.push({id:"collections",label:g("section.containedIn"),count:We.length}),(Ue=e.location_history)!=null&&Ue.length&&ae.push({id:"provenance",label:g("section.locationHistory")});const ke=C=>(d==null?void 0:d(C))??null,H=_e[0],fe=H?ke(H.file):null,ue=$?_e:_e.slice(0,ob),$e=(C,ie,re)=>C?t.jsx("a",{className:re,href:C.href??"#",onClick:C.onClick?ve=>{ve.metaKey||ve.ctrlKey||(ve.preventDefault(),C.onClick())}:void 0,children:ie}):t.jsx("span",{className:re,children:ie}),G=t.jsxs(t.Fragment,{children:[(_e.length>0||I.text.length>0||l)&&t.jsxs(ot,{id:"fulltext",title:g("bookPage.sec.fulltext"),meta:_e.length>0?t.jsx(it,{items:[Ne,(Ve=a==null?void 0:a.source)!=null&&Ve.name?g("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!H&&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"})]}),H&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:g("bookPage.readFrom",{ch:f(ao(H.title)[0])||g("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((H.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),$e(fe,t.jsxs(t.Fragment,{children:[g("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),_e.length>1&&t.jsx("ul",{className:"bim-d-chap",children:ue.map(C=>{const[ie,re]=ao(C.title);return t.jsx("li",{children:$e(ke(C.file),t.jsxs(t.Fragment,{children:[ie&&t.jsx("b",{children:f(ie)}),f(re||C.file)]}))},C.file)})}),_e.length>ue.length&&t.jsx(or,{label:g("detail.expandRest",{n:_e.length-ue.length,unit:Be}),onClick:()=>_(!0)}),I.text.length>0&&t.jsxs(t.Fragment,{children:[(_e.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:g("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:I.text.map((C,ie)=>t.jsx(Nr,{item:C,siblings:I.text,listedVolumeCounts:K},`${C.id||C.url||C.name}-${ie}`))})})]})]}),I.groups.length>0&&t.jsx(ot,{id:"images",title:le,meta:t.jsx(it,{items:[I.groups.length>1?g("bookPage.groupCount",{n:I.groups.length}):"",g("bookPage.placeCount",{n:A})]}),children:t.jsx(Hc,{groups:I.groups,listedVolumeCounts:K})}),X&&t.jsx(ot,{id:"lineage",title:g("bookPage.sec.lineage"),meta:(qe=E==null?void 0:E.derived_from)!=null&&qe.length?g("bookPage.lineageMeta"):void 0,action:N?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":g("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":z==="flow",onClick:()=>P("flow"),children:g("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":z==="graph",onClick:()=>P("graph"),children:g("bookPage.viewGraph")})]}):void 0,children:z==="graph"&&N?t.jsx(Rr,{graph:N,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(C,ie)=>t.jsx(et,{id:C,label:f(ie),onNavigate:o,renderLink:r,dense:!0})}):t.jsx(ab,{data:e,heading:je||ne,yearText:Q,refName:Y,onNavigate:o,renderLink:r})}),We.length>0&&t.jsx(ot,{id:"collections",title:g("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:We.map((C,ie)=>{var Oe,Z;const re=typeof C=="string"?C:C.id,ve=typeof C=="string"?[]:An(C.volume_index),se=y.get(re),he=(se==null?void 0:se._member_count)||((Oe=se==null?void 0:se.books)==null?void 0:Oe.length)||((Z=se==null?void 0:se.contained_works)==null?void 0:Z.length)||0;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:re,label:se?f(se.title):re,onNavigate:o,renderLink:r,dense:!0}),ve.length>0&&t.jsx(sb,{volumes:ve,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&&g("bookPage.totalOf",{n:he,unit:m.unit.bu})})]},`${re}-${ie}`)})})})}),(Ze=e.location_history)!=null&&Ze.length?t.jsx(ot,{id:"provenance",title:g("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((C,ie)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(C.name)}),([C.start_date,C.end_date].filter(Boolean).join("—")||C.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(it,{items:[[C.start_date,C.end_date].filter(Boolean).join("—"),C.description?f(C.description):""]})})]},ie))})}):null,ae.length===0&&t.jsx(ot,{title:g("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:g("bookPage.emptyText")})})]}),Te=b.findIndex(C=>C.id===e.id),Ie=D.length<=wa,B=Ie&&Te>=0?b.slice(Math.max(0,Te-Sa),Te+Sa+1):b.filter(C=>C.id!==e.id),oe=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(et,{id:x.id,label:f(x.title),onNavigate:o,renderLink:r})}),t.jsx(it,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(C=>`${C.dynasty?`〔${f(C.dynasty)}〕`:""}${f(C.name)}`),f(Pt(x,m.unit.juan)),x._edition_count?g("bookPage.editionCount",{n:x._edition_count}):""]}),((Ye=x.description)==null?void 0:Ye.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(Zt,{id:"siblings",timeline:!0,title:Ie?g("bookPage.siblings"):m.relation.siblingVersions,meta:Ie?g("bookPage.byEra"):g("bookPage.kindCount",{n:R}),cap:B.length,items:B.map(C=>C.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(C.edition||C.title||C.id)}):t.jsx(et,{id:C.id,label:f(C.edition||C.title||C.id),onNavigate:o,renderLink:r,dense:!0})),metas:B.map(C=>[C.year!=null?C.year<0?g("detail.bce",{n:-C.year}):String(C.year):"",C.id===e.id?g("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:B.findIndex(C=>C.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(et,{id:x.id,label:g("bookPage.viewAllInWork",{n:D.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),xe=e.work_id?t.jsx(Fl,{caption:m.section.belongsToWork,children:t.jsx(et,{id:e.work_id,label:x?f(x.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return t.jsx(On,{railTop:c,back:p,up:xe,nav:ae,railLinks:u,main:G,card:de,side:oe})};function sb({volumes:e,unit:n}){const{t:o}=ee();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 ab({data:e,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:a}){var w;const{t:l,convert:d}=ee(),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==="底本"),g=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&&rb.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,j)=>t.jsx(et,{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)})]}),g.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:g.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(At,{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 Rn=16,lb=200,cb=16,Kc=({data:e,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var G,Te,Ie,B,oe,xe,Re;const{t:p,convert:u,messages:m}=ee(),[g,f]=h.useState(""),[x,k]=h.useState(!1),[y,w]=h.useState(null),[b,j]=h.useState(""),[S,v]=h.useState(!1),$=h.useMemo(()=>Bl(e,n),[e,n]),[_,z]=h.useState(new Map),P=!!o&&$.rows.length>0&&$.rows.length<=lb,N=P&&($.rows.length<=Rn||S),T=N&&$.rows.every(F=>!F.id||_.has(F.id)),D=F=>{var me;return Io(F?(me=_.get(F))==null?void 0:me.l1:void 0)},R=h.useMemo(()=>{const F=g.trim(),me=F?u(F):"";return $.rows.filter(te=>{var ze,Ue;if(b&&Io(te.id?(ze=_.get(te.id))==null?void 0:ze.l1:void 0)!==b)return!1;if(!me)return!0;const ge=te.id&&((Ue=_.get(te.id))==null?void 0:Ue.title)||te.title;return u(ge).includes(me)||(te.subItems||[]).some(Ve=>u(Ve).includes(me))})},[$.rows,g,b,_,u]),E=x?R:R.slice(0,Rn),L=h.useMemo(()=>(N?$.rows:E).filter(F=>F.id&&!_.has(F.id)).map(F=>F.id),[N,$.rows,E,_]);h.useEffect(()=>{if(!o||L.length===0)return;let F=!1;const me=L.slice(0,cb);return Ri(me,Ni,te=>o.getItem(te).then(ge=>{var Ve,qe;const ze=ge??{},Ue={title:ze.title,edition:ze.edition,authors:ze.authors,measure:ge?Pt(ge,m.unit.juan):void 0,versionCount:ze._edition_count??((Ve=ze.books)==null?void 0:Ve.length),l1:((qe=ze.classification)==null?void 0:qe.l1)||void 0};return[te,Ue]}).catch(()=>[te,{}]),()=>F).then(te=>{F||z(ge=>{const ze=new Map(ge);for(const[Ue,Ve]of te)ze.set(Ue,Ve);return ze})}),()=>{F=!0}},[o,L,m.unit.juan]);const I=(e.contained_in||[])[0];h.useEffect(()=>{if(!I){w(null);return}if(w({id:I}),!o)return;let F=!1;return o.getItem(I).then(me=>{F||w({id:I,title:me==null?void 0:me.title})}).catch(()=>{}),()=>{F=!0}},[o,I]);const A=h.useMemo(()=>Oc(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),V=A.text.length+A.groups.reduce((F,me)=>F+me.rows.length+me.mirrors.length,0),q=e.contained_works||[],U=new Set($.rows.map(F=>F.id).filter(Boolean)),O=q.length>0&&!q.every(F=>U.has(F.id)),K=(()=>{const F=$.rows.map(me=>me.edition).filter(Boolean);return F.length>1&&new Set(F).size===1})(),Y=$.rows.some(F=>F.volumes.length>0||F.expected!=null),W=e._member_count||((G=e.books)==null?void 0:G.length)||q.length,ne=e._members_truncated?W:$.rows.length,je=Pt(e,m.unit.juan),Q=e.count,de=F=>typeof F=="number"&&Number.isFinite(F)?F:null,We=de(Q==null?void 0:Q.juan)??de((Te=e.juan_count)==null?void 0:Te.number),_e=de(Q==null?void 0:Q.ce)??($.totalVolumes||null),Be=[{value:ne,label:p("collectionPage.stat.titles")},{value:We??0,label:m.unit.juan},{value:_e??0,label:m.unit.volume}],Ne=h.useMemo(()=>{var te,ge;const F=[];if((te=e.publication_info)!=null&&te.details&&F.push({label:p("collectionPage.fact.publication"),value:u(e.publication_info.details)}),W&&(W!==$.rows.length||e._members_truncated)){const ze=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");F.push({label:ze,value:`${W} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const me=[de(Q==null?void 0:Q.zhong)!=null?p("collectionPage.nZhong",{n:Q.zhong}):"",de(Q==null?void 0:Q.han)!=null?p("collectionPage.nHan",{n:Q.han}):""].filter(Boolean);return me.length&&F.push({label:p("collectionPage.fact.expected"),value:me.join(" ")}),We==null&&je&&F.push({label:p("collectionPage.fact.measure"),value:u(je),title:(ge=e.juan_count)!=null&&ge.description?u(e.juan_count.description):void 0}),F},[e,W,$.rows.length,We,je,Q,u,p,m]),X=h.useMemo(()=>{if(!T)return[];const F=new Map;for(const te of $.rows){const ge=D(te.id);ge&&F.set(ge,(F.get(ge)??0)+1)}const me=Mn.filter(te=>(F.get(te.key)??0)>0);return me.length<2?[]:[{key:"",label:`${m.catalog.all} ${ne}`},...me.map(te=>({key:te.key,label:`${te.label} ${F.get(te.key)}`}))]},[T,$.rows,_,m]),ae=h.useMemo(()=>{if(!T||!$.rows.some(ge=>ge.volumes.length>0))return null;const F=[],me=$.rows.filter(ge=>ge.volumes.length>0).map(ge=>({k:D(ge.id)??"",from:Math.min(...ge.volumes),to:Math.max(...ge.volumes)})).sort((ge,ze)=>ge.from-ze.from);for(const ge of me){const ze=ge.to-ge.from+1,Ue=F[F.length-1];Ue&&Ue.key===ge.k?(Ue.to=Math.max(Ue.to,ge.to),Ue.n+=ze):F.push({key:ge.k,from:ge.from,to:ge.to,n:ze})}const te=me.reduce((ge,ze)=>Math.max(ge,ze.to),0);return F.length>1&&F.some(ge=>ge.key)?{segs:F,last:te}:null},[T,$.rows,_]),le=(Ie=e.description)==null?void 0:Ie.text,ke=t.jsx(Fn,{kind:p("collectionPage.kind"),title:u(e.title),byline:t.jsx(Tr,{authors:e.authors,onNavigate:r,renderLink:s}),meta:t.jsx(it,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(B=e.publication_info)!=null&&B.year?u(e.publication_info.year):""]}),description:le||(oe=e.history)!=null&&oe.length?t.jsxs(t.Fragment,{children:[le&&t.jsx(At,{text:le,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((F,me)=>t.jsx("li",{children:u(F)},me))}):null]}):void 0,clampDescription:rr(le)||(((Re=e.history)==null?void 0:Re.length)??0)>2?6:void 0,stats:Be,facts:Ne,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((F,me)=>{const te=Mn.find(ge=>ge.key===F.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!te,title:te?p("collectionPage.dist.segTitle",{section:u(te.label),from:F.from,to:F.to}):void 0,"aria-label":te?p("collectionPage.dist.only",{section:u(te.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!te&&b===F.key,style:{flexGrow:F.n,background:i(te?te.token:"rule")},onClick:()=>{te&&(j(b===F.key?"":F.key),k(!1))}},me)})}),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})})]})]})}),H=[];$.rows.length&&H.push({id:"titles",label:p("collectionPage.sec.titles"),count:ne}),V&&H.push({id:"resources",label:p("collectionPage.sec.resources"),count:V}),O&&H.push({id:"works",label:m.section.containedWorks,count:q.length});const fe=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(ot,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(it,{items:[`${ne} ${m.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:m.unit.volume}):"",R.length!==ne?p("collectionPage.currentN",{n:R.length,unit:m.unit.items}):""]}),action:a,children:[($.rows.length>Rn||X.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[X.length>0&&t.jsx(Ci,{items:X,value:b,onChange:F=>{j(F),k(!1)}}),P&&$.rows.length>Rn&&!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>Rn&&t.jsx("input",{type:"search",className:"bim-d-find",value:g,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:F=>{f(F.target.value),k(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&zi(R.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[Y&&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((F,me)=>{var Ze;const te=F.id?_.get(F.id):void 0,ge=te!=null&&te.title&&F.title===F.id?te.title:F.title,ze=((te==null?void 0:te.authors)||[]).find(Ye=>Ye&&Ye.name),Ue=[ze?`${ze.dynasty?`〔${u(ze.dynasty)}〕`:""}${u(ze.name)}${ze.role?` ${u(ze.role)}`:""}`:"",te!=null&&te.measure?u(te.measure):"",(Ze=F.subItems)!=null&&Ze.length?F.subItems.map(Ye=>u(Ye)).join("、"):"",(te!=null&&te.edition||F.edition)&&!K?u((te==null?void 0:te.edition)||F.edition||""):""].filter(Boolean),Ve=Mn.find(Ye=>Ye.key===D(F.id)),qe=F.volumes.length>0?p("collectionPage.volumeRange",{range:$i(F.volumes,m.unit.volume),unit:m.unit.volume}):F.expected!=null?`${F.found??0}/${F.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[Y&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${qe?"":" bim-d-zt-blank"}`,children:[Ve&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(Ve.token)}}),qe||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[F.id?t.jsx(et,{id:F.id,label:u(ge),onNavigate:r,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:u(ge)}),Ue.length>0?t.jsx(it,{items:Ue}):F.id&&!te&&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${te!=null&&te.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:te!=null&&te.versionCount?p("collectionPage.nZhong",{n:te.versionCount}):""})]},`${F.id??F.title}-${me}`)})})]}),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(ir,{total:R.length,shown:E.length,unit:m.unit.items,onClick:()=>k(!0)})]}),V>0&&t.jsxs(ot,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:V}),children:[A.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[A.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:A.text.map((F,me)=>t.jsx(Nr,{item:F,siblings:A.text},`${F.id||F.url||F.name}-${me}`))})})]}),t.jsx(Hc,{groups:A.groups})]}),$.rows.length===0&&V===0&&t.jsx(ot,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),ue=O?t.jsx(Zt,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:q.length}),cap:12,items:q.map(F=>t.jsx(et,{id:F.id,label:u(F.title),onNavigate:r,renderLink:s,dense:!0}))}):null,$e=y?t.jsx(Fl,{caption:p("collectionPage.parent"),children:t.jsx(et,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return t.jsx(On,{railTop:l,back:d,up:$e,nav:H,railLinks:c,main:fe,card:ke,side:ue})},db=16,lo=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function _a(e){if(!e)return lo.length;const n=lo.indexOf(e);return n===-1?lo.length:n}function pb(e,n,o){if(n)return e[n]??o(n)}function ub(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const mb={秦:[-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]},qc=({data:e,transport:n,onNavigate:o,renderLink:r,railTop:s,back:a,railLinks:l})=>{var ue,$e,G,Te,Ie;const{t:d,convert:c,messages:p}=ee(),u=B=>ub(B,d),[m,g]=h.useState("全部"),[f,x]=h.useState(!1),[k,y]=h.useState("default"),[w,b]=h.useState(new Map),j=h.useMemo(()=>(e.works||[]).map(B=>{const oe=w.get(B.work_id);return{id:B.work_id,title:(oe==null?void 0:oe.title)??B.title??B.work_id,role:B.role||"",cls:tr(B.role),versionCount:oe==null?void 0:oe.versionCount,section:oe==null?void 0:oe.cls,l1:oe==null?void 0:oe.l1,measure:oe==null?void 0:oe.measure,hasImage:oe==null?void 0:oe.hasImage,loaded:!!(oe!=null&&oe.loaded)}}),[e.works,w]),S=h.useMemo(()=>Ml((e.works||[]).map(B=>B.role),d("detail.roleAll")),[e.works,d]),v=h.useMemo(()=>{const B=m==="全部"?j:j.filter(oe=>oe.cls===m);return k==="versions"?[...B].sort((oe,xe)=>(xe.versionCount??-1)-(oe.versionCount??-1)):B},[j,m,k]),$=f?v:v.slice(0,db),_=h.useMemo(()=>$.filter(B=>!w.has(B.id)).map(B=>B.id),[$,w]);h.useEffect(()=>{if(!n||_.length===0)return;let B=!1;return Ri(_,Ni,oe=>n.getItem(oe).then(xe=>{var te,ge,ze,Ue,Ve;const Re=xe??{},F=Re._edition_count??(((te=Re.books)==null?void 0:te.length)??0)+(((ge=Re.collections)==null?void 0:ge.length)??0),me=[(ze=Re.classification)==null?void 0:ze.l1,(Ue=Re.classification)==null?void 0:Ue.l2].filter(Boolean).join(" ");return[oe,{id:oe,title:Re.title,versionCount:F,loaded:!0,cls:me||void 0,l1:((Ve=Re.classification)==null?void 0:Ve.l1)||void 0,measure:xe&&Pt(xe,p.unit.juan)||void 0,hasImage:!!(Re.has_image??Re._has_image)}]}).catch(()=>[oe,{id:oe,loaded:!0}]),()=>B).then(oe=>{B||b(xe=>{const Re=new Map(xe);for(const[F,me]of oe)Re.set(F,me);return Re})}),()=>{B=!0}},[n,_,p.unit.juan]);const z=h.useMemo(()=>{const B=new Map;for(const oe of e.alt_names||[]){const xe=oe.type||p.section.aliases;B.has(xe)||B.set(xe,[]),B.get(xe).push(oe.name)}return[...B.entries()].sort((oe,xe)=>_a(oe[0])-_a(xe[0])).map(([oe,xe])=>({label:oe,names:xe}))},[e.alt_names,p]),P=e.birth_year??((ue=e.dates)==null?void 0:ue.birth)??void 0,N=e.death_year??(($e=e.dates)==null?void 0:$e.death)??void 0,T=(G=e.dates)==null?void 0:G.floruit,D=P!=null||N!=null?`${u(P)||"?"}—${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=z.filter(B=>R.has(B.label)),L=z.filter(B=>!R.has(B.label)),I=L.reduce((B,oe)=>B+oe.names.length,0),A=h.useMemo(()=>{const B=[];for(const xe of E)B.push({label:xe.label,value:xe.names.map(Re=>c(Re)).join("、")});const oe=(e.works||[]).length;return oe&&B.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:oe})}),B},[e.works,E,c,d]),V=B=>{var oe;return(oe=z.find(xe=>B.includes(xe.label)))==null?void 0:oe.names[0]},q=V(["字"]),U=V(["號","号"]),O=[q?d("entityPage.zi",{name:c(q)}):"",U?d("entityPage.hao",{name:c(U)}):""].filter(Boolean).join(","),K=e.native_place,Y=e.dynasty?mb[e.dynasty]:void 0,W=(()=>{if(!Y||P==null||N==null||N<P)return null;const[B,oe]=Y,xe=Math.max(P,B),Re=Math.min(N,oe);if(Re<=xe)return null;const F=oe-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(P),death:u(N),years:N-P+1}),children:t.jsx("i",{style:{left:`${(xe-B)/F*100}%`,width:`${(Re-xe)/F*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-P+1})}),t.jsx("span",{children:u(oe)})]})]})})(),ne=h.useMemo(()=>{if(!n||j.length===0||j.some(xe=>!xe.loaded))return null;const B=new Map;for(const xe of j){const Re=Io(xe.l1);Re&&B.set(Re,(B.get(Re)??0)+1)}const oe=Mn.map(xe=>({...xe,n:B.get(xe.key)??0})).filter(xe=>xe.n>0);return oe.length?oe:null},[j,n]),je=t.jsxs(Fn,{kind:pb(p.entityPage.subtype,e.subtype,c),title:c(e.primary_name||e.title),subtitle:O||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(it,{items:[e.dynasty?c(e.dynasty):"",D,K?d("entityPage.nativePlace",{place:c(K)}):""]}),W]}),description:(Te=e.description)!=null&&Te.text?t.jsx(At,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:rr((Ie=e.description)==null?void 0:Ie.text)?6:void 0,facts:A,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(h.Fragment,{children:[t.jsx("dt",{children:c(B.label)}),t.jsx("dd",{children:B.names.map(oe=>c(oe)).join("、")})]},B.label))})]}),ne&&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:ne.map(B=>t.jsx("i",{style:{flexGrow:B.n,background:i(B.token)}},B.key))}),t.jsx("div",{className:"bim-d-dist-key",children:ne.map(B=>t.jsxs("span",{children:[t.jsx("i",{style:{background:i(B.token)}}),c(B.label)," ",B.n]},B.key))})]})]}),Q=h.useMemo(()=>j.filter(B=>B.loaded&&(B.versionCount??0)>0).sort((B,oe)=>(oe.versionCount??0)-(B.versionCount??0)).slice(0,3),[j]),de=!!n&&j.length>=3&&$.some(B=>!B.loaded),We=m==="全部"&&(de||Q.length>=2),_e=e.external_ids||{},Be=[];_e.cbdb_id!=null&&Be.push({label:"CBDB",id:String(_e.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${_e.cbdb_id}`,note:_e.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const Ne=_e.wikidata_id;Ne&&Be.push({label:"Wikidata",id:Ne,href:`https://www.wikidata.org/wiki/${Ne}`});const X=_e.viaf_id;X&&Be.push({label:"VIAF",id:X,href:`https://viaf.org/viaf/${X}`});const ae=S.map(B=>({key:B.cls,label:`${B.label} ${B.count}`})),le=[...We&&!de?[{id:"featured",label:d("entityPage.sec.featured"),count:Q.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...Be.length?[{id:"external",label:d("entityPage.sec.external"),count:Be.length}]:[]],ke=We?t.jsxs(ot,{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&&Q.map(B=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(et,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0})}),t.jsx(it,{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,H=j.length===0?t.jsx(ot,{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:[ke,t.jsxs(ot,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(it,{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(Ci,{items:ae,value:m,onChange:B=>{g(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&&zi(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(et,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0}),B.measure?t.jsx(it,{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(ir,{total:v.length,shown:$.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),fe=Be.length>0?t.jsx(Zt,{id:"external",title:d("entityPage.sec.external"),items:Be.map(B=>t.jsxs("a",{href:B.href,target:"_blank",rel:"noopener noreferrer",children:[B.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Be.map(B=>B.id),foot:_e.cbdb_id!=null&&_e.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(On,{railTop:s,back:a,nav:le,railLinks:l,main:H,card:je,side:fe})},Er="(max-width: 719px)",gb=`${Er}, (pointer: coarse)`,Xc=`
|
|
1332
|
+
`,bh=120;function mt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function yh(e,n=bh){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 jh(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 vh(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(o=>{if(!o||typeof o!="object")return"";const r=o,s=mt(r.name);return s?[mt(r.dynasty)&&`〔${mt(r.dynasty)}〕`,s,mt(r.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function hc(e,n){const o=mt(n.type),r=mt(n.primary_name)??mt(n.title)??e,s=o==="entity"?[mt(n.dynasty),jh(n),mt(n.native_place)].filter(Boolean).join(" · "):[vh(n),mt(n.edition),mt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?mt(n.description.text):mt(n.description);return{id:e,type:o,title:r,meta:s||void 0,description:yh(a)}}function fc(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 xc(e){return async n=>{const o=await e.getItem(n);if(o)return hc(n,o);if(e.getEntry){const r=await e.getEntry(n);if(r)return fc(r)}return null}}const Ds=new WeakMap;function kh(e,n,o){let r=Ds.get(e);r||(r=new Map,Ds.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 bc=e=>`/item/${encodeURIComponent(e)}`,wh={work:"書名",person:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},Sh=typeof window>"u"?h.useEffect:h.useLayoutEffect;function kr(e,n){return h.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:xc(e)}:null,[n,e])}const _h=e=>e,$h=({text:e,entities:n,offsets:o="text",plainBase:r=0,transport:s,loadSummary:a,buildHref:l=bc,onNavigate:d,renderText:c=_h,hoverDelayMs:p=250,injectStyles:u=!0,className:m})=>{const g=h.useMemo(()=>{const x=o==="plain"?mc(e,n,r):n;return gc(e,x)},[e,n,o,r]),f=kr(s,a);return t.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&t.jsx("style",{children:vr}),g.map(x=>x.type==="text"?t.jsx(h.Fragment,{children:c(x.text)},`t${x.start}`):t.jsx(wr,{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}`))]})},wr=({span:e,label:n,hasBrackets:o,loader:r,buildHref:s,onNavigate:a,renderText:l,hoverDelayMs:d})=>{const c=h.useId(),[p,u]=h.useState(!1),m=h.useRef(null),g=`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)};h.useEffect(()=>k,[]);const y=h.useCallback(j=>{k(),j<=0?u(!0):m.current=setTimeout(()=>u(!0),j)},[]),w=h.useCallback(()=>{k(),u(!1)},[]);if(!e.targetId)return t.jsx("span",{className:g,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:g,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(Ch,{id:c,entityId:b,span:e,loader:r})]})},Ch=({id:e,entityId:n,span:o,loader:r})=>{const{convert:s}=Q(),a=h.useRef(null),[l,d]=h.useState("start"),[c,p]=h.useState(r?{status:"loading"}:{status:"ready",summary:null});h.useEffect(()=>{if(!r)return;let g=!1;return p({status:"loading"}),kh(r.owner,r.load,n).then(f=>{g||p({status:"ready",summary:f})}).catch(()=>{g||p({status:"error"})}),()=>{g=!0}},[r,n]),Sh(()=>{const g=a.current;if(!g||typeof window>"u")return;const f=g.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(wh[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("摘要載入失敗")})]})},zh=e=>`/item/${encodeURIComponent(e)}`;function Th(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 Nh(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 Sr=({pageData:e,pages:n,punctuations:o=Eh,selectedCharIds:r,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:u,convert:m,scrollToPage:g,entities:f,entityTransport:x,loadEntitySummary:k,buildEntityHref:y,onEntityNavigate:w})=>{const b=h.useRef(null),j=h.useRef(0),S=h.useMemo(()=>{const I=new Map;return p&&o.forEach((A,V)=>{const q=A.id?A:{...A,id:`${A.anchor}#${V}`},O=I.get(q.anchor)||[];O.push(q),I.set(q.anchor,O)}),I},[o,p]),v=h.useMemo(()=>(n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}]).filter(A=>A.columns.some(V=>V.chars.length>0)).map(A=>{const V=[...A.columns].sort((W,K)=>W.col-K.col),q=[];let O=[];for(const W of V)for(const K of W.chars){const{before:Y,after:F}=Th(S.get(K.id)||[]),te=(S.get(K.id)||[]).some(je=>je.kind==="break");O.push({charData:K,col:W.col,beforePuncts:Y,afterPuncts:F}),te&&(q.push({id:`para-p${A.page}-${q.length}`,chars:O}),O=[])}return O.length>0&&q.push({id:`para-p${A.page}-${q.length}`,chars:O}),{page:A.page,paragraphs:q}}),[n,e,S]),$=h.useMemo(()=>{const I=[];for(const A of v)for(const V of A.paragraphs)for(const q of V.chars)I.push(q.charData.id);return I},[v]),_=h.useMemo(()=>{const I=new Map;if(!f||f.length===0)return I;const A=new Map($.map((V,q)=>[V,q]));for(const V of f){if(!V.anchor)continue;const q=A.get(V.anchor.start),O=A.get(V.anchor.end);if(!(q===void 0||O===void 0||O<q))for(let W=q;W<=O;W++)I.has($[W])||I.set($[W],V)}return I},[f,$]),z=kr(x,k),P=_.size>0,N=h.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=h.useMemo(()=>({click:I=>{var A,V;j.current=Date.now()+1200,(V=(A=N.current).onCharClick)==null||V.call(A,I)},enter:I=>{var A,V;return(V=(A=N.current).onCharHover)==null?void 0:V.call(A,I)},leave:()=>{var I,A;return(A=(I=N.current).onCharHover)==null?void 0:A.call(I,null)},navigate:(I,A)=>{var q,O;if(!(A.detail===0||A.ctrlKey||A.metaKey||A.shiftKey)){A.preventDefault();return}(O=(q=N.current).onEntityNavigate)==null||O.call(q,I,A)}}),[]),D=Ih(r),R=h.useRef(null);h.useEffect(()=>{var A,V;if((A=R.current)==null||A.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]),h.useEffect(()=>{let I=null;const A=()=>{var we,Oe;I=null;const q=window.getSelection(),O=b.current;if(!q||q.isCollapsed||q.rangeCount===0||!O)return;const W=q.getRangeAt(0),K=W.commonAncestorContainer,Y=K.nodeType===3?K.parentElement:K;if(!Y||!O.contains(Y))return;const F=O.querySelectorAll("span[data-char-id]");let te=0,je=F.length;for(;te<je;){const Te=te+je>>1;W.comparePoint(F[Te],0)<0?te=Te+1:je=Te}const oe=te;for(je=F.length;te<je;){const Te=te+je>>1;W.comparePoint(F[Te],0)<=0?te=Te+1:je=Te}const ie=te-1;if(ie<oe)return;const Be=[];for(let Te=oe;Te<=ie;Te++)Be.push(F[Te].getAttribute("data-char-id"));Be.length>0&&(j.current=Date.now()+1200,(Oe=(we=N.current).onSelectionChange)==null||Oe.call(we,Be))},V=()=>{I&&clearTimeout(I),I=setTimeout(A,120)};return document.addEventListener("selectionchange",V),()=>{document.removeEventListener("selectionchange",V),I&&clearTimeout(I)}},[]),h.useEffect(()=>{var I;if(r.size===1){const A=Array.from(r)[0],V=(I=b.current)==null?void 0:I.querySelector(`span[data-char-id="${A}"]`);V&&V.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[r]);const E=g==null?void 0:g.nonce;h.useEffect(()=>{var A;if(!g)return;const I=(A=b.current)==null?void 0:A.querySelector(`[data-page-section="${g.page}"]`);I&&(j.current=Date.now()+800,I.scrollIntoView({behavior:"auto",block:"start"}))},[E]);const L=!!u;return h.useEffect(()=>{var W;if(!L)return;const I=Array.from(((W=b.current)==null?void 0:W.querySelectorAll("[data-page-section]"))??[]);if(I.length===0)return;const A=120;let V=0;const q=()=>{var te,je;if(V=0,Date.now()<j.current)return;let K=0,Y=I.length-1;for(;K<Y;){const oe=K+Y+1>>1;I[oe].getBoundingClientRect().top<=A?K=oe:Y=oe-1}const F=parseInt(I[K].getAttribute("data-page-section")||"",10);isNaN(F)||(je=(te=N.current).onVisiblePageChange)==null||je.call(te,F)},O=()=>{V||(V=requestAnimationFrame(q))};return window.addEventListener("scroll",O,{passive:!0}),q(),()=>{window.removeEventListener("scroll",O),V&&cancelAnimationFrame(V)}},[L,v]),t.jsxs("div",{ref:b,className:"guji-text-pane-content",children:[P&&t.jsx("style",{children:vr}),t.jsx("div",{className:"guji-text-reflow-view",children:v.map((I,A)=>t.jsx(Ah,{pGroup:I,first:A===0,selected:D.get(I.page)??Rh,entityOfChar:_,entityLoader:z,convert:m,buildHref:y??zh,handlers:T},`page-sec-${I.page}`))})]})},Rh=new Set,Eh=[];function Ih(e){const n=h.useRef(new Map);return h.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 Lh(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 Ah=h.memo(function({pGroup:n,first:o,selected:r,entityOfChar:s,entityLoader:a,convert:l,buildHref:d,handlers:c}){const p=h.useMemo(()=>{const m=new Map;if(!l)return m;for(const g of n.paragraphs){const f=Lh(g.chars.map(x=>x.charData.char),l);g.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:Nh(m.chars,s).map((g,f)=>{const x=g.chars.map(({charData:w,col:b,beforePuncts:j,afterPuncts:S},v)=>{const $=!!g.entity&&v===0,_=!!g.entity&&v===g.chars.length-1,z=$?[]:j,P=_?[]:S;return t.jsxs(h.Fragment,{children:[z.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)}),P.map(N=>t.jsx("span",{className:"guji-text-punct","data-punct-id":N.id,children:N.mark},N.id))]},w.id)});if(!g.entity)return t.jsx(h.Fragment,{children:x},`r${f}`);const k=g.chars[0].beforePuncts.map(w=>t.jsx("span",{className:"guji-text-punct","data-punct-id":w.id,children:w.mark},w.id)),y=g.chars[g.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(h.Fragment,{children:[k,t.jsx(wr,{span:g.entity,label:g.chars.map(w=>u(w.charData)).join(""),hasBrackets:!0,loader:a,buildHref:d,onNavigate:c.navigate,renderText:()=>x,hoverDelayMs:250}),y]},`${g.entity.key}@${f}`)})},m.id))]})}),yc=1,jc=6,ti={s:1,x:0,y:0},si=(e,n,o)=>Math.min(o,Math.max(n,e));function _r(e,n,o){const r=si(e.s,yc,jc);return{s:r,x:si(e.x,n*(1-r),0),y:si(e.y,o*(1-r),0)}}function no(e,n,o,r,s,a){const l=si(e.s*r,yc,jc),d=l/e.s;return _r({s:l,x:n-(n-e.x)*d,y:o-(o-e.y)*d},s,a)}function Ph(e,n,o,r,s){return _r({s:e.s,x:e.x+n,y:e.y+o},r,s)}function Mh(e,n,o){const r=n===1?e*16:n===2?e*400:e;return Math.exp(-r*(o?.01:.0015))}const Us=4,Bh=h.forwardRef(function({children:n,onScaleChange:o,resetKey:r,style:s},a){const l=h.useRef(null),[d,c]=h.useState(ti),p=h.useRef(d),u=h.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))},g=()=>{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}};h.useImperativeHandle(a,()=>({zoomBy(b){const{w:j,h:S}=g();m(no(p.current,j/2,S/2,b,j,S))},reset(){m(ti)}})),h.useEffect(()=>{m(ti)},[r]),h.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{const{w:S,h:v}=g(),$=_r(p.current,S,v);($.x!==p.current.x||$.y!==p.current.y)&&m($)});return j.observe(b),()=>j.disconnect()},[]),h.useEffect(()=>{const b=l.current;if(!b)return;const j=S=>{const v=Mh(S.deltaY,S.deltaMode,S.ctrlKey);if(p.current.s<=1&&v<1)return;S.preventDefault();const{w:$,h:_,left:z,top:P}=g();m(no(p.current,S.clientX-z,S.clientY-P,v,$,_))};return b.addEventListener("wheel",j,{passive:!1}),()=>b.removeEventListener("wheel",j)},[]);const f=h.useRef(new Map),x=h.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=Us+1}},y=b=>{var D;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:z,top:P}=g();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-z,A=(R.y+E.y)/2-P;m(no(p.current,I,A,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<=Us)){if(!v.dragging){v.dragging=!0;try{(D=l.current)==null||D.setPointerCapture(b.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&m(Ph(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(ti),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 vc(e,n,o,r,s){const[a,l]=h.useState(n??null),[d,c]=h.useState(!1),p=h.useRef(0);return h.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(g=>{u===p.current&&l(g??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 Wh(e,n,o){const[r,s]=h.useState([]),a=h.useRef(0);return h.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?uc(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,o]),r}const Vs={padding:24,color:i("desc-fg"),fontSize:14};function Gs({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 Ys=/^https?:\/\//i;function Oh(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&&Ys.test(o)?o:void 0,license:n(e.license),license_url:r&&Ys.test(r)?r:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function Fh(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 Hh(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 kc(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 Dh(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 g=a.get(u);return{key:u,label:m??(g?kc(g,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(g=>a.has(g))||((m=u.children)==null?void 0:m.length)});if(c&&c.length>0){const u=(m,g)=>{var x;if(m.files.length===1&&!((x=m.children)!=null&&x.length))return d(m.files[0],r(m.label));const f=qg(m,n);return{key:`group:${g}`,label:r(m.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:dc(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,`${g}.${y}`))]}};return c.map((m,g)=>u(m,`${g}`))}return e.chapters.map(u=>d(u.file))}const $r=({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:g,revisedAt:f,backHref:x,backLabel:k,resolveWarpData:y,warpData:w,resolveEntities:b,onEntityNavigate:j,className:S,style:v})=>{var Gr,Yr,Kr;const{t:$,convert:_}=Q(),z=h.useMemo(()=>xl(n),[n]),[P,N]=Cl(),T=tt(),D=h.useRef(s);D.current=s;const[R,E]=h.useState(null),[L,I]=h.useState("loading");h.useEffect(()=>{let M=!1;return E(null),I("loading"),z.getManifest(e).then(pe=>{M||(pe?(E(pe),I("ready")):I("missing"))}).catch(()=>{M||I("missing")}),()=>{M=!0}},[z,e]);const A=o!==void 0,V=r!==void 0,[q,O]=h.useState(null),[W,K]=h.useState(null);h.useEffect(()=>{O(null),K(null)},[e]);const Y=_e.pickTextVersion(R,A?o:q),F=((Gr=R==null?void 0:R.versions.find(M=>M.key==="default"))==null?void 0:Gr.key)??((Yr=R==null?void 0:R.versions[0])==null?void 0:Yr.key)??"default",te=(Y==null?void 0:Y.key)??null,je=V?r:W,oe=h.useCallback((M,pe,Ae)=>{var Ve;(Ve=D.current)==null||Ve.call(D,{key:M,chapter:pe,isDefault:M===F},Ae)},[F]);h.useEffect(()=>{!R||!A||o==null||R.versions.some(M=>M.key===o)||oe(F,null,"auto")},[R,A,o,F,oe]);const ie=h.useRef(new Map);h.useEffect(()=>{ie.current.clear()},[z,e]);const Be=h.useCallback(async M=>{const pe=`${e}
|
|
1333
|
+
${M}`;if(ie.current.has(pe))return ie.current.get(pe)??null;const Ae=await z.getIndex(e,M).catch(()=>null);return Ae&&ie.current.set(pe,Ae),Ae},[z,e]),[we,Oe]=h.useState(null),[Te,X]=h.useState("loading"),le=te?`${e}
|
|
1334
|
+
${te}`:null,de=we&&we.owner===le?we.idx:null;h.useEffect(()=>{if(!te)return;let M=!1;const pe=`${e}
|
|
1335
|
+
${te}`;return Oe(null),X("loading"),Be(te).then(Ae=>{M||(Ae&&Ae.chapters.length>0?(Oe({owner:pe,idx:Ae}),X("ready")):X("failed"))}),()=>{M=!0}},[e,te,Be]),h.useEffect(()=>{if(!de||!te||je!=null&&de.chapters.some(Ae=>Ae.file===je))return;const pe=de.chapters[0].file;V||K(pe),oe(te,pe,"auto")},[de,te,je,V,oe]);const ve=de?je!=null&&de.chapters.some(M=>M.file===je)?je:de.chapters[0].file:je,H=h.useMemo(()=>de&&ve?de.chapters.find(M=>M.file===ve)??null:null,[de,ve]),me=h.useRef(0),ue=h.useCallback(async M=>{if(!R||M===te||!R.versions.some(at=>at.key===M))return;const pe=++me.current,Ae=await Be(M);if(pe!==me.current)return;const Ve=H??(ve?{file:ve}:null),Qe=_e.matchChapterAcrossVersions(Ve,Ae);A||O(M),V||K(Qe),oe(M,Qe,"version")},[R,te,Be,H,ve,A,V,oe]),$e=h.useCallback(M=>{te&&(V||K(M),oe(te,M,"chapter"))},[te,V,oe]),[G,ze]=h.useState(null),Le=te&&H?`${e}
|
|
1336
|
+
${te}
|
|
1337
|
+
${H.file}`:null,[B,re]=h.useState(null),he=Le!==null&&B!==Le,Ne=h.useRef(0);h.useEffect(()=>{if(!te||!H)return;const M=++Ne.current,pe=`${e}
|
|
1338
|
+
${te}
|
|
1339
|
+
${H.file}`;ze(null),z.getChapter(e,te,H.file,{json:!!H.has_json}).then(Ae=>{M===Ne.current&&ze(Ae)}).catch(()=>{M===Ne.current&&ze(null)}).finally(()=>{M===Ne.current&&re(pe)})},[z,e,te,H]);const Re=(Y==null?void 0:Y.kind)==="collated",[U,be]=h.useState("");h.useEffect(()=>{be("")},[e,te]);const ee=h.useMemo(()=>te&&Re?async M=>{const pe=await z.getChapter(e,te,M,{json:!0});return{juan:(pe==null?void 0:pe.json)??null,rawText:(pe==null?void 0:pe.md)??null}}:null,[z,e,te,Re]),fe=(de==null?void 0:de.type)==="kaozhen",Ee=h.useMemo(()=>(de==null?void 0:de.chapters.map(M=>M.file))??[],[de]),{matchStates:Fe}=lh({resetKey:`${e}
|
|
1340
|
+
${te??""}`,load:ee,files:Ee,activeFile:ve??null,activeJuan:(G==null?void 0:G.json)??null,activeRawText:(G==null?void 0:G.md)??null,query:U,isKaozhen:fe}),Ye=h.useRef(new Map);h.useEffect(()=>{Ye.current.clear()},[e]);const Ke=h.useMemo(()=>({versionKey:te,chapter:H??null}),[te,H]),qe=Pg(c,ve??null,Ke),{warpData:C,loading:ne}=vc(y,w,ve??null,H,Ke),se=Wh(b,ve??null,Ke),ke=P.properNames??se.length>0,ae=h.useMemo(()=>({...P,properNames:ke}),[P,ke]),[ge,He]=h.useState(new Set),[Z,ye]=h.useState(null),[Ie,Me]=h.useState(!0),[Se,ce]=h.useState(!0),xe=h.useRef(null),[De,We]=h.useState(1),[jt,vt]=h.useState(null),Dt=M=>{var Ae;const pe=parseInt(((Ae=M==null?void 0:M.page_id)==null?void 0:Ae.split(":")[1])??"",10);return isNaN(pe)?null:pe},Ut=M=>{var Ae,Ve;const pe=(M==null?void 0:M.pages)??[];return Dt(M)??((Ae=pe.find(Qe=>Qe.columns.some(at=>at.chars.length>0)))==null?void 0:Ae.page)??((Ve=pe[0])==null?void 0:Ve.page)??1},[Ge,J]=h.useState(()=>Ut(C)),Ue=`${e}
|
|
1341
|
+
${te}
|
|
1342
|
+
${ve??""}`,[Je,St]=h.useState({key:Ue,data:C,started:!!C});if(Je.key!==Ue)St({key:Ue,data:C,started:!1});else if(C!==Je.data&&(St({key:Ue,data:C,started:!!C}),C)){const M=C.pages??[];(!Je.started||!M.some(pe=>pe.page===Ge))&&J(Ut(C))}h.useEffect(()=>{He(new Set),ye(null)},[ve,te]);const Vd=h.useCallback(M=>{if(He(new Set(M)),M.length>0){const pe=M[0],Ae=parseInt(pe.split(":")[0],10);isNaN(Ae)||J(Ae)}},[]),Mt=h.useMemo(()=>{const M=new Map;for(const pe of(C==null?void 0:C.pages)??[])M.set(pe.page,pe);return M},[C]),jn=Dt(C),Gn=h.useCallback(M=>{var Ve;const pe=qe.images;if(!pe||pe.length===0)return;const Ae=(Ve=Mt.get(M))==null?void 0:Ve.seq;return(Ae?pe.find(Qe=>Qe.seq===Ae):void 0)??pe.find(Qe=>Qe.pageNo===M)??pe[M-1]},[qe.images,Mt]),Fr=De>1.5,Yn=h.useCallback((M,pe=!1)=>{const Ae=Gn(M);return Ae?M===jn||pe?Ae.hiresUrl??Ae.url:Ae.url:M===jn?(C==null?void 0:C.imageUrl)??"":""},[Gn,C,jn]),Gd=h.useMemo(()=>Yn(Ge,Fr),[Yn,Ge,Fr]),vn=h.useMemo(()=>[...Mt.keys()].sort((M,pe)=>M-pe),[Mt]),Wi=h.useRef(Ge);Wi.current=Ge;const kn=h.useCallback(M=>{var Qe;const pe=Wi.current,Ae=vn.indexOf(pe),Ve=vn[Ae<0?0:Ae+M];Ve===void 0||Ve===pe||(Wi.current=Ve,J(Ve),(Qe=Mt.get(Ve))!=null&&Qe.columns.some(at=>at.chars.length>0)&&vt(at=>({page:Ve,nonce:((at==null?void 0:at.nonce)??0)+1})))},[vn,Mt]),Oi=vn.indexOf(Ge),Yd=h.useCallback(M=>{if(M.altKey||M.ctrlKey||M.metaKey)return;const pe=M.target.tagName;pe==="INPUT"||pe==="TEXTAREA"||pe==="SELECT"||(M.key==="ArrowLeft"||M.key==="PageUp"?(M.preventDefault(),kn(-1)):(M.key==="ArrowRight"||M.key==="PageDown")&&(M.preventDefault(),kn(1)))},[kn]);h.useEffect(()=>{if(C)for(const M of[1,-1,2,3]){const pe=Yn(Ge+M);pe&&Co(pe)}},[C,Ge,Yn]);const Hr=h.useMemo(()=>{var Jr;if(!C)return null;if(Ge===jn)return C;const M=Mt.get(Ge);if(M&&M.width>0&&M.height>0)return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[M.width,M.height],total_warped_w:M.width,columns:[{col:1,warped_w:M.width,warped_h:M.height,offset_x:0,strips:[],chars:M.columns.flatMap(Ze=>Ze.chars).map(Ze=>({id:Ze.id,char:Ze.char,slot:Ze.slot,pos:Ze.pos,sub:Ze.sub,bbox_col:Ze.bbox??[0,0,0,0]}))}]};const pe=(Jr=C.pages)==null?void 0:Jr.find(Ze=>Ze.page===Ge),[Ae,Ve]=C.image_size||[2386,3082],Qe=Gn(Ge),at=(Qe==null?void 0:Qe.width)??Ae,Vi=(Qe==null?void 0:Qe.height)??Ve,qr=at/Ae,Xr=Vi/Ve,Zr=new Map;for(const Ze of C.columns){const ut=(Ze.strips||[]).flatMap(Xn=>Xn.srcQuad.map(Zn=>Zn[0]));if(ut.length===0)continue;const Nt=Ze.top_y??0,Gi=Ze.bottom_y??Nt+Ze.warped_h;Zr.set(Ze.col,{x0:Math.min(...ut),x1:Math.max(...ut),top:Nt,slotH:(Gi-Nt)/21})}return{page_id:`p:${Ge}`,title:`第${Ge}葉`,image_size:[at,Vi],total_warped_w:at,columns:pe?pe.columns.map(Ze=>{const ut=Zr.get(Ze.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ze.col,warped_w:at,warped_h:Vi,offset_x:0,strips:[],chars:Ze.chars.map(Nt=>{const Gi=Nt.slot??Nt.pos??0,Xn=(ut.top+(Gi-1)*ut.slotH)*Xr,Zn=(ut.x0+ut.x1)/2,[tp,np]=Nt.sub==="a"?[Zn,ut.x1]:Nt.sub==="b"?[ut.x0,Zn]:[ut.x0,ut.x1];return{...Nt,bbox_col:[tp*qr,Xn,np*qr,Xn+ut.slotH*Xr]}})}}):[]}},[C,Ge,jn,Mt,Gn]),{entryTitle:Kn,authors:Dr}=Gh(e,n,l===void 0),[Ur,Fi]=h.useState("text");if(h.useEffect(()=>{Fi("text")},[ve,te]),L==="loading")return t.jsx(Gs,{className:S,style:v,title:l??Kn,label:$("reader.loading")});if(L==="missing"||!R||!Y)return t.jsx("div",{className:S,style:{...v,...Vs},children:$("reader.noText")});if(Te==="failed")return t.jsx("div",{className:S,style:{...v,...Vs},children:$("reader.tocFailed")});if(!de)return t.jsx(Gs,{className:S,style:v,title:l??Kn,label:$("reader.tocLoading")});const Vt=Hh(Y,de),Kd=Dh(de,Fe,Vt,_,Re),Hi=R.versions.map(M=>({key:M.key,label:_e.textVersionLabel(M),optionLabel:_(_e.textVersionLabel(M)),sourceName:M.source_name?_(M.source_name):void 0,license:M.license??void 0,sourceUrl:M.source_url??void 0,primary:M.key===F})),pt=Oh((Kr=de.source)==null?void 0:Kr.upstream),qn=(typeof l=="string"?_(l):l)??(de.title?_(de.title):Kn?_(Kn):void 0),qd=qn?t.jsx("a",{href:T(e),title:$("reader.viewEntry"),onClick:a?M=>{M.metaKey||M.ctrlKey||(M.preventDefault(),a(e))}:void 0,children:qn}):void 0,Xd=Dr.length>0?_(Dr.slice(0,2).map(M=>`${M.dynasty?`〔${M.dynasty}〕`:""}${M.name}${` ${M.role||$("reader.defaultRole")}`}`).join("、")):void 0,Di=H?kc(H,Vt,_,Re):void 0,on=Re&&!!(G!=null&&G.json),Gt=(G==null?void 0:G.json)??null,rn=(G==null?void 0:G.md)??null,Vr=on&&!fe&&pc(Gt.sections),Zd=Vr&&!(rn&&ae.readingMode==="paragraph"&&ui(rn)),Jd=on&&Vr?t.jsx(ch,{juan:Gt,view:Ur,onView:Fi,textHasEntries:Zd}):void 0,Qd=gl(de)||ho(de),Ui=rn?rn.replace(/^##\s+[^\n]+\n+/,""):null,ep=(typeof d=="string"?_(d):d)??(Y.source_name?_(Y.source_name):_(_e.textVersionLabel(Y)));return t.jsxs(Nl,{className:S,style:v,title:qd,subtitle:ep,byline:Xd,current:Di,pagerUnit:Vt,rail:Jd,revisedAt:f,backHref:x,backLabel:k,onReportError:g?M=>g({...M,bookTitle:typeof qn=="string"?qn:void 0,entryId:e}):void 0,workLinkToggle:on&&!fe&&!!a&&!!(Gt!=null&&Gt.sections.some(M=>M.work_id)),toc:Kd,tocCaption:$("reader.tocCaption",{n:de.chapters.length,unit:_(Vt)}),tocHeader:Re&&de.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:fe?$("reader.searchChaptersPlaceholder"):$("reader.searchUnitPlaceholder",{unit:_(Vt)}),"aria-label":fe?$("reader.searchChapters"):$("reader.searchUnit",{unit:_(Vt)}),value:U,onChange:M=>be(M.target.value)}):void 0,activeKey:ve??null,onSelect:$e,images:qe.images,imagesLoading:qe.loading||ne,renderImageOverlay:p,imagePanel:C?"open":u,isWarpMode:!!C,customImagePanel:C&&Hr?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Yd,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:Oi<=0,onClick:()=>kn(-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:Oi<0||Oi>=vn.length-1,onClick:()=>kn(1),children:"›"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[ge.size>0&&t.jsxs("button",{type:"button",onClick:()=>He(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${i("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",ge.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:De<=1,onClick:()=>{var M;return(M=xe.current)==null?void 0:M.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(De*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:De>=6,onClick:()=>{var M;return(M=xe.current)==null?void 0:M.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:De===1,onClick:()=>{var M;return(M=xe.current)==null?void 0:M.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Bh,{ref:xe,resetKey:Ge,onScaleChange:We,style:{flex:1,minHeight:0},children:t.jsx(yr,{imageUrl:Gd,pageData:Hr,selectedCharIds:ge,hoveredCharId:Z,preserveMargins:Se,onCharClick:M=>{He(Ae=>{const Ve=new Set(Ae);return Ve.has(M)?Ve.delete(M):(Ve.clear(),Ve.add(M)),Ve});const pe=document.querySelector(`[data-char-id="${M}"]`);pe&&pe.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ye})})]}):void 0,settingsAnnotate:C?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${Ie?"bim-rd-on":""}`,"aria-pressed":Ie,title:"切换外挂现代断句标点",onClick:()=>Me(M=>!M),children:Ie?"标点":"无标点"}):void 0,settingsLayout:C?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-badge-warp",children:"图文对读"}),t.jsxs("div",{role:"group","aria-label":"书影留白",style:{display:"inline-flex",border:`1px solid ${i("rule")}`,borderRadius:4,overflow:"hidden"},children:[t.jsx("button",{type:"button",onClick:()=>ce(!1),"aria-pressed":!Se,className:`bim-rd-t ${Se?"":"bim-rd-on"}`,style:{padding:"6px 12px",border:"none",borderRadius:0,background:Se?"transparent":"var(--bimrd-on-bg)",color:Se?"inherit":i("ink")},title:"去空白:紧凑裁切版心",children:"去空白"}),t.jsx("button",{type:"button",onClick:()=>ce(!0),"aria-pressed":Se,className:`bim-rd-t ${Se?"bim-rd-on":""}`,style:{padding:"6px 12px",border:"none",borderRadius:0,background:Se?"var(--bimrd-on-bg)":"transparent",color:Se?i("ink"):"inherit"},title:"保留空白:完整呈现古籍天头地脚与白边",children:"保留空白"})]})]}):void 0,prefs:ae,onPrefsChange:N,versions:Hi.length>1?Hi:void 0,currentVersionKey:Hi.length>1?Y.key:void 0,onVersionChange:ue,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:ui(rn),allowVertical:m,children:[he&&t.jsx(tn,{}),!he&&C&&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:H!=null&&H.title?_(H.title):Di}),(Y.source_name||Y.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[Y.source_name&&_(Y.source_name),Y.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),Y.license]})]})]}),t.jsx(Sr,{pageData:C,pages:C.pages,punctuations:C.punctuations||[],selectedCharIds:ge,hoveredCharId:Z,onSelectionChange:Vd,onCharClick:M=>{He(Ae=>{const Ve=new Set(Ae);return Ve.has(M)?Ve.delete(M):(Ve.clear(),Ve.add(M)),Ve});const pe=parseInt(M.split(":")[0],10);isNaN(pe)||J(pe)},onCharHover:ye,mode:"horizontal",showPunctuation:Ie,entities:ae.properNames?se:void 0,entityTransport:n,onEntityNavigate:j,onVisiblePageChange:M=>J(M),convert:_,scrollToPage:jt})]}),!he&&!C&&on&&Gt&&t.jsx(ah,{juan:Gt,rawText:rn,positionLabel:Uh(H,de,Vt,_),groupLabel:Vh(de,ve??null),index:Fh(e,de),searchQuery:U,onNavigate:a,transport:n,workLabelCache:Ye,prefs:ae,view:Ur,onViewChange:Fi},`${te}/${ve}`),!he&&!C&&!on&&Ui!=null&&H&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:H.title?_(H.title):Di}),(Y.source_name||Y.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[Y.source_name&&t.jsxs(t.Fragment,{children:[$("reader.textSource")," ",Y.source_url?t.jsx("a",{className:"bim-rd-link",href:Y.source_url,target:"_blank",rel:"noreferrer",children:_(Y.source_name)}):_(Y.source_name)]}),Y.source_name&&Y.license&&t.jsx("span",{className:"bim-rd-dot"}),Y.license]}),pt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[$("reader.upstream")," ",pt.url?t.jsx("a",{className:"bim-rd-link",href:pt.url,target:"_blank",rel:"noreferrer",children:_(pt.name??pt.url)}):_(pt.name??""),pt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),pt.license_url?t.jsx("a",{className:"bim-rd-link",href:pt.license_url,target:"_blank",rel:"noreferrer",children:pt.license}):pt.license]}),pt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(bl,{text:pt.note,convert:_})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(ur,{text:Ui,mode:ae.readingMode,tables:Qd,gujiMarkdown:ho(de),properNames:ae.properNames})})]}),!he&&!C&&!on&&Ui==null&&H&&t.jsx("div",{className:"bim-rd-state",children:$("reader.chapterFailed")}),de.references&&de.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:$("reader.references")}),t.jsx("ol",{children:de.references.map((M,pe)=>t.jsxs("li",{children:[M.url?t.jsx("a",{className:"bim-rd-link",href:M.url,target:"_blank",rel:"noopener noreferrer",children:_(M.title)}):t.jsx("span",{children:_(M.title)}),M.author&&t.jsxs("span",{children:[",",_(M.author)]}),M.note&&t.jsxs("span",{children:["。",_(M.note)]})]},pe))})]})]})};function Uh(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 Vh(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 Gh(e,n,o){const[r,s]=h.useState({entryTitle:void 0,authors:[]});return h.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 wc={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")}},Yh=wc.other,Sc={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")}},Kh=Sc.pending;function qh(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 Xh(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 Cr=({items:e,loading:n})=>{const o=tt(),{t:r,convert:s}=Q();return n?t.jsx(tn,{}):e.length===0?t.jsx("div",{style:Zh,children:r("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=wc[a.type]||Yh,d=Sc[a.status]||Kh,c=typeof window<"u"&&Xh(a.pageUrl,window.location.href);return t.jsxs("div",{style:Jh,children:[t.jsxs("div",{style:Qh,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Ks,background:l.color},children:r(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Ks,background:d.color},children:r(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:ef,children:qh(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:tf,children:[a.resourceId&&t.jsx("a",{href:o(a.resourceId),style:io,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:io,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:io,children:a.pageUrl}))]}),t.jsx("div",{style:nf,children:s(a.content)}),a.reply&&t.jsxs("div",{style:of,children:[t.jsx("div",{style:rf,children:r("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Zh={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Jh={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Qh={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Ks={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},ef={fontSize:"12px",color:i("desc-fg")},tf={fontSize:"12px",marginBottom:"6px"},io={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},nf={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},of={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},rf={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},To=({transport:e,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:a})=>{const l=Ce(),[d,c]=h.useState(null),[p,u]=h.useState([]),[m,g]=h.useState("recommend"),[f,x]=h.useState([]),[k,y]=h.useState(!1),w=r??m,b=L=>{g(L),s==null||s(L)},[j,S]=h.useState(!0),[v,$]=h.useState(null),[_,z]=h.useState(null),[P,N]=h.useState(null);h.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]),h.useEffect(()=>{let L=!1;return(async()=>{if(o)return o;if(e.getRecommended)try{const A=await e.getRecommended();if(A!=null&&A.groups)return A.groups.flatMap(V=>V.items.map(q=>({...q,group:V.name})))}catch{}return[]})().then(async A=>{if(L)return;const V=A.filter(O=>O.id);if(V.length===0){S(!1);return}const q=await Promise.all(V.map(async O=>{if(O.type)return{id:O.id,title:O.title,type:O.type,author:O.author,dynasty:O.dynasty,role:O.role,edition:O.edition,has_text:O.has_text,has_image:O.has_image,has_collated:O.has_collated,subtype:O.subtype,primary_name:O.primary_name,group:O.group,fallbackDescription:O.description};try{let W=null;if(e.getEntry)W=await e.getEntry(O.id);else{const K=await e.getItem(O.id);K&&(W={id:O.id,title:K.title||O.id,type:K.type||"work"})}if(W)return{...W,group:O.group,fallbackDescription:O.description}}catch{}return{id:O.id,title:O.title,type:_e.extractType(O.id),group:O.group,fallbackDescription:O.description}}));L||(u(q.filter(O=>O!==null)),S(!1))}),()=>{L=!0}},[e,o]);const T=h.useRef(!1),D=h.useRef(!1),R=h.useRef(!1);h.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(A=>{I||$(A)}).catch(()=>{T.current=!1}),()=>{I=!0}},[e,w]),h.useEffect(()=>{if(w!=="collection"||D.current||!e.getCollectionProgress)return;D.current=!0;let L=!1;return e.getCollectionProgress().then(I=>{L||z(I)}).catch(()=>{D.current=!1}),()=>{L=!0}},[e,w]),h.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]),h.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(yn,{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(zn,{label:l.home.recommendTab,active:w==="recommend",onClick:()=>b("recommend")}),t.jsx(zn,{label:l.home.catalogTab,active:w==="catalog",onClick:()=>b("catalog")}),t.jsx(zn,{label:l.home.collectionTab,active:w==="collection",onClick:()=>b("collection")}),t.jsx(zn,{label:l.home.siteTab,active:w==="site",onClick:()=>b("site")}),a&&t.jsx(zn,{label:l.home.feedbackTab,active:w==="feedback",onClick:()=>b("feedback")})]}),w==="recommend"&&t.jsx(sf,{recommended:p,loading:j,onNavigate:n,getIcon:E,t:l}),w==="catalog"&&t.jsx(qs,{progress:v,t:l,onNavigate:n}),w==="collection"&&t.jsx(qs,{progress:_,t:l,onNavigate:n}),w==="site"&&t.jsx(lf,{progress:P,t:l,totalWorks:(d==null?void 0:d.works)??0}),w==="feedback"&&a&&t.jsx(Cr,{items:f,loading:k})]})})},zn=({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}),sf=({recommended:e,loading:n,onNavigate:o,getIcon:r,t:s})=>{const a=tt();if(n)return t.jsx(tn,{});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))})},qs=({progress:e,t:n,onNavigate:o})=>{if(!e)return t.jsx(tn,{});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(af,{item:p,t:n,statusColor:l[d],onNavigate:o},p.id))})]},d)})})},af=({item:e,t:n,statusColor:o,onNavigate:r})=>{const s=tt(),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?ht(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})]})},lf=({progress:e,t:n,totalWorks:o})=>{if(!e)return t.jsx(tn,{});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(Xs,{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(Xs,{item:c,t:n,totalWorks:o},c.id))})]})]})},Xs=({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})]})},Zs="(max-width: 768px)";function cf(){const[e,n]=h.useState(()=>typeof window>"u"?!1:window.matchMedia(Zs).matches);return h.useEffect(()=>{const o=window.matchMedia(Zs),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e}const df=({transport:e,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var D;const a=Ce(),{convert:l}=Pe(),d=cf(),[c,p]=h.useState(null),[u,m]=h.useState(null),[g,f]=h.useState(!1),[x,k]=h.useState("detail"),[y,w]=h.useState([]),[b,j]=h.useState(!1),S=h.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=h.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]),$=h.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,z=(u==null?void 0:u.type)==="collection"&&(y.length>0||b)||(u==null?void 0:u.type)==="work"&&_,P=d&&(g||u),N=h.useCallback(()=>{p(null),m(null),w([]),k("detail")},[]),T=t.jsx(t.Fragment,{children:g?t.jsx(tn,{}):u?t.jsxs(t.Fragment,{children:[(z||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:[z&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:ni(x==="detail"),children:a.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:ni(!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:ni(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:ni(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(Yo,{data:u,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(Ko,{data:(D=y.find(R=>`catalog:${R.resource_id}`===x))==null?void 0:D.data,onNavigate:$}):x==="collated"?t.jsx($r,{id:u.id,transport:e,onNavigate:$}):null})]}):t.jsx(To,{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:P?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(go,{transport:e,onEntryClick:v,hideModeIndicator:n}),!u&&t.jsx(To,{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(go,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:T})]})};function ni(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 pf=({pageData:e,rawImageUrl:n="",punctuations:o=[],title:r,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=h.useState(new Set),[u,m]=h.useState(null),[g,f]=h.useState("horizontal"),[x,k]=h.useState(!0),y=h.useRef(null),w=h.useCallback(v=>{p(new Set(v))},[]),b=h.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:g==="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(yr,{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:g==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(Sr,{pageData:e,punctuations:S,selectedCharIds:c,hoveredCharId:u,onSelectionChange:w,onCharClick:b,onCharHover:m,mode:g,showPunctuation:x})]})]})]})},uf=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function an(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function mf(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=an((r=u.page)==null?void 0:r.index),g=Array.isArray(u.cells)?u.cells:[];if(m===void 0||g.length===0)continue;const f=new Map;for(const x of g){if(!x||typeof x!="object")continue;const k=x,y=uf.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($=>an($)!==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:an((a=u.canvas)==null?void 0:a.width)??an((l=u.image)==null?void 0:l.width)??0,height:an((d=u.canvas)==null?void 0:d.height)??an((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 gf(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 hf(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 ff=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function xt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Js(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(o=>!!o&&typeof o=="object"):[]}function xf(e,n){var l,d,c,p,u,m,g,f,x,k;const o=new Map,r=new Map;for(const y of Js(n)){const w=xt(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=>xt(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 Js(e)){const w=xt(y.page);if(w===void 0)continue;const b=[];for(const S of Array.isArray(y.columns)?y.columns:[]){const v=xt(S==null?void 0:S.col);if(v===void 0)continue;const $=[];for(const _ of Array.isArray(S.cells)?S.cells:[]){const z=ff.exec(String((_==null?void 0:_.a)??""));if(!z||typeof _.c!="string")continue;const P=parseInt(z[3],10);$.push({id:_.a,char:_.c,slot:P,pos:P,sub:z[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:xt((d=j==null?void 0:j.canvas)==null?void 0:d.width)??xt((c=j==null?void 0:j.image)==null?void 0:c.width)??0,height:xt((p=j==null?void 0:j.canvas)==null?void 0:p.height)??xt((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:xt((g=w.canvas)==null?void 0:g.width)??xt((f=w.image)==null?void 0:f.width)??0,height:xt((x=w.canvas)==null?void 0:x.height)??xt((k=w.image)==null?void 0:k.height)??0,columns:[]})}return s.sort((y,w)=>y.page-w.page)}const bf=({data:e,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:a}=Q(),[l,d]=h.useState(((u=e.divisions[0])==null?void 0:u.name)??null),[c,p]=h.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(yf,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:g=>p(c===g?null:g),onNavigate:n},m.name))})]})},yf=({division:e,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=Q(),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(jf,{category:p,expanded:r===u,onToggle:()=>s(u),onNavigate:a},p.name)})})]})},jf=({category:e,expanded:n,onToggle:o,onNavigate:r})=>{var p,u,m,g;const{t:s,convert:a}=Q(),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)+(((g=e.stats)==null?void 0:g.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}=Q(),a=tt(),[l,d]=h.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})})]})},kt=({title:e,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const a=Ce();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:kf,children:"AI"}),n&&t.jsx("button",{onClick:n,style:vf,children:a.action.save})]})]}),s]})},vf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},kf={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},gt=({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"}})]}),Jt=({value:e,onChange:n,placeholder:o})=>{const r=h.useRef(null);return h.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"}})},gi=({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 wf(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const ai=({value:e,onChange:n,label:o})=>{const[r,s]=h.useState(!1),a=h.useRef(null),l=wf(e||"");return h.useEffect(()=>{r&&a.current&&a.current.focus()},[r]),!r&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:ea,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(gi,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:ea,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"}})]})},ea={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function Sf(e){switch(e){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function _f(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const _c=({items:e,onChange:n,onOpenEntityPicker:o})=>{const r=Ce(),[s,a]=h.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((g,f)=>f!==m)),s===m&&a(null)},c=(m,g,f)=>{const x=[...e];x[m]={...x[m],[g]:f},n(x)},p=(m,g)=>{const f=[...e];f[m]={...f[m],type:g,id:"",name:""},n(f),g==="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(g=>{const f=[...e];f[m]={...f[m],id:g.id,name:g.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,g)=>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===g?null:g),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===g?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:m.name||`${r.editor.sourcePlaceholder} ${g+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Sf(m.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:_f(m.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(g)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===g&&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:Rt,children:r.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(g,"bookID"),style:{...ta,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(g,"url"),style:{...ta,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:Rt,children:r.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[g]={...f[g],type:"",id:"",name:""},n(f)},style:na,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(g),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(g),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:Rt,children:r.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[g]={...f[g],type:"",id:"",name:""},n(f)},style:na,children:r.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:f=>c(g,"name",f.target.value),placeholder:r.editor.sourceNamePlaceholder,style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:r.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:f=>c(g,"id",f.target.value),placeholder:"https://...",style:ln})]})]}),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:{...Rt,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:Rt,children:r.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:f=>c(g,"details",f.target.value),placeholder:r.editor.detailsPlaceholder,style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:r.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:f=>c(g,"position",f.target.value),placeholder:"如: 卷三, p.52",style:ln})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:r.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:f=>c(g,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:ln})]}),t.jsxs("div",{children:[t.jsx("label",{style:Rt,children:r.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:f=>c(g,"processor_version",f.target.value),placeholder:"如: v0.1",style:ln})]})]})]})]})})]},g)),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})]})]})},Rt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},ln={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"},ta={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"},na={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function $c(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 Cc(e){return!e||e.length===0?"":JSON.stringify(e)}const zc=({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:g,onViewEntity:f,onCreateAndLink:x,onSaveRelations:k})=>{const y=Ce();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:$f,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Tn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>g("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(Tn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>g("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(cn,{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(Tn,{direction:"up",title:y.relation.parentWork,entity:r,onView:f,onUnlink:()=>g("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(cn,{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(cn,{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(cn,{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(Tn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>g("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(Tn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>g("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(cn,{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(cn,{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})]})]})]})},Tn=({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 g=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:g,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:Tc(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(ia,{onClick:()=>r(o),title:u,children:"👁️"}),t.jsx(ia,{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(No,{onClick:a,children:d}),t.jsx(No,{onClick:l,primary:!0,children:c})]})]})},cn=({direction:e,title:n,entities:o,onView:r,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=h.useState(!1),u=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",g=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:[g.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:Tc(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(No,{onClick:s,primary:!0,children:["+ ",a]})})]})},ia=({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}),No=({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 Tc(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const $f={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Nc=({isOpen:e,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[u,m]=h.useState(""),g=p?l.filter(y=>y.id!==p):l;h.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:Cf,children:t.jsxs("div",{style:zf,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:Tf,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:Nf})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:oo,children:"搜索中..."}):g.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:g.map(y=>t.jsxs("div",{onClick:()=>r(y),style:Rf,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:oo,children:["未找到匹配的",x]}):t.jsxs("div",{style:oo,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:Ef,children:["创建新",x,"并关联"]})]})]})})},Cf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},zf={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")},Tf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Nf={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"},Rf={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},oo={padding:"20px",textAlign:"center",color:i("desc-fg")},Ef={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},oa={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},If={work:"📜",book:"📖",collection:"📚",entity:"👤"},Rc=({isOpen:e,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:a})=>{const[l,d]=h.useState(""),c=h.useRef(null);h.useEffect(()=>{e&&(d((r==null?void 0:r.title)||""),setTimeout(()=>{var g,f;(g=c.current)==null||g.focus(),(f=c.current)==null||f.select()},100))},[e,r==null?void 0:r.title]);const p=g=>{g.key==="Enter"&&l.trim()?u():g.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`创建新${oa[n]}`}};return t.jsx("div",{style:Lf,onClick:g=>{g.target===g.currentTarget&&a()},children:t.jsxs("div",{style:Af,onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:If[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:g=>d(g.target.value),onKeyDown:p,placeholder:`请输入${oa[n]}名称...`,style:Pf})]}),((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:Mf,children:"取消"}),t.jsx("button",{onClick:u,disabled:!l.trim(),style:{...Bf,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},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",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:i("shadow-dialog")},Pf={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"},Mf={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Bf={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function Wf(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Ec(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Of(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 Ic=({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,g]=h.useState(""),[f,x]=h.useState([]),[k,y]=h.useState(!1),[w,b]=h.useState("recent");h.useEffect(()=>{e&&(g(""),x([]),b(r.length>0?"recent":"search"))},[e,r.length]),h.useEffect(()=>{if(!m.trim()){x([]);return}const z=setTimeout(async()=>{y(!0);try{x(await u(m,o))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(z)},[m,o,u]);const j=h.useCallback(z=>{g(z.target.value),z.target.value.trim()&&b("search")},[]),S=h.useCallback(z=>s?z.filter(P=>P.id!==s):z,[s]);if(!e)return null;const v=n||(o==="all"?"选择实体":`选择${Ec(o)}`),$=S(r),_=S(f);return t.jsx("div",{style:Hf,children:t.jsxs("div",{style:Df,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:Uf,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:Vf}),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(ra,{active:w==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(ra,{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(sa,{entities:$,onSelect:d}):m.trim()?k?t.jsx(ro,{message:"搜索中..."}):_.length>0?t.jsx(sa,{entities:_,onSelect:d}):t.jsx(ro,{message:"未找到匹配的结果"}):t.jsx(ro,{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:Gf,children:l||"创建新实体"})]})]})})},ra=({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}),sa=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(o=>t.jsx(Ff,{entity:o,onClick:()=>n(o)},o.id))}),Ff=({entity:e,onClick:n})=>{const[o,r]=h.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:Wf(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:Of(e.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Ec(e.type)})]})},ro=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:e}),Hf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Df={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")},Uf={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Vf={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"},Gf={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Yf={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},Kf={work:"📜",collection:"📚",book:"📖",entity:"👤"},Lc=({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:g})=>{var $e;const f=Ce(),[x,k]=h.useState(!1),[y,w]=h.useState("work"),[b,j]=h.useState(""),[S,v]=h.useState(""),[$,_]=h.useState([]),[z,P]=h.useState(!1),[N,T]=h.useState(!1),[D,R]=h.useState("work"),[E,L]=h.useState(""),[I,A]=h.useState(),[V,q]=h.useState(!1),[O,W]=h.useState(null),[K,Y]=h.useState([]);h.useRef(null);const F=e.type,te=F==="work",je=F==="collection",oe=F==="book",ie=h.useCallback((G,ze)=>{n({...e,[G]:ze})},[e,n]),Be=h.useCallback((G,ze)=>{j(G),w(ze),v(f.editor.selectToLink+f.indexType[ze]),_([]),k(!0)},[f]),we=h.useCallback(G=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(e.id,G)},[r,e.id]),Oe=h.useCallback(G=>{s==null||s(G.id,G.type)},[s]),Te=h.useCallback((G,ze,Le)=>{const B={...Le,author:(Le==null?void 0:Le.author)||e.author,dynasty:Le==null?void 0:Le.dynasty};R(ze),L(G),A(B),T(!0)},[e.author]),X=h.useCallback((G,ze)=>{r!=null&&r.createAndLink&&r.createAndLink(e.id,E,{type:D,title:G,inheritData:ze}),T(!1)},[r,e.id,E,D]),le=h.useCallback(G=>{if(!G.trim()){_([]);return}P(!0),r!=null&&r.searchEntities&&r.searchEntities(G,y).then(ze=>{_(ze),P(!1)}).catch(()=>{_([]),P(!1)})},[r,y]),de=h.useCallback(G=>{r!=null&&r.linkEntity&&r.linkEntity(e.id,b,G.id),k(!1)},[r,e.id,b]),ve=h.useCallback(()=>{o()},[o]),H=h.useCallback(G=>{W(()=>G),q(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(Y).catch(()=>{})},[r]),me=h.useCallback((G,ze)=>r!=null&&r.searchEntities?r.searchEntities(G,ze==="all"?void 0:ze):Promise.resolve([]),[r]),ue=h.useCallback(G=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(G),Y(ze=>[G,...ze.filter(Le=>Le.id!==G.id)].slice(0,10)),O==null||O(G),q(!1),W(null)},[r,O]);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:Kf[F]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(gi,{children:e.id}),t.jsx(gi,{color:Yf[F],children:f.indexType[F]})]})}),t.jsx(kt,{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(ai,{label:te?f.editor.workTitle:je?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:G=>ie("title",G)}),oe&&t.jsx(ai,{label:f.editor.belongsToWork,value:e.workName||"",onChange:G=>ie("workName",G)}),t.jsx(gt,{label:f.editor.authorLabel,value:e.author||"",onChange:G=>ie("author",G)}),t.jsx(gt,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:G=>ie("publicationYear",G)}),(oe||je)&&t.jsx(ai,{label:f.editor.containedIn,value:e.collection||"",onChange:G=>ie("collection",G)}),(oe||je)&&t.jsx(gt,{label:f.editor.holderLabel,value:e.holder||"",onChange:G=>ie("holder",G)}),(oe||je)&&t.jsx(gt,{label:oe?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:G=>ie("pages",G)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(gt,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:G=>ie("firstImage",G)})})]})}),t.jsx(kt,{title:f.section.description,onSave:o,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(Jt,{value:e.description||"",onChange:G=>ie("description",G),placeholder:f.editor.descriptionPlaceholder})}),((($e=e.additional_works)==null?void 0:$e.length)||0)>0&&t.jsx(kt,{title:f.section.additionalWorks,onSave:o,children:t.jsx(qf,{items:e.additional_works||[],onChange:G=>ie("additional_works",G)})}),t.jsx(kt,{title:f.section.indexedBy,onSave:o,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Xf,{items:e.indexed_by||[],onChange:G=>ie("indexed_by",G)})}),t.jsx(kt,{title:f.section.emendatedBy,onSave:o,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Zf,{items:e.emendated_by||[],onChange:G=>ie("emendated_by",G)})}),t.jsx(kt,{title:f.section.textResources,onSave:o,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(uo,{items:e.resources||[],onChange:G=>ie("resources",G),onDownload:p,downloadStatuses:u,filterType:"text"})}),t.jsx(kt,{title:f.section.imageResources,onSave:o,children:t.jsx(uo,{items:e.resources||[],onChange:G=>ie("resources",G),onDownload:p,downloadStatuses:u,filterType:"image"})}),t.jsx(kt,{title:f.section.sources,onSave:o,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(_c,{items:$c(e.sources||""),onChange:G=>ie("sources",Cc(G)),onOpenEntityPicker:H})}),(oe||je)&&t.jsx(kt,{title:f.section.provenance,onSave:o,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(Jt,{value:e.provenance||"",onChange:G=>ie("provenance",G),placeholder:f.editor.provenancePlaceholder})}),oe&&t.jsx(kt,{title:f.section.otherEditions,onSave:o,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(Jt,{value:e.otherEditions||"",onChange:G=>ie("otherEditions",G),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(zc,{entityType:F,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:Be,onUnlinkEntity:we,onViewEntity:Oe,onCreateAndLink:Te,onSaveRelations:ve}),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(Nc,{isOpen:x,entityType:y,title:S,onSelect:de,onCancel:()=>k(!1),onCreate:()=>{k(!1),Te(b,y)},searchResults:$,onSearch:le,isLoading:z,excludeId:e.id}),t.jsx(Rc,{isOpen:N,entityType:D,relationField:E,inheritData:I,onConfirm:X,onCancel:()=>T(!1)}),t.jsx(Ic,{isOpen:V,title:f.action.selectBookOrWork,filterType:"all",recentEntities:K,excludeId:e.id,onSelect:ue,onCancel:()=>{q(!1),W(null)},onSearch:me})]})};function qf({items:e,onChange:n}){const o=Ce(),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(gt,{label:o.editor.bookNameLabel,value:l.book_title,onChange:c=>r(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(gt,{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 Ac({items:e,onChange:n,showMeta:o,addLabel:r}){const s=Ce(),[a,l]=h.useState(null),d=(u,m,g)=>{const f=e.map((x,k)=>k===u?{...x,[m]:g||void 0}:x);n(f)},c=u=>{n(e.filter((m,g)=>g!==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 g=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:g?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(g?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:g?"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:"✕"})]}),!g&&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]}),g&&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(gt,{label:s.label.sourceName,value:u.source,onChange:f=>d(m,"source",f)}),t.jsx(gt,{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(gt,{label:s.label.titleInfo,value:u.title_info||"",onChange:f=>d(m,"title_info",f)}),t.jsx(gt,{label:s.label.authorInfo,value:u.author_info||"",onChange:f=>d(m,"author_info",f)})]}),t.jsx(gt,{label:s.label.edition,value:u.edition||"",onChange:f=>d(m,"edition",f)})]}),t.jsx(Jt,{value:u.summary||"",onChange:f=>d(m,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(Jt,{value:u.comment||"",onChange:f=>d(m,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(Jt,{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 Xf({items:e,onChange:n}){const o=Ce();return t.jsx(Ac,{items:e,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function Zf({items:e,onChange:n}){const o=Ce();return t.jsx(Ac,{items:e,onChange:n,addLabel:o.action.addEmendatedBy})}function Pc(e){var d,c,p,u,m,g,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):((g=e.page_count)==null?void 0:g.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 Jf(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 Qf=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:g,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y,headerExtra:w,className:b,style:j}=e,S=Ce(),[v,$]=h.useState(s),_=a?s:v;h.useEffect(()=>{s!==v&&$(s)},[s]);const z=h.useCallback(()=>{const L=_==="view"?"edit":"view";a?a(L):$(L)},[_,a]),[P,N]=h.useState(null);h.useEffect(()=>{o&&r&&r.getItem(o).then(L=>{L&&N(L)})},[o,r]);const T=n||P,D=h.useMemo(()=>T?Pc(T):null,[T]),R=a||!n?t.jsx("button",{onClick:z,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:_==="edit"?i("accent-bg"):"transparent",color:i(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?S.common.switchToEdit:S.common.switchToView,children:_==="view"?S.common.modeEdit:S.common.modeView}):null,E=t.jsxs(t.Fragment,{children:[R,w]});return!T&&!D?t.jsx(tn,{}):_==="view"?t.jsx(Yo,{data:T,transport:r,onNavigate:p?L=>p(L):void 0,renderLink:u,headerExtra:E,className:b,style:j}):D?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(Lc,{data:D,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:r,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:g,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},ex=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Mc=({isOpen:e,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=Q(),[a,l]=h.useState(null),[d,c]=h.useState(""),[p,u]=h.useState(""),[m,g]=h.useState("idle"),[f,x]=h.useState(""),k=h.useRef(null);h.useEffect(()=>{e&&(l(null),c(""),u(""),g("idle"),x(""))},[e]),h.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=k.current)==null?void 0:b.focus()},100)},[a]),h.useEffect(()=>{if(m==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[m,n]),h.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())){g("submitting"),x("");try{await o({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),g("success")}catch(b){g("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:tx,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:nx,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:ix,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:ox,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:cx,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:ex.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...rx,...a===b.value?sx:{}},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:{...ax,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:px}),t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:dx,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!w,style:{...lx,opacity:w?1:.6,cursor:w?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},tx={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},nx={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},ix={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},ox={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},rx={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"},sx={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},ax={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"},lx={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},cx={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},dx={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},px={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"},Ro="--bim-feedback-fab-offset",Eo=48,ux=16,mx=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:a}=Q(),[l,d]=h.useState(!1),c=n.bottom??24;return h.useEffect(()=>{if(r||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(Ro,`calc(${c+Eo+ux}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(Ro)}},[r,c]),t.jsxs(t.Fragment,{children:[!r&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...gx,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(Mc,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:o})]})},gx={position:"fixed",width:`${Eo}px`,height:`${Eo}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"},hx=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],Bc=({onSubmit:e})=>{const{t:n}=Q(),[o,r]=h.useState("bug"),[s,a]=h.useState(""),[l,d]=h.useState(""),[c,p]=h.useState("idle"),[u,m]=h.useState(""),g=h.useRef(null);h.useEffect(()=>{o&&setTimeout(()=>{var k;return(k=g.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:aa,children:t.jsxs("div",{style:jx,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:vx,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:aa,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:hx.map(k=>t.jsxs("button",{onClick:()=>r(k.value),style:{...fx,...o===k.value?xx:{}},children:[t.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),t.jsx("textarea",{ref:g,value:s,onChange:k=>a(k.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...bx}}),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:wx}),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:{...yx,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:kx,children:u})]})},aa={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},fx={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"},xx={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},bx={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"},yx={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},jx={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},vx={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},kx={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},wx={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 la(e){return typeof e=="function"?e():e??"/api/feedback"}const Wc=({resourceId:e,apiUrl:n})=>{const{t:o}=Q(),[r,s]=h.useState([]),[a,l]=h.useState(!0),d=h.useCallback(async()=>{const p=la(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]);h.useEffect(()=>{d()},[d]);const c=async p=>{const u=la(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 g=await m.json().catch(()=>null);throw new Error((g==null?void 0:g.error)||o("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Cr,{items:r,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Bc,{onSubmit:c})})]})},Ni=8;async function Ri(e,n,o,r){const s=Number.isFinite(n)?Math.max(1,Math.floor(n)):1,a=new Array(e.length);let l=0;const d=Array.from({length:Math.min(s,Math.max(1,e.length))},async()=>{for(;l<e.length&&!(r!=null&&r());){const c=l++;a[c]=await o(e[c],c)}});return await Promise.all(d),a}const Sx=fi["zh-Hant"].relation,_x=fi["zh-Hant"].lossStatus,$x=fi["zh-Hant"].resourceKind,Ei=fn("zh-Hant"),zr=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function ca(e,n=Ei){return e?zr(Sx,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function Cx(e,n=Ei){return zr(_x,e)?n(`detail.lossStatus.${e}`):e}function zx(e,n=Ei){return zr($x,e)?n(`detail.resourceKind.${e}`):""}function Tr({authors:e,onNavigate:n,renderLink:o}){const{convert:r}=Q(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=nr(a.role);return t.jsxs(h.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(et,{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 Oc(e,n,o=Ei){var c,p;const r=er(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 Fc(e,n){const o=(e.url?xn(e.url):void 0)||e.name,r=Il(e,n);return r?`${o}(${r})`:o}function Nr({item:e,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=Q(),[a,l]=h.useState(!1),d=xi(e),c=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),p=s(Fc(e,n)),u=bn(e),m=_i(e,r)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const g=(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:"↗"}),g]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,g]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(ar,{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(g=>!g),children:a?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:d.expected})})})]})}function Hc({groups:e,listedVolumeCounts:n}){const{t:o,convert:r}=Q();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(Nr,{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=bn(a),c=r(Fc(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 Mn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function Io(e){var o;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=Mn.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const da=12,Tx=60,Dc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:a,back:l,railLinks:d})=>{var le,de,ve;const{t:c,convert:p,messages:u}=Q(),m=h.useMemo(()=>[...e.books||[],...e.collections||[]],[e.books,e.collections]),[g,f]=h.useState(new Map),[x,k]=h.useState(!1),[y,w]=h.useState(""),[b,j]=h.useState(!1),S=m.length<=Tx,v=S||x||!!y||b,$=h.useMemo(()=>v?m:m.slice(0,da),[m,v]);h.useEffect(()=>{if(!n||$.length===0)return;const H=$.filter(ue=>!g.has(ue));if(H.length===0)return;let me=!1;return Ri(H,Ni,ue=>n.getItem(ue).then($e=>{const G=$e??{};return[ue,{id:ue,title:G.title,edition:G.edition,resources:G.resources,publication_info:G.publication_info,current_location:G.current_location,lineage:G.lineage,measure_info:G.measure_info}]}).catch(()=>[ue,{id:ue}]),()=>me).then(ue=>{me||f($e=>{const G=new Map($e);for(const[ze,Le]of ue)G.set(ze,Le);return G})}),()=>{me=!0}},[n,$,g]);const _=h.useMemo(()=>m.map(H=>g.get(H)??{id:H}),[m,g]),z=m.length>0&&m.every(H=>g.has(H)),P=!!n&&$.some(H=>!g.has(H)),N=S||v,T=h.useMemo(()=>Al(_,e.version_graph,{era:y,scanOnly:b,sort:N?"year":"default"}),[_,e.version_graph,y,b,N]),D=x?T.rows:T.rows.slice(0,da),R=T.allRows.filter(H=>H.hasImage).length,E=e.related_works||[],L=E.filter(H=>H.relation==="collected_in"),I=h.useMemo(()=>{const H=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],me=ue=>{const $e=H.indexOf(ue??"");return $e<0?H.length:$e};return E.filter(ue=>ue.relation!=="collected_in").map((ue,$e)=>({r:ue,i:$e})).sort((ue,$e)=>me(ue.r.relation)-me($e.r.relation)||ue.i-$e.i).map(ue=>ue.r)},[E]),A=h.useMemo(()=>{const H=er(e.resources,e.resource_groups);return[...H.mirrors.flatMap(me=>me.items.map(ue=>({r:ue,kind:p(me.label)}))),...H.buckets.flatMap(me=>me.items.map(ue=>({r:ue,kind:p(zx(me.key,c))})))]},[e.resources,e.resource_groups,p,c]),V=e.indexed_by||[],q=e.emendated_by||[],O=h.useMemo(()=>{var re,he,Ne;const H=[],me=(he=(re=e.authors)==null?void 0:re[0])==null?void 0:he.dynasty;me&&H.push({label:c("workPage.fact.written"),value:p(me)});const ue=Pt(e,u.unit.juan);if(ue){const Re=(Ne=e.juan_count)==null?void 0:Ne.description;H.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(ue),Re&&Re!==ue?t.jsxs("span",{className:"bim-d-meta",children:["(",p(Re),")"]}):null]})})}e.loss_status&&H.push({label:c("workPage.fact.loss"),value:p(Cx(e.loss_status,c))});const $e=T.allRows.filter(Re=>Re.sortYear!=null),G=$e.length>0?$e.reduce((Re,U)=>Re.sortYear<=U.sortYear?Re:U):null;G!=null&&G.era.era?H.push({label:c("workPage.fact.earliest"),value:p([G.era.era,G.era.reign].filter(Boolean).join(" ")),title:G.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):P&&H.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),q.length&&H.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:q.length})});const ze=pa(e.additional_titles);ze.length&&H.push({label:c("workPage.fact.alias"),value:ze.map(p).join("、")});const Le=pa(e.attached_texts);Le.length&&H.push({label:c("workPage.fact.attached"),value:Le.map(p).join("、")});const B=(e.additional_works||[]).map(Re=>p(Re.book_title)+(Re.n_juan!=null?` ${Re.n_juan}${u.unit.juan}`:""));return B.length&&H.push({label:c("workPage.fact.appendix"),value:B.join("、")}),H},[e,p,c,u,P,T.allRows,q.length]),K=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:z?R:0,label:c("workPage.stat.hasImage")},{value:V.length,label:c("workPage.stat.catalogs")}],Y=e.classification,F=Y?[Y.l1,Y.l2,Y.l3,Y.l4].filter(Boolean).map(H=>p(H)):[],te=e.subtype?u.workSubtype[e.subtype]??p(e.subtype):"",je=t.jsx(Fn,{title:p(e.title),byline:t.jsx(Tr,{authors:e.authors,onNavigate:o,renderLink:r}),meta:t.jsx(it,{items:[...F,Y!=null&&Y.source?c("workPage.classifiedBy",{source:p(Y.source.split("/")[0])}):"",te]}),description:(le=e.description)!=null&&le.text?t.jsxs(t.Fragment,{children:[t.jsx(At,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(de=e.description.sources)!=null&&de.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(H=>({text:p(Vm(H)),href:Gm(H)})).filter(H=>H.text).map((H,me)=>t.jsxs(h.Fragment,{children:[me>0?" · ":null,H.href?t.jsx("a",{href:H.href,target:"_blank",rel:"noopener noreferrer",children:H.text}):H.text]},me))}):null]}):void 0,stats:K,facts:O,readAction:s,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(ve=e.appendix)==null?void 0:ve.map((H,me)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(H.title)}),t.jsx(At,{text:H.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},me))}),oe=T.eras.length>=2?[{key:"",label:c("catalog.all")},...T.eras.map(H=>({key:H,label:`${H} ${T.allRows.filter(me=>me.era.era===H).length}`}))]:[],ie=[];m.length&&ie.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),V.length&&ie.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:V.length}),L.length&&ie.push({id:"collected",label:c("workPage.sec.collected"),count:L.length}),I.length&&ie.push({id:"related",label:c("workPage.sec.related"),count:I.length}),A.length&&ie.push({id:"resources",label:c("workPage.sec.resources"),count:A.length});const Be=m.length===0&&V.length===0,we=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(ot,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(it,{items:[c("workPage.versionsTotal",{n:m.length}),z&&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":P&&oe.length===0&&m.length>1?"":void 0,children:[oe.length>0&&t.jsx(Ci,{items:oe,value:y,onChange:H=>{w(H),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Hl,{label:c("workPage.scanOnly"),checked:b,onChange:H=>{j(H),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&&zi(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:D.map(H=>{var me;return t.jsx(Nx,{row:H,measure:(me=g.get(H.id))==null?void 0:me.measure_info,loaded:g.has(H.id),onNavigate:o,renderLink:r},`${H.id}:${g.has(H.id)?"r":"p"}`)})})]}),D.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(ir,{total:T.rows.length,shown:D.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(Rx,{items:V,transport:n,onNavigate:o,renderLink:r}),Be&&t.jsx(ot,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Oe=(H,me)=>t.jsx(et,{id:H,label:p(me),onNavigate:o,renderLink:r,dense:!0}),Te=h.useMemo(()=>{const H=new Map;for(const me of I){const ue=ca(me.relation,c);H.set(ue,(H.get(ue)??0)+1)}return H.size>1?[...H.entries()].sort((me,ue)=>ue[1]-me[1]).slice(0,4).map(([me,ue])=>`${p(me)} ${ue}`).join(" · "):void 0},[I,p,c]),X=t.jsxs(t.Fragment,{children:[t.jsx(Zt,{id:"collected",title:c("workPage.sec.collected"),items:L.map(H=>Oe(H.id,H.title))}),t.jsx(Zt,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:I.length}),sub:Te,items:I.map(H=>t.jsxs(t.Fragment,{children:[Oe(H.id,H.title),t.jsx("span",{className:"bim-d-meta",title:H.note?p(H.note):void 0,children:p(ca(H.relation,c))})]}))}),t.jsx(Zt,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:A.map(({r:H,kind:me})=>{const ue=p((H.url?xn(H.url):void 0)||H.name),$e=bn(H);return t.jsxs(t.Fragment,{children:[$e?t.jsxs("a",{href:$e,target:"_blank",rel:"noopener noreferrer",children:[ue," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:ue}),me&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:me})]})})})]});return t.jsx(On,{railTop:a,back:l,nav:ie,railLinks:d,main:we,card:je,side:X})};function pa(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function ua(e,n){return n((e.url?xn(e.url):void 0)||e.name)}function Nx({row:e,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:a,convert:l}=Q(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],u=p?ua(p,l):e.locationName?l(e.locationName):"",m=e.images[0],g=m?bn(m):void 0,f=e.images.map(x=>ua(x,l)).join("、");return t.jsxs("tr",{"data-loading":o?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{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&&(g?t.jsx("a",{className:"bim-d-flag",href:g,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 Rx({items:e,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:a}=Q(),[l,d]=h.useState(0),c=Math.min(l,e.length-1),p=e[c],[u,m]=h.useState(new Map);return h.useEffect(()=>{if(!n)return;const g=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(g.length===0)return;let f=!1;return Promise.all(g.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(ot,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(it,{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((g,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(g.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(g.source_bid??"")?a(u.get(g.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(g.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(it,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(et,{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:ft(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:ft(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:ft(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 Ex(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 Ix(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 ma(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 Lx(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 Ax(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 li(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=Ax(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,g=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 D=v.get(N);return D?(D.derived_from??[]).map(R=>R.ref):[]},_=N=>v.has(N)?!u||u.has(N):!p||p.has(N),z=new Set,P=N=>{if(!z.has(N)){z.add(N);for(const T of $(N))a.has(T)||(_(T)||(v.has(T)?g.add(T):S.has(T)&&m.add(T)),P(T))}};for(const N of n)p&&p.has(N.id)&&!a.has(N.id)&&P(N.id);for(const N of r.hypothetical_nodes??[])u&&u.has(N.id)&&P(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=Ix(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)||g.has(S.id)).map(S=>{const v=Ex(S);return g.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(ma(S.id,v,$))}),(S.lineage.related_to??[]).forEach((v,$)=>{j(Lx(S.id,v,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!g.has(S.id)||(S.derived_from??[]).forEach((v,$)=>{j(ma(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 Uc(e,n,o){const r=(e??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function Px(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 Vc=({graph:e,renderLink:n,className:o,style:r})=>{const{t:s,convert:a}=Q();if(!e.nodes.length)return t.jsx("div",{style:{...Xx,...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 g=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:o,style:{...Bx,...r},children:[e.title&&t.jsx("div",{style:Wx,children:a(e.title)}),e.description&&t.jsx("div",{style:Ox,children:a(e.description)}),g.map(f=>t.jsx(ga,{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(ga,{label:s("lineage.otherGroup"),nodes:u,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},ga=({label:e,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=Q();return t.jsxs("div",{style:Fx,children:[t.jsx("div",{style:{...Hx,borderLeftColor:n??i("widget-border")},children:d(e)}),o.map(c=>t.jsx(Mx,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},Mx=({node:e,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=Q();return t.jsxs("div",{style:{...Dx,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:Ux,children:[t.jsx("span",{style:Vx,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Gx,children:Uc(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Yx,children:[e.category&&t.jsx(Nn,{children:c(e.category)}),e.status==="lost"&&t.jsx(Nn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(Nn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(Nn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(Nn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Kx,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:qx,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:fa,children:[t.jsx("div",{style:xa,children:d("lineage.sources")}),n.map(p=>{const u=r.get(p.source);return t.jsxs("div",{style:ba(p.confidence),children:[t.jsx("span",{style:ya,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(ha,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ja,children:["· ",c(p.evidence)]})]},p.id)})]}),o.length>0&&t.jsxs("div",{style:fa,children:[t.jsx("div",{style:xa,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:ba(p.confidence),children:[t.jsx("span",{style:ya,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(ha,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ja,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Nn=({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})},ha=({level:e})=>{const{t:n}=Q(),r={certain:{key:"certain",color:i("confidence-certain")},consensus:{key:"consensus",color:i("confidence-consensus")},probable:{key:"probable",color:i("confidence-probable")},disputed:{key:"disputed",color:i("confidence-disputed")}}[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},Bx={fontSize:"14px",color:i("fg")},Wx={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Ox={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},Fx={marginBottom:"16px"},Hx={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},Dx={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},Ux={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Vx={fontSize:"15px",fontWeight:600},Gx={fontSize:"12px",color:i("muted")},Yx={marginBottom:"6px"},Kx={fontSize:"12px",color:i("muted"),margin:"2px 0"},qx={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},fa={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},xa={fontSize:"11px",color:i("muted"),marginBottom:"2px"},ba=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),ya={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},ja={fontSize:"11px",color:i("muted")},Xx={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},Gc=({selectedNodeId:e,...n})=>{const{t:o}=Q(),[r,s]=h.useState("loading"),[a,l]=h.useState(null);return h.useEffect(()=>{let d=!1;return Zx().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),r==="loading"?t.jsx("div",{style:ka,children:o("lineage.graphLoading")}):r==="missing"||!a?t.jsxs("div",{style:ka,children:[t.jsx("div",{children:va(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:va(o("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Jx,{modules:a,selectedNodeId:e,...n})};function va(e,n){return e.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return t.jsx(h.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function Zx(){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 Jx=({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:g,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:k}=l,y=h.useMemo(()=>({lineage:$=>{var I,A,V,q;const _=((I=$.data)==null?void 0:I.stepPosition)??.85,[z,P,N]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:_,borderRadius:5}),T=!!((A=$.data)!=null&&A.isSibling),D=T?P:$.targetX-18,R=T?N:$.targetY-12,E=(V=$.data)==null?void 0:V.labelStyle,L=(q=$.data)==null?void 0:q.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(g,{id:$.id,path:z,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${D}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})})]})}}),[g,f,x]),w=h.useMemo(()=>({version:$=>{const{t:_}=Q(),z=$.data,P=z.kind==="hypothetical",N=z.status==="lost",T=z.isSelected,D=z.bridge,R=z.borderColor??i("muted"),E=D||P?"dashed":"solid",L=D?.5:N?.6:1;return t.jsxs("div",{style:{background:i(D?"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"):P||D?"none":i("shadow-node")},title:D?_("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:P||!z.renderLink?z.label:z.renderLink(z.bookId,z.label)}),z.description&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:z.description}),z.yearText&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:Uc(z.yearText,void 0,z.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}=Q(),{rfNodes:j,rfEdges:S}=h.useMemo(()=>Qx(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 Qx(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??tb(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}}),g=.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 P,N;const _=((P=c.node(v.target))==null?void 0:P.y)??0,z=((N=c.node($.target))==null?void 0:N.y)??0;return _-z}),S=j.length;j.forEach((v,$)=>{const _=($-(S-1)/2)*f;k.set(v.id,g+_)})}const y=e.edges.map(w=>eb(w,k.get(w.id),s));return{rfNodes:m,rfEdges:y}}function eb(e,n,o=r=>r??""){const r=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=nb(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 tb(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function nb(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 ka={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},Rr=({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:g,convert:f}=Q(),[x,k]=h.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:g("lineage.collectionAll"),description:g("lineage.collectionAllDesc")}]]})(),b=!!(d&&w.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:g("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:ib,children:[t.jsx("button",{onClick:()=>y("list"),style:so(x==="list"),children:g("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:so(x==="graph"),children:g("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:g("lineage.collectionLabel")}),w.map(([v,$])=>{const _=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:so(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(Vc,{graph:e,renderLink:o}):t.jsx(Gc,{graph:e,renderLink:o,height:r,selectedNodeId:s})]})},ib={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},so=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"}),wa=40,Sa=2,ob=9,rb=new Set(["certain","consensus","probable","disputed"]);function ao(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Yc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:u})=>{var Ne,Re,U,be,ee,fe,Ee,Fe,Ye,Ke,qe;const m=Ce(),{t:g,convert:f}=Q(),[x,k]=h.useState(null),[y,w]=h.useState(new Map),[b,j]=h.useState([]),[S,v]=h.useState(new Map),[$,_]=h.useState(!1),[z,P]=h.useState("flow"),[N,T]=h.useState(null);h.useEffect(()=>{if(!n||!e.work_id){k(null);return}let C=!1;return n.getItem(e.work_id).then(ne=>{!C&&ne&&ne.type==="work"&&k(ne)}).catch(()=>{}),()=>{C=!0}},[n,e.work_id]),h.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let C=!1;return n.getLineageGraph(e.work_id).then(ne=>{C||T(ne&&ne.nodes.length>1?ne:null)}).catch(()=>{C||T(null)}),()=>{C=!0}},[n,e.work_id]),h.useEffect(()=>{const C=e.contained_in||[];if(!n||C.length===0){w(new Map);return}let ne=!1;return Promise.all(C.map(se=>{const ke=typeof se=="string"?se:se.id;return n.getItem(ke).then(ae=>[ke,ae]).catch(()=>[ke,null])})).then(se=>{if(ne)return;const ke=new Map;for(const[ae,ge]of se)ge&&ke.set(ae,ge);w(ke)}),()=>{ne=!0}},[n,e.contained_in]);const D=h.useMemo(()=>{const C=new Set([...(x==null?void 0:x.books)||[],...e.related_books||[]]);return C.add(e.id),[...C]},[x==null?void 0:x.books,e.related_books,e.id]),R=D.length-1;h.useEffect(()=>{if(!n||R<=0){j([]);return}const C=D.length<=wa,ne=C?D:D.slice(0,8);let se=!1;return Promise.all(ne.map(ke=>ke===e.id?Promise.resolve({id:ke,title:e.title,edition:e.edition,year:pi(e)}):n.getItem(ke).then(ae=>{const ge=ae??{};return{id:ke,title:ge.title,edition:ge.edition,year:ae?pi(ge):void 0}}).catch(()=>({id:ke})))).then(ke=>{if(se)return;const ae=ke.filter(ge=>ge.id===e.id||ge.title||ge.edition);C&&ae.sort((ge,He)=>(ge.year??1/0)-(He.year??1/0)),j(ae)}),()=>{se=!0}},[n,D,R,e]);const E=e.lineage,L=h.useMemo(()=>[...((E==null?void 0:E.derived_from)||[]).filter(C=>C.ref_type==="book").map(C=>C.ref),...((E==null?void 0:E.related_to)||[]).map(C=>C.book_id)].filter(Boolean),[E]);h.useEffect(()=>{if(!n||L.length===0){v(new Map);return}let C=!1;return Promise.all(L.map(ne=>n.getItem(ne).then(se=>[ne,{id:ne,title:se==null?void 0:se.title,edition:se==null?void 0:se.edition}]).catch(()=>[ne,{id:ne}]))).then(ne=>{C||v(new Map(ne))}),()=>{C=!0}},[n,L]);const I=h.useMemo(()=>Oc(e.resources,e.resource_groups,g),[e.resources,e.resource_groups,g]),A=I.groups.reduce((C,ne)=>C+ne.rows.length+ne.mirrors.length,0),V=I.groups.length>0&&I.groups.every(C=>C.key==="_physical"),q=Wn(e),O=Ol(e),W=Pt(e,m.unit.juan),K=new Set((e.contained_in||[]).map(C=>typeof C=="string"?0:An(C.volume_index).length).filter(C=>C>0)),Y=C=>{var ke;const ne=(ke=e.base_edition)==null?void 0:ke.find(ae=>ae.book_id===C&&ae.name);if(ne!=null&&ne.name)return ne.name;const se=S.get(C);return(se==null?void 0:se.edition)||(se==null?void 0:se.title)||""},F=h.useMemo(()=>{var ye,Ie,Me,Se,ce;const C=[];O&&C.push({label:g("bookPage.fact.editionType"),value:f(O),title:e.edition_type||(ye=e.lineage)!=null&&ye.category?void 0:g("bookPage.inferredFromEdition")}),(Ie=e.publication_info)!=null&&Ie.details?C.push({label:g("bookPage.fact.publication"),value:f(e.publication_info.details)}):(q.era||q.reign)&&C.push({label:g("bookPage.fact.era"),value:f([q.era,q.reign].filter(Boolean).join(" ")),title:q.source==="edition"?g("bookPage.inferredFromEdition"):void 0}),W&&C.push({label:g("bookPage.fact.measure"),value:f(W)});const ne=(e.contained_in||[]).flatMap(xe=>typeof xe=="string"?[]:An(xe.volume_index));ne.length&&C.push({label:g("bookPage.fact.volumes"),value:g("bookPage.volumesValue",{range:$i(ne,m.unit.volume),unit:m.unit.volume,n:ne.length})});const se=(((Me=e.lineage)==null?void 0:Me.derived_from)||[]).find(xe=>xe.relation==="底本"&&xe.ref_type==="book");se&&Y(se.ref)&&C.push({label:g("bookPage.fact.baseEdition"),value:t.jsx(et,{id:se.ref,label:f(Y(se.ref)),onNavigate:o,renderLink:r,dense:!0})});const ke=(e.base_edition||[]).filter(xe=>xe&&xe.name);for(const xe of["底本","配補","參校"]){if(xe==="底本"&&se&&Y(se.ref))continue;const De=ke.filter(We=>We.role===xe);De.length&&C.push({label:f(xe),value:De.map((We,jt)=>t.jsxs(h.Fragment,{children:[jt>0&&"、",We.book_id?t.jsx(et,{id:We.book_id,label:f(We.name),onNavigate:o,renderLink:r,dense:!0}):f(We.name)]},jt))})}const ae=(e.provenance||[]).filter(xe=>xe&&xe.institution),ge=(e.resources||[]).filter(xe=>(xe.types||(xe.type?[xe.type]:[])).includes("physical"));if(ae.length){C.push({label:g("bookPage.fact.holdings"),value:ae.slice(0,2).map(We=>f(We.institution)).join("、")+(ae.length>2?g("bookPage.andMorePlaces",{n:ae.length}):"")});const xe=ae.filter(We=>We.call_number).slice(0,2).map(We=>`${f(We.institution)} ${We.call_number}`);xe.length&&C.push({label:g("bookPage.fact.callNumber"),value:xe.join(";")+(ae.filter(We=>We.call_number).length>2?"…":"")});const De=ae.flatMap(We=>We.seals||[]).filter(Boolean);De.length&&C.push({label:g("bookPage.fact.seals"),value:f(De.join("、"))})}else ge.length?C.push({label:g("bookPage.fact.holdings"),value:ge.slice(0,2).map(xe=>f(xe.name)).join("、")+(ge.length>2?g("bookPage.andMorePlaces",{n:ge.length}):"")}):(Se=e.current_location)!=null&&Se.name&&C.push({label:g("bookPage.fact.holdings"),value:f(e.current_location.name)});const He=e.physical_description;if(He){const xe=[[g("bookPage.fact.leafStyle"),He.leaf_style],[g("bookPage.fact.binding"),He.binding],[g("bookPage.fact.dimensions"),He.dimensions],[g("bookPage.fact.condition"),He.condition]];for(const[De,We]of xe)We&&We.trim()&&C.push({label:De,value:f(We)})}(ce=e.page_count)!=null&&ce.description&&C.push({label:m.label.pageCount,value:f(e.page_count.description)});const Z=[..._o(e.additional_titles),..._o(e.attached_texts)];return Z.length&&C.push({label:g("bookPage.fact.aliases"),value:Z.map(f).join("、")}),C},[e,f,m,g,q,O,W,S,o,r]),te=f(e.title),je=e.edition?f(e.edition):void 0,oe=((Ne=e.lineage)==null?void 0:Ne.year_text)||"",ie=t.jsx(Fn,{kind:g("bookPage.kind"),title:te,subtitle:je,byline:t.jsx(Tr,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:o,renderLink:r}),meta:(()=>{const C=[O?f(O):"",q.era?f([q.era,q.reign].filter(Boolean).join("")):"",W?f(W):""].filter(Boolean);return C.length?t.jsx("span",{className:"bim-d-tags",children:C.map((ne,se)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(se,2)}`,children:ne},se))}):null})(),description:(Re=e.description)!=null&&Re.text?t.jsx(At,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:rr((U=e.description)==null?void 0:U.text)?6:void 0,facts:F,readAction:s,secondaryAction:s&&A>0&&!V?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:g("bookPage.viewImages")}):void 0,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),Be=e.contained_in||[],we=(a==null?void 0:a.chapters)||[],Oe=f(we[0]&&ao(we[0].title)[0].slice(-1)||"")||g("bookPage.chapterUnit"),Te=g("bookPage.chapterCount",{n:we.length,unit:Oe}),X=!!((be=E==null?void 0:E.derived_from)!=null&&be.length||(ee=E==null?void 0:E.related_to)!=null&&ee.length||(fe=e.appendix)!=null&&fe.length),le=[],de=g(V?"bookPage.sec.physical":"bookPage.sec.images");(we.length||I.text.length||l)&&le.push({id:"fulltext",label:g("bookPage.sec.fulltext"),count:we.length?Te:void 0}),I.groups.length&&le.push({id:"images",label:de,count:A}),X&&le.push({id:"lineage",label:g("bookPage.sec.lineage")}),Be.length&&le.push({id:"collections",label:g("section.containedIn"),count:Be.length}),(Ee=e.location_history)!=null&&Ee.length&&le.push({id:"provenance",label:g("section.locationHistory")});const ve=C=>(d==null?void 0:d(C))??null,H=we[0],me=H?ve(H.file):null,ue=$?we:we.slice(0,ob),$e=(C,ne,se)=>C?t.jsx("a",{className:se,href:C.href??"#",onClick:C.onClick?ke=>{ke.metaKey||ke.ctrlKey||(ke.preventDefault(),C.onClick())}:void 0,children:ne}):t.jsx("span",{className:se,children:ne}),G=t.jsxs(t.Fragment,{children:[(we.length>0||I.text.length>0||l)&&t.jsxs(ot,{id:"fulltext",title:g("bookPage.sec.fulltext"),meta:we.length>0?t.jsx(it,{items:[Te,(Fe=a==null?void 0:a.source)!=null&&Fe.name?g("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!H&&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"})]}),H&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:g("bookPage.readFrom",{ch:f(ao(H.title)[0])||g("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((H.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),$e(me,t.jsxs(t.Fragment,{children:[g("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:ue.map(C=>{const[ne,se]=ao(C.title);return t.jsx("li",{children:$e(ve(C.file),t.jsxs(t.Fragment,{children:[ne&&t.jsx("b",{children:f(ne)}),f(se||C.file)]}))},C.file)})}),we.length>ue.length&&t.jsx(or,{label:g("detail.expandRest",{n:we.length-ue.length,unit:Oe}),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:g("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:I.text.map((C,ne)=>t.jsx(Nr,{item:C,siblings:I.text,listedVolumeCounts:K},`${C.id||C.url||C.name}-${ne}`))})})]})]}),I.groups.length>0&&t.jsx(ot,{id:"images",title:de,meta:t.jsx(it,{items:[I.groups.length>1?g("bookPage.groupCount",{n:I.groups.length}):"",g("bookPage.placeCount",{n:A})]}),children:t.jsx(Hc,{groups:I.groups,listedVolumeCounts:K})}),X&&t.jsx(ot,{id:"lineage",title:g("bookPage.sec.lineage"),meta:(Ye=E==null?void 0:E.derived_from)!=null&&Ye.length?g("bookPage.lineageMeta"):void 0,action:N?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":g("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":z==="flow",onClick:()=>P("flow"),children:g("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":z==="graph",onClick:()=>P("graph"),children:g("bookPage.viewGraph")})]}):void 0,children:z==="graph"&&N?t.jsx(Rr,{graph:N,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(C,ne)=>t.jsx(et,{id:C,label:f(ne),onNavigate:o,renderLink:r,dense:!0})}):t.jsx(ab,{data:e,heading:je||te,yearText:oe,refName:Y,onNavigate:o,renderLink:r})}),Be.length>0&&t.jsx(ot,{id:"collections",title:g("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:Be.map((C,ne)=>{var He,Z;const se=typeof C=="string"?C:C.id,ke=typeof C=="string"?[]:An(C.volume_index),ae=y.get(se),ge=(ae==null?void 0:ae._member_count)||((He=ae==null?void 0:ae.books)==null?void 0:He.length)||((Z=ae==null?void 0:ae.contained_works)==null?void 0:Z.length)||0;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(et,{id:se,label:ae?f(ae.title):se,onNavigate:o,renderLink:r,dense:!0}),ke.length>0&&t.jsx(sb,{volumes:ke,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&&g("bookPage.totalOf",{n:ge,unit:m.unit.bu})})]},`${se}-${ne}`)})})})}),(Ke=e.location_history)!=null&&Ke.length?t.jsx(ot,{id:"provenance",title:g("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((C,ne)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(C.name)}),([C.start_date,C.end_date].filter(Boolean).join("—")||C.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(it,{items:[[C.start_date,C.end_date].filter(Boolean).join("—"),C.description?f(C.description):""]})})]},ne))})}):null,le.length===0&&t.jsx(ot,{title:g("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:g("bookPage.emptyText")})})]}),ze=b.findIndex(C=>C.id===e.id),Le=D.length<=wa,B=Le&&ze>=0?b.slice(Math.max(0,ze-Sa),ze+Sa+1):b.filter(C=>C.id!==e.id),re=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(m.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(et,{id:x.id,label:f(x.title),onNavigate:o,renderLink:r})}),t.jsx(it,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(C=>`${C.dynasty?`〔${f(C.dynasty)}〕`:""}${f(C.name)}`),f(Pt(x,m.unit.juan)),x._edition_count?g("bookPage.editionCount",{n:x._edition_count}):""]}),((qe=x.description)==null?void 0:qe.text)&&t.jsx("p",{style:{fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc bim-d-side-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),R>0&&B.length>0&&t.jsxs("div",{children:[t.jsx(Zt,{id:"siblings",timeline:!0,title:Le?g("bookPage.siblings"):m.relation.siblingVersions,meta:Le?g("bookPage.byEra"):g("bookPage.kindCount",{n:R}),cap:B.length,items:B.map(C=>C.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(C.edition||C.title||C.id)}):t.jsx(et,{id:C.id,label:f(C.edition||C.title||C.id),onNavigate:o,renderLink:r,dense:!0})),metas:B.map(C=>[C.year!=null?C.year<0?g("detail.bce",{n:-C.year}):String(C.year):"",C.id===e.id?g("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:B.findIndex(C=>C.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(et,{id:x.id,label:g("bookPage.viewAllInWork",{n:D.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),he=e.work_id?t.jsx(Fl,{caption:m.section.belongsToWork,children:t.jsx(et,{id:e.work_id,label:x?f(x.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return t.jsx(On,{railTop:c,back:p,up:he,nav:le,railLinks:u,main:G,card:ie,side:re})};function sb({volumes:e,unit:n}){const{t:o}=Q();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 ab({data:e,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:a}){var w;const{t:l,convert:d}=Q(),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==="底本"),g=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&&rb.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,j)=>t.jsx(et,{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)})]}),g.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:g.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(At,{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 Rn=16,lb=200,cb=16,Kc=({data:e,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var ze,Le,B,re,he,Ne,Re;const{t:p,convert:u,messages:m}=Q(),[g,f]=h.useState(""),[x,k]=h.useState(!1),[y,w]=h.useState(null),[b,j]=h.useState(""),[S,v]=h.useState(!1),$=h.useMemo(()=>Bl(e,n),[e,n]),[_,z]=h.useState(new Map),P=!!o&&$.rows.length>0&&$.rows.length<=lb,N=P&&($.rows.length<=Rn||S),T=N&&$.rows.every(U=>!U.id||_.has(U.id)),D=U=>{var be;return Io(U?(be=_.get(U))==null?void 0:be.l1:void 0)},R=h.useMemo(()=>{const U=g.trim(),be=U?u(U):"";return $.rows.filter(ee=>{var Ee,Fe;if(b&&Io(ee.id?(Ee=_.get(ee.id))==null?void 0:Ee.l1:void 0)!==b)return!1;if(!be)return!0;const fe=ee.id&&((Fe=_.get(ee.id))==null?void 0:Fe.title)||ee.title;return u(fe).includes(be)||(ee.subItems||[]).some(Ye=>u(Ye).includes(be))})},[$.rows,g,b,_,u]),E=x?R:R.slice(0,Rn),L=h.useMemo(()=>(N?$.rows:E).filter(U=>U.id&&!_.has(U.id)).map(U=>U.id),[N,$.rows,E,_]);h.useEffect(()=>{if(!o||L.length===0)return;let U=!1;const be=L.slice(0,cb);return Ri(be,Ni,ee=>o.getItem(ee).then(fe=>{var Ye,Ke;const Ee=fe??{},Fe={title:Ee.title,edition:Ee.edition,authors:Ee.authors,measure:fe?Pt(fe,m.unit.juan):void 0,versionCount:Ee._edition_count??((Ye=Ee.books)==null?void 0:Ye.length),l1:((Ke=Ee.classification)==null?void 0:Ke.l1)||void 0};return[ee,Fe]}).catch(()=>[ee,{}]),()=>U).then(ee=>{U||z(fe=>{const Ee=new Map(fe);for(const[Fe,Ye]of ee)Ee.set(Fe,Ye);return Ee})}),()=>{U=!0}},[o,L,m.unit.juan]);const I=(e.contained_in||[])[0],A=typeof I=="string"?I:I==null?void 0:I.id;h.useEffect(()=>{if(!A){w(null);return}if(w({id:A}),!o)return;let U=!1;return o.getItem(A).then(be=>{U||w({id:A,title:be==null?void 0:be.title})}).catch(()=>{}),()=>{U=!0}},[o,A]);const V=h.useMemo(()=>Oc(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),q=V.text.length+V.groups.reduce((U,be)=>U+be.rows.length+be.mirrors.length,0),O=e.contained_works||[],W=new Set($.rows.map(U=>U.id).filter(Boolean)),K=O.length>0&&!O.every(U=>W.has(U.id)),Y=(()=>{const U=$.rows.map(be=>be.edition).filter(Boolean);return U.length>1&&new Set(U).size===1})(),F=$.rows.some(U=>U.volumes.length>0||U.expected!=null),te=e._member_count||((ze=e.books)==null?void 0:ze.length)||O.length,je=e._members_truncated?te:$.rows.length,oe=Pt(e,m.unit.juan),ie=e.count,Be=U=>typeof U=="number"&&Number.isFinite(U)?U:null,we=Be(ie==null?void 0:ie.juan)??Be((Le=e.juan_count)==null?void 0:Le.number),Oe=Be(ie==null?void 0:ie.ce)??($.totalVolumes||null),Te=[{value:je,label:p("collectionPage.stat.titles")},{value:we??0,label:m.unit.juan},{value:Oe??0,label:m.unit.volume}],X=h.useMemo(()=>{var ee,fe;const U=[];if((ee=e.publication_info)!=null&&ee.details&&U.push({label:p("collectionPage.fact.publication"),value:u(e.publication_info.details)}),te&&(te!==$.rows.length||e._members_truncated)){const Ee=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");U.push({label:Ee,value:`${te} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const be=[Be(ie==null?void 0:ie.zhong)!=null?p("collectionPage.nZhong",{n:ie.zhong}):"",Be(ie==null?void 0:ie.han)!=null?p("collectionPage.nHan",{n:ie.han}):""].filter(Boolean);return be.length&&U.push({label:p("collectionPage.fact.expected"),value:be.join(" ")}),we==null&&oe&&U.push({label:p("collectionPage.fact.measure"),value:u(oe),title:(fe=e.juan_count)!=null&&fe.description?u(e.juan_count.description):void 0}),U},[e,te,$.rows.length,we,oe,ie,u,p,m]),le=h.useMemo(()=>{if(!T)return[];const U=new Map;for(const ee of $.rows){const fe=D(ee.id);fe&&U.set(fe,(U.get(fe)??0)+1)}const be=Mn.filter(ee=>(U.get(ee.key)??0)>0);return be.length<2?[]:[{key:"",label:`${m.catalog.all} ${je}`},...be.map(ee=>({key:ee.key,label:`${ee.label} ${U.get(ee.key)}`}))]},[T,$.rows,_,m]),de=h.useMemo(()=>{if(!T||!$.rows.some(fe=>fe.volumes.length>0))return null;const U=[],be=$.rows.filter(fe=>fe.volumes.length>0).map(fe=>({k:D(fe.id)??"",from:Math.min(...fe.volumes),to:Math.max(...fe.volumes)})).sort((fe,Ee)=>fe.from-Ee.from);for(const fe of be){const Ee=fe.to-fe.from+1,Fe=U[U.length-1];Fe&&Fe.key===fe.k?(Fe.to=Math.max(Fe.to,fe.to),Fe.n+=Ee):U.push({key:fe.k,from:fe.from,to:fe.to,n:Ee})}const ee=be.reduce((fe,Ee)=>Math.max(fe,Ee.to),0);return U.length>1&&U.some(fe=>fe.key)?{segs:U,last:ee}:null},[T,$.rows,_]),ve=(B=e.description)==null?void 0:B.text,H=t.jsx(Fn,{kind:p("collectionPage.kind"),title:u(e.title),byline:t.jsx(Tr,{authors:e.authors,onNavigate:r,renderLink:s}),meta:t.jsx(it,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(re=e.publication_info)!=null&&re.year?u(e.publication_info.year):""]}),description:ve||(he=e.history)!=null&&he.length?t.jsxs(t.Fragment,{children:[ve&&t.jsx(At,{text:ve,style:{fontSize:15,lineHeight:1.85}}),(Ne=e.history)!=null&&Ne.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((U,be)=>t.jsx("li",{children:u(U)},be))}):null]}):void 0,clampDescription:rr(ve)||(((Re=e.history)==null?void 0:Re.length)??0)>2?6:void 0,stats:Te,facts:X,foot:t.jsx(Hn,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:de&&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:de.segs.map((U,be)=>{const ee=Mn.find(fe=>fe.key===U.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:U.from,to:U.to}):void 0,"aria-label":ee?p("collectionPage.dist.only",{section:u(ee.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!ee&&b===U.key,style:{flexGrow:U.n,background:i(ee?ee.token:"rule")},onClick:()=>{ee&&(j(b===U.key?"":U.key),k(!1))}},be)})}),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:de.last})})]})]})}),me=[];$.rows.length&&me.push({id:"titles",label:p("collectionPage.sec.titles"),count:je}),q&&me.push({id:"resources",label:p("collectionPage.sec.resources"),count:q}),K&&me.push({id:"works",label:m.section.containedWorks,count:O.length});const ue=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(ot,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(it,{items:[`${je} ${m.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:m.unit.volume}):"",R.length!==je?p("collectionPage.currentN",{n:R.length,unit:m.unit.items}):""]}),action:a,children:[($.rows.length>Rn||le.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[le.length>0&&t.jsx(Ci,{items:le,value:b,onChange:U=>{j(U),k(!1)}}),P&&$.rows.length>Rn&&!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>Rn&&t.jsx("input",{type:"search",className:"bim-d-find",value:g,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:U=>{f(U.target.value),k(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&zi(R.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[F&&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((U,be)=>{var qe;const ee=U.id?_.get(U.id):void 0,fe=ee!=null&&ee.title&&U.title===U.id?ee.title:U.title,Ee=((ee==null?void 0:ee.authors)||[]).find(C=>C&&C.name),Fe=[Ee?`${Ee.dynasty?`〔${u(Ee.dynasty)}〕`:""}${u(Ee.name)}${Ee.role?` ${u(Ee.role)}`:""}`:"",ee!=null&&ee.measure?u(ee.measure):"",(qe=U.subItems)!=null&&qe.length?U.subItems.map(C=>u(C)).join("、"):"",(ee!=null&&ee.edition||U.edition)&&!Y?u((ee==null?void 0:ee.edition)||U.edition||""):""].filter(Boolean),Ye=Mn.find(C=>C.key===D(U.id)),Ke=U.volumes.length>0?p("collectionPage.volumeRange",{range:$i(U.volumes,m.unit.volume),unit:m.unit.volume}):U.expected!=null?`${U.found??0}/${U.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[F&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Ke?"":" bim-d-zt-blank"}`,children:[Ye&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(Ye.token)}}),Ke||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[U.id?t.jsx(et,{id:U.id,label:u(fe),onNavigate:r,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:u(fe)}),Fe.length>0?t.jsx(it,{items:Fe}):U.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}):""})]},`${U.id??U.title}-${be}`)})})]}),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(ir,{total:R.length,shown:E.length,unit:m.unit.items,onClick:()=>k(!0)})]}),q>0&&t.jsxs(ot,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:q}),children:[V.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[V.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:V.text.map((U,be)=>t.jsx(Nr,{item:U,siblings:V.text},`${U.id||U.url||U.name}-${be}`))})})]}),t.jsx(Hc,{groups:V.groups})]}),$.rows.length===0&&q===0&&t.jsx(ot,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),$e=K?t.jsx(Zt,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:O.length}),cap:12,items:O.map(U=>t.jsx(et,{id:U.id,label:u(U.title),onNavigate:r,renderLink:s,dense:!0}))}):null,G=y?t.jsx(Fl,{caption:p("collectionPage.parent"),children:t.jsx(et,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return t.jsx(On,{railTop:l,back:d,up:G,nav:me,railLinks:c,main:ue,card:H,side:$e})},db=16,lo=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function _a(e){if(!e)return lo.length;const n=lo.indexOf(e);return n===-1?lo.length:n}function pb(e,n,o){if(n)return e[n]??o(n)}function ub(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const mb={秦:[-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]},qc=({data:e,transport:n,onNavigate:o,renderLink:r,railTop:s,back:a,railLinks:l})=>{var ue,$e,G,ze,Le;const{t:d,convert:c,messages:p}=Q(),u=B=>ub(B,d),[m,g]=h.useState("全部"),[f,x]=h.useState(!1),[k,y]=h.useState("default"),[w,b]=h.useState(new Map),j=h.useMemo(()=>(e.works||[]).map(B=>{const re=w.get(B.work_id);return{id:B.work_id,title:(re==null?void 0:re.title)??B.title??B.work_id,role:B.role||"",cls:tr(B.role),versionCount:re==null?void 0:re.versionCount,section:re==null?void 0:re.cls,l1:re==null?void 0:re.l1,measure:re==null?void 0:re.measure,hasImage:re==null?void 0:re.hasImage,loaded:!!(re!=null&&re.loaded)}}),[e.works,w]),S=h.useMemo(()=>Ml((e.works||[]).map(B=>B.role),d("detail.roleAll")),[e.works,d]),v=h.useMemo(()=>{const B=m==="全部"?j:j.filter(re=>re.cls===m);return k==="versions"?[...B].sort((re,he)=>(he.versionCount??-1)-(re.versionCount??-1)):B},[j,m,k]),$=f?v:v.slice(0,db),_=h.useMemo(()=>$.filter(B=>!w.has(B.id)).map(B=>B.id),[$,w]);h.useEffect(()=>{if(!n||_.length===0)return;let B=!1;return Ri(_,Ni,re=>n.getItem(re).then(he=>{var be,ee,fe,Ee,Fe;const Ne=he??{},Re=Ne._edition_count??(((be=Ne.books)==null?void 0:be.length)??0)+(((ee=Ne.collections)==null?void 0:ee.length)??0),U=[(fe=Ne.classification)==null?void 0:fe.l1,(Ee=Ne.classification)==null?void 0:Ee.l2].filter(Boolean).join(" ");return[re,{id:re,title:Ne.title,versionCount:Re,loaded:!0,cls:U||void 0,l1:((Fe=Ne.classification)==null?void 0:Fe.l1)||void 0,measure:he&&Pt(he,p.unit.juan)||void 0,hasImage:!!(Ne.has_image??Ne._has_image)}]}).catch(()=>[re,{id:re,loaded:!0}]),()=>B).then(re=>{B||b(he=>{const Ne=new Map(he);for(const[Re,U]of re)Ne.set(Re,U);return Ne})}),()=>{B=!0}},[n,_,p.unit.juan]);const z=h.useMemo(()=>{const B=new Map;for(const re of e.alt_names||[]){const he=re.type||p.section.aliases;B.has(he)||B.set(he,[]),B.get(he).push(re.name)}return[...B.entries()].sort((re,he)=>_a(re[0])-_a(he[0])).map(([re,he])=>({label:re,names:he}))},[e.alt_names,p]),P=e.birth_year??((ue=e.dates)==null?void 0:ue.birth)??void 0,N=e.death_year??(($e=e.dates)==null?void 0:$e.death)??void 0,T=(G=e.dates)==null?void 0:G.floruit,D=P!=null||N!=null?`${u(P)||"?"}—${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=z.filter(B=>R.has(B.label)),L=z.filter(B=>!R.has(B.label)),I=L.reduce((B,re)=>B+re.names.length,0),A=h.useMemo(()=>{const B=[];for(const he of E)B.push({label:he.label,value:he.names.map(Ne=>c(Ne)).join("、")});const re=(e.works||[]).length;return re&&B.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:re})}),B},[e.works,E,c,d]),V=B=>{var re;return(re=z.find(he=>B.includes(he.label)))==null?void 0:re.names[0]},q=V(["字"]),O=V(["號","号"]),W=[q?d("entityPage.zi",{name:c(q)}):"",O?d("entityPage.hao",{name:c(O)}):""].filter(Boolean).join(","),K=e.native_place,Y=e.dynasty?mb[e.dynasty]:void 0,F=(()=>{if(!Y||P==null||N==null||N<P)return null;const[B,re]=Y,he=Math.max(P,B),Ne=Math.min(N,re);if(Ne<=he)return null;const Re=re-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(P),death:u(N),years:N-P+1}),children:t.jsx("i",{style:{left:`${(he-B)/Re*100}%`,width:`${(Ne-he)/Re*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-P+1})}),t.jsx("span",{children:u(re)})]})]})})(),te=h.useMemo(()=>{if(!n||j.length===0||j.some(he=>!he.loaded))return null;const B=new Map;for(const he of j){const Ne=Io(he.l1);Ne&&B.set(Ne,(B.get(Ne)??0)+1)}const re=Mn.map(he=>({...he,n:B.get(he.key)??0})).filter(he=>he.n>0);return re.length?re:null},[j,n]),je=t.jsxs(Fn,{kind:pb(p.entityPage.subtype,e.subtype,c),title:c(e.primary_name||e.title),subtitle:W||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(it,{items:[e.dynasty?c(e.dynasty):"",D,K?d("entityPage.nativePlace",{place:c(K)}):""]}),F]}),description:(ze=e.description)!=null&&ze.text?t.jsx(At,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:rr((Le=e.description)==null?void 0:Le.text)?6:void 0,facts:A,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(h.Fragment,{children:[t.jsx("dt",{children:c(B.label)}),t.jsx("dd",{children:B.names.map(re=>c(re)).join("、")})]},B.label))})]}),te&&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:te.map(B=>t.jsx("i",{style:{flexGrow:B.n,background:i(B.token)}},B.key))}),t.jsx("div",{className:"bim-d-dist-key",children:te.map(B=>t.jsxs("span",{children:[t.jsx("i",{style:{background:i(B.token)}}),c(B.label)," ",B.n]},B.key))})]})]}),oe=h.useMemo(()=>j.filter(B=>B.loaded&&(B.versionCount??0)>0).sort((B,re)=>(re.versionCount??0)-(B.versionCount??0)).slice(0,3),[j]),ie=!!n&&j.length>=3&&$.some(B=>!B.loaded),Be=m==="全部"&&(ie||oe.length>=2),we=e.external_ids||{},Oe=[];we.cbdb_id!=null&&Oe.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 Te=we.wikidata_id;Te&&Oe.push({label:"Wikidata",id:Te,href:`https://www.wikidata.org/wiki/${Te}`});const X=we.viaf_id;X&&Oe.push({label:"VIAF",id:X,href:`https://viaf.org/viaf/${X}`});const le=S.map(B=>({key:B.cls,label:`${B.label} ${B.count}`})),de=[...Be&&!ie?[{id:"featured",label:d("entityPage.sec.featured"),count:oe.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...Oe.length?[{id:"external",label:d("entityPage.sec.external"),count:Oe.length}]:[]],ve=Be?t.jsxs(ot,{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":ie||void 0,children:[ie&&[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)),!ie&&oe.map(B=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(et,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0})}),t.jsx(it,{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,H=j.length===0?t.jsx(ot,{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:[ve,t.jsxs(ot,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(it,{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(Ci,{items:le,value:m,onChange:B=>{g(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&&zi(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(et,{id:B.id,label:c(B.title),onNavigate:o,renderLink:r,dense:!0}),B.measure?t.jsx(it,{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(ir,{total:v.length,shown:$.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),me=Oe.length>0?t.jsx(Zt,{id:"external",title:d("entityPage.sec.external"),items:Oe.map(B=>t.jsxs("a",{href:B.href,target:"_blank",rel:"noopener noreferrer",children:[B.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Oe.map(B=>B.id),foot:we.cbdb_id!=null&&we.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(On,{railTop:s,back:a,nav:de,railLinks:l,main:H,card:je,side:me})},Er="(max-width: 719px)",gb=`${Er}, (pointer: coarse)`,Xc=`
|
|
1343
1343
|
.bim-ct {
|
|
1344
1344
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1345
1345
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1498,7 +1498,7 @@ ${ke??""}`,[Je,St]=h.useState({key:He,data:C,started:!!C});if(Je.key!==He)St({ke
|
|
|
1498
1498
|
/* 窄屏分类抽屉:界栏下按钮和面板都有框 */
|
|
1499
1499
|
:root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${i("fr-bd")}; background: ${i("fr-bg")}; }
|
|
1500
1500
|
:root[data-layout="boxed"] .bim-ct-drawer { border: ${i("fr-bd")}; }
|
|
1501
|
-
`,Xt="未分類",It="all",Ir=20;function Un(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 hb(e){const n=Un(e);return n.length?n.join("/"):Xt}function fb(e){const n=Un(e);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Xt]}function xb(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 g=p.slice(0,m+1).join("/");o.has(g)||o.set(g,c)})});const r=new Map;let s=0;for(const d of e){const c=Un(d.classification);if(!c.length){s++;continue}let p=r;c.forEach((u,m)=>{const g=c.slice(0,m+1).join("/");let f=p.get(u);f||(f={id:g,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===Xt?1:0,m=p.label===Xt?1:0;if(u!==m)return u-m;const g=o.get(c.id)??1/0,f=o.get(p.id)??1/0;return g!==f?g-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:Xt,label:Xt,count:s}),l}function dn(e,n){if(!n)return[];for(const o of e){if(o.id===n)return[o];if(o.children){const r=dn(o.children,n);if(r.length)return[o,...r]}}return[]}function Lr(e){return e.reduce((n,o)=>n+o.count,0)}function bb(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function yb(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=bb(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Un(e.classification);return l.length&&(n.classification=l),n}function jb(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 vb(e,n=Ir){return Math.max(1,Math.ceil(e/n))}function Zc(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 kb=()=>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 wb(e,n,o){const r=[];o&&r.push({id:It,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 Jc({tree:e,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:a,convert:l}=ee(),d=r===void 0?a("catalogPage.all"):r,c=s??a("catalogPage.classification"),p=h.useRef(null),u=n&&n!==It?n:null,m=d!==null,[g,f]=h.useState(()=>{const z=new Set;for(const P of dn(e,u))z.add(P.id);return z});h.useEffect(()=>{const z=dn(e,u);z.length&&f(P=>{if(z.every(T=>P.has(T.id)))return P;const N=new Set(P);for(const T of z)N.add(T.id);return N})},[e,u]);const x=h.useMemo(()=>wb(e,g,m),[e,g,m]),[k,y]=h.useState(null);h.useEffect(()=>{y(null)},[n]);const w=u??(m?It:null),b=h.useMemo(()=>{var N;const z=new Set(x.map(T=>T.id));if(k&&z.has(k))return k;if(w&&z.has(w))return w;const P=dn(e,u).map(T=>T.id).filter(T=>z.has(T));return P.length?P[P.length-1]:((N=x[0])==null?void 0:N.id)??null},[x,k,w,e,u]),j=h.useCallback((z,P)=>{f(N=>{const T=N.has(z),D=P??!T;if(D===T)return N;const R=new Set(N);return D?R.add(z):R.delete(z),R})},[]),S=h.useCallback(z=>{y(z),requestAnimationFrame(()=>{var N;const P=Array.from(((N=p.current)==null?void 0:N.querySelectorAll("[data-ct-id]"))??[]).find(T=>T.dataset.ctId===z);P==null||P.focus()})},[]),v=h.useCallback((z,P)=>{P&&j(z,!0),o(z)},[o,j]),$=h.useCallback(z=>{const P=z.target.closest("[data-ct-id]");if(!P)return;const N=P.dataset.ctId,T=x.findIndex(E=>E.id===N);if(T<0)return;const D=x[T];let R=null;switch(z.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(!D.hasChildren)break;g.has(N)?R=D.firstChildId:j(N,!0);break;case"ArrowLeft":D.hasChildren&&g.has(N)?j(N,!1):R=D.parentId;break;case"Enter":case" ":z.preventDefault(),v(N,D.hasChildren);return;default:return}z.preventDefault(),R&&R!==N&&S(R)},[x,g,j,S,v]),_=(z,P)=>z.map((N,T)=>{var I;const D=(I=N.children)!=null&&I.length?N.children:null,R=!!D&&g.has(N.id),E=N.id===u,L=P===1&&z.length>1&&T===z.length-1;return t.jsxs("li",{role:"treeitem","aria-level":P,"aria-expanded":D?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":P-1},onClick:()=>{y(N.id),v(N.id,!!D)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:D?A=>{A.stopPropagation(),y(N.id),j(N.id)}:void 0,children:D?t.jsx(kb,{}):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:_(D,P+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===It?0:-1,"data-ct-id":It,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(It),o(It)},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:Lr(e).toLocaleString("en-US")})]})}),_(e,1)]})}const Qc=e=>`/item/${encodeURIComponent(e)}`;function Sb(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function ed(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function td({work:e,href:n}){var d,c;const{t:o,convert:r}=ee(),s=ed(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(h.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 nd({work:e,href:n}){var d,c;const{t:o,convert:r}=ee(),s=ed(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(h.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 id({page:e,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:a,convert:l}=ee();if(n<=1)return null;const d=p=>u=>{o&&(r&&!Sb(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 g={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return r?t.jsx("a",{...g,href:r(p),onClick:d(p),children:u}):t.jsx("button",{type:"button",...g,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:Zc(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 od({works:e,workLink:n=Qc,emptyText:o,view:r="card",...s}){const{t:a,convert:l}=ee();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(nd,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(td,{work:d,href:n(d.id)},d.id))}),t.jsx(id,{...s})]})}const _b=()=>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 $b({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:g=Ir,className:f,view:x,onViewChange:k}){const{t:y,convert:w}=ee(),b=u===void 0?y("catalogPage.all"):u,j=m??y("catalogPage.allTitle"),v=`bim-ct-drawer-${h.useId().replace(/:/g,"")}`,[$,_]=h.useState(!1),[z,P]=h.useState("card"),N=x??z,T=A=>{P(A),k==null||k(A)},D=dn(e,n&&n!==It?n:null),R=D.length?D[D.length-1]:null,E=R?R.label:j,L=R?R.count:Lr(e),I=h.useCallback(A=>{_(!1),a(A)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:Xc}),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:()=>_(A=>!A),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:w(D.length?D.map(A=>A.label).join(" › "):b??j)})}),t.jsx(_b,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Jc,{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)}),D.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:w(D.slice(0,-1).map(A=>A.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:L.toLocaleString("en-US"),size:g}),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(od,{works:s,view:N,workLink:c,page:o,pageCount:r,onPage:l,pageHref:p})]})]})}const Vn="(max-width: 719px)",Cb="(max-width: 1079px)",zb=`${Vn}, (pointer: coarse)`,Tb=[8,18,30,42,88],Ar=`
|
|
1501
|
+
`,Xt="未分類",It="all",Ir=20;function Un(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 hb(e){const n=Un(e);return n.length?n.join("/"):Xt}function fb(e){const n=Un(e);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Xt]}function xb(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 g=p.slice(0,m+1).join("/");o.has(g)||o.set(g,c)})});const r=new Map;let s=0;for(const d of e){const c=Un(d.classification);if(!c.length){s++;continue}let p=r;c.forEach((u,m)=>{const g=c.slice(0,m+1).join("/");let f=p.get(u);f||(f={id:g,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===Xt?1:0,m=p.label===Xt?1:0;if(u!==m)return u-m;const g=o.get(c.id)??1/0,f=o.get(p.id)??1/0;return g!==f?g-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:Xt,label:Xt,count:s}),l}function dn(e,n){if(!n)return[];for(const o of e){if(o.id===n)return[o];if(o.children){const r=dn(o.children,n);if(r.length)return[o,...r]}}return[]}function Lr(e){return e.reduce((n,o)=>n+o.count,0)}function bb(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function yb(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=bb(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Un(e.classification);return l.length&&(n.classification=l),n}function jb(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 vb(e,n=Ir){return Math.max(1,Math.ceil(e/n))}function Zc(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 kb=()=>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 wb(e,n,o){const r=[];o&&r.push({id:It,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 Jc({tree:e,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:a,convert:l}=Q(),d=r===void 0?a("catalogPage.all"):r,c=s??a("catalogPage.classification"),p=h.useRef(null),u=n&&n!==It?n:null,m=d!==null,[g,f]=h.useState(()=>{const z=new Set;for(const P of dn(e,u))z.add(P.id);return z});h.useEffect(()=>{const z=dn(e,u);z.length&&f(P=>{if(z.every(T=>P.has(T.id)))return P;const N=new Set(P);for(const T of z)N.add(T.id);return N})},[e,u]);const x=h.useMemo(()=>wb(e,g,m),[e,g,m]),[k,y]=h.useState(null);h.useEffect(()=>{y(null)},[n]);const w=u??(m?It:null),b=h.useMemo(()=>{var N;const z=new Set(x.map(T=>T.id));if(k&&z.has(k))return k;if(w&&z.has(w))return w;const P=dn(e,u).map(T=>T.id).filter(T=>z.has(T));return P.length?P[P.length-1]:((N=x[0])==null?void 0:N.id)??null},[x,k,w,e,u]),j=h.useCallback((z,P)=>{f(N=>{const T=N.has(z),D=P??!T;if(D===T)return N;const R=new Set(N);return D?R.add(z):R.delete(z),R})},[]),S=h.useCallback(z=>{y(z),requestAnimationFrame(()=>{var N;const P=Array.from(((N=p.current)==null?void 0:N.querySelectorAll("[data-ct-id]"))??[]).find(T=>T.dataset.ctId===z);P==null||P.focus()})},[]),v=h.useCallback((z,P)=>{P&&j(z,!0),o(z)},[o,j]),$=h.useCallback(z=>{const P=z.target.closest("[data-ct-id]");if(!P)return;const N=P.dataset.ctId,T=x.findIndex(E=>E.id===N);if(T<0)return;const D=x[T];let R=null;switch(z.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(!D.hasChildren)break;g.has(N)?R=D.firstChildId:j(N,!0);break;case"ArrowLeft":D.hasChildren&&g.has(N)?j(N,!1):R=D.parentId;break;case"Enter":case" ":z.preventDefault(),v(N,D.hasChildren);return;default:return}z.preventDefault(),R&&R!==N&&S(R)},[x,g,j,S,v]),_=(z,P)=>z.map((N,T)=>{var I;const D=(I=N.children)!=null&&I.length?N.children:null,R=!!D&&g.has(N.id),E=N.id===u,L=P===1&&z.length>1&&T===z.length-1;return t.jsxs("li",{role:"treeitem","aria-level":P,"aria-expanded":D?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":P-1},onClick:()=>{y(N.id),v(N.id,!!D)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:D?A=>{A.stopPropagation(),y(N.id),j(N.id)}:void 0,children:D?t.jsx(kb,{}):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:_(D,P+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===It?0:-1,"data-ct-id":It,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(It),o(It)},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:Lr(e).toLocaleString("en-US")})]})}),_(e,1)]})}const Qc=e=>`/item/${encodeURIComponent(e)}`;function Sb(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function ed(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function td({work:e,href:n}){var d,c;const{t:o,convert:r}=Q(),s=ed(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(h.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 nd({work:e,href:n}){var d,c;const{t:o,convert:r}=Q(),s=ed(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(h.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 id({page:e,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:a,convert:l}=Q();if(n<=1)return null;const d=p=>u=>{o&&(r&&!Sb(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 g={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return r?t.jsx("a",{...g,href:r(p),onClick:d(p),children:u}):t.jsx("button",{type:"button",...g,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:Zc(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 od({works:e,workLink:n=Qc,emptyText:o,view:r="card",...s}){const{t:a,convert:l}=Q();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(nd,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(td,{work:d,href:n(d.id)},d.id))}),t.jsx(id,{...s})]})}const _b=()=>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 $b({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:g=Ir,className:f,view:x,onViewChange:k}){const{t:y,convert:w}=Q(),b=u===void 0?y("catalogPage.all"):u,j=m??y("catalogPage.allTitle"),v=`bim-ct-drawer-${h.useId().replace(/:/g,"")}`,[$,_]=h.useState(!1),[z,P]=h.useState("card"),N=x??z,T=A=>{P(A),k==null||k(A)},D=dn(e,n&&n!==It?n:null),R=D.length?D[D.length-1]:null,E=R?R.label:j,L=R?R.count:Lr(e),I=h.useCallback(A=>{_(!1),a(A)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:Xc}),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:()=>_(A=>!A),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:w(D.length?D.map(A=>A.label).join(" › "):b??j)})}),t.jsx(_b,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Jc,{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)}),D.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:w(D.slice(0,-1).map(A=>A.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:L.toLocaleString("en-US"),size:g}),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(od,{works:s,view:N,workLink:c,page:o,pageCount:r,onPage:l,pageHref:p})]})]})}const Vn="(max-width: 719px)",Cb="(max-width: 1079px)",zb=`${Vn}, (pointer: coarse)`,Tb=[8,18,30,42,88],Ar=`
|
|
1502
1502
|
.bim-rh { color: ${i("ink")}; font-family: ${i("font-ui")}; font-size: 14px; line-height: 1.6; }
|
|
1503
1503
|
.bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
|
|
1504
1504
|
.bim-rh a { color: ${i("accent")}; text-decoration: none; }
|
|
@@ -1728,7 +1728,7 @@ ${Tb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1728
1728
|
}
|
|
1729
1729
|
|
|
1730
1730
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1731
|
-
`,Nb=Bo["zh-Hant"].period,rd={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Ft(e){return{...rd,...e??{}}}function Pr(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 Ii(e){return(e.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function sd(e,n=Bo["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 ad(e){return Math.max(150,Array.from(e).length*18+44)}function ld(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 cd=.04;function Ke(e){return e.toLocaleString("en-US")}function dd({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,o)=>t.jsx("span",{children:n},o))})}function ct({id:e,title:n,sub:o,more:r,children:s}){const{convert:a}=ee(),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 pd({counts:e}){const{t:n}=ee();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ke(e.pieces)}),n("readHome.pieces")]})]})}function ud({picks:e,links:n}){const{t:o,convert:r}=ee(),s=Ft(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Ii(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(dd,{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 md(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Mr({topic:e,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ee(),c=Ft(n);if(!e.items.length)return null;const p=r===void 0?l("readHome.shelfLegendCount"):r,u=sd(e.items,l("readHome.shelfOther")),m=g=>{const f=g.records?Ke(g.records):md(g.text_count,l),x=Pr(g),k=[d(g.title),g.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",g.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(g.id),"data-orig":g.orig?"":void 0,"aria-label":k,title:k,style:{height:ad(g.title)},children:[t.jsx(dd,{text:d(g.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":g.records?"":void 0,children:f})]})},g.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(g=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(g.label),children:g.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(g.label)})]},g.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(g=>t.jsx("span",{children:d(g)},g))]})]})}const Rb=4,Bn=e=>e>Rb+1;function gd({topic:e,links:n}){const{t:o,convert:r}=ee(),s=Ft(n),[a,l]=h.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":Bn(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:Ke(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=md(c.text_count,o),u=Pr(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)})}),Bn(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 hd({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(Mr,{topic:s,links:n},s.key)),r.length>0&&t.jsx("div",{className:"bim-rh-groups",children:r.map(s=>t.jsx(gd,{topic:s,links:n},s.key))})]})}function fd({famous:e,links:n}){const{t:o,convert:r}=ee(),s=Ft(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 Br({bu:e,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:a}=ee(),l=Ft(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:Ke(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:Ke(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:Ke(n)})}),t.jsx("span",{children:r?a(r):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function xd({periods:e,unknown:n,links:o}){const{t:r,convert:s,messages:a}=ee(),l=a.readHome.period,d=Ft(o),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,g)=>m+g.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 g=m.label?s(m.label):l[m.key]??s(m.key),f=m.count/p,x=r("readHome.periodItem",{label:g,n:Ke(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":ld(m.count,u),"data-narrow":f<cd?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:g}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(g)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ke(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:r("readHome.periodUnknown",{n:Ke(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function bd({authors:e,links:n}){const{t:o,convert:r}=ee(),s=Ft(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:Ke(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 yd={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function Eb({sections:e,links:n,head:o,piecesMoreHref:r,className:s}){const{t:a}=ee(),l=e,d=yd,c=l.topics.filter(g=>!g.shelf),p={picks:l.picks.length>0,topics:c.some(g=>g.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(g=>g.count>0),pieces:l.pieces.authors.length>0},u=Object.keys(d).filter(g=>p[g]),m=g=>a(`readHome.nav.${g}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:Ar}),t.jsxs("div",{className:"bim-rh-head",children:[o,t.jsx(pd,{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(g=>t.jsx("li",{children:t.jsx("a",{href:`#${d[g]}`,children:m(g)})},g))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(ct,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(ud,{picks:l.picks,links:n})}),p.topics&&t.jsx(ct,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(hd,{topics:c,links:n})}),p.famous&&t.jsx(ct,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(fd,{famous:l.famous,links:n})}),p.sibu&&t.jsx(ct,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Br,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(ct,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(xd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(ct,{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(bd,{authors:l.pieces.authors,links:n})})]})]})}const Ib="(max-width: 1079px)",Lb=`${Vn}, (pointer: coarse)`,jd=`
|
|
1731
|
+
`,Nb=Bo["zh-Hant"].period,rd={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Ft(e){return{...rd,...e??{}}}function Pr(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 Ii(e){return(e.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function sd(e,n=Bo["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 ad(e){return Math.max(150,Array.from(e).length*18+44)}function ld(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 cd=.04;function Xe(e){return e.toLocaleString("en-US")}function dd({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,o)=>t.jsx("span",{children:n},o))})}function ct({id:e,title:n,sub:o,more:r,children:s}){const{convert:a}=Q(),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 pd({counts:e}){const{t:n}=Q();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Xe(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Xe(e.pieces)}),n("readHome.pieces")]})]})}function ud({picks:e,links:n}){const{t:o,convert:r}=Q(),s=Ft(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=Ii(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(dd,{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 md(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Mr({topic:e,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=Q(),c=Ft(n);if(!e.items.length)return null;const p=r===void 0?l("readHome.shelfLegendCount"):r,u=sd(e.items,l("readHome.shelfOther")),m=g=>{const f=g.records?Xe(g.records):md(g.text_count,l),x=Pr(g),k=[d(g.title),g.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",g.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(g.id),"data-orig":g.orig?"":void 0,"aria-label":k,title:k,style:{height:ad(g.title)},children:[t.jsx(dd,{text:d(g.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":g.records?"":void 0,children:f})]})},g.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(g=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(g.label),children:g.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(g.label)})]},g.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(g=>t.jsx("span",{children:d(g)},g))]})]})}const Rb=4,Bn=e=>e>Rb+1;function gd({topic:e,links:n}){const{t:o,convert:r}=Q(),s=Ft(n),[a,l]=h.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":Bn(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:Xe(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=md(c.text_count,o),u=Pr(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)})}),Bn(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 hd({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(Mr,{topic:s,links:n},s.key)),r.length>0&&t.jsx("div",{className:"bim-rh-groups",children:r.map(s=>t.jsx(gd,{topic:s,links:n},s.key))})]})}function fd({famous:e,links:n}){const{t:o,convert:r}=Q(),s=Ft(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 Br({bu:e,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:a}=Q(),l=Ft(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:Xe(d.count)})})]}),d.top.length>0&&t.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:a(d.label)}),children:d.top.map(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:Xe(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:Xe(n)})}),t.jsx("span",{children:r?a(r):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function xd({periods:e,unknown:n,links:o}){const{t:r,convert:s,messages:a}=Q(),l=a.readHome.period,d=Ft(o),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,g)=>m+g.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 g=m.label?s(m.label):l[m.key]??s(m.key),f=m.count/p,x=r("readHome.periodItem",{label:g,n:Xe(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":ld(m.count,u),"data-narrow":f<cd?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:g}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(g)[0]}),t.jsx("small",{className:"bim-rh-num",children:Xe(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:r("readHome.periodUnknown",{n:Xe(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function bd({authors:e,links:n}){const{t:o,convert:r}=Q(),s=Ft(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:Xe(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 yd={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function Eb({sections:e,links:n,head:o,piecesMoreHref:r,className:s}){const{t:a}=Q(),l=e,d=yd,c=l.topics.filter(g=>!g.shelf),p={picks:l.picks.length>0,topics:c.some(g=>g.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(g=>g.count>0),pieces:l.pieces.authors.length>0},u=Object.keys(d).filter(g=>p[g]),m=g=>a(`readHome.nav.${g}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:Ar}),t.jsxs("div",{className:"bim-rh-head",children:[o,t.jsx(pd,{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(g=>t.jsx("li",{children:t.jsx("a",{href:`#${d[g]}`,children:m(g)})},g))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(ct,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(ud,{picks:l.picks,links:n})}),p.topics&&t.jsx(ct,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(hd,{topics:c,links:n})}),p.famous&&t.jsx(ct,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(fd,{famous:l.famous,links:n})}),p.sibu&&t.jsx(ct,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(Br,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(ct,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(xd,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(ct,{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(bd,{authors:l.pieces.authors,links:n})})]})]})}const Ib="(max-width: 1079px)",Lb=`${Vn}, (pointer: coarse)`,jd=`
|
|
1732
1732
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1733
1733
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1734
1734
|
.bim-mh-q { min-width: 0; }
|
|
@@ -1899,4 +1899,4 @@ ${Tb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1899
1899
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
1900
1900
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
1901
1901
|
}
|
|
1902
|
-
`,vd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Ht(e){return{...vd,...e??{}}}function kd(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 Wr(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function wd(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=fn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function Ab(e){return{read:e.item,work:e.item,node:e.node}}function Sd({counts:e,links:n}){const{t:o}=ee(),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:Ke(d)})]})},a))})}function _d(e,n=5){const[o,r]=h.useState(null);h.useEffect(()=>{let a=!1;const l=Ot().slice(0,n);if(!l.length||!e){r([]);return}return Promise.all(l.map(d=>Go(e,d))).then(d=>{a||r(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=h.useCallback(()=>{Vo(),r([])},[]);return{entries:o,clear:s}}function Pb(e,n,o){const r=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return r?o(r):$d(e.type,n)}function $d(e,n){return n(`metaHome.typeLabel.${e}`)}function Cd({entries:e,onClear:n,links:o}){const{t:r,convert:s}=ee(),a=Ht(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?$d(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:Pb(l,r,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function zd(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 Td({rows:e,links:n}){const{t:o,convert:r}=ee(),s=Ht(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=Wr(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:Ke(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ke(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:zd(a.status,o,r)})})]},a.id||a.name)})})]})}):null}function Nd({items:e,links:n,label:o}){const{convert:r}=ee();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 Rd({works:e,links:n}){const{t:o}=ee(),[r,s]=h.useState(!1);if(!e.length)return null;const a=Bn(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(Nd,{items:e.map(l=>({id:l.id,title:l.title,sub:Ii(l)||void 0})),links:Ht(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 Ed="siku_qige";function Mb({group:e,links:n}){const{t:o,convert:r}=ee(),[s,a]=h.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Bn(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(Nd,{items:e.items,links:n,label:e.label}),Bn(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 Id({groups:e,links:n}){const{t:o,convert:r}=ee(),s=Ht(n);if(!e.length)return null;const a=e.find(c=>c.key===Ed),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(Mb,{group:c,links:s},c.key))})]})}const $a=34,Ca=13;function za(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 Bb(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 Ld({people:e,links:n}){const{t:o,convert:r}=ee(),s=Ht(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=wd(e),p=[],u=d.map(g=>{const f=g.left>70,x=f?Math.min(g.left,g.left+g.width-Ca):g.left;let k=0;for(;p[k]!=null&&p[k]>x;)k++;return p[k]=f?g.left+g.width:g.left+Math.max(g.width,Ca),{...g,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*$a+10},children:u.map(g=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":g.end?"":void 0,style:{left:`${g.left}%`,top:g.lane*$a+4,width:`${Math.max(g.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(g.p.id),children:[r(g.p.name),t.jsx("small",{className:"bim-rh-num",children:za(g.p,o)})]})]},g.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Bb(a,l).map(g=>t.jsx("span",{style:{left:`${(g-a)/m*100}%`},children:hi(g,o)},g))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?e:c).map(g=>t.jsx("li",{children:t.jsxs("a",{href:s.item(g.id),children:[t.jsx("span",{children:r(g.name)}),t.jsx("small",{className:"bim-rh-num",children:[g.dynasty?r(g.dynasty):"",za(g,o)].filter(Boolean).join(" ")})]})},g.id))}),c.length>0&&u.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(g=>g.name).join("、"))})})]})}const Wb=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 Ad({works:e,links:n}){const{t:o,convert:r}=ee(),s=Ht(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Ii(a);return t.jsx("li",{children:t.jsxs("a",{href:kd(s,a.id),children:[Wb,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 Pd({sites:e}){const{t:n,convert:o}=ee(),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=Wr(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:[`${Ke(a.imported)} / ${Ke(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:zd(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 Ta=["extant","partially_extant","lost","unknown"];function Md({stats:e,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:a}=ee(),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=Ta.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:Ke(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:Ta.map(p=>{var g;const u=((g=e.loss)==null?void 0:g[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:Ke(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 Bd={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Ob({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}=ee(),g=e,f=Ht(n),x=Ab(f),k=Bd,y=_d(r),w={zhi:!!((v=g.shelf)!=null&&v.items.length)||g.catalog_progress.length>0||g.related_catalogs.length>0,sibu:g.bu.length>0||g.unclassified>0,cong:g.collection_groups.length>0,people:g.bibliographers.length>0,lineage:g.lineage.length>0,sites:g.sites.length>0,data:!0},b=Object.keys(k).filter(_=>w[_]),j=_=>m(`metaHome.nav.${_}`),S=(_,z)=>_?t.jsx("a",{className:"bim-rh-more",href:_,children:z}):void 0;return t.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[t.jsx("style",{children:Ar+jd}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[o,t.jsx(Sd,{counts:g.counts,links:n})]}),r&&t.jsx(Cd,{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(ct,{id:k.zhi,title:j("zhi"),sub:m("metaHome.zhiSub"),children:[g.shelf&&g.shelf.items.length>0&&t.jsx(Mr,{topic:{key:"shelf",label:g.shelf.label,shelf:!0,items:g.shelf.items},links:x,showTitle:!1,legendCount:g.shelf.items.some(_=>_.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(g.catalog_progress.length>0||g.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=g.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(Td,{rows:g.catalog_progress,links:n}),t.jsx(Rd,{works:g.related_catalogs,links:n})]})]}),w.sibu&&t.jsx(ct,{id:k.sibu,title:j("sibu"),sub:m("metaHome.sibuSub"),more:S(s,m("metaHome.toCatalog")),children:t.jsx(Br,{bu:g.bu,unclassified:g.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),w.cong&&t.jsx(ct,{id:k.cong,title:j("cong"),sub:m("metaHome.congSub"),more:S(a,m("metaHome.allNKindsMore",{n:Ke(g.counts.collections)})),children:t.jsx(Id,{groups:g.collection_groups,links:n})}),w.people&&t.jsx(ct,{id:k.people,title:j("people"),sub:m("metaHome.peopleSub"),more:S(l,m("metaHome.allNPeopleMore",{n:Ke(g.counts.entities)})),children:t.jsx(Ld,{people:g.bibliographers,links:n})}),w.lineage&&t.jsx(ct,{id:k.lineage,title:j("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(Ad,{works:g.lineage,links:n})}),w.sites&&t.jsx(ct,{id:k.sites,title:j("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(Pd,{sites:g.sites})}),t.jsx(ct,{id:k.data,title:j("data"),sub:m("metaHome.dataSub"),children:t.jsx(Md,{stats:g.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const Ct=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),rt=e=>Array.isArray(e),Fb=e=>Ct(e)&&!!e.h;function Hb(e){if(!e)return!1;for(const n of["_related","_catalogs","_collections","_works","_members","_children"]){const o=e[n];if(rt(o)&&o.some(Fb))return!0}return!1}function ii(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 Db(e){const n=e.filter(Ct);return n.find(o=>o.scheme==="zongmu")??n[0]??null}const Ub=e=>typeof e=="number"?e:rt(e)&&typeof e[0]=="number"?e[0]:void 0;function Lo(e,n){if(!Ct(e))return e;const o={...e},r=e.type;if(r==="work"){if(!rt(e.books)&&rt(e._books)&&(o.books=e._books.filter(Ct).map(s=>s.id).filter(s=>typeof s=="string")),!Ct(e.classification)&&rt(e._classifications)){const s=Db(e._classifications);s&&(o.classification={l1:s.l1??"",l2:s.l2??"",l3:s.l3??"",l4:s.l4??"",...s.source?{source:s.source}:{}})}rt(e._related)&&(o.related_works=e._related.filter(Ct).map(s=>{const a=s;return{id:a.id,title:ii(a,n),...a.relation?{relation:a.relation}:{},...a.note?{note:a.note}:{}}})),!rt(e.indexed_by)&&rt(e._catalogs)&&e._catalogs.length&&(o.indexed_by=e._catalogs.filter(Ct).map(s=>{const a=s;return{source:ii(a,n)||String(a.bid??""),...a.bid?{source_bid:a.bid}:{},...a.section?{section:a.section}:{}}}))}if((r==="work"||r==="book")&&!rt(e.contained_in)&&rt(e._collections)&&e._collections.length&&(o.contained_in=e._collections.filter(Ct).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"&&rt(e._members)){const s=e._members.filter(Ct),a=typeof e._member_count=="number"?e._member_count:s.length,l=d=>d.t==="work";if(!rt(e.books)){const d=s.filter(c=>!l(c)).map(c=>c.id).filter(c=>typeof c=="string");d.length&&(o.books=d)}if(!rt(e.contained_works)){const d=s.filter(l).map(c=>{const p=Ub(c.vol);return{id:c.id,title:ii(c,n),...p!=null?{volume_index:p}:{}}});d.length&&(o.contained_works=d)}a>s.length&&(o._members_truncated=!0)}return r==="entity"&&!rt(e.works)&&rt(e._works)&&(o.works=e._works.filter(Ct).map(s=>{const a=s,l=ii({...a,id:a.work_id},n);return{...a,work_id:a.work_id,...l?{title:l}:{}}})),o}function Vb(e){let n=null;const o=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null),r=async s=>s&&Lo(s,Hb(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 Ao=({style:e})=>{const n=h.useContext(en),{t:o}=ee();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")})]})},Po=({href:e,label:n,size:o=16,className:r,style:s})=>{const{t:a}=ee(),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 co(e){const n=e.text_count;return typeof n=="number"&&n>0}function po(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function Gb(e,n){if(!n)return!1;const o=n.id;return o===void 0||o===e}const Yb=({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:g=1,selectedLineageNodeId:f,onNavigate:x,onBack:k,backLabel:y,renderLink:w,enrichDetail:b,getSourceLink:j,readLink:S,railTop:v,extraTabs:$=[],showFeedbackTab:_=!0,feedbackApiUrl:z,height:P,footerExtra:N,hideHeaderControls:T=!1,className:D,style:R})=>{const E=h.useMemo(()=>Vb(n),[n]),L=Ce(),{t:I,convert:A}=ee(),[V]=h.useState(()=>{if(!Gb(e,o))return null;const Z=Lo({...o}),ye=r??po(e,Z);return b&&b(ye,Z),{id:e,entry:ye,detail:Z}}),[q,U]=h.useState((V==null?void 0:V.entry)??null),[O,K]=h.useState((V==null?void 0:V.detail)??null),[Y,W]=h.useState(!V),[ne,je]=h.useState(!1),[Q,de]=h.useState([]),[We,_e]=h.useState(!1),[Be,Ne]=h.useState(null),[X,ae]=h.useState(null),[le,ke]=h.useState(null),[H,fe]=h.useState(!1),ue=h.useRef(null),$e=h.useRef(0),[G,Te]=h.useState(null),Ie=l!==void 0?l:G,B=h.useCallback(Z=>{d?d(Z):Te(Z)},[d]),oe=h.useCallback(async Z=>{if(!E.getCollectionCatalogs&&!E.getCollectionCatalog){de([]);return}_e(!0);try{if(E.getCollectionCatalogs)de(await E.getCollectionCatalogs(Z)||[]);else if(E.getCollectionCatalog){const ye=await E.getCollectionCatalog(Z);de(ye?[{resource_id:"",data:ye}]:[])}}catch{de([])}finally{_e(!1)}},[E]),xe=h.useCallback(async Z=>{var ye,Ee;if(!E.getTextManifest||!E.getTextIndex){Ne(null),ae(Z);return}try{const Pe=Se.pickTextVersion(await E.getTextManifest(Z)),we=Pe?await E.getTextIndex(Z,Pe.key):null;Ne(we&&we.chapters.length>0?{chapters:we.chapters.map(ce=>({n:ce.n,title:ce.title,file:ce.file})),source:{name:((ye=we.source)==null?void 0:ye.name)??(Pe==null?void 0:Pe.source_name),license:((Ee=we.source)==null?void 0:Ee.license)??(Pe==null?void 0:Pe.license)??void 0}}:null)}catch{Ne(null)}finally{ae(Z)}},[E]),Re=h.useCallback(async(Z,ye)=>{const Ee=++$e.current,Pe=()=>Ee!==$e.current;fe(!0);try{if(E.getLineageGraph){const vt=await E.getLineageGraph(Z);if(Pe())return;vt&&ke(vt)}const we=ye.version_graph;if(!we||!we.enabled){le||ke(null),ue.current=null;return}const ce=ye.books??[],Fe=(await Ri(ce,Ni,async vt=>{try{return await E.getItem(vt)}catch{return null}},Pe)).filter(Boolean);if(Pe())return;ue.current={work:ye,books:Fe};const Me=u??we.default_collection??(we.core_books&&we.core_books.length>0?"core":"all"),jt=Me==="core"&&Array.isArray(we.core_books)&&we.core_books.length>0?"core":Me??"all";ke(li(ye,Fe,jt))}catch{if(Pe())return;ke(null),ue.current=null}finally{Pe()||fe(!1)}},[E]),F=h.useRef({initialDetail:o,initialEntry:r});F.current={initialDetail:o,initialEntry:r},h.useEffect(()=>{let Z=!1;$e.current++,fe(!1);const ye=ce=>{ce.type==="collection"?oe(e):ce.type==="work"?(ce.version_graph||E.getLineageGraph)&&Re(e,ce):ce.type==="book"&&co(ce)&&xe(e)},Ee=F.current;let Pe=null;if(V&&V.id===e)Pe=V;else if(Ee.initialDetail&&Ee.initialDetail.id===e){const ce=Lo({...Ee.initialDetail}),be=Ee.initialEntry??po(e,ce);b&&b(be,ce),Pe={entry:be,detail:ce}}return Pe?(je(!1),de(ce=>ce.length?[]:ce),Ne(null),ke(null),ue.current=null,U(Pe.entry),K(Pe.detail),W(!1),ye(Pe.detail),()=>{Z=!0}):((async()=>{W(!0),je(!1),U(null),K(null),de([]),Ne(null),ke(null),ue.current=null;try{const ce=await E.getItem(e);if(Z)return;if(!ce){je(!0);return}const be=ce;let Fe=null;if(E.getEntry&&(Fe=await E.getEntry(e),Z))return;Fe||(Fe=po(e,be)),b&&b(Fe,be),U(Fe),K(be),ye(be)}catch{Z||je(!0)}finally{Z||W(!1)}})(),()=>{Z=!0})},[e,E,V,b,oe,Re,xe]),h.useEffect(()=>{const Z=ue.current;!Z||!u||ke(li(Z.work,Z.books,u))},[u]);const me=[];if(O){if(me.push({key:"basic",label:L.detailTab.basicInfo}),O.type==="collection"){We&&Q.length===0&&me.push({key:"catalog:loading",label:`${L.detailTab.catalog}…`});for(const Z of Q)me.push({key:`catalog:${Z.resource_id}`,label:Z.short_name?`${A(Z.short_name)}${L.detailTab.catalogSuffix}`:L.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&me.push({key:s,label:L.detailTab.fullText}),O.type==="work"&&(le||H)&&me.push({key:"lineage",label:H?`${L.detailTab.lineage}…`:L.detailTab.lineage});for(const Z of $)(Z.position??"before-feedback")==="before-feedback"&&Z.shouldShow(O)&&me.push({key:Z.key,label:Z.label});_&&s==="feedback"&&me.push({key:"feedback",label:L.detailTab.feedback});for(const Z of $)Z.position==="after-feedback"&&Z.shouldShow(O)&&me.push({key:Z.key,label:Z.label})}h.useEffect(()=>{if(s!=="emendated"||!O)return;a("basic");const Z=setTimeout(()=>{var ye;(ye=document.getElementById("studies"))==null||ye.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Z)},[s,O,a]);const te=q&&O&&j?j({activeTab:s,activeJuan:Ie,entry:q,detail:O}):null,ge=h.useMemo(()=>{var we;if(!O)return null;const ye=(O.authors??[]).map(ce=>{const be=nr(ce.role);return`${ce.dynasty?`〔${A(ce.dynasty)}〕`:""}${A(ce.name)}${be?` ${A(be)}`:""}`}).join(" · ");let Ee=!1;try{Ee=Se.extractStatus(O.id)==="draft"}catch{}if(O.type==="book"){const ce=O;return{title:A(ce.title),subtitle:ce.edition?A(ce.edition):ye||void 0,aside:[Ee?L.status.draft:"",ye&&ce.edition?ye:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(O.type==="collection"){const ce=O;return{title:A(ce.title),subtitle:A(Pt(ce,L.unit.juan))||void 0,aside:[(we=ce.publication_info)==null?void 0:we.year,Ee?L.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ye||void 0}}if(O.type==="entity"){const ce=O,be=Me=>Me==null?"":Me<0?I("detail.bce",{n:-Me}):String(Me),Fe=ce.birth_year!=null||ce.death_year!=null?`${be(ce.birth_year)||"?"}—${be(ce.death_year)||"?"}`:"";return{title:A(ce.primary_name||ce.title),subtitle:[ce.dynasty?`〔${A(ce.dynasty)}〕`:"",Fe].filter(Boolean).join(" ")||void 0,aside:Ee?L.status.draft:void 0,secondLine:void 0}}const Pe=A(Pt(O,L.unit.juan));return{title:A(O.title),subtitle:[Pe,ye].filter(Boolean).join(" · ")||void 0,aside:[qb(L,O.subtype),Ee?L.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[O,A,L,I]),ze=O&&co(O)?"text":null,Ue=()=>{B(null),a("fulltext")};let Ve=null;if(O&&S){const Z=S({detail:O,kind:ze});Z&&(Ve=t.jsx(ko,{href:Z}))}else ze&&(Ve=t.jsx(ko,{onClick:Ue}));const qe=Z=>{if(!O)return null;const ye=Z.replace(/\.[^.]+$/,"");if(S){const Ee=S({detail:O,kind:ze,juan:ye});return Ee?{href:Ee}:null}return{onClick:()=>{B(ye),a("fulltext")}}},Ze=new Set($.map(Z=>Z.key)),Ye=me.filter(Z=>Z.key.startsWith("catalog:")&&Z.key!=="catalog:loading"||Z.key==="lineage"&&!!le&&!H||Ze.has(Z.key)).map(Z=>({key:Z.key,label:Z.label,onClick:()=>a(Z.key)})),C=()=>{var Z;return O?O.type==="work"?t.jsx(Dc,{data:O,transport:E,onNavigate:x,renderLink:w,readAction:Ve,railTop:v,railLinks:Ye}):O.type==="book"?t.jsx(Yc,{data:O,transport:E,onNavigate:x,renderLink:w,readAction:Ve,fullText:Be,fullTextPending:co(O)&&!!E.getTextManifest&&X!==O.id,chapterLink:qe,railTop:v,railLinks:Ye}):O.type==="collection"?t.jsx(Kc,{data:O,catalog:(Z=Q[0])==null?void 0:Z.data,transport:E,onNavigate:x,renderLink:w,readAction:Ve,railTop:v,railLinks:Ye,catalogAction:Q.length>0?t.jsxs("a",{href:"#catalog",onClick:ye=>{ye.preventDefault(),a(`catalog:${Q[0].resource_id}`)},children:[A(L.detailTab.collectionCatalog)," →"]}):null}):t.jsx(qc,{data:O,transport:E,onNavigate:x,renderLink:w,railTop:v,railLinks:Ye}):null},ie=()=>{var ye,Ee,Pe;if(!q||!O)return null;if(s==="basic"||s==="emendated")return C();if(typeof s=="string"&&s.startsWith("catalog:")){const we=(ye=Q.find(ce=>`catalog:${ce.resource_id}`===s))==null?void 0:ye.data;return t.jsx(Ko,{data:we,onNavigate:x,renderLink:w})}if(s==="collated"||s==="fulltext")return t.jsx($r,{id:e,transport:E,chapter:Ie,onLocationChange:we=>B(we.chapter),onNavigate:x});if(s==="lineage"){if(!le)return t.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:I(H?"detail.loading":"detail.noLineageGraph")});const we=O.type==="work"?O:null;return t.jsx(Rr,{graph:le,renderLink:w,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:u??((Ee=we==null?void 0:we.version_graph)==null?void 0:Ee.default_collection),onCollectionChange:m,collectionsAvailable:(Pe=we==null?void 0:we.version_graph)==null?void 0:Pe.collections,collectionCounts:(()=>{var Me,jt,vt,Dt,Ut,Ge,J;if(!we)return;const ce={},be=((Me=ue.current)==null?void 0:Me.books)??[];ce.all=(((jt=we.books)==null?void 0:jt.length)??0)-(((Dt=(vt=we.version_graph)==null?void 0:vt.excluded_books)==null?void 0:Dt.length)??0);const Fe=(Ut=we.version_graph)==null?void 0:Ut.collections;if(Fe)for(const He of Object.keys(Fe))ce[He]=li(we,be,He).nodes.filter(Je=>Je.kind==="book"&&!Je.bridge).length;return ce.core==null&&((J=(Ge=we.version_graph)==null?void 0:Ge.core_books)!=null&&J.length)&&(ce.core=we.version_graph.core_books.length),ce})()})}if(s==="feedback"&&_)return t.jsx(Wc,{resourceId:e,apiUrl:z});const Z=$.find(we=>we.key===s);return Z?Z.render({detail:O,entry:q,transport:E,onNavigate:x}):null};if(Y)return t.jsx(En,{style:{minHeight:P,...R},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Z,ye)=>t.jsx("div",{style:{height:ye===1?40:16,width:Z,opacity:.35,background:i("rule")}},ye))})});if(ne||!O||!q||!ge)return t.jsx(En,{style:{minHeight:P,...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",ve=[{label:y??L.detailTab.backToIndex,onClick:k}];if(O.type==="book"&&O.work_id){const Z=O.work_id;ve.push({label:L.indexType.work,id:Z,onClick:()=>x==null?void 0:x(Z)})}ve.push({label:L.indexType[O.type]});const se=s==="collated"||s==="fulltext",he=typeof N=="string"?L.status[N.trim()]??N:N,Oe=t.jsx(ec,{left:t.jsxs(t.Fragment,{children:[he,he?" · ":"",t.jsx(Kb,{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}),te&&t.jsx("a",{href:te.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:D,children:t.jsxs(En,{grid:!0,style:{minHeight:P,...R},children:[t.jsx(wo,{breadcrumb:t.jsx(So,{items:ve}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Ao,{style:{border:"none",background:"transparent"}}),!T&&te&&t.jsx(Po,{...te})]})}),C(),Oe]})}):t.jsx("div",{className:D,children:t.jsxs(En,{wide:se,style:{minHeight:P,...R},children:[t.jsx(wo,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(sr,{char:"籍"}),t.jsx(So,{items:ve})]}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Ao,{}),_&&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&&te&&t.jsx(Po,{...te})]})}),t.jsx(Vl,{...ge,aside:se?t.jsxs("button",{type:"button",onClick:()=>a("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[I("detail.workInfo")," →"]}):ge.aside}),!se&&me.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:me.map(Z=>t.jsx(Gl,{label:Z.label,active:Z.key===s||re&&Z.key==="basic",onClick:()=>a(Z.key)},Z.key))}),t.jsx("div",{style:{marginTop:!se&&me.length>1?8:0},children:ie()}),Oe]})})};function Kb({id:e,label:n,copied:o,copyLabel:r}){const[s,a]=h.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 qb(e,n){return n?e.workSubtype[n]??n:""}const Wd=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Li="zhusha",Ai="bim-theme";function Od(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Pi(e){return Od(e)?e:Li}function Xb(){try{return Pi(window.localStorage.getItem(Ai))}catch{return Li}}function Fd(e){try{window.localStorage.setItem(Ai,e)}catch{}}function Hd(e){const n=Pi(e);return document.documentElement.setAttribute("data-theme",n),n}function Dd(){return Pi(document.documentElement.getAttribute("data-theme"))}const Zb=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Or="airy",Mi="bim-layout";function Ud(e){return e==="airy"||e==="boxed"}function Bi(e){return Ud(e)?e:Or}function Jb(){try{return Bi(window.localStorage.getItem(Mi))}catch{return Or}}function Qb(e){try{window.localStorage.setItem(Mi,e)}catch{}}function ey(e){const n=Bi(e);return document.documentElement.setAttribute("data-layout",n),n}function ty(){return Bi(document.documentElement.getAttribute("data-layout"))}const ny=`try{var t=localStorage.getItem(${JSON.stringify(Ai)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Mi)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,iy={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},oy=({onChange:e,style:n})=>{const{t:o}=ee(),[r,s]=h.useState(Li);h.useEffect(()=>{s(Dd())},[]);const a=l=>{s(Hd(l)),Fd(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Wd.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(iy[l.name]),boxShadow:d?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=Se.BidLink;exports.BookIndexError=Se.BookIndexError;exports.BookIndexManager=Se.BookIndexManager;exports.BookIndexStorage=Se.BookIndexStorage;exports.BundleStorage=Se.BundleStorage;exports.ConfigError=Se.ConfigError;exports.GithubStorage=Se.GithubStorage;exports.IdGenerationError=Se.IdGenerationError;exports.IdGenerator=Se.IdGenerator;exports.LocalStorage=Se.LocalStorage;exports.MigrationError=Se.MigrationError;exports.StorageError=Se.StorageError;exports.VARIANT_CHARS=Se.VARIANT_CHARS;exports.base36Decode=Se.base36Decode;exports.base36Encode=Se.base36Encode;exports.base58Decode=Se.base58Decode;exports.buildId=Se.buildId;exports.buildPromotionMap=Se.buildPromotionMap;exports.cleanName=Se.cleanName;exports.decodeId=Se.decodeId;exports.decodeIdString=Se.decodeIdString;exports.encodeId=Se.encodeId;exports.extractIdFromUrl=Se.extractIdFromUrl;exports.extractStatus=Se.extractStatus;exports.extractType=Se.extractType;exports.isChapterSegment=Se.isChapterSegment;exports.isTextKey=Se.isTextKey;exports.matchChapterAcrossVersions=Se.matchChapterAcrossVersions;exports.normalizeCatalog=Se.normalizeCatalog;exports.normalizeVariants=Se.normalizeVariants;exports.parseId=Se.parseId;exports.pickTextVersion=Se.pickTextVersion;exports.shardOf=Se.shardOf;exports.smartDecode=Se.smartDecode;exports.textVersionLabel=Se.textVersionLabel;exports.validateResource=Se.validateResource;exports.Badge=gi;exports.BidUrlProvider=mp;exports.BookDetailLayout=Yb;exports.BookPage=Yc;exports.Breadcrumb=So;exports.CATALOG_ALL_ID=It;exports.CATALOG_CSS=Xc;exports.CATALOG_NARROW_QUERY=Er;exports.CATALOG_PAGE_SIZE=Ir;exports.CATALOG_UNCLASSIFIED_ID=Xt;exports.CLASSIFICATIONS=vi;exports.COMMON_TRADITIONAL_CHARS=Ma;exports.CardFoot=Hn;exports.CatalogPage=$b;exports.CatalogPager=id;exports.CatalogTree=Jc;exports.CheckFilter=Hl;exports.Chip=Yl;exports.ChipWall=rg;exports.CollectionCatalog=Ko;exports.CollectionPage=Kc;exports.CreateEntityDialog=Rc;exports.DEFAULT_LAYOUT=Or;exports.DEFAULT_META_HOME_LINKS=vd;exports.DEFAULT_READER_PREFS=Zo;exports.DEFAULT_READ_HOME_LINKS=rd;exports.DEFAULT_THEME=Li;exports.DETAIL_CSS=Ul;exports.DYNASTY_GROUPS=ji;exports.Dash=pg;exports.DataTable=ag;exports.DetailFooter=ec;exports.DetailGrid=On;exports.DetailHeader=Vl;exports.EMPTY_FILTERS=yi;exports.ENTITY_TEXT_CSS=vr;exports.EmendatedBySection=al;exports.EmptyNote=bg;exports.EntityDetail=tl;exports.EntityMark=wr;exports.EntityPage=qc;exports.EntityPickerDialog=Ic;exports.EntitySelector=Nc;exports.EntityText=$h;exports.ExpandRow=ug;exports.ExtLink=yg;exports.FEEDBACK_FAB_OFFSET_VAR=Ro;exports.FILTER_SUPPORT=Ga;exports.FONT_SIZE_STEPS=Et;exports.FactList=tg;exports.FeedbackButton=mx;exports.FeedbackDialog=Mc;exports.FeedbackForm=Bc;exports.FeedbackList=Cr;exports.FeedbackTab=Wc;exports.FilterChip=Gl;exports.FormInput=gt;exports.FormTextArea=Jt;exports.GUJI_MARKDOWN_FIELD=rm;exports.GUJI_TABLE_NOTATION=ml;exports.GlyphBadge=sr;exports.GujiInteractiveReader=pf;exports.GujiTable=lr;exports.GujiTextViewer=Sr;exports.GujiWarpCanvas=yr;exports.HomePage=To;exports.ImagePanel=fo;exports.IndexApp=df;exports.IndexBrowser=go;exports.IndexDetail=Yo;exports.IndexEditor=Lc;exports.IndexView=Qf;exports.IntroGrid=eg;exports.LAYOUTS=Zb;exports.LAYOUT_STORAGE_KEY=Mi;exports.LOSS_OPTIONS=Va;exports.LocaleContext=en;exports.LocaleProvider=Op;exports.LocaleToggle=Ao;exports.META_HOME_CSS=jd;exports.META_HOME_SECTION_IDS=Bd;exports.MetaCatalogTable=Td;exports.MetaCollectionGroups=Id;exports.MetaDataLicense=Md;exports.MetaHomeView=Ob;exports.MetaLine=it;exports.MetaLineageCards=Ad;exports.MetaOnlineSites=Pd;exports.MetaPeopleTimeline=Ld;exports.MetaRecentPanel=Cd;exports.MetaRelatedCatalogs=Rd;exports.MetaTypeChips=Sd;exports.ModeIndicator=Fa;exports.MoreButton=og;exports.MoreLink=or;exports.PAGE_MAX_WIDTH=ri;exports.PERIOD_NARROW_SHARE=cd;exports.PageFrame=En;exports.Quote=gg;exports.READER_CSS=kl;exports.READ_HOME_CSS=Ar;exports.READ_HOME_NARROW_QUERY=Vn;exports.READ_HOME_SECTION_IDS=yd;exports.READ_PERIOD_LABELS=Nb;exports.RECENT_IDS_STORAGE_KEY=pn;exports.ROLE_CLASS_ORDER=Pl;exports.ReadButton=ko;exports.ReadFamousWorks=fd;exports.ReadHomeView=Eb;exports.ReadPeriodBand=xd;exports.ReadPicks=ud;exports.ReadPieces=bd;exports.ReadSection=ct;exports.ReadShelf=Mr;exports.ReadSibu=Br;exports.ReadStats=pd;exports.ReadTopicGroup=gd;exports.ReadTopics=hd;exports.ReaderMdText=ur;exports.ReaderShell=Nl;exports.ReaderToc=Sl;exports.RelationPanel=zc;exports.RepoSourceLink=Po;exports.ResourceEditor=uo;exports.ResourceGroup=hg;exports.ResourceLine=fg;exports.ResourceList=Do;exports.ResourceRow=Jl;exports.SEARCH_VIEW_STORAGE_KEY=Uo;exports.SEVEN_PAVILIONS_KEY=Ed;exports.SNIPPET_MARK_END=Ea;exports.SNIPPET_MARK_START=Ra;exports.SORTABLE_TYPES=Ua;exports.SearchInput=Da;exports.SearchResults=Ja;exports.Sec=ot;exports.Section=kt;exports.SectionHead=ng;exports.SideList=Zt;exports.SmartBidInput=ai;exports.SourceEditor=_c;exports.StripWarpRenderer=$o;exports.SummaryCard=Fn;exports.THEMES=Wd;exports.THEME_INIT_SCRIPT=ny;exports.THEME_STORAGE_KEY=Ai;exports.TRADITIONAL_ALLOWLIST=Ba;exports.TabFilter=Ci;exports.TableHead=lg;exports.TableRow=cg;exports.TagRow=Ql;exports.TagRows=xg;exports.TextButton=ig;exports.TextReader=$r;exports.ThemeToggle=oy;exports.TopStrip=wo;exports.VersionLineageGraph=Gc;exports.VersionLineageList=Vc;exports.VersionLineageView=Rr;exports.VolumeChips=sg;exports.VolumeLinks=ar;exports.WorkCard=td;exports.WorkCardGrid=od;exports.WorkCatalog=bf;exports.WorkPage=Dc;exports.WorkRow=nd;exports.adaptCharCord=xf;exports.adaptEntityJson=uc;exports.adaptGujiPages=mf;exports.adaptPunctJson=gf;exports.applyLayout=ey;exports.applyTheme=Hd;exports.authorsLine=Ii;exports.bookIndexUriToId=zo;exports.bucketResources=er;exports.buildCatalogTree=xb;exports.buildCollectionTable=Bl;exports.buildLineageGraph=li;exports.buildMeiliFilter=iu;exports.buildPageUrl=Ho;exports.buildParagraphBlocks=rc;exports.buildVersionRow=Ll;exports.buildVersionTable=Al;exports.canParagraphize=ui;exports.catalogNodeIdOf=hb;exports.catalogNodeIdsOf=fb;exports.catalogPageCount=vb;exports.catalogTotal=Lr;exports.classificationPath=Un;exports.clearAllRecentIds=Vo;exports.compareCatalogCards=jb;exports.computeVersionPartition=Hm;exports.countActiveFilters=ki;exports.createTextApi=xl;exports.currentLayout=ty;exports.currentTheme=Dd;exports.defaultEntityHref=bc;exports.defaultWorkLink=Qc;exports.deriveDating=Wm;exports.deriveEditionType=Ol;exports.deriveEra=Wn;exports.deriveYear=Si;exports.deriveYearRange=Qo;exports.detailToEditor=Pc;exports.detectGenre=Ti;exports.displayAuthorRole=nr;exports.editorToDetail=Jf;exports.eraRank=jo;exports.filtersFromParams=ou;exports.filtersToParams=ci;exports.findCatalogPath=dn;exports.findTraditionalChars=Dp;exports.firstAuthorText=Pr;exports.flattenTitles=_o;exports.flattenToc=Tl;exports.fmtCount=Ke;exports.formatHitCount=oi;exports.formatTemplate=ht;exports.formatVolumeRange=$i;exports.getDisplayNameFromUrl=xn;exports.getMessages=hn;exports.getStartPage=Fo;exports.getT=fn;exports.getTypeGroupKey=Wo;exports.groupRelatedWorks=Om;exports.gujiInlineToPlain=ul;exports.hasActiveFilters=Ya;exports.hasGujiMarkdownV02=ho;exports.hasGujiTableNotation=gl;exports.hasSearchOptions=eu;exports.iiifVolumeOf=hf;exports.isCountedChar=jr;exports.isLayoutName=Ud;exports.isThemeName=Od;exports.lineageHref=kd;exports.loadRecentIds=Ot;exports.measureText=Pt;exports.mergeVolumeResources=Oo;exports.normalizeEra=nt;exports.normalizeLayout=Bi;exports.normalizeRole=tr;exports.normalizeTheme=Pi;exports.normalizeVolumeIndex=An;exports.normalizeVolumes=Oa;exports.numberToChinese=Wl;exports.paginationItems=Zc;exports.parseChineseNumber=di;exports.parseGujiInline=pl;exports.parseGujiTable=fl;exports.parseSourceString=$c;exports.pct=Wr;exports.periodLevel=ld;exports.pickReaderVersion=zl;exports.readStoredLayout=Jb;exports.readStoredTheme=Xb;exports.readerVersionOptionLabel=bo;exports.remapPlainOffsets=mc;exports.removeRecentId=Qa;exports.renderFullTextBody=_g;exports.renderProperNames=ac;exports.renderReaderInline=pr;exports.resolveRecentEntry=Go;exports.resourceHref=bn;exports.resourceNote=_i;exports.resultTabFromParam=gu;exports.resultTabToParam=hu;exports.roleFacets=Ml;exports.rowNo=dg;exports.sameFilters=ru;exports.saveRecentId=mo;exports.segmentEntities=gc;exports.shelfColumns=sd;exports.sortFor=tu;exports.sortYear=pi;exports.spineHeight=ad;exports.splitFullTextTables=qo;exports.splitHighlightSnippet=Mo;exports.splitTableRow=hl;exports.storeLayout=Qb;exports.storeTheme=Fd;exports.stringifySources=Cc;exports.summaryFromEntry=fc;exports.summaryFromItem=hc;exports.timelineLayout=wd;exports.toCatalogWorkCard=yb;exports.transportSummaryLoader=xc;exports.typeSupportsFilters=Ka;exports.useBidUrl=tt;exports.useChapterWarpData=vc;exports.useConvert=Ae;exports.useEntitySummaryLoader=kr;exports.useI18n=ee;exports.useReaderPrefs=Cl;exports.useRecentEntries=_d;exports.useT=Ce;exports.validateLineageGraph=Px;exports.volumeStats=xi;exports.withDefaultLinks=Ft;exports.withMetaLinks=Ht;exports.yearText=hi;
|
|
1902
|
+
`,vd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function Ht(e){return{...vd,...e??{}}}function kd(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 Wr(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function wd(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=fn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function Ab(e){return{read:e.item,work:e.item,node:e.node}}function Sd({counts:e,links:n}){const{t:o}=Q(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),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:Xe(d)})]})},a))})}function _d(e,n=5){const[o,r]=h.useState(null);h.useEffect(()=>{let a=!1;const l=Ot().slice(0,n);if(!l.length||!e){r([]);return}return Promise.all(l.map(d=>Go(e,d))).then(d=>{a||r(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=h.useCallback(()=>{Vo(),r([])},[]);return{entries:o,clear:s}}function Pb(e,n,o){const r=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return r?o(r):$d(e.type,n)}function $d(e,n){return n(`metaHome.typeLabel.${e}`)}function Cd({entries:e,onClear:n,links:o}){const{t:r,convert:s}=Q(),a=Ht(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?$d(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:Pb(l,r,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function zd(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 Td({rows:e,links:n}){const{t:o,convert:r}=Q(),s=Ht(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=Wr(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:Xe(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Xe(a.imported)}),t.jsx("td",{children:t.jsxs("span",{className:"bim-mh-meter",children:[t.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[l,"%"]})]})}),t.jsx("td",{children:a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:zd(a.status,o,r)})})]},a.id||a.name)})})]})}):null}function Nd({items:e,links:n,label:o}){const{convert:r}=Q();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 Rd({works:e,links:n}){const{t:o}=Q(),[r,s]=h.useState(!1);if(!e.length)return null;const a=Bn(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(Nd,{items:e.map(l=>({id:l.id,title:l.title,sub:Ii(l)||void 0})),links:Ht(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 Ed="siku_qige";function Mb({group:e,links:n}){const{t:o,convert:r}=Q(),[s,a]=h.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":Bn(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(Nd,{items:e.items,links:n,label:e.label}),Bn(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 Id({groups:e,links:n}){const{t:o,convert:r}=Q(),s=Ht(n);if(!e.length)return null;const a=e.find(c=>c.key===Ed),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(Mb,{group:c,links:s},c.key))})]})}const $a=34,Ca=13;function za(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 Bb(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 Ld({people:e,links:n}){const{t:o,convert:r}=Q(),s=Ht(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=wd(e),p=[],u=d.map(g=>{const f=g.left>70,x=f?Math.min(g.left,g.left+g.width-Ca):g.left;let k=0;for(;p[k]!=null&&p[k]>x;)k++;return p[k]=f?g.left+g.width:g.left+Math.max(g.width,Ca),{...g,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*$a+10},children:u.map(g=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":g.end?"":void 0,style:{left:`${g.left}%`,top:g.lane*$a+4,width:`${Math.max(g.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(g.p.id),children:[r(g.p.name),t.jsx("small",{className:"bim-rh-num",children:za(g.p,o)})]})]},g.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Bb(a,l).map(g=>t.jsx("span",{style:{left:`${(g-a)/m*100}%`},children:hi(g,o)},g))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?e:c).map(g=>t.jsx("li",{children:t.jsxs("a",{href:s.item(g.id),children:[t.jsx("span",{children:r(g.name)}),t.jsx("small",{className:"bim-rh-num",children:[g.dynasty?r(g.dynasty):"",za(g,o)].filter(Boolean).join(" ")})]})},g.id))}),c.length>0&&u.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(g=>g.name).join("、"))})})]})}const Wb=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 Ad({works:e,links:n}){const{t:o,convert:r}=Q(),s=Ht(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=Ii(a);return t.jsx("li",{children:t.jsxs("a",{href:kd(s,a.id),children:[Wb,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 Pd({sites:e}){const{t:n,convert:o}=Q(),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=Wr(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:[`${Xe(a.imported)} / ${Xe(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:zd(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 Ta=["extant","partially_extant","lost","unknown"];function Md({stats:e,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:a}=Q(),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=Ta.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:Xe(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:Ta.map(p=>{var g;const u=((g=e.loss)==null?void 0:g[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:Xe(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 Bd={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function Ob({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}=Q(),g=e,f=Ht(n),x=Ab(f),k=Bd,y=_d(r),w={zhi:!!((v=g.shelf)!=null&&v.items.length)||g.catalog_progress.length>0||g.related_catalogs.length>0,sibu:g.bu.length>0||g.unclassified>0,cong:g.collection_groups.length>0,people:g.bibliographers.length>0,lineage:g.lineage.length>0,sites:g.sites.length>0,data:!0},b=Object.keys(k).filter(_=>w[_]),j=_=>m(`metaHome.nav.${_}`),S=(_,z)=>_?t.jsx("a",{className:"bim-rh-more",href:_,children:z}):void 0;return t.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[t.jsx("style",{children:Ar+jd}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[o,t.jsx(Sd,{counts:g.counts,links:n})]}),r&&t.jsx(Cd,{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(ct,{id:k.zhi,title:j("zhi"),sub:m("metaHome.zhiSub"),children:[g.shelf&&g.shelf.items.length>0&&t.jsx(Mr,{topic:{key:"shelf",label:g.shelf.label,shelf:!0,items:g.shelf.items},links:x,showTitle:!1,legendCount:g.shelf.items.some(_=>_.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(g.catalog_progress.length>0||g.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=g.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(Td,{rows:g.catalog_progress,links:n}),t.jsx(Rd,{works:g.related_catalogs,links:n})]})]}),w.sibu&&t.jsx(ct,{id:k.sibu,title:j("sibu"),sub:m("metaHome.sibuSub"),more:S(s,m("metaHome.toCatalog")),children:t.jsx(Br,{bu:g.bu,unclassified:g.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),w.cong&&t.jsx(ct,{id:k.cong,title:j("cong"),sub:m("metaHome.congSub"),more:S(a,m("metaHome.allNKindsMore",{n:Xe(g.counts.collections)})),children:t.jsx(Id,{groups:g.collection_groups,links:n})}),w.people&&t.jsx(ct,{id:k.people,title:j("people"),sub:m("metaHome.peopleSub"),more:S(l,m("metaHome.allNPeopleMore",{n:Xe(g.counts.entities)})),children:t.jsx(Ld,{people:g.bibliographers,links:n})}),w.lineage&&t.jsx(ct,{id:k.lineage,title:j("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(Ad,{works:g.lineage,links:n})}),w.sites&&t.jsx(ct,{id:k.sites,title:j("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(Pd,{sites:g.sites})}),t.jsx(ct,{id:k.data,title:j("data"),sub:m("metaHome.dataSub"),children:t.jsx(Md,{stats:g.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const Ct=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),rt=e=>Array.isArray(e),Fb=e=>Ct(e)&&!!e.h;function Hb(e){if(!e)return!1;for(const n of["_related","_catalogs","_collections","_works","_members","_children"]){const o=e[n];if(rt(o)&&o.some(Fb))return!0}return!1}function ii(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 Db(e){const n=e.filter(Ct);return n.find(o=>o.scheme==="zongmu")??n[0]??null}const Ub=e=>typeof e=="number"?e:rt(e)&&typeof e[0]=="number"?e[0]:void 0;function Lo(e,n){if(!Ct(e))return e;const o={...e},r=e.type;if(r==="work"){if(!rt(e.books)&&rt(e._books)&&(o.books=e._books.filter(Ct).map(s=>s.id).filter(s=>typeof s=="string")),!Ct(e.classification)&&rt(e._classifications)){const s=Db(e._classifications);s&&(o.classification={l1:s.l1??"",l2:s.l2??"",l3:s.l3??"",l4:s.l4??"",...s.source?{source:s.source}:{}})}rt(e._related)&&(o.related_works=e._related.filter(Ct).map(s=>{const a=s;return{id:a.id,title:ii(a,n),...a.relation?{relation:a.relation}:{},...a.note?{note:a.note}:{}}})),!rt(e.indexed_by)&&rt(e._catalogs)&&e._catalogs.length&&(o.indexed_by=e._catalogs.filter(Ct).map(s=>{const a=s;return{source:ii(a,n)||String(a.bid??""),...a.bid?{source_bid:a.bid}:{},...a.section?{section:a.section}:{}}}))}if((r==="work"||r==="book")&&!rt(e.contained_in)&&rt(e._collections)&&e._collections.length&&(o.contained_in=e._collections.filter(Ct).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"&&rt(e._members)){const s=e._members.filter(Ct),a=typeof e._member_count=="number"?e._member_count:s.length,l=d=>d.t==="work";if(!rt(e.books)){const d=s.filter(c=>!l(c)).map(c=>c.id).filter(c=>typeof c=="string");d.length&&(o.books=d)}if(!rt(e.contained_works)){const d=s.filter(l).map(c=>{const p=Ub(c.vol);return{id:c.id,title:ii(c,n),...p!=null?{volume_index:p}:{}}});d.length&&(o.contained_works=d)}a>s.length&&(o._members_truncated=!0)}return r==="entity"&&!rt(e.works)&&rt(e._works)&&(o.works=e._works.filter(Ct).map(s=>{const a=s,l=ii({...a,id:a.work_id},n);return{...a,work_id:a.work_id,...l?{title:l}:{}}})),o}function Vb(e){let n=null;const o=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null),r=async s=>s&&Lo(s,Hb(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 Ao=({style:e})=>{const n=h.useContext(en),{t:o}=Q();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")})]})},Po=({href:e,label:n,size:o=16,className:r,style:s})=>{const{t:a}=Q(),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 co(e){const n=e.text_count;return typeof n=="number"&&n>0}function po(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function Gb(e,n){if(!n)return!1;const o=n.id;return o===void 0||o===e}const Yb=({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:g=1,selectedLineageNodeId:f,onNavigate:x,onBack:k,backLabel:y,renderLink:w,enrichDetail:b,getSourceLink:j,readLink:S,railTop:v,extraTabs:$=[],showFeedbackTab:_=!0,feedbackApiUrl:z,height:P,footerExtra:N,hideHeaderControls:T=!1,className:D,style:R})=>{const E=h.useMemo(()=>Vb(n),[n]),L=Ce(),{t:I,convert:A}=Q(),[V]=h.useState(()=>{if(!Gb(e,o))return null;const Z=Lo({...o}),ye=r??po(e,Z);return b&&b(ye,Z),{id:e,entry:ye,detail:Z}}),[q,O]=h.useState((V==null?void 0:V.entry)??null),[W,K]=h.useState((V==null?void 0:V.detail)??null),[Y,F]=h.useState(!V),[te,je]=h.useState(!1),[oe,ie]=h.useState([]),[Be,we]=h.useState(!1),[Oe,Te]=h.useState(null),[X,le]=h.useState(null),[de,ve]=h.useState(null),[H,me]=h.useState(!1),ue=h.useRef(null),$e=h.useRef(0),[G,ze]=h.useState(null),Le=l!==void 0?l:G,B=h.useCallback(Z=>{d?d(Z):ze(Z)},[d]),re=h.useCallback(async Z=>{if(!E.getCollectionCatalogs&&!E.getCollectionCatalog){ie([]);return}we(!0);try{if(E.getCollectionCatalogs)ie(await E.getCollectionCatalogs(Z)||[]);else if(E.getCollectionCatalog){const ye=await E.getCollectionCatalog(Z);ie(ye?[{resource_id:"",data:ye}]:[])}}catch{ie([])}finally{we(!1)}},[E]),he=h.useCallback(async Z=>{var ye,Ie;if(!E.getTextManifest||!E.getTextIndex){Te(null),le(Z);return}try{const Me=_e.pickTextVersion(await E.getTextManifest(Z)),Se=Me?await E.getTextIndex(Z,Me.key):null;Te(Se&&Se.chapters.length>0?{chapters:Se.chapters.map(ce=>({n:ce.n,title:ce.title,file:ce.file})),source:{name:((ye=Se.source)==null?void 0:ye.name)??(Me==null?void 0:Me.source_name),license:((Ie=Se.source)==null?void 0:Ie.license)??(Me==null?void 0:Me.license)??void 0}}:null)}catch{Te(null)}finally{le(Z)}},[E]),Ne=h.useCallback(async(Z,ye)=>{const Ie=++$e.current,Me=()=>Ie!==$e.current;me(!0);try{if(E.getLineageGraph){const vt=await E.getLineageGraph(Z);if(Me())return;vt&&ve(vt)}const Se=ye.version_graph;if(!Se||!Se.enabled){de||ve(null),ue.current=null;return}const ce=ye.books??[],De=(await Ri(ce,Ni,async vt=>{try{return await E.getItem(vt)}catch{return null}},Me)).filter(Boolean);if(Me())return;ue.current={work:ye,books:De};const We=u??Se.default_collection??(Se.core_books&&Se.core_books.length>0?"core":"all"),jt=We==="core"&&Array.isArray(Se.core_books)&&Se.core_books.length>0?"core":We??"all";ve(li(ye,De,jt))}catch{if(Me())return;ve(null),ue.current=null}finally{Me()||me(!1)}},[E]),Re=h.useRef({initialDetail:o,initialEntry:r});Re.current={initialDetail:o,initialEntry:r},h.useEffect(()=>{let Z=!1;$e.current++,me(!1);const ye=ce=>{ce.type==="collection"?re(e):ce.type==="work"?(ce.version_graph||E.getLineageGraph)&&Ne(e,ce):ce.type==="book"&&co(ce)&&he(e)},Ie=Re.current;let Me=null;if(V&&V.id===e)Me=V;else if(Ie.initialDetail&&Ie.initialDetail.id===e){const ce=Lo({...Ie.initialDetail}),xe=Ie.initialEntry??po(e,ce);b&&b(xe,ce),Me={entry:xe,detail:ce}}return Me?(je(!1),ie(ce=>ce.length?[]:ce),Te(null),ve(null),ue.current=null,O(Me.entry),K(Me.detail),F(!1),ye(Me.detail),()=>{Z=!0}):((async()=>{F(!0),je(!1),O(null),K(null),ie([]),Te(null),ve(null),ue.current=null;try{const ce=await E.getItem(e);if(Z)return;if(!ce){je(!0);return}const xe=ce;let De=null;if(E.getEntry&&(De=await E.getEntry(e),Z))return;De||(De=po(e,xe)),b&&b(De,xe),O(De),K(xe),ye(xe)}catch{Z||je(!0)}finally{Z||F(!1)}})(),()=>{Z=!0})},[e,E,V,b,re,Ne,he]),h.useEffect(()=>{const Z=ue.current;!Z||!u||ve(li(Z.work,Z.books,u))},[u]);const U=[];if(W){if(U.push({key:"basic",label:L.detailTab.basicInfo}),W.type==="collection"){Be&&oe.length===0&&U.push({key:"catalog:loading",label:`${L.detailTab.catalog}…`});for(const Z of oe)U.push({key:`catalog:${Z.resource_id}`,label:Z.short_name?`${A(Z.short_name)}${L.detailTab.catalogSuffix}`:L.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&U.push({key:s,label:L.detailTab.fullText}),W.type==="work"&&(de||H)&&U.push({key:"lineage",label:H?`${L.detailTab.lineage}…`:L.detailTab.lineage});for(const Z of $)(Z.position??"before-feedback")==="before-feedback"&&Z.shouldShow(W)&&U.push({key:Z.key,label:Z.label});_&&s==="feedback"&&U.push({key:"feedback",label:L.detailTab.feedback});for(const Z of $)Z.position==="after-feedback"&&Z.shouldShow(W)&&U.push({key:Z.key,label:Z.label})}h.useEffect(()=>{if(s!=="emendated"||!W)return;a("basic");const Z=setTimeout(()=>{var ye;(ye=document.getElementById("studies"))==null||ye.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Z)},[s,W,a]);const be=q&&W&&j?j({activeTab:s,activeJuan:Le,entry:q,detail:W}):null,ee=h.useMemo(()=>{var Se;if(!W)return null;const ye=(W.authors??[]).map(ce=>{const xe=nr(ce.role);return`${ce.dynasty?`〔${A(ce.dynasty)}〕`:""}${A(ce.name)}${xe?` ${A(xe)}`:""}`}).join(" · ");let Ie=!1;try{Ie=_e.extractStatus(W.id)==="draft"}catch{}if(W.type==="book"){const ce=W;return{title:A(ce.title),subtitle:ce.edition?A(ce.edition):ye||void 0,aside:[Ie?L.status.draft:"",ye&&ce.edition?ye:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(W.type==="collection"){const ce=W;return{title:A(ce.title),subtitle:A(Pt(ce,L.unit.juan))||void 0,aside:[(Se=ce.publication_info)==null?void 0:Se.year,Ie?L.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ye||void 0}}if(W.type==="entity"){const ce=W,xe=We=>We==null?"":We<0?I("detail.bce",{n:-We}):String(We),De=ce.birth_year!=null||ce.death_year!=null?`${xe(ce.birth_year)||"?"}—${xe(ce.death_year)||"?"}`:"";return{title:A(ce.primary_name||ce.title),subtitle:[ce.dynasty?`〔${A(ce.dynasty)}〕`:"",De].filter(Boolean).join(" ")||void 0,aside:Ie?L.status.draft:void 0,secondLine:void 0}}const Me=A(Pt(W,L.unit.juan));return{title:A(W.title),subtitle:[Me,ye].filter(Boolean).join(" · ")||void 0,aside:[qb(L,W.subtype),Ie?L.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[W,A,L,I]),fe=W&&co(W)?"text":null,Ee=()=>{B(null),a("fulltext")};let Fe=null;if(W&&S){const Z=S({detail:W,kind:fe});Z&&(Fe=t.jsx(ko,{href:Z}))}else fe&&(Fe=t.jsx(ko,{onClick:Ee}));const Ye=Z=>{if(!W)return null;const ye=Z.replace(/\.[^.]+$/,"");if(S){const Ie=S({detail:W,kind:fe,juan:ye});return Ie?{href:Ie}:null}return{onClick:()=>{B(ye),a("fulltext")}}},Ke=new Set($.map(Z=>Z.key)),qe=U.filter(Z=>Z.key.startsWith("catalog:")&&Z.key!=="catalog:loading"||Z.key==="lineage"&&!!de&&!H||Ke.has(Z.key)).map(Z=>({key:Z.key,label:Z.label,onClick:()=>a(Z.key)})),C=()=>{var Z;return W?W.type==="work"?t.jsx(Dc,{data:W,transport:E,onNavigate:x,renderLink:w,readAction:Fe,railTop:v,railLinks:qe}):W.type==="book"?t.jsx(Yc,{data:W,transport:E,onNavigate:x,renderLink:w,readAction:Fe,fullText:Oe,fullTextPending:co(W)&&!!E.getTextManifest&&X!==W.id,chapterLink:Ye,railTop:v,railLinks:qe}):W.type==="collection"?t.jsx(Kc,{data:W,catalog:(Z=oe[0])==null?void 0:Z.data,transport:E,onNavigate:x,renderLink:w,readAction:Fe,railTop:v,railLinks:qe,catalogAction:oe.length>0?t.jsxs("a",{href:"#catalog",onClick:ye=>{ye.preventDefault(),a(`catalog:${oe[0].resource_id}`)},children:[A(L.detailTab.collectionCatalog)," →"]}):null}):t.jsx(qc,{data:W,transport:E,onNavigate:x,renderLink:w,railTop:v,railLinks:qe}):null},ne=()=>{var ye,Ie,Me;if(!q||!W)return null;if(s==="basic"||s==="emendated")return C();if(typeof s=="string"&&s.startsWith("catalog:")){const Se=(ye=oe.find(ce=>`catalog:${ce.resource_id}`===s))==null?void 0:ye.data;return t.jsx(Ko,{data:Se,onNavigate:x,renderLink:w})}if(s==="collated"||s==="fulltext")return t.jsx($r,{id:e,transport:E,chapter:Le,onLocationChange:Se=>B(Se.chapter),onNavigate:x});if(s==="lineage"){if(!de)return t.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:I(H?"detail.loading":"detail.noLineageGraph")});const Se=W.type==="work"?W:null;return t.jsx(Rr,{graph:de,renderLink:w,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:u??((Ie=Se==null?void 0:Se.version_graph)==null?void 0:Ie.default_collection),onCollectionChange:m,collectionsAvailable:(Me=Se==null?void 0:Se.version_graph)==null?void 0:Me.collections,collectionCounts:(()=>{var We,jt,vt,Dt,Ut,Ge,J;if(!Se)return;const ce={},xe=((We=ue.current)==null?void 0:We.books)??[];ce.all=(((jt=Se.books)==null?void 0:jt.length)??0)-(((Dt=(vt=Se.version_graph)==null?void 0:vt.excluded_books)==null?void 0:Dt.length)??0);const De=(Ut=Se.version_graph)==null?void 0:Ut.collections;if(De)for(const Ue of Object.keys(De))ce[Ue]=li(Se,xe,Ue).nodes.filter(Je=>Je.kind==="book"&&!Je.bridge).length;return ce.core==null&&((J=(Ge=Se.version_graph)==null?void 0:Ge.core_books)!=null&&J.length)&&(ce.core=Se.version_graph.core_books.length),ce})()})}if(s==="feedback"&&_)return t.jsx(Wc,{resourceId:e,apiUrl:z});const Z=$.find(Se=>Se.key===s);return Z?Z.render({detail:W,entry:q,transport:E,onNavigate:x}):null};if(Y)return t.jsx(En,{style:{minHeight:P,...R},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Z,ye)=>t.jsx("div",{style:{height:ye===1?40:16,width:Z,opacity:.35,background:i("rule")}},ye))})});if(te||!W||!q||!ee)return t.jsx(En,{style:{minHeight:P,...R},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:I("detail.notFound")})});const se=s==="basic"||s==="emendated",ke=[{label:y??L.detailTab.backToIndex,onClick:k}];if(W.type==="book"&&W.work_id){const Z=W.work_id;ke.push({label:L.indexType.work,id:Z,onClick:()=>x==null?void 0:x(Z)})}ke.push({label:L.indexType[W.type]});const ae=s==="collated"||s==="fulltext",ge=typeof N=="string"?L.status[N.trim()]??N:N,He=t.jsx(ec,{left:t.jsxs(t.Fragment,{children:[ge,ge?" · ":"",t.jsx(Kb,{id:W.id,label:L.label.id,copied:L.action.copied,copyLabel:L.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!se&&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}),be&&t.jsx("a",{href:be.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:L.detailTab.dataLicense})]})});return se?t.jsx("div",{className:D,children:t.jsxs(En,{grid:!0,style:{minHeight:P,...R},children:[t.jsx(wo,{breadcrumb:t.jsx(So,{items:ke}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Ao,{style:{border:"none",background:"transparent"}}),!T&&be&&t.jsx(Po,{...be})]})}),C(),He]})}):t.jsx("div",{className:D,children:t.jsxs(En,{wide:ae,style:{minHeight:P,...R},children:[t.jsx(wo,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(sr,{char:"籍"}),t.jsx(So,{items:ke})]}),actions:t.jsxs(t.Fragment,{children:[!T&&t.jsx(Ao,{}),_&&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&&be&&t.jsx(Po,{...be})]})}),t.jsx(Vl,{...ee,aside:ae?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")," →"]}):ee.aside}),!ae&&U.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:U.map(Z=>t.jsx(Gl,{label:Z.label,active:Z.key===s||se&&Z.key==="basic",onClick:()=>a(Z.key)},Z.key))}),t.jsx("div",{style:{marginTop:!ae&&U.length>1?8:0},children:ne()}),He]})})};function Kb({id:e,label:n,copied:o,copyLabel:r}){const[s,a]=h.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 qb(e,n){return n?e.workSubtype[n]??n:""}const Wd=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Li="zhusha",Ai="bim-theme";function Od(e){return e==="zhusha"||e==="indigo"||e==="ink"}function Pi(e){return Od(e)?e:Li}function Xb(){try{return Pi(window.localStorage.getItem(Ai))}catch{return Li}}function Fd(e){try{window.localStorage.setItem(Ai,e)}catch{}}function Hd(e){const n=Pi(e);return document.documentElement.setAttribute("data-theme",n),n}function Dd(){return Pi(document.documentElement.getAttribute("data-theme"))}const Zb=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Or="airy",Mi="bim-layout";function Ud(e){return e==="airy"||e==="boxed"}function Bi(e){return Ud(e)?e:Or}function Jb(){try{return Bi(window.localStorage.getItem(Mi))}catch{return Or}}function Qb(e){try{window.localStorage.setItem(Mi,e)}catch{}}function ey(e){const n=Bi(e);return document.documentElement.setAttribute("data-layout",n),n}function ty(){return Bi(document.documentElement.getAttribute("data-layout"))}const ny=`try{var t=localStorage.getItem(${JSON.stringify(Ai)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Mi)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,iy={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},oy=({onChange:e,style:n})=>{const{t:o}=Q(),[r,s]=h.useState(Li);h.useEffect(()=>{s(Dd())},[]);const a=l=>{s(Hd(l)),Fd(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:Wd.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(iy[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=gi;exports.BidUrlProvider=mp;exports.BookDetailLayout=Yb;exports.BookPage=Yc;exports.Breadcrumb=So;exports.CATALOG_ALL_ID=It;exports.CATALOG_CSS=Xc;exports.CATALOG_NARROW_QUERY=Er;exports.CATALOG_PAGE_SIZE=Ir;exports.CATALOG_UNCLASSIFIED_ID=Xt;exports.CLASSIFICATIONS=vi;exports.COMMON_TRADITIONAL_CHARS=Ma;exports.CardFoot=Hn;exports.CatalogPage=$b;exports.CatalogPager=id;exports.CatalogTree=Jc;exports.CheckFilter=Hl;exports.Chip=Yl;exports.ChipWall=rg;exports.CollectionCatalog=Ko;exports.CollectionPage=Kc;exports.CreateEntityDialog=Rc;exports.DEFAULT_LAYOUT=Or;exports.DEFAULT_META_HOME_LINKS=vd;exports.DEFAULT_READER_PREFS=Zo;exports.DEFAULT_READ_HOME_LINKS=rd;exports.DEFAULT_THEME=Li;exports.DETAIL_CSS=Ul;exports.DYNASTY_GROUPS=ji;exports.Dash=pg;exports.DataTable=ag;exports.DetailFooter=ec;exports.DetailGrid=On;exports.DetailHeader=Vl;exports.EMPTY_FILTERS=yi;exports.ENTITY_TEXT_CSS=vr;exports.EmendatedBySection=al;exports.EmptyNote=bg;exports.EntityDetail=tl;exports.EntityMark=wr;exports.EntityPage=qc;exports.EntityPickerDialog=Ic;exports.EntitySelector=Nc;exports.EntityText=$h;exports.ExpandRow=ug;exports.ExtLink=yg;exports.FEEDBACK_FAB_OFFSET_VAR=Ro;exports.FILTER_SUPPORT=Ga;exports.FONT_SIZE_STEPS=Et;exports.FactList=tg;exports.FeedbackButton=mx;exports.FeedbackDialog=Mc;exports.FeedbackForm=Bc;exports.FeedbackList=Cr;exports.FeedbackTab=Wc;exports.FilterChip=Gl;exports.FormInput=gt;exports.FormTextArea=Jt;exports.GUJI_MARKDOWN_FIELD=rm;exports.GUJI_TABLE_NOTATION=ml;exports.GlyphBadge=sr;exports.GujiInteractiveReader=pf;exports.GujiTable=lr;exports.GujiTextViewer=Sr;exports.GujiWarpCanvas=yr;exports.HomePage=To;exports.ImagePanel=fo;exports.IndexApp=df;exports.IndexBrowser=go;exports.IndexDetail=Yo;exports.IndexEditor=Lc;exports.IndexView=Qf;exports.IntroGrid=eg;exports.LAYOUTS=Zb;exports.LAYOUT_STORAGE_KEY=Mi;exports.LOSS_OPTIONS=Va;exports.LocaleContext=en;exports.LocaleProvider=Op;exports.LocaleToggle=Ao;exports.META_HOME_CSS=jd;exports.META_HOME_SECTION_IDS=Bd;exports.MetaCatalogTable=Td;exports.MetaCollectionGroups=Id;exports.MetaDataLicense=Md;exports.MetaHomeView=Ob;exports.MetaLine=it;exports.MetaLineageCards=Ad;exports.MetaOnlineSites=Pd;exports.MetaPeopleTimeline=Ld;exports.MetaRecentPanel=Cd;exports.MetaRelatedCatalogs=Rd;exports.MetaTypeChips=Sd;exports.ModeIndicator=Fa;exports.MoreButton=og;exports.MoreLink=or;exports.PAGE_MAX_WIDTH=ri;exports.PERIOD_NARROW_SHARE=cd;exports.PageFrame=En;exports.Quote=gg;exports.READER_CSS=kl;exports.READ_HOME_CSS=Ar;exports.READ_HOME_NARROW_QUERY=Vn;exports.READ_HOME_SECTION_IDS=yd;exports.READ_PERIOD_LABELS=Nb;exports.RECENT_IDS_STORAGE_KEY=pn;exports.ROLE_CLASS_ORDER=Pl;exports.ReadButton=ko;exports.ReadFamousWorks=fd;exports.ReadHomeView=Eb;exports.ReadPeriodBand=xd;exports.ReadPicks=ud;exports.ReadPieces=bd;exports.ReadSection=ct;exports.ReadShelf=Mr;exports.ReadSibu=Br;exports.ReadStats=pd;exports.ReadTopicGroup=gd;exports.ReadTopics=hd;exports.ReaderMdText=ur;exports.ReaderShell=Nl;exports.ReaderToc=Sl;exports.RelationPanel=zc;exports.RepoSourceLink=Po;exports.ResourceEditor=uo;exports.ResourceGroup=hg;exports.ResourceLine=fg;exports.ResourceList=Do;exports.ResourceRow=Jl;exports.SEARCH_VIEW_STORAGE_KEY=Uo;exports.SEVEN_PAVILIONS_KEY=Ed;exports.SNIPPET_MARK_END=Ea;exports.SNIPPET_MARK_START=Ra;exports.SORTABLE_TYPES=Ua;exports.SearchInput=Da;exports.SearchResults=Ja;exports.Sec=ot;exports.Section=kt;exports.SectionHead=ng;exports.SideList=Zt;exports.SmartBidInput=ai;exports.SourceEditor=_c;exports.StripWarpRenderer=$o;exports.SummaryCard=Fn;exports.THEMES=Wd;exports.THEME_INIT_SCRIPT=ny;exports.THEME_STORAGE_KEY=Ai;exports.TRADITIONAL_ALLOWLIST=Ba;exports.TabFilter=Ci;exports.TableHead=lg;exports.TableRow=cg;exports.TagRow=Ql;exports.TagRows=xg;exports.TextButton=ig;exports.TextReader=$r;exports.ThemeToggle=oy;exports.TopStrip=wo;exports.VersionLineageGraph=Gc;exports.VersionLineageList=Vc;exports.VersionLineageView=Rr;exports.VolumeChips=sg;exports.VolumeLinks=ar;exports.WorkCard=td;exports.WorkCardGrid=od;exports.WorkCatalog=bf;exports.WorkPage=Dc;exports.WorkRow=nd;exports.adaptCharCord=xf;exports.adaptEntityJson=uc;exports.adaptGujiPages=mf;exports.adaptPunctJson=gf;exports.applyLayout=ey;exports.applyTheme=Hd;exports.authorsLine=Ii;exports.bookIndexUriToId=zo;exports.bucketResources=er;exports.buildCatalogTree=xb;exports.buildCollectionTable=Bl;exports.buildLineageGraph=li;exports.buildMeiliFilter=iu;exports.buildPageUrl=Ho;exports.buildParagraphBlocks=rc;exports.buildVersionRow=Ll;exports.buildVersionTable=Al;exports.canParagraphize=ui;exports.catalogNodeIdOf=hb;exports.catalogNodeIdsOf=fb;exports.catalogPageCount=vb;exports.catalogTotal=Lr;exports.classificationPath=Un;exports.clearAllRecentIds=Vo;exports.compareCatalogCards=jb;exports.computeVersionPartition=Hm;exports.countActiveFilters=ki;exports.createTextApi=xl;exports.currentLayout=ty;exports.currentTheme=Dd;exports.defaultEntityHref=bc;exports.defaultWorkLink=Qc;exports.deriveDating=Wm;exports.deriveEditionType=Ol;exports.deriveEra=Wn;exports.deriveYear=Si;exports.deriveYearRange=Qo;exports.detailToEditor=Pc;exports.detectGenre=Ti;exports.displayAuthorRole=nr;exports.editorToDetail=Jf;exports.eraRank=jo;exports.filtersFromParams=ou;exports.filtersToParams=ci;exports.findCatalogPath=dn;exports.findTraditionalChars=Dp;exports.firstAuthorText=Pr;exports.flattenTitles=_o;exports.flattenToc=Tl;exports.fmtCount=Xe;exports.formatHitCount=oi;exports.formatTemplate=ht;exports.formatVolumeRange=$i;exports.getDisplayNameFromUrl=xn;exports.getMessages=hn;exports.getStartPage=Fo;exports.getT=fn;exports.getTypeGroupKey=Wo;exports.groupRelatedWorks=Om;exports.gujiInlineToPlain=ul;exports.hasActiveFilters=Ya;exports.hasGujiMarkdownV02=ho;exports.hasGujiTableNotation=gl;exports.hasSearchOptions=eu;exports.iiifVolumeOf=hf;exports.isCountedChar=jr;exports.isLayoutName=Ud;exports.isThemeName=Od;exports.lineageHref=kd;exports.loadRecentIds=Ot;exports.measureText=Pt;exports.mergeVolumeResources=Oo;exports.normalizeEra=nt;exports.normalizeLayout=Bi;exports.normalizeRole=tr;exports.normalizeTheme=Pi;exports.normalizeVolumeIndex=An;exports.normalizeVolumes=Oa;exports.numberToChinese=Wl;exports.paginationItems=Zc;exports.parseChineseNumber=di;exports.parseGujiInline=pl;exports.parseGujiTable=fl;exports.parseSourceString=$c;exports.pct=Wr;exports.periodLevel=ld;exports.pickReaderVersion=zl;exports.readStoredLayout=Jb;exports.readStoredTheme=Xb;exports.readerVersionOptionLabel=bo;exports.remapPlainOffsets=mc;exports.removeRecentId=Qa;exports.renderFullTextBody=_g;exports.renderProperNames=ac;exports.renderReaderInline=pr;exports.resolveRecentEntry=Go;exports.resourceHref=bn;exports.resourceNote=_i;exports.resultTabFromParam=gu;exports.resultTabToParam=hu;exports.roleFacets=Ml;exports.rowNo=dg;exports.sameFilters=ru;exports.saveRecentId=mo;exports.segmentEntities=gc;exports.shelfColumns=sd;exports.sortFor=tu;exports.sortYear=pi;exports.spineHeight=ad;exports.splitFullTextTables=qo;exports.splitHighlightSnippet=Mo;exports.splitTableRow=hl;exports.storeLayout=Qb;exports.storeTheme=Fd;exports.stringifySources=Cc;exports.summaryFromEntry=fc;exports.summaryFromItem=hc;exports.timelineLayout=wd;exports.toCatalogWorkCard=yb;exports.transportSummaryLoader=xc;exports.typeSupportsFilters=Ka;exports.useBidUrl=tt;exports.useChapterWarpData=vc;exports.useConvert=Pe;exports.useEntitySummaryLoader=kr;exports.useI18n=Q;exports.useReaderPrefs=Cl;exports.useRecentEntries=_d;exports.useT=Ce;exports.validateLineageGraph=Px;exports.volumeStats=xi;exports.withDefaultLinks=Ft;exports.withMetaLinks=Ht;exports.yearText=hi;
|