book-index-ui 0.63.2 → 0.63.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +115 -84
- package/dist/index.d.ts +13 -1
- package/dist/index.js +5924 -5839
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Tu=Object.create;var Xs=Object.defineProperty;var Ru=Object.getOwnPropertyDescriptor;var Iu=Object.getOwnPropertyNames;var Eu=Object.getPrototypeOf,Lu=Object.prototype.hasOwnProperty;var Au=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Iu(n))!Lu.call(e,s)&&s!==i&&Xs(e,s,{get:()=>n[s],enumerable:!(o=Ru(n,s))||o.enumerable});return e};var yi=(e,n,i)=>(i=e!=null?Tu(Eu(e)):{},Au(n||!e||!e.__esModule?Xs(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ee=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),f=require("react"),Mu=require("opencc-js/t2cn"),Ml=require("./variant-supplement.cjs"),Pu=require("react-markdown"),Bu=require("remark-gfm"),Ou=e=>`/item/${e}`,Pl=f.createContext(Ou);function Wu({buildUrl:e,children:n}){const i=f.useMemo(()=>e,[e]);return t.jsx(Pl.Provider,{value:i,children:n})}function mt(){return f.useContext(Pl)}const Bl="",Ol="";function yo(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?Ol:Bl,a=o.indexOf(s);if(a===-1){n.push({text:o,marked:i});break}a>0&&n.push({text:o.slice(0,a),marked:i}),o=o.slice(a+1),i=!i}return n}function yt(e,n){return{title:e,tokens:n}}const Zs='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Fu=[yt("基础(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"}}),yt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),yt("提示与警告",{"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)"}}),yt("遮罩与阴影",{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)"}}),yt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),yt("资源",{"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"}}),yt("整理本(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-source":{value:"#1b5e20",note:"文本质量等级(底本 / OCR / 粗校 / 精校 / 暂无正文 / 占位)"},"quality-ocr":{value:"#e65100"},"quality-rough":{value:"#1565c0"},"quality-fine":{value:"#2e7d32"},"quality-none":{value:"#5f6368",note:"中性灰:暂无正文"},"quality-placeholder":{value:"#757575",note:"中性灰:占位"}}),yt("版本传承(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"}}),yt("编辑器视图(主要在 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")'}}),yt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),yt('版式(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"}}),yt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"reader-warm":{value:"#c9a24a",note:"阅读设置侧栏的暖黄:只做底色(8%)与选中态(24%),与朱/靛/墨三套主色都不冲"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),yt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),yt("字体(全站无衬线,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:Zs,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:Zs,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Hu=Object.assign({},...Fu.map(e=>e.tokens)),Wl={};for(const[e,n]of Object.entries(Hu))Wl[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=Wl[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Yt(e){return e.types&&e.types.length>0?e.types:[]}function Du(e,n){return Yt(e).includes(n)}const Uu={source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"};r("quality-source"),r("quality-ocr"),r("quality-rough"),r("quality-fine"),r("quality-none"),r("quality-placeholder");const Vu={"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 zn(e){try{return Vu[new URL(e).hostname]}catch{return}}const Js={text:0,image:1,physical:2};function jo(e){return e.length===0?"physical":[...e].sort((n,i)=>(Js[n]??99)-(Js[i]??99)).join("+")}function Gu(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function vo(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},i=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[g,m]=p,u=`${g}|${jo(Yt(c))}`;i.has(u)||i.set(u,{base:{...c,name:g,url:"",volumes:[]},volumes:[],indices:[]});const h=i.get(u);h.volumes.push({volume:m,url:c.url||void 0,status:"found"}),h.indices.push(d)}const o=[],s=new Set;for(const d of i.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)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function Fl(e){if(e.url)return e.url;for(const[n,i]of Object.entries(e))if(n.endsWith("_url")&&typeof i=="string")return i}function Hl(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||Fl(n)}))}function Oi(e){const n=Hl(e);if(!n)return null;const i=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,o=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:i,missing:o,expected:e.expected_volumes??i+o}}function ko(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const i=n.match(/^(\d+)/);return i?parseInt(i[1],10):void 0}function wo(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const o=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(o)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(o[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function Nn(e){if(!e.url)return;const n=ko(e.metadata);return n?wo(e.url,n):e.url}const Bt=f.createContext(null),Dl=["曹霑"];function Yu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ku(e,n=Dl){const i=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!i.length)return e;const o=new RegExp(`(${i.map(Yu).join("|")})`,"g"),s=new Set(i);return a=>{if(!a)return e(a);const l=a.split(o);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let On=null;function Ul(){if(On)return On;try{const e=Mu.Converter({from:"t",to:"cn"});On=Ku(n=>e(Ee.normalizeVariants(n)))}catch{On=e=>e}return On}const qu={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("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:"圖片資源"}},Xu={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("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 kt(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const Zu=kt({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),Wi=kt({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:"作品信息"}),Ju=kt({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:"附记"}}),Qu=kt({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:"種版本",sameEditionCopies:"同版另藏 {n} 部:",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:"种版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),em=kt({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:"上级丛编"}),tm=kt({subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對",sealAlt:"{name}印影",imgCredit:"圖像:{credit}",imgLicense:"授權:{license}",imgSource:"來源"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对",sealAlt:"{name}印影",imgCredit:"图像:{credit}",imgLicense:"授权:{license}",imgSource:"来源"}),nm=kt({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"來源",versionShort:"來源▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",properNameOff:"不顯示",properNameLite:"精簡",properNameFull:"完整",properNameLiteTitle:"只標人名、地名、朝代",showWorks:"標註書名",bookTitleStyle:"書名樣式",bookTitleWavy:"波浪線",bookTitleBracket:"書名號",scriptOrig:"原字",scriptOrigUnavailable:"此文本沒有規範層,無「原字」可選",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁體",scriptHans:"簡體",quoteStyle:"引號",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原樣",pageBreaks:"顯示分葉分割線",pageIndicator:"頁指示頭(上下鍵調整位置)",preserveMargins:"書影保留空白",facsimilePager:"書影翻頁",facsimilePageInput:"書影葉碼(輸入數字後按 Enter 或離開輸入框跳轉)",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",tocExpand:"展開",tocCollapse:"收起",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",figLabel:"圖形符號:{alt}",figPlain:"圖形符號",lacunaGuess:"闕文,推測為「{guess}」",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"来源",versionShort:"来源▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",properNameOff:"不显示",properNameLite:"精简",properNameFull:"完整",properNameLiteTitle:"只标人名、地名、朝代",showWorks:"标注书名",bookTitleStyle:"书名样式",bookTitleWavy:"波浪线",bookTitleBracket:"书名号",scriptOrig:"原字",scriptOrigUnavailable:"此文本没有规范层,无「原字」可选",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁体",scriptHans:"简体",quoteStyle:"引号",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原样",pageBreaks:"显示分叶分割线",pageIndicator:"页指示头(上下键调整位置)",preserveMargins:"书影保留空白",facsimilePager:"书影翻页",facsimilePageInput:"书影叶码(输入数字后按 Enter 或离开输入框跳转)",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",tocExpand:"展开",tocCollapse:"收起",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",figLabel:"图形符号:{alt}",figPlain:"图形符号",lacunaGuess:"阙文,推测为「{guess}」",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),im=kt({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:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"},qualityCriteria:{source:"照錄來源原文,本站未另行校對",ocr:"保持大意和結構,錯誤率在百分之十以內",rough:"保證文意基本正確,錯誤率在百分之三以內",fine:"通讀無障礙,錯誤率在百分之一以內",none:"質量未評定",placeholder:"占位條目,正文尚未錄入"},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:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暂无正文",placeholder:"占位"},qualityCriteria:{source:"照录来源原文,本站未另行校对",ocr:"保持大意和结构,错误率在百分之十以内",rough:"保证文意基本正确,错误率在百分之三以内",fine:"通读无障碍,错误率在百分之一以内",none:"质量未评定",placeholder:"占位条目,正文尚未录入"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),rm=kt({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:"古籍元數據以 CC BY-SA 4.0 發布,可自由複製、改編、再發布,但須註明出處,並以相同方式共享。",repo:"數據倉庫:",repoNote:"(GitHub,CC BY-SA 4.0)",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:"古籍元数据以 CC BY-SA 4.0 发布,可自由复制、改编、再发布,但须注明出处,并以相同方式共享。",repo:"数据仓库:",repoNote:"(GitHub,CC BY-SA 4.0)",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:"规模、存佚、许可与版本"}),So=kt({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:"按作者浏览全部 →"}),om=kt({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} 条"}),sm=kt({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:"搜索"}),am=kt({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:"回复"}),lm=kt({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:"有争议"}}),cm={common:Zu,detail:Wi,bookPage:Ju,workPage:Qu,collectionPage:em,entityPage:tm,reader:nm,collated:im,metaHome:rm,readHome:So,catalogPage:om,searchPage:sm,feedback:am,lineage:lm};function dm(e){const n={};for(const[i,o]of Object.entries(cm))n[i]=o[e];return n}function $t(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const Qs=new Map;function Tn(e){let n=Qs.get(e);return n||(n={...e==="zh-Hans"?Xu:qu,...dm(e)},Qs.set(e,n)),n}function ea(e,n){let i=e;for(const o of n.split(".")){if(i==null||typeof i!="object")return;i=i[o]}return typeof i=="string"?i:void 0}function Vl(e){return(n,i)=>{const o=ea(e,n)??ea(Tn("zh-Hant"),n)??n;return i?$t(o,i):o}}const ta=new Map;function Rn(e){let n=ta.get(e);return n||(n=Vl(Tn(e)),ta.set(e,n)),n}const Gl="bim-locale";function pm(){try{const e=localStorage.getItem(Gl);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function um(e){try{localStorage.setItem(Gl,e)}catch{}}const mm="zh-Hans",gm=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=f.useState(e??mm),l=e??s;f.useEffect(()=>{if(e)return;const g=pm();g&&g!==s&&a(g)},[]);const d=f.useMemo(()=>l==="zh-Hans"?i??Ul():null,[l,i]),c=f.useCallback(g=>{a(g),um(g),n==null||n(g)},[n]),p=f.useMemo(()=>({locale:l,setLocale:c,messages:Tn(l),converter:d}),[l,c,d]);return t.jsx(Bt.Provider,{value:p,children:o})};function We(){const e=f.useContext(Bt);return(e==null?void 0:e.messages)??Tn("zh-Hant")}const fm=2e3;function Ue(){const e=f.useContext(Bt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=f.useRef(new Map),s=f.useRef(n),a=f.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=f.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=fm){const g=o.current.keys().next().value;g!==void 0&&o.current.delete(g)}return o.current.set(d,p),p},[i]);return f.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function ae(){const e=f.useContext(Bt),{convert:n,locale:i,isSimplified:o}=Ue(),s=(e==null?void 0:e.messages)??Tn("zh-Hant"),a=f.useMemo(()=>e?Vl(s):Rn("zh-Hant"),[e,s]);return f.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const Yl=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),hm=new Set([...Yl,...Object.keys(Ee.VARIANT_CHARS),...Object.keys(Ml.VARIANT_SUPPLEMENT)]),Kl=[...Dl,"切換為繁體","漢籍リポジトリ"];function xm(e,n=Kl){let i=e;for(const a of n)a&&(i=i.split(a).join(" "));const o=[],s=Array.from(i);return s.forEach((a,l)=>{hm.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function bm(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??Ul():e==="hant"?Ee.normalizeVariants:i:n==="zh-Hans"?i:Ee.normalizeVariants}const ym=({mode:e,children:n})=>{const i=f.useContext(Bt),o=f.useMemo(()=>i&&{...i,converter:bm(e,i.locale,i.converter)},[i,e]);return t.jsx(Bt.Provider,{value:o,children:n})};function jm(e){if(!e)return"";try{const n=new URL(e).hostname,i={"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(i[n])return i[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function na(e){return e==="text+image"?["text","image"]:[e]}function ia(e){const n=Yt(e);return n.length===0?"text":Gu(n)}function vm(){return{id:"",name:"",url:"",types:["text"],details:""}}const Dr=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=We(),[l,d]=f.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}],g=k=>{if(!s)return!0;const w=Yt(k);return s==="text"?w.includes("text"):s==="image"?w.includes("image")||w.includes("physical"):s==="physical"?w.includes("physical"):w.includes(s)},m=e.map((k,w)=>({item:k,originalIndex:w})).filter(({item:k})=>g(k)),u=()=>{const k=vm();s&&(k.types=na(s)),n([...e,k]),d(e.length)},h=k=>{n(e.filter((w,v)=>v!==k)),d(null)},x=(k,w,v)=>{const C=[...e];if(C[k]={...C[k],[w]:v},w==="url"&&!C[k].id){const S=jm(v);S&&(C[k].id=S)}n(C)},j=(k,w)=>{const v=[...e],{type:C,...S}=v[k];v[k]={...S,types:na(w)},n(v)},b=(k,w,v)=>{const S={...e[k].metadata||{}};v?S[w]=v:delete S[w],x(k,"metadata",Object.keys(S).length>0?S:void 0)},$=(k,w)=>{const v=w.trim()?w.split(/[,,、]/).map(C=>C.trim()).filter(Boolean):void 0;x(k,"structure",v)},y=(k,w,v)=>{const S=e[k].coverage||{level:1,ranges:""};w==="level"?S.level=parseInt(v)||1:S.ranges=v,x(k,"coverage",S.ranges?S:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:k,originalIndex:w})=>{var v,C,S;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===w?null:w),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===w?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:km(ia(k)),color:r("on-color-fg")},children:(()=>{var R,z;const _=Yt(k);return _.length===0?"text":_.length===1?((R=c.find(N=>N.value===_[0]))==null?void 0:R.label)??_[0]:_.includes("text")&&_.includes("image")?((z=c.find(N=>N.value==="text+image"))==null?void 0:z.label)??"text+image":_.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:k.name||`${a.editor.resourcePlaceholder} ${w+1}`}),k.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:k.id}),k.url&&t.jsx("a",{href:k.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&k.url&&wm(w,o==null?void 0:o[w],i,a),t.jsx("button",{onClick:_=>{_.stopPropagation(),h(w)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===w&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[Du(k,"image")&&k.url&&Sm(k,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Wn,children:[t.jsx("span",{style:Fn,children:a.label.type}),t.jsx("select",{value:ia(k),onChange:_=>j(w,_.target.value),style:{...Lt,flex:1},children:c.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]}),t.jsxs("label",{style:Wn,children:[t.jsx("span",{style:Fn,children:a.label.rootType}),t.jsx("select",{value:k.root_type||"catalog",onChange:_=>x(w,"root_type",_.target.value),style:{...Lt,flex:1},children:p.map(_=>t.jsx("option",{value:_.value,children:_.label},_.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:k.id,onChange:_=>x(w,"id",_.target.value),placeholder:a.editor.idAutoExtract,style:{...Lt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:k.name,onChange:_=>x(w,"name",_.target.value),placeholder:a.editor.resourceName,style:{...Lt,flex:1}})]}),t.jsx("input",{type:"text",value:k.url,onChange:_=>x(w,"url",_.target.value),placeholder:a.editor.resourceUrl,style:Lt}),t.jsx("input",{type:"text",value:((v=k.structure)==null?void 0:v.join("、"))||"",onChange:_=>$(w,_.target.value),placeholder:a.editor.structurePlaceholder,style:Lt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Wn,children:[t.jsx("span",{style:Fn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((C=k.coverage)==null?void 0:C.level)??"",onChange:_=>y(w,"level",_.target.value),placeholder:"1",style:{...Lt,width:"60px"}})]}),t.jsxs("label",{style:{...Wn,flex:1},children:[t.jsx("span",{style:Fn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((S=k.coverage)==null?void 0:S.ranges)||"",onChange:_=>y(w,"ranges",_.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...Lt,flex:1}})]})]}),t.jsx("textarea",{value:k.details||"",onChange:_=>x(w,"details",_.target.value),placeholder:a.editor.detailsPlaceholder,style:{...Lt,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${r("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:r("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(([_,R])=>{var z;return t.jsxs("label",{style:{...Wn,gap:"4px"},children:[t.jsx("span",{style:{...Fn,minWidth:"56px"},children:R}),t.jsx("input",{type:"text",value:((z=k.metadata)==null?void 0:z[_])||"",onChange:N=>b(w,_,N.target.value),placeholder:R,style:{...Lt,flex:1}})]},_)})})]})]})]})]},w)}),t.jsxs("button",{onClick:u,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function km(e){switch(e){case"text":return r("restype-text");case"image":return r("restype-image");case"text+image":return r("restype-text-image");case"physical":return r("restype-physical")}}function wm(e,n,i,o){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||i(e,"")},disabled:s,style:{background:"transparent",border:"none",color:r(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?o.download.completed:s?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function Sm(e,n){const i=/\.(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:i?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:r("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:r("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:r("desc-fg")},children:n.editor.imageResourceLink})})}const Lt={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Wn={display:"flex",alignItems:"center",gap:"6px"},Fn={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},ra={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function _m(e){return e.includes("text")&&e.includes("image")?ra["text+image"]:ra[e[0]||"physical"]}const _o=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=We(),{convert:l}=Ue(),d=f.useMemo(()=>vo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=f.useMemo(()=>{const b=new Map,$=[];for(const y of d){const k=y.group;k?(b.has(k)||b.set(k,[]),b.get(k).push(y)):$.push(y)}for(const y of b.values())y.sort((k,w)=>{const v=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return v(k)-v(w)});return{mirrorGroups:b,ungroupedItems:$}},[d]),g={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=b=>g[b]?g[b]:b.split("+").map($=>g[$]||$).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("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((b,$)=>t.jsx(kr,{item:b},b.id||$))});const u=(b,$)=>{const y=i==null?void 0:i[b],k=(y==null?void 0:y.label)||b,w=y==null?void 0:y.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(k)}),w&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.5},children:l(w)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((v,C)=>t.jsx(kr,{item:v,onNavigate:o,renderLink:s},v.id||C))})]},`group-${b}`)},h=new Map;for(const b of p){const $=jo(Yt(b));h.has($)||h.set($,[]),h.get($).push(b)}const x=["text","image","text+image","physical"],j=[...x.filter(b=>h.has(b)),...[...h.keys()].filter(b=>!x.includes(b)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([b,$])=>u(b,$)),j.map(b=>{const $=h.get(b),y=_m(b.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:y,whiteSpace:"nowrap",flexShrink:0},children:m(b)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$.map((k,w)=>t.jsx(kr,{item:k,onNavigate:o,renderLink:s},k.id||w))})]},b)})]})},$m={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},kr=({item:e})=>{const n=We(),{convert:i}=Ue(),[o,s]=f.useState(!1),a=f.useMemo(()=>(e.url?zn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=f.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||Fl(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,g=e.expected_volumes??(d?c+p:0),m=e.color_mode?{...$m[e.color_mode],label:n.colorMode[e.color_mode]}:null,u=e.details&&!d?i(e.details):null,h={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",background:r("input-bg"),fontSize:"12px",color:r("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:h,children:[t.jsx("span",{style:{fontWeight:500},children:a}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),u&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:u}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",g,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:$t(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=ko(e.metadata);return x?wo(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:r("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),d&&o&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const j=x.status==="missing";return x.url&&!j?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 ${r("widget-border")}`,color:r("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:r(j?"missing-fg":"desc-fg"),textDecoration:j?"line-through":"none",opacity:j?.6:1},children:x.volume},x.volume)})})]})},ql=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=We(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,g=(n==null?void 0:n.repoPath)||"",m=g?g.split(/[/\\]/).pop()||g:"",u={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},h={onMouseOver:j=>j.currentTarget.style.opacity="0.8",onMouseOut:j=>j.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...u,background:r(p?"warning":"success"),color:r("on-color-fg")},...h,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:u,...h,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:g||d.mode.selectFolder,style:{...u,paddingLeft:"8px",paddingRight:"8px"},...h,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:u,...h,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:m||d.mode.configurePath,style:{...u,background:"transparent",padding:"6px",fontSize:"12px"},...h,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:u,...h,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:g||d.mode.selectFolder,style:{...u,paddingLeft:"8px",paddingRight:"8px",minWidth:g?"100px":"auto",justifyContent:"space-between"},...h,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...u,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:g,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:m})]})]})},Fi="bim-search-history",oa=10,sa=8;function Kn(){try{const e=localStorage.getItem(Fi);return e?JSON.parse(e):[]}catch{return[]}}function Xl(e){try{const n=Kn().filter(i=>i!==e);n.unshift(e),n.length>oa&&(n.length=oa),localStorage.setItem(Fi,JSON.stringify(n))}catch{}}function Cm(e){try{const n=Kn().filter(i=>i!==e);localStorage.setItem(Fi,JSON.stringify(n))}catch{}}function zm(){try{localStorage.removeItem(Fi)}catch{}}const Zl=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=We(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,g]=f.useState(!1),[m,u]=f.useState([]),[h,x]=f.useState(-1),[j,b]=f.useState(Kn),$=f.useRef(null),y=f.useRef(null),k=f.useRef(null),w=f.useRef(!1);f.useEffect(()=>{x(-1);const N=n.trim();if(!N){u(j.map(O=>({type:"history",text:O})));return}if(!e.searchAll){u([]);return}let I=!1;const B=setTimeout(()=>{e.searchAll(N,sa).then(O=>{if(I)return;const A=[...O.works,...O.books,...O.collections,...O.entities??[]];u(A.slice(0,sa).map(W=>({type:"entry",text:W.title||W.id,entry:W})))}).catch(()=>{I||u([])})},80);return()=>{I=!0,clearTimeout(B)}},[n,j,e]),f.useEffect(()=>{const N=I=>{k.current&&!k.current.contains(I.target)&&g(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),f.useEffect(()=>{const N=I=>{var B,O;if(I.key==="/"&&document.activeElement!==$.current){const A=(B=document.activeElement)==null?void 0:B.tagName;if(A==="INPUT"||A==="TEXTAREA"||A==="SELECT")return;I.preventDefault(),(O=$.current)==null||O.focus()}};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[]);const v=f.useCallback(N=>{N.trim()&&(Xl(N.trim()),b(Kn())),o(N),g(!1)},[o]),C=f.useCallback(N=>{N.type==="history"?(i(N.text),v(N.text)):N.entry&&(s?(s(N.entry),g(!1)):(i(N.text),v(N.text)))},[i,v,s]),S=f.useCallback(N=>{if(!p||m.length===0){N.key==="Enter"&&v(n);return}switch(N.key){case"ArrowDown":N.preventDefault(),x(I=>(I+1)%m.length);break;case"ArrowUp":N.preventDefault(),x(I=>(I-1+m.length)%m.length);break;case"Enter":N.preventDefault(),h>=0&&h<m.length?C(m[h]):v(n);break;case"Escape":N.preventDefault(),g(!1);break}},[p,m,h,n,v,C]),_=f.useCallback((N,I)=>{I.stopPropagation(),Cm(N),b(Kn()),u(B=>B.filter(O=>!(O.type==="history"&&O.text===N)))},[]),R=f.useCallback(N=>{N.stopPropagation(),zm(),b([]),u([])},[]);f.useEffect(()=>{if(h>=0&&y.current){const N=y.current.children;N[h]&&N[h].scrollIntoView({block:"nearest"})}},[h]);const z=!n.trim()&&j.length>0;return t.jsxs("div",{ref:k,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:$,type:"text",placeholder:d,value:n,onChange:N=>{i(N.target.value),g(!0)},onCompositionStart:()=>{w.current=!0},onCompositionEnd:()=>{w.current=!1},onFocus:()=>{g(!0)},onKeyDown:S,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&m.length>0&&t.jsxs("div",{ref:y,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:r("input-bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"6px",boxShadow:r("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[z&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:r("desc-fg"),borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:R,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((N,I)=>t.jsxs("div",{onClick:()=>C(N),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:I===h?r("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:N.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.text}),N.entry&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:[c[N.entry.type],N.entry.edition&&` · ${N.entry.edition}`,N.entry.author&&` · ${N.entry.author}`]}),N.type==="history"&&t.jsx("button",{onClick:B=>_(N.text,B),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${N.type}-${N.text}-${I}`))]})]})},In=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:r(`type-${e}`),verticalAlign:"middle"}}),Jl=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Nm={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function gt(e){return Nm[e]??e}const Sn=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],_n={熹平: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},Ql={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Hi(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const i=parseInt(n[1],10);if(i<100||i>2100)return;const o=n[2]?parseInt(n[2],10):void 0;return{from:i,to:o!=null&&o>=i&&o<=2100?o:void 0}}function Tm(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 Rm=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,aa={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function $o(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(aa))if(n.startsWith(s))return aa[s];const i=gt(n);if(ln[i]!=null)return i;const o=Gt(n);if(o&&n.length<=o.length+1)return gt(o)}function an(e,n){if(n){const i=Ql[`${n}|${e}`];if(i!=null)return i}return _n[e]}const Im=1911;function Em(e){const n=_n[e];if(n==null)return;const i=Pt[e];let o;for(const[s,a]of Object.entries(_n))Pt[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const Lm={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Ii(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,i=0,o=!1;for(const a of e){const l=Lm[a];if(l===void 0)return;o=!0,a==="十"?i=(i||1)*10:a==="廿"||a==="卅"?(n+=l,i=0):i>=10?(n+=i+l,i=0):i=i*10+l}const s=n+i;return o&&s>0?s:void 0}function Gt(e){for(const n of Jl)if(e.startsWith(n))return n}const Pt={};{const e=(n,i)=>{for(const o of i)Pt[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function cn(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys(_n))if(e.includes(o)&&!(i&&Pt[o]&&Pt[o]!==i&&Ql[`${i}|${o}`]==null))return o}function ni(e){var l,d,c;const n={era:"",reign:"",source:"none"},i=e.dating;if(i!=null&&i.era||i!=null&&i.reign)return{era:i.era??"",reign:i.reign??"",source:i.certainty==="attested"?"catalog":"edition"};const o=(l=e.lineage)==null?void 0:l.year_text;if(o){const p=Gt(o)??"";return{era:gt(p),reign:cn(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=Hi(s);if(p)return{era:Tm(p.from),reign:"",source:"publication"};const g=Gt(s)??$o(s)??((c=Sn.find(h=>h.pattern.test(s)))==null?void 0:c.era)??"",m=cn(s,g)??"",u=g||(m?Pt[m]??"":"");if(u||m)return{era:gt(u),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Gt(a);if(p)return{era:gt(p),reign:cn(a,p)??"",source:"edition"};const g=Sn.find(m=>m.pattern.test(a));if(g)return{era:gt(g.era),reign:cn(a,g.era)??g.reign??"",source:"edition"}}return n}function Di(e){var o,s,a,l,d,c,p,g,m;if(((o=e.dating)==null?void 0:o.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 u=Hi(n);if(u)return u.from}const i=[(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 u of i){const h=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(h&&u!==h&&(Gt(h)||$o(h)))break;const x=u.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??u.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const k=parseInt(x[1],10);if(k>=100&&k<=2100)return k}const j=u.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(j){const k=Gt(u);if(!k||gt(k)==="民國"){const v=Ii(j[1]);if(v!=null&&v>=1&&v<=120)return Im+v}}const b=Gt(u)??((g=Sn.find(k=>k.pattern.test(u)))==null?void 0:g.era),$=b?gt(b):void 0,y=cn(u,$)??(Gt(u)||(m=Sn.find(k=>k.pattern.test(u)))==null?void 0:m.reign);if(y){const k=an(y,$);if(k==null)continue;const w=u.indexOf(y),v=w>=0?u.slice(w+y.length):"",C=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),S=C?Ii(C[1]):void 0;return k+(S?S-1:0)}}}function Co(e){var l,d,c,p,g,m;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(d=e.lineage)==null?void 0:d.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const o=(c=e.lineage)==null?void 0:c.year_text;if(o){const u=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(u){const h=Ur[gt(u[1])],x=ln[gt(u[2])];if(h!=null&&x!=null)return{from:Math.min(h,x)-20,to:Math.max(h,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const u=Hi(s);if((u==null?void 0:u.to)!=null)return{from:u.from,to:u.to};const h=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const x=Ur[gt(h[1])],j=ln[gt(h[2])];if(x!=null&&j!=null)return{from:Math.min(x,j)-20,to:Math.max(x,j)+40}}}const a=[(g=e.publication_info)==null?void 0:g.year,e.edition,e.title].filter(Boolean);for(const u of a){if(!/[間间]/.test(u))continue;const h=Gt(u)??$o(u)??((m=Sn.find(b=>b.pattern.test(u)))==null?void 0:m.era),x=h?gt(h):void 0,j=[];for(const b of Object.keys(_n))u.includes(b)&&(x&&Pt[b]&&Pt[b]!==x||an(b,x)!=null&&j.push(b));if(j.length===0){const b=u.match(/([一-鿿])([一-鿿])[間间]/);if(b&&x){for(const $ of[b[1],b[2]])for(const y of Object.keys(_n))if(Pt[y]===x&&!(y[0]!==$&&y[y.length-1]!==$)&&an(y,x)!=null){j.push(y);break}}}if(j.length>0){const b=j.map(w=>an(w,x)).filter(w=>w!=null),$=Math.min(...b),y=j.reduce((w,v)=>an(w,x)>=an(v,x)?w:v),k=Em(y)??wr(x??"")??Math.max(...b);return{from:$,to:k>$?k:wr(x??Pt[y]??"")??$}}if(x&&ln[x]!=null)return{from:ln[x],to:wr(x)??ln[x]}}}const ln={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Am=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Mm=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,la=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function ca(e,n){for(const i of Jl){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!cn(e.slice(o),gt(i)))continue}const s=gt(i);if(s===n)continue;const a=e.slice(o),l=cn(a,s)??"";let d;if(l){const c=an(l,s);if(c!=null){const g=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=g?Ii(g[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const i of Sn)if(i.pattern.test(e))return{era:gt(i.era),reign:i.reign??""}}function Pm(e){var $,y,k,w,v;const n=ni(e),i=(($=e.publication_info)==null?void 0:$.year)??"",o=i?Hi(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((y=e.lineage)==null?void 0:y.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&Rm.test(i),p=n.source==="publication"&&/[間间]/.test(i),g=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:g?m=parseInt(g[2],10):m=Di(e);const u=m==null?Co(e):void 0;let h;n.source==="publication"&&(c||la.test(i))?h="uncertain":n.source==="lineage"||n.source==="publication"?h="attested":la.test(s)||!n.reign&&m==null?h="uncertain":h="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((k=e.lineage)==null?void 0:k.year_text)??((w=e.lineage)==null?void 0:w.year)??""}」`:`出版著錄「${((v=e.publication_info)==null?void 0:v.year)??""}」`,j={era:n.era,reign:n.reign,year:m,yearRange:u,certainty:h,source:n.source==="edition"?"edition":"catalog",basis:x};if(g){const C=l.match(/[、,,]\s*([宋元明清])/);C&&C[1]!==j.era&&(j.laterRepair={era:C[1]})}if(!j.laterRepair&&Mm.test(s)){const C=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);C&&C[1]!==n.era&&(j.laterRepair={era:C[1]})}const b=Am.find(C=>C.re.test(s));if(b){const C=s.search(b.re),S=s.slice(C),_=ca(S,n.era)??ca(s,n.era);_&&(j.basedOn={era:_.era,reign:_.reign,year:_.year,relation:b.relation})}return j}const Ur={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function wr(e){return Ur[e]}function Ei(e){const n=Di(e);if(n!=null)return n;const i=Co(e);if(i)return i.from;const o=ni(e).era;return o?ln[o]:void 0}const da=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Vr(e){const n=da.indexOf(e);return n===-1?da.length:n}function Bm(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 i=[],o=(s,a)=>{n[s].length&&i.push({key:s,labelKey:a,items:n[s]})};return o("belongsTo","belongsToWork"),o("collected","collectedIn"),o("contains","containedWorks"),o("derivative","derivativeWorks"),o("studies","studies"),o("related","relatedWorks"),i}function zo(e,n){const i=vo(e||[]),o=new Map,s=[];for(const p of i)p.group?(o.has(p.group)||o.set(p.group,[]),o.get(p.group).push(p)):s.push(p);for(const p of o.values())p.sort((g,m)=>{const u=h=>h.group_role==="origin"?0:h.group_role==="mirror"?1:2;return u(g)-u(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const g=Yt(p),m=g.includes("text"),u=g.includes("image");m&&u?a.textImage.push(p):m?a.text.push(p):u?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=[...o.entries()].map(([p,g])=>{var m,u;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(u=n==null?void 0:n[p])==null?void 0:u.description,items:g}});return{buckets:d,mirrors:c,total:i.length}}function Ui(e,n=Rn("zh-Hant")){const i=[],o=e.metadata||{};o.edition&&i.push(String(o.edition)),e.source_label&&i.push(e.source_label),e.details&&i.push(e.details);const s=Oi(e);return s&&s.expected>0&&i.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})),o.version&&i.push(String(o.version)),i.join(" · ")}function ec(e,n){if(Ui(e)||n.filter(o=>o.name===e.name).length<2)return"";try{const o=new URL(e.url),s=o.searchParams.get("res")||o.searchParams.get("id");if(s)return s;const a=o.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}const Om="同版";function Wm(e){const n=e==null?void 0:e.metadata;return((n==null?void 0:n.item_id)||(n==null?void 0:n.call_number)||"").trim()||void 0}function Fm(e){var n;for(const i of((n=e.lineage)==null?void 0:n.related_to)??[]){const o=i.ref??i.book_id;if(i.relation===Om&&o&&o!==e.id)return o}}function Hm(e){const n=new Map(e.map(a=>[a.id,a])),i=a=>{const l=n.get(a);return!!l&&!l.copyOf},o=new Map;for(const a of e)if(a.copyOf&&i(a.copyOf)){const l=o.get(a.copyOf)??[];l.push(a),o.set(a.copyOf,l)}if(o.size===0)return e;const s=[];for(const a of e){if(a.copyOf&&i(a.copyOf))continue;const l=o.get(a.id);if(!l){s.push(a);continue}const d=[...l].sort((c,p)=>(c.callNumber??c.id).localeCompare(p.callNumber??p.id));s.push({...a,copies:d,hasImage:a.hasImage||d.some(c=>c.hasImage)})}return s}function tc(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Yt(d);c.includes("image")&&o.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:ni(e),year:Di(e),sortYear:Ei(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,callNumber:Wm(s[0]),copyOf:Fm(e),summary:e.summary,important:Dm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function Dm(e,n){var d,c;if(!n)return!1;const i=n.default_collection;if(!i)return!1;const o=(d=n.collections)==null?void 0:d[i];if(((o==null?void 0:o.book_ids)??(i==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(o==null?void 0:o.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function nc(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=Hm(e.filter(c=>!o.has(c.id)).map(c=>tc(c,n)));let a=s;i.era&&(a=a.filter(c=>c.era.era===i.era)),i.scanOnly&&(a=a.filter(c=>c.hasImage)),i.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const g=c.r.sortYear,m=p.r.sortYear;return g!=null&&m!=null?g-m||c.i-p.i:g!=null?-1:m!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const g=m=>(m.important?0:1)*2+(m.hasImage?0:1);return g(c.r)-g(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)=>Vr(c)-Vr(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Um(e,n){var b,$;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(b=n.collections)==null?void 0:b[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.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(o),c=new Set([...s,...l]),p=y=>{if(c.has(y))return!0;const k=n.node_groups[y];return k!=null&&d.has(k)},g=[],m=new Map,u=[];for(const y of e)if(!(($=n.excluded_books)!=null&&$.includes(y)))if(p(y))g.push(y);else{const k=n.node_groups[y];k?(m.has(k)||m.set(k,[]),m.get(k).push(y)):u.push(y)}if(u.length+[...m.values()].reduce((y,k)=>y+k.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(y=>[y.id,y])),j=[...m.entries()].map(([y,k])=>{const w=x.get(y);return{id:y,label:(w==null?void 0:w.label)??y,description:w==null?void 0:w.description,ids:k}});return u.length>0&&j.push({id:"__other__",label:"其他版本",description:void 0,ids:u}),{useGrouping:!0,coreIds:g,groupedIds:j}}const ic=["撰","編","注","校","譯","繪","其他"],Vm=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function No(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of Vm)if(o.test(n))return i;return"其他"}function To(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function rc(e,n="全部"){const i=new Map;for(const s of e){const a=No(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of ic){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function Ro(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function Io(e){const n=e._classifications??[],i=n.find(o=>o.scheme==="zongmu")??n[0];if(i)return{l1:i.l1??"",l2:i.l2??"",l3:i.l3??"",l4:i.l4??"",...i.source?{source:i.source}:{}}}function oc(e){const n=e._members??[],i=typeof e._member_count=="number"?e._member_count:n.length;return{works:n.filter(o=>o.t==="work").map(o=>({id:o.id,title:o.title??"",volumes:qn(o.vol)})),bookIds:n.filter(o=>o.t!=="work").map(o=>o.id).filter(o=>typeof o=="string"),total:i,truncated:i>n.length}}function Gm(e){var n;return(e==null?void 0:e._member_count)||((n=e==null?void 0:e._members)==null?void 0:n.length)||0}function sc(e,n,i){if(n&&n.books&&n.books.length>0){const l=n.books.map(c=>({id:c.work_id||c.book_id||void 0,title:c.title,section:c.section,volumes:c.volumes||[],subItems:c.sub_items,edition:c.edition,found:c.found_volumes,expected:c.expected_volumes})),d=[...new Set(l.map(c=>c.section).filter(Boolean))];return{rows:l,source:"catalog",sections:d,totalVolumes:n.total_volumes}}const{works:o,bookIds:s}=oc(e);return o.length>0?{rows:o.map(d=>({id:d.id,title:d.title,volumes:d.volumes})),source:"works",sections:[]}:{rows:s.map(l=>{var d,c;return{id:l,title:((d=i==null?void 0:i.get(l))==null?void 0:d.title)||l,edition:(c=i==null?void 0:i.get(l))==null?void 0:c.edition,volumes:[]}}),source:"books",sections:[]}}function qn(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[i,o]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,o-i+1)},(s,a)=>i+a)}return e.split(/[,、]/).map(i=>parseInt(i.trim())).filter(i=>!isNaN(i))}return[]}function Vi(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=[...e].sort((a,l)=>a-l),o=i[0],s=i[i.length-1];return s-o+1===i.length?`${o}–${s}`:i.length<=3?i.join(", "):`${o}–${s} (${i.length}${n})`}const Ym=["〇","一","二","三","四","五","六","七","八","九"],pa=["","十","百","千"];function En(e){if(!Number.isInteger(e)||e<=0)return"";if(e>=1e8)return String(e);if(e<1e4)return Sr(e,!0);const n=Math.floor(e/1e4),i=e%1e4;let o=Sr(n,!0)+"萬";return i>0&&(o+=(i<1e3?"〇":"")+Sr(i,!1)),o}function Sr(e,n){const i=String(e),o=i.length;let s="",a=!1;for(let l=0;l<o;l++){const d=parseInt(i[l]),c=o-1-l;d===0?a=!0:(a&&s&&(s+="〇"),a=!1,n&&d===1&&c===1&&l===0?s+=pa[c]:s+=Ym[d]+pa[c])}return s}function Km(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function qm(e){if(e==null||typeof e=="string")return;const n="url"in e&&e.url?e.url:"type"in e&&e.type==="url"?e.details:void 0;return n&&/^https?:\/\//i.test(n)?n:void 0}function Kt(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?En(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function ac(e){var o;if(e.edition_type)return e.edition_type;if((o=e.lineage)!=null&&o.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/油印/,"油印本"],[/曬印|晒印/,"曬印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of i)if(s.test(n))return a;return""}const Gi={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},lc=new Set(["work","book","entity"]);function Xm(e){return pc(e)||!!e.sort}function Zm(e,n){return n.sort&&lc.has(e)?n.sort:void 0}const Yi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Ki=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],cc=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],dc={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function qi(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 pc(e){return qi(e)>0}function Jm(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 uc(e,n){const i=dc[e];return Jm(n).every(o=>i.has(o))}const Hn=e=>JSON.stringify(e);function Qm(e,n){if(!uc(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=Yi.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${Hn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(Hn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${Hn(e.classification[0])}`:`classification IN [${e.classification.map(Hn).join(", ")}]`),e.hasImage&&i.push("has_image = true"),e.hasText&&i.push("has_text = true"),e.hasCollated&&i.push("has_collated = true"),e.loss&&i.push(`loss_status = ${Hn(e.loss)}`),i.join(" AND ")}const bt={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},mc="_";function Li(e,n=new URLSearchParams){for(const i of Object.values(bt))n.delete(i);return e.dynasty.length&&n.set(bt.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(bt.classification,e.classification.map(i=>i||mc).join(",")),e.hasImage&&n.set(bt.hasImage,"1"),e.hasText&&n.set(bt.hasText,"1"),e.hasCollated&&n.set(bt.hasCollated,"1"),e.loss&&n.set(bt.loss,e.loss),e.sort&&n.set(bt.sort,e.sort),n}function eg(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(Yi.map(a=>a.key)),o=new Set(Ki.map(a=>a.value)),s=e.get(bt.loss);return{dynasty:Array.from(new Set(n(bt.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(bt.classification).map(a=>a===mc?"":a).filter(a=>o.has(a)))),hasImage:e.get(bt.hasImage)==="1",hasText:e.get(bt.hasText)==="1"||e.get(bt.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(bt.sort))??""}}function tg(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 ua(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const ng=({filters:e,onChange:n})=>{const i=We(),o=i.searchV4,{convert:s}=Ue(),[a,l]=f.useState(!1),d=f.useId(),c=qi(e),p=g=>n({...e,...g});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(o.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(g=>!g),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s($t(o.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?o.collapse:o.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(o.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:Yi.map(g=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(g.key),onClick:()=>p({dynasty:ua(e.dynasty,g.key)}),children:s(g.key)},g.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),Ki.map(g=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(g.value),onChange:()=>p({classification:ua(e.classification,g.value)})}),g.value?s(g.label):i.searchPage.unclassified]},g.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:g=>p({hasImage:g.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:g=>p({hasText:g.target.checked})}),s(o.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(o.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:cc.map(g=>t.jsx("button",{type:"button","aria-pressed":e.loss===g.value,onClick:()=>p({loss:g.value}),children:i.searchPage.loss[g.value||"all"]},g.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Gi,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function gc({text:e,query:n}){const i=(n??"").trim();if(!i||!e)return t.jsx(t.Fragment,{children:e});const o=e.toLowerCase(),s=i.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=o.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 ma=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=We(),a=s.searchV4,{convert:l}=Ue(),d=mt();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),g=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",u=c.type==="book"?c.era??c.dynasty:c.dynasty,h=u?l(u):"",x=c.classification?l(c.classification):"",j=[];c.has_image&&j.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&j.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&j.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const b=[m,h,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:$=>i(c,$),children:t.jsx(gc,{text:p,query:n?l(n):void 0})}),g&&t.jsx("span",{className:"bim-sr-measure",children:g})]}),b&&t.jsx("span",{className:"bim-sr-sub",children:b})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(In,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:h||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:j.map($=>t.jsx("span",{className:`bim-sr-tag ${$.cls}`,children:l($.label)},$.label))})]},c.id)})})]})})},ig=`
|
|
1
|
+
"use strict";var Eu=Object.create;var Qs=Object.defineProperty;var Lu=Object.getOwnPropertyDescriptor;var Au=Object.getOwnPropertyNames;var Mu=Object.getPrototypeOf,Pu=Object.prototype.hasOwnProperty;var Bu=(e,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Au(n))!Pu.call(e,s)&&s!==i&&Qs(e,s,{get:()=>n[s],enumerable:!(o=Lu(n,s))||o.enumerable});return e};var vi=(e,n,i)=>(i=e!=null?Eu(Mu(e)):{},Bu(n||!e||!e.__esModule?Qs(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Re=require("./storage-entry-Cx6j1zcJ.cjs"),t=require("react/jsx-runtime"),f=require("react"),Ou=require("opencc-js/t2cn"),Ol=require("./variant-supplement.cjs"),Wu=require("react-markdown"),Fu=require("remark-gfm"),Hu=e=>`/item/${e}`,Wl=f.createContext(Hu);function Du({buildUrl:e,children:n}){const i=f.useMemo(()=>e,[e]);return t.jsx(Wl.Provider,{value:i,children:n})}function gt(){return f.useContext(Wl)}const Fl="",Hl="";function vo(e){const n=[];let i=!1,o=e;for(;o.length;){const s=i?Hl:Fl,a=o.indexOf(s);if(a===-1){n.push({text:o,marked:i});break}a>0&&n.push({text:o.slice(0,a),marked:i}),o=o.slice(a+1),i=!i}return n}function vt(e,n){return{title:e,tokens:n}}const ea='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Uu=[vt("基础(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"}}),vt("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),vt("提示与警告",{"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)"}}),vt("遮罩与阴影",{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)"}}),vt("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),vt("资源",{"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"}}),vt("整理本(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-source":{value:"#1b5e20",note:"文本质量等级(底本 / OCR / 粗校 / 精校 / 暂无正文 / 占位)"},"quality-ocr":{value:"#e65100"},"quality-rough":{value:"#1565c0"},"quality-fine":{value:"#2e7d32"},"quality-none":{value:"#5f6368",note:"中性灰:暂无正文"},"quality-placeholder":{value:"#757575",note:"中性灰:占位"}}),vt("版本传承(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"}}),vt("编辑器视图(主要在 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")'}}),vt("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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}}),vt('版式(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"}}),vt("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"},"reader-warm":{value:"#c9a24a",note:"阅读设置侧栏的暖黄:只做底色(8%)与选中态(24%),与朱/靛/墨三套主色都不冲"},"warp-bg":{value:"#faf8f5",note:"古籍矫正底本书影画布底色"},"warp-box-shadow":{value:"0 2px 12px rgba(0, 0, 0, 0.08)",note:"古籍底本书影浮雕阴影"},"warp-sel-bg":{value:"rgba(196, 148, 76, 0.45)",note:"古籍对读字框选中高亮底色"},"warp-sel-stroke":{value:"#a06e1c",note:"古籍对读字框选中描边"},"warp-hover-bg":{value:"rgba(217, 185, 106, 0.25)",note:"古籍对读字框悬停高亮底色"},"warp-hover-stroke":{value:"#c4944c",note:"古籍对读字框悬停描边"},"warp-badge-bg":{value:"rgba(184, 134, 54, 0.12)",note:"图文对读徽章背景"},"warp-badge-fg":{value:"#8c6820",note:"图文对读徽章文字颜色"},"warp-badge-bd":{value:"rgba(184, 134, 54, 0.3)",note:"图文对读徽章边框"},"warp-banxin-border":{value:"#8a8070",note:"版心分界线"},"warp-banxin-fold":{value:"rgba(160, 110, 28, 0.65)",note:"版心中缝对折线"},"warp-banxin-outer":{value:"#c9c3b4",note:"版心外边线"}}),vt("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),vt("字体(全站无衬线,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:ea,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:ea,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Vu=Object.assign({},...Uu.map(e=>e.tokens)),Dl={};for(const[e,n]of Object.entries(Vu))Dl[e]=`var(--bim-${e}, ${n.value})`;function r(e){const n=Dl[e];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${e}`);return n}function Yt(e){return e.types&&e.types.length>0?e.types:[]}function Gu(e,n){return Yt(e).includes(n)}const Yu={source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"};r("quality-source"),r("quality-ocr"),r("quality-rough"),r("quality-fine"),r("quality-none"),r("quality-placeholder");const Ku={"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 Nn(e){try{return Ku[new URL(e).hostname]}catch{return}}const ta={text:0,image:1,physical:2};function ko(e){return e.length===0?"physical":[...e].sort((n,i)=>(ta[n]??99)-(ta[i]??99)).join("+")}function qu(e){return e.includes("text")&&e.includes("image")?"text+image":e[0]||"physical"}function wo(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},i=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[g,m]=p,u=`${g}|${ko(Yt(c))}`;i.has(u)||i.set(u,{base:{...c,name:g,url:"",volumes:[]},volumes:[],indices:[]});const h=i.get(u);h.volumes.push({volume:m,url:c.url||void 0,status:"found"}),h.indices.push(d)}const o=[],s=new Set;for(const d of i.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)??""),o.push(d.base);for(const c of d.indices)s.add(c)}const a=[...o];for(let d=0;d<e.length;d++)s.has(d)||a.push(e[d]);return a}function Ul(e){if(e.url)return e.url;for(const[n,i]of Object.entries(e))if(n.endsWith("_url")&&typeof i=="string")return i}function Vl(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||Ul(n)}))}function Fi(e){const n=Vl(e);if(!n)return null;const i=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,o=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:i,missing:o,expected:e.expected_volumes??i+o}}function So(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const i=n.match(/^(\d+)/);return i?parseInt(i[1],10):void 0}function _o(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const o=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(o)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(o[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function Tn(e){if(!e.url)return;const n=So(e.metadata);return n?_o(e.url,n):e.url}const Ot=f.createContext(null),Gl=["曹霑"];function Xu(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zu(e,n=Gl){const i=[...new Set(n.filter(Boolean))].sort((a,l)=>l.length-a.length);if(!i.length)return e;const o=new RegExp(`(${i.map(Xu).join("|")})`,"g"),s=new Set(i);return a=>{if(!a)return e(a);const l=a.split(o);return l.length===1?e(a):l.map((d,c)=>c%2===1&&s.has(d)?d:d&&e(d)).join("")}}let Wn=null;function Yl(){if(Wn)return Wn;try{const e=Ou.Converter({from:"t",to:"cn"});Wn=Zu(n=>e(Re.normalizeVariants(n)))}catch{Wn=e=>e}return Wn}const Ju={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("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:"圖片資源"}},Qu={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:r("check-fine-bg"),fg:r("check-fine-fg")},粗校:{label:"粗校",bg:r("check-rough-bg"),fg:r("check-rough-fg")},AI整理:{label:"AI整理",bg:r("check-ai-bg"),fg:r("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 St(e,n,i){return{"zh-Hant":e,"zh-Hans":n}}const em=St({toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主題",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加載中",repoSourceLink:"在 GitHub 查看本條目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分冊",expandVolumes:"展開分冊",collapseArrow:"收起 ▲",expandArrow:"展開 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"集體"},cbdbTitle:"CBDB 中國歷代人物傳記數據庫",entityPlaceholderNote:"人物信息暫缺。該 Entity 僅作為作者佔位,詳細生平資料尚待補充。",otherVersions:"其他版本",switchToEdit:"切換到編輯模式",switchToView:"切換到查看模式",modeEdit:"✏️ 編輯",modeView:"👁 查看",noData:"無數據"},{toHans:"切换为简体",toHant:"切換為繁體",localeShortHans:"简",localeShortHant:"繁",themeLabel:"主题",theme:{zhusha:"朱砂",indigo:"靛青",ink:"墨"},loading:"加载中",repoSourceLink:"在 GitHub 查看本条目源文件",volumesMissing:"缺{n}",collapseVolumes:"收起分册",expandVolumes:"展开分册",collapseArrow:"收起 ▲",expandArrow:"展开 ▼",entitySubtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"集体"},cbdbTitle:"CBDB 中国历代人物传记数据库",entityPlaceholderNote:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。",otherVersions:"其他版本",switchToEdit:"切换到编辑模式",switchToView:"切换到查看模式",modeEdit:"✏️ 编辑",modeView:"👁 查看",noData:"无数据"}),Hi=St({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:"作品信息"}),tm=St({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:"附记"}}),nm=St({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:"種版本",sameEditionCopies:"同版另藏 {n} 部:",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:"种版本",sameEditionCopies:"同版另藏 {n} 部:",inferredEraNote:"部分年代据版本题名推断,非著录原文",empty:"尚未著录该作品的版本与书目收录。",relatedCount:"{n} 部",hasImage:"有影印",catalog:{meta:"历代书目 {n} 家",tablist:"著录书目",titleOnly:"仅著录书名,无提要。",prev:"上一家:{name}",next:"下一家:{name}"}}),im=St({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:"上级丛编"}),rm=St({subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年號",office:"官職",anonymous:"佚名",collective:"群體"},bce:"前{n}",floruit:"活躍於 {from}—{to}",zi:"字{name}",hao:"號{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 種",moreNames:"更多別名({n})",dist:"著作分佈",autoMatch:"自動匹配",sec:{featured:"著作舉要",allWorks:"全部著作",works:"著作",external:"站外資料"},featuredSub:"存世版本最多的三部",versionsUnit:"種版本",hasImage:"有影印",empty:"尚未著錄該人物的關聯作品。",total:"共 {n} 種",current:"當前 {n} 種",sortByVersions:"按版本數排列",sortByCatalog:"按著錄順序",col:{work:"作品",section:"部類",role:"職任",versions:"存世版本",image:"影印"},notRecorded:"未著錄",emptyRole:"該職任下的著作尚未著錄。",moreUnit:"種著作",cbdbAuto:"CBDB 為自動匹配,未經人工核對",sealAlt:"{name}印影",imgCredit:"圖像:{credit}",imgLicense:"授權:{license}",imgSource:"來源"},{subtype:{people:"人物",place:"地名",dynasty:"朝代",reign:"年号",office:"官职",anonymous:"佚名",collective:"群体"},bce:"前{n}",floruit:"活跃于 {from}—{to}",zi:"字{name}",hao:"号{name}",nativePlace:"{place}人",lifeAria:"{birth}—{death},一生 {years} 年",lifeYears:"一生 {years} 年",fact:{works:"著作"},nZhong:"{n} 种",moreNames:"更多别名({n})",dist:"著作分布",autoMatch:"自动匹配",sec:{featured:"著作举要",allWorks:"全部著作",works:"著作",external:"站外资料"},featuredSub:"存世版本最多的三部",versionsUnit:"种版本",hasImage:"有影印",empty:"尚未著录该人物的关联作品。",total:"共 {n} 种",current:"当前 {n} 种",sortByVersions:"按版本数排列",sortByCatalog:"按著录顺序",col:{work:"作品",section:"部类",role:"职任",versions:"存世版本",image:"影印"},notRecorded:"未著录",emptyRole:"该职任下的著作尚未著录。",moreUnit:"种著作",cbdbAuto:"CBDB 为自动匹配,未经人工核对",sealAlt:"{name}印影",imgCredit:"图像:{credit}",imgLicense:"授权:{license}",imgSource:"来源"}),om=St({imagesLoading:"加載書影…",noImages:"暫無書影",noImagesHint:"這一卷還沒有配上影像;接入後在此與正文逐頁對看",imageAlt:"書影 第 {label} 頁",prevImage:"上一頁書影",nextImage:"下一頁書影",back:"閱讀",backAria:"返回{label}首頁",skipToText:"跳到正文",settings:"閱讀設置",settingsShort:"設置",closeSettings:"收起設置",groupText:"文字",groupMark:"標註",groupLayout:"版面",groupMore:"更多",font:"字體",fontSong:"宋體",fontKai:"楷體",fontSystem:"系統默認",script:"繁簡",version:"來源",versionShort:"來源▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最後一{unit}",toc:"目錄",images:"書影",fontSmaller:"縮小字號",fontLarger:"放大字號",paragraphTitle:"條目分行 ↔ 自然段",paragraph:"自然段",workLinks:"標出作品鏈接",properNameTitle:"書名加波浪線",properName:"專名線",properNameOff:"不顯示",properNameLite:"精簡",properNameFull:"完整",properNameLiteTitle:"只標人名、地名、朝代",showWorks:"標註書名",bookTitleStyle:"書名樣式",bookTitleWavy:"波浪線",bookTitleBracket:"書名號",scriptOrig:"原字",scriptOrigUnavailable:"此文本沒有規範層,無「原字」可選",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁體",scriptHans:"簡體",quoteStyle:"引號",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原樣",pageBreaks:"顯示分葉分割線",pageIndicator:"頁指示頭(上下鍵調整位置)",preserveMargins:"書影保留空白",facsimilePager:"書影翻頁",facsimilePageInput:"書影葉碼(輸入數字後按 Enter 或離開輸入框跳轉)",vertical:"豎排",closeToc:"收起目錄",sourceLabel:"出處",licenseOf:"授權 {license}",revisedAt:"最近校訂 {date}",reportError:"報告錯字",pagerNav:"翻卷",rail:"本卷",bottomBar:"閱讀工具",tocShort:"卷目",fontSize:"字號",close:"關閉",loading:"加載中…",noText:"暫無文本",tocFailed:"無法加載目錄",tocLoading:"加載目錄…",viewEntry:"查看條目",defaultRole:"撰",tocCaption:"目錄 · {n} {unit}",tocExpand:"展開",tocCollapse:"收起",searchChapters:"搜索全部章節",searchChaptersPlaceholder:"搜索全部章節…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"來源",originalSource:"本站獨立整理",charGuess:"殘字(推測)",figLabel:"圖形符號:{alt}",figPlain:"圖形符號",lacunaGuess:"闕文,推測為「{guess}」",upstream:"上游",chapterFailed:"無法加載章節內容",references:"參考文獻",entityDetail:"查看詳情 →"},{imagesLoading:"加载书影…",noImages:"暂无书影",noImagesHint:"这一卷还没有配上影像;接入后在此与正文逐页对看",imageAlt:"书影 第 {label} 页",prevImage:"上一页书影",nextImage:"下一页书影",back:"阅读",backAria:"返回{label}首页",skipToText:"跳到正文",settings:"阅读设置",settingsShort:"设置",closeSettings:"收起设置",groupText:"文字",groupMark:"标注",groupLayout:"版面",groupMore:"更多",font:"字体",fontSong:"宋体",fontKai:"楷体",fontSystem:"系统默认",script:"繁简",version:"来源",versionShort:"来源▾",unitJuan:"卷",pagerGroup:"翻{unit}",prevUnit:"上一{unit}",nextUnit:"下一{unit}",prevUnitTitle:"上一{unit}:{label}",nextUnitTitle:"下一{unit}:{label}",firstUnit:"已是第一{unit}",lastUnit:"已是最后一{unit}",toc:"目录",images:"书影",fontSmaller:"缩小字号",fontLarger:"放大字号",paragraphTitle:"条目分行 ↔ 自然段",paragraph:"自然段",workLinks:"标出作品链接",properNameTitle:"书名加波浪线",properName:"专名线",properNameOff:"不显示",properNameLite:"精简",properNameFull:"完整",properNameLiteTitle:"只标人名、地名、朝代",showWorks:"标注书名",bookTitleStyle:"书名样式",bookTitleWavy:"波浪线",bookTitleBracket:"书名号",scriptOrig:"原字",scriptOrigUnavailable:"此文本没有规范层,无「原字」可选",scriptOrigShort:"原",scriptQuick:"字形",scriptHant:"通行繁体",scriptHans:"简体",quoteStyle:"引号",quoteModern:"“”‘’",quoteClassic:"「」『』",quoteOriginal:"原样",pageBreaks:"显示分叶分割线",pageIndicator:"页指示头(上下键调整位置)",preserveMargins:"书影保留空白",facsimilePager:"书影翻页",facsimilePageInput:"书影叶码(输入数字后按 Enter 或离开输入框跳转)",vertical:"竖排",closeToc:"收起目录",sourceLabel:"出处",licenseOf:"授权 {license}",revisedAt:"最近校订 {date}",reportError:"报告错字",pagerNav:"翻卷",rail:"本卷",bottomBar:"阅读工具",tocShort:"卷目",fontSize:"字号",close:"关闭",loading:"加载中…",noText:"暂无文本",tocFailed:"无法加载目录",tocLoading:"加载目录…",viewEntry:"查看条目",defaultRole:"撰",tocCaption:"目录 · {n} {unit}",tocExpand:"展开",tocCollapse:"收起",searchChapters:"搜索全部章节",searchChaptersPlaceholder:"搜索全部章节…",searchUnit:"搜索全部{unit}",searchUnitPlaceholder:"搜索全部{unit}…",textSource:"来源",originalSource:"本站独立整理",charGuess:"残字(推测)",figLabel:"图形符号:{alt}",figPlain:"图形符号",lacunaGuess:"阙文,推测为「{guess}」",upstream:"上游",chapterFailed:"无法加载章节内容",references:"参考文献",entityDetail:"查看详情 →"}),sm=St({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:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暫無正文",placeholder:"占位"},qualityCriteria:{source:"照錄來源原文,本站未另行校對",ocr:"保持大意和結構,錯誤率在百分之十以內",rough:"保證文意基本正確,錯誤率在百分之三以內",fine:"通讀無障礙,錯誤率在百分之一以內",none:"質量未評定",placeholder:"占位條目,正文尚未錄入"},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:{source:"底本",ocr:"OCR",rough:"粗校",fine:"精校",none:"暂无正文",placeholder:"占位"},qualityCriteria:{source:"照录来源原文,本站未另行校对",ocr:"保持大意和结构,错误率在百分之十以内",rough:"保证文意基本正确,错误率在百分之三以内",fine:"通读无障碍,错误率在百分之一以内",none:"质量未评定",placeholder:"占位条目,正文尚未录入"},originalSource:"原文来源",viewsGroup:"看法",viewText:"正文",viewEntries:"条目",rowHeadNo:"序",rowHeadTitle:"书名",rowHeadWork:"作品",railCap:"本卷",railUnitPoems:"首",railUnitBooks:"部书",linkedN:"已关联 {n}",linkedOf:"已关联 {n} / {total}",railEntriesNav:"本卷条目"}),am=St({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:"古籍元數據以 CC BY-SA 4.0 發布,可自由複製、改編、再發布,但須註明出處,並以相同方式共享。",repo:"數據倉庫:",repoNote:"(GitHub,CC BY-SA 4.0)",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:"古籍元数据以 CC BY-SA 4.0 发布,可自由复制、改编、再发布,但须注明出处,并以相同方式共享。",repo:"数据仓库:",repoNote:"(GitHub,CC BY-SA 4.0)",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=St({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:"按作者浏览全部 →"}),lm=St({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} 条"}),cm=St({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:"搜索"}),dm=St({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:"回复"}),pm=St({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:"有争议"}}),um={common:em,detail:Hi,bookPage:tm,workPage:nm,collectionPage:im,entityPage:rm,reader:om,collated:sm,metaHome:am,readHome:$o,catalogPage:lm,searchPage:cm,feedback:dm,lineage:pm};function mm(e){const n={};for(const[i,o]of Object.entries(um))n[i]=o[e];return n}function zt(e,n){return e.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}const na=new Map;function Rn(e){let n=na.get(e);return n||(n={...e==="zh-Hans"?Qu:Ju,...mm(e)},na.set(e,n)),n}function ia(e,n){let i=e;for(const o of n.split(".")){if(i==null||typeof i!="object")return;i=i[o]}return typeof i=="string"?i:void 0}function Kl(e){return(n,i)=>{const o=ia(e,n)??ia(Rn("zh-Hant"),n)??n;return i?zt(o,i):o}}const ra=new Map;function In(e){let n=ra.get(e);return n||(n=Kl(Rn(e)),ra.set(e,n)),n}const ql="bim-locale";function gm(){try{const e=localStorage.getItem(ql);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function fm(e){try{localStorage.setItem(ql,e)}catch{}}const hm="zh-Hans",xm=({locale:e,onLocaleChange:n,converter:i,children:o})=>{const[s,a]=f.useState(e??hm),l=e??s;f.useEffect(()=>{if(e)return;const g=gm();g&&g!==s&&a(g)},[]);const d=f.useMemo(()=>l==="zh-Hans"?i??Yl():null,[l,i]),c=f.useCallback(g=>{a(g),fm(g),n==null||n(g)},[n]),p=f.useMemo(()=>({locale:l,setLocale:c,messages:Rn(l),converter:d}),[l,c,d]);return t.jsx(Ot.Provider,{value:p,children:o})};function Be(){const e=f.useContext(Ot);return(e==null?void 0:e.messages)??Rn("zh-Hant")}const bm=2e3;function Ve(){const e=f.useContext(Ot),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,o=f.useRef(new Map),s=f.useRef(n),a=f.useRef(i);(s.current!==n||a.current!==i)&&(o.current.clear(),s.current=n,a.current=i);const l=f.useCallback(d=>{if(!d)return"";if(!i)return d;const c=o.current.get(d);if(c!==void 0)return c;const p=i(d);if(o.current.size>=bm){const g=o.current.keys().next().value;g!==void 0&&o.current.delete(g)}return o.current.set(d,p),p},[i]);return f.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function ae(){const e=f.useContext(Ot),{convert:n,locale:i,isSimplified:o}=Ve(),s=(e==null?void 0:e.messages)??Rn("zh-Hant"),a=f.useMemo(()=>e?Kl(s):In("zh-Hant"),[e,s]);return f.useMemo(()=>({t:a,convert:n,locale:i,isSimplified:o,messages:s}),[a,n,i,o,s])}const Xl=["錄說語詞議樣書記類傳國經補藝紀編後與間條號為開總種無數據冊頁選時題爲詩萬證學續關東圖資歷來讀館論見鈔別進師輯陳覽寫現應從","點兩華實對員長註結闕殘檢閱當會單換體將裡訂處過區釋術頭錢譯識個電動顯問這認質還幾遺雖須專擇係網運權務變發機請風聲輸軍導產","話們車難報讓業設帶辦紙氣麼際聽親場買賣謝費漢庫遷馬叢孫於張義晉閣維曆欽則夢慶齋録舊內陽樓紅淵歸載稱隱遼計評觀禮龜黃興節併","餘齊韓簡霑並樂諸滸屬組篩紹緒劉蘇誤職夾廣蓋敘斷歐寬駰極參試雜魯沒順線貞該測鮮統戰檔衛辭聯臺贊刪聖貫啟瀏譜薈寶約嘗諜謂舉詳","異賦軾復諒構級審標劃彙吳楊暫轉項寧硯蕭儀禪韻掃閉倉麗禎錯監鞏轍繫説筆竄縣聞諡賈僅擊羅宮訓談誌葉視戶細許祿繪鍵絕欄鑑講誕馮","趙習樹饋確賜裝擬規繼製薦畫鉛獨誠遠龍門覺訣隸軒諭繕塊爭鏡裏豐碼備掛堯錦駕鶴遊傷猶鄒瑩綴揚詔託僞頗竊虛莊歲禍爾辯獲篤窮盡跡","萊終穎訛瑣鐫繡廟幀佈躍雙預連狀態軸複懸遞灣箋頌訪層鏈敗達鈞鳳亂奮豈陰婁騎純優獻靈牆隨摺疊驗徑橫瀾蔣壞鈕盤範圍責減籤適側","榮聶頃縉讎銓廳軌厲鶚駢醫駝黨鐘諫樞滄軻溫贈鐵徵賴蹟潁閒顗歿駁歟勸諷誼湯詐脫羣尋澤擄顏釀謄鴻離騷傑滯憤執廢懼匱歎毀蠶獄寵闇","陸淺貨輕貧俠賤貴煩競樑鳩採綜謬鳴養堅韋顎呂蘭脈峯鵲兒賞籠階緊綱漁荊嬰慍潛營鎔繞陣塚億負卻塵懷閨擋撐縮領滾輪匯撈貼讚創險團","隊準礙強髒藥鮑顧給緯悅帳巖廬貢亞壇惡諱鎮薊驍愛討彌護揮偉輒擾況較響喪鑰藍"].join(""),ym=new Set([...Xl,...Object.keys(Re.VARIANT_CHARS),...Object.keys(Ol.VARIANT_SUPPLEMENT)]),Zl=[...Gl,"切換為繁體","漢籍リポジトリ"];function jm(e,n=Zl){let i=e;for(const a of n)a&&(i=i.split(a).join(" "));const o=[],s=Array.from(i);return s.forEach((a,l)=>{ym.has(a)&&o.push({char:a,context:s.slice(Math.max(0,l-8),l+9).join("")})}),o}function vm(e,n,i){return e?e==="orig"?null:n==="zh-Hans"?i??Yl():e==="hant"?Re.normalizeVariants:i:n==="zh-Hans"?i:Re.normalizeVariants}const km=({mode:e,children:n})=>{const i=f.useContext(Ot),o=f.useMemo(()=>i&&{...i,converter:vm(e,i.locale,i.converter)},[i,e]);return t.jsx(Ot.Provider,{value:o,children:n})};function wm(e){if(!e)return"";try{const n=new URL(e).hostname,i={"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(i[n])return i[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function oa(e){return e==="text+image"?["text","image"]:[e]}function sa(e){const n=Yt(e);return n.length===0?"text":qu(n)}function Sm(){return{id:"",name:"",url:"",types:["text"],details:""}}const Vr=({items:e,onChange:n,onDownload:i,downloadStatuses:o,filterType:s})=>{const a=Be(),[l,d]=f.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}],g=k=>{if(!s)return!0;const w=Yt(k);return s==="text"?w.includes("text"):s==="image"?w.includes("image")||w.includes("physical"):s==="physical"?w.includes("physical"):w.includes(s)},m=e.map((k,w)=>({item:k,originalIndex:w})).filter(({item:k})=>g(k)),u=()=>{const k=Sm();s&&(k.types=oa(s)),n([...e,k]),d(e.length)},h=k=>{n(e.filter((w,v)=>v!==k)),d(null)},x=(k,w,v)=>{const C=[...e];if(C[k]={...C[k],[w]:v},w==="url"&&!C[k].id){const _=wm(v);_&&(C[k].id=_)}n(C)},j=(k,w)=>{const v=[...e],{type:C,..._}=v[k];v[k]={..._,types:oa(w)},n(v)},b=(k,w,v)=>{const _={...e[k].metadata||{}};v?_[w]=v:delete _[w],x(k,"metadata",Object.keys(_).length>0?_:void 0)},S=(k,w)=>{const v=w.trim()?w.split(/[,,、]/).map(C=>C.trim()).filter(Boolean):void 0;x(k,"structure",v)},y=(k,w,v)=>{const _=e[k].coverage||{level:1,ranges:""};w==="level"?_.level=parseInt(v)||1:_.ranges=v,x(k,"coverage",_.ranges?_:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[m.map(({item:k,originalIndex:w})=>{var v,C,_;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>d(l===w?null:w),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:l===w?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:_m(sa(k)),color:r("on-color-fg")},children:(()=>{var A,R;const $=Yt(k);return $.length===0?"text":$.length===1?((A=c.find(z=>z.value===$[0]))==null?void 0:A.label)??$[0]:$.includes("text")&&$.includes("image")?((R=c.find(z=>z.value==="text+image"))==null?void 0:R.label)??"text+image":$.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:k.name||`${a.editor.resourcePlaceholder} ${w+1}`}),k.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:k.id}),k.url&&t.jsx("a",{href:k.url,target:"_blank",rel:"noopener noreferrer",onClick:$=>$.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&k.url&&$m(w,o==null?void 0:o[w],i,a),t.jsx("button",{onClick:$=>{$.stopPropagation(),h(w)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:a.editor.deleteThisResource,children:"✕"})]}),l===w&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:[Gu(k,"image")&&k.url&&Cm(k,a),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Fn,children:[t.jsx("span",{style:Hn,children:a.label.type}),t.jsx("select",{value:sa(k),onChange:$=>j(w,$.target.value),style:{...At,flex:1},children:c.map($=>t.jsx("option",{value:$.value,children:$.label},$.value))})]}),t.jsxs("label",{style:Fn,children:[t.jsx("span",{style:Hn,children:a.label.rootType}),t.jsx("select",{value:k.root_type||"catalog",onChange:$=>x(w,"root_type",$.target.value),style:{...At,flex:1},children:p.map($=>t.jsx("option",{value:$.value,children:$.label},$.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:k.id,onChange:$=>x(w,"id",$.target.value),placeholder:a.editor.idAutoExtract,style:{...At,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:k.name,onChange:$=>x(w,"name",$.target.value),placeholder:a.editor.resourceName,style:{...At,flex:1}})]}),t.jsx("input",{type:"text",value:k.url,onChange:$=>x(w,"url",$.target.value),placeholder:a.editor.resourceUrl,style:At}),t.jsx("input",{type:"text",value:((v=k.structure)==null?void 0:v.join("、"))||"",onChange:$=>S(w,$.target.value),placeholder:a.editor.structurePlaceholder,style:At}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Fn,children:[t.jsx("span",{style:Hn,children:a.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((C=k.coverage)==null?void 0:C.level)??"",onChange:$=>y(w,"level",$.target.value),placeholder:"1",style:{...At,width:"60px"}})]}),t.jsxs("label",{style:{...Fn,flex:1},children:[t.jsx("span",{style:Hn,children:a.label.coverageRange}),t.jsx("input",{type:"text",value:((_=k.coverage)==null?void 0:_.ranges)||"",onChange:$=>y(w,"ranges",$.target.value),placeholder:a.editor.coverageRangePlaceholder,style:{...At,flex:1}})]})]}),t.jsx("textarea",{value:k.details||"",onChange:$=>x(w,"details",$.target.value),placeholder:a.editor.detailsPlaceholder,style:{...At,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${r("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:r("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(([$,A])=>{var R;return t.jsxs("label",{style:{...Fn,gap:"4px"},children:[t.jsx("span",{style:{...Hn,minWidth:"56px"},children:A}),t.jsx("input",{type:"text",value:((R=k.metadata)==null?void 0:R[$])||"",onChange:z=>b(w,$,z.target.value),placeholder:A,style:{...At,flex:1}})]},$)})})]})]})]})]},w)}),t.jsxs("button",{onClick:u,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:a.action.addResource})]})]})};function _m(e){switch(e){case"text":return r("restype-text");case"image":return r("restype-image");case"text+image":return r("restype-text-image");case"physical":return r("restype-physical")}}function $m(e,n,i,o){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||i(e,"")},disabled:s,style:{background:"transparent",border:"none",color:r(a?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:a?o.download.completed:s?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:a?"✓":s?"⏳":"⬇"})}function Cm(e,n){const i=/\.(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:i?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:r("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:r("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:r("desc-fg")},children:n.editor.imageResourceLink})})}const At={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Fn={display:"flex",alignItems:"center",gap:"6px"},Hn={fontSize:"12px",color:r("desc-fg"),whiteSpace:"nowrap"},aa={text:r("restype-text"),image:r("restype-image"),"text+image":r("restype-text-image"),physical:r("restype-physical")};function zm(e){return e.includes("text")&&e.includes("image")?aa["text+image"]:aa[e[0]||"physical"]}const Co=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:o,renderLink:s})=>{const a=Be(),{convert:l}=Ve(),d=f.useMemo(()=>wo(e||[]),[e]),{mirrorGroups:c,ungroupedItems:p}=f.useMemo(()=>{const b=new Map,S=[];for(const y of d){const k=y.group;k?(b.has(k)||b.set(k,[]),b.get(k).push(y)):S.push(y)}for(const y of b.values())y.sort((k,w)=>{const v=C=>C.group_role==="origin"?0:C.group_role==="mirror"?1:2;return v(k)-v(w)});return{mirrorGroups:b,ungroupedItems:S}},[d]),g={text:a.resourceType.text,image:a.resourceType.image,"text+image":a.resourceType.textImage,physical:a.resourceType.physical},m=b=>g[b]?g[b]:b.split("+").map(S=>g[S]||S).join("+");if(!d||d.length===0)return t.jsx("div",{style:{padding:"16px",color:r("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((b,S)=>t.jsx(Sr,{item:b},b.id||S))});const u=(b,S)=>{const y=i==null?void 0:i[b],k=(y==null?void 0:y.label)||b,w=y==null?void 0:y.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(k)}),w&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.5},children:l(w)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.map((v,C)=>t.jsx(Sr,{item:v,onNavigate:o,renderLink:s},v.id||C))})]},`group-${b}`)},h=new Map;for(const b of p){const S=ko(Yt(b));h.has(S)||h.set(S,[]),h.get(S).push(b)}const x=["text","image","text+image","physical"],j=[...x.filter(b=>h.has(b)),...[...h.keys()].filter(b=>!x.includes(b)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([b,S])=>u(b,S)),j.map(b=>{const S=h.get(b),y=zm(b.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:y,whiteSpace:"nowrap",flexShrink:0},children:m(b)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.map((k,w)=>t.jsx(Sr,{item:k,onNavigate:o,renderLink:s},k.id||w))})]},b)})]})},Nm={bw:{label:"",bg:r("colormode-bw-bg"),fg:r("colormode-bw-fg")},color:{label:"",bg:r("colormode-color-bg"),fg:r("colormode-color-fg")}},Sr=({item:e})=>{const n=Be(),{convert:i}=Ve(),[o,s]=f.useState(!1),a=f.useMemo(()=>(e.url?Nn(e.url):void 0)||i(e.name),[e.url,e.name,i]),l=f.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(x=>({...x,url:x.url||Ul(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,g=e.expected_volumes??(d?c+p:0),m=e.color_mode?{...Nm[e.color_mode],label:n.colorMode[e.color_mode]}:null,u=e.details&&!d?i(e.details):null,h={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",background:r("input-bg"),fontSize:"12px",color:r("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:h,children:[t.jsx("span",{style:{fontWeight:500},children:a}),m&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:m.bg,color:m.fg},children:m.label}),u&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:u}),d&&t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[c,"/",g,n.unit.volume,p>0&&t.jsx("span",{style:{color:r("missing-fg"),marginLeft:"3px"},children:zt(n.common.volumesMissing,{n:p})})]}),e.url&&t.jsx("a",{href:(()=>{const x=So(e.metadata);return x?_o(e.url,x):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:r("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),d&&t.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),d&&o&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${r("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:l.map(x=>{const j=x.status==="missing";return x.url&&!j?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 ${r("widget-border")}`,color:r("link-fg"),textDecoration:"none"},children:x.volume},x.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:r(j?"missing-fg":"desc-fg"),textDecoration:j?"line-through":"none",opacity:j?.6:1},children:x.volume},x.volume)})})]})},Jl=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:a,onSelectFolder:l})=>{const d=Be(),c=e==="local",p=(n==null?void 0:n.isDraft)??!0,g=(n==null?void 0:n.repoPath)||"",m=g?g.split(/[/\\]/).pop()||g:"",u={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:r("primary-soft"),color:r("primary")},h={onMouseOver:j=>j.currentTarget.style.opacity="0.8",onMouseOut:j=>j.currentTarget.style.opacity="1"},x=t.jsxs("div",{onClick:s,title:p?d.mode.switchToOfficial:d.mode.switchToDraft,style:{...u,background:r(p?"warning":"success"),color:r("on-color-fg")},...h,children:[t.jsx("span",{children:p?"📝":"📚"}),t.jsx("span",{children:p?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,t.jsxs("div",{onClick:o,title:d.mode.switchToSync,style:u,...h,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:g||d.mode.selectFolder,style:{...u,paddingLeft:"8px",paddingRight:"8px"},...h,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:o,title:d.mode.switchToLocal,style:u,...h,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:d.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:a,title:m||d.mode.configurePath,style:{...u,background:"transparent",padding:"6px",fontSize:"12px"},...h,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:o,title:c?d.mode.switchToGithub:d.mode.switchToLocal,style:u,...h,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:g||d.mode.selectFolder,style:{...u,paddingLeft:"8px",paddingRight:"8px",minWidth:g?"100px":"auto",justifyContent:"space-between"},...h,children:[t.jsx("span",{children:"📂"}),m&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:m})]}),!c&&m&&t.jsxs("div",{style:{...u,background:r("mode-active-bg"),color:r("on-color-fg"),cursor:"default"},title:g,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:m})]})]})},Di="bim-search-history",la=10,ca=8;function qn(){try{const e=localStorage.getItem(Di);return e?JSON.parse(e):[]}catch{return[]}}function Ql(e){try{const n=qn().filter(i=>i!==e);n.unshift(e),n.length>la&&(n.length=la),localStorage.setItem(Di,JSON.stringify(n))}catch{}}function Tm(e){try{const n=qn().filter(i=>i!==e);localStorage.setItem(Di,JSON.stringify(n))}catch{}}function Rm(){try{localStorage.removeItem(Di)}catch{}}const ec=({transport:e,value:n,onChange:i,onSearch:o,onEntrySelect:s,placeholder:a})=>{const l=Be(),d=a??l.search.placeholder,c={work:l.indexType.work,book:l.indexType.book,collection:l.indexType.collection,entity:l.indexType.entity},[p,g]=f.useState(!1),[m,u]=f.useState([]),[h,x]=f.useState(-1),[j,b]=f.useState(qn),S=f.useRef(null),y=f.useRef(null),k=f.useRef(null),w=f.useRef(!1);f.useEffect(()=>{x(-1);const z=n.trim();if(!z){u(j.map(O=>({type:"history",text:O})));return}if(!e.searchAll){u([]);return}let N=!1;const M=setTimeout(()=>{e.searchAll(z,ca).then(O=>{if(N)return;const L=[...O.works,...O.books,...O.collections,...O.entities??[]];u(L.slice(0,ca).map(D=>({type:"entry",text:D.title||D.id,entry:D})))}).catch(()=>{N||u([])})},80);return()=>{N=!0,clearTimeout(M)}},[n,j,e]),f.useEffect(()=>{const z=N=>{k.current&&!k.current.contains(N.target)&&g(!1)};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]),f.useEffect(()=>{const z=N=>{var M,O;if(N.key==="/"&&document.activeElement!==S.current){const L=(M=document.activeElement)==null?void 0:M.tagName;if(L==="INPUT"||L==="TEXTAREA"||L==="SELECT")return;N.preventDefault(),(O=S.current)==null||O.focus()}};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[]);const v=f.useCallback(z=>{z.trim()&&(Ql(z.trim()),b(qn())),o(z),g(!1)},[o]),C=f.useCallback(z=>{z.type==="history"?(i(z.text),v(z.text)):z.entry&&(s?(s(z.entry),g(!1)):(i(z.text),v(z.text)))},[i,v,s]),_=f.useCallback(z=>{if(!p||m.length===0){z.key==="Enter"&&v(n);return}switch(z.key){case"ArrowDown":z.preventDefault(),x(N=>(N+1)%m.length);break;case"ArrowUp":z.preventDefault(),x(N=>(N-1+m.length)%m.length);break;case"Enter":z.preventDefault(),h>=0&&h<m.length?C(m[h]):v(n);break;case"Escape":z.preventDefault(),g(!1);break}},[p,m,h,n,v,C]),$=f.useCallback((z,N)=>{N.stopPropagation(),Tm(z),b(qn()),u(M=>M.filter(O=>!(O.type==="history"&&O.text===z)))},[]),A=f.useCallback(z=>{z.stopPropagation(),Rm(),b([]),u([])},[]);f.useEffect(()=>{if(h>=0&&y.current){const z=y.current.children;z[h]&&z[h].scrollIntoView({block:"nearest"})}},[h]);const R=!n.trim()&&j.length>0;return t.jsxs("div",{ref:k,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:S,type:"text",placeholder:d,value:n,onChange:z=>{i(z.target.value),g(!0)},onCompositionStart:()=>{w.current=!0},onCompositionEnd:()=>{w.current=!1},onFocus:()=>{g(!0)},onKeyDown:_,style:{width:"100%",padding:"8px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),p&&m.length>0&&t.jsxs("div",{ref:y,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:r("input-bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"6px",boxShadow:r("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[R&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:r("desc-fg"),borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("span",{children:l.search.history}),t.jsx("button",{onClick:A,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:l.search.clearAll})]}),m.map((z,N)=>t.jsxs("div",{onClick:()=>C(z),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:r("fg"),background:N===h?r("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:r("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:M=>$(z.text,M),style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:l.action.remove,children:"×"})]},`${z.type}-${z.text}-${N}`))]})]})},En=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:r(`type-${e}`),verticalAlign:"middle"}}),tc=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Im={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function ft(e){return Im[e]??e}const _n=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],$n={熹平: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},nc={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function Ui(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const i=parseInt(n[1],10);if(i<100||i>2100)return;const o=n[2]?parseInt(n[2],10):void 0;return{from:i,to:o!=null&&o>=i&&o<=2100?o:void 0}}function Em(e){return e>=1950?"":e>=1912?"民國":e>=1645?"清":e>=1368?"明":e>=1279?"元":e>=960?"宋":e>=907?"五代":e>=618?"唐":e>=581?"隋":e>=420?"南北朝":e>=265?"晉":e>=220?"三國":e>=-202?"漢":""}const Lm=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,da={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function zo(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(da))if(n.startsWith(s))return da[s];const i=ft(n);if(cn[i]!=null)return i;const o=Gt(n);if(o&&n.length<=o.length+1)return ft(o)}function ln(e,n){if(n){const i=nc[`${n}|${e}`];if(i!=null)return i}return $n[e]}const Am=1911;function Mm(e){const n=$n[e];if(n==null)return;const i=Bt[e];let o;for(const[s,a]of Object.entries($n))Bt[s]===i&&a>n&&(o==null||a<o)&&(o=a);return o!=null?o-1:void 0}const Pm={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function Li(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,i=0,o=!1;for(const a of e){const l=Pm[a];if(l===void 0)return;o=!0,a==="十"?i=(i||1)*10:a==="廿"||a==="卅"?(n+=l,i=0):i>=10?(n+=i+l,i=0):i=i*10+l}const s=n+i;return o&&s>0?s:void 0}function Gt(e){for(const n of tc)if(e.startsWith(n))return n}const Bt={};{const e=(n,i)=>{for(const o of i)Bt[o]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function dn(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const o of Object.keys($n))if(e.includes(o)&&!(i&&Bt[o]&&Bt[o]!==i&&nc[`${i}|${o}`]==null))return o}function ii(e){var l,d,c;const n={era:"",reign:"",source:"none"},i=e.dating;if(i!=null&&i.era||i!=null&&i.reign)return{era:i.era??"",reign:i.reign??"",source:i.certainty==="attested"?"catalog":"edition"};const o=(l=e.lineage)==null?void 0:l.year_text;if(o){const p=Gt(o)??"";return{era:ft(p),reign:dn(o,p)??"",source:"lineage"}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const p=Ui(s);if(p)return{era:Em(p.from),reign:"",source:"publication"};const g=Gt(s)??zo(s)??((c=_n.find(h=>h.pattern.test(s)))==null?void 0:c.era)??"",m=dn(s,g)??"",u=g||(m?Bt[m]??"":"");if(u||m)return{era:ft(u),reign:m,source:"publication"}}const a=e.edition||e.title||"";if(a){const p=Gt(a);if(p)return{era:ft(p),reign:dn(a,p)??"",source:"edition"};const g=_n.find(m=>m.pattern.test(a));if(g)return{era:ft(g.era),reign:dn(a,g.era)??g.reign??"",source:"edition"}}return n}function Vi(e){var o,s,a,l,d,c,p,g,m;if(((o=e.dating)==null?void 0:o.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 u=Ui(n);if(u)return u.from}const i=[(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 u of i){const h=((c=e.publication_info)==null?void 0:c.year)||((p=e.lineage)==null?void 0:p.year_text);if(h&&u!==h&&(Gt(h)||zo(h)))break;const x=u.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??u.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(x){const k=parseInt(x[1],10);if(k>=100&&k<=2100)return k}const j=u.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(j){const k=Gt(u);if(!k||ft(k)==="民國"){const v=Li(j[1]);if(v!=null&&v>=1&&v<=120)return Am+v}}const b=Gt(u)??((g=_n.find(k=>k.pattern.test(u)))==null?void 0:g.era),S=b?ft(b):void 0,y=dn(u,S)??(Gt(u)||(m=_n.find(k=>k.pattern.test(u)))==null?void 0:m.reign);if(y){const k=ln(y,S);if(k==null)continue;const w=u.indexOf(y),v=w>=0?u.slice(w+y.length):"",C=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),_=C?Li(C[1]):void 0;return k+(_?_-1:0)}}}function No(e){var l,d,c,p,g,m;const n=(l=e.dating)==null?void 0:l.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(d=e.lineage)==null?void 0:d.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const o=(c=e.lineage)==null?void 0:c.year_text;if(o){const u=o.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(u){const h=Gr[ft(u[1])],x=cn[ft(u[2])];if(h!=null&&x!=null)return{from:Math.min(h,x)-20,to:Math.max(h,x)+40}}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const u=Ui(s);if((u==null?void 0:u.to)!=null)return{from:u.from,to:u.to};const h=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(h){const x=Gr[ft(h[1])],j=cn[ft(h[2])];if(x!=null&&j!=null)return{from:Math.min(x,j)-20,to:Math.max(x,j)+40}}}const a=[(g=e.publication_info)==null?void 0:g.year,e.edition,e.title].filter(Boolean);for(const u of a){if(!/[間间]/.test(u))continue;const h=Gt(u)??zo(u)??((m=_n.find(b=>b.pattern.test(u)))==null?void 0:m.era),x=h?ft(h):void 0,j=[];for(const b of Object.keys($n))u.includes(b)&&(x&&Bt[b]&&Bt[b]!==x||ln(b,x)!=null&&j.push(b));if(j.length===0){const b=u.match(/([一-鿿])([一-鿿])[間间]/);if(b&&x){for(const S of[b[1],b[2]])for(const y of Object.keys($n))if(Bt[y]===x&&!(y[0]!==S&&y[y.length-1]!==S)&&ln(y,x)!=null){j.push(y);break}}}if(j.length>0){const b=j.map(w=>ln(w,x)).filter(w=>w!=null),S=Math.min(...b),y=j.reduce((w,v)=>ln(w,x)>=ln(v,x)?w:v),k=Mm(y)??_r(x??"")??Math.max(...b);return{from:S,to:k>S?k:_r(x??Bt[y]??"")??S}}if(x&&cn[x]!=null)return{from:cn[x],to:_r(x)??cn[x]}}}const cn={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Bm=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Om=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,pa=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function ua(e,n){for(const i of tc){const o=e.indexOf(i);if(o<0)continue;if(i.length===1){const c=e[o+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!dn(e.slice(o),ft(i)))continue}const s=ft(i);if(s===n)continue;const a=e.slice(o),l=dn(a,s)??"";let d;if(l){const c=ln(l,s);if(c!=null){const g=a.slice(a.indexOf(l)+l.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),m=g?Li(g[1]):void 0;d=c+(m?m-1:0)}}return{era:s,reign:l,year:d}}for(const i of _n)if(i.pattern.test(e))return{era:ft(i.era),reign:i.reign??""}}function Wm(e){var S,y,k,w,v;const n=ii(e),i=((S=e.publication_info)==null?void 0:S.year)??"",o=i?Ui(i):void 0;if(!n.era&&!n.reign&&!o)return;const s=e.edition||e.title||"",a=/[間间]/.test(s),l=((y=e.lineage)==null?void 0:y.year_text)??"",d=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(l),c=n.source==="publication"&&Lm.test(i),p=n.source==="publication"&&/[間间]/.test(i),g=l.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let m;a||d||c||p?m=void 0:g?m=parseInt(g[2],10):m=Vi(e);const u=m==null?No(e):void 0;let h;n.source==="publication"&&(c||pa.test(i))?h="uncertain":n.source==="lineage"||n.source==="publication"?h="attested":pa.test(s)||!n.reign&&m==null?h="uncertain":h="inferred";const x=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((k=e.lineage)==null?void 0:k.year_text)??((w=e.lineage)==null?void 0:w.year)??""}」`:`出版著錄「${((v=e.publication_info)==null?void 0:v.year)??""}」`,j={era:n.era,reign:n.reign,year:m,yearRange:u,certainty:h,source:n.source==="edition"?"edition":"catalog",basis:x};if(g){const C=l.match(/[、,,]\s*([宋元明清])/);C&&C[1]!==j.era&&(j.laterRepair={era:C[1]})}if(!j.laterRepair&&Om.test(s)){const C=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);C&&C[1]!==n.era&&(j.laterRepair={era:C[1]})}const b=Bm.find(C=>C.re.test(s));if(b){const C=s.search(b.re),_=s.slice(C),$=ua(_,n.era)??ua(s,n.era);$&&(j.basedOn={era:$.era,reign:$.reign,year:$.year,relation:b.relation})}return j}const Gr={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function _r(e){return Gr[e]}function Ai(e){const n=Vi(e);if(n!=null)return n;const i=No(e);if(i)return i.from;const o=ii(e).era;return o?cn[o]:void 0}const ma=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Yr(e){const n=ma.indexOf(e);return n===-1?ma.length:n}function Fm(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 i=[],o=(s,a)=>{n[s].length&&i.push({key:s,labelKey:a,items:n[s]})};return o("belongsTo","belongsToWork"),o("collected","collectedIn"),o("contains","containedWorks"),o("derivative","derivativeWorks"),o("studies","studies"),o("related","relatedWorks"),i}function To(e,n){const i=wo(e||[]),o=new Map,s=[];for(const p of i)p.group?(o.has(p.group)||o.set(p.group,[]),o.get(p.group).push(p)):s.push(p);for(const p of o.values())p.sort((g,m)=>{const u=h=>h.group_role==="origin"?0:h.group_role==="mirror"?1:2;return u(g)-u(m)});const a={text:[],image:[],textImage:[],physical:[]};for(const p of s){const g=Yt(p),m=g.includes("text"),u=g.includes("image");m&&u?a.textImage.push(p):m?a.text.push(p):u?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=[...o.entries()].map(([p,g])=>{var m,u;return{key:p,label:((m=n==null?void 0:n[p])==null?void 0:m.label)||p,description:(u=n==null?void 0:n[p])==null?void 0:u.description,items:g}});return{buckets:d,mirrors:c,total:i.length}}function Gi(e,n=In("zh-Hant")){const i=[],o=e.metadata||{};o.edition&&i.push(String(o.edition)),e.source_label&&i.push(e.source_label),e.details&&i.push(e.details);const s=Fi(e);return s&&s.expected>0&&i.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})),o.version&&i.push(String(o.version)),i.join(" · ")}function ic(e,n){if(Gi(e)||n.filter(o=>o.name===e.name).length<2)return"";try{const o=new URL(e.url),s=o.searchParams.get("res")||o.searchParams.get("id");if(s)return s;const a=o.pathname.split("/").filter(Boolean).pop();if(a)return decodeURIComponent(a)}catch{}return""}const Hm="同版";function Dm(e){const n=e==null?void 0:e.metadata;return((n==null?void 0:n.item_id)||(n==null?void 0:n.call_number)||"").trim()||void 0}function Um(e){var n;for(const i of((n=e.lineage)==null?void 0:n.related_to)??[]){const o=i.ref??i.book_id;if(i.relation===Hm&&o&&o!==e.id)return o}}function Vm(e){const n=new Map(e.map(a=>[a.id,a])),i=a=>{const l=n.get(a);return!!l&&!l.copyOf},o=new Map;for(const a of e)if(a.copyOf&&i(a.copyOf)){const l=o.get(a.copyOf)??[];l.push(a),o.set(a.copyOf,l)}if(o.size===0)return e;const s=[];for(const a of e){if(a.copyOf&&i(a.copyOf))continue;const l=o.get(a.id);if(!l){s.push(a);continue}const d=[...l].sort((c,p)=>(c.callNumber??c.id).localeCompare(p.callNumber??p.id));s.push({...a,copies:d,hasImage:a.hasImage||d.some(c=>c.hasImage)})}return s}function rc(e,n){var a,l;const i=e.resources||[],o=[],s=[];for(const d of i){const c=Yt(d);c.includes("image")&&o.push(d),c.includes("physical")&&s.push(d)}return{id:e.id,name:e.edition||e.title||e.id,era:ii(e),year:Vi(e),sortYear:Ai(e),images:o,holders:s,locationName:(a=e.current_location)==null?void 0:a.name,callNumber:Dm(s[0]),copyOf:Um(e),summary:e.summary,important:Gm(e.id,n),group:(l=n==null?void 0:n.node_groups)==null?void 0:l[e.id],hasImage:o.length>0}}function Gm(e,n){var d,c;if(!n)return!1;const i=n.default_collection;if(!i)return!1;const o=(d=n.collections)==null?void 0:d[i];if(((o==null?void 0:o.book_ids)??(i==="core"?n.core_books??[]:[])).includes(e))return!0;const a=(o==null?void 0:o.groups)??[],l=(c=n.node_groups)==null?void 0:c[e];return!!l&&a.includes(l)}function oc(e,n,i={}){const o=new Set((n==null?void 0:n.excluded_books)??[]),s=Vm(e.filter(c=>!o.has(c.id)).map(c=>rc(c,n)));let a=s;i.era&&(a=a.filter(c=>c.era.era===i.era)),i.scanOnly&&(a=a.filter(c=>c.hasImage)),i.sort==="year"?a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const g=c.r.sortYear,m=p.r.sortYear;return g!=null&&m!=null?g-m||c.i-p.i:g!=null?-1:m!=null?1:c.i-p.i}).map(c=>c.r):a=a.map((c,p)=>({r:c,i:p})).sort((c,p)=>{const g=m=>(m.important?0:1)*2+(m.hasImage?0:1);return g(c.r)-g(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)=>Yr(c)-Yr(p));return{rows:a,allRows:s,eras:d,hasInferredEra:s.some(c=>c.era.source==="edition")}}function Ym(e,n){var b,S;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(b=n.collections)==null?void 0:b[n.default_collection],o=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],a=o.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(o),c=new Set([...s,...l]),p=y=>{if(c.has(y))return!0;const k=n.node_groups[y];return k!=null&&d.has(k)},g=[],m=new Map,u=[];for(const y of e)if(!((S=n.excluded_books)!=null&&S.includes(y)))if(p(y))g.push(y);else{const k=n.node_groups[y];k?(m.has(k)||m.set(k,[]),m.get(k).push(y)):u.push(y)}if(u.length+[...m.values()].reduce((y,k)=>y+k.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const x=new Map((n.groups??[]).map(y=>[y.id,y])),j=[...m.entries()].map(([y,k])=>{const w=x.get(y);return{id:y,label:(w==null?void 0:w.label)??y,description:w==null?void 0:w.description,ids:k}});return u.length>0&&j.push({id:"__other__",label:"其他版本",description:void 0,ids:u}),{useGrouping:!0,coreIds:g,groupedIds:j}}const sc=["撰","編","注","校","譯","繪","其他"],Km=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function Ro(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n)return"撰";for(const{cls:i,re:o}of Km)if(o.test(n))return i;return"其他"}function Io(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function ac(e,n="全部"){const i=new Map;for(const s of e){const a=Ro(s);i.set(a,(i.get(a)??0)+1)}const o=[{cls:"全部",label:n,count:e.length}];for(const s of sc){const a=i.get(s);a&&o.push({cls:s,label:s,count:a})}return o.length>2?o:[]}function Eo(e){return(e._books??[]).map(n=>n.id).filter(n=>typeof n=="string")}function Lo(e){const n=e._classifications??[],i=n.find(o=>o.scheme==="zongmu")??n[0];if(i)return{l1:i.l1??"",l2:i.l2??"",l3:i.l3??"",l4:i.l4??"",...i.source?{source:i.source}:{}}}function lc(e){const n=e._members??[],i=typeof e._member_count=="number"?e._member_count:n.length;return{works:n.filter(o=>o.t==="work").map(o=>({id:o.id,title:o.title??"",volumes:Xn(o.vol)})),bookIds:n.filter(o=>o.t!=="work").map(o=>o.id).filter(o=>typeof o=="string"),total:i,truncated:i>n.length}}function qm(e){var n;return(e==null?void 0:e._member_count)||((n=e==null?void 0:e._members)==null?void 0:n.length)||0}function cc(e,n,i){if(n&&n.books&&n.books.length>0){const l=n.books.map(c=>({id:c.work_id||c.book_id||void 0,title:c.title,section:c.section,volumes:c.volumes||[],subItems:c.sub_items,edition:c.edition,found:c.found_volumes,expected:c.expected_volumes})),d=[...new Set(l.map(c=>c.section).filter(Boolean))];return{rows:l,source:"catalog",sections:d,totalVolumes:n.total_volumes}}const{works:o,bookIds:s}=lc(e);return o.length>0?{rows:o.map(d=>({id:d.id,title:d.title,volumes:d.volumes})),source:"works",sections:[]}:{rows:s.map(l=>{var d,c;return{id:l,title:((d=i==null?void 0:i.get(l))==null?void 0:d.title)||l,edition:(c=i==null?void 0:i.get(l))==null?void 0:c.edition,volumes:[]}}),source:"books",sections:[]}}function Xn(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[i,o]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,o-i+1)},(s,a)=>i+a)}return e.split(/[,、]/).map(i=>parseInt(i.trim())).filter(i=>!isNaN(i))}return[]}function Yi(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=[...e].sort((a,l)=>a-l),o=i[0],s=i[i.length-1];return s-o+1===i.length?`${o}–${s}`:i.length<=3?i.join(", "):`${o}–${s} (${i.length}${n})`}const Xm=["〇","一","二","三","四","五","六","七","八","九"],ga=["","十","百","千"];function Ln(e){if(!Number.isInteger(e)||e<=0)return"";if(e>=1e8)return String(e);if(e<1e4)return $r(e,!0);const n=Math.floor(e/1e4),i=e%1e4;let o=$r(n,!0)+"萬";return i>0&&(o+=(i<1e3?"〇":"")+$r(i,!1)),o}function $r(e,n){const i=String(e),o=i.length;let s="",a=!1;for(let l=0;l<o;l++){const d=parseInt(i[l]),c=o-1-l;d===0?a=!0:(a&&s&&(s+="〇"),a=!1,n&&d===1&&c===1&&l===0?s+=ga[c]:s+=Xm[d]+ga[c])}return s}function Zm(e){return e==null?"":typeof e=="string"?e:"name"in e&&e.name?e.name:"title"in e&&e.title||""}function Jm(e){if(e==null||typeof e=="string")return;const n="url"in e&&e.url?e.url:"type"in e&&e.type==="url"?e.details:void 0;return n&&/^https?:\/\//i.test(n)?n:void 0}function Kt(e,n="卷"){var o,s;const i=e;return i.measure_info?i.measure_info:(o=i.juan_count)!=null&&o.number?Ln(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function dc(e){var o;if(e.edition_type)return e.edition_type;if((o=e.lineage)!=null&&o.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/油印/,"油印本"],[/曬印|晒印/,"曬印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,a]of i)if(s.test(n))return a;return""}const Ki={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},pc=new Set(["work","book","entity"]);function Qm(e){return gc(e)||!!e.sort}function eg(e,n){return n.sort&&pc.has(e)?n.sort:void 0}const qi=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Xi=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],uc=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],mc={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function Zi(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 gc(e){return Zi(e)>0}function tg(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 fc(e,n){const i=mc[e];return tg(n).every(o=>i.has(o))}const Dn=e=>JSON.stringify(e);function ng(e,n){if(!fc(n,e))return null;const i=[];if(e.dynasty.length){const o=Array.from(new Set(e.dynasty.flatMap(s=>{var a;return((a=qi.find(l=>l.key===s))==null?void 0:a.values)??[]})));o.length===1?i.push(`dynasty = ${Dn(o[0])}`):o.length>1&&i.push(`dynasty IN [${o.map(Dn).join(", ")}]`)}return e.classification.length&&i.push(e.classification.length===1?`classification = ${Dn(e.classification[0])}`:`classification IN [${e.classification.map(Dn).join(", ")}]`),e.hasImage&&i.push("has_image = true"),e.hasText&&i.push("has_text = true"),e.hasCollated&&i.push("has_collated = true"),e.loss&&i.push(`loss_status = ${Dn(e.loss)}`),i.join(" AND ")}const yt={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},hc="_";function Mi(e,n=new URLSearchParams){for(const i of Object.values(yt))n.delete(i);return e.dynasty.length&&n.set(yt.dynasty,e.dynasty.join(",")),e.classification.length&&n.set(yt.classification,e.classification.map(i=>i||hc).join(",")),e.hasImage&&n.set(yt.hasImage,"1"),e.hasText&&n.set(yt.hasText,"1"),e.hasCollated&&n.set(yt.hasCollated,"1"),e.loss&&n.set(yt.loss,e.loss),e.sort&&n.set(yt.sort,e.sort),n}function ig(e){const n=a=>(e.get(a)??"").split(",").map(l=>l.trim()).filter(Boolean),i=new Set(qi.map(a=>a.key)),o=new Set(Xi.map(a=>a.value)),s=e.get(yt.loss);return{dynasty:Array.from(new Set(n(yt.dynasty).filter(a=>i.has(a)))),classification:Array.from(new Set(n(yt.classification).map(a=>a===hc?"":a).filter(a=>o.has(a)))),hasImage:e.get(yt.hasImage)==="1",hasText:e.get(yt.hasText)==="1"||e.get(yt.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(yt.sort))??""}}function rg(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 fa(e,n){return e.includes(n)?e.filter(i=>i!==n):[...e,n]}const og=({filters:e,onChange:n})=>{const i=Be(),o=i.searchV4,{convert:s}=Ve(),[a,l]=f.useState(!1),d=f.useId(),c=Zi(e),p=g=>n({...e,...g});return t.jsxs("aside",{className:"bim-sr-aside","aria-label":s(o.filterTitle),children:[t.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":a,"aria-controls":d,onClick:()=>l(g=>!g),children:[t.jsxs("span",{children:[s(o.filterButton),c>0&&t.jsx("span",{className:"bim-sr-fn",children:s(zt(o.filterSelected,{n:c}))})]}),t.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[s(a?o.collapse:o.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(o.dynasty)}),t.jsx("div",{className:"bim-sr-chips",children:qi.map(g=>t.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":e.dynasty.includes(g.key),onClick:()=>p({dynasty:fa(e.dynasty,g.key)}),children:s(g.key)},g.key))})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.classification)}),Xi.map(g=>t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.classification.includes(g.value),onChange:()=>p({classification:fa(e.classification,g.value)})}),g.value?s(g.label):i.searchPage.unclassified]},g.value||"_"))]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{children:s(o.resources)}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasImage,onChange:g=>p({hasImage:g.target.checked})}),s(o.hasImage)]}),t.jsxs("label",{className:"bim-sr-opt",children:[t.jsx("input",{type:"checkbox",checked:e.hasText,onChange:g=>p({hasText:g.target.checked})}),s(o.hasText)]})]}),t.jsxs("section",{className:"bim-sr-fg",children:[t.jsx("h3",{id:`${d}-loss`,children:s(o.extant)}),t.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${d}-loss`,children:uc.map(g=>t.jsx("button",{type:"button","aria-pressed":e.loss===g.value,onClick:()=>p({loss:g.value}),children:i.searchPage.loss[g.value||"all"]},g.value||"all"))})]}),c>0&&t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Ki,sort:e.sort}),children:s(o.clearAllFilters)})]})]})};function xc({text:e,query:n}){const i=(n??"").trim();if(!i||!e)return t.jsx(t.Fragment,{children:e});const o=e.toLowerCase(),s=i.toLowerCase(),a=[];let l=0,d=0;for(;l<e.length;){const c=o.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 ha=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Be(),a=s.searchV4,{convert:l}=Ve(),d=gt();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),g=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",m=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${l(c.author)}${c.role&&c.role!=="author"?` ${l(c.role)}`:""}`:"",u=c.type==="book"?c.era??c.dynasty:c.dynasty,h=u?l(u):"",x=c.classification?l(c.classification):"",j=[];c.has_image&&j.push({label:a.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&j.push({label:a.tagText,cls:""}),c.loss_status==="lost"&&j.push({label:a.tagLost,cls:"bim-sr-tag--lost"});const b=[m,h,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:S=>i(c,S),children:t.jsx(xc,{text:p,query:n?l(n):void 0})}),g&&t.jsx("span",{className:"bim-sr-measure",children:g})]}),b&&t.jsx("span",{className:"bim-sr-sub",children:b})]}),t.jsxs("td",{className:"bim-sr-c-type",children:[t.jsx(En,{type:c.type,size:6})," ",o(c.type)]}),t.jsx("td",{className:"bim-sr-c-who",children:m||"—"}),t.jsx("td",{className:"bim-sr-c-era",children:h||"—"}),t.jsx("td",{className:"bim-sr-c-cls",children:x||"—"}),t.jsx("td",{className:"bim-sr-c-res",children:j.map(S=>t.jsx("span",{className:`bim-sr-tag ${S.cls}`,children:l(S.label)},S.label))})]},c.id)})})]})})},sg=`
|
|
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 ${r("rule")}; background: ${r("card-bg")}; color: inherit; text-decoration: none; }
|
|
4
4
|
.bim-sc:hover { border-color: ${r("rule-dashed")}; box-shadow: ${r("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: ${r("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
|
+
`,xa=({entries:e,query:n,onEntryLinkClick:i,typeName:o})=>{const s=Be(),a=s.searchV4,{convert:l}=Ve(),d=gt();return t.jsxs("div",{className:"bim-sc-grid",children:[t.jsx("style",{children:sg}),e.map(c=>{const p=l(c.title||c.primary_name||c.id),g=c.measure_info?l(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",u=[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):"",g].filter(Boolean).join(" · "),h=[o(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:j=>i(c,j),children:[t.jsx("span",{className:"bim-sc-t",children:t.jsx(xc,{text:p,query:n?l(n):void 0})}),u&&t.jsx("span",{className:"bim-sc-m",children:u}),c.descriptionSnippet&&t.jsx("p",{className:"bim-sc-s",children:vo(c.descriptionSnippet).map((j,b)=>j.marked?t.jsx("mark",{children:l(j.text)},b):t.jsx(f.Fragment,{children:l(j.text)},b))}),t.jsx("span",{className:"bim-sc-sp"}),t.jsxs("div",{className:"bim-sc-f",children:[t.jsx("span",{className:"bim-sc-fl",children:h}),t.jsx("span",{className:"bim-sc-tags",children:x.map(j=>t.jsx("span",{className:`bim-sr-tag ${j.cls}`,children:l(j.label)},j.label))})]})]},c.id)})]})};function ag(e,n){const i=new Set([1,n,e-1,e,e+1].filter(a=>a>=1&&a<=n)),o=Array.from(i).sort((a,l)=>a-l),s=[];return o.forEach((a,l)=>{l>0&&a-o[l-1]>1&&s.push("gap"),s.push(a)}),s}function lg(e,n,i){const o=Math.max(1,Math.ceil(n/i));return Math.min(Math.max(1,e),o)}const cg=({page:e,pageSize:n,total:i,totalLabel:o,onPage:s})=>{const a=Be().searchV4,{convert:l}=Ve(),d=Math.max(1,Math.ceil(i/n));return i<=0?null:t.jsxs("nav",{className:"bim-sr-pager","aria-label":l(a.pagerLabel),children:[t.jsx("span",{className:"bim-sr-info",children:l(zt(a.pageInfo,{total:o??i.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)})}),ag(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)})})]})]})},bc="(max-width: 719px)",dg=`${bc}, (pointer: coarse)`,pg=`
|
|
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(${r("reader-top")} + 16px); padding-top: 2px; }
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
.bim-sr-pager .bim-sr-gap { color: ${r("aux-fg")}; padding: 0 2px; }
|
|
82
82
|
.bim-sr-empty { padding: 60px 0; text-align: center; font-size: 14px; color: ${r("meta-fg")}; }
|
|
83
83
|
|
|
84
|
-
@media ${
|
|
84
|
+
@media ${bc} {
|
|
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 ${dg} {
|
|
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: ${r("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
|
-
`,Eo="bim-search-view",_r=50,fa=5,Xn=1e3;function Si(e){return e>=Xn?`${Xn.toLocaleString()}+`:e.toLocaleString()}const cg={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function dg(e){return e&&cg[e.toLowerCase()]||"all"}function pg(e){return e==="all"?null:e}const ha=["work","collection","book","entity"],ug={work:"works",collection:"collections",book:"books",entity:"entities"},mg={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function gg(){try{return window.localStorage.getItem(Eo)==="card"?"card":"table"}catch{return"table"}}function fg(e){try{window.localStorage.setItem(Eo,e)}catch{}}const bn=(e,n)=>(e==null?void 0:e[mg[n]])??0,$r=(e,n)=>(e==null?void 0:e[ug[n]])??[],hc=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const g=We(),m=g.searchV4,{convert:u}=Ue(),h=!!e.supportsSearchFilters,x=f.useMemo(()=>h?i:Gi,[h,i]),[j,b]=f.useState("table");f.useEffect(()=>{b(gg())},[]);const $=H=>{b(H),fg(H)},[y,k]=f.useState(l??"all"),w=f.useRef(y);w.current=y,f.useEffect(()=>{l!==void 0&&l!==w.current&&(k(l),C(1))},[l]);const[v,C]=f.useState(c&&c>0?c:1),S=f.useRef(v);S.current=v,f.useEffect(()=>{c!==void 0&&c>0&&c!==S.current&&C(c)},[c]);const _=f.useRef(null),R=f.useCallback(H=>{var Ne;C(H),p==null||p(H);const Z=_.current;Z&&Z.getBoundingClientRect().top<0&&((Ne=Z.scrollIntoView)==null||Ne.call(Z,{block:"start",behavior:"instant"}))},[p]),[z,N]=f.useState(null),[I,B]=f.useState(null),[O,A]=f.useState(!1),[W,G]=f.useState(""),oe=Li(x).toString(),se=qi(x)>0,Y=Li({...x,sort:""}).toString(),de=f.useRef({query:n,filterOnlyKey:Y,sort:x.sort});f.useEffect(()=>{const H=de.current;H.query!==n||H.filterOnlyKey!==Y?(k("all"),C(1)):H.sort!==x.sort&&C(1),de.current={query:n,filterOnlyKey:Y,sort:x.sort}},[n,Y,x.sort]),f.useEffect(()=>{let H=!1;return A(!0),G(""),(async()=>{try{let Z;if(e.searchAll)Z=await e.searchAll(n,fa,x);else{const Ne=["work","book","collection","entity"],ze=await Promise.all(Ne.map(Fe=>e.search(n,Fe,{page:1,pageSize:fa,filters:x})));Z={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}}H||N(Z)}catch(Z){H||(G(Z instanceof Error?Z.message:String(Z)),N(null))}finally{H||A(!1)}})(),()=>{H=!0}},[e,n,oe]);const ne=y;f.useEffect(()=>{if(y==="all"){B(null);return}let H=!1;return A(!0),(async()=>{try{const Z=await e.search(n,y,{page:v,pageSize:_r,filters:x});H||B({key:ne,entries:Z.entries,total:Z.total})}catch(Z){H||(G(Z instanceof Error?Z.message:String(Z)),B(null))}finally{H||A(!1)}})(),()=>{H=!0}},[e,n,oe,y,v]);const ue=I&&I.key===ne?I:null;f.useEffect(()=>{if(y==="all"||!ue||O)return;const H=Math.min(ue.total,Xn),Z=og(v,H,_r);ue.entries.length===0&&H>0&&Z!==v&&(C(Z),p==null||p(Z))},[y,ue,O,v]);const ke=f.useMemo(()=>ha.filter(H=>bn(z,H)>0),[z]),Ae=ke.reduce((H,Z)=>H+bn(z,Z),0),he=ke.some(H=>bn(z,H)>=Xn)?`${Ae.toLocaleString()}+`:Ae.toLocaleString(),$e=!O&&!W&&z!==null&&Ae===0,L=f.useCallback(H=>{k(H),C(1),d==null||d(H)},[d]),Me=f.useMemo(()=>{const H=[];return x.dynasty.forEach(Z=>H.push({name:Z,remove:()=>o({...x,dynasty:x.dynasty.filter(Ne=>Ne!==Z)})})),x.classification.forEach(Z=>{var Ne;return H.push({name:Z?((Ne=Ki.find(ze=>ze.value===Z))==null?void 0:Ne.label)??Z:g.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(ze=>ze!==Z)})})}),x.hasImage&&H.push({name:m.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&H.push({name:m.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&H.push({name:m.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&H.push({name:`${m.extant}:${g.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),H},[x,o,m,g]),q={query:n,onEntryLinkClick:s,typeName:a},le=H=>j==="table"?t.jsx(ma,{entries:H,...q}):t.jsx(ga,{entries:H,...q}),ge=ha.flatMap(H=>$r(z,H));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":h?void 0:"true",children:[t.jsx("style",{children:lg}),h&&t.jsx(ng,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":O,ref:_,children:[ke.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":g.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs(xa,{on:y==="all",onClick:()=>L("all"),children:[g.search.allTab," ",t.jsx("small",{children:he})]}),ke.map(H=>t.jsxs(xa,{on:y===H,onClick:()=>L(H),children:[a(H)," ",t.jsx("small",{children:Si(bn(z,H))})]},H))]}),t.jsxs("div",{className:"bim-sr-tools",children:[h&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:u(m.sortRelevance)}),["era","title"].map(H=>{const Z=x.sort.startsWith(`${H}:`)?x.sort.endsWith("desc")?"desc":"asc":null,Ne=H==="era"?m.sortEra:m.sortTitle,ze=H==="era"?Z==="desc"?m.sortEraDesc:m.sortEraAsc:Z==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":Z!==null,title:u(ze),onClick:()=>o({...x,sort:`${H}:${Z==="asc"?"desc":"asc"}`}),children:[u(Ne),Z?t.jsxs("span",{"aria-hidden":"true",children:[" ",Z==="asc"?"↑":"↓"]}):null]},H)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":j==="table",onClick:()=>$("table"),children:u(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":j==="card",onClick:()=>$("card"),children:u(m.viewCard)})]})]}),se&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:u($t(m.filteredCount,{n:he}))}),Me.map(H=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u($t(m.removeFilter,{name:H.name})),onClick:H.remove,children:[u(H.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},H.name))]}),W&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:W}),$e&&t.jsx("div",{className:"bim-sr-empty",children:u(se?m.emptyFiltered:$t(g.search.noResultsFor,{query:n}))}),!W&&!$e&&y==="all"&&z&&(j==="table"?t.jsxs(t.Fragment,{children:[t.jsx(ma,{entries:ge,...q}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(m.limitedNote)})]}):t.jsx(t.Fragment,{children:ke.map(H=>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(In,{type:H,size:8}),a(H),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[Si(bn(z,H))," ",g.unit.items]})]}),bn(z,H)>$r(z,H).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>L(H),children:g.action.viewAll})]}),t.jsx(ga,{entries:$r(z,H),...q})]},H))})),!W&&y!=="all"&&!ue&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:g.search.loading}),!W&&y!=="all"&&ue&&ue.entries.length>0&&t.jsxs(t.Fragment,{children:[le(ue.entries),t.jsx(sg,{page:v,pageSize:_r,total:Math.min(ue.total,Xn),totalLabel:Si(ue.total),onPage:R})]}),!W&&y!=="all"&&ue&&ue.entries.length===0&&!O&&t.jsxs("div",{className:"bim-sr-empty",children:[u(se?m.emptyFiltered:$t(g.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>L("all"),children:g.search.allTab})})]})]})]})};function xa({on:e,onClick:n,children:i}){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:r(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${r("accent")}`:"none"},children:i})}const $n="bim-recent-ids",ba="bim-recent-entries",ya=50;function en(){try{const e=localStorage.getItem($n);if(e)return JSON.parse(e);const n=localStorage.getItem(ba);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem($n,JSON.stringify(i)),localStorage.removeItem(ba),i}return[]}catch{return[]}}function Gr(e){try{const n=en().filter(i=>i!==e);n.unshift(e),n.length>ya&&(n.length=ya),localStorage.setItem($n,JSON.stringify(n))}catch{}}function xc(e){try{const n=en().filter(i=>i!==e);localStorage.setItem($n,JSON.stringify(n))}catch{}}function Lo(){try{localStorage.removeItem($n)}catch{}}async function Ao(e,n){var i,o,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:(i=l==null?void 0:l[0])==null?void 0:i.name,dynasty:(o=l==null?void 0:l[0])==null?void 0:o.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 Cr=5,hg=50,xg=200,ja={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Yr=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:g="compact",renderEntry:m,initialQuery:u,onQueryChange:h,headerRight:x,reserveViewportHeight:j=!1,filtersEnabled:b=!1,filters:$=Gi,onFiltersChange:y,resultTab:k,onResultTabChange:w,resultPage:v,onResultPageChange:C})=>{const S=We(),_=[{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"}],R=["work","collection","book","entity"],[z,N]=f.useState(u??""),[I,B]=f.useState(null),[O,A]=f.useState(u??""),W=Li($).toString(),[G,oe]=f.useState($);f.useEffect(()=>{oe($)},[W]);const se=T=>{oe(T),y==null||y(T)},[Y,de]=f.useState(null),[ne,ue]=f.useState("all"),[ke,Ae]=f.useState(!1),[he,$e]=f.useState(null),[L,Me]=f.useState(""),[q,le]=f.useState(!(u!=null&&u.trim())),[ge,H]=f.useState(en),[Z,Ne]=f.useState([]),[ze,Fe]=f.useState(!1),[P,ie]=f.useState(!1),[Q,X]=f.useState(null),[we,He]=f.useState(null),Ke=f.useRef(void 0),Qe=f.useRef(!1),U=f.useCallback(async(T,fe)=>{if(!T.trim()){le(!0),B(null),de(null);return}if(le(!1),b){A(T);return}Ae(!0),Me("");try{if(e.searchAll){const be=await e.searchAll(T,fe??Cr);B(be)}else{const be=["work","book","collection","entity"],Le=await Promise.all(be.map(V=>e.search(T,V,{page:1,pageSize:fe??Cr})));B({works:Le[0].entries,books:Le[1].entries,collections:Le[2].entries,entities:Le[3].entries,totalWorks:Le[0].total,totalBooks:Le[1].total,totalCollections:Le[2].total,totalEntities:Le[3].total})}}catch(be){Me(be instanceof Error?be.message:String(be)),B(null)}finally{Ae(!1)}},[e,b]);f.useEffect(()=>{let T=!1;const fe=()=>{var J,Se;const be=["work","book","collection","entity"],Le=Promise.all(be.map(F=>e.loadEntries(F,{page:1,pageSize:1}).catch(()=>({total:0})))),V=((J=e.getResourceCounts)==null?void 0:J.call(e).catch(()=>null))??Promise.resolve(null),M=((Se=e.getSubtypeStats)==null?void 0:Se.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([Le,V,M]).then(([F,pe,ce])=>{T||(X({works:F[0].total,books:F[1].total,collections:F[2].total,entities:F[3].total,hasText:pe==null?void 0:pe.hasText,hasImage:pe==null?void 0:pe.hasImage}),ce&&He(ce))})};return e.getCounts?e.getCounts().then(be=>{var Le,V;T||(X({works:be.works,books:be.books,collections:be.collections,entities:be.entities,hasText:(Le=be.resourceCounts)==null?void 0:Le.hasText,hasImage:(V=be.resourceCounts)==null?void 0:V.hasImage}),be.subtypeStats&&He(be.subtypeStats))}).catch(()=>{T||fe()}):fe(),()=>{T=!0}},[e]),f.useEffect(()=>{Qe.current||!(u!=null&&u.trim())||(Qe.current=!0,U(u))},[u,U]);const me=f.useCallback(T=>{if(N(T),!T.trim()){h==null||h(T),le(!0),B(null),de(null),ue("all");return}Ke.current&&clearTimeout(Ke.current),Ke.current=setTimeout(()=>{de(null),ue("all"),h==null||h(T),U(T)},xg)},[U,h]),Re=f.useCallback(T=>{Ke.current&&clearTimeout(Ke.current),ue("all"),h==null||h(T),U(T)},[U,h]),D=f.useCallback(T=>{de(T),U(z,hg)},[z,U]);f.useEffect(()=>{if(!ge.length){Ne([]);return}let T=!1;return Fe(!0),Promise.all(ge.slice(0,10).map(fe=>Ao(e,fe))).then(fe=>{T||(Ne(fe),Fe(!1))}),()=>{T=!0}},[ge,e]);const je=T=>{$e(T.id),Gr(T.id),H(en()),o==null||o(T)},te=(T,fe)=>{if(o&&yg(fe)){fe.preventDefault(),je(T);return}Gr(T.id),H(en())},_e=T=>{xc(T),H(en())},Be=()=>{Lo(),H([])},Ge=T=>_.find(fe=>fe.type===T),Ye=!q&&!I&&!L,it=I&&(I.works.length>0||I.books.length>0||I.collections.length>0),st=t.jsxs(t.Fragment,{children:[t.jsx(Zl,{transport:e,value:z,onChange:me,onSearch:Re,onEntrySelect:je}),b&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const T=z.trim();T&&Xl(T),Re(z)},children:S.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${r("primary")}`,borderRadius:"6px",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"13px"},children:S.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:j?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:jg+(b?vg:"")}),(!b||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:r("fg")},children:S.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(ql,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),b?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:st})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:st}),q&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:Q&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:we?t.jsxs(t.Fragment,{children:[(we.book??0)>0&&t.jsxs(t.Fragment,{children:[S.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:we.book.toLocaleString()})," ",S.unit.bu,S.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:Q.books.toLocaleString()})," ",S.searchPage.statBookCopies]}),we.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:we.article.toLocaleString()})," ",S.searchPage.statArticleUnit]}):null,we.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:we.poem.toLocaleString()})," ",S.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:Q.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[S.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:Q.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:Q.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:Q.collections.toLocaleString()}),Q.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:Q.entities.toLocaleString()})]})]})}),Q.hasImage!=null&&Q.hasText!=null&&t.jsxs("span",{children:[S.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:Q.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),S.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:Q.hasText.toLocaleString()})]})]})}),b&&!q&&t.jsx(hc,{transport:e,query:O,filters:G,onFiltersChange:se,onEntryLinkClick:te,typeName:T=>Ge(T).name,tab:k,onTabChange:w,page:v,onPageChange:C}),!(b&&!q)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ke||Ye?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:bg,boxSizing:"border-box"},children:S.search.searching}):L?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:L})}):q?t.jsx("div",{style:{flex:1},children:ze?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:S.search.loading}):Z.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:S.search.recentBrowse}),t.jsx("button",{onClick:Be,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:S.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:Z.slice(0,P?10:3).map(T=>T.notFound?t.jsx(_g,{id:T.id,onRemove:_e,t:S},T.id):t.jsx(va,{entry:T,selected:he===T.id,onClick:te,getConfig:Ge,onRemove:_e},T.id))}),!P&&Z.length>3&&t.jsx("button",{onClick:()=>ie(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:r("primary"),background:"transparent",border:`1px solid ${r("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:r("fg")},children:S.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:S.search.searchSubtitle})]})}):it?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:kg}),(()=>{const T=M=>I[ja[M]]??0,fe=R.map(M=>_.find(J=>J.type===M)).filter(M=>T(M.key)>0);if(fe.length<2)return null;const be=fe.reduce((M,J)=>M+T(J.key),0),Le=M=>{if(ue(M),M!=="all"&&Y!==M){const J=_.find(F=>F.type===M),Se=(I[J.key]??[]).length;T(J.key)>Se&&D(M)}},V=M=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(M?"fg":"desc-fg"),fontWeight:M?700:400,boxShadow:M?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":S.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":ne==="all",style:V(ne==="all"),onClick:()=>Le("all"),children:[S.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:be.toLocaleString()})]}),fe.map(M=>t.jsxs("button",{type:"button","aria-pressed":ne===M.type,style:V(ne===M.type),onClick:()=>Le(M.type),children:[M.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:T(M.key).toLocaleString()})]},M.type))]})})(),_.map(({type:T,name:fe,key:be})=>{const Le=I[be]??[],V=ja[be],M=I[V]??0;if(Le.length===0||ne!=="all"&&ne!==T)return null;const Se=ne==="all"&&!(Y===T)&&M>Cr;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:[t.jsx(In,{type:T})," ",fe,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[M," ",S.unit.items]})]}),Se&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>D(T),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:S.action.viewAll})]}),t.jsx("div",{style:g==="list"?{display:"flex",flexDirection:"column",gap:0}:g==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:Le.map(F=>{if(m)return t.jsx(f.Fragment,{children:m(F)},F.id);const pe=g==="card"?Sg:va;return t.jsx(pe,{entry:F,selected:he===F.id,onClick:te,getConfig:Ge,query:z},F.id)})})]},T)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:$t(S.search.noResultsFor,{query:z})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:S.search.tryOther})]})})]})},bg=240;function yg(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const jg=`
|
|
120
|
+
`,Ao="bim-search-view",Cr=50,ba=5,Zn=1e3;function $i(e){return e>=Zn?`${Zn.toLocaleString()}+`:e.toLocaleString()}const ug={work:"work",works:"work",book:"book",books:"book",collection:"collection",collections:"collection",entity:"entity",entities:"entity"};function mg(e){return e&&ug[e.toLowerCase()]||"all"}function gg(e){return e==="all"?null:e}const ya=["work","collection","book","entity"],fg={work:"works",collection:"collections",book:"books",entity:"entities"},hg={work:"totalWorks",collection:"totalCollections",book:"totalBooks",entity:"totalEntities"};function xg(){try{return window.localStorage.getItem(Ao)==="card"?"card":"table"}catch{return"table"}}function bg(e){try{window.localStorage.setItem(Ao,e)}catch{}}const yn=(e,n)=>(e==null?void 0:e[hg[n]])??0,zr=(e,n)=>(e==null?void 0:e[fg[n]])??[],yc=({transport:e,query:n,filters:i,onFiltersChange:o,onEntryLinkClick:s,typeName:a,tab:l,onTabChange:d,page:c,onPageChange:p})=>{const g=Be(),m=g.searchV4,{convert:u}=Ve(),h=!!e.supportsSearchFilters,x=f.useMemo(()=>h?i:Ki,[h,i]),[j,b]=f.useState("table");f.useEffect(()=>{b(xg())},[]);const S=B=>{b(B),bg(B)},[y,k]=f.useState(l??"all"),w=f.useRef(y);w.current=y,f.useEffect(()=>{l!==void 0&&l!==w.current&&(k(l),C(1))},[l]);const[v,C]=f.useState(c&&c>0?c:1),_=f.useRef(v);_.current=v,f.useEffect(()=>{c!==void 0&&c>0&&c!==_.current&&C(c)},[c]);const $=f.useRef(null),A=f.useCallback(B=>{var Ce;C(B),p==null||p(B);const ee=$.current;ee&&ee.getBoundingClientRect().top<0&&((Ce=ee.scrollIntoView)==null||Ce.call(ee,{block:"start",behavior:"instant"}))},[p]),[R,z]=f.useState(null),[N,M]=f.useState(null),[O,L]=f.useState(!1),[D,q]=f.useState(""),J=Mi(x).toString(),se=Zi(x)>0,U=Mi({...x,sort:""}).toString(),K=f.useRef({query:n,filterOnlyKey:U,sort:x.sort});f.useEffect(()=>{const B=K.current;B.query!==n||B.filterOnlyKey!==U?(k("all"),C(1)):B.sort!==x.sort&&C(1),K.current={query:n,filterOnlyKey:U,sort:x.sort}},[n,U,x.sort]),f.useEffect(()=>{let B=!1;return L(!0),q(""),(async()=>{try{let ee;if(e.searchAll)ee=await e.searchAll(n,ba,x);else{const Ce=["work","book","collection","entity"],Ie=await Promise.all(Ce.map(We=>e.search(n,We,{page:1,pageSize:ba,filters:x})));ee={works:Ie[0].entries,books:Ie[1].entries,collections:Ie[2].entries,entities:Ie[3].entries,totalWorks:Ie[0].total,totalBooks:Ie[1].total,totalCollections:Ie[2].total,totalEntities:Ie[3].total}}B||z(ee)}catch(ee){B||(q(ee instanceof Error?ee.message:String(ee)),z(null))}finally{B||L(!1)}})(),()=>{B=!0}},[e,n,J]);const Z=y;f.useEffect(()=>{if(y==="all"){M(null);return}let B=!1;return L(!0),(async()=>{try{const ee=await e.search(n,y,{page:v,pageSize:Cr,filters:x});B||M({key:Z,entries:ee.entries,total:ee.total})}catch(ee){B||(q(ee instanceof Error?ee.message:String(ee)),M(null))}finally{B||L(!1)}})(),()=>{B=!0}},[e,n,J,y,v]);const oe=N&&N.key===Z?N:null;f.useEffect(()=>{if(y==="all"||!oe||O)return;const B=Math.min(oe.total,Zn),ee=lg(v,B,Cr);oe.entries.length===0&&B>0&&ee!==v&&(C(ee),p==null||p(ee))},[y,oe,O,v]);const ye=f.useMemo(()=>ya.filter(B=>yn(R,B)>0),[R]),Le=ye.reduce((B,ee)=>B+yn(R,ee),0),Me=ye.some(B=>yn(R,B)>=Zn)?`${Le.toLocaleString()}+`:Le.toLocaleString(),Se=!O&&!D&&R!==null&&Le===0,le=f.useCallback(B=>{k(B),C(1),d==null||d(B)},[d]),Oe=f.useMemo(()=>{const B=[];return x.dynasty.forEach(ee=>B.push({name:ee,remove:()=>o({...x,dynasty:x.dynasty.filter(Ce=>Ce!==ee)})})),x.classification.forEach(ee=>{var Ce;return B.push({name:ee?((Ce=Xi.find(Ie=>Ie.value===ee))==null?void 0:Ce.label)??ee:g.searchPage.unclassified,remove:()=>o({...x,classification:x.classification.filter(Ie=>Ie!==ee)})})}),x.hasImage&&B.push({name:m.hasImage,remove:()=>o({...x,hasImage:!1})}),x.hasText&&B.push({name:m.hasText,remove:()=>o({...x,hasText:!1})}),x.hasCollated&&B.push({name:m.hasCollated,remove:()=>o({...x,hasCollated:!1})}),x.loss&&B.push({name:`${m.extant}:${g.searchPage.loss[x.loss]}`,remove:()=>o({...x,loss:""})}),B},[x,o,m,g]),T={query:n,onEntryLinkClick:s,typeName:a},de=B=>j==="table"?t.jsx(ha,{entries:B,...T}):t.jsx(xa,{entries:B,...T}),pe=ya.flatMap(B=>zr(R,B));return t.jsxs("div",{className:"bim-sr-layout","data-nofilters":h?void 0:"true",children:[t.jsx("style",{children:pg}),h&&t.jsx(og,{filters:x,onChange:o}),t.jsxs("div",{className:"bim-sr-main","aria-busy":O,ref:$,children:[ye.length>0&&t.jsxs("div",{className:"bim-sr-tabs",role:"group","aria-label":g.search.resultTabs,style:{display:"flex",flexWrap:"wrap",gap:"0 4px",borderBottom:`1px solid ${r("rule")}`},children:[t.jsxs(ja,{on:y==="all",onClick:()=>le("all"),children:[g.search.allTab," ",t.jsx("small",{children:Me})]}),ye.map(B=>t.jsxs(ja,{on:y===B,onClick:()=>le(B),children:[a(B)," ",t.jsx("small",{children:$i(yn(R,B))})]},B))]}),t.jsxs("div",{className:"bim-sr-tools",children:[h&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-sr-sorts",role:"group","aria-label":u(m.sortLabel),children:[t.jsx("button",{type:"button","aria-pressed":!x.sort,onClick:()=>o({...x,sort:""}),children:u(m.sortRelevance)}),["era","title"].map(B=>{const ee=x.sort.startsWith(`${B}:`)?x.sort.endsWith("desc")?"desc":"asc":null,Ce=B==="era"?m.sortEra:m.sortTitle,Ie=B==="era"?ee==="desc"?m.sortEraDesc:m.sortEraAsc:ee==="desc"?m.sortTitleDesc:m.sortTitleAsc;return t.jsxs("button",{type:"button","aria-pressed":ee!==null,title:u(Ie),onClick:()=>o({...x,sort:`${B}:${ee==="asc"?"desc":"asc"}`}),children:[u(Ce),ee?t.jsxs("span",{"aria-hidden":"true",children:[" ",ee==="asc"?"↑":"↓"]}):null]},B)})]}),t.jsx("span",{className:"bim-sr-vsep","aria-hidden":"true"})]}),t.jsxs("div",{className:"bim-sr-view",role:"group","aria-label":u(m.viewLabel),children:[t.jsx("button",{type:"button","aria-pressed":j==="table",onClick:()=>S("table"),children:u(m.viewTable)}),t.jsx("button",{type:"button","aria-pressed":j==="card",onClick:()=>S("card"),children:u(m.viewCard)})]})]}),se&&t.jsxs("div",{className:"bim-sr-chips-row",children:[t.jsx("span",{className:"bim-sr-count",role:"status",children:u(zt(m.filteredCount,{n:Me}))}),Oe.map(B=>t.jsxs("button",{type:"button",className:"bim-sr-tag-x","aria-label":u(zt(m.removeFilter,{name:B.name})),onClick:B.remove,children:[u(B.name),t.jsx("span",{"aria-hidden":"true",children:"×"})]},B.name))]}),D&&t.jsx("div",{className:"bim-sr-empty",role:"alert",children:D}),Se&&t.jsx("div",{className:"bim-sr-empty",children:u(se?m.emptyFiltered:zt(g.search.noResultsFor,{query:n}))}),!D&&!Se&&y==="all"&&R&&(j==="table"?t.jsxs(t.Fragment,{children:[t.jsx(ha,{entries:pe,...T}),t.jsx("p",{className:"bim-sr-note",style:{marginTop:10},children:u(m.limitedNote)})]}):t.jsx(t.Fragment,{children:ye.map(B=>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(En,{type:B,size:8}),a(B),t.jsxs("span",{style:{fontSize:12.5,fontWeight:400,color:r("meta-fg")},children:[$i(yn(R,B))," ",g.unit.items]})]}),yn(R,B)>zr(R,B).length&&t.jsx("button",{type:"button",className:"bim-sr-clear",style:{textDecoration:"none"},onClick:()=>le(B),children:g.action.viewAll})]}),t.jsx(xa,{entries:zr(R,B),...T})]},B))})),!D&&y!=="all"&&!oe&&t.jsx("div",{className:"bim-sr-empty",role:"status",style:{minHeight:240},children:g.search.loading}),!D&&y!=="all"&&oe&&oe.entries.length>0&&t.jsxs(t.Fragment,{children:[de(oe.entries),t.jsx(cg,{page:v,pageSize:Cr,total:Math.min(oe.total,Zn),totalLabel:$i(oe.total),onPage:A})]}),!D&&y!=="all"&&oe&&oe.entries.length===0&&!O&&t.jsxs("div",{className:"bim-sr-empty",children:[u(se?m.emptyFiltered:zt(g.search.noResultsFor,{query:n})),t.jsx("div",{children:t.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>le("all"),children:g.search.allTab})})]})]})]})};function ja({on:e,onClick:n,children:i}){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:r(e?"ink":"meta-fg"),fontWeight:e?700:400,boxShadow:e?`inset 0 -2px 0 ${r("accent")}`:"none"},children:i})}const Cn="bim-recent-ids",va="bim-recent-entries",ka=50;function tn(){try{const e=localStorage.getItem(Cn);if(e)return JSON.parse(e);const n=localStorage.getItem(va);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(Cn,JSON.stringify(i)),localStorage.removeItem(va),i}return[]}catch{return[]}}function Kr(e){try{const n=tn().filter(i=>i!==e);n.unshift(e),n.length>ka&&(n.length=ka),localStorage.setItem(Cn,JSON.stringify(n))}catch{}}function jc(e){try{const n=tn().filter(i=>i!==e);localStorage.setItem(Cn,JSON.stringify(n))}catch{}}function Mo(){try{localStorage.removeItem(Cn)}catch{}}async function Po(e,n){var i,o,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:(i=l==null?void 0:l[0])==null?void 0:i.name,dynasty:(o=l==null?void 0:l[0])==null?void 0:o.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 Nr=5,yg=50,jg=200,wa={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},qr=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:s,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c,hideModeIndicator:p,resultVariant:g="compact",renderEntry:m,initialQuery:u,onQueryChange:h,headerRight:x,reserveViewportHeight:j=!1,filtersEnabled:b=!1,filters:S=Ki,onFiltersChange:y,resultTab:k,onResultTabChange:w,resultPage:v,onResultPageChange:C})=>{const _=Be(),$=[{type:"work",name:_.indexType.work,key:"works"},{type:"book",name:_.indexType.book,key:"books"},{type:"collection",name:_.indexType.collection,key:"collections"},{type:"entity",name:_.indexType.entity,key:"entities"}],A=["work","collection","book","entity"],[R,z]=f.useState(u??""),[N,M]=f.useState(null),[O,L]=f.useState(u??""),D=Mi(S).toString(),[q,J]=f.useState(S);f.useEffect(()=>{J(S)},[D]);const se=I=>{J(I),y==null||y(I)},[U,K]=f.useState(null),[Z,oe]=f.useState("all"),[ye,Le]=f.useState(!1),[Me,Se]=f.useState(null),[le,Oe]=f.useState(""),[T,de]=f.useState(!(u!=null&&u.trim())),[pe,B]=f.useState(tn),[ee,Ce]=f.useState([]),[Ie,We]=f.useState(!1),[G,he]=f.useState(!1),[te,H]=f.useState(null),[ue,Fe]=f.useState(null),Ge=f.useRef(void 0),Je=f.useRef(!1),F=f.useCallback(async(I,fe)=>{if(!I.trim()){de(!0),M(null),K(null);return}if(de(!1),b){L(I);return}Le(!0),Oe("");try{if(e.searchAll){const xe=await e.searchAll(I,fe??Nr);M(xe)}else{const xe=["work","book","collection","entity"],ze=await Promise.all(xe.map(V=>e.search(I,V,{page:1,pageSize:fe??Nr})));M({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})}}catch(xe){Oe(xe instanceof Error?xe.message:String(xe)),M(null)}finally{Le(!1)}},[e,b]);f.useEffect(()=>{let I=!1;const fe=()=>{var X,je;const xe=["work","book","collection","entity"],ze=Promise.all(xe.map(Y=>e.loadEntries(Y,{page:1,pageSize:1}).catch(()=>({total:0})))),V=((X=e.getResourceCounts)==null?void 0:X.call(e).catch(()=>null))??Promise.resolve(null),P=((je=e.getSubtypeStats)==null?void 0:je.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([ze,V,P]).then(([Y,me,_e])=>{I||(H({works:Y[0].total,books:Y[1].total,collections:Y[2].total,entities:Y[3].total,hasText:me==null?void 0:me.hasText,hasImage:me==null?void 0:me.hasImage}),_e&&Fe(_e))})};return e.getCounts?e.getCounts().then(xe=>{var ze,V;I||(H({works:xe.works,books:xe.books,collections:xe.collections,entities:xe.entities,hasText:(ze=xe.resourceCounts)==null?void 0:ze.hasText,hasImage:(V=xe.resourceCounts)==null?void 0:V.hasImage}),xe.subtypeStats&&Fe(xe.subtypeStats))}).catch(()=>{I||fe()}):fe(),()=>{I=!0}},[e]),f.useEffect(()=>{Je.current||!(u!=null&&u.trim())||(Je.current=!0,F(u))},[u,F]);const ge=f.useCallback(I=>{if(z(I),!I.trim()){h==null||h(I),de(!0),M(null),K(null),oe("all");return}Ge.current&&clearTimeout(Ge.current),Ge.current=setTimeout(()=>{K(null),oe("all"),h==null||h(I),F(I)},jg)},[F,h]),Ae=f.useCallback(I=>{Ge.current&&clearTimeout(Ge.current),oe("all"),h==null||h(I),F(I)},[F,h]),W=f.useCallback(I=>{K(I),F(R,yg)},[R,F]);f.useEffect(()=>{if(!pe.length){Ce([]);return}let I=!1;return We(!0),Promise.all(pe.slice(0,10).map(fe=>Po(e,fe))).then(fe=>{I||(Ce(fe),We(!1))}),()=>{I=!0}},[pe,e]);const be=I=>{Se(I.id),Kr(I.id),B(tn()),o==null||o(I)},ce=(I,fe)=>{if(o&&kg(fe)){fe.preventDefault(),be(I);return}Kr(I.id),B(tn())},Ne=I=>{jc(I),B(tn())},$e=()=>{Mo(),B([])},Ke=I=>$.find(fe=>fe.type===I),Qe=!T&&!N&&!le,it=N&&(N.works.length>0||N.books.length>0||N.collections.length>0),nt=t.jsxs(t.Fragment,{children:[t.jsx(ec,{transport:e,value:R,onChange:ge,onSearch:Ae,onEntrySelect:be}),b&&t.jsx("button",{type:"button",className:"bim-ib-submit",onClick:()=>{const I=R.trim();I&&Ql(I),Ae(R)},children:_.searchPage.submit}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${r("primary")}`,borderRadius:"6px",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"13px"},children:_.action.newEntry})]});return t.jsxs("div",{className:"bim-browser-container",style:j?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:wg+(b?Sg:"")}),(!b||x||!p)&&t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[b?t.jsx("span",{}):t.jsx("h1",{style:{margin:0,fontSize:"18px",color:r("fg")},children:_.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,!p&&t.jsx(Jl,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:a,onToggleDraft:l,onConfigurePath:d,onSelectFolder:c})]})]})}),b?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:nt})]}):t.jsx("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:nt}),T&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:te&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:ue?t.jsxs(t.Fragment,{children:[(ue.book??0)>0&&t.jsxs(t.Fragment,{children:[_.searchPage.statBook," ",t.jsx("strong",{style:{color:r("fg")},children:ue.book.toLocaleString()})," ",_.unit.bu,_.searchPage.statComma,t.jsx("strong",{style:{color:r("fg")},children:te.books.toLocaleString()})," ",_.searchPage.statBookCopies]}),ue.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statArticle," ",t.jsx("strong",{style:{color:r("fg")},children:ue.article.toLocaleString()})," ",_.searchPage.statArticleUnit]}):null,ue.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statPoem," ",t.jsx("strong",{style:{color:r("fg")},children:ue.poem.toLocaleString()})," ",_.searchPage.statPoemUnit]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.searchPage.statCollection," ",t.jsx("strong",{style:{color:r("fg")},children:te.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[_.indexType.work," ",t.jsx("strong",{style:{color:r("fg")},children:te.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.book," ",t.jsx("strong",{style:{color:r("fg")},children:te.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.collection," ",t.jsx("strong",{style:{color:r("fg")},children:te.collections.toLocaleString()}),te.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.indexType.entity," ",t.jsx("strong",{style:{color:r("fg")},children:te.entities.toLocaleString()})]})]})}),te.hasImage!=null&&te.hasText!=null&&t.jsxs("span",{children:[_.resourceType.image," ",t.jsx("strong",{style:{color:r("fg")},children:te.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),_.resourceType.text," ",t.jsx("strong",{style:{color:r("fg")},children:te.hasText.toLocaleString()})]})]})}),b&&!T&&t.jsx(yc,{transport:e,query:O,filters:q,onFiltersChange:se,onEntryLinkClick:ce,typeName:I=>Ke(I).name,tab:k,onTabChange:w,page:v,onPageChange:C}),!(b&&!T)&&t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:ye||Qe?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg"),minHeight:vg,boxSizing:"border-box"},children:_.search.searching}):le?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:r("desc-fg")},children:le})}):T?t.jsx("div",{style:{flex:1},children:Ie?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:r("desc-fg")},children:_.search.loading}):ee.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:r("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:_.search.recentBrowse}),t.jsx("button",{onClick:$e,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:_.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:ee.slice(0,G?10:3).map(I=>I.notFound?t.jsx(zg,{id:I.id,onRemove:Ne,t:_},I.id):t.jsx(Sa,{entry:I,selected:Me===I.id,onClick:ce,getConfig:Ke,onRemove:Ne},I.id))}),!G&&ee.length>3&&t.jsx("button",{onClick:()=>he(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:_.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:_.search.searchTitle}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:_.search.searchSubtitle})]})}):it?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:_g}),(()=>{const I=P=>N[wa[P]]??0,fe=A.map(P=>$.find(X=>X.type===P)).filter(P=>I(P.key)>0);if(fe.length<2)return null;const xe=fe.reduce((P,X)=>P+I(X.key),0),ze=P=>{if(oe(P),P!=="all"&&U!==P){const X=$.find(Y=>Y.type===P),je=(N[X.key]??[]).length;I(X.key)>je&&W(P)}},V=P=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:r(P?"fg":"desc-fg"),fontWeight:P?700:400,boxShadow:P?`inset 0 -2px 0 ${r("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":_.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":Z==="all",style:V(Z==="all"),onClick:()=>ze("all"),children:[_.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:xe.toLocaleString()})]}),fe.map(P=>t.jsxs("button",{type:"button","aria-pressed":Z===P.type,style:V(Z===P.type),onClick:()=>ze(P.type),children:[P.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:I(P.key).toLocaleString()})]},P.type))]})})(),$.map(({type:I,name:fe,key:xe})=>{const ze=N[xe]??[],V=wa[xe],P=N[V]??0;if(ze.length===0||Z!=="all"&&Z!==I)return null;const je=Z==="all"&&!(U===I)&&P>Nr;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:[t.jsx(En,{type:I})," ",fe,t.jsxs("span",{style:{fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:[P," ",_.unit.items]})]}),je&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>W(I),style:{border:"none",background:"transparent",color:r("primary"),cursor:"pointer",fontSize:"12px"},children:_.action.viewAll})]}),t.jsx("div",{style:g==="list"?{display:"flex",flexDirection:"column",gap:0}:g==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:ze.map(Y=>{if(m)return t.jsx(f.Fragment,{children:m(Y)},Y.id);const me=g==="card"?Cg:Sa;return t.jsx(me,{entry:Y,selected:Me===Y.id,onClick:ce,getConfig:Ke,query:R},Y.id)})})]},I)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:r("fg")},children:zt(_.search.noResultsFor,{query:R})}),t.jsx("p",{style:{color:r("desc-fg"),fontSize:"13px"},children:_.search.tryOther})]})})]})},vg=240;function kg(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const wg=`
|
|
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
|
+
`,Sg=`
|
|
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,20 +135,20 @@
|
|
|
135
135
|
.bim-ib-bar-main { max-width: none; }
|
|
136
136
|
.bim-ib-submit { min-height: 44px; padding: 0 16px; }
|
|
137
137
|
}
|
|
138
|
-
`,
|
|
138
|
+
`,_g=`
|
|
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
|
-
}`,bc={color:"inherit",textDecoration:"none"},wg=({snippet:e})=>{const{convert:n}=Ue();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:yo(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(f.Fragment,{children:n(i.text)},o))})},Sg=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=We(),{convert:l}=Ue(),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?`${En(e.juan_count)}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],g=s&&p.length?p.find(h=>{const x=typeof h=="string"?h:h==null?void 0:h.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=r("cover-accent"),u=mt();return t.jsxs("a",{href:u(e.id),onClick:h=>i(e,h),className:"bim-result-card",style:{...bc,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:r("bg"),border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${m} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${r("bg")}), color-mix(in srgb, ${m} 7%, ${r("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${m} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:m},children:Array.from(d).map((h,x)=>t.jsx("span",{children:h},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:r("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:r("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:r("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),g&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof g=="string"?g:g.book_title||"")]}),e.descriptionSnippet&&t.jsx(wg,{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:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:[t.jsx(In,{type:e.type,size:8})," ",o(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.imageResource})]})]})]})},va=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=We(),{convert:d}=Ue(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const u=typeof m=="string"?m:m==null?void 0:m.book_title;return u==null?void 0:u.toLowerCase().includes(s.toLowerCase())}):void 0,g=mt();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("a",{href:g(e.id),onClick:m=>i(e,m),className:"bim-result-card",style:{...bc,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(In,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:r("desc-fg"),lineHeight:1},children:o(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:r("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:r("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:r("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[En(e.juan_count),l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:r("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:r("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:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},_g=({id:e,onRemove:n,t:i})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${r("widget-border")}`,background:r("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:r("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:i.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:i.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function $g(e){var n,i,o;return!e.dynasty&&((n=e.dates)==null?void 0:n.birth)==null&&((i=e.dates)==null?void 0:i.death)==null&&(!e.alt_names||e.alt_names.length===0)&&!((o=e.description)!=null&&o.text)}function Cg({data:e}){var l,d;const{convert:n}=Ue(),{dynasty:i}=e,o=((l=e.dates)==null?void 0:l.birth)??void 0,s=((d=e.dates)==null?void 0:d.death)??void 0,a=[];return i&&a.push(`〔${n(i)}〕`),o!==void 0&&s!==void 0?a.push(`${o}—${s}`):o!==void 0?a.push(`${o}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:r("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function zg({alt_names:e}){const{convert:n}=Ue(),i=new Map;for(const a of e){const l=a.type||"別名";i.has(l)||i.set(l,[]),i.get(l).push(a.name)}const o=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...i.keys()].sort((a,l)=>{const d=o.indexOf(a),c=o.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=i.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:r("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:r("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function Ng({data:e}){const n=We(),i=e.external_ids;if(!i)return null;const o=[];return i.cbdb_id&&o.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${i.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:r("link-fg"),border:`1px solid ${r("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${r("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",i.cbdb_id]},"cbdb")),o.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:o})}function Tg({works:e,transport:n,onNavigate:i,renderLink:o}){const s=We(),{convert:a}=Ue(),l=mt(),[d,c]=f.useState(new Map);f.useEffect(()=>{if(!n)return;let u=!1;const h=e.map(j=>j.work_id);return(async()=>{const j=new Map;if(n.getEntriesByIds)try{const k=await n.getEntriesByIds(h);let w=!0;for(let v=0;v<h.length;v++){const C=k[v];C!=null&&C.title?j.set(h[v],C.title):C!=null&&C.primary_name?j.set(h[v],C.primary_name):w=!1}if(w)return j}catch{}const b=[...h],$=8,y=new Array($).fill(0).map(async()=>{for(;b.length;){const k=b.shift();if(!k)break;if(!j.has(k))try{if(n.getEntry){const C=await n.getEntry(k);if(C!=null&&C.title){j.set(k,C.title);continue}}const w=await n.getItem(k),v=w&&(w.title||w.primary_name)||k;j.set(k,v)}catch{j.set(k,k)}}});return await Promise.all(y),j})().then(j=>{u||c(j)}),()=>{u=!0}},[e,n]);const p=new Map;for(const u of e){const h=u.role||"";p.has(h)||p.set(h,[]),p.get(h).push(u)}const g=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((u,h)=>{const x=g.indexOf(u),j=g.indexOf(h);return x===-1&&j===-1?u.localeCompare(h):x===-1?1:j===-1?-1:x-j});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(u=>{const h=p.get(u);return t.jsxs("div",{style:{marginBottom:"8px"},children:[u&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(u)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",h.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:u?"16px":"0",listStyle:u?"disc":"none",fontSize:"14px",lineHeight:1.8},children:h.map((x,j)=>{const b=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,b)},j):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:$=>{$.metaKey||$.ctrlKey||($.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:b})},j):t.jsx("li",{children:b},j)})})]},u)})]})}const yc=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var m;const l=We(),{convert:d}=Ue();let c=!1;try{c=Ee.extractStatus(e.id)==="draft"}catch{}const p=$g(e),g=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:r("fg")},children:[d(e.primary_name),t.jsx(Cg,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:r("type-entity"),border:`1px solid color-mix(in srgb, ${r("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${r("type-entity")} 3%, transparent)`},children:l.indexType.entity}),g&&e.subtype!=="people"&&t.jsx("span",{children:g}),c&&t.jsx("span",{style:{padding:"1px 6px",background:r("warn-bg"),border:`1px solid ${r("warn-border")}`,borderRadius:"2px",color:r("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:r("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:r("widget-bg"),border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(zg,{alt_names:e.alt_names}),t.jsx(Ng,{data:e}),((m=e.description)==null?void 0:m.text)&&t.jsx("p",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(Tg,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},Rg=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Ig(e){const n=e.search(Rg);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const jc={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 i=e,o="",s=n;if(e&&typeof n=="string"&&(n===e||n===Eg(e))){const[a,l]=Ig(n);l&&(i=encodeURI(a),s=a,o=l)}return t.jsxs(t.Fragment,{children:[t.jsx("a",{href:i,target:i!=null&&i.startsWith("http")?"_blank":void 0,rel:i!=null&&i.startsWith("http")?"noopener noreferrer":void 0,style:{color:r("link")},children:s}),o]})},code:({children:e})=>t.jsx("code",{style:{background:r("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function Eg(e){try{return decodeURI(e)}catch{return e}}const Lg={...jc,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},qt=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Ue(),a=n?Lg:jc;return t.jsx("div",{className:o,style:i,children:t.jsx(Pu,{remarkPlugins:[Bu],components:a,children:s(e)})})};function vc(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 Ag={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function Mg({type:e}){const n=We();return t.jsx("span",{style:vc(Ag[e]),children:n.indexType[e]})}function Pg({isDraft:e}){const n=We(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:vc(i),children:e?n.status.draft:n.status.official})}function Bg({id:e}){const n=We(),[i,o]=f.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function zt({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:r("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function Mt({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:r("fg")},children:n})]})}function kc({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Ue();return t.jsx("span",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(It,{id:a.entity_id,label:d,onNavigate:i,renderLink:o}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function It({id:e,label:n,onNavigate:i,renderLink:o}){const s=mt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("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 Og({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:g}){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:r("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,i&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:i}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:r("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(Mg,{type:o}),t.jsx(Pg,{isDraft:s}),t.jsx(Bg,{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(kc,{authors:a,type:o,onNavigate:p,renderLink:g}),d]})]})}function wc({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=We(),{convert:l}=Ue();if(!e.length)return null;const[d,c]=f.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(zt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,g)=>{const m=d===g;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?null:g),style:{padding:"8px 12px",background:r("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!m&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:u=>u.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(It,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),m&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${r("widget-border")}`},children:[i&&(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(Mt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Mt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Mt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:r("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 ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:r("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 ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},g)})})]})}function Wg({items:e,onNavigate:n,renderLink:i}){const o=We();return t.jsx(wc,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function Sc({items:e,onNavigate:n,renderLink:i}){const o=We();return t.jsx(wc,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function _c({label:e,items:n}){const{convert:i}=Ue();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(zt,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((o,s)=>{const a=typeof o=="string"?o:o.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:i(a)},s)})})]}):null}function Fg({items:e}){const n=We();return t.jsx(_c,{label:n.section.aliases,items:e})}function Hg({items:e}){const n=We();return t.jsx(_c,{label:n.section.attachedTexts,items:e})}function Dg({items:e}){const n=We(),{convert:i}=Ue();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(zt,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((o,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:["《",i(o.book_title),"》",o.n_juan!=null&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:[o.n_juan,n.unit.juan]})]},s))})]}):null}function Ug({items:e}){const n=We(),{convert:i}=Ue();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(zt,{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:r("widget-border")}}),e.map((o,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:r("primary"),border:`1.5px solid ${r("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:r("fg")},children:i(o.name)}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function Vg({items:e}){const n=We(),{convert:i}=Ue();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(zt,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((o,s)=>t.jsxs("div",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:r("desc-fg")},children:"·"}),i(o)]},s))})]}):null}function ka({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Ue(),[l,d]=f.useState([]);return f.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(g=>({id:p,title:g?g.title:void 0,edition:g?g.edition:void 0,type:g?g.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(zt,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:r("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 ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),transition:"border-color 0.15s"},children:t.jsx(It,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function zr({book:e,onNavigate:n,renderLink:i}){const o=We(),{convert:s}=Ue(),[a,l]=f.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 ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(It,{id:e.id,label:c,onNavigate:n,renderLink:i})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:r("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?o.action.expand:o.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(_o,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function Gg({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=We(),{convert:d}=Ue(),[c,p]=f.useState([]);if(f.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(j=>({id:j})));return}let x=!1;return Promise.all(e.map(j=>i.getItem(j).then(b=>({id:j,title:b?b.title:void 0,edition:b?b.edition:void 0,resources:b?b.resources:void 0,resource_groups:b?b.resource_groups:void 0})).catch(()=>({id:j})))).then(j=>{x||p(j)}),()=>{x=!0}},[e,i]),!e.length)return null;const g=c.length?c:e.map(x=>({id:x})),m=new Map(g.map(x=>[x.id,x])),u=n==null?void 0:n.version_graph,h=Yg(e,u,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(zt,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,h.useGrouping?t.jsxs(t.Fragment,{children:[h.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.coreIds.map(x=>{const j=m.get(x);return j?t.jsx(zr,{book:j,onNavigate:o,renderLink:s},x):null})}),h.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${r("widget-border")}`,borderRadius:6,background:r("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:r("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:r("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:r("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(j=>{const b=m.get(j);return b?t.jsx(zr,{book:b,onNavigate:o,renderLink:s},j):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:g.map(x=>t.jsx(zr,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function Yg(e,n,i){var $,y;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=($=n.collections)==null?void 0:$[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.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]),g=k=>{if(p.has(k))return!0;const w=n.node_groups[k];return w!=null&&c.has(w)},m=[],u=new Map,h=[];for(const k of e)if(!((y=n.excluded_books)!=null&&y.includes(k)))if(g(k))m.push(k);else{const w=n.node_groups[k];w?(u.has(w)||u.set(w,[]),u.get(w).push(k)):h.push(k)}if(h.length+[...u.values()].reduce((k,w)=>k+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const j=new Map((n.groups??[]).map(k=>[k.id,k])),b=[...u.entries()].map(([k,w])=>{const v=j.get(k);return{id:k,label:(v==null?void 0:v.label)??k,description:v==null?void 0:v.description,ids:w}});return h.length>0&&b.push({id:"__other__",label:i,description:void 0,ids:h}),{useGrouping:!0,coreIds:m,groupedIds:b}}function Kg({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=We(),{convert:s}=Ue(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:r("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:t.jsx(It,{id:e.id,label:s(e.title),onNavigate:n,renderLink:i})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:r("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:r("desc-fg")},children:[En(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(kc,{authors:e.authors,type:"work",onNavigate:n,renderLink:i})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(qt,{text:e.description.text,style:{fontSize:"13px",color:r("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(Mt,{label:o.label.parentWork,children:t.jsx(It,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function qg({items:e,onNavigate:n,renderLink:i}){const o=We(),{convert:s}=Ue();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, ${r("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${r("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:r("type-collection")},children:o.indexType.collection}),t.jsx(It,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:i}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"2px"},children:$t(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Mo=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var I,B,O,A,W,G,oe,se;const p=We(),{convert:g}=Ue(),[m,u]=f.useState(null),[h,x]=f.useState(!1),[j,b]=f.useState(null),[$,y]=f.useState(null),[k,w]=f.useState([]),v=e||m;if(f.useEffect(()=>{if(e||!n||!i)return;let Y=!1;return x(!0),b(null),i.getItem(n).then(de=>{Y||(de?u(de):b(p.misc.notFoundEntry))}).catch(de=>{Y||b(de instanceof Error?de.message:p.misc.loadFailed)}).finally(()=>{Y||x(!1)}),()=>{Y=!0}},[e,n,i]),f.useEffect(()=>{if(!v||!i){y(null),w([]);return}let Y=!1;const de=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(de?i.getItem(de).then(ne=>{!Y&&ne&&ne.type==="work"&&y(ne)}).catch(()=>{}):y(null),v.type==="book"){const ne=v;ne.contained_in&&ne.contained_in.length>0?Promise.all(ne.contained_in.map(ue=>{const ke=typeof ue=="string"?ue:ue.id,Ae=typeof ue=="string"?void 0:ue.volume_index;return i.getItem(ke).then(he=>({id:ke,title:he&&he.title||ke,volume_index:Ae})).catch(()=>({id:ke,title:ke,volume_index:Ae}))})).then(ue=>{Y||w(ue)}):w([])}else w([]);return()=>{Y=!0}},[v,i]),h)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((Y,de)=>t.jsx("div",{style:{height:de===1?"32px":"16px",width:`${Y}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},de))})});if(j)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:j});if(!v)return null;if(v.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(yc,{data:v,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const C=v.type==="book"?v:null,S=v.type==="collection"?v:null,_=v.type==="work"?v:null;let R=!1;try{R=Ee.extractStatus(v.id)==="draft"}catch{}let z="";v.measure_info?z=g(v.measure_info):(I=v.juan_count)!=null&&I.number?z=En(v.juan_count.number)+p.unit.juan:(B=v.juan_count)!=null&&B.description&&(z=g(v.juan_count.description));const N=[];return(O=v.publication_info)!=null&&O.year&&N.push(t.jsx(Mt,{label:p.label.year,children:v.publication_info.year},"year")),(A=v.current_location)!=null&&A.name&&N.push(t.jsx(Mt,{label:p.label.currentLocation,children:g(v.current_location.name)},"loc")),(W=v.page_count)!=null&&W.description&&N.push(t.jsx(Mt,{label:p.label.pageCount,children:v.page_count.description},"page")),C!=null&&C.edition&&N.push(t.jsx(Mt,{label:p.label.edition,children:g(C.edition)},"ver")),_!=null&&_.parent_work&&N.push(t.jsx(Mt,{label:p.label.parentWork,children:t.jsx(It,{id:_.parent_work.id,label:g(_.parent_work.title),onNavigate:o,renderLink:s})},"pw")),_!=null&&_.parent_works&&_.parent_works.length>0&&!_.parent_work&&N.push(t.jsx(Mt,{label:p.label.parentWork,children:_.parent_works.map((Y,de)=>t.jsxs("span",{children:[de>0&&"、",t.jsx(It,{id:Y,onNavigate:o,renderLink:s})]},Y))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Og,{id:v.id,title:g(v.title),edition:v.edition?g(v.edition):void 0,type:v.type,isDraft:R,authors:v.authors,volumeText:z,meta:N,headerExtra:a,onNavigate:o,renderLink:s}),((G=v.description)==null?void 0:G.text)&&t.jsx(qt,{text:v.description.text,style:{fontSize:"14px",color:r("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((Y,de)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:r("bg-subtle"),borderRadius:4,border:`1px solid ${r("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:r("muted")},children:g(Y.title)}),t.jsx(qt,{text:Y.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},de))}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(zt,{children:p.section.containedIn}),t.jsx(qg,{items:k,onNavigate:o,renderLink:s})]}),$&&t.jsxs(t.Fragment,{children:[t.jsx(zt,{children:p.section.belongsToWork}),t.jsx(Kg,{workData:$,onNavigate:o,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Dg,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Fg,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(Hg,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(Wg,{items:v.indexed_by,onNavigate:o,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(Sc,{items:v.emendated_by,onNavigate:o,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(zt,{children:p.section.resources}),t.jsx(_o,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),(C==null?void 0:C.location_history)&&C.location_history.length>0&&t.jsx(Ug,{items:C.location_history}),(S==null?void 0:S.history)&&S.history.length>0&&t.jsx(Vg,{items:S.history}),(C==null?void 0:C.related_books)&&C.related_books.length>0&&t.jsx(ka,{title:p.section.relatedVersions,ids:C.related_books,transport:i,onNavigate:o,renderLink:s}),(S==null?void 0:S.books)&&S.books.length>0&&t.jsx(ka,{title:p.section.containedBooks,ids:S.books,transport:i,onNavigate:o,renderLink:s}),(S==null?void 0:S.contained_works)&&S.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(zt,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",S.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.contained_works.map(Y=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx(It,{id:Y.id,label:g(Y.title),onNavigate:o,renderLink:s})},Y.id))})]}),(((oe=_==null?void 0:_.books)==null?void 0:oe.length)||0)+(((se=_==null?void 0:_.collections)==null?void 0:se.length)||0)>0&&t.jsx(Gg,{ids:[...(_==null?void 0:_.books)||[],...(_==null?void 0:_.collections)||[]],workData:_??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),(_==null?void 0:_.related_works)&&_.related_works.length>0&&(()=>{const Y=[],de=_.related_works.filter($e=>$e.relation==="part_of"),ne=_.related_works.filter($e=>$e.relation==="has_part"),ue=_.related_works.filter($e=>$e.relation==="has_adaptation"),ke=_.related_works.filter($e=>$e.relation==="text_carried_by"),Ae=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),he=_.related_works.filter($e=>!$e.relation||!Ae.has($e.relation));return de.length>0&&Y.push({label:p.section.belongsToWork,items:de}),ne.length>0&&Y.push({label:p.section.containedWorks,items:ne}),ue.length>0&&Y.push({label:p.section.adaptations,items:ue}),ke.length>0&&Y.push({label:p.section.derivativeWorks,items:ke}),he.length>0&&Y.push({label:p.section.relatedWorks,items:he}),Y.map($e=>t.jsxs("div",{children:[t.jsxs(zt,{children:[$e.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",$e.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:$e.items.map(L=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx(It,{id:L.id,label:g(L.title),onNavigate:o,renderLink:s})},L.id))})]},$e.label))})()]})};function Xg({data:e}){const n=We(),{convert:i}=Ue(),{stats:o}=e,s=o.processed_volumes??o.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:r("fg"),margin:"0 0 8px"},children:i(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"6px"},children:i(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:r("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:r("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:r("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:r("fg")},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:r("fg")},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:r("missing-fg")},children:o.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:r("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Zg({sections:e,activeSection:n,onSelect:i}){const o=We();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:wa(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:wa(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 wa(e){return{padding:"4px 12px",border:e?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${r("primary")} 8%, transparent)`:"transparent",color:r(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Jg({id:e,label:n,onNavigate:i,renderLink:o}){const s=mt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("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:r("desc-fg")},children:n||e})}function Qg(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=e[0],o=e[e.length-1];return o-i+1===e.length?`${i}–${o}`:e.length<=3?e.join(", "):`${i}–${o} (${e.length}${n})`}function Sa({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=We(),{convert:a}=Ue(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?Qg(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 ${r("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[o&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:r("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:r("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:r(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(Jg,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:i}),!l&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const Po=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=We(),[c,p]=f.useState(null),[g,m]=f.useState(!1),[u,h]=f.useState(null),[x,j]=f.useState(null),[b,$]=f.useState(""),y=e||c;f.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let S=!1;return m(!0),h(null),i.getCollectionCatalog(n).then(_=>{S||(_?p(_):h(d.catalog.notFound))}).catch(_=>{S||h(_ instanceof Error?_.message:d.catalog.loadFailed)}).finally(()=>{S||m(!1)}),()=>{S=!0}},[e,n,i,d]);const k=(y==null?void 0:y.sections)&&y.sections.length>0,w=f.useMemo(()=>{if(!y)return!1;if(y.volume_index&&Object.keys(y.volume_index).length>0)return!0;const S=y.books.map(R=>R.volumes[0]).filter(R=>R!=null);return new Set(S).size<S.length},[y]),v=f.useMemo(()=>{if(!y)return[];let S=y.books;if(x&&(S=S.filter(_=>_.section===x)),b.trim()){const _=b.trim().toLowerCase();S=S.filter(R=>R.title.toLowerCase().includes(_)||R.sub_items&&R.sub_items.some(z=>z.toLowerCase().includes(_))||R.edition&&R.edition.toLowerCase().includes(_))}return S},[y,x,b]),C=f.useMemo(()=>{if(!w)return null;const S=[],_=new Map;for(const z of v){if(!z.volumes||z.volumes.length===0)continue;const N=z.volumes[0];_.has(N)||_.set(N,[]),_.get(N).push(z)}const R=[..._.keys()].sort((z,N)=>z-N);for(const z of R)S.push({volume:z,books:_.get(z)});return S},[v,w]);return g?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):u?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:u}):y?t.jsxs("div",{className:a,style:l,children:[t.jsx(Xg,{data:y}),k&&t.jsx(Zg,{sections:y.sections,activeSection:x,onSelect:j}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:b,onChange:S=>$(S.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:r("desc-fg")},children:[v.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[C?C.map((S,_)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:r("bg"),borderBottom:`1px solid ${r("widget-border")}`,fontSize:"12px",fontWeight:600,color:r("desc-fg"),position:"sticky",top:0,zIndex:1},children:$t(d.catalog.volume,{n:S.volume})}),S.books.map((R,z)=>t.jsx(Sa,{book:R,onNavigate:o,renderLink:s,showVolumes:R.volumes.length>1},`${S.volume}-${z}`))]},`${S.volume}-${_}`)):v.map((S,_)=>t.jsx(Sa,{book:S,onNavigate:o,renderLink:s,showVolumes:!0},_)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},Nr=e=>e?e.catch(()=>null):Promise.resolve(null);function $c(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=Nr((a=e.getTextManifest)==null?void 0:a.call(e,o)).then(l=>{const d=l&&Array.isArray(l.versions)&&l.versions.length>0?l:null;return d||n.delete(o),d}),n.set(o,s)),s}return{getManifest(o){return Ee.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!Ee.isSafeSegment(o)||!Ee.isSafeSegment(s)||!e.getTextIndex?null:Nr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!Ee.isSafeSegment(o)||!Ee.isSafeSegment(s)||!Ee.isSafeSegment(a)||!e.getChapter?null:Nr(e.getChapter(o,s,a,l))}}}const mn=()=>{const{t:e}=ae(),[n,i]=f.useState(1);return f.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},Tr=String.raw`https?:\/\/[^\s()()<>"]+`,ef=new RegExp(String.raw`\[([^\]\n]+)\]\((${Tr})\)`+String.raw`|(《[^》\n]+》)\s?[((](${Tr})[))]`+`|(${Tr})`,"g");function tf(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function nf(e){const n=[];let i=0;for(const o of e.matchAll(ef)){const s=o.index??0;s>i&&n.push({text:e.slice(i,s)}),o[1]!==void 0?n.push({text:o[1],url:o[2]}):o[3]!==void 0?n.push({text:o[3],url:o[4]}):n.push({text:tf(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function Cc({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:nf(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(f.Fragment,{children:n(o.text)},s))})}const zc="(min-width: 1100px)",_i="(max-width: 719px)",Nc="(max-width: 859px)",rf=`${_i}, (pointer: coarse)`,At=r("reader-top"),of="48px",Tc=`
|
|
145
|
+
}`,vc={color:"inherit",textDecoration:"none"},$g=({snippet:e})=>{const{convert:n}=Ve();return t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),lineHeight:1.6},children:vo(e).map((i,o)=>i.marked?t.jsx("mark",{style:{background:r("highlight-bg"),color:r("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},o):t.jsx(f.Fragment,{children:n(i.text)},o))})},Cg=({entry:e,selected:n,onClick:i,getConfig:o,query:s})=>{const a=Be(),{convert:l}=Ve(),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?`${Ln(e.juan_count)}${a.unit.juan}`:"",p=[...e.additional_titles||[],...e.attached_texts||[]],g=s&&p.length?p.find(h=>{const x=typeof h=="string"?h:h==null?void 0:h.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,m=r("cover-accent"),u=gt();return t.jsxs("a",{href:u(e.id),onClick:h=>i(e,h),className:"bim-result-card",style:{...vc,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:r("bg"),border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${m} 50%, ${r("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${m} 14%, ${r("bg")}), color-mix(in srgb, ${m} 7%, ${r("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${m} 45%, transparent)`}}),t.jsx("span",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",height:"108px",flexShrink:0,overflow:"hidden",fontSize:"1.05rem",fontWeight:700,lineHeight:1.25,color:m},children:Array.from(d).map((h,x)=>t.jsx("span",{children:h},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:r("fg")},children:d}),c&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:r("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:r("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",l(e.era),"〕"]}),e.edition&&t.jsx("span",{children:l(e.edition)})]}),g&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg")},children:[a.search.alias,":",l(typeof g=="string"?g:g.book_title||"")]}),e.descriptionSnippet&&t.jsx($g,{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:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:[t.jsx(En,{type:e.type,size:8})," ",o(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:r("desc-fg"),border:`1px solid ${r("widget-border")}`},children:a.misc.imageResource})]})]})]})},Sa=({entry:e,selected:n,onClick:i,getConfig:o,query:s,onRemove:a})=>{const l=Be(),{convert:d}=Ve(),c=[...e.additional_titles||[],...e.attached_texts||[]],p=s&&c.length?c.find(m=>{const u=typeof m=="string"?m:m==null?void 0:m.book_title;return u==null?void 0:u.toLowerCase().includes(s.toLowerCase())}):void 0,g=gt();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,background:r("input-bg")},children:[t.jsxs("a",{href:g(e.id),onClick:m=>i(e,m),className:"bim-result-card",style:{...vc,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(En,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:r("desc-fg"),lineHeight:1},children:o(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:r("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:r("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:r("desc-fg")},children:d(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:r("desc-fg")},children:[Ln(e.juan_count),l.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:r("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:r("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:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},zg=({id:e,onRemove:n,t:i})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${r("widget-border")}`,background:r("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:r("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:r("desc-fg"),marginTop:"2px"},children:i.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:i.search.removeFromRecent,style:{border:"none",background:"transparent",color:r("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function Ng(e){var n,i,o;return!e.dynasty&&((n=e.dates)==null?void 0:n.birth)==null&&((i=e.dates)==null?void 0:i.death)==null&&(!e.alt_names||e.alt_names.length===0)&&!((o=e.description)!=null&&o.text)}function Tg({data:e}){var l,d;const{convert:n}=Ve(),{dynasty:i}=e,o=((l=e.dates)==null?void 0:l.birth)??void 0,s=((d=e.dates)==null?void 0:d.death)??void 0,a=[];return i&&a.push(`〔${n(i)}〕`),o!==void 0&&s!==void 0?a.push(`${o}—${s}`):o!==void 0?a.push(`${o}—?`):s!==void 0&&a.push(`?—${s}`),a.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:r("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:a.join(" ")})}function Rg({alt_names:e}){const{convert:n}=Ve(),i=new Map;for(const a of e){const l=a.type||"別名";i.has(l)||i.set(l,[]),i.get(l).push(a.name)}const o=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...i.keys()].sort((a,l)=>{const d=o.indexOf(a),c=o.indexOf(l);return d===-1&&c===-1?0:d===-1?1:c===-1?-1:d-c});return t.jsx("div",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(a=>{const l=i.get(a);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:r("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:r("desc-fg"),margin:"0 4px"},children:"·"}),n(d)]},c))})]},a)})})}function Ig({data:e}){const n=Be(),i=e.external_ids;if(!i)return null;const o=[];return i.cbdb_id&&o.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${i.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:r("link-fg"),border:`1px solid ${r("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${r("link-fg")}08`},title:n.common.cbdbTitle,children:["CBDB ",i.cbdb_id]},"cbdb")),o.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:o})}function Eg({works:e,transport:n,onNavigate:i,renderLink:o}){const s=Be(),{convert:a}=Ve(),l=gt(),[d,c]=f.useState(new Map);f.useEffect(()=>{if(!n)return;let u=!1;const h=e.map(j=>j.work_id);return(async()=>{const j=new Map;if(n.getEntriesByIds)try{const k=await n.getEntriesByIds(h);let w=!0;for(let v=0;v<h.length;v++){const C=k[v];C!=null&&C.title?j.set(h[v],C.title):C!=null&&C.primary_name?j.set(h[v],C.primary_name):w=!1}if(w)return j}catch{}const b=[...h],S=8,y=new Array(S).fill(0).map(async()=>{for(;b.length;){const k=b.shift();if(!k)break;if(!j.has(k))try{if(n.getEntry){const C=await n.getEntry(k);if(C!=null&&C.title){j.set(k,C.title);continue}}const w=await n.getItem(k),v=w&&(w.title||w.primary_name)||k;j.set(k,v)}catch{j.set(k,k)}}});return await Promise.all(y),j})().then(j=>{u||c(j)}),()=>{u=!0}},[e,n]);const p=new Map;for(const u of e){const h=u.role||"";p.has(h)||p.set(h,[]),p.get(h).push(u)}const g=["撰","編","注","輯","集","校","評","譯","述","作",""],m=[...p.keys()].sort((u,h)=>{const x=g.indexOf(u),j=g.indexOf(h);return x===-1&&j===-1?u.localeCompare(h):x===-1?1:j===-1?-1:x-j});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:r("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:r("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),m.map(u=>{const h=p.get(u);return t.jsxs("div",{style:{marginBottom:"8px"},children:[u&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"2px"},children:[a(u)," ",t.jsxs("span",{style:{color:r("desc-fg")},children:["(",h.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:u?"16px":"0",listStyle:u?"disc":"none",fontSize:"14px",lineHeight:1.8},children:h.map((x,j)=>{const b=a(d.get(x.work_id)||x.work_id);return o?t.jsx("li",{children:o(x.work_id,b)},j):i?t.jsx("li",{children:t.jsx("a",{href:l(x.work_id),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),i(x.work_id))},style:{color:r("link-fg"),textDecoration:"underline",cursor:"pointer"},children:b})},j):t.jsx("li",{children:b},j)})})]},u)})]})}const kc=({data:e,transport:n,onNavigate:i,renderLink:o,headerExtra:s,hideHeader:a})=>{var m;const l=Be(),{convert:d}=Ve();let c=!1;try{c=Re.extractStatus(e.id)==="draft"}catch{}const p=Ng(e),g=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:r("fg")},children:[d(e.primary_name),t.jsx(Tg,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:r("type-entity"),border:`1px solid color-mix(in srgb, ${r("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${r("type-entity")} 3%, transparent)`},children:l.indexType.entity}),g&&e.subtype!=="people"&&t.jsx("span",{children:g}),c&&t.jsx("span",{style:{padding:"1px 6px",background:r("warn-bg"),border:`1px solid ${r("warn-border")}`,borderRadius:"2px",color:r("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:r("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:r("widget-bg"),border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:l.common.entityPlaceholderNote}),e.alt_names&&e.alt_names.length>0&&t.jsx(Rg,{alt_names:e.alt_names}),t.jsx(Ig,{data:e}),((m=e.description)==null?void 0:m.text)&&t.jsx("p",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:d(e.description.text)}),e.works&&e.works.length>0&&t.jsx(Eg,{works:e.works,transport:n,onNavigate:i,renderLink:o})]})},Lg=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function Ag(e){const n=e.search(Lg);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const wc={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 i=e,o="",s=n;if(e&&typeof n=="string"&&(n===e||n===Mg(e))){const[a,l]=Ag(n);l&&(i=encodeURI(a),s=a,o=l)}return t.jsxs(t.Fragment,{children:[t.jsx("a",{href:i,target:i!=null&&i.startsWith("http")?"_blank":void 0,rel:i!=null&&i.startsWith("http")?"noopener noreferrer":void 0,style:{color:r("link")},children:s}),o]})},code:({children:e})=>t.jsx("code",{style:{background:r("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function Mg(e){try{return decodeURI(e)}catch{return e}}const Pg={...wc,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},qt=({text:e,plainStrong:n,style:i,className:o})=>{const{convert:s}=Ve(),a=n?Pg:wc;return t.jsx("div",{className:o,style:i,children:t.jsx(Wu,{remarkPlugins:[Fu],components:a,children:s(e)})})};function Sc(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 Bg={book:r("type-book"),work:r("type-work"),collection:r("type-collection"),entity:r("type-entity")};function Og({type:e}){const n=Be();return t.jsx("span",{style:Sc(Bg[e]),children:n.indexType[e]})}function Wg({isDraft:e}){const n=Be(),i=r(e?"status-draft":"status-official");return t.jsx("span",{style:Sc(i),children:e?n.status.draft:n.status.official})}function Fg({id:e}){const n=Be(),[i,o]=f.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:r("desc-fg"),background:r("bg-subtle"),border:`1px solid ${r("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:r("fg")},children:e}),t.jsx("span",{onClick:s,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function Tt({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:r("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function Pt({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:r("fg")},children:n})]})}function _c({authors:e,type:n,onNavigate:i,renderLink:o}){const{convert:s}=Ve();return t.jsx("span",{style:{fontSize:"14px",color:r("fg"),lineHeight:1.6},children:e.map((a,l)=>{const d=s(a.name),c=a.entity_id?t.jsx(Lt,{id:a.entity_id,label:d,onNavigate:i,renderLink:o}):t.jsx("span",{style:{fontWeight:500},children:d});return t.jsxs("span",{children:[l>0&&t.jsx("span",{style:{color:r("desc-fg"),margin:"0 4px"},children:"·"}),a.dynasty&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:["〔",s(a.dynasty),"〕"]}),c,a.role&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(a.role)]})]},l)})})}function Lt({id:e,label:n,onNavigate:i,renderLink:o}){const s=gt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("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 Hg({id:e,title:n,edition:i,type:o,isDraft:s,authors:a,volumeText:l,meta:d,headerExtra:c,onNavigate:p,renderLink:g}){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:r("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,i&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:i}),l&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:r("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(Og,{type:o}),t.jsx(Wg,{isDraft:s}),t.jsx(Fg,{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(_c,{authors:a,type:o,onNavigate:p,renderLink:g}),d]})]})}function $c({items:e,label:n,showMeta:i,onNavigate:o,renderLink:s}){const a=Be(),{convert:l}=Ve();if(!e.length)return null;const[d,c]=f.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(Tt,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((p,g)=>{const m=d===g;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...m?{boxShadow:r("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(m?null:g),style:{padding:"8px 12px",background:r("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:r("fg")},children:l(p.source)}),!m&&i&&p.title_info&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l(p.title_info)}),p.source_bid&&t.jsx("span",{onClick:u=>u.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(Lt,{id:p.source_bid,label:a.action.view,onNavigate:o,renderLink:s})})]}),m&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${r("widget-border")}`},children:[i&&(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(Pt,{label:a.label.titleInfo,children:l(p.title_info)}),p.author_info&&t.jsx(Pt,{label:a.label.authorInfo,children:l(p.author_info)}),p.edition&&t.jsx(Pt,{label:a.label.edition,children:l(p.edition)})]}),p.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:r("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 ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:r("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 ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:a.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:l(p.additional_comment)})]})]})]},g)})})]})}function Dg({items:e,onNavigate:n,renderLink:i}){const o=Be();return t.jsx($c,{items:e,label:o.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function Cc({items:e,onNavigate:n,renderLink:i}){const o=Be();return t.jsx($c,{items:e,label:o.section.emendated,onNavigate:n,renderLink:i})}function zc({label:e,items:n}){const{convert:i}=Ve();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((o,s)=>{const a=typeof o=="string"?o:o.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:i(a)},s)})})]}):null}function Ug({items:e}){const n=Be();return t.jsx(zc,{label:n.section.aliases,items:e})}function Vg({items:e}){const n=Be();return t.jsx(zc,{label:n.section.attachedTexts,items:e})}function Gg({items:e}){const n=Be(),{convert:i}=Ve();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((o,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:r("fg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:["《",i(o.book_title),"》",o.n_juan!=null&&t.jsxs("span",{style:{color:r("desc-fg"),fontSize:"12px"},children:[o.n_juan,n.unit.juan]})]},s))})]}):null}function Yg({items:e}){const n=Be(),{convert:i}=Ve();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{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:r("widget-border")}}),e.map((o,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:r("primary"),border:`1.5px solid ${r("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:r("fg")},children:i(o.name)}),o.description&&t.jsx("span",{style:{fontSize:"12px",color:r("desc-fg"),marginLeft:"8px"},children:i(o.description)})]},s))]})]}):null}function Kg({items:e}){const n=Be(),{convert:i}=Ve();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((o,s)=>t.jsxs("div",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:r("desc-fg")},children:"·"}),i(o)]},s))})]}):null}function _a({title:e,ids:n,transport:i,onNavigate:o,renderLink:s}){const{convert:a}=Ve(),[l,d]=f.useState([]);return f.useEffect(()=>{if(!n.length){d([]);return}if(!i){d(n.map(p=>({id:p})));return}let c=!1;return Promise.all(n.map(p=>i.getItem(p).then(g=>({id:p,title:g?g.title:void 0,edition:g?g.edition:void 0,type:g?g.type:void 0})).catch(()=>({id:p})))).then(p=>{c||d(p)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(Tt,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:r("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 ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),transition:"border-color 0.15s"},children:t.jsx(Lt,{id:c.id,label:p,onNavigate:o,renderLink:s})},c.id)})})]}):null}function Tr({book:e,onNavigate:n,renderLink:i}){const o=Be(),{convert:s}=Ve(),[a,l]=f.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 ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:r("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:d&&!a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(Lt,{id:e.id,label:c,onNavigate:n,renderLink:i})}),d&&t.jsx("span",{onClick:()=>l(p=>!p),style:{cursor:"pointer",fontSize:"10px",color:r("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:a?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:a?o.action.expand:o.action.collapse,children:"▼"})]}),d&&!a&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(Co,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function qg({ids:e,workData:n,transport:i,onNavigate:o,renderLink:s,footer:a}){const l=Be(),{convert:d}=Ve(),[c,p]=f.useState([]);if(f.useEffect(()=>{if(!e.length){p([]);return}if(!i){p(e.map(j=>({id:j})));return}let x=!1;return Promise.all(e.map(j=>i.getItem(j).then(b=>({id:j,title:b?b.title:void 0,edition:b?b.edition:void 0,resources:b?b.resources:void 0,resource_groups:b?b.resource_groups:void 0})).catch(()=>({id:j})))).then(j=>{x||p(j)}),()=>{x=!0}},[e,i]),!e.length)return null;const g=c.length?c:e.map(x=>({id:x})),m=new Map(g.map(x=>[x.id,x])),u=n==null?void 0:n.version_graph,h=Xg(e,u,l.common.otherVersions);return t.jsxs(t.Fragment,{children:[t.jsxs(Tt,{children:[l.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),a,h.useGrouping?t.jsxs(t.Fragment,{children:[h.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:h.coreIds.map(x=>{const j=m.get(x);return j?t.jsx(Tr,{book:j,onNavigate:o,renderLink:s},x):null})}),h.groupedIds.map(x=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${r("widget-border")}`,borderRadius:6,background:r("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:r("fg"),userSelect:"none"},children:[d(x.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:r("desc-fg"),fontWeight:400},children:["(",x.ids.length,")"]}),x.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:r("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(j=>{const b=m.get(j);return b?t.jsx(Tr,{book:b,onNavigate:o,renderLink:s},j):null})})]},x.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:g.map(x=>t.jsx(Tr,{book:x,onNavigate:o,renderLink:s},x.id))})]})}function Xg(e,n,i){var S,y;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(S=n.collections)==null?void 0:S[n.default_collection],s=(o==null?void 0:o.groups)??[],a=(o==null?void 0:o.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]),g=k=>{if(p.has(k))return!0;const w=n.node_groups[k];return w!=null&&c.has(w)},m=[],u=new Map,h=[];for(const k of e)if(!((y=n.excluded_books)!=null&&y.includes(k)))if(g(k))m.push(k);else{const w=n.node_groups[k];w?(u.has(w)||u.set(w,[]),u.get(w).push(k)):h.push(k)}if(h.length+[...u.values()].reduce((k,w)=>k+w.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const j=new Map((n.groups??[]).map(k=>[k.id,k])),b=[...u.entries()].map(([k,w])=>{const v=j.get(k);return{id:k,label:(v==null?void 0:v.label)??k,description:v==null?void 0:v.description,ids:w}});return h.length>0&&b.push({id:"__other__",label:i,description:void 0,ids:h}),{useGrouping:!0,coreIds:m,groupedIds:b}}function Zg({workData:e,onNavigate:n,renderLink:i}){var l,d,c,p;const o=Be(),{convert:s}=Ve(),a=!!((l=e.description)!=null&&l.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:r("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:a?`1px solid ${r("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:t.jsx(Lt,{id:e.id,label:s(e.title),onNavigate:n,renderLink:i})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:r("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:r("desc-fg")},children:[Ln(e.juan_count.number),o.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(_c,{authors:e.authors,type:"work",onNavigate:n,renderLink:i})})]}),a&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(qt,{text:e.description.text,style:{fontSize:"13px",color:r("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(Pt,{label:o.label.parentWork,children:t.jsx(Lt,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function Jg({items:e,onNavigate:n,renderLink:i}){const o=Be(),{convert:s}=Ve();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, ${r("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${r("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:r("type-collection")},children:o.indexType.collection}),t.jsx(Lt,{id:a.id,label:s(a.title)||a.id,onNavigate:n,renderLink:i}),a.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"2px"},children:zt(o.catalog.volume,{n:a.volume_index})})]},a.id))}):null}const Bo=({data:e,id:n,transport:i,onNavigate:o,renderLink:s,headerExtra:a,relatedBooksFooter:l,className:d,style:c})=>{var N,M,O,L,D,q,J,se;const p=Be(),{convert:g}=Ve(),[m,u]=f.useState(null),[h,x]=f.useState(!1),[j,b]=f.useState(null),[S,y]=f.useState(null),[k,w]=f.useState([]),v=e||m;if(f.useEffect(()=>{if(e||!n||!i)return;let U=!1;return x(!0),b(null),i.getItem(n).then(K=>{U||(K?u(K):b(p.misc.notFoundEntry))}).catch(K=>{U||b(K instanceof Error?K.message:p.misc.loadFailed)}).finally(()=>{U||x(!1)}),()=>{U=!0}},[e,n,i]),f.useEffect(()=>{if(!v||!i){y(null),w([]);return}let U=!1;const K=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(K?i.getItem(K).then(Z=>{!U&&Z&&Z.type==="work"&&y(Z)}).catch(()=>{}):y(null),v.type==="book"){const Z=v;Z.contained_in&&Z.contained_in.length>0?Promise.all(Z.contained_in.map(oe=>{const ye=typeof oe=="string"?oe:oe.id,Le=typeof oe=="string"?void 0:oe.volume_index;return i.getItem(ye).then(Me=>({id:ye,title:Me&&Me.title||ye,volume_index:Le})).catch(()=>({id:ye,title:ye,volume_index:Le}))})).then(oe=>{U||w(oe)}):w([])}else w([]);return()=>{U=!0}},[v,i]),h)return t.jsx("div",{className:d,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((U,K)=>t.jsx("div",{style:{height:K===1?"32px":"16px",width:`${U}px`,background:r("widget-border"),borderRadius:"4px",opacity:.4}},K))})});if(j)return t.jsx("div",{className:d,style:{...c,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:j});if(!v)return null;if(v.type==="entity")return t.jsx("div",{className:d,style:c,children:t.jsx(kc,{data:v,transport:i,onNavigate:o,renderLink:s,headerExtra:a})});const C=v.type==="book"?v:null,_=v.type==="collection"?v:null,$=v.type==="work"?v:null;let A=!1;try{A=Re.extractStatus(v.id)==="draft"}catch{}let R="";v.measure_info?R=g(v.measure_info):(N=v.juan_count)!=null&&N.number?R=Ln(v.juan_count.number)+p.unit.juan:(M=v.juan_count)!=null&&M.description&&(R=g(v.juan_count.description));const z=[];return(O=v.publication_info)!=null&&O.year&&z.push(t.jsx(Pt,{label:p.label.year,children:v.publication_info.year},"year")),(L=v.current_location)!=null&&L.name&&z.push(t.jsx(Pt,{label:p.label.currentLocation,children:g(v.current_location.name)},"loc")),(D=v.page_count)!=null&&D.description&&z.push(t.jsx(Pt,{label:p.label.pageCount,children:v.page_count.description},"page")),C!=null&&C.edition&&z.push(t.jsx(Pt,{label:p.label.edition,children:g(C.edition)},"ver")),$!=null&&$.parent_work&&z.push(t.jsx(Pt,{label:p.label.parentWork,children:t.jsx(Lt,{id:$.parent_work.id,label:g($.parent_work.title),onNavigate:o,renderLink:s})},"pw")),$!=null&&$.parent_works&&$.parent_works.length>0&&!$.parent_work&&z.push(t.jsx(Pt,{label:p.label.parentWork,children:$.parent_works.map((U,K)=>t.jsxs("span",{children:[K>0&&"、",t.jsx(Lt,{id:U,onNavigate:o,renderLink:s})]},U))},"pws")),t.jsxs("div",{className:d,style:c,children:[t.jsx(Hg,{id:v.id,title:g(v.title),edition:v.edition?g(v.edition):void 0,type:v.type,isDraft:A,authors:v.authors,volumeText:R,meta:z,headerExtra:a,onNavigate:o,renderLink:s}),((q=v.description)==null?void 0:q.text)&&t.jsx(qt,{text:v.description.text,style:{fontSize:"14px",color:r("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),v.appendix&&v.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:v.appendix.map((U,K)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:r("bg-subtle"),borderRadius:4,border:`1px solid ${r("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:r("muted")},children:g(U.title)}),t.jsx(qt,{text:U.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:r("fg")}})]},K))}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{children:p.section.containedIn}),t.jsx(Jg,{items:k,onNavigate:o,renderLink:s})]}),S&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{children:p.section.belongsToWork}),t.jsx(Zg,{workData:S,onNavigate:o,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Gg,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Ug,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(Vg,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(Dg,{items:v.indexed_by,onNavigate:o,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(Cc,{items:v.emendated_by,onNavigate:o,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Tt,{children:p.section.resources}),t.jsx(Co,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:o,renderLink:s})]}),(C==null?void 0:C.location_history)&&C.location_history.length>0&&t.jsx(Yg,{items:C.location_history}),(_==null?void 0:_.history)&&_.history.length>0&&t.jsx(Kg,{items:_.history}),(C==null?void 0:C.related_books)&&C.related_books.length>0&&t.jsx(_a,{title:p.section.relatedVersions,ids:C.related_books,transport:i,onNavigate:o,renderLink:s}),(_==null?void 0:_.books)&&_.books.length>0&&t.jsx(_a,{title:p.section.containedBooks,ids:_.books,transport:i,onNavigate:o,renderLink:s}),(_==null?void 0:_.contained_works)&&_.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(Tt,{children:[p.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",_.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:_.contained_works.map(U=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx(Lt,{id:U.id,label:g(U.title),onNavigate:o,renderLink:s})},U.id))})]}),(((J=$==null?void 0:$.books)==null?void 0:J.length)||0)+(((se=$==null?void 0:$.collections)==null?void 0:se.length)||0)>0&&t.jsx(qg,{ids:[...($==null?void 0:$.books)||[],...($==null?void 0:$.collections)||[]],workData:$??void 0,transport:i,onNavigate:o,renderLink:s,footer:l}),($==null?void 0:$.related_works)&&$.related_works.length>0&&(()=>{const U=[],K=$.related_works.filter(Se=>Se.relation==="part_of"),Z=$.related_works.filter(Se=>Se.relation==="has_part"),oe=$.related_works.filter(Se=>Se.relation==="has_adaptation"),ye=$.related_works.filter(Se=>Se.relation==="text_carried_by"),Le=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),Me=$.related_works.filter(Se=>!Se.relation||!Le.has(Se.relation));return K.length>0&&U.push({label:p.section.belongsToWork,items:K}),Z.length>0&&U.push({label:p.section.containedWorks,items:Z}),oe.length>0&&U.push({label:p.section.adaptations,items:oe}),ye.length>0&&U.push({label:p.section.derivativeWorks,items:ye}),Me.length>0&&U.push({label:p.section.relatedWorks,items:Me}),U.map(Se=>t.jsxs("div",{children:[t.jsxs(Tt,{children:[Se.label,t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400},children:["(",Se.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:Se.items.map(le=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg")},children:t.jsx(Lt,{id:le.id,label:g(le.title),onNavigate:o,renderLink:s})},le.id))})]},Se.label))})()]})};function Qg({data:e}){const n=Be(),{convert:i}=Ve(),{stats:o}=e,s=o.processed_volumes??o.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:r("fg"),margin:"0 0 8px"},children:i(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"6px"},children:i(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:r("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:r("fg")},children:e.total_volumes})," ",n.unit.volume]}),a!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:r("fg")},children:s})," ",n.unit.volume," (",a,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:r("fg")},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:r("fg")},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:r("missing-fg")},children:o.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:r("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function ef({sections:e,activeSection:n,onSelect:i}){const o=Be();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:$a(n===null),children:o.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:$a(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 $a(e){return{padding:"4px 12px",border:e?`1px solid ${r("primary")}`:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${r("primary")} 8%, transparent)`:"transparent",color:r(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function tf({id:e,label:n,onNavigate:i,renderLink:o}){const s=gt();return o?t.jsx(t.Fragment,{children:o(e,n)}):i?t.jsx("a",{href:s(e),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i(e))},style:{color:r("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${r("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:r("desc-fg")},children:n||e})}function nf(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=e[0],o=e[e.length-1];return o-i+1===e.length?`${i}–${o}`:e.length<=3?e.join(", "):`${i}–${o} (${e.length}${n})`}function Ca({book:e,onNavigate:n,renderLink:i,showVolumes:o}){const s=Be(),{convert:a}=Ve(),l=e.book_id||e.work_id,d=o&&e.volumes.length>0?nf(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 ${r("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[o&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:r("desc-fg"),textAlign:"right"},children:d}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:r("fg")},children:[a(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(p=>a(p)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),fontWeight:400,marginLeft:"8px"},children:a(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:r(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),l&&t.jsx(tf,{id:l,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:i}),!l&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const Oo=({data:e,collectionId:n,transport:i,onNavigate:o,renderLink:s,className:a,style:l})=>{const d=Be(),[c,p]=f.useState(null),[g,m]=f.useState(!1),[u,h]=f.useState(null),[x,j]=f.useState(null),[b,S]=f.useState(""),y=e||c;f.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let _=!1;return m(!0),h(null),i.getCollectionCatalog(n).then($=>{_||($?p($):h(d.catalog.notFound))}).catch($=>{_||h($ instanceof Error?$.message:d.catalog.loadFailed)}).finally(()=>{_||m(!1)}),()=>{_=!0}},[e,n,i,d]);const k=(y==null?void 0:y.sections)&&y.sections.length>0,w=f.useMemo(()=>{if(!y)return!1;if(y.volume_index&&Object.keys(y.volume_index).length>0)return!0;const _=y.books.map(A=>A.volumes[0]).filter(A=>A!=null);return new Set(_).size<_.length},[y]),v=f.useMemo(()=>{if(!y)return[];let _=y.books;if(x&&(_=_.filter($=>$.section===x)),b.trim()){const $=b.trim().toLowerCase();_=_.filter(A=>A.title.toLowerCase().includes($)||A.sub_items&&A.sub_items.some(R=>R.toLowerCase().includes($))||A.edition&&A.edition.toLowerCase().includes($))}return _},[y,x,b]),C=f.useMemo(()=>{if(!w)return null;const _=[],$=new Map;for(const R of v){if(!R.volumes||R.volumes.length===0)continue;const z=R.volumes[0];$.has(z)||$.set(z,[]),$.get(z).push(R)}const A=[...$.keys()].sort((R,z)=>R-z);for(const R of A)_.push({volume:R,books:$.get(R)});return _},[v,w]);return g?t.jsx("div",{className:a,style:{...l,padding:"24px"},children:t.jsx("div",{style:{color:r("desc-fg"),fontSize:"13px"},children:d.catalog.loading})}):u?t.jsx("div",{className:a,style:{...l,padding:"24px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:u}):y?t.jsxs("div",{className:a,style:l,children:[t.jsx(Qg,{data:y}),k&&t.jsx(ef,{sections:y.sections,activeSection:x,onSelect:j}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:d.search.searchBookName,value:b,onChange:_=>S(_.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:r("desc-fg")},children:[v.length," ",d.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[C?C.map((_,$)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:r("bg"),borderBottom:`1px solid ${r("widget-border")}`,fontSize:"12px",fontWeight:600,color:r("desc-fg"),position:"sticky",top:0,zIndex:1},children:zt(d.catalog.volume,{n:_.volume})}),_.books.map((A,R)=>t.jsx(Ca,{book:A,onNavigate:o,renderLink:s,showVolumes:A.volumes.length>1},`${_.volume}-${R}`))]},`${_.volume}-${$}`)):v.map((_,$)=>t.jsx(Ca,{book:_,onNavigate:o,renderLink:s,showVolumes:!0},$)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:d.catalog.noMatch})]})]}):null},Rr=e=>e?e.catch(()=>null):Promise.resolve(null);function Nc(e){const n=new Map;function i(o){var a;let s=n.get(o);return s||(s=Rr((a=e.getTextManifest)==null?void 0:a.call(e,o)).then(l=>{const d=l&&Array.isArray(l.versions)&&l.versions.length>0?l:null;return d||n.delete(o),d}),n.set(o,s)),s}return{getManifest(o){return Re.isSafeSegment(o)?i(o):Promise.resolve(null)},async getIndex(o,s){return!Re.isSafeSegment(o)||!Re.isSafeSegment(s)||!e.getTextIndex?null:Rr(e.getTextIndex(o,s))},async getChapter(o,s,a,l){return!Re.isSafeSegment(o)||!Re.isSafeSegment(s)||!Re.isSafeSegment(a)||!e.getChapter?null:Rr(e.getChapter(o,s,a,l))}}}const gn=()=>{const{t:e}=ae(),[n,i]=f.useState(1);return f.useEffect(()=>{const o=setInterval(()=>i(s=>s>=3?1:s+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:r("desc-fg"),fontSize:"14px"},children:e("common.loading")+".".repeat(n)})},Ir=String.raw`https?:\/\/[^\s()()<>"]+`,rf=new RegExp(String.raw`\[([^\]\n]+)\]\((${Ir})\)`+String.raw`|(《[^》\n]+》)\s?[((](${Ir})[))]`+`|(${Ir})`,"g");function of(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function sf(e){const n=[];let i=0;for(const o of e.matchAll(rf)){const s=o.index??0;s>i&&n.push({text:e.slice(i,s)}),o[1]!==void 0?n.push({text:o[1],url:o[2]}):o[3]!==void 0?n.push({text:o[3],url:o[4]}):n.push({text:of(o[5]),url:o[5]}),i=s+o[0].length}return i<e.length&&n.push({text:e.slice(i)}),n}function Tc({text:e,convert:n,className:i="bim-rd-link"}){return t.jsx(t.Fragment,{children:sf(e).map((o,s)=>o.url?t.jsx("a",{className:i,href:o.url,target:"_blank",rel:"noopener noreferrer",children:n(o.text)},s):t.jsx(f.Fragment,{children:n(o.text)},s))})}const Rc="(min-width: 1100px)",Ci="(max-width: 719px)",Ic="(max-width: 859px)",af=`${Ci}, (pointer: coarse)`,Mt=r("reader-top"),lf="48px",Ec=`
|
|
146
146
|
.bim-rd {
|
|
147
147
|
position: relative;
|
|
148
148
|
background: ${r("page-bg")};
|
|
149
149
|
color: ${r("ink")};
|
|
150
150
|
font-family: ${r("font-ui")};
|
|
151
|
-
--bimrd-bar-h: ${
|
|
151
|
+
--bimrd-bar-h: ${lf};
|
|
152
152
|
/* 设置侧栏的暖黄:与朱/靛/墨三套主色都不冲,只做底色与选中态 */
|
|
153
153
|
--bimrd-warm: ${r("reader-warm")};
|
|
154
154
|
--bimrd-warm-bg: color-mix(in srgb, var(--bimrd-warm) 8%, ${r("page-bg")});
|
|
@@ -182,7 +182,7 @@
|
|
|
182
182
|
|
|
183
183
|
/* ── 工具条:文字 + 图标,不画按钮外框 ── */
|
|
184
184
|
.bim-rd-bar {
|
|
185
|
-
position: sticky; top: ${
|
|
185
|
+
position: sticky; top: ${Mt}; z-index: 30;
|
|
186
186
|
height: var(--bimrd-bar-h);
|
|
187
187
|
display: flex; align-items: center; gap: 16px;
|
|
188
188
|
padding: 0 20px;
|
|
@@ -238,14 +238,14 @@
|
|
|
238
238
|
display: grid;
|
|
239
239
|
grid-template-columns: auto auto minmax(0, 1fr) auto;
|
|
240
240
|
align-items: start;
|
|
241
|
-
min-height: calc(100vh - ${
|
|
241
|
+
min-height: calc(100vh - ${Mt} - var(--bimrd-bar-h));
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/* 目录:宽屏是侧栏 */
|
|
245
245
|
.bim-rd-toc {
|
|
246
246
|
grid-column: 1;
|
|
247
|
-
position: sticky; top: calc(${
|
|
248
|
-
width: 248px; height: calc(100vh - ${
|
|
247
|
+
position: sticky; top: calc(${Mt} + var(--bimrd-bar-h));
|
|
248
|
+
width: 248px; height: calc(100vh - ${Mt} - var(--bimrd-bar-h));
|
|
249
249
|
overflow-y: auto; overscroll-behavior: contain;
|
|
250
250
|
padding: 0 10px 40px;
|
|
251
251
|
background: ${r("sidebar-bg")};
|
|
@@ -292,8 +292,8 @@
|
|
|
292
292
|
/* 书影:正文左侧 */
|
|
293
293
|
.bim-rd-img {
|
|
294
294
|
grid-column: 2;
|
|
295
|
-
position: sticky; top: calc(${
|
|
296
|
-
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${
|
|
295
|
+
position: sticky; top: calc(${Mt} + var(--bimrd-bar-h));
|
|
296
|
+
width: clamp(300px, 32vw, 560px); height: calc(100vh - ${Mt} - var(--bimrd-bar-h) - var(--bimrd-img-lead, 0px));
|
|
297
297
|
padding: 16px 0 16px 20px;
|
|
298
298
|
display: flex; flex-direction: column; gap: 8px;
|
|
299
299
|
}
|
|
@@ -304,7 +304,7 @@
|
|
|
304
304
|
display: flex; align-items: center; justify-content: center; overflow: hidden;
|
|
305
305
|
}
|
|
306
306
|
.bim-rd-img-fig { position: relative; margin: 0; max-width: 100%; max-height: 100%; }
|
|
307
|
-
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${
|
|
307
|
+
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${Mt} - var(--bimrd-bar-h) - var(--bimrd-img-lead, 0px) - 80px); object-fit: contain; }
|
|
308
308
|
.bim-rd-img-fig svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
309
309
|
.bim-rd-img-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center; font-size: 13px; color: ${r("meta-fg")}; }
|
|
310
310
|
.bim-rd-img-empty b { font-size: 15px; font-weight: 500; color: ${r("quiet-fg")}; }
|
|
@@ -400,7 +400,7 @@
|
|
|
400
400
|
|
|
401
401
|
/* 竖排(预留):只在宿主打开 allowVertical 时可切换 */
|
|
402
402
|
.bim-rd-vertical .bim-rd-prose {
|
|
403
|
-
writing-mode: vertical-rl; max-height: calc(100vh - ${
|
|
403
|
+
writing-mode: vertical-rl; max-height: calc(100vh - ${Mt} - var(--bimrd-bar-h) - 120px);
|
|
404
404
|
overflow-x: auto; text-align: start;
|
|
405
405
|
}
|
|
406
406
|
|
|
@@ -455,7 +455,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
455
455
|
.bim-rd-sheet-head .bim-rd-t { margin-left: auto; min-width: 44px; min-height: 44px; justify-content: center; letter-spacing: 0; }
|
|
456
456
|
.bim-rd-sheet-img { display: flex; flex-direction: column; gap: 8px; min-height: 40vh; }
|
|
457
457
|
.bim-rd-sheet-img .bim-rd-img-fig img { max-height: 60vh; }
|
|
458
|
-
@media ${
|
|
458
|
+
@media ${Ic} {
|
|
459
459
|
.bim-rd[data-bb] .bim-rd-text { padding-bottom: calc(56px + 64px + env(safe-area-inset-bottom, 0px)); }
|
|
460
460
|
/* 底栏上已有的,工具条上不再重复(目录、字号) */
|
|
461
461
|
.bim-rd[data-bb] .bim-rd-bb-dup { display: none !important; }
|
|
@@ -466,8 +466,8 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
466
466
|
/* ── 右侧「阅读设置」侧栏(overview#463):≥860px 是右栏,窄屏改走底栏的底部抽屉;分组 文字/标注/版面 ── */
|
|
467
467
|
.bim-rd-set {
|
|
468
468
|
grid-column: 4; grid-row: 1;
|
|
469
|
-
position: sticky; top: calc(${
|
|
470
|
-
width: 264px; height: calc(100vh - ${
|
|
469
|
+
position: sticky; top: calc(${Mt} + var(--bimrd-bar-h));
|
|
470
|
+
width: 264px; height: calc(100vh - ${Mt} - var(--bimrd-bar-h));
|
|
471
471
|
overflow-y: auto; overscroll-behavior: contain;
|
|
472
472
|
padding: 0 16px 40px;
|
|
473
473
|
/* 比目录栏(灰)暖一档:纸色里调入一点暖黄,与页面同色系又能分出层次 */
|
|
@@ -500,7 +500,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
500
500
|
|
|
501
501
|
/* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
|
|
502
502
|
A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
|
|
503
|
-
@media ${
|
|
503
|
+
@media ${af} {
|
|
504
504
|
.bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
|
|
505
505
|
.bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
|
|
506
506
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
@@ -513,7 +513,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
/* ── 中屏以下:目录改抽屉 ── */
|
|
516
|
-
@media not all and ${
|
|
516
|
+
@media not all and ${Rc} {
|
|
517
517
|
.bim-rd-toc {
|
|
518
518
|
position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
|
|
519
519
|
width: min(86vw, 320px);
|
|
@@ -527,7 +527,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
527
527
|
}
|
|
528
528
|
|
|
529
529
|
/* ── 窄屏:书影收起,只留正文 ── */
|
|
530
|
-
@media ${
|
|
530
|
+
@media ${Ci} {
|
|
531
531
|
.bim-rd-bar { padding: 0 12px; gap: 10px; }
|
|
532
532
|
.bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
|
|
533
533
|
/* 工具条放不下时(版本、自然段、标出作品链接都在)在条内左右滑,不撑宽页面 */
|
|
@@ -722,7 +722,7 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
722
722
|
}
|
|
723
723
|
|
|
724
724
|
/* ── 手机:正文两侧不留白(放在对读、界栏规则之后才压得过它们) ── */
|
|
725
|
-
@media ${
|
|
725
|
+
@media ${Ci} {
|
|
726
726
|
.bim-rd-text, .bim-rd[data-warp="true"] .bim-rd-text { padding-left: 0; padding-right: 0; }
|
|
727
727
|
.bim-rd-col, :root[data-layout="boxed"] .bim-rd-col { padding-left: 14px; padding-right: 14px; }
|
|
728
728
|
:root[data-layout="boxed"] .bim-rd-col { border-left: 0; border-right: 0; }
|
|
@@ -733,17 +733,17 @@ button.bim-rd-pg:hover { border-color: ${r("accent")}; }
|
|
|
733
733
|
.guji-page-indicator { opacity: 0.55; transition: opacity 0.15s; outline: none; }
|
|
734
734
|
.guji-page-indicator:hover, .guji-page-indicator:focus-visible { opacity: 1; }
|
|
735
735
|
.guji-page-indicator:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 1px; border-radius: 3px; }
|
|
736
|
-
@media ${
|
|
737
|
-
`;function Bo(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>Bo(o,n))):!1}const _a=()=>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 sf({item:e,activeKey:n,onSelect:i,tabKey:o}){const{t:s}=ae(),a=Bo(e,n),[l,d]=f.useState(a||!!e.defaultExpanded);return f.useEffect(()=>{a&&d(!0)},[a]),f.useEffect(()=>{e.defaultExpanded&&d(!0)},[e.defaultExpanded]),e.selectable?t.jsxs("li",{children:[t.jsxs("div",{className:"bim-rd-ti-row",children:[t.jsx("button",{type:"button",className:"bim-rd-ti-tw","aria-expanded":l,"aria-label":s(l?"reader.tocCollapse":"reader.tocExpand"),tabIndex:-1,onClick:()=>d(c=>!c),children:t.jsx(_a,{})}),t.jsxs("button",{type:"button",className:`bim-rd-ti${e.inChapter?"":" bim-rd-ti-group"}`,"aria-current":e.key===n?"true":void 0,disabled:e.disabled,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>{d(!0),i(e.key)},onKeyDown:c=>{c.key==="ArrowRight"&&!l?(c.preventDefault(),d(!0)):c.key==="ArrowLeft"&&l&&(c.preventDefault(),d(!1))},children:[t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]})]}),l&&t.jsx(Kr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]}):t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>d(c=>!c),children:[t.jsx(_a,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),l&&t.jsx(Kr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Kr({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(sf,{item:s,activeKey:n,onSelect:i,tabKey:o},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:o===s.key?0:-1,onClick:()=>i(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 $a(e,n){var i;for(const o of e)if(o.key===n||Bo(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function Rc({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=ae(),a=o??s("reader.toc"),l=f.useRef(null),[d,c]=f.useState(null);f.useEffect(()=>{c(null)},[n]);const p=f.useMemo(()=>d||(n??$a(e,n)),[d,n,e]);f.useEffect(()=>{const m=l.current;if(!m)return;const u=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(u.length===0)return;const h=u.find(x=>x.dataset.rdTocKey===p)??u.find(x=>x.dataset.rdTocKey===$a(e,n))??u.find(x=>!x.disabled)??u[0];for(const x of u)x.tabIndex=x===h?0:-1}),f.useEffect(()=>{const m=l.current,u=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!u||!n)return;const h=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(j=>j.dataset.rdTocKey===n);if(!h)return;const x=h.getBoundingClientRect().top-u.getBoundingClientRect().top+u.scrollTop;(x<u.scrollTop+80||x>u.scrollTop+u.clientHeight-40)&&(u.scrollTop=Math.max(0,x-u.clientHeight/3))},[n]);const g=f.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const h=l.current;if(!h)return;const x=Array.from(h.querySelectorAll("[data-rd-toc-key]")).filter(y=>!y.disabled),j=x.indexOf(document.activeElement);let b=j;if(m.key==="ArrowDown"?b=Math.min(x.length-1,j+1):m.key==="ArrowUp"?b=Math.max(0,j-1):m.key==="Home"?b=0:m.key==="End"&&(b=x.length-1),b<0||b===j)return;m.preventDefault();const $=x[b];for(const y of x)y.tabIndex=-1;$.tabIndex=0,$.focus(),c($.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:g,children:t.jsx(Kr,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function Ca({page:e,crop:n}){var i;return!((i=e.boxes)!=null&&i.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:n?`${n.x} ${n.y} ${n.w} ${n.h}`:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,s)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:r("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},s))})}function af(e){const{boxes:n,width:i,height:o}=e;if(!(n!=null&&n.length)||!i||!o||e.boxFormat&&e.boxFormat!=="bim-charbox-v0")return null;let s=1/0,a=1/0,l=-1/0,d=-1/0;for(const h of n)[h.x,h.y,h.w,h.h].every(Number.isFinite)&&(s=Math.min(s,h.x),a=Math.min(a,h.y),l=Math.max(l,h.x+h.w),d=Math.max(d,h.y+h.h));if(!(l>s)||!(d>a))return null;const c=Math.min(i,o)*.03,p=Math.min(i,Math.max(0,s-c)),g=Math.min(o,Math.max(0,a-c)),m=Math.min(i,Math.max(0,l+c))-p,u=Math.min(o,Math.max(0,d+c))-g;return!(m>0)||!(u>0)||m>=i*.98&&u>=o*.98?null:{x:p,y:g,w:m,h:u}}function qr({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=ae(),[d,c]=f.useState(0),p=i??d,g=j=>{o?o(j):c(j)};if(f.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("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:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const m=Math.max(0,Math.min(e.length-1,p)),u=e[m],h=u.label??`${m+1}`,x=!a&&!s?af(u):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:h}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${u.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(Ca,{page:u,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:h}),width:u.width,height:u.height,loading:"lazy",decoding:"async"}),t.jsx(Ca,{page:u}),s==null?void 0:s(u,m)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:m===0,onClick:()=>g(m-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:u.label??`${m+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:m===e.length-1,onClick:()=>g(m+1),children:"›"})]})]})}function lf(e){return e==="lite"||e==="full"}const Qn=[.1,.9],Ic=[{key:"song",stack:null},{key:"kai",stack:'"Kaiti SC", "Kaiti TC", STKaiti, "KaiTi", "AR PL UKai CN", "Noto Serif CJK SC", serif'},{key:"system",stack:"var(--bim-font-ui)"}];function cf(e){var n;return((n=Ic.find(i=>i.key===e))==null?void 0:n.stack)??null}const Oo={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!1,pageIndicatorY:.33,bookTitleStyle:"bracket",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Ut=[15,16,17,18,20,22,24],Xr=18,Ec="bim-reader-prefs",Lc=2,df="bim-reading-mode";function pf(){const e={...Oo};try{const n=localStorage.getItem(Ec),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Ut.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(df))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily);const s=i.v===Lc;s&&typeof i.pageBreaks=="boolean"&&(e.pageBreaks=i.pageBreaks),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=Qn[0]&&i.pageIndicatorY<=Qn[1]&&(e.pageIndicatorY=i.pageIndicatorY),s&&(i.bookTitleStyle==="wavy"||i.bookTitleStyle==="bracket")&&(e.bookTitleStyle=i.bookTitleStyle),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function uf(e){try{localStorage.setItem(Ec,JSON.stringify({...e,v:Lc}))}catch{}}function ji(e,n){const i=e??Xr,o=Ut;let s=o.indexOf(i);return s<0&&(s=o.indexOf(Xr)),o[Math.max(0,Math.min(o.length-1,s+n))]}function Ac(){const[e,n]=f.useState(Oo);f.useEffect(()=>{n(pf())},[]);const i=f.useCallback(o=>{n(s=>{const a={...s,...o};return uf(a),a})},[]);return[e,i]}function Zr(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 Mc(e,n){if(!(!e||e.length===0))return(n!=null?e.find(i=>i.key===n):void 0)??e.find(i=>i.primary)??e[0]}function Pc(e){const n=[],i=o=>{for(const s of o){if(s.inChapter)continue;const a=!!s.children&&s.children.length>0;(!a||s.selectable)&&n.push(s),a&&i(s.children)}};return i(e),n}const za=()=>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"})}),mf=()=>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"})}),gf=()=>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"})}),Na=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),Ta=()=>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 Ra(e,n){if(!n)return;const i=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(i.length===0)return;const o=i[0],s=i[i.length-1],a=document.activeElement;e.shiftKey&&(a===o||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),o.focus())}function Ia(e,n){const[i,o]=f.useState(n);return f.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(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]),i}function ff({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(Bt),{t:s}=ae();if(!o)return null;const a=o.locale==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a,d=[{key:"orig",short:s("reader.scriptOrigShort"),title:s(i?"reader.scriptOrig":"reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",short:s("common.localeShortHant"),title:s("reader.scriptHant")},{key:"hans",short:s("common.localeShortHans"),title:s("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":s("reader.scriptQuick"),children:d.map((c,p)=>t.jsxs(f.Fragment,{children:[p>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":l===c.key,title:c.title,"aria-label":c.title,disabled:c.disabled,onClick:()=>{c.disabled||(n({scriptMode:c.key}),c.key==="hant"?o.setLocale("zh-Hant"):c.key==="hans"&&o.setLocale("zh-Hans"))},children:c.short})]},c.key))})}function $i({label:e,value:n,options:i,onPick:o,title:s}){return t.jsxs("div",{className:"bim-rd-sp-row",role:"group","aria-label":e,title:s,children:[t.jsx("span",{className:"bim-rd-sp-l",children:e}),t.jsx("span",{className:"bim-rd-sp-fs",children:i.map(a=>t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":n===a.key,title:a.title,disabled:a.disabled,onClick:()=>{a.disabled||o(a.key)},children:a.label},a.key))})]})}function hf({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(Bt),{t:s}=ae(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx($i,{label:s("reader.script"),value:l,options:[{key:"orig",label:s("reader.scriptOrig"),title:i?void 0:s("reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",label:s("reader.scriptHant")},{key:"hans",label:s("reader.scriptHans")}],onPick:d=>{n({scriptMode:d}),d==="hant"?o==null||o.setLocale("zh-Hant"):d==="hans"&&(o==null||o.setLocale("zh-Hans"))}})}function xf(e,n){if(!e)return;let i;for(const o of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(o.getBoundingClientRect().top<=n+8)i=o.id;else break;return i}function bf(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 i=e.querySelector(".bim-rd-col"),o=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(i!=null&&i.contains(l))&&!(d!=null&&d.closest(".bim-rd-src, .bim-rd-pager"))};if(!o(n.anchorNode)||!o(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function Bc({title:e,subtitle:n,toc:i,activeKey:o,tocActiveKey:s,onSelect:a,tocHeader:l,tocCaption:d,images:c,imagesLoading:p,renderImageOverlay:g,imagePanel:m="auto",prefs:u,onPrefsChange:h,paragraphToggle:x,properNameToggle:j=!0,allowVertical:b,origScriptAvailable:$=!0,byline:y,current:k,workLinkToggle:w,rail:v,onReportError:C,revisedAt:S,backHref:_,backLabel:R,bottomBar:z=!0,pager:N=!0,contentLoading:I=!1,pagerUnit:B,versions:O,currentVersionKey:A,onVersionChange:W,versionSource:G=!0,keepChapterOnVersionChange:oe=!1,customImagePanel:se,toolbarExtra:Y,settingsAnnotate:de,settingsLayout:ne,isWarpMode:ue,showPreserveMargins:ke=!0,children:Ae,className:he,style:$e}){const{t:L,convert:Me}=ae(),q=R??L("reader.back"),le=Me(B??L("reader.unitJuan")),ge=f.useId().replace(/:/g,""),H=`bim-rd-toc-${ge}`,Z=`bim-rd-text-${ge}`,Ne=f.useRef(null),ze=f.useRef(null),Fe=f.useRef(null),P=f.useRef(null),ie=Ia(zc,!0),Q=Ia(Nc,!1),X=z&&Q,[we,He]=f.useState(null),[Ke,Qe]=f.useState(!1),U=f.useRef(null),me=`bim-rd-set-${ge}`,Re=f.useRef(null),D=f.useRef(null),je=(K,De)=>{D.current=De,He(et=>et===K?null:K)},te=f.useCallback(()=>{var K;He(null),(K=D.current)==null||K.focus()},[]);f.useEffect(()=>{X||He(null)},[X]),f.useEffect(()=>{var K,De;we&&((De=(K=Re.current)==null?void 0:K.querySelector("button:not([disabled])"))==null||De.focus())},[we]);const[_e,Be]=f.useState("auto"),Ge=_e==="auto"?ie:_e==="open",Ye=!ie,it=!!se||!!c&&c.length>0,[st,T]=f.useState(m);f.useEffect(()=>{T(m)},[m]);const fe=st==="auto"?it||!!p:st==="open",be=f.useCallback(K=>{var De;Be("auto"),K&&((De=P.current)==null||De.focus())},[]),Le=()=>Be(Ge?"closed":"open");f.useEffect(()=>{if(!Ye||_e!=="open")return;const K=Fe.current,De=K==null?void 0:K.querySelector('input, [data-rd-toc-key][tabindex="0"]');De==null||De.focus()},[Ye,_e]);const V=f.useCallback(K=>{a(K),Ye&&be(!1);const De=ze.current,et=Ne.current;if(De&&et&&typeof window<"u"){const nt=De.getBoundingClientRect().top-et.getBoundingClientRect().bottom;nt<0&&window.scrollBy({top:nt})}},[a,Ye,be]),M=f.useMemo(()=>Pc(i),[i]),[J,Se]=f.useState(null),F=Mc(O,A!==void 0?A:J),pe=(F==null?void 0:F.key)??null,ce=f.useMemo(()=>M.map(K=>K.key).join(`
|
|
738
|
-
`),[M]),Oe=f.useRef(null),Ce=K=>{K!==pe&&(oe||(Oe.current={key:K,sig:ce,done:!1}),A===void 0&&Se(K),W==null||W(K))};f.useEffect(()=>{const K=Oe.current;if(!K||K.key!==pe)return;const De=M.find(nt=>!nt.disabled);if(!De)return;const et=ce!==K.sig;!et&&K.done||(et?Oe.current=null:K.done=!0,De.key!==o&&V(De.key))},[pe,ce,M,o,V]);const re=M.find(K=>K.key===o),ye=()=>{var K;C==null||C({chapterKey:o,chapterLabel:typeof(re==null?void 0:re.label)=="string"?re.label:void 0,anchor:xf(ze.current,((K=Ne.current)==null?void 0:K.getBoundingClientRect().bottom)??0),selectedText:bf(ze.current)})},ve=M.findIndex(K=>K.key===o),Pe=ve>0?M.slice(0,ve).reverse().find(K=>!K.disabled):void 0,xe=ve>=0?M.slice(ve+1).find(K=>!K.disabled):void 0,Te=u.fontSize??Xr,Ze=cf(u.fontFamily),tt={...$e,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...Ze?{"--bimrd-ff":Ze}:null},Ve={song:L("reader.fontSong"),kai:L("reader.fontKai"),system:L("reader.fontSystem")},ut=j||!!de,qe=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${me}-g1`,children:[t.jsx("h3",{id:`${me}-g1`,className:"bim-rd-sp-h",children:L("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:L("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":L("reader.font"),value:u.fontFamily,onChange:K=>h({fontFamily:K.target.value}),children:Ic.map(K=>t.jsx("option",{value:K.key,children:Ve[K.key]},K.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:L("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":L("reader.fontSmaller"),disabled:Te<=Ut[0],onClick:()=>h({fontSize:ji(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Te,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":L("reader.fontLarger"),disabled:Te>=Ut[Ut.length-1],onClick:()=>h({fontSize:ji(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(hf,{prefs:u,onPrefsChange:h,origAvailable:$}),t.jsx($i,{label:L("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:L("reader.quoteModern")},{key:"classic",label:L("reader.quoteClassic")},{key:"original",label:L("reader.quoteOriginal")}],onPick:K=>h({quoteStyle:K})})]}),ut&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${me}-g2`,children:[t.jsx("h3",{id:`${me}-g2`,className:"bim-rd-sp-h",children:L("reader.groupMark")}),j&&t.jsxs(t.Fragment,{children:[t.jsx($i,{label:L("reader.properName"),value:u.properNameMode,title:L("reader.properNameTitle"),options:[{key:"off",label:L("reader.properNameOff")},{key:"lite",label:L("reader.properNameLite"),title:L("reader.properNameLiteTitle")},{key:"full",label:L("reader.properNameFull")}],onPick:K=>h({properNameMode:K})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:K=>h({showWorks:K.target.checked})}),t.jsx("span",{children:L("reader.showWorks")})]}),t.jsx($i,{label:L("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:L("reader.bookTitleWavy")},{key:"bracket",label:L("reader.bookTitleBracket")}],onPick:K=>h({bookTitleStyle:K})})]}),de]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${me}-g3`,children:[t.jsx("h3",{id:`${me}-g3`,className:"bim-rd-sp-h",children:L("reader.groupLayout")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:L("reader.paragraphTitle"),onClick:()=>h({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:L("reader.paragraph")}),w&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:K=>h({workLinks:K.target.checked})}),t.jsx("span",{children:L("reader.workLinks")})]}),b&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>h({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:L("reader.vertical")}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.pageBreaks,onChange:K=>h({pageBreaks:K.target.checked})}),t.jsx("span",{children:L("reader.pageBreaks")})]}),ke&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:K=>h({preserveMargins:K.target.checked})}),t.jsx("span",{children:L("reader.preserveMargins")})]}),ne]})]}),ct=f.useRef(null);return f.useEffect(()=>{const K=ct.current;if(!K||!fe)return;let De=0,et=-1;const nt=()=>{De=0;const Ot=parseFloat(getComputedStyle(K).top);if(!Number.isFinite(Ot))return;const Ln=Math.max(0,Math.round(K.getBoundingClientRect().top-Ot));Ln!==et&&(et=Ln,K.style.setProperty("--bimrd-img-lead",`${Ln}px`))},xt=()=>{De||(De=requestAnimationFrame(nt))};xt(),window.addEventListener("scroll",xt,{passive:!0}),window.addEventListener("resize",xt);const Et=typeof ResizeObserver<"u"?new ResizeObserver(xt):null;return Et==null||Et.observe(document.body),()=>{window.removeEventListener("scroll",xt),window.removeEventListener("resize",xt),Et==null||Et.disconnect(),De&&cancelAnimationFrame(De),K.style.removeProperty("--bimrd-img-lead")}},[fe]),t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&b?"bim-rd-vertical":"",he].filter(Boolean).join(" "),"data-toc":_e,"data-img":fe?"open":"closed","data-bb":X?"":void 0,"data-set":!X&&Ke?"open":void 0,"data-warp":ue?"true":void 0,style:tt,children:[t.jsx("style",{children:Tc}),t.jsx("a",{className:"bim-rd-skip",href:`#${Z}`,onClick:K=>{var De,et,nt;K.preventDefault(),(De=ze.current)==null||De.focus(),(nt=(et=ze.current)==null?void 0:et.scrollIntoView)==null||nt.call(et,{block:"start"})},children:L("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:Ne,children:[_&&t.jsxs("a",{className:"bim-rd-back",href:_,"aria-label":L("reader.backAria",{label:q}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:q})]}),(e||n||y||k)&&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}),k&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:k})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":L("reader.settings"),children:[O&&O.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:F?Me(Zr(F)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:L("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:L("reader.versionShort")}),t.jsx("select",{"aria-label":L("reader.version"),value:pe??"",onChange:K=>Ce(K.target.value),children:O.map(K=>t.jsx("option",{value:K.key,children:Me(Zr(K))},K.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),N&&(Pe||xe)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":L("reader.pagerGroup",{unit:le}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":L("reader.prevUnit",{unit:le}),title:Pe?typeof Pe.label=="string"&&Pe.label?L("reader.prevUnitTitle",{unit:le,label:Pe.label}):L("reader.prevUnit",{unit:le}):L("reader.firstUnit",{unit:le}),disabled:!Pe,onClick:()=>Pe&&V(Pe.key),children:t.jsx(mf,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":L("reader.nextUnit",{unit:le}),title:xe?typeof xe.label=="string"&&xe.label?L("reader.nextUnitTitle",{unit:le,label:xe.label}):L("reader.nextUnit",{unit:le}):L("reader.lastUnit",{unit:le}),disabled:!xe,onClick:()=>xe&&V(xe.key),children:t.jsx(gf,{})})]}),N&&(Pe||xe)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:P,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":Ge,"aria-controls":H,onClick:Le,children:[t.jsx(za,{}),t.jsx("span",{className:"bim-rd-tlabel",children:L("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":fe,onClick:()=>T(fe?"closed":"open"),children:[t.jsx(Ta,{}),L("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(ff,{prefs:u,onPrefsChange:h,origAvailable:$}),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":L("reader.fontSmaller"),disabled:Te<=Ut[0],onClick:()=>h({fontSize:ji(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":L("reader.fontLarger"),disabled:Te>=Ut[Ut.length-1],onClick:()=>h({fontSize:ji(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:U,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":Ke,"aria-controls":me,onClick:()=>Qe(K=>!K),children:[t.jsx(Na,{}),t.jsx("span",{className:"bim-rd-tlabel",children:L("reader.settings")})]}),Y]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:H,ref:Fe,role:Ye&&Ge?"dialog":void 0,"aria-modal":Ye&&Ge?!0:void 0,"aria-label":Ye&&Ge?L("reader.toc"):void 0,onKeyDown:K=>{if(!(!Ye||!Ge)){if(K.key==="Escape"){K.stopPropagation(),be(!0);return}K.key==="Tab"&&Ra(K,Fe.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:d??L("reader.toc")}),Ye&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":L("reader.closeToc"),onClick:()=>be(!0),children:"✕"})]}),l]}),t.jsx(Rc,{items:i,activeKey:s!==void 0?s:o,onSelect:V})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>be(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":L("reader.images"),ref:ct,children:fe&&(se||t.jsx(qr,{pages:c??null,loading:p,renderOverlay:g,preserveMargins:u.preserveMargins}))}),!X&&Ke&&t.jsxs("aside",{className:"bim-rd-set",id:me,"aria-label":L("reader.settings"),onKeyDown:K=>{var De;K.key==="Escape"&&(K.stopPropagation(),Qe(!1),(De=U.current)==null||De.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:L("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":L("reader.closeSettings"),onClick:()=>{var K;Qe(!1),(K=U.current)==null||K.focus()},children:"✕"})]}),qe]}),t.jsxs("div",{className:"bim-rd-text",id:Z,ref:ze,tabIndex:-1,"data-rail":(v||C)&&!ue?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[Ae,G&&F&&(F.sourceName||F.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":F.key,children:[F.sourceName&&t.jsxs(t.Fragment,{children:[L("reader.sourceLabel")," ",F.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:F.sourceUrl,target:"_blank",rel:"noreferrer",children:Me(F.sourceName)}):Me(F.sourceName)]}),F.sourceName&&F.license&&t.jsx("span",{className:"bim-rd-dot"}),F.license&&t.jsx(t.Fragment,{children:L("reader.licenseOf",{license:F.license})})]}),S&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:L("reader.revisedAt",{date:S})}),C&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:K=>K.preventDefault(),onClick:ye,children:L("reader.reportError")})}),N&&!I&&(Pe||xe)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":L("reader.pagerNav"),children:[Pe?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>V(Pe.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),L("reader.prevUnit",{unit:le})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Pe.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",L("reader.firstUnit",{unit:le})]}),xe?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>V(xe.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[L("reader.nextUnit",{unit:le}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:xe.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[L("reader.lastUnit",{unit:le})," →"]})]})]}),(v||C)&&!ue&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":L("reader.rail"),children:[v,C&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:K=>K.preventDefault(),onClick:ye,children:L("reader.reportError")})})]})]})]}),X&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":L("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":Ge,"aria-controls":H,onClick:()=>{He(null),Le()},children:[t.jsx(za,{}),t.jsx("span",{children:L("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":we==="img","aria-haspopup":"dialog",onClick:K=>je("img",K.currentTarget),children:[t.jsx(Ta,{}),t.jsx("span",{children:L("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":we==="set","aria-haspopup":"dialog",onClick:K=>je("set",K.currentTarget),children:[t.jsx(Na,{}),t.jsx("span",{children:L("reader.settingsShort")})]}),C&&t.jsxs("button",{type:"button",onMouseDown:K=>K.preventDefault(),onClick:()=>{He(null),ye()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:L("reader.reportError")})]})]}),X&&we&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:te}),t.jsxs("div",{className:"bim-rd-sheet",ref:Re,role:"dialog","aria-modal":"true","aria-label":L(we==="img"?"reader.images":"reader.settings"),onKeyDown:K=>{if(K.key==="Escape"){K.stopPropagation(),te();return}K.key==="Tab"&&Ra(K,Re.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:L(we==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":L("reader.close"),onClick:te,children:"✕"})]}),we==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(qr,{pages:c??null,loading:p,renderOverlay:g,preserveMargins:u.preserveMargins})}):qe]})]})]})}function yf(e,n,i){return i?Oc(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function Oc(e){return e.replace(/\r\n/g,`
|
|
739
|
-
`)}const
|
|
740
|
-
`)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function
|
|
741
|
-
`)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=
|
|
742
|
-
`)return null}const g=
|
|
743
|
-
.bim-d-main.bim-d-main-grid { max-width: ${
|
|
736
|
+
@media ${Ci} { .guji-page-indicator { display: none; } }
|
|
737
|
+
`;function Wo(e,n){var i;return n?e.key===n?!0:!!((i=e.children)!=null&&i.some(o=>Wo(o,n))):!1}const za=()=>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 cf({item:e,activeKey:n,onSelect:i,tabKey:o}){const{t:s}=ae(),a=Wo(e,n),[l,d]=f.useState(a||!!e.defaultExpanded);return f.useEffect(()=>{a&&d(!0)},[a]),f.useEffect(()=>{e.defaultExpanded&&d(!0)},[e.defaultExpanded]),e.selectable?t.jsxs("li",{children:[t.jsxs("div",{className:"bim-rd-ti-row",children:[t.jsx("button",{type:"button",className:"bim-rd-ti-tw","aria-expanded":l,"aria-label":s(l?"reader.tocCollapse":"reader.tocExpand"),tabIndex:-1,onClick:()=>d(c=>!c),children:t.jsx(za,{})}),t.jsxs("button",{type:"button",className:`bim-rd-ti${e.inChapter?"":" bim-rd-ti-group"}`,"aria-current":e.key===n?"true":void 0,disabled:e.disabled,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>{d(!0),i(e.key)},onKeyDown:c=>{c.key==="ArrowRight"&&!l?(c.preventDefault(),d(!0)):c.key==="ArrowLeft"&&l&&(c.preventDefault(),d(!1))},children:[t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]})]}),l&&t.jsx(Xr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]}):t.jsxs("li",{children:[t.jsxs("button",{type:"button",className:"bim-rd-ti bim-rd-ti-group","aria-expanded":l,"data-rd-toc-key":e.key,tabIndex:o===e.key?0:-1,onClick:()=>d(c=>!c),children:[t.jsx(za,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),l&&t.jsx(Xr,{items:e.children,activeKey:n,onSelect:i,tabKey:o})]})}function Xr({items:e,activeKey:n,onSelect:i,tabKey:o}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(cf,{item:s,activeKey:n,onSelect:i,tabKey:o},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:o===s.key?0:-1,onClick:()=>i(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 Na(e,n){var i;for(const o of e)if(o.key===n||Wo(o,n))return o.key;return((i=e[0])==null?void 0:i.key)??null}function Lc({items:e,activeKey:n,onSelect:i,label:o}){const{t:s}=ae(),a=o??s("reader.toc"),l=f.useRef(null),[d,c]=f.useState(null);f.useEffect(()=>{c(null)},[n]);const p=f.useMemo(()=>d||(n??Na(e,n)),[d,n,e]);f.useEffect(()=>{const m=l.current;if(!m)return;const u=Array.from(m.querySelectorAll("[data-rd-toc-key]"));if(u.length===0)return;const h=u.find(x=>x.dataset.rdTocKey===p)??u.find(x=>x.dataset.rdTocKey===Na(e,n))??u.find(x=>!x.disabled)??u[0];for(const x of u)x.tabIndex=x===h?0:-1}),f.useEffect(()=>{const m=l.current,u=m==null?void 0:m.closest(".bim-rd-toc");if(!m||!u||!n)return;const h=Array.from(m.querySelectorAll("[data-rd-toc-key]")).find(j=>j.dataset.rdTocKey===n);if(!h)return;const x=h.getBoundingClientRect().top-u.getBoundingClientRect().top+u.scrollTop;(x<u.scrollTop+80||x>u.scrollTop+u.clientHeight-40)&&(u.scrollTop=Math.max(0,x-u.clientHeight/3))},[n]);const g=f.useCallback(m=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(m.key))return;const h=l.current;if(!h)return;const x=Array.from(h.querySelectorAll("[data-rd-toc-key]")).filter(y=>!y.disabled),j=x.indexOf(document.activeElement);let b=j;if(m.key==="ArrowDown"?b=Math.min(x.length-1,j+1):m.key==="ArrowUp"?b=Math.max(0,j-1):m.key==="Home"?b=0:m.key==="End"&&(b=x.length-1),b<0||b===j)return;m.preventDefault();const S=x[b];for(const y of x)y.tabIndex=-1;S.tabIndex=0,S.focus(),c(S.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:l,role:"navigation","aria-label":a,onKeyDown:g,children:t.jsx(Xr,{items:e,activeKey:n,onSelect:i,tabKey:p})})}function Ta({page:e,crop:n}){var i;return!((i=e.boxes)!=null&&i.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:n?`${n.x} ${n.y} ${n.w} ${n.h}`:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,s)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:r("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},s))})}function df(e){const{boxes:n,width:i,height:o}=e;if(!(n!=null&&n.length)||!i||!o||e.boxFormat&&e.boxFormat!=="bim-charbox-v0")return null;let s=1/0,a=1/0,l=-1/0,d=-1/0;for(const h of n)[h.x,h.y,h.w,h.h].every(Number.isFinite)&&(s=Math.min(s,h.x),a=Math.min(a,h.y),l=Math.max(l,h.x+h.w),d=Math.max(d,h.y+h.h));if(!(l>s)||!(d>a))return null;const c=Math.min(i,o)*.03,p=Math.min(i,Math.max(0,s-c)),g=Math.min(o,Math.max(0,a-c)),m=Math.min(i,Math.max(0,l+c))-p,u=Math.min(o,Math.max(0,d+c))-g;return!(m>0)||!(u>0)||m>=i*.98&&u>=o*.98?null:{x:p,y:g,w:m,h:u}}function Zr({pages:e,loading:n,page:i,onPageChange:o,renderOverlay:s,preserveMargins:a=!0}){const{t:l}=ae(),[d,c]=f.useState(0),p=i??d,g=j=>{o?o(j):c(j)};if(f.useEffect(()=>{i===void 0&&c(0)},[e,i]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:l("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:l("reader.noImages")}),t.jsx("span",{children:l("reader.noImagesHint")})]})});const m=Math.max(0,Math.min(e.length-1,p)),u=e[m],h=u.label??`${m+1}`,x=!a&&!s?df(u):null;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:x?t.jsxs("figure",{className:"bim-rd-img-fig bim-rd-img-trimmed","data-trim":`${Math.round(x.x)},${Math.round(x.y)},${Math.round(x.w)},${Math.round(x.h)}`,style:{aspectRatio:`${x.w} / ${x.h}`,overflow:"hidden",width:"100%",maxWidth:`calc((100vh - 200px) * ${x.w/x.h})`},children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:h}),decoding:"async",style:{position:"absolute",maxWidth:"none",maxHeight:"none",width:`${u.width/x.w*100}%`,left:`${-x.x/x.w*100}%`,top:`${-x.y/x.h*100}%`}}),t.jsx(Ta,{page:u,crop:x})]}):t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:u.url,alt:u.alt??l("reader.imageAlt",{label:h}),width:u.width,height:u.height,loading:"lazy",decoding:"async"}),t.jsx(Ta,{page:u}),s==null?void 0:s(u,m)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.prevImage"),disabled:m===0,onClick:()=>g(m-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:u.label??`${m+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":l("reader.nextImage"),disabled:m===e.length-1,onClick:()=>g(m+1),children:"›"})]})]})}function pf(e){return e==="lite"||e==="full"}const ei=[.1,.9],Ac=[{key:"song",stack:null},{key:"kai",stack:'"Kaiti SC", "Kaiti TC", STKaiti, "KaiTi", "AR PL UKai CN", "Noto Serif CJK SC", serif'},{key:"system",stack:"var(--bim-font-ui)"}];function uf(e){var n;return((n=Ac.find(i=>i.key===e))==null?void 0:n.stack)??null}const Fo={fontSize:null,readingMode:"line",properNameMode:null,writingMode:"horizontal",workLinks:!0,fontFamily:"song",pageBreaks:!1,pageIndicatorY:.33,bookTitleStyle:"bracket",showWorks:!0,quoteStyle:"original",scriptMode:null,preserveMargins:!0},Ut=[15,16,17,18,20,22,24],Jr=18,Mc="bim-reader-prefs",Pc=2,mf="bim-reading-mode";function gf(){const e={...Fo};try{const n=localStorage.getItem(Mc),i=n?JSON.parse(n):{};typeof i.fontSize=="number"&&Ut.includes(i.fontSize)&&(e.fontSize=i.fontSize),(i.readingMode??localStorage.getItem(mf))==="paragraph"&&(e.readingMode="paragraph"),i.properNameMode==="off"||i.properNameMode==="lite"||i.properNameMode==="full"?e.properNameMode=i.properNameMode:i.properNames===!0?e.properNameMode="full":i.properNames===!1&&(e.properNameMode="off"),i.writingMode==="vertical"&&(e.writingMode="vertical"),i.workLinks===!1&&(e.workLinks=!1),(i.fontFamily==="kai"||i.fontFamily==="system")&&(e.fontFamily=i.fontFamily);const s=i.v===Pc;s&&typeof i.pageBreaks=="boolean"&&(e.pageBreaks=i.pageBreaks),typeof i.pageIndicatorY=="number"&&Number.isFinite(i.pageIndicatorY)&&i.pageIndicatorY>=ei[0]&&i.pageIndicatorY<=ei[1]&&(e.pageIndicatorY=i.pageIndicatorY),s&&(i.bookTitleStyle==="wavy"||i.bookTitleStyle==="bracket")&&(e.bookTitleStyle=i.bookTitleStyle),i.showWorks===!1&&(e.showWorks=!1),(i.quoteStyle==="modern"||i.quoteStyle==="classic")&&(e.quoteStyle=i.quoteStyle),(i.scriptMode==="orig"||i.scriptMode==="hant"||i.scriptMode==="hans")&&(e.scriptMode=i.scriptMode),i.preserveMargins===!1&&(e.preserveMargins=!1)}catch{}return e}function ff(e){try{localStorage.setItem(Mc,JSON.stringify({...e,v:Pc}))}catch{}}function ki(e,n){const i=e??Jr,o=Ut;let s=o.indexOf(i);return s<0&&(s=o.indexOf(Jr)),o[Math.max(0,Math.min(o.length-1,s+n))]}function Bc(){const[e,n]=f.useState(Fo);f.useEffect(()=>{n(gf())},[]);const i=f.useCallback(o=>{n(s=>{const a={...s,...o};return ff(a),a})},[]);return[e,i]}function Qr(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 Oc(e,n){if(!(!e||e.length===0))return(n!=null?e.find(i=>i.key===n):void 0)??e.find(i=>i.primary)??e[0]}function Wc(e){const n=[],i=o=>{for(const s of o){if(s.inChapter)continue;const a=!!s.children&&s.children.length>0;(!a||s.selectable)&&n.push(s),a&&i(s.children)}};return i(e),n}const Ra=()=>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"})}),hf=()=>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"})}),xf=()=>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"})}),Ia=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 7h10M18 7h2M4 17h2M10 17h10"}),t.jsx("circle",{cx:"16",cy:"7",r:"2"}),t.jsx("circle",{cx:"8",cy:"17",r:"2"})]}),Ea=()=>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 La(e,n){if(!n)return;const i=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(l=>l.tabIndex>=0);if(i.length===0)return;const o=i[0],s=i[i.length-1],a=document.activeElement;e.shiftKey&&(a===o||!n.contains(a))?(e.preventDefault(),s.focus()):!e.shiftKey&&(a===s||!n.contains(a))&&(e.preventDefault(),o.focus())}function Aa(e,n){const[i,o]=f.useState(n);return f.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);o(s.matches);const a=()=>o(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]),i}function bf({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(Ot),{t:s}=ae();if(!o)return null;const a=o.locale==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a,d=[{key:"orig",short:s("reader.scriptOrigShort"),title:s(i?"reader.scriptOrig":"reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",short:s("common.localeShortHant"),title:s("reader.scriptHant")},{key:"hans",short:s("common.localeShortHans"),title:s("reader.scriptHans")}];return t.jsx("span",{className:"bim-rd-script-sw",role:"group","aria-label":s("reader.scriptQuick"),children:d.map((c,p)=>t.jsxs(f.Fragment,{children:[p>0&&t.jsx("span",{className:"bim-rd-off","aria-hidden":"true",children:"|"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":l===c.key,title:c.title,"aria-label":c.title,disabled:c.disabled,onClick:()=>{c.disabled||(n({scriptMode:c.key}),c.key==="hant"?o.setLocale("zh-Hant"):c.key==="hans"&&o.setLocale("zh-Hans"))},children:c.short})]},c.key))})}function zi({label:e,value:n,options:i,onPick:o,title:s}){return t.jsxs("div",{className:"bim-rd-sp-row",role:"group","aria-label":e,title:s,children:[t.jsx("span",{className:"bim-rd-sp-l",children:e}),t.jsx("span",{className:"bim-rd-sp-fs",children:i.map(a=>t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":n===a.key,title:a.title,disabled:a.disabled,onClick:()=>{a.disabled||o(a.key)},children:a.label},a.key))})]})}function yf({prefs:e,onPrefsChange:n,origAvailable:i}){const o=f.useContext(Ot),{t:s}=ae(),a=(o==null?void 0:o.locale)==="zh-Hans"?"hans":"hant",l=e.scriptMode==="orig"?"orig":a;return t.jsx(zi,{label:s("reader.script"),value:l,options:[{key:"orig",label:s("reader.scriptOrig"),title:i?void 0:s("reader.scriptOrigUnavailable"),disabled:!i},{key:"hant",label:s("reader.scriptHant")},{key:"hans",label:s("reader.scriptHans")}],onPick:d=>{n({scriptMode:d}),d==="hant"?o==null||o.setLocale("zh-Hant"):d==="hans"&&(o==null||o.setLocale("zh-Hans"))}})}function jf(e,n){if(!e)return;let i;for(const o of Array.from(e.querySelectorAll('[id^="rd-e-"]')))if(o.getBoundingClientRect().top<=n+8)i=o.id;else break;return i}function vf(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 i=e.querySelector(".bim-rd-col"),o=l=>{const d=(l==null?void 0:l.nodeType)===1?l:l==null?void 0:l.parentElement;return!!l&&!!(i!=null&&i.contains(l))&&!(d!=null&&d.closest(".bim-rd-src, .bim-rd-pager"))};if(!o(n.anchorNode)||!o(n.focusNode))return;const s=n.toString().replace(/\s+/g," ").trim();return s?s.slice(0,500):void 0}function Fc({title:e,subtitle:n,toc:i,activeKey:o,tocActiveKey:s,onSelect:a,tocHeader:l,tocCaption:d,images:c,imagesLoading:p,renderImageOverlay:g,imagePanel:m="auto",prefs:u,onPrefsChange:h,paragraphToggle:x,properNameToggle:j=!0,allowVertical:b,origScriptAvailable:S=!0,byline:y,current:k,workLinkToggle:w,rail:v,onReportError:C,revisedAt:_,backHref:$,backLabel:A,bottomBar:R=!0,pager:z=!0,contentLoading:N=!1,pagerUnit:M,versions:O,currentVersionKey:L,onVersionChange:D,versionSource:q=!0,keepChapterOnVersionChange:J=!1,customImagePanel:se,toolbarExtra:U,settingsAnnotate:K,settingsLayout:Z,settingsExtra:oe,settingsExtraTitle:ye,isWarpMode:Le,showPreserveMargins:Me=!0,children:Se,className:le,style:Oe}){const{t:T,convert:de}=ae(),pe=A??T("reader.back"),B=de(M??T("reader.unitJuan")),ee=f.useId().replace(/:/g,""),Ce=`bim-rd-toc-${ee}`,Ie=`bim-rd-text-${ee}`,We=f.useRef(null),G=f.useRef(null),he=f.useRef(null),te=f.useRef(null),H=Aa(Rc,!0),ue=Aa(Ic,!1),Fe=R&&ue,[Ge,Je]=f.useState(null),[F,ge]=f.useState(!1),Ae=f.useRef(null),W=`bim-rd-set-${ee}`,be=f.useRef(null),ce=f.useRef(null),Ne=(Q,De)=>{ce.current=De,Je(dt=>dt===Q?null:Q)},$e=f.useCallback(()=>{var Q;Je(null),(Q=ce.current)==null||Q.focus()},[]);f.useEffect(()=>{Fe||Je(null)},[Fe]),f.useEffect(()=>{var Q,De;Ge&&((De=(Q=be.current)==null?void 0:Q.querySelector("button:not([disabled])"))==null||De.focus())},[Ge]);const[Ke,Qe]=f.useState("auto"),it=Ke==="auto"?H:Ke==="open",nt=!H,I=!!se||!!c&&c.length>0,[fe,xe]=f.useState(m);f.useEffect(()=>{xe(m)},[m]);const ze=fe==="auto"?I||!!p:fe==="open",V=f.useCallback(Q=>{var De;Qe("auto"),Q&&((De=te.current)==null||De.focus())},[]),P=()=>Qe(it?"closed":"open");f.useEffect(()=>{if(!nt||Ke!=="open")return;const Q=he.current,De=Q==null?void 0:Q.querySelector('input, [data-rd-toc-key][tabindex="0"]');De==null||De.focus()},[nt,Ke]);const X=f.useCallback(Q=>{a(Q),nt&&V(!1);const De=G.current,dt=We.current;if(De&&dt&&typeof window<"u"){const xt=De.getBoundingClientRect().top-dt.getBoundingClientRect().bottom;xt<0&&window.scrollBy({top:xt})}},[a,nt,V]),je=f.useMemo(()=>Wc(i),[i]),[Y,me]=f.useState(null),_e=Oc(O,L!==void 0?L:Y),Pe=(_e==null?void 0:_e.key)??null,ne=f.useMemo(()=>je.map(Q=>Q.key).join(`
|
|
738
|
+
`),[je]),re=f.useRef(null),ve=Q=>{Q!==Pe&&(J||(re.current={key:Q,sig:ne,done:!1}),L===void 0&&me(Q),D==null||D(Q))};f.useEffect(()=>{const Q=re.current;if(!Q||Q.key!==Pe)return;const De=je.find(xt=>!xt.disabled);if(!De)return;const dt=ne!==Q.sig;!dt&&Q.done||(dt?re.current=null:Q.done=!0,De.key!==o&&X(De.key))},[Pe,ne,je,o,X]);const ke=je.find(Q=>Q.key===o),Ue=()=>{var Q;C==null||C({chapterKey:o,chapterLabel:typeof(ke==null?void 0:ke.label)=="string"?ke.label:void 0,anchor:jf(G.current,((Q=We.current)==null?void 0:Q.getBoundingClientRect().bottom)??0),selectedText:vf(G.current)})},we=je.findIndex(Q=>Q.key===o),Ee=we>0?je.slice(0,we).reverse().find(Q=>!Q.disabled):void 0,He=we>=0?je.slice(we+1).find(Q=>!Q.disabled):void 0,Ye=u.fontSize??Jr,Xe=uf(u.fontFamily),at={...Oe,...u.fontSize?{"--bimrd-fs":`${u.fontSize}px`}:null,...Xe?{"--bimrd-ff":Xe}:null},qe={song:T("reader.fontSong"),kai:T("reader.fontKai"),system:T("reader.fontSystem")},jt=j||!!K,tt=t.jsxs("div",{className:"bim-rd-sp",children:[t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${W}-g1`,children:[t.jsx("h3",{id:`${W}-g1`,className:"bim-rd-sp-h",children:T("reader.groupText")}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:T("reader.font")}),t.jsx("select",{className:"bim-rd-sp-sel","aria-label":T("reader.font"),value:u.fontFamily,onChange:Q=>h({fontFamily:Q.target.value}),children:Ac.map(Q=>t.jsx("option",{value:Q.key,children:qe[Q.key]},Q.key))})]}),t.jsxs("div",{className:"bim-rd-sp-row",children:[t.jsx("span",{className:"bim-rd-sp-l",children:T("reader.fontSize")}),t.jsxs("span",{className:"bim-rd-sp-fs",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":T("reader.fontSmaller"),disabled:Ye<=Ut[0],onClick:()=>h({fontSize:ki(u.fontSize,-1)}),children:"A−"}),t.jsxs("output",{"aria-live":"polite",children:[Ye,"px"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":T("reader.fontLarger"),disabled:Ye>=Ut[Ut.length-1],onClick:()=>h({fontSize:ki(u.fontSize,1)}),children:"A+"})]})]}),t.jsx(yf,{prefs:u,onPrefsChange:h,origAvailable:S}),t.jsx(zi,{label:T("reader.quoteStyle"),value:u.quoteStyle,options:[{key:"modern",label:T("reader.quoteModern")},{key:"classic",label:T("reader.quoteClassic")},{key:"original",label:T("reader.quoteOriginal")}],onPick:Q=>h({quoteStyle:Q})})]}),jt&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${W}-g2`,children:[t.jsx("h3",{id:`${W}-g2`,className:"bim-rd-sp-h",children:T("reader.groupMark")}),j&&t.jsxs(t.Fragment,{children:[t.jsx(zi,{label:T("reader.properName"),value:u.properNameMode,title:T("reader.properNameTitle"),options:[{key:"off",label:T("reader.properNameOff")},{key:"lite",label:T("reader.properNameLite"),title:T("reader.properNameLiteTitle")},{key:"full",label:T("reader.properNameFull")}],onPick:Q=>h({properNameMode:Q})}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.showWorks,onChange:Q=>h({showWorks:Q.target.checked})}),t.jsx("span",{children:T("reader.showWorks")})]}),t.jsx(zi,{label:T("reader.bookTitleStyle"),value:u.bookTitleStyle,options:[{key:"wavy",label:T("reader.bookTitleWavy")},{key:"bracket",label:T("reader.bookTitleBracket")}],onPick:Q=>h({bookTitleStyle:Q})})]}),K]}),t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${W}-g3`,children:[t.jsx("h3",{id:`${W}-g3`,className:"bim-rd-sp-h",children:T("reader.groupLayout")}),x&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.readingMode==="paragraph",title:T("reader.paragraphTitle"),onClick:()=>h({readingMode:u.readingMode==="paragraph"?"line":"paragraph"}),children:T("reader.paragraph")}),w&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.workLinks,onChange:Q=>h({workLinks:Q.target.checked})}),t.jsx("span",{children:T("reader.workLinks")})]}),b&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-sp-tg","aria-pressed":u.writingMode==="vertical",onClick:()=>h({writingMode:u.writingMode==="vertical"?"horizontal":"vertical"}),children:T("reader.vertical")}),t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.pageBreaks,onChange:Q=>h({pageBreaks:Q.target.checked})}),t.jsx("span",{children:T("reader.pageBreaks")})]}),Me&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk bim-rd-sp-tg",children:[t.jsx("input",{type:"checkbox",checked:u.preserveMargins,onChange:Q=>h({preserveMargins:Q.target.checked})}),t.jsx("span",{children:T("reader.preserveMargins")})]}),Z]}),oe&&t.jsxs("section",{className:"bim-rd-sp-g","aria-labelledby":`${W}-g4`,children:[t.jsx("h3",{id:`${W}-g4`,className:"bim-rd-sp-h",children:ye??T("reader.groupMore")}),oe]})]}),ct=f.useRef(null);return f.useEffect(()=>{const Q=ct.current;if(!Q||!ze)return;let De=0,dt=-1;const xt=()=>{De=0;const di=parseFloat(getComputedStyle(Q).top);if(!Number.isFinite(di))return;const An=Math.max(0,Math.round(Q.getBoundingClientRect().top-di));An!==dt&&(dt=An,Q.style.setProperty("--bimrd-img-lead",`${An}px`))},mt=()=>{De||(De=requestAnimationFrame(xt))};mt(),window.addEventListener("scroll",mt,{passive:!0}),window.addEventListener("resize",mt);const Xt=typeof ResizeObserver<"u"?new ResizeObserver(mt):null;return Xt==null||Xt.observe(document.body),()=>{window.removeEventListener("scroll",mt),window.removeEventListener("resize",mt),Xt==null||Xt.disconnect(),De&&cancelAnimationFrame(De),Q.style.removeProperty("--bimrd-img-lead")}},[ze]),t.jsxs("div",{className:["bim-rd",u.writingMode==="vertical"&&b?"bim-rd-vertical":"",le].filter(Boolean).join(" "),"data-toc":Ke,"data-img":ze?"open":"closed","data-bb":Fe?"":void 0,"data-set":!Fe&&F?"open":void 0,"data-warp":Le?"true":void 0,style:at,children:[t.jsx("style",{children:Ec}),t.jsx("a",{className:"bim-rd-skip",href:`#${Ie}`,onClick:Q=>{var De,dt,xt;Q.preventDefault(),(De=G.current)==null||De.focus(),(xt=(dt=G.current)==null?void 0:dt.scrollIntoView)==null||xt.call(dt,{block:"start"})},children:T("reader.skipToText")}),t.jsxs("div",{className:"bim-rd-bar",ref:We,children:[$&&t.jsxs("a",{className:"bim-rd-back",href:$,"aria-label":T("reader.backAria",{label:pe}),children:[t.jsx("span",{"aria-hidden":"true",children:"‹"}),t.jsx("span",{className:"bim-rd-tlabel","aria-hidden":"true",children:pe})]}),(e||n||y||k)&&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}),k&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:k})]}),n&&t.jsx("span",{className:"bim-rd-ttl-src",children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":T("reader.settings"),children:[O&&O.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:_e?de(Qr(_e)):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:T("reader.version")}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:T("reader.versionShort")}),t.jsx("select",{"aria-label":T("reader.version"),value:Pe??"",onChange:Q=>ve(Q.target.value),children:O.map(Q=>t.jsx("option",{value:Q.key,children:de(Qr(Q))},Q.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),z&&(Ee||He)&&t.jsxs("span",{className:"bim-rd-nav bim-rd-hide-narrow",role:"group","aria-label":T("reader.pagerGroup",{unit:B}),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":T("reader.prevUnit",{unit:B}),title:Ee?typeof Ee.label=="string"&&Ee.label?T("reader.prevUnitTitle",{unit:B,label:Ee.label}):T("reader.prevUnit",{unit:B}):T("reader.firstUnit",{unit:B}),disabled:!Ee,onClick:()=>Ee&&X(Ee.key),children:t.jsx(hf,{})}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":T("reader.nextUnit",{unit:B}),title:He?typeof He.label=="string"&&He.label?T("reader.nextUnitTitle",{unit:B,label:He.label}):T("reader.nextUnit",{unit:B}):T("reader.lastUnit",{unit:B}),disabled:!He,onClick:()=>He&&X(He.key),children:t.jsx(xf,{})})]}),z&&(Ee||He)&&t.jsx("span",{className:"bim-rd-sep bim-rd-hide-narrow","aria-hidden":"true"}),t.jsxs("button",{ref:te,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":it,"aria-controls":Ce,onClick:P,children:[t.jsx(Ra,{}),t.jsx("span",{className:"bim-rd-tlabel",children:T("reader.toc")})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":ze,onClick:()=>xe(ze?"closed":"open"),children:[t.jsx(Ea,{}),T("reader.images")]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(bf,{prefs:u,onPrefsChange:h,origAvailable:S}),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":T("reader.fontSmaller"),disabled:Ye<=Ut[0],onClick:()=>h({fontSize:ki(u.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs bim-rd-bb-dup","aria-label":T("reader.fontLarger"),disabled:Ye>=Ut[Ut.length-1],onClick:()=>h({fontSize:ki(u.fontSize,1)}),children:"A+"}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsxs("button",{ref:Ae,type:"button",className:"bim-rd-t bim-rd-bb-dup","aria-expanded":F,"aria-controls":W,onClick:()=>ge(Q=>!Q),children:[t.jsx(Ia,{}),t.jsx("span",{className:"bim-rd-tlabel",children:T("reader.settings")})]}),U]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:Ce,ref:he,role:nt&&it?"dialog":void 0,"aria-modal":nt&&it?!0:void 0,"aria-label":nt&&it?T("reader.toc"):void 0,onKeyDown:Q=>{if(!(!nt||!it)){if(Q.key==="Escape"){Q.stopPropagation(),V(!0);return}Q.key==="Tab"&&La(Q,he.current)}},children:[t.jsxs("div",{className:"bim-rd-toc-top",children:[t.jsxs("div",{className:"bim-rd-toc-head",children:[t.jsx("span",{children:d??T("reader.toc")}),nt&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":T("reader.closeToc"),onClick:()=>V(!0),children:"✕"})]}),l]}),t.jsx(Lc,{items:i,activeKey:s!==void 0?s:o,onSelect:X})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>V(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":T("reader.images"),ref:ct,children:ze&&(se||t.jsx(Zr,{pages:c??null,loading:p,renderOverlay:g,preserveMargins:u.preserveMargins}))}),!Fe&&F&&t.jsxs("aside",{className:"bim-rd-set",id:W,"aria-label":T("reader.settings"),onKeyDown:Q=>{var De;Q.key==="Escape"&&(Q.stopPropagation(),ge(!1),(De=Ae.current)==null||De.focus())},children:[t.jsxs("div",{className:"bim-rd-sp-top",children:[t.jsx("span",{children:T("reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":T("reader.closeSettings"),onClick:()=>{var Q;ge(!1),(Q=Ae.current)==null||Q.focus()},children:"✕"})]}),tt]}),t.jsxs("div",{className:"bim-rd-text",id:Ie,ref:G,tabIndex:-1,"data-rail":(v||C)&&!Le?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[Se,q&&_e&&(_e.sourceName||_e.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":_e.key,children:[_e.sourceName&&t.jsxs(t.Fragment,{children:[T("reader.sourceLabel")," ",_e.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:_e.sourceUrl,target:"_blank",rel:"noreferrer",children:de(_e.sourceName)}):de(_e.sourceName)]}),_e.sourceName&&_e.license&&t.jsx("span",{className:"bim-rd-dot"}),_e.license&&t.jsx(t.Fragment,{children:T("reader.licenseOf",{license:_e.license})})]}),_&&t.jsx("p",{className:"bim-rd-src bim-rd-rev",children:T("reader.revisedAt",{date:_})}),C&&t.jsx("p",{className:"bim-rd-src bim-rd-report-foot",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:Q=>Q.preventDefault(),onClick:Ue,children:T("reader.reportError")})}),z&&!N&&(Ee||He)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":T("reader.pagerNav"),children:[Ee?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>X(Ee.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),T("reader.prevUnit",{unit:B})]}),t.jsx("span",{className:"bim-rd-pglabel",children:Ee.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← ",T("reader.firstUnit",{unit:B})]}),He?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>X(He.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[T("reader.nextUnit",{unit:B}),t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:He.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:[T("reader.lastUnit",{unit:B})," →"]})]})]}),(v||C)&&!Le&&t.jsxs("aside",{className:"bim-rd-rail","aria-label":T("reader.rail"),children:[v,C&&t.jsx("div",{className:"bim-rd-rail-acts",children:t.jsx("button",{type:"button",className:"bim-rd-rail-report",onMouseDown:Q=>Q.preventDefault(),onClick:Ue,children:T("reader.reportError")})})]})]})]}),Fe&&t.jsxs("nav",{className:"bim-rd-bb","aria-label":T("reader.bottomBar"),children:[t.jsxs("button",{type:"button","aria-expanded":it,"aria-controls":Ce,onClick:()=>{Je(null),P()},children:[t.jsx(Ra,{}),t.jsx("span",{children:T("reader.tocShort")})]}),t.jsxs("button",{type:"button","aria-expanded":Ge==="img","aria-haspopup":"dialog",onClick:Q=>Ne("img",Q.currentTarget),children:[t.jsx(Ea,{}),t.jsx("span",{children:T("reader.images")})]}),t.jsxs("button",{type:"button","aria-expanded":Ge==="set","aria-haspopup":"dialog",onClick:Q=>Ne("set",Q.currentTarget),children:[t.jsx(Ia,{}),t.jsx("span",{children:T("reader.settingsShort")})]}),C&&t.jsxs("button",{type:"button",onMouseDown:Q=>Q.preventDefault(),onClick:()=>{Je(null),Ue()},children:[t.jsx("span",{className:"bim-rd-bb-ic","aria-hidden":"true",children:"!"}),t.jsx("span",{children:T("reader.reportError")})]})]}),Fe&&Ge&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-sheet-scrim","aria-hidden":"true",onClick:$e}),t.jsxs("div",{className:"bim-rd-sheet",ref:be,role:"dialog","aria-modal":"true","aria-label":T(Ge==="img"?"reader.images":"reader.settings"),onKeyDown:Q=>{if(Q.key==="Escape"){Q.stopPropagation(),$e();return}Q.key==="Tab"&&La(Q,be.current)},children:[t.jsxs("div",{className:"bim-rd-sheet-head",children:[t.jsx("span",{children:T(Ge==="img"?"reader.images":"reader.settings")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":T("reader.close"),onClick:$e,children:"✕"})]}),Ge==="img"?t.jsx("div",{className:"bim-rd-sheet-img",children:t.jsx(Zr,{pages:c??null,loading:p,renderOverlay:g,preserveMargins:u.preserveMargins})}):tt]})]})]})}function kf(e,n,i){return i?Hc(e).includes("\r")?"lone-cr":Array.from(e).length!==Array.from(n).length?"convert-length":n.includes(":::")?"tables":null:"quoteStyle"}function Hc(e){return e.replace(/\r\n/g,`
|
|
739
|
+
`)}const Ma=2,wf=400,Sf=6,Dc=e=>e==="*"||e==="#"||e==="<"||e===">"||/\s/.test(e);function Uc(e,n){if(e[n]!=="<"||e[n+1]!=="!"||e[n+2]!=="-"||e[n+3]!=="-")return-1;for(let i=n+4;i+2<e.length;i++)if(e[i]==="-"&&e[i+1]==="-"&&e[i+2]===">")return i+2;return-1}function _f(e,n,i){let o=n;for(let s=0;s<i.length;){if(o>=e.length)return-1;if(i[s]===e[o]){s++,o++;continue}const a=Uc(e,o);if(a>=0){o=a+1;continue}if(Dc(e[o])){o++;continue}if(i[s]===" "){s++;continue}return-1}return o}function $f(e){const n=Array.from(Hc(e));let i=0;return{align(o){if(!o)return;const s=Array.from(o);if(s.every(d=>d===" "||/\s/.test(d)))return;const a=s.length>=Sf;let l=0;for(let d=i;d<n.length&&d-i<=(a?wf:Ma+64);d++){const c=Uc(n,d);if(c>=0){d=c;continue}if(!Dc(n[d])){const g=_f(n,d,s);if(g>=0)return i=g,d;if(l++,!a&&l>Ma)return}}}}}const Cf=65536,zf="guji_markdown";function Nf(e){const n=e==null?void 0:e.guji_markdown;if(typeof n!="string")return!1;const i=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!i)return!1;const o=parseInt(i[1],10),s=parseInt(i[2],10);return o>0||s>=2}const Tf=/^□\{guess=([^\s{}]+)\}/;function Rf(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function Vc(e,n){let i=0;for(let o=n;o<e.length;o++){const s=e[o];if(s===`
|
|
740
|
+
`)return-1;if(s==="\\"){o++;continue}if(s==="[")i++;else if(s==="]"&&(i--,i===0))return o}return-1}function If(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function Ef(e,n){const i=e[n];if(i==="["&&e[n+1]==="["){const o=e.indexOf("]]",n+2);return o>=0&&e.slice(n+2,o).indexOf(`
|
|
741
|
+
`)<0?{node:{type:"qw",label:e.slice(n+2,o)},end:o+2}:null}if(i===":"&&e.startsWith(":zi[",n)){const o=Vc(e,n+3);return o>n+4?{node:{type:"zi",label:If(e.slice(n+4,o))},end:o+1}:null}if(i==="□"&&e[n+1]==="{"){const o=Tf.exec(e.slice(n,n+64));if(o)return{node:{type:"qz",guess:o[1]},end:n+o[0].length}}return null}function Gc(e,n,i,o,s){const a=[];let l="",d=!1;const c=()=>{if(!l)return;let p=l;o&&(p=l.replace(/\\?\|/g,g=>d?"|":(d=!0,""))),p&&a.push({type:"text",text:p}),l=""};for(;n<e.length;){const p=e[n];if(p==="\\"&&(e[n+1]==="<"||e[n+1]===">")){l+=e[n+1],n+=2;continue}if(i!==null){if(p===i)return c(),{nodes:a,end:n};if(p===`
|
|
742
|
+
`)return null}const g=Ef(e,n);if(g){c(),a.push(g.node),n=g.end;continue}let m=null;if(p==="<"&&Rf(e,n)&&(m=">"),m){const u=Gc(e,n+1,m,!0,s);if(u&&!(u.end-(n+1)>s)){c(),a.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return i!==null?null:(c(),{nodes:a,end:n})}function Yc(e,n){return Gc(e,0,null,!1,(n==null?void 0:n.jzMaxLength)??Cf).nodes}function Lf(e){return/[<□]|\[\[|:zi\[/.test(e)}function Kc(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Kc(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const Af=216,Pa="clamp(280px, 23vw, 360px)",Mf=1440,eo="(max-width: 719px)",Pf=`${eo}, (pointer: coarse)`,Bf=`
|
|
743
|
+
.bim-d-main.bim-d-main-grid { max-width: ${Mf}px; padding: 16px 32px 0; }
|
|
744
744
|
.bim-d-grid {
|
|
745
745
|
display: grid;
|
|
746
|
-
grid-template-columns: ${
|
|
746
|
+
grid-template-columns: ${Af}px minmax(0, 1fr) ${Pa};
|
|
747
747
|
grid-template-rows: auto 1fr;
|
|
748
748
|
grid-template-areas: "rail main card" "rail main side";
|
|
749
749
|
column-gap: 32px; row-gap: 28px; align-items: start;
|
|
@@ -1096,7 +1096,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1096
1096
|
.bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
|
|
1097
1097
|
|
|
1098
1098
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1099
|
-
@media ${
|
|
1099
|
+
@media ${Pf} {
|
|
1100
1100
|
.bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
|
|
1101
1101
|
.bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
|
|
1102
1102
|
.bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
|
|
@@ -1134,7 +1134,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1134
1134
|
/* 中等宽度:左栏折到顶部一行 */
|
|
1135
1135
|
@media (max-width: 1100px) {
|
|
1136
1136
|
.bim-d-grid {
|
|
1137
|
-
grid-template-columns: minmax(0, 1fr) ${
|
|
1137
|
+
grid-template-columns: minmax(0, 1fr) ${Pa};
|
|
1138
1138
|
grid-template-rows: auto auto 1fr;
|
|
1139
1139
|
grid-template-areas: "rail rail" "main card" "main side";
|
|
1140
1140
|
}
|
|
@@ -1148,7 +1148,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1148
1148
|
}
|
|
1149
1149
|
|
|
1150
1150
|
/* 手机:左栏收起,提要卡 → 正文 → 旁栏 */
|
|
1151
|
-
@media ${
|
|
1151
|
+
@media ${eo} {
|
|
1152
1152
|
.bim-d-main.bim-d-main-grid { padding: 8px 16px 0; }
|
|
1153
1153
|
.bim-d-grid {
|
|
1154
1154
|
grid-template-columns: minmax(0, 1fr);
|
|
@@ -1223,7 +1223,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1223
1223
|
:root[data-layout="boxed"] .bim-d-g-rail { border: ${r("fr-bd")}; background: ${r("fr-bg")}; padding: 14px 8px; }
|
|
1224
1224
|
:root[data-layout="boxed"] .bim-d-filters { border-bottom: 1px solid ${r("fr-tab-bd")}; }
|
|
1225
1225
|
:root[data-layout="boxed"] .bim-d-filters .bim-d-tab { margin-bottom: -1px; }
|
|
1226
|
-
@media ${
|
|
1226
|
+
@media ${eo} {
|
|
1227
1227
|
:root[data-layout="boxed"] .bim-d-card { padding: 16px; }
|
|
1228
1228
|
:root[data-layout="boxed"] .bim-d-g-rail { border: 0; background: transparent; padding: 0; }
|
|
1229
1229
|
}
|
|
@@ -1238,7 +1238,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1238
1238
|
: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 {
|
|
1239
1239
|
text-decoration-color: currentColor; text-decoration-thickness: 2px;
|
|
1240
1240
|
}
|
|
1241
|
-
`;function
|
|
1241
|
+
`;function ri({railTop:e,back:n,up:i,nav:o,railLinks:s,main:a,card:l,side:d}){const{t:c,convert:p}=ae(),g=(o||[]).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}),i,g.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:g.map(m=>t.jsx("li",{children:t.jsxs("a",{href:`#${m.id}`,children:[t.jsx("span",{children:p(m.label)}),m.count!=null&&t.jsx("span",{className:"bim-d-meta",children:m.count})]})},m.id))})]}),s&&s.length>0&&t.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("detail.more"),children:[t.jsx("p",{className:"bim-d-rail-cap",children:c("detail.more")}),t.jsx("ul",{className:"bim-d-rail-nav",children:s.map(m=>t.jsx("li",{children:t.jsxs("a",{href:m.href??"#",onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),m.onClick())},children:[t.jsx("span",{children:p(m.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},m.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:a}),t.jsx("div",{className:"bim-d-g-card",children:l}),t.jsx("div",{className:"bim-d-g-side",children:d})]})}function qc({caption:e,children:n}){const{convert:i}=ae();return t.jsxs("div",{className:"bim-d-up bim-d-ui",children:[t.jsx("span",{className:"bim-d-up-cap",children:i(e)}),n]})}function bt({id:e,title:n,meta:i,action:o,children:s}){const{convert:a}=ae();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)}),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i}),o&&t.jsx("span",{className:"bim-d-sec-act",children:o})]}),t.jsx("div",{className:"bim-d-sec-body",children:s})]})}function ht({items:e,className:n,style:i}){const o=e.filter(s=>s!=null&&s!==""&&s!==!1);return o.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:i,children:o.map((s,a)=>t.jsxs(f.Fragment,{children:[a>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},a))}):null}function Ji({items:e,value:n,onChange:i}){const{convert:o}=ae();return t.jsx(t.Fragment,{children:e.map(s=>t.jsx("button",{type:"button",className:[...o(s.label)].length===1?"bim-d-tab bim-d-tab-1":"bim-d-tab","aria-pressed":s.key===n,onClick:()=>i(s.key),children:o(s.label)},s.key))})}function Xc({label:e,checked:n,onChange:i}){const{convert:o}=ae();return t.jsxs("label",{className:"bim-d-check",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:s=>i(s.target.checked)}),o(e)]})}const Zc=6,Qi=e=>e>Zc+1;function Ho({total:e,shown:n,unit:i,onClick:o}){const{t:s,convert:a}=ae(),l=e-n,d=Qi(e)?e-Math.min(n,Zc):l;return d<=0?null:t.jsxs("button",{type:"button",className:`bim-d-more bim-d-ui${l>0?"":" bim-d-more-ncap"}`,onClick:o,children:[l>0&&t.jsx("span",{className:"bim-d-more-w",children:s("detail.expandRest",{n:l,unit:a(i)})}),t.jsx("span",{className:"bim-d-more-n",children:s("detail.expandRest",{n:d,unit:a(i)})})]})}function Do({label:e,onClick:n}){const{convert:i}=ae();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:i(e)})}function oi({kind:e,title:n,subtitle:i,byline:o,meta:s,description:a,clampDescription:l,facts:d,stats:c,readAction:p,secondaryAction:g,children:m,foot:u}){const{t:h,convert:x}=ae(),j=(d||[]).filter(w=>w.value!=null&&w.value!==""),b=(c||[]).filter(w=>w.value!=null&&w.value!==""&&w.value!==0),[S,y]=f.useState(!1),k=!!l&&!S;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}),i&&t.jsx("div",{className:"bim-d-card-sub",children:i}),o&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:o}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),a&&t.jsx("div",{className:k?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:k?{"--detail-clamp":l}:void 0,children:a}),a&&!!l&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":S,onClick:()=>y(w=>!w),children:h(S?"action.collapse":"action.expand")}),b.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:b.map((w,v)=>t.jsxs("div",{children:[t.jsx("b",{children:w.value}),t.jsx("span",{children:x(w.label)})]},v))}),j.length>0&&t.jsx("dl",{className:"bim-d-ui",children:j.map((w,v)=>t.jsxs(f.Fragment,{children:[t.jsx("dt",{children:x(w.label)}),t.jsx("dd",{title:w.title,children:w.value})]},v))}),m,p,g,u&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:u})]})}function Uo(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function to({href:e,onClick:n,label:i}){const{t:o,convert:s}=ae(),a=i??o("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 un({id:e,title:n,meta:i,items:o,metas:s,currentIndex:a,cap:l=8,moreLabel:d,foot:c,sub:p,timeline:g}){const{t:m,convert:u}=ae(),[h,x]=f.useState(!1);if(!o.length)return null;const j=h?o:o.slice(0,l),b=o.length-j.length;return t.jsxs("div",{id:e,className:g?"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:[u(n),i!=null&&i!==""&&t.jsx("span",{className:"bim-d-meta",children:i})]}),p&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:p}),t.jsx("ul",{children:j.map((S,y)=>t.jsxs("li",{className:y===a?"bim-d-side-cur":void 0,"aria-current":y===a?"page":void 0,children:[S,s!=null&&s[y]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[y]}):null]},y))}),b>0&&t.jsx(Do,{label:d?d(b):m("detail.showMore",{n:b}),onClick:()=>x(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const Of=new Set(["reviewed","disputed","unreviewed","draft"]);function si({revision:e,revisedAt:n,review:i,todo:o}){const{t:s,convert:a}=ae(),l=i&&Of.has(i.status)?s(`detail.review.${i.status}`):void 0,d=i&&i.status!=="unreviewed"&&l?[l,i.by,i.date].filter(Boolean).join(" "):"",c=[e!=null&&e!==""?`${s("detail.dataVersion")} ${e}`:"",n??"",a(d)].filter(Boolean),p=(o||[]).filter(g=>g&&g.what);return!c.length&&!p.length?null:t.jsxs(t.Fragment,{children:[c.length>0&&t.jsx(ht,{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((g,m)=>t.jsxs("li",{children:[a(g.what),(g.by||g.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[g.by&&a(g.by),g.date].filter(Boolean).join(" · "),")"]})]},m))})]})]})}const Ni=1e3,Ba=208,Wf=1440,Ff="(max-width: 719px)",Jc=`
|
|
1242
1242
|
.bim-d-page {
|
|
1243
1243
|
background: ${r("page-bg")};
|
|
1244
1244
|
color: ${r("ink")};
|
|
@@ -1247,7 +1247,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1247
1247
|
padding-bottom: 64px;
|
|
1248
1248
|
}
|
|
1249
1249
|
.bim-d-main {
|
|
1250
|
-
max-width: ${
|
|
1250
|
+
max-width: ${Ni}px;
|
|
1251
1251
|
margin: 0 auto;
|
|
1252
1252
|
padding: 24px clamp(16px, 4vw, 28px) 0;
|
|
1253
1253
|
}
|
|
@@ -1258,7 +1258,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1258
1258
|
* PAGE_MAX_WIDTH,读者的行宽体验不变。
|
|
1259
1259
|
*/
|
|
1260
1260
|
.bim-d-main.bim-d-main-wide {
|
|
1261
|
-
max-width: ${
|
|
1261
|
+
max-width: ${Wf}px;
|
|
1262
1262
|
}
|
|
1263
1263
|
.bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
|
|
1264
1264
|
|
|
@@ -1290,9 +1290,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1290
1290
|
*/
|
|
1291
1291
|
.bim-d-reader {
|
|
1292
1292
|
display: grid;
|
|
1293
|
-
grid-template-columns: ${
|
|
1293
|
+
grid-template-columns: ${Ba}px minmax(0, ${Ni}px);
|
|
1294
1294
|
gap: 32px;
|
|
1295
|
-
max-width: ${
|
|
1295
|
+
max-width: ${Ba+Ni+32}px;
|
|
1296
1296
|
margin: 0 auto;
|
|
1297
1297
|
align-items: start;
|
|
1298
1298
|
}
|
|
@@ -1315,7 +1315,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1315
1315
|
align-items: start; margin-bottom: 48px; }
|
|
1316
1316
|
.bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
|
|
1317
1317
|
|
|
1318
|
-
@media ${
|
|
1318
|
+
@media ${Ff} {
|
|
1319
1319
|
.bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
|
|
1320
1320
|
.bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
|
|
1321
1321
|
/* 表格:meta 列折到第二行,表头隐藏 */
|
|
@@ -1333,22 +1333,22 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${r("tint-bg"
|
|
|
1333
1333
|
padding-right: 0; padding-bottom: 12px;
|
|
1334
1334
|
}
|
|
1335
1335
|
}
|
|
1336
|
-
${
|
|
1337
|
-
`)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function
|
|
1336
|
+
${Bf}`;function Kn({children:e,style:n,wide:i,grid:o}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:Jc}),t.jsx("div",{className:o?"bim-d-main bim-d-main-grid":i?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function no({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:r("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 Vo({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:r(n==="accent"?"accent":"ink"),color:r("page-bg")},children:e})}function io({items:e}){const n=gt();return t.jsx(t.Fragment,{children:e.map((i,o)=>{const s=o===e.length-1,a=o>0&&t.jsx("span",{style:{color:r("hint-fg")},children:"/"},`s${o}`),l=i.id?n(i.id):i.href,d=s||!i.onClick&&!l?t.jsx("span",{style:{color:r("ink")},children:i.label},o):t.jsx("a",{href:l??"#",onClick:i.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),i.onClick())}:void 0,style:{color:r("meta-fg")},children:i.label},o);return t.jsxs(f.Fragment,{children:[a,d]},o)})})}function Qc({title:e,subtitle:n,aside:i,secondLine:o}){return t.jsxs("header",{style:{borderBottom:`2px solid ${r("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:r("meta-fg"),letterSpacing:".06em"},children:n})]}),i&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg"),letterSpacing:".06em"},children:i})]}),o&&t.jsx("div",{style:{marginTop:12,fontSize:13.5,color:r("quiet-fg")},children:o})]})}function Hf({children:e,facts:n}){return!e&&n?t.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${r("rule")}`,marginBottom:40},children:n}):t.jsxs("div",{className:"bim-d-intro",children:[t.jsx("div",{style:{minWidth:0},children:e}),n]})}function Df({items:e,horizontal:n}){const{convert:i}=Ve();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${r("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((o,s)=>t.jsxs("div",{title:o.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:r("label-fg"),letterSpacing:".08em",flex:"none"},children:i(o.label)}),t.jsx("span",{style:{color:r("body-fg"),textAlign:n?"left":"right",minWidth:0},children:o.value})]},s))}):null}function Uf({glyph:e,tone:n,title:i,count:o,actions:s,id:a}){const{convert:l}=Ve();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(Vo,{char:e,tone:n}),t.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:l(i)}),o!=null&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:r("label-fg")},children:o})]}),s&&t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function ed({label:e,active:n,onClick:i,dashed:o}){const{convert:s}=Ve();return t.jsx("button",{type:"button",onClick:i,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${o&&!n?"dashed":"solid"} ${r(n?"accent":"rule")}`,background:n?r("accent"):"transparent",color:r(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function Vf({label:e,onClick:n}){const{convert:i}=Ve();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:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:i(e)})}function Gf({label:e,onClick:n,inline:i}){const{convert:o}=Ve();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:i?0:12,width:i?void 0:"100%",padding:i?"4px 12px":9,background:"none",border:`1px dashed ${r("rule-dashed")}`,cursor:"pointer",fontSize:12,color:r("meta-fg"),letterSpacing:i?void 0:".08em"},children:o(e)})}function td({children:e,href:n,onClick:i,title:o}){const s={display:"inline-block",padding:"4px 10px",border:`1px solid ${r("rule")}`,fontSize:13,color:r("body-fg"),lineHeight:1.5};return n||i?t.jsx("a",{href:n??"#",title:o,onClick:i?a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),i())}:void 0,style:s,children:e}):t.jsx("span",{title:o,style:s,children:e})}function Yf({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function Kf({volumes:e,unit:n,max:i=60}){const{t:o}=ae(),s=n??o("unit.volume"),[a,l]=f.useState(!1);if(!e.length)return null;const d=a?e:e.slice(0,i);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 ${r("rule")}`,color:r("meta-fg")},children:c},c)),!a&&e.length>i&&t.jsxs("button",{type:"button",onClick:()=>l(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${r("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:r("meta-fg")},children:["+",e.length-i]}),t.jsx("span",{style:{padding:"2px 6px",color:r("hint-fg")},children:s})]})}function qf({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${r("rule-strong")}`},children:e})}function Xf({spec:e}){const{convert:n}=Ve();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 ${r("rule-strong")}`,fontSize:11,color:r("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(i=>i.width).join(" "),gap:12},children:e.columns.map(i=>t.jsx("span",{children:n(i.label)},i.label))})]})}function Zf({no:e,main:n,meta:i,spec:o}){return t.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${o.leadWidth}px 1fr ${o.metaWidth}px`,gap:12},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("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:o.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:i})]})}function Jf(e){return String(e+1).padStart(2,"0")}function Qf(){return t.jsx("span",{style:{color:r("hint-fg")},children:"—"})}function eh({open:e,onToggle:n,main:i,action:o,children:s}){return t.jsxs("div",{style:{borderBottom:`1px solid ${r("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 ${r(e?"accent":"rule-dashed")}`,background:e?r("accent"):"transparent",color:r(e?"page-bg":"accent")},children:e?"-":"+"}),t.jsx("span",{style:{fontSize:14,minWidth:0},children:i}),o]}),e&&s&&t.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${r("rule-accent-soft")}`,marginLeft:12},children:s})]})}function nd(e){const n=[];for(let i=0;i<e.length;i++){if(e[i]!=="<")continue;const s=e[i+1];if(s===void 0||/[A-Za-z/!?>\s]/.test(s))continue;const l=e.indexOf(">",i+1);if(l<0)continue;const d=e.slice(i+1,l);d.includes(`
|
|
1337
|
+
`)||(n.push({start:i,end:l+1,inner:d}),i=l)}return n}function id(e,n){if(e.length<=n)return e;let i=n;for(const o of nd(e)){if(o.start>=i)break;if(o.end>i){i=o.start>0?o.start:o.end;break}}return e.slice(0,i)}const rd={fontSize:".78em",color:r("meta-fg"),lineHeight:1.55},th={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 od(e,n,i,o){return e.map((s,a)=>{switch(s.type){case"text":return t.jsx(f.Fragment,{children:n(s.text)},a);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:i===0?rd:void 0,children:od(s.children,n,i+1,o)},a);case"qw":return t.jsx("span",{className:"bim-qw guji-qw",title:s.label?o("detail.lacunaWith",{label:s.label}):o("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:o("detail.composedChar",{label:s.label}),style:th,children:s.label},a)}})}function Nt(e,n=o=>o,i){if(!e)return"";if(i!=null&&i.gujiMarkdown)return Lf(e)?od(Yc(e,{jzMaxLength:i.jzMaxLength}),n,0,i.t??In("zh-Hant")):n(e);if(e.indexOf("<")<0)return n(e);const o=[];let s=0,a=0;for(const l of nd(e))l.start>s&&o.push(t.jsx(f.Fragment,{children:n(e.slice(s,l.start))},a++)),o.push(t.jsx("span",{className:"bim-jiazhu",style:rd,children:n(l.inner)},a++)),s=l.end;return s<e.length&&o.push(t.jsx(f.Fragment,{children:n(e.slice(s))},a++)),o}function nh({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:r("label-fg"),marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:r("quiet-fg"),textAlign:"justify"},children:n})]})}function ih({title:e,tag:n,children:i}){const{convert:o}=Ve();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${r("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:o(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:r("accent"),letterSpacing:".06em"},children:o(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:i})]})}function sd({name:e,note:n,href:i,extra:o}){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:r("hint-fg"),flex:"none"},children:i?"↗":""}),n&&t.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:r("label-fg")},children:n})]}),a={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${r("rule")}`,color:r("body-fg"),alignItems:"baseline"};return t.jsxs(t.Fragment,{children:[i?t.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",style:a,children:s}):t.jsx("div",{style:a,children:s}),o]})}function rh({item:e,siblings:n,showVolumes:i=!0,fallbackNote:o}){const{t:s,convert:a}=ae(),[l,d]=f.useState(!1),c=Fi(e),p=i&&!!c&&c.expected>0,g=(e.url?Nn(e.url):void 0)||a(e.name),m=n?ic(e,n):"",u=m?`${g}(${m})`:g;return t.jsx(sd,{name:u,note:Gi(e,s)||o,href:Tn(e),extra:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(h=>!h),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:r("meta-fg"),borderBottom:`1px solid ${r("rule")}`},children:l?s("detail.collapseVolumes"):s("detail.expandVolumes",{n:c.expected})}),l&&t.jsx(Go,{item:e})]}):void 0})}function Go({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,i)=>{const o=n.status==="missing";return n.url&&!o?t.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{padding:"4px 8px",borderRadius:4,background:r("zebra-bg")},children:n.volume},i):t.jsx("span",{style:{padding:"1px 5px",color:r(o?"missing-fg":"hint-fg"),textDecoration:o?"line-through":void 0},children:n.volume},i)})})}function ad({label:e,items:n}){const{convert:i}=Ve();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:r("label-fg"),letterSpacing:".08em"},children:e}),n.map((o,s)=>t.jsx(td,{children:i(o)},s))]}):null}function oh({rows:e}){const n=e.filter(i=>i.items.length>0);return n.length?t.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(i=>t.jsx(ad,{label:i.label,items:i.items},i.label))}):null}function ro(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function ld({left:e,right:n}){return t.jsxs("footer",{className:"bim-d-ui",style:{marginTop:52,paddingTop:14,borderTop:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",justifyContent:"space-between",gap:"8px 16px",fontSize:11.5,color:r("aux-fg")},children:[t.jsx("span",{children:e}),n&&t.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function sh({children:e,action:n}){return t.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:r("aux-fg"),borderBottom:`1px solid ${r("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[t.jsx("span",{children:e}),n]})}function ut({id:e,label:n,onNavigate:i,renderLink:o,style:s,dense:a}){const l=gt();return o?t.jsx(t.Fragment,{children:o(e,typeof n=="string"?n:void 0,{dense:a})}):t.jsx("a",{href:l(e),onClick:i?d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),i(e))}:void 0,style:s,children:n??e})}function ah({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 cd="guji-table-v1";function lh(e){return!!e&&e.table_notation===cd}const ch=/^:::table(?:\{[^}]*\})?[ \t]*$/,dh=/^:::[ \t]*$/;function dd(e){const n=[];let i="";for(let o=0;o<e.length;o++){const s=e[o];if(s===":"&&e.startsWith(":zi[",o)){const l=Vc(e,o+3);if(l>o+4){i+=e.slice(o,l+1),o=l;continue}}let a=null;if(s==="<"){const l=e[o+1];l!==void 0&&!/[A-Za-z/!?>\s]/.test(l)&&(a=">")}if(a){const l=e.indexOf(a,o+1);if(l>0){i+=e.slice(o,l+1),o=l;continue}}s==="|"?(n.push(i),i=""):i+=s}return n.push(i),n.map(o=>o.trim())}const ph=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function uh(e){if(e==="^")return{cont:!0};const n=ph.exec(e),i=n[1].trim(),o=n[2]?Math.max(1,parseInt(n[2],10)):1,s=n[3]?Math.max(1,parseInt(n[3],10)):1,a=i==="_";return{cont:!1,cell:{text:a?"":i,empty:a,colspan:o,rowspan:s}}}function pd(e,n=1){const i=[],o=[],s=[];let a=[];e.forEach((d,c)=>{const p=c+n+1;let g=d.trim();if(!g)return;let m=!1;g.startsWith("!")&&(m=!0,g=g.slice(1));const u=dd(g).map(uh),h=a.map(S=>S>0),x=a.map(S=>S>0?S-1:0),j=[];let b=0;for(const S of u){if(S.cont){h[b]||i.push(`第 ${p} 行第 ${b+1} 列:续格 ^ 上方没有跨行格`),b+=1;continue}const{cell:y}=S;for(let k=b;k<b+y.colspan;k++)if(h[k]){i.push(`第 ${p} 行第 ${k+1} 列:此处被上方跨行格占住,应写 ^`);break}if(y.rowspan>1)for(let k=b;k<b+y.colspan;k++)x[k]=y.rowspan-1;j.push(y),b+=y.colspan}for(let S=b;S<h.length;S++)h[S]&&i.push(`第 ${p} 行第 ${S+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let S=0;S<x.length;S++)x[S]===void 0&&(x[S]=0);a=x,o.push({header:m,cells:j}),s.push({width:b,line:p})});const l=s.reduce((d,c)=>Math.max(d,c.width),0);for(const d of s)d.width!==l&&i.push(`第 ${d.line} 行:占 ${d.width} 列,与总列数 ${l} 不符`);return a.some(d=>d>0)&&i.push("表尾:有跨行格超出了表的最后一行"),o.length===0&&i.push("空表"),{rows:o,columns:l,warnings:i}}function Yo(e){const n=e.split(`
|
|
1338
1338
|
`),i=[];let o=[];const s=()=>{if(o.length===0)return;const l=o.join(`
|
|
1339
|
-
`);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(
|
|
1340
|
-
`)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,g;if(l.type!=="text")return l;let c=l.text;return((p=i[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((g=i[d+1])==null?void 0:g.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const
|
|
1341
|
-
`).map(n=>n.trim()).filter(n=>n&&!
|
|
1342
|
-
`)){const s=o.trim();if(!s||
|
|
1339
|
+
`);o=[],i.push({type:"text",text:l})};let a=0;for(;a<n.length;){if(ch.test(n[a].trim())){let l=a+1;for(;l<n.length&&!dh.test(n[l].trim());)l++;if(l<n.length){s();const d=n.slice(a+1,l);i.push({type:"table",table:pd(d,a+1),source:n.slice(a,l+1).join(`
|
|
1340
|
+
`)}),a=l+1;continue}}o.push(n[a]),a++}return s(),i.map((l,d)=>{var p,g;if(l.type!=="text")return l;let c=l.text;return((p=i[d-1])==null?void 0:p.type)==="table"&&(c=c.replace(/^\n+/,"")),((g=i[d+1])==null?void 0:g.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(l=>l.type!=="text"||l.text!=="")}const mh={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},gh={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},fh=`1px solid ${r("table-border")}`,ud={border:fh,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},hh={...ud,background:r("table-head-bg"),fontWeight:600};function Ko({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:mh,children:t.jsx("table",{className:"bim-guji-table",style:gh,children:t.jsx("tbody",{children:e.rows.map((i,o)=>t.jsx("tr",{children:i.cells.map((s,a)=>{const l=i.header?"th":"td";return t.jsx(l,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:i.header?hh:ud,children:s.empty?null:Nt(s.text,void 0,n)},a)})},o))})})})}function xh(e,n){return e.indexOf("**")<0?Nt(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((o,s)=>s%2===1?t.jsx("strong",{children:Nt(o.trim().slice(2,-2),void 0,n)},s):t.jsx(f.Fragment,{children:Nt(o,void 0,n)},s))}function bh(e,n,i=!1){const o=i?{gujiMarkdown:!0}:void 0;return n?Yo(e).map((s,a)=>s.type==="table"?t.jsx(Ko,{table:s.table,opts:o},a):t.jsx(f.Fragment,{children:xh(s.text,o)},a)):Nt(e,void 0,o)}const yh=/^(#{1,6})\s+(.*)$/,jh=/^\*\*([^*\n]+)\*\*\s*$/;function qo(e){const n=e.match(yh);if(n)return{level:n[1].length,text:n[2].trim()};const i=e.trim().match(jh);return i?{level:3,text:i[1].trim()}:null}const Xo=/^<!--.*-->$/;function md(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function gd(e){return e.split(`
|
|
1341
|
+
`).map(n=>n.trim()).filter(n=>n&&!Xo.test(n))}const vh=60;function fd(e){let n=0,i=0;for(const o of e.split(`
|
|
1342
|
+
`)){const s=o.trim();if(!s||Xo.test(s)||qo(s))continue;const a=s.replace(/<[^<>\n]*>/g,"").replace(/\s/g,"").length;n+=a,a>vh&&(i+=a)}return n>0&&i*2>=n}function kh(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function er(e){if(e=kh(e),fd(e))return"unknown";const n=md(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const i=n.map(s=>gd(s).length).filter(s=>s>0);if(i.length===0)return"unknown";const o=i.reduce((s,a)=>s+a,0)/i.length;return o<=4?"record":o>=8?"catalog":"unknown"}function wh(e){const n=e.split(`
|
|
1343
1343
|
`),i=[];let o=null,s=[];const a=()=>{i.push({heading:o,body:s.join(`
|
|
1344
|
-
`)}),s=[]};for(const l of n){const d=
|
|
1345
|
-
`)){const o=
|
|
1346
|
-
`)?"":n)}function
|
|
1347
|
-
`);let p=0;return t.jsx(t.Fragment,{children:c.map((g,m)=>{const u=g.match(
|
|
1348
|
-
,。、;:?!「」『』()…—·`));function
|
|
1344
|
+
`)}),s=[]};for(const l of n){const d=qo(l);if(d){a(),o={kind:"heading",level:d.level,text:d.text};continue}s.push(l)}return a(),i}function Oa(e){const n=[];for(const i of e.split(`
|
|
1345
|
+
`)){const o=qo(i);if(o){n.push({kind:"heading",level:o.level,text:o.text});continue}const s=i.trim();!s||Xo.test(s)||n.push({kind:"body",text:i})}return n}function hd(e){if(!e)return[];const n=er(e);if(n==="unknown")return Oa(e);const i=[];for(const{heading:o,body:s}of wh(e)){o&&i.push(o);const a=md(s);if(a.length!==0){if(fd(s)){i.push(...Oa(s));continue}if(n==="record"){const l=a.join(" ");l&&i.push({kind:"body",text:l})}else for(const l of a){const d=gd(l);d.length&&i.push({kind:"body",text:d.join(" ")})}}}return i}const Sh={"「":"“","」":"”","『":"‘","』":"’"},_h={"“":"「","”":"」","‘":"『","’":"』"},$h=new Set(["《","》","〈","〉"]);function xd(e,n){const i=n.quoteStyle==="modern"?Sh:n.quoteStyle==="classic"?_h:null;let o="";for(const s of e)n.hideBookBrackets&&$h.has(s)||(o+=(i==null?void 0:i[s])??s);return o}const bd=e=>e;function Zo(e){return e.showWorks?e.bookTitleStyle==="bracket"?"bracket":pf(e.properNameMode)?"wavy":"bracket":"none"}function yd(e,n=bd,i="wavy"){if(e.indexOf("《")<0)return n(e);const o=[],s=/《([^《》\n]+)》/g;let a=0,l=0,d;for(;d=s.exec(e);){d.index>a&&o.push(t.jsx(f.Fragment,{children:n(e.slice(a,d.index))},l++));const c=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(d[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]});o.push(i==="wavy"?t.jsx("span",{className:"bim-rd-pn",children:c},l++):t.jsx(f.Fragment,{children:c},l++)),a=d.index+d[0].length}return a===0?n(e):(a<e.length&&o.push(t.jsx(f.Fragment,{children:n(e.slice(a))},l++)),o)}function tr(e,n={}){let i=n.renderText??bd;const o=n.quoteStyle;if(o&&o!=="original"){const d=i;i=c=>d(xd(c,{quoteStyle:o}))}const s=n.bookMarking??(n.properNames?"wavy":"bracket"),a=s==="bracket"?i:d=>yd(d,i,s),l=n.gujiMarkdown?{gujiMarkdown:!0,t:n.t}:void 0;return Nt(e,a,l)}function Wa(e,n,i){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))},`${i}-${a}`):t.jsx(f.Fragment,{children:n(s)},`${i}-${a}`))}const Er=/^(#{1,6})\s+(.*)$/,Ch=/^\s*<!--.*-->\s*$/;function jd(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
1346
|
+
`)?"":n)}function zh(e){return e<=1?2:e===2?3:4}function Nh(){let e=1;return n=>{const i=zh(n),o=Math.min(i,e+1);return e=o,{Tag:`h${o}`,className:`bim-rd-hl${i}`}}}function Pi(e){return e?er(jd(e))!=="unknown":!1}function Th(e){return/^\u3000{2}/.test(e)}const Fa=e=>Th(e)?"bim-rd-noindent":void 0;function Ha({text:e,mode:n,inline:i,dropTitle:o,onStart:s}){s==null||s();const a=jd(e),l=(g,m,u)=>!!o&&u<=1&&g<=2&&m.trim()===o.trim(),d=Nh();if(n==="paragraph"&&er(a)!=="unknown"){const g=hd(a);return t.jsx(t.Fragment,{children:g.map((m,u)=>{if(m.kind==="heading"){if(l(m.level??1,m.text,u))return null;const{Tag:h,className:x}=d(m.level??1);return t.jsx(h,{className:x,children:i(m.text)},u)}return t.jsx("p",{className:Fa(m.text),children:Wa(m.text,i,u)},u)})})}const c=a.split(`
|
|
1347
|
+
`);let p=0;return t.jsx(t.Fragment,{children:c.map((g,m)=>{const u=g.match(Er);if(u){const x=p++;if(l(u[1].length,u[2],x))return null;const{Tag:j,className:b}=d(u[1].length);return t.jsx(j,{className:b,children:i(u[2])},m)}if(!g.trim())return m>=2&&!!c[m-1].trim()&&!!c[m-2].trim()&&!Er.test(c[m-1])&&!Er.test(c[m-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},m):null;if(Ch.test(g))return null;if(p++,/^\*\*[^*]+\*\*\s*$/.test(g.trim())){const{Tag:x,className:j}=d(3);return t.jsx(x,{className:j,children:i(g.trim().slice(2,-2))},m)}return t.jsx("p",{className:Fa(g),children:Wa(g,i,m)},m)})})}function Rh(e){const{convert:n}=Ve();return f.useMemo(()=>e?n(e):"",[e,n])}function Jo({text:e,mode:n,tables:i=!1,gujiMarkdown:o=!1,properNames:s=!1,bookMarking:a,quoteStyle:l,renderText:d,dropTitle:c}){const p=Rh(e),{t:g,convert:m}=ae();let u=null;const h=!!d&&!kf(e,p,!l||l==="original"),x=d&&h?k=>d(k,{mdStart:u==null?void 0:u.align(k)}):d,j=h?()=>{u=$f(e)}:void 0,b=k=>tr(k,{renderText:x,properNames:s,bookMarking:a,quoteStyle:l,gujiMarkdown:o,t:g}),S=o?{gujiMarkdown:!0,t:g}:void 0,y=c?m(c):void 0;return!i||p.indexOf(":::")<0?t.jsx(Ha,{text:p,mode:n,inline:b,dropTitle:y,onStart:j}):t.jsx(t.Fragment,{children:Yo(p).map((k,w)=>k.type==="table"?t.jsx(Ko,{table:k.table,opts:S},w):t.jsx(Ha,{text:k.text,mode:n,inline:b,dropTitle:w===0?y:void 0},w))})}const Da={work:"work",book:"work",people:"people",person:"people",place:"place",office:"office",dynasty:"dynasty",reign:"reign"};function Ih(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(Da,e)&&Da[e]||"other"}function ti(e){if(!e)return null;const n=e.trim(),i=/^book-index:\/\/(?:[A-Za-z]+\/)*([0-9A-Za-z]+)\/?$/.exec(n);if(i)return i[1];const o=/^bid:\\{1,2}([0-9A-Za-z]+)$/.exec(n);return o?o[1]:/^[0-9A-Za-z]+$/.test(n)?n:null}function en(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function ot(e){return typeof e=="string"&&e?e:void 0}function Eh(e){const n=e&&typeof e=="object"?e.candidates:void 0;if(!Array.isArray(n))return;const i=[];for(const o of n){if(!o||typeof o!="object"||Array.isArray(o))continue;const s=o,a={};ot(s.entity_id)!==void 0&&(a.entity_id=ot(s.entity_id)),ot(s.canonical_name)!==void 0&&(a.canonical_name=ot(s.canonical_name)),en(s.confidence)!==void 0&&(a.confidence=en(s.confidence)),i.push(a)}return i}function Lh(e){if(!Array.isArray(e.targets))return;const n=[];for(const i of e.targets){if(!i||typeof i!="object"||Array.isArray(i))continue;const o=i,s=ti(ot(o.entity_id))??ti(ot(o.href));s&&n.push({id:s,...ot(o.canonical_name)?{canonicalName:ot(o.canonical_name)}:{},...ot(o.part)?{part:ot(o.part)}:{}})}return n.length>=2?n:void 0}const wn=e=>e.start!==void 0&&e.end!==void 0;function vd(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.entities)?e.entities:[],i=[];return n.forEach((o,s)=>{if(!o||typeof o!="object")return;const a=o,l=a.span??{},d=a.target??{},c=en(l.start_offset)??en(a.start_offset),p=en(l.end_offset)??en(a.end_offset),g=c!==void 0&&p!==void 0&&c>=0&&p>c,m=a.anchor??{},u=ot(m.start),h=ot(m.end);if(!g&&!!!(u&&h))return;const j=ot(d.status),b=j===void 0||j==="matched"?ti(ot(d.entity_id))??ti(ot(d.href))??void 0:void 0,S=en(d.confidence),y=j==="matched_multi"?Lh(d):void 0,k=Eh(a.ambiguous);i.push({...u&&h?{anchor:{start:u,end:h}}:{},key:ot(a.id)??`e${s}`,kind:Ih(a.type),...g?{start:c,end:p}:{},text:ot(a.text),targetId:b,canonicalName:ot(d.canonical_name),...y?{targets:y}:{},confidence:en(a.confidence)??S,...S!==void 0?{targetConfidence:S}:{},...ot(d.level)!==void 0?{targetLevel:ot(d.level)}:{},...ot(d.note)!==void 0?{targetNote:ot(d.note)}:{},...ot(a.group)!==void 0?{group:ot(a.group)}:{},...k!==void 0?{candidates:k}:{}})}),i.sort((o,s)=>!wn(o)||!wn(s)?+!wn(o)-+!wn(s):o.start-s.start||s.end-o.end)}const Ah=new Set(Array.from(`《》/<>\r
|
|
1348
|
+
,。、;:?!「」『』()…—·`));function Qo(e){return!Ah.has(e)}function kd(e,n,i=0){const o=[],s=Array.from(e);let a=0;for(const d of s)Qo(d)&&o.push(a),a+=d.length;const l=[];for(const d of n){if(!wn(d))continue;const c=d.start-i,p=d.end-i;if(c<0||p>o.length||p<=c)continue;const g=o[p-1],m=e.codePointAt(g)>65535?2:1;l.push({...d,start:o[c],end:g+m})}return l}function Mh(e,n){return n.text?Array.from(e.slice(n.start,n.end)).filter(Qo).join("")===n.text:!0}function Ph(e,n,i){if(!n.text)return null;let o=-1,s=Math.max(0,n.start-i);const a=n.start+i;for(;s<=a;){const l=e.indexOf(n.text,s);if(l<0||l>a)break;(o<0||Math.abs(l-n.start)<Math.abs(o-n.start))&&(o=l),s=l+1}return o<0?null:{...n,start:o,end:o+n.text.length}}function wd(e,n,i=16){const o=[];for(const l of n){if(!wn(l))continue;let d={...l,start:Math.max(0,l.start),end:Math.min(e.length,l.end)};(d.end<=d.start||!Mh(e,d))&&(d=Ph(e,l,i)),d&&o.push(d)}o.sort((l,d)=>l.start-d.start||d.end-l.end);const s=[];let a=0;for(const l of o)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 Bh={off:[],lite:["people","place","dynasty"],full:["people","place","dynasty","office","reign","other"]};function Oh(e,n,i){const o=(i==null?void 0:i.showWorks)!==!1,s=new Set(Bh[n]);return e.filter(a=>a.kind==="work"?o:s.has(a.kind))}function Wh(e,n,i,o=""){const s=`${o}
|
|
1349
1349
|
${i.versionKey??""}
|
|
1350
|
-
${n??""}`,[a,l]=f.useState({tag:"",images:null}),d=f.useRef(0);f.useEffect(()=>{const p=++d.current,g=u=>{p===d.current&&l({tag:s,images:u})};if(!e||!n){g(null);return}let m;try{m=e(n,i)}catch{g(null);return}if(!m||typeof m.then!="function"){g(m??null);return}m.then(u=>g(u??null),()=>g(null))},[e,n,i,s]);const c=a.tag===s;return{images:c?a.images:null,loading:!!e&&!!n&&!c}}function Bh(){let e=null;const n=new Set;return{get:()=>e,set:i=>{i!==e&&(e=i,n.forEach(o=>o()))},subscribe:i=>(n.add(i),()=>{n.delete(i)})}}function Oh(e){return f.useSyncExternalStore(e.subscribe,e.get,e.get)}function Fa({store:e,children:n}){const i=Oh(e);return f.createElement(f.Fragment,null,n(i))}function Wh(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(Uu,e)?e:null}function Fh(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const Hh={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},vd="\0";function Dh(e,n,i){const[o,s=""]=e.split(vd);return t.jsxs(t.Fragment,{children:[o,t.jsx(Cc,{text:n,convert:i}),s]})}function Nt(e){return typeof e!="string"?"":Hh[e]??e}const Uh=["〇","一","二","三","四","五","六","七","八","九"],Ha=["","十","百","千"],Vh=["","萬","億"];function Jo(e){if(e===0)return"〇";if(e<0)return`負${Jo(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(Gh(s,o>0)+Vh[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Gh(e,n){const i=[];let o=e;for(;o>0;)i.unshift(o%10),o=Math.floor(o/10);let s="";for(let a=0;a<i.length;a++){const l=i[a],d=i.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=Ha[d]:s+=Uh[l]+Ha[d]}return s.replace(/〇$/,"")}let Zn=null,vi=null;const Mi=new Set;function Yh(){return Zn?Promise.resolve():vi||(vi=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Zn=i=>n(Ee.normalizeVariants(i)),Mi.forEach(i=>i())}).catch(()=>{Zn=e=>e,Mi.forEach(e=>e())}),vi)}const Kh=e=>e;function gn(){const[,e]=f.useState(0);return f.useEffect(()=>{if(Zn)return;const n=()=>e(i=>i+1);return Mi.add(n),Yh(),()=>{Mi.delete(n)}},[]),Zn??Kh}function Cn(e,n){return n(e).toLowerCase()}const qh=r("highlight-bg");function si(e,n,i){if(!n)return e;const o=Cn(n,i);if(!o)return e;const s=Cn(e,i),a=Array.from(e),l=Array.from(s);if(l.length!==a.length)return e;const d=new Map;let c=0;l.forEach((x,j)=>{d.set(c,j),c+=x.length});const p=Array.from(o).length,g=[];let m=0,u=0,h=0;for(;m<a.length;){const x=s.indexOf(o,u),j=x===-1?void 0:d.get(x);if(x===-1){g.push(a.slice(m).join(""));break}if(j===void 0){u=x+1;continue}j>m&&g.push(a.slice(m,j).join("")),g.push(t.jsx("mark",{style:{background:qh,padding:0,color:"inherit"},children:a.slice(j,j+p).join("")},h++)),m=j+p,u=x+o.length}return t.jsx(t.Fragment,{children:g})}function Qo(e,n,i,o){if(!n)return!0;const s=Cn(n,o);return(i?[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"&&Cn(l,o).includes(s))}function Xh(e,n,i){return n?Cn(e,i).includes(Cn(n,i)):!0}const es={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},Zh={考证:r("section-kaozhen")};function ts(e,n,i){return e.collated.sectionType[n]??i(n)}function kd(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+kd(a),0))||0;return n+i}function Jh(e,n){const i=[],o=l=>{var d;i.push(...l.files),(d=l.children)==null||d.forEach(o)};if(o(e),i.length===0)return;const s=i.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 Qh={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function ns({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...Qh,...o},children:s}):t.jsx("span",{style:o,children:s})}function ex({type:e}){const{convert:n,messages:i}=ae(),o=Nt(e),s=es[o]||r("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:ts(i,o,n)})}function tx({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=ae(),c=mt(),p=gn(),g=k=>k?Ct(d(k),w=>i?si(w,i,p):w,{t:l}):"",[m,u]=f.useState(!1),h=!!e.summary,x=!!e.comment,j=!!e.additional_comment,b=!!(e.content&&e.content.length>60),$=h||x||j||b;f.useEffect(()=>{i&&u(!0)},[i]);const y=!m&&b?ed(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${r("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>$&&u(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:$?"pointer":"default",userSelect:"none"},children:[o!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:r("label-fg")},children:o}),t.jsxs(ns,{enabled:$,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[$&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",g(e.book_title),"》"]}):g(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(Jo(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:g(e.author_info||e.author)})]}),!m&&y&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:g(y)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:g(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:r("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:k=>{k.metaKey||k.ctrlKey||(k.preventDefault(),k.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:r("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:r("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),m&&$&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:g(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:g(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:g(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:g(e.additional_comment)})]}),b&&!h&&!x&&!j&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:g(e.content)})]})]})}function nx({section:e,highlightQuery:n=""}){const{t:i,convert:o}=ae(),s=gn(),a=p=>p?Ct(o(p),g=>n?si(g,n,s):g,{t:i}):"",[l,d]=f.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(ns,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(ex,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("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, ${es[Nt(e.type)]||r("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:r("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const ix=100;function is(e){return Nt(e.type)!=="page_header"?!1:(e.content||"").length>=ix}function rx({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=ae(),a=gn();if(Nt(e.type)==="page_header"&&!is(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1351
|
-
`)),d=Ct(l,m=>n?si(m,n,a):m,{t:i}),c=Nt(e.type),p=es[c]||r("desc-fg"),g=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:g?"10px 12px":"6px 0",margin:g?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:g?`3px solid ${p}40`:void 0,background:g?r("bg"):void 0,borderRadius:g?"0 4px 4px 0":void 0,position:"relative"},children:[g&&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:ts(s,c,o)}),d]})}function ox(e,n,i){const[o,s]=f.useState({});return f.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(g=>{var m;return!((m=i==null?void 0:i.current)!=null&&m.has(g))}),d={};for(const g of e)(p=i==null?void 0:i.current)!=null&&p.has(g)&&(d[g]=i.current.get(g));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async g=>{var m;try{if(n.getEntry){const b=await n.getEntry(g);if(b)return{title:b.title,author:b.author}}const u=await n.getItem(g);if(!u)return null;const h=u.title||g,x=u.authors,j=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:h,author:j}}catch{return null}};return Promise.all(l.map(async g=>{var u;const m=await c(g);return(u=i==null?void 0:i.current)==null||u.set(g,m),[g,m]})).then(g=>{a||s(m=>{const u={...m};for(const[h,x]of g)u[h]=x;return u})}),()=>{a=!0}},[e.join(","),n]),o}function sx({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=ae(),c=mt(),p=gn(),g=w=>w?Ct(l(w),v=>s?si(v,s,p):v,{t:a}):"",[m,u]=f.useState(!1);f.useEffect(()=>{s&&u(!0)},[s]);const h=Nt(e.type),x=Zh[h]||r("desc-fg"),j=!!e.content,b=e.work_ids||[],$=b.length>1,y=ox($?b:[],i,o),k=j&&!m&&e.content.length>80?ed(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>j&&u(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:j?"pointer":"default",userSelect:"none"},children:[t.jsxs(ns,{enabled:j,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[j&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg"),lineHeight:1.6},children:e.header_line?g(e.header_line):g(e.title)}),!m&&k&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:g(k)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[b.length===1&&n&&t.jsx("a",{href:c(b[0]),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(b[0]))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),$&&t.jsx("span",{style:{fontSize:"11px",color:r("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:b.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:ts(d,h,l)})]})]}),$&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:b.map(w=>{const v=y[w],C=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:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:w,children:["→",C]},w)})}),m&&j&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:g(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${r("widget-border")}`,fontSize:"12px",color:r("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:g(e.comment)})]})]})}function ax({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=ae(),l=gn(),d=n.trim(),c=f.useMemo(()=>d?e.sections.filter(p=>Qo(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,g)=>t.jsx(sx,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},g))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function lx(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function cx({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=mt(),{t:a,convert:l}=ae(),d=lx();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const g=Nt(c.type);if(g==="page_header"&&!is(c))return null;if(g==="类")return t.jsxs(f.Fragment,{children:[f.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(g==="书"||g==="诗"||g==="考证"||g==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:Jo(c.n_juan)}):""}`:c.title,u=i(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[f.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:u}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):u),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((h,x)=>t.jsx("p",{children:i(l(h))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),i(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),i(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),i(l(c.additional_comment))]})]},p)}return g==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function wd(e){return e.some(n=>{const i=Nt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&is(n)})}function dx({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:g,onViewChange:m}){var ne;const{t:u,convert:h,messages:x}=ae(),j=gn(),[b,$]=f.useState("text"),y=g??b,k=ue=>{$(ue),m==null||m(ue)},w=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",C=f.useCallback(ue=>w?si(ue,w,j):ue,[w,j]),S=qo(p),_=ue=>Qi(ue,{renderText:C,bookMarking:S,quoteStyle:p.quoteStyle,t:u}),R=f.useMemo(()=>w?e.sections.filter(ue=>Qo(ue,w,v,j)):e.sections,[e.sections,w,v,j]),z=(ue,ke)=>ke.filter(Ae=>Nt(Ae.type)===ue).length,N=z("书",e.sections),I=z("诗",e.sections),B=z("考证",e.sections);let O="";v?O=w?u("collated.countTiaoOf",{m:z("考证",R),n:B}):u("collated.countTiao",{n:B}):I>0?O=w?u("collated.countPoemsOf",{m:z("诗",R),n:I}):u("collated.countPoems",{n:I}):N>0&&(O=w?u("collated.countBooksOf",{m:z("书",R),n:N}):u("collated.countBooks",{n:N}));const A=s!=null&&s.text_quality?Wh(s.text_quality.grade):null,W=[];if(O&&W.push(O),v&&(s!=null&&s.target_source)&&W.push(t.jsx(t.Fragment,{children:u("collated.kaozhenTarget",{target:h(s.target_source)})})),A){const ue=t.jsx("span",{className:"bim-rd-grade",style:Fh(A),children:x.collated.qualityLabel[A]});W.push(t.jsx("span",{title:x.collated.qualityCriteria[A],children:(ne=s==null?void 0:s.text_quality)!=null&&ne.source_note?t.jsxs(t.Fragment,{children:[Dh(u("collated.baseText",{note:vd}),s.text_quality.source_note,h),ue]}):t.jsxs(t.Fragment,{children:[u("collated.textQuality"),ue]})}))}e.source_url&&W.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:u("collated.originalSource")}));const G=!v&&wd(e.sections),oe=!!n&&(!G||p.readingMode==="paragraph"&&Ai(n)),se=!v&&(G||!!n),Y=v||!se?"entries":y;let de=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(i||o)&&t.jsxs("p",{className:"bim-rd-kicker",children:[i,i&&o&&t.jsx("span",{className:"bim-rd-dot"}),o&&h(o)]}),t.jsx("h1",{className:"bim-rd-h1",children:h(e.title)}),W.length>0&&t.jsx("p",{className:"bim-rd-meta",children:W.map((ue,ke)=>t.jsxs(f.Fragment,{children:[ke>0&&t.jsx("span",{className:"bim-rd-dot"}),ue]},ke))}),se&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":u("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":Y==="text",onClick:()=>k("text"),children:u("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":Y==="entries",onClick:()=>k("entries"),children:u("collated.viewEntries")})]})]}),Y==="text"&&t.jsx("article",{className:"bim-rd-prose",children:oe?t.jsx(Xo,{text:n,mode:p.readingMode,bookMarking:S,quoteStyle:p.quoteStyle,renderText:C,dropTitle:e.title}):t.jsx(cx,{sections:e.sections,onNavigate:l,inline:_,workLinks:p.workLinks})}),Y==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?t.jsx(ax,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[R.some(ue=>["书","诗","考证"].includes(Nt(ue.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:u("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:u("collated.rowHeadTitle")}),t.jsx("span",{children:u("collated.rowHeadWork")})]}),R.map((ue,ke)=>{const Ae=Nt(ue.type);return Ae==="书"||Ae==="诗"||Ae==="考证"?(de+=1,t.jsx(tx,{domId:`rd-e-${e.sections.indexOf(ue)}`,section:ue,onNavigate:p.workLinks?l:void 0,highlightQuery:w,no:de,showUnlinked:p.workLinks&&!!l},ke)):Ae==="类"?t.jsx(nx,{section:ue,highlightQuery:w},ke):t.jsx(rx,{section:ue,highlightQuery:w},ke)}),R.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:u("collated.noMatch")})]})})]})}function px(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=gn(),g=f.useRef(new Map),[m,u]=f.useState({}),[h,x]=f.useState({}),j=f.useCallback(($,y)=>{const k=y==null?void 0:y.title;k&&x(w=>w[$]===k?w:{...w,[$]:k})},[]);f.useEffect(()=>{s&&a&&(g.current.set(s,{juan:a,rawText:l}),j(s,a))},[s,a,l,j]),f.useEffect(()=>{g.current.clear(),u({}),x({})},[n]);const b=f.useCallback(($,y)=>{let k=0;if($.juan)for(const w of $.juan.sections)Qo(w,y,c,p)&&k++;return k===0&&$.rawText&&Xh($.rawText,y,p)&&(k=1),k},[c,p]);return f.useEffect(()=>{const $=d.trim();if(!$){u({});return}if(!i||o.length===0)return;let y=!1;const k={},w=[];for(const R of o){const z=g.current.get(R);z?k[R]=b(z,$):(k[R]="loading",w.push(R))}u(k);const v=8;let C=0;const S=async()=>{for(;C<w.length;){if(y)return;const R=C++,z=w[R];try{const N=await i(z),I=N.juan;if(g.current.set(z,N),j(z,I),y)return;u(B=>({...B,[z]:b(N,$)}))}catch{if(y)return;u(N=>({...N,[z]:0}))}}},_=Array.from({length:Math.min(v,w.length)},()=>S());return Promise.all(_),()=>{y=!0}},[d,n,i,o.join(","),b,p,j]),{matchStates:m,titles:h}}function ux({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=ae(),l=e.sections.map((g,m)=>({s:g,i:m,t:Nt(g.type)})).filter(g=>g.t==="书"||g.t==="诗");if(l.length===0)return null;const d=l.filter(g=>!!g.s.work_id).length,c=l.every(g=>g.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=g=>{const m=()=>{var u,h;return(h=(u=document.getElementById(`rd-e-${g}`))==null?void 0:u.scrollIntoView)==null?void 0:h.call(u,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(m,0):m()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:g,i:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:u=>{u.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${g.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:Qi(a(g.book_title||g.title),{t:s})})]})},m))})]})]})}const mx=`
|
|
1350
|
+
${n??""}`,[a,l]=f.useState({tag:"",images:null}),d=f.useRef(0);f.useEffect(()=>{const p=++d.current,g=u=>{p===d.current&&l({tag:s,images:u})};if(!e||!n){g(null);return}let m;try{m=e(n,i)}catch{g(null);return}if(!m||typeof m.then!="function"){g(m??null);return}m.then(u=>g(u??null),()=>g(null))},[e,n,i,s]);const c=a.tag===s;return{images:c?a.images:null,loading:!!e&&!!n&&!c}}function Fh(){let e=null;const n=new Set;return{get:()=>e,set:i=>{i!==e&&(e=i,n.forEach(o=>o()))},subscribe:i=>(n.add(i),()=>{n.delete(i)})}}function Hh(e){return f.useSyncExternalStore(e.subscribe,e.get,e.get)}function Ua({store:e,children:n}){const i=Hh(e);return f.createElement(f.Fragment,null,n(i))}function Dh(e){return typeof e!="string"?null:e==="published"?"source":Object.prototype.hasOwnProperty.call(Yu,e)?e:null}function Uh(e){if(e==="none")return{color:r("quality-none"),fontWeight:400};if(e==="placeholder")return{color:r("quality-placeholder"),fontWeight:400}}const Vh={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释",tally:"小计"},Sd="\0";function Gh(e,n,i){const[o,s=""]=e.split(Sd);return t.jsxs(t.Fragment,{children:[o,t.jsx(Tc,{text:n,convert:i}),s]})}function Rt(e){return typeof e!="string"?"":Vh[e]??e}const Yh=["〇","一","二","三","四","五","六","七","八","九"],Va=["","十","百","千"],Kh=["","萬","億"];function es(e){if(e===0)return"〇";if(e<0)return`負${es(-e)}`;const n=[];let i=e,o=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(qh(s,o>0)+Kh[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function qh(e,n){const i=[];let o=e;for(;o>0;)i.unshift(o%10),o=Math.floor(o/10);let s="";for(let a=0;a<i.length;a++){const l=i[a],d=i.length-1-a;l===0?s&&!s.endsWith("〇")&&(s+="〇"):l===1&&d===1&&a===0&&!n?s+=Va[d]:s+=Yh[l]+Va[d]}return s.replace(/〇$/,"")}let Jn=null,wi=null;const Bi=new Set;function Xh(){return Jn?Promise.resolve():wi||(wi=import("opencc-js/t2cn").then(e=>{const n=e.Converter({from:"t",to:"cn"});Jn=i=>n(Re.normalizeVariants(i)),Bi.forEach(i=>i())}).catch(()=>{Jn=e=>e,Bi.forEach(e=>e())}),wi)}const Zh=e=>e;function fn(){const[,e]=f.useState(0);return f.useEffect(()=>{if(Jn)return;const n=()=>e(i=>i+1);return Bi.add(n),Xh(),()=>{Bi.delete(n)}},[]),Jn??Zh}function zn(e,n){return n(e).toLowerCase()}const Jh=r("highlight-bg");function ai(e,n,i){if(!n)return e;const o=zn(n,i);if(!o)return e;const s=zn(e,i),a=Array.from(e),l=Array.from(s);if(l.length!==a.length)return e;const d=new Map;let c=0;l.forEach((x,j)=>{d.set(c,j),c+=x.length});const p=Array.from(o).length,g=[];let m=0,u=0,h=0;for(;m<a.length;){const x=s.indexOf(o,u),j=x===-1?void 0:d.get(x);if(x===-1){g.push(a.slice(m).join(""));break}if(j===void 0){u=x+1;continue}j>m&&g.push(a.slice(m,j).join("")),g.push(t.jsx("mark",{style:{background:Jh,padding:0,color:"inherit"},children:a.slice(j,j+p).join("")},h++)),m=j+p,u=x+o.length}return t.jsx(t.Fragment,{children:g})}function ts(e,n,i,o){if(!n)return!0;const s=zn(n,o);return(i?[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"&&zn(l,o).includes(s))}function Qh(e,n,i){return n?zn(e,i).includes(zn(n,i)):!0}const ns={类:r("section-lei"),书:r("section-shu"),序:r("section-xu"),结语:r("section-jieyu"),注释:r("section-zhushi")},ex={考证:r("section-kaozhen")};function is(e,n,i){return e.collated.sectionType[n]??i(n)}function _d(e){var o;const n=e.files.length,i=((o=e.children)==null?void 0:o.reduce((s,a)=>s+_d(a),0))||0;return n+i}function tx(e,n){const i=[],o=l=>{var d;i.push(...l.files),(d=l.children)==null||d.forEach(o)};if(o(e),i.length===0)return;const s=i.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 nx={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function rs({enabled:e,expanded:n,onClick:i,style:o,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...nx,...o},children:s}):t.jsx("span",{style:o,children:s})}function ix({type:e}){const{convert:n,messages:i}=ae(),o=Rt(e),s=ns[o]||r("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:is(i,o,n)})}function rx({section:e,onNavigate:n,highlightQuery:i="",no:o,showUnlinked:s=!1,domId:a}){const{t:l,convert:d}=ae(),c=gt(),p=fn(),g=k=>k?Nt(d(k),w=>i?ai(w,i,p):w,{t:l}):"",[m,u]=f.useState(!1),h=!!e.summary,x=!!e.comment,j=!!e.additional_comment,b=!!(e.content&&e.content.length>60),S=h||x||j||b;f.useEffect(()=>{i&&u(!0)},[i]);const y=!m&&b?id(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:a,style:{borderBottom:`1px solid ${r("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>S&&u(!m),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:S?"pointer":"default",userSelect:"none"},children:[o!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:r("label-fg")},children:o}),t.jsxs(rs,{enabled:S,expanded:m,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[S&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",g(e.book_title),"》"]}):g(e.title),e.n_juan!=null&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"6px"},children:l("collated.nJuan",{n:d(es(e.n_juan))})}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:r("desc-fg"),marginLeft:"8px"},children:g(e.author_info||e.author)})]}),!m&&y&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:r("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:g(y)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:g(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:r("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:c(e.work_id),onClick:k=>{k.metaKey||k.ctrlKey||(k.preventDefault(),k.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:r("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:r("label-fg"),flexShrink:0},children:l("collated.unlinked")})]}),m&&S&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${r("widget-border")}`,background:r("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:r("desc-fg"),marginBottom:"8px"},children:g(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${r("primary")}`,background:`color-mix(in srgb, ${r("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.summary")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:g(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.comment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:g(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${r("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:r("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l("collated.additionalComment")}),t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:g(e.additional_comment)})]}),b&&!h&&!x&&!j&&t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:g(e.content)})]})]})}function ox({section:e,highlightQuery:n=""}){const{t:i,convert:o}=ae(),s=fn(),a=p=>p?Nt(o(p),g=>n?ai(g,n,s):g,{t:i}):"",[l,d]=f.useState(!1),c=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(rs,{enabled:c,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:c?"pointer":"default",userSelect:"none"},children:[t.jsx(ix,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:r("fg")},children:a(e.title)}),c&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("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, ${ns[Rt(e.type)]||r("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:r("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})})]})}const sx=100;function os(e){return Rt(e.type)!=="page_header"?!1:(e.content||"").length>=sx}function ax({section:e,highlightQuery:n=""}){const{t:i,convert:o,messages:s}=ae(),a=fn();if(Rt(e.type)==="page_header"&&!os(e)||!e.content&&!e.title)return null;const l=o((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
1351
|
+
`)),d=Nt(l,m=>n?ai(m,n,a):m,{t:i}),c=Rt(e.type),p=ns[c]||r("desc-fg"),g=c==="序"||c==="结语"||c==="注释";return t.jsxs("div",{style:{padding:g?"10px 12px":"6px 0",margin:g?"8px 0":void 0,fontSize:"13px",color:r("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:g?`3px solid ${p}40`:void 0,background:g?r("bg"):void 0,borderRadius:g?"0 4px 4px 0":void 0,position:"relative"},children:[g&&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:is(s,c,o)}),d]})}function lx(e,n,i){const[o,s]=f.useState({});return f.useEffect(()=>{var p;if(!n||e.length===0)return;let a=!1;const l=e.filter(g=>{var m;return!((m=i==null?void 0:i.current)!=null&&m.has(g))}),d={};for(const g of e)(p=i==null?void 0:i.current)!=null&&p.has(g)&&(d[g]=i.current.get(g));if(Object.keys(d).length>0&&s(d),l.length===0)return;const c=async g=>{var m;try{if(n.getEntry){const b=await n.getEntry(g);if(b)return{title:b.title,author:b.author}}const u=await n.getItem(g);if(!u)return null;const h=u.title||g,x=u.authors,j=(m=x==null?void 0:x[0])==null?void 0:m.name;return{title:h,author:j}}catch{return null}};return Promise.all(l.map(async g=>{var u;const m=await c(g);return(u=i==null?void 0:i.current)==null||u.set(g,m),[g,m]})).then(g=>{a||s(m=>{const u={...m};for(const[h,x]of g)u[h]=x;return u})}),()=>{a=!0}},[e.join(","),n]),o}function cx({section:e,onNavigate:n,transport:i,workLabelCache:o,highlightQuery:s=""}){const{t:a,convert:l,messages:d}=ae(),c=gt(),p=fn(),g=w=>w?Nt(l(w),v=>s?ai(v,s,p):v,{t:a}):"",[m,u]=f.useState(!1);f.useEffect(()=>{s&&u(!0)},[s]);const h=Rt(e.type),x=ex[h]||r("desc-fg"),j=!!e.content,b=e.work_ids||[],S=b.length>1,y=lx(S?b:[],i,o),k=j&&!m&&e.content.length>80?id(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${r("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>j&&u(!m),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:j?"pointer":"default",userSelect:"none"},children:[t.jsxs(rs,{enabled:j,expanded:m,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[j&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:r("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:m?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:r("fg"),lineHeight:1.6},children:e.header_line?g(e.header_line):g(e.title)}),!m&&k&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:r("desc-fg"),lineHeight:1.7},children:g(k)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[b.length===1&&n&&t.jsx("a",{href:c(b[0]),onClick:w=>{w.metaKey||w.ctrlKey||(w.preventDefault(),w.stopPropagation(),n(b[0]))},style:{fontSize:"11px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:a("collated.viewWork"),children:a("collated.arrowWork")}),S&&t.jsx("span",{style:{fontSize:"11px",color:r("link-fg"),flexShrink:0},children:a("collated.nWorks",{n:b.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:is(d,h,l)})]})]}),S&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:b.map(w=>{const v=y[w],C=v?`${l(v.title)}${v.author?`(${l(v.author)})`:""}`:w.slice(0,8)+"…";return t.jsxs("a",{href:c(w),onClick:_=>{_.metaKey||_.ctrlKey||(_.preventDefault(),_.stopPropagation(),n(w))},style:{fontSize:"12px",color:r("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:w,children:["→",C]},w)})}),m&&j&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:r("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:r("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:g(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${r("widget-border")}`,fontSize:"12px",color:r("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:g(e.comment)})]})]})}function dx({juan:e,searchQuery:n,onNavigate:i,transport:o,workLabelCache:s}){const{t:a}=ae(),l=fn(),d=n.trim(),c=f.useMemo(()=>d?e.sections.filter(p=>ts(p,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:c.map((p,g)=>t.jsx(cx,{section:p,onNavigate:i,transport:o,workLabelCache:s,highlightQuery:d},g))}),c.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:a("collated.noMatch")})]})}function px(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function ux({sections:e,onNavigate:n,inline:i,workLinks:o=!0}){const s=gt(),{t:a,convert:l}=ae(),d=px();return t.jsx(t.Fragment,{children:e.map((c,p)=>{const g=Rt(c.type);if(g==="page_header"&&!os(c))return null;if(g==="类")return t.jsxs(f.Fragment,{children:[f.createElement(d("类"),null,i(l(c.title))),c.content&&t.jsx("p",{children:i(l(c.content))})]},p);if(g==="书"||g==="诗"||g==="考证"||g==="注释"){const m=c.book_title?`《${c.book_title}》${c.n_juan!=null?a("collated.nJuan",{n:es(c.n_juan)}):""}`:c.title,u=i(l(m));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${p}`,children:[f.createElement(d("条目"),{className:"bim-rd-entry-h"},c.work_id&&n&&o?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},title:a("collated.viewWork"),children:u}),t.jsx("a",{className:"bim-rd-wl",href:s(c.work_id),onClick:h=>{h.metaKey||h.ctrlKey||(h.preventDefault(),n(c.work_id))},"aria-label":a("collated.viewWorkOf",{title:l(m)}),children:a("collated.workArrow")})]}):u),c.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(l(c.author_info))}),c.content&&c.content.split(/\n+/).map((h,x)=>t.jsx("p",{children:i(l(h))},x)),c.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.summary")}),i(l(c.summary))]}),c.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.comment")}),i(l(c.comment))]}),c.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:a("collated.additionalComment")}),i(l(c.additional_comment))]})]},p)}return g==="小计"&&c.title?t.jsx("p",{children:i(l(c.title))},p):c.content?t.jsx("p",{children:i(l(c.content))},p):null})})}function $d(e){return e.some(n=>{const i=Rt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&os(n)})}function mx({juan:e,rawText:n,positionLabel:i,groupLabel:o,index:s,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c,prefs:p,view:g,onViewChange:m}){var Z;const{t:u,convert:h,messages:x}=ae(),j=fn(),[b,S]=f.useState("text"),y=g??b,k=oe=>{S(oe),m==null||m(oe)},w=a.trim(),v=(s==null?void 0:s.type)==="kaozhen",C=f.useCallback(oe=>w?ai(oe,w,j):oe,[w,j]),_=Zo(p),$=oe=>tr(oe,{renderText:C,bookMarking:_,quoteStyle:p.quoteStyle,t:u}),A=f.useMemo(()=>w?e.sections.filter(oe=>ts(oe,w,v,j)):e.sections,[e.sections,w,v,j]),R=(oe,ye)=>ye.filter(Le=>Rt(Le.type)===oe).length,z=R("书",e.sections),N=R("诗",e.sections),M=R("考证",e.sections);let O="";v?O=w?u("collated.countTiaoOf",{m:R("考证",A),n:M}):u("collated.countTiao",{n:M}):N>0?O=w?u("collated.countPoemsOf",{m:R("诗",A),n:N}):u("collated.countPoems",{n:N}):z>0&&(O=w?u("collated.countBooksOf",{m:R("书",A),n:z}):u("collated.countBooks",{n:z}));const L=s!=null&&s.text_quality?Dh(s.text_quality.grade):null,D=[];if(O&&D.push(O),v&&(s!=null&&s.target_source)&&D.push(t.jsx(t.Fragment,{children:u("collated.kaozhenTarget",{target:h(s.target_source)})})),L){const oe=t.jsx("span",{className:"bim-rd-grade",style:Uh(L),children:x.collated.qualityLabel[L]});D.push(t.jsx("span",{title:x.collated.qualityCriteria[L],children:(Z=s==null?void 0:s.text_quality)!=null&&Z.source_note?t.jsxs(t.Fragment,{children:[Gh(u("collated.baseText",{note:Sd}),s.text_quality.source_note,h),oe]}):t.jsxs(t.Fragment,{children:[u("collated.textQuality"),oe]})}))}e.source_url&&D.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:u("collated.originalSource")}));const q=!v&&$d(e.sections),J=!!n&&(!q||p.readingMode==="paragraph"&&Pi(n)),se=!v&&(q||!!n),U=v||!se?"entries":y;let K=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[(i||o)&&t.jsxs("p",{className:"bim-rd-kicker",children:[i,i&&o&&t.jsx("span",{className:"bim-rd-dot"}),o&&h(o)]}),t.jsx("h1",{className:"bim-rd-h1",children:h(e.title)}),D.length>0&&t.jsx("p",{className:"bim-rd-meta",children:D.map((oe,ye)=>t.jsxs(f.Fragment,{children:[ye>0&&t.jsx("span",{className:"bim-rd-dot"}),oe]},ye))}),se&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":u("collated.viewsGroup"),children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":U==="text",onClick:()=>k("text"),children:u("collated.viewText")}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":U==="entries",onClick:()=>k("entries"),children:u("collated.viewEntries")})]})]}),U==="text"&&t.jsx("article",{className:"bim-rd-prose",children:J?t.jsx(Jo,{text:n,mode:p.readingMode,bookMarking:_,quoteStyle:p.quoteStyle,renderText:C,dropTitle:e.title}):t.jsx(ux,{sections:e.sections,onNavigate:l,inline:$,workLinks:p.workLinks})}),U==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:v?t.jsx(dx,{juan:e,searchQuery:a,onNavigate:l,transport:d,workLabelCache:c}):t.jsxs(t.Fragment,{children:[A.some(oe=>["书","诗","考证"].includes(Rt(oe.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:u("collated.rowHeadNo")}),t.jsx("span",{style:{flex:1},children:u("collated.rowHeadTitle")}),t.jsx("span",{children:u("collated.rowHeadWork")})]}),A.map((oe,ye)=>{const Le=Rt(oe.type);return Le==="书"||Le==="诗"||Le==="考证"?(K+=1,t.jsx(rx,{domId:`rd-e-${e.sections.indexOf(oe)}`,section:oe,onNavigate:p.workLinks?l:void 0,highlightQuery:w,no:K,showUnlinked:p.workLinks&&!!l},ye)):Le==="类"?t.jsx(ox,{section:oe,highlightQuery:w},ye):t.jsx(ax,{section:oe,highlightQuery:w},ye)}),A.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:u("collated.noMatch")})]})})]})}function gx(e){const{resetKey:n,load:i,files:o,activeFile:s,activeJuan:a,activeRawText:l,query:d,isKaozhen:c}=e,p=fn(),g=f.useRef(new Map),[m,u]=f.useState({}),[h,x]=f.useState({}),j=f.useCallback((S,y)=>{const k=y==null?void 0:y.title;k&&x(w=>w[S]===k?w:{...w,[S]:k})},[]);f.useEffect(()=>{s&&a&&(g.current.set(s,{juan:a,rawText:l}),j(s,a))},[s,a,l,j]),f.useEffect(()=>{g.current.clear(),u({}),x({})},[n]);const b=f.useCallback((S,y)=>{let k=0;if(S.juan)for(const w of S.juan.sections)ts(w,y,c,p)&&k++;return k===0&&S.rawText&&Qh(S.rawText,y,p)&&(k=1),k},[c,p]);return f.useEffect(()=>{const S=d.trim();if(!S){u({});return}if(!i||o.length===0)return;let y=!1;const k={},w=[];for(const A of o){const R=g.current.get(A);R?k[A]=b(R,S):(k[A]="loading",w.push(A))}u(k);const v=8;let C=0;const _=async()=>{for(;C<w.length;){if(y)return;const A=C++,R=w[A];try{const z=await i(R),N=z.juan;if(g.current.set(R,z),j(R,N),y)return;u(M=>({...M,[R]:b(z,S)}))}catch{if(y)return;u(z=>({...z,[R]:0}))}}},$=Array.from({length:Math.min(v,w.length)},()=>_());return Promise.all($),()=>{y=!0}},[d,n,i,o.join(","),b,p,j]),{matchStates:m,titles:h}}function fx({juan:e,view:n,onView:i,textHasEntries:o}){const{t:s,convert:a}=ae(),l=e.sections.map((g,m)=>({s:g,i:m,t:Rt(g.type)})).filter(g=>g.t==="书"||g.t==="诗");if(l.length===0)return null;const d=l.filter(g=>!!g.s.work_id).length,c=l.every(g=>g.t==="诗")?s("collated.railUnitPoems"):s("collated.railUnitBooks"),p=g=>{const m=()=>{var u,h;return(h=(u=document.getElementById(`rd-e-${g}`))==null?void 0:u.scrollIntoView)==null?void 0:h.call(u,{block:"start",behavior:"smooth"})};n==="text"&&!o&&i("entries"),n==="text"&&!o?setTimeout(m,0):m()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:s("collated.railCap")}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:c}),t.jsx("span",{className:"bim-rd-rail-linked",children:s("collated.linkedN",{n:d})})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":s("collated.linkedOf",{n:d,total:l.length}),children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":s("collated.railEntriesNav"),children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("collated.viewEntries")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:g,i:m})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${m}`,onClick:u=>{u.preventDefault(),p(m)},children:[t.jsx("span",{className:`bim-rd-rail-dot${g.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:tr(a(g.book_title||g.title),{t:s})})]})},m))})]})]})}const hx=`
|
|
1352
1352
|
attribute vec2 a_position; // 目标画布像素坐标 [0, canvasWidth] x [0, canvasHeight]
|
|
1353
1353
|
attribute vec2 a_texCoord; // 原图像素坐标 [0, imgWidth] x [0, imgHeight]
|
|
1354
1354
|
|
|
@@ -1366,7 +1366,7 @@ ${n??""}`,[a,l]=f.useState({tag:"",images:null}),d=f.useRef(0);f.useEffect(()=>{
|
|
|
1366
1366
|
// 纹理坐标归一化 [0, 1]
|
|
1367
1367
|
v_texCoord = a_texCoord / u_imgResolution;
|
|
1368
1368
|
}
|
|
1369
|
-
`,
|
|
1369
|
+
`,xx=`
|
|
1370
1370
|
precision mediump float;
|
|
1371
1371
|
uniform sampler2D u_image;
|
|
1372
1372
|
uniform float u_alpha;
|
|
@@ -1376,7 +1376,7 @@ ${n??""}`,[a,l]=f.useState({tag:"",images:null}),d=f.useRef(0);f.useEffect(()=>{
|
|
|
1376
1376
|
vec4 tex = texture2D(u_image, v_texCoord);
|
|
1377
1377
|
gl_FragColor = vec4(tex.rgb, tex.a * u_alpha);
|
|
1378
1378
|
}
|
|
1379
|
-
`;function Da(e,n,i){const o=e.createShader(n);return o?(e.shaderSource(o,i),e.compileShader(o),e.getShaderParameter(o,e.COMPILE_STATUS)?o:(console.error("Shader compile error:",e.getShaderInfoLog(o)),e.deleteShader(o),null)):null}class io{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=Da(i,i.VERTEX_SHADER,mx),s=Da(i,i.FRAGMENT_SHADER,gx);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,o.drawingBufferWidth,o.drawingBufferHeight),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,c.drawingBufferWidth,c.drawingBufferHeight),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],g=[],m=8;for(const u of l){const h=u.colOffsetX||0,x=u.colOffsetY||0,{srcQuad:j,dstRect:b}=u.strip,[$,y,k,w]=b,v=h+$,C=x+y,[S,_,R,z]=j;for(let N=0;N<m;N++){const I=N/m,B=(N+1)/m,O=C+w*I,A=C+w*B,W=[S[0]+(z[0]-S[0])*I,S[1]+(z[1]-S[1])*I],G=[S[0]+(z[0]-S[0])*B,S[1]+(z[1]-S[1])*B],oe=[_[0]+(R[0]-_[0])*I,_[1]+(R[1]-_[1])*I],se=[_[0]+(R[0]-_[0])*B,_[1]+(R[1]-_[1])*B],Y=[v,O],de=[v+k,O],ne=[v,A],ue=[v+k,A];p.push(Y[0],Y[1],de[0],de[1],ne[0],ne[1]),g.push(W[0],W[1],oe[0],oe[1],G[0],G[1]),p.push(de[0],de[1],ue[0],ue[1],ne[0],ne[1]),g.push(oe[0],oe[1],se[0],se[1],G[0],G[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(g),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)}}function fx(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(u=>{var h;return(((h=u.strips)==null?void 0:h.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const u of e.columns)for(const h of u.chars){const[x,j,b,$]=h.bbox_col;![x,j,b,$].every(Number.isFinite)||!(b>x)||!($>j)||(o=Math.min(o,u.offset_x+x),s=Math.min(s,j),a=Math.max(a,u.offset_x+b),l=Math.max(l,$))}for(const u of e.figBlocks??[]){const[h,x,j,b]=u.box;![h,x,j,b].every(Number.isFinite)||!(j>h)||!(b>x)||(o=Math.min(o,h),s=Math.min(s,x),a=Math.max(a,j),l=Math.max(l,b))}if(!(a>o)||!(l>s))return null;const d=Math.min(n,i)*.03,c=Math.min(n,Math.max(0,o-d)),p=Math.min(i,Math.max(0,s-d)),g=Math.min(n,Math.max(0,a+d))-c,m=Math.min(i,Math.max(0,l+d))-p;return!(g>0)||!(m>0)||g>=n*.98&&m>=i*.98?null:{x:c,y:p,w:g,h:m}}const Ua=typeof window>"u"?f.useEffect:f.useLayoutEffect;function hx(e,n){const i=Math.max(1,Math.round(e)),o=Math.max(1,Math.round(n));return`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${o}"/>`)}`}const Ir=[1,1.5,2,3,4,6];function xx(e){for(const n of Ir)if(e<=n)return n;return Ir[Ir.length-1]}function bx(e,n,i,o,s=1){if(!(e>0)||!(n>0))return[1,1];if(i===null||!(i>0))return[1,1];const a=Math.ceil(i*Math.min(Math.max(o,1),2)*xx(s)/64)*64,l=Math.max(1,Math.min(Math.round(e),a)),d=Math.max(1,Math.round(l*n/e));return[l,d]}const Zt=new Map,yx=8;function ro(e){let n=Zt.get(e);if(n)return Zt.delete(e),Zt.set(e,n),n;for(n=new Promise(i=>{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{(o.decode?o.decode().catch(()=>{}):Promise.resolve()).then(()=>i(o))},o.onerror=()=>{Zt.delete(e),i(null)},o.src=e}),Zt.set(e,n);Zt.size>yx;)Zt.delete(Zt.keys().next().value);return n}function jx(e,n){if(!n||!(n.w>0)||!(n.h>0))return e;const[i,o]=e.image_size||[0,0];if(!(i>0)||!(o>0)||e.columns.some(l=>{var d;return(((d=l.strips)==null?void 0:d.length)??0)>0}))return e;const s=i*n.h/n.w;if(Math.abs(s/o-1)<=.01)return e;const a=s/o;return{...e,image_size:[i,s],columns:e.columns.map(l=>({...l,warped_h:l.warped_h*a,chars:l.chars.map(d=>({...d,bbox_col:[d.bbox_col[0],d.bbox_col[1]*a,d.bbox_col[2],d.bbox_col[3]*a]}))})),...e.figBlocks?{figBlocks:e.figBlocks.map(l=>({...l,box:[l.box[0],l.box[1]*a,l.box[2],l.box[3]*a]}))}:{}}}const rs=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l,selectedFigBlock:d,onFigBlockClick:c,renderScale:p=1})=>{const[g,m]=f.useState(null),u=f.useMemo(()=>jx(n,g&&g.url===e?g:null),[n,g,e]),h=f.useRef(null),x=f.useRef(null),j=typeof ResizeObserver<"u",[b,$]=f.useState(null);Ua(()=>{const q=x.current;if(!q||typeof ResizeObserver>"u")return;const le=new ResizeObserver(ge=>{var Z;const H=((Z=ge[ge.length-1])==null?void 0:Z.contentRect.width)??0;$(Ne=>Ne===H?Ne:H)});return le.observe(q),()=>le.disconnect()},[]);const y=!j||b!==null&&b>0,k=f.useRef(null),w=f.useRef(null),v=f.useRef(null),C=f.useRef(null),S=f.useRef(null),[_,R]=f.useState(0),[z,N]=f.useState(0),I=f.useRef(""),B=f.useMemo(()=>Math.max(...u.columns.map(q=>q.warped_h),2440),[u]),O=u.total_warped_w,A=u.banxin,W=f.useMemo(()=>!u.columns.some(q=>{var le;return(((le=q.strips)==null?void 0:le.length)??0)>0}),[u]),G=f.useMemo(()=>{var ze;if(!s||W)return{top:0,bottom:0,left:0,right:0};const[q,le]=u.image_size||[2386,3082];let ge=1/0,H=-1/0,Z=1/0,Ne=-1/0;for(const Fe of u.columns)for(const P of Fe.strips||[])for(const ie of P.srcQuad)ie[0]<ge&&(ge=ie[0]),ie[0]>H&&(H=ie[0]),ie[1]<Z&&(Z=ie[1]),ie[1]>Ne&&(Ne=ie[1]);if((ze=u.banxin)!=null&&ze.current_page_strips)for(const Fe of u.banxin.current_page_strips)for(const P of Fe.srcQuad)P[0]<ge&&(ge=P[0]),P[0]>H&&(H=P[0]),P[1]<Z&&(Z=P[1]),P[1]>Ne&&(Ne=P[1]);return isFinite(ge)||(ge=0),isFinite(H)||(H=q),isFinite(Z)||(Z=0),isFinite(Ne)||(Ne=le),{top:Math.max(0,Math.round(Z)),bottom:Math.max(0,Math.round(le-Ne)),left:Math.max(0,Math.round(ge)),right:Math.max(0,Math.round(q-H)),rawMinX:ge,rawMaxX:H,rawMinY:Z,rawMaxY:Ne,imgW:q,imgH:le}},[u,s,W]),oe=f.useMemo(()=>{if(!W)return null;const[q,le]=u.image_size||[0,0];return!(q>0)||!(le>0)?null:!s&&fx(u)||{x:0,y:0,w:q,h:le}},[u,s,W]),se=O+(A?A.total_w:0),Y=oe?oe.w:se+G.left+G.right,de=oe?oe.h:B+G.top+G.bottom,ne=typeof window<"u"&&window.devicePixelRatio||1,[ue,ke]=j?bx(Y,de,b,ne,p):[Math.round(Y),Math.round(de)],Ae=f.useCallback(()=>{const q=k.current;if(!(!q||!h.current)&&!(e&&I.current!==e)){if(q.clear(Y,de),s&&G.rawMinX!==void 0&&C.current&&w.current){const{rawMinX:le,rawMaxX:ge,rawMinY:H,rawMaxY:Z,imgW:Ne,imgH:ze,top:Fe,bottom:P,left:ie,right:Q}=G,X=[];ie>0&&X.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[le,0],[le,ze],[0,ze]],dstRect:[0,0,ie,de]}}),Fe>0&&X.push({colOffsetX:ie,colOffsetY:0,strip:{srcQuad:[[le,0],[ge,0],[ge,H],[le,H]],dstRect:[0,0,se,Fe]}}),P>0&&X.push({colOffsetX:ie,colOffsetY:Fe+B,strip:{srcQuad:[[le,Z],[ge,Z],[ge,ze],[le,ze]],dstRect:[0,0,se,P]}}),Q>0&&X.push({colOffsetX:ie+se,colOffsetY:0,strip:{srcQuad:[[ge,0],[Ne,0],[Ne,ze],[ge,ze]],dstRect:[0,0,Q,de]}}),q.renderStripsWithTexture(C.current,Y,de,u.image_size[0],u.image_size[1],X,1)}if(C.current&&w.current){const le=u.columns.flatMap(ge=>(ge.strips||[]).map(H=>({colOffsetX:G.left+ge.offset_x,colOffsetY:G.top,strip:H})));if(le.length>0?q.renderStripsWithTexture(C.current,Y,de,u.image_size[0],u.image_size[1],le,1):q.renderStripsWithTexture(C.current,Y,de,u.image_size[0],u.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:oe?[[oe.x,oe.y],[oe.x+oe.w,oe.y],[oe.x+oe.w,oe.y+oe.h],[oe.x,oe.y+oe.h]]:[[0,0],[u.image_size[0],0],[u.image_size[0],u.image_size[1]],[0,u.image_size[1]]],dstRect:[0,0,Y,de]}}],1),A&&A.current_page_strips.length>0){const ge=A.current_page_strips.map(H=>({colOffsetX:G.left+O,colOffsetY:G.top,strip:H}));q.renderStripsWithTexture(C.current,Y,de,u.image_size[0],u.image_size[1],ge,1)}}if(A&&S.current&&v.current&&A.mate_page_strips.length>0){const le=A.mate_page_strips.map(ge=>({colOffsetX:G.left+O+A.half_w,colOffsetY:G.top,strip:ge}));q.renderStripsWithTexture(S.current,Y,de,A.mate_img_size[0],A.mate_img_size[1],le,.65)}}},[e,u,A,Y,de,O,B,se,G,s,oe]),he=f.useRef(Ae);he.current=Ae,f.useEffect(()=>{const q=h.current;if(!q)return;const le=Z=>{C.current=w.current?Z.createTexture(w.current):null,S.current=v.current?Z.createTexture(v.current):null,he.current()};try{const Z=new io(q);k.current=Z,le(Z)}catch(Z){console.error("Failed to init WebGL renderer:",Z)}const ge=Z=>{Z.preventDefault(),console.warn("WebGL context lost")},H=()=>{console.info("WebGL context restored, re-initializing..."),h.current&&(k.current=new io(h.current),le(k.current))};return q.addEventListener("webglcontextlost",ge,!1),q.addEventListener("webglcontextrestored",H,!1),()=>{q.removeEventListener("webglcontextlost",ge),q.removeEventListener("webglcontextrestored",H),k.current&&(k.current.deleteTexture(C.current),k.current.deleteTexture(S.current),k.current.destroy(),k.current=null)}},[]),f.useEffect(()=>{if(!e||!y)return;let q=!0;return ro(e).then(le=>{if(!q||!le)return;w.current=le,I.current=e,m(H=>H&&H.url===e&&H.w===le.naturalWidth&&H.h===le.naturalHeight?H:{url:e,w:le.naturalWidth,h:le.naturalHeight});const ge=k.current;ge&&(ge.deleteTexture(C.current),C.current=ge.createTexture(le)),R(H=>H+1)}),()=>{q=!1}},[e,y]);const $e=A==null?void 0:A.mate_image_url;f.useEffect(()=>{if(!$e||!y)return;let q=!0;return ro($e).then(le=>{if(!q||!le)return;v.current=le;const ge=k.current;ge&&(ge.deleteTexture(S.current),S.current=ge.createTexture(le)),N(H=>H+1)}),()=>{q=!1}},[$e,y]),Ua(()=>{y&&Ae()},[Ae,_,z,ue,ke,y]);const L=f.useMemo(()=>(u.figBlocks??[]).map(q=>{const[le,ge,H,Z]=q.box;return{id:q.id,x:G.left+le-((oe==null?void 0:oe.x)??0),y:G.top+ge-((oe==null?void 0:oe.y)??0),w:Math.max(H-le,1),h:Math.max(Z-ge,1)}}),[u,G,oe]),Me=f.useMemo(()=>{const q=[];for(const le of u.columns)for(const ge of le.chars){const[H,Z,Ne,ze]=ge.bbox_col;q.push({id:ge.id,char:ge.char,x:G.left+le.offset_x+H-((oe==null?void 0:oe.x)??0),y:G.top+Z-((oe==null?void 0:oe.y)??0),w:Math.max(Ne-H,1),h:Math.max(ze-Z,1)})}return q},[u,G,oe]);return t.jsxs("div",{ref:x,className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${Y} / ${de}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("img",{alt:"","aria-hidden":"true","data-warp-sizer":"",src:hx(Y,de),style:{display:"block",width:"100%",height:"100%",visibility:"hidden"}}),t.jsx("canvas",{ref:h,width:ue,height:ke,"data-logical-size":`${Math.floor(Y)}x${Math.floor(de)}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${Y} ${de}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[Me.map(q=>{const le=i.has(q.id),ge=o===q.id;return t.jsx("rect",{"data-selected":le?"true":void 0,x:q.x,y:q.y,width:q.w,height:q.h,fill:le?r("warp-sel-bg"):ge?r("warp-hover-bg"):"transparent",stroke:le?r("warp-sel-stroke"):ge?r("warp-hover-stroke"):"transparent",strokeWidth:le?3.5:ge?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(q.id),onMouseEnter:()=>l==null?void 0:l(q.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:q.char})},q.id)}),L.map(q=>{const le=d===q.id;return t.jsx("rect",{"data-fig-block":q.id,"data-selected":le?"true":void 0,x:q.x,y:q.y,width:q.w,height:q.h,fill:le?r("warp-sel-bg"):"transparent",stroke:r(le?"warp-sel-stroke":"warp-hover-stroke"),strokeWidth:le?3.5:2,strokeDasharray:le?void 0:"10 8",style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>c==null?void 0:c(q.id),children:t.jsx("title",{children:q.id})},`fig-${q.id}`)}),A&&t.jsxs("g",{children:[t.jsx("line",{x1:G.left+O,y1:G.top,x2:G.left+O,y2:G.top+B,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:G.left+O+A.half_w,y1:G.top,x2:G.left+O+A.half_w,y2:G.top+B,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:G.left+se,y1:G.top,x2:G.left+se,y2:G.top+B,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},os=`
|
|
1379
|
+
`;function Ga(e,n,i){const o=e.createShader(n);return o?(e.shaderSource(o,i),e.compileShader(o),e.getShaderParameter(o,e.COMPILE_STATUS)?o:(console.error("Shader compile error:",e.getShaderInfoLog(o)),e.deleteShader(o),null)):null}class oo{constructor(n){const i=n.getContext("webgl",{alpha:!0,antialias:!1,preserveDrawingBuffer:!1,premultipliedAlpha:!1});if(!i)throw new Error("WebGL not supported");this.gl=i;const o=Ga(i,i.VERTEX_SHADER,hx),s=Ga(i,i.FRAGMENT_SHADER,xx);if(!o||!s)throw new Error("Failed to create shaders");const a=i.createProgram();if(!a)throw new Error("Failed to create program");if(i.attachShader(a,o),i.attachShader(a,s),i.linkProgram(a),!i.getProgramParameter(a,i.LINK_STATUS))throw new Error("Program link error: "+i.getProgramInfoLog(a));this.program=a,this.positionBuffer=i.createBuffer(),this.texCoordBuffer=i.createBuffer(),this.uResolutionLoc=i.getUniformLocation(a,"u_resolution"),this.uImgResolutionLoc=i.getUniformLocation(a,"u_imgResolution"),this.uAlphaLoc=i.getUniformLocation(a,"u_alpha"),this.aPositionLoc=i.getAttribLocation(a,"a_position"),this.aTexCoordLoc=i.getAttribLocation(a,"a_texCoord"),i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.clear(n.width,n.height)}clear(n,i){const o=this.gl;o.viewport(0,0,o.drawingBufferWidth,o.drawingBufferHeight),o.clearColor(.98,.97,.95,1),o.clear(o.COLOR_BUFFER_BIT)}createTexture(n){const i=this.gl,o=i.createTexture();return i.bindTexture(i.TEXTURE_2D,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,n),o}renderStripsWithTexture(n,i,o,s,a,l,d=1){if(l.length===0)return;const c=this.gl;c.viewport(0,0,c.drawingBufferWidth,c.drawingBufferHeight),c.useProgram(this.program),c.uniform2f(this.uResolutionLoc,i,o),c.uniform2f(this.uImgResolutionLoc,s,a),c.uniform1f(this.uAlphaLoc,d);const p=[],g=[],m=8;for(const u of l){const h=u.colOffsetX||0,x=u.colOffsetY||0,{srcQuad:j,dstRect:b}=u.strip,[S,y,k,w]=b,v=h+S,C=x+y,[_,$,A,R]=j;for(let z=0;z<m;z++){const N=z/m,M=(z+1)/m,O=C+w*N,L=C+w*M,D=[_[0]+(R[0]-_[0])*N,_[1]+(R[1]-_[1])*N],q=[_[0]+(R[0]-_[0])*M,_[1]+(R[1]-_[1])*M],J=[$[0]+(A[0]-$[0])*N,$[1]+(A[1]-$[1])*N],se=[$[0]+(A[0]-$[0])*M,$[1]+(A[1]-$[1])*M],U=[v,O],K=[v+k,O],Z=[v,L],oe=[v+k,L];p.push(U[0],U[1],K[0],K[1],Z[0],Z[1]),g.push(D[0],D[1],J[0],J[1],q[0],q[1]),p.push(K[0],K[1],oe[0],oe[1],Z[0],Z[1]),g.push(J[0],J[1],se[0],se[1],q[0],q[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(g),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)}}function bx(e){const[n,i]=e.image_size||[0,0];if(!(n>0)||!(i>0)||e.columns.some(u=>{var h;return(((h=u.strips)==null?void 0:h.length)??0)>0}))return null;let o=1/0,s=1/0,a=-1/0,l=-1/0;for(const u of e.columns)for(const h of u.chars){const[x,j,b,S]=h.bbox_col;![x,j,b,S].every(Number.isFinite)||!(b>x)||!(S>j)||(o=Math.min(o,u.offset_x+x),s=Math.min(s,j),a=Math.max(a,u.offset_x+b),l=Math.max(l,S))}for(const u of e.figBlocks??[]){const[h,x,j,b]=u.box;![h,x,j,b].every(Number.isFinite)||!(j>h)||!(b>x)||(o=Math.min(o,h),s=Math.min(s,x),a=Math.max(a,j),l=Math.max(l,b))}if(!(a>o)||!(l>s))return null;const d=Math.min(n,i)*.03,c=Math.min(n,Math.max(0,o-d)),p=Math.min(i,Math.max(0,s-d)),g=Math.min(n,Math.max(0,a+d))-c,m=Math.min(i,Math.max(0,l+d))-p;return!(g>0)||!(m>0)||g>=n*.98&&m>=i*.98?null:{x:c,y:p,w:g,h:m}}const Ya=typeof window>"u"?f.useEffect:f.useLayoutEffect;function yx(e,n){const i=Math.max(1,Math.round(e)),o=Math.max(1,Math.round(n));return`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${i}" height="${o}"/>`)}`}const Lr=[1,1.5,2,3,4,6];function jx(e){for(const n of Lr)if(e<=n)return n;return Lr[Lr.length-1]}function vx(e,n,i,o,s=1){if(!(e>0)||!(n>0))return[1,1];if(i===null||!(i>0))return[1,1];const a=Math.ceil(i*Math.min(Math.max(o,1),2)*jx(s)/64)*64,l=Math.max(1,Math.min(Math.round(e),a)),d=Math.max(1,Math.round(l*n/e));return[l,d]}const Jt=new Map,kx=8;function so(e){let n=Jt.get(e);if(n)return Jt.delete(e),Jt.set(e,n),n;for(n=new Promise(i=>{const o=new Image;o.crossOrigin="anonymous",o.onload=()=>{(o.decode?o.decode().catch(()=>{}):Promise.resolve()).then(()=>i(o))},o.onerror=()=>{Jt.delete(e),i(null)},o.src=e}),Jt.set(e,n);Jt.size>kx;)Jt.delete(Jt.keys().next().value);return n}function wx(e,n){if(!n||!(n.w>0)||!(n.h>0))return e;const[i,o]=e.image_size||[0,0];if(!(i>0)||!(o>0)||e.columns.some(l=>{var d;return(((d=l.strips)==null?void 0:d.length)??0)>0}))return e;const s=i*n.h/n.w;if(Math.abs(s/o-1)<=.01)return e;const a=s/o;return{...e,image_size:[i,s],columns:e.columns.map(l=>({...l,warped_h:l.warped_h*a,chars:l.chars.map(d=>({...d,bbox_col:[d.bbox_col[0],d.bbox_col[1]*a,d.bbox_col[2],d.bbox_col[3]*a]}))})),...e.figBlocks?{figBlocks:e.figBlocks.map(l=>({...l,box:[l.box[0],l.box[1]*a,l.box[2],l.box[3]*a]}))}:{}}}const ss=({imageUrl:e,pageData:n,selectedCharIds:i,hoveredCharId:o,preserveMargins:s=!1,onCharClick:a,onCharHover:l,selectedFigBlock:d,onFigBlockClick:c,renderScale:p=1})=>{const[g,m]=f.useState(null),u=f.useMemo(()=>wx(n,g&&g.url===e?g:null),[n,g,e]),h=f.useRef(null),x=f.useRef(null),j=typeof ResizeObserver<"u",[b,S]=f.useState(null);Ya(()=>{const T=x.current;if(!T||typeof ResizeObserver>"u")return;const de=new ResizeObserver(pe=>{var ee;const B=((ee=pe[pe.length-1])==null?void 0:ee.contentRect.width)??0;S(Ce=>Ce===B?Ce:B)});return de.observe(T),()=>de.disconnect()},[]);const y=!j||b!==null&&b>0,k=f.useRef(null),w=f.useRef(null),v=f.useRef(null),C=f.useRef(null),_=f.useRef(null),[$,A]=f.useState(0),[R,z]=f.useState(0),N=f.useRef(""),M=f.useMemo(()=>Math.max(...u.columns.map(T=>T.warped_h),2440),[u]),O=u.total_warped_w,L=u.banxin,D=f.useMemo(()=>!u.columns.some(T=>{var de;return(((de=T.strips)==null?void 0:de.length)??0)>0}),[u]),q=f.useMemo(()=>{var Ie;if(!s||D)return{top:0,bottom:0,left:0,right:0};const[T,de]=u.image_size||[2386,3082];let pe=1/0,B=-1/0,ee=1/0,Ce=-1/0;for(const We of u.columns)for(const G of We.strips||[])for(const he of G.srcQuad)he[0]<pe&&(pe=he[0]),he[0]>B&&(B=he[0]),he[1]<ee&&(ee=he[1]),he[1]>Ce&&(Ce=he[1]);if((Ie=u.banxin)!=null&&Ie.current_page_strips)for(const We of u.banxin.current_page_strips)for(const G of We.srcQuad)G[0]<pe&&(pe=G[0]),G[0]>B&&(B=G[0]),G[1]<ee&&(ee=G[1]),G[1]>Ce&&(Ce=G[1]);return isFinite(pe)||(pe=0),isFinite(B)||(B=T),isFinite(ee)||(ee=0),isFinite(Ce)||(Ce=de),{top:Math.max(0,Math.round(ee)),bottom:Math.max(0,Math.round(de-Ce)),left:Math.max(0,Math.round(pe)),right:Math.max(0,Math.round(T-B)),rawMinX:pe,rawMaxX:B,rawMinY:ee,rawMaxY:Ce,imgW:T,imgH:de}},[u,s,D]),J=f.useMemo(()=>{if(!D)return null;const[T,de]=u.image_size||[0,0];return!(T>0)||!(de>0)?null:!s&&bx(u)||{x:0,y:0,w:T,h:de}},[u,s,D]),se=O+(L?L.total_w:0),U=J?J.w:se+q.left+q.right,K=J?J.h:M+q.top+q.bottom,Z=typeof window<"u"&&window.devicePixelRatio||1,[oe,ye]=j?vx(U,K,b,Z,p):[Math.round(U),Math.round(K)],Le=f.useCallback(()=>{const T=k.current;if(!(!T||!h.current)&&!(e&&N.current!==e)){if(T.clear(U,K),s&&q.rawMinX!==void 0&&C.current&&w.current){const{rawMinX:de,rawMaxX:pe,rawMinY:B,rawMaxY:ee,imgW:Ce,imgH:Ie,top:We,bottom:G,left:he,right:te}=q,H=[];he>0&&H.push({colOffsetX:0,colOffsetY:0,strip:{srcQuad:[[0,0],[de,0],[de,Ie],[0,Ie]],dstRect:[0,0,he,K]}}),We>0&&H.push({colOffsetX:he,colOffsetY:0,strip:{srcQuad:[[de,0],[pe,0],[pe,B],[de,B]],dstRect:[0,0,se,We]}}),G>0&&H.push({colOffsetX:he,colOffsetY:We+M,strip:{srcQuad:[[de,ee],[pe,ee],[pe,Ie],[de,Ie]],dstRect:[0,0,se,G]}}),te>0&&H.push({colOffsetX:he+se,colOffsetY:0,strip:{srcQuad:[[pe,0],[Ce,0],[Ce,Ie],[pe,Ie]],dstRect:[0,0,te,K]}}),T.renderStripsWithTexture(C.current,U,K,u.image_size[0],u.image_size[1],H,1)}if(C.current&&w.current){const de=u.columns.flatMap(pe=>(pe.strips||[]).map(B=>({colOffsetX:q.left+pe.offset_x,colOffsetY:q.top,strip:B})));if(de.length>0?T.renderStripsWithTexture(C.current,U,K,u.image_size[0],u.image_size[1],de,1):T.renderStripsWithTexture(C.current,U,K,u.image_size[0],u.image_size[1],[{colOffsetX:0,colOffsetY:0,strip:{srcQuad:J?[[J.x,J.y],[J.x+J.w,J.y],[J.x+J.w,J.y+J.h],[J.x,J.y+J.h]]:[[0,0],[u.image_size[0],0],[u.image_size[0],u.image_size[1]],[0,u.image_size[1]]],dstRect:[0,0,U,K]}}],1),L&&L.current_page_strips.length>0){const pe=L.current_page_strips.map(B=>({colOffsetX:q.left+O,colOffsetY:q.top,strip:B}));T.renderStripsWithTexture(C.current,U,K,u.image_size[0],u.image_size[1],pe,1)}}if(L&&_.current&&v.current&&L.mate_page_strips.length>0){const de=L.mate_page_strips.map(pe=>({colOffsetX:q.left+O+L.half_w,colOffsetY:q.top,strip:pe}));T.renderStripsWithTexture(_.current,U,K,L.mate_img_size[0],L.mate_img_size[1],de,.65)}}},[e,u,L,U,K,O,M,se,q,s,J]),Me=f.useRef(Le);Me.current=Le,f.useEffect(()=>{const T=h.current;if(!T)return;const de=ee=>{C.current=w.current?ee.createTexture(w.current):null,_.current=v.current?ee.createTexture(v.current):null,Me.current()};try{const ee=new oo(T);k.current=ee,de(ee)}catch(ee){console.error("Failed to init WebGL renderer:",ee)}const pe=ee=>{ee.preventDefault(),console.warn("WebGL context lost")},B=()=>{console.info("WebGL context restored, re-initializing..."),h.current&&(k.current=new oo(h.current),de(k.current))};return T.addEventListener("webglcontextlost",pe,!1),T.addEventListener("webglcontextrestored",B,!1),()=>{T.removeEventListener("webglcontextlost",pe),T.removeEventListener("webglcontextrestored",B),k.current&&(k.current.deleteTexture(C.current),k.current.deleteTexture(_.current),k.current.destroy(),k.current=null)}},[]),f.useEffect(()=>{if(!e||!y)return;let T=!0;return so(e).then(de=>{if(!T||!de)return;w.current=de,N.current=e,m(B=>B&&B.url===e&&B.w===de.naturalWidth&&B.h===de.naturalHeight?B:{url:e,w:de.naturalWidth,h:de.naturalHeight});const pe=k.current;pe&&(pe.deleteTexture(C.current),C.current=pe.createTexture(de)),A(B=>B+1)}),()=>{T=!1}},[e,y]);const Se=L==null?void 0:L.mate_image_url;f.useEffect(()=>{if(!Se||!y)return;let T=!0;return so(Se).then(de=>{if(!T||!de)return;v.current=de;const pe=k.current;pe&&(pe.deleteTexture(_.current),_.current=pe.createTexture(de)),z(B=>B+1)}),()=>{T=!1}},[Se,y]),Ya(()=>{y&&Le()},[Le,$,R,oe,ye,y]);const le=f.useMemo(()=>(u.figBlocks??[]).map(T=>{const[de,pe,B,ee]=T.box;return{id:T.id,x:q.left+de-((J==null?void 0:J.x)??0),y:q.top+pe-((J==null?void 0:J.y)??0),w:Math.max(B-de,1),h:Math.max(ee-pe,1)}}),[u,q,J]),Oe=f.useMemo(()=>{const T=[];for(const de of u.columns)for(const pe of de.chars){const[B,ee,Ce,Ie]=pe.bbox_col;T.push({id:pe.id,char:pe.char,x:q.left+de.offset_x+B-((J==null?void 0:J.x)??0),y:q.top+ee-((J==null?void 0:J.y)??0),w:Math.max(Ce-B,1),h:Math.max(Ie-ee,1)})}return T},[u,q,J]);return t.jsxs("div",{ref:x,className:"guji-warp-wrapper",style:{position:"relative",maxWidth:"100%",maxHeight:"100%",aspectRatio:`${U} / ${K}`,backgroundColor:r("warp-bg"),boxShadow:r("warp-box-shadow"),borderRadius:"3px",overflow:"hidden",margin:"0 auto"},children:[t.jsx("img",{alt:"","aria-hidden":"true","data-warp-sizer":"",src:yx(U,K),style:{display:"block",width:"100%",height:"100%",visibility:"hidden"}}),t.jsx("canvas",{ref:h,width:oe,height:ye,"data-logical-size":`${Math.floor(U)}x${Math.floor(K)}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",display:"block",backgroundColor:r("warp-bg")}}),t.jsxs("svg",{viewBox:`0 0 ${U} ${K}`,preserveAspectRatio:"none",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[Oe.map(T=>{const de=i.has(T.id),pe=o===T.id;return t.jsx("rect",{"data-selected":de?"true":void 0,x:T.x,y:T.y,width:T.w,height:T.h,fill:de?r("warp-sel-bg"):pe?r("warp-hover-bg"):"transparent",stroke:de?r("warp-sel-stroke"):pe?r("warp-hover-stroke"):"transparent",strokeWidth:de?3.5:pe?2:0,style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>a==null?void 0:a(T.id),onMouseEnter:()=>l==null?void 0:l(T.id),onMouseLeave:()=>l==null?void 0:l(null),children:t.jsx("title",{children:T.char})},T.id)}),le.map(T=>{const de=d===T.id;return t.jsx("rect",{"data-fig-block":T.id,"data-selected":de?"true":void 0,x:T.x,y:T.y,width:T.w,height:T.h,fill:de?r("warp-sel-bg"):"transparent",stroke:r(de?"warp-sel-stroke":"warp-hover-stroke"),strokeWidth:de?3.5:2,strokeDasharray:de?void 0:"10 8",style:{pointerEvents:"auto",cursor:"pointer"},onClick:()=>c==null?void 0:c(T.id),children:t.jsx("title",{children:T.id})},`fig-${T.id}`)}),L&&t.jsxs("g",{children:[t.jsx("line",{x1:q.left+O,y1:q.top,x2:q.left+O,y2:q.top+M,stroke:r("warp-banxin-border"),strokeWidth:1.5}),t.jsx("line",{x1:q.left+O+L.half_w,y1:q.top,x2:q.left+O+L.half_w,y2:q.top+M,stroke:r("warp-banxin-fold"),strokeWidth:1.5,strokeDasharray:"8 6"}),t.jsx("line",{x1:q.left+se,y1:q.top,x2:q.left+se,y2:q.top+M,stroke:r("warp-banxin-outer"),strokeWidth:1})]})]})]})},as=`
|
|
1380
1380
|
.bim-et-w { position: relative; display: inline; }
|
|
1381
1381
|
.bim-et {
|
|
1382
1382
|
color: inherit; text-decoration-line: underline;
|
|
@@ -1428,27 +1428,58 @@ a.bim-et:focus-visible { outline: 2px solid ${r("accent")}; outline-offset: 2px;
|
|
|
1428
1428
|
.bim-et-card-s { display: block; color: ${r("hint-fg")}; }
|
|
1429
1429
|
.bim-et-card-a { display: block; margin-top: 6px; color: ${r("accent")}; text-decoration: none; }
|
|
1430
1430
|
.bim-et-card-a:hover, .bim-et-card-a:focus-visible { text-decoration: underline; }
|
|
1431
|
+
/* 触屏:点专名/书名打开的卡是贴底面板(手机无悬停,浮在词旁的小卡遮字、链接难点)。
|
|
1432
|
+
fixed 定位:阅读页分页容器已对含卡的页关掉 content-visibility,不会裁掉它 */
|
|
1433
|
+
.bim-et-card[data-sheet] {
|
|
1434
|
+
position: fixed; z-index: 200; top: auto; left: 8px; right: 8px; width: auto; max-width: none;
|
|
1435
|
+
bottom: calc(8px + env(safe-area-inset-bottom, 0px));
|
|
1436
|
+
max-height: min(50vh, 420px); overflow-y: auto; overscroll-behavior: contain;
|
|
1437
|
+
padding: 14px 16px 6px; font-size: 15px; border-radius: 12px;
|
|
1438
|
+
box-shadow: ${r("shadow-summary")};
|
|
1439
|
+
}
|
|
1440
|
+
.bim-et-card[data-sheet] .bim-et-card-k { padding-right: 44px; }
|
|
1441
|
+
.bim-et-card[data-sheet] .bim-et-card-t { font-size: 17px; }
|
|
1442
|
+
.bim-et-card[data-sheet] .bim-et-card-d { -webkit-line-clamp: 5; }
|
|
1443
|
+
.bim-et-card[data-sheet] .bim-et-card-a {
|
|
1444
|
+
box-sizing: border-box; min-height: 44px; margin: 10px 0 8px; padding: 10px 12px;
|
|
1445
|
+
display: flex; align-items: center; justify-content: center;
|
|
1446
|
+
border: 1px solid ${r("accent")}; border-radius: 8px; font-size: 15px;
|
|
1447
|
+
}
|
|
1448
|
+
/* 合称面板:每条目一行,「查看详情」缩成标题行右端的按钮,两三条不必滚动 */
|
|
1449
|
+
.bim-et-card-multi[data-sheet] .bim-et-row { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; padding: 10px 0 8px; }
|
|
1450
|
+
.bim-et-card-multi[data-sheet] .bim-et-row-t { grid-column: 1; grid-row: 1; }
|
|
1451
|
+
.bim-et-card-multi[data-sheet] .bim-et-row > .bim-et-card-a { grid-column: 2; grid-row: 1; margin: 0; padding: 6px 12px; min-height: 40px; white-space: nowrap; }
|
|
1452
|
+
.bim-et-card-multi[data-sheet] .bim-et-row > :not(.bim-et-row-t):not(.bim-et-card-a) { grid-column: 1 / -1; }
|
|
1453
|
+
.bim-et-card-multi[data-sheet] .bim-et-card-k + .bim-et-row { margin-top: 6px; }
|
|
1454
|
+
.bim-et-card.bim-et-dense[data-sheet] .bim-et-card-a { margin: 0 0 0 auto; padding: 6px 14px; min-height: 40px; }
|
|
1455
|
+
.bim-et-card-x {
|
|
1456
|
+
position: absolute; top: 2px; right: 2px; width: 44px; height: 44px; padding: 0;
|
|
1457
|
+
display: flex; align-items: center; justify-content: center;
|
|
1458
|
+
background: none; border: 0; color: ${r("label-fg")}; font-size: 26px; line-height: 1; cursor: pointer;
|
|
1459
|
+
}
|
|
1431
1460
|
@media (prefers-reduced-motion: no-preference) {
|
|
1432
1461
|
.bim-et-card { animation: bim-et-in 120ms ease-out; }
|
|
1433
1462
|
@keyframes bim-et-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
|
|
1463
|
+
.bim-et-card[data-sheet] { animation: bim-et-up 160ms ease-out; }
|
|
1464
|
+
@keyframes bim-et-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
|
|
1434
1465
|
}
|
|
1435
|
-
`,vx=120;function jt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function kx(e,n=vx){if(!e)return;const i=e.replace(/\s+/g," ").trim(),o=Array.from(i);return o.length>n?o.slice(0,n).join("")+"…":i}function wx(e){const n=e.dates&&typeof e.dates=="object"?e.dates:{},i=typeof n.birth=="number"?n.birth:void 0,o=typeof n.death=="number"?n.death:void 0;if(!(i===void 0&&o===void 0))return`${i??"?"}–${o??"?"}`}function Sx(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=jt(o.name);return s?[jt(o.dynasty)&&`〔${jt(o.dynasty)}〕`,s,jt(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Sd(e,n){const i=jt(n.type),o=jt(n.primary_name)??jt(n.title)??e,s=i==="entity"?[jt(n.dynasty),wx(n),jt(n.native_place)].filter(Boolean).join(" · "):[Sx(n),jt(n.edition),jt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?jt(n.description.text):jt(n.description);return{id:jt(n.id)??e,type:i,title:o,meta:s||void 0,description:kx(a)}}function _d(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 $d(e){return async n=>{const i=await e.getItem(n);if(i)return Sd(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return _d(o)}return null}}const Va=new WeakMap;function Cd(e,n,i){let o=Va.get(e);o||(o=new Map,Va.set(e,o));const s=o.get(i);if(s)return s;const a=n(i);return o.set(i,a),a.catch(()=>o.delete(i)),a}const zd=e=>`/item/${encodeURIComponent(e)}`,oo={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},Nd=typeof window>"u"?f.useEffect:f.useLayoutEffect;function ss(e,n){return f.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:$d(e)}:null,[n,e])}const _x=e=>e,$x=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=zd,onNavigate:d,renderText:c=_x,hoverDelayMs:p=250,closeDelayMs:g,injectStyles:m=!0,className:u})=>{const h=f.useMemo(()=>{const j=i==="plain"?yd(e,n,o):n;return jd(e,j)},[e,n,i,o]),x=ss(s,a);return t.jsxs("span",{className:u?`bim-et-root ${u}`:"bim-et-root",children:[m&&t.jsx("style",{children:os}),h.map(j=>j.type==="text"?t.jsx(f.Fragment,{children:c(j.text)},`t${j.start}`):t.jsx(as,{span:j.span,label:j.text,hasBrackets:e[j.start-1]==="《"&&e[j.start+j.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:g},`${j.span.key}@${j.start}`))]})};let Jt=null;const as=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,cardNewTab:c,renderText:p,hoverDelayMs:g,closeDelayMs:m=280})=>{const u=f.useId(),[h,x]=f.useState(!1),[j,b]=f.useState(!1),$=f.useRef(null),y=f.useRef(null),k=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,w=e.kind==="work"&&!i,v=t.jsxs(t.Fragment,{children:[w&&t.jsx("span",{className:"bim-et-sr",children:"《"}),p(n),w&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),C=()=>{$.current&&(clearTimeout($.current),$.current=null)},S=()=>{y.current&&(clearTimeout(y.current),y.current=null)},_=f.useRef(!1),R=f.useCallback(()=>{_.current=!1,C(),S(),x(!1),b(!1),Jt===R&&(Jt=null)},[]);f.useEffect(()=>()=>{C(),S(),Jt===R&&(Jt=null)},[R]);const z=f.useCallback(()=>{Jt&&Jt!==R&&Jt(),Jt=R,x(!0)},[R]),N=f.useCallback(G=>{S(),b(!0),!h&&(C(),G<=0?z():$.current=setTimeout(z,G))},[h,z]),I=f.useCallback(()=>{C(),S(),!_.current&&(y.current=setTimeout(R,m))},[R,m]),B=f.useRef(null);f.useEffect(()=>{if(!h||!e.targets)return;const G=oe=>{var se;(se=B.current)!=null&&se.contains(oe.target)||R()};return document.addEventListener("pointerdown",G),()=>document.removeEventListener("pointerdown",G)},[h,e.targets,R]);const O=!!e.targetId,A=e.targetId,W={className:"bim-et-w","data-active":j?"":void 0,onMouseEnter:()=>N(g),onMouseLeave:I,onBlur:G=>{G.currentTarget.contains(G.relatedTarget)||R()},onKeyDown:G=>{G.key==="Escape"&&h&&(G.stopPropagation(),R())}};return e.targets?t.jsxs("span",{...W,ref:B,children:[t.jsx("span",{className:`${k} bim-et-multi`,role:"button",tabIndex:0,"aria-haspopup":"true","aria-expanded":h,"aria-controls":h?u:void 0,onFocus:()=>N(0),onClick:()=>{S(),_.current=!0,b(!0),z()},onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),h?R():(_.current=!0,b(!0),z()))},children:v}),h&&t.jsx(Cx,{id:u,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c})]}):!O||!A?t.jsxs("span",{...W,children:[t.jsx("span",{className:k,children:v}),h&&t.jsx(Ga,{id:u,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...W,children:[t.jsx("a",{className:k,href:a(A),"data-entity-id":A,"aria-describedby":h?u:void 0,onFocus:()=>N(0),onClick:l?G=>l(A,G):void 0,children:v}),h&&t.jsx(Ga,{id:u,entityId:A,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c})]})},Ga=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a,newTab:l})=>{const{convert:d,t:c}=ae(),p=f.useRef(null),[g,m]=f.useState("start"),[u,h]=f.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});f.useEffect(()=>{if(!o||!n)return;let b=!1;return h({status:"loading"}),Cd(o.owner,o.load,n).then($=>{b||h({status:"ready",summary:$})}).catch(()=>{b||h({status:"error"})}),()=>{b=!0}},[o,n]),Nd(()=>{const b=p.current;if(!b||typeof window>"u")return;const $=b.getBoundingClientRect(),y=document.documentElement.clientWidth||window.innerWidth;$.right>y-8&&g==="start"&&m("end")},[u,g]);const x=u.status==="ready"?u.summary:null,j=(x==null?void 0:x.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:p,id:e,role:"tooltip",className:"bim-et-card","data-align":g,children:[t.jsx("span",{className:"bim-et-card-k",children:d(oo[i.kind])}),j&&t.jsx("span",{className:"bim-et-card-t",children:d(j)}),(x==null?void 0:x.meta)&&t.jsx("span",{className:"bim-et-card-m",children:d(x.meta)}),(x==null?void 0:x.description)&&t.jsx("span",{className:"bim-et-card-d",children:d(x.description)}),u.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:d("載入中…")}),u.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:d("摘要載入失敗")}),x&&t.jsx("a",{className:"bim-et-card-a",href:s(x.id||n),...l?{target:"_blank",rel:"noopener"}:{},onClick:a?b=>a(x.id||n,b):void 0,children:c("reader.entityDetail")})]}):t.jsx("span",{ref:p,id:e,role:"tooltip",className:"bim-et-card","data-align":g,children:t.jsx("span",{className:"bim-et-card-k",children:d(oo[i.kind])})})},Cx=({id:e,span:n,loader:i,buildHref:o,onNavigate:s,newTab:a})=>{const{convert:l}=ae(),d=f.useRef(null),[c,p]=f.useState(0);Nd(()=>{const m=d.current;if(!m||typeof window>"u")return;const u=m.getBoundingClientRect();if(!u.width)return;const h=document.documentElement.clientWidth||window.innerWidth;p(Math.max(8-u.left,Math.min(0,h-8-u.right)))},[]);const g=n.targets??[];return t.jsxs("span",{ref:d,id:e,role:"group","aria-label":l(`合稱,${g.length} 條`),className:`bim-et-card bim-et-card-multi${g.length>3?" bim-et-dense":""}`,style:c?{left:c}:void 0,children:[t.jsxs("span",{className:"bim-et-card-k",children:[l("合稱")," · ",l(`${g.length} 條`)]}),g.map(m=>t.jsx(zx,{target:m,kind:n.kind,loader:i,buildHref:o,onNavigate:s,newTab:a},m.id))]})},zx=({target:e,kind:n,loader:i,buildHref:o,onNavigate:s,newTab:a})=>{const{convert:l,t:d}=ae(),[c,p]=f.useState(i?{status:"loading"}:{status:"ready",summary:null});f.useEffect(()=>{if(!i)return;let u=!1;return p({status:"loading"}),Cd(i.owner,i.load,e.id).then(h=>{u||p({status:"ready",summary:h})}).catch(()=>{u||p({status:"error"})}),()=>{u=!0}},[i,e.id]);const g=c.status==="ready"?c.summary:null,m=(g==null?void 0:g.title)??e.canonicalName??e.id;return t.jsxs("span",{className:"bim-et-row","data-entity-id":e.id,children:[t.jsxs("span",{className:"bim-et-row-t",children:[e.part&&t.jsx("span",{className:"bim-et-row-p",children:Nx(e.part,l)}),t.jsx("span",{className:"bim-et-card-t",children:l(m)}),t.jsx("span",{className:"bim-et-row-k",children:l(oo[n])})]}),(g==null?void 0:g.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(g.meta)}),(g==null?void 0:g.description)&&t.jsx("span",{className:"bim-et-card-d bim-et-card-d2",children:l(g.description)}),c.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),c.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),g&&t.jsx("a",{className:"bim-et-card-a",href:o(g.id||e.id),...a?{target:"_blank",rel:"noopener"}:{},onClick:s?u=>s(g.id||e.id,u):void 0,children:d("reader.entityDetail")})]})},Nx=(e,n)=>`${n(e)} →`,ls=e=>`〔图:${e}〕`,Td=(e,n)=>e&&n?n(e.file):null;function Rd({fig:e,info:n,figUrl:i,block:o,failed:s,onFail:a}){const l=(n==null?void 0:n.alt)??"图形符号",d=Td(n,i);if(!d||s)return t.jsx("span",{className:"guji-fig-missing","data-fig-missing":e,children:ls(l)});const c=n.width>0&&n.height>0?`${n.width} / ${n.height}`:void 0;return n.mime==="image/svg+xml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"guji-fig-img is-svg",role:"img","aria-label":l,"data-fig":e,style:{"--guji-fig-src":`url("${d}")`,aspectRatio:c}}),t.jsx("img",{src:d,alt:"",hidden:!0,onError:a})]}):t.jsx("img",{className:`guji-fig-img${o?" is-block":""}`,src:d,alt:o?l:"","data-fig":e,"data-raster":"1",loading:o?"lazy":void 0,decoding:"async",draggable:!1,style:c?{aspectRatio:c}:void 0,onError:a})}function Tx({id:e,fig:n,info:i,figUrl:o,cells:s,cont:a,className:l,pageStart:d,children:c}){const{t:p}=ae(),g=(i==null?void 0:i.alt)??"",m=g&&g!==p("reader.figPlain")?p("reader.figLabel",{alt:g}):p("reader.figPlain"),[u,h]=f.useState(!1),x=u||!Td(i,o);return t.jsxs("span",{"data-char-id":e,"data-page-start":d,"data-fig-copy":a?"":ls((i==null?void 0:i.alt)??"图形符号"),className:`${l} is-fig${a?" is-fig-cont":""}${x&&!a?" is-fig-missing":""}`,style:a?void 0:{"--guji-fig-n":s},title:m,"aria-label":m,role:"img",children:[t.jsx("span",{className:"guji-fig-glyph",children:c}),!a&&t.jsx(Rd,{fig:n,info:i,figUrl:o,failed:u,onFail:()=>h(!0)})]})}function Rx({fig:e,info:n,figUrl:i,onClick:o}){const{t:s}=ae(),a=(n==null?void 0:n.alt)??"图形符号",l=a!==s("reader.figPlain")?s("reader.figLabel",{alt:a}):s("reader.figPlain"),[d,c]=f.useState(!1);return t.jsxs("figure",{className:"guji-fig-block","data-fig-block":e,"data-fig-copy":ls(a),title:l,onClick:o,style:o?{cursor:"pointer"}:void 0,children:[t.jsx(Rd,{fig:e,info:n,figUrl:i,block:!0,failed:d,onFail:()=>c(!0)}),t.jsx("figcaption",{className:"guji-fig-caption",children:a})]})}const Ix=new Set(["P","H1","H2","H3","H4","H5","H6","FIGURE","SECTION","DIV","LI"]);function Ex(e){const n=e.cloneContents();if(!n.querySelector("[data-fig-copy]"))return null;let i="";const o=()=>{i&&!i.endsWith(`
|
|
1466
|
+
`,Sx=120;function kt(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function _x(e,n=Sx){if(!e)return;const i=e.replace(/\s+/g," ").trim(),o=Array.from(i);return o.length>n?o.slice(0,n).join("")+"…":i}function $x(e){const n=e.dates&&typeof e.dates=="object"?e.dates:{},i=typeof n.birth=="number"?n.birth:void 0,o=typeof n.death=="number"?n.death:void 0;if(!(i===void 0&&o===void 0))return`${i??"?"}–${o??"?"}`}function Cx(e){if(!Array.isArray(e.authors))return;const n=e.authors.map(i=>{if(!i||typeof i!="object")return"";const o=i,s=kt(o.name);return s?[kt(o.dynasty)&&`〔${kt(o.dynasty)}〕`,s,kt(o.role)].filter(Boolean).join(""):""}).filter(Boolean);return n.length?n.slice(0,3).join("、"):void 0}function Cd(e,n){const i=kt(n.type),o=kt(n.primary_name)??kt(n.title)??e,s=i==="entity"?[kt(n.dynasty),$x(n),kt(n.native_place)].filter(Boolean).join(" · "):[Cx(n),kt(n.edition),kt(n.measure_info)].filter(Boolean).join(" · "),a=n.description&&typeof n.description=="object"?kt(n.description.text):kt(n.description);return{id:kt(n.id)??e,type:i,title:o,meta:s||void 0,description:_x(a)}}function zd(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 Nd(e){return async n=>{const i=await e.getItem(n);if(i)return Cd(n,i);if(e.getEntry){const o=await e.getEntry(n);if(o)return zd(o)}return null}}const Ka=new WeakMap;function Td(e,n,i){let o=Ka.get(e);o||(o=new Map,Ka.set(e,o));const s=o.get(i);if(s)return s;const a=n(i);return o.set(i,a),a.catch(()=>o.delete(i)),a}const Rd=e=>`/item/${encodeURIComponent(e)}`,ao={work:"書名",people:"人名",place:"地名",office:"官職",dynasty:"朝代",reign:"年號",other:"專名"},ls=typeof window>"u"?f.useEffect:f.useLayoutEffect;function cs(e,n){return f.useMemo(()=>n?{owner:n,load:n}:e?{owner:e,load:Nd(e)}:null,[n,e])}const zx=e=>e,Nx=({text:e,entities:n,offsets:i="text",plainBase:o=0,transport:s,loadSummary:a,buildHref:l=Rd,onNavigate:d,renderText:c=zx,hoverDelayMs:p=250,closeDelayMs:g,injectStyles:m=!0,className:u})=>{const h=f.useMemo(()=>{const j=i==="plain"?kd(e,n,o):n;return wd(e,j)},[e,n,i,o]),x=cs(s,a);return t.jsxs("span",{className:u?`bim-et-root ${u}`:"bim-et-root",children:[m&&t.jsx("style",{children:as}),h.map(j=>j.type==="text"?t.jsx(f.Fragment,{children:c(j.text)},`t${j.start}`):t.jsx(ds,{span:j.span,label:j.text,hasBrackets:e[j.start-1]==="《"&&e[j.start+j.text.length]==="》",loader:x,buildHref:l,onNavigate:d,renderText:c,hoverDelayMs:p,closeDelayMs:g},`${j.span.key}@${j.start}`))]})};let Qt=null;const ds=({span:e,label:n,hasBrackets:i,plain:o,loader:s,buildHref:a,onNavigate:l,onCardNavigate:d=l,cardNewTab:c,renderText:p,hoverDelayMs:g,closeDelayMs:m=280})=>{const u=f.useId(),[h,x]=f.useState(!1),[j,b]=f.useState(!1),[S,y]=f.useState(!1),k=f.useRef(!1),w=f.useRef(null),v=f.useRef(null),C=`bim-et bim-et-${e.kind}${o?" bim-et-nu":""}`,_=e.kind==="work"&&!i,$=t.jsxs(t.Fragment,{children:[_&&t.jsx("span",{className:"bim-et-sr",children:"《"}),p(n),_&&t.jsx("span",{className:"bim-et-sr",children:"》"})]}),A=()=>{w.current&&(clearTimeout(w.current),w.current=null)},R=()=>{v.current&&(clearTimeout(v.current),v.current=null)},z=f.useRef(!1),N=f.useCallback(()=>{z.current=!1,A(),R(),x(!1),b(!1),y(!1),Qt===N&&(Qt=null)},[]);f.useEffect(()=>()=>{A(),R(),Qt===N&&(Qt=null)},[N]);const M=f.useCallback(()=>{Qt&&Qt!==N&&Qt(),Qt=N,x(!0)},[N]),O=f.useCallback(K=>{R(),b(!0),!h&&(A(),K<=0?M():w.current=setTimeout(M,K))},[h,M]),L=f.useCallback(()=>{A(),R(),!z.current&&(v.current=setTimeout(N,m))},[N,m]),D=f.useRef(null);f.useEffect(()=>{if(!h||!(e.targets||S))return;const K=S?"click":"pointerdown",Z=oe=>{var ye;(ye=D.current)!=null&&ye.contains(oe.target)||N()};return document.addEventListener(K,Z),()=>document.removeEventListener(K,Z)},[h,S,e.targets,N]);const q=f.useCallback(()=>{A(),R(),z.current=!0,b(!0),y(!0),M()},[M]);ls(()=>{if(!h||!S)return;const K=D.current,Z=K==null?void 0:K.querySelector(".bim-et-card");if(!K||!Z||typeof window>"u")return;const oe=()=>{const Le=K.getClientRects(),Me=Le[Le.length-1];if(!Me)return;const Se=Me.bottom+12-Z.getBoundingClientRect().top;Se>0&&window.scrollBy({top:Se,behavior:"smooth"})};if(oe(),typeof ResizeObserver>"u")return;const ye=new ResizeObserver(oe);return ye.observe(Z),()=>ye.disconnect()},[h,S]);const J=!!e.targetId,se=e.targetId,U={className:"bim-et-w","data-active":j?"":void 0,onPointerEnter:K=>{k.current=K.pointerType==="touch"},onPointerDown:K=>{k.current=K.pointerType==="touch"},onMouseEnter:()=>{k.current||O(g)},onMouseLeave:()=>{k.current||L()},onBlur:K=>{K.currentTarget.contains(K.relatedTarget)||N()},onKeyDown:K=>{K.key==="Escape"&&h&&(K.stopPropagation(),N())}};return e.targets?t.jsxs("span",{...U,ref:D,children:[t.jsx("span",{className:`${C} bim-et-multi`,role:"button",tabIndex:0,"aria-haspopup":"true","aria-expanded":h,"aria-controls":h?u:void 0,onFocus:()=>{k.current||O(0)},onClick:()=>{k.current?q():(R(),z.current=!0,b(!0),M())},onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),h?N():(z.current=!0,b(!0),M()))},children:$}),h&&t.jsx(Tx,{id:u,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c,sheet:S,onClose:N})]}):!J||!se?t.jsxs("span",{...U,ref:D,children:[t.jsx("span",{className:C,children:$}),h&&!k.current&&t.jsx(qa,{id:u,entityId:null,span:e,loader:null,buildHref:a,onNavigate:l})]}):t.jsxs("span",{...U,ref:D,children:[t.jsx("a",{className:C,href:a(se),"data-entity-id":se,"aria-describedby":h?u:void 0,onFocus:()=>{k.current||O(0)},onClick:K=>{if(k.current&&K.detail>0){K.preventDefault(),q();return}l==null||l(se,K)},children:$}),h&&t.jsx(qa,{id:u,entityId:se,span:e,loader:s,buildHref:a,onNavigate:c?void 0:d,newTab:c,sheet:S,onClose:N})]})},qa=({id:e,entityId:n,span:i,loader:o,buildHref:s,onNavigate:a,newTab:l,sheet:d,onClose:c})=>{const{convert:p,t:g}=ae(),m=f.useRef(null),[u,h]=f.useState("start"),[x,j]=f.useState(o&&n?{status:"loading"}:{status:"ready",summary:null});f.useEffect(()=>{if(!o||!n)return;let y=!1;return j({status:"loading"}),Td(o.owner,o.load,n).then(k=>{y||j({status:"ready",summary:k})}).catch(()=>{y||j({status:"error"})}),()=>{y=!0}},[o,n]),ls(()=>{const y=m.current;if(!y||typeof window>"u")return;const k=y.getBoundingClientRect(),w=document.documentElement.clientWidth||window.innerWidth;!d&&k.right>w-8&&u==="start"&&h("end")},[x,u,d]);const b=x.status==="ready"?x.summary:null,S=(b==null?void 0:b.title)??i.canonicalName??i.text;return n?t.jsxs("span",{ref:m,id:e,role:d?"dialog":"tooltip","aria-label":d?S:void 0,className:"bim-et-card","data-align":u,"data-sheet":d?"":void 0,children:[d&&c&&t.jsx(Id,{onClose:c}),t.jsx("span",{className:"bim-et-card-k",children:p(ao[i.kind])}),S&&t.jsx("span",{className:"bim-et-card-t",children:p(S)}),(b==null?void 0:b.meta)&&t.jsx("span",{className:"bim-et-card-m",children:p(b.meta)}),(b==null?void 0:b.description)&&t.jsx("span",{className:"bim-et-card-d",children:p(b.description)}),x.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:p("載入中…")}),x.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:p("摘要載入失敗")}),b&&t.jsx("a",{className:"bim-et-card-a",href:s(b.id||n),...l?{target:"_blank",rel:"noopener"}:{},onClick:a?y=>a(b.id||n,y):void 0,children:g("reader.entityDetail")})]}):t.jsx("span",{ref:m,id:e,role:"tooltip",className:"bim-et-card","data-align":u,children:t.jsx("span",{className:"bim-et-card-k",children:p(ao[i.kind])})})},Tx=({id:e,span:n,loader:i,buildHref:o,onNavigate:s,newTab:a,sheet:l,onClose:d})=>{const{convert:c}=ae(),p=f.useRef(null),[g,m]=f.useState(0);ls(()=>{const h=p.current;if(!h||l||typeof window>"u")return;const x=h.getBoundingClientRect();if(!x.width)return;const j=document.documentElement.clientWidth||window.innerWidth;m(Math.max(8-x.left,Math.min(0,j-8-x.right)))},[]);const u=n.targets??[];return t.jsxs("span",{ref:p,id:e,role:"group","aria-label":c(`合稱,${u.length} 條`),className:`bim-et-card bim-et-card-multi${u.length>3?" bim-et-dense":""}`,"data-sheet":l?"":void 0,style:g&&!l?{left:g}:void 0,children:[l&&d&&t.jsx(Id,{onClose:d}),t.jsxs("span",{className:"bim-et-card-k",children:[c("合稱")," · ",c(`${u.length} 條`)]}),u.map(h=>t.jsx(Rx,{target:h,kind:n.kind,loader:i,buildHref:o,onNavigate:s,newTab:a},h.id))]})},Rx=({target:e,kind:n,loader:i,buildHref:o,onNavigate:s,newTab:a})=>{const{convert:l,t:d}=ae(),[c,p]=f.useState(i?{status:"loading"}:{status:"ready",summary:null});f.useEffect(()=>{if(!i)return;let u=!1;return p({status:"loading"}),Td(i.owner,i.load,e.id).then(h=>{u||p({status:"ready",summary:h})}).catch(()=>{u||p({status:"error"})}),()=>{u=!0}},[i,e.id]);const g=c.status==="ready"?c.summary:null,m=(g==null?void 0:g.title)??e.canonicalName??e.id;return t.jsxs("span",{className:"bim-et-row","data-entity-id":e.id,children:[t.jsxs("span",{className:"bim-et-row-t",children:[e.part&&t.jsx("span",{className:"bim-et-row-p",children:Ix(e.part,l)}),t.jsx("span",{className:"bim-et-card-t",children:l(m)}),t.jsx("span",{className:"bim-et-row-k",children:l(ao[n])})]}),(g==null?void 0:g.meta)&&t.jsx("span",{className:"bim-et-card-m",children:l(g.meta)}),(g==null?void 0:g.description)&&t.jsx("span",{className:"bim-et-card-d bim-et-card-d2",children:l(g.description)}),c.status==="loading"&&t.jsx("span",{className:"bim-et-card-s",children:l("載入中…")}),c.status==="error"&&t.jsx("span",{className:"bim-et-card-s",children:l("摘要載入失敗")}),g&&t.jsx("a",{className:"bim-et-card-a",href:o(g.id||e.id),...a?{target:"_blank",rel:"noopener"}:{},onClick:s?u=>s(g.id||e.id,u):void 0,children:d("reader.entityDetail")})]})},Ix=(e,n)=>`${n(e)} →`,Id=({onClose:e})=>{const{t:n}=ae();return t.jsx("button",{type:"button",className:"bim-et-card-x","aria-label":n("reader.close"),onClick:e,children:"×"})},ps=e=>`〔图:${e}〕`,Ed=(e,n)=>e&&n?n(e.file):null;function Ld({fig:e,info:n,figUrl:i,block:o,failed:s,onFail:a}){const l=(n==null?void 0:n.alt)??"图形符号",d=Ed(n,i);if(!d||s)return t.jsx("span",{className:"guji-fig-missing","data-fig-missing":e,children:ps(l)});const c=n.width>0&&n.height>0?`${n.width} / ${n.height}`:void 0;return n.mime==="image/svg+xml"?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"guji-fig-img is-svg",role:"img","aria-label":l,"data-fig":e,style:{"--guji-fig-src":`url("${d}")`,aspectRatio:c}}),t.jsx("img",{src:d,alt:"",hidden:!0,onError:a})]}):t.jsx("img",{className:`guji-fig-img${o?" is-block":""}`,src:d,alt:o?l:"","data-fig":e,"data-raster":"1",loading:o?"lazy":void 0,decoding:"async",draggable:!1,style:c?{aspectRatio:c}:void 0,onError:a})}function Ex({id:e,fig:n,info:i,figUrl:o,cells:s,cont:a,className:l,pageStart:d,children:c}){const{t:p}=ae(),g=(i==null?void 0:i.alt)??"",m=g&&g!==p("reader.figPlain")?p("reader.figLabel",{alt:g}):p("reader.figPlain"),[u,h]=f.useState(!1),x=u||!Ed(i,o);return t.jsxs("span",{"data-char-id":e,"data-page-start":d,"data-fig-copy":a?"":ps((i==null?void 0:i.alt)??"图形符号"),className:`${l} is-fig${a?" is-fig-cont":""}${x&&!a?" is-fig-missing":""}`,style:a?void 0:{"--guji-fig-n":s},title:m,"aria-label":m,role:"img",children:[t.jsx("span",{className:"guji-fig-glyph",children:c}),!a&&t.jsx(Ld,{fig:n,info:i,figUrl:o,failed:u,onFail:()=>h(!0)})]})}function Lx({fig:e,info:n,figUrl:i,onClick:o}){const{t:s}=ae(),a=(n==null?void 0:n.alt)??"图形符号",l=a!==s("reader.figPlain")?s("reader.figLabel",{alt:a}):s("reader.figPlain"),[d,c]=f.useState(!1);return t.jsxs("figure",{className:"guji-fig-block","data-fig-block":e,"data-fig-copy":ps(a),title:l,onClick:o,style:o?{cursor:"pointer"}:void 0,children:[t.jsx(Ld,{fig:e,info:n,figUrl:i,block:!0,failed:d,onFail:()=>c(!0)}),t.jsx("figcaption",{className:"guji-fig-caption",children:a})]})}const Ax=new Set(["P","H1","H2","H3","H4","H5","H6","FIGURE","SECTION","DIV","LI"]);function Mx(e){const n=e.cloneContents();if(!n.querySelector("[data-fig-copy]"))return null;let i="";const o=()=>{i&&!i.endsWith(`
|
|
1436
1467
|
`)&&(i+=`
|
|
1437
|
-
`)},s=a=>{if(a.nodeType===3){i+=a.nodeValue??"";return}if(!(a.nodeType!==1&&a.nodeType!==11)){if(a.nodeType===1){const l=a;if(l.classList.contains("guji-page-divider")||l.style.userSelect==="none")return;const d=l.getAttribute("data-fig-copy");if(d!==null){l.tagName==="FIGURE"?(o(),i+=d,o()):i+=d;return}const c=Ix.has(l.tagName);c&&o(),l.childNodes.forEach(s),c&&o();return}a.childNodes.forEach(s)}};return s(n),i.replace(/\n+$/,"")}const Lx=e=>`/item/${encodeURIComponent(e)}`;function Ax(e){const n=e.filter(i=>i.kind==null||i.kind==="point");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function Mx(e,n){const i=[];for(const o of e){const s=n.get(o.charData.id)??null,a=i[i.length-1];a&&a.entity===s?a.chars.push(o):i.push({entity:s,chars:[o]})}return i}const cs=({pageData:e,pages:n,punctuations:i=so,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:g,convert:m,scrollToPage:u,scrollToAnchor:h,onVisibleHeadingChange:x,entities:j,entityTransport:b,loadEntitySummary:$,buildEntityHref:y,onEntityNavigate:k,pageBreaks:w=!0,pageIndicatorY:v,onPageIndicatorYChange:C,quoteStyle:S,bookTitleStyle:_,showWorks:R,figures:z,figUrl:N,onFigureBlockClick:I})=>{var fe,be,Le;const B=f.useRef(null),O=f.useRef(0),A=f.useMemo(()=>{const V=new Map;return p&&i.forEach((M,J)=>{const Se=M.id?M:{...M,id:`${M.anchor}#${J}`},F=V.get(Se.anchor)||[];F.push(Se),V.set(Se.anchor,F)}),V},[i,p]),W=f.useMemo(()=>S===void 0&&_===void 0&&R===void 0?null:{quoteStyle:S??"original",hideBookBrackets:_==="wavy"||R===!1},[S,_,R]),G=_==="bracket",oe=f.useMemo(()=>{var Ce;const V=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],M=new Map;for(const re of V)for(const ye of re.columns)ye.chars.length>0&&!ye.raised&&M.set(ye.lead_blank||0,(M.get(ye.lead_blank||0)||0)+1);let J=0,Se=-1;for(const[re,ye]of M)(ye>Se||ye===Se&&re<J)&&(J=re,Se=ye);const F=re=>!!re.raised||(re.lead_blank||0)<J,pe=V.filter(re=>re.columns.some(ye=>ye.chars.length>0||ye.kind==="figure")).map(re=>{const ye=[...re.columns].sort((qe,ct)=>qe.col-ct.col),ve=[];let Pe=[];const xe=()=>{const qe=Hx(A.get(Pe[0].charData.id));ve.push({id:`para-p${re.page}-${ve.length}`,chars:Pe,...qe?{heading:{level:qe.mark.length,anchor:Pe[0].charData.id,...qe.toc===!1?{toc:!1}:{}}}:{}}),Pe=[]};let Te=!1,Ze=0,tt;const Ve=[];for(const qe of ye){if(qe.kind==="figure"&&qe.fig){Pe.length>0?xe():ve.length===0&&(Te=!0),Ve.push({before:ve.length,fig:qe.fig,...qe.figBox?{box:qe.figBox}:{}}),Ze=0;continue}if(qe.chars.length===0){qe.kind==="blank"&&Ze++;continue}const ct=qe.raised||qe.lead_blank||Ze?{raised:qe.raised,leadBlank:qe.lead_blank,blankBefore:Ze}:void 0;Ze=0,F(qe)||(tt=qe.lead_blank||0);let K=!0;for(const De of qe.chars){const et=A.get(De.id),{before:nt,after:xt}=et?Ax(et):Wx,Et=!!et&&et.some(Ot=>Ot.kind==="break"&&Ot.pos!=="before");et&&et.some(Ot=>Ot.kind==="heading")&&(Pe.length>0?xe():ve.length===0&&(Te=!0)),Pe.push({charData:De,col:qe.col,beforePuncts:nt,afterPuncts:xt,...K&&ct?{start:ct}:{}}),K=!1,Et&&xe()}}const ut=Pe.length>0;return ut&&xe(),{page:re.page,paragraphs:ve,endsOpen:ut,...tt!==void 0?{tailLead:tt}:{},...Te?{leadStarts:Te}:{},...re.label?{label:re.label}:{},...Ze>0?{trailingBlank:Ze}:{},...Ve.length>0?{blocks:Ve}:{}}}),ce=new Map;if(!w){let re=null;for(const ye of pe){const ve=ye.paragraphs[0],Pe=(Ce=ve==null?void 0:ve.chars[0])==null?void 0:Ce.start,xe=(Pe==null?void 0:Pe.leadBlank)||0,Te=!!Pe&&!Pe.raised&&xe>=J&&xe>((re==null?void 0:re.tailLead)??J),Ze=!!ye.leadStarts||!!(Pe!=null&&Pe.blankBefore)||Te,tt=ye.paragraphs.length===1&&!!ye.trailingBlank;if(re&&ve&&!Ze&&!tt){for(const Ve of ve.chars)ce.set(Ve.charData.id,re.owner);re.para.chars=re.para.chars.concat(ve.chars),ye.leadFirstId=ve.chars[0].charData.id,ye.paragraphs=ye.paragraphs.slice(1),ye.blocks&&(ye.blocks=ye.blocks.map(Ve=>({...Ve,before:Ve.before-1})))}if(ye.endsOpen&&!ye.trailingBlank){const Ve=ye.paragraphs[ye.paragraphs.length-1];Ve?re={para:Ve,owner:ye.page,tailLead:ye.tailLead??(re==null?void 0:re.tailLead)??J}:re&&ye.tailLead!==void 0&&(re.tailLead=ye.tailLead)}else re=null}}const Oe=new Map;for(const re of pe)re.leadFirstId&&Oe.set(re.leadFirstId,re.page);return{pages:pe,mergedOwner:ce,pageStarts:Oe}},[n,e,A,w]),se=oe.pages,Y=f.useRef(se);Y.current=se;const de=f.useMemo(()=>se.map(V=>V.paragraphs.reduce((M,J)=>M+J.chars.length,0)),[se]),ne=f.useCallback((V,M)=>{let J=V,Se=0;for(;J<de.length&&(J===V||Se+de[J]<=M);)Se+=de[J++];return J},[de]),ue=`${se.length}:${((Le=(be=(fe=se[0])==null?void 0:fe.paragraphs[0])==null?void 0:be.chars[0])==null?void 0:Le.charData.id)??""}`,[ke,Ae]=f.useState(()=>({sig:ue,n:ne(0,Ya)}));let he=ke.n;ke.sig!==ue&&(he=ne(0,Ya),Ae({sig:ue,n:he})),he=Math.min(he,se.length);const $e=he>=se.length;f.useEffect(()=>$e?void 0:(M=>{const J=window;if(J.requestIdleCallback){const F=J.requestIdleCallback(M,{timeout:300});return()=>{var pe;return(pe=J.cancelIdleCallback)==null?void 0:pe.call(J,F)}}const Se=setTimeout(M,16);return()=>clearTimeout(Se)})(()=>Ae(M=>M.sig===ue?{sig:M.sig,n:Math.max(M.n,ne(M.n,Px))}:M)),[$e,he,ue,ne]);const L=f.useCallback(V=>{const M=Y.current.findIndex(Se=>Se.page>=V),J=(M<0?Y.current.length:M)+2;Ae(Se=>Se.n>=J?Se:{...Se,n:J})},[]),Me=$e?se:se.slice(0,he);f.useEffect(()=>{let V;const M=requestAnimationFrame(()=>{V=setTimeout(()=>{const J=B.current,Se=J==null?void 0:J.querySelector(".guji-reflow-paragraph");if(!J||!Se)return;const F=getComputedStyle(Se),pe=parseFloat(F.fontSize),ce=Se.clientWidth;if(!(pe>0)||!(ce>0))return;const Oe=parseFloat(F.lineHeight);J.style.setProperty("--gtv-cpl",String(Math.max(8,Math.floor(ce/pe)))),J.style.setProperty("--gtv-lh",`${Math.round(Oe>0?Oe:pe*2)}px`)},0)});return()=>{cancelAnimationFrame(M),V&&clearTimeout(V)}},[ue]);const q=f.useMemo(()=>{const V=[];for(const M of se)for(const J of M.paragraphs)for(const Se of J.chars)V.push(Se.charData.id);return V},[se]),le=f.useMemo(()=>{const V=new Map;if(!j||j.length===0)return V;const M=new Map(q.map((J,Se)=>[J,Se]));for(const J of j){if(!J.anchor)continue;const Se=M.get(J.anchor.start),F=M.get(J.anchor.end);if(!(Se===void 0||F===void 0||F<Se))for(let pe=Se;pe<=F;pe++)V.has(q[pe])||V.set(q[pe],J)}return V},[j,q]),ge=ss(b,$),H=le.size>0,Z=f.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:g,onEntityNavigate:k,onVisibleHeadingChange:x,onFigureBlockClick:I});Z.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:g,onEntityNavigate:k,onVisibleHeadingChange:x,onFigureBlockClick:I};const Ne=f.useMemo(()=>({click:V=>{var M,J;O.current=Date.now()+1200,(J=(M=Z.current).onCharClick)==null||J.call(M,V)},enter:V=>{var M,J;return(J=(M=Z.current).onCharHover)==null?void 0:J.call(M,V)},leave:()=>{var V,M;return(M=(V=Z.current).onCharHover)==null?void 0:M.call(V,null)},figBlock:V=>{var M,J;return(J=(M=Z.current).onFigureBlockClick)==null?void 0:J.call(M,V)},navigate:(V,M)=>{M.ctrlKey||M.metaKey||M.shiftKey||(M.preventDefault(),M.detail===0&&window.open(M.currentTarget.href,"_blank","noopener"))}}),[]),ze=Fx(o,oe.mergedOwner),Fe=f.useRef(he);Fe.current=he;const P=f.useRef(null),ie=f.useCallback(V=>{const M=P.current,J=M==null?void 0:M.map.get(V);if(J&&J.isConnected)return J;if(M&&M.for===Y.current&&M.n===Fe.current&&!J)return null;const Se=B.current;if(!Se)return null;const F=new Map;return Se.querySelectorAll("span[data-char-id]").forEach(pe=>{F.set(pe.getAttribute("data-char-id"),pe)}),P.current={for:Y.current,n:Fe.current,map:F},F.get(V)??null},[]),Q=f.useRef(null);f.useEffect(()=>{var M;if((M=Q.current)==null||M.classList.remove("is-hovered"),Q.current=null,!s)return;const V=ie(s);V&&(V.classList.add("is-hovered"),Q.current=V)},[s,ie]);const X=f.useRef(null),we=V=>{var J;const M=V instanceof Element?V.closest("span[data-char-id]"):null;return M&&((J=B.current)!=null&&J.contains(M))?M.getAttribute("data-char-id"):null},He=V=>{const M=we(V.target);M&&Ne.click(M)},Ke=V=>{const M=we(V.target);M!==X.current&&(X.current=M,M?Ne.enter(M):Ne.leave())},Qe=V=>{const M=typeof window<"u"?window.getSelection():null;if(!M||M.isCollapsed||M.rangeCount===0)return;const J=Ex(M.getRangeAt(0));J!==null&&(V.clipboardData.setData("text/plain",J),V.preventDefault())},U=()=>{X.current!==null&&(X.current=null,Ne.leave())};f.useEffect(()=>{let V=null;const M=()=>{var Ze,tt;V=null;const Se=window.getSelection(),F=B.current;if(!Se||Se.isCollapsed||Se.rangeCount===0||!F)return;const pe=Se.getRangeAt(0),ce=pe.commonAncestorContainer,Oe=ce.nodeType===3?ce.parentElement:ce;if(!Oe||!F.contains(Oe))return;const Ce=F.querySelectorAll("span[data-char-id]"),re=Ve=>{let ut=Ve;for(;ut.nodeType!==3&&ut.firstChild;)ut=ut.firstChild;return ut};let ye=0,ve=Ce.length;for(;ye<ve;){const Ve=ye+ve>>1;pe.comparePoint(re(Ce[Ve]),0)<0?ye=Ve+1:ve=Ve}const Pe=ye;for(ve=Ce.length;ye<ve;){const Ve=ye+ve>>1;pe.comparePoint(re(Ce[Ve]),0)<=0?ye=Ve+1:ve=Ve}let xe=ye-1;if(xe>=Pe&&pe.endOffset===0&&pe.endContainer===re(Ce[xe])&&xe--,xe<Pe)return;const Te=[];for(let Ve=Pe;Ve<=xe;Ve++)Te.push(Ce[Ve].getAttribute("data-char-id"));Te.length>0&&(O.current=Date.now()+1200,(tt=(Ze=Z.current).onSelectionChange)==null||tt.call(Ze,Te))},J=()=>{V&&clearTimeout(V),V=setTimeout(M,120)};return document.addEventListener("selectionchange",J),()=>{document.removeEventListener("selectionchange",J),V&&clearTimeout(V)}},[]);const me=f.useRef(null);f.useEffect(()=>{if(o.size!==1||me.current===o)return;const V=Array.from(o)[0],M=ie(V);if(M)me.current=o,M.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const J=parseInt(V.split(":")[0],10);isNaN(J)||L(J)}},[o,he,ie,L]);const Re=V=>{var Se;const M=B.current;if(!M)return null;const J=(Se=se.find(F=>F.page===V))==null?void 0:Se.leadFirstId;return J?M.querySelector(`span[data-char-id="${J}"]`):M.querySelector(`[data-page-section="${V}"]`)},D=u==null?void 0:u.nonce,je=f.useRef(null);f.useEffect(()=>{if(!u||je.current===u.nonce)return;const V=Re(u.page);if(!V){!$e&&se.some(M=>M.page>=u.page)&&L(u.page);return}je.current=u.nonce,O.current=Date.now()+800,V.scrollIntoView({behavior:"auto",block:"start"})},[D,he]);const te=f.useRef(null);f.useEffect(()=>{var F,pe;if(!h||te.current===h.nonce)return;const V=B.current,M=V==null?void 0:V.querySelector(`span[data-char-id="${Ux(h.anchor)}"]`);if(!M){const ce=parseInt(h.anchor.split(":")[0],10);!$e&&!isNaN(ce)&&L(ce);return}te.current=h.nonce;const J=M.closest(".guji-reflow-paragraph")??M;O.current=Date.now()+800,J.scrollIntoView({behavior:"auto",block:"start"});const Se=parseInt(h.anchor.split(":")[0],10);isNaN(Se)||(pe=(F=Z.current).onVisiblePageChange)==null||pe.call(F,Se)},[h,se,he,$e,L]);const _e=!!g||!!x,Be=!!g&&typeof v=="number",[Ge,Ye]=f.useState(null),it=ao(Ge??v??0),st=f.useRef(null);st.current=Be?it:null;const T=f.useRef(()=>{});return f.useEffect(()=>{var ve,Pe;if(!_e)return;const V=new Map,M=new Map;(ve=B.current)==null||ve.querySelectorAll("[data-page-section],[data-page-start]").forEach(xe=>{const Te=xe.getAttribute("data-page-section");Te!==null?V.set(Te,xe):M.set(xe.getAttribute("data-page-start"),xe)});const J=[],Se=[];for(const xe of Me){const Te=V.get(String(xe.page));Te&&(J.push(Te),Se.push(xe.page))}if(J.length===0)return;const F=new Map(J.map((xe,Te)=>[xe,Te])),pe=J.map(()=>[]);let ce=0;(Pe=B.current)==null||Pe.querySelectorAll('.guji-reflow-heading:not([data-heading-toc="0"])').forEach(xe=>{const Te=F.get(xe.closest("[data-page-section]"));Te!==void 0&&(pe[Te].push(xe),ce++)});let Oe,Ce=0;const re=()=>{var qe,ct;if(Ce=0,Date.now()<O.current)return;const xe=K=>K.getBoundingClientRect().top;if(J.length>1&&xe(J[0])===xe(J[J.length-1]))return;const Te=st.current===null?120:st.current*window.innerHeight;let Ze=0,tt=J.length-1;for(;Ze<tt;){const K=Ze+tt+1>>1;xe(J[K])<=Te?Ze=K:tt=K-1}const Ve=xe(J[0])>Te;let ut=Se[Ze];for(let K=Ze+1;K<J.length;K++){const De=M.get(String(Se[K]));if(!De||!J[Ze].contains(De)||xe(De)>Te)break;ut=Se[K]}if(ce>0&&Z.current.onVisibleHeadingChange){let K=null;if(!Ve){const et=pe[Ze];for(let nt=et.length-1;nt>=0&&!K;nt--)xe(et[nt])<=Te&&(K=et[nt]);for(let nt=Ze-1;nt>=0&&!K;nt--)pe[nt].length>0&&(K=pe[nt][pe[nt].length-1])}const De=K?Dx(K):null;De!==Oe&&(Oe=De,Z.current.onVisibleHeadingChange(De))}(ct=(qe=Z.current).onVisiblePageChange)==null||ct.call(qe,ut)},ye=()=>{Ce||(Ce=requestAnimationFrame(re))};return T.current=()=>{Ce||(Ce=requestAnimationFrame(re))},window.addEventListener("scroll",ye,{passive:!0}),ye(),()=>{window.removeEventListener("scroll",ye),Ce&&cancelAnimationFrame(Ce),T.current=()=>{}}},[_e,se,he]),f.useEffect(()=>{Be&&T.current()},[Be,it]),t.jsxs("div",{ref:B,className:"guji-text-pane-content",onClick:He,onMouseOver:Ke,onMouseLeave:U,onCopy:Qe,children:[H&&t.jsx("style",{children:os}),Be&&t.jsx(Xx,{y:it,containerRef:B,onDrag:Ye,onCommit:V=>{Ye(null),C==null||C(V)}}),t.jsx("div",{className:"guji-text-reflow-view",children:Me.map((V,M)=>t.jsx(Yx,{pGroup:V,first:M===0,pageBreaks:w,markOpts:W,plainBooks:G,selected:ze.get(V.page)??Ox,entityOfChar:le,entityLoader:ge,convert:m,buildHref:y??Lx,handlers:Ne,charCount:de[M]??0,pageStarts:oe.pageStarts,figures:z,figUrl:N},`page-sec-${V.page}`))})]})},Ya=1800,Px=800,Bx="auto calc((var(--gtv-pc) / var(--gtv-cpl, 30) + var(--gtv-pp) * 1.4) * var(--gtv-lh, 44px) + 64px)",Ox=new Set,so=[],Wx={before:so,after:so};function Fx(e,n){const i=f.useRef(new Map);return f.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function Hx(e){return e==null?void 0:e.find(n=>n.kind==="heading"&&/^#{1,6}$/.test(n.mark))}function Dx(e){return e.getAttribute("data-heading-anchor")}function Ux(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function Ka({n:e}){return t.jsx(t.Fragment,{children:Array.from({length:e},(n,i)=>t.jsx("span",{className:"guji-text-blank-col","aria-hidden":"true","data-blank-col":""},i))})}function Vx(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}function Gx({heading:e,children:n}){if(!e)return t.jsx("p",{className:"guji-reflow-paragraph",children:n});const i=`h${Math.min(6,e.level+1)}`;return t.jsx(i,{className:`guji-reflow-paragraph guji-reflow-heading guji-reflow-h${e.level}`,"data-heading-anchor":e.anchor,"data-heading-level":e.level,"data-heading-toc":e.toc===!1?"0":void 0,children:n})}const Yx=f.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:g,handlers:m,charCount:u,pageStarts:h,figures:x,figUrl:j}){const b=f.useMemo(()=>{const v=new Map;if(!p)return v;for(const C of n.paragraphs){const S=Vx(C.chars.map(_=>_.charData.fig?_.charData.char:_.charData.norm??_.charData.char),p);C.chars.forEach((_,R)=>v.set(_.charData.id,_.charData.fig?_.charData.char:S[R]))}return v},[n,p]),$=v=>b.get(v.id)??v.char,{t:y}=ae(),k=v=>{const C=s?gd(v.mark,s):v.mark;return C?t.jsx("span",{className:"guji-text-punct","data-punct-id":v.id,children:C},v.id):null},w=v=>{var C;return(C=n.blocks)==null?void 0:C.map((S,_)=>S.before===v&&t.jsx(Rx,{fig:S.fig,info:x==null?void 0:x.get(S.fig),figUrl:j,onClick:()=>m.figBlock({page:n.page,fig:S.fig,...S.box?{box:S.box}:{}})},`fig-${S.fig}-${_}`))};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96,contentVisibility:"auto",containIntrinsicSize:Bx,"--gtv-pc":u,"--gtv-pp":n.paragraphs.length},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((v,C)=>t.jsxs(f.Fragment,{children:[w(C),t.jsxs(Gx,{heading:v.heading,children:[Mx(v.chars,d).map((S,_)=>{const R=S.chars.map(({charData:I,beforePuncts:B,afterPuncts:O,start:A},W)=>{var ke;const G=!!S.entity&&W===0,oe=!!S.entity&&W===S.chars.length-1,se=G?[]:B,Y=oe?[]:O,de=!!I.fig&&W>0&&S.chars[W-1].charData.fig===I.fig;let ne=1;if(I.fig&&!de)for(;((ke=S.chars[W+ne])==null?void 0:ke.charData.fig)===I.fig;)ne++;const ue=`guji-text-char${l.has(I.id)?" is-selected":""}${I.sub?" is-sub":""}${I.lane==="solo"?" is-solo":""}${A!=null&&A.raised?" is-raised":""}`;return t.jsxs(f.Fragment,{children:[A&&A.blankBefore>0&&t.jsx(Ka,{n:A.blankBefore}),se.map(k),I.fig?t.jsx(Tx,{id:I.id,fig:I.fig,info:x==null?void 0:x.get(I.fig),figUrl:j,cells:ne,cont:de,className:ue,pageStart:h.get(I.id),children:$(I)}):t.jsx("span",{"data-char-id":I.id,"data-page-start":h.get(I.id),className:`guji-text-char${l.has(I.id)?" is-selected":""}${I.sub?" is-sub":""}${I.lane==="solo"?" is-solo":""}${I.lacuna?" is-lacuna":""}${I.lacuna&&I.guess_c?" has-guess":""}${I.guess?" is-guess":""}${I.zi?" is-zi":""}${A!=null&&A.raised?" is-raised":""}`,"data-raised":(A==null?void 0:A.raised)||void 0,"data-guji-guess":I.lacuna&&I.guess_c?I.guess_c:void 0,title:I.lacuna?I.guess_c?y("reader.lacunaGuess",{guess:p?p(I.guess_c):I.guess_c}):y("detail.lacuna"):I.zi?y("detail.composedChar",{label:I.zi}):I.guess?y("reader.charGuess"):void 0,children:$(I)}),Y.map(k)]},I.id)});if(!S.entity)return t.jsx(f.Fragment,{children:R},`r${_}`);const z=S.chars[0].beforePuncts.map(k),N=S.chars[S.chars.length-1].afterPuncts.map(k);return t.jsxs(f.Fragment,{children:[z,t.jsx(as,{span:S.entity,label:S.chars.map(I=>$(I.charData)).join(""),hasBrackets:!0,plain:a&&S.entity.kind==="work",loader:c,buildHref:g,onNavigate:m.navigate,cardNewTab:!0,renderText:()=>R,hoverDelayMs:250}),N]},`${S.entity.key}@${_}`)}),C===n.paragraphs.length-1&&n.trailingBlank?t.jsx(Ka,{n:n.trailingBlank}):null]})]},v.id)),w(n.paragraphs.length)]})});function ao(e){const[n,i]=Qn,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const Kx=.02,yn=16,qx=4;function Xx({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ae(),[a,l]=f.useState(0),d=f.useRef(!1),c=f.useRef(null),p=f.useRef(e);p.current=e;const g=f.useCallback(()=>{var j;const u=((j=c.current)==null?void 0:j.parentElement)??n.current,h=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=h==null?void 0:h.getBoundingClientRect();l(Math.max(0,((x==null?void 0:x.left)??0)-yn-qx))},[n]);f.useLayoutEffect(()=>{var j;window.addEventListener("resize",g);const u=((j=c.current)==null?void 0:j.parentElement)??n.current,h=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=typeof ResizeObserver<"u"?new ResizeObserver(()=>g()):null;for(const b of[h,u==null?void 0:u.closest(".bim-rd-text"),u==null?void 0:u.closest(".bim-rd-body")])b&&(x==null||x.observe(b));return x||g(),()=>{window.removeEventListener("resize",g),x==null||x.disconnect()}},[g,n]);const m=u=>ao(u/Math.max(1,window.innerHeight));return t.jsx("div",{ref:c,role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(Qn[0]*100),"aria-valuemax":Math.round(Qn[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${yn/2}px)`,width:yn,height:yn,zIndex:20,cursor:"ns-resize",touchAction:"none",display:"flex",alignItems:"center",justifyContent:"center",color:r("meta-fg")},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const h=m(u.clientY);p.current=h,i(h)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(m(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(p.current))},onKeyDown:u=>{const h=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;h&&(u.preventDefault(),o(ao(e+h*(u.shiftKey?5:1)*Kx)))},children:t.jsx("svg",{width:yn,height:yn,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M2 8h11M9 4l4 4-4 4"})})})}const Id=1,Ed=6,ki={s:1,x:0,y:0},zi=(e,n,i)=>Math.min(i,Math.max(n,e));function ds(e,n,i){const o=zi(e.s,Id,Ed);return{s:o,x:zi(e.x,n*(1-o),0),y:zi(e.y,i*(1-o),0)}}function Er(e,n,i,o,s,a){const l=zi(e.s*o,Id,Ed),d=l/e.s;return ds({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function Zx(e,n,i,o,s){return ds({s:e.s,x:e.x+n,y:e.y+i},o,s)}function Jx(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const qa=4,Qx=f.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=f.useRef(null),[d,c]=f.useState(ki),p=f.useRef(d),g=f.useRef(i);g.current=i;const m=y=>{var w;const k=p.current;p.current=y,c(y),y.s!==k.s&&((w=g.current)==null||w.call(g,y.s))},u=()=>{var k;const y=(k=l.current)==null?void 0:k.getBoundingClientRect();return{w:(y==null?void 0:y.width)??0,h:(y==null?void 0:y.height)??0,left:(y==null?void 0:y.left)??0,top:(y==null?void 0:y.top)??0}};f.useImperativeHandle(a,()=>({zoomBy(y){const{w:k,h:w}=u();m(Er(p.current,k/2,w/2,y,k,w))},reset(){m(ki)}})),f.useEffect(()=>{m(ki)},[o]),f.useEffect(()=>{const y=l.current;if(!y||typeof ResizeObserver>"u")return;const k=new ResizeObserver(()=>{const{w,h:v}=u(),C=ds(p.current,w,v);(C.x!==p.current.x||C.y!==p.current.y)&&m(C)});return k.observe(y),()=>k.disconnect()},[]),f.useEffect(()=>{const y=l.current;if(!y)return;const k=w=>{const v=Jx(w.deltaY,w.deltaMode,w.ctrlKey);if(p.current.s<=1&&v<1)return;w.preventDefault();const{w:C,h:S,left:_,top:R}=u();m(Er(p.current,w.clientX-_,w.clientY-R,v,C,S))};return y.addEventListener("wheel",k,{passive:!1}),()=>y.removeEventListener("wheel",k)},[]);const h=f.useRef(new Map),x=f.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),j=y=>{if(y.pointerType==="mouse"&&y.button!==0)return;h.current.set(y.pointerId,{x:y.clientX,y:y.clientY});const k=x.current;if(k.swallowClick=!1,h.current.size===1&&(k.moved=0,k.dragging=!1),h.current.size===2){const[w,v]=[...h.current.values()];k.pinchDist=Math.hypot(w.x-v.x,w.y-v.y),k.moved=qa+1}},b=y=>{var I;const k=h.current.get(y.pointerId);if(!k)return;const w={x:y.clientX,y:y.clientY};h.current.set(y.pointerId,w);const v=x.current,{w:C,h:S,left:_,top:R}=u();if(h.current.size>=2){const[B,O]=[...h.current.values()],A=Math.hypot(B.x-O.x,B.y-O.y);if(v.pinchDist>0&&A>0){const W=(B.x+O.x)/2-_,G=(B.y+O.y)/2-R;m(Er(p.current,W,G,A/v.pinchDist,C,S))}v.pinchDist=A,v.swallowClick=!0;return}const z=w.x-k.x,N=w.y-k.y;if(v.moved+=Math.abs(z)+Math.abs(N),!(v.moved<=qa)){if(!v.dragging){v.dragging=!0;try{(I=l.current)==null||I.setPointerCapture(y.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&m(Zx(p.current,z,N,C,S))}},$=y=>{h.current.delete(y.pointerId);const k=x.current;k.pinchDist=0,h.current.size===0&&(k.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:j,onPointerMove:b,onPointerUp:$,onPointerCancel:$,onClickCapture:y=>{x.current.swallowClick&&(x.current.swallowClick=!1,y.stopPropagation(),y.preventDefault())},onDoubleClick:()=>m(ki),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 Ld(e,n,i,o,s=""){const a=`${s}
|
|
1468
|
+
`)},s=a=>{if(a.nodeType===3){i+=a.nodeValue??"";return}if(!(a.nodeType!==1&&a.nodeType!==11)){if(a.nodeType===1){const l=a;if(l.classList.contains("guji-page-divider")||l.style.userSelect==="none")return;const d=l.getAttribute("data-fig-copy");if(d!==null){l.tagName==="FIGURE"?(o(),i+=d,o()):i+=d;return}const c=Ax.has(l.tagName);c&&o(),l.childNodes.forEach(s),c&&o();return}a.childNodes.forEach(s)}};return s(n),i.replace(/\n+$/,"")}const Px=e=>`/item/${encodeURIComponent(e)}`;function Bx(e){const n=e.filter(i=>i.kind==null||i.kind==="point");return{before:n.filter(i=>i.pos==="before"),after:n.filter(i=>i.pos!=="before")}}function Ox(e,n){const i=[];for(const o of e){const s=n.get(o.charData.id)??null,a=i[i.length-1];a&&a.entity===s?a.chars.push(o):i.push({entity:s,chars:[o]})}return i}const us=({pageData:e,pages:n,punctuations:i=lo,selectedCharIds:o,hoveredCharId:s,onSelectionChange:a,onCharClick:l,onCharHover:d,mode:c="horizontal",showPunctuation:p=!0,onVisiblePageChange:g,convert:m,scrollToPage:u,scrollToAnchor:h,onVisibleHeadingChange:x,entities:j,entityTransport:b,loadEntitySummary:S,buildEntityHref:y,onEntityNavigate:k,pageBreaks:w=!0,pageIndicatorY:v,onPageIndicatorYChange:C,quoteStyle:_,bookTitleStyle:$,showWorks:A,figures:R,figUrl:z,onFigureBlockClick:N})=>{var fe,xe,ze;const M=f.useRef(null),O=f.useRef(0),L=f.useMemo(()=>{const V=new Map;return p&&i.forEach((P,X)=>{const je=P.id?P:{...P,id:`${P.anchor}#${X}`},Y=V.get(je.anchor)||[];Y.push(je),V.set(je.anchor,Y)}),V},[i,p]),D=f.useMemo(()=>_===void 0&&$===void 0&&A===void 0?null:{quoteStyle:_??"original",hideBookBrackets:$==="wavy"||A===!1},[_,$,A]),q=$==="bracket",J=f.useMemo(()=>{var ne;const V=n&&n.length>0?n:[{page:parseInt(e.page_id.split(":")[1]||"1",10),columns:e.columns}],P=new Map;for(const re of V)for(const ve of re.columns)ve.chars.length>0&&!ve.raised&&P.set(ve.lead_blank||0,(P.get(ve.lead_blank||0)||0)+1);let X=0,je=-1;for(const[re,ve]of P)(ve>je||ve===je&&re<X)&&(X=re,je=ve);const Y=re=>!!re.raised||(re.lead_blank||0)<X,me=V.filter(re=>re.columns.some(ve=>ve.chars.length>0||ve.kind==="figure")).map(re=>{const ve=[...re.columns].sort((qe,jt)=>qe.col-jt.col),ke=[];let Ue=[];const we=()=>{const qe=Vx(L.get(Ue[0].charData.id));ke.push({id:`para-p${re.page}-${ke.length}`,chars:Ue,...qe?{heading:{level:qe.mark.length,anchor:Ue[0].charData.id,...qe.toc===!1?{toc:!1}:{}}}:{}}),Ue=[]};let Ee=!1,He=0,Ye;const Xe=[];for(const qe of ve){if(qe.kind==="figure"&&qe.fig){Ue.length>0?we():ke.length===0&&(Ee=!0),Xe.push({before:ke.length,fig:qe.fig,...qe.figBox?{box:qe.figBox}:{}}),He=0;continue}if(qe.chars.length===0){qe.kind==="blank"&&He++;continue}const jt=qe.raised||qe.lead_blank||He?{raised:qe.raised,leadBlank:qe.lead_blank,blankBefore:He}:void 0;He=0,Y(qe)||(Ye=qe.lead_blank||0);let tt=!0;for(const ct of qe.chars){const Q=L.get(ct.id),{before:De,after:dt}=Q?Bx(Q):Dx,xt=!!Q&&Q.some(mt=>mt.kind==="break"&&mt.pos!=="before");Q&&Q.some(mt=>mt.kind==="heading")&&(Ue.length>0?we():ke.length===0&&(Ee=!0)),Ue.push({charData:ct,col:qe.col,beforePuncts:De,afterPuncts:dt,...tt&&jt?{start:jt}:{}}),tt=!1,xt&&we()}}const at=Ue.length>0;return at&&we(),{page:re.page,paragraphs:ke,endsOpen:at,...Ye!==void 0?{tailLead:Ye}:{},...Ee?{leadStarts:Ee}:{},...re.label?{label:re.label}:{},...He>0?{trailingBlank:He}:{},...Xe.length>0?{blocks:Xe}:{}}}),_e=new Map;if(!w){let re=null;for(const ve of me){const ke=ve.paragraphs[0],Ue=(ne=ke==null?void 0:ke.chars[0])==null?void 0:ne.start,we=(Ue==null?void 0:Ue.leadBlank)||0,Ee=!!Ue&&!Ue.raised&&we>=X&&we>((re==null?void 0:re.tailLead)??X),He=!!ve.leadStarts||!!(Ue!=null&&Ue.blankBefore)||Ee,Ye=ve.paragraphs.length===1&&!!ve.trailingBlank;if(re&&ke&&!He&&!Ye){for(const Xe of ke.chars)_e.set(Xe.charData.id,re.owner);re.para.chars=re.para.chars.concat(ke.chars),ve.leadFirstId=ke.chars[0].charData.id,ve.paragraphs=ve.paragraphs.slice(1),ve.blocks&&(ve.blocks=ve.blocks.map(Xe=>({...Xe,before:Xe.before-1})))}if(ve.endsOpen&&!ve.trailingBlank){const Xe=ve.paragraphs[ve.paragraphs.length-1];Xe?re={para:Xe,owner:ve.page,tailLead:ve.tailLead??(re==null?void 0:re.tailLead)??X}:re&&ve.tailLead!==void 0&&(re.tailLead=ve.tailLead)}else re=null}}const Pe=new Map;for(const re of me)re.leadFirstId&&Pe.set(re.leadFirstId,re.page);return{pages:me,mergedOwner:_e,pageStarts:Pe}},[n,e,L,w]),se=J.pages,U=f.useRef(se);U.current=se;const K=f.useMemo(()=>se.map(V=>V.paragraphs.reduce((P,X)=>P+X.chars.length,0)),[se]),Z=f.useCallback((V,P)=>{let X=V,je=0;for(;X<K.length&&(X===V||je+K[X]<=P);)je+=K[X++];return X},[K]),oe=`${se.length}:${((ze=(xe=(fe=se[0])==null?void 0:fe.paragraphs[0])==null?void 0:xe.chars[0])==null?void 0:ze.charData.id)??""}`,[ye,Le]=f.useState(()=>({sig:oe,n:Z(0,Xa)}));let Me=ye.n;ye.sig!==oe&&(Me=Z(0,Xa),Le({sig:oe,n:Me})),Me=Math.min(Me,se.length);const Se=Me>=se.length;f.useEffect(()=>Se?void 0:(P=>{const X=window;if(X.requestIdleCallback){const Y=X.requestIdleCallback(P,{timeout:300});return()=>{var me;return(me=X.cancelIdleCallback)==null?void 0:me.call(X,Y)}}const je=setTimeout(P,16);return()=>clearTimeout(je)})(()=>Le(P=>P.sig===oe?{sig:P.sig,n:Math.max(P.n,Z(P.n,Wx))}:P)),[Se,Me,oe,Z]);const le=f.useCallback(V=>{const P=U.current.findIndex(je=>je.page>=V),X=(P<0?U.current.length:P)+2;Le(je=>je.n>=X?je:{...je,n:X})},[]),Oe=Se?se:se.slice(0,Me);f.useEffect(()=>{let V;const P=requestAnimationFrame(()=>{V=setTimeout(()=>{const X=M.current,je=X==null?void 0:X.querySelector(".guji-reflow-paragraph");if(!X||!je)return;const Y=getComputedStyle(je),me=parseFloat(Y.fontSize),_e=je.clientWidth;if(!(me>0)||!(_e>0))return;const Pe=parseFloat(Y.lineHeight);X.style.setProperty("--gtv-cpl",String(Math.max(8,Math.floor(_e/me)))),X.style.setProperty("--gtv-lh",`${Math.round(Pe>0?Pe:me*2)}px`)},0)});return()=>{cancelAnimationFrame(P),V&&clearTimeout(V)}},[oe]);const T=f.useMemo(()=>{const V=[];for(const P of se)for(const X of P.paragraphs)for(const je of X.chars)V.push(je.charData.id);return V},[se]),de=f.useMemo(()=>{const V=new Map;if(!j||j.length===0)return V;const P=new Map(T.map((X,je)=>[X,je]));for(const X of j){if(!X.anchor)continue;const je=P.get(X.anchor.start),Y=P.get(X.anchor.end);if(!(je===void 0||Y===void 0||Y<je))for(let me=je;me<=Y;me++)V.has(T[me])||V.set(T[me],X)}return V},[j,T]),pe=cs(b,S),B=de.size>0,ee=f.useRef({onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:g,onEntityNavigate:k,onVisibleHeadingChange:x,onFigureBlockClick:N});ee.current={onCharClick:l,onCharHover:d,onSelectionChange:a,onVisiblePageChange:g,onEntityNavigate:k,onVisibleHeadingChange:x,onFigureBlockClick:N};const Ce=f.useMemo(()=>({click:V=>{var P,X;O.current=Date.now()+1200,(X=(P=ee.current).onCharClick)==null||X.call(P,V)},enter:V=>{var P,X;return(X=(P=ee.current).onCharHover)==null?void 0:X.call(P,V)},leave:()=>{var V,P;return(P=(V=ee.current).onCharHover)==null?void 0:P.call(V,null)},figBlock:V=>{var P,X;return(X=(P=ee.current).onFigureBlockClick)==null?void 0:X.call(P,V)},navigate:(V,P)=>{P.ctrlKey||P.metaKey||P.shiftKey||(P.preventDefault(),P.detail===0&&window.open(P.currentTarget.href,"_blank","noopener"))}}),[]),Ie=Ux(o,J.mergedOwner),We=f.useRef(Me);We.current=Me;const G=f.useRef(null),he=f.useCallback(V=>{const P=G.current,X=P==null?void 0:P.map.get(V);if(X&&X.isConnected)return X;if(P&&P.for===U.current&&P.n===We.current&&!X)return null;const je=M.current;if(!je)return null;const Y=new Map;return je.querySelectorAll("span[data-char-id]").forEach(me=>{Y.set(me.getAttribute("data-char-id"),me)}),G.current={for:U.current,n:We.current,map:Y},Y.get(V)??null},[]),te=f.useRef(null);f.useEffect(()=>{var P;if((P=te.current)==null||P.classList.remove("is-hovered"),te.current=null,!s)return;const V=he(s);V&&(V.classList.add("is-hovered"),te.current=V)},[s,he]);const H=f.useRef(null),ue=V=>{var X;const P=V instanceof Element?V.closest("span[data-char-id]"):null;return P&&((X=M.current)!=null&&X.contains(P))?P.getAttribute("data-char-id"):null},Fe=V=>{const P=ue(V.target);P&&Ce.click(P)},Ge=V=>{const P=ue(V.target);P!==H.current&&(H.current=P,P?Ce.enter(P):Ce.leave())},Je=V=>{const P=typeof window<"u"?window.getSelection():null;if(!P||P.isCollapsed||P.rangeCount===0)return;const X=Mx(P.getRangeAt(0));X!==null&&(V.clipboardData.setData("text/plain",X),V.preventDefault())},F=()=>{H.current!==null&&(H.current=null,Ce.leave())};f.useEffect(()=>{let V=null;const P=()=>{var He,Ye;V=null;const je=window.getSelection(),Y=M.current;if(!je||je.isCollapsed||je.rangeCount===0||!Y)return;const me=je.getRangeAt(0),_e=me.commonAncestorContainer,Pe=_e.nodeType===3?_e.parentElement:_e;if(!Pe||!Y.contains(Pe))return;const ne=Y.querySelectorAll("span[data-char-id]"),re=Xe=>{let at=Xe;for(;at.nodeType!==3&&at.firstChild;)at=at.firstChild;return at};let ve=0,ke=ne.length;for(;ve<ke;){const Xe=ve+ke>>1;me.comparePoint(re(ne[Xe]),0)<0?ve=Xe+1:ke=Xe}const Ue=ve;for(ke=ne.length;ve<ke;){const Xe=ve+ke>>1;me.comparePoint(re(ne[Xe]),0)<=0?ve=Xe+1:ke=Xe}let we=ve-1;if(we>=Ue&&me.endOffset===0&&me.endContainer===re(ne[we])&&we--,we<Ue)return;const Ee=[];for(let Xe=Ue;Xe<=we;Xe++)Ee.push(ne[Xe].getAttribute("data-char-id"));Ee.length>0&&(O.current=Date.now()+1200,(Ye=(He=ee.current).onSelectionChange)==null||Ye.call(He,Ee))},X=()=>{V&&clearTimeout(V),V=setTimeout(P,120)};return document.addEventListener("selectionchange",X),()=>{document.removeEventListener("selectionchange",X),V&&clearTimeout(V)}},[]);const ge=f.useRef(null);f.useEffect(()=>{if(o.size!==1||ge.current===o)return;const V=Array.from(o)[0],P=he(V);if(P)ge.current=o,P.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"});else{const X=parseInt(V.split(":")[0],10);isNaN(X)||le(X)}},[o,Me,he,le]);const Ae=V=>{var je;const P=M.current;if(!P)return null;const X=(je=se.find(Y=>Y.page===V))==null?void 0:je.leadFirstId;return X?P.querySelector(`span[data-char-id="${X}"]`):P.querySelector(`[data-page-section="${V}"]`)},W=u==null?void 0:u.nonce,be=f.useRef(null);f.useEffect(()=>{if(!u||be.current===u.nonce)return;const V=Ae(u.page);if(!V){!Se&&se.some(P=>P.page>=u.page)&&le(u.page);return}be.current=u.nonce,O.current=Date.now()+800,V.scrollIntoView({behavior:"auto",block:"start"})},[W,Me]);const ce=f.useRef(null);f.useEffect(()=>{var Y,me;if(!h||ce.current===h.nonce)return;const V=M.current,P=V==null?void 0:V.querySelector(`span[data-char-id="${Yx(h.anchor)}"]`);if(!P){const _e=parseInt(h.anchor.split(":")[0],10);!Se&&!isNaN(_e)&&le(_e);return}ce.current=h.nonce;const X=P.closest(".guji-reflow-paragraph")??P;O.current=Date.now()+800,X.scrollIntoView({behavior:"auto",block:"start"});const je=parseInt(h.anchor.split(":")[0],10);isNaN(je)||(me=(Y=ee.current).onVisiblePageChange)==null||me.call(Y,je)},[h,se,Me,Se,le]);const Ne=!!g||!!x,$e=!!g&&typeof v=="number",[Ke,Qe]=f.useState(null),it=co(Ke??v??0),nt=f.useRef(null);nt.current=$e?it:null;const I=f.useRef(()=>{});return f.useEffect(()=>{var ke,Ue;if(!Ne)return;const V=new Map,P=new Map;(ke=M.current)==null||ke.querySelectorAll("[data-page-section],[data-page-start]").forEach(we=>{const Ee=we.getAttribute("data-page-section");Ee!==null?V.set(Ee,we):P.set(we.getAttribute("data-page-start"),we)});const X=[],je=[];for(const we of Oe){const Ee=V.get(String(we.page));Ee&&(X.push(Ee),je.push(we.page))}if(X.length===0)return;const Y=new Map(X.map((we,Ee)=>[we,Ee])),me=X.map(()=>[]);let _e=0;(Ue=M.current)==null||Ue.querySelectorAll('.guji-reflow-heading:not([data-heading-toc="0"])').forEach(we=>{const Ee=Y.get(we.closest("[data-page-section]"));Ee!==void 0&&(me[Ee].push(we),_e++)});let Pe,ne=0;const re=()=>{var qe,jt;if(ne=0,Date.now()<O.current)return;const we=tt=>tt.getBoundingClientRect().top;if(X.length>1&&we(X[0])===we(X[X.length-1]))return;const Ee=nt.current===null?120:nt.current*window.innerHeight;let He=0,Ye=X.length-1;for(;He<Ye;){const tt=He+Ye+1>>1;we(X[tt])<=Ee?He=tt:Ye=tt-1}const Xe=we(X[0])>Ee;let at=je[He];for(let tt=He+1;tt<X.length;tt++){const ct=P.get(String(je[tt]));if(!ct||!X[He].contains(ct)||we(ct)>Ee)break;at=je[tt]}if(_e>0&&ee.current.onVisibleHeadingChange){let tt=null;if(!Xe){const Q=me[He];for(let De=Q.length-1;De>=0&&!tt;De--)we(Q[De])<=Ee&&(tt=Q[De]);for(let De=He-1;De>=0&&!tt;De--)me[De].length>0&&(tt=me[De][me[De].length-1])}const ct=tt?Gx(tt):null;ct!==Pe&&(Pe=ct,ee.current.onVisibleHeadingChange(ct))}(jt=(qe=ee.current).onVisiblePageChange)==null||jt.call(qe,at)},ve=()=>{ne||(ne=requestAnimationFrame(re))};return I.current=()=>{ne||(ne=requestAnimationFrame(re))},window.addEventListener("scroll",ve,{passive:!0}),ve(),()=>{window.removeEventListener("scroll",ve),ne&&cancelAnimationFrame(ne),I.current=()=>{}}},[Ne,se,Me]),f.useEffect(()=>{$e&&I.current()},[$e,it]),t.jsxs("div",{ref:M,className:"guji-text-pane-content",onClick:Fe,onMouseOver:Ge,onMouseLeave:F,onCopy:Je,children:[B&&t.jsx("style",{children:as}),$e&&t.jsx(Qx,{y:it,containerRef:M,onDrag:Qe,onCommit:V=>{Qe(null),C==null||C(V)}}),t.jsx("div",{className:"guji-text-reflow-view",children:Oe.map((V,P)=>t.jsx(Xx,{pGroup:V,first:P===0,pageBreaks:w,markOpts:D,plainBooks:q,selected:Ie.get(V.page)??Hx,entityOfChar:de,entityLoader:pe,convert:m,buildHref:y??Px,handlers:Ce,charCount:K[P]??0,pageStarts:J.pageStarts,figures:R,figUrl:z},`page-sec-${V.page}`))})]})},Xa=1800,Wx=800,Fx="auto calc((var(--gtv-pc) / var(--gtv-cpl, 30) + var(--gtv-pp) * 1.4) * var(--gtv-lh, 44px) + 64px)",Hx=new Set,lo=[],Dx={before:lo,after:lo};function Ux(e,n){const i=f.useRef(new Map);return f.useMemo(()=>{const o=new Map;e.forEach(a=>{const l=n.get(a)??parseInt(a.split(":")[0],10);let d=o.get(l);d||o.set(l,d=new Set),d.add(a)});const s=new Map;return o.forEach((a,l)=>{const d=i.current.get(l),c=d&&d.size===a.size&&Array.from(a).every(p=>d.has(p));s.set(l,c?d:a)}),i.current=s,s},[e,n])}function Vx(e){return e==null?void 0:e.find(n=>n.kind==="heading"&&/^#{1,6}$/.test(n.mark))}function Gx(e){return e.getAttribute("data-heading-anchor")}function Yx(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function Za({n:e}){return t.jsx(t.Fragment,{children:Array.from({length:e},(n,i)=>t.jsx("span",{className:"guji-text-blank-col","aria-hidden":"true","data-blank-col":""},i))})}function Kx(e,n){const i=Array.from(n(e.join("")));return i.length===e.length&&e.every(o=>Array.from(o).length===1)?i:e.map(o=>n(o))}function qx({heading:e,children:n}){if(!e)return t.jsx("p",{className:"guji-reflow-paragraph",children:n});const i=`h${Math.min(6,e.level+1)}`;return t.jsx(i,{className:`guji-reflow-paragraph guji-reflow-heading guji-reflow-h${e.level}`,"data-heading-anchor":e.anchor,"data-heading-level":e.level,"data-heading-toc":e.toc===!1?"0":void 0,children:n})}const Xx=f.memo(function({pGroup:n,first:i,pageBreaks:o,markOpts:s,plainBooks:a,selected:l,entityOfChar:d,entityLoader:c,convert:p,buildHref:g,handlers:m,charCount:u,pageStarts:h,figures:x,figUrl:j}){const b=f.useMemo(()=>{const v=new Map;if(!p)return v;for(const C of n.paragraphs){const _=Kx(C.chars.map($=>$.charData.fig?$.charData.char:$.charData.norm??$.charData.char),p);C.chars.forEach(($,A)=>v.set($.charData.id,$.charData.fig?$.charData.char:_[A]))}return v},[n,p]),S=v=>b.get(v.id)??v.char,{t:y}=ae(),k=v=>{const C=s?xd(v.mark,s):v.mark;return C?t.jsx("span",{className:"guji-text-punct","data-punct-id":v.id,children:C},v.id):null},w=v=>{var C;return(C=n.blocks)==null?void 0:C.map((_,$)=>_.before===v&&t.jsx(Lx,{fig:_.fig,info:x==null?void 0:x.get(_.fig),figUrl:j,onClick:()=>m.figBlock({page:n.page,fig:_.fig,..._.box?{box:_.box}:{}})},`fig-${_.fig}-${$}`))};return t.jsxs("section",{"data-page-section":n.page,className:"guji-page-section",style:{position:"relative",scrollMarginTop:96,contentVisibility:"auto",containIntrinsicSize:Fx,"--gtv-pc":u,"--gtv-pp":n.paragraphs.length},children:[!i&&o&&t.jsxs("div",{className:"guji-page-divider",style:{display:"flex",alignItems:"center",margin:"2rem 0 1.2rem",color:r("meta-fg"),fontSize:"0.82rem",letterSpacing:"0.08em",userSelect:"none"},children:[t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}}),t.jsxs("span",{style:{padding:"0 12px",fontWeight:500},"data-page-label":n.label,title:n.label?`${n.page}`:void 0,children:["第 ",n.label??n.page," 葉"]}),t.jsx("div",{style:{flex:1,height:"1px",background:r("rule")}})]}),n.paragraphs.map((v,C)=>t.jsxs(f.Fragment,{children:[w(C),t.jsxs(qx,{heading:v.heading,children:[Ox(v.chars,d).map((_,$)=>{const A=_.chars.map(({charData:N,beforePuncts:M,afterPuncts:O,start:L},D)=>{var ye;const q=!!_.entity&&D===0,J=!!_.entity&&D===_.chars.length-1,se=q?[]:M,U=J?[]:O,K=!!N.fig&&D>0&&_.chars[D-1].charData.fig===N.fig;let Z=1;if(N.fig&&!K)for(;((ye=_.chars[D+Z])==null?void 0:ye.charData.fig)===N.fig;)Z++;const oe=`guji-text-char${l.has(N.id)?" is-selected":""}${N.sub?" is-sub":""}${N.lane==="solo"?" is-solo":""}${L!=null&&L.raised?" is-raised":""}`;return t.jsxs(f.Fragment,{children:[L&&L.blankBefore>0&&t.jsx(Za,{n:L.blankBefore}),se.map(k),N.fig?t.jsx(Ex,{id:N.id,fig:N.fig,info:x==null?void 0:x.get(N.fig),figUrl:j,cells:Z,cont:K,className:oe,pageStart:h.get(N.id),children:S(N)}):t.jsx("span",{"data-char-id":N.id,"data-page-start":h.get(N.id),className:`guji-text-char${l.has(N.id)?" is-selected":""}${N.sub?" is-sub":""}${N.lane==="solo"?" is-solo":""}${N.lacuna?" is-lacuna":""}${N.lacuna&&N.guess_c?" has-guess":""}${N.guess?" is-guess":""}${N.zi?" is-zi":""}${L!=null&&L.raised?" is-raised":""}`,"data-raised":(L==null?void 0:L.raised)||void 0,"data-guji-guess":N.lacuna&&N.guess_c?N.guess_c:void 0,title:N.lacuna?N.guess_c?y("reader.lacunaGuess",{guess:p?p(N.guess_c):N.guess_c}):y("detail.lacuna"):N.zi?y("detail.composedChar",{label:N.zi}):N.guess?y("reader.charGuess"):void 0,children:S(N)}),U.map(k)]},N.id)});if(!_.entity)return t.jsx(f.Fragment,{children:A},`r${$}`);const R=_.chars[0].beforePuncts.map(k),z=_.chars[_.chars.length-1].afterPuncts.map(k);return t.jsxs(f.Fragment,{children:[R,t.jsx(ds,{span:_.entity,label:_.chars.map(N=>S(N.charData)).join(""),hasBrackets:!0,plain:a&&_.entity.kind==="work",loader:c,buildHref:g,onNavigate:m.navigate,cardNewTab:!0,renderText:()=>A,hoverDelayMs:250}),z]},`${_.entity.key}@${$}`)}),C===n.paragraphs.length-1&&n.trailingBlank?t.jsx(Za,{n:n.trailingBlank}):null]})]},v.id)),w(n.paragraphs.length)]})});function co(e){const[n,i]=ei,o=Number.isFinite(e)?e:.33;return Math.round(Math.min(i,Math.max(n,o))*1e3)/1e3}const Zx=.02,jn=16,Jx=4;function Qx({y:e,containerRef:n,onDrag:i,onCommit:o}){const{t:s}=ae(),[a,l]=f.useState(0),d=f.useRef(!1),c=f.useRef(null),p=f.useRef(e);p.current=e;const g=f.useCallback(()=>{var j;const u=((j=c.current)==null?void 0:j.parentElement)??n.current,h=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=h==null?void 0:h.getBoundingClientRect();l(Math.max(0,((x==null?void 0:x.left)??0)-jn-Jx))},[n]);f.useLayoutEffect(()=>{var j;window.addEventListener("resize",g);const u=((j=c.current)==null?void 0:j.parentElement)??n.current,h=(u==null?void 0:u.closest(".bim-rd-col"))??u,x=typeof ResizeObserver<"u"?new ResizeObserver(()=>g()):null;for(const b of[h,u==null?void 0:u.closest(".bim-rd-text"),u==null?void 0:u.closest(".bim-rd-body")])b&&(x==null||x.observe(b));return x||g(),()=>{window.removeEventListener("resize",g),x==null||x.disconnect()}},[g,n]);const m=u=>co(u/Math.max(1,window.innerHeight));return t.jsx("div",{ref:c,role:"slider",tabIndex:0,className:"guji-page-indicator","aria-label":s("reader.pageIndicator"),"aria-orientation":"vertical","aria-valuemin":Math.round(ei[0]*100),"aria-valuemax":Math.round(ei[1]*100),"aria-valuenow":Math.round(e*100),"data-indicator-y":e,style:{position:"fixed",left:a,top:`calc(${e*100}vh - ${jn/2}px)`,width:jn,height:jn,zIndex:20,cursor:"ns-resize",touchAction:"none",display:"flex",alignItems:"center",justifyContent:"center",color:r("meta-fg")},onPointerDown:u=>{d.current=!0;try{u.currentTarget.setPointerCapture(u.pointerId)}catch{}u.preventDefault()},onPointerMove:u=>{if(!d.current)return;const h=m(u.clientY);p.current=h,i(h)},onPointerUp:u=>{if(d.current){d.current=!1;try{u.currentTarget.releasePointerCapture(u.pointerId)}catch{}o(m(u.clientY))}},onPointerCancel:()=>{d.current&&(d.current=!1,o(p.current))},onKeyDown:u=>{const h=u.key==="ArrowUp"?-1:u.key==="ArrowDown"?1:0;h&&(u.preventDefault(),o(co(e+h*(u.shiftKey?5:1)*Zx)))},children:t.jsx("svg",{width:jn,height:jn,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M2 8h11M9 4l4 4-4 4"})})})}const Ad=1,Md=6,Si={s:1,x:0,y:0},Ti=(e,n,i)=>Math.min(i,Math.max(n,e));function ms(e,n,i){const o=Ti(e.s,Ad,Md);return{s:o,x:Ti(e.x,n*(1-o),0),y:Ti(e.y,i*(1-o),0)}}function Ar(e,n,i,o,s,a){const l=Ti(e.s*o,Ad,Md),d=l/e.s;return ms({s:l,x:n-(n-e.x)*d,y:i-(i-e.y)*d},s,a)}function eb(e,n,i,o,s){return ms({s:e.s,x:e.x+n,y:e.y+i},o,s)}function tb(e,n,i){const o=n===1?e*16:n===2?e*400:e;return Math.exp(-o*(i?.01:.0015))}const Ja=4,nb=f.forwardRef(function({children:n,onScaleChange:i,resetKey:o,style:s},a){const l=f.useRef(null),[d,c]=f.useState(Si),p=f.useRef(d),g=f.useRef(i);g.current=i;const m=y=>{var w;const k=p.current;p.current=y,c(y),y.s!==k.s&&((w=g.current)==null||w.call(g,y.s))},u=()=>{var k;const y=(k=l.current)==null?void 0:k.getBoundingClientRect();return{w:(y==null?void 0:y.width)??0,h:(y==null?void 0:y.height)??0,left:(y==null?void 0:y.left)??0,top:(y==null?void 0:y.top)??0}};f.useImperativeHandle(a,()=>({zoomBy(y){const{w:k,h:w}=u();m(Ar(p.current,k/2,w/2,y,k,w))},reset(){m(Si)}})),f.useEffect(()=>{m(Si)},[o]),f.useEffect(()=>{const y=l.current;if(!y||typeof ResizeObserver>"u")return;const k=new ResizeObserver(()=>{const{w,h:v}=u(),C=ms(p.current,w,v);(C.x!==p.current.x||C.y!==p.current.y)&&m(C)});return k.observe(y),()=>k.disconnect()},[]),f.useEffect(()=>{const y=l.current;if(!y)return;const k=w=>{const v=tb(w.deltaY,w.deltaMode,w.ctrlKey);if(p.current.s<=1&&v<1)return;w.preventDefault();const{w:C,h:_,left:$,top:A}=u();m(Ar(p.current,w.clientX-$,w.clientY-A,v,C,_))};return y.addEventListener("wheel",k,{passive:!1}),()=>y.removeEventListener("wheel",k)},[]);const h=f.useRef(new Map),x=f.useRef({dragging:!1,moved:0,pinchDist:0,swallowClick:!1}),j=y=>{if(y.pointerType==="mouse"&&y.button!==0)return;h.current.set(y.pointerId,{x:y.clientX,y:y.clientY});const k=x.current;if(k.swallowClick=!1,h.current.size===1&&(k.moved=0,k.dragging=!1),h.current.size===2){const[w,v]=[...h.current.values()];k.pinchDist=Math.hypot(w.x-v.x,w.y-v.y),k.moved=Ja+1}},b=y=>{var N;const k=h.current.get(y.pointerId);if(!k)return;const w={x:y.clientX,y:y.clientY};h.current.set(y.pointerId,w);const v=x.current,{w:C,h:_,left:$,top:A}=u();if(h.current.size>=2){const[M,O]=[...h.current.values()],L=Math.hypot(M.x-O.x,M.y-O.y);if(v.pinchDist>0&&L>0){const D=(M.x+O.x)/2-$,q=(M.y+O.y)/2-A;m(Ar(p.current,D,q,L/v.pinchDist,C,_))}v.pinchDist=L,v.swallowClick=!0;return}const R=w.x-k.x,z=w.y-k.y;if(v.moved+=Math.abs(R)+Math.abs(z),!(v.moved<=Ja)){if(!v.dragging){v.dragging=!0;try{(N=l.current)==null||N.setPointerCapture(y.pointerId)}catch{}}v.swallowClick=!0,p.current.s>1&&m(eb(p.current,R,z,C,_))}},S=y=>{h.current.delete(y.pointerId);const k=x.current;k.pinchDist=0,h.current.size===0&&(k.dragging=!1)};return t.jsx("div",{ref:l,className:"bim-zp","data-zoom":d.s.toFixed(2),onPointerDown:j,onPointerMove:b,onPointerUp:S,onPointerCancel:S,onClickCapture:y=>{x.current.swallowClick&&(x.current.swallowClick=!1,y.stopPropagation(),y.preventDefault())},onDoubleClick:()=>m(Si),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 Pd(e,n,i,o,s=""){const a=`${s}
|
|
1438
1469
|
${o.versionKey??""}
|
|
1439
|
-
${i??""}`,[l,d]=f.useState({tag:"",data:null}),c=f.useRef(0);if(f.useEffect(()=>{if(n!==void 0)return;const g=++c.current,m=u=>{g===c.current&&d({tag:a,data:u})};if(!i)return m(null);if(e){let u;try{u=e(i,o)}catch{return m(null)}if(!u||typeof u.then!="function")return m(u??null);u.then(h=>m(h??null),()=>m(null));return}m(null)},[e,n,i,o,a]),n!==void 0)return{warpData:n,loading:!1};const p=l.tag===a;return{warpData:p?l.data:null,loading:!!e&&!!i&&!p}}function
|
|
1470
|
+
${i??""}`,[l,d]=f.useState({tag:"",data:null}),c=f.useRef(0);if(f.useEffect(()=>{if(n!==void 0)return;const g=++c.current,m=u=>{g===c.current&&d({tag:a,data:u})};if(!i)return m(null);if(e){let u;try{u=e(i,o)}catch{return m(null)}if(!u||typeof u.then!="function")return m(u??null);u.then(h=>m(h??null),()=>m(null));return}m(null)},[e,n,i,o,a]),n!==void 0)return{warpData:n,loading:!1};const p=l.tag===a;return{warpData:p?l.data:null,loading:!!e&&!!i&&!p}}function ib(e,n,i,o=""){const s=`${o}
|
|
1440
1471
|
${i.versionKey??""}
|
|
1441
|
-
${n??""}`,[a,l]=f.useState({tag:"",spans:[]}),d=f.useRef(0);return f.useEffect(()=>{const c=++d.current,p=m=>{c===d.current&&l({tag:s,spans:m})};if(!e||!n){p([]);return}let g;try{g=e(n,i)}catch{p([]);return}Promise.resolve(g).then(m=>p(m?
|
|
1442
|
-
${E}`;if(
|
|
1443
|
-
${
|
|
1444
|
-
${
|
|
1445
|
-
${
|
|
1446
|
-
${
|
|
1447
|
-
${
|
|
1448
|
-
${
|
|
1449
|
-
${
|
|
1450
|
-
${
|
|
1451
|
-
${ie??""}`,[Mn,Ts]=f.useState({key:An,data:ce,started:!!ce});if(Mn.key!==An)Ts({key:An,data:ce,started:!1});else if(ce!==Mn.data&&(Ts({key:An,data:ce,started:!!ce}),ce)){const E=ce.pages??[];(!Mn.started||!E.some(ee=>ee.page===at))&&fn(Ns(ce))}f.useEffect(()=>{Ve(new Set),ct.set(null)},[ie,L,ct]);const cr=Mn.key===An&&Mn.started,Rs=!!Q&&lo(Q.headings).length===0,Is=f.useMemo(()=>Rs&&cr&&ce?Ad(ce.pages,ce.punctuations):[],[Rs,cr,ce]),dr=f.useCallback(E=>{const ee=lo(E.headings);return ee.length>0?ee:E.file===ie?Is:[]},[ie,Is]),mu=f.useCallback(E=>{if(Ve(new Set(E)),E.length>0){const ee=E[0],Ie=parseInt(ee.split(":")[0],10);isNaN(Ie)||fn(Ie)}},[]),Wt=f.useMemo(()=>{const E=new Map;for(const ee of(ce==null?void 0:ce.pages)??[])E.set(ee.page,ee);return E},[ce]),Pn=zs(ce),ci=f.useCallback(E=>{var rt;const ee=pe.images;if(!ee||ee.length===0)return;const Ie=(rt=Wt.get(E))==null?void 0:rt.seq;return(Ie?ee.find(Xe=>Xe.seq===Ie):void 0)??ee.find(Xe=>Xe.pageNo===E)??ee[E-1]},[pe.images,Wt]),Es=xt>1.5,di=f.useCallback((E,ee=!1)=>{const Ie=ci(E);return Ie?E===Pn||ee?Ie.hiresUrl??Ie.url:Ie.url:E===Pn?(ce==null?void 0:ce.imageUrl)??"":""},[ci,ce,Pn]),gu=f.useMemo(()=>di(at,Es),[di,at,Es]),Ft=f.useMemo(()=>[...Wt.keys()].sort((E,ee)=>E-ee),[Wt]),rn=f.useRef(at);rn.current=at;const pr=f.useRef(0),ur=f.useRef({page:null,timer:null}),fu=f.useCallback(E=>{const ee=ur.current;E!==ee.page&&(ee.timer&&(clearTimeout(ee.timer),ee.timer=null),ee.page=null,!(E===rn.current||Date.now()<pr.current)&&(ee.page=E,ee.timer=setTimeout(()=>{ee.timer=null,ee.page=null,!(Date.now()<pr.current||rn.current===E)&&(rn.current=E,fn(E))},ob)))},[]);f.useEffect(()=>()=>{ur.current.timer&&clearTimeout(ur.current.timer)},[]);const pi=f.useCallback(E=>{var ee;rn.current===E||!Wt.has(E)||(pr.current=Date.now()+1e3,rn.current=E,fn(E),(ee=Wt.get(E))!=null&&ee.columns.some(Ie=>Ie.chars.length>0)&&Ln(Ie=>({page:E,nonce:((Ie==null?void 0:Ie.nonce)??0)+1})))},[Wt]),Bn=f.useCallback(E=>{const ee=rn.current,Ie=Ft.indexOf(ee),rt=Ft[Ie<0?0:Ie+E];rt===void 0||rt===ee||pi(rt)},[Ft,pi]),Ls=f.useCallback(E=>{if(!E.trim().match(/^\d+$/)||Ft.length===0)return null;const Ie=parseInt(E.trim(),10),rt=Number.isFinite(Ie)?Ie:Number.MAX_SAFE_INTEGER;return Ft.reduce((Xe,Tt)=>Math.abs(Tt-rt)<Math.abs(Xe-rt)?Tt:Xe,Ft[0])},[Ft]),[mr,gr]=f.useState(null),ui=f.useRef(null),hu=f.useCallback(E=>{ui.current=E,gr(E)},[]),As=f.useCallback(()=>{const E=ui.current;if(ui.current=null,gr(null),E===null)return;const ee=Ls(E);ee!==null&&pi(ee)},[Ls,pi]),fr=Ft.indexOf(at),xu=f.useCallback(E=>{if(E.altKey||E.ctrlKey||E.metaKey)return;const ee=E.target.tagName;ee==="INPUT"||ee==="TEXTAREA"||ee==="SELECT"||(E.key==="ArrowLeft"||E.key==="PageUp"?(E.preventDefault(),Bn(-1)):(E.key==="ArrowRight"||E.key==="PageDown")&&(E.preventDefault(),Bn(1)))},[Bn]),Ms=f.useRef(null);f.useEffect(()=>{if(!ce)return;const E=Ms.current;if(!(!E||E.offsetWidth===0))for(const ee of[1,-1]){const Ie=di(at+ee);Ie&&ro(Ie)}},[ce,at,di]);const Ps=f.useMemo(()=>{var qs;if(!ce)return null;if(at===Pn)return ce;const E=Wt.get(at);if(E&&E.width>0&&E.height>0)return{page_id:`p:${at}`,title:`第${at}葉`,image_size:[E.width,E.height],total_warped_w:E.width,columns:[{col:1,warped_w:E.width,warped_h:E.height,offset_x:0,strips:[],chars:E.columns.flatMap(Je=>Je.chars).map(Je=>({id:Je.id,char:Je.char,slot:Je.slot,pos:Je.pos,sub:Je.sub,bbox_col:Je.bbox??[0,0,0,0]}))}],...E.columns.some(Je=>Je.kind==="figure"&&Je.figBox)?{figBlocks:E.columns.filter(Je=>Je.kind==="figure"&&Je.figBox).map(Je=>({id:Je.fig,box:Je.figBox}))}:{}};const ee=(qs=ce.pages)==null?void 0:qs.find(Je=>Je.page===at),[Ie,rt]=ce.image_size||[2386,3082];if(!(Ie>0&&rt>0))return null;const Xe=ci(at),Tt=(Xe==null?void 0:Xe.width)??Ie,jr=(Xe==null?void 0:Xe.height)??rt,Gs=Tt/Ie,Ys=jr/rt,Ks=new Map;for(const Je of ce.columns){const St=(Je.strips||[]).flatMap(xi=>xi.srcQuad.map(bi=>bi[0]));if(St.length===0)continue;const Ht=Je.top_y??0,vr=Je.bottom_y??Ht+Je.warped_h;Ks.set(Je.col,{x0:Math.min(...St),x1:Math.max(...St),top:Ht,slotH:(vr-Ht)/21})}return{page_id:`p:${at}`,title:`第${at}葉`,image_size:[Tt,jr],total_warped_w:Tt,columns:ee?ee.columns.map(Je=>{const St=Ks.get(Je.col)??{x0:0,x1:0,top:0,slotH:118};return{col:Je.col,warped_w:Tt,warped_h:jr,offset_x:0,strips:[],chars:Je.chars.map(Ht=>{const vr=Ht.slot??Ht.pos??0,xi=(St.top+(vr-1)*St.slotH)*Ys,bi=(St.x0+St.x1)/2,[zu,Nu]=Ht.sub==="a"?[bi,St.x1]:Ht.sub==="b"?[St.x0,bi]:[St.x0,St.x1];return{...Ht,bbox_col:[zu*Gs,xi,Nu*Gs,xi+St.slotH*Ys]}})}}):[]}},[ce,at,Pn,Wt,ci]),{entryTitle:mi,authors:Bs}=mb(n,i,c===void 0),[Os,hr]=f.useState("text");f.useEffect(()=>{hr("text")},[ie,L]);const bu=f.useMemo(()=>P?cb(P,J,el(he,P),z,T,dr):[],[P,J,he,z,T,dr]);if(oe==="loading")return t.jsx(Ja,{className:S,style:_,title:c??mi,label:R("reader.loading")});if(oe==="missing"||!W||!he)return t.jsx("div",{className:S,style:{..._,...Za},children:R("reader.noText")});if(Ne==="failed")return t.jsx("div",{className:S,style:{..._,...Za},children:R("reader.tocFailed")});if(!P)return t.jsx(Ja,{className:S,style:_,title:c??mi,label:R("reader.tocLoading")});const hn=el(he,P),yu=bu,Ws=Qe&&ie&&Qe.chapter===ie?ps(ie,Qe.anchor):null,ju=Ws&&Q&&dr(Q).some(E=>E.anchor===Qe.anchor)?Ws:ie??null,xr=W.versions.map(E=>({key:E.key,label:Ee.textVersionLabel(E),optionLabel:z(Ee.textVersionLabel(E)),sourceName:tl(E)?R("reader.originalSource"):E.source_name?z(E.source_name):void 0,license:E.license??void 0,sourceUrl:E.source_url??void 0,primary:E.key===$e})),wt=ab((Vs=P.source)==null?void 0:Vs.upstream),gi=(typeof c=="string"?z(c):c)??(P.title?z(P.title):mi?z(mi):void 0),Fs=he.edition_label?z(he.edition_label):void 0,br=gi?t.jsx("a",{href:O(n),title:R("reader.viewEntry"),onClick:l?E=>{E.metaKey||E.ctrlKey||(E.preventDefault(),l(n))}:void 0,children:gi}):void 0,vu=br&&Fs?t.jsxs(t.Fragment,{children:[br,t.jsxs("span",{className:"bim-rd-ed",children:["·",Fs]})]}):br,ku=Bs.length>0?z(Bs.slice(0,2).map(E=>`${E.dynasty?`〔${E.dynasty}〕`:""}${E.name}${` ${E.role||R("reader.defaultRole")}`}`).join("、")):void 0,yr=Q?Bd(Q,hn,z,T):void 0,on=T&&!!(te!=null&&te.json),sn=(te==null?void 0:te.json)??null,xn=(te==null?void 0:te.md)??null,Hs=on&&!V&&wd(sn.sections),wu=Hs&&!(xn&&Te.readingMode==="paragraph"&&Ai(xn)),Su=on&&Hs?t.jsx(ux,{juan:sn,view:Os,onView:hr,textHasEntries:wu}):void 0,_u=!0,fi=xn?xn.replace(/^##\s+[^\n]+\n+/,""):null,hi=tl(he),Xt=hi?R("reader.originalSource"):he.source_name?z(he.source_name):void 0,$u=(typeof p=="string"?z(p):p)??(hi?void 0:Xt??z(Ee.textVersionLabel(he))),Cu=(ce==null?void 0:ce.hasNorm)===!0;return t.jsxs(Bc,{className:S,style:_,title:vu,subtitle:$u,byline:ku,current:yr,pagerUnit:hn,rail:Su,revisedAt:b,backHref:$,backLabel:y,onReportError:j?E=>j({...E,bookTitle:typeof gi=="string"?gi:void 0,entryId:n}):void 0,workLinkToggle:on&&!V&&!!l&&!!(sn!=null&&sn.sections.some(E=>E.work_id)),toc:yu,tocCaption:R("reader.tocCaption",{n:P.chapters.length,unit:z(hn)}),tocHeader:T&&P.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:V?R("reader.searchChaptersPlaceholder"):R("reader.searchUnitPlaceholder",{unit:z(hn)}),"aria-label":V?R("reader.searchChapters"):R("reader.searchUnit",{unit:z(hn)}),value:fe,onChange:E=>be(E.target.value)}):void 0,activeKey:ie??null,tocActiveKey:ju,onSelect:D,images:Ni(Q)&&Oe&&!ce?null:pe.images,renderImageOverlay:m,imagePanel:ce||ye?"open":u,imagesLoading:ve,isWarpMode:!!ce,showPreserveMargins:!h,customImagePanel:ce&&Ps?t.jsxs("div",{ref:Ms,className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:xu,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:r("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4},children:t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[tt.size>0&&t.jsxs("button",{type:"button",onClick:()=>Ve(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",tt.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:xt<=1,onClick:()=>{var E;return(E=nt.current)==null?void 0:E.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(xt*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:xt>=6,onClick:()=>{var E;return(E=nt.current)==null?void 0:E.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:xt===1,onClick:()=>{var E;return(E=nt.current)==null?void 0:E.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(Qx,{ref:nt,resetKey:at,onScaleChange:Et,style:{flex:1,minHeight:0},children:t.jsx(Fa,{store:ct,children:E=>t.jsx(rs,{imageUrl:gu,pageData:Ps,selectedCharIds:tt,hoveredCharId:E,preserveMargins:et,renderScale:xt,selectedFigBlock:ut,onFigBlockClick:ee=>qe(ee),onCharClick:ee=>{qe(null),Ve(rt=>{const Xe=new Set(rt);return Xe.has(ee)?Xe.delete(ee):(Xe.clear(),Xe.add(ee)),Xe});const Ie=document.querySelector(`[data-char-id="${ee}"]`);Ie&&Ie.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ct.set})})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":R("reader.facsimilePager"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"6px 4px 0",fontSize:13,color:r("meta-fg")},children:[t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:fr<=0,onClick:()=>Bn(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":at,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 8px",background:r("rule"),borderRadius:10},children:["第",t.jsx("input",{type:"text",inputMode:"numeric","data-testid":"facsimile-page-input","aria-label":R("reader.facsimilePageInput"),size:Math.max(2,String(mr??at).length),value:mr??String(at),onFocus:E=>E.currentTarget.select(),onChange:E=>hu(E.target.value),onKeyDown:E=>{E.key==="Enter"?(E.preventDefault(),As()):E.key==="Escape"&&(ui.current=null,gr(null)),E.stopPropagation()},onBlur:As,style:{width:`${Math.max(2,String(mr??at).length)+1}ch`,minHeight:28,textAlign:"center",font:"inherit",border:`1px solid ${r("rule")}`,borderRadius:4,background:"transparent",color:"inherit"}}),"葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:fr<0||fr>=Ft.length-1,onClick:()=>Bn(1),children:"›"})]})]}):void 0,settingsAnnotate:ce?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${K?"bim-rd-on":""}`,"aria-pressed":K,title:"切换外挂现代断句标点",onClick:()=>De(E=>!E),children:K?"标点":"无标点"}):void 0,prefs:Te,onPrefsChange:B,versions:xr.length>1?xr:void 0,currentVersionKey:xr.length>1?he.key:void 0,onVersionChange:we,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:Ai(xn),allowVertical:x,origScriptAvailable:Cu,contentLoading:it,children:[(it||Oe&&!ce&&!on&&fi==null)&&t.jsx(mn,{}),!it&&ce&&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:Q!=null&&Q.title?z(Q.title):yr}),(Xt||he.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Xt,he.license&&t.jsxs(t.Fragment,{children:[Xt&&t.jsx("span",{className:"bim-rd-dot"}),he.license]})]})]}),t.jsx(Fa,{store:ct,children:E=>t.jsx(cs,{pageData:ce,pages:ce.pages,punctuations:ce.punctuations||sb,selectedCharIds:tt,hoveredCharId:E,onSelectionChange:mu,figures:ce.figures,figUrl:ce.figUrl,onFigureBlockClick:({page:ee,fig:Ie})=>{Ve(new Set),qe(Ie),fn(ee)},onCharClick:ee=>{qe(null),Ve(rt=>{const Xe=new Set(rt);return Xe.has(ee)?Xe.delete(ee):(Xe.clear(),Xe.add(ee)),Xe});const Ie=parseInt(ee.split(":")[0],10);isNaN(Ie)||fn(Ie)},onCharHover:ct.set,mode:"horizontal",showPunctuation:K,entities:Ze,entityTransport:i,onEntityNavigate:C,onVisiblePageChange:fu,convert:z,scrollToPage:Ot,scrollToAnchor:He&&He.chapter===ie&&cr?He:null,onVisibleHeadingChange:ee=>U(ee&&ie?{chapter:ie,anchor:ee}:null),pageBreaks:Te.pageBreaks,pageIndicatorY:Te.pageIndicatorY,onPageIndicatorYChange:ee=>B({pageIndicatorY:ee}),quoteStyle:Te.quoteStyle,bookTitleStyle:Te.bookTitleStyle,showWorks:Te.showWorks})})]}),!it&&!ce&&on&&sn&&t.jsx(dx,{juan:sn,rawText:xn,positionLabel:pb(Q,P,hn,z),groupLabel:ub(P,ie??null),index:lb(n,P),searchQuery:fe,onNavigate:l,transport:i,workLabelCache:Se,prefs:Te,view:Os,onViewChange:hr},`${L}/${ie}`),!it&&!ce&&!on&&fi!=null&&Q&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:Q.title?z(Q.title):yr}),(Xt||he.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[hi&&Xt&&t.jsx(t.Fragment,{children:Xt}),!hi&&he.source_name&&t.jsxs(t.Fragment,{children:[R("reader.textSource")," ",he.source_url?t.jsx("a",{className:"bim-rd-link",href:he.source_url,target:"_blank",rel:"noreferrer",children:z(he.source_name)}):z(he.source_name)]}),Xt&&he.license&&t.jsx("span",{className:"bim-rd-dot"}),he.license]}),wt&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[R("reader.upstream")," ",wt.url?t.jsx("a",{className:"bim-rd-link",href:wt.url,target:"_blank",rel:"noreferrer",children:z(wt.name??wt.url)}):z(wt.name??""),wt.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),wt.license_url?t.jsx("a",{className:"bim-rd-link",href:wt.license_url,target:"_blank",rel:"noreferrer",children:wt.license}):wt.license]}),wt.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Cc,{text:wt.note,convert:z})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(Xo,{text:fi,mode:Te.readingMode,tables:_u,gujiMarkdown:!0,bookMarking:qo(Te),quoteStyle:Te.quoteStyle})})]}),!it&&!Oe&&!ce&&!on&&fi==null&&Q&&t.jsx("div",{className:"bim-rd-state",children:R("reader.chapterFailed")}),!it&&P.references&&P.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:R("reader.references")}),t.jsx("ol",{children:P.references.map((E,ee)=>t.jsxs("li",{children:[E.url?t.jsx("a",{className:"bim-rd-link",href:E.url,target:"_blank",rel:"noopener noreferrer",children:z(E.title)}):t.jsx("span",{children:z(E.title)}),E.author&&t.jsxs("span",{children:[",",z(E.author)]}),E.note&&t.jsxs("span",{children:["。",z(E.note)]})]},ee))})]})]})};function tl(e){return e.is_original===!0||e.source==="original"}function pb(e,n,i,o){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 o(s?`${s}冊`:`${i}${e.n}`)}function ub(e,n){if(!n)return;const i=o=>{var s;for(const a of o??[]){const l=i(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return i(e.juan_groups)}function mb(e,n,i){const[o,s]=f.useState({entryTitle:void 0,authors:[]});return f.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:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const Wd={bug:{key:"bug",color:r("danger")},resource:{key:"resource",color:r("primary")},suggestion:{key:"suggestion",color:r("primary")},other:{key:"other",color:r("desc-fg")}},gb=Wd.other,Fd={pending:{key:"pending",color:r("warning")},in_progress:{key:"in_progress",color:r("primary")},resolved:{key:"resolved",color:r("success")},wontfix:{key:"wontfix",color:r("desc-fg")},duplicate:{key:"duplicate",color:r("desc-fg")}},fb=Fd.pending;function hb(e){try{const n=new Date(e),i=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())} ${i(n.getHours())}:${i(n.getMinutes())}`}catch{return e}}function xb(e,n){if(!e)return!1;try{const i=new URL(e,n);if(i.protocol!=="http:"&&i.protocol!=="https:")return!1;const o=new URL(n);return i.hostname===o.hostname}catch{return!1}}const ms=({items:e,loading:n})=>{const i=mt(),{t:o,convert:s}=ae();return n?t.jsx(mn,{}):e.length===0?t.jsx("div",{style:bb,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=Wd[a.type]||gb,d=Fd[a.status]||fb,c=typeof window<"u"&&xb(a.pageUrl,window.location.href);return t.jsxs("div",{style:yb,children:[t.jsxs("div",{style:jb,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...nl,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...nl,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:vb,children:hb(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:kb,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:Lr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:Lr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:Lr,children:a.pageUrl}))]}),t.jsx("div",{style:wb,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Sb,children:[t.jsx("div",{style:_b,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},bb={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},yb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},jb={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},nl={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},vb={fontSize:"12px",color:r("desc-fg")},kb={fontSize:"12px",marginBottom:"6px"},Lr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},wb={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},Sb={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},_b={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},co=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=We(),[d,c]=f.useState(null),[p,g]=f.useState([]),[m,u]=f.useState("recommend"),[h,x]=f.useState([]),[j,b]=f.useState(!1),$=o??m,y=A=>{u(A),s==null||s(A)},[k,w]=f.useState(!0),[v,C]=f.useState(null),[S,_]=f.useState(null),[R,z]=f.useState(null);f.useEffect(()=>{let A=!1;if(e.getCounts)return e.getCounts().then(W=>{A||c({works:W.works,books:W.books,collections:W.collections})}).catch(()=>{}),()=>{A=!0}},[e]),f.useEffect(()=>{let A=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const G=await e.getRecommended();if(G!=null&&G.groups)return G.groups.flatMap(oe=>oe.items.map(se=>({...se,group:oe.name})))}catch{}return[]})().then(async G=>{if(A)return;const oe=G.filter(Y=>Y.id);if(oe.length===0){w(!1);return}const se=await Promise.all(oe.map(async Y=>{if(Y.type)return{id:Y.id,title:Y.title,type:Y.type,author:Y.author,dynasty:Y.dynasty,role:Y.role,edition:Y.edition,has_text:Y.has_text,has_image:Y.has_image,has_collated:Y.has_collated,subtype:Y.subtype,primary_name:Y.primary_name,group:Y.group,fallbackDescription:Y.description};try{let de=null;if(e.getEntry)de=await e.getEntry(Y.id);else{const ne=await e.getItem(Y.id);ne&&(de={id:Y.id,title:ne.title||Y.id,type:ne.type||"work"})}if(de)return{...de,group:Y.group,fallbackDescription:Y.description}}catch{}return{id:Y.id,title:Y.title,type:Ee.extractType(Y.id),group:Y.group,fallbackDescription:Y.description}}));A||(g(se.filter(Y=>Y!==null)),w(!1))}),()=>{A=!0}},[e,i]);const N=f.useRef(!1),I=f.useRef(!1),B=f.useRef(!1);f.useEffect(()=>{if($!=="catalog"||N.current)return;const A=e.getCatalogProgress??e.getResourceProgress;if(!A)return;N.current=!0;let W=!1;return A.call(e).then(G=>{W||C(G)}).catch(()=>{N.current=!1}),()=>{W=!0}},[e,$]),f.useEffect(()=>{if($!=="collection"||I.current||!e.getCollectionProgress)return;I.current=!0;let A=!1;return e.getCollectionProgress().then(W=>{A||_(W)}).catch(()=>{I.current=!1}),()=>{A=!0}},[e,$]),f.useEffect(()=>{if($!=="site"||B.current||!e.getSiteProgress)return;B.current=!0;let A=!1;return e.getSiteProgress().then(W=>{A||z(W)}).catch(()=>{B.current=!1}),()=>{A=!0}},[e,$]),f.useEffect(()=>{if(!a||$!=="feedback")return;let A=!1;return b(!0),fetch(a).then(W=>W.json()).then(W=>{!A&&W.success&&x(W.items||[])}).catch(()=>{}).finally(()=>{A||b(!1)}),()=>{A=!0}},[a,$]);const O=A=>t.jsx(In,{type:A,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:r("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"16px"},children:[t.jsx(Dn,{label:l.home.recommendTab,active:$==="recommend",onClick:()=>y("recommend")}),t.jsx(Dn,{label:l.home.catalogTab,active:$==="catalog",onClick:()=>y("catalog")}),t.jsx(Dn,{label:l.home.collectionTab,active:$==="collection",onClick:()=>y("collection")}),t.jsx(Dn,{label:l.home.siteTab,active:$==="site",onClick:()=>y("site")}),a&&t.jsx(Dn,{label:l.home.feedbackTab,active:$==="feedback",onClick:()=>y("feedback")})]}),$==="recommend"&&t.jsx($b,{recommended:p,loading:k,onNavigate:n,getIcon:O,t:l}),$==="catalog"&&t.jsx(il,{progress:v,t:l,onNavigate:n}),$==="collection"&&t.jsx(il,{progress:S,t:l,onNavigate:n}),$==="site"&&t.jsx(zb,{progress:R,t:l,totalWorks:(d==null?void 0:d.works)??0}),$==="feedback"&&a&&t.jsx(ms,{items:h,loading:j})]})})},Dn=({label:e,active:n,onClick:i})=>t.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:r(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${r("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),$b=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=mt();if(n)return t.jsx(mn,{});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:r("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 g=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),i==null||i(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,cursor:"pointer",background:r("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:o(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:r("desc-fg"),marginLeft:"4px"},children:p.edition})]}),g&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g})]})]},p.id)})})]},d))})},il=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(mn,{});const o=[...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:r("progress-active"),done:r("progress-done"),todo:r("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=o.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:r("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(Cb,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},Cb=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=mt(),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 ${r("widget-border")}`,background:r("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&&o?t.jsx("a",{href:s(c),onClick:p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("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:r("widget-border"),color:r("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:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?$t(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:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:i,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},zb=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(mn,{});const o=[...e.resources].sort((c,p)=>c.priority-p.priority),s=o.filter(c=>c.imported>0),a=o.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=i>0?Math.round(l/i*100):0;return t.jsxs("div",{children:[i>0&&t.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${r("primary")} 6%, transparent)`,fontSize:"13px",color:r("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",i.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:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(rl,{item:c,t:n,totalWorks:i},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:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(rl,{item:c,t:n,totalWorks:i},c.id))})]})]})},rl=({item:e,t:n,totalWorks:i})=>{const o=i>0?Math.round(e.imported/i*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("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:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${o}%)`:n.home.statusTodo})]}),e.imported>0&&i>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${o}%`,borderRadius:"2px",background:r("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},ol="(max-width: 768px)";function Nb(){const[e,n]=f.useState(()=>typeof window>"u"?!1:window.matchMedia(ol).matches);return f.useEffect(()=>{const i=window.matchMedia(ol),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const Tb=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var I;const a=We(),{convert:l}=Ue(),d=Nb(),[c,p]=f.useState(null),[g,m]=f.useState(null),[u,h]=f.useState(!1),[x,j]=f.useState("detail"),[b,$]=f.useState([]),[y,k]=f.useState(!1),w=f.useCallback(async B=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){$([]);return}k(!0);try{if(e.getCollectionCatalogs){const O=await e.getCollectionCatalogs(B);$(O||[])}else if(e.getCollectionCatalog){const O=await e.getCollectionCatalog(B);$(O?[{resource_id:"",data:O}]:[])}}catch{$([])}finally{k(!1)}},[e]),v=f.useCallback(async B=>{if(i){i(B);return}p(B),m(null),$([]),j("detail"),h(!0);try{const O=await e.getItem(B.id);O&&(m(O),O.type==="collection"&&w(B.id))}catch(O){console.error("加载详情失败:",O)}finally{h(!1)}},[e,i,w]),C=f.useCallback(async B=>{m(null),$([]),j("detail"),h(!0);try{const O=await e.getItem(B);O&&(m(O),p({id:B,title:O.title||B,type:O.type||"book"}),O.type==="collection"&&w(B))}catch(O){console.error("导航失败:",O)}finally{h(!1)}},[e,w]),S=typeof(g==null?void 0:g.text_count)=="number"&&g.text_count>0,_=(g==null?void 0:g.type)==="collection"&&(b.length>0||y)||(g==null?void 0:g.type)==="work"&&S,R=d&&(u||g),z=f.useCallback(()=>{p(null),m(null),$([]),j("detail")},[]),N=t.jsx(t.Fragment,{children:u?t.jsx(mn,{}):g?t.jsxs(t.Fragment,{children:[(_||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${r("widget-border")}`,padding:d?"0 12px":"0 48px",background:r("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[_&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>j("detail"),style:wi(x==="detail"),children:a.detailTab.basicInfo}),g.type==="collection"&&y&&b.length===0&&t.jsxs("button",{onClick:()=>{},style:wi(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),g.type==="collection"&&b.map(B=>t.jsx("button",{onClick:()=>j(`catalog:${B.resource_id}`),style:wi(x===`catalog:${B.resource_id}`),children:B.short_name?`${l(B.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},B.resource_id)),g.type==="work"&&S&&t.jsx("button",{onClick:()=>j("collated"),style:wi(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(Mo,{data:g,transport:e,onNavigate:C}):x.startsWith("catalog:")?t.jsx(Po,{data:(I=b.find(B=>`catalog:${B.resource_id}`===x))==null?void 0:I.data,onNavigate:C}):x==="collated"?t.jsx(us,{id:g.id,transport:e,onNavigate:C}):null})]}):t.jsx(co,{transport:e,onNavigate:C,recommendedIds:o})});return d?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:R?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${r("widget-border")}`,background:r("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:z,style:{padding:"4px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",a.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:N})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Yr,{transport:e,onEntryClick:v,hideModeIndicator:n}),!g&&t.jsx(co,{transport:e,onNavigate:C,recommendedIds:o})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${r("widget-border")}`,display:"flex",flexDirection:"column",background:r("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(Yr,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:N})]})};function wi(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const Rb=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=f.useState(new Set),[g,m]=f.useState(null),[u,h]=f.useState("horizontal"),[x,j]=f.useState(!0),b=f.useRef(null),$=f.useCallback(v=>{p(new Set(v))},[]),y=f.useCallback(v=>{if(p(C=>{const S=new Set(C);return S.has(v)?S.delete(v):(S.clear(),S.add(v)),S}),b.current){const C=b.current.querySelector(`[data-char-id="${v}"]`);C&&C.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),k=()=>{var v;p(new Set),window.getSelection&&((v=window.getSelection())==null||v.removeAllRanges())},w=i.length>0?i: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:o||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:r("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:r("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:r("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:k,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>j(v=>!v),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>h(v=>v==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:u==="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(rs,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:g,onCharClick:y,onCharHover:m})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:b,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:u==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(cs,{pageData:e,punctuations:w,selectedCharIds:c,hoveredCharId:g,onSelectionChange:$,onCharClick:y,onCharHover:m,mode:u,showPunctuation:x})]})]})]})},Ib=e=>typeof e=="string"&&Array.from(e).length===1,Eb=new Set(["point","break","heading"]),Lb=/^#{1,6}$/;function Ab(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;if(typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!Ib(s.pre_char)||s.kind!=null&&!Eb.has(s.kind)||s.pos!=null&&s.pos!=="after"&&s.pos!=="before")continue;const a={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??void 0};if(!(s.kind==="break"&&s.pos==="before")){if(s.kind==="heading"){if(s.pos!=="before"||!Lb.test(s.mark))continue;typeof s.label=="string"&&s.label.trim()&&(a.label=s.label.trim()),s.toc===!1&&(a.toc=!1)}i.push(a)}}return i}function Mb(e){var i;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const o of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((i=o==null?void 0:o.canvas)==null?void 0:i.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const Hd=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function dt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const gs=/^[a-z0-9][a-z0-9-]*$/,Pb=new Set(["main","solo","jz_r","jz_l"]),Bb=new Set(["body","banxin","blank"]);function Ob(e){const n={};return typeof e.lane=="string"&&Pb.has(e.lane)&&e.lane!=="main"&&(n.lane=e.lane),e.lacuna===!0&&(n.lacuna=!0),e.lacuna===!0&&e.guess!==!0&&typeof e.guess_c=="string"&&e.guess_c.trim()&&(n.guess_c=e.guess_c.trim()),e.guess===!0&&(n.guess=!0),typeof e.zi=="string"&&e.zi&&(n.zi=e.zi),typeof e.fig=="string"&&gs.test(e.fig)&&e.c==="□"&&!e.lacuna&&!e.guess&&e.guess_c===void 0&&e.zi===void 0&&(n.fig=e.fig),n}function Wb(e){const n={};typeof e.kind=="string"&&Bb.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=dt(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=dt(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function Ar(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function Fb(e){return typeof e=="string"&&Array.from(e).length===1}function Dd(e){const n=new Map,i={badAnchor:0,badChar:0,badWhy:0,notObject:0},o=e&&typeof e=="object"?e.items:void 0;for(const s of Array.isArray(o)?o:[]){if(!s||typeof s!="object"){i.notObject++;continue}const{a,t:l,why:d}=s;if(typeof a!="string"||!Hd.test(a)){i.badAnchor++;continue}if(!Fb(l)){i.badChar++;continue}if(d!==void 0&&d!=="异体"){i.badWhy++;continue}n.set(a,l)}return{map:n,dropped:i}}function Ud(e){return Dd(e).map}function Hb(e,n,i){var m,u,h,x,j,b,$,y,k,w;const o=i==null?null:Ud(i),s=new Map,a=new Map;for(const v of Ar(n)){const C=dt(v.page);if(C!==void 0){s.set(C,v);for(const S of Array.isArray(v.cells)?v.cells:[]){const _=S==null?void 0:S.box;typeof(S==null?void 0:S.a)=="string"&&Array.isArray(_)&&_.length===4&&_.every(R=>dt(R)!==void 0)&&a.set(S.a,[_[0],_[1],_[0]+_[2],_[1]+_[3]])}}}const l=new Map;for(const[v,C]of s)for(const S of Array.isArray(C.marks)?C.marks:[]){const _=S==null?void 0:S.box;if((S==null?void 0:S.kind)!=="figure"||typeof S.fig!="string"||!Array.isArray(_)||_.length!==4||!_.every(z=>dt(z)!==void 0))continue;let R=l.get(v);R||l.set(v,R=new Map),R.set(S.fig,[_[0],_[1],_[0]+_[2],_[1]+_[3]])}const d=[],c=new Map,p=new Map;for(const v of Ar(e)){const C=dt(v.page);C!==void 0&&typeof v.label=="string"&&v.label&&c.set(C,v.label)}for(const v of Ar(e)){const C=dt(v.page);if(C===void 0)continue;const S=[],_=l.get(C);for(const z of Array.isArray(v.columns)?v.columns:[]){const N=dt(z==null?void 0:z.col);if(N===void 0)continue;if(z.kind==="figure"){if(typeof z.fig!="string"||!gs.test(z.fig))continue;const O=dt(z.span),A=_==null?void 0:_.get(z.fig);S.push({col:N,chars:[],kind:"figure",fig:z.fig,...O!==void 0&&Number.isInteger(O)&&O>1?{span:O}:{},...A?{figBox:A}:{}});continue}const I=[];for(const O of Array.isArray(z.cells)?z.cells:[]){const A=Hd.exec(String((O==null?void 0:O.a)??""));if(!A||typeof O.c!="string")continue;const W=parseInt(A[3],10),G=o==null?void 0:o.get(O.a);I.push({id:O.a,char:O.c,slot:W,pos:W,sub:A[4]||null,bbox:a.get(O.a)??null,...Ob(O),...G!==void 0&&G!==O.c?{norm:G}:{}})}const B=Wb(z);(I.length>0||B.kind==="blank")&&S.push({col:N,chars:I,...B})}if(!S.some(z=>z.chars.length>0||z.kind==="figure")){S.length>0&&p.set(C,S);continue}S.sort((z,N)=>z.col-N.col);const R=s.get(C);d.push({page:C,seq:String(((m=R==null?void 0:R.canvas)==null?void 0:m.seq)??""),width:dt((u=R==null?void 0:R.canvas)==null?void 0:u.width)??dt((h=R==null?void 0:R.image)==null?void 0:h.width)??0,height:dt((x=R==null?void 0:R.canvas)==null?void 0:x.height)??dt((j=R==null?void 0:R.image)==null?void 0:j.height)??0,...typeof v.label=="string"&&v.label?{label:v.label}:{},columns:S})}const g=new Set(d.map(v=>v.page));for(const[v,C]of s){const S=(b=C==null?void 0:C.canvas)==null?void 0:b.seq;g.has(v)||typeof S!="string"&&typeof S!="number"||String(S)===""||d.push({page:v,seq:String(S),width:dt(($=C.canvas)==null?void 0:$.width)??dt((y=C.image)==null?void 0:y.width)??0,height:dt((k=C.canvas)==null?void 0:k.height)??dt((w=C.image)==null?void 0:w.height)??0,...c.has(v)?{label:c.get(v)}:{},columns:p.get(v)??[]})}return d.sort((v,C)=>v.page-C.page)}const Db=new Set(["image/png","image/webp","image/svg+xml"]);function Ub(e){const n=new Map,i=e&&typeof e=="object"?e.figures:void 0;for(const o of Array.isArray(i)?i:[]){if(!o||typeof o!="object")continue;const s=o;if(typeof s.id!="string"||!gs.test(s.id))continue;const a=s.kind==="block"?"block":s.kind==="inline"?"inline":null;a&&(typeof s.file!="string"||!/^fig\/[\w./-]+$/.test(s.file)||s.file.split("/").includes("..")||typeof s.mime!="string"||!Db.has(s.mime)||n.set(s.id,{id:s.id,kind:a,alt:typeof s.alt=="string"&&s.alt.trim()?s.alt.trim():"图形符号",file:s.file,mime:s.mime,width:dt(s.width)??0,height:dt(s.height)??0}))}return n}const Vb=({data:e,onNavigate:n,className:i,style:o})=>{var g;const{t:s,convert:a}=ae(),[l,d]=f.useState(((g=e.divisions[0])==null?void 0:g.name)??null),[c,p]=f.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(m=>t.jsx(Gb,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:u=>p(c===u?null:u),onNavigate:n},m.name))})]})},Gb=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ae(),c=e.categories.reduce((p,g)=>{const m=g.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${r("primary")} 6%, transparent)`:r("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:r("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:r("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 g=`${e.name}/${p.name}`;return t.jsx(Yb,{category:p,expanded:o===g,onToggle:()=>s(g),onNavigate:a},p.name)})})]})},Yb=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,g,m,u;const{t:s,convert:a}=ae(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((g=e.books)==null?void 0:g.cunmu)||[],c=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((u=e.stats)==null?void 0:u.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("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(sl,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(sl,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},sl=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ae(),a=mt(),[l,d]=f.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:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,g)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:r("fg")},children:p.work_id&&i?t.jsx("a",{href:a(p.work_id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),i(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.author).slice(0,20)})]},g))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:o("catalogPage.expandAllN",{n:n.length})})]})},Rt=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=We();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("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 ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:r("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o,i&&t.jsx("button",{onClick:i,style:qb,children:"AI"}),n&&t.jsx("button",{onClick:n,style:Kb,children:a.action.save})]})]}),s]})},Kb={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},qb={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},_t=({label:e,value:n,onChange:i,placeholder:o,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>i(a.target.value),placeholder:o,disabled:s,style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),un=({value:e,onChange:n,placeholder:i})=>{const o=f.useRef(null);return f.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},Pi=({children:e,color:n,style:i})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||r("primary-soft"),color:r(n?"on-color-fg":"fg"),...i},children:e});function Xb(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Ti=({value:e,onChange:n,label:i})=>{const[o,s]=f.useState(!1),a=f.useRef(null),l=Xb(e||"");return f.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:al,children:i}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${r("input-border")}`,borderRadius:"2px",background:r("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:r("fg")},children:l.name}),t.jsx(Pi,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:al,children:i}),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:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},al={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function Zb(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function Jb(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Vd=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=We(),[s,a]=f.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((u,h)=>h!==m)),s===m&&a(null)},c=(m,u,h)=>{const x=[...e];x[m]={...x[m],[u]:h},n(x)},p=(m,u)=>{const h=[...e];h[m]={...h[m],type:u,id:"",name:""},n(h),u==="bookID"&&i&&i(x=>{const j=[...e];j[m]={...j[m],id:x.id,name:x.title,type:"bookID"},n(j)})},g=m=>{i&&i(u=>{const h=[...e];h[m]={...h[m],id:u.id,name:u.title,type:"bookID"},n(h)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,u)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===u?null:u),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===u?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:m.name||`${o.editor.sourcePlaceholder} ${u+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Zb(m.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:Jb(m.type)}),t.jsx("button",{onClick:h=>{h.stopPropagation(),d(u)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===u&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(u,"bookID"),style:{...ll,borderColor:r("source-bookid"),color:r("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:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(u,"url"),style:{...ll,borderColor:r("source-url"),color:r("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),m.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Dt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const h=[...e];h[u]={...h[u],type:"",id:"",name:""},n(h)},style:cl,children:o.action.changeType})]}),m.id&&m.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:r("bg"),border:`1px solid ${r("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:r("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:m.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>g(u),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>g(u),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),m.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Dt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const h=[...e];h[u]={...h[u],type:"",id:"",name:""},n(h)},style:cl,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:h=>c(u,"name",h.target.value),placeholder:o.editor.sourceNamePlaceholder,style:jn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:h=>c(u,"id",h.target.value),placeholder:"https://...",style:jn})]})]}),m.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${r("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...Dt,opacity:.7},children:o.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:h=>c(u,"details",h.target.value),placeholder:o.editor.detailsPlaceholder,style:jn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:h=>c(u,"position",h.target.value),placeholder:"如: 卷三, p.52",style:jn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:h=>c(u,"version",h.target.value),placeholder:"如: v1.0, 2024-01",style:jn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:h=>c(u,"processor_version",h.target.value),placeholder:"如: v0.1",style:jn})]})]})]})]})})]},u)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Dt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},jn={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},ll={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:r("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},cl={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Gd(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(i=>({id:i.id||"",name:i.name||"",type:i.type||"",details:i.details||"",position:i.position||"",version:i.version||"",processor_version:i.processor_version||""}))}catch{}return[]}function Yd(e){return!e||e.length===0?"":JSON.stringify(e)}const Kd=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:g,onLinkEntity:m,onUnlinkEntity:u,onViewEntity:h,onCreateAndLink:x,onSaveRelations:j})=>{const b=We();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${r("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:b.section.relations})]}),j&&t.jsx("button",{onClick:j,style:Qb,children:b.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Un,{direction:"up",title:b.relation.belongsToWork,entity:a,onView:h,onUnlink:()=>u("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(Un,{direction:"up",title:b.relation.containedInCollection,entity:l,onView:h,onUnlink:()=>u("collectionId"),onLink:()=>m("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),a&&g&&g.length>0&&t.jsx(vn,{direction:"horizontal",title:`${b.relation.siblingVersions} (${g.length})`,entities:g,onView:h,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:b.relation.addVersionForWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Un,{direction:"up",title:b.relation.parentWork,entity:o,onView:h,onUnlink:()=>u("parentWorkId"),onLink:()=>m("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),d&&d.length>0&&t.jsx(vn,{direction:"down",title:`${b.relation.childWorks} (${d.length})`,entities:d,onView:h,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:b.action.addSubWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),c&&c.length>0&&t.jsx(vn,{direction:"down",title:`${b.relation.collectionImpl} (${c.length})`,entities:c,onView:h,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:b.action.addCollectionImpl,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),t.jsx(vn,{direction:"down",title:`${b.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:h,onAdd:()=>x("childBook","book",{workId:n}),addLabel:b.action.addVersion,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Un,{direction:"up",title:b.relation.correspondingWork,entity:a,onView:h,onUnlink:()=>u("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(Un,{direction:"up",title:b.relation.parentCollection,entity:s,onView:h,onUnlink:()=>u("parentCollectionId"),onLink:()=>m("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(vn,{direction:"down",title:`${b.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:h,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:b.action.addSubCollection,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),t.jsx(vn,{direction:"down",title:`${b.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:h,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:b.action.addBook,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]})]})]})},Un=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:g,unlinkLabel:m})=>{const u=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),h=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("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})]}),i?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:r("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:qd(i.type)}),t.jsx("span",{style:{fontWeight:500},children:i.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:i.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx(dl,{onClick:()=>o(i),title:g,children:"👁️"}),t.jsx(dl,{onClick:s,title:m,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(po,{onClick:a,children:d}),t.jsx(po,{onClick:l,primary:!0,children:c})]})]})},vn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=f.useState(!1),g=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",u=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:g,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:m}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[u.map(h=>t.jsxs("div",{onClick:()=>o(h),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:qd(h.type)}),t.jsx("span",{children:h.title})]},h.id)),i.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:r("link-fg"),cursor:"pointer"},children:[d," (",i.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(po,{onClick:s,primary:!0,children:["+ ",a]})})]})},dl=({onClick:e,title:n,danger:i,children:o})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:i?r("danger"):"inherit",opacity:.7},children:o}),po=({onClick:e,primary:n,children:i})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${r("widget-border")}`,borderRadius:"4px",background:n?r("primary"):"transparent",color:n?r("primary-fg"):"inherit",cursor:"pointer"},children:i});function qd(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const Qb={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Xd=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[g,m]=f.useState(""),u=p?l.filter(b=>b.id!==p):l;f.useEffect(()=>{e&&(m(""),d(""))},[e]);const h=b=>{m(b),d(b)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",j=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:ey,children:t.jsxs("div",{style:ty,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:i}),t.jsx("button",{onClick:s,style:ny,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:g,onChange:b=>h(b.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:iy})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:Mr,children:"搜索中..."}):u.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:u.map(b=>t.jsxs("div",{onClick:()=>o(b),style:ry,children:[t.jsx("span",{style:{fontSize:"16px"},children:j}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[b.title,b.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:b.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[b.id,b.author&&` · ${b.author}`,b.dynasty&&` · ${b.dynasty}`]})]})]},b.id))}):g?t.jsxs("div",{style:Mr,children:["未找到匹配的",x]}):t.jsxs("div",{style:Mr,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:oy,children:["创建新",x,"并关联"]})]})]})})},ey={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ty={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},ny={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},iy={width:"100%",padding:"10px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},ry={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},Mr={padding:"20px",textAlign:"center",color:r("desc-fg")},oy={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},pl={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},sy={work:"📜",book:"📖",collection:"📚",entity:"👤"},Zd=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=f.useState(""),c=f.useRef(null);f.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var u,h;(u=c.current)==null||u.focus(),(h=c.current)==null||h.select()},100))},[e,o==null?void 0:o.title]);const p=u=>{u.key==="Enter"&&l.trim()?g():u.key==="Escape"&&a()},g=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const m=()=>{switch(i){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`创建新${pl[n]}`}};return t.jsx("div",{style:ay,onClick:u=>{u.target===u.currentTarget&&a()},children:t.jsxs("div",{style:ly,onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:sy[n]}),t.jsx("span",{children:m()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:u=>d(u.target.value),onKeyDown:p,placeholder:`请输入${pl[n]}名称...`,style:cy})]}),((o==null?void 0:o.author)||(o==null?void 0:o.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),background:r("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(o==null?void 0:o.author)&&t.jsxs("div",{children:["作者: ",o.author]}),(o==null?void 0:o.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",o.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:dy,children:"取消"}),t.jsx("button",{onClick:g,disabled:!l.trim(),style:{...py,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},ay={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ly={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:r("shadow-dialog")},cy={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box"},dy={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},py={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function uy(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Jd(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function my(e){switch(e){case"work":return r("editor-type-work");case"collection":return r("editor-type-collection");case"book":return r("editor-type-book");default:return r("desc-fg")}}const Qd=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:g})=>{const[m,u]=f.useState(""),[h,x]=f.useState([]),[j,b]=f.useState(!1),[$,y]=f.useState("recent");f.useEffect(()=>{e&&(u(""),x([]),y(o.length>0?"recent":"search"))},[e,o.length]),f.useEffect(()=>{if(!m.trim()){x([]);return}const _=setTimeout(async()=>{b(!0);try{x(await g(m,i))}catch{x([])}finally{b(!1)}},300);return()=>clearTimeout(_)},[m,i,g]);const k=f.useCallback(_=>{u(_.target.value),_.target.value.trim()&&y("search")},[]),w=f.useCallback(_=>s?_.filter(R=>R.id!==s):_,[s]);if(!e)return null;const v=n||(i==="all"?"选择实体":`选择${Jd(i)}`),C=w(o),S=w(h);return t.jsx("div",{style:fy,children:t.jsxs("div",{style:hy,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:v}),t.jsx("button",{onClick:c,style:xy,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:m,onChange:k,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:by}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),j&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),C.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs(ul,{active:$==="recent",onClick:()=>y("recent"),children:["最近使用 (",C.length,")"]}),t.jsxs(ul,{active:$==="search",onClick:()=>y("search"),children:["搜索结果 ",S.length>0&&`(${S.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:$==="recent"&&C.length>0?t.jsx(ml,{entities:C,onSelect:d}):m.trim()?j?t.jsx(Pr,{message:"搜索中..."}):S.length>0?t.jsx(ml,{entities:S,onSelect:d}):t.jsx(Pr,{message:"未找到匹配的结果"}):t.jsx(Pr,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:yy,children:l||"创建新实体"})]})]})})},ul=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),ml=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(gy,{entity:i,onClick:()=>n(i)},i.id))}),gy=({entity:e,onClick:n})=>{const[i,o]=f.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:uy(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:r("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:r("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:my(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Jd(e.type)})]})},Pr=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),fy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},hy={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},xy={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},by={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},yy={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},jy={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},vy={work:"📜",collection:"📚",book:"📖",entity:"👤"},ep=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:g,relations:m,onRelationsChange:u})=>{var Q;const h=We(),[x,j]=f.useState(!1),[b,$]=f.useState("work"),[y,k]=f.useState(""),[w,v]=f.useState(""),[C,S]=f.useState([]),[_,R]=f.useState(!1),[z,N]=f.useState(!1),[I,B]=f.useState("work"),[O,A]=f.useState(""),[W,G]=f.useState(),[oe,se]=f.useState(!1),[Y,de]=f.useState(null),[ne,ue]=f.useState([]);f.useRef(null);const ke=e.type,Ae=ke==="work",he=ke==="collection",$e=ke==="book",L=f.useCallback((X,we)=>{n({...e,[X]:we})},[e,n]),Me=f.useCallback((X,we)=>{k(X),$(we),v(h.editor.selectToLink+h.indexType[we]),S([]),j(!0)},[h]),q=f.useCallback(X=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,X)},[o,e.id]),le=f.useCallback(X=>{s==null||s(X.id,X.type)},[s]),ge=f.useCallback((X,we,He)=>{const Ke={...He,author:(He==null?void 0:He.author)||e.author,dynasty:He==null?void 0:He.dynasty};B(we),A(X),G(Ke),N(!0)},[e.author]),H=f.useCallback((X,we)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,O,{type:I,title:X,inheritData:we}),N(!1)},[o,e.id,O,I]),Z=f.useCallback(X=>{if(!X.trim()){S([]);return}R(!0),o!=null&&o.searchEntities&&o.searchEntities(X,b).then(we=>{S(we),R(!1)}).catch(()=>{S([]),R(!1)})},[o,b]),Ne=f.useCallback(X=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,y,X.id),j(!1)},[o,e.id,y]),ze=f.useCallback(()=>{i()},[i]),Fe=f.useCallback(X=>{de(()=>X),se(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(ue).catch(()=>{})},[o]),P=f.useCallback((X,we)=>o!=null&&o.searchEntities?o.searchEntities(X,we==="all"?void 0:we):Promise.resolve([]),[o]),ie=f.useCallback(X=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(X),ue(we=>[X,...we.filter(He=>He.id!==X.id)].slice(0,10)),Y==null||Y(X),se(!1),de(null)},[o,Y]);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 ${r("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:vy[ke]}),t.jsx("span",{children:e.title||h.editor.untitled}),t.jsx(Pi,{children:e.id}),t.jsx(Pi,{color:jy[ke],children:h.indexType[ke]})]})}),t.jsx(Rt,{title:h.section.basicInfo,onSave:i,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(Ti,{label:Ae?h.editor.workTitle:he?h.editor.collectionTitle:h.editor.bookTitle,value:e.title,onChange:X=>L("title",X)}),$e&&t.jsx(Ti,{label:h.editor.belongsToWork,value:e.workName||"",onChange:X=>L("workName",X)}),t.jsx(_t,{label:h.editor.authorLabel,value:e.author||"",onChange:X=>L("author",X)}),t.jsx(_t,{label:h.editor.publicationYearLabel,value:e.publicationYear||"",onChange:X=>L("publicationYear",X)}),($e||he)&&t.jsx(Ti,{label:h.editor.containedIn,value:e.collection||"",onChange:X=>L("collection",X)}),($e||he)&&t.jsx(_t,{label:h.editor.holderLabel,value:e.holder||"",onChange:X=>L("holder",X)}),($e||he)&&t.jsx(_t,{label:$e?h.editor.pageLabel:h.editor.volumeLabel,value:e.pages||"",onChange:X=>L("pages",X)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(_t,{label:h.editor.firstImageLabel,value:e.firstImage||"",onChange:X=>L("firstImage",X)})})]})}),t.jsx(Rt,{title:h.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(un,{value:e.description||"",onChange:X=>L("description",X),placeholder:h.editor.descriptionPlaceholder})}),(((Q=e.additional_works)==null?void 0:Q.length)||0)>0&&t.jsx(Rt,{title:h.section.additionalWorks,onSave:i,children:t.jsx(ky,{items:e.additional_works||[],onChange:X=>L("additional_works",X)})}),t.jsx(Rt,{title:h.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx(wy,{items:e.indexed_by||[],onChange:X=>L("indexed_by",X)})}),t.jsx(Rt,{title:h.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Sy,{items:e.emendated_by||[],onChange:X=>L("emendated_by",X)})}),t.jsx(Rt,{title:h.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(Dr,{items:e.resources||[],onChange:X=>L("resources",X),onDownload:p,downloadStatuses:g,filterType:"text"})}),t.jsx(Rt,{title:h.section.imageResources,onSave:i,children:t.jsx(Dr,{items:e.resources||[],onChange:X=>L("resources",X),onDownload:p,downloadStatuses:g,filterType:"image"})}),t.jsx(Rt,{title:h.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(Vd,{items:Gd(e.sources||""),onChange:X=>L("sources",Yd(X)),onOpenEntityPicker:Fe})}),($e||he)&&t.jsx(Rt,{title:h.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(un,{value:e.provenance||"",onChange:X=>L("provenance",X),placeholder:h.editor.provenancePlaceholder})}),$e&&t.jsx(Rt,{title:h.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(un,{value:e.otherEditions||"",onChange:X=>L("otherEditions",X),placeholder:h.editor.otherEditionsPlaceholder})}),t.jsx(Kd,{entityType:ke,entityId:e.id,entityTitle:e.title,parentWork:m==null?void 0:m.parentWork,parentCollection:m==null?void 0:m.parentCollection,belongsToWork:m==null?void 0:m.belongsToWork,belongsToCollection:m==null?void 0:m.belongsToCollection,childWorks:m==null?void 0:m.childWorks,childCollections:m==null?void 0:m.childCollections,containedBooks:m==null?void 0:m.containedBooks,siblingBooks:m==null?void 0:m.siblingBooks,onLinkEntity:Me,onUnlinkEntity:q,onViewEntity:le,onCreateAndLink:ge,onSaveRelations:ze}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${r("danger-soft-border")}`,background:r("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:r("danger"),fontWeight:600,marginBottom:"8px"},children:h.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:h.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("danger")}`,borderRadius:"4px",background:"transparent",color:r("danger"),cursor:"pointer"},children:h.editor.deleteEntity})]}),t.jsx(Xd,{isOpen:x,entityType:b,title:w,onSelect:Ne,onCancel:()=>j(!1),onCreate:()=>{j(!1),ge(y,b)},searchResults:C,onSearch:Z,isLoading:_,excludeId:e.id}),t.jsx(Zd,{isOpen:z,entityType:I,relationField:O,inheritData:W,onConfirm:H,onCancel:()=>N(!1)}),t.jsx(Qd,{isOpen:oe,title:h.action.selectBookOrWork,filterType:"all",recentEntities:ne,excludeId:e.id,onSelect:ie,onCancel:()=>{se(!1),de(null)},onSearch:P})]})};function ky({items:e,onChange:n}){const i=We(),o=(l,d,c)=>{const p=e.map((g,m)=>m===l?{...g,[d]:c}:g);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(_t,{label:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(_t,{label:i.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>o(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(d),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("muted"),marginTop:"18px"},children:"✕"})]},d)),t.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:i.action.addAdditionalWork})]})}function tp({items:e,onChange:n,showMeta:i,addLabel:o}){const s=We(),[a,l]=f.useState(null),d=(g,m,u)=>{const h=e.map((x,j)=>j===g?{...x,[m]:u||void 0}:x);n(h)},c=g=>{n(e.filter((m,u)=>u!==g)),a===g&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((g,m)=>{const u=a===m;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:u?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(u?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:u?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:g.source||s.editor.unnamedSource}),g.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:g.source_bid}),t.jsx("button",{onClick:h=>{h.stopPropagation(),c(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!u&&i&&(g.title_info||g.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[g.title_info,g.title_info&&g.author_info&&" — ",g.author_info]}),u&&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(_t,{label:s.label.sourceName,value:g.source,onChange:h=>d(m,"source",h)}),t.jsx(_t,{label:s.label.sourceBid,value:g.source_bid||"",onChange:h=>d(m,"source_bid",h)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(_t,{label:s.label.titleInfo,value:g.title_info||"",onChange:h=>d(m,"title_info",h)}),t.jsx(_t,{label:s.label.authorInfo,value:g.author_info||"",onChange:h=>d(m,"author_info",h)})]}),t.jsx(_t,{label:s.label.edition,value:g.edition||"",onChange:h=>d(m,"edition",h)})]}),t.jsx(un,{value:g.summary||"",onChange:h=>d(m,"summary",h),placeholder:s.editor.summaryPlaceholder}),t.jsx(un,{value:g.comment||"",onChange:h=>d(m,"comment",h),placeholder:s.editor.commentPlaceholder}),t.jsx(un,{value:g.additional_comment||"",onChange:h=>d(m,"additional_comment",h),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:o})]})}function wy({items:e,onChange:n}){const i=We();return t.jsx(tp,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Sy({items:e,onChange:n}){const i=We();return t.jsx(tp,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function np(e){var d,c,p,g,m,u,h;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",i=((p=e.publication_info)==null?void 0:p.year)||"",o=((g=e.current_location)==null?void 0:g.name)||"",s=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((u=e.page_count)==null?void 0:u.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:i,holder:o,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 j=x.related_works.find(b=>b.relation==="part_of");j&&(l.parentWorkId=j.id,l.parentWorkName=j.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=(h=x.contained_in[0])==null?void 0:h.id)}return l}function _y(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 $y=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:g,onAskAI:m,renderSectionActions:u,onDownloadResource:h,downloadStatuses:x,relations:j,onRelationsChange:b,headerExtra:$,className:y,style:k}=e,w=We(),[v,C]=f.useState(s),S=a?s:v;f.useEffect(()=>{s!==v&&C(s)},[s]);const _=f.useCallback(()=>{const A=S==="view"?"edit":"view";a?a(A):C(A)},[S,a]),[R,z]=f.useState(null);f.useEffect(()=>{i&&o&&o.getItem(i).then(A=>{A&&z(A)})},[i,o]);const N=n||R,I=f.useMemo(()=>N?np(N):null,[N]),B=a||!n?t.jsx("button",{onClick:_,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:S==="edit"?r("accent-bg"):"transparent",color:r(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,O=t.jsxs(t.Fragment,{children:[B,$]});return!N&&!I?t.jsx(mn,{}):S==="view"?t.jsx(Mo,{data:N,transport:o,onNavigate:p?A=>p(A):void 0,renderLink:g,headerExtra:O,className:y,style:k}):I?t.jsxs("div",{className:y,style:k,children:[O&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:O}),t.jsx(ep,{data:I,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:u,onDownloadResource:h,downloadStatuses:x,relations:j,onRelationsChange:b})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:w.common.noData})},Cy=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],ip=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=ae(),[a,l]=f.useState(null),[d,c]=f.useState(""),[p,g]=f.useState(""),[m,u]=f.useState("idle"),[h,x]=f.useState(""),j=f.useRef(null);f.useEffect(()=>{e&&(l(null),c(""),g(""),u("idle"),x(""))},[e]),f.useEffect(()=>{a&&setTimeout(()=>{var y;return(y=j.current)==null?void 0:y.focus()},100)},[a]),f.useEffect(()=>{if(m==="success"){const y=setTimeout(n,2e3);return()=>clearTimeout(y)}},[m,n]),f.useEffect(()=>{if(!e)return;const y=k=>{k.key==="Escape"&&n()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[e,n]);const b=async()=>{if(!(!a||!d.trim())){u("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),u("success")}catch(y){u("error"),x(y instanceof Error?y.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const $=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:zy,onClick:y=>{y.target===y.currentTarget&&n()},children:t.jsxs("div",{style:Ny,onClick:y=>y.stopPropagation(),children:[t.jsxs("div",{style:Ty,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Ry,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:My,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),o&&t.jsx("a",{href:o,style:{fontSize:"13px",color:r("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:Cy.map(y=>t.jsxs("button",{onClick:()=>l(y.value),style:{...Iy,...a===y.value?Ey:{}},children:[t.jsx("span",{children:y.icon})," ",s(`feedback.submitType.${y.value}`)]},y.value))}),t.jsx("textarea",{ref:j,value:d,onChange:y=>c(y.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...Ly,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:y=>g(y.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||m==="submitting","aria-label":s("feedback.contactLabel"),style:By}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:Py,children:h}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:b,disabled:!$,style:{...Ay,opacity:$?1:.6,cursor:$?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},zy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ny={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},Ty={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Ry={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Iy={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Ey={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Ly={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},Ay={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},My={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},Py={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},By={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},uo="--bim-feedback-fab-offset",mo=48,Oy=16,Wy=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=ae(),[l,d]=f.useState(!1),c=n.bottom??24;return f.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(uo,`calc(${c+mo+Oy}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(uo)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...Fy,zIndex:s??r("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(ip,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},Fy={position:"fixed",width:`${mo}px`,height:`${mo}px`,borderRadius:"50%",border:"none",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},Hy=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],rp=({onSubmit:e})=>{const{t:n}=ae(),[i,o]=f.useState("bug"),[s,a]=f.useState(""),[l,d]=f.useState(""),[c,p]=f.useState("idle"),[g,m]=f.useState(""),u=f.useRef(null);f.useEffect(()=>{i&&setTimeout(()=>{var j;return(j=u.current)==null?void 0:j.focus()},100)},[i]);const h=async()=>{if(!(!i||!s.trim())){p("submitting"),m("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(j){p("error"),m(j instanceof Error?j.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:gl,children:t.jsxs("div",{style:Yy,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:Ky,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:gl,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Hy.map(j=>t.jsxs("button",{onClick:()=>o(j.value),style:{...Dy,...i===j.value?Uy:{}},children:[t.jsx("span",{children:j.icon})," ",n(`feedback.submitType.${j.value}`)]},j.value))}),t.jsx("textarea",{ref:u,value:s,onChange:j=>a(j.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Vy}}),t.jsx("input",{type:"text",value:l,onChange:j=>d(j.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:Xy}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:h,disabled:!x,style:{...Gy,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:qy,children:g})]})},gl={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},Dy={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Uy={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Vy={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},Gy={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},Yy={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},Ky={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},qy={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},Xy={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function fl(e){return typeof e=="function"?e():e??"/api/feedback"}const op=({resourceId:e,apiUrl:n})=>{const{t:i}=ae(),[o,s]=f.useState([]),[a,l]=f.useState(!0),d=f.useCallback(async()=>{const p=fl(n);l(!0);try{const m=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();m.success&&s(m.items)}catch{}finally{l(!1)}},[e,n]);f.useEffect(()=>{d()},[d]);const c=async p=>{const g=fl(n),m=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const u=await m.json().catch(()=>null);throw new Error((u==null?void 0:u.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(ms,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(rp,{onSubmit:c})})]})},er=8;async function tr(e,n,i,o){const s=Number.isFinite(n)?Math.max(1,Math.floor(n)):1,a=new Array(e.length);let l=0;const d=Array.from({length:Math.min(s,Math.max(1,e.length))},async()=>{for(;l<e.length&&!(o!=null&&o());){const c=l++;a[c]=await i(e[c],c)}});return await Promise.all(d),a}const Zy=Wi["zh-Hant"].relation,Jy=Wi["zh-Hant"].lossStatus,Qy=Wi["zh-Hant"].resourceKind,nr=Rn("zh-Hant"),fs=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function hl(e,n=nr){return e?fs(Zy,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function e0(e,n=nr){return fs(Jy,e)?n(`detail.lossStatus.${e}`):e}function t0(e,n=nr){return fs(Qy,e)?n(`detail.resourceKind.${e}`):""}function hs({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=ae(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=To(a.role);return t.jsxs(f.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(pt,{id:a.entity_id,label:o(a.name),onNavigate:n,renderLink:i,dense:!0}):o(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:o(d)})]},l)})}):null}function sp(e,n,i=nr){var c,p;const o=zo(e,n),s=o.mirrors.map(g=>({key:g.key,label:g.label,description:g.description,rows:g.items.filter(m=>m.group_role!=="mirror"),mirrors:g.items.filter(m=>m.group_role==="mirror")})),a=o.buckets.filter(g=>g.key==="image"||g.key==="textImage").flatMap(g=>g.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(g=>g.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:i("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=o.buckets.find(g=>g.key==="text"))==null?void 0:p.items)??[],groups:s}}function ap(e,n){const i=(e.url?zn(e.url):void 0)||e.name,o=ec(e,n);return o?`${i}(${o})`:i}function xs({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ae(),[a,l]=f.useState(!1),d=Oi(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(ap(e,n)),g=Nn(e),m=Ui(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var h,x;const u=(h=e.metadata)!=null&&h.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:o("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?o("colorMode.color"):o("colorMode.bw")})]}):null;return g?t.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),u]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,u]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(Uo,{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(u=>!u),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function lp({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=ae();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:o(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:o(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(xs,{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:i("detail.mirror")}),s.mirrors.map((a,l)=>{const d=Nn(a),c=o(ap(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?o(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 Jn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function go(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Jn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const xl=12,n0=60,cp=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var Ne,ze,Fe;const{t:c,convert:p,messages:g}=ae(),m=f.useMemo(()=>Ro({_books:e._books}),[e._books]),[u,h]=f.useState(new Map),[x,j]=f.useState(!1),[b,$]=f.useState(""),[y,k]=f.useState(!1),w=m.length<=n0,v=w||x||!!b||y,C=f.useMemo(()=>v?m:m.slice(0,xl),[m,v]);f.useEffect(()=>{if(!n||C.length===0)return;const P=C.filter(Q=>!u.has(Q));if(P.length===0)return;let ie=!1;return tr(P,er,Q=>n.getItem(Q).then(X=>{var He;const we=X??{};return[Q,{id:Q,title:we.title,edition:we.edition,resources:we.resources,publication_info:we.publication_info,current_location:we.current_location,lineage:we.lineage,measure_info:we.measure_info,summary:i0((He=X==null?void 0:X.description)==null?void 0:He.text)}]}).catch(()=>[Q,{id:Q}]),()=>ie).then(Q=>{ie||h(X=>{const we=new Map(X);for(const[He,Ke]of Q)we.set(He,Ke);return we})}),()=>{ie=!0}},[n,C,u]);const S=f.useMemo(()=>m.map(P=>u.get(P)??{id:P}),[m,u]),_=m.length>0&&m.every(P=>u.has(P)),R=!!n&&C.some(P=>!u.has(P)),z=w||v,N=f.useMemo(()=>nc(S,e.version_graph,{era:b,scanOnly:y,sort:z?"year":"default"}),[S,e.version_graph,b,y,z]),I=x?N.rows:N.rows.slice(0,xl),B=N.allRows.filter(P=>P.hasImage).length,O=N.allRows.reduce((P,ie)=>{var Q;return P+(((Q=ie.copies)==null?void 0:Q.length)??0)},0),A=f.useMemo(()=>(e._related||[]).map(P=>({...P,title:P.title??""})),[e._related]),W=A.filter(P=>P.relation==="collected_in"),G=f.useMemo(()=>{const P=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],ie=Q=>{const X=P.indexOf(Q??"");return X<0?P.length:X};return A.filter(Q=>Q.relation!=="collected_in").map((Q,X)=>({r:Q,i:X})).sort((Q,X)=>ie(Q.r.relation)-ie(X.r.relation)||Q.i-X.i).map(Q=>Q.r)},[A]),oe=f.useMemo(()=>{const P=zo(e.resources,e.resource_groups);return[...P.mirrors.flatMap(ie=>ie.items.map(Q=>({r:Q,kind:p(ie.label)}))),...P.buckets.flatMap(ie=>ie.items.map(Q=>({r:Q,kind:p(t0(ie.key,c))})))]},[e.resources,e.resource_groups,p,c]),se=e.indexed_by||[],Y=e.emendated_by||[],de=f.useMemo(()=>{var U,me,Re;const P=[],ie=(me=(U=e.authors)==null?void 0:U[0])==null?void 0:me.dynasty;ie&&P.push({label:c("workPage.fact.written"),value:p(ie)});const Q=Kt(e,g.unit.juan);if(Q){const D=(Re=e.juan_count)==null?void 0:Re.description;P.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(Q),D&&D!==Q?t.jsxs("span",{className:"bim-d-meta",children:["(",p(D),")"]}):null]})})}e.loss_status&&P.push({label:c("workPage.fact.loss"),value:p(e0(e.loss_status,c))});const X=N.allRows.filter(D=>D.sortYear!=null),we=X.length>0?X.reduce((D,je)=>D.sortYear<=je.sortYear?D:je):null;we!=null&&we.era.era?P.push({label:c("workPage.fact.earliest"),value:p([we.era.era,we.era.reign].filter(Boolean).join(" ")),title:we.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):R&&P.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),Y.length&&P.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:Y.length})});const He=bl(e.additional_titles);He.length&&P.push({label:c("workPage.fact.alias"),value:He.map(p).join("、")});const Ke=bl(e.attached_texts);Ke.length&&P.push({label:c("workPage.fact.attached"),value:Ke.map(p).join("、")});const Qe=(e.additional_works||[]).map(D=>p(D.book_title)+(D.n_juan!=null?` ${D.n_juan}${g.unit.juan}`:""));return Qe.length&&P.push({label:c("workPage.fact.appendix"),value:Qe.join("、")}),P},[e,p,c,g,R,N.allRows,Y.length]),ue=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:_?B:0,label:c("workPage.stat.hasImage")},{value:se.length,label:c("workPage.stat.catalogs")}],ke=Io(e),Ae=ke?[ke.l1,ke.l2,ke.l3,ke.l4].filter(Boolean).map(P=>p(P)):[],he=e.subtype?g.workSubtype[e.subtype]??p(e.subtype):"",$e=t.jsx(ri,{title:p(e.title),byline:t.jsx(hs,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(ft,{items:[...Ae,ke!=null&&ke.source?c("workPage.classifiedBy",{source:p(ke.source.split("/")[0])}):"",he]}),description:(Ne=e.description)!=null&&Ne.text?t.jsxs(t.Fragment,{children:[t.jsx(qt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(ze=e.description.sources)!=null&&ze.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(P=>({text:p(Km(P)),href:qm(P)})).filter(P=>P.text).map((P,ie)=>t.jsxs(f.Fragment,{children:[ie>0?" · ":null,P.href?t.jsx("a",{href:P.href,target:"_blank",rel:"noopener noreferrer",children:P.text}):P.text]},ie))}):null]}):void 0,stats:ue,facts:de,readAction:s,foot:t.jsx(oi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(Fe=e.appendix)==null?void 0:Fe.map((P,ie)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(P.title)}),t.jsx(qt,{text:P.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},ie))}),L=N.eras.length>=2?[{key:"",label:c("catalog.all")},...N.eras.map(P=>({key:P,label:`${P} ${N.allRows.filter(ie=>ie.era.era===P).length}`}))]:[],Me=[];m.length&&Me.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),se.length&&Me.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:se.length}),W.length&&Me.push({id:"collected",label:c("workPage.sec.collected"),count:W.length}),G.length&&Me.push({id:"related",label:c("workPage.sec.related"),count:G.length}),oe.length&&Me.push({id:"resources",label:c("workPage.sec.resources"),count:oe.length});const q=m.length===0&&se.length===0,le=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(ht,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(ft,{items:[c("workPage.versionsTotal",{n:m.length-O}),_&&B?c("workPage.versionsWithImage",{n:B}):"",N.rows.length!==N.allRows.length?c("workPage.versionsCurrent",{n:N.rows.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":R&&L.length===0&&m.length>1?"":void 0,children:[L.length>0&&t.jsx(Xi,{items:L,value:b,onChange:P=>{$(P),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Yc,{label:c("workPage.scanOnly"),checked:y,onChange:P=>{k(P),j(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(z?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Zi(N.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:I.map(P=>{var ie;return t.jsx(o0,{row:P,measure:(ie=u.get(P.id))==null?void 0:ie.measure_info,loaded:u.has(P.id),onNavigate:i,renderLink:o},`${P.id}:${u.has(P.id)?"r":"p"}`)})})]}),I.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(b||y?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(Wo,{total:N.rows.length,shown:I.length,unit:c("workPage.moreUnit"),onClick:()=>j(!0)}),N.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),se.length>0&&t.jsx(s0,{items:se,transport:n,onNavigate:i,renderLink:o}),q&&t.jsx(ht,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),ge=(P,ie)=>t.jsx(pt,{id:P,label:p(ie),onNavigate:i,renderLink:o,dense:!0}),H=f.useMemo(()=>{const P=new Map;for(const ie of G){const Q=hl(ie.relation,c);P.set(Q,(P.get(Q)??0)+1)}return P.size>1?[...P.entries()].sort((ie,Q)=>Q[1]-ie[1]).slice(0,4).map(([ie,Q])=>`${p(ie)} ${Q}`).join(" · "):void 0},[G,p,c]),Z=t.jsxs(t.Fragment,{children:[t.jsx(pn,{id:"collected",title:c("workPage.sec.collected"),items:W.map(P=>ge(P.id,P.title))}),t.jsx(pn,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:G.length}),sub:H,items:G.map(P=>t.jsxs(t.Fragment,{children:[ge(P.id,P.title),t.jsx("span",{className:"bim-d-meta",title:P.note?p(P.note):void 0,children:p(hl(P.relation,c))})]}))}),t.jsx(pn,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:oe.map(({r:P,kind:ie})=>{const Q=p((P.url?zn(P.url):void 0)||P.name),X=Nn(P);return t.jsxs(t.Fragment,{children:[X?t.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",children:[Q," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:Q}),ie&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:ie})]})})})]});return t.jsx(ii,{railTop:a,back:l,nav:Me,railLinks:d,main:le,card:$e,side:Z})};function bl(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function fo(e,n){return n((e.url?zn(e.url):void 0)||e.name)}function i0(e){var a;if(!e)return;const i=e.replace(/\*\*/g,"").split(/\n/)[0].trim().match(/[^。]+。?/g)??[],s=((i.length>1&&((a=i[0])!=null&&a.startsWith("《"))?i[1]:i[0])??"").trim();return s?s.length>120?`${s.slice(0,120)}…`:s:void 0}function r0({copies:e,onNavigate:n,renderLink:i}){const{t:o,convert:s}=ae(),a=new Map;for(const l of e){const d=l.locationName||(l.holders[0]?fo(l.holders[0],s):"")||"",c=a.get(d)??[];c.push(l),a.set(d,c)}return t.jsxs("span",{className:"bim-d-zt-copies",children:[o("workPage.sameEditionCopies",{n:e.length}),[...a].map(([l,d],c)=>t.jsxs(f.Fragment,{children:[c>0?";":"",l?`${s(l)} `:"",d.map((p,g)=>t.jsxs(f.Fragment,{children:[g>0?" · ":"",t.jsx(pt,{id:p.id,label:p.callNumber||p.id,onNavigate:n,renderLink:i,dense:!0})]},p.id))]},l||c))]})}function o0({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=ae(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],g=e.copies??[],m=g.length&&e.locationName?l(e.locationName):p?fo(p,l):e.locationName?l(e.locationName):"",u=e.images[0],h=u?Nn(u):void 0,x=e.images.map(j=>fo(j,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",className:g.length?"bim-d-zt-group":void 0,children:[t.jsxs("td",{className:g.length?"bim-d-zt-main bim-d-zt-rep":"bim-d-zt-main",children:[t.jsx(pt,{id:e.id,label:l(e.name),onNavigate:o,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:" "}),g.length>0&&e.summary&&t.jsx("span",{className:"bim-d-zt-summary",children:l(e.summary)}),g.length>0&&t.jsx(r0,{copies:g,onNavigate:o,renderLink:s})]}),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):i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${m?"":" bim-d-zt-blank"}`,children:[m||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),g.length>0&&e.callNumber&&t.jsx("span",{className:"bim-d-meta",style:{display:"block",fontSize:12},children:e.callNumber}),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(h?t.jsx("a",{className:"bim-d-flag",href:h,target:"_blank",rel:"noopener noreferrer",title:x,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:x,children:a("workPage.hasImage")}))})]})}function s0({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=ae(),[l,d]=f.useState(0),c=Math.min(l,e.length-1),p=e[c],[g,m]=f.useState(new Map);return f.useEffect(()=>{if(!n)return;const u=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(u.length===0)return;let h=!1;return Promise.all(u.map(x=>n.getItem(x).then(j=>{var b,$;return[x,(($=(b=j==null?void 0:j.authors)==null?void 0:b[0])==null?void 0:$.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{h||m(new Map(x.filter(([,j])=>j)))}),()=>{h=!0}},[n,e]),t.jsx(ht,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(ft,{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((u,h)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":h===c,"aria-label":a(u.source),onClick:()=>d(h),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:g.get(u.source_bid??"")?a(g.get(u.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(u.source)].slice(0,9).map((x,j)=>t.jsx("span",{children:x},j))})]})},h))}),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(ft,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(pt,{id:p.source_bid,label:a(p.source),onNavigate:i,renderLink:o,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:Ct(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:Ct(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:Ct(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 a0(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 l0(e,n){if(!e.lineage)return null;const i=e.lineage;return{id:e.id,kind:"book",label:e.title,year:i.year,year_text:i.year_text,year_uncertain:i.year_uncertain,category:i.category,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function yl(e,n,i){return{id:`derive:${n.ref}->${e}:${i}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function c0(e,n,i){const[o,s]=[e,n.book_id].sort();return{id:`sibling:${o}-${s}:${i}`,source:o,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function d0(e,n){var p;if(n==="all")return null;const i=(p=e.collections)==null?void 0:p[n],o=Array.isArray(i==null?void 0:i.groups)&&i.groups.length>0,s=Array.isArray(i==null?void 0:i.book_ids)&&i.book_ids.length>0,a=o||s||!!(i!=null&&i.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(!i||!a)return null;const l=o?new Set(i.groups):null,d=new Set(i.book_ids??[]);if(l&&e.node_groups)for(const[g,m]of Object.entries(e.node_groups))l.has(m)&&d.add(g);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const g of e.hypothetical_nodes??[])g.group&&l.has(g.group)&&c.add(g.id)}return{books:d,hypos:c}}function Ri(e,n,i){const o=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!o||!o.enabled)return s;const a=new Set(o.excluded_books??[]),l=o.node_groups??{},d=d0(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,g=(d==null?void 0:d.hypos)??null,m=new Set,u=new Set;if(c){const w=new Map(n.map(z=>[z.id,z])),v=new Map((o.hypothetical_nodes??[]).map(z=>[z.id,z])),C=z=>{const N=w.get(z);if(N&&N.lineage)return(N.lineage.derived_from??[]).map(B=>B.ref);const I=v.get(z);return I?(I.derived_from??[]).map(B=>B.ref):[]},S=z=>v.has(z)?!g||g.has(z):!p||p.has(z),_=new Set,R=z=>{if(!_.has(z)){_.add(z);for(const N of C(z))a.has(N)||(S(N)||(v.has(N)?u.add(N):w.has(N)&&m.add(N)),R(N))}};for(const z of n)p&&p.has(z.id)&&!a.has(z.id)&&R(z.id);for(const z of o.hypothetical_nodes??[])g&&g.has(z.id)&&R(z.id)}const h=n.filter(w=>!a.has(w.id)).filter(w=>!p||p.has(w.id)||m.has(w.id)).map(w=>{const v=l0(w,l);return v&&m.has(w.id)&&(v.bridge=!0),v}).filter(w=>w!==null),x=(o.hypothetical_nodes??[]).filter(w=>!g||g.has(w.id)||u.has(w.id)).map(w=>{const v=a0(w);return u.has(w.id)&&(v.bridge=!0),v}),j=[...h,...x],b=new Set(j.map(w=>w.id)),$=new Set,y=[],k=w=>{$.has(w.id)||!b.has(w.source)||!b.has(w.target)||($.add(w.id),y.push(w))};for(const w of n)a.has(w.id)||!w.lineage||p&&!p.has(w.id)&&!m.has(w.id)||((w.lineage.derived_from??[]).forEach((v,C)=>{k(yl(w.id,v,C))}),(w.lineage.related_to??[]).forEach((v,C)=>{k(c0(w.id,v,C))}));for(const w of o.hypothetical_nodes??[])g&&!g.has(w.id)&&!u.has(w.id)||(w.derived_from??[]).forEach((v,C)=>{k(yl(w.id,v,C))});return{nodes:j,edges:y,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function dp(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function p0(e,n){const i=[],o=e.version_graph;if(!o)return i;const s=new Set(n.map(c=>c.id)),a=new Set((o.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||i.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&i.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(g=>d(p,g)),(c.lineage.related_to??[]).forEach(g=>{s.has(g.book_id)||i.push(`${p}: related_to.book_id "${g.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(g=>d(p,g))}return i}const pp=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ae();if(!e.nodes.length)return t.jsx("div",{style:{..._0,...o},className:i,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const h of e.edges)if(h.kind==="derive"){const x=l.get(h.target)??[];x.push(h),l.set(h.target,x)}else for(const x of[h.source,h.target]){const j=d.get(x)??[];j.push(h),d.set(x,j)}const c=new Map(e.nodes.map(h=>[h.id,h])),p=new Map,g=[];for(const h of e.nodes)if(h.group){const x=p.get(h.group)??[];x.push(h),p.set(h.group,x)}else g.push(h);const m=(h,x)=>(h.year??9999)-(x.year??9999);p.forEach(h=>h.sort(m)),g.sort(m);const u=e.groups.filter(h=>p.has(h.id));return t.jsxs("div",{className:i,style:{...m0,...o},children:[e.title&&t.jsx("div",{style:g0,children:a(e.title)}),e.description&&t.jsx("div",{style:f0,children:a(e.description)}),u.map(h=>t.jsx(jl,{label:h.label,color:h.color,nodes:p.get(h.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},h.id)),g.length>0&&t.jsx(jl,{label:s("lineage.otherGroup"),nodes:g,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},jl=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ae();return t.jsxs("div",{style:h0,children:[t.jsx("div",{style:{...x0,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(u0,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},u0=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ae();return t.jsxs("div",{style:{...b0,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?r("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:y0,children:[t.jsx("span",{style:j0,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:v0,children:dp(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:k0,children:[e.category&&t.jsx(Vn,{children:c(e.category)}),e.status==="lost"&&t.jsx(Vn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(Vn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(Vn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(Vn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:w0,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:S0,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:kl,children:[t.jsx("div",{style:wl,children:d("lineage.sources")}),n.map(p=>{const g=o.get(p.source);return t.jsxs("div",{style:Sl(p.confidence),children:[t.jsx("span",{style:_l,children:c(p.relation)}),t.jsx("span",{children:(g==null?void 0:g.kind)==="book"&&s?s(g.id,c(g.label)):c((g==null?void 0:g.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(vl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:$l,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:kl,children:[t.jsx("div",{style:wl,children:d("lineage.related")}),i.map(p=>{const g=p.source===e.id?p.target:p.source,m=o.get(g);return t.jsxs("div",{style:Sl(p.confidence),children:[t.jsx("span",{style:_l,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??g)}),t.jsx(vl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:$l,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Vn=({children:e,tone:n="default"})=>{const o={default:{bg:r("tag-bg"),fg:r("fg")},warn:{bg:r("warn-bg"),fg:r("warn-fg")},info:{bg:r("info-bg"),fg:r("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:o.bg,color:o.fg,marginRight:"4px"},children:e})},vl=({level:e})=>{const{t:n}=ae(),o={certain:{key:"certain",color:r("confidence-certain")},consensus:{key:"consensus",color:r("confidence-consensus")},probable:{key:"probable",color:r("confidence-probable")},disputed:{key:"disputed",color:r("confidence-disputed")}}[e];return o?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${o.color}`,color:o.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${o.key}`)}):null},m0={fontSize:"14px",color:r("fg")},g0={fontSize:"16px",fontWeight:600,marginBottom:"8px"},f0={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},h0={marginBottom:"16px"},x0={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},b0={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},y0={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},j0={fontSize:"15px",fontWeight:600},v0={fontSize:"12px",color:r("muted")},k0={marginBottom:"6px"},w0={fontSize:"12px",color:r("muted"),margin:"2px 0"},S0={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},kl={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},wl={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Sl=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),_l={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},$l={fontSize:"11px",color:r("muted")},_0={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},up=({selectedNodeId:e,...n})=>{const{t:i}=ae(),[o,s]=f.useState("loading"),[a,l]=f.useState(null);return f.useEffect(()=>{let d=!1;return $0().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:zl,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:zl,children:[t.jsx("div",{children:Cl(i("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:Cl(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(C0,{modules:a,selectedNodeId:e,...n})};function Cl(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(f.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function $0(){try{const[e,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let i=!1;try{await import("@xyflow/react/dist/style.css"),i=!0}catch{i=!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:i}}catch{return null}}const C0=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:g,Position:m,BaseEdge:u,EdgeLabelRenderer:h,getSmoothStepPath:x,dagre:j}=l,b=f.useMemo(()=>({lineage:C=>{var W,G,oe,se;const S=((W=C.data)==null?void 0:W.stepPosition)??.85,[_,R,z]=x({sourceX:C.sourceX,sourceY:C.sourceY,sourcePosition:C.sourcePosition,targetX:C.targetX,targetY:C.targetY,targetPosition:C.targetPosition,stepPosition:S,borderRadius:5}),N=!!((G=C.data)!=null&&G.isSibling),I=N?R:C.targetX-18,B=N?z:C.targetY-12,O=(oe=C.data)==null?void 0:oe.labelStyle,A=(se=C.data)==null?void 0:se.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(u,{id:C.id,path:_,style:C.style,markerStart:C.markerStart,markerEnd:C.markerEnd}),C.label&&t.jsx(h,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${I}px,${B}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...A,...O},children:C.label})})]})}}),[u,h,x]),$=f.useMemo(()=>({version:C=>{const{t:S}=ae(),_=C.data,R=_.kind==="hypothetical",z=_.status==="lost",N=_.isSelected,I=_.bridge,B=_.borderColor??r("muted"),O=I||R?"dashed":"solid",A=I?.5:z?.6:1;return t.jsxs("div",{style:{background:r(I?"bg-subtle":"bg"),border:`2px ${O} ${N?r("primary"):B}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:A,boxShadow:N?r("shadow-node-selected"):R||I?"none":r("shadow-node")},title:I?S("lineage.bridgeTitle"):void 0,children:[t.jsx(g,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:R||!_.renderLink?_.label:_.renderLink(_.bookId,_.label)}),_.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:_.description}),_.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:dp(_.yearText,void 0,_.uncertain)}),z&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:S("lineage.lost")}),t.jsx(g,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[g,m]),{convert:y}=ae(),{rfNodes:k,rfEdges:w}=f.useMemo(()=>z0(e,j,n,a,y),[e,j,n,a,y]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:k,edges:w,nodeTypes:$,edgeTypes:b,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 z0(e,n,i,o,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??r("muted")]));for(const $ of e.nodes)c.setNode($.id,{width:160,height:90});const g=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const $ of e.edges)$.kind==="derive"&&(g.has($.relation)||c.setEdge($.source,$.target));n.layout(c);const m=e.nodes.map($=>{const y=c.node($.id),k=o?$.id===o:void 0,w={kind:$.kind,label:s($.label),bookId:$.kind==="book"?$.id:void 0,yearText:s($.year_text??T0($)),uncertain:$.year_uncertain,category:$.category,status:$.status,borderColor:$.group?p.get($.group):void 0,renderLink:i,isSelected:k,description:s($.description),bridge:$.bridge};return{id:$.id,type:"version",position:{x:y.x-160/2,y:y.y-90/2},data:w,draggable:!1,selected:k}}),u=.78,h=.06,x=new Map;for(const $ of e.edges)$.kind==="derive"&&(x.has($.source)||x.set($.source,[]),x.get($.source).push($));const j=new Map;for(const[$,y]of x){if(y.length<=1)continue;const k=[...y].sort((v,C)=>{var R,z;const S=((R=c.node(v.target))==null?void 0:R.y)??0,_=((z=c.node(C.target))==null?void 0:z.y)??0;return S-_}),w=k.length;k.forEach((v,C)=>{const S=(C-(w-1)/2)*h;j.set(v.id,u+S)})}const b=e.edges.map($=>N0($,j.get($.id),s));return{rfNodes:m,rfEdges:b}}function N0(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=R0(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:i(e.relation),data:{labelStyle:{color:r("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":o?"6 4":void 0,opacity:o?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function T0(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function R0(e){switch(e){case"certain":return r("confidence-certain");case"consensus":return r("lineage-edge-consensus");case"probable":return r("confidence-probable");case"disputed":return r("confidence-disputed");default:return r("muted")}}const zl={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},bs=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:g,style:m})=>{var w;const{t:u,convert:h}=ae(),[x,j]=f.useState(n),b=v=>{j(v),a==null||a(v)},$=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:u("lineage.collectionAll"),description:u("lineage.collectionAllDesc")}]]})(),y=!!(d&&$.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:u("lineage.empty")});const k=l?(w=c==null?void 0:c[l])==null?void 0:w.description:void 0;return t.jsxs("div",{className:g,style:m,children:[t.jsxs("div",{style:I0,children:[t.jsx("button",{onClick:()=>b("list"),style:Br(x==="list"),children:u("lineage.modeList")}),t.jsx("button",{onClick:()=>b("graph"),style:Br(x==="graph"),children:u("lineage.modeGraph")}),y&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:u("lineage.collectionLabel")}),$.map(([v,C])=>{const S=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:Br(l===v),title:C.description?h(C.description):void 0,children:[h(C.label),S!=null?` ${S}`:""]},v)})]})]}),y&&k&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:h(k)}),x==="list"?t.jsx(pp,{graph:e,renderLink:i}):t.jsx(up,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},I0={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Br=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${r("widget-border")}`,borderRadius:4,background:e?r("primary"):"transparent",color:r(e?"primary-fg":"fg"),cursor:"pointer"}),Nl=40,Tl=2,E0=9,L0=new Set(["certain","consensus","probable","disputed"]);function Or(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const mp=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:g})=>{var me,Re,D,je,te,_e,Be,Ge,Ye,it,st;const m=We(),{t:u,convert:h}=ae(),[x,j]=f.useState(null),[b,$]=f.useState(new Map),[y,k]=f.useState([]),[w,v]=f.useState(new Map),[C,S]=f.useState(!1),[_,R]=f.useState("flow"),[z,N]=f.useState(null);f.useEffect(()=>{if(!n||!e.work_id){j(null);return}let T=!1;return n.getItem(e.work_id).then(fe=>{!T&&fe&&fe.type==="work"&&j(fe)}).catch(()=>{}),()=>{T=!0}},[n,e.work_id]),f.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){N(null);return}let T=!1;return n.getLineageGraph(e.work_id).then(fe=>{T||N(fe&&fe.nodes.length>1?fe:null)}).catch(()=>{T||N(null)}),()=>{T=!0}},[n,e.work_id]),f.useEffect(()=>{const T=e._collections||[];if(!n||T.length===0){$(new Map);return}let fe=!1;return Promise.all(T.map(be=>{const Le=be.id;return n.getItem(Le).then(V=>[Le,V]).catch(()=>[Le,null])})).then(be=>{if(fe)return;const Le=new Map;for(const[V,M]of be)M&&Le.set(V,M);$(Le)}),()=>{fe=!0}},[n,e._collections]);const I=f.useMemo(()=>{const T=new Set([...x?Ro(x):[],...e.related_books||[]]);return T.add(e.id),[...T]},[x,e.related_books,e.id]),B=I.length-1;f.useEffect(()=>{if(!n||B<=0){k([]);return}const T=I.length<=Nl,fe=T?I:I.slice(0,8);let be=!1;return Promise.all(fe.map(Le=>Le===e.id?Promise.resolve({id:Le,title:e.title,edition:e.edition,year:Ei(e)}):n.getItem(Le).then(V=>{const M=V??{};return{id:Le,title:M.title,edition:M.edition,year:V?Ei(M):void 0}}).catch(()=>({id:Le})))).then(Le=>{if(be)return;const V=Le.filter(M=>M.id===e.id||M.title||M.edition);T&&V.sort((M,J)=>(M.year??1/0)-(J.year??1/0)),k(V)}),()=>{be=!0}},[n,I,B,e]);const O=e.lineage,A=f.useMemo(()=>[...((O==null?void 0:O.derived_from)||[]).filter(T=>T.ref_type==="book").map(T=>T.ref),...((O==null?void 0:O.related_to)||[]).map(T=>T.book_id)].filter(Boolean),[O]);f.useEffect(()=>{if(!n||A.length===0){v(new Map);return}let T=!1;return Promise.all(A.map(fe=>n.getItem(fe).then(be=>[fe,{id:fe,title:be==null?void 0:be.title,edition:be==null?void 0:be.edition}]).catch(()=>[fe,{id:fe}]))).then(fe=>{T||v(new Map(fe))}),()=>{T=!0}},[n,A]);const W=f.useMemo(()=>sp(e.resources,e.resource_groups,u),[e.resources,e.resource_groups,u]),G=W.groups.reduce((T,fe)=>T+fe.rows.length+fe.mirrors.length,0),oe=W.groups.length>0&&W.groups.every(T=>T.key==="_physical"),se=ni(e),Y=ac(e),de=Kt(e,m.unit.juan),ne=new Set((e._collections||[]).map(T=>qn(T.vol).length).filter(T=>T>0)),ue=T=>{var Le;const fe=(Le=e.base_edition)==null?void 0:Le.find(V=>V.book_id===T&&V.name);if(fe!=null&&fe.name)return fe.name;const be=w.get(T);return(be==null?void 0:be.edition)||(be==null?void 0:be.title)||""},ke=f.useMemo(()=>{var F,pe,ce,Oe,Ce;const T=[];Y&&T.push({label:u("bookPage.fact.editionType"),value:h(Y),title:e.edition_type||(F=e.lineage)!=null&&F.category?void 0:u("bookPage.inferredFromEdition")}),(pe=e.publication_info)!=null&&pe.details?T.push({label:u("bookPage.fact.publication"),value:h(e.publication_info.details)}):(se.era||se.reign)&&T.push({label:u("bookPage.fact.era"),value:h([se.era,se.reign].filter(Boolean).join(" ")),title:se.source==="edition"?u("bookPage.inferredFromEdition"):void 0}),de&&T.push({label:u("bookPage.fact.measure"),value:h(de)});const fe=(e._collections||[]).flatMap(re=>qn(re.vol));fe.length&&T.push({label:u("bookPage.fact.volumes"),value:u("bookPage.volumesValue",{range:Vi(fe,m.unit.volume),unit:m.unit.volume,n:fe.length})});const be=(((ce=e.lineage)==null?void 0:ce.derived_from)||[]).find(re=>re.relation==="底本"&&re.ref_type==="book");be&&ue(be.ref)&&T.push({label:u("bookPage.fact.baseEdition"),value:t.jsx(pt,{id:be.ref,label:h(ue(be.ref)),onNavigate:i,renderLink:o,dense:!0})});const Le=(e.base_edition||[]).filter(re=>re&&re.name);for(const re of["底本","配補","參校"]){if(re==="底本"&&be&&ue(be.ref))continue;const ye=Le.filter(ve=>ve.role===re);ye.length&&T.push({label:h(re),value:ye.map((ve,Pe)=>t.jsxs(f.Fragment,{children:[Pe>0&&"、",ve.book_id?t.jsx(pt,{id:ve.book_id,label:h(ve.name),onNavigate:i,renderLink:o,dense:!0}):h(ve.name)]},Pe))})}const V=(e.provenance||[]).filter(re=>re&&re.institution),M=(e.resources||[]).filter(re=>Yt(re).includes("physical"));if(V.length){T.push({label:u("bookPage.fact.holdings"),value:V.slice(0,2).map(ve=>h(ve.institution)).join("、")+(V.length>2?u("bookPage.andMorePlaces",{n:V.length}):"")});const re=V.filter(ve=>ve.call_number).slice(0,2).map(ve=>`${h(ve.institution)} ${ve.call_number}`);re.length&&T.push({label:u("bookPage.fact.callNumber"),value:re.join(";")+(V.filter(ve=>ve.call_number).length>2?"…":"")});const ye=V.flatMap(ve=>ve.seals||[]).filter(Boolean);ye.length&&T.push({label:u("bookPage.fact.seals"),value:h(ye.join("、"))})}else M.length?T.push({label:u("bookPage.fact.holdings"),value:M.slice(0,2).map(re=>h(re.name)).join("、")+(M.length>2?u("bookPage.andMorePlaces",{n:M.length}):"")}):(Oe=e.current_location)!=null&&Oe.name&&T.push({label:u("bookPage.fact.holdings"),value:h(e.current_location.name)});const J=e.physical_description;if(J){const re=[[u("bookPage.fact.leafStyle"),J.leaf_style],[u("bookPage.fact.binding"),J.binding],[u("bookPage.fact.dimensions"),J.dimensions],[u("bookPage.fact.condition"),J.condition]];for(const[ye,ve]of re)ve&&ve.trim()&&T.push({label:ye,value:h(ve)})}(Ce=e.page_count)!=null&&Ce.description&&T.push({label:m.label.pageCount,value:h(e.page_count.description)});const Se=[...no(e.additional_titles),...no(e.attached_texts)];return Se.length&&T.push({label:u("bookPage.fact.aliases"),value:Se.map(h).join("、")}),T},[e,h,m,u,se,Y,de,w,i,o]),Ae=h(e.title),he=e.edition?h(e.edition):void 0,$e=((me=e.lineage)==null?void 0:me.year_text)||"",L=t.jsx(ri,{kind:u("bookPage.kind"),title:Ae,subtitle:he,byline:t.jsx(hs,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const T=[Y?h(Y):"",se.era?h([se.era,se.reign].filter(Boolean).join("")):"",de?h(de):""].filter(Boolean);return T.length?t.jsx("span",{className:"bim-d-tags",children:T.map((fe,be)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(be,2)}`,children:fe},be))}):null})(),description:(Re=e.description)!=null&&Re.text?t.jsx(qt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Ho((D=e.description)==null?void 0:D.text)?6:void 0,facts:ke,readAction:s,secondaryAction:s&&G>0&&!oe?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:u("bookPage.viewImages")}):void 0,foot:t.jsx(oi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),Me=e._collections||[],q=(a==null?void 0:a.chapters)||[],le=h(q[0]&&Or(q[0].title)[0].slice(-1)||"")||u("bookPage.chapterUnit"),ge=u("bookPage.chapterCount",{n:q.length,unit:le}),H=!!((je=O==null?void 0:O.derived_from)!=null&&je.length||(te=O==null?void 0:O.related_to)!=null&&te.length||(_e=e.appendix)!=null&&_e.length),Z=[],Ne=u(oe?"bookPage.sec.physical":"bookPage.sec.images");(q.length||W.text.length||l)&&Z.push({id:"fulltext",label:u("bookPage.sec.fulltext"),count:q.length?ge:void 0}),W.groups.length&&Z.push({id:"images",label:Ne,count:G}),H&&Z.push({id:"lineage",label:u("bookPage.sec.lineage")}),Me.length&&Z.push({id:"collections",label:u("section.containedIn"),count:Me.length}),(Be=e.location_history)!=null&&Be.length&&Z.push({id:"provenance",label:u("section.locationHistory")});const ze=T=>(d==null?void 0:d(T))??null,Fe=q[0],P=Fe?ze(Fe.file):null,ie=C?q:q.slice(0,E0),Q=(T,fe,be)=>T?t.jsx("a",{className:be,href:T.href??"#",onClick:T.onClick?Le=>{Le.metaKey||Le.ctrlKey||(Le.preventDefault(),T.onClick())}:void 0,children:fe}):t.jsx("span",{className:be,children:fe}),X=t.jsxs(t.Fragment,{children:[(q.length>0||W.text.length>0||l)&&t.jsxs(ht,{id:"fulltext",title:u("bookPage.sec.fulltext"),meta:q.length>0?t.jsx(ft,{items:[ge,(Ge=a==null?void 0:a.source)!=null&&Ge.name?u("bookPage.sourceBy",{src:h(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!Fe&&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"})]}),Fe&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:u("bookPage.readFrom",{ch:h(Or(Fe.title)[0])||u("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:h((Fe.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),Q(P,t.jsxs(t.Fragment,{children:[u("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),q.length>1&&t.jsx("ul",{className:"bim-d-chap",children:ie.map(T=>{const[fe,be]=Or(T.title);return t.jsx("li",{children:Q(ze(T.file),t.jsxs(t.Fragment,{children:[fe&&t.jsx("b",{children:h(fe)}),h(be||T.file)]}))},T.file)})}),q.length>ie.length&&t.jsx(Fo,{label:u("detail.expandRest",{n:q.length-ie.length,unit:le}),onClick:()=>S(!0)}),W.text.length>0&&t.jsxs(t.Fragment,{children:[(q.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:u("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:W.text.map((T,fe)=>t.jsx(xs,{item:T,siblings:W.text,listedVolumeCounts:ne},`${T.id||T.url||T.name}-${fe}`))})})]})]}),W.groups.length>0&&t.jsx(ht,{id:"images",title:Ne,meta:t.jsx(ft,{items:[W.groups.length>1?u("bookPage.groupCount",{n:W.groups.length}):"",u("bookPage.placeCount",{n:G})]}),children:t.jsx(lp,{groups:W.groups,listedVolumeCounts:ne})}),H&&t.jsx(ht,{id:"lineage",title:u("bookPage.sec.lineage"),meta:(Ye=O==null?void 0:O.derived_from)!=null&&Ye.length?u("bookPage.lineageMeta"):void 0,action:z?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":u("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":_==="flow",onClick:()=>R("flow"),children:u("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":_==="graph",onClick:()=>R("graph"),children:u("bookPage.viewGraph")})]}):void 0,children:_==="graph"&&z?t.jsx(bs,{graph:z,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(T,fe)=>t.jsx(pt,{id:T,label:h(fe),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(M0,{data:e,heading:he||Ae,yearText:$e,refName:ue,onNavigate:i,renderLink:o})}),Me.length>0&&t.jsx(ht,{id:"collections",title:u("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:Me.map((T,fe)=>{const be=T.id,Le=qn(T.vol),V=b.get(be),M=Gm(V);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(pt,{id:be,label:V?h(V.title):be,onNavigate:i,renderLink:o,dense:!0}),Le.length>0&&t.jsx(A0,{volumes:Le,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${M?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:M>0&&u("bookPage.totalOf",{n:M,unit:m.unit.bu})})]},`${be}-${fe}`)})})})}),(it=e.location_history)!=null&&it.length?t.jsx(ht,{id:"provenance",title:u("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((T,fe)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:h(T.name)}),([T.start_date,T.end_date].filter(Boolean).join("—")||T.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(ft,{items:[[T.start_date,T.end_date].filter(Boolean).join("—"),T.description?h(T.description):""]})})]},fe))})}):null,Z.length===0&&t.jsx(ht,{title:u("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("bookPage.emptyText")})})]}),we=y.findIndex(T=>T.id===e.id),He=I.length<=Nl,Ke=He&&we>=0?y.slice(Math.max(0,we-Tl),we+Tl+1):y.filter(T=>T.id!==e.id),Qe=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:h(m.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(pt,{id:x.id,label:h(x.title),onNavigate:i,renderLink:o})}),t.jsx(ft,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(T=>`${T.dynasty?`〔${h(T.dynasty)}〕`:""}${h(T.name)}`),h(Kt(x,m.unit.juan)),x._edition_count?u("bookPage.editionCount",{n:x._edition_count}):""]}),((st=x.description)==null?void 0:st.text)&&t.jsx("p",{style:{fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc bim-d-side-desc",children:h(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),B>0&&Ke.length>0&&t.jsxs("div",{children:[t.jsx(pn,{id:"siblings",timeline:!0,title:He?u("bookPage.siblings"):m.relation.siblingVersions,meta:He?u("bookPage.byEra"):u("bookPage.kindCount",{n:B}),cap:Ke.length,items:Ke.map(T=>T.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:h(T.edition||T.title||T.id)}):t.jsx(pt,{id:T.id,label:h(T.edition||T.title||T.id),onNavigate:i,renderLink:o,dense:!0})),metas:Ke.map(T=>[T.year!=null?T.year<0?u("detail.bce",{n:-T.year}):String(T.year):"",T.id===e.id?u("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:Ke.findIndex(T=>T.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(pt,{id:x.id,label:u("bookPage.viewAllInWork",{n:I.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),U=e.work_id?t.jsx(Gc,{caption:m.section.belongsToWork,children:t.jsx(pt,{id:e.work_id,label:x?h(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(ii,{railTop:c,back:p,up:U,nav:Z,railLinks:g,main:X,card:L,side:Qe})};function A0({volumes:e,unit:n}){const{t:i}=ae();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Vi(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),i("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function M0({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var $;const{t:l,convert:d}=ae(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],g=p.filter(y=>y.ref_type!=="book"),m=p.filter(y=>y.ref_type==="book"&&y.relation==="底本"),u=p.filter(y=>y.ref_type==="book"&&y.relation!=="底本"),h=(c==null?void 0:c.related_to)||[],x=p.length>0||h.length>0,j=y=>y&&L0.has(y)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${y}`)}):"",b=(y,k)=>t.jsx(pt,{id:y,label:d(k||y),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:[g.map((y,k)=>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:y.relation?d(y.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),y.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(y.evidence),j(y.confidence)]})]})},`a-${k}`)),m.map((y,k)=>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(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,o(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(y.evidence),j(y.confidence)]})]})},`b-${k}`)),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}),i&&t.jsx("span",{className:"bim-d-lf-yr",children:d(i)})]}),u.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:u.map((y,k)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,o(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(y.evidence),j(y.confidence)]})]},k))})]}),h.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:h.map((y,k)=>t.jsxs("span",{className:"bim-d-lf-chip",title:y.evidence?d(y.evidence):void 0,children:[b(y.book_id,o(y.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(y.relation)})]},k))})]})]}),($=e.appendix)==null?void 0:$.map((y,k)=>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(y.title)]}),t.jsx(qt,{text:y.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${k}`)),(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 Gn=16,P0=200,B0=16,gp=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var we,He,Ke,Qe,U,me,Re;const{t:p,convert:g,messages:m}=ae(),[u,h]=f.useState(""),[x,j]=f.useState(!1),[b,$]=f.useState(null),[y,k]=f.useState(""),[w,v]=f.useState(!1),C=f.useMemo(()=>sc(e,n),[e,n]),S=f.useMemo(()=>oc(e),[e]),[_,R]=f.useState(new Map),z=!!i&&C.rows.length>0&&C.rows.length<=P0,N=z&&(C.rows.length<=Gn||w),I=N&&C.rows.every(D=>!D.id||_.has(D.id)),B=D=>{var je;return go(D?(je=_.get(D))==null?void 0:je.l1:void 0)},O=f.useMemo(()=>{const D=u.trim(),je=D?g(D):"";return C.rows.filter(te=>{var Be,Ge;if(y&&go(te.id?(Be=_.get(te.id))==null?void 0:Be.l1:void 0)!==y)return!1;if(!je)return!0;const _e=te.id&&((Ge=_.get(te.id))==null?void 0:Ge.title)||te.title;return g(_e).includes(je)||(te.subItems||[]).some(Ye=>g(Ye).includes(je))})},[C.rows,u,y,_,g]),A=x?O:O.slice(0,Gn),W=f.useMemo(()=>(N?C.rows:A).filter(D=>D.id&&!_.has(D.id)).map(D=>D.id),[N,C.rows,A,_]);f.useEffect(()=>{if(!i||W.length===0)return;let D=!1;const je=W.slice(0,B0);return tr(je,er,te=>i.getItem(te).then(_e=>{var Ye,it;const Be=_e??{},Ge={title:Be.title,edition:Be.edition,authors:Be.authors,measure:_e?Kt(_e,m.unit.juan):void 0,versionCount:Be._edition_count??((Ye=Be._books)==null?void 0:Ye.length),l1:((it=Io(Be))==null?void 0:it.l1)||void 0};return[te,Ge]}).catch(()=>[te,{}]),()=>D).then(te=>{D||R(_e=>{const Be=new Map(_e);for(const[Ge,Ye]of te)Be.set(Ge,Ye);return Be})}),()=>{D=!0}},[i,W,m.unit.juan]);const G=(we=(e.contained_in||[])[0])==null?void 0:we.id;f.useEffect(()=>{if(!G){$(null);return}if($({id:G}),!i)return;let D=!1;return i.getItem(G).then(je=>{D||$({id:G,title:je==null?void 0:je.title})}).catch(()=>{}),()=>{D=!0}},[i,G]);const oe=f.useMemo(()=>sp(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),se=oe.text.length+oe.groups.reduce((D,je)=>D+je.rows.length+je.mirrors.length,0),Y=S.works,de=new Set(C.rows.map(D=>D.id).filter(Boolean)),ne=Y.length>0&&!Y.every(D=>de.has(D.id)),ue=(()=>{const D=C.rows.map(je=>je.edition).filter(Boolean);return D.length>1&&new Set(D).size===1})(),ke=C.rows.some(D=>D.volumes.length>0||D.expected!=null),Ae=S.total,he=S.truncated?Ae:C.rows.length,$e=Kt(e,m.unit.juan),L=e.count,Me=D=>typeof D=="number"&&Number.isFinite(D)?D:null,q=Me(L==null?void 0:L.juan)??Me((He=e.juan_count)==null?void 0:He.number),le=Me(L==null?void 0:L.ce)??(C.totalVolumes||null),ge=[{value:he,label:p("collectionPage.stat.titles")},{value:q??0,label:m.unit.juan},{value:le??0,label:m.unit.volume}],H=f.useMemo(()=>{var te,_e;const D=[];if((te=e.publication_info)!=null&&te.details&&D.push({label:p("collectionPage.fact.publication"),value:g(e.publication_info.details)}),Ae&&(Ae!==C.rows.length||S.truncated)){const Be=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");D.push({label:Be,value:`${Ae} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const je=[Me(L==null?void 0:L.zhong)!=null?p("collectionPage.nZhong",{n:L.zhong}):"",Me(L==null?void 0:L.han)!=null?p("collectionPage.nHan",{n:L.han}):""].filter(Boolean);return je.length&&D.push({label:p("collectionPage.fact.expected"),value:je.join(" ")}),q==null&&$e&&D.push({label:p("collectionPage.fact.measure"),value:g($e),title:(_e=e.juan_count)!=null&&_e.description?g(e.juan_count.description):void 0}),D},[e,Ae,S.truncated,C.rows.length,q,$e,L,g,p,m]),Z=f.useMemo(()=>{if(!I)return[];const D=new Map;for(const te of C.rows){const _e=B(te.id);_e&&D.set(_e,(D.get(_e)??0)+1)}const je=Jn.filter(te=>(D.get(te.key)??0)>0);return je.length<2?[]:[{key:"",label:`${m.catalog.all} ${he}`},...je.map(te=>({key:te.key,label:`${te.label} ${D.get(te.key)}`}))]},[I,C.rows,_,m]),Ne=f.useMemo(()=>{if(!I||!C.rows.some(_e=>_e.volumes.length>0))return null;const D=[],je=C.rows.filter(_e=>_e.volumes.length>0).map(_e=>({k:B(_e.id)??"",from:Math.min(..._e.volumes),to:Math.max(..._e.volumes)})).sort((_e,Be)=>_e.from-Be.from);for(const _e of je){const Be=_e.to-_e.from+1,Ge=D[D.length-1];Ge&&Ge.key===_e.k?(Ge.to=Math.max(Ge.to,_e.to),Ge.n+=Be):D.push({key:_e.k,from:_e.from,to:_e.to,n:Be})}const te=je.reduce((_e,Be)=>Math.max(_e,Be.to),0);return D.length>1&&D.some(_e=>_e.key)?{segs:D,last:te}:null},[I,C.rows,_]),ze=(Ke=e.description)==null?void 0:Ke.text,Fe=t.jsx(ri,{kind:p("collectionPage.kind"),title:g(e.title),byline:t.jsx(hs,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(ft,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Qe=e.publication_info)!=null&&Qe.year?g(e.publication_info.year):""]}),description:ze||(U=e.history)!=null&&U.length?t.jsxs(t.Fragment,{children:[ze&&t.jsx(qt,{text:ze,style:{fontSize:15,lineHeight:1.85}}),(me=e.history)!=null&&me.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((D,je)=>t.jsx("li",{children:g(D)},je))}):null]}):void 0,clampDescription:Ho(ze)||(((Re=e.history)==null?void 0:Re.length)??0)>2?6:void 0,stats:ge,facts:H,foot:t.jsx(oi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:Ne&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:p("collectionPage.dist.head")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":p("collectionPage.dist.head"),children:Ne.segs.map((D,je)=>{const te=Jn.find(_e=>_e.key===D.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!te,title:te?p("collectionPage.dist.segTitle",{section:g(te.label),from:D.from,to:D.to}):void 0,"aria-label":te?p("collectionPage.dist.only",{section:g(te.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!te&&y===D.key,style:{flexGrow:D.n,background:r(te?te.token:"rule")},onClick:()=>{te&&(k(y===D.key?"":D.key),j(!1))}},je)})}),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:Ne.last})})]})]})}),P=[];C.rows.length&&P.push({id:"titles",label:p("collectionPage.sec.titles"),count:he}),se&&P.push({id:"resources",label:p("collectionPage.sec.resources"),count:se}),ne&&P.push({id:"works",label:m.section.containedWorks,count:Y.length});const ie=t.jsxs(t.Fragment,{children:[C.rows.length>0&&t.jsxs(ht,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(ft,{items:[`${he} ${m.unit.items}`,C.totalVolumes?p("collectionPage.totalVolumes",{n:C.totalVolumes,unit:m.unit.volume}):"",O.length!==he?p("collectionPage.currentN",{n:O.length,unit:m.unit.items}):""]}),action:a,children:[(C.rows.length>Gn||Z.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Z.length>0&&t.jsx(Xi,{items:Z,value:y,onChange:D=>{k(D),j(!1)}}),z&&C.rows.length>Gn&&!I&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:w,onClick:()=>v(!0),title:p("collectionPage.loadAllTitle",{n:C.rows.length,unit:m.unit.items}),children:p(w?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),C.rows.length>Gn&&t.jsx("input",{type:"search",className:"bim-d-find",value:u,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:D=>{h(D.target.value),j(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Zi(O.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[ke&&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:A.map((D,je)=>{var st;const te=D.id?_.get(D.id):void 0,_e=te!=null&&te.title&&D.title===D.id?te.title:D.title,Be=((te==null?void 0:te.authors)||[]).find(T=>T&&T.name),Ge=[Be?`${Be.dynasty?`〔${g(Be.dynasty)}〕`:""}${g(Be.name)}${Be.role?` ${g(Be.role)}`:""}`:"",te!=null&&te.measure?g(te.measure):"",(st=D.subItems)!=null&&st.length?D.subItems.map(T=>g(T)).join("、"):"",(te!=null&&te.edition||D.edition)&&!ue?g((te==null?void 0:te.edition)||D.edition||""):""].filter(Boolean),Ye=Jn.find(T=>T.key===B(D.id)),it=D.volumes.length>0?p("collectionPage.volumeRange",{range:Vi(D.volumes,m.unit.volume),unit:m.unit.volume}):D.expected!=null?`${D.found??0}/${D.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[ke&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${it?"":" bim-d-zt-blank"}`,children:[Ye&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(Ye.token)}}),it||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[D.id?t.jsx(pt,{id:D.id,label:g(_e),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:g(_e)}),Ge.length>0?t.jsx(ft,{items:Ge}):D.id&&!te&&i?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${te!=null&&te.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:te!=null&&te.versionCount?p("collectionPage.nZhong",{n:te.versionCount}):""})]},`${D.id??D.title}-${je}`)})})]}),A.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(Wo,{total:O.length,shown:A.length,unit:m.unit.items,onClick:()=>j(!0)})]}),se>0&&t.jsxs(ht,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:se}),children:[oe.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[oe.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:oe.text.map((D,je)=>t.jsx(xs,{item:D,siblings:oe.text},`${D.id||D.url||D.name}-${je}`))})})]}),t.jsx(lp,{groups:oe.groups})]}),C.rows.length===0&&se===0&&t.jsx(ht,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),Q=ne?t.jsx(pn,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:Y.length}),cap:12,items:Y.map(D=>t.jsx(pt,{id:D.id,label:g(D.title),onNavigate:o,renderLink:s,dense:!0}))}):null,X=b?t.jsx(Gc,{caption:p("collectionPage.parent"),children:t.jsx(pt,{id:b.id,label:g(b.title||b.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(ii,{railTop:l,back:d,up:X,nav:P,railLinks:c,main:ie,card:Fe,side:Q})},O0=8;function fp(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function W0(e){return(e||[]).filter(n=>{var i,o;return fp(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,O0)}function F0({images:e,assetBase:n,name:i}){const{t:o,convert:s}=ae(),[a,l]=f.useState(0),[d,c]=f.useState(!1),p=n?W0(e):[];if(!n||d||p.length===0)return null;const g=n.endsWith("/")?n:n+"/",m=p[Math.min(a,p.length-1)],u=m.width&&m.height&&m.width>0&&m.height>0?`${m.width} / ${m.height}`:void 0,h=x=>g+fp(x.file).split("/").map(encodeURIComponent).join("/");return t.jsxs("figure",{className:"bim-d-seal bim-d-ui",children:[t.jsx("img",{className:"bim-d-seal-main",src:h(m),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:u?{"--seal-ar":u}:void 0,width:m.width,height:m.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},m.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,j)=>t.jsx("button",{type:"button","aria-pressed":j===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${j+1}`,onClick:()=>l(j),children:t.jsx("img",{src:h(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(m.credit)})," · ",o("entityPage.imgLicense",{license:s(m.license)}),m.source_url&&/^https?:\/\//i.test(m.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:m.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),m.note&&t.jsxs(t.Fragment,{children:[" · ",s(m.note)]})]})]})}const H0=16,Wr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function Rl(e){if(!e)return Wr.length;const n=Wr.indexOf(e);return n===-1?Wr.length:n}function D0(e,n,i){if(n)return e[n]??i(n)}function U0(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const V0={秦:[-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]},hp=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var X,we,He,Ke,Qe;const{t:c,convert:p,messages:g}=ae(),m=U=>U0(U,c),[u,h]=f.useState("全部"),[x,j]=f.useState(!1),[b,$]=f.useState("default"),[y,k]=f.useState(new Map),w=f.useMemo(()=>e._works||[],[e._works]),v=f.useMemo(()=>w.map(U=>{const me=y.get(U.work_id);return{id:U.work_id,title:(me==null?void 0:me.title)??U.title??U.work_id,role:U.role||"",cls:No(U.role),versionCount:me==null?void 0:me.versionCount,section:me==null?void 0:me.cls,l1:me==null?void 0:me.l1,measure:me==null?void 0:me.measure,hasImage:me==null?void 0:me.hasImage,loaded:!!(me!=null&&me.loaded)}}),[w,y]),C=f.useMemo(()=>rc(w.map(U=>U.role),c("detail.roleAll")),[w,c]),S=f.useMemo(()=>{const U=u==="全部"?v:v.filter(me=>me.cls===u);return b==="versions"?[...U].sort((me,Re)=>(Re.versionCount??-1)-(me.versionCount??-1)):U},[v,u,b]),_=x?S:S.slice(0,H0),R=f.useMemo(()=>_.filter(U=>!y.has(U.id)).map(U=>U.id),[_,y]);f.useEffect(()=>{if(!n||R.length===0)return;let U=!1;return tr(R,er,me=>n.getItem(me).then(Re=>{var Be;const D=Re??{},je=D._edition_count??((Be=D._books)==null?void 0:Be.length)??0,te=Io(D),_e=[te==null?void 0:te.l1,te==null?void 0:te.l2].filter(Boolean).join(" ");return[me,{id:me,title:D.title,versionCount:je,loaded:!0,cls:_e||void 0,l1:(te==null?void 0:te.l1)||void 0,measure:Re&&Kt(Re,g.unit.juan)||void 0,hasImage:!!D._has_image}]}).catch(()=>[me,{id:me,loaded:!0}]),()=>U).then(me=>{U||k(Re=>{const D=new Map(Re);for(const[je,te]of me)D.set(je,te);return D})}),()=>{U=!0}},[n,R,g.unit.juan]);const z=f.useMemo(()=>{const U=new Map;for(const me of e.alt_names||[]){const Re=me.type||g.section.aliases;U.has(Re)||U.set(Re,[]),U.get(Re).push(me.name)}return[...U.entries()].sort((me,Re)=>Rl(me[0])-Rl(Re[0])).map(([me,Re])=>({label:me,names:Re}))},[e.alt_names,g]),N=((X=e.dates)==null?void 0:X.birth)??void 0,I=((we=e.dates)==null?void 0:we.death)??void 0,B=(He=e.dates)==null?void 0:He.floruit,O=N!=null||I!=null?`${m(N)||"?"}—${m(I)||"?"}`:Array.isArray(B)&&B.length===2&&B.every(U=>Number.isFinite(U))?c("entityPage.floruit",{from:m(B[0]),to:m(B[1])}):"",A=new Set(["本名","字","號","号"]),W=z.filter(U=>A.has(U.label)),G=z.filter(U=>!A.has(U.label)),oe=G.reduce((U,me)=>U+me.names.length,0),se=f.useMemo(()=>{const U=[];for(const Re of W)U.push({label:Re.label,value:Re.names.map(D=>p(D)).join("、")});const me=w.length;return me&&U.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:me})}),U},[w,W,p,c]),Y=U=>{var me;return(me=z.find(Re=>U.includes(Re.label)))==null?void 0:me.names[0]},de=Y(["字"]),ne=Y(["號","号"]),ue=[de?c("entityPage.zi",{name:p(de)}):"",ne?c("entityPage.hao",{name:p(ne)}):""].filter(Boolean).join(","),ke=e.native_place,Ae=e.dynasty?V0[e.dynasty]:void 0,he=(()=>{if(!Ae||N==null||I==null||I<N)return null;const[U,me]=Ae,Re=Math.max(N,U),D=Math.min(I,me);if(D<=Re)return null;const je=me-U;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":c("entityPage.lifeAria",{birth:m(N),death:m(I),years:I-N+1}),children:t.jsx("i",{style:{left:`${(Re-U)/je*100}%`,width:`${(D-Re)/je*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${m(U)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:I-N+1})}),t.jsx("span",{children:m(me)})]})]})})(),$e=f.useMemo(()=>{if(!n||v.length===0||v.some(Re=>!Re.loaded))return null;const U=new Map;for(const Re of v){const D=go(Re.l1);D&&U.set(D,(U.get(D)??0)+1)}const me=Jn.map(Re=>({...Re,n:U.get(Re.key)??0})).filter(Re=>Re.n>0);return me.length?me:null},[v,n]),L=t.jsxs(ri,{kind:D0(g.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:ue||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(ft,{items:[e.dynasty?p(e.dynasty):"",O,ke?c("entityPage.nativePlace",{place:p(ke)}):""]}),he,t.jsx(F0,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(Ke=e.description)!=null&&Ke.text?t.jsx(qt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Ho((Qe=e.description)==null?void 0:Qe.text)?6:void 0,facts:se,foot:t.jsx(oi,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[oe>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:oe})}),t.jsx("dl",{children:G.map(U=>t.jsxs(f.Fragment,{children:[t.jsx("dt",{children:p(U.label)}),t.jsx("dd",{children:U.names.map(me=>p(me)).join("、")})]},U.label))})]}),$e&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:c("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:$e.map(U=>t.jsx("i",{style:{flexGrow:U.n,background:r(U.token)}},U.key))}),t.jsx("div",{className:"bim-d-dist-key",children:$e.map(U=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(U.token)}}),p(U.label)," ",U.n]},U.key))})]})]}),Me=f.useMemo(()=>v.filter(U=>U.loaded&&(U.versionCount??0)>0).sort((U,me)=>(me.versionCount??0)-(U.versionCount??0)).slice(0,3),[v]),q=!!n&&v.length>=3&&_.some(U=>!U.loaded),le=u==="全部"&&(q||Me.length>=2),ge=e.external_ids||{},H=[];ge.cbdb_id!=null&&H.push({label:"CBDB",id:String(ge.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ge.cbdb_id}`,note:ge.cbdb_match==="auto"?c("entityPage.autoMatch"):void 0});const Z=ge.wikidata_id;Z&&H.push({label:"Wikidata",id:Z,href:`https://www.wikidata.org/wiki/${Z}`});const Ne=ge.viaf_id;Ne&&H.push({label:"VIAF",id:Ne,href:`https://viaf.org/viaf/${Ne}`});const ze=C.map(U=>({key:U.cls,label:`${U.label} ${U.count}`})),Fe=[...le&&!q?[{id:"featured",label:c("entityPage.sec.featured"),count:Me.length}]:[],...v.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:v.length}]:[],...H.length?[{id:"external",label:c("entityPage.sec.external"),count:H.length}]:[]],P=le?t.jsxs(ht,{id:"featured",title:c("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:c("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":q||void 0,children:[q&&[0,1,2].map(U=>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:" "})]},U)),!q&&Me.map(U=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(pt,{id:U.id,label:p(U.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(ft,{items:[U.section?p(U.section):"",U.measure?p(U.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:U.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),U.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},U.id))]})]}):null,ie=v.length===0?t.jsx(ht,{title:c("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[P,t.jsxs(ht,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(ft,{items:[c("entityPage.total",{n:v.length}),S.length!==v.length?c("entityPage.current",{n:S.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[ze.length>1&&t.jsx(Xi,{items:ze,value:u,onChange:U=>{h(U),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":b==="versions",onClick:()=>{b==="default"&&j(!0),$(U=>U==="default"?"versions":"default")},children:c(b==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Zi(S.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("entityPage.col.work")}),t.jsx("th",{children:c("entityPage.col.section")}),t.jsx("th",{children:c("entityPage.col.role")}),t.jsx("th",{children:c("entityPage.col.versions")}),t.jsx("th",{"aria-label":c("entityPage.col.image")})]})}),t.jsx("tbody",{children:_.map(U=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(pt,{id:U.id,label:p(U.title),onNavigate:i,renderLink:o,dense:!0}),U.measure?t.jsx(ft,{items:[p(U.measure)]}):!U.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${U.section||U.loaded?"":" bim-d-zt-blank"}`,children:U.section?p(U.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${U.role?"":" bim-d-zt-blank"}`,children:U.role?p(U.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${U.loaded?"":" bim-d-zt-blank"}`,children:U.loaded?U.versionCount?c("entityPage.nZhong",{n:U.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:U.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:U.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},U.id))})]}),_.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("entityPage.emptyRole")}),!x&&t.jsx(Wo,{total:S.length,shown:_.length,unit:c("entityPage.moreUnit"),onClick:()=>j(!0)})]})]}),Q=H.length>0?t.jsx(pn,{id:"external",title:c("entityPage.sec.external"),items:H.map(U=>t.jsxs("a",{href:U.href,target:"_blank",rel:"noopener noreferrer",children:[U.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:H.map(U=>U.id),foot:ge.cbdb_id!=null&&ge.cbdb_match==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(ii,{railTop:s,back:a,nav:Fe,railLinks:l,main:ie,card:L,side:Q})},ys="(max-width: 719px)",G0=`${ys}, (pointer: coarse)`,xp=`
|
|
1472
|
+
${n??""}`,[a,l]=f.useState({tag:"",spans:[]}),d=f.useRef(0);return f.useEffect(()=>{const c=++d.current,p=m=>{c===d.current&&l({tag:s,spans:m})};if(!e||!n){p([]);return}let g;try{g=e(n,i)}catch{p([]);return}Promise.resolve(g).then(m=>p(m?vd(m):[]),()=>p([]))},[e,n,i,s]),a.tag===s?a.spans:rb}const rb=[],ob=/^#{1,6}$/,sb=/^([^《》]*)《([^《》]+)》\s*(?:[〇零一二三四五六七八九十百千]+|不分|無|无)卷/;function ab(e){let n=e.trim();const i=sb.exec(n);return i&&(n=i[1]+i[2]),n.replace(/[《》〈〉]/g,"").trim()}const Qa=e=>e.kind==null||e.kind==="point";function Bd(e,n){var d;if(!e||!n||n.length===0)return[];const i=new Map;let o=!1;for(const c of n){c.kind==="heading"&&(o=!0);const p=i.get(c.anchor);p?p.push(c):i.set(c.anchor,[c])}if(!o)return[];const s=[];let a=null;const l=()=>{a&&(a.fixed||(a.h.label=ab(a.text)),a.h.label&&s.push(a.h)),a=null};for(const c of e){const p=[...c.columns].sort((g,m)=>g.col-m.col);for(const g of p)for(const m of g.chars){const u=i.get(m.id)??[],h=u.find(x=>x.kind==="heading"&&x.pos==="before"&&ob.test(x.mark));if(h&&l(),h&&h.toc!==!1){const x=(d=h.label)==null?void 0:d.trim();a={h:{level:h.mark.length,label:x??"",anchor:m.id},text:"",fixed:!!x}}if(a&&!a.fixed){for(const x of u)Qa(x)&&x.pos==="before"&&(a.text+=x.mark);a.text+=m.char;for(const x of u)Qa(x)&&x.pos!=="before"&&(a.text+=x.mark)}u.some(x=>x.kind==="break"&&x.pos!=="before")&&l()}}return l(),s}function po(e){if(!Array.isArray(e))return[];const n=[];for(const i of e){if(!i||typeof i!="object")continue;const{level:o,label:s,anchor:a}=i;typeof o!="number"||!Number.isInteger(o)||o<1||o>6||typeof s!="string"||!s.trim()||typeof a!="string"||!a||n.push({level:o,label:s.trim(),anchor:a})}return n}function gs(e,n){return`${e}#${n}`}function Od(e){const n=e.indexOf("#");return n<=0||n===e.length-1?null:{chapter:e.slice(0,n),anchor:e.slice(n+1)}}function Wd(e){const n=[],i=[];for(const o of e){const s={...o,children:[]};for(;i.length>0&&i[i.length-1].level>=o.level;)i.pop();i.length===0?n.push(s):i[i.length-1].children.push(s),i.push(s)}return n}function Ri(e){return!!e&&!e.has_json&&typeof e.char_file=="string"&&!!e.char_file&&typeof e.cord_file=="string"&&!!e.cord_file}const lb=150,el={padding:24,color:r("desc-fg"),fontSize:14};function tl({title:e,label:n,className:i,style:o}){const s=(a,l=14,d=14)=>({width:a,height:l,marginTop:d,borderRadius:3,background:r("rule")});return t.jsxs("div",{className:i,style:{...o,padding:"20px 24px",maxWidth:760,margin:"0 auto"},"aria-busy":"true",children:[e&&t.jsx("div",{style:{fontSize:15,color:r("ink"),fontFamily:r("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:r("desc-fg"),fontSize:14,fontFamily:r("font-ui")},children:n})]})}const nl=/^https?:\/\//i,cb=[];function db(e){if(!e||typeof e!="object")return null;const n=a=>typeof a=="string"&&a.trim()?a.trim():void 0,i=n(e.url),o=n(e.license_url),s={name:n(e.name),url:i&&nl.test(i)?i:void 0,license:n(e.license),license_url:o&&nl.test(o)?o:void 0,note:n(e.note)};return s.name||s.license||s.note?s:null}function pb(e,n){return{work_id:n.work_id??e,title:n.title,type:n.type,juan_files:n.chapters.map(i=>i.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 il(e,n){return(n==null?void 0:n.type)==="kaozhen"?"章":n!=null&&n.juan_metadata&&Object.values(n.juan_metadata).some(i=>i.vol_label)||Array.isArray(n==null?void 0:n.heading_levels)&&n.heading_levels.length>0?"冊":Re.isCollatedKind(e==null?void 0:e.kind)?"卷":"章"}function Fd(e,n,i,o=!1){const s=i(`${n}${e.n}`);if(!e.title)return s;const a=i(e.title);return o&&!/^[卷冊册章篇回第]/.test(e.title)?`${s} ${a}`:a}function Hd(e,n,i){return n.map(o=>({key:gs(e,o.anchor),label:i(o.label),inChapter:!0,...o.children.length>0?{selectable:!0,children:Hd(e,o.children,i)}:{}}))}function ub(e,n,i,o,s,a=()=>[]){var g;const l=new Map(e.chapters.map(m=>[m.file,m])),d=m=>m==="loading"?"…":typeof m=="number"&&m>0?m:void 0,c=(m,u)=>{const h=l.get(m),x=h?a(h):[];return{key:m,label:u??(h?Fd(h,i,o,s):m),hint:d(n[m]),disabled:n[m]===0,...x.length>0?{selectable:!0,children:Hd(m,Wd(x),o)}:{}}},p=(g=e.juan_groups)==null?void 0:g.filter(m=>{var u;return m.files.some(h=>l.has(h))||((u=m.children)==null?void 0:u.length)});if(p&&p.length>0){const m=(u,h)=>{var j;if(u.files.length===1&&!((j=u.children)!=null&&j.length))return c(u.files[0],o(u.label));const x=tx(u,n);return{key:`group:${h}`,label:o(u.label),hint:x==="loading"?"…":typeof x=="number"&&x>0?`${x}`:_d(u),defaultExpanded:typeof x=="number"&&x>0,children:[...u.files.filter(b=>l.has(b)).map(b=>c(b)),...(u.children??[]).map((b,S)=>m(b,`${h}.${S}`))]}};return p.map((u,h)=>m(u,`${h}`))}return e.chapters.map(m=>c(m.file))}const fs=e=>{const n=Bc();return t.jsx(km,{mode:n[0].scriptMode,children:t.jsx(mb,{...e,prefsState:n})})},mb=({prefsState:e,id:n,transport:i,versionKey:o,chapter:s,onLocationChange:a,onNavigate:l,anchor:d,title:c,subtitle:p,settingsExtra:g,settingsExtraTitle:m,resolveImages:u,renderImageOverlay:h,imagePanel:x,facsimileTrimmed:j,allowVertical:b,onReportError:S,revisedAt:y,backHref:k,backLabel:w,resolveWarpData:v,warpData:C,resolveEntities:_,onEntityNavigate:$,className:A,style:R})=>{var Gs,Ys,Ks;const{t:z,convert:N}=ae(),M=f.useMemo(()=>Nc(i),[i]),[O,L]=e,D=gt(),q=f.useRef(a);q.current=a;const[J,se]=f.useState(null),[U,K]=f.useState("loading");f.useEffect(()=>{let E=!1;return se(null),K("loading"),M.getManifest(n).then(ie=>{E||(ie?(se(ie),K("ready")):K("missing"))}).catch(()=>{E||K("missing")}),()=>{E=!0}},[M,n]);const Z=o!==void 0,oe=s!==void 0,[ye,Le]=f.useState(null),[Me,Se]=f.useState(null);f.useEffect(()=>{Le(null),Se(null)},[n]);const le=Re.pickTextVersion(J,Z?o:ye),Oe=((Gs=J==null?void 0:J.versions.find(E=>E.key==="default"))==null?void 0:Gs.key)??((Ys=J==null?void 0:J.versions[0])==null?void 0:Ys.key)??"default",T=(le==null?void 0:le.key)??null,de=oe?s:Me,pe=f.useCallback((E,ie,Te,rt)=>{var Ze;(Ze=q.current)==null||Ze.call(q,{key:E,chapter:ie,isDefault:E===Oe,...rt?{anchor:rt}:{}},Te)},[Oe]);f.useEffect(()=>{!J||!Z||o==null||J.versions.some(E=>E.key===o)||pe(Oe,null,"auto")},[J,Z,o,Oe,pe]);const B=f.useRef(new Map);f.useEffect(()=>{B.current.clear()},[M,n]);const ee=f.useCallback(async E=>{const ie=`${n}
|
|
1473
|
+
${E}`;if(B.current.has(ie))return B.current.get(ie)??null;const Te=await M.getIndex(n,E).catch(()=>null);return Te&&B.current.set(ie,Te),Te},[M,n]),[Ce,Ie]=f.useState(null),[We,G]=f.useState("loading"),he=T?`${n}
|
|
1474
|
+
${T}`:null,te=Ce&&Ce.owner===he?Ce.idx:null;f.useEffect(()=>{if(!T)return;let E=!1;const ie=`${n}
|
|
1475
|
+
${T}`;return Ie(null),G("loading"),ee(T).then(Te=>{E||(Te&&Te.chapters.length>0?(Ie({owner:ie,idx:Te}),G("ready")):G("failed"))}),()=>{E=!0}},[n,T,ee]),f.useEffect(()=>{if(!te||!T||de!=null&&te.chapters.some(Te=>Te.file===de))return;const ie=te.chapters[0].file;oe||Se(ie),pe(T,ie,"auto")},[te,T,de,oe,pe]);const H=te?de!=null&&te.chapters.some(E=>E.file===de)?de:te.chapters[0].file:de,ue=f.useMemo(()=>te&&H?te.chapters.find(E=>E.file===H)??null:null,[te,H]),Fe=f.useRef(0),Ge=f.useCallback(async E=>{if(!J||E===T||!J.versions.some(It=>It.key===E))return;const ie=++Fe.current,Te=await ee(E);if(ie!==Fe.current)return;const rt=ue??(H?{file:H}:null),Ze=Re.matchChapterAcrossVersions(rt,Te);Z||Le(E),oe||Se(Ze),pe(E,Ze,"version")},[J,T,ee,ue,H,Z,oe,pe]),[Je,F]=f.useState(null),[ge,Ae]=f.useState(null),W=f.useRef(0),be=f.useCallback((E,ie)=>{F({chapter:E,anchor:ie,nonce:++W.current}),Ae({chapter:E,anchor:ie})},[]),ce=f.useCallback(E=>{if(!T)return;const ie=Od(E);if(ie){be(ie.chapter,ie.anchor),oe||Se(ie.chapter),pe(T,ie.chapter,"chapter",ie.anchor);return}oe||Se(E),pe(T,E,"chapter")},[T,oe,pe,be]),Ne=f.useRef(null);f.useEffect(()=>{!d||!H||d===Ne.current||(Ne.current=d,be(H,d))},[d,H,be]),f.useEffect(()=>{d||(Ne.current=null)},[d]);const[$e,Ke]=f.useState(null),Qe=T&&ue?`${n}
|
|
1476
|
+
${T}
|
|
1477
|
+
${ue.file}`:null,[it,nt]=f.useState(null),I=Qe!==null&&it!==Qe,fe=f.useRef(0);f.useEffect(()=>{if(!T||!ue)return;const E=++fe.current,ie=`${n}
|
|
1478
|
+
${T}
|
|
1479
|
+
${ue.file}`;if(Ke(null),Ri(ue)){nt(ie);return}M.getChapter(n,T,ue.file,{json:!!ue.has_json}).then(Te=>{E===fe.current&&Ke(Te)}).catch(()=>{E===fe.current&&Ke(null)}).finally(()=>{E===fe.current&&nt(ie)})},[M,n,T,ue]);const xe=Re.isCollatedKind(le==null?void 0:le.kind),[ze,V]=f.useState("");f.useEffect(()=>{V("")},[n,T]);const P=f.useMemo(()=>T&&xe?async E=>{const ie=await M.getChapter(n,T,E,{json:!0});return{juan:(ie==null?void 0:ie.json)??null,rawText:(ie==null?void 0:ie.md)??null}}:null,[M,n,T,xe]),X=(te==null?void 0:te.type)==="kaozhen",je=f.useMemo(()=>(te==null?void 0:te.chapters.map(E=>E.file))??[],[te]),{matchStates:Y}=gx({resetKey:`${n}
|
|
1480
|
+
${T??""}`,load:P,files:je,activeFile:H??null,activeJuan:($e==null?void 0:$e.json)??null,activeRawText:($e==null?void 0:$e.md)??null,query:ze,isKaozhen:X}),me=f.useRef(new Map);f.useEffect(()=>{me.current.clear()},[n]);const _e=f.useMemo(()=>({versionKey:T,chapter:ue??null}),[T,ue]),Pe=Wh(u,H??null,_e,n),{warpData:ne,loading:re}=Pd(v,C,H??null,_e,n),ve=f.useRef(!1);(ne||Pe.images&&Pe.images.length>0)&&(ve.current=!0),f.useEffect(()=>{ve.current=!1},[n]);const ke=Pe.loading||Ri(ue)&&re&&!ne,Ue=ve.current&&ke,we=Ue,Ee=ib(_,H??null,_e,n),He=O.properNameMode??(Ee.length>0?"full":"off"),Ye=f.useMemo(()=>({...O,properNameMode:He}),[O,He]),Xe=f.useMemo(()=>Oh(Ee,He,{showWorks:Ye.showWorks}),[Ee,He,Ye.showWorks]),[at,qe]=f.useState(new Set),[jt,tt]=f.useState(null),[ct]=f.useState(Fh),[Q,De]=f.useState(!0),dt=j?!0:O.preserveMargins;f.useCallback(E=>L({preserveMargins:E}),[L]);const xt=f.useRef(null),[mt,Xt]=f.useState(1),[di,An]=f.useState(null),Rs=E=>{var Te;const ie=parseInt(((Te=E==null?void 0:E.page_id)==null?void 0:Te.split(":")[1])??"",10);return isNaN(ie)?null:ie},Is=E=>{var Te,rt;const ie=(E==null?void 0:E.pages)??[];return((Te=ie.find(Ze=>Ze.columns.some(It=>It.chars.length>0)))==null?void 0:Te.page)??Rs(E)??((rt=ie[0])==null?void 0:rt.page)??1},[st,hn]=f.useState(()=>Is(ne)),Mn=`${n}
|
|
1481
|
+
${T}
|
|
1482
|
+
${H??""}`,[Pn,Es]=f.useState({key:Mn,data:ne,started:!!ne});if(Pn.key!==Mn)Es({key:Mn,data:ne,started:!1});else if(ne!==Pn.data&&(Es({key:Mn,data:ne,started:!!ne}),ne)){const E=ne.pages??[];(!Pn.started||!E.some(ie=>ie.page===st))&&hn(Is(ne))}f.useEffect(()=>{qe(new Set),ct.set(null)},[H,T,ct]);const pr=Pn.key===Mn&&Pn.started,Ls=!!ue&&po(ue.headings).length===0,As=f.useMemo(()=>Ls&&pr&&ne?Bd(ne.pages,ne.punctuations):[],[Ls,pr,ne]),ur=f.useCallback(E=>{const ie=po(E.headings);return ie.length>0?ie:E.file===H?As:[]},[H,As]),hu=f.useCallback(E=>{if(qe(new Set(E)),E.length>0){const ie=E[0],Te=parseInt(ie.split(":")[0],10);isNaN(Te)||hn(Te)}},[]),Wt=f.useMemo(()=>{const E=new Map;for(const ie of(ne==null?void 0:ne.pages)??[])E.set(ie.page,ie);return E},[ne]),Bn=Rs(ne),pi=f.useCallback(E=>{var rt;const ie=Pe.images;if(!ie||ie.length===0)return;const Te=(rt=Wt.get(E))==null?void 0:rt.seq;return(Te?ie.find(Ze=>Ze.seq===Te):void 0)??ie.find(Ze=>Ze.pageNo===E)??ie[E-1]},[Pe.images,Wt]),Ms=mt>1.5,ui=f.useCallback((E,ie=!1)=>{const Te=pi(E);return Te?E===Bn||ie?Te.hiresUrl??Te.url:Te.url:E===Bn?(ne==null?void 0:ne.imageUrl)??"":""},[pi,ne,Bn]),xu=f.useMemo(()=>ui(st,Ms),[ui,st,Ms]),Ft=f.useMemo(()=>[...Wt.keys()].sort((E,ie)=>E-ie),[Wt]),on=f.useRef(st);on.current=st;const mr=f.useRef(0),gr=f.useRef({page:null,timer:null}),bu=f.useCallback(E=>{const ie=gr.current;E!==ie.page&&(ie.timer&&(clearTimeout(ie.timer),ie.timer=null),ie.page=null,!(E===on.current||Date.now()<mr.current)&&(ie.page=E,ie.timer=setTimeout(()=>{ie.timer=null,ie.page=null,!(Date.now()<mr.current||on.current===E)&&(on.current=E,hn(E))},lb)))},[]);f.useEffect(()=>()=>{gr.current.timer&&clearTimeout(gr.current.timer)},[]);const mi=f.useCallback(E=>{var ie;on.current===E||!Wt.has(E)||(mr.current=Date.now()+1e3,on.current=E,hn(E),(ie=Wt.get(E))!=null&&ie.columns.some(Te=>Te.chars.length>0)&&An(Te=>({page:E,nonce:((Te==null?void 0:Te.nonce)??0)+1})))},[Wt]),On=f.useCallback(E=>{const ie=on.current,Te=Ft.indexOf(ie),rt=Ft[Te<0?0:Te+E];rt===void 0||rt===ie||mi(rt)},[Ft,mi]),Ps=f.useCallback(E=>{if(!E.trim().match(/^\d+$/)||Ft.length===0)return null;const Te=parseInt(E.trim(),10),rt=Number.isFinite(Te)?Te:Number.MAX_SAFE_INTEGER;return Ft.reduce((Ze,It)=>Math.abs(It-rt)<Math.abs(Ze-rt)?It:Ze,Ft[0])},[Ft]),[fr,hr]=f.useState(null),gi=f.useRef(null),yu=f.useCallback(E=>{gi.current=E,hr(E)},[]),Bs=f.useCallback(()=>{const E=gi.current;if(gi.current=null,hr(null),E===null)return;const ie=Ps(E);ie!==null&&mi(ie)},[Ps,mi]),xr=Ft.indexOf(st),ju=f.useCallback(E=>{if(E.altKey||E.ctrlKey||E.metaKey)return;const ie=E.target.tagName;ie==="INPUT"||ie==="TEXTAREA"||ie==="SELECT"||(E.key==="ArrowLeft"||E.key==="PageUp"?(E.preventDefault(),On(-1)):(E.key==="ArrowRight"||E.key==="PageDown")&&(E.preventDefault(),On(1)))},[On]),Os=f.useRef(null);f.useEffect(()=>{if(!ne)return;const E=Os.current;if(!(!E||E.offsetWidth===0))for(const ie of[1,-1]){const Te=ui(st+ie);Te&&so(Te)}},[ne,st,ui]);const Ws=f.useMemo(()=>{var Js;if(!ne)return null;if(st===Bn)return ne;const E=Wt.get(st);if(E&&E.width>0&&E.height>0)return{page_id:`p:${st}`,title:`第${st}葉`,image_size:[E.width,E.height],total_warped_w:E.width,columns:[{col:1,warped_w:E.width,warped_h:E.height,offset_x:0,strips:[],chars:E.columns.flatMap(et=>et.chars).map(et=>({id:et.id,char:et.char,slot:et.slot,pos:et.pos,sub:et.sub,bbox_col:et.bbox??[0,0,0,0]}))}],...E.columns.some(et=>et.kind==="figure"&&et.figBox)?{figBlocks:E.columns.filter(et=>et.kind==="figure"&&et.figBox).map(et=>({id:et.fig,box:et.figBox}))}:{}};const ie=(Js=ne.pages)==null?void 0:Js.find(et=>et.page===st),[Te,rt]=ne.image_size||[2386,3082];if(!(Te>0&&rt>0))return null;const Ze=pi(st),It=(Ze==null?void 0:Ze.width)??Te,kr=(Ze==null?void 0:Ze.height)??rt,qs=It/Te,Xs=kr/rt,Zs=new Map;for(const et of ne.columns){const $t=(et.strips||[]).flatMap(yi=>yi.srcQuad.map(ji=>ji[0]));if($t.length===0)continue;const Ht=et.top_y??0,wr=et.bottom_y??Ht+et.warped_h;Zs.set(et.col,{x0:Math.min(...$t),x1:Math.max(...$t),top:Ht,slotH:(wr-Ht)/21})}return{page_id:`p:${st}`,title:`第${st}葉`,image_size:[It,kr],total_warped_w:It,columns:ie?ie.columns.map(et=>{const $t=Zs.get(et.col)??{x0:0,x1:0,top:0,slotH:118};return{col:et.col,warped_w:It,warped_h:kr,offset_x:0,strips:[],chars:et.chars.map(Ht=>{const wr=Ht.slot??Ht.pos??0,yi=($t.top+(wr-1)*$t.slotH)*Xs,ji=($t.x0+$t.x1)/2,[Ru,Iu]=Ht.sub==="a"?[ji,$t.x1]:Ht.sub==="b"?[$t.x0,ji]:[$t.x0,$t.x1];return{...Ht,bbox_col:[Ru*qs,yi,Iu*qs,yi+$t.slotH*Xs]}})}}):[]}},[ne,st,Bn,Wt,pi]),{entryTitle:fi,authors:Fs}=hb(n,i,c===void 0),[Hs,br]=f.useState("text");f.useEffect(()=>{br("text")},[H,T]);const vu=f.useMemo(()=>te?ub(te,Y,il(le,te),N,xe,ur):[],[te,Y,le,N,xe,ur]);if(U==="loading")return t.jsx(tl,{className:A,style:R,title:c??fi,label:z("reader.loading")});if(U==="missing"||!J||!le)return t.jsx("div",{className:A,style:{...R,...el},children:z("reader.noText")});if(We==="failed")return t.jsx("div",{className:A,style:{...R,...el},children:z("reader.tocFailed")});if(!te)return t.jsx(tl,{className:A,style:R,title:c??fi,label:z("reader.tocLoading")});const xn=il(le,te),ku=vu,Ds=ge&&H&&ge.chapter===H?gs(H,ge.anchor):null,wu=Ds&&ue&&ur(ue).some(E=>E.anchor===ge.anchor)?Ds:H??null,yr=J.versions.map(E=>({key:E.key,label:Re.textVersionLabel(E),optionLabel:N(Re.textVersionLabel(E)),sourceName:rl(E)?z("reader.originalSource"):E.source_name?N(E.source_name):void 0,license:E.license??void 0,sourceUrl:E.source_url??void 0,primary:E.key===Oe})),_t=db((Ks=te.source)==null?void 0:Ks.upstream),hi=(typeof c=="string"?N(c):c)??(te.title?N(te.title):fi?N(fi):void 0),Us=le.edition_label?N(le.edition_label):void 0,jr=hi?t.jsx("a",{href:D(n),title:z("reader.viewEntry"),onClick:l?E=>{E.metaKey||E.ctrlKey||(E.preventDefault(),l(n))}:void 0,children:hi}):void 0,Su=jr&&Us?t.jsxs(t.Fragment,{children:[jr,t.jsxs("span",{className:"bim-rd-ed",children:["·",Us]})]}):jr,_u=Fs.length>0?N(Fs.slice(0,2).map(E=>`${E.dynasty?`〔${E.dynasty}〕`:""}${E.name}${` ${E.role||z("reader.defaultRole")}`}`).join("、")):void 0,vr=ue?Fd(ue,xn,N,xe):void 0,sn=xe&&!!($e!=null&&$e.json),an=($e==null?void 0:$e.json)??null,bn=($e==null?void 0:$e.md)??null,Vs=sn&&!X&&$d(an.sections),$u=Vs&&!(bn&&Ye.readingMode==="paragraph"&&Pi(bn)),Cu=sn&&Vs?t.jsx(fx,{juan:an,view:Hs,onView:br,textHasEntries:$u}):void 0,zu=!0,xi=bn?bn.replace(/^##\s+[^\n]+\n+/,""):null,bi=rl(le),Zt=bi?z("reader.originalSource"):le.source_name?N(le.source_name):void 0,Nu=(typeof p=="string"?N(p):p)??(bi?void 0:Zt??N(Re.textVersionLabel(le))),Tu=(ne==null?void 0:ne.hasNorm)===!0;return t.jsxs(Fc,{className:A,style:R,title:Su,subtitle:Nu,byline:_u,current:vr,pagerUnit:xn,rail:Cu,revisedAt:y,backHref:k,backLabel:w,onReportError:S?E=>S({...E,bookTitle:typeof hi=="string"?hi:void 0,entryId:n}):void 0,workLinkToggle:sn&&!X&&!!l&&!!(an!=null&&an.sections.some(E=>E.work_id)),toc:ku,tocCaption:z("reader.tocCaption",{n:te.chapters.length,unit:N(xn)}),tocHeader:xe&&te.chapters.length>1?t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:X?z("reader.searchChaptersPlaceholder"):z("reader.searchUnitPlaceholder",{unit:N(xn)}),"aria-label":X?z("reader.searchChapters"):z("reader.searchUnit",{unit:N(xn)}),value:ze,onChange:E=>V(E.target.value)}):void 0,activeKey:H??null,tocActiveKey:wu,onSelect:ce,images:Ri(ue)&&re&&!ne?null:Pe.images,renderImageOverlay:h,imagePanel:ne||Ue?"open":x,imagesLoading:we,isWarpMode:!!ne,showPreserveMargins:!j,customImagePanel:ne&&Ws?t.jsxs("div",{ref:Os,className:"bim-fx-panel","data-testid":"facsimile-panel",tabIndex:0,role:"group","aria-label":"底本书影(聚焦后可用 ← → 翻页)",onKeyDown:ju,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:r("meta-fg"),gap:8,flexWrap:"wrap"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:4},children:t.jsx("span",{style:{fontWeight:600,marginRight:4},children:"底本书影"})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[at.size>0&&t.jsxs("button",{type:"button",onClick:()=>qe(new Set),className:"bim-rd-t",style:{fontSize:11,padding:"2px 6px",border:`1px solid ${r("rule")}`,borderRadius:4,cursor:"pointer"},children:["清除选中 (",at.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:mt<=1,onClick:()=>{var E;return(E=xt.current)==null?void 0:E.zoomBy(1/1.4)},children:"−"}),t.jsxs("span",{"data-testid":"facsimile-zoom-pct",style:{minWidth:38,textAlign:"center",fontSize:11},children:[Math.round(mt*100),"%"]}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"放大",title:"放大",disabled:mt>=6,onClick:()=>{var E;return(E=xt.current)==null?void 0:E.zoomBy(1.4)},children:"+"}),t.jsx("button",{type:"button",className:"bim-rd-t",title:"复位(双击书影也可)",disabled:mt===1,onClick:()=>{var E;return(E=xt.current)==null?void 0:E.reset()},style:{fontSize:11,padding:"2px 4px"},children:"复位"})]})]})]}),t.jsx(nb,{ref:xt,resetKey:st,onScaleChange:Xt,style:{flex:1,minHeight:0},children:t.jsx(Ua,{store:ct,children:E=>t.jsx(ss,{imageUrl:xu,pageData:Ws,selectedCharIds:at,hoveredCharId:E,preserveMargins:dt,renderScale:mt,selectedFigBlock:jt,onFigBlockClick:ie=>tt(ie),onCharClick:ie=>{tt(null),qe(rt=>{const Ze=new Set(rt);return Ze.has(ie)?Ze.delete(ie):(Ze.clear(),Ze.add(ie)),Ze});const Te=document.querySelector(`[data-char-id="${ie}"]`);Te&&Te.scrollIntoView({behavior:"smooth",block:"nearest"})},onCharHover:ct.set})})}),t.jsxs("div",{"data-testid":"facsimile-pager",role:"group","aria-label":z("reader.facsimilePager"),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"6px 4px 0",fontSize:13,color:r("meta-fg")},children:[t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-prev","aria-label":"上一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:xr<=0,onClick:()=>On(-1),children:"‹"}),t.jsxs("span",{"data-warp-page":st,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"1px 8px",background:r("rule"),borderRadius:10},children:["第",t.jsx("input",{type:"text",inputMode:"numeric","data-testid":"facsimile-page-input","aria-label":z("reader.facsimilePageInput"),size:Math.max(2,String(fr??st).length),value:fr??String(st),onFocus:E=>E.currentTarget.select(),onChange:E=>yu(E.target.value),onKeyDown:E=>{E.key==="Enter"?(E.preventDefault(),Bs()):E.key==="Escape"&&(gi.current=null,hr(null)),E.stopPropagation()},onBlur:Bs,style:{width:`${Math.max(2,String(fr??st).length)+1}ch`,minHeight:28,textAlign:"center",font:"inherit",border:`1px solid ${r("rule")}`,borderRadius:4,background:"transparent",color:"inherit"}}),"葉"]}),t.jsx("button",{type:"button",className:"bim-rd-t","data-testid":"facsimile-next","aria-label":"下一葉",style:{minWidth:40,minHeight:40,fontSize:20,lineHeight:1},disabled:xr<0||xr>=Ft.length-1,onClick:()=>On(1),children:"›"})]})]}):void 0,settingsExtra:g,settingsExtraTitle:m,settingsAnnotate:ne?t.jsx("button",{type:"button",className:`bim-rd-t bim-rd-sp-tg ${Q?"bim-rd-on":""}`,"aria-pressed":Q,title:"切换外挂现代断句标点",onClick:()=>De(E=>!E),children:Q?"标点":"无标点"}):void 0,prefs:Ye,onPrefsChange:L,versions:yr.length>1?yr:void 0,currentVersionKey:yr.length>1?le.key:void 0,onVersionChange:Ge,keepChapterOnVersionChange:!0,versionSource:!0,paragraphToggle:Pi(bn),allowVertical:b,origScriptAvailable:Tu,contentLoading:I,children:[(I||re&&!ne&&!sn&&xi==null)&&t.jsx(gn,{}),!I&&ne&&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:ue!=null&&ue.title?N(ue.title):vr}),(Zt||le.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[Zt,le.license&&t.jsxs(t.Fragment,{children:[Zt&&t.jsx("span",{className:"bim-rd-dot"}),le.license]})]})]}),t.jsx(Ua,{store:ct,children:E=>t.jsx(us,{pageData:ne,pages:ne.pages,punctuations:ne.punctuations||cb,selectedCharIds:at,hoveredCharId:E,onSelectionChange:hu,figures:ne.figures,figUrl:ne.figUrl,onFigureBlockClick:({page:ie,fig:Te})=>{qe(new Set),tt(Te),hn(ie)},onCharClick:ie=>{tt(null),qe(rt=>{const Ze=new Set(rt);return Ze.has(ie)?Ze.delete(ie):(Ze.clear(),Ze.add(ie)),Ze});const Te=parseInt(ie.split(":")[0],10);isNaN(Te)||hn(Te)},onCharHover:ct.set,mode:"horizontal",showPunctuation:Q,entities:Xe,entityTransport:i,onEntityNavigate:$,onVisiblePageChange:bu,convert:N,scrollToPage:di,scrollToAnchor:Je&&Je.chapter===H&&pr?Je:null,onVisibleHeadingChange:ie=>Ae(ie&&H?{chapter:H,anchor:ie}:null),pageBreaks:Ye.pageBreaks,pageIndicatorY:Ye.pageIndicatorY,onPageIndicatorYChange:ie=>L({pageIndicatorY:ie}),quoteStyle:Ye.quoteStyle,bookTitleStyle:Ye.bookTitleStyle,showWorks:Ye.showWorks})})]}),!I&&!ne&&sn&&an&&t.jsx(mx,{juan:an,rawText:bn,positionLabel:gb(ue,te,xn,N),groupLabel:fb(te,H??null),index:pb(n,te),searchQuery:ze,onNavigate:l,transport:i,workLabelCache:me,prefs:Ye,view:Hs,onViewChange:br},`${T}/${H}`),!I&&!ne&&!sn&&xi!=null&&ue&&t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:ue.title?N(ue.title):vr}),(Zt||le.license)&&t.jsxs("p",{className:"bim-rd-meta bim-rd-meta-src",children:[bi&&Zt&&t.jsx(t.Fragment,{children:Zt}),!bi&&le.source_name&&t.jsxs(t.Fragment,{children:[z("reader.textSource")," ",le.source_url?t.jsx("a",{className:"bim-rd-link",href:le.source_url,target:"_blank",rel:"noreferrer",children:N(le.source_name)}):N(le.source_name)]}),Zt&&le.license&&t.jsx("span",{className:"bim-rd-dot"}),le.license]}),_t&&t.jsxs("p",{className:"bim-rd-meta","data-bim-upstream":"",children:[z("reader.upstream")," ",_t.url?t.jsx("a",{className:"bim-rd-link",href:_t.url,target:"_blank",rel:"noreferrer",children:N(_t.name??_t.url)}):N(_t.name??""),_t.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),_t.license_url?t.jsx("a",{className:"bim-rd-link",href:_t.license_url,target:"_blank",rel:"noreferrer",children:_t.license}):_t.license]}),_t.note&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),t.jsx(Tc,{text:_t.note,convert:N})]})]})]}),t.jsx("article",{className:"bim-rd-prose",children:t.jsx(Jo,{text:xi,mode:Ye.readingMode,tables:zu,gujiMarkdown:!0,bookMarking:Zo(Ye),quoteStyle:Ye.quoteStyle})})]}),!I&&!re&&!ne&&!sn&&xi==null&&ue&&t.jsx("div",{className:"bim-rd-state",children:z("reader.chapterFailed")}),!I&&te.references&&te.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:z("reader.references")}),t.jsx("ol",{children:te.references.map((E,ie)=>t.jsxs("li",{children:[E.url?t.jsx("a",{className:"bim-rd-link",href:E.url,target:"_blank",rel:"noopener noreferrer",children:N(E.title)}):t.jsx("span",{children:N(E.title)}),E.author&&t.jsxs("span",{children:[",",N(E.author)]}),E.note&&t.jsxs("span",{children:["。",N(E.note)]})]},ie))})]})]})};function rl(e){return e.is_original===!0||e.source==="original"}function gb(e,n,i,o){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 o(s?`${s}冊`:`${i}${e.n}`)}function fb(e,n){if(!n)return;const i=o=>{var s;for(const a of o??[]){const l=i(a.children);if(l)return l;if((s=a.files)!=null&&s.includes(n))return a.label}};return i(e.juan_groups)}function hb(e,n,i){const[o,s]=f.useState({entryTitle:void 0,authors:[]});return f.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:i&&typeof l.title=="string"?l.title:void 0,authors:d})}).catch(()=>{}),()=>{a=!0}},[e,n,i]),o}const Dd={bug:{key:"bug",color:r("danger")},resource:{key:"resource",color:r("primary")},suggestion:{key:"suggestion",color:r("primary")},other:{key:"other",color:r("desc-fg")}},xb=Dd.other,Ud={pending:{key:"pending",color:r("warning")},in_progress:{key:"in_progress",color:r("primary")},resolved:{key:"resolved",color:r("success")},wontfix:{key:"wontfix",color:r("desc-fg")},duplicate:{key:"duplicate",color:r("desc-fg")}},bb=Ud.pending;function yb(e){try{const n=new Date(e),i=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())} ${i(n.getHours())}:${i(n.getMinutes())}`}catch{return e}}function jb(e,n){if(!e)return!1;try{const i=new URL(e,n);if(i.protocol!=="http:"&&i.protocol!=="https:")return!1;const o=new URL(n);return i.hostname===o.hostname}catch{return!1}}const hs=({items:e,loading:n})=>{const i=gt(),{t:o,convert:s}=ae();return n?t.jsx(gn,{}):e.length===0?t.jsx("div",{style:vb,children:o("feedback.empty")}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(a=>{const l=Dd[a.type]||xb,d=Ud[a.status]||bb,c=typeof window<"u"&&jb(a.pageUrl,window.location.href);return t.jsxs("div",{style:kb,children:[t.jsxs("div",{style:wb,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...ol,background:l.color},children:o(`feedback.listType.${l.key}`)}),t.jsx("span",{style:{...ol,background:d.color},children:o(`feedback.status.${d.key}`)})]}),t.jsx("span",{style:Sb,children:yb(a.createdAt)})]}),(a.resourceId||a.pageUrl)&&t.jsxs("div",{style:_b,children:[a.resourceId&&t.jsx("a",{href:i(a.resourceId),style:Mr,children:a.resourceId}),a.pageUrl&&!a.resourceId&&(c?t.jsx("a",{href:a.pageUrl,style:Mr,children:a.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:Mr,children:a.pageUrl}))]}),t.jsx("div",{style:$b,children:s(a.content)}),a.reply&&t.jsxs("div",{style:Cb,children:[t.jsx("div",{style:zb,children:o("feedback.reply")}),t.jsx("div",{children:s(a.reply)})]})]},a.id)})})},vb={textAlign:"center",padding:"40px 0",color:r("desc-fg"),fontSize:"14px"},kb={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"16px"},wb={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},ol={fontSize:"12px",color:r("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},Sb={fontSize:"12px",color:r("desc-fg")},_b={fontSize:"12px",marginBottom:"6px"},Mr={color:r("primary"),textDecoration:"none",borderBottom:`1px dashed ${r("primary")}`},$b={fontSize:"14px",lineHeight:"1.6",color:r("fg"),whiteSpace:"pre-wrap"},Cb={marginTop:"12px",padding:"10px 12px",background:r("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:r("fg")},zb={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:r("primary")},uo=({transport:e,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:s,feedbackApiUrl:a})=>{const l=Be(),[d,c]=f.useState(null),[p,g]=f.useState([]),[m,u]=f.useState("recommend"),[h,x]=f.useState([]),[j,b]=f.useState(!1),S=o??m,y=L=>{u(L),s==null||s(L)},[k,w]=f.useState(!0),[v,C]=f.useState(null),[_,$]=f.useState(null),[A,R]=f.useState(null);f.useEffect(()=>{let L=!1;if(e.getCounts)return e.getCounts().then(D=>{L||c({works:D.works,books:D.books,collections:D.collections})}).catch(()=>{}),()=>{L=!0}},[e]),f.useEffect(()=>{let L=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const q=await e.getRecommended();if(q!=null&&q.groups)return q.groups.flatMap(J=>J.items.map(se=>({...se,group:J.name})))}catch{}return[]})().then(async q=>{if(L)return;const J=q.filter(U=>U.id);if(J.length===0){w(!1);return}const se=await Promise.all(J.map(async U=>{if(U.type)return{id:U.id,title:U.title,type:U.type,author:U.author,dynasty:U.dynasty,role:U.role,edition:U.edition,has_text:U.has_text,has_image:U.has_image,has_collated:U.has_collated,subtype:U.subtype,primary_name:U.primary_name,group:U.group,fallbackDescription:U.description};try{let K=null;if(e.getEntry)K=await e.getEntry(U.id);else{const Z=await e.getItem(U.id);Z&&(K={id:U.id,title:Z.title||U.id,type:Z.type||"work"})}if(K)return{...K,group:U.group,fallbackDescription:U.description}}catch{}return{id:U.id,title:U.title,type:Re.extractType(U.id),group:U.group,fallbackDescription:U.description}}));L||(g(se.filter(U=>U!==null)),w(!1))}),()=>{L=!0}},[e,i]);const z=f.useRef(!1),N=f.useRef(!1),M=f.useRef(!1);f.useEffect(()=>{if(S!=="catalog"||z.current)return;const L=e.getCatalogProgress??e.getResourceProgress;if(!L)return;z.current=!0;let D=!1;return L.call(e).then(q=>{D||C(q)}).catch(()=>{z.current=!1}),()=>{D=!0}},[e,S]),f.useEffect(()=>{if(S!=="collection"||N.current||!e.getCollectionProgress)return;N.current=!0;let L=!1;return e.getCollectionProgress().then(D=>{L||$(D)}).catch(()=>{N.current=!1}),()=>{L=!0}},[e,S]),f.useEffect(()=>{if(S!=="site"||M.current||!e.getSiteProgress)return;M.current=!0;let L=!1;return e.getSiteProgress().then(D=>{L||R(D)}).catch(()=>{M.current=!1}),()=>{L=!0}},[e,S]),f.useEffect(()=>{if(!a||S!=="feedback")return;let L=!1;return b(!0),fetch(a).then(D=>D.json()).then(D=>{!L&&D.success&&x(D.items||[])}).catch(()=>{}).finally(()=>{L||b(!1)}),()=>{L=!0}},[a,S]);const O=L=>t.jsx(En,{type:L,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:r("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${r("widget-border")}`,marginBottom:"16px"},children:[t.jsx(Un,{label:l.home.recommendTab,active:S==="recommend",onClick:()=>y("recommend")}),t.jsx(Un,{label:l.home.catalogTab,active:S==="catalog",onClick:()=>y("catalog")}),t.jsx(Un,{label:l.home.collectionTab,active:S==="collection",onClick:()=>y("collection")}),t.jsx(Un,{label:l.home.siteTab,active:S==="site",onClick:()=>y("site")}),a&&t.jsx(Un,{label:l.home.feedbackTab,active:S==="feedback",onClick:()=>y("feedback")})]}),S==="recommend"&&t.jsx(Nb,{recommended:p,loading:k,onNavigate:n,getIcon:O,t:l}),S==="catalog"&&t.jsx(sl,{progress:v,t:l,onNavigate:n}),S==="collection"&&t.jsx(sl,{progress:_,t:l,onNavigate:n}),S==="site"&&t.jsx(Rb,{progress:A,t:l,totalWorks:(d==null?void 0:d.works)??0}),S==="feedback"&&a&&t.jsx(hs,{items:h,loading:j})]})})},Un=({label:e,active:n,onClick:i})=>t.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:r(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${r("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),Nb=({recommended:e,loading:n,onNavigate:i,getIcon:o,t:s})=>{const a=gt();if(n)return t.jsx(gn,{});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:r("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 g=p.dynasty||p.author?`${p.dynasty?`〔${p.dynasty}〕`:""}${p.author||""}`:p.fallbackDescription;return t.jsxs("a",{href:a(p.id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),i==null||i(p.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,cursor:"pointer",background:r("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:o(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:r("desc-fg"),marginLeft:"4px"},children:p.edition})]}),g&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g})]})]},p.id)})})]},d))})},sl=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(gn,{});const o=[...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:r("progress-active"),done:r("progress-done"),todo:r("progress-todo")};return t.jsx("div",{children:s.map(d=>{const c=o.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:r("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(Tb,{item:p,t:n,statusColor:l[d],onNavigate:i},p.id))})]},d)})})},Tb=({item:e,t:n,statusColor:i,onNavigate:o})=>{const s=gt(),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 ${r("widget-border")}`,background:r("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&&o?t.jsx("a",{href:s(c),onClick:p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("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:r("widget-border"),color:r("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:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?zt(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:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"2px",background:i,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},Rb=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(gn,{});const o=[...e.resources].sort((c,p)=>c.priority-p.priority),s=o.filter(c=>c.imported>0),a=o.filter(c=>c.imported===0),l=s.reduce((c,p)=>Math.max(c,p.imported),0),d=i>0?Math.round(l/i*100):0;return t.jsxs("div",{children:[i>0&&t.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${r("primary")} 6%, transparent)`,fontSize:"13px",color:r("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:l.toLocaleString()})," / ",i.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:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(al,{item:c,t:n,totalWorks:i},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:r("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:r("progress-todo")}}),n.home.statusTodo," (",a.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(c=>t.jsx(al,{item:c,t:n,totalWorks:i},c.id))})]})]})},al=({item:e,t:n,totalWorks:i})=>{const o=i>0?Math.round(e.imported/i*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${r("widget-border")}`,background:r("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:r("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${o}%)`:n.home.statusTodo})]}),e.imported>0&&i>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:r("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${o}%`,borderRadius:"2px",background:r("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:r("desc-fg"),marginTop:"4px"},children:e.description})]})},ll="(max-width: 768px)";function Ib(){const[e,n]=f.useState(()=>typeof window>"u"?!1:window.matchMedia(ll).matches);return f.useEffect(()=>{const i=window.matchMedia(ll),o=s=>n(s.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),e}const Eb=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o,headerRight:s})=>{var N;const a=Be(),{convert:l}=Ve(),d=Ib(),[c,p]=f.useState(null),[g,m]=f.useState(null),[u,h]=f.useState(!1),[x,j]=f.useState("detail"),[b,S]=f.useState([]),[y,k]=f.useState(!1),w=f.useCallback(async M=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){S([]);return}k(!0);try{if(e.getCollectionCatalogs){const O=await e.getCollectionCatalogs(M);S(O||[])}else if(e.getCollectionCatalog){const O=await e.getCollectionCatalog(M);S(O?[{resource_id:"",data:O}]:[])}}catch{S([])}finally{k(!1)}},[e]),v=f.useCallback(async M=>{if(i){i(M);return}p(M),m(null),S([]),j("detail"),h(!0);try{const O=await e.getItem(M.id);O&&(m(O),O.type==="collection"&&w(M.id))}catch(O){console.error("加载详情失败:",O)}finally{h(!1)}},[e,i,w]),C=f.useCallback(async M=>{m(null),S([]),j("detail"),h(!0);try{const O=await e.getItem(M);O&&(m(O),p({id:M,title:O.title||M,type:O.type||"book"}),O.type==="collection"&&w(M))}catch(O){console.error("导航失败:",O)}finally{h(!1)}},[e,w]),_=typeof(g==null?void 0:g.text_count)=="number"&&g.text_count>0,$=(g==null?void 0:g.type)==="collection"&&(b.length>0||y)||(g==null?void 0:g.type)==="work"&&_,A=d&&(u||g),R=f.useCallback(()=>{p(null),m(null),S([]),j("detail")},[]),z=t.jsx(t.Fragment,{children:u?t.jsx(gn,{}):g?t.jsxs(t.Fragment,{children:[($||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${r("widget-border")}`,padding:d?"0 12px":"0 48px",background:r("input-bg"),flexShrink:0,overflowX:d?"auto":void 0},children:[$&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>j("detail"),style:_i(x==="detail"),children:a.detailTab.basicInfo}),g.type==="collection"&&y&&b.length===0&&t.jsxs("button",{onClick:()=>{},style:_i(!1),children:[a.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),g.type==="collection"&&b.map(M=>t.jsx("button",{onClick:()=>j(`catalog:${M.resource_id}`),style:_i(x===`catalog:${M.resource_id}`),children:M.short_name?`${l(M.short_name)}${a.detailTab.catalogSuffix}`:a.detailTab.collectionCatalog},M.resource_id)),g.type==="work"&&_&&t.jsx("button",{onClick:()=>j("collated"),style:_i(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(Bo,{data:g,transport:e,onNavigate:C}):x.startsWith("catalog:")?t.jsx(Oo,{data:(N=b.find(M=>`catalog:${M.resource_id}`===x))==null?void 0:N.data,onNavigate:C}):x==="collated"?t.jsx(fs,{id:g.id,transport:e,onNavigate:C}):null})]}):t.jsx(uo,{transport:e,onNavigate:C,recommendedIds:o})});return d?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:A?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${r("widget-border")}`,background:r("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:R,style:{padding:"4px 12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("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(qr,{transport:e,onEntryClick:v,hideModeIndicator:n}),!g&&t.jsx(uo,{transport:e,onNavigate:C,recommendedIds:o})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:r("bg"),color:r("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${r("widget-border")}`,display:"flex",flexDirection:"column",background:r("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(qr,{transport:e,onEntryClick:v,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:r("bg"),display:"flex",flexDirection:"column"},children:z})]})};function _i(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}const Lb=({pageData:e,rawImageUrl:n="",punctuations:i=[],title:o,subtitle:s,onBack:a,className:l="",style:d={}})=>{const[c,p]=f.useState(new Set),[g,m]=f.useState(null),[u,h]=f.useState("horizontal"),[x,j]=f.useState(!0),b=f.useRef(null),S=f.useCallback(v=>{p(new Set(v))},[]),y=f.useCallback(v=>{if(p(C=>{const _=new Set(C);return _.has(v)?_.delete(v):(_.clear(),_.add(v)),_}),b.current){const C=b.current.querySelector(`[data-char-id="${v}"]`);C&&C.scrollIntoView({behavior:"smooth",block:"nearest"})}},[]),k=()=>{var v;p(new Set),window.getSelection&&((v=window.getSelection())==null||v.removeAllRanges())},w=i.length>0?i: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:o||e.title}),s&&t.jsx("span",{style:{fontSize:"0.85rem",color:r("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:r("body-fg")},children:["已选字数: ",t.jsx("strong",{style:{color:r("accent")},children:c.size})]}),c.size>0&&t.jsx("button",{type:"button",onClick:k,className:"guji-reader-btn",children:"清除选中"}),t.jsx("button",{type:"button",onClick:()=>j(v=>!v),className:`guji-reader-btn ${x?"active":""}`,title:"独立外挂标点 (guji-punct v0.1)",children:x?"✓ 标点":"底本文本"}),t.jsx("button",{type:"button",onClick:()=>h(v=>v==="horizontal"?"vertical":"horizontal"),className:"guji-reader-btn primary",children:u==="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(ss,{imageUrl:n,pageData:e,selectedCharIds:c,hoveredCharId:g,onCharClick:y,onCharHover:m})})]}),t.jsxs("div",{className:"guji-pane-card",style:{flex:"1 1 50%"},ref:b,children:[t.jsxs("div",{className:"guji-pane-header",children:[t.jsx("span",{className:"guji-pane-title",children:u==="horizontal"?"排版文本 (横排分段 · 外挂断句标点)":"排版文本 (原刻竖排逐列)"}),t.jsx("span",{className:"guji-pane-hint",children:"支持鼠标跨标点整句划词高亮"})]}),t.jsx(us,{pageData:e,punctuations:w,selectedCharIds:c,hoveredCharId:g,onSelectionChange:S,onCharClick:y,onCharHover:m,mode:u,showPunctuation:x})]})]})]})},Ab=e=>typeof e=="string"&&Array.from(e).length===1,Mb=new Set(["point","break","heading"]),Pb=/^#{1,6}$/;function Bb(e){const n=Array.isArray(e)?e:e&&typeof e=="object"&&Array.isArray(e.punctuations)?e.punctuations:[],i=[];for(const o of n){if(!o||typeof o!="object")continue;const s=o;if(typeof s.anchor!="string"||typeof s.mark!="string"||s.pre_char!=null&&!Ab(s.pre_char)||s.kind!=null&&!Mb.has(s.kind)||s.pos!=null&&s.pos!=="after"&&s.pos!=="before")continue;const a={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??void 0};if(!(s.kind==="break"&&s.pos==="before")){if(s.kind==="heading"){if(s.pos!=="before"||!Pb.test(s.mark))continue;typeof s.label=="string"&&s.label.trim()&&(a.label=s.label.trim()),s.toc===!1&&(a.toc=!1)}i.push(a)}}return i}function Ob(e){var i;const n=e&&typeof e=="object"?e.pages:void 0;if(!Array.isArray(n))return null;for(const o of n){const s=/\/iiif\/([^/]+)\/canvas\/([^/]+)\//.exec(String(((i=o==null?void 0:o.canvas)==null?void 0:i.id)??""));if(s)return{bookId:s[1],vol:s[2]}}return null}const Vd=/^(\d+):(-?\d+):(-?\d+)([a-z]?)$/;function pt(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}const xs=/^[a-z0-9][a-z0-9-]*$/,Wb=new Set(["main","solo","jz_r","jz_l"]),Fb=new Set(["body","banxin","blank"]);function Hb(e){const n={};return typeof e.lane=="string"&&Wb.has(e.lane)&&e.lane!=="main"&&(n.lane=e.lane),e.lacuna===!0&&(n.lacuna=!0),e.lacuna===!0&&e.guess!==!0&&typeof e.guess_c=="string"&&e.guess_c.trim()&&(n.guess_c=e.guess_c.trim()),e.guess===!0&&(n.guess=!0),typeof e.zi=="string"&&e.zi&&(n.zi=e.zi),typeof e.fig=="string"&&xs.test(e.fig)&&e.c==="□"&&!e.lacuna&&!e.guess&&e.guess_c===void 0&&e.zi===void 0&&(n.fig=e.fig),n}function Db(e){const n={};typeof e.kind=="string"&&Fb.has(e.kind)&&e.kind!=="body"&&(n.kind=e.kind);const i=pt(e.raised);i!==void 0&&Number.isInteger(i)&&i>0&&(n.raised=i);const o=pt(e.lead_blank);return o!==void 0&&Number.isInteger(o)&&o>0&&(n.lead_blank=o),n}function Pr(e){const n=e&&typeof e=="object"?e.pages:void 0;return Array.isArray(n)?n.filter(i=>!!i&&typeof i=="object"):[]}function Ub(e){return typeof e=="string"&&Array.from(e).length===1}function Gd(e){const n=new Map,i={badAnchor:0,badChar:0,badWhy:0,notObject:0},o=e&&typeof e=="object"?e.items:void 0;for(const s of Array.isArray(o)?o:[]){if(!s||typeof s!="object"){i.notObject++;continue}const{a,t:l,why:d}=s;if(typeof a!="string"||!Vd.test(a)){i.badAnchor++;continue}if(!Ub(l)){i.badChar++;continue}if(d!==void 0&&d!=="异体"){i.badWhy++;continue}n.set(a,l)}return{map:n,dropped:i}}function Yd(e){return Gd(e).map}function Vb(e,n,i){var m,u,h,x,j,b,S,y,k,w;const o=i==null?null:Yd(i),s=new Map,a=new Map;for(const v of Pr(n)){const C=pt(v.page);if(C!==void 0){s.set(C,v);for(const _ of Array.isArray(v.cells)?v.cells:[]){const $=_==null?void 0:_.box;typeof(_==null?void 0:_.a)=="string"&&Array.isArray($)&&$.length===4&&$.every(A=>pt(A)!==void 0)&&a.set(_.a,[$[0],$[1],$[0]+$[2],$[1]+$[3]])}}}const l=new Map;for(const[v,C]of s)for(const _ of Array.isArray(C.marks)?C.marks:[]){const $=_==null?void 0:_.box;if((_==null?void 0:_.kind)!=="figure"||typeof _.fig!="string"||!Array.isArray($)||$.length!==4||!$.every(R=>pt(R)!==void 0))continue;let A=l.get(v);A||l.set(v,A=new Map),A.set(_.fig,[$[0],$[1],$[0]+$[2],$[1]+$[3]])}const d=[],c=new Map,p=new Map;for(const v of Pr(e)){const C=pt(v.page);C!==void 0&&typeof v.label=="string"&&v.label&&c.set(C,v.label)}for(const v of Pr(e)){const C=pt(v.page);if(C===void 0)continue;const _=[],$=l.get(C);for(const R of Array.isArray(v.columns)?v.columns:[]){const z=pt(R==null?void 0:R.col);if(z===void 0)continue;if(R.kind==="figure"){if(typeof R.fig!="string"||!xs.test(R.fig))continue;const O=pt(R.span),L=$==null?void 0:$.get(R.fig);_.push({col:z,chars:[],kind:"figure",fig:R.fig,...O!==void 0&&Number.isInteger(O)&&O>1?{span:O}:{},...L?{figBox:L}:{}});continue}const N=[];for(const O of Array.isArray(R.cells)?R.cells:[]){const L=Vd.exec(String((O==null?void 0:O.a)??""));if(!L||typeof O.c!="string")continue;const D=parseInt(L[3],10),q=o==null?void 0:o.get(O.a);N.push({id:O.a,char:O.c,slot:D,pos:D,sub:L[4]||null,bbox:a.get(O.a)??null,...Hb(O),...q!==void 0&&q!==O.c?{norm:q}:{}})}const M=Db(R);(N.length>0||M.kind==="blank")&&_.push({col:z,chars:N,...M})}if(!_.some(R=>R.chars.length>0||R.kind==="figure")){_.length>0&&p.set(C,_);continue}_.sort((R,z)=>R.col-z.col);const A=s.get(C);d.push({page:C,seq:String(((m=A==null?void 0:A.canvas)==null?void 0:m.seq)??""),width:pt((u=A==null?void 0:A.canvas)==null?void 0:u.width)??pt((h=A==null?void 0:A.image)==null?void 0:h.width)??0,height:pt((x=A==null?void 0:A.canvas)==null?void 0:x.height)??pt((j=A==null?void 0:A.image)==null?void 0:j.height)??0,...typeof v.label=="string"&&v.label?{label:v.label}:{},columns:_})}const g=new Set(d.map(v=>v.page));for(const[v,C]of s){const _=(b=C==null?void 0:C.canvas)==null?void 0:b.seq;g.has(v)||typeof _!="string"&&typeof _!="number"||String(_)===""||d.push({page:v,seq:String(_),width:pt((S=C.canvas)==null?void 0:S.width)??pt((y=C.image)==null?void 0:y.width)??0,height:pt((k=C.canvas)==null?void 0:k.height)??pt((w=C.image)==null?void 0:w.height)??0,...c.has(v)?{label:c.get(v)}:{},columns:p.get(v)??[]})}return d.sort((v,C)=>v.page-C.page)}const Gb=new Set(["image/png","image/webp","image/svg+xml"]);function Yb(e){const n=new Map,i=e&&typeof e=="object"?e.figures:void 0;for(const o of Array.isArray(i)?i:[]){if(!o||typeof o!="object")continue;const s=o;if(typeof s.id!="string"||!xs.test(s.id))continue;const a=s.kind==="block"?"block":s.kind==="inline"?"inline":null;a&&(typeof s.file!="string"||!/^fig\/[\w./-]+$/.test(s.file)||s.file.split("/").includes("..")||typeof s.mime!="string"||!Gb.has(s.mime)||n.set(s.id,{id:s.id,kind:a,alt:typeof s.alt=="string"&&s.alt.trim()?s.alt.trim():"图形符号",file:s.file,mime:s.mime,width:pt(s.width)??0,height:pt(s.height)??0}))}return n}const Kb=({data:e,onNavigate:n,className:i,style:o})=>{var g;const{t:s,convert:a}=ae(),[l,d]=f.useState(((g=e.divisions[0])==null?void 0:g.name)??null),[c,p]=f.useState(null);return t.jsxs("div",{className:i,style:o,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:r("fg"),margin:"0 0 8px"},children:a(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:r("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s("catalog.totalVolumes")," ",t.jsx("strong",{children:e.total_volumes})," ",s("unit.juan")]}),e.stats.zhulu!=null&&t.jsxs("span",{children:[s("catalogPage.zhulu")," ",t.jsx("strong",{children:e.stats.zhulu})," ",s("unit.bu")]}),e.stats.cunmu!=null&&t.jsxs("span",{children:[s("catalogPage.cunmu")," ",t.jsx("strong",{children:e.stats.cunmu})," ",s("unit.bu")]}),e.stats.categories!=null&&t.jsx("span",{children:s("catalogPage.categoriesN",{n:e.stats.categories})})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(m=>t.jsx(qb,{division:m,expanded:l===m.name,onToggle:()=>d(l===m.name?null:m.name),expandedCat:c,onCatToggle:u=>p(c===u?null:u),onNavigate:n},m.name))})]})},qb=({division:e,expanded:n,onToggle:i,expandedCat:o,onCatToggle:s,onNavigate:a})=>{const{t:l,convert:d}=ae(),c=e.categories.reduce((p,g)=>{const m=g.stats||{zhulu:0,cunmu:0};return p+(m.zhulu||0)+(m.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${r("primary")} 6%, transparent)`:r("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:r("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:r("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 g=`${e.name}/${p.name}`;return t.jsx(Xb,{category:p,expanded:o===g,onToggle:()=>s(g),onNavigate:a},p.name)})})]})},Xb=({category:e,expanded:n,onToggle:i,onNavigate:o})=>{var p,g,m,u;const{t:s,convert:a}=ae(),l=((p=e.books)==null?void 0:p.zhulu)||[],d=((g=e.books)==null?void 0:g.cunmu)||[],c=(((m=e.stats)==null?void 0:m.zhulu)||l.length)+(((u=e.stats)==null?void 0:u.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?r("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:r("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[a(e.name),e.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg"),marginLeft:"8px",fontWeight:400},children:s("catalogPage.categoryJuan",{n:a(e.volumes)})})]}),t.jsxs("span",{style:{fontSize:"11px",color:r("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(cl,{label:s("catalogPage.zhulu"),books:l,onNavigate:o}),d.length>0&&t.jsx(cl,{label:s("catalogPage.cunmu"),books:d,onNavigate:o})]})]})},cl=({label:e,books:n,onNavigate:i})=>{const{t:o,convert:s}=ae(),a=gt(),[l,d]=f.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:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:c.map((p,g)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:r("fg")},children:p.work_id&&i?t.jsx("a",{href:a(p.work_id),onClick:m=>{m.metaKey||m.ctrlKey||(m.preventDefault(),i(p.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${r("link-fg")}`},children:s(p.title)}):s(p.title)}),p.volumes&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.volumes)}),p.author&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:s(p.author).slice(0,20)})]},g))}),!l&&t.jsx("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:r("primary"),background:"transparent",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:o("catalogPage.expandAllN",{n:n.length})})]})},Et=({title:e,onSave:n,onAskAI:i,extraButtons:o,children:s})=>{const a=Be();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("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 ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:r("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o,i&&t.jsx("button",{onClick:i,style:Jb,children:"AI"}),n&&t.jsx("button",{onClick:n,style:Zb,children:a.action.save})]})]}),s]})},Zb={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},Jb={padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},Ct=({label:e,value:n,onChange:i,placeholder:o,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:a=>i(a.target.value),placeholder:o,disabled:s,style:{width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),mn=({value:e,onChange:n,placeholder:i})=>{const o=f.useRef(null);return f.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:o,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},Oi=({children:e,color:n,style:i})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||r("primary-soft"),color:r(n?"on-color-fg":"fg"),...i},children:e});function Qb(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Ii=({value:e,onChange:n,label:i})=>{const[o,s]=f.useState(!1),a=f.useRef(null),l=Qb(e||"");return f.useEffect(()=>{o&&a.current&&a.current.focus()},[o]),!o&&l?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:dl,children:i}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${r("input-border")}`,borderRadius:"2px",background:r("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:r("fg")},children:l.name}),t.jsx(Oi,{children:l.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:dl,children:i}),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:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},dl={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500};function ey(e){switch(e){case"url":return r("source-url");case"bookID":return r("source-bookid");default:return r("desc-fg")}}function ty(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Kd=({items:e,onChange:n,onOpenEntityPicker:i})=>{const o=Be(),[s,a]=f.useState(null),l=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(e.length)},d=m=>{n(e.filter((u,h)=>h!==m)),s===m&&a(null)},c=(m,u,h)=>{const x=[...e];x[m]={...x[m],[u]:h},n(x)},p=(m,u)=>{const h=[...e];h[m]={...h[m],type:u,id:"",name:""},n(h),u==="bookID"&&i&&i(x=>{const j=[...e];j[m]={...j[m],id:x.id,name:x.title,type:"bookID"},n(j)})},g=m=>{i&&i(u=>{const h=[...e];h[m]={...h[m],id:u.id,name:u.title,type:"bookID"},n(h)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((m,u)=>t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:r("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>a(s===u?null:u),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===u?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:r("fg")},children:m.name||`${o.editor.sourcePlaceholder} ${u+1}`}),m.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:ey(m.type),color:r("on-color-fg"),borderRadius:"3px",fontWeight:500},children:ty(m.type)}),t.jsx("button",{onClick:h=>{h.stopPropagation(),d(u)},style:{background:"transparent",border:"none",color:r("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),s===u&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${r("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!m.type&&t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>p(u,"bookID"),style:{...pl,borderColor:r("source-bookid"),color:r("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:o.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>p(u,"url"),style:{...pl,borderColor:r("source-url"),color:r("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),m.type==="bookID"&&t.jsx(t.Fragment,{children:t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Dt,children:o.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const h=[...e];h[u]={...h[u],type:"",id:"",name:""},n(h)},style:ul,children:o.action.changeType})]}),m.id&&m.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:r("bg"),border:`1px solid ${r("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:r("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:m.name}),t.jsx("code",{style:{fontSize:"11px",background:r("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:m.id})]}),t.jsx("button",{onClick:()=>g(u),style:{background:"transparent",border:`1px solid ${r("widget-border")}`,color:r("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):t.jsxs("button",{onClick:()=>g(u),style:{width:"100%",padding:"14px",border:`2px dashed ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),m.type==="url"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("label",{style:Dt,children:o.label.sourceName}),t.jsx("button",{onClick:()=>{const h=[...e];h[u]={...h[u],type:"",id:"",name:""},n(h)},style:ul,children:o.action.changeType})]}),t.jsx("input",{type:"text",value:m.name,onChange:h=>c(u,"name",h.target.value),placeholder:o.editor.sourceNamePlaceholder,style:vn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.urlAddress}),t.jsx("input",{type:"text",value:m.id,onChange:h=>c(u,"id",h.target.value),placeholder:"https://...",style:vn})]})]}),m.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${r("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...Dt,opacity:.7},children:o.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.detailsOptional}),t.jsx("input",{type:"text",value:m.details,onChange:h=>c(u,"details",h.target.value),placeholder:o.editor.detailsPlaceholder,style:vn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.positionOptional}),t.jsx("input",{type:"text",value:m.position,onChange:h=>c(u,"position",h.target.value),placeholder:"如: 卷三, p.52",style:vn})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.dataVersionOptional}),t.jsx("input",{type:"text",value:m.version,onChange:h=>c(u,"version",h.target.value),placeholder:"如: v1.0, 2024-01",style:vn})]}),t.jsxs("div",{children:[t.jsx("label",{style:Dt,children:o.label.processorVersionOptional}),t.jsx("input",{type:"text",value:m.processor_version,onChange:h=>c(u,"processor_version",h.target.value),placeholder:"如: v0.1",style:vn})]})]})]})]})})]},u)),t.jsxs("button",{onClick:l,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:o.action.addSource})]})]})},Dt={display:"block",fontSize:"11px",color:r("desc-fg"),marginBottom:"4px",fontWeight:500},vn={width:"100%",padding:"6px 8px",background:r("input-bg"),color:r("input-fg"),border:`1px solid ${r("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},pl={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:r("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},ul={background:"transparent",border:"none",color:r("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function qd(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(i=>({id:i.id||"",name:i.name||"",type:i.type||"",details:i.details||"",position:i.position||"",version:i.version||"",processor_version:i.processor_version||""}))}catch{}return[]}function Xd(e){return!e||e.length===0?"":JSON.stringify(e)}const Zd=({entityType:e,entityId:n,entityTitle:i,parentWork:o,parentCollection:s,belongsToWork:a,belongsToCollection:l,childWorks:d,childCollections:c,containedBooks:p,siblingBooks:g,onLinkEntity:m,onUnlinkEntity:u,onViewEntity:h,onCreateAndLink:x,onSaveRelations:j})=>{const b=Be();return t.jsxs("div",{style:{background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${r("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:b.section.relations})]}),j&&t.jsx("button",{onClick:j,style:ny,children:b.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Vn,{direction:"up",title:b.relation.belongsToWork,entity:a,onView:h,onUnlink:()=>u("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(Vn,{direction:"up",title:b.relation.containedInCollection,entity:l,onView:h,onUnlink:()=>u("collectionId"),onLink:()=>m("collectionId","collection"),onCreate:()=>x("collectionId","collection",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),a&&g&&g.length>0&&t.jsx(kn,{direction:"horizontal",title:`${b.relation.siblingVersions} (${g.length})`,entities:g,onView:h,onAdd:()=>x("siblingBook","book",{workId:a.id}),addLabel:b.relation.addVersionForWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Vn,{direction:"up",title:b.relation.parentWork,entity:o,onView:h,onUnlink:()=>u("parentWorkId"),onLink:()=>m("parentWorkId","work"),onCreate:()=>x("parentWorkId","work"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),d&&d.length>0&&t.jsx(kn,{direction:"down",title:`${b.relation.childWorks} (${d.length})`,entities:d,onView:h,onAdd:()=>x("childWork","work",{parentWorkId:n}),addLabel:b.action.addSubWork,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),c&&c.length>0&&t.jsx(kn,{direction:"down",title:`${b.relation.collectionImpl} (${c.length})`,entities:c,onView:h,onAdd:()=>x("childCollection","collection",{workId:n}),addLabel:b.action.addCollectionImpl,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),t.jsx(kn,{direction:"down",title:`${b.relation.allVersions} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:h,onAdd:()=>x("childBook","book",{workId:n}),addLabel:b.action.addVersion,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Vn,{direction:"up",title:b.relation.correspondingWork,entity:a,onView:h,onUnlink:()=>u("workId"),onLink:()=>m("workId","work"),onCreate:()=>x("workId","work",{title:i}),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(Vn,{direction:"up",title:b.relation.parentCollection,entity:s,onView:h,onUnlink:()=>u("parentCollectionId"),onLink:()=>m("parentCollectionId","collection"),onCreate:()=>x("parentCollectionId","collection"),linkLabel:b.action.linkExisting,createLabel:b.action.createAndLink,notLinkedLabel:b.relation.notLinked,viewLabel:b.action.viewEntity,unlinkLabel:b.action.unlink}),t.jsx(kn,{direction:"down",title:`${b.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:h,onAdd:()=>x("childCollection","collection",{parentCollectionId:n}),addLabel:b.action.addSubCollection,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore}),t.jsx(kn,{direction:"down",title:`${b.relation.containedBooks} (${(p==null?void 0:p.length)??0})`,entities:p||[],onView:h,onAdd:()=>x("childBook","book",{collectionId:n}),addLabel:b.action.addBook,noneLabel:b.relation.none,expandMoreLabel:b.action.expandMore})]})]})]})},Vn=({direction:e,title:n,entity:i,onView:o,onUnlink:s,onLink:a,onCreate:l,linkLabel:d,createLabel:c,notLinkedLabel:p,viewLabel:g,unlinkLabel:m})=>{const u=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),h=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("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})]}),i?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:r("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Jd(i.type)}),t.jsx("span",{style:{fontWeight:500},children:i.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:i.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx(ml,{onClick:()=>o(i),title:g,children:"👁️"}),t.jsx(ml,{onClick:s,title:m,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:p}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(mo,{onClick:a,children:d}),t.jsx(mo,{onClick:l,primary:!0,children:c})]})]})},kn=({direction:e,title:n,entities:i,onView:o,onAdd:s,addLabel:a,noneLabel:l,expandMoreLabel:d})=>{const[c,p]=f.useState(!1),g=r(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",u=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"4px",padding:"10px",background:r("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:g,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:m}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[u.map(h=>t.jsxs("div",{onClick:()=>o(h),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:r("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:Jd(h.type)}),t.jsx("span",{children:h.title})]},h.id)),i.length>5&&!c&&t.jsxs("div",{onClick:()=>p(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:r("link-fg"),cursor:"pointer"},children:[d," (",i.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:r("bg"),borderRadius:"4px",color:r("desc-fg"),fontSize:"12px",textAlign:"center"},children:l}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(mo,{onClick:s,primary:!0,children:["+ ",a]})})]})},ml=({onClick:e,title:n,danger:i,children:o})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:i?r("danger"):"inherit",opacity:.7},children:o}),mo=({onClick:e,primary:n,children:i})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${r("widget-border")}`,borderRadius:"4px",background:n?r("primary"):"transparent",color:n?r("primary-fg"):"inherit",cursor:"pointer"},children:i});function Jd(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const ny={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Qd=({isOpen:e,entityType:n,title:i,onSelect:o,onCancel:s,onCreate:a,searchResults:l,onSearch:d,isLoading:c,excludeId:p})=>{const[g,m]=f.useState(""),u=p?l.filter(b=>b.id!==p):l;f.useEffect(()=>{e&&(m(""),d(""))},[e]);const h=b=>{m(b),d(b)};if(!e)return null;const x=n==="work"?"作品":n==="book"?"书籍":"丛编",j=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:iy,children:t.jsxs("div",{style:ry,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:i}),t.jsx("button",{onClick:s,style:oy,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:g,onChange:b=>h(b.target.value),placeholder:`搜索${x}名称或 ID...`,autoFocus:!0,style:sy})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:Br,children:"搜索中..."}):u.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:u.map(b=>t.jsxs("div",{onClick:()=>o(b),style:ay,children:[t.jsx("span",{style:{fontSize:"16px"},children:j}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[b.title,b.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:b.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[b.id,b.author&&` · ${b.author}`,b.dynasty&&` · ${b.dynasty}`]})]})]},b.id))}):g?t.jsxs("div",{style:Br,children:["未找到匹配的",x]}):t.jsxs("div",{style:Br,children:["输入关键词搜索",x]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:a,style:ly,children:["创建新",x,"并关联"]})]})]})})},iy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},ry={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},oy={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},sy={width:"100%",padding:"10px 12px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},ay={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:r("primary-soft")},Br={padding:"20px",textAlign:"center",color:r("desc-fg")},ly={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},gl={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},cy={work:"📜",book:"📖",collection:"📚",entity:"👤"},ep=({isOpen:e,entityType:n,relationField:i,inheritData:o,onConfirm:s,onCancel:a})=>{const[l,d]=f.useState(""),c=f.useRef(null);f.useEffect(()=>{e&&(d((o==null?void 0:o.title)||""),setTimeout(()=>{var u,h;(u=c.current)==null||u.focus(),(h=c.current)==null||h.select()},100))},[e,o==null?void 0:o.title]);const p=u=>{u.key==="Enter"&&l.trim()?g():u.key==="Escape"&&a()},g=()=>{l.trim()&&s(l.trim(),{...o,title:l.trim()})};if(!e)return null;const m=()=>{switch(i){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`创建新${gl[n]}`}};return t.jsx("div",{style:dy,onClick:u=>{u.target===u.currentTarget&&a()},children:t.jsxs("div",{style:py,onClick:u=>u.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:cy[n]}),t.jsx("span",{children:m()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:r("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:r("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:l,onChange:u=>d(u.target.value),onKeyDown:p,placeholder:`请输入${gl[n]}名称...`,style:uy})]}),((o==null?void 0:o.author)||(o==null?void 0:o.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),background:r("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(o==null?void 0:o.author)&&t.jsxs("div",{children:["作者: ",o.author]}),(o==null?void 0:o.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",o.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:a,style:my,children:"取消"}),t.jsx("button",{onClick:g,disabled:!l.trim(),style:{...gy,opacity:l.trim()?1:.6,cursor:l.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},dy={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},py={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:r("shadow-dialog")},uy={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${r("input-border")}`,borderRadius:"4px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box"},my={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",color:r("fg"),cursor:"pointer"},gy={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg")};function fy(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function tp(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function hy(e){switch(e){case"work":return r("editor-type-work");case"collection":return r("editor-type-collection");case"book":return r("editor-type-book");default:return r("desc-fg")}}const np=({isOpen:e,title:n,filterType:i="all",recentEntities:o=[],excludeId:s,showCreateButton:a=!1,createButtonText:l,onSelect:d,onCancel:c,onCreate:p,onSearch:g})=>{const[m,u]=f.useState(""),[h,x]=f.useState([]),[j,b]=f.useState(!1),[S,y]=f.useState("recent");f.useEffect(()=>{e&&(u(""),x([]),y(o.length>0?"recent":"search"))},[e,o.length]),f.useEffect(()=>{if(!m.trim()){x([]);return}const $=setTimeout(async()=>{b(!0);try{x(await g(m,i))}catch{x([])}finally{b(!1)}},300);return()=>clearTimeout($)},[m,i,g]);const k=f.useCallback($=>{u($.target.value),$.target.value.trim()&&y("search")},[]),w=f.useCallback($=>s?$.filter(A=>A.id!==s):$,[s]);if(!e)return null;const v=n||(i==="all"?"选择实体":`选择${tp(i)}`),C=w(o),_=w(h);return t.jsx("div",{style:by,children:t.jsxs("div",{style:yy,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:v}),t.jsx("button",{onClick:c,style:jy,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:m,onChange:k,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:vy}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),j&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),C.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${r("widget-border")}`},children:[t.jsxs(fl,{active:S==="recent",onClick:()=>y("recent"),children:["最近使用 (",C.length,")"]}),t.jsxs(fl,{active:S==="search",onClick:()=>y("search"),children:["搜索结果 ",_.length>0&&`(${_.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:S==="recent"&&C.length>0?t.jsx(hl,{entities:C,onSelect:d}):m.trim()?j?t.jsx(Or,{message:"搜索中..."}):_.length>0?t.jsx(hl,{entities:_,onSelect:d}):t.jsx(Or,{message:"未找到匹配的结果"}):t.jsx(Or,{message:"输入关键词开始搜索"})}),a&&p&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${r("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:p,style:ky,children:l||"创建新实体"})]})]})})},fl=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${r("primary")}`:"2px solid transparent",background:"transparent",color:r(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),hl=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(xy,{entity:i,onClick:()=>n(i)},i.id))}),xy=({entity:e,onClick:n})=>{const[i,o]=f.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:r("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:fy(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:r("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:r("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:hy(e.type),color:r("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:tp(e.type)})]})},Or=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:r("desc-fg"),fontSize:"13px"},children:e}),by={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},yy={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:r("shadow-dialog")},jy={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},vy={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),fontSize:"13px",boxSizing:"border-box"},ky={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:r("primary"),color:r("primary-fg"),cursor:"pointer"},wy={work:r("editor-type-work"),collection:r("editor-type-collection"),book:r("editor-type-book"),entity:r("editor-type-entity")},Sy={work:"📜",collection:"📚",book:"📖",entity:"👤"},ip=({data:e,onChange:n,onSave:i,transport:o,onNavigate:s,showDelete:a,onDelete:l,onAskAI:d,renderSectionActions:c,onDownloadResource:p,downloadStatuses:g,relations:m,onRelationsChange:u})=>{var te;const h=Be(),[x,j]=f.useState(!1),[b,S]=f.useState("work"),[y,k]=f.useState(""),[w,v]=f.useState(""),[C,_]=f.useState([]),[$,A]=f.useState(!1),[R,z]=f.useState(!1),[N,M]=f.useState("work"),[O,L]=f.useState(""),[D,q]=f.useState(),[J,se]=f.useState(!1),[U,K]=f.useState(null),[Z,oe]=f.useState([]);f.useRef(null);const ye=e.type,Le=ye==="work",Me=ye==="collection",Se=ye==="book",le=f.useCallback((H,ue)=>{n({...e,[H]:ue})},[e,n]),Oe=f.useCallback((H,ue)=>{k(H),S(ue),v(h.editor.selectToLink+h.indexType[ue]),_([]),j(!0)},[h]),T=f.useCallback(H=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(e.id,H)},[o,e.id]),de=f.useCallback(H=>{s==null||s(H.id,H.type)},[s]),pe=f.useCallback((H,ue,Fe)=>{const Ge={...Fe,author:(Fe==null?void 0:Fe.author)||e.author,dynasty:Fe==null?void 0:Fe.dynasty};M(ue),L(H),q(Ge),z(!0)},[e.author]),B=f.useCallback((H,ue)=>{o!=null&&o.createAndLink&&o.createAndLink(e.id,O,{type:N,title:H,inheritData:ue}),z(!1)},[o,e.id,O,N]),ee=f.useCallback(H=>{if(!H.trim()){_([]);return}A(!0),o!=null&&o.searchEntities&&o.searchEntities(H,b).then(ue=>{_(ue),A(!1)}).catch(()=>{_([]),A(!1)})},[o,b]),Ce=f.useCallback(H=>{o!=null&&o.linkEntity&&o.linkEntity(e.id,y,H.id),j(!1)},[o,e.id,y]),Ie=f.useCallback(()=>{i()},[i]),We=f.useCallback(H=>{K(()=>H),se(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(oe).catch(()=>{})},[o]),G=f.useCallback((H,ue)=>o!=null&&o.searchEntities?o.searchEntities(H,ue==="all"?void 0:ue):Promise.resolve([]),[o]),he=f.useCallback(H=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(H),oe(ue=>[H,...ue.filter(Fe=>Fe.id!==H.id)].slice(0,10)),U==null||U(H),se(!1),K(null)},[o,U]);return t.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${r("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:Sy[ye]}),t.jsx("span",{children:e.title||h.editor.untitled}),t.jsx(Oi,{children:e.id}),t.jsx(Oi,{color:wy[ye],children:h.indexType[ye]})]})}),t.jsx(Et,{title:h.section.basicInfo,onSave:i,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(Ii,{label:Le?h.editor.workTitle:Me?h.editor.collectionTitle:h.editor.bookTitle,value:e.title,onChange:H=>le("title",H)}),Se&&t.jsx(Ii,{label:h.editor.belongsToWork,value:e.workName||"",onChange:H=>le("workName",H)}),t.jsx(Ct,{label:h.editor.authorLabel,value:e.author||"",onChange:H=>le("author",H)}),t.jsx(Ct,{label:h.editor.publicationYearLabel,value:e.publicationYear||"",onChange:H=>le("publicationYear",H)}),(Se||Me)&&t.jsx(Ii,{label:h.editor.containedIn,value:e.collection||"",onChange:H=>le("collection",H)}),(Se||Me)&&t.jsx(Ct,{label:h.editor.holderLabel,value:e.holder||"",onChange:H=>le("holder",H)}),(Se||Me)&&t.jsx(Ct,{label:Se?h.editor.pageLabel:h.editor.volumeLabel,value:e.pages||"",onChange:H=>le("pages",H)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(Ct,{label:h.editor.firstImageLabel,value:e.firstImage||"",onChange:H=>le("firstImage",H)})})]})}),t.jsx(Et,{title:h.section.description,onSave:i,onAskAI:d?()=>d("介绍"):void 0,children:t.jsx(mn,{value:e.description||"",onChange:H=>le("description",H),placeholder:h.editor.descriptionPlaceholder})}),(((te=e.additional_works)==null?void 0:te.length)||0)>0&&t.jsx(Et,{title:h.section.additionalWorks,onSave:i,children:t.jsx(_y,{items:e.additional_works||[],onChange:H=>le("additional_works",H)})}),t.jsx(Et,{title:h.section.indexedBy,onSave:i,onAskAI:d?()=>d("收录于"):void 0,children:t.jsx($y,{items:e.indexed_by||[],onChange:H=>le("indexed_by",H)})}),t.jsx(Et,{title:h.section.emendatedBy,onSave:i,onAskAI:d?()=>d("考证"):void 0,children:t.jsx(Cy,{items:e.emendated_by||[],onChange:H=>le("emendated_by",H)})}),t.jsx(Et,{title:h.section.textResources,onSave:i,onAskAI:d?()=>d("资源"):void 0,children:t.jsx(Vr,{items:e.resources||[],onChange:H=>le("resources",H),onDownload:p,downloadStatuses:g,filterType:"text"})}),t.jsx(Et,{title:h.section.imageResources,onSave:i,children:t.jsx(Vr,{items:e.resources||[],onChange:H=>le("resources",H),onDownload:p,downloadStatuses:g,filterType:"image"})}),t.jsx(Et,{title:h.section.sources,onSave:i,onAskAI:d?()=>d("资料来源"):void 0,children:t.jsx(Kd,{items:qd(e.sources||""),onChange:H=>le("sources",Xd(H)),onOpenEntityPicker:We})}),(Se||Me)&&t.jsx(Et,{title:h.section.provenance,onSave:i,onAskAI:d?()=>d("收藏历史"):void 0,children:t.jsx(mn,{value:e.provenance||"",onChange:H=>le("provenance",H),placeholder:h.editor.provenancePlaceholder})}),Se&&t.jsx(Et,{title:h.section.otherEditions,onSave:i,onAskAI:d?()=>d("其他版本"):void 0,children:t.jsx(mn,{value:e.otherEditions||"",onChange:H=>le("otherEditions",H),placeholder:h.editor.otherEditionsPlaceholder})}),t.jsx(Zd,{entityType:ye,entityId:e.id,entityTitle:e.title,parentWork:m==null?void 0:m.parentWork,parentCollection:m==null?void 0:m.parentCollection,belongsToWork:m==null?void 0:m.belongsToWork,belongsToCollection:m==null?void 0:m.belongsToCollection,childWorks:m==null?void 0:m.childWorks,childCollections:m==null?void 0:m.childCollections,containedBooks:m==null?void 0:m.containedBooks,siblingBooks:m==null?void 0:m.siblingBooks,onLinkEntity:Oe,onUnlinkEntity:T,onViewEntity:de,onCreateAndLink:pe,onSaveRelations:Ie}),a&&l&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${r("danger-soft-border")}`,background:r("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:r("danger"),fontWeight:600,marginBottom:"8px"},children:h.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:r("desc-fg"),marginBottom:"12px"},children:h.editor.dangerZoneDesc}),t.jsx("button",{onClick:l,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("danger")}`,borderRadius:"4px",background:"transparent",color:r("danger"),cursor:"pointer"},children:h.editor.deleteEntity})]}),t.jsx(Qd,{isOpen:x,entityType:b,title:w,onSelect:Ce,onCancel:()=>j(!1),onCreate:()=>{j(!1),pe(y,b)},searchResults:C,onSearch:ee,isLoading:$,excludeId:e.id}),t.jsx(ep,{isOpen:R,entityType:N,relationField:O,inheritData:D,onConfirm:B,onCancel:()=>z(!1)}),t.jsx(np,{isOpen:J,title:h.action.selectBookOrWork,filterType:"all",recentEntities:Z,excludeId:e.id,onSelect:he,onCancel:()=>{se(!1),K(null)},onSearch:G})]})};function _y({items:e,onChange:n}){const i=Be(),o=(l,d,c)=>{const p=e.map((g,m)=>m===l?{...g,[d]:c}:g);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:i.editor.bookNameLabel,value:l.book_title,onChange:c=>o(d,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(Ct,{label:i.label.juanCount,value:l.n_juan!=null?String(l.n_juan):"",onChange:c=>o(d,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(d),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("muted"),marginTop:"18px"},children:"✕"})]},d)),t.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:i.action.addAdditionalWork})]})}function rp({items:e,onChange:n,showMeta:i,addLabel:o}){const s=Be(),[a,l]=f.useState(null),d=(g,m,u)=>{const h=e.map((x,j)=>j===g?{...x,[m]:u||void 0}:x);n(h)},c=g=>{n(e.filter((m,u)=>u!==g)),a===g&&l(null)},p=()=>{n([...e,{source:""}]),l(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((g,m)=>{const u=a===m;return t.jsxs("div",{style:{border:`1px solid ${r("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:u?`color-mix(in srgb, ${r("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>l(u?null:m),children:[t.jsx("span",{style:{fontSize:"10px",color:r("desc-fg"),transition:"transform 0.2s",transform:u?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:g.source||s.editor.unnamedSource}),g.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:r("desc-fg")},children:g.source_bid}),t.jsx("button",{onClick:h=>{h.stopPropagation(),c(m)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${r("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:r("muted")},children:"✕"})]}),!u&&i&&(g.title_info||g.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:r("desc-fg")},children:[g.title_info,g.title_info&&g.author_info&&" — ",g.author_info]}),u&&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:g.source,onChange:h=>d(m,"source",h)}),t.jsx(Ct,{label:s.label.sourceBid,value:g.source_bid||"",onChange:h=>d(m,"source_bid",h)})]}),i&&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:g.title_info||"",onChange:h=>d(m,"title_info",h)}),t.jsx(Ct,{label:s.label.authorInfo,value:g.author_info||"",onChange:h=>d(m,"author_info",h)})]}),t.jsx(Ct,{label:s.label.edition,value:g.edition||"",onChange:h=>d(m,"edition",h)})]}),t.jsx(mn,{value:g.summary||"",onChange:h=>d(m,"summary",h),placeholder:s.editor.summaryPlaceholder}),t.jsx(mn,{value:g.comment||"",onChange:h=>d(m,"comment",h),placeholder:s.editor.commentPlaceholder}),t.jsx(mn,{value:g.additional_comment||"",onChange:h=>d(m,"additional_comment",h),placeholder:s.editor.additionalCommentPlaceholder})]})]},m)}),t.jsx("button",{onClick:p,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${r("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:r("desc-fg"),alignSelf:"flex-start"},children:o})]})}function $y({items:e,onChange:n}){const i=Be();return t.jsx(rp,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Cy({items:e,onChange:n}){const i=Be();return t.jsx(rp,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function op(e){var d,c,p,g,m,u,h;const n=((c=(d=e.authors)==null?void 0:d[0])==null?void 0:c.name)||"",i=((p=e.publication_info)==null?void 0:p.year)||"",o=((g=e.current_location)==null?void 0:g.name)||"",s=(m=e.page_count)!=null&&m.number?String(e.page_count.number):((u=e.page_count)==null?void 0:u.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:i,holder:o,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 j=x.related_works.find(b=>b.relation==="part_of");j&&(l.parentWorkId=j.id,l.parentWorkName=j.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=(h=x.contained_in[0])==null?void 0:h.id)}return l}function zy(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 Ny=e=>{const{data:n,id:i,transport:o,mode:s="view",onModeChange:a,onChange:l,onSave:d,onDelete:c,onNavigate:p,renderLink:g,onAskAI:m,renderSectionActions:u,onDownloadResource:h,downloadStatuses:x,relations:j,onRelationsChange:b,headerExtra:S,className:y,style:k}=e,w=Be(),[v,C]=f.useState(s),_=a?s:v;f.useEffect(()=>{s!==v&&C(s)},[s]);const $=f.useCallback(()=>{const L=_==="view"?"edit":"view";a?a(L):C(L)},[_,a]),[A,R]=f.useState(null);f.useEffect(()=>{i&&o&&o.getItem(i).then(L=>{L&&R(L)})},[i,o]);const z=n||A,N=f.useMemo(()=>z?op(z):null,[z]),M=a||!n?t.jsx("button",{onClick:$,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${r("widget-border")}`,borderRadius:"4px",background:_==="edit"?r("accent-bg"):"transparent",color:r(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?w.common.switchToEdit:w.common.switchToView,children:_==="view"?w.common.modeEdit:w.common.modeView}):null,O=t.jsxs(t.Fragment,{children:[M,S]});return!z&&!N?t.jsx(gn,{}):_==="view"?t.jsx(Bo,{data:z,transport:o,onNavigate:p?L=>p(L):void 0,renderLink:g,headerExtra:O,className:y,style:k}):N?t.jsxs("div",{className:y,style:k,children:[O&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:O}),t.jsx(ip,{data:N,onChange:l||(()=>{}),onSave:d||(()=>{}),transport:o,onNavigate:p,showDelete:!!c,onDelete:c,onAskAI:m,renderSectionActions:u,onDownloadResource:h,downloadStatuses:x,relations:j,onRelationsChange:b})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:r("muted")},children:w.common.noData})},Ty=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],sp=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:o})=>{const{t:s}=ae(),[a,l]=f.useState(null),[d,c]=f.useState(""),[p,g]=f.useState(""),[m,u]=f.useState("idle"),[h,x]=f.useState(""),j=f.useRef(null);f.useEffect(()=>{e&&(l(null),c(""),g(""),u("idle"),x(""))},[e]),f.useEffect(()=>{a&&setTimeout(()=>{var y;return(y=j.current)==null?void 0:y.focus()},100)},[a]),f.useEffect(()=>{if(m==="success"){const y=setTimeout(n,2e3);return()=>clearTimeout(y)}},[m,n]),f.useEffect(()=>{if(!e)return;const y=k=>{k.key==="Escape"&&n()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[e,n]);const b=async()=>{if(!(!a||!d.trim())){u("submitting"),x("");try{await i({type:a,content:d.trim(),...p.trim()?{contact:p.trim()}:{}}),u("success")}catch(y){u("error"),x(y instanceof Error?y.message:s("feedback.submitFailedRetry"))}}};if(!e)return null;const S=a&&d.trim()&&m!=="submitting";return t.jsx("div",{style:Ry,onClick:y=>{y.target===y.currentTarget&&n()},children:t.jsxs("div",{style:Iy,onClick:y=>y.stopPropagation(),children:[t.jsxs("div",{style:Ey,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:s("feedback.title")}),t.jsx("button",{onClick:n,style:Ly,"aria-label":s("feedback.close"),children:"✕"})]}),m==="success"?t.jsxs("div",{style:Oy,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:s("feedback.thanks")}),o&&t.jsx("a",{href:o,style:{fontSize:"13px",color:r("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:Ty.map(y=>t.jsxs("button",{onClick:()=>l(y.value),style:{...Ay,...a===y.value?My:{}},children:[t.jsx("span",{children:y.icon})," ",s(`feedback.submitType.${y.value}`)]},y.value))}),t.jsx("textarea",{ref:j,value:d,onChange:y=>c(y.target.value),placeholder:s(a?`feedback.placeholder.${a}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:!a||m==="submitting",style:{...Py,opacity:a?1:.6}}),t.jsx("input",{type:"text",value:p,onChange:y=>g(y.target.value),placeholder:s("feedback.contactPlaceholder"),maxLength:200,disabled:!a||m==="submitting","aria-label":s("feedback.contactLabel"),style:Fy}),t.jsxs("div",{style:{fontSize:"12px",color:r("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),m==="error"&&t.jsx("div",{style:Wy,children:h}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:b,disabled:!S,style:{...By,opacity:S?1:.6,cursor:S?"pointer":"not-allowed"},children:s(m==="submitting"?"feedback.submitting":"feedback.submitFeedback")})})]})]})})},Ry={position:"fixed",top:0,left:0,right:0,bottom:0,background:r("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Iy={background:r("bg"),border:`1px solid ${r("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:r("shadow-dialog")},Ey={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Ly={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:r("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Ay={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},My={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Py={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("input-bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},By={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},Oy={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:r("success")},Wy={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginBottom:"12px"},Fy={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},go="--bim-feedback-fab-offset",fo=48,Hy=16,Dy=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:o=!1,zIndex:s})=>{const{t:a}=ae(),[l,d]=f.useState(!1),c=n.bottom??24;return f.useEffect(()=>{if(o||typeof document>"u")return;const p=document.documentElement;return p.style.setProperty(go,`calc(${c+fo+Hy}px + env(safe-area-inset-bottom, 0px))`),()=>{p.style.removeProperty(go)}},[o,c]),t.jsxs(t.Fragment,{children:[!o&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...Uy,zIndex:s??r("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(sp,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:i})]})},Uy={position:"fixed",width:`${fo}px`,height:`${fo}px`,borderRadius:"50%",border:"none",background:r("primary"),color:r("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},Vy=[{value:"bug",icon:"🐛"},{value:"resource",icon:"📚"},{value:"suggestion",icon:"💡"},{value:"contact",icon:"🤝"}],ap=({onSubmit:e})=>{const{t:n}=ae(),[i,o]=f.useState("bug"),[s,a]=f.useState(""),[l,d]=f.useState(""),[c,p]=f.useState("idle"),[g,m]=f.useState(""),u=f.useRef(null);f.useEffect(()=>{i&&setTimeout(()=>{var j;return(j=u.current)==null?void 0:j.focus()},100)},[i]);const h=async()=>{if(!(!i||!s.trim())){p("submitting"),m("");try{await e({type:i,content:s.trim(),...l.trim()?{contact:l.trim()}:{}}),p("success"),a(""),d(""),o("bug")}catch(j){p("error"),m(j instanceof Error?j.message:n("feedback.submitFailedRetry"))}}},x=i&&s.trim()&&c!=="submitting";return c==="success"?t.jsx("div",{style:xl,children:t.jsxs("div",{style:Xy,children:[t.jsxs("span",{children:["✓ ",n("feedback.thanks")]}),t.jsx("button",{onClick:()=>p("idle"),style:Zy,children:n("feedback.continueSubmit")})]})}):t.jsxs("div",{style:xl,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Vy.map(j=>t.jsxs("button",{onClick:()=>o(j.value),style:{...Gy,...i===j.value?Yy:{}},children:[t.jsx("span",{children:j.icon})," ",n(`feedback.submitType.${j.value}`)]},j.value))}),t.jsx("textarea",{ref:u,value:s,onChange:j=>a(j.target.value),placeholder:n(i?`feedback.placeholder.${i}`:"feedback.chooseTypeFirst"),maxLength:2e3,disabled:c==="submitting",style:{...Ky}}),t.jsx("input",{type:"text",value:l,onChange:j=>d(j.target.value),placeholder:n("feedback.contactPlaceholder"),maxLength:200,disabled:c==="submitting","aria-label":n("feedback.contactLabel"),style:Qy}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:r("desc-fg")},children:[s.length," / 2000"]}),t.jsx("button",{onClick:h,disabled:!x,style:{...qy,opacity:x?1:.6,cursor:x?"pointer":"not-allowed"},children:n(c==="submitting"?"feedback.submitting":"feedback.submit")})]}),c==="error"&&t.jsx("div",{style:Jy,children:g})]})},xl={padding:"16px",border:`1px solid ${r("widget-border")}`,borderRadius:"8px",background:r("input-bg")},Gy={padding:"8px 16px",fontSize:"13px",border:`1px solid ${r("widget-border")}`,borderRadius:"6px",background:"transparent",color:r("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Yy={borderColor:r("primary"),background:r("list-active-bg"),color:r("primary"),fontWeight:500},Ky={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},qy={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:r("primary"),color:r("primary-fg"),fontWeight:500},Xy={display:"flex",alignItems:"center",gap:"12px",color:r("success"),fontSize:"14px"},Zy={background:"none",border:"none",color:r("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},Jy={fontSize:"13px",color:r("danger"),padding:"8px 12px",background:r("danger-bg"),borderRadius:"4px",marginTop:"8px"},Qy={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${r("input-border")}`,borderRadius:"6px",background:r("bg"),color:r("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function bl(e){return typeof e=="function"?e():e??"/api/feedback"}const lp=({resourceId:e,apiUrl:n})=>{const{t:i}=ae(),[o,s]=f.useState([]),[a,l]=f.useState(!0),d=f.useCallback(async()=>{const p=bl(n);l(!0);try{const m=await(await fetch(`${p}?resourceId=${encodeURIComponent(e)}`)).json();m.success&&s(m.items)}catch{}finally{l(!1)}},[e,n]);f.useEffect(()=>{d()},[d]);const c=async p=>{const g=bl(n),m=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...p,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!m.ok){const u=await m.json().catch(()=>null);throw new Error((u==null?void 0:u.error)||i("feedback.submitFailed"))}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(hs,{items:o,loading:a}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(ap,{onSubmit:c})})]})},nr=8;async function ir(e,n,i,o){const s=Number.isFinite(n)?Math.max(1,Math.floor(n)):1,a=new Array(e.length);let l=0;const d=Array.from({length:Math.min(s,Math.max(1,e.length))},async()=>{for(;l<e.length&&!(o!=null&&o());){const c=l++;a[c]=await i(e[c],c)}});return await Promise.all(d),a}const e0=Hi["zh-Hant"].relation,t0=Hi["zh-Hant"].lossStatus,n0=Hi["zh-Hant"].resourceKind,rr=In("zh-Hant"),bs=(e,n)=>Object.prototype.hasOwnProperty.call(e,n);function yl(e,n=rr){return e?bs(e0,e)?n(`detail.relation.${e}`):e:n("detail.relation.related")}function i0(e,n=rr){return bs(t0,e)?n(`detail.lossStatus.${e}`):e}function r0(e,n=rr){return bs(n0,e)?n(`detail.resourceKind.${e}`):""}function ys({authors:e,onNavigate:n,renderLink:i}){const{convert:o}=ae(),s=(e||[]).filter(a=>a&&a.name);return s.length?t.jsx(t.Fragment,{children:s.map((a,l)=>{const d=Io(a.role);return t.jsxs(f.Fragment,{children:[l>0&&" ",a.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",o(a.dynasty),"〕"]}),a.entity_id?t.jsx(ut,{id:a.entity_id,label:o(a.name),onNavigate:n,renderLink:i,dense:!0}):o(a.name),d&&t.jsx("span",{style:{marginLeft:4},children:o(d)})]},l)})}):null}function cp(e,n,i=rr){var c,p;const o=To(e,n),s=o.mirrors.map(g=>({key:g.key,label:g.label,description:g.description,rows:g.items.filter(m=>m.group_role!=="mirror"),mirrors:g.items.filter(m=>m.group_role==="mirror")})),a=o.buckets.filter(g=>g.key==="image"||g.key==="textImage").flatMap(g=>g.items);a.length&&s.push({key:"_images",label:s.length?i("detail.otherImages"):void 0,rows:a,mirrors:[]});const l=((c=o.buckets.find(g=>g.key==="physical"))==null?void 0:c.items)??[];return l.length&&s.push({key:"_physical",label:i("detail.resourceKind.physical"),rows:l,mirrors:[]}),{text:((p=o.buckets.find(g=>g.key==="text"))==null?void 0:p.items)??[],groups:s}}function dp(e,n){const i=(e.url?Nn(e.url):void 0)||e.name,o=ic(e,n);return o?`${i}(${o})`:i}function js({item:e,siblings:n,listedVolumeCounts:i}){const{t:o,convert:s}=ae(),[a,l]=f.useState(!1),d=Fi(e),c=!!d&&d.expected>0&&!(i!=null&&i.has(d.expected)),p=s(dp(e,n)),g=Tn(e),m=Gi(e,o)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var h,x;const u=(h=e.metadata)!=null&&h.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:o("detail.fragmentTag")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:e.color_mode==="color"?o("colorMode.color"):o("colorMode.bw")})]}):null;return g?t.jsxs("a",{href:g,target:"_blank",rel:"noopener noreferrer",children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),u]}):t.jsxs("span",{className:"bim-d-zt-name",children:[p,u]})})(),m&&t.jsx("span",{className:"bim-d-meta",children:s(m)}),c&&a&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(Go,{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(u=>!u),children:a?o("detail.collapseVolumes"):o("detail.expandVolumes",{n:d.expected})})})]})}function pp({groups:e,listedVolumeCounts:n}){const{t:i,convert:o}=ae();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:o(s.label)}),s.description&&t.jsx("p",{className:"bim-d-rg-d",children:o(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(js,{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:i("detail.mirror")}),s.mirrors.map((a,l)=>{const d=Tn(a),c=o(dp(a,s.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:a.details?o(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 Qn=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function ho(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Qn.find(o=>n.startsWith(o.key[0])))==null?void 0:i.key}const jl=12,o0=60,up=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,railTop:a,back:l,railLinks:d})=>{var Ce,Ie,We;const{t:c,convert:p,messages:g}=ae(),m=f.useMemo(()=>Eo({_books:e._books}),[e._books]),[u,h]=f.useState(new Map),[x,j]=f.useState(!1),[b,S]=f.useState(""),[y,k]=f.useState(!1),w=m.length<=o0,v=w||x||!!b||y,C=f.useMemo(()=>v?m:m.slice(0,jl),[m,v]);f.useEffect(()=>{if(!n||C.length===0)return;const G=C.filter(te=>!u.has(te));if(G.length===0)return;let he=!1;return ir(G,nr,te=>n.getItem(te).then(H=>{var Fe;const ue=H??{};return[te,{id:te,title:ue.title,edition:ue.edition,resources:ue.resources,publication_info:ue.publication_info,current_location:ue.current_location,lineage:ue.lineage,measure_info:ue.measure_info,summary:s0((Fe=H==null?void 0:H.description)==null?void 0:Fe.text)}]}).catch(()=>[te,{id:te}]),()=>he).then(te=>{he||h(H=>{const ue=new Map(H);for(const[Fe,Ge]of te)ue.set(Fe,Ge);return ue})}),()=>{he=!0}},[n,C,u]);const _=f.useMemo(()=>m.map(G=>u.get(G)??{id:G}),[m,u]),$=m.length>0&&m.every(G=>u.has(G)),A=!!n&&C.some(G=>!u.has(G)),R=w||v,z=f.useMemo(()=>oc(_,e.version_graph,{era:b,scanOnly:y,sort:R?"year":"default"}),[_,e.version_graph,b,y,R]),N=x?z.rows:z.rows.slice(0,jl),M=z.allRows.filter(G=>G.hasImage).length,O=z.allRows.reduce((G,he)=>{var te;return G+(((te=he.copies)==null?void 0:te.length)??0)},0),L=f.useMemo(()=>(e._related||[]).map(G=>({...G,title:G.title??""})),[e._related]),D=L.filter(G=>G.relation==="collected_in"),q=f.useMemo(()=>{const G=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],he=te=>{const H=G.indexOf(te??"");return H<0?G.length:H};return L.filter(te=>te.relation!=="collected_in").map((te,H)=>({r:te,i:H})).sort((te,H)=>he(te.r.relation)-he(H.r.relation)||te.i-H.i).map(te=>te.r)},[L]),J=f.useMemo(()=>{const G=To(e.resources,e.resource_groups);return[...G.mirrors.flatMap(he=>he.items.map(te=>({r:te,kind:p(he.label)}))),...G.buckets.flatMap(he=>he.items.map(te=>({r:te,kind:p(r0(he.key,c))})))]},[e.resources,e.resource_groups,p,c]),se=e.indexed_by||[],U=e.emendated_by||[],K=f.useMemo(()=>{var F,ge,Ae;const G=[],he=(ge=(F=e.authors)==null?void 0:F[0])==null?void 0:ge.dynasty;he&&G.push({label:c("workPage.fact.written"),value:p(he)});const te=Kt(e,g.unit.juan);if(te){const W=(Ae=e.juan_count)==null?void 0:Ae.description;G.push({label:c("workPage.fact.measure"),value:t.jsxs(t.Fragment,{children:[p(te),W&&W!==te?t.jsxs("span",{className:"bim-d-meta",children:["(",p(W),")"]}):null]})})}e.loss_status&&G.push({label:c("workPage.fact.loss"),value:p(i0(e.loss_status,c))});const H=z.allRows.filter(W=>W.sortYear!=null),ue=H.length>0?H.reduce((W,be)=>W.sortYear<=be.sortYear?W:be):null;ue!=null&&ue.era.era?G.push({label:c("workPage.fact.earliest"),value:p([ue.era.era,ue.era.reign].filter(Boolean).join(" ")),title:ue.era.source==="edition"?c("workPage.inferredFromEdition"):void 0}):A&&G.push({label:c("workPage.fact.earliest"),value:t.jsx("span",{className:"bim-d-meta","aria-label":c("workPage.loading"),children:"…"})}),U.length&&G.push({label:c("workPage.fact.emendation"),value:c("workPage.emendationCount",{n:U.length})});const Fe=vl(e.additional_titles);Fe.length&&G.push({label:c("workPage.fact.alias"),value:Fe.map(p).join("、")});const Ge=vl(e.attached_texts);Ge.length&&G.push({label:c("workPage.fact.attached"),value:Ge.map(p).join("、")});const Je=(e.additional_works||[]).map(W=>p(W.book_title)+(W.n_juan!=null?` ${W.n_juan}${g.unit.juan}`:""));return Je.length&&G.push({label:c("workPage.fact.appendix"),value:Je.join("、")}),G},[e,p,c,g,A,z.allRows,U.length]),oe=[{value:e._edition_count??m.length,label:c("workPage.stat.editions")},{value:$?M:0,label:c("workPage.stat.hasImage")},{value:se.length,label:c("workPage.stat.catalogs")}],ye=Lo(e),Le=ye?[ye.l1,ye.l2,ye.l3,ye.l4].filter(Boolean).map(G=>p(G)):[],Me=e.subtype?g.workSubtype[e.subtype]??p(e.subtype):"",Se=t.jsx(oi,{title:p(e.title),byline:t.jsx(ys,{authors:e.authors,onNavigate:i,renderLink:o}),meta:t.jsx(ht,{items:[...Le,ye!=null&&ye.source?c("workPage.classifiedBy",{source:p(ye.source.split("/")[0])}):"",Me]}),description:(Ce=e.description)!=null&&Ce.text?t.jsxs(t.Fragment,{children:[t.jsx(qt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(Ie=e.description.sources)!=null&&Ie.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(G=>({text:p(Zm(G)),href:Jm(G)})).filter(G=>G.text).map((G,he)=>t.jsxs(f.Fragment,{children:[he>0?" · ":null,G.href?t.jsx("a",{href:G.href,target:"_blank",rel:"noopener noreferrer",children:G.text}):G.text]},he))}):null]}):void 0,stats:oe,facts:K,readAction:s,foot:t.jsx(si,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(We=e.appendix)==null?void 0:We.map((G,he)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:p(G.title)}),t.jsx(qt,{text:G.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},he))}),le=z.eras.length>=2?[{key:"",label:c("catalog.all")},...z.eras.map(G=>({key:G,label:`${G} ${z.allRows.filter(he=>he.era.era===G).length}`}))]:[],Oe=[];m.length&&Oe.push({id:"versions",label:c("workPage.sec.versions"),count:m.length}),se.length&&Oe.push({id:"catalogs",label:c("workPage.sec.catalogs"),count:se.length}),D.length&&Oe.push({id:"collected",label:c("workPage.sec.collected"),count:D.length}),q.length&&Oe.push({id:"related",label:c("workPage.sec.related"),count:q.length}),J.length&&Oe.push({id:"resources",label:c("workPage.sec.resources"),count:J.length});const T=m.length===0&&se.length===0,de=t.jsxs(t.Fragment,{children:[m.length>0&&t.jsxs(bt,{id:"versions",title:c("workPage.sec.versions"),meta:t.jsx(ht,{items:[c("workPage.versionsTotal",{n:m.length-O}),$&&M?c("workPage.versionsWithImage",{n:M}):"",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":A&&le.length===0&&m.length>1?"":void 0,children:[le.length>0&&t.jsx(Ji,{items:le,value:b,onChange:G=>{S(G),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Xc,{label:c("workPage.scanOnly"),checked:y,onChange:G=>{k(G),j(!1)}}),t.jsx("span",{className:"bim-d-meta",children:c(R?"workPage.sortByYear":"workPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver","data-ncap":!x&&Qi(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:N.map(G=>{var he;return t.jsx(l0,{row:G,measure:(he=u.get(G.id))==null?void 0:he.measure_info,loaded:u.has(G.id),onNavigate:i,renderLink:o},`${G.id}:${u.has(G.id)?"r":"p"}`)})})]}),N.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c(b||y?"workPage.noVersionsFiltered":"workPage.noVersions")}),!x&&t.jsx(Ho,{total:z.rows.length,shown:N.length,unit:c("workPage.moreUnit"),onClick:()=>j(!0)}),z.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:c("workPage.inferredEraNote")})]}),se.length>0&&t.jsx(c0,{items:se,transport:n,onNavigate:i,renderLink:o}),T&&t.jsx(bt,{title:c("workPage.sec.versions"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("workPage.empty")})})]}),pe=(G,he)=>t.jsx(ut,{id:G,label:p(he),onNavigate:i,renderLink:o,dense:!0}),B=f.useMemo(()=>{const G=new Map;for(const he of q){const te=yl(he.relation,c);G.set(te,(G.get(te)??0)+1)}return G.size>1?[...G.entries()].sort((he,te)=>te[1]-he[1]).slice(0,4).map(([he,te])=>`${p(he)} ${te}`).join(" · "):void 0},[q,p,c]),ee=t.jsxs(t.Fragment,{children:[t.jsx(un,{id:"collected",title:c("workPage.sec.collected"),items:D.map(G=>pe(G.id,G.title))}),t.jsx(un,{id:"related",title:c("workPage.sec.related"),meta:c("workPage.relatedCount",{n:q.length}),sub:B,items:q.map(G=>t.jsxs(t.Fragment,{children:[pe(G.id,G.title),t.jsx("span",{className:"bim-d-meta",title:G.note?p(G.note):void 0,children:p(yl(G.relation,c))})]}))}),t.jsx(un,{id:"resources",title:c("workPage.sec.resources"),cap:6,items:J.map(({r:G,kind:he})=>{const te=p((G.url?Nn(G.url):void 0)||G.name),H=Tn(G);return t.jsxs(t.Fragment,{children:[H?t.jsxs("a",{href:H,target:"_blank",rel:"noopener noreferrer",children:[te," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:te}),he&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:he})]})})})]});return t.jsx(ri,{railTop:a,back:l,nav:Oe,railLinks:d,main:de,card:Se,side:ee})};function vl(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function xo(e,n){return n((e.url?Nn(e.url):void 0)||e.name)}function s0(e){var a;if(!e)return;const i=e.replace(/\*\*/g,"").split(/\n/)[0].trim().match(/[^。]+。?/g)??[],s=((i.length>1&&((a=i[0])!=null&&a.startsWith("《"))?i[1]:i[0])??"").trim();return s?s.length>120?`${s.slice(0,120)}…`:s:void 0}function a0({copies:e,onNavigate:n,renderLink:i}){const{t:o,convert:s}=ae(),a=new Map;for(const l of e){const d=l.locationName||(l.holders[0]?xo(l.holders[0],s):"")||"",c=a.get(d)??[];c.push(l),a.set(d,c)}return t.jsxs("span",{className:"bim-d-zt-copies",children:[o("workPage.sameEditionCopies",{n:e.length}),[...a].map(([l,d],c)=>t.jsxs(f.Fragment,{children:[c>0?";":"",l?`${s(l)} `:"",d.map((p,g)=>t.jsxs(f.Fragment,{children:[g>0?" · ":"",t.jsx(ut,{id:p.id,label:p.callNumber||p.id,onNavigate:n,renderLink:i,dense:!0})]},p.id))]},l||c))]})}function l0({row:e,measure:n,loaded:i,onNavigate:o,renderLink:s}){const{t:a,convert:l}=ae(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),c=e.era.source==="edition",p=e.holders[0],g=e.copies??[],m=g.length&&e.locationName?l(e.locationName):p?xo(p,l):e.locationName?l(e.locationName):"",u=e.images[0],h=u?Tn(u):void 0,x=e.images.map(j=>xo(j,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",className:g.length?"bim-d-zt-group":void 0,children:[t.jsxs("td",{className:g.length?"bim-d-zt-main bim-d-zt-rep":"bim-d-zt-main",children:[t.jsx(ut,{id:e.id,label:l(e.name),onNavigate:o,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:" "}),g.length>0&&e.summary&&t.jsx("span",{className:"bim-d-zt-summary",children:l(e.summary)}),g.length>0&&t.jsx(a0,{copies:g,onNavigate:o,renderLink:s})]}),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):i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${m?"":" bim-d-zt-blank"}`,children:[m||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),g.length>0&&e.callNumber&&t.jsx("span",{className:"bim-d-meta",style:{display:"block",fontSize:12},children:e.callNumber}),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(h?t.jsx("a",{className:"bim-d-flag",href:h,target:"_blank",rel:"noopener noreferrer",title:x,children:a("workPage.hasImage")}):t.jsx("span",{className:"bim-d-flag",title:x,children:a("workPage.hasImage")}))})]})}function c0({items:e,transport:n,onNavigate:i,renderLink:o}){const{t:s,convert:a}=ae(),[l,d]=f.useState(0),c=Math.min(l,e.length-1),p=e[c],[g,m]=f.useState(new Map);return f.useEffect(()=>{if(!n)return;const u=[...new Set(e.map(x=>x.source_bid).filter(x=>!!x))];if(u.length===0)return;let h=!1;return Promise.all(u.map(x=>n.getItem(x).then(j=>{var b,S;return[x,((S=(b=j==null?void 0:j.authors)==null?void 0:b[0])==null?void 0:S.dynasty)??""]}).catch(()=>[x,""]))).then(x=>{h||m(new Map(x.filter(([,j])=>j)))}),()=>{h=!0}},[n,e]),t.jsx(bt,{id:"catalogs",title:s("workPage.sec.catalogs"),meta:t.jsx(ht,{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((u,h)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":h===c,"aria-label":a(u.source),onClick:()=>d(h),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:g.get(u.source_bid??"")?a(g.get(u.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(u.source)].slice(0,9).map((x,j)=>t.jsx("span",{children:x},j))})]})},h))}),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(ht,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[p.source_bid?t.jsx(ut,{id:p.source_bid,label:a(p.source),onNavigate:i,renderLink:o,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:Nt(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:Nt(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:Nt(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 d0(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 p0(e,n){if(!e.lineage)return null;const i=e.lineage;return{id:e.id,kind:"book",label:e.title,year:i.year,year_text:i.year_text,year_uncertain:i.year_uncertain,category:i.category,status:i.status,extant_juan:i.extant_juan,group:n[e.id],note:i.note}}function kl(e,n,i){return{id:`derive:${n.ref}->${e}:${i}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function u0(e,n,i){const[o,s]=[e,n.book_id].sort();return{id:`sibling:${o}-${s}:${i}`,source:o,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function m0(e,n){var p;if(n==="all")return null;const i=(p=e.collections)==null?void 0:p[n],o=Array.isArray(i==null?void 0:i.groups)&&i.groups.length>0,s=Array.isArray(i==null?void 0:i.book_ids)&&i.book_ids.length>0,a=o||s||!!(i!=null&&i.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(!i||!a)return null;const l=o?new Set(i.groups):null,d=new Set(i.book_ids??[]);if(l&&e.node_groups)for(const[g,m]of Object.entries(e.node_groups))l.has(m)&&d.add(g);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),l){c||(c=new Set);for(const g of e.hypothetical_nodes??[])g.group&&l.has(g.group)&&c.add(g.id)}return{books:d,hypos:c}}function Ei(e,n,i){const o=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!o||!o.enabled)return s;const a=new Set(o.excluded_books??[]),l=o.node_groups??{},d=m0(o,i??o.default_collection??"all"),c=d!==null,p=(d==null?void 0:d.books)??null,g=(d==null?void 0:d.hypos)??null,m=new Set,u=new Set;if(c){const w=new Map(n.map(R=>[R.id,R])),v=new Map((o.hypothetical_nodes??[]).map(R=>[R.id,R])),C=R=>{const z=w.get(R);if(z&&z.lineage)return(z.lineage.derived_from??[]).map(M=>M.ref);const N=v.get(R);return N?(N.derived_from??[]).map(M=>M.ref):[]},_=R=>v.has(R)?!g||g.has(R):!p||p.has(R),$=new Set,A=R=>{if(!$.has(R)){$.add(R);for(const z of C(R))a.has(z)||(_(z)||(v.has(z)?u.add(z):w.has(z)&&m.add(z)),A(z))}};for(const R of n)p&&p.has(R.id)&&!a.has(R.id)&&A(R.id);for(const R of o.hypothetical_nodes??[])g&&g.has(R.id)&&A(R.id)}const h=n.filter(w=>!a.has(w.id)).filter(w=>!p||p.has(w.id)||m.has(w.id)).map(w=>{const v=p0(w,l);return v&&m.has(w.id)&&(v.bridge=!0),v}).filter(w=>w!==null),x=(o.hypothetical_nodes??[]).filter(w=>!g||g.has(w.id)||u.has(w.id)).map(w=>{const v=d0(w);return u.has(w.id)&&(v.bridge=!0),v}),j=[...h,...x],b=new Set(j.map(w=>w.id)),S=new Set,y=[],k=w=>{S.has(w.id)||!b.has(w.source)||!b.has(w.target)||(S.add(w.id),y.push(w))};for(const w of n)a.has(w.id)||!w.lineage||p&&!p.has(w.id)&&!m.has(w.id)||((w.lineage.derived_from??[]).forEach((v,C)=>{k(kl(w.id,v,C))}),(w.lineage.related_to??[]).forEach((v,C)=>{k(u0(w.id,v,C))}));for(const w of o.hypothetical_nodes??[])g&&!g.has(w.id)&&!u.has(w.id)||(w.derived_from??[]).forEach((v,C)=>{k(kl(w.id,v,C))});return{nodes:j,edges:y,groups:o.groups??[],title:o.title,description:o.description,layout:o.layout??"LR",excluded:Array.from(a)}}function mp(e,n,i){const o=(e??(n!=null?String(n):"")).trim();return o?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(o)?o:`约 ${o}`:""}function g0(e,n){const i=[],o=e.version_graph;if(!o)return i;const s=new Set(n.map(c=>c.id)),a=new Set((o.hypothetical_nodes??[]).map(c=>c.id)),l=new Set([...s,...a]),d=(c,p)=>{l.has(p.ref)||i.push(`${c}: derived_from.ref "${p.ref}" 未在 books 或 hypothetical_nodes 中找到`),p.ref_type==="book"&&!s.has(p.ref)&&i.push(`${c}: derived_from.ref "${p.ref}" 标记为 book 但不在 books 列表中`),p.ref_type==="hypothetical"&&!a.has(p.ref)&&i.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(g=>d(p,g)),(c.lineage.related_to??[]).forEach(g=>{s.has(g.book_id)||i.push(`${p}: related_to.book_id "${g.book_id}" 不在 books 列表中`)})}for(const c of o.hypothetical_nodes??[]){const p=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(g=>d(p,g))}return i}const gp=({graph:e,renderLink:n,className:i,style:o})=>{const{t:s,convert:a}=ae();if(!e.nodes.length)return t.jsx("div",{style:{...z0,...o},className:i,children:s("lineage.emptyGraph")});const l=new Map,d=new Map;for(const h of e.edges)if(h.kind==="derive"){const x=l.get(h.target)??[];x.push(h),l.set(h.target,x)}else for(const x of[h.source,h.target]){const j=d.get(x)??[];j.push(h),d.set(x,j)}const c=new Map(e.nodes.map(h=>[h.id,h])),p=new Map,g=[];for(const h of e.nodes)if(h.group){const x=p.get(h.group)??[];x.push(h),p.set(h.group,x)}else g.push(h);const m=(h,x)=>(h.year??9999)-(x.year??9999);p.forEach(h=>h.sort(m)),g.sort(m);const u=e.groups.filter(h=>p.has(h.id));return t.jsxs("div",{className:i,style:{...h0,...o},children:[e.title&&t.jsx("div",{style:x0,children:a(e.title)}),e.description&&t.jsx("div",{style:b0,children:a(e.description)}),u.map(h=>t.jsx(wl,{label:h.label,color:h.color,nodes:p.get(h.id),incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n},h.id)),g.length>0&&t.jsx(wl,{label:s("lineage.otherGroup"),nodes:g,incomingMap:l,siblingMap:d,nodeMap:c,renderLink:n})]})},wl=({label:e,color:n,nodes:i,incomingMap:o,siblingMap:s,nodeMap:a,renderLink:l})=>{const{convert:d}=ae();return t.jsxs("div",{style:y0,children:[t.jsx("div",{style:{...j0,borderLeftColor:n??r("widget-border")},children:d(e)}),i.map(c=>t.jsx(f0,{node:c,incoming:o.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:a,renderLink:l},c.id))]})},f0=({node:e,incoming:n,siblings:i,nodeMap:o,renderLink:s})=>{const a=e.kind==="hypothetical",l=e.bridge,{t:d,convert:c}=ae();return t.jsxs("div",{style:{...v0,borderStyle:a||l?"dashed":"solid",opacity:l?.55:e.status==="lost"?.7:1,background:l?r("bg-subtle"):void 0},title:l?d("lineage.bridgeTitle"):void 0,children:[t.jsxs("div",{style:k0,children:[t.jsx("span",{style:w0,children:a||!s?c(e.label):s(e.id,c(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:S0,children:mp(c(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:_0,children:[e.category&&t.jsx(Gn,{children:c(e.category)}),e.status==="lost"&&t.jsx(Gn,{tone:"warn",children:d("lineage.lost")}),e.status==="fragment"&&t.jsx(Gn,{tone:"warn",children:d("lineage.fragment")}),a&&t.jsx(Gn,{tone:"info",children:d("lineage.hypothetical")}),l&&t.jsx(Gn,{tone:"info",children:d("lineage.bridge")})]}),e.extant_juan&&t.jsx("div",{style:$0,children:d("lineage.extant",{juan:c(e.extant_juan)})}),e.note&&t.jsx("div",{style:C0,children:c(e.note)}),n.length>0&&t.jsxs("div",{style:_l,children:[t.jsx("div",{style:$l,children:d("lineage.sources")}),n.map(p=>{const g=o.get(p.source);return t.jsxs("div",{style:Cl(p.confidence),children:[t.jsx("span",{style:zl,children:c(p.relation)}),t.jsx("span",{children:(g==null?void 0:g.kind)==="book"&&s?s(g.id,c(g.label)):c((g==null?void 0:g.label)??p.source)}),p.confidence!=="consensus"&&p.confidence!=="certain"&&t.jsx(Sl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Nl,children:["· ",c(p.evidence)]})]},p.id)})]}),i.length>0&&t.jsxs("div",{style:_l,children:[t.jsx("div",{style:$l,children:d("lineage.related")}),i.map(p=>{const g=p.source===e.id?p.target:p.source,m=o.get(g);return t.jsxs("div",{style:Cl(p.confidence),children:[t.jsx("span",{style:zl,children:c(p.relation)}),t.jsx("span",{children:(m==null?void 0:m.kind)==="book"&&s?s(m.id,c(m.label)):c((m==null?void 0:m.label)??g)}),t.jsx(Sl,{level:p.confidence}),p.evidence&&t.jsxs("span",{style:Nl,children:["· ",c(p.evidence)]})]},p.id)})]})]})},Gn=({children:e,tone:n="default"})=>{const o={default:{bg:r("tag-bg"),fg:r("fg")},warn:{bg:r("warn-bg"),fg:r("warn-fg")},info:{bg:r("info-bg"),fg:r("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:o.bg,color:o.fg,marginRight:"4px"},children:e})},Sl=({level:e})=>{const{t:n}=ae(),o={certain:{key:"certain",color:r("confidence-certain")},consensus:{key:"consensus",color:r("confidence-consensus")},probable:{key:"probable",color:r("confidence-probable")},disputed:{key:"disputed",color:r("confidence-disputed")}}[e];return o?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${o.color}`,color:o.color,borderRadius:"8px",marginLeft:"4px"},children:n(`lineage.confidence.${o.key}`)}):null},h0={fontSize:"14px",color:r("fg")},x0={fontSize:"16px",fontWeight:600,marginBottom:"8px"},b0={fontSize:"13px",color:r("muted"),marginBottom:"16px",lineHeight:1.6},y0={marginBottom:"16px"},j0={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:r("fg")},v0={border:`1px solid ${r("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:r("bg")},k0={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},w0={fontSize:"15px",fontWeight:600},S0={fontSize:"12px",color:r("muted")},_0={marginBottom:"6px"},$0={fontSize:"12px",color:r("muted"),margin:"2px 0"},C0={fontSize:"12px",color:r("muted"),fontStyle:"italic",margin:"4px 0"},_l={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${r("widget-border")}`},$l={fontSize:"11px",color:r("muted"),marginBottom:"2px"},Cl=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),zl={display:"inline-block",padding:"0 6px",fontSize:"11px",background:r("tag-bg"),color:r("fg"),borderRadius:"3px",marginRight:"6px"},Nl={fontSize:"11px",color:r("muted")},z0={padding:"20px",textAlign:"center",color:r("muted"),fontSize:"13px"},fp=({selectedNodeId:e,...n})=>{const{t:i}=ae(),[o,s]=f.useState("loading"),[a,l]=f.useState(null);return f.useEffect(()=>{let d=!1;return N0().then(c=>{d||(c?(l(c),s("ready")):s("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:Rl,children:i("lineage.graphLoading")}):o==="missing"||!a?t.jsxs("div",{style:Rl,children:[t.jsx("div",{children:Tl(i("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:Tl(i("lineage.graphMissingHint"),{list:t.jsx("code",{children:"VersionLineageList"})})})]}):t.jsx(T0,{modules:a,selectedNodeId:e,...n})};function Tl(e,n){return e.split(/(\{\w+\})/).map((i,o)=>{const s=/^\{(\w+)\}$/.exec(i);return t.jsx(f.Fragment,{children:s&&s[1]in n?n[s[1]]:i},o)})}async function N0(){try{const[e,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let i=!1;try{await import("@xyflow/react/dist/style.css"),i=!0}catch{i=!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:i}}catch{return null}}const T0=({graph:e,renderLink:n,height:i=600,className:o,style:s,selectedNodeId:a,modules:l})=>{const{ReactFlow:d,Background:c,Controls:p,Handle:g,Position:m,BaseEdge:u,EdgeLabelRenderer:h,getSmoothStepPath:x,dagre:j}=l,b=f.useMemo(()=>({lineage:C=>{var D,q,J,se;const _=((D=C.data)==null?void 0:D.stepPosition)??.85,[$,A,R]=x({sourceX:C.sourceX,sourceY:C.sourceY,sourcePosition:C.sourcePosition,targetX:C.targetX,targetY:C.targetY,targetPosition:C.targetPosition,stepPosition:_,borderRadius:5}),z=!!((q=C.data)!=null&&q.isSibling),N=z?A:C.targetX-18,M=z?R:C.targetY-12,O=(J=C.data)==null?void 0:J.labelStyle,L=(se=C.data)==null?void 0:se.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(u,{id:C.id,path:$,style:C.style,markerStart:C.markerStart,markerEnd:C.markerEnd}),C.label&&t.jsx(h,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${N}px,${M}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:r("bg"),border:`0.5px solid ${r("widget-border")}`,...L,...O},children:C.label})})]})}}),[u,h,x]),S=f.useMemo(()=>({version:C=>{const{t:_}=ae(),$=C.data,A=$.kind==="hypothetical",R=$.status==="lost",z=$.isSelected,N=$.bridge,M=$.borderColor??r("muted"),O=N||A?"dashed":"solid",L=N?.5:R?.6:1;return t.jsxs("div",{style:{background:r(N?"bg-subtle":"bg"),border:`2px ${O} ${z?r("primary"):M}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:L,boxShadow:z?r("shadow-node-selected"):A||N?"none":r("shadow-node")},title:N?_("lineage.bridgeTitle"):void 0,children:[t.jsx(g,{type:"target",position:m.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:A||!$.renderLink?$.label:$.renderLink($.bookId,$.label)}),$.description&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.25,marginTop:1},children:$.description}),$.yearText&&t.jsx("div",{style:{fontSize:10,color:r("aux-fg"),lineHeight:1.2},children:mp($.yearText,void 0,$.uncertain)}),R&&t.jsx("div",{style:{fontSize:9,color:r("lost-fg"),marginTop:1},children:_("lineage.lost")}),t.jsx(g,{type:"source",position:m.Right,style:{visibility:"hidden"}})]})}}),[g,m]),{convert:y}=ae(),{rfNodes:k,rfEdges:w}=f.useMemo(()=>R0(e,j,n,a,y),[e,j,n,a,y]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:o,children:t.jsxs(d,{nodes:k,edges:w,nodeTypes:S,edgeTypes:b,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 R0(e,n,i,o,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(S=>[S.id,S.color??r("muted")]));for(const S of e.nodes)c.setNode(S.id,{width:160,height:90});const g=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const S of e.edges)S.kind==="derive"&&(g.has(S.relation)||c.setEdge(S.source,S.target));n.layout(c);const m=e.nodes.map(S=>{const y=c.node(S.id),k=o?S.id===o:void 0,w={kind:S.kind,label:s(S.label),bookId:S.kind==="book"?S.id:void 0,yearText:s(S.year_text??E0(S)),uncertain:S.year_uncertain,category:S.category,status:S.status,borderColor:S.group?p.get(S.group):void 0,renderLink:i,isSelected:k,description:s(S.description),bridge:S.bridge};return{id:S.id,type:"version",position:{x:y.x-160/2,y:y.y-90/2},data:w,draggable:!1,selected:k}}),u=.78,h=.06,x=new Map;for(const S of e.edges)S.kind==="derive"&&(x.has(S.source)||x.set(S.source,[]),x.get(S.source).push(S));const j=new Map;for(const[S,y]of x){if(y.length<=1)continue;const k=[...y].sort((v,C)=>{var A,R;const _=((A=c.node(v.target))==null?void 0:A.y)??0,$=((R=c.node(C.target))==null?void 0:R.y)??0;return _-$}),w=k.length;k.forEach((v,C)=>{const _=(C-(w-1)/2)*h;j.set(v.id,u+_)})}const b=e.edges.map(S=>I0(S,j.get(S.id),s));return{rfNodes:m,rfEdges:b}}function I0(e,n,i=o=>o??""){const o=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",a=L0(e.confidence),l={type:"arrowclosed",color:a,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:i(e.relation),data:{labelStyle:{color:r("fg")},isSibling:s,stepPosition:n},style:{stroke:a,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":o?"6 4":void 0,opacity:o?.75:1},animated:!1,markerEnd:l,markerStart:s?l:void 0,zIndex:1e3}}function E0(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function L0(e){switch(e){case"certain":return r("confidence-certain");case"consensus":return r("lineage-edge-consensus");case"probable":return r("confidence-probable");case"disputed":return r("confidence-disputed");default:return r("muted")}}const Rl={padding:"40px 20px",textAlign:"center",color:r("muted"),fontSize:"13px",border:`1px dashed ${r("widget-border")}`,borderRadius:8,background:r("bg")},vs=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:o=600,selectedNodeId:s,onModeChange:a,collection:l,onCollectionChange:d,collectionsAvailable:c,collectionCounts:p,className:g,style:m})=>{var w;const{t:u,convert:h}=ae(),[x,j]=f.useState(n),b=v=>{j(v),a==null||a(v)},S=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:u("lineage.collectionAll"),description:u("lineage.collectionAllDesc")}]]})(),y=!!(d&&S.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:r("muted"),textAlign:"center"},children:u("lineage.empty")});const k=l?(w=c==null?void 0:c[l])==null?void 0:w.description:void 0;return t.jsxs("div",{className:g,style:m,children:[t.jsxs("div",{style:A0,children:[t.jsx("button",{onClick:()=>b("list"),style:Wr(x==="list"),children:u("lineage.modeList")}),t.jsx("button",{onClick:()=>b("graph"),style:Wr(x==="graph"),children:u("lineage.modeGraph")}),y&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:r("muted"),marginRight:4},children:u("lineage.collectionLabel")}),S.map(([v,C])=>{const _=p==null?void 0:p[v];return t.jsxs("button",{onClick:()=>d==null?void 0:d(v),style:Wr(l===v),title:C.description?h(C.description):void 0,children:[h(C.label),_!=null?` ${_}`:""]},v)})]})]}),y&&k&&t.jsx("div",{style:{fontSize:12,color:r("muted"),marginBottom:8,padding:"4px 8px",background:r("bg-subtle"),borderRadius:4},children:h(k)}),x==="list"?t.jsx(gp,{graph:e,renderLink:i}):t.jsx(fp,{graph:e,renderLink:i,height:o,selectedNodeId:s})]})},A0={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Wr=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${r("widget-border")}`,borderRadius:4,background:e?r("primary"):"transparent",color:r(e?"primary-fg":"fg"),cursor:"pointer"}),Il=40,El=2,M0=9,P0=new Set(["certain","consensus","probable","disputed"]);function Fr(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const hp=({data:e,transport:n,onNavigate:i,renderLink:o,readAction:s,fullText:a,fullTextPending:l,chapterLink:d,railTop:c,back:p,railLinks:g})=>{var ge,Ae,W,be,ce,Ne,$e,Ke,Qe,it,nt;const m=Be(),{t:u,convert:h}=ae(),[x,j]=f.useState(null),[b,S]=f.useState(new Map),[y,k]=f.useState([]),[w,v]=f.useState(new Map),[C,_]=f.useState(!1),[$,A]=f.useState("flow"),[R,z]=f.useState(null);f.useEffect(()=>{if(!n||!e.work_id){j(null);return}let I=!1;return n.getItem(e.work_id).then(fe=>{!I&&fe&&fe.type==="work"&&j(fe)}).catch(()=>{}),()=>{I=!0}},[n,e.work_id]),f.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){z(null);return}let I=!1;return n.getLineageGraph(e.work_id).then(fe=>{I||z(fe&&fe.nodes.length>1?fe:null)}).catch(()=>{I||z(null)}),()=>{I=!0}},[n,e.work_id]),f.useEffect(()=>{const I=e._collections||[];if(!n||I.length===0){S(new Map);return}let fe=!1;return Promise.all(I.map(xe=>{const ze=xe.id;return n.getItem(ze).then(V=>[ze,V]).catch(()=>[ze,null])})).then(xe=>{if(fe)return;const ze=new Map;for(const[V,P]of xe)P&&ze.set(V,P);S(ze)}),()=>{fe=!0}},[n,e._collections]);const N=f.useMemo(()=>{const I=new Set([...x?Eo(x):[],...e.related_books||[]]);return I.add(e.id),[...I]},[x,e.related_books,e.id]),M=N.length-1;f.useEffect(()=>{if(!n||M<=0){k([]);return}const I=N.length<=Il,fe=I?N:N.slice(0,8);let xe=!1;return Promise.all(fe.map(ze=>ze===e.id?Promise.resolve({id:ze,title:e.title,edition:e.edition,year:Ai(e)}):n.getItem(ze).then(V=>{const P=V??{};return{id:ze,title:P.title,edition:P.edition,year:V?Ai(P):void 0}}).catch(()=>({id:ze})))).then(ze=>{if(xe)return;const V=ze.filter(P=>P.id===e.id||P.title||P.edition);I&&V.sort((P,X)=>(P.year??1/0)-(X.year??1/0)),k(V)}),()=>{xe=!0}},[n,N,M,e]);const O=e.lineage,L=f.useMemo(()=>[...((O==null?void 0:O.derived_from)||[]).filter(I=>I.ref_type==="book").map(I=>I.ref),...((O==null?void 0:O.related_to)||[]).map(I=>I.book_id)].filter(Boolean),[O]);f.useEffect(()=>{if(!n||L.length===0){v(new Map);return}let I=!1;return Promise.all(L.map(fe=>n.getItem(fe).then(xe=>[fe,{id:fe,title:xe==null?void 0:xe.title,edition:xe==null?void 0:xe.edition}]).catch(()=>[fe,{id:fe}]))).then(fe=>{I||v(new Map(fe))}),()=>{I=!0}},[n,L]);const D=f.useMemo(()=>cp(e.resources,e.resource_groups,u),[e.resources,e.resource_groups,u]),q=D.groups.reduce((I,fe)=>I+fe.rows.length+fe.mirrors.length,0),J=D.groups.length>0&&D.groups.every(I=>I.key==="_physical"),se=ii(e),U=dc(e),K=Kt(e,m.unit.juan),Z=new Set((e._collections||[]).map(I=>Xn(I.vol).length).filter(I=>I>0)),oe=I=>{var ze;const fe=(ze=e.base_edition)==null?void 0:ze.find(V=>V.book_id===I&&V.name);if(fe!=null&&fe.name)return fe.name;const xe=w.get(I);return(xe==null?void 0:xe.edition)||(xe==null?void 0:xe.title)||""},ye=f.useMemo(()=>{var Y,me,_e,Pe,ne;const I=[];U&&I.push({label:u("bookPage.fact.editionType"),value:h(U),title:e.edition_type||(Y=e.lineage)!=null&&Y.category?void 0:u("bookPage.inferredFromEdition")}),(me=e.publication_info)!=null&&me.details?I.push({label:u("bookPage.fact.publication"),value:h(e.publication_info.details)}):(se.era||se.reign)&&I.push({label:u("bookPage.fact.era"),value:h([se.era,se.reign].filter(Boolean).join(" ")),title:se.source==="edition"?u("bookPage.inferredFromEdition"):void 0}),K&&I.push({label:u("bookPage.fact.measure"),value:h(K)});const fe=(e._collections||[]).flatMap(re=>Xn(re.vol));fe.length&&I.push({label:u("bookPage.fact.volumes"),value:u("bookPage.volumesValue",{range:Yi(fe,m.unit.volume),unit:m.unit.volume,n:fe.length})});const xe=(((_e=e.lineage)==null?void 0:_e.derived_from)||[]).find(re=>re.relation==="底本"&&re.ref_type==="book");xe&&oe(xe.ref)&&I.push({label:u("bookPage.fact.baseEdition"),value:t.jsx(ut,{id:xe.ref,label:h(oe(xe.ref)),onNavigate:i,renderLink:o,dense:!0})});const ze=(e.base_edition||[]).filter(re=>re&&re.name);for(const re of["底本","配補","參校"]){if(re==="底本"&&xe&&oe(xe.ref))continue;const ve=ze.filter(ke=>ke.role===re);ve.length&&I.push({label:h(re),value:ve.map((ke,Ue)=>t.jsxs(f.Fragment,{children:[Ue>0&&"、",ke.book_id?t.jsx(ut,{id:ke.book_id,label:h(ke.name),onNavigate:i,renderLink:o,dense:!0}):h(ke.name)]},Ue))})}const V=(e.provenance||[]).filter(re=>re&&re.institution),P=(e.resources||[]).filter(re=>Yt(re).includes("physical"));if(V.length){I.push({label:u("bookPage.fact.holdings"),value:V.slice(0,2).map(ke=>h(ke.institution)).join("、")+(V.length>2?u("bookPage.andMorePlaces",{n:V.length}):"")});const re=V.filter(ke=>ke.call_number).slice(0,2).map(ke=>`${h(ke.institution)} ${ke.call_number}`);re.length&&I.push({label:u("bookPage.fact.callNumber"),value:re.join(";")+(V.filter(ke=>ke.call_number).length>2?"…":"")});const ve=V.flatMap(ke=>ke.seals||[]).filter(Boolean);ve.length&&I.push({label:u("bookPage.fact.seals"),value:h(ve.join("、"))})}else P.length?I.push({label:u("bookPage.fact.holdings"),value:P.slice(0,2).map(re=>h(re.name)).join("、")+(P.length>2?u("bookPage.andMorePlaces",{n:P.length}):"")}):(Pe=e.current_location)!=null&&Pe.name&&I.push({label:u("bookPage.fact.holdings"),value:h(e.current_location.name)});const X=e.physical_description;if(X){const re=[[u("bookPage.fact.leafStyle"),X.leaf_style],[u("bookPage.fact.binding"),X.binding],[u("bookPage.fact.dimensions"),X.dimensions],[u("bookPage.fact.condition"),X.condition]];for(const[ve,ke]of re)ke&&ke.trim()&&I.push({label:ve,value:h(ke)})}(ne=e.page_count)!=null&&ne.description&&I.push({label:m.label.pageCount,value:h(e.page_count.description)});const je=[...ro(e.additional_titles),...ro(e.attached_texts)];return je.length&&I.push({label:u("bookPage.fact.aliases"),value:je.map(h).join("、")}),I},[e,h,m,u,se,U,K,w,i,o]),Le=h(e.title),Me=e.edition?h(e.edition):void 0,Se=((ge=e.lineage)==null?void 0:ge.year_text)||"",le=t.jsx(oi,{kind:u("bookPage.kind"),title:Le,subtitle:Me,byline:t.jsx(ys,{authors:e.authors??(x==null?void 0:x.authors),onNavigate:i,renderLink:o}),meta:(()=>{const I=[U?h(U):"",se.era?h([se.era,se.reign].filter(Boolean).join("")):"",K?h(K):""].filter(Boolean);return I.length?t.jsx("span",{className:"bim-d-tags",children:I.map((fe,xe)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(xe,2)}`,children:fe},xe))}):null})(),description:(Ae=e.description)!=null&&Ae.text?t.jsx(qt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Uo((W=e.description)==null?void 0:W.text)?6:void 0,facts:ye,readAction:s,secondaryAction:s&&q>0&&!J?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:u("bookPage.viewImages")}):void 0,foot:t.jsx(si,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),Oe=e._collections||[],T=(a==null?void 0:a.chapters)||[],de=h(T[0]&&Fr(T[0].title)[0].slice(-1)||"")||u("bookPage.chapterUnit"),pe=u("bookPage.chapterCount",{n:T.length,unit:de}),B=!!((be=O==null?void 0:O.derived_from)!=null&&be.length||(ce=O==null?void 0:O.related_to)!=null&&ce.length||(Ne=e.appendix)!=null&&Ne.length),ee=[],Ce=u(J?"bookPage.sec.physical":"bookPage.sec.images");(T.length||D.text.length||l)&&ee.push({id:"fulltext",label:u("bookPage.sec.fulltext"),count:T.length?pe:void 0}),D.groups.length&&ee.push({id:"images",label:Ce,count:q}),B&&ee.push({id:"lineage",label:u("bookPage.sec.lineage")}),Oe.length&&ee.push({id:"collections",label:u("section.containedIn"),count:Oe.length}),($e=e.location_history)!=null&&$e.length&&ee.push({id:"provenance",label:u("section.locationHistory")});const Ie=I=>(d==null?void 0:d(I))??null,We=T[0],G=We?Ie(We.file):null,he=C?T:T.slice(0,M0),te=(I,fe,xe)=>I?t.jsx("a",{className:xe,href:I.href??"#",onClick:I.onClick?ze=>{ze.metaKey||ze.ctrlKey||(ze.preventDefault(),I.onClick())}:void 0,children:fe}):t.jsx("span",{className:xe,children:fe}),H=t.jsxs(t.Fragment,{children:[(T.length>0||D.text.length>0||l)&&t.jsxs(bt,{id:"fulltext",title:u("bookPage.sec.fulltext"),meta:T.length>0?t.jsx(ht,{items:[pe,(Ke=a==null?void 0:a.source)!=null&&Ke.name?u("bookPage.sourceBy",{src:h(`${a.source.name}${a.source.license?` ${a.source.license}`:""}`)}):""]}):void 0,children:[l&&!We&&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"})]}),We&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:u("bookPage.readFrom",{ch:h(Fr(We.title)[0])||u("bookPage.firstChapter")})}),t.jsx("span",{className:"bim-d-meta",children:h((We.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),te(G,t.jsxs(t.Fragment,{children:[u("bookPage.enterReader")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),T.length>1&&t.jsx("ul",{className:"bim-d-chap",children:he.map(I=>{const[fe,xe]=Fr(I.title);return t.jsx("li",{children:te(Ie(I.file),t.jsxs(t.Fragment,{children:[fe&&t.jsx("b",{children:h(fe)}),h(xe||I.file)]}))},I.file)})}),T.length>he.length&&t.jsx(Do,{label:u("detail.expandRest",{n:T.length-he.length,unit:de}),onClick:()=>_(!0)}),D.text.length>0&&t.jsxs(t.Fragment,{children:[(T.length>0||l)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:u("bookPage.externalText")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:D.text.map((I,fe)=>t.jsx(js,{item:I,siblings:D.text,listedVolumeCounts:Z},`${I.id||I.url||I.name}-${fe}`))})})]})]}),D.groups.length>0&&t.jsx(bt,{id:"images",title:Ce,meta:t.jsx(ht,{items:[D.groups.length>1?u("bookPage.groupCount",{n:D.groups.length}):"",u("bookPage.placeCount",{n:q})]}),children:t.jsx(pp,{groups:D.groups,listedVolumeCounts:Z})}),B&&t.jsx(bt,{id:"lineage",title:u("bookPage.sec.lineage"),meta:(Qe=O==null?void 0:O.derived_from)!=null&&Qe.length?u("bookPage.lineageMeta"):void 0,action:R?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":u("bookPage.lineageView"),children:[t.jsx("button",{type:"button","aria-pressed":$==="flow",onClick:()=>A("flow"),children:u("bookPage.viewCards")}),t.jsx("button",{type:"button","aria-pressed":$==="graph",onClick:()=>A("graph"),children:u("bookPage.viewGraph")})]}):void 0,children:$==="graph"&&R?t.jsx(vs,{graph:R,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(I,fe)=>t.jsx(ut,{id:I,label:h(fe),onNavigate:i,renderLink:o,dense:!0})}):t.jsx(O0,{data:e,heading:Me||Le,yearText:Se,refName:oe,onNavigate:i,renderLink:o})}),Oe.length>0&&t.jsx(bt,{id:"collections",title:u("section.containedIn"),children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:Oe.map((I,fe)=>{const xe=I.id,ze=Xn(I.vol),V=b.get(xe),P=qm(V);return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(ut,{id:xe,label:V?h(V.title):xe,onNavigate:i,renderLink:o,dense:!0}),ze.length>0&&t.jsx(B0,{volumes:ze,unit:m.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${P?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:P>0&&u("bookPage.totalOf",{n:P,unit:m.unit.bu})})]},`${xe}-${fe}`)})})})}),(it=e.location_history)!=null&&it.length?t.jsx(bt,{id:"provenance",title:u("section.locationHistory"),children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((I,fe)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:h(I.name)}),([I.start_date,I.end_date].filter(Boolean).join("—")||I.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(ht,{items:[[I.start_date,I.end_date].filter(Boolean).join("—"),I.description?h(I.description):""]})})]},fe))})}):null,ee.length===0&&t.jsx(bt,{title:u("bookPage.sec.empty"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("bookPage.emptyText")})})]}),ue=y.findIndex(I=>I.id===e.id),Fe=N.length<=Il,Ge=Fe&&ue>=0?y.slice(Math.max(0,ue-El),ue+El+1):y.filter(I=>I.id!==e.id),Je=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:h(m.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(ut,{id:x.id,label:h(x.title),onNavigate:i,renderLink:o})}),t.jsx(ht,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(x.authors||[]).slice(0,2).map(I=>`${I.dynasty?`〔${h(I.dynasty)}〕`:""}${h(I.name)}`),h(Kt(x,m.unit.juan)),x._edition_count?u("bookPage.editionCount",{n:x._edition_count}):""]}),((nt=x.description)==null?void 0:nt.text)&&t.jsx("p",{style:{fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc bim-d-side-desc",children:h(x.description.text.replace(/[#*_>`[\]]/g,""))})]}),M>0&&Ge.length>0&&t.jsxs("div",{children:[t.jsx(un,{id:"siblings",timeline:!0,title:Fe?u("bookPage.siblings"):m.relation.siblingVersions,meta:Fe?u("bookPage.byEra"):u("bookPage.kindCount",{n:M}),cap:Ge.length,items:Ge.map(I=>I.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:h(I.edition||I.title||I.id)}):t.jsx(ut,{id:I.id,label:h(I.edition||I.title||I.id),onNavigate:i,renderLink:o,dense:!0})),metas:Ge.map(I=>[I.year!=null?I.year<0?u("detail.bce",{n:-I.year}):String(I.year):"",I.id===e.id?u("detail.thisPage"):""].filter(Boolean).join(" ")),currentIndex:Ge.findIndex(I=>I.id===e.id)}),x&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(ut,{id:x.id,label:u("bookPage.viewAllInWork",{n:N.length}),onNavigate:i,renderLink:o,dense:!0})})]})]}),F=e.work_id?t.jsx(qc,{caption:m.section.belongsToWork,children:t.jsx(ut,{id:e.work_id,label:x?h(x.title):" ",onNavigate:i,renderLink:o,dense:!0})}):void 0;return t.jsx(ri,{railTop:c,back:p,up:F,nav:ee,railLinks:g,main:H,card:le,side:Je})};function B0({volumes:e,unit:n}){const{t:i}=ae();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i("bookPage.volumeRange",{range:Yi(e,n),unit:n}),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),i("bookPage.volumeCount",{n:e.length,unit:n})]})]})}function O0({data:e,heading:n,yearText:i,refName:o,onNavigate:s,renderLink:a}){var S;const{t:l,convert:d}=ae(),c=e.lineage,p=(c==null?void 0:c.derived_from)||[],g=p.filter(y=>y.ref_type!=="book"),m=p.filter(y=>y.ref_type==="book"&&y.relation==="底本"),u=p.filter(y=>y.ref_type==="book"&&y.relation!=="底本"),h=(c==null?void 0:c.related_to)||[],x=p.length>0||h.length>0,j=y=>y&&P0.has(y)?l("bookPage.confidenceNote",{c:l(`bookPage.confidence.${y}`)}):"",b=(y,k)=>t.jsx(ut,{id:y,label:d(k||y),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:[g.map((y,k)=>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:y.relation?d(y.relation):l("bookPage.lineage.ancestor")}),t.jsx("span",{className:"bim-d-lf-name",children:l("bookPage.lineage.reconstructed")}),y.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(y.evidence),j(y.confidence)]})]})},`a-${k}`)),m.map((y,k)=>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(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,o(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(y.evidence),j(y.confidence)]})]})},`b-${k}`)),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}),i&&t.jsx("span",{className:"bim-d-lf-yr",children:d(i)})]}),u.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:u.map((y,k)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:b(y.ref,o(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(y.evidence),j(y.confidence)]})]},k))})]}),h.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:h.map((y,k)=>t.jsxs("span",{className:"bim-d-lf-chip",title:y.evidence?d(y.evidence):void 0,children:[b(y.book_id,o(y.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(y.relation)})]},k))})]})]}),(S=e.appendix)==null?void 0:S.map((y,k)=>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(y.title)]}),t.jsx(qt,{text:y.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${k}`)),(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 Yn=16,W0=200,F0=16,xp=({data:e,catalog:n,transport:i,onNavigate:o,renderLink:s,catalogAction:a,railTop:l,back:d,railLinks:c})=>{var ue,Fe,Ge,Je,F,ge,Ae;const{t:p,convert:g,messages:m}=ae(),[u,h]=f.useState(""),[x,j]=f.useState(!1),[b,S]=f.useState(null),[y,k]=f.useState(""),[w,v]=f.useState(!1),C=f.useMemo(()=>cc(e,n),[e,n]),_=f.useMemo(()=>lc(e),[e]),[$,A]=f.useState(new Map),R=!!i&&C.rows.length>0&&C.rows.length<=W0,z=R&&(C.rows.length<=Yn||w),N=z&&C.rows.every(W=>!W.id||$.has(W.id)),M=W=>{var be;return ho(W?(be=$.get(W))==null?void 0:be.l1:void 0)},O=f.useMemo(()=>{const W=u.trim(),be=W?g(W):"";return C.rows.filter(ce=>{var $e,Ke;if(y&&ho(ce.id?($e=$.get(ce.id))==null?void 0:$e.l1:void 0)!==y)return!1;if(!be)return!0;const Ne=ce.id&&((Ke=$.get(ce.id))==null?void 0:Ke.title)||ce.title;return g(Ne).includes(be)||(ce.subItems||[]).some(Qe=>g(Qe).includes(be))})},[C.rows,u,y,$,g]),L=x?O:O.slice(0,Yn),D=f.useMemo(()=>(z?C.rows:L).filter(W=>W.id&&!$.has(W.id)).map(W=>W.id),[z,C.rows,L,$]);f.useEffect(()=>{if(!i||D.length===0)return;let W=!1;const be=D.slice(0,F0);return ir(be,nr,ce=>i.getItem(ce).then(Ne=>{var Qe,it;const $e=Ne??{},Ke={title:$e.title,edition:$e.edition,authors:$e.authors,measure:Ne?Kt(Ne,m.unit.juan):void 0,versionCount:$e._edition_count??((Qe=$e._books)==null?void 0:Qe.length),l1:((it=Lo($e))==null?void 0:it.l1)||void 0};return[ce,Ke]}).catch(()=>[ce,{}]),()=>W).then(ce=>{W||A(Ne=>{const $e=new Map(Ne);for(const[Ke,Qe]of ce)$e.set(Ke,Qe);return $e})}),()=>{W=!0}},[i,D,m.unit.juan]);const q=(ue=(e.contained_in||[])[0])==null?void 0:ue.id;f.useEffect(()=>{if(!q){S(null);return}if(S({id:q}),!i)return;let W=!1;return i.getItem(q).then(be=>{W||S({id:q,title:be==null?void 0:be.title})}).catch(()=>{}),()=>{W=!0}},[i,q]);const J=f.useMemo(()=>cp(e.resources,e.resource_groups,p),[e.resources,e.resource_groups,p]),se=J.text.length+J.groups.reduce((W,be)=>W+be.rows.length+be.mirrors.length,0),U=_.works,K=new Set(C.rows.map(W=>W.id).filter(Boolean)),Z=U.length>0&&!U.every(W=>K.has(W.id)),oe=(()=>{const W=C.rows.map(be=>be.edition).filter(Boolean);return W.length>1&&new Set(W).size===1})(),ye=C.rows.some(W=>W.volumes.length>0||W.expected!=null),Le=_.total,Me=_.truncated?Le:C.rows.length,Se=Kt(e,m.unit.juan),le=e.count,Oe=W=>typeof W=="number"&&Number.isFinite(W)?W:null,T=Oe(le==null?void 0:le.juan)??Oe((Fe=e.juan_count)==null?void 0:Fe.number),de=Oe(le==null?void 0:le.ce)??(C.totalVolumes||null),pe=[{value:Me,label:p("collectionPage.stat.titles")},{value:T??0,label:m.unit.juan},{value:de??0,label:m.unit.volume}],B=f.useMemo(()=>{var ce,Ne;const W=[];if((ce=e.publication_info)!=null&&ce.details&&W.push({label:p("collectionPage.fact.publication"),value:g(e.publication_info.details)}),Le&&(Le!==C.rows.length||_.truncated)){const $e=e._member_type==="Book"?p("collectionPage.member.Book"):e._member_type==="Work"?p("collectionPage.member.Work"):p("collectionPage.member.other");W.push({label:$e,value:`${Le} ${m.unit.bu}`,title:p("collectionPage.memberNote")})}const be=[Oe(le==null?void 0:le.zhong)!=null?p("collectionPage.nZhong",{n:le.zhong}):"",Oe(le==null?void 0:le.han)!=null?p("collectionPage.nHan",{n:le.han}):""].filter(Boolean);return be.length&&W.push({label:p("collectionPage.fact.expected"),value:be.join(" ")}),T==null&&Se&&W.push({label:p("collectionPage.fact.measure"),value:g(Se),title:(Ne=e.juan_count)!=null&&Ne.description?g(e.juan_count.description):void 0}),W},[e,Le,_.truncated,C.rows.length,T,Se,le,g,p,m]),ee=f.useMemo(()=>{if(!N)return[];const W=new Map;for(const ce of C.rows){const Ne=M(ce.id);Ne&&W.set(Ne,(W.get(Ne)??0)+1)}const be=Qn.filter(ce=>(W.get(ce.key)??0)>0);return be.length<2?[]:[{key:"",label:`${m.catalog.all} ${Me}`},...be.map(ce=>({key:ce.key,label:`${ce.label} ${W.get(ce.key)}`}))]},[N,C.rows,$,m]),Ce=f.useMemo(()=>{if(!N||!C.rows.some(Ne=>Ne.volumes.length>0))return null;const W=[],be=C.rows.filter(Ne=>Ne.volumes.length>0).map(Ne=>({k:M(Ne.id)??"",from:Math.min(...Ne.volumes),to:Math.max(...Ne.volumes)})).sort((Ne,$e)=>Ne.from-$e.from);for(const Ne of be){const $e=Ne.to-Ne.from+1,Ke=W[W.length-1];Ke&&Ke.key===Ne.k?(Ke.to=Math.max(Ke.to,Ne.to),Ke.n+=$e):W.push({key:Ne.k,from:Ne.from,to:Ne.to,n:$e})}const ce=be.reduce((Ne,$e)=>Math.max(Ne,$e.to),0);return W.length>1&&W.some(Ne=>Ne.key)?{segs:W,last:ce}:null},[N,C.rows,$]),Ie=(Ge=e.description)==null?void 0:Ge.text,We=t.jsx(oi,{kind:p("collectionPage.kind"),title:g(e.title),byline:t.jsx(ys,{authors:e.authors,onNavigate:o,renderLink:s}),meta:t.jsx(ht,{items:[e.subtype==="work_collection"?p("collectionPage.workCollection"):"",(Je=e.publication_info)!=null&&Je.year?g(e.publication_info.year):""]}),description:Ie||(F=e.history)!=null&&F.length?t.jsxs(t.Fragment,{children:[Ie&&t.jsx(qt,{text:Ie,style:{fontSize:15,lineHeight:1.85}}),(ge=e.history)!=null&&ge.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((W,be)=>t.jsx("li",{children:g(W)},be))}):null]}):void 0,clampDescription:Uo(Ie)||(((Ae=e.history)==null?void 0:Ae.length)??0)>2?6:void 0,stats:pe,facts:B,foot:t.jsx(si,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:Ce&&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:Ce.segs.map((W,be)=>{const ce=Qn.find(Ne=>Ne.key===W.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!ce,title:ce?p("collectionPage.dist.segTitle",{section:g(ce.label),from:W.from,to:W.to}):void 0,"aria-label":ce?p("collectionPage.dist.only",{section:g(ce.label)}):p("collectionPage.dist.unclassified"),"aria-pressed":!!ce&&y===W.key,style:{flexGrow:W.n,background:r(ce?ce.token:"rule")},onClick:()=>{ce&&(k(y===W.key?"":W.key),j(!1))}},be)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:p("catalog.volume",{n:1})}),t.jsx("span",{children:p("collectionPage.dist.hint")}),t.jsx("span",{children:p("catalog.volume",{n:Ce.last})})]})]})}),G=[];C.rows.length&&G.push({id:"titles",label:p("collectionPage.sec.titles"),count:Me}),se&&G.push({id:"resources",label:p("collectionPage.sec.resources"),count:se}),Z&&G.push({id:"works",label:m.section.containedWorks,count:U.length});const he=t.jsxs(t.Fragment,{children:[C.rows.length>0&&t.jsxs(bt,{id:"titles",title:p("collectionPage.sec.titles"),meta:t.jsx(ht,{items:[`${Me} ${m.unit.items}`,C.totalVolumes?p("collectionPage.totalVolumes",{n:C.totalVolumes,unit:m.unit.volume}):"",O.length!==Me?p("collectionPage.currentN",{n:O.length,unit:m.unit.items}):""]}),action:a,children:[(C.rows.length>Yn||ee.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[ee.length>0&&t.jsx(Ji,{items:ee,value:y,onChange:W=>{k(W),j(!1)}}),R&&C.rows.length>Yn&&!N&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:w,onClick:()=>v(!0),title:p("collectionPage.loadAllTitle",{n:C.rows.length,unit:m.unit.items}),children:p(w?"collectionPage.grouping":"collectionPage.groupBySection")}),t.jsx("span",{className:"bim-d-spacer"}),C.rows.length>Yn&&t.jsx("input",{type:"search",className:"bim-d-find",value:u,placeholder:p("collectionPage.find"),"aria-label":p("collectionPage.find"),onChange:W=>{h(W.target.value),j(!1)}})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Qi(O.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[ye&&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:L.map((W,be)=>{var nt;const ce=W.id?$.get(W.id):void 0,Ne=ce!=null&&ce.title&&W.title===W.id?ce.title:W.title,$e=((ce==null?void 0:ce.authors)||[]).find(I=>I&&I.name),Ke=[$e?`${$e.dynasty?`〔${g($e.dynasty)}〕`:""}${g($e.name)}${$e.role?` ${g($e.role)}`:""}`:"",ce!=null&&ce.measure?g(ce.measure):"",(nt=W.subItems)!=null&&nt.length?W.subItems.map(I=>g(I)).join("、"):"",(ce!=null&&ce.edition||W.edition)&&!oe?g((ce==null?void 0:ce.edition)||W.edition||""):""].filter(Boolean),Qe=Qn.find(I=>I.key===M(W.id)),it=W.volumes.length>0?p("collectionPage.volumeRange",{range:Yi(W.volumes,m.unit.volume),unit:m.unit.volume}):W.expected!=null?`${W.found??0}/${W.expected} ${m.unit.volume}`:"";return t.jsxs("tr",{children:[ye&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${it?"":" bim-d-zt-blank"}`,children:[Qe&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:r(Qe.token)}}),it||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[W.id?t.jsx(ut,{id:W.id,label:g(Ne),onNavigate:o,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:g(Ne)}),Ke.length>0?t.jsx(ht,{items:Ke}):W.id&&!ce&&i?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${ce!=null&&ce.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:ce!=null&&ce.versionCount?p("collectionPage.nZhong",{n:ce.versionCount}):""})]},`${W.id??W.title}-${be}`)})})]}),L.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:p("catalog.noMatch")}),!x&&t.jsx(Ho,{total:O.length,shown:L.length,unit:m.unit.items,onClick:()=>j(!0)})]}),se>0&&t.jsxs(bt,{id:"resources",title:p("collectionPage.sec.resources"),meta:p("collectionPage.resourcesCount",{n:se}),children:[J.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[J.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:J.text.map((W,be)=>t.jsx(js,{item:W,siblings:J.text},`${W.id||W.url||W.name}-${be}`))})})]}),t.jsx(pp,{groups:J.groups})]}),C.rows.length===0&&se===0&&t.jsx(bt,{title:p("collectionPage.sec.titles"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:p("collectionPage.empty")})})]}),te=Z?t.jsx(un,{id:"works",title:m.section.containedWorks,meta:p("collectionPage.nZhong",{n:U.length}),cap:12,items:U.map(W=>t.jsx(ut,{id:W.id,label:g(W.title),onNavigate:o,renderLink:s,dense:!0}))}):null,H=b?t.jsx(qc,{caption:p("collectionPage.parent"),children:t.jsx(ut,{id:b.id,label:g(b.title||b.id),onNavigate:o,renderLink:s,dense:!0})}):void 0;return t.jsx(ri,{railTop:l,back:d,up:H,nav:G,railLinks:c,main:he,card:We,side:te})},H0=8;function bp(e){return typeof e!="string"||!e||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e)||e.split("/").some(n=>n==="..")?null:e}function D0(e){return(e||[]).filter(n=>{var i,o;return bp(n==null?void 0:n.file)&&((i=n.credit)==null?void 0:i.trim())&&((o=n.license)==null?void 0:o.trim())}).slice(0,H0)}function U0({images:e,assetBase:n,name:i}){const{t:o,convert:s}=ae(),[a,l]=f.useState(0),[d,c]=f.useState(!1),p=n?D0(e):[];if(!n||d||p.length===0)return null;const g=n.endsWith("/")?n:n+"/",m=p[Math.min(a,p.length-1)],u=m.width&&m.height&&m.width>0&&m.height>0?`${m.width} / ${m.height}`:void 0,h=x=>g+bp(x.file).split("/").map(encodeURIComponent).join("/");return t.jsxs("figure",{className:"bim-d-seal bim-d-ui",children:[t.jsx("img",{className:"bim-d-seal-main",src:h(m),alt:o("entityPage.sealAlt",{name:i})+(p.length>1?` ${a+1}`:""),style:u?{"--seal-ar":u}:void 0,width:m.width,height:m.height,decoding:"async",fetchPriority:"high",onError:()=>c(!0)},m.file),p.length>1&&t.jsx("div",{className:"bim-d-seal-thumbs",children:p.map((x,j)=>t.jsx("button",{type:"button","aria-pressed":j===a,"aria-label":`${o("entityPage.sealAlt",{name:i})} ${j+1}`,onClick:()=>l(j),children:t.jsx("img",{src:h(x),alt:"",loading:"lazy",decoding:"async"})},x.file))}),t.jsxs("figcaption",{children:[o("entityPage.imgCredit",{credit:s(m.credit)})," · ",o("entityPage.imgLicense",{license:s(m.license)}),m.source_url&&/^https?:\/\//i.test(m.source_url)&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:m.source_url,target:"_blank",rel:"noopener noreferrer nofollow",children:o("entityPage.imgSource")})]}),m.note&&t.jsxs(t.Fragment,{children:[" · ",s(m.note)]})]})]})}const V0=16,Hr=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function Ll(e){if(!e)return Hr.length;const n=Hr.indexOf(e);return n===-1?Hr.length:n}function G0(e,n,i){if(n)return e[n]??i(n)}function Y0(e,n){return e==null?"":e<0?n("entityPage.bce",{n:-e}):String(e)}const K0={秦:[-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]},yp=({data:e,transport:n,onNavigate:i,renderLink:o,railTop:s,back:a,railLinks:l,assetBase:d})=>{var H,ue,Fe,Ge,Je;const{t:c,convert:p,messages:g}=ae(),m=F=>Y0(F,c),[u,h]=f.useState("全部"),[x,j]=f.useState(!1),[b,S]=f.useState("default"),[y,k]=f.useState(new Map),w=f.useMemo(()=>e._works||[],[e._works]),v=f.useMemo(()=>w.map(F=>{const ge=y.get(F.work_id);return{id:F.work_id,title:(ge==null?void 0:ge.title)??F.title??F.work_id,role:F.role||"",cls:Ro(F.role),versionCount:ge==null?void 0:ge.versionCount,section:ge==null?void 0:ge.cls,l1:ge==null?void 0:ge.l1,measure:ge==null?void 0:ge.measure,hasImage:ge==null?void 0:ge.hasImage,loaded:!!(ge!=null&&ge.loaded)}}),[w,y]),C=f.useMemo(()=>ac(w.map(F=>F.role),c("detail.roleAll")),[w,c]),_=f.useMemo(()=>{const F=u==="全部"?v:v.filter(ge=>ge.cls===u);return b==="versions"?[...F].sort((ge,Ae)=>(Ae.versionCount??-1)-(ge.versionCount??-1)):F},[v,u,b]),$=x?_:_.slice(0,V0),A=f.useMemo(()=>$.filter(F=>!y.has(F.id)).map(F=>F.id),[$,y]);f.useEffect(()=>{if(!n||A.length===0)return;let F=!1;return ir(A,nr,ge=>n.getItem(ge).then(Ae=>{var $e;const W=Ae??{},be=W._edition_count??(($e=W._books)==null?void 0:$e.length)??0,ce=Lo(W),Ne=[ce==null?void 0:ce.l1,ce==null?void 0:ce.l2].filter(Boolean).join(" ");return[ge,{id:ge,title:W.title,versionCount:be,loaded:!0,cls:Ne||void 0,l1:(ce==null?void 0:ce.l1)||void 0,measure:Ae&&Kt(Ae,g.unit.juan)||void 0,hasImage:!!W._has_image}]}).catch(()=>[ge,{id:ge,loaded:!0}]),()=>F).then(ge=>{F||k(Ae=>{const W=new Map(Ae);for(const[be,ce]of ge)W.set(be,ce);return W})}),()=>{F=!0}},[n,A,g.unit.juan]);const R=f.useMemo(()=>{const F=new Map;for(const ge of e.alt_names||[]){const Ae=ge.type||g.section.aliases;F.has(Ae)||F.set(Ae,[]),F.get(Ae).push(ge.name)}return[...F.entries()].sort((ge,Ae)=>Ll(ge[0])-Ll(Ae[0])).map(([ge,Ae])=>({label:ge,names:Ae}))},[e.alt_names,g]),z=((H=e.dates)==null?void 0:H.birth)??void 0,N=((ue=e.dates)==null?void 0:ue.death)??void 0,M=(Fe=e.dates)==null?void 0:Fe.floruit,O=z!=null||N!=null?`${m(z)||"?"}—${m(N)||"?"}`:Array.isArray(M)&&M.length===2&&M.every(F=>Number.isFinite(F))?c("entityPage.floruit",{from:m(M[0]),to:m(M[1])}):"",L=new Set(["本名","字","號","号"]),D=R.filter(F=>L.has(F.label)),q=R.filter(F=>!L.has(F.label)),J=q.reduce((F,ge)=>F+ge.names.length,0),se=f.useMemo(()=>{const F=[];for(const Ae of D)F.push({label:Ae.label,value:Ae.names.map(W=>p(W)).join("、")});const ge=w.length;return ge&&F.push({label:c("entityPage.fact.works"),value:c("entityPage.nZhong",{n:ge})}),F},[w,D,p,c]),U=F=>{var ge;return(ge=R.find(Ae=>F.includes(Ae.label)))==null?void 0:ge.names[0]},K=U(["字"]),Z=U(["號","号"]),oe=[K?c("entityPage.zi",{name:p(K)}):"",Z?c("entityPage.hao",{name:p(Z)}):""].filter(Boolean).join(","),ye=e.native_place,Le=e.dynasty?K0[e.dynasty]:void 0,Me=(()=>{if(!Le||z==null||N==null||N<z)return null;const[F,ge]=Le,Ae=Math.max(z,F),W=Math.min(N,ge);if(W<=Ae)return null;const be=ge-F;return t.jsxs("div",{className:"bim-d-life bim-d-ui",children:[t.jsx("div",{className:"bim-d-life-bar",role:"img","aria-label":c("entityPage.lifeAria",{birth:m(z),death:m(N),years:N-z+1}),children:t.jsx("i",{style:{left:`${(Ae-F)/be*100}%`,width:`${(W-Ae)/be*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:`${m(F)} ${p(e.dynasty)}`}),t.jsx("span",{children:c("entityPage.lifeYears",{years:N-z+1})}),t.jsx("span",{children:m(ge)})]})]})})(),Se=f.useMemo(()=>{if(!n||v.length===0||v.some(Ae=>!Ae.loaded))return null;const F=new Map;for(const Ae of v){const W=ho(Ae.l1);W&&F.set(W,(F.get(W)??0)+1)}const ge=Qn.map(Ae=>({...Ae,n:F.get(Ae.key)??0})).filter(Ae=>Ae.n>0);return ge.length?ge:null},[v,n]),le=t.jsxs(oi,{kind:G0(g.entityPage.subtype,e.subtype,p),title:p(e.primary_name||e.title),subtitle:oe||void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(ht,{items:[e.dynasty?p(e.dynasty):"",O,ye?c("entityPage.nativePlace",{place:p(ye)}):""]}),Me,t.jsx(U0,{images:e.images,assetBase:d,name:p(e.primary_name||e.title)})]}),description:(Ge=e.description)!=null&&Ge.text?t.jsx(qt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:Uo((Je=e.description)==null?void 0:Je.text)?6:void 0,facts:se,foot:t.jsx(si,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[J>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c("entityPage.moreNames",{n:J})}),t.jsx("dl",{children:q.map(F=>t.jsxs(f.Fragment,{children:[t.jsx("dt",{children:p(F.label)}),t.jsx("dd",{children:F.names.map(ge=>p(ge)).join("、")})]},F.label))})]}),Se&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:c("entityPage.dist")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:Se.map(F=>t.jsx("i",{style:{flexGrow:F.n,background:r(F.token)}},F.key))}),t.jsx("div",{className:"bim-d-dist-key",children:Se.map(F=>t.jsxs("span",{children:[t.jsx("i",{style:{background:r(F.token)}}),p(F.label)," ",F.n]},F.key))})]})]}),Oe=f.useMemo(()=>v.filter(F=>F.loaded&&(F.versionCount??0)>0).sort((F,ge)=>(ge.versionCount??0)-(F.versionCount??0)).slice(0,3),[v]),T=!!n&&v.length>=3&&$.some(F=>!F.loaded),de=u==="全部"&&(T||Oe.length>=2),pe=e.external_ids||{},B=[];pe.cbdb_id!=null&&B.push({label:"CBDB",id:String(pe.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${pe.cbdb_id}`,note:pe.cbdb_match==="auto"?c("entityPage.autoMatch"):void 0});const ee=pe.wikidata_id;ee&&B.push({label:"Wikidata",id:ee,href:`https://www.wikidata.org/wiki/${ee}`});const Ce=pe.viaf_id;Ce&&B.push({label:"VIAF",id:Ce,href:`https://viaf.org/viaf/${Ce}`});const Ie=C.map(F=>({key:F.cls,label:`${F.label} ${F.count}`})),We=[...de&&!T?[{id:"featured",label:c("entityPage.sec.featured"),count:Oe.length}]:[],...v.length?[{id:"works",label:c("entityPage.sec.allWorks"),count:v.length}]:[],...B.length?[{id:"external",label:c("entityPage.sec.external"),count:B.length}]:[]],G=de?t.jsxs(bt,{id:"featured",title:c("entityPage.sec.featured"),children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:c("entityPage.featuredSub")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":T||void 0,children:[T&&[0,1,2].map(F=>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:" "})]},F)),!T&&Oe.map(F=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(ut,{id:F.id,label:p(F.title),onNavigate:i,renderLink:o,dense:!0})}),t.jsx(ht,{items:[F.section?p(F.section):"",F.measure?p(F.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:F.versionCount}),t.jsx("span",{children:c("entityPage.versionsUnit")}),F.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("entityPage.hasImage")})]})]},F.id))]})]}):null,he=v.length===0?t.jsx(bt,{title:c("entityPage.sec.works"),children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("entityPage.empty")})}):t.jsxs(t.Fragment,{children:[G,t.jsxs(bt,{id:"works",title:c("entityPage.sec.works"),meta:t.jsx(ht,{items:[c("entityPage.total",{n:v.length}),_.length!==v.length?c("entityPage.current",{n:_.length}):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[Ie.length>1&&t.jsx(Ji,{items:Ie,value:u,onChange:F=>{h(F),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":b==="versions",onClick:()=>{b==="default"&&j(!0),S(F=>F==="default"?"versions":"default")},children:c(b==="default"?"entityPage.sortByVersions":"entityPage.sortByCatalog")})]}),t.jsxs("table",{className:"bim-d-zt","data-ncap":!x&&Qi(_.length)?"":void 0,children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("entityPage.col.work")}),t.jsx("th",{children:c("entityPage.col.section")}),t.jsx("th",{children:c("entityPage.col.role")}),t.jsx("th",{children:c("entityPage.col.versions")}),t.jsx("th",{"aria-label":c("entityPage.col.image")})]})}),t.jsx("tbody",{children:$.map(F=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(ut,{id:F.id,label:p(F.title),onNavigate:i,renderLink:o,dense:!0}),F.measure?t.jsx(ht,{items:[p(F.measure)]}):!F.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${F.section||F.loaded?"":" bim-d-zt-blank"}`,children:F.section?p(F.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${F.role?"":" bim-d-zt-blank"}`,children:F.role?p(F.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${F.loaded?"":" bim-d-zt-blank"}`,children:F.loaded?F.versionCount?c("entityPage.nZhong",{n:F.versionCount}):t.jsx("span",{className:"bim-d-zt-empty",children:c("entityPage.notRecorded")}):""}),t.jsx("td",{className:F.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:F.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("entityPage.hasImage")})})]},F.id))})]}),$.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("entityPage.emptyRole")}),!x&&t.jsx(Ho,{total:_.length,shown:$.length,unit:c("entityPage.moreUnit"),onClick:()=>j(!0)})]})]}),te=B.length>0?t.jsx(un,{id:"external",title:c("entityPage.sec.external"),items:B.map(F=>t.jsxs("a",{href:F.href,target:"_blank",rel:"noopener noreferrer",children:[F.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:B.map(F=>F.id),foot:pe.cbdb_id!=null&&pe.cbdb_match==="auto"?c("entityPage.cbdbAuto"):void 0}):null;return t.jsx(ri,{railTop:s,back:a,nav:We,railLinks:l,main:he,card:le,side:te})},ks="(max-width: 719px)",q0=`${ks}, (pointer: coarse)`,jp=`
|
|
1452
1483
|
.bim-ct {
|
|
1453
1484
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
1454
1485
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
@@ -1556,7 +1587,7 @@ ${ie??""}`,[Mn,Ts]=f.useState({key:An,data:ce,started:!!ce});if(Mn.key!==An)Ts({
|
|
|
1556
1587
|
.bim-ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1557
1588
|
}
|
|
1558
1589
|
|
|
1559
|
-
@media ${
|
|
1590
|
+
@media ${ks} {
|
|
1560
1591
|
.bim-ct { display: block; padding: 12px 16px 40px; }
|
|
1561
1592
|
.bim-ct-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
|
1562
1593
|
.bim-ct-lrow > a { grid-template-columns: minmax(0, 1fr); }
|
|
@@ -1581,7 +1612,7 @@ ${ie??""}`,[Mn,Ts]=f.useState({key:An,data:ce,started:!!ce});if(Mn.key!==An)Ts({
|
|
|
1581
1612
|
}
|
|
1582
1613
|
|
|
1583
1614
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
1584
|
-
@media ${
|
|
1615
|
+
@media ${q0} {
|
|
1585
1616
|
.bim-ct-row { min-height: 44px; }
|
|
1586
1617
|
.bim-ct-tw { width: 44px; }
|
|
1587
1618
|
.bim-ct-pg { min-width: 44px; height: 44px; }
|
|
@@ -1607,7 +1638,7 @@ ${ie??""}`,[Mn,Ts]=f.useState({key:An,data:ce,started:!!ce});if(Mn.key!==An)Ts({
|
|
|
1607
1638
|
/* 窄屏分类抽屉:界栏下按钮和面板都有框 */
|
|
1608
1639
|
:root[data-layout="boxed"] .bim-ct-drawer-btn { border: ${r("fr-bd")}; background: ${r("fr-bg")}; }
|
|
1609
1640
|
:root[data-layout="boxed"] .bim-ct-drawer { border: ${r("fr-bd")}; }
|
|
1610
|
-
`,dn="未分類",Vt="all",js=20;function ai(e){if(!e)return[];const n=[];for(const i of[e.l1,e.l2,e.l3,e.l4]){const o=(i??"").trim();if(!o)break;n.push(o)}return n}function Y0(e){const n=ai(e);return n.length?n.join("/"):dn}function K0(e){const n=ai(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[dn]}function q0(e,n=[]){const i=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(g=>!!g);p.forEach((g,m)=>{const u=p.slice(0,m+1).join("/");i.has(u)||i.set(u,c)})});const o=new Map;let s=0;for(const d of e){const c=ai(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((g,m)=>{const u=c.slice(0,m+1).join("/");let h=p.get(g);h||(h={id:u,label:g,count:0,children:new Map},p.set(g,h)),h.count++,p=h.children})}const a=d=>[...d.values()].sort((c,p)=>{const g=c.label===dn?1:0,m=p.label===dn?1:0;if(g!==m)return g-m;const u=i.get(c.id)??1/0,h=i.get(p.id)??1/0;return u!==h?u-h:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(o);return s>0&&l.push({id:dn,label:dn,count:s}),l}function wn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=wn(i.children,n);if(o.length)return[i,...o]}}return[]}function vs(e){return e.reduce((n,i)=>n+i.count,0)}function X0(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function Z0(e){var d;const n={id:e.id,title:e.title||e.id},i=e.juan_count,o=typeof i=="number"?i:i==null?void 0:i.number;typeof o=="number"&&o>0?n.juan=o: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=X0(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=ai(e.classification);return l.length&&(n.classification=l),n}function J0(e,n){const i=e.summary?0:1,o=n.summary?0:1;return i!==o?i-o:e.title.localeCompare(n.title,"zh")}function Q0(e,n=js){return Math.max(1,Math.ceil(e/n))}function bp(e,n,i=2){if(n<=1)return[1];const o=new Set([1,n]);for(let l=e-i;l<=e+i;l++)l>=1&&l<=n&&o.add(l);const s=[...o].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 e1=()=>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 t1(e,n,i){const o=[];i&&o.push({id:Vt,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;o.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),o}function yp({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=ae(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=f.useRef(null),g=n&&n!==Vt?n:null,m=d!==null,[u,h]=f.useState(()=>{const _=new Set;for(const R of wn(e,g))_.add(R.id);return _});f.useEffect(()=>{const _=wn(e,g);_.length&&h(R=>{if(_.every(N=>R.has(N.id)))return R;const z=new Set(R);for(const N of _)z.add(N.id);return z})},[e,g]);const x=f.useMemo(()=>t1(e,u,m),[e,u,m]),[j,b]=f.useState(null);f.useEffect(()=>{b(null)},[n]);const $=g??(m?Vt:null),y=f.useMemo(()=>{var z;const _=new Set(x.map(N=>N.id));if(j&&_.has(j))return j;if($&&_.has($))return $;const R=wn(e,g).map(N=>N.id).filter(N=>_.has(N));return R.length?R[R.length-1]:((z=x[0])==null?void 0:z.id)??null},[x,j,$,e,g]),k=f.useCallback((_,R)=>{h(z=>{const N=z.has(_),I=R??!N;if(I===N)return z;const B=new Set(z);return I?B.add(_):B.delete(_),B})},[]),w=f.useCallback(_=>{b(_),requestAnimationFrame(()=>{var z;const R=Array.from(((z=p.current)==null?void 0:z.querySelectorAll("[data-ct-id]"))??[]).find(N=>N.dataset.ctId===_);R==null||R.focus()})},[]),v=f.useCallback((_,R)=>{R&&k(_,!0),i(_)},[i,k]),C=f.useCallback(_=>{const R=_.target.closest("[data-ct-id]");if(!R)return;const z=R.dataset.ctId,N=x.findIndex(O=>O.id===z);if(N<0)return;const I=x[N];let B=null;switch(_.key){case"ArrowDown":B=x[Math.min(x.length-1,N+1)].id;break;case"ArrowUp":B=x[Math.max(0,N-1)].id;break;case"Home":B=x[0].id;break;case"End":B=x[x.length-1].id;break;case"ArrowRight":if(!I.hasChildren)break;u.has(z)?B=I.firstChildId:k(z,!0);break;case"ArrowLeft":I.hasChildren&&u.has(z)?k(z,!1):B=I.parentId;break;case"Enter":case" ":_.preventDefault(),v(z,I.hasChildren);return;default:return}_.preventDefault(),B&&B!==z&&w(B)},[x,u,k,w,v]),S=(_,R)=>_.map((z,N)=>{var W;const I=(W=z.children)!=null&&W.length?z.children:null,B=!!I&&u.has(z.id),O=z.id===g,A=R===1&&_.length>1&&N===_.length-1;return t.jsxs("li",{role:"treeitem","aria-level":R,"aria-expanded":I?B:void 0,"aria-selected":O,tabIndex:y===z.id?0:-1,"data-ct-id":z.id,className:A?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":R-1},onClick:()=>{b(z.id),v(z.id,!!I)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:I?G=>{G.stopPropagation(),b(z.id),k(z.id)}:void 0,children:I?t.jsx(e1,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(z.label)}),t.jsx("span",{className:"bim-ct-n",children:z.count.toLocaleString("en-US")})]}),B&&t.jsx("ul",{role:"group",children:S(I,R+1)})]},z.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:C,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!g,tabIndex:y===Vt?0:-1,"data-ct-id":Vt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{b(Vt),i(Vt)},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:vs(e).toLocaleString("en-US")})]})}),S(e,1)]})}const jp=e=>`/item/${encodeURIComponent(e)}`;function n1(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function vp(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function kp({work:e,href:n}){var d,c;const{t:i,convert:o}=ae(),s=vp(e.juan,i),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:o(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,g)=>t.jsxs(f.Fragment,{children:[g>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},g))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:o(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function wp({work:e,href:n}){var d,c;const{t:i,convert:o}=ae(),s=vp(e.juan,i),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:[o(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,g)=>t.jsxs(f.Fragment,{children:[g>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},g))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Sp({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=ae();if(n<=1)return null;const d=p=>g=>{i&&(o&&!n1(g)||(g.preventDefault(),i(p)))},c=(p,g,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:g});const u={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return o?t.jsx("a",{...u,href:o(p),onClick:d(p),children:g}):t.jsx("button",{type:"button",...u,onClick:m.current?void 0:d(p),children:g})};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:bp(e,n).map((p,g)=>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${g}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function _p({works:e,workLink:n=jp,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=ae();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:i===void 0?a("catalogPage.emptyWorks"):typeof i=="string"?l(i):i}):o==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(wp,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(kp,{work:d,href:n(d.id)},d.id))}),t.jsx(Sp,{...s})]})}const i1=()=>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 r1({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:g,allTitle:m,pageSize:u=js,className:h,view:x,onViewChange:j}){const{t:b,convert:$}=ae(),y=g===void 0?b("catalogPage.all"):g,k=m??b("catalogPage.allTitle"),v=`bim-ct-drawer-${f.useId().replace(/:/g,"")}`,[C,S]=f.useState(!1),[_,R]=f.useState("card"),z=x??_,N=G=>{R(G),j==null||j(G)},I=wn(e,n&&n!==Vt?n:null),B=I.length?I[I.length-1]:null,O=B?B.label:k,A=B?B.count:vs(e),W=f.useCallback(G=>{S(!1),a(G)},[a]);return t.jsxs("div",{className:h?`bim-ct ${h}`:"bim-ct","data-drawer":C?"open":"closed",children:[t.jsx("style",{children:xp}),t.jsxs("aside",{className:"bim-ct-side","aria-label":b("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":C,"aria-controls":v,onClick:()=>S(G=>!G),children:[t.jsx("span",{children:b("catalogPage.drawerLabel",{path:$(I.length?I.map(G=>G.label).join(" › "):y??k)})}),t.jsx(i1,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:b("catalogPage.classification")}),t.jsx(yp,{tree:e,selectedId:n,onSelect:W,allLabel:y})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:$(O)}),I.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:$(I.slice(0,-1).map(G=>G.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[b("catalogPage.stat",{total:A.toLocaleString("en-US"),size:u}),o>1&&b("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":b("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":z==="card",onClick:()=>N("card"),children:b("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":z==="list",onClick:()=>N("list"),children:b("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(_p,{works:s,view:z,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const li="(max-width: 719px)",o1="(max-width: 1079px)",s1=`${li}, (pointer: coarse)`,a1=[8,18,30,42,88],ks=`
|
|
1641
|
+
`,pn="未分類",Vt="all",ws=20;function li(e){if(!e)return[];const n=[];for(const i of[e.l1,e.l2,e.l3,e.l4]){const o=(i??"").trim();if(!o)break;n.push(o)}return n}function X0(e){const n=li(e);return n.length?n.join("/"):pn}function Z0(e){const n=li(e);return n.length?n.map((i,o)=>n.slice(0,o+1).join("/")):[pn]}function J0(e,n=[]){const i=new Map;n.forEach((d,c)=>{const p=[d.cata_l1,d.cata_l2,d.cata_l3,d.cata_l4].filter(g=>!!g);p.forEach((g,m)=>{const u=p.slice(0,m+1).join("/");i.has(u)||i.set(u,c)})});const o=new Map;let s=0;for(const d of e){const c=li(d.classification);if(!c.length){s++;continue}let p=o;c.forEach((g,m)=>{const u=c.slice(0,m+1).join("/");let h=p.get(g);h||(h={id:u,label:g,count:0,children:new Map},p.set(g,h)),h.count++,p=h.children})}const a=d=>[...d.values()].sort((c,p)=>{const g=c.label===pn?1:0,m=p.label===pn?1:0;if(g!==m)return g-m;const u=i.get(c.id)??1/0,h=i.get(p.id)??1/0;return u!==h?u-h:c.label.localeCompare(p.label,"zh")}).map(c=>{const p={id:c.id,label:c.label,count:c.count};return c.children.size&&(p.children=a(c.children)),p}),l=a(o);return s>0&&l.push({id:pn,label:pn,count:s}),l}function Sn(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const o=Sn(i.children,n);if(o.length)return[i,...o]}}return[]}function Ss(e){return e.reduce((n,i)=>n+i.count,0)}function Q0(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function e1(e){var d;const n={id:e.id,title:e.title||e.id},i=e.juan_count,o=typeof i=="number"?i:i==null?void 0:i.number;typeof o=="number"&&o>0?n.juan=o: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=Q0(typeof e.description=="string"?e.description:(d=e.description)==null?void 0:d.text);a&&(n.summary=a);const l=li(e.classification);return l.length&&(n.classification=l),n}function t1(e,n){const i=e.summary?0:1,o=n.summary?0:1;return i!==o?i-o:e.title.localeCompare(n.title,"zh")}function n1(e,n=ws){return Math.max(1,Math.ceil(e/n))}function vp(e,n,i=2){if(n<=1)return[1];const o=new Set([1,n]);for(let l=e-i;l<=e+i;l++)l>=1&&l<=n&&o.add(l);const s=[...o].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 i1=()=>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 r1(e,n,i){const o=[];i&&o.push({id:Vt,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;o.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),o}function kp({tree:e,selectedId:n,onSelect:i,allLabel:o,label:s}){const{t:a,convert:l}=ae(),d=o===void 0?a("catalogPage.all"):o,c=s??a("catalogPage.classification"),p=f.useRef(null),g=n&&n!==Vt?n:null,m=d!==null,[u,h]=f.useState(()=>{const $=new Set;for(const A of Sn(e,g))$.add(A.id);return $});f.useEffect(()=>{const $=Sn(e,g);$.length&&h(A=>{if($.every(z=>A.has(z.id)))return A;const R=new Set(A);for(const z of $)R.add(z.id);return R})},[e,g]);const x=f.useMemo(()=>r1(e,u,m),[e,u,m]),[j,b]=f.useState(null);f.useEffect(()=>{b(null)},[n]);const S=g??(m?Vt:null),y=f.useMemo(()=>{var R;const $=new Set(x.map(z=>z.id));if(j&&$.has(j))return j;if(S&&$.has(S))return S;const A=Sn(e,g).map(z=>z.id).filter(z=>$.has(z));return A.length?A[A.length-1]:((R=x[0])==null?void 0:R.id)??null},[x,j,S,e,g]),k=f.useCallback(($,A)=>{h(R=>{const z=R.has($),N=A??!z;if(N===z)return R;const M=new Set(R);return N?M.add($):M.delete($),M})},[]),w=f.useCallback($=>{b($),requestAnimationFrame(()=>{var R;const A=Array.from(((R=p.current)==null?void 0:R.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===$);A==null||A.focus()})},[]),v=f.useCallback(($,A)=>{A&&k($,!0),i($)},[i,k]),C=f.useCallback($=>{const A=$.target.closest("[data-ct-id]");if(!A)return;const R=A.dataset.ctId,z=x.findIndex(O=>O.id===R);if(z<0)return;const N=x[z];let M=null;switch($.key){case"ArrowDown":M=x[Math.min(x.length-1,z+1)].id;break;case"ArrowUp":M=x[Math.max(0,z-1)].id;break;case"Home":M=x[0].id;break;case"End":M=x[x.length-1].id;break;case"ArrowRight":if(!N.hasChildren)break;u.has(R)?M=N.firstChildId:k(R,!0);break;case"ArrowLeft":N.hasChildren&&u.has(R)?k(R,!1):M=N.parentId;break;case"Enter":case" ":$.preventDefault(),v(R,N.hasChildren);return;default:return}$.preventDefault(),M&&M!==R&&w(M)},[x,u,k,w,v]),_=($,A)=>$.map((R,z)=>{var D;const N=(D=R.children)!=null&&D.length?R.children:null,M=!!N&&u.has(R.id),O=R.id===g,L=A===1&&$.length>1&&z===$.length-1;return t.jsxs("li",{role:"treeitem","aria-level":A,"aria-expanded":N?M:void 0,"aria-selected":O,tabIndex:y===R.id?0:-1,"data-ct-id":R.id,className:L?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":A-1},onClick:()=>{b(R.id),v(R.id,!!N)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:N?q=>{q.stopPropagation(),b(R.id),k(R.id)}:void 0,children:N?t.jsx(i1,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(R.label)}),t.jsx("span",{className:"bim-ct-n",children:R.count.toLocaleString("en-US")})]}),M&&t.jsx("ul",{role:"group",children:_(N,A+1)})]},R.id)});return t.jsxs("ul",{ref:p,role:"tree","aria-label":l(c),className:"bim-ct-tree",onKeyDown:C,children:[m&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!g,tabIndex:y===Vt?0:-1,"data-ct-id":Vt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{b(Vt),i(Vt)},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:Ss(e).toLocaleString("en-US")})]})}),_(e,1)]})}const wp=e=>`/item/${encodeURIComponent(e)}`;function o1(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function Sp(e,n){return e==null||e===""?null:typeof e=="number"?n("catalogPage.juanN",{n:e}):e}function _p({work:e,href:n}){var d,c;const{t:i,convert:o}=ae(),s=Sp(e.juan,i),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:o(e.title)}),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),a.length>0&&t.jsx("span",{className:"bim-ct-by",children:a.map((p,g)=>t.jsxs(f.Fragment,{children:[g>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},g))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:o(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function $p({work:e,href:n}){var d,c;const{t:i,convert:o}=ae(),s=Sp(e.juan,i),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:[o(e.title),s&&t.jsx("span",{className:"bim-ct-juan",children:o(s)})]}),t.jsx("span",{className:"bim-ct-by",children:a.map((p,g)=>t.jsxs(f.Fragment,{children:[g>0&&"、",p.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(p.dynasty),"〕"]}),o(p.name)]},g))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(p=>o(p)).join(" · ")})]})})}function Cp({page:e,pageCount:n,onPage:i,pageHref:o,label:s}){const{t:a,convert:l}=ae();if(n<=1)return null;const d=p=>g=>{i&&(o&&!o1(g)||(g.preventDefault(),i(p)))},c=(p,g,m)=>{if(m.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:g});const u={className:"bim-ct-pg","aria-current":m.current?"page":void 0,"aria-label":m.aria};return o?t.jsx("a",{...u,href:o(p),onClick:d(p),children:g}):t.jsx("button",{type:"button",...u,onClick:m.current?void 0:d(p),children:g})};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:vp(e,n).map((p,g)=>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${g}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),c(e+1,a("catalogPage.nextPage"),{disabled:e>=n})]})}function zp({works:e,workLink:n=wp,emptyText:i,view:o="card",...s}){const{t:a,convert:l}=ae();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:i===void 0?a("catalogPage.emptyWorks"):typeof i=="string"?l(i):i}):o==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx($p,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(_p,{work:d,href:n(d.id)},d.id))}),t.jsx(Cp,{...s})]})}const s1=()=>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 a1({tree:e,selectedId:n,page:i,pageCount:o,works:s,onSelect:a,onPage:l,searchSlot:d,workLink:c,pageHref:p,allLabel:g,allTitle:m,pageSize:u=ws,className:h,view:x,onViewChange:j}){const{t:b,convert:S}=ae(),y=g===void 0?b("catalogPage.all"):g,k=m??b("catalogPage.allTitle"),v=`bim-ct-drawer-${f.useId().replace(/:/g,"")}`,[C,_]=f.useState(!1),[$,A]=f.useState("card"),R=x??$,z=q=>{A(q),j==null||j(q)},N=Sn(e,n&&n!==Vt?n:null),M=N.length?N[N.length-1]:null,O=M?M.label:k,L=M?M.count:Ss(e),D=f.useCallback(q=>{_(!1),a(q)},[a]);return t.jsxs("div",{className:h?`bim-ct ${h}`:"bim-ct","data-drawer":C?"open":"closed",children:[t.jsx("style",{children:jp}),t.jsxs("aside",{className:"bim-ct-side","aria-label":b("catalogPage.sideNav"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":C,"aria-controls":v,onClick:()=>_(q=>!q),children:[t.jsx("span",{children:b("catalogPage.drawerLabel",{path:S(N.length?N.map(q=>q.label).join(" › "):y??k)})}),t.jsx(s1,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:v,children:[t.jsx("h2",{className:"bim-ct-side-h",children:b("catalogPage.classification")}),t.jsx(kp,{tree:e,selectedId:n,onSelect:D,allLabel:y})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:S(O)}),N.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:S(N.slice(0,-1).map(q=>q.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[b("catalogPage.stat",{total:L.toLocaleString("en-US"),size:u}),o>1&&b("catalogPage.statPage",{page:i,pages:o})]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":b("catalogPage.viewLabel"),children:[t.jsx("button",{type:"button","aria-pressed":R==="card",onClick:()=>z("card"),children:b("catalogPage.viewCard")}),t.jsx("button",{type:"button","aria-pressed":R==="list",onClick:()=>z("list"),children:b("catalogPage.viewList")})]})]}),d&&t.jsx("div",{className:"bim-ct-search",children:d}),t.jsx(zp,{works:s,view:R,workLink:c,page:i,pageCount:o,onPage:l,pageHref:p})]})]})}const ci="(max-width: 719px)",l1="(max-width: 1079px)",c1=`${ci}, (pointer: coarse)`,d1=[8,18,30,42,88],_s=`
|
|
1611
1642
|
.bim-rh { color: ${r("ink")}; font-family: ${r("font-ui")}; font-size: 14px; line-height: 1.6; }
|
|
1612
1643
|
.bim-rh *, .bim-rh *::before, .bim-rh *::after { box-sizing: border-box; }
|
|
1613
1644
|
.bim-rh a { color: ${r("accent")}; text-decoration: none; }
|
|
@@ -1755,7 +1786,7 @@ ${ie??""}`,[Mn,Ts]=f.useState({key:An,data:ce,started:!!ce});if(Mn.key!==An)Ts({
|
|
|
1755
1786
|
flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 8px; overflow: hidden;
|
|
1756
1787
|
color: ${r("ink")} !important; font-size: 13px;
|
|
1757
1788
|
}
|
|
1758
|
-
${
|
|
1789
|
+
${d1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb, ${r("accent")} ${e}%, ${r("card-bg")}); }`).join(`
|
|
1759
1790
|
`)}
|
|
1760
1791
|
.bim-rh-band a[data-k="4"] { color: ${r("page-bg")} !important; }
|
|
1761
1792
|
.bim-rh-band a:hover { outline: 2px solid ${r("ink")}; outline-offset: -2px; }
|
|
@@ -1783,13 +1814,13 @@ ${a1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1783
1814
|
}
|
|
1784
1815
|
|
|
1785
1816
|
/* ── 中屏 ── */
|
|
1786
|
-
@media ${
|
|
1817
|
+
@media ${l1} {
|
|
1787
1818
|
.bim-rh-picks, .bim-rh-works, .bim-rh-groups, .bim-rh-bu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1788
1819
|
.bim-rh-authors { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
1789
1820
|
}
|
|
1790
1821
|
|
|
1791
1822
|
/* ── 手机 ── */
|
|
1792
|
-
@media ${
|
|
1823
|
+
@media ${ci} {
|
|
1793
1824
|
.bim-rh-main { padding-top: 24px; }
|
|
1794
1825
|
.bim-rh-stats { gap: 4px 18px; }
|
|
1795
1826
|
.bim-rh-stats b { font-size: 16px; }
|
|
@@ -1826,7 +1857,7 @@ ${a1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1826
1857
|
}
|
|
1827
1858
|
|
|
1828
1859
|
/* 触屏或窄屏:点击目标放大到 44px */
|
|
1829
|
-
@media ${
|
|
1860
|
+
@media ${c1} {
|
|
1830
1861
|
.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; }
|
|
1831
1862
|
.bim-rh-chip { display: inline-flex; }
|
|
1832
1863
|
}
|
|
@@ -1837,7 +1868,7 @@ ${a1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1837
1868
|
}
|
|
1838
1869
|
|
|
1839
1870
|
@media (prefers-reduced-motion: reduce) { .bim-rh * { scroll-behavior: auto !important; transition: none !important; } }
|
|
1840
|
-
`,l1=So["zh-Hant"].period,$p={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function tn(e){return{...$p,...e??{}}}function ws(e){var i;const n=(i=e.authors)==null?void 0:i.find(o=>o==null?void 0:o.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function ir(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Cp(e,n=So["zh-Hant"].shelfOther){var s;const i=[],o=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=o.get(l);d||(d={label:l,items:[]},o.set(l,d),i.push(d)),d.items.push(a)}return i}function zp(e){return Math.max(150,Array.from(e).length*18+44)}function Np(e,n){if(n<=0||e<=0)return 0;const i=e/n;return i<.15?0:i<.35?1:i<.6?2:i<.85?3:4}const Tp=.04;function lt(e){return e.toLocaleString("en-US")}function Rp({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function vt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=ae(),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)}),i&&t.jsx("span",{className:"bim-rh-sub",children:i}),o]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function Ip({counts:e}){const{t:n}=ae();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:lt(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:lt(e.pieces)}),n("readHome.pieces")]})]})}function Ep({picks:e,links:n}){const{t:i,convert:o}=ae(),s=tn(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=ir(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(Rp,{text:o(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:o(d)}),t.jsx("h3",{children:o(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:o(l)}),a.blurb&&t.jsx("p",{children:o(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:i("readHome.startReading")})]})]})},a.id)})}):null}function Lp(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Ss({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ae(),c=tn(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,g=Cp(e.items,l("readHome.shelfOther")),m=u=>{const h=u.records?lt(u.records):Lp(u.text_count,l),x=ws(u),j=[d(u.title),u.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",u.records?l("readHome.spineRecords",{n:h}):h?l("readHome.spineOnSite",{n:h}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(u.id),"data-orig":u.orig?"":void 0,"aria-label":j,title:j,style:{height:zp(u.title)},children:[t.jsx(Rp,{text:d(u.title)}),h&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":u.records?"":void 0,children:h})]})},u.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:i?d(i):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:g.map(u=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(u.label),children:u.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(u.label)})]},u.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(u=>t.jsx("span",{children:d(u)},u))]})]})}const c1=4,ti=e=>e>c1+1;function Ap({topic:e,links:n}){const{t:i,convert:o}=ae(),s=tn(n),[a,l]=f.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":ti(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nWorks",{n:lt(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Lp(c.text_count,i),g=ws(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),g&&t.jsx("small",{children:o(g)})]})},c.id)})}),ti(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?i("action.collapse"):i("readHome.allNWorks",{n:e.items.length})})]})}function Mp({topics:e,links:n}){const i=e.filter(s=>s.shelf&&s.items.length),o=e.filter(s=>!s.shelf&&s.items.length);return!i.length&&!o.length?null:t.jsxs(t.Fragment,{children:[i.map(s=>t.jsx(Ss,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(Ap,{topic:s,links:n},s.key))})]})}function Pp({famous:e,links:n}){const{t:i,convert:o}=ae(),s=tn(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:o(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:o(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:i("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?o(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:o(l.label)}),l.items.map(c=>t.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:o([c.title,c.edition].filter(Boolean).join(" · ")),children:o(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:i("readHome.workPageLink",{title:o(a.title)})})})]})},a.work_id??a.title))}):null}function _s({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ae(),l=tn(i);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:lt(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(g=>t.jsx("li",{children:t.jsxs("a",{href:l.node(g.id),children:[t.jsx("span",{children:a(g.label)}),t.jsx("small",{className:"bim-rh-num",children:lt(g.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(g.count/c*100)}%`}})]})},g.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:lt(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Bp({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ae(),l=a.readHome.period,d=tn(i),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,u)=>m+u.count,0),g=Math.max(...c.map(m=>m.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(m=>{const u=m.label?s(m.label):l[m.key]??s(m.key),h=m.count/p,x=o("readHome.periodItem",{label:u,n:lt(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(h*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":Np(m.count,g),"data-narrow":h<Tp?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:u}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(u)[0]}),t.jsx("small",{className:"bim-rh-num",children:lt(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:lt(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Op({authors:e,links:n}){const{t:i,convert:o}=ae(),s=tn(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:[o(a.name),a.dynasty&&t.jsx("span",{children:o(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nPieces",{n:lt(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:o(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:i("readHome.authorAll",{name:o(a.name),n:a.count})})]},a.name))}):null}const Wp={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function d1({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ae(),l=e,d=Wp,c=l.topics.filter(u=>!u.shelf),p={picks:l.picks.length>0,topics:c.some(u=>u.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(u=>u.count>0),pieces:l.pieces.authors.length>0},g=Object.keys(d).filter(u=>p[u]),m=u=>a(`readHome.nav.${u}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:ks}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Ip,{counts:l.counts})]}),g.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:g.map(u=>t.jsx("li",{children:t.jsx("a",{href:`#${d[u]}`,children:m(u)})},u))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(vt,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(Ep,{picks:l.picks,links:n})}),p.topics&&t.jsx(vt,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(Mp,{topics:c,links:n})}),p.famous&&t.jsx(vt,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(Pp,{famous:l.famous,links:n})}),p.sibu&&t.jsx(vt,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(_s,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(vt,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(Bp,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(vt,{id:d.pieces,title:m("pieces"),sub:a("readHome.piecesSub"),more:o?t.jsx("a",{className:"bim-rh-more",href:o,children:a("readHome.piecesMore")}):void 0,children:t.jsx(Op,{authors:l.pieces.authors,links:n})})]})]})}const p1="(max-width: 1079px)",u1=`${li}, (pointer: coarse)`,Fp=`
|
|
1871
|
+
`,p1=$o["zh-Hant"].period,Np={read:e=>`/read/${encodeURIComponent(e)}`,node:e=>`/read?node=${encodeURIComponent(e)}`,period:e=>`/read?period=${encodeURIComponent(e)}`,work:e=>`/item/${encodeURIComponent(e)}`};function nn(e){return{...Np,...e??{}}}function $s(e){var i;const n=(i=e.authors)==null?void 0:i.find(o=>o==null?void 0:o.name);return n?n.dynasty?`${n.dynasty} ${n.name}`:n.name:""}function or(e){return(e.authors??[]).filter(i=>i==null?void 0:i.name).map(i=>i.dynasty?`〔${i.dynasty}〕${i.name}`:i.name).join(" ")}function Tp(e,n=$o["zh-Hant"].shelfOther){var s;const i=[],o=new Map;for(const a of e){const l=((s=a.period_of)==null?void 0:s.trim())||n;let d=o.get(l);d||(d={label:l,items:[]},o.set(l,d),i.push(d)),d.items.push(a)}return i}function Rp(e){return Math.max(150,Array.from(e).length*18+44)}function Ip(e,n){if(n<=0||e<=0)return 0;const i=e/n;return i<.15?0:i<.35?1:i<.6?2:i<.85?3:4}const Ep=.04;function lt(e){return e.toLocaleString("en-US")}function Lp({text:e}){return t.jsx(t.Fragment,{children:Array.from(e).map((n,i)=>t.jsx("span",{children:n},i))})}function wt({id:e,title:n,sub:i,more:o,children:s}){const{convert:a}=ae(),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)}),i&&t.jsx("span",{className:"bim-rh-sub",children:i}),o]}),t.jsx("div",{className:"bim-rh-bd",children:s})]})}function Ap({counts:e}){const{t:n}=ae();return t.jsxs("p",{className:"bim-rh-stats bim-rh-num",children:[t.jsxs("span",{children:[t.jsx("b",{children:lt(e.readable)}),n("readHome.readable")]}),e.pieces>0&&t.jsxs("span",{children:[t.jsx("b",{children:lt(e.pieces)}),n("readHome.pieces")]})]})}function Mp({picks:e,links:n}){const{t:i,convert:o}=ae(),s=nn(n);return e.length?t.jsx("ul",{className:"bim-rh-picks",children:e.map(a=>{const l=or(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(Lp,{text:o(a.slip||a.title)})}),t.jsxs("span",{className:"bim-rh-pk-body",children:[d&&t.jsx("span",{className:"bim-rh-badge",children:o(d)}),t.jsx("h3",{children:o(a.title)}),l&&t.jsx("span",{className:"bim-rh-by",children:o(l)}),a.blurb&&t.jsx("p",{children:o(a.blurb)}),t.jsx("span",{className:"bim-rh-go","aria-hidden":"true",children:i("readHome.startReading")})]})]})},a.id)})}):null}function Pp(e,n){return e&&e>1?n("readHome.nCopies",{n:e}):null}function Cs({topic:e,links:n,hint:i,legendCount:o,showTitle:s=!0,legendExtra:a}){const{t:l,convert:d}=ae(),c=nn(n);if(!e.items.length)return null;const p=o===void 0?l("readHome.shelfLegendCount"):o,g=Tp(e.items,l("readHome.shelfOther")),m=u=>{const h=u.records?lt(u.records):Pp(u.text_count,l),x=$s(u),j=[d(u.title),u.orig?l("readHome.origZhi"):"",x?l("readHome.spineBy",{name:d(x)}):"",u.records?l("readHome.spineRecords",{n:h}):h?l("readHome.spineOnSite",{n:h}):""].filter(Boolean).join(",");return t.jsx("li",{children:t.jsxs("a",{className:"bim-rh-spine",href:c.read(u.id),"data-orig":u.orig?"":void 0,"aria-label":j,title:j,style:{height:Rp(u.title)},children:[t.jsx(Lp,{text:d(u.title)}),h&&t.jsx("span",{className:"bim-rh-n bim-rh-num","data-records":u.records?"":void 0,children:h})]})},u.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:i?d(i):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:g.map(u=>t.jsxs("li",{className:"bim-rh-era",children:[t.jsx("ul",{className:"bim-rh-spines","aria-label":d(u.label),children:u.items.map(m)}),t.jsx("span",{"aria-hidden":"true",children:d(u.label)})]},u.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(u=>t.jsx("span",{children:d(u)},u))]})]})}const u1=4,ni=e=>e>u1+1;function Bp({topic:e,links:n}){const{t:i,convert:o}=ae(),s=nn(n),[a,l]=f.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":ni(e.items.length)?"":void 0,"data-open":a?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",id:d,children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nWorks",{n:lt(e.items.length)})})]}),t.jsx("ul",{className:"bim-rh-rows","aria-labelledby":d,children:e.items.map(c=>{const p=Pp(c.text_count,i),g=$s(c);return t.jsx("li",{children:t.jsxs("a",{href:s.read(c.id),children:[t.jsx("span",{className:"bim-rh-t",children:o(c.title)}),p&&t.jsx("em",{className:"bim-rh-cnt bim-rh-num",children:p}),g&&t.jsx("small",{children:o(g)})]})},c.id)})}),ni(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":a,onClick:()=>l(c=>!c),children:a?i("action.collapse"):i("readHome.allNWorks",{n:e.items.length})})]})}function Op({topics:e,links:n}){const i=e.filter(s=>s.shelf&&s.items.length),o=e.filter(s=>!s.shelf&&s.items.length);return!i.length&&!o.length?null:t.jsxs(t.Fragment,{children:[i.map(s=>t.jsx(Cs,{topic:s,links:n},s.key)),o.length>0&&t.jsx("div",{className:"bim-rh-groups",children:o.map(s=>t.jsx(Bp,{topic:s,links:n},s.key))})]})}function Wp({famous:e,links:n}){const{t:i,convert:o}=ae(),s=nn(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:o(a.title)}),a.authors&&t.jsx("span",{className:"bim-rh-by",children:o(a.authors)}),t.jsx("span",{className:"bim-rh-c bim-rh-num",children:i("readHome.nCopiesCard",{n:a.text_count})})]}),a.systems.map((l,d)=>t.jsxs("div",{className:"bim-rh-lin",role:"group","aria-label":l.label?o(l.label):void 0,children:[l.label&&t.jsx("small",{"aria-hidden":"true",children:o(l.label)}),l.items.map(c=>t.jsx("a",{className:"bim-rh-chip",href:s.read(c.id),title:o([c.title,c.edition].filter(Boolean).join(" · ")),children:o(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:i("readHome.workPageLink",{title:o(a.title)})})})]})},a.work_id??a.title))}):null}function zs({bu:e,unclassified:n,links:i,unclassifiedNote:o}){const{t:s,convert:a}=ae(),l=nn(i);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:lt(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(g=>t.jsx("li",{children:t.jsxs("a",{href:l.node(g.id),children:[t.jsx("span",{children:a(g.label)}),t.jsx("small",{className:"bim-rh-num",children:lt(g.count)}),t.jsx("span",{className:"bim-rh-bar","aria-hidden":"true",style:{"--bimrh-w":`${Math.round(g.count/c*100)}%`}})]})},g.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:lt(n)})}),t.jsx("span",{children:o?a(o):s("readHome.sibuUnclassifiedNote")}),t.jsx("a",{href:l.node("unclassified"),children:s("readHome.viewUnclassified")})]})]})}function Fp({periods:e,unknown:n,links:i}){const{t:o,convert:s,messages:a}=ae(),l=a.readHome.period,d=nn(i),c=e.filter(m=>m.count>0);if(!c.length)return null;const p=c.reduce((m,u)=>m+u.count,0),g=Math.max(...c.map(m=>m.count));return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"bim-rh-band",children:c.map(m=>{const u=m.label?s(m.label):l[m.key]??s(m.key),h=m.count/p,x=o("readHome.periodItem",{label:u,n:lt(m.count)});return t.jsx("li",{style:{flex:`0 0 ${(h*100).toFixed(3)}%`},children:t.jsxs("a",{href:d.period(m.key),"data-k":Ip(m.count,g),"data-narrow":h<Ep?"":void 0,"aria-label":x,title:x,children:[t.jsx("span",{className:"bim-rh-pl",children:u}),t.jsx("span",{className:"bim-rh-pl-s","aria-hidden":"true",children:Array.from(u)[0]}),t.jsx("small",{className:"bim-rh-num",children:lt(m.count)})]})},m.key)})}),t.jsxs("p",{className:"bim-rh-pfoot bim-rh-num",children:[!!n&&t.jsx("span",{children:o("readHome.periodUnknown",{n:lt(n)})}),t.jsx("span",{className:"bim-rh-hover-hint",children:o("readHome.hoverHint")})]})]})}function Hp({authors:e,links:n}){const{t:i,convert:o}=ae(),s=nn(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:[o(a.name),a.dynasty&&t.jsx("span",{children:o(a.dynasty)}),t.jsx("small",{className:"bim-rh-num",children:i("readHome.nPieces",{n:lt(a.count)})})]}),t.jsx("ul",{children:a.items.map(l=>t.jsx("li",{children:t.jsx("a",{href:s.read(l.id),children:o(l.title)})},l.id))}),s.author&&t.jsx("a",{className:"bim-rh-more",href:s.author(a.name),children:i("readHome.authorAll",{name:o(a.name),n:a.count})})]},a.name))}):null}const Dp={picks:"picks",topics:"topics",famous:"classics",sibu:"sibu",period:"period",pieces:"pieces"};function m1({sections:e,links:n,head:i,piecesMoreHref:o,className:s}){const{t:a}=ae(),l=e,d=Dp,c=l.topics.filter(u=>!u.shelf),p={picks:l.picks.length>0,topics:c.some(u=>u.items.length>0),famous:l.famous.length>0,sibu:l.bu.length>0||l.unclassified>0,period:l.periods.some(u=>u.count>0),pieces:l.pieces.authors.length>0},g=Object.keys(d).filter(u=>p[u]),m=u=>a(`readHome.nav.${u}`);return t.jsxs("div",{className:s?`bim-rh ${s}`:"bim-rh",children:[t.jsx("style",{children:_s}),t.jsxs("div",{className:"bim-rh-head",children:[i,t.jsx(Ap,{counts:l.counts})]}),g.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":a("readHome.navLabel"),children:t.jsx("ul",{children:g.map(u=>t.jsx("li",{children:t.jsx("a",{href:`#${d[u]}`,children:m(u)})},u))})}),t.jsxs("div",{className:"bim-rh-main",children:[p.picks&&t.jsx(wt,{id:d.picks,title:m("picks"),sub:a("readHome.picksSub"),children:t.jsx(Mp,{picks:l.picks,links:n})}),p.topics&&t.jsx(wt,{id:d.topics,title:m("topics"),sub:a("readHome.topicsSub"),children:t.jsx(Op,{topics:c,links:n})}),p.famous&&t.jsx(wt,{id:d.famous,title:m("famous"),sub:a("readHome.famousSub"),children:t.jsx(Wp,{famous:l.famous,links:n})}),p.sibu&&t.jsx(wt,{id:d.sibu,title:m("sibu"),sub:a("readHome.sibuSub"),children:t.jsx(zs,{bu:l.bu,unclassified:l.unclassified,links:n})}),p.period&&t.jsx(wt,{id:d.period,title:m("period"),sub:a("readHome.periodSub"),children:t.jsx(Fp,{periods:l.periods,unknown:l.period_unknown,links:n})}),p.pieces&&t.jsx(wt,{id:d.pieces,title:m("pieces"),sub:a("readHome.piecesSub"),more:o?t.jsx("a",{className:"bim-rh-more",href:o,children:a("readHome.piecesMore")}):void 0,children:t.jsx(Hp,{authors:l.pieces.authors,links:n})})]})]})}const g1="(max-width: 1079px)",f1=`${ci}, (pointer: coarse)`,Up=`
|
|
1841
1872
|
/* ── 页首:检索(宿主插槽)+类型签|最近浏览 ── */
|
|
1842
1873
|
.bim-mh-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 16px 48px; align-items: start; padding-top: 8px; }
|
|
1843
1874
|
.bim-mh-q { min-width: 0; }
|
|
@@ -1977,7 +2008,7 @@ ${a1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1977
2008
|
.bim-mh-cc0 { display: inline-block; margin-right: 8px; padding: 1px 7px; font-size: 11.5px; letter-spacing: 0.08em; background: ${r("check-fine-bg")}; color: ${r("check-fine-fg")}; }
|
|
1978
2009
|
|
|
1979
2010
|
/* ── 中屏 ── */
|
|
1980
|
-
@media ${
|
|
2011
|
+
@media ${g1} {
|
|
1981
2012
|
.bim-mh-head, .bim-mh-zhi { grid-template-columns: minmax(0, 1fr); }
|
|
1982
2013
|
.bim-mh-cg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1983
2014
|
.bim-mh-lin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
@@ -1987,7 +2018,7 @@ ${a1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
1987
2018
|
}
|
|
1988
2019
|
|
|
1989
2020
|
/* ── 手机 ── */
|
|
1990
|
-
@media ${
|
|
2021
|
+
@media ${ci} {
|
|
1991
2022
|
.bim-mh-cg, .bim-mh-data { grid-template-columns: minmax(0, 1fr); }
|
|
1992
2023
|
.bim-mh-ge { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
1993
2024
|
.bim-mh-lin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
@@ -2004,8 +2035,8 @@ ${a1.map((e,n)=>`.bim-rh-band a[data-k="${n}"] { background: color-mix(in srgb,
|
|
|
2004
2035
|
.bim-mh-tbl tr > :nth-child(2), .bim-mh-tbl tr > :nth-child(3) { display: none; }
|
|
2005
2036
|
}
|
|
2006
2037
|
|
|
2007
|
-
@media ${
|
|
2038
|
+
@media ${f1} {
|
|
2008
2039
|
.bim-mh-recent li a, .bim-mh-types a, .bim-mh-tl-list a { min-height: 44px; align-items: center; }
|
|
2009
2040
|
.bim-mh-recent-h button { min-height: 44px; }
|
|
2010
2041
|
}
|
|
2011
|
-
`,Hp={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function nn(e){return{...Hp,...e??{}}}function Dp(e,n){if(e.lineage)return e.lineage(n);const i=e.item(n),o=i.indexOf("#"),[s,a]=o<0?[i,""]:[i.slice(0,o),i.slice(o)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function $s(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function Up(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),i=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:i};const o=p=>{const g=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,m=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(g,m),Math.max(g,m)]},s=n.map(o),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,g)=>({p,from:s[g][0],to:s[g][1]})).sort((p,g)=>p.from-g.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:i}}function Bi(e,n=Rn("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function m1(e){return{read:e.item,work:e.item,node:e.node}}function Vp({counts:e,links:n}){const{t:i}=ae(),o=n==null?void 0:n.type;if(!o)return null;const s=[["all",i("metaHome.typeAll"),null],["work",i("metaHome.typeLabel.work"),e.works],["book",i("metaHome.typeLabel.book"),e.books],["collection",i("metaHome.typeLabel.collection"),e.collections],["entity",i("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":i("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:o(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:lt(d)})]})},a))})}function Gp(e,n=5){const[i,o]=f.useState(null);f.useEffect(()=>{let a=!1;const l=en().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>Ao(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=f.useCallback(()=>{Lo(),o([])},[]);return{entries:i,clear:s}}function g1(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):Yp(e.type,n)}function Yp(e,n){return n(`metaHome.typeLabel.${e}`)}function Kp({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ae(),a=nn(i);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:o("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:o("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":o("metaHome.recentItemLabel",{type:l.type?Yp(l.type,o):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?o(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:g1(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function qp(e,n,i,o=!1){return o&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):i(e)}function Xp({rows:e,links:n}){const{t:i,convert:o}=ae(),s=nn(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":i("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[i("metaHome.catalogTitle"),t.jsx("small",{children:i("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:i("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:i("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:i("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=$s(a.imported,a.total),d=a.work_id??a.collection_id,c=o(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:lt(a.total)}),t.jsx("td",{className:"bim-mh-r",children:lt(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:qp(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function Zp({items:e,links:n,label:i}){const{convert:o}=ae();return t.jsx("ul",{className:"bim-rh-rows","aria-label":i?o(i):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:o(s.title)}),s.sub&&t.jsx("small",{children:o(s.sub)})]})},s.id))})}function Jp({works:e,links:n}){const{t:i}=ae(),[o,s]=f.useState(!1);if(!e.length)return null;const a=ti(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":o?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[i("metaHome.relatedTitle"),t.jsx("small",{children:i("metaHome.relatedNote")})]}),t.jsx(Zp,{items:e.map(l=>({id:l.id,title:l.title,sub:ir(l)||void 0})),links:nn(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":o,onClick:()=>s(l=>!l),children:o?i("action.collapse"):i("metaHome.allNWorks",{n:e.length})})]})}const Qp="siku_qige";function f1({group:e,links:n}){const{t:i,convert:o}=ae(),[s,a]=f.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":ti(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(Zp,{items:e.items,links:n,label:e.label}),ti(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?i("action.collapse"):i("metaHome.allNKinds",{n:e.items.length})})]})}function eu({groups:e,links:n}){const{t:i,convert:o}=ae(),s=nn(n);if(!e.length)return null;const a=e.find(c=>c.key===Qp),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:[o(a.label),t.jsx("small",{children:o(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":o(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":o(c.title),title:o(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:o(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:i("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(f1,{group:c,links:s},c.key))})]})}const Il=34,El=13;function Ll(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?Bi(e.birth_year,n):"?"}–${e.death_year!=null?Bi(e.death_year,n):"?"}`}function h1(e,n){const i=n-e,o=i>1200?300:i>400?100:50,s=[];for(let a=Math.ceil(e/o)*o;a<=n;a+=o)s.push(a);return s}function tu({people:e,links:n}){const{t:i,convert:o}=ae(),s=nn(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=Up(e),p=[],g=d.map(u=>{const h=u.left>70,x=h?Math.min(u.left,u.left+u.width-El):u.left;let j=0;for(;p[j]!=null&&p[j]>x;)j++;return p[j]=h?u.left+u.width:u.left+Math.max(u.width,El),{...u,lane:j,end:h}}),m=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[g.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Il+10},children:g.map(u=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":u.end?"":void 0,style:{left:`${u.left}%`,top:u.lane*Il+4,width:`${Math.max(u.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(u.p.id),children:[o(u.p.name),t.jsx("small",{className:"bim-rh-num",children:Ll(u.p,i)})]})]},u.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:h1(a,l).map(u=>t.jsx("span",{style:{left:`${(u-a)/m*100}%`},children:Bi(u,i)},u))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":g.length?void 0:"",children:(g.length?e:c).map(u=>t.jsx("li",{children:t.jsxs("a",{href:s.item(u.id),children:[t.jsx("span",{children:o(u.name)}),t.jsx("small",{className:"bim-rh-num",children:[u.dynasty?o(u.dynasty):"",Ll(u,i)].filter(Boolean).join(" ")})]})},u.id))}),c.length>0&&g.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(u=>u.name).join("、"))})})]})}const x1=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 nu({works:e,links:n}){const{t:i,convert:o}=ae(),s=nn(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=ir(a);return t.jsx("li",{children:t.jsxs("a",{href:Dp(s,a.id),children:[x1,t.jsx("b",{children:o(a.title)}),l&&t.jsx("small",{children:o(l)}),t.jsx("span",{children:i("metaHome.viewLineage")})]})},a.id)})}):null}function iu({sites:e}){const{t:n,convert:i}=ae(),o=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!o.includes(a));return e.length?t.jsxs(t.Fragment,{children:[o.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:o.map(a=>{const l=$s(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:i(a.name)}):t.jsx("span",{children:i(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${lt(a.imported)} / ${lt(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:qp(a.status,n,i,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:i(s.map(a=>a.name).join("、"))})})]}):null}const Al=["extant","partially_extant","lost","unknown"];function ru({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=ae(),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=Al.some(p=>{var g;return(((g=e.loss)==null?void 0:g[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,g])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:lt(p)}),t.jsx("span",{children:g})]},g))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Al.map(p=>{var u;const g=((u=e.loss)==null?void 0:u[p])??0,m=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&g>0?a("metaHome.lossCount",{n:lt(g),note:m}):m})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC BY-SA 4.0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),o?t.jsx("a",{href:o,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),i&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:i})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const ou={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function b1({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:g}){var v,C;const{t:m}=ae(),u=e,h=nn(n),x=m1(h),j=ou,b=Gp(o),$={zhi:!!((v=u.shelf)!=null&&v.items.length)||u.catalog_progress.length>0||u.related_catalogs.length>0,sibu:u.bu.length>0||u.unclassified>0,cong:u.collection_groups.length>0,people:u.bibliographers.length>0,lineage:u.lineage.length>0,sites:u.sites.length>0,data:!0},y=Object.keys(j).filter(S=>$[S]),k=S=>m(`metaHome.nav.${S}`),w=(S,_)=>S?t.jsx("a",{className:"bim-rh-more",href:S,children:_}):void 0;return t.jsxs("div",{className:g?`bim-rh bim-mh ${g}`:"bim-rh bim-mh",children:[t.jsx("style",{children:ks+Fp}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(Vp,{counts:u.counts,links:n})]}),o&&t.jsx(Kp,{entries:b.entries,onClear:b.clear,links:n})]}),y.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":m("metaHome.navLabel"),children:t.jsx("ul",{children:y.map(S=>t.jsx("li",{children:t.jsx("a",{href:`#${j[S]}`,children:k(S)})},S))})}),t.jsxs("div",{className:"bim-rh-main",children:[$.zhi&&t.jsxs(vt,{id:j.zhi,title:k("zhi"),sub:m("metaHome.zhiSub"),children:[u.shelf&&u.shelf.items.length>0&&t.jsx(Ss,{topic:{key:"shelf",label:u.shelf.label,shelf:!0,items:u.shelf.items},links:x,showTitle:!1,legendCount:u.shelf.items.some(S=>S.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(u.catalog_progress.length>0||u.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(C=u.shelf)!=null&&C.items.length?void 0:{marginTop:0},children:[t.jsx(Xp,{rows:u.catalog_progress,links:n}),t.jsx(Jp,{works:u.related_catalogs,links:n})]})]}),$.sibu&&t.jsx(vt,{id:j.sibu,title:k("sibu"),sub:m("metaHome.sibuSub"),more:w(s,m("metaHome.toCatalog")),children:t.jsx(_s,{bu:u.bu,unclassified:u.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),$.cong&&t.jsx(vt,{id:j.cong,title:k("cong"),sub:m("metaHome.congSub"),more:w(a,m("metaHome.allNKindsMore",{n:lt(u.counts.collections)})),children:t.jsx(eu,{groups:u.collection_groups,links:n})}),$.people&&t.jsx(vt,{id:j.people,title:k("people"),sub:m("metaHome.peopleSub"),more:w(l,m("metaHome.allNPeopleMore",{n:lt(u.counts.entities)})),children:t.jsx(tu,{people:u.bibliographers,links:n})}),$.lineage&&t.jsx(vt,{id:j.lineage,title:k("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(nu,{works:u.lineage,links:n})}),$.sites&&t.jsx(vt,{id:j.sites,title:k("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(iu,{sites:u.sites})}),t.jsx(vt,{id:j.data,title:k("data"),sub:m("metaHome.dataSub"),children:t.jsx(ru,{stats:u.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const su=["_related","_catalogs","_collections","_members","_children"],y1=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),ho=e=>y1(e)&&!!e.h;function j1(e){return e?su.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(ho)}):!1}function v1(e,n){const i={...e};if(!n)return i;for(const o of su){const s=e[o];!Array.isArray(s)||!s.some(ho)||(i[o]=s.map(a=>{var c;if(!ho(a)||typeof a.title=="string"&&a.title)return a;const l=a.id??a.bid,d=l?(c=n[l])==null?void 0:c.title:void 0;return d?{...a,title:d}:a}))}return i}function k1(e){let n=null;const i=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null);return new Proxy(e,{get(o,s){if(s==="getItem")return async l=>{const d=await o.getItem(l);return d&&v1(d,j1(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const xo=({style:e})=>{const n=f.useContext(Bt),{t:i}=ae();if(!n)return null;const{locale:o,setLocale:s}=n,a=o==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:i(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 ${r("border")}`,borderRadius:"4px",background:r("bg"),color:r("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?r("primary"):void 0,fontWeight:a?700:400},children:i("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:r("primary"),fontWeight:a?400:700},children:i("common.localeShortHans")})]})},bo=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=ae(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:o,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i+8,height:i+8,borderRadius:4,color:r("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=r("fg")},onMouseLeave:d=>{d.currentTarget.style.color=r("desc-fg")},children:t.jsx("svg",{width:i,height:i,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 Fr(e){const n=e.text_count;return typeof n=="number"&&n>0}function Hr(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function w1(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const S1=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:g,onLineageCollectionChange:m,initialPage:u=1,selectedLineageNodeId:h,onNavigate:x,onBack:j,backLabel:b,renderLink:$,assetBase:y,enrichDetail:k,getSourceLink:w,readLink:v,railTop:C,extraTabs:S=[],showFeedbackTab:_=!0,feedbackApiUrl:R,height:z,footerExtra:N,hideHeaderControls:I=!1,className:B,style:O})=>{const A=f.useMemo(()=>k1(n),[n]),W=We(),{t:G,convert:oe}=ae(),[se]=f.useState(()=>{if(!w1(e,i))return null;const F={...i},pe=o??Hr(e,F);return k&&k(pe,F),{id:e,entry:pe,detail:F}}),[Y,de]=f.useState((se==null?void 0:se.entry)??null),[ne,ue]=f.useState((se==null?void 0:se.detail)??null),[ke,Ae]=f.useState(!se),[he,$e]=f.useState(!1),[L,Me]=f.useState([]),[q,le]=f.useState(!1),[ge,H]=f.useState(null),[Z,Ne]=f.useState(null),[ze,Fe]=f.useState(null),[P,ie]=f.useState(!1),Q=f.useRef(null),X=f.useRef(0),[we,He]=f.useState(null),Ke=l!==void 0?l:we,Qe=f.useCallback(F=>{d?d(F):He(F)},[d]),U=f.useCallback(async F=>{if(!A.getCollectionCatalogs&&!A.getCollectionCatalog){Me([]);return}le(!0);try{if(A.getCollectionCatalogs)Me(await A.getCollectionCatalogs(F)||[]);else if(A.getCollectionCatalog){const pe=await A.getCollectionCatalog(F);Me(pe?[{resource_id:"",data:pe}]:[])}}catch{Me([])}finally{le(!1)}},[A]),me=f.useCallback(async F=>{var pe,ce;if(!A.getTextManifest||!A.getTextIndex){H(null),Ne(F);return}try{const Oe=Ee.pickTextVersion(await A.getTextManifest(F)),Ce=Oe?await A.getTextIndex(F,Oe.key):null;H(Ce&&Ce.chapters.length>0?{chapters:Ce.chapters.map(re=>({n:re.n,title:re.title,file:re.file})),source:{name:((pe=Ce.source)==null?void 0:pe.name)??(Oe==null?void 0:Oe.source_name),license:((ce=Ce.source)==null?void 0:ce.license)??(Oe==null?void 0:Oe.license)??void 0}}:null)}catch{H(null)}finally{Ne(F)}},[A]),Re=f.useCallback(async(F,pe)=>{const ce=++X.current,Oe=()=>ce!==X.current;ie(!0);try{if(A.getLineageGraph){const Te=await A.getLineageGraph(F);if(Oe())return;Te&&Fe(Te)}const Ce=pe.version_graph;if(!Ce||!Ce.enabled){ze||Fe(null),Q.current=null;return}const re=Ro(pe),ve=(await tr(re,er,async Te=>{try{return await A.getItem(Te)}catch{return null}},Oe)).filter(Boolean);if(Oe())return;Q.current={work:pe,books:ve};const Pe=g??Ce.default_collection??(Ce.core_books&&Ce.core_books.length>0?"core":"all"),xe=Pe==="core"&&Array.isArray(Ce.core_books)&&Ce.core_books.length>0?"core":Pe??"all";Fe(Ri(pe,ve,xe))}catch{if(Oe())return;Fe(null),Q.current=null}finally{Oe()||ie(!1)}},[A]),D=f.useRef({initialDetail:i,initialEntry:o});D.current={initialDetail:i,initialEntry:o},f.useEffect(()=>{let F=!1;X.current++,ie(!1);const pe=re=>{re.type==="collection"?U(e):re.type==="work"?(re.version_graph||A.getLineageGraph)&&Re(e,re):re.type==="book"&&Fr(re)&&me(e)},ce=D.current;let Oe=null;if(se&&se.id===e)Oe=se;else if(ce.initialDetail&&ce.initialDetail.id===e){const re={...ce.initialDetail},ye=ce.initialEntry??Hr(e,re);k&&k(ye,re),Oe={entry:ye,detail:re}}return Oe?($e(!1),Me(re=>re.length?[]:re),H(null),Fe(null),Q.current=null,de(Oe.entry),ue(Oe.detail),Ae(!1),pe(Oe.detail),()=>{F=!0}):((async()=>{Ae(!0),$e(!1),de(null),ue(null),Me([]),H(null),Fe(null),Q.current=null;try{const re=await A.getItem(e);if(F)return;if(!re){$e(!0);return}const ye=re;let ve=null;if(A.getEntry&&(ve=await A.getEntry(e),F))return;ve||(ve=Hr(e,ye)),k&&k(ve,ye),de(ve),ue(ye),pe(ye)}catch{F||$e(!0)}finally{F||Ae(!1)}})(),()=>{F=!0})},[e,A,se,k,U,Re,me]),f.useEffect(()=>{const F=Q.current;!F||!g||Fe(Ri(F.work,F.books,g))},[g]);const je=[];if(ne){if(je.push({key:"basic",label:W.detailTab.basicInfo}),ne.type==="collection"){q&&L.length===0&&je.push({key:"catalog:loading",label:`${W.detailTab.catalog}…`});for(const F of L)je.push({key:`catalog:${F.resource_id}`,label:F.short_name?`${oe(F.short_name)}${W.detailTab.catalogSuffix}`:W.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&je.push({key:s,label:W.detailTab.fullText}),ne.type==="work"&&(ze||P)&&je.push({key:"lineage",label:P?`${W.detailTab.lineage}…`:W.detailTab.lineage});for(const F of S)(F.position??"before-feedback")==="before-feedback"&&F.shouldShow(ne)&&je.push({key:F.key,label:F.label});_&&s==="feedback"&&je.push({key:"feedback",label:W.detailTab.feedback});for(const F of S)F.position==="after-feedback"&&F.shouldShow(ne)&&je.push({key:F.key,label:F.label})}f.useEffect(()=>{if(s!=="emendated"||!ne)return;a("basic");const F=setTimeout(()=>{var pe;(pe=document.getElementById("studies"))==null||pe.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(F)},[s,ne,a]);const te=Y&&ne&&w?w({activeTab:s,activeJuan:Ke,entry:Y,detail:ne}):null,_e=f.useMemo(()=>{var Ce,re,ye,ve,Pe;if(!ne)return null;const pe=(ne.authors??[]).map(xe=>{const Te=To(xe.role);return`${xe.dynasty?`〔${oe(xe.dynasty)}〕`:""}${oe(xe.name)}${Te?` ${oe(Te)}`:""}`}).join(" · ");let ce=!1;try{ce=Ee.extractStatus(ne.id)==="draft"}catch{}if(ne.type==="book"){const xe=ne;return{title:oe(xe.title),subtitle:xe.edition?oe(xe.edition):pe||void 0,aside:[ce?W.status.draft:"",pe&&xe.edition?pe:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(ne.type==="collection"){const xe=ne;return{title:oe(xe.title),subtitle:oe(Kt(xe,W.unit.juan))||void 0,aside:[(Ce=xe.publication_info)==null?void 0:Ce.year,ce?W.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:pe||void 0}}if(ne.type==="entity"){const xe=ne,Te=tt=>tt==null?"":tt<0?G("detail.bce",{n:-tt}):String(tt),Ze=((re=xe.dates)==null?void 0:re.birth)!=null||((ye=xe.dates)==null?void 0:ye.death)!=null?`${Te(((ve=xe.dates)==null?void 0:ve.birth)??void 0)||"?"}—${Te(((Pe=xe.dates)==null?void 0:Pe.death)??void 0)||"?"}`:"";return{title:oe(xe.primary_name||xe.title),subtitle:[xe.dynasty?`〔${oe(xe.dynasty)}〕`:"",Ze].filter(Boolean).join(" ")||void 0,aside:ce?W.status.draft:void 0,secondLine:void 0}}const Oe=oe(Kt(ne,W.unit.juan));return{title:oe(ne.title),subtitle:[Oe,pe].filter(Boolean).join(" · ")||void 0,aside:[$1(W,ne.subtype),ce?W.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[ne,oe,W,G]),Be=ne&&Fr(ne)?"text":null,Ge=()=>{Qe(null),a("fulltext")};let Ye=null;if(ne&&v){const F=v({detail:ne,kind:Be});F&&(Ye=t.jsx(Qr,{href:F}))}else Be&&(Ye=t.jsx(Qr,{onClick:Ge}));const it=F=>{if(!ne)return null;const pe=F.replace(/\.[^.]+$/,"");if(v){const ce=v({detail:ne,kind:Be,juan:pe});return ce?{href:ce}:null}return{onClick:()=>{Qe(pe),a("fulltext")}}},st=new Set(S.map(F=>F.key)),T=je.filter(F=>F.key.startsWith("catalog:")&&F.key!=="catalog:loading"||F.key==="lineage"&&!!ze&&!P||st.has(F.key)).map(F=>({key:F.key,label:F.label,onClick:()=>a(F.key)})),fe=()=>{var F;return ne?ne.type==="work"?t.jsx(cp,{data:ne,transport:A,onNavigate:x,renderLink:$,readAction:Ye,railTop:C,railLinks:T}):ne.type==="book"?t.jsx(mp,{data:ne,transport:A,onNavigate:x,renderLink:$,readAction:Ye,fullText:ge,fullTextPending:Fr(ne)&&!!A.getTextManifest&&Z!==ne.id,chapterLink:it,railTop:C,railLinks:T}):ne.type==="collection"?t.jsx(gp,{data:ne,catalog:(F=L[0])==null?void 0:F.data,transport:A,onNavigate:x,renderLink:$,readAction:Ye,railTop:C,railLinks:T,catalogAction:L.length>0?t.jsxs("a",{href:"#catalog",onClick:pe=>{pe.preventDefault(),a(`catalog:${L[0].resource_id}`)},children:[oe(W.detailTab.collectionCatalog)," →"]}):null}):t.jsx(hp,{data:ne,transport:A,onNavigate:x,renderLink:$,railTop:C,railLinks:T,assetBase:y}):null},be=()=>{var pe,ce,Oe;if(!Y||!ne)return null;if(s==="basic"||s==="emendated")return fe();if(typeof s=="string"&&s.startsWith("catalog:")){const Ce=(pe=L.find(re=>`catalog:${re.resource_id}`===s))==null?void 0:pe.data;return t.jsx(Po,{data:Ce,onNavigate:x,renderLink:$})}if(s==="collated"||s==="fulltext")return t.jsx(us,{id:e,transport:A,chapter:Ke,onLocationChange:Ce=>Qe(Ce.chapter),onNavigate:x});if(s==="lineage"){if(!ze)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:G(P?"detail.loading":"detail.noLineageGraph")});const Ce=ne.type==="work"?ne:null;return t.jsx(bs,{graph:ze,renderLink:$,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:h,collection:g??((ce=Ce==null?void 0:Ce.version_graph)==null?void 0:ce.default_collection),onCollectionChange:m,collectionsAvailable:(Oe=Ce==null?void 0:Ce.version_graph)==null?void 0:Oe.collections,collectionCounts:(()=>{var Pe,xe,Te,Ze,tt,Ve,ut;if(!Ce)return;const re={},ye=((Pe=Q.current)==null?void 0:Pe.books)??[];re.all=(((xe=Ce._books)==null?void 0:xe.length)??0)-(((Ze=(Te=Ce.version_graph)==null?void 0:Te.excluded_books)==null?void 0:Ze.length)??0);const ve=(tt=Ce.version_graph)==null?void 0:tt.collections;if(ve)for(const qe of Object.keys(ve))re[qe]=Ri(Ce,ye,qe).nodes.filter(ct=>ct.kind==="book"&&!ct.bridge).length;return re.core==null&&((ut=(Ve=Ce.version_graph)==null?void 0:Ve.core_books)!=null&&ut.length)&&(re.core=Ce.version_graph.core_books.length),re})()})}if(s==="feedback"&&_)return t.jsx(op,{resourceId:e,apiUrl:R});const F=S.find(Ce=>Ce.key===s);return F?F.render({detail:ne,entry:Y,transport:A,onNavigate:x}):null};if(ke)return t.jsx(Yn,{style:{minHeight:z,...O},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((F,pe)=>t.jsx("div",{style:{height:pe===1?40:16,width:F,opacity:.35,background:r("rule")}},pe))})});if(he||!ne||!Y||!_e)return t.jsx(Yn,{style:{minHeight:z,...O},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:G("detail.notFound")})});const Le=s==="basic"||s==="emendated",V=[{label:b??W.detailTab.backToIndex,onClick:j}];if(ne.type==="book"&&ne.work_id){const F=ne.work_id;V.push({label:W.indexType.work,id:F,onClick:()=>x==null?void 0:x(F)})}V.push({label:W.indexType[ne.type]});const M=s==="collated"||s==="fulltext",J=typeof N=="string"?W.status[N.trim()]??N:N,Se=t.jsx(od,{left:t.jsxs(t.Fragment,{children:[J,J?" · ":"",t.jsx(_1,{id:ne.id,label:W.label.id,copied:W.action.copied,copyLabel:W.action.copy})]}),right:t.jsxs(t.Fragment,{children:[_&&!Le&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:W.detailTab.submitVersion}),te&&t.jsx("a",{href:te.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:W.detailTab.dataLicense})]})});return Le?t.jsx("div",{className:B,children:t.jsxs(Yn,{grid:!0,style:{minHeight:z,...O},children:[t.jsx(eo,{breadcrumb:t.jsx(to,{items:V}),actions:t.jsxs(t.Fragment,{children:[!I&&t.jsx(xo,{style:{border:"none",background:"transparent"}}),!I&&te&&t.jsx(bo,{...te})]})}),fe(),Se]})}):t.jsx("div",{className:B,children:t.jsxs(Yn,{wide:M,style:{minHeight:z,...O},children:[t.jsx(eo,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(Do,{char:"籍"}),t.jsx(to,{items:V})]}),actions:t.jsxs(t.Fragment,{children:[!I&&t.jsx(xo,{}),_&&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:r("meta-fg")},children:W.detailTab.feedback}),!I&&te&&t.jsx(bo,{...te})]})}),t.jsx(Xc,{..._e,aside:M?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:r("accent"),borderBottom:`1px solid ${r("rule")}`},children:[G("detail.workInfo")," →"]}):_e.aside}),!M&&je.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:je.map(F=>t.jsx(Zc,{label:F.label,active:F.key===s||Le&&F.key==="basic",onClick:()=>a(F.key)},F.key))}),t.jsx("div",{style:{marginTop:!M&&je.length>1?8:0},children:be()}),Se]})})};function _1({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=f.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?i:o,"aria-label":s?i:o,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:r("aux-fg")},children:s?"✓":"⧉"})]})}function $1(e,n){return n?e.workSubtype[n]??n:""}const au=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],rr="zhusha",or="bim-theme";function lu(e){return e==="zhusha"||e==="indigo"||e==="ink"}function sr(e){return lu(e)?e:rr}function C1(){try{return sr(window.localStorage.getItem(or))}catch{return rr}}function cu(e){try{window.localStorage.setItem(or,e)}catch{}}function du(e){const n=sr(e);return document.documentElement.setAttribute("data-theme",n),n}function pu(){return sr(document.documentElement.getAttribute("data-theme"))}const z1=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Cs="airy",ar="bim-layout";function uu(e){return e==="airy"||e==="boxed"}function lr(e){return uu(e)?e:Cs}function N1(){try{return lr(window.localStorage.getItem(ar))}catch{return Cs}}function T1(e){try{window.localStorage.setItem(ar,e)}catch{}}function R1(e){const n=lr(e);return document.documentElement.setAttribute("data-layout",n),n}function I1(){return lr(document.documentElement.getAttribute("data-layout"))}const E1=`try{var t=localStorage.getItem(${JSON.stringify(or)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(ar)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,L1={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},A1=({onChange:e,style:n})=>{const{t:i}=ae(),[o,s]=f.useState(rr);f.useEffect(()=>{s(pu())},[]);const a=l=>{s(du(l)),cu(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:au.map(l=>{const d=o===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":i(`common.theme.${l.name}`),title:i(`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:r(L1[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=Ee.BidLink;exports.BookIndexError=Ee.BookIndexError;exports.BookIndexManager=Ee.BookIndexManager;exports.BookIndexStorage=Ee.BookIndexStorage;exports.BundleStorage=Ee.BundleStorage;exports.ConfigError=Ee.ConfigError;exports.GithubStorage=Ee.GithubStorage;exports.IdGenerationError=Ee.IdGenerationError;exports.IdGenerator=Ee.IdGenerator;exports.LocalStorage=Ee.LocalStorage;exports.MigrationError=Ee.MigrationError;exports.StorageError=Ee.StorageError;exports.VARIANT_CHARS=Ee.VARIANT_CHARS;exports.base36Decode=Ee.base36Decode;exports.base36Encode=Ee.base36Encode;exports.base58Decode=Ee.base58Decode;exports.buildId=Ee.buildId;exports.buildPromotionMap=Ee.buildPromotionMap;exports.cleanName=Ee.cleanName;exports.decodeId=Ee.decodeId;exports.decodeIdString=Ee.decodeIdString;exports.encodeId=Ee.encodeId;exports.extractIdFromUrl=Ee.extractIdFromUrl;exports.extractStatus=Ee.extractStatus;exports.extractType=Ee.extractType;exports.isChapterSegment=Ee.isChapterSegment;exports.isTextKey=Ee.isTextKey;exports.matchChapterAcrossVersions=Ee.matchChapterAcrossVersions;exports.normalizeCatalog=Ee.normalizeCatalog;exports.normalizeVariants=Ee.normalizeVariants;exports.parseId=Ee.parseId;exports.pickTextVersion=Ee.pickTextVersion;exports.shardOf=Ee.shardOf;exports.smartDecode=Ee.smartDecode;exports.textVersionLabel=Ee.textVersionLabel;exports.validateResource=Ee.validateResource;exports.VARIANT_SUPPLEMENT=Ml.VARIANT_SUPPLEMENT;exports.Badge=Pi;exports.BidUrlProvider=Wu;exports.BookDetailLayout=S1;exports.BookPage=mp;exports.Breadcrumb=to;exports.CATALOG_ALL_ID=Vt;exports.CATALOG_CSS=xp;exports.CATALOG_NARROW_QUERY=ys;exports.CATALOG_PAGE_SIZE=js;exports.CATALOG_UNCLASSIFIED_ID=dn;exports.CLASSIFICATIONS=Ki;exports.COMMON_TRADITIONAL_CHARS=Yl;exports.CardFoot=oi;exports.CatalogPage=r1;exports.CatalogPager=Sp;exports.CatalogTree=yp;exports.CheckFilter=Yc;exports.Chip=Jc;exports.ChipWall=Uf;exports.CollectionCatalog=Po;exports.CollectionPage=gp;exports.CreateEntityDialog=Zd;exports.DEFAULT_LAYOUT=Cs;exports.DEFAULT_META_HOME_LINKS=Hp;exports.DEFAULT_READER_PREFS=Oo;exports.DEFAULT_READ_HOME_LINKS=$p;exports.DEFAULT_THEME=rr;exports.DETAIL_CSS=qc;exports.DYNASTY_GROUPS=Yi;exports.Dash=Xf;exports.DataTable=Gf;exports.DetailFooter=od;exports.DetailGrid=ii;exports.DetailHeader=Xc;exports.EMPTY_FILTERS=Gi;exports.ENTITY_TEXT_CSS=os;exports.EmendatedBySection=Sc;exports.EmptyNote=ih;exports.EntityDetail=yc;exports.EntityMark=as;exports.EntityPage=hp;exports.EntityPickerDialog=Qd;exports.EntitySelector=Xd;exports.EntityText=$x;exports.ExpandRow=Zf;exports.ExtLink=rh;exports.FEEDBACK_FAB_OFFSET_VAR=uo;exports.FILTER_SUPPORT=dc;exports.FONT_SIZE_STEPS=Ut;exports.FactList=Wf;exports.FeedbackButton=Wy;exports.FeedbackDialog=ip;exports.FeedbackForm=rp;exports.FeedbackList=ms;exports.FeedbackTab=op;exports.FilterChip=Zc;exports.FormInput=_t;exports.FormTextArea=un;exports.GUJI_MARKDOWN_FIELD=_f;exports.GUJI_TABLE_NOTATION=sd;exports.GlyphBadge=Do;exports.GujiInteractiveReader=Rb;exports.GujiTable=Go;exports.GujiTextViewer=cs;exports.GujiWarpCanvas=rs;exports.HomePage=co;exports.ImagePanel=qr;exports.IndexApp=Tb;exports.IndexBrowser=Yr;exports.IndexDetail=Mo;exports.IndexEditor=ep;exports.IndexView=$y;exports.IntroGrid=Of;exports.LAYOUTS=z1;exports.LAYOUT_STORAGE_KEY=ar;exports.LOSS_OPTIONS=cc;exports.LocaleContext=Bt;exports.LocaleProvider=gm;exports.LocaleToggle=xo;exports.META_HOME_CSS=Fp;exports.META_HOME_SECTION_IDS=ou;exports.MetaCatalogTable=Xp;exports.MetaCollectionGroups=eu;exports.MetaDataLicense=ru;exports.MetaHomeView=b1;exports.MetaLine=ft;exports.MetaLineageCards=nu;exports.MetaOnlineSites=iu;exports.MetaPeopleTimeline=tu;exports.MetaRecentPanel=Kp;exports.MetaRelatedCatalogs=Jp;exports.MetaTypeChips=Vp;exports.ModeIndicator=ql;exports.MoreButton=Df;exports.MoreLink=Fo;exports.PAGE_MAX_WIDTH=Ci;exports.PERIOD_NARROW_SHARE=Tp;exports.PageFrame=Yn;exports.Quote=Qf;exports.READER_CSS=Tc;exports.READ_HOME_CSS=ks;exports.READ_HOME_NARROW_QUERY=li;exports.READ_HOME_SECTION_IDS=Wp;exports.READ_PERIOD_LABELS=l1;exports.RECENT_IDS_STORAGE_KEY=$n;exports.ROLE_CLASS_ORDER=ic;exports.ReadButton=Qr;exports.ReadFamousWorks=Pp;exports.ReadHomeView=d1;exports.ReadPeriodBand=Bp;exports.ReadPicks=Ep;exports.ReadPieces=Op;exports.ReadSection=vt;exports.ReadShelf=Ss;exports.ReadSibu=_s;exports.ReadStats=Ip;exports.ReadTopicGroup=Ap;exports.ReadTopics=Mp;exports.ReaderMdText=Xo;exports.ReaderShell=Bc;exports.ReaderToc=Rc;exports.RelationPanel=Kd;exports.RepoSourceLink=bo;exports.ResourceEditor=Dr;exports.ResourceGroup=eh;exports.ResourceLine=th;exports.ResourceList=_o;exports.ResourceRow=id;exports.SEARCH_VIEW_STORAGE_KEY=Eo;exports.SEVEN_PAVILIONS_KEY=Qp;exports.SNIPPET_MARK_END=Ol;exports.SNIPPET_MARK_START=Bl;exports.SORTABLE_TYPES=lc;exports.SearchInput=Zl;exports.SearchResults=hc;exports.Sec=ht;exports.Section=Rt;exports.SectionHead=Ff;exports.SideList=pn;exports.SmartBidInput=Ti;exports.SourceEditor=Vd;exports.StripWarpRenderer=io;exports.SummaryCard=ri;exports.THEMES=au;exports.THEME_INIT_SCRIPT=E1;exports.THEME_STORAGE_KEY=or;exports.TRADITIONAL_ALLOWLIST=Kl;exports.TabFilter=Xi;exports.TableHead=Yf;exports.TableRow=Kf;exports.TagRow=rd;exports.TagRows=nh;exports.TextButton=Hf;exports.TextReader=us;exports.ThemeToggle=A1;exports.TopStrip=eo;exports.VersionLineageGraph=up;exports.VersionLineageList=pp;exports.VersionLineageView=bs;exports.VolumeChips=Vf;exports.VolumeLinks=Uo;exports.WorkCard=kp;exports.WorkCardGrid=_p;exports.WorkCatalog=Vb;exports.WorkPage=cp;exports.WorkRow=wp;exports.adaptCharCord=Hb;exports.adaptEntityJson=bd;exports.adaptFig=Ub;exports.adaptNorm=Ud;exports.adaptNormDetailed=Dd;exports.adaptPunctJson=Ab;exports.applyLayout=R1;exports.applyTheme=du;exports.authorsLine=ir;exports.bookIndexUriToId=ei;exports.bookMarkingOf=qo;exports.bucketResources=zo;exports.buildCatalogTree=q0;exports.buildCollectionTable=sc;exports.buildLineageGraph=Ri;exports.buildMeiliFilter=Qm;exports.buildPageUrl=wo;exports.buildParagraphBlocks=md;exports.buildVersionRow=tc;exports.buildVersionTable=nc;exports.canParagraphize=Ai;exports.catalogNodeIdOf=Y0;exports.catalogNodeIdsOf=K0;exports.catalogPageCount=Q0;exports.catalogTotal=vs;exports.classificationPath=ai;exports.clearAllRecentIds=Lo;exports.compareCatalogCards=J0;exports.computeVersionPartition=Um;exports.countActiveFilters=qi;exports.createTextApi=$c;exports.currentLayout=I1;exports.currentTheme=pu;exports.defaultEntityHref=zd;exports.defaultWorkLink=jp;exports.deriveDating=Pm;exports.deriveEditionType=ac;exports.deriveEra=ni;exports.deriveYear=Di;exports.deriveYearRange=Co;exports.detailToEditor=np;exports.detectGenre=Ji;exports.displayAuthorRole=To;exports.editorToDetail=_y;exports.eraRank=Vr;exports.filtersFromParams=eg;exports.filtersToParams=Li;exports.findCatalogPath=wn;exports.findTraditionalChars=xm;exports.firstAuthorText=ws;exports.flattenTitles=no;exports.flattenToc=Pc;exports.fmtCount=lt;exports.formatHitCount=Si;exports.formatTemplate=$t;exports.formatVolumeRange=Vi;exports.getDisplayNameFromUrl=zn;exports.getMessages=Tn;exports.getStartPage=ko;exports.getT=Rn;exports.getTypeGroupKey=jo;exports.groupRelatedWorks=Bm;exports.gujiInlineToPlain=Vc;exports.hasActiveFilters=pc;exports.hasGujiMarkdownV02=$f;exports.hasGujiTableNotation=oh;exports.hasSearchOptions=Xm;exports.headingKey=ps;exports.headingsFromPunct=Ad;exports.iiifVolumeOf=Mb;exports.isCountedChar=Zo;exports.isDuiduChapter=Ni;exports.isLayoutName=uu;exports.isThemeName=lu;exports.lineageHref=Dp;exports.loadRecentIds=en;exports.measureText=Kt;exports.mergeVolumeResources=vo;exports.nestHeadings=Pd;exports.normalizeEra=gt;exports.normalizeLayout=lr;exports.normalizeRole=No;exports.normalizeTheme=sr;exports.normalizeVolumeIndex=qn;exports.normalizeVolumes=Hl;exports.numberToChinese=En;exports.paginationItems=bp;exports.parseChineseNumber=Ii;exports.parseGujiInline=Uc;exports.parseGujiTable=ld;exports.parseHeadingKey=Md;exports.parseSourceString=Gd;exports.pct=$s;exports.periodLevel=Np;exports.pickReaderVersion=Mc;exports.readStoredLayout=N1;exports.readStoredTheme=C1;exports.readerVersionOptionLabel=Zr;exports.remapPlainOffsets=yd;exports.removeRecentId=xc;exports.renderFullTextBody=fh;exports.renderProperNames=hd;exports.renderReaderInline=Qi;exports.resolveRecentEntry=Ao;exports.resourceHref=Nn;exports.resourceNote=Ui;exports.resultTabFromParam=dg;exports.resultTabToParam=pg;exports.roleFacets=rc;exports.rowNo=qf;exports.sameFilters=tg;exports.sanitizeHeadings=lo;exports.saveRecentId=Gr;exports.segmentEntities=jd;exports.shelfColumns=Cp;exports.sortFor=Zm;exports.sortYear=Ei;exports.spineHeight=zp;exports.splitFullTextTables=Vo;exports.splitHighlightSnippet=yo;exports.splitTableRow=ad;exports.storeLayout=T1;exports.storeTheme=cu;exports.stringifySources=Yd;exports.summaryFromEntry=_d;exports.summaryFromItem=Sd;exports.timelineLayout=Up;exports.toCatalogWorkCard=Z0;exports.transportSummaryLoader=$d;exports.typeSupportsFilters=uc;exports.useBidUrl=mt;exports.useChapterWarpData=Ld;exports.useConvert=Ue;exports.useEntitySummaryLoader=ss;exports.useI18n=ae;exports.useReaderPrefs=Ac;exports.useRecentEntries=Gp;exports.useT=We;exports.validateLineageGraph=p0;exports.volumeStats=Oi;exports.withDefaultLinks=tn;exports.withMetaLinks=nn;exports.yearText=Bi;
|
|
2042
|
+
`,Vp={item:e=>`/item/${encodeURIComponent(e)}`,node:e=>`/catalog?node=${encodeURIComponent(e)}`};function rn(e){return{...Vp,...e??{}}}function Gp(e,n){if(e.lineage)return e.lineage(n);const i=e.item(n),o=i.indexOf("#"),[s,a]=o<0?[i,""]:[i.slice(0,o),i.slice(o)];return`${s}${s.includes("?")?"&":"?"}tab=lineage${a}`}function Ns(e,n){return!n||n<=0?0:Math.max(0,Math.min(100,Math.round(e/n*100)))}function Yp(e){const n=e.filter(p=>Number.isFinite(p.birth_year)||Number.isFinite(p.death_year)),i=e.filter(p=>!n.includes(p));if(!n.length)return{min:0,max:0,placed:[],missing:i};const o=p=>{const g=Number.isFinite(p.birth_year)?p.birth_year:p.death_year-50,m=Number.isFinite(p.death_year)?p.death_year:p.birth_year+50;return[Math.min(g,m),Math.max(g,m)]},s=n.map(o),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,g)=>({p,from:s[g][0],to:s[g][1]})).sort((p,g)=>p.from-g.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:i}}function Wi(e,n=In("zh-Hant")){return e<0?n("metaHome.yearBC",{n:-e}):String(e)}function h1(e){return{read:e.item,work:e.item,node:e.node}}function Kp({counts:e,links:n}){const{t:i}=ae(),o=n==null?void 0:n.type;if(!o)return null;const s=[["all",i("metaHome.typeAll"),null],["work",i("metaHome.typeLabel.work"),e.works],["book",i("metaHome.typeLabel.book"),e.books],["collection",i("metaHome.typeLabel.collection"),e.collections],["entity",i("metaHome.typeLabel.entity"),e.entities]];return t.jsx("ul",{className:"bim-mh-types bim-rh-num","aria-label":i("metaHome.typeChipsLabel"),children:s.map(([a,l,d])=>t.jsx("li",{children:t.jsxs("a",{href:o(a),children:[t.jsx("b",{children:l}),d!=null&&d>0&&t.jsx("small",{children:lt(d)})]})},a))})}function qp(e,n=5){const[i,o]=f.useState(null);f.useEffect(()=>{let a=!1;const l=tn().slice(0,n);if(!l.length||!e){o([]);return}return Promise.all(l.map(d=>Po(e,d))).then(d=>{a||o(d.filter(c=>!c.notFound))}),()=>{a=!0}},[e,n]);const s=f.useCallback(()=>{Mo(),o([])},[]);return{entries:i,clear:s}}function x1(e,n,i){const o=e.type==="book"?e.edition||e.era:e.type==="collection"?"":e.dynasty;return o?i(o):Xp(e.type,n)}function Xp(e,n){return n(`metaHome.typeLabel.${e}`)}function Zp({entries:e,onClear:n,links:i}){const{t:o,convert:s}=ae(),a=rn(i);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:o("metaHome.recentTitle")}),e&&e.length>0&&n&&t.jsx("button",{type:"button",onClick:n,children:o("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":o("metaHome.recentItemLabel",{type:l.type?Xp(l.type,o):"",title:s(l.title)}),children:[t.jsx("i",{className:"bim-mh-ty","aria-hidden":"true",children:l.type?o(`metaHome.typeShort.${l.type}`):""}),t.jsx("span",{children:s(l.title)}),t.jsx("small",{"aria-hidden":"true",children:x1(l,o,s)})]})},l.id))}),e&&e.length===0&&t.jsx("p",{className:"bim-mh-recent-empty",children:o("metaHome.recentEmpty")})]})}function Jp(e,n,i,o=!1){return o&&(e==="done"||e==="in_progress")?n(`metaHome.siteStatus.${e}`):e==="done"||e==="in_progress"||e==="todo"?n(`metaHome.status.${e}`):i(e)}function Qp({rows:e,links:n}){const{t:i,convert:o}=ae(),s=rn(n);return e.length?t.jsx("div",{className:"bim-mh-tbl-wrap",tabIndex:0,role:"region","aria-label":i("metaHome.catalogTitle"),children:t.jsxs("table",{className:"bim-mh-tbl",children:[t.jsxs("caption",{children:[i("metaHome.catalogTitle"),t.jsx("small",{children:i("metaHome.catalogNote")})]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",children:i("metaHome.colCatalog")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colRecords")}),t.jsx("th",{scope:"col",className:"bim-mh-r",children:i("metaHome.colMatched")}),t.jsx("th",{scope:"col",children:i("metaHome.colProgress")}),t.jsx("th",{scope:"col",children:i("metaHome.colStatus")})]})}),t.jsx("tbody",{children:e.map(a=>{const l=Ns(a.imported,a.total),d=a.work_id??a.collection_id,c=o(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:lt(a.total)}),t.jsx("td",{className:"bim-mh-r",children:lt(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:Jp(a.status,i,o)})})]},a.id||a.name)})})]})}):null}function eu({items:e,links:n,label:i}){const{convert:o}=ae();return t.jsx("ul",{className:"bim-rh-rows","aria-label":i?o(i):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:o(s.title)}),s.sub&&t.jsx("small",{children:o(s.sub)})]})},s.id))})}function tu({works:e,links:n}){const{t:i}=ae(),[o,s]=f.useState(!1);if(!e.length)return null;const a=ni(e.length);return t.jsxs("div",{className:"bim-rh-grp","data-cap":a?"":void 0,"data-open":o?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[i("metaHome.relatedTitle"),t.jsx("small",{children:i("metaHome.relatedNote")})]}),t.jsx(eu,{items:e.map(l=>({id:l.id,title:l.title,sub:or(l)||void 0})),links:rn(n)}),a&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":o,onClick:()=>s(l=>!l),children:o?i("action.collapse"):i("metaHome.allNWorks",{n:e.length})})]})}const nu="siku_qige";function b1({group:e,links:n}){const{t:i,convert:o}=ae(),[s,a]=f.useState(!1);return t.jsxs("div",{className:"bim-rh-grp","data-cap":ni(e.items.length)?"":void 0,"data-open":s?"":void 0,children:[t.jsxs("h3",{className:"bim-rh-gt",children:[o(e.label),t.jsx("small",{className:"bim-rh-num",children:i("metaHome.nKinds",{n:e.items.length})})]}),t.jsx(eu,{items:e.items,links:n,label:e.label}),ni(e.items.length)&&t.jsx("button",{type:"button",className:"bim-rh-expand","aria-expanded":s,onClick:()=>a(l=>!l),children:s?i("action.collapse"):i("metaHome.allNKinds",{n:e.items.length})})]})}function iu({groups:e,links:n}){const{t:i,convert:o}=ae(),s=rn(n);if(!e.length)return null;const a=e.find(c=>c.key===nu),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:[o(a.label),t.jsx("small",{children:o(a.items.map(c=>d(c.title)).join("、"))})]}),t.jsx("ul",{className:"bim-mh-ge","aria-label":o(a.label),children:a.items.map(c=>t.jsx("li",{children:t.jsxs("a",{href:s.item(c.id),"aria-label":o(c.title),title:o(c.title),children:[t.jsx("span",{"aria-hidden":"true",children:o(d(c.title))}),d(c.title)!==c.title&&t.jsx("small",{"aria-hidden":"true",children:i("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(b1,{group:c,links:s},c.key))})]})}const Al=34,Ml=13;function Pl(e,n){return e.birth_year==null&&e.death_year==null?"":`${e.birth_year!=null?Wi(e.birth_year,n):"?"}–${e.death_year!=null?Wi(e.death_year,n):"?"}`}function y1(e,n){const i=n-e,o=i>1200?300:i>400?100:50,s=[];for(let a=Math.ceil(e/o)*o;a<=n;a+=o)s.push(a);return s}function ru({people:e,links:n}){const{t:i,convert:o}=ae(),s=rn(n);if(!e.length)return null;const{min:a,max:l,placed:d,missing:c}=Yp(e),p=[],g=d.map(u=>{const h=u.left>70,x=h?Math.min(u.left,u.left+u.width-Ml):u.left;let j=0;for(;p[j]!=null&&p[j]>x;)j++;return p[j]=h?u.left+u.width:u.left+Math.max(u.width,Ml),{...u,lane:j,end:h}}),m=Math.max(1,l-a);return t.jsxs(t.Fragment,{children:[g.length>0&&t.jsxs("div",{className:"bim-mh-tl",children:[t.jsx("ul",{className:"bim-mh-tl-rows",style:{height:p.length*Al+10},children:g.map(u=>t.jsxs("li",{className:"bim-mh-tl-bar","data-end":u.end?"":void 0,style:{left:`${u.left}%`,top:u.lane*Al+4,width:`${Math.max(u.width,.5)}%`},children:[t.jsx("i",{"aria-hidden":"true",style:{width:"100%"}}),t.jsxs("a",{href:s.item(u.p.id),children:[o(u.p.name),t.jsx("small",{className:"bim-rh-num",children:Pl(u.p,i)})]})]},u.p.id))}),t.jsx("div",{className:"bim-mh-tl-axis","aria-hidden":"true",children:y1(a,l).map(u=>t.jsx("span",{style:{left:`${(u-a)/m*100}%`},children:Wi(u,i)},u))})]}),t.jsx("ul",{className:"bim-mh-tl-list","data-only":g.length?void 0:"",children:(g.length?e:c).map(u=>t.jsx("li",{children:t.jsxs("a",{href:s.item(u.id),children:[t.jsx("span",{children:o(u.name)}),t.jsx("small",{className:"bim-rh-num",children:[u.dynasty?o(u.dynasty):"",Pl(u,i)].filter(Boolean).join(" ")})]})},u.id))}),c.length>0&&g.length>0&&t.jsx("p",{className:"bim-mh-tl-foot",children:i("metaHome.missingLife",{names:o(c.map(u=>u.name).join("、"))})})]})}const j1=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 ou({works:e,links:n}){const{t:i,convert:o}=ae(),s=rn(n);return e.length?t.jsx("ul",{className:"bim-mh-lin",children:e.map(a=>{const l=or(a);return t.jsx("li",{children:t.jsxs("a",{href:Gp(s,a.id),children:[j1,t.jsx("b",{children:o(a.title)}),l&&t.jsx("small",{children:o(l)}),t.jsx("span",{children:i("metaHome.viewLineage")})]})},a.id)})}):null}function su({sites:e}){const{t:n,convert:i}=ae(),o=e.filter(a=>a.status!=="todo"&&a.total>0),s=e.filter(a=>!o.includes(a));return e.length?t.jsxs(t.Fragment,{children:[o.length>0&&t.jsx("ul",{className:"bim-mh-cov",children:o.map(a=>{const l=Ns(a.imported,a.total);return t.jsxs("li",{children:[a.url?t.jsx("a",{href:a.url,rel:"noopener noreferrer",target:"_blank",children:i(a.name)}):t.jsx("span",{children:i(a.name)}),t.jsx("span",{className:"bim-mh-bar","aria-hidden":"true",style:{"--bimmh-w":`${l}%`}}),t.jsxs("small",{children:[`${lt(a.imported)} / ${lt(a.total)} ${l}% `,a.status&&t.jsx("span",{className:"bim-mh-st","data-st":a.status,children:Jp(a.status,n,i,!0)})]})]},a.id||a.name)})}),s.length>0&&t.jsx("p",{className:"bim-mh-todo",children:n("metaHome.plannedSites",{names:i(s.map(a=>a.name).join("、"))})})]}):null}const Bl=["extant","partially_extant","lost","unknown"];function au({stats:e,links:n,version:i,repoUrl:o,downloadHref:s}){const{t:a}=ae(),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=Bl.some(p=>{var g;return(((g=e.loss)==null?void 0:g[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,g])=>t.jsxs("li",{children:[t.jsx("b",{className:"bim-rh-num",children:lt(p)}),t.jsx("span",{children:g})]},g))})]}),d&&t.jsxs("div",{children:[t.jsx("h3",{className:"bim-rh-gt",children:a("metaHome.byLoss")}),t.jsx("ul",{className:"bim-mh-loss",children:Bl.map(p=>{var u;const g=((u=e.loss)==null?void 0:u[p])??0,m=a(`metaHome.lossNote.${p}`);return t.jsx("li",{children:t.jsxs("a",{href:d(p),children:[a(`metaHome.loss.${p}`),t.jsx("small",{className:"bim-rh-num",children:c&&g>0?a("metaHome.lossCount",{n:lt(g),note:m}):m})]})},p)})})]}),t.jsxs("div",{className:"bim-mh-lic",children:[t.jsxs("p",{children:[t.jsx("span",{className:"bim-mh-cc0",children:"CC BY-SA 4.0"}),a("metaHome.license")]}),t.jsxs("p",{children:[a("metaHome.repo"),o?t.jsx("a",{href:o,children:t.jsx("code",{children:"book-index"})}):t.jsx("code",{children:"book-index"}),a("metaHome.repoNote")]}),i&&t.jsxs("p",{children:[a("metaHome.version"),t.jsx("code",{children:i})]}),s&&t.jsx("p",{children:t.jsx("a",{href:s,children:a("metaHome.download")})})]})]})}const lu={zhi:"zhi",sibu:"sibu",cong:"cong",people:"people",lineage:"lineage",sites:"sites",data:"data"};function v1({sections:e,links:n,head:i,transport:o,catalogHref:s,collectionsHref:a,entitiesHref:l,version:d,repoUrl:c,downloadHref:p,className:g}){var v,C;const{t:m}=ae(),u=e,h=rn(n),x=h1(h),j=lu,b=qp(o),S={zhi:!!((v=u.shelf)!=null&&v.items.length)||u.catalog_progress.length>0||u.related_catalogs.length>0,sibu:u.bu.length>0||u.unclassified>0,cong:u.collection_groups.length>0,people:u.bibliographers.length>0,lineage:u.lineage.length>0,sites:u.sites.length>0,data:!0},y=Object.keys(j).filter(_=>S[_]),k=_=>m(`metaHome.nav.${_}`),w=(_,$)=>_?t.jsx("a",{className:"bim-rh-more",href:_,children:$}):void 0;return t.jsxs("div",{className:g?`bim-rh bim-mh ${g}`:"bim-rh bim-mh",children:[t.jsx("style",{children:_s+Up}),t.jsxs("div",{className:"bim-mh-head",children:[t.jsxs("div",{className:"bim-mh-q",children:[i,t.jsx(Kp,{counts:u.counts,links:n})]}),o&&t.jsx(Zp,{entries:b.entries,onClear:b.clear,links:n})]}),y.length>1&&t.jsx("nav",{className:"bim-rh-secnav","aria-label":m("metaHome.navLabel"),children:t.jsx("ul",{children:y.map(_=>t.jsx("li",{children:t.jsx("a",{href:`#${j[_]}`,children:k(_)})},_))})}),t.jsxs("div",{className:"bim-rh-main",children:[S.zhi&&t.jsxs(wt,{id:j.zhi,title:k("zhi"),sub:m("metaHome.zhiSub"),children:[u.shelf&&u.shelf.items.length>0&&t.jsx(Cs,{topic:{key:"shelf",label:u.shelf.label,shelf:!0,items:u.shelf.items},links:x,showTitle:!1,legendCount:u.shelf.items.some(_=>_.records)?m("metaHome.shelfLegendCount"):null,legendExtra:[m("metaHome.shelfLegendClick")]}),(u.catalog_progress.length>0||u.related_catalogs.length>0)&&t.jsxs("div",{className:"bim-mh-zhi",style:(C=u.shelf)!=null&&C.items.length?void 0:{marginTop:0},children:[t.jsx(Qp,{rows:u.catalog_progress,links:n}),t.jsx(tu,{works:u.related_catalogs,links:n})]})]}),S.sibu&&t.jsx(wt,{id:j.sibu,title:k("sibu"),sub:m("metaHome.sibuSub"),more:w(s,m("metaHome.toCatalog")),children:t.jsx(zs,{bu:u.bu,unclassified:u.unclassified,links:x,unclassifiedNote:m("metaHome.unclassifiedNote")})}),S.cong&&t.jsx(wt,{id:j.cong,title:k("cong"),sub:m("metaHome.congSub"),more:w(a,m("metaHome.allNKindsMore",{n:lt(u.counts.collections)})),children:t.jsx(iu,{groups:u.collection_groups,links:n})}),S.people&&t.jsx(wt,{id:j.people,title:k("people"),sub:m("metaHome.peopleSub"),more:w(l,m("metaHome.allNPeopleMore",{n:lt(u.counts.entities)})),children:t.jsx(ru,{people:u.bibliographers,links:n})}),S.lineage&&t.jsx(wt,{id:j.lineage,title:k("lineage"),sub:m("metaHome.lineageSub"),children:t.jsx(ou,{works:u.lineage,links:n})}),S.sites&&t.jsx(wt,{id:j.sites,title:k("sites"),sub:m("metaHome.sitesSub"),children:t.jsx(su,{sites:u.sites})}),t.jsx(wt,{id:j.data,title:k("data"),sub:m("metaHome.dataSub"),children:t.jsx(au,{stats:u.stats,links:n,version:d,repoUrl:c,downloadHref:p})})]})]})}const cu=["_related","_catalogs","_collections","_members","_children"],k1=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),bo=e=>k1(e)&&!!e.h;function w1(e){return e?cu.some(n=>{const i=e[n];return Array.isArray(i)&&i.some(bo)}):!1}function S1(e,n){const i={...e};if(!n)return i;for(const o of cu){const s=e[o];!Array.isArray(s)||!s.some(bo)||(i[o]=s.map(a=>{var c;if(!bo(a)||typeof a.title=="string"&&a.title)return a;const l=a.id??a.bid,d=l?(c=n[l])==null?void 0:c.title:void 0;return d?{...a,title:d}:a}))}return i}function _1(e){let n=null;const i=()=>e.getHubs?(n??(n=e.getHubs().catch(()=>null)),n):Promise.resolve(null);return new Proxy(e,{get(o,s){if(s==="getItem")return async l=>{const d=await o.getItem(l);return d&&S1(d,w1(d)?await i():null)};const a=Reflect.get(o,s,o);return typeof a=="function"?a.bind(o):a}})}const yo=({style:e})=>{const n=f.useContext(Ot),{t:i}=ae();if(!n)return null;const{locale:o,setLocale:s}=n,a=o==="zh-Hant",l=()=>s(a?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:i(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 ${r("border")}`,borderRadius:"4px",background:r("bg"),color:r("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:a?r("primary"):void 0,fontWeight:a?700:400},children:i("common.localeShortHant")}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:a?void 0:r("primary"),fontWeight:a?400:700},children:i("common.localeShortHans")})]})},jo=({href:e,label:n,size:i=16,className:o,style:s})=>{const{t:a}=ae(),l=n??a("common.repoSourceLink");return t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:l,"aria-label":l,className:o,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i+8,height:i+8,borderRadius:4,color:r("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:d=>{d.currentTarget.style.color=r("fg")},onMouseLeave:d=>{d.currentTarget.style.color=r("desc-fg")},children:t.jsx("svg",{width:i,height:i,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 Dr(e){const n=e.text_count;return typeof n=="number"&&n>0}function Ur(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function $1(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const C1=({id:e,transport:n,initialDetail:i,initialEntry:o,activeTab:s,onTabChange:a,activeJuan:l,onJuanChange:d,lineageMode:c="list",onLineageModeChange:p,lineageCollection:g,onLineageCollectionChange:m,initialPage:u=1,selectedLineageNodeId:h,onNavigate:x,onBack:j,backLabel:b,renderLink:S,assetBase:y,enrichDetail:k,getSourceLink:w,readLink:v,railTop:C,extraTabs:_=[],showFeedbackTab:$=!0,feedbackApiUrl:A,height:R,footerExtra:z,hideHeaderControls:N=!1,className:M,style:O})=>{const L=f.useMemo(()=>_1(n),[n]),D=Be(),{t:q,convert:J}=ae(),[se]=f.useState(()=>{if(!$1(e,i))return null;const Y={...i},me=o??Ur(e,Y);return k&&k(me,Y),{id:e,entry:me,detail:Y}}),[U,K]=f.useState((se==null?void 0:se.entry)??null),[Z,oe]=f.useState((se==null?void 0:se.detail)??null),[ye,Le]=f.useState(!se),[Me,Se]=f.useState(!1),[le,Oe]=f.useState([]),[T,de]=f.useState(!1),[pe,B]=f.useState(null),[ee,Ce]=f.useState(null),[Ie,We]=f.useState(null),[G,he]=f.useState(!1),te=f.useRef(null),H=f.useRef(0),[ue,Fe]=f.useState(null),Ge=l!==void 0?l:ue,Je=f.useCallback(Y=>{d?d(Y):Fe(Y)},[d]),F=f.useCallback(async Y=>{if(!L.getCollectionCatalogs&&!L.getCollectionCatalog){Oe([]);return}de(!0);try{if(L.getCollectionCatalogs)Oe(await L.getCollectionCatalogs(Y)||[]);else if(L.getCollectionCatalog){const me=await L.getCollectionCatalog(Y);Oe(me?[{resource_id:"",data:me}]:[])}}catch{Oe([])}finally{de(!1)}},[L]),ge=f.useCallback(async Y=>{var me,_e;if(!L.getTextManifest||!L.getTextIndex){B(null),Ce(Y);return}try{const Pe=Re.pickTextVersion(await L.getTextManifest(Y)),ne=Pe?await L.getTextIndex(Y,Pe.key):null;B(ne&&ne.chapters.length>0?{chapters:ne.chapters.map(re=>({n:re.n,title:re.title,file:re.file})),source:{name:((me=ne.source)==null?void 0:me.name)??(Pe==null?void 0:Pe.source_name),license:((_e=ne.source)==null?void 0:_e.license)??(Pe==null?void 0:Pe.license)??void 0}}:null)}catch{B(null)}finally{Ce(Y)}},[L]),Ae=f.useCallback(async(Y,me)=>{const _e=++H.current,Pe=()=>_e!==H.current;he(!0);try{if(L.getLineageGraph){const Ee=await L.getLineageGraph(Y);if(Pe())return;Ee&&We(Ee)}const ne=me.version_graph;if(!ne||!ne.enabled){Ie||We(null),te.current=null;return}const re=Eo(me),ke=(await ir(re,nr,async Ee=>{try{return await L.getItem(Ee)}catch{return null}},Pe)).filter(Boolean);if(Pe())return;te.current={work:me,books:ke};const Ue=g??ne.default_collection??(ne.core_books&&ne.core_books.length>0?"core":"all"),we=Ue==="core"&&Array.isArray(ne.core_books)&&ne.core_books.length>0?"core":Ue??"all";We(Ei(me,ke,we))}catch{if(Pe())return;We(null),te.current=null}finally{Pe()||he(!1)}},[L]),W=f.useRef({initialDetail:i,initialEntry:o});W.current={initialDetail:i,initialEntry:o},f.useEffect(()=>{let Y=!1;H.current++,he(!1);const me=re=>{re.type==="collection"?F(e):re.type==="work"?(re.version_graph||L.getLineageGraph)&&Ae(e,re):re.type==="book"&&Dr(re)&&ge(e)},_e=W.current;let Pe=null;if(se&&se.id===e)Pe=se;else if(_e.initialDetail&&_e.initialDetail.id===e){const re={..._e.initialDetail},ve=_e.initialEntry??Ur(e,re);k&&k(ve,re),Pe={entry:ve,detail:re}}return Pe?(Se(!1),Oe(re=>re.length?[]:re),B(null),We(null),te.current=null,K(Pe.entry),oe(Pe.detail),Le(!1),me(Pe.detail),()=>{Y=!0}):((async()=>{Le(!0),Se(!1),K(null),oe(null),Oe([]),B(null),We(null),te.current=null;try{const re=await L.getItem(e);if(Y)return;if(!re){Se(!0);return}const ve=re;let ke=null;if(L.getEntry&&(ke=await L.getEntry(e),Y))return;ke||(ke=Ur(e,ve)),k&&k(ke,ve),K(ke),oe(ve),me(ve)}catch{Y||Se(!0)}finally{Y||Le(!1)}})(),()=>{Y=!0})},[e,L,se,k,F,Ae,ge]),f.useEffect(()=>{const Y=te.current;!Y||!g||We(Ei(Y.work,Y.books,g))},[g]);const be=[];if(Z){if(be.push({key:"basic",label:D.detailTab.basicInfo}),Z.type==="collection"){T&&le.length===0&&be.push({key:"catalog:loading",label:`${D.detailTab.catalog}…`});for(const Y of le)be.push({key:`catalog:${Y.resource_id}`,label:Y.short_name?`${J(Y.short_name)}${D.detailTab.catalogSuffix}`:D.detailTab.collectionCatalog})}(s==="collated"||s==="fulltext")&&be.push({key:s,label:D.detailTab.fullText}),Z.type==="work"&&(Ie||G)&&be.push({key:"lineage",label:G?`${D.detailTab.lineage}…`:D.detailTab.lineage});for(const Y of _)(Y.position??"before-feedback")==="before-feedback"&&Y.shouldShow(Z)&&be.push({key:Y.key,label:Y.label});$&&s==="feedback"&&be.push({key:"feedback",label:D.detailTab.feedback});for(const Y of _)Y.position==="after-feedback"&&Y.shouldShow(Z)&&be.push({key:Y.key,label:Y.label})}f.useEffect(()=>{if(s!=="emendated"||!Z)return;a("basic");const Y=setTimeout(()=>{var me;(me=document.getElementById("studies"))==null||me.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(Y)},[s,Z,a]);const ce=U&&Z&&w?w({activeTab:s,activeJuan:Ge,entry:U,detail:Z}):null,Ne=f.useMemo(()=>{var ne,re,ve,ke,Ue;if(!Z)return null;const me=(Z.authors??[]).map(we=>{const Ee=Io(we.role);return`${we.dynasty?`〔${J(we.dynasty)}〕`:""}${J(we.name)}${Ee?` ${J(Ee)}`:""}`}).join(" · ");let _e=!1;try{_e=Re.extractStatus(Z.id)==="draft"}catch{}if(Z.type==="book"){const we=Z;return{title:J(we.title),subtitle:we.edition?J(we.edition):me||void 0,aside:[_e?D.status.draft:"",me&&we.edition?me:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(Z.type==="collection"){const we=Z;return{title:J(we.title),subtitle:J(Kt(we,D.unit.juan))||void 0,aside:[(ne=we.publication_info)==null?void 0:ne.year,_e?D.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:me||void 0}}if(Z.type==="entity"){const we=Z,Ee=Ye=>Ye==null?"":Ye<0?q("detail.bce",{n:-Ye}):String(Ye),He=((re=we.dates)==null?void 0:re.birth)!=null||((ve=we.dates)==null?void 0:ve.death)!=null?`${Ee(((ke=we.dates)==null?void 0:ke.birth)??void 0)||"?"}—${Ee(((Ue=we.dates)==null?void 0:Ue.death)??void 0)||"?"}`:"";return{title:J(we.primary_name||we.title),subtitle:[we.dynasty?`〔${J(we.dynasty)}〕`:"",He].filter(Boolean).join(" ")||void 0,aside:_e?D.status.draft:void 0,secondLine:void 0}}const Pe=J(Kt(Z,D.unit.juan));return{title:J(Z.title),subtitle:[Pe,me].filter(Boolean).join(" · ")||void 0,aside:[N1(D,Z.subtype),_e?D.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[Z,J,D,q]),$e=Z&&Dr(Z)?"text":null,Ke=()=>{Je(null),a("fulltext")};let Qe=null;if(Z&&v){const Y=v({detail:Z,kind:$e});Y&&(Qe=t.jsx(to,{href:Y}))}else $e&&(Qe=t.jsx(to,{onClick:Ke}));const it=Y=>{if(!Z)return null;const me=Y.replace(/\.[^.]+$/,"");if(v){const _e=v({detail:Z,kind:$e,juan:me});return _e?{href:_e}:null}return{onClick:()=>{Je(me),a("fulltext")}}},nt=new Set(_.map(Y=>Y.key)),I=be.filter(Y=>Y.key.startsWith("catalog:")&&Y.key!=="catalog:loading"||Y.key==="lineage"&&!!Ie&&!G||nt.has(Y.key)).map(Y=>({key:Y.key,label:Y.label,onClick:()=>a(Y.key)})),fe=()=>{var Y;return Z?Z.type==="work"?t.jsx(up,{data:Z,transport:L,onNavigate:x,renderLink:S,readAction:Qe,railTop:C,railLinks:I}):Z.type==="book"?t.jsx(hp,{data:Z,transport:L,onNavigate:x,renderLink:S,readAction:Qe,fullText:pe,fullTextPending:Dr(Z)&&!!L.getTextManifest&&ee!==Z.id,chapterLink:it,railTop:C,railLinks:I}):Z.type==="collection"?t.jsx(xp,{data:Z,catalog:(Y=le[0])==null?void 0:Y.data,transport:L,onNavigate:x,renderLink:S,readAction:Qe,railTop:C,railLinks:I,catalogAction:le.length>0?t.jsxs("a",{href:"#catalog",onClick:me=>{me.preventDefault(),a(`catalog:${le[0].resource_id}`)},children:[J(D.detailTab.collectionCatalog)," →"]}):null}):t.jsx(yp,{data:Z,transport:L,onNavigate:x,renderLink:S,railTop:C,railLinks:I,assetBase:y}):null},xe=()=>{var me,_e,Pe;if(!U||!Z)return null;if(s==="basic"||s==="emendated")return fe();if(typeof s=="string"&&s.startsWith("catalog:")){const ne=(me=le.find(re=>`catalog:${re.resource_id}`===s))==null?void 0:me.data;return t.jsx(Oo,{data:ne,onNavigate:x,renderLink:S})}if(s==="collated"||s==="fulltext")return t.jsx(fs,{id:e,transport:L,chapter:Ge,onLocationChange:ne=>Je(ne.chapter),onNavigate:x});if(s==="lineage"){if(!Ie)return t.jsx("div",{style:{color:r("label-fg"),padding:"24px 0"},children:q(G?"detail.loading":"detail.noLineageGraph")});const ne=Z.type==="work"?Z:null;return t.jsx(vs,{graph:Ie,renderLink:S,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:p,selectedNodeId:h,collection:g??((_e=ne==null?void 0:ne.version_graph)==null?void 0:_e.default_collection),onCollectionChange:m,collectionsAvailable:(Pe=ne==null?void 0:ne.version_graph)==null?void 0:Pe.collections,collectionCounts:(()=>{var Ue,we,Ee,He,Ye,Xe,at;if(!ne)return;const re={},ve=((Ue=te.current)==null?void 0:Ue.books)??[];re.all=(((we=ne._books)==null?void 0:we.length)??0)-(((He=(Ee=ne.version_graph)==null?void 0:Ee.excluded_books)==null?void 0:He.length)??0);const ke=(Ye=ne.version_graph)==null?void 0:Ye.collections;if(ke)for(const qe of Object.keys(ke))re[qe]=Ei(ne,ve,qe).nodes.filter(jt=>jt.kind==="book"&&!jt.bridge).length;return re.core==null&&((at=(Xe=ne.version_graph)==null?void 0:Xe.core_books)!=null&&at.length)&&(re.core=ne.version_graph.core_books.length),re})()})}if(s==="feedback"&&$)return t.jsx(lp,{resourceId:e,apiUrl:A});const Y=_.find(ne=>ne.key===s);return Y?Y.render({detail:Z,entry:U,transport:L,onNavigate:x}):null};if(ye)return t.jsx(Kn,{style:{minHeight:R,...O},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((Y,me)=>t.jsx("div",{style:{height:me===1?40:16,width:Y,opacity:.35,background:r("rule")}},me))})});if(Me||!Z||!U||!Ne)return t.jsx(Kn,{style:{minHeight:R,...O},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:r("label-fg"),fontSize:14},children:q("detail.notFound")})});const ze=s==="basic"||s==="emendated",V=[{label:b??D.detailTab.backToIndex,onClick:j}];if(Z.type==="book"&&Z.work_id){const Y=Z.work_id;V.push({label:D.indexType.work,id:Y,onClick:()=>x==null?void 0:x(Y)})}V.push({label:D.indexType[Z.type]});const P=s==="collated"||s==="fulltext",X=typeof z=="string"?D.status[z.trim()]??z:z,je=t.jsx(ld,{left:t.jsxs(t.Fragment,{children:[X,X?" · ":"",t.jsx(z1,{id:Z.id,label:D.label.id,copied:D.action.copied,copyLabel:D.action.copy})]}),right:t.jsxs(t.Fragment,{children:[$&&!ze&&t.jsx("button",{type:"button",onClick:()=>a("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:r("meta-fg")},children:D.detailTab.submitVersion}),ce&&t.jsx("a",{href:ce.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:r("meta-fg")},children:D.detailTab.dataLicense})]})});return ze?t.jsx("div",{className:M,children:t.jsxs(Kn,{grid:!0,style:{minHeight:R,...O},children:[t.jsx(no,{breadcrumb:t.jsx(io,{items:V}),actions:t.jsxs(t.Fragment,{children:[!N&&t.jsx(yo,{style:{border:"none",background:"transparent"}}),!N&&ce&&t.jsx(jo,{...ce})]})}),fe(),je]})}):t.jsx("div",{className:M,children:t.jsxs(Kn,{wide:P,style:{minHeight:R,...O},children:[t.jsx(no,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(Vo,{char:"籍"}),t.jsx(io,{items:V})]}),actions:t.jsxs(t.Fragment,{children:[!N&&t.jsx(yo,{}),$&&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:r("meta-fg")},children:D.detailTab.feedback}),!N&&ce&&t.jsx(jo,{...ce})]})}),t.jsx(Qc,{...Ne,aside:P?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:r("accent"),borderBottom:`1px solid ${r("rule")}`},children:[q("detail.workInfo")," →"]}):Ne.aside}),!P&&be.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:be.map(Y=>t.jsx(ed,{label:Y.label,active:Y.key===s||ze&&Y.key==="basic",onClick:()=>a(Y.key)},Y.key))}),t.jsx("div",{style:{marginTop:!P&&be.length>1?8:0},children:xe()}),je]})})};function z1({id:e,label:n,copied:i,copyLabel:o}){const[s,a]=f.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?i:o,"aria-label":s?i:o,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:r("aux-fg")},children:s?"✓":"⧉"})]})}function N1(e,n){return n?e.workSubtype[n]??n:""}const du=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛青"},{name:"ink",label:"墨"}],sr="zhusha",ar="bim-theme";function pu(e){return e==="zhusha"||e==="indigo"||e==="ink"}function lr(e){return pu(e)?e:sr}function T1(){try{return lr(window.localStorage.getItem(ar))}catch{return sr}}function uu(e){try{window.localStorage.setItem(ar,e)}catch{}}function mu(e){const n=lr(e);return document.documentElement.setAttribute("data-theme",n),n}function gu(){return lr(document.documentElement.getAttribute("data-theme"))}const R1=[{name:"airy",label:"疏朗",hint:"留白分区"},{name:"boxed",label:"界欄",hint:"框線分區"}],Ts="airy",cr="bim-layout";function fu(e){return e==="airy"||e==="boxed"}function dr(e){return fu(e)?e:Ts}function I1(){try{return dr(window.localStorage.getItem(cr))}catch{return Ts}}function E1(e){try{window.localStorage.setItem(cr,e)}catch{}}function L1(e){const n=dr(e);return document.documentElement.setAttribute("data-layout",n),n}function A1(){return dr(document.documentElement.getAttribute("data-layout"))}const M1=`try{var t=localStorage.getItem(${JSON.stringify(ar)});if(t==='indigo'||t==='ink')document.documentElement.setAttribute('data-theme',t);if(localStorage.getItem(${JSON.stringify(cr)})==='boxed')document.documentElement.setAttribute('data-layout','boxed')}catch(e){}`,P1={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo",ink:"theme-dot-ink"},B1=({onChange:e,style:n})=>{const{t:i}=ae(),[o,s]=f.useState(sr);f.useEffect(()=>{s(gu())},[]);const a=l=>{s(mu(l)),uu(l),e==null||e(l)};return t.jsx("div",{role:"radiogroup","aria-label":i("common.themeLabel"),style:{display:"inline-flex",alignItems:"center",...n},children:du.map(l=>{const d=o===l.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":d,"aria-label":i(`common.theme.${l.name}`),title:i(`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:r(P1[l.name]),boxShadow:d?`0 0 0 2px ${r("page-bg")}, 0 0 0 3.5px ${r("aux-fg")}`:"none"}})},l.name)})})};exports.BidLink=Re.BidLink;exports.BookIndexError=Re.BookIndexError;exports.BookIndexManager=Re.BookIndexManager;exports.BookIndexStorage=Re.BookIndexStorage;exports.BundleStorage=Re.BundleStorage;exports.ConfigError=Re.ConfigError;exports.GithubStorage=Re.GithubStorage;exports.IdGenerationError=Re.IdGenerationError;exports.IdGenerator=Re.IdGenerator;exports.LocalStorage=Re.LocalStorage;exports.MigrationError=Re.MigrationError;exports.StorageError=Re.StorageError;exports.VARIANT_CHARS=Re.VARIANT_CHARS;exports.base36Decode=Re.base36Decode;exports.base36Encode=Re.base36Encode;exports.base58Decode=Re.base58Decode;exports.buildId=Re.buildId;exports.buildPromotionMap=Re.buildPromotionMap;exports.cleanName=Re.cleanName;exports.decodeId=Re.decodeId;exports.decodeIdString=Re.decodeIdString;exports.encodeId=Re.encodeId;exports.extractIdFromUrl=Re.extractIdFromUrl;exports.extractStatus=Re.extractStatus;exports.extractType=Re.extractType;exports.isChapterSegment=Re.isChapterSegment;exports.isTextKey=Re.isTextKey;exports.matchChapterAcrossVersions=Re.matchChapterAcrossVersions;exports.normalizeCatalog=Re.normalizeCatalog;exports.normalizeVariants=Re.normalizeVariants;exports.parseId=Re.parseId;exports.pickTextVersion=Re.pickTextVersion;exports.shardOf=Re.shardOf;exports.smartDecode=Re.smartDecode;exports.textVersionLabel=Re.textVersionLabel;exports.validateResource=Re.validateResource;exports.VARIANT_SUPPLEMENT=Ol.VARIANT_SUPPLEMENT;exports.Badge=Oi;exports.BidUrlProvider=Du;exports.BookDetailLayout=C1;exports.BookPage=hp;exports.Breadcrumb=io;exports.CATALOG_ALL_ID=Vt;exports.CATALOG_CSS=jp;exports.CATALOG_NARROW_QUERY=ks;exports.CATALOG_PAGE_SIZE=ws;exports.CATALOG_UNCLASSIFIED_ID=pn;exports.CLASSIFICATIONS=Xi;exports.COMMON_TRADITIONAL_CHARS=Xl;exports.CardFoot=si;exports.CatalogPage=a1;exports.CatalogPager=Cp;exports.CatalogTree=kp;exports.CheckFilter=Xc;exports.Chip=td;exports.ChipWall=Yf;exports.CollectionCatalog=Oo;exports.CollectionPage=xp;exports.CreateEntityDialog=ep;exports.DEFAULT_LAYOUT=Ts;exports.DEFAULT_META_HOME_LINKS=Vp;exports.DEFAULT_READER_PREFS=Fo;exports.DEFAULT_READ_HOME_LINKS=Np;exports.DEFAULT_THEME=sr;exports.DETAIL_CSS=Jc;exports.DYNASTY_GROUPS=qi;exports.Dash=Qf;exports.DataTable=qf;exports.DetailFooter=ld;exports.DetailGrid=ri;exports.DetailHeader=Qc;exports.EMPTY_FILTERS=Ki;exports.ENTITY_TEXT_CSS=as;exports.EmendatedBySection=Cc;exports.EmptyNote=sh;exports.EntityDetail=kc;exports.EntityMark=ds;exports.EntityPage=yp;exports.EntityPickerDialog=np;exports.EntitySelector=Qd;exports.EntityText=Nx;exports.ExpandRow=eh;exports.ExtLink=ah;exports.FEEDBACK_FAB_OFFSET_VAR=go;exports.FILTER_SUPPORT=mc;exports.FONT_SIZE_STEPS=Ut;exports.FactList=Df;exports.FeedbackButton=Dy;exports.FeedbackDialog=sp;exports.FeedbackForm=ap;exports.FeedbackList=hs;exports.FeedbackTab=lp;exports.FilterChip=ed;exports.FormInput=Ct;exports.FormTextArea=mn;exports.GUJI_MARKDOWN_FIELD=zf;exports.GUJI_TABLE_NOTATION=cd;exports.GlyphBadge=Vo;exports.GujiInteractiveReader=Lb;exports.GujiTable=Ko;exports.GujiTextViewer=us;exports.GujiWarpCanvas=ss;exports.HomePage=uo;exports.ImagePanel=Zr;exports.IndexApp=Eb;exports.IndexBrowser=qr;exports.IndexDetail=Bo;exports.IndexEditor=ip;exports.IndexView=Ny;exports.IntroGrid=Hf;exports.LAYOUTS=R1;exports.LAYOUT_STORAGE_KEY=cr;exports.LOSS_OPTIONS=uc;exports.LocaleContext=Ot;exports.LocaleProvider=xm;exports.LocaleToggle=yo;exports.META_HOME_CSS=Up;exports.META_HOME_SECTION_IDS=lu;exports.MetaCatalogTable=Qp;exports.MetaCollectionGroups=iu;exports.MetaDataLicense=au;exports.MetaHomeView=v1;exports.MetaLine=ht;exports.MetaLineageCards=ou;exports.MetaOnlineSites=su;exports.MetaPeopleTimeline=ru;exports.MetaRecentPanel=Zp;exports.MetaRelatedCatalogs=tu;exports.MetaTypeChips=Kp;exports.ModeIndicator=Jl;exports.MoreButton=Gf;exports.MoreLink=Do;exports.PAGE_MAX_WIDTH=Ni;exports.PERIOD_NARROW_SHARE=Ep;exports.PageFrame=Kn;exports.Quote=nh;exports.READER_CSS=Ec;exports.READ_HOME_CSS=_s;exports.READ_HOME_NARROW_QUERY=ci;exports.READ_HOME_SECTION_IDS=Dp;exports.READ_PERIOD_LABELS=p1;exports.RECENT_IDS_STORAGE_KEY=Cn;exports.ROLE_CLASS_ORDER=sc;exports.ReadButton=to;exports.ReadFamousWorks=Wp;exports.ReadHomeView=m1;exports.ReadPeriodBand=Fp;exports.ReadPicks=Mp;exports.ReadPieces=Hp;exports.ReadSection=wt;exports.ReadShelf=Cs;exports.ReadSibu=zs;exports.ReadStats=Ap;exports.ReadTopicGroup=Bp;exports.ReadTopics=Op;exports.ReaderMdText=Jo;exports.ReaderShell=Fc;exports.ReaderToc=Lc;exports.RelationPanel=Zd;exports.RepoSourceLink=jo;exports.ResourceEditor=Vr;exports.ResourceGroup=ih;exports.ResourceLine=rh;exports.ResourceList=Co;exports.ResourceRow=sd;exports.SEARCH_VIEW_STORAGE_KEY=Ao;exports.SEVEN_PAVILIONS_KEY=nu;exports.SNIPPET_MARK_END=Hl;exports.SNIPPET_MARK_START=Fl;exports.SORTABLE_TYPES=pc;exports.SearchInput=ec;exports.SearchResults=yc;exports.Sec=bt;exports.Section=Et;exports.SectionHead=Uf;exports.SideList=un;exports.SmartBidInput=Ii;exports.SourceEditor=Kd;exports.StripWarpRenderer=oo;exports.SummaryCard=oi;exports.THEMES=du;exports.THEME_INIT_SCRIPT=M1;exports.THEME_STORAGE_KEY=ar;exports.TRADITIONAL_ALLOWLIST=Zl;exports.TabFilter=Ji;exports.TableHead=Xf;exports.TableRow=Zf;exports.TagRow=ad;exports.TagRows=oh;exports.TextButton=Vf;exports.TextReader=fs;exports.ThemeToggle=B1;exports.TopStrip=no;exports.VersionLineageGraph=fp;exports.VersionLineageList=gp;exports.VersionLineageView=vs;exports.VolumeChips=Kf;exports.VolumeLinks=Go;exports.WorkCard=_p;exports.WorkCardGrid=zp;exports.WorkCatalog=Kb;exports.WorkPage=up;exports.WorkRow=$p;exports.adaptCharCord=Vb;exports.adaptEntityJson=vd;exports.adaptFig=Yb;exports.adaptNorm=Yd;exports.adaptNormDetailed=Gd;exports.adaptPunctJson=Bb;exports.applyLayout=L1;exports.applyTheme=mu;exports.authorsLine=or;exports.bookIndexUriToId=ti;exports.bookMarkingOf=Zo;exports.bucketResources=To;exports.buildCatalogTree=J0;exports.buildCollectionTable=cc;exports.buildLineageGraph=Ei;exports.buildMeiliFilter=ng;exports.buildPageUrl=_o;exports.buildParagraphBlocks=hd;exports.buildVersionRow=rc;exports.buildVersionTable=oc;exports.canParagraphize=Pi;exports.catalogNodeIdOf=X0;exports.catalogNodeIdsOf=Z0;exports.catalogPageCount=n1;exports.catalogTotal=Ss;exports.classificationPath=li;exports.clearAllRecentIds=Mo;exports.compareCatalogCards=t1;exports.computeVersionPartition=Ym;exports.countActiveFilters=Zi;exports.createTextApi=Nc;exports.currentLayout=A1;exports.currentTheme=gu;exports.defaultEntityHref=Rd;exports.defaultWorkLink=wp;exports.deriveDating=Wm;exports.deriveEditionType=dc;exports.deriveEra=ii;exports.deriveYear=Vi;exports.deriveYearRange=No;exports.detailToEditor=op;exports.detectGenre=er;exports.displayAuthorRole=Io;exports.editorToDetail=zy;exports.eraRank=Yr;exports.filtersFromParams=ig;exports.filtersToParams=Mi;exports.findCatalogPath=Sn;exports.findTraditionalChars=jm;exports.firstAuthorText=$s;exports.flattenTitles=ro;exports.flattenToc=Wc;exports.fmtCount=lt;exports.formatHitCount=$i;exports.formatTemplate=zt;exports.formatVolumeRange=Yi;exports.getDisplayNameFromUrl=Nn;exports.getMessages=Rn;exports.getStartPage=So;exports.getT=In;exports.getTypeGroupKey=ko;exports.groupRelatedWorks=Fm;exports.gujiInlineToPlain=Kc;exports.hasActiveFilters=gc;exports.hasGujiMarkdownV02=Nf;exports.hasGujiTableNotation=lh;exports.hasSearchOptions=Qm;exports.headingKey=gs;exports.headingsFromPunct=Bd;exports.iiifVolumeOf=Ob;exports.isCountedChar=Qo;exports.isDuiduChapter=Ri;exports.isLayoutName=fu;exports.isThemeName=pu;exports.lineageHref=Gp;exports.loadRecentIds=tn;exports.measureText=Kt;exports.mergeVolumeResources=wo;exports.nestHeadings=Wd;exports.normalizeEra=ft;exports.normalizeLayout=dr;exports.normalizeRole=Ro;exports.normalizeTheme=lr;exports.normalizeVolumeIndex=Xn;exports.normalizeVolumes=Vl;exports.numberToChinese=Ln;exports.paginationItems=vp;exports.parseChineseNumber=Li;exports.parseGujiInline=Yc;exports.parseGujiTable=pd;exports.parseHeadingKey=Od;exports.parseSourceString=qd;exports.pct=Ns;exports.periodLevel=Ip;exports.pickReaderVersion=Oc;exports.readStoredLayout=I1;exports.readStoredTheme=T1;exports.readerVersionOptionLabel=Qr;exports.remapPlainOffsets=kd;exports.removeRecentId=jc;exports.renderFullTextBody=bh;exports.renderProperNames=yd;exports.renderReaderInline=tr;exports.resolveRecentEntry=Po;exports.resourceHref=Tn;exports.resourceNote=Gi;exports.resultTabFromParam=mg;exports.resultTabToParam=gg;exports.roleFacets=ac;exports.rowNo=Jf;exports.sameFilters=rg;exports.sanitizeHeadings=po;exports.saveRecentId=Kr;exports.segmentEntities=wd;exports.shelfColumns=Tp;exports.sortFor=eg;exports.sortYear=Ai;exports.spineHeight=Rp;exports.splitFullTextTables=Yo;exports.splitHighlightSnippet=vo;exports.splitTableRow=dd;exports.storeLayout=E1;exports.storeTheme=uu;exports.stringifySources=Xd;exports.summaryFromEntry=zd;exports.summaryFromItem=Cd;exports.timelineLayout=Yp;exports.toCatalogWorkCard=e1;exports.transportSummaryLoader=Nd;exports.typeSupportsFilters=fc;exports.useBidUrl=gt;exports.useChapterWarpData=Pd;exports.useConvert=Ve;exports.useEntitySummaryLoader=cs;exports.useI18n=ae;exports.useReaderPrefs=Bc;exports.useRecentEntries=qp;exports.useT=Be;exports.validateLineageGraph=g0;exports.volumeStats=Fi;exports.withDefaultLinks=nn;exports.withMetaLinks=rn;exports.yearText=Wi;
|