book-index-ui 0.22.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +336 -284
- package/dist/index.d.ts +13 -1
- package/dist/index.js +7017 -6823
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";var kl=Object.create;var ro=Object.defineProperty;var Sl=Object.getOwnPropertyDescriptor;var wl=Object.getOwnPropertyNames;var _l=Object.getPrototypeOf,$l=Object.prototype.hasOwnProperty;var zl=(e,n,i,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of wl(n))!$l.call(e,s)&&s!==i&&ro(e,s,{get:()=>n[s],enumerable:!(r=Sl(n,s))||r.enumerable});return e};var ln=(e,n,i)=>(i=e!=null?kl(_l(e)):{},zl(n||!e||!e.__esModule?ro(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ke=require("./storage-entry-BLfpDWdl.cjs"),t=require("react/jsx-runtime"),f=require("react"),Cl=require("opencc-js/t2cn"),Il=require("react-markdown"),Tl=require("remark-gfm"),El=e=>`/book-index?id=${e}`,hr=f.createContext(El);function Rl({buildUrl:e,children:n}){const i=f.useMemo(()=>e,[e]);return t.jsx(hr.Provider,{value:i,children:n})}function Fe(){return f.useContext(hr)}const br="",yr="";function jr(e){const n=[];let i=!1,r=e;for(;r.length;){const s=i?yr:br,l=r.indexOf(s);if(l===-1){n.push({text:r,marked:i});break}l>0&&n.push({text:r.slice(0,l),marked:i}),r=r.slice(l+1),i=!i}return n}function He(e,n){return{title:e,tokens:n}}const so='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Nl=[He("基础(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"}}),He("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),He("提示与警告",{"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)"}}),He("遮罩与阴影",{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)"}}),He("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),He("资源",{"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"}}),He("整理本(CollatedEdition)",{"highlight-bg":{value:"#fff59d",note:"搜索命中高亮底"},"highlight-fg":{value:"inherit",root:!1},"section-lei":{value:"#8e6f3e",note:"章节类型标记:类 / 书 / 序 / 结语 / 考证 / 注释"},"section-shu":{value:"#c0392b"},"section-xu":{value:"#1a5276"},"section-jieyu":{value:"#7d6608"},"section-kaozhen":{value:"#5d6d7e"},"section-zhushi":{value:"#6c5b7b"},"section-tag-fg":{value:"#e74c3c",note:"章节标记(△ 等)"},"matchstate-fg":{value:"#b78900",note:"与底本匹配状态提示"},"quality-published":{value:"#1b5e20",note:"文本质量等级(出版 / 精校 / 粗校 / OCR)"},"quality-fine":{value:"#2e7d32"},"quality-rough":{value:"#1565c0"},"quality-ocr":{value:"#e65100"}}),He("版本传承(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"}}),He("编辑器视图(主要在 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")'}}),He("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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:"主题切换控件的色点:靛蓝"},"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}}),He("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"}}),He("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),He("字体(全站无衬线,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:so,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:so,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Ll=Object.assign({},...Nl.map(e=>e.tokens)),vr={};for(const[e,n]of Object.entries(Ll))vr[e]=`var(--bim-${e}, ${n.value})`;function o(e){const n=vr[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:e.type?e.type==="text+image"?["text","image"]:[e.type]:[]}function Bl(e,n){return yt(e).includes(n)}const Hn={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"},Al={published:"達到出版、學術研究標準,錯誤率在萬分之一以內",fine:"通讀無障礙,錯誤率在百分之一以內",rough:"保證文意基本正確,錯誤率在百分之三以內",ocr:"保持大意和結構,錯誤率在百分之十以內"};o("quality-published"),o("quality-fine"),o("quality-rough"),o("quality-ocr");const Rt=f.createContext(null),kr={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:o("check-fine-bg"),fg:o("check-fine-fg")},粗校:{label:"粗校",bg:o("check-rough-bg"),fg:o("check-rough-fg")},AI整理:{label:"AI整理",bg:o("check-ai-bg"),fg:o("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:"別名"},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:"圖片資源"}},Wl={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:o("check-fine-bg"),fg:o("check-fine-fg")},粗校:{label:"粗校",bg:o("check-rough-bg"),fg:o("check-rough-fg")},AI整理:{label:"AI整理",bg:o("check-ai-bg"),fg:o("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:"别名"},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:"图片资源"}},Ml=["曹霑"];function Fl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pl(e,n=Ml){const i=[...new Set(n.filter(Boolean))].sort((l,a)=>a.length-l.length);if(!i.length)return e;const r=new RegExp(`(${i.map(Fl).join("|")})`,"g"),s=new Set(i);return l=>{if(!l)return e(l);const a=l.split(r);return a.length===1?e(l):a.map((p,c)=>c%2===1&&s.has(p)?p:p&&e(p)).join("")}}let At=null;function Ol(){if(At)return At;try{At=Pl(Cl.Converter({from:"tw",to:"cn"}))}catch{At=e=>e}return At}const Dl={"zh-Hant":kr,"zh-Hans":Wl},Sr="bim-locale";function Hl(){try{const e=localStorage.getItem(Sr);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Gl(e){try{localStorage.setItem(Sr,e)}catch{}}const Ul="zh-Hans",Vl=({locale:e,onLocaleChange:n,converter:i,children:r})=>{const[s,l]=f.useState(e??Ul),a=e??s;f.useEffect(()=>{if(e)return;const u=Hl();u&&u!==s&&l(u)},[]);const p=f.useMemo(()=>a==="zh-Hans"?i??Ol():null,[a,i]),c=f.useCallback(u=>{l(u),Gl(u),n==null||n(u)},[n]),d=f.useMemo(()=>({locale:a,setLocale:c,messages:Dl[a],converter:p}),[a,c,p]);return t.jsx(Rt.Provider,{value:d,children:r})};function de(){const e=f.useContext(Rt);return(e==null?void 0:e.messages)??kr}const Yl=2e3;function V(){const e=f.useContext(Rt),n=(e==null?void 0:e.locale)??"zh-Hant",i=(e==null?void 0:e.converter)??null,r=f.useRef(new Map),s=f.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const l=f.useCallback(a=>{if(!a)return"";if(!i)return a;const p=r.current.get(a);if(p!==void 0)return p;const c=i(a);if(r.current.size>=Yl){const d=r.current.keys().next().value;d!==void 0&&r.current.delete(d)}return r.current.set(a,c),c},[i]);return f.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function Kt(e,n){return e.replace(/\{(\w+)\}/g,(i,r)=>String(n[r]??""))}function Kl(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 r=n.split(".");return r.length>=2?r[r.length-2]:n}catch{return""}}function ql(){return{id:"",name:"",url:"",type:"text",details:""}}const Gn=({items:e,onChange:n,onDownload:i,downloadStatuses:r,filterType:s})=>{const l=de(),[a,p]=f.useState(null),c=[{value:"text",label:l.resourceTypeShort.text},{value:"image",label:l.resourceTypeShort.image},{value:"text+image",label:l.resourceTypeShort.textImage},{value:"physical",label:l.resourceTypeShort.physical}],d=[{value:"catalog",label:l.rootType.catalog},{value:"search",label:l.rootType.search}],u=j=>{if(!s)return!0;const v=yt(j);return s==="text"?v.includes("text"):s==="image"?v.includes("image")||v.includes("physical"):s==="physical"?v.includes("physical"):v.includes(s)},g=e.map((j,v)=>({item:j,originalIndex:v})).filter(({item:j})=>u(j)),x=()=>{const j=ql();s&&(j.type=s),n([...e,j]),p(e.length)},m=j=>{n(e.filter((v,_)=>_!==j)),p(null)},b=(j,v,_)=>{const S=[...e];if(S[j]={...S[j],[v]:_},v==="url"&&!S[j].id){const $=Kl(_);$&&(S[j].id=$)}n(S)},k=(j,v,_)=>{const $={...e[j].metadata||{}};_?$[v]=_:delete $[v],b(j,"metadata",Object.keys($).length>0?$:void 0)},h=(j,v)=>{const _=v.trim()?v.split(/[,,、]/).map(S=>S.trim()).filter(Boolean):void 0;b(j,"structure",_)},y=(j,v,_)=>{const $=e[j].coverage||{level:1,ranges:""};v==="level"?$.level=parseInt(_)||1:$.ranges=_,b(j,"coverage",$.ranges?$:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[g.map(({item:j,originalIndex:v})=>{var _,S,$;return t.jsxs("div",{style:{border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:o("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(a===v?null:v),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:a===v?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Jl(j.type??"text"),color:o("on-color-fg")},children:(()=>{var C,N;const w=yt(j);return w.length===0?j.type??"text":w.length===1?((C=c.find(E=>E.value===w[0]))==null?void 0:C.label)??w[0]:w.includes("text")&&w.includes("image")?((N=c.find(E=>E.value==="text+image"))==null?void 0:N.label)??"text+image":w.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:j.name||`${l.editor.resourcePlaceholder} ${v+1}`}),j.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:j.id}),j.url&&t.jsx("a",{href:j.url,target:"_blank",rel:"noopener noreferrer",onClick:w=>w.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&j.url&&Zl(v,r==null?void 0:r[v],i,l),t.jsx("button",{onClick:w=>{w.stopPropagation(),m(v)},style:{background:"transparent",border:"none",color:o("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),a===v&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${o("widget-border")}`},children:[Bl(j,"image")&&j.url&&Xl(j,l),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Wt,children:[t.jsx("span",{style:Mt,children:l.label.type}),t.jsx("select",{value:j.type,onChange:w=>b(v,"type",w.target.value),style:{...Qe,flex:1},children:c.map(w=>t.jsx("option",{value:w.value,children:w.label},w.value))})]}),t.jsxs("label",{style:Wt,children:[t.jsx("span",{style:Mt,children:l.label.rootType}),t.jsx("select",{value:j.root_type||"catalog",onChange:w=>b(v,"root_type",w.target.value),style:{...Qe,flex:1},children:d.map(w=>t.jsx("option",{value:w.value,children:w.label},w.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:j.id,onChange:w=>b(v,"id",w.target.value),placeholder:l.editor.idAutoExtract,style:{...Qe,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:j.name,onChange:w=>b(v,"name",w.target.value),placeholder:l.editor.resourceName,style:{...Qe,flex:1}})]}),t.jsx("input",{type:"text",value:j.url,onChange:w=>b(v,"url",w.target.value),placeholder:l.editor.resourceUrl,style:Qe}),t.jsx("input",{type:"text",value:((_=j.structure)==null?void 0:_.join("、"))||"",onChange:w=>h(v,w.target.value),placeholder:l.editor.structurePlaceholder,style:Qe}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Wt,children:[t.jsx("span",{style:Mt,children:l.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((S=j.coverage)==null?void 0:S.level)??"",onChange:w=>y(v,"level",w.target.value),placeholder:"1",style:{...Qe,width:"60px"}})]}),t.jsxs("label",{style:{...Wt,flex:1},children:[t.jsx("span",{style:Mt,children:l.label.coverageRange}),t.jsx("input",{type:"text",value:(($=j.coverage)==null?void 0:$.ranges)||"",onChange:w=>y(v,"ranges",w.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...Qe,flex:1}})]})]}),t.jsx("textarea",{value:j.details||"",onChange:w=>b(v,"details",w.target.value),placeholder:l.editor.detailsPlaceholder,style:{...Qe,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${o("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:o("desc-fg"),marginBottom:"6px"},children:l.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([w,C])=>{var N;return t.jsxs("label",{style:{...Wt,gap:"4px"},children:[t.jsx("span",{style:{...Mt,minWidth:"56px"},children:C}),t.jsx("input",{type:"text",value:((N=j.metadata)==null?void 0:N[w])||"",onChange:E=>k(v,w,E.target.value),placeholder:C,style:{...Qe,flex:1}})]},w)})})]})]})]})]},v)}),t.jsxs("button",{onClick:x,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${o("widget-border")}`,borderRadius:"4px",background:"transparent",color:o("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:l.action.addResource})]})]})};function Jl(e){switch(e){case"text":return o("restype-text");case"image":return o("restype-image");case"text+image":return o("restype-text-image");case"physical":return o("restype-physical")}}function Zl(e,n,i,r){const s=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return t.jsx("button",{onClick:a=>{a.stopPropagation(),s||i(e,"")},disabled:s,style:{background:"transparent",border:"none",color:o(l?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:l?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:l?"✓":s?"⏳":"⬇"})}function Xl(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:o("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:o("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:o("desc-fg")},children:n.editor.imageResourceLink})})}const Qe={width:"100%",padding:"6px 8px",background:o("input-bg"),color:o("input-fg"),border:`1px solid ${o("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Wt={display:"flex",alignItems:"center",gap:"6px"},Mt={fontSize:"12px",color:o("desc-fg"),whiteSpace:"nowrap"},Ql={"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 Nt(e){try{return Ql[new URL(e).hostname]}catch{return}}const lo={text:0,image:1,physical:2};function ci(e){return e.length===0?"physical":[...e].sort((n,i)=>(lo[n]??99)-(lo[i]??99)).join("+")}function di(e){var a;const n=p=>{const c=p.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const d=p.match(/^(.+?)[·(](\d+)[)]?$/);return d?[d[1],parseInt(d[2])]:null},i=new Map;for(let p=0;p<e.length;p++){const c=e[p];if(c.volumes&&c.volumes.length>0)continue;const d=n(c.name);if(!d)continue;const[u,g]=d,x=`${u}|${ci(yt(c))}`;i.has(x)||i.set(x,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const m=i.get(x);m.volumes.push({volume:g,url:c.url||void 0,status:"found"}),m.indices.push(p)}const r=[],s=new Set;for(const p of i.values())if(!(p.volumes.length<2)){p.volumes.sort((c,d)=>c.volume-d.volume),p.base.volumes=p.volumes,p.base.expected_volumes=p.volumes.length,p.base.url||(p.base.url=((a=p.volumes.find(c=>c.url))==null?void 0:a.url)??""),r.push(p.base);for(const c of p.indices)s.add(c)}const l=[...r];for(let p=0;p<e.length;p++)s.has(p)||l.push(e[p]);return l}function wr(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 _r(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||wr(n)}))}function hn(e){const n=_r(e);if(!n)return null;const i=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,r=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:i,missing:r,expected:e.expected_volumes??i+r}}function pi(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 ui(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const r=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(r)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(r[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function Lt(e){if(!e.url)return;const n=pi(e.metadata);return n?ui(e.url,n):e.url}const ao={text:o("restype-text"),image:o("restype-image"),"text+image":o("restype-text-image"),physical:o("restype-physical")};function ea(e){return e.includes("text")&&e.includes("image")?ao["text+image"]:ao[e[0]||"physical"]}const xi=({items:e,groupByType:n=!0,resourceGroups:i,onNavigate:r,renderLink:s})=>{const l=de(),{convert:a}=V(),p=f.useMemo(()=>di(e||[]),[e]),{mirrorGroups:c,ungroupedItems:d}=f.useMemo(()=>{const h=new Map,y=[];for(const j of p){const v=j.group;v?(h.has(v)||h.set(v,[]),h.get(v).push(j)):y.push(j)}for(const j of h.values())j.sort((v,_)=>{const S=$=>$.group_role==="origin"?0:$.group_role==="mirror"?1:2;return S(v)-S(_)});return{mirrorGroups:h,ungroupedItems:y}},[p]),u={text:l.resourceType.text,image:l.resourceType.image,"text+image":l.resourceType.textImage,physical:l.resourceType.physical},g=h=>u[h]?u[h]:h.split("+").map(y=>u[y]||y).join("+");if(!p||p.length===0)return t.jsx("div",{style:{padding:"16px",color:o("desc-fg"),fontSize:"13px",textAlign:"center"},children:l.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:p.map((h,y)=>t.jsx(Tn,{item:h},h.id||y))});const x=(h,y)=>{const j=i==null?void 0:i[h],v=(j==null?void 0:j.label)||h,_=j==null?void 0:j.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${o("widget-border")}`,borderRadius:"6px",background:o("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:o("fg")},children:a(v)}),_&&t.jsx("div",{style:{fontSize:"12px",color:o("desc-fg"),lineHeight:1.5},children:a(_)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:y.map((S,$)=>t.jsx(Tn,{item:S,onNavigate:r,renderLink:s},S.id||$))})]},`group-${h}`)},m=new Map;for(const h of d){const y=ci(yt(h));m.has(y)||m.set(y,[]),m.get(y).push(h)}const b=["text","image","text+image","physical"],k=[...b.filter(h=>m.has(h)),...[...m.keys()].filter(h=>!b.includes(h)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([h,y])=>x(h,y)),k.map(h=>{const y=m.get(h),j=ea(h.split("+"));return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:j,whiteSpace:"nowrap",flexShrink:0},children:g(h)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:y.map((v,_)=>t.jsx(Tn,{item:v,onNavigate:r,renderLink:s},v.id||_))})]},h)})]})},ta={bw:{label:"",bg:o("colormode-bw-bg"),fg:o("colormode-bw-fg")},color:{label:"",bg:o("colormode-color-bg"),fg:o("colormode-color-fg")}},Tn=({item:e})=>{const n=de(),{convert:i}=V(),[r,s]=f.useState(!1),l=f.useMemo(()=>(e.url?Nt(e.url):void 0)||i(e.name),[e.url,e.name,i]),a=f.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(b=>({...b,url:b.url||wr(b)})),[e.volumes]),p=a&&a.length>0,c=p?new Set(a.filter(b=>b.status!=="missing").map(b=>b.volume)).size:0,d=p?new Set(a.filter(b=>b.status==="missing").map(b=>b.volume)).size:0,u=e.expected_volumes??(p?c+d:0),g=e.color_mode?{...ta[e.color_mode],label:n.colorMode[e.color_mode]}:null,x=e.details&&!p?i(e.details):null,m={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${o("widget-border")}`,borderRadius:"5px",background:o("input-bg"),fontSize:"12px",color:o("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:m,children:[t.jsx("span",{style:{fontWeight:500},children:l}),g&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:g.bg,color:g.fg},children:g.label}),x&&t.jsx("span",{style:{fontSize:"11px",color:o("desc-fg")},children:x}),p&&t.jsxs("span",{style:{fontSize:"11px",color:o("desc-fg")},children:[c,"/",u,n.unit.volume,d>0&&t.jsxs("span",{style:{color:o("missing-fg"),marginLeft:"3px"},children:["缺",d]})]}),e.url&&t.jsx("a",{href:(()=>{const b=pi(e.metadata);return b?ui(e.url,b):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:o("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),p&&t.jsx("button",{onClick:()=>s(!r),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:o("desc-fg"),cursor:"pointer",lineHeight:1.4},children:r?"▲":"▼"})]}),p&&r&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${o("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:a.map(b=>{const k=b.status==="missing";return b.url&&!k?t.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${o("widget-border")}`,color:o("link-fg"),textDecoration:"none"},children:b.volume},b.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:o(k?"missing-fg":"desc-fg"),textDecoration:k?"line-through":"none",opacity:k?.6:1},children:b.volume},b.volume)})})]})},$r=({indexSource:e,syncConfig:n,variant:i="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:l,onSelectFolder:a})=>{const p=de(),c=e==="local",d=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",g=u?u.split(/[/\\]/).pop()||u:"",x={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:o("primary-soft"),color:o("primary")},m={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},b=t.jsxs("div",{onClick:s,title:d?p.mode.switchToOfficial:p.mode.switchToDraft,style:{...x,background:o(d?"warning":"success"),color:o("on-color-fg")},...m,children:[t.jsx("span",{children:d?"📝":"📚"}),t.jsx("span",{children:d?"draft":"official"})]});return i==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[b,t.jsxs("div",{onClick:r,title:p.mode.switchToSync,style:x,...m,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:p.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...x,paddingLeft:"8px",paddingRight:"8px"},...m,children:[t.jsx("span",{children:"📂"}),g&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[b,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:r,title:p.mode.switchToLocal,style:x,...m,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:p.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:l,title:g||p.mode.configurePath,style:{...x,background:"transparent",padding:"6px",fontSize:"12px"},...m,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:r,title:c?p.mode.switchToGithub:p.mode.switchToLocal,style:x,...m,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?p.mode.localMode:p.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...x,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...m,children:[t.jsx("span",{children:"📂"}),g&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:g})]}),!c&&g&&t.jsxs("div",{style:{...x,background:o("mode-active-bg"),color:o("on-color-fg"),cursor:"default"},title:u,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:g})]})]})},bn="bim-search-history",co=10,po=8;function Ht(){try{const e=localStorage.getItem(bn);return e?JSON.parse(e):[]}catch{return[]}}function na(e){try{const n=Ht().filter(i=>i!==e);n.unshift(e),n.length>co&&(n.length=co),localStorage.setItem(bn,JSON.stringify(n))}catch{}}function ia(e){try{const n=Ht().filter(i=>i!==e);localStorage.setItem(bn,JSON.stringify(n))}catch{}}function oa(){try{localStorage.removeItem(bn)}catch{}}const zr=({transport:e,value:n,onChange:i,onSearch:r,onEntrySelect:s,placeholder:l})=>{const a=de(),p=l??a.search.placeholder,c={work:a.indexType.work,book:a.indexType.book,collection:a.indexType.collection,entity:a.indexType.entity},[d,u]=f.useState(!1),[g,x]=f.useState([]),[m,b]=f.useState(-1),[k,h]=f.useState(Ht),y=f.useRef(null),j=f.useRef(null),v=f.useRef(null),_=f.useRef(!1);f.useEffect(()=>{b(-1);const I=n.trim();if(!I){x(k.map(M=>({type:"history",text:M})));return}if(!e.searchAll){x([]);return}let O=!1;const A=setTimeout(()=>{e.searchAll(I,po).then(M=>{if(O)return;const F=[...M.works,...M.books,...M.collections,...M.entities??[]];x(F.slice(0,po).map(Y=>({type:"entry",text:Y.title||Y.id,entry:Y})))}).catch(()=>{O||x([])})},80);return()=>{O=!0,clearTimeout(A)}},[n,k,e]),f.useEffect(()=>{const I=O=>{v.current&&!v.current.contains(O.target)&&u(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]),f.useEffect(()=>{const I=O=>{var A,M;if(O.key==="/"&&document.activeElement!==y.current){const F=(A=document.activeElement)==null?void 0:A.tagName;if(F==="INPUT"||F==="TEXTAREA"||F==="SELECT")return;O.preventDefault(),(M=y.current)==null||M.focus()}};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[]);const S=f.useCallback(I=>{I.trim()&&(na(I.trim()),h(Ht())),r(I),u(!1)},[r]),$=f.useCallback(I=>{I.type==="history"?(i(I.text),S(I.text)):I.entry&&(s?(s(I.entry),u(!1)):(i(I.text),S(I.text)))},[i,S,s]),w=f.useCallback(I=>{if(!d||g.length===0){I.key==="Enter"&&S(n);return}switch(I.key){case"ArrowDown":I.preventDefault(),b(O=>(O+1)%g.length);break;case"ArrowUp":I.preventDefault(),b(O=>(O-1+g.length)%g.length);break;case"Enter":I.preventDefault(),m>=0&&m<g.length?$(g[m]):S(n);break;case"Escape":I.preventDefault(),u(!1);break}},[d,g,m,n,S,$]),C=f.useCallback((I,O)=>{O.stopPropagation(),ia(I),h(Ht()),x(A=>A.filter(M=>!(M.type==="history"&&M.text===I)))},[]),N=f.useCallback(I=>{I.stopPropagation(),oa(),h([]),x([])},[]);f.useEffect(()=>{if(m>=0&&j.current){const I=j.current.children;I[m]&&I[m].scrollIntoView({block:"nearest"})}},[m]);const E=!n.trim()&&k.length>0;return t.jsxs("div",{ref:v,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:y,type:"text",placeholder:p,value:n,onChange:I=>{i(I.target.value),u(!0)},onCompositionStart:()=>{_.current=!0},onCompositionEnd:()=>{_.current=!1},onFocus:()=>{u(!0)},onKeyDown:w,style:{width:"100%",padding:"8px 12px",border:`1px solid ${o("input-border")}`,borderRadius:"6px",background:o("input-bg"),color:o("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),d&&g.length>0&&t.jsxs("div",{ref:j,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:o("input-bg"),border:`1px solid ${o("widget-border")}`,borderRadius:"6px",boxShadow:o("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[E&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:o("desc-fg"),borderBottom:`1px solid ${o("widget-border")}`},children:[t.jsx("span",{children:a.search.history}),t.jsx("button",{onClick:N,style:{border:"none",background:"transparent",color:o("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:a.search.clearAll})]}),g.map((I,O)=>t.jsxs("div",{onClick:()=>$(I),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:o("fg"),background:O===m?o("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:I.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:I.text}),I.entry&&t.jsxs("span",{style:{fontSize:"11px",color:o("desc-fg"),flexShrink:0},children:[c[I.entry.type],I.entry.edition&&` · ${I.entry.edition}`,I.entry.author&&` · ${I.entry.author}`]}),I.type==="history"&&t.jsx("button",{onClick:A=>C(I.text,A),style:{border:"none",background:"transparent",color:o("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:a.action.remove,children:"×"})]},`${I.type}-${I.text}-${O}`))]})]})},yn=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:o(`type-${e}`),verticalAlign:"middle"}}),Ct="bim-recent-ids",uo="bim-recent-entries",xo=50,En=5,ra=50,sa=200;function _t(){try{const e=localStorage.getItem(Ct);if(e)return JSON.parse(e);const n=localStorage.getItem(uo);if(n){const i=JSON.parse(n).map(r=>r.id);return localStorage.setItem(Ct,JSON.stringify(i)),localStorage.removeItem(uo),i}return[]}catch{return[]}}function fo(e){try{const n=_t().filter(i=>i!==e);n.unshift(e),n.length>xo&&(n.length=xo),localStorage.setItem(Ct,JSON.stringify(n))}catch{}}function la(e){try{const n=_t().filter(i=>i!==e);localStorage.setItem(Ct,JSON.stringify(n))}catch{}}function aa(){try{localStorage.removeItem(Ct)}catch{}}const go={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Un=({transport:e,indexSource:n="local",syncConfig:i,onEntryClick:r,onNewEntry:s,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c,hideModeIndicator:d,resultVariant:u="compact",renderEntry:g,initialQuery:x,onQueryChange:m,headerRight:b,reserveViewportHeight:k=!1})=>{const h=de(),y=[{type:"work",name:h.indexType.work,key:"works"},{type:"book",name:h.indexType.book,key:"books"},{type:"collection",name:h.indexType.collection,key:"collections"},{type:"entity",name:h.indexType.entity,key:"entities"}],j=["work","collection","book","entity"],[v,_]=f.useState(x??""),[S,$]=f.useState(null),[w,C]=f.useState(null),[N,E]=f.useState("all"),[I,O]=f.useState(!1),[A,M]=f.useState(null),[F,Y]=f.useState(""),[K,R]=f.useState(!(x!=null&&x.trim())),[oe,H]=f.useState(_t),[re,ee]=f.useState([]),[Q,J]=f.useState(!1),[ce,me]=f.useState(!1),[te,ie]=f.useState(null),[pe,ge]=f.useState(null),Ce=f.useRef(void 0),ve=f.useRef(!1),we=f.useCallback(async(L,B)=>{if(!L.trim()){R(!0),$(null),C(null);return}R(!1),O(!0),Y("");try{if(e.searchAll){const G=await e.searchAll(L,B??En);$(G)}else{const G=["work","book","collection","entity"],Z=await Promise.all(G.map(ue=>e.search(L,ue,{page:1,pageSize:B??En})));$({works:Z[0].entries,books:Z[1].entries,collections:Z[2].entries,entities:Z[3].entries,totalWorks:Z[0].total,totalBooks:Z[1].total,totalCollections:Z[2].total,totalEntities:Z[3].total})}}catch(G){Y(G instanceof Error?G.message:String(G)),$(null)}finally{O(!1)}},[e]);f.useEffect(()=>{let L=!1;const B=()=>{var be,Ne;const G=["work","book","collection","entity"],Z=Promise.all(G.map(je=>e.loadEntries(je,{page:1,pageSize:1}).catch(()=>({total:0})))),ue=((be=e.getResourceCounts)==null?void 0:be.call(e).catch(()=>null))??Promise.resolve(null),le=((Ne=e.getSubtypeStats)==null?void 0:Ne.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([Z,ue,le]).then(([je,Pe,at])=>{L||(ie({works:je[0].total,books:je[1].total,collections:je[2].total,entities:je[3].total,hasText:Pe==null?void 0:Pe.hasText,hasImage:Pe==null?void 0:Pe.hasImage}),at&&ge(at))})};return e.getCounts?e.getCounts().then(G=>{var Z,ue;L||(ie({works:G.works,books:G.books,collections:G.collections,entities:G.entities,hasText:(Z=G.resourceCounts)==null?void 0:Z.hasText,hasImage:(ue=G.resourceCounts)==null?void 0:ue.hasImage}),G.subtypeStats&&ge(G.subtypeStats))}).catch(()=>{L||B()}):B(),()=>{L=!0}},[e]),f.useEffect(()=>{ve.current||!(x!=null&&x.trim())||(ve.current=!0,we(x))},[x,we]);const Ee=f.useCallback(L=>{if(_(L),!L.trim()){m==null||m(L),R(!0),$(null),C(null),E("all");return}Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{C(null),E("all"),m==null||m(L),we(L)},sa)},[we,m]),Re=f.useCallback(L=>{Ce.current&&clearTimeout(Ce.current),E("all"),m==null||m(L),we(L)},[we,m]),D=f.useCallback(L=>{C(L),we(v,ra)},[v,we]);f.useEffect(()=>{if(!oe.length){ee([]);return}let L=!1;return J(!0),Promise.all(oe.slice(0,10).map(async B=>{var G,Z,ue;try{if(e.getEntry){const be=await e.getEntry(B);if(be)return be}const le=await e.getItem(B);if(le){const be=le.authors;return{id:B,title:le.title||B,type:le.type||"work",author:(G=be==null?void 0:be[0])==null?void 0:G.name,dynasty:(Z=be==null?void 0:be[0])==null?void 0:Z.dynasty,role:(ue=be==null?void 0:be[0])==null?void 0:ue.role,edition:le.edition||void 0}}}catch{}return{id:B,title:B,type:"work",notFound:!0}})).then(B=>{L||(ee(B),J(!1))}),()=>{L=!0}},[oe,e]);const se=L=>{M(L.id),fo(L.id),H(_t()),r==null||r(L)},ne=(L,B)=>{if(r&&da(B)){B.preventDefault(),se(L);return}fo(L.id),H(_t())},he=L=>{la(L),H(_t())},q=()=>{aa(),H([])},P=L=>y.find(B=>B.type===L),T=!K&&!S&&!F,z=S&&(S.works.length>0||S.books.length>0||S.collections.length>0);return t.jsxs("div",{className:"bim-browser-container",style:k?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:pa}),t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${o("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("h1",{style:{margin:0,fontSize:"18px",color:o("fg")},children:h.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[b,!d&&t.jsx($r,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:l,onToggleDraft:a,onConfigurePath:p,onSelectFolder:c})]})]})}),t.jsxs("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:[t.jsx(zr,{transport:e,value:v,onChange:Ee,onSearch:Re,onEntrySelect:se}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${o("primary")}`,borderRadius:"6px",background:"transparent",color:o("primary"),cursor:"pointer",fontSize:"13px"},children:h.action.newEntry})]}),K&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:o("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:te&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:pe?t.jsxs(t.Fragment,{children:[(pe.book??0)>0&&t.jsxs(t.Fragment,{children:["書 ",t.jsx("strong",{style:{color:o("fg")},children:pe.book.toLocaleString()})," 部 ,",t.jsx("strong",{style:{color:o("fg")},children:te.books.toLocaleString()})," 本"]}),pe.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),"文章 ",t.jsx("strong",{style:{color:o("fg")},children:pe.article.toLocaleString()})," 篇"]}):null,pe.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),"詩詞 ",t.jsx("strong",{style:{color:o("fg")},children:pe.poem.toLocaleString()})," 首"]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),"叢編 ",t.jsx("strong",{style:{color:o("fg")},children:te.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[h.indexType.work," ",t.jsx("strong",{style:{color:o("fg")},children:te.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),h.indexType.book," ",t.jsx("strong",{style:{color:o("fg")},children:te.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),h.indexType.collection," ",t.jsx("strong",{style:{color:o("fg")},children:te.collections.toLocaleString()}),te.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),h.indexType.entity," ",t.jsx("strong",{style:{color:o("fg")},children:te.entities.toLocaleString()})]})]})}),te.hasImage!=null&&te.hasText!=null&&t.jsxs("span",{children:[h.resourceType.image," ",t.jsx("strong",{style:{color:o("fg")},children:te.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),h.resourceType.text," ",t.jsx("strong",{style:{color:o("fg")},children:te.hasText.toLocaleString()})]})]})}),t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:I||T?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:o("desc-fg"),minHeight:ca,boxSizing:"border-box"},children:h.search.searching}):F?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:o("desc-fg")},children:F})}):K?t.jsx("div",{style:{flex:1},children:Q?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:o("desc-fg")},children:h.search.loading}):re.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:o("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:h.search.recentBrowse}),t.jsx("button",{onClick:q,style:{border:"none",background:"transparent",color:o("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:h.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:re.slice(0,ce?10:3).map(L=>L.notFound?t.jsx(ga,{id:L.id,onRemove:he,t:h},L.id):t.jsx(mo,{entry:L,selected:A===L.id,onClick:ne,getConfig:P,onRemove:he},L.id))}),!ce&&re.length>3&&t.jsx("button",{onClick:()=>me(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:o("primary"),background:"transparent",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:h.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:o("fg")},children:h.search.searchTitle}),t.jsx("p",{style:{color:o("desc-fg"),fontSize:"13px"},children:h.search.searchSubtitle})]})}):z?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:ua}),(()=>{const L=le=>S[go[le]]??0,B=j.map(le=>y.find(be=>be.type===le)).filter(le=>L(le.key)>0);if(B.length<2)return null;const G=B.reduce((le,be)=>le+L(be.key),0),Z=le=>{if(E(le),le!=="all"&&w!==le){const be=y.find(je=>je.type===le),Ne=(S[be.key]??[]).length;L(be.key)>Ne&&D(le)}},ue=le=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:o(le?"fg":"desc-fg"),fontWeight:le?700:400,boxShadow:le?`inset 0 -2px 0 ${o("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":h.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${o("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":N==="all",style:ue(N==="all"),onClick:()=>Z("all"),children:[h.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:G.toLocaleString()})]}),B.map(le=>t.jsxs("button",{type:"button","aria-pressed":N===le.type,style:ue(N===le.type),onClick:()=>Z(le.type),children:[le.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:L(le.key).toLocaleString()})]},le.type))]})})(),y.map(({type:L,name:B,key:G})=>{const Z=S[G]??[],ue=go[G],le=S[ue]??0;if(Z.length===0||N!=="all"&&N!==L)return null;const Ne=N==="all"&&!(w===L)&&le>En;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${o("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:o("fg")},children:[t.jsx(yn,{type:L})," ",B,t.jsxs("span",{style:{fontWeight:400,color:o("desc-fg"),marginLeft:"6px"},children:[le," ",h.unit.items]})]}),Ne&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>D(L),style:{border:"none",background:"transparent",color:o("primary"),cursor:"pointer",fontSize:"12px"},children:h.action.viewAll})]}),t.jsx("div",{style:u==="list"?{display:"flex",flexDirection:"column",gap:0}:u==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:Z.map(je=>{if(g)return t.jsx(f.Fragment,{children:g(je)},je.id);const Pe=u==="card"?fa:mo;return t.jsx(Pe,{entry:je,selected:A===je.id,onClick:ne,getConfig:P,query:v},je.id)})})]},L)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:o("fg")},children:Kt(h.search.noResultsFor,{query:v})}),t.jsx("p",{style:{color:o("desc-fg"),fontSize:"13px"},children:h.search.tryOther})]})})]})},ca=240;function da(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const pa=`
|
|
1
|
+
"use strict";var wl=Object.create;var so=Object.defineProperty;var Sl=Object.getOwnPropertyDescriptor;var _l=Object.getOwnPropertyNames;var $l=Object.getPrototypeOf,zl=Object.prototype.hasOwnProperty;var Cl=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of _l(n))!zl.call(e,s)&&s!==o&&so(e,s,{get:()=>n[s],enumerable:!(r=Sl(n,s))||r.enumerable});return e};var cn=(e,n,o)=>(o=e!=null?wl($l(e)):{},Cl(n||!e||!e.__esModule?so(o,"default",{value:e,enumerable:!0}):o,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const we=require("./storage-entry-BLfpDWdl.cjs"),t=require("react/jsx-runtime"),g=require("react"),Il=require("opencc-js/t2cn"),Tl=require("react-markdown"),El=require("remark-gfm"),Rl=e=>`/book-index?id=${e}`,br=g.createContext(Rl);function Nl({buildUrl:e,children:n}){const o=g.useMemo(()=>e,[e]);return t.jsx(br.Provider,{value:o,children:n})}function Pe(){return g.useContext(br)}const yr="",jr="";function vr(e){const n=[];let o=!1,r=e;for(;r.length;){const s=o?jr:yr,l=r.indexOf(s);if(l===-1){n.push({text:r,marked:o});break}l>0&&n.push({text:r.slice(0,l),marked:o}),r=r.slice(l+1),o=!o}return n}function He(e,n){return{title:e,tokens:n}}const lo='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',Ll=[He("基础(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"}}),He("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),He("提示与警告",{"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)"}}),He("遮罩与阴影",{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)"}}),He("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),He("资源",{"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"}}),He("整理本(CollatedEdition)",{"highlight-bg":{value:"#fff59d",note:"搜索命中高亮底"},"highlight-fg":{value:"inherit",root:!1},"section-lei":{value:"#8e6f3e",note:"章节类型标记:类 / 书 / 序 / 结语 / 考证 / 注释"},"section-shu":{value:"#c0392b"},"section-xu":{value:"#1a5276"},"section-jieyu":{value:"#7d6608"},"section-kaozhen":{value:"#5d6d7e"},"section-zhushi":{value:"#6c5b7b"},"section-tag-fg":{value:"#e74c3c",note:"章节标记(△ 等)"},"matchstate-fg":{value:"#b78900",note:"与底本匹配状态提示"},"quality-published":{value:"#1b5e20",note:"文本质量等级(出版 / 精校 / 粗校 / OCR)"},"quality-fine":{value:"#2e7d32"},"quality-rough":{value:"#1565c0"},"quality-ocr":{value:"#e65100"}}),He("版本传承(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"}}),He("编辑器视图(主要在 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")'}}),He("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --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:"主题切换控件的色点:靛蓝"},"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}}),He("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"}}),He("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),He("字体(全站无衬线,2026-09-05 定)",{"font-ui":{value:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif'},"font-body":{value:"system-ui, sans-serif",css:"var(--bim-font-ui)"},"font-serif":{value:lo,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:lo,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],Bl=Object.assign({},...Ll.map(e=>e.tokens)),kr={};for(const[e,n]of Object.entries(Bl))kr[e]=`var(--bim-${e}, ${n.value})`;function i(e){const n=kr[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:e.type?e.type==="text+image"?["text","image"]:[e.type]:[]}function Al(e,n){return yt(e).includes(n)}const Hn={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"},Wl={published:"達到出版、學術研究標準,錯誤率在萬分之一以內",fine:"通讀無障礙,錯誤率在百分之一以內",rough:"保證文意基本正確,錯誤率在百分之三以內",ocr:"保持大意和結構,錯誤率在百分之十以內"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Rt=g.createContext(null),wr={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("check-ai-fg")}},action:{save:"保存",delete:"刪除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"訪問 →",view:"查看 →",viewEntity:"查看",copy:"複製 ID",copied:"已複製",linkExisting:"+ 關聯現有",createAndLink:"+ 創建並關聯",remove:"刪除",clearAll:"清除全部",reselect:"重選",changeType:"更換類型",expand:"展開",collapse:"收起",expandMore:"展開更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加書籍",addSubCollection:"添加子叢編",addCollectionImpl:"添加叢編實現",addSource:"添加來源",addResource:"添加資源",addIndexedBy:"+ 添加收錄來源",addEmendatedBy:"+ 添加考證來源",addAdditionalWork:"+ 添加附屬作品",selectBookOrWork:"選擇書籍/作品",clickToSelectBookOrWork:"點擊選擇書籍/作品",unlink:"解除關聯"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷數",pageCount:"頁數 (Pages)",volumeCount:"冊數 (Volumes)",holder:"現藏於 (Holder)",firstImage:"首頁圖片 (First Image URL)",year:"年代",currentLocation:"現藏",parentWork:"上級作品",relatedWorks:"相關作品",type:"類型",rootType:"根類型",coverageLevel:"覆蓋層級",coverageRange:"覆蓋範圍",metadata:"元數據",optionalInfo:"可選信息",details:"詳細說明",detailsOptional:"詳細說明 (可選)",positionOptional:"位置/頁碼 (可選)",dataVersionOptional:"數據版本 (可選)",processorVersionOptional:"處理器版本 (可選)",sourceName:"來源名稱",sourceBid:"來源 BID",titleInfo:"題名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介紹 (Description)",additionalWorks:"📑 附屬作品 (Additional Works)",indexedBy:"📖 著錄於",emendatedBy:"📝 考證",resources:"資源",textResources:"📝 文字資源 (Text Resources)",imageResources:"🖼️ 圖片資源 (Image Resources)",sources:"📚 資料來源 (Sources)",provenance:"📜 收藏歷史 (Provenance)",relatedVersions:"相關版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危險區域 (Danger Zone)",aliases:"別名",attachedTexts:"附載篇目",appendix:"附錄",containedIn:"收入叢編",collectedIn:"收入叢編",belongsToWork:"所屬作品",locationHistory:"流轉歷史",historyOverview:"歷史沿革",containedBooks:"收錄書籍",relations:"關聯關係",summary:"提要",comment:"按語",additionalComment:"附按",indexed:"收錄於",emendated:"考證",relatedWorks:"相關作品",containedWorks:"包含作品",adaptations:"改編作品",derivativeWorks:"續書與評註",studies:"所考典籍"},relation:{belongsToWork:"所屬作品 (Work)",containedInCollection:"收入叢編",siblingVersions:"同作品其他版本",addVersionForWork:"為此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"叢編實現",allVersions:"所有版本",correspondingWork:"對應作品 (Work)",parentCollection:"父叢編 (Parent Collection)",childCollections:"子叢編",containedBooks:"包含書籍",notLinked:"(未關聯)",none:"(暫無)"},search:{placeholder:"搜索作品、書籍、叢編...",searching:"搜索中...",loading:"加載中...",noResults:"無匹配結果",noResultsFor:"未找到與「{query}」相關的結果",tryOther:"試試其他關鍵詞、別名或作者名",recentBrowse:"最近瀏覽",history:"搜索歷史",clearAll:"清除全部",clearRecent:"清除最近瀏覽",itemNotFound:"無法找到,可能已刪除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"結果分類",searchSubtitle:"輸入關鍵詞搜索作品、書籍或叢編",searchBookName:"搜索書名...",alias:"別名"},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:"圖片資源"}},Ml={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("check-ai-fg")}},action:{save:"保存",delete:"删除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"访问 →",view:"查看 →",viewEntity:"查看",copy:"复制 ID",copied:"已复制",linkExisting:"+ 关联现有",createAndLink:"+ 创建并关联",remove:"删除",clearAll:"清除全部",reselect:"重选",changeType:"更换类型",expand:"展开",collapse:"收起",expandMore:"展开更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加书籍",addSubCollection:"添加子丛编",addCollectionImpl:"添加丛编实现",addSource:"添加来源",addResource:"添加资源",addIndexedBy:"+ 添加收录来源",addEmendatedBy:"+ 添加考证来源",addAdditionalWork:"+ 添加附属作品",selectBookOrWork:"选择书籍/作品",clickToSelectBookOrWork:"点击选择书籍/作品",unlink:"解除关联"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷数",pageCount:"页数 (Pages)",volumeCount:"册数 (Volumes)",holder:"现藏于 (Holder)",firstImage:"首页图片 (First Image URL)",year:"年代",currentLocation:"现藏",parentWork:"上级作品",relatedWorks:"相关作品",type:"类型",rootType:"根类型",coverageLevel:"覆盖层级",coverageRange:"覆盖范围",metadata:"元数据",optionalInfo:"可选信息",details:"详细说明",detailsOptional:"详细说明 (可选)",positionOptional:"位置/页码 (可选)",dataVersionOptional:"数据版本 (可选)",processorVersionOptional:"处理器版本 (可选)",sourceName:"来源名称",sourceBid:"来源 BID",titleInfo:"题名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介绍 (Description)",additionalWorks:"📑 附属作品 (Additional Works)",indexedBy:"📖 著录于",emendatedBy:"📝 考证",resources:"资源",textResources:"📝 文字资源 (Text Resources)",imageResources:"🖼️ 图片资源 (Image Resources)",sources:"📚 资料来源 (Sources)",provenance:"📜 收藏历史 (Provenance)",relatedVersions:"相关版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危险区域 (Danger Zone)",aliases:"别名",attachedTexts:"附载篇目",appendix:"附录",containedIn:"收入丛编",collectedIn:"收入丛编",belongsToWork:"所属作品",locationHistory:"流转历史",historyOverview:"历史沿革",containedBooks:"收录书籍",relations:"关联关系",summary:"提要",comment:"按语",additionalComment:"附按",indexed:"收录于",emendated:"考证",relatedWorks:"相关作品",containedWorks:"包含作品",adaptations:"改编作品",derivativeWorks:"续书与评注",studies:"所考典籍"},relation:{belongsToWork:"所属作品 (Work)",containedInCollection:"收入丛编",siblingVersions:"同作品其他版本",addVersionForWork:"为此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"丛编实现",allVersions:"所有版本",correspondingWork:"对应作品 (Work)",parentCollection:"父丛编 (Parent Collection)",childCollections:"子丛编",containedBooks:"包含书籍",notLinked:"(未关联)",none:"(暂无)"},search:{placeholder:"搜索作品、书籍、丛编...",searching:"搜索中...",loading:"加载中...",noResults:"无匹配结果",noResultsFor:"未找到与「{query}」相关的结果",tryOther:"试试其他关键词、别名或作者名",recentBrowse:"最近浏览",history:"搜索历史",clearAll:"清除全部",clearRecent:"清除最近浏览",itemNotFound:"无法找到,可能已删除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"结果分类",searchSubtitle:"输入关键词搜索作品、书籍或丛编",searchBookName:"搜索书名...",alias:"别名"},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:"图片资源"}},Fl=["曹霑"];function Pl(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ol(e,n=Fl){const o=[...new Set(n.filter(Boolean))].sort((l,d)=>d.length-l.length);if(!o.length)return e;const r=new RegExp(`(${o.map(Pl).join("|")})`,"g"),s=new Set(o);return l=>{if(!l)return e(l);const d=l.split(r);return d.length===1?e(l):d.map((p,c)=>c%2===1&&s.has(p)?p:p&&e(p)).join("")}}let At=null;function Dl(){if(At)return At;try{At=Ol(Il.Converter({from:"tw",to:"cn"}))}catch{At=e=>e}return At}const Hl={"zh-Hant":wr,"zh-Hans":Ml},Sr="bim-locale";function Gl(){try{const e=localStorage.getItem(Sr);if(e==="zh-Hant"||e==="zh-Hans")return e}catch{}}function Ul(e){try{localStorage.setItem(Sr,e)}catch{}}const Vl="zh-Hans",Yl=({locale:e,onLocaleChange:n,converter:o,children:r})=>{const[s,l]=g.useState(e??Vl),d=e??s;g.useEffect(()=>{if(e)return;const u=Gl();u&&u!==s&&l(u)},[]);const p=g.useMemo(()=>d==="zh-Hans"?o??Dl():null,[d,o]),c=g.useCallback(u=>{l(u),Ul(u),n==null||n(u)},[n]),a=g.useMemo(()=>({locale:d,setLocale:c,messages:Hl[d],converter:p}),[d,c,p]);return t.jsx(Rt.Provider,{value:a,children:r})};function ue(){const e=g.useContext(Rt);return(e==null?void 0:e.messages)??wr}const ql=2e3;function Z(){const e=g.useContext(Rt),n=(e==null?void 0:e.locale)??"zh-Hant",o=(e==null?void 0:e.converter)??null,r=g.useRef(new Map),s=g.useRef(n);s.current!==n&&(r.current.clear(),s.current=n);const l=g.useCallback(d=>{if(!d)return"";if(!o)return d;const p=r.current.get(d);if(p!==void 0)return p;const c=o(d);if(r.current.size>=ql){const a=r.current.keys().next().value;a!==void 0&&r.current.delete(a)}return r.current.set(d,c),c},[o]);return g.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function Jt(e,n){return e.replace(/\{(\w+)\}/g,(o,r)=>String(n[r]??""))}function Kl(e){if(!e)return"";try{const n=new URL(e).hostname,o={"zh.wikisource.org":"wikisource","www.shidianguji.com":"shidianguji","shidianguji.com":"shidianguji","archive.org":"archive","ctext.org":"ctext","read.nlc.cn":"nlc","www.digital.archives.go.jp":"japan_archives"};if(o[n])return o[n];const r=n.split(".");return r.length>=2?r[r.length-2]:n}catch{return""}}function Jl(){return{id:"",name:"",url:"",type:"text",details:""}}const Gn=({items:e,onChange:n,onDownload:o,downloadStatuses:r,filterType:s})=>{const l=ue(),[d,p]=g.useState(null),c=[{value:"text",label:l.resourceTypeShort.text},{value:"image",label:l.resourceTypeShort.image},{value:"text+image",label:l.resourceTypeShort.textImage},{value:"physical",label:l.resourceTypeShort.physical}],a=[{value:"catalog",label:l.rootType.catalog},{value:"search",label:l.rootType.search}],u=y=>{if(!s)return!0;const k=yt(y);return s==="text"?k.includes("text"):s==="image"?k.includes("image")||k.includes("physical"):s==="physical"?k.includes("physical"):k.includes(s)},f=e.map((y,k)=>({item:y,originalIndex:k})).filter(({item:y})=>u(y)),x=()=>{const y=Jl();s&&(y.type=s),n([...e,y]),p(e.length)},m=y=>{n(e.filter((k,$)=>$!==y)),p(null)},j=(y,k,$)=>{const v=[...e];if(v[y]={...v[y],[k]:$},k==="url"&&!v[y].id){const _=Kl($);_&&(v[y].id=_)}n(v)},w=(y,k,$)=>{const _={...e[y].metadata||{}};$?_[k]=$:delete _[k],j(y,"metadata",Object.keys(_).length>0?_:void 0)},h=(y,k)=>{const $=k.trim()?k.split(/[,,、]/).map(v=>v.trim()).filter(Boolean):void 0;j(y,"structure",$)},b=(y,k,$)=>{const _=e[y].coverage||{level:1,ranges:""};k==="level"?_.level=parseInt($)||1:_.ranges=$,j(y,"coverage",_.ranges?_:void 0)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[f.map(({item:y,originalIndex:k})=>{var $,v,_;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(d===k?null:k),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:d===k?"▼":"▶"}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:Zl(y.type??"text"),color:i("on-color-fg")},children:(()=>{var z,N;const S=yt(y);return S.length===0?y.type??"text":S.length===1?((z=c.find(T=>T.value===S[0]))==null?void 0:z.label)??S[0]:S.includes("text")&&S.includes("image")?((N=c.find(T=>T.value==="text+image"))==null?void 0:N.label)??"text+image":S.join("+")})()}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:y.name||`${l.editor.resourcePlaceholder} ${k+1}`}),y.id&&t.jsx("span",{style:{fontSize:"11px",opacity:.5},children:y.id}),y.url&&t.jsx("a",{href:y.url,target:"_blank",rel:"noopener noreferrer",onClick:S=>S.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),o&&y.url&&Xl(k,r==null?void 0:r[k],o,l),t.jsx("button",{onClick:S=>{S.stopPropagation(),m(k)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),d===k&&t.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[Al(y,"image")&&y.url&&Ql(y,l),t.jsxs("div",{style:{display:"grid",gap:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Wt,children:[t.jsx("span",{style:Mt,children:l.label.type}),t.jsx("select",{value:y.type,onChange:S=>j(k,"type",S.target.value),style:{...tt,flex:1},children:c.map(S=>t.jsx("option",{value:S.value,children:S.label},S.value))})]}),t.jsxs("label",{style:Wt,children:[t.jsx("span",{style:Mt,children:l.label.rootType}),t.jsx("select",{value:y.root_type||"catalog",onChange:S=>j(k,"root_type",S.target.value),style:{...tt,flex:1},children:a.map(S=>t.jsx("option",{value:S.value,children:S.label},S.value))})]})]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("input",{type:"text",value:y.id,onChange:S=>j(k,"id",S.target.value),placeholder:l.editor.idAutoExtract,style:{...tt,width:"140px",flexShrink:0}}),t.jsx("input",{type:"text",value:y.name,onChange:S=>j(k,"name",S.target.value),placeholder:l.editor.resourceName,style:{...tt,flex:1}})]}),t.jsx("input",{type:"text",value:y.url,onChange:S=>j(k,"url",S.target.value),placeholder:l.editor.resourceUrl,style:tt}),t.jsx("input",{type:"text",value:(($=y.structure)==null?void 0:$.join("、"))||"",onChange:S=>h(k,S.target.value),placeholder:l.editor.structurePlaceholder,style:tt}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("label",{style:Wt,children:[t.jsx("span",{style:Mt,children:l.label.coverageLevel}),t.jsx("input",{type:"number",min:1,value:((v=y.coverage)==null?void 0:v.level)??"",onChange:S=>b(k,"level",S.target.value),placeholder:"1",style:{...tt,width:"60px"}})]}),t.jsxs("label",{style:{...Wt,flex:1},children:[t.jsx("span",{style:Mt,children:l.label.coverageRange}),t.jsx("input",{type:"text",value:((_=y.coverage)==null?void 0:_.ranges)||"",onChange:S=>b(k,"ranges",S.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...tt,flex:1}})]})]}),t.jsx("textarea",{value:y.details||"",onChange:S=>j(k,"details",S.target.value),placeholder:l.editor.detailsPlaceholder,style:{...tt,minHeight:"60px",resize:"vertical"}}),t.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:l.label.metadata}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([S,z])=>{var N;return t.jsxs("label",{style:{...Wt,gap:"4px"},children:[t.jsx("span",{style:{...Mt,minWidth:"56px"},children:z}),t.jsx("input",{type:"text",value:((N=y.metadata)==null?void 0:N[S])||"",onChange:T=>w(k,S,T.target.value),placeholder:z,style:{...tt,flex:1}})]},S)})})]})]})]})]},k)}),t.jsxs("button",{onClick:x,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:l.action.addResource})]})]})};function Zl(e){switch(e){case"text":return i("restype-text");case"image":return i("restype-image");case"text+image":return i("restype-text-image");case"physical":return i("restype-physical")}}function Xl(e,n,o,r){const s=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return t.jsx("button",{onClick:d=>{d.stopPropagation(),s||o(e,"")},disabled:s,style:{background:"transparent",border:"none",color:i(l?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:l?r.download.completed:s?`${r.download.downloading} ${(n==null?void 0:n.progress)||0}%`:r.download.downloadThis,children:l?"✓":s?"⏳":"⬇"})}function Ql(e,n){const o=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.url)||e.url.includes("iiif")||e.url.includes("image");return t.jsx("div",{style:{marginBottom:"12px"},children:o?t.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:t.jsx("img",{src:e.url,alt:e.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:r=>{r.target.style.display="none"}})}):t.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const tt={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Wt={display:"flex",alignItems:"center",gap:"6px"},Mt={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},ea={"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 Nt(e){try{return ea[new URL(e).hostname]}catch{return}}const ao={text:0,image:1,physical:2};function di(e){return e.length===0?"physical":[...e].sort((n,o)=>(ao[n]??99)-(ao[o]??99)).join("+")}function pi(e){var d;const n=p=>{const c=p.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const a=p.match(/^(.+?)[·(](\d+)[)]?$/);return a?[a[1],parseInt(a[2])]:null},o=new Map;for(let p=0;p<e.length;p++){const c=e[p];if(c.volumes&&c.volumes.length>0)continue;const a=n(c.name);if(!a)continue;const[u,f]=a,x=`${u}|${di(yt(c))}`;o.has(x)||o.set(x,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const m=o.get(x);m.volumes.push({volume:f,url:c.url||void 0,status:"found"}),m.indices.push(p)}const r=[],s=new Set;for(const p of o.values())if(!(p.volumes.length<2)){p.volumes.sort((c,a)=>c.volume-a.volume),p.base.volumes=p.volumes,p.base.expected_volumes=p.volumes.length,p.base.url||(p.base.url=((d=p.volumes.find(c=>c.url))==null?void 0:d.url)??""),r.push(p.base);for(const c of p.indices)s.add(c)}const l=[...r];for(let p=0;p<e.length;p++)s.has(p)||l.push(e[p]);return l}function _r(e){if(e.url)return e.url;for(const[n,o]of Object.entries(e))if(n.endsWith("_url")&&typeof o=="string")return o}function $r(e){return!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(n=>({...n,url:n.url||_r(n)}))}function yn(e){const n=$r(e);if(!n)return null;const o=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,r=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:o,missing:r,expected:e.expected_volumes??o+r}}function ui(e){if(!e)return;const n=e.file_page_range||e.page_range;if(!n||typeof n!="string")return;const o=n.match(/^(\d+)/);return o?parseInt(o[1],10):void 0}function xi(e,n){try{if(new URL(e).hostname.includes("wikimedia.org")){const r=e.match(/\/wiki\/File:(.+?)(?:#|$)/);if(r)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(r[1]))}&page=${n}`;const s=new URL(e);return s.searchParams.set("page",String(n)),s.toString()}return e}catch{return e}}function Lt(e){if(!e.url)return;const n=ui(e.metadata);return n?xi(e.url,n):e.url}const co={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function ta(e){return e.includes("text")&&e.includes("image")?co["text+image"]:co[e[0]||"physical"]}const fi=({items:e,groupByType:n=!0,resourceGroups:o,onNavigate:r,renderLink:s})=>{const l=ue(),{convert:d}=Z(),p=g.useMemo(()=>pi(e||[]),[e]),{mirrorGroups:c,ungroupedItems:a}=g.useMemo(()=>{const h=new Map,b=[];for(const y of p){const k=y.group;k?(h.has(k)||h.set(k,[]),h.get(k).push(y)):b.push(y)}for(const y of h.values())y.sort((k,$)=>{const v=_=>_.group_role==="origin"?0:_.group_role==="mirror"?1:2;return v(k)-v($)});return{mirrorGroups:h,ungroupedItems:b}},[p]),u={text:l.resourceType.text,image:l.resourceType.image,"text+image":l.resourceType.textImage,physical:l.resourceType.physical},f=h=>u[h]?u[h]:h.split("+").map(b=>u[b]||b).join("+");if(!p||p.length===0)return t.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:l.misc.noResources});if(!n)return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:p.map((h,b)=>t.jsx(En,{item:h},h.id||b))});const x=(h,b)=>{const y=o==null?void 0:o[h],k=(y==null?void 0:y.label)||h,$=y==null?void 0:y.description;return t.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:d(k)}),$&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:d($)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:b.map((v,_)=>t.jsx(En,{item:v,onNavigate:r,renderLink:s},v.id||_))})]},`group-${h}`)},m=new Map;for(const h of a){const b=di(yt(h));m.has(b)||m.set(b,[]),m.get(b).push(h)}const j=["text","image","text+image","physical"],w=[...j.filter(h=>m.has(h)),...[...m.keys()].filter(h=>!j.includes(h)).sort()];return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([h,b])=>x(h,b)),w.map(h=>{const b=m.get(h),y=ta(h.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:f(h)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:b.map((k,$)=>t.jsx(En,{item:k,onNavigate:r,renderLink:s},k.id||$))})]},h)})]})},na={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},En=({item:e})=>{const n=ue(),{convert:o}=Z(),[r,s]=g.useState(!1),l=g.useMemo(()=>(e.url?Nt(e.url):void 0)||o(e.name),[e.url,e.name,o]),d=g.useMemo(()=>!Array.isArray(e.volumes)||e.volumes.length===0?null:e.volumes.map(j=>({...j,url:j.url||_r(j)})),[e.volumes]),p=d&&d.length>0,c=p?new Set(d.filter(j=>j.status!=="missing").map(j=>j.volume)).size:0,a=p?new Set(d.filter(j=>j.status==="missing").map(j=>j.volume)).size:0,u=e.expected_volumes??(p?c+a:0),f=e.color_mode?{...na[e.color_mode],label:n.colorMode[e.color_mode]}:null,x=e.details&&!p?o(e.details):null,m={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",background:i("input-bg"),fontSize:"12px",color:i("fg"),lineHeight:1.4,verticalAlign:"middle"};return t.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[t.jsxs("div",{style:m,children:[t.jsx("span",{style:{fontWeight:500},children:l}),f&&t.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:f.bg,color:f.fg},children:f.label}),x&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:x}),p&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,a>0&&t.jsxs("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:["缺",a]})]}),e.url&&t.jsx("a",{href:(()=>{const j=ui(e.metadata);return j?xi(e.url,j):e.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),p&&t.jsx("button",{onClick:()=>s(!r),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",lineHeight:1.4},children:r?"▲":"▼"})]}),p&&r&&t.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:d.map(j=>{const w=j.status==="missing";return j.url&&!w?t.jsx("a",{href:j.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",borderRadius:"3px",border:`1px solid ${i("widget-border")}`,color:i("link-fg"),textDecoration:"none"},children:j.volume},j.volume):t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(w?"missing-fg":"desc-fg"),textDecoration:w?"line-through":"none",opacity:w?.6:1},children:j.volume},j.volume)})})]})},zr=({indexSource:e,syncConfig:n,variant:o="index-browser",onSwitchMode:r,onToggleDraft:s,onConfigurePath:l,onSelectFolder:d})=>{const p=ue(),c=e==="local",a=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",f=u?u.split(/[/\\]/).pop()||u:"",x={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},m={onMouseOver:w=>w.currentTarget.style.opacity="0.8",onMouseOut:w=>w.currentTarget.style.opacity="1"},j=t.jsxs("div",{onClick:s,title:a?p.mode.switchToOfficial:p.mode.switchToDraft,style:{...x,background:i(a?"warning":"success"),color:i("on-color-fg")},...m,children:[t.jsx("span",{children:a?"📝":"📚"}),t.jsx("span",{children:a?"draft":"official"})]});return o==="index-browser"?c?t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[j,t.jsxs("div",{onClick:r,title:p.mode.switchToSync,style:x,...m,children:[t.jsx("span",{children:"📁"}),t.jsx("span",{children:p.mode.localMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsxs("div",{onClick:d,title:u||p.mode.selectFolder,style:{...x,paddingLeft:"8px",paddingRight:"8px"},...m,children:[t.jsx("span",{children:"📂"}),f&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:f})]})]}):t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[j,t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsxs("div",{onClick:r,title:p.mode.switchToLocal,style:x,...m,children:[t.jsx("span",{children:"🌐"}),t.jsx("span",{children:p.mode.syncMode}),t.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),t.jsx("div",{onClick:l,title:f||p.mode.configurePath,style:{...x,background:"transparent",padding:"6px",fontSize:"12px"},...m,children:t.jsx("span",{children:"⚙️"})})]})]}):t.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[t.jsxs("div",{onClick:r,title:c?p.mode.switchToGithub:p.mode.switchToLocal,style:x,...m,children:[t.jsx("span",{children:c?"📁":"🌐"}),t.jsx("span",{children:c?p.mode.localMode:p.mode.githubSync}),t.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&t.jsxs("div",{onClick:d,title:u||p.mode.selectFolder,style:{...x,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...m,children:[t.jsx("span",{children:"📂"}),f&&t.jsx("span",{style:{fontSize:"11px",opacity:.9},children:f})]}),!c&&f&&t.jsxs("div",{style:{...x,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[t.jsx("span",{children:"📂"}),t.jsx("span",{style:{fontSize:"11px"},children:f})]})]})},jn="bim-search-history",po=10,uo=8;function Gt(){try{const e=localStorage.getItem(jn);return e?JSON.parse(e):[]}catch{return[]}}function ia(e){try{const n=Gt().filter(o=>o!==e);n.unshift(e),n.length>po&&(n.length=po),localStorage.setItem(jn,JSON.stringify(n))}catch{}}function oa(e){try{const n=Gt().filter(o=>o!==e);localStorage.setItem(jn,JSON.stringify(n))}catch{}}function ra(){try{localStorage.removeItem(jn)}catch{}}const Cr=({transport:e,value:n,onChange:o,onSearch:r,onEntrySelect:s,placeholder:l})=>{const d=ue(),p=l??d.search.placeholder,c={work:d.indexType.work,book:d.indexType.book,collection:d.indexType.collection,entity:d.indexType.entity},[a,u]=g.useState(!1),[f,x]=g.useState([]),[m,j]=g.useState(-1),[w,h]=g.useState(Gt),b=g.useRef(null),y=g.useRef(null),k=g.useRef(null),$=g.useRef(!1);g.useEffect(()=>{j(-1);const C=n.trim();if(!C){x(w.map(O=>({type:"history",text:O})));return}if(!e.searchAll){x([]);return}let D=!1;const B=setTimeout(()=>{e.searchAll(C,uo).then(O=>{if(D)return;const M=[...O.works,...O.books,...O.collections,...O.entities??[]];x(M.slice(0,uo).map(X=>({type:"entry",text:X.title||X.id,entry:X})))}).catch(()=>{D||x([])})},80);return()=>{D=!0,clearTimeout(B)}},[n,w,e]),g.useEffect(()=>{const C=D=>{k.current&&!k.current.contains(D.target)&&u(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[]),g.useEffect(()=>{const C=D=>{var B,O;if(D.key==="/"&&document.activeElement!==b.current){const M=(B=document.activeElement)==null?void 0:B.tagName;if(M==="INPUT"||M==="TEXTAREA"||M==="SELECT")return;D.preventDefault(),(O=b.current)==null||O.focus()}};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const v=g.useCallback(C=>{C.trim()&&(ia(C.trim()),h(Gt())),r(C),u(!1)},[r]),_=g.useCallback(C=>{C.type==="history"?(o(C.text),v(C.text)):C.entry&&(s?(s(C.entry),u(!1)):(o(C.text),v(C.text)))},[o,v,s]),S=g.useCallback(C=>{if(!a||f.length===0){C.key==="Enter"&&v(n);return}switch(C.key){case"ArrowDown":C.preventDefault(),j(D=>(D+1)%f.length);break;case"ArrowUp":C.preventDefault(),j(D=>(D-1+f.length)%f.length);break;case"Enter":C.preventDefault(),m>=0&&m<f.length?_(f[m]):v(n);break;case"Escape":C.preventDefault(),u(!1);break}},[a,f,m,n,v,_]),z=g.useCallback((C,D)=>{D.stopPropagation(),oa(C),h(Gt()),x(B=>B.filter(O=>!(O.type==="history"&&O.text===C)))},[]),N=g.useCallback(C=>{C.stopPropagation(),ra(),h([]),x([])},[]);g.useEffect(()=>{if(m>=0&&y.current){const C=y.current.children;C[m]&&C[m].scrollIntoView({block:"nearest"})}},[m]);const T=!n.trim()&&w.length>0;return t.jsxs("div",{ref:k,style:{position:"relative",flex:1},children:[t.jsx("input",{ref:b,type:"text",placeholder:p,value:n,onChange:C=>{o(C.target.value),u(!0)},onCompositionStart:()=>{$.current=!0},onCompositionEnd:()=>{$.current=!1},onFocus:()=>{u(!0)},onKeyDown:S,style:{width:"100%",padding:"8px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"14px",boxSizing:"border-box"}}),a&&f.length>0&&t.jsxs("div",{ref:y,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:i("input-bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"6px",boxShadow:i("shadow-dropdown"),zIndex:100,maxHeight:"320px",overflow:"auto"},children:[T&&t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:i("desc-fg"),borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("span",{children:d.search.history}),t.jsx("button",{onClick:N,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:d.search.clearAll})]}),f.map((C,D)=>t.jsxs("div",{onClick:()=>_(C),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:D===m?i("list-active-bg"):"transparent"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:C.type==="history"?"🕐":"🔍"}),t.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C.text}),C.entry&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[C.entry.type],C.entry.edition&&` · ${C.entry.edition}`,C.entry.author&&` · ${C.entry.author}`]}),C.type==="history"&&t.jsx("button",{onClick:B=>z(C.text,B),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:d.action.remove,children:"×"})]},`${C.type}-${C.text}-${D}`))]})]})},vn=({type:e,size:n=9})=>t.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${e}`),verticalAlign:"middle"}}),Ct="bim-recent-ids",xo="bim-recent-entries",fo=50,Rn=5,sa=50,la=200;function _t(){try{const e=localStorage.getItem(Ct);if(e)return JSON.parse(e);const n=localStorage.getItem(xo);if(n){const o=JSON.parse(n).map(r=>r.id);return localStorage.setItem(Ct,JSON.stringify(o)),localStorage.removeItem(xo),o}return[]}catch{return[]}}function go(e){try{const n=_t().filter(o=>o!==e);n.unshift(e),n.length>fo&&(n.length=fo),localStorage.setItem(Ct,JSON.stringify(n))}catch{}}function aa(e){try{const n=_t().filter(o=>o!==e);localStorage.setItem(Ct,JSON.stringify(n))}catch{}}function ca(){try{localStorage.removeItem(Ct)}catch{}}const mo={works:"totalWorks",books:"totalBooks",collections:"totalCollections",entities:"totalEntities"},Un=({transport:e,indexSource:n="local",syncConfig:o,onEntryClick:r,onNewEntry:s,onSwitchMode:l,onToggleDraft:d,onConfigurePath:p,onSelectFolder:c,hideModeIndicator:a,resultVariant:u="compact",renderEntry:f,initialQuery:x,onQueryChange:m,headerRight:j,reserveViewportHeight:w=!1})=>{const h=ue(),b=[{type:"work",name:h.indexType.work,key:"works"},{type:"book",name:h.indexType.book,key:"books"},{type:"collection",name:h.indexType.collection,key:"collections"},{type:"entity",name:h.indexType.entity,key:"entities"}],y=["work","collection","book","entity"],[k,$]=g.useState(x??""),[v,_]=g.useState(null),[S,z]=g.useState(null),[N,T]=g.useState("all"),[C,D]=g.useState(!1),[B,O]=g.useState(null),[M,X]=g.useState(""),[Y,E]=g.useState(!(x!=null&&x.trim())),[ee,F]=g.useState(_t),[q,ae]=g.useState([]),[ne,Q]=g.useState(!1),[ie,ge]=g.useState(!1),[re,le]=g.useState(null),[pe,Re]=g.useState(null),$e=g.useRef(void 0),ye=g.useRef(!1),Se=g.useCallback(async(W,A)=>{if(!W.trim()){E(!0),_(null),z(null);return}E(!1),D(!0),X("");try{if(e.searchAll){const I=await e.searchAll(W,A??Rn);_(I)}else{const I=["work","book","collection","entity"],G=await Promise.all(I.map(P=>e.search(W,P,{page:1,pageSize:A??Rn})));_({works:G[0].entries,books:G[1].entries,collections:G[2].entries,entities:G[3].entries,totalWorks:G[0].total,totalBooks:G[1].total,totalCollections:G[2].total,totalEntities:G[3].total})}}catch(I){X(I instanceof Error?I.message:String(I)),_(null)}finally{D(!1)}},[e]);g.useEffect(()=>{let W=!1;const A=()=>{var se,ke;const I=["work","book","collection","entity"],G=Promise.all(I.map(be=>e.loadEntries(be,{page:1,pageSize:1}).catch(()=>({total:0})))),P=((se=e.getResourceCounts)==null?void 0:se.call(e).catch(()=>null))??Promise.resolve(null),K=((ke=e.getSubtypeStats)==null?void 0:ke.call(e).catch(()=>null))??Promise.resolve(null);Promise.all([G,P,K]).then(([be,Le,qe])=>{W||(le({works:be[0].total,books:be[1].total,collections:be[2].total,entities:be[3].total,hasText:Le==null?void 0:Le.hasText,hasImage:Le==null?void 0:Le.hasImage}),qe&&Re(qe))})};return e.getCounts?e.getCounts().then(I=>{var G,P;W||(le({works:I.works,books:I.books,collections:I.collections,entities:I.entities,hasText:(G=I.resourceCounts)==null?void 0:G.hasText,hasImage:(P=I.resourceCounts)==null?void 0:P.hasImage}),I.subtypeStats&&Re(I.subtypeStats))}).catch(()=>{W||A()}):A(),()=>{W=!0}},[e]),g.useEffect(()=>{ye.current||!(x!=null&&x.trim())||(ye.current=!0,Se(x))},[x,Se]);const Ne=g.useCallback(W=>{if($(W),!W.trim()){m==null||m(W),E(!0),_(null),z(null),T("all");return}$e.current&&clearTimeout($e.current),$e.current=setTimeout(()=>{z(null),T("all"),m==null||m(W),Se(W)},la)},[Se,m]),je=g.useCallback(W=>{$e.current&&clearTimeout($e.current),T("all"),m==null||m(W),Se(W)},[Se,m]),H=g.useCallback(W=>{z(W),Se(k,sa)},[k,Se]);g.useEffect(()=>{if(!ee.length){ae([]);return}let W=!1;return Q(!0),Promise.all(ee.slice(0,10).map(async A=>{var I,G,P;try{if(e.getEntry){const se=await e.getEntry(A);if(se)return se}const K=await e.getItem(A);if(K){const se=K.authors;return{id:A,title:K.title||A,type:K.type||"work",author:(I=se==null?void 0:se[0])==null?void 0:I.name,dynasty:(G=se==null?void 0:se[0])==null?void 0:G.dynasty,role:(P=se==null?void 0:se[0])==null?void 0:P.role,edition:K.edition||void 0}}}catch{}return{id:A,title:A,type:"work",notFound:!0}})).then(A=>{W||(ae(A),Q(!1))}),()=>{W=!0}},[ee,e]);const ce=W=>{O(W.id),go(W.id),F(_t()),r==null||r(W)},oe=(W,A)=>{if(r&&pa(A)){A.preventDefault(),ce(W);return}go(W.id),F(_t())},he=W=>{aa(W),F(_t())},me=()=>{ca(),F([])},U=W=>b.find(A=>A.type===W),R=!Y&&!v&&!M,V=v&&(v.works.length>0||v.books.length>0||v.collections.length>0);return t.jsxs("div",{className:"bim-browser-container",style:w?{minHeight:"100svh"}:void 0,children:[t.jsx("style",{children:ua}),t.jsx("header",{style:{padding:"12px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("h1",{style:{margin:0,fontSize:"18px",color:i("fg")},children:h.browser.title}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[j,!a&&t.jsx(zr,{variant:"index-browser",indexSource:n,syncConfig:o,onSwitchMode:l,onToggleDraft:d,onConfigurePath:p,onSelectFolder:c})]})]})}),t.jsxs("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:[t.jsx(Cr,{transport:e,value:k,onChange:Ne,onSearch:je,onEntrySelect:ce}),s&&t.jsx("button",{onClick:()=>s("work"),style:{padding:"8px 14px",border:`1px solid ${i("primary")}`,borderRadius:"6px",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"13px"},children:h.action.newEntry})]}),Y&&t.jsx("div",{className:"bim-ib-stats",style:{padding:"0 20px 8px",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"4px"},children:re&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:pe?t.jsxs(t.Fragment,{children:[(pe.book??0)>0&&t.jsxs(t.Fragment,{children:["書 ",t.jsx("strong",{style:{color:i("fg")},children:pe.book.toLocaleString()})," 部 ,",t.jsx("strong",{style:{color:i("fg")},children:re.books.toLocaleString()})," 本"]}),pe.article?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),"文章 ",t.jsx("strong",{style:{color:i("fg")},children:pe.article.toLocaleString()})," 篇"]}):null,pe.poem?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),"詩詞 ",t.jsx("strong",{style:{color:i("fg")},children:pe.poem.toLocaleString()})," 首"]}):null,t.jsx("span",{style:{margin:"0 6px"},children:"·"}),"叢編 ",t.jsx("strong",{style:{color:i("fg")},children:re.collections.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[h.indexType.work," ",t.jsx("strong",{style:{color:i("fg")},children:re.works.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),h.indexType.book," ",t.jsx("strong",{style:{color:i("fg")},children:re.books.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),h.indexType.collection," ",t.jsx("strong",{style:{color:i("fg")},children:re.collections.toLocaleString()}),re.entities>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{margin:"0 6px"},children:"·"}),h.indexType.entity," ",t.jsx("strong",{style:{color:i("fg")},children:re.entities.toLocaleString()})]})]})}),re.hasImage!=null&&re.hasText!=null&&t.jsxs("span",{children:[h.resourceType.image," ",t.jsx("strong",{style:{color:i("fg")},children:re.hasImage.toLocaleString()}),t.jsx("span",{style:{margin:"0 6px"},children:"·"}),h.resourceType.text," ",t.jsx("strong",{style:{color:i("fg")},children:re.hasText.toLocaleString()})]})]})}),t.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:C||R?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg"),minHeight:da,boxSizing:"border-box"},children:h.search.searching}):M?t.jsx("div",{style:{textAlign:"center",padding:"40px"},children:t.jsx("p",{style:{color:i("desc-fg")},children:M})}):Y?t.jsx("div",{style:{flex:1},children:ne?t.jsx("div",{style:{textAlign:"center",padding:"40px",color:i("desc-fg")},children:h.search.loading}):q.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{padding:"8px 0",fontSize:"12px",color:i("desc-fg"),display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{children:h.search.recentBrowse}),t.jsx("button",{onClick:me,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"2px 4px"},children:h.search.clearRecent})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:q.slice(0,ie?10:3).map(W=>W.notFound?t.jsx(ma,{id:W.id,onRemove:he,t:h},W.id):t.jsx(ho,{entry:W,selected:B===W.id,onClick:oe,getConfig:U,onRemove:he},W.id))}),!ie&&q.length>3&&t.jsx("button",{onClick:()=>ge(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:h.action.expandMore})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:h.search.searchTitle}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:h.search.searchSubtitle})]})}):V?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[t.jsx("style",{children:xa}),(()=>{const W=K=>v[mo[K]]??0,A=y.map(K=>b.find(se=>se.type===K)).filter(K=>W(K.key)>0);if(A.length<2)return null;const I=A.reduce((K,se)=>K+W(se.key),0),G=K=>{if(T(K),K!=="all"&&S!==K){const se=b.find(be=>be.type===K),ke=(v[se.key]??[]).length;W(se.key)>ke&&H(K)}},P=K=>({border:"none",background:"transparent",cursor:"pointer",font:"inherit",fontSize:"14px",padding:"8px 12px",minHeight:44,color:i(K?"fg":"desc-fg"),fontWeight:K?700:400,boxShadow:K?`inset 0 -2px 0 ${i("primary")}`:"none"});return t.jsxs("div",{role:"group","aria-label":h.search.resultTabs,style:{display:"flex",flexWrap:"wrap",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs("button",{type:"button","aria-pressed":N==="all",style:P(N==="all"),onClick:()=>G("all"),children:[h.search.allTab," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:I.toLocaleString()})]}),A.map(K=>t.jsxs("button",{type:"button","aria-pressed":N===K.type,style:P(N===K.type),onClick:()=>G(K.type),children:[K.name," ",t.jsx("span",{style:{fontSize:12,fontWeight:400},children:W(K.key).toLocaleString()})]},K.type))]})})(),b.map(({type:W,name:A,key:I})=>{const G=v[I]??[],P=mo[I],K=v[P]??0;if(G.length===0||N!=="all"&&N!==W)return null;const ke=N==="all"&&!(S===W)&&K>Rn;return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:[t.jsx(vn,{type:W})," ",A,t.jsxs("span",{style:{fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[K," ",h.unit.items]})]}),ke&&t.jsx("button",{className:"bim-ib-viewall",onClick:()=>H(W),style:{border:"none",background:"transparent",color:i("primary"),cursor:"pointer",fontSize:"12px"},children:h.action.viewAll})]}),t.jsx("div",{style:u==="list"?{display:"flex",flexDirection:"column",gap:0}:u==="card"?{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(340px, 100%), 1fr))",gap:"14px"}:{display:"flex",flexDirection:"column",gap:"4px"},children:G.map(be=>{if(f)return t.jsx(g.Fragment,{children:f(be)},be.id);const Le=u==="card"?ga:ho;return t.jsx(Le,{entry:be,selected:B===be.id,onClick:oe,getConfig:U,query:k},be.id)})})]},W)})]}):t.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[t.jsx("h2",{style:{margin:"0 0 8px",fontSize:"1.17em",color:i("fg")},children:Jt(h.search.noResultsFor,{query:k})}),t.jsx("p",{style:{color:i("desc-fg"),fontSize:"13px"},children:h.search.tryOther})]})})]})},da=240;function pa(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}const ua=`
|
|
2
2
|
.bim-ib-stats { min-height: 25px; box-sizing: content-box; }
|
|
3
3
|
@media (max-width: 719px) { .bim-ib-stats { min-height: 46px; } }
|
|
4
|
-
`,
|
|
4
|
+
`,xa=`
|
|
5
5
|
@media (max-width: 719px), (pointer: coarse) {
|
|
6
6
|
.bim-ib-viewall { position: relative; }
|
|
7
7
|
.bim-ib-viewall::after {
|
|
8
8
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
9
9
|
width: max(calc(100% + 8px), 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
|
|
10
10
|
}
|
|
11
|
-
}`,Cr={color:"inherit",textDecoration:"none"},xa=({snippet:e})=>{const{convert:n}=V();return t.jsx("div",{style:{fontSize:"12px",color:o("desc-fg"),lineHeight:1.6},children:jr(e).map((i,r)=>i.marked?t.jsx("mark",{style:{background:o("highlight-bg"),color:o("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(i.text)},r):t.jsx(f.Fragment,{children:n(i.text)},r))})},fa=({entry:e,selected:n,onClick:i,getConfig:r,query:s})=>{const l=de(),{convert:a}=V(),p=a(e.title||e.primary_name||e.id),c=e.measure_info?a(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${l.unit.juan}`:"",d=[...e.additional_titles||[],...e.attached_texts||[]],u=s&&d.length?d.find(m=>{const b=typeof m=="string"?m:m==null?void 0:m.book_title;return b==null?void 0:b.toLowerCase().includes(s.toLowerCase())}):void 0,g=o("cover-accent"),x=Fe();return t.jsxs("a",{href:x(e.id),onClick:m=>i(e,m),className:"bim-result-card",style:{...Cr,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:o("bg"),border:n?`1px solid ${o("primary")}`:`1px solid ${o("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, ${g} 50%, ${o("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${g} 14%, ${o("bg")}), color-mix(in srgb, ${g} 7%, ${o("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, ${g} 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:g},children:Array.from(p).map((m,b)=>t.jsx("span",{children:m},b))})]}),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:o("fg")},children:p}),c&&t.jsx("span",{style:{fontSize:"12px",color:o("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:o("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",a(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:a(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",a(e.role)]})]}),(e.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:o("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",a(e.era),"〕"]}),e.edition&&t.jsx("span",{children:a(e.edition)})]}),u&&t.jsxs("div",{style:{fontSize:"12px",color:o("desc-fg")},children:[l.search.alias,":",a(typeof u=="string"?u:u.book_title||"")]}),e.descriptionSnippet&&t.jsx(xa,{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:o("desc-fg"),border:`1px solid ${o("widget-border")}`},children:[t.jsx(yn,{type:e.type,size:8})," ",r(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:o("desc-fg"),border:`1px solid ${o("widget-border")}`},children:l.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:o("desc-fg"),border:`1px solid ${o("widget-border")}`},children:l.misc.imageResource})]})]})]})},mo=({entry:e,selected:n,onClick:i,getConfig:r,query:s,onRemove:l})=>{const a=de(),{convert:p}=V(),c=[...e.additional_titles||[],...e.attached_texts||[]],d=s&&c.length?c.find(g=>{const x=typeof g=="string"?g:g==null?void 0:g.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,u=Fe();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${o("primary")}`:`1px solid ${o("widget-border")}`,background:o("input-bg")},children:[t.jsxs("a",{href:u(e.id),onClick:g=>i(e,g),className:"bim-result-card",style:{...Cr,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:l?"10px 0 10px 12px":"10px 12px",borderRadius:"6px",cursor:"pointer"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[t.jsx(yn,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:o("desc-fg"),lineHeight:1},children:r(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:o("fg")},children:p(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:a.misc.textResource}),e.has_image&&t.jsx("span",{children:a.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:o("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",p(e.era),"〕"]}),e.edition&&p(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:o("desc-fg")},children:p(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:o("desc-fg")},children:[e.juan_count,a.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:o("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",p(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:p(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",p(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??"?"]})]}),d&&t.jsxs("div",{style:{fontSize:"11px",color:o("desc-fg"),marginTop:"2px"},children:[a.search.alias,":",p(d)]})]}),!l&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),l&&t.jsx("button",{type:"button",onClick:()=>l(e.id),title:a.search.removeFromRecent,"aria-label":a.search.removeFromRecent,style:{border:"none",background:"transparent",color:o("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},ga=({id:e,onRemove:n,t:i})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${o("widget-border")}`,background:o("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:o("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:o("desc-fg"),marginTop:"2px"},children:i.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:i.search.removeFromRecent,style:{border:"none",background:"transparent",color:o("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function ma(e){var n;return!e.dynasty&&!e.birth_year&&!e.death_year&&(!e.alt_names||e.alt_names.length===0)&&!((n=e.description)!=null&&n.text)}function ha({data:e}){const{convert:n}=V(),{dynasty:i,birth_year:r,death_year:s}=e,l=[];return i&&l.push(`〔${n(i)}〕`),r!==void 0&&s!==void 0?l.push(`${r}—${s}`):r!==void 0?l.push(`${r}—?`):s!==void 0&&l.push(`?—${s}`),l.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:o("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:l.join(" ")})}function ba({alt_names:e}){const{convert:n}=V(),i=new Map;for(const l of e){const a=l.type||"別名";i.has(a)||i.set(a,[]),i.get(a).push(l.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...i.keys()].sort((l,a)=>{const p=r.indexOf(l),c=r.indexOf(a);return p===-1&&c===-1?0:p===-1?1:c===-1?-1:p-c});return t.jsx("div",{style:{fontSize:"14px",color:o("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(l=>{const a=i.get(l);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:o("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:l}),t.jsx("span",{children:a.map((p,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:o("desc-fg"),margin:"0 4px"},children:"·"}),n(p)]},c))})]},l)})})}function ya({data:e}){const n=e.external_ids;if(!n)return null;const i=[];return n.cbdb_id&&i.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${n.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:o("link-fg"),border:`1px solid ${o("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${o("link-fg")}08`},title:"CBDB 中国历代人物传记数据库",children:["CBDB ",n.cbdb_id]},"cbdb")),i.length===0?null:t.jsx("div",{style:{display:"flex",gap:"6px",margin:"8px 0",alignItems:"center",flexWrap:"wrap"},children:i})}function ja({works:e,transport:n,onNavigate:i,renderLink:r}){const s=de(),{convert:l}=V(),a=Fe(),[p,c]=f.useState(new Map);f.useEffect(()=>{if(!n)return;let x=!1;const m=e.map(k=>k.work_id);return(async()=>{const k=new Map;if(n.getEntriesByIds)try{const v=await n.getEntriesByIds(m);let _=!0;for(let S=0;S<m.length;S++){const $=v[S];$!=null&&$.title?k.set(m[S],$.title):$!=null&&$.primary_name?k.set(m[S],$.primary_name):_=!1}if(_)return k}catch{}const h=[...m],y=8,j=new Array(y).fill(0).map(async()=>{for(;h.length;){const v=h.shift();if(!v)break;if(!k.has(v))try{if(n.getEntry){const $=await n.getEntry(v);if($!=null&&$.title){k.set(v,$.title);continue}}const _=await n.getItem(v),S=_&&(_.title||_.primary_name)||v;k.set(v,S)}catch{k.set(v,v)}}});return await Promise.all(j),k})().then(k=>{x||c(k)}),()=>{x=!0}},[e,n]);const d=new Map;for(const x of e){const m=x.role||"";d.has(m)||d.set(m,[]),d.get(m).push(x)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],g=[...d.keys()].sort((x,m)=>{const b=u.indexOf(x),k=u.indexOf(m);return b===-1&&k===-1?x.localeCompare(m):b===-1?1:k===-1?-1:b-k});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:o("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${o("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:o("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),g.map(x=>{const m=d.get(x);return t.jsxs("div",{style:{marginBottom:"8px"},children:[x&&t.jsxs("div",{style:{fontSize:"12px",color:o("desc-fg"),marginBottom:"2px"},children:[l(x)," ",t.jsxs("span",{style:{color:o("desc-fg")},children:["(",m.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:x?"16px":"0",listStyle:x?"disc":"none",fontSize:"14px",lineHeight:1.8},children:m.map((b,k)=>{const h=l(p.get(b.work_id)||b.work_id);return r?t.jsx("li",{children:r(b.work_id,h)},k):i?t.jsx("li",{children:t.jsx("a",{href:a(b.work_id),onClick:y=>{y.metaKey||y.ctrlKey||(y.preventDefault(),i(b.work_id))},style:{color:o("link-fg"),textDecoration:"underline",cursor:"pointer"},children:h})},k):t.jsx("li",{children:h},k)})})]},x)})]})}const Ir=({data:e,transport:n,onNavigate:i,renderLink:r,headerExtra:s,hideHeader:l})=>{var g;const a=de(),{convert:p}=V();let c=!1;try{c=ke.extractStatus(e.id)==="draft"}catch{}const d=ma(e),u=e.subtype==="people"?"人物":e.subtype==="place"?"地名":e.subtype==="dynasty"?"朝代":e.subtype==="anonymous"?"佚名":e.subtype==="collective"?"集体":e.subtype;return t.jsxs("div",{children:[!l&&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:o("fg")},children:[p(e.primary_name),t.jsx(ha,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:o("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:o("type-entity"),border:`1px solid color-mix(in srgb, ${o("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${o("type-entity")} 3%, transparent)`},children:a.indexType.entity}),u&&e.subtype!=="people"&&t.jsx("span",{children:u}),c&&t.jsx("span",{style:{padding:"1px 6px",background:o("warn-bg"),border:`1px solid ${o("warn-border")}`,borderRadius:"2px",color:o("warn-fg")},children:a.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),d&&t.jsx("div",{style:{fontSize:"13px",color:o("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:o("widget-bg"),border:`1px dashed ${o("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。"}),e.alt_names&&e.alt_names.length>0&&t.jsx(ba,{alt_names:e.alt_names}),t.jsx(ya,{data:e}),((g=e.description)==null?void 0:g.text)&&t.jsx("p",{style:{fontSize:"14px",color:o("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:p(e.description.text)}),e.works&&e.works.length>0&&t.jsx(ja,{works:e.works,transport:n,onNavigate:i,renderLink:r})]})},va=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function ka(e){const n=e.search(va);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Tr={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,r="",s=n;if(e&&typeof n=="string"&&(n===e||n===Sa(e))){const[l,a]=ka(n);a&&(i=encodeURI(l),s=l,r=a)}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:o("link")},children:s}),r]})},code:({children:e})=>t.jsx("code",{style:{background:o("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function Sa(e){try{return decodeURI(e)}catch{return e}}const wa={...Tr,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},st=({text:e,plainStrong:n,style:i,className:r})=>{const{convert:s}=V(),l=n?wa:Tr;return t.jsx("div",{className:r,style:i,children:t.jsx(Il,{remarkPlugins:[Tl],components:l,children:s(e)})})},_a=["〇","一","二","三","四","五","六","七","八","九"],ho=["","十","百","千"];function Er(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let r="",s=!1;for(let l=0;l<i;l++){const a=parseInt(n[l]),p=i-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=ho[p]:r+=_a[a]+ho[p])}return r}function Rr(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 $a={book:o("type-book"),work:o("type-work"),collection:o("type-collection"),entity:o("type-entity")};function za({type:e}){const n=de();return t.jsx("span",{style:Rr($a[e]),children:n.indexType[e]})}function Ca({isDraft:e}){const n=de(),i=o(e?"status-draft":"status-official");return t.jsx("span",{style:Rr(i),children:e?n.status.draft:n.status.official})}function Ia({id:e}){const n=de(),[i,r]=f.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:o("desc-fg"),background:o("bg-subtle"),border:`1px solid ${o("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:o("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:l=>l.currentTarget.style.opacity="1",onMouseLeave:l=>l.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function Ve({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:o("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function et({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:o("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:o("fg")},children:n})]})}function Nr({authors:e,type:n,onNavigate:i,renderLink:r}){const{convert:s}=V();return t.jsx("span",{style:{fontSize:"14px",color:o("fg"),lineHeight:1.6},children:e.map((l,a)=>{const p=s(l.name),c=l.entity_id?t.jsx(Ke,{id:l.entity_id,label:p,onNavigate:i,renderLink:r}):t.jsx("span",{style:{fontWeight:500},children:p});return t.jsxs("span",{children:[a>0&&t.jsx("span",{style:{color:o("desc-fg"),margin:"0 4px"},children:"·"}),l.dynasty&&t.jsxs("span",{style:{color:o("desc-fg"),fontSize:"12px"},children:["〔",s(l.dynasty),"〕"]}),c,l.role&&t.jsxs("span",{style:{color:o("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(l.role)]})]},a)})})}function Ke({id:e,label:n,onNavigate:i,renderLink:r}){const s=Fe();return r?t.jsx(t.Fragment,{children:r(e,n)}):i?t.jsx("a",{href:s(e),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),i(e))},style:{color:o("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${o("link-fg")}`,paddingBottom:"1px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{children:n||e})}function Ta({id:e,title:n,edition:i,type:r,isDraft:s,authors:l,volumeText:a,meta:p,headerExtra:c,onNavigate:d,renderLink:u}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:o("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:o("desc-fg"),marginLeft:"6px"},children:i}),a&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:o("desc-fg"),marginLeft:"8px"},children:a})]}),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(za,{type:r}),t.jsx(Ca,{isDraft:s}),t.jsx(Ia,{id:e})]}),((l==null?void 0:l.length)||p.length>0)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[l&&l.length>0&&t.jsx(Nr,{authors:l,type:r,onNavigate:d,renderLink:u}),p]})]})}function Lr({items:e,label:n,showMeta:i,onNavigate:r,renderLink:s}){const l=de(),{convert:a}=V();if(!e.length)return null;const[p,c]=f.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((d,u)=>{const g=p===u;return t.jsxs("div",{style:{border:`1px solid ${o("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...g?{boxShadow:o("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(g?null:u),style:{padding:"8px 12px",background:o("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:o("desc-fg"),transition:"transform 0.15s",transform:g?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:o("fg")},children:a(d.source)}),!g&&i&&d.title_info&&t.jsx("span",{style:{fontSize:"12px",color:o("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a(d.title_info)}),d.source_bid&&t.jsx("span",{onClick:x=>x.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(Ke,{id:d.source_bid,label:l.action.view,onNavigate:r,renderLink:s})})]}),g&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${o("widget-border")}`},children:[i&&(d.title_info||d.author_info||d.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[d.title_info&&t.jsx(et,{label:l.label.titleInfo,children:a(d.title_info)}),d.author_info&&t.jsx(et,{label:l.label.authorInfo,children:a(d.author_info)}),d.edition&&t.jsx(et,{label:l.label.edition,children:a(d.edition)})]}),d.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${o("primary")}`,background:`color-mix(in srgb, ${o("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:o("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:o("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:a(d.summary)})]}),d.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${o("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:o("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:o("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.comment)})]}),d.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${o("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:o("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:o("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(d.additional_comment)})]})]})]},u)})})]})}function Ea({items:e,onNavigate:n,renderLink:i}){const r=de();return t.jsx(Lr,{items:e,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:i})}function Br({items:e,onNavigate:n,renderLink:i}){const r=de();return t.jsx(Lr,{items:e,label:r.section.emendated,onNavigate:n,renderLink:i})}function Ar({label:e,items:n}){const{convert:i}=V();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const l=typeof r=="string"?r:r.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:o("fg"),border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:o("input-bg")},children:i(l)},s)})})]}):null}function Ra({items:e}){const n=de();return t.jsx(Ar,{label:n.section.aliases,items:e})}function Na({items:e}){const n=de();return t.jsx(Ar,{label:n.section.attachedTexts,items:e})}function La({items:e}){const n=de(),{convert:i}=V();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((r,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:o("fg"),border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:o("input-bg")},children:["《",i(r.book_title),"》",r.n_juan!=null&&t.jsxs("span",{style:{color:o("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function Ba({items:e}){const n=de(),{convert:i}=V();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Ve,{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:o("widget-border")}}),e.map((r,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:o("primary"),border:`1.5px solid ${o("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:o("fg")},children:i(r.name)}),r.description&&t.jsx("span",{style:{fontSize:"12px",color:o("desc-fg"),marginLeft:"8px"},children:i(r.description)})]},s))]})]}):null}function Aa({items:e}){const n=de(),{convert:i}=V();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((r,s)=>t.jsxs("div",{style:{fontSize:"13px",color:o("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:o("desc-fg")},children:"·"}),i(r)]},s))})]}):null}function bo({title:e,ids:n,transport:i,onNavigate:r,renderLink:s}){const{convert:l}=V(),[a,p]=f.useState([]);return f.useEffect(()=>{if(!n.length){p([]);return}if(!i){p(n.map(d=>({id:d})));return}let c=!1;return Promise.all(n.map(d=>i.getItem(d).then(u=>({id:d,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:d})))).then(d=>{c||p(d)}),()=>{c=!0}},[n,i]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:o("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(a.length?a:n.map(c=>({id:c}))).map(c=>{const d=c.edition?`${l(c.title)||c.id}(${l(c.edition)})`:l(c.title)||void 0;return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:o("input-bg"),transition:"border-color 0.15s"},children:t.jsx(Ke,{id:c.id,label:d,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Rn({book:e,onNavigate:n,renderLink:i}){const r=de(),{convert:s}=V(),[l,a]=f.useState(!1),p=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 ${o("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:o("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:p&&!l?`1px solid ${o("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(Ke,{id:e.id,label:c,onNavigate:n,renderLink:i})}),p&&t.jsx("span",{onClick:()=>a(d=>!d),style:{cursor:"pointer",fontSize:"10px",color:o("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:l?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:l?r.action.expand:r.action.collapse,children:"▼"})]}),p&&!l&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(xi,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:i})})]})}function Wa({ids:e,workData:n,transport:i,onNavigate:r,renderLink:s,footer:l}){const a=de(),{convert:p}=V(),[c,d]=f.useState([]);if(f.useEffect(()=>{if(!e.length){d([]);return}if(!i){d(e.map(k=>({id:k})));return}let b=!1;return Promise.all(e.map(k=>i.getItem(k).then(h=>({id:k,title:h?h.title:void 0,edition:h?h.edition:void 0,resources:h?h.resources:void 0,resource_groups:h?h.resource_groups:void 0})).catch(()=>({id:k})))).then(k=>{b||d(k)}),()=>{b=!0}},[e,i]),!e.length)return null;const u=c.length?c:e.map(b=>({id:b})),g=new Map(u.map(b=>[b.id,b])),x=n==null?void 0:n.version_graph,m=Ma(e,x);return t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{children:[a.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:o("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),l,m.useGrouping?t.jsxs(t.Fragment,{children:[m.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:m.coreIds.map(b=>{const k=g.get(b);return k?t.jsx(Rn,{book:k,onNavigate:r,renderLink:s},b):null})}),m.groupedIds.map(b=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${o("widget-border")}`,borderRadius:6,background:o("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:o("fg"),userSelect:"none"},children:[p(b.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:o("desc-fg"),fontWeight:400},children:["(",b.ids.length,")"]}),b.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:o("desc-fg"),fontWeight:400},children:p(b.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:b.ids.map(k=>{const h=g.get(k);return h?t.jsx(Rn,{book:h,onNavigate:r,renderLink:s},k):null})})]},b.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(b=>t.jsx(Rn,{book:b,onNavigate:r,renderLink:s},b.id))})]})}function Ma(e,n){var h,y;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(h=n.collections)==null?void 0:h[n.default_collection],r=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],l=r.length>0||s.length>0,a=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&a.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const p=new Set(r),c=new Set([...s,...a]),d=j=>{if(c.has(j))return!0;const v=n.node_groups[j];return v!=null&&p.has(v)},u=[],g=new Map,x=[];for(const j of e)if(!((y=n.excluded_books)!=null&&y.includes(j)))if(d(j))u.push(j);else{const v=n.node_groups[j];v?(g.has(v)||g.set(v,[]),g.get(v).push(j)):x.push(j)}if(x.length+[...g.values()].reduce((j,v)=>j+v.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const b=new Map((n.groups??[]).map(j=>[j.id,j])),k=[...g.entries()].map(([j,v])=>{const _=b.get(j);return{id:j,label:(_==null?void 0:_.label)??j,description:_==null?void 0:_.description,ids:v}});return x.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:x}),{useGrouping:!0,coreIds:u,groupedIds:k}}function Fa({workData:e,onNavigate:n,renderLink:i}){var a,p,c,d;const r=de(),{convert:s}=V(),l=!!((a=e.description)!=null&&a.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${o("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:o("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:l?`1px solid ${o("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${o("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:o("fg")},children:t.jsx(Ke,{id:e.id,label:s(e.title),onNavigate:n,renderLink:i})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:o("desc-fg")},children:s(e.measure_info)}):((p=e.juan_count)==null?void 0:p.number)!=null&&e.juan_count.number>0?t.jsxs("span",{style:{fontSize:"12px",color:o("desc-fg")},children:[Er(e.juan_count.number),r.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Nr,{authors:e.authors,type:"work",onNavigate:n,renderLink:i})})]}),l&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(st,{text:e.description.text,style:{fontSize:"13px",color:o("fg"),lineHeight:1.8,textAlign:"justify"}}),e.parent_work&&t.jsx("div",{style:{marginTop:(d=e.description)!=null&&d.text?"8px":0,fontSize:"13px"},children:t.jsx(et,{label:r.label.parentWork,children:t.jsx(Ke,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function Pa({items:e,onNavigate:n,renderLink:i}){const r=de(),{convert:s}=V();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(l=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${o("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${o("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:o("type-collection")},children:r.indexType.collection}),t.jsx(Ke,{id:l.id,label:s(l.title)||l.id,onNavigate:n,renderLink:i}),l.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:o("desc-fg"),marginLeft:"2px"},children:Kt(r.catalog.volume,{n:l.volume_index})})]},l.id))}):null}const fi=({data:e,id:n,transport:i,onNavigate:r,renderLink:s,headerExtra:l,relatedBooksFooter:a,className:p,style:c})=>{var O,A,M,F,Y,K,R,oe;const d=de(),{convert:u}=V(),[g,x]=f.useState(null),[m,b]=f.useState(!1),[k,h]=f.useState(null),[y,j]=f.useState(null),[v,_]=f.useState([]),S=e||g;if(f.useEffect(()=>{if(e||!n||!i)return;let H=!1;return b(!0),h(null),i.getItem(n).then(re=>{H||(re?x(re):h(d.misc.notFoundEntry))}).catch(re=>{H||h(re instanceof Error?re.message:d.misc.loadFailed)}).finally(()=>{H||b(!1)}),()=>{H=!0}},[e,n,i]),f.useEffect(()=>{if(!S||!i){j(null),_([]);return}let H=!1;const re=S.type==="book"||S.type==="collection"?S.work_id:void 0;if(re?i.getItem(re).then(ee=>{!H&&ee&&ee.type==="work"&&j(ee)}).catch(()=>{}):j(null),S.type==="book"){const ee=S;ee.contained_in&&ee.contained_in.length>0?Promise.all(ee.contained_in.map(Q=>{const J=typeof Q=="string"?Q:Q.id,ce=typeof Q=="string"?void 0:Q.volume_index;return i.getItem(J).then(me=>({id:J,title:me&&me.title||J,volume_index:ce})).catch(()=>({id:J,title:J,volume_index:ce}))})).then(Q=>{H||_(Q)}):_([])}else _([]);return()=>{H=!0}},[S,i]),m)return t.jsx("div",{className:p,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((H,re)=>t.jsx("div",{style:{height:re===1?"32px":"16px",width:`${H}px`,background:o("widget-border"),borderRadius:"4px",opacity:.4}},re))})});if(k)return t.jsx("div",{className:p,style:{...c,padding:"24px",textAlign:"center",color:o("desc-fg"),fontSize:"13px"},children:k});if(!S)return null;if(S.type==="entity")return t.jsx("div",{className:p,style:c,children:t.jsx(Ir,{data:S,transport:i,onNavigate:r,renderLink:s,headerExtra:l})});const $=S.type==="book"?S:null,w=S.type==="collection"?S:null,C=S.type==="work"?S:null;let N=!1;try{N=ke.extractStatus(S.id)==="draft"}catch{}let E="";S.measure_info?E=u(S.measure_info):(O=S.juan_count)!=null&&O.number?E=Er(S.juan_count.number)+d.unit.juan:(A=S.juan_count)!=null&&A.description&&(E=u(S.juan_count.description));const I=[];return(M=S.publication_info)!=null&&M.year&&I.push(t.jsx(et,{label:d.label.year,children:S.publication_info.year},"year")),(F=S.current_location)!=null&&F.name&&I.push(t.jsx(et,{label:d.label.currentLocation,children:u(S.current_location.name)},"loc")),(Y=S.page_count)!=null&&Y.description&&I.push(t.jsx(et,{label:d.label.pageCount,children:S.page_count.description},"page")),$!=null&&$.edition&&I.push(t.jsx(et,{label:d.label.edition,children:u($.edition)},"ver")),C!=null&&C.parent_work&&I.push(t.jsx(et,{label:d.label.parentWork,children:t.jsx(Ke,{id:C.parent_work.id,label:u(C.parent_work.title),onNavigate:r,renderLink:s})},"pw")),C!=null&&C.parent_works&&C.parent_works.length>0&&!C.parent_work&&I.push(t.jsx(et,{label:d.label.parentWork,children:C.parent_works.map((H,re)=>t.jsxs("span",{children:[re>0&&"、",t.jsx(Ke,{id:H,onNavigate:r,renderLink:s})]},H))},"pws")),t.jsxs("div",{className:p,style:c,children:[t.jsx(Ta,{id:S.id,title:u(S.title),edition:S.edition?u(S.edition):void 0,type:S.type,isDraft:N,authors:S.authors,volumeText:E,meta:I,headerExtra:l,onNavigate:r,renderLink:s}),((K=S.description)==null?void 0:K.text)&&t.jsx(st,{text:S.description.text,style:{fontSize:"14px",color:o("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),S.appendix&&S.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:S.appendix.map((H,re)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:o("bg-subtle"),borderRadius:4,border:`1px solid ${o("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:o("muted")},children:u(H.title)}),t.jsx(st,{text:H.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:o("fg")}})]},re))}),v.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:d.section.containedIn}),t.jsx(Pa,{items:v,onNavigate:r,renderLink:s})]}),y&&t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:d.section.belongsToWork}),t.jsx(Fa,{workData:y,onNavigate:r,renderLink:s})]}),S.additional_works&&S.additional_works.length>0&&t.jsx(La,{items:S.additional_works}),S.additional_titles&&S.additional_titles.length>0&&t.jsx(Ra,{items:S.additional_titles}),S.attached_texts&&S.attached_texts.length>0&&t.jsx(Na,{items:S.attached_texts}),S.indexed_by&&S.indexed_by.length>0&&t.jsx(Ea,{items:S.indexed_by,onNavigate:r,renderLink:s}),S.emendated_by&&S.emendated_by.length>0&&t.jsx(Br,{items:S.emendated_by,onNavigate:r,renderLink:s}),S.resources&&S.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:d.section.resources}),t.jsx(xi,{items:S.resources,resourceGroups:S.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),($==null?void 0:$.location_history)&&$.location_history.length>0&&t.jsx(Ba,{items:$.location_history}),(w==null?void 0:w.history)&&w.history.length>0&&t.jsx(Aa,{items:w.history}),($==null?void 0:$.related_books)&&$.related_books.length>0&&t.jsx(bo,{title:d.section.relatedVersions,ids:$.related_books,transport:i,onNavigate:r,renderLink:s}),(w==null?void 0:w.books)&&w.books.length>0&&t.jsx(bo,{title:d.section.containedBooks,ids:w.books,transport:i,onNavigate:r,renderLink:s}),(w==null?void 0:w.contained_works)&&w.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(Ve,{children:[d.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:o("desc-fg"),fontWeight:400},children:["(",w.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:w.contained_works.map(H=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:o("input-bg")},children:t.jsx(Ke,{id:H.id,label:u(H.title),onNavigate:r,renderLink:s})},H.id))})]}),(((R=C==null?void 0:C.books)==null?void 0:R.length)||0)+(((oe=C==null?void 0:C.collections)==null?void 0:oe.length)||0)>0&&t.jsx(Wa,{ids:[...(C==null?void 0:C.books)||[],...(C==null?void 0:C.collections)||[]],workData:C??void 0,transport:i,onNavigate:r,renderLink:s,footer:a}),(C==null?void 0:C.related_works)&&C.related_works.length>0&&(()=>{const H=[],re=C.related_works.filter(te=>te.relation==="part_of"),ee=C.related_works.filter(te=>te.relation==="has_part"),Q=C.related_works.filter(te=>te.relation==="has_adaptation"),J=C.related_works.filter(te=>te.relation==="text_carried_by"),ce=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),me=C.related_works.filter(te=>!te.relation||!ce.has(te.relation));return re.length>0&&H.push({label:d.section.belongsToWork,items:re}),ee.length>0&&H.push({label:d.section.containedWorks,items:ee}),Q.length>0&&H.push({label:d.section.adaptations,items:Q}),J.length>0&&H.push({label:d.section.derivativeWorks,items:J}),me.length>0&&H.push({label:d.section.relatedWorks,items:me}),H.map(te=>t.jsxs("div",{children:[t.jsxs(Ve,{children:[te.label,t.jsxs("span",{style:{fontSize:"12px",color:o("desc-fg"),fontWeight:400},children:["(",te.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:te.items.map(ie=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:o("input-bg")},children:t.jsx(Ke,{id:ie.id,label:u(ie.title),onNavigate:r,renderLink:s})},ie.id))})]},te.label))})()]})};function Oa({data:e}){const n=de(),{convert:i}=V(),{stats:r}=e,s=r.processed_volumes??r.total_found_volumes,l=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:o("fg"),margin:"0 0 8px"},children:i(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:o("desc-fg"),marginBottom:"6px"},children:i(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:o("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:o("fg")},children:e.total_volumes})," ",n.unit.volume]}),l!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:o("fg")},children:s})," ",n.unit.volume," (",l,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:o("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:o("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:o("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:o("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Da({sections:e,activeSection:n,onSelect:i}){const r=de();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>i(null),style:yo(n===null),children:r.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>i(s.name),style:yo(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 yo(e){return{padding:"4px 12px",border:e?`1px solid ${o("primary")}`:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${o("primary")} 8%, transparent)`:"transparent",color:o(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Ha({id:e,label:n,onNavigate:i,renderLink:r}){const s=Fe();return r?t.jsx(t.Fragment,{children:r(e,n)}):i?t.jsx("a",{href:s(e),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),i(e))},style:{color:o("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${o("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{style:{fontSize:"12px",color:o("desc-fg")},children:n||e})}function Ga(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=e[0],r=e[e.length-1];return r-i+1===e.length?`${i}–${r}`:e.length<=3?e.join(", "):`${i}–${r} (${e.length}${n})`}function jo({book:e,onNavigate:n,renderLink:i,showVolumes:r}){const s=de(),{convert:l}=V(),a=e.book_id||e.work_id,p=r&&e.volumes.length>0?Ga(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 ${o("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[r&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:o("desc-fg"),textAlign:"right"},children:p}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:o("fg")},children:[l(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:o("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(d=>l(d)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:o("desc-fg"),fontWeight:400,marginLeft:"8px"},children:l(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:o(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),a&&t.jsx(Ha,{id:a,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:i}),!a&&t.jsx("span",{style:{fontSize:"11px",color:o("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const gi=({data:e,collectionId:n,transport:i,onNavigate:r,renderLink:s,className:l,style:a})=>{const p=de(),[c,d]=f.useState(null),[u,g]=f.useState(!1),[x,m]=f.useState(null),[b,k]=f.useState(null),[h,y]=f.useState(""),j=e||c;f.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollectionCatalog))return;let w=!1;return g(!0),m(null),i.getCollectionCatalog(n).then(C=>{w||(C?d(C):m(p.catalog.notFound))}).catch(C=>{w||m(C instanceof Error?C.message:p.catalog.loadFailed)}).finally(()=>{w||g(!1)}),()=>{w=!0}},[e,n,i,p]);const v=(j==null?void 0:j.sections)&&j.sections.length>0,_=f.useMemo(()=>{if(!j)return!1;if(j.volume_index&&Object.keys(j.volume_index).length>0)return!0;const w=j.books.map(N=>N.volumes[0]).filter(N=>N!=null);return new Set(w).size<w.length},[j]),S=f.useMemo(()=>{if(!j)return[];let w=j.books;if(b&&(w=w.filter(C=>C.section===b)),h.trim()){const C=h.trim().toLowerCase();w=w.filter(N=>N.title.toLowerCase().includes(C)||N.sub_items&&N.sub_items.some(E=>E.toLowerCase().includes(C))||N.edition&&N.edition.toLowerCase().includes(C))}return w},[j,b,h]),$=f.useMemo(()=>{if(!_)return null;const w=[],C=new Map;for(const E of S){if(!E.volumes||E.volumes.length===0)continue;const I=E.volumes[0];C.has(I)||C.set(I,[]),C.get(I).push(E)}const N=[...C.keys()].sort((E,I)=>E-I);for(const E of N)w.push({volume:E,books:C.get(E)});return w},[S,_]);return u?t.jsx("div",{className:l,style:{...a,padding:"24px"},children:t.jsx("div",{style:{color:o("desc-fg"),fontSize:"13px"},children:p.catalog.loading})}):x?t.jsx("div",{className:l,style:{...a,padding:"24px",textAlign:"center",color:o("desc-fg"),fontSize:"13px"},children:x}):j?t.jsxs("div",{className:l,style:a,children:[t.jsx(Oa,{data:j}),v&&t.jsx(Da,{sections:j.sections,activeSection:b,onSelect:k}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:p.search.searchBookName,value:h,onChange:w=>y(w.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${o("input-border")}`,borderRadius:"4px",background:o("input-bg"),color:o("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:o("desc-fg")},children:[S.length," ",p.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${o("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[$?$.map((w,C)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:o("bg"),borderBottom:`1px solid ${o("widget-border")}`,fontSize:"12px",fontWeight:600,color:o("desc-fg"),position:"sticky",top:0,zIndex:1},children:Kt(p.catalog.volume,{n:w.volume})}),w.books.map((N,E)=>t.jsx(jo,{book:N,onNavigate:r,renderLink:s,showVolumes:N.volumes.length>1},`${w.volume}-${E}`))]},`${w.volume}-${C}`)):S.map((w,C)=>t.jsx(jo,{book:w,onNavigate:r,renderLink:s,showVolumes:!0},C)),S.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:o("desc-fg"),fontSize:"13px"},children:p.catalog.noMatch})]})]}):null},jt=()=>{const[e,n]=f.useState(1);return f.useEffect(()=>{const i=setInterval(()=>n(r=>r>=3?1:r+1),500);return()=>clearInterval(i)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:o("desc-fg"),fontSize:"14px"},children:"加载中"+".".repeat(e)})},Wr=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Ua={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function Ae(e){return Ua[e]??e}const It=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],Tt={熹平: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},Mr={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function jn(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 r=n[2]?parseInt(n[2],10):void 0;return{from:i,to:r!=null&&r>=i&&r<=2100?r:void 0}}function Va(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 Ya=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,vo={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function mi(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(vo))if(n.startsWith(s))return vo[s];const i=Ae(n);if(gt[i]!=null)return i;const r=rt(n);if(r&&n.length<=r.length+1)return Ae(r)}function ft(e,n){if(n){const i=Mr[`${n}|${e}`];if(i!=null)return i}return Tt[e]}const Ka=1911;function qa(e){const n=Tt[e];if(n==null)return;const i=tt[e];let r;for(const[s,l]of Object.entries(Tt))tt[s]===i&&l>n&&(r==null||l<r)&&(r=l);return r!=null?r-1:void 0}const Ja={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function xn(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,i=0,r=!1;for(const l of e){const a=Ja[l];if(a===void 0)return;r=!0,l==="十"?i=(i||1)*10:l==="廿"||l==="卅"?(n+=a,i=0):i>=10?(n+=i+a,i=0):i=i*10+a}const s=n+i;return r&&s>0?s:void 0}function rt(e){for(const n of Wr)if(e.startsWith(n))return n}const tt={};{const e=(n,i)=>{for(const r of i)tt[r]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function mt(e,n){const i=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(Tt))if(e.includes(r)&&!(i&&tt[r]&&tt[r]!==i&&Mr[`${i}|${r}`]==null))return r}function qt(e){var a,p,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 r=(a=e.lineage)==null?void 0:a.year_text;if(r){const d=rt(r)??"";return{era:Ae(d),reign:mt(r,d)??"",source:"lineage"}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const d=jn(s);if(d)return{era:Va(d.from),reign:"",source:"publication"};const u=rt(s)??mi(s)??((c=It.find(m=>m.pattern.test(s)))==null?void 0:c.era)??"",g=mt(s,u)??"",x=u||(g?tt[g]??"":"");if(x||g)return{era:Ae(x),reign:g,source:"publication"}}const l=e.edition||e.title||"";if(l){const d=rt(l);if(d)return{era:Ae(d),reign:mt(l,d)??"",source:"edition"};const u=It.find(g=>g.pattern.test(l));if(u)return{era:Ae(u.era),reign:mt(l,u.era)??u.reign??"",source:"edition"}}return n}function vn(e){var r,s,l,a,p,c,d,u,g;if(((r=e.dating)==null?void 0:r.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(l=e.publication_info)==null?void 0:l.year;if(n){const x=jn(n);if(x)return x.from}const i=[(a=e.lineage)==null?void 0:a.year_text,(p=e.publication_info)==null?void 0:p.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const x of i){const m=((c=e.publication_info)==null?void 0:c.year)||((d=e.lineage)==null?void 0:d.year_text);if(m&&x!==m&&(rt(m)||mi(m)))break;const b=x.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??x.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(b){const v=parseInt(b[1],10);if(v>=100&&v<=2100)return v}const k=x.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(k){const v=rt(x);if(!v||Ae(v)==="民國"){const S=xn(k[1]);if(S!=null&&S>=1&&S<=120)return Ka+S}}const h=rt(x)??((u=It.find(v=>v.pattern.test(x)))==null?void 0:u.era),y=h?Ae(h):void 0,j=mt(x,y)??(rt(x)||(g=It.find(v=>v.pattern.test(x)))==null?void 0:g.reign);if(j){const v=ft(j,y);if(v==null)continue;const _=x.indexOf(j),S=_>=0?x.slice(_+j.length):"",$=S.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??S.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),w=$?xn($[1]):void 0;return v+(w?w-1:0)}}}function hi(e){var a,p,c,d,u,g;const n=(a=e.dating)==null?void 0:a.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const i=(p=e.lineage)==null?void 0:p.year_range;if(i&&i.length===2)return{from:i[0],to:i[1]};const r=(c=e.lineage)==null?void 0:c.year_text;if(r){const x=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(x){const m=Vn[Ae(x[1])],b=gt[Ae(x[2])];if(m!=null&&b!=null)return{from:Math.min(m,b)-20,to:Math.max(m,b)+40}}}const s=(d=e.publication_info)==null?void 0:d.year;if(s){const x=jn(s);if((x==null?void 0:x.to)!=null)return{from:x.from,to:x.to};const m=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const b=Vn[Ae(m[1])],k=gt[Ae(m[2])];if(b!=null&&k!=null)return{from:Math.min(b,k)-20,to:Math.max(b,k)+40}}}const l=[(u=e.publication_info)==null?void 0:u.year,e.edition,e.title].filter(Boolean);for(const x of l){if(!/[間间]/.test(x))continue;const m=rt(x)??mi(x)??((g=It.find(h=>h.pattern.test(x)))==null?void 0:g.era),b=m?Ae(m):void 0,k=[];for(const h of Object.keys(Tt))x.includes(h)&&(b&&tt[h]&&tt[h]!==b||ft(h,b)!=null&&k.push(h));if(k.length===0){const h=x.match(/([一-鿿])([一-鿿])[間间]/);if(h&&b){for(const y of[h[1],h[2]])for(const j of Object.keys(Tt))if(tt[j]===b&&!(j[0]!==y&&j[j.length-1]!==y)&&ft(j,b)!=null){k.push(j);break}}}if(k.length>0){const h=k.map(_=>ft(_,b)).filter(_=>_!=null),y=Math.min(...h),j=k.reduce((_,S)=>ft(_,b)>=ft(S,b)?_:S),v=qa(j)??Nn(b??"")??Math.max(...h);return{from:y,to:v>y?v:Nn(b??tt[j]??"")??y}}if(b&>[b]!=null)return{from:gt[b],to:Nn(b)??gt[b]}}}const gt={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Za=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Xa=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,ko=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function So(e,n){for(const i of Wr){const r=e.indexOf(i);if(r<0)continue;if(i.length===1){const c=e[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!mt(e.slice(r),Ae(i)))continue}const s=Ae(i);if(s===n)continue;const l=e.slice(r),a=mt(l,s)??"";let p;if(a){const c=ft(a,s);if(c!=null){const u=l.slice(l.indexOf(a)+a.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),g=u?xn(u[1]):void 0;p=c+(g?g-1:0)}}return{era:s,reign:a,year:p}}for(const i of It)if(i.pattern.test(e))return{era:Ae(i.era),reign:i.reign??""}}function Qa(e){var y,j,v,_,S;const n=qt(e),i=((y=e.publication_info)==null?void 0:y.year)??"",r=i?jn(i):void 0;if(!n.era&&!n.reign&&!r)return;const s=e.edition||e.title||"",l=/[間间]/.test(s),a=((j=e.lineage)==null?void 0:j.year_text)??"",p=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(a),c=n.source==="publication"&&Ya.test(i),d=n.source==="publication"&&/[間间]/.test(i),u=a.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let g;l||p||c||d?g=void 0:u?g=parseInt(u[2],10):g=vn(e);const x=g==null?hi(e):void 0;let m;n.source==="publication"&&(c||ko.test(i))?m="uncertain":n.source==="lineage"||n.source==="publication"?m="attested":ko.test(s)||!n.reign&&g==null?m="uncertain":m="inferred";const b=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((v=e.lineage)==null?void 0:v.year_text)??((_=e.lineage)==null?void 0:_.year)??""}」`:`出版著錄「${((S=e.publication_info)==null?void 0:S.year)??""}」`,k={era:n.era,reign:n.reign,year:g,yearRange:x,certainty:m,source:n.source==="edition"?"edition":"catalog",basis:b};if(u){const $=a.match(/[、,,]\s*([宋元明清])/);$&&$[1]!==k.era&&(k.laterRepair={era:$[1]})}if(!k.laterRepair&&Xa.test(s)){const $=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);$&&$[1]!==n.era&&(k.laterRepair={era:$[1]})}const h=Za.find($=>$.re.test(s));if(h){const $=s.search(h.re),w=s.slice($),C=So(w,n.era)??So(s,n.era);C&&(k.basedOn={era:C.era,reign:C.reign,year:C.year,relation:h.relation})}return k}const Vn={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Nn(e){return Vn[e]}function fn(e){const n=vn(e);if(n!=null)return n;const i=hi(e);if(i)return i.from;const r=qt(e).era;return r?gt[r]:void 0}const wo=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Yn(e){const n=wo.indexOf(e);return n===-1?wo.length:n}function ec(e){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of e){const l=s.relation;l==="part_of"?n.belongsTo.push(s):l==="collected_in"?n.collected.push(s):l==="has_part"||l==="contains_text_of"?n.contains.push(s):l==="text_carried_by"||l==="studied_by"||l==="derived_from"||l==="followed_by"||l==="has_adaptation"?n.derivative.push(s):l==="studies"||l==="preceded_by"?n.studies.push(s):n.related.push(s)}const i=[],r=(s,l)=>{n[s].length&&i.push({key:s,labelKey:l,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),i}function bi(e,n){const i=di(e||[]),r=new Map,s=[];for(const d of i)d.group?(r.has(d.group)||r.set(d.group,[]),r.get(d.group).push(d)):s.push(d);for(const d of r.values())d.sort((u,g)=>{const x=m=>m.group_role==="origin"?0:m.group_role==="mirror"?1:2;return x(u)-x(g)});const l={text:[],image:[],textImage:[],physical:[]};for(const d of s){const u=yt(d),g=u.includes("text"),x=u.includes("image");g&&x?l.textImage.push(d):g?l.text.push(d):x?l.image.push(d):l.physical.push(d)}const p=["text","image","textImage","physical"].filter(d=>l[d].length>0).map(d=>({key:d,items:l[d]})),c=[...r.entries()].map(([d,u])=>{var g,x;return{key:d,label:((g=n==null?void 0:n[d])==null?void 0:g.label)||d,description:(x=n==null?void 0:n[d])==null?void 0:x.description,items:u}});return{buckets:p,mirrors:c,total:i.length}}function kn(e){const n=[],i=e.metadata||{};i.edition&&n.push(String(i.edition)),e.source_label&&n.push(e.source_label),e.details&&n.push(e.details);const r=hn(e);return r&&r.expected>0&&n.push(r.missing>0?`${r.found} / ${r.expected} 冊 缺 ${r.missing}`:`${r.found} / ${r.expected} 冊`),i.version&&n.push(String(i.version)),n.join(" · ")}function Fr(e,n){if(kn(e)||n.filter(r=>r.name===e.name).length<2)return"";try{const r=new URL(e.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const l=r.pathname.split("/").filter(Boolean).pop();if(l)return decodeURIComponent(l)}catch{}return""}function Pr(e,n){var l,a;const i=e.resources||[],r=[],s=[];for(const p of i){const c=yt(p);c.includes("image")&&r.push(p),c.includes("physical")&&s.push(p)}return{id:e.id,name:e.edition||e.title||e.id,era:qt(e),year:vn(e),sortYear:fn(e),images:r,holders:s,locationName:(l=e.current_location)==null?void 0:l.name,important:tc(e.id,n),group:(a=n==null?void 0:n.node_groups)==null?void 0:a[e.id],hasImage:r.length>0}}function tc(e,n){var p,c;if(!n)return!1;const i=n.default_collection;if(!i)return!1;const r=(p=n.collections)==null?void 0:p[i];if(((r==null?void 0:r.book_ids)??(i==="core"?n.core_books??[]:[])).includes(e))return!0;const l=(r==null?void 0:r.groups)??[],a=(c=n.node_groups)==null?void 0:c[e];return!!a&&l.includes(a)}function Or(e,n,i={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!r.has(c.id)).map(c=>Pr(c,n));let l=s;i.era&&(l=l.filter(c=>c.era.era===i.era)),i.scanOnly&&(l=l.filter(c=>c.hasImage)),i.sort==="year"?l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=c.r.sortYear,g=d.r.sortYear;return u!=null&&g!=null?u-g||c.i-d.i:u!=null?-1:g!=null?1:c.i-d.i}).map(c=>c.r):l=l.map((c,d)=>({r:c,i:d})).sort((c,d)=>{const u=g=>(g.important?0:1)*2+(g.hasImage?0:1);return u(c.r)-u(d.r)||c.i-d.i}).map(c=>c.r);const p=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,d)=>Yn(c)-Yn(d));return{rows:l,allRows:s,eras:p,hasInferredEra:s.some(c=>c.era.source==="edition")}}function nc(e,n){var h,y;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const i=(h=n.collections)==null?void 0:h[n.default_collection],r=(i==null?void 0:i.groups)??[],s=(i==null?void 0:i.book_ids)??[],l=r.length>0||s.length>0,a=!l&&n.default_collection==="core"&&Array.isArray(n.core_books)?n.core_books:[];if(!l&&a.length===0)return{useGrouping:!1,coreIds:e,groupedIds:[]};const p=new Set(r),c=new Set([...s,...a]),d=j=>{if(c.has(j))return!0;const v=n.node_groups[j];return v!=null&&p.has(v)},u=[],g=new Map,x=[];for(const j of e)if(!((y=n.excluded_books)!=null&&y.includes(j)))if(d(j))u.push(j);else{const v=n.node_groups[j];v?(g.has(v)||g.set(v,[]),g.get(v).push(j)):x.push(j)}if(x.length+[...g.values()].reduce((j,v)=>j+v.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const b=new Map((n.groups??[]).map(j=>[j.id,j])),k=[...g.entries()].map(([j,v])=>{const _=b.get(j);return{id:j,label:(_==null?void 0:_.label)??j,description:_==null?void 0:_.description,ids:v}});return x.length>0&&k.push({id:"__other__",label:"其他版本",description:void 0,ids:x}),{useGrouping:!0,coreIds:u,groupedIds:k}}const Dr=["撰","編","注","校","譯","繪","其他"],ic=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function yi(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:i,re:r}of ic)if(r.test(n))return i;return"其他"}function ji(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Hr(e){const n=new Map;for(const r of e){const s=yi(r);n.set(s,(n.get(s)??0)+1)}const i=[{cls:"全部",label:"全部",count:e.length}];for(const r of Dr){const s=n.get(r);s&&i.push({cls:r,label:r,count:s})}return i.length>2?i:[]}function Gr(e,n,i){if(n&&n.books&&n.books.length>0){const s=n.books.map(a=>({id:a.work_id||a.book_id||void 0,title:a.title,section:a.section,volumes:a.volumes||[],subItems:a.sub_items,edition:a.edition,found:a.found_volumes,expected:a.expected_volumes})),l=[...new Set(s.map(a=>a.section).filter(Boolean))];return{rows:s,source:"catalog",sections:l,totalVolumes:n.total_volumes}}return e.contained_works&&e.contained_works.length>0?{rows:e.contained_works.map(l=>({id:l.id,title:l.title,volumes:Gt(l.volume_index)})),source:"works",sections:[]}:{rows:(e.books||[]).map(s=>{var l,a;return{id:s,title:((l=i==null?void 0:i.get(s))==null?void 0:l.title)||s,edition:(a=i==null?void 0:i.get(s))==null?void 0:a.edition,volumes:[]}}),source:"books",sections:[]}}function Gt(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,r]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,r-i+1)},(s,l)=>i+l)}return e.split(/[,、]/).map(i=>parseInt(i.trim())).filter(i=>!isNaN(i))}return[]}function Sn(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const i=[...e].sort((l,a)=>l-a),r=i[0],s=i[i.length-1];return s-r+1===i.length?`${r}–${s}`:i.length<=3?i.join(", "):`${r}–${s} (${i.length}${n})`}const oc=["〇","一","二","三","四","五","六","七","八","九"],_o=["","十","百","千"];function Ur(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),i=n.length;let r="",s=!1;for(let l=0;l<i;l++){const a=parseInt(n[l]),p=i-1-l;a===0?s=!0:(s&&r&&(r+="〇"),s=!1,a===1&&p===1&&l===0?r+=_o[p]:r+=oc[a]+_o[p])}return r}function rc(e){return e==null?"":typeof e=="string"?e:e.title??""}function lt(e,n="卷"){var r,s;const i=e;return i.measure_info?i.measure_info:(r=i.juan_count)!=null&&r.number?Ur(i.juan_count.number)+n:(s=i.juan_count)!=null&&s.description?i.juan_count.description:""}function Vr(e){var r;if(e.edition_type)return e.edition_type;if((r=e.lineage)!=null&&r.category)return e.lineage.category;const n=e.edition||e.title||"",i=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,l]of i)if(s.test(n))return l;return""}const sc="guji_markdown";function Kn(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 r=parseInt(i[1],10),s=parseInt(i[2],10);return r>0||s>=2}const lc=/^□\{guess=([^\s{}]+)\}/;function ac(e,n){const i=e[n+1];return i!==void 0&&!/[A-Za-z/!?>\s]/.test(i)}function Yr(e,n){let i=0;for(let r=n;r<e.length;r++){const s=e[r];if(s===`
|
|
12
|
-
`)return-1;if(s==="\\"){r++;continue}if(s==="[")
|
|
13
|
-
`)<0?{node:{type:"qw",label:e.slice(n+2,r)},end:r+2}:null}if(
|
|
14
|
-
`)return null}const c=
|
|
15
|
-
.bim-d-main.bim-d-main-grid { max-width: ${
|
|
11
|
+
}`,Ir={color:"inherit",textDecoration:"none"},fa=({snippet:e})=>{const{convert:n}=Z();return t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.6},children:vr(e).map((o,r)=>o.marked?t.jsx("mark",{style:{background:i("highlight-bg"),color:i("highlight-fg"),padding:"0 1px",borderRadius:"2px"},children:n(o.text)},r):t.jsx(g.Fragment,{children:n(o.text)},r))})},ga=({entry:e,selected:n,onClick:o,getConfig:r,query:s})=>{const l=ue(),{convert:d}=Z(),p=d(e.title||e.primary_name||e.id),c=e.measure_info?d(e.measure_info):e.juan_count!=null&&e.juan_count>0?`${e.juan_count}${l.unit.juan}`:"",a=[...e.additional_titles||[],...e.attached_texts||[]],u=s&&a.length?a.find(m=>{const j=typeof m=="string"?m:m==null?void 0:m.book_title;return j==null?void 0:j.toLowerCase().includes(s.toLowerCase())}):void 0,f=i("cover-accent"),x=Pe();return t.jsxs("a",{href:x(e.id),onClick:m=>o(e,m),className:"bim-result-card",style:{...Ir,display:"flex",gap:"1.2rem",alignItems:"stretch",padding:"1.1rem 1.3rem",borderRadius:"12px",cursor:"pointer",background:i("bg"),border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,transition:"border-color .2s ease, transform .2s ease, box-shadow .2s ease"},children:[t.jsxs("div",{"aria-hidden":"true",style:{position:"relative",width:"92px",minHeight:"126px",flexShrink:0,borderRadius:"4px",border:`1px solid color-mix(in srgb, ${f} 50%, ${i("widget-border")})`,background:`linear-gradient(color-mix(in srgb, ${f} 14%, ${i("bg")}), color-mix(in srgb, ${f} 7%, ${i("bg")}))`,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.6rem 0.3rem"},children:[t.jsx("span",{style:{position:"absolute",left:"6px",top:0,bottom:0,borderLeft:`1px dashed color-mix(in srgb, ${f} 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:f},children:Array.from(p).map((m,j)=>t.jsx("span",{children:m},j))})]}),t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:"17px",fontWeight:600,color:i("fg")},children:p}),c&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:c})]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg")},children:[e.dynasty&&t.jsxs("span",{children:["〔",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.era||e.edition)&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[e.era&&t.jsxs("span",{children:["〔",d(e.era),"〕"]}),e.edition&&t.jsx("span",{children:d(e.edition)})]}),u&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg")},children:[l.search.alias,":",d(typeof u=="string"?u:u.book_title||"")]}),e.descriptionSnippet&&t.jsx(fa,{snippet:e.descriptionSnippet}),t.jsxs("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"auto",paddingTop:"4px"},children:[t.jsxs("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:[t.jsx(vn,{type:e.type,size:8})," ",r(e.type).name]}),e.has_text&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.textResource}),e.has_image&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",borderRadius:"999px",color:i("desc-fg"),border:`1px solid ${i("widget-border")}`},children:l.misc.imageResource})]})]})]})},ho=({entry:e,selected:n,onClick:o,getConfig:r,query:s,onRemove:l})=>{const d=ue(),{convert:p}=Z(),c=[...e.additional_titles||[],...e.attached_texts||[]],a=s&&c.length?c.find(f=>{const x=typeof f=="string"?f:f==null?void 0:f.book_title;return x==null?void 0:x.toLowerCase().includes(s.toLowerCase())}):void 0,u=Pe();return t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",borderRadius:"6px",border:n?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[t.jsxs("a",{href:u(e.id),onClick:f=>o(e,f),className:"bim-result-card",style:{...Ir,flex:1,minWidth:0,display:"flex",alignItems:"flex-start",gap:"10px",padding:l?"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(vn,{type:e.type,size:12}),t.jsx("span",{style:{fontSize:"9px",color:i("desc-fg"),lineHeight:1},children:r(e.type).name})]}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:p(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:d.misc.textResource}),e.has_image&&t.jsx("span",{children:d.misc.imageResource})]}),(e.era||e.edition)&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[e.era&&t.jsxs(t.Fragment,{children:["〔",p(e.era),"〕"]}),e.edition&&p(e.edition)]}),e.measure_info?t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:p(e.measure_info)}):e.juan_count!=null&&e.juan_count>0?t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[e.juan_count,d.unit.juan]}):null]}),(e.dynasty||e.author)&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px"},children:[e.dynasty&&t.jsxs("span",{children:["〔",p(e.dynasty),"〕"]}),e.author&&t.jsx("span",{children:p(e.author)}),e.role&&e.role!=="author"&&t.jsxs("span",{children:[" ",p(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??"?"]})]}),a&&t.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:[d.search.alias,":",p(a)]})]}),!l&&t.jsx("span",{"aria-hidden":"true",style:{opacity:.4,marginTop:"2px"},children:"→"})]}),l&&t.jsx("button",{type:"button",onClick:()=>l(e.id),title:d.search.removeFromRecent,"aria-label":d.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"12px 12px 12px 8px",lineHeight:1,opacity:.5},children:"×"})]})},ma=({id:e,onRemove:n,t:o})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${i("widget-border")}`,background:i("input-bg"),opacity:.6},children:[t.jsx("span",{style:{fontSize:"16px"},children:"❓"}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:"13px",color:i("fg"),fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:"11px",color:i("desc-fg"),marginTop:"2px"},children:o.search.itemNotFound})]}),t.jsx("button",{onClick:()=>n(e),title:o.search.removeFromRecent,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"14px",padding:"2px 4px",lineHeight:1},children:"×"})]});function ha(e){var n;return!e.dynasty&&!e.birth_year&&!e.death_year&&(!e.alt_names||e.alt_names.length===0)&&!((n=e.description)!=null&&n.text)}function ba({data:e}){const{convert:n}=Z(),{dynasty:o,birth_year:r,death_year:s}=e,l=[];return o&&l.push(`〔${n(o)}〕`),r!==void 0&&s!==void 0?l.push(`${r}—${s}`):r!==void 0?l.push(`${r}—?`):s!==void 0&&l.push(`?—${s}`),l.length===0?null:t.jsx("span",{style:{fontSize:"14px",color:i("desc-fg"),marginLeft:"8px",fontWeight:"normal"},children:l.join(" ")})}function ya({alt_names:e}){const{convert:n}=Z(),o=new Map;for(const l of e){const d=l.type||"別名";o.has(d)||o.set(d,[]),o.get(d).push(l.name)}const r=["字","號","本名","諡號","賜號","常用名","別名","稱號","簡體","行第","小名","小字","俗姓","俗名","廟號","尊號","法號","道號","年號"],s=[...o.keys()].sort((l,d)=>{const p=r.indexOf(l),c=r.indexOf(d);return p===-1&&c===-1?0:p===-1?1:c===-1?-1:p-c});return t.jsx("div",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0 4px"},children:s.map(l=>{const d=o.get(l);return t.jsxs("div",{style:{display:"flex",gap:"6px",marginBottom:"2px"},children:[t.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px",minWidth:"36px",paddingTop:"2px"},children:l}),t.jsx("span",{children:d.map((p,c)=>t.jsxs("span",{children:[c>0&&t.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),n(p)]},c))})]},l)})})}function ja({data:e}){const n=e.external_ids;if(!n)return null;const o=[];return n.cbdb_id&&o.push(t.jsxs("a",{href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${n.cbdb_id}`,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 8px",fontSize:"12px",color:i("link-fg"),border:`1px solid ${i("link-fg")}40`,borderRadius:"3px",textDecoration:"none",background:`${i("link-fg")}08`},title:"CBDB 中国历代人物传记数据库",children:["CBDB ",n.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 va({works:e,transport:n,onNavigate:o,renderLink:r}){const s=ue(),{convert:l}=Z(),d=Pe(),[p,c]=g.useState(new Map);g.useEffect(()=>{if(!n)return;let x=!1;const m=e.map(w=>w.work_id);return(async()=>{const w=new Map;if(n.getEntriesByIds)try{const k=await n.getEntriesByIds(m);let $=!0;for(let v=0;v<m.length;v++){const _=k[v];_!=null&&_.title?w.set(m[v],_.title):_!=null&&_.primary_name?w.set(m[v],_.primary_name):$=!1}if($)return w}catch{}const h=[...m],b=8,y=new Array(b).fill(0).map(async()=>{for(;h.length;){const k=h.shift();if(!k)break;if(!w.has(k))try{if(n.getEntry){const _=await n.getEntry(k);if(_!=null&&_.title){w.set(k,_.title);continue}}const $=await n.getItem(k),v=$&&($.title||$.primary_name)||k;w.set(k,v)}catch{w.set(k,k)}}});return await Promise.all(y),w})().then(w=>{x||c(w)}),()=>{x=!0}},[e,n]);const a=new Map;for(const x of e){const m=x.role||"";a.has(m)||a.set(m,[]),a.get(m).push(x)}const u=["撰","編","注","輯","集","校","評","譯","述","作",""],f=[...a.keys()].sort((x,m)=>{const j=u.indexOf(x),w=u.indexOf(m);return j===-1&&w===-1?x.localeCompare(m):j===-1?1:w===-1?-1:j-w});return t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:i("fg"),margin:"0 0 8px",paddingBottom:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[s.label.relatedWorks," ",t.jsxs("span",{style:{color:i("desc-fg"),fontWeight:"normal",fontSize:"12px"},children:["(",e.length,")"]})]}),f.map(x=>{const m=a.get(x);return t.jsxs("div",{style:{marginBottom:"8px"},children:[x&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"2px"},children:[l(x)," ",t.jsxs("span",{style:{color:i("desc-fg")},children:["(",m.length,")"]})]}),t.jsx("ul",{style:{margin:0,paddingLeft:x?"16px":"0",listStyle:x?"disc":"none",fontSize:"14px",lineHeight:1.8},children:m.map((j,w)=>{const h=l(p.get(j.work_id)||j.work_id);return r?t.jsx("li",{children:r(j.work_id,h)},w):o?t.jsx("li",{children:t.jsx("a",{href:d(j.work_id),onClick:b=>{b.metaKey||b.ctrlKey||(b.preventDefault(),o(j.work_id))},style:{color:i("link-fg"),textDecoration:"underline",cursor:"pointer"},children:h})},w):t.jsx("li",{children:h},w)})})]},x)})]})}const Tr=({data:e,transport:n,onNavigate:o,renderLink:r,headerExtra:s,hideHeader:l})=>{var f;const d=ue(),{convert:p}=Z();let c=!1;try{c=we.extractStatus(e.id)==="draft"}catch{}const a=ha(e),u=e.subtype==="people"?"人物":e.subtype==="place"?"地名":e.subtype==="dynasty"?"朝代":e.subtype==="anonymous"?"佚名":e.subtype==="collective"?"集体":e.subtype;return t.jsxs("div",{children:[!l&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px",marginBottom:"4px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:600,margin:0,lineHeight:1.3,color:i("fg")},children:[p(e.primary_name),t.jsx(ba,{data:e})]}),s]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:i("type-entity"),border:`1px solid color-mix(in srgb, ${i("type-entity")} 25%, transparent)`,borderRadius:"2px",background:`color-mix(in srgb, ${i("type-entity")} 3%, transparent)`},children:d.indexType.entity}),u&&e.subtype!=="people"&&t.jsx("span",{children:u}),c&&t.jsx("span",{style:{padding:"1px 6px",background:i("warn-bg"),border:`1px solid ${i("warn-border")}`,borderRadius:"2px",color:i("warn-fg")},children:d.status.draft}),t.jsx("span",{style:{fontFamily:"monospace",opacity:.6},children:e.id})]})]}),a&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),fontStyle:"italic",padding:"8px 12px",background:i("widget-bg"),border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",margin:"8px 0"},children:"人物信息暂缺。该 Entity 仅作为作者占位,详细生平资料尚待补充。"}),e.alt_names&&e.alt_names.length>0&&t.jsx(ya,{alt_names:e.alt_names}),t.jsx(ja,{data:e}),((f=e.description)==null?void 0:f.text)&&t.jsx("p",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"8px 0",textAlign:"justify"},children:p(e.description.text)}),e.works&&e.works.length>0&&t.jsx(va,{works:e.works,transport:n,onNavigate:o,renderLink:r})]})},ka=/[)」』】》〉”’。,、;:!?…(「『【《〈“‘]/;function wa(e){const n=e.search(ka);return n<0?[e,""]:[e.slice(0,n),e.slice(n)]}const Er={p:({children:e})=>t.jsx("p",{style:{margin:"0 0 0.5em"},children:e}),ul:({children:e})=>t.jsx("ul",{style:{margin:"0 0 0.5em",paddingLeft:"1.4em"},children:e}),ol:({children:e})=>t.jsx("ol",{style:{margin:"0 0 0.5em",paddingLeft:"1.6em"},children:e}),li:({children:e})=>t.jsx("li",{style:{marginBottom:"2px"},children:e}),a:({href:e,children:n})=>{let o=e,r="",s=n;if(e&&typeof n=="string"&&(n===e||n===Sa(e))){const[l,d]=wa(n);d&&(o=encodeURI(l),s=l,r=d)}return t.jsxs(t.Fragment,{children:[t.jsx("a",{href:o,target:o!=null&&o.startsWith("http")?"_blank":void 0,rel:o!=null&&o.startsWith("http")?"noopener noreferrer":void 0,style:{color:i("link")},children:s}),r]})},code:({children:e})=>t.jsx("code",{style:{background:i("bg-subtle"),padding:"1px 4px",borderRadius:3,fontSize:"0.92em"},children:e})};function Sa(e){try{return decodeURI(e)}catch{return e}}const _a={...Er,strong:({children:e})=>t.jsx(t.Fragment,{children:e})},lt=({text:e,plainStrong:n,style:o,className:r})=>{const{convert:s}=Z(),l=n?_a:Er;return t.jsx("div",{className:r,style:o,children:t.jsx(Tl,{remarkPlugins:[El],components:l,children:s(e)})})},$a=["〇","一","二","三","四","五","六","七","八","九"],bo=["","十","百","千"];function Rr(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const d=parseInt(n[l]),p=o-1-l;d===0?s=!0:(s&&r&&(r+="〇"),s=!1,d===1&&p===1&&l===0?r+=bo[p]:r+=$a[d]+bo[p])}return r}function Nr(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 za={book:i("type-book"),work:i("type-work"),collection:i("type-collection"),entity:i("type-entity")};function Ca({type:e}){const n=ue();return t.jsx("span",{style:Nr(za[e]),children:n.indexType[e]})}function Ia({isDraft:e}){const n=ue(),o=i(e?"status-draft":"status-official");return t.jsx("span",{style:Nr(o),children:e?n.status.draft:n.status.official})}function Ta({id:e}){const n=ue(),[o,r]=g.useState(!1),s=()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})};return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"1px 6px",fontSize:"11px",color:i("desc-fg"),background:i("bg-subtle"),border:`1px solid ${i("widget-border")}`,borderRadius:"2px"},children:[t.jsx("span",{children:n.label.id}),t.jsx("span",{style:{fontFamily:"monospace",fontSize:"11px",color:i("fg")},children:e}),t.jsx("span",{onClick:s,title:o?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"11px",opacity:o?1:.5,transition:"opacity 0.15s"},onMouseEnter:l=>l.currentTarget.style.opacity="1",onMouseLeave:l=>l.currentTarget.style.opacity=o?"1":"0.5",children:o?"✓":"⧉"})]})}function Ve({children:e,extra:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("desc-fg"),letterSpacing:"1px"},children:e}),t.jsx("span",{style:{flex:1}}),n]})}function nt({label:e,children:n}){return t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[t.jsx("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:e}),t.jsx("span",{style:{color:i("fg")},children:n})]})}function Lr({authors:e,type:n,onNavigate:o,renderLink:r}){const{convert:s}=Z();return t.jsx("span",{style:{fontSize:"14px",color:i("fg"),lineHeight:1.6},children:e.map((l,d)=>{const p=s(l.name),c=l.entity_id?t.jsx(Je,{id:l.entity_id,label:p,onNavigate:o,renderLink:r}):t.jsx("span",{style:{fontWeight:500},children:p});return t.jsxs("span",{children:[d>0&&t.jsx("span",{style:{color:i("desc-fg"),margin:"0 4px"},children:"·"}),l.dynasty&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:["〔",s(l.dynasty),"〕"]}),c,l.role&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px",marginLeft:"2px"},children:[" ",s(l.role)]})]},d)})})}function Je({id:e,label:n,onNavigate:o,renderLink:r}){const s=Pe();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{children:n||e})}function Ea({id:e,title:n,edition:o,type:r,isDraft:s,authors:l,volumeText:d,meta:p,headerExtra:c,onNavigate:a,renderLink:u}){return t.jsxs("div",{style:{marginBottom:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("h1",{style:{fontSize:"clamp(18px, 4vw, 24px)",fontWeight:700,color:i("fg"),margin:"0 0 6px",lineHeight:1.4,letterSpacing:"0.5px",wordBreak:"break-word",flex:1,minWidth:0},children:[n,o&&t.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:o}),d&&t.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:d})]}),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(Ca,{type:r}),t.jsx(Ia,{isDraft:s}),t.jsx(Ta,{id:e})]}),((l==null?void 0:l.length)||p.length>0)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[l&&l.length>0&&t.jsx(Lr,{authors:l,type:r,onNavigate:a,renderLink:u}),p]})]})}function Br({items:e,label:n,showMeta:o,onNavigate:r,renderLink:s}){const l=ue(),{convert:d}=Z();if(!e.length)return null;const[p,c]=g.useState(null);return t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:n}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.map((a,u)=>{const f=p===u;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...f?{boxShadow:i("shadow-card")}:{}},children:[t.jsxs("div",{onClick:()=>c(f?null:u),style:{padding:"8px 12px",background:i("input-bg"),cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.15s",transform:f?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:d(a.source)}),!f&&o&&a.title_info&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d(a.title_info)}),a.source_bid&&t.jsx("span",{onClick:x=>x.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:t.jsx(Je,{id:a.source_bid,label:l.action.view,onNavigate:r,renderLink:s})})]}),f&&t.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:`1px solid ${i("widget-border")}`},children:[o&&(a.title_info||a.author_info||a.edition)&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[a.title_info&&t.jsx(nt,{label:l.label.titleInfo,children:d(a.title_info)}),a.author_info&&t.jsx(nt,{label:l.label.authorInfo,children:d(a.author_info)}),a.edition&&t.jsx(nt,{label:l.label.edition,children:d(a.edition)})]}),a.summary&&t.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.summary}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:d(a.summary)})]}),a.comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.comment}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:d(a.comment)})]}),a.additional_comment&&t.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:l.section.additionalComment}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:d(a.additional_comment)})]})]})]},u)})})]})}function Ra({items:e,onNavigate:n,renderLink:o}){const r=ue();return t.jsx(Br,{items:e,label:r.section.indexed,showMeta:!0,onNavigate:n,renderLink:o})}function Ar({items:e,onNavigate:n,renderLink:o}){const r=ue();return t.jsx(Br,{items:e,label:r.section.emendated,onNavigate:n,renderLink:o})}function Wr({label:e,items:n}){const{convert:o}=Z();return n.length?t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:n.map((r,s)=>{const l=typeof r=="string"?r:r.book_title;return t.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:o(l)},s)})})]}):null}function Na({items:e}){const n=ue();return t.jsx(Wr,{label:n.section.aliases,items:e})}function La({items:e}){const n=ue();return t.jsx(Wr,{label:n.section.attachedTexts,items:e})}function Ba({items:e}){const n=ue(),{convert:o}=Z();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:n.section.appendix}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:e.map((r,s)=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:i("fg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:["《",o(r.book_title),"》",r.n_juan!=null&&t.jsxs("span",{style:{color:i("desc-fg"),fontSize:"12px"},children:[r.n_juan,n.unit.juan]})]},s))})]}):null}function Aa({items:e}){const n=ue(),{convert:o}=Z();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:n.section.locationHistory}),t.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[t.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:i("widget-border")}}),e.map((r,s)=>t.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[t.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:i("primary"),border:`1.5px solid ${i("input-bg")}`}}),t.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:i("fg")},children:o(r.name)}),r.description&&t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),marginLeft:"8px"},children:o(r.description)})]},s))]})]}):null}function Wa({items:e}){const n=ue(),{convert:o}=Z();return e.length?t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:n.section.historyOverview}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map((r,s)=>t.jsxs("div",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[t.jsx("span",{style:{position:"absolute",left:0,top:0,color:i("desc-fg")},children:"·"}),o(r)]},s))})]}):null}function yo({title:e,ids:n,transport:o,onNavigate:r,renderLink:s}){const{convert:l}=Z(),[d,p]=g.useState([]);return g.useEffect(()=>{if(!n.length){p([]);return}if(!o){p(n.map(a=>({id:a})));return}let c=!1;return Promise.all(n.map(a=>o.getItem(a).then(u=>({id:a,title:u?u.title:void 0,edition:u?u.edition:void 0,type:u?u.type:void 0})).catch(()=>({id:a})))).then(a=>{c||p(a)}),()=>{c=!0}},[n,o]),n.length?t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{children:[e,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",n.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(d.length?d:n.map(c=>({id:c}))).map(c=>{const a=c.edition?`${l(c.title)||c.id}(${l(c.edition)})`:l(c.title)||void 0;return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),transition:"border-color 0.15s"},children:t.jsx(Je,{id:c.id,label:a,onNavigate:r,renderLink:s})},c.id)})})]}):null}function Nn({book:e,onNavigate:n,renderLink:o}){const r=ue(),{convert:s}=Z(),[l,d]=g.useState(!1),p=e.resources&&e.resources.length>0,c=e.edition?s(e.edition):s(e.title)||void 0;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden",background:i("input-bg")},children:[t.jsxs("div",{style:{padding:"6px 12px",borderBottom:p&&!l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("div",{style:{flex:1,fontSize:"14px",lineHeight:1.4},children:t.jsx(Je,{id:e.id,label:c,onNavigate:n,renderLink:o})}),p&&t.jsx("span",{onClick:()=>d(a=>!a),style:{cursor:"pointer",fontSize:"10px",color:i("desc-fg"),userSelect:"none",transition:"transform 0.15s",transform:l?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:l?r.action.expand:r.action.collapse,children:"▼"})]}),p&&!l&&t.jsx("div",{style:{padding:"10px 14px"},children:t.jsx(fi,{items:e.resources,resourceGroups:e.resource_groups,groupByType:!0,onNavigate:n,renderLink:o})})]})}function Ma({ids:e,workData:n,transport:o,onNavigate:r,renderLink:s,footer:l}){const d=ue(),{convert:p}=Z(),[c,a]=g.useState([]);if(g.useEffect(()=>{if(!e.length){a([]);return}if(!o){a(e.map(w=>({id:w})));return}let j=!1;return Promise.all(e.map(w=>o.getItem(w).then(h=>({id:w,title:h?h.title:void 0,edition:h?h.edition:void 0,resources:h?h.resources:void 0,resource_groups:h?h.resource_groups:void 0})).catch(()=>({id:w})))).then(w=>{j||a(w)}),()=>{j=!0}},[e,o]),!e.length)return null;const u=c.length?c:e.map(j=>({id:j})),f=new Map(u.map(j=>[j.id,j])),x=n==null?void 0:n.version_graph,m=Fa(e,x);return t.jsxs(t.Fragment,{children:[t.jsxs(Ve,{children:[d.section.relatedVersions,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",e.length,")"]})]}),l,m.useGrouping?t.jsxs(t.Fragment,{children:[m.coreIds.length>0&&t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:m.coreIds.map(j=>{const w=f.get(j);return w?t.jsx(Nn,{book:w,onNavigate:r,renderLink:s},j):null})}),m.groupedIds.map(j=>t.jsxs("details",{style:{marginTop:12,border:`1px solid ${i("widget-border")}`,borderRadius:6,background:i("bg-subtle")},children:[t.jsxs("summary",{style:{cursor:"pointer",padding:"8px 14px",fontSize:14,fontWeight:600,color:i("fg"),userSelect:"none"},children:[p(j.label),t.jsxs("span",{style:{marginLeft:6,fontSize:12,color:i("desc-fg"),fontWeight:400},children:["(",j.ids.length,")"]}),j.description&&t.jsx("span",{style:{marginLeft:8,fontSize:12,color:i("desc-fg"),fontWeight:400},children:p(j.description)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",padding:"0 12px 12px"},children:j.ids.map(w=>{const h=f.get(w);return h?t.jsx(Nn,{book:h,onNavigate:r,renderLink:s},w):null})})]},j.id))]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px",marginTop:"12px"},children:u.map(j=>t.jsx(Nn,{book:j,onNavigate:r,renderLink:s},j.id))})]})}function Fa(e,n){var h,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(h=n.collections)==null?void 0:h[n.default_collection],r=(o==null?void 0:o.groups)??[],s=(o==null?void 0:o.book_ids)??[],l=r.length>0||s.length>0,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 p=new Set(r),c=new Set([...s,...d]),a=y=>{if(c.has(y))return!0;const k=n.node_groups[y];return k!=null&&p.has(k)},u=[],f=new Map,x=[];for(const y of e)if(!((b=n.excluded_books)!=null&&b.includes(y)))if(a(y))u.push(y);else{const k=n.node_groups[y];k?(f.has(k)||f.set(k,[]),f.get(k).push(y)):x.push(y)}if(x.length+[...f.values()].reduce((y,k)=>y+k.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const j=new Map((n.groups??[]).map(y=>[y.id,y])),w=[...f.entries()].map(([y,k])=>{const $=j.get(y);return{id:y,label:($==null?void 0:$.label)??y,description:$==null?void 0:$.description,ids:k}});return x.length>0&&w.push({id:"__other__",label:"其他版本",description:void 0,ids:x}),{useGrouping:!0,coreIds:u,groupedIds:w}}function Pa({workData:e,onNavigate:n,renderLink:o}){var d,p,c,a;const r=ue(),{convert:s}=Z(),l=!!((d=e.description)!=null&&d.text)||!!e.parent_work;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"8px",overflow:"hidden",background:i("input-bg"),marginTop:"4px"},children:[t.jsxs("div",{style:{padding:"6px 14px",borderBottom:l?`1px solid ${i("widget-border")}`:"none",display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap",background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`},children:[t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:t.jsx(Je,{id:e.id,label:s(e.title),onNavigate:n,renderLink:o})}),e.measure_info?t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:s(e.measure_info)}):((p=e.juan_count)==null?void 0:p.number)!=null&&e.juan_count.number>0?t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[Rr(e.juan_count.number),r.unit.juan]}):null,e.authors&&e.authors.length>0&&t.jsx("span",{style:{fontSize:"13px"},children:t.jsx(Lr,{authors:e.authors,type:"work",onNavigate:n,renderLink:o})})]}),l&&t.jsxs("div",{style:{padding:"8px 14px"},children:[((c=e.description)==null?void 0:c.text)&&t.jsx(lt,{text:e.description.text,style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,textAlign:"justify"}}),e.parent_work&&t.jsx("div",{style:{marginTop:(a=e.description)!=null&&a.text?"8px":0,fontSize:"13px"},children:t.jsx(nt,{label:r.label.parentWork,children:t.jsx(Je,{id:e.parent_work.id,label:s(e.parent_work.title),onNavigate:n,renderLink:o})})})]})]})}function Oa({items:e,onNavigate:n,renderLink:o}){const r=ue(),{convert:s}=Z();return e.length?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:e.map(l=>t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid color-mix(in srgb, ${i("type-collection")} 25%, transparent)`,borderRadius:"4px",background:`color-mix(in srgb, ${i("type-collection")} 3%, transparent)`},children:[t.jsx("span",{style:{fontSize:"11px",color:i("type-collection")},children:r.indexType.collection}),t.jsx(Je,{id:l.id,label:s(l.title)||l.id,onNavigate:n,renderLink:o}),l.volume_index!=null&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"2px"},children:Jt(r.catalog.volume,{n:l.volume_index})})]},l.id))}):null}const gi=({data:e,id:n,transport:o,onNavigate:r,renderLink:s,headerExtra:l,relatedBooksFooter:d,className:p,style:c})=>{var D,B,O,M,X,Y,E,ee;const a=ue(),{convert:u}=Z(),[f,x]=g.useState(null),[m,j]=g.useState(!1),[w,h]=g.useState(null),[b,y]=g.useState(null),[k,$]=g.useState([]),v=e||f;if(g.useEffect(()=>{if(e||!n||!o)return;let F=!1;return j(!0),h(null),o.getItem(n).then(q=>{F||(q?x(q):h(a.misc.notFoundEntry))}).catch(q=>{F||h(q instanceof Error?q.message:a.misc.loadFailed)}).finally(()=>{F||j(!1)}),()=>{F=!0}},[e,n,o]),g.useEffect(()=>{if(!v||!o){y(null),$([]);return}let F=!1;const q=v.type==="book"||v.type==="collection"?v.work_id:void 0;if(q?o.getItem(q).then(ae=>{!F&&ae&&ae.type==="work"&&y(ae)}).catch(()=>{}):y(null),v.type==="book"){const ae=v;ae.contained_in&&ae.contained_in.length>0?Promise.all(ae.contained_in.map(ne=>{const Q=typeof ne=="string"?ne:ne.id,ie=typeof ne=="string"?void 0:ne.volume_index;return o.getItem(Q).then(ge=>({id:Q,title:ge&&ge.title||Q,volume_index:ie})).catch(()=>({id:Q,title:Q,volume_index:ie}))})).then(ne=>{F||$(ne)}):$([])}else $([]);return()=>{F=!0}},[v,o]),m)return t.jsx("div",{className:p,style:{...c,padding:"24px"},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((F,q)=>t.jsx("div",{style:{height:q===1?"32px":"16px",width:`${F}px`,background:i("widget-border"),borderRadius:"4px",opacity:.4}},q))})});if(w)return t.jsx("div",{className:p,style:{...c,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:w});if(!v)return null;if(v.type==="entity")return t.jsx("div",{className:p,style:c,children:t.jsx(Tr,{data:v,transport:o,onNavigate:r,renderLink:s,headerExtra:l})});const _=v.type==="book"?v:null,S=v.type==="collection"?v:null,z=v.type==="work"?v:null;let N=!1;try{N=we.extractStatus(v.id)==="draft"}catch{}let T="";v.measure_info?T=u(v.measure_info):(D=v.juan_count)!=null&&D.number?T=Rr(v.juan_count.number)+a.unit.juan:(B=v.juan_count)!=null&&B.description&&(T=u(v.juan_count.description));const C=[];return(O=v.publication_info)!=null&&O.year&&C.push(t.jsx(nt,{label:a.label.year,children:v.publication_info.year},"year")),(M=v.current_location)!=null&&M.name&&C.push(t.jsx(nt,{label:a.label.currentLocation,children:u(v.current_location.name)},"loc")),(X=v.page_count)!=null&&X.description&&C.push(t.jsx(nt,{label:a.label.pageCount,children:v.page_count.description},"page")),_!=null&&_.edition&&C.push(t.jsx(nt,{label:a.label.edition,children:u(_.edition)},"ver")),z!=null&&z.parent_work&&C.push(t.jsx(nt,{label:a.label.parentWork,children:t.jsx(Je,{id:z.parent_work.id,label:u(z.parent_work.title),onNavigate:r,renderLink:s})},"pw")),z!=null&&z.parent_works&&z.parent_works.length>0&&!z.parent_work&&C.push(t.jsx(nt,{label:a.label.parentWork,children:z.parent_works.map((F,q)=>t.jsxs("span",{children:[q>0&&"、",t.jsx(Je,{id:F,onNavigate:r,renderLink:s})]},F))},"pws")),t.jsxs("div",{className:p,style:c,children:[t.jsx(Ea,{id:v.id,title:u(v.title),edition:v.edition?u(v.edition):void 0,type:v.type,isDraft:N,authors:v.authors,volumeText:T,meta:C,headerExtra:l,onNavigate:r,renderLink:s}),((Y=v.description)==null?void 0:Y.text)&&t.jsx(lt,{text:v.description.text,style:{fontSize:"14px",color:i("fg"),lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"}}),v.appendix&&v.appendix.length>0&&t.jsx("div",{style:{marginTop:8,marginBottom:4},children:v.appendix.map((F,q)=>t.jsxs("details",{style:{marginTop:6,padding:"6px 10px",background:i("bg-subtle"),borderRadius:4,border:`1px solid ${i("widget-border")}`},children:[t.jsx("summary",{style:{cursor:"pointer",fontWeight:600,fontSize:13,color:i("muted")},children:u(F.title)}),t.jsx(lt,{text:F.text,plainStrong:!0,style:{marginTop:8,fontSize:13,lineHeight:1.9,color:i("fg")}})]},q))}),k.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:a.section.containedIn}),t.jsx(Oa,{items:k,onNavigate:r,renderLink:s})]}),b&&t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:a.section.belongsToWork}),t.jsx(Pa,{workData:b,onNavigate:r,renderLink:s})]}),v.additional_works&&v.additional_works.length>0&&t.jsx(Ba,{items:v.additional_works}),v.additional_titles&&v.additional_titles.length>0&&t.jsx(Na,{items:v.additional_titles}),v.attached_texts&&v.attached_texts.length>0&&t.jsx(La,{items:v.attached_texts}),v.indexed_by&&v.indexed_by.length>0&&t.jsx(Ra,{items:v.indexed_by,onNavigate:r,renderLink:s}),v.emendated_by&&v.emendated_by.length>0&&t.jsx(Ar,{items:v.emendated_by,onNavigate:r,renderLink:s}),v.resources&&v.resources.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(Ve,{children:a.section.resources}),t.jsx(fi,{items:v.resources,resourceGroups:v.resource_groups,groupByType:!0,onNavigate:r,renderLink:s})]}),(_==null?void 0:_.location_history)&&_.location_history.length>0&&t.jsx(Aa,{items:_.location_history}),(S==null?void 0:S.history)&&S.history.length>0&&t.jsx(Wa,{items:S.history}),(_==null?void 0:_.related_books)&&_.related_books.length>0&&t.jsx(yo,{title:a.section.relatedVersions,ids:_.related_books,transport:o,onNavigate:r,renderLink:s}),(S==null?void 0:S.books)&&S.books.length>0&&t.jsx(yo,{title:a.section.containedBooks,ids:S.books,transport:o,onNavigate:r,renderLink:s}),(S==null?void 0:S.contained_works)&&S.contained_works.length>0&&t.jsxs("div",{children:[t.jsxs(Ve,{children:[a.section.containedWorks,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",S.contained_works.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:S.contained_works.map(F=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:t.jsx(Je,{id:F.id,label:u(F.title),onNavigate:r,renderLink:s})},F.id))})]}),(((E=z==null?void 0:z.books)==null?void 0:E.length)||0)+(((ee=z==null?void 0:z.collections)==null?void 0:ee.length)||0)>0&&t.jsx(Ma,{ids:[...(z==null?void 0:z.books)||[],...(z==null?void 0:z.collections)||[]],workData:z??void 0,transport:o,onNavigate:r,renderLink:s,footer:d}),(z==null?void 0:z.related_works)&&z.related_works.length>0&&(()=>{const F=[],q=z.related_works.filter(re=>re.relation==="part_of"),ae=z.related_works.filter(re=>re.relation==="has_part"),ne=z.related_works.filter(re=>re.relation==="has_adaptation"),Q=z.related_works.filter(re=>re.relation==="text_carried_by"),ie=new Set(["part_of","has_part","has_adaptation","text_carried_by"]),ge=z.related_works.filter(re=>!re.relation||!ie.has(re.relation));return q.length>0&&F.push({label:a.section.belongsToWork,items:q}),ae.length>0&&F.push({label:a.section.containedWorks,items:ae}),ne.length>0&&F.push({label:a.section.adaptations,items:ne}),Q.length>0&&F.push({label:a.section.derivativeWorks,items:Q}),ge.length>0&&F.push({label:a.section.relatedWorks,items:ge}),F.map(re=>t.jsxs("div",{children:[t.jsxs(Ve,{children:[re.label,t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400},children:["(",re.items.length,")"]})]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:re.items.map(le=>t.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg")},children:t.jsx(Je,{id:le.id,label:u(le.title),onNavigate:r,renderLink:s})},le.id))})]},re.label))})()]})};function Da({data:e}){const n=ue(),{convert:o}=Z(),{stats:r}=e,s=r.processed_volumes??r.total_found_volumes,l=s!=null&&e.total_volumes>0?Math.round(s/e.total_volumes*100):null;return t.jsxs("div",{style:{marginBottom:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:o(e.title)}),e.resource_name&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"6px"},children:o(e.resource_name)}),t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:i("desc-fg")},children:[t.jsxs("span",{children:[n.catalog.totalVolumes," ",t.jsx("strong",{style:{color:i("fg")},children:e.total_volumes})," ",n.unit.volume]}),l!=null&&t.jsxs("span",{children:[n.catalog.processed," ",t.jsx("strong",{style:{color:i("fg")},children:s})," ",n.unit.volume," (",l,"%)"]}),t.jsxs("span",{children:[n.catalog.contains," ",t.jsx("strong",{style:{color:i("fg")},children:r.total_books})," ",n.unit.bu]}),r.matched_works!=null&&r.matched_works>0&&t.jsxs("span",{children:[n.catalog.matched," ",t.jsx("strong",{style:{color:i("fg")},children:r.matched_works})," ",n.unit.bu]}),r.unmatched_works!=null&&r.unmatched_works>0&&t.jsxs("span",{children:[n.catalog.unmatched," ",t.jsx("strong",{style:{color:i("missing-fg")},children:r.unmatched_works})," ",n.unit.bu]})]}),e.source&&t.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:i("desc-fg")},children:[n.catalog.source," ",e.source]})]})}function Ha({sections:e,activeSection:n,onSelect:o}){const r=ue();return t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[t.jsx("button",{onClick:()=>o(null),style:jo(n===null),children:r.catalog.all}),e.map(s=>t.jsxs("button",{onClick:()=>o(s.name),style:jo(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 jo(e){return{padding:"4px 12px",border:e?`1px solid ${i("primary")}`:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:e?`color-mix(in srgb, ${i("primary")} 8%, transparent)`:"transparent",color:i(e?"primary":"fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function Ga({id:e,label:n,onNavigate:o,renderLink:r}){const s=Pe();return r?t.jsx(t.Fragment,{children:r(e,n)}):o?t.jsx("a",{href:s(e),onClick:l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o(e))},style:{color:i("link-fg"),cursor:"pointer",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`,paddingBottom:"1px",fontSize:"12px"},onMouseEnter:l=>l.currentTarget.style.borderBottomStyle="solid",onMouseLeave:l=>l.currentTarget.style.borderBottomStyle="dashed",children:n||e}):t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg")},children:n||e})}function Ua(e,n){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=e[0],r=e[e.length-1];return r-o+1===e.length?`${o}–${r}`:e.length<=3?e.join(", "):`${o}–${r} (${e.length}${n})`}function vo({book:e,onNavigate:n,renderLink:o,showVolumes:r}){const s=ue(),{convert:l}=Z(),d=e.book_id||e.work_id,p=r&&e.volumes.length>0?Ua(e.volumes,s.unit.volume):null,c=e.missing_volumes&&e.missing_volumes.length>0;return t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:`1px solid ${i("widget-border")}`,fontSize:"14px",lineHeight:1.8},children:[r&&t.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:i("desc-fg"),textAlign:"right"},children:p}),t.jsxs("span",{style:{flex:1,fontWeight:500,color:i("fg")},children:[l(e.title),e.sub_items&&e.sub_items.length>0&&t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg"),fontWeight:400,marginLeft:"6px"},children:["(",e.sub_items.map(a=>l(a)).join("、"),")"]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),fontWeight:400,marginLeft:"8px"},children:l(e.edition)})]}),e.expected_volumes!=null&&t.jsxs("span",{style:{fontSize:"11px",color:i(c?"missing-fg":"desc-fg"),flexShrink:0},children:[e.found_volumes??0,"/",e.expected_volumes,s.unit.volume]}),d&&t.jsx(Ga,{id:d,label:e.book_id?s.indexType.book:s.indexType.work,onNavigate:n,renderLink:o}),!d&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:s.catalog.unmatched_label})]})}const mi=({data:e,collectionId:n,transport:o,onNavigate:r,renderLink:s,className:l,style:d})=>{const p=ue(),[c,a]=g.useState(null),[u,f]=g.useState(!1),[x,m]=g.useState(null),[j,w]=g.useState(null),[h,b]=g.useState(""),y=e||c;g.useEffect(()=>{if(e||!n||!(o!=null&&o.getCollectionCatalog))return;let S=!1;return f(!0),m(null),o.getCollectionCatalog(n).then(z=>{S||(z?a(z):m(p.catalog.notFound))}).catch(z=>{S||m(z instanceof Error?z.message:p.catalog.loadFailed)}).finally(()=>{S||f(!1)}),()=>{S=!0}},[e,n,o,p]);const k=(y==null?void 0:y.sections)&&y.sections.length>0,$=g.useMemo(()=>{if(!y)return!1;if(y.volume_index&&Object.keys(y.volume_index).length>0)return!0;const S=y.books.map(N=>N.volumes[0]).filter(N=>N!=null);return new Set(S).size<S.length},[y]),v=g.useMemo(()=>{if(!y)return[];let S=y.books;if(j&&(S=S.filter(z=>z.section===j)),h.trim()){const z=h.trim().toLowerCase();S=S.filter(N=>N.title.toLowerCase().includes(z)||N.sub_items&&N.sub_items.some(T=>T.toLowerCase().includes(z))||N.edition&&N.edition.toLowerCase().includes(z))}return S},[y,j,h]),_=g.useMemo(()=>{if(!$)return null;const S=[],z=new Map;for(const T of v){if(!T.volumes||T.volumes.length===0)continue;const C=T.volumes[0];z.has(C)||z.set(C,[]),z.get(C).push(T)}const N=[...z.keys()].sort((T,C)=>T-C);for(const T of N)S.push({volume:T,books:z.get(T)});return S},[v,$]);return u?t.jsx("div",{className:l,style:{...d,padding:"24px"},children:t.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:p.catalog.loading})}):x?t.jsx("div",{className:l,style:{...d,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:x}):y?t.jsxs("div",{className:l,style:d,children:[t.jsx(Da,{data:y}),k&&t.jsx(Ha,{sections:y.sections,activeSection:j,onSelect:w}),t.jsxs("div",{style:{marginBottom:"12px"},children:[t.jsx("input",{type:"text",placeholder:p.search.searchBookName,value:h,onChange:S=>b(S.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"}}),t.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:i("desc-fg")},children:[v.length," ",p.unit.bu]})]}),t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[_?_.map((S,z)=>t.jsxs("div",{children:[t.jsx("div",{style:{padding:"4px 12px",background:i("bg"),borderBottom:`1px solid ${i("widget-border")}`,fontSize:"12px",fontWeight:600,color:i("desc-fg"),position:"sticky",top:0,zIndex:1},children:Jt(p.catalog.volume,{n:S.volume})}),S.books.map((N,T)=>t.jsx(vo,{book:N,onNavigate:r,renderLink:s,showVolumes:N.volumes.length>1},`${S.volume}-${T}`))]},`${S.volume}-${z}`)):v.map((S,z)=>t.jsx(vo,{book:S,onNavigate:r,renderLink:s,showVolumes:!0},z)),v.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:p.catalog.noMatch})]})]}):null},jt=()=>{const[e,n]=g.useState(1);return g.useEffect(()=>{const o=setInterval(()=>n(r=>r>=3?1:r+1),500);return()=>clearInterval(o)},[]),t.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:i("desc-fg"),fontSize:"14px"},children:"加载中"+".".repeat(e)})},Mr=["西漢","東漢","三國","西晉","東晉","南北朝","南朝","北朝","隋","唐","五代","北宋","南宋","宋","遼","西夏","金","元","南明","明","清","民國","日本","朝鮮","高麗","越南","琉球","西汉","东汉","西晋","东晋","南北朝","南朝","北朝","辽","民国","朝鲜","高丽"],Va={北宋:"宋",南宋:"宋",西漢:"漢",東漢:"漢",西汉:"漢",东汉:"漢",西晉:"晉",東晉:"晉",西晋:"晉",东晋:"晉",南明:"明",民国:"民國",辽:"遼",朝鲜:"朝鮮",高丽:"高麗",南北朝:"南北朝",南朝:"南北朝",北朝:"南北朝"};function We(e){return Va[e]??e}const It=[{pattern:/欽定四庫全書薈要|摛藻堂/,era:"清",reign:"乾隆"},{pattern:/欽定四庫全書|四庫全書|文淵閣|文瀾閣|文溯閣|文津閣|文匯閣|文宗閣|文瀾閣/,era:"清",reign:"乾隆"},{pattern:/钦定四库全书|四库全书|文渊阁|文澜阁|文溯阁|文津阁/,era:"清",reign:"乾隆"},{pattern:/武英殿聚珍|聚珍版/,era:"清",reign:"乾隆"},{pattern:/武英殿/,era:"清"},{pattern:/百衲本|涵芬樓|涵芬楼|商務印書館|商务印书馆|中華書局|中华书局/,era:"民國"},{pattern:/汲古閣|汲古阁/,era:"明",reign:"崇禎"}],Tt={熹平: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},Fr={"唐|元和":806,"日本|元和":1615,"明|正德":1506,"日本|正德":1711};function kn(e){const n=e.match(/^\s*(\d{3,4})(?:\s*[-–—~至]\s*(\d{3,4}))?/);if(!n)return;const o=parseInt(n[1],10);if(o<100||o>2100)return;const r=n[2]?parseInt(n[2],10):void 0;return{from:o,to:r!=null&&r>=o&&r<=2100?r:void 0}}function Ya(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 qa=/末[宋元明清]初|[約约]|推定|推算|前後|前后|左右|[前中後后末]期/,ko={曹魏:"三國",蜀漢:"三國",東吳:"三國",前蜀:"五代",後蜀:"五代"};function hi(e){const n=e.trim().replace(/[代朝]$/,"");for(const s of Object.keys(ko))if(n.startsWith(s))return ko[s];const o=We(n);if(gt[o]!=null)return o;const r=st(n);if(r&&n.length<=r.length+1)return We(r)}function ft(e,n){if(n){const o=Fr[`${n}|${e}`];if(o!=null)return o}return Tt[e]}const Ka=1911;function Ja(e){const n=Tt[e];if(n==null)return;const o=it[e];let r;for(const[s,l]of Object.entries(Tt))it[s]===o&&l>n&&(r==null||l<r)&&(r=l);return r!=null?r-1:void 0}const Za={零:0,"〇":0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9,十:10,廿:20,卅:30,元:1};function gn(e){if(!e)return;if(/^\d+$/.test(e))return parseInt(e,10);let n=0,o=0,r=!1;for(const l of e){const d=Za[l];if(d===void 0)return;r=!0,l==="十"?o=(o||1)*10:l==="廿"||l==="卅"?(n+=d,o=0):o>=10?(n+=o+d,o=0):o=o*10+d}const s=n+o;return r&&s>0?s:void 0}function st(e){for(const n of Mr)if(e.startsWith(n))return n}const it={};{const e=(n,o)=>{for(const r of o)it[r]=n};e("東漢",["熹平","建安"]),e("三國",["黃初","正始"]),e("五代",["廣政"]),e("西晉",["太康"]),e("東晉",["永和"]),e("隋",["開皇"]),e("唐",["貞觀","開元","天寶","貞元","元和","開成","會昌","咸通"]),e("宋",["建隆","太平興國","咸平","天禧","慶曆","皇祐","嘉祐","治平","熙寧","元豐","元祐","紹聖","崇寧","大觀","政和","宣和","建炎","紹興","隆興","乾道","淳熙","紹熙","慶元","嘉泰","開禧","嘉定","寶慶","紹定","端平","嘉熙","淳祐","寶祐","開慶","景定","咸淳"]),e("金",["大定","明昌"]),e("元",["至元","大德","皇慶","延祐","泰定","天曆","至順","至正"]),e("明",["洪武","永樂","宣德","正統","景泰","天順","成化","弘治","正德","嘉靖","隆慶","萬曆","泰昌","天啟","崇禎","弘光","隆武","紹武","永曆"]),e("清",["順治","康熙","雍正","乾隆","嘉慶","道光","咸豐","同治","光緒","宣統"]),e("日本",["慶長","寬永","正保","慶安","承應","明曆","萬治","寬文","延寶","天和","貞享","元祿","寶永","享保","元文","寬保","延享","寬延","寶曆","明和","安永","天明","寬政","享和","文化","文政","天保","弘化","嘉永","安政","萬延","文久","元治","慶應","明治","大正","昭和","天正","文祿","永祿","天文"])}function mt(e,n){const o=n==="北宋"||n==="南宋"?"宋":n;for(const r of Object.keys(Tt))if(e.includes(r)&&!(o&&it[r]&&it[r]!==o&&Fr[`${o}|${r}`]==null))return r}function Zt(e){var d,p,c;const n={era:"",reign:"",source:"none"},o=e.dating;if(o!=null&&o.era||o!=null&&o.reign)return{era:o.era??"",reign:o.reign??"",source:o.certainty==="attested"?"catalog":"edition"};const r=(d=e.lineage)==null?void 0:d.year_text;if(r){const a=st(r)??"";return{era:We(a),reign:mt(r,a)??"",source:"lineage"}}const s=(p=e.publication_info)==null?void 0:p.year;if(s){const a=kn(s);if(a)return{era:Ya(a.from),reign:"",source:"publication"};const u=st(s)??hi(s)??((c=It.find(m=>m.pattern.test(s)))==null?void 0:c.era)??"",f=mt(s,u)??"",x=u||(f?it[f]??"":"");if(x||f)return{era:We(x),reign:f,source:"publication"}}const l=e.edition||e.title||"";if(l){const a=st(l);if(a)return{era:We(a),reign:mt(l,a)??"",source:"edition"};const u=It.find(f=>f.pattern.test(l));if(u)return{era:We(u.era),reign:mt(l,u.era)??u.reign??"",source:"edition"}}return n}function wn(e){var r,s,l,d,p,c,a,u,f;if(((r=e.dating)==null?void 0:r.year)!=null)return e.dating.year;if(typeof((s=e.lineage)==null?void 0:s.year)=="number")return e.lineage.year;const n=(l=e.publication_info)==null?void 0:l.year;if(n){const x=kn(n);if(x)return x.from}const o=[(d=e.lineage)==null?void 0:d.year_text,(p=e.publication_info)==null?void 0:p.year,e.edition,e.edition?void 0:e.title].filter(Boolean);for(const x of o){const m=((c=e.publication_info)==null?void 0:c.year)||((a=e.lineage)==null?void 0:a.year_text);if(m&&x!==m&&(st(m)||hi(m)))break;const j=x.match(/(?:^|[^\d第卷冊册頁页])(\d{3,4})\s*年/)??x.match(/[((](\d{3,4})\s*(?:[-–—~至]\s*\d{3,4})?\s*年?[))]/);if(j){const k=parseInt(j[1],10);if(k>=100&&k<=2100)return k}const w=x.match(/民[國国]\s*([零〇一二三四五六七八九十廿卅百元\d]+)\s*年/);if(w){const k=st(x);if(!k||We(k)==="民國"){const v=gn(w[1]);if(v!=null&&v>=1&&v<=120)return Ka+v}}const h=st(x)??((u=It.find(k=>k.pattern.test(x)))==null?void 0:u.era),b=h?We(h):void 0,y=mt(x,b)??(st(x)||(f=It.find(k=>k.pattern.test(x)))==null?void 0:f.reign);if(y){const k=ft(y,b);if(k==null)continue;const $=x.indexOf(y),v=$>=0?x.slice($+y.length):"",_=v.match(/^([零〇一二三四五六七八九十廿卅元]+)年/)??v.match(/^[甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥]\s*[((]\s*([零〇一二三四五六七八九十廿卅元]+)\s*年?\s*[))]/),S=_?gn(_[1]):void 0;return k+(S?S-1:0)}}}function bi(e){var d,p,c,a,u,f;const n=(d=e.dating)==null?void 0:d.year_range;if(n&&n.length===2)return{from:n[0],to:n[1]};const o=(p=e.lineage)==null?void 0:p.year_range;if(o&&o.length===2)return{from:o[0],to:o[1]};const r=(c=e.lineage)==null?void 0:c.year_text;if(r){const x=r.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(x){const m=Vn[We(x[1])],j=gt[We(x[2])];if(m!=null&&j!=null)return{from:Math.min(m,j)-20,to:Math.max(m,j)+40}}}const s=(a=e.publication_info)==null?void 0:a.year;if(s){const x=kn(s);if((x==null?void 0:x.to)!=null)return{from:x.from,to:x.to};const m=s.match(/([宋元明清])\s*末\s*([宋元明清])\s*初/);if(m){const j=Vn[We(m[1])],w=gt[We(m[2])];if(j!=null&&w!=null)return{from:Math.min(j,w)-20,to:Math.max(j,w)+40}}}const l=[(u=e.publication_info)==null?void 0:u.year,e.edition,e.title].filter(Boolean);for(const x of l){if(!/[間间]/.test(x))continue;const m=st(x)??hi(x)??((f=It.find(h=>h.pattern.test(x)))==null?void 0:f.era),j=m?We(m):void 0,w=[];for(const h of Object.keys(Tt))x.includes(h)&&(j&&it[h]&&it[h]!==j||ft(h,j)!=null&&w.push(h));if(w.length===0){const h=x.match(/([一-鿿])([一-鿿])[間间]/);if(h&&j){for(const b of[h[1],h[2]])for(const y of Object.keys(Tt))if(it[y]===j&&!(y[0]!==b&&y[y.length-1]!==b)&&ft(y,j)!=null){w.push(y);break}}}if(w.length>0){const h=w.map($=>ft($,j)).filter($=>$!=null),b=Math.min(...h),y=w.reduce(($,v)=>ft($,j)>=ft(v,j)?$:v),k=Ja(y)??Ln(j??"")??Math.max(...h);return{from:b,to:k>b?k:Ln(j??it[y]??"")??b}}if(j&>[j]!=null)return{from:gt[j],to:Ln(j)??gt[j]}}}const gt={漢:-202,三國:220,晉:265,南北朝:420,隋:581,唐:618,五代:907,宋:960,遼:916,西夏:1038,金:1115,元:1271,明:1368,清:1644,民國:1912,日本:1600,朝鮮:1392,高麗:918,越南:1400,琉球:1400},Xa=[{re:/影印|景印|影鈔|影钞|景鈔|景钞/,relation:"影印"},{re:/翻刻|覆刻|覆刊|翻雕|重刊|重雕/,relation:"翻刻"},{re:/傳鈔|传钞|傳抄|传抄/,relation:"傳鈔"},{re:/配補|配补|百衲/,relation:"配補"},{re:/據.{0,12}本|据.{0,12}本/,relation:"據刊"}],Qa=/修補|修补|遞修|递修|[明清元宋]修本|後代修|后代修/,wo=/約|约|疑|傳為|传为|舊題|旧题|相傳|相传|待考|未詳|未详|\(疑\)|(疑)/;function So(e,n){for(const o of Mr){const r=e.indexOf(o);if(r<0)continue;if(o.length===1){const c=e[r+1]??"";if(!/[刻刊寫写鈔钞抄印本間间初末年時时代人臧藏]/.test(c)&&!mt(e.slice(r),We(o)))continue}const s=We(o);if(s===n)continue;const l=e.slice(r),d=mt(l,s)??"";let p;if(d){const c=ft(d,s);if(c!=null){const u=l.slice(l.indexOf(d)+d.length).match(/^([零〇一二三四五六七八九十廿卅元]+)年/),f=u?gn(u[1]):void 0;p=c+(f?f-1:0)}}return{era:s,reign:d,year:p}}for(const o of It)if(o.pattern.test(e))return{era:We(o.era),reign:o.reign??""}}function ec(e){var b,y,k,$,v;const n=Zt(e),o=((b=e.publication_info)==null?void 0:b.year)??"",r=o?kn(o):void 0;if(!n.era&&!n.reign&&!r)return;const s=e.edition||e.title||"",l=/[間间]/.test(s),d=((y=e.lineage)==null?void 0:y.year_text)??"",p=/末[宋元明清]初|[約约]|推定|前後|前后|左右/.test(d),c=n.source==="publication"&&qa.test(o),a=n.source==="publication"&&/[間间]/.test(o),u=d.match(/([宋元明清])[^、,,]*?[((](\d{3,4})[))][^、,,]*?原刻/);let f;l||p||c||a?f=void 0:u?f=parseInt(u[2],10):f=wn(e);const x=f==null?bi(e):void 0;let m;n.source==="publication"&&(c||wo.test(o))?m="uncertain":n.source==="lineage"||n.source==="publication"?m="attested":wo.test(s)||!n.reign&&f==null?m="uncertain":m="inferred";const j=n.source==="edition"?`題名「${s}」`:n.source==="lineage"?`版本傳承著錄「${((k=e.lineage)==null?void 0:k.year_text)??(($=e.lineage)==null?void 0:$.year)??""}」`:`出版著錄「${((v=e.publication_info)==null?void 0:v.year)??""}」`,w={era:n.era,reign:n.reign,year:f,yearRange:x,certainty:m,source:n.source==="edition"?"edition":"catalog",basis:j};if(u){const _=d.match(/[、,,]\s*([宋元明清])/);_&&_[1]!==w.era&&(w.laterRepair={era:_[1]})}if(!w.laterRepair&&Qa.test(s)){const _=s.match(/([宋元明清])\s*(?:初|末)?\s*(?:修補|修补|遞修|递修|修)/);_&&_[1]!==n.era&&(w.laterRepair={era:_[1]})}const h=Xa.find(_=>_.re.test(s));if(h){const _=s.search(h.re),S=s.slice(_),z=So(S,n.era)??So(s,n.era);z&&(w.basedOn={era:z.era,reign:z.reign,year:z.year,relation:h.relation})}return w}const Vn={漢:220,三國:280,晉:420,南北朝:589,隋:618,唐:907,五代:960,宋:1279,遼:1125,西夏:1227,金:1234,元:1368,明:1662,清:1911,民國:1975,日本:1912,朝鮮:1897,高麗:1392,越南:1945,琉球:1879};function Ln(e){return Vn[e]}function mn(e){const n=wn(e);if(n!=null)return n;const o=bi(e);if(o)return o.from;const r=Zt(e).era;return r?gt[r]:void 0}const _o=["漢","三國","晉","南北朝","隋","唐","五代","宋","遼","西夏","金","元","明","清","民國","日本","朝鮮","高麗","越南","琉球"];function Yn(e){const n=_o.indexOf(e);return n===-1?_o.length:n}function tc(e){const n={belongsTo:[],collected:[],contains:[],derivative:[],studies:[],related:[]};for(const s of e){const l=s.relation;l==="part_of"?n.belongsTo.push(s):l==="collected_in"?n.collected.push(s):l==="has_part"||l==="contains_text_of"?n.contains.push(s):l==="text_carried_by"||l==="studied_by"||l==="derived_from"||l==="followed_by"||l==="has_adaptation"?n.derivative.push(s):l==="studies"||l==="preceded_by"?n.studies.push(s):n.related.push(s)}const o=[],r=(s,l)=>{n[s].length&&o.push({key:s,labelKey:l,items:n[s]})};return r("belongsTo","belongsToWork"),r("collected","collectedIn"),r("contains","containedWorks"),r("derivative","derivativeWorks"),r("studies","studies"),r("related","relatedWorks"),o}function yi(e,n){const o=pi(e||[]),r=new Map,s=[];for(const a of o)a.group?(r.has(a.group)||r.set(a.group,[]),r.get(a.group).push(a)):s.push(a);for(const a of r.values())a.sort((u,f)=>{const x=m=>m.group_role==="origin"?0:m.group_role==="mirror"?1:2;return x(u)-x(f)});const l={text:[],image:[],textImage:[],physical:[]};for(const a of s){const u=yt(a),f=u.includes("text"),x=u.includes("image");f&&x?l.textImage.push(a):f?l.text.push(a):x?l.image.push(a):l.physical.push(a)}const p=["text","image","textImage","physical"].filter(a=>l[a].length>0).map(a=>({key:a,items:l[a]})),c=[...r.entries()].map(([a,u])=>{var f,x;return{key:a,label:((f=n==null?void 0:n[a])==null?void 0:f.label)||a,description:(x=n==null?void 0:n[a])==null?void 0:x.description,items:u}});return{buckets:p,mirrors:c,total:o.length}}function Sn(e){const n=[],o=e.metadata||{};o.edition&&n.push(String(o.edition)),e.source_label&&n.push(e.source_label),e.details&&n.push(e.details);const r=yn(e);return r&&r.expected>0&&n.push(r.missing>0?`${r.found} / ${r.expected} 冊 缺 ${r.missing}`:`${r.found} / ${r.expected} 冊`),o.version&&n.push(String(o.version)),n.join(" · ")}function Pr(e,n){if(Sn(e)||n.filter(r=>r.name===e.name).length<2)return"";try{const r=new URL(e.url),s=r.searchParams.get("res")||r.searchParams.get("id");if(s)return s;const l=r.pathname.split("/").filter(Boolean).pop();if(l)return decodeURIComponent(l)}catch{}return""}function Or(e,n){var l,d;const o=e.resources||[],r=[],s=[];for(const p of o){const c=yt(p);c.includes("image")&&r.push(p),c.includes("physical")&&s.push(p)}return{id:e.id,name:e.edition||e.title||e.id,era:Zt(e),year:wn(e),sortYear:mn(e),images:r,holders:s,locationName:(l=e.current_location)==null?void 0:l.name,important:nc(e.id,n),group:(d=n==null?void 0:n.node_groups)==null?void 0:d[e.id],hasImage:r.length>0}}function nc(e,n){var p,c;if(!n)return!1;const o=n.default_collection;if(!o)return!1;const r=(p=n.collections)==null?void 0:p[o];if(((r==null?void 0:r.book_ids)??(o==="core"?n.core_books??[]:[])).includes(e))return!0;const l=(r==null?void 0:r.groups)??[],d=(c=n.node_groups)==null?void 0:c[e];return!!d&&l.includes(d)}function Dr(e,n,o={}){const r=new Set((n==null?void 0:n.excluded_books)??[]),s=e.filter(c=>!r.has(c.id)).map(c=>Or(c,n));let l=s;o.era&&(l=l.filter(c=>c.era.era===o.era)),o.scanOnly&&(l=l.filter(c=>c.hasImage)),o.sort==="year"?l=l.map((c,a)=>({r:c,i:a})).sort((c,a)=>{const u=c.r.sortYear,f=a.r.sortYear;return u!=null&&f!=null?u-f||c.i-a.i:u!=null?-1:f!=null?1:c.i-a.i}).map(c=>c.r):l=l.map((c,a)=>({r:c,i:a})).sort((c,a)=>{const u=f=>(f.important?0:1)*2+(f.hasImage?0:1);return u(c.r)-u(a.r)||c.i-a.i}).map(c=>c.r);const p=[...new Set(s.map(c=>c.era.era).filter(Boolean))].sort((c,a)=>Yn(c)-Yn(a));return{rows:l,allRows:s,eras:p,hasInferredEra:s.some(c=>c.era.source==="edition")}}function ic(e,n){var h,b;if(!n||!n.default_collection||!n.node_groups)return{useGrouping:!1,coreIds:e,groupedIds:[]};const o=(h=n.collections)==null?void 0:h[n.default_collection],r=(o==null?void 0:o.groups)??[],s=(o==null?void 0:o.book_ids)??[],l=r.length>0||s.length>0,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 p=new Set(r),c=new Set([...s,...d]),a=y=>{if(c.has(y))return!0;const k=n.node_groups[y];return k!=null&&p.has(k)},u=[],f=new Map,x=[];for(const y of e)if(!((b=n.excluded_books)!=null&&b.includes(y)))if(a(y))u.push(y);else{const k=n.node_groups[y];k?(f.has(k)||f.set(k,[]),f.get(k).push(y)):x.push(y)}if(x.length+[...f.values()].reduce((y,k)=>y+k.length,0)<3)return{useGrouping:!1,coreIds:e,groupedIds:[]};const j=new Map((n.groups??[]).map(y=>[y.id,y])),w=[...f.entries()].map(([y,k])=>{const $=j.get(y);return{id:y,label:($==null?void 0:$.label)??y,description:$==null?void 0:$.description,ids:k}});return x.length>0&&w.push({id:"__other__",label:"其他版本",description:void 0,ids:x}),{useGrouping:!0,coreIds:u,groupedIds:w}}const Hr=["撰","編","注","校","譯","繪","其他"],oc=[{cls:"譯",re:/譯|译/},{cls:"繪",re:/繪|绘|畫|画|圖|图|篆|摹/},{cls:"校",re:/^(?!.*[編编輯辑纂])(?=.*(校|訂|订|勘|審|审|考異)).*/},{cls:"注",re:/注|註|疏|箋|笺|解|釋|释|音|義疏|章句|評|评|批|論|论|答/},{cls:"編",re:/編|编|輯|辑|纂|集|選|选|錄|录|彙|汇|續|续|補|补|刪|删|修|次|定/},{cls:"撰",re:/撰|譔|作|著|述|製|制|書|书|記|记|傳|传|題|题|序|跋|讚|贊|赞|頌|颂/}];function ji(e){if(!e||!e.trim())return"撰";const n=e.replace(/[\s-]/g,"");if(!n||n==="author")return"撰";for(const{cls:o,re:r}of oc)if(r.test(n))return o;return"其他"}function vi(e){if(!e)return"";const n=e.trim();return!n||!/[一-鿿]/.test(n)?"":n}function Gr(e){const n=new Map;for(const r of e){const s=ji(r);n.set(s,(n.get(s)??0)+1)}const o=[{cls:"全部",label:"全部",count:e.length}];for(const r of Hr){const s=n.get(r);s&&o.push({cls:r,label:r,count:s})}return o.length>2?o:[]}function Ur(e,n,o){if(n&&n.books&&n.books.length>0){const s=n.books.map(d=>({id:d.work_id||d.book_id||void 0,title:d.title,section:d.section,volumes:d.volumes||[],subItems:d.sub_items,edition:d.edition,found:d.found_volumes,expected:d.expected_volumes})),l=[...new Set(s.map(d=>d.section).filter(Boolean))];return{rows:s,source:"catalog",sections:l,totalVolumes:n.total_volumes}}return e.contained_works&&e.contained_works.length>0?{rows:e.contained_works.map(l=>({id:l.id,title:l.title,volumes:Ut(l.volume_index)})),source:"works",sections:[]}:{rows:(e.books||[]).map(s=>{var l,d;return{id:s,title:((l=o==null?void 0:o.get(s))==null?void 0:l.title)||s,edition:(d=o==null?void 0:o.get(s))==null?void 0:d.edition,volumes:[]}}),source:"books",sections:[]}}function Ut(e){if(e==null)return[];if(typeof e=="number")return[e];if(Array.isArray(e))return e.filter(n=>typeof n=="number");if(typeof e=="string"){const n=e.match(/^(\d+)\s*[-–~]\s*(\d+)$/);if(n){const[o,r]=[parseInt(n[1]),parseInt(n[2])];return Array.from({length:Math.max(0,r-o+1)},(s,l)=>o+l)}return e.split(/[,、]/).map(o=>parseInt(o.trim())).filter(o=>!isNaN(o))}return[]}function _n(e,n="冊"){if(e.length===0)return"";if(e.length===1)return`${e[0]}`;const o=[...e].sort((l,d)=>l-d),r=o[0],s=o[o.length-1];return s-r+1===o.length?`${r}–${s}`:o.length<=3?o.join(", "):`${r}–${s} (${o.length}${n})`}const rc=["〇","一","二","三","四","五","六","七","八","九"],$o=["","十","百","千"];function Vr(e){if(e<=0)return"";if(e>=1e4)return String(e);const n=String(e),o=n.length;let r="",s=!1;for(let l=0;l<o;l++){const d=parseInt(n[l]),p=o-1-l;d===0?s=!0:(s&&r&&(r+="〇"),s=!1,d===1&&p===1&&l===0?r+=$o[p]:r+=rc[d]+$o[p])}return r}function sc(e){return e==null?"":typeof e=="string"?e:e.title??""}function at(e,n="卷"){var r,s;const o=e;return o.measure_info?o.measure_info:(r=o.juan_count)!=null&&r.number?Vr(o.juan_count.number)+n:(s=o.juan_count)!=null&&s.description?o.juan_count.description:""}function Yr(e){var r;if(e.edition_type)return e.edition_type;if((r=e.lineage)!=null&&r.category)return e.lineage.category;const n=e.edition||e.title||"",o=[[/活字|聚珍/,"活字本"],[/石印/,"石印本"],[/影印|景印/,"影印本"],[/寫本|写本|繕寫|缮写/,"寫本"],[/鈔本|抄本/,"抄本"],[/拓本/,"拓本"],[/批校|評本|评本|校本/,"校本"],[/刻本|刊本|梓行|開雕/,"刻本"],[/排印|鉛印|铅印/,"排印本"]];for(const[s,l]of o)if(s.test(n))return l;return""}const lc="guji_markdown";function qn(e){const n=e==null?void 0:e.guji_markdown;if(typeof n!="string")return!1;const o=/^(\d+)\.(\d+)(?:\.\d+)?$/.exec(n.trim());if(!o)return!1;const r=parseInt(o[1],10),s=parseInt(o[2],10);return r>0||s>=2}const ac=/^□\{guess=([^\s{}]+)\}/;function cc(e,n){const o=e[n+1];return o!==void 0&&!/[A-Za-z/!?>\s]/.test(o)}function qr(e,n){let o=0;for(let r=n;r<e.length;r++){const s=e[r];if(s===`
|
|
12
|
+
`)return-1;if(s==="\\"){r++;continue}if(s==="[")o++;else if(s==="]"&&(o--,o===0))return r}return-1}function dc(e){return e.replace(/\\([\\[\]<>|{}])/g,"$1")}function pc(e,n){const o=e[n];if(o==="["&&e[n+1]==="["){const r=e.indexOf("]]",n+2);return r>=0&&e.slice(n+2,r).indexOf(`
|
|
13
|
+
`)<0?{node:{type:"qw",label:e.slice(n+2,r)},end:r+2}:null}if(o===":"&&e.startsWith(":zi[",n)){const r=qr(e,n+3);return r>n+4?{node:{type:"zi",label:dc(e.slice(n+4,r))},end:r+1}:null}if(o==="□"&&e[n+1]==="{"){const r=ac.exec(e.slice(n,n+64));if(r)return{node:{type:"qz",guess:r[1]},end:n+r[0].length}}return null}function Kr(e,n,o,r){const s=[];let l="";const d=()=>{if(!l)return;const p=r?l.replace(/\\?\|/g,""):l;p&&s.push({type:"text",text:p}),l=""};for(;n<e.length;){const p=e[n];if(o!==null){if(p===o)return d(),{nodes:s,end:n};if(p===`
|
|
14
|
+
`)return null}const c=pc(e,n);if(c){d(),s.push(c.node),n=c.end;continue}let a=null;if(p==="⟨"?a="⟩":p==="<"&&cc(e,n)&&(a=">"),a){const u=Kr(e,n+1,a,!0);if(u){d(),s.push({type:"jz",children:u.nodes}),n=u.end+1;continue}}l+=p,n++}return o!==null?null:(d(),{nodes:s,end:n})}function Jr(e){return Kr(e,0,null,!1).nodes}function uc(e){return/[<⟨□]|\[\[|:zi\[/.test(e)}function Zr(e){return e.map(n=>{switch(n.type){case"text":return n.text;case"jz":return`(${Zr(n.children)})`;case"qw":return"□";case"qz":return"□";case"zi":return n.label}}).join("")}const xc=216,zo="clamp(280px, 23vw, 360px)",fc=1440,Xr="(max-width: 719px)",gc=`${Xr}, (pointer: coarse)`,mc=`
|
|
15
|
+
.bim-d-main.bim-d-main-grid { max-width: ${fc}px; padding: 16px 32px 0; }
|
|
16
16
|
.bim-d-grid {
|
|
17
17
|
display: grid;
|
|
18
|
-
grid-template-columns: ${
|
|
18
|
+
grid-template-columns: ${xc}px minmax(0, 1fr) ${zo};
|
|
19
19
|
grid-template-rows: auto 1fr;
|
|
20
20
|
grid-template-areas: "rail main card" "rail main side";
|
|
21
21
|
column-gap: 32px; row-gap: 28px; align-items: start;
|
|
@@ -26,60 +26,66 @@
|
|
|
26
26
|
.bim-d-g-side { grid-area: side; min-width: 0; display: flex; flex-direction: column; gap: 28px; }
|
|
27
27
|
.bim-d-g-side:empty { display: none; }
|
|
28
28
|
|
|
29
|
-
.bim-d-meta { color: ${
|
|
30
|
-
.bim-d-dot::before { content: "·"; margin: 0 .45em; color: ${
|
|
29
|
+
.bim-d-meta { color: ${i("aux-fg")}; font-size: 13px; }
|
|
30
|
+
.bim-d-dot::before { content: "·"; margin: 0 .45em; color: ${i("aux-fg")}; }
|
|
31
31
|
|
|
32
32
|
/* 左栏 */
|
|
33
|
-
.bim-d-rail-cap { font-size: 12px; letter-spacing: .2em; color: ${
|
|
33
|
+
.bim-d-rail-cap { font-size: 12px; letter-spacing: .2em; color: ${i("aux-fg")}; margin: 0 12px 6px; }
|
|
34
34
|
.bim-d-rail-nav { list-style: none; margin: 0; padding: 0; }
|
|
35
35
|
.bim-d-rail-nav a {
|
|
36
36
|
display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
|
|
37
37
|
padding: 7px 12px; border-radius: 6px; font-size: 15px;
|
|
38
|
-
color: ${
|
|
38
|
+
color: ${i("quiet-fg")} !important; text-decoration: none !important;
|
|
39
39
|
}
|
|
40
|
-
.bim-d-rail-nav a:hover { background: ${
|
|
40
|
+
.bim-d-rail-nav a:hover { background: ${i("zebra-bg")}; color: ${i("ink")} !important; }
|
|
41
41
|
.bim-d-rail-nav .bim-d-meta { font-size: 12px; }
|
|
42
42
|
.bim-d-rail-links { margin-top: 20px; }
|
|
43
43
|
.bim-d-rail-back { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
|
|
44
|
-
font-size: 13px; color: ${
|
|
44
|
+
font-size: 13px; color: ${i("aux-fg")} !important; }
|
|
45
45
|
|
|
46
46
|
/* 区块 */
|
|
47
47
|
.bim-d-sec + .bim-d-sec { margin-top: 48px; }
|
|
48
48
|
.bim-d-sec { scroll-margin-top: 16px; }
|
|
49
49
|
.bim-d-sec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 14px; }
|
|
50
|
-
.bim-d-sec-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .04em; color: ${
|
|
50
|
+
.bim-d-sec-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .04em; color: ${i("ink")}; }
|
|
51
51
|
.bim-d-sec-head .bim-d-sec-act { margin-left: auto; font-size: 13px; }
|
|
52
52
|
|
|
53
53
|
/* 文字页签式筛选。min-height = 页签行高:朝代页签随次级数据晚到,行高先占好(INT Q3) */
|
|
54
54
|
.bim-d-filters { min-height: 26px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-bottom: 10px; font-size: 13px; }
|
|
55
55
|
.bim-d-tab {
|
|
56
56
|
background: none; border: 0; padding: 4px 0; cursor: pointer; font: inherit;
|
|
57
|
-
color: ${
|
|
57
|
+
color: ${i("quiet-fg")};
|
|
58
58
|
}
|
|
59
|
-
.bim-d-tab:hover { color: ${
|
|
60
|
-
.bim-d-tab[aria-pressed="true"] { color: ${
|
|
59
|
+
.bim-d-tab:hover { color: ${i("ink")}; }
|
|
60
|
+
.bim-d-tab[aria-pressed="true"] { color: ${i("accent")}; font-weight: 700; box-shadow: inset 0 -2px 0 ${i("accent")}; }
|
|
61
|
+
.bim-d-groupbtn {
|
|
62
|
+
background: none; border: 1px dashed ${i("rule-strong")}; border-radius: 3px; padding: 2px 8px; cursor: pointer;
|
|
63
|
+
font: inherit; color: ${i("quiet-fg")};
|
|
64
|
+
}
|
|
65
|
+
.bim-d-groupbtn:hover:not(:disabled) { color: ${i("accent")}; border-color: ${i("accent")}; }
|
|
66
|
+
.bim-d-groupbtn:disabled { cursor: progress; }
|
|
61
67
|
.bim-d-filters .bim-d-spacer { flex: 1; }
|
|
62
|
-
.bim-d-check { display: inline-flex; align-items: center; gap: 6px; color: ${
|
|
63
|
-
.bim-d-check input { accent-color: ${
|
|
68
|
+
.bim-d-check { display: inline-flex; align-items: center; gap: 6px; color: ${i("quiet-fg")}; cursor: pointer; }
|
|
69
|
+
.bim-d-check input { accent-color: ${i("accent")}; margin: 0; width: 15px; height: 15px; }
|
|
64
70
|
|
|
65
71
|
/* 斑马表:不画格线 */
|
|
66
72
|
.bim-d-zt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; }
|
|
67
|
-
.bim-d-zt th { text-align: left; font-weight: 400; color: ${
|
|
73
|
+
.bim-d-zt th { text-align: left; font-weight: 400; color: ${i("aux-fg")}; font-size: 12px;
|
|
68
74
|
letter-spacing: .1em; padding: 6px 12px; white-space: nowrap; }
|
|
69
75
|
.bim-d-zt td { padding: 10px 12px; vertical-align: baseline; }
|
|
70
|
-
.bim-d-zt tbody tr:nth-child(odd) td { background: ${
|
|
76
|
+
.bim-d-zt tbody tr:nth-child(odd) td { background: ${i("zebra-bg")}; }
|
|
71
77
|
.bim-d-zt tbody tr td:first-child { border-radius: 6px 0 0 6px; }
|
|
72
78
|
.bim-d-zt tbody tr td:last-child { border-radius: 0 6px 6px 0; }
|
|
73
|
-
.bim-d-zt tbody tr:hover td { background: ${
|
|
79
|
+
.bim-d-zt tbody tr:hover td { background: ${i("tint-bg")}; }
|
|
74
80
|
.bim-d-zt td.bim-d-zt-main { padding: 0; }
|
|
75
81
|
.bim-d-zt td.bim-d-zt-main > a, .bim-d-zt td.bim-d-zt-main > span.bim-d-zt-name {
|
|
76
|
-
display: block; padding: 10px 12px; color: ${
|
|
82
|
+
display: block; padding: 10px 12px; color: ${i("ink")}; font-weight: 500;
|
|
77
83
|
}
|
|
78
|
-
.bim-d-zt td.bim-d-zt-main > a:hover { color: ${
|
|
84
|
+
.bim-d-zt td.bim-d-zt-main > a:hover { color: ${i("accent")}; }
|
|
79
85
|
.bim-d-zt td.bim-d-zt-main .bim-d-meta { display: block; margin: -8px 12px 0; padding-bottom: 10px; font-size: 12px; font-weight: 400; }
|
|
80
|
-
.bim-d-zt .bim-d-zt-sub { color: ${
|
|
86
|
+
.bim-d-zt .bim-d-zt-sub { color: ${i("quiet-fg")}; font-size: 13px; }
|
|
81
87
|
.bim-d-zt .bim-d-zt-nowrap { white-space: nowrap; }
|
|
82
|
-
.bim-d-zt .bim-d-zt-empty { color: ${
|
|
88
|
+
.bim-d-zt .bim-d-zt-empty { color: ${i("aux-fg")}; }
|
|
83
89
|
/* 版本表:行高先按「有影印」色块那一行的高度占好,解析到的年代、馆藏、色块进来时行不再长高(INT Q3) */
|
|
84
90
|
.bim-d-zt-ver tbody tr { height: 58px; }
|
|
85
91
|
/* 版本行一律「版本名 + 一行卷帙小字」(小字晚到,没有时也留空行):行高固定,
|
|
@@ -87,15 +93,15 @@
|
|
|
87
93
|
|
|
88
94
|
.bim-d-flag {
|
|
89
95
|
display: inline-block; padding: 1px 8px; border-radius: 4px;
|
|
90
|
-
background: ${
|
|
96
|
+
background: ${i("flag-bg")}; color: ${i("accent")} !important;
|
|
91
97
|
font-size: 12px; line-height: 20px; white-space: nowrap;
|
|
92
98
|
}
|
|
93
|
-
a.bim-d-flag:hover { text-decoration: none !important; background: ${
|
|
99
|
+
a.bim-d-flag:hover { text-decoration: none !important; background: ${i("tint-bg")}; }
|
|
94
100
|
|
|
95
101
|
.bim-d-more {
|
|
96
102
|
display: inline-flex; align-items: center; min-height: 32px; margin-top: 6px;
|
|
97
103
|
background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: 13px;
|
|
98
|
-
color: ${
|
|
104
|
+
color: ${i("accent")};
|
|
99
105
|
}
|
|
100
106
|
.bim-d-more:hover { text-decoration: underline; text-underline-offset: 3px; }
|
|
101
107
|
|
|
@@ -104,208 +110,208 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
104
110
|
.bim-d-tl2 { list-style: none; margin: 0 0 18px; padding: 0; display: flex; overflow-x: auto; }
|
|
105
111
|
.bim-d-tl2 li { flex: 1 0 64px; min-width: 64px; }
|
|
106
112
|
.bim-d-tl2 button { height: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; background: none;
|
|
107
|
-
border: 0; cursor: pointer; padding: 4px 2px 8px; font: inherit; color: ${
|
|
108
|
-
.bim-d-tl2 button::before { content: ""; position: absolute; left: 0; right: 0; top: 30px; height: 1px; background: ${
|
|
109
|
-
.bim-d-tl2-dyn { font-size: 12px; color: ${
|
|
113
|
+
border: 0; cursor: pointer; padding: 4px 2px 8px; font: inherit; color: ${i("quiet-fg")}; position: relative; }
|
|
114
|
+
.bim-d-tl2 button::before { content: ""; position: absolute; left: 0; right: 0; top: 30px; height: 1px; background: ${i("rule")}; }
|
|
115
|
+
.bim-d-tl2-dyn { font-size: 12px; color: ${i("aux-fg")}; min-height: 18px; }
|
|
110
116
|
.bim-d-tl2-dot { position: relative; width: 9px; height: 9px; border-radius: 50%; box-sizing: border-box;
|
|
111
|
-
background: ${
|
|
117
|
+
background: ${i("page-bg")}; border: 1px solid ${i("aux-fg")}; }
|
|
112
118
|
.bim-d-tl2-name { display: flex; flex-direction: column; align-items: center; font-size: 15px; line-height: 1.25;
|
|
113
|
-
font-family: ${
|
|
114
|
-
.bim-d-tl2 button:hover .bim-d-tl2-name { color: ${
|
|
115
|
-
.bim-d-tl2 button[aria-selected="true"] .bim-d-tl2-dot { background: ${
|
|
116
|
-
.bim-d-tl2 button[aria-selected="true"] .bim-d-tl2-name { color: ${
|
|
119
|
+
font-family: ${i("font-serif")}; }; }
|
|
120
|
+
.bim-d-tl2 button:hover .bim-d-tl2-name { color: ${i("accent")}; }
|
|
121
|
+
.bim-d-tl2 button[aria-selected="true"] .bim-d-tl2-dot { background: ${i("accent")}; border-color: ${i("accent")}; }
|
|
122
|
+
.bim-d-tl2 button[aria-selected="true"] .bim-d-tl2-name { color: ${i("ink")}; font-weight: 700; }
|
|
117
123
|
.bim-d-lu-pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px;
|
|
118
|
-
padding-top: 12px; border-top: 1px solid ${
|
|
119
|
-
.bim-d-lu-pager button { background: none; border: 0; padding: 4px 0; cursor: pointer; font: inherit; color: ${
|
|
124
|
+
padding-top: 12px; border-top: 1px solid ${i("rule")}; font-size: 13px; }
|
|
125
|
+
.bim-d-lu-pager button { background: none; border: 0; padding: 4px 0; cursor: pointer; font: inherit; color: ${i("accent")}; }
|
|
120
126
|
.bim-d-lu-pager button:disabled { cursor: default; }
|
|
121
127
|
.bim-d-lu-pager button:not(:disabled):hover { text-decoration: underline; text-underline-offset: 3px; }
|
|
122
|
-
.bim-d-lu-body { padding: 18px 22px 14px; min-width: 0; border-radius: 10px; background: ${
|
|
123
|
-
.bim-d-lu-title { font-size: 17px; font-weight: 700; color: ${
|
|
124
|
-
.bim-d-quote { margin: 14px 0 0; font-family: ${
|
|
125
|
-
color: ${
|
|
126
|
-
.bim-d-quote-label { margin-top: 16px; font-size: 12px; letter-spacing: .1em; color: ${
|
|
128
|
+
.bim-d-lu-body { padding: 18px 22px 14px; min-width: 0; border-radius: 10px; background: ${i("card-bg")}; }
|
|
129
|
+
.bim-d-lu-title { font-size: 17px; font-weight: 700; color: ${i("ink")}; }
|
|
130
|
+
.bim-d-quote { margin: 14px 0 0; font-family: ${i("font-serif")}; font-size: 17px; line-height: 2;
|
|
131
|
+
color: ${i("ink")}; text-align: justify; }
|
|
132
|
+
.bim-d-quote-label { margin-top: 16px; font-size: 12px; letter-spacing: .1em; color: ${i("aux-fg")}; }
|
|
127
133
|
.bim-d-quote-label + .bim-d-quote { margin-top: 4px; }
|
|
128
134
|
|
|
129
135
|
/* 提要卡 */
|
|
130
|
-
.bim-d-card { background: ${
|
|
131
|
-
box-shadow: ${
|
|
136
|
+
.bim-d-card { background: ${i("card-bg")}; border-radius: 10px; padding: 24px;
|
|
137
|
+
box-shadow: ${i("shadow-summary")}; }
|
|
132
138
|
.bim-d-card h1 { margin: 0; font-size: 36px; font-weight: 700; letter-spacing: .08em; line-height: 1.25;
|
|
133
|
-
color: ${
|
|
139
|
+
color: ${i("ink")}; word-break: break-word; }
|
|
134
140
|
.bim-d-card h1.bim-d-card-long { font-size: 26px; letter-spacing: .04em; line-height: 1.35; }
|
|
135
|
-
.bim-d-card-sub { margin-top: 6px; font-size: 17px; font-weight: 500; color: ${
|
|
136
|
-
.bim-d-card-byline { margin-top: 8px; font-size: 15px; color: ${
|
|
141
|
+
.bim-d-card-sub { margin-top: 6px; font-size: 17px; font-weight: 500; color: ${i("quiet-fg")}; }
|
|
142
|
+
.bim-d-card-byline { margin-top: 8px; font-size: 15px; color: ${i("ink")}; }
|
|
137
143
|
.bim-d-card-cls { margin-top: 4px; }
|
|
138
|
-
.bim-d-card-desc { margin-top: 16px; color: ${
|
|
144
|
+
.bim-d-card-desc { margin-top: 16px; color: ${i("quiet-fg")}; line-height: 1.85; font-size: 15px; }
|
|
139
145
|
/* 提要卡顶上的类型小字(版本 / 叢編 / 人物):四类页长得一样,靠它区分 */
|
|
140
|
-
.bim-d-card-kind { margin-bottom: 6px; font-size: 12px; letter-spacing: .3em; color: ${
|
|
146
|
+
.bim-d-card-kind { margin-bottom: 6px; font-size: 12px; letter-spacing: .3em; color: ${i("aux-fg")}; }
|
|
141
147
|
/* 简介折叠:截到 N 行(行数由 --detail-clamp 给),「展開」后放开 */
|
|
142
148
|
.bim-d-card-desc.bim-d-clamp { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden;
|
|
143
149
|
-webkit-line-clamp: var(--detail-clamp, 6); }
|
|
144
150
|
/* 截断时里面的 MarkdownText 段落不要再带上下外边距,免得第一行前空一截 */
|
|
145
151
|
.bim-d-card-desc.bim-d-clamp > * { margin-top: 0; }
|
|
146
152
|
.bim-d-card-toggle { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: 13px;
|
|
147
|
-
color: ${
|
|
153
|
+
color: ${i("accent")}; display: inline-flex; align-items: center; min-height: 28px; }
|
|
148
154
|
.bim-d-card-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }
|
|
149
155
|
.bim-d-card details.bim-d-more-names { margin-top: 8px; font-size: 13px; }
|
|
150
|
-
.bim-d-card details.bim-d-more-names summary { cursor: pointer; color: ${
|
|
156
|
+
.bim-d-card details.bim-d-more-names summary { cursor: pointer; color: ${i("accent")}; display: inline-flex;
|
|
151
157
|
align-items: center; min-height: 28px; }
|
|
152
158
|
.bim-d-card details.bim-d-more-names dl { margin-top: 6px; }
|
|
153
159
|
|
|
154
160
|
/* 左栏「上一级」:版本页的所属作品、丛编页的上级丛编 */
|
|
155
|
-
.bim-d-up { display: block; margin-top: 16px; padding: 10px 12px; border-radius: 8px; background: ${
|
|
156
|
-
.bim-d-up-cap { display: block; font-size: 12px; letter-spacing: .1em; color: ${
|
|
157
|
-
.bim-d-up a { font-size: 16px; font-weight: 700; color: ${
|
|
158
|
-
.bim-d-up a:hover { color: ${
|
|
159
|
-
.bim-d-up a::after { content: " →"; font-weight: 400; color: ${
|
|
161
|
+
.bim-d-up { display: block; margin-top: 16px; padding: 10px 12px; border-radius: 8px; background: ${i("zebra-bg")}; }
|
|
162
|
+
.bim-d-up-cap { display: block; font-size: 12px; letter-spacing: .1em; color: ${i("aux-fg")}; }
|
|
163
|
+
.bim-d-up a { font-size: 16px; font-weight: 700; color: ${i("ink")} !important; }
|
|
164
|
+
.bim-d-up a:hover { color: ${i("accent")} !important; }
|
|
165
|
+
.bim-d-up a::after { content: " →"; font-weight: 400; color: ${i("aux-fg")}; }
|
|
160
166
|
|
|
161
167
|
/* 资源分组:一组一个小标题、一句说明;镜像收成一行文字链接,不再逐行重复组名 */
|
|
162
168
|
.bim-d-rg + .bim-d-rg { margin-top: 22px; }
|
|
163
|
-
.bim-d-rg-h { font-size: 15px; font-weight: 700; color: ${
|
|
164
|
-
.bim-d-rg-d { font-size: 13px; color: ${
|
|
169
|
+
.bim-d-rg-h { font-size: 15px; font-weight: 700; color: ${i("ink")}; margin: 0; }
|
|
170
|
+
.bim-d-rg-d { font-size: 13px; color: ${i("aux-fg")}; margin: 2px 0 8px; max-width: 46em;
|
|
165
171
|
display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
|
|
166
|
-
.bim-d-rg-mir { padding: 6px 12px 0; font-size: 13px; color: ${
|
|
167
|
-
.bim-d-rg-mir a { color: ${
|
|
172
|
+
.bim-d-rg-mir { padding: 6px 12px 0; font-size: 13px; color: ${i("quiet-fg")}; }
|
|
173
|
+
.bim-d-rg-mir a { color: ${i("accent")} !important; margin-right: 14px; }
|
|
168
174
|
|
|
169
175
|
/* 本站全文:一块浅底的阅读入口 + 回目网格(不另加按钮,主按钮在提要卡) */
|
|
170
176
|
.bim-d-ft { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 24px; align-items: center;
|
|
171
|
-
padding: 18px 20px; border-radius: 10px; background: ${
|
|
172
|
-
.bim-d-ft-h { margin: 0; font-size: 17px; font-weight: 700; color: ${
|
|
177
|
+
padding: 18px 20px; border-radius: 10px; background: ${i("zebra-bg")}; }
|
|
178
|
+
.bim-d-ft-h { margin: 0; font-size: 17px; font-weight: 700; color: ${i("ink")}; }
|
|
173
179
|
.bim-d-ft .bim-d-meta { grid-column: 1; }
|
|
174
|
-
.bim-d-ft-go { grid-column: 2; grid-row: 1 / span 2; color: ${
|
|
180
|
+
.bim-d-ft-go { grid-column: 2; grid-row: 1 / span 2; color: ${i("accent")} !important; font-weight: 500; white-space: nowrap; }
|
|
175
181
|
.bim-d-chap { list-style: none; margin: 12px 0 0; padding: 0; display: grid;
|
|
176
182
|
grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0 20px; font-size: 14px; }
|
|
177
|
-
.bim-d-chap a { display: flex; gap: 10px; padding: 5px 0; color: ${
|
|
183
|
+
.bim-d-chap a { display: flex; gap: 10px; padding: 5px 0; color: ${i("quiet-fg")} !important;
|
|
178
184
|
overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
179
|
-
.bim-d-chap a:hover { color: ${
|
|
185
|
+
.bim-d-chap a:hover { color: ${i("accent")} !important; }
|
|
180
186
|
.bim-d-chap-pending { height: 142px; margin-top: 12px; }
|
|
181
|
-
.bim-d-chap b { font-weight: 400; color: ${
|
|
187
|
+
.bim-d-chap b { font-weight: 400; color: ${i("aux-fg")}; flex: none; }
|
|
182
188
|
|
|
183
189
|
/* 版本源流:一条竖线,靠字重和颜色分层,不画框 */
|
|
184
190
|
.bim-d-tl { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; }
|
|
185
|
-
.bim-d-tl::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px; width: 1px; background: ${
|
|
191
|
+
.bim-d-tl::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: 10px; width: 1px; background: ${i("rule")}; }
|
|
186
192
|
.bim-d-tl > li { position: relative; padding: 6px 0; }
|
|
187
193
|
.bim-d-tl > li::before { content: ""; position: absolute; left: -18px; top: 15px; width: 9px; height: 9px;
|
|
188
|
-
border-radius: 50%; background: ${
|
|
189
|
-
.bim-d-tl > li.bim-d-tl-cur::before { background: ${
|
|
190
|
-
.bim-d-tl-rel { display: inline-block; min-width: 4.5em; font-size: 12px; color: ${
|
|
191
|
-
.bim-d-tl-t { color: ${
|
|
192
|
-
.bim-d-tl-cur .bim-d-tl-t { color: ${
|
|
193
|
-
.bim-d-tl-ev { display: block; margin-left: 4.5em; font-size: 12px; color: ${
|
|
194
|
+
border-radius: 50%; background: ${i("rule-dashed")}; }
|
|
195
|
+
.bim-d-tl > li.bim-d-tl-cur::before { background: ${i("accent")}; }
|
|
196
|
+
.bim-d-tl-rel { display: inline-block; min-width: 4.5em; font-size: 12px; color: ${i("aux-fg")}; letter-spacing: .1em; }
|
|
197
|
+
.bim-d-tl-t { color: ${i("ink")}; font-weight: 500; }
|
|
198
|
+
.bim-d-tl-cur .bim-d-tl-t { color: ${i("accent")}; }
|
|
199
|
+
.bim-d-tl-ev { display: block; margin-left: 4.5em; font-size: 12px; color: ${i("aux-fg")}; }
|
|
194
200
|
.bim-d-tl details { margin: 4px 0 0 4.5em; font-size: 13px; }
|
|
195
|
-
.bim-d-tl summary { cursor: pointer; color: ${
|
|
201
|
+
.bim-d-tl summary { cursor: pointer; color: ${i("accent")}; display: inline-flex; align-items: center; min-height: 28px; }
|
|
196
202
|
|
|
197
203
|
/* 著作举要:无框的排印块 */
|
|
198
204
|
.bim-d-picks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 28px; }
|
|
199
|
-
.bim-d-pick { padding: 16px 18px; border-radius: 10px; background: ${
|
|
205
|
+
.bim-d-pick { padding: 16px 18px; border-radius: 10px; background: ${i("zebra-bg")}; min-width: 0; }
|
|
200
206
|
.bim-d-pick-t { display: block; font-size: 18px; font-weight: 700; letter-spacing: .04em; }
|
|
201
|
-
.bim-d-pick-t a { color: ${
|
|
202
|
-
.bim-d-pick-t a:hover { color: ${
|
|
207
|
+
.bim-d-pick-t a { color: ${i("ink")} !important; }
|
|
208
|
+
.bim-d-pick-t a:hover { color: ${i("accent")} !important; }
|
|
203
209
|
.bim-d-pick .bim-d-meta { display: block; margin-top: 4px; font-size: 12px; }
|
|
204
|
-
.bim-d-pick-n { margin-top: 10px; font-size: 13px; color: ${
|
|
210
|
+
.bim-d-pick-n { margin-top: 10px; font-size: 13px; color: ${i("quiet-fg")}; display: flex; gap: 8px; align-items: center; }
|
|
205
211
|
|
|
206
212
|
/* 著作举要:版本数放大 */
|
|
207
|
-
.bim-d-pick-num { font-size: 26px; font-weight: 700; line-height: 1; color: ${
|
|
213
|
+
.bim-d-pick-num { font-size: 26px; font-weight: 700; line-height: 1; color: ${i("ink")}; letter-spacing: 0; }
|
|
208
214
|
.bim-d-pick-num + span { font-size: 13px; }
|
|
209
215
|
.bim-d-pick-n { align-items: baseline; }
|
|
210
216
|
.bim-d-pick-n .bim-d-flag { margin-left: auto; }
|
|
211
|
-
.bim-d-sec-sub { margin: -8px 0 16px; font-size: 13px; color: ${
|
|
217
|
+
.bim-d-sec-sub { margin: -8px 0 16px; font-size: 13px; color: ${i("aux-fg")}; }
|
|
212
218
|
|
|
213
219
|
/* 提要卡:生卒条、著作四部分布条 */
|
|
214
220
|
.bim-d-life { margin-top: 18px; }
|
|
215
|
-
.bim-d-life-bar { position: relative; height: 6px; border-radius: 3px; background: ${
|
|
216
|
-
.bim-d-life-bar > i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: ${
|
|
217
|
-
.bim-d-life-lab { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: ${
|
|
221
|
+
.bim-d-life-bar { position: relative; height: 6px; border-radius: 3px; background: ${i("rule")}; }
|
|
222
|
+
.bim-d-life-bar > i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: ${i("sect-jing")}; }
|
|
223
|
+
.bim-d-life-lab { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: ${i("aux-fg")}; }
|
|
218
224
|
.bim-d-dist { margin-top: 18px; }
|
|
219
|
-
.bim-d-dist-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: ${
|
|
220
|
-
.bim-d-dist-head b { font-size: 20px; color: ${
|
|
225
|
+
.bim-d-dist-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: ${i("aux-fg")}; }
|
|
226
|
+
.bim-d-dist-head b { font-size: 20px; color: ${i("ink")}; margin-right: 3px; }
|
|
221
227
|
.bim-d-dist-bar { display: flex; gap: 1px; height: 6px; margin-top: 8px; border-radius: 3px; overflow: hidden; }
|
|
222
228
|
.bim-d-dist-bar > i { display: block; }
|
|
223
|
-
.bim-d-dist-key { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: ${
|
|
229
|
+
.bim-d-dist-key { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: ${i("quiet-fg")}; }
|
|
224
230
|
.bim-d-dist-key i { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 2px; }
|
|
225
231
|
.bim-d-dist-seg { display: block; flex-basis: 0; min-width: 2px; height: 100%; padding: 0; border: 0; cursor: pointer; }
|
|
226
232
|
.bim-d-dist-seg:disabled { cursor: default; }
|
|
227
|
-
.bim-d-dist-seg[aria-pressed="true"] { outline: 2px solid ${
|
|
233
|
+
.bim-d-dist-seg[aria-pressed="true"] { outline: 2px solid ${i("ink")}; outline-offset: -2px; }
|
|
228
234
|
.bim-d-dist-bar:has(.bim-d-dist-seg[aria-pressed="true"]) .bim-d-dist-seg:not([aria-pressed="true"]) { opacity: .35; }
|
|
229
235
|
.bim-d-sq { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 1px; vertical-align: middle; }
|
|
230
|
-
.bim-d-side-note { margin: 8px 0 0; font-size: 12px; color: ${
|
|
236
|
+
.bim-d-side-note { margin: 8px 0 0; font-size: 12px; color: ${i("aux-fg")}; }
|
|
231
237
|
|
|
232
238
|
/* 提要卡:数字格(版本 / 有影印 / 家著录) */
|
|
233
239
|
.bim-d-stats { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin: 18px 0 0; padding: 14px 0 2px;
|
|
234
|
-
border-top: 1px solid ${
|
|
235
|
-
.bim-d-stats > div + div { padding-left: 14px; border-left: 1px solid ${
|
|
236
|
-
.bim-d-stats b { display: block; font-size: 24px; font-weight: 700; line-height: 1.1; color: ${
|
|
237
|
-
.bim-d-stats span { display: block; margin-top: 4px; font-size: 12px; color: ${
|
|
238
|
-
.bim-d-side-sub { margin: -2px 0 6px; font-size: 12px; color: ${
|
|
239
|
-
.bim-d-side li .bim-d-kind { padding: 0 6px; border-radius: 3px; background: ${
|
|
240
|
+
border-top: 1px solid ${i("rule")}; }
|
|
241
|
+
.bim-d-stats > div + div { padding-left: 14px; border-left: 1px solid ${i("rule")}; }
|
|
242
|
+
.bim-d-stats b { display: block; font-size: 24px; font-weight: 700; line-height: 1.1; color: ${i("ink")}; }
|
|
243
|
+
.bim-d-stats span { display: block; margin-top: 4px; font-size: 12px; color: ${i("aux-fg")}; }
|
|
244
|
+
.bim-d-side-sub { margin: -2px 0 6px; font-size: 12px; color: ${i("aux-fg")}; }
|
|
245
|
+
.bim-d-side li .bim-d-kind { padding: 0 6px; border-radius: 3px; background: ${i("zebra-bg")}; line-height: 18px; }
|
|
240
246
|
|
|
241
247
|
/* 提要卡:版本类型/年代/卷帙 三个标签 */
|
|
242
248
|
.bim-d-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
|
|
243
|
-
.bim-d-tag { padding: 1px 8px; border-radius: 3px; font-size: 12px; line-height: 20px; color: ${
|
|
244
|
-
background: ${
|
|
245
|
-
.bim-d-tag-0 { background: ${
|
|
246
|
-
.bim-d-tag-2 { background: none; box-shadow: inset 0 0 0 1px ${
|
|
249
|
+
.bim-d-tag { padding: 1px 8px; border-radius: 3px; font-size: 12px; line-height: 20px; color: ${i("quiet-fg")};
|
|
250
|
+
background: ${i("zebra-bg")}; }
|
|
251
|
+
.bim-d-tag-0 { background: ${i("flag-bg")}; color: ${i("accent")}; }
|
|
252
|
+
.bim-d-tag-2 { background: none; box-shadow: inset 0 0 0 1px ${i("rule")}; }
|
|
247
253
|
|
|
248
254
|
/* 分段切换(卡片/关系图) */
|
|
249
|
-
.bim-d-seg { display: inline-flex; border-radius: 6px; box-shadow: inset 0 0 0 1px ${
|
|
255
|
+
.bim-d-seg { display: inline-flex; border-radius: 6px; box-shadow: inset 0 0 0 1px ${i("rule")}; overflow: hidden; }
|
|
250
256
|
.bim-d-seg button { min-height: 28px; padding: 0 12px; border: 0; background: none; cursor: pointer; font: inherit;
|
|
251
|
-
font-size: 13px; color: ${
|
|
252
|
-
.bim-d-seg button[aria-pressed="true"] { background: ${
|
|
257
|
+
font-size: 13px; color: ${i("quiet-fg")}; }
|
|
258
|
+
.bim-d-seg button[aria-pressed="true"] { background: ${i("flag-bg")}; color: ${i("accent")}; font-weight: 700; }
|
|
253
259
|
|
|
254
260
|
/* 版本源流·卡片流 */
|
|
255
261
|
.bim-d-lf-list { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
|
|
256
|
-
.bim-d-lf-list::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: 12px; width: 1px; background: ${
|
|
262
|
+
.bim-d-lf-list::before { content: ""; position: absolute; left: 4px; top: 12px; bottom: 12px; width: 1px; background: ${i("rule")}; }
|
|
257
263
|
.bim-d-lf-node { position: relative; padding: 6px 0; }
|
|
258
264
|
.bim-d-lf-node::before { content: ""; position: absolute; left: -22px; top: 22px; width: 9px; height: 9px; border-radius: 50%;
|
|
259
|
-
box-sizing: border-box; background: ${
|
|
260
|
-
.bim-d-lf-cur::before { background: ${
|
|
265
|
+
box-sizing: border-box; background: ${i("page-bg")}; border: 1px solid ${i("aux-fg")}; }
|
|
266
|
+
.bim-d-lf-cur::before { background: ${i("accent")}; border-color: ${i("accent")}; }
|
|
261
267
|
.bim-d-lf-out::before { top: 16px; }
|
|
262
268
|
.bim-d-lf-card, .bim-d-lf-dash { padding: 12px 16px; border-radius: 8px; min-width: 0; }
|
|
263
|
-
.bim-d-lf-card { background: ${
|
|
264
|
-
.bim-d-lf-dash { box-shadow: inset 0 0 0 1px ${
|
|
269
|
+
.bim-d-lf-card { background: ${i("card-bg")}; box-shadow: inset 0 0 0 1px ${i("rule")}; }
|
|
270
|
+
.bim-d-lf-dash { box-shadow: inset 0 0 0 1px ${i("rule-dashed")}; }
|
|
265
271
|
.bim-d-lf-tag { display: inline-block; margin-right: 10px; padding: 0 7px; border-radius: 3px; font-size: 12px; line-height: 20px;
|
|
266
|
-
background: ${
|
|
267
|
-
.bim-d-lf-name { font-weight: 700; color: ${
|
|
268
|
-
.bim-d-lf-ev { margin: 6px 0 0; font-size: 13px; line-height: 1.8; color: ${
|
|
272
|
+
background: ${i("zebra-bg")}; color: ${i("quiet-fg")}; }
|
|
273
|
+
.bim-d-lf-name { font-weight: 700; color: ${i("ink")}; }
|
|
274
|
+
.bim-d-lf-ev { margin: 6px 0 0; font-size: 13px; line-height: 1.8; color: ${i("quiet-fg")}; }
|
|
269
275
|
.bim-d-lf-cur { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
|
|
270
|
-
.bim-d-lf-here { padding: 12px 16px; border-radius: 8px; background: ${
|
|
271
|
-
.bim-d-lf-here .bim-d-lf-name { color: ${
|
|
272
|
-
.bim-d-lf-here .bim-d-lf-tag { background: color-mix(in srgb, ${
|
|
276
|
+
.bim-d-lf-here { padding: 12px 16px; border-radius: 8px; background: ${i("accent")}; color: ${i("on-color-fg")}; min-width: 0; }
|
|
277
|
+
.bim-d-lf-here .bim-d-lf-name { color: ${i("on-color-fg")}; }
|
|
278
|
+
.bim-d-lf-here .bim-d-lf-tag { background: color-mix(in srgb, ${i("on-color-fg")} 18%, transparent); color: ${i("on-color-fg")}; }
|
|
273
279
|
.bim-d-lf-yr { display: block; margin-top: 4px; font-size: 13px; opacity: .9; }
|
|
274
280
|
.bim-d-lf-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
|
|
275
281
|
.bim-d-lf-out { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
|
|
276
|
-
.bim-d-lf-out-h { font-size: 12px; letter-spacing: .1em; color: ${
|
|
282
|
+
.bim-d-lf-out-h { font-size: 12px; letter-spacing: .1em; color: ${i("aux-fg")}; }
|
|
277
283
|
.bim-d-lf-chips { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
278
284
|
.bim-d-lf-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px; border-radius: 6px;
|
|
279
|
-
box-shadow: inset 0 0 0 1px ${
|
|
285
|
+
box-shadow: inset 0 0 0 1px ${i("rule")}; font-size: 14px; }
|
|
280
286
|
.bim-d-lf-app { margin-top: 10px; font-size: 14px; }
|
|
281
|
-
.bim-d-lf-app summary { cursor: pointer; min-height: 28px; display: inline-flex; align-items: center; gap: 6px; color: ${
|
|
287
|
+
.bim-d-lf-app summary { cursor: pointer; min-height: 28px; display: inline-flex; align-items: center; gap: 6px; color: ${i("accent")}; }
|
|
282
288
|
|
|
283
289
|
/* 影印分组:一组一张卡 */
|
|
284
|
-
.bim-d-rg { padding: 14px 16px 10px; border-radius: 10px; background: ${
|
|
290
|
+
.bim-d-rg { padding: 14px 16px 10px; border-radius: 10px; background: ${i("card-bg")}; box-shadow: inset 0 0 0 1px ${i("rule")}; }
|
|
285
291
|
.bim-d-rg .bim-d-zt tbody tr:nth-child(odd) td { background: none; }
|
|
286
292
|
|
|
287
293
|
/* 旁栏:时间轴点(同作品版本) */
|
|
288
294
|
.bim-d-side-tl ul { position: relative; padding-left: 16px; }
|
|
289
|
-
.bim-d-side-tl ul::before { content: ""; position: absolute; left: 3px; top: 12px; bottom: 12px; width: 1px; background: ${
|
|
295
|
+
.bim-d-side-tl ul::before { content: ""; position: absolute; left: 3px; top: 12px; bottom: 12px; width: 1px; background: ${i("rule")}; }
|
|
290
296
|
.bim-d-side-tl li { position: relative; }
|
|
291
297
|
.bim-d-side-tl li::before { content: ""; position: absolute; left: -16px; top: 14px; width: 7px; height: 7px; border-radius: 50%;
|
|
292
|
-
box-sizing: border-box; background: ${
|
|
293
|
-
.bim-d-side-tl li.bim-d-side-cur::before { background: ${
|
|
298
|
+
box-sizing: border-box; background: ${i("page-bg")}; border: 1px solid ${i("aux-fg")}; }
|
|
299
|
+
.bim-d-side-tl li.bim-d-side-cur::before { background: ${i("accent")}; border-color: ${i("accent")}; }
|
|
294
300
|
|
|
295
301
|
/* 本页内检索(丛编子目) */
|
|
296
302
|
.bim-d-find { height: 30px; min-width: 190px; padding: 0 12px; border: 0; border-radius: 6px; box-sizing: border-box;
|
|
297
|
-
background: ${
|
|
298
|
-
.bim-d-find::placeholder { color: ${
|
|
299
|
-
.bim-d-find:focus { outline: 2px solid ${
|
|
303
|
+
background: ${i("tint-bg")}; color: ${i("ink")}; font: inherit; font-size: 13px; }
|
|
304
|
+
.bim-d-find::placeholder { color: ${i("aux-fg")}; }
|
|
305
|
+
.bim-d-find:focus { outline: 2px solid ${i("accent")}; outline-offset: 1px; }
|
|
300
306
|
|
|
301
307
|
/* 旁栏:当前条目高亮 */
|
|
302
|
-
.bim-d-side-all a { color: ${
|
|
303
|
-
.bim-d-side li.bim-d-side-cur, .bim-d-side li.bim-d-side-cur .bim-d-meta { color: ${
|
|
308
|
+
.bim-d-side-all a { color: ${i("accent")} !important; }
|
|
309
|
+
.bim-d-side li.bim-d-side-cur, .bim-d-side li.bim-d-side-cur .bim-d-meta { color: ${i("accent")}; font-weight: 500; }
|
|
304
310
|
.bim-d-card dl { margin: 18px 0 0; display: grid; grid-template-columns: auto minmax(0, 1fr);
|
|
305
311
|
gap: 6px 16px; font-size: 13px; }
|
|
306
|
-
.bim-d-card dt { color: ${
|
|
307
|
-
.bim-d-card dd { margin: 0; color: ${
|
|
308
|
-
.bim-d-card-foot { margin-top: 14px; font-size: 12px; text-align: center; color: ${
|
|
312
|
+
.bim-d-card dt { color: ${i("aux-fg")}; white-space: nowrap; }
|
|
313
|
+
.bim-d-card dd { margin: 0; color: ${i("ink")}; min-width: 0; overflow-wrap: anywhere; }
|
|
314
|
+
.bim-d-card-foot { margin-top: 14px; font-size: 12px; text-align: center; color: ${i("aux-fg")}; }
|
|
309
315
|
.bim-d-card-foot:empty { display: none; }
|
|
310
316
|
.bim-d-card-foot details { text-align: left; margin-top: 6px; }
|
|
311
317
|
.bim-d-card-foot summary { cursor: pointer; display: inline-flex; align-items: center; min-height: 32px; }
|
|
@@ -314,27 +320,27 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
314
320
|
.bim-d-btn {
|
|
315
321
|
display: flex; align-items: center; justify-content: center; margin-top: 22px; width: 100%;
|
|
316
322
|
height: 44px; padding: 0 24px; border: 0; border-radius: 8px; box-sizing: border-box;
|
|
317
|
-
background: ${
|
|
318
|
-
font: 500 15px/1 ${
|
|
323
|
+
background: ${i("accent")}; color: ${i("on-color-fg")} !important;
|
|
324
|
+
font: 500 15px/1 ${i("font-ui")}; letter-spacing: .08em; cursor: pointer; white-space: nowrap;
|
|
319
325
|
text-decoration: none !important;
|
|
320
326
|
}
|
|
321
|
-
.bim-d-btn:hover { background: ${
|
|
327
|
+
.bim-d-btn:hover { background: ${i("accent-deep")}; }
|
|
322
328
|
.bim-d-card-alt { display: flex; align-items: center; justify-content: center; min-height: 40px; margin-top: 8px;
|
|
323
|
-
border-radius: 6px; background: ${
|
|
324
|
-
.bim-d-card-alt:hover { text-decoration: none !important; background: ${
|
|
329
|
+
border-radius: 6px; background: ${i("flag-bg")}; font-size: 14px; color: ${i("accent")} !important; }
|
|
330
|
+
.bim-d-card-alt:hover { text-decoration: none !important; background: ${i("tint-bg")}; }
|
|
325
331
|
|
|
326
332
|
/* 旁栏清单:小标题是 h2(提要卡 h1 之下不跳级,INT Q5),外观仍是 15px 小标题 */
|
|
327
|
-
.bim-d-side h3, .bim-d-side .bim-d-side-h { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: ${
|
|
333
|
+
.bim-d-side h3, .bim-d-side .bim-d-side-h { margin: 0 0 6px; font-size: 15px; font-weight: 700; color: ${i("ink")};
|
|
328
334
|
display: flex; align-items: baseline; gap: 8px; }
|
|
329
335
|
.bim-d-side h3 .bim-d-meta, .bim-d-side .bim-d-side-h .bim-d-meta { font-weight: 400; font-size: 12px; }
|
|
330
336
|
.bim-d-side ul { list-style: none; margin: 0; padding: 0; }
|
|
331
337
|
.bim-d-side li { display: flex; align-items: baseline; gap: 10px; padding: 5px 0; font-size: 15px; min-width: 0; }
|
|
332
|
-
.bim-d-side li > a, .bim-d-side li > span:first-child { color: ${
|
|
333
|
-
.bim-d-side li > a:hover { color: ${
|
|
338
|
+
.bim-d-side li > a, .bim-d-side li > span:first-child { color: ${i("ink")}; min-width: 0; overflow-wrap: anywhere; }
|
|
339
|
+
.bim-d-side li > a:hover { color: ${i("accent")}; }
|
|
334
340
|
.bim-d-side li .bim-d-meta { font-size: 12px; flex: none; }
|
|
335
341
|
|
|
336
342
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
337
|
-
@media ${
|
|
343
|
+
@media ${gc} {
|
|
338
344
|
.bim-d-tab, .bim-d-check, .bim-d-more, .bim-d-rail-back,
|
|
339
345
|
.bim-d-card-foot summary, .bim-d-card-toggle, .bim-d-card details.bim-d-more-names summary,
|
|
340
346
|
.bim-d-tl summary, .bim-d-chap a { min-height: 44px; }
|
|
@@ -372,7 +378,7 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
372
378
|
/* 中等宽度:左栏折到顶部一行 */
|
|
373
379
|
@media (max-width: 1100px) {
|
|
374
380
|
.bim-d-grid {
|
|
375
|
-
grid-template-columns: minmax(0, 1fr) ${
|
|
381
|
+
grid-template-columns: minmax(0, 1fr) ${zo};
|
|
376
382
|
grid-template-rows: auto auto 1fr;
|
|
377
383
|
grid-template-areas: "rail rail" "main card" "main side";
|
|
378
384
|
}
|
|
@@ -381,12 +387,12 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
381
387
|
.bim-d-rail-links { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; }
|
|
382
388
|
.bim-d-rail-links .bim-d-rail-cap { display: none; }
|
|
383
389
|
.bim-d-rail-links .bim-d-rail-nav { display: flex; flex-wrap: wrap; gap: 0 16px; }
|
|
384
|
-
.bim-d-rail-links .bim-d-rail-nav a { padding: 7px 0; color: ${
|
|
390
|
+
.bim-d-rail-links .bim-d-rail-nav a { padding: 7px 0; color: ${i("accent")} !important; font-size: 14px; }
|
|
385
391
|
.bim-d-up { display: inline-block; margin-top: 12px; }
|
|
386
392
|
}
|
|
387
393
|
|
|
388
394
|
/* 手机:左栏收起,提要卡 → 正文 → 旁栏 */
|
|
389
|
-
@media ${
|
|
395
|
+
@media ${Xr} {
|
|
390
396
|
.bim-d-main.bim-d-main-grid { padding: 8px 16px 0; }
|
|
391
397
|
.bim-d-grid {
|
|
392
398
|
grid-template-columns: minmax(0, 1fr);
|
|
@@ -400,11 +406,11 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
400
406
|
.bim-d-zt thead { display: none; }
|
|
401
407
|
.bim-d-zt, .bim-d-zt tbody, .bim-d-zt tr, .bim-d-zt td { display: block; width: 100%; box-sizing: border-box; }
|
|
402
408
|
.bim-d-zt tr { padding: 0 0 10px; border-radius: 6px; }
|
|
403
|
-
.bim-d-zt tbody tr:nth-child(odd) { background: ${
|
|
409
|
+
.bim-d-zt tbody tr:nth-child(odd) { background: ${i("zebra-bg")}; }
|
|
404
410
|
.bim-d-zt tbody tr:nth-child(odd) td, .bim-d-zt tbody tr:hover td { background: transparent; }
|
|
405
411
|
.bim-d-zt td { padding: 0 12px; }
|
|
406
412
|
.bim-d-zt td:not(.bim-d-zt-main) { display: inline; width: auto; padding: 0 0 0 12px; font-size: 12px;
|
|
407
|
-
color: ${
|
|
413
|
+
color: ${i("aux-fg")}; }
|
|
408
414
|
.bim-d-zt td.bim-d-zt-blank { display: none; }
|
|
409
415
|
.bim-d-zt td.bim-d-zt-main .bim-d-meta { padding-bottom: 2px; }
|
|
410
416
|
/* 手机上版本行是块:解析前先按「名 + 卷帙小字 + 一行年代馆藏」占高(实测解析后 81–87px) */
|
|
@@ -427,16 +433,16 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
427
433
|
.bim-d-pick-n { margin: 0; grid-column: 2; grid-row: 1 / span 2; }
|
|
428
434
|
.bim-d-find { flex-basis: 100%; min-height: 40px; }
|
|
429
435
|
}
|
|
430
|
-
`;function
|
|
436
|
+
`;function Xt({railTop:e,back:n,up:o,nav:r,railLinks:s,main:l,card:d,side:p}){const{convert:c}=Z(),a=(r||[]).filter(Boolean);return t.jsxs("div",{className:"bim-d-grid",children:[t.jsxs("aside",{className:"bim-d-g-rail bim-d-ui",children:[e,n&&t.jsx("div",{style:{marginTop:e?12:0},children:n}),o,a.length>1&&t.jsxs("nav",{className:"bim-d-rail-navwrap","aria-label":c("本頁導航"),style:{marginTop:20},children:[t.jsx("p",{className:"bim-d-rail-cap",style:{marginTop:0},children:c("本頁")}),t.jsx("ul",{className:"bim-d-rail-nav",children:a.map(u=>t.jsx("li",{children:t.jsxs("a",{href:`#${u.id}`,children:[t.jsx("span",{children:c(u.label)}),u.count!=null&&t.jsx("span",{className:"bim-d-meta",children:u.count})]})},u.id))})]}),s&&s.length>0&&t.jsxs("nav",{className:"bim-d-rail-links","aria-label":c("更多"),children:[t.jsx("p",{className:"bim-d-rail-cap",children:c("更多")}),t.jsx("ul",{className:"bim-d-rail-nav",children:s.map(u=>t.jsx("li",{children:t.jsxs("a",{href:u.href??"#",onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),u.onClick())},children:[t.jsx("span",{children:c(u.label)}),t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:"→"})]})},u.key))})]})]}),t.jsx("div",{className:"bim-d-g-main",children:l}),t.jsx("div",{className:"bim-d-g-card",children:d}),t.jsx("div",{className:"bim-d-g-side",children:p})]})}function Qr({caption:e,children:n}){const{convert:o}=Z();return t.jsxs("div",{className:"bim-d-up bim-d-ui",children:[t.jsx("span",{className:"bim-d-up-cap",children:o(e)}),n]})}function Fe({id:e,title:n,meta:o,action:r,children:s}){const{convert:l}=Z();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:l(n)}),o!=null&&o!==""&&t.jsx("span",{className:"bim-d-meta",children:o}),r&&t.jsx("span",{className:"bim-d-sec-act",children:r})]}),s]})}function Me({items:e,className:n,style:o}){const r=e.filter(s=>s!=null&&s!==""&&s!==!1);return r.length?t.jsx("span",{className:`bim-d-meta${n?` ${n}`:""}`,style:o,children:r.map((s,l)=>t.jsxs(g.Fragment,{children:[l>0&&t.jsx("span",{className:"bim-d-dot"}),t.jsx("span",{children:s})]},l))}):null}function $n({items:e,value:n,onChange:o}){const{convert:r}=Z();return t.jsx(t.Fragment,{children:e.map(s=>t.jsx("button",{type:"button",className:[...r(s.label)].length===1?"bim-d-tab bim-d-tab-1":"bim-d-tab","aria-pressed":s.key===n,onClick:()=>o(s.key),children:r(s.label)},s.key))})}function es({label:e,checked:n,onChange:o}){const{convert:r}=Z();return t.jsxs("label",{className:"bim-d-check",children:[t.jsx("input",{type:"checkbox",checked:n,onChange:s=>o(s.target.checked)}),r(e)]})}function Bt({label:e,onClick:n}){const{convert:o}=Z();return t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",onClick:n,children:o(e)})}function Qt({kind:e,title:n,subtitle:o,byline:r,meta:s,description:l,clampDescription:d,facts:p,stats:c,readAction:a,secondaryAction:u,children:f,foot:x}){const{convert:m}=Z(),j=(p||[]).filter(k=>k.value!=null&&k.value!==""),w=(c||[]).filter(k=>k.value!=null&&k.value!==""&&k.value!==0),[h,b]=g.useState(!1),y=!!d&&!h;return t.jsxs("div",{className:"bim-d-card",children:[e&&t.jsx("div",{className:"bim-d-card-kind bim-d-ui",children:m(e)}),t.jsx("h1",{className:typeof n=="string"&&[...n].length>7?"bim-d-card-long":void 0,children:n}),o&&t.jsx("div",{className:"bim-d-card-sub",children:o}),r&&t.jsx("p",{className:"bim-d-card-byline",style:{marginBottom:0},children:r}),s&&t.jsx("div",{className:"bim-d-card-cls bim-d-ui",children:s}),l&&t.jsx("div",{className:y?"bim-d-card-desc bim-d-clamp":"bim-d-card-desc",style:y?{"--detail-clamp":d}:void 0,children:l}),l&&!!d&&t.jsx("button",{type:"button",className:"bim-d-card-toggle bim-d-ui","aria-expanded":h,onClick:()=>b(k=>!k),children:m(h?"收起":"展開")}),w.length>0&&t.jsx("div",{className:"bim-d-stats bim-d-ui",children:w.map((k,$)=>t.jsxs("div",{children:[t.jsx("b",{children:k.value}),t.jsx("span",{children:m(k.label)})]},$))}),j.length>0&&t.jsx("dl",{className:"bim-d-ui",children:j.map((k,$)=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:m(k.label)}),t.jsx("dd",{title:k.title,children:k.value})]},$))}),f,a,u,x&&t.jsx("div",{className:"bim-d-card-foot bim-d-ui",children:x})]})}function ki(e){return!!e&&[...e.replace(/\s+/g,"")].length>110}function Kn({href:e,onClick:n,label:o="閱讀全文"}){const{convert:r}=Z();return e?t.jsx("a",{className:"bim-d-btn",href:e,onClick:n?s=>{s.metaKey||s.ctrlKey||(s.preventDefault(),n())}:void 0,children:r(o)}):t.jsx("button",{type:"button",className:"bim-d-btn",onClick:n,children:r(o)})}function ht({id:e,title:n,meta:o,items:r,metas:s,currentIndex:l,cap:d=8,moreLabel:p,foot:c,sub:a,timeline:u}){const{convert:f}=Z(),[x,m]=g.useState(!1);if(!r.length)return null;const j=x?r:r.slice(0,d),w=r.length-j.length;return t.jsxs("div",{id:e,className:u?"bim-d-side bim-d-side-tl":"bim-d-side",style:{scrollMarginTop:16},children:[t.jsxs("h2",{className:"bim-d-ui bim-d-side-h",children:[f(n),o!=null&&o!==""&&t.jsx("span",{className:"bim-d-meta",children:o})]}),a&&t.jsx("p",{className:"bim-d-side-sub bim-d-ui",children:a}),t.jsx("ul",{children:j.map((h,b)=>t.jsxs("li",{className:b===l?"bim-d-side-cur":void 0,"aria-current":b===l?"page":void 0,children:[h,s!=null&&s[b]?t.jsx("span",{className:"bim-d-meta",style:{marginLeft:"auto"},children:s[b]}):null]},b))}),w>0&&t.jsx(Bt,{label:p?p(w):`顯示更多(${w})`,onClick:()=>m(!0)}),c&&t.jsx("p",{className:"bim-d-side-note bim-d-ui",children:c})]})}const hc={reviewed:"已審核",disputed:"有爭議",unreviewed:"未審核",draft:"草稿"};function en({revision:e,revisedAt:n,review:o,todo:r}){const{convert:s}=Z(),l=o?hc[o.status]:void 0,d=o&&o.status!=="unreviewed"&&l?[l,o.by,o.date].filter(Boolean).join(" "):"",p=[e!=null&&e!==""?`${s("數據版本")} ${e}`:"",n??"",s(d)].filter(Boolean),c=(r||[]).filter(a=>a&&a.what);return!p.length&&!c.length?null:t.jsxs(t.Fragment,{children:[p.length>0&&t.jsx(Me,{items:p,style:{fontSize:12}}),c.length>0&&t.jsxs("details",{children:[t.jsx("summary",{children:s(`待核 ${c.length} 項`)}),t.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18,lineHeight:1.7},children:c.map((a,u)=>t.jsxs("li",{children:[s(a.what),(a.by||a.date)&&t.jsxs("span",{style:{marginLeft:6},children:["(",[a.by&&s(a.by),a.date].filter(Boolean).join(" · "),")"]})]},u))})]})]})}const un=1e3,Co=208,bc=1440,yc="(max-width: 719px)",ts=`
|
|
431
437
|
.bim-d-page {
|
|
432
|
-
background: ${
|
|
433
|
-
color: ${
|
|
438
|
+
background: ${i("page-bg")};
|
|
439
|
+
color: ${i("ink")};
|
|
434
440
|
font-family: var(--bim-font-body, system-ui, sans-serif);
|
|
435
441
|
min-height: 100%;
|
|
436
442
|
padding-bottom: 64px;
|
|
437
443
|
}
|
|
438
444
|
.bim-d-main {
|
|
439
|
-
max-width: ${
|
|
445
|
+
max-width: ${un}px;
|
|
440
446
|
margin: 0 auto;
|
|
441
447
|
padding: 24px clamp(16px, 4vw, 28px) 0;
|
|
442
448
|
}
|
|
@@ -447,23 +453,23 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
447
453
|
* PAGE_MAX_WIDTH,读者的行宽体验不变。
|
|
448
454
|
*/
|
|
449
455
|
.bim-d-main.bim-d-main-wide {
|
|
450
|
-
max-width: ${
|
|
456
|
+
max-width: ${bc}px;
|
|
451
457
|
}
|
|
452
458
|
.bim-d-ui { font-family: var(--bim-font-ui, system-ui, sans-serif); }
|
|
453
459
|
|
|
454
|
-
.bim-d-page a { color: ${
|
|
460
|
+
.bim-d-page a { color: ${i("accent")}; text-decoration: none; }
|
|
455
461
|
.bim-d-page a:hover {
|
|
456
|
-
color: ${
|
|
462
|
+
color: ${i("accent-deep")};
|
|
457
463
|
text-decoration: underline;
|
|
458
464
|
text-decoration-thickness: 1px;
|
|
459
465
|
text-underline-offset: 3px;
|
|
460
466
|
}
|
|
461
|
-
.bim-d-page ::selection { background: ${
|
|
467
|
+
.bim-d-page ::selection { background: ${i("selection-bg")}; }
|
|
462
468
|
|
|
463
469
|
/* 表格行 */
|
|
464
470
|
.bim-d-row { display: grid; align-items: center; padding: 9px 4px;
|
|
465
|
-
border-bottom: 1px solid ${
|
|
466
|
-
.bim-d-row:hover { background: ${
|
|
471
|
+
border-bottom: 1px solid ${i("rule")}; font-size: 14px; }
|
|
472
|
+
.bim-d-row:hover { background: ${i("row-hover-bg")}; }
|
|
467
473
|
|
|
468
474
|
/*
|
|
469
475
|
* 全文阅读布局(整理本 / Book 全文)。
|
|
@@ -479,9 +485,9 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
479
485
|
*/
|
|
480
486
|
.bim-d-reader {
|
|
481
487
|
display: grid;
|
|
482
|
-
grid-template-columns: ${
|
|
488
|
+
grid-template-columns: ${Co}px minmax(0, ${un}px);
|
|
483
489
|
gap: 32px;
|
|
484
|
-
max-width: ${
|
|
490
|
+
max-width: ${Co+un+32}px;
|
|
485
491
|
margin: 0 auto;
|
|
486
492
|
align-items: start;
|
|
487
493
|
}
|
|
@@ -492,19 +498,19 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
492
498
|
overflow-y: auto;
|
|
493
499
|
overscroll-behavior: contain;
|
|
494
500
|
padding-right: 4px;
|
|
495
|
-
border-right: 1px solid ${
|
|
501
|
+
border-right: 1px solid ${i("rule")};
|
|
496
502
|
}
|
|
497
503
|
.bim-d-reader-main { min-width: 0; }
|
|
498
504
|
|
|
499
505
|
/* intro / 成对区块:宽屏两栏,窄屏单栏 */
|
|
500
506
|
.bim-d-intro { display: grid; grid-template-columns: minmax(0, 1fr) 244px; gap: 30px;
|
|
501
|
-
padding: 20px 0 26px; border-bottom: 1px solid ${
|
|
507
|
+
padding: 20px 0 26px; border-bottom: 1px solid ${i("rule")};
|
|
502
508
|
margin-bottom: 40px; align-items: start; }
|
|
503
509
|
.bim-d-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 34px;
|
|
504
510
|
align-items: start; margin-bottom: 48px; }
|
|
505
511
|
.bim-d-pair-wide { grid-template-columns: 1fr 1.2fr; }
|
|
506
512
|
|
|
507
|
-
@media ${
|
|
513
|
+
@media ${yc} {
|
|
508
514
|
.bim-d-intro { grid-template-columns: 1fr; gap: 20px; margin-bottom: 32px; }
|
|
509
515
|
.bim-d-pair, .bim-d-pair-wide { grid-template-columns: 1fr; gap: 40px; }
|
|
510
516
|
/* 表格:meta 列折到第二行,表头隐藏 */
|
|
@@ -518,18 +524,18 @@ a.bim-d-flag:hover { text-decoration: none !important; background: ${o("tint-bg"
|
|
|
518
524
|
.bim-d-reader { grid-template-columns: 1fr; gap: 16px; }
|
|
519
525
|
.bim-d-reader-aside {
|
|
520
526
|
position: static; max-height: 240px;
|
|
521
|
-
border-right: none; border-bottom: 1px solid ${
|
|
527
|
+
border-right: none; border-bottom: 1px solid ${i("rule")};
|
|
522
528
|
padding-right: 0; padding-bottom: 12px;
|
|
523
529
|
}
|
|
524
530
|
}
|
|
525
|
-
${
|
|
526
|
-
`)||(n.push({start:
|
|
531
|
+
${mc}`;function Ht({children:e,style:n,wide:o,grid:r}){return t.jsxs("div",{className:"bim-d-page",style:n,children:[t.jsx("style",{children:ts}),t.jsx("div",{className:r?"bim-d-main bim-d-main-grid":o?"bim-d-main bim-d-main-wide":"bim-d-main",children:e})]})}function Jn({breadcrumb:e,actions:n}){return t.jsxs("div",{className:"bim-d-ui bim-d-top",style:{display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:"8px 16px",marginBottom:24,fontSize:12,color:i("aux-fg")},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:e}),n&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:16},children:n})]})}function wi({char:e,tone:n="accent"}){return t.jsx("span",{"aria-hidden":"true",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,flex:"none",fontSize:11,fontFamily:"var(--bim-font-ui, system-ui, sans-serif)",background:i(n==="accent"?"accent":"ink"),color:i("page-bg")},children:e})}function Zn({items:e}){const n=Pe();return t.jsx(t.Fragment,{children:e.map((o,r)=>{const s=r===e.length-1,l=r>0&&t.jsx("span",{style:{color:i("hint-fg")},children:"/"},`s${r}`),d=o.id?n(o.id):o.href,p=s||!o.onClick&&!d?t.jsx("span",{style:{color:i("ink")},children:o.label},r):t.jsx("a",{href:d??"#",onClick:o.onClick?c=>{c.metaKey||c.ctrlKey||(c.preventDefault(),o.onClick())}:void 0,style:{color:i("meta-fg")},children:o.label},r);return t.jsxs(g.Fragment,{children:[l,p]},r)})})}function ns({title:e,subtitle:n,aside:o,secondLine:r}){return t.jsxs("header",{style:{borderBottom:`2px solid ${i("rule-strong")}`,paddingBottom:18},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"flex-end",justifyContent:"space-between",gap:"10px 24px"},children:[t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"6px 14px",minWidth:0},children:[t.jsx("h1",{className:"bim-d-h1",style:{margin:0,fontSize:42,fontWeight:700,letterSpacing:".06em",lineHeight:1.1,wordBreak:"break-word"},children:e}),n&&t.jsx("span",{style:{fontSize:15,color:i("meta-fg"),letterSpacing:".06em"},children:n})]}),o&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".06em"},children:o})]}),r&&t.jsx("div",{style:{marginTop:12,fontSize:13.5,color:i("quiet-fg")},children:r})]})}function jc({children:e,facts:n}){return!e&&n?t.jsx("div",{style:{padding:"20px 0 26px",borderBottom:`1px solid ${i("rule")}`,marginBottom:40},children:n}):t.jsxs("div",{className:"bim-d-intro",children:[t.jsx("div",{style:{minWidth:0},children:e}),n]})}function vc({items:e,horizontal:n}){const{convert:o}=Z();return e.length?t.jsx("div",{style:{borderLeft:`2px solid ${i("accent")}`,paddingLeft:16,display:n?"grid":"flex",gridTemplateColumns:n?"repeat(auto-fit, minmax(150px, max-content))":void 0,flexDirection:n?void 0:"column",gap:n?"14px 40px":10,fontSize:13},children:e.map((r,s)=>t.jsxs("div",{title:r.title,style:n?{display:"flex",flexDirection:"column",gap:3}:{display:"flex",justifyContent:"space-between",gap:10},children:[t.jsx("span",{className:"bim-d-ui",style:{color:i("label-fg"),letterSpacing:".08em",flex:"none"},children:o(r.label)}),t.jsx("span",{style:{color:i("body-fg"),textAlign:n?"left":"right",minWidth:0},children:r.value})]},s))}):null}function kc({glyph:e,tone:n,title:o,count:r,actions:s,id:l}){const{convert:d}=Z();return t.jsxs("div",{id:l,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(wi,{char:e,tone:n}),t.jsx("h2",{style:{margin:0,fontSize:19,fontWeight:600,letterSpacing:".1em"},children:d(o)}),r!=null&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg")},children:r})]}),s&&t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:14,fontSize:12},children:s})]})}function is({label:e,active:n,onClick:o,dashed:r}){const{convert:s}=Z();return t.jsx("button",{type:"button",onClick:o,"aria-pressed":n,className:"bim-d-ui",style:{padding:"5px 13px",border:`1px ${r&&!n?"dashed":"solid"} ${i(n?"accent":"rule")}`,background:n?i("accent"):"transparent",color:i(n?"page-bg":"meta-fg"),fontSize:12,cursor:"pointer",letterSpacing:".04em",lineHeight:1.4},children:s(e)})}function wc({label:e,onClick:n}){const{convert:o}=Z();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg"),borderBottom:`1px solid ${i("rule")}`},children:o(e)})}function Sc({label:e,onClick:n,inline:o}){const{convert:r}=Z();return t.jsx("button",{type:"button",onClick:n,className:"bim-d-ui",style:{marginTop:o?0:12,width:o?void 0:"100%",padding:o?"4px 12px":9,background:"none",border:`1px dashed ${i("rule-dashed")}`,cursor:"pointer",fontSize:12,color:i("meta-fg"),letterSpacing:o?void 0:".08em"},children:r(e)})}function os({children:e,href:n,onClick:o,title:r}){const s={display:"inline-block",padding:"4px 10px",border:`1px solid ${i("rule")}`,fontSize:13,color:i("body-fg"),lineHeight:1.5};return n||o?t.jsx("a",{href:n??"#",title:r,onClick:o?l=>{l.metaKey||l.ctrlKey||(l.preventDefault(),o())}:void 0,style:s,children:e}):t.jsx("span",{title:r,style:s,children:e})}function _c({children:e}){return t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:e})}function $c({volumes:e,unit:n="冊",max:o=60}){const[r,s]=g.useState(!1);if(!e.length)return null;const l=r?e:e.slice(0,o);return t.jsxs("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,fontSize:11.5},children:[l.map(d=>t.jsx("span",{style:{minWidth:30,textAlign:"center",padding:"2px 5px",border:`1px solid ${i("rule")}`,color:i("meta-fg")},children:d},d)),!r&&e.length>o&&t.jsxs("button",{type:"button",onClick:()=>s(!0),style:{padding:"2px 8px",background:"none",cursor:"pointer",border:`1px dashed ${i("rule-dashed")}`,fontFamily:"inherit",fontSize:11.5,color:i("meta-fg")},children:["+",e.length-o]}),t.jsx("span",{style:{padding:"2px 6px",color:i("hint-fg")},children:n})]})}function zc({children:e}){return t.jsx("div",{style:{borderTop:`1px solid ${i("rule-strong")}`},children:e})}function Cc({spec:e}){const{convert:n}=Z();return t.jsxs("div",{className:"bim-d-thead bim-d-ui",style:{display:"grid",gridTemplateColumns:`${e.leadWidth}px 1fr ${e.metaWidth}px`,gap:12,padding:"7px 4px",borderBottom:`1px solid ${i("rule-strong")}`,fontSize:11,color:i("label-fg"),letterSpacing:".1em"},children:[t.jsx("span",{}),t.jsx("span",{children:n(e.mainLabel)}),t.jsx("span",{style:{display:"grid",gridTemplateColumns:e.columns.map(o=>o.width).join(" "),gap:12},children:e.columns.map(o=>t.jsx("span",{children:n(o.label)},o.label))})]})}function Ic({no:e,main:n,meta:o,spec:r}){return t.jsxs("div",{className:"bim-d-row",style:{gridTemplateColumns:`${r.leadWidth}px 1fr ${r.metaWidth}px`,gap:12},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("hint-fg"),textAlign:"right"},children:e}),t.jsx("span",{style:{minWidth:0},children:n}),t.jsx("span",{className:"bim-d-row-meta",style:{display:"grid",gridTemplateColumns:r.columns.map(s=>s.width).join(" "),gap:12,alignItems:"center",fontSize:12},children:o})]})}function Tc(e){return String(e+1).padStart(2,"0")}function Ec(){return t.jsx("span",{style:{color:i("hint-fg")},children:"—"})}function Rc({open:e,onToggle:n,main:o,action:r,children:s}){return t.jsxs("div",{style:{borderBottom:`1px solid ${i("rule")}`},children:[t.jsxs("div",{className:"bim-d-expand-head",style:{display:"grid",gridTemplateColumns:"26px 1fr auto",gap:12,alignItems:"baseline",padding:"9px 4px"},children:[t.jsx("button",{type:"button",onClick:n,"aria-expanded":e,className:"bim-d-ui",style:{width:18,height:18,display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,cursor:"pointer",fontSize:12,lineHeight:1,border:`1px solid ${i(e?"accent":"rule-dashed")}`,background:e?i("accent"):"transparent",color:i(e?"page-bg":"accent")},children:e?"-":"+"}),t.jsx("span",{style:{fontSize:14,minWidth:0},children:o}),r]}),e&&s&&t.jsx("div",{style:{padding:"2px 4px 14px 38px",borderLeft:`2px solid ${i("rule-accent-soft")}`,marginLeft:12},children:s})]})}function rs(e){const n=[];for(let o=0;o<e.length;o++){const r=e[o];let s;if(r==="⟨")s="⟩";else if(r==="<"){const p=e[o+1];if(p===void 0||/[A-Za-z/!?>\s]/.test(p))continue;s=">"}else continue;const l=e.indexOf(s,o+1);if(l<0)continue;const d=e.slice(o+1,l);d.includes(`
|
|
532
|
+
`)||(n.push({start:o,end:l+1,inner:d}),o=l)}return n}function ss(e,n){if(e.length<=n)return e;let o=n;for(const r of rs(e)){if(r.start>=o)break;if(r.end>o){o=r.start>0?r.start:r.end;break}}return e.slice(0,o)}const ls={fontSize:".78em",color:i("meta-fg"),lineHeight:1.55},Nc={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 as(e,n,o){return e.map((r,s)=>{switch(r.type){case"text":return t.jsx(g.Fragment,{children:n(r.text)},s);case"jz":return t.jsx("span",{className:"bim-jiazhu",style:o===0?ls:void 0,children:as(r.children,n,o+1)},s);case"qw":return t.jsx("span",{className:"bim-qw guji-qw",title:r.label?`闕文:${r.label}`:"闕文",children:"□"},s);case"qz":return t.jsx("span",{className:"bim-qz guji-qz","data-guji-guess":r.guess,children:"□"},s);case"zi":return t.jsx("span",{className:"bim-zi guji-zi",title:`組字:${r.label}`,style:Nc,children:r.label},s)}})}function Ue(e,n=r=>r,o){if(!e)return"";if(o!=null&&o.gujiMarkdown)return uc(e)?as(Jr(e),n,0):n(e);if(e.indexOf("⟨")<0&&e.indexOf("<")<0)return n(e);const r=[];let s=0,l=0;for(const d of rs(e))d.start>s&&r.push(t.jsx(g.Fragment,{children:n(e.slice(s,d.start))},l++)),r.push(t.jsx("span",{className:"bim-jiazhu",style:ls,children:n(d.inner)},l++)),s=d.end;return s<e.length&&r.push(t.jsx(g.Fragment,{children:n(e.slice(s))},l++)),r}function Lc({label:e,children:n}){return t.jsxs("div",{style:{marginBottom:10},children:[e&&t.jsx("div",{className:"bim-d-ui",style:{fontSize:11,fontWeight:600,letterSpacing:".1em",color:i("label-fg"),marginBottom:4},children:e}),t.jsx("div",{style:{fontSize:13.5,lineHeight:2,color:i("quiet-fg"),textAlign:"justify"},children:n})]})}function Bc({title:e,tag:n,children:o}){const{convert:r}=Z();return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:8,paddingBottom:7,borderBottom:`1px solid ${i("rule-strong")}`,marginBottom:2},children:[t.jsx("span",{style:{fontSize:14.5,letterSpacing:".08em"},children:r(e)}),n&&t.jsx("span",{className:"bim-d-ui",style:{fontSize:10.5,color:i("accent"),letterSpacing:".06em"},children:r(n)})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column"},children:o})]})}function cs({name:e,note:n,href:o,extra:r}){const s=t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{fontSize:14,minWidth:0},children:e}),t.jsx("span",{className:"bim-d-ui",style:{fontSize:11,color:i("hint-fg"),flex:"none"},children:o?"↗":""}),n&&t.jsx("span",{className:"bim-d-ui",style:{gridColumn:"1 / -1",fontSize:11.5,color:i("label-fg")},children:n})]}),l={display:"grid",gridTemplateColumns:"1fr auto",gap:"4px 12px",padding:"9px 4px",borderBottom:`1px solid ${i("rule")}`,color:i("body-fg"),alignItems:"baseline"};return t.jsxs(t.Fragment,{children:[o?t.jsx("a",{href:o,target:"_blank",rel:"noopener noreferrer",style:l,children:s}):t.jsx("div",{style:l,children:s}),r]})}function Ac({item:e,siblings:n,showVolumes:o=!0,fallbackNote:r}){const{convert:s}=Z(),[l,d]=g.useState(!1),p=yn(e),c=o&&!!p&&p.expected>0,a=(e.url?Nt(e.url):void 0)||s(e.name),u=n?Pr(e,n):"",f=u?`${a}(${u})`:a;return t.jsx(cs,{name:f,note:Sn(e)||r,href:Lt(e),extra:c?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>d(x=>!x),className:"bim-d-ui",style:{alignSelf:"flex-start",padding:"2px 0",marginTop:4,background:"none",border:"none",cursor:"pointer",fontSize:11,color:i("meta-fg"),borderBottom:`1px solid ${i("rule")}`},children:l?"收起分冊":`展開 ${p.expected} 冊`}),l&&t.jsx(Si,{item:e})]}):void 0})}function Si({item:e}){return t.jsx("div",{className:"bim-d-ui",style:{display:"flex",flexWrap:"wrap",gap:4,padding:"6px 0 10px",fontSize:11},children:(e.volumes||[]).map((n,o)=>{const r=n.status==="missing";return n.url&&!r?t.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{padding:"4px 8px",borderRadius:4,background:i("zebra-bg")},children:n.volume},o):t.jsx("span",{style:{padding:"1px 5px",color:i(r?"missing-fg":"hint-fg"),textDecoration:r?"line-through":void 0},children:n.volume},o)})})}function ds({label:e,items:n}){const{convert:o}=Z();return n.length?t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[t.jsx("span",{className:"bim-d-ui",style:{fontSize:11.5,color:i("label-fg"),letterSpacing:".08em"},children:e}),n.map((r,s)=>t.jsx(os,{children:o(r)},s))]}):null}function Wc({rows:e}){const n=e.filter(o=>o.items.length>0);return n.length?t.jsx("div",{style:{marginTop:16,display:"flex",flexDirection:"column",gap:8},children:n.map(o=>t.jsx(ds,{label:o.label,items:o.items},o.label))}):null}function Xn(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function ps({left:e,right:n}){return t.jsxs("footer",{className:"bim-d-ui",style:{marginTop:52,paddingTop:14,borderTop:`1px solid ${i("rule")}`,display:"flex",flexWrap:"wrap",justifyContent:"space-between",gap:"8px 16px",fontSize:11.5,color:i("aux-fg")},children:[t.jsx("span",{children:e}),n&&t.jsx("span",{style:{display:"flex",gap:16},children:n})]})}function Mc({children:e,action:n}){return t.jsxs("div",{className:"bim-d-ui",style:{padding:"18px 4px",fontSize:12.5,color:i("aux-fg"),borderBottom:`1px solid ${i("rule")}`,display:"flex",flexWrap:"wrap",alignItems:"center",gap:12},children:[t.jsx("span",{children:e}),n]})}function Be({id:e,label:n,onNavigate:o,renderLink:r,style:s,dense:l}){const d=Pe();return r?t.jsx(t.Fragment,{children:r(e,typeof n=="string"?n:void 0,{dense:l})}):t.jsx("a",{href:d(e),onClick:o?p=>{p.metaKey||p.ctrlKey||(p.preventDefault(),o(e))}:void 0,style:s,children:n??e})}function Fc({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 us="(min-width: 1100px)",xs="(max-width: 719px)",Pc=`${xs}, (pointer: coarse)`,pt=i("reader-top"),Oc="48px",fs=`
|
|
527
533
|
.bim-rd {
|
|
528
534
|
position: relative;
|
|
529
|
-
background: ${
|
|
530
|
-
color: ${
|
|
531
|
-
font-family: ${
|
|
532
|
-
--bimrd-bar-h: ${
|
|
535
|
+
background: ${i("page-bg")};
|
|
536
|
+
color: ${i("ink")};
|
|
537
|
+
font-family: ${i("font-ui")};
|
|
538
|
+
--bimrd-bar-h: ${Oc};
|
|
533
539
|
}
|
|
534
540
|
.bim-rd *, .bim-rd *::before, .bim-rd *::after { box-sizing: border-box; }
|
|
535
541
|
|
|
@@ -543,9 +549,9 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
543
549
|
left: 8px; top: 8px; z-index: 60;
|
|
544
550
|
width: auto; height: auto; margin: 0; overflow: visible; clip: auto; clip-path: none;
|
|
545
551
|
padding: 8px 14px; border-radius: 6px;
|
|
546
|
-
background: ${
|
|
552
|
+
background: ${i("ink")}; color: ${i("page-bg")} !important;
|
|
547
553
|
font-size: 14px; text-decoration: none !important;
|
|
548
|
-
outline: 2px solid ${
|
|
554
|
+
outline: 2px solid ${i("accent")}; outline-offset: 2px;
|
|
549
555
|
}
|
|
550
556
|
|
|
551
557
|
.bim-rd-sr {
|
|
@@ -559,33 +565,50 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
559
565
|
height: var(--bimrd-bar-h);
|
|
560
566
|
display: flex; align-items: center; gap: 16px;
|
|
561
567
|
padding: 0 20px;
|
|
562
|
-
background: color-mix(in srgb, ${
|
|
568
|
+
background: color-mix(in srgb, ${i("page-bg")} 94%, transparent);
|
|
563
569
|
backdrop-filter: blur(8px);
|
|
564
570
|
}
|
|
565
571
|
.bim-rd-ttl { min-width: 0; display: flex; align-items: baseline; gap: 10px; overflow: hidden; white-space: nowrap; }
|
|
566
|
-
.bim-rd-ttl b { font-size: 15px; font-weight: 700; letter-spacing: 0.06em; color: ${
|
|
567
|
-
.bim-rd-ttl span { font-size: 13px; color: ${
|
|
568
|
-
.bim-rd-
|
|
569
|
-
.bim-rd-
|
|
572
|
+
.bim-rd-ttl b { font-size: 15px; font-weight: 700; letter-spacing: 0.06em; color: ${i("ink")}; overflow: hidden; text-overflow: ellipsis; }
|
|
573
|
+
.bim-rd-ttl span { font-size: 13px; color: ${i("meta-fg")}; overflow: hidden; text-overflow: ellipsis; }
|
|
574
|
+
.bim-rd-ttl b a { color: inherit; text-decoration: none; }
|
|
575
|
+
.bim-rd-ttl b a:hover { color: ${i("accent")}; text-decoration: underline; text-underline-offset: 4px; }
|
|
576
|
+
.bim-rd-ttl .bim-rd-dot { flex: none; }
|
|
577
|
+
.bim-rd-ttl .bim-rd-dot::before { content: "·"; }
|
|
578
|
+
.bim-rd-ttl .bim-rd-cur { color: ${i("ink")}; flex: none; }
|
|
579
|
+
.bim-rd-chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
|
|
580
|
+
.bim-rd-chk input { margin: 0; accent-color: ${i("accent")}; cursor: pointer; }
|
|
581
|
+
.bim-rd-rowhead {
|
|
582
|
+
display: flex; gap: 8px; padding: 8px 10px; border-bottom: 1px solid ${i("ink")};
|
|
583
|
+
font-family: ${i("font-ui")}; font-size: 11.5px; letter-spacing: 0.12em; color: ${i("meta-fg")};
|
|
584
|
+
}
|
|
585
|
+
.bim-rd-entries .bim-rd-row:hover { background: ${i("row-hover-bg")}; }
|
|
586
|
+
.bim-rd-wl {
|
|
587
|
+
display: inline-block; margin-left: 12px; padding: 1px 8px; font-size: 11.5px; letter-spacing: 0; font-weight: 400; line-height: 1.7;
|
|
588
|
+
background: ${i("flag-bg")}; color: ${i("accent")} !important; text-decoration: none !important; vertical-align: 2px; white-space: nowrap;
|
|
589
|
+
}
|
|
590
|
+
.bim-rd-wl:hover { background: ${i("accent")}; color: ${i("page-bg")} !important; }
|
|
591
|
+
.bim-rd-tools { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; color: ${i("quiet-fg")}; flex: none; }
|
|
592
|
+
.bim-rd-tools .bim-rd-sep { width: 1px; height: 14px; background: ${i("rule")}; }
|
|
570
593
|
.bim-rd-t {
|
|
571
594
|
background: none; border: 0; margin: 0; padding: 6px 2px;
|
|
572
595
|
font: inherit; color: inherit; cursor: pointer; line-height: 1;
|
|
573
596
|
display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
|
|
574
597
|
}
|
|
575
|
-
.bim-rd-t:hover { color: ${
|
|
576
|
-
.bim-rd-t[aria-pressed="true"], .bim-rd-t[aria-current="true"] { color: ${
|
|
598
|
+
.bim-rd-t:hover { color: ${i("ink")}; }
|
|
599
|
+
.bim-rd-t[aria-pressed="true"], .bim-rd-t[aria-current="true"] { color: ${i("accent")}; }
|
|
577
600
|
.bim-rd-t:disabled { opacity: 0.4; cursor: default; }
|
|
578
601
|
.bim-rd-t svg { flex: none; }
|
|
579
|
-
.bim-rd-t .bim-rd-on { color: ${
|
|
602
|
+
.bim-rd-t .bim-rd-on { color: ${i("accent")}; font-weight: 700; }
|
|
580
603
|
.bim-rd-t .bim-rd-off { opacity: 0.55; }
|
|
581
604
|
.bim-rd-ver { position: relative; display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
|
|
582
605
|
.bim-rd-ver-short { display: none; }
|
|
583
606
|
.bim-rd-ver select {
|
|
584
607
|
max-width: 16em; min-height: 32px; margin: 0; padding: 0 2px;
|
|
585
|
-
background: none; border: 0; font: inherit; color: ${
|
|
608
|
+
background: none; border: 0; font: inherit; color: ${i("ink")}; cursor: pointer;
|
|
586
609
|
text-overflow: ellipsis;
|
|
587
610
|
}
|
|
588
|
-
.bim-rd :focus-visible { outline: 2px solid ${
|
|
611
|
+
.bim-rd :focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 2px; border-radius: 3px; }
|
|
589
612
|
|
|
590
613
|
/* ── 主体:目录 | 书影 | 正文 ── */
|
|
591
614
|
.bim-rd-body {
|
|
@@ -602,34 +625,34 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
602
625
|
width: 248px; height: calc(100vh - ${pt} - var(--bimrd-bar-h));
|
|
603
626
|
overflow-y: auto; overscroll-behavior: contain;
|
|
604
627
|
padding: 0 10px 40px;
|
|
605
|
-
background: ${
|
|
628
|
+
background: ${i("sidebar-bg")};
|
|
606
629
|
}
|
|
607
630
|
.bim-rd[data-toc="closed"] .bim-rd-toc { display: none; }
|
|
608
631
|
.bim-rd-scrim { display: none; }
|
|
609
632
|
/* 目录标题与搜索框吸在目录顶上:长目录滚动时关闭键、搜索框不跟着滚走 */
|
|
610
|
-
.bim-rd-toc-top { position: sticky; top: 0; z-index: 1; padding-top: 16px; background: ${
|
|
611
|
-
.bim-rd-toc-head { display: flex; align-items: center; gap: 8px; margin: 0 8px 10px; min-height: 22px; font-size: 12px; letter-spacing: 0.15em; color: ${
|
|
633
|
+
.bim-rd-toc-top { position: sticky; top: 0; z-index: 1; padding-top: 16px; background: ${i("sidebar-bg")}; }
|
|
634
|
+
.bim-rd-toc-head { display: flex; align-items: center; gap: 8px; margin: 0 8px 10px; min-height: 22px; font-size: 12px; letter-spacing: 0.15em; color: ${i("meta-fg")}; }
|
|
612
635
|
.bim-rd-toc-head .bim-rd-t { margin-left: auto; letter-spacing: 0; }
|
|
613
636
|
.bim-rd-toc-search {
|
|
614
637
|
display: block; width: 100%; margin: 0 0 12px;
|
|
615
638
|
padding: 7px 10px; border-radius: 6px;
|
|
616
|
-
border: 1px solid transparent; background: ${
|
|
617
|
-
color: ${
|
|
639
|
+
border: 1px solid transparent; background: ${i("bg")};
|
|
640
|
+
color: ${i("ink")}; font: inherit; font-size: 13px;
|
|
618
641
|
}
|
|
619
|
-
.bim-rd-toc-search:focus { border-color: ${
|
|
642
|
+
.bim-rd-toc-search:focus { border-color: ${i("accent")}; outline: none; }
|
|
620
643
|
.bim-rd-toc ul { list-style: none; margin: 0; padding: 0; }
|
|
621
644
|
.bim-rd-toc li ul { padding-left: 14px; }
|
|
622
645
|
.bim-rd-ti {
|
|
623
646
|
display: flex; align-items: baseline; gap: 8px; width: 100%;
|
|
624
647
|
padding: 5px 10px; border: 0; border-radius: 6px; margin: 0;
|
|
625
648
|
background: none; font: inherit; font-size: 13px; line-height: 1.5; text-align: left;
|
|
626
|
-
color: ${
|
|
649
|
+
color: ${i("quiet-fg")}; cursor: pointer;
|
|
627
650
|
}
|
|
628
|
-
.bim-rd-ti:hover { background: ${
|
|
629
|
-
.bim-rd-ti[aria-current="true"] { background: ${
|
|
651
|
+
.bim-rd-ti:hover { background: ${i("row-hover-bg")}; color: ${i("ink")}; }
|
|
652
|
+
.bim-rd-ti[aria-current="true"] { background: ${i("bg")}; color: ${i("accent")}; font-weight: 700; box-shadow: inset 2px 0 0 ${i("accent")}; }
|
|
630
653
|
.bim-rd-ti:disabled { opacity: 0.45; cursor: default; background: none; }
|
|
631
|
-
.bim-rd-ti .bim-rd-hint { margin-left: auto; font-size: 12px; font-weight: 400; color: ${
|
|
632
|
-
.bim-rd-ti-group { font-weight: 600; color: ${
|
|
654
|
+
.bim-rd-ti .bim-rd-hint { margin-left: auto; font-size: 12px; font-weight: 400; color: ${i("meta-fg")}; flex: none; }
|
|
655
|
+
.bim-rd-ti-group { font-weight: 600; color: ${i("ink")}; }
|
|
633
656
|
.bim-rd-ti-group svg { transition: transform 0.15s; flex: none; align-self: center; }
|
|
634
657
|
.bim-rd-ti-group[aria-expanded="true"] svg { transform: rotate(90deg); }
|
|
635
658
|
|
|
@@ -644,39 +667,62 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
644
667
|
.bim-rd[data-img="closed"] .bim-rd-img { display: none; }
|
|
645
668
|
.bim-rd-img-box {
|
|
646
669
|
position: relative; flex: 1; min-height: 0; border-radius: 10px;
|
|
647
|
-
background: ${
|
|
670
|
+
background: ${i("sidebar-bg")};
|
|
648
671
|
display: flex; align-items: center; justify-content: center; overflow: hidden;
|
|
649
672
|
}
|
|
650
673
|
.bim-rd-img-fig { position: relative; margin: 0; max-width: 100%; max-height: 100%; }
|
|
651
674
|
.bim-rd-img-fig img { display: block; max-width: 100%; max-height: calc(100vh - ${pt} - var(--bimrd-bar-h) - 80px); object-fit: contain; }
|
|
652
675
|
.bim-rd-img-fig svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
|
|
653
|
-
.bim-rd-img-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center; font-size: 13px; color: ${
|
|
654
|
-
.bim-rd-img-empty b { font-size: 15px; font-weight: 500; color: ${
|
|
676
|
+
.bim-rd-img-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px; text-align: center; font-size: 13px; color: ${i("meta-fg")}; }
|
|
677
|
+
.bim-rd-img-empty b { font-size: 15px; font-weight: 500; color: ${i("quiet-fg")}; }
|
|
655
678
|
.bim-rd-img-frame {
|
|
656
679
|
width: 46%; aspect-ratio: 2 / 3; border-radius: 4px; margin-bottom: 10px;
|
|
657
|
-
background: repeating-linear-gradient(90deg, transparent 0 22px, color-mix(in srgb, ${
|
|
658
|
-
}
|
|
659
|
-
.bim-rd-img-pager { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 13px; color: ${
|
|
680
|
+
background: repeating-linear-gradient(90deg, transparent 0 22px, color-mix(in srgb, ${i("ink")} 5%, transparent) 22px 24px), ${i("bg")};
|
|
681
|
+
}
|
|
682
|
+
.bim-rd-img-pager { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 13px; color: ${i("quiet-fg")}; }
|
|
683
|
+
|
|
684
|
+
/* 右栏(v3):正文列右侧 220px,≥860px 才显示,吸顶 */
|
|
685
|
+
.bim-rd-rail { display: none; }
|
|
686
|
+
@media (min-width: 860px) {
|
|
687
|
+
.bim-rd-text[data-rail] { display: grid; grid-template-columns: minmax(0, 50em) 220px; gap: 40px; align-items: start; justify-content: start; }
|
|
688
|
+
.bim-rd-text[data-rail] .bim-rd-col { margin: 0; max-width: none; }
|
|
689
|
+
.bim-rd-rail { display: block; position: sticky; top: calc(var(--bimrd-bar-h) + 16px); max-height: calc(100vh - var(--bimrd-bar-h) - 32px); overflow-y: auto; font-family: ${i("font-ui")}; }
|
|
690
|
+
}
|
|
691
|
+
.bim-rd-rail-card { padding: 12px 14px; background: ${i("bg")}; border: 1px solid ${i("rule")}; }
|
|
692
|
+
.bim-rd-rail-cap { font-size: 11.5px; letter-spacing: 0.16em; color: ${i("label-fg")}; }
|
|
693
|
+
.bim-rd-rail-n { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
|
|
694
|
+
.bim-rd-rail-n b { font-size: 22px; font-weight: 600; color: ${i("ink")}; }
|
|
695
|
+
.bim-rd-rail-n span { font-size: 12px; color: ${i("meta-fg")}; }
|
|
696
|
+
.bim-rd-rail-n .bim-rd-rail-linked { margin-left: auto; color: ${i("accent")}; white-space: nowrap; }
|
|
697
|
+
.bim-rd-rail-bar { display: flex; height: 5px; margin-top: 8px; background: ${i("rule")}; }
|
|
698
|
+
.bim-rd-rail-bar span { background: ${i("accent")}; }
|
|
699
|
+
.bim-rd-rail-list { list-style: none; margin: 0; padding: 0; }
|
|
700
|
+
.bim-rd-rail-list a { display: flex; align-items: baseline; gap: 8px; padding: 5px 12px; border-left: 2px solid ${i("rule")}; font-size: 13px; color: ${i("quiet-fg")}; text-decoration: none; }
|
|
701
|
+
.bim-rd-rail-list a > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
702
|
+
.bim-rd-rail-list a:hover { border-left-color: ${i("accent")}; color: ${i("ink")}; }
|
|
703
|
+
.bim-rd-rail-dot { flex: none; align-self: center; width: 5px; height: 5px; background: ${i("rule")}; }
|
|
704
|
+
.bim-rd-rail-dot.on { background: ${i("accent")}; }
|
|
660
705
|
|
|
661
706
|
/* 正文 */
|
|
662
707
|
.bim-rd-text { grid-column: 3; min-width: 0; padding: 32px 48px 96px 40px; outline: none; }
|
|
663
708
|
/* 正文列靠左紧贴目录栏(原来居中,两边各留 ~150px 空隙),并加宽 38em → 50em */
|
|
664
709
|
.bim-rd-col { max-width: 50em; margin: 0 auto 0 0; font-size: var(--bimrd-fs, 18px); }
|
|
665
|
-
.bim-rd-h1 { font-family: ${
|
|
666
|
-
.bim-rd-meta { margin: 6px 0 0; font-size: 13px; line-height: 1.8; color: ${
|
|
710
|
+
.bim-rd-h1 { font-family: ${i("font-ui")}; font-size: 28px; font-weight: 700; letter-spacing: 0.12em; margin: 0; color: ${i("ink")}; line-height: 1.4; }
|
|
711
|
+
.bim-rd-meta { margin: 6px 0 0; font-size: 13px; line-height: 1.8; color: ${i("meta-fg")}; font-family: ${i("font-ui")}; }
|
|
667
712
|
.bim-rd-meta .bim-rd-dot::before { content: "·"; margin: 0 0.5em; }
|
|
713
|
+
.bim-rd-grade { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 11.5px; line-height: 1.7; background: ${i("band-bg")}; color: ${i("quiet-fg")}; }
|
|
668
714
|
.bim-rd-meta select { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
|
|
669
|
-
.bim-rd a.bim-rd-link { color: ${
|
|
670
|
-
.bim-rd a.bim-rd-link:hover { color: ${
|
|
671
|
-
.bim-rd-views { display: flex; gap: 14px; margin-top: 10px; font-size: 13px; color: ${
|
|
672
|
-
.bim-rd-state { padding: 32px 0; font-size: 14px; color: ${
|
|
715
|
+
.bim-rd a.bim-rd-link { color: ${i("quiet-fg")}; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
|
|
716
|
+
.bim-rd a.bim-rd-link:hover { color: ${i("accent")}; }
|
|
717
|
+
.bim-rd-views { display: flex; gap: 14px; margin-top: 10px; font-size: 13px; color: ${i("quiet-fg")}; font-family: ${i("font-ui")}; }
|
|
718
|
+
.bim-rd-state { padding: 32px 0; font-size: 14px; color: ${i("meta-fg")}; font-family: ${i("font-ui")}; }
|
|
673
719
|
|
|
674
720
|
/* 宋体正文:18px / 2.05,避头尾 */
|
|
675
721
|
.bim-rd-prose {
|
|
676
722
|
margin-top: 28px;
|
|
677
|
-
font-family: ${
|
|
723
|
+
font-family: ${i("font-reading")};
|
|
678
724
|
line-height: 2.05;
|
|
679
|
-
color: ${
|
|
725
|
+
color: ${i("ink")};
|
|
680
726
|
text-align: justify;
|
|
681
727
|
line-break: strict;
|
|
682
728
|
hanging-punctuation: allow-end;
|
|
@@ -684,7 +730,7 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
684
730
|
}
|
|
685
731
|
.bim-rd-prose p { margin: 0.5em 0; text-indent: 2em; }
|
|
686
732
|
.bim-rd-prose .bim-rd-noindent { text-indent: 0; }
|
|
687
|
-
.bim-rd-prose h2, .bim-rd-prose h3, .bim-rd-prose h4 { font-family: ${
|
|
733
|
+
.bim-rd-prose h2, .bim-rd-prose h3, .bim-rd-prose h4 { font-family: ${i("font-reading")}; color: ${i("ink")}; line-height: 1.6; letter-spacing: 0.04em; }
|
|
688
734
|
.bim-rd-prose h2 { font-size: 1.2em; font-weight: 700; margin: 1.6em 0 0.6em; }
|
|
689
735
|
.bim-rd-prose h3 { font-size: 1.06em; font-weight: 700; margin: 1.4em 0 0.3em; }
|
|
690
736
|
.bim-rd-prose h4 { font-size: 1em; font-weight: 700; margin: 1.2em 0 0.2em; }
|
|
@@ -698,16 +744,16 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
698
744
|
.bim-rd-entry { margin-top: 1.6em; }
|
|
699
745
|
.bim-rd-entry .bim-rd-entry-h { margin: 0 !important; font-size: 1.06em; }
|
|
700
746
|
.bim-rd-entry .bim-rd-entry-h a { color: inherit !important; text-decoration: none; }
|
|
701
|
-
.bim-rd-entry .bim-rd-entry-h a:hover { color: ${
|
|
702
|
-
.bim-rd-entry .bim-rd-sub { font-family: ${
|
|
703
|
-
.bim-rd-entry .bim-rd-lbl { font-family: ${
|
|
747
|
+
.bim-rd-entry .bim-rd-entry-h a:hover { color: ${i("accent")} !important; text-decoration: underline; text-underline-offset: 4px; }
|
|
748
|
+
.bim-rd-entry .bim-rd-sub { font-family: ${i("font-ui")}; font-size: 13px; color: ${i("meta-fg")}; text-indent: 0; margin: 0.2em 0 0; }
|
|
749
|
+
.bim-rd-entry .bim-rd-lbl { font-family: ${i("font-ui")}; font-size: 0.72em; letter-spacing: 0.1em; color: ${i("meta-fg")}; margin-right: 0.6em; }
|
|
704
750
|
.bim-rd-prose strong { font-weight: 700; }
|
|
705
751
|
|
|
706
752
|
/* 专名线:书名加波浪线,书名号隐去(仍可复制) */
|
|
707
753
|
.bim-rd-pn {
|
|
708
754
|
text-decoration-line: underline; text-decoration-style: wavy;
|
|
709
755
|
text-decoration-thickness: 1px; text-underline-offset: 0.32em;
|
|
710
|
-
text-decoration-color: ${
|
|
756
|
+
text-decoration-color: ${i("quiet-fg")};
|
|
711
757
|
text-decoration-skip-ink: none;
|
|
712
758
|
}
|
|
713
759
|
|
|
@@ -717,21 +763,27 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
717
763
|
overflow-x: auto; text-align: start;
|
|
718
764
|
}
|
|
719
765
|
|
|
720
|
-
.bim-rd-src { margin: 48px 0 0; font-size: 12px; line-height: 1.8; color: ${
|
|
766
|
+
.bim-rd-src { margin: 48px 0 0; font-size: 12px; line-height: 1.8; color: ${i("meta-fg")}; font-family: ${i("font-ui")}; }
|
|
721
767
|
.bim-rd-src .bim-rd-dot::before { content: "·"; margin: 0 0.5em; }
|
|
722
|
-
.bim-rd-pager { display:
|
|
723
|
-
.bim-rd-
|
|
768
|
+
.bim-rd-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; font-size: 14px; font-family: ${i("font-ui")}; }
|
|
769
|
+
.bim-rd-pg {
|
|
770
|
+
display: block; min-width: 0; margin: 0; padding: 14px 16px; text-align: left; font: inherit;
|
|
771
|
+
border: 1px solid ${i("rule")}; background: ${i("bg")}; color: ${i("ink")}; cursor: pointer;
|
|
772
|
+
}
|
|
773
|
+
button.bim-rd-pg:hover { border-color: ${i("accent")}; }
|
|
774
|
+
.bim-rd-pg-next { text-align: right; }
|
|
775
|
+
.bim-rd-pg-end { cursor: default; font-size: 13px; color: ${i("label-fg")}; background: none; border-style: dashed; }
|
|
776
|
+
.bim-rd-pgcap { display: block; font-size: 11.5px; color: ${i("label-fg")}; }
|
|
777
|
+
.bim-rd-pg .bim-rd-pglabel { display: block; margin-top: 3px; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
724
778
|
/* 长回目不能撑宽页面:两侧各占不超过一半,标题省略号截断(390 宽 scrollWidth 曾到 648) */
|
|
725
|
-
.bim-rd-pager > span { display: flex; min-width: 0; max-width: calc(50% - 8px); }
|
|
726
|
-
.bim-rd-pager > span:last-child { margin-left: auto; justify-content: flex-end; }
|
|
727
779
|
.bim-rd-pglabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
728
|
-
.bim-rd-refs { margin-top: 48px; font-size: 12px; line-height: 1.8; color: ${
|
|
729
|
-
.bim-rd-refs h2 { font-size: 12px; font-weight: 600; letter-spacing: 0.2em; margin: 0 0 6px; color: ${
|
|
780
|
+
.bim-rd-refs { margin-top: 48px; font-size: 12px; line-height: 1.8; color: ${i("meta-fg")}; font-family: ${i("font-ui")}; }
|
|
781
|
+
.bim-rd-refs h2 { font-size: 12px; font-weight: 600; letter-spacing: 0.2em; margin: 0 0 6px; color: ${i("meta-fg")}; }
|
|
730
782
|
.bim-rd-refs ol { margin: 0; padding-left: 1.6em; }
|
|
731
783
|
|
|
732
784
|
/* ── 点击区 ≥44×44(INT Q4):伪元素向外扩,按钮外观与排布不变;
|
|
733
785
|
A− A+ 挨着,两边各扩约 10px 会叠在一起,所以二者之间多留 12px ── */
|
|
734
|
-
@media ${
|
|
786
|
+
@media ${Pc} {
|
|
735
787
|
.bim-rd-tools .bim-rd-t, .bim-rd-toc-head .bim-rd-t { position: relative; }
|
|
736
788
|
.bim-rd-tools .bim-rd-t::after, .bim-rd-toc-head .bim-rd-t::after {
|
|
737
789
|
content: ""; position: absolute; left: 50%; top: 50%;
|
|
@@ -739,25 +791,25 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
739
791
|
}
|
|
740
792
|
.bim-rd-tools .bim-rd-fs + .bim-rd-fs { margin-left: 12px; }
|
|
741
793
|
.bim-rd-ver select { min-height: 44px; }
|
|
742
|
-
.bim-rd-pager .bim-rd-
|
|
794
|
+
.bim-rd-pager .bim-rd-pg { min-height: 44px; }
|
|
743
795
|
}
|
|
744
796
|
|
|
745
797
|
/* ── 中屏以下:目录改抽屉 ── */
|
|
746
|
-
@media not all and ${
|
|
798
|
+
@media not all and ${us} {
|
|
747
799
|
.bim-rd-toc {
|
|
748
800
|
position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; height: auto;
|
|
749
801
|
width: min(86vw, 320px);
|
|
750
|
-
box-shadow: ${
|
|
802
|
+
box-shadow: ${i("shadow-dialog")};
|
|
751
803
|
}
|
|
752
804
|
.bim-rd[data-toc="auto"] .bim-rd-toc { display: none; }
|
|
753
805
|
.bim-rd[data-toc="open"] .bim-rd-scrim {
|
|
754
|
-
display: block; position: fixed; inset: 0; z-index: 45; background: ${
|
|
806
|
+
display: block; position: fixed; inset: 0; z-index: 45; background: ${i("backdrop")};
|
|
755
807
|
}
|
|
756
808
|
.bim-rd-text { padding: 28px 32px 80px; }
|
|
757
809
|
}
|
|
758
810
|
|
|
759
811
|
/* ── 窄屏:书影收起,只留正文 ── */
|
|
760
|
-
@media ${
|
|
812
|
+
@media ${xs} {
|
|
761
813
|
.bim-rd-bar { padding: 0 12px; gap: 10px; }
|
|
762
814
|
.bim-rd-ttl span, .bim-rd-hide-narrow { display: none !important; }
|
|
763
815
|
.bim-rd-ttl { flex: 1 1 auto; }
|
|
@@ -765,7 +817,7 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
765
817
|
.bim-rd-ver { min-width: 44px; min-height: 44px; justify-content: center; }
|
|
766
818
|
.bim-rd-ver-short { display: inline; white-space: nowrap; }
|
|
767
819
|
.bim-rd-ver select { position: absolute; inset: 0; width: 100%; max-width: none; opacity: 0; }
|
|
768
|
-
.bim-rd-ver:focus-within { outline: 2px solid ${
|
|
820
|
+
.bim-rd-ver:focus-within { outline: 2px solid ${i("accent")}; outline-offset: 2px; border-radius: 3px; }
|
|
769
821
|
.bim-rd-tlabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
770
822
|
.bim-rd-img { display: none !important; }
|
|
771
823
|
.bim-rd-body { grid-template-columns: minmax(0, 1fr); }
|
|
@@ -773,23 +825,23 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
773
825
|
.bim-rd-h1 { font-size: 20px; letter-spacing: 0.06em; }
|
|
774
826
|
.bim-rd-prose { margin-top: 20px; }
|
|
775
827
|
}
|
|
776
|
-
`;function
|
|
777
|
-
`),[
|
|
778
|
-
`),
|
|
779
|
-
`);r=[],
|
|
780
|
-
`)}),l=
|
|
781
|
-
`).map(n=>n.trim()).filter(n=>n&&!
|
|
782
|
-
`)){const s=r.trim();if(!s||
|
|
783
|
-
`),
|
|
784
|
-
`)}),s=[]};for(const
|
|
785
|
-
`)){const r=
|
|
786
|
-
`)?"":n)}function
|
|
787
|
-
`);let c=0;return t.jsx(t.Fragment,{children:p.map((d,u)=>{const g=d.match(Ln);if(g){const m=c++;if(l(g[1].length,g[2],m))return null;const{Tag:b,className:k}=a(g[1].length);return t.jsx(b,{className:k,children:i(g[2])},u)}if(!d.trim())return u>=2&&!!p[u-1].trim()&&!!p[u-2].trim()&&!Ln.test(p[u-1])&&!Ln.test(p[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(xd.test(d))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(d.trim())){const{Tag:m,className:b}=a(3);return t.jsx(m,{className:b,children:i(d.trim().slice(2,-2))},u)}return t.jsx("p",{children:Eo(d,i,u)},u)})})}function md(e){const{convert:n}=V();return f.useMemo(()=>e?n(e):"",[e,n])}function Ni({text:e,mode:n,tables:i=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:l,dropTitle:a}){const p=md(e),{convert:c}=V(),d=x=>Ri(x,{renderText:l,properNames:s,gujiMarkdown:r}),u=r?{gujiMarkdown:!0}:void 0,g=a?c(a):void 0;return!i||p.indexOf(":::")<0?t.jsx(Ro,{text:p,mode:n,inline:d,dropTitle:g}):t.jsx(t.Fragment,{children:Ci(p).map((x,m)=>x.type==="table"?t.jsx(Ii,{table:x.table,opts:u},m):t.jsx(Ro,{text:x.text,mode:n,inline:d,dropTitle:m===0?g:void 0},m))})}function Ns(e,n){const[i,r]=f.useState(null),[s,l]=f.useState(!1),a=f.useRef(0);return f.useEffect(()=>{const p=++a.current;if(!e||!n){r(null),l(!1);return}let c;try{c=e(n)}catch{r(null),l(!1);return}if(!c||typeof c.then!="function"){r(c??null),l(!1);return}l(!0),c.then(d=>{p===a.current&&r(d??null)}).catch(()=>{p===a.current&&r(null)}).finally(()=>{p===a.current&&l(!1)})},[e,n]),{images:i,loading:s}}const No={A:"fine",B:"rough",C:"rough",D:"ocr"};function hd(e){return typeof e!="string"?null:e in Hn?e:e in No?No[e]:null}const bd={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},yd={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"};function nt(e){return typeof e!="string"?"":bd[e]??yd[e]??e}const jd=["〇","一","二","三","四","五","六","七","八","九"],Lo=["","十","百","千"],vd=["","萬","億"];function Li(e){if(e===0)return"〇";if(e<0)return`負${Li(-e)}`;const n=[];let i=e,r=0;for(;i>0;){const s=i%1e4;s>0?n.unshift(kd(s,r>0)+vd[r]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function kd(e,n){const i=[];let r=e;for(;r>0;)i.unshift(r%10),r=Math.floor(r/10);let s="";for(let l=0;l<i.length;l++){const a=i[l],p=i.length-1-l;a===0?s&&!s.endsWith("〇")&&(s+="〇"):a===1&&p===1&&l===0&&!n?s+=Lo[p]:s+=jd[a]+Lo[p]}return s.replace(/〇$/,"")}let Ut=null,an=null;const gn=new Set;function Sd(){return Ut?Promise.resolve():an||(an=import("opencc-js/t2cn").then(e=>{Ut=e.Converter({from:"tw",to:"cn"}),gn.forEach(n=>n())}).catch(()=>{Ut=e=>e,gn.forEach(e=>e())}),an)}const wd=e=>e;function vt(){const[,e]=f.useState(0);return f.useEffect(()=>{if(Ut)return;const n=()=>e(i=>i+1);return gn.add(n),Sd(),()=>{gn.delete(n)}},[]),Ut??wd}function Et(e,n){return n(e).toLowerCase()}const _d=o("highlight-bg");function Qt(e,n,i){if(!n)return e;const r=Et(n,i);if(!r)return e;const s=Et(e,i);if(s.length!==e.length)return e;const l=[];let a=0,p=0;for(;a<e.length;){const c=s.indexOf(r,a);if(c===-1){l.push(e.slice(a));break}c>a&&l.push(e.slice(a,c)),l.push(t.jsx("mark",{style:{background:_d,padding:0,color:"inherit"},children:e.slice(c,c+r.length)},p++)),a=c+r.length}return t.jsx(t.Fragment,{children:l})}function Bi(e,n,i,r){if(!n)return!0;const s=Et(n,r);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(a=>typeof a=="string"&&Et(a,r).includes(s))}function $d(e,n,i){return n?Et(e,i).includes(Et(n,i)):!0}const Ai={类:o("section-lei"),书:o("section-shu"),序:o("section-xu"),结语:o("section-jieyu"),注释:o("section-zhushi")},zd={考证:o("section-kaozhen")};function Cd(e){const n=e.replace(".json","").replace(/[/\\]/g,"");return n==="fulu"?"附錄":n.startsWith("juanshou")?`卷首${n.replace("juanshou","")}`:n.startsWith("juan")?`卷${n.replace("juan","").replace(/^0+/,"")}`:n}function Ls(e){var r;const n=e.files.length,i=((r=e.children)==null?void 0:r.reduce((s,l)=>s+Ls(l),0))||0;return n+i}function Id(e,n){const i=[],r=a=>{var p;i.push(...a.files),(p=a.children)==null||p.forEach(r)};if(r(e),i.length===0)return;const s=i.map(a=>n[a]);if(s.every(a=>a===void 0))return;if(s.some(a=>a==="loading"))return"loading";let l=0;for(const a of s)typeof a=="number"&&(l+=a);return l}const Td={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function Wi({enabled:e,expanded:n,onClick:i,style:r,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:i,style:{...Td,...r},children:s}):t.jsx("span",{style:r,children:s})}function Ed({type:e}){const n=nt(e),i=Ai[n]||o("desc-fg");return t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:i,border:`1px solid ${i}40`,borderRadius:"2px",background:`${i}08`,flexShrink:0},children:n})}function Rd({section:e,onNavigate:n,highlightQuery:i=""}){const{convert:r}=V(),s=Fe(),l=vt(),a=k=>k?Ue(r(k),h=>i?Qt(h,i,l):h):"",[p,c]=f.useState(!1),d=!!e.summary,u=!!e.comment,g=!!e.additional_comment,x=!!(e.content&&e.content.length>60),m=d||u||g||x;f.useEffect(()=>{i&&c(!0)},[i]);const b=!p&&x?rs(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{style:{border:`1px solid ${o("widget-border")}`,borderRadius:"6px",overflow:"hidden",marginBottom:"6px"},children:[t.jsxs("div",{onClick:()=>m&&c(!p),style:{padding:"8px 12px",display:"flex",alignItems:"baseline",gap:"8px",cursor:m?"pointer":"default",userSelect:"none",background:o("input-bg")},children:[t.jsxs(Wi,{enabled:m,expanded:p,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[m&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:o("desc-fg"),transition:"transform 0.15s",transform:p?"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:o("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",a(e.book_title),"》"]}):a(e.title),e.n_juan!=null&&t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:o("desc-fg"),marginLeft:"6px"},children:[Li(e.n_juan),"卷"]}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:o("desc-fg"),marginLeft:"8px"},children:a(e.author_info||e.author)})]}),!p&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:o("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:a(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:o("desc-fg")},children:a(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:o("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:s(e.work_id),onClick:k=>{k.metaKey||k.ctrlKey||(k.preventDefault(),k.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:o("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:"查看作品",children:"→作品"})]}),p&&m&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${o("widget-border")}`,background:o("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:o("desc-fg"),marginBottom:"8px"},children:a(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${o("primary")}`,background:`color-mix(in srgb, ${o("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:o("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:"提要"}),t.jsx("p",{style:{fontSize:"13px",color:o("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:a(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${o("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:o("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:"按語"}),t.jsx("p",{style:{fontSize:"13px",color:o("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${o("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:o("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:"附按"}),t.jsx("p",{style:{fontSize:"13px",color:o("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(e.additional_comment)})]}),x&&!d&&!u&&!g&&t.jsx("p",{style:{fontSize:"13px",color:o("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})]})]})}function Nd({section:e,highlightQuery:n=""}){const{convert:i}=V(),r=vt(),s=c=>c?Ue(i(c),d=>n?Qt(d,n,r):d):"",[l,a]=f.useState(!1),p=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(Wi,{enabled:p,expanded:l,onClick:()=>a(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:p?"pointer":"default",userSelect:"none"},children:[t.jsx(Ed,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:o("fg")},children:s(e.title)}),p&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:o("desc-fg"),transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),l&&p&&t.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${Ai[nt(e.type)]||o("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:o("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:o("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:s(e.content)})})]})}const Ld=100;function Mi(e){return nt(e.type)!=="page_header"?!1:(e.content||"").length>=Ld}function Bd({section:e,highlightQuery:n=""}){const{convert:i}=V(),r=vt();if(nt(e.type)==="page_header"&&!Mi(e)||!e.content&&!e.title)return null;const s=i((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
788
|
-
`)),l=Ue(s,d=>n?Qt(d,n,r):d),a=nt(e.type),p=Ai[a]||o("desc-fg"),c=a==="序"||a==="结语"||a==="注释";return t.jsxs("div",{style:{padding:c?"10px 12px":"6px 0",margin:c?"8px 0":void 0,fontSize:"13px",color:o("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:c?`3px solid ${p}40`:void 0,background:c?o("bg"):void 0,borderRadius:c?"0 4px 4px 0":void 0,position:"relative"},children:[c&&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:a}),l]})}function Ad(e,n,i){const[r,s]=f.useState({});return f.useEffect(()=>{var d;if(!n||e.length===0)return;let l=!1;const a=e.filter(u=>{var g;return!((g=i==null?void 0:i.current)!=null&&g.has(u))}),p={};for(const u of e)(d=i==null?void 0:i.current)!=null&&d.has(u)&&(p[u]=i.current.get(u));if(Object.keys(p).length>0&&s(p),a.length===0)return;const c=async u=>{var g;try{if(n.getEntry){const h=await n.getEntry(u);if(h)return{title:h.title,author:h.author}}const x=await n.getItem(u);if(!x)return null;const m=x.title||u,b=x.authors,k=(g=b==null?void 0:b[0])==null?void 0:g.name;return{title:m,author:k}}catch{return null}};return Promise.all(a.map(async u=>{var x;const g=await c(u);return(x=i==null?void 0:i.current)==null||x.set(u,g),[u,g]})).then(u=>{l||s(g=>{const x={...g};for(const[m,b]of u)x[m]=b;return x})}),()=>{l=!0}},[e.join(","),n]),r}function Wd({section:e,onNavigate:n,transport:i,workLabelCache:r,highlightQuery:s=""}){const{convert:l}=V(),a=Fe(),p=vt(),c=j=>j?Ue(l(j),v=>s?Qt(v,s,p):v):"",[d,u]=f.useState(!1);f.useEffect(()=>{s&&u(!0)},[s]);const g=nt(e.type),x=zd[g]||o("desc-fg"),m=!!e.content,b=e.work_ids||[],k=b.length>1,h=Ad(k?b:[],i,r),y=m&&!d&&e.content.length>80?rs(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${o("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>m&&u(!d),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:m?"pointer":"default",userSelect:"none"},children:[t.jsxs(Wi,{enabled:m,expanded:d,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[m&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:o("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:d?"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:o("fg"),lineHeight:1.6},children:e.header_line?c(e.header_line):c(e.title)}),!d&&y&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:o("desc-fg"),lineHeight:1.7},children:c(y)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[b.length===1&&n&&t.jsx("a",{href:a(b[0]),onClick:j=>{j.metaKey||j.ctrlKey||(j.preventDefault(),j.stopPropagation(),n(b[0]))},style:{fontSize:"11px",color:o("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:"查看作品",children:"→作品"}),k&&t.jsxs("span",{style:{fontSize:"11px",color:o("link-fg"),flexShrink:0},children:[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:g})]})]}),k&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:b.map(j=>{const v=h[j],_=v?`${l(v.title)}${v.author?`(${l(v.author)})`:""}`:j.slice(0,8)+"…";return t.jsxs("a",{href:a(j),onClick:S=>{S.metaKey||S.ctrlKey||(S.preventDefault(),S.stopPropagation(),n(j))},style:{fontSize:"12px",color:o("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:j,children:["→",_]},j)})}),d&&m&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:o("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:o("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:c(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${o("widget-border")}`,fontSize:"12px",color:o("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:c(e.comment)})]})]})}function Md({juan:e,searchQuery:n,onNavigate:i,transport:r,workLabelCache:s}){const l=vt(),a=n.trim(),p=f.useMemo(()=>a?e.sections.filter(c=>Bi(c,a,!0,l)):e.sections,[e.sections,a,l]);return t.jsxs("div",{children:[t.jsx("div",{children:p.map((c,d)=>t.jsx(Wd,{section:c,onNavigate:i,transport:r,workLabelCache:s,highlightQuery:a},d))}),p.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:o("desc-fg"),fontSize:"13px"},children:"无匹配结果"})]})}function Fd(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Pd({sections:e,onNavigate:n,inline:i}){const r=Fe(),{convert:s}=V(),l=Fd();return t.jsx(t.Fragment,{children:e.map((a,p)=>{const c=nt(a.type);if(c==="page_header"&&!Mi(a))return null;if(c==="类")return t.jsxs(f.Fragment,{children:[f.createElement(l("类"),null,i(s(a.title))),a.content&&t.jsx("p",{children:i(s(a.content))})]},p);if(c==="书"||c==="诗"||c==="考证"||c==="注释"){const d=a.book_title?`《${a.book_title}》${a.n_juan!=null?Li(a.n_juan)+"卷":""}`:a.title,u=i(s(d));return t.jsxs("section",{className:"bim-rd-entry",children:[f.createElement(l("条目"),{className:"bim-rd-entry-h"},a.work_id&&n?t.jsx("a",{href:r(a.work_id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),n(a.work_id))},title:"查看作品",children:u}):u),a.author_info&&t.jsx("p",{className:"bim-rd-sub",children:i(s(a.author_info))}),a.content&&a.content.split(/\n+/).map((g,x)=>t.jsx("p",{children:i(s(g))},x)),a.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:"提要"}),i(s(a.summary))]}),a.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:"按語"}),i(s(a.comment))]}),a.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:"附按"}),i(s(a.additional_comment))]})]},p)}return a.content?t.jsx("p",{children:i(s(a.content))},p):null})})}function Od(e){return e.some(n=>{const i=nt(n.type);return i==="书"||i==="诗"||i==="考证"||i==="注释"||i==="类"||(i==="序"||i==="结语")&&!!n.content||i==="page_header"&&Mi(n)})}function Dd({juan:e,rawText:n,positionLabel:i,index:r,searchQuery:s,onNavigate:l,transport:a,workLabelCache:p,prefs:c}){var A;const{convert:d}=V(),u=vt(),[g,x]=f.useState("text"),m=s.trim(),b=(r==null?void 0:r.type)==="kaozhen",k=f.useCallback(M=>m?Qt(M,m,u):M,[m,u]),h=M=>Ri(M,{renderText:k,properNames:c.properNames}),y=f.useMemo(()=>m?e.sections.filter(M=>Bi(M,m,b,u)):e.sections,[e.sections,m,b,u]),j=(M,F)=>F.filter(Y=>nt(Y.type)===M).length,v=j("书",e.sections),_=j("诗",e.sections),S=j("考证",e.sections);let $="";b?$=m?`${j("考证",y)} / ${S} ${d("條")}`:`${S} ${d("條")}`:_>0?$=m?`${j("诗",y)} / ${_} 首`:`${_} 首`:v>0&&($=m?`${j("书",y)} / ${v} ${d("部書")}`:`${v} ${d("部書")}`);const w=r!=null&&r.text_quality?hd(r.text_quality.grade):null,C=[];i&&C.push(i),$&&C.push($),b&&(r!=null&&r.target_source)&&C.push(t.jsxs(t.Fragment,{children:[d("考證對象")," ",d(r.target_source)]})),w&&C.push(t.jsx("span",{title:Al[w],children:(A=r==null?void 0:r.text_quality)!=null&&A.source_note?t.jsxs(t.Fragment,{children:["底本 ",d(r.text_quality.source_note),"(",d(Hn[w]),")"]}):t.jsxs(t.Fragment,{children:[d("文本質量")," ",d(Hn[w])]})})),e.source_url&&C.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:d("原文來源")}));const N=!b&&Od(e.sections),E=!!n&&(!N||c.readingMode==="paragraph"&&$n(n)),I=!b&&(N||!!n),O=b||!I?"entries":g;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:d(e.title)}),C.length>0&&t.jsx("p",{className:"bim-rd-meta",children:C.map((M,F)=>t.jsxs(f.Fragment,{children:[F>0&&t.jsx("span",{className:"bim-rd-dot"}),M]},F))}),I&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":"看法",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":O==="text",onClick:()=>x("text"),children:"正文"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":O==="entries",onClick:()=>x("entries"),children:d("條目")})]})]}),O==="text"&&t.jsx("article",{className:"bim-rd-prose",children:E?t.jsx(Ni,{text:n,mode:c.readingMode,properNames:c.properNames,renderText:k,dropTitle:e.title}):t.jsx(Pd,{sections:e.sections,onNavigate:l,inline:h})}),O==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:b?t.jsx(Md,{juan:e,searchQuery:s,onNavigate:l,transport:a,workLabelCache:p}):t.jsxs(t.Fragment,{children:[y.map((M,F)=>{const Y=nt(M.type);return Y==="书"||Y==="诗"||Y==="考证"?t.jsx(Rd,{section:M,onNavigate:l,highlightQuery:m},F):Y==="类"?t.jsx(Nd,{section:M,highlightQuery:m},F):t.jsx(Bd,{section:M,highlightQuery:m},F)}),y.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:"无匹配结果"})]})})]})}function Bs(e){return e.juan_files&&e.juan_files.length>0?e.juan_files:e.files&&e.files.length>0?e.files.map(n=>n.filename):[]}function Hd(e){const n=Bs(e);return n.length>0?n[0]:null}function Gd(e){const{workId:n,transport:i,files:r,activeFile:s,activeJuan:l,activeRawText:a,query:p,isKaozhen:c}=e,d=vt(),u=f.useRef(new Map),[g,x]=f.useState({}),[m,b]=f.useState({}),k=f.useCallback((y,j)=>{const v=j==null?void 0:j.title;v&&b(_=>_[y]===v?_:{..._,[y]:v})},[]);f.useEffect(()=>{s&&l&&(u.current.set(s,{juan:l,rawText:a}),k(s,l))},[s,l,a,k]),f.useEffect(()=>{u.current.clear(),x({}),b({})},[n]);const h=f.useCallback((y,j)=>{let v=0;if(y.juan)for(const _ of y.juan.sections)Bi(_,j,c,d)&&v++;return v===0&&y.rawText&&$d(y.rawText,j,d)&&(v=1),v},[c,d]);return f.useEffect(()=>{const y=p.trim();if(!y){x({});return}if(!n||!(i!=null&&i.getCollatedJuan)||r.length===0)return;let j=!1;const v={},_=[];for(const N of r){const E=u.current.get(N);E?v[N]=h(E,y):(v[N]="loading",_.push(N))}x(v);const S=8;let $=0;const w=async()=>{var N;for(;$<_.length;){if(j)return;const E=$++,I=_[E];try{const[O,A]=await Promise.all([i.getCollatedJuan(n,I),((N=i.getCollatedJuanText)==null?void 0:N.call(i,n,I))??Promise.resolve(null)]),M={juan:O,rawText:A};if(u.current.set(I,M),k(I,O),j)return;x(F=>({...F,[I]:h(M,y)}))}catch{if(j)return;x(O=>({...O,[I]:0}))}}},C=Array.from({length:Math.min(S,_.length)},()=>w());return Promise.all(C),()=>{j=!0}},[p,n,i,r.join(","),h,d,k]),{matchStates:g,titles:m}}const Fi=({index:e,workId:n,transport:i,onNavigate:r,activeJuan:s,onJuanChange:l,className:a,style:p,title:c,subtitle:d,resolveImages:u,renderImageOverlay:g,imagePanel:x,allowVertical:m})=>{const[b,k]=f.useState(null),[h,y]=f.useState(!1),[j,v]=f.useState(null),[_,S]=f.useState(null),[$,w]=f.useState(null),[C,N]=f.useState(!1),[E,I]=f.useState(null),[O,A]=f.useState(""),M=f.useRef(new Map),F=f.useRef(0),Y=s??_,K=f.useCallback(J=>{S(J),l==null||l(J)},[l]),R=e||b;f.useEffect(()=>{e&&(y(!1),v(null))},[e]),f.useEffect(()=>{if(e||!n||!(i!=null&&i.getCollatedEditionIndex))return;let J=!1;return y(!0),v(null),i.getCollatedEditionIndex(n).then(ce=>{J||(ce?k(ce):v("未找到整理本数据"))}).catch(ce=>{J||v(ce instanceof Error?ce.message:"加载失败")}).finally(()=>{J||y(!1)}),()=>{J=!0}},[e,n,i]),f.useEffect(()=>{if(R&&!Y){const J=Hd(R);J&&K(J)}},[R,Y,K]);const oe=n||(R==null?void 0:R.work_id),H=f.useCallback(async J=>{var me;if(!oe||!(i!=null&&i.getCollatedJuan))return;const ce=++F.current;N(!0),w(null),I(null);try{const[te,ie]=await Promise.all([i.getCollatedJuan(oe,J),((me=i.getCollatedJuanText)==null?void 0:me.call(i,oe,J))??Promise.resolve(null)]);if(ce!==F.current)return;w(te),I(ie)}catch{if(ce!==F.current)return;w(null),I(null)}finally{ce===F.current&&N(!1)}},[oe,i]);f.useEffect(()=>{Y&&H(Y)},[Y,H]);const re=J=>{K(J)};if(h)return t.jsx("div",{className:a,style:{...p,padding:"24px"},children:t.jsx("div",{style:{color:o("desc-fg"),fontSize:"13px"},children:"加载整理本..."})});if(j)return t.jsx("div",{className:a,style:{...p,padding:"24px",textAlign:"center",color:o("desc-fg"),fontSize:"13px"},children:j});if(!R)return null;const ee=R.type==="kaozhen",Q=Bs(R);return t.jsx(Vd,{className:a,style:p,index:R,allFiles:Q,isKaozhen:ee,effectiveWorkId:oe,transport:i,activeFile:Y,handleSelectFile:re,juanData:$,juanRawText:E,juanLoading:C,searchQuery:O,setSearchQuery:A,onNavigate:r,workLabelCacheRef:M,reader:{title:c,subtitle:d,resolveImages:u,renderImageOverlay:g,imagePanel:x,allowVertical:m}})};function As(e,n,i,r){var d,u,g,x;const s=(u=(d=n.juan_metadata)==null?void 0:d[e])==null?void 0:u.vol_label,l=r(s?`${s}冊`:Cd(e)),p=((x=(g=n.files)==null?void 0:g.find(m=>m.filename===e))==null?void 0:x.title)??i[e];if(!p)return{position:l,label:l};const c=r(p);return{position:l,label:l===p||l===c?c:`${l} ${c}`}}function Ud(e,n,i,r,s){const l=c=>c==="loading"?"…":typeof c=="number"&&c>0?c:void 0,a=(c,d)=>({key:c,label:d??As(c,e,r,s).label,hint:l(i[c]),disabled:i[c]===0}),p=(c,d)=>{var g;if(c.files.length===1&&!((g=c.children)!=null&&g.length))return a(c.files[0],s(c.label));const u=Id(c,i);return{key:`group:${d}`,label:s(c.label),hint:u==="loading"?"…":typeof u=="number"&&u>0?`${u}`:Ls(c),defaultExpanded:typeof u=="number"&&u>0,children:[...c.files.map(x=>a(x)),...(c.children??[]).map((x,m)=>p(x,`${d}.${m}`))]}};return e.juan_groups&&e.juan_groups.length>0?e.juan_groups.map((c,d)=>p(c,`${d}`)):n.map(c=>a(c))}const Vd=({className:e,style:n,index:i,allFiles:r,isKaozhen:s,effectiveWorkId:l,transport:a,activeFile:p,handleSelectFile:c,juanData:d,juanRawText:u,juanLoading:g,searchQuery:x,setSearchQuery:m,onNavigate:b,workLabelCacheRef:k,reader:h})=>{const{convert:y}=V(),[j,v]=$i(),{matchStates:_,titles:S}=Gd({workId:l,transport:a,files:r,activeFile:p,activeJuan:d,activeRawText:u,query:x,isKaozhen:s}),$=Ns(h.resolveImages,p),w=f.useMemo(()=>Ud(i,r,_,S,y),[i,r,_,S,y]),C=t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:s?"搜索全部章节…":"搜索全部卷…","aria-label":s?"搜索全部章节":"搜索全部卷",value:x,onChange:I=>m(I.target.value)}),N=s?"章":i.juan_metadata&&Object.values(i.juan_metadata).some(I=>I.vol_label)?"冊":"卷",E=p?As(p,i,S,y).position:void 0;return t.jsxs(zi,{className:e,style:n,title:h.title??(i.title?y(i.title):void 0),subtitle:h.subtitle??y(s?"考證":"整理本"),toc:w,tocCaption:`目录 · ${r.length} ${y(N)}`,tocHeader:C,activeKey:p,onSelect:c,images:$.images,imagesLoading:$.loading,renderImageOverlay:h.renderImageOverlay,imagePanel:h.imagePanel,prefs:j,onPrefsChange:v,paragraphToggle:!s&&$n(u),allowVertical:h.allowVertical,children:[g?t.jsx(jt,{}):d?t.jsx(Dd,{juan:d,rawText:u,positionLabel:E,index:i,searchQuery:x,onNavigate:b,transport:a,workLabelCache:k,prefs:j},p??""):p?t.jsx("div",{className:"bim-rd-state",children:"无法加载这一卷"}):null,i.references&&i.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:y("參考文獻")}),t.jsx("ol",{children:i.references.map((I,O)=>t.jsxs("li",{children:[I.url?t.jsx("a",{className:"bim-rd-link",href:I.url,target:"_blank",rel:"noopener noreferrer",children:I.title}):t.jsx("span",{children:I.title}),I.author&&t.jsxs("span",{children:[",",I.author]}),I.note&&t.jsxs("span",{children:["。",I.note]})]},O))})]})]})},Yd={bug:{label:"错误反馈",color:o("danger")},resource:{label:"资源建议",color:o("primary")},suggestion:{label:"功能建议",color:o("primary")},other:{label:"其他",color:o("desc-fg")}},Kd={label:"其他",color:o("desc-fg")},qd={pending:{label:"待处理",color:o("warning")},in_progress:{label:"处理中",color:o("primary")},resolved:{label:"已处理",color:o("success")},wontfix:{label:"不采纳",color:o("desc-fg")},duplicate:{label:"重复",color:o("desc-fg")}},Jd={label:"待处理",color:o("warning")};function Zd(e){try{const n=new Date(e),i=r=>String(r).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())} ${i(n.getHours())}:${i(n.getMinutes())}`}catch{return e}}function Xd(e,n){if(!e)return!1;try{const i=new URL(e,n);if(i.protocol!=="http:"&&i.protocol!=="https:")return!1;const r=new URL(n);return i.hostname===r.hostname}catch{return!1}}const Pi=({items:e,loading:n})=>{const i=Fe();return n?t.jsx(jt,{}):e.length===0?t.jsx("div",{style:Qd,children:"暂无反馈"}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(r=>{const s=Yd[r.type]||Kd,l=qd[r.status]||Jd,a=typeof window<"u"&&Xd(r.pageUrl,window.location.href);return t.jsxs("div",{style:ep,children:[t.jsxs("div",{style:tp,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Bo,background:s.color},children:s.label}),t.jsx("span",{style:{...Bo,background:l.color},children:l.label})]}),t.jsx("span",{style:np,children:Zd(r.createdAt)})]}),(r.resourceId||r.pageUrl)&&t.jsxs("div",{style:ip,children:[r.resourceId&&t.jsx("a",{href:i(r.resourceId),style:Bn,children:r.resourceId}),r.pageUrl&&!r.resourceId&&(a?t.jsx("a",{href:r.pageUrl,style:Bn,children:r.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:Bn,children:r.pageUrl}))]}),t.jsx("div",{style:op,children:r.content}),r.reply&&t.jsxs("div",{style:rp,children:[t.jsx("div",{style:sp,children:"回复"}),t.jsx("div",{children:r.reply})]})]},r.id)})})},Qd={textAlign:"center",padding:"40px 0",color:o("desc-fg"),fontSize:"14px"},ep={background:o("bg"),border:`1px solid ${o("widget-border")}`,borderRadius:"8px",padding:"16px"},tp={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Bo={fontSize:"12px",color:o("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},np={fontSize:"12px",color:o("desc-fg")},ip={fontSize:"12px",marginBottom:"6px"},Bn={color:o("primary"),textDecoration:"none",borderBottom:`1px dashed ${o("primary")}`},op={fontSize:"14px",lineHeight:"1.6",color:o("fg"),whiteSpace:"pre-wrap"},rp={marginTop:"12px",padding:"10px 12px",background:o("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:o("fg")},sp={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:o("primary")},ti=({transport:e,onNavigate:n,recommendedIds:i,activeTab:r,onTabChange:s,feedbackApiUrl:l})=>{const a=de(),[p,c]=f.useState(null),[d,u]=f.useState([]),[g,x]=f.useState("recommend"),[m,b]=f.useState([]),[k,h]=f.useState(!1),y=r??g,j=F=>{x(F),s==null||s(F)},[v,_]=f.useState(!0),[S,$]=f.useState(null),[w,C]=f.useState(null),[N,E]=f.useState(null);f.useEffect(()=>{let F=!1;if(e.getCounts)return e.getCounts().then(Y=>{F||c({works:Y.works,books:Y.books,collections:Y.collections})}).catch(()=>{}),()=>{F=!0}},[e]),f.useEffect(()=>{let F=!1;return(async()=>{if(i)return i;if(e.getRecommended)try{const K=await e.getRecommended();if(K!=null&&K.groups)return K.groups.flatMap(R=>R.items.map(oe=>({...oe,group:R.name})))}catch{}return[]})().then(async K=>{if(F)return;const R=K.filter(H=>H.id);if(R.length===0){_(!1);return}const oe=await Promise.all(R.map(async H=>{if(H.type)return{id:H.id,title:H.title,type:H.type,author:H.author,dynasty:H.dynasty,role:H.role,edition:H.edition,has_text:H.has_text,has_image:H.has_image,has_collated:H.has_collated,subtype:H.subtype,primary_name:H.primary_name,group:H.group,fallbackDescription:H.description};try{let re=null;if(e.getEntry)re=await e.getEntry(H.id);else{const ee=await e.getItem(H.id);ee&&(re={id:H.id,title:ee.title||H.id,type:ee.type||"work"})}if(re)return{...re,group:H.group,fallbackDescription:H.description}}catch{}return{id:H.id,title:H.title,type:ke.extractType(H.id),group:H.group,fallbackDescription:H.description}}));F||(u(oe.filter(H=>H!==null)),_(!1))}),()=>{F=!0}},[e,i]);const I=f.useRef(!1),O=f.useRef(!1),A=f.useRef(!1);f.useEffect(()=>{if(y!=="catalog"||I.current)return;const F=e.getCatalogProgress??e.getResourceProgress;if(!F)return;I.current=!0;let Y=!1;return F.call(e).then(K=>{Y||$(K)}).catch(()=>{I.current=!1}),()=>{Y=!0}},[e,y]),f.useEffect(()=>{if(y!=="collection"||O.current||!e.getCollectionProgress)return;O.current=!0;let F=!1;return e.getCollectionProgress().then(Y=>{F||C(Y)}).catch(()=>{O.current=!1}),()=>{F=!0}},[e,y]),f.useEffect(()=>{if(y!=="site"||A.current||!e.getSiteProgress)return;A.current=!0;let F=!1;return e.getSiteProgress().then(Y=>{F||E(Y)}).catch(()=>{A.current=!1}),()=>{F=!0}},[e,y]),f.useEffect(()=>{if(!l||y!=="feedback")return;let F=!1;return h(!0),fetch(l).then(Y=>Y.json()).then(Y=>{!F&&Y.success&&b(Y.items||[])}).catch(()=>{}).finally(()=>{F||h(!1)}),()=>{F=!0}},[l,y]);const M=F=>t.jsx(yn,{type:F,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:o("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${o("widget-border")}`,marginBottom:"16px"},children:[t.jsx(Ft,{label:a.home.recommendTab,active:y==="recommend",onClick:()=>j("recommend")}),t.jsx(Ft,{label:a.home.catalogTab,active:y==="catalog",onClick:()=>j("catalog")}),t.jsx(Ft,{label:a.home.collectionTab,active:y==="collection",onClick:()=>j("collection")}),t.jsx(Ft,{label:a.home.siteTab,active:y==="site",onClick:()=>j("site")}),l&&t.jsx(Ft,{label:a.home.feedbackTab,active:y==="feedback",onClick:()=>j("feedback")})]}),y==="recommend"&&t.jsx(lp,{recommended:d,loading:v,onNavigate:n,getIcon:M,t:a}),y==="catalog"&&t.jsx(Ao,{progress:S,t:a,onNavigate:n}),y==="collection"&&t.jsx(Ao,{progress:w,t:a,onNavigate:n}),y==="site"&&t.jsx(cp,{progress:N,t:a,totalWorks:(p==null?void 0:p.works)??0}),y==="feedback"&&l&&t.jsx(Pi,{items:m,loading:k})]})})},Ft=({label:e,active:n,onClick:i})=>t.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:o(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${o("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),lp=({recommended:e,loading:n,onNavigate:i,getIcon:r,t:s})=>{const l=Fe();if(n)return t.jsx(jt,{});if(e.length===0)return null;const a=new Map;for(const p of e){const c=p.group||s.home.recommendedBrowse;a.has(c)||a.set(c,[]),a.get(c).push(p)}return t.jsx(t.Fragment,{children:Array.from(a.entries()).map(([p,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:o("desc-fg"),marginBottom:"8px"},children:p}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(d=>{const u=d.dynasty||d.author?`${d.dynasty?`〔${d.dynasty}〕`:""}${d.author||""}`:d.fallbackDescription;return t.jsxs("a",{href:l(d.id),onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),i==null||i(d.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${o("widget-border")}`,cursor:"pointer",background:o("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:r(d.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[d.title,d.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:o("desc-fg"),marginLeft:"4px"},children:d.edition})]}),u&&t.jsx("div",{style:{fontSize:"12px",color:o("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},d.id)})})]},p))})},Ao=({progress:e,t:n,onNavigate:i})=>{if(!e)return t.jsx(jt,{});const r=[...e.resources].sort((p,c)=>p.priority-c.priority),s=["in_progress","done","todo"],l={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},a={in_progress:o("progress-active"),done:o("progress-done"),todo:o("progress-todo")};return t.jsx("div",{children:s.map(p=>{const c=r.filter(d=>d.status===p);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:o("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:a[p]}}),l[p]," (",c.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(d=>t.jsx(ap,{item:d,t:n,statusColor:a[p],onNavigate:i},d.id))})]},p)})})},ap=({item:e,t:n,statusColor:i,onNavigate:r})=>{const s=Fe(),l=e.total>0?Math.round(e.imported/e.total*100):0,a=e.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${o("widget-border")}`,background:o("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 p=e.edition?`${e.name}·${e.edition}`:e.name,c=e.collection_id||e.work_id;return c&&r?t.jsx("a",{href:s(c),onClick:d=>{d.metaKey||d.ctrlKey||(d.preventDefault(),r(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${o("link-fg")}`},onMouseEnter:d=>d.currentTarget.style.borderBottomStyle="solid",onMouseLeave:d=>d.currentTarget.style.borderBottomStyle="dashed",children:p}):e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:p}):p})()}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:o("widget-border"),color:o("desc-fg"),whiteSpace:"nowrap"},children:e.collection_id?n.indexType.collection:e.work_id?n.indexType.work:a})]}),t.jsx("span",{style:{fontSize:"12px",color:o("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?Kt(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:o("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${l}%`,borderRadius:"2px",background:i,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:o("desc-fg"),marginTop:"4px"},children:e.description})]})},cp=({progress:e,t:n,totalWorks:i})=>{if(!e)return t.jsx(jt,{});const r=[...e.resources].sort((c,d)=>c.priority-d.priority),s=r.filter(c=>c.imported>0),l=r.filter(c=>c.imported===0),a=s.reduce((c,d)=>Math.max(c,d.imported),0),p=i>0?Math.round(a/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, ${o("primary")} 6%, transparent)`,fontSize:"13px",color:o("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:a.toLocaleString()})," / ",i.toLocaleString()," ",n.indexType.work," (",p,"%)"]}),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:o("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:o("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(Wo,{item:c,t:n,totalWorks:i},c.id))})]}),l.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:o("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:o("progress-todo")}}),n.home.statusTodo," (",l.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:l.map(c=>t.jsx(Wo,{item:c,t:n,totalWorks:i},c.id))})]})]})},Wo=({item:e,t:n,totalWorks:i})=>{const r=i>0?Math.round(e.imported/i*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${o("widget-border")}`,background:o("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:o("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),e.imported>0&&i>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:o("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:o("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:o("desc-fg"),marginTop:"4px"},children:e.description})]})},Mo="(max-width: 768px)";function dp(){const[e,n]=f.useState(()=>typeof window>"u"?!1:window.matchMedia(Mo).matches);return f.useEffect(()=>{const i=window.matchMedia(Mo),r=s=>n(s.matches);return i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),e}const pp=({transport:e,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:r,headerRight:s})=>{var Y;const l=de(),{convert:a}=V(),p=dp(),[c,d]=f.useState(null),[u,g]=f.useState(null),[x,m]=f.useState(!1),[b,k]=f.useState("detail"),[h,y]=f.useState([]),[j,v]=f.useState(!1),[_,S]=f.useState(null),[$,w]=f.useState(!1),C=f.useCallback(async K=>{if(!e.getCollatedEditionIndex){S(null);return}w(!0);try{const R=await e.getCollatedEditionIndex(K);S(R)}catch{S(null)}finally{w(!1)}},[e]),N=f.useCallback(async K=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){y([]);return}v(!0);try{if(e.getCollectionCatalogs){const R=await e.getCollectionCatalogs(K);y(R||[])}else if(e.getCollectionCatalog){const R=await e.getCollectionCatalog(K);y(R?[{resource_id:"",data:R}]:[])}}catch{y([])}finally{v(!1)}},[e]),E=f.useCallback(async K=>{if(i){i(K);return}d(K),g(null),y([]),S(null),k("detail"),m(!0);try{const R=await e.getItem(K.id);R&&(g(R),R.type==="collection"?N(K.id):R.type==="work"&&R.has_collated&&C(K.id))}catch(R){console.error("加载详情失败:",R)}finally{m(!1)}},[e,i,N,C]),I=f.useCallback(async K=>{g(null),y([]),S(null),k("detail"),m(!0);try{const R=await e.getItem(K);R&&(g(R),d({id:K,title:R.title||K,type:R.type||"book"}),R.type==="collection"?N(K):R.type==="work"&&R.has_collated&&C(K))}catch(R){console.error("导航失败:",R)}finally{m(!1)}},[e,N,C]),O=(u==null?void 0:u.type)==="collection"&&(h.length>0||j)||(u==null?void 0:u.type)==="work"&&(_||$),A=p&&(x||u),M=f.useCallback(()=>{d(null),g(null),y([]),S(null),k("detail")},[]),F=t.jsx(t.Fragment,{children:x?t.jsx(jt,{}):u?t.jsxs(t.Fragment,{children:[(O||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${o("widget-border")}`,padding:p?"0 12px":"0 48px",background:o("input-bg"),flexShrink:0,overflowX:p?"auto":void 0},children:[O&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>k("detail"),style:cn(b==="detail"),children:l.detailTab.basicInfo}),u.type==="collection"&&j&&h.length===0&&t.jsxs("button",{onClick:()=>{},style:cn(!1),children:[l.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&h.map(K=>t.jsx("button",{onClick:()=>k(`catalog:${K.resource_id}`),style:cn(b===`catalog:${K.resource_id}`),children:K.short_name?`${a(K.short_name)}${l.detailTab.catalogSuffix}`:l.detailTab.collectionCatalog},K.resource_id)),u.type==="work"&&(_||$)&&t.jsxs("button",{onClick:()=>k("collated"),style:cn(b==="collated"),children:[l.detailTab.collatedEdition,$&&t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),t.jsx("div",{style:{padding:p?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:b==="detail"?t.jsx(fi,{data:u,transport:e,onNavigate:I}):b.startsWith("catalog:")?t.jsx(gi,{data:(Y=h.find(K=>`catalog:${K.resource_id}`===b))==null?void 0:Y.data,onNavigate:I}):b==="collated"?t.jsx(Fi,{index:_||void 0,workId:u.id,transport:e,onNavigate:I}):null})]}):t.jsx(ti,{transport:e,onNavigate:I,recommendedIds:r})});return p?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:o("bg"),color:o("fg")},children:A?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${o("widget-border")}`,background:o("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:M,style:{padding:"4px 12px",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:"transparent",color:o("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",l.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:F})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Un,{transport:e,onEntryClick:E,hideModeIndicator:n}),!u&&t.jsx(ti,{transport:e,onNavigate:I,recommendedIds:r})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:o("bg"),color:o("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${o("widget-border")}`,display:"flex",flexDirection:"column",background:o("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(Un,{transport:e,onEntryClick:E,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:o("bg"),display:"flex",flexDirection:"column"},children:F})]})};function cn(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${o("primary")}`:"2px solid transparent",background:"transparent",color:o(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function ut(e){return e.replace(/\.md$/,"")}function Fo(e){let n="";if(e.source_url)try{const r=new URL(e.source_url).pathname.split("/").filter(Boolean).pop()??"";n=decodeURIComponent(r).replace(/_/g," ")}catch{}return[e.source_name,n||e.version_label].filter(Boolean).join(" · ")||e.key}const Po={padding:24,color:o("desc-fg")},ni=({index:e,bookId:n,transport:i,activeChapter:r,onChapterChange:s,workKey:l,versions:a,onVersionChange:p,title:c,subtitle:d,resolveImages:u,renderImageOverlay:g,imagePanel:x,allowVertical:m,className:b,style:k})=>{const[h,y]=f.useState(e??null),[j,v]=f.useState(!1),[_,S]=f.useState(null),$=r!==void 0?r:_,w=f.useCallback(Q=>{s?s(Q):S(Q)},[s]),[C,N]=f.useState(null),[E,I]=f.useState(!1);f.useEffect(()=>{e&&y(e)},[e]),f.useEffect(()=>{if(e)return;y(null),v(!1);const Q=l!==void 0?i.getWorkFullTextIndex?()=>i.getWorkFullTextIndex(n,l):null:i.getBookFullTextIndex?()=>i.getBookFullTextIndex(n):null;if(!n||!Q){v(!0);return}let J=!1;return Promise.resolve().then(Q).then(ce=>{J||(ce?y(ce):v(!0))}).catch(()=>{J||v(!0)}),()=>{J=!0}},[n,i,e,l]),f.useEffect(()=>{if(!h||h.chapters.length===0)return;const Q=ut(h.chapters[0].file);if(!$){w(Q);return}const J=ut($);h.chapters.some(me=>ut(me.file)===J)||w(Q)},[h,$,w]);const O=f.useMemo(()=>{if(!h||!$)return null;const Q=ut($);return h.chapters.find(J=>ut(J.file)===Q)??null},[h,$]);f.useEffect(()=>{if(!n||!O)return;const Q=l!==void 0?i.getWorkFullTextChapter?ce=>i.getWorkFullTextChapter(n,l,ce):null:i.getBookFullTextChapter?ce=>i.getBookFullTextChapter(n,ce):null;if(!Q)return;let J=!1;return I(!0),N(null),Promise.resolve(O.file).then(Q).then(ce=>{J||N(ce)}).catch(()=>{J||N(null)}).finally(()=>{J||I(!1)}),()=>{J=!0}},[n,O,i,l]);const A=Ns(u,O?ut(O.file):null),[M,F]=$i(),{convert:Y}=V(),K=!!(a&&a.length>1&&p),R=f.useMemo(()=>K?bs(a).map((Q,J)=>({...Q,label:Fo(a[J])})):void 0,[K,a]),oe=K?t.jsxs("label",{children:["版本:",t.jsx("select",{value:l,onChange:Q=>p(Q.target.value),children:a.map(Q=>t.jsx("option",{value:Q.key,children:Fo(Q)},Q.key))})]}):null;if(!h)return t.jsxs("div",{style:Po,children:[oe&&t.jsx("div",{style:{marginBottom:12},children:oe}),j?"无法加载全文目录":"加载全文目录…"]});if(h.chapters.length===0)return t.jsxs("div",{style:Po,children:[oe&&t.jsx("div",{style:{marginBottom:12},children:oe}),"全文目录为空"]});const H=h.chapters.map(Q=>({key:ut(Q.file),label:Y(Q.title)})),re=ks(h)||Kn(h),ee=C?C.replace(/^##\s+[^\n]+\n+/,""):null;return t.jsxs(zi,{title:c??Y(h.version_label),subtitle:d??"全文",toc:H,tocCaption:`目录 · ${h.chapters.length} ${h.chapters.length>1?"卷":"篇"}`,activeKey:$?ut($):null,onSelect:w,images:A.images,imagesLoading:A.loading,renderImageOverlay:g,imagePanel:x,prefs:M,onPrefsChange:F,versions:R,currentVersionKey:R?l??null:void 0,onVersionChange:R?p:void 0,versionSource:!1,paragraphToggle:$n(ee),allowVertical:m,className:b,style:k,children:[O&&t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:Y(O.title)}),t.jsxs("p",{className:"bim-rd-meta",children:["来源 ",t.jsx("a",{className:"bim-rd-link",href:h.source.url,target:"_blank",rel:"noreferrer",children:Y(h.source.name)}),h.source.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),h.source.license]})]})]}),E&&t.jsx("div",{className:"bim-rd-state",children:"加载中…"}),!E&&ee!=null&&t.jsx("article",{className:"bim-rd-prose",children:t.jsx(Ni,{text:ee,mode:M.readingMode,tables:re,gujiMarkdown:Kn(h),properNames:M.properNames})}),!E&&!C&&t.jsx("div",{className:"bim-rd-state",children:"无法加载章节内容"})]})},up=({data:e,onNavigate:n,className:i,style:r})=>{var u;const s=de(),{convert:l}=V(),[a,p]=f.useState(((u=e.divisions[0])==null?void 0:u.name)??null),[c,d]=f.useState(null);return t.jsxs("div",{className:i,style:r,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:o("fg"),margin:"0 0 8px"},children:l(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:o("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:["著錄 ",t.jsx("strong",{children:e.stats.zhulu})," ",s.unit.bu]}),e.stats.cunmu!=null&&t.jsxs("span",{children:["存目 ",t.jsx("strong",{children:e.stats.cunmu})," ",s.unit.bu]}),e.stats.categories!=null&&t.jsxs("span",{children:[e.stats.categories," 類"]})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(g=>t.jsx(xp,{division:g,expanded:a===g.name,onToggle:()=>p(a===g.name?null:g.name),expandedCat:c,onCatToggle:x=>d(c===x?null:x),onNavigate:n},g.name))})]})},xp=({division:e,expanded:n,onToggle:i,expandedCat:r,onCatToggle:s,onNavigate:l})=>{const{convert:a}=V(),p=e.categories.reduce((c,d)=>{const u=d.stats||{zhulu:0,cunmu:0};return c+(u.zhulu||0)+(u.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${o("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, ${o("primary")} 6%, transparent)`:o("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:o("fg"),textAlign:"left"},children:[t.jsx("span",{children:a(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:o("desc-fg")},children:[e.categories.length," 類 · ",p," 部",t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(c=>{const d=`${e.name}/${c.name}`;return t.jsx(fp,{category:c,expanded:r===d,onToggle:()=>s(d),onNavigate:l},c.name)})})]})},fp=({category:e,expanded:n,onToggle:i,onNavigate:r})=>{var c,d,u,g;const{convert:s}=V(),l=((c=e.books)==null?void 0:c.zhulu)||[],a=((d=e.books)==null?void 0:d.cunmu)||[],p=(((u=e.stats)==null?void 0:u.zhulu)||l.length)+(((g=e.stats)==null?void 0:g.cunmu)||a.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?o("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:o("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[s(e.name),e.volumes&&t.jsxs("span",{style:{fontSize:"11px",color:o("desc-fg"),marginLeft:"8px",fontWeight:400},children:["卷",e.volumes]})]}),t.jsxs("span",{style:{fontSize:"11px",color:o("desc-fg")},children:[p," 部 ",n?"▲":"▼"]})]}),n&&(l.length>0||a.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(Oo,{label:"著錄",books:l,onNavigate:r}),a.length>0&&t.jsx(Oo,{label:"存目",books:a,onNavigate:r})]})]})},Oo=({label:e,books:n,onNavigate:i})=>{const{convert:r}=V(),s=Fe(),[l,a]=f.useState(n.length<=20),p=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:o("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:p.map((c,d)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:o("fg")},children:c.work_id&&i?t.jsx("a",{href:s(c.work_id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),i(c.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${o("link-fg")}`},children:r(c.title)}):r(c.title)}),c.volumes&&t.jsx("span",{style:{fontSize:"11px",color:o("desc-fg")},children:r(c.volumes)}),c.author&&t.jsx("span",{style:{fontSize:"11px",color:o("desc-fg")},children:r(c.author).slice(0,20)})]},d))}),!l&&t.jsxs("button",{onClick:()=>a(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:o("primary"),background:"transparent",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:["展開全部 ",n.length," 條"]})]})},Ye=({title:e,onSave:n,onAskAI:i,extraButtons:r,children:s})=>{const l=de();return t.jsxs("div",{style:{background:o("bg"),border:`1px solid ${o("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 ${o("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:o("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,i&&t.jsx("button",{onClick:i,style:mp,children:"AI"}),n&&t.jsx("button",{onClick:n,style:gp,children:l.action.save})]})]}),s]})},gp={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:o("primary"),color:o("primary-fg"),cursor:"pointer"},mp={padding:"4px 12px",fontSize:"12px",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:"transparent",color:o("fg"),cursor:"pointer"},Ge=({label:e,value:n,onChange:i,placeholder:r,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:o("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:l=>i(l.target.value),placeholder:r,disabled:s,style:{width:"100%",padding:"6px 8px",background:o("input-bg"),color:o("input-fg"),border:`1px solid ${o("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),bt=({value:e,onChange:n,placeholder:i})=>{const r=f.useRef(null);return f.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:r,value:e||"",onChange:s=>n(s.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:o("input-bg"),color:o("input-fg"),border:`1px solid ${o("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},mn=({children:e,color:n,style:i})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||o("primary-soft"),color:o(n?"on-color-fg":"fg"),...i},children:e});function hp(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const pn=({value:e,onChange:n,label:i})=>{const[r,s]=f.useState(!1),l=f.useRef(null),a=hp(e||"");return f.useEffect(()=>{r&&l.current&&l.current.focus()},[r]),!r&&a?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Do,children:i}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${o("input-border")}`,borderRadius:"2px",background:o("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:o("fg")},children:a.name}),t.jsx(mn,{children:a.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Do,children:i}),t.jsx("input",{ref:l,type:"text",value:e||"",onChange:p=>n(p.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:o("input-bg"),color:o("input-fg"),border:`1px solid ${o("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Do={display:"block",fontSize:"11px",color:o("desc-fg"),marginBottom:"4px",fontWeight:500};function bp(e){switch(e){case"url":return o("source-url");case"bookID":return o("source-bookid");default:return o("desc-fg")}}function yp(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Ws=({items:e,onChange:n,onOpenEntityPicker:i})=>{const r=de(),[s,l]=f.useState(null),a=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),l(e.length)},p=g=>{n(e.filter((x,m)=>m!==g)),s===g&&l(null)},c=(g,x,m)=>{const b=[...e];b[g]={...b[g],[x]:m},n(b)},d=(g,x)=>{const m=[...e];m[g]={...m[g],type:x,id:"",name:""},n(m),x==="bookID"&&i&&i(b=>{const k=[...e];k[g]={...k[g],id:b.id,name:b.title,type:"bookID"},n(k)})},u=g=>{i&&i(x=>{const m=[...e];m[g]={...m[g],id:x.id,name:x.title,type:"bookID"},n(m)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((g,x)=>t.jsxs("div",{style:{border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:o("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>l(s===x?null:x),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===x?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:o("fg")},children:g.name||`${r.editor.sourcePlaceholder} ${x+1}`}),g.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:bp(g.type),color:o("on-color-fg"),borderRadius:"3px",fontWeight:500},children:yp(g.type)}),t.jsx("button",{onClick:m=>{m.stopPropagation(),p(x)},style:{background:"transparent",border:"none",color:o("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===x&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${o("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!g.type&&t.jsxs("div",{children:[t.jsx("label",{style:it,children:r.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>d(x,"bookID"),style:{...Ho,borderColor:o("source-bookid"),color:o("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>d(x,"url"),style:{...Ho,borderColor:o("source-url"),color:o("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.enterUrl})]})]})]}),g.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:it,children:r.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const m=[...e];m[x]={...m[x],type:"",id:"",name:""},n(m)},style:Go,children:r.action.changeType})]}),g.id&&g.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:o("bg"),border:`1px solid ${o("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:o("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:g.name}),t.jsx("code",{style:{fontSize:"11px",background:o("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:g.id})]}),t.jsx("button",{onClick:()=>u(x),style:{background:"transparent",border:`1px solid ${o("widget-border")}`,color:o("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:r.action.reselect})]}):t.jsxs("button",{onClick:()=>u(x),style:{width:"100%",padding:"14px",border:`2px dashed ${o("widget-border")}`,borderRadius:"6px",background:"transparent",color:o("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),g.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:it,children:r.label.sourceName}),t.jsx("button",{onClick:()=>{const m=[...e];m[x]={...m[x],type:"",id:"",name:""},n(m)},style:Go,children:r.action.changeType})]}),t.jsx("input",{type:"text",value:g.name,onChange:m=>c(x,"name",m.target.value),placeholder:r.editor.sourceNamePlaceholder,style:St})]}),t.jsxs("div",{children:[t.jsx("label",{style:it,children:r.label.urlAddress}),t.jsx("input",{type:"text",value:g.id,onChange:m=>c(x,"id",m.target.value),placeholder:"https://...",style:St})]})]}),g.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${o("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...it,opacity:.7},children:r.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:it,children:r.label.detailsOptional}),t.jsx("input",{type:"text",value:g.details,onChange:m=>c(x,"details",m.target.value),placeholder:r.editor.detailsPlaceholder,style:St})]}),t.jsxs("div",{children:[t.jsx("label",{style:it,children:r.label.positionOptional}),t.jsx("input",{type:"text",value:g.position,onChange:m=>c(x,"position",m.target.value),placeholder:"如: 卷三, p.52",style:St})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:it,children:r.label.dataVersionOptional}),t.jsx("input",{type:"text",value:g.version,onChange:m=>c(x,"version",m.target.value),placeholder:"如: v1.0, 2024-01",style:St})]}),t.jsxs("div",{children:[t.jsx("label",{style:it,children:r.label.processorVersionOptional}),t.jsx("input",{type:"text",value:g.processor_version,onChange:m=>c(x,"processor_version",m.target.value),placeholder:"如: v0.1",style:St})]})]})]})]})})]},x)),t.jsxs("button",{onClick:a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${o("widget-border")}`,borderRadius:"4px",background:"transparent",color:o("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:r.action.addSource})]})]})},it={display:"block",fontSize:"11px",color:o("desc-fg"),marginBottom:"4px",fontWeight:500},St={width:"100%",padding:"6px 8px",background:o("input-bg"),color:o("input-fg"),border:`1px solid ${o("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Ho={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:o("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},Go={background:"transparent",border:"none",color:o("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Ms(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 Fs(e){return!e||e.length===0?"":JSON.stringify(e)}const Ps=({entityType:e,entityId:n,entityTitle:i,parentWork:r,parentCollection:s,belongsToWork:l,belongsToCollection:a,childWorks:p,childCollections:c,containedBooks:d,siblingBooks:u,onLinkEntity:g,onUnlinkEntity:x,onViewEntity:m,onCreateAndLink:b,onSaveRelations:k})=>{const h=de();return t.jsxs("div",{style:{background:o("bg"),border:`1px solid ${o("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${o("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:h.section.relations})]}),k&&t.jsx("button",{onClick:k,style:jp,children:h.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Pt,{direction:"up",title:h.relation.belongsToWork,entity:l,onView:m,onUnlink:()=>x("workId"),onLink:()=>g("workId","work"),onCreate:()=>b("workId","work",{title:i}),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),t.jsx(Pt,{direction:"up",title:h.relation.containedInCollection,entity:a,onView:m,onUnlink:()=>x("collectionId"),onLink:()=>g("collectionId","collection"),onCreate:()=>b("collectionId","collection",{title:i}),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),l&&u&&u.length>0&&t.jsx(wt,{direction:"horizontal",title:`${h.relation.siblingVersions} (${u.length})`,entities:u,onView:m,onAdd:()=>b("siblingBook","book",{workId:l.id}),addLabel:h.relation.addVersionForWork,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Pt,{direction:"up",title:h.relation.parentWork,entity:r,onView:m,onUnlink:()=>x("parentWorkId"),onLink:()=>g("parentWorkId","work"),onCreate:()=>b("parentWorkId","work"),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),p&&p.length>0&&t.jsx(wt,{direction:"down",title:`${h.relation.childWorks} (${p.length})`,entities:p,onView:m,onAdd:()=>b("childWork","work",{parentWorkId:n}),addLabel:h.action.addSubWork,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore}),c&&c.length>0&&t.jsx(wt,{direction:"down",title:`${h.relation.collectionImpl} (${c.length})`,entities:c,onView:m,onAdd:()=>b("childCollection","collection",{workId:n}),addLabel:h.action.addCollectionImpl,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore}),t.jsx(wt,{direction:"down",title:`${h.relation.allVersions} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:m,onAdd:()=>b("childBook","book",{workId:n}),addLabel:h.action.addVersion,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Pt,{direction:"up",title:h.relation.correspondingWork,entity:l,onView:m,onUnlink:()=>x("workId"),onLink:()=>g("workId","work"),onCreate:()=>b("workId","work",{title:i}),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),t.jsx(Pt,{direction:"up",title:h.relation.parentCollection,entity:s,onView:m,onUnlink:()=>x("parentCollectionId"),onLink:()=>g("parentCollectionId","collection"),onCreate:()=>b("parentCollectionId","collection"),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),t.jsx(wt,{direction:"down",title:`${h.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:m,onAdd:()=>b("childCollection","collection",{parentCollectionId:n}),addLabel:h.action.addSubCollection,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore}),t.jsx(wt,{direction:"down",title:`${h.relation.containedBooks} (${(d==null?void 0:d.length)??0})`,entities:d||[],onView:m,onAdd:()=>b("childBook","book",{collectionId:n}),addLabel:h.action.addBook,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore})]})]})]})},Pt=({direction:e,title:n,entity:i,onView:r,onUnlink:s,onLink:l,onCreate:a,linkLabel:p,createLabel:c,notLinkedLabel:d,viewLabel:u,unlinkLabel:g})=>{const x=o(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${o("widget-border")}`,borderRadius:"4px",padding:"10px",background:o("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:x,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:m}),t.jsx("span",{children:n})]}),i?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:o("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Os(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(Uo,{onClick:()=>r(i),title:u,children:"👁️"}),t.jsx(Uo,{onClick:s,title:g,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:o("bg"),borderRadius:"4px",color:o("desc-fg"),fontSize:"12px",textAlign:"center"},children:d}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(ii,{onClick:l,children:p}),t.jsx(ii,{onClick:a,primary:!0,children:c})]})]})},wt=({direction:e,title:n,entities:i,onView:r,onAdd:s,addLabel:l,noneLabel:a,expandMoreLabel:p})=>{const[c,d]=f.useState(!1),u=o(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),g=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",x=c?i:i.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${o("widget-border")}`,borderRadius:"4px",padding:"10px",background:o("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:g}),t.jsx("span",{children:n})]}),i.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[x.map(m=>t.jsxs("div",{onClick:()=>r(m),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:o("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:Os(m.type)}),t.jsx("span",{children:m.title})]},m.id)),i.length>5&&!c&&t.jsxs("div",{onClick:()=>d(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:o("link-fg"),cursor:"pointer"},children:[p," (",i.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:o("bg"),borderRadius:"4px",color:o("desc-fg"),fontSize:"12px",textAlign:"center"},children:a}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(ii,{onClick:s,primary:!0,children:["+ ",l]})})]})},Uo=({onClick:e,title:n,danger:i,children:r})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:i?o("danger"):"inherit",opacity:.7},children:r}),ii=({onClick:e,primary:n,children:i})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${o("widget-border")}`,borderRadius:"4px",background:n?o("primary"):"transparent",color:n?o("primary-fg"):"inherit",cursor:"pointer"},children:i});function Os(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const jp={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:o("primary"),color:o("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Ds=({isOpen:e,entityType:n,title:i,onSelect:r,onCancel:s,onCreate:l,searchResults:a,onSearch:p,isLoading:c,excludeId:d})=>{const[u,g]=f.useState(""),x=d?a.filter(h=>h.id!==d):a;f.useEffect(()=>{e&&(g(""),p(""))},[e]);const m=h=>{g(h),p(h)};if(!e)return null;const b=n==="work"?"作品":n==="book"?"书籍":"丛编",k=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:vp,children:t.jsxs("div",{style:kp,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${o("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:i}),t.jsx("button",{onClick:s,style:Sp,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:u,onChange:h=>m(h.target.value),placeholder:`搜索${b}名称或 ID...`,autoFocus:!0,style:wp})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:An,children:"搜索中..."}):x.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:x.map(h=>t.jsxs("div",{onClick:()=>r(h),style:_p,children:[t.jsx("span",{style:{fontSize:"16px"},children:k}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[h.title,h.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:h.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[h.id,h.author&&` · ${h.author}`,h.dynasty&&` · ${h.dynasty}`]})]})]},h.id))}):u?t.jsxs("div",{style:An,children:["未找到匹配的",b]}):t.jsxs("div",{style:An,children:["输入关键词搜索",b]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${o("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:l,style:$p,children:["创建新",b,"并关联"]})]})]})})},vp={position:"fixed",top:0,left:0,right:0,bottom:0,background:o("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},kp={background:o("bg"),border:`1px solid ${o("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:o("shadow-dialog")},Sp={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},wp={width:"100%",padding:"10px 12px",border:`1px solid ${o("input-border")}`,borderRadius:"4px",background:o("input-bg"),color:o("input-fg"),fontSize:"13px",boxSizing:"border-box"},_p={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:o("primary-soft")},An={padding:"20px",textAlign:"center",color:o("desc-fg")},$p={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:o("primary"),color:o("primary-fg"),cursor:"pointer"},Vo={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},zp={work:"📜",book:"📖",collection:"📚",entity:"👤"},Hs=({isOpen:e,entityType:n,relationField:i,inheritData:r,onConfirm:s,onCancel:l})=>{const[a,p]=f.useState(""),c=f.useRef(null);f.useEffect(()=>{e&&(p((r==null?void 0:r.title)||""),setTimeout(()=>{var x,m;(x=c.current)==null||x.focus(),(m=c.current)==null||m.select()},100))},[e,r==null?void 0:r.title]);const d=x=>{x.key==="Enter"&&a.trim()?u():x.key==="Escape"&&l()},u=()=>{a.trim()&&s(a.trim(),{...r,title:a.trim()})};if(!e)return null;const g=()=>{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`创建新${Vo[n]}`}};return t.jsx("div",{style:Cp,onClick:x=>{x.target===x.currentTarget&&l()},children:t.jsxs("div",{style:Ip,onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:zp[n]}),t.jsx("span",{children:g()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:o("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:o("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:a,onChange:x=>p(x.target.value),onKeyDown:d,placeholder:`请输入${Vo[n]}名称...`,style:Tp})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:o("desc-fg"),background:o("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&t.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:l,style:Ep,children:"取消"}),t.jsx("button",{onClick:u,disabled:!a.trim(),style:{...Rp,opacity:a.trim()?1:.6,cursor:a.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Cp={position:"fixed",top:0,left:0,right:0,bottom:0,background:o("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ip={background:o("bg"),border:`1px solid ${o("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:o("shadow-dialog")},Tp={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${o("input-border")}`,borderRadius:"4px",background:o("input-bg"),color:o("input-fg"),outline:"none",boxSizing:"border-box"},Ep={padding:"8px 16px",fontSize:"13px",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:"transparent",color:o("fg"),cursor:"pointer"},Rp={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:o("primary"),color:o("primary-fg")};function Np(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Gs(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Lp(e){switch(e){case"work":return o("editor-type-work");case"collection":return o("editor-type-collection");case"book":return o("editor-type-book");default:return o("desc-fg")}}const Us=({isOpen:e,title:n,filterType:i="all",recentEntities:r=[],excludeId:s,showCreateButton:l=!1,createButtonText:a,onSelect:p,onCancel:c,onCreate:d,onSearch:u})=>{const[g,x]=f.useState(""),[m,b]=f.useState([]),[k,h]=f.useState(!1),[y,j]=f.useState("recent");f.useEffect(()=>{e&&(x(""),b([]),j(r.length>0?"recent":"search"))},[e,r.length]),f.useEffect(()=>{if(!g.trim()){b([]);return}const C=setTimeout(async()=>{h(!0);try{b(await u(g,i))}catch{b([])}finally{h(!1)}},300);return()=>clearTimeout(C)},[g,i,u]);const v=f.useCallback(C=>{x(C.target.value),C.target.value.trim()&&j("search")},[]),_=f.useCallback(C=>s?C.filter(N=>N.id!==s):C,[s]);if(!e)return null;const S=n||(i==="all"?"选择实体":`选择${Gs(i)}`),$=_(r),w=_(m);return t.jsx("div",{style:Ap,children:t.jsxs("div",{style:Wp,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${o("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:S}),t.jsx("button",{onClick:c,style:Mp,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:g,onChange:v,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Fp}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),k&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),$.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${o("widget-border")}`},children:[t.jsxs(Yo,{active:y==="recent",onClick:()=>j("recent"),children:["最近使用 (",$.length,")"]}),t.jsxs(Yo,{active:y==="search",onClick:()=>j("search"),children:["搜索结果 ",w.length>0&&`(${w.length})`]})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:y==="recent"&&$.length>0?t.jsx(Ko,{entities:$,onSelect:p}):g.trim()?k?t.jsx(Wn,{message:"搜索中..."}):w.length>0?t.jsx(Ko,{entities:w,onSelect:p}):t.jsx(Wn,{message:"未找到匹配的结果"}):t.jsx(Wn,{message:"输入关键词开始搜索"})}),l&&d&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${o("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:d,style:Pp,children:a||"创建新实体"})]})]})})},Yo=({active:e,onClick:n,children:i})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${o("primary")}`:"2px solid transparent",background:"transparent",color:o(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:i}),Ko=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(i=>t.jsx(Bp,{entity:i,onClick:()=>n(i)},i.id))}),Bp=({entity:e,onClick:n})=>{const[i,r]=f.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:o("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Np(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:o("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:o("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:Lp(e.type),color:o("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Gs(e.type)})]})},Wn=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:o("desc-fg"),fontSize:"13px"},children:e}),Ap={position:"fixed",top:0,left:0,right:0,bottom:0,background:o("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Wp={background:o("bg"),border:`1px solid ${o("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:o("shadow-dialog")},Mp={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Fp={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${o("input-border")}`,borderRadius:"6px",background:o("input-bg"),color:o("input-fg"),fontSize:"13px",boxSizing:"border-box"},Pp={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:o("primary"),color:o("primary-fg"),cursor:"pointer"},Op={work:o("editor-type-work"),collection:o("editor-type-collection"),book:o("editor-type-book"),entity:o("editor-type-entity")},Dp={work:"📜",collection:"📚",book:"📖",entity:"👤"},Vs=({data:e,onChange:n,onSave:i,transport:r,onNavigate:s,showDelete:l,onDelete:a,onAskAI:p,renderSectionActions:c,onDownloadResource:d,downloadStatuses:u,relations:g,onRelationsChange:x})=>{var q;const m=de(),[b,k]=f.useState(!1),[h,y]=f.useState("work"),[j,v]=f.useState(""),[_,S]=f.useState(""),[$,w]=f.useState([]),[C,N]=f.useState(!1),[E,I]=f.useState(!1),[O,A]=f.useState("work"),[M,F]=f.useState(""),[Y,K]=f.useState(),[R,oe]=f.useState(!1),[H,re]=f.useState(null),[ee,Q]=f.useState([]);f.useRef(null);const J=e.type,ce=J==="work",me=J==="collection",te=J==="book",ie=f.useCallback((P,T)=>{n({...e,[P]:T})},[e,n]),pe=f.useCallback((P,T)=>{v(P),y(T),S(m.editor.selectToLink+m.indexType[T]),w([]),k(!0)},[m]),ge=f.useCallback(P=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(e.id,P)},[r,e.id]),Ce=f.useCallback(P=>{s==null||s(P.id,P.type)},[s]),ve=f.useCallback((P,T,z)=>{const L={...z,author:(z==null?void 0:z.author)||e.author,dynasty:z==null?void 0:z.dynasty};A(T),F(P),K(L),I(!0)},[e.author]),we=f.useCallback((P,T)=>{r!=null&&r.createAndLink&&r.createAndLink(e.id,M,{type:O,title:P,inheritData:T}),I(!1)},[r,e.id,M,O]),Ee=f.useCallback(P=>{if(!P.trim()){w([]);return}N(!0),r!=null&&r.searchEntities&&r.searchEntities(P,h).then(T=>{w(T),N(!1)}).catch(()=>{w([]),N(!1)})},[r,h]),Re=f.useCallback(P=>{r!=null&&r.linkEntity&&r.linkEntity(e.id,j,P.id),k(!1)},[r,e.id,j]),D=f.useCallback(()=>{i()},[i]),se=f.useCallback(P=>{re(()=>P),oe(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(Q).catch(()=>{})},[r]),ne=f.useCallback((P,T)=>r!=null&&r.searchEntities?r.searchEntities(P,T==="all"?void 0:T):Promise.resolve([]),[r]),he=f.useCallback(P=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(P),Q(T=>[P,...T.filter(z=>z.id!==P.id)].slice(0,10)),H==null||H(P),oe(!1),re(null)},[r,H]);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 ${o("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:Dp[J]}),t.jsx("span",{children:e.title||m.editor.untitled}),t.jsx(mn,{children:e.id}),t.jsx(mn,{color:Op[J],children:m.indexType[J]})]})}),t.jsx(Ye,{title:m.section.basicInfo,onSave:i,onAskAI:p?()=>p("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[t.jsx(pn,{label:ce?m.editor.workTitle:me?m.editor.collectionTitle:m.editor.bookTitle,value:e.title,onChange:P=>ie("title",P)}),te&&t.jsx(pn,{label:m.editor.belongsToWork,value:e.workName||"",onChange:P=>ie("workName",P)}),t.jsx(Ge,{label:m.editor.authorLabel,value:e.author||"",onChange:P=>ie("author",P)}),t.jsx(Ge,{label:m.editor.publicationYearLabel,value:e.publicationYear||"",onChange:P=>ie("publicationYear",P)}),(te||me)&&t.jsx(pn,{label:m.editor.containedIn,value:e.collection||"",onChange:P=>ie("collection",P)}),(te||me)&&t.jsx(Ge,{label:m.editor.holderLabel,value:e.holder||"",onChange:P=>ie("holder",P)}),(te||me)&&t.jsx(Ge,{label:te?m.editor.pageLabel:m.editor.volumeLabel,value:e.pages||"",onChange:P=>ie("pages",P)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(Ge,{label:m.editor.firstImageLabel,value:e.firstImage||"",onChange:P=>ie("firstImage",P)})})]})}),t.jsx(Ye,{title:m.section.description,onSave:i,onAskAI:p?()=>p("介绍"):void 0,children:t.jsx(bt,{value:e.description||"",onChange:P=>ie("description",P),placeholder:m.editor.descriptionPlaceholder})}),(((q=e.additional_works)==null?void 0:q.length)||0)>0&&t.jsx(Ye,{title:m.section.additionalWorks,onSave:i,children:t.jsx(Hp,{items:e.additional_works||[],onChange:P=>ie("additional_works",P)})}),t.jsx(Ye,{title:m.section.indexedBy,onSave:i,onAskAI:p?()=>p("收录于"):void 0,children:t.jsx(Gp,{items:e.indexed_by||[],onChange:P=>ie("indexed_by",P)})}),t.jsx(Ye,{title:m.section.emendatedBy,onSave:i,onAskAI:p?()=>p("考证"):void 0,children:t.jsx(Up,{items:e.emendated_by||[],onChange:P=>ie("emendated_by",P)})}),t.jsx(Ye,{title:m.section.textResources,onSave:i,onAskAI:p?()=>p("资源"):void 0,children:t.jsx(Gn,{items:e.resources||[],onChange:P=>ie("resources",P),onDownload:d,downloadStatuses:u,filterType:"text"})}),t.jsx(Ye,{title:m.section.imageResources,onSave:i,children:t.jsx(Gn,{items:e.resources||[],onChange:P=>ie("resources",P),onDownload:d,downloadStatuses:u,filterType:"image"})}),t.jsx(Ye,{title:m.section.sources,onSave:i,onAskAI:p?()=>p("资料来源"):void 0,children:t.jsx(Ws,{items:Ms(e.sources||""),onChange:P=>ie("sources",Fs(P)),onOpenEntityPicker:se})}),(te||me)&&t.jsx(Ye,{title:m.section.provenance,onSave:i,onAskAI:p?()=>p("收藏历史"):void 0,children:t.jsx(bt,{value:e.provenance||"",onChange:P=>ie("provenance",P),placeholder:m.editor.provenancePlaceholder})}),te&&t.jsx(Ye,{title:m.section.otherEditions,onSave:i,onAskAI:p?()=>p("其他版本"):void 0,children:t.jsx(bt,{value:e.otherEditions||"",onChange:P=>ie("otherEditions",P),placeholder:m.editor.otherEditionsPlaceholder})}),t.jsx(Ps,{entityType:J,entityId:e.id,entityTitle:e.title,parentWork:g==null?void 0:g.parentWork,parentCollection:g==null?void 0:g.parentCollection,belongsToWork:g==null?void 0:g.belongsToWork,belongsToCollection:g==null?void 0:g.belongsToCollection,childWorks:g==null?void 0:g.childWorks,childCollections:g==null?void 0:g.childCollections,containedBooks:g==null?void 0:g.containedBooks,siblingBooks:g==null?void 0:g.siblingBooks,onLinkEntity:pe,onUnlinkEntity:ge,onViewEntity:Ce,onCreateAndLink:ve,onSaveRelations:D}),l&&a&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${o("danger-soft-border")}`,background:o("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:o("danger"),fontWeight:600,marginBottom:"8px"},children:m.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:o("desc-fg"),marginBottom:"12px"},children:m.editor.dangerZoneDesc}),t.jsx("button",{onClick:a,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${o("danger")}`,borderRadius:"4px",background:"transparent",color:o("danger"),cursor:"pointer"},children:m.editor.deleteEntity})]}),t.jsx(Ds,{isOpen:b,entityType:h,title:_,onSelect:Re,onCancel:()=>k(!1),onCreate:()=>{k(!1),ve(j,h)},searchResults:$,onSearch:Ee,isLoading:C,excludeId:e.id}),t.jsx(Hs,{isOpen:E,entityType:O,relationField:M,inheritData:Y,onConfirm:we,onCancel:()=>I(!1)}),t.jsx(Us,{isOpen:R,title:m.action.selectBookOrWork,filterType:"all",recentEntities:ee,excludeId:e.id,onSelect:he,onCancel:()=>{oe(!1),re(null)},onSearch:ne})]})};function Hp({items:e,onChange:n}){const i=de(),r=(a,p,c)=>{const d=e.map((u,g)=>g===a?{...u,[p]:c}:u);n(d)},s=a=>n(e.filter((p,c)=>c!==a)),l=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((a,p)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(Ge,{label:i.editor.bookNameLabel,value:a.book_title,onChange:c=>r(p,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(Ge,{label:i.label.juanCount,value:a.n_juan!=null?String(a.n_juan):"",onChange:c=>r(p,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(p),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:o("muted"),marginTop:"18px"},children:"✕"})]},p)),t.jsx("button",{onClick:l,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${o("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:o("desc-fg"),alignSelf:"flex-start"},children:i.action.addAdditionalWork})]})}function Ys({items:e,onChange:n,showMeta:i,addLabel:r}){const s=de(),[l,a]=f.useState(null),p=(u,g,x)=>{const m=e.map((b,k)=>k===u?{...b,[g]:x||void 0}:b);n(m)},c=u=>{n(e.filter((g,x)=>x!==u)),l===u&&a(null)},d=()=>{n([...e,{source:""}]),a(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,g)=>{const x=l===g;return t.jsxs("div",{style:{border:`1px solid ${o("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:x?`color-mix(in srgb, ${o("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>a(x?null:g),children:[t.jsx("span",{style:{fontSize:"10px",color:o("desc-fg"),transition:"transform 0.2s",transform:x?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:o("desc-fg")},children:u.source_bid}),t.jsx("button",{onClick:m=>{m.stopPropagation(),c(g)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${o("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:o("muted")},children:"✕"})]}),!x&&i&&(u.title_info||u.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:o("desc-fg")},children:[u.title_info,u.title_info&&u.author_info&&" — ",u.author_info]}),x&&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(Ge,{label:s.label.sourceName,value:u.source,onChange:m=>p(g,"source",m)}),t.jsx(Ge,{label:s.label.sourceBid,value:u.source_bid||"",onChange:m=>p(g,"source_bid",m)})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(Ge,{label:s.label.titleInfo,value:u.title_info||"",onChange:m=>p(g,"title_info",m)}),t.jsx(Ge,{label:s.label.authorInfo,value:u.author_info||"",onChange:m=>p(g,"author_info",m)})]}),t.jsx(Ge,{label:s.label.edition,value:u.edition||"",onChange:m=>p(g,"edition",m)})]}),t.jsx(bt,{value:u.summary||"",onChange:m=>p(g,"summary",m),placeholder:s.editor.summaryPlaceholder}),t.jsx(bt,{value:u.comment||"",onChange:m=>p(g,"comment",m),placeholder:s.editor.commentPlaceholder}),t.jsx(bt,{value:u.additional_comment||"",onChange:m=>p(g,"additional_comment",m),placeholder:s.editor.additionalCommentPlaceholder})]})]},g)}),t.jsx("button",{onClick:d,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${o("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:o("desc-fg"),alignSelf:"flex-start"},children:r})]})}function Gp({items:e,onChange:n}){const i=de();return t.jsx(Ys,{items:e,onChange:n,showMeta:!0,addLabel:i.action.addIndexedBy})}function Up({items:e,onChange:n}){const i=de();return t.jsx(Ys,{items:e,onChange:n,addLabel:i.action.addEmendatedBy})}function Ks(e){var p,c,d,u,g,x,m;const n=((c=(p=e.authors)==null?void 0:p[0])==null?void 0:c.name)||"",i=((d=e.publication_info)==null?void 0:d.year)||"",r=((u=e.current_location)==null?void 0:u.name)||"",s=(g=e.page_count)!=null&&g.number?String(e.page_count.number):((x=e.page_count)==null?void 0:x.description)||"",l=typeof e.description=="object"&&e.description!==null&&e.description.text||"",a={id:e.id,title:e.title,type:e.type,author:n,publicationYear:i,holder:r,pages:s,description:l,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const b=e;if(Array.isArray(b.related_works)){const k=b.related_works.find(h=>h.relation==="part_of");k&&(a.parentWorkId=k.id,a.parentWorkName=k.title)}}if(e.type==="book"){const b=e;a.workId=b.work_id,Array.isArray(b.contained_in)&&b.contained_in.length>0&&(a.collectionId=(m=b.contained_in[0])==null?void 0:m.id)}return a}function Vp(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 Yp=e=>{const{data:n,id:i,transport:r,mode:s="view",onModeChange:l,onChange:a,onSave:p,onDelete:c,onNavigate:d,renderLink:u,onAskAI:g,renderSectionActions:x,onDownloadResource:m,downloadStatuses:b,relations:k,onRelationsChange:h,headerExtra:y,className:j,style:v}=e;de();const[_,S]=f.useState(s),$=l?s:_;f.useEffect(()=>{s!==_&&S(s)},[s]);const w=f.useCallback(()=>{const M=$==="view"?"edit":"view";l?l(M):S(M)},[$,l]),[C,N]=f.useState(null);f.useEffect(()=>{i&&r&&r.getItem(i).then(M=>{M&&N(M)})},[i,r]);const E=n||C,I=f.useMemo(()=>E?Ks(E):null,[E]),O=l||!n?t.jsx("button",{onClick:w,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${o("widget-border")}`,borderRadius:"4px",background:$==="edit"?o("accent-bg"):"transparent",color:o($==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:$==="view"?"切换到编辑模式":"切换到查看模式",children:$==="view"?"✏️ 编辑":"👁 查看"}):null,A=t.jsxs(t.Fragment,{children:[O,y]});return!E&&!I?t.jsx(jt,{}):$==="view"?t.jsx(fi,{data:E,transport:r,onNavigate:d?M=>d(M):void 0,renderLink:u,headerExtra:A,className:j,style:v}):I?t.jsxs("div",{className:j,style:v,children:[A&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:A}),t.jsx(Vs,{data:I,onChange:a||(()=>{}),onSave:p||(()=>{}),transport:r,onNavigate:d,showDelete:!!c,onDelete:c,onAskAI:g,renderSectionActions:x,onDownloadResource:m,downloadStatuses:b,relations:k,onRelationsChange:h})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:o("muted")},children:"无数据"})},qo=[{value:"bug",label:"反馈错误",icon:"🐛",placeholder:"请描述您发现的错误,包括页面位置和具体内容"},{value:"resource",label:"添加资源",icon:"📚",placeholder:"请提供完整资源链接和简要版本说明"},{value:"suggestion",label:"功能建议",icon:"💡",placeholder:"您希望网站增加或改进什么?"},{value:"contact",label:"想参与",icon:"🤝",placeholder:"想参与整理、校对或合作?简单介绍一下您自己,并留下联系方式(此类留言不公开)"}],qs=({isOpen:e,onClose:n,onSubmit:i,feedbackListUrl:r})=>{const[s,l]=f.useState(null),[a,p]=f.useState(""),[c,d]=f.useState(""),[u,g]=f.useState("idle"),[x,m]=f.useState(""),b=f.useRef(null);f.useEffect(()=>{e&&(l(null),p(""),d(""),g("idle"),m(""))},[e]),f.useEffect(()=>{s&&setTimeout(()=>{var j;return(j=b.current)==null?void 0:j.focus()},100)},[s]),f.useEffect(()=>{if(u==="success"){const j=setTimeout(n,2e3);return()=>clearTimeout(j)}},[u,n]),f.useEffect(()=>{if(!e)return;const j=v=>{v.key==="Escape"&&n()};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[e,n]);const k=async()=>{if(!(!s||!a.trim())){g("submitting"),m("");try{await i({type:s,content:a.trim(),...c.trim()?{contact:c.trim()}:{}}),g("success")}catch(j){g("error"),m(j instanceof Error?j.message:"提交失败,请稍后重试")}}};if(!e)return null;const h=s&&a.trim()&&u!=="submitting",y=qo.find(j=>j.value===s);return t.jsx("div",{style:Kp,onClick:j=>{j.target===j.currentTarget&&n()},children:t.jsxs("div",{style:qp,onClick:j=>j.stopPropagation(),children:[t.jsxs("div",{style:Jp,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:"反馈"}),t.jsx("button",{onClick:n,style:Zp,"aria-label":"关闭",children:"✕"})]}),u==="success"?t.jsxs("div",{style:nu,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:"感谢您的反馈!"}),r&&t.jsx("a",{href:r,style:{fontSize:"13px",color:o("primary"),marginTop:"8px"},children:"查看反馈列表 →"})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:qo.map(j=>t.jsxs("button",{onClick:()=>l(j.value),style:{...Xp,...s===j.value?Qp:{}},children:[t.jsx("span",{children:j.icon})," ",j.label]},j.value))}),t.jsx("textarea",{ref:b,value:a,onChange:j=>p(j.target.value),placeholder:(y==null?void 0:y.placeholder)||"请先选择反馈类型",maxLength:2e3,disabled:!s||u==="submitting",style:{...eu,opacity:s?1:.6}}),t.jsx("input",{type:"text",value:c,onChange:j=>d(j.target.value),placeholder:"邮箱(选填,仅站方可见,方便我们回复您)",maxLength:200,disabled:!s||u==="submitting","aria-label":"联系方式(选填)",style:ou}),t.jsxs("div",{style:{fontSize:"12px",color:o("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[a.length," / 2000"]}),u==="error"&&t.jsx("div",{style:iu,children:x}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:k,disabled:!h,style:{...tu,opacity:h?1:.6,cursor:h?"pointer":"not-allowed"},children:u==="submitting"?"提交中...":"提交反馈"})})]})]})})},Kp={position:"fixed",top:0,left:0,right:0,bottom:0,background:o("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},qp={background:o("bg"),border:`1px solid ${o("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:o("shadow-dialog")},Jp={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Zp={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:o("desc-fg"),padding:"4px 8px",borderRadius:"4px"},Xp={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${o("widget-border")}`,borderRadius:"6px",background:o("input-bg"),color:o("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Qp={borderColor:o("primary"),background:o("list-active-bg"),color:o("primary"),fontWeight:500},eu={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${o("input-border")}`,borderRadius:"6px",background:o("input-bg"),color:o("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},tu={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:o("primary"),color:o("primary-fg"),fontWeight:500},nu={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:o("success")},iu={fontSize:"13px",color:o("danger"),padding:"8px 12px",background:o("danger-bg"),borderRadius:"4px",marginBottom:"12px"},ou={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${o("input-border")}`,borderRadius:"6px",background:o("bg"),color:o("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},oi="--bim-feedback-fab-offset",ri=48,ru=16,su=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:i,hidden:r=!1,zIndex:s})=>{const[l,a]=f.useState(!1),p=n.bottom??24;return f.useEffect(()=>{if(r||typeof document>"u")return;const c=document.documentElement;return c.style.setProperty(oi,`calc(${p+ri+ru}px + env(safe-area-inset-bottom, 0px))`),()=>{c.style.removeProperty(oi)}},[r,p]),t.jsxs(t.Fragment,{children:[!r&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>a(!0),style:{...lu,zIndex:s??o("feedback-fab-z"),bottom:`calc(${p}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":"反馈",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(qs,{isOpen:l,onClose:()=>a(!1),onSubmit:e,feedbackListUrl:i})]})},lu={position:"fixed",width:`${ri}px`,height:`${ri}px`,borderRadius:"50%",border:"none",background:o("primary"),color:o("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:o("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},Jo=[{value:"bug",label:"反馈错误",icon:"🐛",placeholder:"请描述您发现的错误,包括页面位置和具体内容"},{value:"resource",label:"添加资源",icon:"📚",placeholder:"请提供完整资源链接和简要版本说明"},{value:"suggestion",label:"功能建议",icon:"💡",placeholder:"您希望网站增加或改进什么?"},{value:"contact",label:"想参与",icon:"🤝",placeholder:"想参与整理、校对或合作?简单介绍一下您自己,并留下联系方式(此类留言不公开)"}],Js=({onSubmit:e})=>{const[n,i]=f.useState("bug"),[r,s]=f.useState(""),[l,a]=f.useState(""),[p,c]=f.useState("idle"),[d,u]=f.useState(""),g=f.useRef(null);f.useEffect(()=>{n&&setTimeout(()=>{var k;return(k=g.current)==null?void 0:k.focus()},100)},[n]);const x=async()=>{if(!(!n||!r.trim())){c("submitting"),u("");try{await e({type:n,content:r.trim(),...l.trim()?{contact:l.trim()}:{}}),c("success"),s(""),a(""),i("bug")}catch(k){c("error"),u(k instanceof Error?k.message:"提交失败,请稍后重试")}}},m=n&&r.trim()&&p!=="submitting",b=Jo.find(k=>k.value===n);return p==="success"?t.jsx("div",{style:Zo,children:t.jsxs("div",{style:uu,children:[t.jsx("span",{children:"✓ 感谢您的反馈!"}),t.jsx("button",{onClick:()=>c("idle"),style:xu,children:"继续提交"})]})}):t.jsxs("div",{style:Zo,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Jo.map(k=>t.jsxs("button",{onClick:()=>i(k.value),style:{...au,...n===k.value?cu:{}},children:[t.jsx("span",{children:k.icon})," ",k.label]},k.value))}),t.jsx("textarea",{ref:g,value:r,onChange:k=>s(k.target.value),placeholder:(b==null?void 0:b.placeholder)||"请先选择反馈类型",maxLength:2e3,disabled:p==="submitting",style:{...du}}),t.jsx("input",{type:"text",value:l,onChange:k=>a(k.target.value),placeholder:"邮箱(选填,仅站方可见,方便我们回复您)",maxLength:200,disabled:p==="submitting","aria-label":"联系方式(选填)",style:gu}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:o("desc-fg")},children:[r.length," / 2000"]}),t.jsx("button",{onClick:x,disabled:!m,style:{...pu,opacity:m?1:.6,cursor:m?"pointer":"not-allowed"},children:p==="submitting"?"提交中...":"提交"})]}),p==="error"&&t.jsx("div",{style:fu,children:d})]})},Zo={padding:"16px",border:`1px solid ${o("widget-border")}`,borderRadius:"8px",background:o("input-bg")},au={padding:"8px 16px",fontSize:"13px",border:`1px solid ${o("widget-border")}`,borderRadius:"6px",background:"transparent",color:o("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},cu={borderColor:o("primary"),background:o("list-active-bg"),color:o("primary"),fontWeight:500},du={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${o("input-border")}`,borderRadius:"6px",background:o("bg"),color:o("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},pu={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:o("primary"),color:o("primary-fg"),fontWeight:500},uu={display:"flex",alignItems:"center",gap:"12px",color:o("success"),fontSize:"14px"},xu={background:"none",border:"none",color:o("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},fu={fontSize:"13px",color:o("danger"),padding:"8px 12px",background:o("danger-bg"),borderRadius:"4px",marginTop:"8px"},gu={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${o("input-border")}`,borderRadius:"6px",background:o("bg"),color:o("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Xo(e){return typeof e=="function"?e():e??"/api/feedback"}const Zs=({resourceId:e,apiUrl:n})=>{const[i,r]=f.useState([]),[s,l]=f.useState(!0),a=f.useCallback(async()=>{const c=Xo(n);l(!0);try{const u=await(await fetch(`${c}?resourceId=${encodeURIComponent(e)}`)).json();u.success&&r(u.items)}catch{}finally{l(!1)}},[e,n]);f.useEffect(()=>{a()},[a]);const p=async c=>{const d=Xo(n),u=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...c,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!u.ok){const g=await u.json().catch(()=>null);throw new Error((g==null?void 0:g.error)||"提交失败")}setTimeout(()=>a(),500)};return t.jsxs("div",{children:[t.jsx(Pi,{items:i,loading:s}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Js,{onSubmit:p})})]})},Qo={part_of:"所屬",has_part:"包含",contains_text_of:"收錄",collected_in:"叢編",text_carried_by:"載錄",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"後繼",derived_from:"衍生",has_adaptation:"改編",related:"相關"};function er(e){return e?Qo[e]??e:Qo.related}const mu={extant:"今存",fragment:"殘存",partial:"殘存",lost:"已佚",unknown:"未詳"};function hu(e){return mu[e]??e}const bu={text:"全文",image:"影印",textImage:"圖文",physical:"館藏"};function yu(e){return bu[e]??""}function Oi({authors:e,onNavigate:n,renderLink:i}){const{convert:r}=V(),s=(e||[]).filter(l=>l&&l.name);return s.length?t.jsx(t.Fragment,{children:s.map((l,a)=>{const p=ji(l.role);return t.jsxs(f.Fragment,{children:[a>0&&" ",l.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(l.dynasty),"〕"]}),l.entity_id?t.jsx(Le,{id:l.entity_id,label:r(l.name),onNavigate:n,renderLink:i,dense:!0}):r(l.name),p&&t.jsx("span",{style:{marginLeft:4},children:r(p)})]},a)})}):null}function Xs(e,n){var p,c;const i=bi(e,n),r=i.mirrors.map(d=>({key:d.key,label:d.label,description:d.description,rows:d.items.filter(u=>u.group_role!=="mirror"),mirrors:d.items.filter(u=>u.group_role==="mirror")})),s=i.buckets.filter(d=>d.key==="image"||d.key==="textImage").flatMap(d=>d.items);s.length&&r.push({key:"_images",label:r.length?"其他影印":void 0,rows:s,mirrors:[]});const l=((p=i.buckets.find(d=>d.key==="physical"))==null?void 0:p.items)??[];return l.length&&r.push({key:"_physical",label:"館藏",rows:l,mirrors:[]}),{text:((c=i.buckets.find(d=>d.key==="text"))==null?void 0:c.items)??[],groups:r}}function Qs(e,n){const i=(e.url?Nt(e.url):void 0)||e.name,r=Fr(e,n);return r?`${i}(${r})`:i}function Di({item:e,siblings:n,listedVolumeCounts:i}){const{convert:r}=V(),[s,l]=f.useState(!1),a=hn(e),p=!!a&&a.expected>0&&!(i!=null&&i.has(a.expected)),c=r(Qs(e,n)),d=Lt(e),u=kn(e)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var x,m;const g=(x=e.metadata)!=null&&x.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:[((m=e.metadata)==null?void 0:m.fragment)&&t.jsx("span",{className:"bim-d-tag",children:r("殘片")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:r(e.color_mode==="color"?"彩色":"黑白")})]}):null;return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",children:[c," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),g]}):t.jsxs("span",{className:"bim-d-zt-name",children:[c,g]})})(),u&&t.jsx("span",{className:"bim-d-meta",children:r(u)}),p&&s&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(Si,{item:e})})]}),t.jsx("td",{className:p?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:p&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":s,onClick:()=>l(g=>!g),children:r(s?"收起分冊":`展開 ${a.expected} 冊`)})})]})}function el({groups:e,listedVolumeCounts:n}){const{convert:i}=V();return t.jsx(t.Fragment,{children:e.map(r=>t.jsxs("div",{className:"bim-d-rg",children:[r.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:i(r.label)}),r.description&&t.jsx("p",{className:"bim-d-rg-d",children:i(r.description)}),r.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:r.rows.map((s,l)=>t.jsx(Di,{item:s,siblings:r.rows,listedVolumeCounts:n},`${s.id||s.url||s.name}-${l}`))})}),r.mirrors.length>0&&t.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[r.rows.length>0&&t.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:i("鏡像")}),r.mirrors.map((s,l)=>{const a=Lt(s),p=i(Qs(s,r.mirrors));return a?t.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",title:s.details?i(s.details):void 0,children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]},l):t.jsx("span",{style:{marginRight:14},children:p},l)})]})]},r.key))})}const Vt=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function si(e){var i;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(i=Vt.find(r=>n.startsWith(r.key[0])))==null?void 0:i.key}const tr=12,ju=60,tl=({data:e,transport:n,onNavigate:i,renderLink:r,readAction:s,railTop:l,back:a,railLinks:p})=>{var we,Ee,Re;const c=de(),{convert:d}=V(),u=f.useMemo(()=>[...e.books||[],...e.collections||[]],[e.books,e.collections]),[g,x]=f.useState(new Map),[m,b]=f.useState(!1),[k,h]=f.useState(""),[y,j]=f.useState(!1),v=u.length<=ju,_=v||m||!!k||y,S=f.useMemo(()=>_?u:u.slice(0,tr),[u,_]);f.useEffect(()=>{if(!n||S.length===0)return;const D=S.filter(ne=>!g.has(ne));if(D.length===0)return;let se=!1;return Promise.all(D.map(ne=>n.getItem(ne).then(he=>{const q=he??{};return[ne,{id:ne,title:q.title,edition:q.edition,resources:q.resources,publication_info:q.publication_info,current_location:q.current_location,lineage:q.lineage,measure_info:q.measure_info}]}).catch(()=>[ne,{id:ne}]))).then(ne=>{se||x(he=>{const q=new Map(he);for(const[P,T]of ne)q.set(P,T);return q})}),()=>{se=!0}},[n,S,g]);const $=f.useMemo(()=>u.map(D=>g.get(D)??{id:D}),[u,g]),w=u.length>0&&u.every(D=>g.has(D)),C=!!n&&S.some(D=>!g.has(D)),N=v||_,E=f.useMemo(()=>Or($,e.version_graph,{era:k,scanOnly:y,sort:N?"year":"default"}),[$,e.version_graph,k,y,N]),I=m?E.rows:E.rows.slice(0,tr),O=E.allRows.filter(D=>D.hasImage).length,A=e.related_works||[],M=A.filter(D=>D.relation==="collected_in"),F=f.useMemo(()=>{const D=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],se=ne=>{const he=D.indexOf(ne??"");return he<0?D.length:he};return A.filter(ne=>ne.relation!=="collected_in").map((ne,he)=>({r:ne,i:he})).sort((ne,he)=>se(ne.r.relation)-se(he.r.relation)||ne.i-he.i).map(ne=>ne.r)},[A]),Y=f.useMemo(()=>{const D=bi(e.resources,e.resource_groups);return[...D.mirrors.flatMap(se=>se.items.map(ne=>({r:ne,kind:d(se.label)}))),...D.buckets.flatMap(se=>se.items.map(ne=>({r:ne,kind:d(yu(se.key))})))]},[e.resources,e.resource_groups,d]),K=e.indexed_by||[],R=e.emendated_by||[],oe=f.useMemo(()=>{var L,B,G;const D=[],se=(B=(L=e.authors)==null?void 0:L[0])==null?void 0:B.dynasty;se&&D.push({label:"成書",value:d(se)});const ne=lt(e,c.unit.juan);if(ne){const Z=(G=e.juan_count)==null?void 0:G.description;D.push({label:"卷帙",value:t.jsxs(t.Fragment,{children:[d(ne),Z&&Z!==ne?t.jsxs("span",{className:"bim-d-meta",children:["(",d(Z),")"]}):null]})})}e.loss_status&&D.push({label:"存佚",value:d(hu(e.loss_status))});const he=E.allRows.filter(Z=>Z.sortYear!=null),q=he.length>0?he.reduce((Z,ue)=>Z.sortYear<=ue.sortYear?Z:ue):null;q!=null&&q.era.era?D.push({label:"最早存世",value:d([q.era.era,q.era.reign].filter(Boolean).join(" ")),title:q.era.source==="edition"?d("據版本題名推斷"):void 0}):C&&D.push({label:"最早存世",value:t.jsx("span",{className:"bim-d-meta","aria-label":d("載入中"),children:"…"})}),R.length&&D.push({label:"考證",value:`${R.length} ${d("條")}`});const P=nr(e.additional_titles);P.length&&D.push({label:"又名",value:P.map(d).join("、")});const T=nr(e.attached_texts);T.length&&D.push({label:"附載",value:T.map(d).join("、")});const z=(e.additional_works||[]).map(Z=>d(Z.book_title)+(Z.n_juan!=null?` ${Z.n_juan}${d(c.unit.juan)}`:""));return z.length&&D.push({label:"附錄",value:z.join("、")}),D},[e,d,c,C,E.allRows,R.length]),re=[{value:e._edition_count??u.length,label:"版本"},{value:w?O:0,label:"有影印"},{value:K.length,label:"家著錄"}],ee=e.classification,Q=ee?[ee.l1,ee.l2,ee.l3,ee.l4].filter(Boolean).map(D=>d(D)):[],J=e.subtype?d(c.workSubtype[e.subtype]??e.subtype):"",ce=t.jsx(Zt,{title:d(e.title),byline:t.jsx(Oi,{authors:e.authors,onNavigate:i,renderLink:r}),meta:t.jsx(We,{items:[...Q,ee!=null&&ee.source?d(`據《${ee.source.split("/")[0]}》`):"",J]}),description:(we=e.description)!=null&&we.text?t.jsxs(t.Fragment,{children:[t.jsx(st,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(Ee=e.description.sources)!=null&&Ee.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(D=>d(rc(D))).filter(Boolean).join(" · ")}):null]}):void 0,stats:re,facts:oe,readAction:s,foot:t.jsx(Xt,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(Re=e.appendix)==null?void 0:Re.map((D,se)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:d(D.title)}),t.jsx(st,{text:D.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},se))}),me=E.eras.length>=2?[{key:"",label:c.catalog.all},...E.eras.map(D=>({key:D,label:`${D} ${E.allRows.filter(se=>se.era.era===D).length}`}))]:[],te=[];u.length&&te.push({id:"versions",label:"版本",count:u.length}),K.length&&te.push({id:"catalogs",label:"著錄",count:K.length}),M.length&&te.push({id:"collected",label:"收入叢編",count:M.length}),F.length&&te.push({id:"related",label:"相關書目",count:F.length}),Y.length&&te.push({id:"resources",label:"在線資源",count:Y.length});const ie=u.length===0&&K.length===0,pe=t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs(Me,{id:"versions",title:"版本",meta:t.jsx(We,{items:[d(`共 ${u.length} 種`),w&&O?d(`${O} 種有影印`):"",E.rows.length!==E.allRows.length?d(`當前 ${E.rows.length} 種`):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":C&&me.length===0&&u.length>1?"":void 0,children:[me.length>0&&t.jsx(wn,{items:me,value:k,onChange:D=>{h(D),b(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(Qr,{label:"只看有影印",checked:y,onChange:D=>{j(D),b(!1)}}),t.jsx("span",{className:"bim-d-meta",children:d(N?"按年代排列":"按著錄順序")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver",children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:d("版本")}),t.jsx("th",{children:d("年代")}),t.jsx("th",{children:d("館藏")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:d("影印")})})]})}),t.jsx("tbody",{children:I.map(D=>{var se;return t.jsx(vu,{row:D,measure:(se=g.get(D.id))==null?void 0:se.measure_info,loaded:g.has(D.id),onNavigate:i,renderLink:r},`${D.id}:${g.has(D.id)?"r":"p"}`)})})]}),I.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:d(k||y?"當前篩選下沒有版本":"暫無版本著錄")}),E.rows.length>I.length&&t.jsx(Bt,{label:`展開其餘 ${E.rows.length-I.length} 種版本`,onClick:()=>b(!0)}),E.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:d("部分年代據版本題名推斷,非著錄原文")})]}),K.length>0&&t.jsx(ku,{items:K,transport:n,onNavigate:i,renderLink:r}),ie&&t.jsx(Me,{title:"版本",children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:d("尚未著錄該作品的版本與書目收錄。")})})]}),ge=(D,se)=>t.jsx(Le,{id:D,label:d(se),onNavigate:i,renderLink:r,dense:!0}),Ce=f.useMemo(()=>{const D=new Map;for(const se of F){const ne=er(se.relation);D.set(ne,(D.get(ne)??0)+1)}return D.size>1?[...D.entries()].sort((se,ne)=>ne[1]-se[1]).slice(0,4).map(([se,ne])=>`${d(se)} ${ne}`).join(" · "):void 0},[F,d]),ve=t.jsxs(t.Fragment,{children:[t.jsx(ht,{id:"collected",title:"收入叢編",items:M.map(D=>ge(D.id,D.title))}),t.jsx(ht,{id:"related",title:"相關書目",meta:d(`${F.length} 部`),sub:Ce,items:F.map(D=>t.jsxs(t.Fragment,{children:[ge(D.id,D.title),t.jsx("span",{className:"bim-d-meta",title:D.note?d(D.note):void 0,children:d(er(D.relation))})]}))}),t.jsx(ht,{id:"resources",title:"在線資源",cap:6,items:Y.map(({r:D,kind:se})=>{const ne=d((D.url?Nt(D.url):void 0)||D.name),he=Lt(D);return t.jsxs(t.Fragment,{children:[he?t.jsxs("a",{href:he,target:"_blank",rel:"noopener noreferrer",children:[ne," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:ne}),se&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:se})]})})})]});return t.jsx(Jt,{railTop:l,back:a,nav:te,railLinks:p,main:pe,card:ce,side:ve})};function nr(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function ir(e,n){return n((e.url?Nt(e.url):void 0)||e.name)}function vu({row:e,measure:n,loaded:i,onNavigate:r,renderLink:s}){const{convert:l}=V(),a=[e.era.era,e.era.reign].filter(Boolean).join(" "),p=e.era.source==="edition",c=e.holders[0],d=c?ir(c,l):e.locationName?l(e.locationName):"",u=e.images[0],g=u?Lt(u):void 0,x=e.images.map(m=>ir(m,l)).join("、");return t.jsxs("tr",{"data-loading":i?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Le,{id:e.id,label:l(e.name),onNavigate:r,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${a?"":" bim-d-zt-blank"}`,title:p?l("據版本題名推斷"):void 0,children:a?l(a):i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${d?"":" bim-d-zt-blank"}`,children:[d||(i?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(g?t.jsx("a",{className:"bim-d-flag",href:g,target:"_blank",rel:"noopener noreferrer",title:x,children:l("有影印")}):t.jsx("span",{className:"bim-d-flag",title:x,children:l("有影印")}))})]})}function ku({items:e,transport:n,onNavigate:i,renderLink:r}){const s=de(),{convert:l}=V(),[a,p]=f.useState(0),c=Math.min(a,e.length-1),d=e[c],[u,g]=f.useState(new Map);return f.useEffect(()=>{if(!n)return;const x=[...new Set(e.map(b=>b.source_bid).filter(b=>!!b))];if(x.length===0)return;let m=!1;return Promise.all(x.map(b=>n.getItem(b).then(k=>{var h,y;return[b,((y=(h=k==null?void 0:k.authors)==null?void 0:h[0])==null?void 0:y.dynasty)??""]}).catch(()=>[b,""]))).then(b=>{m||g(new Map(b.filter(([,k])=>k)))}),()=>{m=!0}},[n,e]),t.jsx(Me,{id:"catalogs",title:"著錄",meta:t.jsx(We,{items:[l(`歷代書目 ${e.length} 家`),l("按著錄順序")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":l("著錄書目"),children:e.map((x,m)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":m===c,"aria-label":l(x.source),onClick:()=>p(m),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(x.source_bid??"")?l(u.get(x.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:[...l(x.source)].slice(0,9).map((b,k)=>t.jsx("span",{children:b},k))})]})},m))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[d.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:l(d.title_info)}),t.jsx(We,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[d.source_bid?t.jsx(Le,{id:d.source_bid,label:l(d.source),onNavigate:i,renderLink:r,dense:!0}):l(d.source),d.section?l(d.section):"",d.author_info?`${l(s.label.authorInfo)} ${l(d.author_info)}`:"",d.edition?`${l(s.label.edition)} ${l(d.edition)}`:"",d.page??""]}),d.summary&&t.jsx("p",{className:"bim-d-quote",children:Ue(l(d.summary))}),d.comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:l(s.section.comment)}),t.jsx("p",{className:"bim-d-quote",children:Ue(l(d.comment))})]}),d.additional_comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:l(s.section.additionalComment)}),t.jsx("p",{className:"bim-d-quote",children:Ue(l(d.additional_comment))})]}),!d.summary&&!d.comment&&!d.additional_comment&&!d.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:l("僅著錄書名,無提要。")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":l(`上一家:${e[c-1].source}`),onClick:()=>p(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",l(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":l(`下一家:${e[c+1].source}`),onClick:()=>p(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[l(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function Su(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 wu(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 or(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 _u(e,n,i){const[r,s]=[e,n.book_id].sort();return{id:`sibling:${r}-${s}:${i}`,source:r,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function $u(e,n){var d;if(n==="all")return null;const i=(d=e.collections)==null?void 0:d[n],r=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,l=r||s||!!(i!=null&&i.hypothetical_ids);if(!l&&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||!l)return null;const a=r?new Set(i.groups):null,p=new Set(i.book_ids??[]);if(a&&e.node_groups)for(const[u,g]of Object.entries(e.node_groups))a.has(g)&&p.add(u);let c=null;if(i.hypothetical_ids&&(c=new Set(i.hypothetical_ids)),a){c||(c=new Set);for(const u of e.hypothetical_nodes??[])u.group&&a.has(u.group)&&c.add(u.id)}return{books:p,hypos:c}}function un(e,n,i){const r=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const l=new Set(r.excluded_books??[]),a=r.node_groups??{},p=$u(r,i??r.default_collection??"all"),c=p!==null,d=(p==null?void 0:p.books)??null,u=(p==null?void 0:p.hypos)??null,g=new Set,x=new Set;if(c){const _=new Map(n.map(E=>[E.id,E])),S=new Map((r.hypothetical_nodes??[]).map(E=>[E.id,E])),$=E=>{const I=_.get(E);if(I&&I.lineage)return(I.lineage.derived_from??[]).map(A=>A.ref);const O=S.get(E);return O?(O.derived_from??[]).map(A=>A.ref):[]},w=E=>S.has(E)?!u||u.has(E):!d||d.has(E),C=new Set,N=E=>{if(!C.has(E)){C.add(E);for(const I of $(E))l.has(I)||(w(I)||(S.has(I)?x.add(I):_.has(I)&&g.add(I)),N(I))}};for(const E of n)d&&d.has(E.id)&&!l.has(E.id)&&N(E.id);for(const E of r.hypothetical_nodes??[])u&&u.has(E.id)&&N(E.id)}const m=n.filter(_=>!l.has(_.id)).filter(_=>!d||d.has(_.id)||g.has(_.id)).map(_=>{const S=wu(_,a);return S&&g.has(_.id)&&(S.bridge=!0),S}).filter(_=>_!==null),b=(r.hypothetical_nodes??[]).filter(_=>!u||u.has(_.id)||x.has(_.id)).map(_=>{const S=Su(_);return x.has(_.id)&&(S.bridge=!0),S}),k=[...m,...b],h=new Set(k.map(_=>_.id)),y=new Set,j=[],v=_=>{y.has(_.id)||!h.has(_.source)||!h.has(_.target)||(y.add(_.id),j.push(_))};for(const _ of n)l.has(_.id)||!_.lineage||d&&!d.has(_.id)&&!g.has(_.id)||((_.lineage.derived_from??[]).forEach((S,$)=>{v(or(_.id,S,$))}),(_.lineage.related_to??[]).forEach((S,$)=>{v(_u(_.id,S,$))}));for(const _ of r.hypothetical_nodes??[])u&&!u.has(_.id)&&!x.has(_.id)||(_.derived_from??[]).forEach((S,$)=>{v(or(_.id,S,$))});return{nodes:k,edges:j,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(l)}}function nl(e,n,i){const r=(e??(n!=null?String(n):"")).trim();return r?!i||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function zu(e,n){const i=[],r=e.version_graph;if(!r)return i;const s=new Set(n.map(c=>c.id)),l=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),a=new Set([...s,...l]),p=(c,d)=>{a.has(d.ref)||i.push(`${c}: derived_from.ref "${d.ref}" 未在 books 或 hypothetical_nodes 中找到`),d.ref_type==="book"&&!s.has(d.ref)&&i.push(`${c}: derived_from.ref "${d.ref}" 标记为 book 但不在 books 列表中`),d.ref_type==="hypothetical"&&!l.has(d.ref)&&i.push(`${c}: derived_from.ref "${d.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const d=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(u=>p(d,u)),(c.lineage.related_to??[]).forEach(u=>{s.has(u.book_id)||i.push(`${d}: related_to.book_id "${u.book_id}" 不在 books 列表中`)})}for(const c of r.hypothetical_nodes??[]){const d=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(u=>p(d,u))}return i}const il=({graph:e,renderLink:n,className:i,style:r})=>{const{convert:s}=V();if(!e.nodes.length)return t.jsx("div",{style:{...Ou,...r},className:i,children:"暂无版本图数据"});const l=new Map,a=new Map;for(const x of e.edges)if(x.kind==="derive"){const m=l.get(x.target)??[];m.push(x),l.set(x.target,m)}else for(const m of[x.source,x.target]){const b=a.get(m)??[];b.push(x),a.set(m,b)}const p=new Map(e.nodes.map(x=>[x.id,x])),c=new Map,d=[];for(const x of e.nodes)if(x.group){const m=c.get(x.group)??[];m.push(x),c.set(x.group,m)}else d.push(x);const u=(x,m)=>(x.year??9999)-(m.year??9999);c.forEach(x=>x.sort(u)),d.sort(u);const g=e.groups.filter(x=>c.has(x.id));return t.jsxs("div",{className:i,style:{...Iu,...r},children:[e.title&&t.jsx("div",{style:Tu,children:s(e.title)}),e.description&&t.jsx("div",{style:Eu,children:s(e.description)}),g.map(x=>t.jsx(rr,{label:x.label,color:x.color,nodes:c.get(x.id),incomingMap:l,siblingMap:a,nodeMap:p,renderLink:n},x.id)),d.length>0&&t.jsx(rr,{label:"其他",nodes:d,incomingMap:l,siblingMap:a,nodeMap:p,renderLink:n})]})},rr=({label:e,color:n,nodes:i,incomingMap:r,siblingMap:s,nodeMap:l,renderLink:a})=>{const{convert:p}=V();return t.jsxs("div",{style:Ru,children:[t.jsx("div",{style:{...Nu,borderLeftColor:n??o("widget-border")},children:p(e)}),i.map(c=>t.jsx(Cu,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:l,renderLink:a},c.id))]})},Cu=({node:e,incoming:n,siblings:i,nodeMap:r,renderLink:s})=>{const l=e.kind==="hypothetical",a=e.bridge,{convert:p}=V();return t.jsxs("div",{style:{...Lu,borderStyle:l||a?"dashed":"solid",opacity:a?.55:e.status==="lost"?.7:1,background:a?o("bg-subtle"):void 0},title:a?"桥接节点:本身不在核心集,为保持派生链完整而显示":void 0,children:[t.jsxs("div",{style:Bu,children:[t.jsx("span",{style:Au,children:l||!s?p(e.label):s(e.id,p(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Wu,children:nl(p(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Mu,children:[e.category&&t.jsx(Ot,{children:p(e.category)}),e.status==="lost"&&t.jsx(Ot,{tone:"warn",children:"已佚"}),e.status==="fragment"&&t.jsx(Ot,{tone:"warn",children:"残本"}),l&&t.jsx(Ot,{tone:"info",children:"假想祖本"}),a&&t.jsx(Ot,{tone:"info",children:"桥接"})]}),e.extant_juan&&t.jsxs("div",{style:Fu,children:["现存:",p(e.extant_juan)]}),e.note&&t.jsx("div",{style:Pu,children:p(e.note)}),n.length>0&&t.jsxs("div",{style:lr,children:[t.jsx("div",{style:ar,children:"来源:"}),n.map(c=>{const d=r.get(c.source);return t.jsxs("div",{style:cr(c.confidence),children:[t.jsx("span",{style:dr,children:p(c.relation)}),t.jsx("span",{children:(d==null?void 0:d.kind)==="book"&&s?s(d.id,p(d.label)):p((d==null?void 0:d.label)??c.source)}),c.confidence!=="consensus"&&c.confidence!=="certain"&&t.jsx(sr,{level:c.confidence}),c.evidence&&t.jsxs("span",{style:pr,children:["· ",p(c.evidence)]})]},c.id)})]}),i.length>0&&t.jsxs("div",{style:lr,children:[t.jsx("div",{style:ar,children:"关联:"}),i.map(c=>{const d=c.source===e.id?c.target:c.source,u=r.get(d);return t.jsxs("div",{style:cr(c.confidence),children:[t.jsx("span",{style:dr,children:p(c.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,p(u.label)):p((u==null?void 0:u.label)??d)}),t.jsx(sr,{level:c.confidence}),c.evidence&&t.jsxs("span",{style:pr,children:["· ",p(c.evidence)]})]},c.id)})]})]})},Ot=({children:e,tone:n="default"})=>{const r={default:{bg:o("tag-bg"),fg:o("fg")},warn:{bg:o("warn-bg"),fg:o("warn-fg")},info:{bg:o("info-bg"),fg:o("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:e})},sr=({level:e})=>{const i={certain:{label:"确定",color:o("confidence-certain")},consensus:{label:"共识",color:o("confidence-consensus")},probable:{label:"推测",color:o("confidence-probable")},disputed:{label:"有争议",color:o("confidence-disputed")}}[e];return i?t.jsx("span",{style:{display:"inline-block",padding:"0 6px",fontSize:"10px",border:`1px solid ${i.color}`,color:i.color,borderRadius:"8px",marginLeft:"4px"},children:i.label}):null},Iu={fontSize:"14px",color:o("fg")},Tu={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Eu={fontSize:"13px",color:o("muted"),marginBottom:"16px",lineHeight:1.6},Ru={marginBottom:"16px"},Nu={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:o("fg")},Lu={border:`1px solid ${o("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:o("bg")},Bu={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Au={fontSize:"15px",fontWeight:600},Wu={fontSize:"12px",color:o("muted")},Mu={marginBottom:"6px"},Fu={fontSize:"12px",color:o("muted"),margin:"2px 0"},Pu={fontSize:"12px",color:o("muted"),fontStyle:"italic",margin:"4px 0"},lr={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${o("widget-border")}`},ar={fontSize:"11px",color:o("muted"),marginBottom:"2px"},cr=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),dr={display:"inline-block",padding:"0 6px",fontSize:"11px",background:o("tag-bg"),color:o("fg"),borderRadius:"3px",marginRight:"6px"},pr={fontSize:"11px",color:o("muted")},Ou={padding:"20px",textAlign:"center",color:o("muted"),fontSize:"13px"},ol=({selectedNodeId:e,...n})=>{const[i,r]=f.useState("loading"),[s,l]=f.useState(null);return f.useEffect(()=>{let a=!1;return Du().then(p=>{a||(p?(l(p),r("ready")):r("missing"))}),()=>{a=!0}},[]),i==="loading"?t.jsx("div",{style:ur,children:"加载图组件中…"}):i==="missing"||!s?t.jsxs("div",{style:ur,children:[t.jsxs("div",{children:["图组件未安装。请安装 ",t.jsx("code",{children:"@xyflow/react"})," 与 ",t.jsx("code",{children:"@dagrejs/dagre"}),"。"]}),t.jsxs("div",{style:{fontSize:"12px",marginTop:"4px"},children:["或使用 ",t.jsx("code",{children:"VersionLineageList"})," 列表视图。"]})]}):t.jsx(Hu,{modules:s,selectedNodeId:e,...n})};async function Du(){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 Hu=({graph:e,renderLink:n,height:i=600,className:r,style:s,selectedNodeId:l,modules:a})=>{const{ReactFlow:p,Background:c,Controls:d,Handle:u,Position:g,BaseEdge:x,EdgeLabelRenderer:m,getSmoothStepPath:b,dagre:k}=a,h=f.useMemo(()=>({lineage:$=>{var Y,K,R,oe;const w=((Y=$.data)==null?void 0:Y.stepPosition)??.85,[C,N,E]=b({sourceX:$.sourceX,sourceY:$.sourceY,sourcePosition:$.sourcePosition,targetX:$.targetX,targetY:$.targetY,targetPosition:$.targetPosition,stepPosition:w,borderRadius:5}),I=!!((K=$.data)!=null&&K.isSibling),O=I?N:$.targetX-18,A=I?E:$.targetY-12,M=(R=$.data)==null?void 0:R.labelStyle,F=(oe=$.data)==null?void 0:oe.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(x,{id:$.id,path:C,style:$.style,markerStart:$.markerStart,markerEnd:$.markerEnd}),$.label&&t.jsx(m,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${O}px,${A}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:o("bg"),border:`0.5px solid ${o("widget-border")}`,...F,...M},children:$.label})})]})}}),[x,m,b]),y=f.useMemo(()=>({version:$=>{const w=$.data,C=w.kind==="hypothetical",N=w.status==="lost",E=w.isSelected,I=w.bridge,O=w.borderColor??o("muted"),A=I||C?"dashed":"solid",M=I?.5:N?.6:1;return t.jsxs("div",{style:{background:o(I?"bg-subtle":"bg"),border:`2px ${A} ${E?o("primary"):O}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:M,boxShadow:E?o("shadow-node-selected"):C||I?"none":o("shadow-node")},title:I?"桥接节点:本身不在核心集,为保持派生链完整而显示":void 0,children:[t.jsx(u,{type:"target",position:g.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:C||!w.renderLink?w.label:w.renderLink(w.bookId,w.label)}),w.description&&t.jsx("div",{style:{fontSize:10,color:o("aux-fg"),lineHeight:1.25,marginTop:1},children:w.description}),w.yearText&&t.jsx("div",{style:{fontSize:10,color:o("aux-fg"),lineHeight:1.2},children:nl(w.yearText,void 0,w.uncertain)}),N&&t.jsx("div",{style:{fontSize:9,color:o("lost-fg"),marginTop:1},children:"已佚"}),t.jsx(u,{type:"source",position:g.Right,style:{visibility:"hidden"}})]})}}),[u,g]),{convert:j}=V(),{rfNodes:v,rfEdges:_}=f.useMemo(()=>Gu(e,k,n,l,j),[e,k,n,l,j]);return t.jsx("div",{style:{width:"100%",height:i,...s},className:r,children:t.jsxs(p,{nodes:v,edges:_,nodeTypes:y,edgeTypes:h,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(d,{showInteractive:!1})]})})};function Gu(e,n,i,r,s=l=>l??""){const p=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:p?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const d=new Map(e.groups.map(y=>[y.id,y.color??o("muted")]));for(const y of e.nodes)c.setNode(y.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const y of e.edges)y.kind==="derive"&&(u.has(y.relation)||c.setEdge(y.source,y.target));n.layout(c);const g=e.nodes.map(y=>{const j=c.node(y.id),v=r?y.id===r:void 0,_={kind:y.kind,label:s(y.label),bookId:y.kind==="book"?y.id:void 0,yearText:s(y.year_text??Vu(y)),uncertain:y.year_uncertain,category:y.category,status:y.status,borderColor:y.group?d.get(y.group):void 0,renderLink:i,isSelected:v,description:s(y.description),bridge:y.bridge};return{id:y.id,type:"version",position:{x:j.x-160/2,y:j.y-90/2},data:_,draggable:!1,selected:v}}),x=.78,m=.06,b=new Map;for(const y of e.edges)y.kind==="derive"&&(b.has(y.source)||b.set(y.source,[]),b.get(y.source).push(y));const k=new Map;for(const[y,j]of b){if(j.length<=1)continue;const v=[...j].sort((S,$)=>{var N,E;const w=((N=c.node(S.target))==null?void 0:N.y)??0,C=((E=c.node($.target))==null?void 0:E.y)??0;return w-C}),_=v.length;v.forEach((S,$)=>{const w=($-(_-1)/2)*m;k.set(S.id,x+w)})}const h=e.edges.map(y=>Uu(y,k.get(y.id),s));return{rfNodes:g,rfEdges:h}}function Uu(e,n,i=r=>r??""){const r=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",l=Yu(e.confidence),a={type:"arrowclosed",color:l,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:i(e.relation),data:{labelStyle:{color:o("fg")},isSibling:s,stepPosition:n},style:{stroke:l,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:a,markerStart:s?a:void 0,zIndex:1e3}}function Vu(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Yu(e){switch(e){case"certain":return o("confidence-certain");case"consensus":return o("lineage-edge-consensus");case"probable":return o("confidence-probable");case"disputed":return o("confidence-disputed");default:return o("muted")}}const ur={padding:"40px 20px",textAlign:"center",color:o("muted"),fontSize:"13px",border:`1px dashed ${o("widget-border")}`,borderRadius:8,background:o("bg")},Hi=({graph:e,defaultMode:n="list",renderLink:i,graphHeight:r=600,selectedNodeId:s,onModeChange:l,collection:a,onCollectionChange:p,collectionsAvailable:c,collectionCounts:d,className:u,style:g})=>{var j;const[x,m]=f.useState(n),b=v=>{m(v),l==null||l(v)},k=(()=>{if(!c)return[];const v=Object.entries(c);return v.length===0||c.all?v:[...v,["all",{label:"全部",description:"显示该作品所有版本(含桥接节点)"}]]})(),h=!!(p&&k.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:o("muted"),textAlign:"center"},children:"暂无版本传承数据"});const y=a?(j=c==null?void 0:c[a])==null?void 0:j.description:void 0;return t.jsxs("div",{className:u,style:g,children:[t.jsxs("div",{style:Ku,children:[t.jsx("button",{onClick:()=>b("list"),style:Mn(x==="list"),children:"列表"}),t.jsx("button",{onClick:()=>b("graph"),style:Mn(x==="graph"),children:"关系图"}),h&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:o("muted"),marginRight:4},children:"集合:"}),k.map(([v,_])=>{const S=d==null?void 0:d[v];return t.jsxs("button",{onClick:()=>p==null?void 0:p(v),style:Mn(a===v),title:_.description,children:[_.label,S!=null?` ${S}`:""]},v)})]})]}),h&&y&&t.jsx("div",{style:{fontSize:12,color:o("muted"),marginBottom:8,padding:"4px 8px",background:o("bg-subtle"),borderRadius:4},children:y}),x==="list"?t.jsx(il,{graph:e,renderLink:i}):t.jsx(ol,{graph:e,renderLink:i,height:r,selectedNodeId:s})]})},Ku={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Mn=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${o("widget-border")}`,borderRadius:4,background:e?o("primary"):"transparent",color:o(e?"primary-fg":"fg"),cursor:"pointer"}),xr=40,fr=2,qu=9,gr={certain:"確證",consensus:"通說",probable:"可能",disputed:"有爭議"};function Fn(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const rl=({data:e,transport:n,onNavigate:i,renderLink:r,readAction:s,fullText:l,fullTextPending:a,chapterLink:p,railTop:c,back:d,railLinks:u})=>{var L,B,G,Z,ue,le,be,Ne,je,Pe,at;const g=de(),{convert:x}=V(),[m,b]=f.useState(null),[k,h]=f.useState(new Map),[y,j]=f.useState([]),[v,_]=f.useState(new Map),[S,$]=f.useState(!1),[w,C]=f.useState("flow"),[N,E]=f.useState(null);f.useEffect(()=>{if(!n||!e.work_id){b(null);return}let W=!1;return n.getItem(e.work_id).then(ae=>{!W&&ae&&ae.type==="work"&&b(ae)}).catch(()=>{}),()=>{W=!0}},[n,e.work_id]),f.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){E(null);return}let W=!1;return n.getLineageGraph(e.work_id).then(ae=>{W||E(ae&&ae.nodes.length>1?ae:null)}).catch(()=>{W||E(null)}),()=>{W=!0}},[n,e.work_id]),f.useEffect(()=>{const W=e.contained_in||[];if(!n||W.length===0){h(new Map);return}let ae=!1;return Promise.all(W.map(fe=>{const _e=typeof fe=="string"?fe:fe.id;return n.getItem(_e).then(xe=>[_e,xe]).catch(()=>[_e,null])})).then(fe=>{if(ae)return;const _e=new Map;for(const[xe,$e]of fe)$e&&_e.set(xe,$e);h(_e)}),()=>{ae=!0}},[n,e.contained_in]);const I=f.useMemo(()=>{const W=new Set([...(m==null?void 0:m.books)||[],...e.related_books||[]]);return W.add(e.id),[...W]},[m==null?void 0:m.books,e.related_books,e.id]),O=I.length-1;f.useEffect(()=>{if(!n||O<=0){j([]);return}const W=I.length<=xr,ae=W?I:I.slice(0,8);let fe=!1;return Promise.all(ae.map(_e=>_e===e.id?Promise.resolve({id:_e,title:e.title,edition:e.edition,year:fn(e)}):n.getItem(_e).then(xe=>{const $e=xe??{};return{id:_e,title:$e.title,edition:$e.edition,year:xe?fn($e):void 0}}).catch(()=>({id:_e})))).then(_e=>{if(fe)return;const xe=_e.filter($e=>$e.id===e.id||$e.title||$e.edition);W&&xe.sort(($e,Oe)=>($e.year??1/0)-(Oe.year??1/0)),j(xe)}),()=>{fe=!0}},[n,I,O,e]);const A=e.lineage,M=f.useMemo(()=>[...((A==null?void 0:A.derived_from)||[]).filter(W=>W.ref_type==="book").map(W=>W.ref),...((A==null?void 0:A.related_to)||[]).map(W=>W.book_id)].filter(Boolean),[A]);f.useEffect(()=>{if(!n||M.length===0){_(new Map);return}let W=!1;return Promise.all(M.map(ae=>n.getItem(ae).then(fe=>[ae,{id:ae,title:fe==null?void 0:fe.title,edition:fe==null?void 0:fe.edition}]).catch(()=>[ae,{id:ae}]))).then(ae=>{W||_(new Map(ae))}),()=>{W=!0}},[n,M]);const F=f.useMemo(()=>Xs(e.resources,e.resource_groups),[e.resources,e.resource_groups]),Y=F.groups.reduce((W,ae)=>W+ae.rows.length+ae.mirrors.length,0),K=F.groups.length>0&&F.groups.every(W=>W.key==="_physical"),R=qt(e),oe=Vr(e),H=lt(e,g.unit.juan),re=new Set((e.contained_in||[]).map(W=>typeof W=="string"?0:Gt(W.volume_index).length).filter(W=>W>0)),ee=W=>{var _e;const ae=(_e=e.base_edition)==null?void 0:_e.find(xe=>xe.book_id===W&&xe.name);if(ae!=null&&ae.name)return ae.name;const fe=v.get(W);return(fe==null?void 0:fe.edition)||(fe==null?void 0:fe.title)||""},Q=f.useMemo(()=>{var ct,tn,dt,nn,on;const W=[];oe&&W.push({label:"版本類型",value:x(oe),title:e.edition_type||(ct=e.lineage)!=null&&ct.category?void 0:x("據版本題名推斷")}),(tn=e.publication_info)!=null&&tn.details?W.push({label:"刊印",value:x(e.publication_info.details)}):(R.era||R.reign)&&W.push({label:"刊寫年代",value:x([R.era,R.reign].filter(Boolean).join(" ")),title:R.source==="edition"?x("據版本題名推斷"):void 0}),H&&W.push({label:"卷帙",value:x(H)});const ae=(e.contained_in||[]).flatMap(Se=>typeof Se=="string"?[]:Gt(Se.volume_index));ae.length&&W.push({label:"冊次",value:x(`第 ${Sn(ae,g.unit.volume)} ${g.unit.volume}(${ae.length} ${g.unit.volume})`)});const fe=(((dt=e.lineage)==null?void 0:dt.derived_from)||[]).find(Se=>Se.relation==="底本"&&Se.ref_type==="book");fe&&ee(fe.ref)&&W.push({label:"底本",value:t.jsx(Le,{id:fe.ref,label:x(ee(fe.ref)),onNavigate:i,renderLink:r,dense:!0})});const _e=(e.base_edition||[]).filter(Se=>Se&&Se.name);for(const Se of["底本","配補","參校"]){if(Se==="底本"&&fe&&ee(fe.ref))continue;const Je=_e.filter(Te=>Te.role===Se);Je.length&&W.push({label:Se,value:Je.map((Te,kt)=>t.jsxs(f.Fragment,{children:[kt>0&&"、",Te.book_id?t.jsx(Le,{id:Te.book_id,label:x(Te.name),onNavigate:i,renderLink:r,dense:!0}):x(Te.name)]},kt))})}const xe=(e.provenance||[]).filter(Se=>Se&&Se.institution),$e=(e.resources||[]).filter(Se=>(Se.types||(Se.type?[Se.type]:[])).includes("physical"));if(xe.length){W.push({label:"存藏",value:xe.slice(0,2).map(Te=>x(Te.institution)).join("、")+(xe.length>2?x(` 等 ${xe.length} 處`):"")});const Se=xe.filter(Te=>Te.call_number).slice(0,2).map(Te=>`${x(Te.institution)} ${Te.call_number}`);Se.length&&W.push({label:"索書號",value:Se.join(";")+(xe.filter(Te=>Te.call_number).length>2?"…":"")});const Je=xe.flatMap(Te=>Te.seals||[]).filter(Boolean);Je.length&&W.push({label:"藏印",value:x(Je.join("、"))})}else $e.length?W.push({label:"存藏",value:$e.slice(0,2).map(Se=>x(Se.name)).join("、")+($e.length>2?x(` 等 ${$e.length} 處`):"")}):(nn=e.current_location)!=null&&nn.name&&W.push({label:"存藏",value:x(e.current_location.name)});const Oe=e.physical_description;if(Oe){const Se=[["行款",Oe.leaf_style],["裝幀",Oe.binding],["尺寸",Oe.dimensions],["品相",Oe.condition]];for(const[Je,Te]of Se)Te&&Te.trim()&&W.push({label:Je,value:x(Te)})}(on=e.page_count)!=null&&on.description&&W.push({label:g.label.pageCount,value:x(e.page_count.description)});const qe=[...Xn(e.additional_titles),...Xn(e.attached_texts)];return qe.length&&W.push({label:"又名",value:qe.map(x).join("、")}),W},[e,x,g,R,oe,H,v,i,r]),J=x(e.title),ce=e.edition?x(e.edition):void 0,me=((L=e.lineage)==null?void 0:L.year_text)||"",te=t.jsx(Zt,{kind:"版本",title:J,subtitle:ce,byline:t.jsx(Oi,{authors:e.authors??(m==null?void 0:m.authors),onNavigate:i,renderLink:r}),meta:(()=>{const W=[oe?x(oe):"",R.era?x([R.era,R.reign].filter(Boolean).join("")):"",H?x(H):""].filter(Boolean);return W.length?t.jsx("span",{className:"bim-d-tags",children:W.map((ae,fe)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(fe,2)}`,children:ae},fe))}):null})(),description:(B=e.description)!=null&&B.text?t.jsx(st,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:vi((G=e.description)==null?void 0:G.text)?6:void 0,facts:Q,readAction:s,secondaryAction:s&&Y>0&&!K?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:x("看原書影印")}):void 0,foot:t.jsx(Xt,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),ie=e.contained_in||[],pe=(l==null?void 0:l.chapters)||[],ge=pe[0]&&Fn(pe[0].title)[0].slice(-1)||"章",Ce=!!((Z=A==null?void 0:A.derived_from)!=null&&Z.length||(ue=A==null?void 0:A.related_to)!=null&&ue.length||(le=e.appendix)!=null&&le.length),ve=[];(pe.length||F.text.length||a)&&ve.push({id:"fulltext",label:"全文",count:pe.length?x(`${pe.length} ${ge}`):void 0}),F.groups.length&&ve.push({id:"images",label:K?"館藏":"影印",count:Y}),Ce&&ve.push({id:"lineage",label:"版本源流"}),ie.length&&ve.push({id:"collections",label:"收入叢編",count:ie.length}),(be=e.location_history)!=null&&be.length&&ve.push({id:"provenance",label:"流轉歷史"});const we=W=>(p==null?void 0:p(W))??null,Ee=pe[0],Re=Ee?we(Ee.file):null,D=S?pe:pe.slice(0,qu),se=(W,ae,fe)=>W?t.jsx("a",{className:fe,href:W.href??"#",onClick:W.onClick?_e=>{_e.metaKey||_e.ctrlKey||(_e.preventDefault(),W.onClick())}:void 0,children:ae}):t.jsx("span",{className:fe,children:ae}),ne=t.jsxs(t.Fragment,{children:[(pe.length>0||F.text.length>0||a)&&t.jsxs(Me,{id:"fulltext",title:"全文",meta:pe.length>0?t.jsx(We,{items:[x(`${pe.length} ${ge}`),(Ne=l==null?void 0:l.source)!=null&&Ne.name?x(`據${l.source.name}${l.source.license?` ${l.source.license}`:""}`):""]}):void 0,children:[a&&!Ee&&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"})]}),Ee&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:x(`從${Fn(Ee.title)[0]||"第一章"}讀起`)}),t.jsx("span",{className:"bim-d-meta",children:x((Ee.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),se(Re,t.jsxs(t.Fragment,{children:[x("進入閱讀頁")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),pe.length>1&&t.jsx("ul",{className:"bim-d-chap",children:D.map(W=>{const[ae,fe]=Fn(W.title);return t.jsx("li",{children:se(we(W.file),t.jsxs(t.Fragment,{children:[ae&&t.jsx("b",{children:x(ae)}),x(fe||W.file)]}))},W.file)})}),pe.length>D.length&&t.jsx(Bt,{label:`展開其餘 ${pe.length-D.length} ${ge}`,onClick:()=>$(!0)}),F.text.length>0&&t.jsxs(t.Fragment,{children:[(pe.length>0||a)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:x("站外全文")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:F.text.map((W,ae)=>t.jsx(Di,{item:W,siblings:F.text,listedVolumeCounts:re},`${W.id||W.url||W.name}-${ae}`))})})]})]}),F.groups.length>0&&t.jsx(Me,{id:"images",title:K?"館藏":"影印",meta:t.jsx(We,{items:[F.groups.length>1?x(`${F.groups.length} 組`):"",x(`${Y} 處`)]}),children:t.jsx(el,{groups:F.groups,listedVolumeCounts:re})}),Ce&&t.jsx(Me,{id:"lineage",title:"版本源流",meta:(je=A==null?void 0:A.derived_from)!=null&&je.length?x("據版本傳承著錄"):void 0,action:N?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":x("源流視圖"),children:[t.jsx("button",{type:"button","aria-pressed":w==="flow",onClick:()=>C("flow"),children:x("卡片")}),t.jsx("button",{type:"button","aria-pressed":w==="graph",onClick:()=>C("graph"),children:x("關係圖")})]}):void 0,children:w==="graph"&&N?t.jsx(Hi,{graph:N,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(W,ae)=>t.jsx(Le,{id:W,label:x(ae),onNavigate:i,renderLink:r,dense:!0})}):t.jsx(Zu,{data:e,heading:ce||J,yearText:me,refName:ee,onNavigate:i,renderLink:r})}),ie.length>0&&t.jsx(Me,{id:"collections",title:"收入叢編",children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:ie.map((W,ae)=>{var Oe,qe;const fe=typeof W=="string"?W:W.id,_e=typeof W=="string"?[]:Gt(W.volume_index),xe=k.get(fe),$e=(xe==null?void 0:xe._member_count)||((Oe=xe==null?void 0:xe.books)==null?void 0:Oe.length)||((qe=xe==null?void 0:xe.contained_works)==null?void 0:qe.length)||0;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Le,{id:fe,label:xe?x(xe.title):fe,onNavigate:i,renderLink:r,dense:!0}),_e.length>0&&t.jsx(Ju,{volumes:_e,unit:g.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${$e?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:$e>0&&x(`全 ${$e} ${g.unit.bu}`)})]},`${fe}-${ae}`)})})})}),(Pe=e.location_history)!=null&&Pe.length?t.jsx(Me,{id:"provenance",title:"流轉歷史",children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((W,ae)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:x(W.name)}),([W.start_date,W.end_date].filter(Boolean).join("—")||W.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(We,{items:[[W.start_date,W.end_date].filter(Boolean).join("—"),W.description?x(W.description):""]})})]},ae))})}):null,ve.length===0&&t.jsx(Me,{title:"影印與全文",children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:x("尚未著錄該版本的影印、全文與收藏信息。")})})]}),he=y.findIndex(W=>W.id===e.id),q=I.length<=xr,P=q&&he>=0?y.slice(Math.max(0,he-fr),he+fr+1):y.filter(W=>W.id!==e.id),T=t.jsxs(t.Fragment,{children:[m&&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:x(g.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(Le,{id:m.id,label:x(m.title),onNavigate:i,renderLink:r})}),t.jsx(We,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(m.authors||[]).slice(0,2).map(W=>`${W.dynasty?`〔${x(W.dynasty)}〕`:""}${x(W.name)}`),x(lt(m,g.unit.juan)),m._edition_count?x(`${m._edition_count} 種版本`):""]}),((at=m.description)==null?void 0:at.text)&&t.jsx("p",{style:{margin:"8px 0 0",fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc",children:x(m.description.text.replace(/[#*_>`[\]]/g,""))})]}),O>0&&P.length>0&&t.jsxs("div",{children:[t.jsx(ht,{id:"siblings",timeline:!0,title:q?"同作品版本":g.relation.siblingVersions,meta:x(q?"按年代":`${O} 種`),cap:P.length,items:P.map(W=>W.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:x(W.edition||W.title||W.id)}):t.jsx(Le,{id:W.id,label:x(W.edition||W.title||W.id),onNavigate:i,renderLink:r,dense:!0})),metas:P.map(W=>[W.year!=null?W.year<0?`前${-W.year}`:String(W.year):"",W.id===e.id?x("本頁"):""].filter(Boolean).join(" ")),currentIndex:P.findIndex(W=>W.id===e.id)}),m&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(Le,{id:m.id,label:x(`在作品頁看全部 ${I.length} 種 →`),onNavigate:i,renderLink:r,dense:!0})})]})]}),z=e.work_id?t.jsx(Xr,{caption:g.section.belongsToWork,children:t.jsx(Le,{id:e.work_id,label:m?x(m.title):" ",onNavigate:i,renderLink:r,dense:!0})}):void 0;return t.jsx(Jt,{railTop:c,back:d,up:z,nav:ve,railLinks:u,main:ne,card:te,side:T})};function Ju({volumes:e,unit:n}){const{convert:i}=V();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[i(`第 ${Sn(e,n)} ${n}`),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),i(`${e.length} ${n}`)]})]})}function Zu({data:e,heading:n,yearText:i,refName:r,onNavigate:s,renderLink:l}){var h;const{convert:a}=V(),p=e.lineage,c=(p==null?void 0:p.derived_from)||[],d=c.filter(y=>y.ref_type!=="book"),u=c.filter(y=>y.ref_type==="book"&&y.relation==="底本"),g=c.filter(y=>y.ref_type==="book"&&y.relation!=="底本"),x=(p==null?void 0:p.related_to)||[],m=c.length>0||x.length>0,b=y=>y&&gr[y]?a(`(${gr[y]})`):"",k=(y,j)=>t.jsx(Le,{id:y,label:a(j||y),onNavigate:s,renderLink:l,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[m&&t.jsxs("ol",{className:"bim-d-lf-list",children:[d.map((y,j)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:a(y.relation||"祖本")}),t.jsx("span",{className:"bim-d-lf-name",children:a("擬構祖本")}),y.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[a(y.evidence),b(y.confidence)]})]})},`a-${j}`)),u.map((y,j)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:a(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:k(y.ref,r(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[a(y.evidence),b(y.confidence)]})]})},`b-${j}`)),t.jsxs("li",{className:"bim-d-lf-node bim-d-lf-cur",children:[t.jsxs("div",{className:"bim-d-lf-here",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:a("本版")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),i&&t.jsx("span",{className:"bim-d-lf-yr",children:a(i)})]}),g.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:g.map((y,j)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:a(y.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:k(y.ref,r(y.ref))}),y.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[a(y.evidence),b(y.confidence)]})]},j))})]}),x.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:a("翻刻 · 衍生")}),t.jsx("span",{className:"bim-d-lf-chips",children:x.map((y,j)=>t.jsxs("span",{className:"bim-d-lf-chip",title:y.evidence?a(y.evidence):void 0,children:[k(y.book_id,r(y.book_id)),t.jsx("span",{className:"bim-d-meta",children:a(y.relation)})]},j))})]})]}),(h=e.appendix)==null?void 0:h.map((y,j)=>t.jsxs("details",{className:"bim-d-lf-app",children:[t.jsxs("summary",{className:"bim-d-ui",children:[t.jsx("span",{className:"bim-d-meta",children:a("附記")})," ",a(y.title)]}),t.jsx(st,{text:y.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${j}`)),(p==null?void 0:p.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:a(p.note)})]})}const Pn=16,Xu=200,Qu=16,sl=({data:e,catalog:n,transport:i,onNavigate:r,renderLink:s,catalogAction:l,railTop:a,back:p,railLinks:c})=>{var D,se,ne,he,q,P,T;const d=de(),{convert:u}=V(),[g,x]=f.useState(""),[m,b]=f.useState(!1),[k,h]=f.useState(null),[y,j]=f.useState(""),v=f.useMemo(()=>Gr(e,n),[e,n]),[_,S]=f.useState(new Map),$=!!i&&v.rows.length>0&&v.rows.length<=Xu,w=$&&v.rows.every(z=>!z.id||_.has(z.id)),C=z=>{var L;return si(z?(L=_.get(z))==null?void 0:L.l1:void 0)},N=f.useMemo(()=>{const z=g.trim(),L=z?u(z):"";return v.rows.filter(B=>{var Z,ue;if(y&&si(B.id?(Z=_.get(B.id))==null?void 0:Z.l1:void 0)!==y)return!1;if(!L)return!0;const G=B.id&&((ue=_.get(B.id))==null?void 0:ue.title)||B.title;return u(G).includes(L)||(B.subItems||[]).some(le=>u(le).includes(L))})},[v.rows,g,y,_,u]),E=m?N:N.slice(0,Pn),I=f.useMemo(()=>($?v.rows:E).filter(z=>z.id&&!_.has(z.id)).map(z=>z.id),[$,v.rows,E,_]);f.useEffect(()=>{if(!i||I.length===0)return;let z=!1;const L=I.slice(0,Qu);return Promise.all(L.map(B=>i.getItem(B).then(G=>{var le,be;const Z=G??{},ue={title:Z.title,edition:Z.edition,authors:Z.authors,measure:G?lt(G,d.unit.juan):void 0,versionCount:Z._edition_count??((le=Z.books)==null?void 0:le.length),l1:((be=Z.classification)==null?void 0:be.l1)||void 0};return[B,ue]}).catch(()=>[B,{}]))).then(B=>{z||S(G=>{const Z=new Map(G);for(const[ue,le]of B)Z.set(ue,le);return Z})}),()=>{z=!0}},[i,I,d.unit.juan]);const O=(e.contained_in||[])[0];f.useEffect(()=>{if(!O){h(null);return}if(h({id:O}),!i)return;let z=!1;return i.getItem(O).then(L=>{z||h({id:O,title:L==null?void 0:L.title})}).catch(()=>{}),()=>{z=!0}},[i,O]);const A=f.useMemo(()=>Xs(e.resources,e.resource_groups),[e.resources,e.resource_groups]),M=A.text.length+A.groups.reduce((z,L)=>z+L.rows.length+L.mirrors.length,0),F=e.contained_works||[],Y=new Set(v.rows.map(z=>z.id).filter(Boolean)),K=F.length>0&&!F.every(z=>Y.has(z.id)),R=(()=>{const z=v.rows.map(L=>L.edition).filter(Boolean);return z.length>1&&new Set(z).size===1})(),oe=v.rows.some(z=>z.volumes.length>0||z.expected!=null),H=e._member_count||((D=e.books)==null?void 0:D.length)||F.length,re=lt(e,d.unit.juan),ee=e.count,Q=z=>typeof z=="number"&&Number.isFinite(z)?z:null,J=Q(ee==null?void 0:ee.juan)??Q((se=e.juan_count)==null?void 0:se.number),ce=Q(ee==null?void 0:ee.ce)??(v.totalVolumes||null),me=[{value:v.rows.length,label:"子目"},{value:J??0,label:d.unit.juan},{value:ce??0,label:d.unit.volume}],te=f.useMemo(()=>{var B,G;const z=[];if((B=e.publication_info)!=null&&B.details&&z.push({label:"刊印",value:u(e.publication_info.details)}),H&&H!==v.rows.length){const Z=e._member_type==="Book"?"所收版本":e._member_type==="Work"?"所收作品":"成員";z.push({label:u(Z),value:`${H} ${u(d.unit.bu)}`,title:u("子目與其各版本合計")})}const L=[Q(ee==null?void 0:ee.zhong)!=null?`${ee.zhong} 種`:"",Q(ee==null?void 0:ee.han)!=null?`${ee.han} 函`:""].filter(Boolean);return L.length&&z.push({label:"應收",value:u(L.join(" "))}),J==null&&re&&z.push({label:"卷帙",value:u(re),title:(G=e.juan_count)!=null&&G.description?u(e.juan_count.description):void 0}),z},[e,H,v.rows.length,J,re,ee,u,d]),ie=f.useMemo(()=>{if(!w)return[];const z=new Map;for(const B of v.rows){const G=C(B.id);G&&z.set(G,(z.get(G)??0)+1)}const L=Vt.filter(B=>(z.get(B.key)??0)>0);return L.length<2?[]:[{key:"",label:`${d.catalog.all} ${v.rows.length}`},...L.map(B=>({key:B.key,label:`${B.label} ${z.get(B.key)}`}))]},[w,v.rows,_,d]),pe=f.useMemo(()=>{if(!w||!v.rows.some(G=>G.volumes.length>0))return null;const z=[],L=v.rows.filter(G=>G.volumes.length>0).map(G=>({k:C(G.id)??"",from:Math.min(...G.volumes),to:Math.max(...G.volumes)})).sort((G,Z)=>G.from-Z.from);for(const G of L){const Z=G.to-G.from+1,ue=z[z.length-1];ue&&ue.key===G.k?(ue.to=Math.max(ue.to,G.to),ue.n+=Z):z.push({key:G.k,from:G.from,to:G.to,n:Z})}const B=L.reduce((G,Z)=>Math.max(G,Z.to),0);return z.length>1&&z.some(G=>G.key)?{segs:z,last:B}:null},[w,v.rows,_]),ge=(ne=e.description)==null?void 0:ne.text,Ce=t.jsx(Zt,{kind:"叢編",title:u(e.title),byline:t.jsx(Oi,{authors:e.authors,onNavigate:r,renderLink:s}),meta:t.jsx(We,{items:[e.subtype==="work_collection"?u("作品集"):"",(he=e.publication_info)!=null&&he.year?u(e.publication_info.year):""]}),description:ge||(q=e.history)!=null&&q.length?t.jsxs(t.Fragment,{children:[ge&&t.jsx(st,{text:ge,style:{fontSize:15,lineHeight:1.85}}),(P=e.history)!=null&&P.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((z,L)=>t.jsx("li",{children:u(z)},L))}):null]}):void 0,clampDescription:vi(ge)||(((T=e.history)==null?void 0:T.length)??0)>2?6:void 0,stats:me,facts:te,foot:t.jsx(Xt,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:pe&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:u("全帙冊次分佈")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":u("全帙冊次分佈"),children:pe.segs.map((z,L)=>{const B=Vt.find(G=>G.key===z.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!B,title:B?u(`${B.label} 第 ${z.from}–${z.to} 冊`):void 0,"aria-label":u(B?`只看${B.label}`:"未分類"),"aria-pressed":!!B&&y===z.key,style:{flexGrow:z.n,background:o(B?B.token:"rule")},onClick:()=>{B&&(j(y===z.key?"":z.key),b(!1))}},L)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:u(`第 1 ${d.unit.volume}`)}),t.jsx("span",{children:u("點色段篩選部類")}),t.jsx("span",{children:u(`第 ${pe.last} ${d.unit.volume}`)})]})]})}),ve=[];v.rows.length&&ve.push({id:"titles",label:"子目",count:v.rows.length}),M&&ve.push({id:"resources",label:"影印與全文",count:M}),K&&ve.push({id:"works",label:d.section.containedWorks,count:F.length});const we=t.jsxs(t.Fragment,{children:[v.rows.length>0&&t.jsxs(Me,{id:"titles",title:"子目",meta:t.jsx(We,{items:[u(`${v.rows.length} ${d.unit.items}`),v.totalVolumes?u(`全帙 ${v.totalVolumes} ${d.unit.volume}`):"",N.length!==v.rows.length?u(`當前 ${N.length} ${d.unit.items}`):""]}),action:l,children:[(v.rows.length>Pn||ie.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[ie.length>0&&t.jsx(wn,{items:ie,value:y,onChange:z=>{j(z),b(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),v.rows.length>Pn&&t.jsx("input",{type:"search",className:"bim-d-find",value:g,placeholder:u("在本叢編中檢索"),"aria-label":u("在本叢編中檢索"),onChange:z=>{x(z.target.value),b(!1)}})]}),t.jsxs("table",{className:"bim-d-zt",children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[oe&&t.jsx("th",{style:{width:"8.5em"},children:u("冊次")}),t.jsx("th",{children:u("書名")}),t.jsx("th",{style:{textAlign:"right"},children:u("版本")})]})}),t.jsx("tbody",{children:E.map((z,L)=>{var Ne;const B=z.id?_.get(z.id):void 0,G=B!=null&&B.title&&z.title===z.id?B.title:z.title,Z=((B==null?void 0:B.authors)||[]).find(je=>je&&je.name),ue=[Z?`${Z.dynasty?`〔${u(Z.dynasty)}〕`:""}${u(Z.name)}${Z.role?` ${u(Z.role)}`:""}`:"",B!=null&&B.measure?u(B.measure):"",(Ne=z.subItems)!=null&&Ne.length?z.subItems.map(je=>u(je)).join("、"):"",(B!=null&&B.edition||z.edition)&&!R?u((B==null?void 0:B.edition)||z.edition||""):""].filter(Boolean),le=Vt.find(je=>je.key===C(z.id)),be=z.volumes.length>0?u(`第 ${Sn(z.volumes,d.unit.volume)} ${d.unit.volume}`):z.expected!=null?u(`${z.found??0}/${z.expected} ${d.unit.volume}`):"";return t.jsxs("tr",{children:[oe&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${be?"":" bim-d-zt-blank"}`,children:[le&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:o(le.token)}}),be||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[z.id?t.jsx(Le,{id:z.id,label:u(G),onNavigate:r,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:u(G)}),ue.length>0?t.jsx(We,{items:ue}):z.id&&!B&&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${B!=null&&B.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:B!=null&&B.versionCount?u(`${B.versionCount} 種`):""})]},`${z.id??z.title}-${L}`)})})]}),E.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:u(d.catalog.noMatch)}),N.length>E.length&&t.jsx(Bt,{label:`展開其餘 ${N.length-E.length} ${d.unit.items}`,onClick:()=>b(!0)})]}),M>0&&t.jsxs(Me,{id:"resources",title:"影印與全文",meta:u(`${M} 處`),children:[A.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[A.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:u("全文")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:A.text.map((z,L)=>t.jsx(Di,{item:z,siblings:A.text},`${z.id||z.url||z.name}-${L}`))})})]}),t.jsx(el,{groups:A.groups})]}),v.rows.length===0&&M===0&&t.jsx(Me,{title:"子目",children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("尚未著錄該叢編的子目。")})})]}),Ee=K?t.jsx(ht,{id:"works",title:d.section.containedWorks,meta:u(`${F.length} 種`),cap:12,items:F.map(z=>t.jsx(Le,{id:z.id,label:u(z.title),onNavigate:r,renderLink:s,dense:!0}))}):null,Re=k?t.jsx(Xr,{caption:"上級叢編",children:t.jsx(Le,{id:k.id,label:u(k.title||k.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return t.jsx(Jt,{railTop:a,back:p,up:Re,nav:ve,railLinks:c,main:we,card:Ce,side:Ee})},ex=16,On=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function mr(e){if(!e)return On.length;const n=On.indexOf(e);return n===-1?On.length:n}const tx={people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群體"};function xt(e){return e==null?"":e<0?`前${-e}`:String(e)}const nx={秦:[-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]},ll=({data:e,transport:n,onNavigate:i,renderLink:r,railTop:s,back:l,railLinks:a})=>{var se,ne,he,q,P;const p=de(),{convert:c}=V(),[d,u]=f.useState("全部"),[g,x]=f.useState(!1),[m,b]=f.useState("default"),[k,h]=f.useState(new Map),y=f.useMemo(()=>(e.works||[]).map(T=>{const z=k.get(T.work_id);return{id:T.work_id,title:(z==null?void 0:z.title)??T.title??T.work_id,role:T.role||"",cls:yi(T.role),versionCount:z==null?void 0:z.versionCount,section:z==null?void 0:z.cls,l1:z==null?void 0:z.l1,measure:z==null?void 0:z.measure,hasImage:z==null?void 0:z.hasImage,loaded:!!(z!=null&&z.loaded)}}),[e.works,k]),j=f.useMemo(()=>Hr((e.works||[]).map(T=>T.role)),[e.works]),v=f.useMemo(()=>{const T=d==="全部"?y:y.filter(z=>z.cls===d);return m==="versions"?[...T].sort((z,L)=>(L.versionCount??-1)-(z.versionCount??-1)):T},[y,d,m]),_=g?v:v.slice(0,ex),S=f.useMemo(()=>_.filter(T=>!k.has(T.id)).map(T=>T.id),[_,k]);f.useEffect(()=>{if(!n||S.length===0)return;let T=!1;return Promise.all(S.map(z=>n.getItem(z).then(L=>{var ue,le,be,Ne,je;const B=L??{},G=B._edition_count??(((ue=B.books)==null?void 0:ue.length)??0)+(((le=B.collections)==null?void 0:le.length)??0),Z=[(be=B.classification)==null?void 0:be.l1,(Ne=B.classification)==null?void 0:Ne.l2].filter(Boolean).join(" ");return[z,{id:z,title:B.title,versionCount:G,loaded:!0,cls:Z||void 0,l1:((je=B.classification)==null?void 0:je.l1)||void 0,measure:L&<(L,p.unit.juan)||void 0,hasImage:!!(B.has_image??B._has_image)}]}).catch(()=>[z,{id:z,loaded:!0}]))).then(z=>{T||h(L=>{const B=new Map(L);for(const[G,Z]of z)B.set(G,Z);return B})}),()=>{T=!0}},[n,S,p.unit.juan]);const $=f.useMemo(()=>{const T=new Map;for(const z of e.alt_names||[]){const L=z.type||p.section.aliases;T.has(L)||T.set(L,[]),T.get(L).push(z.name)}return[...T.entries()].sort((z,L)=>mr(z[0])-mr(L[0])).map(([z,L])=>({label:z,names:L}))},[e.alt_names,p]),w=e.birth_year??((se=e.dates)==null?void 0:se.birth)??void 0,C=e.death_year??((ne=e.dates)==null?void 0:ne.death)??void 0,N=(he=e.dates)==null?void 0:he.floruit,E=w!=null||C!=null?`${xt(w)||"?"}—${xt(C)||"?"}`:Array.isArray(N)&&N.length===2&&N.every(T=>Number.isFinite(T))?`活躍於 ${xt(N[0])}—${xt(N[1])}`:"",I=new Set(["本名","字","號","号"]),O=$.filter(T=>I.has(T.label)),A=$.filter(T=>!I.has(T.label)),M=A.reduce((T,z)=>T+z.names.length,0),F=f.useMemo(()=>{const T=[];for(const L of O)T.push({label:L.label,value:L.names.map(B=>c(B)).join("、")});const z=(e.works||[]).length;return z&&T.push({label:"著作",value:`${z} ${c("種")}`}),T},[e.works,O,c]),Y=T=>{var z;return(z=$.find(L=>T.includes(L.label)))==null?void 0:z.names[0]},K=Y(["字"]),R=Y(["號","号"]),oe=[K?`字${K}`:"",R?`號${R}`:""].filter(Boolean).join(","),H=e.native_place,re=e.dynasty?nx[e.dynasty]:void 0,ee=(()=>{if(!re||w==null||C==null||C<w)return null;const[T,z]=re,L=Math.max(w,T),B=Math.min(C,z);if(B<=L)return null;const G=z-T;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(`${xt(w)}—${xt(C)},一生 ${C-w+1} 年`),children:t.jsx("i",{style:{left:`${(L-T)/G*100}%`,width:`${(B-L)/G*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:c(`${xt(T)} ${e.dynasty}`)}),t.jsx("span",{children:c(`一生 ${C-w+1} 年`)}),t.jsx("span",{children:xt(z)})]})]})})(),Q=f.useMemo(()=>{if(!n||y.length===0||y.some(L=>!L.loaded))return null;const T=new Map;for(const L of y){const B=si(L.l1);B&&T.set(B,(T.get(B)??0)+1)}const z=Vt.map(L=>({...L,n:T.get(L.key)??0})).filter(L=>L.n>0);return z.length?z:null},[y,n]),J=t.jsxs(Zt,{kind:tx[e.subtype]??"人物",title:c(e.primary_name||e.title),subtitle:oe?c(oe):void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(We,{items:[e.dynasty?c(e.dynasty):"",E?c(E):"",H?c(`${H}人`):""]}),ee]}),description:(q=e.description)!=null&&q.text?t.jsx(st,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:vi((P=e.description)==null?void 0:P.text)?6:void 0,facts:F,foot:t.jsx(Xt,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[M>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c(`更多別名(${M})`)}),t.jsx("dl",{children:A.map(T=>t.jsxs(f.Fragment,{children:[t.jsx("dt",{children:c(T.label)}),t.jsx("dd",{children:T.names.map(z=>c(z)).join("、")})]},T.label))})]}),Q&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:c("著作分佈")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:Q.map(T=>t.jsx("i",{style:{flexGrow:T.n,background:o(T.token)}},T.key))}),t.jsx("div",{className:"bim-d-dist-key",children:Q.map(T=>t.jsxs("span",{children:[t.jsx("i",{style:{background:o(T.token)}}),c(T.label)," ",T.n]},T.key))})]})]}),ce=f.useMemo(()=>y.filter(T=>T.loaded&&(T.versionCount??0)>0).sort((T,z)=>(z.versionCount??0)-(T.versionCount??0)).slice(0,3),[y]),me=!!n&&y.length>=3&&_.some(T=>!T.loaded),te=d==="全部"&&(me||ce.length>=2),ie=e.external_ids||{},pe=[];ie.cbdb_id!=null&&pe.push({label:"CBDB",id:String(ie.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${ie.cbdb_id}`,note:ie.cbdb_match==="auto"?"自動匹配":void 0});const ge=ie.wikidata_id;ge&&pe.push({label:"Wikidata",id:ge,href:`https://www.wikidata.org/wiki/${ge}`});const Ce=ie.viaf_id;Ce&&pe.push({label:"VIAF",id:Ce,href:`https://viaf.org/viaf/${Ce}`});const ve=j.map(T=>({key:T.cls,label:`${T.label} ${T.count}`})),we=[...te&&!me?[{id:"featured",label:"著作舉要",count:ce.length}]:[],...y.length?[{id:"works",label:"全部著作",count:y.length}]:[],...pe.length?[{id:"external",label:"站外資料",count:pe.length}]:[]],Ee=te?t.jsxs(Me,{id:"featured",title:"著作舉要",children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:c("存世版本最多的三部")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":me||void 0,children:[me&&[0,1,2].map(T=>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:" "})]},T)),!me&&ce.map(T=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(Le,{id:T.id,label:c(T.title),onNavigate:i,renderLink:r,dense:!0})}),t.jsx(We,{items:[T.section?c(T.section):"",T.measure?c(T.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:T.versionCount}),t.jsx("span",{children:c("種版本")}),T.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("有影印")})]})]},T.id))]})]}):null,Re=y.length===0?t.jsx(Me,{title:"著作",children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("尚未著錄該人物的關聯作品。")})}):t.jsxs(t.Fragment,{children:[Ee,t.jsxs(Me,{id:"works",title:"著作",meta:t.jsx(We,{items:[c(`共 ${y.length} 種`),v.length!==y.length?c(`當前 ${v.length} 種`):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[ve.length>1&&t.jsx(wn,{items:ve,value:d,onChange:T=>{u(T),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":m==="versions",onClick:()=>{m==="default"&&x(!0),b(T=>T==="default"?"versions":"default")},children:c(m==="default"?"按版本數排列":"按著錄順序")})]}),t.jsxs("table",{className:"bim-d-zt",children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("作品")}),t.jsx("th",{children:c("部類")}),t.jsx("th",{children:c("職任")}),t.jsx("th",{children:c("存世版本")}),t.jsx("th",{"aria-label":c("影印")})]})}),t.jsx("tbody",{children:_.map(T=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Le,{id:T.id,label:c(T.title),onNavigate:i,renderLink:r,dense:!0}),T.measure?t.jsx(We,{items:[c(T.measure)]}):!T.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${T.section||T.loaded?"":" bim-d-zt-blank"}`,children:T.section?c(T.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${T.role?"":" bim-d-zt-blank"}`,children:T.role?c(T.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${T.loaded?"":" bim-d-zt-blank"}`,children:T.loaded?T.versionCount?c(`${T.versionCount} 種`):t.jsx("span",{className:"bim-d-zt-empty",children:c("未著錄")}):""}),t.jsx("td",{className:T.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:T.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("有影印")})})]},T.id))})]}),_.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("該職任下的著作尚未著錄。")}),v.length>_.length&&t.jsx(Bt,{label:`展開其餘 ${v.length-_.length} 種著作`,onClick:()=>x(!0)})]})]}),D=pe.length>0?t.jsx(ht,{id:"external",title:"站外資料",items:pe.map(T=>t.jsxs("a",{href:T.href,target:"_blank",rel:"noopener noreferrer",children:[T.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:pe.map(T=>T.id),foot:ie.cbdb_id!=null&&ie.cbdb_match==="auto"?c("CBDB 為自動匹配,未經人工核對"):void 0}):null;return t.jsx(Jt,{railTop:s,back:l,nav:we,railLinks:a,main:Re,card:J,side:D})},Gi="(max-width: 719px)",ix=`${Gi}, (pointer: coarse)`,al=`
|
|
828
|
+
`;function _i(e,n){var o;return n?e.key===n?!0:!!((o=e.children)!=null&&o.some(r=>_i(r,n))):!1}const Dc=()=>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 Hc({item:e,activeKey:n,onSelect:o,tabKey:r}){const s=_i(e,n),[l,d]=g.useState(s||!!e.defaultExpanded);return g.useEffect(()=>{s&&d(!0)},[s]),g.useEffect(()=>{e.defaultExpanded&&d(!0)},[e.defaultExpanded]),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:r===e.key?0:-1,onClick:()=>d(p=>!p),children:[t.jsx(Dc,{}),t.jsx("span",{children:e.label}),e.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:e.hint})]}),l&&t.jsx(gs,{items:e.children,activeKey:n,onSelect:o,tabKey:r})]})}function gs({items:e,activeKey:n,onSelect:o,tabKey:r}){return t.jsx("ul",{children:e.map(s=>s.children&&s.children.length>0?t.jsx(Hc,{item:s,activeKey:n,onSelect:o,tabKey:r},s.key):t.jsx("li",{children:t.jsxs("button",{type:"button",className:"bim-rd-ti","aria-current":s.key===n?"true":void 0,disabled:s.disabled,"data-rd-toc-key":s.key,tabIndex:r===s.key?0:-1,onClick:()=>o(s.key),children:[t.jsx("span",{children:s.label}),s.hint!=null&&t.jsx("span",{className:"bim-rd-hint",children:s.hint})]})},s.key))})}function Io(e,n){var o;for(const r of e)if(r.key===n||_i(r,n))return r.key;return((o=e[0])==null?void 0:o.key)??null}function ms({items:e,activeKey:n,onSelect:o,label:r="目录"}){const s=g.useRef(null),[l,d]=g.useState(null);g.useEffect(()=>{d(null)},[n]);const p=g.useMemo(()=>l||(n??Io(e,n)),[l,n,e]);g.useEffect(()=>{const a=s.current;if(!a)return;const u=Array.from(a.querySelectorAll("[data-rd-toc-key]"));if(u.length===0)return;const f=u.find(x=>x.dataset.rdTocKey===p)??u.find(x=>x.dataset.rdTocKey===Io(e,n))??u.find(x=>!x.disabled)??u[0];for(const x of u)x.tabIndex=x===f?0:-1}),g.useEffect(()=>{const a=s.current,u=a==null?void 0:a.closest(".bim-rd-toc");if(!a||!u||!n)return;const f=Array.from(a.querySelectorAll("[data-rd-toc-key]")).find(m=>m.dataset.rdTocKey===n);if(!f)return;const x=f.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 c=g.useCallback(a=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(a.key))return;const f=s.current;if(!f)return;const x=Array.from(f.querySelectorAll("[data-rd-toc-key]")).filter(h=>!h.disabled),m=x.indexOf(document.activeElement);let j=m;if(a.key==="ArrowDown"?j=Math.min(x.length-1,m+1):a.key==="ArrowUp"?j=Math.max(0,m-1):a.key==="Home"?j=0:a.key==="End"&&(j=x.length-1),j<0||j===m)return;a.preventDefault();const w=x[j];for(const h of x)h.tabIndex=-1;w.tabIndex=0,w.focus(),d(w.dataset.rdTocKey??null)},[]);return t.jsx("div",{ref:s,role:"navigation","aria-label":r,onKeyDown:c,children:t.jsx(gs,{items:e,activeKey:n,onSelect:o,tabKey:p})})}function Gc({page:e}){var n;return!((n=e.boxes)!=null&&n.length)||!e.width||!e.height||e.boxFormat&&e.boxFormat!=="bim-charbox-v0"?null:t.jsx("svg",{viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none","aria-hidden":"true",children:e.boxes.map((o,r)=>t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:"none",stroke:i("accent"),strokeOpacity:.55,vectorEffect:"non-scaling-stroke",strokeWidth:1},r))})}function hs({pages:e,loading:n,page:o,onPageChange:r,renderOverlay:s}){const[l,d]=g.useState(0),p=o??l,c=x=>{r?r(x):d(x)};if(g.useEffect(()=>{o===void 0&&d(0)},[e,o]),n)return t.jsx("div",{className:"bim-rd-img-box",children:t.jsx("div",{className:"bim-rd-img-empty",children:"加载书影…"})});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:"暂无书影"}),t.jsx("span",{children:"这一卷还没有配上影像;接入后在此与正文逐页对看"})]})});const a=Math.max(0,Math.min(e.length-1,p)),u=e[a],f=u.label??`${a+1}`;return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-rd-img-box",children:t.jsxs("figure",{className:"bim-rd-img-fig",children:[t.jsx("img",{src:u.url,alt:u.alt??`书影 第 ${f} 页`,width:u.width,height:u.height,loading:"lazy",decoding:"async"}),t.jsx(Gc,{page:u}),s==null?void 0:s(u,a)]})}),e.length>1&&t.jsxs("div",{className:"bim-rd-img-pager",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"上一页书影",disabled:a===0,onClick:()=>c(a-1),children:"‹"}),t.jsx("span",{"aria-live":"polite",children:u.label??`${a+1} / ${e.length}`}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"下一页书影",disabled:a===e.length-1,onClick:()=>c(a+1),children:"›"})]})]})}const $i={fontSize:null,readingMode:"line",properNames:!1,writingMode:"horizontal",workLinks:!0},$t=[15,16,17,18,20,22,24],Qn=18,bs="bim-reader-prefs",Uc="bim-reading-mode";function Vc(){const e={...$i};try{const n=localStorage.getItem(bs),o=n?JSON.parse(n):{};typeof o.fontSize=="number"&&$t.includes(o.fontSize)&&(e.fontSize=o.fontSize),(o.readingMode??localStorage.getItem(Uc))==="paragraph"&&(e.readingMode="paragraph"),o.properNames===!0&&(e.properNames=!0),o.writingMode==="vertical"&&(e.writingMode="vertical"),o.workLinks===!1&&(e.workLinks=!1)}catch{}return e}function Yc(e){try{localStorage.setItem(bs,JSON.stringify(e))}catch{}}function To(e,n){const o=e??Qn,r=$t;let s=r.indexOf(o);return s<0&&(s=r.indexOf(Qn)),r[Math.max(0,Math.min(r.length-1,s+n))]}function zi(){const[e,n]=g.useState($i);g.useEffect(()=>{n(Vc())},[]);const o=g.useCallback(r=>{n(s=>{const l={...s,...r};return Yc(l),l})},[]);return[e,o]}function ys(e){return e.map(n=>({key:n.key,label:n.version_label||n.key,sourceName:n.source_name,license:n.license,sourceUrl:n.source_url,primary:n.primary}))}function ei(e){const n=e.label||e.key;return!e.sourceName||n.includes(e.sourceName)?n:`${n} · ${e.sourceName}`}function js(e,n){if(!(!e||e.length===0))return(n!=null?e.find(o=>o.key===n):void 0)??e.find(o=>o.primary)??e[0]}function vs(e){const n=[],o=r=>{for(const s of r)s.children&&s.children.length>0?o(s.children):n.push(s)};return o(e),n}const qc=()=>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"})}),Kc=()=>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 Jc(e,n){if(!n)return;const o=Array.from(n.querySelectorAll('button:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(d=>d.tabIndex>=0);if(o.length===0)return;const r=o[0],s=o[o.length-1],l=document.activeElement;e.shiftKey&&(l===r||!n.contains(l))?(e.preventDefault(),s.focus()):!e.shiftKey&&(l===s||!n.contains(l))&&(e.preventDefault(),r.focus())}function Zc(e,n){const[o,r]=g.useState(n);return g.useEffect(()=>{var d;if(typeof window>"u"||!window.matchMedia)return;const s=window.matchMedia(e);r(s.matches);const l=()=>r(s.matches);return(d=s.addEventListener)==null||d.call(s,"change",l),()=>{var p;return(p=s.removeEventListener)==null?void 0:p.call(s,"change",l)}},[e]),o}function Xc(){const e=g.useContext(Rt);if(!e)return null;const n=e.locale==="zh-Hant";return t.jsxs("button",{type:"button",className:"bim-rd-t",title:n?"切换为简体":"切換為繁體","aria-label":n?"切换为简体":"切換為繁體",onClick:()=>e.setLocale(n?"zh-Hans":"zh-Hant"),children:[t.jsx("span",{className:n?"bim-rd-on":"bim-rd-off",children:"繁"}),t.jsx("span",{className:"bim-rd-off",children:"|"}),t.jsx("span",{className:n?"bim-rd-off":"bim-rd-on",children:"简"})]})}function Ci({title:e,subtitle:n,toc:o,activeKey:r,onSelect:s,tocHeader:l,tocCaption:d,images:p,imagesLoading:c,renderImageOverlay:a,imagePanel:u="auto",prefs:f,onPrefsChange:x,paragraphToggle:m,properNameToggle:j=!0,allowVertical:w,byline:h,current:b,workLinkToggle:y,rail:k,pager:$=!0,pagerUnit:v="卷",versions:_,currentVersionKey:S,onVersionChange:z,versionSource:N=!0,children:T,className:C,style:D}){const B=g.useId().replace(/:/g,""),O=`bim-rd-toc-${B}`,M=`bim-rd-text-${B}`,X=g.useRef(null),Y=g.useRef(null),E=g.useRef(null),ee=g.useRef(null),F=Zc(us,!0),[q,ae]=g.useState("auto"),ne=q==="auto"?F:q==="open",Q=!F,ie=!!p&&p.length>0,[ge,re]=g.useState(u);g.useEffect(()=>{re(u)},[u]);const le=ge==="auto"?ie||!!c:ge==="open",pe=g.useCallback(A=>{var I;ae("auto"),A&&((I=ee.current)==null||I.focus())},[]),Re=()=>ae(ne?"closed":"open");g.useEffect(()=>{if(!Q||q!=="open")return;const A=E.current,I=A==null?void 0:A.querySelector('input, [data-rd-toc-key][tabindex="0"]');I==null||I.focus()},[Q,q]);const $e=g.useCallback(A=>{s(A),Q&&pe(!1);const I=Y.current,G=X.current;if(I&&G&&typeof window<"u"){const P=I.getBoundingClientRect().top-G.getBoundingClientRect().bottom;P<0&&window.scrollBy({top:P})}},[s,Q,pe]),ye=g.useMemo(()=>vs(o),[o]),[Se,Ne]=g.useState(null),je=js(_,S!==void 0?S:Se),H=(je==null?void 0:je.key)??null,ce=g.useMemo(()=>ye.map(A=>A.key).join(`
|
|
829
|
+
`),[ye]),oe=g.useRef(null),he=A=>{A!==H&&(oe.current={key:A,sig:ce,done:!1},S===void 0&&Ne(A),z==null||z(A))};g.useEffect(()=>{const A=oe.current;if(!A||A.key!==H)return;const I=ye.find(P=>!P.disabled);if(!I)return;const G=ce!==A.sig;!G&&A.done||(G?oe.current=null:A.done=!0,I.key!==r&&$e(I.key))},[H,ce,ye,r,$e]);const me=ye.findIndex(A=>A.key===r),U=me>0?ye.slice(0,me).reverse().find(A=>!A.disabled):void 0,R=me>=0?ye.slice(me+1).find(A=>!A.disabled):void 0,V=f.fontSize??Qn,W={...D,...f.fontSize?{"--bimrd-fs":`${f.fontSize}px`}:null};return t.jsxs("div",{className:["bim-rd",f.writingMode==="vertical"&&w?"bim-rd-vertical":"",C].filter(Boolean).join(" "),"data-toc":q,"data-img":le?"open":"closed",style:W,children:[t.jsx("style",{children:fs}),t.jsx("a",{className:"bim-rd-skip",href:`#${M}`,onClick:A=>{var I,G,P;A.preventDefault(),(I=Y.current)==null||I.focus(),(P=(G=Y.current)==null?void 0:G.scrollIntoView)==null||P.call(G,{block:"start"})},children:"跳到正文"}),t.jsxs("div",{className:"bim-rd-bar",ref:X,children:[(e||n||h||b)&&t.jsxs("p",{className:"bim-rd-ttl",style:{margin:0},children:[e&&t.jsx("b",{children:e}),h&&t.jsx("span",{className:"bim-rd-by",children:h}),b&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot","aria-hidden":"true"}),t.jsx("span",{className:"bim-rd-cur",children:b})]}),n&&t.jsx("span",{children:n})]}),t.jsxs("div",{className:"bim-rd-tools",role:"group","aria-label":"阅读设置",children:[_&&_.length>1&&t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"bim-rd-ver",title:je?ei(je):void 0,children:[t.jsx("span",{className:"bim-rd-tlabel",children:"版本"}),t.jsx("span",{className:"bim-rd-ver-short","aria-hidden":"true",children:"版本▾"}),t.jsx("select",{"aria-label":"版本",value:H??"",onChange:A=>he(A.target.value),children:_.map(A=>t.jsx("option",{value:A.key,children:ei(A)},A.key))})]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"})]}),t.jsxs("button",{ref:ee,type:"button",className:"bim-rd-t","aria-expanded":ne,"aria-controls":O,onClick:Re,children:[t.jsx(qc,{}),t.jsx("span",{className:"bim-rd-tlabel",children:"目录"})]}),t.jsxs("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":le,onClick:()=>re(le?"closed":"open"),children:[t.jsx(Kc,{}),"书影"]}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx(Xc,{}),t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs","aria-label":"缩小字号",disabled:V<=$t[0],onClick:()=>x({fontSize:To(f.fontSize,-1)}),children:"A−"}),t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-fs","aria-label":"放大字号",disabled:V>=$t[$t.length-1],onClick:()=>x({fontSize:To(f.fontSize,1)}),children:"A+"}),(m||j||w)&&t.jsx("span",{className:"bim-rd-sep","aria-hidden":"true"}),m&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":f.readingMode==="paragraph",title:"条目分行 ↔ 自然段",onClick:()=>x({readingMode:f.readingMode==="paragraph"?"line":"paragraph"}),children:"自然段"}),y&&t.jsxs("label",{className:"bim-rd-t bim-rd-chk",children:[t.jsx("input",{type:"checkbox",checked:f.workLinks,onChange:A=>x({workLinks:A.target.checked})}),t.jsx("span",{children:"标出作品链接"})]}),j&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":f.properNames,title:"书名加波浪线",onClick:()=>x({properNames:!f.properNames}),children:"专名线"}),w&&t.jsx("button",{type:"button",className:"bim-rd-t bim-rd-hide-narrow","aria-pressed":f.writingMode==="vertical",onClick:()=>x({writingMode:f.writingMode==="vertical"?"horizontal":"vertical"}),children:"竖排"})]})]}),t.jsxs("div",{className:"bim-rd-body",children:[t.jsxs("div",{className:"bim-rd-toc",id:O,ref:E,role:Q&&ne?"dialog":void 0,"aria-modal":Q&&ne?!0:void 0,"aria-label":Q&&ne?"目录":void 0,onKeyDown:A=>{if(!(!Q||!ne)){if(A.key==="Escape"){A.stopPropagation(),pe(!0);return}A.key==="Tab"&&Jc(A,E.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??"目录"}),Q&&t.jsx("button",{type:"button",className:"bim-rd-t","aria-label":"收起目录",onClick:()=>pe(!0),children:"✕"})]}),l]}),t.jsx(ms,{items:o,activeKey:r,onSelect:$e})]}),t.jsx("div",{className:"bim-rd-scrim","aria-hidden":"true",onClick:()=>pe(!0)}),t.jsx("aside",{className:"bim-rd-img","aria-label":"书影",children:le&&t.jsx(hs,{pages:p??null,loading:c,renderOverlay:a})}),t.jsxs("div",{className:"bim-rd-text",id:M,ref:Y,tabIndex:-1,"data-rail":k?"true":void 0,children:[t.jsxs("div",{className:"bim-rd-col",children:[T,N&&je&&(je.sourceName||je.license)&&t.jsxs("p",{className:"bim-rd-src","data-version":je.key,children:[je.sourceName&&t.jsxs(t.Fragment,{children:["出处"," ",je.sourceUrl?t.jsx("a",{className:"bim-rd-link",href:je.sourceUrl,target:"_blank",rel:"noreferrer",children:je.sourceName}):je.sourceName]}),je.sourceName&&je.license&&t.jsx("span",{className:"bim-rd-dot"}),je.license&&t.jsxs(t.Fragment,{children:["授权 ",je.license]})]}),$&&(U||R)&&t.jsxs("nav",{className:"bim-rd-pager","aria-label":"翻卷",children:[U?t.jsxs("button",{type:"button",className:"bim-rd-pg",onClick:()=>$e(U.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:[t.jsx("span",{"aria-hidden":"true",children:"← "}),"上一",v]}),t.jsx("span",{className:"bim-rd-pglabel",children:U.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-end","aria-hidden":"true",children:["← 已是第一",v]}),R?t.jsxs("button",{type:"button",className:"bim-rd-pg bim-rd-pg-next",onClick:()=>$e(R.key),children:[t.jsxs("span",{className:"bim-rd-pgcap",children:["下一",v,t.jsx("span",{"aria-hidden":"true",children:" →"})]}),t.jsx("span",{className:"bim-rd-pglabel",children:R.label})]}):t.jsxs("span",{className:"bim-rd-pg bim-rd-pg-next bim-rd-pg-end","aria-hidden":"true",children:["已是最后一",v," →"]})]})]}),k&&t.jsx("aside",{className:"bim-rd-rail","aria-label":"本卷",children:k})]})]})]})}const ks="guji-table-v1";function ws(e){return!!e&&e.table_notation===ks}const Qc=/^:::table(?:\{[^}]*\})?[ \t]*$/,ed=/^:::[ \t]*$/;function Ss(e){const n=[];let o="";for(let r=0;r<e.length;r++){const s=e[r];if(s===":"&&e.startsWith(":zi[",r)){const d=qr(e,r+3);if(d>r+4){o+=e.slice(r,d+1),r=d;continue}}let l=null;if(s==="⟨")l="⟩";else if(s==="<"){const d=e[r+1];d!==void 0&&!/[A-Za-z/!?>\s]/.test(d)&&(l=">")}if(l){const d=e.indexOf(l,r+1);if(d>0){o+=e.slice(r,d+1),r=d;continue}}s==="|"?(n.push(o),o=""):o+=s}return n.push(o),n.map(r=>r.trim())}const td=/^([\s\S]*?)(?:\{(\d+)\})?(?:\^(\d+))?$/;function nd(e){if(e==="^")return{cont:!0};const n=td.exec(e),o=n[1].trim(),r=n[2]?Math.max(1,parseInt(n[2],10)):1,s=n[3]?Math.max(1,parseInt(n[3],10)):1,l=o==="_";return{cont:!1,cell:{text:l?"":o,empty:l,colspan:r,rowspan:s}}}function _s(e,n=1){const o=[],r=[],s=[];let l=[];e.forEach((p,c)=>{const a=c+n+1;let u=p.trim();if(!u)return;let f=!1;u.startsWith("!")&&(f=!0,u=u.slice(1));const x=Ss(u).map(nd),m=l.map(b=>b>0),j=l.map(b=>b>0?b-1:0),w=[];let h=0;for(const b of x){if(b.cont){m[h]||o.push(`第 ${a} 行第 ${h+1} 列:续格 ^ 上方没有跨行格`),h+=1;continue}const{cell:y}=b;for(let k=h;k<h+y.colspan;k++)if(m[k]){o.push(`第 ${a} 行第 ${k+1} 列:此处被上方跨行格占住,应写 ^`);break}if(y.rowspan>1)for(let k=h;k<h+y.colspan;k++)j[k]=y.rowspan-1;w.push(y),h+=y.colspan}for(let b=h;b<m.length;b++)m[b]&&o.push(`第 ${a} 行第 ${b+1} 列:被上方跨行格占住,但本行缺续格 ^`);for(let b=0;b<j.length;b++)j[b]===void 0&&(j[b]=0);l=j,r.push({header:f,cells:w}),s.push({width:h,line:a})});const d=s.reduce((p,c)=>Math.max(p,c.width),0);for(const p of s)p.width!==d&&o.push(`第 ${p.line} 行:占 ${p.width} 列,与总列数 ${d} 不符`);return l.some(p=>p>0)&&o.push("表尾:有跨行格超出了表的最后一行"),r.length===0&&o.push("空表"),{rows:r,columns:d,warnings:o}}function Ii(e){const n=e.split(`
|
|
830
|
+
`),o=[];let r=[];const s=()=>{if(r.length===0)return;const d=r.join(`
|
|
831
|
+
`);r=[],o.push({type:"text",text:d})};let l=0;for(;l<n.length;){if(Qc.test(n[l].trim())){let d=l+1;for(;d<n.length&&!ed.test(n[d].trim());)d++;if(d<n.length){s();const p=n.slice(l+1,d);o.push({type:"table",table:_s(p,l+1),source:n.slice(l,d+1).join(`
|
|
832
|
+
`)}),l=d+1;continue}}r.push(n[l]),l++}return s(),o.map((d,p)=>{var a,u;if(d.type!=="text")return d;let c=d.text;return((a=o[p-1])==null?void 0:a.type)==="table"&&(c=c.replace(/^\n+/,"")),((u=o[p+1])==null?void 0:u.type)==="table"&&(c=c.replace(/\n+$/,"")),{type:"text",text:c}}).filter(d=>d.type!=="text"||d.text!=="")}const id={overflowX:"auto",WebkitOverflowScrolling:"touch",margin:"0.8em 0",maxWidth:"100%"},od={borderCollapse:"collapse",fontSize:"0.9em",lineHeight:1.6,whiteSpace:"normal"},rd=`1px solid ${i("table-border")}`,$s={border:rd,padding:"4px 8px",verticalAlign:"top",textAlign:"left",minWidth:"3em"},sd={...$s,background:i("table-head-bg"),fontWeight:600};function Ti({table:e,opts:n}){return t.jsx("div",{className:"bim-guji-table-wrap",style:id,children:t.jsx("table",{className:"bim-guji-table",style:od,children:t.jsx("tbody",{children:e.rows.map((o,r)=>t.jsx("tr",{children:o.cells.map((s,l)=>{const d=o.header?"th":"td";return t.jsx(d,{colSpan:s.colspan>1?s.colspan:void 0,rowSpan:s.rowspan>1?s.rowspan:void 0,style:o.header?sd:$s,children:s.empty?null:Ue(s.text,void 0,n)},l)})},r))})})})}function ld(e,n){return e.indexOf("**")<0?Ue(e,void 0,n):e.split(/(^\*\*[^*\n]+\*\*[ \t]*$)/m).map((r,s)=>s%2===1?t.jsx("strong",{children:Ue(r.trim().slice(2,-2),void 0,n)},s):t.jsx(g.Fragment,{children:Ue(r,void 0,n)},s))}function ad(e,n,o=!1){const r=o?{gujiMarkdown:!0}:void 0;return n?Ii(e).map((s,l)=>s.type==="table"?t.jsx(Ti,{table:s.table,opts:r},l):t.jsx(g.Fragment,{children:ld(s.text,r)},l)):Ue(e,void 0,r)}const cd=/^(#{1,6})\s+(.*)$/,dd=/^\*\*([^*\n]+)\*\*\s*$/;function Ei(e){const n=e.match(cd);if(n)return{level:n[1].length,text:n[2].trim()};const o=e.trim().match(dd);return o?{level:3,text:o[1].trim()}:null}const Ri=/^<!--.*-->$/;function zs(e){return e.split(/\n\s*\n/).map(n=>n.trim()).filter(Boolean)}function Cs(e){return e.split(`
|
|
833
|
+
`).map(n=>n.trim()).filter(n=>n&&!Ri.test(n))}const pd=60;function Is(e){let n=0,o=0;for(const r of e.split(`
|
|
834
|
+
`)){const s=r.trim();if(!s||Ri.test(s)||Ei(s))continue;const l=s.replace(/<[^<>\n]*>|\u27e8[^\u27e9\n]*\u27e9/g,"").replace(/\s/g,"").length;n+=l,l>pd&&(o+=l)}return n>0&&o*2>=n}function ud(e){return e.replace(/^[ \t]*:::table[^\n]*\n[\s\S]*?^[ \t]*:::[ \t]*$/gm,"")}function zn(e){if(e=ud(e),Is(e))return"unknown";const n=zs(e);if(n.length===0)return"unknown";if(n.length===1)return"catalog";const o=n.map(s=>Cs(s).length).filter(s=>s>0);if(o.length===0)return"unknown";const r=o.reduce((s,l)=>s+l,0)/o.length;return r<=4?"record":r>=8?"catalog":"unknown"}function xd(e){const n=e.split(`
|
|
835
|
+
`),o=[];let r=null,s=[];const l=()=>{o.push({heading:r,body:s.join(`
|
|
836
|
+
`)}),s=[]};for(const d of n){const p=Ei(d);if(p){l(),r={kind:"heading",level:p.level,text:p.text};continue}s.push(d)}return l(),o}function Eo(e){const n=[];for(const o of e.split(`
|
|
837
|
+
`)){const r=Ei(o);if(r){n.push({kind:"heading",level:r.level,text:r.text});continue}const s=o.trim();!s||Ri.test(s)||n.push({kind:"body",text:o})}return n}function Ts(e){if(!e)return[];const n=zn(e);if(n==="unknown")return Eo(e);const o=[];for(const{heading:r,body:s}of xd(e)){r&&o.push(r);const l=zs(s);if(l.length!==0){if(Is(s)){o.push(...Eo(s));continue}if(n==="record"){const d=l.join(" ");d&&o.push({kind:"body",text:d})}else for(const d of l){const p=Cs(d);p.length&&o.push({kind:"body",text:p.join(" ")})}}}return o}const Es=e=>e;function Rs(e,n=Es){if(e.indexOf("《")<0)return n(e);const o=[],r=/《([^《》\n]+)》/g;let s=0,l=0,d;for(;d=r.exec(e);)d.index>s&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s,d.index))},l++)),o.push(t.jsxs("span",{className:"bim-rd-pn",children:[t.jsx("span",{className:"bim-rd-sr",children:"《"}),n(d[1]),t.jsx("span",{className:"bim-rd-sr",children:"》"})]},l++)),s=d.index+d[0].length;return s===0?n(e):(s<e.length&&o.push(t.jsx(g.Fragment,{children:n(e.slice(s))},l++)),o)}function Ni(e,n={}){const o=n.renderText??Es,r=n.properNames?l=>Rs(l,o):o,s=n.gujiMarkdown?{gujiMarkdown:!0}:void 0;return Ue(e,r,s)}function Ro(e,n,o){return e.indexOf("**")<0?n(e):e.split(/(\*\*[^*]+\*\*)/g).map((s,l)=>s.startsWith("**")&&s.endsWith("**")&&s.length>4?t.jsx("strong",{children:n(s.slice(2,-2))},`${o}-${l}`):t.jsx(g.Fragment,{children:n(s)},`${o}-${l}`))}const Bn=/^(#{1,6})\s+(.*)$/,fd=/^\s*<!--.*-->\s*$/;function Ns(e){return e.replace(/<!--[\s\S]*?-->/g,n=>n.includes(`
|
|
838
|
+
`)?"":n)}function gd(e){return e<=1?2:e===2?3:4}function md(){let e=1;return n=>{const o=gd(n),r=Math.min(o,e+1);return e=r,{Tag:`h${r}`,className:`bim-rd-hl${o}`}}}function qt(e){return e?zn(Ns(e))!=="unknown":!1}function No({text:e,mode:n,inline:o,dropTitle:r}){const s=Ns(e),l=(a,u,f)=>!!r&&f<=1&&a<=2&&u.trim()===r.trim(),d=md();if(n==="paragraph"&&zn(s)!=="unknown"){const a=Ts(s);return t.jsx(t.Fragment,{children:a.map((u,f)=>{if(u.kind==="heading"){if(l(u.level??1,u.text,f))return null;const{Tag:x,className:m}=d(u.level??1);return t.jsx(x,{className:m,children:o(u.text)},f)}return t.jsx("p",{children:Ro(u.text,o,f)},f)})})}const p=s.split(`
|
|
839
|
+
`);let c=0;return t.jsx(t.Fragment,{children:p.map((a,u)=>{const f=a.match(Bn);if(f){const m=c++;if(l(f[1].length,f[2],m))return null;const{Tag:j,className:w}=d(f[1].length);return t.jsx(j,{className:w,children:o(f[2])},u)}if(!a.trim())return u>=2&&!!p[u-1].trim()&&!!p[u-2].trim()&&!Bn.test(p[u-1])&&!Bn.test(p[u-2])?t.jsx("div",{className:"bim-rd-gap","aria-hidden":"true"},u):null;if(fd.test(a))return null;if(c++,/^\*\*[^*]+\*\*\s*$/.test(a.trim())){const{Tag:m,className:j}=d(3);return t.jsx(m,{className:j,children:o(a.trim().slice(2,-2))},u)}return t.jsx("p",{children:Ro(a,o,u)},u)})})}function hd(e){const{convert:n}=Z();return g.useMemo(()=>e?n(e):"",[e,n])}function Li({text:e,mode:n,tables:o=!1,gujiMarkdown:r=!1,properNames:s=!1,renderText:l,dropTitle:d}){const p=hd(e),{convert:c}=Z(),a=x=>Ni(x,{renderText:l,properNames:s,gujiMarkdown:r}),u=r?{gujiMarkdown:!0}:void 0,f=d?c(d):void 0;return!o||p.indexOf(":::")<0?t.jsx(No,{text:p,mode:n,inline:a,dropTitle:f}):t.jsx(t.Fragment,{children:Ii(p).map((x,m)=>x.type==="table"?t.jsx(Ti,{table:x.table,opts:u},m):t.jsx(No,{text:x.text,mode:n,inline:a,dropTitle:m===0?f:void 0},m))})}function Ls(e,n){const[o,r]=g.useState(null),[s,l]=g.useState(!1),d=g.useRef(0);return g.useEffect(()=>{const p=++d.current;if(!e||!n){r(null),l(!1);return}let c;try{c=e(n)}catch{r(null),l(!1);return}if(!c||typeof c.then!="function"){r(c??null),l(!1);return}l(!0),c.then(a=>{p===d.current&&r(a??null)}).catch(()=>{p===d.current&&r(null)}).finally(()=>{p===d.current&&l(!1)})},[e,n]),{images:o,loading:s}}const Lo={A:"fine",B:"rough",C:"rough",D:"ocr"};function bd(e){return typeof e!="string"?null:e in Hn?e:e in Lo?Lo[e]:null}const yd={書:"书",類:"类",結語:"结语",結语:"结语",考證:"考证",詩:"诗"},jd={book:"书",poem:"诗",category:"类",preface:"序",verification:"考证",prose:"书",reconstruction:"书",comment:"注释"};function Ye(e){return typeof e!="string"?"":yd[e]??jd[e]??e}const vd=["〇","一","二","三","四","五","六","七","八","九"],Bo=["","十","百","千"],kd=["","萬","億"];function Bi(e){if(e===0)return"〇";if(e<0)return`負${Bi(-e)}`;const n=[];let o=e,r=0;for(;o>0;){const s=o%1e4;s>0?n.unshift(wd(s,r>0)+kd[r]):n.length>0&&n.unshift("〇"),o=Math.floor(o/1e4),r++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function wd(e,n){const o=[];let r=e;for(;r>0;)o.unshift(r%10),r=Math.floor(r/10);let s="";for(let l=0;l<o.length;l++){const d=o[l],p=o.length-1-l;d===0?s&&!s.endsWith("〇")&&(s+="〇"):d===1&&p===1&&l===0&&!n?s+=Bo[p]:s+=vd[d]+Bo[p]}return s.replace(/〇$/,"")}let Vt=null,dn=null;const hn=new Set;function Sd(){return Vt?Promise.resolve():dn||(dn=import("opencc-js/t2cn").then(e=>{Vt=e.Converter({from:"tw",to:"cn"}),hn.forEach(n=>n())}).catch(()=>{Vt=e=>e,hn.forEach(e=>e())}),dn)}const _d=e=>e;function vt(){const[,e]=g.useState(0);return g.useEffect(()=>{if(Vt)return;const n=()=>e(o=>o+1);return hn.add(n),Sd(),()=>{hn.delete(n)}},[]),Vt??_d}function Et(e,n){return n(e).toLowerCase()}const $d=i("highlight-bg");function tn(e,n,o){if(!n)return e;const r=Et(n,o);if(!r)return e;const s=Et(e,o);if(s.length!==e.length)return e;const l=[];let d=0,p=0;for(;d<e.length;){const c=s.indexOf(r,d);if(c===-1){l.push(e.slice(d));break}c>d&&l.push(e.slice(d,c)),l.push(t.jsx("mark",{style:{background:$d,padding:0,color:"inherit"},children:e.slice(c,c+r.length)},p++)),d=c+r.length}return t.jsx(t.Fragment,{children:l})}function Ai(e,n,o,r){if(!n)return!0;const s=Et(n,r);return(o?[e.title,e.header_line,e.content,e.comment]:[e.title,e.book_title,e.author,e.author_info,e.summary,e.content,e.comment,e.additional_comment]).some(d=>typeof d=="string"&&Et(d,r).includes(s))}function zd(e,n,o){return n?Et(e,o).includes(Et(n,o)):!0}const Wi={类:i("section-lei"),书:i("section-shu"),序:i("section-xu"),结语:i("section-jieyu"),注释:i("section-zhushi")},Cd={考证:i("section-kaozhen")};function Id(e){const n=e.replace(".json","").replace(/[/\\]/g,"");return n==="fulu"?"附錄":n.startsWith("juanshou")?`卷首${n.replace("juanshou","")}`:n.startsWith("juan")?`卷${n.replace("juan","").replace(/^0+/,"")}`:n}function Bs(e){var r;const n=e.files.length,o=((r=e.children)==null?void 0:r.reduce((s,l)=>s+Bs(l),0))||0;return n+o}function Td(e,n){const o=[],r=d=>{var p;o.push(...d.files),(p=d.children)==null||p.forEach(r)};if(r(e),o.length===0)return;const s=o.map(d=>n[d]);if(s.every(d=>d===void 0))return;if(s.some(d=>d==="loading"))return"loading";let l=0;for(const d of s)typeof d=="number"&&(l+=d);return l}const Ed={background:"none",border:"none",padding:0,margin:0,font:"inherit",color:"inherit",textAlign:"left",cursor:"pointer"};function Mi({enabled:e,expanded:n,onClick:o,style:r,children:s}){return e?t.jsx("button",{type:"button","aria-expanded":n,onClick:o,style:{...Ed,...r},children:s}):t.jsx("span",{style:r,children:s})}function Rd({type:e}){const n=Ye(e),o=Wi[n]||i("desc-fg");return t.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:o,border:`1px solid ${o}40`,borderRadius:"2px",background:`${o}08`,flexShrink:0},children:n})}function Nd({section:e,onNavigate:n,highlightQuery:o="",no:r,showUnlinked:s=!1,domId:l}){const{convert:d}=Z(),p=Pe(),c=vt(),a=y=>y?Ue(d(y),k=>o?tn(k,o,c):k):"",[u,f]=g.useState(!1),x=!!e.summary,m=!!e.comment,j=!!e.additional_comment,w=!!(e.content&&e.content.length>60),h=x||m||j||w;g.useEffect(()=>{o&&f(!0)},[o]);const b=!u&&w?ss(e.content.replace(/\n/g," "),80)+"…":null;return t.jsxs("div",{className:"bim-rd-row",id:l,style:{borderBottom:`1px solid ${i("rule")}`,overflow:"hidden"},children:[t.jsxs("div",{onClick:()=>h&&f(!u),style:{padding:"10px 10px",display:"flex",alignItems:"baseline",gap:"8px",cursor:h?"pointer":"default",userSelect:"none"},children:[r!=null&&t.jsx("span",{className:"bim-rd-no",style:{flex:"none",width:28,fontSize:12,color:i("label-fg")},children:r}),t.jsxs(Mi,{enabled:h,expanded:u,style:{flex:1,minWidth:0,display:"flex",alignItems:"baseline",gap:"8px"},children:[h&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:u?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1,minWidth:0},children:[t.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg")},children:[e.book_title?t.jsxs(t.Fragment,{children:["《",a(e.book_title),"》"]}):a(e.title),e.n_juan!=null&&t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"6px"},children:[Bi(e.n_juan),"卷"]}),(e.author_info||e.author)&&t.jsx("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg"),marginLeft:"8px"},children:a(e.author_info||e.author)})]}),!u&&b&&t.jsx("span",{style:{display:"block",fontSize:"12px",color:i("desc-fg"),overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"2px"},children:a(b)})]})]}),e.edition&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:a(e.edition)}),e.tag&&t.jsx("span",{style:{fontSize:"11px",color:i("section-tag-fg")},children:e.tag==="triangle"?"△":e.tag}),e.work_id&&n&&t.jsx("a",{href:p(e.work_id),onClick:y=>{y.metaKey||y.ctrlKey||(y.preventDefault(),y.stopPropagation(),n(e.work_id))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:"查看作品","aria-label":`查看作品:${e.book_title||e.title}`,children:"作品 →"}),s&&!e.work_id&&t.jsx("span",{style:{fontSize:"11px",color:i("label-fg"),flexShrink:0},children:"未关联"})]}),u&&h&&t.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:`1px solid ${i("widget-border")}`,background:i("bg")},children:[e.author_info&&t.jsx("div",{style:{fontSize:"13px",color:i("desc-fg"),marginBottom:"8px"},children:a(e.author_info)}),e.summary&&t.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:`3px solid ${i("primary")}`,background:`color-mix(in srgb, ${i("primary")} 4%, transparent)`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:"提要"}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify"},children:a(e.summary)})]}),e.comment&&t.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:"按語"}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(e.comment)})]}),e.additional_comment&&t.jsxs("div",{style:{padding:"8px 14px",borderLeft:`3px solid ${i("desc-fg")}`,borderRadius:"0 4px 4px 0"},children:[t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:i("desc-fg"),marginBottom:"4px",letterSpacing:"1px"},children:"附按"}),t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.8,margin:0,fontStyle:"italic"},children:a(e.additional_comment)})]}),w&&!x&&!m&&!j&&t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:a(e.content)})]})]})}function Ld({section:e,highlightQuery:n=""}){const{convert:o}=Z(),r=vt(),s=c=>c?Ue(o(c),a=>n?tn(a,n,r):a):"",[l,d]=g.useState(!1),p=!!e.content;return t.jsxs("div",{style:{padding:"12px 0 6px"},children:[t.jsxs(Mi,{enabled:p,expanded:l,onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"8px",cursor:p?"pointer":"default",userSelect:"none"},children:[t.jsx(Rd,{type:e.type}),t.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:i("fg")},children:s(e.title)}),p&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),l&&p&&t.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid color-mix(in srgb, ${Wi[Ye(e.type)]||i("desc-fg")} 25%, transparent)`,borderRadius:"0 4px 4px 0",background:i("bg")},children:t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:s(e.content)})})]})}const Bd=100;function Fi(e){return Ye(e.type)!=="page_header"?!1:(e.content||"").length>=Bd}function Ad({section:e,highlightQuery:n=""}){const{convert:o}=Z(),r=vt();if(Ye(e.type)==="page_header"&&!Fi(e)||!e.content&&!e.title)return null;const s=o((e.content||e.title||"").replace(/\n{2,}/g,`
|
|
840
|
+
`)),l=Ue(s,a=>n?tn(a,n,r):a),d=Ye(e.type),p=Wi[d]||i("desc-fg"),c=d==="序"||d==="结语"||d==="注释";return t.jsxs("div",{style:{padding:c?"10px 12px":"6px 0",margin:c?"8px 0":void 0,fontSize:"13px",color:i("desc-fg"),lineHeight:1.8,whiteSpace:"pre-line",borderLeft:c?`3px solid ${p}40`:void 0,background:c?i("bg"):void 0,borderRadius:c?"0 4px 4px 0":void 0,position:"relative"},children:[c&&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:d}),l]})}function Wd(e,n,o){const[r,s]=g.useState({});return g.useEffect(()=>{var a;if(!n||e.length===0)return;let l=!1;const d=e.filter(u=>{var f;return!((f=o==null?void 0:o.current)!=null&&f.has(u))}),p={};for(const u of e)(a=o==null?void 0:o.current)!=null&&a.has(u)&&(p[u]=o.current.get(u));if(Object.keys(p).length>0&&s(p),d.length===0)return;const c=async u=>{var f;try{if(n.getEntry){const h=await n.getEntry(u);if(h)return{title:h.title,author:h.author}}const x=await n.getItem(u);if(!x)return null;const m=x.title||u,j=x.authors,w=(f=j==null?void 0:j[0])==null?void 0:f.name;return{title:m,author:w}}catch{return null}};return Promise.all(d.map(async u=>{var x;const f=await c(u);return(x=o==null?void 0:o.current)==null||x.set(u,f),[u,f]})).then(u=>{l||s(f=>{const x={...f};for(const[m,j]of u)x[m]=j;return x})}),()=>{l=!0}},[e.join(","),n]),r}function Md({section:e,onNavigate:n,transport:o,workLabelCache:r,highlightQuery:s=""}){const{convert:l}=Z(),d=Pe(),p=vt(),c=y=>y?Ue(l(y),k=>s?tn(k,s,p):k):"",[a,u]=g.useState(!1);g.useEffect(()=>{s&&u(!0)},[s]);const f=Ye(e.type),x=Cd[f]||i("desc-fg"),m=!!e.content,j=e.work_ids||[],w=j.length>1,h=Wd(w?j:[],o,r),b=m&&!a&&e.content.length>80?ss(e.content,80)+"……":null;return t.jsxs("div",{style:{borderBottom:`1px solid ${i("widget-border")}`,padding:"10px 0"},children:[t.jsxs("div",{onClick:()=>m&&u(!a),style:{display:"flex",alignItems:"flex-start",gap:"8px",cursor:m?"pointer":"default",userSelect:"none"},children:[t.jsxs(Mi,{enabled:m,expanded:a,style:{flex:1,display:"flex",alignItems:"flex-start",gap:"8px"},children:[m&&t.jsx("span",{"aria-hidden":"true",style:{fontSize:"9px",color:i("desc-fg"),marginTop:"5px",transition:"transform 0.15s",transform:a?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),t.jsxs("span",{style:{display:"block",flex:1},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:i("fg"),lineHeight:1.6},children:e.header_line?c(e.header_line):c(e.title)}),!a&&b&&t.jsx("span",{style:{display:"block",margin:"4px 0 0",fontSize:"12px",color:i("desc-fg"),lineHeight:1.7},children:c(b)})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[j.length===1&&n&&t.jsx("a",{href:d(j[0]),onClick:y=>{y.metaKey||y.ctrlKey||(y.preventDefault(),y.stopPropagation(),n(j[0]))},style:{fontSize:"11px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",flexShrink:0},title:"查看作品",children:"→作品"}),w&&t.jsxs("span",{style:{fontSize:"11px",color:i("link-fg"),flexShrink:0},children:[j.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:f})]})]}),w&&n&&t.jsx("div",{style:{margin:"6px 0 0 17px",display:"flex",flexWrap:"wrap",gap:"4px 12px"},children:j.map(y=>{const k=h[y],$=k?`${l(k.title)}${k.author?`(${l(k.author)})`:""}`:y.slice(0,8)+"…";return t.jsxs("a",{href:d(y),onClick:v=>{v.metaKey||v.ctrlKey||(v.preventDefault(),v.stopPropagation(),n(y))},style:{fontSize:"12px",color:i("link-fg"),cursor:"pointer",textDecoration:"none",lineHeight:1.8},title:y,children:["→",$]},y)})}),a&&m&&t.jsxs("div",{style:{marginTop:"10px",padding:"12px 16px",borderLeft:`3px solid ${x}40`,borderRadius:"0 4px 4px 0",background:i("bg")},children:[t.jsx("p",{style:{fontSize:"13px",color:i("fg"),lineHeight:2,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:c(e.content)}),e.comment&&t.jsx("div",{style:{marginTop:"10px",paddingTop:"8px",borderTop:`1px solid ${i("widget-border")}`,fontSize:"12px",color:i("desc-fg"),lineHeight:1.8,fontStyle:"italic"},children:c(e.comment)})]})]})}function Fd({juan:e,searchQuery:n,onNavigate:o,transport:r,workLabelCache:s}){const l=vt(),d=n.trim(),p=g.useMemo(()=>d?e.sections.filter(c=>Ai(c,d,!0,l)):e.sections,[e.sections,d,l]);return t.jsxs("div",{children:[t.jsx("div",{children:p.map((c,a)=>t.jsx(Md,{section:c,onNavigate:o,transport:r,workLabelCache:s,highlightQuery:d},a))}),p.length===0&&t.jsx("div",{style:{padding:"32px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:"无匹配结果"})]})}function Pd(){let e=!1;return n=>n==="类"?(e=!0,"h2"):e?"h3":"h2"}function Od({sections:e,onNavigate:n,inline:o,workLinks:r=!0}){const s=Pe(),{convert:l}=Z(),d=Pd();return t.jsx(t.Fragment,{children:e.map((p,c)=>{const a=Ye(p.type);if(a==="page_header"&&!Fi(p))return null;if(a==="类")return t.jsxs(g.Fragment,{children:[g.createElement(d("类"),null,o(l(p.title))),p.content&&t.jsx("p",{children:o(l(p.content))})]},c);if(a==="书"||a==="诗"||a==="考证"||a==="注释"){const u=p.book_title?`《${p.book_title}》${p.n_juan!=null?Bi(p.n_juan)+"卷":""}`:p.title,f=o(l(u));return t.jsxs("section",{className:"bim-rd-entry",id:`rd-e-${c}`,children:[g.createElement(d("条目"),{className:"bim-rd-entry-h"},p.work_id&&n&&r?t.jsxs(t.Fragment,{children:[t.jsx("a",{href:s(p.work_id),onClick:x=>{x.metaKey||x.ctrlKey||(x.preventDefault(),n(p.work_id))},title:"查看作品",children:f}),t.jsx("a",{className:"bim-rd-wl",href:s(p.work_id),onClick:x=>{x.metaKey||x.ctrlKey||(x.preventDefault(),n(p.work_id))},"aria-label":`查看作品:${u}`,children:"作品 →"})]}):f),p.author_info&&t.jsx("p",{className:"bim-rd-sub",children:o(l(p.author_info))}),p.content&&p.content.split(/\n+/).map((x,m)=>t.jsx("p",{children:o(l(x))},m)),p.summary&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:"提要"}),o(l(p.summary))]}),p.comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:"按語"}),o(l(p.comment))]}),p.additional_comment&&t.jsxs("p",{children:[t.jsx("span",{className:"bim-rd-lbl",children:"附按"}),o(l(p.additional_comment))]})]},c)}return p.content?t.jsx("p",{children:o(l(p.content))},c):null})})}function As(e){return e.some(n=>{const o=Ye(n.type);return o==="书"||o==="诗"||o==="考证"||o==="注释"||o==="类"||(o==="序"||o==="结语")&&!!n.content||o==="page_header"&&Fi(n)})}function Dd({juan:e,rawText:n,positionLabel:o,index:r,searchQuery:s,onNavigate:l,transport:d,workLabelCache:p,prefs:c,view:a,onViewChange:u}){var E;const{convert:f}=Z(),x=vt(),[m,j]=g.useState("text"),w=a??m,h=ee=>{j(ee),u==null||u(ee)},b=s.trim(),y=(r==null?void 0:r.type)==="kaozhen",k=g.useCallback(ee=>b?tn(ee,b,x):ee,[b,x]),$=ee=>Ni(ee,{renderText:k,properNames:c.properNames}),v=g.useMemo(()=>b?e.sections.filter(ee=>Ai(ee,b,y,x)):e.sections,[e.sections,b,y,x]),_=(ee,F)=>F.filter(q=>Ye(q.type)===ee).length,S=_("书",e.sections),z=_("诗",e.sections),N=_("考证",e.sections);let T="";y?T=b?`${_("考证",v)} / ${N} ${f("條")}`:`${N} ${f("條")}`:z>0?T=b?`${_("诗",v)} / ${z} 首`:`${z} 首`:S>0&&(T=b?`${_("书",v)} / ${S} ${f("部書")}`:`${S} ${f("部書")}`);const C=r!=null&&r.text_quality?bd(r.text_quality.grade):null,D=[];o&&D.push(o),T&&D.push(T),y&&(r!=null&&r.target_source)&&D.push(t.jsxs(t.Fragment,{children:[f("考證對象")," ",f(r.target_source)]})),C&&D.push(t.jsx("span",{title:Wl[C],children:(E=r==null?void 0:r.text_quality)!=null&&E.source_note?t.jsxs(t.Fragment,{children:["底本 ",f(r.text_quality.source_note),t.jsx("span",{className:"bim-rd-grade",children:f(Hn[C])})]}):t.jsxs(t.Fragment,{children:[f("文本質量"),t.jsx("span",{className:"bim-rd-grade",children:f(Hn[C])})]})})),e.source_url&&D.push(t.jsx("a",{className:"bim-rd-link",href:e.source_url,target:"_blank",rel:"noopener noreferrer",children:f("原文來源")}));const B=!y&&As(e.sections),O=!!n&&(!B||c.readingMode==="paragraph"&&qt(n)),M=!y&&(B||!!n),X=y||!M?"entries":w;let Y=0;return t.jsxs(t.Fragment,{children:[t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:f(e.title)}),D.length>0&&t.jsx("p",{className:"bim-rd-meta",children:D.map((ee,F)=>t.jsxs(g.Fragment,{children:[F>0&&t.jsx("span",{className:"bim-rd-dot"}),ee]},F))}),M&&e.sections.length>0&&t.jsxs("div",{className:"bim-rd-views",role:"group","aria-label":"看法",children:[t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":X==="text",onClick:()=>h("text"),children:"正文"}),t.jsx("button",{type:"button",className:"bim-rd-t","aria-pressed":X==="entries",onClick:()=>h("entries"),children:f("條目")})]})]}),X==="text"&&t.jsx("article",{className:"bim-rd-prose",children:O?t.jsx(Li,{text:n,mode:c.readingMode,properNames:c.properNames,renderText:k,dropTitle:e.title}):t.jsx(Od,{sections:e.sections,onNavigate:l,inline:$,workLinks:c.workLinks})}),X==="entries"&&t.jsx("div",{className:"bim-rd-entries",style:{marginTop:24},children:y?t.jsx(Fd,{juan:e,searchQuery:s,onNavigate:l,transport:d,workLabelCache:p}):t.jsxs(t.Fragment,{children:[v.some(ee=>["书","诗","考证"].includes(Ye(ee.type)))&&t.jsxs("div",{className:"bim-rd-rowhead","aria-hidden":"true",children:[t.jsx("span",{style:{width:28},children:"序"}),t.jsx("span",{style:{flex:1},children:"书名"}),t.jsx("span",{children:"作品"})]}),v.map((ee,F)=>{const q=Ye(ee.type);return q==="书"||q==="诗"||q==="考证"?(Y+=1,t.jsx(Nd,{domId:`rd-e-${e.sections.indexOf(ee)}`,section:ee,onNavigate:c.workLinks?l:void 0,highlightQuery:b,no:Y,showUnlinked:c.workLinks&&!!l},F)):q==="类"?t.jsx(Ld,{section:ee,highlightQuery:b},F):t.jsx(Ad,{section:ee,highlightQuery:b},F)}),v.length===0&&t.jsx("div",{className:"bim-rd-state",style:{textAlign:"center"},children:"无匹配结果"})]})})]})}function Ws(e){return e.juan_files&&e.juan_files.length>0?e.juan_files:e.files&&e.files.length>0?e.files.map(n=>n.filename):[]}function Hd(e){const n=Ws(e);return n.length>0?n[0]:null}function Gd(e){const{workId:n,transport:o,files:r,activeFile:s,activeJuan:l,activeRawText:d,query:p,isKaozhen:c}=e,a=vt(),u=g.useRef(new Map),[f,x]=g.useState({}),[m,j]=g.useState({}),w=g.useCallback((b,y)=>{const k=y==null?void 0:y.title;k&&j($=>$[b]===k?$:{...$,[b]:k})},[]);g.useEffect(()=>{s&&l&&(u.current.set(s,{juan:l,rawText:d}),w(s,l))},[s,l,d,w]),g.useEffect(()=>{u.current.clear(),x({}),j({})},[n]);const h=g.useCallback((b,y)=>{let k=0;if(b.juan)for(const $ of b.juan.sections)Ai($,y,c,a)&&k++;return k===0&&b.rawText&&zd(b.rawText,y,a)&&(k=1),k},[c,a]);return g.useEffect(()=>{const b=p.trim();if(!b){x({});return}if(!n||!(o!=null&&o.getCollatedJuan)||r.length===0)return;let y=!1;const k={},$=[];for(const N of r){const T=u.current.get(N);T?k[N]=h(T,b):(k[N]="loading",$.push(N))}x(k);const v=8;let _=0;const S=async()=>{var N;for(;_<$.length;){if(y)return;const T=_++,C=$[T];try{const[D,B]=await Promise.all([o.getCollatedJuan(n,C),((N=o.getCollatedJuanText)==null?void 0:N.call(o,n,C))??Promise.resolve(null)]),O={juan:D,rawText:B};if(u.current.set(C,O),w(C,D),y)return;x(M=>({...M,[C]:h(O,b)}))}catch{if(y)return;x(D=>({...D,[C]:0}))}}},z=Array.from({length:Math.min(v,$.length)},()=>S());return Promise.all(z),()=>{y=!0}},[p,n,o,r.join(","),h,a,w]),{matchStates:f,titles:m}}function Ud({juan:e,view:n,onView:o,textHasEntries:r}){const{convert:s}=Z(),l=e.sections.map((a,u)=>({s:a,i:u,t:Ye(a.type)})).filter(a=>a.t==="书"||a.t==="诗");if(l.length===0)return null;const d=l.filter(a=>!!a.s.work_id).length,p=l.every(a=>a.t==="诗")?"首":"部书",c=a=>{const u=()=>{var f,x;return(x=(f=document.getElementById(`rd-e-${a}`))==null?void 0:f.scrollIntoView)==null?void 0:x.call(f,{block:"start",behavior:"smooth"})};n==="text"&&!r&&o("entries"),n==="text"&&!r?setTimeout(u,0):u()};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bim-rd-rail-card",children:[t.jsx("div",{className:"bim-rd-rail-cap",children:"本卷"}),t.jsxs("div",{className:"bim-rd-rail-n",children:[t.jsx("b",{children:l.length}),t.jsx("span",{children:s(p)}),t.jsxs("span",{className:"bim-rd-rail-linked",children:["已关联 ",d]})]}),t.jsx("div",{className:"bim-rd-rail-bar",role:"img","aria-label":`已关联 ${d} / ${l.length}`,children:t.jsx("span",{style:{width:`${Math.round(d/l.length*100)}%`}})})]}),t.jsxs("nav",{"aria-label":"本卷条目",children:[t.jsx("div",{className:"bim-rd-rail-cap",style:{margin:"20px 0 6px 12px"},children:s("條目")}),t.jsx("ul",{className:"bim-rd-rail-list",children:l.map(({s:a,i:u})=>t.jsx("li",{children:t.jsxs("a",{href:`#rd-e-${u}`,onClick:f=>{f.preventDefault(),c(u)},children:[t.jsx("span",{className:`bim-rd-rail-dot${a.work_id?" on":""}`,"aria-hidden":"true"}),t.jsx("span",{children:s(a.book_title||a.title)})]})},u))})]})]})}function Vd(e,n){const[o,r]=g.useState([]);return g.useEffect(()=>{if(r([]),!e||typeof(n==null?void 0:n.getItem)!="function")return;let s=!1;return Promise.resolve(n.getItem(e)).then(l=>{if(s||!l)return;const d=l.authors??[];r(d.filter(p=>p&&p.name))}).catch(()=>{}),()=>{s=!0}},[e,n]),o}const Pi=({index:e,workId:n,transport:o,onNavigate:r,activeJuan:s,onJuanChange:l,className:d,style:p,title:c,subtitle:a,resolveImages:u,renderImageOverlay:f,imagePanel:x,allowVertical:m})=>{const[j,w]=g.useState(null),[h,b]=g.useState(!1),[y,k]=g.useState(null),[$,v]=g.useState(null),[_,S]=g.useState(null),[z,N]=g.useState(!1),[T,C]=g.useState(null),[D,B]=g.useState(""),O=g.useRef(new Map),M=g.useRef(0),X=s??$,Y=g.useCallback(Q=>{v(Q),l==null||l(Q)},[l]),E=e||j;g.useEffect(()=>{e&&(b(!1),k(null))},[e]),g.useEffect(()=>{if(e||!n||!(o!=null&&o.getCollatedEditionIndex))return;let Q=!1;return b(!0),k(null),o.getCollatedEditionIndex(n).then(ie=>{Q||(ie?w(ie):k("未找到整理本数据"))}).catch(ie=>{Q||k(ie instanceof Error?ie.message:"加载失败")}).finally(()=>{Q||b(!1)}),()=>{Q=!0}},[e,n,o]),g.useEffect(()=>{if(E&&!X){const Q=Hd(E);Q&&Y(Q)}},[E,X,Y]);const ee=n||(E==null?void 0:E.work_id),F=g.useCallback(async Q=>{var ge;if(!ee||!(o!=null&&o.getCollatedJuan))return;const ie=++M.current;N(!0),S(null),C(null);try{const[re,le]=await Promise.all([o.getCollatedJuan(ee,Q),((ge=o.getCollatedJuanText)==null?void 0:ge.call(o,ee,Q))??Promise.resolve(null)]);if(ie!==M.current)return;S(re),C(le)}catch{if(ie!==M.current)return;S(null),C(null)}finally{ie===M.current&&N(!1)}},[ee,o]);g.useEffect(()=>{X&&F(X)},[X,F]);const q=Q=>{Y(Q)};if(h)return t.jsx("div",{className:d,style:{...p,padding:"24px"},children:t.jsx("div",{style:{color:i("desc-fg"),fontSize:"13px"},children:"加载整理本..."})});if(y)return t.jsx("div",{className:d,style:{...p,padding:"24px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:y});if(!E)return null;const ae=E.type==="kaozhen",ne=Ws(E);return t.jsx(qd,{className:d,style:p,index:E,allFiles:ne,isKaozhen:ae,effectiveWorkId:ee,transport:o,activeFile:X,handleSelectFile:q,juanData:_,juanRawText:T,juanLoading:z,searchQuery:D,setSearchQuery:B,onNavigate:r,workLabelCacheRef:O,reader:{title:c,subtitle:a,resolveImages:u,renderImageOverlay:f,imagePanel:x,allowVertical:m}})};function ti(e,n,o,r){var a,u,f,x;const s=(u=(a=n.juan_metadata)==null?void 0:a[e])==null?void 0:u.vol_label,l=r(s?`${s}冊`:Id(e)),p=((x=(f=n.files)==null?void 0:f.find(m=>m.filename===e))==null?void 0:x.title)??o[e];if(!p)return{position:l,label:l};const c=r(p);return{position:l,label:l===p||l===c?c:`${l} ${c}`}}function Yd(e,n,o,r,s){const l=c=>c==="loading"?"…":typeof c=="number"&&c>0?c:void 0,d=(c,a)=>({key:c,label:a??ti(c,e,r,s).label,hint:l(o[c]),disabled:o[c]===0}),p=(c,a)=>{var f;if(c.files.length===1&&!((f=c.children)!=null&&f.length))return d(c.files[0],s(c.label));const u=Td(c,o);return{key:`group:${a}`,label:s(c.label),hint:u==="loading"?"…":typeof u=="number"&&u>0?`${u}`:Bs(c),defaultExpanded:typeof u=="number"&&u>0,children:[...c.files.map(x=>d(x)),...(c.children??[]).map((x,m)=>p(x,`${a}.${m}`))]}};return e.juan_groups&&e.juan_groups.length>0?e.juan_groups.map((c,a)=>p(c,`${a}`)):n.map(c=>d(c))}const qd=({className:e,style:n,index:o,allFiles:r,isKaozhen:s,effectiveWorkId:l,transport:d,activeFile:p,handleSelectFile:c,juanData:a,juanRawText:u,juanLoading:f,searchQuery:x,setSearchQuery:m,onNavigate:j,workLabelCacheRef:w,reader:h})=>{const{convert:b}=Z(),[y,k]=zi(),[$,v]=g.useState("text");g.useEffect(()=>{v("text")},[p]);const{matchStates:_,titles:S}=Gd({workId:l,transport:d,files:r,activeFile:p,activeJuan:a,activeRawText:u,query:x,isKaozhen:s}),z=Ls(h.resolveImages,p),N=g.useMemo(()=>Yd(o,r,_,S,b),[o,r,_,S,b]),T=t.jsx("input",{type:"search",className:"bim-rd-toc-search",placeholder:s?"搜索全部章节…":"搜索全部卷…","aria-label":s?"搜索全部章节":"搜索全部卷",value:x,onChange:q=>m(q.target.value)}),C=s?"章":o.juan_metadata&&Object.values(o.juan_metadata).some(q=>q.vol_label)?"冊":"卷",D=p?ti(p,o,S,b).position:void 0,B=Pe(),O=h.title??(o.title?b(o.title):void 0),M=O&&l&&j?t.jsx("a",{href:B(l),onClick:q=>{q.metaKey||q.ctrlKey||(q.preventDefault(),j(l))},title:"查看作品",children:O}):O,X=!!a&&!s&&As(a.sections),Y=X&&!(u&&y.readingMode==="paragraph"&&qt(u)),E=a&&!s&&X?t.jsx(Ud,{juan:a,view:$,onView:v,textHasEntries:Y}):void 0,ee=Vd(l,d),F=ee.length>0?b(ee.slice(0,2).map(q=>`${q.dynasty?`〔${q.dynasty}〕`:""}${q.name}${q.role?` ${q.role}`:" 撰"}`).join("、")):void 0;return t.jsxs(Ci,{className:e,style:n,title:M,subtitle:h.subtitle??b(s?"考證":"整理本"),byline:F,pagerUnit:C,rail:E,current:p?ti(p,o,S,b).label:void 0,workLinkToggle:!s&&!!j&&!!(a!=null&&a.sections.some(q=>q.work_id)),toc:N,tocCaption:`目录 · ${r.length} ${b(C)}`,tocHeader:T,activeKey:p,onSelect:c,images:z.images,imagesLoading:z.loading,renderImageOverlay:h.renderImageOverlay,imagePanel:h.imagePanel,prefs:y,onPrefsChange:k,paragraphToggle:!s&&qt(u),allowVertical:h.allowVertical,children:[f?t.jsx(jt,{}):a?t.jsx(Dd,{juan:a,rawText:u,positionLabel:D,index:o,searchQuery:x,onNavigate:j,transport:d,workLabelCache:w,prefs:y,view:$,onViewChange:v},p??""):p?t.jsx("div",{className:"bim-rd-state",children:"无法加载这一卷"}):null,o.references&&o.references.length>0&&t.jsxs("section",{className:"bim-rd-refs",children:[t.jsx("h2",{children:b("參考文獻")}),t.jsx("ol",{children:o.references.map((q,ae)=>t.jsxs("li",{children:[q.url?t.jsx("a",{className:"bim-rd-link",href:q.url,target:"_blank",rel:"noopener noreferrer",children:q.title}):t.jsx("span",{children:q.title}),q.author&&t.jsxs("span",{children:[",",q.author]}),q.note&&t.jsxs("span",{children:["。",q.note]})]},ae))})]})]})},Kd={bug:{label:"错误反馈",color:i("danger")},resource:{label:"资源建议",color:i("primary")},suggestion:{label:"功能建议",color:i("primary")},other:{label:"其他",color:i("desc-fg")}},Jd={label:"其他",color:i("desc-fg")},Zd={pending:{label:"待处理",color:i("warning")},in_progress:{label:"处理中",color:i("primary")},resolved:{label:"已处理",color:i("success")},wontfix:{label:"不采纳",color:i("desc-fg")},duplicate:{label:"重复",color:i("desc-fg")}},Xd={label:"待处理",color:i("warning")};function Qd(e){try{const n=new Date(e),o=r=>String(r).padStart(2,"0");return`${n.getFullYear()}-${o(n.getMonth()+1)}-${o(n.getDate())} ${o(n.getHours())}:${o(n.getMinutes())}`}catch{return e}}function ep(e,n){if(!e)return!1;try{const o=new URL(e,n);if(o.protocol!=="http:"&&o.protocol!=="https:")return!1;const r=new URL(n);return o.hostname===r.hostname}catch{return!1}}const Oi=({items:e,loading:n})=>{const o=Pe();return n?t.jsx(jt,{}):e.length===0?t.jsx("div",{style:tp,children:"暂无反馈"}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:e.map(r=>{const s=Kd[r.type]||Jd,l=Zd[r.status]||Xd,d=typeof window<"u"&&ep(r.pageUrl,window.location.href);return t.jsxs("div",{style:np,children:[t.jsxs("div",{style:ip,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{...Ao,background:s.color},children:s.label}),t.jsx("span",{style:{...Ao,background:l.color},children:l.label})]}),t.jsx("span",{style:op,children:Qd(r.createdAt)})]}),(r.resourceId||r.pageUrl)&&t.jsxs("div",{style:rp,children:[r.resourceId&&t.jsx("a",{href:o(r.resourceId),style:An,children:r.resourceId}),r.pageUrl&&!r.resourceId&&(d?t.jsx("a",{href:r.pageUrl,style:An,children:r.pageUrl.replace(/^https?:\/\/[^/]+/,"")}):t.jsx("span",{style:An,children:r.pageUrl}))]}),t.jsx("div",{style:sp,children:r.content}),r.reply&&t.jsxs("div",{style:lp,children:[t.jsx("div",{style:ap,children:"回复"}),t.jsx("div",{children:r.reply})]})]},r.id)})})},tp={textAlign:"center",padding:"40px 0",color:i("desc-fg"),fontSize:"14px"},np={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"16px"},ip={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},Ao={fontSize:"12px",color:i("on-color-fg"),padding:"2px 8px",borderRadius:"4px",fontWeight:500},op={fontSize:"12px",color:i("desc-fg")},rp={fontSize:"12px",marginBottom:"6px"},An={color:i("primary"),textDecoration:"none",borderBottom:`1px dashed ${i("primary")}`},sp={fontSize:"14px",lineHeight:"1.6",color:i("fg"),whiteSpace:"pre-wrap"},lp={marginTop:"12px",padding:"10px 12px",background:i("input-bg"),borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:i("fg")},ap={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:i("primary")},ni=({transport:e,onNavigate:n,recommendedIds:o,activeTab:r,onTabChange:s,feedbackApiUrl:l})=>{const d=ue(),[p,c]=g.useState(null),[a,u]=g.useState([]),[f,x]=g.useState("recommend"),[m,j]=g.useState([]),[w,h]=g.useState(!1),b=r??f,y=M=>{x(M),s==null||s(M)},[k,$]=g.useState(!0),[v,_]=g.useState(null),[S,z]=g.useState(null),[N,T]=g.useState(null);g.useEffect(()=>{let M=!1;if(e.getCounts)return e.getCounts().then(X=>{M||c({works:X.works,books:X.books,collections:X.collections})}).catch(()=>{}),()=>{M=!0}},[e]),g.useEffect(()=>{let M=!1;return(async()=>{if(o)return o;if(e.getRecommended)try{const Y=await e.getRecommended();if(Y!=null&&Y.groups)return Y.groups.flatMap(E=>E.items.map(ee=>({...ee,group:E.name})))}catch{}return[]})().then(async Y=>{if(M)return;const E=Y.filter(F=>F.id);if(E.length===0){$(!1);return}const ee=await Promise.all(E.map(async F=>{if(F.type)return{id:F.id,title:F.title,type:F.type,author:F.author,dynasty:F.dynasty,role:F.role,edition:F.edition,has_text:F.has_text,has_image:F.has_image,has_collated:F.has_collated,subtype:F.subtype,primary_name:F.primary_name,group:F.group,fallbackDescription:F.description};try{let q=null;if(e.getEntry)q=await e.getEntry(F.id);else{const ae=await e.getItem(F.id);ae&&(q={id:F.id,title:ae.title||F.id,type:ae.type||"work"})}if(q)return{...q,group:F.group,fallbackDescription:F.description}}catch{}return{id:F.id,title:F.title,type:we.extractType(F.id),group:F.group,fallbackDescription:F.description}}));M||(u(ee.filter(F=>F!==null)),$(!1))}),()=>{M=!0}},[e,o]);const C=g.useRef(!1),D=g.useRef(!1),B=g.useRef(!1);g.useEffect(()=>{if(b!=="catalog"||C.current)return;const M=e.getCatalogProgress??e.getResourceProgress;if(!M)return;C.current=!0;let X=!1;return M.call(e).then(Y=>{X||_(Y)}).catch(()=>{C.current=!1}),()=>{X=!0}},[e,b]),g.useEffect(()=>{if(b!=="collection"||D.current||!e.getCollectionProgress)return;D.current=!0;let M=!1;return e.getCollectionProgress().then(X=>{M||z(X)}).catch(()=>{D.current=!1}),()=>{M=!0}},[e,b]),g.useEffect(()=>{if(b!=="site"||B.current||!e.getSiteProgress)return;B.current=!0;let M=!1;return e.getSiteProgress().then(X=>{M||T(X)}).catch(()=>{B.current=!1}),()=>{M=!0}},[e,b]),g.useEffect(()=>{if(!l||b!=="feedback")return;let M=!1;return h(!0),fetch(l).then(X=>X.json()).then(X=>{!M&&X.success&&j(X.items||[])}).catch(()=>{}).finally(()=>{M||h(!1)}),()=>{M=!0}},[l,b]);const O=M=>t.jsx(vn,{type:M,size:12});return t.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:i("fg")},children:t.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[t.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${i("widget-border")}`,marginBottom:"16px"},children:[t.jsx(Ft,{label:d.home.recommendTab,active:b==="recommend",onClick:()=>y("recommend")}),t.jsx(Ft,{label:d.home.catalogTab,active:b==="catalog",onClick:()=>y("catalog")}),t.jsx(Ft,{label:d.home.collectionTab,active:b==="collection",onClick:()=>y("collection")}),t.jsx(Ft,{label:d.home.siteTab,active:b==="site",onClick:()=>y("site")}),l&&t.jsx(Ft,{label:d.home.feedbackTab,active:b==="feedback",onClick:()=>y("feedback")})]}),b==="recommend"&&t.jsx(cp,{recommended:a,loading:k,onNavigate:n,getIcon:O,t:d}),b==="catalog"&&t.jsx(Wo,{progress:v,t:d,onNavigate:n}),b==="collection"&&t.jsx(Wo,{progress:S,t:d,onNavigate:n}),b==="site"&&t.jsx(pp,{progress:N,t:d,totalWorks:(p==null?void 0:p.works)??0}),b==="feedback"&&l&&t.jsx(Oi,{items:m,loading:w})]})})},Ft=({label:e,active:n,onClick:o})=>t.jsx("button",{onClick:o,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:i(n?"primary":"desc-fg"),background:"none",border:"none",borderBottom:n?`2px solid ${i("primary")}`:"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:e}),cp=({recommended:e,loading:n,onNavigate:o,getIcon:r,t:s})=>{const l=Pe();if(n)return t.jsx(jt,{});if(e.length===0)return null;const d=new Map;for(const p of e){const c=p.group||s.home.recommendedBrowse;d.has(c)||d.set(c,[]),d.get(c).push(p)}return t.jsx(t.Fragment,{children:Array.from(d.entries()).map(([p,c])=>t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:p}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:c.map(a=>{const u=a.dynasty||a.author?`${a.dynasty?`〔${a.dynasty}〕`:""}${a.author||""}`:a.fallbackDescription;return t.jsxs("a",{href:l(a.id),onClick:f=>{f.metaKey||f.ctrlKey||(f.preventDefault(),o==null||o(a.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,cursor:"pointer",background:i("input-bg"),textDecoration:"none",color:"inherit"},children:[t.jsx("span",{style:{fontSize:"20px"},children:r(a.type)}),t.jsxs("div",{style:{minWidth:0},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a.title,a.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:a.edition})]}),u&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u})]})]},a.id)})})]},p))})},Wo=({progress:e,t:n,onNavigate:o})=>{if(!e)return t.jsx(jt,{});const r=[...e.resources].sort((p,c)=>p.priority-c.priority),s=["in_progress","done","todo"],l={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},d={in_progress:i("progress-active"),done:i("progress-done"),todo:i("progress-todo")};return t.jsx("div",{children:s.map(p=>{const c=r.filter(a=>a.status===p);return c.length===0?null:t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:d[p]}}),l[p]," (",c.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c.map(a=>t.jsx(dp,{item:a,t:n,statusColor:d[p],onNavigate:o},a.id))})]},p)})})},dp=({item:e,t:n,statusColor:o,onNavigate:r})=>{const s=Pe(),l=e.total>0?Math.round(e.imported/e.total*100):0,d=e.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const p=e.edition?`${e.name}·${e.edition}`:e.name,c=e.collection_id||e.work_id;return c&&r?t.jsx("a",{href:s(c),onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),r(c))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:p}):e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:p}):p})()}),t.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:i("widget-border"),color:i("desc-fg"),whiteSpace:"nowrap"},children:e.collection_id?n.indexType.collection:e.work_id?n.indexType.work:d})]}),t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.total>0?Jt(n.home.progressFormat,{imported:String(e.imported),total:String(e.total)}):n.home.totalPending})]}),e.total>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${l}%`,borderRadius:"2px",background:o,transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},pp=({progress:e,t:n,totalWorks:o})=>{if(!e)return t.jsx(jt,{});const r=[...e.resources].sort((c,a)=>c.priority-a.priority),s=r.filter(c=>c.imported>0),l=r.filter(c=>c.imported===0),d=s.reduce((c,a)=>Math.max(c,a.imported),0),p=o>0?Math.round(d/o*100):0;return t.jsxs("div",{children:[o>0&&t.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:`color-mix(in srgb, ${i("primary")} 6%, transparent)`,fontSize:"13px",color:i("fg")},children:[n.home.siteCoverage,": ",t.jsx("strong",{children:d.toLocaleString()})," / ",o.toLocaleString()," ",n.indexType.work," (",p,"%)"]}),s.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-done")}}),n.home.statusInProgress," (",s.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(c=>t.jsx(Mo,{item:c,t:n,totalWorks:o},c.id))})]}),l.length>0&&t.jsxs("div",{style:{marginBottom:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:i("desc-fg"),marginBottom:"8px"},children:[t.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:i("progress-todo")}}),n.home.statusTodo," (",l.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:l.map(c=>t.jsx(Mo,{item:c,t:n,totalWorks:o},c.id))})]})]})},Mo=({item:e,t:n,totalWorks:o})=>{const r=o>0?Math.round(e.imported/o*100):0;return t.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${i("widget-border")}`,background:i("input-bg")},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:t.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:e.url?t.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:e.name}):e.name})}),t.jsx("span",{style:{fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap",marginLeft:"8px"},children:e.imported>0?`${e.imported.toLocaleString()} ${n.indexType.work} (${r}%)`:n.home.statusTodo})]}),e.imported>0&&o>0&&t.jsx("div",{style:{height:"4px",borderRadius:"2px",background:i("widget-border"),overflow:"hidden",marginBottom:"4px"},children:t.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i("progress-done"),transition:"width 0.3s ease"}})}),e.description&&t.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginTop:"4px"},children:e.description})]})},Fo="(max-width: 768px)";function up(){const[e,n]=g.useState(()=>typeof window>"u"?!1:window.matchMedia(Fo).matches);return g.useEffect(()=>{const o=window.matchMedia(Fo),r=s=>n(s.matches);return o.addEventListener("change",r),()=>o.removeEventListener("change",r)},[]),e}const xp=({transport:e,hideModeIndicator:n=!0,onEntryClick:o,recommendedIds:r,headerRight:s})=>{var X;const l=ue(),{convert:d}=Z(),p=up(),[c,a]=g.useState(null),[u,f]=g.useState(null),[x,m]=g.useState(!1),[j,w]=g.useState("detail"),[h,b]=g.useState([]),[y,k]=g.useState(!1),[$,v]=g.useState(null),[_,S]=g.useState(!1),z=g.useCallback(async Y=>{if(!e.getCollatedEditionIndex){v(null);return}S(!0);try{const E=await e.getCollatedEditionIndex(Y);v(E)}catch{v(null)}finally{S(!1)}},[e]),N=g.useCallback(async Y=>{if(!e.getCollectionCatalogs&&!e.getCollectionCatalog){b([]);return}k(!0);try{if(e.getCollectionCatalogs){const E=await e.getCollectionCatalogs(Y);b(E||[])}else if(e.getCollectionCatalog){const E=await e.getCollectionCatalog(Y);b(E?[{resource_id:"",data:E}]:[])}}catch{b([])}finally{k(!1)}},[e]),T=g.useCallback(async Y=>{if(o){o(Y);return}a(Y),f(null),b([]),v(null),w("detail"),m(!0);try{const E=await e.getItem(Y.id);E&&(f(E),E.type==="collection"?N(Y.id):E.type==="work"&&E.has_collated&&z(Y.id))}catch(E){console.error("加载详情失败:",E)}finally{m(!1)}},[e,o,N,z]),C=g.useCallback(async Y=>{f(null),b([]),v(null),w("detail"),m(!0);try{const E=await e.getItem(Y);E&&(f(E),a({id:Y,title:E.title||Y,type:E.type||"book"}),E.type==="collection"?N(Y):E.type==="work"&&E.has_collated&&z(Y))}catch(E){console.error("导航失败:",E)}finally{m(!1)}},[e,N,z]),D=(u==null?void 0:u.type)==="collection"&&(h.length>0||y)||(u==null?void 0:u.type)==="work"&&($||_),B=p&&(x||u),O=g.useCallback(()=>{a(null),f(null),b([]),v(null),w("detail")},[]),M=t.jsx(t.Fragment,{children:x?t.jsx(jt,{}):u?t.jsxs(t.Fragment,{children:[(D||s)&&t.jsxs("div",{style:{display:"flex",alignItems:"center",borderBottom:`1px solid ${i("widget-border")}`,padding:p?"0 12px":"0 48px",background:i("input-bg"),flexShrink:0,overflowX:p?"auto":void 0},children:[D&&t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>w("detail"),style:pn(j==="detail"),children:l.detailTab.basicInfo}),u.type==="collection"&&y&&h.length===0&&t.jsxs("button",{onClick:()=>{},style:pn(!1),children:[l.detailTab.catalog,t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),u.type==="collection"&&h.map(Y=>t.jsx("button",{onClick:()=>w(`catalog:${Y.resource_id}`),style:pn(j===`catalog:${Y.resource_id}`),children:Y.short_name?`${d(Y.short_name)}${l.detailTab.catalogSuffix}`:l.detailTab.collectionCatalog},Y.resource_id)),u.type==="work"&&($||_)&&t.jsxs("button",{onClick:()=>w("collated"),style:pn(j==="collated"),children:[l.detailTab.collatedEdition,_&&t.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0,padding:"4px 0"},children:s})]}),t.jsx("div",{style:{padding:p?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:j==="detail"?t.jsx(gi,{data:u,transport:e,onNavigate:C}):j.startsWith("catalog:")?t.jsx(mi,{data:(X=h.find(Y=>`catalog:${Y.resource_id}`===j))==null?void 0:X.data,onNavigate:C}):j==="collated"?t.jsx(Pi,{index:$||void 0,workId:u.id,transport:e,onNavigate:C}):null})]}):t.jsx(ni,{transport:e,onNavigate:C,recommendedIds:r})});return p?t.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:B?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i("widget-border")}`,background:i("input-bg"),flexShrink:0},children:t.jsxs("button",{onClick:O,style:{padding:"4px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px"},children:["← ",l.detailTab.basicInfo]})}),t.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:M})]}):t.jsxs("div",{style:{flex:1,overflow:"auto"},children:[t.jsx(Un,{transport:e,onEntryClick:T,hideModeIndicator:n}),!u&&t.jsx(ni,{transport:e,onNavigate:C,recommendedIds:r})]})}):t.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:i("bg"),color:i("fg")},children:[t.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:`1px solid ${i("widget-border")}`,display:"flex",flexDirection:"column",background:i("input-bg"),overflow:"hidden"},children:t.jsx("div",{style:{flex:1,overflow:"auto"},children:t.jsx(Un,{transport:e,onEntryClick:T,hideModeIndicator:n})})}),t.jsx("div",{style:{flex:1,overflow:"auto",background:i("bg"),display:"flex",flexDirection:"column"},children:M})]})};function pn(e){return{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"primary":"desc-fg"),cursor:"pointer",fontSize:"13px",fontWeight:e?600:400}}function ut(e){return e.replace(/\.md$/,"")}function Po(e){let n="";if(e.source_url)try{const r=new URL(e.source_url).pathname.split("/").filter(Boolean).pop()??"";n=decodeURIComponent(r).replace(/_/g," ")}catch{}return[e.source_name,n||e.version_label].filter(Boolean).join(" · ")||e.key}const Oo={padding:24,color:i("desc-fg")},ii=({index:e,bookId:n,transport:o,activeChapter:r,onChapterChange:s,workKey:l,versions:d,onVersionChange:p,title:c,subtitle:a,resolveImages:u,renderImageOverlay:f,imagePanel:x,allowVertical:m,className:j,style:w})=>{const[h,b]=g.useState(e??null),[y,k]=g.useState(!1),[$,v]=g.useState(null),_=r!==void 0?r:$,S=g.useCallback(ne=>{s?s(ne):v(ne)},[s]),[z,N]=g.useState(null),[T,C]=g.useState(!1);g.useEffect(()=>{e&&b(e)},[e]),g.useEffect(()=>{if(e)return;b(null),k(!1);const ne=l!==void 0?o.getWorkFullTextIndex?()=>o.getWorkFullTextIndex(n,l):null:o.getBookFullTextIndex?()=>o.getBookFullTextIndex(n):null;if(!n||!ne){k(!0);return}let Q=!1;return Promise.resolve().then(ne).then(ie=>{Q||(ie?b(ie):k(!0))}).catch(()=>{Q||k(!0)}),()=>{Q=!0}},[n,o,e,l]),g.useEffect(()=>{if(!h||h.chapters.length===0)return;const ne=ut(h.chapters[0].file);if(!_){S(ne);return}const Q=ut(_);h.chapters.some(ge=>ut(ge.file)===Q)||S(ne)},[h,_,S]);const D=g.useMemo(()=>{if(!h||!_)return null;const ne=ut(_);return h.chapters.find(Q=>ut(Q.file)===ne)??null},[h,_]);g.useEffect(()=>{if(!n||!D)return;const ne=l!==void 0?o.getWorkFullTextChapter?ie=>o.getWorkFullTextChapter(n,l,ie):null:o.getBookFullTextChapter?ie=>o.getBookFullTextChapter(n,ie):null;if(!ne)return;let Q=!1;return C(!0),N(null),Promise.resolve(D.file).then(ne).then(ie=>{Q||N(ie)}).catch(()=>{Q||N(null)}).finally(()=>{Q||C(!1)}),()=>{Q=!0}},[n,D,o,l]);const B=Ls(u,D?ut(D.file):null),[O,M]=zi(),{convert:X}=Z(),Y=!!(d&&d.length>1&&p),E=g.useMemo(()=>Y?ys(d).map((ne,Q)=>({...ne,label:Po(d[Q])})):void 0,[Y,d]),ee=Y?t.jsxs("label",{children:["版本:",t.jsx("select",{value:l,onChange:ne=>p(ne.target.value),children:d.map(ne=>t.jsx("option",{value:ne.key,children:Po(ne)},ne.key))})]}):null;if(!h)return t.jsxs("div",{style:Oo,children:[ee&&t.jsx("div",{style:{marginBottom:12},children:ee}),y?"无法加载全文目录":"加载全文目录…"]});if(h.chapters.length===0)return t.jsxs("div",{style:Oo,children:[ee&&t.jsx("div",{style:{marginBottom:12},children:ee}),"全文目录为空"]});const F=h.chapters.map(ne=>({key:ut(ne.file),label:X(ne.title)})),q=ws(h)||qn(h),ae=z?z.replace(/^##\s+[^\n]+\n+/,""):null;return t.jsxs(Ci,{title:c??X(h.version_label),subtitle:a??"全文",toc:F,tocCaption:`目录 · ${h.chapters.length} ${h.chapters.length>1?"卷":"篇"}`,activeKey:_?ut(_):null,onSelect:S,images:B.images,imagesLoading:B.loading,renderImageOverlay:f,imagePanel:x,prefs:O,onPrefsChange:M,versions:E,currentVersionKey:E?l??null:void 0,onVersionChange:E?p:void 0,versionSource:!1,paragraphToggle:qt(ae),allowVertical:m,className:j,style:w,children:[D&&t.jsxs("header",{children:[t.jsx("h1",{className:"bim-rd-h1",children:X(D.title)}),t.jsxs("p",{className:"bim-rd-meta",children:["来源 ",t.jsx("a",{className:"bim-rd-link",href:h.source.url,target:"_blank",rel:"noreferrer",children:X(h.source.name)}),h.source.license&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-rd-dot"}),h.source.license]})]})]}),T&&t.jsx("div",{className:"bim-rd-state",children:"加载中…"}),!T&&ae!=null&&t.jsx("article",{className:"bim-rd-prose",children:t.jsx(Li,{text:ae,mode:O.readingMode,tables:q,gujiMarkdown:qn(h),properNames:O.properNames})}),!T&&!z&&t.jsx("div",{className:"bim-rd-state",children:"无法加载章节内容"})]})},fp=({data:e,onNavigate:n,className:o,style:r})=>{var u;const s=ue(),{convert:l}=Z(),[d,p]=g.useState(((u=e.divisions[0])==null?void 0:u.name)??null),[c,a]=g.useState(null);return t.jsxs("div",{className:o,style:r,children:[t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:i("fg"),margin:"0 0 8px"},children:l(e.title)}),e.stats&&t.jsxs("div",{style:{fontSize:"13px",color:i("desc-fg"),display:"flex",gap:"16px"},children:[e.total_volumes!=null&&t.jsxs("span",{children:[s.catalog.totalVolumes," ",t.jsx("strong",{children:e.total_volumes})," ",s.unit.juan]}),e.stats.zhulu!=null&&t.jsxs("span",{children:["著錄 ",t.jsx("strong",{children:e.stats.zhulu})," ",s.unit.bu]}),e.stats.cunmu!=null&&t.jsxs("span",{children:["存目 ",t.jsx("strong",{children:e.stats.cunmu})," ",s.unit.bu]}),e.stats.categories!=null&&t.jsxs("span",{children:[e.stats.categories," 類"]})]})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:e.divisions.map(f=>t.jsx(gp,{division:f,expanded:d===f.name,onToggle:()=>p(d===f.name?null:f.name),expandedCat:c,onCatToggle:x=>a(c===x?null:x),onNavigate:n},f.name))})]})},gp=({division:e,expanded:n,onToggle:o,expandedCat:r,onCatToggle:s,onNavigate:l})=>{const{convert:d}=Z(),p=e.categories.reduce((c,a)=>{const u=a.stats||{zhulu:0,cunmu:0};return c+(u.zhulu||0)+(u.cunmu||0)},0);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?`color-mix(in srgb, ${i("primary")} 6%, transparent)`:i("bg"),cursor:"pointer",fontSize:"15px",fontWeight:600,color:i("fg"),textAlign:"left"},children:[t.jsx("span",{children:d(e.name)}),t.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:i("desc-fg")},children:[e.categories.length," 類 · ",p," 部",t.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&t.jsx("div",{style:{padding:"4px 0"},children:e.categories.map(c=>{const a=`${e.name}/${c.name}`;return t.jsx(mp,{category:c,expanded:r===a,onToggle:()=>s(a),onNavigate:l},c.name)})})]})},mp=({category:e,expanded:n,onToggle:o,onNavigate:r})=>{var c,a,u,f;const{convert:s}=Z(),l=((c=e.books)==null?void 0:c.zhulu)||[],d=((a=e.books)==null?void 0:a.cunmu)||[],p=(((u=e.stats)==null?void 0:u.zhulu)||l.length)+(((f=e.stats)==null?void 0:f.cunmu)||d.length);return t.jsxs("div",{children:[t.jsxs("button",{onClick:o,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?i("input-bg"):"transparent",cursor:"pointer",fontSize:"13px",color:i("fg"),textAlign:"left"},children:[t.jsxs("span",{style:{fontWeight:500},children:[s(e.name),e.volumes&&t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),marginLeft:"8px",fontWeight:400},children:["卷",e.volumes]})]}),t.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[p," 部 ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&t.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&t.jsx(Do,{label:"著錄",books:l,onNavigate:r}),d.length>0&&t.jsx(Do,{label:"存目",books:d,onNavigate:r})]})]})},Do=({label:e,books:n,onNavigate:o})=>{const{convert:r}=Z(),s=Pe(),[l,d]=g.useState(n.length<=20),p=l?n:n.slice(0,10);return t.jsxs("div",{style:{marginBottom:"8px"},children:[t.jsxs("div",{style:{fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:[e," (",n.length,")"]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:p.map((c,a)=>t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[t.jsx("span",{style:{fontWeight:500,color:i("fg")},children:c.work_id&&o?t.jsx("a",{href:s(c.work_id),onClick:u=>{u.metaKey||u.ctrlKey||(u.preventDefault(),o(c.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:`1px dashed ${i("link-fg")}`},children:r(c.title)}):r(c.title)}),c.volumes&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:r(c.volumes)}),c.author&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:r(c.author).slice(0,20)})]},a))}),!l&&t.jsxs("button",{onClick:()=>d(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:i("primary"),background:"transparent",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",cursor:"pointer"},children:["展開全部 ",n.length," 條"]})]})},Ke=({title:e,onSave:n,onAskAI:o,extraButtons:r,children:s})=>{const l=ue();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:i("fg")},children:e}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[r,o&&t.jsx("button",{onClick:o,style:bp,children:"AI"}),n&&t.jsx("button",{onClick:n,style:hp,children:l.action.save})]})]}),s]})},hp={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},bp={padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Ge=({label:e,value:n,onChange:o,placeholder:r,disabled:s})=>t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},children:e}),t.jsx("input",{type:"text",value:n,onChange:l=>o(l.target.value),placeholder:r,disabled:s,style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),bt=({value:e,onChange:n,placeholder:o})=>{const r=g.useRef(null);return g.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[e]),t.jsx("textarea",{ref:r,value:e||"",onChange:s=>n(s.target.value),placeholder:o,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},bn=({children:e,color:n,style:o})=>t.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||i("primary-soft"),color:i(n?"on-color-fg":"fg"),...o},children:e});function yp(e){const n=e.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const xn=({value:e,onChange:n,label:o})=>{const[r,s]=g.useState(!1),l=g.useRef(null),d=yp(e||"");return g.useEffect(()=>{r&&l.current&&l.current.focus()},[r]),!r&&d?t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ho,children:o}),t.jsxs("div",{onClick:()=>s(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:`1px solid ${i("input-border")}`,borderRadius:"2px",background:i("input-bg"),cursor:"pointer",minHeight:"30px"},children:[t.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:i("fg")},children:d.name}),t.jsx(bn,{children:d.id})]})]}):t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:Ho,children:o}),t.jsx("input",{ref:l,type:"text",value:e||"",onChange:p=>n(p.target.value),onBlur:()=>s(!1),style:{width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},Ho={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500};function jp(e){switch(e){case"url":return i("source-url");case"bookID":return i("source-bookid");default:return i("desc-fg")}}function vp(e){switch(e){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Ms=({items:e,onChange:n,onOpenEntityPicker:o})=>{const r=ue(),[s,l]=g.useState(null),d=()=>{n([...e,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),l(e.length)},p=f=>{n(e.filter((x,m)=>m!==f)),s===f&&l(null)},c=(f,x,m)=>{const j=[...e];j[f]={...j[f],[x]:m},n(j)},a=(f,x)=>{const m=[...e];m[f]={...m[f],type:x,id:"",name:""},n(m),x==="bookID"&&o&&o(j=>{const w=[...e];w[f]={...w[f],id:j.id,name:j.title,type:"bookID"},n(w)})},u=f=>{o&&o(x=>{const m=[...e];m[f]={...m[f],id:x.id,name:x.title,type:"bookID"},n(m)})};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((f,x)=>t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>l(s===x?null:x),children:[t.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:s===x?"▼":"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:i("fg")},children:f.name||`${r.editor.sourcePlaceholder} ${x+1}`}),f.type&&t.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:jp(f.type),color:i("on-color-fg"),borderRadius:"3px",fontWeight:500},children:vp(f.type)}),t.jsx("button",{onClick:m=>{m.stopPropagation(),p(x)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:r.editor.deleteThisSource,children:"✕"})]}),s===x&&t.jsx("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!f.type&&t.jsxs("div",{children:[t.jsx("label",{style:ot,children:r.editor.selectSourceType}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsxs("button",{onClick:()=>a(x,"bookID"),style:{...Go,borderColor:i("source-bookid"),color:i("source-bookid")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"📚"}),t.jsx("span",{children:"Book ID"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.fromExistingBook})]}),t.jsxs("button",{onClick:()=>a(x,"url"),style:{...Go,borderColor:i("source-url"),color:i("source-url")},children:[t.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),t.jsx("span",{children:"URL"}),t.jsx("span",{style:{fontSize:"11px",opacity:.7},children:r.editor.enterUrl})]})]})]}),f.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:ot,children:r.action.selectBookOrWork}),t.jsx("button",{onClick:()=>{const m=[...e];m[x]={...m[x],type:"",id:"",name:""},n(m)},style:Uo,children:r.action.changeType})]}),f.id&&f.name?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:i("bg"),border:`1px solid ${i("source-bookid")}`,borderRadius:"6px"},children:[t.jsx("span",{style:{color:i("source-bookid"),fontSize:"16px"},children:"✓"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:500},children:f.name}),t.jsx("code",{style:{fontSize:"11px",background:i("primary-soft"),padding:"2px 6px",borderRadius:"3px"},children:f.id})]}),t.jsx("button",{onClick:()=>u(x),style:{background:"transparent",border:`1px solid ${i("widget-border")}`,color:i("fg"),cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:r.action.reselect})]}):t.jsxs("button",{onClick:()=>u(x),style:{width:"100%",padding:"14px",border:`2px dashed ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[t.jsx("span",{children:"🔍"}),t.jsx("span",{children:r.action.clickToSelectBookOrWork})]})]})}),f.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:ot,children:r.label.sourceName}),t.jsx("button",{onClick:()=>{const m=[...e];m[x]={...m[x],type:"",id:"",name:""},n(m)},style:Uo,children:r.action.changeType})]}),t.jsx("input",{type:"text",value:f.name,onChange:m=>c(x,"name",m.target.value),placeholder:r.editor.sourceNamePlaceholder,style:wt})]}),t.jsxs("div",{children:[t.jsx("label",{style:ot,children:r.label.urlAddress}),t.jsx("input",{type:"text",value:f.id,onChange:m=>c(x,"id",m.target.value),placeholder:"https://...",style:wt})]})]}),f.type&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{borderTop:`1px dashed ${i("widget-border")}`,paddingTop:"12px",marginTop:"4px"},children:t.jsx("label",{style:{...ot,opacity:.7},children:r.label.optionalInfo})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:ot,children:r.label.detailsOptional}),t.jsx("input",{type:"text",value:f.details,onChange:m=>c(x,"details",m.target.value),placeholder:r.editor.detailsPlaceholder,style:wt})]}),t.jsxs("div",{children:[t.jsx("label",{style:ot,children:r.label.positionOptional}),t.jsx("input",{type:"text",value:f.position,onChange:m=>c(x,"position",m.target.value),placeholder:"如: 卷三, p.52",style:wt})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsxs("div",{children:[t.jsx("label",{style:ot,children:r.label.dataVersionOptional}),t.jsx("input",{type:"text",value:f.version,onChange:m=>c(x,"version",m.target.value),placeholder:"如: v1.0, 2024-01",style:wt})]}),t.jsxs("div",{children:[t.jsx("label",{style:ot,children:r.label.processorVersionOptional}),t.jsx("input",{type:"text",value:f.processor_version,onChange:m=>c(x,"processor_version",m.target.value),placeholder:"如: v0.1",style:wt})]})]})]})]})})]},x)),t.jsxs("button",{onClick:d,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[t.jsx("span",{children:"+"}),t.jsx("span",{children:r.action.addSource})]})]})},ot={display:"block",fontSize:"11px",color:i("desc-fg"),marginBottom:"4px",fontWeight:500},wt={width:"100%",padding:"6px 8px",background:i("input-bg"),color:i("input-fg"),border:`1px solid ${i("input-border")}`,borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},Go={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:i("bg"),border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},Uo={background:"transparent",border:"none",color:i("link-fg"),cursor:"pointer",fontSize:"11px",padding:0};function Fs(e){if(!e||!e.trim())return[];try{const n=JSON.parse(e);if(Array.isArray(n))return n.map(o=>({id:o.id||"",name:o.name||"",type:o.type||"",details:o.details||"",position:o.position||"",version:o.version||"",processor_version:o.processor_version||""}))}catch{}return[]}function Ps(e){return!e||e.length===0?"":JSON.stringify(e)}const Os=({entityType:e,entityId:n,entityTitle:o,parentWork:r,parentCollection:s,belongsToWork:l,belongsToCollection:d,childWorks:p,childCollections:c,containedBooks:a,siblingBooks:u,onLinkEntity:f,onUnlinkEntity:x,onViewEntity:m,onCreateAndLink:j,onSaveRelations:w})=>{const h=ue();return t.jsxs("div",{style:{background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[t.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:"🔗"}),t.jsx("span",{children:h.section.relations})]}),w&&t.jsx("button",{onClick:w,style:kp,children:h.action.save})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e==="book"&&t.jsxs(t.Fragment,{children:[t.jsx(Pt,{direction:"up",title:h.relation.belongsToWork,entity:l,onView:m,onUnlink:()=>x("workId"),onLink:()=>f("workId","work"),onCreate:()=>j("workId","work",{title:o}),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),t.jsx(Pt,{direction:"up",title:h.relation.containedInCollection,entity:d,onView:m,onUnlink:()=>x("collectionId"),onLink:()=>f("collectionId","collection"),onCreate:()=>j("collectionId","collection",{title:o}),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),l&&u&&u.length>0&&t.jsx(St,{direction:"horizontal",title:`${h.relation.siblingVersions} (${u.length})`,entities:u,onView:m,onAdd:()=>j("siblingBook","book",{workId:l.id}),addLabel:h.relation.addVersionForWork,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore})]}),e==="work"&&t.jsxs(t.Fragment,{children:[t.jsx(Pt,{direction:"up",title:h.relation.parentWork,entity:r,onView:m,onUnlink:()=>x("parentWorkId"),onLink:()=>f("parentWorkId","work"),onCreate:()=>j("parentWorkId","work"),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),p&&p.length>0&&t.jsx(St,{direction:"down",title:`${h.relation.childWorks} (${p.length})`,entities:p,onView:m,onAdd:()=>j("childWork","work",{parentWorkId:n}),addLabel:h.action.addSubWork,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore}),c&&c.length>0&&t.jsx(St,{direction:"down",title:`${h.relation.collectionImpl} (${c.length})`,entities:c,onView:m,onAdd:()=>j("childCollection","collection",{workId:n}),addLabel:h.action.addCollectionImpl,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore}),t.jsx(St,{direction:"down",title:`${h.relation.allVersions} (${(a==null?void 0:a.length)??0})`,entities:a||[],onView:m,onAdd:()=>j("childBook","book",{workId:n}),addLabel:h.action.addVersion,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore})]}),e==="collection"&&t.jsxs(t.Fragment,{children:[t.jsx(Pt,{direction:"up",title:h.relation.correspondingWork,entity:l,onView:m,onUnlink:()=>x("workId"),onLink:()=>f("workId","work"),onCreate:()=>j("workId","work",{title:o}),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),t.jsx(Pt,{direction:"up",title:h.relation.parentCollection,entity:s,onView:m,onUnlink:()=>x("parentCollectionId"),onLink:()=>f("parentCollectionId","collection"),onCreate:()=>j("parentCollectionId","collection"),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),t.jsx(St,{direction:"down",title:`${h.relation.childCollections} (${(c==null?void 0:c.length)??0})`,entities:c||[],onView:m,onAdd:()=>j("childCollection","collection",{parentCollectionId:n}),addLabel:h.action.addSubCollection,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore}),t.jsx(St,{direction:"down",title:`${h.relation.containedBooks} (${(a==null?void 0:a.length)??0})`,entities:a||[],onView:m,onAdd:()=>j("childBook","book",{collectionId:n}),addLabel:h.action.addBook,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore})]})]})]})},Pt=({direction:e,title:n,entity:o,onView:r,onUnlink:s,onLink:l,onCreate:d,linkLabel:p,createLabel:c,notLinkedLabel:a,viewLabel:u,unlinkLabel:f})=>{const x=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),m=e==="up"?"⬆️":e==="down"?"⬇️":"↔️";return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:x,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:m}),t.jsx("span",{children:n})]}),o?t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:i("bg"),borderRadius:"4px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ds(o.type)}),t.jsx("span",{style:{fontWeight:500},children:o.title}),t.jsx("span",{style:{fontSize:"11px",opacity:.6},children:o.id})]}),t.jsxs("div",{style:{display:"flex",gap:"4px"},children:[t.jsx(Vo,{onClick:()=>r(o),title:u,children:"👁️"}),t.jsx(Vo,{onClick:s,title:f,danger:!0,children:"✕"})]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:a}),t.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[t.jsx(oi,{onClick:l,children:p}),t.jsx(oi,{onClick:d,primary:!0,children:c})]})]})},St=({direction:e,title:n,entities:o,onView:r,onAdd:s,addLabel:l,noneLabel:d,expandMoreLabel:p})=>{const[c,a]=g.useState(!1),u=i(e==="up"?"relation-up":e==="down"?"relation-down":"relation-flat"),f=e==="up"?"⬆️":e==="down"?"⬇️":"↔️",x=c?o:o.slice(0,5);return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",padding:"10px",background:i("input-bg")},children:[t.jsxs("div",{style:{fontSize:"12px",color:u,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{children:f}),t.jsx("span",{children:n})]}),o.length>0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[x.map(m=>t.jsxs("div",{onClick:()=>r(m),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:i("bg"),borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[t.jsx("span",{children:Ds(m.type)}),t.jsx("span",{children:m.title})]},m.id)),o.length>5&&!c&&t.jsxs("div",{onClick:()=>a(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:i("link-fg"),cursor:"pointer"},children:[p," (",o.length-5,")"]})]}):t.jsx("div",{style:{padding:"8px",background:i("bg"),borderRadius:"4px",color:i("desc-fg"),fontSize:"12px",textAlign:"center"},children:d}),t.jsx("div",{style:{marginTop:"8px"},children:t.jsxs(oi,{onClick:s,primary:!0,children:["+ ",l]})})]})},Vo=({onClick:e,title:n,danger:o,children:r})=>t.jsx("button",{onClick:s=>{s.stopPropagation(),e()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:o?i("danger"):"inherit",opacity:.7},children:r}),oi=({onClick:e,primary:n,children:o})=>t.jsx("button",{onClick:e,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":`1px solid ${i("widget-border")}`,borderRadius:"4px",background:n?i("primary"):"transparent",color:n?i("primary-fg"):"inherit",cursor:"pointer"},children:o});function Ds(e){switch(e){case"work":return"📜";case"book":return"📖";case"collection":return"📚";default:return}}const kp={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},Hs=({isOpen:e,entityType:n,title:o,onSelect:r,onCancel:s,onCreate:l,searchResults:d,onSearch:p,isLoading:c,excludeId:a})=>{const[u,f]=g.useState(""),x=a?d.filter(h=>h.id!==a):d;g.useEffect(()=>{e&&(f(""),p(""))},[e]);const m=h=>{f(h),p(h)};if(!e)return null;const j=n==="work"?"作品":n==="book"?"书籍":"丛编",w=n==="work"?"📜":n==="book"?"📖":"📚";return t.jsx("div",{style:wp,children:t.jsxs("div",{style:Sp,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:o}),t.jsx("button",{onClick:s,style:_p,children:"✕"})]}),t.jsx("div",{style:{padding:"12px 16px"},children:t.jsx("input",{type:"text",value:u,onChange:h=>m(h.target.value),placeholder:`搜索${j}名称或 ID...`,autoFocus:!0,style:$p})}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:c?t.jsx("div",{style:Wn,children:"搜索中..."}):x.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:x.map(h=>t.jsxs("div",{onClick:()=>r(h),style:zp,children:[t.jsx("span",{style:{fontSize:"16px"},children:w}),t.jsxs("div",{style:{flex:1},children:[t.jsxs("div",{style:{fontWeight:500},children:[h.title,h.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:h.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[h.id,h.author&&` · ${h.author}`,h.dynasty&&` · ${h.dynasty}`]})]})]},h.id))}):u?t.jsxs("div",{style:Wn,children:["未找到匹配的",j]}):t.jsxs("div",{style:Wn,children:["输入关键词搜索",j]})}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsxs("button",{onClick:l,style:Cp,children:["创建新",j,"并关联"]})]})]})})},wp={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Sp={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},_p={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},$p={width:"100%",padding:"10px 12px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},zp={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:i("primary-soft")},Wn={padding:"20px",textAlign:"center",color:i("desc-fg")},Cp={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Yo={work:"作品",book:"书籍",collection:"丛编",entity:"人物"},Ip={work:"📜",book:"📖",collection:"📚",entity:"👤"},Gs=({isOpen:e,entityType:n,relationField:o,inheritData:r,onConfirm:s,onCancel:l})=>{const[d,p]=g.useState(""),c=g.useRef(null);g.useEffect(()=>{e&&(p((r==null?void 0:r.title)||""),setTimeout(()=>{var x,m;(x=c.current)==null||x.focus(),(m=c.current)==null||m.select()},100))},[e,r==null?void 0:r.title]);const a=x=>{x.key==="Enter"&&d.trim()?u():x.key==="Escape"&&l()},u=()=>{d.trim()&&s(d.trim(),{...r,title:d.trim()})};if(!e)return null;const f=()=>{switch(o){case"parentWorkId":return"创建父作品";case"workId":return"创建所属作品";case"collectionId":return"创建所属丛编";case"parentCollectionId":return"创建父丛编";case"childWork":return"创建子作品";case"childBook":case"siblingBook":return"创建书籍";case"childCollection":return"创建子丛编";default:return`创建新${Yo[n]}`}};return t.jsx("div",{style:Tp,onClick:x=>{x.target===x.currentTarget&&l()},children:t.jsxs("div",{style:Ep,onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Ip[n]}),t.jsx("span",{children:f()})]}),t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:i("fg")},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",t.jsx("span",{style:{color:i("danger"),marginLeft:"4px"},children:"*"})]}),t.jsx("input",{ref:c,type:"text",value:d,onChange:x=>p(x.target.value),onKeyDown:a,placeholder:`请输入${Yo[n]}名称...`,style:Rp})]}),((r==null?void 0:r.author)||(r==null?void 0:r.dynasty))&&t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),background:i("input-bg"),padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[t.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(r==null?void 0:r.author)&&t.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&t.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),t.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[t.jsx("button",{onClick:l,style:Np,children:"取消"}),t.jsx("button",{onClick:u,disabled:!d.trim(),style:{...Lp,opacity:d.trim()?1:.6,cursor:d.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},Tp={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Ep={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:i("shadow-dialog")},Rp={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${i("input-border")}`,borderRadius:"4px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box"},Np={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer"},Lp={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg")};function Bp(e){switch(e){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Us(e){switch(e){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Ap(e){switch(e){case"work":return i("editor-type-work");case"collection":return i("editor-type-collection");case"book":return i("editor-type-book");default:return i("desc-fg")}}const Vs=({isOpen:e,title:n,filterType:o="all",recentEntities:r=[],excludeId:s,showCreateButton:l=!1,createButtonText:d,onSelect:p,onCancel:c,onCreate:a,onSearch:u})=>{const[f,x]=g.useState(""),[m,j]=g.useState([]),[w,h]=g.useState(!1),[b,y]=g.useState("recent");g.useEffect(()=>{e&&(x(""),j([]),y(r.length>0?"recent":"search"))},[e,r.length]),g.useEffect(()=>{if(!f.trim()){j([]);return}const z=setTimeout(async()=>{h(!0);try{j(await u(f,o))}catch{j([])}finally{h(!1)}},300);return()=>clearTimeout(z)},[f,o,u]);const k=g.useCallback(z=>{x(z.target.value),z.target.value.trim()&&y("search")},[]),$=g.useCallback(z=>s?z.filter(N=>N.id!==s):z,[s]);if(!e)return null;const v=n||(o==="all"?"选择实体":`选择${Us(o)}`),_=$(r),S=$(m);return t.jsx("div",{style:Mp,children:t.jsxs("div",{style:Fp,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:v}),t.jsx("button",{onClick:c,style:Pp,children:"✕"})]}),t.jsx("div",{style:{padding:"16px 20px 12px"},children:t.jsxs("div",{style:{position:"relative"},children:[t.jsx("input",{type:"text",value:f,onChange:k,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Op}),t.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),w&&t.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),_.length>0&&t.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:`1px solid ${i("widget-border")}`},children:[t.jsxs(qo,{active:b==="recent",onClick:()=>y("recent"),children:["最近使用 (",_.length,")"]}),t.jsxs(qo,{active:b==="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:b==="recent"&&_.length>0?t.jsx(Ko,{entities:_,onSelect:p}):f.trim()?w?t.jsx(Mn,{message:"搜索中..."}):S.length>0?t.jsx(Ko,{entities:S,onSelect:p}):t.jsx(Mn,{message:"未找到匹配的结果"}):t.jsx(Mn,{message:"输入关键词开始搜索"})}),l&&a&&t.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${i("widget-border")}`,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),t.jsx("button",{onClick:a,style:Dp,children:d||"创建新实体"})]})]})})},qo=({active:e,onClick:n,children:o})=>t.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:e?`2px solid ${i("primary")}`:"2px solid transparent",background:"transparent",color:i(e?"fg":"desc-fg"),cursor:"pointer",fontSize:"12px",fontWeight:e?600:400,marginBottom:"-1px"},children:o}),Ko=({entities:e,onSelect:n})=>t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:e.map(o=>t.jsx(Wp,{entity:o,onClick:()=>n(o)},o.id))}),Wp=({entity:e,onClick:n})=>{const[o,r]=g.useState(!1);return t.jsxs("div",{onClick:n,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:i("primary-soft"),transition:"background 0.1s"},children:[t.jsx("span",{style:{fontSize:"18px"},children:Bp(e.type)}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.title,e.edition&&t.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:i("desc-fg"),marginLeft:"4px"},children:e.edition})]}),t.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[t.jsx("code",{style:{fontSize:"10px",background:i("primary-soft"),padding:"1px 4px",borderRadius:"2px"},children:e.id}),e.author&&t.jsx("span",{children:e.author}),e.dynasty&&t.jsx("span",{children:e.dynasty})]})]}),t.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:Ap(e.type),color:i("on-color-fg"),borderRadius:"4px",fontWeight:500,flexShrink:0},children:Us(e.type)})]})},Mn=({message:e})=>t.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:i("desc-fg"),fontSize:"13px"},children:e}),Mp={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Fp={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:i("shadow-dialog")},Pp={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Op={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),fontSize:"13px",boxSizing:"border-box"},Dp={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:i("primary"),color:i("primary-fg"),cursor:"pointer"},Hp={work:i("editor-type-work"),collection:i("editor-type-collection"),book:i("editor-type-book"),entity:i("editor-type-entity")},Gp={work:"📜",collection:"📚",book:"📖",entity:"👤"},Ys=({data:e,onChange:n,onSave:o,transport:r,onNavigate:s,showDelete:l,onDelete:d,onAskAI:p,renderSectionActions:c,onDownloadResource:a,downloadStatuses:u,relations:f,onRelationsChange:x})=>{var me;const m=ue(),[j,w]=g.useState(!1),[h,b]=g.useState("work"),[y,k]=g.useState(""),[$,v]=g.useState(""),[_,S]=g.useState([]),[z,N]=g.useState(!1),[T,C]=g.useState(!1),[D,B]=g.useState("work"),[O,M]=g.useState(""),[X,Y]=g.useState(),[E,ee]=g.useState(!1),[F,q]=g.useState(null),[ae,ne]=g.useState([]);g.useRef(null);const Q=e.type,ie=Q==="work",ge=Q==="collection",re=Q==="book",le=g.useCallback((U,R)=>{n({...e,[U]:R})},[e,n]),pe=g.useCallback((U,R)=>{k(U),b(R),v(m.editor.selectToLink+m.indexType[R]),S([]),w(!0)},[m]),Re=g.useCallback(U=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(e.id,U)},[r,e.id]),$e=g.useCallback(U=>{s==null||s(U.id,U.type)},[s]),ye=g.useCallback((U,R,V)=>{const W={...V,author:(V==null?void 0:V.author)||e.author,dynasty:V==null?void 0:V.dynasty};B(R),M(U),Y(W),C(!0)},[e.author]),Se=g.useCallback((U,R)=>{r!=null&&r.createAndLink&&r.createAndLink(e.id,O,{type:D,title:U,inheritData:R}),C(!1)},[r,e.id,O,D]),Ne=g.useCallback(U=>{if(!U.trim()){S([]);return}N(!0),r!=null&&r.searchEntities&&r.searchEntities(U,h).then(R=>{S(R),N(!1)}).catch(()=>{S([]),N(!1)})},[r,h]),je=g.useCallback(U=>{r!=null&&r.linkEntity&&r.linkEntity(e.id,y,U.id),w(!1)},[r,e.id,y]),H=g.useCallback(()=>{o()},[o]),ce=g.useCallback(U=>{q(()=>U),ee(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(ne).catch(()=>{})},[r]),oe=g.useCallback((U,R)=>r!=null&&r.searchEntities?r.searchEntities(U,R==="all"?void 0:R):Promise.resolve([]),[r]),he=g.useCallback(U=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(U),ne(R=>[U,...R.filter(V=>V.id!==U.id)].slice(0,10)),F==null||F(U),ee(!1),q(null)},[r,F]);return t.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:`1px solid ${i("widget-border")}`,paddingBottom:"16px"},children:t.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{children:Gp[Q]}),t.jsx("span",{children:e.title||m.editor.untitled}),t.jsx(bn,{children:e.id}),t.jsx(bn,{color:Hp[Q],children:m.indexType[Q]})]})}),t.jsx(Ke,{title:m.section.basicInfo,onSave:o,onAskAI:p?()=>p("基本信息"):void 0,extraButtons:c==null?void 0:c("基本信息"),children:t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[t.jsx(xn,{label:ie?m.editor.workTitle:ge?m.editor.collectionTitle:m.editor.bookTitle,value:e.title,onChange:U=>le("title",U)}),re&&t.jsx(xn,{label:m.editor.belongsToWork,value:e.workName||"",onChange:U=>le("workName",U)}),t.jsx(Ge,{label:m.editor.authorLabel,value:e.author||"",onChange:U=>le("author",U)}),t.jsx(Ge,{label:m.editor.publicationYearLabel,value:e.publicationYear||"",onChange:U=>le("publicationYear",U)}),(re||ge)&&t.jsx(xn,{label:m.editor.containedIn,value:e.collection||"",onChange:U=>le("collection",U)}),(re||ge)&&t.jsx(Ge,{label:m.editor.holderLabel,value:e.holder||"",onChange:U=>le("holder",U)}),(re||ge)&&t.jsx(Ge,{label:re?m.editor.pageLabel:m.editor.volumeLabel,value:e.pages||"",onChange:U=>le("pages",U)}),t.jsx("div",{style:{gridColumn:"1 / -1"},children:t.jsx(Ge,{label:m.editor.firstImageLabel,value:e.firstImage||"",onChange:U=>le("firstImage",U)})})]})}),t.jsx(Ke,{title:m.section.description,onSave:o,onAskAI:p?()=>p("介绍"):void 0,children:t.jsx(bt,{value:e.description||"",onChange:U=>le("description",U),placeholder:m.editor.descriptionPlaceholder})}),(((me=e.additional_works)==null?void 0:me.length)||0)>0&&t.jsx(Ke,{title:m.section.additionalWorks,onSave:o,children:t.jsx(Up,{items:e.additional_works||[],onChange:U=>le("additional_works",U)})}),t.jsx(Ke,{title:m.section.indexedBy,onSave:o,onAskAI:p?()=>p("收录于"):void 0,children:t.jsx(Vp,{items:e.indexed_by||[],onChange:U=>le("indexed_by",U)})}),t.jsx(Ke,{title:m.section.emendatedBy,onSave:o,onAskAI:p?()=>p("考证"):void 0,children:t.jsx(Yp,{items:e.emendated_by||[],onChange:U=>le("emendated_by",U)})}),t.jsx(Ke,{title:m.section.textResources,onSave:o,onAskAI:p?()=>p("资源"):void 0,children:t.jsx(Gn,{items:e.resources||[],onChange:U=>le("resources",U),onDownload:a,downloadStatuses:u,filterType:"text"})}),t.jsx(Ke,{title:m.section.imageResources,onSave:o,children:t.jsx(Gn,{items:e.resources||[],onChange:U=>le("resources",U),onDownload:a,downloadStatuses:u,filterType:"image"})}),t.jsx(Ke,{title:m.section.sources,onSave:o,onAskAI:p?()=>p("资料来源"):void 0,children:t.jsx(Ms,{items:Fs(e.sources||""),onChange:U=>le("sources",Ps(U)),onOpenEntityPicker:ce})}),(re||ge)&&t.jsx(Ke,{title:m.section.provenance,onSave:o,onAskAI:p?()=>p("收藏历史"):void 0,children:t.jsx(bt,{value:e.provenance||"",onChange:U=>le("provenance",U),placeholder:m.editor.provenancePlaceholder})}),re&&t.jsx(Ke,{title:m.section.otherEditions,onSave:o,onAskAI:p?()=>p("其他版本"):void 0,children:t.jsx(bt,{value:e.otherEditions||"",onChange:U=>le("otherEditions",U),placeholder:m.editor.otherEditionsPlaceholder})}),t.jsx(Os,{entityType:Q,entityId:e.id,entityTitle:e.title,parentWork:f==null?void 0:f.parentWork,parentCollection:f==null?void 0:f.parentCollection,belongsToWork:f==null?void 0:f.belongsToWork,belongsToCollection:f==null?void 0:f.belongsToCollection,childWorks:f==null?void 0:f.childWorks,childCollections:f==null?void 0:f.childCollections,containedBooks:f==null?void 0:f.containedBooks,siblingBooks:f==null?void 0:f.siblingBooks,onLinkEntity:pe,onUnlinkEntity:Re,onViewEntity:$e,onCreateAndLink:ye,onSaveRelations:H}),l&&d&&t.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:`1px solid ${i("danger-soft-border")}`,background:i("danger-soft-bg"),borderRadius:"4px"},children:[t.jsx("div",{style:{color:i("danger"),fontWeight:600,marginBottom:"8px"},children:m.section.dangerZone}),t.jsx("p",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"12px"},children:m.editor.dangerZoneDesc}),t.jsx("button",{onClick:d,style:{padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("danger")}`,borderRadius:"4px",background:"transparent",color:i("danger"),cursor:"pointer"},children:m.editor.deleteEntity})]}),t.jsx(Hs,{isOpen:j,entityType:h,title:$,onSelect:je,onCancel:()=>w(!1),onCreate:()=>{w(!1),ye(y,h)},searchResults:_,onSearch:Ne,isLoading:z,excludeId:e.id}),t.jsx(Gs,{isOpen:T,entityType:D,relationField:O,inheritData:X,onConfirm:Se,onCancel:()=>C(!1)}),t.jsx(Vs,{isOpen:E,title:m.action.selectBookOrWork,filterType:"all",recentEntities:ae,excludeId:e.id,onSelect:he,onCancel:()=>{ee(!1),q(null)},onSearch:oe})]})};function Up({items:e,onChange:n}){const o=ue(),r=(d,p,c)=>{const a=e.map((u,f)=>f===d?{...u,[p]:c}:u);n(a)},s=d=>n(e.filter((p,c)=>c!==d)),l=()=>n([...e,{book_title:""}]);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((d,p)=>t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[t.jsx(Ge,{label:o.editor.bookNameLabel,value:d.book_title,onChange:c=>r(p,"book_title",c)}),t.jsx("div",{style:{width:"100px"},children:t.jsx(Ge,{label:o.label.juanCount,value:d.n_juan!=null?String(d.n_juan):"",onChange:c=>r(p,"n_juan",c&&parseInt(c,10)||void 0)})}),t.jsx("button",{onClick:()=>s(p),style:{padding:"4px 8px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("muted"),marginTop:"18px"},children:"✕"})]},p)),t.jsx("button",{onClick:l,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:o.action.addAdditionalWork})]})}function qs({items:e,onChange:n,showMeta:o,addLabel:r}){const s=ue(),[l,d]=g.useState(null),p=(u,f,x)=>{const m=e.map((j,w)=>w===u?{...j,[f]:x||void 0}:j);n(m)},c=u=>{n(e.filter((f,x)=>x!==u)),l===u&&d(null)},a=()=>{n([...e,{source:""}]),d(e.length)};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.map((u,f)=>{const x=l===f;return t.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"6px",overflow:"hidden"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:x?`color-mix(in srgb, ${i("primary")} 5%, transparent)`:"transparent",cursor:"pointer"},onClick:()=>d(x?null:f),children:[t.jsx("span",{style:{fontSize:"10px",color:i("desc-fg"),transition:"transform 0.2s",transform:x?"rotate(90deg)":"none"},children:"▶"}),t.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:u.source||s.editor.unnamedSource}),u.source_bid&&t.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:u.source_bid}),t.jsx("button",{onClick:m=>{m.stopPropagation(),c(f)},style:{padding:"2px 6px",fontSize:"11px",border:`1px solid ${i("widget-border")}`,borderRadius:"3px",background:"transparent",cursor:"pointer",color:i("muted")},children:"✕"})]}),!x&&o&&(u.title_info||u.author_info)&&t.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:i("desc-fg")},children:[u.title_info,u.title_info&&u.author_info&&" — ",u.author_info]}),x&&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(Ge,{label:s.label.sourceName,value:u.source,onChange:m=>p(f,"source",m)}),t.jsx(Ge,{label:s.label.sourceBid,value:u.source_bid||"",onChange:m=>p(f,"source_bid",m)})]}),o&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[t.jsx(Ge,{label:s.label.titleInfo,value:u.title_info||"",onChange:m=>p(f,"title_info",m)}),t.jsx(Ge,{label:s.label.authorInfo,value:u.author_info||"",onChange:m=>p(f,"author_info",m)})]}),t.jsx(Ge,{label:s.label.edition,value:u.edition||"",onChange:m=>p(f,"edition",m)})]}),t.jsx(bt,{value:u.summary||"",onChange:m=>p(f,"summary",m),placeholder:s.editor.summaryPlaceholder}),t.jsx(bt,{value:u.comment||"",onChange:m=>p(f,"comment",m),placeholder:s.editor.commentPlaceholder}),t.jsx(bt,{value:u.additional_comment||"",onChange:m=>p(f,"additional_comment",m),placeholder:s.editor.additionalCommentPlaceholder})]})]},f)}),t.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:`1px dashed ${i("input-border")}`,borderRadius:"4px",background:"transparent",cursor:"pointer",color:i("desc-fg"),alignSelf:"flex-start"},children:r})]})}function Vp({items:e,onChange:n}){const o=ue();return t.jsx(qs,{items:e,onChange:n,showMeta:!0,addLabel:o.action.addIndexedBy})}function Yp({items:e,onChange:n}){const o=ue();return t.jsx(qs,{items:e,onChange:n,addLabel:o.action.addEmendatedBy})}function Ks(e){var p,c,a,u,f,x,m;const n=((c=(p=e.authors)==null?void 0:p[0])==null?void 0:c.name)||"",o=((a=e.publication_info)==null?void 0:a.year)||"",r=((u=e.current_location)==null?void 0:u.name)||"",s=(f=e.page_count)!=null&&f.number?String(e.page_count.number):((x=e.page_count)==null?void 0:x.description)||"",l=typeof e.description=="object"&&e.description!==null&&e.description.text||"",d={id:e.id,title:e.title,type:e.type,author:n,publicationYear:o,holder:r,pages:s,description:l,resources:e.resources,additional_works:e.additional_works,indexed_by:e.indexed_by,emendated_by:e.emendated_by};if(e.type==="work"){const j=e;if(Array.isArray(j.related_works)){const w=j.related_works.find(h=>h.relation==="part_of");w&&(d.parentWorkId=w.id,d.parentWorkName=w.title)}}if(e.type==="book"){const j=e;d.workId=j.work_id,Array.isArray(j.contained_in)&&j.contained_in.length>0&&(d.collectionId=(m=j.contained_in[0])==null?void 0:m.id)}return d}function qp(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 Kp=e=>{const{data:n,id:o,transport:r,mode:s="view",onModeChange:l,onChange:d,onSave:p,onDelete:c,onNavigate:a,renderLink:u,onAskAI:f,renderSectionActions:x,onDownloadResource:m,downloadStatuses:j,relations:w,onRelationsChange:h,headerExtra:b,className:y,style:k}=e;ue();const[$,v]=g.useState(s),_=l?s:$;g.useEffect(()=>{s!==$&&v(s)},[s]);const S=g.useCallback(()=>{const O=_==="view"?"edit":"view";l?l(O):v(O)},[_,l]),[z,N]=g.useState(null);g.useEffect(()=>{o&&r&&r.getItem(o).then(O=>{O&&N(O)})},[o,r]);const T=n||z,C=g.useMemo(()=>T?Ks(T):null,[T]),D=l||!n?t.jsx("button",{onClick:S,style:{padding:"4px 12px",fontSize:"12px",border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:_==="edit"?i("accent-bg"):"transparent",color:i(_==="edit"?"on-color-fg":"fg"),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:_==="view"?"切换到编辑模式":"切换到查看模式",children:_==="view"?"✏️ 编辑":"👁 查看"}):null,B=t.jsxs(t.Fragment,{children:[D,b]});return!T&&!C?t.jsx(jt,{}):_==="view"?t.jsx(gi,{data:T,transport:r,onNavigate:a?O=>a(O):void 0,renderLink:u,headerExtra:B,className:y,style:k}):C?t.jsxs("div",{className:y,style:k,children:[B&&t.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:B}),t.jsx(Ys,{data:C,onChange:d||(()=>{}),onSave:p||(()=>{}),transport:r,onNavigate:a,showDelete:!!c,onDelete:c,onAskAI:f,renderSectionActions:x,onDownloadResource:m,downloadStatuses:j,relations:w,onRelationsChange:h})]}):t.jsx("div",{style:{padding:"24px",textAlign:"center",color:i("muted")},children:"无数据"})},Jo=[{value:"bug",label:"反馈错误",icon:"🐛",placeholder:"请描述您发现的错误,包括页面位置和具体内容"},{value:"resource",label:"添加资源",icon:"📚",placeholder:"请提供完整资源链接和简要版本说明"},{value:"suggestion",label:"功能建议",icon:"💡",placeholder:"您希望网站增加或改进什么?"},{value:"contact",label:"想参与",icon:"🤝",placeholder:"想参与整理、校对或合作?简单介绍一下您自己,并留下联系方式(此类留言不公开)"}],Js=({isOpen:e,onClose:n,onSubmit:o,feedbackListUrl:r})=>{const[s,l]=g.useState(null),[d,p]=g.useState(""),[c,a]=g.useState(""),[u,f]=g.useState("idle"),[x,m]=g.useState(""),j=g.useRef(null);g.useEffect(()=>{e&&(l(null),p(""),a(""),f("idle"),m(""))},[e]),g.useEffect(()=>{s&&setTimeout(()=>{var y;return(y=j.current)==null?void 0:y.focus()},100)},[s]),g.useEffect(()=>{if(u==="success"){const y=setTimeout(n,2e3);return()=>clearTimeout(y)}},[u,n]),g.useEffect(()=>{if(!e)return;const y=k=>{k.key==="Escape"&&n()};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[e,n]);const w=async()=>{if(!(!s||!d.trim())){f("submitting"),m("");try{await o({type:s,content:d.trim(),...c.trim()?{contact:c.trim()}:{}}),f("success")}catch(y){f("error"),m(y instanceof Error?y.message:"提交失败,请稍后重试")}}};if(!e)return null;const h=s&&d.trim()&&u!=="submitting",b=Jo.find(y=>y.value===s);return t.jsx("div",{style:Jp,onClick:y=>{y.target===y.currentTarget&&n()},children:t.jsxs("div",{style:Zp,onClick:y=>y.stopPropagation(),children:[t.jsxs("div",{style:Xp,children:[t.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:"反馈"}),t.jsx("button",{onClick:n,style:Qp,"aria-label":"关闭",children:"✕"})]}),u==="success"?t.jsxs("div",{style:ou,children:[t.jsx("span",{style:{fontSize:"32px"},children:"✓"}),t.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:"感谢您的反馈!"}),r&&t.jsx("a",{href:r,style:{fontSize:"13px",color:i("primary"),marginTop:"8px"},children:"查看反馈列表 →"})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},children:Jo.map(y=>t.jsxs("button",{onClick:()=>l(y.value),style:{...eu,...s===y.value?tu:{}},children:[t.jsx("span",{children:y.icon})," ",y.label]},y.value))}),t.jsx("textarea",{ref:j,value:d,onChange:y=>p(y.target.value),placeholder:(b==null?void 0:b.placeholder)||"请先选择反馈类型",maxLength:2e3,disabled:!s||u==="submitting",style:{...nu,opacity:s?1:.6}}),t.jsx("input",{type:"text",value:c,onChange:y=>a(y.target.value),placeholder:"邮箱(选填,仅站方可见,方便我们回复您)",maxLength:200,disabled:!s||u==="submitting","aria-label":"联系方式(选填)",style:su}),t.jsxs("div",{style:{fontSize:"12px",color:i("desc-fg"),textAlign:"right",marginBottom:"12px"},children:[d.length," / 2000"]}),u==="error"&&t.jsx("div",{style:ru,children:x}),t.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:t.jsx("button",{onClick:w,disabled:!h,style:{...iu,opacity:h?1:.6,cursor:h?"pointer":"not-allowed"},children:u==="submitting"?"提交中...":"提交反馈"})})]})]})})},Jp={position:"fixed",top:0,left:0,right:0,bottom:0,background:i("backdrop"),display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Zp={background:i("bg"),border:`1px solid ${i("widget-border")}`,borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:i("shadow-dialog")},Xp={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Qp={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:i("desc-fg"),padding:"4px 8px",borderRadius:"4px"},eu={flex:"1 1 calc(50% - 4px)",padding:"10px 12px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},tu={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},nu={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("input-bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},iu={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},ou={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:i("success")},ru={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginBottom:"12px"},su={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"},ri="--bim-feedback-fab-offset",si=48,lu=16,au=({onSubmit:e,position:n={bottom:24,right:24},feedbackListUrl:o,hidden:r=!1,zIndex:s})=>{const[l,d]=g.useState(!1),p=n.bottom??24;return g.useEffect(()=>{if(r||typeof document>"u")return;const c=document.documentElement;return c.style.setProperty(ri,`calc(${p+si+lu}px + env(safe-area-inset-bottom, 0px))`),()=>{c.style.removeProperty(ri)}},[r,p]),t.jsxs(t.Fragment,{children:[!r&&t.jsx("button",{type:"button",className:"bim-feedback-fab",onClick:()=>d(!0),style:{...cu,zIndex:s??i("feedback-fab-z"),bottom:`calc(${p}px + env(safe-area-inset-bottom, 0px))`,right:n.right},"aria-label":"反馈",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(Js,{isOpen:l,onClose:()=>d(!1),onSubmit:e,feedbackListUrl:o})]})},cu={position:"fixed",width:`${si}px`,height:`${si}px`,borderRadius:"50%",border:"none",background:i("primary"),color:i("primary-fg"),cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:i("shadow-fab"),transition:"transform 0.2s, box-shadow 0.2s"},Zo=[{value:"bug",label:"反馈错误",icon:"🐛",placeholder:"请描述您发现的错误,包括页面位置和具体内容"},{value:"resource",label:"添加资源",icon:"📚",placeholder:"请提供完整资源链接和简要版本说明"},{value:"suggestion",label:"功能建议",icon:"💡",placeholder:"您希望网站增加或改进什么?"},{value:"contact",label:"想参与",icon:"🤝",placeholder:"想参与整理、校对或合作?简单介绍一下您自己,并留下联系方式(此类留言不公开)"}],Zs=({onSubmit:e})=>{const[n,o]=g.useState("bug"),[r,s]=g.useState(""),[l,d]=g.useState(""),[p,c]=g.useState("idle"),[a,u]=g.useState(""),f=g.useRef(null);g.useEffect(()=>{n&&setTimeout(()=>{var w;return(w=f.current)==null?void 0:w.focus()},100)},[n]);const x=async()=>{if(!(!n||!r.trim())){c("submitting"),u("");try{await e({type:n,content:r.trim(),...l.trim()?{contact:l.trim()}:{}}),c("success"),s(""),d(""),o("bug")}catch(w){c("error"),u(w instanceof Error?w.message:"提交失败,请稍后重试")}}},m=n&&r.trim()&&p!=="submitting",j=Zo.find(w=>w.value===n);return p==="success"?t.jsx("div",{style:Xo,children:t.jsxs("div",{style:fu,children:[t.jsx("span",{children:"✓ 感谢您的反馈!"}),t.jsx("button",{onClick:()=>c("idle"),style:gu,children:"继续提交"})]})}):t.jsxs("div",{style:Xo,children:[t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},children:Zo.map(w=>t.jsxs("button",{onClick:()=>o(w.value),style:{...du,...n===w.value?pu:{}},children:[t.jsx("span",{children:w.icon})," ",w.label]},w.value))}),t.jsx("textarea",{ref:f,value:r,onChange:w=>s(w.target.value),placeholder:(j==null?void 0:j.placeholder)||"请先选择反馈类型",maxLength:2e3,disabled:p==="submitting",style:{...uu}}),t.jsx("input",{type:"text",value:l,onChange:w=>d(w.target.value),placeholder:"邮箱(选填,仅站方可见,方便我们回复您)",maxLength:200,disabled:p==="submitting","aria-label":"联系方式(选填)",style:hu}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[t.jsxs("span",{style:{fontSize:"12px",color:i("desc-fg")},children:[r.length," / 2000"]}),t.jsx("button",{onClick:x,disabled:!m,style:{...xu,opacity:m?1:.6,cursor:m?"pointer":"not-allowed"},children:p==="submitting"?"提交中...":"提交"})]}),p==="error"&&t.jsx("div",{style:mu,children:a})]})},Xo={padding:"16px",border:`1px solid ${i("widget-border")}`,borderRadius:"8px",background:i("input-bg")},du={padding:"8px 16px",fontSize:"13px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:"transparent",color:i("fg"),cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},pu={borderColor:i("primary"),background:i("list-active-bg"),color:i("primary"),fontWeight:500},uu={width:"100%",minHeight:"100px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},xu={padding:"6px 20px",fontSize:"13px",border:"none",borderRadius:"6px",background:i("primary"),color:i("primary-fg"),fontWeight:500},fu={display:"flex",alignItems:"center",gap:"12px",color:i("success"),fontSize:"14px"},gu={background:"none",border:"none",color:i("primary"),cursor:"pointer",fontSize:"13px",textDecoration:"underline"},mu={fontSize:"13px",color:i("danger"),padding:"8px 12px",background:i("danger-bg"),borderRadius:"4px",marginTop:"8px"},hu={width:"100%",marginTop:"8px",padding:"8px 12px",fontSize:"13px",border:`1px solid ${i("input-border")}`,borderRadius:"6px",background:i("bg"),color:i("input-fg"),outline:"none",boxSizing:"border-box",fontFamily:"inherit"};function Qo(e){return typeof e=="function"?e():e??"/api/feedback"}const Xs=({resourceId:e,apiUrl:n})=>{const[o,r]=g.useState([]),[s,l]=g.useState(!0),d=g.useCallback(async()=>{const c=Qo(n);l(!0);try{const u=await(await fetch(`${c}?resourceId=${encodeURIComponent(e)}`)).json();u.success&&r(u.items)}catch{}finally{l(!1)}},[e,n]);g.useEffect(()=>{d()},[d]);const p=async c=>{const a=Qo(n),u=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...c,pageUrl:typeof window<"u"?window.location.href:"",resourceId:e})});if(!u.ok){const f=await u.json().catch(()=>null);throw new Error((f==null?void 0:f.error)||"提交失败")}setTimeout(()=>d(),500)};return t.jsxs("div",{children:[t.jsx(Oi,{items:o,loading:s}),t.jsx("div",{style:{marginTop:"24px"},children:t.jsx(Zs,{onSubmit:p})})]})},er={part_of:"所屬",has_part:"包含",contains_text_of:"收錄",collected_in:"叢編",text_carried_by:"載錄",studied_by:"研究",studies:"所考",preceded_by:"前承",followed_by:"後繼",derived_from:"衍生",has_adaptation:"改編",related:"相關"};function tr(e){return e?er[e]??e:er.related}const bu={extant:"今存",fragment:"殘存",partial:"殘存",lost:"已佚",unknown:"未詳"};function yu(e){return bu[e]??e}const ju={text:"全文",image:"影印",textImage:"圖文",physical:"館藏"};function vu(e){return ju[e]??""}function Di({authors:e,onNavigate:n,renderLink:o}){const{convert:r}=Z(),s=(e||[]).filter(l=>l&&l.name);return s.length?t.jsx(t.Fragment,{children:s.map((l,d)=>{const p=vi(l.role);return t.jsxs(g.Fragment,{children:[d>0&&" ",l.dynasty&&t.jsxs("span",{className:"bim-d-meta",style:{fontSize:"inherit",marginRight:2},children:["〔",r(l.dynasty),"〕"]}),l.entity_id?t.jsx(Be,{id:l.entity_id,label:r(l.name),onNavigate:n,renderLink:o,dense:!0}):r(l.name),p&&t.jsx("span",{style:{marginLeft:4},children:r(p)})]},d)})}):null}function Qs(e,n){var p,c;const o=yi(e,n),r=o.mirrors.map(a=>({key:a.key,label:a.label,description:a.description,rows:a.items.filter(u=>u.group_role!=="mirror"),mirrors:a.items.filter(u=>u.group_role==="mirror")})),s=o.buckets.filter(a=>a.key==="image"||a.key==="textImage").flatMap(a=>a.items);s.length&&r.push({key:"_images",label:r.length?"其他影印":void 0,rows:s,mirrors:[]});const l=((p=o.buckets.find(a=>a.key==="physical"))==null?void 0:p.items)??[];return l.length&&r.push({key:"_physical",label:"館藏",rows:l,mirrors:[]}),{text:((c=o.buckets.find(a=>a.key==="text"))==null?void 0:c.items)??[],groups:r}}function el(e,n){const o=(e.url?Nt(e.url):void 0)||e.name,r=Pr(e,n);return r?`${o}(${r})`:o}function Hi({item:e,siblings:n,listedVolumeCounts:o}){const{convert:r}=Z(),[s,l]=g.useState(!1),d=yn(e),p=!!d&&d.expected>0&&!(o!=null&&o.has(d.expected)),c=r(el(e,n)),a=Lt(e),u=Sn(e)||e.details;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[(()=>{var x,m;const f=(x=e.metadata)!=null&&x.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:[((m=e.metadata)==null?void 0:m.fragment)&&t.jsx("span",{className:"bim-d-tag",children:r("殘片")}),e.color_mode&&t.jsx("span",{className:"bim-d-tag",children:r(e.color_mode==="color"?"彩色":"黑白")})]}):null;return a?t.jsxs("a",{href:a,target:"_blank",rel:"noopener noreferrer",children:[c," ",t.jsx("span",{"aria-hidden":"true",children:"↗"}),f]}):t.jsxs("span",{className:"bim-d-zt-name",children:[c,f]})})(),u&&t.jsx("span",{className:"bim-d-meta",children:r(u)}),p&&s&&t.jsx("div",{style:{padding:"0 12px 10px"},children:t.jsx(Si,{item:e})})]}),t.jsx("td",{className:p?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:p&&t.jsx("button",{type:"button",className:"bim-d-more bim-d-ui",style:{marginTop:0},"aria-expanded":s,onClick:()=>l(f=>!f),children:r(s?"收起分冊":`展開 ${d.expected} 冊`)})})]})}function tl({groups:e,listedVolumeCounts:n}){const{convert:o}=Z();return t.jsx(t.Fragment,{children:e.map(r=>t.jsxs("div",{className:"bim-d-rg",children:[r.label&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:o(r.label)}),r.description&&t.jsx("p",{className:"bim-d-rg-d",children:o(r.description)}),r.rows.length>0&&t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:r.rows.map((s,l)=>t.jsx(Hi,{item:s,siblings:r.rows,listedVolumeCounts:n},`${s.id||s.url||s.name}-${l}`))})}),r.mirrors.length>0&&t.jsxs("div",{className:"bim-d-rg-mir bim-d-ui",children:[r.rows.length>0&&t.jsx("span",{className:"bim-d-meta",style:{marginRight:10},children:o("鏡像")}),r.mirrors.map((s,l)=>{const d=Lt(s),p=o(el(s,r.mirrors));return d?t.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",title:s.details?o(s.details):void 0,children:[p," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]},l):t.jsx("span",{style:{marginRight:14},children:p},l)})]})]},r.key))})}const Yt=[{key:"經部",label:"經部",token:"sect-jing"},{key:"史部",label:"史部",token:"sect-shi"},{key:"子部",label:"子部",token:"sect-zi"},{key:"集部",label:"集部",token:"sect-ji"}];function li(e){var o;if(!e)return;const n=e.replace(/经/g,"經").replace(/史/g,"史").replace(/集/g,"集");return(o=Yt.find(r=>n.startsWith(r.key[0])))==null?void 0:o.key}const nr=12,ku=60,nl=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,railTop:l,back:d,railLinks:p})=>{var Se,Ne,je;const c=ue(),{convert:a}=Z(),u=g.useMemo(()=>[...e.books||[],...e.collections||[]],[e.books,e.collections]),[f,x]=g.useState(new Map),[m,j]=g.useState(!1),[w,h]=g.useState(""),[b,y]=g.useState(!1),k=u.length<=ku,$=k||m||!!w||b,v=g.useMemo(()=>$?u:u.slice(0,nr),[u,$]);g.useEffect(()=>{if(!n||v.length===0)return;const H=v.filter(oe=>!f.has(oe));if(H.length===0)return;let ce=!1;return Promise.all(H.map(oe=>n.getItem(oe).then(he=>{const me=he??{};return[oe,{id:oe,title:me.title,edition:me.edition,resources:me.resources,publication_info:me.publication_info,current_location:me.current_location,lineage:me.lineage,measure_info:me.measure_info}]}).catch(()=>[oe,{id:oe}]))).then(oe=>{ce||x(he=>{const me=new Map(he);for(const[U,R]of oe)me.set(U,R);return me})}),()=>{ce=!0}},[n,v,f]);const _=g.useMemo(()=>u.map(H=>f.get(H)??{id:H}),[u,f]),S=u.length>0&&u.every(H=>f.has(H)),z=!!n&&v.some(H=>!f.has(H)),N=k||$,T=g.useMemo(()=>Dr(_,e.version_graph,{era:w,scanOnly:b,sort:N?"year":"default"}),[_,e.version_graph,w,b,N]),C=m?T.rows:T.rows.slice(0,nr),D=T.allRows.filter(H=>H.hasImage).length,B=e.related_works||[],O=B.filter(H=>H.relation==="collected_in"),M=g.useMemo(()=>{const H=["part_of","has_part","studied_by","studies","preceded_by","followed_by"],ce=oe=>{const he=H.indexOf(oe??"");return he<0?H.length:he};return B.filter(oe=>oe.relation!=="collected_in").map((oe,he)=>({r:oe,i:he})).sort((oe,he)=>ce(oe.r.relation)-ce(he.r.relation)||oe.i-he.i).map(oe=>oe.r)},[B]),X=g.useMemo(()=>{const H=yi(e.resources,e.resource_groups);return[...H.mirrors.flatMap(ce=>ce.items.map(oe=>({r:oe,kind:a(ce.label)}))),...H.buckets.flatMap(ce=>ce.items.map(oe=>({r:oe,kind:a(vu(ce.key))})))]},[e.resources,e.resource_groups,a]),Y=e.indexed_by||[],E=e.emendated_by||[],ee=g.useMemo(()=>{var W,A,I;const H=[],ce=(A=(W=e.authors)==null?void 0:W[0])==null?void 0:A.dynasty;ce&&H.push({label:"成書",value:a(ce)});const oe=at(e,c.unit.juan);if(oe){const G=(I=e.juan_count)==null?void 0:I.description;H.push({label:"卷帙",value:t.jsxs(t.Fragment,{children:[a(oe),G&&G!==oe?t.jsxs("span",{className:"bim-d-meta",children:["(",a(G),")"]}):null]})})}e.loss_status&&H.push({label:"存佚",value:a(yu(e.loss_status))});const he=T.allRows.filter(G=>G.sortYear!=null),me=he.length>0?he.reduce((G,P)=>G.sortYear<=P.sortYear?G:P):null;me!=null&&me.era.era?H.push({label:"最早存世",value:a([me.era.era,me.era.reign].filter(Boolean).join(" ")),title:me.era.source==="edition"?a("據版本題名推斷"):void 0}):z&&H.push({label:"最早存世",value:t.jsx("span",{className:"bim-d-meta","aria-label":a("載入中"),children:"…"})}),E.length&&H.push({label:"考證",value:`${E.length} ${a("條")}`});const U=ir(e.additional_titles);U.length&&H.push({label:"又名",value:U.map(a).join("、")});const R=ir(e.attached_texts);R.length&&H.push({label:"附載",value:R.map(a).join("、")});const V=(e.additional_works||[]).map(G=>a(G.book_title)+(G.n_juan!=null?` ${G.n_juan}${a(c.unit.juan)}`:""));return V.length&&H.push({label:"附錄",value:V.join("、")}),H},[e,a,c,z,T.allRows,E.length]),q=[{value:e._edition_count??u.length,label:"版本"},{value:S?D:0,label:"有影印"},{value:Y.length,label:"家著錄"}],ae=e.classification,ne=ae?[ae.l1,ae.l2,ae.l3,ae.l4].filter(Boolean).map(H=>a(H)):[],Q=e.subtype?a(c.workSubtype[e.subtype]??e.subtype):"",ie=t.jsx(Qt,{title:a(e.title),byline:t.jsx(Di,{authors:e.authors,onNavigate:o,renderLink:r}),meta:t.jsx(Me,{items:[...ne,ae!=null&&ae.source?a(`據《${ae.source.split("/")[0]}》`):"",Q]}),description:(Se=e.description)!=null&&Se.text?t.jsxs(t.Fragment,{children:[t.jsx(lt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}),(Ne=e.description.sources)!=null&&Ne.length?t.jsx("div",{className:"bim-d-meta bim-d-ui",style:{marginTop:6,fontSize:12},children:e.description.sources.map(H=>a(sc(H))).filter(Boolean).join(" · ")}):null]}):void 0,stats:q,facts:ee,readAction:s,foot:t.jsx(en,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:(je=e.appendix)==null?void 0:je.map((H,ce)=>t.jsxs("details",{style:{marginTop:12},children:[t.jsx("summary",{className:"bim-d-ui",style:{cursor:"pointer",fontSize:13,minHeight:32},children:a(H.title)}),t.jsx(lt,{text:H.text,plainStrong:!0,style:{marginTop:8,fontSize:14,lineHeight:1.9}})]},ce))}),ge=T.eras.length>=2?[{key:"",label:c.catalog.all},...T.eras.map(H=>({key:H,label:`${H} ${T.allRows.filter(ce=>ce.era.era===H).length}`}))]:[],re=[];u.length&&re.push({id:"versions",label:"版本",count:u.length}),Y.length&&re.push({id:"catalogs",label:"著錄",count:Y.length}),O.length&&re.push({id:"collected",label:"收入叢編",count:O.length}),M.length&&re.push({id:"related",label:"相關書目",count:M.length}),X.length&&re.push({id:"resources",label:"在線資源",count:X.length});const le=u.length===0&&Y.length===0,pe=t.jsxs(t.Fragment,{children:[u.length>0&&t.jsxs(Fe,{id:"versions",title:"版本",meta:t.jsx(Me,{items:[a(`共 ${u.length} 種`),S&&D?a(`${D} 種有影印`):"",T.rows.length!==T.allRows.length?a(`當前 ${T.rows.length} 種`):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui","data-pending":z&&ge.length===0&&u.length>1?"":void 0,children:[ge.length>0&&t.jsx($n,{items:ge,value:w,onChange:H=>{h(H),j(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx(es,{label:"只看有影印",checked:b,onChange:H=>{y(H),j(!1)}}),t.jsx("span",{className:"bim-d-meta",children:a(N?"按年代排列":"按著錄順序")})]}),t.jsxs("table",{className:"bim-d-zt bim-d-zt-ver",children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:a("版本")}),t.jsx("th",{children:a("年代")}),t.jsx("th",{children:a("館藏")}),t.jsx("th",{children:t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:a("影印")})})]})}),t.jsx("tbody",{children:C.map(H=>{var ce;return t.jsx(wu,{row:H,measure:(ce=f.get(H.id))==null?void 0:ce.measure_info,loaded:f.has(H.id),onNavigate:o,renderLink:r},`${H.id}:${f.has(H.id)?"r":"p"}`)})})]}),C.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:a(w||b?"當前篩選下沒有版本":"暫無版本著錄")}),T.rows.length>C.length&&t.jsx(Bt,{label:`展開其餘 ${T.rows.length-C.length} 種版本`,onClick:()=>j(!0)}),T.hasInferredEra&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"8px 0 0",fontSize:12},children:a("部分年代據版本題名推斷,非著錄原文")})]}),Y.length>0&&t.jsx(Su,{items:Y,transport:n,onNavigate:o,renderLink:r}),le&&t.jsx(Fe,{title:"版本",children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:a("尚未著錄該作品的版本與書目收錄。")})})]}),Re=(H,ce)=>t.jsx(Be,{id:H,label:a(ce),onNavigate:o,renderLink:r,dense:!0}),$e=g.useMemo(()=>{const H=new Map;for(const ce of M){const oe=tr(ce.relation);H.set(oe,(H.get(oe)??0)+1)}return H.size>1?[...H.entries()].sort((ce,oe)=>oe[1]-ce[1]).slice(0,4).map(([ce,oe])=>`${a(ce)} ${oe}`).join(" · "):void 0},[M,a]),ye=t.jsxs(t.Fragment,{children:[t.jsx(ht,{id:"collected",title:"收入叢編",items:O.map(H=>Re(H.id,H.title))}),t.jsx(ht,{id:"related",title:"相關書目",meta:a(`${M.length} 部`),sub:$e,items:M.map(H=>t.jsxs(t.Fragment,{children:[Re(H.id,H.title),t.jsx("span",{className:"bim-d-meta",title:H.note?a(H.note):void 0,children:a(tr(H.relation))})]}))}),t.jsx(ht,{id:"resources",title:"在線資源",cap:6,items:X.map(({r:H,kind:ce})=>{const oe=a((H.url?Nt(H.url):void 0)||H.name),he=Lt(H);return t.jsxs(t.Fragment,{children:[he?t.jsxs("a",{href:he,target:"_blank",rel:"noopener noreferrer",children:[oe," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]}):t.jsx("span",{children:oe}),ce&&t.jsx("span",{className:"bim-d-meta bim-d-kind",children:ce})]})})})]});return t.jsx(Xt,{railTop:l,back:d,nav:re,railLinks:p,main:pe,card:ie,side:ye})};function ir(e){return(e||[]).map(n=>typeof n=="string"?n:n==null?void 0:n.book_title).filter(n=>!!n)}function or(e,n){return n((e.url?Nt(e.url):void 0)||e.name)}function wu({row:e,measure:n,loaded:o,onNavigate:r,renderLink:s}){const{convert:l}=Z(),d=[e.era.era,e.era.reign].filter(Boolean).join(" "),p=e.era.source==="edition",c=e.holders[0],a=c?or(c,l):e.locationName?l(e.locationName):"",u=e.images[0],f=u?Lt(u):void 0,x=e.images.map(m=>or(m,l)).join("、");return t.jsxs("tr",{"data-loading":o?void 0:"",children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Be,{id:e.id,label:l(e.name),onNavigate:r,renderLink:s,dense:!0}),n?t.jsx("span",{className:"bim-d-meta",children:l(n)}):t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${d?"":" bim-d-zt-blank"}`,title:p?l("據版本題名推斷"):void 0,children:d?l(d):o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null}),t.jsxs("td",{className:`bim-d-zt-sub${a?"":" bim-d-zt-blank"}`,children:[a||(o?t.jsx("span",{className:"bim-d-zt-empty",children:"—"}):null),e.holders.length>1&&t.jsxs("span",{className:"bim-d-meta",children:[" +",e.holders.length-1]})]}),t.jsx("td",{className:e.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:e.hasImage&&(f?t.jsx("a",{className:"bim-d-flag",href:f,target:"_blank",rel:"noopener noreferrer",title:x,children:l("有影印")}):t.jsx("span",{className:"bim-d-flag",title:x,children:l("有影印")}))})]})}function Su({items:e,transport:n,onNavigate:o,renderLink:r}){const s=ue(),{convert:l}=Z(),[d,p]=g.useState(0),c=Math.min(d,e.length-1),a=e[c],[u,f]=g.useState(new Map);return g.useEffect(()=>{if(!n)return;const x=[...new Set(e.map(j=>j.source_bid).filter(j=>!!j))];if(x.length===0)return;let m=!1;return Promise.all(x.map(j=>n.getItem(j).then(w=>{var h,b;return[j,((b=(h=w==null?void 0:w.authors)==null?void 0:h[0])==null?void 0:b.dynasty)??""]}).catch(()=>[j,""]))).then(j=>{m||f(new Map(j.filter(([,w])=>w)))}),()=>{m=!0}},[n,e]),t.jsx(Fe,{id:"catalogs",title:"著錄",meta:t.jsx(Me,{items:[l(`歷代書目 ${e.length} 家`),l("按著錄順序")]}),children:t.jsxs("div",{className:"bim-d-lu",children:[t.jsx("ul",{className:"bim-d-tl2 bim-d-ui",role:"tablist","aria-label":l("著錄書目"),children:e.map((x,m)=>t.jsx("li",{role:"presentation",children:t.jsxs("button",{type:"button",role:"tab","aria-selected":m===c,"aria-label":l(x.source),onClick:()=>p(m),children:[t.jsx("span",{className:"bim-d-tl2-dyn",children:u.get(x.source_bid??"")?l(u.get(x.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:[...l(x.source)].slice(0,9).map((j,w)=>t.jsx("span",{children:j},w))})]})},m))}),t.jsxs("div",{className:"bim-d-lu-body",role:"tabpanel",children:[a.title_info&&t.jsx("div",{className:"bim-d-lu-title",children:l(a.title_info)}),t.jsx(Me,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[a.source_bid?t.jsx(Be,{id:a.source_bid,label:l(a.source),onNavigate:o,renderLink:r,dense:!0}):l(a.source),a.section?l(a.section):"",a.author_info?`${l(s.label.authorInfo)} ${l(a.author_info)}`:"",a.edition?`${l(s.label.edition)} ${l(a.edition)}`:"",a.page??""]}),a.summary&&t.jsx("p",{className:"bim-d-quote",children:Ue(l(a.summary))}),a.comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:l(s.section.comment)}),t.jsx("p",{className:"bim-d-quote",children:Ue(l(a.comment))})]}),a.additional_comment&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"bim-d-quote-label bim-d-ui",children:l(s.section.additionalComment)}),t.jsx("p",{className:"bim-d-quote",children:Ue(l(a.additional_comment))})]}),!a.summary&&!a.comment&&!a.additional_comment&&!a.title_info&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{marginTop:12},children:l("僅著錄書名,無提要。")}),e.length>1&&t.jsxs("div",{className:"bim-d-lu-pager bim-d-ui",children:[c>0?t.jsx("button",{type:"button","aria-label":l(`上一家:${e[c-1].source}`),onClick:()=>p(c-1),children:t.jsxs("span",{"aria-hidden":"true",children:["← ",l(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":l(`下一家:${e[c+1].source}`),onClick:()=>p(c+1),children:t.jsxs("span",{"aria-hidden":"true",children:[l(e[c+1].source)," →"]})}):t.jsx("span",{"aria-hidden":"true"})]})]})]})})}function _u(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 $u(e,n){if(!e.lineage)return null;const o=e.lineage;return{id:e.id,kind:"book",label:e.title,year:o.year,year_text:o.year_text,year_uncertain:o.year_uncertain,category:o.category,status:o.status,extant_juan:o.extant_juan,group:n[e.id],note:o.note}}function rr(e,n,o){return{id:`derive:${n.ref}->${e}:${o}`,source:n.ref,target:e,kind:"derive",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function zu(e,n,o){const[r,s]=[e,n.book_id].sort();return{id:`sibling:${r}-${s}:${o}`,source:r,target:s,kind:"sibling",relation:n.relation,confidence:n.confidence,evidence:n.evidence,note:n.note}}function Cu(e,n){var a;if(n==="all")return null;const o=(a=e.collections)==null?void 0:a[n],r=Array.isArray(o==null?void 0:o.groups)&&o.groups.length>0,s=Array.isArray(o==null?void 0:o.book_ids)&&o.book_ids.length>0,l=r||s||!!(o!=null&&o.hypothetical_ids);if(!l&&n==="core"&&Array.isArray(e.core_books)&&e.core_books.length>0)return{books:new Set(e.core_books),hypos:e.core_hypotheticals?new Set(e.core_hypotheticals):null};if(!o||!l)return null;const d=r?new Set(o.groups):null,p=new Set(o.book_ids??[]);if(d&&e.node_groups)for(const[u,f]of Object.entries(e.node_groups))d.has(f)&&p.add(u);let c=null;if(o.hypothetical_ids&&(c=new Set(o.hypothetical_ids)),d){c||(c=new Set);for(const u of e.hypothetical_nodes??[])u.group&&d.has(u.group)&&c.add(u.id)}return{books:p,hypos:c}}function fn(e,n,o){const r=e.version_graph,s={nodes:[],edges:[],groups:[],layout:"LR",excluded:[]};if(!r||!r.enabled)return s;const l=new Set(r.excluded_books??[]),d=r.node_groups??{},p=Cu(r,o??r.default_collection??"all"),c=p!==null,a=(p==null?void 0:p.books)??null,u=(p==null?void 0:p.hypos)??null,f=new Set,x=new Set;if(c){const $=new Map(n.map(T=>[T.id,T])),v=new Map((r.hypothetical_nodes??[]).map(T=>[T.id,T])),_=T=>{const C=$.get(T);if(C&&C.lineage)return(C.lineage.derived_from??[]).map(B=>B.ref);const D=v.get(T);return D?(D.derived_from??[]).map(B=>B.ref):[]},S=T=>v.has(T)?!u||u.has(T):!a||a.has(T),z=new Set,N=T=>{if(!z.has(T)){z.add(T);for(const C of _(T))l.has(C)||(S(C)||(v.has(C)?x.add(C):$.has(C)&&f.add(C)),N(C))}};for(const T of n)a&&a.has(T.id)&&!l.has(T.id)&&N(T.id);for(const T of r.hypothetical_nodes??[])u&&u.has(T.id)&&N(T.id)}const m=n.filter($=>!l.has($.id)).filter($=>!a||a.has($.id)||f.has($.id)).map($=>{const v=$u($,d);return v&&f.has($.id)&&(v.bridge=!0),v}).filter($=>$!==null),j=(r.hypothetical_nodes??[]).filter($=>!u||u.has($.id)||x.has($.id)).map($=>{const v=_u($);return x.has($.id)&&(v.bridge=!0),v}),w=[...m,...j],h=new Set(w.map($=>$.id)),b=new Set,y=[],k=$=>{b.has($.id)||!h.has($.source)||!h.has($.target)||(b.add($.id),y.push($))};for(const $ of n)l.has($.id)||!$.lineage||a&&!a.has($.id)&&!f.has($.id)||(($.lineage.derived_from??[]).forEach((v,_)=>{k(rr($.id,v,_))}),($.lineage.related_to??[]).forEach((v,_)=>{k(zu($.id,v,_))}));for(const $ of r.hypothetical_nodes??[])u&&!u.has($.id)&&!x.has($.id)||($.derived_from??[]).forEach((v,_)=>{k(rr($.id,v,_))});return{nodes:w,edges:y,groups:r.groups??[],title:r.title,description:r.description,layout:r.layout??"LR",excluded:Array.from(l)}}function il(e,n,o){const r=(e??(n!=null?String(n):"")).trim();return r?!o||/约|約|推定|大约|大約|学界估计|學界估計|不確|不确|前后|前後|疑/.test(r)?r:`约 ${r}`:""}function Iu(e,n){const o=[],r=e.version_graph;if(!r)return o;const s=new Set(n.map(c=>c.id)),l=new Set((r.hypothetical_nodes??[]).map(c=>c.id)),d=new Set([...s,...l]),p=(c,a)=>{d.has(a.ref)||o.push(`${c}: derived_from.ref "${a.ref}" 未在 books 或 hypothetical_nodes 中找到`),a.ref_type==="book"&&!s.has(a.ref)&&o.push(`${c}: derived_from.ref "${a.ref}" 标记为 book 但不在 books 列表中`),a.ref_type==="hypothetical"&&!l.has(a.ref)&&o.push(`${c}: derived_from.ref "${a.ref}" 标记为 hypothetical 但不在 hypothetical_nodes 中`)};for(const c of n){if(!c.lineage)continue;const a=`Book ${c.id} (${c.title})`;(c.lineage.derived_from??[]).forEach(u=>p(a,u)),(c.lineage.related_to??[]).forEach(u=>{s.has(u.book_id)||o.push(`${a}: related_to.book_id "${u.book_id}" 不在 books 列表中`)})}for(const c of r.hypothetical_nodes??[]){const a=`Hypothetical ${c.id} (${c.label})`;(c.derived_from??[]).forEach(u=>p(a,u))}return o}const ol=({graph:e,renderLink:n,className:o,style:r})=>{const{convert:s}=Z();if(!e.nodes.length)return t.jsx("div",{style:{...Hu,...r},className:o,children:"暂无版本图数据"});const l=new Map,d=new Map;for(const x of e.edges)if(x.kind==="derive"){const m=l.get(x.target)??[];m.push(x),l.set(x.target,m)}else for(const m of[x.source,x.target]){const j=d.get(m)??[];j.push(x),d.set(m,j)}const p=new Map(e.nodes.map(x=>[x.id,x])),c=new Map,a=[];for(const x of e.nodes)if(x.group){const m=c.get(x.group)??[];m.push(x),c.set(x.group,m)}else a.push(x);const u=(x,m)=>(x.year??9999)-(m.year??9999);c.forEach(x=>x.sort(u)),a.sort(u);const f=e.groups.filter(x=>c.has(x.id));return t.jsxs("div",{className:o,style:{...Eu,...r},children:[e.title&&t.jsx("div",{style:Ru,children:s(e.title)}),e.description&&t.jsx("div",{style:Nu,children:s(e.description)}),f.map(x=>t.jsx(sr,{label:x.label,color:x.color,nodes:c.get(x.id),incomingMap:l,siblingMap:d,nodeMap:p,renderLink:n},x.id)),a.length>0&&t.jsx(sr,{label:"其他",nodes:a,incomingMap:l,siblingMap:d,nodeMap:p,renderLink:n})]})},sr=({label:e,color:n,nodes:o,incomingMap:r,siblingMap:s,nodeMap:l,renderLink:d})=>{const{convert:p}=Z();return t.jsxs("div",{style:Lu,children:[t.jsx("div",{style:{...Bu,borderLeftColor:n??i("widget-border")},children:p(e)}),o.map(c=>t.jsx(Tu,{node:c,incoming:r.get(c.id)??[],siblings:s.get(c.id)??[],nodeMap:l,renderLink:d},c.id))]})},Tu=({node:e,incoming:n,siblings:o,nodeMap:r,renderLink:s})=>{const l=e.kind==="hypothetical",d=e.bridge,{convert:p}=Z();return t.jsxs("div",{style:{...Au,borderStyle:l||d?"dashed":"solid",opacity:d?.55:e.status==="lost"?.7:1,background:d?i("bg-subtle"):void 0},title:d?"桥接节点:本身不在核心集,为保持派生链完整而显示":void 0,children:[t.jsxs("div",{style:Wu,children:[t.jsx("span",{style:Mu,children:l||!s?p(e.label):s(e.id,p(e.label))}),(e.year_text||e.year!=null)&&t.jsx("span",{style:Fu,children:il(p(e.year_text),e.year,e.year_uncertain)})]}),t.jsxs("div",{style:Pu,children:[e.category&&t.jsx(Ot,{children:p(e.category)}),e.status==="lost"&&t.jsx(Ot,{tone:"warn",children:"已佚"}),e.status==="fragment"&&t.jsx(Ot,{tone:"warn",children:"残本"}),l&&t.jsx(Ot,{tone:"info",children:"假想祖本"}),d&&t.jsx(Ot,{tone:"info",children:"桥接"})]}),e.extant_juan&&t.jsxs("div",{style:Ou,children:["现存:",p(e.extant_juan)]}),e.note&&t.jsx("div",{style:Du,children:p(e.note)}),n.length>0&&t.jsxs("div",{style:ar,children:[t.jsx("div",{style:cr,children:"来源:"}),n.map(c=>{const a=r.get(c.source);return t.jsxs("div",{style:dr(c.confidence),children:[t.jsx("span",{style:pr,children:p(c.relation)}),t.jsx("span",{children:(a==null?void 0:a.kind)==="book"&&s?s(a.id,p(a.label)):p((a==null?void 0:a.label)??c.source)}),c.confidence!=="consensus"&&c.confidence!=="certain"&&t.jsx(lr,{level:c.confidence}),c.evidence&&t.jsxs("span",{style:ur,children:["· ",p(c.evidence)]})]},c.id)})]}),o.length>0&&t.jsxs("div",{style:ar,children:[t.jsx("div",{style:cr,children:"关联:"}),o.map(c=>{const a=c.source===e.id?c.target:c.source,u=r.get(a);return t.jsxs("div",{style:dr(c.confidence),children:[t.jsx("span",{style:pr,children:p(c.relation)}),t.jsx("span",{children:(u==null?void 0:u.kind)==="book"&&s?s(u.id,p(u.label)):p((u==null?void 0:u.label)??a)}),t.jsx(lr,{level:c.confidence}),c.evidence&&t.jsxs("span",{style:ur,children:["· ",p(c.evidence)]})]},c.id)})]})]})},Ot=({children:e,tone:n="default"})=>{const r={default:{bg:i("tag-bg"),fg:i("fg")},warn:{bg:i("warn-bg"),fg:i("warn-fg")},info:{bg:i("info-bg"),fg:i("info-fg")}}[n];return t.jsx("span",{style:{display:"inline-block",padding:"1px 8px",fontSize:"11px",borderRadius:"10px",background:r.bg,color:r.fg,marginRight:"4px"},children:e})},lr=({level:e})=>{const o={certain:{label:"确定",color:i("confidence-certain")},consensus:{label:"共识",color:i("confidence-consensus")},probable:{label:"推测",color:i("confidence-probable")},disputed:{label:"有争议",color:i("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:o.label}):null},Eu={fontSize:"14px",color:i("fg")},Ru={fontSize:"16px",fontWeight:600,marginBottom:"8px"},Nu={fontSize:"13px",color:i("muted"),marginBottom:"16px",lineHeight:1.6},Lu={marginBottom:"16px"},Bu={fontSize:"13px",fontWeight:600,padding:"4px 12px",borderLeft:"4px solid",marginBottom:"8px",color:i("fg")},Au={border:`1px solid ${i("widget-border")}`,borderRadius:"6px",padding:"10px 12px",marginBottom:"8px",background:i("bg")},Wu={display:"flex",justifyContent:"space-between",alignItems:"baseline",marginBottom:"4px"},Mu={fontSize:"15px",fontWeight:600},Fu={fontSize:"12px",color:i("muted")},Pu={marginBottom:"6px"},Ou={fontSize:"12px",color:i("muted"),margin:"2px 0"},Du={fontSize:"12px",color:i("muted"),fontStyle:"italic",margin:"4px 0"},ar={marginTop:"6px",paddingTop:"6px",borderTop:`1px dashed ${i("widget-border")}`},cr={fontSize:"11px",color:i("muted"),marginBottom:"2px"},dr=e=>({fontSize:"12px",margin:"2px 0",opacity:e==="probable"||e==="disputed"?.85:1}),pr={display:"inline-block",padding:"0 6px",fontSize:"11px",background:i("tag-bg"),color:i("fg"),borderRadius:"3px",marginRight:"6px"},ur={fontSize:"11px",color:i("muted")},Hu={padding:"20px",textAlign:"center",color:i("muted"),fontSize:"13px"},rl=({selectedNodeId:e,...n})=>{const[o,r]=g.useState("loading"),[s,l]=g.useState(null);return g.useEffect(()=>{let d=!1;return Gu().then(p=>{d||(p?(l(p),r("ready")):r("missing"))}),()=>{d=!0}},[]),o==="loading"?t.jsx("div",{style:xr,children:"加载图组件中…"}):o==="missing"||!s?t.jsxs("div",{style:xr,children:[t.jsxs("div",{children:["图组件未安装。请安装 ",t.jsx("code",{children:"@xyflow/react"})," 与 ",t.jsx("code",{children:"@dagrejs/dagre"}),"。"]}),t.jsxs("div",{style:{fontSize:"12px",marginTop:"4px"},children:["或使用 ",t.jsx("code",{children:"VersionLineageList"})," 列表视图。"]})]}):t.jsx(Uu,{modules:s,selectedNodeId:e,...n})};async function Gu(){try{const[e,n]=await Promise.all([import("@xyflow/react"),import("@dagrejs/dagre")]);let o=!1;try{await import("@xyflow/react/dist/style.css"),o=!0}catch{o=!1}return{ReactFlow:e.ReactFlow,Background:e.Background,Controls:e.Controls,Handle:e.Handle,Position:e.Position,BaseEdge:e.BaseEdge,EdgeLabelRenderer:e.EdgeLabelRenderer,getSmoothStepPath:e.getSmoothStepPath,dagre:n,cssLoaded:o}}catch{return null}}const Uu=({graph:e,renderLink:n,height:o=600,className:r,style:s,selectedNodeId:l,modules:d})=>{const{ReactFlow:p,Background:c,Controls:a,Handle:u,Position:f,BaseEdge:x,EdgeLabelRenderer:m,getSmoothStepPath:j,dagre:w}=d,h=g.useMemo(()=>({lineage:_=>{var X,Y,E,ee;const S=((X=_.data)==null?void 0:X.stepPosition)??.85,[z,N,T]=j({sourceX:_.sourceX,sourceY:_.sourceY,sourcePosition:_.sourcePosition,targetX:_.targetX,targetY:_.targetY,targetPosition:_.targetPosition,stepPosition:S,borderRadius:5}),C=!!((Y=_.data)!=null&&Y.isSibling),D=C?N:_.targetX-18,B=C?T:_.targetY-12,O=(E=_.data)==null?void 0:E.labelStyle,M=(ee=_.data)==null?void 0:ee.labelBgStyle;return t.jsxs(t.Fragment,{children:[t.jsx(x,{id:_.id,path:z,style:_.style,markerStart:_.markerStart,markerEnd:_.markerEnd}),_.label&&t.jsx(m,{children:t.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${D}px,${B}px)`,pointerEvents:"none",padding:"2px 6px",borderRadius:4,fontSize:11,fontWeight:500,whiteSpace:"nowrap",background:i("bg"),border:`0.5px solid ${i("widget-border")}`,...M,...O},children:_.label})})]})}}),[x,m,j]),b=g.useMemo(()=>({version:_=>{const S=_.data,z=S.kind==="hypothetical",N=S.status==="lost",T=S.isSelected,C=S.bridge,D=S.borderColor??i("muted"),B=C||z?"dashed":"solid",O=C?.5:N?.6:1;return t.jsxs("div",{style:{background:i(C?"bg-subtle":"bg"),border:`2px ${B} ${T?i("primary"):D}`,borderRadius:8,padding:"6px 10px",minWidth:120,maxWidth:160,wordWrap:"break-word",wordBreak:"break-word",opacity:O,boxShadow:T?i("shadow-node-selected"):z||C?"none":i("shadow-node")},title:C?"桥接节点:本身不在核心集,为保持派生链完整而显示":void 0,children:[t.jsx(u,{type:"target",position:f.Left,style:{visibility:"hidden"}}),t.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:1,lineHeight:1.3},children:z||!S.renderLink?S.label:S.renderLink(S.bookId,S.label)}),S.description&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.25,marginTop:1},children:S.description}),S.yearText&&t.jsx("div",{style:{fontSize:10,color:i("aux-fg"),lineHeight:1.2},children:il(S.yearText,void 0,S.uncertain)}),N&&t.jsx("div",{style:{fontSize:9,color:i("lost-fg"),marginTop:1},children:"已佚"}),t.jsx(u,{type:"source",position:f.Right,style:{visibility:"hidden"}})]})}}),[u,f]),{convert:y}=Z(),{rfNodes:k,rfEdges:$}=g.useMemo(()=>Vu(e,w,n,l,y),[e,w,n,l,y]);return t.jsx("div",{style:{width:"100%",height:o,...s},className:r,children:t.jsxs(p,{nodes:k,edges:$,nodeTypes:b,edgeTypes:h,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(a,{showInteractive:!1})]})})};function Vu(e,n,o,r,s=l=>l??""){const p=e.layout==="LR"||!e.layout,c=new n.graphlib.Graph;c.setGraph({rankdir:p?"LR":"TB",ranksep:160,nodesep:40,edgesep:16,marginx:20,marginy:20}),c.setDefaultEdgeLabel(()=>({}));const a=new Map(e.groups.map(b=>[b.id,b.color??i("muted")]));for(const b of e.nodes)c.setNode(b.id,{width:160,height:90});const u=new Set(["配补","形式仿照","综合","兄弟本","同源","互校"]);for(const b of e.edges)b.kind==="derive"&&(u.has(b.relation)||c.setEdge(b.source,b.target));n.layout(c);const f=e.nodes.map(b=>{const y=c.node(b.id),k=r?b.id===r:void 0,$={kind:b.kind,label:s(b.label),bookId:b.kind==="book"?b.id:void 0,yearText:s(b.year_text??qu(b)),uncertain:b.year_uncertain,category:b.category,status:b.status,borderColor:b.group?a.get(b.group):void 0,renderLink:o,isSelected:k,description:s(b.description),bridge:b.bridge};return{id:b.id,type:"version",position:{x:y.x-160/2,y:y.y-90/2},data:$,draggable:!1,selected:k}}),x=.78,m=.06,j=new Map;for(const b of e.edges)b.kind==="derive"&&(j.has(b.source)||j.set(b.source,[]),j.get(b.source).push(b));const w=new Map;for(const[b,y]of j){if(y.length<=1)continue;const k=[...y].sort((v,_)=>{var N,T;const S=((N=c.node(v.target))==null?void 0:N.y)??0,z=((T=c.node(_.target))==null?void 0:T.y)??0;return S-z}),$=k.length;k.forEach((v,_)=>{const S=(_-($-1)/2)*m;w.set(v.id,x+S)})}const h=e.edges.map(b=>Yu(b,w.get(b.id),s));return{rfNodes:f,rfEdges:h}}function Yu(e,n,o=r=>r??""){const r=e.confidence==="probable"||e.confidence==="disputed",s=e.kind==="sibling",l=Ku(e.confidence),d={type:"arrowclosed",color:l,width:14,height:14};return{id:e.id,source:e.source,target:e.target,type:"lineage",label:o(e.relation),data:{labelStyle:{color:i("fg")},isSibling:s,stepPosition:n},style:{stroke:l,strokeWidth:s?1:1.5,strokeDasharray:s?"4 3":r?"6 4":void 0,opacity:r?.75:1},animated:!1,markerEnd:d,markerStart:s?d:void 0,zIndex:1e3}}function qu(e){if(e.year_range)return`~${e.year_range[0]}–${e.year_range[1]}`;if(typeof e.year=="number")return String(e.year)}function Ku(e){switch(e){case"certain":return i("confidence-certain");case"consensus":return i("lineage-edge-consensus");case"probable":return i("confidence-probable");case"disputed":return i("confidence-disputed");default:return i("muted")}}const xr={padding:"40px 20px",textAlign:"center",color:i("muted"),fontSize:"13px",border:`1px dashed ${i("widget-border")}`,borderRadius:8,background:i("bg")},Gi=({graph:e,defaultMode:n="list",renderLink:o,graphHeight:r=600,selectedNodeId:s,onModeChange:l,collection:d,onCollectionChange:p,collectionsAvailable:c,collectionCounts:a,className:u,style:f})=>{var y;const[x,m]=g.useState(n),j=k=>{m(k),l==null||l(k)},w=(()=>{if(!c)return[];const k=Object.entries(c);return k.length===0||c.all?k:[...k,["all",{label:"全部",description:"显示该作品所有版本(含桥接节点)"}]]})(),h=!!(p&&w.length>0);if(!e.nodes.length)return t.jsx("div",{style:{padding:24,color:i("muted"),textAlign:"center"},children:"暂无版本传承数据"});const b=d?(y=c==null?void 0:c[d])==null?void 0:y.description:void 0;return t.jsxs("div",{className:u,style:f,children:[t.jsxs("div",{style:Ju,children:[t.jsx("button",{onClick:()=>j("list"),style:Fn(x==="list"),children:"列表"}),t.jsx("button",{onClick:()=>j("graph"),style:Fn(x==="graph"),children:"关系图"}),h&&t.jsxs("div",{style:{marginLeft:"auto",marginRight:80,display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,color:i("muted"),marginRight:4},children:"集合:"}),w.map(([k,$])=>{const v=a==null?void 0:a[k];return t.jsxs("button",{onClick:()=>p==null?void 0:p(k),style:Fn(d===k),title:$.description,children:[$.label,v!=null?` ${v}`:""]},k)})]})]}),h&&b&&t.jsx("div",{style:{fontSize:12,color:i("muted"),marginBottom:8,padding:"4px 8px",background:i("bg-subtle"),borderRadius:4},children:b}),x==="list"?t.jsx(ol,{graph:e,renderLink:o}):t.jsx(rl,{graph:e,renderLink:o,height:r,selectedNodeId:s})]})},Ju={display:"flex",gap:4,marginBottom:12,position:"relative",zIndex:20,flexWrap:"wrap"},Fn=e=>({padding:"4px 12px",fontSize:12,border:`1px solid ${i("widget-border")}`,borderRadius:4,background:e?i("primary"):"transparent",color:i(e?"primary-fg":"fg"),cursor:"pointer"}),fr=40,gr=2,Zu=9,mr={certain:"確證",consensus:"通說",probable:"可能",disputed:"有爭議"};function Pn(e){if(!e)return["",""];const n=e.split(/[ ]+/).filter(Boolean);return n.length>=2&&/^第.+[回章卷篇節节]$/.test(n[0])?[n[0],n[1]]:["",e]}const sl=({data:e,transport:n,onNavigate:o,renderLink:r,readAction:s,fullText:l,fullTextPending:d,chapterLink:p,railTop:c,back:a,railLinks:u})=>{var W,A,I,G,P,K,se,ke,be,Le,qe;const f=ue(),{convert:x}=Z(),[m,j]=g.useState(null),[w,h]=g.useState(new Map),[b,y]=g.useState([]),[k,$]=g.useState(new Map),[v,_]=g.useState(!1),[S,z]=g.useState("flow"),[N,T]=g.useState(null);g.useEffect(()=>{if(!n||!e.work_id){j(null);return}let L=!1;return n.getItem(e.work_id).then(de=>{!L&&de&&de.type==="work"&&j(de)}).catch(()=>{}),()=>{L=!0}},[n,e.work_id]),g.useEffect(()=>{if(!(n!=null&&n.getLineageGraph)||!e.work_id){T(null);return}let L=!1;return n.getLineageGraph(e.work_id).then(de=>{L||T(de&&de.nodes.length>1?de:null)}).catch(()=>{L||T(null)}),()=>{L=!0}},[n,e.work_id]),g.useEffect(()=>{const L=e.contained_in||[];if(!n||L.length===0){h(new Map);return}let de=!1;return Promise.all(L.map(fe=>{const ze=typeof fe=="string"?fe:fe.id;return n.getItem(ze).then(xe=>[ze,xe]).catch(()=>[ze,null])})).then(fe=>{if(de)return;const ze=new Map;for(const[xe,Ce]of fe)Ce&&ze.set(xe,Ce);h(ze)}),()=>{de=!0}},[n,e.contained_in]);const C=g.useMemo(()=>{const L=new Set([...(m==null?void 0:m.books)||[],...e.related_books||[]]);return L.add(e.id),[...L]},[m==null?void 0:m.books,e.related_books,e.id]),D=C.length-1;g.useEffect(()=>{if(!n||D<=0){y([]);return}const L=C.length<=fr,de=L?C:C.slice(0,8);let fe=!1;return Promise.all(de.map(ze=>ze===e.id?Promise.resolve({id:ze,title:e.title,edition:e.edition,year:mn(e)}):n.getItem(ze).then(xe=>{const Ce=xe??{};return{id:ze,title:Ce.title,edition:Ce.edition,year:xe?mn(Ce):void 0}}).catch(()=>({id:ze})))).then(ze=>{if(fe)return;const xe=ze.filter(Ce=>Ce.id===e.id||Ce.title||Ce.edition);L&&xe.sort((Ce,Oe)=>(Ce.year??1/0)-(Oe.year??1/0)),y(xe)}),()=>{fe=!0}},[n,C,D,e]);const B=e.lineage,O=g.useMemo(()=>[...((B==null?void 0:B.derived_from)||[]).filter(L=>L.ref_type==="book").map(L=>L.ref),...((B==null?void 0:B.related_to)||[]).map(L=>L.book_id)].filter(Boolean),[B]);g.useEffect(()=>{if(!n||O.length===0){$(new Map);return}let L=!1;return Promise.all(O.map(de=>n.getItem(de).then(fe=>[de,{id:de,title:fe==null?void 0:fe.title,edition:fe==null?void 0:fe.edition}]).catch(()=>[de,{id:de}]))).then(de=>{L||$(new Map(de))}),()=>{L=!0}},[n,O]);const M=g.useMemo(()=>Qs(e.resources,e.resource_groups),[e.resources,e.resource_groups]),X=M.groups.reduce((L,de)=>L+de.rows.length+de.mirrors.length,0),Y=M.groups.length>0&&M.groups.every(L=>L.key==="_physical"),E=Zt(e),ee=Yr(e),F=at(e,f.unit.juan),q=new Set((e.contained_in||[]).map(L=>typeof L=="string"?0:Ut(L.volume_index).length).filter(L=>L>0)),ae=L=>{var ze;const de=(ze=e.base_edition)==null?void 0:ze.find(xe=>xe.book_id===L&&xe.name);if(de!=null&&de.name)return de.name;const fe=k.get(L);return(fe==null?void 0:fe.edition)||(fe==null?void 0:fe.title)||""},ne=g.useMemo(()=>{var ct,on,dt,rn,sn;const L=[];ee&&L.push({label:"版本類型",value:x(ee),title:e.edition_type||(ct=e.lineage)!=null&&ct.category?void 0:x("據版本題名推斷")}),(on=e.publication_info)!=null&&on.details?L.push({label:"刊印",value:x(e.publication_info.details)}):(E.era||E.reign)&&L.push({label:"刊寫年代",value:x([E.era,E.reign].filter(Boolean).join(" ")),title:E.source==="edition"?x("據版本題名推斷"):void 0}),F&&L.push({label:"卷帙",value:x(F)});const de=(e.contained_in||[]).flatMap(_e=>typeof _e=="string"?[]:Ut(_e.volume_index));de.length&&L.push({label:"冊次",value:x(`第 ${_n(de,f.unit.volume)} ${f.unit.volume}(${de.length} ${f.unit.volume})`)});const fe=(((dt=e.lineage)==null?void 0:dt.derived_from)||[]).find(_e=>_e.relation==="底本"&&_e.ref_type==="book");fe&&ae(fe.ref)&&L.push({label:"底本",value:t.jsx(Be,{id:fe.ref,label:x(ae(fe.ref)),onNavigate:o,renderLink:r,dense:!0})});const ze=(e.base_edition||[]).filter(_e=>_e&&_e.name);for(const _e of["底本","配補","參校"]){if(_e==="底本"&&fe&&ae(fe.ref))continue;const Xe=ze.filter(Ee=>Ee.role===_e);Xe.length&&L.push({label:_e,value:Xe.map((Ee,kt)=>t.jsxs(g.Fragment,{children:[kt>0&&"、",Ee.book_id?t.jsx(Be,{id:Ee.book_id,label:x(Ee.name),onNavigate:o,renderLink:r,dense:!0}):x(Ee.name)]},kt))})}const xe=(e.provenance||[]).filter(_e=>_e&&_e.institution),Ce=(e.resources||[]).filter(_e=>(_e.types||(_e.type?[_e.type]:[])).includes("physical"));if(xe.length){L.push({label:"存藏",value:xe.slice(0,2).map(Ee=>x(Ee.institution)).join("、")+(xe.length>2?x(` 等 ${xe.length} 處`):"")});const _e=xe.filter(Ee=>Ee.call_number).slice(0,2).map(Ee=>`${x(Ee.institution)} ${Ee.call_number}`);_e.length&&L.push({label:"索書號",value:_e.join(";")+(xe.filter(Ee=>Ee.call_number).length>2?"…":"")});const Xe=xe.flatMap(Ee=>Ee.seals||[]).filter(Boolean);Xe.length&&L.push({label:"藏印",value:x(Xe.join("、"))})}else Ce.length?L.push({label:"存藏",value:Ce.slice(0,2).map(_e=>x(_e.name)).join("、")+(Ce.length>2?x(` 等 ${Ce.length} 處`):"")}):(rn=e.current_location)!=null&&rn.name&&L.push({label:"存藏",value:x(e.current_location.name)});const Oe=e.physical_description;if(Oe){const _e=[["行款",Oe.leaf_style],["裝幀",Oe.binding],["尺寸",Oe.dimensions],["品相",Oe.condition]];for(const[Xe,Ee]of _e)Ee&&Ee.trim()&&L.push({label:Xe,value:x(Ee)})}(sn=e.page_count)!=null&&sn.description&&L.push({label:f.label.pageCount,value:x(e.page_count.description)});const Ze=[...Xn(e.additional_titles),...Xn(e.attached_texts)];return Ze.length&&L.push({label:"又名",value:Ze.map(x).join("、")}),L},[e,x,f,E,ee,F,k,o,r]),Q=x(e.title),ie=e.edition?x(e.edition):void 0,ge=((W=e.lineage)==null?void 0:W.year_text)||"",re=t.jsx(Qt,{kind:"版本",title:Q,subtitle:ie,byline:t.jsx(Di,{authors:e.authors??(m==null?void 0:m.authors),onNavigate:o,renderLink:r}),meta:(()=>{const L=[ee?x(ee):"",E.era?x([E.era,E.reign].filter(Boolean).join("")):"",F?x(F):""].filter(Boolean);return L.length?t.jsx("span",{className:"bim-d-tags",children:L.map((de,fe)=>t.jsx("span",{className:`bim-d-tag bim-d-tag-${Math.min(fe,2)}`,children:de},fe))}):null})(),description:(A=e.description)!=null&&A.text?t.jsx(lt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:ki((I=e.description)==null?void 0:I.text)?6:void 0,facts:ne,readAction:s,secondaryAction:s&&X>0&&!Y?t.jsx("a",{className:"bim-d-card-alt bim-d-ui",href:"#images",children:x("看原書影印")}):void 0,foot:t.jsx(en,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo})}),le=e.contained_in||[],pe=(l==null?void 0:l.chapters)||[],Re=pe[0]&&Pn(pe[0].title)[0].slice(-1)||"章",$e=!!((G=B==null?void 0:B.derived_from)!=null&&G.length||(P=B==null?void 0:B.related_to)!=null&&P.length||(K=e.appendix)!=null&&K.length),ye=[];(pe.length||M.text.length||d)&&ye.push({id:"fulltext",label:"全文",count:pe.length?x(`${pe.length} ${Re}`):void 0}),M.groups.length&&ye.push({id:"images",label:Y?"館藏":"影印",count:X}),$e&&ye.push({id:"lineage",label:"版本源流"}),le.length&&ye.push({id:"collections",label:"收入叢編",count:le.length}),(se=e.location_history)!=null&&se.length&&ye.push({id:"provenance",label:"流轉歷史"});const Se=L=>(p==null?void 0:p(L))??null,Ne=pe[0],je=Ne?Se(Ne.file):null,H=v?pe:pe.slice(0,Zu),ce=(L,de,fe)=>L?t.jsx("a",{className:fe,href:L.href??"#",onClick:L.onClick?ze=>{ze.metaKey||ze.ctrlKey||(ze.preventDefault(),L.onClick())}:void 0,children:de}):t.jsx("span",{className:fe,children:de}),oe=t.jsxs(t.Fragment,{children:[(pe.length>0||M.text.length>0||d)&&t.jsxs(Fe,{id:"fulltext",title:"全文",meta:pe.length>0?t.jsx(Me,{items:[x(`${pe.length} ${Re}`),(ke=l==null?void 0:l.source)!=null&&ke.name?x(`據${l.source.name}${l.source.license?` ${l.source.license}`:""}`):""]}):void 0,children:[d&&!Ne&&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"})]}),Ne&&t.jsxs("div",{className:"bim-d-ft",children:[t.jsx("h3",{className:"bim-d-ft-h",children:x(`從${Pn(Ne.title)[0]||"第一章"}讀起`)}),t.jsx("span",{className:"bim-d-meta",children:x((Ne.title||"").replace(/^第.+?[回章卷篇節节][ ]*/,""))}),ce(je,t.jsxs(t.Fragment,{children:[x("進入閱讀頁")," ",t.jsx("span",{"aria-hidden":"true",children:"→"})]}),"bim-d-ft-go bim-d-ui")]}),pe.length>1&&t.jsx("ul",{className:"bim-d-chap",children:H.map(L=>{const[de,fe]=Pn(L.title);return t.jsx("li",{children:ce(Se(L.file),t.jsxs(t.Fragment,{children:[de&&t.jsx("b",{children:x(de)}),x(fe||L.file)]}))},L.file)})}),pe.length>H.length&&t.jsx(Bt,{label:`展開其餘 ${pe.length-H.length} ${Re}`,onClick:()=>_(!0)}),M.text.length>0&&t.jsxs(t.Fragment,{children:[(pe.length>0||d)&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"14px 0 4px"},children:x("站外全文")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:M.text.map((L,de)=>t.jsx(Hi,{item:L,siblings:M.text,listedVolumeCounts:q},`${L.id||L.url||L.name}-${de}`))})})]})]}),M.groups.length>0&&t.jsx(Fe,{id:"images",title:Y?"館藏":"影印",meta:t.jsx(Me,{items:[M.groups.length>1?x(`${M.groups.length} 組`):"",x(`${X} 處`)]}),children:t.jsx(tl,{groups:M.groups,listedVolumeCounts:q})}),$e&&t.jsx(Fe,{id:"lineage",title:"版本源流",meta:(be=B==null?void 0:B.derived_from)!=null&&be.length?x("據版本傳承著錄"):void 0,action:N?t.jsxs("span",{className:"bim-d-seg bim-d-ui",role:"group","aria-label":x("源流視圖"),children:[t.jsx("button",{type:"button","aria-pressed":S==="flow",onClick:()=>z("flow"),children:x("卡片")}),t.jsx("button",{type:"button","aria-pressed":S==="graph",onClick:()=>z("graph"),children:x("關係圖")})]}):void 0,children:S==="graph"&&N?t.jsx(Gi,{graph:N,defaultMode:"graph",selectedNodeId:e.id,graphHeight:480,renderLink:(L,de)=>t.jsx(Be,{id:L,label:x(de),onNavigate:o,renderLink:r,dense:!0})}):t.jsx(Qu,{data:e,heading:ie||Q,yearText:ge,refName:ae,onNavigate:o,renderLink:r})}),le.length>0&&t.jsx(Fe,{id:"collections",title:"收入叢編",children:t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:le.map((L,de)=>{var Oe,Ze;const fe=typeof L=="string"?L:L.id,ze=typeof L=="string"?[]:Ut(L.volume_index),xe=w.get(fe),Ce=(xe==null?void 0:xe._member_count)||((Oe=xe==null?void 0:xe.books)==null?void 0:Oe.length)||((Ze=xe==null?void 0:xe.contained_works)==null?void 0:Ze.length)||0;return t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Be,{id:fe,label:xe?x(xe.title):fe,onNavigate:o,renderLink:r,dense:!0}),ze.length>0&&t.jsx(Xu,{volumes:ze,unit:f.unit.volume})]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Ce?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:Ce>0&&x(`全 ${Ce} ${f.unit.bu}`)})]},`${fe}-${de}`)})})})}),(Le=e.location_history)!=null&&Le.length?t.jsx(Fe,{id:"provenance",title:"流轉歷史",children:t.jsx("ul",{className:"bim-d-tl",children:e.location_history.map((L,de)=>t.jsxs("li",{children:[t.jsx("span",{className:"bim-d-tl-t",children:x(L.name)}),([L.start_date,L.end_date].filter(Boolean).join("—")||L.description)&&t.jsx("span",{className:"bim-d-tl-ev",style:{marginLeft:0},children:t.jsx(Me,{items:[[L.start_date,L.end_date].filter(Boolean).join("—"),L.description?x(L.description):""]})})]},de))})}):null,ye.length===0&&t.jsx(Fe,{title:"影印與全文",children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:x("尚未著錄該版本的影印、全文與收藏信息。")})})]}),he=b.findIndex(L=>L.id===e.id),me=C.length<=fr,U=me&&he>=0?b.slice(Math.max(0,he-gr),he+gr+1):b.filter(L=>L.id!==e.id),R=t.jsxs(t.Fragment,{children:[m&&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:x(f.section.belongsToWork)}),t.jsx("div",{style:{fontSize:17,fontWeight:500},children:t.jsx(Be,{id:m.id,label:x(m.title),onNavigate:o,renderLink:r})}),t.jsx(Me,{className:"bim-d-ui",style:{display:"block",marginTop:2},items:[...(m.authors||[]).slice(0,2).map(L=>`${L.dynasty?`〔${x(L.dynasty)}〕`:""}${x(L.name)}`),x(at(m,f.unit.juan)),m._edition_count?x(`${m._edition_count} 種版本`):""]}),((qe=m.description)==null?void 0:qe.text)&&t.jsx("p",{style:{margin:"8px 0 0",fontSize:14,lineHeight:1.8,display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},className:"bim-d-card-desc",children:x(m.description.text.replace(/[#*_>`[\]]/g,""))})]}),D>0&&U.length>0&&t.jsxs("div",{children:[t.jsx(ht,{id:"siblings",timeline:!0,title:me?"同作品版本":f.relation.siblingVersions,meta:x(me?"按年代":`${D} 種`),cap:U.length,items:U.map(L=>L.id===e.id?t.jsx("span",{className:"bim-d-side-cur-mark","data-current":"true",children:x(L.edition||L.title||L.id)}):t.jsx(Be,{id:L.id,label:x(L.edition||L.title||L.id),onNavigate:o,renderLink:r,dense:!0})),metas:U.map(L=>[L.year!=null?L.year<0?`前${-L.year}`:String(L.year):"",L.id===e.id?x("本頁"):""].filter(Boolean).join(" ")),currentIndex:U.findIndex(L=>L.id===e.id)}),m&&t.jsx("div",{className:"bim-d-ui bim-d-side-all",style:{marginTop:4,fontSize:13},children:t.jsx(Be,{id:m.id,label:x(`在作品頁看全部 ${C.length} 種 →`),onNavigate:o,renderLink:r,dense:!0})})]})]}),V=e.work_id?t.jsx(Qr,{caption:f.section.belongsToWork,children:t.jsx(Be,{id:e.work_id,label:m?x(m.title):" ",onNavigate:o,renderLink:r,dense:!0})}):void 0;return t.jsx(Xt,{railTop:c,back:a,up:V,nav:ye,railLinks:u,main:oe,card:re,side:R})};function Xu({volumes:e,unit:n}){const{convert:o}=Z();return t.jsxs("span",{className:"bim-d-meta bim-d-ui",children:[o(`第 ${_n(e,n)} ${n}`),e.length>1&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"bim-d-dot"}),o(`${e.length} ${n}`)]})]})}function Qu({data:e,heading:n,yearText:o,refName:r,onNavigate:s,renderLink:l}){var h;const{convert:d}=Z(),p=e.lineage,c=(p==null?void 0:p.derived_from)||[],a=c.filter(b=>b.ref_type!=="book"),u=c.filter(b=>b.ref_type==="book"&&b.relation==="底本"),f=c.filter(b=>b.ref_type==="book"&&b.relation!=="底本"),x=(p==null?void 0:p.related_to)||[],m=c.length>0||x.length>0,j=b=>b&&mr[b]?d(`(${mr[b]})`):"",w=(b,y)=>t.jsx(Be,{id:b,label:d(y||b),onNavigate:s,renderLink:l,dense:!0});return t.jsxs("div",{className:"bim-d-lf",children:[m&&t.jsxs("ol",{className:"bim-d-lf-list",children:[a.map((b,y)=>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:d(b.relation||"祖本")}),t.jsx("span",{className:"bim-d-lf-name",children:d("擬構祖本")}),b.evidence&&t.jsxs("span",{className:"bim-d-meta",children:[d(b.evidence),j(b.confidence)]})]})},`a-${y}`)),u.map((b,y)=>t.jsx("li",{className:"bim-d-lf-node",children:t.jsxs("div",{className:"bim-d-lf-card",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:w(b.ref,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),j(b.confidence)]})]})},`b-${y}`)),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:d("本版")}),t.jsx("span",{className:"bim-d-lf-name",children:n}),o&&t.jsx("span",{className:"bim-d-lf-yr",children:d(o)})]}),f.length>0&&t.jsx("div",{className:"bim-d-lf-side",children:f.map((b,y)=>t.jsxs("div",{className:"bim-d-lf-dash",children:[t.jsx("span",{className:"bim-d-lf-tag bim-d-ui",children:d(b.relation)}),t.jsx("span",{className:"bim-d-lf-name",children:w(b.ref,r(b.ref))}),b.evidence&&t.jsxs("p",{className:"bim-d-lf-ev",children:[d(b.evidence),j(b.confidence)]})]},y))})]}),x.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:d("翻刻 · 衍生")}),t.jsx("span",{className:"bim-d-lf-chips",children:x.map((b,y)=>t.jsxs("span",{className:"bim-d-lf-chip",title:b.evidence?d(b.evidence):void 0,children:[w(b.book_id,r(b.book_id)),t.jsx("span",{className:"bim-d-meta",children:d(b.relation)})]},y))})]})]}),(h=e.appendix)==null?void 0:h.map((b,y)=>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:d("附記")})," ",d(b.title)]}),t.jsx(lt,{text:b.text,plainStrong:!0,style:{marginTop:6,fontSize:14,lineHeight:1.9}})]},`x-${y}`)),(p==null?void 0:p.note)&&t.jsx("p",{className:"bim-d-meta",style:{margin:"12px 0 0",maxWidth:"46em"},children:d(p.note)})]})}const Dt=16,ex=200,tx=16,ll=({data:e,catalog:n,transport:o,onNavigate:r,renderLink:s,catalogAction:l,railTop:d,back:p,railLinks:c})=>{var he,me,U,R,V,W,A;const a=ue(),{convert:u}=Z(),[f,x]=g.useState(""),[m,j]=g.useState(!1),[w,h]=g.useState(null),[b,y]=g.useState(""),[k,$]=g.useState(!1),v=g.useMemo(()=>Ur(e,n),[e,n]),[_,S]=g.useState(new Map),z=!!o&&v.rows.length>0&&v.rows.length<=ex,N=z&&(v.rows.length<=Dt||k),T=N&&v.rows.every(I=>!I.id||_.has(I.id)),C=I=>{var G;return li(I?(G=_.get(I))==null?void 0:G.l1:void 0)},D=g.useMemo(()=>{const I=f.trim(),G=I?u(I):"";return v.rows.filter(P=>{var se,ke;if(b&&li(P.id?(se=_.get(P.id))==null?void 0:se.l1:void 0)!==b)return!1;if(!G)return!0;const K=P.id&&((ke=_.get(P.id))==null?void 0:ke.title)||P.title;return u(K).includes(G)||(P.subItems||[]).some(be=>u(be).includes(G))})},[v.rows,f,b,_,u]),B=m?D:D.slice(0,Dt),O=g.useMemo(()=>(N?v.rows:B).filter(I=>I.id&&!_.has(I.id)).map(I=>I.id),[N,v.rows,B,_]);g.useEffect(()=>{if(!o||O.length===0)return;let I=!1;const G=O.slice(0,tx);return Promise.all(G.map(P=>o.getItem(P).then(K=>{var be,Le;const se=K??{},ke={title:se.title,edition:se.edition,authors:se.authors,measure:K?at(K,a.unit.juan):void 0,versionCount:se._edition_count??((be=se.books)==null?void 0:be.length),l1:((Le=se.classification)==null?void 0:Le.l1)||void 0};return[P,ke]}).catch(()=>[P,{}]))).then(P=>{I||S(K=>{const se=new Map(K);for(const[ke,be]of P)se.set(ke,be);return se})}),()=>{I=!0}},[o,O,a.unit.juan]);const M=(e.contained_in||[])[0];g.useEffect(()=>{if(!M){h(null);return}if(h({id:M}),!o)return;let I=!1;return o.getItem(M).then(G=>{I||h({id:M,title:G==null?void 0:G.title})}).catch(()=>{}),()=>{I=!0}},[o,M]);const X=g.useMemo(()=>Qs(e.resources,e.resource_groups),[e.resources,e.resource_groups]),Y=X.text.length+X.groups.reduce((I,G)=>I+G.rows.length+G.mirrors.length,0),E=e.contained_works||[],ee=new Set(v.rows.map(I=>I.id).filter(Boolean)),F=E.length>0&&!E.every(I=>ee.has(I.id)),q=(()=>{const I=v.rows.map(G=>G.edition).filter(Boolean);return I.length>1&&new Set(I).size===1})(),ae=v.rows.some(I=>I.volumes.length>0||I.expected!=null),ne=e._member_count||((he=e.books)==null?void 0:he.length)||E.length,Q=at(e,a.unit.juan),ie=e.count,ge=I=>typeof I=="number"&&Number.isFinite(I)?I:null,re=ge(ie==null?void 0:ie.juan)??ge((me=e.juan_count)==null?void 0:me.number),le=ge(ie==null?void 0:ie.ce)??(v.totalVolumes||null),pe=[{value:v.rows.length,label:"子目"},{value:re??0,label:a.unit.juan},{value:le??0,label:a.unit.volume}],Re=g.useMemo(()=>{var P,K;const I=[];if((P=e.publication_info)!=null&&P.details&&I.push({label:"刊印",value:u(e.publication_info.details)}),ne&&ne!==v.rows.length){const se=e._member_type==="Book"?"所收版本":e._member_type==="Work"?"所收作品":"成員";I.push({label:u(se),value:`${ne} ${u(a.unit.bu)}`,title:u("子目與其各版本合計")})}const G=[ge(ie==null?void 0:ie.zhong)!=null?`${ie.zhong} 種`:"",ge(ie==null?void 0:ie.han)!=null?`${ie.han} 函`:""].filter(Boolean);return G.length&&I.push({label:"應收",value:u(G.join(" "))}),re==null&&Q&&I.push({label:"卷帙",value:u(Q),title:(K=e.juan_count)!=null&&K.description?u(e.juan_count.description):void 0}),I},[e,ne,v.rows.length,re,Q,ie,u,a]),$e=g.useMemo(()=>{if(!T)return[];const I=new Map;for(const P of v.rows){const K=C(P.id);K&&I.set(K,(I.get(K)??0)+1)}const G=Yt.filter(P=>(I.get(P.key)??0)>0);return G.length<2?[]:[{key:"",label:`${a.catalog.all} ${v.rows.length}`},...G.map(P=>({key:P.key,label:`${P.label} ${I.get(P.key)}`}))]},[T,v.rows,_,a]),ye=g.useMemo(()=>{if(!T||!v.rows.some(K=>K.volumes.length>0))return null;const I=[],G=v.rows.filter(K=>K.volumes.length>0).map(K=>({k:C(K.id)??"",from:Math.min(...K.volumes),to:Math.max(...K.volumes)})).sort((K,se)=>K.from-se.from);for(const K of G){const se=K.to-K.from+1,ke=I[I.length-1];ke&&ke.key===K.k?(ke.to=Math.max(ke.to,K.to),ke.n+=se):I.push({key:K.k,from:K.from,to:K.to,n:se})}const P=G.reduce((K,se)=>Math.max(K,se.to),0);return I.length>1&&I.some(K=>K.key)?{segs:I,last:P}:null},[T,v.rows,_]),Se=(U=e.description)==null?void 0:U.text,Ne=t.jsx(Qt,{kind:"叢編",title:u(e.title),byline:t.jsx(Di,{authors:e.authors,onNavigate:r,renderLink:s}),meta:t.jsx(Me,{items:[e.subtype==="work_collection"?u("作品集"):"",(R=e.publication_info)!=null&&R.year?u(e.publication_info.year):""]}),description:Se||(V=e.history)!=null&&V.length?t.jsxs(t.Fragment,{children:[Se&&t.jsx(lt,{text:Se,style:{fontSize:15,lineHeight:1.85}}),(W=e.history)!=null&&W.length?t.jsx("ul",{style:{margin:"10px 0 0",paddingLeft:18,fontSize:14},children:e.history.map((I,G)=>t.jsx("li",{children:u(I)},G))}):null]}):void 0,clampDescription:ki(Se)||(((A=e.history)==null?void 0:A.length)??0)>2?6:void 0,stats:pe,facts:Re,foot:t.jsx(en,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:ye&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:u("全帙冊次分佈")})}),t.jsx("div",{className:"bim-d-dist-bar",role:"group","aria-label":u("全帙冊次分佈"),children:ye.segs.map((I,G)=>{const P=Yt.find(K=>K.key===I.key);return t.jsx("button",{type:"button",className:"bim-d-dist-seg",disabled:!P,title:P?u(`${P.label} 第 ${I.from}–${I.to} 冊`):void 0,"aria-label":u(P?`只看${P.label}`:"未分類"),"aria-pressed":!!P&&b===I.key,style:{flexGrow:I.n,background:i(P?P.token:"rule")},onClick:()=>{P&&(y(b===I.key?"":I.key),j(!1))}},G)})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:u(`第 1 ${a.unit.volume}`)}),t.jsx("span",{children:u("點色段篩選部類")}),t.jsx("span",{children:u(`第 ${ye.last} ${a.unit.volume}`)})]})]})}),je=[];v.rows.length&&je.push({id:"titles",label:"子目",count:v.rows.length}),Y&&je.push({id:"resources",label:"影印與全文",count:Y}),F&&je.push({id:"works",label:a.section.containedWorks,count:E.length});const H=t.jsxs(t.Fragment,{children:[v.rows.length>0&&t.jsxs(Fe,{id:"titles",title:"子目",meta:t.jsx(Me,{items:[u(`${v.rows.length} ${a.unit.items}`),v.totalVolumes?u(`全帙 ${v.totalVolumes} ${a.unit.volume}`):"",D.length!==v.rows.length?u(`當前 ${D.length} ${a.unit.items}`):""]}),action:l,children:[(v.rows.length>Dt||$e.length>0)&&t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[$e.length>0&&t.jsx($n,{items:$e,value:b,onChange:I=>{y(I),j(!1)}}),z&&v.rows.length>Dt&&!T&&t.jsx("button",{type:"button",className:"bim-d-groupbtn",disabled:k,onClick:()=>$(!0),title:u(`將載入全部 ${v.rows.length} ${a.unit.items}`),children:u(k?"正在按部類分組…":"按部類分組")}),t.jsx("span",{className:"bim-d-spacer"}),v.rows.length>Dt&&t.jsx("input",{type:"search",className:"bim-d-find",value:f,placeholder:u("在本叢編中檢索"),"aria-label":u("在本叢編中檢索"),onChange:I=>{x(I.target.value),j(!1)}})]}),t.jsxs("table",{className:"bim-d-zt",children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[ae&&t.jsx("th",{style:{width:"8.5em"},children:u("冊次")}),t.jsx("th",{children:u("書名")}),t.jsx("th",{style:{textAlign:"right"},children:u("版本")})]})}),t.jsx("tbody",{children:B.map((I,G)=>{var qe;const P=I.id?_.get(I.id):void 0,K=P!=null&&P.title&&I.title===I.id?P.title:I.title,se=((P==null?void 0:P.authors)||[]).find(L=>L&&L.name),ke=[se?`${se.dynasty?`〔${u(se.dynasty)}〕`:""}${u(se.name)}${se.role?` ${u(se.role)}`:""}`:"",P!=null&&P.measure?u(P.measure):"",(qe=I.subItems)!=null&&qe.length?I.subItems.map(L=>u(L)).join("、"):"",(P!=null&&P.edition||I.edition)&&!q?u((P==null?void 0:P.edition)||I.edition||""):""].filter(Boolean),be=Yt.find(L=>L.key===C(I.id)),Le=I.volumes.length>0?u(`第 ${_n(I.volumes,a.unit.volume)} ${a.unit.volume}`):I.expected!=null?u(`${I.found??0}/${I.expected} ${a.unit.volume}`):"";return t.jsxs("tr",{children:[ae&&t.jsxs("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${Le?"":" bim-d-zt-blank"}`,children:[be&&t.jsx("i",{className:"bim-d-sq","aria-hidden":"true",style:{background:i(be.token)}}),Le||t.jsx("span",{className:"bim-d-zt-empty",children:"—"})]}),t.jsxs("td",{className:"bim-d-zt-main",children:[I.id?t.jsx(Be,{id:I.id,label:u(K),onNavigate:r,renderLink:s,dense:!0}):t.jsx("span",{className:"bim-d-zt-name",children:u(K)}),ke.length>0?t.jsx(Me,{items:ke}):I.id&&!P&&o?t.jsx("span",{className:"bim-d-meta","aria-hidden":"true",children:" "}):null]}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${P!=null&&P.versionCount?"":" bim-d-zt-blank"}`,style:{textAlign:"right"},children:P!=null&&P.versionCount?u(`${P.versionCount} 種`):""})]},`${I.id??I.title}-${G}`)})})]}),B.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:u(a.catalog.noMatch)}),D.length>B.length&&t.jsx(Bt,{label:`展開其餘 ${D.length-B.length} ${a.unit.items}`,onClick:()=>j(!0)})]}),Y>0&&t.jsxs(Fe,{id:"resources",title:"影印與全文",meta:u(`${Y} 處`),children:[X.text.length>0&&t.jsxs("div",{className:"bim-d-rg",children:[X.groups.length>0&&t.jsx("h3",{className:"bim-d-rg-h bim-d-ui",children:u("全文")}),t.jsx("table",{className:"bim-d-zt",children:t.jsx("tbody",{children:X.text.map((I,G)=>t.jsx(Hi,{item:I,siblings:X.text},`${I.id||I.url||I.name}-${G}`))})})]}),t.jsx(tl,{groups:X.groups})]}),v.rows.length===0&&Y===0&&t.jsx(Fe,{title:"子目",children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:u("尚未著錄該叢編的子目。")})})]}),ce=F?t.jsx(ht,{id:"works",title:a.section.containedWorks,meta:u(`${E.length} 種`),cap:12,items:E.map(I=>t.jsx(Be,{id:I.id,label:u(I.title),onNavigate:r,renderLink:s,dense:!0}))}):null,oe=w?t.jsx(Qr,{caption:"上級叢編",children:t.jsx(Be,{id:w.id,label:u(w.title||w.id),onNavigate:r,renderLink:s,dense:!0})}):void 0;return t.jsx(Xt,{railTop:d,back:p,up:oe,nav:je,railLinks:c,main:H,card:Ne,side:ce})},nx=16,On=["本名","字","號","号","諡號","谥号","尊號","尊号","廟號","庙号","法號","法号","道號","道号","年號","年号","常用名","別名","别名","小名","小字","行第","俗姓","俗名","稱號","称号","賜號","赐号","簡體","简体"];function hr(e){if(!e)return On.length;const n=On.indexOf(e);return n===-1?On.length:n}const ix={people:"人物",place:"地名",dynasty:"朝代",anonymous:"佚名",collective:"群體"};function xt(e){return e==null?"":e<0?`前${-e}`:String(e)}const ox={秦:[-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]},al=({data:e,transport:n,onNavigate:o,renderLink:r,railTop:s,back:l,railLinks:d})=>{var ce,oe,he,me,U;const p=ue(),{convert:c}=Z(),[a,u]=g.useState("全部"),[f,x]=g.useState(!1),[m,j]=g.useState("default"),[w,h]=g.useState(new Map),b=g.useMemo(()=>(e.works||[]).map(R=>{const V=w.get(R.work_id);return{id:R.work_id,title:(V==null?void 0:V.title)??R.title??R.work_id,role:R.role||"",cls:ji(R.role),versionCount:V==null?void 0:V.versionCount,section:V==null?void 0:V.cls,l1:V==null?void 0:V.l1,measure:V==null?void 0:V.measure,hasImage:V==null?void 0:V.hasImage,loaded:!!(V!=null&&V.loaded)}}),[e.works,w]),y=g.useMemo(()=>Gr((e.works||[]).map(R=>R.role)),[e.works]),k=g.useMemo(()=>{const R=a==="全部"?b:b.filter(V=>V.cls===a);return m==="versions"?[...R].sort((V,W)=>(W.versionCount??-1)-(V.versionCount??-1)):R},[b,a,m]),$=f?k:k.slice(0,nx),v=g.useMemo(()=>$.filter(R=>!w.has(R.id)).map(R=>R.id),[$,w]);g.useEffect(()=>{if(!n||v.length===0)return;let R=!1;return Promise.all(v.map(V=>n.getItem(V).then(W=>{var P,K,se,ke,be;const A=W??{},I=A._edition_count??(((P=A.books)==null?void 0:P.length)??0)+(((K=A.collections)==null?void 0:K.length)??0),G=[(se=A.classification)==null?void 0:se.l1,(ke=A.classification)==null?void 0:ke.l2].filter(Boolean).join(" ");return[V,{id:V,title:A.title,versionCount:I,loaded:!0,cls:G||void 0,l1:((be=A.classification)==null?void 0:be.l1)||void 0,measure:W&&at(W,p.unit.juan)||void 0,hasImage:!!(A.has_image??A._has_image)}]}).catch(()=>[V,{id:V,loaded:!0}]))).then(V=>{R||h(W=>{const A=new Map(W);for(const[I,G]of V)A.set(I,G);return A})}),()=>{R=!0}},[n,v,p.unit.juan]);const _=g.useMemo(()=>{const R=new Map;for(const V of e.alt_names||[]){const W=V.type||p.section.aliases;R.has(W)||R.set(W,[]),R.get(W).push(V.name)}return[...R.entries()].sort((V,W)=>hr(V[0])-hr(W[0])).map(([V,W])=>({label:V,names:W}))},[e.alt_names,p]),S=e.birth_year??((ce=e.dates)==null?void 0:ce.birth)??void 0,z=e.death_year??((oe=e.dates)==null?void 0:oe.death)??void 0,N=(he=e.dates)==null?void 0:he.floruit,T=S!=null||z!=null?`${xt(S)||"?"}—${xt(z)||"?"}`:Array.isArray(N)&&N.length===2&&N.every(R=>Number.isFinite(R))?`活躍於 ${xt(N[0])}—${xt(N[1])}`:"",C=new Set(["本名","字","號","号"]),D=_.filter(R=>C.has(R.label)),B=_.filter(R=>!C.has(R.label)),O=B.reduce((R,V)=>R+V.names.length,0),M=g.useMemo(()=>{const R=[];for(const W of D)R.push({label:W.label,value:W.names.map(A=>c(A)).join("、")});const V=(e.works||[]).length;return V&&R.push({label:"著作",value:`${V} ${c("種")}`}),R},[e.works,D,c]),X=R=>{var V;return(V=_.find(W=>R.includes(W.label)))==null?void 0:V.names[0]},Y=X(["字"]),E=X(["號","号"]),ee=[Y?`字${Y}`:"",E?`號${E}`:""].filter(Boolean).join(","),F=e.native_place,q=e.dynasty?ox[e.dynasty]:void 0,ae=(()=>{if(!q||S==null||z==null||z<S)return null;const[R,V]=q,W=Math.max(S,R),A=Math.min(z,V);if(A<=W)return null;const I=V-R;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(`${xt(S)}—${xt(z)},一生 ${z-S+1} 年`),children:t.jsx("i",{style:{left:`${(W-R)/I*100}%`,width:`${(A-W)/I*100}%`}})}),t.jsxs("div",{className:"bim-d-life-lab",children:[t.jsx("span",{children:c(`${xt(R)} ${e.dynasty}`)}),t.jsx("span",{children:c(`一生 ${z-S+1} 年`)}),t.jsx("span",{children:xt(V)})]})]})})(),ne=g.useMemo(()=>{if(!n||b.length===0||b.some(W=>!W.loaded))return null;const R=new Map;for(const W of b){const A=li(W.l1);A&&R.set(A,(R.get(A)??0)+1)}const V=Yt.map(W=>({...W,n:R.get(W.key)??0})).filter(W=>W.n>0);return V.length?V:null},[b,n]),Q=t.jsxs(Qt,{kind:ix[e.subtype]??"人物",title:c(e.primary_name||e.title),subtitle:ee?c(ee):void 0,meta:t.jsxs(t.Fragment,{children:[t.jsx(Me,{items:[e.dynasty?c(e.dynasty):"",T?c(T):"",F?c(`${F}人`):""]}),ae]}),description:(me=e.description)!=null&&me.text?t.jsx(lt,{text:e.description.text,style:{fontSize:15,lineHeight:1.85}}):void 0,clampDescription:ki((U=e.description)==null?void 0:U.text)?6:void 0,facts:M,foot:t.jsx(en,{revision:e.revision,revisedAt:e.revised_at,review:e.review,todo:e.todo}),children:[O>0&&t.jsxs("details",{className:"bim-d-more-names bim-d-ui",children:[t.jsx("summary",{children:c(`更多別名(${O})`)}),t.jsx("dl",{children:B.map(R=>t.jsxs(g.Fragment,{children:[t.jsx("dt",{children:c(R.label)}),t.jsx("dd",{children:R.names.map(V=>c(V)).join("、")})]},R.label))})]}),ne&&t.jsxs("div",{className:"bim-d-dist bim-d-ui",children:[t.jsx("div",{className:"bim-d-dist-head",children:t.jsx("span",{children:c("著作分佈")})}),t.jsx("div",{className:"bim-d-dist-bar","aria-hidden":"true",children:ne.map(R=>t.jsx("i",{style:{flexGrow:R.n,background:i(R.token)}},R.key))}),t.jsx("div",{className:"bim-d-dist-key",children:ne.map(R=>t.jsxs("span",{children:[t.jsx("i",{style:{background:i(R.token)}}),c(R.label)," ",R.n]},R.key))})]})]}),ie=g.useMemo(()=>b.filter(R=>R.loaded&&(R.versionCount??0)>0).sort((R,V)=>(V.versionCount??0)-(R.versionCount??0)).slice(0,3),[b]),ge=!!n&&b.length>=3&&$.some(R=>!R.loaded),re=a==="全部"&&(ge||ie.length>=2),le=e.external_ids||{},pe=[];le.cbdb_id!=null&&pe.push({label:"CBDB",id:String(le.cbdb_id),href:`https://cbdb.fas.harvard.edu/cbdbapi/person.php?id=${le.cbdb_id}`,note:le.cbdb_match==="auto"?"自動匹配":void 0});const Re=le.wikidata_id;Re&&pe.push({label:"Wikidata",id:Re,href:`https://www.wikidata.org/wiki/${Re}`});const $e=le.viaf_id;$e&&pe.push({label:"VIAF",id:$e,href:`https://viaf.org/viaf/${$e}`});const ye=y.map(R=>({key:R.cls,label:`${R.label} ${R.count}`})),Se=[...re&&!ge?[{id:"featured",label:"著作舉要",count:ie.length}]:[],...b.length?[{id:"works",label:"全部著作",count:b.length}]:[],...pe.length?[{id:"external",label:"站外資料",count:pe.length}]:[]],Ne=re?t.jsxs(Fe,{id:"featured",title:"著作舉要",children:[t.jsx("p",{className:"bim-d-sec-sub bim-d-ui",children:c("存世版本最多的三部")}),t.jsxs("div",{className:"bim-d-picks","aria-busy":ge||void 0,children:[ge&&[0,1,2].map(R=>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:" "})]},R)),!ge&&ie.map(R=>t.jsxs("div",{className:"bim-d-pick",children:[t.jsx("span",{className:"bim-d-pick-t",children:t.jsx(Be,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0})}),t.jsx(Me,{items:[R.section?c(R.section):"",R.measure?c(R.measure):""]}),t.jsxs("div",{className:"bim-d-pick-n bim-d-ui",children:[t.jsx("span",{className:"bim-d-pick-num",children:R.versionCount}),t.jsx("span",{children:c("種版本")}),R.hasImage&&t.jsx("span",{className:"bim-d-flag",children:c("有影印")})]})]},R.id))]})]}):null,je=b.length===0?t.jsx(Fe,{title:"著作",children:t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:0},children:c("尚未著錄該人物的關聯作品。")})}):t.jsxs(t.Fragment,{children:[Ne,t.jsxs(Fe,{id:"works",title:"著作",meta:t.jsx(Me,{items:[c(`共 ${b.length} 種`),k.length!==b.length?c(`當前 ${k.length} 種`):""]}),children:[t.jsxs("div",{className:"bim-d-filters bim-d-ui",children:[ye.length>1&&t.jsx($n,{items:ye,value:a,onChange:R=>{u(R),x(!1)}}),t.jsx("span",{className:"bim-d-spacer"}),t.jsx("button",{type:"button",className:"bim-d-tab","aria-pressed":m==="versions",onClick:()=>{m==="default"&&x(!0),j(R=>R==="default"?"versions":"default")},children:c(m==="default"?"按版本數排列":"按著錄順序")})]}),t.jsxs("table",{className:"bim-d-zt",children:[t.jsx("thead",{className:"bim-d-ui",children:t.jsxs("tr",{children:[t.jsx("th",{children:c("作品")}),t.jsx("th",{children:c("部類")}),t.jsx("th",{children:c("職任")}),t.jsx("th",{children:c("存世版本")}),t.jsx("th",{"aria-label":c("影印")})]})}),t.jsx("tbody",{children:$.map(R=>t.jsxs("tr",{children:[t.jsxs("td",{className:"bim-d-zt-main",children:[t.jsx(Be,{id:R.id,label:c(R.title),onNavigate:o,renderLink:r,dense:!0}),R.measure?t.jsx(Me,{items:[c(R.measure)]}):!R.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${R.section||R.loaded?"":" bim-d-zt-blank"}`,children:R.section?c(R.section):null}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.role?"":" bim-d-zt-blank"}`,children:R.role?c(R.role):t.jsx("span",{className:"bim-d-zt-empty",children:"—"})}),t.jsx("td",{className:`bim-d-zt-sub bim-d-zt-nowrap${R.loaded?"":" bim-d-zt-blank"}`,children:R.loaded?R.versionCount?c(`${R.versionCount} 種`):t.jsx("span",{className:"bim-d-zt-empty",children:c("未著錄")}):""}),t.jsx("td",{className:R.hasImage?void 0:"bim-d-zt-blank",style:{textAlign:"right"},children:R.hasImage&&t.jsx("span",{className:"bim-d-flag bim-d-ui",children:c("有影印")})})]},R.id))})]}),$.length===0&&t.jsx("p",{className:"bim-d-meta bim-d-ui",style:{margin:"12px 12px 0"},children:c("該職任下的著作尚未著錄。")}),k.length>$.length&&t.jsx(Bt,{label:`展開其餘 ${k.length-$.length} 種著作`,onClick:()=>x(!0)})]})]}),H=pe.length>0?t.jsx(ht,{id:"external",title:"站外資料",items:pe.map(R=>t.jsxs("a",{href:R.href,target:"_blank",rel:"noopener noreferrer",children:[R.label," ",t.jsx("span",{"aria-hidden":"true",children:"↗"})]})),metas:pe.map(R=>R.id),foot:le.cbdb_id!=null&&le.cbdb_match==="auto"?c("CBDB 為自動匹配,未經人工核對"):void 0}):null;return t.jsx(Xt,{railTop:s,back:l,nav:Se,railLinks:d,main:je,card:Q,side:H})},Ui="(max-width: 719px)",rx=`${Ui}, (pointer: coarse)`,cl=`
|
|
789
841
|
.bim-ct {
|
|
790
842
|
display: grid; grid-template-columns: 248px minmax(0, 1fr); column-gap: 32px; align-items: start;
|
|
791
843
|
max-width: 1440px; margin: 0 auto; padding: 20px 32px 48px; box-sizing: border-box;
|
|
792
|
-
background: ${
|
|
844
|
+
background: ${i("page-bg")}; color: ${i("ink")}; font-family: ${i("font-ui")};
|
|
793
845
|
}
|
|
794
846
|
.bim-ct *, .bim-ct *::before, .bim-ct *::after { box-sizing: border-box; }
|
|
795
847
|
.bim-ct-sr {
|
|
@@ -798,8 +850,8 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
798
850
|
}
|
|
799
851
|
|
|
800
852
|
/* ── 左栏 ── */
|
|
801
|
-
.bim-ct-side { position: sticky; top: calc(${
|
|
802
|
-
.bim-ct-side-h { margin: 0 0 8px; padding: 0 10px; font-size: 13px; font-weight: 600; letter-spacing: 0.12em; color: ${
|
|
853
|
+
.bim-ct-side { position: sticky; top: calc(${i("reader-top")} + 16px); max-height: calc(100vh - ${i("reader-top")} - 32px); overflow-y: auto; }
|
|
854
|
+
.bim-ct-side-h { margin: 0 0 8px; padding: 0 10px; font-size: 13px; font-weight: 600; letter-spacing: 0.12em; color: ${i("aux-fg")}; }
|
|
803
855
|
.bim-ct-drawer-btn { display: none; }
|
|
804
856
|
|
|
805
857
|
/* ── 分类树 ── */
|
|
@@ -808,33 +860,33 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
808
860
|
.bim-ct-row {
|
|
809
861
|
display: flex; align-items: center; gap: 4px; min-height: 34px;
|
|
810
862
|
padding: 0 10px 0 calc(var(--bimct-lv, 0) * 14px + 4px); border-radius: 6px;
|
|
811
|
-
font-size: 14px; line-height: 1.4; color: ${
|
|
863
|
+
font-size: 14px; line-height: 1.4; color: ${i("body-fg")}; cursor: pointer; user-select: none;
|
|
812
864
|
}
|
|
813
|
-
.bim-ct-row:hover { background: ${
|
|
814
|
-
.bim-ct-tree li[aria-selected="true"] > .bim-ct-row { background: ${
|
|
815
|
-
.bim-ct-tree li:focus-visible > .bim-ct-row { outline: 2px solid ${
|
|
865
|
+
.bim-ct-row:hover { background: ${i("row-hover-bg")}; color: ${i("ink")}; }
|
|
866
|
+
.bim-ct-tree li[aria-selected="true"] > .bim-ct-row { background: ${i("zebra-bg")}; color: ${i("accent")}; font-weight: 700; }
|
|
867
|
+
.bim-ct-tree li:focus-visible > .bim-ct-row { outline: 2px solid ${i("accent")}; outline-offset: -2px; }
|
|
816
868
|
.bim-ct-tw {
|
|
817
869
|
flex: none; width: 20px; align-self: stretch; display: inline-flex; align-items: center; justify-content: center;
|
|
818
|
-
color: ${
|
|
870
|
+
color: ${i("aux-fg")};
|
|
819
871
|
}
|
|
820
872
|
.bim-ct-tw svg { transition: transform 0.15s; }
|
|
821
873
|
.bim-ct-tree li[aria-expanded="true"] > .bim-ct-row .bim-ct-tw svg { transform: rotate(90deg); }
|
|
822
874
|
.bim-ct-lb { min-width: 0; flex: 1; overflow-wrap: anywhere; }
|
|
823
|
-
.bim-ct-n { flex: none; margin-left: 8px; font-size: 12px; font-weight: 400; color: ${
|
|
824
|
-
.bim-ct-tree li[aria-selected="true"] > .bim-ct-row .bim-ct-n { color: ${
|
|
825
|
-
.bim-ct-tree .bim-ct-last { margin-top: 6px; padding-top: 6px; border-top: 1px solid ${
|
|
875
|
+
.bim-ct-n { flex: none; margin-left: 8px; font-size: 12px; font-weight: 400; color: ${i("aux-fg")}; font-variant-numeric: tabular-nums; }
|
|
876
|
+
.bim-ct-tree li[aria-selected="true"] > .bim-ct-row .bim-ct-n { color: ${i("accent")}; }
|
|
877
|
+
.bim-ct-tree .bim-ct-last { margin-top: 6px; padding-top: 6px; border-top: 1px solid ${i("rule")}; }
|
|
826
878
|
|
|
827
879
|
/* ── 右栏 ── */
|
|
828
880
|
.bim-ct-main { min-width: 0; }
|
|
829
881
|
.bim-ct-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 14px; }
|
|
830
|
-
.bim-ct-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: 0.04em; color: ${
|
|
831
|
-
.bim-ct-crumb { font-size: 13px; color: ${
|
|
832
|
-
.bim-ct-stat { font-size: 13px; color: ${
|
|
882
|
+
.bim-ct-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: 0.04em; color: ${i("ink")}; }
|
|
883
|
+
.bim-ct-crumb { font-size: 13px; color: ${i("aux-fg")}; }
|
|
884
|
+
.bim-ct-stat { font-size: 13px; color: ${i("aux-fg")}; }
|
|
833
885
|
.bim-ct-search { margin: 0 0 16px; }
|
|
834
|
-
.bim-ct-view { margin-left: auto; display: inline-flex; border-radius: 6px; box-shadow: inset 0 0 0 1px ${
|
|
835
|
-
.bim-ct-view button { min-height: 28px; padding: 0 12px; border: 0; background: none; cursor: pointer; font: inherit; font-size: 13px; color: ${
|
|
836
|
-
.bim-ct-view button[aria-pressed="true"] { background: ${
|
|
837
|
-
.bim-ct-view button:focus-visible { outline: 2px solid ${
|
|
886
|
+
.bim-ct-view { margin-left: auto; display: inline-flex; border-radius: 6px; box-shadow: inset 0 0 0 1px ${i("rule")}; overflow: hidden; }
|
|
887
|
+
.bim-ct-view button { min-height: 28px; padding: 0 12px; border: 0; background: none; cursor: pointer; font: inherit; font-size: 13px; color: ${i("quiet-fg")}; }
|
|
888
|
+
.bim-ct-view button[aria-pressed="true"] { background: ${i("flag-bg")}; color: ${i("accent")}; font-weight: 700; }
|
|
889
|
+
.bim-ct-view button:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: -2px; }
|
|
838
890
|
|
|
839
891
|
/* ── 卡片网格 ── */
|
|
840
892
|
.bim-ct-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
|
|
@@ -842,35 +894,35 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
842
894
|
.bim-ct-card > a {
|
|
843
895
|
display: flex; flex-direction: column; gap: 6px; height: 100%; min-height: 44px;
|
|
844
896
|
padding: 14px 16px 12px; border-radius: 8px;
|
|
845
|
-
background: ${
|
|
897
|
+
background: ${i("card-bg")}; color: inherit; text-decoration: none;
|
|
846
898
|
transition: background 0.12s;
|
|
847
899
|
}
|
|
848
|
-
.bim-ct-card > a:hover { background: ${
|
|
849
|
-
.bim-ct-card > a:hover .bim-ct-ct { color: ${
|
|
850
|
-
.bim-ct-card > a:focus-visible { outline: 2px solid ${
|
|
900
|
+
.bim-ct-card > a:hover { background: ${i("tint-bg")}; }
|
|
901
|
+
.bim-ct-card > a:hover .bim-ct-ct { color: ${i("accent")}; }
|
|
902
|
+
.bim-ct-card > a:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 2px; }
|
|
851
903
|
.bim-ct-ch { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
|
|
852
|
-
.bim-ct-ct { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.4; color: ${
|
|
853
|
-
.bim-ct-juan { flex: none; font-size: 12px; color: ${
|
|
854
|
-
.bim-ct-by { font-size: 13px; line-height: 1.5; color: ${
|
|
855
|
-
.bim-ct-dy { font-size: 12px; color: ${
|
|
904
|
+
.bim-ct-ct { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.4; color: ${i("ink")}; overflow-wrap: anywhere; }
|
|
905
|
+
.bim-ct-juan { flex: none; font-size: 12px; color: ${i("aux-fg")}; }
|
|
906
|
+
.bim-ct-by { font-size: 13px; line-height: 1.5; color: ${i("quiet-fg")}; overflow-wrap: anywhere; }
|
|
907
|
+
.bim-ct-dy { font-size: 12px; color: ${i("aux-fg")}; }
|
|
856
908
|
.bim-ct-sum {
|
|
857
|
-
margin: 0; font-size: 13px; line-height: 1.65; color: ${
|
|
909
|
+
margin: 0; font-size: 13px; line-height: 1.65; color: ${i("body-fg")};
|
|
858
910
|
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
|
|
859
911
|
}
|
|
860
|
-
.bim-ct-cls { margin-top: auto; padding-top: 2px; font-size: 12px; color: ${
|
|
861
|
-
.bim-ct-empty { padding: 48px 0; text-align: center; font-size: 14px; color: ${
|
|
912
|
+
.bim-ct-cls { margin-top: auto; padding-top: 2px; font-size: 12px; color: ${i("aux-fg")}; }
|
|
913
|
+
.bim-ct-empty { padding: 48px 0; text-align: center; font-size: 14px; color: ${i("aux-fg")}; }
|
|
862
914
|
|
|
863
915
|
/* ── 列表视图 ── */
|
|
864
916
|
.bim-ct-list { list-style: none; margin: 0; padding: 0; }
|
|
865
|
-
.bim-ct-lrow:nth-child(odd) { background: ${
|
|
917
|
+
.bim-ct-lrow:nth-child(odd) { background: ${i("zebra-bg")}; border-radius: 6px; }
|
|
866
918
|
.bim-ct-lrow > a {
|
|
867
919
|
display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 2fr); gap: 4px 20px; align-items: baseline;
|
|
868
920
|
min-height: 44px; padding: 10px 14px; color: inherit; text-decoration: none; border-radius: 6px;
|
|
869
921
|
}
|
|
870
|
-
.bim-ct-lrow > a:hover { background: ${
|
|
871
|
-
.bim-ct-lrow > a:hover .bim-ct-lt { color: ${
|
|
872
|
-
.bim-ct-lrow > a:focus-visible { outline: 2px solid ${
|
|
873
|
-
.bim-ct-lt { font-size: 16px; font-weight: 700; color: ${
|
|
922
|
+
.bim-ct-lrow > a:hover { background: ${i("tint-bg")}; }
|
|
923
|
+
.bim-ct-lrow > a:hover .bim-ct-lt { color: ${i("accent")}; }
|
|
924
|
+
.bim-ct-lrow > a:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: -2px; }
|
|
925
|
+
.bim-ct-lt { font-size: 16px; font-weight: 700; color: ${i("ink")}; overflow-wrap: anywhere; }
|
|
874
926
|
.bim-ct-lt .bim-ct-juan { margin-left: 8px; font-weight: 400; }
|
|
875
927
|
.bim-ct-lrow .bim-ct-cls { margin: 0; padding: 0; }
|
|
876
928
|
|
|
@@ -879,21 +931,21 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
879
931
|
.bim-ct-pager ol { display: contents; list-style: none; }
|
|
880
932
|
.bim-ct-pg {
|
|
881
933
|
display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 10px;
|
|
882
|
-
border: 0; border-radius: 6px; background: none; font: inherit; color: ${
|
|
934
|
+
border: 0; border-radius: 6px; background: none; font: inherit; color: ${i("body-fg")};
|
|
883
935
|
text-decoration: none; cursor: pointer;
|
|
884
936
|
}
|
|
885
|
-
.bim-ct-pg:hover { background: ${
|
|
886
|
-
.bim-ct-pg:focus-visible { outline: 2px solid ${
|
|
887
|
-
.bim-ct-pg[aria-current="page"] { background: ${
|
|
888
|
-
.bim-ct-pg[aria-disabled="true"], .bim-ct-pg:disabled { color: ${
|
|
889
|
-
.bim-ct-gap { min-width: 24px; text-align: center; color: ${
|
|
890
|
-
.bim-ct-pg-of { display: none; padding: 0 12px; color: ${
|
|
937
|
+
.bim-ct-pg:hover { background: ${i("row-hover-bg")}; color: ${i("accent")}; }
|
|
938
|
+
.bim-ct-pg:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 1px; }
|
|
939
|
+
.bim-ct-pg[aria-current="page"] { background: ${i("zebra-bg")}; color: ${i("accent")}; font-weight: 700; cursor: default; }
|
|
940
|
+
.bim-ct-pg[aria-disabled="true"], .bim-ct-pg:disabled { color: ${i("aux-fg")}; opacity: 0.6; cursor: default; background: none; }
|
|
941
|
+
.bim-ct-gap { min-width: 24px; text-align: center; color: ${i("aux-fg")}; }
|
|
942
|
+
.bim-ct-pg-of { display: none; padding: 0 12px; color: ${i("body-fg")}; font-variant-numeric: tabular-nums; }
|
|
891
943
|
|
|
892
944
|
@media (max-width: 1199px) {
|
|
893
945
|
.bim-ct-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
894
946
|
}
|
|
895
947
|
|
|
896
|
-
@media ${
|
|
948
|
+
@media ${Ui} {
|
|
897
949
|
.bim-ct { display: block; padding: 12px 16px 40px; }
|
|
898
950
|
.bim-ct-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
|
899
951
|
.bim-ct-lrow > a { grid-template-columns: minmax(0, 1fr); }
|
|
@@ -902,14 +954,14 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
902
954
|
.bim-ct-side-h { display: none; }
|
|
903
955
|
.bim-ct-drawer-btn {
|
|
904
956
|
display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 14px;
|
|
905
|
-
border: 0; border-radius: 8px; background: ${
|
|
906
|
-
font: inherit; font-size: 14px; color: ${
|
|
957
|
+
border: 0; border-radius: 8px; background: ${i("tint-bg")};
|
|
958
|
+
font: inherit; font-size: 14px; color: ${i("ink")}; text-align: left; cursor: pointer;
|
|
907
959
|
}
|
|
908
960
|
.bim-ct-drawer-btn span { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
909
|
-
.bim-ct-drawer-btn svg { flex: none; transition: transform 0.15s; color: ${
|
|
961
|
+
.bim-ct-drawer-btn svg { flex: none; transition: transform 0.15s; color: ${i("aux-fg")}; }
|
|
910
962
|
.bim-ct-drawer-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
|
|
911
|
-
.bim-ct-drawer-btn:focus-visible { outline: 2px solid ${
|
|
912
|
-
.bim-ct-drawer { margin-top: 6px; padding: 6px; border-radius: 8px; background: ${
|
|
963
|
+
.bim-ct-drawer-btn:focus-visible { outline: 2px solid ${i("accent")}; outline-offset: 2px; }
|
|
964
|
+
.bim-ct-drawer { margin-top: 6px; padding: 6px; border-radius: 8px; background: ${i("card-bg")}; max-height: 70vh; overflow-y: auto; }
|
|
913
965
|
.bim-ct[data-drawer="closed"] .bim-ct-drawer { display: none; }
|
|
914
966
|
.bim-ct-title { font-size: 18px; }
|
|
915
967
|
.bim-ct-pager { flex-wrap: nowrap; justify-content: space-between; }
|
|
@@ -918,9 +970,9 @@ ${gc}`;function Dt({children:e,style:n,wide:i,grid:r}){return t.jsxs("div",{clas
|
|
|
918
970
|
}
|
|
919
971
|
|
|
920
972
|
/* 点击目标 ≥44px(Q5):触屏与窄屏 */
|
|
921
|
-
@media ${
|
|
973
|
+
@media ${rx} {
|
|
922
974
|
.bim-ct-row { min-height: 44px; }
|
|
923
975
|
.bim-ct-tw { width: 44px; }
|
|
924
976
|
.bim-ct-pg { min-width: 44px; height: 44px; }
|
|
925
977
|
}
|
|
926
|
-
`,Yt="未分類",ot="all",Ui=20;function en(e){if(!e)return[];const n=[];for(const i of[e.l1,e.l2,e.l3,e.l4]){const r=(i??"").trim();if(!r)break;n.push(r)}return n}function ox(e){const n=en(e);return n.length?n.join("/"):Yt}function rx(e){const n=en(e);return n.length?n.map((i,r)=>n.slice(0,r+1).join("/")):[Yt]}function sx(e,n=[]){const i=new Map;n.forEach((p,c)=>{const d=[p.cata_l1,p.cata_l2,p.cata_l3,p.cata_l4].filter(u=>!!u);d.forEach((u,g)=>{const x=d.slice(0,g+1).join("/");i.has(x)||i.set(x,c)})});const r=new Map;let s=0;for(const p of e){const c=en(p.classification);if(!c.length){s++;continue}let d=r;c.forEach((u,g)=>{const x=c.slice(0,g+1).join("/");let m=d.get(u);m||(m={id:x,label:u,count:0,children:new Map},d.set(u,m)),m.count++,d=m.children})}const l=p=>[...p.values()].sort((c,d)=>{const u=i.get(c.id)??1/0,g=i.get(d.id)??1/0;return u!==g?u-g:c.label.localeCompare(d.label,"zh")}).map(c=>{const d={id:c.id,label:c.label,count:c.count};return c.children.size&&(d.children=l(c.children)),d}),a=l(r);return s>0&&a.push({id:Yt,label:Yt,count:s}),a}function zt(e,n){if(!n)return[];for(const i of e){if(i.id===n)return[i];if(i.children){const r=zt(i.children,n);if(r.length)return[i,...r]}}return[]}function Vi(e){return e.reduce((n,i)=>n+i.count,0)}function lx(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function ax(e){var p;const n={id:e.id,title:e.title||e.id},i=e.juan_count,r=typeof i=="number"?i:i==null?void 0:i.number;typeof r=="number"&&r>0?n.juan=r:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const d=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return d?{name:c.name,dynasty:d}:{name:c.name}});s.length&&(n.authors=s);const l=lx(typeof e.description=="string"?e.description:(p=e.description)==null?void 0:p.text);l&&(n.summary=l);const a=en(e.classification);return a.length&&(n.classification=a),n}function cx(e,n){const i=e.summary?0:1,r=n.summary?0:1;return i!==r?i-r:e.title.localeCompare(n.title,"zh")}function dx(e,n=Ui){return Math.max(1,Math.ceil(e/n))}function cl(e,n,i=2){if(n<=1)return[1];const r=new Set([1,n]);for(let a=e-i;a<=e+i;a++)a>=1&&a<=n&&r.add(a);const s=[...r].sort((a,p)=>a-p),l=[];return s.forEach((a,p)=>{if(p>0){const c=a-s[p-1];c===2?l.push(a-1):c>2&&l.push(null)}l.push(a)}),l}const px=()=>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 ux(e,n,i){const r=[];i&&r.push({id:ot,parentId:null,hasChildren:!1,firstChildId:null});const s=(l,a)=>{var p;for(const c of l){const d=(p=c.children)!=null&&p.length?c.children:null;r.push({id:c.id,parentId:a,hasChildren:!!d,firstChildId:d?d[0].id:null}),d&&n.has(c.id)&&s(d,c.id)}};return s(e,null),r}function dl({tree:e,selectedId:n,onSelect:i,allLabel:r="全部",label:s="分類"}){const{convert:l}=V(),a=f.useRef(null),p=n&&n!==ot?n:null,c=r!==null,[d,u]=f.useState(()=>{const S=new Set;for(const $ of zt(e,p))S.add($.id);return S});f.useEffect(()=>{const S=zt(e,p);S.length&&u($=>{if(S.every(C=>$.has(C.id)))return $;const w=new Set($);for(const C of S)w.add(C.id);return w})},[e,p]);const g=f.useMemo(()=>ux(e,d,c),[e,d,c]),[x,m]=f.useState(null);f.useEffect(()=>{m(null)},[n]);const b=p??(c?ot:null),k=f.useMemo(()=>{var w;const S=new Set(g.map(C=>C.id));if(x&&S.has(x))return x;if(b&&S.has(b))return b;const $=zt(e,p).map(C=>C.id).filter(C=>S.has(C));return $.length?$[$.length-1]:((w=g[0])==null?void 0:w.id)??null},[g,x,b,e,p]),h=f.useCallback((S,$)=>{u(w=>{const C=w.has(S),N=$??!C;if(N===C)return w;const E=new Set(w);return N?E.add(S):E.delete(S),E})},[]),y=f.useCallback(S=>{m(S),requestAnimationFrame(()=>{var w;const $=Array.from(((w=a.current)==null?void 0:w.querySelectorAll("[data-ct-id]"))??[]).find(C=>C.dataset.ctId===S);$==null||$.focus()})},[]),j=f.useCallback((S,$)=>{$&&h(S,!0),i(S)},[i,h]),v=f.useCallback(S=>{const $=S.target.closest("[data-ct-id]");if(!$)return;const w=$.dataset.ctId,C=g.findIndex(I=>I.id===w);if(C<0)return;const N=g[C];let E=null;switch(S.key){case"ArrowDown":E=g[Math.min(g.length-1,C+1)].id;break;case"ArrowUp":E=g[Math.max(0,C-1)].id;break;case"Home":E=g[0].id;break;case"End":E=g[g.length-1].id;break;case"ArrowRight":if(!N.hasChildren)break;d.has(w)?E=N.firstChildId:h(w,!0);break;case"ArrowLeft":N.hasChildren&&d.has(w)?h(w,!1):E=N.parentId;break;case"Enter":case" ":S.preventDefault(),j(w,N.hasChildren);return;default:return}S.preventDefault(),E&&E!==w&&y(E)},[g,d,h,y,j]),_=(S,$)=>S.map((w,C)=>{var A;const N=(A=w.children)!=null&&A.length?w.children:null,E=!!N&&d.has(w.id),I=w.id===p,O=$===1&&S.length>1&&C===S.length-1;return t.jsxs("li",{role:"treeitem","aria-level":$,"aria-expanded":N?E:void 0,"aria-selected":I,tabIndex:k===w.id?0:-1,"data-ct-id":w.id,className:O?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":$-1},onClick:()=>{m(w.id),j(w.id,!!N)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:N?M=>{M.stopPropagation(),m(w.id),h(w.id)}:void 0,children:N?t.jsx(px,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(w.label)}),t.jsx("span",{className:"bim-ct-n",children:w.count.toLocaleString("en-US")})]}),E&&t.jsx("ul",{role:"group",children:_(N,$+1)})]},w.id)});return t.jsxs("ul",{ref:a,role:"tree","aria-label":l(s),className:"bim-ct-tree",onKeyDown:v,children:[c&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!p,tabIndex:k===ot?0:-1,"data-ct-id":ot,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{m(ot),i(ot)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),t.jsx("span",{className:"bim-ct-lb",children:l(r)}),t.jsx("span",{className:"bim-ct-n",children:Vi(e).toLocaleString("en-US")})]})}),_(e,1)]})}const pl=e=>`/item/${encodeURIComponent(e)}`;function xx(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function ul(e){return e==null||e===""?null:typeof e=="number"?`${e}卷`:e}function xl({work:e,href:n}){var a,p;const{convert:i}=V(),r=ul(e.juan),s=((a=e.authors)==null?void 0:a.filter(c=>c.name))??[],l=((p=e.classification)==null?void 0:p.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:i(e.title)}),r&&t.jsx("span",{className:"bim-ct-juan",children:i(r)})]}),s.length>0&&t.jsx("span",{className:"bim-ct-by",children:s.map((c,d)=>t.jsxs(f.Fragment,{children:[d>0&&"、",c.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",i(c.dynasty),"〕"]}),i(c.name)]},d))}),e.summary&&t.jsx("p",{className:"bim-ct-sum",children:i(e.summary)}),l.length>0&&t.jsx("span",{className:"bim-ct-cls",children:l.map(c=>i(c)).join(" · ")})]})})}function fl({work:e,href:n}){var a,p;const{convert:i}=V(),r=ul(e.juan),s=((a=e.authors)==null?void 0:a.filter(c=>c.name))??[],l=((p=e.classification)==null?void 0:p.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:[i(e.title),r&&t.jsx("span",{className:"bim-ct-juan",children:i(r)})]}),t.jsx("span",{className:"bim-ct-by",children:s.map((c,d)=>t.jsxs(f.Fragment,{children:[d>0&&"、",c.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",i(c.dynasty),"〕"]}),i(c.name)]},d))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(c=>i(c)).join(" · ")})]})})}function gl({page:e,pageCount:n,onPage:i,pageHref:r,label:s="分頁"}){const{convert:l}=V();if(n<=1)return null;const a=c=>d=>{i&&(r&&!xx(d)||(d.preventDefault(),i(c)))},p=(c,d,u)=>{if(u.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:d});const g={className:"bim-ct-pg","aria-current":u.current?"page":void 0,"aria-label":u.aria};return r?t.jsx("a",{...g,href:r(c),onClick:a(c),children:d}):t.jsx("button",{type:"button",...g,onClick:u.current?void 0:a(c),children:d})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":l(s),children:[p(e-1,l("上一頁"),{disabled:e<=1}),t.jsx("ol",{children:cl(e,n).map((c,d)=>t.jsx("li",{style:{display:"contents"},children:c===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):p(c,c,{current:c===e,aria:l(`第 ${c} 頁`)})},c??`gap${d}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),p(e+1,l("下一頁"),{disabled:e>=n})]})}function ml({works:e,workLink:n=pl,emptyText:i="此類暫無作品",view:r="card",...s}){const{convert:l}=V();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:typeof i=="string"?l(i):i}):r==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(a=>t.jsx(fl,{work:a,href:n(a.id)},a.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(a=>t.jsx(xl,{work:a,href:n(a.id)},a.id))}),t.jsx(gl,{...s})]})}const fx=()=>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 gx({tree:e,selectedId:n,page:i,pageCount:r,works:s,onSelect:l,onPage:a,searchSlot:p,workLink:c,pageHref:d,allLabel:u="全部",allTitle:g="全部典籍",pageSize:x=Ui,className:m,view:b,onViewChange:k}){const{convert:h}=V(),j=`bim-ct-drawer-${f.useId().replace(/:/g,"")}`,[v,_]=f.useState(!1),[S,$]=f.useState("card"),w=b??S,C=M=>{$(M),k==null||k(M)},N=zt(e,n&&n!==ot?n:null),E=N.length?N[N.length-1]:null,I=E?E.label:g,O=E?E.count:Vi(e),A=f.useCallback(M=>{_(!1),l(M)},[l]);return t.jsxs("div",{className:m?`bim-ct ${m}`:"bim-ct","data-drawer":v?"open":"closed",children:[t.jsx("style",{children:al}),t.jsxs("aside",{className:"bim-ct-side","aria-label":h("分類導航"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":v,"aria-controls":j,onClick:()=>_(M=>!M),children:[t.jsxs("span",{children:[h("分類"),":",h(N.length?N.map(M=>M.label).join(" › "):u??g)]}),t.jsx(fx,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:j,children:[t.jsx("h2",{className:"bim-ct-side-h",children:h("分類")}),t.jsx(dl,{tree:e,selectedId:n,onSelect:A,allLabel:u})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:h(I)}),N.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:h(N.slice(0,-1).map(M=>M.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[h(`共 ${O.toLocaleString("en-US")} 種 · 每頁 ${x} 條`),r>1&&h(` · 第 ${i} / ${r} 頁`)]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":h("呈現方式"),children:[t.jsx("button",{type:"button","aria-pressed":w==="card",onClick:()=>C("card"),children:h("卡片")}),t.jsx("button",{type:"button","aria-pressed":w==="list",onClick:()=>C("list"),children:h("列表")})]})]}),p&&t.jsx("div",{className:"bim-ct-search",children:p}),t.jsx(ml,{works:s,view:w,workLink:c,page:i,pageCount:r,onPage:a,pageHref:d})]})]})}const li=({style:e})=>{const n=f.useContext(Rt);if(!n)return null;const{locale:i,setLocale:r}=n,s=i==="zh-Hant",l=()=>r(s?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:s?"切换为简体":"切換為繁體",style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${o("border")}`,borderRadius:"4px",background:o("bg"),color:o("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:s?o("primary"):void 0,fontWeight:s?700:400},children:"繁"}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:s?void 0:o("primary"),fontWeight:s?400:700},children:"简"})]})},ai=({href:e,label:n="在 GitHub 查看本条目源文件",size:i=16,className:r,style:s})=>t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:n,"aria-label":n,className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i+8,height:i+8,borderRadius:4,color:o("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:l=>{l.currentTarget.style.color=o("fg")},onMouseLeave:l=>{l.currentTarget.style.color=o("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 Dn(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function mx(e,n){if(!n)return!1;const i=n.id;return i===void 0||i===e}const hx=({id:e,transport:n,initialDetail:i,initialEntry:r,activeTab:s,onTabChange:l,activeJuan:a,onJuanChange:p,lineageMode:c="list",onLineageModeChange:d,lineageCollection:u,onLineageCollectionChange:g,initialPage:x=1,selectedLineageNodeId:m,onNavigate:b,onBack:k,backLabel:h,renderLink:y,enrichDetail:j,getSourceLink:v,readLink:_,railTop:S,extraTabs:$=[],showFeedbackTab:w=!0,feedbackApiUrl:C,height:N,footerExtra:E,className:I,style:O})=>{var qi;const A=de(),{convert:M}=V(),[F]=f.useState(()=>{if(!mx(e,i))return null;const U={...i},ye=r??Dn(e,U);return j&&j(ye,U),{id:e,entry:ye,detail:U}}),[Y,K]=f.useState((F==null?void 0:F.entry)??null),[R,oe]=f.useState((F==null?void 0:F.detail)??null),[H,re]=f.useState(!F),[ee,Q]=f.useState(!1),[J,ce]=f.useState([]),[me,te]=f.useState(!1),[ie,pe]=f.useState(null),[ge,Ce]=f.useState(!1),[ve,we]=f.useState(null),[Ee,Re]=f.useState(!1),[D,se]=f.useState(null),[ne,he]=f.useState([]),[q,P]=f.useState(!1),[T,z]=f.useState(null),[L,B]=f.useState(null),[G,Z]=f.useState(!1),ue=f.useRef(null),[le,be]=f.useState(null),Ne=a!==void 0?a:le,je=f.useCallback(U=>{p?p(U):be(U)},[p]),Pe=f.useCallback(async U=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){ce([]);return}te(!0);try{if(n.getCollectionCatalogs)ce(await n.getCollectionCatalogs(U)||[]);else if(n.getCollectionCatalog){const ye=await n.getCollectionCatalog(U);ce(ye?[{resource_id:"",data:ye}]:[])}}catch{ce([])}finally{te(!1)}},[n]),at=f.useCallback(async U=>{if(!n.getCollatedEditionIndex){pe(null);return}Ce(!0);try{pe(await n.getCollatedEditionIndex(U))}catch{pe(null)}finally{Ce(!1)}},[n]),W=f.useCallback(async U=>{if(!n.getBookFullTextIndex){we(null);return}Re(!0);try{we(await n.getBookFullTextIndex(U))}catch{we(null)}finally{Re(!1),se(U)}},[n]),ae=f.useCallback(async U=>{var ye;if(!n.getWorkFullTextList){he([]);return}P(!0);try{const ze=(await n.getWorkFullTextList(U)??[]).filter(Be=>Be.owner_type!=="Book");he(ze),z(((ye=ze.find(Be=>Be.primary)??ze[0])==null?void 0:ye.key)??null)}catch{he([])}finally{P(!1)}},[n]),fe=f.useCallback(async(U,ye)=>{Z(!0);try{if(n.getLineageGraph){const De=await n.getLineageGraph(U);De&&B(De)}const ze=ye.version_graph;if(!ze||!ze.enabled){L||B(null),ue.current=null;return}const Be=ye.books??[],Ze=[];for(const De of Be)try{const Xe=await n.getItem(De);Xe&&Ze.push(Xe)}catch{}ue.current={work:ye,books:Ze};const X=u??ze.default_collection??(ze.core_books&&ze.core_books.length>0?"core":"all"),Ie=X==="core"&&Array.isArray(ze.core_books)&&ze.core_books.length>0?"core":X??"all";B(un(ye,Ze,Ie))}catch{B(null),ue.current=null}finally{Z(!1)}},[n]),_e=f.useRef({initialDetail:i,initialEntry:r});_e.current={initialDetail:i,initialEntry:r},f.useEffect(()=>{let U=!1;const ye=X=>{X.type==="collection"?Pe(e):X.type==="work"?(X.has_collated&&at(e),(X.version_graph||n.getLineageGraph)&&fe(e,X),n.getWorkFullTextList&&ae(e)):X.type==="book"&&X.has_full_text&&n.getBookFullTextIndex&&W(e)},ze=_e.current;let Be=null;if(F&&F.id===e)Be=F;else if(ze.initialDetail&&ze.initialDetail.id===e){const X={...ze.initialDetail},Ie=ze.initialEntry??Dn(e,X);j&&j(Ie,X),Be={entry:Ie,detail:X}}return Be?(Q(!1),ce(X=>X.length?[]:X),pe(null),we(null),he(X=>X.length?[]:X),z(null),B(null),ue.current=null,K(Be.entry),oe(Be.detail),re(!1),ye(Be.detail),()=>{U=!0}):((async()=>{re(!0),Q(!1),K(null),oe(null),ce([]),pe(null),we(null),he([]),z(null),B(null),ue.current=null;try{const X=await n.getItem(e);if(U)return;if(!X){Q(!0);return}const Ie=X;let De=null;if(n.getEntry&&(De=await n.getEntry(e),U))return;De||(De=Dn(e,Ie)),j&&j(De,Ie),K(De),oe(Ie),ye(Ie)}catch{U||Q(!0)}finally{U||re(!1)}})(),()=>{U=!0})},[e,n,F,j,Pe,at,fe,W,ae]),f.useEffect(()=>{const U=ue.current;!U||!u||B(un(U.work,U.books,u))},[u]);const xe=[];if(R){if(xe.push({key:"basic",label:A.detailTab.basicInfo}),R.type==="collection"){me&&J.length===0&&xe.push({key:"catalog:loading",label:`${A.detailTab.catalog}…`});for(const U of J)xe.push({key:`catalog:${U.resource_id}`,label:U.short_name?`${M(U.short_name)}${A.detailTab.catalogSuffix}`:A.detailTab.collectionCatalog})}R.type==="work"&&(ie||ge)&&s==="collated"&&xe.push({key:"collated",label:ge?`${A.detailTab.collatedEdition}…`:A.detailTab.collatedEdition}),R.type==="book"&&(ve||Ee)&&s==="fulltext"&&xe.push({key:"fulltext",label:Ee?`${A.detailTab.fullText}…`:A.detailTab.fullText}),R.type==="work"&&(ne.length>0||q)&&s==="fulltext"&&xe.push({key:"fulltext",label:q?`${A.detailTab.fullText}…`:A.detailTab.fullText}),R.type==="work"&&(L||G)&&xe.push({key:"lineage",label:G?`${A.detailTab.lineage}…`:A.detailTab.lineage});for(const U of $)(U.position??"before-feedback")==="before-feedback"&&U.shouldShow(R)&&xe.push({key:U.key,label:U.label});w&&s==="feedback"&&xe.push({key:"feedback",label:A.detailTab.feedback});for(const U of $)U.position==="after-feedback"&&U.shouldShow(R)&&xe.push({key:U.key,label:U.label})}f.useEffect(()=>{if(s!=="emendated"||!R)return;l("basic");const U=setTimeout(()=>{var ye;(ye=document.getElementById("studies"))==null||ye.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(U)},[s,R,l]);const $e=Y&&R&&v?v({activeTab:s,activeJuan:Ne,entry:Y,detail:R}):null,Oe=f.useMemo(()=>{var Ze;if(!R)return null;const ye=(R.authors??[]).map(X=>{const Ie=ji(X.role);return`${X.dynasty?`〔${M(X.dynasty)}〕`:""}${M(X.name)}${Ie?` ${M(Ie)}`:""}`}).join(" · ");let ze=!1;try{ze=ke.extractStatus(R.id)==="draft"}catch{}if(R.type==="book"){const X=R;return{title:M(X.title),subtitle:X.edition?M(X.edition):ye||void 0,aside:[ze?A.status.draft:"",ye&&X.edition?ye:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(R.type==="collection"){const X=R;return{title:M(X.title),subtitle:M(lt(X,A.unit.juan))||void 0,aside:[(Ze=X.publication_info)==null?void 0:Ze.year,ze?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ye||void 0}}if(R.type==="entity"){const X=R,Ie=Xe=>Xe==null?"":Xe<0?`前${-Xe}`:String(Xe),De=X.birth_year!=null||X.death_year!=null?`${Ie(X.birth_year)||"?"}—${Ie(X.death_year)||"?"}`:"";return{title:M(X.primary_name||X.title),subtitle:[X.dynasty?`〔${M(X.dynasty)}〕`:"",De].filter(Boolean).join(" ")||void 0,aside:ze?A.status.draft:void 0,secondLine:void 0}}const Be=M(lt(R,A.unit.juan));return{title:M(R.title),subtitle:[Be,ye].filter(Boolean).join(" · ")||void 0,aside:[yx(A,R.subtype),ze?A.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[R,M,A]),qe=R?R.type==="work"?(((qi=ie==null?void 0:ie.juan_files)==null?void 0:qi.length)??0)>0?"collated":ne.length>0?"fulltext":null:R.type==="book"&&(((ve==null?void 0:ve.chapters.length)??0)>0||R.has_full_text&&n.getBookFullTextIndex&&D!==R.id)?"fulltext":null:null,ct=ne.find(U=>U.primary)??ne[0],tn=()=>{var U;qe==="collated"&&((U=ie==null?void 0:ie.juan_files)!=null&&U.length)?(je(ie.juan_files[0]),l("collated")):qe==="fulltext"&&((R==null?void 0:R.type)==="work"&&ct&&z(ct.key),je(null),l("fulltext"))};let dt=null;if(R&&_){const U=_({detail:R,kind:qe,fullTextKey:R.type==="work"?ct==null?void 0:ct.key:void 0});U&&(dt=t.jsx(qn,{href:U}))}else qe&&(dt=t.jsx(qn,{onClick:tn}));const nn=U=>{if(!R)return null;const ye=U.replace(/\.[^.]+$/,"");if(_){const ze=_({detail:R,kind:"fulltext",juan:ye});return ze?{href:ze}:null}return{onClick:()=>{je(ye),l("fulltext")}}},on=new Set($.map(U=>U.key)),Se=xe.filter(U=>U.key.startsWith("catalog:")&&U.key!=="catalog:loading"||on.has(U.key)).map(U=>({key:U.key,label:U.label,onClick:()=>l(U.key)})),Je=()=>{var U;return R?R.type==="work"?t.jsx(tl,{data:R,transport:n,onNavigate:b,renderLink:y,readAction:dt,railTop:S,railLinks:Se}):R.type==="book"?t.jsx(rl,{data:R,transport:n,onNavigate:b,renderLink:y,readAction:dt,fullText:ve,fullTextPending:!!R.has_full_text&&!!n.getBookFullTextIndex&&D!==R.id,chapterLink:nn,railTop:S,railLinks:Se}):R.type==="collection"?t.jsx(sl,{data:R,catalog:(U=J[0])==null?void 0:U.data,transport:n,onNavigate:b,renderLink:y,readAction:dt,railTop:S,railLinks:Se,catalogAction:J.length>0?t.jsxs("a",{href:"#catalog",onClick:ye=>{ye.preventDefault(),l(`catalog:${J[0].resource_id}`)},children:[M(A.detailTab.collectionCatalog)," →"]}):null}):t.jsx(ll,{data:R,transport:n,onNavigate:b,renderLink:y,railTop:S,railLinks:Se}):null},Te=()=>{var ye,ze,Be,Ze;if(!Y||!R)return null;if(s==="basic"||s==="emendated")return Je();if(typeof s=="string"&&s.startsWith("catalog:")){const X=(ye=J.find(Ie=>`catalog:${Ie.resource_id}`===s))==null?void 0:ye.data;return t.jsx(gi,{data:X,onNavigate:b,renderLink:y})}if(s==="collated")return t.jsx(Fi,{index:ie||void 0,workId:e,transport:n,onNavigate:b,activeJuan:Ne,onJuanChange:je});if(s==="fulltext"&&R.type==="work"){const X=T??((ze=ne[0])==null?void 0:ze.key);return X?t.jsx(ni,{bookId:e,workKey:X,versions:ne,onVersionChange:Ie=>{z(Ie),je(null)},transport:n,activeChapter:Ne,onChapterChange:je},X):t.jsx("div",{style:{padding:24,color:o("desc-fg")},children:q?"加载全文目录…":"暂无全文"})}if(s==="fulltext")return t.jsx(ni,{index:ve||void 0,bookId:e,transport:n,activeChapter:Ne,onChapterChange:je});if(s==="lineage"){if(!L)return t.jsx("div",{style:{color:o("label-fg"),padding:"24px 0"},children:G?"加載中…":"暫無版本圖數據"});const X=R.type==="work"?R:null;return t.jsx(Hi,{graph:L,renderLink:y,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:d,selectedNodeId:m,collection:u??((Be=X==null?void 0:X.version_graph)==null?void 0:Be.default_collection),onCollectionChange:g,collectionsAvailable:(Ze=X==null?void 0:X.version_graph)==null?void 0:Ze.collections,collectionCounts:(()=>{var Ji,Zi,Xi,Qi,eo,to,no;if(!X)return;const Ie={},De=((Ji=ue.current)==null?void 0:Ji.books)??[];Ie.all=(((Zi=X.books)==null?void 0:Zi.length)??0)-(((Qi=(Xi=X.version_graph)==null?void 0:Xi.excluded_books)==null?void 0:Qi.length)??0);const Xe=(eo=X.version_graph)==null?void 0:eo.collections;if(Xe)for(const io of Object.keys(Xe))Ie[io]=un(X,De,io).nodes.filter(oo=>oo.kind==="book"&&!oo.bridge).length;return Ie.core==null&&((no=(to=X.version_graph)==null?void 0:to.core_books)!=null&&no.length)&&(Ie.core=X.version_graph.core_books.length),Ie})()})}if(s==="feedback"&&w)return t.jsx(Zs,{resourceId:e,apiUrl:C});const U=$.find(X=>X.key===s);return U?U.render({detail:R,entry:Y,transport:n,onNavigate:b}):null};if(H)return t.jsx(Dt,{style:{minHeight:N,...O},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((U,ye)=>t.jsx("div",{style:{height:ye===1?40:16,width:U,opacity:.35,background:o("rule")}},ye))})});if(ee||!R||!Y||!Oe)return t.jsx(Dt,{style:{minHeight:N,...O},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:o("label-fg"),fontSize:14},children:"找不到該條目,可能已被刪除或 ID 不正確"})});const kt=s==="basic"||s==="emendated",rn=[{label:h??A.detailTab.backToIndex,onClick:k}];if(R.type==="book"&&R.work_id){const U=R.work_id;rn.push({label:A.indexType.work,id:U,onClick:()=>b==null?void 0:b(U)})}rn.push({label:A.indexType[R.type]});const sn=s==="collated"||s==="fulltext",Yi=typeof E=="string"?A.status[E.trim()]??E:E,Ki=t.jsx(ds,{left:t.jsxs(t.Fragment,{children:[Yi,Yi?" · ":"",t.jsx(bx,{id:R.id,label:A.label.id,copied:A.action.copied,copyLabel:A.action.copy})]}),right:t.jsxs(t.Fragment,{children:[w&&!kt&&t.jsx("button",{type:"button",onClick:()=>l("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:o("meta-fg")},children:A.detailTab.submitVersion}),$e&&t.jsx("a",{href:$e.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:o("meta-fg")},children:A.detailTab.dataLicense})]})});return kt?t.jsx("div",{className:I,children:t.jsxs(Dt,{grid:!0,style:{minHeight:N,...O},children:[t.jsx(Jn,{breadcrumb:t.jsx(Zn,{items:rn}),actions:t.jsxs(t.Fragment,{children:[t.jsx(li,{style:{border:"none",background:"transparent"}}),$e&&t.jsx(ai,{...$e})]})}),Je(),Ki]})}):t.jsx("div",{className:I,children:t.jsxs(Dt,{wide:sn,style:{minHeight:N,...O},children:[t.jsx(Jn,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(ki,{char:"籍"}),t.jsx(Zn,{items:rn})]}),actions:t.jsxs(t.Fragment,{children:[t.jsx(li,{}),w&&t.jsx("button",{type:"button",onClick:()=>l("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:o("meta-fg")},children:A.detailTab.feedback}),$e&&t.jsx(ai,{...$e})]})}),t.jsx(ts,{...Oe,aside:sn?t.jsxs("button",{type:"button",onClick:()=>l("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:o("accent"),borderBottom:`1px solid ${o("rule")}`},children:[M("作品信息")," →"]}):Oe.aside}),!sn&&xe.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:xe.map(U=>t.jsx(ns,{label:U.label,active:U.key===s||kt&&U.key==="basic",onClick:()=>l(U.key)},U.key))}),t.jsx("div",{style:{marginTop:!sn&&xe.length>1?8:0},children:Te()}),Ki]})})};function bx({id:e,label:n,copied:i,copyLabel:r}){const[s,l]=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 a;(a=navigator.clipboard)==null||a.writeText(e).then(()=>{l(!0),setTimeout(()=>l(!1),1500)}).catch(()=>{})},title:s?i:r,"aria-label":s?i:r,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:o("aux-fg")},children:s?"✓":"⧉"})]})}function yx(e,n){return n?e.workSubtype[n]??n:""}const hl=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛藍"}],zn="zhusha",Cn="bim-theme";function bl(e){return e==="zhusha"||e==="indigo"}function In(e){return bl(e)?e:zn}function jx(){try{return In(window.localStorage.getItem(Cn))}catch{return zn}}function yl(e){try{window.localStorage.setItem(Cn,e)}catch{}}function jl(e){const n=In(e);return document.documentElement.setAttribute("data-theme",n),n}function vl(){return In(document.documentElement.getAttribute("data-theme"))}const vx=`try{if(localStorage.getItem(${JSON.stringify(Cn)})==='indigo')document.documentElement.setAttribute('data-theme','indigo')}catch(e){}`,kx={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo"},Sx=({onChange:e,style:n})=>{const{convert:i}=V(),[r,s]=f.useState(zn);f.useEffect(()=>{s(vl())},[]);const l=a=>{s(jl(a)),yl(a),e==null||e(a)};return t.jsx("div",{role:"radiogroup","aria-label":i("主題"),style:{display:"inline-flex",alignItems:"center",...n},children:hl.map(a=>{const p=r===a.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":p,"aria-label":i(a.label),title:i(a.label),onClick:()=>l(a.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:o(kx[a.name]),boxShadow:p?`0 0 0 2px ${o("page-bg")}, 0 0 0 3.5px ${o("aux-fg")}`:"none"}})},a.name)})})};exports.BidLink=ke.BidLink;exports.BookIndexError=ke.BookIndexError;exports.BookIndexManager=ke.BookIndexManager;exports.BookIndexStorage=ke.BookIndexStorage;exports.BundleStorage=ke.BundleStorage;exports.ConfigError=ke.ConfigError;exports.GithubStorage=ke.GithubStorage;exports.IdGenerationError=ke.IdGenerationError;exports.IdGenerator=ke.IdGenerator;exports.LocalStorage=ke.LocalStorage;exports.MigrationError=ke.MigrationError;exports.StorageError=ke.StorageError;exports.base36Decode=ke.base36Decode;exports.base36Encode=ke.base36Encode;exports.base58Decode=ke.base58Decode;exports.buildId=ke.buildId;exports.buildPromotionMap=ke.buildPromotionMap;exports.cleanName=ke.cleanName;exports.decodeId=ke.decodeId;exports.decodeIdString=ke.decodeIdString;exports.encodeId=ke.encodeId;exports.extractIdFromUrl=ke.extractIdFromUrl;exports.extractStatus=ke.extractStatus;exports.extractType=ke.extractType;exports.normalizeCatalog=ke.normalizeCatalog;exports.parseId=ke.parseId;exports.shardOf=ke.shardOf;exports.smartDecode=ke.smartDecode;exports.validateResource=ke.validateResource;exports.Badge=mn;exports.BidUrlProvider=Rl;exports.BookDetailLayout=hx;exports.BookFullText=ni;exports.BookPage=rl;exports.Breadcrumb=Zn;exports.CATALOG_ALL_ID=ot;exports.CATALOG_CSS=al;exports.CATALOG_NARROW_QUERY=Gi;exports.CATALOG_PAGE_SIZE=Ui;exports.CATALOG_UNCLASSIFIED_ID=Yt;exports.CardFoot=Xt;exports.CatalogPage=gx;exports.CatalogPager=gl;exports.CatalogTree=dl;exports.CheckFilter=Qr;exports.Chip=is;exports.ChipWall=wc;exports.CollatedEdition=Fi;exports.CollectionCatalog=gi;exports.CollectionPage=sl;exports.CreateEntityDialog=Hs;exports.DEFAULT_READER_PREFS=_i;exports.DEFAULT_THEME=zn;exports.DETAIL_CSS=es;exports.Dash=Tc;exports.DataTable=$c;exports.DetailFooter=ds;exports.DetailGrid=Jt;exports.DetailHeader=ts;exports.EmendatedBySection=Br;exports.EmptyNote=Wc;exports.EntityDetail=Ir;exports.EntityPage=ll;exports.EntityPickerDialog=Us;exports.EntitySelector=Ds;exports.ExpandRow=Ec;exports.ExtLink=Mc;exports.FEEDBACK_FAB_OFFSET_VAR=oi;exports.FONT_SIZE_STEPS=$t;exports.FactList=jc;exports.FeedbackButton=su;exports.FeedbackDialog=qs;exports.FeedbackForm=Js;exports.FeedbackList=Pi;exports.FeedbackTab=Zs;exports.FilterChip=ns;exports.FormInput=Ge;exports.FormTextArea=bt;exports.GUJI_MARKDOWN_FIELD=sc;exports.GUJI_TABLE_NOTATION=vs;exports.GlyphBadge=ki;exports.GujiTable=Ii;exports.HomePage=ti;exports.ImagePanel=ms;exports.IndexApp=pp;exports.IndexBrowser=Un;exports.IndexDetail=fi;exports.IndexEditor=Vs;exports.IndexView=Yp;exports.IntroGrid=yc;exports.LocaleContext=Rt;exports.LocaleProvider=Vl;exports.LocaleToggle=li;exports.MetaLine=We;exports.ModeIndicator=$r;exports.MoreButton=Sc;exports.MoreLink=Bt;exports.PAGE_MAX_WIDTH=dn;exports.PageFrame=Dt;exports.Quote=Nc;exports.READER_CSS=xs;exports.RECENT_IDS_STORAGE_KEY=Ct;exports.ROLE_CLASS_ORDER=Dr;exports.ReadButton=qn;exports.ReaderMdText=Ni;exports.ReaderShell=zi;exports.ReaderToc=gs;exports.RelationPanel=Ps;exports.RepoSourceLink=ai;exports.ResourceEditor=Gn;exports.ResourceGroup=Lc;exports.ResourceLine=Bc;exports.ResourceList=xi;exports.ResourceRow=as;exports.SNIPPET_MARK_END=yr;exports.SNIPPET_MARK_START=br;exports.SearchInput=zr;exports.Sec=Me;exports.Section=Ye;exports.SectionHead=vc;exports.SideList=ht;exports.SmartBidInput=pn;exports.SourceEditor=Ws;exports.SummaryCard=Zt;exports.THEMES=hl;exports.THEME_INIT_SCRIPT=vx;exports.THEME_STORAGE_KEY=Cn;exports.TabFilter=wn;exports.TableHead=zc;exports.TableRow=Cc;exports.TagRow=cs;exports.TagRows=Ac;exports.TextButton=kc;exports.ThemeToggle=Sx;exports.TopStrip=Jn;exports.VersionLineageGraph=ol;exports.VersionLineageList=il;exports.VersionLineageView=Hi;exports.VolumeChips=_c;exports.VolumeLinks=Si;exports.WorkCard=xl;exports.WorkCardGrid=ml;exports.WorkCatalog=up;exports.WorkPage=tl;exports.WorkRow=fl;exports.applyTheme=jl;exports.bucketResources=bi;exports.buildCatalogTree=sx;exports.buildCollectionTable=Gr;exports.buildLineageGraph=un;exports.buildPageUrl=ui;exports.buildParagraphBlocks=Is;exports.buildVersionRow=Pr;exports.buildVersionTable=Or;exports.canParagraphize=$n;exports.catalogNodeIdOf=ox;exports.catalogNodeIdsOf=rx;exports.catalogPageCount=dx;exports.catalogTotal=Vi;exports.classificationPath=en;exports.compareCatalogCards=cx;exports.computeVersionPartition=nc;exports.currentTheme=vl;exports.defaultWorkLink=pl;exports.deriveDating=Qa;exports.deriveEditionType=Vr;exports.deriveEra=qt;exports.deriveYear=vn;exports.deriveYearRange=hi;exports.detailToEditor=Ks;exports.detectGenre=_n;exports.displayAuthorRole=ji;exports.editorToDetail=Vp;exports.eraRank=Yn;exports.findCatalogPath=zt;exports.flattenTitles=Xn;exports.flattenToc=js;exports.formatTemplate=Kt;exports.formatVolumeRange=Sn;exports.getDisplayNameFromUrl=Nt;exports.getStartPage=pi;exports.getTypeGroupKey=ci;exports.groupRelatedWorks=ec;exports.gujiInlineToPlain=Jr;exports.hasGujiMarkdownV02=Kn;exports.hasGujiTableNotation=ks;exports.isThemeName=bl;exports.measureText=lt;exports.mergeVolumeResources=di;exports.normalizeEra=Ae;exports.normalizeRole=yi;exports.normalizeTheme=In;exports.normalizeVolumeIndex=Gt;exports.normalizeVolumes=_r;exports.numberToChinese=Ur;exports.paginationItems=cl;exports.parseChineseNumber=xn;exports.parseGujiInline=qr;exports.parseGujiTable=ws;exports.parseSourceString=Ms;exports.pickReaderVersion=ys;exports.readStoredTheme=jx;exports.readerVersionOptionLabel=ei;exports.readerVersionsFromFullText=bs;exports.renderFullTextBody=ld;exports.renderProperNames=Es;exports.renderReaderInline=Ri;exports.resourceHref=Lt;exports.resourceNote=kn;exports.roleFacets=Hr;exports.rowNo=Ic;exports.sortYear=fn;exports.splitFullTextTables=Ci;exports.splitHighlightSnippet=jr;exports.splitTableRow=Ss;exports.storeTheme=yl;exports.stringifySources=Fs;exports.toCatalogWorkCard=ax;exports.useBidUrl=Fe;exports.useConvert=V;exports.useReaderPrefs=$i;exports.useT=de;exports.validateLineageGraph=zu;exports.volumeStats=hn;
|
|
978
|
+
`,Kt="未分類",rt="all",Vi=20;function nn(e){if(!e)return[];const n=[];for(const o of[e.l1,e.l2,e.l3,e.l4]){const r=(o??"").trim();if(!r)break;n.push(r)}return n}function sx(e){const n=nn(e);return n.length?n.join("/"):Kt}function lx(e){const n=nn(e);return n.length?n.map((o,r)=>n.slice(0,r+1).join("/")):[Kt]}function ax(e,n=[]){const o=new Map;n.forEach((p,c)=>{const a=[p.cata_l1,p.cata_l2,p.cata_l3,p.cata_l4].filter(u=>!!u);a.forEach((u,f)=>{const x=a.slice(0,f+1).join("/");o.has(x)||o.set(x,c)})});const r=new Map;let s=0;for(const p of e){const c=nn(p.classification);if(!c.length){s++;continue}let a=r;c.forEach((u,f)=>{const x=c.slice(0,f+1).join("/");let m=a.get(u);m||(m={id:x,label:u,count:0,children:new Map},a.set(u,m)),m.count++,a=m.children})}const l=p=>[...p.values()].sort((c,a)=>{const u=o.get(c.id)??1/0,f=o.get(a.id)??1/0;return u!==f?u-f:c.label.localeCompare(a.label,"zh")}).map(c=>{const a={id:c.id,label:c.label,count:c.count};return c.children.size&&(a.children=l(c.children)),a}),d=l(r);return s>0&&d.push({id:Kt,label:Kt,count:s}),d}function zt(e,n){if(!n)return[];for(const o of e){if(o.id===n)return[o];if(o.children){const r=zt(o.children,n);if(r.length)return[o,...r]}}return[]}function Yi(e){return e.reduce((n,o)=>n+o.count,0)}function cx(e){return(e??"").replace(/\*\*|__/g,"").replace(/\s+/g," ").trim()}function dx(e){var p;const n={id:e.id,title:e.title||e.id},o=e.juan_count,r=typeof o=="number"?o:o==null?void 0:o.number;typeof r=="number"&&r>0?n.juan=r:e.measure_info&&(n.juan=e.measure_info);const s=(e.authors??[]).filter(c=>c==null?void 0:c.name).map(c=>{const a=c.dynasty||(e.authors.length===1?e.dynasty:void 0);return a?{name:c.name,dynasty:a}:{name:c.name}});s.length&&(n.authors=s);const l=cx(typeof e.description=="string"?e.description:(p=e.description)==null?void 0:p.text);l&&(n.summary=l);const d=nn(e.classification);return d.length&&(n.classification=d),n}function px(e,n){const o=e.summary?0:1,r=n.summary?0:1;return o!==r?o-r:e.title.localeCompare(n.title,"zh")}function ux(e,n=Vi){return Math.max(1,Math.ceil(e/n))}function dl(e,n,o=2){if(n<=1)return[1];const r=new Set([1,n]);for(let d=e-o;d<=e+o;d++)d>=1&&d<=n&&r.add(d);const s=[...r].sort((d,p)=>d-p),l=[];return s.forEach((d,p)=>{if(p>0){const c=d-s[p-1];c===2?l.push(d-1):c>2&&l.push(null)}l.push(d)}),l}const xx=()=>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 fx(e,n,o){const r=[];o&&r.push({id:rt,parentId:null,hasChildren:!1,firstChildId:null});const s=(l,d)=>{var p;for(const c of l){const a=(p=c.children)!=null&&p.length?c.children:null;r.push({id:c.id,parentId:d,hasChildren:!!a,firstChildId:a?a[0].id:null}),a&&n.has(c.id)&&s(a,c.id)}};return s(e,null),r}function pl({tree:e,selectedId:n,onSelect:o,allLabel:r="全部",label:s="分類"}){const{convert:l}=Z(),d=g.useRef(null),p=n&&n!==rt?n:null,c=r!==null,[a,u]=g.useState(()=>{const v=new Set;for(const _ of zt(e,p))v.add(_.id);return v});g.useEffect(()=>{const v=zt(e,p);v.length&&u(_=>{if(v.every(z=>_.has(z.id)))return _;const S=new Set(_);for(const z of v)S.add(z.id);return S})},[e,p]);const f=g.useMemo(()=>fx(e,a,c),[e,a,c]),[x,m]=g.useState(null);g.useEffect(()=>{m(null)},[n]);const j=p??(c?rt:null),w=g.useMemo(()=>{var S;const v=new Set(f.map(z=>z.id));if(x&&v.has(x))return x;if(j&&v.has(j))return j;const _=zt(e,p).map(z=>z.id).filter(z=>v.has(z));return _.length?_[_.length-1]:((S=f[0])==null?void 0:S.id)??null},[f,x,j,e,p]),h=g.useCallback((v,_)=>{u(S=>{const z=S.has(v),N=_??!z;if(N===z)return S;const T=new Set(S);return N?T.add(v):T.delete(v),T})},[]),b=g.useCallback(v=>{m(v),requestAnimationFrame(()=>{var S;const _=Array.from(((S=d.current)==null?void 0:S.querySelectorAll("[data-ct-id]"))??[]).find(z=>z.dataset.ctId===v);_==null||_.focus()})},[]),y=g.useCallback((v,_)=>{_&&h(v,!0),o(v)},[o,h]),k=g.useCallback(v=>{const _=v.target.closest("[data-ct-id]");if(!_)return;const S=_.dataset.ctId,z=f.findIndex(C=>C.id===S);if(z<0)return;const N=f[z];let T=null;switch(v.key){case"ArrowDown":T=f[Math.min(f.length-1,z+1)].id;break;case"ArrowUp":T=f[Math.max(0,z-1)].id;break;case"Home":T=f[0].id;break;case"End":T=f[f.length-1].id;break;case"ArrowRight":if(!N.hasChildren)break;a.has(S)?T=N.firstChildId:h(S,!0);break;case"ArrowLeft":N.hasChildren&&a.has(S)?h(S,!1):T=N.parentId;break;case"Enter":case" ":v.preventDefault(),y(S,N.hasChildren);return;default:return}v.preventDefault(),T&&T!==S&&b(T)},[f,a,h,b,y]),$=(v,_)=>v.map((S,z)=>{var B;const N=(B=S.children)!=null&&B.length?S.children:null,T=!!N&&a.has(S.id),C=S.id===p,D=_===1&&v.length>1&&z===v.length-1;return t.jsxs("li",{role:"treeitem","aria-level":_,"aria-expanded":N?T:void 0,"aria-selected":C,tabIndex:w===S.id?0:-1,"data-ct-id":S.id,className:D?"bim-ct-last":void 0,children:[t.jsxs("div",{className:"bim-ct-row",style:{"--bimct-lv":_-1},onClick:()=>{m(S.id),y(S.id,!!N)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true",onClick:N?O=>{O.stopPropagation(),m(S.id),h(S.id)}:void 0,children:N?t.jsx(xx,{}):null}),t.jsx("span",{className:"bim-ct-lb",children:l(S.label)}),t.jsx("span",{className:"bim-ct-n",children:S.count.toLocaleString("en-US")})]}),T&&t.jsx("ul",{role:"group",children:$(N,_+1)})]},S.id)});return t.jsxs("ul",{ref:d,role:"tree","aria-label":l(s),className:"bim-ct-tree",onKeyDown:k,children:[c&&t.jsx("li",{role:"treeitem","aria-level":1,"aria-selected":!p,tabIndex:w===rt?0:-1,"data-ct-id":rt,children:t.jsxs("div",{className:"bim-ct-row",onClick:()=>{m(rt),o(rt)},children:[t.jsx("span",{className:"bim-ct-tw","aria-hidden":"true"}),t.jsx("span",{className:"bim-ct-lb",children:l(r)}),t.jsx("span",{className:"bim-ct-n",children:Yi(e).toLocaleString("en-US")})]})}),$(e,1)]})}const ul=e=>`/item/${encodeURIComponent(e)}`;function gx(e){return e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey}function xl(e){return e==null||e===""?null:typeof e=="number"?`${e}卷`:e}function fl({work:e,href:n}){var d,p;const{convert:o}=Z(),r=xl(e.juan),s=((d=e.authors)==null?void 0:d.filter(c=>c.name))??[],l=((p=e.classification)==null?void 0:p.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)}),r&&t.jsx("span",{className:"bim-ct-juan",children:o(r)})]}),s.length>0&&t.jsx("span",{className:"bim-ct-by",children:s.map((c,a)=>t.jsxs(g.Fragment,{children:[a>0&&"、",c.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(c.dynasty),"〕"]}),o(c.name)]},a))}),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(c=>o(c)).join(" · ")})]})})}function gl({work:e,href:n}){var d,p;const{convert:o}=Z(),r=xl(e.juan),s=((d=e.authors)==null?void 0:d.filter(c=>c.name))??[],l=((p=e.classification)==null?void 0:p.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),r&&t.jsx("span",{className:"bim-ct-juan",children:o(r)})]}),t.jsx("span",{className:"bim-ct-by",children:s.map((c,a)=>t.jsxs(g.Fragment,{children:[a>0&&"、",c.dynasty&&t.jsxs("span",{className:"bim-ct-dy",children:["〔",o(c.dynasty),"〕"]}),o(c.name)]},a))}),t.jsx("span",{className:"bim-ct-cls",children:l.map(c=>o(c)).join(" · ")})]})})}function ml({page:e,pageCount:n,onPage:o,pageHref:r,label:s="分頁"}){const{convert:l}=Z();if(n<=1)return null;const d=c=>a=>{o&&(r&&!gx(a)||(a.preventDefault(),o(c)))},p=(c,a,u)=>{if(u.disabled)return t.jsx("span",{className:"bim-ct-pg","aria-disabled":"true",children:a});const f={className:"bim-ct-pg","aria-current":u.current?"page":void 0,"aria-label":u.aria};return r?t.jsx("a",{...f,href:r(c),onClick:d(c),children:a}):t.jsx("button",{type:"button",...f,onClick:u.current?void 0:d(c),children:a})};return t.jsxs("nav",{className:"bim-ct-pager","aria-label":l(s),children:[p(e-1,l("上一頁"),{disabled:e<=1}),t.jsx("ol",{children:dl(e,n).map((c,a)=>t.jsx("li",{style:{display:"contents"},children:c===null?t.jsx("span",{className:"bim-ct-gap","aria-hidden":"true",children:"…"}):p(c,c,{current:c===e,aria:l(`第 ${c} 頁`)})},c??`gap${a}`))}),t.jsxs("span",{className:"bim-ct-pg-of","aria-current":"page",children:[e," / ",n]}),p(e+1,l("下一頁"),{disabled:e>=n})]})}function hl({works:e,workLink:n=ul,emptyText:o="此類暫無作品",view:r="card",...s}){const{convert:l}=Z();return t.jsxs("div",{className:"bim-ct-works",children:[e.length===0?t.jsx("p",{className:"bim-ct-empty",children:typeof o=="string"?l(o):o}):r==="list"?t.jsx("ul",{className:"bim-ct-list",children:e.map(d=>t.jsx(gl,{work:d,href:n(d.id)},d.id))}):t.jsx("ul",{className:"bim-ct-grid",children:e.map(d=>t.jsx(fl,{work:d,href:n(d.id)},d.id))}),t.jsx(ml,{...s})]})}const mx=()=>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 hx({tree:e,selectedId:n,page:o,pageCount:r,works:s,onSelect:l,onPage:d,searchSlot:p,workLink:c,pageHref:a,allLabel:u="全部",allTitle:f="全部典籍",pageSize:x=Vi,className:m,view:j,onViewChange:w}){const{convert:h}=Z(),y=`bim-ct-drawer-${g.useId().replace(/:/g,"")}`,[k,$]=g.useState(!1),[v,_]=g.useState("card"),S=j??v,z=O=>{_(O),w==null||w(O)},N=zt(e,n&&n!==rt?n:null),T=N.length?N[N.length-1]:null,C=T?T.label:f,D=T?T.count:Yi(e),B=g.useCallback(O=>{$(!1),l(O)},[l]);return t.jsxs("div",{className:m?`bim-ct ${m}`:"bim-ct","data-drawer":k?"open":"closed",children:[t.jsx("style",{children:cl}),t.jsxs("aside",{className:"bim-ct-side","aria-label":h("分類導航"),children:[t.jsxs("button",{type:"button",className:"bim-ct-drawer-btn","aria-expanded":k,"aria-controls":y,onClick:()=>$(O=>!O),children:[t.jsxs("span",{children:[h("分類"),":",h(N.length?N.map(O=>O.label).join(" › "):u??f)]}),t.jsx(mx,{})]}),t.jsxs("div",{className:"bim-ct-drawer",id:y,children:[t.jsx("h2",{className:"bim-ct-side-h",children:h("分類")}),t.jsx(pl,{tree:e,selectedId:n,onSelect:B,allLabel:u})]})]}),t.jsxs("div",{className:"bim-ct-main",children:[t.jsxs("header",{className:"bim-ct-head",children:[t.jsx("h1",{className:"bim-ct-title",children:h(C)}),N.length>1&&t.jsx("span",{className:"bim-ct-crumb",children:h(N.slice(0,-1).map(O=>O.label).join(" › "))}),t.jsxs("span",{className:"bim-ct-stat",children:[h(`共 ${D.toLocaleString("en-US")} 種 · 每頁 ${x} 條`),r>1&&h(` · 第 ${o} / ${r} 頁`)]}),t.jsxs("span",{className:"bim-ct-view",role:"group","aria-label":h("呈現方式"),children:[t.jsx("button",{type:"button","aria-pressed":S==="card",onClick:()=>z("card"),children:h("卡片")}),t.jsx("button",{type:"button","aria-pressed":S==="list",onClick:()=>z("list"),children:h("列表")})]})]}),p&&t.jsx("div",{className:"bim-ct-search",children:p}),t.jsx(hl,{works:s,view:S,workLink:c,page:o,pageCount:r,onPage:d,pageHref:a})]})]})}const ai=({style:e})=>{const n=g.useContext(Rt);if(!n)return null;const{locale:o,setLocale:r}=n,s=o==="zh-Hant",l=()=>r(s?"zh-Hans":"zh-Hant");return t.jsxs("button",{type:"button",onClick:l,title:s?"切换为简体":"切換為繁體",style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:`1px solid ${i("border")}`,borderRadius:"4px",background:i("bg"),color:i("fg"),cursor:"pointer",userSelect:"none",...e},children:[t.jsx("span",{style:{color:s?i("primary"):void 0,fontWeight:s?700:400},children:"繁"}),t.jsx("span",{style:{opacity:.3},children:"/"}),t.jsx("span",{style:{color:s?void 0:i("primary"),fontWeight:s?400:700},children:"简"})]})},ci=({href:e,label:n="在 GitHub 查看本条目源文件",size:o=16,className:r,style:s})=>t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",title:n,"aria-label":n,className:r,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:o+8,height:o+8,borderRadius:4,color:i("desc-fg"),textDecoration:"none",transition:"color 120ms, background 120ms",...s},onMouseEnter:l=>{l.currentTarget.style.color=i("fg")},onMouseLeave:l=>{l.currentTarget.style.color=i("desc-fg")},children:t.jsx("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M8 0C3.58 0 0 3.58 0 8a8 8 0 0 0 5.47 7.59c.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"})})});function Dn(e,n){return{id:e,title:n.title??n.primary_name??e,type:n.type??"book"}}function bx(e,n){if(!n)return!1;const o=n.id;return o===void 0||o===e}const yx=({id:e,transport:n,initialDetail:o,initialEntry:r,activeTab:s,onTabChange:l,activeJuan:d,onJuanChange:p,lineageMode:c="list",onLineageModeChange:a,lineageCollection:u,onLineageCollectionChange:f,initialPage:x=1,selectedLineageNodeId:m,onNavigate:j,onBack:w,backLabel:h,renderLink:b,enrichDetail:y,getSourceLink:k,readLink:$,railTop:v,extraTabs:_=[],showFeedbackTab:S=!0,feedbackApiUrl:z,height:N,footerExtra:T,className:C,style:D})=>{var Ji;const B=ue(),{convert:O}=Z(),[M]=g.useState(()=>{if(!bx(e,o))return null;const J={...o},ve=r??Dn(e,J);return y&&y(ve,J),{id:e,entry:ve,detail:J}}),[X,Y]=g.useState((M==null?void 0:M.entry)??null),[E,ee]=g.useState((M==null?void 0:M.detail)??null),[F,q]=g.useState(!M),[ae,ne]=g.useState(!1),[Q,ie]=g.useState([]),[ge,re]=g.useState(!1),[le,pe]=g.useState(null),[Re,$e]=g.useState(!1),[ye,Se]=g.useState(null),[Ne,je]=g.useState(!1),[H,ce]=g.useState(null),[oe,he]=g.useState([]),[me,U]=g.useState(!1),[R,V]=g.useState(null),[W,A]=g.useState(null),[I,G]=g.useState(!1),P=g.useRef(null),[K,se]=g.useState(null),ke=d!==void 0?d:K,be=g.useCallback(J=>{p?p(J):se(J)},[p]),Le=g.useCallback(async J=>{if(!n.getCollectionCatalogs&&!n.getCollectionCatalog){ie([]);return}re(!0);try{if(n.getCollectionCatalogs)ie(await n.getCollectionCatalogs(J)||[]);else if(n.getCollectionCatalog){const ve=await n.getCollectionCatalog(J);ie(ve?[{resource_id:"",data:ve}]:[])}}catch{ie([])}finally{re(!1)}},[n]),qe=g.useCallback(async J=>{if(!n.getCollatedEditionIndex){pe(null);return}$e(!0);try{pe(await n.getCollatedEditionIndex(J))}catch{pe(null)}finally{$e(!1)}},[n]),L=g.useCallback(async J=>{if(!n.getBookFullTextIndex){Se(null);return}je(!0);try{Se(await n.getBookFullTextIndex(J))}catch{Se(null)}finally{je(!1),ce(J)}},[n]),de=g.useCallback(async J=>{var ve;if(!n.getWorkFullTextList){he([]);return}U(!0);try{const Ie=(await n.getWorkFullTextList(J)??[]).filter(Ae=>Ae.owner_type!=="Book");he(Ie),V(((ve=Ie.find(Ae=>Ae.primary)??Ie[0])==null?void 0:ve.key)??null)}catch{he([])}finally{U(!1)}},[n]),fe=g.useCallback(async(J,ve)=>{G(!0);try{if(n.getLineageGraph){const De=await n.getLineageGraph(J);De&&A(De)}const Ie=ve.version_graph;if(!Ie||!Ie.enabled){W||A(null),P.current=null;return}const Ae=ve.books??[],Qe=[];for(const De of Ae)try{const et=await n.getItem(De);et&&Qe.push(et)}catch{}P.current={work:ve,books:Qe};const te=u??Ie.default_collection??(Ie.core_books&&Ie.core_books.length>0?"core":"all"),Te=te==="core"&&Array.isArray(Ie.core_books)&&Ie.core_books.length>0?"core":te??"all";A(fn(ve,Qe,Te))}catch{A(null),P.current=null}finally{G(!1)}},[n]),ze=g.useRef({initialDetail:o,initialEntry:r});ze.current={initialDetail:o,initialEntry:r},g.useEffect(()=>{let J=!1;const ve=te=>{te.type==="collection"?Le(e):te.type==="work"?(te.has_collated&&qe(e),(te.version_graph||n.getLineageGraph)&&fe(e,te),n.getWorkFullTextList&&de(e)):te.type==="book"&&te.has_full_text&&n.getBookFullTextIndex&&L(e)},Ie=ze.current;let Ae=null;if(M&&M.id===e)Ae=M;else if(Ie.initialDetail&&Ie.initialDetail.id===e){const te={...Ie.initialDetail},Te=Ie.initialEntry??Dn(e,te);y&&y(Te,te),Ae={entry:Te,detail:te}}return Ae?(ne(!1),ie(te=>te.length?[]:te),pe(null),Se(null),he(te=>te.length?[]:te),V(null),A(null),P.current=null,Y(Ae.entry),ee(Ae.detail),q(!1),ve(Ae.detail),()=>{J=!0}):((async()=>{q(!0),ne(!1),Y(null),ee(null),ie([]),pe(null),Se(null),he([]),V(null),A(null),P.current=null;try{const te=await n.getItem(e);if(J)return;if(!te){ne(!0);return}const Te=te;let De=null;if(n.getEntry&&(De=await n.getEntry(e),J))return;De||(De=Dn(e,Te)),y&&y(De,Te),Y(De),ee(Te),ve(Te)}catch{J||ne(!0)}finally{J||q(!1)}})(),()=>{J=!0})},[e,n,M,y,Le,qe,fe,L,de]),g.useEffect(()=>{const J=P.current;!J||!u||A(fn(J.work,J.books,u))},[u]);const xe=[];if(E){if(xe.push({key:"basic",label:B.detailTab.basicInfo}),E.type==="collection"){ge&&Q.length===0&&xe.push({key:"catalog:loading",label:`${B.detailTab.catalog}…`});for(const J of Q)xe.push({key:`catalog:${J.resource_id}`,label:J.short_name?`${O(J.short_name)}${B.detailTab.catalogSuffix}`:B.detailTab.collectionCatalog})}E.type==="work"&&(le||Re)&&s==="collated"&&xe.push({key:"collated",label:Re?`${B.detailTab.collatedEdition}…`:B.detailTab.collatedEdition}),E.type==="book"&&(ye||Ne)&&s==="fulltext"&&xe.push({key:"fulltext",label:Ne?`${B.detailTab.fullText}…`:B.detailTab.fullText}),E.type==="work"&&(oe.length>0||me)&&s==="fulltext"&&xe.push({key:"fulltext",label:me?`${B.detailTab.fullText}…`:B.detailTab.fullText}),E.type==="work"&&(W||I)&&xe.push({key:"lineage",label:I?`${B.detailTab.lineage}…`:B.detailTab.lineage});for(const J of _)(J.position??"before-feedback")==="before-feedback"&&J.shouldShow(E)&&xe.push({key:J.key,label:J.label});S&&s==="feedback"&&xe.push({key:"feedback",label:B.detailTab.feedback});for(const J of _)J.position==="after-feedback"&&J.shouldShow(E)&&xe.push({key:J.key,label:J.label})}g.useEffect(()=>{if(s!=="emendated"||!E)return;l("basic");const J=setTimeout(()=>{var ve;(ve=document.getElementById("studies"))==null||ve.scrollIntoView({behavior:"smooth",block:"start"})},100);return()=>clearTimeout(J)},[s,E,l]);const Ce=X&&E&&k?k({activeTab:s,activeJuan:ke,entry:X,detail:E}):null,Oe=g.useMemo(()=>{var Qe;if(!E)return null;const ve=(E.authors??[]).map(te=>{const Te=vi(te.role);return`${te.dynasty?`〔${O(te.dynasty)}〕`:""}${O(te.name)}${Te?` ${O(Te)}`:""}`}).join(" · ");let Ie=!1;try{Ie=we.extractStatus(E.id)==="draft"}catch{}if(E.type==="book"){const te=E;return{title:O(te.title),subtitle:te.edition?O(te.edition):ve||void 0,aside:[Ie?B.status.draft:"",ve&&te.edition?ve:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}}if(E.type==="collection"){const te=E;return{title:O(te.title),subtitle:O(at(te,B.unit.juan))||void 0,aside:[(Qe=te.publication_info)==null?void 0:Qe.year,Ie?B.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:ve||void 0}}if(E.type==="entity"){const te=E,Te=et=>et==null?"":et<0?`前${-et}`:String(et),De=te.birth_year!=null||te.death_year!=null?`${Te(te.birth_year)||"?"}—${Te(te.death_year)||"?"}`:"";return{title:O(te.primary_name||te.title),subtitle:[te.dynasty?`〔${O(te.dynasty)}〕`:"",De].filter(Boolean).join(" ")||void 0,aside:Ie?B.status.draft:void 0,secondLine:void 0}}const Ae=O(at(E,B.unit.juan));return{title:O(E.title),subtitle:[Ae,ve].filter(Boolean).join(" · ")||void 0,aside:[vx(B,E.subtype),Ie?B.status.draft:""].filter(Boolean).join(" · ")||void 0,secondLine:void 0}},[E,O,B]),Ze=E?E.type==="work"?(((Ji=le==null?void 0:le.juan_files)==null?void 0:Ji.length)??0)>0?"collated":oe.length>0?"fulltext":null:E.type==="book"&&(((ye==null?void 0:ye.chapters.length)??0)>0||E.has_full_text&&n.getBookFullTextIndex&&H!==E.id)?"fulltext":null:null,ct=oe.find(J=>J.primary)??oe[0],on=()=>{var J;Ze==="collated"&&((J=le==null?void 0:le.juan_files)!=null&&J.length)?(be(le.juan_files[0]),l("collated")):Ze==="fulltext"&&((E==null?void 0:E.type)==="work"&&ct&&V(ct.key),be(null),l("fulltext"))};let dt=null;if(E&&$){const J=$({detail:E,kind:Ze,fullTextKey:E.type==="work"?ct==null?void 0:ct.key:void 0});J&&(dt=t.jsx(Kn,{href:J}))}else Ze&&(dt=t.jsx(Kn,{onClick:on}));const rn=J=>{if(!E)return null;const ve=J.replace(/\.[^.]+$/,"");if($){const Ie=$({detail:E,kind:"fulltext",juan:ve});return Ie?{href:Ie}:null}return{onClick:()=>{be(ve),l("fulltext")}}},sn=new Set(_.map(J=>J.key)),_e=xe.filter(J=>J.key.startsWith("catalog:")&&J.key!=="catalog:loading"||sn.has(J.key)).map(J=>({key:J.key,label:J.label,onClick:()=>l(J.key)})),Xe=()=>{var J;return E?E.type==="work"?t.jsx(nl,{data:E,transport:n,onNavigate:j,renderLink:b,readAction:dt,railTop:v,railLinks:_e}):E.type==="book"?t.jsx(sl,{data:E,transport:n,onNavigate:j,renderLink:b,readAction:dt,fullText:ye,fullTextPending:!!E.has_full_text&&!!n.getBookFullTextIndex&&H!==E.id,chapterLink:rn,railTop:v,railLinks:_e}):E.type==="collection"?t.jsx(ll,{data:E,catalog:(J=Q[0])==null?void 0:J.data,transport:n,onNavigate:j,renderLink:b,readAction:dt,railTop:v,railLinks:_e,catalogAction:Q.length>0?t.jsxs("a",{href:"#catalog",onClick:ve=>{ve.preventDefault(),l(`catalog:${Q[0].resource_id}`)},children:[O(B.detailTab.collectionCatalog)," →"]}):null}):t.jsx(al,{data:E,transport:n,onNavigate:j,renderLink:b,railTop:v,railLinks:_e}):null},Ee=()=>{var ve,Ie,Ae,Qe;if(!X||!E)return null;if(s==="basic"||s==="emendated")return Xe();if(typeof s=="string"&&s.startsWith("catalog:")){const te=(ve=Q.find(Te=>`catalog:${Te.resource_id}`===s))==null?void 0:ve.data;return t.jsx(mi,{data:te,onNavigate:j,renderLink:b})}if(s==="collated")return t.jsx(Pi,{index:le||void 0,workId:e,transport:n,onNavigate:j,activeJuan:ke,onJuanChange:be});if(s==="fulltext"&&E.type==="work"){const te=R??((Ie=oe[0])==null?void 0:Ie.key);return te?t.jsx(ii,{bookId:e,workKey:te,versions:oe,onVersionChange:Te=>{V(Te),be(null)},transport:n,activeChapter:ke,onChapterChange:be},te):t.jsx("div",{style:{padding:24,color:i("desc-fg")},children:me?"加载全文目录…":"暂无全文"})}if(s==="fulltext")return t.jsx(ii,{index:ye||void 0,bookId:e,transport:n,activeChapter:ke,onChapterChange:be});if(s==="lineage"){if(!W)return t.jsx("div",{style:{color:i("label-fg"),padding:"24px 0"},children:I?"加載中…":"暫無版本圖數據"});const te=E.type==="work"?E:null;return t.jsx(Gi,{graph:W,renderLink:b,graphHeight:Math.max(500,(typeof window<"u"?window.innerHeight:800)-250),defaultMode:c,onModeChange:a,selectedNodeId:m,collection:u??((Ae=te==null?void 0:te.version_graph)==null?void 0:Ae.default_collection),onCollectionChange:f,collectionsAvailable:(Qe=te==null?void 0:te.version_graph)==null?void 0:Qe.collections,collectionCounts:(()=>{var Zi,Xi,Qi,eo,to,no,io;if(!te)return;const Te={},De=((Zi=P.current)==null?void 0:Zi.books)??[];Te.all=(((Xi=te.books)==null?void 0:Xi.length)??0)-(((eo=(Qi=te.version_graph)==null?void 0:Qi.excluded_books)==null?void 0:eo.length)??0);const et=(to=te.version_graph)==null?void 0:to.collections;if(et)for(const oo of Object.keys(et))Te[oo]=fn(te,De,oo).nodes.filter(ro=>ro.kind==="book"&&!ro.bridge).length;return Te.core==null&&((io=(no=te.version_graph)==null?void 0:no.core_books)!=null&&io.length)&&(Te.core=te.version_graph.core_books.length),Te})()})}if(s==="feedback"&&S)return t.jsx(Xs,{resourceId:e,apiUrl:z});const J=_.find(te=>te.key===s);return J?J.render({detail:E,entry:X,transport:n,onNavigate:j}):null};if(F)return t.jsx(Ht,{style:{minHeight:N,...D},children:t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12,paddingTop:48},children:[180,320,160].map((J,ve)=>t.jsx("div",{style:{height:ve===1?40:16,width:J,opacity:.35,background:i("rule")}},ve))})});if(ae||!E||!X||!Oe)return t.jsx(Ht,{style:{minHeight:N,...D},children:t.jsx("div",{style:{padding:"64px 0",textAlign:"center",color:i("label-fg"),fontSize:14},children:"找不到該條目,可能已被刪除或 ID 不正確"})});const kt=s==="basic"||s==="emendated",ln=[{label:h??B.detailTab.backToIndex,onClick:w}];if(E.type==="book"&&E.work_id){const J=E.work_id;ln.push({label:B.indexType.work,id:J,onClick:()=>j==null?void 0:j(J)})}ln.push({label:B.indexType[E.type]});const an=s==="collated"||s==="fulltext",qi=typeof T=="string"?B.status[T.trim()]??T:T,Ki=t.jsx(ps,{left:t.jsxs(t.Fragment,{children:[qi,qi?" · ":"",t.jsx(jx,{id:E.id,label:B.label.id,copied:B.action.copied,copyLabel:B.action.copy})]}),right:t.jsxs(t.Fragment,{children:[S&&!kt&&t.jsx("button",{type:"button",onClick:()=>l("feedback"),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:B.detailTab.submitVersion}),Ce&&t.jsx("a",{href:Ce.href,target:"_blank",rel:"noopener noreferrer",className:"bim-d-hit",style:{color:i("meta-fg")},children:B.detailTab.dataLicense})]})});return kt?t.jsx("div",{className:C,children:t.jsxs(Ht,{grid:!0,style:{minHeight:N,...D},children:[t.jsx(Jn,{breadcrumb:t.jsx(Zn,{items:ln}),actions:t.jsxs(t.Fragment,{children:[t.jsx(ai,{style:{border:"none",background:"transparent"}}),Ce&&t.jsx(ci,{...Ce})]})}),Xe(),Ki]})}):t.jsx("div",{className:C,children:t.jsxs(Ht,{wide:an,style:{minHeight:N,...D},children:[t.jsx(Jn,{breadcrumb:t.jsxs(t.Fragment,{children:[t.jsx(wi,{char:"籍"}),t.jsx(Zn,{items:ln})]}),actions:t.jsxs(t.Fragment,{children:[t.jsx(ai,{}),S&&t.jsx("button",{type:"button",onClick:()=>l("feedback"),className:"bim-d-ui",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("meta-fg")},children:B.detailTab.feedback}),Ce&&t.jsx(ci,{...Ce})]})}),t.jsx(ns,{...Oe,aside:an?t.jsxs("button",{type:"button",onClick:()=>l("basic"),className:"bim-d-ui",style:{background:"none",border:"none",padding:"2px 0",cursor:"pointer",fontFamily:"inherit",fontSize:12,color:i("accent"),borderBottom:`1px solid ${i("rule")}`},children:[O("作品信息")," →"]}):Oe.aside}),!an&&xe.length>1&&t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,margin:"14px 0 0",paddingBottom:2},children:xe.map(J=>t.jsx(is,{label:J.label,active:J.key===s||kt&&J.key==="basic",onClick:()=>l(J.key)},J.key))}),t.jsx("div",{style:{marginTop:!an&&xe.length>1?8:0},children:Ee()}),Ki]})})};function jx({id:e,label:n,copied:o,copyLabel:r}){const[s,l]=g.useState(!1);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[t.jsxs("span",{children:[n," ",e]}),t.jsx("button",{type:"button",onClick:()=>{var d;(d=navigator.clipboard)==null||d.writeText(e).then(()=>{l(!0),setTimeout(()=>l(!1),1500)}).catch(()=>{})},title:s?o:r,"aria-label":s?o:r,className:"bim-d-hit",style:{background:"none",border:"none",padding:0,cursor:"pointer",fontFamily:"inherit",fontSize:14,minWidth:32,minHeight:32,display:"inline-flex",alignItems:"center",justifyContent:"center",color:i("aux-fg")},children:s?"✓":"⧉"})]})}function vx(e,n){return n?e.workSubtype[n]??n:""}const bl=[{name:"zhusha",label:"朱砂"},{name:"indigo",label:"靛藍"}],Cn="zhusha",In="bim-theme";function yl(e){return e==="zhusha"||e==="indigo"}function Tn(e){return yl(e)?e:Cn}function kx(){try{return Tn(window.localStorage.getItem(In))}catch{return Cn}}function jl(e){try{window.localStorage.setItem(In,e)}catch{}}function vl(e){const n=Tn(e);return document.documentElement.setAttribute("data-theme",n),n}function kl(){return Tn(document.documentElement.getAttribute("data-theme"))}const wx=`try{if(localStorage.getItem(${JSON.stringify(In)})==='indigo')document.documentElement.setAttribute('data-theme','indigo')}catch(e){}`,Sx={zhusha:"theme-dot-zhusha",indigo:"theme-dot-indigo"},_x=({onChange:e,style:n})=>{const{convert:o}=Z(),[r,s]=g.useState(Cn);g.useEffect(()=>{s(kl())},[]);const l=d=>{s(vl(d)),jl(d),e==null||e(d)};return t.jsx("div",{role:"radiogroup","aria-label":o("主題"),style:{display:"inline-flex",alignItems:"center",...n},children:bl.map(d=>{const p=r===d.name;return t.jsx("button",{type:"button",role:"radio","aria-checked":p,"aria-label":o(d.label),title:o(d.label),onClick:()=>l(d.name),style:{width:28,height:44,padding:0,border:0,background:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t.jsx("span",{"aria-hidden":"true",style:{width:14,height:14,borderRadius:"50%",boxSizing:"border-box",background:i(Sx[d.name]),boxShadow:p?`0 0 0 2px ${i("page-bg")}, 0 0 0 3.5px ${i("aux-fg")}`:"none"}})},d.name)})})};exports.BidLink=we.BidLink;exports.BookIndexError=we.BookIndexError;exports.BookIndexManager=we.BookIndexManager;exports.BookIndexStorage=we.BookIndexStorage;exports.BundleStorage=we.BundleStorage;exports.ConfigError=we.ConfigError;exports.GithubStorage=we.GithubStorage;exports.IdGenerationError=we.IdGenerationError;exports.IdGenerator=we.IdGenerator;exports.LocalStorage=we.LocalStorage;exports.MigrationError=we.MigrationError;exports.StorageError=we.StorageError;exports.base36Decode=we.base36Decode;exports.base36Encode=we.base36Encode;exports.base58Decode=we.base58Decode;exports.buildId=we.buildId;exports.buildPromotionMap=we.buildPromotionMap;exports.cleanName=we.cleanName;exports.decodeId=we.decodeId;exports.decodeIdString=we.decodeIdString;exports.encodeId=we.encodeId;exports.extractIdFromUrl=we.extractIdFromUrl;exports.extractStatus=we.extractStatus;exports.extractType=we.extractType;exports.normalizeCatalog=we.normalizeCatalog;exports.parseId=we.parseId;exports.shardOf=we.shardOf;exports.smartDecode=we.smartDecode;exports.validateResource=we.validateResource;exports.Badge=bn;exports.BidUrlProvider=Nl;exports.BookDetailLayout=yx;exports.BookFullText=ii;exports.BookPage=sl;exports.Breadcrumb=Zn;exports.CATALOG_ALL_ID=rt;exports.CATALOG_CSS=cl;exports.CATALOG_NARROW_QUERY=Ui;exports.CATALOG_PAGE_SIZE=Vi;exports.CATALOG_UNCLASSIFIED_ID=Kt;exports.CardFoot=en;exports.CatalogPage=hx;exports.CatalogPager=ml;exports.CatalogTree=pl;exports.CheckFilter=es;exports.Chip=os;exports.ChipWall=_c;exports.CollatedEdition=Pi;exports.CollectionCatalog=mi;exports.CollectionPage=ll;exports.CreateEntityDialog=Gs;exports.DEFAULT_READER_PREFS=$i;exports.DEFAULT_THEME=Cn;exports.DETAIL_CSS=ts;exports.Dash=Ec;exports.DataTable=zc;exports.DetailFooter=ps;exports.DetailGrid=Xt;exports.DetailHeader=ns;exports.EmendatedBySection=Ar;exports.EmptyNote=Mc;exports.EntityDetail=Tr;exports.EntityPage=al;exports.EntityPickerDialog=Vs;exports.EntitySelector=Hs;exports.ExpandRow=Rc;exports.ExtLink=Fc;exports.FEEDBACK_FAB_OFFSET_VAR=ri;exports.FONT_SIZE_STEPS=$t;exports.FactList=vc;exports.FeedbackButton=au;exports.FeedbackDialog=Js;exports.FeedbackForm=Zs;exports.FeedbackList=Oi;exports.FeedbackTab=Xs;exports.FilterChip=is;exports.FormInput=Ge;exports.FormTextArea=bt;exports.GUJI_MARKDOWN_FIELD=lc;exports.GUJI_TABLE_NOTATION=ks;exports.GlyphBadge=wi;exports.GujiTable=Ti;exports.HomePage=ni;exports.ImagePanel=hs;exports.IndexApp=xp;exports.IndexBrowser=Un;exports.IndexDetail=gi;exports.IndexEditor=Ys;exports.IndexView=Kp;exports.IntroGrid=jc;exports.LocaleContext=Rt;exports.LocaleProvider=Yl;exports.LocaleToggle=ai;exports.MetaLine=Me;exports.ModeIndicator=zr;exports.MoreButton=Sc;exports.MoreLink=Bt;exports.PAGE_MAX_WIDTH=un;exports.PageFrame=Ht;exports.Quote=Lc;exports.READER_CSS=fs;exports.RECENT_IDS_STORAGE_KEY=Ct;exports.ROLE_CLASS_ORDER=Hr;exports.ReadButton=Kn;exports.ReaderMdText=Li;exports.ReaderShell=Ci;exports.ReaderToc=ms;exports.RelationPanel=Os;exports.RepoSourceLink=ci;exports.ResourceEditor=Gn;exports.ResourceGroup=Bc;exports.ResourceLine=Ac;exports.ResourceList=fi;exports.ResourceRow=cs;exports.SNIPPET_MARK_END=jr;exports.SNIPPET_MARK_START=yr;exports.SearchInput=Cr;exports.Sec=Fe;exports.Section=Ke;exports.SectionHead=kc;exports.SideList=ht;exports.SmartBidInput=xn;exports.SourceEditor=Ms;exports.SummaryCard=Qt;exports.THEMES=bl;exports.THEME_INIT_SCRIPT=wx;exports.THEME_STORAGE_KEY=In;exports.TabFilter=$n;exports.TableHead=Cc;exports.TableRow=Ic;exports.TagRow=ds;exports.TagRows=Wc;exports.TextButton=wc;exports.ThemeToggle=_x;exports.TopStrip=Jn;exports.VersionLineageGraph=rl;exports.VersionLineageList=ol;exports.VersionLineageView=Gi;exports.VolumeChips=$c;exports.VolumeLinks=Si;exports.WorkCard=fl;exports.WorkCardGrid=hl;exports.WorkCatalog=fp;exports.WorkPage=nl;exports.WorkRow=gl;exports.applyTheme=vl;exports.bucketResources=yi;exports.buildCatalogTree=ax;exports.buildCollectionTable=Ur;exports.buildLineageGraph=fn;exports.buildPageUrl=xi;exports.buildParagraphBlocks=Ts;exports.buildVersionRow=Or;exports.buildVersionTable=Dr;exports.canParagraphize=qt;exports.catalogNodeIdOf=sx;exports.catalogNodeIdsOf=lx;exports.catalogPageCount=ux;exports.catalogTotal=Yi;exports.classificationPath=nn;exports.compareCatalogCards=px;exports.computeVersionPartition=ic;exports.currentTheme=kl;exports.defaultWorkLink=ul;exports.deriveDating=ec;exports.deriveEditionType=Yr;exports.deriveEra=Zt;exports.deriveYear=wn;exports.deriveYearRange=bi;exports.detailToEditor=Ks;exports.detectGenre=zn;exports.displayAuthorRole=vi;exports.editorToDetail=qp;exports.eraRank=Yn;exports.findCatalogPath=zt;exports.flattenTitles=Xn;exports.flattenToc=vs;exports.formatTemplate=Jt;exports.formatVolumeRange=_n;exports.getDisplayNameFromUrl=Nt;exports.getStartPage=ui;exports.getTypeGroupKey=di;exports.groupRelatedWorks=tc;exports.gujiInlineToPlain=Zr;exports.hasGujiMarkdownV02=qn;exports.hasGujiTableNotation=ws;exports.isThemeName=yl;exports.measureText=at;exports.mergeVolumeResources=pi;exports.normalizeEra=We;exports.normalizeRole=ji;exports.normalizeTheme=Tn;exports.normalizeVolumeIndex=Ut;exports.normalizeVolumes=$r;exports.numberToChinese=Vr;exports.paginationItems=dl;exports.parseChineseNumber=gn;exports.parseGujiInline=Jr;exports.parseGujiTable=_s;exports.parseSourceString=Fs;exports.pickReaderVersion=js;exports.readStoredTheme=kx;exports.readerVersionOptionLabel=ei;exports.readerVersionsFromFullText=ys;exports.renderFullTextBody=ad;exports.renderProperNames=Rs;exports.renderReaderInline=Ni;exports.resourceHref=Lt;exports.resourceNote=Sn;exports.roleFacets=Gr;exports.rowNo=Tc;exports.sortYear=mn;exports.splitFullTextTables=Ii;exports.splitHighlightSnippet=vr;exports.splitTableRow=Ss;exports.storeTheme=jl;exports.stringifySources=Ps;exports.toCatalogWorkCard=dx;exports.useBidUrl=Pe;exports.useConvert=Z;exports.useReaderPrefs=zi;exports.useT=ue;exports.validateLineageGraph=Iu;exports.volumeStats=yn;
|