book-index-ui 0.44.0 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +77 -74
- package/dist/index.d.ts +10 -0
- package/dist/index.js +6357 -6075
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var vd=Object.create;var Cr=Object.defineProperty;var kd=Object.getOwnPropertyDescriptor;var wd=Object.getOwnPropertyNames;var Sd=Object.getPrototypeOf,_d=Object.prototype.hasOwnProperty;var $d=(t,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of wd(n))!_d.call(t,s)&&s!==o&&Cr(t,s,{get:()=>n[s],enumerable:!(r=kd(n,s))||r.enumerable});return t};var On=(t,n,o)=>(o=t!=null?vd(Sd(t)):{},$d(n||!t||!t.__esModule?Cr(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const we=require("./storage-entry-C9uAfe4i.cjs"),e=require("react/jsx-runtime"),g=require("react"),Cd=require("opencc-js/t2cn"),zd=require("react-markdown"),Td=require("remark-gfm"),Nd=t=>`/book-index?id=${t}`,el=g.createContext(Nd);function Ed({buildUrl:t,children:n}){const o=g.useMemo(()=>t,[t]);return e.jsx(el.Provider,{value:o,children:n})}function Ke(){return g.useContext(el)}const tl="",nl="";function fo(t){const n=[];let o=!1,r=t;for(;r.length;){const s=o?nl:tl,l=r.indexOf(s);if(l===-1){n.push({text:r,marked:o});break}l>0&&n.push({text:r.slice(0,l),marked:o}),r=r.slice(l+1),o=!o}return n}function tt(t,n){return{title:t,tokens:n}}const zr='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Id=[tt("基础(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"}}),tt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),tt("提示与警告",{"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)"}}),tt("遮罩与阴影",{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)"}}),tt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),tt("资源",{"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"}}),tt("整理本(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"}}),tt("版本传承(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"}}),tt("编辑器视图(主要在 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")'}}),tt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),tt('版式(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"}}),tt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),tt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),tt("字体(全站无衬线,2026-09-05 定)",{"font-ui":{value:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif'},"font-body":{value:"system-ui, sans-serif",css:"var(--bim-font-ui)"},"font-serif":{value:zr,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:zr,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Rd=Object.assign({},...Id.map(t=>t.tokens)),il={};for(const[t,n]of Object.entries(Rd))il[t]=`var(--bim-${t}, ${n.value})`;function i(t){const n=il[t];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${t}`);return n}function Ft(t){return t.types&&t.types.length>0?t.types:t.type?t.type==="text+image"?["text","image"]:[t.type]:[]}function Ld(t,n){return Ft(t).includes(n)}const Ad={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Dt=g.createContext(null),ol=["曹霑"];function Pd(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Md(t,n=ol){const o=[...new Set(n.filter(Boolean))].sort((l,a)=>a.length-l.length);if(!o.length)return t;const r=new RegExp(`(${o.map(Pd).join("|")})`,"g"),s=new Set(o);return l=>{if(!l)return t(l);const a=l.split(r);return a.length===1?t(l):a.map((p,c)=>c%2===1&&s.has(p)?p:p&&t(p)).join("")}}let mn=null;function Bd(){if(mn)return mn;try{const t=Cd.Converter({from:"t",to:"cn"});mn=Md(n=>t(we.normalizeVariants(n)))}catch{mn=t=>t}return mn}const Wd={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:"圖片資源"}},Od={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 it(t,n,o){return{"zh-Hant":t,"zh-Hans":n}}const Hd=it({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),ti=it({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:"作品信息"}),Fd=it({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:"附记"}}),Dd=it({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}"}}),Ud=it({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:"上级丛编"}),Vd=it({subtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对"}),Gd=it({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献"}),Yd=it({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:"本卷条目"}),Kd=it({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:"规模、存佚、许可与版本"}),xo=it({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:"按作者浏览全部 →"}),qd=it({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} 条"}),Xd=it({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:"搜索"}),Zd=it({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:"回复"}),Jd=it({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:"有争议"}}),Qd={common:Hd,detail:ti,bookPage:Fd,workPage:Dd,collectionPage:Ud,entityPage:Vd,reader:Gd,collated:Yd,metaHome:Kd,readHome:xo,catalogPage:qd,searchPage:Xd,feedback:Zd,lineage:Jd};function ep(t){const n={};for(const[o,r]of Object.entries(Qd))n[o]=r[t];return n}function dt(t,n){return t.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Tr=new Map;function rn(t){let n=Tr.get(t);return n||(n={...t==="zh-Hans"?Od:Wd,...ep(t)},Tr.set(t,n)),n}function Nr(t,n){let o=t;for(const r of n.split(".")){if(o==null||typeof o!="object")return;o=o[r]}return typeof o=="string"?o:void 0}function rl(t){return(n,o)=>{const r=Nr(t,n)??Nr(rn("zh-Hant"),n)??n;return o?dt(r,o):r}}const Er=new Map;function sn(t){let n=Er.get(t);return n||(n=rl(rn(t)),Er.set(t,n)),n}const sl="bim-locale";function tp(){try{const t=localStorage.getItem(sl);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function np(t){try{localStorage.setItem(sl,t)}catch{}}const ip="zh-Hans",op=({locale:t,onLocaleChange:n,converter:o,children:r})=>{const[s,l]=g.useState(t??ip),a=t??s;g.useEffect(()=>{if(t)return;const u=tp();u&&u!==s&&l(u)},[]);const p=g.useMemo(()=>a==="zh-Hans"?o??Bd():null,[a,o]),c=g.useCallback(u=>{l(u),np(u),n==null||n(u)},[n]),d=g.useMemo(()=>({locale:a,setLocale:c,messages:rn(a),converter:p}),[a,c,p]);return e.jsx(Dt.Provider,{value:d,children:r})};function $e(){const t=g.useContext(Dt);return(t==null?void 0:t.messages)??rn("zh-Hant")}const rp=2e3;function Re(){const t=g.useContext(Dt),n=(t==null?void 0:t.locale)??"zh-Hant",o=(t==null?void 0:t.converter)??null,r=g.useRef(new Map),s=g.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const l=g.useCallback(a=>{if(!a)return"";if(!o)return a;const p=r.current.get(a);if(p!==void 0)return p;const c=o(a);if(r.current.size>=rp){const d=r.current.keys().next().value;d!==void 0&&r.current.delete(d)}return r.current.set(a,c),c},[o]);return g.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function Z(){const t=g.useContext(Dt),{convert:n,locale:o,isSimplified:r}=Re(),s=(t==null?void 0:t.messages)??rn("zh-Hant"),l=g.useMemo(()=>t?rl(s):sn("zh-Hant"),[t,s]);return g.useMemo(()=>({t:l,convert:n,locale:o,isSimplified:r,messages:s}),[l,n,o,r,s])}const ll=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),sp=new Set([...ll,...Object.keys(we.VARIANT_CHARS)]),al=[...ol,"切換為繁體","漢籍リポジトリ"];function lp(t,n=al){let o=t;for(const l of n)l&&(o=o.split(l).join(" "));const r=[],s=Array.from(o);return s.forEach((l,a)=>{sp.has(l)&&r.push({char:l,context:s.slice(Math.max(0,a-8),a+9).join("")})}),r}function ap(t){if(!t)return"";try{const n=new URL(t).hostname,o={"zh.wikisource.org":"wikisource","www.shidianguji.com":"shidianguji","shidianguji.com":"shidianguji","archive.org":"archive","ctext.org":"ctext","read.nlc.cn":"nlc","www.digital.archives.go.jp":"japan_archives"};if(o[n])return o[n];const r=n.split(".");return r.length>=2?r[r.length-2]:n}catch{return""}}function cp(){return{id:"",name:"",url:"",type:"text",details:""}}const Vi=({items:t,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const l=$e(),[a,p]=g.useState(null),c=[{value:"text",label:l.resourceTypeShort.text},{value:"image",label:l.resourceTypeShort.image},{value:"text+image",label:l.resourceTypeShort.textImage},{value:"physical",label:l.resourceTypeShort.physical}],d=[{value:"catalog",label:l.rootType.catalog},{value:"search",label:l.rootType.search}],u=b=>{if(!s)return!0;const v=Ft(b);return s==="text"?v.includes("text"):s==="image"?v.includes("image")||v.includes("physical"):s==="physical"?v.includes("physical"):v.includes(s)},m=t.map((b,v)=>({item:b,originalIndex:v})).filter(({item:b})=>u(b)),h=()=>{const b=cp();s&&(b.type=s),n([...t,b]),p(t.length)},f=b=>{n(t.filter((v,S)=>S!==b)),p(null)},x=(b,v,S)=>{const k=[...t];if(k[b]={...k[b],[v]:S},v==="url"&&!k[b].id){const $=ap(S);$&&(k[b].id=$)}n(k)},j=(b,v,S)=>{const $={...t[b].metadata||{}};S?$[v]=S:delete $[v],x(b,"metadata",Object.keys($).length>0?$:void 0)},y=(b,v)=>{const S=v.trim()?v.split(/[,,、]/).map(k=>k.trim()).filter(Boolean):void 0;x(b,"structure",S)},_=(b,v,S)=>{const $=t[b].coverage||{level:1,ranges:""};v==="level"?$.level=parseInt(S)||1:$.ranges=S,x(b,"coverage",$.ranges?$:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:b,originalIndex:v})=>{var S,k,$;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(a===v?null:v),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:a===v?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:dp(b.type??"text"),color:i("on-color-fg")},children:(()=>{var z,B;const w=Ft(b);return w.length===0?b.type??"text":w.length===1?((z=c.find(I=>I.value===w[0]))==null?void 0:z.label)??w[0]:w.includes("text")&&w.includes("image")?((B=c.find(I=>I.value==="text+image"))==null?void 0:B.label)??"text+image":w.join("+")})()}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${l.editor.resourcePlaceholder} ${v+1}`}),b.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&e.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:w=>w.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&pp(v,r==null?void 0:r[v],o,l),e.jsx("button",{onClick:w=>{w.stopPropagation(),f(v)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),a===v&&e.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[Ld(b,"image")&&b.url&&up(b,l),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:hn,children:[e.jsx("span",{style:gn,children:l.label.type}),e.jsx("select",{value:b.type,onChange:w=>x(v,"type",w.target.value),style:{...ft,flex:1},children:c.map(w=>e.jsx("option",{value:w.value,children:w.label},w.value))})]}),e.jsxs("label",{style:hn,children:[e.jsx("span",{style:gn,children:l.label.rootType}),e.jsx("select",{value:b.root_type||"catalog",onChange:w=>x(v,"root_type",w.target.value),style:{...ft,flex:1},children:d.map(w=>e.jsx("option",{value:w.value,children:w.label},w.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:b.id,onChange:w=>x(v,"id",w.target.value),placeholder:l.editor.idAutoExtract,style:{...ft,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:b.name,onChange:w=>x(v,"name",w.target.value),placeholder:l.editor.resourceName,style:{...ft,flex:1}})]}),e.jsx("input",{type:"text",value:b.url,onChange:w=>x(v,"url",w.target.value),placeholder:l.editor.resourceUrl,style:ft}),e.jsx("input",{type:"text",value:((S=b.structure)==null?void 0:S.join("、"))||"",onChange:w=>y(v,w.target.value),placeholder:l.editor.structurePlaceholder,style:ft}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:hn,children:[e.jsx("span",{style:gn,children:l.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((k=b.coverage)==null?void 0:k.level)??"",onChange:w=>_(v,"level",w.target.value),placeholder:"1",style:{...ft,width:"60px"}})]}),e.jsxs("label",{style:{...hn,flex:1},children:[e.jsx("span",{style:gn,children:l.label.coverageRange}),e.jsx("input",{type:"text",value:(($=b.coverage)==null?void 0:$.ranges)||"",onChange:w=>_(v,"ranges",w.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...ft,flex:1}})]})]}),e.jsx("textarea",{value:b.details||"",onChange:w=>x(v,"details",w.target.value),placeholder:l.editor.detailsPlaceholder,style:{...ft,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:l.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([w,z])=>{var B;return e.jsxs("label",{style:{...hn,gap:"4px"},children:[e.jsx("span",{style:{...gn,minWidth:"56px"},children:z}),e.jsx("input",{type:"text",value:((B=b.metadata)==null?void 0:B[w])||"",onChange:I=>j(v,w,I.target.value),placeholder:z,style:{...ft,flex:1}})]},w)})})]})]})]})]},v)}),e.jsxs("button",{onClick:h,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:l.action.addResource})]})]})};function dp(t){switch(t){case"text":return i("restype-text");case"image":return i("restype-image");case"text+image":return i("restype-text-image");case"physical":return i("restype-physical")}}function pp(t,n,o,r){const s=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return e.jsx("button",{onClick:a=>{a.stopPropagation(),s||o(t,"")},disabled:s,style:{background:"transparent",border:"none",color:i(l?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:l?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:l?"✓":s?"⏳":"⬇"})}function up(t,n){const o=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(t.url)||t.url.includes("iiif")||t.url.includes("image");return e.jsx("div",{style:{marginBottom:"12px"},children:o?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:e.jsx("img",{src:t.url,alt:t.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const ft={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"},hn={display:"flex",alignItems:"center",gap:"6px"},gn={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},mp={"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 ln(t){try{return mp[new URL(t).hostname]}catch{return}}const Ir={text:0,image:1,physical:2};function bo(t){return t.length===0?"physical":[...t].sort((n,o)=>(Ir[n]??99)-(Ir[o]??99)).join("+")}function yo(t){var a;const n=p=>{const c=p.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const d=p.match(/^(.+?)[·(](\d+)[)]?$/);return d?[d[1],parseInt(d[2])]:null},o=new Map;for(let p=0;p<t.length;p++){const c=t[p];if(c.volumes&&c.volumes.length>0)continue;const d=n(c.name);if(!d)continue;const[u,m]=d,h=`${u}|${bo(Ft(c))}`;o.has(h)||o.set(h,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const f=o.get(h);f.volumes.push({volume:m,url:c.url||void 0,status:"found"}),f.indices.push(p)}const r=[],s=new Set;for(const p of o.values())if(!(p.volumes.length<2)){p.volumes.sort((c,d)=>c.volume-d.volume),p.base.volumes=p.volumes,p.base.expected_volumes=p.volumes.length,p.base.url||(p.base.url=((a=p.volumes.find(c=>c.url))==null?void 0:a.url)??""),r.push(p.base);for(const c of p.indices)s.add(c)}const l=[...r];for(let p=0;p<t.length;p++)s.has(p)||l.push(t[p]);return l}function cl(t){if(t.url)return t.url;for(const[n,o]of Object.entries(t))if(n.endsWith("_url")&&typeof o=="string")return o}function dl(t){return!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(n=>({...n,url:n.url||cl(n)}))}function ni(t){const n=dl(t);if(!n)return null;const o=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,r=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:o,missing:r,expected:t.expected_volumes??o+r}}function jo(t){if(!t)return;const n=t.file_page_range||t.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function vo(t,n){try{if(new URL(t).hostname.includes("wikimedia.org")){const r=t.match(/\/wiki\/File:(.+?)(?:#|$)/);if(r)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(r[1]))}&page=${n}`;const s=new URL(t);return s.searchParams.set("page",String(n)),s.toString()}return t}catch{return t}}function an(t){if(!t.url)return;const n=jo(t.metadata);return n?vo(t.url,n):t.url}const Rr={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function hp(t){return t.includes("text")&&t.includes("image")?Rr["text+image"]:Rr[t[0]||"physical"]}const ko=({items:t,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const l=$e(),{convert:a}=Re(),p=g.useMemo(()=>yo(t||[]),[t]),{mirrorGroups:c,ungroupedItems:d}=g.useMemo(()=>{const y=new Map,_=[];for(const b of p){const v=b.group;v?(y.has(v)||y.set(v,[]),y.get(v).push(b)):_.push(b)}for(const b of y.values())b.sort((v,S)=>{const k=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return k(v)-k(S)});return{mirrorGroups:y,ungroupedItems:_}},[p]),u={text:l.resourceType.text,image:l.resourceType.image,"text+image":l.resourceType.textImage,physical:l.resourceType.physical},m=y=>u[y]?u[y]:y.split("+").map(_=>u[_]||_).join("+");if(!p||p.length===0)return e.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:l.misc.noResources});if(!n)return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:p.map((y,_)=>e.jsx(zi,{item:y},y.id||_))});const h=(y,_)=>{const b=o==null?void 0:o[y],v=(b==null?void 0:b.label)||y,S=b==null?void 0:b.description;return e.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(v)}),S&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:a(S)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.map((k,$)=>e.jsx(zi,{item:k,onNavigate:r,renderLink:s},k.id||$))})]},`group-${y}`)},f=new Map;for(const y of d){const _=bo(Ft(y));f.has(_)||f.set(_,[]),f.get(_).push(y)}const x=["text","image","text+image","physical"],j=[...x.filter(y=>f.has(y)),...[...f.keys()].filter(y=>!x.includes(y)).sort()];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,_])=>h(y,_)),j.map(y=>{const _=f.get(y),b=hp(y.split("+"));return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:b,whiteSpace:"nowrap",flexShrink:0},children:m(y)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.map((v,S)=>e.jsx(zi,{item:v,onNavigate:r,renderLink:s},v.id||S))})]},y)})]})},gp={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},zi=({item:t})=>{const n=$e(),{convert:o}=Re(),[r,s]=g.useState(!1),l=g.useMemo(()=>(t.url?ln(t.url):void 0)||o(t.name),[t.url,t.name,o]),a=g.useMemo(()=>!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(x=>({...x,url:x.url||cl(x)})),[t.volumes]),p=a&&a.length>0,c=p?new Set(a.filter(x=>x.status!=="missing").map(x=>x.volume)).size:0,d=p?new Set(a.filter(x=>x.status==="missing").map(x=>x.volume)).size:0,u=t.expected_volumes??(p?c+d:0),m=t.color_mode?{...gp[t.color_mode],label:n.colorMode[t.color_mode]}:null,h=t.details&&!p?o(t.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 e.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[e.jsxs("div",{style:f,children:[e.jsx("span",{style:{fontWeight:500},children:l}),m&&e.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),h&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:h}),p&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,d>0&&e.jsx("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:dt(n.common.volumesMissing,{n:d})})]}),t.url&&e.jsx("a",{href:(()=>{const x=jo(t.metadata);return x?vo(t.url,x):t.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),p&&e.jsx("button",{onClick:()=>s(!r),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",lineHeight:1.4},children:r?"▲":"▼"})]}),p&&r&&e.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:a.map(x=>{const j=x.status==="missing";return x.url&&!j?e.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):e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(j?"missing-fg":"desc-fg"),textDecoration:j?"line-through":"none",opacity:j?.6:1},children:x.volume},x.volume)})})]})},pl=({indexSource:t,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:l,onSelectFolder:a})=>{const p=$e(),c=t==="local",d=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",m=u?u.split(/[/\\]/).pop()||u:"",h={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},f={onMouseOver:j=>j.currentTarget.style.opacity="0.8",onMouseOut:j=>j.currentTarget.style.opacity="1"},x=e.jsxs("div",{onClick:s,title:d?p.mode.switchToOfficial:p.mode.switchToDraft,style:{...h,background:i(d?"warning":"success"),color:i("on-color-fg")},...f,children:[e.jsx("span",{children:d?"📝":"📚"}),e.jsx("span",{children:d?"draft":"official"})]});return o==="index-browser"?c?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,e.jsxs("div",{onClick:r,title:p.mode.switchToSync,style:h,...f,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:p.mode.localMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px"},...f,children:[e.jsx("span",{children:"📂"}),m&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:r,title:p.mode.switchToLocal,style:h,...f,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:p.mode.syncMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:l,title:m||p.mode.configurePath,style:{...h,background:"transparent",padding:"6px",fontSize:"12px"},...f,children:e.jsx("span",{children:"⚙️"})})]})]}):e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsxs("div",{onClick:r,title:c?p.mode.switchToGithub:p.mode.switchToLocal,style:h,...f,children:[e.jsx("span",{children:c?"📁":"🌐"}),e.jsx("span",{children:c?p.mode.localMode:p.mode.githubSync}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...h,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...f,children:[e.jsx("span",{children:"📂"}),m&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&e.jsxs("div",{style:{...h,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:m})]})]})},ii="bim-search-history",Lr=10,Ar=8;function wn(){try{const t=localStorage.getItem(ii);return t?JSON.parse(t):[]}catch{return[]}}function ul(t){try{const n=wn().filter(o=>o!==t);n.unshift(t),n.length>Lr&&(n.length=Lr),localStorage.setItem(ii,JSON.stringify(n))}catch{}}function fp(t){try{const n=wn().filter(o=>o!==t);localStorage.setItem(ii,JSON.stringify(n))}catch{}}function xp(){try{localStorage.removeItem(ii)}catch{}}const ml=({transport:t,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:l})=>{const a=$e(),p=l??a.search.placeholder,c={work:a.indexType.work,book:a.indexType.book,collection:a.indexType.collection,entity:a.indexType.entity},[d,u]=g.useState(!1),[m,h]=g.useState([]),[f,x]=g.useState(-1),[j,y]=g.useState(wn),_=g.useRef(null),b=g.useRef(null),v=g.useRef(null),S=g.useRef(!1);g.useEffect(()=>{x(-1);const N=n.trim();if(!N){h(j.map(T=>({type:"history",text:T})));return}if(!t.searchAll){h([]);return}let O=!1;const C=setTimeout(()=>{t.searchAll(N,Ar).then(T=>{if(O)return;const R=[...T.works,...T.books,...T.collections,...T.entities??[]];h(R.slice(0,Ar).map(A=>({type:"entry",text:A.title||A.id,entry:A})))}).catch(()=>{O||h([])})},80);return()=>{O=!0,clearTimeout(C)}},[n,j,t]),g.useEffect(()=>{const N=O=>{v.current&&!v.current.contains(O.target)&&u(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),g.useEffect(()=>{const N=O=>{var C,T;if(O.key==="/"&&document.activeElement!==_.current){const R=(C=document.activeElement)==null?void 0:C.tagName;if(R==="INPUT"||R==="TEXTAREA"||R==="SELECT")return;O.preventDefault(),(T=_.current)==null||T.focus()}};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[]);const k=g.useCallback(N=>{N.trim()&&(ul(N.trim()),y(wn())),r(N),u(!1)},[r]),$=g.useCallback(N=>{N.type==="history"?(o(N.text),k(N.text)):N.entry&&(s?(s(N.entry),u(!1)):(o(N.text),k(N.text)))},[o,k,s]),w=g.useCallback(N=>{if(!d||m.length===0){N.key==="Enter"&&k(n);return}switch(N.key){case"ArrowDown":N.preventDefault(),x(O=>(O+1)%m.length);break;case"ArrowUp":N.preventDefault(),x(O=>(O-1+m.length)%m.length);break;case"Enter":N.preventDefault(),f>=0&&f<m.length?$(m[f]):k(n);break;case"Escape":N.preventDefault(),u(!1);break}},[d,m,f,n,k,$]),z=g.useCallback((N,O)=>{O.stopPropagation(),fp(N),y(wn()),h(C=>C.filter(T=>!(T.type==="history"&&T.text===N)))},[]),B=g.useCallback(N=>{N.stopPropagation(),xp(),y([]),h([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const N=b.current.children;N[f]&&N[f].scrollIntoView({block:"nearest"})}},[f]);const I=!n.trim()&&j.length>0;return e.jsxs("div",{ref:v,style:{position:"relative",flex:1},children:[e.jsx("input",{ref:_,type:"text",placeholder:p,value:n,onChange:N=>{o(N.target.value),u(!0)},onCompositionStart:()=>{S.current=!0},onCompositionEnd:()=>{S.current=!1},onFocus:()=>{u(!0)},onKeyDown:w,style:{width:"100%",padding:"8px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),d&&m.length>0&&e.jsxs("div",{ref:b,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:i("input-bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"6px",boxShadow:i("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[I&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:i("desc-fg"),borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("span",{children:a.search.history}),e.jsx("button",{onClick:B,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:a.search.clearAll})]}),m.map((N,O)=>e.jsxs("div",{onClick:()=>$(N),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:O===f?i("list-active-bg"):"transparent"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:N.type==="history"?"🕐":"🔍"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.text}),N.entry&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[N.entry.type],N.entry.edition&&` · ${N.entry.edition}`,N.entry.author&&` · ${N.entry.author}`]}),N.type==="history"&&e.jsx("button",{onClick:C=>z(N.text,C),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:a.action.remove,children:"×"})]},`${N.type}-${N.text}-${O}`))]})]})},cn=({type:t,size:n=9})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${t}`),verticalAlign:"middle"}}),oi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},hl=new Set(["work","book","entity"]);function bp(t){return xl(t)||!!t.sort}function yp(t,n){return n.sort&&hl.has(t)?n.sort:void 0}const ri=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],si=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],gl=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],fl={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function li(t){return t.dynasty.length+t.classification.length+(t.hasImage?1:0)+(t.hasText?1:0)+(t.hasCollated?1:0)+(t.loss?1:0)}function xl(t){return li(t)>0}function jp(t){const n=[];return t.dynasty.length&&n.push("dynasty"),t.classification.length&&n.push("classification"),t.hasImage&&n.push("hasImage"),t.hasText&&n.push("hasText"),t.hasCollated&&n.push("hasCollated"),t.loss&&n.push("loss"),n}function bl(t,n){const o=fl[t];return jp(n).every(r=>o.has(r))}const fn=t=>JSON.stringify(t);function vp(t,n){if(!bl(n,t))return null;const o=[];if(t.dynasty.length){const r=Array.from(new Set(t.dynasty.flatMap(s=>{var l;return((l=ri.find(a=>a.key===s))==null?void 0:l.values)??[]})));r.length===1?o.push(`dynasty = ${fn(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(fn).join(", ")}]`)}return t.classification.length&&o.push(t.classification.length===1?`classification = ${fn(t.classification[0])}`:`classification IN [${t.classification.map(fn).join(", ")}]`),t.hasImage&&o.push("has_image = true"),t.hasText&&o.push("has_text = true"),t.hasCollated&&o.push("has_collated = true"),t.loss&&o.push(`loss_status = ${fn(t.loss)}`),o.join(" AND ")}const et={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},yl="_";function Kn(t,n=new URLSearchParams){for(const o of Object.values(et))n.delete(o);return t.dynasty.length&&n.set(et.dynasty,t.dynasty.join(",")),t.classification.length&&n.set(et.classification,t.classification.map(o=>o||yl).join(",")),t.hasImage&&n.set(et.hasImage,"1"),t.hasText&&n.set(et.hasText,"1"),t.hasCollated&&n.set(et.hasCollated,"1"),t.loss&&n.set(et.loss,t.loss),t.sort&&n.set(et.sort,t.sort),n}function kp(t){const n=l=>(t.get(l)??"").split(",").map(a=>a.trim()).filter(Boolean),o=new Set(ri.map(l=>l.key)),r=new Set(si.map(l=>l.value)),s=t.get(et.loss);return{dynasty:Array.from(new Set(n(et.dynasty).filter(l=>o.has(l)))),classification:Array.from(new Set(n(et.classification).map(l=>l===yl?"":l).filter(l=>r.has(l)))),hasImage:t.get(et.hasImage)==="1",hasText:t.get(et.hasText)==="1"||t.get(et.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(l=>l===t.get(et.sort))??""}}function wp(t,n){return JSON.stringify([t.dynasty.slice().sort(),t.classification.slice().sort(),t.hasImage,t.hasText,t.hasCollated,t.loss,t.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Pr(t,n){return t.includes(n)?t.filter(o=>o!==n):[...t,n]}const Sp=({filters:t,onChange:n})=>{const o=$e(),r=o.searchV4,{convert:s}=Re(),[l,a]=g.useState(!1),p=g.useId(),c=li(t),d=u=>n({...t,...u});return e.jsxs("aside",{className:"bim-sr-aside","aria-label":s(r.filterTitle),children:[e.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":l,"aria-controls":p,onClick:()=>a(u=>!u),children:[e.jsxs("span",{children:[s(r.filterButton),c>0&&e.jsx("span",{className:"bim-sr-fn",children:s(dt(r.filterSelected,{n:c}))})]}),e.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(l?r.collapse:r.expand)," ",l?"▴":"▾"]})]}),e.jsxs("div",{className:"bim-sr-filters",id:p,"data-open":l?"true":"false",...l?{}:{"data-collapsed":"true"},children:[e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.dynasty)}),e.jsx("div",{className:"bim-sr-chips",children:ri.map(u=>e.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":t.dynasty.includes(u.key),onClick:()=>d({dynasty:Pr(t.dynasty,u.key)}),children:s(u.key)},u.key))})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.classification)}),si.map(u=>e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.classification.includes(u.value),onChange:()=>d({classification:Pr(t.classification,u.value)})}),u.value?s(u.label):o.searchPage.unclassified]},u.value||"_"))]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:s(r.resources)}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasImage,onChange:u=>d({hasImage:u.target.checked})}),s(r.hasImage)]}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasText,onChange:u=>d({hasText:u.target.checked})}),s(r.hasText)]})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{id:`${p}-loss`,children:s(r.extant)}),e.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${p}-loss`,children:gl.map(u=>e.jsx("button",{type:"button","aria-pressed":t.loss===u.value,onClick:()=>d({loss:u.value}),children:o.searchPage.loss[u.value||"all"]},u.value||"all"))})]}),c>0&&e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...oi,sort:t.sort}),children:s(r.clearAllFilters)})]})]})};function jl({text:t,query:n}){const o=(n??"").trim();if(!o||!t)return e.jsx(e.Fragment,{children:t});const r=t.toLowerCase(),s=o.toLowerCase(),l=[];let a=0,p=0;for(;a<t.length;){const c=r.indexOf(s,a);if(c<0){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{className:"bim-sr-hl",children:t.slice(c,c+s.length)},p++)),a=c+s.length}return e.jsx(e.Fragment,{children:l})}const Mr=({entries:t,query:n,onEntryLinkClick:o,typeName:r})=>{const s=$e(),l=s.searchV4,{convert:a}=Re(),p=Ke();return e.jsx("div",{className:"bim-sr-tablewrap",children:e.jsxs("table",{className:"bim-sr-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"34%"}}),e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"19%"}}),e.jsx("col",{style:{width:"13%"}}),e.jsx("col",{style:{width:"12%"}}),e.jsx("col",{style:{width:"14%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:a(l.colTitle)}),e.jsx("th",{scope:"col",children:a(l.colType)}),e.jsx("th",{scope:"col",children:a(l.colAuthor)}),e.jsx("th",{scope:"col",children:a(l.colEra)}),e.jsx("th",{scope:"col",children:a(l.colClass)}),e.jsx("th",{scope:"col",style:{textAlign:"right"},children:a(l.colResource)})]})}),e.jsx("tbody",{children:t.map(c=>{const d=a(c.title||c.primary_name||c.id),u=c.measure_info?a(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${a(c.author)}${c.role&&c.role!=="author"?` ${a(c.role)}`:""}`:"",h=c.type==="book"?c.era??c.dynasty:c.dynasty,f=h?a(h):"",x=c.classification?a(c.classification):"",j=[];c.has_image&&j.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&j.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&j.push({label:l.tagLost,cls:"bim-sr-tag--lost"});const y=[m,f,x].filter(Boolean).join(" · ");return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-sr-c-title",children:[e.jsxs("div",{className:"bim-sr-tl",children:[e.jsx("a",{href:p(c.id),onClick:_=>o(c,_),children:e.jsx(jl,{text:d,query:n?a(n):void 0})}),u&&e.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&e.jsx("span",{className:"bim-sr-sub",children:y})]}),e.jsxs("td",{className:"bim-sr-c-type",children:[e.jsx(cn,{type:c.type,size:6})," ",r(c.type)]}),e.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),e.jsx("td",{className:"bim-sr-c-era",children:f||"—"}),e.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),e.jsx("td",{className:"bim-sr-c-res",children:j.map(_=>e.jsx("span",{className:`bim-sr-tag ${_.cls}`,children:a(_.label)},_.label))})]},c.id)})})]})})},_p=`
|
|
1
|
+
"use strict";var Od=Object.create;var Or=Object.defineProperty;var Hd=Object.getOwnPropertyDescriptor;var Fd=Object.getOwnPropertyNames;var Dd=Object.getPrototypeOf,Ud=Object.prototype.hasOwnProperty;var Vd=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Fd(n))!Ud.call(e,s)&&s!==o&&Or(e,s,{get:()=>n[s],enumerable:!(r=Hd(n,s))||r.enumerable});return e};var Vn=(e,n,o)=>(o=e!=null?Od(Dd(e)):{},Vd(n||!e||!e.__esModule?Or(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const we=require("./storage-entry-C9uAfe4i.cjs"),t=require("react/jsx-runtime"),g=require("react"),Gd=require("opencc-js/t2cn"),Yd=require("react-markdown"),Kd=require("remark-gfm"),qd=e=>`/book-index?id=${e}`,ga=g.createContext(qd);function Xd({buildUrl:e,children:n}){const o=g.useMemo(()=>e,[e]);return t.jsx(ga.Provider,{value:o,children:n})}function qe(){return g.useContext(ga)}const fa="",xa="";function _o(e){const n=[];let o=!1,r=e;for(;r.length;){const s=o?xa:fa,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 nt(e,n){return{title:e,tokens:n}}const Hr='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Zd=[nt("基础(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"}}),nt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),nt("提示与警告",{"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)"}}),nt("遮罩与阴影",{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)"}}),nt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),nt("资源",{"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"}}),nt("整理本(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"}}),nt("版本传承(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"}}),nt("编辑器视图(主要在 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")'}}),nt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),nt('版式(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"}}),nt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),nt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),nt("字体(全站无衬线,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:Hr,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Hr,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Jd=Object.assign({},...Zd.map(e=>e.tokens)),ba={};for(const[e,n]of Object.entries(Jd))ba[e]=`var(--bim-${e}, ${n.value})`;function i(e){const n=ba[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Vt(e){return e.types&&e.types.length>0?e.types:e.type?e.type==="text+image"?["text","image"]:[e.type]:[]}function Qd(e,n){return Vt(e).includes(n)}const ep={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Gt=g.createContext(null),ya=["曹霑"];function tp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function np(e,n=ya){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(tp).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 fn=null;function ip(){if(fn)return fn;try{const e=Gd.Converter({from:"t",to:"cn"});fn=np(n=>e(we.normalizeVariants(n)))}catch{fn=e=>e}return fn}const op={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:"圖片資源"}},rp={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 ot(e,n,o){return{"zh-Hant":e,"zh-Hans":n}}const sp=ot({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),li=ot({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:"作品信息"}),ap=ot({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:"附记"}}),lp=ot({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}"}}),cp=ot({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:"上级丛编"}),dp=ot({subtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对"}),pp=ot({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",version:"版本",versionShort:"版本▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献"}),up=ot({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:"本卷条目"}),mp=ot({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:"规模、存佚、许可与版本"}),$o=ot({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:"按作者浏览全部 →"}),hp=ot({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} 条"}),gp=ot({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:"搜索"}),fp=ot({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:"回复"}),xp=ot({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:"有争议"}}),bp={common:sp,detail:li,bookPage:ap,workPage:lp,collectionPage:cp,entityPage:dp,reader:pp,collated:up,metaHome:mp,readHome:$o,catalogPage:hp,searchPage:gp,feedback:fp,lineage:xp};function yp(e){const n={};for(const[o,r]of Object.entries(bp))n[o]=r[e];return n}function dt(e,n){return e.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}const Fr=new Map;function ln(e){let n=Fr.get(e);return n||(n={...e==="zh-Hans"?rp:op,...yp(e)},Fr.set(e,n)),n}function Dr(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 ja(e){return(n,o)=>{const r=Dr(e,n)??Dr(ln("zh-Hant"),n)??n;return o?dt(r,o):r}}const Ur=new Map;function cn(e){let n=Ur.get(e);return n||(n=ja(ln(e)),Ur.set(e,n)),n}const va="bim-locale";function jp(){try{const e=localStorage.getItem(va);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function vp(e){try{localStorage.setItem(va,e)}catch{}}const kp="zh-Hans",wp=({locale:e,onLocaleChange:n,converter:o,children:r})=>{const[s,a]=g.useState(e??kp),l=e??s;g.useEffect(()=>{if(e)return;const u=jp();u&&u!==s&&a(u)},[]);const d=g.useMemo(()=>l==="zh-Hans"?o??ip():null,[l,o]),c=g.useCallback(u=>{a(u),vp(u),n==null||n(u)},[n]),p=g.useMemo(()=>({locale:l,setLocale:c,messages:ln(l),converter:d}),[l,c,d]);return t.jsx(Gt.Provider,{value:p,children:r})};function $e(){const e=g.useContext(Gt);return(e==null?void 0:e.messages)??ln("zh-Hant")}const Sp=2e3;function Ie(){const e=g.useContext(Gt),n=(e==null?void 0:e.locale)??"zh-Hant",o=(e==null?void 0:e.converter)??null,r=g.useRef(new Map),s=g.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const a=g.useCallback(l=>{if(!l)return"";if(!o)return l;const d=r.current.get(l);if(d!==void 0)return d;const c=o(l);if(r.current.size>=Sp){const p=r.current.keys().next().value;p!==void 0&&r.current.delete(p)}return r.current.set(l,c),c},[o]);return g.useMemo(()=>({convert:a,locale:n,isSimplified:n==="zh-Hans"}),[a,n])}function J(){const e=g.useContext(Gt),{convert:n,locale:o,isSimplified:r}=Ie(),s=(e==null?void 0:e.messages)??ln("zh-Hant"),a=g.useMemo(()=>e?ja(s):cn("zh-Hant"),[e,s]);return g.useMemo(()=>({t:a,convert:n,locale:o,isSimplified:r,messages:s}),[a,n,o,r,s])}const ka=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),_p=new Set([...ka,...Object.keys(we.VARIANT_CHARS)]),wa=[...ya,"切換為繁體","漢籍リポジトリ"];function $p(e,n=wa){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)=>{_p.has(a)&&r.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),r}function Cp(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 zp(){return{id:"",name:"",url:"",type:"text",details:""}}const eo=({items:e,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const a=$e(),[l,d]=g.useState(null),c=[{value:"text",label:a.resourceTypeShort.text},{value:"image",label:a.resourceTypeShort.image},{value:"text+image",label:a.resourceTypeShort.textImage},{value:"physical",label:a.resourceTypeShort.physical}],p=[{value:"catalog",label:a.rootType.catalog},{value:"search",label:a.rootType.search}],u=b=>{if(!s)return!0;const j=Vt(b);return s==="text"?j.includes("text"):s==="image"?j.includes("image")||j.includes("physical"):s==="physical"?j.includes("physical"):j.includes(s)},h=e.map((b,j)=>({item:b,originalIndex:j})).filter(({item:b})=>u(b)),m=()=>{const b=zp();s&&(b.type=s),n([...e,b]),d(e.length)},f=b=>{n(e.filter((j,w)=>w!==b)),d(null)},x=(b,j,w)=>{const v=[...e];if(v[b]={...v[b],[j]:w},j==="url"&&!v[b].id){const $=Cp(w);$&&(v[b].id=$)}n(v)},k=(b,j,w)=>{const $={...e[b].metadata||{}};w?$[j]=w:delete $[j],x(b,"metadata",Object.keys($).length>0?$:void 0)},y=(b,j)=>{const w=j.trim()?j.split(/[,,、]/).map(v=>v.trim()).filter(Boolean):void 0;x(b,"structure",w)},_=(b,j,w)=>{const $=e[b].coverage||{level:1,ranges:""};j==="level"?$.level=parseInt(w)||1:$.ranges=w,x(b,"coverage",$.ranges?$:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[h.map(({item:b,originalIndex:j})=>{var w,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:Tp(b.type??"text"),color:i("on-color-fg")},children:(()=>{var C,B;const S=Vt(b);return S.length===0?b.type??"text":S.length===1?((C=c.find(T=>T.value===S[0]))==null?void 0:C.label)??S[0]:S.includes("text")&&S.includes("image")?((B=c.find(T=>T.value==="text+image"))==null?void 0:B.label)??"text+image":S.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:S=>S.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&b.url&&Np(j,r==null?void 0:r[j],o,a),t.jsx("button",{onClick:S=>{S.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:[Qd(b,"image")&&b.url&&Ep(b,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:xn,children:[t.jsx("span",{style:bn,children:a.label.type}),t.jsx("select",{value:b.type,onChange:S=>x(j,"type",S.target.value),style:{...ft,flex:1},children:c.map(S=>t.jsx("option",{value:S.value,children:S.label},S.value))})]}),t.jsxs("label",{style:xn,children:[t.jsx("span",{style:bn,children:a.label.rootType}),t.jsx("select",{value:b.root_type||"catalog",onChange:S=>x(j,"root_type",S.target.value),style:{...ft,flex:1},children:p.map(S=>t.jsx("option",{value:S.value,children:S.label},S.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:b.id,onChange:S=>x(j,"id",S.target.value),placeholder:a.editor.idAutoExtract,style:{...ft,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:b.name,onChange:S=>x(j,"name",S.target.value),placeholder:a.editor.resourceName,style:{...ft,flex:1}})]}),t.jsx("input",{type:"text",value:b.url,onChange:S=>x(j,"url",S.target.value),placeholder:a.editor.resourceUrl,style:ft}),t.jsx("input",{type:"text",value:((w=b.structure)==null?void 0:w.join("、"))||"",onChange:S=>y(j,S.target.value),placeholder:a.editor.structurePlaceholder,style:ft}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:xn,children:[t.jsx("span",{style:bn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((v=b.coverage)==null?void 0:v.level)??"",onChange:S=>_(j,"level",S.target.value),placeholder:"1",style:{...ft,width:"60px"}})]}),t.jsxs("label",{style:{...xn,flex:1},children:[t.jsx("span",{style:bn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:(($=b.coverage)==null?void 0:$.ranges)||"",onChange:S=>_(j,"ranges",S.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...ft,flex:1}})]})]}),t.jsx("textarea",{value:b.details||"",onChange:S=>x(j,"details",S.target.value),placeholder:a.editor.detailsPlaceholder,style:{...ft,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(([S,C])=>{var B;return t.jsxs("label",{style:{...xn,gap:"4px"},children:[t.jsx("span",{style:{...bn,minWidth:"56px"},children:C}),t.jsx("input",{type:"text",value:((B=b.metadata)==null?void 0:B[S])||"",onChange:T=>k(j,S,T.target.value),placeholder:C,style:{...ft,flex:1}})]},S)})})]})]})]})]},j)}),t.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function Tp(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 Np(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 Ep(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 ft={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"},xn={display:"flex",alignItems:"center",gap:"6px"},bn={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},Ip={"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 dn(e){try{return Ip[new URL(e).hostname]}catch{return}}const Vr={text:0,image:1,physical:2};function Co(e){return e.length===0?"physical":[...e].sort((n,o)=>(Vr[n]??99)-(Vr[o]??99)).join("+")}function zo(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,h]=p,m=`${u}|${Co(Vt(c))}`;o.has(m)||o.set(m,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const f=o.get(m);f.volumes.push({volume:h,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 Sa(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 _a(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||Sa(n)}))}function ci(e){const n=_a(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 To(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 No(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 pn(e){if(!e.url)return;const n=To(e.metadata);return n?No(e.url,n):e.url}const Gr={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function Rp(e){return e.includes("text")&&e.includes("image")?Gr["text+image"]:Gr[e[0]||"physical"]}const Eo=({items:e,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const a=$e(),{convert:l}=Ie(),d=g.useMemo(()=>zo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=g.useMemo(()=>{const y=new Map,_=[];for(const b of d){const j=b.group;j?(y.has(j)||y.set(j,[]),y.get(j).push(b)):_.push(b)}for(const b of y.values())b.sort((j,w)=>{const v=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return v(j)-v(w)});return{mirrorGroups:y,ungroupedItems:_}},[d]),u={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},h=y=>u[y]?u[y]:y.split("+").map(_=>u[_]||_).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,_)=>t.jsx(Pi,{item:y},y.id||_))});const m=(y,_)=>{const b=o==null?void 0:o[y],j=(b==null?void 0:b.label)||y,w=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)}),w&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:l(w)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.map((v,$)=>t.jsx(Pi,{item:v,onNavigate:r,renderLink:s},v.id||$))})]},`group-${y}`)},f=new Map;for(const y of p){const _=Co(Vt(y));f.has(_)||f.set(_,[]),f.get(_).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,_])=>m(y,_)),k.map(y=>{const _=f.get(y),b=Rp(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:h(y)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.map((j,w)=>t.jsx(Pi,{item:j,onNavigate:r,renderLink:s},j.id||w))})]},y)})]})},Lp={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Pi=({item:e})=>{const n=$e(),{convert:o}=Ie(),[r,s]=g.useState(!1),a=g.useMemo(()=>(e.url?dn(e.url):void 0)||o(e.name),[e.url,e.name,o]),l=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||Sa(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),h=e.color_mode?{...Lp[e.color_mode],label:n.colorMode[e.color_mode]}:null,m=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}),h&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:h.bg,color:h.fg},children:h.label}),m&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:m}),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:dt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=To(e.metadata);return x?No(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)})})]})},$a=({indexSource:e,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=$e(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",h=u?u.split(/[/\\]/).pop()||u:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},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:{...m,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:m,...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:{...m,paddingLeft:"8px",paddingRight:"8px"},...f,children:[t.jsx("span",{children:"📂"}),h&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:h})]})]}):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:m,...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:h||d.mode.configurePath,style:{...m,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:m,...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:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...f,children:[t.jsx("span",{children:"📂"}),h&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:h})]}),!c&&h&&t.jsxs("div",{style:{...m,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:h})]})]})},di="bim-search-history",Yr=10,Kr=8;function $n(){try{const e=localStorage.getItem(di);return e?JSON.parse(e):[]}catch{return[]}}function Ca(e){try{const n=$n().filter(o=>o!==e);n.unshift(e),n.length>Yr&&(n.length=Yr),localStorage.setItem(di,JSON.stringify(n))}catch{}}function Ap(e){try{const n=$n().filter(o=>o!==e);localStorage.setItem(di,JSON.stringify(n))}catch{}}function Pp(){try{localStorage.removeItem(di)}catch{}}const za=({transport:e,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:a})=>{const l=$e(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,u]=g.useState(!1),[h,m]=g.useState([]),[f,x]=g.useState(-1),[k,y]=g.useState($n),_=g.useRef(null),b=g.useRef(null),j=g.useRef(null),w=g.useRef(!1);g.useEffect(()=>{x(-1);const z=n.trim();if(!z){m(k.map(R=>({type:"history",text:R})));return}if(!e.searchAll){m([]);return}let F=!1;const N=setTimeout(()=>{e.searchAll(z,Kr).then(R=>{if(F)return;const O=[...R.works,...R.books,...R.collections,...R.entities??[]];m(O.slice(0,Kr).map(I=>({type:"entry",text:I.title||I.id,entry:I})))}).catch(()=>{F||m([])})},80);return()=>{F=!0,clearTimeout(N)}},[n,k,e]),g.useEffect(()=>{const z=F=>{j.current&&!j.current.contains(F.target)&&u(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]),g.useEffect(()=>{const z=F=>{var N,R;if(F.key==="/"&&document.activeElement!==_.current){const O=(N=document.activeElement)==null?void 0:N.tagName;if(O==="INPUT"||O==="TEXTAREA"||O==="SELECT")return;F.preventDefault(),(R=_.current)==null||R.focus()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const v=g.useCallback(z=>{z.trim()&&(Ca(z.trim()),y($n())),r(z),u(!1)},[r]),$=g.useCallback(z=>{z.type==="history"?(o(z.text),v(z.text)):z.entry&&(s?(s(z.entry),u(!1)):(o(z.text),v(z.text)))},[o,v,s]),S=g.useCallback(z=>{if(!p||h.length===0){z.key==="Enter"&&v(n);return}switch(z.key){case"ArrowDown":z.preventDefault(),x(F=>(F+1)%h.length);break;case"ArrowUp":z.preventDefault(),x(F=>(F-1+h.length)%h.length);break;case"Enter":z.preventDefault(),f>=0&&f<h.length?$(h[f]):v(n);break;case"Escape":z.preventDefault(),u(!1);break}},[p,h,f,n,v,$]),C=g.useCallback((z,F)=>{F.stopPropagation(),Ap(z),y($n()),m(N=>N.filter(R=>!(R.type==="history"&&R.text===z)))},[]),B=g.useCallback(z=>{z.stopPropagation(),Pp(),y([]),m([])},[]);g.useEffect(()=>{if(f>=0&&b.current){const z=b.current.children;z[f]&&z[f].scrollIntoView({block:"nearest"})}},[f]);const T=!n.trim()&&k.length>0;return t.jsxs("div",{ref:j,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:_,type:"text",placeholder:d,value:n,onChange:z=>{o(z.target.value),u(!0)},onCompositionStart:()=>{w.current=!0},onCompositionEnd:()=>{w.current=!1},onFocus:()=>{u(!0)},onKeyDown:S,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&&h.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:[T&&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:B,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),h.map((z,F)=>t.jsxs("div",{onClick:()=>$(z),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:F===f?i("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:z.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.text}),z.entry&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[z.entry.type],z.entry.edition&&` · ${z.entry.edition}`,z.entry.author&&` · ${z.entry.author}`]}),z.type==="history"&&t.jsx("button",{onClick:N=>C(z.text,N),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${z.type}-${z.text}-${F}`))]})]})},un=({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"}}),pi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},Ta=new Set(["work","book","entity"]);function Mp(e){return Ia(e)||!!e.sort}function Bp(e,n){return n.sort&&Ta.has(e)?n.sort:void 0}const ui=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],mi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Na=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],Ea={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function hi(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 Ia(e){return hi(e)>0}function Wp(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 Ra(e,n){const o=Ea[e];return Wp(n).every(r=>o.has(r))}const yn=e=>JSON.stringify(e);function Op(e,n){if(!Ra(n,e))return null;const o=[];if(e.dynasty.length){const r=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=ui.find(l=>l.key===s))==null?void 0:a.values)??[]})));r.length===1?o.push(`dynasty = ${yn(r[0])}`):r.length>1&&o.push(`dynasty IN [${r.map(yn).join(", ")}]`)}return e.classification.length&&o.push(e.classification.length===1?`classification = ${yn(e.classification[0])}`:`classification IN [${e.classification.map(yn).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 = ${yn(e.loss)}`),o.join(" AND ")}const tt={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},La="_";function ti(e,n=new URLSearchParams){for(const o of Object.values(tt))n.delete(o);return e.dynasty.length&&n.set(tt.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(tt.classification,e.classification.map(o=>o||La).join(",")),e.hasImage&&n.set(tt.hasImage,"1"),e.hasText&&n.set(tt.hasText,"1"),e.hasCollated&&n.set(tt.hasCollated,"1"),e.loss&&n.set(tt.loss,e.loss),e.sort&&n.set(tt.sort,e.sort),n}function Hp(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),o=new Set(ui.map(a=>a.key)),r=new Set(mi.map(a=>a.value)),s=e.get(tt.loss);return{dynasty:Array.from(new Set(n(tt.dynasty).filter(a=>o.has(a)))),classification:Array.from(new Set(n(tt.classification).map(a=>a===La?"":a).filter(a=>r.has(a)))),hasImage:e.get(tt.hasImage)==="1",hasText:e.get(tt.hasText)==="1"||e.get(tt.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(tt.sort))??""}}function Fp(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 qr(e,n){return e.includes(n)?e.filter(o=>o!==n):[...e,n]}const Dp=({filters:e,onChange:n})=>{const o=$e(),r=o.searchV4,{convert:s}=Ie(),[a,l]=g.useState(!1),d=g.useId(),c=hi(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(dt(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:ui.map(u=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(u.key),onClick:()=>p({dynasty:qr(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)}),mi.map(u=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(u.value),onChange:()=>p({classification:qr(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:Na.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({...pi,sort:e.sort}),children:s(r.clearAllFilters)})]})]})};function Aa({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 Xr=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=$e(),a=s.searchV4,{convert:l}=Ie(),d=qe();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}`:"",h=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)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,f=m?l(m):"",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=[h,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:_=>o(c,_),children:t.jsx(Aa,{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(un,{type:c.type,size:6})," ",r(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:h||"—"}),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(_=>t.jsx("span",{className:`bim-sr-tag ${_.cls}`,children:l(_.label)},_.label))})]},c.id)})})]})})},Up=`
|
|
2
2
|
.bim-sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 10px; }
|
|
3
3
|
.bim-sc { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 12px; border: 1px solid ${i("rule")}; background: ${i("card-bg")}; color: inherit; text-decoration: none; }
|
|
4
4
|
.bim-sc:hover { border-color: ${i("rule-dashed")}; box-shadow: ${i("fr-shadow")}; }
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
.bim-sc-fl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: ${i("aux-fg")}; }
|
|
13
13
|
.bim-sc-tags { display: flex; gap: 4px; flex: none; }
|
|
14
14
|
:root[data-layout="boxed"] .bim-sc { box-shadow: none; }
|
|
15
|
-
`,
|
|
15
|
+
`,Zr=({entries:e,query:n,onEntryLinkClick:o,typeName:r})=>{const s=$e(),a=s.searchV4,{convert:l}=Ie(),d=qe();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:Up}),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??"?"}`:"":`${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(Aa,{text:p,query:n?l(n):void 0})}),m&&t.jsx("span",{className:"bim-sc-m",children:m}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:_o(c.descriptionSnippet).map((k,y)=>k.marked?t.jsx("mark",{children:l(k.text)},y):t.jsx(g.Fragment,{children:l(k.text)},y))}),t.jsx("span",{className:"bim-sc-sp"}),t.jsxs("div",{className:"bim-sc-f",children:[t.jsx("span",{className:"bim-sc-fl",children:f}),t.jsx("span",{className:"bim-sc-tags",children:x.map(k=>t.jsx("span",{className:`bim-sr-tag ${k.cls}`,children:l(k.label)},k.label))})]})]},c.id)})]})};function Vp(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 Gp(e,n,o){const r=Math.max(1,Math.ceil(n/o));return Math.min(Math.max(1,e),r)}const Yp=({page:e,pageSize:n,total:o,totalLabel:r,onPage:s})=>{const a=$e().searchV4,{convert:l}=Ie(),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(dt(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)})}),Vp(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)})})]})]})},Pa="(max-width: 719px)",Kp=`${Pa}, (pointer: coarse)`,qp=`
|
|
16
16
|
.bim-sr-layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; align-items: start; padding: 0 20px; }
|
|
17
17
|
.bim-sr-layout[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
|
|
18
18
|
.bim-sr-aside { position: sticky; top: calc(${i("reader-top")} + 16px); padding-top: 2px; }
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
.bim-sr-pager .bim-sr-gap { color: ${i("aux-fg")}; padding: 0 2px; }
|
|
82
82
|
.bim-sr-empty { padding: 60px 0; text-align: center; font-size: 14px; color: ${i("meta-fg")}; }
|
|
83
83
|
|
|
84
|
-
@media ${
|
|
84
|
+
@media ${Pa} {
|
|
85
85
|
.bim-sr-layout { grid-template-columns: minmax(0, 1fr); row-gap: 16px; padding: 0 16px; }
|
|
86
86
|
.bim-sr-aside { position: static; }
|
|
87
87
|
.bim-sr-fbtn {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
.bim-sr-table td.bim-sr-c-res { text-align: left; padding-bottom: 2px; }
|
|
103
103
|
.bim-sr-table td.bim-sr-c-res:empty { display: none; }
|
|
104
104
|
}
|
|
105
|
-
@media ${
|
|
105
|
+
@media ${Kp} {
|
|
106
106
|
.bim-sr-chip { min-height: 36px; }
|
|
107
107
|
.bim-sr-opt { min-height: 44px; }
|
|
108
108
|
.bim-sr-seg button { min-height: 44px; }
|
|
@@ -117,10 +117,10 @@
|
|
|
117
117
|
:root[data-layout="boxed"] .bim-sr-table th { background: ${i("fr-bg")}; }
|
|
118
118
|
/* 墨:主色与正文对比不到 3:1,标题链接另加下划线 */
|
|
119
119
|
:root[data-theme="ink"] .bim-sr-table td.bim-sr-c-title a { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; }
|
|
120
|
-
`,wo="bim-search-view",Ti=50,Wr=5,Sn=1e3;function Un(t){return t>=Sn?`${Sn.toLocaleString()}+`:t.toLocaleString()}const Ep={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Ip(t){return t&&Ep[t.toLowerCase()]||"all"}function Rp(t){return t==="all"?null:t}const Or=["work","collection","book","entity"],Lp={work:"works",collection:"collections",book:"books",entity:"entities"},Ap={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function Pp(){try{return window.localStorage.getItem(wo)==="card"?"card":"table"}catch{return"table"}}function Mp(t){try{window.localStorage.setItem(wo,t)}catch{}}const qt=(t,n)=>(t==null?void 0:t[Ap[n]])??0,Ni=(t,n)=>(t==null?void 0:t[Lp[n]])??[],kl=({transport:t,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:l,tab:a,onTabChange:p,page:c,onPageChange:d})=>{const u=$e(),m=u.searchV4,{convert:h}=Re(),f=!!t.supportsSearchFilters,x=g.useMemo(()=>f?o:oi,[f,o]),[j,y]=g.useState("table");g.useEffect(()=>{y(Pp())},[]);const _=Y=>{y(Y),Mp(Y)},[b,v]=g.useState(a??"all"),S=g.useRef(b);S.current=b,g.useEffect(()=>{a!==void 0&&a!==S.current&&(v(a),$(1))},[a]);const[k,$]=g.useState(c&&c>0?c:1),w=g.useRef(k);w.current=k,g.useEffect(()=>{c!==void 0&&c>0&&c!==w.current&&$(c)},[c]);const z=g.useRef(null),B=g.useCallback(Y=>{var he;$(Y),d==null||d(Y);const J=z.current;J&&J.getBoundingClientRect().top<0&&((he=J.scrollIntoView)==null||he.call(J,{block:"start",behavior:"instant"}))},[d]),[I,N]=g.useState(null),[O,C]=g.useState(null),[T,R]=g.useState(!1),[A,H]=g.useState(""),q=Kn(x).toString(),ne=li(x)>0,L=Kn({...x,sort:""}).toString(),Q=g.useRef({query:n,filterOnlyKey:L,sort:x.sort});g.useEffect(()=>{const Y=Q.current;Y.query!==n||Y.filterOnlyKey!==L?(v("all"),$(1)):Y.sort!==x.sort&&$(1),Q.current={query:n,filterOnlyKey:L,sort:x.sort}},[n,L,x.sort]),g.useEffect(()=>{let Y=!1;return R(!0),H(""),(async()=>{try{let J;if(t.searchAll)J=await t.searchAll(n,Wr,x);else{const he=["work","book","collection","entity"],ze=await Promise.all(he.map(G=>t.search(n,G,{page:1,pageSize:Wr,filters:x})));J={works:ze[0].entries,books:ze[1].entries,collections:ze[2].entries,entities:ze[3].entries,totalWorks:ze[0].total,totalBooks:ze[1].total,totalCollections:ze[2].total,totalEntities:ze[3].total}}Y||N(J)}catch(J){Y||(H(J instanceof Error?J.message:String(J)),N(null))}finally{Y||R(!1)}})(),()=>{Y=!0}},[t,n,q]);const P=b;g.useEffect(()=>{if(b==="all"){C(null);return}let Y=!1;return R(!0),(async()=>{try{const J=await t.search(n,b,{page:k,pageSize:Ti,filters:x});Y||C({key:P,entries:J.entries,total:J.total})}catch(J){Y||(H(J instanceof Error?J.message:String(J)),C(null))}finally{Y||R(!1)}})(),()=>{Y=!0}},[t,n,q,b,k]);const D=O&&O.key===P?O:null;g.useEffect(()=>{if(b==="all"||!D||T)return;const Y=Math.min(D.total,Sn),J=Cp(k,Y,Ti);D.entries.length===0&&Y>0&&J!==k&&($(J),d==null||d(J))},[b,D,T,k]);const pe=g.useMemo(()=>Or.filter(Y=>qt(I,Y)>0),[I]),le=pe.reduce((Y,J)=>Y+qt(I,J),0),fe=pe.some(Y=>qt(I,Y)>=Sn)?`${le.toLocaleString()}+`:le.toLocaleString(),ue=!T&&!A&&I!==null&&le===0,xe=g.useCallback(Y=>{v(Y),$(1),p==null||p(Y)},[p]),Ee=g.useMemo(()=>{const Y=[];return x.dynasty.forEach(J=>Y.push({name:J,remove:()=>r({...x,dynasty:x.dynasty.filter(he=>he!==J)})})),x.classification.forEach(J=>{var he;return Y.push({name:J?((he=si.find(ze=>ze.value===J))==null?void 0:he.label)??J:u.searchPage.unclassified,remove:()=>r({...x,classification:x.classification.filter(ze=>ze!==J)})})}),x.hasImage&&Y.push({name:m.hasImage,remove:()=>r({...x,hasImage:!1})}),x.hasText&&Y.push({name:m.hasText,remove:()=>r({...x,hasText:!1})}),x.hasCollated&&Y.push({name:m.hasCollated,remove:()=>r({...x,hasCollated:!1})}),x.loss&&Y.push({name:`${m.extant}:${u.searchPage.loss[x.loss]}`,remove:()=>r({...x,loss:""})}),Y},[x,r,m,u]),ie={query:n,onEntryLinkClick:s,typeName:l},Ae=Y=>j==="table"?e.jsx(Mr,{entries:Y,...ie}):e.jsx(Br,{entries:Y,...ie}),He=Or.flatMap(Y=>Ni(I,Y));return e.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[e.jsx("style",{children:Np}),f&&e.jsx(Sp,{filters:x,onChange:r}),e.jsxs("div",{className:"bim-sr-main","aria-busy":T,ref:z,children:[pe.length>0&&e.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:[e.jsxs(Hr,{on:b==="all",onClick:()=>xe("all"),children:[u.search.allTab," ",e.jsx("small",{children:fe})]}),pe.map(Y=>e.jsxs(Hr,{on:b===Y,onClick:()=>xe(Y),children:[l(Y)," ",e.jsx("small",{children:Un(qt(I,Y))})]},Y))]}),e.jsxs("div",{className:"bim-sr-tools",children:[f&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":h(m.sortLabel),children:[e.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>r({...x,sort:""}),children:h(m.sortRelevance)}),["era","title"].map(Y=>{const J=x.sort.startsWith(`${Y}:`)?x.sort.endsWith("desc")?"desc":"asc":null,he=Y==="era"?m.sortEra:m.sortTitle,ze=Y==="era"?J==="desc"?m.sortEraDesc:m.sortEraAsc:J==="desc"?m.sortTitleDesc:m.sortTitleAsc;return e.jsxs("button",{type:"button","aria-pressed":J!==null,title:h(ze),onClick:()=>r({...x,sort:`${Y}:${J==="asc"?"desc":"asc"}`}),children:[h(he),J?e.jsxs("span",{"aria-hidden":"true",children:[" ",J==="asc"?"↑":"↓"]}):null]},Y)})]}),e.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),e.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":h(m.viewLabel),children:[e.jsx("button",{type:"button","aria-pressed":j==="table",onClick:()=>_("table"),children:h(m.viewTable)}),e.jsx("button",{type:"button","aria-pressed":j==="card",onClick:()=>_("card"),children:h(m.viewCard)})]})]}),ne&&e.jsxs("div",{className:"bim-sr-chips-row",children:[e.jsx("span",{className:"bim-sr-count",role:"status",children:h(dt(m.filteredCount,{n:fe}))}),Ee.map(Y=>e.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":h(dt(m.removeFilter,{name:Y.name})),onClick:Y.remove,children:[h(Y.name),e.jsx("span",{"aria-hidden":"true",children:"×"})]},Y.name))]}),A&&e.jsx("div",{className:"bim-sr-empty",role:"alert",children:A}),ue&&e.jsx("div",{className:"bim-sr-empty",children:h(ne?m.emptyFiltered:dt(u.search.noResultsFor,{query:n}))}),!A&&!ue&&b==="all"&&I&&(j==="table"?e.jsxs(e.Fragment,{children:[e.jsx(Mr,{entries:He,...ie}),e.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:h(m.limitedNote)})]}):e.jsx(e.Fragment,{children:pe.map(Y=>e.jsxs("section",{style:{marginTop:22},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[e.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,letterSpacing:".1em",display:"flex",alignItems:"center",gap:8},children:[e.jsx(cn,{type:Y,size:8}),l(Y),e.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[Un(qt(I,Y))," ",u.unit.items]})]}),qt(I,Y)>Ni(I,Y).length&&e.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>xe(Y),children:u.action.viewAll})]}),e.jsx(Br,{entries:Ni(I,Y),...ie})]},Y))})),!A&&b!=="all"&&!D&&e.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:u.search.loading}),!A&&b!=="all"&&D&&D.entries.length>0&&e.jsxs(e.Fragment,{children:[Ae(D.entries),e.jsx(zp,{page:k,pageSize:Ti,total:Math.min(D.total,Sn),totalLabel:Un(D.total),onPage:B})]}),!A&&b!=="all"&&D&&D.entries.length===0&&!T&&e.jsxs("div",{className:"bim-sr-empty",children:[h(ne?m.emptyFiltered:dt(u.search.noResultsFor,{query:n})),e.jsx("div",{children:e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>xe("all"),children:u.search.allTab})})]})]})]})};function Hr({on:t,onClick:n,children:o}){return e.jsx("button",{type:"button","aria-pressed":t,onClick:n,style:{border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:14.5,minHeight:44,padding:"8px 12px",letterSpacing:".06em",color:i(t?"ink":"meta-fg"),fontWeight:t?700:400,boxShadow:t?`inset 0 -2px 0 ${i("accent")}`:"none"},children:o})}const en="bim-recent-ids",Fr="bim-recent-entries",Dr=50;function Tt(){try{const t=localStorage.getItem(en);if(t)return JSON.parse(t);const n=localStorage.getItem(Fr);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(en,JSON.stringify(o)),localStorage.removeItem(Fr),o}return[]}catch{return[]}}function Gi(t){try{const n=Tt().filter(o=>o!==t);n.unshift(t),n.length>Dr&&(n.length=Dr),localStorage.setItem(en,JSON.stringify(n))}catch{}}function wl(t){try{const n=Tt().filter(o=>o!==t);localStorage.setItem(en,JSON.stringify(n))}catch{}}function So(){try{localStorage.removeItem(en)}catch{}}async function _o(t,n){var o,r,s;try{if(t.getEntry){const a=await t.getEntry(n);if(a)return a}const l=await t.getItem(n);if(l){const a=l.authors;return{id:n,title:l.title||n,type:l.type||"work",author:(o=a==null?void 0:a[0])==null?void 0:o.name,dynasty:(r=a==null?void 0:a[0])==null?void 0:r.dynasty,role:(s=a==null?void 0:a[0])==null?void 0:s.role,edition:l.edition||void 0}}}catch{}return{id:n,title:n,type:"work",notFound:!0}}const Ei=5,Bp=50,Wp=200,Ur={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Yi=({transport:t,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c,hideModeIndicator:d,resultVariant:u="compact",renderEntry:m,initialQuery:h,onQueryChange:f,headerRight:x,reserveViewportHeight:j=!1,filtersEnabled:y=!1,filters:_=oi,onFiltersChange:b,resultTab:v,onResultTabChange:S,resultPage:k,onResultPageChange:$})=>{const w=$e(),z=[{type:"work",name:w.indexType.work,key:"works"},{type:"book",name:w.indexType.book,key:"books"},{type:"collection",name:w.indexType.collection,key:"collections"},{type:"entity",name:w.indexType.entity,key:"entities"}],B=["work","collection","book","entity"],[I,N]=g.useState(h??""),[O,C]=g.useState(null),[T,R]=g.useState(h??""),A=Kn(_).toString(),[H,q]=g.useState(_);g.useEffect(()=>{q(_)},[A]);const ne=E=>{q(E),b==null||b(E)},[L,Q]=g.useState(null),[P,D]=g.useState("all"),[pe,le]=g.useState(!1),[fe,ue]=g.useState(null),[xe,Ee]=g.useState(""),[ie,Ae]=g.useState(!(h!=null&&h.trim())),[He,Y]=g.useState(Tt),[J,he]=g.useState([]),[ze,G]=g.useState(!1),[ve,ae]=g.useState(!1),[Se,K]=g.useState(null),[Ce,Pe]=g.useState(null),M=g.useRef(void 0),ee=g.useRef(!1),be=g.useCallback(async(E,oe)=>{if(!E.trim()){Ae(!0),C(null),Q(null);return}if(Ae(!1),y){R(E);return}le(!0),Ee("");try{if(t.searchAll){const se=await t.searchAll(E,oe??Ei);C(se)}else{const se=["work","book","collection","entity"],je=await Promise.all(se.map(ke=>t.search(E,ke,{page:1,pageSize:oe??Ei})));C({works:je[0].entries,books:je[1].entries,collections:je[2].entries,entities:je[3].entries,totalWorks:je[0].total,totalBooks:je[1].total,totalCollections:je[2].total,totalEntities:je[3].total})}}catch(se){Ee(se instanceof Error?se.message:String(se)),C(null)}finally{le(!1)}},[t,y]);g.useEffect(()=>{let E=!1;const oe=()=>{var V,ce;const se=["work","book","collection","entity"],je=Promise.all(se.map(Te=>t.loadEntries(Te,{page:1,pageSize:1}).catch(()=>({total:0})))),ke=((V=t.getResourceCounts)==null?void 0:V.call(t).catch(()=>null))??Promise.resolve(null),ge=((ce=t.getSubtypeStats)==null?void 0:ce.call(t).catch(()=>null))??Promise.resolve(null);Promise.all([je,ke,ge]).then(([Te,Ie,U])=>{E||(K({works:Te[0].total,books:Te[1].total,collections:Te[2].total,entities:Te[3].total,hasText:Ie==null?void 0:Ie.hasText,hasImage:Ie==null?void 0:Ie.hasImage}),U&&Pe(U))})};return t.getCounts?t.getCounts().then(se=>{var je,ke;E||(K({works:se.works,books:se.books,collections:se.collections,entities:se.entities,hasText:(je=se.resourceCounts)==null?void 0:je.hasText,hasImage:(ke=se.resourceCounts)==null?void 0:ke.hasImage}),se.subtypeStats&&Pe(se.subtypeStats))}).catch(()=>{E||oe()}):oe(),()=>{E=!0}},[t]),g.useEffect(()=>{ee.current||!(h!=null&&h.trim())||(ee.current=!0,be(h))},[h,be]);const W=g.useCallback(E=>{if(N(E),!E.trim()){f==null||f(E),Ae(!0),C(null),Q(null),D("all");return}M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{Q(null),D("all"),f==null||f(E),be(E)},Wp)},[be,f]),re=g.useCallback(E=>{M.current&&clearTimeout(M.current),D("all"),f==null||f(E),be(E)},[be,f]),te=g.useCallback(E=>{Q(E),be(I,Bp)},[I,be]);g.useEffect(()=>{if(!He.length){he([]);return}let E=!1;return G(!0),Promise.all(He.slice(0,10).map(oe=>_o(t,oe))).then(oe=>{E||(he(oe),G(!1))}),()=>{E=!0}},[He,t]);const me=E=>{ue(E.id),Gi(E.id),Y(Tt()),r==null||r(E)},Ne=(E,oe)=>{if(r&&Hp(oe)){oe.preventDefault(),me(E);return}Gi(E.id),Y(Tt())},Me=E=>{wl(E),Y(Tt())},Be=()=>{So(),Y([])},Fe=E=>z.find(oe=>oe.type===E),Ze=!ie&&!O&&!xe,de=O&&(O.works.length>0||O.books.length>0||O.collections.length>0),Qe=e.jsxs(e.Fragment,{children:[e.jsx(ml,{transport:t,value:I,onChange:W,onSearch:re,onEntrySelect:me}),y&&e.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const E=I.trim();E&&ul(E),re(I)},children:w.searchPage.submit}),s&&e.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${i("primary")}`,borderRadius:"6px",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"13px"},children:w.action.newEntry})]});return e.jsxs("div",{className:"bim-browser-container",style:j?{minHeight:"100svh"}:void 0,children:[e.jsx("style",{children:Fp+(y?Dp:"")}),(!y||x||!d)&&e.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[y?e.jsx("span",{}):e.jsx("h1",{style:{margin:0,fontSize:"18px",color:i("fg")},children:w.browser.title}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!d&&e.jsx(pl,{variant:"index-browser",indexSource:n,syncConfig:o,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c})]})]})}),y?e.jsxs("div",{className:"bim-ib-bar","data-nofilters":t.supportsSearchFilters?void 0:"true",children:[e.jsx("span",{"aria-hidden":"true"}),e.jsx("div",{className:"bim-ib-bar-main",children:Qe})]}):e.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:Qe}),ie&&e.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:Se&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:Ce?e.jsxs(e.Fragment,{children:[(Ce.book??0)>0&&e.jsxs(e.Fragment,{children:[w.searchPage.statBook," ",e.jsx("strong",{style:{color:i("fg")},children:Ce.book.toLocaleString()})," ",w.unit.bu,w.searchPage.statComma,e.jsx("strong",{style:{color:i("fg")},children:Se.books.toLocaleString()})," ",w.searchPage.statBookCopies]}),Ce.article?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),w.searchPage.statArticle," ",e.jsx("strong",{style:{color:i("fg")},children:Ce.article.toLocaleString()})," ",w.searchPage.statArticleUnit]}):null,Ce.poem?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),w.searchPage.statPoem," ",e.jsx("strong",{style:{color:i("fg")},children:Ce.poem.toLocaleString()})," ",w.searchPage.statPoemUnit]}):null,e.jsx("span",{style:{margin:"0 6px"},children:"·"}),w.searchPage.statCollection," ",e.jsx("strong",{style:{color:i("fg")},children:Se.collections.toLocaleString()})]}):e.jsxs(e.Fragment,{children:[w.indexType.work," ",e.jsx("strong",{style:{color:i("fg")},children:Se.works.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),w.indexType.book," ",e.jsx("strong",{style:{color:i("fg")},children:Se.books.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),w.indexType.collection," ",e.jsx("strong",{style:{color:i("fg")},children:Se.collections.toLocaleString()}),Se.entities>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{margin:"0 6px"},children:"·"}),w.indexType.entity," ",e.jsx("strong",{style:{color:i("fg")},children:Se.entities.toLocaleString()})]})]})}),Se.hasImage!=null&&Se.hasText!=null&&e.jsxs("span",{children:[w.resourceType.image," ",e.jsx("strong",{style:{color:i("fg")},children:Se.hasImage.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),w.resourceType.text," ",e.jsx("strong",{style:{color:i("fg")},children:Se.hasText.toLocaleString()})]})]})}),y&&!ie&&e.jsx(kl,{transport:t,query:T,filters:H,onFiltersChange:ne,onEntryLinkClick:Ne,typeName:E=>Fe(E).name,tab:v,onTabChange:S,page:k,onPageChange:$}),!(y&&!ie)&&e.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:pe||Ze?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:Op,boxSizing:"border-box"},children:w.search.searching}):xe?e.jsx("div",{style:{textAlign:"center",padding:"40px"},children:e.jsx("p",{style:{color:i("desc-fg")},children:xe})}):ie?e.jsx("div",{style:{flex:1},children:ze?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:w.search.loading}):J.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{children:w.search.recentBrowse}),e.jsx("button",{onClick:Be,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:w.search.clearRecent})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:J.slice(0,ve?10:3).map(E=>E.notFound?e.jsx(Yp,{id:E.id,onRemove:Me,t:w},E.id):e.jsx(Vr,{entry:E,selected:fe===E.id,onClick:Ne,getConfig:Fe,onRemove:Me},E.id))}),!ve&&J.length>3&&e.jsx("button",{onClick:()=>ae(!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:w.action.expandMore})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:w.search.searchTitle}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:w.search.searchSubtitle})]})}):de?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsx("style",{children:Up}),(()=>{const E=ge=>O[Ur[ge]]??0,oe=B.map(ge=>z.find(V=>V.type===ge)).filter(ge=>E(ge.key)>0);if(oe.length<2)return null;const se=oe.reduce((ge,V)=>ge+E(V.key),0),je=ge=>{if(D(ge),ge!=="all"&&L!==ge){const V=z.find(Te=>Te.type===ge),ce=(O[V.key]??[]).length;E(V.key)>ce&&te(ge)}},ke=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 e.jsxs("div",{role:"group","aria-label":w.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs("button",{type:"button","aria-pressed":P==="all",style:ke(P==="all"),onClick:()=>je("all"),children:[w.search.allTab," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:se.toLocaleString()})]}),oe.map(ge=>e.jsxs("button",{type:"button","aria-pressed":P===ge.type,style:ke(P===ge.type),onClick:()=>je(ge.type),children:[ge.name," ",e.jsx("span",{style:{fontSize:12,fontWeight:400},children:E(ge.key).toLocaleString()})]},ge.type))]})})(),z.map(({type:E,name:oe,key:se})=>{const je=O[se]??[],ke=Ur[se],ge=O[ke]??0;if(je.length===0||P!=="all"&&P!==E)return null;const ce=P==="all"&&!(L===E)&&ge>Ei;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[e.jsx(cn,{type:E})," ",oe,e.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[ge," ",w.unit.items]})]}),ce&&e.jsx("button",{className:"bim-ib-viewall",onClick:()=>te(E),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:w.action.viewAll})]}),e.jsx("div",{style:u==="list"?{display:"flex",flexDirection:"column",gap:0}:u==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:je.map(Te=>{if(m)return e.jsx(g.Fragment,{children:m(Te)},Te.id);const Ie=u==="card"?Gp:Vr;return e.jsx(Ie,{entry:Te,selected:fe===Te.id,onClick:Ne,getConfig:Fe,query:I},Te.id)})})]},E)})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:dt(w.search.noResultsFor,{query:I})}),e.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:w.search.tryOther})]})})]})},Op=240;function Hp(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}const Fp=`
|
|
120
|
+
`,Io="bim-search-view",Mi=50,Jr=5,Cn=1e3;function Xn(e){return e>=Cn?`${Cn.toLocaleString()}+`:e.toLocaleString()}const Xp={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function Zp(e){return e&&Xp[e.toLowerCase()]||"all"}function Jp(e){return e==="all"?null:e}const Qr=["work","collection","book","entity"],Qp={work:"works",collection:"collections",book:"books",entity:"entities"},eu={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function tu(){try{return window.localStorage.getItem(Io)==="card"?"card":"table"}catch{return"table"}}function nu(e){try{window.localStorage.setItem(Io,e)}catch{}}const Jt=(e,n)=>(e==null?void 0:e[eu[n]])??0,Bi=(e,n)=>(e==null?void 0:e[Qp[n]])??[],Ma=({transport:e,query:n,filters:o,onFiltersChange:r,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const u=$e(),h=u.searchV4,{convert:m}=Ie(),f=!!e.supportsSearchFilters,x=g.useMemo(()=>f?o:pi,[f,o]),[k,y]=g.useState("table");g.useEffect(()=>{y(tu())},[]);const _=q=>{y(q),nu(q)},[b,j]=g.useState(l??"all"),w=g.useRef(b);w.current=b,g.useEffect(()=>{l!==void 0&&l!==w.current&&(j(l),$(1))},[l]);const[v,$]=g.useState(c&&c>0?c:1),S=g.useRef(v);S.current=v,g.useEffect(()=>{c!==void 0&&c>0&&c!==S.current&&$(c)},[c]);const C=g.useRef(null),B=g.useCallback(q=>{var fe;$(q),p==null||p(q);const Q=C.current;Q&&Q.getBoundingClientRect().top<0&&((fe=Q.scrollIntoView)==null||fe.call(Q,{block:"start",behavior:"instant"}))},[p]),[T,z]=g.useState(null),[F,N]=g.useState(null),[R,O]=g.useState(!1),[I,P]=g.useState(""),G=ti(x).toString(),K=hi(x)>0,L=ti({...x,sort:""}).toString(),Z=g.useRef({query:n,filterOnlyKey:L,sort:x.sort});g.useEffect(()=>{const q=Z.current;q.query!==n||q.filterOnlyKey!==L?(j("all"),$(1)):q.sort!==x.sort&&$(1),Z.current={query:n,filterOnlyKey:L,sort:x.sort}},[n,L,x.sort]),g.useEffect(()=>{let q=!1;return O(!0),P(""),(async()=>{try{let Q;if(e.searchAll)Q=await e.searchAll(n,Jr,x);else{const fe=["work","book","collection","entity"],ze=await Promise.all(fe.map(Y=>e.search(n,Y,{page:1,pageSize:Jr,filters:x})));Q={works:ze[0].entries,books:ze[1].entries,collections:ze[2].entries,entities:ze[3].entries,totalWorks:ze[0].total,totalBooks:ze[1].total,totalCollections:ze[2].total,totalEntities:ze[3].total}}q||z(Q)}catch(Q){q||(P(Q instanceof Error?Q.message:String(Q)),z(null))}finally{q||O(!1)}})(),()=>{q=!0}},[e,n,G]);const A=b;g.useEffect(()=>{if(b==="all"){N(null);return}let q=!1;return O(!0),(async()=>{try{const Q=await e.search(n,b,{page:v,pageSize:Mi,filters:x});q||N({key:A,entries:Q.entries,total:Q.total})}catch(Q){q||(P(Q instanceof Error?Q.message:String(Q)),N(null))}finally{q||O(!1)}})(),()=>{q=!0}},[e,n,G,b,v]);const U=F&&F.key===A?F:null;g.useEffect(()=>{if(b==="all"||!U||R)return;const q=Math.min(U.total,Cn),Q=Gp(v,q,Mi);U.entries.length===0&&q>0&&Q!==v&&($(Q),p==null||p(Q))},[b,U,R,v]);const ce=g.useMemo(()=>Qr.filter(q=>Jt(T,q)>0),[T]),ee=ce.reduce((q,Q)=>q+Jt(T,Q),0),ue=ce.some(q=>Jt(T,q)>=Cn)?`${ee.toLocaleString()}+`:ee.toLocaleString(),de=!R&&!I&&T!==null&&ee===0,be=g.useCallback(q=>{j(q),$(1),d==null||d(q)},[d]),Oe=g.useMemo(()=>{const q=[];return x.dynasty.forEach(Q=>q.push({name:Q,remove:()=>r({...x,dynasty:x.dynasty.filter(fe=>fe!==Q)})})),x.classification.forEach(Q=>{var fe;return q.push({name:Q?((fe=mi.find(ze=>ze.value===Q))==null?void 0:fe.label)??Q:u.searchPage.unclassified,remove:()=>r({...x,classification:x.classification.filter(ze=>ze!==Q)})})}),x.hasImage&&q.push({name:h.hasImage,remove:()=>r({...x,hasImage:!1})}),x.hasText&&q.push({name:h.hasText,remove:()=>r({...x,hasText:!1})}),x.hasCollated&&q.push({name:h.hasCollated,remove:()=>r({...x,hasCollated:!1})}),x.loss&&q.push({name:`${h.extant}:${u.searchPage.loss[x.loss]}`,remove:()=>r({...x,loss:""})}),q},[x,r,h,u]),ie={query:n,onEntryLinkClick:s,typeName:a},Re=q=>k==="table"?t.jsx(Xr,{entries:q,...ie}):t.jsx(Zr,{entries:q,...ie}),Le=Qr.flatMap(q=>Bi(T,q));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":f?void 0:"true",children:[t.jsx("style",{children:qp}),f&&t.jsx(Dp,{filters:x,onChange:r}),t.jsxs("div",{className:"bim-sr-main","aria-busy":R,ref:C,children:[ce.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(es,{on:b==="all",onClick:()=>be("all"),children:[u.search.allTab," ",t.jsx("small",{children:ue})]}),ce.map(q=>t.jsxs(es,{on:b===q,onClick:()=>be(q),children:[a(q)," ",t.jsx("small",{children:Xn(Jt(T,q))})]},q))]}),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":m(h.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>r({...x,sort:""}),children:m(h.sortRelevance)}),["era","title"].map(q=>{const Q=x.sort.startsWith(`${q}:`)?x.sort.endsWith("desc")?"desc":"asc":null,fe=q==="era"?h.sortEra:h.sortTitle,ze=q==="era"?Q==="desc"?h.sortEraDesc:h.sortEraAsc:Q==="desc"?h.sortTitleDesc:h.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":Q!==null,title:m(ze),onClick:()=>r({...x,sort:`${q}:${Q==="asc"?"desc":"asc"}`}),children:[m(fe),Q?t.jsxs("span",{"aria-hidden":"true",children:[" ",Q==="asc"?"↑":"↓"]}):null]},q)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":m(h.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":k==="table",onClick:()=>_("table"),children:m(h.viewTable)}),t.jsx("button",{type:"button","aria-pressed":k==="card",onClick:()=>_("card"),children:m(h.viewCard)})]})]}),K&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:m(dt(h.filteredCount,{n:ue}))}),Oe.map(q=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":m(dt(h.removeFilter,{name:q.name})),onClick:q.remove,children:[m(q.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},q.name))]}),I&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:I}),de&&t.jsx("div",{className:"bim-sr-empty",children:m(K?h.emptyFiltered:dt(u.search.noResultsFor,{query:n}))}),!I&&!de&&b==="all"&&T&&(k==="table"?t.jsxs(t.Fragment,{children:[t.jsx(Xr,{entries:Le,...ie}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:m(h.limitedNote)})]}):t.jsx(t.Fragment,{children:ce.map(q=>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(un,{type:q,size:8}),a(q),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:i("meta-fg")},children:[Xn(Jt(T,q))," ",u.unit.items]})]}),Jt(T,q)>Bi(T,q).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>be(q),children:u.action.viewAll})]}),t.jsx(Zr,{entries:Bi(T,q),...ie})]},q))})),!I&&b!=="all"&&!U&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:u.search.loading}),!I&&b!=="all"&&U&&U.entries.length>0&&t.jsxs(t.Fragment,{children:[Re(U.entries),t.jsx(Yp,{page:v,pageSize:Mi,total:Math.min(U.total,Cn),totalLabel:Xn(U.total),onPage:B})]}),!I&&b!=="all"&&U&&U.entries.length===0&&!R&&t.jsxs("div",{className:"bim-sr-empty",children:[m(K?h.emptyFiltered:dt(u.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>be("all"),children:u.search.allTab})})]})]})]})};function es({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 on="bim-recent-ids",ts="bim-recent-entries",ns=50;function Rt(){try{const e=localStorage.getItem(on);if(e)return JSON.parse(e);const n=localStorage.getItem(ts);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(on,JSON.stringify(o)),localStorage.removeItem(ts),o}return[]}catch{return[]}}function to(e){try{const n=Rt().filter(o=>o!==e);n.unshift(e),n.length>ns&&(n.length=ns),localStorage.setItem(on,JSON.stringify(n))}catch{}}function Ba(e){try{const n=Rt().filter(o=>o!==e);localStorage.setItem(on,JSON.stringify(n))}catch{}}function Ro(){try{localStorage.removeItem(on)}catch{}}async function Lo(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 Wi=5,iu=50,ou=200,is={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},no=({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:h,initialQuery:m,onQueryChange:f,headerRight:x,reserveViewportHeight:k=!1,filtersEnabled:y=!1,filters:_=pi,onFiltersChange:b,resultTab:j,onResultTabChange:w,resultPage:v,onResultPageChange:$})=>{const S=$e(),C=[{type:"work",name:S.indexType.work,key:"works"},{type:"book",name:S.indexType.book,key:"books"},{type:"collection",name:S.indexType.collection,key:"collections"},{type:"entity",name:S.indexType.entity,key:"entities"}],B=["work","collection","book","entity"],[T,z]=g.useState(m??""),[F,N]=g.useState(null),[R,O]=g.useState(m??""),I=ti(_).toString(),[P,G]=g.useState(_);g.useEffect(()=>{G(_)},[I]);const K=E=>{G(E),b==null||b(E)},[L,Z]=g.useState(null),[A,U]=g.useState("all"),[ce,ee]=g.useState(!1),[ue,de]=g.useState(null),[be,Oe]=g.useState(""),[ie,Re]=g.useState(!(m!=null&&m.trim())),[Le,q]=g.useState(Rt),[Q,fe]=g.useState([]),[ze,Y]=g.useState(!1),[ve,le]=g.useState(!1),[Se,X]=g.useState(null),[Ce,Me]=g.useState(null),M=g.useRef(void 0),te=g.useRef(!1),ye=g.useCallback(async(E,oe)=>{if(!E.trim()){Re(!0),N(null),Z(null);return}if(Re(!1),y){O(E);return}ee(!0),Oe("");try{if(e.searchAll){const ae=await e.searchAll(E,oe??Wi);N(ae)}else{const ae=["work","book","collection","entity"],je=await Promise.all(ae.map(ke=>e.search(E,ke,{page:1,pageSize:oe??Wi})));N({works:je[0].entries,books:je[1].entries,collections:je[2].entries,entities:je[3].entries,totalWorks:je[0].total,totalBooks:je[1].total,totalCollections:je[2].total,totalEntities:je[3].total})}}catch(ae){Oe(ae instanceof Error?ae.message:String(ae)),N(null)}finally{ee(!1)}},[e,y]);g.useEffect(()=>{let E=!1;const oe=()=>{var V,pe;const ae=["work","book","collection","entity"],je=Promise.all(ae.map(Te=>e.loadEntries(Te,{page:1,pageSize:1}).catch(()=>({total:0})))),ke=((V=e.getResourceCounts)==null?void 0:V.call(e).catch(()=>null))??Promise.resolve(null),xe=((pe=e.getSubtypeStats)==null?void 0:pe.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([je,ke,xe]).then(([Te,Ee,D])=>{E||(X({works:Te[0].total,books:Te[1].total,collections:Te[2].total,entities:Te[3].total,hasText:Ee==null?void 0:Ee.hasText,hasImage:Ee==null?void 0:Ee.hasImage}),D&&Me(D))})};return e.getCounts?e.getCounts().then(ae=>{var je,ke;E||(X({works:ae.works,books:ae.books,collections:ae.collections,entities:ae.entities,hasText:(je=ae.resourceCounts)==null?void 0:je.hasText,hasImage:(ke=ae.resourceCounts)==null?void 0:ke.hasImage}),ae.subtypeStats&&Me(ae.subtypeStats))}).catch(()=>{E||oe()}):oe(),()=>{E=!0}},[e]),g.useEffect(()=>{te.current||!(m!=null&&m.trim())||(te.current=!0,ye(m))},[m,ye]);const H=g.useCallback(E=>{if(z(E),!E.trim()){f==null||f(E),Re(!0),N(null),Z(null),U("all");return}M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{Z(null),U("all"),f==null||f(E),ye(E)},ou)},[ye,f]),se=g.useCallback(E=>{M.current&&clearTimeout(M.current),U("all"),f==null||f(E),ye(E)},[ye,f]),ne=g.useCallback(E=>{Z(E),ye(T,iu)},[T,ye]);g.useEffect(()=>{if(!Le.length){fe([]);return}let E=!1;return Y(!0),Promise.all(Le.slice(0,10).map(oe=>Lo(e,oe))).then(oe=>{E||(fe(oe),Y(!1))}),()=>{E=!0}},[Le,e]);const ge=E=>{de(E.id),to(E.id),q(Rt()),r==null||r(E)},Ne=(E,oe)=>{if(r&&su(oe)){oe.preventDefault(),ge(E);return}to(E.id),q(Rt())},Be=E=>{Ba(E),q(Rt())},We=()=>{Ro(),q([])},Ue=E=>C.find(oe=>oe.type===E),Je=!ie&&!F&&!be,me=F&&(F.works.length>0||F.books.length>0||F.collections.length>0),et=t.jsxs(t.Fragment,{children:[t.jsx(za,{transport:e,value:T,onChange:H,onSearch:se,onEntrySelect:ge}),y&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const E=T.trim();E&&Ca(E),se(T)},children:S.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:S.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:k?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:au+(y?lu:"")}),(!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:S.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx($a,{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:et})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:et}),ie&&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:Se&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:Ce?t.jsxs(t.Fragment,{children:[(Ce.book??0)>0&&t.jsxs(t.Fragment,{children:[S.searchPage.statBook," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.book.toLocaleString()})," ",S.unit.bu,S.searchPage.statComma,t.jsx("strong",{style:{color:i("fg")},children:Se.books.toLocaleString()})," ",S.searchPage.statBookCopies]}),Ce.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statArticle," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.article.toLocaleString()})," ",S.searchPage.statArticleUnit]}):null,Ce.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statPoem," ",t.jsx("strong",{style:{color:i("fg")},children:Ce.poem.toLocaleString()})," ",S.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statCollection," ",t.jsx("strong",{style:{color:i("fg")},children:Se.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[S.indexType.work," ",t.jsx("strong",{style:{color:i("fg")},children:Se.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.book," ",t.jsx("strong",{style:{color:i("fg")},children:Se.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.collection," ",t.jsx("strong",{style:{color:i("fg")},children:Se.collections.toLocaleString()}),Se.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.entity," ",t.jsx("strong",{style:{color:i("fg")},children:Se.entities.toLocaleString()})]})]})}),Se.hasImage!=null&&Se.hasText!=null&&t.jsxs("span",{children:[S.resourceType.image," ",t.jsx("strong",{style:{color:i("fg")},children:Se.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.resourceType.text," ",t.jsx("strong",{style:{color:i("fg")},children:Se.hasText.toLocaleString()})]})]})}),y&&!ie&&t.jsx(Ma,{transport:e,query:R,filters:P,onFiltersChange:K,onEntryLinkClick:Ne,typeName:E=>Ue(E).name,tab:j,onTabChange:w,page:v,onPageChange:$}),!(y&&!ie)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ce||Je?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:ru,boxSizing:"border-box"},children:S.search.searching}):be?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:i("desc-fg")},children:be})}):ie?t.jsx("div",{style:{flex:1},children:ze?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:S.search.loading}):Q.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:S.search.recentBrowse}),t.jsx("button",{onClick:We,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:S.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:Q.slice(0,ve?10:3).map(E=>E.notFound?t.jsx(uu,{id:E.id,onRemove:Be,t:S},E.id):t.jsx(os,{entry:E,selected:ue===E.id,onClick:Ne,getConfig:Ue,onRemove:Be},E.id))}),!ve&&Q.length>3&&t.jsx("button",{onClick:()=>le(!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:S.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:S.search.searchTitle}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:S.search.searchSubtitle})]})}):me?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:cu}),(()=>{const E=xe=>F[is[xe]]??0,oe=B.map(xe=>C.find(V=>V.type===xe)).filter(xe=>E(xe.key)>0);if(oe.length<2)return null;const ae=oe.reduce((xe,V)=>xe+E(V.key),0),je=xe=>{if(U(xe),xe!=="all"&&L!==xe){const V=C.find(Te=>Te.type===xe),pe=(F[V.key]??[]).length;E(V.key)>pe&&ne(xe)}},ke=xe=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(xe?"fg":"desc-fg"),fontWeight:xe?700:400,boxShadow:xe?`inset 0 -2px 0 ${i("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":S.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":A==="all",style:ke(A==="all"),onClick:()=>je("all"),children:[S.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:ae.toLocaleString()})]}),oe.map(xe=>t.jsxs("button",{type:"button","aria-pressed":A===xe.type,style:ke(A===xe.type),onClick:()=>je(xe.type),children:[xe.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:E(xe.key).toLocaleString()})]},xe.type))]})})(),C.map(({type:E,name:oe,key:ae})=>{const je=F[ae]??[],ke=is[ae],xe=F[ke]??0;if(je.length===0||A!=="all"&&A!==E)return null;const pe=A==="all"&&!(L===E)&&xe>Wi;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(un,{type:E})," ",oe,t.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[xe," ",S.unit.items]})]}),pe&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>ne(E),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:S.action.viewAll})]}),t.jsx("div",{style:u==="list"?{display:"flex",flexDirection:"column",gap:0}:u==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:je.map(Te=>{if(h)return t.jsx(g.Fragment,{children:h(Te)},Te.id);const Ee=u==="card"?pu:os;return t.jsx(Ee,{entry:Te,selected:ue===Te.id,onClick:Ne,getConfig:Ue,query:T},Te.id)})})]},E)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:dt(S.search.noResultsFor,{query:T})}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:S.search.tryOther})]})})]})},ru=240;function su(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const au=`
|
|
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
|
+
`,lu=`
|
|
124
124
|
.bim-ib-bar { display: grid; grid-template-columns: 208px minmax(0, 1fr); column-gap: 40px; padding: 0 20px 16px; }
|
|
125
125
|
.bim-ib-bar[data-nofilters] { grid-template-columns: minmax(0, 1fr); }
|
|
126
126
|
.bim-ib-bar[data-nofilters] > [aria-hidden] { display: none; }
|
|
@@ -135,26 +135,26 @@
|
|
|
135
135
|
.bim-ib-bar-main { max-width: none; }
|
|
136
136
|
.bim-ib-submit { min-height: 44px; padding: 0 16px; }
|
|
137
137
|
}
|
|
138
|
-
`,
|
|
138
|
+
`,cu=`
|
|
139
139
|
@media (max-width: 719px), (pointer: coarse) {
|
|
140
140
|
.bim-ib-viewall { position: relative; }
|
|
141
141
|
.bim-ib-viewall::after {
|
|
142
142
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
143
143
|
width: max(calc(100% + 8px), 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
|
|
144
144
|
}
|
|
145
|
-
}`,Sl={color:"inherit",textDecoration:"none"},Vp=({snippet:t})=>{const{convert:n}=Re();return e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:fo(t).map((o,r)=>o.marked?e.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):e.jsx(g.Fragment,{children:n(o.text)},r))})},Gp=({entry:t,selected:n,onClick:o,getConfig:r,query:s})=>{const l=$e(),{convert:a}=Re(),p=a(t.title||t.primary_name||t.id),c=t.measure_info?a(t.measure_info):t.juan_count!=null&&t.juan_count>0?`${t.juan_count}${l.unit.juan}`:"",d=[...t.additional_titles||[],...t.attached_texts||[]],u=s&&d.length?d.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=i("cover-accent"),h=Ke();return e.jsxs("a",{href:h(t.id),onClick:f=>o(t,f),className:"bim-result-card",style:{...Sl,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:i("bg"),border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[e.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${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:[e.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${m} 45%, transparent)`}}),e.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:m},children:Array.from(p).map((f,x)=>e.jsx("span",{children:f},x))})]}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:p}),c&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg")},children:[t.dynasty&&e.jsxs("span",{children:["〔",a(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:a(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",a(t.role)]})]}),(t.era||t.edition)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[t.era&&e.jsxs("span",{children:["〔",a(t.era),"〕"]}),t.edition&&e.jsx("span",{children:a(t.edition)})]}),u&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[l.search.alias,":",a(typeof u=="string"?u:u.book_title||"")]}),t.descriptionSnippet&&e.jsx(Vp,{snippet:t.descriptionSnippet}),e.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[e.jsx(cn,{type:t.type,size:8})," ",r(t.type).name]}),t.has_text&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.textResource}),t.has_image&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.imageResource})]})]})]})},Vr=({entry:t,selected:n,onClick:o,getConfig:r,query:s,onRemove:l})=>{const a=$e(),{convert:p}=Re(),c=[...t.additional_titles||[],...t.attached_texts||[]],d=s&&c.length?c.find(m=>{const h=typeof m=="string"?m:m==null?void 0:m.book_title;return h==null?void 0:h.toLowerCase().includes(s.toLowerCase())}):void 0,u=Ke();return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("a",{href:u(t.id),onClick:m=>o(t,m),className:"bim-result-card",style:{...Sl,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:l?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[e.jsx(cn,{type:t.type,size:12}),e.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(t.type).name})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:p(t.title||t.primary_name||t.id)}),e.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[t.has_text&&e.jsx("span",{children:a.misc.textResource}),t.has_image&&e.jsx("span",{children:a.misc.imageResource})]}),(t.era||t.edition)&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.era&&e.jsxs(e.Fragment,{children:["〔",p(t.era),"〕"]}),t.edition&&p(t.edition)]}),t.measure_info?e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:p(t.measure_info)}):t.juan_count!=null&&t.juan_count>0?e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[t.juan_count,a.unit.juan]}):null]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px"},children:[t.dynasty&&e.jsxs("span",{children:["〔",p(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:p(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",p(t.role)]}),t.type==="entity"&&(t.birth_year!=null||t.death_year!=null)&&e.jsxs("span",{style:{marginLeft:t.dynasty?"4px":0},children:[t.birth_year??"?","—",t.death_year??"?"]})]}),d&&e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:[a.search.alias,":",p(d)]})]}),!l&&e.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),l&&e.jsx("button",{type:"button",onClick:()=>l(t.id),title:a.search.removeFromRecent,"aria-label":a.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},Yp=({id:t,onRemove:n,t:o})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${i("widget-border")}`,background:i("input-bg"),opacity:.6},children:[e.jsx("span",{style:{fontSize:"16px"},children:"❓"}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:"13px",color:i("fg"),fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),e.jsx("button",{onClick:()=>n(t),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function Kp(t){var n;return!t.dynasty&&!t.birth_year&&!t.death_year&&(!t.alt_names||t.alt_names.length===0)&&!((n=t.description)!=null&&n.text)}function qp({data:t}){const{convert:n}=Re(),{dynasty:o,birth_year:r,death_year:s}=t,l=[];return o&&l.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?l.push(`${r}—${s}`):r!==void 0?l.push(`${r}—?`):s!==void 0&&l.push(`?—${s}`),l.length===0?null:e.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:l.join(" ")})}function Xp({alt_names:t}){const{convert:n}=Re(),o=new Map;for(const l of t){const a=l.type||"別名";o.has(a)||o.set(a,[]),o.get(a).push(l.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((l,a)=>{const p=r.indexOf(l),c=r.indexOf(a);return p===-1&&c===-1?0:p===-1?1:c===-1?-1:p-c});return e.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(l=>{const a=o.get(l);return e.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:n(l)}),e.jsx("span",{children:a.map((p,c)=>e.jsxs("span",{children:[c>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),n(p)]},c))})]},l)})})}function Zp({data:t}){const n=$e(),o=t.external_ids;if(!o)return null;const r=[];return o.cbdb_id&&r.push(e.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${o.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:i("link-fg"),border:`1px solid ${i("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${i("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",o.cbdb_id]},"cbdb")),r.length===0?null:e.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:r})}function Jp({works:t,transport:n,onNavigate:o,renderLink:r}){const s=$e(),{convert:l}=Re(),a=Ke(),[p,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let h=!1;const f=t.map(j=>j.work_id);return(async()=>{const j=new Map;if(n.getEntriesByIds)try{const v=await n.getEntriesByIds(f);let S=!0;for(let k=0;k<f.length;k++){const $=v[k];$!=null&&$.title?j.set(f[k],$.title):$!=null&&$.primary_name?j.set(f[k],$.primary_name):S=!1}if(S)return j}catch{}const y=[...f],_=8,b=new Array(_).fill(0).map(async()=>{for(;y.length;){const v=y.shift();if(!v)break;if(!j.has(v))try{if(n.getEntry){const $=await n.getEntry(v);if($!=null&&$.title){j.set(v,$.title);continue}}const S=await n.getItem(v),k=S&&(S.title||S.primary_name)||v;j.set(v,k)}catch{j.set(v,v)}}});return await Promise.all(b),j})().then(j=>{h||c(j)}),()=>{h=!0}},[t,n]);const d=new Map;for(const h of t){const f=h.role||"";d.has(f)||d.set(f,[]),d.get(f).push(h)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...d.keys()].sort((h,f)=>{const x=u.indexOf(h),j=u.indexOf(f);return x===-1&&j===-1?h.localeCompare(f):x===-1?1:j===-1?-1:x-j});return e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:i("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[s.label.relatedWorks," ",e.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",t.length,")"]})]}),m.map(h=>{const f=d.get(h);return e.jsxs("div",{style:{marginBottom:"8px"},children:[h&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[l(h)," ",e.jsxs("span",{style:{color:i("desc-fg")},children:["(",f.length,")"]})]}),e.jsx("ul",{style:{margin:0,paddingLeft:h?"16px":"0",listStyle:h?"disc":"none",fontSize:"14px",lineHeight:1.8},children:f.map((x,j)=>{const y=l(p.get(x.work_id)||x.work_id);return r?e.jsx("li",{children:r(x.work_id,y)},j):o?e.jsx("li",{children:e.jsx("a",{href:a(x.work_id),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),o(x.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},j):e.jsx("li",{children:y},j)})})]},h)})]})}const _l=({data:t,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:l})=>{var m;const a=$e(),{convert:p}=Re();let c=!1;try{c=we.extractStatus(t.id)==="draft"}catch{}const d=Kp(t),u=t.subtype&&t.subtype in a.common.entitySubtype?a.common.entitySubtype[t.subtype]:p(t.subtype);return e.jsxs("div",{children:[!l&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[e.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:i("fg")},children:[p(t.primary_name),e.jsx(qp,{data:t})]}),s]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:i("type-entity"),border:`1px solid color-mix(in srgb, ${i("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${i("type-entity")} 3%, transparent)`},children:a.indexType.entity}),u&&t.subtype!=="people"&&e.jsx("span",{children:u}),c&&e.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("warn-fg")},children:a.status.draft}),e.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:t.id})]})]}),d&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:i("widget-bg"),border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:a.common.entityPlaceholderNote}),t.alt_names&&t.alt_names.length>0&&e.jsx(Xp,{alt_names:t.alt_names}),e.jsx(Zp,{data:t}),((m=t.description)==null?void 0:m.text)&&e.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:p(t.description.text)}),t.works&&t.works.length>0&&e.jsx(Jp,{works:t.works,transport:n,onNavigate:o,renderLink:r})]})},Qp=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function eu(t){const n=t.search(Qp);return n<0?[t,""]:[t.slice(0,n),t.slice(n)]}const $l={p:({children:t})=>e.jsx("p",{style:{margin:"0 0 0.5em"},children:t}),ul:({children:t})=>e.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:t}),ol:({children:t})=>e.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:t}),li:({children:t})=>e.jsx("li",{style:{marginBottom:"2px"},children:t}),a:({href:t,children:n})=>{let o=t,r="",s=n;if(t&&typeof n=="string"&&(n===t||n===tu(t))){const[l,a]=eu(n);a&&(o=encodeURI(l),s=l,r=a)}return e.jsxs(e.Fragment,{children:[e.jsx("a",{href:o,target:o!=null&&o.startsWith("http")?"_blank":void 0,rel:o!=null&&o.startsWith("http")?"noopener noreferrer":void 0,style:{color:i("link")},children:s}),r]})},code:({children:t})=>e.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:t})};function tu(t){try{return decodeURI(t)}catch{return t}}const nu={...$l,strong:({children:t})=>e.jsx(e.Fragment,{children:t})},St=({text:t,plainStrong:n,style:o,className:r})=>{const{convert:s}=Re(),l=n?nu:$l;return e.jsx("div",{className:r,style:o,children:e.jsx(zd,{remarkPlugins:[Td],components:l,children:s(t)})})},iu=["〇","一","二","三","四","五","六","七","八","九"],Gr=["","十","百","千"];function Cl(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),p=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=Gr[p]:r+=iu[a]+Gr[p])}return r}function zl(t){return{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:t,border:`1px solid color-mix(in srgb, ${t} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${t} 3%, transparent)`}}const ou={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function ru({type:t}){const n=$e();return e.jsx("span",{style:zl(ou[t]),children:n.indexType[t]})}function su({isDraft:t}){const n=$e(),o=i(t?"status-draft":"status-official");return e.jsx("span",{style:zl(o),children:t?n.status.draft:n.status.official})}function lu({id:t}){const n=$e(),[o,r]=g.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:i("desc-fg"),background:i("bg-subtle"),border:`1px solid ${i("widget-border")}`,borderRadius:"2px"},children:[e.jsx("span",{children:n.label.id}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:t}),e.jsx("span",{onClick:s,title:o?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:o?1:.5,transition:"opacity 0.15s"},onMouseEnter:l=>l.currentTarget.style.opacity="1",onMouseLeave:l=>l.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function ut({children:t,extra:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("desc-fg"),letterSpacing:"1px"},children:t}),e.jsx("span",{style:{flex:1}}),n]})}function xt({label:t,children:n}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[e.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:t}),e.jsx("span",{style:{color:i("fg")},children:n})]})}function Tl({authors:t,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Re();return e.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:t.map((l,a)=>{const p=s(l.name),c=l.entity_id?e.jsx(gt,{id:l.entity_id,label:p,onNavigate:o,renderLink:r}):e.jsx("span",{style:{fontWeight:500},children:p});return e.jsxs("span",{children:[a>0&&e.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),l.dynasty&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(l.dynasty),"〕"]}),c,l.role&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(l.role)]})]},a)})})}function gt({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ke();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{children:n||t})}function au({id:t,title:n,edition:o,type:r,isDraft:s,authors:l,volumeText:a,meta:p,headerExtra:c,onNavigate:d,renderLink:u}){return e.jsxs("div",{style:{marginBottom:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[e.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:i("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,o&&e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),a&&e.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:a})]}),c&&e.jsx("div",{style:{flexShrink:0,paddingTop:"2px"},children:c})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",marginBottom:"4px"},children:[e.jsx(ru,{type:r}),e.jsx(su,{isDraft:s}),e.jsx(lu,{id:t})]}),((l==null?void 0:l.length)||p.length>0)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[l&&l.length>0&&e.jsx(Tl,{authors:l,type:r,onNavigate:d,renderLink:u}),p]})]})}function Nl({items:t,label:n,showMeta:o,onNavigate:r,renderLink:s}){const l=$e(),{convert:a}=Re();if(!t.length)return null;const[p,c]=g.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(ut,{children:n}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map((d,u)=>{const m=p===u;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:i("shadow-card")}:{}},children:[e.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:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(d.source)}),!m&&o&&d.title_info&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a(d.title_info)}),d.source_bid&&e.jsx("span",{onClick:h=>h.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:e.jsx(gt,{id:d.source_bid,label:l.action.view,onNavigate:r,renderLink:s})})]}),m&&e.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(d.title_info||d.author_info||d.edition)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[d.title_info&&e.jsx(xt,{label:l.label.titleInfo,children:a(d.title_info)}),d.author_info&&e.jsx(xt,{label:l.label.authorInfo,children:a(d.author_info)}),d.edition&&e.jsx(xt,{label:l.label.edition,children:a(d.edition)})]}),d.summary&&e.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.summary}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:a(d.summary)})]}),d.comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.comment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.comment)})]}),d.additional_comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.additionalComment}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.additional_comment)})]})]})]},u)})})]})}function cu({items:t,onNavigate:n,renderLink:o}){const r=$e();return e.jsx(Nl,{items:t,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function El({items:t,onNavigate:n,renderLink:o}){const r=$e();return e.jsx(Nl,{items:t,label:r.section.emendated,onNavigate:n,renderLink:o})}function Il({label:t,items:n}){const{convert:o}=Re();return n.length?e.jsxs(e.Fragment,{children:[e.jsx(ut,{children:t}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const l=typeof r=="string"?r:r.book_title;return e.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:o(l)},s)})})]}):null}function du({items:t}){const n=$e();return e.jsx(Il,{label:n.section.aliases,items:t})}function pu({items:t}){const n=$e();return e.jsx(Il,{label:n.section.attachedTexts,items:t})}function uu({items:t}){const n=$e(),{convert:o}=Re();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(ut,{children:n.section.appendix}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((r,s)=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:["《",o(r.book_title),"》",r.n_juan!=null&&e.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function mu({items:t}){const n=$e(),{convert:o}=Re();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(ut,{children:n.section.locationHistory}),e.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[e.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:i("widget-border")}}),t.map((r,s)=>e.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[e.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:i("primary"),border:`1.5px solid ${i("input-bg")}`}}),e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function hu({items:t}){const n=$e(),{convert:o}=Re();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(ut,{children:n.section.historyOverview}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map((r,s)=>e.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[e.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function Yr({title:t,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:l}=Re(),[a,p]=g.useState([]);return g.useEffect(()=>{if(!n.length){p([]);return}if(!o){p(n.map(d=>({id:d})));return}let c=!1;return Promise.all(n.map(d=>o.getItem(d).then(u=>({id:d,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:d})))).then(d=>{c||p(d)}),()=>{c=!0}},[n,o]),n.length?e.jsxs(e.Fragment,{children:[e.jsxs(ut,{children:[t,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(a.length?a:n.map(c=>({id:c}))).map(c=>{const d=c.edition?`${l(c.title)||c.id}(${l(c.edition)})`:l(c.title)||void 0;return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),transition:"border-color 0.15s"},children:e.jsx(gt,{id:c.id,label:d,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Ii({book:t,onNavigate:n,renderLink:o}){const r=$e(),{convert:s}=Re(),[l,a]=g.useState(!1),p=t.resources&&t.resources.length>0,c=t.edition?s(t.edition):s(t.title)||void 0;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[e.jsxs("div",{style:{padding:"6px 12px",borderBottom:p&&!l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:e.jsx(gt,{id:t.id,label:c,onNavigate:n,renderLink:o})}),p&&e.jsx("span",{onClick:()=>a(d=>!d),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:l?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:l?r.action.expand:r.action.collapse,children:"▼"})]}),p&&!l&&e.jsx("div",{style:{padding:"10px 14px"},children:e.jsx(ko,{items:t.resources,resourceGroups:t.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function gu({ids:t,workData:n,transport:o,onNavigate:r,renderLink:s,footer:l}){const a=$e(),{convert:p}=Re(),[c,d]=g.useState([]);if(g.useEffect(()=>{if(!t.length){d([]);return}if(!o){d(t.map(j=>({id:j})));return}let x=!1;return Promise.all(t.map(j=>o.getItem(j).then(y=>({id:j,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:j})))).then(j=>{x||d(j)}),()=>{x=!0}},[t,o]),!t.length)return null;const u=c.length?c:t.map(x=>({id:x})),m=new Map(u.map(x=>[x.id,x])),h=n==null?void 0:n.version_graph,f=fu(t,h,a.common.otherVersions);return e.jsxs(e.Fragment,{children:[e.jsxs(ut,{children:[a.section.relatedVersions,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",t.length,")"]})]}),l,f.useGrouping?e.jsxs(e.Fragment,{children:[f.coreIds.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:f.coreIds.map(x=>{const j=m.get(x);return j?e.jsx(Ii,{book:j,onNavigate:r,renderLink:s},x):null})}),f.groupedIds.map(x=>e.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[e.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[p(x.label),e.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&e.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:p(x.description)})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:x.ids.map(j=>{const y=m.get(j);return y?e.jsx(Ii,{book:y,onNavigate:r,renderLink:s},j):null})})]},x.id))]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(x=>e.jsx(Ii,{book:x,onNavigate:r,renderLink:s},x.id))})]})}function fu(t,n,o){var _,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,groupedIds:[]};const r=(_=n.collections)==null?void 0:_[n.default_collection],s=(r==null?void 0:r.groups)??[],l=(r==null?void 0:r.book_ids)??[],a=s.length>0||l.length>0,p=!a&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!a&&p.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const c=new Set(s),d=new Set([...l,...p]),u=v=>{if(d.has(v))return!0;const S=n.node_groups[v];return S!=null&&c.has(S)},m=[],h=new Map,f=[];for(const v of t)if(!((b=n.excluded_books)!=null&&b.includes(v)))if(u(v))m.push(v);else{const S=n.node_groups[v];S?(h.has(S)||h.set(S,[]),h.get(S).push(v)):f.push(v)}if(f.length+[...h.values()].reduce((v,S)=>v+S.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const j=new Map((n.groups??[]).map(v=>[v.id,v])),y=[...h.entries()].map(([v,S])=>{const k=j.get(v);return{id:v,label:(k==null?void 0:k.label)??v,description:k==null?void 0:k.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 xu({workData:t,onNavigate:n,renderLink:o}){var a,p,c,d;const r=$e(),{convert:s}=Re(),l=!!((a=t.description)!=null&&a.text)||!!t.parent_work;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[e.jsxs("div",{style:{padding:"6px 14px",borderBottom:l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:e.jsx(gt,{id:t.id,label:s(t.title),onNavigate:n,renderLink:o})}),t.measure_info?e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:s(t.measure_info)}):((p=t.juan_count)==null?void 0:p.number)!=null&&t.juan_count.number>0?e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[Cl(t.juan_count.number),r.unit.juan]}):null,t.authors&&t.authors.length>0&&e.jsx("span",{style:{fontSize:"13px"},children:e.jsx(Tl,{authors:t.authors,type:"work",onNavigate:n,renderLink:o})})]}),l&&e.jsxs("div",{style:{padding:"8px 14px"},children:[((c=t.description)==null?void 0:c.text)&&e.jsx(St,{text:t.description.text,style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,textAlign:"justify"}}),t.parent_work&&e.jsx("div",{style:{marginTop:(d=t.description)!=null&&d.text?"8px":0,fontSize:"13px"},children:e.jsx(xt,{label:r.label.parentWork,children:e.jsx(gt,{id:t.parent_work.id,label:s(t.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function bu({items:t,onNavigate:n,renderLink:o}){const r=$e(),{convert:s}=Re();return t.length?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:t.map(l=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${i("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${i("type-collection")} 3%, transparent)`},children:[e.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),e.jsx(gt,{id:l.id,label:s(l.title)||l.id,onNavigate:n,renderLink:o}),l.volume_index!=null&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:dt(r.catalog.volume,{n:l.volume_index})})]},l.id))}):null}const $o=({data:t,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:l,relatedBooksFooter:a,className:p,style:c})=>{var O,C,T,R,A,H,q,ne;const d=$e(),{convert:u}=Re(),[m,h]=g.useState(null),[f,x]=g.useState(!1),[j,y]=g.useState(null),[_,b]=g.useState(null),[v,S]=g.useState([]),k=t||m;if(g.useEffect(()=>{if(t||!n||!o)return;let L=!1;return x(!0),y(null),o.getItem(n).then(Q=>{L||(Q?h(Q):y(d.misc.notFoundEntry))}).catch(Q=>{L||y(Q instanceof Error?Q.message:d.misc.loadFailed)}).finally(()=>{L||x(!1)}),()=>{L=!0}},[t,n,o]),g.useEffect(()=>{if(!k||!o){b(null),S([]);return}let L=!1;const Q=k.type==="book"||k.type==="collection"?k.work_id:void 0;if(Q?o.getItem(Q).then(P=>{!L&&P&&P.type==="work"&&b(P)}).catch(()=>{}):b(null),k.type==="book"){const P=k;P.contained_in&&P.contained_in.length>0?Promise.all(P.contained_in.map(D=>{const pe=typeof D=="string"?D:D.id,le=typeof D=="string"?void 0:D.volume_index;return o.getItem(pe).then(fe=>({id:pe,title:fe&&fe.title||pe,volume_index:le})).catch(()=>({id:pe,title:pe,volume_index:le}))})).then(D=>{L||S(D)}):S([])}else S([]);return()=>{L=!0}},[k,o]),f)return e.jsx("div",{className:p,style:{...c,padding:"24px"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((L,Q)=>e.jsx("div",{style:{height:Q===1?"32px":"16px",width:`${L}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},Q))})});if(j)return e.jsx("div",{className:p,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:j});if(!k)return null;if(k.type==="entity")return e.jsx("div",{className:p,style:c,children:e.jsx(_l,{data:k,transport:o,onNavigate:r,renderLink:s,headerExtra:l})});const $=k.type==="book"?k:null,w=k.type==="collection"?k:null,z=k.type==="work"?k:null;let B=!1;try{B=we.extractStatus(k.id)==="draft"}catch{}let I="";k.measure_info?I=u(k.measure_info):(O=k.juan_count)!=null&&O.number?I=Cl(k.juan_count.number)+d.unit.juan:(C=k.juan_count)!=null&&C.description&&(I=u(k.juan_count.description));const N=[];return(T=k.publication_info)!=null&&T.year&&N.push(e.jsx(xt,{label:d.label.year,children:k.publication_info.year},"year")),(R=k.current_location)!=null&&R.name&&N.push(e.jsx(xt,{label:d.label.currentLocation,children:u(k.current_location.name)},"loc")),(A=k.page_count)!=null&&A.description&&N.push(e.jsx(xt,{label:d.label.pageCount,children:k.page_count.description},"page")),$!=null&&$.edition&&N.push(e.jsx(xt,{label:d.label.edition,children:u($.edition)},"ver")),z!=null&&z.parent_work&&N.push(e.jsx(xt,{label:d.label.parentWork,children:e.jsx(gt,{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&&N.push(e.jsx(xt,{label:d.label.parentWork,children:z.parent_works.map((L,Q)=>e.jsxs("span",{children:[Q>0&&"、",e.jsx(gt,{id:L,onNavigate:r,renderLink:s})]},L))},"pws")),e.jsxs("div",{className:p,style:c,children:[e.jsx(au,{id:k.id,title:u(k.title),edition:k.edition?u(k.edition):void 0,type:k.type,isDraft:B,authors:k.authors,volumeText:I,meta:N,headerExtra:l,onNavigate:r,renderLink:s}),((H=k.description)==null?void 0:H.text)&&e.jsx(St,{text:k.description.text,style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),k.appendix&&k.appendix.length>0&&e.jsx("div",{style:{marginTop:8,marginBottom:4},children:k.appendix.map((L,Q)=>e.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[e.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(L.title)}),e.jsx(St,{text:L.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},Q))}),v.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ut,{children:d.section.containedIn}),e.jsx(bu,{items:v,onNavigate:r,renderLink:s})]}),_&&e.jsxs(e.Fragment,{children:[e.jsx(ut,{children:d.section.belongsToWork}),e.jsx(xu,{workData:_,onNavigate:r,renderLink:s})]}),k.additional_works&&k.additional_works.length>0&&e.jsx(uu,{items:k.additional_works}),k.additional_titles&&k.additional_titles.length>0&&e.jsx(du,{items:k.additional_titles}),k.attached_texts&&k.attached_texts.length>0&&e.jsx(pu,{items:k.attached_texts}),k.indexed_by&&k.indexed_by.length>0&&e.jsx(cu,{items:k.indexed_by,onNavigate:r,renderLink:s}),k.emendated_by&&k.emendated_by.length>0&&e.jsx(El,{items:k.emendated_by,onNavigate:r,renderLink:s}),k.resources&&k.resources.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(ut,{children:d.section.resources}),e.jsx(ko,{items:k.resources,resourceGroups:k.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&e.jsx(mu,{items:$.location_history}),(w==null?void 0:w.history)&&w.history.length>0&&e.jsx(hu,{items:w.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&e.jsx(Yr,{title:d.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(w==null?void 0:w.books)&&w.books.length>0&&e.jsx(Yr,{title:d.section.containedBooks,ids:w.books,transport:o,onNavigate:r,renderLink:s}),(w==null?void 0:w.contained_works)&&w.contained_works.length>0&&e.jsxs("div",{children:[e.jsxs(ut,{children:[d.section.containedWorks,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",w.contained_works.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.contained_works.map(L=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:e.jsx(gt,{id:L.id,label:u(L.title),onNavigate:r,renderLink:s})},L.id))})]}),(((q=z==null?void 0:z.books)==null?void 0:q.length)||0)+(((ne=z==null?void 0:z.collections)==null?void 0:ne.length)||0)>0&&e.jsx(gu,{ids:[...(z==null?void 0:z.books)||[],...(z==null?void 0:z.collections)||[]],workData:z??void 0,transport:o,onNavigate:r,renderLink:s,footer:a}),(z==null?void 0:z.related_works)&&z.related_works.length>0&&(()=>{const L=[],Q=z.related_works.filter(ue=>ue.relation==="part_of"),P=z.related_works.filter(ue=>ue.relation==="has_part"),D=z.related_works.filter(ue=>ue.relation==="has_adaptation"),pe=z.related_works.filter(ue=>ue.relation==="text_carried_by"),le=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),fe=z.related_works.filter(ue=>!ue.relation||!le.has(ue.relation));return Q.length>0&&L.push({label:d.section.belongsToWork,items:Q}),P.length>0&&L.push({label:d.section.containedWorks,items:P}),D.length>0&&L.push({label:d.section.adaptations,items:D}),pe.length>0&&L.push({label:d.section.derivativeWorks,items:pe}),fe.length>0&&L.push({label:d.section.relatedWorks,items:fe}),L.map(ue=>e.jsxs("div",{children:[e.jsxs(ut,{children:[ue.label,e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",ue.items.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:ue.items.map(xe=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:e.jsx(gt,{id:xe.id,label:u(xe.title),onNavigate:r,renderLink:s})},xe.id))})]},ue.label))})()]})};function yu({data:t}){const n=$e(),{convert:o}=Re(),{stats:r}=t,s=r.processed_volumes??r.total_found_volumes,l=s!=null&&t.total_volumes>0?Math.round(s/t.total_volumes*100):null;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:o(t.title)}),t.resource_name&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(t.resource_name)}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[e.jsxs("span",{children:[n.catalog.totalVolumes," ",e.jsx("strong",{style:{color:i("fg")},children:t.total_volumes})," ",n.unit.volume]}),l!=null&&e.jsxs("span",{children:[n.catalog.processed," ",e.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",l,"%)"]}),e.jsxs("span",{children:[n.catalog.contains," ",e.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&e.jsxs("span",{children:[n.catalog.matched," ",e.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&e.jsxs("span",{children:[n.catalog.unmatched," ",e.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),t.source&&e.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",t.source]})]})}function ju({sections:t,activeSection:n,onSelect:o}){const r=$e();return e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[e.jsx("button",{onClick:()=>o(null),style:Kr(n===null),children:r.catalog.all}),t.map(s=>e.jsxs("button",{onClick:()=>o(s.name),style:Kr(n===s.name),children:[s.name,s.volume_range&&e.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[s.volume_range[0],"–",s.volume_range[1]]})]},s.name))]})}function Kr(t){return{padding:"4px 12px",border:t?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:t?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(t?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}function vu({id:t,label:n,onNavigate:o,renderLink:r}){const s=Ke();return r?e.jsx(e.Fragment,{children:r(t,n)}):o?e.jsx("a",{href:s(t),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(t))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:n||t})}function ku(t,n){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=t[0],r=t[t.length-1];return r-o+1===t.length?`${o}–${r}`:t.length<=3?t.join(", "):`${o}–${r} (${t.length}${n})`}function qr({book:t,onNavigate:n,renderLink:o,showVolumes:r}){const s=$e(),{convert:l}=Re(),a=t.book_id||t.work_id,p=r&&t.volumes.length>0?ku(t.volumes,s.unit.volume):null,c=t.missing_volumes&&t.missing_volumes.length>0;return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${i("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[r&&e.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:p}),e.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[l(t.title),t.sub_items&&t.sub_items.length>0&&e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",t.sub_items.map(d=>l(d)).join("、"),")"]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:l(t.edition)})]}),t.expected_volumes!=null&&e.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[t.found_volumes??0,"/",t.expected_volumes,s.unit.volume]}),a&&e.jsx(vu,{id:a,label:t.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!a&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const Co=({data:t,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:l,style:a})=>{const p=$e(),[c,d]=g.useState(null),[u,m]=g.useState(!1),[h,f]=g.useState(null),[x,j]=g.useState(null),[y,_]=g.useState(""),b=t||c;g.useEffect(()=>{if(t||!n||!(o!=null&&o.getCollectionCatalog))return;let w=!1;return m(!0),f(null),o.getCollectionCatalog(n).then(z=>{w||(z?d(z):f(p.catalog.notFound))}).catch(z=>{w||f(z instanceof Error?z.message:p.catalog.loadFailed)}).finally(()=>{w||m(!1)}),()=>{w=!0}},[t,n,o,p]);const v=(b==null?void 0:b.sections)&&b.sections.length>0,S=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const w=b.books.map(B=>B.volumes[0]).filter(B=>B!=null);return new Set(w).size<w.length},[b]),k=g.useMemo(()=>{if(!b)return[];let w=b.books;if(x&&(w=w.filter(z=>z.section===x)),y.trim()){const z=y.trim().toLowerCase();w=w.filter(B=>B.title.toLowerCase().includes(z)||B.sub_items&&B.sub_items.some(I=>I.toLowerCase().includes(z))||B.edition&&B.edition.toLowerCase().includes(z))}return w},[b,x,y]),$=g.useMemo(()=>{if(!S)return null;const w=[],z=new Map;for(const I of k){if(!I.volumes||I.volumes.length===0)continue;const N=I.volumes[0];z.has(N)||z.set(N,[]),z.get(N).push(I)}const B=[...z.keys()].sort((I,N)=>I-N);for(const I of B)w.push({volume:I,books:z.get(I)});return w},[k,S]);return u?e.jsx("div",{className:l,style:{...a,padding:"24px"},children:e.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:p.catalog.loading})}):h?e.jsx("div",{className:l,style:{...a,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:h}):b?e.jsxs("div",{className:l,style:a,children:[e.jsx(yu,{data:b}),v&&e.jsx(ju,{sections:b.sections,activeSection:x,onSelect:j}),e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("input",{type:"text",placeholder:p.search.searchBookName,value:y,onChange:w=>_(w.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),e.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[k.length," ",p.unit.bu]})]}),e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((w,z)=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"4px 12px",background:i("bg"),borderBottom:`1px solid ${i("widget-border")}`,fontSize:"12px",fontWeight:600,color:i("desc-fg"),position:"sticky",top:0,zIndex:1},children:dt(p.catalog.volume,{n:w.volume})}),w.books.map((B,I)=>e.jsx(qr,{book:B,onNavigate:r,renderLink:s,showVolumes:B.volumes.length>1},`${w.volume}-${I}`))]},`${w.volume}-${z}`)):k.map((w,z)=>e.jsx(qr,{book:w,onNavigate:r,renderLink:s,showVolumes:!0},z)),k.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:p.catalog.noMatch})]})]}):null},wu="guji_markdown";function Ki(t){const n=t==null?void 0:t.guji_markdown;if(typeof n!="string")return!1;const o=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!o)return!1;const r=parseInt(o[1],10),s=parseInt(o[2],10);return r>0||s>=2}const Su=/^□\{guess=([^\s{}]+)\}/;function _u(t,n){const o=t[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function Rl(t,n){let o=0;for(let r=n;r<t.length;r++){const s=t[r];if(s===`
|
|
146
|
-
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function
|
|
147
|
-
`)<0?{node:{type:"qw",label:
|
|
148
|
-
`)return null}const c=
|
|
149
|
-
`),o=[];let r=[];const s=()=>{if(r.length===0)return;const
|
|
150
|
-
`);r=[],o.push({type:"text",text:
|
|
151
|
-
`)}),l
|
|
145
|
+
}`,Wa={color:"inherit",textDecoration:"none"},du=({snippet:e})=>{const{convert:n}=Ie();return t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:_o(e).map((o,r)=>o.marked?t.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):t.jsx(g.Fragment,{children:n(o.text)},r))})},pu=({entry:e,selected:n,onClick:o,getConfig:r,query:s})=>{const a=$e(),{convert:l}=Ie(),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,h=i("cover-accent"),m=qe();return t.jsxs("a",{href:m(e.id),onClick:f=>o(e,f),className:"bim-result-card",style:{...Wa,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, ${h} 50%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${h} 14%, ${i("bg")}), color-mix(in srgb, ${h} 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, ${h} 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:h},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(du,{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(un,{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})]})]})]})},os=({entry:e,selected:n,onClick:o,getConfig:r,query:s,onRemove:a})=>{const l=$e(),{convert:d}=Ie(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(h=>{const m=typeof h=="string"?h:h==null?void 0:h.book_title;return m==null?void 0:m.toLowerCase().includes(s.toLowerCase())}):void 0,u=qe();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:h=>o(e,h),className:"bim-result-card",style:{...Wa,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(un,{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:"×"})]})},uu=({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 mu(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 hu({data:e}){const{convert:n}=Ie(),{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 gu({alt_names:e}){const{convert:n}=Ie(),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 fu({data:e}){const n=$e(),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 xu({works:e,transport:n,onNavigate:o,renderLink:r}){const s=$e(),{convert:a}=Ie(),l=qe(),[d,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let m=!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 w=!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):w=!1}if(w)return k}catch{}const y=[...f],_=8,b=new Array(_).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 w=await n.getItem(j),v=w&&(w.title||w.primary_name)||j;k.set(j,v)}catch{k.set(j,j)}}});return await Promise.all(b),k})().then(k=>{m||c(k)}),()=>{m=!0}},[e,n]);const p=new Map;for(const m of e){const f=m.role||"";p.has(f)||p.set(f,[]),p.get(f).push(m)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],h=[...p.keys()].sort((m,f)=>{const x=u.indexOf(m),k=u.indexOf(f);return x===-1&&k===-1?m.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,")"]})]}),h.map(m=>{const f=p.get(m);return t.jsxs("div",{style:{marginBottom:"8px"},children:[m&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[a(m)," ",t.jsxs("span",{style:{color:i("desc-fg")},children:["(",f.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:m?"16px":"0",listStyle:m?"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:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),o(x.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:y})},k):t.jsx("li",{children:y},k)})})]},m)})]})}const Oa=({data:e,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:a})=>{var h;const l=$e(),{convert:d}=Ie();let c=!1;try{c=we.extractStatus(e.id)==="draft"}catch{}const p=mu(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(hu,{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(gu,{alt_names:e.alt_names}),t.jsx(fu,{data:e}),((h=e.description)==null?void 0:h.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(xu,{works:e.works,transport:n,onNavigate:o,renderLink:r})]})},bu=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function yu(e){const n=e.search(bu);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Ha={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===ju(e))){const[a,l]=yu(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 ju(e){try{return decodeURI(e)}catch{return e}}const vu={...Ha,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},_t=({text:e,plainStrong:n,style:o,className:r})=>{const{convert:s}=Ie(),a=n?vu:Ha;return t.jsx("div",{className:r,style:o,children:t.jsx(Yd,{remarkPlugins:[Kd],components:a,children:s(e)})})},ku=["〇","一","二","三","四","五","六","七","八","九"],rs=["","十","百","千"];function Fa(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+=rs[d]:r+=ku[l]+rs[d])}return r}function Da(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 wu={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function Su({type:e}){const n=$e();return t.jsx("span",{style:Da(wu[e]),children:n.indexType[e]})}function _u({isDraft:e}){const n=$e(),o=i(e?"status-draft":"status-official");return t.jsx("span",{style:Da(o),children:e?n.status.draft:n.status.official})}function $u({id:e}){const n=$e(),[o,r]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:i("desc-fg"),background:i("bg-subtle"),border:`1px solid ${i("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:e}),t.jsx("span",{onClick:s,title:o?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:o?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function ut({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 xt({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 Ua({authors:e,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Ie();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(gt,{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 gt({id:e,label:n,onNavigate:o,renderLink:r}){const s=qe();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 Cu({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(Su,{type:r}),t.jsx(_u,{isDraft:s}),t.jsx($u,{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(Ua,{authors:a,type:r,onNavigate:p,renderLink:u}),d]})]})}function Va({items:e,label:n,showMeta:o,onNavigate:r,renderLink:s}){const a=$e(),{convert:l}=Ie();if(!e.length)return null;const[d,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(ut,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,u)=>{const h=d===u;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...h?{boxShadow:i("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(h?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:h?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:l(p.source)}),!h&&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:m=>m.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(gt,{id:p.source_bid,label:a.action.view,onNavigate:r,renderLink:s})})]}),h&&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(xt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(xt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(xt,{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 zu({items:e,onNavigate:n,renderLink:o}){const r=$e();return t.jsx(Va,{items:e,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function Ga({items:e,onNavigate:n,renderLink:o}){const r=$e();return t.jsx(Va,{items:e,label:r.section.emendated,onNavigate:n,renderLink:o})}function Ya({label:e,items:n}){const{convert:o}=Ie();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(ut,{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 Tu({items:e}){const n=$e();return t.jsx(Ya,{label:n.section.aliases,items:e})}function Nu({items:e}){const n=$e();return t.jsx(Ya,{label:n.section.attachedTexts,items:e})}function Eu({items:e}){const n=$e(),{convert:o}=Ie();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ut,{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 Iu({items:e}){const n=$e(),{convert:o}=Ie();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ut,{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 Ru({items:e}){const n=$e(),{convert:o}=Ie();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(ut,{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 ss({title:e,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:a}=Ie(),[l,d]=g.useState([]);return g.useEffect(()=>{if(!n.length){d([]);return}if(!o){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>o.getItem(p).then(u=>({id:p,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,o]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(ut,{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(gt,{id:c.id,label:p,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Oi({book:e,onNavigate:n,renderLink:o}){const r=$e(),{convert:s}=Ie(),[a,l]=g.useState(!1),d=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(gt,{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(Eo,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function Lu({ids:e,workData:n,transport:o,onNavigate:r,renderLink:s,footer:a}){const l=$e(),{convert:d}=Ie(),[c,p]=g.useState([]);if(g.useEffect(()=>{if(!e.length){p([]);return}if(!o){p(e.map(k=>({id:k})));return}let x=!1;return Promise.all(e.map(k=>o.getItem(k).then(y=>({id:k,title:y?y.title:void 0,edition:y?y.edition:void 0,resources:y?y.resources:void 0,resource_groups:y?y.resource_groups:void 0})).catch(()=>({id:k})))).then(k=>{x||p(k)}),()=>{x=!0}},[e,o]),!e.length)return null;const u=c.length?c:e.map(x=>({id:x})),h=new Map(u.map(x=>[x.id,x])),m=n==null?void 0:n.version_graph,f=Au(e,m,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(ut,{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=h.get(x);return k?t.jsx(Oi,{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=h.get(k);return y?t.jsx(Oi,{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(Oi,{book:x,onNavigate:r,renderLink:s},x.id))})]})}function Au(e,n,o){var _,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const r=(_=n.collections)==null?void 0:_[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 w=n.node_groups[j];return w!=null&&c.has(w)},h=[],m=new Map,f=[];for(const j of e)if(!((b=n.excluded_books)!=null&&b.includes(j)))if(u(j))h.push(j);else{const w=n.node_groups[j];w?(m.has(w)||m.set(w,[]),m.get(w).push(j)):f.push(j)}if(f.length+[...m.values()].reduce((j,w)=>j+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const k=new Map((n.groups??[]).map(j=>[j.id,j])),y=[...m.entries()].map(([j,w])=>{const v=k.get(j);return{id:j,label:(v==null?void 0:v.label)??j,description:v==null?void 0:v.description,ids:w}});return f.length>0&&y.push({id:"__other__",label:o,description:void 0,ids:f}),{useGrouping:!0,coreIds:h,groupedIds:y}}function Pu({workData:e,onNavigate:n,renderLink:o}){var l,d,c,p;const r=$e(),{convert:s}=Ie(),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(gt,{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:[Fa(e.juan_count.number),r.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Ua,{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(_t,{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(xt,{label:r.label.parentWork,children:t.jsx(gt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function Mu({items:e,onNavigate:n,renderLink:o}){const r=$e(),{convert:s}=Ie();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(gt,{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:dt(r.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Ao=({data:e,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var F,N,R,O,I,P,G,K;const p=$e(),{convert:u}=Ie(),[h,m]=g.useState(null),[f,x]=g.useState(!1),[k,y]=g.useState(null),[_,b]=g.useState(null),[j,w]=g.useState([]),v=e||h;if(g.useEffect(()=>{if(e||!n||!o)return;let L=!1;return x(!0),y(null),o.getItem(n).then(Z=>{L||(Z?m(Z):y(p.misc.notFoundEntry))}).catch(Z=>{L||y(Z instanceof Error?Z.message:p.misc.loadFailed)}).finally(()=>{L||x(!1)}),()=>{L=!0}},[e,n,o]),g.useEffect(()=>{if(!v||!o){b(null),w([]);return}let L=!1;const Z=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(Z?o.getItem(Z).then(A=>{!L&&A&&A.type==="work"&&b(A)}).catch(()=>{}):b(null),v.type==="book"){const A=v;A.contained_in&&A.contained_in.length>0?Promise.all(A.contained_in.map(U=>{const ce=typeof U=="string"?U:U.id,ee=typeof U=="string"?void 0:U.volume_index;return o.getItem(ce).then(ue=>({id:ce,title:ue&&ue.title||ce,volume_index:ee})).catch(()=>({id:ce,title:ce,volume_index:ee}))})).then(U=>{L||w(U)}):w([])}else w([]);return()=>{L=!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((L,Z)=>t.jsx("div",{style:{height:Z===1?"32px":"16px",width:`${L}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},Z))})});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(Oa,{data:v,transport:o,onNavigate:r,renderLink:s,headerExtra:a})});const $=v.type==="book"?v:null,S=v.type==="collection"?v:null,C=v.type==="work"?v:null;let B=!1;try{B=we.extractStatus(v.id)==="draft"}catch{}let T="";v.measure_info?T=u(v.measure_info):(F=v.juan_count)!=null&&F.number?T=Fa(v.juan_count.number)+p.unit.juan:(N=v.juan_count)!=null&&N.description&&(T=u(v.juan_count.description));const z=[];return(R=v.publication_info)!=null&&R.year&&z.push(t.jsx(xt,{label:p.label.year,children:v.publication_info.year},"year")),(O=v.current_location)!=null&&O.name&&z.push(t.jsx(xt,{label:p.label.currentLocation,children:u(v.current_location.name)},"loc")),(I=v.page_count)!=null&&I.description&&z.push(t.jsx(xt,{label:p.label.pageCount,children:v.page_count.description},"page")),$!=null&&$.edition&&z.push(t.jsx(xt,{label:p.label.edition,children:u($.edition)},"ver")),C!=null&&C.parent_work&&z.push(t.jsx(xt,{label:p.label.parentWork,children:t.jsx(gt,{id:C.parent_work.id,label:u(C.parent_work.title),onNavigate:r,renderLink:s})},"pw")),C!=null&&C.parent_works&&C.parent_works.length>0&&!C.parent_work&&z.push(t.jsx(xt,{label:p.label.parentWork,children:C.parent_works.map((L,Z)=>t.jsxs("span",{children:[Z>0&&"、",t.jsx(gt,{id:L,onNavigate:r,renderLink:s})]},L))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Cu,{id:v.id,title:u(v.title),edition:v.edition?u(v.edition):void 0,type:v.type,isDraft:B,authors:v.authors,volumeText:T,meta:z,headerExtra:a,onNavigate:r,renderLink:s}),((P=v.description)==null?void 0:P.text)&&t.jsx(_t,{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((L,Z)=>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(L.title)}),t.jsx(_t,{text:L.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},Z))}),j.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(ut,{children:p.section.containedIn}),t.jsx(Mu,{items:j,onNavigate:r,renderLink:s})]}),_&&t.jsxs(t.Fragment,{children:[t.jsx(ut,{children:p.section.belongsToWork}),t.jsx(Pu,{workData:_,onNavigate:r,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Eu,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Tu,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(Nu,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(zu,{items:v.indexed_by,onNavigate:r,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(Ga,{items:v.emendated_by,onNavigate:r,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(ut,{children:p.section.resources}),t.jsx(Eo,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(Iu,{items:$.location_history}),(S==null?void 0:S.history)&&S.history.length>0&&t.jsx(Ru,{items:S.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(ss,{title:p.section.relatedVersions,ids:$.related_books,transport:o,onNavigate:r,renderLink:s}),(S==null?void 0:S.books)&&S.books.length>0&&t.jsx(ss,{title:p.section.containedBooks,ids:S.books,transport:o,onNavigate:r,renderLink:s}),(S==null?void 0:S.contained_works)&&S.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(ut,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",S.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.contained_works.map(L=>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(gt,{id:L.id,label:u(L.title),onNavigate:r,renderLink:s})},L.id))})]}),(((G=C==null?void 0:C.books)==null?void 0:G.length)||0)+(((K=C==null?void 0:C.collections)==null?void 0:K.length)||0)>0&&t.jsx(Lu,{ids:[...(C==null?void 0:C.books)||[],...(C==null?void 0:C.collections)||[]],workData:C??void 0,transport:o,onNavigate:r,renderLink:s,footer:l}),(C==null?void 0:C.related_works)&&C.related_works.length>0&&(()=>{const L=[],Z=C.related_works.filter(de=>de.relation==="part_of"),A=C.related_works.filter(de=>de.relation==="has_part"),U=C.related_works.filter(de=>de.relation==="has_adaptation"),ce=C.related_works.filter(de=>de.relation==="text_carried_by"),ee=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),ue=C.related_works.filter(de=>!de.relation||!ee.has(de.relation));return Z.length>0&&L.push({label:p.section.belongsToWork,items:Z}),A.length>0&&L.push({label:p.section.containedWorks,items:A}),U.length>0&&L.push({label:p.section.adaptations,items:U}),ce.length>0&&L.push({label:p.section.derivativeWorks,items:ce}),ue.length>0&&L.push({label:p.section.relatedWorks,items:ue}),L.map(de=>t.jsxs("div",{children:[t.jsxs(ut,{children:[de.label,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",de.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:de.items.map(be=>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(gt,{id:be.id,label:u(be.title),onNavigate:r,renderLink:s})},be.id))})]},de.label))})()]})};function Bu({data:e}){const n=$e(),{convert:o}=Ie(),{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 Wu({sections:e,activeSection:n,onSelect:o}){const r=$e();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>o(null),style:as(n===null),children:r.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>o(s.name),style:as(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 as(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 Ou({id:e,label:n,onNavigate:o,renderLink:r}){const s=qe();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 Hu(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 ls({book:e,onNavigate:n,renderLink:o,showVolumes:r}){const s=$e(),{convert:a}=Ie(),l=e.book_id||e.work_id,d=r&&e.volumes.length>0?Hu(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(Ou,{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 Po=({data:e,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:a,style:l})=>{const d=$e(),[c,p]=g.useState(null),[u,h]=g.useState(!1),[m,f]=g.useState(null),[x,k]=g.useState(null),[y,_]=g.useState(""),b=e||c;g.useEffect(()=>{if(e||!n||!(o!=null&&o.getCollectionCatalog))return;let S=!1;return h(!0),f(null),o.getCollectionCatalog(n).then(C=>{S||(C?p(C):f(d.catalog.notFound))}).catch(C=>{S||f(C instanceof Error?C.message:d.catalog.loadFailed)}).finally(()=>{S||h(!1)}),()=>{S=!0}},[e,n,o,d]);const j=(b==null?void 0:b.sections)&&b.sections.length>0,w=g.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const S=b.books.map(B=>B.volumes[0]).filter(B=>B!=null);return new Set(S).size<S.length},[b]),v=g.useMemo(()=>{if(!b)return[];let S=b.books;if(x&&(S=S.filter(C=>C.section===x)),y.trim()){const C=y.trim().toLowerCase();S=S.filter(B=>B.title.toLowerCase().includes(C)||B.sub_items&&B.sub_items.some(T=>T.toLowerCase().includes(C))||B.edition&&B.edition.toLowerCase().includes(C))}return S},[b,x,y]),$=g.useMemo(()=>{if(!w)return null;const S=[],C=new Map;for(const T of v){if(!T.volumes||T.volumes.length===0)continue;const z=T.volumes[0];C.has(z)||C.set(z,[]),C.get(z).push(T)}const B=[...C.keys()].sort((T,z)=>T-z);for(const T of B)S.push({volume:T,books:C.get(T)});return S},[v,w]);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})}):m?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:m}):b?t.jsxs("div",{className:a,style:l,children:[t.jsx(Bu,{data:b}),j&&t.jsx(Wu,{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:S=>_(S.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((S,C)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:i("bg"),borderBottom:`1px solid ${i("widget-border")}`,fontSize:"12px",fontWeight:600,color:i("desc-fg"),position:"sticky",top:0,zIndex:1},children:dt(d.catalog.volume,{n:S.volume})}),S.books.map((B,T)=>t.jsx(ls,{book:B,onNavigate:r,renderLink:s,showVolumes:B.volumes.length>1},`${S.volume}-${T}`))]},`${S.volume}-${C}`)):v.map((S,C)=>t.jsx(ls,{book:S,onNavigate:r,renderLink:s,showVolumes:!0},C)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},Fu="guji_markdown";function io(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 Du=/^□\{guess=([^\s{}]+)\}/;function Uu(e,n){const o=e[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function Ka(e,n){let o=0;for(let r=n;r<e.length;r++){const s=e[r];if(s===`
|
|
146
|
+
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function Vu(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function Gu(e,n){const o=e[n];if(o==="["&&e[n+1]==="["){const r=e.indexOf("]]",n+2);return r>=0&&e.slice(n+2,r).indexOf(`
|
|
147
|
+
`)<0?{node:{type:"qw",label:e.slice(n+2,r)},end:r+2}:null}if(o===":"&&e.startsWith(":zi[",n)){const r=Ka(e,n+3);return r>n+4?{node:{type:"zi",label:Vu(e.slice(n+4,r))},end:r+1}:null}if(o==="□"&&e[n+1]==="{"){const r=Du.exec(e.slice(n,n+64));if(r)return{node:{type:"qz",guess:r[1]},end:n+r[0].length}}return null}function qa(e,n,o,r){const s=[];let a="";const l=()=>{if(!a)return;const d=r?a.replace(/\\?\|/g,""):a;d&&s.push({type:"text",text:d}),a=""};for(;n<e.length;){const d=e[n];if(o!==null){if(d===o)return l(),{nodes:s,end:n};if(d===`
|
|
148
|
+
`)return null}const c=Gu(e,n);if(c){l(),s.push(c.node),n=c.end;continue}let p=null;if(d==="⟨"?p="⟩":d==="<"&&Uu(e,n)&&(p=">"),p){const u=qa(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 Xa(e){return qa(e,0,null,!1).nodes}function Yu(e){return/[<⟨□]|\[\[|:zi\[/.test(e)}function Za(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Za(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Ja="guji-table-v1";function Qa(e){return!!e&&e.table_notation===Ja}const Ku=/^:::table(?:\{[^}]*\})?[ \t]*$/,qu=/^:::[ \t]*$/;function el(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=Ka(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 Xu=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function Zu(e){if(e==="^")return{cont:!0};const n=Xu.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 tl(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 h=!1;u.startsWith("!")&&(h=!0,u=u.slice(1));const m=el(u).map(Zu),f=a.map(_=>_>0),x=a.map(_=>_>0?_-1:0),k=[];let y=0;for(const _ of m){if(_.cont){f[y]||o.push(`第 ${p} 行第 ${y+1} 列:续格 ^ 上方没有跨行格`),y+=1;continue}const{cell:b}=_;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 _=y;_<f.length;_++)f[_]&&o.push(`第 ${p} 行第 ${_+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let _=0;_<x.length;_++)x[_]===void 0&&(x[_]=0);a=x,r.push({header:h,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 Mo(e){const n=e.split(`
|
|
149
|
+
`),o=[];let r=[];const s=()=>{if(r.length===0)return;const l=r.join(`
|
|
150
|
+
`);r=[],o.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(Ku.test(n[a].trim())){let l=a+1;for(;l<n.length&&!qu.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);o.push({type:"table",table:tl(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 Hi=e=>e?e.catch(()=>null):Promise.resolve(null);function nl(e){const n=new Map;function o(r){var a;let s=n.get(r);return s||(s=Hi((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 we.isSafeSegment(r)?o(r):Promise.resolve(null)},async getIndex(r,s){return!we.isSafeSegment(r)||!we.isSafeSegment(s)||!e.getTextIndex?null:Hi(e.getTextIndex(r,s))},async getChapter(r,s,a,l){return!we.isSafeSegment(r)||!we.isSafeSegment(s)||!we.isSafeSegment(a)||!e.getChapter?null:Hi(e.getChapter(r,s,a,l))}}}const Yt=()=>{const{t:e}=J(),[n,o]=g.useState(1);return g.useEffect(()=>{const r=setInterval(()=>o(s=>s>=3?1:s+1),500);return()=>clearInterval(r)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:i("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},Fi=String.raw`https?:\/\/[^\s()()<>"]+`,Ju=new RegExp(String.raw`\[([^\]\n]+)\]\((${Fi})\)`+String.raw`|(《[^》\n]+》)\s?[((](${Fi})[))]`+`|(${Fi})`,"g");function Qu(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function em(e){const n=[];let o=0;for(const r of e.matchAll(Ju)){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:Qu(r[5]),url:r[5]}),o=s+r[0].length}return o<e.length&&n.push({text:e.slice(o)}),n}function il({text:e,convert:n,className:o="bim-rd-link"}){return t.jsx(t.Fragment,{children:em(e).map((r,s)=>r.url?t.jsx("a",{className:o,href:r.url,target:"_blank",rel:"noopener noreferrer",children:n(r.text)},s):t.jsx(g.Fragment,{children:n(r.text)},s))})}const ol="(min-width: 1100px)",rl="(max-width: 719px)",sl="(max-width: 859px)",tm=`${rl}, (pointer: coarse)`,Tt=i("reader-top"),nm="48px",al=`
|
|
152
152
|
.bim-rd {
|
|
153
153
|
position: relative;
|
|
154
154
|
background: ${i("page-bg")};
|
|
155
155
|
color: ${i("ink")};
|
|
156
156
|
font-family: ${i("font-ui")};
|
|
157
|
-
--bimrd-bar-h: ${
|
|
157
|
+
--bimrd-bar-h: ${nm};
|
|
158
158
|
}
|
|
159
159
|
.bim-rd *, .bim-rd *::before, .bim-rd *::after { box-sizing: border-box; }
|
|
160
160
|
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
|
|
181
181
|
/* ── 工具条:文字 + 图标,不画按钮外框 ── */
|
|
182
182
|
.bim-rd-bar {
|
|
183
|
-
position: sticky; top: ${
|
|
183
|
+
position: sticky; top: ${Tt}; z-index: 30;
|
|
184
184
|
height: var(--bimrd-bar-h);
|
|
185
185
|
display: flex; align-items: center; gap: 16px;
|
|
186
186
|
padding: 0 20px;
|
|
@@ -235,14 +235,14 @@
|
|
|
235
235
|
display: grid;
|
|
236
236
|
grid-template-columns: auto auto minmax(0, 1fr);
|
|
237
237
|
align-items: start;
|
|
238
|
-
min-height: calc(100vh - ${
|
|
238
|
+
min-height: calc(100vh - ${Tt} - var(--bimrd-bar-h));
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
/* 目录:宽屏是侧栏 */
|
|
242
242
|
.bim-rd-toc {
|
|
243
243
|
grid-column: 1;
|
|
244
|
-
position: sticky; top: calc(${
|
|
245
|
-
width: 248px; height: calc(100vh - ${
|
|
244
|
+
position: sticky; top: calc(${Tt} + var(--bimrd-bar-h));
|
|
245
|
+
width: 248px; height: calc(100vh - ${Tt} - var(--bimrd-bar-h));
|
|
246
246
|
overflow-y: auto; overscroll-behavior: contain;
|
|
247
247
|
padding: 0 10px 40px;
|
|
248
248
|
background: ${i("sidebar-bg")};
|
|
@@ -279,8 +279,8 @@
|
|
|
279
279
|
/* 书影:正文左侧 */
|
|
280
280
|
.bim-rd-img {
|
|
281
281
|
grid-column: 2;
|
|
282
|
-
position: sticky; top: calc(${
|
|
283
|
-
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${
|
|
282
|
+
position: sticky; top: calc(${Tt} + var(--bimrd-bar-h));
|
|
283
|
+
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${Tt} - var(--bimrd-bar-h));
|
|
284
284
|
padding: 16px 0 16px 20px;
|
|
285
285
|
display: flex; flex-direction: column; gap: 8px;
|
|
286
286
|
}
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
display: flex; align-items: center; justify-content: center; overflow: hidden;
|
|
292
292
|
}
|
|
293
293
|
.bim-rd-img-fig { position: relative; margin: 0; max-width: 100%; max-height: 100%; }
|
|
294
|
-
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${
|
|
294
|
+
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${Tt} - var(--bimrd-bar-h) - 80px); object-fit: contain; }
|
|
295
295
|
.bim-rd-img-fig svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
296
296
|
.bim-rd-img-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center; font-size: 13px; color: ${i("meta-fg")}; }
|
|
297
297
|
.bim-rd-img-empty b { font-size: 15px; font-weight: 500; color: ${i("quiet-fg")}; }
|
|
@@ -387,7 +387,7 @@
|
|
|
387
387
|
|
|
388
388
|
/* 竖排(预留):只在宿主打开 allowVertical 时可切换 */
|
|
389
389
|
.bim-rd-vertical .bim-rd-prose {
|
|
390
|
-
writing-mode: vertical-rl; max-height: calc(100vh - ${
|
|
390
|
+
writing-mode: vertical-rl; max-height: calc(100vh - ${Tt} - var(--bimrd-bar-h) - 120px);
|
|
391
391
|
overflow-x: auto; text-align: start;
|
|
392
392
|
}
|
|
393
393
|
|
|
@@ -444,7 +444,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
444
444
|
.bim-rd-sheet-img .bim-rd-img-fig img { max-height: 60vh; }
|
|
445
445
|
.bim-rd-sheet-fs { display: flex; align-items: center; justify-content: center; gap: 24px; padding: 8px 0 12px; font-size: 15px; color: ${i("ink")}; }
|
|
446
446
|
.bim-rd-sheet-fs .bim-rd-t { min-width: 56px; min-height: 44px; justify-content: center; font-size: 17px; border: 1px solid ${i("rule")}; }
|
|
447
|
-
@media ${
|
|
447
|
+
@media ${sl} {
|
|
448
448
|
.bim-rd[data-bb] .bim-rd-text { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom, 0px)); }
|
|
449
449
|
/* 底栏上已有的,工具条上不再重复(目录、字号) */
|
|
450
450
|
.bim-rd[data-bb] .bim-rd-bb-dup { display: none !important; }
|
|
@@ -454,7 +454,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
454
454
|
|
|
455
455
|
/* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
|
|
456
456
|
A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
|
|
457
|
-
@media ${
|
|
457
|
+
@media ${tm} {
|
|
458
458
|
.bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
|
|
459
459
|
.bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
|
|
460
460
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
@@ -467,7 +467,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
467
467
|
}
|
|
468
468
|
|
|
469
469
|
/* ── 中屏以下:目录改抽屉 ── */
|
|
470
|
-
@media not all and ${
|
|
470
|
+
@media not all and ${ol} {
|
|
471
471
|
.bim-rd-toc {
|
|
472
472
|
position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
|
|
473
473
|
width: min(86vw, 320px);
|
|
@@ -481,7 +481,7 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
/* ── 窄屏:书影收起,只留正文 ── */
|
|
484
|
-
@media ${
|
|
484
|
+
@media ${rl} {
|
|
485
485
|
.bim-rd-bar { padding: 0 12px; gap: 10px; }
|
|
486
486
|
.bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
|
|
487
487
|
/* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
|
|
@@ -634,12 +634,12 @@ button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
|
634
634
|
letter-spacing: 0.05em;
|
|
635
635
|
margin-left: 6px;
|
|
636
636
|
}
|
|
637
|
-
`;function To(t,n){var o;return n?t.key===n?!0:!!((o=t.children)!=null&&o.some(r=>To(r,n))):!1}const Bu=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Wu({item:t,activeKey:n,onSelect:o,tabKey:r}){const s=To(t,n),[l,a]=g.useState(s||!!t.defaultExpanded);return g.useEffect(()=>{s&&a(!0)},[s]),g.useEffect(()=>{t.defaultExpanded&&a(!0)},[t.defaultExpanded]),e.jsxs("li",{children:[e.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":t.key,tabIndex:r===t.key?0:-1,onClick:()=>a(p=>!p),children:[e.jsx(Bu,{}),e.jsx("span",{children:t.label}),t.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:t.hint})]}),l&&e.jsx(Yl,{items:t.children,activeKey:n,onSelect:o,tabKey:r})]})}function Yl({items:t,activeKey:n,onSelect:o,tabKey:r}){return e.jsx("ul",{children:t.map(s=>s.children&&s.children.length>0?e.jsx(Wu,{item:s,activeKey:n,onSelect:o,tabKey:r},s.key):e.jsx("li",{children:e.jsxs("button",{type:"button",className:"bim-rd-ti","aria-current":s.key===n?"true":void 0,disabled:s.disabled,"data-rd-toc-key":s.key,tabIndex:r===s.key?0:-1,onClick:()=>o(s.key),children:[e.jsx("span",{children:s.label}),s.hint!=null&&e.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function Xr(t,n){var o;for(const r of t)if(r.key===n||To(r,n))return r.key;return((o=t[0])==null?void 0:o.key)??null}function Kl({items:t,activeKey:n,onSelect:o,label:r}){const{t:s}=Z(),l=r??s("reader.toc"),a=g.useRef(null),[p,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const d=g.useMemo(()=>p||(n??Xr(t,n)),[p,n,t]);g.useEffect(()=>{const m=a.current;if(!m)return;const h=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(h.length===0)return;const f=h.find(x=>x.dataset.rdTocKey===d)??h.find(x=>x.dataset.rdTocKey===Xr(t,n))??h.find(x=>!x.disabled)??h[0];for(const x of h)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const m=a.current,h=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!h||!n)return;const f=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(j=>j.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-h.getBoundingClientRect().top+h.scrollTop;(x<h.scrollTop+80||x>h.scrollTop+h.clientHeight-40)&&(h.scrollTop=Math.max(0,x-h.clientHeight/3))},[n]);const u=g.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const f=a.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(b=>!b.disabled),j=x.indexOf(document.activeElement);let y=j;if(m.key==="ArrowDown"?y=Math.min(x.length-1,j+1):m.key==="ArrowUp"?y=Math.max(0,j-1):m.key==="Home"?y=0:m.key==="End"&&(y=x.length-1),y<0||y===j)return;m.preventDefault();const _=x[y];for(const b of x)b.tabIndex=-1;_.tabIndex=0,_.focus(),c(_.dataset.rdTocKey??null)},[]);return e.jsx("div",{ref:a,role:"navigation","aria-label":l,onKeyDown:u,children:e.jsx(Yl,{items:t,activeKey:n,onSelect:o,tabKey:d})})}function Ou({page:t}){var n;return!((n=t.boxes)!=null&&n.length)||!t.width||!t.height||t.boxFormat&&t.boxFormat!=="bim-charbox-v0"?null:e.jsx("svg",{viewBox:`0 0 ${t.width} ${t.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:t.boxes.map((o,r)=>e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:i("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},r))})}function qi({pages:t,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:l}=Z(),[a,p]=g.useState(0),c=o??a,d=f=>{r?r(f):p(f)};if(g.useEffect(()=>{o===void 0&&p(0)},[t,o]),n)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsx("div",{className:"bim-rd-img-empty",children:l("reader.imagesLoading")})});if(!t||t.length===0)return e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("div",{className:"bim-rd-img-empty",children:[e.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),e.jsx("b",{children:l("reader.noImages")}),e.jsx("span",{children:l("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(t.length-1,c)),m=t[u],h=m.label??`${u+1}`;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-img-box",children:e.jsxs("figure",{className:"bim-rd-img-fig",children:[e.jsx("img",{src:m.url,alt:m.alt??l("reader.imageAlt",{label:h}),width:m.width,height:m.height,loading:"lazy",decoding:"async"}),e.jsx(Ou,{page:m}),s==null?void 0:s(m,u)]})}),t.length>1&&e.jsxs("div",{className:"bim-rd-img-pager",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:u===0,onClick:()=>d(u-1),children:"‹"}),e.jsx("span",{"aria-live":"polite",children:m.label??`${u+1} / ${t.length}`}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:u===t.length-1,onClick:()=>d(u+1),children:"›"})]})]})}const No={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},vt=[15,16,17,18,20,22,24],Xi=18,ql="bim-reader-prefs",Hu="bim-reading-mode";function Fu(){const t={...No};try{const n=localStorage.getItem(ql),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&vt.includes(o.fontSize)&&(t.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(Hu))==="paragraph"&&(t.readingMode="paragraph"),o.properNames===!0&&(t.properNames=!0),o.writingMode==="vertical"&&(t.writingMode="vertical"),o.workLinks===!1&&(t.workLinks=!1)}catch{}return t}function Du(t){try{localStorage.setItem(ql,JSON.stringify(t))}catch{}}function Hn(t,n){const o=t??Xi,r=vt;let s=r.indexOf(o);return s<0&&(s=r.indexOf(Xi)),r[Math.max(0,Math.min(r.length-1,s+n))]}function Xl(){const[t,n]=g.useState(No);g.useEffect(()=>{n(Fu())},[]);const o=g.useCallback(r=>{n(s=>{const l={...s,...r};return Du(l),l})},[]);return[t,o]}function Zi(t){if(t.optionLabel)return t.optionLabel;const n=t.label||t.key;return!t.sourceName||n.includes(t.sourceName)?n:`${n} · ${t.sourceName}`}function Zl(t,n){if(!(!t||t.length===0))return(n!=null?t.find(o=>o.key===n):void 0)??t.find(o=>o.primary)??t[0]}function Jl(t){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(t),n}const Zr=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":"true",children:e.jsx("path",{d:"M4 6h16M4 12h10M4 18h16"})}),Uu=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M15 5l-7 7 7 7"})}),Vu=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M9 5l7 7-7 7"})}),Jr=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"4",y:"3",width:"16",height:"18",rx:"1.5"}),e.jsx("path",{d:"M9 3v18M13 7v10M16.5 7v10"})]});function Qr(t,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(a=>a.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],l=document.activeElement;t.shiftKey&&(l===r||!n.contains(l))?(t.preventDefault(),s.focus()):!t.shiftKey&&(l===s||!n.contains(l))&&(t.preventDefault(),r.focus())}function es(t,n){const[o,r]=g.useState(n);return g.useEffect(()=>{var a;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(t);r(s.matches);const l=()=>r(s.matches);return(a=s.addEventListener)==null||a.call(s,"change",l),()=>{var p;return(p=s.removeEventListener)==null?void 0:p.call(s,"change",l)}},[t]),o}function Gu(){const t=g.useContext(Dt),{t:n}=Z();if(!t)return null;const o=t.locale==="zh-Hant";return e.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>t.setLocale(o?"zh-Hans":"zh-Hant"),children:[e.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),e.jsx("span",{className:"bim-rd-off",children:"|"}),e.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function Yu(t,n){if(!t)return;let o;for(const r of Array.from(t.querySelectorAll('[id^="rd-e-"]')))if(r.getBoundingClientRect().top<=n+8)o=r.id;else break;return o}function Ku(t){var l;if(typeof window>"u"||!t)return;const n=(l=window.getSelection)==null?void 0:l.call(window);if(!n||n.isCollapsed||n.rangeCount===0)return;const o=t.querySelector(".bim-rd-col"),r=a=>{const p=(a==null?void 0:a.nodeType)===1?a:a==null?void 0:a.parentElement;return!!a&&!!(o!=null&&o.contains(a))&&!(p!=null&&p.closest(".bim-rd-src, .bim-rd-pager"))};if(!r(n.anchorNode)||!r(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function Ql({title:t,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:l,tocCaption:a,images:p,imagesLoading:c,renderImageOverlay:d,imagePanel:u="auto",prefs:m,onPrefsChange:h,paragraphToggle:f,properNameToggle:x=!0,allowVertical:j,byline:y,current:_,workLinkToggle:b,rail:v,onReportError:S,revisedAt:k,backHref:$,backLabel:w,bottomBar:z=!0,pager:B=!0,pagerUnit:I,versions:N,currentVersionKey:O,onVersionChange:C,versionSource:T=!0,keepChapterOnVersionChange:R=!1,customImagePanel:A,toolbarExtra:H,isWarpMode:q,children:ne,className:L,style:Q}){const{t:P,convert:D}=Z(),pe=w??P("reader.back"),le=D(I??P("reader.unitJuan")),fe=g.useId().replace(/:/g,""),ue=`bim-rd-toc-${fe}`,xe=`bim-rd-text-${fe}`,Ee=g.useRef(null),ie=g.useRef(null),Ae=g.useRef(null),He=g.useRef(null),Y=es(Dl,!0),J=es(Vl,!1),he=z&&J,[ze,G]=g.useState(null),ve=g.useRef(null),ae=g.useRef(null),Se=(U,X)=>{ae.current=X,G(Le=>Le===U?null:U)},K=g.useCallback(()=>{var U;G(null),(U=ae.current)==null||U.focus()},[]);g.useEffect(()=>{he||G(null)},[he]),g.useEffect(()=>{var U,X;ze&&((X=(U=ve.current)==null?void 0:U.querySelector("button:not([disabled])"))==null||X.focus())},[ze]);const[Ce,Pe]=g.useState("auto"),M=Ce==="auto"?Y:Ce==="open",ee=!Y,be=!!A||!!p&&p.length>0,[W,re]=g.useState(u);g.useEffect(()=>{re(u)},[u]);const te=W==="auto"?be||!!c:W==="open",me=g.useCallback(U=>{var X;Pe("auto"),U&&((X=He.current)==null||X.focus())},[]),Ne=()=>Pe(M?"closed":"open");g.useEffect(()=>{if(!ee||Ce!=="open")return;const U=Ae.current,X=U==null?void 0:U.querySelector('input, [data-rd-toc-key][tabindex="0"]');X==null||X.focus()},[ee,Ce]);const Me=g.useCallback(U=>{s(U),ee&&me(!1);const X=ie.current,Le=Ee.current;if(X&&Le&&typeof window<"u"){const _e=X.getBoundingClientRect().top-Le.getBoundingClientRect().bottom;_e<0&&window.scrollBy({top:_e})}},[s,ee,me]),Be=g.useMemo(()=>Jl(o),[o]),[Fe,Ze]=g.useState(null),de=Zl(N,O!==void 0?O:Fe),Qe=(de==null?void 0:de.key)??null,E=g.useMemo(()=>Be.map(U=>U.key).join(`
|
|
638
|
-
`),[Be]),oe=g.useRef(null),se=U=>{U!==Qe&&(R||(oe.current={key:U,sig:E,done:!1}),O===void 0&&Ze(U),C==null||C(U))};g.useEffect(()=>{const U=oe.current;if(!U||U.key!==Qe)return;const X=Be.find(_e=>!_e.disabled);if(!X)return;const Le=E!==U.sig;!Le&&U.done||(Le?oe.current=null:U.done=!0,X.key!==r&&Me(X.key))},[Qe,E,Be,r,Me]);const je=Be.find(U=>U.key===r),ke=()=>{var U;S==null||S({chapterKey:r,chapterLabel:typeof(je==null?void 0:je.label)=="string"?je.label:void 0,anchor:Yu(ie.current,((U=Ee.current)==null?void 0:U.getBoundingClientRect().bottom)??0),selectedText:Ku(ie.current)})},ge=Be.findIndex(U=>U.key===r),V=ge>0?Be.slice(0,ge).reverse().find(U=>!U.disabled):void 0,ce=ge>=0?Be.slice(ge+1).find(U=>!U.disabled):void 0,Te=m.fontSize??Xi,Ie={...Q,...m.fontSize?{"--bimrd-fs":`${m.fontSize}px`}:null};return e.jsxs("div",{className:["bim-rd",m.writingMode==="vertical"&&j?"bim-rd-vertical":"",L].filter(Boolean).join(" "),"data-toc":Ce,"data-img":te?"open":"closed","data-bb":he?"":void 0,"data-warp":q?"true":void 0,style:Ie,children:[e.jsx("style",{children:Gl}),e.jsx("a",{className:"bim-rd-skip",href:`#${xe}`,onClick:U=>{var X,Le,_e;U.preventDefault(),(X=ie.current)==null||X.focus(),(_e=(Le=ie.current)==null?void 0:Le.scrollIntoView)==null||_e.call(Le,{block:"start"})},children:P("reader.skipToText")}),e.jsxs("div",{className:"bim-rd-bar",ref:Ee,children:[$&&e.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":P("reader.backAria",{label:pe}),children:[e.jsx("span",{"aria-hidden":"true",children:"‹"}),e.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:pe})]}),(t||n||y||_)&&e.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[t&&e.jsx("b",{children:t}),y&&e.jsx("span",{className:"bim-rd-by",children:y}),_&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-rd-cur",children:_})]}),n&&e.jsx("span",{children:n})]}),e.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":P("reader.settings"),children:[N&&N.length>1&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"bim-rd-ver",title:de?D(Zi(de)):void 0,children:[e.jsx("span",{className:"bim-rd-tlabel",children:P("reader.version")}),e.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:P("reader.versionShort")}),e.jsx("select",{"aria-label":P("reader.version"),value:Qe??"",onChange:U=>se(U.target.value),children:N.map(U=>e.jsx("option",{value:U.key,children:D(Zi(U))},U.key))})]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),B&&(V||ce)&&e.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":P("reader.pagerGroup",{unit:le}),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.prevUnit",{unit:le}),title:V?typeof V.label=="string"&&V.label?P("reader.prevUnitTitle",{unit:le,label:V.label}):P("reader.prevUnit",{unit:le}):P("reader.firstUnit",{unit:le}),disabled:!V,onClick:()=>V&&Me(V.key),children:e.jsx(Uu,{})}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.nextUnit",{unit:le}),title:ce?typeof ce.label=="string"&&ce.label?P("reader.nextUnitTitle",{unit:le,label:ce.label}):P("reader.nextUnit",{unit:le}):P("reader.lastUnit",{unit:le}),disabled:!ce,onClick:()=>ce&&Me(ce.key),children:e.jsx(Vu,{})})]}),B&&(V||ce)&&e.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),e.jsxs("button",{ref:He,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":M,"aria-controls":ue,onClick:Ne,children:[e.jsx(Zr,{}),e.jsx("span",{className:"bim-rd-tlabel",children:P("reader.toc")})]}),e.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":te,onClick:()=>re(te?"closed":"open"),children:[e.jsx(Jr,{}),P("reader.images")]}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx(Gu,{}),e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":P("reader.fontSmaller"),disabled:Te<=vt[0],onClick:()=>h({fontSize:Hn(m.fontSize,-1)}),children:"A−"}),e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":P("reader.fontLarger"),disabled:Te>=vt[vt.length-1],onClick:()=>h({fontSize:Hn(m.fontSize,1)}),children:"A+"}),(f||x||j)&&e.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),f&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":m.readingMode==="paragraph",title:P("reader.paragraphTitle"),onClick:()=>h({readingMode:m.readingMode==="paragraph"?"line":"paragraph"}),children:P("reader.paragraph")}),b&&e.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[e.jsx("input",{type:"checkbox",checked:m.workLinks,onChange:U=>h({workLinks:U.target.checked})}),e.jsx("span",{children:P("reader.workLinks")})]}),x&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":m.properNames,title:P("reader.properNameTitle"),onClick:()=>h({properNames:!m.properNames}),children:P("reader.properName")}),j&&e.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":m.writingMode==="vertical",onClick:()=>h({writingMode:m.writingMode==="vertical"?"horizontal":"vertical"}),children:P("reader.vertical")}),H]})]}),e.jsxs("div",{className:"bim-rd-body",children:[e.jsxs("div",{className:"bim-rd-toc",id:ue,ref:Ae,role:ee&&M?"dialog":void 0,"aria-modal":ee&&M?!0:void 0,"aria-label":ee&&M?P("reader.toc"):void 0,onKeyDown:U=>{if(!(!ee||!M)){if(U.key==="Escape"){U.stopPropagation(),me(!0);return}U.key==="Tab"&&Qr(U,Ae.current)}},children:[e.jsxs("div",{className:"bim-rd-toc-top",children:[e.jsxs("div",{className:"bim-rd-toc-head",children:[e.jsx("span",{children:a??P("reader.toc")}),ee&&e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.closeToc"),onClick:()=>me(!0),children:"✕"})]}),l]}),e.jsx(Kl,{items:o,activeKey:r,onSelect:Me})]}),e.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>me(!0)}),e.jsx("aside",{className:"bim-rd-img","aria-label":P("reader.images"),children:te&&(A||e.jsx(qi,{pages:p??null,loading:c,renderOverlay:d}))}),e.jsxs("div",{className:"bim-rd-text",id:xe,ref:ie,tabIndex:-1,"data-rail":(v||S)&&!q?"true":void 0,children:[e.jsxs("div",{className:"bim-rd-col",children:[ne,T&&de&&(de.sourceName||de.license)&&e.jsxs("p",{className:"bim-rd-src","data-version":de.key,children:[de.sourceName&&e.jsxs(e.Fragment,{children:[P("reader.sourceLabel")," ",de.sourceUrl?e.jsx("a",{className:"bim-rd-link",href:de.sourceUrl,target:"_blank",rel:"noreferrer",children:D(de.sourceName)}):D(de.sourceName)]}),de.sourceName&&de.license&&e.jsx("span",{className:"bim-rd-dot"}),de.license&&e.jsx(e.Fragment,{children:P("reader.licenseOf",{license:de.license})})]}),k&&e.jsx("p",{className:"bim-rd-src bim-rd-rev",children:P("reader.revisedAt",{date:k})}),S&&e.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:U=>U.preventDefault(),onClick:ke,children:P("reader.reportError")})}),B&&(V||ce)&&e.jsxs("nav",{className:"bim-rd-pager","aria-label":P("reader.pagerNav"),children:[V?e.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>Me(V.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[e.jsx("span",{"aria-hidden":"true",children:"← "}),P("reader.prevUnit",{unit:le})]}),e.jsx("span",{className:"bim-rd-pglabel",children:V.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",P("reader.firstUnit",{unit:le})]}),ce?e.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>Me(ce.key),children:[e.jsxs("span",{className:"bim-rd-pgcap",children:[P("reader.nextUnit",{unit:le}),e.jsx("span",{"aria-hidden":"true",children:" →"})]}),e.jsx("span",{className:"bim-rd-pglabel",children:ce.label})]}):e.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[P("reader.lastUnit",{unit:le})," →"]})]})]}),(v||S)&&!q&&e.jsxs("aside",{className:"bim-rd-rail","aria-label":P("reader.rail"),children:[v,S&&e.jsx("div",{className:"bim-rd-rail-acts",children:e.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:U=>U.preventDefault(),onClick:ke,children:P("reader.reportError")})})]})]})]}),he&&e.jsxs("nav",{className:"bim-rd-bb","aria-label":P("reader.bottomBar"),children:[e.jsxs("button",{type:"button","aria-expanded":M,"aria-controls":ue,onClick:()=>{G(null),Ne()},children:[e.jsx(Zr,{}),e.jsx("span",{children:P("reader.tocShort")})]}),e.jsxs("button",{type:"button","aria-expanded":ze==="img","aria-haspopup":"dialog",onClick:U=>Se("img",U.currentTarget),children:[e.jsx(Jr,{}),e.jsx("span",{children:P("reader.images")})]}),e.jsxs("button",{type:"button","aria-expanded":ze==="fs","aria-haspopup":"dialog",onClick:U=>Se("fs",U.currentTarget),children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),e.jsx("span",{children:P("reader.fontSize")})]}),S&&e.jsxs("button",{type:"button",onMouseDown:U=>U.preventDefault(),onClick:()=>{G(null),ke()},children:[e.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),e.jsx("span",{children:P("reader.reportError")})]})]}),he&&ze&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:K}),e.jsxs("div",{className:"bim-rd-sheet",ref:ve,role:"dialog","aria-modal":"true","aria-label":P(ze==="img"?"reader.images":"reader.fontSize"),onKeyDown:U=>{if(U.key==="Escape"){U.stopPropagation(),K();return}U.key==="Tab"&&Qr(U,ve.current)},children:[e.jsxs("div",{className:"bim-rd-sheet-head",children:[e.jsx("span",{children:P(ze==="img"?"reader.images":"reader.fontSize")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.close"),onClick:K,children:"✕"})]}),ze==="img"?e.jsx("div",{className:"bim-rd-sheet-img",children:e.jsx(qi,{pages:p??null,loading:c,renderOverlay:d})}):e.jsxs("div",{className:"bim-rd-sheet-fs",children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.fontSmaller"),disabled:Te<=vt[0],onClick:()=>h({fontSize:Hn(m.fontSize,-1)}),children:"A−"}),e.jsxs("output",{"aria-live":"polite",children:[Te,"px"]}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-label":P("reader.fontLarger"),disabled:Te>=vt[vt.length-1],onClick:()=>h({fontSize:Hn(m.fontSize,1)}),children:"A+"})]})]})]})]})}const ea=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],qu={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function qe(t){return qu[t]??t}const tn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],nn={熹平: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},ta={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function ai(t){const n=t.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const o=parseInt(n[1],10);if(o<100||o>2100)return;const r=n[2]?parseInt(n[2],10):void 0;return{from:o,to:r!=null&&r>=o&&r<=2100?r:void 0}}function Xu(t){return t>=1950?"":t>=1912?"民國":t>=1645?"清":t>=1368?"明":t>=1279?"元":t>=960?"宋":t>=907?"五代":t>=618?"唐":t>=581?"隋":t>=420?"南北朝":t>=265?"晉":t>=220?"三國":t>=-202?"漢":""}const Zu=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,ts={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Eo(t){const n=t.trim().replace(/[代朝]$/,"");for(const s of Object.keys(ts))if(n.startsWith(s))return ts[s];const o=qe(n);if(Mt[o]!=null)return o;const r=wt(n);if(r&&n.length<=r.length+1)return qe(r)}function Pt(t,n){if(n){const o=ta[`${n}|${t}`];if(o!=null)return o}return nn[t]}const Ju=1911;function Qu(t){const n=nn[t];if(n==null)return;const o=bt[t];let r;for(const[s,l]of Object.entries(nn))bt[s]===o&&l>n&&(r==null||l<r)&&(r=l);return r!=null?r-1:void 0}const em={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function qn(t){if(!t)return;if(/^\d+$/.test(t))return parseInt(t,10);let n=0,o=0,r=!1;for(const l of t){const a=em[l];if(a===void 0)return;r=!0,l==="十"?o=(o||1)*10:l==="廿"||l==="卅"?(n+=a,o=0):o>=10?(n+=o+a,o=0):o=o*10+a}const s=n+o;return r&&s>0?s:void 0}function wt(t){for(const n of ea)if(t.startsWith(n))return n}const bt={};{const t=(n,o)=>{for(const r of o)bt[r]=n};t("東漢",["熹平","建安"]),t("三國",["黃初","正始"]),t("五代",["廣政"]),t("西晉",["太康"]),t("東晉",["永和"]),t("隋",["開皇"]),t("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),t("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),t("金",["大定","明昌"]),t("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),t("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),t("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),t("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Bt(t,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(nn))if(t.includes(r)&&!(o&&bt[r]&&bt[r]!==o&&ta[`${o}|${r}`]==null))return r}function Tn(t){var a,p,c;const n={era:"",reign:"",source:"none"},o=t.dating;if(o!=null&&o.era||o!=null&&o.reign)return{era:o.era??"",reign:o.reign??"",source:o.certainty==="attested"?"catalog":"edition"};const r=(a=t.lineage)==null?void 0:a.year_text;if(r){const d=wt(r)??"";return{era:qe(d),reign:Bt(r,d)??"",source:"lineage"}}const s=(p=t.publication_info)==null?void 0:p.year;if(s){const d=ai(s);if(d)return{era:Xu(d.from),reign:"",source:"publication"};const u=wt(s)??Eo(s)??((c=tn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",m=Bt(s,u)??"",h=u||(m?bt[m]??"":"");if(h||m)return{era:qe(h),reign:m,source:"publication"}}const l=t.edition||t.title||"";if(l){const d=wt(l);if(d)return{era:qe(d),reign:Bt(l,d)??"",source:"edition"};const u=tn.find(m=>m.pattern.test(l));if(u)return{era:qe(u.era),reign:Bt(l,u.era)??u.reign??"",source:"edition"}}return n}function ci(t){var r,s,l,a,p,c,d,u,m;if(((r=t.dating)==null?void 0:r.year)!=null)return t.dating.year;if(typeof((s=t.lineage)==null?void 0:s.year)=="number")return t.lineage.year;const n=(l=t.publication_info)==null?void 0:l.year;if(n){const h=ai(n);if(h)return h.from}const o=[(a=t.lineage)==null?void 0:a.year_text,(p=t.publication_info)==null?void 0:p.year,t.edition,t.edition?void 0:t.title].filter(Boolean);for(const h of o){const f=((c=t.publication_info)==null?void 0:c.year)||((d=t.lineage)==null?void 0:d.year_text);if(f&&h!==f&&(wt(f)||Eo(f)))break;const x=h.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??h.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const v=parseInt(x[1],10);if(v>=100&&v<=2100)return v}const j=h.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(j){const v=wt(h);if(!v||qe(v)==="民國"){const k=qn(j[1]);if(k!=null&&k>=1&&k<=120)return Ju+k}}const y=wt(h)??((u=tn.find(v=>v.pattern.test(h)))==null?void 0:u.era),_=y?qe(y):void 0,b=Bt(h,_)??(wt(h)||(m=tn.find(v=>v.pattern.test(h)))==null?void 0:m.reign);if(b){const v=Pt(b,_);if(v==null)continue;const S=h.indexOf(b),k=S>=0?h.slice(S+b.length):"",$=k.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??k.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),w=$?qn($[1]):void 0;return v+(w?w-1:0)}}}function Io(t){var a,p,c,d,u,m;const n=(a=t.dating)==null?void 0:a.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const o=(p=t.lineage)==null?void 0:p.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=t.lineage)==null?void 0:c.year_text;if(r){const h=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const f=Ji[qe(h[1])],x=Mt[qe(h[2])];if(f!=null&&x!=null)return{from:Math.min(f,x)-20,to:Math.max(f,x)+40}}}const s=(d=t.publication_info)==null?void 0:d.year;if(s){const h=ai(s);if((h==null?void 0:h.to)!=null)return{from:h.from,to:h.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=Ji[qe(f[1])],j=Mt[qe(f[2])];if(x!=null&&j!=null)return{from:Math.min(x,j)-20,to:Math.max(x,j)+40}}}const l=[(u=t.publication_info)==null?void 0:u.year,t.edition,t.title].filter(Boolean);for(const h of l){if(!/[間间]/.test(h))continue;const f=wt(h)??Eo(h)??((m=tn.find(y=>y.pattern.test(h)))==null?void 0:m.era),x=f?qe(f):void 0,j=[];for(const y of Object.keys(nn))h.includes(y)&&(x&&bt[y]&&bt[y]!==x||Pt(y,x)!=null&&j.push(y));if(j.length===0){const y=h.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const _ of[y[1],y[2]])for(const b of Object.keys(nn))if(bt[b]===x&&!(b[0]!==_&&b[b.length-1]!==_)&&Pt(b,x)!=null){j.push(b);break}}}if(j.length>0){const y=j.map(S=>Pt(S,x)).filter(S=>S!=null),_=Math.min(...y),b=j.reduce((S,k)=>Pt(S,x)>=Pt(k,x)?S:k),v=Qu(b)??Ai(x??"")??Math.max(...y);return{from:_,to:v>_?v:Ai(x??bt[b]??"")??_}}if(x&&Mt[x]!=null)return{from:Mt[x],to:Ai(x)??Mt[x]}}}const Mt={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},tm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],nm=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,ns=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function is(t,n){for(const o of ea){const r=t.indexOf(o);if(r<0)continue;if(o.length===1){const c=t[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Bt(t.slice(r),qe(o)))continue}const s=qe(o);if(s===n)continue;const l=t.slice(r),a=Bt(l,s)??"";let p;if(a){const c=Pt(a,s);if(c!=null){const u=l.slice(l.indexOf(a)+a.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=u?qn(u[1]):void 0;p=c+(m?m-1:0)}}return{era:s,reign:a,year:p}}for(const o of tn)if(o.pattern.test(t))return{era:qe(o.era),reign:o.reign??""}}function im(t){var _,b,v,S,k;const n=Tn(t),o=((_=t.publication_info)==null?void 0:_.year)??"",r=o?ai(o):void 0;if(!n.era&&!n.reign&&!r)return;const s=t.edition||t.title||"",l=/[間间]/.test(s),a=((b=t.lineage)==null?void 0:b.year_text)??"",p=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(a),c=n.source==="publication"&&Zu.test(o),d=n.source==="publication"&&/[間间]/.test(o),u=a.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;l||p||c||d?m=void 0:u?m=parseInt(u[2],10):m=ci(t);const h=m==null?Io(t):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"?`版本傳承著錄「${((v=t.lineage)==null?void 0:v.year_text)??((S=t.lineage)==null?void 0:S.year)??""}」`:`出版著錄「${((k=t.publication_info)==null?void 0:k.year)??""}」`,j={era:n.era,reign:n.reign,year:m,yearRange:h,certainty:f,source:n.source==="edition"?"edition":"catalog",basis:x};if(u){const $=a.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==j.era&&(j.laterRepair={era:$[1]})}if(!j.laterRepair&&nm.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(j.laterRepair={era:$[1]})}const y=tm.find($=>$.re.test(s));if(y){const $=s.search(y.re),w=s.slice($),z=is(w,n.era)??is(s,n.era);z&&(j.basedOn={era:z.era,reign:z.reign,year:z.year,relation:y.relation})}return j}const Ji={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Ai(t){return Ji[t]}function Xn(t){const n=ci(t);if(n!=null)return n;const o=Io(t);if(o)return o.from;const r=Tn(t).era;return r?Mt[r]:void 0}const os=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Qi(t){const n=os.indexOf(t);return n===-1?os.length:n}function om(t){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of t){const l=s.relation;l==="part_of"?n.belongsTo.push(s):l==="collected_in"?n.collected.push(s):l==="has_part"||l==="contains_text_of"?n.contains.push(s):l==="text_carried_by"||l==="studied_by"||l==="derived_from"||l==="followed_by"||l==="has_adaptation"?n.derivative.push(s):l==="studies"||l==="preceded_by"?n.studies.push(s):n.related.push(s)}const o=[],r=(s,l)=>{n[s].length&&o.push({key:s,labelKey:l,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function Ro(t,n){const o=yo(t||[]),r=new Map,s=[];for(const d of o)d.group?(r.has(d.group)||r.set(d.group,[]),r.get(d.group).push(d)):s.push(d);for(const d of r.values())d.sort((u,m)=>{const h=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return h(u)-h(m)});const l={text:[],image:[],textImage:[],physical:[]};for(const d of s){const u=Ft(d),m=u.includes("text"),h=u.includes("image");m&&h?l.textImage.push(d):m?l.text.push(d):h?l.image.push(d):l.physical.push(d)}const p=["text","image","textImage","physical"].filter(d=>l[d].length>0).map(d=>({key:d,items:l[d]})),c=[...r.entries()].map(([d,u])=>{var m,h;return{key:d,label:((m=n==null?void 0:n[d])==null?void 0:m.label)||d,description:(h=n==null?void 0:n[d])==null?void 0:h.description,items:u}});return{buckets:p,mirrors:c,total:o.length}}function di(t,n=sn("zh-Hant")){const o=[],r=t.metadata||{};r.edition&&o.push(String(r.edition)),t.source_label&&o.push(t.source_label),t.details&&o.push(t.details);const s=ni(t);return s&&s.expected>0&&o.push(s.missing>0?n("detail.volumeStatsMissing",{found:s.found,expected:s.expected,missing:s.missing}):n("detail.volumeStats",{found:s.found,expected:s.expected})),r.version&&o.push(String(r.version)),o.join(" · ")}function na(t,n){if(di(t)||n.filter(r=>r.name===t.name).length<2)return"";try{const r=new URL(t.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const l=r.pathname.split("/").filter(Boolean).pop();if(l)return decodeURIComponent(l)}catch{}return""}function ia(t,n){var l,a;const o=t.resources||[],r=[],s=[];for(const p of o){const c=Ft(p);c.includes("image")&&r.push(p),c.includes("physical")&&s.push(p)}return{id:t.id,name:t.edition||t.title||t.id,era:Tn(t),year:ci(t),sortYear:Xn(t),images:r,holders:s,locationName:(l=t.current_location)==null?void 0:l.name,important:rm(t.id,n),group:(a=n==null?void 0:n.node_groups)==null?void 0:a[t.id],hasImage:r.length>0}}function rm(t,n){var p,c;if(!n)return!1;const o=n.default_collection;if(!o)return!1;const r=(p=n.collections)==null?void 0:p[o];if(((r==null?void 0:r.book_ids)??(o==="core"?n.core_books??[]:[])).includes(t))return!0;const l=(r==null?void 0:r.groups)??[],a=(c=n.node_groups)==null?void 0:c[t];return!!a&&l.includes(a)}function oa(t,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=t.filter(c=>!r.has(c.id)).map(c=>ia(c,n));let l=s;o.era&&(l=l.filter(c=>c.era.era===o.era)),o.scanOnly&&(l=l.filter(c=>c.hasImage)),o.sort==="year"?l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=c.r.sortYear,m=d.r.sortYear;return u!=null&&m!=null?u-m||c.i-d.i:u!=null?-1:m!=null?1:c.i-d.i}).map(c=>c.r):l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=m=>(m.important?0:1)*2+(m.hasImage?0:1);return u(c.r)-u(d.r)||c.i-d.i}).map(c=>c.r);const p=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,d)=>Qi(c)-Qi(d));return{rows:l,allRows:s,eras:p,hasInferredEra:s.some(c=>c.era.source==="edition")}}function sm(t,n){var y,_;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:t,groupedIds:[]};const o=(y=n.collections)==null?void 0:y[n.default_collection],r=(o==null?void 0:o.groups)??[],s=(o==null?void 0:o.book_ids)??[],l=r.length>0||s.length>0,a=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&a.length===0)return{useGrouping:!1,coreIds:t,groupedIds:[]};const p=new Set(r),c=new Set([...s,...a]),d=b=>{if(c.has(b))return!0;const v=n.node_groups[b];return v!=null&&p.has(v)},u=[],m=new Map,h=[];for(const b of t)if(!((_=n.excluded_books)!=null&&_.includes(b)))if(d(b))u.push(b);else{const v=n.node_groups[b];v?(m.has(v)||m.set(v,[]),m.get(v).push(b)):h.push(b)}if(h.length+[...m.values()].reduce((b,v)=>b+v.length,0)<3)return{useGrouping:!1,coreIds:t,groupedIds:[]};const x=new Map((n.groups??[]).map(b=>[b.id,b])),j=[...m.entries()].map(([b,v])=>{const S=x.get(b);return{id:b,label:(S==null?void 0:S.label)??b,description:S==null?void 0:S.description,ids:v}});return h.length>0&&j.push({id:"__other__",label:"其他版本",description:void 0,ids:h}),{useGrouping:!0,coreIds:u,groupedIds:j}}const ra=["撰","編","注","校","譯","繪","其他"],lm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Lo(t){if(!t||!t.trim())return"撰";const n=t.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of lm)if(r.test(n))return o;return"其他"}function Ao(t){if(!t)return"";const n=t.trim();return!n||!/[一-鿿]/.test(n)?"":n}function sa(t,n="全部"){const o=new Map;for(const s of t){const l=Lo(s);o.set(l,(o.get(l)??0)+1)}const r=[{cls:"全部",label:n,count:t.length}];for(const s of ra){const l=o.get(s);l&&r.push({cls:s,label:s,count:l})}return r.length>2?r:[]}function la(t,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(a=>({id:a.work_id||a.book_id||void 0,title:a.title,section:a.section,volumes:a.volumes||[],subItems:a.sub_items,edition:a.edition,found:a.found_volumes,expected:a.expected_volumes})),l=[...new Set(s.map(a=>a.section).filter(Boolean))];return{rows:s,source:"catalog",sections:l,totalVolumes:n.total_volumes}}return t.contained_works&&t.contained_works.length>0?{rows:t.contained_works.map(l=>({id:l.id,title:l.title,volumes:_n(l.volume_index)})),source:"works",sections:[]}:{rows:(t.books||[]).map(s=>{var l,a;return{id:s,title:((l=o==null?void 0:o.get(s))==null?void 0:l.title)||s,edition:(a=o==null?void 0:o.get(s))==null?void 0:a.edition,volumes:[]}}),source:"books",sections:[]}}function _n(t){if(t==null)return[];if(typeof t=="number")return[t];if(Array.isArray(t))return t.filter(n=>typeof n=="number");if(typeof t=="string"){const n=t.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[o,r]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,r-o+1)},(s,l)=>o+l)}return t.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function pi(t,n="冊"){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const o=[...t].sort((l,a)=>l-a),r=o[0],s=o[o.length-1];return s-r+1===o.length?`${r}–${s}`:o.length<=3?o.join(", "):`${r}–${s} (${o.length}${n})`}const am=["〇","一","二","三","四","五","六","七","八","九"],rs=["","十","百","千"];function aa(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const a=parseInt(n[l]),p=o-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=rs[p]:r+=am[a]+rs[p])}return r}function cm(t){return t==null?"":typeof t=="string"?t:t.title??""}function _t(t,n="卷"){var r,s;const o=t;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?aa(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function ca(t){var r;if(t.edition_type)return t.edition_type;if((r=t.lineage)!=null&&r.category)return t.lineage.category;const n=t.edition||t.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,l]of o)if(s.test(n))return l;return""}const dm=216,ss="clamp(280px, 23vw, 360px)",pm=1440,eo="(max-width: 719px)",um=`${eo}, (pointer: coarse)`,mm=`
|
|
639
|
-
.bim-d-main.bim-d-main-grid { max-width: ${
|
|
637
|
+
`;function Bo(e,n){var o;return n?e.key===n?!0:!!((o=e.children)!=null&&o.some(r=>Bo(r,n))):!1}const im=()=>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 om({item:e,activeKey:n,onSelect:o,tabKey:r}){const s=Bo(e,n),[a,l]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&l(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&l(!0)},[e.defaultExpanded]),t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":a,"data-rd-toc-key":e.key,tabIndex:r===e.key?0:-1,onClick:()=>l(d=>!d),children:[t.jsx(im,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),a&&t.jsx(ll,{items:e.children,activeKey:n,onSelect:o,tabKey:r})]})}function ll({items:e,activeKey:n,onSelect:o,tabKey:r}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(om,{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 cs(e,n){var o;for(const r of e)if(r.key===n||Bo(r,n))return r.key;return((o=e[0])==null?void 0:o.key)??null}function cl({items:e,activeKey:n,onSelect:o,label:r}){const{t:s}=J(),a=r??s("reader.toc"),l=g.useRef(null),[d,c]=g.useState(null);g.useEffect(()=>{c(null)},[n]);const p=g.useMemo(()=>d||(n??cs(e,n)),[d,n,e]);g.useEffect(()=>{const h=l.current;if(!h)return;const m=Array.from(h.querySelectorAll("[data-rd-toc-key]"));if(m.length===0)return;const f=m.find(x=>x.dataset.rdTocKey===p)??m.find(x=>x.dataset.rdTocKey===cs(e,n))??m.find(x=>!x.disabled)??m[0];for(const x of m)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const h=l.current,m=h==null?void 0:h.closest(".bim-rd-toc");if(!h||!m||!n)return;const f=Array.from(h.querySelectorAll("[data-rd-toc-key]")).find(k=>k.dataset.rdTocKey===n);if(!f)return;const x=f.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop;(x<m.scrollTop+80||x>m.scrollTop+m.clientHeight-40)&&(m.scrollTop=Math.max(0,x-m.clientHeight/3))},[n]);const u=g.useCallback(h=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(h.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(h.key==="ArrowDown"?y=Math.min(x.length-1,k+1):h.key==="ArrowUp"?y=Math.max(0,k-1):h.key==="Home"?y=0:h.key==="End"&&(y=x.length-1),y<0||y===k)return;h.preventDefault();const _=x[y];for(const b of x)b.tabIndex=-1;_.tabIndex=0,_.focus(),c(_.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:u,children:t.jsx(ll,{items:e,activeKey:n,onSelect:o,tabKey:p})})}function rm({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 oo({pages:e,loading:n,page:o,onPageChange:r,renderOverlay:s}){const{t:a}=J(),[l,d]=g.useState(0),c=o??l,p=f=>{r?r(f):d(f)};if(g.useEffect(()=>{o===void 0&&d(0)},[e,o]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:a("reader.imagesLoading")})});if(!e||e.length===0)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("div",{className:"bim-rd-img-empty",children:[t.jsx("div",{className:"bim-rd-img-frame","aria-hidden":"true"}),t.jsx("b",{children:a("reader.noImages")}),t.jsx("span",{children:a("reader.noImagesHint")})]})});const u=Math.max(0,Math.min(e.length-1,c)),h=e[u],m=h.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:h.url,alt:h.alt??a("reader.imageAlt",{label:m}),width:h.width,height:h.height,loading:"lazy",decoding:"async"}),t.jsx(rm,{page:h}),s==null?void 0:s(h,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:h.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 Wo={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},kt=[15,16,17,18,20,22,24],ro=18,dl="bim-reader-prefs",sm="bim-reading-mode";function am(){const e={...Wo};try{const n=localStorage.getItem(dl),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&kt.includes(o.fontSize)&&(e.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(sm))==="paragraph"&&(e.readingMode="paragraph"),o.properNames===!0&&(e.properNames=!0),o.writingMode==="vertical"&&(e.writingMode="vertical"),o.workLinks===!1&&(e.workLinks=!1)}catch{}return e}function lm(e){try{localStorage.setItem(dl,JSON.stringify(e))}catch{}}function Gn(e,n){const o=e??ro,r=kt;let s=r.indexOf(o);return s<0&&(s=r.indexOf(ro)),r[Math.max(0,Math.min(r.length-1,s+n))]}function pl(){const[e,n]=g.useState(Wo);g.useEffect(()=>{n(am())},[]);const o=g.useCallback(r=>{n(s=>{const a={...s,...r};return lm(a),a})},[]);return[e,o]}function so(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 ul(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 ml(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 ds=()=>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"})}),dm=()=>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"})}),ps=()=>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 us(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 ms(e,n){const[o,r]=g.useState(n);return g.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);r(s.matches);const a=()=>r(s.matches);return(l=s.addEventListener)==null||l.call(s,"change",a),()=>{var d;return(d=s.removeEventListener)==null?void 0:d.call(s,"change",a)}},[e]),o}function pm(){const e=g.useContext(Gt),{t:n}=J();if(!e)return null;const o=e.locale==="zh-Hant";return t.jsxs("button",{type:"button",className:"bim-rd-t",title:n(o?"common.toHans":"common.toHant"),"aria-label":n(o?"common.toHans":"common.toHant"),onClick:()=>e.setLocale(o?"zh-Hans":"zh-Hant"),children:[t.jsx("span",{className:o?"bim-rd-on":"bim-rd-off",children:n("common.localeShortHant")}),t.jsx("span",{className:"bim-rd-off",children:"|"}),t.jsx("span",{className:o?"bim-rd-off":"bim-rd-on",children:n("common.localeShortHans")})]})}function um(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 mm(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 hl({title:e,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:a,tocCaption:l,images:d,imagesLoading:c,renderImageOverlay:p,imagePanel:u="auto",prefs:h,onPrefsChange:m,paragraphToggle:f,properNameToggle:x=!0,allowVertical:k,byline:y,current:_,workLinkToggle:b,rail:j,onReportError:w,revisedAt:v,backHref:$,backLabel:S,bottomBar:C=!0,pager:B=!0,pagerUnit:T,versions:z,currentVersionKey:F,onVersionChange:N,versionSource:R=!0,keepChapterOnVersionChange:O=!1,customImagePanel:I,toolbarExtra:P,isWarpMode:G,children:K,className:L,style:Z}){const{t:A,convert:U}=J(),ce=S??A("reader.back"),ee=U(T??A("reader.unitJuan")),ue=g.useId().replace(/:/g,""),de=`bim-rd-toc-${ue}`,be=`bim-rd-text-${ue}`,Oe=g.useRef(null),ie=g.useRef(null),Re=g.useRef(null),Le=g.useRef(null),q=ms(ol,!0),Q=ms(sl,!1),fe=C&&Q,[ze,Y]=g.useState(null),ve=g.useRef(null),le=g.useRef(null),Se=(D,re)=>{le.current=re,Y(Pe=>Pe===D?null:D)},X=g.useCallback(()=>{var D;Y(null),(D=le.current)==null||D.focus()},[]);g.useEffect(()=>{fe||Y(null)},[fe]),g.useEffect(()=>{var D,re;ze&&((re=(D=ve.current)==null?void 0:D.querySelector("button:not([disabled])"))==null||re.focus())},[ze]);const[Ce,Me]=g.useState("auto"),M=Ce==="auto"?q:Ce==="open",te=!q,ye=!!I||!!d&&d.length>0,[H,se]=g.useState(u);g.useEffect(()=>{se(u)},[u]);const ne=H==="auto"?ye||!!c:H==="open",ge=g.useCallback(D=>{var re;Me("auto"),D&&((re=Le.current)==null||re.focus())},[]),Ne=()=>Me(M?"closed":"open");g.useEffect(()=>{if(!te||Ce!=="open")return;const D=Re.current,re=D==null?void 0:D.querySelector('input, [data-rd-toc-key][tabindex="0"]');re==null||re.focus()},[te,Ce]);const Be=g.useCallback(D=>{s(D),te&&ge(!1);const re=ie.current,Pe=Oe.current;if(re&&Pe&&typeof window<"u"){const _e=re.getBoundingClientRect().top-Pe.getBoundingClientRect().bottom;_e<0&&window.scrollBy({top:_e})}},[s,te,ge]),We=g.useMemo(()=>ml(o),[o]),[Ue,Je]=g.useState(null),me=ul(z,F!==void 0?F:Ue),et=(me==null?void 0:me.key)??null,E=g.useMemo(()=>We.map(D=>D.key).join(`
|
|
638
|
+
`),[We]),oe=g.useRef(null),ae=D=>{D!==et&&(O||(oe.current={key:D,sig:E,done:!1}),F===void 0&&Je(D),N==null||N(D))};g.useEffect(()=>{const D=oe.current;if(!D||D.key!==et)return;const re=We.find(_e=>!_e.disabled);if(!re)return;const Pe=E!==D.sig;!Pe&&D.done||(Pe?oe.current=null:D.done=!0,re.key!==r&&Be(re.key))},[et,E,We,r,Be]);const je=We.find(D=>D.key===r),ke=()=>{var D;w==null||w({chapterKey:r,chapterLabel:typeof(je==null?void 0:je.label)=="string"?je.label:void 0,anchor:um(ie.current,((D=Oe.current)==null?void 0:D.getBoundingClientRect().bottom)??0),selectedText:mm(ie.current)})},xe=We.findIndex(D=>D.key===r),V=xe>0?We.slice(0,xe).reverse().find(D=>!D.disabled):void 0,pe=xe>=0?We.slice(xe+1).find(D=>!D.disabled):void 0,Te=h.fontSize??ro,Ee={...Z,...h.fontSize?{"--bimrd-fs":`${h.fontSize}px`}:null};return t.jsxs("div",{className:["bim-rd",h.writingMode==="vertical"&&k?"bim-rd-vertical":"",L].filter(Boolean).join(" "),"data-toc":Ce,"data-img":ne?"open":"closed","data-bb":fe?"":void 0,"data-warp":G?"true":void 0,style:Ee,children:[t.jsx("style",{children:al}),t.jsx("a",{className:"bim-rd-skip",href:`#${be}`,onClick:D=>{var re,Pe,_e;D.preventDefault(),(re=ie.current)==null||re.focus(),(_e=(Pe=ie.current)==null?void 0:Pe.scrollIntoView)==null||_e.call(Pe,{block:"start"})},children:A("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Oe,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":A("reader.backAria",{label:ce}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:ce})]}),(e||n||y||_)&&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}),_&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:_})]}),n&&t.jsx("span",{children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":A("reader.settings"),children:[z&&z.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:me?U(so(me)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:A("reader.versionShort")}),t.jsx("select",{"aria-label":A("reader.version"),value:et??"",onChange:D=>ae(D.target.value),children:z.map(D=>t.jsx("option",{value:D.key,children:U(so(D))},D.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),B&&(V||pe)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":A("reader.pagerGroup",{unit:ee}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.prevUnit",{unit:ee}),title:V?typeof V.label=="string"&&V.label?A("reader.prevUnitTitle",{unit:ee,label:V.label}):A("reader.prevUnit",{unit:ee}):A("reader.firstUnit",{unit:ee}),disabled:!V,onClick:()=>V&&Be(V.key),children:t.jsx(cm,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.nextUnit",{unit:ee}),title:pe?typeof pe.label=="string"&&pe.label?A("reader.nextUnitTitle",{unit:ee,label:pe.label}):A("reader.nextUnit",{unit:ee}):A("reader.lastUnit",{unit:ee}),disabled:!pe,onClick:()=>pe&&Be(pe.key),children:t.jsx(dm,{})})]}),B&&(V||pe)&&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":M,"aria-controls":de,onClick:Ne,children:[t.jsx(ds,{}),t.jsx("span",{className:"bim-rd-tlabel",children:A("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":ne,onClick:()=>se(ne?"closed":"open"),children:[t.jsx(ps,{}),A("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(pm,{}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontSmaller"),disabled:Te<=kt[0],onClick:()=>m({fontSize:Gn(h.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":A("reader.fontLarger"),disabled:Te>=kt[kt.length-1],onClick:()=>m({fontSize:Gn(h.fontSize,1)}),children:"A+"}),(f||x||k)&&t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),f&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":h.readingMode==="paragraph",title:A("reader.paragraphTitle"),onClick:()=>m({readingMode:h.readingMode==="paragraph"?"line":"paragraph"}),children:A("reader.paragraph")}),b&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[t.jsx("input",{type:"checkbox",checked:h.workLinks,onChange:D=>m({workLinks:D.target.checked})}),t.jsx("span",{children:A("reader.workLinks")})]}),x&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":h.properNames,title:A("reader.properNameTitle"),onClick:()=>m({properNames:!h.properNames}),children:A("reader.properName")}),k&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":h.writingMode==="vertical",onClick:()=>m({writingMode:h.writingMode==="vertical"?"horizontal":"vertical"}),children:A("reader.vertical")}),P]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:de,ref:Re,role:te&&M?"dialog":void 0,"aria-modal":te&&M?!0:void 0,"aria-label":te&&M?A("reader.toc"):void 0,onKeyDown:D=>{if(!(!te||!M)){if(D.key==="Escape"){D.stopPropagation(),ge(!0);return}D.key==="Tab"&&us(D,Re.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:l??A("reader.toc")}),te&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.closeToc"),onClick:()=>ge(!0),children:"✕"})]}),a]}),t.jsx(cl,{items:o,activeKey:r,onSelect:Be})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>ge(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":A("reader.images"),children:ne&&(I||t.jsx(oo,{pages:d??null,loading:c,renderOverlay:p}))}),t.jsxs("div",{className:"bim-rd-text",id:be,ref:ie,tabIndex:-1,"data-rail":(j||w)&&!G?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[K,R&&me&&(me.sourceName||me.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":me.key,children:[me.sourceName&&t.jsxs(t.Fragment,{children:[A("reader.sourceLabel")," ",me.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:me.sourceUrl,target:"_blank",rel:"noreferrer",children:U(me.sourceName)}):U(me.sourceName)]}),me.sourceName&&me.license&&t.jsx("span",{className:"bim-rd-dot"}),me.license&&t.jsx(t.Fragment,{children:A("reader.licenseOf",{license:me.license})})]}),v&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:A("reader.revisedAt",{date:v})}),w&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:D=>D.preventDefault(),onClick:ke,children:A("reader.reportError")})}),B&&(V||pe)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":A("reader.pagerNav"),children:[V?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>Be(V.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),A("reader.prevUnit",{unit:ee})]}),t.jsx("span",{className:"bim-rd-pglabel",children:V.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",A("reader.firstUnit",{unit:ee})]}),pe?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>Be(pe.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[A("reader.nextUnit",{unit:ee}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:pe.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[A("reader.lastUnit",{unit:ee})," →"]})]})]}),(j||w)&&!G&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":A("reader.rail"),children:[j,w&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:D=>D.preventDefault(),onClick:ke,children:A("reader.reportError")})})]})]})]}),fe&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":A("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":M,"aria-controls":de,onClick:()=>{Y(null),Ne()},children:[t.jsx(ds,{}),t.jsx("span",{children:A("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":ze==="img","aria-haspopup":"dialog",onClick:D=>Se("img",D.currentTarget),children:[t.jsx(ps,{}),t.jsx("span",{children:A("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":ze==="fs","aria-haspopup":"dialog",onClick:D=>Se("fs",D.currentTarget),children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"A"}),t.jsx("span",{children:A("reader.fontSize")})]}),w&&t.jsxs("button",{type:"button",onMouseDown:D=>D.preventDefault(),onClick:()=>{Y(null),ke()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:A("reader.reportError")})]})]}),fe&&ze&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:X}),t.jsxs("div",{className:"bim-rd-sheet",ref:ve,role:"dialog","aria-modal":"true","aria-label":A(ze==="img"?"reader.images":"reader.fontSize"),onKeyDown:D=>{if(D.key==="Escape"){D.stopPropagation(),X();return}D.key==="Tab"&&us(D,ve.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:A(ze==="img"?"reader.images":"reader.fontSize")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.close"),onClick:X,children:"✕"})]}),ze==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(oo,{pages:d??null,loading:c,renderOverlay:p})}):t.jsxs("div",{className:"bim-rd-sheet-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontSmaller"),disabled:Te<=kt[0],onClick:()=>m({fontSize:Gn(h.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Te,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":A("reader.fontLarger"),disabled:Te>=kt[kt.length-1],onClick:()=>m({fontSize:Gn(h.fontSize,1)}),children:"A+"})]})]})]})]})}const gl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],hm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Xe(e){return hm[e]??e}const rn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],sn={熹平: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},fl={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function gi(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 gm(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 fm=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,hs={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function Oo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(hs))if(n.startsWith(s))return hs[s];const o=Xe(n);if(Ot[o]!=null)return o;const r=St(n);if(r&&n.length<=r.length+1)return Xe(r)}function Wt(e,n){if(n){const o=fl[`${n}|${e}`];if(o!=null)return o}return sn[e]}const xm=1911;function bm(e){const n=sn[e];if(n==null)return;const o=bt[e];let r;for(const[s,a]of Object.entries(sn))bt[s]===o&&a>n&&(r==null||a<r)&&(r=a);return r!=null?r-1:void 0}const ym={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function ni(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=ym[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 St(e){for(const n of gl)if(e.startsWith(n))return n}const bt={};{const e=(n,o)=>{for(const r of o)bt[r]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function Ht(e,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(sn))if(e.includes(r)&&!(o&&bt[r]&&bt[r]!==o&&fl[`${o}|${r}`]==null))return r}function In(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=St(r)??"";return{era:Xe(p),reign:Ht(r,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=gi(s);if(p)return{era:gm(p.from),reign:"",source:"publication"};const u=St(s)??Oo(s)??((c=rn.find(f=>f.pattern.test(s)))==null?void 0:c.era)??"",h=Ht(s,u)??"",m=u||(h?bt[h]??"":"");if(m||h)return{era:Xe(m),reign:h,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=St(a);if(p)return{era:Xe(p),reign:Ht(a,p)??"",source:"edition"};const u=rn.find(h=>h.pattern.test(a));if(u)return{era:Xe(u.era),reign:Ht(a,u.era)??u.reign??"",source:"edition"}}return n}function fi(e){var r,s,a,l,d,c,p,u,h;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 m=gi(n);if(m)return m.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 m of o){const f=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(f&&m!==f&&(St(f)||Oo(f)))break;const x=m.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??m.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=m.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const j=St(m);if(!j||Xe(j)==="民國"){const v=ni(k[1]);if(v!=null&&v>=1&&v<=120)return xm+v}}const y=St(m)??((u=rn.find(j=>j.pattern.test(m)))==null?void 0:u.era),_=y?Xe(y):void 0,b=Ht(m,_)??(St(m)||(h=rn.find(j=>j.pattern.test(m)))==null?void 0:h.reign);if(b){const j=Wt(b,_);if(j==null)continue;const w=m.indexOf(b),v=w>=0?m.slice(w+b.length):"",$=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),S=$?ni($[1]):void 0;return j+(S?S-1:0)}}}function Ho(e){var l,d,c,p,u,h;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 m=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const f=ao[Xe(m[1])],x=Ot[Xe(m[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 m=gi(s);if((m==null?void 0:m.to)!=null)return{from:m.from,to:m.to};const f=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(f){const x=ao[Xe(f[1])],k=Ot[Xe(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 m of a){if(!/[間间]/.test(m))continue;const f=St(m)??Oo(m)??((h=rn.find(y=>y.pattern.test(m)))==null?void 0:h.era),x=f?Xe(f):void 0,k=[];for(const y of Object.keys(sn))m.includes(y)&&(x&&bt[y]&&bt[y]!==x||Wt(y,x)!=null&&k.push(y));if(k.length===0){const y=m.match(/([一-鿿])([一-鿿])[間间]/);if(y&&x){for(const _ of[y[1],y[2]])for(const b of Object.keys(sn))if(bt[b]===x&&!(b[0]!==_&&b[b.length-1]!==_)&&Wt(b,x)!=null){k.push(b);break}}}if(k.length>0){const y=k.map(w=>Wt(w,x)).filter(w=>w!=null),_=Math.min(...y),b=k.reduce((w,v)=>Wt(w,x)>=Wt(v,x)?w:v),j=bm(b)??Di(x??"")??Math.max(...y);return{from:_,to:j>_?j:Di(x??bt[b]??"")??_}}if(x&&Ot[x]!=null)return{from:Ot[x],to:Di(x)??Ot[x]}}}const Ot={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},jm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],vm=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,gs=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function fs(e,n){for(const o of gl){const r=e.indexOf(o);if(r<0)continue;if(o.length===1){const c=e[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!Ht(e.slice(r),Xe(o)))continue}const s=Xe(o);if(s===n)continue;const a=e.slice(r),l=Ht(a,s)??"";let d;if(l){const c=Wt(l,s);if(c!=null){const u=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),h=u?ni(u[1]):void 0;d=c+(h?h-1:0)}}return{era:s,reign:l,year:d}}for(const o of rn)if(o.pattern.test(e))return{era:Xe(o.era),reign:o.reign??""}}function km(e){var _,b,j,w,v;const n=In(e),o=((_=e.publication_info)==null?void 0:_.year)??"",r=o?gi(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"&&fm.test(o),p=n.source==="publication"&&/[間间]/.test(o),u=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let h;a||d||c||p?h=void 0:u?h=parseInt(u[2],10):h=fi(e);const m=h==null?Ho(e):void 0;let f;n.source==="publication"&&(c||gs.test(o))?f="uncertain":n.source==="lineage"||n.source==="publication"?f="attested":gs.test(s)||!n.reign&&h==null?f="uncertain":f="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((j=e.lineage)==null?void 0:j.year_text)??((w=e.lineage)==null?void 0:w.year)??""}」`:`出版著錄「${((v=e.publication_info)==null?void 0:v.year)??""}」`,k={era:n.era,reign:n.reign,year:h,yearRange:m,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&&vm.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(k.laterRepair={era:$[1]})}const y=jm.find($=>$.re.test(s));if(y){const $=s.search(y.re),S=s.slice($),C=fs(S,n.era)??fs(s,n.era);C&&(k.basedOn={era:C.era,reign:C.reign,year:C.year,relation:y.relation})}return k}const ao={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Di(e){return ao[e]}function ii(e){const n=fi(e);if(n!=null)return n;const o=Ho(e);if(o)return o.from;const r=In(e).era;return r?Ot[r]:void 0}const xs=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function lo(e){const n=xs.indexOf(e);return n===-1?xs.length:n}function wm(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 Fo(e,n){const o=zo(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,h)=>{const m=f=>f.group_role==="origin"?0:f.group_role==="mirror"?1:2;return m(u)-m(h)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const u=Vt(p),h=u.includes("text"),m=u.includes("image");h&&m?a.textImage.push(p):h?a.text.push(p):m?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 h,m;return{key:p,label:((h=n==null?void 0:n[p])==null?void 0:h.label)||p,description:(m=n==null?void 0:n[p])==null?void 0:m.description,items:u}});return{buckets:d,mirrors:c,total:o.length}}function xi(e,n=cn("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=ci(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 xl(e,n){if(xi(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 bl(e,n){var a,l;const o=e.resources||[],r=[],s=[];for(const d of o){const c=Vt(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:In(e),year:fi(e),sortYear:ii(e),images:r,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,important:Sm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:r.length>0}}function Sm(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 yl(e,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!r.has(c.id)).map(c=>bl(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,h=p.r.sortYear;return u!=null&&h!=null?u-h||c.i-p.i:u!=null?-1:h!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const u=h=>(h.important?0:1)*2+(h.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)=>lo(c)-lo(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function _m(e,n){var y,_;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=[],h=new Map,m=[];for(const b of e)if(!((_=n.excluded_books)!=null&&_.includes(b)))if(p(b))u.push(b);else{const j=n.node_groups[b];j?(h.has(j)||h.set(j,[]),h.get(j).push(b)):m.push(b)}if(m.length+[...h.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=[...h.entries()].map(([b,j])=>{const w=x.get(b);return{id:b,label:(w==null?void 0:w.label)??b,description:w==null?void 0:w.description,ids:j}});return m.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:m}),{useGrouping:!0,coreIds:u,groupedIds:k}}const jl=["撰","編","注","校","譯","繪","其他"],$m=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Do(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of $m)if(r.test(n))return o;return"其他"}function Uo(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function vl(e,n="全部"){const o=new Map;for(const s of e){const a=Do(s);o.set(a,(o.get(a)??0)+1)}const r=[{cls:"全部",label:n,count:e.length}];for(const s of jl){const a=o.get(s);a&&r.push({cls:s,label:s,count:a})}return r.length>2?r:[]}function kl(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:zn(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 zn(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 bi(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 Cm=["〇","一","二","三","四","五","六","七","八","九"],bs=["","十","百","千"];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+=bs[d]:r+=Cm[l]+bs[d])}return r}function zm(e){return e==null?"":typeof e=="string"?e:e.title??""}function $t(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 Sl(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 Tm=216,ys="clamp(280px, 23vw, 360px)",Nm=1440,co="(max-width: 719px)",Em=`${co}, (pointer: coarse)`,Im=`
|
|
639
|
+
.bim-d-main.bim-d-main-grid { max-width: ${Nm}px; padding: 16px 32px 0; }
|
|
640
640
|
.bim-d-grid {
|
|
641
641
|
display: grid;
|
|
642
|
-
grid-template-columns: ${
|
|
642
|
+
grid-template-columns: ${Tm}px minmax(0, 1fr) ${ys};
|
|
643
643
|
grid-template-rows: auto 1fr;
|
|
644
644
|
grid-template-areas: "rail main card" "rail main side";
|
|
645
645
|
column-gap: 32px; row-gap: 28px; align-items: start;
|
|
@@ -869,6 +869,8 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
869
869
|
.bim-d-stats span { display: block; margin-top: 4px; font-size: 12px; color: ${i("aux-fg")}; }
|
|
870
870
|
.bim-d-side-sub { margin: -2px 0 6px; font-size: 12px; color: ${i("aux-fg")}; }
|
|
871
871
|
.bim-d-side li .bim-d-kind { padding: 0 6px; border-radius: 3px; background: ${i("zebra-bg")}; line-height: 18px; }
|
|
872
|
+
/* 类别标签可能很长(如馆藏资源组「國圖藏本:……刻本 ……重修」):允许收缩、折行,窄屏不撑出横向滚动(覆盖下面 .bim-d-meta 的 flex: none) */
|
|
873
|
+
.bim-d-side li .bim-d-meta.bim-d-kind { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
|
|
872
874
|
|
|
873
875
|
/* 提要卡:版本类型/年代/卷帙 三个标签 */
|
|
874
876
|
.bim-d-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
|
|
@@ -973,7 +975,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
973
975
|
.bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
|
|
974
976
|
|
|
975
977
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
976
|
-
@media ${
|
|
978
|
+
@media ${Em} {
|
|
977
979
|
.bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
|
|
978
980
|
.bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
|
|
979
981
|
.bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
|
|
@@ -1011,7 +1013,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1011
1013
|
/* 中等宽度:左栏折到顶部一行 */
|
|
1012
1014
|
@media (max-width: 1100px) {
|
|
1013
1015
|
.bim-d-grid {
|
|
1014
|
-
grid-template-columns: minmax(0, 1fr) ${
|
|
1016
|
+
grid-template-columns: minmax(0, 1fr) ${ys};
|
|
1015
1017
|
grid-template-rows: auto auto 1fr;
|
|
1016
1018
|
grid-template-areas: "rail rail" "main card" "main side";
|
|
1017
1019
|
}
|
|
@@ -1025,7 +1027,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1025
1027
|
}
|
|
1026
1028
|
|
|
1027
1029
|
/* 手机:左栏收起,提要卡 → 正文 → 旁栏 */
|
|
1028
|
-
@media ${
|
|
1030
|
+
@media ${co} {
|
|
1029
1031
|
.bim-d-main.bim-d-main-grid { padding: 8px 16px 0; }
|
|
1030
1032
|
.bim-d-grid {
|
|
1031
1033
|
grid-template-columns: minmax(0, 1fr);
|
|
@@ -1100,7 +1102,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1100
1102
|
:root[data-layout="boxed"] .bim-d-g-rail { border: ${i("fr-bd")}; background: ${i("fr-bg")}; padding: 14px 8px; }
|
|
1101
1103
|
:root[data-layout="boxed"] .bim-d-filters { border-bottom: 1px solid ${i("fr-tab-bd")}; }
|
|
1102
1104
|
:root[data-layout="boxed"] .bim-d-filters .bim-d-tab { margin-bottom: -1px; }
|
|
1103
|
-
@media ${
|
|
1105
|
+
@media ${co} {
|
|
1104
1106
|
:root[data-layout="boxed"] .bim-d-card { padding: 16px; }
|
|
1105
1107
|
:root[data-layout="boxed"] .bim-d-g-rail { border: 0; background: transparent; padding: 0; }
|
|
1106
1108
|
}
|
|
@@ -1115,7 +1117,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1115
1117
|
: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 {
|
|
1116
1118
|
text-decoration-color: currentColor; text-decoration-thickness: 2px;
|
|
1117
1119
|
}
|
|
1118
|
-
`;function
|
|
1120
|
+
`;function Rn({railTop:e,back:n,up:o,nav:r,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=J(),u=(r||[]).filter(Boolean);return t.jsxs("div",{className:"bim-d-grid",children:[t.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[e,n&&t.jsx("div",{style:{marginTop:e?12:0},children:n}),o,u.length>1&&t.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("detail.pageNav"),style:{marginTop:20},children:[t.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("detail.thisPage")}),t.jsx("ul",{className:"bim-d-rail-nav",children:u.map(h=>t.jsx("li",{children:t.jsxs("a",{href:`#${h.id}`,children:[t.jsx("span",{children:p(h.label)}),h.count!=null&&t.jsx("span",{className:"bim-d-meta",children:h.count})]})},h.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(h=>t.jsx("li",{children:t.jsxs("a",{href:h.href??"#",onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),h.onClick())},children:[t.jsx("span",{children:p(h.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},h.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 _l({caption:e,children:n}){const{convert:o}=J();return t.jsxs("div",{className:"bim-d-up bim-d-ui",children:[t.jsx("span",{className:"bim-d-up-cap",children:o(e)}),n]})}function Qe({id:e,title:n,meta:o,action:r,children:s}){const{convert:a}=J();return t.jsxs("section",{id:e,className:"bim-d-sec",children:[t.jsxs("div",{className:"bim-d-sec-head bim-d-ui",children:[t.jsx("h2",{children:a(n)}),o!=null&&o!==""&&t.jsx("span",{className:"bim-d-meta",children:o}),r&&t.jsx("span",{className:"bim-d-sec-act",children:r})]}),t.jsx("div",{className:"bim-d-sec-body",children:s})]})}function Ze({items:e,className:n,style:o}){const r=e.filter(s=>s!=null&&s!==""&&s!==!1);return r.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:o,children:r.map((s,a)=>t.jsxs(g.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function yi({items:e,value:n,onChange:o}){const{convert:r}=J();return t.jsx(t.Fragment,{children:e.map(s=>t.jsx("button",{type:"button",className:[...r(s.label)].length===1?"bim-d-tab bim-d-tab-1":"bim-d-tab","aria-pressed":s.key===n,onClick:()=>o(s.key),children:r(s.label)},s.key))})}function $l({label:e,checked:n,onChange:o}){const{convert:r}=J();return t.jsxs("label",{className:"bim-d-check",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:s=>o(s.target.checked)}),r(e)]})}const Cl=6,ji=e=>e>Cl+1;function Vo({total:e,shown:n,unit:o,onClick:r}){const{t:s,convert:a}=J(),l=e-n,d=ji(e)?e-Math.min(n,Cl):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 Go({label:e,onClick:n}){const{convert:o}=J();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(e)})}function Ln({kind:e,title:n,subtitle:o,byline:r,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:u,children:h,foot:m}){const{t:f,convert:x}=J(),k=(d||[]).filter(w=>w.value!=null&&w.value!==""),y=(c||[]).filter(w=>w.value!=null&&w.value!==""&&w.value!==0),[_,b]=g.useState(!1),j=!!l&&!_;return t.jsxs("div",{className:"bim-d-card",children:[e&&t.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:x(e)}),t.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),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":_,onClick:()=>b(w=>!w),children:f(_?"action.collapse":"action.expand")}),y.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:y.map((w,v)=>t.jsxs("div",{children:[t.jsx("b",{children:w.value}),t.jsx("span",{children:x(w.label)})]},v))}),k.length>0&&t.jsx("dl",{className:"bim-d-ui",children:k.map((w,v)=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:x(w.label)}),t.jsx("dd",{title:w.title,children:w.value})]},v))}),h,p,u,m&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:m})]})}function Yo(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function po({href:e,onClick:n,label:o}){const{t:r,convert:s}=J(),a=o??r("detail.read");return e?t.jsx("a",{className:"bim-d-btn",href:e,onClick:n?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),n())}:void 0,children:s(a)}):t.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:s(a)})}function Dt({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:h,convert:m}=J(),[f,x]=g.useState(!1);if(!r.length)return null;const k=f?r:r.slice(0,l),y=r.length-k.length;return t.jsxs("div",{id:e,className:u?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[t.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[m(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((_,b)=>t.jsxs("li",{className:b===a?"bim-d-side-cur":void 0,"aria-current":b===a?"page":void 0,children:[_,s!=null&&s[b]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),y>0&&t.jsx(Go,{label:d?d(y):h("detail.showMore",{n:y}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const Rm=new Set(["reviewed","disputed","unreviewed","draft"]);function An({revision:e,revisedAt:n,review:o,todo:r}){const{t:s,convert:a}=J(),l=o&&Rm.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(Ze,{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,h)=>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(" · "),")"]})]},h))})]})]})}const Zn=1e3,js=208,Lm=1440,Am="(max-width: 719px)",zl=`
|
|
1119
1121
|
.bim-d-page {
|
|
1120
1122
|
background: ${i("page-bg")};
|
|
1121
1123
|
color: ${i("ink")};
|
|
@@ -1124,7 +1126,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1124
1126
|
padding-bottom: 64px;
|
|
1125
1127
|
}
|
|
1126
1128
|
.bim-d-main {
|
|
1127
|
-
max-width: ${
|
|
1129
|
+
max-width: ${Zn}px;
|
|
1128
1130
|
margin: 0 auto;
|
|
1129
1131
|
padding: 24px clamp(16px, 4vw, 28px) 0;
|
|
1130
1132
|
}
|
|
@@ -1135,7 +1137,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1135
1137
|
* PAGE_MAX_WIDTH,读者的行宽体验不变。
|
|
1136
1138
|
*/
|
|
1137
1139
|
.bim-d-main.bim-d-main-wide {
|
|
1138
|
-
max-width: ${
|
|
1140
|
+
max-width: ${Lm}px;
|
|
1139
1141
|
}
|
|
1140
1142
|
.bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
|
|
1141
1143
|
|
|
@@ -1167,9 +1169,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1167
1169
|
*/
|
|
1168
1170
|
.bim-d-reader {
|
|
1169
1171
|
display: grid;
|
|
1170
|
-
grid-template-columns: ${
|
|
1172
|
+
grid-template-columns: ${js}px minmax(0, ${Zn}px);
|
|
1171
1173
|
gap: 32px;
|
|
1172
|
-
max-width: ${
|
|
1174
|
+
max-width: ${js+Zn+32}px;
|
|
1173
1175
|
margin: 0 auto;
|
|
1174
1176
|
align-items: start;
|
|
1175
1177
|
}
|
|
@@ -1192,7 +1194,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1192
1194
|
align-items: start; margin-bottom: 48px; }
|
|
1193
1195
|
.bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
|
|
1194
1196
|
|
|
1195
|
-
@media ${
|
|
1197
|
+
@media ${Am} {
|
|
1196
1198
|
.bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
|
|
1197
1199
|
.bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
|
|
1198
1200
|
/* 表格:meta 列折到第二行,表头隐藏 */
|
|
@@ -1210,16 +1212,16 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg"
|
|
|
1210
1212
|
padding-right: 0; padding-bottom: 12px;
|
|
1211
1213
|
}
|
|
1212
1214
|
}
|
|
1213
|
-
${
|
|
1214
|
-
`)||(n.push({start:o,end:
|
|
1215
|
-
`).map(n=>n.trim()).filter(n=>n&&!
|
|
1216
|
-
`)){const s=r.trim();if(!s||
|
|
1217
|
-
`),o=[];let r=null,s=[];const
|
|
1218
|
-
`)}),s=[]};for(const
|
|
1219
|
-
`)){const r=
|
|
1220
|
-
`)?"":n)}function
|
|
1221
|
-
`);let c=0;return e.jsx(e.Fragment,{children:p.map((d,u)=>{const m=d.match(Pi);if(m){const f=c++;if(l(m[1].length,m[2],f))return null;const{Tag:x,className:j}=a(m[1].length);return e.jsx(x,{className:j,children:o(m[2])},u)}if(!d.trim())return u>=2&&!!p[u-1].trim()&&!!p[u-2].trim()&&!Pi.test(p[u-1])&&!Pi.test(p[u-2])?e.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(Km.test(d))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(d.trim())){const{Tag:f,className:x}=a(3);return e.jsx(f,{className:x,children:o(d.trim().slice(2,-2))},u)}return e.jsx("p",{className:ds(d),children:cs(d,o,u)},u)})})}function Jm(t){const{convert:n}=Re();return g.useMemo(()=>t?n(t):"",[t,n])}function Vo({text:t,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:l,dropTitle:a}){const p=Jm(t),{t:c,convert:d}=Z(),u=f=>Uo(f,{renderText:l,properNames:s,gujiMarkdown:r,t:c}),m=r?{gujiMarkdown:!0,t:c}:void 0,h=a?d(a):void 0;return!o||p.indexOf(":::")<0?e.jsx(ps,{text:p,mode:n,inline:u,dropTitle:h}):e.jsx(e.Fragment,{children:zo(p).map((f,x)=>f.type==="table"?e.jsx(Ho,{table:f.table,opts:m},x):e.jsx(ps,{text:f.text,mode:n,inline:u,dropTitle:x===0?h:void 0},x))})}function Qm(t,n,o){const[r,s]=g.useState(null),[l,a]=g.useState(!1),p=g.useRef(0);return g.useEffect(()=>{const c=++p.current;if(!t||!n){s(null),a(!1);return}let d;try{d=t(n,o)}catch{s(null),a(!1);return}if(!d||typeof d.then!="function"){s(d??null),a(!1);return}a(!0),d.then(u=>{c===p.current&&s(u??null)}).catch(()=>{c===p.current&&s(null)}).finally(()=>{c===p.current&&a(!1)})},[t,n,o]),{images:r,loading:l}}const us={A:"fine",B:"rough",C:"rough",D:"ocr"};function eh(t){return typeof t!="string"?null:t in Ad?t:t in us?us[t]:null}const th={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},nh={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},Ia="\0";function ih(t,n,o){const[r,s=""]=t.split(Ia);return e.jsxs(e.Fragment,{children:[r,e.jsx(Fl,{text:n,convert:o}),s]})}function mt(t){return typeof t!="string"?"":th[t]??nh[t]??t}const oh=["〇","一","二","三","四","五","六","七","八","九"],ms=["","十","百","千"],rh=["","萬","億"];function Go(t){if(t===0)return"〇";if(t<0)return`負${Go(-t)}`;const n=[];let o=t,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(sh(s,r>0)+rh[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function sh(t,n){const o=[];let r=t;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let l=0;l<o.length;l++){const a=o[l],p=o.length-1-l;a===0?s&&!s.endsWith("〇")&&(s+="〇"):a===1&&p===1&&l===0&&!n?s+=ms[p]:s+=oh[a]+ms[p]}return s.replace(/〇$/,"")}let $n=null,Fn=null;const Jn=new Set;function lh(){return $n?Promise.resolve():Fn||(Fn=import("opencc-js/t2cn").then(t=>{const n=t.Converter({from:"t",to:"cn"});$n=o=>n(we.normalizeVariants(o)),Jn.forEach(o=>o())}).catch(()=>{$n=t=>t,Jn.forEach(t=>t())}),Fn)}const ah=t=>t;function Vt(){const[,t]=g.useState(0);return g.useEffect(()=>{if($n)return;const n=()=>t(o=>o+1);return Jn.add(n),lh(),()=>{Jn.delete(n)}},[]),$n??ah}function on(t,n){return n(t).toLowerCase()}const ch=i("highlight-bg");function Rn(t,n,o){if(!n)return t;const r=on(n,o);if(!r)return t;const s=on(t,o);if(s.length!==t.length)return t;const l=[];let a=0,p=0;for(;a<t.length;){const c=s.indexOf(r,a);if(c===-1){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{style:{background:ch,padding:0,color:"inherit"},children:t.slice(c,c+r.length)},p++)),a=c+r.length}return e.jsx(e.Fragment,{children:l})}function Yo(t,n,o,r){if(!n)return!0;const s=on(n,r);return(o?[t.title,t.header_line,t.content,t.comment]:[t.title,t.book_title,t.author,t.author_info,t.summary,t.content,t.comment,t.additional_comment]).some(a=>typeof a=="string"&&on(a,r).includes(s))}function dh(t,n,o){return n?on(t,o).includes(on(n,o)):!0}const Ko={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},ph={考证:i("section-kaozhen")};function qo(t,n,o){return t.collated.sectionType[n]??o(n)}function Ra(t){var r;const n=t.files.length,o=((r=t.children)==null?void 0:r.reduce((s,l)=>s+Ra(l),0))||0;return n+o}function uh(t,n){const o=[],r=a=>{var p;o.push(...a.files),(p=a.children)==null||p.forEach(r)};if(r(t),o.length===0)return;const s=o.map(a=>n[a]);if(s.every(a=>a===void 0))return;if(s.some(a=>a==="loading"))return"loading";let l=0;for(const a of s)typeof a=="number"&&(l+=a);return l}const mh={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function Xo({enabled:t,expanded:n,onClick:o,style:r,children:s}){return t?e.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...mh,...r},children:s}):e.jsx("span",{style:r,children:s})}function hh({type:t}){const{convert:n,messages:o}=Z(),r=mt(t),s=Ko[r]||i("desc-fg");return e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:s,border:`1px solid ${s}40`,borderRadius:"2px",background:`${s}08`,flexShrink:0},children:qo(o,r,n)})}function gh({section:t,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:l}){const{t:a,convert:p}=Z(),c=Ke(),d=Vt(),u=v=>v?pt(p(v),S=>o?Rn(S,o,d):S,{t:a}):"",[m,h]=g.useState(!1),f=!!t.summary,x=!!t.comment,j=!!t.additional_comment,y=!!(t.content&&t.content.length>60),_=f||x||j||y;g.useEffect(()=>{o&&h(!0)},[o]);const b=!m&&y?ba(t.content.replace(/\n/g," "),80)+"…":null;return e.jsxs("div",{className:"bim-rd-row",id:l,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[e.jsxs("div",{onClick:()=>_&&h(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:_?"pointer":"default",userSelect:"none"},children:[r!=null&&e.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),e.jsxs(Xo,{enabled:_,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[_&&e.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:"▶"}),e.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:[t.book_title?e.jsxs(e.Fragment,{children:["《",u(t.book_title),"》"]}):u(t.title),t.n_juan!=null&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:a("collated.nJuan",{n:p(Go(t.n_juan))})}),(t.author_info||t.author)&&e.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:u(t.author_info||t.author)})]}),!m&&b&&e.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:u(b)})]})]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u(t.edition)}),t.tag&&e.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:t.tag==="triangle"?"△":t.tag}),t.work_id&&n&&e.jsx("a",{href:c(t.work_id),onClick:v=>{v.metaKey||v.ctrlKey||(v.preventDefault(),v.stopPropagation(),n(t.work_id))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),"aria-label":a("collated.viewWorkOf",{title:p(t.book_title||t.title)}),children:a("collated.workArrow")}),s&&!t.work_id&&e.jsx("span",{style:{fontSize:"11px",color:i("label-fg"),flexShrink:0},children:a("collated.unlinked")})]}),m&&_&&e.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[t.author_info&&e.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:u(t.author_info)}),t.summary&&e.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.summary")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:u(t.summary)})]}),t.comment&&e.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.comment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.comment)})]}),t.additional_comment&&e.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a("collated.additionalComment")}),e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:u(t.additional_comment)})]}),y&&!f&&!x&&!j&&e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)})]})]})}function fh({section:t,highlightQuery:n=""}){const{t:o,convert:r}=Z(),s=Vt(),l=d=>d?pt(r(d),u=>n?Rn(u,n,s):u,{t:o}):"",[a,p]=g.useState(!1),c=!!t.content;return e.jsxs("div",{style:{padding:"12px 0 6px"},children:[e.jsxs(Xo,{enabled:c,expanded:a,onClick:()=>p(!a),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[e.jsx(hh,{type:t.type}),e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:l(t.title)}),c&&e.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:a?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),a&&c&&e.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${Ko[mt(t.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:l(t.content)})})]})}const xh=100;function Zo(t){return mt(t.type)!=="page_header"?!1:(t.content||"").length>=xh}function bh({section:t,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=Z(),l=Vt();if(mt(t.type)==="page_header"&&!Zo(t)||!t.content&&!t.title)return null;const a=r((t.content||t.title||"").replace(/\n{2,}/g,`
|
|
1222
|
-
`)),p=pt(a,m=>n?Rn(m,n,l):m,{t:o}),c=mt(t.type),d=Ko[c]||i("desc-fg"),u=c==="序"||c==="结语"||c==="注释";return e.jsxs("div",{style:{padding:u?"10px 12px":"6px 0",margin:u?"8px 0":void 0,fontSize:"13px",color:i("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:u?`3px solid ${d}40`:void 0,background:u?i("bg"):void 0,borderRadius:u?"0 4px 4px 0":void 0,position:"relative"},children:[u&&e.jsx("span",{style:{display:"inline-block",fontSize:"10px",fontWeight:500,color:d,marginRight:"8px",padding:"1px 5px",border:`1px solid ${d}40`,borderRadius:"2px",background:`${d}08`,verticalAlign:"middle"},children:qo(s,c,r)}),p]})}function yh(t,n,o){const[r,s]=g.useState({});return g.useEffect(()=>{var d;if(!n||t.length===0)return;let l=!1;const a=t.filter(u=>{var m;return!((m=o==null?void 0:o.current)!=null&&m.has(u))}),p={};for(const u of t)(d=o==null?void 0:o.current)!=null&&d.has(u)&&(p[u]=o.current.get(u));if(Object.keys(p).length>0&&s(p),a.length===0)return;const c=async u=>{var m;try{if(n.getEntry){const y=await n.getEntry(u);if(y)return{title:y.title,author:y.author}}const h=await n.getItem(u);if(!h)return null;const f=h.title||u,x=h.authors,j=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:f,author:j}}catch{return null}};return Promise.all(a.map(async u=>{var h;const m=await c(u);return(h=o==null?void 0:o.current)==null||h.set(u,m),[u,m]})).then(u=>{l||s(m=>{const h={...m};for(const[f,x]of u)h[f]=x;return h})}),()=>{l=!0}},[t.join(","),n]),r}function jh({section:t,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:l,convert:a,messages:p}=Z(),c=Ke(),d=Vt(),u=S=>S?pt(a(S),k=>s?Rn(k,s,d):k,{t:l}):"",[m,h]=g.useState(!1);g.useEffect(()=>{s&&h(!0)},[s]);const f=mt(t.type),x=ph[f]||i("desc-fg"),j=!!t.content,y=t.work_ids||[],_=y.length>1,b=yh(_?y:[],o,r),v=j&&!m&&t.content.length>80?ba(t.content,80)+"……":null;return e.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[e.jsxs("div",{onClick:()=>j&&h(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:j?"pointer":"default",userSelect:"none"},children:[e.jsxs(Xo,{enabled:j,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[j&&e.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:"▶"}),e.jsxs("span",{style:{display:"block",flex:1},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg"),lineHeight:1.6},children:t.header_line?u(t.header_line):u(t.title)}),!m&&v&&e.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:u(v)})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[y.length===1&&n&&e.jsx("a",{href:c(y[0]),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:l("collated.viewWork"),children:l("collated.arrowWork")}),_&&e.jsx("span",{style:{fontSize:"11px",color:i("link-fg"),flexShrink:0},children:l("collated.nWorks",{n:y.length})}),e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:x,border:`1px solid ${x}40`,borderRadius:"2px",background:`${x}08`},children:qo(p,f,a)})]})]}),_&&n&&e.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(S=>{const k=b[S],$=k?`${a(k.title)}${k.author?`(${a(k.author)})`:""}`:S.slice(0,8)+"…";return e.jsxs("a",{href:c(S),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(S))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:S,children:["→",$]},S)})}),m&&j&&e.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[e.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:u(t.content)}),t.comment&&e.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${i("widget-border")}`,fontSize:"12px",color:i("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:u(t.comment)})]})]})}function vh({juan:t,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const{t:l}=Z(),a=Vt(),p=n.trim(),c=g.useMemo(()=>p?t.sections.filter(d=>Yo(d,p,!0,a)):t.sections,[t.sections,p,a]);return e.jsxs("div",{children:[e.jsx("div",{children:c.map((d,u)=>e.jsx(jh,{section:d,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:p},u))}),c.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:l("collated.noMatch")})]})}function kh(){let t=!1;return n=>n==="类"?(t=!0,"h2"):t?"h3":"h2"}function wh({sections:t,onNavigate:n,inline:o,workLinks:r=!0}){const s=Ke(),{t:l,convert:a}=Z(),p=kh();return e.jsx(e.Fragment,{children:t.map((c,d)=>{const u=mt(c.type);if(u==="page_header"&&!Zo(c))return null;if(u==="类")return e.jsxs(g.Fragment,{children:[g.createElement(p("类"),null,o(a(c.title))),c.content&&e.jsx("p",{children:o(a(c.content))})]},d);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?l("collated.nJuan",{n:Go(c.n_juan)}):""}`:c.title,h=o(a(m));return e.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${d}`,children:[g.createElement(p("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:l("collated.viewWork"),children:h}),e.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":l("collated.viewWorkOf",{title:a(m)}),children:l("collated.workArrow")})]}):h),c.author_info&&e.jsx("p",{className:"bim-rd-sub",children:o(a(c.author_info))}),c.content&&c.content.split(/\n+/).map((f,x)=>e.jsx("p",{children:o(a(f))},x)),c.summary&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.summary")}),o(a(c.summary))]}),c.comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.comment")}),o(a(c.comment))]}),c.additional_comment&&e.jsxs("p",{children:[e.jsx("span",{className:"bim-rd-lbl",children:l("collated.additionalComment")}),o(a(c.additional_comment))]})]},d)}return c.content?e.jsx("p",{children:o(a(c.content))},d):null})})}function La(t){return t.some(n=>{const o=mt(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&Zo(n)})}function Sh({juan:t,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:l,onNavigate:a,transport:p,workLabelCache:c,prefs:d,view:u,onViewChange:m}){var Q;const{t:h,convert:f,messages:x}=Z(),j=Vt(),[y,_]=g.useState("text"),b=u??y,v=P=>{_(P),m==null||m(P)},S=l.trim(),k=(s==null?void 0:s.type)==="kaozhen",$=g.useCallback(P=>S?Rn(P,S,j):P,[S,j]),w=P=>Uo(P,{renderText:$,properNames:d.properNames,t:h}),z=g.useMemo(()=>S?t.sections.filter(P=>Yo(P,S,k,j)):t.sections,[t.sections,S,k,j]),B=(P,D)=>D.filter(pe=>mt(pe.type)===P).length,I=B("书",t.sections),N=B("诗",t.sections),O=B("考证",t.sections);let C="";k?C=S?h("collated.countTiaoOf",{m:B("考证",z),n:O}):h("collated.countTiao",{n:O}):N>0?C=S?h("collated.countPoemsOf",{m:B("诗",z),n:N}):h("collated.countPoems",{n:N}):I>0&&(C=S?h("collated.countBooksOf",{m:B("书",z),n:I}):h("collated.countBooks",{n:I}));const T=s!=null&&s.text_quality?eh(s.text_quality.grade):null,R=[];C&&R.push(C),k&&(s!=null&&s.target_source)&&R.push(e.jsx(e.Fragment,{children:h("collated.kaozhenTarget",{target:f(s.target_source)})})),T&&R.push(e.jsx("span",{title:x.collated.qualityCriteria[T],children:(Q=s==null?void 0:s.text_quality)!=null&&Q.source_note?e.jsxs(e.Fragment,{children:[ih(h("collated.baseText",{note:Ia}),s.text_quality.source_note,f),e.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[T]})]}):e.jsxs(e.Fragment,{children:[h("collated.textQuality"),e.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[T]})]})})),t.source_url&&R.push(e.jsx("a",{className:"bim-rd-link",href:t.source_url,target:"_blank",rel:"noopener noreferrer",children:h("collated.originalSource")}));const A=!k&&La(t.sections),H=!!n&&(!A||d.readingMode==="paragraph"&&Zn(n)),q=!k&&(A||!!n),ne=k||!q?"entries":b;let L=0;return e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[(o||r)&&e.jsxs("p",{className:"bim-rd-kicker",children:[o,o&&r&&e.jsx("span",{className:"bim-rd-dot"}),r&&f(r)]}),e.jsx("h1",{className:"bim-rd-h1",children:f(t.title)}),R.length>0&&e.jsx("p",{className:"bim-rd-meta",children:R.map((P,D)=>e.jsxs(g.Fragment,{children:[D>0&&e.jsx("span",{className:"bim-rd-dot"}),P]},D))}),q&&t.sections.length>0&&e.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":h("collated.viewsGroup"),children:[e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":ne==="text",onClick:()=>v("text"),children:h("collated.viewText")}),e.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":ne==="entries",onClick:()=>v("entries"),children:h("collated.viewEntries")})]})]}),ne==="text"&&e.jsx("article",{className:"bim-rd-prose",children:H?e.jsx(Vo,{text:n,mode:d.readingMode,properNames:d.properNames,renderText:$,dropTitle:t.title}):e.jsx(wh,{sections:t.sections,onNavigate:a,inline:w,workLinks:d.workLinks})}),ne==="entries"&&e.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:k?e.jsx(vh,{juan:t,searchQuery:l,onNavigate:a,transport:p,workLabelCache:c}):e.jsxs(e.Fragment,{children:[z.some(P=>["书","诗","考证"].includes(mt(P.type)))&&e.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[e.jsx("span",{style:{width:28},children:h("collated.rowHeadNo")}),e.jsx("span",{style:{flex:1},children:h("collated.rowHeadTitle")}),e.jsx("span",{children:h("collated.rowHeadWork")})]}),z.map((P,D)=>{const pe=mt(P.type);return pe==="书"||pe==="诗"||pe==="考证"?(L+=1,e.jsx(gh,{domId:`rd-e-${t.sections.indexOf(P)}`,section:P,onNavigate:d.workLinks?a:void 0,highlightQuery:S,no:L,showUnlinked:d.workLinks&&!!a},D)):pe==="类"?e.jsx(fh,{section:P,highlightQuery:S},D):e.jsx(bh,{section:P,highlightQuery:S},D)}),z.length===0&&e.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:h("collated.noMatch")})]})})]})}function _h(t){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:l,activeRawText:a,query:p,isKaozhen:c}=t,d=Vt(),u=g.useRef(new Map),[m,h]=g.useState({}),[f,x]=g.useState({}),j=g.useCallback((_,b)=>{const v=b==null?void 0:b.title;v&&x(S=>S[_]===v?S:{...S,[_]:v})},[]);g.useEffect(()=>{s&&l&&(u.current.set(s,{juan:l,rawText:a}),j(s,l))},[s,l,a,j]),g.useEffect(()=>{u.current.clear(),h({}),x({})},[n]);const y=g.useCallback((_,b)=>{let v=0;if(_.juan)for(const S of _.juan.sections)Yo(S,b,c,d)&&v++;return v===0&&_.rawText&&dh(_.rawText,b,d)&&(v=1),v},[c,d]);return g.useEffect(()=>{const _=p.trim();if(!_){h({});return}if(!o||r.length===0)return;let b=!1;const v={},S=[];for(const B of r){const I=u.current.get(B);I?v[B]=y(I,_):(v[B]="loading",S.push(B))}h(v);const k=8;let $=0;const w=async()=>{for(;$<S.length;){if(b)return;const B=$++,I=S[B];try{const N=await o(I),O=N.juan;if(u.current.set(I,N),j(I,O),b)return;h(C=>({...C,[I]:y(N,_)}))}catch{if(b)return;h(N=>({...N,[I]:0}))}}},z=Array.from({length:Math.min(k,S.length)},()=>w());return Promise.all(z),()=>{b=!0}},[p,n,o,r.join(","),y,d,j]),{matchStates:m,titles:f}}function $h({juan:t,view:n,onView:o,textHasEntries:r}){const{t:s,convert:l}=Z(),a=t.sections.map((u,m)=>({s:u,i:m,t:mt(u.type)})).filter(u=>u.t==="书"||u.t==="诗");if(a.length===0)return null;const p=a.filter(u=>!!u.s.work_id).length,c=a.every(u=>u.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),d=u=>{const m=()=>{var h,f;return(f=(h=document.getElementById(`rd-e-${u}`))==null?void 0:h.scrollIntoView)==null?void 0:f.call(h,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?setTimeout(m,0):m()};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-rd-rail-card",children:[e.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),e.jsxs("div",{className:"bim-rd-rail-n",children:[e.jsx("b",{children:a.length}),e.jsx("span",{children:c}),e.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:p})})]}),e.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:p,total:a.length}),children:e.jsx("span",{style:{width:`${Math.round(p/a.length*100)}%`}})})]}),e.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[e.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),e.jsx("ul",{className:"bim-rd-rail-list",children:a.map(({s:u,i:m})=>e.jsx("li",{children:e.jsxs("a",{href:`#rd-e-${m}`,onClick:h=>{h.preventDefault(),d(m)},children:[e.jsx("span",{className:`bim-rd-rail-dot${u.work_id?" on":""}`,"aria-hidden":"true"}),e.jsx("span",{children:l(u.book_title||u.title)})]})},m))})]})]})}const Ch=`
|
|
1215
|
+
${Im}`;function _n({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:zl}),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 uo({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 Ko({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 mo({items:e}){const n=qe();return t.jsx(t.Fragment,{children:e.map((o,r)=>{const s=r===e.length-1,a=r>0&&t.jsx("span",{style:{color:i("hint-fg")},children:"/"},`s${r}`),l=o.id?n(o.id):o.href,d=s||!o.onClick&&!l?t.jsx("span",{style:{color:i("ink")},children:o.label},r):t.jsx("a",{href:l??"#",onClick:o.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),o.onClick())}:void 0,style:{color:i("meta-fg")},children:o.label},r);return t.jsxs(g.Fragment,{children:[a,d]},r)})})}function Tl({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 Pm({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 Mm({items:e,horizontal:n}){const{convert:o}=Ie();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 Bm({glyph:e,tone:n,title:o,count:r,actions:s,id:a}){const{convert:l}=Ie();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(Ko,{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 Nl({label:e,active:n,onClick:o,dashed:r}){const{convert:s}=Ie();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 Wm({label:e,onClick:n}){const{convert:o}=Ie();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 Om({label:e,onClick:n,inline:o}){const{convert:r}=Ie();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 El({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 Hm({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function Fm({volumes:e,unit:n,max:o=60}){const{t:r}=J(),s=n??r("unit.volume"),[a,l]=g.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,o);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[d.map(c=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${i("rule")}`,color:i("meta-fg")},children:c},c)),!a&&e.length>o&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${i("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:i("meta-fg")},children:["+",e.length-o]}),t.jsx("span",{style:{padding:"2px 6px",color:i("hint-fg")},children:s})]})}function Dm({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:e})}function Um({spec:e}){const{convert:n}=Ie();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 Vm({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 Gm(e){return String(e+1).padStart(2,"0")}function Ym(){return t.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function Km({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 Il(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(`
|
|
1216
|
+
`)||(n.push({start:o,end:a+1,inner:l}),o=a)}return n}function Rl(e,n){if(e.length<=n)return e;let o=n;for(const r of Il(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 Ll={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},qm={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 Al(e,n,o,r){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(g.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:o===0?Ll:void 0,children:Al(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:qm,children:s.label},a)}})}function pt(e,n=r=>r,o){if(!e)return"";if(o!=null&&o.gujiMarkdown)return Yu(e)?Al(Xa(e),n,0,o.t??cn("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 Il(e))l.start>s&&r.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.start))},a++)),r.push(t.jsx("span",{className:"bim-jiazhu",style:Ll,children:n(l.inner)},a++)),s=l.end;return s<e.length&&r.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),r}function Xm({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 Zm({title:e,tag:n,children:o}){const{convert:r}=Ie();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 Pl({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 Jm({item:e,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{t:s,convert:a}=J(),[l,d]=g.useState(!1),c=ci(e),p=o&&!!c&&c.expected>0,u=(e.url?dn(e.url):void 0)||a(e.name),h=n?xl(e,n):"",m=h?`${u}(${h})`:u;return t.jsx(Pl,{name:m,note:xi(e,s)||r,href:pn(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(qo,{item:e})]}):void 0})}function qo({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 Ml({label:e,items:n}){const{convert:o}=Ie();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(El,{children:o(r)},s))]}):null}function Qm({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(Ml,{label:o.label,items:o.items},o.label))}):null}function ho(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Bl({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 eh({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 Ke({id:e,label:n,onNavigate:o,renderLink:r,style:s,dense:a}){const l=qe();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 th({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 nh={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},ih={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},oh=`1px solid ${i("table-border")}`,Wl={border:oh,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},rh={...Wl,background:i("table-head-bg"),fontWeight:600};function Xo({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:nh,children:t.jsx("table",{className:"bim-guji-table",style:ih,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?rh:Wl,children:s.empty?null:pt(s.text,void 0,n)},a)})},r))})})})}function sh(e,n){return e.indexOf("**")<0?pt(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?t.jsx("strong",{children:pt(r.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:pt(r,void 0,n)},s))}function ah(e,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?Mo(e).map((s,a)=>s.type==="table"?t.jsx(Xo,{table:s.table,opts:r},a):t.jsx(g.Fragment,{children:sh(s.text,r)},a)):pt(e,void 0,r)}const lh=/^(#{1,6})\s+(.*)$/,ch=/^\*\*([^*\n]+)\*\*\s*$/;function Zo(e){const n=e.match(lh);if(n)return{level:n[1].length,text:n[2].trim()};const o=e.trim().match(ch);return o?{level:3,text:o[1].trim()}:null}const Jo=/^<!--.*-->$/;function Ol(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Hl(e){return e.split(`
|
|
1217
|
+
`).map(n=>n.trim()).filter(n=>n&&!Jo.test(n))}const dh=60;function Fl(e){let n=0,o=0;for(const r of e.split(`
|
|
1218
|
+
`)){const s=r.trim();if(!s||Jo.test(s)||Zo(s))continue;const a=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=a,a>dh&&(o+=a)}return n>0&&o*2>=n}function ph(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function vi(e){if(e=ph(e),Fl(e))return"unknown";const n=Ol(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const o=n.map(s=>Hl(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 uh(e){const n=e.split(`
|
|
1219
|
+
`),o=[];let r=null,s=[];const a=()=>{o.push({heading:r,body:s.join(`
|
|
1220
|
+
`)}),s=[]};for(const l of n){const d=Zo(l);if(d){a(),r={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),o}function vs(e){const n=[];for(const o of e.split(`
|
|
1221
|
+
`)){const r=Zo(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||Jo.test(s)||n.push({kind:"body",text:o})}return n}function Dl(e){if(!e)return[];const n=vi(e);if(n==="unknown")return vs(e);const o=[];for(const{heading:r,body:s}of uh(e)){r&&o.push(r);const a=Ol(s);if(a.length!==0){if(Fl(s)){o.push(...vs(s));continue}if(n==="record"){const l=a.join(" ");l&&o.push({kind:"body",text:l})}else for(const l of a){const d=Hl(l);d.length&&o.push({kind:"body",text:d.join(" ")})}}}return o}const Ul=e=>e;function Vl(e,n=Ul){if(e.indexOf("《")<0)return n(e);const o=[],r=/《([^《》\n]+)》/g;let s=0,a=0,l;for(;l=r.exec(e);)l.index>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,l.index))},a++)),o.push(t.jsxs("span",{className:"bim-rd-pn",children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(l[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]},a++)),s=l.index+l[0].length;return s===0?n(e):(s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},a++)),o)}function Qo(e,n={}){const o=n.renderText??Ul,r=n.properNames?a=>Vl(a,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return pt(e,r,s)}function ks(e,n,o){return e.indexOf("**")<0?n(e):e.split(/(\*\*[^*]+\*\*)/g).map((s,a)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{children:n(s.slice(2,-2))},`${o}-${a}`):t.jsx(g.Fragment,{children:n(s)},`${o}-${a}`))}const Ui=/^(#{1,6})\s+(.*)$/,mh=/^\s*<!--.*-->\s*$/;function Gl(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
1222
|
+
`)?"":n)}function hh(e){return e<=1?2:e===2?3:4}function gh(){let e=1;return n=>{const o=hh(n),r=Math.min(o,e+1);return e=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function oi(e){return e?vi(Gl(e))!=="unknown":!1}function fh(e){return/^\u3000{2}/.test(e)}const ws=e=>fh(e)?"bim-rd-noindent":void 0;function Ss({text:e,mode:n,inline:o,dropTitle:r}){const s=Gl(e),a=(p,u,h)=>!!r&&h<=1&&p<=2&&u.trim()===r.trim(),l=gh();if(n==="paragraph"&&vi(s)!=="unknown"){const p=Dl(s);return t.jsx(t.Fragment,{children:p.map((u,h)=>{if(u.kind==="heading"){if(a(u.level??1,u.text,h))return null;const{Tag:m,className:f}=l(u.level??1);return t.jsx(m,{className:f,children:o(u.text)},h)}return t.jsx("p",{className:ws(u.text),children:ks(u.text,o,h)},h)})})}const d=s.split(`
|
|
1223
|
+
`);let c=0;return t.jsx(t.Fragment,{children:d.map((p,u)=>{const h=p.match(Ui);if(h){const f=c++;if(a(h[1].length,h[2],f))return null;const{Tag:x,className:k}=l(h[1].length);return t.jsx(x,{className:k,children:o(h[2])},u)}if(!p.trim())return u>=2&&!!d[u-1].trim()&&!!d[u-2].trim()&&!Ui.test(d[u-1])&&!Ui.test(d[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(mh.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:ws(p),children:ks(p,o,u)},u)})})}function xh(e){const{convert:n}=Ie();return g.useMemo(()=>e?n(e):"",[e,n])}function er({text:e,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:a,dropTitle:l}){const d=xh(e),{t:c,convert:p}=J(),u=f=>Qo(f,{renderText:a,properNames:s,gujiMarkdown:r,t:c}),h=r?{gujiMarkdown:!0,t:c}:void 0,m=l?p(l):void 0;return!o||d.indexOf(":::")<0?t.jsx(Ss,{text:d,mode:n,inline:u,dropTitle:m}):t.jsx(t.Fragment,{children:Mo(d).map((f,x)=>f.type==="table"?t.jsx(Xo,{table:f.table,opts:h},x):t.jsx(Ss,{text:f.text,mode:n,inline:u,dropTitle:x===0?m:void 0},x))})}function bh(e,n,o){const[r,s]=g.useState(null),[a,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const c=++d.current;if(!e||!n){s(null),l(!1);return}let p;try{p=e(n,o)}catch{s(null),l(!1);return}if(!p||typeof p.then!="function"){s(p??null),l(!1);return}l(!0),p.then(u=>{c===d.current&&s(u??null)}).catch(()=>{c===d.current&&s(null)}).finally(()=>{c===d.current&&l(!1)})},[e,n,o]),{images:r,loading:a}}const _s={A:"fine",B:"rough",C:"rough",D:"ocr"};function yh(e){return typeof e!="string"?null:e in ep?e:e in _s?_s[e]:null}const jh={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},vh={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"},Yl="\0";function kh(e,n,o){const[r,s=""]=e.split(Yl);return t.jsxs(t.Fragment,{children:[r,t.jsx(il,{text:n,convert:o}),s]})}function mt(e){return typeof e!="string"?"":jh[e]??vh[e]??e}const wh=["〇","一","二","三","四","五","六","七","八","九"],$s=["","十","百","千"],Sh=["","萬","億"];function tr(e){if(e===0)return"〇";if(e<0)return`負${tr(-e)}`;const n=[];let o=e,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(_h(s,r>0)+Sh[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function _h(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+=$s[d]:s+=wh[l]+$s[d]}return s.replace(/〇$/,"")}let Tn=null,Yn=null;const ri=new Set;function $h(){return Tn?Promise.resolve():Yn||(Yn=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Tn=o=>n(we.normalizeVariants(o)),ri.forEach(o=>o())}).catch(()=>{Tn=e=>e,ri.forEach(e=>e())}),Yn)}const Ch=e=>e;function Kt(){const[,e]=g.useState(0);return g.useEffect(()=>{if(Tn)return;const n=()=>e(o=>o+1);return ri.add(n),$h(),()=>{ri.delete(n)}},[]),Tn??Ch}function an(e,n){return n(e).toLowerCase()}const zh=i("highlight-bg");function Pn(e,n,o){if(!n)return e;const r=an(n,o);if(!r)return e;const s=an(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:zh,padding:0,color:"inherit"},children:e.slice(c,c+r.length)},d++)),l=c+r.length}return t.jsx(t.Fragment,{children:a})}function nr(e,n,o,r){if(!n)return!0;const s=an(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"&&an(l,r).includes(s))}function Th(e,n,o){return n?an(e,o).includes(an(n,o)):!0}const ir={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},Nh={考证:i("section-kaozhen")};function or(e,n,o){return e.collated.sectionType[n]??o(n)}function Kl(e){var r;const n=e.files.length,o=((r=e.children)==null?void 0:r.reduce((s,a)=>s+Kl(a),0))||0;return n+o}function Eh(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 Ih={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function rr({enabled:e,expanded:n,onClick:o,style:r,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...Ih,...r},children:s}):t.jsx("span",{style:r,children:s})}function Rh({type:e}){const{convert:n,messages:o}=J(),r=mt(e),s=ir[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:or(o,r,n)})}function Lh({section:e,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=J(),c=qe(),p=Kt(),u=j=>j?pt(d(j),w=>o?Pn(w,o,p):w,{t:l}):"",[h,m]=g.useState(!1),f=!!e.summary,x=!!e.comment,k=!!e.additional_comment,y=!!(e.content&&e.content.length>60),_=f||x||k||y;g.useEffect(()=>{o&&m(!0)},[o]);const b=!h&&y?Rl(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:()=>_&&m(!h),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:_?"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(rr,{enabled:_,expanded:h,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[_&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:h?"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(tr(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)})]}),!h&&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")})]}),h&&_&&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 Ah({section:e,highlightQuery:n=""}){const{t:o,convert:r}=J(),s=Kt(),a=p=>p?pt(r(p),u=>n?Pn(u,n,s):u,{t:o}):"",[l,d]=g.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(rr,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(Rh,{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, ${ir[mt(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 Ph=100;function sr(e){return mt(e.type)!=="page_header"?!1:(e.content||"").length>=Ph}function Mh({section:e,highlightQuery:n=""}){const{t:o,convert:r,messages:s}=J(),a=Kt();if(mt(e.type)==="page_header"&&!sr(e)||!e.content&&!e.title)return null;const l=r((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1224
|
+
`)),d=pt(l,h=>n?Pn(h,n,a):h,{t:o}),c=mt(e.type),p=ir[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:or(s,c,r)}),d]})}function Bh(e,n,o){const[r,s]=g.useState({});return g.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(u=>{var h;return!((h=o==null?void 0:o.current)!=null&&h.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 h;try{if(n.getEntry){const y=await n.getEntry(u);if(y)return{title:y.title,author:y.author}}const m=await n.getItem(u);if(!m)return null;const f=m.title||u,x=m.authors,k=(h=x==null?void 0:x[0])==null?void 0:h.name;return{title:f,author:k}}catch{return null}};return Promise.all(l.map(async u=>{var m;const h=await c(u);return(m=o==null?void 0:o.current)==null||m.set(u,h),[u,h]})).then(u=>{a||s(h=>{const m={...h};for(const[f,x]of u)m[f]=x;return m})}),()=>{a=!0}},[e.join(","),n]),r}function Wh({section:e,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=J(),c=qe(),p=Kt(),u=w=>w?pt(l(w),v=>s?Pn(v,s,p):v,{t:a}):"",[h,m]=g.useState(!1);g.useEffect(()=>{s&&m(!0)},[s]);const f=mt(e.type),x=Nh[f]||i("desc-fg"),k=!!e.content,y=e.work_ids||[],_=y.length>1,b=Bh(_?y:[],o,r),j=k&&!h&&e.content.length>80?Rl(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>k&&m(!h),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:k?"pointer":"default",userSelect:"none"},children:[t.jsxs(rr,{enabled:k,expanded:h,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:h?"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)}),!h&&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:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(y[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),_&&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:or(d,f,l)})]})]}),_&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:y.map(w=>{const v=b[w],$=v?`${l(v.title)}${v.author?`(${l(v.author)})`:""}`:w.slice(0,8)+"…";return t.jsxs("a",{href:c(w),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(w))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:w,children:["→",$]},w)})}),h&&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}=J(),l=Kt(),d=n.trim(),c=g.useMemo(()=>d?e.sections.filter(p=>nr(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(Wh,{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 Hh(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Fh({sections:e,onNavigate:n,inline:o,workLinks:r=!0}){const s=qe(),{t:a,convert:l}=J(),d=Hh();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const u=mt(c.type);if(u==="page_header"&&!sr(c))return null;if(u==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,o(l(c.title))),c.content&&t.jsx("p",{children:o(l(c.content))})]},p);if(u==="书"||u==="诗"||u==="考证"||u==="注释"){const h=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:tr(c.n_juan)}):""}`:c.title,m=o(l(h));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&r?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:m}),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(h)}),children:a("collated.workArrow")})]}):m),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 ql(e){return e.some(n=>{const o=mt(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&sr(n)})}function Dh({juan:e,rawText:n,positionLabel:o,groupLabel:r,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:u,onViewChange:h}){var Z;const{t:m,convert:f,messages:x}=J(),k=Kt(),[y,_]=g.useState("text"),b=u??y,j=A=>{_(A),h==null||h(A)},w=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",$=g.useCallback(A=>w?Pn(A,w,k):A,[w,k]),S=A=>Qo(A,{renderText:$,properNames:p.properNames,t:m}),C=g.useMemo(()=>w?e.sections.filter(A=>nr(A,w,v,k)):e.sections,[e.sections,w,v,k]),B=(A,U)=>U.filter(ce=>mt(ce.type)===A).length,T=B("书",e.sections),z=B("诗",e.sections),F=B("考证",e.sections);let N="";v?N=w?m("collated.countTiaoOf",{m:B("考证",C),n:F}):m("collated.countTiao",{n:F}):z>0?N=w?m("collated.countPoemsOf",{m:B("诗",C),n:z}):m("collated.countPoems",{n:z}):T>0&&(N=w?m("collated.countBooksOf",{m:B("书",C),n:T}):m("collated.countBooks",{n:T}));const R=s!=null&&s.text_quality?yh(s.text_quality.grade):null,O=[];N&&O.push(N),v&&(s!=null&&s.target_source)&&O.push(t.jsx(t.Fragment,{children:m("collated.kaozhenTarget",{target:f(s.target_source)})})),R&&O.push(t.jsx("span",{title:x.collated.qualityCriteria[R],children:(Z=s==null?void 0:s.text_quality)!=null&&Z.source_note?t.jsxs(t.Fragment,{children:[kh(m("collated.baseText",{note:Yl}),s.text_quality.source_note,f),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[R]})]}):t.jsxs(t.Fragment,{children:[m("collated.textQuality"),t.jsx("span",{className:"bim-rd-grade",children:x.collated.qualityLabel[R]})]})})),e.source_url&&O.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:m("collated.originalSource")}));const I=!v&&ql(e.sections),P=!!n&&(!I||p.readingMode==="paragraph"&&oi(n)),G=!v&&(I||!!n),K=v||!G?"entries":b;let L=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)}),O.length>0&&t.jsx("p",{className:"bim-rd-meta",children:O.map((A,U)=>t.jsxs(g.Fragment,{children:[U>0&&t.jsx("span",{className:"bim-rd-dot"}),A]},U))}),G&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":m("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":K==="text",onClick:()=>j("text"),children:m("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":K==="entries",onClick:()=>j("entries"),children:m("collated.viewEntries")})]})]}),K==="text"&&t.jsx("article",{className:"bim-rd-prose",children:P?t.jsx(er,{text:n,mode:p.readingMode,properNames:p.properNames,renderText:$,dropTitle:e.title}):t.jsx(Fh,{sections:e.sections,onNavigate:l,inline:S,workLinks:p.workLinks})}),K==="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:[C.some(A=>["书","诗","考证"].includes(mt(A.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:m("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:m("collated.rowHeadTitle")}),t.jsx("span",{children:m("collated.rowHeadWork")})]}),C.map((A,U)=>{const ce=mt(A.type);return ce==="书"||ce==="诗"||ce==="考证"?(L+=1,t.jsx(Lh,{domId:`rd-e-${e.sections.indexOf(A)}`,section:A,onNavigate:p.workLinks?l:void 0,highlightQuery:w,no:L,showUnlinked:p.workLinks&&!!l},U)):ce==="类"?t.jsx(Ah,{section:A,highlightQuery:w},U):t.jsx(Mh,{section:A,highlightQuery:w},U)}),C.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:m("collated.noMatch")})]})})]})}function Uh(e){const{resetKey:n,load:o,files:r,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=Kt(),u=g.useRef(new Map),[h,m]=g.useState({}),[f,x]=g.useState({}),k=g.useCallback((_,b)=>{const j=b==null?void 0:b.title;j&&x(w=>w[_]===j?w:{...w,[_]:j})},[]);g.useEffect(()=>{s&&a&&(u.current.set(s,{juan:a,rawText:l}),k(s,a))},[s,a,l,k]),g.useEffect(()=>{u.current.clear(),m({}),x({})},[n]);const y=g.useCallback((_,b)=>{let j=0;if(_.juan)for(const w of _.juan.sections)nr(w,b,c,p)&&j++;return j===0&&_.rawText&&Th(_.rawText,b,p)&&(j=1),j},[c,p]);return g.useEffect(()=>{const _=d.trim();if(!_){m({});return}if(!o||r.length===0)return;let b=!1;const j={},w=[];for(const B of r){const T=u.current.get(B);T?j[B]=y(T,_):(j[B]="loading",w.push(B))}m(j);const v=8;let $=0;const S=async()=>{for(;$<w.length;){if(b)return;const B=$++,T=w[B];try{const z=await o(T),F=z.juan;if(u.current.set(T,z),k(T,F),b)return;m(N=>({...N,[T]:y(z,_)}))}catch{if(b)return;m(z=>({...z,[T]:0}))}}},C=Array.from({length:Math.min(v,w.length)},()=>S());return Promise.all(C),()=>{b=!0}},[d,n,o,r.join(","),y,p,k]),{matchStates:h,titles:f}}function Vh({juan:e,view:n,onView:o,textHasEntries:r}){const{t:s,convert:a}=J(),l=e.sections.map((u,h)=>({s:u,i:h,t:mt(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 h=()=>{var m,f;return(f=(m=document.getElementById(`rd-e-${u}`))==null?void 0:m.scrollIntoView)==null?void 0:f.call(m,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?setTimeout(h,0):h()};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:h})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${h}`,onClick:m=>{m.preventDefault(),p(h)},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)})]})},h))})]})]})}const Gh=`
|
|
1223
1225
|
attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
|
|
1224
1226
|
attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
|
|
1225
1227
|
|
|
@@ -1237,7 +1239,7 @@ ${mm}`;function kn({children:t,style:n,wide:o,grid:r}){return e.jsxs("div",{clas
|
|
|
1237
1239
|
// 纹理坐标归一化 [0, 1]
|
|
1238
1240
|
v_texCoord = a_texCoord / u_imgResolution;
|
|
1239
1241
|
}
|
|
1240
|
-
`,
|
|
1242
|
+
`,Yh=`
|
|
1241
1243
|
precision mediump float;
|
|
1242
1244
|
uniform sampler2D u_image;
|
|
1243
1245
|
uniform float u_alpha;
|
|
@@ -1247,8 +1249,8 @@ ${mm}`;function kn({children:t,style:n,wide:o,grid:r}){return e.jsxs("div",{clas
|
|
|
1247
1249
|
vec4 tex = texture2D(u_image, v_texCoord);
|
|
1248
1250
|
gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
|
|
1249
1251
|
}
|
|
1250
|
-
`;function hs(t,n,o){const r=t.createShader(n);return r?(t.shaderSource(r,o),t.compileShader(r),t.getShaderParameter(r,t.COMPILE_STATUS)?r:(console.error("Shader compile error:",t.getShaderInfoLog(r)),t.deleteShader(r),null)):null}class ro{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,Ch),s=hs(o,o.FRAGMENT_SHADER,zh);if(!r||!s)throw new Error("Failed to create shaders");const l=o.createProgram();if(!l)throw new Error("Failed to create program");if(o.attachShader(l,r),o.attachShader(l,s),o.linkProgram(l),!o.getProgramParameter(l,o.LINK_STATUS))throw new Error("Program link error: "+o.getProgramInfoLog(l));this.program=l,this.positionBuffer=o.createBuffer(),this.texCoordBuffer=o.createBuffer(),this.uResolutionLoc=o.getUniformLocation(l,"u_resolution"),this.uImgResolutionLoc=o.getUniformLocation(l,"u_imgResolution"),this.uAlphaLoc=o.getUniformLocation(l,"u_alpha"),this.aPositionLoc=o.getAttribLocation(l,"a_position"),this.aTexCoordLoc=o.getAttribLocation(l,"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,l,a,p=1){if(a.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,l),c.uniform1f(this.uAlphaLoc,p);const d=[],u=[],m=8;for(const h of a){const f=h.colOffsetX||0,x=h.colOffsetY||0,{srcQuad:j,dstRect:y}=h.strip,[_,b,v,S]=y,k=f+_,$=x+b,[w,z,B,I]=j;for(let N=0;N<m;N++){const O=N/m,C=(N+1)/m,T=$+S*O,R=$+S*C,A=[w[0]+(I[0]-w[0])*O,w[1]+(I[1]-w[1])*O],H=[w[0]+(I[0]-w[0])*C,w[1]+(I[1]-w[1])*C],q=[z[0]+(B[0]-z[0])*O,z[1]+(B[1]-z[1])*O],ne=[z[0]+(B[0]-z[0])*C,z[1]+(B[1]-z[1])*C],L=[k,T],Q=[k+v,T],P=[k,R],D=[k+v,R];d.push(L[0],L[1],Q[0],Q[1],P[0],P[1]),u.push(A[0],A[1],q[0],q[1],H[0],H[1]),d.push(Q[0],Q[1],D[0],D[1],P[0],P[1]),u.push(q[0],q[1],ne[0],ne[1],H[0],H[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(d),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,d.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 Ct=new Map,Th=24;function so(t){let n=Ct.get(t);if(n)return Ct.delete(t),Ct.set(t,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=()=>{Ct.delete(t),o(null)},r.src=t}),Ct.set(t,n);Ct.size>Th;)Ct.delete(Ct.keys().next().value);return n}const Jo=({imageUrl:t,pageData:n,selectedCharIds:o,hoveredCharId:r,preserveMargins:s=!1,onCharClick:l,onCharHover:a})=>{const p=g.useRef(null),c=g.useRef(null),d=g.useRef(null),u=g.useRef(null),m=g.useRef(null),h=g.useRef(null),[f,x]=g.useState(0),[j,y]=g.useState(0),_=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(C=>C.warped_h),2440),[n]),v=n.total_warped_w,S=n.banxin,k=g.useMemo(()=>{var ne;if(!s)return{top:0,bottom:0,left:0,right:0};const[C,T]=n.image_size||[2386,3082];let R=1/0,A=-1/0,H=1/0,q=-1/0;for(const L of n.columns)for(const Q of L.strips||[])for(const P of Q.srcQuad)P[0]<R&&(R=P[0]),P[0]>A&&(A=P[0]),P[1]<H&&(H=P[1]),P[1]>q&&(q=P[1]);if((ne=n.banxin)!=null&&ne.current_page_strips)for(const L of n.banxin.current_page_strips)for(const Q of L.srcQuad)Q[0]<R&&(R=Q[0]),Q[0]>A&&(A=Q[0]),Q[1]<H&&(H=Q[1]),Q[1]>q&&(q=Q[1]);return isFinite(R)||(R=0),isFinite(A)||(A=C),isFinite(H)||(H=0),isFinite(q)||(q=T),{top:Math.max(0,Math.round(H)),bottom:Math.max(0,Math.round(T-q)),left:Math.max(0,Math.round(R)),right:Math.max(0,Math.round(C-A)),rawMinX:R,rawMaxX:A,rawMinY:H,rawMaxY:q,imgW:C,imgH:T}},[n,s]),$=v+(S?S.total_w:0),w=$+k.left+k.right,z=b+k.top+k.bottom,B=g.useCallback(()=>{const C=c.current;if(!(!C||!p.current)&&!(t&&_.current!==t)){if(C.clear(w,z),s&&k.rawMinX!==void 0&&m.current&&d.current){const{rawMinX:T,rawMaxX:R,rawMinY:A,rawMaxY:H,imgW:q,imgH:ne,top:L,bottom:Q,left:P,right:D}=k,pe=[];P>0&&pe.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[T,0],[T,ne],[0,ne]],dstRect:[0,0,P,z]}}),L>0&&pe.push({colOffsetX:P,colOffsetY:0,strip:{srcQuad:[[T,0],[R,0],[R,A],[T,A]],dstRect:[0,0,$,L]}}),Q>0&&pe.push({colOffsetX:P,colOffsetY:L+b,strip:{srcQuad:[[T,H],[R,H],[R,ne],[T,ne]],dstRect:[0,0,$,Q]}}),D>0&&pe.push({colOffsetX:P+$,colOffsetY:0,strip:{srcQuad:[[R,0],[q,0],[q,ne],[R,ne]],dstRect:[0,0,D,z]}}),C.renderStripsWithTexture(m.current,w,z,n.image_size[0],n.image_size[1],pe,1)}if(m.current&&d.current){const T=n.columns.flatMap(R=>(R.strips||[]).map(A=>({colOffsetX:k.left+R.offset_x,colOffsetY:k.top,strip:A})));if(T.length>0?C.renderStripsWithTexture(m.current,w,z,n.image_size[0],n.image_size[1],T,1):C.renderStripsWithTexture(m.current,w,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,w,z]}}],1),S&&S.current_page_strips.length>0){const R=S.current_page_strips.map(A=>({colOffsetX:k.left+v,colOffsetY:k.top,strip:A}));C.renderStripsWithTexture(m.current,w,z,n.image_size[0],n.image_size[1],R,1)}}if(S&&h.current&&u.current&&S.mate_page_strips.length>0){const T=S.mate_page_strips.map(R=>({colOffsetX:k.left+v+S.half_w,colOffsetY:k.top,strip:R}));C.renderStripsWithTexture(h.current,w,z,S.mate_img_size[0],S.mate_img_size[1],T,.65)}}},[t,n,S,w,z,v,b,$,k,s]),I=g.useRef(B);I.current=B,g.useEffect(()=>{const C=p.current;if(!C)return;const T=H=>{m.current=d.current?H.createTexture(d.current):null,h.current=u.current?H.createTexture(u.current):null,I.current()};try{const H=new ro(C);c.current=H,T(H)}catch(H){console.error("Failed to init WebGL renderer:",H)}const R=H=>{H.preventDefault(),console.warn("WebGL context lost")},A=()=>{console.info("WebGL context restored, re-initializing..."),p.current&&(c.current=new ro(p.current),T(c.current))};return C.addEventListener("webglcontextlost",R,!1),C.addEventListener("webglcontextrestored",A,!1),()=>{C.removeEventListener("webglcontextlost",R),C.removeEventListener("webglcontextrestored",A),c.current&&(c.current.deleteTexture(m.current),c.current.deleteTexture(h.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!t)return;let C=!0;return so(t).then(T=>{if(!C||!T)return;d.current=T,_.current=t;const R=c.current;R&&(R.deleteTexture(m.current),m.current=R.createTexture(T)),x(A=>A+1)}),()=>{C=!1}},[t]);const N=S==null?void 0:S.mate_image_url;g.useEffect(()=>{if(!N)return;let C=!0;return so(N).then(T=>{if(!C||!T)return;u.current=T;const R=c.current;R&&(R.deleteTexture(h.current),h.current=R.createTexture(T)),y(A=>A+1)}),()=>{C=!1}},[N]),g.useEffect(()=>{B()},[B,f,j]);const O=g.useMemo(()=>{const C=[];for(const T of n.columns)for(const R of T.chars){const[A,H,q,ne]=R.bbox_col;C.push({id:R.id,char:R.char,x:k.left+T.offset_x+A,y:k.top+H,w:Math.max(q-A,1),h:Math.max(ne-H,1)})}return C},[n,k]);return e.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${w} / ${z}`,backgroundColor:i("warp-bg"),boxShadow:i("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[e.jsx("canvas",{ref:p,width:w,height:z,style:{width:"100%",height:"100%",display:"block",backgroundColor:i("warp-bg")}}),e.jsxs("svg",{viewBox:`0 0 ${w} ${z}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[O.map(C=>{const T=o.has(C.id),R=r===C.id;return e.jsx("rect",{"data-selected":T?"true":void 0,x:C.x,y:C.y,width:C.w,height:C.h,fill:T?i("warp-sel-bg"):R?i("warp-hover-bg"):"transparent",stroke:T?i("warp-sel-stroke"):R?i("warp-hover-stroke"):"transparent",strokeWidth:T?3.5:R?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>l==null?void 0:l(C.id),onMouseEnter:()=>a==null?void 0:a(C.id),onMouseLeave:()=>a==null?void 0:a(null),children:e.jsx("title",{children:C.char})},C.id)}),S&&e.jsxs("g",{children:[e.jsx("line",{x1:k.left+v,y1:k.top,x2:k.left+v,y2:k.top+b,stroke:i("warp-banxin-border"),strokeWidth:1.5}),e.jsx("line",{x1:k.left+v+S.half_w,y1:k.top,x2:k.left+v+S.half_w,y2:k.top+b,stroke:i("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),e.jsx("line",{x1:k.left+$,y1:k.top,x2:k.left+$,y2:k.top+b,stroke:i("warp-banxin-outer"),strokeWidth:1})]})]})]})},Nh={work:"work",book:"work",people:"person",person:"person",place:"place",office:"office",dynasty:"dynasty"};function Eh(t){return typeof t=="string"&&Nh[t]||"other"}function lo(t){if(!t)return null;const n=t.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 xn(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0}function zt(t){return typeof t=="string"&&t?t:void 0}function Aa(t){const n=Array.isArray(t)?t:t&&typeof t=="object"&&Array.isArray(t.entities)?t.entities:[],o=[];return n.forEach((r,s)=>{if(!r||typeof r!="object")return;const l=r,a=l.span??{},p=l.target??{},c=xn(a.start_offset)??xn(l.start_offset),d=xn(a.end_offset)??xn(l.end_offset);if(c===void 0||d===void 0||c<0||d<=c)return;const u=zt(p.status),m=u===void 0||u==="matched"?lo(zt(p.entity_id))??lo(zt(p.href))??void 0:void 0,h=l.anchor??{},f=zt(h.start),x=zt(h.end);o.push({...f&&x?{anchor:{start:f,end:x}}:{},key:zt(l.id)??`e${s}`,kind:Eh(l.type),start:c,end:d,text:zt(l.text),targetId:m,canonicalName:zt(p.canonical_name),confidence:xn(l.confidence)})}),o.sort((r,s)=>r.start-s.start||s.end-r.end)}const Ih=new Set(Array.from(`《》/<>\r
|
|
1251
|
-
,。、;:?!「」『』()…—·`));function
|
|
1252
|
+
`;function Cs(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 go{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=Cs(o,o.VERTEX_SHADER,Gh),s=Cs(o,o.FRAGMENT_SHADER,Yh);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=[],h=8;for(const m of l){const f=m.colOffsetX||0,x=m.colOffsetY||0,{srcQuad:k,dstRect:y}=m.strip,[_,b,j,w]=y,v=f+_,$=x+b,[S,C,B,T]=k;for(let z=0;z<h;z++){const F=z/h,N=(z+1)/h,R=$+w*F,O=$+w*N,I=[S[0]+(T[0]-S[0])*F,S[1]+(T[1]-S[1])*F],P=[S[0]+(T[0]-S[0])*N,S[1]+(T[1]-S[1])*N],G=[C[0]+(B[0]-C[0])*F,C[1]+(B[1]-C[1])*F],K=[C[0]+(B[0]-C[0])*N,C[1]+(B[1]-C[1])*N],L=[v,R],Z=[v+j,R],A=[v,O],U=[v+j,O];p.push(L[0],L[1],Z[0],Z[1],A[0],A[1]),u.push(I[0],I[1],G[0],G[1],P[0],P[1]),p.push(Z[0],Z[1],U[0],U[1],A[0],A[1]),u.push(G[0],G[1],K[0],K[1],P[0],P[1])}}c.bindBuffer(c.ARRAY_BUFFER,this.positionBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(p),c.STATIC_DRAW),c.enableVertexAttribArray(this.aPositionLoc),c.vertexAttribPointer(this.aPositionLoc,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this.texCoordBuffer),c.bufferData(c.ARRAY_BUFFER,new Float32Array(u),c.STATIC_DRAW),c.enableVertexAttribArray(this.aTexCoordLoc),c.vertexAttribPointer(this.aTexCoordLoc,2,c.FLOAT,!1,0,0),c.bindTexture(c.TEXTURE_2D,n),c.drawArrays(c.TRIANGLES,0,p.length/2)}deleteTexture(n){n&&this.gl.deleteTexture(n)}destroy(){const n=this.gl;n.deleteProgram(this.program),n.deleteBuffer(this.positionBuffer),n.deleteBuffer(this.texCoordBuffer)}}const Nt=new Map,Kh=24;function fo(e){let n=Nt.get(e);if(n)return Nt.delete(e),Nt.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=()=>{Nt.delete(e),o(null)},r.src=e}),Nt.set(e,n);Nt.size>Kh;)Nt.delete(Nt.keys().next().value);return n}const ar=({imageUrl:e,pageData:n,selectedCharIds:o,hoveredCharId:r,preserveMargins:s=!1,onCharClick:a,onCharHover:l})=>{const d=g.useRef(null),c=g.useRef(null),p=g.useRef(null),u=g.useRef(null),h=g.useRef(null),m=g.useRef(null),[f,x]=g.useState(0),[k,y]=g.useState(0),_=g.useRef(""),b=g.useMemo(()=>Math.max(...n.columns.map(N=>N.warped_h),2440),[n]),j=n.total_warped_w,w=n.banxin,v=g.useMemo(()=>{var K;if(!s)return{top:0,bottom:0,left:0,right:0};const[N,R]=n.image_size||[2386,3082];let O=1/0,I=-1/0,P=1/0,G=-1/0;for(const L of n.columns)for(const Z of L.strips||[])for(const A of Z.srcQuad)A[0]<O&&(O=A[0]),A[0]>I&&(I=A[0]),A[1]<P&&(P=A[1]),A[1]>G&&(G=A[1]);if((K=n.banxin)!=null&&K.current_page_strips)for(const L of n.banxin.current_page_strips)for(const Z of L.srcQuad)Z[0]<O&&(O=Z[0]),Z[0]>I&&(I=Z[0]),Z[1]<P&&(P=Z[1]),Z[1]>G&&(G=Z[1]);return isFinite(O)||(O=0),isFinite(I)||(I=N),isFinite(P)||(P=0),isFinite(G)||(G=R),{top:Math.max(0,Math.round(P)),bottom:Math.max(0,Math.round(R-G)),left:Math.max(0,Math.round(O)),right:Math.max(0,Math.round(N-I)),rawMinX:O,rawMaxX:I,rawMinY:P,rawMaxY:G,imgW:N,imgH:R}},[n,s]),$=j+(w?w.total_w:0),S=$+v.left+v.right,C=b+v.top+v.bottom,B=g.useCallback(()=>{const N=c.current;if(!(!N||!d.current)&&!(e&&_.current!==e)){if(N.clear(S,C),s&&v.rawMinX!==void 0&&h.current&&p.current){const{rawMinX:R,rawMaxX:O,rawMinY:I,rawMaxY:P,imgW:G,imgH:K,top:L,bottom:Z,left:A,right:U}=v,ce=[];A>0&&ce.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[R,0],[R,K],[0,K]],dstRect:[0,0,A,C]}}),L>0&&ce.push({colOffsetX:A,colOffsetY:0,strip:{srcQuad:[[R,0],[O,0],[O,I],[R,I]],dstRect:[0,0,$,L]}}),Z>0&&ce.push({colOffsetX:A,colOffsetY:L+b,strip:{srcQuad:[[R,P],[O,P],[O,K],[R,K]],dstRect:[0,0,$,Z]}}),U>0&&ce.push({colOffsetX:A+$,colOffsetY:0,strip:{srcQuad:[[O,0],[G,0],[G,K],[O,K]],dstRect:[0,0,U,C]}}),N.renderStripsWithTexture(h.current,S,C,n.image_size[0],n.image_size[1],ce,1)}if(h.current&&p.current){const R=n.columns.flatMap(O=>(O.strips||[]).map(I=>({colOffsetX:v.left+O.offset_x,colOffsetY:v.top,strip:I})));if(R.length>0?N.renderStripsWithTexture(h.current,S,C,n.image_size[0],n.image_size[1],R,1):N.renderStripsWithTexture(h.current,S,C,n.image_size[0],n.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[n.image_size[0],0],[n.image_size[0],n.image_size[1]],[0,n.image_size[1]]],dstRect:[0,0,S,C]}}],1),w&&w.current_page_strips.length>0){const O=w.current_page_strips.map(I=>({colOffsetX:v.left+j,colOffsetY:v.top,strip:I}));N.renderStripsWithTexture(h.current,S,C,n.image_size[0],n.image_size[1],O,1)}}if(w&&m.current&&u.current&&w.mate_page_strips.length>0){const R=w.mate_page_strips.map(O=>({colOffsetX:v.left+j+w.half_w,colOffsetY:v.top,strip:O}));N.renderStripsWithTexture(m.current,S,C,w.mate_img_size[0],w.mate_img_size[1],R,.65)}}},[e,n,w,S,C,j,b,$,v,s]),T=g.useRef(B);T.current=B,g.useEffect(()=>{const N=d.current;if(!N)return;const R=P=>{h.current=p.current?P.createTexture(p.current):null,m.current=u.current?P.createTexture(u.current):null,T.current()};try{const P=new go(N);c.current=P,R(P)}catch(P){console.error("Failed to init WebGL renderer:",P)}const O=P=>{P.preventDefault(),console.warn("WebGL context lost")},I=()=>{console.info("WebGL context restored, re-initializing..."),d.current&&(c.current=new go(d.current),R(c.current))};return N.addEventListener("webglcontextlost",O,!1),N.addEventListener("webglcontextrestored",I,!1),()=>{N.removeEventListener("webglcontextlost",O),N.removeEventListener("webglcontextrestored",I),c.current&&(c.current.deleteTexture(h.current),c.current.deleteTexture(m.current),c.current.destroy(),c.current=null)}},[]),g.useEffect(()=>{if(!e)return;let N=!0;return fo(e).then(R=>{if(!N||!R)return;p.current=R,_.current=e;const O=c.current;O&&(O.deleteTexture(h.current),h.current=O.createTexture(R)),x(I=>I+1)}),()=>{N=!1}},[e]);const z=w==null?void 0:w.mate_image_url;g.useEffect(()=>{if(!z)return;let N=!0;return fo(z).then(R=>{if(!N||!R)return;u.current=R;const O=c.current;O&&(O.deleteTexture(m.current),m.current=O.createTexture(R)),y(I=>I+1)}),()=>{N=!1}},[z]),g.useEffect(()=>{B()},[B,f,k]);const F=g.useMemo(()=>{const N=[];for(const R of n.columns)for(const O of R.chars){const[I,P,G,K]=O.bbox_col;N.push({id:O.id,char:O.char,x:v.left+R.offset_x+I,y:v.top+P,w:Math.max(G-I,1),h:Math.max(K-P,1)})}return N},[n,v]);return t.jsxs("div",{className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${S} / ${C}`,backgroundColor:i("warp-bg"),boxShadow:i("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("canvas",{ref:d,width:S,height:C,style:{width:"100%",height:"100%",display:"block",backgroundColor:i("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${S} ${C}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[F.map(N=>{const R=o.has(N.id),O=r===N.id;return t.jsx("rect",{"data-selected":R?"true":void 0,x:N.x,y:N.y,width:N.w,height:N.h,fill:R?i("warp-sel-bg"):O?i("warp-hover-bg"):"transparent",stroke:R?i("warp-sel-stroke"):O?i("warp-hover-stroke"):"transparent",strokeWidth:R?3.5:O?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(N.id),onMouseEnter:()=>l==null?void 0:l(N.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:N.char})},N.id)}),w&&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+w.half_w,y1:v.top,x2:v.left+j+w.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})]})]})]})},qh={work:"work",book:"work",people:"person",person:"person",place:"place",office:"office",dynasty:"dynasty"};function Xh(e){return typeof e=="string"&&qh[e]||"other"}function xo(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 jn(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Et(e){return typeof e=="string"&&e?e:void 0}function Xl(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=jn(l.start_offset)??jn(a.start_offset),p=jn(l.end_offset)??jn(a.end_offset);if(c===void 0||p===void 0||c<0||p<=c)return;const u=Et(d.status),h=u===void 0||u==="matched"?xo(Et(d.entity_id))??xo(Et(d.href))??void 0:void 0,m=a.anchor??{},f=Et(m.start),x=Et(m.end);o.push({...f&&x?{anchor:{start:f,end:x}}:{},key:Et(a.id)??`e${s}`,kind:Xh(a.type),start:c,end:p,text:Et(a.text),targetId:h,canonicalName:Et(d.canonical_name),confidence:jn(a.confidence)})}),o.sort((r,s)=>r.start-s.start||s.end-r.end)}const Zh=new Set(Array.from(`《》/<>\r
|
|
1253
|
+
,。、;:?!「」『』()…—·`));function lr(e){return!Zh.has(e)}function Zl(e,n,o=0){const r=[],s=Array.from(e);let a=0;for(const d of s)lr(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],h=e.codePointAt(u)>65535?2:1;l.push({...d,start:r[c],end:u+h})}return l}function Jh(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(lr).join("")===n.text:!0}function Qh(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 Jl(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||!Jh(e,d))&&(d=Qh(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 cr=`
|
|
1252
1254
|
.bim-et-w { position: relative; display: inline; }
|
|
1253
1255
|
.bim-et {
|
|
1254
1256
|
color: inherit; text-decoration-line: underline;
|
|
@@ -1257,7 +1259,8 @@ ${mm}`;function kn({children:t,style:n,wide:o,grid:r}){return e.jsxs("div",{clas
|
|
|
1257
1259
|
text-decoration-skip-ink: none;
|
|
1258
1260
|
}
|
|
1259
1261
|
.bim-et-work { text-decoration-style: wavy; }
|
|
1260
|
-
.bim-et-person, .bim-et-
|
|
1262
|
+
.bim-et-person, .bim-et-office, .bim-et-dynasty, .bim-et-other { text-decoration-style: solid; }
|
|
1263
|
+
.bim-et-place { text-decoration-style: double; text-decoration-thickness: 3px; }
|
|
1261
1264
|
a.bim-et { cursor: pointer; }
|
|
1262
1265
|
a.bim-et:hover, a.bim-et:focus-visible { color: ${i("accent")}; text-decoration-color: ${i("accent")}; }
|
|
1263
1266
|
a.bim-et:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 2px; border-radius: 2px; }
|
|
@@ -1287,13 +1290,13 @@ a.bim-et:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 2px;
|
|
|
1287
1290
|
.bim-et-card { animation: bim-et-in 120ms ease-out; }
|
|
1288
1291
|
@keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
|
|
1289
1292
|
}
|
|
1290
|
-
`,Ah=120;function at(t){return typeof t=="string"&&t.trim()?t.trim():void 0}function Ph(t,n=Ah){if(!t)return;const o=t.replace(/\s+/g," ").trim(),r=Array.from(o);return r.length>n?r.slice(0,n).join("")+"…":o}function Mh(t){const n=typeof t.birth_year=="number"?t.birth_year:void 0,o=typeof t.death_year=="number"?t.death_year:void 0;if(!(n===void 0&&o===void 0))return`${n??"?"}–${o??"?"}`}function Bh(t){if(!Array.isArray(t.authors))return;const n=t.authors.map(o=>{if(!o||typeof o!="object")return"";const r=o,s=at(r.name);return s?[at(r.dynasty)&&`〔${at(r.dynasty)}〕`,s,at(r.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Ba(t,n){const o=at(n.type),r=at(n.primary_name)??at(n.title)??t,s=o==="entity"?[at(n.dynasty),Mh(n),at(n.native_place)].filter(Boolean).join(" · "):[Bh(n),at(n.edition),at(n.measure_info)].filter(Boolean).join(" · "),l=n.description&&typeof n.description=="object"?at(n.description.text):at(n.description);return{id:t,type:o,title:r,meta:s||void 0,description:Ph(l)}}function Wa(t){const n=[t.dynasty,t.author,t.edition].filter(Boolean).join(" · ");return{id:t.id,type:t.type,title:t.title,meta:n||void 0}}function Oa(t){return async n=>{const o=await t.getItem(n);if(o)return Ba(n,o);if(t.getEntry){const r=await t.getEntry(n);if(r)return Wa(r)}return null}}const gs=new WeakMap;function Wh(t,n,o){let r=gs.get(t);r||(r=new Map,gs.set(t,r));const s=r.get(o);if(s)return s;const l=n(o);return r.set(o,l),l.catch(()=>r.delete(o)),l}const Ha=t=>`/item/${encodeURIComponent(t)}`,Oh={work:"書名",person:"人名",place:"地名",office:"官職",dynasty:"朝代",other:"專名"},Hh=typeof window>"u"?g.useEffect:g.useLayoutEffect;function tr(t,n){return g.useMemo(()=>n?{owner:n,load:n}:t?{owner:t,load:Oa(t)}:null,[n,t])}const Fh=t=>t,Dh=({text:t,entities:n,offsets:o="text",plainBase:r=0,transport:s,loadSummary:l,buildHref:a=Ha,onNavigate:p,renderText:c=Fh,hoverDelayMs:d=250,injectStyles:u=!0,className:m})=>{const h=g.useMemo(()=>{const x=o==="plain"?Pa(t,n,r):n;return Ma(t,x)},[t,n,o,r]),f=tr(s,l);return e.jsxs("span",{className:m?`bim-et-root ${m}`:"bim-et-root",children:[u&&e.jsx("style",{children:er}),h.map(x=>x.type==="text"?e.jsx(g.Fragment,{children:c(x.text)},`t${x.start}`):e.jsx(nr,{span:x.span,label:x.text,hasBrackets:t[x.start-1]==="《"&&t[x.start+x.text.length]==="》",loader:f,buildHref:a,onNavigate:p,renderText:c,hoverDelayMs:d},`${x.span.key}@${x.start}`))]})},nr=({span:t,label:n,hasBrackets:o,loader:r,buildHref:s,onNavigate:l,renderText:a,hoverDelayMs:p})=>{const c=g.useId(),[d,u]=g.useState(!1),m=g.useRef(null),h=`bim-et bim-et-${t.kind}`,f=t.kind==="work"&&!o,x=e.jsxs(e.Fragment,{children:[f&&e.jsx("span",{className:"bim-et-sr",children:"《"}),a(n),f&&e.jsx("span",{className:"bim-et-sr",children:"》"})]}),j=()=>{m.current&&(clearTimeout(m.current),m.current=null)};g.useEffect(()=>j,[]);const y=g.useCallback(v=>{j(),v<=0?u(!0):m.current=setTimeout(()=>u(!0),v)},[]),_=g.useCallback(()=>{j(),u(!1)},[]);if(!t.targetId)return e.jsx("span",{className:h,children:x});const b=t.targetId;return e.jsxs("span",{className:"bim-et-w",onMouseEnter:()=>y(p),onMouseLeave:_,onKeyDown:v=>{v.key==="Escape"&&d&&(v.stopPropagation(),_())},children:[e.jsx("a",{className:h,href:s(b),"data-entity-id":b,"aria-describedby":d?c:void 0,onFocus:()=>y(0),onBlur:_,onClick:l?v=>l(b,v):void 0,children:x}),d&&e.jsx(Uh,{id:c,entityId:b,span:t,loader:r})]})},Uh=({id:t,entityId:n,span:o,loader:r})=>{const{convert:s}=Z(),l=g.useRef(null),[a,p]=g.useState("start"),[c,d]=g.useState(r?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!r)return;let h=!1;return d({status:"loading"}),Wh(r.owner,r.load,n).then(f=>{h||d({status:"ready",summary:f})}).catch(()=>{h||d({status:"error"})}),()=>{h=!0}},[r,n]),Hh(()=>{const h=l.current;if(!h||typeof window>"u")return;const f=h.getBoundingClientRect(),x=document.documentElement.clientWidth||window.innerWidth;f.right>x-8&&a==="start"&&p("end")},[c,a]);const u=c.status==="ready"?c.summary:null,m=(u==null?void 0:u.title)??o.canonicalName??o.text;return e.jsxs("span",{ref:l,id:t,role:"tooltip",className:"bim-et-card","data-align":a,children:[e.jsx("span",{className:"bim-et-card-k",children:s(Oh[o.kind])}),m&&e.jsx("span",{className:"bim-et-card-t",children:s(m)}),(u==null?void 0:u.meta)&&e.jsx("span",{className:"bim-et-card-m",children:s(u.meta)}),(u==null?void 0:u.description)&&e.jsx("span",{className:"bim-et-card-d",children:s(u.description)}),c.status==="loading"&&e.jsx("span",{className:"bim-et-card-s",children:s("載入中…")}),c.status==="error"&&e.jsx("span",{className:"bim-et-card-s",children:s("摘要載入失敗")})]})},Vh=t=>`/item/${encodeURIComponent(t)}`;function Gh(t,n){const o=[];for(const r of t){const s=n.get(r.charData.id)??null,l=o[o.length-1];l&&l.entity===s?l.chars.push(r):o.push({entity:s,chars:[r]})}return o}const ir=({pageData:t,pages:n,punctuations:o=Kh,selectedCharIds:r,hoveredCharId:s,onSelectionChange:l,onCharClick:a,onCharHover:p,mode:c="horizontal",showPunctuation:d=!0,onVisiblePageChange:u,entities:m,entityTransport:h,loadEntitySummary:f,buildEntityHref:x,onEntityNavigate:j})=>{const y=g.useRef(null),_=g.useRef(0),b=g.useMemo(()=>{const C=new Map;return d&&o.forEach((T,R)=>{const A=T.id?T:{...T,id:`${T.anchor}#${R}`},H=C.get(A.anchor)||[];H.push(A),C.set(A.anchor,H)}),C},[o,d]),v=g.useMemo(()=>(n&&n.length>0?n:[{page:parseInt(t.page_id.split(":")[1]||"1",10),columns:t.columns}]).map(T=>{const R=[...T.columns].sort((q,ne)=>q.col-ne.col),A=[];let H=[];for(const q of R)for(const ne of q.chars){const L=(b.get(ne.id)||[]).filter(P=>P.kind!=="break"),Q=(b.get(ne.id)||[]).some(P=>P.kind==="break");H.push({charData:ne,col:q.col,afterPuncts:L}),Q&&(A.push({id:`para-p${T.page}-${A.length}`,chars:H}),H=[])}return H.length>0&&A.push({id:`para-p${T.page}-${A.length}`,chars:H}),{page:T.page,paragraphs:A}}),[n,t,b]),S=g.useMemo(()=>{const C=[];for(const T of v)for(const R of T.paragraphs)for(const A of R.chars)C.push(A.charData.id);return C},[v]),k=g.useMemo(()=>{const C=new Map;if(!m||m.length===0)return C;const T=new Map(S.map((R,A)=>[R,A]));for(const R of m){if(!R.anchor)continue;const A=T.get(R.anchor.start),H=T.get(R.anchor.end);if(!(A===void 0||H===void 0||H<A))for(let q=A;q<=H;q++)C.has(S[q])||C.set(S[q],R)}return C},[m,S]),$=tr(h,f),w=k.size>0,z=g.useRef({onCharClick:a,onCharHover:p,onSelectionChange:l,onVisiblePageChange:u,onEntityNavigate:j});z.current={onCharClick:a,onCharHover:p,onSelectionChange:l,onVisiblePageChange:u,onEntityNavigate:j};const B=g.useMemo(()=>({click:C=>{var T,R;_.current=Date.now()+1200,(R=(T=z.current).onCharClick)==null||R.call(T,C)},enter:C=>{var T,R;return(R=(T=z.current).onCharHover)==null?void 0:R.call(T,C)},leave:()=>{var C,T;return(T=(C=z.current).onCharHover)==null?void 0:T.call(C,null)},navigate:(C,T)=>{var A,H;if(!(T.detail===0||T.ctrlKey||T.metaKey||T.shiftKey)){T.preventDefault();return}(H=(A=z.current).onEntityNavigate)==null||H.call(A,C,T)}}),[]),I=qh(r),N=g.useRef(null);g.useEffect(()=>{var T,R;if((T=N.current)==null||T.classList.remove("is-hovered"),N.current=null,!s)return;const C=(R=y.current)==null?void 0:R.querySelector(`span[data-char-id="${s}"]`);C&&(C.classList.add("is-hovered"),N.current=C)},[s]),g.useEffect(()=>{let C=null;const T=()=>{var ue,xe;C=null;const A=window.getSelection(),H=y.current;if(!A||A.isCollapsed||A.rangeCount===0||!H)return;const q=A.getRangeAt(0),ne=q.commonAncestorContainer,L=ne.nodeType===3?ne.parentElement:ne;if(!L||!H.contains(L))return;const Q=H.querySelectorAll("span[data-char-id]");let P=0,D=Q.length;for(;P<D;){const Ee=P+D>>1;q.comparePoint(Q[Ee],0)<0?P=Ee+1:D=Ee}const pe=P;for(D=Q.length;P<D;){const Ee=P+D>>1;q.comparePoint(Q[Ee],0)<=0?P=Ee+1:D=Ee}const le=P-1;if(le<pe)return;const fe=[];for(let Ee=pe;Ee<=le;Ee++)fe.push(Q[Ee].getAttribute("data-char-id"));fe.length>0&&(_.current=Date.now()+1200,(xe=(ue=z.current).onSelectionChange)==null||xe.call(ue,fe))},R=()=>{C&&clearTimeout(C),C=setTimeout(T,120)};return document.addEventListener("selectionchange",R),()=>{document.removeEventListener("selectionchange",R),C&&clearTimeout(C)}},[]),g.useEffect(()=>{var C;if(r.size===1){const T=Array.from(r)[0],R=(C=y.current)==null?void 0:C.querySelector(`span[data-char-id="${T}"]`);R&&R.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[r]);const O=!!u;return g.useEffect(()=>{var q;if(!O)return;const C=Array.from(((q=y.current)==null?void 0:q.querySelectorAll("[data-page-section]"))??[]);if(C.length===0)return;const T=120;let R=0;const A=()=>{var P,D;if(R=0,Date.now()<_.current)return;let ne=0,L=C.length-1;for(;ne<L;){const pe=ne+L+1>>1;C[pe].getBoundingClientRect().top<=T?ne=pe:L=pe-1}const Q=parseInt(C[ne].getAttribute("data-page-section")||"",10);isNaN(Q)||(D=(P=z.current).onVisiblePageChange)==null||D.call(P,Q)},H=()=>{R||(R=requestAnimationFrame(A))};return window.addEventListener("scroll",H,{passive:!0}),A(),()=>{window.removeEventListener("scroll",H),R&&cancelAnimationFrame(R)}},[O,v]),e.jsxs("div",{ref:y,className:"guji-text-pane-content",children:[w&&e.jsx("style",{children:er}),e.jsx("div",{className:"guji-text-reflow-view",children:v.map((C,T)=>e.jsx(Xh,{pGroup:C,first:T===0,selected:I.get(C.page)??Yh,entityOfChar:k,entityLoader:$,buildHref:x??Vh,handlers:B},`page-sec-${C.page}`))})]})},Yh=new Set,Kh=[];function qh(t){const n=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;t.forEach(s=>{const l=parseInt(s.split(":")[0],10);let a=o.get(l);a||o.set(l,a=new Set),a.add(s)});const r=new Map;return o.forEach((s,l)=>{const a=n.current.get(l),p=a&&a.size===s.size&&Array.from(s).every(c=>a.has(c));r.set(l,p?a:s)}),n.current=r,r},[t])}const Xh=g.memo(function({pGroup:n,first:o,selected:r,entityOfChar:s,entityLoader:l,buildHref:a,handlers:p}){return e.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative"},children:[!o&&e.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:[e.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}}),e.jsxs("span",{style:{padding:"0 12px",fontWeight:500},children:["第 ",n.page," 葉"]}),e.jsx("div",{style:{flex:1,height:"1px",background:i("rule")}})]}),n.paragraphs.map(c=>e.jsx("p",{className:"guji-reflow-paragraph",children:Gh(c.chars,s).map((d,u)=>{const m=d.chars.map(({charData:f,col:x,afterPuncts:j},y)=>{const b=!!d.entity&&y===d.chars.length-1?[]:j;return e.jsxs(g.Fragment,{children:[e.jsx("span",{"data-char-id":f.id,onClick:()=>p.click(f.id),onMouseEnter:()=>p.enter(f.id),onMouseLeave:p.leave,className:`guji-text-char${r.has(f.id)?" is-selected":""}${f.sub?" is-sub":""}`,title:`[第${n.page}葉·第${x}列·第${f.slot||f.pos}字] ${f.char}`,children:f.char}),b.map(v=>e.jsx("span",{className:"guji-text-punct","data-punct-id":v.id,children:v.mark},v.id))]},f.id)});if(!d.entity)return e.jsx(g.Fragment,{children:m},`r${u}`);const h=d.chars[d.chars.length-1].afterPuncts.map(f=>e.jsx("span",{className:"guji-text-punct","data-punct-id":f.id,children:f.mark},f.id));return e.jsxs(g.Fragment,{children:[e.jsx(nr,{span:d.entity,label:d.chars.map(f=>f.charData.char).join(""),hasBrackets:!0,loader:l,buildHref:a,onNavigate:p.navigate,renderText:()=>m,hoverDelayMs:250}),h]},`${d.entity.key}@${u}`)})},c.id))]})});function Fa(t,n,o,r,s){const[l,a]=g.useState(n??null),[p,c]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){a(n);return}const u=++d.current;if(!o){a(null),c(!1);return}if(t){let m;try{m=t(o,s)}catch{a(null),c(!1);return}if(!m||typeof m.then!="function"){a(m??null),c(!1);return}c(!0),m.then(h=>{u===d.current&&a(h??null)}).catch(()=>{u===d.current&&a(null)}).finally(()=>{u===d.current&&c(!1)});return}if(r!=null&&r.warp_data){if(typeof r.warp_data=="object"){a(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===d.current&&a(m)}).catch(()=>{u===d.current&&a(null)}).finally(()=>{u===d.current&&c(!1)});return}}a(null),c(!1)},[t,n,o,r,s]),{warpData:l,loading:p}}function Zh(t,n,o){const[r,s]=g.useState([]),l=g.useRef(0);return g.useEffect(()=>{const a=++l.current;if(!t||!n){s([]);return}let p;try{p=t(n,o)}catch{s([]);return}Promise.resolve(p).then(c=>{a===l.current&&s(c?Aa(c):[])}).catch(()=>{a===l.current&&s([])})},[t,n,o]),r}const fs={padding:24,color:i("desc-fg"),fontSize:14};function xs({title:t,label:n,className:o,style:r}){const s=(l,a=14,p=14)=>({width:l,height:a,marginTop:p,borderRadius:3,background:i("rule")});return e.jsxs("div",{className:o,style:{...r,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[t&&e.jsx("div",{style:{fontSize:15,color:i("ink"),fontFamily:i("font-ui")},children:t}),e.jsx("div",{style:s("42%",24,28)}),e.jsx("div",{style:s("30%",12,10)}),["96%","100%","92%","98%","64%"].map((l,a)=>e.jsx("div",{style:s(l,16,a===0?30:14)},a)),e.jsx("p",{role:"status",style:{marginTop:24,color:i("desc-fg"),fontSize:14,fontFamily:i("font-ui")},children:n})]})}const bs=/^https?:\/\//i;function Jh(t){if(!t||typeof t!="object")return null;const n=l=>typeof l=="string"&&l.trim()?l.trim():void 0,o=n(t.url),r=n(t.license_url),s={name:n(t.name),url:o&&bs.test(o)?o:void 0,license:n(t.license),license_url:r&&bs.test(r)?r:void 0,note:n(t.note)};return s.name||s.license||s.note?s:null}function Qh(t,n){return{work_id:n.work_id??t,title:n.title,type:n.type,juan_files:n.chapters.map(o=>o.file),juan_metadata:n.juan_metadata,juan_groups:n.juan_groups,references:n.references,target_source:n.target_source,target_source_id:n.target_source_id,text_source:n.text_source,text_quality:n.text_quality}}function eg(t,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(o=>o.vol_label)?"冊":(t==null?void 0:t.kind)==="collated"?"卷":"章"}function Da(t,n,o,r=!1){const s=o(`${n}${t.n}`);if(!t.title)return s;const l=o(t.title);return r&&!/^[卷冊册章篇回第]/.test(t.title)?`${s} ${l}`:l}function tg(t,n,o,r,s){var d;const l=new Map(t.chapters.map(u=>[u.file,u])),a=u=>u==="loading"?"…":typeof u=="number"&&u>0?u:void 0,p=(u,m)=>{const h=l.get(u);return{key:u,label:m??(h?Da(h,o,r,s):u),hint:a(n[u]),disabled:n[u]===0}},c=(d=t.juan_groups)==null?void 0:d.filter(u=>{var m;return u.files.some(h=>l.has(h))||((m=u.children)==null?void 0:m.length)});if(c&&c.length>0){const u=(m,h)=>{var x;if(m.files.length===1&&!((x=m.children)!=null&&x.length))return p(m.files[0],r(m.label));const f=uh(m,n);return{key:`group:${h}`,label:r(m.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Ra(m),defaultExpanded:typeof f=="number"&&f>0,children:[...m.files.filter(j=>l.has(j)).map(j=>p(j)),...(m.children??[]).map((j,y)=>u(j,`${h}.${y}`))]}};return c.map((m,h)=>u(m,`${h}`))}return t.chapters.map(u=>p(u.file))}const or=({id:t,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:l,title:a,subtitle:p,resolveImages:c,renderImageOverlay:d,imagePanel:u,allowVertical:m,onReportError:h,revisedAt:f,backHref:x,backLabel:j,resolveWarpData:y,warpData:_,resolveEntities:b,onEntityNavigate:v,className:S,style:k})=>{var jr,vr,kr;const{t:$,convert:w}=Z(),z=g.useMemo(()=>Hl(n),[n]),[B,I]=Xl(),N=Ke(),O=g.useRef(s);O.current=s;const[C,T]=g.useState(null),[R,A]=g.useState("loading");g.useEffect(()=>{let F=!1;return T(null),A("loading"),z.getManifest(t).then(ye=>{F||(ye?(T(ye),A("ready")):A("missing"))}).catch(()=>{F||A("missing")}),()=>{F=!0}},[z,t]);const H=o!==void 0,q=r!==void 0,[ne,L]=g.useState(null),[Q,P]=g.useState(null);g.useEffect(()=>{L(null),P(null)},[t]);const D=we.pickTextVersion(C,H?o:ne),pe=((jr=C==null?void 0:C.versions.find(F=>F.key==="default"))==null?void 0:jr.key)??((vr=C==null?void 0:C.versions[0])==null?void 0:vr.key)??"default",le=(D==null?void 0:D.key)??null,fe=q?r:Q,ue=g.useCallback((F,ye,Oe)=>{var Ue;(Ue=O.current)==null||Ue.call(O,{key:F,chapter:ye,isDefault:F===pe},Oe)},[pe]);g.useEffect(()=>{!C||!H||o==null||C.versions.some(F=>F.key===o)||ue(pe,null,"auto")},[C,H,o,pe,ue]);const xe=g.useRef(new Map);g.useEffect(()=>{xe.current.clear()},[z,t]);const Ee=g.useCallback(async F=>{const ye=`${t}
|
|
1291
|
-
${
|
|
1292
|
-
${
|
|
1293
|
-
${
|
|
1294
|
-
${
|
|
1295
|
-
${
|
|
1296
|
-
${le??""}`,load:te,files:Ne,activeFile:J??null,activeJuan:(ae==null?void 0:ae.json)??null,activeRawText:(ae==null?void 0:ae.md)??null,query:W,isKaozhen:me}),Be=g.useRef(new Map);g.useEffect(()=>{Be.current.clear()},[t]);const Fe=g.useMemo(()=>({versionKey:le,chapter:he??null}),[le,he]),Ze=Qm(c,J??null,Fe),{warpData:de,loading:Qe}=Fa(y,_,J??null,he,Fe),E=Zh(b,J??null,Fe),[oe,se]=g.useState(new Set),[je,ke]=g.useState(null),[ge,V]=g.useState(!0),[ce,Te]=g.useState(!0),Ie=F=>{var Oe;const ye=parseInt(((Oe=F==null?void 0:F.page_id)==null?void 0:Oe.split(":")[1])??"",10);return isNaN(ye)?null:ye},U=F=>{var ye,Oe;return Ie(F)??((Oe=(ye=F==null?void 0:F.pages)==null?void 0:ye[0])==null?void 0:Oe.page)??1},[X,Le]=g.useState(()=>U(de));g.useEffect(()=>{de&&Le(U(de))},[de]),g.useEffect(()=>{se(new Set),ke(null)},[J,le]);const _e=g.useCallback(F=>{if(se(new Set(F)),F.length>0){const ye=F[0],Oe=parseInt(ye.split(":")[0],10);isNaN(Oe)||Le(Oe)}},[]),De=g.useMemo(()=>{const F=new Map;for(const ye of(de==null?void 0:de.pages)??[])F.set(ye.page,ye);return F},[de]),We=Ie(de),ot=g.useCallback(F=>{var Ue;const ye=Ze.images;if(!ye||ye.length===0)return;const Oe=(Ue=De.get(F))==null?void 0:Ue.seq;return(Oe?ye.find(st=>st.seq===Oe):void 0)??ye.find(st=>st.pageNo===F)??ye[F-1]},[Ze.images,De]),It=g.useCallback(F=>{const ye=ot(F);return ye?F===We?ye.hiresUrl??ye.url:ye.url:F===We?(de==null?void 0:de.imageUrl)??"":""},[ot,de,We]),Pn=g.useMemo(()=>It(X),[It,X]);g.useEffect(()=>{if(de)for(const F of[1,-1,2,3]){const ye=It(X+F);ye&&so(ye)}},[de,X,It]);const dn=g.useMemo(()=>{var $r;if(!de)return null;if(X===We)return de;const F=De.get(X);if(F&&F.width>0&&F.height>0)return{page_id:`p:${X}`,title:`第${X}葉`,image_size:[F.width,F.height],total_warped_w:F.width,columns:[{col:1,warped_w:F.width,warped_h:F.height,offset_x:0,strips:[],chars:F.columns.flatMap(Ge=>Ge.chars).map(Ge=>({id:Ge.id,char:Ge.char,slot:Ge.slot,pos:Ge.pos,sub:Ge.sub,bbox_col:Ge.bbox??[0,0,0,0]}))}]};const ye=($r=de.pages)==null?void 0:$r.find(Ge=>Ge.page===X),[Oe,Ue]=de.image_size||[2386,3082],st=ot(X),Kt=(st==null?void 0:st.width)??Oe,$i=(st==null?void 0:st.height)??Ue,wr=Kt/Oe,Sr=$i/Ue,_r=new Map;for(const Ge of de.columns){const lt=(Ge.strips||[]).flatMap(Bn=>Bn.srcQuad.map(Wn=>Wn[0]));if(lt.length===0)continue;const yt=Ge.top_y??0,Ci=Ge.bottom_y??yt+Ge.warped_h;_r.set(Ge.col,{x0:Math.min(...lt),x1:Math.max(...lt),top:yt,slotH:(Ci-yt)/21})}return{page_id:`p:${X}`,title:`第${X}葉`,image_size:[Kt,$i],total_warped_w:Kt,columns:ye?ye.columns.map(Ge=>{const lt=_r.get(Ge.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ge.col,warped_w:Kt,warped_h:$i,offset_x:0,strips:[],chars:Ge.chars.map(yt=>{const Ci=yt.slot??yt.pos??0,Bn=(lt.top+(Ci-1)*lt.slotH)*Sr,Wn=(lt.x0+lt.x1)/2,[yd,jd]=yt.sub==="a"?[Wn,lt.x1]:yt.sub==="b"?[lt.x0,Wn]:[lt.x0,lt.x1];return{...yt,bbox_col:[yd*wr,Bn,jd*wr,Bn+lt.slotH*Sr]}})}}):[]}},[de,X,We,De,ot]),{entryTitle:Rt,authors:pn}=og(t,n,a===void 0),[un,ki]=g.useState("text");if(g.useEffect(()=>{ki("text")},[J,le]),R==="loading")return e.jsx(xs,{className:S,style:k,title:a??Rt,label:$("reader.loading")});if(R==="missing"||!C||!D)return e.jsx("div",{className:S,style:{...k,...fs},children:$("reader.noText")});if(He==="failed")return e.jsx("div",{className:S,style:{...k,...fs},children:$("reader.tocFailed")});if(!ie)return e.jsx(xs,{className:S,style:k,title:a??Rt,label:$("reader.tocLoading")});const Lt=eg(D,ie),ud=tg(ie,Me,Lt,w,be),wi=C.versions.map(F=>({key:F.key,label:we.textVersionLabel(F),optionLabel:w(we.textVersionLabel(F)),sourceName:F.source_name?w(F.source_name):void 0,license:F.license??void 0,sourceUrl:F.source_url??void 0,primary:F.key===pe})),rt=Jh((kr=ie.source)==null?void 0:kr.upstream),Mn=(typeof a=="string"?w(a):a)??(ie.title?w(ie.title):Rt?w(Rt):void 0),md=Mn?e.jsx("a",{href:N(t),title:$("reader.viewEntry"),onClick:l?F=>{F.metaKey||F.ctrlKey||(F.preventDefault(),l(t))}:void 0,children:Mn}):void 0,hd=pn.length>0?w(pn.slice(0,2).map(F=>`${F.dynasty?`〔${F.dynasty}〕`:""}${F.name}${` ${F.role||$("reader.defaultRole")}`}`).join("、")):void 0,Si=he?Da(he,Lt,w,be):void 0,Gt=be&&!!(ae!=null&&ae.json),At=(ae==null?void 0:ae.json)??null,Yt=(ae==null?void 0:ae.md)??null,yr=Gt&&!me&&La(At.sections),gd=yr&&!(Yt&&B.readingMode==="paragraph"&&Zn(Yt)),fd=Gt&&yr?e.jsx($h,{juan:At,view:un,onView:ki,textHasEntries:gd}):void 0,xd=Bl(ie)||Ki(ie),_i=Yt?Yt.replace(/^##\s+[^\n]+\n+/,""):null,bd=(typeof p=="string"?w(p):p)??(D.source_name?w(D.source_name):w(we.textVersionLabel(D)));return e.jsxs(Ql,{className:S,style:k,title:md,subtitle:bd,byline:hd,current:Si,pagerUnit:Lt,rail:fd,revisedAt:f,backHref:x,backLabel:j,onReportError:h?F=>h({...F,bookTitle:typeof Mn=="string"?Mn:void 0,entryId:t}):void 0,workLinkToggle:Gt&&!me&&!!l&&!!(At!=null&&At.sections.some(F=>F.work_id)),toc:ud,tocCaption:$("reader.tocCaption",{n:ie.chapters.length,unit:w(Lt)}),tocHeader:be&&ie.chapters.length>1?e.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:me?$("reader.searchChaptersPlaceholder"):$("reader.searchUnitPlaceholder",{unit:w(Lt)}),"aria-label":me?$("reader.searchChapters"):$("reader.searchUnit",{unit:w(Lt)}),value:W,onChange:F=>re(F.target.value)}):void 0,activeKey:J??null,onSelect:ve,images:Ze.images,imagesLoading:Ze.loading||Qe,renderImageOverlay:d,imagePanel:de?"open":u,isWarpMode:!!de,customImagePanel:de&&dn?e.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px 6px",fontSize:12,color:i("meta-fg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600},children:"底本书影"}),e.jsxs("span",{"data-warp-page":X,style:{fontSize:11,padding:"1px 6px",background:i("rule"),borderRadius:10},children:["第 ",X," 葉"]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:oe.size>0&&e.jsxs("button",{type:"button",onClick:()=>se(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${i("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",oe.size,")"]})})]}),e.jsx("div",{style:{flex:1,minHeight:0,position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Jo,{imageUrl:Pn,pageData:dn,selectedCharIds:oe,hoveredCharId:je,preserveMargins:ce,onCharClick:F=>{se(Oe=>{const Ue=new Set(Oe);return Ue.has(F)?Ue.delete(F):(Ue.clear(),Ue.add(F)),Ue});const ye=document.querySelector(`[data-char-id="${F}"]`);ye&&ye.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ke})}),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0 2px"},children:e.jsxs("div",{style:{display:"inline-flex",border:`1px solid ${i("rule")}`,borderRadius:4,overflow:"hidden"},children:[e.jsx("button",{type:"button",onClick:()=>Te(!1),className:`bim-rd-t ${ce?"":"bim-rd-on"}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:ce?"transparent":i("accent-bg"),color:ce?"inherit":i("accent")},title:"去空白:紧凑裁切版心",children:"去空白"}),e.jsx("button",{type:"button",onClick:()=>Te(!0),className:`bim-rd-t ${ce?"bim-rd-on":""}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:ce?i("accent-bg"):"transparent",color:ce?i("accent"):"inherit"},title:"保留空白:完整呈现古籍天头地脚与白边",children:"保留空白"})]})})]}):void 0,toolbarExtra:de?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-badge-warp",children:"图文对读"}),e.jsx("button",{type:"button",className:`bim-rd-t ${ge?"bim-rd-on":""}`,title:"切换外挂现代断句标点",onClick:()=>V(F=>!F),children:ge?"标点":"无标点"})]}):void 0,prefs:B,onPrefsChange:I,versions:wi.length>1?wi:void 0,currentVersionKey:wi.length>1?D.key:void 0,onVersionChange:G,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:Zn(Yt),allowVertical:m,children:[M&&e.jsx(Ut,{}),!M&&de&&e.jsxs("article",{className:"bim-rd-prose",style:{marginTop:0},children:[e.jsxs("header",{style:{marginBottom:16},children:[e.jsx("h1",{className:"bim-rd-h1",children:he!=null&&he.title?w(he.title):Si}),(D.source_name||D.license)&&e.jsxs("p",{className:"bim-rd-meta",children:[D.source_name&&w(D.source_name),D.license&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),D.license]})]})]}),e.jsx(ir,{pageData:de,pages:de.pages,punctuations:de.punctuations||[],selectedCharIds:oe,hoveredCharId:je,onSelectionChange:_e,onCharClick:F=>{se(Oe=>{const Ue=new Set(Oe);return Ue.has(F)?Ue.delete(F):(Ue.clear(),Ue.add(F)),Ue});const ye=parseInt(F.split(":")[0],10);isNaN(ye)||Le(ye)},onCharHover:ke,mode:"horizontal",showPunctuation:ge,entities:B.properNames?E:void 0,entityTransport:n,onEntityNavigate:v,onVisiblePageChange:F=>Le(F)})]}),!M&&!de&&Gt&&At&&e.jsx(Sh,{juan:At,rawText:Yt,positionLabel:ng(he,ie,Lt,w),groupLabel:ig(ie,J??null),index:Qh(t,ie),searchQuery:W,onNavigate:l,transport:n,workLabelCache:Be,prefs:B,view:un,onViewChange:ki},`${le}/${J}`),!M&&!de&&!Gt&&_i!=null&&he&&e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsx("h1",{className:"bim-rd-h1",children:he.title?w(he.title):Si}),(D.source_name||D.license)&&e.jsxs("p",{className:"bim-rd-meta",children:[D.source_name&&e.jsxs(e.Fragment,{children:[$("reader.textSource")," ",D.source_url?e.jsx("a",{className:"bim-rd-link",href:D.source_url,target:"_blank",rel:"noreferrer",children:w(D.source_name)}):w(D.source_name)]}),D.source_name&&D.license&&e.jsx("span",{className:"bim-rd-dot"}),D.license]}),rt&&e.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[$("reader.upstream")," ",rt.url?e.jsx("a",{className:"bim-rd-link",href:rt.url,target:"_blank",rel:"noreferrer",children:w(rt.name??rt.url)}):w(rt.name??""),rt.license&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),rt.license_url?e.jsx("a",{className:"bim-rd-link",href:rt.license_url,target:"_blank",rel:"noreferrer",children:rt.license}):rt.license]}),rt.note&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-rd-dot"}),e.jsx(Fl,{text:rt.note,convert:w})]})]})]}),e.jsx("article",{className:"bim-rd-prose",children:e.jsx(Vo,{text:_i,mode:B.readingMode,tables:xd,gujiMarkdown:Ki(ie),properNames:B.properNames})})]}),!M&&!de&&!Gt&&_i==null&&he&&e.jsx("div",{className:"bim-rd-state",children:$("reader.chapterFailed")}),ie.references&&ie.references.length>0&&e.jsxs("section",{className:"bim-rd-refs",children:[e.jsx("h2",{children:$("reader.references")}),e.jsx("ol",{children:ie.references.map((F,ye)=>e.jsxs("li",{children:[F.url?e.jsx("a",{className:"bim-rd-link",href:F.url,target:"_blank",rel:"noopener noreferrer",children:w(F.title)}):e.jsx("span",{children:w(F.title)}),F.author&&e.jsxs("span",{children:[",",w(F.author)]}),F.note&&e.jsxs("span",{children:["。",w(F.note)]})]},ye))})]})]})};function ng(t,n,o,r){var l,a;if(!t)return;const s=(a=(l=n.juan_metadata)==null?void 0:l[t.file])==null?void 0:a.vol_label;return r(s?`${s}冊`:`${o}${t.n}`)}function ig(t,n){if(!n)return;const o=r=>{var s;for(const l of r??[]){const a=o(l.children);if(a)return a;if((s=l.files)!=null&&s.includes(n))return l.label}};return o(t.juan_groups)}function og(t,n,o){const[r,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let l=!1;return Promise.resolve(n.getItem(t)).then(a=>{if(l||!a)return;const p=(a.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof a.title=="string"?a.title:void 0,authors:p})}).catch(()=>{}),()=>{l=!0}},[t,n,o]),r}const Ua={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")}},rg=Ua.other,Va={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")}},sg=Va.pending;function lg(t){try{const n=new Date(t),o=r=>String(r).padStart(2,"0");return`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())} ${o(n.getHours())}:${o(n.getMinutes())}`}catch{return t}}function ag(t,n){if(!t)return!1;try{const o=new URL(t,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const rr=({items:t,loading:n})=>{const o=Ke(),{t:r,convert:s}=Z();return n?e.jsx(Ut,{}):t.length===0?e.jsx("div",{style:cg,children:r("feedback.empty")}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:t.map(l=>{const a=Ua[l.type]||rg,p=Va[l.status]||sg,c=typeof window<"u"&&ag(l.pageUrl,window.location.href);return e.jsxs("div",{style:dg,children:[e.jsxs("div",{style:pg,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{...ys,background:a.color},children:r(`feedback.listType.${a.key}`)}),e.jsx("span",{style:{...ys,background:p.color},children:r(`feedback.status.${p.key}`)})]}),e.jsx("span",{style:ug,children:lg(l.createdAt)})]}),(l.resourceId||l.pageUrl)&&e.jsxs("div",{style:mg,children:[l.resourceId&&e.jsx("a",{href:o(l.resourceId),style:Mi,children:l.resourceId}),l.pageUrl&&!l.resourceId&&(c?e.jsx("a",{href:l.pageUrl,style:Mi,children:l.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):e.jsx("span",{style:Mi,children:l.pageUrl}))]}),e.jsx("div",{style:hg,children:s(l.content)}),l.reply&&e.jsxs("div",{style:gg,children:[e.jsx("div",{style:fg,children:r("feedback.reply")}),e.jsx("div",{children:s(l.reply)})]})]},l.id)})})},cg={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},dg={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},pg={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},ys={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},ug={fontSize:"12px",color:i("desc-fg")},mg={fontSize:"12px",marginBottom:"6px"},Mi={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},hg={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},gg={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},fg={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},ao=({transport:t,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:l})=>{const a=$e(),[p,c]=g.useState(null),[d,u]=g.useState([]),[m,h]=g.useState("recommend"),[f,x]=g.useState([]),[j,y]=g.useState(!1),_=r??m,b=R=>{h(R),s==null||s(R)},[v,S]=g.useState(!0),[k,$]=g.useState(null),[w,z]=g.useState(null),[B,I]=g.useState(null);g.useEffect(()=>{let R=!1;if(t.getCounts)return t.getCounts().then(A=>{R||c({works:A.works,books:A.books,collections:A.collections})}).catch(()=>{}),()=>{R=!0}},[t]),g.useEffect(()=>{let R=!1;return(async()=>{if(o)return o;if(t.getRecommended)try{const H=await t.getRecommended();if(H!=null&&H.groups)return H.groups.flatMap(q=>q.items.map(ne=>({...ne,group:q.name})))}catch{}return[]})().then(async H=>{if(R)return;const q=H.filter(L=>L.id);if(q.length===0){S(!1);return}const ne=await Promise.all(q.map(async L=>{if(L.type)return{id:L.id,title:L.title,type:L.type,author:L.author,dynasty:L.dynasty,role:L.role,edition:L.edition,has_text:L.has_text,has_image:L.has_image,has_collated:L.has_collated,subtype:L.subtype,primary_name:L.primary_name,group:L.group,fallbackDescription:L.description};try{let Q=null;if(t.getEntry)Q=await t.getEntry(L.id);else{const P=await t.getItem(L.id);P&&(Q={id:L.id,title:P.title||L.id,type:P.type||"work"})}if(Q)return{...Q,group:L.group,fallbackDescription:L.description}}catch{}return{id:L.id,title:L.title,type:we.extractType(L.id),group:L.group,fallbackDescription:L.description}}));R||(u(ne.filter(L=>L!==null)),S(!1))}),()=>{R=!0}},[t,o]);const N=g.useRef(!1),O=g.useRef(!1),C=g.useRef(!1);g.useEffect(()=>{if(_!=="catalog"||N.current)return;const R=t.getCatalogProgress??t.getResourceProgress;if(!R)return;N.current=!0;let A=!1;return R.call(t).then(H=>{A||$(H)}).catch(()=>{N.current=!1}),()=>{A=!0}},[t,_]),g.useEffect(()=>{if(_!=="collection"||O.current||!t.getCollectionProgress)return;O.current=!0;let R=!1;return t.getCollectionProgress().then(A=>{R||z(A)}).catch(()=>{O.current=!1}),()=>{R=!0}},[t,_]),g.useEffect(()=>{if(_!=="site"||C.current||!t.getSiteProgress)return;C.current=!0;let R=!1;return t.getSiteProgress().then(A=>{R||I(A)}).catch(()=>{C.current=!1}),()=>{R=!0}},[t,_]),g.useEffect(()=>{if(!l||_!=="feedback")return;let R=!1;return y(!0),fetch(l).then(A=>A.json()).then(A=>{!R&&A.success&&x(A.items||[])}).catch(()=>{}).finally(()=>{R||y(!1)}),()=>{R=!0}},[l,_]);const T=R=>e.jsx(cn,{type:R,size:12});return e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:e.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[e.jsx(bn,{label:a.home.recommendTab,active:_==="recommend",onClick:()=>b("recommend")}),e.jsx(bn,{label:a.home.catalogTab,active:_==="catalog",onClick:()=>b("catalog")}),e.jsx(bn,{label:a.home.collectionTab,active:_==="collection",onClick:()=>b("collection")}),e.jsx(bn,{label:a.home.siteTab,active:_==="site",onClick:()=>b("site")}),l&&e.jsx(bn,{label:a.home.feedbackTab,active:_==="feedback",onClick:()=>b("feedback")})]}),_==="recommend"&&e.jsx(xg,{recommended:d,loading:v,onNavigate:n,getIcon:T,t:a}),_==="catalog"&&e.jsx(js,{progress:k,t:a,onNavigate:n}),_==="collection"&&e.jsx(js,{progress:w,t:a,onNavigate:n}),_==="site"&&e.jsx(yg,{progress:B,t:a,totalWorks:(p==null?void 0:p.works)??0}),_==="feedback"&&l&&e.jsx(rr,{items:f,loading:j})]})})},bn=({label:t,active:n,onClick:o})=>e.jsx("button",{onClick:o,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:i(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${i("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:t}),xg=({recommended:t,loading:n,onNavigate:o,getIcon:r,t:s})=>{const l=Ke();if(n)return e.jsx(Ut,{});if(t.length===0)return null;const a=new Map;for(const p of t){const c=p.group||s.home.recommendedBrowse;a.has(c)||a.set(c,[]),a.get(c).push(p)}return e.jsx(e.Fragment,{children:Array.from(a.entries()).map(([p,c])=>e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:p}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(d=>{const u=d.dynasty||d.author?`${d.dynasty?`〔${d.dynasty}〕`:""}${d.author||""}`:d.fallbackDescription;return e.jsxs("a",{href:l(d.id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),o==null||o(d.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,cursor:"pointer",background:i("input-bg"),textDecoration:"none",color:"inherit"},children:[e.jsx("span",{style:{fontSize:"20px"},children:r(d.type)}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[d.title,d.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:d.edition})]}),u&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},d.id)})})]},p))})},js=({progress:t,t:n,onNavigate:o})=>{if(!t)return e.jsx(Ut,{});const r=[...t.resources].sort((p,c)=>p.priority-c.priority),s=["in_progress","done","todo"],l={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},a={in_progress:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return e.jsx("div",{children:s.map(p=>{const c=r.filter(d=>d.status===p);return c.length===0?null:e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:a[p]}}),l[p]," (",c.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(d=>e.jsx(bg,{item:d,t:n,statusColor:a[p],onNavigate:o},d.id))})]},p)})})},bg=({item:t,t:n,statusColor:o,onNavigate:r})=>{const s=Ke(),l=t.total>0?Math.round(t.imported/t.total*100):0,a=t.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const p=t.edition?`${t.name}·${t.edition}`:t.name,c=t.collection_id||t.work_id;return c&&r?e.jsx("a",{href:s(c),onClick:d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),r(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},onMouseEnter:d=>d.currentTarget.style.borderBottomStyle="solid",onMouseLeave:d=>d.currentTarget.style.borderBottomStyle="dashed",children:p}):t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:p}):p})()}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:i("widget-border"),color:i("desc-fg"),whiteSpace:"nowrap"},children:t.collection_id?n.indexType.collection:t.work_id?n.indexType.work:a})]}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.total>0?dt(n.home.progressFormat,{imported:String(t.imported),total:String(t.total)}):n.home.totalPending})]}),t.total>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${l}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},yg=({progress:t,t:n,totalWorks:o})=>{if(!t)return e.jsx(Ut,{});const r=[...t.resources].sort((c,d)=>c.priority-d.priority),s=r.filter(c=>c.imported>0),l=r.filter(c=>c.imported===0),a=s.reduce((c,d)=>Math.max(c,d.imported),0),p=o>0?Math.round(a/o*100):0;return e.jsxs("div",{children:[o>0&&e.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${i("primary")} 6%, transparent)`,fontSize:"13px",color:i("fg")},children:[n.home.siteCoverage,": ",e.jsx("strong",{children:a.toLocaleString()})," / ",o.toLocaleString()," ",n.indexType.work," (",p,"%)"]}),s.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>e.jsx(vs,{item:c,t:n,totalWorks:o},c.id))})]}),l.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",l.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:l.map(c=>e.jsx(vs,{item:c,t:n,totalWorks:o},c.id))})]})]})},vs=({item:t,t:n,totalWorks:o})=>{const r=o>0?Math.round(t.imported/o*100):0;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:t.name}):t.name})}),e.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:t.imported>0?`${t.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),t.imported>0&&o>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:t.description})]})},ks="(max-width: 768px)";function jg(){const[t,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(ks).matches);return g.useEffect(()=>{const o=window.matchMedia(ks),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),t}const vg=({transport:t,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var O;const l=$e(),{convert:a}=Re(),p=jg(),[c,d]=g.useState(null),[u,m]=g.useState(null),[h,f]=g.useState(!1),[x,j]=g.useState("detail"),[y,_]=g.useState([]),[b,v]=g.useState(!1),S=g.useCallback(async C=>{if(!t.getCollectionCatalogs&&!t.getCollectionCatalog){_([]);return}v(!0);try{if(t.getCollectionCatalogs){const T=await t.getCollectionCatalogs(C);_(T||[])}else if(t.getCollectionCatalog){const T=await t.getCollectionCatalog(C);_(T?[{resource_id:"",data:T}]:[])}}catch{_([])}finally{v(!1)}},[t]),k=g.useCallback(async C=>{if(o){o(C);return}d(C),m(null),_([]),j("detail"),f(!0);try{const T=await t.getItem(C.id);T&&(m(T),T.type==="collection"&&S(C.id))}catch(T){console.error("加载详情失败:",T)}finally{f(!1)}},[t,o,S]),$=g.useCallback(async C=>{m(null),_([]),j("detail"),f(!0);try{const T=await t.getItem(C);T&&(m(T),d({id:C,title:T.title||C,type:T.type||"book"}),T.type==="collection"&&S(C))}catch(T){console.error("导航失败:",T)}finally{f(!1)}},[t,S]),w=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"&&w,B=p&&(h||u),I=g.useCallback(()=>{d(null),m(null),_([]),j("detail")},[]),N=e.jsx(e.Fragment,{children:h?e.jsx(Ut,{}):u?e.jsxs(e.Fragment,{children:[(z||s)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${i("widget-border")}`,padding:p?"0 12px":"0 48px",background:i("input-bg"),flexShrink:0,overflowX:p?"auto":void 0},children:[z&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>j("detail"),style:Dn(x==="detail"),children:l.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&e.jsxs("button",{onClick:()=>{},style:Dn(!1),children:[l.detailTab.catalog,e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&y.map(C=>e.jsx("button",{onClick:()=>j(`catalog:${C.resource_id}`),style:Dn(x===`catalog:${C.resource_id}`),children:C.short_name?`${a(C.short_name)}${l.detailTab.catalogSuffix}`:l.detailTab.collectionCatalog},C.resource_id)),u.type==="work"&&w&&e.jsx("button",{onClick:()=>j("collated"),style:Dn(x==="collated"),children:l.detailTab.collatedEdition})]}),s&&e.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),e.jsx("div",{style:{padding:p?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:x==="detail"?e.jsx($o,{data:u,transport:t,onNavigate:$}):x.startsWith("catalog:")?e.jsx(Co,{data:(O=y.find(C=>`catalog:${C.resource_id}`===x))==null?void 0:O.data,onNavigate:$}):x==="collated"?e.jsx(or,{id:u.id,transport:t,onNavigate:$}):null})]}):e.jsx(ao,{transport:t,onNavigate:$,recommendedIds:r})});return p?e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:B?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:e.jsxs("button",{onClick:I,style:{padding:"4px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",l.detailTab.basicInfo]})}),e.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:N})]}):e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[e.jsx(Yi,{transport:t,onEntryClick:k,hideModeIndicator:n}),!u&&e.jsx(ao,{transport:t,onNavigate:$,recommendedIds:r})]})}):e.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:[e.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsx(Yi,{transport:t,onEntryClick:k,hideModeIndicator:n})})}),e.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:N})]})};function Dn(t){return{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}const kg=({pageData:t,rawImageUrl:n="",punctuations:o=[],title:r,subtitle:s,onBack:l,className:a="",style:p={}})=>{const[c,d]=g.useState(new Set),[u,m]=g.useState(null),[h,f]=g.useState("horizontal"),[x,j]=g.useState(!0),y=g.useRef(null),_=g.useCallback(k=>{d(new Set(k))},[]),b=g.useCallback(k=>{if(d($=>{const w=new Set($);return w.has(k)?w.delete(k):(w.clear(),w.add(k)),w}),y.current){const $=y.current.querySelector(`[data-char-id="${k}"]`);$&&$.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),v=()=>{var k;d(new Set),window.getSelection&&((k=window.getSelection())==null||k.removeAllRanges())},S=o.length>0?o:t.punctuations||[];return e.jsxs("div",{className:`guji-reader-container ${a}`,style:p,children:[e.jsxs("header",{className:"guji-reader-header",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[l&&e.jsx("button",{type:"button",onClick:l,className:"guji-reader-btn",style:{marginRight:6},children:"‹ 返回"}),e.jsx("span",{className:"guji-reader-title",children:r||t.title}),s&&e.jsx("span",{style:{fontSize:"0.85rem",color:i("meta-fg")},children:s}),e.jsx("span",{className:"guji-reader-tag",children:"WebGL 客户端透视矫正对读"})]}),e.jsxs("div",{className:"guji-reader-actions",children:[e.jsxs("span",{style:{fontSize:"0.85rem",color:i("body-fg")},children:["已选字数: ",e.jsx("strong",{style:{color:i("accent")},children:c.size})]}),c.size>0&&e.jsx("button",{type:"button",onClick:v,className:"guji-reader-btn",children:"清除选中"}),e.jsx("button",{type:"button",onClick:()=>j(k=>!k),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),e.jsx("button",{type:"button",onClick:()=>f(k=>k==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:h==="horizontal"?"切换竖排":"切换横排"})]})]}),e.jsxs("div",{className:"guji-reader-body",children:[e.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%",position:"sticky",top:0},children:[e.jsxs("div",{className:"guji-pane-header",children:[e.jsx("span",{className:"guji-pane-title",children:"底本书影 (WebGL 分带透视矫正 + 完整版心)"}),e.jsx("span",{className:"guji-pane-hint",children:"点击字框可联动文本定位"})]}),e.jsx("div",{className:"guji-pane-content",children:e.jsx(Jo,{imageUrl:n,pageData:t,selectedCharIds:c,hoveredCharId:u,onCharClick:b,onCharHover:m})})]}),e.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:y,children:[e.jsxs("div",{className:"guji-pane-header",children:[e.jsx("span",{className:"guji-pane-title",children:h==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),e.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),e.jsx(ir,{pageData:t,punctuations:S,selectedCharIds:c,hoveredCharId:u,onSelectionChange:_,onCharClick:b,onCharHover:m,mode:h,showPunctuation:x})]})]})]})},wg=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function Xt(t){return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Sg(t){var r,s,l,a,p,c;const n=t&&typeof t=="object"?t.pages:void 0;if(!Array.isArray(n))return[];const o=[];for(const d of n){if(!d||typeof d!="object")continue;const u=d,m=Xt((r=u.page)==null?void 0:r.index),h=Array.isArray(u.cells)?u.cells:[];if(m===void 0||h.length===0)continue;const f=new Map;for(const x of h){if(!x||typeof x!="object")continue;const j=x,y=wg.exec(String(j.a??""));if(!y||typeof j.c!="string")continue;const _=parseInt(y[2],10),b=parseInt(y[3],10),v=Array.isArray(j.box)&&j.box.length===4&&j.box.every($=>Xt($)!==void 0)?j.box:null,S={id:String(j.a),char:j.c,slot:b,pos:b,sub:y[4]||null,bbox:v?[v[0],v[1],v[0]+v[2],v[1]+v[3]]:null};let k=f.get(_);k||f.set(_,k=[]),k.push(S)}o.push({page:m,seq:String(((s=u.canvas)==null?void 0:s.seq)??""),width:Xt((l=u.canvas)==null?void 0:l.width)??Xt((a=u.image)==null?void 0:a.width)??0,height:Xt((p=u.canvas)==null?void 0:p.height)??Xt((c=u.image)==null?void 0:c.height)??0,columns:Array.from(f.entries()).sort((x,j)=>x[0]-j[0]).map(([x,j])=>({col:x,chars:j}))})}return o}function _g(t){const n=Array.isArray(t)?t:t&&typeof t=="object"&&Array.isArray(t.punctuations)?t.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 $g(t){var o;const n=t&&typeof t=="object"?t.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 Cg=({data:t,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:l}=Z(),[a,p]=g.useState(((u=t.divisions[0])==null?void 0:u.name)??null),[c,d]=g.useState(null);return e.jsxs("div",{className:o,style:r,children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:l(t.title)}),t.stats&&e.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg"),display:"flex",gap:"16px"},children:[t.total_volumes!=null&&e.jsxs("span",{children:[s("catalog.totalVolumes")," ",e.jsx("strong",{children:t.total_volumes})," ",s("unit.juan")]}),t.stats.zhulu!=null&&e.jsxs("span",{children:[s("catalogPage.zhulu")," ",e.jsx("strong",{children:t.stats.zhulu})," ",s("unit.bu")]}),t.stats.cunmu!=null&&e.jsxs("span",{children:[s("catalogPage.cunmu")," ",e.jsx("strong",{children:t.stats.cunmu})," ",s("unit.bu")]}),t.stats.categories!=null&&e.jsx("span",{children:s("catalogPage.categoriesN",{n:t.stats.categories})})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.divisions.map(m=>e.jsx(zg,{division:m,expanded:a===m.name,onToggle:()=>p(a===m.name?null:m.name),expandedCat:c,onCatToggle:h=>d(c===h?null:h),onNavigate:n},m.name))})]})},zg=({division:t,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:l})=>{const{t:a,convert:p}=Z(),c=t.categories.reduce((d,u)=>{const m=u.stats||{zhulu:0,cunmu:0};return d+(m.zhulu||0)+(m.cunmu||0)},0);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${i("primary")} 6%, transparent)`:i("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:i("fg"),textAlign:"left"},children:[e.jsx("span",{children:p(t.name)}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg")},children:[a("catalogPage.divisionStat",{cats:t.categories.length,books:c}),e.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&e.jsx("div",{style:{padding:"4px 0"},children:t.categories.map(d=>{const u=`${t.name}/${d.name}`;return e.jsx(Tg,{category:d,expanded:r===u,onToggle:()=>s(u),onNavigate:l},d.name)})})]})},Tg=({category:t,expanded:n,onToggle:o,onNavigate:r})=>{var d,u,m,h;const{t:s,convert:l}=Z(),a=((d=t.books)==null?void 0:d.zhulu)||[],p=((u=t.books)==null?void 0:u.cunmu)||[],c=(((m=t.stats)==null?void 0:m.zhulu)||a.length)+(((h=t.stats)==null?void 0:h.cunmu)||p.length);return e.jsxs("div",{children:[e.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?i("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:i("fg"),textAlign:"left"},children:[e.jsxs("span",{style:{fontWeight:500},children:[l(t.name),t.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:l(t.volumes)})})]}),e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[s("catalogPage.booksN",{n:c})," ",n?"▲":"▼"]})]}),n&&(a.length>0||p.length>0)&&e.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[a.length>0&&e.jsx(ws,{label:s("catalogPage.zhulu"),books:a,onNavigate:r}),p.length>0&&e.jsx(ws,{label:s("catalogPage.cunmu"),books:p,onNavigate:r})]})]})},ws=({label:t,books:n,onNavigate:o})=>{const{t:r,convert:s}=Z(),l=Ke(),[a,p]=g.useState(n.length<=20),c=a?n:n.slice(0,10);return e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[t," (",n.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((d,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[e.jsx("span",{style:{fontWeight:500,color:i("fg")},children:d.work_id&&o?e.jsx("a",{href:l(d.work_id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),o(d.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},children:s(d.title)}):s(d.title)}),d.volumes&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(d.volumes)}),d.author&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:s(d.author).slice(0,20)})]},u))}),!a&&e.jsx("button",{onClick:()=>p(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:r("catalogPage.expandAllN",{n:n.length})})]})},ht=({title:t,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const l=$e();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:t}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&e.jsx("button",{onClick:o,style:Eg,children:"AI"}),n&&e.jsx("button",{onClick:n,style:Ng,children:l.action.save})]})]}),s]})},Ng={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Eg={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},ct=({label:t,value:n,onChange:o,placeholder:r,disabled:s})=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:t}),e.jsx("input",{type:"text",value:n,onChange:l=>o(l.target.value),placeholder:r,disabled:s,style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),Ht=({value:t,onChange:n,placeholder:o})=>{const r=g.useRef(null);return g.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[t]),e.jsx("textarea",{ref:r,value:t||"",onChange:s=>n(s.target.value),placeholder:o,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},Qn=({children:t,color:n,style:o})=>e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||i("primary-soft"),color:i(n?"on-color-fg":"fg"),...o},children:t});function Ig(t){const n=t.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Gn=({value:t,onChange:n,label:o})=>{const[r,s]=g.useState(!1),l=g.useRef(null),a=Ig(t||"");return g.useEffect(()=>{r&&l.current&&l.current.focus()},[r]),!r&&a?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Ss,children:o}),e.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${i("input-border")}`,borderRadius:"2px",background:i("input-bg"),cursor:"pointer",minHeight:"30px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:a.name}),e.jsx(Qn,{children:a.id})]})]}):e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:Ss,children:o}),e.jsx("input",{ref:l,type:"text",value:t||"",onChange:p=>n(p.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Ss={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function Rg(t){switch(t){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function Lg(t){switch(t){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Ga=({items:t,onChange:n,onOpenEntityPicker:o})=>{const r=$e(),[s,l]=g.useState(null),a=()=>{n([...t,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),l(t.length)},p=m=>{n(t.filter((h,f)=>f!==m)),s===m&&l(null)},c=(m,h,f)=>{const x=[...t];x[m]={...x[m],[h]:f},n(x)},d=(m,h)=>{const f=[...t];f[m]={...f[m],type:h,id:"",name:""},n(f),h==="bookID"&&o&&o(x=>{const j=[...t];j[m]={...j[m],id:x.id,name:x.title,type:"bookID"},n(j)})},u=m=>{o&&o(h=>{const f=[...t];f[m]={...f[m],id:h.id,name:h.title,type:"bookID"},n(f)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((m,h)=>e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>l(s===h?null:h),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===h?"▼":"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:m.name||`${r.editor.sourcePlaceholder} ${h+1}`}),m.type&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Rg(m.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Lg(m.type)}),e.jsx("button",{onClick:f=>{f.stopPropagation(),p(h)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===h&&e.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&e.jsxs("div",{children:[e.jsx("label",{style:jt,children:r.editor.selectSourceType}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsxs("button",{onClick:()=>d(h,"bookID"),style:{..._s,borderColor:i("source-bookid"),color:i("source-bookid")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"📚"}),e.jsx("span",{children:"Book ID"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.fromExistingBook})]}),e.jsxs("button",{onClick:()=>d(h,"url"),style:{..._s,borderColor:i("source-url"),color:i("source-url")},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),e.jsx("span",{children:"URL"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.enterUrl})]})]})]}),m.type==="bookID"&&e.jsx(e.Fragment,{children:e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:jt,children:r.action.selectBookOrWork}),e.jsx("button",{onClick:()=>{const f=[...t];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:$s,children:r.action.changeType})]}),m.id&&m.name?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[e.jsx("span",{style:{color:i("source-bookid"),fontSize:"16px"},children:"✓"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:m.name}),e.jsx("code",{style:{fontSize:"11px",background:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),e.jsx("button",{onClick:()=>u(h),style:{background:"transparent",border:`1px solid ${i("widget-border")}`,color:i("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:r.action.reselect})]}):e.jsxs("button",{onClick:()=>u(h),style:{width:"100%",padding:"14px",border:`2px dashed ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[e.jsx("span",{children:"🔍"}),e.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),m.type==="url"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:jt,children:r.label.sourceName}),e.jsx("button",{onClick:()=>{const f=[...t];f[h]={...f[h],type:"",id:"",name:""},n(f)},style:$s,children:r.action.changeType})]}),e.jsx("input",{type:"text",value:m.name,onChange:f=>c(h,"name",f.target.value),placeholder:r.editor.sourceNamePlaceholder,style:Zt})]}),e.jsxs("div",{children:[e.jsx("label",{style:jt,children:r.label.urlAddress}),e.jsx("input",{type:"text",value:m.id,onChange:f=>c(h,"id",f.target.value),placeholder:"https://...",style:Zt})]})]}),m.type&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:e.jsx("label",{style:{...jt,opacity:.7},children:r.label.optionalInfo})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:jt,children:r.label.detailsOptional}),e.jsx("input",{type:"text",value:m.details,onChange:f=>c(h,"details",f.target.value),placeholder:r.editor.detailsPlaceholder,style:Zt})]}),e.jsxs("div",{children:[e.jsx("label",{style:jt,children:r.label.positionOptional}),e.jsx("input",{type:"text",value:m.position,onChange:f=>c(h,"position",f.target.value),placeholder:"如: 卷三, p.52",style:Zt})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:jt,children:r.label.dataVersionOptional}),e.jsx("input",{type:"text",value:m.version,onChange:f=>c(h,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:Zt})]}),e.jsxs("div",{children:[e.jsx("label",{style:jt,children:r.label.processorVersionOptional}),e.jsx("input",{type:"text",value:m.processor_version,onChange:f=>c(h,"processor_version",f.target.value),placeholder:"如: v0.1",style:Zt})]})]})]})]})})]},h)),e.jsxs("button",{onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:r.action.addSource})]})]})},jt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},Zt={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"},_s={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"},$s={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Ya(t){if(!t||!t.trim())return[];try{const n=JSON.parse(t);if(Array.isArray(n))return n.map(o=>({id:o.id||"",name:o.name||"",type:o.type||"",details:o.details||"",position:o.position||"",version:o.version||"",processor_version:o.processor_version||""}))}catch{}return[]}function Ka(t){return!t||t.length===0?"":JSON.stringify(t)}const qa=({entityType:t,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:l,belongsToCollection:a,childWorks:p,childCollections:c,containedBooks:d,siblingBooks:u,onLinkEntity:m,onUnlinkEntity:h,onViewEntity:f,onCreateAndLink:x,onSaveRelations:j})=>{const y=$e();return e.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:y.section.relations})]}),j&&e.jsx("button",{onClick:j,style:Ag,children:y.action.save})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[t==="book"&&e.jsxs(e.Fragment,{children:[e.jsx(yn,{direction:"up",title:y.relation.belongsToWork,entity:l,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(yn,{direction:"up",title:y.relation.containedInCollection,entity:a,onView:f,onUnlink:()=>h("collectionId"),onLink:()=>m("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),l&&u&&u.length>0&&e.jsx(Jt,{direction:"horizontal",title:`${y.relation.siblingVersions} (${u.length})`,entities:u,onView:f,onAdd:()=>x("siblingBook","book",{workId:l.id}),addLabel:y.relation.addVersionForWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),t==="work"&&e.jsxs(e.Fragment,{children:[e.jsx(yn,{direction:"up",title:y.relation.parentWork,entity:r,onView:f,onUnlink:()=>h("parentWorkId"),onLink:()=>m("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),p&&p.length>0&&e.jsx(Jt,{direction:"down",title:`${y.relation.childWorks} (${p.length})`,entities:p,onView:f,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:y.action.addSubWork,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore}),c&&c.length>0&&e.jsx(Jt,{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}),e.jsx(Jt,{direction:"down",title:`${y.relation.allVersions} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:f,onAdd:()=>x("childBook","book",{workId:n}),addLabel:y.action.addVersion,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]}),t==="collection"&&e.jsxs(e.Fragment,{children:[e.jsx(yn,{direction:"up",title:y.relation.correspondingWork,entity:l,onView:f,onUnlink:()=>h("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:o}),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(yn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>h("parentCollectionId"),onLink:()=>m("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:y.action.linkExisting,createLabel:y.action.createAndLink,notLinkedLabel:y.relation.notLinked,viewLabel:y.action.viewEntity,unlinkLabel:y.action.unlink}),e.jsx(Jt,{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}),e.jsx(Jt,{direction:"down",title:`${y.relation.containedBooks} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:f,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:y.action.addBook,noneLabel:y.relation.none,expandMoreLabel:y.action.expandMore})]})]})]})},yn=({direction:t,title:n,entity:o,onView:r,onUnlink:s,onLink:l,onCreate:a,linkLabel:p,createLabel:c,notLinkedLabel:d,viewLabel:u,unlinkLabel:m})=>{const h=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),f=t==="up"?"⬆️":t==="down"?"⬇️":"↔️";return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:h,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:f}),e.jsx("span",{children:n})]}),o?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:Xa(o.type)}),e.jsx("span",{style:{fontWeight:500},children:o.title}),e.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx(Cs,{onClick:()=>r(o),title:u,children:"👁️"}),e.jsx(Cs,{onClick:s,title:m,danger:!0,children:"✕"})]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:d}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsx(co,{onClick:l,children:p}),e.jsx(co,{onClick:a,primary:!0,children:c})]})]})},Jt=({direction:t,title:n,entities:o,onView:r,onAdd:s,addLabel:l,noneLabel:a,expandMoreLabel:p})=>{const[c,d]=g.useState(!1),u=i(t==="up"?"relation-up":t==="down"?"relation-down":"relation-flat"),m=t==="up"?"⬆️":t==="down"?"⬇️":"↔️",h=c?o:o.slice(0,5);return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[e.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:m}),e.jsx("span",{children:n})]}),o.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[h.map(f=>e.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:[e.jsx("span",{children:Xa(f.type)}),e.jsx("span",{children:f.title})]},f.id)),o.length>5&&!c&&e.jsxs("div",{onClick:()=>d(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[p," (",o.length-5,")"]})]}):e.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:a}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs(co,{onClick:s,primary:!0,children:["+ ",l]})})]})},Cs=({onClick:t,title:n,danger:o,children:r})=>e.jsx("button",{onClick:s=>{s.stopPropagation(),t()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),co=({onClick:t,primary:n,children:o})=>e.jsx("button",{onClick:t,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${i("widget-border")}`,borderRadius:"4px",background:n?i("primary"):"transparent",color:n?i("primary-fg"):"inherit",cursor:"pointer"},children:o});function Xa(t){switch(t){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Ag={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Za=({isOpen:t,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:l,searchResults:a,onSearch:p,isLoading:c,excludeId:d})=>{const[u,m]=g.useState(""),h=d?a.filter(y=>y.id!==d):a;g.useEffect(()=>{t&&(m(""),p(""))},[t]);const f=y=>{m(y),p(y)};if(!t)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",j=n==="work"?"📜":n==="book"?"📖":"📚";return e.jsx("div",{style:Pg,children:e.jsxs("div",{style:Mg,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),e.jsx("button",{onClick:s,style:Bg,children:"✕"})]}),e.jsx("div",{style:{padding:"12px 16px"},children:e.jsx("input",{type:"text",value:u,onChange:y=>f(y.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:Wg})}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?e.jsx("div",{style:Bi,children:"搜索中..."}):h.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:h.map(y=>e.jsxs("div",{onClick:()=>r(y),style:Og,children:[e.jsx("span",{style:{fontSize:"16px"},children:j}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[y.title,y.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:y.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[y.id,y.author&&` · ${y.author}`,y.dynasty&&` · ${y.dynasty}`]})]})]},y.id))}):u?e.jsxs("div",{style:Bi,children:["未找到匹配的",x]}):e.jsxs("div",{style:Bi,children:["输入关键词搜索",x]})}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsxs("button",{onClick:l,style:Hg,children:["创建新",x,"并关联"]})]})]})})},Pg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Mg={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")},Bg={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Wg={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"},Og={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},Bi={padding:"20px",textAlign:"center",color:i("desc-fg")},Hg={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},zs={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Fg={work:"📜",book:"📖",collection:"📚",entity:"👤"},Ja=({isOpen:t,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:l})=>{const[a,p]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{t&&(p((r==null?void 0:r.title)||""),setTimeout(()=>{var h,f;(h=c.current)==null||h.focus(),(f=c.current)==null||f.select()},100))},[t,r==null?void 0:r.title]);const d=h=>{h.key==="Enter"&&a.trim()?u():h.key==="Escape"&&l()},u=()=>{a.trim()&&s(a.trim(),{...r,title:a.trim()})};if(!t)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`创建新${zs[n]}`}};return e.jsx("div",{style:Dg,onClick:h=>{h.target===h.currentTarget&&l()},children:e.jsxs("div",{style:Ug,onClick:h=>h.stopPropagation(),children:[e.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:Fg[n]}),e.jsx("span",{children:m()})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",e.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),e.jsx("input",{ref:c,type:"text",value:a,onChange:h=>p(h.target.value),onKeyDown:d,placeholder:`请输入${zs[n]}名称...`,style:Vg})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[e.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&e.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&e.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{onClick:l,style:Gg,children:"取消"}),e.jsx("button",{onClick:u,disabled:!a.trim(),style:{...Yg,opacity:a.trim()?1:.6,cursor:a.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Dg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ug={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:i("shadow-dialog")},Vg={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"},Gg={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Yg={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function Kg(t){switch(t){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Qa(t){switch(t){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function qg(t){switch(t){case"work":return i("editor-type-work");case"collection":return i("editor-type-collection");case"book":return i("editor-type-book");default:return i("desc-fg")}}const ec=({isOpen:t,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:l=!1,createButtonText:a,onSelect:p,onCancel:c,onCreate:d,onSearch:u})=>{const[m,h]=g.useState(""),[f,x]=g.useState([]),[j,y]=g.useState(!1),[_,b]=g.useState("recent");g.useEffect(()=>{t&&(h(""),x([]),b(r.length>0?"recent":"search"))},[t,r.length]),g.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 v=g.useCallback(z=>{h(z.target.value),z.target.value.trim()&&b("search")},[]),S=g.useCallback(z=>s?z.filter(B=>B.id!==s):z,[s]);if(!t)return null;const k=n||(o==="all"?"选择实体":`选择${Qa(o)}`),$=S(r),w=S(f);return e.jsx("div",{style:Zg,children:e.jsxs("div",{style:Jg,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:k}),e.jsx("button",{onClick:c,style:Qg,children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px 12px"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",value:m,onChange:v,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:ef}),e.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),j&&e.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&e.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsxs(Ts,{active:_==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),e.jsxs(Ts,{active:_==="search",onClick:()=>b("search"),children:["搜索结果 ",w.length>0&&`(${w.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:_==="recent"&&$.length>0?e.jsx(Ns,{entities:$,onSelect:p}):m.trim()?j?e.jsx(Wi,{message:"搜索中..."}):w.length>0?e.jsx(Ns,{entities:w,onSelect:p}):e.jsx(Wi,{message:"未找到匹配的结果"}):e.jsx(Wi,{message:"输入关键词开始搜索"})}),l&&d&&e.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsx("button",{onClick:d,style:tf,children:a||"创建新实体"})]})]})})},Ts=({active:t,onClick:n,children:o})=>e.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:t?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(t?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:t?600:400,marginBottom:"-1px"},children:o}),Ns=({entities:t,onSelect:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map(o=>e.jsx(Xg,{entity:o,onClick:()=>n(o)},o.id))}),Xg=({entity:t,onClick:n})=>{const[o,r]=g.useState(!1);return e.jsxs("div",{onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:i("primary-soft"),transition:"background 0.1s"},children:[e.jsx("span",{style:{fontSize:"18px"},children:Kg(t.type)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[t.title,t.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:t.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[e.jsx("code",{style:{fontSize:"10px",background:i("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:t.id}),t.author&&e.jsx("span",{children:t.author}),t.dynasty&&e.jsx("span",{children:t.dynasty})]})]}),e.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:qg(t.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Qa(t.type)})]})},Wi=({message:t})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:t}),Zg={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Jg={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")},Qg={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},ef={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"},tf={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},nf={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},of={work:"📜",collection:"📚",book:"📖",entity:"👤"},tc=({data:t,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:l,onDelete:a,onAskAI:p,renderSectionActions:c,onDownloadResource:d,downloadStatuses:u,relations:m,onRelationsChange:h})=>{var Se;const f=$e(),[x,j]=g.useState(!1),[y,_]=g.useState("work"),[b,v]=g.useState(""),[S,k]=g.useState(""),[$,w]=g.useState([]),[z,B]=g.useState(!1),[I,N]=g.useState(!1),[O,C]=g.useState("work"),[T,R]=g.useState(""),[A,H]=g.useState(),[q,ne]=g.useState(!1),[L,Q]=g.useState(null),[P,D]=g.useState([]);g.useRef(null);const pe=t.type,le=pe==="work",fe=pe==="collection",ue=pe==="book",xe=g.useCallback((K,Ce)=>{n({...t,[K]:Ce})},[t,n]),Ee=g.useCallback((K,Ce)=>{v(K),_(Ce),k(f.editor.selectToLink+f.indexType[Ce]),w([]),j(!0)},[f]),ie=g.useCallback(K=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(t.id,K)},[r,t.id]),Ae=g.useCallback(K=>{s==null||s(K.id,K.type)},[s]),He=g.useCallback((K,Ce,Pe)=>{const M={...Pe,author:(Pe==null?void 0:Pe.author)||t.author,dynasty:Pe==null?void 0:Pe.dynasty};C(Ce),R(K),H(M),N(!0)},[t.author]),Y=g.useCallback((K,Ce)=>{r!=null&&r.createAndLink&&r.createAndLink(t.id,T,{type:O,title:K,inheritData:Ce}),N(!1)},[r,t.id,T,O]),J=g.useCallback(K=>{if(!K.trim()){w([]);return}B(!0),r!=null&&r.searchEntities&&r.searchEntities(K,y).then(Ce=>{w(Ce),B(!1)}).catch(()=>{w([]),B(!1)})},[r,y]),he=g.useCallback(K=>{r!=null&&r.linkEntity&&r.linkEntity(t.id,b,K.id),j(!1)},[r,t.id,b]),ze=g.useCallback(()=>{o()},[o]),G=g.useCallback(K=>{Q(()=>K),ne(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(D).catch(()=>{})},[r]),ve=g.useCallback((K,Ce)=>r!=null&&r.searchEntities?r.searchEntities(K,Ce==="all"?void 0:Ce):Promise.resolve([]),[r]),ae=g.useCallback(K=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(K),D(Ce=>[K,...Ce.filter(Pe=>Pe.id!==K.id)].slice(0,10)),L==null||L(K),ne(!1),Q(null)},[r,L]);return e.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${i("widget-border")}`,paddingBottom:"16px"},children:e.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:of[pe]}),e.jsx("span",{children:t.title||f.editor.untitled}),e.jsx(Qn,{children:t.id}),e.jsx(Qn,{color:nf[pe],children:f.indexType[pe]})]})}),e.jsx(ht,{title:f.section.basicInfo,onSave:o,onAskAI:p?()=>p("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsx(Gn,{label:le?f.editor.workTitle:fe?f.editor.collectionTitle:f.editor.bookTitle,value:t.title,onChange:K=>xe("title",K)}),ue&&e.jsx(Gn,{label:f.editor.belongsToWork,value:t.workName||"",onChange:K=>xe("workName",K)}),e.jsx(ct,{label:f.editor.authorLabel,value:t.author||"",onChange:K=>xe("author",K)}),e.jsx(ct,{label:f.editor.publicationYearLabel,value:t.publicationYear||"",onChange:K=>xe("publicationYear",K)}),(ue||fe)&&e.jsx(Gn,{label:f.editor.containedIn,value:t.collection||"",onChange:K=>xe("collection",K)}),(ue||fe)&&e.jsx(ct,{label:f.editor.holderLabel,value:t.holder||"",onChange:K=>xe("holder",K)}),(ue||fe)&&e.jsx(ct,{label:ue?f.editor.pageLabel:f.editor.volumeLabel,value:t.pages||"",onChange:K=>xe("pages",K)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(ct,{label:f.editor.firstImageLabel,value:t.firstImage||"",onChange:K=>xe("firstImage",K)})})]})}),e.jsx(ht,{title:f.section.description,onSave:o,onAskAI:p?()=>p("介绍"):void 0,children:e.jsx(Ht,{value:t.description||"",onChange:K=>xe("description",K),placeholder:f.editor.descriptionPlaceholder})}),(((Se=t.additional_works)==null?void 0:Se.length)||0)>0&&e.jsx(ht,{title:f.section.additionalWorks,onSave:o,children:e.jsx(rf,{items:t.additional_works||[],onChange:K=>xe("additional_works",K)})}),e.jsx(ht,{title:f.section.indexedBy,onSave:o,onAskAI:p?()=>p("收录于"):void 0,children:e.jsx(sf,{items:t.indexed_by||[],onChange:K=>xe("indexed_by",K)})}),e.jsx(ht,{title:f.section.emendatedBy,onSave:o,onAskAI:p?()=>p("考证"):void 0,children:e.jsx(lf,{items:t.emendated_by||[],onChange:K=>xe("emendated_by",K)})}),e.jsx(ht,{title:f.section.textResources,onSave:o,onAskAI:p?()=>p("资源"):void 0,children:e.jsx(Vi,{items:t.resources||[],onChange:K=>xe("resources",K),onDownload:d,downloadStatuses:u,filterType:"text"})}),e.jsx(ht,{title:f.section.imageResources,onSave:o,children:e.jsx(Vi,{items:t.resources||[],onChange:K=>xe("resources",K),onDownload:d,downloadStatuses:u,filterType:"image"})}),e.jsx(ht,{title:f.section.sources,onSave:o,onAskAI:p?()=>p("资料来源"):void 0,children:e.jsx(Ga,{items:Ya(t.sources||""),onChange:K=>xe("sources",Ka(K)),onOpenEntityPicker:G})}),(ue||fe)&&e.jsx(ht,{title:f.section.provenance,onSave:o,onAskAI:p?()=>p("收藏历史"):void 0,children:e.jsx(Ht,{value:t.provenance||"",onChange:K=>xe("provenance",K),placeholder:f.editor.provenancePlaceholder})}),ue&&e.jsx(ht,{title:f.section.otherEditions,onSave:o,onAskAI:p?()=>p("其他版本"):void 0,children:e.jsx(Ht,{value:t.otherEditions||"",onChange:K=>xe("otherEditions",K),placeholder:f.editor.otherEditionsPlaceholder})}),e.jsx(qa,{entityType:pe,entityId:t.id,entityTitle:t.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:Ee,onUnlinkEntity:ie,onViewEntity:Ae,onCreateAndLink:He,onSaveRelations:ze}),l&&a&&e.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[e.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:f.section.dangerZone}),e.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:f.editor.dangerZoneDesc}),e.jsx("button",{onClick:a,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:f.editor.deleteEntity})]}),e.jsx(Za,{isOpen:x,entityType:y,title:S,onSelect:he,onCancel:()=>j(!1),onCreate:()=>{j(!1),He(b,y)},searchResults:$,onSearch:J,isLoading:z,excludeId:t.id}),e.jsx(Ja,{isOpen:I,entityType:O,relationField:T,inheritData:A,onConfirm:Y,onCancel:()=>N(!1)}),e.jsx(ec,{isOpen:q,title:f.action.selectBookOrWork,filterType:"all",recentEntities:P,excludeId:t.id,onSelect:ae,onCancel:()=>{ne(!1),Q(null)},onSearch:ve})]})};function rf({items:t,onChange:n}){const o=$e(),r=(a,p,c)=>{const d=t.map((u,m)=>m===a?{...u,[p]:c}:u);n(d)},s=a=>n(t.filter((p,c)=>c!==a)),l=()=>n([...t,{book_title:""}]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((a,p)=>e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(ct,{label:o.editor.bookNameLabel,value:a.book_title,onChange:c=>r(p,"book_title",c)}),e.jsx("div",{style:{width:"100px"},children:e.jsx(ct,{label:o.label.juanCount,value:a.n_juan!=null?String(a.n_juan):"",onChange:c=>r(p,"n_juan",c&&parseInt(c,10)||void 0)})}),e.jsx("button",{onClick:()=>s(p),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("muted"),marginTop:"18px"},children:"✕"})]},p)),e.jsx("button",{onClick:l,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:o.action.addAdditionalWork})]})}function nc({items:t,onChange:n,showMeta:o,addLabel:r}){const s=$e(),[l,a]=g.useState(null),p=(u,m,h)=>{const f=t.map((x,j)=>j===u?{...x,[m]:h||void 0}:x);n(f)},c=u=>{n(t.filter((m,h)=>h!==u)),l===u&&a(null)},d=()=>{n([...t,{source:""}]),a(t.length)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((u,m)=>{const h=l===m;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:h?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>a(h?null:m),children:[e.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:h?"rotate(90deg)":"none"},children:"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),e.jsx("button",{onClick:f=>{f.stopPropagation(),c(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!h&&o&&(u.title_info||u.author_info)&&e.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:i("desc-fg")},children:[u.title_info,u.title_info&&u.author_info&&" — ",u.author_info]}),h&&e.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(ct,{label:s.label.sourceName,value:u.source,onChange:f=>p(m,"source",f)}),e.jsx(ct,{label:s.label.sourceBid,value:u.source_bid||"",onChange:f=>p(m,"source_bid",f)})]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(ct,{label:s.label.titleInfo,value:u.title_info||"",onChange:f=>p(m,"title_info",f)}),e.jsx(ct,{label:s.label.authorInfo,value:u.author_info||"",onChange:f=>p(m,"author_info",f)})]}),e.jsx(ct,{label:s.label.edition,value:u.edition||"",onChange:f=>p(m,"edition",f)})]}),e.jsx(Ht,{value:u.summary||"",onChange:f=>p(m,"summary",f),placeholder:s.editor.summaryPlaceholder}),e.jsx(Ht,{value:u.comment||"",onChange:f=>p(m,"comment",f),placeholder:s.editor.commentPlaceholder}),e.jsx(Ht,{value:u.additional_comment||"",onChange:f=>p(m,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),e.jsx("button",{onClick:d,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:r})]})}function sf({items:t,onChange:n}){const o=$e();return e.jsx(nc,{items:t,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function lf({items:t,onChange:n}){const o=$e();return e.jsx(nc,{items:t,onChange:n,addLabel:o.action.addEmendatedBy})}function ic(t){var p,c,d,u,m,h,f;const n=((c=(p=t.authors)==null?void 0:p[0])==null?void 0:c.name)||"",o=((d=t.publication_info)==null?void 0:d.year)||"",r=((u=t.current_location)==null?void 0:u.name)||"",s=(m=t.page_count)!=null&&m.number?String(t.page_count.number):((h=t.page_count)==null?void 0:h.description)||"",l=typeof t.description=="object"&&t.description!==null&&t.description.text||"",a={id:t.id,title:t.title,type:t.type,author:n,publicationYear:o,holder:r,pages:s,description:l,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};if(t.type==="work"){const x=t;if(Array.isArray(x.related_works)){const j=x.related_works.find(y=>y.relation==="part_of");j&&(a.parentWorkId=j.id,a.parentWorkName=j.title)}}if(t.type==="book"){const x=t;a.workId=x.work_id,Array.isArray(x.contained_in)&&x.contained_in.length>0&&(a.collectionId=(f=x.contained_in[0])==null?void 0:f.id)}return a}function af(t){const n={id:t.id,title:t.title,type:t.type,description:t.description?{text:t.description}:void 0,authors:t.author?[{name:t.author}]:void 0,publication_info:t.publicationYear?{year:t.publicationYear}:void 0,current_location:t.holder?{name:t.holder}:void 0,page_count:t.pages?{number:parseInt(t.pages)||0,description:t.pages}:void 0,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by,emendated_by:t.emendated_by};return t.type==="work"&&t.parentWorkId&&(n.related_works=[{id:t.parentWorkId,title:t.parentWorkName||"",relation:"part_of"}]),t.type==="book"&&(n.work_id=t.workId,t.collectionId&&(n.contained_in=[{id:t.collectionId}])),n}const cf=t=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:l,onChange:a,onSave:p,onDelete:c,onNavigate:d,renderLink:u,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:j,onRelationsChange:y,headerExtra:_,className:b,style:v}=t,S=$e(),[k,$]=g.useState(s),w=l?s:k;g.useEffect(()=>{s!==k&&$(s)},[s]);const z=g.useCallback(()=>{const R=w==="view"?"edit":"view";l?l(R):$(R)},[w,l]),[B,I]=g.useState(null);g.useEffect(()=>{o&&r&&r.getItem(o).then(R=>{R&&I(R)})},[o,r]);const N=n||B,O=g.useMemo(()=>N?ic(N):null,[N]),C=l||!n?e.jsx("button",{onClick:z,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:w==="edit"?i("accent-bg"):"transparent",color:i(w==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:w==="view"?S.common.switchToEdit:S.common.switchToView,children:w==="view"?S.common.modeEdit:S.common.modeView}):null,T=e.jsxs(e.Fragment,{children:[C,_]});return!N&&!O?e.jsx(Ut,{}):w==="view"?e.jsx($o,{data:N,transport:r,onNavigate:d?R=>d(R):void 0,renderLink:u,headerExtra:T,className:b,style:v}):O?e.jsxs("div",{className:b,style:v,children:[T&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:T}),e.jsx(tc,{data:O,onChange:a||(()=>{}),onSave:p||(()=>{}),transport:r,onNavigate:d,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:h,onDownloadResource:f,downloadStatuses:x,relations:j,onRelationsChange:y})]}):e.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:S.common.noData})},df=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],oc=({isOpen:t,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=Z(),[l,a]=g.useState(null),[p,c]=g.useState(""),[d,u]=g.useState(""),[m,h]=g.useState("idle"),[f,x]=g.useState(""),j=g.useRef(null);g.useEffect(()=>{t&&(a(null),c(""),u(""),h("idle"),x(""))},[t]),g.useEffect(()=>{l&&setTimeout(()=>{var b;return(b=j.current)==null?void 0:b.focus()},100)},[l]),g.useEffect(()=>{if(m==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[m,n]),g.useEffect(()=>{if(!t)return;const b=v=>{v.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[t,n]);const y=async()=>{if(!(!l||!p.trim())){h("submitting"),x("");try{await o({type:l,content:p.trim(),...d.trim()?{contact:d.trim()}:{}}),h("success")}catch(b){h("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!t)return null;const _=l&&p.trim()&&m!=="submitting";return e.jsx("div",{style:pf,onClick:b=>{b.target===b.currentTarget&&n()},children:e.jsxs("div",{style:uf,onClick:b=>b.stopPropagation(),children:[e.jsxs("div",{style:mf,children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),e.jsx("button",{onClick:n,style:hf,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?e.jsxs("div",{style:yf,children:[e.jsx("span",{style:{fontSize:"32px"},children:"✓"}),e.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),r&&e.jsx("a",{href:r,style:{fontSize:"13px",color:i("primary"),marginTop:"8px"},children:s("feedback.viewList")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:df.map(b=>e.jsxs("button",{onClick:()=>a(b.value),style:{...gf,...l===b.value?ff:{}},children:[e.jsx("span",{children:b.icon})," ",s(`feedback.submitType.${b.value}`)]},b.value))}),e.jsx("textarea",{ref:j,value:p,onChange:b=>c(b.target.value),placeholder:s(l?`feedback.placeholder.${l}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!l||m==="submitting",style:{...xf,opacity:l?1:.6}}),e.jsx("input",{type:"text",value:d,onChange:b=>u(b.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!l||m==="submitting","aria-label":s("feedback.contactLabel"),style:vf}),e.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[p.length," / 2000"]}),m==="error"&&e.jsx("div",{style:jf,children:f}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{onClick:y,disabled:!_,style:{...bf,opacity:_?1:.6,cursor:_?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},pf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},uf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},mf={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},hf={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},gf={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"},ff={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},xf={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"},bf={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},yf={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},jf={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},vf={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"},po="--bim-feedback-fab-offset",uo=48,kf=16,wf=({onSubmit:t,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:l}=Z(),[a,p]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(r||typeof document>"u")return;const d=document.documentElement;return d.style.setProperty(po,`calc(${c+uo+kf}px + env(safe-area-inset-bottom, 0px))`),()=>{d.style.removeProperty(po)}},[r,c]),e.jsxs(e.Fragment,{children:[!r&&e.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>p(!0),style:{...Sf,zIndex:s??i("feedback-fab-z"),bottom:`calc(${c}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":l("feedback.title"),title:l("feedback.title"),children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),e.jsx(oc,{isOpen:a,onClose:()=>p(!1),onSubmit:t,feedbackListUrl:o})]})},Sf={position:"fixed",width:`${uo}px`,height:`${uo}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"},_f=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],rc=({onSubmit:t})=>{const{t:n}=Z(),[o,r]=g.useState("bug"),[s,l]=g.useState(""),[a,p]=g.useState(""),[c,d]=g.useState("idle"),[u,m]=g.useState(""),h=g.useRef(null);g.useEffect(()=>{o&&setTimeout(()=>{var j;return(j=h.current)==null?void 0:j.focus()},100)},[o]);const f=async()=>{if(!(!o||!s.trim())){d("submitting"),m("");try{await t({type:o,content:s.trim(),...a.trim()?{contact:a.trim()}:{}}),d("success"),l(""),p(""),r("bug")}catch(j){d("error"),m(j instanceof Error?j.message:n("feedback.submitFailedRetry"))}}},x=o&&s.trim()&&c!=="submitting";return c==="success"?e.jsx("div",{style:Es,children:e.jsxs("div",{style:Nf,children:[e.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),e.jsx("button",{onClick:()=>d("idle"),style:Ef,children:n("feedback.continueSubmit")})]})}):e.jsxs("div",{style:Es,children:[e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:_f.map(j=>e.jsxs("button",{onClick:()=>r(j.value),style:{...$f,...o===j.value?Cf:{}},children:[e.jsx("span",{children:j.icon})," ",n(`feedback.submitType.${j.value}`)]},j.value))}),e.jsx("textarea",{ref:h,value:s,onChange:j=>l(j.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...zf}}),e.jsx("input",{type:"text",value:a,onChange:j=>p(j.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:Rf}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[s.length," / 2000"]}),e.jsx("button",{onClick:f,disabled:!x,style:{...Tf,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&e.jsx("div",{style:If,children:u})]})},Es={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},$f={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"},Cf={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},zf={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"},Tf={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Nf={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},Ef={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},If={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},Rf={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 Is(t){return typeof t=="function"?t():t??"/api/feedback"}const sc=({resourceId:t,apiUrl:n})=>{const{t:o}=Z(),[r,s]=g.useState([]),[l,a]=g.useState(!0),p=g.useCallback(async()=>{const d=Is(n);a(!0);try{const m=await(await fetch(`${d}?resourceId=${encodeURIComponent(t)}`)).json();m.success&&s(m.items)}catch{}finally{a(!1)}},[t,n]);g.useEffect(()=>{p()},[p]);const c=async d=>{const u=Is(n),m=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...d,pageUrl:typeof window<"u"?window.location.href:"",resourceId:t})});if(!m.ok){const h=await m.json().catch(()=>null);throw new Error((h==null?void 0:h.error)||o("feedback.submitFailed"))}setTimeout(()=>p(),500)};return e.jsxs("div",{children:[e.jsx(rr,{items:r,loading:l}),e.jsx("div",{style:{marginTop:"24px"},children:e.jsx(rc,{onSubmit:c})})]})},Lf=ti["zh-Hant"].relation,Af=ti["zh-Hant"].lossStatus,Pf=ti["zh-Hant"].resourceKind,gi=sn("zh-Hant"),sr=(t,n)=>Object.prototype.hasOwnProperty.call(t,n);function Rs(t,n=gi){return t?sr(Lf,t)?n(`detail.relation.${t}`):t:n("detail.relation.related")}function Mf(t,n=gi){return sr(Af,t)?n(`detail.lossStatus.${t}`):t}function Bf(t,n=gi){return sr(Pf,t)?n(`detail.resourceKind.${t}`):""}function lr({authors:t,onNavigate:n,renderLink:o}){const{convert:r}=Z(),s=(t||[]).filter(l=>l&&l.name);return s.length?e.jsx(e.Fragment,{children:s.map((l,a)=>{const p=Ao(l.role);return e.jsxs(g.Fragment,{children:[a>0&&" ",l.dynasty&&e.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(l.dynasty),"〕"]}),l.entity_id?e.jsx(Ye,{id:l.entity_id,label:r(l.name),onNavigate:n,renderLink:o,dense:!0}):r(l.name),p&&e.jsx("span",{style:{marginLeft:4},children:r(p)})]},a)})}):null}function lc(t,n,o=gi){var c,d;const r=Ro(t,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")})),l=r.buckets.filter(u=>u.key==="image"||u.key==="textImage").flatMap(u=>u.items);l.length&&s.push({key:"_images",label:s.length?o("detail.otherImages"):void 0,rows:l,mirrors:[]});const a=((c=r.buckets.find(u=>u.key==="physical"))==null?void 0:c.items)??[];return a.length&&s.push({key:"_physical",label:o("detail.resourceKind.physical"),rows:a,mirrors:[]}),{text:((d=r.buckets.find(u=>u.key==="text"))==null?void 0:d.items)??[],groups:s}}function ac(t,n){const o=(t.url?ln(t.url):void 0)||t.name,r=na(t,n);return r?`${o}(${r})`:o}function ar({item:t,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=Z(),[l,a]=g.useState(!1),p=ni(t),c=!!p&&p.expected>0&&!(o!=null&&o.has(p.expected)),d=s(ac(t,n)),u=an(t),m=di(t,r)||t.details;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const h=(f=t.metadata)!=null&&f.fragment||t.color_mode?e.jsxs("span",{className:"bim-d-tags bim-d-ui",style:{display:"inline-flex",margin:"0 0 0 8px",verticalAlign:"middle"},children:[((x=t.metadata)==null?void 0:x.fragment)&&e.jsx("span",{className:"bim-d-tag",children:r("detail.fragmentTag")}),t.color_mode&&e.jsx("span",{className:"bim-d-tag",children:t.color_mode==="color"?r("colorMode.color"):r("colorMode.bw")})]}):null;return u?e.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[d," ",e.jsx("span",{"aria-hidden":"true",children:"↗"}),h]}):e.jsxs("span",{className:"bim-d-zt-name",children:[d,h]})})(),m&&e.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&l&&e.jsx("div",{style:{padding:"0 12px 10px"},children:e.jsx(Oo,{item:t})})]}),e.jsx("td",{className:c?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:c&&e.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":l,onClick:()=>a(h=>!h),children:l?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:p.expected})})})]})}function cc({groups:t,listedVolumeCounts:n}){const{t:o,convert:r}=Z();return e.jsx(e.Fragment,{children:t.map(s=>e.jsxs("div",{className:"bim-d-rg",children:[s.label&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:r(s.label)}),s.description&&e.jsx("p",{className:"bim-d-rg-d",children:r(s.description)}),s.rows.length>0&&e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:s.rows.map((l,a)=>e.jsx(ar,{item:l,siblings:s.rows,listedVolumeCounts:n},`${l.id||l.url||l.name}-${a}`))})}),s.mirrors.length>0&&e.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[s.rows.length>0&&e.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:o("detail.mirror")}),s.mirrors.map((l,a)=>{const p=an(l),c=r(ac(l,s.mirrors));return p?e.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",title:l.details?r(l.details):void 0,children:[c," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]},a):e.jsx("span",{style:{marginRight:14},children:c},a)})]})]},s.key))})}const Cn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function mo(t){var o;if(!t)return;const n=t.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=Cn.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const Ls=12,Wf=60,dc=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:l,back:a,railLinks:p})=>{var J,he,ze;const{t:c,convert:d,messages:u}=Z(),m=g.useMemo(()=>[...t.books||[],...t.collections||[]],[t.books,t.collections]),[h,f]=g.useState(new Map),[x,j]=g.useState(!1),[y,_]=g.useState(""),[b,v]=g.useState(!1),S=m.length<=Wf,k=S||x||!!y||b,$=g.useMemo(()=>k?m:m.slice(0,Ls),[m,k]);g.useEffect(()=>{if(!n||$.length===0)return;const G=$.filter(ae=>!h.has(ae));if(G.length===0)return;let ve=!1;return Promise.all(G.map(ae=>n.getItem(ae).then(Se=>{const K=Se??{};return[ae,{id:ae,title:K.title,edition:K.edition,resources:K.resources,publication_info:K.publication_info,current_location:K.current_location,lineage:K.lineage,measure_info:K.measure_info}]}).catch(()=>[ae,{id:ae}]))).then(ae=>{ve||f(Se=>{const K=new Map(Se);for(const[Ce,Pe]of ae)K.set(Ce,Pe);return K})}),()=>{ve=!0}},[n,$,h]);const w=g.useMemo(()=>m.map(G=>h.get(G)??{id:G}),[m,h]),z=m.length>0&&m.every(G=>h.has(G)),B=!!n&&$.some(G=>!h.has(G)),I=S||k,N=g.useMemo(()=>oa(w,t.version_graph,{era:y,scanOnly:b,sort:I?"year":"default"}),[w,t.version_graph,y,b,I]),O=x?N.rows:N.rows.slice(0,Ls),C=N.allRows.filter(G=>G.hasImage).length,T=t.related_works||[],R=T.filter(G=>G.relation==="collected_in"),A=g.useMemo(()=>{const G=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],ve=ae=>{const Se=G.indexOf(ae??"");return Se<0?G.length:Se};return T.filter(ae=>ae.relation!=="collected_in").map((ae,Se)=>({r:ae,i:Se})).sort((ae,Se)=>ve(ae.r.relation)-ve(Se.r.relation)||ae.i-Se.i).map(ae=>ae.r)},[T]),H=g.useMemo(()=>{const G=Ro(t.resources,t.resource_groups);return[...G.mirrors.flatMap(ve=>ve.items.map(ae=>({r:ae,kind:d(ve.label)}))),...G.buckets.flatMap(ve=>ve.items.map(ae=>({r:ae,kind:d(Bf(ve.key,c))})))]},[t.resources,t.resource_groups,d,c]),q=t.indexed_by||[],ne=t.emendated_by||[],L=g.useMemo(()=>{var ee,be,W;const G=[],ve=(be=(ee=t.authors)==null?void 0:ee[0])==null?void 0:be.dynasty;ve&&G.push({label:c("workPage.fact.written"),value:d(ve)});const ae=_t(t,u.unit.juan);if(ae){const re=(W=t.juan_count)==null?void 0:W.description;G.push({label:c("workPage.fact.measure"),value:e.jsxs(e.Fragment,{children:[d(ae),re&&re!==ae?e.jsxs("span",{className:"bim-d-meta",children:["(",d(re),")"]}):null]})})}t.loss_status&&G.push({label:c("workPage.fact.loss"),value:d(Mf(t.loss_status,c))});const Se=N.allRows.filter(re=>re.sortYear!=null),K=Se.length>0?Se.reduce((re,te)=>re.sortYear<=te.sortYear?re:te):null;K!=null&&K.era.era?G.push({label:c("workPage.fact.earliest"),value:d([K.era.era,K.era.reign].filter(Boolean).join(" ")),title:K.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):B&&G.push({label:c("workPage.fact.earliest"),value:e.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),ne.length&&G.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:ne.length})});const Ce=As(t.additional_titles);Ce.length&&G.push({label:c("workPage.fact.alias"),value:Ce.map(d).join("、")});const Pe=As(t.attached_texts);Pe.length&&G.push({label:c("workPage.fact.attached"),value:Pe.map(d).join("、")});const M=(t.additional_works||[]).map(re=>d(re.book_title)+(re.n_juan!=null?` ${re.n_juan}${u.unit.juan}`:""));return M.length&&G.push({label:c("workPage.fact.appendix"),value:M.join("、")}),G},[t,d,c,u,B,N.allRows,ne.length]),P=[{value:t._edition_count??m.length,label:c("workPage.stat.editions")},{value:z?C:0,label:c("workPage.stat.hasImage")},{value:q.length,label:c("workPage.stat.catalogs")}],D=t.classification,pe=D?[D.l1,D.l2,D.l3,D.l4].filter(Boolean).map(G=>d(G)):[],le=t.subtype?u.workSubtype[t.subtype]??d(t.subtype):"",fe=e.jsx(En,{title:d(t.title),byline:e.jsx(lr,{authors:t.authors,onNavigate:o,renderLink:r}),meta:e.jsx(Xe,{items:[...pe,D!=null&&D.source?c("workPage.classifiedBy",{source:d(D.source.split("/")[0])}):"",le]}),description:(J=t.description)!=null&&J.text?e.jsxs(e.Fragment,{children:[e.jsx(St,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}),(he=t.description.sources)!=null&&he.length?e.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:t.description.sources.map(G=>d(cm(G))).filter(Boolean).join(" · ")}):null]}):void 0,stats:P,facts:L,readAction:s,foot:e.jsx(In,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:(ze=t.appendix)==null?void 0:ze.map((G,ve)=>e.jsxs("details",{style:{marginTop:12},children:[e.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:d(G.title)}),e.jsx(St,{text:G.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},ve))}),ue=N.eras.length>=2?[{key:"",label:c("catalog.all")},...N.eras.map(G=>({key:G,label:`${G} ${N.allRows.filter(ve=>ve.era.era===G).length}`}))]:[],xe=[];m.length&&xe.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),q.length&&xe.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:q.length}),R.length&&xe.push({id:"collected",label:c("workPage.sec.collected"),count:R.length}),A.length&&xe.push({id:"related",label:c("workPage.sec.related"),count:A.length}),H.length&&xe.push({id:"resources",label:c("workPage.sec.resources"),count:H.length});const Ee=m.length===0&&q.length===0,ie=e.jsxs(e.Fragment,{children:[m.length>0&&e.jsxs(Je,{id:"versions",title:c("workPage.sec.versions"),meta:e.jsx(Xe,{items:[c("workPage.versionsTotal",{n:m.length}),z&&C?c("workPage.versionsWithImage",{n:C}):"",N.rows.length!==N.allRows.length?c("workPage.versionsCurrent",{n:N.rows.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":B&&ue.length===0&&m.length>1?"":void 0,children:[ue.length>0&&e.jsx(ui,{items:ue,value:y,onChange:G=>{_(G),j(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx(pa,{label:c("workPage.scanOnly"),checked:b,onChange:G=>{v(G),j(!1)}}),e.jsx("span",{className:"bim-d-meta",children:c(I?"workPage.sortByYear":"workPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&mi(N.rows.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:c("workPage.col.edition")}),e.jsx("th",{children:c("workPage.col.era")}),e.jsx("th",{children:c("workPage.col.holder")}),e.jsx("th",{children:e.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),e.jsx("tbody",{children:O.map(G=>{var ve;return e.jsx(Of,{row:G,measure:(ve=h.get(G.id))==null?void 0:ve.measure_info,loaded:h.has(G.id),onNavigate:o,renderLink:r},`${G.id}:${h.has(G.id)?"r":"p"}`)})})]}),O.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&e.jsx(Po,{total:N.rows.length,shown:O.length,unit:c("workPage.moreUnit"),onClick:()=>j(!0)}),N.hasInferredEra&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),q.length>0&&e.jsx(Hf,{items:q,transport:n,onNavigate:o,renderLink:r}),Ee&&e.jsx(Je,{title:c("workPage.sec.versions"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Ae=(G,ve)=>e.jsx(Ye,{id:G,label:d(ve),onNavigate:o,renderLink:r,dense:!0}),He=g.useMemo(()=>{const G=new Map;for(const ve of A){const ae=Rs(ve.relation,c);G.set(ae,(G.get(ae)??0)+1)}return G.size>1?[...G.entries()].sort((ve,ae)=>ae[1]-ve[1]).slice(0,4).map(([ve,ae])=>`${d(ve)} ${ae}`).join(" · "):void 0},[A,d,c]),Y=e.jsxs(e.Fragment,{children:[e.jsx(Ot,{id:"collected",title:c("workPage.sec.collected"),items:R.map(G=>Ae(G.id,G.title))}),e.jsx(Ot,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:A.length}),sub:He,items:A.map(G=>e.jsxs(e.Fragment,{children:[Ae(G.id,G.title),e.jsx("span",{className:"bim-d-meta",title:G.note?d(G.note):void 0,children:d(Rs(G.relation,c))})]}))}),e.jsx(Ot,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:H.map(({r:G,kind:ve})=>{const ae=d((G.url?ln(G.url):void 0)||G.name),Se=an(G);return e.jsxs(e.Fragment,{children:[Se?e.jsxs("a",{href:Se,target:"_blank",rel:"noopener noreferrer",children:[ae," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]}):e.jsx("span",{children:ae}),ve&&e.jsx("span",{className:"bim-d-meta bim-d-kind",children:ve})]})})})]});return e.jsx(Nn,{railTop:l,back:a,nav:xe,railLinks:p,main:ie,card:fe,side:Y})};function As(t){return(t||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Ps(t,n){return n((t.url?ln(t.url):void 0)||t.name)}function Of({row:t,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:l,convert:a}=Z(),p=[t.era.era,t.era.reign].filter(Boolean).join(" "),c=t.era.source==="edition",d=t.holders[0],u=d?Ps(d,a):t.locationName?a(t.locationName):"",m=t.images[0],h=m?an(m):void 0,f=t.images.map(x=>Ps(x,a)).join("、");return e.jsxs("tr",{"data-loading":o?void 0:"",children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ye,{id:t.id,label:a(t.name),onNavigate:r,renderLink:s,dense:!0}),n?e.jsx("span",{className:"bim-d-meta",children:a(n)}):e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${p?"":" bim-d-zt-blank"}`,title:c?l("workPage.inferredFromEdition"):void 0,children:p?a(p):o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),e.jsxs("td",{className:`bim-d-zt-sub${u?"":" bim-d-zt-blank"}`,children:[u||(o?e.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),t.holders.length>1&&e.jsxs("span",{className:"bim-d-meta",children:[" +",t.holders.length-1]})]}),e.jsx("td",{className:t.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:t.hasImage&&(h?e.jsx("a",{className:"bim-d-flag",href:h,target:"_blank",rel:"noopener noreferrer",title:f,children:l("workPage.hasImage")}):e.jsx("span",{className:"bim-d-flag",title:f,children:l("workPage.hasImage")}))})]})}function Hf({items:t,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:l}=Z(),[a,p]=g.useState(0),c=Math.min(a,t.length-1),d=t[c],[u,m]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const h=[...new Set(t.map(x=>x.source_bid).filter(x=>!!x))];if(h.length===0)return;let f=!1;return Promise.all(h.map(x=>n.getItem(x).then(j=>{var y,_;return[x,((_=(y=j==null?void 0:j.authors)==null?void 0:y[0])==null?void 0:_.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||m(new Map(x.filter(([,j])=>j)))}),()=>{f=!0}},[n,t]),e.jsx(Je,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:e.jsx(Xe,{items:[s("workPage.catalog.meta",{n:t.length}),s("workPage.sortByCatalog")]}),children:e.jsxs("div",{className:"bim-d-lu",children:[e.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":s("workPage.catalog.tablist"),children:t.map((h,f)=>e.jsx("li",{role:"presentation",children:e.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":l(h.source),onClick:()=>p(f),children:[e.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(h.source_bid??"")?l(u.get(h.source_bid??"")):" "}),e.jsx("i",{className:"bim-d-tl2-dot","aria-hidden":"true"}),e.jsx("span",{className:"bim-d-tl2-name","aria-hidden":"true",children:[...l(h.source)].slice(0,9).map((x,j)=>e.jsx("span",{children:x},j))})]})},f))}),e.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[d.title_info&&e.jsx("div",{className:"bim-d-lu-title",children:l(d.title_info)}),e.jsx(Xe,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[d.source_bid?e.jsx(Ye,{id:d.source_bid,label:l(d.source),onNavigate:o,renderLink:r,dense:!0}):l(d.source),d.section?l(d.section):"",d.author_info?`${s("label.authorInfo")} ${l(d.author_info)}`:"",d.edition?`${s("label.edition")} ${l(d.edition)}`:"",d.page??""]}),d.summary&&e.jsx("p",{className:"bim-d-quote",children:pt(l(d.summary),void 0,{t:s})}),d.comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.comment")}),e.jsx("p",{className:"bim-d-quote",children:pt(l(d.comment),void 0,{t:s})})]}),d.additional_comment&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:s("section.additionalComment")}),e.jsx("p",{className:"bim-d-quote",children:pt(l(d.additional_comment),void 0,{t:s})})]}),!d.summary&&!d.comment&&!d.additional_comment&&!d.title_info&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:s("workPage.catalog.titleOnly")}),t.length>1&&e.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.prev",{name:l(t[c-1].source)}),onClick:()=>p(c-1),children:e.jsxs("span",{"aria-hidden":"true",children:["← ",l(t[c-1].source)]})}):e.jsx("span",{"aria-hidden":"true"}),e.jsxs("span",{className:"bim-d-meta",children:[c+1," / ",t.length]}),c<t.length-1?e.jsx("button",{type:"button","aria-label":s("workPage.catalog.next",{name:l(t[c+1].source)}),onClick:()=>p(c+1),children:e.jsxs("span",{"aria-hidden":"true",children:[l(t[c+1].source)," →"]})}):e.jsx("span",{"aria-hidden":"true"})]})]})]})})}function Ff(t){var n;return{id:t.id,kind:"hypothetical",label:t.label,year:t.year??((n=t.year_range)==null?void 0:n[0]),year_range:t.year_range,year_uncertain:t.year_uncertain,group:t.group,note:t.note,description:t.description}}function Df(t,n){if(!t.lineage)return null;const o=t.lineage;return{id:t.id,kind:"book",label:t.title,year:o.year,year_text:o.year_text,year_uncertain:o.year_uncertain,category:o.category,status:o.status,extant_juan:o.extant_juan,group:n[t.id],note:o.note}}function Ms(t,n,o){return{id:`derive:${n.ref}->${t}:${o}`,source:n.ref,target:t,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Uf(t,n,o){const[r,s]=[t,n.book_id].sort();return{id:`sibling:${r}-${s}:${o}`,source:r,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Vf(t,n){var d;if(n==="all")return null;const o=(d=t.collections)==null?void 0:d[n],r=Array.isArray(o==null?void 0:o.groups)&&o.groups.length>0,s=Array.isArray(o==null?void 0:o.book_ids)&&o.book_ids.length>0,l=r||s||!!(o!=null&&o.hypothetical_ids);if(!l&&n==="core"&&Array.isArray(t.core_books)&&t.core_books.length>0)return{books:new Set(t.core_books),hypos:t.core_hypotheticals?new Set(t.core_hypotheticals):null};if(!o||!l)return null;const a=r?new Set(o.groups):null,p=new Set(o.book_ids??[]);if(a&&t.node_groups)for(const[u,m]of Object.entries(t.node_groups))a.has(m)&&p.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),a){c||(c=new Set);for(const u of t.hypothetical_nodes??[])u.group&&a.has(u.group)&&c.add(u.id)}return{books:p,hypos:c}}function Yn(t,n,o){const r=t.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const l=new Set(r.excluded_books??[]),a=r.node_groups??{},p=Vf(r,o??r.default_collection??"all"),c=p!==null,d=(p==null?void 0:p.books)??null,u=(p==null?void 0:p.hypos)??null,m=new Set,h=new Set;if(c){const S=new Map(n.map(I=>[I.id,I])),k=new Map((r.hypothetical_nodes??[]).map(I=>[I.id,I])),$=I=>{const N=S.get(I);if(N&&N.lineage)return(N.lineage.derived_from??[]).map(C=>C.ref);const O=k.get(I);return O?(O.derived_from??[]).map(C=>C.ref):[]},w=I=>k.has(I)?!u||u.has(I):!d||d.has(I),z=new Set,B=I=>{if(!z.has(I)){z.add(I);for(const N of $(I))l.has(N)||(w(N)||(k.has(N)?h.add(N):S.has(N)&&m.add(N)),B(N))}};for(const I of n)d&&d.has(I.id)&&!l.has(I.id)&&B(I.id);for(const I of r.hypothetical_nodes??[])u&&u.has(I.id)&&B(I.id)}const f=n.filter(S=>!l.has(S.id)).filter(S=>!d||d.has(S.id)||m.has(S.id)).map(S=>{const k=Df(S,a);return k&&m.has(S.id)&&(k.bridge=!0),k}).filter(S=>S!==null),x=(r.hypothetical_nodes??[]).filter(S=>!u||u.has(S.id)||h.has(S.id)).map(S=>{const k=Ff(S);return h.has(S.id)&&(k.bridge=!0),k}),j=[...f,...x],y=new Set(j.map(S=>S.id)),_=new Set,b=[],v=S=>{_.has(S.id)||!y.has(S.source)||!y.has(S.target)||(_.add(S.id),b.push(S))};for(const S of n)l.has(S.id)||!S.lineage||d&&!d.has(S.id)&&!m.has(S.id)||((S.lineage.derived_from??[]).forEach((k,$)=>{v(Ms(S.id,k,$))}),(S.lineage.related_to??[]).forEach((k,$)=>{v(Uf(S.id,k,$))}));for(const S of r.hypothetical_nodes??[])u&&!u.has(S.id)&&!h.has(S.id)||(S.derived_from??[]).forEach((k,$)=>{v(Ms(S.id,k,$))});return{nodes:j,edges:b,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(l)}}function pc(t,n,o){const r=(t??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function Gf(t,n){const o=[],r=t.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),l=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),a=new Set([...s,...l]),p=(c,d)=>{a.has(d.ref)||o.push(`${c}: derived_from.ref "${d.ref}" 未在 books 或 hypothetical_nodes 中找到`),d.ref_type==="book"&&!s.has(d.ref)&&o.push(`${c}: derived_from.ref "${d.ref}" 标记为 book 但不在 books 列表中`),d.ref_type==="hypothetical"&&!l.has(d.ref)&&o.push(`${c}: derived_from.ref "${d.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const d=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(u=>p(d,u)),(c.lineage.related_to??[]).forEach(u=>{s.has(u.book_id)||o.push(`${d}: related_to.book_id "${u.book_id}" 不在 books 列表中`)})}for(const c of r.hypothetical_nodes??[]){const d=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(u=>p(d,u))}return o}const uc=({graph:t,renderLink:n,className:o,style:r})=>{const{t:s,convert:l}=Z();if(!t.nodes.length)return e.jsx("div",{style:{...sx,...r},className:o,children:s("lineage.emptyGraph")});const a=new Map,p=new Map;for(const f of t.edges)if(f.kind==="derive"){const x=a.get(f.target)??[];x.push(f),a.set(f.target,x)}else for(const x of[f.source,f.target]){const j=p.get(x)??[];j.push(f),p.set(x,j)}const c=new Map(t.nodes.map(f=>[f.id,f])),d=new Map,u=[];for(const f of t.nodes)if(f.group){const x=d.get(f.group)??[];x.push(f),d.set(f.group,x)}else u.push(f);const m=(f,x)=>(f.year??9999)-(x.year??9999);d.forEach(f=>f.sort(m)),u.sort(m);const h=t.groups.filter(f=>d.has(f.id));return e.jsxs("div",{className:o,style:{...Kf,...r},children:[t.title&&e.jsx("div",{style:qf,children:l(t.title)}),t.description&&e.jsx("div",{style:Xf,children:l(t.description)}),h.map(f=>e.jsx(Bs,{label:f.label,color:f.color,nodes:d.get(f.id),incomingMap:a,siblingMap:p,nodeMap:c,renderLink:n},f.id)),u.length>0&&e.jsx(Bs,{label:s("lineage.otherGroup"),nodes:u,incomingMap:a,siblingMap:p,nodeMap:c,renderLink:n})]})},Bs=({label:t,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:l,renderLink:a})=>{const{convert:p}=Z();return e.jsxs("div",{style:Zf,children:[e.jsx("div",{style:{...Jf,borderLeftColor:n??i("widget-border")},children:p(t)}),o.map(c=>e.jsx(Yf,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:l,renderLink:a},c.id))]})},Yf=({node:t,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const l=t.kind==="hypothetical",a=t.bridge,{t:p,convert:c}=Z();return e.jsxs("div",{style:{...Qf,borderStyle:l||a?"dashed":"solid",opacity:a?.55:t.status==="lost"?.7:1,background:a?i("bg-subtle"):void 0},title:a?p("lineage.bridgeTitle"):void 0,children:[e.jsxs("div",{style:ex,children:[e.jsx("span",{style:tx,children:l||!s?c(t.label):s(t.id,c(t.label))}),(t.year_text||t.year!=null)&&e.jsx("span",{style:nx,children:pc(c(t.year_text),t.year,t.year_uncertain)})]}),e.jsxs("div",{style:ix,children:[t.category&&e.jsx(jn,{children:c(t.category)}),t.status==="lost"&&e.jsx(jn,{tone:"warn",children:p("lineage.lost")}),t.status==="fragment"&&e.jsx(jn,{tone:"warn",children:p("lineage.fragment")}),l&&e.jsx(jn,{tone:"info",children:p("lineage.hypothetical")}),a&&e.jsx(jn,{tone:"info",children:p("lineage.bridge")})]}),t.extant_juan&&e.jsx("div",{style:ox,children:p("lineage.extant",{juan:c(t.extant_juan)})}),t.note&&e.jsx("div",{style:rx,children:c(t.note)}),n.length>0&&e.jsxs("div",{style:Os,children:[e.jsx("div",{style:Hs,children:p("lineage.sources")}),n.map(d=>{const u=r.get(d.source);return e.jsxs("div",{style:Fs(d.confidence),children:[e.jsx("span",{style:Ds,children:c(d.relation)}),e.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,c(u.label)):c((u==null?void 0:u.label)??d.source)}),d.confidence!=="consensus"&&d.confidence!=="certain"&&e.jsx(Ws,{level:d.confidence}),d.evidence&&e.jsxs("span",{style:Us,children:["· ",c(d.evidence)]})]},d.id)})]}),o.length>0&&e.jsxs("div",{style:Os,children:[e.jsx("div",{style:Hs,children:p("lineage.related")}),o.map(d=>{const u=d.source===t.id?d.target:d.source,m=r.get(u);return e.jsxs("div",{style:Fs(d.confidence),children:[e.jsx("span",{style:Ds,children:c(d.relation)}),e.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)}),e.jsx(Ws,{level:d.confidence}),d.evidence&&e.jsxs("span",{style:Us,children:["· ",c(d.evidence)]})]},d.id)})]})]})},jn=({children:t,tone:n="default"})=>{const r={default:{bg:i("tag-bg"),fg:i("fg")},warn:{bg:i("warn-bg"),fg:i("warn-fg")},info:{bg:i("info-bg"),fg:i("info-fg")}}[n];return e.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:t})},Ws=({level:t})=>{const{t:n}=Z(),r={certain:{key:"certain",color:i("confidence-certain")},consensus:{key:"consensus",color:i("confidence-consensus")},probable:{key:"probable",color:i("confidence-probable")},disputed:{key:"disputed",color:i("confidence-disputed")}}[t];return r?e.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${r.color}`,color:r.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${r.key}`)}):null},Kf={fontSize:"14px",color:i("fg")},qf={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Xf={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},Zf={marginBottom:"16px"},Jf={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},Qf={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},ex={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},tx={fontSize:"15px",fontWeight:600},nx={fontSize:"12px",color:i("muted")},ix={marginBottom:"6px"},ox={fontSize:"12px",color:i("muted"),margin:"2px 0"},rx={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},Os={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},Hs={fontSize:"11px",color:i("muted"),marginBottom:"2px"},Fs=t=>({fontSize:"12px",margin:"2px 0",opacity:t==="probable"||t==="disputed"?.85:1}),Ds={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},Us={fontSize:"11px",color:i("muted")},sx={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},mc=({selectedNodeId:t,...n})=>{const{t:o}=Z(),[r,s]=g.useState("loading"),[l,a]=g.useState(null);return g.useEffect(()=>{let p=!1;return lx().then(c=>{p||(c?(a(c),s("ready")):s("missing"))}),()=>{p=!0}},[]),r==="loading"?e.jsx("div",{style:Gs,children:o("lineage.graphLoading")}):r==="missing"||!l?e.jsxs("div",{style:Gs,children:[e.jsx("div",{children:Vs(o("lineage.graphMissing"),{xyflow:e.jsx("code",{children:"@xyflow/react"}),dagre:e.jsx("code",{children:"@dagrejs/dagre"})})}),e.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:Vs(o("lineage.graphMissingHint"),{list:e.jsx("code",{children:"VersionLineageList"})})})]}):e.jsx(ax,{modules:l,selectedNodeId:t,...n})};function Vs(t,n){return t.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return e.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function lx(){try{const[t,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let o=!1;try{await import("@xyflow/react/dist/style.css"),o=!0}catch{o=!1}return{ReactFlow:t.ReactFlow,Background:t.Background,Controls:t.Controls,Handle:t.Handle,Position:t.Position,BaseEdge:t.BaseEdge,EdgeLabelRenderer:t.EdgeLabelRenderer,getSmoothStepPath:t.getSmoothStepPath,dagre:n,cssLoaded:o}}catch{return null}}const ax=({graph:t,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:l,modules:a})=>{const{ReactFlow:p,Background:c,Controls:d,Handle:u,Position:m,BaseEdge:h,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:j}=a,y=g.useMemo(()=>({lineage:$=>{var A,H,q,ne;const w=((A=$.data)==null?void 0:A.stepPosition)??.85,[z,B,I]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:w,borderRadius:5}),N=!!((H=$.data)!=null&&H.isSibling),O=N?B:$.targetX-18,C=N?I:$.targetY-12,T=(q=$.data)==null?void 0:q.labelStyle,R=(ne=$.data)==null?void 0:ne.labelBgStyle;return e.jsxs(e.Fragment,{children:[e.jsx(h,{id:$.id,path:z,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&e.jsx(f,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${O}px,${C}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...R,...T},children:$.label})})]})}}),[h,f,x]),_=g.useMemo(()=>({version:$=>{const{t:w}=Z(),z=$.data,B=z.kind==="hypothetical",I=z.status==="lost",N=z.isSelected,O=z.bridge,C=z.borderColor??i("muted"),T=O||B?"dashed":"solid",R=O?.5:I?.6:1;return e.jsxs("div",{style:{background:i(O?"bg-subtle":"bg"),border:`2px ${T} ${N?i("primary"):C}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:R,boxShadow:N?i("shadow-node-selected"):B||O?"none":i("shadow-node")},title:O?w("lineage.bridgeTitle"):void 0,children:[e.jsx(u,{type:"target",position:m.Left,style:{visibility:"hidden"}}),e.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:B||!z.renderLink?z.label:z.renderLink(z.bookId,z.label)}),z.description&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:z.description}),z.yearText&&e.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:pc(z.yearText,void 0,z.uncertain)}),I&&e.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:w("lineage.lost")}),e.jsx(u,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[u,m]),{convert:b}=Z(),{rfNodes:v,rfEdges:S}=g.useMemo(()=>cx(t,j,n,l,b),[t,j,n,l,b]);return e.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:e.jsxs(p,{nodes:v,edges:S,nodeTypes:_,edgeTypes:y,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.2,maxZoom:1.8,children:[e.jsx(c,{gap:16}),e.jsx(d,{showInteractive:!1})]})})};function cx(t,n,o,r,s=l=>l??""){const p=t.layout==="LR"||!t.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:p?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const d=new Map(t.groups.map(_=>[_.id,_.color??i("muted")]));for(const _ of t.nodes)c.setNode(_.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const _ of t.edges)_.kind==="derive"&&(u.has(_.relation)||c.setEdge(_.source,_.target));n.layout(c);const m=t.nodes.map(_=>{const b=c.node(_.id),v=r?_.id===r:void 0,S={kind:_.kind,label:s(_.label),bookId:_.kind==="book"?_.id:void 0,yearText:s(_.year_text??px(_)),uncertain:_.year_uncertain,category:_.category,status:_.status,borderColor:_.group?d.get(_.group):void 0,renderLink:o,isSelected:v,description:s(_.description),bridge:_.bridge};return{id:_.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:S,draggable:!1,selected:v}}),h=.78,f=.06,x=new Map;for(const _ of t.edges)_.kind==="derive"&&(x.has(_.source)||x.set(_.source,[]),x.get(_.source).push(_));const j=new Map;for(const[_,b]of x){if(b.length<=1)continue;const v=[...b].sort((k,$)=>{var B,I;const w=((B=c.node(k.target))==null?void 0:B.y)??0,z=((I=c.node($.target))==null?void 0:I.y)??0;return w-z}),S=v.length;v.forEach((k,$)=>{const w=($-(S-1)/2)*f;j.set(k.id,h+w)})}const y=t.edges.map(_=>dx(_,j.get(_.id),s));return{rfNodes:m,rfEdges:y}}function dx(t,n,o=r=>r??""){const r=t.confidence==="probable"||t.confidence==="disputed",s=t.kind==="sibling",l=ux(t.confidence),a={type:"arrowclosed",color:l,width:14,height:14};return{id:t.id,source:t.source,target:t.target,type:"lineage",label:o(t.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:l,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:a,markerStart:s?a:void 0,zIndex:1e3}}function px(t){if(t.year_range)return`~${t.year_range[0]}–${t.year_range[1]}`;if(typeof t.year=="number")return String(t.year)}function ux(t){switch(t){case"certain":return i("confidence-certain");case"consensus":return i("lineage-edge-consensus");case"probable":return i("confidence-probable");case"disputed":return i("confidence-disputed");default:return i("muted")}}const Gs={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},cr=({graph:t,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:l,collection:a,onCollectionChange:p,collectionsAvailable:c,collectionCounts:d,className:u,style:m})=>{var S;const{t:h,convert:f}=Z(),[x,j]=g.useState(n),y=k=>{j(k),l==null||l(k)},_=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:h("lineage.collectionAll"),description:h("lineage.collectionAllDesc")}]]})(),b=!!(p&&_.length>0);if(!t.nodes.length)return e.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:h("lineage.empty")});const v=a?(S=c==null?void 0:c[a])==null?void 0:S.description:void 0;return e.jsxs("div",{className:u,style:m,children:[e.jsxs("div",{style:mx,children:[e.jsx("button",{onClick:()=>y("list"),style:Oi(x==="list"),children:h("lineage.modeList")}),e.jsx("button",{onClick:()=>y("graph"),style:Oi(x==="graph"),children:h("lineage.modeGraph")}),b&&e.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:12,color:i("muted"),marginRight:4},children:h("lineage.collectionLabel")}),_.map(([k,$])=>{const w=d==null?void 0:d[k];return e.jsxs("button",{onClick:()=>p==null?void 0:p(k),style:Oi(a===k),title:$.description?f($.description):void 0,children:[f($.label),w!=null?` ${w}`:""]},k)})]})]}),b&&v&&e.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:f(v)}),x==="list"?e.jsx(uc,{graph:t,renderLink:o}):e.jsx(mc,{graph:t,renderLink:o,height:r,selectedNodeId:s})]})},mx={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Oi=t=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:t?i("primary"):"transparent",color:i(t?"primary-fg":"fg"),cursor:"pointer"}),Ys=40,Ks=2,hx=9,gx=new Set(["certain","consensus","probable","disputed"]);function Hi(t){if(!t)return["",""];const n=t.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",t]}const hc=({data:t,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:l,fullTextPending:a,chapterLink:p,railTop:c,back:d,railLinks:u})=>{var W,re,te,me,Ne,Me,Be,Fe,Ze,de,Qe;const m=$e(),{t:h,convert:f}=Z(),[x,j]=g.useState(null),[y,_]=g.useState(new Map),[b,v]=g.useState([]),[S,k]=g.useState(new Map),[$,w]=g.useState(!1),[z,B]=g.useState("flow"),[I,N]=g.useState(null);g.useEffect(()=>{if(!n||!t.work_id){j(null);return}let E=!1;return n.getItem(t.work_id).then(oe=>{!E&&oe&&oe.type==="work"&&j(oe)}).catch(()=>{}),()=>{E=!0}},[n,t.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!t.work_id){N(null);return}let E=!1;return n.getLineageGraph(t.work_id).then(oe=>{E||N(oe&&oe.nodes.length>1?oe:null)}).catch(()=>{E||N(null)}),()=>{E=!0}},[n,t.work_id]),g.useEffect(()=>{const E=t.contained_in||[];if(!n||E.length===0){_(new Map);return}let oe=!1;return Promise.all(E.map(se=>{const je=typeof se=="string"?se:se.id;return n.getItem(je).then(ke=>[je,ke]).catch(()=>[je,null])})).then(se=>{if(oe)return;const je=new Map;for(const[ke,ge]of se)ge&&je.set(ke,ge);_(je)}),()=>{oe=!0}},[n,t.contained_in]);const O=g.useMemo(()=>{const E=new Set([...(x==null?void 0:x.books)||[],...t.related_books||[]]);return E.add(t.id),[...E]},[x==null?void 0:x.books,t.related_books,t.id]),C=O.length-1;g.useEffect(()=>{if(!n||C<=0){v([]);return}const E=O.length<=Ys,oe=E?O:O.slice(0,8);let se=!1;return Promise.all(oe.map(je=>je===t.id?Promise.resolve({id:je,title:t.title,edition:t.edition,year:Xn(t)}):n.getItem(je).then(ke=>{const ge=ke??{};return{id:je,title:ge.title,edition:ge.edition,year:ke?Xn(ge):void 0}}).catch(()=>({id:je})))).then(je=>{if(se)return;const ke=je.filter(ge=>ge.id===t.id||ge.title||ge.edition);E&&ke.sort((ge,V)=>(ge.year??1/0)-(V.year??1/0)),v(ke)}),()=>{se=!0}},[n,O,C,t]);const T=t.lineage,R=g.useMemo(()=>[...((T==null?void 0:T.derived_from)||[]).filter(E=>E.ref_type==="book").map(E=>E.ref),...((T==null?void 0:T.related_to)||[]).map(E=>E.book_id)].filter(Boolean),[T]);g.useEffect(()=>{if(!n||R.length===0){k(new Map);return}let E=!1;return Promise.all(R.map(oe=>n.getItem(oe).then(se=>[oe,{id:oe,title:se==null?void 0:se.title,edition:se==null?void 0:se.edition}]).catch(()=>[oe,{id:oe}]))).then(oe=>{E||k(new Map(oe))}),()=>{E=!0}},[n,R]);const A=g.useMemo(()=>lc(t.resources,t.resource_groups,h),[t.resources,t.resource_groups,h]),H=A.groups.reduce((E,oe)=>E+oe.rows.length+oe.mirrors.length,0),q=A.groups.length>0&&A.groups.every(E=>E.key==="_physical"),ne=Tn(t),L=ca(t),Q=_t(t,m.unit.juan),P=new Set((t.contained_in||[]).map(E=>typeof E=="string"?0:_n(E.volume_index).length).filter(E=>E>0)),D=E=>{var je;const oe=(je=t.base_edition)==null?void 0:je.find(ke=>ke.book_id===E&&ke.name);if(oe!=null&&oe.name)return oe.name;const se=S.get(E);return(se==null?void 0:se.edition)||(se==null?void 0:se.title)||""},pe=g.useMemo(()=>{var Te,Ie,U,X,Le;const E=[];L&&E.push({label:h("bookPage.fact.editionType"),value:f(L),title:t.edition_type||(Te=t.lineage)!=null&&Te.category?void 0:h("bookPage.inferredFromEdition")}),(Ie=t.publication_info)!=null&&Ie.details?E.push({label:h("bookPage.fact.publication"),value:f(t.publication_info.details)}):(ne.era||ne.reign)&&E.push({label:h("bookPage.fact.era"),value:f([ne.era,ne.reign].filter(Boolean).join(" ")),title:ne.source==="edition"?h("bookPage.inferredFromEdition"):void 0}),Q&&E.push({label:h("bookPage.fact.measure"),value:f(Q)});const oe=(t.contained_in||[]).flatMap(_e=>typeof _e=="string"?[]:_n(_e.volume_index));oe.length&&E.push({label:h("bookPage.fact.volumes"),value:h("bookPage.volumesValue",{range:pi(oe,m.unit.volume),unit:m.unit.volume,n:oe.length})});const se=(((U=t.lineage)==null?void 0:U.derived_from)||[]).find(_e=>_e.relation==="底本"&&_e.ref_type==="book");se&&D(se.ref)&&E.push({label:h("bookPage.fact.baseEdition"),value:e.jsx(Ye,{id:se.ref,label:f(D(se.ref)),onNavigate:o,renderLink:r,dense:!0})});const je=(t.base_edition||[]).filter(_e=>_e&&_e.name);for(const _e of["底本","配補","參校"]){if(_e==="底本"&&se&&D(se.ref))continue;const De=je.filter(We=>We.role===_e);De.length&&E.push({label:f(_e),value:De.map((We,ot)=>e.jsxs(g.Fragment,{children:[ot>0&&"、",We.book_id?e.jsx(Ye,{id:We.book_id,label:f(We.name),onNavigate:o,renderLink:r,dense:!0}):f(We.name)]},ot))})}const ke=(t.provenance||[]).filter(_e=>_e&&_e.institution),ge=(t.resources||[]).filter(_e=>(_e.types||(_e.type?[_e.type]:[])).includes("physical"));if(ke.length){E.push({label:h("bookPage.fact.holdings"),value:ke.slice(0,2).map(We=>f(We.institution)).join("、")+(ke.length>2?h("bookPage.andMorePlaces",{n:ke.length}):"")});const _e=ke.filter(We=>We.call_number).slice(0,2).map(We=>`${f(We.institution)} ${We.call_number}`);_e.length&&E.push({label:h("bookPage.fact.callNumber"),value:_e.join(";")+(ke.filter(We=>We.call_number).length>2?"…":"")});const De=ke.flatMap(We=>We.seals||[]).filter(Boolean);De.length&&E.push({label:h("bookPage.fact.seals"),value:f(De.join("、"))})}else ge.length?E.push({label:h("bookPage.fact.holdings"),value:ge.slice(0,2).map(_e=>f(_e.name)).join("、")+(ge.length>2?h("bookPage.andMorePlaces",{n:ge.length}):"")}):(X=t.current_location)!=null&&X.name&&E.push({label:h("bookPage.fact.holdings"),value:f(t.current_location.name)});const V=t.physical_description;if(V){const _e=[[h("bookPage.fact.leafStyle"),V.leaf_style],[h("bookPage.fact.binding"),V.binding],[h("bookPage.fact.dimensions"),V.dimensions],[h("bookPage.fact.condition"),V.condition]];for(const[De,We]of _e)We&&We.trim()&&E.push({label:De,value:f(We)})}(Le=t.page_count)!=null&&Le.description&&E.push({label:m.label.pageCount,value:f(t.page_count.description)});const ce=[...oo(t.additional_titles),...oo(t.attached_texts)];return ce.length&&E.push({label:h("bookPage.fact.aliases"),value:ce.map(f).join("、")}),E},[t,f,m,h,ne,L,Q,S,o,r]),le=f(t.title),fe=t.edition?f(t.edition):void 0,ue=((W=t.lineage)==null?void 0:W.year_text)||"",xe=e.jsx(En,{kind:h("bookPage.kind"),title:le,subtitle:fe,byline:e.jsx(lr,{authors:t.authors??(x==null?void 0:x.authors),onNavigate:o,renderLink:r}),meta:(()=>{const E=[L?f(L):"",ne.era?f([ne.era,ne.reign].filter(Boolean).join("")):"",Q?f(Q):""].filter(Boolean);return E.length?e.jsx("span",{className:"bim-d-tags",children:E.map((oe,se)=>e.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(se,2)}`,children:oe},se))}):null})(),description:(re=t.description)!=null&&re.text?e.jsx(St,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Bo((te=t.description)==null?void 0:te.text)?6:void 0,facts:pe,readAction:s,secondaryAction:s&&H>0&&!q?e.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:h("bookPage.viewImages")}):void 0,foot:e.jsx(In,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo})}),Ee=t.contained_in||[],ie=(l==null?void 0:l.chapters)||[],Ae=f(ie[0]&&Hi(ie[0].title)[0].slice(-1)||"")||h("bookPage.chapterUnit"),He=h("bookPage.chapterCount",{n:ie.length,unit:Ae}),Y=!!((me=T==null?void 0:T.derived_from)!=null&&me.length||(Ne=T==null?void 0:T.related_to)!=null&&Ne.length||(Me=t.appendix)!=null&&Me.length),J=[],he=h(q?"bookPage.sec.physical":"bookPage.sec.images");(ie.length||A.text.length||a)&&J.push({id:"fulltext",label:h("bookPage.sec.fulltext"),count:ie.length?He:void 0}),A.groups.length&&J.push({id:"images",label:he,count:H}),Y&&J.push({id:"lineage",label:h("bookPage.sec.lineage")}),Ee.length&&J.push({id:"collections",label:h("section.containedIn"),count:Ee.length}),(Be=t.location_history)!=null&&Be.length&&J.push({id:"provenance",label:h("section.locationHistory")});const ze=E=>(p==null?void 0:p(E))??null,G=ie[0],ve=G?ze(G.file):null,ae=$?ie:ie.slice(0,hx),Se=(E,oe,se)=>E?e.jsx("a",{className:se,href:E.href??"#",onClick:E.onClick?je=>{je.metaKey||je.ctrlKey||(je.preventDefault(),E.onClick())}:void 0,children:oe}):e.jsx("span",{className:se,children:oe}),K=e.jsxs(e.Fragment,{children:[(ie.length>0||A.text.length>0||a)&&e.jsxs(Je,{id:"fulltext",title:h("bookPage.sec.fulltext"),meta:ie.length>0?e.jsx(Xe,{items:[He,(Fe=l==null?void 0:l.source)!=null&&Fe.name?h("bookPage.sourceBy",{src:f(`${l.source.name}${l.source.license?` ${l.source.license}`:""}`)}):""]}):void 0,children:[a&&!G&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[e.jsx("span",{className:"bim-d-ft-h",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "})]}),e.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),G&&e.jsxs("div",{className:"bim-d-ft",children:[e.jsx("h3",{className:"bim-d-ft-h",children:h("bookPage.readFrom",{ch:f(Hi(G.title)[0])||h("bookPage.firstChapter")})}),e.jsx("span",{className:"bim-d-meta",children:f((G.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),Se(ve,e.jsxs(e.Fragment,{children:[h("bookPage.enterReader")," ",e.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ie.length>1&&e.jsx("ul",{className:"bim-d-chap",children:ae.map(E=>{const[oe,se]=Hi(E.title);return e.jsx("li",{children:Se(ze(E.file),e.jsxs(e.Fragment,{children:[oe&&e.jsx("b",{children:f(oe)}),f(se||E.file)]}))},E.file)})}),ie.length>ae.length&&e.jsx(Mo,{label:h("detail.expandRest",{n:ie.length-ae.length,unit:Ae}),onClick:()=>w(!0)}),A.text.length>0&&e.jsxs(e.Fragment,{children:[(ie.length>0||a)&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:h("bookPage.externalText")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:A.text.map((E,oe)=>e.jsx(ar,{item:E,siblings:A.text,listedVolumeCounts:P},`${E.id||E.url||E.name}-${oe}`))})})]})]}),A.groups.length>0&&e.jsx(Je,{id:"images",title:he,meta:e.jsx(Xe,{items:[A.groups.length>1?h("bookPage.groupCount",{n:A.groups.length}):"",h("bookPage.placeCount",{n:H})]}),children:e.jsx(cc,{groups:A.groups,listedVolumeCounts:P})}),Y&&e.jsx(Je,{id:"lineage",title:h("bookPage.sec.lineage"),meta:(Ze=T==null?void 0:T.derived_from)!=null&&Ze.length?h("bookPage.lineageMeta"):void 0,action:I?e.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":h("bookPage.lineageView"),children:[e.jsx("button",{type:"button","aria-pressed":z==="flow",onClick:()=>B("flow"),children:h("bookPage.viewCards")}),e.jsx("button",{type:"button","aria-pressed":z==="graph",onClick:()=>B("graph"),children:h("bookPage.viewGraph")})]}):void 0,children:z==="graph"&&I?e.jsx(cr,{graph:I,defaultMode:"graph",selectedNodeId:t.id,graphHeight:480,renderLink:(E,oe)=>e.jsx(Ye,{id:E,label:f(oe),onNavigate:o,renderLink:r,dense:!0})}):e.jsx(xx,{data:t,heading:fe||le,yearText:ue,refName:D,onNavigate:o,renderLink:r})}),Ee.length>0&&e.jsx(Je,{id:"collections",title:h("section.containedIn"),children:e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:Ee.map((E,oe)=>{var V,ce;const se=typeof E=="string"?E:E.id,je=typeof E=="string"?[]:_n(E.volume_index),ke=y.get(se),ge=(ke==null?void 0:ke._member_count)||((V=ke==null?void 0:ke.books)==null?void 0:V.length)||((ce=ke==null?void 0:ke.contained_works)==null?void 0:ce.length)||0;return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ye,{id:se,label:ke?f(ke.title):se,onNavigate:o,renderLink:r,dense:!0}),je.length>0&&e.jsx(fx,{volumes:je,unit:m.unit.volume})]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ge?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ge>0&&h("bookPage.totalOf",{n:ge,unit:m.unit.bu})})]},`${se}-${oe}`)})})})}),(de=t.location_history)!=null&&de.length?e.jsx(Je,{id:"provenance",title:h("section.locationHistory"),children:e.jsx("ul",{className:"bim-d-tl",children:t.location_history.map((E,oe)=>e.jsxs("li",{children:[e.jsx("span",{className:"bim-d-tl-t",children:f(E.name)}),([E.start_date,E.end_date].filter(Boolean).join("—")||E.description)&&e.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:e.jsx(Xe,{items:[[E.start_date,E.end_date].filter(Boolean).join("—"),E.description?f(E.description):""]})})]},oe))})}):null,J.length===0&&e.jsx(Je,{title:h("bookPage.sec.empty"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:h("bookPage.emptyText")})})]}),Ce=b.findIndex(E=>E.id===t.id),Pe=O.length<=Ys,M=Pe&&Ce>=0?b.slice(Math.max(0,Ce-Ks),Ce+Ks+1):b.filter(E=>E.id!==t.id),ee=e.jsxs(e.Fragment,{children:[x&&e.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[e.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(m.section.belongsToWork)}),e.jsx("div",{style:{fontSize:17,fontWeight:500},children:e.jsx(Ye,{id:x.id,label:f(x.title),onNavigate:o,renderLink:r})}),e.jsx(Xe,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(E=>`${E.dynasty?`〔${f(E.dynasty)}〕`:""}${f(E.name)}`),f(_t(x,m.unit.juan)),x._edition_count?h("bookPage.editionCount",{n:x._edition_count}):""]}),((Qe=x.description)==null?void 0:Qe.text)&&e.jsx("p",{style:{margin:"8px 0 0",fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),C>0&&M.length>0&&e.jsxs("div",{children:[e.jsx(Ot,{id:"siblings",timeline:!0,title:Pe?h("bookPage.siblings"):m.relation.siblingVersions,meta:Pe?h("bookPage.byEra"):h("bookPage.kindCount",{n:C}),cap:M.length,items:M.map(E=>E.id===t.id?e.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(E.edition||E.title||E.id)}):e.jsx(Ye,{id:E.id,label:f(E.edition||E.title||E.id),onNavigate:o,renderLink:r,dense:!0})),metas:M.map(E=>[E.year!=null?E.year<0?h("detail.bce",{n:-E.year}):String(E.year):"",E.id===t.id?h("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:M.findIndex(E=>E.id===t.id)}),x&&e.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:e.jsx(Ye,{id:x.id,label:h("bookPage.viewAllInWork",{n:O.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),be=t.work_id?e.jsx(da,{caption:m.section.belongsToWork,children:e.jsx(Ye,{id:t.work_id,label:x?f(x.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return e.jsx(Nn,{railTop:c,back:d,up:be,nav:J,railLinks:u,main:K,card:xe,side:ee})};function fx({volumes:t,unit:n}){const{t:o}=Z();return e.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:pi(t,n),unit:n}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bim-d-dot"}),o("bookPage.volumeCount",{n:t.length,unit:n})]})]})}function xx({data:t,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:l}){var _;const{t:a,convert:p}=Z(),c=t.lineage,d=(c==null?void 0:c.derived_from)||[],u=d.filter(b=>b.ref_type!=="book"),m=d.filter(b=>b.ref_type==="book"&&b.relation==="底本"),h=d.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),f=(c==null?void 0:c.related_to)||[],x=d.length>0||f.length>0,j=b=>b&&gx.has(b)?a("bookPage.confidenceNote",{c:a(`bookPage.confidence.${b}`)}):"",y=(b,v)=>e.jsx(Ye,{id:b,label:p(v||b),onNavigate:s,renderLink:l,dense:!0});return e.jsxs("div",{className:"bim-d-lf",children:[x&&e.jsxs("ol",{className:"bim-d-lf-list",children:[u.map((b,v)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:b.relation?p(b.relation):a("bookPage.lineage.ancestor")}),e.jsx("span",{className:"bim-d-lf-name",children:a("bookPage.lineage.reconstructed")}),b.evidence&&e.jsxs("span",{className:"bim-d-meta",children:[p(b.evidence),j(b.confidence)]})]})},`a-${v}`)),m.map((b,v)=>e.jsx("li",{className:"bim-d-lf-node",children:e.jsxs("div",{className:"bim-d-lf-card",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:p(b.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[p(b.evidence),j(b.confidence)]})]})},`b-${v}`)),e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[e.jsxs("div",{className:"bim-d-lf-here",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:a("bookPage.lineage.thisEdition")}),e.jsx("span",{className:"bim-d-lf-name",children:n}),o&&e.jsx("span",{className:"bim-d-lf-yr",children:p(o)})]}),h.length>0&&e.jsx("div",{className:"bim-d-lf-side",children:h.map((b,v)=>e.jsxs("div",{className:"bim-d-lf-dash",children:[e.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:p(b.relation)}),e.jsx("span",{className:"bim-d-lf-name",children:y(b.ref,r(b.ref))}),b.evidence&&e.jsxs("p",{className:"bim-d-lf-ev",children:[p(b.evidence),j(b.confidence)]})]},v))})]}),f.length>0&&e.jsxs("li",{className:"bim-d-lf-node bim-d-lf-out",children:[e.jsx("span",{className:"bim-d-lf-out-h bim-d-ui",children:a("bookPage.lineage.derivatives")}),e.jsx("span",{className:"bim-d-lf-chips",children:f.map((b,v)=>e.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?p(b.evidence):void 0,children:[y(b.book_id,r(b.book_id)),e.jsx("span",{className:"bim-d-meta",children:p(b.relation)})]},v))})]})]}),(_=t.appendix)==null?void 0:_.map((b,v)=>e.jsxs("details",{className:"bim-d-lf-app",children:[e.jsxs("summary",{className:"bim-d-ui",children:[e.jsx("span",{className:"bim-d-meta",children:a("bookPage.lineage.appendix")})," ",p(b.title)]}),e.jsx(St,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${v}`)),(c==null?void 0:c.note)&&e.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:p(c.note)})]})}const vn=16,bx=200,yx=16,gc=({data:t,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:l,railTop:a,back:p,railLinks:c})=>{var Se,K,Ce,Pe,M,ee,be;const{t:d,convert:u,messages:m}=Z(),[h,f]=g.useState(""),[x,j]=g.useState(!1),[y,_]=g.useState(null),[b,v]=g.useState(""),[S,k]=g.useState(!1),$=g.useMemo(()=>la(t,n),[t,n]),[w,z]=g.useState(new Map),B=!!o&&$.rows.length>0&&$.rows.length<=bx,I=B&&($.rows.length<=vn||S),N=I&&$.rows.every(W=>!W.id||w.has(W.id)),O=W=>{var re;return mo(W?(re=w.get(W))==null?void 0:re.l1:void 0)},C=g.useMemo(()=>{const W=h.trim(),re=W?u(W):"";return $.rows.filter(te=>{var Ne,Me;if(b&&mo(te.id?(Ne=w.get(te.id))==null?void 0:Ne.l1:void 0)!==b)return!1;if(!re)return!0;const me=te.id&&((Me=w.get(te.id))==null?void 0:Me.title)||te.title;return u(me).includes(re)||(te.subItems||[]).some(Be=>u(Be).includes(re))})},[$.rows,h,b,w,u]),T=x?C:C.slice(0,vn),R=g.useMemo(()=>(I?$.rows:T).filter(W=>W.id&&!w.has(W.id)).map(W=>W.id),[I,$.rows,T,w]);g.useEffect(()=>{if(!o||R.length===0)return;let W=!1;const re=R.slice(0,yx);return Promise.all(re.map(te=>o.getItem(te).then(me=>{var Be,Fe;const Ne=me??{},Me={title:Ne.title,edition:Ne.edition,authors:Ne.authors,measure:me?_t(me,m.unit.juan):void 0,versionCount:Ne._edition_count??((Be=Ne.books)==null?void 0:Be.length),l1:((Fe=Ne.classification)==null?void 0:Fe.l1)||void 0};return[te,Me]}).catch(()=>[te,{}]))).then(te=>{W||z(me=>{const Ne=new Map(me);for(const[Me,Be]of te)Ne.set(Me,Be);return Ne})}),()=>{W=!0}},[o,R,m.unit.juan]);const A=(t.contained_in||[])[0];g.useEffect(()=>{if(!A){_(null);return}if(_({id:A}),!o)return;let W=!1;return o.getItem(A).then(re=>{W||_({id:A,title:re==null?void 0:re.title})}).catch(()=>{}),()=>{W=!0}},[o,A]);const H=g.useMemo(()=>lc(t.resources,t.resource_groups,d),[t.resources,t.resource_groups,d]),q=H.text.length+H.groups.reduce((W,re)=>W+re.rows.length+re.mirrors.length,0),ne=t.contained_works||[],L=new Set($.rows.map(W=>W.id).filter(Boolean)),Q=ne.length>0&&!ne.every(W=>L.has(W.id)),P=(()=>{const W=$.rows.map(re=>re.edition).filter(Boolean);return W.length>1&&new Set(W).size===1})(),D=$.rows.some(W=>W.volumes.length>0||W.expected!=null),pe=t._member_count||((Se=t.books)==null?void 0:Se.length)||ne.length,le=_t(t,m.unit.juan),fe=t.count,ue=W=>typeof W=="number"&&Number.isFinite(W)?W:null,xe=ue(fe==null?void 0:fe.juan)??ue((K=t.juan_count)==null?void 0:K.number),Ee=ue(fe==null?void 0:fe.ce)??($.totalVolumes||null),ie=[{value:$.rows.length,label:d("collectionPage.stat.titles")},{value:xe??0,label:m.unit.juan},{value:Ee??0,label:m.unit.volume}],Ae=g.useMemo(()=>{var te,me;const W=[];if((te=t.publication_info)!=null&&te.details&&W.push({label:d("collectionPage.fact.publication"),value:u(t.publication_info.details)}),pe&&pe!==$.rows.length){const Ne=t._member_type==="Book"?d("collectionPage.member.Book"):t._member_type==="Work"?d("collectionPage.member.Work"):d("collectionPage.member.other");W.push({label:Ne,value:`${pe} ${m.unit.bu}`,title:d("collectionPage.memberNote")})}const re=[ue(fe==null?void 0:fe.zhong)!=null?d("collectionPage.nZhong",{n:fe.zhong}):"",ue(fe==null?void 0:fe.han)!=null?d("collectionPage.nHan",{n:fe.han}):""].filter(Boolean);return re.length&&W.push({label:d("collectionPage.fact.expected"),value:re.join(" ")}),xe==null&&le&&W.push({label:d("collectionPage.fact.measure"),value:u(le),title:(me=t.juan_count)!=null&&me.description?u(t.juan_count.description):void 0}),W},[t,pe,$.rows.length,xe,le,fe,u,d,m]),He=g.useMemo(()=>{if(!N)return[];const W=new Map;for(const te of $.rows){const me=O(te.id);me&&W.set(me,(W.get(me)??0)+1)}const re=Cn.filter(te=>(W.get(te.key)??0)>0);return re.length<2?[]:[{key:"",label:`${m.catalog.all} ${$.rows.length}`},...re.map(te=>({key:te.key,label:`${te.label} ${W.get(te.key)}`}))]},[N,$.rows,w,m]),Y=g.useMemo(()=>{if(!N||!$.rows.some(me=>me.volumes.length>0))return null;const W=[],re=$.rows.filter(me=>me.volumes.length>0).map(me=>({k:O(me.id)??"",from:Math.min(...me.volumes),to:Math.max(...me.volumes)})).sort((me,Ne)=>me.from-Ne.from);for(const me of re){const Ne=me.to-me.from+1,Me=W[W.length-1];Me&&Me.key===me.k?(Me.to=Math.max(Me.to,me.to),Me.n+=Ne):W.push({key:me.k,from:me.from,to:me.to,n:Ne})}const te=re.reduce((me,Ne)=>Math.max(me,Ne.to),0);return W.length>1&&W.some(me=>me.key)?{segs:W,last:te}:null},[N,$.rows,w]),J=(Ce=t.description)==null?void 0:Ce.text,he=e.jsx(En,{kind:d("collectionPage.kind"),title:u(t.title),byline:e.jsx(lr,{authors:t.authors,onNavigate:r,renderLink:s}),meta:e.jsx(Xe,{items:[t.subtype==="work_collection"?d("collectionPage.workCollection"):"",(Pe=t.publication_info)!=null&&Pe.year?u(t.publication_info.year):""]}),description:J||(M=t.history)!=null&&M.length?e.jsxs(e.Fragment,{children:[J&&e.jsx(St,{text:J,style:{fontSize:15,lineHeight:1.85}}),(ee=t.history)!=null&&ee.length?e.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:t.history.map((W,re)=>e.jsx("li",{children:u(W)},re))}):null]}):void 0,clampDescription:Bo(J)||(((be=t.history)==null?void 0:be.length)??0)>2?6:void 0,stats:ie,facts:Ae,foot:e.jsx(In,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:Y&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:d("collectionPage.dist.head")})}),e.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":d("collectionPage.dist.head"),children:Y.segs.map((W,re)=>{const te=Cn.find(me=>me.key===W.key);return e.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!te,title:te?d("collectionPage.dist.segTitle",{section:u(te.label),from:W.from,to:W.to}):void 0,"aria-label":te?d("collectionPage.dist.only",{section:u(te.label)}):d("collectionPage.dist.unclassified"),"aria-pressed":!!te&&b===W.key,style:{flexGrow:W.n,background:i(te?te.token:"rule")},onClick:()=>{te&&(v(b===W.key?"":W.key),j(!1))}},re)})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:d("catalog.volume",{n:1})}),e.jsx("span",{children:d("collectionPage.dist.hint")}),e.jsx("span",{children:d("catalog.volume",{n:Y.last})})]})]})}),ze=[];$.rows.length&&ze.push({id:"titles",label:d("collectionPage.sec.titles"),count:$.rows.length}),q&&ze.push({id:"resources",label:d("collectionPage.sec.resources"),count:q}),Q&&ze.push({id:"works",label:m.section.containedWorks,count:ne.length});const G=e.jsxs(e.Fragment,{children:[$.rows.length>0&&e.jsxs(Je,{id:"titles",title:d("collectionPage.sec.titles"),meta:e.jsx(Xe,{items:[`${$.rows.length} ${m.unit.items}`,$.totalVolumes?d("collectionPage.totalVolumes",{n:$.totalVolumes,unit:m.unit.volume}):"",C.length!==$.rows.length?d("collectionPage.currentN",{n:C.length,unit:m.unit.items}):""]}),action:l,children:[($.rows.length>vn||He.length>0)&&e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[He.length>0&&e.jsx(ui,{items:He,value:b,onChange:W=>{v(W),j(!1)}}),B&&$.rows.length>vn&&!N&&e.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:S,onClick:()=>k(!0),title:d("collectionPage.loadAllTitle",{n:$.rows.length,unit:m.unit.items}),children:d(S?"collectionPage.grouping":"collectionPage.groupBySection")}),e.jsx("span",{className:"bim-d-spacer"}),$.rows.length>vn&&e.jsx("input",{type:"search",className:"bim-d-find",value:h,placeholder:d("collectionPage.find"),"aria-label":d("collectionPage.find"),onChange:W=>{f(W.target.value),j(!1)}})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&mi(C.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[D&&e.jsx("th",{style:{width:"8.5em"},children:d("collectionPage.col.volumes")}),e.jsx("th",{children:d("collectionPage.col.title")}),e.jsx("th",{style:{textAlign:"right"},children:d("collectionPage.col.versions")})]})}),e.jsx("tbody",{children:T.map((W,re)=>{var Ze;const te=W.id?w.get(W.id):void 0,me=te!=null&&te.title&&W.title===W.id?te.title:W.title,Ne=((te==null?void 0:te.authors)||[]).find(de=>de&&de.name),Me=[Ne?`${Ne.dynasty?`〔${u(Ne.dynasty)}〕`:""}${u(Ne.name)}${Ne.role?` ${u(Ne.role)}`:""}`:"",te!=null&&te.measure?u(te.measure):"",(Ze=W.subItems)!=null&&Ze.length?W.subItems.map(de=>u(de)).join("、"):"",(te!=null&&te.edition||W.edition)&&!P?u((te==null?void 0:te.edition)||W.edition||""):""].filter(Boolean),Be=Cn.find(de=>de.key===O(W.id)),Fe=W.volumes.length>0?d("collectionPage.volumeRange",{range:pi(W.volumes,m.unit.volume),unit:m.unit.volume}):W.expected!=null?`${W.found??0}/${W.expected} ${m.unit.volume}`:"";return e.jsxs("tr",{children:[D&&e.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Fe?"":" bim-d-zt-blank"}`,children:[Be&&e.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(Be.token)}}),Fe||e.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),e.jsxs("td",{className:"bim-d-zt-main",children:[W.id?e.jsx(Ye,{id:W.id,label:u(me),onNavigate:r,renderLink:s,dense:!0}):e.jsx("span",{className:"bim-d-zt-name",children:u(me)}),Me.length>0?e.jsx(Xe,{items:Me}):W.id&&!te&&o?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${te!=null&&te.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:te!=null&&te.versionCount?d("collectionPage.nZhong",{n:te.versionCount}):""})]},`${W.id??W.title}-${re}`)})})]}),T.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d("catalog.noMatch")}),!x&&e.jsx(Po,{total:C.length,shown:T.length,unit:m.unit.items,onClick:()=>j(!0)})]}),q>0&&e.jsxs(Je,{id:"resources",title:d("collectionPage.sec.resources"),meta:d("collectionPage.resourcesCount",{n:q}),children:[H.text.length>0&&e.jsxs("div",{className:"bim-d-rg",children:[H.groups.length>0&&e.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:d("collectionPage.text")}),e.jsx("table",{className:"bim-d-zt",children:e.jsx("tbody",{children:H.text.map((W,re)=>e.jsx(ar,{item:W,siblings:H.text},`${W.id||W.url||W.name}-${re}`))})})]}),e.jsx(cc,{groups:H.groups})]}),$.rows.length===0&&q===0&&e.jsx(Je,{title:d("collectionPage.sec.titles"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("collectionPage.empty")})})]}),ve=Q?e.jsx(Ot,{id:"works",title:m.section.containedWorks,meta:d("collectionPage.nZhong",{n:ne.length}),cap:12,items:ne.map(W=>e.jsx(Ye,{id:W.id,label:u(W.title),onNavigate:r,renderLink:s,dense:!0}))}):null,ae=y?e.jsx(da,{caption:d("collectionPage.parent"),children:e.jsx(Ye,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return e.jsx(Nn,{railTop:a,back:p,up:ae,nav:ze,railLinks:c,main:G,card:he,side:ve})},jx=16,Fi=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function qs(t){if(!t)return Fi.length;const n=Fi.indexOf(t);return n===-1?Fi.length:n}function vx(t,n){return t==null?"":t<0?n("entityPage.bce",{n:-t}):String(t)}const kx={秦:[-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]},fc=({data:t,transport:n,onNavigate:o,renderLink:r,railTop:s,back:l,railLinks:a})=>{var ae,Se,K,Ce,Pe;const{t:p,convert:c,messages:d}=Z(),u=M=>vx(M,p),[m,h]=g.useState("全部"),[f,x]=g.useState(!1),[j,y]=g.useState("default"),[_,b]=g.useState(new Map),v=g.useMemo(()=>(t.works||[]).map(M=>{const ee=_.get(M.work_id);return{id:M.work_id,title:(ee==null?void 0:ee.title)??M.title??M.work_id,role:M.role||"",cls:Lo(M.role),versionCount:ee==null?void 0:ee.versionCount,section:ee==null?void 0:ee.cls,l1:ee==null?void 0:ee.l1,measure:ee==null?void 0:ee.measure,hasImage:ee==null?void 0:ee.hasImage,loaded:!!(ee!=null&&ee.loaded)}}),[t.works,_]),S=g.useMemo(()=>sa((t.works||[]).map(M=>M.role),p("detail.roleAll")),[t.works,p]),k=g.useMemo(()=>{const M=m==="全部"?v:v.filter(ee=>ee.cls===m);return j==="versions"?[...M].sort((ee,be)=>(be.versionCount??-1)-(ee.versionCount??-1)):M},[v,m,j]),$=f?k:k.slice(0,jx),w=g.useMemo(()=>$.filter(M=>!_.has(M.id)).map(M=>M.id),[$,_]);g.useEffect(()=>{if(!n||w.length===0)return;let M=!1;return Promise.all(w.map(ee=>n.getItem(ee).then(be=>{var me,Ne,Me,Be,Fe;const W=be??{},re=W._edition_count??(((me=W.books)==null?void 0:me.length)??0)+(((Ne=W.collections)==null?void 0:Ne.length)??0),te=[(Me=W.classification)==null?void 0:Me.l1,(Be=W.classification)==null?void 0:Be.l2].filter(Boolean).join(" ");return[ee,{id:ee,title:W.title,versionCount:re,loaded:!0,cls:te||void 0,l1:((Fe=W.classification)==null?void 0:Fe.l1)||void 0,measure:be&&_t(be,d.unit.juan)||void 0,hasImage:!!(W.has_image??W._has_image)}]}).catch(()=>[ee,{id:ee,loaded:!0}]))).then(ee=>{M||b(be=>{const W=new Map(be);for(const[re,te]of ee)W.set(re,te);return W})}),()=>{M=!0}},[n,w,d.unit.juan]);const z=g.useMemo(()=>{const M=new Map;for(const ee of t.alt_names||[]){const be=ee.type||d.section.aliases;M.has(be)||M.set(be,[]),M.get(be).push(ee.name)}return[...M.entries()].sort((ee,be)=>qs(ee[0])-qs(be[0])).map(([ee,be])=>({label:ee,names:be}))},[t.alt_names,d]),B=t.birth_year??((ae=t.dates)==null?void 0:ae.birth)??void 0,I=t.death_year??((Se=t.dates)==null?void 0:Se.death)??void 0,N=(K=t.dates)==null?void 0:K.floruit,O=B!=null||I!=null?`${u(B)||"?"}—${u(I)||"?"}`:Array.isArray(N)&&N.length===2&&N.every(M=>Number.isFinite(M))?p("entityPage.floruit",{from:u(N[0]),to:u(N[1])}):"",C=new Set(["本名","字","號","号"]),T=z.filter(M=>C.has(M.label)),R=z.filter(M=>!C.has(M.label)),A=R.reduce((M,ee)=>M+ee.names.length,0),H=g.useMemo(()=>{const M=[];for(const be of T)M.push({label:be.label,value:be.names.map(W=>c(W)).join("、")});const ee=(t.works||[]).length;return ee&&M.push({label:p("entityPage.fact.works"),value:p("entityPage.nZhong",{n:ee})}),M},[t.works,T,c,p]),q=M=>{var ee;return(ee=z.find(be=>M.includes(be.label)))==null?void 0:ee.names[0]},ne=q(["字"]),L=q(["號","号"]),Q=[ne?p("entityPage.zi",{name:c(ne)}):"",L?p("entityPage.hao",{name:c(L)}):""].filter(Boolean).join(","),P=t.native_place,D=t.dynasty?kx[t.dynasty]:void 0,pe=(()=>{if(!D||B==null||I==null||I<B)return null;const[M,ee]=D,be=Math.max(B,M),W=Math.min(I,ee);if(W<=be)return null;const re=ee-M;return e.jsxs("div",{className:"bim-d-life bim-d-ui",children:[e.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":p("entityPage.lifeAria",{birth:u(B),death:u(I),years:I-B+1}),children:e.jsx("i",{style:{left:`${(be-M)/re*100}%`,width:`${(W-be)/re*100}%`}})}),e.jsxs("div",{className:"bim-d-life-lab",children:[e.jsx("span",{children:`${u(M)} ${c(t.dynasty)}`}),e.jsx("span",{children:p("entityPage.lifeYears",{years:I-B+1})}),e.jsx("span",{children:u(ee)})]})]})})(),le=g.useMemo(()=>{if(!n||v.length===0||v.some(be=>!be.loaded))return null;const M=new Map;for(const be of v){const W=mo(be.l1);W&&M.set(W,(M.get(W)??0)+1)}const ee=Cn.map(be=>({...be,n:M.get(be.key)??0})).filter(be=>be.n>0);return ee.length?ee:null},[v,n]),fe=e.jsxs(En,{kind:d.entityPage.subtype[t.subtype]??p("entityPage.subtype.people"),title:c(t.primary_name||t.title),subtitle:Q||void 0,meta:e.jsxs(e.Fragment,{children:[e.jsx(Xe,{items:[t.dynasty?c(t.dynasty):"",O,P?p("entityPage.nativePlace",{place:c(P)}):""]}),pe]}),description:(Ce=t.description)!=null&&Ce.text?e.jsx(St,{text:t.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Bo((Pe=t.description)==null?void 0:Pe.text)?6:void 0,facts:H,foot:e.jsx(In,{revision:t.revision,revisedAt:t.revised_at,review:t.review,todo:t.todo}),children:[A>0&&e.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[e.jsx("summary",{children:p("entityPage.moreNames",{n:A})}),e.jsx("dl",{children:R.map(M=>e.jsxs(g.Fragment,{children:[e.jsx("dt",{children:c(M.label)}),e.jsx("dd",{children:M.names.map(ee=>c(ee)).join("、")})]},M.label))})]}),le&&e.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[e.jsx("div",{className:"bim-d-dist-head",children:e.jsx("span",{children:p("entityPage.dist")})}),e.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:le.map(M=>e.jsx("i",{style:{flexGrow:M.n,background:i(M.token)}},M.key))}),e.jsx("div",{className:"bim-d-dist-key",children:le.map(M=>e.jsxs("span",{children:[e.jsx("i",{style:{background:i(M.token)}}),c(M.label)," ",M.n]},M.key))})]})]}),ue=g.useMemo(()=>v.filter(M=>M.loaded&&(M.versionCount??0)>0).sort((M,ee)=>(ee.versionCount??0)-(M.versionCount??0)).slice(0,3),[v]),xe=!!n&&v.length>=3&&$.some(M=>!M.loaded),Ee=m==="全部"&&(xe||ue.length>=2),ie=t.external_ids||{},Ae=[];ie.cbdb_id!=null&&Ae.push({label:"CBDB",id:String(ie.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ie.cbdb_id}`,note:ie.cbdb_match==="auto"?p("entityPage.autoMatch"):void 0});const He=ie.wikidata_id;He&&Ae.push({label:"Wikidata",id:He,href:`https://www.wikidata.org/wiki/${He}`});const Y=ie.viaf_id;Y&&Ae.push({label:"VIAF",id:Y,href:`https://viaf.org/viaf/${Y}`});const J=S.map(M=>({key:M.cls,label:`${M.label} ${M.count}`})),he=[...Ee&&!xe?[{id:"featured",label:p("entityPage.sec.featured"),count:ue.length}]:[],...v.length?[{id:"works",label:p("entityPage.sec.allWorks"),count:v.length}]:[],...Ae.length?[{id:"external",label:p("entityPage.sec.external"),count:Ae.length}]:[]],ze=Ee?e.jsxs(Je,{id:"featured",title:p("entityPage.sec.featured"),children:[e.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:p("entityPage.featuredSub")}),e.jsxs("div",{className:"bim-d-picks","aria-busy":xe||void 0,children:[xe&&[0,1,2].map(M=>e.jsxs("div",{className:"bim-d-pick","aria-hidden":"true",children:[e.jsx("span",{className:"bim-d-pick-t",children:" "}),e.jsx("span",{className:"bim-d-meta",children:" "}),e.jsx("div",{className:"bim-d-pick-n",children:" "})]},M)),!xe&&ue.map(M=>e.jsxs("div",{className:"bim-d-pick",children:[e.jsx("span",{className:"bim-d-pick-t",children:e.jsx(Ye,{id:M.id,label:c(M.title),onNavigate:o,renderLink:r,dense:!0})}),e.jsx(Xe,{items:[M.section?c(M.section):"",M.measure?c(M.measure):""]}),e.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[e.jsx("span",{className:"bim-d-pick-num",children:M.versionCount}),e.jsx("span",{children:p("entityPage.versionsUnit")}),M.hasImage&&e.jsx("span",{className:"bim-d-flag",children:p("entityPage.hasImage")})]})]},M.id))]})]}):null,G=v.length===0?e.jsx(Je,{title:p("entityPage.sec.works"),children:e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("entityPage.empty")})}):e.jsxs(e.Fragment,{children:[ze,e.jsxs(Je,{id:"works",title:p("entityPage.sec.works"),meta:e.jsx(Xe,{items:[p("entityPage.total",{n:v.length}),k.length!==v.length?p("entityPage.current",{n:k.length}):""]}),children:[e.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[J.length>1&&e.jsx(ui,{items:J,value:m,onChange:M=>{h(M),x(!1)}}),e.jsx("span",{className:"bim-d-spacer"}),e.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":j==="versions",onClick:()=>{j==="default"&&x(!0),y(M=>M==="default"?"versions":"default")},children:p(j==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),e.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&mi(k.length)?"":void 0,children:[e.jsx("thead",{className:"bim-d-ui",children:e.jsxs("tr",{children:[e.jsx("th",{children:p("entityPage.col.work")}),e.jsx("th",{children:p("entityPage.col.section")}),e.jsx("th",{children:p("entityPage.col.role")}),e.jsx("th",{children:p("entityPage.col.versions")}),e.jsx("th",{"aria-label":p("entityPage.col.image")})]})}),e.jsx("tbody",{children:$.map(M=>e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-d-zt-main",children:[e.jsx(Ye,{id:M.id,label:c(M.title),onNavigate:o,renderLink:r,dense:!0}),M.measure?e.jsx(Xe,{items:[c(M.measure)]}):!M.loaded&&n?e.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.section||M.loaded?"":" bim-d-zt-blank"}`,children:M.section?c(M.section):null}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.role?"":" bim-d-zt-blank"}`,children:M.role?c(M.role):e.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),e.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.loaded?"":" bim-d-zt-blank"}`,children:M.loaded?M.versionCount?p("entityPage.nZhong",{n:M.versionCount}):e.jsx("span",{className:"bim-d-zt-empty",children:p("entityPage.notRecorded")}):""}),e.jsx("td",{className:M.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:M.hasImage&&e.jsx("span",{className:"bim-d-flag bim-d-ui",children:p("entityPage.hasImage")})})]},M.id))})]}),$.length===0&&e.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("entityPage.emptyRole")}),!f&&e.jsx(Po,{total:k.length,shown:$.length,unit:p("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),ve=Ae.length>0?e.jsx(Ot,{id:"external",title:p("entityPage.sec.external"),items:Ae.map(M=>e.jsxs("a",{href:M.href,target:"_blank",rel:"noopener noreferrer",children:[M.label," ",e.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Ae.map(M=>M.id),foot:ie.cbdb_id!=null&&ie.cbdb_match==="auto"?p("entityPage.cbdbAuto"):void 0}):null;return e.jsx(Nn,{railTop:s,back:l,nav:he,railLinks:a,main:G,card:fe,side:ve})},dr="(max-width: 719px)",wx=`${dr}, (pointer: coarse)`,xc=`
|
|
1293
|
+
`,eg=120;function lt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function tg(e,n=eg){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 ng(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 ig(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(o=>{if(!o||typeof o!="object")return"";const r=o,s=lt(r.name);return s?[lt(r.dynasty)&&`〔${lt(r.dynasty)}〕`,s,lt(r.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Ql(e,n){const o=lt(n.type),r=lt(n.primary_name)??lt(n.title)??e,s=o==="entity"?[lt(n.dynasty),ng(n),lt(n.native_place)].filter(Boolean).join(" · "):[ig(n),lt(n.edition),lt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?lt(n.description.text):lt(n.description);return{id:e,type:o,title:r,meta:s||void 0,description:tg(a)}}function ec(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 tc(e){return async n=>{const o=await e.getItem(n);if(o)return Ql(n,o);if(e.getEntry){const r=await e.getEntry(n);if(r)return ec(r)}return null}}const zs=new WeakMap;function og(e,n,o){let r=zs.get(e);r||(r=new Map,zs.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 nc=e=>`/item/${encodeURIComponent(e)}`,rg={work:"書名",person:"人名",place:"地名",office:"官職",dynasty:"朝代",other:"專名"},sg=typeof window>"u"?g.useEffect:g.useLayoutEffect;function dr(e,n){return g.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:tc(e)}:null,[n,e])}const ag=e=>e,lg=({text:e,entities:n,offsets:o="text",plainBase:r=0,transport:s,loadSummary:a,buildHref:l=nc,onNavigate:d,renderText:c=ag,hoverDelayMs:p=250,injectStyles:u=!0,className:h})=>{const m=g.useMemo(()=>{const x=o==="plain"?Zl(e,n,r):n;return Jl(e,x)},[e,n,o,r]),f=dr(s,a);return t.jsxs("span",{className:h?`bim-et-root ${h}`:"bim-et-root",children:[u&&t.jsx("style",{children:cr}),m.map(x=>x.type==="text"?t.jsx(g.Fragment,{children:c(x.text)},`t${x.start}`):t.jsx(pr,{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}`))]})},pr=({span:e,label:n,hasBrackets:o,loader:r,buildHref:s,onNavigate:a,renderText:l,hoverDelayMs:d})=>{const c=g.useId(),[p,u]=g.useState(!1),h=g.useRef(null),m=`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=()=>{h.current&&(clearTimeout(h.current),h.current=null)};g.useEffect(()=>k,[]);const y=g.useCallback(j=>{k(),j<=0?u(!0):h.current=setTimeout(()=>u(!0),j)},[]),_=g.useCallback(()=>{k(),u(!1)},[]);if(!e.targetId)return t.jsx("span",{className:m,children:x});const b=e.targetId;return t.jsxs("span",{className:"bim-et-w",onMouseEnter:()=>y(d),onMouseLeave:_,onKeyDown:j=>{j.key==="Escape"&&p&&(j.stopPropagation(),_())},children:[t.jsx("a",{className:m,href:s(b),"data-entity-id":b,"aria-describedby":p?c:void 0,onFocus:()=>y(0),onBlur:_,onClick:a?j=>a(b,j):void 0,children:x}),p&&t.jsx(cg,{id:c,entityId:b,span:e,loader:r})]})},cg=({id:e,entityId:n,span:o,loader:r})=>{const{convert:s}=J(),a=g.useRef(null),[l,d]=g.useState("start"),[c,p]=g.useState(r?{status:"loading"}:{status:"ready",summary:null});g.useEffect(()=>{if(!r)return;let m=!1;return p({status:"loading"}),og(r.owner,r.load,n).then(f=>{m||p({status:"ready",summary:f})}).catch(()=>{m||p({status:"error"})}),()=>{m=!0}},[r,n]),sg(()=>{const m=a.current;if(!m||typeof window>"u")return;const f=m.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,h=(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(rg[o.kind])}),h&&t.jsx("span",{className:"bim-et-card-t",children:s(h)}),(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("摘要載入失敗")})]})},dg=e=>`/item/${encodeURIComponent(e)}`;function pg(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 ur=({pageData:e,pages:n,punctuations:o=mg,selectedCharIds:r,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:u,convert:h,scrollToPage:m,entities:f,entityTransport:x,loadEntitySummary:k,buildEntityHref:y,onEntityNavigate:_})=>{const b=g.useRef(null),j=g.useRef(0),w=g.useMemo(()=>{const I=new Map;return p&&o.forEach((P,G)=>{const K=P.id?P:{...P,id:`${P.anchor}#${G}`},L=I.get(K.anchor)||[];L.push(K),I.set(K.anchor,L)}),I},[o,p]),v=g.useMemo(()=>(n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}]).map(P=>{const G=[...P.columns].sort((Z,A)=>Z.col-A.col),K=[];let L=[];for(const Z of G)for(const A of Z.chars){const U=(w.get(A.id)||[]).filter(ee=>ee.kind!=="break"),ce=(w.get(A.id)||[]).some(ee=>ee.kind==="break");L.push({charData:A,col:Z.col,afterPuncts:U}),ce&&(K.push({id:`para-p${P.page}-${K.length}`,chars:L}),L=[])}return L.length>0&&K.push({id:`para-p${P.page}-${K.length}`,chars:L}),{page:P.page,paragraphs:K}}),[n,e,w]),$=g.useMemo(()=>{const I=[];for(const P of v)for(const G of P.paragraphs)for(const K of G.chars)I.push(K.charData.id);return I},[v]),S=g.useMemo(()=>{const I=new Map;if(!f||f.length===0)return I;const P=new Map($.map((G,K)=>[G,K]));for(const G of f){if(!G.anchor)continue;const K=P.get(G.anchor.start),L=P.get(G.anchor.end);if(!(K===void 0||L===void 0||L<K))for(let Z=K;Z<=L;Z++)I.has($[Z])||I.set($[Z],G)}return I},[f,$]),C=dr(x,k),B=S.size>0,T=g.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:_});T.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:u,onEntityNavigate:_};const z=g.useMemo(()=>({click:I=>{var P,G;j.current=Date.now()+1200,(G=(P=T.current).onCharClick)==null||G.call(P,I)},enter:I=>{var P,G;return(G=(P=T.current).onCharHover)==null?void 0:G.call(P,I)},leave:()=>{var I,P;return(P=(I=T.current).onCharHover)==null?void 0:P.call(I,null)},navigate:(I,P)=>{var K,L;if(!(P.detail===0||P.ctrlKey||P.metaKey||P.shiftKey)){P.preventDefault();return}(L=(K=T.current).onEntityNavigate)==null||L.call(K,I,P)}}),[]),F=hg(r),N=g.useRef(null);g.useEffect(()=>{var P,G;if((P=N.current)==null||P.classList.remove("is-hovered"),N.current=null,!s)return;const I=(G=b.current)==null?void 0:G.querySelector(`span[data-char-id="${s}"]`);I&&(I.classList.add("is-hovered"),N.current=I)},[s]),g.useEffect(()=>{let I=null;const P=()=>{var ie,Re;I=null;const K=window.getSelection(),L=b.current;if(!K||K.isCollapsed||K.rangeCount===0||!L)return;const Z=K.getRangeAt(0),A=Z.commonAncestorContainer,U=A.nodeType===3?A.parentElement:A;if(!U||!L.contains(U))return;const ce=L.querySelectorAll("span[data-char-id]");let ee=0,ue=ce.length;for(;ee<ue;){const Le=ee+ue>>1;Z.comparePoint(ce[Le],0)<0?ee=Le+1:ue=Le}const de=ee;for(ue=ce.length;ee<ue;){const Le=ee+ue>>1;Z.comparePoint(ce[Le],0)<=0?ee=Le+1:ue=Le}const be=ee-1;if(be<de)return;const Oe=[];for(let Le=de;Le<=be;Le++)Oe.push(ce[Le].getAttribute("data-char-id"));Oe.length>0&&(j.current=Date.now()+1200,(Re=(ie=T.current).onSelectionChange)==null||Re.call(ie,Oe))},G=()=>{I&&clearTimeout(I),I=setTimeout(P,120)};return document.addEventListener("selectionchange",G),()=>{document.removeEventListener("selectionchange",G),I&&clearTimeout(I)}},[]),g.useEffect(()=>{var I;if(r.size===1){const P=Array.from(r)[0],G=(I=b.current)==null?void 0:I.querySelector(`span[data-char-id="${P}"]`);G&&G.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}},[r]);const R=m==null?void 0:m.nonce;g.useEffect(()=>{var P;if(!m)return;const I=(P=b.current)==null?void 0:P.querySelector(`[data-page-section="${m.page}"]`);I&&(j.current=Date.now()+800,I.scrollIntoView({behavior:"auto",block:"start"}))},[R]);const O=!!u;return g.useEffect(()=>{var Z;if(!O)return;const I=Array.from(((Z=b.current)==null?void 0:Z.querySelectorAll("[data-page-section]"))??[]);if(I.length===0)return;const P=120;let G=0;const K=()=>{var ee,ue;if(G=0,Date.now()<j.current)return;let A=0,U=I.length-1;for(;A<U;){const de=A+U+1>>1;I[de].getBoundingClientRect().top<=P?A=de:U=de-1}const ce=parseInt(I[A].getAttribute("data-page-section")||"",10);isNaN(ce)||(ue=(ee=T.current).onVisiblePageChange)==null||ue.call(ee,ce)},L=()=>{G||(G=requestAnimationFrame(K))};return window.addEventListener("scroll",L,{passive:!0}),K(),()=>{window.removeEventListener("scroll",L),G&&cancelAnimationFrame(G)}},[O,v]),t.jsxs("div",{ref:b,className:"guji-text-pane-content",children:[B&&t.jsx("style",{children:cr}),t.jsx("div",{className:"guji-text-reflow-view",children:v.map((I,P)=>t.jsx(fg,{pGroup:I,first:P===0,selected:F.get(I.page)??ug,entityOfChar:S,entityLoader:C,convert:h,buildHref:y??dg,handlers:z},`page-sec-${I.page}`))})]})},ug=new Set,mg=[];function hg(e){const n=g.useRef(new Map);return g.useMemo(()=>{const o=new Map;e.forEach(s=>{const a=parseInt(s.split(":")[0],10);let l=o.get(a);l||o.set(a,l=new Set),l.add(s)});const r=new Map;return o.forEach((s,a)=>{const l=n.current.get(a),d=l&&l.size===s.size&&Array.from(s).every(c=>l.has(c));r.set(a,d?l:s)}),n.current=r,r},[e])}function gg(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 fg=g.memo(function({pGroup:n,first:o,selected:r,entityOfChar:s,entityLoader:a,convert:l,buildHref:d,handlers:c}){const p=g.useMemo(()=>{const h=new Map;if(!l)return h;for(const m of n.paragraphs){const f=gg(m.chars.map(x=>x.charData.char),l);m.chars.forEach((x,k)=>h.set(x.charData.id,f[k]))}return h},[n,l]),u=h=>p.get(h.id)??h.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(h=>t.jsx("p",{className:"guji-reflow-paragraph",children:pg(h.chars,s).map((m,f)=>{const x=m.chars.map(({charData:y,col:_,afterPuncts:b},j)=>{const v=!!m.entity&&j===m.chars.length-1?[]:b;return t.jsxs(g.Fragment,{children:[t.jsx("span",{"data-char-id":y.id,onClick:()=>c.click(y.id),onMouseEnter:()=>c.enter(y.id),onMouseLeave:c.leave,className:`guji-text-char${r.has(y.id)?" is-selected":""}${y.sub?" is-sub":""}`,title:`[第${n.page}葉·第${_}列·第${y.slot||y.pos}字] ${u(y)}`,children:u(y)}),v.map($=>t.jsx("span",{className:"guji-text-punct","data-punct-id":$.id,children:$.mark},$.id))]},y.id)});if(!m.entity)return t.jsx(g.Fragment,{children:x},`r${f}`);const k=m.chars[m.chars.length-1].afterPuncts.map(y=>t.jsx("span",{className:"guji-text-punct","data-punct-id":y.id,children:y.mark},y.id));return t.jsxs(g.Fragment,{children:[t.jsx(pr,{span:m.entity,label:m.chars.map(y=>u(y.charData)).join(""),hasBrackets:!0,loader:a,buildHref:d,onNavigate:c.navigate,renderText:()=>x,hoverDelayMs:250}),k]},`${m.entity.key}@${f}`)})},h.id))]})}),ic=1,oc=6,Kn={s:1,x:0,y:0},Jn=(e,n,o)=>Math.min(o,Math.max(n,e));function mr(e,n,o){const r=Jn(e.s,ic,oc);return{s:r,x:Jn(e.x,n*(1-r),0),y:Jn(e.y,o*(1-r),0)}}function Vi(e,n,o,r,s,a){const l=Jn(e.s*r,ic,oc),d=l/e.s;return mr({s:l,x:n-(n-e.x)*d,y:o-(o-e.y)*d},s,a)}function xg(e,n,o,r,s){return mr({s:e.s,x:e.x+n,y:e.y+o},r,s)}function bg(e,n,o){const r=n===1?e*16:n===2?e*400:e;return Math.exp(-r*(o?.01:.0015))}const Ts=4,yg=g.forwardRef(function({children:n,onScaleChange:o,resetKey:r,style:s},a){const l=g.useRef(null),[d,c]=g.useState(Kn),p=g.useRef(d),u=g.useRef(o);u.current=o;const h=b=>{var w;const j=p.current;p.current=b,c(b),b.s!==j.s&&((w=u.current)==null||w.call(u,b.s))},m=()=>{var j;const b=(j=l.current)==null?void 0:j.getBoundingClientRect();return{w:(b==null?void 0:b.width)??0,h:(b==null?void 0:b.height)??0,left:(b==null?void 0:b.left)??0,top:(b==null?void 0:b.top)??0}};g.useImperativeHandle(a,()=>({zoomBy(b){const{w:j,h:w}=m();h(Vi(p.current,j/2,w/2,b,j,w))},reset(){h(Kn)}})),g.useEffect(()=>{h(Kn)},[r]),g.useEffect(()=>{const b=l.current;if(!b||typeof ResizeObserver>"u")return;const j=new ResizeObserver(()=>{const{w,h:v}=m(),$=mr(p.current,w,v);($.x!==p.current.x||$.y!==p.current.y)&&h($)});return j.observe(b),()=>j.disconnect()},[]),g.useEffect(()=>{const b=l.current;if(!b)return;const j=w=>{const v=bg(w.deltaY,w.deltaMode,w.ctrlKey);if(p.current.s<=1&&v<1)return;w.preventDefault();const{w:$,h:S,left:C,top:B}=m();h(Vi(p.current,w.clientX-C,w.clientY-B,v,$,S))};return b.addEventListener("wheel",j,{passive:!1}),()=>b.removeEventListener("wheel",j)},[]);const f=g.useRef(new Map),x=g.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),k=b=>{if(b.pointerType==="mouse"&&b.button!==0)return;f.current.set(b.pointerId,{x:b.clientX,y:b.clientY});const j=x.current;if(j.swallowClick=!1,f.current.size===1&&(j.moved=0,j.dragging=!1),f.current.size===2){const[w,v]=[...f.current.values()];j.pinchDist=Math.hypot(w.x-v.x,w.y-v.y),j.moved=Ts+1}},y=b=>{var F;const j=f.current.get(b.pointerId);if(!j)return;const w={x:b.clientX,y:b.clientY};f.current.set(b.pointerId,w);const v=x.current,{w:$,h:S,left:C,top:B}=m();if(f.current.size>=2){const[N,R]=[...f.current.values()],O=Math.hypot(N.x-R.x,N.y-R.y);if(v.pinchDist>0&&O>0){const I=(N.x+R.x)/2-C,P=(N.y+R.y)/2-B;h(Vi(p.current,I,P,O/v.pinchDist,$,S))}v.pinchDist=O,v.swallowClick=!0;return}const T=w.x-j.x,z=w.y-j.y;if(v.moved+=Math.abs(T)+Math.abs(z),!(v.moved<=Ts)){if(!v.dragging){v.dragging=!0;try{(F=l.current)==null||F.setPointerCapture(b.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&h(xg(p.current,T,z,$,S))}},_=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:_,onPointerCancel:_,onClickCapture:b=>{x.current.swallowClick&&(x.current.swallowClick=!1,b.stopPropagation(),b.preventDefault())},onDoubleClick:()=>h(Kn),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 rc(e,n,o,r,s){const[a,l]=g.useState(n??null),[d,c]=g.useState(!1),p=g.useRef(0);return g.useEffect(()=>{if(n!==void 0){l(n);return}const u=++p.current;if(!o){l(null),c(!1);return}if(e){let h;try{h=e(o,s)}catch{l(null),c(!1);return}if(!h||typeof h.then!="function"){l(h??null),c(!1);return}c(!0),h.then(m=>{u===p.current&&l(m??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(h=>h.ok?h.json():null).then(h=>{u===p.current&&l(h)}).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 jg(e,n,o){const[r,s]=g.useState([]),a=g.useRef(0);return g.useEffect(()=>{const l=++a.current;if(!e||!n){s([]);return}let d;try{d=e(n,o)}catch{s([]);return}Promise.resolve(d).then(c=>{l===a.current&&s(c?Xl(c):[])}).catch(()=>{l===a.current&&s([])})},[e,n,o]),r}const Ns={padding:24,color:i("desc-fg"),fontSize:14};function Es({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 Is=/^https?:\/\//i;function vg(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&&Is.test(o)?o:void 0,license:n(e.license),license_url:r&&Is.test(r)?r:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function kg(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 wg(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 sc(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 Sg(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,h)=>{const m=a.get(u);return{key:u,label:h??(m?sc(m,o,r,s):u),hint:l(n[u]),disabled:n[u]===0}},c=(p=e.juan_groups)==null?void 0:p.filter(u=>{var h;return u.files.some(m=>a.has(m))||((h=u.children)==null?void 0:h.length)});if(c&&c.length>0){const u=(h,m)=>{var x;if(h.files.length===1&&!((x=h.children)!=null&&x.length))return d(h.files[0],r(h.label));const f=Eh(h,n);return{key:`group:${m}`,label:r(h.label),hint:f==="loading"?"…":typeof f=="number"&&f>0?`${f}`:Kl(h),defaultExpanded:typeof f=="number"&&f>0,children:[...h.files.filter(k=>a.has(k)).map(k=>d(k)),...(h.children??[]).map((k,y)=>u(k,`${m}.${y}`))]}};return c.map((h,m)=>u(h,`${m}`))}return e.chapters.map(u=>d(u.file))}const hr=({id:e,transport:n,versionKey:o,chapter:r,onLocationChange:s,onNavigate:a,title:l,subtitle:d,resolveImages:c,renderImageOverlay:p,imagePanel:u,allowVertical:h,onReportError:m,revisedAt:f,backHref:x,backLabel:k,resolveWarpData:y,warpData:_,resolveEntities:b,onEntityNavigate:j,className:w,style:v})=>{var Rr,Lr,Ar;const{t:$,convert:S}=J(),C=g.useMemo(()=>nl(n),[n]),[B,T]=pl(),z=qe(),F=g.useRef(s);F.current=s;const[N,R]=g.useState(null),[O,I]=g.useState("loading");g.useEffect(()=>{let W=!1;return R(null),I("loading"),C.getManifest(e).then(he=>{W||(he?(R(he),I("ready")):I("missing"))}).catch(()=>{W||I("missing")}),()=>{W=!0}},[C,e]);const P=o!==void 0,G=r!==void 0,[K,L]=g.useState(null),[Z,A]=g.useState(null);g.useEffect(()=>{L(null),A(null)},[e]);const U=we.pickTextVersion(N,P?o:K),ce=((Rr=N==null?void 0:N.versions.find(W=>W.key==="default"))==null?void 0:Rr.key)??((Lr=N==null?void 0:N.versions[0])==null?void 0:Lr.key)??"default",ee=(U==null?void 0:U.key)??null,ue=G?r:Z,de=g.useCallback((W,he,Ae)=>{var De;(De=F.current)==null||De.call(F,{key:W,chapter:he,isDefault:W===ce},Ae)},[ce]);g.useEffect(()=>{!N||!P||o==null||N.versions.some(W=>W.key===o)||de(ce,null,"auto")},[N,P,o,ce,de]);const be=g.useRef(new Map);g.useEffect(()=>{be.current.clear()},[C,e]);const Oe=g.useCallback(async W=>{const he=`${e}
|
|
1294
|
+
${W}`;if(be.current.has(he))return be.current.get(he)??null;const Ae=await C.getIndex(e,W).catch(()=>null);return Ae&&be.current.set(he,Ae),Ae},[C,e]),[ie,Re]=g.useState(null),[Le,q]=g.useState("loading");g.useEffect(()=>{if(!ee)return;let W=!1;return Re(null),q("loading"),Oe(ee).then(he=>{W||(he&&he.chapters.length>0?(Re(he),q("ready")):q("failed"))}),()=>{W=!0}},[ee,Oe]),g.useEffect(()=>{if(!ie||!ee||ue!=null&&ie.chapters.some(Ae=>Ae.file===ue))return;const he=ie.chapters[0].file;G||A(he),de(ee,he,"auto")},[ie,ee,ue,G,de]);const Q=ie?ue!=null&&ie.chapters.some(W=>W.file===ue)?ue:ie.chapters[0].file:ue,fe=g.useMemo(()=>ie&&Q?ie.chapters.find(W=>W.file===Q)??null:null,[ie,Q]),ze=g.useRef(0),Y=g.useCallback(async W=>{if(!N||W===ee||!N.versions.some(Zt=>Zt.key===W))return;const he=++ze.current,Ae=await Oe(W);if(he!==ze.current)return;const De=fe??(Q?{file:Q}:null),st=we.matchChapterAcrossVersions(De,Ae);P||L(W),G||A(st),de(W,st,"version")},[N,ee,Oe,fe,Q,P,G,de]),ve=g.useCallback(W=>{ee&&(G||A(W),de(ee,W,"chapter"))},[ee,G,de]),[le,Se]=g.useState(null),X=ee&&fe?`${e}
|
|
1295
|
+
${ee}
|
|
1296
|
+
${fe.file}`:null,[Ce,Me]=g.useState(null),M=X!==null&&Ce!==X,te=g.useRef(0);g.useEffect(()=>{if(!ee||!fe)return;const W=++te.current,he=`${e}
|
|
1297
|
+
${ee}
|
|
1298
|
+
${fe.file}`;Se(null),C.getChapter(e,ee,fe.file,{json:!!fe.has_json}).then(Ae=>{W===te.current&&Se(Ae)}).catch(()=>{W===te.current&&Se(null)}).finally(()=>{W===te.current&&Me(he)})},[C,e,ee,fe]);const ye=(U==null?void 0:U.kind)==="collated",[H,se]=g.useState("");g.useEffect(()=>{se("")},[e,ee]);const ne=g.useMemo(()=>ee&&ye?async W=>{const he=await C.getChapter(e,ee,W,{json:!0});return{juan:(he==null?void 0:he.json)??null,rawText:(he==null?void 0:he.md)??null}}:null,[C,e,ee,ye]),ge=(ie==null?void 0:ie.type)==="kaozhen",Ne=g.useMemo(()=>(ie==null?void 0:ie.chapters.map(W=>W.file))??[],[ie]),{matchStates:Be}=Uh({resetKey:`${e}
|
|
1299
|
+
${ee??""}`,load:ne,files:Ne,activeFile:Q??null,activeJuan:(le==null?void 0:le.json)??null,activeRawText:(le==null?void 0:le.md)??null,query:H,isKaozhen:ge}),We=g.useRef(new Map);g.useEffect(()=>{We.current.clear()},[e]);const Ue=g.useMemo(()=>({versionKey:ee,chapter:fe??null}),[ee,fe]),Je=bh(c,Q??null,Ue),{warpData:me,loading:et}=rc(y,_,Q??null,fe,Ue),E=jg(b,Q??null,Ue),[oe,ae]=g.useState(new Set),[je,ke]=g.useState(null),[xe,V]=g.useState(!0),[pe,Te]=g.useState(!0),Ee=g.useRef(null),[D,re]=g.useState(1),[Pe,_e]=g.useState(null),Ge=W=>{var Ae;const he=parseInt(((Ae=W==null?void 0:W.page_id)==null?void 0:Ae.split(":")[1])??"",10);return isNaN(he)?null:he},He=W=>{var he,Ae;return Ge(W)??((Ae=(he=W==null?void 0:W.pages)==null?void 0:he[0])==null?void 0:Ae.page)??1},[Fe,Ct]=g.useState(()=>He(me));g.useEffect(()=>{me&&Ct(He(me))},[me]),g.useEffect(()=>{ae(new Set),ke(null)},[Q,ee]);const Wn=g.useCallback(W=>{if(ae(new Set(W)),W.length>0){const he=W[0],Ae=parseInt(he.split(":")[0],10);isNaN(Ae)||Ct(Ae)}},[]),yt=g.useMemo(()=>{const W=new Map;for(const he of(me==null?void 0:me.pages)??[])W.set(he.page,he);return W},[me]),zt=Ge(me),Pt=g.useCallback(W=>{var De;const he=Je.images;if(!he||he.length===0)return;const Ae=(De=yt.get(W))==null?void 0:De.seq;return(Ae?he.find(st=>st.seq===Ae):void 0)??he.find(st=>st.pageNo===W)??he[W-1]},[Je.images,yt]),mn=D>1.5,On=g.useCallback((W,he=!1)=>{const Ae=Pt(W);return Ae?W===zt||he?Ae.hiresUrl??Ae.url:Ae.url:W===zt?(me==null?void 0:me.imageUrl)??"":""},[Pt,me,zt]),Td=g.useMemo(()=>On(Fe,mn),[On,Fe,mn]),hn=g.useMemo(()=>[...yt.keys()].sort((W,he)=>W-he),[yt]),gn=g.useCallback(W=>{const he=hn.indexOf(Fe),Ae=hn[he<0?0:he+W];Ae===void 0||Ae===Fe||(Ct(Ae),_e(De=>({page:Ae,nonce:((De==null?void 0:De.nonce)??0)+1})))},[hn,Fe]),Ti=hn.indexOf(Fe),Nd=g.useCallback(W=>{if(W.altKey||W.ctrlKey||W.metaKey)return;const he=W.target.tagName;he==="INPUT"||he==="TEXTAREA"||he==="SELECT"||(W.key==="ArrowLeft"||W.key==="PageUp"?(W.preventDefault(),gn(-1)):(W.key==="ArrowRight"||W.key==="PageDown")&&(W.preventDefault(),gn(1)))},[gn]);g.useEffect(()=>{if(me)for(const W of[1,-1,2,3]){const he=On(Fe+W);he&&fo(he)}},[me,Fe,On]);const Tr=g.useMemo(()=>{var Wr;if(!me)return null;if(Fe===zt)return me;const W=yt.get(Fe);if(W&&W.width>0&&W.height>0)return{page_id:`p:${Fe}`,title:`第${Fe}葉`,image_size:[W.width,W.height],total_warped_w:W.width,columns:[{col:1,warped_w:W.width,warped_h:W.height,offset_x:0,strips:[],chars:W.columns.flatMap(Ye=>Ye.chars).map(Ye=>({id:Ye.id,char:Ye.char,slot:Ye.slot,pos:Ye.pos,sub:Ye.sub,bbox_col:Ye.bbox??[0,0,0,0]}))}]};const he=(Wr=me.pages)==null?void 0:Wr.find(Ye=>Ye.page===Fe),[Ae,De]=me.image_size||[2386,3082],st=Pt(Fe),Zt=(st==null?void 0:st.width)??Ae,Li=(st==null?void 0:st.height)??De,Pr=Zt/Ae,Mr=Li/De,Br=new Map;for(const Ye of me.columns){const at=(Ye.strips||[]).flatMap(Dn=>Dn.srcQuad.map(Un=>Un[0]));if(at.length===0)continue;const jt=Ye.top_y??0,Ai=Ye.bottom_y??jt+Ye.warped_h;Br.set(Ye.col,{x0:Math.min(...at),x1:Math.max(...at),top:jt,slotH:(Ai-jt)/21})}return{page_id:`p:${Fe}`,title:`第${Fe}葉`,image_size:[Zt,Li],total_warped_w:Zt,columns:he?he.columns.map(Ye=>{const at=Br.get(Ye.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Ye.col,warped_w:Zt,warped_h:Li,offset_x:0,strips:[],chars:Ye.chars.map(jt=>{const Ai=jt.slot??jt.pos??0,Dn=(at.top+(Ai-1)*at.slotH)*Mr,Un=(at.x0+at.x1)/2,[Bd,Wd]=jt.sub==="a"?[Un,at.x1]:jt.sub==="b"?[at.x0,Un]:[at.x0,at.x1];return{...jt,bbox_col:[Bd*Pr,Dn,Wd*Pr,Dn+at.slotH*Mr]}})}}):[]}},[me,Fe,zt,yt,Pt]),{entryTitle:Hn,authors:Nr}=Cg(e,n,l===void 0),[Er,Ni]=g.useState("text");if(g.useEffect(()=>{Ni("text")},[Q,ee]),O==="loading")return t.jsx(Es,{className:w,style:v,title:l??Hn,label:$("reader.loading")});if(O==="missing"||!N||!U)return t.jsx("div",{className:w,style:{...v,...Ns},children:$("reader.noText")});if(Le==="failed")return t.jsx("div",{className:w,style:{...v,...Ns},children:$("reader.tocFailed")});if(!ie)return t.jsx(Es,{className:w,style:v,title:l??Hn,label:$("reader.tocLoading")});const Mt=wg(U,ie),Ed=Sg(ie,Be,Mt,S,ye),Ei=N.versions.map(W=>({key:W.key,label:we.textVersionLabel(W),optionLabel:S(we.textVersionLabel(W)),sourceName:W.source_name?S(W.source_name):void 0,license:W.license??void 0,sourceUrl:W.source_url??void 0,primary:W.key===ce})),rt=vg((Ar=ie.source)==null?void 0:Ar.upstream),Fn=(typeof l=="string"?S(l):l)??(ie.title?S(ie.title):Hn?S(Hn):void 0),Id=Fn?t.jsx("a",{href:z(e),title:$("reader.viewEntry"),onClick:a?W=>{W.metaKey||W.ctrlKey||(W.preventDefault(),a(e))}:void 0,children:Fn}):void 0,Rd=Nr.length>0?S(Nr.slice(0,2).map(W=>`${W.dynasty?`〔${W.dynasty}〕`:""}${W.name}${` ${W.role||$("reader.defaultRole")}`}`).join("、")):void 0,Ii=fe?sc(fe,Mt,S,ye):void 0,qt=ye&&!!(le!=null&&le.json),Bt=(le==null?void 0:le.json)??null,Xt=(le==null?void 0:le.md)??null,Ir=qt&&!ge&&ql(Bt.sections),Ld=Ir&&!(Xt&&B.readingMode==="paragraph"&&oi(Xt)),Ad=qt&&Ir?t.jsx(Vh,{juan:Bt,view:Er,onView:Ni,textHasEntries:Ld}):void 0,Pd=Qa(ie)||io(ie),Ri=Xt?Xt.replace(/^##\s+[^\n]+\n+/,""):null,Md=(typeof d=="string"?S(d):d)??(U.source_name?S(U.source_name):S(we.textVersionLabel(U)));return t.jsxs(hl,{className:w,style:v,title:Id,subtitle:Md,byline:Rd,current:Ii,pagerUnit:Mt,rail:Ad,revisedAt:f,backHref:x,backLabel:k,onReportError:m?W=>m({...W,bookTitle:typeof Fn=="string"?Fn:void 0,entryId:e}):void 0,workLinkToggle:qt&&!ge&&!!a&&!!(Bt!=null&&Bt.sections.some(W=>W.work_id)),toc:Ed,tocCaption:$("reader.tocCaption",{n:ie.chapters.length,unit:S(Mt)}),tocHeader:ye&&ie.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:ge?$("reader.searchChaptersPlaceholder"):$("reader.searchUnitPlaceholder",{unit:S(Mt)}),"aria-label":ge?$("reader.searchChapters"):$("reader.searchUnit",{unit:S(Mt)}),value:H,onChange:W=>se(W.target.value)}):void 0,activeKey:Q??null,onSelect:ve,images:Je.images,imagesLoading:Je.loading||et,renderImageOverlay:p,imagePanel:me?"open":u,isWarpMode:!!me,customImagePanel:me&&Tr?t.jsxs("div",{className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:Nd,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:Ti<=0,onClick:()=>gn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":Fe,style:{fontSize:11,padding:"1px 6px",background:i("rule"),borderRadius:10},children:["第 ",Fe," 葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",disabled:Ti<0||Ti>=hn.length-1,onClick:()=>gn(1),children:"›"})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[oe.size>0&&t.jsxs("button",{type:"button",onClick:()=>ae(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${i("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",oe.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:D<=1,onClick:()=>{var W;return(W=Ee.current)==null?void 0:W.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(D*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:D>=6,onClick:()=>{var W;return(W=Ee.current)==null?void 0:W.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:D===1,onClick:()=>{var W;return(W=Ee.current)==null?void 0:W.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(yg,{ref:Ee,resetKey:Fe,onScaleChange:re,style:{flex:1,minHeight:0},children:t.jsx(ar,{imageUrl:Td,pageData:Tr,selectedCharIds:oe,hoveredCharId:je,preserveMargins:pe,onCharClick:W=>{ae(Ae=>{const De=new Set(Ae);return De.has(W)?De.delete(W):(De.clear(),De.add(W)),De});const he=document.querySelector(`[data-char-id="${W}"]`);he&&he.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ke})}),t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"8px 0 2px"},children:t.jsxs("div",{style:{display:"inline-flex",border:`1px solid ${i("rule")}`,borderRadius:4,overflow:"hidden"},children:[t.jsx("button",{type:"button",onClick:()=>Te(!1),className:`bim-rd-t ${pe?"":"bim-rd-on"}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:pe?"transparent":i("accent-bg"),color:pe?"inherit":i("accent")},title:"去空白:紧凑裁切版心",children:"去空白"}),t.jsx("button",{type:"button",onClick:()=>Te(!0),className:`bim-rd-t ${pe?"bim-rd-on":""}`,style:{fontSize:11,padding:"2px 10px",lineHeight:"18px",border:"none",borderRadius:0,cursor:"pointer",background:pe?i("accent-bg"):"transparent",color:pe?i("accent"):"inherit"},title:"保留空白:完整呈现古籍天头地脚与白边",children:"保留空白"})]})})]}):void 0,toolbarExtra:me?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-badge-warp",children:"图文对读"}),t.jsx("button",{type:"button",className:`bim-rd-t ${xe?"bim-rd-on":""}`,title:"切换外挂现代断句标点",onClick:()=>V(W=>!W),children:xe?"标点":"无标点"})]}):void 0,prefs:B,onPrefsChange:T,versions:Ei.length>1?Ei:void 0,currentVersionKey:Ei.length>1?U.key:void 0,onVersionChange:Y,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:oi(Xt),allowVertical:h,children:[M&&t.jsx(Yt,{}),!M&&me&&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:fe!=null&&fe.title?S(fe.title):Ii}),(U.source_name||U.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[U.source_name&&S(U.source_name),U.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),U.license]})]})]}),t.jsx(ur,{pageData:me,pages:me.pages,punctuations:me.punctuations||[],selectedCharIds:oe,hoveredCharId:je,onSelectionChange:Wn,onCharClick:W=>{ae(Ae=>{const De=new Set(Ae);return De.has(W)?De.delete(W):(De.clear(),De.add(W)),De});const he=parseInt(W.split(":")[0],10);isNaN(he)||Ct(he)},onCharHover:ke,mode:"horizontal",showPunctuation:xe,entities:B.properNames?E:void 0,entityTransport:n,onEntityNavigate:j,onVisiblePageChange:W=>Ct(W),convert:S,scrollToPage:Pe})]}),!M&&!me&&qt&&Bt&&t.jsx(Dh,{juan:Bt,rawText:Xt,positionLabel:_g(fe,ie,Mt,S),groupLabel:$g(ie,Q??null),index:kg(e,ie),searchQuery:H,onNavigate:a,transport:n,workLabelCache:We,prefs:B,view:Er,onViewChange:Ni},`${ee}/${Q}`),!M&&!me&&!qt&&Ri!=null&&fe&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:fe.title?S(fe.title):Ii}),(U.source_name||U.license)&&t.jsxs("p",{className:"bim-rd-meta",children:[U.source_name&&t.jsxs(t.Fragment,{children:[$("reader.textSource")," ",U.source_url?t.jsx("a",{className:"bim-rd-link",href:U.source_url,target:"_blank",rel:"noreferrer",children:S(U.source_name)}):S(U.source_name)]}),U.source_name&&U.license&&t.jsx("span",{className:"bim-rd-dot"}),U.license]}),rt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[$("reader.upstream")," ",rt.url?t.jsx("a",{className:"bim-rd-link",href:rt.url,target:"_blank",rel:"noreferrer",children:S(rt.name??rt.url)}):S(rt.name??""),rt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),rt.license_url?t.jsx("a",{className:"bim-rd-link",href:rt.license_url,target:"_blank",rel:"noreferrer",children:rt.license}):rt.license]}),rt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(il,{text:rt.note,convert:S})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(er,{text:Ri,mode:B.readingMode,tables:Pd,gujiMarkdown:io(ie),properNames:B.properNames})})]}),!M&&!me&&!qt&&Ri==null&&fe&&t.jsx("div",{className:"bim-rd-state",children:$("reader.chapterFailed")}),ie.references&&ie.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:$("reader.references")}),t.jsx("ol",{children:ie.references.map((W,he)=>t.jsxs("li",{children:[W.url?t.jsx("a",{className:"bim-rd-link",href:W.url,target:"_blank",rel:"noopener noreferrer",children:S(W.title)}):t.jsx("span",{children:S(W.title)}),W.author&&t.jsxs("span",{children:[",",S(W.author)]}),W.note&&t.jsxs("span",{children:["。",S(W.note)]})]},he))})]})]})};function _g(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 $g(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 Cg(e,n,o){const[r,s]=g.useState({entryTitle:void 0,authors:[]});return g.useEffect(()=>{if(s({entryTitle:void 0,authors:[]}),typeof n.getItem!="function")return;let a=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(a||!l)return;const d=(l.authors??[]).filter(c=>c&&c.name);s({entryTitle:o&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,o]),r}const ac={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")}},zg=ac.other,lc={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")}},Tg=lc.pending;function Ng(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 Eg(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 gr=({items:e,loading:n})=>{const o=qe(),{t:r,convert:s}=J();return n?t.jsx(Yt,{}):e.length===0?t.jsx("div",{style:Ig,children:r("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=ac[a.type]||zg,d=lc[a.status]||Tg,c=typeof window<"u"&&Eg(a.pageUrl,window.location.href);return t.jsxs("div",{style:Rg,children:[t.jsxs("div",{style:Lg,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Rs,background:l.color},children:r(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...Rs,background:d.color},children:r(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Ag,children:Ng(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:Pg,children:[a.resourceId&&t.jsx("a",{href:o(a.resourceId),style:Gi,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:Gi,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:Gi,children:a.pageUrl}))]}),t.jsx("div",{style:Mg,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Bg,children:[t.jsx("div",{style:Wg,children:r("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},Ig={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},Rg={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},Lg={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Rs={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Ag={fontSize:"12px",color:i("desc-fg")},Pg={fontSize:"12px",marginBottom:"6px"},Gi={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},Mg={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},Bg={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},Wg={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},bo=({transport:e,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:a})=>{const l=$e(),[d,c]=g.useState(null),[p,u]=g.useState([]),[h,m]=g.useState("recommend"),[f,x]=g.useState([]),[k,y]=g.useState(!1),_=r??h,b=O=>{m(O),s==null||s(O)},[j,w]=g.useState(!0),[v,$]=g.useState(null),[S,C]=g.useState(null),[B,T]=g.useState(null);g.useEffect(()=>{let O=!1;if(e.getCounts)return e.getCounts().then(I=>{O||c({works:I.works,books:I.books,collections:I.collections})}).catch(()=>{}),()=>{O=!0}},[e]),g.useEffect(()=>{let O=!1;return(async()=>{if(o)return o;if(e.getRecommended)try{const P=await e.getRecommended();if(P!=null&&P.groups)return P.groups.flatMap(G=>G.items.map(K=>({...K,group:G.name})))}catch{}return[]})().then(async P=>{if(O)return;const G=P.filter(L=>L.id);if(G.length===0){w(!1);return}const K=await Promise.all(G.map(async L=>{if(L.type)return{id:L.id,title:L.title,type:L.type,author:L.author,dynasty:L.dynasty,role:L.role,edition:L.edition,has_text:L.has_text,has_image:L.has_image,has_collated:L.has_collated,subtype:L.subtype,primary_name:L.primary_name,group:L.group,fallbackDescription:L.description};try{let Z=null;if(e.getEntry)Z=await e.getEntry(L.id);else{const A=await e.getItem(L.id);A&&(Z={id:L.id,title:A.title||L.id,type:A.type||"work"})}if(Z)return{...Z,group:L.group,fallbackDescription:L.description}}catch{}return{id:L.id,title:L.title,type:we.extractType(L.id),group:L.group,fallbackDescription:L.description}}));O||(u(K.filter(L=>L!==null)),w(!1))}),()=>{O=!0}},[e,o]);const z=g.useRef(!1),F=g.useRef(!1),N=g.useRef(!1);g.useEffect(()=>{if(_!=="catalog"||z.current)return;const O=e.getCatalogProgress??e.getResourceProgress;if(!O)return;z.current=!0;let I=!1;return O.call(e).then(P=>{I||$(P)}).catch(()=>{z.current=!1}),()=>{I=!0}},[e,_]),g.useEffect(()=>{if(_!=="collection"||F.current||!e.getCollectionProgress)return;F.current=!0;let O=!1;return e.getCollectionProgress().then(I=>{O||C(I)}).catch(()=>{F.current=!1}),()=>{O=!0}},[e,_]),g.useEffect(()=>{if(_!=="site"||N.current||!e.getSiteProgress)return;N.current=!0;let O=!1;return e.getSiteProgress().then(I=>{O||T(I)}).catch(()=>{N.current=!1}),()=>{O=!0}},[e,_]),g.useEffect(()=>{if(!a||_!=="feedback")return;let O=!1;return y(!0),fetch(a).then(I=>I.json()).then(I=>{!O&&I.success&&x(I.items||[])}).catch(()=>{}).finally(()=>{O||y(!1)}),()=>{O=!0}},[a,_]);const R=O=>t.jsx(un,{type:O,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(vn,{label:l.home.recommendTab,active:_==="recommend",onClick:()=>b("recommend")}),t.jsx(vn,{label:l.home.catalogTab,active:_==="catalog",onClick:()=>b("catalog")}),t.jsx(vn,{label:l.home.collectionTab,active:_==="collection",onClick:()=>b("collection")}),t.jsx(vn,{label:l.home.siteTab,active:_==="site",onClick:()=>b("site")}),a&&t.jsx(vn,{label:l.home.feedbackTab,active:_==="feedback",onClick:()=>b("feedback")})]}),_==="recommend"&&t.jsx(Og,{recommended:p,loading:j,onNavigate:n,getIcon:R,t:l}),_==="catalog"&&t.jsx(Ls,{progress:v,t:l,onNavigate:n}),_==="collection"&&t.jsx(Ls,{progress:S,t:l,onNavigate:n}),_==="site"&&t.jsx(Fg,{progress:B,t:l,totalWorks:(d==null?void 0:d.works)??0}),_==="feedback"&&a&&t.jsx(gr,{items:f,loading:k})]})})},vn=({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}),Og=({recommended:e,loading:n,onNavigate:o,getIcon:r,t:s})=>{const a=qe();if(n)return t.jsx(Yt,{});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:h=>{h.metaKey||h.ctrlKey||(h.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))})},Ls=({progress:e,t:n,onNavigate:o})=>{if(!e)return t.jsx(Yt,{});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(Hg,{item:p,t:n,statusColor:l[d],onNavigate:o},p.id))})]},d)})})},Hg=({item:e,t:n,statusColor:o,onNavigate:r})=>{const s=qe(),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?dt(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})]})},Fg=({progress:e,t:n,totalWorks:o})=>{if(!e)return t.jsx(Yt,{});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(As,{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(As,{item:c,t:n,totalWorks:o},c.id))})]})]})},As=({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})]})},Ps="(max-width: 768px)";function Dg(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(Ps).matches);return g.useEffect(()=>{const o=window.matchMedia(Ps),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e}const Ug=({transport:e,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var F;const a=$e(),{convert:l}=Ie(),d=Dg(),[c,p]=g.useState(null),[u,h]=g.useState(null),[m,f]=g.useState(!1),[x,k]=g.useState("detail"),[y,_]=g.useState([]),[b,j]=g.useState(!1),w=g.useCallback(async N=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){_([]);return}j(!0);try{if(e.getCollectionCatalogs){const R=await e.getCollectionCatalogs(N);_(R||[])}else if(e.getCollectionCatalog){const R=await e.getCollectionCatalog(N);_(R?[{resource_id:"",data:R}]:[])}}catch{_([])}finally{j(!1)}},[e]),v=g.useCallback(async N=>{if(o){o(N);return}p(N),h(null),_([]),k("detail"),f(!0);try{const R=await e.getItem(N.id);R&&(h(R),R.type==="collection"&&w(N.id))}catch(R){console.error("加载详情失败:",R)}finally{f(!1)}},[e,o,w]),$=g.useCallback(async N=>{h(null),_([]),k("detail"),f(!0);try{const R=await e.getItem(N);R&&(h(R),p({id:N,title:R.title||N,type:R.type||"book"}),R.type==="collection"&&w(N))}catch(R){console.error("导航失败:",R)}finally{f(!1)}},[e,w]),S=typeof(u==null?void 0:u.text_count)=="number"&&u.text_count>0,C=(u==null?void 0:u.type)==="collection"&&(y.length>0||b)||(u==null?void 0:u.type)==="work"&&S,B=d&&(m||u),T=g.useCallback(()=>{p(null),h(null),_([]),k("detail")},[]),z=t.jsx(t.Fragment,{children:m?t.jsx(Yt,{}):u?t.jsxs(t.Fragment,{children:[(C||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${i("widget-border")}`,padding:d?"0 12px":"0 48px",background:i("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[C&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:qn(x==="detail"),children:a.detailTab.basicInfo}),u.type==="collection"&&b&&y.length===0&&t.jsxs("button",{onClick:()=>{},style:qn(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&y.map(N=>t.jsx("button",{onClick:()=>k(`catalog:${N.resource_id}`),style:qn(x===`catalog:${N.resource_id}`),children:N.short_name?`${l(N.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},N.resource_id)),u.type==="work"&&S&&t.jsx("button",{onClick:()=>k("collated"),style:qn(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(Ao,{data:u,transport:e,onNavigate:$}):x.startsWith("catalog:")?t.jsx(Po,{data:(F=y.find(N=>`catalog:${N.resource_id}`===x))==null?void 0:F.data,onNavigate:$}):x==="collated"?t.jsx(hr,{id:u.id,transport:e,onNavigate:$}):null})]}):t.jsx(bo,{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:B?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:T,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:z})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(no,{transport:e,onEntryClick:v,hideModeIndicator:n}),!u&&t.jsx(bo,{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(no,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:z})]})};function qn(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 Vg=({pageData:e,rawImageUrl:n="",punctuations:o=[],title:r,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=g.useState(new Set),[u,h]=g.useState(null),[m,f]=g.useState("horizontal"),[x,k]=g.useState(!0),y=g.useRef(null),_=g.useCallback(v=>{p(new Set(v))},[]),b=g.useCallback(v=>{if(p($=>{const S=new Set($);return S.has(v)?S.delete(v):(S.clear(),S.add(v)),S}),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())},w=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:m==="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(ar,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:u,onCharClick:b,onCharHover:h})})]}),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:m==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(ur,{pageData:e,punctuations:w,selectedCharIds:c,hoveredCharId:u,onSelectionChange:_,onCharClick:b,onCharHover:h,mode:m,showPunctuation:x})]})]})]})},Gg=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function Qt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Yg(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,h=Qt((r=u.page)==null?void 0:r.index),m=Array.isArray(u.cells)?u.cells:[];if(h===void 0||m.length===0)continue;const f=new Map;for(const x of m){if(!x||typeof x!="object")continue;const k=x,y=Gg.exec(String(k.a??""));if(!y||typeof k.c!="string")continue;const _=parseInt(y[2],10),b=parseInt(y[3],10),j=Array.isArray(k.box)&&k.box.length===4&&k.box.every($=>Qt($)!==void 0)?k.box:null,w={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(_);v||f.set(_,v=[]),v.push(w)}o.push({page:h,seq:String(((s=u.canvas)==null?void 0:s.seq)??""),width:Qt((a=u.canvas)==null?void 0:a.width)??Qt((l=u.image)==null?void 0:l.width)??0,height:Qt((d=u.canvas)==null?void 0:d.height)??Qt((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 Kg(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 qg(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 Xg=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function It(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Ms(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(o=>!!o&&typeof o=="object"):[]}function Zg(e,n){var a,l,d,c,p;const o=new Map,r=new Map;for(const u of Ms(n)){const h=It(u.page);if(h!==void 0){o.set(h,u);for(const m of Array.isArray(u.cells)?u.cells:[]){const f=m==null?void 0:m.box;typeof(m==null?void 0:m.a)=="string"&&Array.isArray(f)&&f.length===4&&f.every(x=>It(x)!==void 0)&&r.set(m.a,[f[0],f[1],f[0]+f[2],f[1]+f[3]])}}}const s=[];for(const u of Ms(e)){const h=It(u.page);if(h===void 0)continue;const m=[];for(const x of Array.isArray(u.columns)?u.columns:[]){const k=It(x==null?void 0:x.col);if(k===void 0)continue;const y=[];for(const _ of Array.isArray(x.cells)?x.cells:[]){const b=Xg.exec(String((_==null?void 0:_.a)??""));if(!b||typeof _.c!="string")continue;const j=parseInt(b[3],10);y.push({id:_.a,char:_.c,slot:j,pos:j,sub:b[4]||null,bbox:r.get(_.a)??null})}y.length>0&&m.push({col:k,chars:y})}if(m.length===0)continue;m.sort((x,k)=>x.col-k.col);const f=o.get(h);s.push({page:h,seq:String(((a=f==null?void 0:f.canvas)==null?void 0:a.seq)??""),width:It((l=f==null?void 0:f.canvas)==null?void 0:l.width)??It((d=f==null?void 0:f.image)==null?void 0:d.width)??0,height:It((c=f==null?void 0:f.canvas)==null?void 0:c.height)??It((p=f==null?void 0:f.image)==null?void 0:p.height)??0,columns:m})}return s}const Jg=({data:e,onNavigate:n,className:o,style:r})=>{var u;const{t:s,convert:a}=J(),[l,d]=g.useState(((u=e.divisions[0])==null?void 0:u.name)??null),[c,p]=g.useState(null);return t.jsxs("div",{className:o,style:r,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(h=>t.jsx(Qg,{division:h,expanded:l===h.name,onToggle:()=>d(l===h.name?null:h.name),expandedCat:c,onCatToggle:m=>p(c===m?null:m),onNavigate:n},h.name))})]})},Qg=({division:e,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=J(),c=e.categories.reduce((p,u)=>{const h=u.stats||{zhulu:0,cunmu:0};return p+(h.zhulu||0)+(h.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(ef,{category:p,expanded:r===u,onToggle:()=>s(u),onNavigate:a},p.name)})})]})},ef=({category:e,expanded:n,onToggle:o,onNavigate:r})=>{var p,u,h,m;const{t:s,convert:a}=J(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((u=e.books)==null?void 0:u.cunmu)||[],c=(((h=e.stats)==null?void 0:h.zhulu)||l.length)+(((m=e.stats)==null?void 0:m.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(Bs,{label:s("catalogPage.zhulu"),books:l,onNavigate:r}),d.length>0&&t.jsx(Bs,{label:s("catalogPage.cunmu"),books:d,onNavigate:r})]})]})},Bs=({label:e,books:n,onNavigate:o})=>{const{t:r,convert:s}=J(),a=qe(),[l,d]=g.useState(n.length<=20),c=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,u)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:i("fg")},children:p.work_id&&o?t.jsx("a",{href:a(p.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.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})})]})},ht=({title:e,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const a=$e();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:nf,children:"AI"}),n&&t.jsx("button",{onClick:n,style:tf,children:a.action.save})]})]}),s]})},tf={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},nf={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},ct=({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"}})]}),Ut=({value:e,onChange:n,placeholder:o})=>{const r=g.useRef(null);return g.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:r,value:e||"",onChange:s=>n(s.target.value),placeholder:o,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},si=({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 of(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Qn=({value:e,onChange:n,label:o})=>{const[r,s]=g.useState(!1),a=g.useRef(null),l=of(e||"");return g.useEffect(()=>{r&&a.current&&a.current.focus()},[r]),!r&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ws,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(si,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ws,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"}})]})},Ws={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function rf(e){switch(e){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function sf(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const cc=({items:e,onChange:n,onOpenEntityPicker:o})=>{const r=$e(),[s,a]=g.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=h=>{n(e.filter((m,f)=>f!==h)),s===h&&a(null)},c=(h,m,f)=>{const x=[...e];x[h]={...x[h],[m]:f},n(x)},p=(h,m)=>{const f=[...e];f[h]={...f[h],type:m,id:"",name:""},n(f),m==="bookID"&&o&&o(x=>{const k=[...e];k[h]={...k[h],id:x.id,name:x.title,type:"bookID"},n(k)})},u=h=>{o&&o(m=>{const f=[...e];f[h]={...f[h],id:m.id,name:m.title,type:"bookID"},n(f)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((h,m)=>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===m?null:m),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===m?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:h.name||`${r.editor.sourcePlaceholder} ${m+1}`}),h.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:rf(h.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:sf(h.type)}),t.jsx("button",{onClick:f=>{f.stopPropagation(),d(m)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===m&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!h.type&&t.jsxs("div",{children:[t.jsx("label",{style:vt,children:r.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(m,"bookID"),style:{...Os,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(m,"url"),style:{...Os,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})]})]})]}),h.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:vt,children:r.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:Hs,children:r.action.changeType})]}),h.id&&h.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:h.name}),t.jsx("code",{style:{fontSize:"11px",background:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:h.id})]}),t.jsx("button",{onClick:()=>u(m),style:{background:"transparent",border:`1px solid ${i("widget-border")}`,color:i("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:r.action.reselect})]}):t.jsxs("button",{onClick:()=>u(m),style:{width:"100%",padding:"14px",border:`2px dashed ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),h.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:vt,children:r.label.sourceName}),t.jsx("button",{onClick:()=>{const f=[...e];f[m]={...f[m],type:"",id:"",name:""},n(f)},style:Hs,children:r.action.changeType})]}),t.jsx("input",{type:"text",value:h.name,onChange:f=>c(m,"name",f.target.value),placeholder:r.editor.sourceNamePlaceholder,style:en})]}),t.jsxs("div",{children:[t.jsx("label",{style:vt,children:r.label.urlAddress}),t.jsx("input",{type:"text",value:h.id,onChange:f=>c(m,"id",f.target.value),placeholder:"https://...",style:en})]})]}),h.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:{...vt,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:vt,children:r.label.detailsOptional}),t.jsx("input",{type:"text",value:h.details,onChange:f=>c(m,"details",f.target.value),placeholder:r.editor.detailsPlaceholder,style:en})]}),t.jsxs("div",{children:[t.jsx("label",{style:vt,children:r.label.positionOptional}),t.jsx("input",{type:"text",value:h.position,onChange:f=>c(m,"position",f.target.value),placeholder:"如: 卷三, p.52",style:en})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:vt,children:r.label.dataVersionOptional}),t.jsx("input",{type:"text",value:h.version,onChange:f=>c(m,"version",f.target.value),placeholder:"如: v1.0, 2024-01",style:en})]}),t.jsxs("div",{children:[t.jsx("label",{style:vt,children:r.label.processorVersionOptional}),t.jsx("input",{type:"text",value:h.processor_version,onChange:f=>c(m,"processor_version",f.target.value),placeholder:"如: v0.1",style:en})]})]})]})]})})]},m)),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})]})]})},vt={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},en={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"},Os={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"},Hs={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function dc(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 pc(e){return!e||e.length===0?"":JSON.stringify(e)}const uc=({entityType:e,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:u,onLinkEntity:h,onUnlinkEntity:m,onViewEntity:f,onCreateAndLink:x,onSaveRelations:k})=>{const y=$e();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:af,children:y.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(kn,{direction:"up",title:y.relation.belongsToWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>h("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(kn,{direction:"up",title:y.relation.containedInCollection,entity:l,onView:f,onUnlink:()=>m("collectionId"),onLink:()=>h("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(tn,{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(kn,{direction:"up",title:y.relation.parentWork,entity:r,onView:f,onUnlink:()=>m("parentWorkId"),onLink:()=>h("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(tn,{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(tn,{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(tn,{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(kn,{direction:"up",title:y.relation.correspondingWork,entity:a,onView:f,onUnlink:()=>m("workId"),onLink:()=>h("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(kn,{direction:"up",title:y.relation.parentCollection,entity:s,onView:f,onUnlink:()=>m("parentCollectionId"),onLink:()=>h("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(tn,{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(tn,{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})]})]})]})},kn=({direction:e,title:n,entity:o,onView:r,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:u,unlinkLabel:h})=>{const m=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:m,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:mc(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(Fs,{onClick:()=>r(o),title:u,children:"👁️"}),t.jsx(Fs,{onClick:s,title:h,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(yo,{onClick:a,children:d}),t.jsx(yo,{onClick:l,primary:!0,children:c})]})]})},tn=({direction:e,title:n,entities:o,onView:r,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=g.useState(!1),u=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),h=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",m=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:h}),t.jsx("span",{children:n})]}),o.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[m.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:mc(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(yo,{onClick:s,primary:!0,children:["+ ",a]})})]})},Fs=({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}),yo=({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 mc(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const af={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},hc=({isOpen:e,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[u,h]=g.useState(""),m=p?l.filter(y=>y.id!==p):l;g.useEffect(()=>{e&&(h(""),d(""))},[e]);const f=y=>{h(y),d(y)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",k=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:lf,children:t.jsxs("div",{style:cf,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:df,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:pf})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:Yi,children:"搜索中..."}):m.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:m.map(y=>t.jsxs("div",{onClick:()=>r(y),style:uf,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:Yi,children:["未找到匹配的",x]}):t.jsxs("div",{style:Yi,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:mf,children:["创建新",x,"并关联"]})]})]})})},lf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},cf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},df={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},pf={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"},uf={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},Yi={padding:"20px",textAlign:"center",color:i("desc-fg")},mf={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Ds={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},hf={work:"📜",book:"📖",collection:"📚",entity:"👤"},gc=({isOpen:e,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:a})=>{const[l,d]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(d((r==null?void 0:r.title)||""),setTimeout(()=>{var m,f;(m=c.current)==null||m.focus(),(f=c.current)==null||f.select()},100))},[e,r==null?void 0:r.title]);const p=m=>{m.key==="Enter"&&l.trim()?u():m.key==="Escape"&&a()},u=()=>{l.trim()&&s(l.trim(),{...r,title:l.trim()})};if(!e)return null;const h=()=>{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`创建新${Ds[n]}`}};return t.jsx("div",{style:gf,onClick:m=>{m.target===m.currentTarget&&a()},children:t.jsxs("div",{style:ff,onClick:m=>m.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:hf[n]}),t.jsx("span",{children:h()})]}),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:m=>d(m.target.value),onKeyDown:p,placeholder:`请输入${Ds[n]}名称...`,style:xf})]}),((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:bf,children:"取消"}),t.jsx("button",{onClick:u,disabled:!l.trim(),style:{...yf,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},gf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ff={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")},xf={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"},bf={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},yf={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function jf(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function fc(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function vf(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 xc=({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[h,m]=g.useState(""),[f,x]=g.useState([]),[k,y]=g.useState(!1),[_,b]=g.useState("recent");g.useEffect(()=>{e&&(m(""),x([]),b(r.length>0?"recent":"search"))},[e,r.length]),g.useEffect(()=>{if(!h.trim()){x([]);return}const C=setTimeout(async()=>{y(!0);try{x(await u(h,o))}catch{x([])}finally{y(!1)}},300);return()=>clearTimeout(C)},[h,o,u]);const j=g.useCallback(C=>{m(C.target.value),C.target.value.trim()&&b("search")},[]),w=g.useCallback(C=>s?C.filter(B=>B.id!==s):C,[s]);if(!e)return null;const v=n||(o==="all"?"选择实体":`选择${fc(o)}`),$=w(r),S=w(f);return t.jsx("div",{style:wf,children:t.jsxs("div",{style:Sf,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:_f,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:h,onChange:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:$f}),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(Us,{active:_==="recent",onClick:()=>b("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(Us,{active:_==="search",onClick:()=>b("search"),children:["搜索结果 ",S.length>0&&`(${S.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:_==="recent"&&$.length>0?t.jsx(Vs,{entities:$,onSelect:d}):h.trim()?k?t.jsx(Ki,{message:"搜索中..."}):S.length>0?t.jsx(Vs,{entities:S,onSelect:d}):t.jsx(Ki,{message:"未找到匹配的结果"}):t.jsx(Ki,{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:Cf,children:l||"创建新实体"})]})]})})},Us=({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}),Vs=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(o=>t.jsx(kf,{entity:o,onClick:()=>n(o)},o.id))}),kf=({entity:e,onClick:n})=>{const[o,r]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:i("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:jf(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:vf(e.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:fc(e.type)})]})},Ki=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:e}),wf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Sf={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")},_f={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},$f={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"},Cf={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},zf={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},Tf={work:"📜",collection:"📚",book:"📖",entity:"👤"},bc=({data:e,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:u,relations:h,onRelationsChange:m})=>{var Se;const f=$e(),[x,k]=g.useState(!1),[y,_]=g.useState("work"),[b,j]=g.useState(""),[w,v]=g.useState(""),[$,S]=g.useState([]),[C,B]=g.useState(!1),[T,z]=g.useState(!1),[F,N]=g.useState("work"),[R,O]=g.useState(""),[I,P]=g.useState(),[G,K]=g.useState(!1),[L,Z]=g.useState(null),[A,U]=g.useState([]);g.useRef(null);const ce=e.type,ee=ce==="work",ue=ce==="collection",de=ce==="book",be=g.useCallback((X,Ce)=>{n({...e,[X]:Ce})},[e,n]),Oe=g.useCallback((X,Ce)=>{j(X),_(Ce),v(f.editor.selectToLink+f.indexType[Ce]),S([]),k(!0)},[f]),ie=g.useCallback(X=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(e.id,X)},[r,e.id]),Re=g.useCallback(X=>{s==null||s(X.id,X.type)},[s]),Le=g.useCallback((X,Ce,Me)=>{const M={...Me,author:(Me==null?void 0:Me.author)||e.author,dynasty:Me==null?void 0:Me.dynasty};N(Ce),O(X),P(M),z(!0)},[e.author]),q=g.useCallback((X,Ce)=>{r!=null&&r.createAndLink&&r.createAndLink(e.id,R,{type:F,title:X,inheritData:Ce}),z(!1)},[r,e.id,R,F]),Q=g.useCallback(X=>{if(!X.trim()){S([]);return}B(!0),r!=null&&r.searchEntities&&r.searchEntities(X,y).then(Ce=>{S(Ce),B(!1)}).catch(()=>{S([]),B(!1)})},[r,y]),fe=g.useCallback(X=>{r!=null&&r.linkEntity&&r.linkEntity(e.id,b,X.id),k(!1)},[r,e.id,b]),ze=g.useCallback(()=>{o()},[o]),Y=g.useCallback(X=>{Z(()=>X),K(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(U).catch(()=>{})},[r]),ve=g.useCallback((X,Ce)=>r!=null&&r.searchEntities?r.searchEntities(X,Ce==="all"?void 0:Ce):Promise.resolve([]),[r]),le=g.useCallback(X=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(X),U(Ce=>[X,...Ce.filter(Me=>Me.id!==X.id)].slice(0,10)),L==null||L(X),K(!1),Z(null)},[r,L]);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:Tf[ce]}),t.jsx("span",{children:e.title||f.editor.untitled}),t.jsx(si,{children:e.id}),t.jsx(si,{color:zf[ce],children:f.indexType[ce]})]})}),t.jsx(ht,{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(Qn,{label:ee?f.editor.workTitle:ue?f.editor.collectionTitle:f.editor.bookTitle,value:e.title,onChange:X=>be("title",X)}),de&&t.jsx(Qn,{label:f.editor.belongsToWork,value:e.workName||"",onChange:X=>be("workName",X)}),t.jsx(ct,{label:f.editor.authorLabel,value:e.author||"",onChange:X=>be("author",X)}),t.jsx(ct,{label:f.editor.publicationYearLabel,value:e.publicationYear||"",onChange:X=>be("publicationYear",X)}),(de||ue)&&t.jsx(Qn,{label:f.editor.containedIn,value:e.collection||"",onChange:X=>be("collection",X)}),(de||ue)&&t.jsx(ct,{label:f.editor.holderLabel,value:e.holder||"",onChange:X=>be("holder",X)}),(de||ue)&&t.jsx(ct,{label:de?f.editor.pageLabel:f.editor.volumeLabel,value:e.pages||"",onChange:X=>be("pages",X)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(ct,{label:f.editor.firstImageLabel,value:e.firstImage||"",onChange:X=>be("firstImage",X)})})]})}),t.jsx(ht,{title:f.section.description,onSave:o,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(Ut,{value:e.description||"",onChange:X=>be("description",X),placeholder:f.editor.descriptionPlaceholder})}),(((Se=e.additional_works)==null?void 0:Se.length)||0)>0&&t.jsx(ht,{title:f.section.additionalWorks,onSave:o,children:t.jsx(Nf,{items:e.additional_works||[],onChange:X=>be("additional_works",X)})}),t.jsx(ht,{title:f.section.indexedBy,onSave:o,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(Ef,{items:e.indexed_by||[],onChange:X=>be("indexed_by",X)})}),t.jsx(ht,{title:f.section.emendatedBy,onSave:o,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(If,{items:e.emendated_by||[],onChange:X=>be("emendated_by",X)})}),t.jsx(ht,{title:f.section.textResources,onSave:o,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(eo,{items:e.resources||[],onChange:X=>be("resources",X),onDownload:p,downloadStatuses:u,filterType:"text"})}),t.jsx(ht,{title:f.section.imageResources,onSave:o,children:t.jsx(eo,{items:e.resources||[],onChange:X=>be("resources",X),onDownload:p,downloadStatuses:u,filterType:"image"})}),t.jsx(ht,{title:f.section.sources,onSave:o,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(cc,{items:dc(e.sources||""),onChange:X=>be("sources",pc(X)),onOpenEntityPicker:Y})}),(de||ue)&&t.jsx(ht,{title:f.section.provenance,onSave:o,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(Ut,{value:e.provenance||"",onChange:X=>be("provenance",X),placeholder:f.editor.provenancePlaceholder})}),de&&t.jsx(ht,{title:f.section.otherEditions,onSave:o,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(Ut,{value:e.otherEditions||"",onChange:X=>be("otherEditions",X),placeholder:f.editor.otherEditionsPlaceholder})}),t.jsx(uc,{entityType:ce,entityId:e.id,entityTitle:e.title,parentWork:h==null?void 0:h.parentWork,parentCollection:h==null?void 0:h.parentCollection,belongsToWork:h==null?void 0:h.belongsToWork,belongsToCollection:h==null?void 0:h.belongsToCollection,childWorks:h==null?void 0:h.childWorks,childCollections:h==null?void 0:h.childCollections,containedBooks:h==null?void 0:h.containedBooks,siblingBooks:h==null?void 0:h.siblingBooks,onLinkEntity:Oe,onUnlinkEntity:ie,onViewEntity:Re,onCreateAndLink:Le,onSaveRelations:ze}),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(hc,{isOpen:x,entityType:y,title:w,onSelect:fe,onCancel:()=>k(!1),onCreate:()=>{k(!1),Le(b,y)},searchResults:$,onSearch:Q,isLoading:C,excludeId:e.id}),t.jsx(gc,{isOpen:T,entityType:F,relationField:R,inheritData:I,onConfirm:q,onCancel:()=>z(!1)}),t.jsx(xc,{isOpen:G,title:f.action.selectBookOrWork,filterType:"all",recentEntities:A,excludeId:e.id,onSelect:le,onCancel:()=>{K(!1),Z(null)},onSearch:ve})]})};function Nf({items:e,onChange:n}){const o=$e(),r=(l,d,c)=>{const p=e.map((u,h)=>h===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(ct,{label:o.editor.bookNameLabel,value:l.book_title,onChange:c=>r(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(ct,{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 yc({items:e,onChange:n,showMeta:o,addLabel:r}){const s=$e(),[a,l]=g.useState(null),d=(u,h,m)=>{const f=e.map((x,k)=>k===u?{...x,[h]:m||void 0}:x);n(f)},c=u=>{n(e.filter((h,m)=>m!==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,h)=>{const m=a===h;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:m?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(m?null:h),children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:m?"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(h)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!m&&o&&(u.title_info||u.author_info)&&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]}),m&&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(ct,{label:s.label.sourceName,value:u.source,onChange:f=>d(h,"source",f)}),t.jsx(ct,{label:s.label.sourceBid,value:u.source_bid||"",onChange:f=>d(h,"source_bid",f)})]}),o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(ct,{label:s.label.titleInfo,value:u.title_info||"",onChange:f=>d(h,"title_info",f)}),t.jsx(ct,{label:s.label.authorInfo,value:u.author_info||"",onChange:f=>d(h,"author_info",f)})]}),t.jsx(ct,{label:s.label.edition,value:u.edition||"",onChange:f=>d(h,"edition",f)})]}),t.jsx(Ut,{value:u.summary||"",onChange:f=>d(h,"summary",f),placeholder:s.editor.summaryPlaceholder}),t.jsx(Ut,{value:u.comment||"",onChange:f=>d(h,"comment",f),placeholder:s.editor.commentPlaceholder}),t.jsx(Ut,{value:u.additional_comment||"",onChange:f=>d(h,"additional_comment",f),placeholder:s.editor.additionalCommentPlaceholder})]})]},h)}),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 Ef({items:e,onChange:n}){const o=$e();return t.jsx(yc,{items:e,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function If({items:e,onChange:n}){const o=$e();return t.jsx(yc,{items:e,onChange:n,addLabel:o.action.addEmendatedBy})}function jc(e){var d,c,p,u,h,m,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=(h=e.page_count)!=null&&h.number?String(e.page_count.number):((m=e.page_count)==null?void 0:m.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 Rf(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 Lf=e=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:u,onAskAI:h,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y,headerExtra:_,className:b,style:j}=e,w=$e(),[v,$]=g.useState(s),S=a?s:v;g.useEffect(()=>{s!==v&&$(s)},[s]);const C=g.useCallback(()=>{const O=S==="view"?"edit":"view";a?a(O):$(O)},[S,a]),[B,T]=g.useState(null);g.useEffect(()=>{o&&r&&r.getItem(o).then(O=>{O&&T(O)})},[o,r]);const z=n||B,F=g.useMemo(()=>z?jc(z):null,[z]),N=a||!n?t.jsx("button",{onClick:C,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:S==="edit"?i("accent-bg"):"transparent",color:i(S==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:S==="view"?w.common.switchToEdit:w.common.switchToView,children:S==="view"?w.common.modeEdit:w.common.modeView}):null,R=t.jsxs(t.Fragment,{children:[N,_]});return!z&&!F?t.jsx(Yt,{}):S==="view"?t.jsx(Ao,{data:z,transport:r,onNavigate:p?O=>p(O):void 0,renderLink:u,headerExtra:R,className:b,style:j}):F?t.jsxs("div",{className:b,style:j,children:[R&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:R}),t.jsx(bc,{data:F,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:r,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:h,renderSectionActions:m,onDownloadResource:f,downloadStatuses:x,relations:k,onRelationsChange:y})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:w.common.noData})},Af=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],vc=({isOpen:e,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const{t:s}=J(),[a,l]=g.useState(null),[d,c]=g.useState(""),[p,u]=g.useState(""),[h,m]=g.useState("idle"),[f,x]=g.useState(""),k=g.useRef(null);g.useEffect(()=>{e&&(l(null),c(""),u(""),m("idle"),x(""))},[e]),g.useEffect(()=>{a&&setTimeout(()=>{var b;return(b=k.current)==null?void 0:b.focus()},100)},[a]),g.useEffect(()=>{if(h==="success"){const b=setTimeout(n,2e3);return()=>clearTimeout(b)}},[h,n]),g.useEffect(()=>{if(!e)return;const b=j=>{j.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,n]);const y=async()=>{if(!(!a||!d.trim())){m("submitting"),x("");try{await o({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),m("success")}catch(b){m("error"),x(b instanceof Error?b.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const _=a&&d.trim()&&h!=="submitting";return t.jsx("div",{style:Pf,onClick:b=>{b.target===b.currentTarget&&n()},children:t.jsxs("div",{style:Mf,onClick:b=>b.stopPropagation(),children:[t.jsxs("div",{style:Bf,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Wf,"aria-label":s("feedback.close"),children:"✕"})]}),h==="success"?t.jsxs("div",{style:Uf,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:Af.map(b=>t.jsxs("button",{onClick:()=>l(b.value),style:{...Of,...a===b.value?Hf:{}},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||h==="submitting",style:{...Ff,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||h==="submitting","aria-label":s("feedback.contactLabel"),style:Gf}),t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),h==="error"&&t.jsx("div",{style:Vf,children:f}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:y,disabled:!_,style:{...Df,opacity:_?1:.6,cursor:_?"pointer":"not-allowed"},children:s(h==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Pf={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Mf={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},Bf={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Wf={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Of={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"},Hf={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Ff={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"},Df={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},Uf={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},Vf={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},Gf={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"},jo="--bim-feedback-fab-offset",vo=48,Yf=16,Kf=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const{t:a}=J(),[l,d]=g.useState(!1),c=n.bottom??24;return g.useEffect(()=>{if(r||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(jo,`calc(${c+vo+Yf}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(jo)}},[r,c]),t.jsxs(t.Fragment,{children:[!r&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...qf,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(vc,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:o})]})},qf={position:"fixed",width:`${vo}px`,height:`${vo}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"},Xf=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],kc=({onSubmit:e})=>{const{t:n}=J(),[o,r]=g.useState("bug"),[s,a]=g.useState(""),[l,d]=g.useState(""),[c,p]=g.useState("idle"),[u,h]=g.useState(""),m=g.useRef(null);g.useEffect(()=>{o&&setTimeout(()=>{var k;return(k=m.current)==null?void 0:k.focus()},100)},[o]);const f=async()=>{if(!(!o||!s.trim())){p("submitting"),h("");try{await e({type:o,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),r("bug")}catch(k){p("error"),h(k instanceof Error?k.message:n("feedback.submitFailedRetry"))}}},x=o&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:Gs,children:t.jsxs("div",{style:tx,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:nx,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:Gs,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Xf.map(k=>t.jsxs("button",{onClick:()=>r(k.value),style:{...Zf,...o===k.value?Jf:{}},children:[t.jsx("span",{children:k.icon})," ",n(`feedback.submitType.${k.value}`)]},k.value))}),t.jsx("textarea",{ref:m,value:s,onChange:k=>a(k.target.value),placeholder:n(o?`feedback.placeholder.${o}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Qf}}),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:ox}),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:{...ex,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:ix,children:u})]})},Gs={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},Zf={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"},Jf={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},Qf={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"},ex={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},tx={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},nx={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},ix={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},ox={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 Ys(e){return typeof e=="function"?e():e??"/api/feedback"}const wc=({resourceId:e,apiUrl:n})=>{const{t:o}=J(),[r,s]=g.useState([]),[a,l]=g.useState(!0),d=g.useCallback(async()=>{const p=Ys(n);l(!0);try{const h=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();h.success&&s(h.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const c=async p=>{const u=Ys(n),h=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!h.ok){const m=await h.json().catch(()=>null);throw new Error((m==null?void 0:m.error)||o("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(gr,{items:r,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(kc,{onSubmit:c})})]})},rx=li["zh-Hant"].relation,sx=li["zh-Hant"].lossStatus,ax=li["zh-Hant"].resourceKind,ki=cn("zh-Hant"),fr=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function Ks(e,n=ki){return e?fr(rx,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function lx(e,n=ki){return fr(sx,e)?n(`detail.lossStatus.${e}`):e}function cx(e,n=ki){return fr(ax,e)?n(`detail.resourceKind.${e}`):""}function xr({authors:e,onNavigate:n,renderLink:o}){const{convert:r}=J(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=Uo(a.role);return t.jsxs(g.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(a.dynasty),"〕"]}),a.entity_id?t.jsx(Ke,{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 Sc(e,n,o=ki){var c,p;const r=Fo(e,n),s=r.mirrors.map(u=>({key:u.key,label:u.label,description:u.description,rows:u.items.filter(h=>h.group_role!=="mirror"),mirrors:u.items.filter(h=>h.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 _c(e,n){const o=(e.url?dn(e.url):void 0)||e.name,r=xl(e,n);return r?`${o}(${r})`:o}function br({item:e,siblings:n,listedVolumeCounts:o}){const{t:r,convert:s}=J(),[a,l]=g.useState(!1),d=ci(e),c=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),p=s(_c(e,n)),u=pn(e),h=xi(e,r)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var f,x;const m=(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:"↗"}),m]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,m]})})(),h&&t.jsx("span",{className:"bim-d-meta",children:s(h)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(qo,{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(m=>!m),children:a?r("detail.collapseVolumes"):r("detail.expandVolumes",{n:d.expected})})})]})}function $c({groups:e,listedVolumeCounts:n}){const{t:o,convert:r}=J();return t.jsx(t.Fragment,{children:e.map(s=>t.jsxs("div",{className:"bim-d-rg",children:[s.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:r(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:r(s.description)}),s.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:s.rows.map((a,l)=>t.jsx(br,{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=pn(a),c=r(_c(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 Nn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function ko(e){var o;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=Nn.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const qs=12,dx=60,Cc=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:a,back:l,railLinks:d})=>{var Q,fe,ze;const{t:c,convert:p,messages:u}=J(),h=g.useMemo(()=>[...e.books||[],...e.collections||[]],[e.books,e.collections]),[m,f]=g.useState(new Map),[x,k]=g.useState(!1),[y,_]=g.useState(""),[b,j]=g.useState(!1),w=h.length<=dx,v=w||x||!!y||b,$=g.useMemo(()=>v?h:h.slice(0,qs),[h,v]);g.useEffect(()=>{if(!n||$.length===0)return;const Y=$.filter(le=>!m.has(le));if(Y.length===0)return;let ve=!1;return Promise.all(Y.map(le=>n.getItem(le).then(Se=>{const X=Se??{};return[le,{id:le,title:X.title,edition:X.edition,resources:X.resources,publication_info:X.publication_info,current_location:X.current_location,lineage:X.lineage,measure_info:X.measure_info}]}).catch(()=>[le,{id:le}]))).then(le=>{ve||f(Se=>{const X=new Map(Se);for(const[Ce,Me]of le)X.set(Ce,Me);return X})}),()=>{ve=!0}},[n,$,m]);const S=g.useMemo(()=>h.map(Y=>m.get(Y)??{id:Y}),[h,m]),C=h.length>0&&h.every(Y=>m.has(Y)),B=!!n&&$.some(Y=>!m.has(Y)),T=w||v,z=g.useMemo(()=>yl(S,e.version_graph,{era:y,scanOnly:b,sort:T?"year":"default"}),[S,e.version_graph,y,b,T]),F=x?z.rows:z.rows.slice(0,qs),N=z.allRows.filter(Y=>Y.hasImage).length,R=e.related_works||[],O=R.filter(Y=>Y.relation==="collected_in"),I=g.useMemo(()=>{const Y=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],ve=le=>{const Se=Y.indexOf(le??"");return Se<0?Y.length:Se};return R.filter(le=>le.relation!=="collected_in").map((le,Se)=>({r:le,i:Se})).sort((le,Se)=>ve(le.r.relation)-ve(Se.r.relation)||le.i-Se.i).map(le=>le.r)},[R]),P=g.useMemo(()=>{const Y=Fo(e.resources,e.resource_groups);return[...Y.mirrors.flatMap(ve=>ve.items.map(le=>({r:le,kind:p(ve.label)}))),...Y.buckets.flatMap(ve=>ve.items.map(le=>({r:le,kind:p(cx(ve.key,c))})))]},[e.resources,e.resource_groups,p,c]),G=e.indexed_by||[],K=e.emendated_by||[],L=g.useMemo(()=>{var te,ye,H;const Y=[],ve=(ye=(te=e.authors)==null?void 0:te[0])==null?void 0:ye.dynasty;ve&&Y.push({label:c("workPage.fact.written"),value:p(ve)});const le=$t(e,u.unit.juan);if(le){const se=(H=e.juan_count)==null?void 0:H.description;Y.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(le),se&&se!==le?t.jsxs("span",{className:"bim-d-meta",children:["(",p(se),")"]}):null]})})}e.loss_status&&Y.push({label:c("workPage.fact.loss"),value:p(lx(e.loss_status,c))});const Se=z.allRows.filter(se=>se.sortYear!=null),X=Se.length>0?Se.reduce((se,ne)=>se.sortYear<=ne.sortYear?se:ne):null;X!=null&&X.era.era?Y.push({label:c("workPage.fact.earliest"),value:p([X.era.era,X.era.reign].filter(Boolean).join(" ")),title:X.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):B&&Y.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),K.length&&Y.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:K.length})});const Ce=Xs(e.additional_titles);Ce.length&&Y.push({label:c("workPage.fact.alias"),value:Ce.map(p).join("、")});const Me=Xs(e.attached_texts);Me.length&&Y.push({label:c("workPage.fact.attached"),value:Me.map(p).join("、")});const M=(e.additional_works||[]).map(se=>p(se.book_title)+(se.n_juan!=null?` ${se.n_juan}${u.unit.juan}`:""));return M.length&&Y.push({label:c("workPage.fact.appendix"),value:M.join("、")}),Y},[e,p,c,u,B,z.allRows,K.length]),A=[{value:e._edition_count??h.length,label:c("workPage.stat.editions")},{value:C?N:0,label:c("workPage.stat.hasImage")},{value:G.length,label:c("workPage.stat.catalogs")}],U=e.classification,ce=U?[U.l1,U.l2,U.l3,U.l4].filter(Boolean).map(Y=>p(Y)):[],ee=e.subtype?u.workSubtype[e.subtype]??p(e.subtype):"",ue=t.jsx(Ln,{title:p(e.title),byline:t.jsx(xr,{authors:e.authors,onNavigate:o,renderLink:r}),meta:t.jsx(Ze,{items:[...ce,U!=null&&U.source?c("workPage.classifiedBy",{source:p(U.source.split("/")[0])}):"",ee]}),description:(Q=e.description)!=null&&Q.text?t.jsxs(t.Fragment,{children:[t.jsx(_t,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(fe=e.description.sources)!=null&&fe.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(Y=>p(zm(Y))).filter(Boolean).join(" · ")}):null]}):void 0,stats:A,facts:L,readAction:s,foot:t.jsx(An,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(ze=e.appendix)==null?void 0:ze.map((Y,ve)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(Y.title)}),t.jsx(_t,{text:Y.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},ve))}),de=z.eras.length>=2?[{key:"",label:c("catalog.all")},...z.eras.map(Y=>({key:Y,label:`${Y} ${z.allRows.filter(ve=>ve.era.era===Y).length}`}))]:[],be=[];h.length&&be.push({id:"versions",label:c("workPage.sec.versions"),count:h.length}),G.length&&be.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:G.length}),O.length&&be.push({id:"collected",label:c("workPage.sec.collected"),count:O.length}),I.length&&be.push({id:"related",label:c("workPage.sec.related"),count:I.length}),P.length&&be.push({id:"resources",label:c("workPage.sec.resources"),count:P.length});const Oe=h.length===0&&G.length===0,ie=t.jsxs(t.Fragment,{children:[h.length>0&&t.jsxs(Qe,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(Ze,{items:[c("workPage.versionsTotal",{n:h.length}),C&&N?c("workPage.versionsWithImage",{n:N}):"",z.rows.length!==z.allRows.length?c("workPage.versionsCurrent",{n:z.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":B&&de.length===0&&h.length>1?"":void 0,children:[de.length>0&&t.jsx(yi,{items:de,value:y,onChange:Y=>{_(Y),k(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx($l,{label:c("workPage.scanOnly"),checked:b,onChange:Y=>{j(Y),k(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(T?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&ji(z.rows.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("workPage.col.edition")}),t.jsx("th",{children:c("workPage.col.era")}),t.jsx("th",{children:c("workPage.col.holder")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:c("workPage.col.image")})})]})}),t.jsx("tbody",{children:F.map(Y=>{var ve;return t.jsx(px,{row:Y,measure:(ve=m.get(Y.id))==null?void 0:ve.measure_info,loaded:m.has(Y.id),onNavigate:o,renderLink:r},`${Y.id}:${m.has(Y.id)?"r":"p"}`)})})]}),F.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(y||b?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(Vo,{total:z.rows.length,shown:F.length,unit:c("workPage.moreUnit"),onClick:()=>k(!0)}),z.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),G.length>0&&t.jsx(ux,{items:G,transport:n,onNavigate:o,renderLink:r}),Oe&&t.jsx(Qe,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),Re=(Y,ve)=>t.jsx(Ke,{id:Y,label:p(ve),onNavigate:o,renderLink:r,dense:!0}),Le=g.useMemo(()=>{const Y=new Map;for(const ve of I){const le=Ks(ve.relation,c);Y.set(le,(Y.get(le)??0)+1)}return Y.size>1?[...Y.entries()].sort((ve,le)=>le[1]-ve[1]).slice(0,4).map(([ve,le])=>`${p(ve)} ${le}`).join(" · "):void 0},[I,p,c]),q=t.jsxs(t.Fragment,{children:[t.jsx(Dt,{id:"collected",title:c("workPage.sec.collected"),items:O.map(Y=>Re(Y.id,Y.title))}),t.jsx(Dt,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:I.length}),sub:Le,items:I.map(Y=>t.jsxs(t.Fragment,{children:[Re(Y.id,Y.title),t.jsx("span",{className:"bim-d-meta",title:Y.note?p(Y.note):void 0,children:p(Ks(Y.relation,c))})]}))}),t.jsx(Dt,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:P.map(({r:Y,kind:ve})=>{const le=p((Y.url?dn(Y.url):void 0)||Y.name),Se=pn(Y);return t.jsxs(t.Fragment,{children:[Se?t.jsxs("a",{href:Se,target:"_blank",rel:"noopener noreferrer",children:[le," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:le}),ve&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:ve})]})})})]});return t.jsx(Rn,{railTop:a,back:l,nav:be,railLinks:d,main:ie,card:ue,side:q})};function Xs(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function Zs(e,n){return n((e.url?dn(e.url):void 0)||e.name)}function px({row:e,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{t:a,convert:l}=J(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],u=p?Zs(p,l):e.locationName?l(e.locationName):"",h=e.images[0],m=h?pn(h):void 0,f=e.images.map(x=>Zs(x,l)).join("、");return t.jsxs("tr",{"data-loading":o?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Ke,{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&&(m?t.jsx("a",{className:"bim-d-flag",href:m,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 ux({items:e,transport:n,onNavigate:o,renderLink:r}){const{t:s,convert:a}=J(),[l,d]=g.useState(0),c=Math.min(l,e.length-1),p=e[c],[u,h]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const m=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(m.length===0)return;let f=!1;return Promise.all(m.map(x=>n.getItem(x).then(k=>{var y,_;return[x,((_=(y=k==null?void 0:k.authors)==null?void 0:y[0])==null?void 0:_.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{f||h(new Map(x.filter(([,k])=>k)))}),()=>{f=!0}},[n,e]),t.jsx(Qe,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(Ze,{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((m,f)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":f===c,"aria-label":a(m.source),onClick:()=>d(f),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(m.source_bid??"")?a(u.get(m.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(m.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(Ze,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(Ke,{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:pt(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:pt(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:pt(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 mx(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 hx(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 Js(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 gx(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 fx(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,h]of Object.entries(e.node_groups))l.has(h)&&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 ei(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=fx(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,h=new Set,m=new Set;if(c){const w=new Map(n.map(T=>[T.id,T])),v=new Map((r.hypothetical_nodes??[]).map(T=>[T.id,T])),$=T=>{const z=w.get(T);if(z&&z.lineage)return(z.lineage.derived_from??[]).map(N=>N.ref);const F=v.get(T);return F?(F.derived_from??[]).map(N=>N.ref):[]},S=T=>v.has(T)?!u||u.has(T):!p||p.has(T),C=new Set,B=T=>{if(!C.has(T)){C.add(T);for(const z of $(T))a.has(z)||(S(z)||(v.has(z)?m.add(z):w.has(z)&&h.add(z)),B(z))}};for(const T of n)p&&p.has(T.id)&&!a.has(T.id)&&B(T.id);for(const T of r.hypothetical_nodes??[])u&&u.has(T.id)&&B(T.id)}const f=n.filter(w=>!a.has(w.id)).filter(w=>!p||p.has(w.id)||h.has(w.id)).map(w=>{const v=hx(w,l);return v&&h.has(w.id)&&(v.bridge=!0),v}).filter(w=>w!==null),x=(r.hypothetical_nodes??[]).filter(w=>!u||u.has(w.id)||m.has(w.id)).map(w=>{const v=mx(w);return m.has(w.id)&&(v.bridge=!0),v}),k=[...f,...x],y=new Set(k.map(w=>w.id)),_=new Set,b=[],j=w=>{_.has(w.id)||!y.has(w.source)||!y.has(w.target)||(_.add(w.id),b.push(w))};for(const w of n)a.has(w.id)||!w.lineage||p&&!p.has(w.id)&&!h.has(w.id)||((w.lineage.derived_from??[]).forEach((v,$)=>{j(Js(w.id,v,$))}),(w.lineage.related_to??[]).forEach((v,$)=>{j(gx(w.id,v,$))}));for(const w of r.hypothetical_nodes??[])u&&!u.has(w.id)&&!m.has(w.id)||(w.derived_from??[]).forEach((v,$)=>{j(Js(w.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 zc(e,n,o){const r=(e??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function xx(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 Tc=({graph:e,renderLink:n,className:o,style:r})=>{const{t:s,convert:a}=J();if(!e.nodes.length)return t.jsx("div",{style:{...Ex,...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 h=(f,x)=>(f.year??9999)-(x.year??9999);p.forEach(f=>f.sort(h)),u.sort(h);const m=e.groups.filter(f=>p.has(f.id));return t.jsxs("div",{className:o,style:{...yx,...r},children:[e.title&&t.jsx("div",{style:jx,children:a(e.title)}),e.description&&t.jsx("div",{style:vx,children:a(e.description)}),m.map(f=>t.jsx(Qs,{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(Qs,{label:s("lineage.otherGroup"),nodes:u,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},Qs=({label:e,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=J();return t.jsxs("div",{style:kx,children:[t.jsx("div",{style:{...wx,borderLeftColor:n??i("widget-border")},children:d(e)}),o.map(c=>t.jsx(bx,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},bx=({node:e,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=J();return t.jsxs("div",{style:{...Sx,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:_x,children:[t.jsx("span",{style:$x,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Cx,children:zc(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:zx,children:[e.category&&t.jsx(wn,{children:c(e.category)}),e.status==="lost"&&t.jsx(wn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(wn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(wn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(wn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:Tx,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:Nx,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:ta,children:[t.jsx("div",{style:na,children:d("lineage.sources")}),n.map(p=>{const u=r.get(p.source);return t.jsxs("div",{style:ia(p.confidence),children:[t.jsx("span",{style:oa,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(ea,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ra,children:["· ",c(p.evidence)]})]},p.id)})]}),o.length>0&&t.jsxs("div",{style:ta,children:[t.jsx("div",{style:na,children:d("lineage.related")}),o.map(p=>{const u=p.source===e.id?p.target:p.source,h=r.get(u);return t.jsxs("div",{style:ia(p.confidence),children:[t.jsx("span",{style:oa,children:c(p.relation)}),t.jsx("span",{children:(h==null?void 0:h.kind)==="book"&&s?s(h.id,c(h.label)):c((h==null?void 0:h.label)??u)}),t.jsx(ea,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:ra,children:["· ",c(p.evidence)]})]},p.id)})]})]})},wn=({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})},ea=({level:e})=>{const{t:n}=J(),r={certain:{key:"certain",color:i("confidence-certain")},consensus:{key:"consensus",color:i("confidence-consensus")},probable:{key:"probable",color:i("confidence-probable")},disputed:{key:"disputed",color:i("confidence-disputed")}}[e];return r?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${r.color}`,color:r.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${r.key}`)}):null},yx={fontSize:"14px",color:i("fg")},jx={fontSize:"16px",fontWeight:600,marginBottom:"8px"},vx={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},kx={marginBottom:"16px"},wx={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},Sx={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},_x={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},$x={fontSize:"15px",fontWeight:600},Cx={fontSize:"12px",color:i("muted")},zx={marginBottom:"6px"},Tx={fontSize:"12px",color:i("muted"),margin:"2px 0"},Nx={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},ta={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},na={fontSize:"11px",color:i("muted"),marginBottom:"2px"},ia=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),oa={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},ra={fontSize:"11px",color:i("muted")},Ex={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},Nc=({selectedNodeId:e,...n})=>{const{t:o}=J(),[r,s]=g.useState("loading"),[a,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return Ix().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),r==="loading"?t.jsx("div",{style:aa,children:o("lineage.graphLoading")}):r==="missing"||!a?t.jsxs("div",{style:aa,children:[t.jsx("div",{children:sa(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:sa(o("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(Rx,{modules:a,selectedNodeId:e,...n})};function sa(e,n){return e.split(/(\{\w+\})/).map((o,r)=>{const s=/^\{(\w+)\}$/.exec(o);return t.jsx(g.Fragment,{children:s&&s[1]in n?n[s[1]]:o},r)})}async function Ix(){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 Rx=({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:h,BaseEdge:m,EdgeLabelRenderer:f,getSmoothStepPath:x,dagre:k}=l,y=g.useMemo(()=>({lineage:$=>{var I,P,G,K;const S=((I=$.data)==null?void 0:I.stepPosition)??.85,[C,B,T]=x({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:S,borderRadius:5}),z=!!((P=$.data)!=null&&P.isSibling),F=z?B:$.targetX-18,N=z?T:$.targetY-12,R=(G=$.data)==null?void 0:G.labelStyle,O=(K=$.data)==null?void 0:K.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(m,{id:$.id,path:C,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(f,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F}px,${N}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...O,...R},children:$.label})})]})}}),[m,f,x]),_=g.useMemo(()=>({version:$=>{const{t:S}=J(),C=$.data,B=C.kind==="hypothetical",T=C.status==="lost",z=C.isSelected,F=C.bridge,N=C.borderColor??i("muted"),R=F||B?"dashed":"solid",O=F?.5:T?.6:1;return t.jsxs("div",{style:{background:i(F?"bg-subtle":"bg"),border:`2px ${R} ${z?i("primary"):N}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:O,boxShadow:z?i("shadow-node-selected"):B||F?"none":i("shadow-node")},title:F?S("lineage.bridgeTitle"):void 0,children:[t.jsx(u,{type:"target",position:h.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:B||!C.renderLink?C.label:C.renderLink(C.bookId,C.label)}),C.description&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:C.description}),C.yearText&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:zc(C.yearText,void 0,C.uncertain)}),T&&t.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:S("lineage.lost")}),t.jsx(u,{type:"source",position:h.Right,style:{visibility:"hidden"}})]})}}),[u,h]),{convert:b}=J(),{rfNodes:j,rfEdges:w}=g.useMemo(()=>Lx(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:w,nodeTypes:_,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 Lx(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(_=>[_.id,_.color??i("muted")]));for(const _ of e.nodes)c.setNode(_.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const _ of e.edges)_.kind==="derive"&&(u.has(_.relation)||c.setEdge(_.source,_.target));n.layout(c);const h=e.nodes.map(_=>{const b=c.node(_.id),j=r?_.id===r:void 0,w={kind:_.kind,label:s(_.label),bookId:_.kind==="book"?_.id:void 0,yearText:s(_.year_text??Px(_)),uncertain:_.year_uncertain,category:_.category,status:_.status,borderColor:_.group?p.get(_.group):void 0,renderLink:o,isSelected:j,description:s(_.description),bridge:_.bridge};return{id:_.id,type:"version",position:{x:b.x-160/2,y:b.y-90/2},data:w,draggable:!1,selected:j}}),m=.78,f=.06,x=new Map;for(const _ of e.edges)_.kind==="derive"&&(x.has(_.source)||x.set(_.source,[]),x.get(_.source).push(_));const k=new Map;for(const[_,b]of x){if(b.length<=1)continue;const j=[...b].sort((v,$)=>{var B,T;const S=((B=c.node(v.target))==null?void 0:B.y)??0,C=((T=c.node($.target))==null?void 0:T.y)??0;return S-C}),w=j.length;j.forEach((v,$)=>{const S=($-(w-1)/2)*f;k.set(v.id,m+S)})}const y=e.edges.map(_=>Ax(_,k.get(_.id),s));return{rfNodes:h,rfEdges:y}}function Ax(e,n,o=r=>r??""){const r=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=Mx(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 Px(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Mx(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 aa={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},yr=({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:h})=>{var w;const{t:m,convert:f}=J(),[x,k]=g.useState(n),y=v=>{k(v),a==null||a(v)},_=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:m("lineage.collectionAll"),description:m("lineage.collectionAllDesc")}]]})(),b=!!(d&&_.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:m("lineage.empty")});const j=l?(w=c==null?void 0:c[l])==null?void 0:w.description:void 0;return t.jsxs("div",{className:u,style:h,children:[t.jsxs("div",{style:Bx,children:[t.jsx("button",{onClick:()=>y("list"),style:qi(x==="list"),children:m("lineage.modeList")}),t.jsx("button",{onClick:()=>y("graph"),style:qi(x==="graph"),children:m("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:m("lineage.collectionLabel")}),_.map(([v,$])=>{const S=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:qi(l===v),title:$.description?f($.description):void 0,children:[f($.label),S!=null?` ${S}`:""]},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(Tc,{graph:e,renderLink:o}):t.jsx(Nc,{graph:e,renderLink:o,height:r,selectedNodeId:s})]})},Bx={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},qi=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"}),la=40,ca=2,Wx=9,Ox=new Set(["certain","consensus","probable","disputed"]);function Xi(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const Ec=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:u})=>{var H,se,ne,ge,Ne,Be,We,Ue,Je,me,et;const h=$e(),{t:m,convert:f}=J(),[x,k]=g.useState(null),[y,_]=g.useState(new Map),[b,j]=g.useState([]),[w,v]=g.useState(new Map),[$,S]=g.useState(!1),[C,B]=g.useState("flow"),[T,z]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){k(null);return}let E=!1;return n.getItem(e.work_id).then(oe=>{!E&&oe&&oe.type==="work"&&k(oe)}).catch(()=>{}),()=>{E=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){z(null);return}let E=!1;return n.getLineageGraph(e.work_id).then(oe=>{E||z(oe&&oe.nodes.length>1?oe:null)}).catch(()=>{E||z(null)}),()=>{E=!0}},[n,e.work_id]),g.useEffect(()=>{const E=e.contained_in||[];if(!n||E.length===0){_(new Map);return}let oe=!1;return Promise.all(E.map(ae=>{const je=typeof ae=="string"?ae:ae.id;return n.getItem(je).then(ke=>[je,ke]).catch(()=>[je,null])})).then(ae=>{if(oe)return;const je=new Map;for(const[ke,xe]of ae)xe&&je.set(ke,xe);_(je)}),()=>{oe=!0}},[n,e.contained_in]);const F=g.useMemo(()=>{const E=new Set([...(x==null?void 0:x.books)||[],...e.related_books||[]]);return E.add(e.id),[...E]},[x==null?void 0:x.books,e.related_books,e.id]),N=F.length-1;g.useEffect(()=>{if(!n||N<=0){j([]);return}const E=F.length<=la,oe=E?F:F.slice(0,8);let ae=!1;return Promise.all(oe.map(je=>je===e.id?Promise.resolve({id:je,title:e.title,edition:e.edition,year:ii(e)}):n.getItem(je).then(ke=>{const xe=ke??{};return{id:je,title:xe.title,edition:xe.edition,year:ke?ii(xe):void 0}}).catch(()=>({id:je})))).then(je=>{if(ae)return;const ke=je.filter(xe=>xe.id===e.id||xe.title||xe.edition);E&&ke.sort((xe,V)=>(xe.year??1/0)-(V.year??1/0)),j(ke)}),()=>{ae=!0}},[n,F,N,e]);const R=e.lineage,O=g.useMemo(()=>[...((R==null?void 0:R.derived_from)||[]).filter(E=>E.ref_type==="book").map(E=>E.ref),...((R==null?void 0:R.related_to)||[]).map(E=>E.book_id)].filter(Boolean),[R]);g.useEffect(()=>{if(!n||O.length===0){v(new Map);return}let E=!1;return Promise.all(O.map(oe=>n.getItem(oe).then(ae=>[oe,{id:oe,title:ae==null?void 0:ae.title,edition:ae==null?void 0:ae.edition}]).catch(()=>[oe,{id:oe}]))).then(oe=>{E||v(new Map(oe))}),()=>{E=!0}},[n,O]);const I=g.useMemo(()=>Sc(e.resources,e.resource_groups,m),[e.resources,e.resource_groups,m]),P=I.groups.reduce((E,oe)=>E+oe.rows.length+oe.mirrors.length,0),G=I.groups.length>0&&I.groups.every(E=>E.key==="_physical"),K=In(e),L=Sl(e),Z=$t(e,h.unit.juan),A=new Set((e.contained_in||[]).map(E=>typeof E=="string"?0:zn(E.volume_index).length).filter(E=>E>0)),U=E=>{var je;const oe=(je=e.base_edition)==null?void 0:je.find(ke=>ke.book_id===E&&ke.name);if(oe!=null&&oe.name)return oe.name;const ae=w.get(E);return(ae==null?void 0:ae.edition)||(ae==null?void 0:ae.title)||""},ce=g.useMemo(()=>{var Te,Ee,D,re,Pe;const E=[];L&&E.push({label:m("bookPage.fact.editionType"),value:f(L),title:e.edition_type||(Te=e.lineage)!=null&&Te.category?void 0:m("bookPage.inferredFromEdition")}),(Ee=e.publication_info)!=null&&Ee.details?E.push({label:m("bookPage.fact.publication"),value:f(e.publication_info.details)}):(K.era||K.reign)&&E.push({label:m("bookPage.fact.era"),value:f([K.era,K.reign].filter(Boolean).join(" ")),title:K.source==="edition"?m("bookPage.inferredFromEdition"):void 0}),Z&&E.push({label:m("bookPage.fact.measure"),value:f(Z)});const oe=(e.contained_in||[]).flatMap(_e=>typeof _e=="string"?[]:zn(_e.volume_index));oe.length&&E.push({label:m("bookPage.fact.volumes"),value:m("bookPage.volumesValue",{range:bi(oe,h.unit.volume),unit:h.unit.volume,n:oe.length})});const ae=(((D=e.lineage)==null?void 0:D.derived_from)||[]).find(_e=>_e.relation==="底本"&&_e.ref_type==="book");ae&&U(ae.ref)&&E.push({label:m("bookPage.fact.baseEdition"),value:t.jsx(Ke,{id:ae.ref,label:f(U(ae.ref)),onNavigate:o,renderLink:r,dense:!0})});const je=(e.base_edition||[]).filter(_e=>_e&&_e.name);for(const _e of["底本","配補","參校"]){if(_e==="底本"&&ae&&U(ae.ref))continue;const Ge=je.filter(He=>He.role===_e);Ge.length&&E.push({label:f(_e),value:Ge.map((He,Fe)=>t.jsxs(g.Fragment,{children:[Fe>0&&"、",He.book_id?t.jsx(Ke,{id:He.book_id,label:f(He.name),onNavigate:o,renderLink:r,dense:!0}):f(He.name)]},Fe))})}const ke=(e.provenance||[]).filter(_e=>_e&&_e.institution),xe=(e.resources||[]).filter(_e=>(_e.types||(_e.type?[_e.type]:[])).includes("physical"));if(ke.length){E.push({label:m("bookPage.fact.holdings"),value:ke.slice(0,2).map(He=>f(He.institution)).join("、")+(ke.length>2?m("bookPage.andMorePlaces",{n:ke.length}):"")});const _e=ke.filter(He=>He.call_number).slice(0,2).map(He=>`${f(He.institution)} ${He.call_number}`);_e.length&&E.push({label:m("bookPage.fact.callNumber"),value:_e.join(";")+(ke.filter(He=>He.call_number).length>2?"…":"")});const Ge=ke.flatMap(He=>He.seals||[]).filter(Boolean);Ge.length&&E.push({label:m("bookPage.fact.seals"),value:f(Ge.join("、"))})}else xe.length?E.push({label:m("bookPage.fact.holdings"),value:xe.slice(0,2).map(_e=>f(_e.name)).join("、")+(xe.length>2?m("bookPage.andMorePlaces",{n:xe.length}):"")}):(re=e.current_location)!=null&&re.name&&E.push({label:m("bookPage.fact.holdings"),value:f(e.current_location.name)});const V=e.physical_description;if(V){const _e=[[m("bookPage.fact.leafStyle"),V.leaf_style],[m("bookPage.fact.binding"),V.binding],[m("bookPage.fact.dimensions"),V.dimensions],[m("bookPage.fact.condition"),V.condition]];for(const[Ge,He]of _e)He&&He.trim()&&E.push({label:Ge,value:f(He)})}(Pe=e.page_count)!=null&&Pe.description&&E.push({label:h.label.pageCount,value:f(e.page_count.description)});const pe=[...ho(e.additional_titles),...ho(e.attached_texts)];return pe.length&&E.push({label:m("bookPage.fact.aliases"),value:pe.map(f).join("、")}),E},[e,f,h,m,K,L,Z,w,o,r]),ee=f(e.title),ue=e.edition?f(e.edition):void 0,de=((H=e.lineage)==null?void 0:H.year_text)||"",be=t.jsx(Ln,{kind:m("bookPage.kind"),title:ee,subtitle:ue,byline:t.jsx(xr,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:o,renderLink:r}),meta:(()=>{const E=[L?f(L):"",K.era?f([K.era,K.reign].filter(Boolean).join("")):"",Z?f(Z):""].filter(Boolean);return E.length?t.jsx("span",{className:"bim-d-tags",children:E.map((oe,ae)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(ae,2)}`,children:oe},ae))}):null})(),description:(se=e.description)!=null&&se.text?t.jsx(_t,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Yo((ne=e.description)==null?void 0:ne.text)?6:void 0,facts:ce,readAction:s,secondaryAction:s&&P>0&&!G?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:m("bookPage.viewImages")}):void 0,foot:t.jsx(An,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),Oe=e.contained_in||[],ie=(a==null?void 0:a.chapters)||[],Re=f(ie[0]&&Xi(ie[0].title)[0].slice(-1)||"")||m("bookPage.chapterUnit"),Le=m("bookPage.chapterCount",{n:ie.length,unit:Re}),q=!!((ge=R==null?void 0:R.derived_from)!=null&&ge.length||(Ne=R==null?void 0:R.related_to)!=null&&Ne.length||(Be=e.appendix)!=null&&Be.length),Q=[],fe=m(G?"bookPage.sec.physical":"bookPage.sec.images");(ie.length||I.text.length||l)&&Q.push({id:"fulltext",label:m("bookPage.sec.fulltext"),count:ie.length?Le:void 0}),I.groups.length&&Q.push({id:"images",label:fe,count:P}),q&&Q.push({id:"lineage",label:m("bookPage.sec.lineage")}),Oe.length&&Q.push({id:"collections",label:m("section.containedIn"),count:Oe.length}),(We=e.location_history)!=null&&We.length&&Q.push({id:"provenance",label:m("section.locationHistory")});const ze=E=>(d==null?void 0:d(E))??null,Y=ie[0],ve=Y?ze(Y.file):null,le=$?ie:ie.slice(0,Wx),Se=(E,oe,ae)=>E?t.jsx("a",{className:ae,href:E.href??"#",onClick:E.onClick?je=>{je.metaKey||je.ctrlKey||(je.preventDefault(),E.onClick())}:void 0,children:oe}):t.jsx("span",{className:ae,children:oe}),X=t.jsxs(t.Fragment,{children:[(ie.length>0||I.text.length>0||l)&&t.jsxs(Qe,{id:"fulltext",title:m("bookPage.sec.fulltext"),meta:ie.length>0?t.jsx(Ze,{items:[Le,(Ue=a==null?void 0:a.source)!=null&&Ue.name?m("bookPage.sourceBy",{src:f(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!Y&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-d-ft","aria-busy":"true",children:[t.jsx("span",{className:"bim-d-ft-h",children:" "}),t.jsx("span",{className:"bim-d-meta",children:" "})]}),t.jsx("div",{className:"bim-d-chap-pending","aria-hidden":"true"})]}),Y&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:m("bookPage.readFrom",{ch:f(Xi(Y.title)[0])||m("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:f((Y.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),Se(ve,t.jsxs(t.Fragment,{children:[m("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),ie.length>1&&t.jsx("ul",{className:"bim-d-chap",children:le.map(E=>{const[oe,ae]=Xi(E.title);return t.jsx("li",{children:Se(ze(E.file),t.jsxs(t.Fragment,{children:[oe&&t.jsx("b",{children:f(oe)}),f(ae||E.file)]}))},E.file)})}),ie.length>le.length&&t.jsx(Go,{label:m("detail.expandRest",{n:ie.length-le.length,unit:Re}),onClick:()=>S(!0)}),I.text.length>0&&t.jsxs(t.Fragment,{children:[(ie.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:m("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:I.text.map((E,oe)=>t.jsx(br,{item:E,siblings:I.text,listedVolumeCounts:A},`${E.id||E.url||E.name}-${oe}`))})})]})]}),I.groups.length>0&&t.jsx(Qe,{id:"images",title:fe,meta:t.jsx(Ze,{items:[I.groups.length>1?m("bookPage.groupCount",{n:I.groups.length}):"",m("bookPage.placeCount",{n:P})]}),children:t.jsx($c,{groups:I.groups,listedVolumeCounts:A})}),q&&t.jsx(Qe,{id:"lineage",title:m("bookPage.sec.lineage"),meta:(Je=R==null?void 0:R.derived_from)!=null&&Je.length?m("bookPage.lineageMeta"):void 0,action:T?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":m("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":C==="flow",onClick:()=>B("flow"),children:m("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":C==="graph",onClick:()=>B("graph"),children:m("bookPage.viewGraph")})]}):void 0,children:C==="graph"&&T?t.jsx(yr,{graph:T,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(E,oe)=>t.jsx(Ke,{id:E,label:f(oe),onNavigate:o,renderLink:r,dense:!0})}):t.jsx(Fx,{data:e,heading:ue||ee,yearText:de,refName:U,onNavigate:o,renderLink:r})}),Oe.length>0&&t.jsx(Qe,{id:"collections",title:m("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:Oe.map((E,oe)=>{var V,pe;const ae=typeof E=="string"?E:E.id,je=typeof E=="string"?[]:zn(E.volume_index),ke=y.get(ae),xe=(ke==null?void 0:ke._member_count)||((V=ke==null?void 0:ke.books)==null?void 0:V.length)||((pe=ke==null?void 0:ke.contained_works)==null?void 0:pe.length)||0;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Ke,{id:ae,label:ke?f(ke.title):ae,onNavigate:o,renderLink:r,dense:!0}),je.length>0&&t.jsx(Hx,{volumes:je,unit:h.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${xe?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:xe>0&&m("bookPage.totalOf",{n:xe,unit:h.unit.bu})})]},`${ae}-${oe}`)})})})}),(me=e.location_history)!=null&&me.length?t.jsx(Qe,{id:"provenance",title:m("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((E,oe)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:f(E.name)}),([E.start_date,E.end_date].filter(Boolean).join("—")||E.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(Ze,{items:[[E.start_date,E.end_date].filter(Boolean).join("—"),E.description?f(E.description):""]})})]},oe))})}):null,Q.length===0&&t.jsx(Qe,{title:m("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:m("bookPage.emptyText")})})]}),Ce=b.findIndex(E=>E.id===e.id),Me=F.length<=la,M=Me&&Ce>=0?b.slice(Math.max(0,Ce-ca),Ce+ca+1):b.filter(E=>E.id!==e.id),te=t.jsxs(t.Fragment,{children:[x&&t.jsxs("div",{id:"work",className:"bim-d-side",style:{scrollMarginTop:16},children:[t.jsx("h2",{className:"bim-d-ui bim-d-side-h",children:f(h.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(Ke,{id:x.id,label:f(x.title),onNavigate:o,renderLink:r})}),t.jsx(Ze,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(E=>`${E.dynasty?`〔${f(E.dynasty)}〕`:""}${f(E.name)}`),f($t(x,h.unit.juan)),x._edition_count?m("bookPage.editionCount",{n:x._edition_count}):""]}),((et=x.description)==null?void 0:et.text)&&t.jsx("p",{style:{margin:"8px 0 0",fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc",children:f(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),N>0&&M.length>0&&t.jsxs("div",{children:[t.jsx(Dt,{id:"siblings",timeline:!0,title:Me?m("bookPage.siblings"):h.relation.siblingVersions,meta:Me?m("bookPage.byEra"):m("bookPage.kindCount",{n:N}),cap:M.length,items:M.map(E=>E.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:f(E.edition||E.title||E.id)}):t.jsx(Ke,{id:E.id,label:f(E.edition||E.title||E.id),onNavigate:o,renderLink:r,dense:!0})),metas:M.map(E=>[E.year!=null?E.year<0?m("detail.bce",{n:-E.year}):String(E.year):"",E.id===e.id?m("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:M.findIndex(E=>E.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(Ke,{id:x.id,label:m("bookPage.viewAllInWork",{n:F.length}),onNavigate:o,renderLink:r,dense:!0})})]})]}),ye=e.work_id?t.jsx(_l,{caption:h.section.belongsToWork,children:t.jsx(Ke,{id:e.work_id,label:x?f(x.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return t.jsx(Rn,{railTop:c,back:p,up:ye,nav:Q,railLinks:u,main:X,card:be,side:te})};function Hx({volumes:e,unit:n}){const{t:o}=J();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o("bookPage.volumeRange",{range:bi(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 Fx({data:e,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:a}){var _;const{t:l,convert:d}=J(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],u=p.filter(b=>b.ref_type!=="book"),h=p.filter(b=>b.ref_type==="book"&&b.relation==="底本"),m=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&&Ox.has(b)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${b}`)}):"",y=(b,j)=>t.jsx(Ke,{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}`)),h.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)})]}),m.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:m.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))})]})]}),(_=e.appendix)==null?void 0:_.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(_t,{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 Sn=16,Dx=200,Ux=16,Ic=({data:e,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var Se,X,Ce,Me,M,te,ye;const{t:p,convert:u,messages:h}=J(),[m,f]=g.useState(""),[x,k]=g.useState(!1),[y,_]=g.useState(null),[b,j]=g.useState(""),[w,v]=g.useState(!1),$=g.useMemo(()=>kl(e,n),[e,n]),[S,C]=g.useState(new Map),B=!!o&&$.rows.length>0&&$.rows.length<=Dx,T=B&&($.rows.length<=Sn||w),z=T&&$.rows.every(H=>!H.id||S.has(H.id)),F=H=>{var se;return ko(H?(se=S.get(H))==null?void 0:se.l1:void 0)},N=g.useMemo(()=>{const H=m.trim(),se=H?u(H):"";return $.rows.filter(ne=>{var Ne,Be;if(b&&ko(ne.id?(Ne=S.get(ne.id))==null?void 0:Ne.l1:void 0)!==b)return!1;if(!se)return!0;const ge=ne.id&&((Be=S.get(ne.id))==null?void 0:Be.title)||ne.title;return u(ge).includes(se)||(ne.subItems||[]).some(We=>u(We).includes(se))})},[$.rows,m,b,S,u]),R=x?N:N.slice(0,Sn),O=g.useMemo(()=>(T?$.rows:R).filter(H=>H.id&&!S.has(H.id)).map(H=>H.id),[T,$.rows,R,S]);g.useEffect(()=>{if(!o||O.length===0)return;let H=!1;const se=O.slice(0,Ux);return Promise.all(se.map(ne=>o.getItem(ne).then(ge=>{var We,Ue;const Ne=ge??{},Be={title:Ne.title,edition:Ne.edition,authors:Ne.authors,measure:ge?$t(ge,h.unit.juan):void 0,versionCount:Ne._edition_count??((We=Ne.books)==null?void 0:We.length),l1:((Ue=Ne.classification)==null?void 0:Ue.l1)||void 0};return[ne,Be]}).catch(()=>[ne,{}]))).then(ne=>{H||C(ge=>{const Ne=new Map(ge);for(const[Be,We]of ne)Ne.set(Be,We);return Ne})}),()=>{H=!0}},[o,O,h.unit.juan]);const I=(e.contained_in||[])[0];g.useEffect(()=>{if(!I){_(null);return}if(_({id:I}),!o)return;let H=!1;return o.getItem(I).then(se=>{H||_({id:I,title:se==null?void 0:se.title})}).catch(()=>{}),()=>{H=!0}},[o,I]);const P=g.useMemo(()=>Sc(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),G=P.text.length+P.groups.reduce((H,se)=>H+se.rows.length+se.mirrors.length,0),K=e.contained_works||[],L=new Set($.rows.map(H=>H.id).filter(Boolean)),Z=K.length>0&&!K.every(H=>L.has(H.id)),A=(()=>{const H=$.rows.map(se=>se.edition).filter(Boolean);return H.length>1&&new Set(H).size===1})(),U=$.rows.some(H=>H.volumes.length>0||H.expected!=null),ce=e._member_count||((Se=e.books)==null?void 0:Se.length)||K.length,ee=$t(e,h.unit.juan),ue=e.count,de=H=>typeof H=="number"&&Number.isFinite(H)?H:null,be=de(ue==null?void 0:ue.juan)??de((X=e.juan_count)==null?void 0:X.number),Oe=de(ue==null?void 0:ue.ce)??($.totalVolumes||null),ie=[{value:$.rows.length,label:p("collectionPage.stat.titles")},{value:be??0,label:h.unit.juan},{value:Oe??0,label:h.unit.volume}],Re=g.useMemo(()=>{var ne,ge;const H=[];if((ne=e.publication_info)!=null&&ne.details&&H.push({label:p("collectionPage.fact.publication"),value:u(e.publication_info.details)}),ce&&ce!==$.rows.length){const Ne=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");H.push({label:Ne,value:`${ce} ${h.unit.bu}`,title:p("collectionPage.memberNote")})}const se=[de(ue==null?void 0:ue.zhong)!=null?p("collectionPage.nZhong",{n:ue.zhong}):"",de(ue==null?void 0:ue.han)!=null?p("collectionPage.nHan",{n:ue.han}):""].filter(Boolean);return se.length&&H.push({label:p("collectionPage.fact.expected"),value:se.join(" ")}),be==null&&ee&&H.push({label:p("collectionPage.fact.measure"),value:u(ee),title:(ge=e.juan_count)!=null&&ge.description?u(e.juan_count.description):void 0}),H},[e,ce,$.rows.length,be,ee,ue,u,p,h]),Le=g.useMemo(()=>{if(!z)return[];const H=new Map;for(const ne of $.rows){const ge=F(ne.id);ge&&H.set(ge,(H.get(ge)??0)+1)}const se=Nn.filter(ne=>(H.get(ne.key)??0)>0);return se.length<2?[]:[{key:"",label:`${h.catalog.all} ${$.rows.length}`},...se.map(ne=>({key:ne.key,label:`${ne.label} ${H.get(ne.key)}`}))]},[z,$.rows,S,h]),q=g.useMemo(()=>{if(!z||!$.rows.some(ge=>ge.volumes.length>0))return null;const H=[],se=$.rows.filter(ge=>ge.volumes.length>0).map(ge=>({k:F(ge.id)??"",from:Math.min(...ge.volumes),to:Math.max(...ge.volumes)})).sort((ge,Ne)=>ge.from-Ne.from);for(const ge of se){const Ne=ge.to-ge.from+1,Be=H[H.length-1];Be&&Be.key===ge.k?(Be.to=Math.max(Be.to,ge.to),Be.n+=Ne):H.push({key:ge.k,from:ge.from,to:ge.to,n:Ne})}const ne=se.reduce((ge,Ne)=>Math.max(ge,Ne.to),0);return H.length>1&&H.some(ge=>ge.key)?{segs:H,last:ne}:null},[z,$.rows,S]),Q=(Ce=e.description)==null?void 0:Ce.text,fe=t.jsx(Ln,{kind:p("collectionPage.kind"),title:u(e.title),byline:t.jsx(xr,{authors:e.authors,onNavigate:r,renderLink:s}),meta:t.jsx(Ze,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Me=e.publication_info)!=null&&Me.year?u(e.publication_info.year):""]}),description:Q||(M=e.history)!=null&&M.length?t.jsxs(t.Fragment,{children:[Q&&t.jsx(_t,{text:Q,style:{fontSize:15,lineHeight:1.85}}),(te=e.history)!=null&&te.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((H,se)=>t.jsx("li",{children:u(H)},se))}):null]}):void 0,clampDescription:Yo(Q)||(((ye=e.history)==null?void 0:ye.length)??0)>2?6:void 0,stats:ie,facts:Re,foot:t.jsx(An,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:q&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:p("collectionPage.dist.head")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":p("collectionPage.dist.head"),children:q.segs.map((H,se)=>{const ne=Nn.find(ge=>ge.key===H.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!ne,title:ne?p("collectionPage.dist.segTitle",{section:u(ne.label),from:H.from,to:H.to}):void 0,"aria-label":ne?p("collectionPage.dist.only",{section:u(ne.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!ne&&b===H.key,style:{flexGrow:H.n,background:i(ne?ne.token:"rule")},onClick:()=>{ne&&(j(b===H.key?"":H.key),k(!1))}},se)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:p("catalog.volume",{n:1})}),t.jsx("span",{children:p("collectionPage.dist.hint")}),t.jsx("span",{children:p("catalog.volume",{n:q.last})})]})]})}),ze=[];$.rows.length&&ze.push({id:"titles",label:p("collectionPage.sec.titles"),count:$.rows.length}),G&&ze.push({id:"resources",label:p("collectionPage.sec.resources"),count:G}),Z&&ze.push({id:"works",label:h.section.containedWorks,count:K.length});const Y=t.jsxs(t.Fragment,{children:[$.rows.length>0&&t.jsxs(Qe,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(Ze,{items:[`${$.rows.length} ${h.unit.items}`,$.totalVolumes?p("collectionPage.totalVolumes",{n:$.totalVolumes,unit:h.unit.volume}):"",N.length!==$.rows.length?p("collectionPage.currentN",{n:N.length,unit:h.unit.items}):""]}),action:a,children:[($.rows.length>Sn||Le.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Le.length>0&&t.jsx(yi,{items:Le,value:b,onChange:H=>{j(H),k(!1)}}),B&&$.rows.length>Sn&&!z&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:w,onClick:()=>v(!0),title:p("collectionPage.loadAllTitle",{n:$.rows.length,unit:h.unit.items}),children:p(w?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),$.rows.length>Sn&&t.jsx("input",{type:"search",className:"bim-d-find",value:m,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:H=>{f(H.target.value),k(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&ji(N.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[U&&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:R.map((H,se)=>{var Je;const ne=H.id?S.get(H.id):void 0,ge=ne!=null&&ne.title&&H.title===H.id?ne.title:H.title,Ne=((ne==null?void 0:ne.authors)||[]).find(me=>me&&me.name),Be=[Ne?`${Ne.dynasty?`〔${u(Ne.dynasty)}〕`:""}${u(Ne.name)}${Ne.role?` ${u(Ne.role)}`:""}`:"",ne!=null&&ne.measure?u(ne.measure):"",(Je=H.subItems)!=null&&Je.length?H.subItems.map(me=>u(me)).join("、"):"",(ne!=null&&ne.edition||H.edition)&&!A?u((ne==null?void 0:ne.edition)||H.edition||""):""].filter(Boolean),We=Nn.find(me=>me.key===F(H.id)),Ue=H.volumes.length>0?p("collectionPage.volumeRange",{range:bi(H.volumes,h.unit.volume),unit:h.unit.volume}):H.expected!=null?`${H.found??0}/${H.expected} ${h.unit.volume}`:"";return t.jsxs("tr",{children:[U&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Ue?"":" bim-d-zt-blank"}`,children:[We&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(We.token)}}),Ue||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[H.id?t.jsx(Ke,{id:H.id,label:u(ge),onNavigate:r,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:u(ge)}),Be.length>0?t.jsx(Ze,{items:Be}):H.id&&!ne&&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${ne!=null&&ne.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ne!=null&&ne.versionCount?p("collectionPage.nZhong",{n:ne.versionCount}):""})]},`${H.id??H.title}-${se}`)})})]}),R.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(Vo,{total:N.length,shown:R.length,unit:h.unit.items,onClick:()=>k(!0)})]}),G>0&&t.jsxs(Qe,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:G}),children:[P.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[P.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:p("collectionPage.text")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:P.text.map((H,se)=>t.jsx(br,{item:H,siblings:P.text},`${H.id||H.url||H.name}-${se}`))})})]}),t.jsx($c,{groups:P.groups})]}),$.rows.length===0&&G===0&&t.jsx(Qe,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),ve=Z?t.jsx(Dt,{id:"works",title:h.section.containedWorks,meta:p("collectionPage.nZhong",{n:K.length}),cap:12,items:K.map(H=>t.jsx(Ke,{id:H.id,label:u(H.title),onNavigate:r,renderLink:s,dense:!0}))}):null,le=y?t.jsx(_l,{caption:p("collectionPage.parent"),children:t.jsx(Ke,{id:y.id,label:u(y.title||y.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return t.jsx(Rn,{railTop:l,back:d,up:le,nav:ze,railLinks:c,main:Y,card:fe,side:ve})},Vx=16,Zi=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function da(e){if(!e)return Zi.length;const n=Zi.indexOf(e);return n===-1?Zi.length:n}function Gx(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const Yx={秦:[-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]},Rc=({data:e,transport:n,onNavigate:o,renderLink:r,railTop:s,back:a,railLinks:l})=>{var le,Se,X,Ce,Me;const{t:d,convert:c,messages:p}=J(),u=M=>Gx(M,d),[h,m]=g.useState("全部"),[f,x]=g.useState(!1),[k,y]=g.useState("default"),[_,b]=g.useState(new Map),j=g.useMemo(()=>(e.works||[]).map(M=>{const te=_.get(M.work_id);return{id:M.work_id,title:(te==null?void 0:te.title)??M.title??M.work_id,role:M.role||"",cls:Do(M.role),versionCount:te==null?void 0:te.versionCount,section:te==null?void 0:te.cls,l1:te==null?void 0:te.l1,measure:te==null?void 0:te.measure,hasImage:te==null?void 0:te.hasImage,loaded:!!(te!=null&&te.loaded)}}),[e.works,_]),w=g.useMemo(()=>vl((e.works||[]).map(M=>M.role),d("detail.roleAll")),[e.works,d]),v=g.useMemo(()=>{const M=h==="全部"?j:j.filter(te=>te.cls===h);return k==="versions"?[...M].sort((te,ye)=>(ye.versionCount??-1)-(te.versionCount??-1)):M},[j,h,k]),$=f?v:v.slice(0,Vx),S=g.useMemo(()=>$.filter(M=>!_.has(M.id)).map(M=>M.id),[$,_]);g.useEffect(()=>{if(!n||S.length===0)return;let M=!1;return Promise.all(S.map(te=>n.getItem(te).then(ye=>{var ge,Ne,Be,We,Ue;const H=ye??{},se=H._edition_count??(((ge=H.books)==null?void 0:ge.length)??0)+(((Ne=H.collections)==null?void 0:Ne.length)??0),ne=[(Be=H.classification)==null?void 0:Be.l1,(We=H.classification)==null?void 0:We.l2].filter(Boolean).join(" ");return[te,{id:te,title:H.title,versionCount:se,loaded:!0,cls:ne||void 0,l1:((Ue=H.classification)==null?void 0:Ue.l1)||void 0,measure:ye&&$t(ye,p.unit.juan)||void 0,hasImage:!!(H.has_image??H._has_image)}]}).catch(()=>[te,{id:te,loaded:!0}]))).then(te=>{M||b(ye=>{const H=new Map(ye);for(const[se,ne]of te)H.set(se,ne);return H})}),()=>{M=!0}},[n,S,p.unit.juan]);const C=g.useMemo(()=>{const M=new Map;for(const te of e.alt_names||[]){const ye=te.type||p.section.aliases;M.has(ye)||M.set(ye,[]),M.get(ye).push(te.name)}return[...M.entries()].sort((te,ye)=>da(te[0])-da(ye[0])).map(([te,ye])=>({label:te,names:ye}))},[e.alt_names,p]),B=e.birth_year??((le=e.dates)==null?void 0:le.birth)??void 0,T=e.death_year??((Se=e.dates)==null?void 0:Se.death)??void 0,z=(X=e.dates)==null?void 0:X.floruit,F=B!=null||T!=null?`${u(B)||"?"}—${u(T)||"?"}`:Array.isArray(z)&&z.length===2&&z.every(M=>Number.isFinite(M))?d("entityPage.floruit",{from:u(z[0]),to:u(z[1])}):"",N=new Set(["本名","字","號","号"]),R=C.filter(M=>N.has(M.label)),O=C.filter(M=>!N.has(M.label)),I=O.reduce((M,te)=>M+te.names.length,0),P=g.useMemo(()=>{const M=[];for(const ye of R)M.push({label:ye.label,value:ye.names.map(H=>c(H)).join("、")});const te=(e.works||[]).length;return te&&M.push({label:d("entityPage.fact.works"),value:d("entityPage.nZhong",{n:te})}),M},[e.works,R,c,d]),G=M=>{var te;return(te=C.find(ye=>M.includes(ye.label)))==null?void 0:te.names[0]},K=G(["字"]),L=G(["號","号"]),Z=[K?d("entityPage.zi",{name:c(K)}):"",L?d("entityPage.hao",{name:c(L)}):""].filter(Boolean).join(","),A=e.native_place,U=e.dynasty?Yx[e.dynasty]:void 0,ce=(()=>{if(!U||B==null||T==null||T<B)return null;const[M,te]=U,ye=Math.max(B,M),H=Math.min(T,te);if(H<=ye)return null;const se=te-M;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(B),death:u(T),years:T-B+1}),children:t.jsx("i",{style:{left:`${(ye-M)/se*100}%`,width:`${(H-ye)/se*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${u(M)} ${c(e.dynasty)}`}),t.jsx("span",{children:d("entityPage.lifeYears",{years:T-B+1})}),t.jsx("span",{children:u(te)})]})]})})(),ee=g.useMemo(()=>{if(!n||j.length===0||j.some(ye=>!ye.loaded))return null;const M=new Map;for(const ye of j){const H=ko(ye.l1);H&&M.set(H,(M.get(H)??0)+1)}const te=Nn.map(ye=>({...ye,n:M.get(ye.key)??0})).filter(ye=>ye.n>0);return te.length?te:null},[j,n]),ue=t.jsxs(Ln,{kind:p.entityPage.subtype[e.subtype]??d("entityPage.subtype.people"),title:c(e.primary_name||e.title),subtitle:Z||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(Ze,{items:[e.dynasty?c(e.dynasty):"",F,A?d("entityPage.nativePlace",{place:c(A)}):""]}),ce]}),description:(Ce=e.description)!=null&&Ce.text?t.jsx(_t,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Yo((Me=e.description)==null?void 0:Me.text)?6:void 0,facts:P,foot:t.jsx(An,{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:O.map(M=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(M.label)}),t.jsx("dd",{children:M.names.map(te=>c(te)).join("、")})]},M.label))})]}),ee&&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:ee.map(M=>t.jsx("i",{style:{flexGrow:M.n,background:i(M.token)}},M.key))}),t.jsx("div",{className:"bim-d-dist-key",children:ee.map(M=>t.jsxs("span",{children:[t.jsx("i",{style:{background:i(M.token)}}),c(M.label)," ",M.n]},M.key))})]})]}),de=g.useMemo(()=>j.filter(M=>M.loaded&&(M.versionCount??0)>0).sort((M,te)=>(te.versionCount??0)-(M.versionCount??0)).slice(0,3),[j]),be=!!n&&j.length>=3&&$.some(M=>!M.loaded),Oe=h==="全部"&&(be||de.length>=2),ie=e.external_ids||{},Re=[];ie.cbdb_id!=null&&Re.push({label:"CBDB",id:String(ie.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ie.cbdb_id}`,note:ie.cbdb_match==="auto"?d("entityPage.autoMatch"):void 0});const Le=ie.wikidata_id;Le&&Re.push({label:"Wikidata",id:Le,href:`https://www.wikidata.org/wiki/${Le}`});const q=ie.viaf_id;q&&Re.push({label:"VIAF",id:q,href:`https://viaf.org/viaf/${q}`});const Q=w.map(M=>({key:M.cls,label:`${M.label} ${M.count}`})),fe=[...Oe&&!be?[{id:"featured",label:d("entityPage.sec.featured"),count:de.length}]:[],...j.length?[{id:"works",label:d("entityPage.sec.allWorks"),count:j.length}]:[],...Re.length?[{id:"external",label:d("entityPage.sec.external"),count:Re.length}]:[]],ze=Oe?t.jsxs(Qe,{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":be||void 0,children:[be&&[0,1,2].map(M=>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:" "})]},M)),!be&&de.map(M=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(Ke,{id:M.id,label:c(M.title),onNavigate:o,renderLink:r,dense:!0})}),t.jsx(Ze,{items:[M.section?c(M.section):"",M.measure?c(M.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:M.versionCount}),t.jsx("span",{children:d("entityPage.versionsUnit")}),M.hasImage&&t.jsx("span",{className:"bim-d-flag",children:d("entityPage.hasImage")})]})]},M.id))]})]}):null,Y=j.length===0?t.jsx(Qe,{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:[ze,t.jsxs(Qe,{id:"works",title:d("entityPage.sec.works"),meta:t.jsx(Ze,{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:[Q.length>1&&t.jsx(yi,{items:Q,value:h,onChange:M=>{m(M),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(M=>M==="default"?"versions":"default")},children:d(k==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!f&&ji(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(M=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Ke,{id:M.id,label:c(M.title),onNavigate:o,renderLink:r,dense:!0}),M.measure?t.jsx(Ze,{items:[c(M.measure)]}):!M.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${M.section||M.loaded?"":" bim-d-zt-blank"}`,children:M.section?c(M.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.role?"":" bim-d-zt-blank"}`,children:M.role?c(M.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M.loaded?"":" bim-d-zt-blank"}`,children:M.loaded?M.versionCount?d("entityPage.nZhong",{n:M.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:d("entityPage.notRecorded")}):""}),t.jsx("td",{className:M.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:M.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:d("entityPage.hasImage")})})]},M.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(Vo,{total:v.length,shown:$.length,unit:d("entityPage.moreUnit"),onClick:()=>x(!0)})]})]}),ve=Re.length>0?t.jsx(Dt,{id:"external",title:d("entityPage.sec.external"),items:Re.map(M=>t.jsxs("a",{href:M.href,target:"_blank",rel:"noopener noreferrer",children:[M.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:Re.map(M=>M.id),foot:ie.cbdb_id!=null&&ie.cbdb_match==="auto"?d("entityPage.cbdbAuto"):void 0}):null;return t.jsx(Rn,{railTop:s,back:a,nav:fe,railLinks:l,main:Y,card:ue,side:ve})},jr="(max-width: 719px)",Kx=`${jr}, (pointer: coarse)`,Lc=`
|
|
1297
1300
|
.bim-ct {
|
|
1298
1301
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1299
1302
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1401,7 +1404,7 @@ ${le??""}`,load:te,files:Ne,activeFile:J??null,activeJuan:(ae==null?void 0:ae.js
|
|
|
1401
1404
|
.bim-ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1402
1405
|
}
|
|
1403
1406
|
|
|
1404
|
-
@media ${
|
|
1407
|
+
@media ${jr} {
|
|
1405
1408
|
.bim-ct { display: block; padding: 12px 16px 40px; }
|
|
1406
1409
|
.bim-ct-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
|
1407
1410
|
.bim-ct-lrow > a { grid-template-columns: minmax(0, 1fr); }
|
|
@@ -1426,7 +1429,7 @@ ${le??""}`,load:te,files:Ne,activeFile:J??null,activeJuan:(ae==null?void 0:ae.js
|
|
|
1426
1429
|
}
|
|
1427
1430
|
|
|
1428
1431
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1429
|
-
@media ${
|
|
1432
|
+
@media ${Kx} {
|
|
1430
1433
|
.bim-ct-row { min-height: 44px; }
|
|
1431
1434
|
.bim-ct-tw { width: 44px; }
|
|
1432
1435
|
.bim-ct-pg { min-width: 44px; height: 44px; }
|
|
@@ -1452,7 +1455,7 @@ ${le??""}`,load:te,files:Ne,activeFile:J??null,activeJuan:(ae==null?void 0:ae.js
|
|
|
1452
1455
|
/* 窄屏分类抽屉:界栏下按钮和面板都有框 */
|
|
1453
1456
|
:root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${i("fr-bd")}; background: ${i("fr-bg")}; }
|
|
1454
1457
|
:root[data-layout="boxed"] .bim-ct-drawer { border: ${i("fr-bd")}; }
|
|
1455
|
-
`,Wt="未分類",kt="all",pr=20;function Ln(t){if(!t)return[];const n=[];for(const o of[t.l1,t.l2,t.l3,t.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function Sx(t){const n=Ln(t);return n.length?n.join("/"):Wt}function _x(t){const n=Ln(t);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Wt]}function $x(t,n=[]){const o=new Map;n.forEach((p,c)=>{const d=[p.cata_l1,p.cata_l2,p.cata_l3,p.cata_l4].filter(u=>!!u);d.forEach((u,m)=>{const h=d.slice(0,m+1).join("/");o.has(h)||o.set(h,c)})});const r=new Map;let s=0;for(const p of t){const c=Ln(p.classification);if(!c.length){s++;continue}let d=r;c.forEach((u,m)=>{const h=c.slice(0,m+1).join("/");let f=d.get(u);f||(f={id:h,label:u,count:0,children:new Map},d.set(u,f)),f.count++,d=f.children})}const l=p=>[...p.values()].sort((c,d)=>{const u=c.label===Wt?1:0,m=d.label===Wt?1:0;if(u!==m)return u-m;const h=o.get(c.id)??1/0,f=o.get(d.id)??1/0;return h!==f?h-f:c.label.localeCompare(d.label,"zh")}).map(c=>{const d={id:c.id,label:c.label,count:c.count};return c.children.size&&(d.children=l(c.children)),d}),a=l(r);return s>0&&a.push({id:Wt,label:Wt,count:s}),a}function Qt(t,n){if(!n)return[];for(const o of t){if(o.id===n)return[o];if(o.children){const r=Qt(o.children,n);if(r.length)return[o,...r]}}return[]}function ur(t){return t.reduce((n,o)=>n+o.count,0)}function Cx(t){return(t??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function zx(t){var p;const n={id:t.id,title:t.title||t.id},o=t.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r:t.measure_info&&(n.juan=t.measure_info);const s=(t.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const d=c.dynasty||(t.authors.length===1?t.dynasty:void 0);return d?{name:c.name,dynasty:d}:{name:c.name}});s.length&&(n.authors=s);const l=Cx(typeof t.description=="string"?t.description:(p=t.description)==null?void 0:p.text);l&&(n.summary=l);const a=Ln(t.classification);return a.length&&(n.classification=a),n}function Tx(t,n){const o=t.summary?0:1,r=n.summary?0:1;return o!==r?o-r:t.title.localeCompare(n.title,"zh")}function Nx(t,n=pr){return Math.max(1,Math.ceil(t/n))}function bc(t,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let a=t-o;a<=t+o;a++)a>=1&&a<=n&&r.add(a);const s=[...r].sort((a,p)=>a-p),l=[];return s.forEach((a,p)=>{if(p>0){const c=a-s[p-1];c===2?l.push(a-1):c>2&&l.push(null)}l.push(a)}),l}const Ex=()=>e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:e.jsx("path",{d:"M3 1.5 6.5 5 3 8.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Ix(t,n,o){const r=[];o&&r.push({id:kt,parentId:null,hasChildren:!1,firstChildId:null});const s=(l,a)=>{var p;for(const c of l){const d=(p=c.children)!=null&&p.length?c.children:null;r.push({id:c.id,parentId:a,hasChildren:!!d,firstChildId:d?d[0].id:null}),d&&n.has(c.id)&&s(d,c.id)}};return s(t,null),r}function yc({tree:t,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:l,convert:a}=Z(),p=r===void 0?l("catalogPage.all"):r,c=s??l("catalogPage.classification"),d=g.useRef(null),u=n&&n!==kt?n:null,m=p!==null,[h,f]=g.useState(()=>{const z=new Set;for(const B of Qt(t,u))z.add(B.id);return z});g.useEffect(()=>{const z=Qt(t,u);z.length&&f(B=>{if(z.every(N=>B.has(N.id)))return B;const I=new Set(B);for(const N of z)I.add(N.id);return I})},[t,u]);const x=g.useMemo(()=>Ix(t,h,m),[t,h,m]),[j,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const _=u??(m?kt:null),b=g.useMemo(()=>{var I;const z=new Set(x.map(N=>N.id));if(j&&z.has(j))return j;if(_&&z.has(_))return _;const B=Qt(t,u).map(N=>N.id).filter(N=>z.has(N));return B.length?B[B.length-1]:((I=x[0])==null?void 0:I.id)??null},[x,j,_,t,u]),v=g.useCallback((z,B)=>{f(I=>{const N=I.has(z),O=B??!N;if(O===N)return I;const C=new Set(I);return O?C.add(z):C.delete(z),C})},[]),S=g.useCallback(z=>{y(z),requestAnimationFrame(()=>{var I;const B=Array.from(((I=d.current)==null?void 0:I.querySelectorAll("[data-ct-id]"))??[]).find(N=>N.dataset.ctId===z);B==null||B.focus()})},[]),k=g.useCallback((z,B)=>{B&&v(z,!0),o(z)},[o,v]),$=g.useCallback(z=>{const B=z.target.closest("[data-ct-id]");if(!B)return;const I=B.dataset.ctId,N=x.findIndex(T=>T.id===I);if(N<0)return;const O=x[N];let C=null;switch(z.key){case"ArrowDown":C=x[Math.min(x.length-1,N+1)].id;break;case"ArrowUp":C=x[Math.max(0,N-1)].id;break;case"Home":C=x[0].id;break;case"End":C=x[x.length-1].id;break;case"ArrowRight":if(!O.hasChildren)break;h.has(I)?C=O.firstChildId:v(I,!0);break;case"ArrowLeft":O.hasChildren&&h.has(I)?v(I,!1):C=O.parentId;break;case"Enter":case" ":z.preventDefault(),k(I,O.hasChildren);return;default:return}z.preventDefault(),C&&C!==I&&S(C)},[x,h,v,S,k]),w=(z,B)=>z.map((I,N)=>{var A;const O=(A=I.children)!=null&&A.length?I.children:null,C=!!O&&h.has(I.id),T=I.id===u,R=B===1&&z.length>1&&N===z.length-1;return e.jsxs("li",{role:"treeitem","aria-level":B,"aria-expanded":O?C:void 0,"aria-selected":T,tabIndex:b===I.id?0:-1,"data-ct-id":I.id,className:R?"bim-ct-last":void 0,children:[e.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":B-1},onClick:()=>{y(I.id),k(I.id,!!O)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:O?H=>{H.stopPropagation(),y(I.id),v(I.id)}:void 0,children:O?e.jsx(Ex,{}):null}),e.jsx("span",{className:"bim-ct-lb",children:a(I.label)}),e.jsx("span",{className:"bim-ct-n",children:I.count.toLocaleString("en-US")})]}),C&&e.jsx("ul",{role:"group",children:w(O,B+1)})]},I.id)});return e.jsxs("ul",{ref:d,role:"tree","aria-label":a(c),className:"bim-ct-tree",onKeyDown:$,children:[m&&e.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:b===kt?0:-1,"data-ct-id":kt,children:e.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(kt),o(kt)},children:[e.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),e.jsx("span",{className:"bim-ct-lb",children:a(p)}),e.jsx("span",{className:"bim-ct-n",children:ur(t).toLocaleString("en-US")})]})}),w(t,1)]})}const jc=t=>`/item/${encodeURIComponent(t)}`;function Rx(t){return t.button===0&&!t.metaKey&&!t.ctrlKey&&!t.shiftKey&&!t.altKey}function vc(t,n){return t==null||t===""?null:typeof t=="number"?n("catalogPage.juanN",{n:t}):t}function kc({work:t,href:n}){var p,c;const{t:o,convert:r}=Z(),s=vc(t.juan,o),l=((p=t.authors)==null?void 0:p.filter(d=>d.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-card",children:e.jsxs("a",{href:n,children:[e.jsxs("div",{className:"bim-ct-ch",children:[e.jsx("h2",{className:"bim-ct-ct",children:r(t.title)}),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),l.length>0&&e.jsx("span",{className:"bim-ct-by",children:l.map((d,u)=>e.jsxs(g.Fragment,{children:[u>0&&"、",d.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(d.dynasty),"〕"]}),r(d.name)]},u))}),t.summary&&e.jsx("p",{className:"bim-ct-sum",children:r(t.summary)}),a.length>0&&e.jsx("span",{className:"bim-ct-cls",children:a.map(d=>r(d)).join(" · ")})]})})}function wc({work:t,href:n}){var p,c;const{t:o,convert:r}=Z(),s=vc(t.juan,o),l=((p=t.authors)==null?void 0:p.filter(d=>d.name))??[],a=((c=t.classification)==null?void 0:c.filter(Boolean))??[];return e.jsx("li",{className:"bim-ct-lrow",children:e.jsxs("a",{href:n,children:[e.jsxs("span",{className:"bim-ct-lt",children:[r(t.title),s&&e.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),e.jsx("span",{className:"bim-ct-by",children:l.map((d,u)=>e.jsxs(g.Fragment,{children:[u>0&&"、",d.dynasty&&e.jsxs("span",{className:"bim-ct-dy",children:["〔",r(d.dynasty),"〕"]}),r(d.name)]},u))}),e.jsx("span",{className:"bim-ct-cls",children:a.map(d=>r(d)).join(" · ")})]})})}function Sc({page:t,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:l,convert:a}=Z();if(n<=1)return null;const p=d=>u=>{o&&(r&&!Rx(u)||(u.preventDefault(),o(d)))},c=(d,u,m)=>{if(m.disabled)return e.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const h={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return r?e.jsx("a",{...h,href:r(d),onClick:p(d),children:u}):e.jsx("button",{type:"button",...h,onClick:m.current?void 0:p(d),children:u})};return e.jsxs("nav",{className:"bim-ct-pager","aria-label":s?a(s):l("catalogPage.pagerLabel"),children:[c(t-1,l("catalogPage.prevPage"),{disabled:t<=1}),e.jsx("ol",{children:bc(t,n).map((d,u)=>e.jsx("li",{style:{display:"contents"},children:d===null?e.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):c(d,d,{current:d===t,aria:l("catalogPage.pageN",{n:d})})},d??`gap${u}`))}),e.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[t," / ",n]}),c(t+1,l("catalogPage.nextPage"),{disabled:t>=n})]})}function _c({works:t,workLink:n=jc,emptyText:o,view:r="card",...s}){const{t:l,convert:a}=Z();return e.jsxs("div",{className:"bim-ct-works",children:[t.length===0?e.jsx("p",{className:"bim-ct-empty",children:o===void 0?l("catalogPage.emptyWorks"):typeof o=="string"?a(o):o}):r==="list"?e.jsx("ul",{className:"bim-ct-list",children:t.map(p=>e.jsx(wc,{work:p,href:n(p.id)},p.id))}):e.jsx("ul",{className:"bim-ct-grid",children:t.map(p=>e.jsx(kc,{work:p,href:n(p.id)},p.id))}),e.jsx(Sc,{...s})]})}const Lx=()=>e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:e.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Ax({tree:t,selectedId:n,page:o,pageCount:r,works:s,onSelect:l,onPage:a,searchSlot:p,workLink:c,pageHref:d,allLabel:u,allTitle:m,pageSize:h=pr,className:f,view:x,onViewChange:j}){const{t:y,convert:_}=Z(),b=u===void 0?y("catalogPage.all"):u,v=m??y("catalogPage.allTitle"),k=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[$,w]=g.useState(!1),[z,B]=g.useState("card"),I=x??z,N=H=>{B(H),j==null||j(H)},O=Qt(t,n&&n!==kt?n:null),C=O.length?O[O.length-1]:null,T=C?C.label:v,R=C?C.count:ur(t),A=g.useCallback(H=>{w(!1),l(H)},[l]);return e.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[e.jsx("style",{children:xc}),e.jsxs("aside",{className:"bim-ct-side","aria-label":y("catalogPage.sideNav"),children:[e.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":$,"aria-controls":k,onClick:()=>w(H=>!H),children:[e.jsx("span",{children:y("catalogPage.drawerLabel",{path:_(O.length?O.map(H=>H.label).join(" › "):b??v)})}),e.jsx(Lx,{})]}),e.jsxs("div",{className:"bim-ct-drawer",id:k,children:[e.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),e.jsx(yc,{tree:t,selectedId:n,onSelect:A,allLabel:b})]})]}),e.jsxs("div",{className:"bim-ct-main",children:[e.jsxs("header",{className:"bim-ct-head",children:[e.jsx("h1",{className:"bim-ct-title",children:_(T)}),O.length>1&&e.jsx("span",{className:"bim-ct-crumb",children:_(O.slice(0,-1).map(H=>H.label).join(" › "))}),e.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:R.toLocaleString("en-US"),size:h}),r>1&&y("catalogPage.statPage",{page:o,pages:r})]}),e.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":y("catalogPage.viewLabel"),children:[e.jsx("button",{type:"button","aria-pressed":I==="card",onClick:()=>N("card"),children:y("catalogPage.viewCard")}),e.jsx("button",{type:"button","aria-pressed":I==="list",onClick:()=>N("list"),children:y("catalogPage.viewList")})]})]}),p&&e.jsx("div",{className:"bim-ct-search",children:p}),e.jsx(_c,{works:s,view:I,workLink:c,page:o,pageCount:r,onPage:a,pageHref:d})]})]})}const An="(max-width: 719px)",Px="(max-width: 1079px)",Mx=`${An}, (pointer: coarse)`,Bx=[8,18,30,42,88],mr=`
|
|
1458
|
+
`,Ft="未分類",wt="all",vr=20;function Mn(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 qx(e){const n=Mn(e);return n.length?n.join("/"):Ft}function Xx(e){const n=Mn(e);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Ft]}function Zx(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,h)=>{const m=p.slice(0,h+1).join("/");o.has(m)||o.set(m,c)})});const r=new Map;let s=0;for(const d of e){const c=Mn(d.classification);if(!c.length){s++;continue}let p=r;c.forEach((u,h)=>{const m=c.slice(0,h+1).join("/");let f=p.get(u);f||(f={id:m,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===Ft?1:0,h=p.label===Ft?1:0;if(u!==h)return u-h;const m=o.get(c.id)??1/0,f=o.get(p.id)??1/0;return m!==f?m-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:Ft,label:Ft,count:s}),l}function nn(e,n){if(!n)return[];for(const o of e){if(o.id===n)return[o];if(o.children){const r=nn(o.children,n);if(r.length)return[o,...r]}}return[]}function kr(e){return e.reduce((n,o)=>n+o.count,0)}function Jx(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function Qx(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=Jx(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=Mn(e.classification);return l.length&&(n.classification=l),n}function eb(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 tb(e,n=vr){return Math.max(1,Math.ceil(e/n))}function Ac(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 nb=()=>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 ib(e,n,o){const r=[];o&&r.push({id:wt,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 Pc({tree:e,selectedId:n,onSelect:o,allLabel:r,label:s}){const{t:a,convert:l}=J(),d=r===void 0?a("catalogPage.all"):r,c=s??a("catalogPage.classification"),p=g.useRef(null),u=n&&n!==wt?n:null,h=d!==null,[m,f]=g.useState(()=>{const C=new Set;for(const B of nn(e,u))C.add(B.id);return C});g.useEffect(()=>{const C=nn(e,u);C.length&&f(B=>{if(C.every(z=>B.has(z.id)))return B;const T=new Set(B);for(const z of C)T.add(z.id);return T})},[e,u]);const x=g.useMemo(()=>ib(e,m,h),[e,m,h]),[k,y]=g.useState(null);g.useEffect(()=>{y(null)},[n]);const _=u??(h?wt:null),b=g.useMemo(()=>{var T;const C=new Set(x.map(z=>z.id));if(k&&C.has(k))return k;if(_&&C.has(_))return _;const B=nn(e,u).map(z=>z.id).filter(z=>C.has(z));return B.length?B[B.length-1]:((T=x[0])==null?void 0:T.id)??null},[x,k,_,e,u]),j=g.useCallback((C,B)=>{f(T=>{const z=T.has(C),F=B??!z;if(F===z)return T;const N=new Set(T);return F?N.add(C):N.delete(C),N})},[]),w=g.useCallback(C=>{y(C),requestAnimationFrame(()=>{var T;const B=Array.from(((T=p.current)==null?void 0:T.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===C);B==null||B.focus()})},[]),v=g.useCallback((C,B)=>{B&&j(C,!0),o(C)},[o,j]),$=g.useCallback(C=>{const B=C.target.closest("[data-ct-id]");if(!B)return;const T=B.dataset.ctId,z=x.findIndex(R=>R.id===T);if(z<0)return;const F=x[z];let N=null;switch(C.key){case"ArrowDown":N=x[Math.min(x.length-1,z+1)].id;break;case"ArrowUp":N=x[Math.max(0,z-1)].id;break;case"Home":N=x[0].id;break;case"End":N=x[x.length-1].id;break;case"ArrowRight":if(!F.hasChildren)break;m.has(T)?N=F.firstChildId:j(T,!0);break;case"ArrowLeft":F.hasChildren&&m.has(T)?j(T,!1):N=F.parentId;break;case"Enter":case" ":C.preventDefault(),v(T,F.hasChildren);return;default:return}C.preventDefault(),N&&N!==T&&w(N)},[x,m,j,w,v]),S=(C,B)=>C.map((T,z)=>{var I;const F=(I=T.children)!=null&&I.length?T.children:null,N=!!F&&m.has(T.id),R=T.id===u,O=B===1&&C.length>1&&z===C.length-1;return t.jsxs("li",{role:"treeitem","aria-level":B,"aria-expanded":F?N:void 0,"aria-selected":R,tabIndex:b===T.id?0:-1,"data-ct-id":T.id,className:O?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":B-1},onClick:()=>{y(T.id),v(T.id,!!F)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:F?P=>{P.stopPropagation(),y(T.id),j(T.id)}:void 0,children:F?t.jsx(nb,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(T.label)}),t.jsx("span",{className:"bim-ct-n",children:T.count.toLocaleString("en-US")})]}),N&&t.jsx("ul",{role:"group",children:S(F,B+1)})]},T.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:$,children:[h&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!u,tabIndex:b===wt?0:-1,"data-ct-id":wt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{y(wt),o(wt)},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:kr(e).toLocaleString("en-US")})]})}),S(e,1)]})}const Mc=e=>`/item/${encodeURIComponent(e)}`;function ob(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Bc(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function Wc({work:e,href:n}){var d,c;const{t:o,convert:r}=J(),s=Bc(e.juan,o),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-card",children:t.jsxs("a",{href:n,children:[t.jsxs("div",{className:"bim-ct-ch",children:[t.jsx("h2",{className:"bim-ct-ct",children:r(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:r(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Oc({work:e,href:n}){var d,c;const{t:o,convert:r}=J(),s=Bc(e.juan,o),a=((d=e.authors)==null?void 0:d.filter(p=>p.name))??[],l=((c=e.classification)==null?void 0:c.filter(Boolean))??[];return t.jsx("li",{className:"bim-ct-lrow",children:t.jsxs("a",{href:n,children:[t.jsxs("span",{className:"bim-ct-lt",children:[r(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:r(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,u)=>t.jsxs(g.Fragment,{children:[u>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",r(p.dynasty),"〕"]}),r(p.name)]},u))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>r(p)).join(" · ")})]})})}function Hc({page:e,pageCount:n,onPage:o,pageHref:r,label:s}){const{t:a,convert:l}=J();if(n<=1)return null;const d=p=>u=>{o&&(r&&!ob(u)||(u.preventDefault(),o(p)))},c=(p,u,h)=>{if(h.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:u});const m={className:"bim-ct-pg","aria-current":h.current?"page":void 0,"aria-label":h.aria};return r?t.jsx("a",{...m,href:r(p),onClick:d(p),children:u}):t.jsx("button",{type:"button",...m,onClick:h.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:Ac(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 Fc({works:e,workLink:n=Mc,emptyText:o,view:r="card",...s}){const{t:a,convert:l}=J();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:o===void 0?a("catalogPage.emptyWorks"):typeof o=="string"?l(o):o}):r==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(Oc,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(Wc,{work:d,href:n(d.id)},d.id))}),t.jsx(Hc,{...s})]})}const rb=()=>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 sb({tree:e,selectedId:n,page:o,pageCount:r,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:u,allTitle:h,pageSize:m=vr,className:f,view:x,onViewChange:k}){const{t:y,convert:_}=J(),b=u===void 0?y("catalogPage.all"):u,j=h??y("catalogPage.allTitle"),v=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[$,S]=g.useState(!1),[C,B]=g.useState("card"),T=x??C,z=P=>{B(P),k==null||k(P)},F=nn(e,n&&n!==wt?n:null),N=F.length?F[F.length-1]:null,R=N?N.label:j,O=N?N.count:kr(e),I=g.useCallback(P=>{S(!1),a(P)},[a]);return t.jsxs("div",{className:f?`bim-ct ${f}`:"bim-ct","data-drawer":$?"open":"closed",children:[t.jsx("style",{children:Lc}),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:()=>S(P=>!P),children:[t.jsx("span",{children:y("catalogPage.drawerLabel",{path:_(F.length?F.map(P=>P.label).join(" › "):b??j)})}),t.jsx(rb,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:y("catalogPage.classification")}),t.jsx(Pc,{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:_(R)}),F.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:_(F.slice(0,-1).map(P=>P.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[y("catalogPage.stat",{total:O.toLocaleString("en-US"),size:m}),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":T==="card",onClick:()=>z("card"),children:y("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":T==="list",onClick:()=>z("list"),children:y("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(Fc,{works:s,view:T,workLink:c,page:o,pageCount:r,onPage:l,pageHref:p})]})]})}const Bn="(max-width: 719px)",ab="(max-width: 1079px)",lb=`${Bn}, (pointer: coarse)`,cb=[8,18,30,42,88],wr=`
|
|
1456
1459
|
.bim-rh { color: ${i("ink")}; font-family: ${i("font-ui")}; font-size: 14px; line-height: 1.6; }
|
|
1457
1460
|
.bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
|
|
1458
1461
|
.bim-rh a { color: ${i("accent")}; text-decoration: none; }
|
|
@@ -1600,7 +1603,7 @@ ${le??""}`,load:te,files:Ne,activeFile:J??null,activeJuan:(ae==null?void 0:ae.js
|
|
|
1600
1603
|
flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
|
|
1601
1604
|
color: ${i("ink")} !important; font-size: 13px;
|
|
1602
1605
|
}
|
|
1603
|
-
${
|
|
1606
|
+
${cb.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${i("accent")} ${e}%, ${i("card-bg")}); }`).join(`
|
|
1604
1607
|
`)}
|
|
1605
1608
|
.bim-rh-band a[data-k="4"] { color: ${i("page-bg")} !important; }
|
|
1606
1609
|
.bim-rh-band a:hover { outline: 2px solid ${i("ink")}; outline-offset: -2px; }
|
|
@@ -1628,13 +1631,13 @@ ${Bx.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1628
1631
|
}
|
|
1629
1632
|
|
|
1630
1633
|
/* ── 中屏 ── */
|
|
1631
|
-
@media ${
|
|
1634
|
+
@media ${ab} {
|
|
1632
1635
|
.bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1633
1636
|
.bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1634
1637
|
}
|
|
1635
1638
|
|
|
1636
1639
|
/* ── 手机 ── */
|
|
1637
|
-
@media ${
|
|
1640
|
+
@media ${Bn} {
|
|
1638
1641
|
.bim-rh-main { padding-top: 24px; }
|
|
1639
1642
|
.bim-rh-stats { gap: 4px 18px; }
|
|
1640
1643
|
.bim-rh-stats b { font-size: 16px; }
|
|
@@ -1671,7 +1674,7 @@ ${Bx.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1671
1674
|
}
|
|
1672
1675
|
|
|
1673
1676
|
/* 触屏或窄屏:点击目标放大到 44px */
|
|
1674
|
-
@media ${
|
|
1677
|
+
@media ${lb} {
|
|
1675
1678
|
.bim-rh-rows a, .bim-rh-bu-l a, .bim-rh-au li a, .bim-rh-chip, .bim-rh-secnav a, .bim-rh-expand { min-height: 44px; display: flex; align-items: center; }
|
|
1676
1679
|
.bim-rh-chip { display: inline-flex; }
|
|
1677
1680
|
}
|
|
@@ -1682,7 +1685,7 @@ ${Bx.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1682
1685
|
}
|
|
1683
1686
|
|
|
1684
1687
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1685
|
-
`,Wx=xo["zh-Hant"].period,$c={read:t=>`/read/${encodeURIComponent(t)}`,node:t=>`/read?node=${encodeURIComponent(t)}`,period:t=>`/read?period=${encodeURIComponent(t)}`,work:t=>`/item/${encodeURIComponent(t)}`};function Nt(t){return{...$c,...t??{}}}function hr(t){var o;const n=(o=t.authors)==null?void 0:o.find(r=>r==null?void 0:r.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function fi(t){return(t.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function Cc(t,n=xo["zh-Hant"].shelfOther){var s;const o=[],r=new Map;for(const l of t){const a=((s=l.period_of)==null?void 0:s.trim())||n;let p=r.get(a);p||(p={label:a,items:[]},r.set(a,p),o.push(p)),p.items.push(l)}return o}function zc(t){return Math.max(150,Array.from(t).length*18+44)}function Tc(t,n){if(n<=0||t<=0)return 0;const o=t/n;return o<.15?0:o<.35?1:o<.6?2:o<.85?3:4}const Nc=.04;function Ve(t){return t.toLocaleString("en-US")}function Ec({text:t}){return e.jsx(e.Fragment,{children:Array.from(t).map((n,o)=>e.jsx("span",{children:n},o))})}function nt({id:t,title:n,sub:o,more:r,children:s}){const{convert:l}=Z(),a=`${t}-h`;return e.jsxs("section",{className:"bim-rh-sec",id:t,"aria-labelledby":a,children:[e.jsxs("div",{className:"bim-rh-hd",children:[e.jsx("h2",{id:a,children:l(n)}),o&&e.jsx("span",{className:"bim-rh-sub",children:o}),r]}),e.jsx("div",{className:"bim-rh-bd",children:s})]})}function Ic({counts:t}){const{t:n}=Z();return e.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[e.jsxs("span",{children:[e.jsx("b",{children:Ve(t.readable)}),n("readHome.readable")]}),t.pieces>0&&e.jsxs("span",{children:[e.jsx("b",{children:Ve(t.pieces)}),n("readHome.pieces")]})]})}function Rc({picks:t,links:n}){const{t:o,convert:r}=Z(),s=Nt(n);return t.length?e.jsx("ul",{className:"bim-rh-picks",children:t.map(l=>{const a=fi(l),p=[l.type_label,l.edition].filter(Boolean).join(" · ");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-pk",href:s.read(l.id),children:[e.jsx("span",{className:"bim-rh-slip","aria-hidden":"true",children:e.jsx(Ec,{text:r(l.slip||l.title)})}),e.jsxs("span",{className:"bim-rh-pk-body",children:[p&&e.jsx("span",{className:"bim-rh-badge",children:r(p)}),e.jsx("h3",{children:r(l.title)}),a&&e.jsx("span",{className:"bim-rh-by",children:r(a)}),l.blurb&&e.jsx("p",{children:r(l.blurb)}),e.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:o("readHome.startReading")})]})]})},l.id)})}):null}function Lc(t,n){return t&&t>1?n("readHome.nCopies",{n:t}):null}function gr({topic:t,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:l}){const{t:a,convert:p}=Z(),c=Nt(n);if(!t.items.length)return null;const d=r===void 0?a("readHome.shelfLegendCount"):r,u=Cc(t.items,a("readHome.shelfOther")),m=h=>{const f=h.records?Ve(h.records):Lc(h.text_count,a),x=hr(h),j=[p(h.title),h.orig?a("readHome.origZhi"):"",x?a("readHome.spineBy",{name:p(x)}):"",h.records?a("readHome.spineRecords",{n:f}):f?a("readHome.spineOnSite",{n:f}):""].filter(Boolean).join(",");return e.jsx("li",{children:e.jsxs("a",{className:"bim-rh-spine",href:c.read(h.id),"data-orig":h.orig?"":void 0,"aria-label":j,title:j,style:{height:zc(h.title)},children:[e.jsx(Ec,{text:p(h.title)}),f&&e.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":h.records?"":void 0,children:f})]})},h.id)};return e.jsxs("div",{className:"bim-rh-shelf-box",children:[s&&e.jsxs("h3",{className:"bim-rh-gt",children:[p(t.label),e.jsx("small",{children:o?p(o):a("readHome.shelfHint")})]}),e.jsx("div",{className:"bim-rh-shelf-wrap",tabIndex:0,role:"region","aria-label":a("readHome.shelfRegion",{label:p(t.label)}),children:e.jsx("ul",{className:"bim-rh-shelf",children:u.map(h=>e.jsxs("li",{className:"bim-rh-era",children:[e.jsx("ul",{className:"bim-rh-spines","aria-label":p(h.label),children:h.items.map(m)}),e.jsx("span",{"aria-hidden":"true",children:p(h.label)})]},h.label))})}),e.jsxs("p",{className:"bim-rh-legend",children:[e.jsxs("span",{children:[e.jsx("i",{"data-orig":"","aria-hidden":"true"}),a("readHome.origZhi")]}),e.jsxs("span",{children:[e.jsx("i",{"aria-hidden":"true"}),a("readHome.laterZhi")]}),d&&e.jsx("span",{children:p(d)}),l==null?void 0:l.map(h=>e.jsx("span",{children:p(h)},h))]})]})}const Ox=4,zn=t=>t>Ox+1;function Ac({topic:t,links:n}){const{t:o,convert:r}=Z(),s=Nt(n),[l,a]=g.useState(!1);if(!t.items.length)return null;const p=`bim-rh-g-${t.key}`;return e.jsxs("div",{className:"bim-rh-grp","data-cap":zn(t.items.length)?"":void 0,"data-open":l?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",id:p,children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nWorks",{n:Ve(t.items.length)})})]}),e.jsx("ul",{className:"bim-rh-rows","aria-labelledby":p,children:t.items.map(c=>{const d=Lc(c.text_count,o),u=hr(c);return e.jsx("li",{children:e.jsxs("a",{href:s.read(c.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(c.title)}),d&&e.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:d}),u&&e.jsx("small",{children:r(u)})]})},c.id)})}),zn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":l,onClick:()=>a(c=>!c),children:l?o("action.collapse"):o("readHome.allNWorks",{n:t.items.length})})]})}function Pc({topics:t,links:n}){const o=t.filter(s=>s.shelf&&s.items.length),r=t.filter(s=>!s.shelf&&s.items.length);return!o.length&&!r.length?null:e.jsxs(e.Fragment,{children:[o.map(s=>e.jsx(gr,{topic:s,links:n},s.key)),r.length>0&&e.jsx("div",{className:"bim-rh-groups",children:r.map(s=>e.jsx(Ac,{topic:s,links:n},s.key))})]})}function Mc({famous:t,links:n}){const{t:o,convert:r}=Z(),s=Nt(n);return t.length?e.jsx("ul",{className:"bim-rh-works",children:t.map(l=>e.jsx("li",{children:e.jsxs("article",{className:"bim-rh-wk",children:[e.jsxs("div",{className:"bim-rh-wk-h",children:[e.jsx("h3",{children:r(l.title)}),l.authors&&e.jsx("span",{className:"bim-rh-by",children:r(l.authors)}),e.jsx("span",{className:"bim-rh-c bim-rh-num",children:o("readHome.nCopiesCard",{n:l.text_count})})]}),l.systems.map((a,p)=>e.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":a.label?r(a.label):void 0,children:[a.label&&e.jsx("small",{"aria-hidden":"true",children:r(a.label)}),a.items.map(c=>e.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:r([c.title,c.edition].filter(Boolean).join(" · ")),children:r(c.short)},c.id))]},p)),l.work_id&&e.jsx("div",{className:"bim-rh-wk-f",children:e.jsx("a",{href:s.work(l.work_id),children:o("readHome.workPageLink",{title:r(l.title)})})})]})},l.work_id??l.title))}):null}function fr({bu:t,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:l}=Z(),a=Nt(o);return!t.length&&!n?null:e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-bu",children:t.map(p=>{var d;const c=((d=p.top[0])==null?void 0:d.count)||1;return e.jsxs("li",{className:"bim-rh-bu-c",children:[e.jsxs("a",{className:"bim-rh-bu-h",href:a.node(p.id),children:[e.jsx("b",{children:l(p.label)}),e.jsx("span",{className:"bim-rh-num",children:s("readHome.nWorks",{n:Ve(p.count)})})]}),p.top.length>0&&e.jsx("ul",{className:"bim-rh-bu-l","aria-label":s("readHome.subClasses",{label:l(p.label)}),children:p.top.map(u=>e.jsx("li",{children:e.jsxs("a",{href:a.node(u.id),children:[e.jsx("span",{children:l(u.label)}),e.jsx("small",{className:"bim-rh-num",children:Ve(u.count)}),e.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(u.count/c*100)}%`}})]})},u.id))}),p.children_total>p.top.length&&e.jsx("a",{className:"bim-rh-bu-more",href:a.node(p.id),children:s("readHome.allNClasses",{label:l(p.label),n:p.children_total})})]},p.id)})}),!!n&&e.jsxs("p",{className:"bim-rh-uncl bim-rh-num",children:[e.jsx("b",{children:s("readHome.unclassified")}),e.jsx("span",{children:s("readHome.nWorks",{n:Ve(n)})}),e.jsx("span",{children:r?l(r):s("readHome.sibuUnclassifiedNote")}),e.jsx("a",{href:a.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Bc({periods:t,unknown:n,links:o}){const{t:r,convert:s,messages:l}=Z(),a=l.readHome.period,p=Nt(o),c=t.filter(m=>m.count>0);if(!c.length)return null;const d=c.reduce((m,h)=>m+h.count,0),u=Math.max(...c.map(m=>m.count));return e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"bim-rh-band",children:c.map(m=>{const h=m.label?s(m.label):a[m.key]??s(m.key),f=m.count/d,x=r("readHome.periodItem",{label:h,n:Ve(m.count)});return e.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:e.jsxs("a",{href:p.period(m.key),"data-k":Tc(m.count,u),"data-narrow":f<Nc?"":void 0,"aria-label":x,title:x,children:[e.jsx("span",{className:"bim-rh-pl",children:h}),e.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(h)[0]}),e.jsx("small",{className:"bim-rh-num",children:Ve(m.count)})]})},m.key)})}),e.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&e.jsx("span",{children:r("readHome.periodUnknown",{n:Ve(n)})}),e.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function Wc({authors:t,links:n}){const{t:o,convert:r}=Z(),s=Nt(n);return t.length?e.jsx("ul",{className:"bim-rh-authors",children:t.map(l=>e.jsxs("li",{className:"bim-rh-au",children:[e.jsxs("h3",{className:"bim-rh-au-h",children:[r(l.name),l.dynasty&&e.jsx("span",{children:r(l.dynasty)}),e.jsx("small",{className:"bim-rh-num",children:o("readHome.nPieces",{n:Ve(l.count)})})]}),e.jsx("ul",{children:l.items.map(a=>e.jsx("li",{children:e.jsx("a",{href:s.read(a.id),children:r(a.title)})},a.id))}),s.author&&e.jsx("a",{className:"bim-rh-more",href:s.author(l.name),children:o("readHome.authorAll",{name:r(l.name),n:l.count})})]},l.name))}):null}const Oc={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function Hx({sections:t,links:n,head:o,piecesMoreHref:r,className:s}){const{t:l}=Z(),a=t,p=Oc,c=a.topics.filter(h=>!h.shelf),d={picks:a.picks.length>0,topics:c.some(h=>h.items.length>0),famous:a.famous.length>0,sibu:a.bu.length>0||a.unclassified>0,period:a.periods.some(h=>h.count>0),pieces:a.pieces.authors.length>0},u=Object.keys(p).filter(h=>d[h]),m=h=>l(`readHome.nav.${h}`);return e.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[e.jsx("style",{children:mr}),e.jsxs("div",{className:"bim-rh-head",children:[o,e.jsx(Ic,{counts:a.counts})]}),u.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":l("readHome.navLabel"),children:e.jsx("ul",{children:u.map(h=>e.jsx("li",{children:e.jsx("a",{href:`#${p[h]}`,children:m(h)})},h))})}),e.jsxs("div",{className:"bim-rh-main",children:[d.picks&&e.jsx(nt,{id:p.picks,title:m("picks"),sub:l("readHome.picksSub"),children:e.jsx(Rc,{picks:a.picks,links:n})}),d.topics&&e.jsx(nt,{id:p.topics,title:m("topics"),sub:l("readHome.topicsSub"),children:e.jsx(Pc,{topics:c,links:n})}),d.famous&&e.jsx(nt,{id:p.famous,title:m("famous"),sub:l("readHome.famousSub"),children:e.jsx(Mc,{famous:a.famous,links:n})}),d.sibu&&e.jsx(nt,{id:p.sibu,title:m("sibu"),sub:l("readHome.sibuSub"),children:e.jsx(fr,{bu:a.bu,unclassified:a.unclassified,links:n})}),d.period&&e.jsx(nt,{id:p.period,title:m("period"),sub:l("readHome.periodSub"),children:e.jsx(Bc,{periods:a.periods,unknown:a.period_unknown,links:n})}),d.pieces&&e.jsx(nt,{id:p.pieces,title:m("pieces"),sub:l("readHome.piecesSub"),more:r?e.jsx("a",{className:"bim-rh-more",href:r,children:l("readHome.piecesMore")}):void 0,children:e.jsx(Wc,{authors:a.pieces.authors,links:n})})]})]})}const Fx="(max-width: 1079px)",Dx=`${An}, (pointer: coarse)`,Hc=`
|
|
1688
|
+
`,db=$o["zh-Hant"].period,Dc={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function Lt(e){return{...Dc,...e??{}}}function Sr(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 wi(e){return(e.authors??[]).filter(o=>o==null?void 0:o.name).map(o=>o.dynasty?`〔${o.dynasty}〕${o.name}`:o.name).join(" ")}function Uc(e,n=$o["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 Vc(e){return Math.max(150,Array.from(e).length*18+44)}function Gc(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 Yc=.04;function Ve(e){return e.toLocaleString("en-US")}function Kc({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,o)=>t.jsx("span",{children:n},o))})}function it({id:e,title:n,sub:o,more:r,children:s}){const{convert:a}=J(),l=`${e}-h`;return t.jsxs("section",{className:"bim-rh-sec",id:e,"aria-labelledby":l,children:[t.jsxs("div",{className:"bim-rh-hd",children:[t.jsx("h2",{id:l,children:a(n)}),o&&t.jsx("span",{className:"bim-rh-sub",children:o}),r]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function qc({counts:e}){const{t:n}=J();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:Ve(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:Ve(e.pieces)}),n("readHome.pieces")]})]})}function Xc({picks:e,links:n}){const{t:o,convert:r}=J(),s=Lt(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=wi(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(Kc,{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 Zc(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function _r({topic:e,links:n,hint:o,legendCount:r,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=J(),c=Lt(n);if(!e.items.length)return null;const p=r===void 0?l("readHome.shelfLegendCount"):r,u=Uc(e.items,l("readHome.shelfOther")),h=m=>{const f=m.records?Ve(m.records):Zc(m.text_count,l),x=Sr(m),k=[d(m.title),m.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",m.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(m.id),"data-orig":m.orig?"":void 0,"aria-label":k,title:k,style:{height:Vc(m.title)},children:[t.jsx(Kc,{text:d(m.title)}),f&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":m.records?"":void 0,children:f})]})},m.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(m=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(m.label),children:m.items.map(h)}),t.jsx("span",{"aria-hidden":"true",children:d(m.label)})]},m.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(m=>t.jsx("span",{children:d(m)},m))]})]})}const pb=4,En=e=>e>pb+1;function Jc({topic:e,links:n}){const{t:o,convert:r}=J(),s=Lt(n),[a,l]=g.useState(!1);if(!e.items.length)return null;const d=`bim-rh-g-${e.key}`;return t.jsxs("div",{className:"bim-rh-grp","data-cap":En(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:Ve(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Zc(c.text_count,o),u=Sr(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)})}),En(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 Qc({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(_r,{topic:s,links:n},s.key)),r.length>0&&t.jsx("div",{className:"bim-rh-groups",children:r.map(s=>t.jsx(Jc,{topic:s,links:n},s.key))})]})}function ed({famous:e,links:n}){const{t:o,convert:r}=J(),s=Lt(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 $r({bu:e,unclassified:n,links:o,unclassifiedNote:r}){const{t:s,convert:a}=J(),l=Lt(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:Ve(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:Ve(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:Ve(n)})}),t.jsx("span",{children:r?a(r):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function td({periods:e,unknown:n,links:o}){const{t:r,convert:s,messages:a}=J(),l=a.readHome.period,d=Lt(o),c=e.filter(h=>h.count>0);if(!c.length)return null;const p=c.reduce((h,m)=>h+m.count,0),u=Math.max(...c.map(h=>h.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(h=>{const m=h.label?s(h.label):l[h.key]??s(h.key),f=h.count/p,x=r("readHome.periodItem",{label:m,n:Ve(h.count)});return t.jsx("li",{style:{flex:`0 0 ${(f*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(h.key),"data-k":Gc(h.count,u),"data-narrow":f<Yc?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:m}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(m)[0]}),t.jsx("small",{className:"bim-rh-num",children:Ve(h.count)})]})},h.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:r("readHome.periodUnknown",{n:Ve(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:r("readHome.hoverHint")})]})]})}function nd({authors:e,links:n}){const{t:o,convert:r}=J(),s=Lt(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:Ve(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 id={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function ub({sections:e,links:n,head:o,piecesMoreHref:r,className:s}){const{t:a}=J(),l=e,d=id,c=l.topics.filter(m=>!m.shelf),p={picks:l.picks.length>0,topics:c.some(m=>m.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(m=>m.count>0),pieces:l.pieces.authors.length>0},u=Object.keys(d).filter(m=>p[m]),h=m=>a(`readHome.nav.${m}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:wr}),t.jsxs("div",{className:"bim-rh-head",children:[o,t.jsx(qc,{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(m=>t.jsx("li",{children:t.jsx("a",{href:`#${d[m]}`,children:h(m)})},m))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(it,{id:d.picks,title:h("picks"),sub:a("readHome.picksSub"),children:t.jsx(Xc,{picks:l.picks,links:n})}),p.topics&&t.jsx(it,{id:d.topics,title:h("topics"),sub:a("readHome.topicsSub"),children:t.jsx(Qc,{topics:c,links:n})}),p.famous&&t.jsx(it,{id:d.famous,title:h("famous"),sub:a("readHome.famousSub"),children:t.jsx(ed,{famous:l.famous,links:n})}),p.sibu&&t.jsx(it,{id:d.sibu,title:h("sibu"),sub:a("readHome.sibuSub"),children:t.jsx($r,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(it,{id:d.period,title:h("period"),sub:a("readHome.periodSub"),children:t.jsx(td,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(it,{id:d.pieces,title:h("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(nd,{authors:l.pieces.authors,links:n})})]})]})}const mb="(max-width: 1079px)",hb=`${Bn}, (pointer: coarse)`,od=`
|
|
1686
1689
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1687
1690
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1688
1691
|
.bim-mh-q { min-width: 0; }
|
|
@@ -1822,7 +1825,7 @@ ${Bx.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1822
1825
|
.bim-mh-cc0 { display: inline-block; margin-right: 8px; padding: 1px 7px; font-size: 11.5px; letter-spacing: 0.08em; background: ${i("check-fine-bg")}; color: ${i("check-fine-fg")}; }
|
|
1823
1826
|
|
|
1824
1827
|
/* ── 中屏 ── */
|
|
1825
|
-
@media ${
|
|
1828
|
+
@media ${mb} {
|
|
1826
1829
|
.bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
|
|
1827
1830
|
.bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1828
1831
|
.bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
@@ -1832,7 +1835,7 @@ ${Bx.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1832
1835
|
}
|
|
1833
1836
|
|
|
1834
1837
|
/* ── 手机 ── */
|
|
1835
|
-
@media ${
|
|
1838
|
+
@media ${Bn} {
|
|
1836
1839
|
.bim-mh-cg, .bim-mh-data { grid-template-columns: minmax(0, 1fr); }
|
|
1837
1840
|
.bim-mh-ge { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
1838
1841
|
.bim-mh-lin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
@@ -1849,8 +1852,8 @@ ${Bx.map((t,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1849
1852
|
.bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
|
|
1850
1853
|
}
|
|
1851
1854
|
|
|
1852
|
-
@media ${
|
|
1855
|
+
@media ${hb} {
|
|
1853
1856
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
1854
1857
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
1855
1858
|
}
|
|
1856
|
-
`,Fc={item:t=>`/item/${encodeURIComponent(t)}`,node:t=>`/catalog?node=${encodeURIComponent(t)}`};function Et(t){return{...Fc,...t??{}}}function Dc(t,n){if(t.lineage)return t.lineage(n);const o=t.item(n),r=o.indexOf("#"),[s,l]=r<0?[o,""]:[o.slice(0,r),o.slice(r)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${l}`}function xr(t,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(t/n*100)))}function Uc(t){const n=t.filter(d=>Number.isFinite(d.birth_year)||Number.isFinite(d.death_year)),o=t.filter(d=>!n.includes(d));if(!n.length)return{min:0,max:0,placed:[],missing:o};const r=d=>{const u=Number.isFinite(d.birth_year)?d.birth_year:d.death_year-50,m=Number.isFinite(d.death_year)?d.death_year:d.birth_year+50;return[Math.min(u,m),Math.max(u,m)]},s=n.map(r),l=Math.min(...s.map(d=>d[0])),a=Math.max(...s.map(d=>d[1])),p=Math.max(1,a-l),c=n.map((d,u)=>({p:d,from:s[u][0],to:s[u][1]})).sort((d,u)=>d.from-u.from).map(d=>({...d,left:(d.from-l)/p*100,width:Math.max(.8,(d.to-d.from)/p*100)}));return{min:l,max:a,placed:c,missing:o}}function ei(t,n=sn("zh-Hant")){return t<0?n("metaHome.yearBC",{n:-t}):String(t)}function Ux(t){return{read:t.item,work:t.item,node:t.node}}function Vc({counts:t,links:n}){const{t:o}=Z(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),t.works],["book",o("metaHome.typeLabel.book"),t.books],["collection",o("metaHome.typeLabel.collection"),t.collections],["entity",o("metaHome.typeLabel.entity"),t.entities]];return e.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([l,a,p])=>e.jsx("li",{children:e.jsxs("a",{href:r(l),children:[e.jsx("b",{children:a}),p!=null&&p>0&&e.jsx("small",{children:Ve(p)})]})},l))})}function Gc(t,n=5){const[o,r]=g.useState(null);g.useEffect(()=>{let l=!1;const a=Tt().slice(0,n);if(!a.length||!t){r([]);return}return Promise.all(a.map(p=>_o(t,p))).then(p=>{l||r(p.filter(c=>!c.notFound))}),()=>{l=!0}},[t,n]);const s=g.useCallback(()=>{So(),r([])},[]);return{entries:o,clear:s}}function Vx(t,n,o){const r=t.type==="book"?t.edition||t.era:t.type==="collection"?"":t.dynasty;return r?o(r):Yc(t.type,n)}function Yc(t,n){return n(`metaHome.typeLabel.${t}`)}function Kc({entries:t,onClear:n,links:o}){const{t:r,convert:s}=Z(),l=Et(o);return e.jsxs("aside",{className:"bim-mh-recent","aria-labelledby":"bim-mh-recent-h",children:[e.jsxs("div",{className:"bim-mh-recent-h",children:[e.jsx("h2",{id:"bim-mh-recent-h",children:r("metaHome.recentTitle")}),t&&t.length>0&&n&&e.jsx("button",{type:"button",onClick:n,children:r("metaHome.recentClear")})]}),t&&t.length>0&&e.jsx("ol",{children:t.map(a=>e.jsx("li",{children:e.jsxs("a",{href:l.item(a.id),"aria-label":r("metaHome.recentItemLabel",{type:a.type?Yc(a.type,r):"",title:s(a.title)}),children:[e.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:a.type?r(`metaHome.typeShort.${a.type}`):""}),e.jsx("span",{children:s(a.title)}),e.jsx("small",{"aria-hidden":"true",children:Vx(a,r,s)})]})},a.id))}),t&&t.length===0&&e.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function qc(t,n,o,r=!1){return r&&(t==="done"||t==="in_progress")?n(`metaHome.siteStatus.${t}`):t==="done"||t==="in_progress"||t==="todo"?n(`metaHome.status.${t}`):o(t)}function Xc({rows:t,links:n}){const{t:o,convert:r}=Z(),s=Et(n);return t.length?e.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":o("metaHome.catalogTitle"),children:e.jsxs("table",{className:"bim-mh-tbl",children:[e.jsxs("caption",{children:[o("metaHome.catalogTitle"),e.jsx("small",{children:o("metaHome.catalogNote")})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:o("metaHome.colCatalog")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colRecords")}),e.jsx("th",{scope:"col",className:"bim-mh-r",children:o("metaHome.colMatched")}),e.jsx("th",{scope:"col",children:o("metaHome.colProgress")}),e.jsx("th",{scope:"col",children:o("metaHome.colStatus")})]})}),e.jsx("tbody",{children:t.map(l=>{const a=xr(l.imported,l.total),p=l.work_id??l.collection_id,c=r(l.edition?`${l.name}·${l.edition}`:l.name);return e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:p?e.jsx("a",{href:s.item(p),children:c}):c}),e.jsx("td",{className:"bim-mh-r",children:Ve(l.total)}),e.jsx("td",{className:"bim-mh-r",children:Ve(l.imported)}),e.jsx("td",{children:e.jsxs("span",{className:"bim-mh-meter",children:[e.jsx("i",{"aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[a,"%"]})]})}),e.jsx("td",{children:l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:qc(l.status,o,r)})})]},l.id||l.name)})})]})}):null}function Zc({items:t,links:n,label:o}){const{convert:r}=Z();return e.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):void 0,children:t.map(s=>e.jsx("li",{children:e.jsxs("a",{href:n.item(s.id),children:[e.jsx("span",{className:"bim-rh-t",children:r(s.title)}),s.sub&&e.jsx("small",{children:r(s.sub)})]})},s.id))})}function Jc({works:t,links:n}){const{t:o}=Z(),[r,s]=g.useState(!1);if(!t.length)return null;const l=zn(t.length);return e.jsxs("div",{className:"bim-rh-grp","data-cap":l?"":void 0,"data-open":r?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[o("metaHome.relatedTitle"),e.jsx("small",{children:o("metaHome.relatedNote")})]}),e.jsx(Zc,{items:t.map(a=>({id:a.id,title:a.title,sub:fi(a)||void 0})),links:Et(n)}),l&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":r,onClick:()=>s(a=>!a),children:r?o("action.collapse"):o("metaHome.allNWorks",{n:t.length})})]})}const Qc="siku_qige";function Gx({group:t,links:n}){const{t:o,convert:r}=Z(),[s,l]=g.useState(!1);return e.jsxs("div",{className:"bim-rh-grp","data-cap":zn(t.items.length)?"":void 0,"data-open":s?"":void 0,children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(t.label),e.jsx("small",{className:"bim-rh-num",children:o("metaHome.nKinds",{n:t.items.length})})]}),e.jsx(Zc,{items:t.items,links:n,label:t.label}),zn(t.items.length)&&e.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>l(a=>!a),children:s?o("action.collapse"):o("metaHome.allNKinds",{n:t.items.length})})]})}function ed({groups:t,links:n}){const{t:o,convert:r}=Z(),s=Et(n);if(!t.length)return null;const l=t.find(c=>c.key===Qc),a=t.filter(c=>c!==l),p=c=>{var d;return((d=c.match(/(文[^\s·・閣阁]+)[閣阁]/))==null?void 0:d[1])??c};return e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"bim-rh-gt",children:[r(l.label),e.jsx("small",{children:r(l.items.map(c=>p(c.title)).join("、"))})]}),e.jsx("ul",{className:"bim-mh-ge","aria-label":r(l.label),children:l.items.map(c=>e.jsx("li",{children:e.jsxs("a",{href:s.item(c.id),"aria-label":r(c.title),title:r(c.title),children:[e.jsx("span",{"aria-hidden":"true",children:r(p(c.title))}),p(c.title)!==c.title&&e.jsx("small",{"aria-hidden":"true",children:o("metaHome.pavilion")})]})},c.id))})]}),a.length>0&&e.jsx("div",{className:"bim-mh-cg",style:l?void 0:{marginTop:0},children:a.map(c=>e.jsx(Gx,{group:c,links:s},c.key))})]})}const Xs=34,Zs=13;function Js(t,n){return t.birth_year==null&&t.death_year==null?"":`${t.birth_year!=null?ei(t.birth_year,n):"?"}–${t.death_year!=null?ei(t.death_year,n):"?"}`}function Yx(t,n){const o=n-t,r=o>1200?300:o>400?100:50,s=[];for(let l=Math.ceil(t/r)*r;l<=n;l+=r)s.push(l);return s}function td({people:t,links:n}){const{t:o,convert:r}=Z(),s=Et(n);if(!t.length)return null;const{min:l,max:a,placed:p,missing:c}=Uc(t),d=[],u=p.map(h=>{const f=h.left>70,x=f?Math.min(h.left,h.left+h.width-Zs):h.left;let j=0;for(;d[j]!=null&&d[j]>x;)j++;return d[j]=f?h.left+h.width:h.left+Math.max(h.width,Zs),{...h,lane:j,end:f}}),m=Math.max(1,a-l);return e.jsxs(e.Fragment,{children:[u.length>0&&e.jsxs("div",{className:"bim-mh-tl",children:[e.jsx("ul",{className:"bim-mh-tl-rows",style:{height:d.length*Xs+10},children:u.map(h=>e.jsxs("li",{className:"bim-mh-tl-bar","data-end":h.end?"":void 0,style:{left:`${h.left}%`,top:h.lane*Xs+4,width:`${Math.max(h.width,.5)}%`},children:[e.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),e.jsxs("a",{href:s.item(h.p.id),children:[r(h.p.name),e.jsx("small",{className:"bim-rh-num",children:Js(h.p,o)})]})]},h.p.id))}),e.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:Yx(l,a).map(h=>e.jsx("span",{style:{left:`${(h-l)/m*100}%`},children:ei(h,o)},h))})]}),e.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?t:c).map(h=>e.jsx("li",{children:e.jsxs("a",{href:s.item(h.id),children:[e.jsx("span",{children:r(h.name)}),e.jsx("small",{className:"bim-rh-num",children:[h.dynasty?r(h.dynasty):"",Js(h,o)].filter(Boolean).join(" ")})]})},h.id))}),c.length>0&&u.length>0&&e.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(h=>h.name).join("、"))})})]})}const Kx=e.jsxs("svg",{width:"54",height:"34",viewBox:"0 0 54 34",fill:"none",stroke:"currentColor",strokeWidth:"1.4","aria-hidden":"true",children:[e.jsx("circle",{cx:"27",cy:"5",r:"3.5"}),e.jsx("circle",{cx:"10",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"27",cy:"29",r:"3.5"}),e.jsx("circle",{cx:"44",cy:"29",r:"3.5"}),e.jsx("path",{d:"M27 8.5v17M27 15H10v10.5M27 15h17v10.5"})]});function nd({works:t,links:n}){const{t:o,convert:r}=Z(),s=Et(n);return t.length?e.jsx("ul",{className:"bim-mh-lin",children:t.map(l=>{const a=fi(l);return e.jsx("li",{children:e.jsxs("a",{href:Dc(s,l.id),children:[Kx,e.jsx("b",{children:r(l.title)}),a&&e.jsx("small",{children:r(a)}),e.jsx("span",{children:o("metaHome.viewLineage")})]})},l.id)})}):null}function id({sites:t}){const{t:n,convert:o}=Z(),r=t.filter(l=>l.status!=="todo"&&l.total>0),s=t.filter(l=>!r.includes(l));return t.length?e.jsxs(e.Fragment,{children:[r.length>0&&e.jsx("ul",{className:"bim-mh-cov",children:r.map(l=>{const a=xr(l.imported,l.total);return e.jsxs("li",{children:[l.url?e.jsx("a",{href:l.url,rel:"noopener noreferrer",target:"_blank",children:o(l.name)}):e.jsx("span",{children:o(l.name)}),e.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${a}%`}}),e.jsxs("small",{children:[`${Ve(l.imported)} / ${Ve(l.total)} ${a}% `,l.status&&e.jsx("span",{className:"bim-mh-st","data-st":l.status,children:qc(l.status,n,o,!0)})]})]},l.id||l.name)})}),s.length>0&&e.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:o(s.map(l=>l.name).join("、"))})})]}):null}const Qs=["extant","partially_extant","lost","unknown"];function od({stats:t,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:l}=Z(),a=["works","books","collections","entities","has_image","has_text","article","poem"].map(d=>[t[d],l(`metaHome.stat.${d}`)]).filter(([d])=>d>0),p=n==null?void 0:n.loss,c=Qs.some(d=>{var u;return(((u=t.loss)==null?void 0:u[d])??0)>0});return e.jsxs("div",{className:"bim-mh-data",children:[a.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.dataScale")}),e.jsx("ul",{className:"bim-mh-nums",children:a.map(([d,u])=>e.jsxs("li",{children:[e.jsx("b",{className:"bim-rh-num",children:Ve(d)}),e.jsx("span",{children:u})]},u))})]}),p&&e.jsxs("div",{children:[e.jsx("h3",{className:"bim-rh-gt",children:l("metaHome.byLoss")}),e.jsx("ul",{className:"bim-mh-loss",children:Qs.map(d=>{var h;const u=((h=t.loss)==null?void 0:h[d])??0,m=l(`metaHome.lossNote.${d}`);return e.jsx("li",{children:e.jsxs("a",{href:p(d),children:[l(`metaHome.loss.${d}`),e.jsx("small",{className:"bim-rh-num",children:c&&u>0?l("metaHome.lossCount",{n:Ve(u),note:m}):m})]})},d)})})]}),e.jsxs("div",{className:"bim-mh-lic",children:[e.jsxs("p",{children:[e.jsx("span",{className:"bim-mh-cc0",children:"CC0"}),l("metaHome.license")]}),e.jsxs("p",{children:[l("metaHome.repo"),r?e.jsx("a",{href:r,children:e.jsx("code",{children:"book-index"})}):e.jsx("code",{children:"book-index"}),l("metaHome.repoNote")]}),o&&e.jsxs("p",{children:[l("metaHome.version"),e.jsx("code",{children:o})]}),s&&e.jsx("p",{children:e.jsx("a",{href:s,children:l("metaHome.download")})})]})]})}const rd={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function qx({sections:t,links:n,head:o,transport:r,catalogHref:s,collectionsHref:l,entitiesHref:a,version:p,repoUrl:c,downloadHref:d,className:u}){var k,$;const{t:m}=Z(),h=t,f=Et(n),x=Ux(f),j=rd,y=Gc(r),_={zhi:!!((k=h.shelf)!=null&&k.items.length)||h.catalog_progress.length>0||h.related_catalogs.length>0,sibu:h.bu.length>0||h.unclassified>0,cong:h.collection_groups.length>0,people:h.bibliographers.length>0,lineage:h.lineage.length>0,sites:h.sites.length>0,data:!0},b=Object.keys(j).filter(w=>_[w]),v=w=>m(`metaHome.nav.${w}`),S=(w,z)=>w?e.jsx("a",{className:"bim-rh-more",href:w,children:z}):void 0;return e.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[e.jsx("style",{children:mr+Hc}),e.jsxs("div",{className:"bim-mh-head",children:[e.jsxs("div",{className:"bim-mh-q",children:[o,e.jsx(Vc,{counts:h.counts,links:n})]}),r&&e.jsx(Kc,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&e.jsx("nav",{className:"bim-rh-secnav","aria-label":m("metaHome.navLabel"),children:e.jsx("ul",{children:b.map(w=>e.jsx("li",{children:e.jsx("a",{href:`#${j[w]}`,children:v(w)})},w))})}),e.jsxs("div",{className:"bim-rh-main",children:[_.zhi&&e.jsxs(nt,{id:j.zhi,title:v("zhi"),sub:m("metaHome.zhiSub"),children:[h.shelf&&h.shelf.items.length>0&&e.jsx(gr,{topic:{key:"shelf",label:h.shelf.label,shelf:!0,items:h.shelf.items},links:x,showTitle:!1,legendCount:h.shelf.items.some(w=>w.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(h.catalog_progress.length>0||h.related_catalogs.length>0)&&e.jsxs("div",{className:"bim-mh-zhi",style:($=h.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[e.jsx(Xc,{rows:h.catalog_progress,links:n}),e.jsx(Jc,{works:h.related_catalogs,links:n})]})]}),_.sibu&&e.jsx(nt,{id:j.sibu,title:v("sibu"),sub:m("metaHome.sibuSub"),more:S(s,m("metaHome.toCatalog")),children:e.jsx(fr,{bu:h.bu,unclassified:h.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),_.cong&&e.jsx(nt,{id:j.cong,title:v("cong"),sub:m("metaHome.congSub"),more:S(l,m("metaHome.allNKindsMore",{n:Ve(h.counts.collections)})),children:e.jsx(ed,{groups:h.collection_groups,links:n})}),_.people&&e.jsx(nt,{id:j.people,title:v("people"),sub:m("metaHome.peopleSub"),more:S(a,m("metaHome.allNPeopleMore",{n:Ve(h.counts.entities)})),children:e.jsx(td,{people:h.bibliographers,links:n})}),_.lineage&&e.jsx(nt,{id:j.lineage,title:v("lineage"),sub:m("metaHome.lineageSub"),children:e.jsx(nd,{works:h.lineage,links:n})}),_.sites&&e.jsx(nt,{id:j.sites,title:v("sites"),sub:m("metaHome.sitesSub"),children:e.jsx(id,{sites:h.sites})}),e.jsx(nt,{id:j.data,title:v("data"),sub:m("metaHome.dataSub"),children:e.jsx(od,{stats:h.stats,links:n,version:p,repoUrl:c,downloadHref:d})})]})]})}const ho=({style:t})=>{const n=g.useContext(Dt),{t:o}=Z();if(!n)return null;const{locale:r,setLocale:s}=n,l=r==="zh-Hant",a=()=>s(l?"zh-Hans":"zh-Hant");return e.jsxs("button",{type:"button",onClick:a,title:o(l?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${i("border")}`,borderRadius:"4px",background:i("bg"),color:i("fg"),cursor:"pointer",userSelect:"none",...t},children:[e.jsx("span",{style:{color:l?i("primary"):void 0,fontWeight:l?700:400},children:o("common.localeShortHant")}),e.jsx("span",{style:{opacity:.3},children:"/"}),e.jsx("span",{style:{color:l?void 0:i("primary"),fontWeight:l?400:700},children:o("common.localeShortHans")})]})},go=({href:t,label:n,size:o=16,className:r,style:s})=>{const{t:l}=Z(),a=n??l("common.repoSourceLink");return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",title:a,"aria-label":a,className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:o+8,height:o+8,borderRadius:4,color:i("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:p=>{p.currentTarget.style.color=i("fg")},onMouseLeave:p=>{p.currentTarget.style.color=i("desc-fg")},children:e.jsx("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})})};function Di(t){const n=t.text_count;return typeof n=="number"&&n>0}function Ui(t,n){return{id:t,title:n.title??n.primary_name??t,type:n.type??"book"}}function Xx(t,n){if(!n)return!1;const o=n.id;return o===void 0||o===t}const Zx=({id:t,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:l,activeJuan:a,onJuanChange:p,lineageMode:c="list",onLineageModeChange:d,lineageCollection:u,onLineageCollectionChange:m,initialPage:h=1,selectedLineageNodeId:f,onNavigate:x,onBack:j,backLabel:y,renderLink:_,enrichDetail:b,getSourceLink:v,readLink:S,railTop:k,extraTabs:$=[],showFeedbackTab:w=!0,feedbackApiUrl:z,height:B,footerExtra:I,hideHeaderControls:N=!1,className:O,style:C})=>{const T=$e(),{t:R,convert:A}=Z(),[H]=g.useState(()=>{if(!Xx(t,o))return null;const V={...o},ce=r??Ui(t,V);return b&&b(ce,V),{id:t,entry:ce,detail:V}}),[q,ne]=g.useState((H==null?void 0:H.entry)??null),[L,Q]=g.useState((H==null?void 0:H.detail)??null),[P,D]=g.useState(!H),[pe,le]=g.useState(!1),[fe,ue]=g.useState([]),[xe,Ee]=g.useState(!1),[ie,Ae]=g.useState(null),[He,Y]=g.useState(null),[J,he]=g.useState(null),[ze,G]=g.useState(!1),ve=g.useRef(null),ae=g.useRef(0),[Se,K]=g.useState(null),Ce=a!==void 0?a:Se,Pe=g.useCallback(V=>{p?p(V):K(V)},[p]),M=g.useCallback(async V=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){ue([]);return}Ee(!0);try{if(n.getCollectionCatalogs)ue(await n.getCollectionCatalogs(V)||[]);else if(n.getCollectionCatalog){const ce=await n.getCollectionCatalog(V);ue(ce?[{resource_id:"",data:ce}]:[])}}catch{ue([])}finally{Ee(!1)}},[n]),ee=g.useCallback(async V=>{var ce,Te;if(!n.getTextManifest||!n.getTextIndex){Ae(null),Y(V);return}try{const Ie=we.pickTextVersion(await n.getTextManifest(V)),U=Ie?await n.getTextIndex(V,Ie.key):null;Ae(U&&U.chapters.length>0?{chapters:U.chapters.map(X=>({n:X.n,title:X.title,file:X.file})),source:{name:((ce=U.source)==null?void 0:ce.name)??(Ie==null?void 0:Ie.source_name),license:((Te=U.source)==null?void 0:Te.license)??(Ie==null?void 0:Ie.license)??void 0}}:null)}catch{Ae(null)}finally{Y(V)}},[n]),be=g.useCallback(async(V,ce)=>{const Te=++ae.current,Ie=()=>Te!==ae.current;G(!0);try{if(n.getLineageGraph){const We=await n.getLineageGraph(V);if(Ie())return;We&&he(We)}const U=ce.version_graph;if(!U||!U.enabled){J||he(null),ve.current=null;return}const X=ce.books??[],Le=[];for(const We of X)try{const ot=await n.getItem(We);ot&&Le.push(ot)}catch{}if(Ie())return;ve.current={work:ce,books:Le};const _e=u??U.default_collection??(U.core_books&&U.core_books.length>0?"core":"all"),De=_e==="core"&&Array.isArray(U.core_books)&&U.core_books.length>0?"core":_e??"all";he(Yn(ce,Le,De))}catch{if(Ie())return;he(null),ve.current=null}finally{Ie()||G(!1)}},[n]),W=g.useRef({initialDetail:o,initialEntry:r});W.current={initialDetail:o,initialEntry:r},g.useEffect(()=>{let V=!1;ae.current++,G(!1);const ce=X=>{X.type==="collection"?M(t):X.type==="work"?(X.version_graph||n.getLineageGraph)&&be(t,X):X.type==="book"&&Di(X)&&ee(t)},Te=W.current;let Ie=null;if(H&&H.id===t)Ie=H;else if(Te.initialDetail&&Te.initialDetail.id===t){const X={...Te.initialDetail},Le=Te.initialEntry??Ui(t,X);b&&b(Le,X),Ie={entry:Le,detail:X}}return Ie?(le(!1),ue(X=>X.length?[]:X),Ae(null),he(null),ve.current=null,ne(Ie.entry),Q(Ie.detail),D(!1),ce(Ie.detail),()=>{V=!0}):((async()=>{D(!0),le(!1),ne(null),Q(null),ue([]),Ae(null),he(null),ve.current=null;try{const X=await n.getItem(t);if(V)return;if(!X){le(!0);return}const Le=X;let _e=null;if(n.getEntry&&(_e=await n.getEntry(t),V))return;_e||(_e=Ui(t,Le)),b&&b(_e,Le),ne(_e),Q(Le),ce(Le)}catch{V||le(!0)}finally{V||D(!1)}})(),()=>{V=!0})},[t,n,H,b,M,be,ee]),g.useEffect(()=>{const V=ve.current;!V||!u||he(Yn(V.work,V.books,u))},[u]);const re=[];if(L){if(re.push({key:"basic",label:T.detailTab.basicInfo}),L.type==="collection"){xe&&fe.length===0&&re.push({key:"catalog:loading",label:`${T.detailTab.catalog}…`});for(const V of fe)re.push({key:`catalog:${V.resource_id}`,label:V.short_name?`${A(V.short_name)}${T.detailTab.catalogSuffix}`:T.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&re.push({key:s,label:T.detailTab.fullText}),L.type==="work"&&(J||ze)&&re.push({key:"lineage",label:ze?`${T.detailTab.lineage}…`:T.detailTab.lineage});for(const V of $)(V.position??"before-feedback")==="before-feedback"&&V.shouldShow(L)&&re.push({key:V.key,label:V.label});w&&s==="feedback"&&re.push({key:"feedback",label:T.detailTab.feedback});for(const V of $)V.position==="after-feedback"&&V.shouldShow(L)&&re.push({key:V.key,label:V.label})}g.useEffect(()=>{if(s!=="emendated"||!L)return;l("basic");const V=setTimeout(()=>{var ce;(ce=document.getElementById("studies"))==null||ce.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(V)},[s,L,l]);const te=q&&L&&v?v({activeTab:s,activeJuan:Ce,entry:q,detail:L}):null,me=g.useMemo(()=>{var U;if(!L)return null;const ce=(L.authors??[]).map(X=>{const Le=Ao(X.role);return`${X.dynasty?`〔${A(X.dynasty)}〕`:""}${A(X.name)}${Le?` ${A(Le)}`:""}`}).join(" · ");let Te=!1;try{Te=we.extractStatus(L.id)==="draft"}catch{}if(L.type==="book"){const X=L;return{title:A(X.title),subtitle:X.edition?A(X.edition):ce||void 0,aside:[Te?T.status.draft:"",ce&&X.edition?ce:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(L.type==="collection"){const X=L;return{title:A(X.title),subtitle:A(_t(X,T.unit.juan))||void 0,aside:[(U=X.publication_info)==null?void 0:U.year,Te?T.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ce||void 0}}if(L.type==="entity"){const X=L,Le=De=>De==null?"":De<0?R("detail.bce",{n:-De}):String(De),_e=X.birth_year!=null||X.death_year!=null?`${Le(X.birth_year)||"?"}—${Le(X.death_year)||"?"}`:"";return{title:A(X.primary_name||X.title),subtitle:[X.dynasty?`〔${A(X.dynasty)}〕`:"",_e].filter(Boolean).join(" ")||void 0,aside:Te?T.status.draft:void 0,secondLine:void 0}}const Ie=A(_t(L,T.unit.juan));return{title:A(L.title),subtitle:[Ie,ce].filter(Boolean).join(" · ")||void 0,aside:[Qx(T,L.subtype),Te?T.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[L,A,T,R]),Ne=L&&Di(L)?"text":null,Me=()=>{Pe(null),l("fulltext")};let Be=null;if(L&&S){const V=S({detail:L,kind:Ne});V&&(Be=e.jsx(to,{href:V}))}else Ne&&(Be=e.jsx(to,{onClick:Me}));const Fe=V=>{if(!L)return null;const ce=V.replace(/\.[^.]+$/,"");if(S){const Te=S({detail:L,kind:Ne,juan:ce});return Te?{href:Te}:null}return{onClick:()=>{Pe(ce),l("fulltext")}}},Ze=new Set($.map(V=>V.key)),de=re.filter(V=>V.key.startsWith("catalog:")&&V.key!=="catalog:loading"||V.key==="lineage"&&!!J&&!ze||Ze.has(V.key)).map(V=>({key:V.key,label:V.label,onClick:()=>l(V.key)})),Qe=()=>{var V;return L?L.type==="work"?e.jsx(dc,{data:L,transport:n,onNavigate:x,renderLink:_,readAction:Be,railTop:k,railLinks:de}):L.type==="book"?e.jsx(hc,{data:L,transport:n,onNavigate:x,renderLink:_,readAction:Be,fullText:ie,fullTextPending:Di(L)&&!!n.getTextManifest&&He!==L.id,chapterLink:Fe,railTop:k,railLinks:de}):L.type==="collection"?e.jsx(gc,{data:L,catalog:(V=fe[0])==null?void 0:V.data,transport:n,onNavigate:x,renderLink:_,readAction:Be,railTop:k,railLinks:de,catalogAction:fe.length>0?e.jsxs("a",{href:"#catalog",onClick:ce=>{ce.preventDefault(),l(`catalog:${fe[0].resource_id}`)},children:[A(T.detailTab.collectionCatalog)," →"]}):null}):e.jsx(fc,{data:L,transport:n,onNavigate:x,renderLink:_,railTop:k,railLinks:de}):null},E=()=>{var ce,Te,Ie;if(!q||!L)return null;if(s==="basic"||s==="emendated")return Qe();if(typeof s=="string"&&s.startsWith("catalog:")){const U=(ce=fe.find(X=>`catalog:${X.resource_id}`===s))==null?void 0:ce.data;return e.jsx(Co,{data:U,onNavigate:x,renderLink:_})}if(s==="collated"||s==="fulltext")return e.jsx(or,{id:t,transport:n,chapter:Ce,onLocationChange:U=>Pe(U.chapter),onNavigate:x});if(s==="lineage"){if(!J)return e.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:R(ze?"detail.loading":"detail.noLineageGraph")});const U=L.type==="work"?L:null;return e.jsx(cr,{graph:J,renderLink:_,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:d,selectedNodeId:f,collection:u??((Te=U==null?void 0:U.version_graph)==null?void 0:Te.default_collection),onCollectionChange:m,collectionsAvailable:(Ie=U==null?void 0:U.version_graph)==null?void 0:Ie.collections,collectionCounts:(()=>{var De,We,ot,It,Pn,dn,Rt;if(!U)return;const X={},Le=((De=ve.current)==null?void 0:De.books)??[];X.all=(((We=U.books)==null?void 0:We.length)??0)-(((It=(ot=U.version_graph)==null?void 0:ot.excluded_books)==null?void 0:It.length)??0);const _e=(Pn=U.version_graph)==null?void 0:Pn.collections;if(_e)for(const pn of Object.keys(_e))X[pn]=Yn(U,Le,pn).nodes.filter(un=>un.kind==="book"&&!un.bridge).length;return X.core==null&&((Rt=(dn=U.version_graph)==null?void 0:dn.core_books)!=null&&Rt.length)&&(X.core=U.version_graph.core_books.length),X})()})}if(s==="feedback"&&w)return e.jsx(sc,{resourceId:t,apiUrl:z});const V=$.find(U=>U.key===s);return V?V.render({detail:L,entry:q,transport:n,onNavigate:x}):null};if(P)return e.jsx(kn,{style:{minHeight:B,...C},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((V,ce)=>e.jsx("div",{style:{height:ce===1?40:16,width:V,opacity:.35,background:i("rule")}},ce))})});if(pe||!L||!q||!me)return e.jsx(kn,{style:{minHeight:B,...C},children:e.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:R("detail.notFound")})});const oe=s==="basic"||s==="emendated",se=[{label:y??T.detailTab.backToIndex,onClick:j}];if(L.type==="book"&&L.work_id){const V=L.work_id;se.push({label:T.indexType.work,id:V,onClick:()=>x==null?void 0:x(V)})}se.push({label:T.indexType[L.type]});const je=s==="collated"||s==="fulltext",ke=typeof I=="string"?T.status[I.trim()]??I:I,ge=e.jsx(wa,{left:e.jsxs(e.Fragment,{children:[ke,ke?" · ":"",e.jsx(Jx,{id:L.id,label:T.label.id,copied:T.action.copied,copyLabel:T.action.copy})]}),right:e.jsxs(e.Fragment,{children:[w&&!oe&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:T.detailTab.submitVersion}),te&&e.jsx("a",{href:te.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:T.detailTab.dataLicense})]})});return oe?e.jsx("div",{className:O,children:e.jsxs(kn,{grid:!0,style:{minHeight:B,...C},children:[e.jsx(no,{breadcrumb:e.jsx(io,{items:se}),actions:e.jsxs(e.Fragment,{children:[!N&&e.jsx(ho,{style:{border:"none",background:"transparent"}}),!N&&te&&e.jsx(go,{...te})]})}),Qe(),ge]})}):e.jsx("div",{className:O,children:e.jsxs(kn,{wide:je,style:{minHeight:B,...C},children:[e.jsx(no,{breadcrumb:e.jsxs(e.Fragment,{children:[e.jsx(Wo,{char:"籍"}),e.jsx(io,{items:se})]}),actions:e.jsxs(e.Fragment,{children:[!N&&e.jsx(ho,{}),w&&e.jsx("button",{type:"button",onClick:()=>l("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:T.detailTab.feedback}),!N&&te&&e.jsx(go,{...te})]})}),e.jsx(ha,{...me,aside:je?e.jsxs("button",{type:"button",onClick:()=>l("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[R("detail.workInfo")," →"]}):me.aside}),!je&&re.length>1&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:re.map(V=>e.jsx(ga,{label:V.label,active:V.key===s||oe&&V.key==="basic",onClick:()=>l(V.key)},V.key))}),e.jsx("div",{style:{marginTop:!je&&re.length>1?8:0},children:E()}),ge]})})};function Jx({id:t,label:n,copied:o,copyLabel:r}){const[s,l]=g.useState(!1);return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[e.jsxs("span",{children:[n," ",t]}),e.jsx("button",{type:"button",onClick:()=>{var a;(a=navigator.clipboard)==null||a.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1500)}).catch(()=>{})},title:s?o:r,"aria-label":s?o:r,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:i("aux-fg")},children:s?"✓":"⧉"})]})}function Qx(t,n){return n?t.workSubtype[n]??n:""}const sd=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],xi="zhusha",bi="bim-theme";function ld(t){return t==="zhusha"||t==="indigo"||t==="ink"}function yi(t){return ld(t)?t:xi}function eb(){try{return yi(window.localStorage.getItem(bi))}catch{return xi}}function ad(t){try{window.localStorage.setItem(bi,t)}catch{}}function cd(t){const n=yi(t);return document.documentElement.setAttribute("data-theme",n),n}function dd(){return yi(document.documentElement.getAttribute("data-theme"))}const tb=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],br="airy",ji="bim-layout";function pd(t){return t==="airy"||t==="boxed"}function vi(t){return pd(t)?t:br}function nb(){try{return vi(window.localStorage.getItem(ji))}catch{return br}}function ib(t){try{window.localStorage.setItem(ji,t)}catch{}}function ob(t){const n=vi(t);return document.documentElement.setAttribute("data-layout",n),n}function rb(){return vi(document.documentElement.getAttribute("data-layout"))}const sb=`try{var t=localStorage.getItem(${JSON.stringify(bi)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(ji)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,lb={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},ab=({onChange:t,style:n})=>{const{t:o}=Z(),[r,s]=g.useState(xi);g.useEffect(()=>{s(dd())},[]);const l=a=>{s(cd(a)),ad(a),t==null||t(a)};return e.jsx("div",{role:"radiogroup","aria-label":o("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:sd.map(a=>{const p=r===a.name;return e.jsx("button",{type:"button",role:"radio","aria-checked":p,"aria-label":o(`common.theme.${a.name}`),title:o(`common.theme.${a.name}`),onClick:()=>l(a.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:i(lb[a.name]),boxShadow:p?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},a.name)})})};exports.BidLink=we.BidLink;exports.BookIndexError=we.BookIndexError;exports.BookIndexManager=we.BookIndexManager;exports.BookIndexStorage=we.BookIndexStorage;exports.BundleStorage=we.BundleStorage;exports.ConfigError=we.ConfigError;exports.GithubStorage=we.GithubStorage;exports.IdGenerationError=we.IdGenerationError;exports.IdGenerator=we.IdGenerator;exports.LocalStorage=we.LocalStorage;exports.MigrationError=we.MigrationError;exports.StorageError=we.StorageError;exports.VARIANT_CHARS=we.VARIANT_CHARS;exports.base36Decode=we.base36Decode;exports.base36Encode=we.base36Encode;exports.base58Decode=we.base58Decode;exports.buildId=we.buildId;exports.buildPromotionMap=we.buildPromotionMap;exports.cleanName=we.cleanName;exports.decodeId=we.decodeId;exports.decodeIdString=we.decodeIdString;exports.encodeId=we.encodeId;exports.extractIdFromUrl=we.extractIdFromUrl;exports.extractStatus=we.extractStatus;exports.extractType=we.extractType;exports.isChapterSegment=we.isChapterSegment;exports.isTextKey=we.isTextKey;exports.matchChapterAcrossVersions=we.matchChapterAcrossVersions;exports.normalizeCatalog=we.normalizeCatalog;exports.normalizeVariants=we.normalizeVariants;exports.parseId=we.parseId;exports.pickTextVersion=we.pickTextVersion;exports.shardOf=we.shardOf;exports.smartDecode=we.smartDecode;exports.textVersionLabel=we.textVersionLabel;exports.validateResource=we.validateResource;exports.Badge=Qn;exports.BidUrlProvider=Ed;exports.BookDetailLayout=Zx;exports.BookPage=hc;exports.Breadcrumb=io;exports.CATALOG_ALL_ID=kt;exports.CATALOG_CSS=xc;exports.CATALOG_NARROW_QUERY=dr;exports.CATALOG_PAGE_SIZE=pr;exports.CATALOG_UNCLASSIFIED_ID=Wt;exports.CLASSIFICATIONS=si;exports.COMMON_TRADITIONAL_CHARS=ll;exports.CardFoot=In;exports.CatalogPage=Ax;exports.CatalogPager=Sc;exports.CatalogTree=yc;exports.CheckFilter=pa;exports.Chip=fa;exports.ChipWall=km;exports.CollectionCatalog=Co;exports.CollectionPage=gc;exports.CreateEntityDialog=Ja;exports.DEFAULT_LAYOUT=br;exports.DEFAULT_META_HOME_LINKS=Fc;exports.DEFAULT_READER_PREFS=No;exports.DEFAULT_READ_HOME_LINKS=$c;exports.DEFAULT_THEME=xi;exports.DETAIL_CSS=ma;exports.DYNASTY_GROUPS=ri;exports.Dash=zm;exports.DataTable=Sm;exports.DetailFooter=wa;exports.DetailGrid=Nn;exports.DetailHeader=ha;exports.EMPTY_FILTERS=oi;exports.ENTITY_TEXT_CSS=er;exports.EmendatedBySection=El;exports.EmptyNote=Am;exports.EntityDetail=_l;exports.EntityMark=nr;exports.EntityPage=fc;exports.EntityPickerDialog=ec;exports.EntitySelector=Za;exports.EntityText=Dh;exports.ExpandRow=Tm;exports.ExtLink=Pm;exports.FEEDBACK_FAB_OFFSET_VAR=po;exports.FILTER_SUPPORT=fl;exports.FONT_SIZE_STEPS=vt;exports.FactList=bm;exports.FeedbackButton=wf;exports.FeedbackDialog=oc;exports.FeedbackForm=rc;exports.FeedbackList=rr;exports.FeedbackTab=sc;exports.FilterChip=ga;exports.FormInput=ct;exports.FormTextArea=Ht;exports.GUJI_MARKDOWN_FIELD=wu;exports.GUJI_TABLE_NOTATION=Ml;exports.GlyphBadge=Wo;exports.GujiInteractiveReader=kg;exports.GujiTable=Ho;exports.GujiTextViewer=ir;exports.GujiWarpCanvas=Jo;exports.HomePage=ao;exports.ImagePanel=qi;exports.IndexApp=vg;exports.IndexBrowser=Yi;exports.IndexDetail=$o;exports.IndexEditor=tc;exports.IndexView=cf;exports.IntroGrid=xm;exports.LAYOUTS=tb;exports.LAYOUT_STORAGE_KEY=ji;exports.LOSS_OPTIONS=gl;exports.LocaleContext=Dt;exports.LocaleProvider=op;exports.LocaleToggle=ho;exports.META_HOME_CSS=Hc;exports.META_HOME_SECTION_IDS=rd;exports.MetaCatalogTable=Xc;exports.MetaCollectionGroups=ed;exports.MetaDataLicense=od;exports.MetaHomeView=qx;exports.MetaLine=Xe;exports.MetaLineageCards=nd;exports.MetaOnlineSites=id;exports.MetaPeopleTimeline=td;exports.MetaRecentPanel=Kc;exports.MetaRelatedCatalogs=Jc;exports.MetaTypeChips=Vc;exports.ModeIndicator=pl;exports.MoreButton=vm;exports.MoreLink=Mo;exports.PAGE_MAX_WIDTH=Vn;exports.PERIOD_NARROW_SHARE=Nc;exports.PageFrame=kn;exports.Quote=Em;exports.READER_CSS=Gl;exports.READ_HOME_CSS=mr;exports.READ_HOME_NARROW_QUERY=An;exports.READ_HOME_SECTION_IDS=Oc;exports.READ_PERIOD_LABELS=Wx;exports.RECENT_IDS_STORAGE_KEY=en;exports.ROLE_CLASS_ORDER=ra;exports.ReadButton=to;exports.ReadFamousWorks=Mc;exports.ReadHomeView=Hx;exports.ReadPeriodBand=Bc;exports.ReadPicks=Rc;exports.ReadPieces=Wc;exports.ReadSection=nt;exports.ReadShelf=gr;exports.ReadSibu=fr;exports.ReadStats=Ic;exports.ReadTopicGroup=Ac;exports.ReadTopics=Pc;exports.ReaderMdText=Vo;exports.ReaderShell=Ql;exports.ReaderToc=Kl;exports.RelationPanel=qa;exports.RepoSourceLink=go;exports.ResourceEditor=Vi;exports.ResourceGroup=Im;exports.ResourceLine=Rm;exports.ResourceList=ko;exports.ResourceRow=va;exports.SEARCH_VIEW_STORAGE_KEY=wo;exports.SEVEN_PAVILIONS_KEY=Qc;exports.SNIPPET_MARK_END=nl;exports.SNIPPET_MARK_START=tl;exports.SORTABLE_TYPES=hl;exports.SearchInput=ml;exports.SearchResults=kl;exports.Sec=Je;exports.Section=ht;exports.SectionHead=ym;exports.SideList=Ot;exports.SmartBidInput=Gn;exports.SourceEditor=Ga;exports.StripWarpRenderer=ro;exports.SummaryCard=En;exports.THEMES=sd;exports.THEME_INIT_SCRIPT=sb;exports.THEME_STORAGE_KEY=bi;exports.TRADITIONAL_ALLOWLIST=al;exports.TabFilter=ui;exports.TableHead=_m;exports.TableRow=$m;exports.TagRow=ka;exports.TagRows=Lm;exports.TextButton=jm;exports.TextReader=or;exports.ThemeToggle=ab;exports.TopStrip=no;exports.VersionLineageGraph=mc;exports.VersionLineageList=uc;exports.VersionLineageView=cr;exports.VolumeChips=wm;exports.VolumeLinks=Oo;exports.WorkCard=kc;exports.WorkCardGrid=_c;exports.WorkCatalog=Cg;exports.WorkPage=dc;exports.WorkRow=wc;exports.adaptEntityJson=Aa;exports.adaptGujiPages=Sg;exports.adaptPunctJson=_g;exports.applyLayout=ob;exports.applyTheme=cd;exports.authorsLine=fi;exports.bookIndexUriToId=lo;exports.bucketResources=Ro;exports.buildCatalogTree=$x;exports.buildCollectionTable=la;exports.buildLineageGraph=Yn;exports.buildMeiliFilter=vp;exports.buildPageUrl=vo;exports.buildParagraphBlocks=za;exports.buildVersionRow=ia;exports.buildVersionTable=oa;exports.canParagraphize=Zn;exports.catalogNodeIdOf=Sx;exports.catalogNodeIdsOf=_x;exports.catalogPageCount=Nx;exports.catalogTotal=ur;exports.classificationPath=Ln;exports.clearAllRecentIds=So;exports.compareCatalogCards=Tx;exports.computeVersionPartition=sm;exports.countActiveFilters=li;exports.createTextApi=Hl;exports.currentLayout=rb;exports.currentTheme=dd;exports.defaultEntityHref=Ha;exports.defaultWorkLink=jc;exports.deriveDating=im;exports.deriveEditionType=ca;exports.deriveEra=Tn;exports.deriveYear=ci;exports.deriveYearRange=Io;exports.detailToEditor=ic;exports.detectGenre=hi;exports.displayAuthorRole=Ao;exports.editorToDetail=af;exports.eraRank=Qi;exports.filtersFromParams=kp;exports.filtersToParams=Kn;exports.findCatalogPath=Qt;exports.findTraditionalChars=lp;exports.firstAuthorText=hr;exports.flattenTitles=oo;exports.flattenToc=Jl;exports.fmtCount=Ve;exports.formatHitCount=Un;exports.formatTemplate=dt;exports.formatVolumeRange=pi;exports.getDisplayNameFromUrl=ln;exports.getMessages=rn;exports.getStartPage=jo;exports.getT=sn;exports.getTypeGroupKey=bo;exports.groupRelatedWorks=om;exports.gujiInlineToPlain=Pl;exports.hasActiveFilters=xl;exports.hasGujiMarkdownV02=Ki;exports.hasGujiTableNotation=Bl;exports.hasSearchOptions=bp;exports.iiifVolumeOf=$g;exports.isCountedChar=Qo;exports.isLayoutName=pd;exports.isThemeName=ld;exports.lineageHref=Dc;exports.loadRecentIds=Tt;exports.measureText=_t;exports.mergeVolumeResources=yo;exports.normalizeEra=qe;exports.normalizeLayout=vi;exports.normalizeRole=Lo;exports.normalizeTheme=yi;exports.normalizeVolumeIndex=_n;exports.normalizeVolumes=dl;exports.numberToChinese=aa;exports.paginationItems=bc;exports.parseChineseNumber=qn;exports.parseGujiInline=Al;exports.parseGujiTable=Ol;exports.parseSourceString=Ya;exports.pct=xr;exports.periodLevel=Tc;exports.pickReaderVersion=Zl;exports.readStoredLayout=nb;exports.readStoredTheme=eb;exports.readerVersionOptionLabel=Zi;exports.remapPlainOffsets=Pa;exports.removeRecentId=wl;exports.renderFullTextBody=Fm;exports.renderProperNames=Na;exports.renderReaderInline=Uo;exports.resolveRecentEntry=_o;exports.resourceHref=an;exports.resourceNote=di;exports.resultTabFromParam=Ip;exports.resultTabToParam=Rp;exports.roleFacets=sa;exports.rowNo=Cm;exports.sameFilters=wp;exports.saveRecentId=Gi;exports.segmentEntities=Ma;exports.shelfColumns=Cc;exports.sortFor=yp;exports.sortYear=Xn;exports.spineHeight=zc;exports.splitFullTextTables=zo;exports.splitHighlightSnippet=fo;exports.splitTableRow=Wl;exports.storeLayout=ib;exports.storeTheme=ad;exports.stringifySources=Ka;exports.summaryFromEntry=Wa;exports.summaryFromItem=Ba;exports.timelineLayout=Uc;exports.toCatalogWorkCard=zx;exports.transportSummaryLoader=Oa;exports.typeSupportsFilters=bl;exports.useBidUrl=Ke;exports.useChapterWarpData=Fa;exports.useConvert=Re;exports.useEntitySummaryLoader=tr;exports.useI18n=Z;exports.useReaderPrefs=Xl;exports.useRecentEntries=Gc;exports.useT=$e;exports.validateLineageGraph=Gf;exports.volumeStats=ni;exports.withDefaultLinks=Nt;exports.withMetaLinks=Et;exports.yearText=ei;
|
|
1859
|
+
`,rd={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function At(e){return{...rd,...e??{}}}function sd(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 Cr(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function ad(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,h=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(u,h),Math.max(u,h)]},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 ai(e,n=cn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function gb(e){return{read:e.item,work:e.item,node:e.node}}function ld({counts:e,links:n}){const{t:o}=J(),r=n==null?void 0:n.type;if(!r)return null;const s=[["all",o("metaHome.typeAll"),null],["work",o("metaHome.typeLabel.work"),e.works],["book",o("metaHome.typeLabel.book"),e.books],["collection",o("metaHome.typeLabel.collection"),e.collections],["entity",o("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":o("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:r(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:Ve(d)})]})},a))})}function cd(e,n=5){const[o,r]=g.useState(null);g.useEffect(()=>{let a=!1;const l=Rt().slice(0,n);if(!l.length||!e){r([]);return}return Promise.all(l.map(d=>Lo(e,d))).then(d=>{a||r(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=g.useCallback(()=>{Ro(),r([])},[]);return{entries:o,clear:s}}function fb(e,n,o){const r=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return r?o(r):dd(e.type,n)}function dd(e,n){return n(`metaHome.typeLabel.${e}`)}function pd({entries:e,onClear:n,links:o}){const{t:r,convert:s}=J(),a=At(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?dd(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:fb(l,r,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:r("metaHome.recentEmpty")})]})}function ud(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 md({rows:e,links:n}){const{t:o,convert:r}=J(),s=At(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=Cr(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:Ve(a.total)}),t.jsx("td",{className:"bim-mh-r",children:Ve(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:ud(a.status,o,r)})})]},a.id||a.name)})})]})}):null}function hd({items:e,links:n,label:o}){const{convert:r}=J();return t.jsx("ul",{className:"bim-rh-rows","aria-label":o?r(o):void 0,children:e.map(s=>t.jsx("li",{children:t.jsxs("a",{href:n.item(s.id),children:[t.jsx("span",{className:"bim-rh-t",children:r(s.title)}),s.sub&&t.jsx("small",{children:r(s.sub)})]})},s.id))})}function gd({works:e,links:n}){const{t:o}=J(),[r,s]=g.useState(!1);if(!e.length)return null;const a=En(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(hd,{items:e.map(l=>({id:l.id,title:l.title,sub:wi(l)||void 0})),links:At(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 fd="siku_qige";function xb({group:e,links:n}){const{t:o,convert:r}=J(),[s,a]=g.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":En(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(hd,{items:e.items,links:n,label:e.label}),En(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 xd({groups:e,links:n}){const{t:o,convert:r}=J(),s=At(n);if(!e.length)return null;const a=e.find(c=>c.key===fd),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(xb,{group:c,links:s},c.key))})]})}const pa=34,ua=13;function ma(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?ai(e.birth_year,n):"?"}–${e.death_year!=null?ai(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 bd({people:e,links:n}){const{t:o,convert:r}=J(),s=At(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=ad(e),p=[],u=d.map(m=>{const f=m.left>70,x=f?Math.min(m.left,m.left+m.width-ua):m.left;let k=0;for(;p[k]!=null&&p[k]>x;)k++;return p[k]=f?m.left+m.width:m.left+Math.max(m.width,ua),{...m,lane:k,end:f}}),h=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*pa+10},children:u.map(m=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":m.end?"":void 0,style:{left:`${m.left}%`,top:m.lane*pa+4,width:`${Math.max(m.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(m.p.id),children:[r(m.p.name),t.jsx("small",{className:"bim-rh-num",children:ma(m.p,o)})]})]},m.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:bb(a,l).map(m=>t.jsx("span",{style:{left:`${(m-a)/h*100}%`},children:ai(m,o)},m))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":u.length?void 0:"",children:(u.length?e:c).map(m=>t.jsx("li",{children:t.jsxs("a",{href:s.item(m.id),children:[t.jsx("span",{children:r(m.name)}),t.jsx("small",{className:"bim-rh-num",children:[m.dynasty?r(m.dynasty):"",ma(m,o)].filter(Boolean).join(" ")})]})},m.id))}),c.length>0&&u.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:o("metaHome.missingLife",{names:r(c.map(m=>m.name).join("、"))})})]})}const yb=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 yd({works:e,links:n}){const{t:o,convert:r}=J(),s=At(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=wi(a);return t.jsx("li",{children:t.jsxs("a",{href:sd(s,a.id),children:[yb,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 jd({sites:e}){const{t:n,convert:o}=J(),r=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!r.includes(a));return e.length?t.jsxs(t.Fragment,{children:[r.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:r.map(a=>{const l=Cr(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:[`${Ve(a.imported)} / ${Ve(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:ud(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 ha=["extant","partially_extant","lost","unknown"];function vd({stats:e,links:n,version:o,repoUrl:r,downloadHref:s}){const{t:a}=J(),l=["works","books","collections","entities","has_image","has_text","article","poem"].map(p=>[e[p],a(`metaHome.stat.${p}`)]).filter(([p])=>p>0),d=n==null?void 0:n.loss,c=ha.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:Ve(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:ha.map(p=>{var m;const u=((m=e.loss)==null?void 0:m[p])??0,h=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:Ve(u),note:h}):h})]})},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 kd={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function jb({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:h}=J(),m=e,f=At(n),x=gb(f),k=kd,y=cd(r),_={zhi:!!((v=m.shelf)!=null&&v.items.length)||m.catalog_progress.length>0||m.related_catalogs.length>0,sibu:m.bu.length>0||m.unclassified>0,cong:m.collection_groups.length>0,people:m.bibliographers.length>0,lineage:m.lineage.length>0,sites:m.sites.length>0,data:!0},b=Object.keys(k).filter(S=>_[S]),j=S=>h(`metaHome.nav.${S}`),w=(S,C)=>S?t.jsx("a",{className:"bim-rh-more",href:S,children:C}):void 0;return t.jsxs("div",{className:u?`bim-rh bim-mh ${u}`:"bim-rh bim-mh",children:[t.jsx("style",{children:wr+od}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[o,t.jsx(ld,{counts:m.counts,links:n})]}),r&&t.jsx(pd,{entries:y.entries,onClear:y.clear,links:n})]}),b.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":h("metaHome.navLabel"),children:t.jsx("ul",{children:b.map(S=>t.jsx("li",{children:t.jsx("a",{href:`#${k[S]}`,children:j(S)})},S))})}),t.jsxs("div",{className:"bim-rh-main",children:[_.zhi&&t.jsxs(it,{id:k.zhi,title:j("zhi"),sub:h("metaHome.zhiSub"),children:[m.shelf&&m.shelf.items.length>0&&t.jsx(_r,{topic:{key:"shelf",label:m.shelf.label,shelf:!0,items:m.shelf.items},links:x,showTitle:!1,legendCount:m.shelf.items.some(S=>S.records)?h("metaHome.shelfLegendCount"):null,legendExtra:[h("metaHome.shelfLegendClick")]}),(m.catalog_progress.length>0||m.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:($=m.shelf)!=null&&$.items.length?void 0:{marginTop:0},children:[t.jsx(md,{rows:m.catalog_progress,links:n}),t.jsx(gd,{works:m.related_catalogs,links:n})]})]}),_.sibu&&t.jsx(it,{id:k.sibu,title:j("sibu"),sub:h("metaHome.sibuSub"),more:w(s,h("metaHome.toCatalog")),children:t.jsx($r,{bu:m.bu,unclassified:m.unclassified,links:x,unclassifiedNote:h("metaHome.unclassifiedNote")})}),_.cong&&t.jsx(it,{id:k.cong,title:j("cong"),sub:h("metaHome.congSub"),more:w(a,h("metaHome.allNKindsMore",{n:Ve(m.counts.collections)})),children:t.jsx(xd,{groups:m.collection_groups,links:n})}),_.people&&t.jsx(it,{id:k.people,title:j("people"),sub:h("metaHome.peopleSub"),more:w(l,h("metaHome.allNPeopleMore",{n:Ve(m.counts.entities)})),children:t.jsx(bd,{people:m.bibliographers,links:n})}),_.lineage&&t.jsx(it,{id:k.lineage,title:j("lineage"),sub:h("metaHome.lineageSub"),children:t.jsx(yd,{works:m.lineage,links:n})}),_.sites&&t.jsx(it,{id:k.sites,title:j("sites"),sub:h("metaHome.sitesSub"),children:t.jsx(jd,{sites:m.sites})}),t.jsx(it,{id:k.data,title:j("data"),sub:h("metaHome.dataSub"),children:t.jsx(vd,{stats:m.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const wo=({style:e})=>{const n=g.useContext(Gt),{t:o}=J();if(!n)return null;const{locale:r,setLocale:s}=n,a=r==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:o(a?"common.toHans":"common.toHant"),style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${i("border")}`,borderRadius:"4px",background:i("bg"),color:i("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?i("primary"):void 0,fontWeight:a?700:400},children:o("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:i("primary"),fontWeight:a?400:700},children:o("common.localeShortHans")})]})},So=({href:e,label:n,size:o=16,className:r,style:s})=>{const{t:a}=J(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:o+8,height:o+8,borderRadius:4,color:i("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=i("fg")},onMouseLeave:d=>{d.currentTarget.style.color=i("desc-fg")},children:t.jsx("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})})};function Ji(e){const n=e.text_count;return typeof n=="number"&&n>0}function Qi(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function vb(e,n){if(!n)return!1;const o=n.id;return o===void 0||o===e}const kb=({id:e,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:u,onLineageCollectionChange:h,initialPage:m=1,selectedLineageNodeId:f,onNavigate:x,onBack:k,backLabel:y,renderLink:_,enrichDetail:b,getSourceLink:j,readLink:w,railTop:v,extraTabs:$=[],showFeedbackTab:S=!0,feedbackApiUrl:C,height:B,footerExtra:T,hideHeaderControls:z=!1,className:F,style:N})=>{const R=$e(),{t:O,convert:I}=J(),[P]=g.useState(()=>{if(!vb(e,o))return null;const V={...o},pe=r??Qi(e,V);return b&&b(pe,V),{id:e,entry:pe,detail:V}}),[G,K]=g.useState((P==null?void 0:P.entry)??null),[L,Z]=g.useState((P==null?void 0:P.detail)??null),[A,U]=g.useState(!P),[ce,ee]=g.useState(!1),[ue,de]=g.useState([]),[be,Oe]=g.useState(!1),[ie,Re]=g.useState(null),[Le,q]=g.useState(null),[Q,fe]=g.useState(null),[ze,Y]=g.useState(!1),ve=g.useRef(null),le=g.useRef(0),[Se,X]=g.useState(null),Ce=l!==void 0?l:Se,Me=g.useCallback(V=>{d?d(V):X(V)},[d]),M=g.useCallback(async V=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){de([]);return}Oe(!0);try{if(n.getCollectionCatalogs)de(await n.getCollectionCatalogs(V)||[]);else if(n.getCollectionCatalog){const pe=await n.getCollectionCatalog(V);de(pe?[{resource_id:"",data:pe}]:[])}}catch{de([])}finally{Oe(!1)}},[n]),te=g.useCallback(async V=>{var pe,Te;if(!n.getTextManifest||!n.getTextIndex){Re(null),q(V);return}try{const Ee=we.pickTextVersion(await n.getTextManifest(V)),D=Ee?await n.getTextIndex(V,Ee.key):null;Re(D&&D.chapters.length>0?{chapters:D.chapters.map(re=>({n:re.n,title:re.title,file:re.file})),source:{name:((pe=D.source)==null?void 0:pe.name)??(Ee==null?void 0:Ee.source_name),license:((Te=D.source)==null?void 0:Te.license)??(Ee==null?void 0:Ee.license)??void 0}}:null)}catch{Re(null)}finally{q(V)}},[n]),ye=g.useCallback(async(V,pe)=>{const Te=++le.current,Ee=()=>Te!==le.current;Y(!0);try{if(n.getLineageGraph){const He=await n.getLineageGraph(V);if(Ee())return;He&&fe(He)}const D=pe.version_graph;if(!D||!D.enabled){Q||fe(null),ve.current=null;return}const re=pe.books??[],Pe=[];for(const He of re)try{const Fe=await n.getItem(He);Fe&&Pe.push(Fe)}catch{}if(Ee())return;ve.current={work:pe,books:Pe};const _e=u??D.default_collection??(D.core_books&&D.core_books.length>0?"core":"all"),Ge=_e==="core"&&Array.isArray(D.core_books)&&D.core_books.length>0?"core":_e??"all";fe(ei(pe,Pe,Ge))}catch{if(Ee())return;fe(null),ve.current=null}finally{Ee()||Y(!1)}},[n]),H=g.useRef({initialDetail:o,initialEntry:r});H.current={initialDetail:o,initialEntry:r},g.useEffect(()=>{let V=!1;le.current++,Y(!1);const pe=re=>{re.type==="collection"?M(e):re.type==="work"?(re.version_graph||n.getLineageGraph)&&ye(e,re):re.type==="book"&&Ji(re)&&te(e)},Te=H.current;let Ee=null;if(P&&P.id===e)Ee=P;else if(Te.initialDetail&&Te.initialDetail.id===e){const re={...Te.initialDetail},Pe=Te.initialEntry??Qi(e,re);b&&b(Pe,re),Ee={entry:Pe,detail:re}}return Ee?(ee(!1),de(re=>re.length?[]:re),Re(null),fe(null),ve.current=null,K(Ee.entry),Z(Ee.detail),U(!1),pe(Ee.detail),()=>{V=!0}):((async()=>{U(!0),ee(!1),K(null),Z(null),de([]),Re(null),fe(null),ve.current=null;try{const re=await n.getItem(e);if(V)return;if(!re){ee(!0);return}const Pe=re;let _e=null;if(n.getEntry&&(_e=await n.getEntry(e),V))return;_e||(_e=Qi(e,Pe)),b&&b(_e,Pe),K(_e),Z(Pe),pe(Pe)}catch{V||ee(!0)}finally{V||U(!1)}})(),()=>{V=!0})},[e,n,P,b,M,ye,te]),g.useEffect(()=>{const V=ve.current;!V||!u||fe(ei(V.work,V.books,u))},[u]);const se=[];if(L){if(se.push({key:"basic",label:R.detailTab.basicInfo}),L.type==="collection"){be&&ue.length===0&&se.push({key:"catalog:loading",label:`${R.detailTab.catalog}…`});for(const V of ue)se.push({key:`catalog:${V.resource_id}`,label:V.short_name?`${I(V.short_name)}${R.detailTab.catalogSuffix}`:R.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&se.push({key:s,label:R.detailTab.fullText}),L.type==="work"&&(Q||ze)&&se.push({key:"lineage",label:ze?`${R.detailTab.lineage}…`:R.detailTab.lineage});for(const V of $)(V.position??"before-feedback")==="before-feedback"&&V.shouldShow(L)&&se.push({key:V.key,label:V.label});S&&s==="feedback"&&se.push({key:"feedback",label:R.detailTab.feedback});for(const V of $)V.position==="after-feedback"&&V.shouldShow(L)&&se.push({key:V.key,label:V.label})}g.useEffect(()=>{if(s!=="emendated"||!L)return;a("basic");const V=setTimeout(()=>{var pe;(pe=document.getElementById("studies"))==null||pe.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(V)},[s,L,a]);const ne=G&&L&&j?j({activeTab:s,activeJuan:Ce,entry:G,detail:L}):null,ge=g.useMemo(()=>{var D;if(!L)return null;const pe=(L.authors??[]).map(re=>{const Pe=Uo(re.role);return`${re.dynasty?`〔${I(re.dynasty)}〕`:""}${I(re.name)}${Pe?` ${I(Pe)}`:""}`}).join(" · ");let Te=!1;try{Te=we.extractStatus(L.id)==="draft"}catch{}if(L.type==="book"){const re=L;return{title:I(re.title),subtitle:re.edition?I(re.edition):pe||void 0,aside:[Te?R.status.draft:"",pe&&re.edition?pe:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(L.type==="collection"){const re=L;return{title:I(re.title),subtitle:I($t(re,R.unit.juan))||void 0,aside:[(D=re.publication_info)==null?void 0:D.year,Te?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:pe||void 0}}if(L.type==="entity"){const re=L,Pe=Ge=>Ge==null?"":Ge<0?O("detail.bce",{n:-Ge}):String(Ge),_e=re.birth_year!=null||re.death_year!=null?`${Pe(re.birth_year)||"?"}—${Pe(re.death_year)||"?"}`:"";return{title:I(re.primary_name||re.title),subtitle:[re.dynasty?`〔${I(re.dynasty)}〕`:"",_e].filter(Boolean).join(" ")||void 0,aside:Te?R.status.draft:void 0,secondLine:void 0}}const Ee=I($t(L,R.unit.juan));return{title:I(L.title),subtitle:[Ee,pe].filter(Boolean).join(" · ")||void 0,aside:[Sb(R,L.subtype),Te?R.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[L,I,R,O]),Ne=L&&Ji(L)?"text":null,Be=()=>{Me(null),a("fulltext")};let We=null;if(L&&w){const V=w({detail:L,kind:Ne});V&&(We=t.jsx(po,{href:V}))}else Ne&&(We=t.jsx(po,{onClick:Be}));const Ue=V=>{if(!L)return null;const pe=V.replace(/\.[^.]+$/,"");if(w){const Te=w({detail:L,kind:Ne,juan:pe});return Te?{href:Te}:null}return{onClick:()=>{Me(pe),a("fulltext")}}},Je=new Set($.map(V=>V.key)),me=se.filter(V=>V.key.startsWith("catalog:")&&V.key!=="catalog:loading"||V.key==="lineage"&&!!Q&&!ze||Je.has(V.key)).map(V=>({key:V.key,label:V.label,onClick:()=>a(V.key)})),et=()=>{var V;return L?L.type==="work"?t.jsx(Cc,{data:L,transport:n,onNavigate:x,renderLink:_,readAction:We,railTop:v,railLinks:me}):L.type==="book"?t.jsx(Ec,{data:L,transport:n,onNavigate:x,renderLink:_,readAction:We,fullText:ie,fullTextPending:Ji(L)&&!!n.getTextManifest&&Le!==L.id,chapterLink:Ue,railTop:v,railLinks:me}):L.type==="collection"?t.jsx(Ic,{data:L,catalog:(V=ue[0])==null?void 0:V.data,transport:n,onNavigate:x,renderLink:_,readAction:We,railTop:v,railLinks:me,catalogAction:ue.length>0?t.jsxs("a",{href:"#catalog",onClick:pe=>{pe.preventDefault(),a(`catalog:${ue[0].resource_id}`)},children:[I(R.detailTab.collectionCatalog)," →"]}):null}):t.jsx(Rc,{data:L,transport:n,onNavigate:x,renderLink:_,railTop:v,railLinks:me}):null},E=()=>{var pe,Te,Ee;if(!G||!L)return null;if(s==="basic"||s==="emendated")return et();if(typeof s=="string"&&s.startsWith("catalog:")){const D=(pe=ue.find(re=>`catalog:${re.resource_id}`===s))==null?void 0:pe.data;return t.jsx(Po,{data:D,onNavigate:x,renderLink:_})}if(s==="collated"||s==="fulltext")return t.jsx(hr,{id:e,transport:n,chapter:Ce,onLocationChange:D=>Me(D.chapter),onNavigate:x});if(s==="lineage"){if(!Q)return t.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:O(ze?"detail.loading":"detail.noLineageGraph")});const D=L.type==="work"?L:null;return t.jsx(yr,{graph:Q,renderLink:_,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:f,collection:u??((Te=D==null?void 0:D.version_graph)==null?void 0:Te.default_collection),onCollectionChange:h,collectionsAvailable:(Ee=D==null?void 0:D.version_graph)==null?void 0:Ee.collections,collectionCounts:(()=>{var Ge,He,Fe,Ct,Wn,yt,zt;if(!D)return;const re={},Pe=((Ge=ve.current)==null?void 0:Ge.books)??[];re.all=(((He=D.books)==null?void 0:He.length)??0)-(((Ct=(Fe=D.version_graph)==null?void 0:Fe.excluded_books)==null?void 0:Ct.length)??0);const _e=(Wn=D.version_graph)==null?void 0:Wn.collections;if(_e)for(const Pt of Object.keys(_e))re[Pt]=ei(D,Pe,Pt).nodes.filter(mn=>mn.kind==="book"&&!mn.bridge).length;return re.core==null&&((zt=(yt=D.version_graph)==null?void 0:yt.core_books)!=null&&zt.length)&&(re.core=D.version_graph.core_books.length),re})()})}if(s==="feedback"&&S)return t.jsx(wc,{resourceId:e,apiUrl:C});const V=$.find(D=>D.key===s);return V?V.render({detail:L,entry:G,transport:n,onNavigate:x}):null};if(A)return t.jsx(_n,{style:{minHeight:B,...N},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((V,pe)=>t.jsx("div",{style:{height:pe===1?40:16,width:V,opacity:.35,background:i("rule")}},pe))})});if(ce||!L||!G||!ge)return t.jsx(_n,{style:{minHeight:B,...N},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:O("detail.notFound")})});const oe=s==="basic"||s==="emendated",ae=[{label:y??R.detailTab.backToIndex,onClick:k}];if(L.type==="book"&&L.work_id){const V=L.work_id;ae.push({label:R.indexType.work,id:V,onClick:()=>x==null?void 0:x(V)})}ae.push({label:R.indexType[L.type]});const je=s==="collated"||s==="fulltext",ke=typeof T=="string"?R.status[T.trim()]??T:T,xe=t.jsx(Bl,{left:t.jsxs(t.Fragment,{children:[ke,ke?" · ":"",t.jsx(wb,{id:L.id,label:R.label.id,copied:R.action.copied,copyLabel:R.action.copy})]}),right:t.jsxs(t.Fragment,{children:[S&&!oe&&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:R.detailTab.submitVersion}),ne&&t.jsx("a",{href:ne.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:R.detailTab.dataLicense})]})});return oe?t.jsx("div",{className:F,children:t.jsxs(_n,{grid:!0,style:{minHeight:B,...N},children:[t.jsx(uo,{breadcrumb:t.jsx(mo,{items:ae}),actions:t.jsxs(t.Fragment,{children:[!z&&t.jsx(wo,{style:{border:"none",background:"transparent"}}),!z&&ne&&t.jsx(So,{...ne})]})}),et(),xe]})}):t.jsx("div",{className:F,children:t.jsxs(_n,{wide:je,style:{minHeight:B,...N},children:[t.jsx(uo,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(Ko,{char:"籍"}),t.jsx(mo,{items:ae})]}),actions:t.jsxs(t.Fragment,{children:[!z&&t.jsx(wo,{}),S&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:R.detailTab.feedback}),!z&&ne&&t.jsx(So,{...ne})]})}),t.jsx(Tl,{...ge,aside:je?t.jsxs("button",{type:"button",onClick:()=>a("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[O("detail.workInfo")," →"]}):ge.aside}),!je&&se.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:se.map(V=>t.jsx(Nl,{label:V.label,active:V.key===s||oe&&V.key==="basic",onClick:()=>a(V.key)},V.key))}),t.jsx("div",{style:{marginTop:!je&&se.length>1?8:0},children:E()}),xe]})})};function wb({id:e,label:n,copied:o,copyLabel:r}){const[s,a]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var l;(l=navigator.clipboard)==null||l.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},title:s?o:r,"aria-label":s?o:r,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:i("aux-fg")},children:s?"✓":"⧉"})]})}function Sb(e,n){return n?e.workSubtype[n]??n:""}const wd=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],Si="zhusha",_i="bim-theme";function Sd(e){return e==="zhusha"||e==="indigo"||e==="ink"}function $i(e){return Sd(e)?e:Si}function _b(){try{return $i(window.localStorage.getItem(_i))}catch{return Si}}function _d(e){try{window.localStorage.setItem(_i,e)}catch{}}function $d(e){const n=$i(e);return document.documentElement.setAttribute("data-theme",n),n}function Cd(){return $i(document.documentElement.getAttribute("data-theme"))}const $b=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],zr="airy",Ci="bim-layout";function zd(e){return e==="airy"||e==="boxed"}function zi(e){return zd(e)?e:zr}function Cb(){try{return zi(window.localStorage.getItem(Ci))}catch{return zr}}function zb(e){try{window.localStorage.setItem(Ci,e)}catch{}}function Tb(e){const n=zi(e);return document.documentElement.setAttribute("data-layout",n),n}function Nb(){return zi(document.documentElement.getAttribute("data-layout"))}const Eb=`try{var t=localStorage.getItem(${JSON.stringify(_i)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(Ci)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,Ib={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},Rb=({onChange:e,style:n})=>{const{t:o}=J(),[r,s]=g.useState(Si);g.useEffect(()=>{s(Cd())},[]);const a=l=>{s($d(l)),_d(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(Ib[l.name]),boxShadow:d?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=we.BidLink;exports.BookIndexError=we.BookIndexError;exports.BookIndexManager=we.BookIndexManager;exports.BookIndexStorage=we.BookIndexStorage;exports.BundleStorage=we.BundleStorage;exports.ConfigError=we.ConfigError;exports.GithubStorage=we.GithubStorage;exports.IdGenerationError=we.IdGenerationError;exports.IdGenerator=we.IdGenerator;exports.LocalStorage=we.LocalStorage;exports.MigrationError=we.MigrationError;exports.StorageError=we.StorageError;exports.VARIANT_CHARS=we.VARIANT_CHARS;exports.base36Decode=we.base36Decode;exports.base36Encode=we.base36Encode;exports.base58Decode=we.base58Decode;exports.buildId=we.buildId;exports.buildPromotionMap=we.buildPromotionMap;exports.cleanName=we.cleanName;exports.decodeId=we.decodeId;exports.decodeIdString=we.decodeIdString;exports.encodeId=we.encodeId;exports.extractIdFromUrl=we.extractIdFromUrl;exports.extractStatus=we.extractStatus;exports.extractType=we.extractType;exports.isChapterSegment=we.isChapterSegment;exports.isTextKey=we.isTextKey;exports.matchChapterAcrossVersions=we.matchChapterAcrossVersions;exports.normalizeCatalog=we.normalizeCatalog;exports.normalizeVariants=we.normalizeVariants;exports.parseId=we.parseId;exports.pickTextVersion=we.pickTextVersion;exports.shardOf=we.shardOf;exports.smartDecode=we.smartDecode;exports.textVersionLabel=we.textVersionLabel;exports.validateResource=we.validateResource;exports.Badge=si;exports.BidUrlProvider=Xd;exports.BookDetailLayout=kb;exports.BookPage=Ec;exports.Breadcrumb=mo;exports.CATALOG_ALL_ID=wt;exports.CATALOG_CSS=Lc;exports.CATALOG_NARROW_QUERY=jr;exports.CATALOG_PAGE_SIZE=vr;exports.CATALOG_UNCLASSIFIED_ID=Ft;exports.CLASSIFICATIONS=mi;exports.COMMON_TRADITIONAL_CHARS=ka;exports.CardFoot=An;exports.CatalogPage=sb;exports.CatalogPager=Hc;exports.CatalogTree=Pc;exports.CheckFilter=$l;exports.Chip=El;exports.ChipWall=Hm;exports.CollectionCatalog=Po;exports.CollectionPage=Ic;exports.CreateEntityDialog=gc;exports.DEFAULT_LAYOUT=zr;exports.DEFAULT_META_HOME_LINKS=rd;exports.DEFAULT_READER_PREFS=Wo;exports.DEFAULT_READ_HOME_LINKS=Dc;exports.DEFAULT_THEME=Si;exports.DETAIL_CSS=zl;exports.DYNASTY_GROUPS=ui;exports.Dash=Ym;exports.DataTable=Dm;exports.DetailFooter=Bl;exports.DetailGrid=Rn;exports.DetailHeader=Tl;exports.EMPTY_FILTERS=pi;exports.ENTITY_TEXT_CSS=cr;exports.EmendatedBySection=Ga;exports.EmptyNote=eh;exports.EntityDetail=Oa;exports.EntityMark=pr;exports.EntityPage=Rc;exports.EntityPickerDialog=xc;exports.EntitySelector=hc;exports.EntityText=lg;exports.ExpandRow=Km;exports.ExtLink=th;exports.FEEDBACK_FAB_OFFSET_VAR=jo;exports.FILTER_SUPPORT=Ea;exports.FONT_SIZE_STEPS=kt;exports.FactList=Mm;exports.FeedbackButton=Kf;exports.FeedbackDialog=vc;exports.FeedbackForm=kc;exports.FeedbackList=gr;exports.FeedbackTab=wc;exports.FilterChip=Nl;exports.FormInput=ct;exports.FormTextArea=Ut;exports.GUJI_MARKDOWN_FIELD=Fu;exports.GUJI_TABLE_NOTATION=Ja;exports.GlyphBadge=Ko;exports.GujiInteractiveReader=Vg;exports.GujiTable=Xo;exports.GujiTextViewer=ur;exports.GujiWarpCanvas=ar;exports.HomePage=bo;exports.ImagePanel=oo;exports.IndexApp=Ug;exports.IndexBrowser=no;exports.IndexDetail=Ao;exports.IndexEditor=bc;exports.IndexView=Lf;exports.IntroGrid=Pm;exports.LAYOUTS=$b;exports.LAYOUT_STORAGE_KEY=Ci;exports.LOSS_OPTIONS=Na;exports.LocaleContext=Gt;exports.LocaleProvider=wp;exports.LocaleToggle=wo;exports.META_HOME_CSS=od;exports.META_HOME_SECTION_IDS=kd;exports.MetaCatalogTable=md;exports.MetaCollectionGroups=xd;exports.MetaDataLicense=vd;exports.MetaHomeView=jb;exports.MetaLine=Ze;exports.MetaLineageCards=yd;exports.MetaOnlineSites=jd;exports.MetaPeopleTimeline=bd;exports.MetaRecentPanel=pd;exports.MetaRelatedCatalogs=gd;exports.MetaTypeChips=ld;exports.ModeIndicator=$a;exports.MoreButton=Om;exports.MoreLink=Go;exports.PAGE_MAX_WIDTH=Zn;exports.PERIOD_NARROW_SHARE=Yc;exports.PageFrame=_n;exports.Quote=Xm;exports.READER_CSS=al;exports.READ_HOME_CSS=wr;exports.READ_HOME_NARROW_QUERY=Bn;exports.READ_HOME_SECTION_IDS=id;exports.READ_PERIOD_LABELS=db;exports.RECENT_IDS_STORAGE_KEY=on;exports.ROLE_CLASS_ORDER=jl;exports.ReadButton=po;exports.ReadFamousWorks=ed;exports.ReadHomeView=ub;exports.ReadPeriodBand=td;exports.ReadPicks=Xc;exports.ReadPieces=nd;exports.ReadSection=it;exports.ReadShelf=_r;exports.ReadSibu=$r;exports.ReadStats=qc;exports.ReadTopicGroup=Jc;exports.ReadTopics=Qc;exports.ReaderMdText=er;exports.ReaderShell=hl;exports.ReaderToc=cl;exports.RelationPanel=uc;exports.RepoSourceLink=So;exports.ResourceEditor=eo;exports.ResourceGroup=Zm;exports.ResourceLine=Jm;exports.ResourceList=Eo;exports.ResourceRow=Pl;exports.SEARCH_VIEW_STORAGE_KEY=Io;exports.SEVEN_PAVILIONS_KEY=fd;exports.SNIPPET_MARK_END=xa;exports.SNIPPET_MARK_START=fa;exports.SORTABLE_TYPES=Ta;exports.SearchInput=za;exports.SearchResults=Ma;exports.Sec=Qe;exports.Section=ht;exports.SectionHead=Bm;exports.SideList=Dt;exports.SmartBidInput=Qn;exports.SourceEditor=cc;exports.StripWarpRenderer=go;exports.SummaryCard=Ln;exports.THEMES=wd;exports.THEME_INIT_SCRIPT=Eb;exports.THEME_STORAGE_KEY=_i;exports.TRADITIONAL_ALLOWLIST=wa;exports.TabFilter=yi;exports.TableHead=Um;exports.TableRow=Vm;exports.TagRow=Ml;exports.TagRows=Qm;exports.TextButton=Wm;exports.TextReader=hr;exports.ThemeToggle=Rb;exports.TopStrip=uo;exports.VersionLineageGraph=Nc;exports.VersionLineageList=Tc;exports.VersionLineageView=yr;exports.VolumeChips=Fm;exports.VolumeLinks=qo;exports.WorkCard=Wc;exports.WorkCardGrid=Fc;exports.WorkCatalog=Jg;exports.WorkPage=Cc;exports.WorkRow=Oc;exports.adaptCharCord=Zg;exports.adaptEntityJson=Xl;exports.adaptGujiPages=Yg;exports.adaptPunctJson=Kg;exports.applyLayout=Tb;exports.applyTheme=$d;exports.authorsLine=wi;exports.bookIndexUriToId=xo;exports.bucketResources=Fo;exports.buildCatalogTree=Zx;exports.buildCollectionTable=kl;exports.buildLineageGraph=ei;exports.buildMeiliFilter=Op;exports.buildPageUrl=No;exports.buildParagraphBlocks=Dl;exports.buildVersionRow=bl;exports.buildVersionTable=yl;exports.canParagraphize=oi;exports.catalogNodeIdOf=qx;exports.catalogNodeIdsOf=Xx;exports.catalogPageCount=tb;exports.catalogTotal=kr;exports.classificationPath=Mn;exports.clearAllRecentIds=Ro;exports.compareCatalogCards=eb;exports.computeVersionPartition=_m;exports.countActiveFilters=hi;exports.createTextApi=nl;exports.currentLayout=Nb;exports.currentTheme=Cd;exports.defaultEntityHref=nc;exports.defaultWorkLink=Mc;exports.deriveDating=km;exports.deriveEditionType=Sl;exports.deriveEra=In;exports.deriveYear=fi;exports.deriveYearRange=Ho;exports.detailToEditor=jc;exports.detectGenre=vi;exports.displayAuthorRole=Uo;exports.editorToDetail=Rf;exports.eraRank=lo;exports.filtersFromParams=Hp;exports.filtersToParams=ti;exports.findCatalogPath=nn;exports.findTraditionalChars=$p;exports.firstAuthorText=Sr;exports.flattenTitles=ho;exports.flattenToc=ml;exports.fmtCount=Ve;exports.formatHitCount=Xn;exports.formatTemplate=dt;exports.formatVolumeRange=bi;exports.getDisplayNameFromUrl=dn;exports.getMessages=ln;exports.getStartPage=To;exports.getT=cn;exports.getTypeGroupKey=Co;exports.groupRelatedWorks=wm;exports.gujiInlineToPlain=Za;exports.hasActiveFilters=Ia;exports.hasGujiMarkdownV02=io;exports.hasGujiTableNotation=Qa;exports.hasSearchOptions=Mp;exports.iiifVolumeOf=qg;exports.isCountedChar=lr;exports.isLayoutName=zd;exports.isThemeName=Sd;exports.lineageHref=sd;exports.loadRecentIds=Rt;exports.measureText=$t;exports.mergeVolumeResources=zo;exports.normalizeEra=Xe;exports.normalizeLayout=zi;exports.normalizeRole=Do;exports.normalizeTheme=$i;exports.normalizeVolumeIndex=zn;exports.normalizeVolumes=_a;exports.numberToChinese=wl;exports.paginationItems=Ac;exports.parseChineseNumber=ni;exports.parseGujiInline=Xa;exports.parseGujiTable=tl;exports.parseSourceString=dc;exports.pct=Cr;exports.periodLevel=Gc;exports.pickReaderVersion=ul;exports.readStoredLayout=Cb;exports.readStoredTheme=_b;exports.readerVersionOptionLabel=so;exports.remapPlainOffsets=Zl;exports.removeRecentId=Ba;exports.renderFullTextBody=ah;exports.renderProperNames=Vl;exports.renderReaderInline=Qo;exports.resolveRecentEntry=Lo;exports.resourceHref=pn;exports.resourceNote=xi;exports.resultTabFromParam=Zp;exports.resultTabToParam=Jp;exports.roleFacets=vl;exports.rowNo=Gm;exports.sameFilters=Fp;exports.saveRecentId=to;exports.segmentEntities=Jl;exports.shelfColumns=Uc;exports.sortFor=Bp;exports.sortYear=ii;exports.spineHeight=Vc;exports.splitFullTextTables=Mo;exports.splitHighlightSnippet=_o;exports.splitTableRow=el;exports.storeLayout=zb;exports.storeTheme=_d;exports.stringifySources=pc;exports.summaryFromEntry=ec;exports.summaryFromItem=Ql;exports.timelineLayout=ad;exports.toCatalogWorkCard=Qx;exports.transportSummaryLoader=tc;exports.typeSupportsFilters=Ra;exports.useBidUrl=qe;exports.useChapterWarpData=rc;exports.useConvert=Ie;exports.useEntitySummaryLoader=dr;exports.useI18n=J;exports.useReaderPrefs=pl;exports.useRecentEntries=cd;exports.useT=$e;exports.validateLineageGraph=xx;exports.volumeStats=ci;exports.withDefaultLinks=Lt;exports.withMetaLinks=At;exports.yearText=ai;
|