book-index-ui 0.32.0 → 0.33.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 +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +2 -2
- package/dist/{storage-entry-E80UAT7b.js → storage-entry-BezDJLqe.js} +45 -40
- package/dist/{storage-entry-le9dwVgw.cjs → storage-entry-DPsx0DgD.cjs} +2 -2
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.ts +2 -0
- package/dist/storage.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ha=Object.create;var $r=Object.defineProperty;var Ga=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var Va=Object.getPrototypeOf,Ya=Object.prototype.hasOwnProperty;var Ka=(t,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Ua(n))!Ya.call(t,s)&&s!==r&&$r(t,s,{get:()=>n[s],enumerable:!(o=Ga(n,s))||o.enumerable});return t};var pn=(t,n,r)=>(r=t!=null?Ha(Va(t)):{},Ka(n||!t||!t.__esModule?$r(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const be=require("./storage-entry-le9dwVgw.cjs"),e=require("react/jsx-runtime"),h=require("react"),qa=require("opencc-js/t2cn"),Ja=require("react-markdown"),Za=require("remark-gfm"),Xa=t=>`/book-index?id=${t}`,qo=h.createContext(Xa);function Qa({buildUrl:t,children:n}){const r=h.useMemo(()=>t,[t]);return e.jsx(qo.Provider,{value:r,children:n})}function He(){return h.useContext(qo)}const Jo="",Zo="";function Ti(t){const n=[];let r=!1,o=t;for(;o.length;){const s=r?Zo:Jo,l=o.indexOf(s);if(l===-1){n.push({text:o,marked:r});break}l>0&&n.push({text:o.slice(0,l),marked:r}),o=o.slice(l+1),r=!r}return n}function Ke(t,n){return{title:t,tokens:n}}const _r='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',ec=[Ke("基础(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"}}),Ke("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),Ke("提示与警告",{"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)"}}),Ke("遮罩与阴影",{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)"}}),Ke("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),Ke("资源",{"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"}}),Ke("整理本(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"}}),Ke("版本传承(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"}}),Ke("编辑器视图(主要在 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")'}}),Ke("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#222221",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}}),Ke('版式(v4 外观系统,overview#291):疏朗=留白分区(默认,下列值即疏朗);界栏=框线分区(`<html data-layout="boxed">`)',{"fr-bd":{value:"0 solid transparent",note:"区块外框(border 简写)。疏朗无框;界栏 1px 实线"},"fr-bg":{value:"transparent",note:"区块底。界栏=卡面色"},"fr-hd-pad":{value:"14px 18px",note:"区块标题栏内边距。10-01 起疏朗也有淡染底的标题栏(--bim-fr-hd-bg),故疏朗 14px 18px,界栏 12px 18px"},"fr-hd-bd":{value:"0 solid transparent",note:"区块标题栏下沿线(border 简写)"},"fr-bd-pad":{value:"0",note:"区块正文内边距"},"fr-gap":{value:"56px",note:"区块之间的间距。界栏收紧到 24px(框线本身已分隔)"},"fr-side-gap":{value:"34px",note:"侧栏各块之间的间距;界栏 20px"},"fr-shadow":{value:"0 1px 0 var(--bim-rule), 0 12px 32px -18px rgba(40, 36, 31, 0.25)",note:"抬起的面(提要卡)的投影;界栏不用投影,靠框线"},"fr-tab-bd":{value:"transparent",note:"页签行下沿线颜色(疏朗不画,界栏画)"},"fr-hd-size":{value:"24px",note:"分区标题字号。界栏标题在框顶标题栏里,小一档 19px"},"fr-hd-bg":{value:"color-mix(in srgb, var(--bim-accent) 7%, var(--bim-page-bg))",note:"分区标题栏底色(淡染主色)。疏朗混进页面底,界栏 6% 混进卡面底。主色取 accent(primary 是 VS Code 按钮蓝,不随配色)"},"fr-card-bd":{value:"1px solid transparent",note:"卡片边框。疏朗不画(靠卡面底与淡投影);界栏 1px"},"fr-card-bg":{value:"var(--bim-card-bg)",note:"卡片底"},"fr-row-bd":{value:"1px solid transparent",note:"列表行线、块内小分割线。疏朗不画(靠行距);界栏 1px"},"fr-row-pad":{value:"10px 2px",note:"列表行内边距。界栏收紧 7px 2px"},"fr-chrome-bd":{value:"1px solid transparent",note:"顶栏、分区导航(吸顶锚点条)的线"},"fr-tag-bd":{value:"1px solid transparent",note:"标签、版本签、计数签、工具按钮的边框。疏朗浅底无框;界栏透明底加框"},"fr-tag-bg":{value:"var(--bim-tint-bg)",note:"标签底"},"fr-tbl-cell-bd":{value:"0 solid transparent",note:"表格格线。疏朗不画(靠斑马纹);界栏全格线"},"fr-tbl-zebra":{value:"var(--bim-tint-bg)",note:"表格斑马纹(只在疏朗下有)"},"fr-rail-bd":{value:"1px solid transparent",note:"侧栏里的块、提示块的边框"},"fr-rail-bg":{value:"var(--bim-tint-bg)",note:"侧栏块底。疏朗浅底;界栏卡面底"},"fr-spine-bd":{value:"1px solid transparent",note:"题签、书脊(竖排书名)的边框。界栏是强调色浅线"},"fr-spine-bg":{value:"var(--bim-flag-bg)",note:"题签、书脊底。疏朗浅色实底;界栏卡面底(正史原志两种版式都是强调色实底)"},"fr-plank":{value:"0 solid transparent",note:"书架架板(border 简写)。只在界栏下画 3px"},"fr-axis-bd":{value:"0 solid transparent",note:"时间轴轴线。界栏 1px"},"fr-axis-band":{value:"6px",note:"时间轴底带高度。疏朗用 6px 浅色带代替轴线;界栏 0"},"fr-tick":{value:"0",note:"时间轴刻度短线长度。界栏 5px"},"fr-band-gap":{value:"3px",note:"年代带各段之间的空隙。疏朗 3px;界栏紧贴"},"fr-band-bd":{value:"0 solid transparent",note:"年代带外框与段间分隔。界栏 1px"}}),Ke("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"}}),Ke("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),Ke("字体(全站无衬线,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:_r,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:_r,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],tc=Object.assign({},...ec.map(t=>t.tokens)),Xo={};for(const[t,n]of Object.entries(tc))Xo[t]=`var(--bim-${t}, ${n.value})`;function i(t){const n=Xo[t];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${t}`);return n}function _t(t){return t.types&&t.types.length>0?t.types:t.type?t.type==="text+image"?["text","image"]:[t.type]:[]}function nc(t,n){return _t(t).includes(n)}const li={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"},ic={published:"達到出版、學術研究標準,錯誤率在萬分之一以內",fine:"通讀無障礙,錯誤率在百分之一以內",rough:"保證文意基本正確,錯誤率在百分之三以內",ocr:"保持大意和結構,錯誤率在百分之十以內"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Bt=h.createContext(null),Qo={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("check-ai-fg")}},action:{save:"保存",delete:"刪除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"訪問 →",view:"查看 →",viewEntity:"查看",copy:"複製 ID",copied:"已複製",linkExisting:"+ 關聯現有",createAndLink:"+ 創建並關聯",remove:"刪除",clearAll:"清除全部",reselect:"重選",changeType:"更換類型",expand:"展開",collapse:"收起",expandMore:"展開更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加書籍",addSubCollection:"添加子叢編",addCollectionImpl:"添加叢編實現",addSource:"添加來源",addResource:"添加資源",addIndexedBy:"+ 添加收錄來源",addEmendatedBy:"+ 添加考證來源",addAdditionalWork:"+ 添加附屬作品",selectBookOrWork:"選擇書籍/作品",clickToSelectBookOrWork:"點擊選擇書籍/作品",unlink:"解除關聯"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷數",pageCount:"頁數 (Pages)",volumeCount:"冊數 (Volumes)",holder:"現藏於 (Holder)",firstImage:"首頁圖片 (First Image URL)",year:"年代",currentLocation:"現藏",parentWork:"上級作品",relatedWorks:"相關作品",type:"類型",rootType:"根類型",coverageLevel:"覆蓋層級",coverageRange:"覆蓋範圍",metadata:"元數據",optionalInfo:"可選信息",details:"詳細說明",detailsOptional:"詳細說明 (可選)",positionOptional:"位置/頁碼 (可選)",dataVersionOptional:"數據版本 (可選)",processorVersionOptional:"處理器版本 (可選)",sourceName:"來源名稱",sourceBid:"來源 BID",titleInfo:"題名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介紹 (Description)",additionalWorks:"📑 附屬作品 (Additional Works)",indexedBy:"📖 著錄於",emendatedBy:"📝 考證",resources:"資源",textResources:"📝 文字資源 (Text Resources)",imageResources:"🖼️ 圖片資源 (Image Resources)",sources:"📚 資料來源 (Sources)",provenance:"📜 收藏歷史 (Provenance)",relatedVersions:"相關版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危險區域 (Danger Zone)",aliases:"別名",attachedTexts:"附載篇目",appendix:"附錄",containedIn:"收入叢編",collectedIn:"收入叢編",belongsToWork:"所屬作品",locationHistory:"流轉歷史",historyOverview:"歷史沿革",containedBooks:"收錄書籍",relations:"關聯關係",summary:"提要",comment:"按語",additionalComment:"附按",indexed:"收錄於",emendated:"考證",relatedWorks:"相關作品",containedWorks:"包含作品",adaptations:"改編作品",derivativeWorks:"續書與評註",studies:"所考典籍"},relation:{belongsToWork:"所屬作品 (Work)",containedInCollection:"收入叢編",siblingVersions:"同作品其他版本",addVersionForWork:"為此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"叢編實現",allVersions:"所有版本",correspondingWork:"對應作品 (Work)",parentCollection:"父叢編 (Parent Collection)",childCollections:"子叢編",containedBooks:"包含書籍",notLinked:"(未關聯)",none:"(暫無)"},search:{placeholder:"搜索作品、書籍、叢編...",searching:"搜索中...",loading:"加載中...",noResults:"無匹配結果",noResultsFor:"未找到與「{query}」相關的結果",tryOther:"試試其他關鍵詞、別名或作者名",recentBrowse:"最近瀏覽",history:"搜索歷史",clearAll:"清除全部",clearRecent:"清除最近瀏覽",itemNotFound:"無法找到,可能已刪除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"結果分類",searchSubtitle:"輸入關鍵詞搜索作品、書籍或叢編",searchBookName:"搜索書名...",alias:"別名"},searchV4:{filterTitle:"篩選",dynasty:"朝代",classification:"部類",resources:"資源",extant:"存佚",clearAllFilters:"清除全部篩選",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"篩選",filterSelected:"{n} 項已選",expand:"展開",collapse:"收起",filteredCount:"篩出 {n} 條",removeFilter:"取消篩選:{name}",viewLabel:"結果視圖",viewTable:"表格",viewCard:"卡片",colTitle:"題名",colType:"類型",colAuthor:"責任者",colEra:"年代",colClass:"部類",colResource:"資源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 條 · 每頁 {size} 條 · 第 {page} / {pages} 頁",pagerLabel:"翻頁",prevPage:"上一頁",nextPage:"下一頁",emptyFiltered:"沒有找到匹配的條目。試試更短的書名、減少篩選,或切換繁 / 簡。",limitedNote:"各類只列前幾條,點上方分類頁籤看全部。",sortLabel:"排序",sortRelevance:"相關度",sortEra:"年代",sortTitle:"書名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A",onlyWorksNote:"部類、存佚只適用於作品;選了它們,版本、叢編、人物不參與。"},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:"圖片資源"}},rc={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("check-ai-fg")}},action:{save:"保存",delete:"删除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"访问 →",view:"查看 →",viewEntity:"查看",copy:"复制 ID",copied:"已复制",linkExisting:"+ 关联现有",createAndLink:"+ 创建并关联",remove:"删除",clearAll:"清除全部",reselect:"重选",changeType:"更换类型",expand:"展开",collapse:"收起",expandMore:"展开更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加书籍",addSubCollection:"添加子丛编",addCollectionImpl:"添加丛编实现",addSource:"添加来源",addResource:"添加资源",addIndexedBy:"+ 添加收录来源",addEmendatedBy:"+ 添加考证来源",addAdditionalWork:"+ 添加附属作品",selectBookOrWork:"选择书籍/作品",clickToSelectBookOrWork:"点击选择书籍/作品",unlink:"解除关联"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷数",pageCount:"页数 (Pages)",volumeCount:"册数 (Volumes)",holder:"现藏于 (Holder)",firstImage:"首页图片 (First Image URL)",year:"年代",currentLocation:"现藏",parentWork:"上级作品",relatedWorks:"相关作品",type:"类型",rootType:"根类型",coverageLevel:"覆盖层级",coverageRange:"覆盖范围",metadata:"元数据",optionalInfo:"可选信息",details:"详细说明",detailsOptional:"详细说明 (可选)",positionOptional:"位置/页码 (可选)",dataVersionOptional:"数据版本 (可选)",processorVersionOptional:"处理器版本 (可选)",sourceName:"来源名称",sourceBid:"来源 BID",titleInfo:"题名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介绍 (Description)",additionalWorks:"📑 附属作品 (Additional Works)",indexedBy:"📖 著录于",emendatedBy:"📝 考证",resources:"资源",textResources:"📝 文字资源 (Text Resources)",imageResources:"🖼️ 图片资源 (Image Resources)",sources:"📚 资料来源 (Sources)",provenance:"📜 收藏历史 (Provenance)",relatedVersions:"相关版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危险区域 (Danger Zone)",aliases:"别名",attachedTexts:"附载篇目",appendix:"附录",containedIn:"收入丛编",collectedIn:"收入丛编",belongsToWork:"所属作品",locationHistory:"流转历史",historyOverview:"历史沿革",containedBooks:"收录书籍",relations:"关联关系",summary:"提要",comment:"按语",additionalComment:"附按",indexed:"收录于",emendated:"考证",relatedWorks:"相关作品",containedWorks:"包含作品",adaptations:"改编作品",derivativeWorks:"续书与评注",studies:"所考典籍"},relation:{belongsToWork:"所属作品 (Work)",containedInCollection:"收入丛编",siblingVersions:"同作品其他版本",addVersionForWork:"为此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"丛编实现",allVersions:"所有版本",correspondingWork:"对应作品 (Work)",parentCollection:"父丛编 (Parent Collection)",childCollections:"子丛编",containedBooks:"包含书籍",notLinked:"(未关联)",none:"(暂无)"},search:{placeholder:"搜索作品、书籍、丛编...",searching:"搜索中...",loading:"加载中...",noResults:"无匹配结果",noResultsFor:"未找到与「{query}」相关的结果",tryOther:"试试其他关键词、别名或作者名",recentBrowse:"最近浏览",history:"搜索历史",clearAll:"清除全部",clearRecent:"清除最近浏览",itemNotFound:"无法找到,可能已删除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"结果分类",searchSubtitle:"输入关键词搜索作品、书籍或丛编",searchBookName:"搜索书名...",alias:"别名"},searchV4:{filterTitle:"筛选",dynasty:"朝代",classification:"部类",resources:"资源",extant:"存佚",clearAllFilters:"清除全部筛选",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"筛选",filterSelected:"{n} 项已选",expand:"展开",collapse:"收起",filteredCount:"筛出 {n} 条",removeFilter:"取消筛选:{name}",viewLabel:"结果视图",viewTable:"表格",viewCard:"卡片",colTitle:"题名",colType:"类型",colAuthor:"责任者",colEra:"年代",colClass:"部类",colResource:"资源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 条 · 每页 {size} 条 · 第 {page} / {pages} 页",pagerLabel:"翻页",prevPage:"上一页",nextPage:"下一页",emptyFiltered:"没有找到匹配的条目。试试更短的书名、减少筛选,或切换繁 / 简。",limitedNote:"各类只列前几条,点上方分类页签看全部。",sortLabel:"排序",sortRelevance:"相关度",sortEra:"年代",sortTitle:"书名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A",onlyWorksNote:"部类、存佚只适用于作品;选了它们,版本、丛编、人物不参与。"},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:"图片资源"}},oc=["曹霑"];function sc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lc(t,n=oc){const r=[...new Set(n.filter(Boolean))].sort((l,a)=>a.length-l.length);if(!r.length)return t;const o=new RegExp(`(${r.map(sc).join("|")})`,"g"),s=new Set(r);return l=>{if(!l)return t(l);const a=l.split(o);return a.length===1?t(l):a.map((p,c)=>c%2===1&&s.has(p)?p:p&&t(p)).join("")}}let Pt=null;function ac(){if(Pt)return Pt;try{Pt=lc(qa.Converter({from:"tw",to:"cn"}))}catch{Pt=t=>t}return Pt}const cc={"zh-Hant":Qo,"zh-Hans":rc},es="bim-locale";function dc(){try{const t=localStorage.getItem(es);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function pc(t){try{localStorage.setItem(es,t)}catch{}}const uc="zh-Hans",mc=({locale:t,onLocaleChange:n,converter:r,children:o})=>{const[s,l]=h.useState(t??uc),a=t??s;h.useEffect(()=>{if(t)return;const u=dc();u&&u!==s&&l(u)},[]);const p=h.useMemo(()=>a==="zh-Hans"?r??ac():null,[a,r]),c=h.useCallback(u=>{l(u),pc(u),n==null||n(u)},[n]),d=h.useMemo(()=>({locale:a,setLocale:c,messages:cc[a],converter:p}),[a,c,p]);return e.jsx(Bt.Provider,{value:d,children:o})};function fe(){const t=h.useContext(Bt);return(t==null?void 0:t.messages)??Qo}const xc=2e3;function O(){const t=h.useContext(Bt),n=(t==null?void 0:t.locale)??"zh-Hant",r=(t==null?void 0:t.converter)??null,o=h.useRef(new Map),s=h.useRef(n);s.current!==n&&(o.current.clear(),s.current=n);const l=h.useCallback(a=>{if(!a)return"";if(!r)return a;const p=o.current.get(a);if(p!==void 0)return p;const c=r(a);if(o.current.size>=xc){const d=o.current.keys().next().value;d!==void 0&&o.current.delete(d)}return o.current.set(a,c),c},[r]);return h.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function nt(t,n){return t.replace(/\{(\w+)\}/g,(r,o)=>String(n[o]??""))}function hc(t){if(!t)return"";try{const n=new URL(t).hostname,r={"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(r[n])return r[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function gc(){return{id:"",name:"",url:"",type:"text",details:""}}const ai=({items:t,onChange:n,onDownload:r,downloadStatuses:o,filterType:s})=>{const l=fe(),[a,p]=h.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=f=>{if(!s)return!0;const v=_t(f);return s==="text"?v.includes("text"):s==="image"?v.includes("image")||v.includes("physical"):s==="physical"?v.includes("physical"):v.includes(s)},x=t.map((f,v)=>({item:f,originalIndex:v})).filter(({item:f})=>u(f)),m=()=>{const f=gc();s&&(f.type=s),n([...t,f]),p(t.length)},g=f=>{n(t.filter((v,$)=>$!==f)),p(null)},b=(f,v,$)=>{const w=[...t];if(w[f]={...w[f],[v]:$},v==="url"&&!w[f].id){const _=hc($);_&&(w[f].id=_)}n(w)},k=(f,v,$)=>{const _={...t[f].metadata||{}};$?_[v]=$:delete _[v],b(f,"metadata",Object.keys(_).length>0?_:void 0)},y=(f,v)=>{const $=v.trim()?v.split(/[,,、]/).map(w=>w.trim()).filter(Boolean):void 0;b(f,"structure",$)},j=(f,v,$)=>{const _=t[f].coverage||{level:1,ranges:""};v==="level"?_.level=parseInt($)||1:_.ranges=$,b(f,"coverage",_.ranges?_:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[x.map(({item:f,originalIndex:v})=>{var $,w,_;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(a===v?null:v),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:a===v?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:fc(f.type??"text"),color:i("on-color-fg")},children:(()=>{var z,E;const S=_t(f);return S.length===0?f.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")?((E=c.find(T=>T.value==="text+image"))==null?void 0:E.label)??"text+image":S.join("+")})()}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:f.name||`${l.editor.resourcePlaceholder} ${v+1}`}),f.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:f.id}),f.url&&e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",onClick:S=>S.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),r&&f.url&&bc(v,o==null?void 0:o[v],r,l),e.jsx("button",{onClick:S=>{S.stopPropagation(),g(v)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),a===v&&e.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[nc(f,"image")&&f.url&&yc(f,l),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:Dt,children:[e.jsx("span",{style:Ht,children:l.label.type}),e.jsx("select",{value:f.type,onChange:S=>b(v,"type",S.target.value),style:{...rt,flex:1},children:c.map(S=>e.jsx("option",{value:S.value,children:S.label},S.value))})]}),e.jsxs("label",{style:Dt,children:[e.jsx("span",{style:Ht,children:l.label.rootType}),e.jsx("select",{value:f.root_type||"catalog",onChange:S=>b(v,"root_type",S.target.value),style:{...rt,flex:1},children:d.map(S=>e.jsx("option",{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:f.id,onChange:S=>b(v,"id",S.target.value),placeholder:l.editor.idAutoExtract,style:{...rt,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:f.name,onChange:S=>b(v,"name",S.target.value),placeholder:l.editor.resourceName,style:{...rt,flex:1}})]}),e.jsx("input",{type:"text",value:f.url,onChange:S=>b(v,"url",S.target.value),placeholder:l.editor.resourceUrl,style:rt}),e.jsx("input",{type:"text",value:(($=f.structure)==null?void 0:$.join("、"))||"",onChange:S=>y(v,S.target.value),placeholder:l.editor.structurePlaceholder,style:rt}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:Dt,children:[e.jsx("span",{style:Ht,children:l.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((w=f.coverage)==null?void 0:w.level)??"",onChange:S=>j(v,"level",S.target.value),placeholder:"1",style:{...rt,width:"60px"}})]}),e.jsxs("label",{style:{...Dt,flex:1},children:[e.jsx("span",{style:Ht,children:l.label.coverageRange}),e.jsx("input",{type:"text",value:((_=f.coverage)==null?void 0:_.ranges)||"",onChange:S=>j(v,"ranges",S.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...rt,flex:1}})]})]}),e.jsx("textarea",{value:f.details||"",onChange:S=>b(v,"details",S.target.value),placeholder:l.editor.detailsPlaceholder,style:{...rt,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:l.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([S,z])=>{var E;return e.jsxs("label",{style:{...Dt,gap:"4px"},children:[e.jsx("span",{style:{...Ht,minWidth:"56px"},children:z}),e.jsx("input",{type:"text",value:((E=f.metadata)==null?void 0:E[S])||"",onChange:T=>k(v,S,T.target.value),placeholder:z,style:{...rt,flex:1}})]},S)})})]})]})]})]},v)}),e.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:l.action.addResource})]})]})};function fc(t){switch(t){case"text":return i("restype-text");case"image":return i("restype-image");case"text+image":return i("restype-text-image");case"physical":return i("restype-physical")}}function bc(t,n,r,o){const s=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return e.jsx("button",{onClick:a=>{a.stopPropagation(),s||r(t,"")},disabled:s,style:{background:"transparent",border:"none",color:i(l?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:l?o.download.completed:s?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:l?"✓":s?"⏳":"⬇"})}function yc(t,n){const r=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(t.url)||t.url.includes("iiif")||t.url.includes("image");return e.jsx("div",{style:{marginBottom:"12px"},children:r?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:e.jsx("img",{src:t.url,alt:t.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const rt={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"},Dt={display:"flex",alignItems:"center",gap:"6px"},Ht={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},jc={"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 Mt(t){try{return jc[new URL(t).hostname]}catch{return}}const zr={text:0,image:1,physical:2};function Ni(t){return t.length===0?"physical":[...t].sort((n,r)=>(zr[n]??99)-(zr[r]??99)).join("+")}function Ii(t){var a;const n=p=>{const c=p.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const d=p.match(/^(.+?)[·(](\d+)[)]?$/);return d?[d[1],parseInt(d[2])]:null},r=new Map;for(let p=0;p<t.length;p++){const c=t[p];if(c.volumes&&c.volumes.length>0)continue;const d=n(c.name);if(!d)continue;const[u,x]=d,m=`${u}|${Ni(_t(c))}`;r.has(m)||r.set(m,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const g=r.get(m);g.volumes.push({volume:x,url:c.url||void 0,status:"found"}),g.indices.push(p)}const o=[],s=new Set;for(const p of r.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)??""),o.push(p.base);for(const c of p.indices)s.add(c)}const l=[...o];for(let p=0;p<t.length;p++)s.has(p)||l.push(t[p]);return l}function ts(t){if(t.url)return t.url;for(const[n,r]of Object.entries(t))if(n.endsWith("_url")&&typeof r=="string")return r}function ns(t){return!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(n=>({...n,url:n.url||ts(n)}))}function _n(t){const n=ns(t);if(!n)return null;const r=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,o=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:r,missing:o,expected:t.expected_volumes??r+o}}function Ei(t){if(!t)return;const n=t.file_page_range||t.page_range;if(!n||typeof n!="string")return;const r=n.match(/^(\d+)/);return r?parseInt(r[1],10):void 0}function Ri(t,n){try{if(new URL(t).hostname.includes("wikimedia.org")){const o=t.match(/\/wiki\/File:(.+?)(?:#|$)/);if(o)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(o[1]))}&page=${n}`;const s=new URL(t);return s.searchParams.set("page",String(n)),s.toString()}return t}catch{return t}}function Wt(t){if(!t.url)return;const n=Ei(t.metadata);return n?Ri(t.url,n):t.url}const Cr={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function vc(t){return t.includes("text")&&t.includes("image")?Cr["text+image"]:Cr[t[0]||"physical"]}const Li=({items:t,groupByType:n=!0,resourceGroups:r,onNavigate:o,renderLink:s})=>{const l=fe(),{convert:a}=O(),p=h.useMemo(()=>Ii(t||[]),[t]),{mirrorGroups:c,ungroupedItems:d}=h.useMemo(()=>{const y=new Map,j=[];for(const f of p){const v=f.group;v?(y.has(v)||y.set(v,[]),y.get(v).push(f)):j.push(f)}for(const f of y.values())f.sort((v,$)=>{const w=_=>_.group_role==="origin"?0:_.group_role==="mirror"?1:2;return w(v)-w($)});return{mirrorGroups:y,ungroupedItems:j}},[p]),u={text:l.resourceType.text,image:l.resourceType.image,"text+image":l.resourceType.textImage,physical:l.resourceType.physical},x=y=>u[y]?u[y]:y.split("+").map(j=>u[j]||j).join("+");if(!p||p.length===0)return e.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:l.misc.noResources});if(!n)return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:p.map((y,j)=>e.jsx(Un,{item:y},y.id||j))});const m=(y,j)=>{const f=r==null?void 0:r[y],v=(f==null?void 0:f.label)||y,$=f==null?void 0:f.description;return e.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(v)}),$&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:a($)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:j.map((w,_)=>e.jsx(Un,{item:w,onNavigate:o,renderLink:s},w.id||_))})]},`group-${y}`)},g=new Map;for(const y of d){const j=Ni(_t(y));g.has(j)||g.set(j,[]),g.get(j).push(y)}const b=["text","image","text+image","physical"],k=[...b.filter(y=>g.has(y)),...[...g.keys()].filter(y=>!b.includes(y)).sort()];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,j])=>m(y,j)),k.map(y=>{const j=g.get(y),f=vc(y.split("+"));return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:f,whiteSpace:"nowrap",flexShrink:0},children:x(y)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:j.map((v,$)=>e.jsx(Un,{item:v,onNavigate:o,renderLink:s},v.id||$))})]},y)})]})},kc={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Un=({item:t})=>{const n=fe(),{convert:r}=O(),[o,s]=h.useState(!1),l=h.useMemo(()=>(t.url?Mt(t.url):void 0)||r(t.name),[t.url,t.name,r]),a=h.useMemo(()=>!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(b=>({...b,url:b.url||ts(b)})),[t.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=t.expected_volumes??(p?c+d:0),x=t.color_mode?{...kc[t.color_mode],label:n.colorMode[t.color_mode]}:null,m=t.details&&!p?r(t.details):null,g={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",background:i("input-bg"),fontSize:"12px",color:i("fg"),lineHeight:1.4,verticalAlign:"middle"};return e.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[e.jsxs("div",{style:g,children:[e.jsx("span",{style:{fontWeight:500},children:l}),x&&e.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:x.bg,color:x.fg},children:x.label}),m&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:m}),p&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,d>0&&e.jsxs("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:["缺",d]})]}),t.url&&e.jsx("a",{href:(()=>{const b=Ei(t.metadata);return b?Ri(t.url,b):t.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),p&&e.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),p&&o&&e.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:a.map(b=>{const k=b.status==="missing";return b.url&&!k?e.jsx("a",{href:b.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:b.volume},b.volume):e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(k?"missing-fg":"desc-fg"),textDecoration:k?"line-through":"none",opacity:k?.6:1},children:b.volume},b.volume)})})]})},is=({indexSource:t,syncConfig:n,variant:r="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:l,onSelectFolder:a})=>{const p=fe(),c=t==="local",d=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",x=u?u.split(/[/\\]/).pop()||u:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},g={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},b=e.jsxs("div",{onClick:s,title:d?p.mode.switchToOfficial:p.mode.switchToDraft,style:{...m,background:i(d?"warning":"success"),color:i("on-color-fg")},...g,children:[e.jsx("span",{children:d?"📝":"📚"}),e.jsx("span",{children:d?"draft":"official"})]});return r==="index-browser"?c?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[b,e.jsxs("div",{onClick:o,title:p.mode.switchToSync,style:m,...g,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:p.mode.localMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...g,children:[e.jsx("span",{children:"📂"}),x&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:x})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[b,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:o,title:p.mode.switchToLocal,style:m,...g,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:p.mode.syncMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:l,title:x||p.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...g,children:e.jsx("span",{children:"⚙️"})})]})]}):e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsxs("div",{onClick:o,title:c?p.mode.switchToGithub:p.mode.switchToLocal,style:m,...g,children:[e.jsx("span",{children:c?"📁":"🌐"}),e.jsx("span",{children:c?p.mode.localMode:p.mode.githubSync}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...g,children:[e.jsx("span",{children:"📂"}),x&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:x})]}),!c&&x&&e.jsxs("div",{style:{...m,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:x})]})]})},zn="bim-search-history",Tr=10,Nr=8;function Zt(){try{const t=localStorage.getItem(zn);return t?JSON.parse(t):[]}catch{return[]}}function wc(t){try{const n=Zt().filter(r=>r!==t);n.unshift(t),n.length>Tr&&(n.length=Tr),localStorage.setItem(zn,JSON.stringify(n))}catch{}}function Sc(t){try{const n=Zt().filter(r=>r!==t);localStorage.setItem(zn,JSON.stringify(n))}catch{}}function $c(){try{localStorage.removeItem(zn)}catch{}}const rs=({transport:t,value:n,onChange:r,onSearch:o,onEntrySelect:s,placeholder:l})=>{const a=fe(),p=l??a.search.placeholder,c={work:a.indexType.work,book:a.indexType.book,collection:a.indexType.collection,entity:a.indexType.entity},[d,u]=h.useState(!1),[x,m]=h.useState([]),[g,b]=h.useState(-1),[k,y]=h.useState(Zt),j=h.useRef(null),f=h.useRef(null),v=h.useRef(null),$=h.useRef(!1);h.useEffect(()=>{b(-1);const N=n.trim();if(!N){m(k.map(B=>({type:"history",text:B})));return}if(!t.searchAll){m([]);return}let V=!1;const W=setTimeout(()=>{t.searchAll(N,Nr).then(B=>{if(V)return;const H=[...B.works,...B.books,...B.collections,...B.entities??[]];m(H.slice(0,Nr).map(te=>({type:"entry",text:te.title||te.id,entry:te})))}).catch(()=>{V||m([])})},80);return()=>{V=!0,clearTimeout(W)}},[n,k,t]),h.useEffect(()=>{const N=V=>{v.current&&!v.current.contains(V.target)&&u(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),h.useEffect(()=>{const N=V=>{var W,B;if(V.key==="/"&&document.activeElement!==j.current){const H=(W=document.activeElement)==null?void 0:W.tagName;if(H==="INPUT"||H==="TEXTAREA"||H==="SELECT")return;V.preventDefault(),(B=j.current)==null||B.focus()}};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[]);const w=h.useCallback(N=>{N.trim()&&(wc(N.trim()),y(Zt())),o(N),u(!1)},[o]),_=h.useCallback(N=>{N.type==="history"?(r(N.text),w(N.text)):N.entry&&(s?(s(N.entry),u(!1)):(r(N.text),w(N.text)))},[r,w,s]),S=h.useCallback(N=>{if(!d||x.length===0){N.key==="Enter"&&w(n);return}switch(N.key){case"ArrowDown":N.preventDefault(),b(V=>(V+1)%x.length);break;case"ArrowUp":N.preventDefault(),b(V=>(V-1+x.length)%x.length);break;case"Enter":N.preventDefault(),g>=0&&g<x.length?_(x[g]):w(n);break;case"Escape":N.preventDefault(),u(!1);break}},[d,x,g,n,w,_]),z=h.useCallback((N,V)=>{V.stopPropagation(),Sc(N),y(Zt()),m(W=>W.filter(B=>!(B.type==="history"&&B.text===N)))},[]),E=h.useCallback(N=>{N.stopPropagation(),$c(),y([]),m([])},[]);h.useEffect(()=>{if(g>=0&&f.current){const N=f.current.children;N[g]&&N[g].scrollIntoView({block:"nearest"})}},[g]);const T=!n.trim()&&k.length>0;return e.jsxs("div",{ref:v,style:{position:"relative",flex:1},children:[e.jsx("input",{ref:j,type:"text",placeholder:p,value:n,onChange:N=>{r(N.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"}}),d&&x.length>0&&e.jsxs("div",{ref:f,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&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:i("desc-fg"),borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("span",{children:a.search.history}),e.jsx("button",{onClick:E,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:a.search.clearAll})]}),x.map((N,V)=>e.jsxs("div",{onClick:()=>_(N),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:V===g?i("list-active-bg"):"transparent"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:N.type==="history"?"🕐":"🔍"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.text}),N.entry&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[N.entry.type],N.entry.edition&&` · ${N.entry.edition}`,N.entry.author&&` · ${N.entry.author}`]}),N.type==="history"&&e.jsx("button",{onClick:W=>z(N.text,W),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:a.action.remove,children:"×"})]},`${N.type}-${N.text}-${V}`))]})]})},Ot=({type:t,size:n=9})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${t}`),verticalAlign:"middle"}}),Cn={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},os=new Set(["work","book","entity"]);function _c(t){return ls(t)||!!t.sort}function zc(t,n){return n.sort&&os.has(t)?n.sort:void 0}const Tn=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Nn=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Ai=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],ss={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function In(t){return t.dynasty.length+t.classification.length+(t.hasImage?1:0)+(t.hasText?1:0)+(t.hasCollated?1:0)+(t.loss?1:0)}function ls(t){return In(t)>0}function Cc(t){const n=[];return t.dynasty.length&&n.push("dynasty"),t.classification.length&&n.push("classification"),t.hasImage&&n.push("hasImage"),t.hasText&&n.push("hasText"),t.hasCollated&&n.push("hasCollated"),t.loss&&n.push("loss"),n}function as(t,n){const r=ss[t];return Cc(n).every(o=>r.has(o))}const Gt=t=>JSON.stringify(t);function Tc(t,n){if(!as(n,t))return null;const r=[];if(t.dynasty.length){const o=Array.from(new Set(t.dynasty.flatMap(s=>{var l;return((l=Tn.find(a=>a.key===s))==null?void 0:l.values)??[]})));o.length===1?r.push(`dynasty = ${Gt(o[0])}`):o.length>1&&r.push(`dynasty IN [${o.map(Gt).join(", ")}]`)}return t.classification.length&&r.push(t.classification.length===1?`classification = ${Gt(t.classification[0])}`:`classification IN [${t.classification.map(Gt).join(", ")}]`),t.hasImage&&r.push("has_image = true"),t.hasText&&r.push("has_text = true"),t.hasCollated&&r.push("has_collated = true"),t.loss&&r.push(`loss_status = ${Gt(t.loss)}`),r.join(" AND ")}const Ye={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},cs="_";function yn(t,n=new URLSearchParams){for(const r of Object.values(Ye))n.delete(r);return t.dynasty.length&&n.set(Ye.dynasty,t.dynasty.join(",")),t.classification.length&&n.set(Ye.classification,t.classification.map(r=>r||cs).join(",")),t.hasImage&&n.set(Ye.hasImage,"1"),t.hasText&&n.set(Ye.hasText,"1"),t.hasCollated&&n.set(Ye.hasCollated,"1"),t.loss&&n.set(Ye.loss,t.loss),t.sort&&n.set(Ye.sort,t.sort),n}function Nc(t){const n=l=>(t.get(l)??"").split(",").map(a=>a.trim()).filter(Boolean),r=new Set(Tn.map(l=>l.key)),o=new Set(Nn.map(l=>l.value)),s=t.get(Ye.loss);return{dynasty:Array.from(new Set(n(Ye.dynasty).filter(l=>r.has(l)))),classification:Array.from(new Set(n(Ye.classification).map(l=>l===cs?"":l).filter(l=>o.has(l)))),hasImage:t.get(Ye.hasImage)==="1",hasText:t.get(Ye.hasText)==="1"||t.get(Ye.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(l=>l===t.get(Ye.sort))??""}}function Ic(t,n){return JSON.stringify([t.dynasty.slice().sort(),t.classification.slice().sort(),t.hasImage,t.hasText,t.hasCollated,t.loss,t.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Ir(t,n){return t.includes(n)?t.filter(r=>r!==n):[...t,n]}const Ec=({filters:t,onChange:n})=>{const r=fe().searchV4,{convert:o}=O(),[s,l]=h.useState(!1),a=h.useId(),p=In(t),c=d=>n({...t,...d});return e.jsxs("aside",{className:"bim-sr-aside","aria-label":o(r.filterTitle),children:[e.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":s,"aria-controls":a,onClick:()=>l(d=>!d),children:[e.jsxs("span",{children:[o(r.filterButton),p>0&&e.jsx("span",{className:"bim-sr-fn",children:o(nt(r.filterSelected,{n:p}))})]}),e.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[o(s?r.collapse:r.expand)," ",s?"▴":"▾"]})]}),e.jsxs("div",{className:"bim-sr-filters",id:a,"data-open":s?"true":"false",...s?{}:{"data-collapsed":"true"},children:[e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:o(r.dynasty)}),e.jsx("div",{className:"bim-sr-chips",children:Tn.map(d=>e.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":t.dynasty.includes(d.key),onClick:()=>c({dynasty:Ir(t.dynasty,d.key)}),children:o(d.key)},d.key))})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:o(r.classification)}),Nn.map(d=>e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.classification.includes(d.value),onChange:()=>c({classification:Ir(t.classification,d.value)})}),o(d.label)]},d.value||"_"))]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:o(r.resources)}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasImage,onChange:d=>c({hasImage:d.target.checked})}),o(r.hasImage)]}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasText,onChange:d=>c({hasText:d.target.checked})}),o(r.hasText)]})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{id:`${a}-loss`,children:o(r.extant)}),e.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${a}-loss`,children:Ai.map(d=>e.jsx("button",{type:"button","aria-pressed":t.loss===d.value,onClick:()=>c({loss:d.value}),children:o(d.label)},d.value||"all"))})]}),e.jsx("p",{className:"bim-sr-note",children:o(r.onlyWorksNote)}),p>0&&e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Cn,sort:t.sort}),children:o(r.clearAllFilters)})]})]})};function ds({text:t,query:n}){const r=(n??"").trim();if(!r||!t)return e.jsx(e.Fragment,{children:t});const o=t.toLowerCase(),s=r.toLowerCase(),l=[];let a=0,p=0;for(;a<t.length;){const c=o.indexOf(s,a);if(c<0){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{className:"bim-sr-hl",children:t.slice(c,c+s.length)},p++)),a=c+s.length}return e.jsx(e.Fragment,{children:l})}const Er=({entries:t,query:n,onEntryLinkClick:r,typeName:o})=>{const s=fe(),l=s.searchV4,{convert:a}=O(),p=He();return e.jsx("div",{className:"bim-sr-tablewrap",children:e.jsxs("table",{className:"bim-sr-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"34%"}}),e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"19%"}}),e.jsx("col",{style:{width:"13%"}}),e.jsx("col",{style:{width:"12%"}}),e.jsx("col",{style:{width:"14%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:a(l.colTitle)}),e.jsx("th",{scope:"col",children:a(l.colType)}),e.jsx("th",{scope:"col",children:a(l.colAuthor)}),e.jsx("th",{scope:"col",children:a(l.colEra)}),e.jsx("th",{scope:"col",children:a(l.colClass)}),e.jsx("th",{scope:"col",style:{textAlign:"right"},children:a(l.colResource)})]})}),e.jsx("tbody",{children:t.map(c=>{const d=a(c.title||c.primary_name||c.id),u=c.measure_info?a(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",x=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${a(c.author)}${c.role&&c.role!=="author"?` ${a(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,g=m?a(m):"",b=c.classification?a(c.classification):"",k=[];c.has_image&&k.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&k.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&k.push({label:l.tagLost,cls:"bim-sr-tag--lost"});const y=[x,g,b].filter(Boolean).join(" · ");return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-sr-c-title",children:[e.jsxs("div",{className:"bim-sr-tl",children:[e.jsx("a",{href:p(c.id),onClick:j=>r(c,j),children:e.jsx(ds,{text:d,query:n?a(n):void 0})}),u&&e.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&e.jsx("span",{className:"bim-sr-sub",children:y})]}),e.jsxs("td",{className:"bim-sr-c-type",children:[e.jsx(Ot,{type:c.type,size:6})," ",o(c.type)]}),e.jsx("td",{className:"bim-sr-c-who",children:x||"—"}),e.jsx("td",{className:"bim-sr-c-era",children:g||"—"}),e.jsx("td",{className:"bim-sr-c-cls",children:b||"—"}),e.jsx("td",{className:"bim-sr-c-res",children:k.map(j=>e.jsx("span",{className:`bim-sr-tag ${j.cls}`,children:a(j.label)},j.label))})]},c.id)})})]})})},Rc=`
|
|
1
|
+
"use strict";var Ha=Object.create;var $r=Object.defineProperty;var Ga=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var Va=Object.getPrototypeOf,Ya=Object.prototype.hasOwnProperty;var Ka=(t,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Ua(n))!Ya.call(t,s)&&s!==r&&$r(t,s,{get:()=>n[s],enumerable:!(o=Ga(n,s))||o.enumerable});return t};var pn=(t,n,r)=>(r=t!=null?Ha(Va(t)):{},Ka(n||!t||!t.__esModule?$r(r,"default",{value:t,enumerable:!0}):r,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const be=require("./storage-entry-DPsx0DgD.cjs"),e=require("react/jsx-runtime"),h=require("react"),qa=require("opencc-js/t2cn"),Ja=require("react-markdown"),Za=require("remark-gfm"),Xa=t=>`/book-index?id=${t}`,qo=h.createContext(Xa);function Qa({buildUrl:t,children:n}){const r=h.useMemo(()=>t,[t]);return e.jsx(qo.Provider,{value:r,children:n})}function He(){return h.useContext(qo)}const Jo="",Zo="";function Ti(t){const n=[];let r=!1,o=t;for(;o.length;){const s=r?Zo:Jo,l=o.indexOf(s);if(l===-1){n.push({text:o,marked:r});break}l>0&&n.push({text:o.slice(0,l),marked:r}),o=o.slice(l+1),r=!r}return n}function Ke(t,n){return{title:t,tokens:n}}const _r='"Songti SC", "Songti TC", STSong, "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif',ec=[Ke("基础(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"}}),Ke("底色层次 / 文字与描边 / 链接",{"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:"彩色底(徽章、选中态按钮)上的文字"}}),Ke("提示与警告",{"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)"}}),Ke("遮罩与阴影",{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)"}}),Ke("条目类型 / 状态徽章",{"type-book":{value:"#c0392b"},"type-work":{value:"#8e6f3e"},"type-collection":{value:"#2471a3"},"type-entity":{value:"#5b3e8e"},"status-draft":{value:"#e67e22"},"status-official":{value:"#27ae60"}}),Ke("资源",{"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"}}),Ke("整理本(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"}}),Ke("版本传承(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"}}),Ke("编辑器视图(主要在 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")'}}),Ke("详情页(作品 / 版本 / 丛编):宣纸 + 朱砂一套独立暖色,不继承 --bim-primary 等控件色",{"page-bg":{value:"#fbf9f3",note:"纸"},"row-hover-bg":{value:"#f5f1e5"},"selection-bg":{value:"#ecdcbc",note:"选区"},"band-bg":{value:"#f0e4cb",note:"全文入口横幅(暖沙)"},"band-bg-hover":{value:"#e6d5b4"},ink:{value:"#2a231c",note:"文字层次:墨 → 正文 → 提要 → meta → 标签 → 提示"},"body-fg":{value:"#3b3228"},"quiet-fg":{value:"#5b4f40"},"meta-fg":{value:"#7b6a54"},"label-fg":{value:"#6f6457",note:"标签 / 提示:2026-09 N3a 调深,纸底与斑马底上对比度均 ≥4.5(原 #a3937b 2.8、#b3a385 2.3)"},"hint-fg":{value:"#756a5e"},accent:{value:"#9c3a2c",note:"朱"},"accent-deep":{value:"#6f2a20",note:"链接 hover"},"rule-strong":{value:"#2a231c",note:"分隔线:强 → 常规 → 虚线 → 提要左线"},rule:{value:"#e4dbc9"},"rule-dashed":{value:"#d6c9ae"},"rule-accent-soft":{value:"#e0d3b6"},"aux-fg":{value:"#6f6457",note:"辅助字(元数据、注记、「·」分隔的浅色小字)。须在 page-bg / zebra-bg 上对比度 ≥4.5(Q5 巡检)"},"card-bg":{value:"#fffdf9",note:"提要卡:抬起的面"},"zebra-bg":{value:"#f6f2eb",note:"表格斑马纹 / 左栏分组底(不画格线,靠这一阶底色分行)"},"tint-bg":{value:"#f3eee6",note:"检索框、悬停"},"shadow-summary":{value:"0 10px 32px rgba(60, 50, 40, 0.07)",note:"提要卡投影"},"flag-bg":{value:"rgba(158, 42, 43, 0.08)",note:"唯一的状态色块「有影印」"},"theme-dot-zhusha":{value:"#9c3a2c",note:"主题切换控件的色点:朱砂(不随主题变,两套主题下都要认得出)"},"theme-dot-indigo":{value:"#2e5266",note:"主题切换控件的色点:靛青"},"theme-dot-ink":{value:"#222221",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}}),Ke('版式(v4 外观系统,overview#291):疏朗=留白分区(默认,下列值即疏朗);界栏=框线分区(`<html data-layout="boxed">`)',{"fr-bd":{value:"0 solid transparent",note:"区块外框(border 简写)。疏朗无框;界栏 1px 实线"},"fr-bg":{value:"transparent",note:"区块底。界栏=卡面色"},"fr-hd-pad":{value:"14px 18px",note:"区块标题栏内边距。10-01 起疏朗也有淡染底的标题栏(--bim-fr-hd-bg),故疏朗 14px 18px,界栏 12px 18px"},"fr-hd-bd":{value:"0 solid transparent",note:"区块标题栏下沿线(border 简写)"},"fr-bd-pad":{value:"0",note:"区块正文内边距"},"fr-gap":{value:"56px",note:"区块之间的间距。界栏收紧到 24px(框线本身已分隔)"},"fr-side-gap":{value:"34px",note:"侧栏各块之间的间距;界栏 20px"},"fr-shadow":{value:"0 1px 0 var(--bim-rule), 0 12px 32px -18px rgba(40, 36, 31, 0.25)",note:"抬起的面(提要卡)的投影;界栏不用投影,靠框线"},"fr-tab-bd":{value:"transparent",note:"页签行下沿线颜色(疏朗不画,界栏画)"},"fr-hd-size":{value:"24px",note:"分区标题字号。界栏标题在框顶标题栏里,小一档 19px"},"fr-hd-bg":{value:"color-mix(in srgb, var(--bim-accent) 7%, var(--bim-page-bg))",note:"分区标题栏底色(淡染主色)。疏朗混进页面底,界栏 6% 混进卡面底。主色取 accent(primary 是 VS Code 按钮蓝,不随配色)"},"fr-card-bd":{value:"1px solid transparent",note:"卡片边框。疏朗不画(靠卡面底与淡投影);界栏 1px"},"fr-card-bg":{value:"var(--bim-card-bg)",note:"卡片底"},"fr-row-bd":{value:"1px solid transparent",note:"列表行线、块内小分割线。疏朗不画(靠行距);界栏 1px"},"fr-row-pad":{value:"10px 2px",note:"列表行内边距。界栏收紧 7px 2px"},"fr-chrome-bd":{value:"1px solid transparent",note:"顶栏、分区导航(吸顶锚点条)的线"},"fr-tag-bd":{value:"1px solid transparent",note:"标签、版本签、计数签、工具按钮的边框。疏朗浅底无框;界栏透明底加框"},"fr-tag-bg":{value:"var(--bim-tint-bg)",note:"标签底"},"fr-tbl-cell-bd":{value:"0 solid transparent",note:"表格格线。疏朗不画(靠斑马纹);界栏全格线"},"fr-tbl-zebra":{value:"var(--bim-tint-bg)",note:"表格斑马纹(只在疏朗下有)"},"fr-rail-bd":{value:"1px solid transparent",note:"侧栏里的块、提示块的边框"},"fr-rail-bg":{value:"var(--bim-tint-bg)",note:"侧栏块底。疏朗浅底;界栏卡面底"},"fr-spine-bd":{value:"1px solid transparent",note:"题签、书脊(竖排书名)的边框。界栏是强调色浅线"},"fr-spine-bg":{value:"var(--bim-flag-bg)",note:"题签、书脊底。疏朗浅色实底;界栏卡面底(正史原志两种版式都是强调色实底)"},"fr-plank":{value:"0 solid transparent",note:"书架架板(border 简写)。只在界栏下画 3px"},"fr-axis-bd":{value:"0 solid transparent",note:"时间轴轴线。界栏 1px"},"fr-axis-band":{value:"6px",note:"时间轴底带高度。疏朗用 6px 浅色带代替轴线;界栏 0"},"fr-tick":{value:"0",note:"时间轴刻度短线长度。界栏 5px"},"fr-band-gap":{value:"3px",note:"年代带各段之间的空隙。疏朗 3px;界栏紧贴"},"fr-band-bd":{value:"0 solid transparent",note:"年代带外框与段间分隔。界栏 1px"}}),Ke("阅读器(整理本 / 全文)",{"reader-top":{value:"0px",note:"宿主吸顶导航的高度:阅读器工具条、目录与书影侧栏在它下面吸顶(如 60px)"}}),Ke("反馈浮钮(2026-09-28 Q5)",{"feedback-fab-z":{value:"40",note:"层级:低于页面抽屉、弹层(本包对话框为 1000)"},"feedback-fab-offset":{value:"0px",root:!1}}),Ke("字体(全站无衬线,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:_r,note:"著录原文(提要、按语)用宋体"},"font-reading":{value:_r,css:"var(--bim-font-serif)",note:"阅读器正文(整理本 / 全文);默认接 font-serif,只需覆盖那一个就同时换掉"}})],tc=Object.assign({},...ec.map(t=>t.tokens)),Xo={};for(const[t,n]of Object.entries(tc))Xo[t]=`var(--bim-${t}, ${n.value})`;function i(t){const n=Xo[t];if(n===void 0)throw new Error(`book-index-ui: 未定义的设计变量 --bim-${t}`);return n}function _t(t){return t.types&&t.types.length>0?t.types:t.type?t.type==="text+image"?["text","image"]:[t.type]:[]}function nc(t,n){return _t(t).includes(n)}const li={published:"出版",fine:"精校",rough:"粗校",ocr:"機器識別"},ic={published:"達到出版、學術研究標準,錯誤率在萬分之一以內",fine:"通讀無障礙,錯誤率在百分之一以內",rough:"保證文意基本正確,錯誤率在百分之三以內",ocr:"保持大意和結構,錯誤率在百分之十以內"};i("quality-published"),i("quality-fine"),i("quality-rough"),i("quality-ocr");const Bt=h.createContext(null),Qo={indexType:{work:"作品",book:"書籍",collection:"叢編",entity:"人物"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"館藏"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"館藏"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("check-ai-fg")}},action:{save:"保存",delete:"刪除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"訪問 →",view:"查看 →",viewEntity:"查看",copy:"複製 ID",copied:"已複製",linkExisting:"+ 關聯現有",createAndLink:"+ 創建並關聯",remove:"刪除",clearAll:"清除全部",reselect:"重選",changeType:"更換類型",expand:"展開",collapse:"收起",expandMore:"展開更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加書籍",addSubCollection:"添加子叢編",addCollectionImpl:"添加叢編實現",addSource:"添加來源",addResource:"添加資源",addIndexedBy:"+ 添加收錄來源",addEmendatedBy:"+ 添加考證來源",addAdditionalWork:"+ 添加附屬作品",selectBookOrWork:"選擇書籍/作品",clickToSelectBookOrWork:"點擊選擇書籍/作品",unlink:"解除關聯"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷數",pageCount:"頁數 (Pages)",volumeCount:"冊數 (Volumes)",holder:"現藏於 (Holder)",firstImage:"首頁圖片 (First Image URL)",year:"年代",currentLocation:"現藏",parentWork:"上級作品",relatedWorks:"相關作品",type:"類型",rootType:"根類型",coverageLevel:"覆蓋層級",coverageRange:"覆蓋範圍",metadata:"元數據",optionalInfo:"可選信息",details:"詳細說明",detailsOptional:"詳細說明 (可選)",positionOptional:"位置/頁碼 (可選)",dataVersionOptional:"數據版本 (可選)",processorVersionOptional:"處理器版本 (可選)",sourceName:"來源名稱",sourceBid:"來源 BID",titleInfo:"題名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介紹 (Description)",additionalWorks:"📑 附屬作品 (Additional Works)",indexedBy:"📖 著錄於",emendatedBy:"📝 考證",resources:"資源",textResources:"📝 文字資源 (Text Resources)",imageResources:"🖼️ 圖片資源 (Image Resources)",sources:"📚 資料來源 (Sources)",provenance:"📜 收藏歷史 (Provenance)",relatedVersions:"相關版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危險區域 (Danger Zone)",aliases:"別名",attachedTexts:"附載篇目",appendix:"附錄",containedIn:"收入叢編",collectedIn:"收入叢編",belongsToWork:"所屬作品",locationHistory:"流轉歷史",historyOverview:"歷史沿革",containedBooks:"收錄書籍",relations:"關聯關係",summary:"提要",comment:"按語",additionalComment:"附按",indexed:"收錄於",emendated:"考證",relatedWorks:"相關作品",containedWorks:"包含作品",adaptations:"改編作品",derivativeWorks:"續書與評註",studies:"所考典籍"},relation:{belongsToWork:"所屬作品 (Work)",containedInCollection:"收入叢編",siblingVersions:"同作品其他版本",addVersionForWork:"為此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"叢編實現",allVersions:"所有版本",correspondingWork:"對應作品 (Work)",parentCollection:"父叢編 (Parent Collection)",childCollections:"子叢編",containedBooks:"包含書籍",notLinked:"(未關聯)",none:"(暫無)"},search:{placeholder:"搜索作品、書籍、叢編...",searching:"搜索中...",loading:"加載中...",noResults:"無匹配結果",noResultsFor:"未找到與「{query}」相關的結果",tryOther:"試試其他關鍵詞、別名或作者名",recentBrowse:"最近瀏覽",history:"搜索歷史",clearAll:"清除全部",clearRecent:"清除最近瀏覽",itemNotFound:"無法找到,可能已刪除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"結果分類",searchSubtitle:"輸入關鍵詞搜索作品、書籍或叢編",searchBookName:"搜索書名...",alias:"別名"},searchV4:{filterTitle:"篩選",dynasty:"朝代",classification:"部類",resources:"資源",extant:"存佚",clearAllFilters:"清除全部篩選",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"篩選",filterSelected:"{n} 項已選",expand:"展開",collapse:"收起",filteredCount:"篩出 {n} 條",removeFilter:"取消篩選:{name}",viewLabel:"結果視圖",viewTable:"表格",viewCard:"卡片",colTitle:"題名",colType:"類型",colAuthor:"責任者",colEra:"年代",colClass:"部類",colResource:"資源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 條 · 每頁 {size} 條 · 第 {page} / {pages} 頁",pagerLabel:"翻頁",prevPage:"上一頁",nextPage:"下一頁",emptyFiltered:"沒有找到匹配的條目。試試更短的書名、減少篩選,或切換繁 / 簡。",limitedNote:"各類只列前幾條,點上方分類頁籤看全部。",sortLabel:"排序",sortRelevance:"相關度",sortEra:"年代",sortTitle:"書名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A",onlyWorksNote:"部類、存佚只適用於作品;選了它們,版本、叢編、人物不參與。"},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:"圖片資源"}},rc={indexType:{work:"作品",book:"书籍",collection:"丛编",entity:"人物"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"馆藏"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"馆藏"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:i("check-fine-bg"),fg:i("check-fine-fg")},粗校:{label:"粗校",bg:i("check-rough-bg"),fg:i("check-rough-fg")},AI整理:{label:"AI整理",bg:i("check-ai-bg"),fg:i("check-ai-fg")}},action:{save:"保存",delete:"删除",newEntry:"+ 新建",viewAll:"查看全部 →",visit:"访问 →",view:"查看 →",viewEntity:"查看",copy:"复制 ID",copied:"已复制",linkExisting:"+ 关联现有",createAndLink:"+ 创建并关联",remove:"删除",clearAll:"清除全部",reselect:"重选",changeType:"更换类型",expand:"展开",collapse:"收起",expandMore:"展开更多",addSubWork:"添加子作品",addVersion:"添加新版本",addBook:"添加书籍",addSubCollection:"添加子丛编",addCollectionImpl:"添加丛编实现",addSource:"添加来源",addResource:"添加资源",addIndexedBy:"+ 添加收录来源",addEmendatedBy:"+ 添加考证来源",addAdditionalWork:"+ 添加附属作品",selectBookOrWork:"选择书籍/作品",clickToSelectBookOrWork:"点击选择书籍/作品",unlink:"解除关联"},label:{id:"ID:",author:"作者 (Author)",dynasty:"朝代/年份 (Dynasty/Year)",edition:"版本",juanCount:"卷数",pageCount:"页数 (Pages)",volumeCount:"册数 (Volumes)",holder:"现藏于 (Holder)",firstImage:"首页图片 (First Image URL)",year:"年代",currentLocation:"现藏",parentWork:"上级作品",relatedWorks:"相关作品",type:"类型",rootType:"根类型",coverageLevel:"覆盖层级",coverageRange:"覆盖范围",metadata:"元数据",optionalInfo:"可选信息",details:"详细说明",detailsOptional:"详细说明 (可选)",positionOptional:"位置/页码 (可选)",dataVersionOptional:"数据版本 (可选)",processorVersionOptional:"处理器版本 (可选)",sourceName:"来源名称",sourceBid:"来源 BID",titleInfo:"题名",authorInfo:"著者",urlAddress:"URL 地址"},section:{basicInfo:"📊 基本信息",description:"📝 介绍 (Description)",additionalWorks:"📑 附属作品 (Additional Works)",indexedBy:"📖 著录于",emendatedBy:"📝 考证",resources:"资源",textResources:"📝 文字资源 (Text Resources)",imageResources:"🖼️ 图片资源 (Image Resources)",sources:"📚 资料来源 (Sources)",provenance:"📜 收藏历史 (Provenance)",relatedVersions:"相关版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危险区域 (Danger Zone)",aliases:"别名",attachedTexts:"附载篇目",appendix:"附录",containedIn:"收入丛编",collectedIn:"收入丛编",belongsToWork:"所属作品",locationHistory:"流转历史",historyOverview:"历史沿革",containedBooks:"收录书籍",relations:"关联关系",summary:"提要",comment:"按语",additionalComment:"附按",indexed:"收录于",emendated:"考证",relatedWorks:"相关作品",containedWorks:"包含作品",adaptations:"改编作品",derivativeWorks:"续书与评注",studies:"所考典籍"},relation:{belongsToWork:"所属作品 (Work)",containedInCollection:"收入丛编",siblingVersions:"同作品其他版本",addVersionForWork:"为此作品添加新版本",parentWork:"父作品 (Parent Work)",childWorks:"子作品",collectionImpl:"丛编实现",allVersions:"所有版本",correspondingWork:"对应作品 (Work)",parentCollection:"父丛编 (Parent Collection)",childCollections:"子丛编",containedBooks:"包含书籍",notLinked:"(未关联)",none:"(暂无)"},search:{placeholder:"搜索作品、书籍、丛编...",searching:"搜索中...",loading:"加载中...",noResults:"无匹配结果",noResultsFor:"未找到与「{query}」相关的结果",tryOther:"试试其他关键词、别名或作者名",recentBrowse:"最近浏览",history:"搜索历史",clearAll:"清除全部",clearRecent:"清除最近浏览",itemNotFound:"无法找到,可能已删除",removeFromRecent:"移除",searchTitle:"搜索古籍索引",allTab:"全部",resultTabs:"结果分类",searchSubtitle:"输入关键词搜索作品、书籍或丛编",searchBookName:"搜索书名...",alias:"别名"},searchV4:{filterTitle:"筛选",dynasty:"朝代",classification:"部类",resources:"资源",extant:"存佚",clearAllFilters:"清除全部筛选",hasImage:"有影印",hasText:"有文本",hasCollated:"有文本",filterButton:"筛选",filterSelected:"{n} 项已选",expand:"展开",collapse:"收起",filteredCount:"筛出 {n} 条",removeFilter:"取消筛选:{name}",viewLabel:"结果视图",viewTable:"表格",viewCard:"卡片",colTitle:"题名",colType:"类型",colAuthor:"责任者",colEra:"年代",colClass:"部类",colResource:"资源",tagImage:"影印",tagText:"文本",tagCollated:"文本",tagLost:"佚",pageInfo:"共 {total} 条 · 每页 {size} 条 · 第 {page} / {pages} 页",pagerLabel:"翻页",prevPage:"上一页",nextPage:"下一页",emptyFiltered:"没有找到匹配的条目。试试更短的书名、减少筛选,或切换繁 / 简。",limitedNote:"各类只列前几条,点上方分类页签看全部。",sortLabel:"排序",sortRelevance:"相关度",sortEra:"年代",sortTitle:"书名",sortEraAsc:"由早到晚",sortEraDesc:"由晚到早",sortTitleAsc:"拼音 A→Z",sortTitleDesc:"拼音 Z→A",onlyWorksNote:"部类、存佚只适用于作品;选了它们,版本、丛编、人物不参与。"},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:"图片资源"}},oc=["曹霑"];function sc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lc(t,n=oc){const r=[...new Set(n.filter(Boolean))].sort((l,a)=>a.length-l.length);if(!r.length)return t;const o=new RegExp(`(${r.map(sc).join("|")})`,"g"),s=new Set(r);return l=>{if(!l)return t(l);const a=l.split(o);return a.length===1?t(l):a.map((p,c)=>c%2===1&&s.has(p)?p:p&&t(p)).join("")}}let Pt=null;function ac(){if(Pt)return Pt;try{Pt=lc(qa.Converter({from:"tw",to:"cn"}))}catch{Pt=t=>t}return Pt}const cc={"zh-Hant":Qo,"zh-Hans":rc},es="bim-locale";function dc(){try{const t=localStorage.getItem(es);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function pc(t){try{localStorage.setItem(es,t)}catch{}}const uc="zh-Hans",mc=({locale:t,onLocaleChange:n,converter:r,children:o})=>{const[s,l]=h.useState(t??uc),a=t??s;h.useEffect(()=>{if(t)return;const u=dc();u&&u!==s&&l(u)},[]);const p=h.useMemo(()=>a==="zh-Hans"?r??ac():null,[a,r]),c=h.useCallback(u=>{l(u),pc(u),n==null||n(u)},[n]),d=h.useMemo(()=>({locale:a,setLocale:c,messages:cc[a],converter:p}),[a,c,p]);return e.jsx(Bt.Provider,{value:d,children:o})};function fe(){const t=h.useContext(Bt);return(t==null?void 0:t.messages)??Qo}const xc=2e3;function O(){const t=h.useContext(Bt),n=(t==null?void 0:t.locale)??"zh-Hant",r=(t==null?void 0:t.converter)??null,o=h.useRef(new Map),s=h.useRef(n);s.current!==n&&(o.current.clear(),s.current=n);const l=h.useCallback(a=>{if(!a)return"";if(!r)return a;const p=o.current.get(a);if(p!==void 0)return p;const c=r(a);if(o.current.size>=xc){const d=o.current.keys().next().value;d!==void 0&&o.current.delete(d)}return o.current.set(a,c),c},[r]);return h.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function nt(t,n){return t.replace(/\{(\w+)\}/g,(r,o)=>String(n[o]??""))}function hc(t){if(!t)return"";try{const n=new URL(t).hostname,r={"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(r[n])return r[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function gc(){return{id:"",name:"",url:"",type:"text",details:""}}const ai=({items:t,onChange:n,onDownload:r,downloadStatuses:o,filterType:s})=>{const l=fe(),[a,p]=h.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=f=>{if(!s)return!0;const v=_t(f);return s==="text"?v.includes("text"):s==="image"?v.includes("image")||v.includes("physical"):s==="physical"?v.includes("physical"):v.includes(s)},x=t.map((f,v)=>({item:f,originalIndex:v})).filter(({item:f})=>u(f)),m=()=>{const f=gc();s&&(f.type=s),n([...t,f]),p(t.length)},g=f=>{n(t.filter((v,$)=>$!==f)),p(null)},b=(f,v,$)=>{const w=[...t];if(w[f]={...w[f],[v]:$},v==="url"&&!w[f].id){const _=hc($);_&&(w[f].id=_)}n(w)},k=(f,v,$)=>{const _={...t[f].metadata||{}};$?_[v]=$:delete _[v],b(f,"metadata",Object.keys(_).length>0?_:void 0)},y=(f,v)=>{const $=v.trim()?v.split(/[,,、]/).map(w=>w.trim()).filter(Boolean):void 0;b(f,"structure",$)},j=(f,v,$)=>{const _=t[f].coverage||{level:1,ranges:""};v==="level"?_.level=parseInt($)||1:_.ranges=$,b(f,"coverage",_.ranges?_:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[x.map(({item:f,originalIndex:v})=>{var $,w,_;return e.jsxs("div",{style:{border:`1px solid ${i("widget-border")}`,borderRadius:"4px",background:i("input-bg"),overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>p(a===v?null:v),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:a===v?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:fc(f.type??"text"),color:i("on-color-fg")},children:(()=>{var z,E;const S=_t(f);return S.length===0?f.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")?((E=c.find(T=>T.value==="text+image"))==null?void 0:E.label)??"text+image":S.join("+")})()}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:f.name||`${l.editor.resourcePlaceholder} ${v+1}`}),f.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:f.id}),f.url&&e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",onClick:S=>S.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),r&&f.url&&bc(v,o==null?void 0:o[v],r,l),e.jsx("button",{onClick:S=>{S.stopPropagation(),g(v)},style:{background:"transparent",border:"none",color:i("danger"),cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),a===v&&e.jsxs("div",{style:{padding:"12px",borderTop:`1px solid ${i("widget-border")}`},children:[nc(f,"image")&&f.url&&yc(f,l),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:Dt,children:[e.jsx("span",{style:Ht,children:l.label.type}),e.jsx("select",{value:f.type,onChange:S=>b(v,"type",S.target.value),style:{...rt,flex:1},children:c.map(S=>e.jsx("option",{value:S.value,children:S.label},S.value))})]}),e.jsxs("label",{style:Dt,children:[e.jsx("span",{style:Ht,children:l.label.rootType}),e.jsx("select",{value:f.root_type||"catalog",onChange:S=>b(v,"root_type",S.target.value),style:{...rt,flex:1},children:d.map(S=>e.jsx("option",{value:S.value,children:S.label},S.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:f.id,onChange:S=>b(v,"id",S.target.value),placeholder:l.editor.idAutoExtract,style:{...rt,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:f.name,onChange:S=>b(v,"name",S.target.value),placeholder:l.editor.resourceName,style:{...rt,flex:1}})]}),e.jsx("input",{type:"text",value:f.url,onChange:S=>b(v,"url",S.target.value),placeholder:l.editor.resourceUrl,style:rt}),e.jsx("input",{type:"text",value:(($=f.structure)==null?void 0:$.join("、"))||"",onChange:S=>y(v,S.target.value),placeholder:l.editor.structurePlaceholder,style:rt}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:Dt,children:[e.jsx("span",{style:Ht,children:l.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((w=f.coverage)==null?void 0:w.level)??"",onChange:S=>j(v,"level",S.target.value),placeholder:"1",style:{...rt,width:"60px"}})]}),e.jsxs("label",{style:{...Dt,flex:1},children:[e.jsx("span",{style:Ht,children:l.label.coverageRange}),e.jsx("input",{type:"text",value:((_=f.coverage)==null?void 0:_.ranges)||"",onChange:S=>j(v,"ranges",S.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...rt,flex:1}})]})]}),e.jsx("textarea",{value:f.details||"",onChange:S=>b(v,"details",S.target.value),placeholder:l.editor.detailsPlaceholder,style:{...rt,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:`1px solid ${i("widget-border")}`,paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),marginBottom:"6px"},children:l.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([S,z])=>{var E;return e.jsxs("label",{style:{...Dt,gap:"4px"},children:[e.jsx("span",{style:{...Ht,minWidth:"56px"},children:z}),e.jsx("input",{type:"text",value:((E=f.metadata)==null?void 0:E[S])||"",onChange:T=>k(v,S,T.target.value),placeholder:z,style:{...rt,flex:1}})]},S)})})]})]})]})]},v)}),e.jsxs("button",{onClick:m,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:`1px dashed ${i("widget-border")}`,borderRadius:"4px",background:"transparent",color:i("fg"),cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:l.action.addResource})]})]})};function fc(t){switch(t){case"text":return i("restype-text");case"image":return i("restype-image");case"text+image":return i("restype-text-image");case"physical":return i("restype-physical")}}function bc(t,n,r,o){const s=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return e.jsx("button",{onClick:a=>{a.stopPropagation(),s||r(t,"")},disabled:s,style:{background:"transparent",border:"none",color:i(l?"success":s?"desc-fg":"link-fg"),cursor:s?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:s?.6:.9},title:l?o.download.completed:s?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:l?"✓":s?"⏳":"⬇"})}function yc(t,n){const r=/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(t.url)||t.url.includes("iiif")||t.url.includes("image");return e.jsx("div",{style:{marginBottom:"12px"},children:r?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:i("overlay-bg")},children:e.jsx("img",{src:t.url,alt:t.name,style:{width:"100%",height:"150px",objectFit:"contain"},onError:o=>{o.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:i("overlay-bg"),borderRadius:"4px",fontSize:"12px",color:i("desc-fg")},children:n.editor.imageResourceLink})})}const rt={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"},Dt={display:"flex",alignItems:"center",gap:"6px"},Ht={fontSize:"12px",color:i("desc-fg"),whiteSpace:"nowrap"},jc={"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 Mt(t){try{return jc[new URL(t).hostname]}catch{return}}const zr={text:0,image:1,physical:2};function Ni(t){return t.length===0?"physical":[...t].sort((n,r)=>(zr[n]??99)-(zr[r]??99)).join("+")}function Ii(t){var a;const n=p=>{const c=p.match(/^(.+?)·第(\d+)[冊册]$/);if(c)return[c[1],parseInt(c[2])];const d=p.match(/^(.+?)[·(](\d+)[)]?$/);return d?[d[1],parseInt(d[2])]:null},r=new Map;for(let p=0;p<t.length;p++){const c=t[p];if(c.volumes&&c.volumes.length>0)continue;const d=n(c.name);if(!d)continue;const[u,x]=d,m=`${u}|${Ni(_t(c))}`;r.has(m)||r.set(m,{base:{...c,name:u,url:"",volumes:[]},volumes:[],indices:[]});const g=r.get(m);g.volumes.push({volume:x,url:c.url||void 0,status:"found"}),g.indices.push(p)}const o=[],s=new Set;for(const p of r.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)??""),o.push(p.base);for(const c of p.indices)s.add(c)}const l=[...o];for(let p=0;p<t.length;p++)s.has(p)||l.push(t[p]);return l}function ts(t){if(t.url)return t.url;for(const[n,r]of Object.entries(t))if(n.endsWith("_url")&&typeof r=="string")return r}function ns(t){return!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(n=>({...n,url:n.url||ts(n)}))}function _n(t){const n=ns(t);if(!n)return null;const r=new Set(n.filter(s=>s.status!=="missing").map(s=>s.volume)).size,o=new Set(n.filter(s=>s.status==="missing").map(s=>s.volume)).size;return{found:r,missing:o,expected:t.expected_volumes??r+o}}function Ei(t){if(!t)return;const n=t.file_page_range||t.page_range;if(!n||typeof n!="string")return;const r=n.match(/^(\d+)/);return r?parseInt(r[1],10):void 0}function Ri(t,n){try{if(new URL(t).hostname.includes("wikimedia.org")){const o=t.match(/\/wiki\/File:(.+?)(?:#|$)/);if(o)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(o[1]))}&page=${n}`;const s=new URL(t);return s.searchParams.set("page",String(n)),s.toString()}return t}catch{return t}}function Wt(t){if(!t.url)return;const n=Ei(t.metadata);return n?Ri(t.url,n):t.url}const Cr={text:i("restype-text"),image:i("restype-image"),"text+image":i("restype-text-image"),physical:i("restype-physical")};function vc(t){return t.includes("text")&&t.includes("image")?Cr["text+image"]:Cr[t[0]||"physical"]}const Li=({items:t,groupByType:n=!0,resourceGroups:r,onNavigate:o,renderLink:s})=>{const l=fe(),{convert:a}=O(),p=h.useMemo(()=>Ii(t||[]),[t]),{mirrorGroups:c,ungroupedItems:d}=h.useMemo(()=>{const y=new Map,j=[];for(const f of p){const v=f.group;v?(y.has(v)||y.set(v,[]),y.get(v).push(f)):j.push(f)}for(const f of y.values())f.sort((v,$)=>{const w=_=>_.group_role==="origin"?0:_.group_role==="mirror"?1:2;return w(v)-w($)});return{mirrorGroups:y,ungroupedItems:j}},[p]),u={text:l.resourceType.text,image:l.resourceType.image,"text+image":l.resourceType.textImage,physical:l.resourceType.physical},x=y=>u[y]?u[y]:y.split("+").map(j=>u[j]||j).join("+");if(!p||p.length===0)return e.jsx("div",{style:{padding:"16px",color:i("desc-fg"),fontSize:"13px",textAlign:"center"},children:l.misc.noResources});if(!n)return e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:p.map((y,j)=>e.jsx(Un,{item:y},y.id||j))});const m=(y,j)=>{const f=r==null?void 0:r[y],v=(f==null?void 0:f.label)||y,$=f==null?void 0:f.description;return e.jsxs("div",{style:{padding:"10px 12px",border:`1px solid ${i("widget-border")}`,borderRadius:"6px",background:i("input-bg"),display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:i("fg")},children:a(v)}),$&&e.jsx("div",{style:{fontSize:"12px",color:i("desc-fg"),lineHeight:1.5},children:a($)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:j.map((w,_)=>e.jsx(Un,{item:w,onNavigate:o,renderLink:s},w.id||_))})]},`group-${y}`)},g=new Map;for(const y of d){const j=Ni(_t(y));g.has(j)||g.set(j,[]),g.get(j).push(y)}const b=["text","image","text+image","physical"],k=[...b.filter(y=>g.has(y)),...[...g.keys()].filter(y=>!b.includes(y)).sort()];return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[[...c.entries()].map(([y,j])=>m(y,j)),k.map(y=>{const j=g.get(y),f=vc(y.split("+"));return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:f,whiteSpace:"nowrap",flexShrink:0},children:x(y)}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:j.map((v,$)=>e.jsx(Un,{item:v,onNavigate:o,renderLink:s},v.id||$))})]},y)})]})},kc={bw:{label:"",bg:i("colormode-bw-bg"),fg:i("colormode-bw-fg")},color:{label:"",bg:i("colormode-color-bg"),fg:i("colormode-color-fg")}},Un=({item:t})=>{const n=fe(),{convert:r}=O(),[o,s]=h.useState(!1),l=h.useMemo(()=>(t.url?Mt(t.url):void 0)||r(t.name),[t.url,t.name,r]),a=h.useMemo(()=>!Array.isArray(t.volumes)||t.volumes.length===0?null:t.volumes.map(b=>({...b,url:b.url||ts(b)})),[t.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=t.expected_volumes??(p?c+d:0),x=t.color_mode?{...kc[t.color_mode],label:n.colorMode[t.color_mode]}:null,m=t.details&&!p?r(t.details):null,g={display:"inline-flex",alignItems:"center",gap:"5px",padding:"4px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",background:i("input-bg"),fontSize:"12px",color:i("fg"),lineHeight:1.4,verticalAlign:"middle"};return e.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"4px"},children:[e.jsxs("div",{style:g,children:[e.jsx("span",{style:{fontWeight:500},children:l}),x&&e.jsx("span",{style:{padding:"0 5px",borderRadius:"3px",fontSize:"10px",fontWeight:500,background:x.bg,color:x.fg},children:x.label}),m&&e.jsx("span",{style:{fontSize:"11px",color:i("desc-fg")},children:m}),p&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg")},children:[c,"/",u,n.unit.volume,d>0&&e.jsxs("span",{style:{color:i("missing-fg"),marginLeft:"3px"},children:["缺",d]})]}),t.url&&e.jsx("a",{href:(()=>{const b=Ei(t.metadata);return b?Ri(t.url,b):t.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"11px",color:i("link-fg"),textDecoration:"none",whiteSpace:"nowrap"},children:n.action.visit}),p&&e.jsx("button",{onClick:()=>s(!o),style:{padding:"0 6px",fontSize:"11px",border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",lineHeight:1.4},children:o?"▲":"▼"})]}),p&&o&&e.jsx("div",{style:{padding:"6px 10px",border:`1px solid ${i("widget-border")}`,borderRadius:"5px",display:"flex",flexWrap:"wrap",gap:"4px",maxWidth:"360px"},children:a.map(b=>{const k=b.status==="missing";return b.url&&!k?e.jsx("a",{href:b.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:b.volume},b.volume):e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"11px",color:i(k?"missing-fg":"desc-fg"),textDecoration:k?"line-through":"none",opacity:k?.6:1},children:b.volume},b.volume)})})]})},is=({indexSource:t,syncConfig:n,variant:r="index-browser",onSwitchMode:o,onToggleDraft:s,onConfigurePath:l,onSelectFolder:a})=>{const p=fe(),c=t==="local",d=(n==null?void 0:n.isDraft)??!0,u=(n==null?void 0:n.repoPath)||"",x=u?u.split(/[/\\]/).pop()||u:"",m={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:i("primary-soft"),color:i("primary")},g={onMouseOver:k=>k.currentTarget.style.opacity="0.8",onMouseOut:k=>k.currentTarget.style.opacity="1"},b=e.jsxs("div",{onClick:s,title:d?p.mode.switchToOfficial:p.mode.switchToDraft,style:{...m,background:i(d?"warning":"success"),color:i("on-color-fg")},...g,children:[e.jsx("span",{children:d?"📝":"📚"}),e.jsx("span",{children:d?"draft":"official"})]});return r==="index-browser"?c?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[b,e.jsxs("div",{onClick:o,title:p.mode.switchToSync,style:m,...g,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:p.mode.localMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px"},...g,children:[e.jsx("span",{children:"📂"}),x&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:x})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[b,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:o,title:p.mode.switchToLocal,style:m,...g,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:p.mode.syncMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:l,title:x||p.mode.configurePath,style:{...m,background:"transparent",padding:"6px",fontSize:"12px"},...g,children:e.jsx("span",{children:"⚙️"})})]})]}):e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsxs("div",{onClick:o,title:c?p.mode.switchToGithub:p.mode.switchToLocal,style:m,...g,children:[e.jsx("span",{children:c?"📁":"🌐"}),e.jsx("span",{children:c?p.mode.localMode:p.mode.githubSync}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),c&&e.jsxs("div",{onClick:a,title:u||p.mode.selectFolder,style:{...m,paddingLeft:"8px",paddingRight:"8px",minWidth:u?"100px":"auto",justifyContent:"space-between"},...g,children:[e.jsx("span",{children:"📂"}),x&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:x})]}),!c&&x&&e.jsxs("div",{style:{...m,background:i("mode-active-bg"),color:i("on-color-fg"),cursor:"default"},title:u,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:x})]})]})},zn="bim-search-history",Tr=10,Nr=8;function Zt(){try{const t=localStorage.getItem(zn);return t?JSON.parse(t):[]}catch{return[]}}function wc(t){try{const n=Zt().filter(r=>r!==t);n.unshift(t),n.length>Tr&&(n.length=Tr),localStorage.setItem(zn,JSON.stringify(n))}catch{}}function Sc(t){try{const n=Zt().filter(r=>r!==t);localStorage.setItem(zn,JSON.stringify(n))}catch{}}function $c(){try{localStorage.removeItem(zn)}catch{}}const rs=({transport:t,value:n,onChange:r,onSearch:o,onEntrySelect:s,placeholder:l})=>{const a=fe(),p=l??a.search.placeholder,c={work:a.indexType.work,book:a.indexType.book,collection:a.indexType.collection,entity:a.indexType.entity},[d,u]=h.useState(!1),[x,m]=h.useState([]),[g,b]=h.useState(-1),[k,y]=h.useState(Zt),j=h.useRef(null),f=h.useRef(null),v=h.useRef(null),$=h.useRef(!1);h.useEffect(()=>{b(-1);const N=n.trim();if(!N){m(k.map(B=>({type:"history",text:B})));return}if(!t.searchAll){m([]);return}let V=!1;const W=setTimeout(()=>{t.searchAll(N,Nr).then(B=>{if(V)return;const H=[...B.works,...B.books,...B.collections,...B.entities??[]];m(H.slice(0,Nr).map(te=>({type:"entry",text:te.title||te.id,entry:te})))}).catch(()=>{V||m([])})},80);return()=>{V=!0,clearTimeout(W)}},[n,k,t]),h.useEffect(()=>{const N=V=>{v.current&&!v.current.contains(V.target)&&u(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]),h.useEffect(()=>{const N=V=>{var W,B;if(V.key==="/"&&document.activeElement!==j.current){const H=(W=document.activeElement)==null?void 0:W.tagName;if(H==="INPUT"||H==="TEXTAREA"||H==="SELECT")return;V.preventDefault(),(B=j.current)==null||B.focus()}};return document.addEventListener("keydown",N),()=>document.removeEventListener("keydown",N)},[]);const w=h.useCallback(N=>{N.trim()&&(wc(N.trim()),y(Zt())),o(N),u(!1)},[o]),_=h.useCallback(N=>{N.type==="history"?(r(N.text),w(N.text)):N.entry&&(s?(s(N.entry),u(!1)):(r(N.text),w(N.text)))},[r,w,s]),S=h.useCallback(N=>{if(!d||x.length===0){N.key==="Enter"&&w(n);return}switch(N.key){case"ArrowDown":N.preventDefault(),b(V=>(V+1)%x.length);break;case"ArrowUp":N.preventDefault(),b(V=>(V-1+x.length)%x.length);break;case"Enter":N.preventDefault(),g>=0&&g<x.length?_(x[g]):w(n);break;case"Escape":N.preventDefault(),u(!1);break}},[d,x,g,n,w,_]),z=h.useCallback((N,V)=>{V.stopPropagation(),Sc(N),y(Zt()),m(W=>W.filter(B=>!(B.type==="history"&&B.text===N)))},[]),E=h.useCallback(N=>{N.stopPropagation(),$c(),y([]),m([])},[]);h.useEffect(()=>{if(g>=0&&f.current){const N=f.current.children;N[g]&&N[g].scrollIntoView({block:"nearest"})}},[g]);const T=!n.trim()&&k.length>0;return e.jsxs("div",{ref:v,style:{position:"relative",flex:1},children:[e.jsx("input",{ref:j,type:"text",placeholder:p,value:n,onChange:N=>{r(N.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"}}),d&&x.length>0&&e.jsxs("div",{ref:f,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&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:i("desc-fg"),borderBottom:`1px solid ${i("widget-border")}`},children:[e.jsx("span",{children:a.search.history}),e.jsx("button",{onClick:E,style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:a.search.clearAll})]}),x.map((N,V)=>e.jsxs("div",{onClick:()=>_(N),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:i("fg"),background:V===g?i("list-active-bg"):"transparent"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:N.type==="history"?"🕐":"🔍"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:N.text}),N.entry&&e.jsxs("span",{style:{fontSize:"11px",color:i("desc-fg"),flexShrink:0},children:[c[N.entry.type],N.entry.edition&&` · ${N.entry.edition}`,N.entry.author&&` · ${N.entry.author}`]}),N.type==="history"&&e.jsx("button",{onClick:W=>z(N.text,W),style:{border:"none",background:"transparent",color:i("desc-fg"),cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:a.action.remove,children:"×"})]},`${N.type}-${N.text}-${V}`))]})]})},Ot=({type:t,size:n=9})=>e.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:n,height:n,borderRadius:1,flex:"none",background:i(`type-${t}`),verticalAlign:"middle"}}),Cn={dynasty:[],classification:[],hasImage:!1,hasText:!1,hasCollated:!1,loss:"",sort:""},os=new Set(["work","book","entity"]);function _c(t){return ls(t)||!!t.sort}function zc(t,n){return n.sort&&os.has(t)?n.sort:void 0}const Tn=[{key:"漢",values:["漢","西漢","東漢"]},{key:"魏晉南北朝",values:["三國魏","三國蜀","三國吳","三國","晉","西晉","東晉","南朝宋","南朝齊","南朝梁","南朝陳","北魏","東魏","西魏","北齊","北周"]},{key:"唐",values:["隋","唐","五代","前蜀","後蜀","南唐"]},{key:"宋",values:["宋","北宋","南宋","宋末元初","遼","金"]},{key:"元",values:["元","元末明初"]},{key:"明",values:["明","明末清初"]},{key:"清",values:["清"]}],Nn=[{value:"經部",label:"經部"},{value:"史部",label:"史部"},{value:"子部",label:"子部"},{value:"集部",label:"集部"},{value:"",label:"未分類"}],Ai=[{value:"",label:"全部"},{value:"extant",label:"存"},{value:"partially_extant",label:"殘"},{value:"lost",label:"佚"}],ss={work:new Set(["dynasty","classification","hasImage","hasText","hasCollated","loss"]),book:new Set(["dynasty","hasImage","hasText"]),collection:new Set,entity:new Set(["dynasty"])};function In(t){return t.dynasty.length+t.classification.length+(t.hasImage?1:0)+(t.hasText?1:0)+(t.hasCollated?1:0)+(t.loss?1:0)}function ls(t){return In(t)>0}function Cc(t){const n=[];return t.dynasty.length&&n.push("dynasty"),t.classification.length&&n.push("classification"),t.hasImage&&n.push("hasImage"),t.hasText&&n.push("hasText"),t.hasCollated&&n.push("hasCollated"),t.loss&&n.push("loss"),n}function as(t,n){const r=ss[t];return Cc(n).every(o=>r.has(o))}const Gt=t=>JSON.stringify(t);function Tc(t,n){if(!as(n,t))return null;const r=[];if(t.dynasty.length){const o=Array.from(new Set(t.dynasty.flatMap(s=>{var l;return((l=Tn.find(a=>a.key===s))==null?void 0:l.values)??[]})));o.length===1?r.push(`dynasty = ${Gt(o[0])}`):o.length>1&&r.push(`dynasty IN [${o.map(Gt).join(", ")}]`)}return t.classification.length&&r.push(t.classification.length===1?`classification = ${Gt(t.classification[0])}`:`classification IN [${t.classification.map(Gt).join(", ")}]`),t.hasImage&&r.push("has_image = true"),t.hasText&&r.push("has_text = true"),t.hasCollated&&r.push("has_collated = true"),t.loss&&r.push(`loss_status = ${Gt(t.loss)}`),r.join(" AND ")}const Ye={dynasty:"dy",classification:"cls",hasImage:"img",hasText:"txt",hasCollated:"col",loss:"loss",sort:"sort"},cs="_";function yn(t,n=new URLSearchParams){for(const r of Object.values(Ye))n.delete(r);return t.dynasty.length&&n.set(Ye.dynasty,t.dynasty.join(",")),t.classification.length&&n.set(Ye.classification,t.classification.map(r=>r||cs).join(",")),t.hasImage&&n.set(Ye.hasImage,"1"),t.hasText&&n.set(Ye.hasText,"1"),t.hasCollated&&n.set(Ye.hasCollated,"1"),t.loss&&n.set(Ye.loss,t.loss),t.sort&&n.set(Ye.sort,t.sort),n}function Nc(t){const n=l=>(t.get(l)??"").split(",").map(a=>a.trim()).filter(Boolean),r=new Set(Tn.map(l=>l.key)),o=new Set(Nn.map(l=>l.value)),s=t.get(Ye.loss);return{dynasty:Array.from(new Set(n(Ye.dynasty).filter(l=>r.has(l)))),classification:Array.from(new Set(n(Ye.classification).map(l=>l===cs?"":l).filter(l=>o.has(l)))),hasImage:t.get(Ye.hasImage)==="1",hasText:t.get(Ye.hasText)==="1"||t.get(Ye.hasCollated)==="1",hasCollated:!1,loss:s==="extant"||s==="partially_extant"||s==="lost"?s:"",sort:["era:asc","era:desc","title:asc","title:desc"].find(l=>l===t.get(Ye.sort))??""}}function Ic(t,n){return JSON.stringify([t.dynasty.slice().sort(),t.classification.slice().sort(),t.hasImage,t.hasText,t.hasCollated,t.loss,t.sort])===JSON.stringify([n.dynasty.slice().sort(),n.classification.slice().sort(),n.hasImage,n.hasText,n.hasCollated,n.loss,n.sort])}function Ir(t,n){return t.includes(n)?t.filter(r=>r!==n):[...t,n]}const Ec=({filters:t,onChange:n})=>{const r=fe().searchV4,{convert:o}=O(),[s,l]=h.useState(!1),a=h.useId(),p=In(t),c=d=>n({...t,...d});return e.jsxs("aside",{className:"bim-sr-aside","aria-label":o(r.filterTitle),children:[e.jsxs("button",{type:"button",className:"bim-sr-fbtn","aria-expanded":s,"aria-controls":a,onClick:()=>l(d=>!d),children:[e.jsxs("span",{children:[o(r.filterButton),p>0&&e.jsx("span",{className:"bim-sr-fn",children:o(nt(r.filterSelected,{n:p}))})]}),e.jsxs("span",{className:"bim-sr-fa","aria-hidden":"true",children:[o(s?r.collapse:r.expand)," ",s?"▴":"▾"]})]}),e.jsxs("div",{className:"bim-sr-filters",id:a,"data-open":s?"true":"false",...s?{}:{"data-collapsed":"true"},children:[e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:o(r.dynasty)}),e.jsx("div",{className:"bim-sr-chips",children:Tn.map(d=>e.jsx("button",{type:"button",className:"bim-sr-chip","aria-pressed":t.dynasty.includes(d.key),onClick:()=>c({dynasty:Ir(t.dynasty,d.key)}),children:o(d.key)},d.key))})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:o(r.classification)}),Nn.map(d=>e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.classification.includes(d.value),onChange:()=>c({classification:Ir(t.classification,d.value)})}),o(d.label)]},d.value||"_"))]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{children:o(r.resources)}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasImage,onChange:d=>c({hasImage:d.target.checked})}),o(r.hasImage)]}),e.jsxs("label",{className:"bim-sr-opt",children:[e.jsx("input",{type:"checkbox",checked:t.hasText,onChange:d=>c({hasText:d.target.checked})}),o(r.hasText)]})]}),e.jsxs("section",{className:"bim-sr-fg",children:[e.jsx("h3",{id:`${a}-loss`,children:o(r.extant)}),e.jsx("div",{className:"bim-sr-seg",role:"group","aria-labelledby":`${a}-loss`,children:Ai.map(d=>e.jsx("button",{type:"button","aria-pressed":t.loss===d.value,onClick:()=>c({loss:d.value}),children:o(d.label)},d.value||"all"))})]}),e.jsx("p",{className:"bim-sr-note",children:o(r.onlyWorksNote)}),p>0&&e.jsx("button",{type:"button",className:"bim-sr-clear",onClick:()=>n({...Cn,sort:t.sort}),children:o(r.clearAllFilters)})]})]})};function ds({text:t,query:n}){const r=(n??"").trim();if(!r||!t)return e.jsx(e.Fragment,{children:t});const o=t.toLowerCase(),s=r.toLowerCase(),l=[];let a=0,p=0;for(;a<t.length;){const c=o.indexOf(s,a);if(c<0){l.push(t.slice(a));break}c>a&&l.push(t.slice(a,c)),l.push(e.jsx("mark",{className:"bim-sr-hl",children:t.slice(c,c+s.length)},p++)),a=c+s.length}return e.jsx(e.Fragment,{children:l})}const Er=({entries:t,query:n,onEntryLinkClick:r,typeName:o})=>{const s=fe(),l=s.searchV4,{convert:a}=O(),p=He();return e.jsx("div",{className:"bim-sr-tablewrap",children:e.jsxs("table",{className:"bim-sr-table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"34%"}}),e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"19%"}}),e.jsx("col",{style:{width:"13%"}}),e.jsx("col",{style:{width:"12%"}}),e.jsx("col",{style:{width:"14%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:a(l.colTitle)}),e.jsx("th",{scope:"col",children:a(l.colType)}),e.jsx("th",{scope:"col",children:a(l.colAuthor)}),e.jsx("th",{scope:"col",children:a(l.colEra)}),e.jsx("th",{scope:"col",children:a(l.colClass)}),e.jsx("th",{scope:"col",style:{textAlign:"right"},children:a(l.colResource)})]})}),e.jsx("tbody",{children:t.map(c=>{const d=a(c.title||c.primary_name||c.id),u=c.measure_info?a(c.measure_info):c.juan_count?`${c.juan_count}${s.unit.juan}`:"",x=c.type==="entity"?[c.birth_year!=null||c.death_year!=null?`${c.birth_year??"?"}—${c.death_year??"?"}`:""].filter(Boolean).join(""):c.author?`${a(c.author)}${c.role&&c.role!=="author"?` ${a(c.role)}`:""}`:"",m=c.type==="book"?c.era??c.dynasty:c.dynasty,g=m?a(m):"",b=c.classification?a(c.classification):"",k=[];c.has_image&&k.push({label:l.tagImage,cls:"bim-sr-tag--img"}),(c.has_text||c.has_collated)&&k.push({label:l.tagText,cls:""}),c.loss_status==="lost"&&k.push({label:l.tagLost,cls:"bim-sr-tag--lost"});const y=[x,g,b].filter(Boolean).join(" · ");return e.jsxs("tr",{children:[e.jsxs("td",{className:"bim-sr-c-title",children:[e.jsxs("div",{className:"bim-sr-tl",children:[e.jsx("a",{href:p(c.id),onClick:j=>r(c,j),children:e.jsx(ds,{text:d,query:n?a(n):void 0})}),u&&e.jsx("span",{className:"bim-sr-measure",children:u})]}),y&&e.jsx("span",{className:"bim-sr-sub",children:y})]}),e.jsxs("td",{className:"bim-sr-c-type",children:[e.jsx(Ot,{type:c.type,size:6})," ",o(c.type)]}),e.jsx("td",{className:"bim-sr-c-who",children:x||"—"}),e.jsx("td",{className:"bim-sr-c-era",children:g||"—"}),e.jsx("td",{className:"bim-sr-c-cls",children:b||"—"}),e.jsx("td",{className:"bim-sr-c-res",children:k.map(j=>e.jsx("span",{className:`bim-sr-tag ${j.cls}`,children:a(j.label)},j.label))})]},c.id)})})]})})},Rc=`
|
|
2
2
|
.bim-sc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 10px; }
|
|
3
3
|
.bim-sc { display: flex; flex-direction: column; min-width: 0; padding: 14px 16px 12px; border: 1px solid ${i("rule")}; background: ${i("card-bg")}; color: inherit; text-decoration: none; }
|
|
4
4
|
.bim-sc:hover { border-color: ${i("rule-dashed")}; box-shadow: ${i("fr-shadow")}; }
|
package/dist/index.d.ts
CHANGED
|
@@ -5039,6 +5039,8 @@ export declare interface TextVersion {
|
|
|
5039
5039
|
kind: TextKind;
|
|
5040
5040
|
/** 下拉显示名——只写来源(整理本/維基文庫/維基文庫 2) */
|
|
5041
5041
|
label: string;
|
|
5042
|
+
/** 版本名(底本):「四部叢刊本」「文淵閣四庫全書本」;可选,没有就不写(book-text 901182c50b) */
|
|
5043
|
+
edition_label?: string;
|
|
5042
5044
|
/** 来源短名:collated/wikisource/kanripo/shidian… */
|
|
5043
5045
|
source?: string;
|
|
5044
5046
|
source_name?: string;
|
|
@@ -5051,10 +5053,11 @@ export declare interface TextVersion {
|
|
|
5051
5053
|
}
|
|
5052
5054
|
|
|
5053
5055
|
/**
|
|
5054
|
-
*
|
|
5056
|
+
* 读者看得懂的版本名。有 edition_label 时写「版本名 · 来源名」(如「四部叢刊本 · Kanripo」,overview#307);
|
|
5057
|
+
* 没有时只写来源:label 为空或是类别词(如数据里整理本的 label「整理本」)时改用来源名,再按 key。
|
|
5055
5058
|
* 整理本的来源名是「開源古籍」,所以下拉里写「開源古籍」而不是「整理本」。
|
|
5056
5059
|
*/
|
|
5057
|
-
export declare function textVersionLabel(v: Pick<TextVersion, 'label' | 'source_name' | 'key'>): string;
|
|
5060
|
+
export declare function textVersionLabel(v: Pick<TextVersion, 'label' | 'source_name' | 'key' | 'edition_label'>): string;
|
|
5058
5061
|
|
|
5059
5062
|
/**
|
|
5060
5063
|
* 内联在 <head> 的首屏脚本:存的是 indigo/ink 才改 data-theme、存的是 boxed 才改 data-layout,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as li, i as Et, p as wo, m as ra, t as Nn, a as oa } from "./storage-entry-
|
|
2
|
-
import { B as Gg, b as Yg, c as Vg, d as Kg, f as qg, C as Jg, G as Zg, I as Xg, g as Qg, L as ef, M as tf, S as nf, h as rf, j as of, k as lf, l as af, n as sf, o as cf, q as df, r as pf, s as uf, u as mf, v as hf, w as gf, x as ff, y as bf, z as xf, A as yf, D as vf } from "./storage-entry-
|
|
1
|
+
import { e as li, i as Et, p as wo, m as ra, t as Nn, a as oa } from "./storage-entry-BezDJLqe.js";
|
|
2
|
+
import { B as Gg, b as Yg, c as Vg, d as Kg, f as qg, C as Jg, G as Zg, I as Xg, g as Qg, L as ef, M as tf, S as nf, h as rf, j as of, k as lf, l as af, n as sf, o as cf, q as df, r as pf, s as uf, u as mf, v as hf, w as gf, x as ff, y as bf, z as xf, A as yf, D as vf } from "./storage-entry-BezDJLqe.js";
|
|
3
3
|
import { jsx as t, jsxs as c, Fragment as P } from "react/jsx-runtime";
|
|
4
4
|
import Ye, { createContext as $o, useMemo as fe, useContext as on, useState as C, useEffect as K, useCallback as ke, useRef as We, useId as ai } from "react";
|
|
5
5
|
import { Converter as la } from "opencc-js/t2cn";
|
|
@@ -34,7 +34,7 @@ function At(r) {
|
|
|
34
34
|
function x(r) {
|
|
35
35
|
return /[A-Z]/.test(r) ? At(r) : dt(r);
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const Ht = q, zt = dt;
|
|
38
38
|
function j(r) {
|
|
39
39
|
const t = Number(r >> at & 1n), e = Number(r >> ct & vt), s = r >> lt & ut, n = Number(r >> ht & St), o = Number(r & Et);
|
|
40
40
|
return {
|
|
@@ -54,7 +54,7 @@ function U(r) {
|
|
|
54
54
|
function $t(r) {
|
|
55
55
|
return U(r).type;
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function Yt(r) {
|
|
58
58
|
return U(r).status;
|
|
59
59
|
}
|
|
60
60
|
const H = { book: "Book", collection: "Collection", work: "Work", entity: "Entity" }, jt = { Book: "book", Collection: "collection", Work: "work", Entity: "entity" }, M = 16;
|
|
@@ -586,7 +586,7 @@ const Ft = "https://raw.githubusercontent.com", Lt = [
|
|
|
586
586
|
"https://fastly.jsdelivr.net/gh",
|
|
587
587
|
"https://cdn.jsdelivr.net/gh"
|
|
588
588
|
], Rt = 5e3;
|
|
589
|
-
class
|
|
589
|
+
class Kt {
|
|
590
590
|
// null=未加载, false=不可用
|
|
591
591
|
constructor(t) {
|
|
592
592
|
this.cache = null, this.cacheLoading = null, this.pathMap = /* @__PURE__ */ new Map(), this.promotions = /* @__PURE__ */ new Map(), this.searchSCache = null, this.t2sConverter = null, this.config = {
|
|
@@ -1062,7 +1062,7 @@ class _t {
|
|
|
1062
1062
|
return s;
|
|
1063
1063
|
}
|
|
1064
1064
|
}
|
|
1065
|
-
class
|
|
1065
|
+
class Vt {
|
|
1066
1066
|
constructor(t) {
|
|
1067
1067
|
this.recentEntities = [], this.storage = new gt(t.fs, t.workspaceRoot), this.idGen = new _t(t.machineId ?? 0), this.fs = t.fs, this.workspaceRoot = t.workspaceRoot;
|
|
1068
1068
|
}
|
|
@@ -1329,21 +1329,26 @@ const Dt = ["default", "manifest", "fragments", "sources"], Mt = /^[a-z][a-z0-9-
|
|
|
1329
1329
|
function nt(r) {
|
|
1330
1330
|
return typeof r != "string" ? !1 : r === "default" ? !0 : Mt.test(r) && !Dt.includes(r);
|
|
1331
1331
|
}
|
|
1332
|
-
function
|
|
1332
|
+
function Xt(r) {
|
|
1333
1333
|
return /^\d+$/.test(r);
|
|
1334
1334
|
}
|
|
1335
1335
|
function W(r) {
|
|
1336
1336
|
return r.length > 0 && !r.includes("..") && !/[\\/?#%\s\u0000-\u001f\u007f]/.test(r);
|
|
1337
1337
|
}
|
|
1338
1338
|
const Ut = /^(整理本|整理|转录全文|轉錄全文|转录|轉錄|全文|文本)$/;
|
|
1339
|
-
function
|
|
1339
|
+
function Qt(r) {
|
|
1340
|
+
var s;
|
|
1341
|
+
const t = Ot(r), e = (s = r.edition_label) == null ? void 0 : s.trim();
|
|
1342
|
+
return e && e !== t ? `${e} · ${t}` : t;
|
|
1343
|
+
}
|
|
1344
|
+
function Ot(r) {
|
|
1340
1345
|
for (const t of [r.label, r.source_name]) {
|
|
1341
1346
|
const e = t == null ? void 0 : t.trim();
|
|
1342
1347
|
if (e && !Ut.test(e)) return e;
|
|
1343
1348
|
}
|
|
1344
1349
|
return r.label || r.source_name || r.key;
|
|
1345
1350
|
}
|
|
1346
|
-
function
|
|
1351
|
+
function Zt(r, t) {
|
|
1347
1352
|
const e = (t == null ? void 0 : t.chapters) ?? [];
|
|
1348
1353
|
if (e.length === 0) return null;
|
|
1349
1354
|
if (r) {
|
|
@@ -1356,15 +1361,15 @@ function Qt(r, t) {
|
|
|
1356
1361
|
}
|
|
1357
1362
|
return e[0].file;
|
|
1358
1363
|
}
|
|
1359
|
-
function
|
|
1364
|
+
function te(r, t) {
|
|
1360
1365
|
const e = r == null ? void 0 : r.versions;
|
|
1361
1366
|
if (!(!e || e.length === 0))
|
|
1362
1367
|
return (t != null ? e.find((s) => s.key === t) : void 0) ?? e.find((s) => s.key === "default") ?? e[0];
|
|
1363
1368
|
}
|
|
1364
|
-
const
|
|
1365
|
-
class
|
|
1369
|
+
const Nt = "/data", Wt = 1e4;
|
|
1370
|
+
class ee {
|
|
1366
1371
|
constructor(t = {}) {
|
|
1367
|
-
this.chunkCache = /* @__PURE__ */ new Map(), this.chunkLoading = /* @__PURE__ */ new Map(), this.manifest = null, this.manifestLoading = null, this.tiyaoCache = /* @__PURE__ */ new Map(), this.tiyaoLoading = /* @__PURE__ */ new Map(), this.metaCache = null, this.metaLoading = null, this.promotions = null, this.promotionsLoading = null, this.versionPromise = null, this.versionInjected = !1, this.basePath = t.basePath ??
|
|
1372
|
+
this.chunkCache = /* @__PURE__ */ new Map(), this.chunkLoading = /* @__PURE__ */ new Map(), this.manifest = null, this.manifestLoading = null, this.tiyaoCache = /* @__PURE__ */ new Map(), this.tiyaoLoading = /* @__PURE__ */ new Map(), this.metaCache = null, this.metaLoading = null, this.promotions = null, this.promotionsLoading = null, this.versionPromise = null, this.versionInjected = !1, this.basePath = t.basePath ?? Nt, this.timeout = t.timeout ?? Wt, t.version !== void 0 && (this.version = t.version ?? null, this.versionInjected = !0);
|
|
1368
1373
|
}
|
|
1369
1374
|
// ─── 内部工具 ───
|
|
1370
1375
|
/**
|
|
@@ -1695,27 +1700,27 @@ class O extends Error {
|
|
|
1695
1700
|
super(t), this.name = "BookIndexError";
|
|
1696
1701
|
}
|
|
1697
1702
|
}
|
|
1698
|
-
class
|
|
1703
|
+
class se extends O {
|
|
1699
1704
|
constructor(t) {
|
|
1700
1705
|
super(t), this.name = "StorageError";
|
|
1701
1706
|
}
|
|
1702
1707
|
}
|
|
1703
|
-
class
|
|
1708
|
+
class ne extends O {
|
|
1704
1709
|
constructor(t) {
|
|
1705
1710
|
super(t), this.name = "IdGenerationError";
|
|
1706
1711
|
}
|
|
1707
1712
|
}
|
|
1708
|
-
class
|
|
1713
|
+
class oe extends O {
|
|
1709
1714
|
constructor(t) {
|
|
1710
1715
|
super(t), this.name = "ConfigError";
|
|
1711
1716
|
}
|
|
1712
1717
|
}
|
|
1713
|
-
class
|
|
1718
|
+
class ie extends O {
|
|
1714
1719
|
constructor(t) {
|
|
1715
1720
|
super(t), this.name = "MigrationError";
|
|
1716
1721
|
}
|
|
1717
1722
|
}
|
|
1718
|
-
class
|
|
1723
|
+
class re {
|
|
1719
1724
|
constructor(t, e, s = 1) {
|
|
1720
1725
|
this.storage = new gt(t, e), this.idGen = new _t(s);
|
|
1721
1726
|
}
|
|
@@ -1803,7 +1808,7 @@ class ie {
|
|
|
1803
1808
|
return this.storage;
|
|
1804
1809
|
}
|
|
1805
1810
|
}
|
|
1806
|
-
const
|
|
1811
|
+
const Jt = {
|
|
1807
1812
|
wikisource: "wikisource",
|
|
1808
1813
|
shidianguji: "shidianguji",
|
|
1809
1814
|
archive: "archive",
|
|
@@ -1813,16 +1818,16 @@ const Wt = {
|
|
|
1813
1818
|
"db.sido": "sido",
|
|
1814
1819
|
"guji.artx": "guji-artx",
|
|
1815
1820
|
"digital.library": "digital-library"
|
|
1816
|
-
}, ot = /* @__PURE__ */ new Set(["text", "image", "text+image", "physical"]), it = /* @__PURE__ */ new Set(["text", "image", "physical"]),
|
|
1817
|
-
function
|
|
1821
|
+
}, ot = /* @__PURE__ */ new Set(["text", "image", "text+image", "physical"]), it = /* @__PURE__ */ new Set(["text", "image", "physical"]), qt = /* @__PURE__ */ new Set(["catalog", "search"]), Gt = /* @__PURE__ */ new Set(["com", "org", "net", "cn", "edu", "gov", "io", "jp", "tw", "hk"]);
|
|
1822
|
+
function ae(r) {
|
|
1818
1823
|
if (!r) return "";
|
|
1819
1824
|
try {
|
|
1820
1825
|
const e = new URL(r).hostname;
|
|
1821
|
-
for (const [n, o] of Object.entries(
|
|
1826
|
+
for (const [n, o] of Object.entries(Jt))
|
|
1822
1827
|
if (e.includes(n)) return o;
|
|
1823
1828
|
const s = e.split(".");
|
|
1824
1829
|
if (s.length >= 2) {
|
|
1825
|
-
const n = s.filter((o) => !
|
|
1830
|
+
const n = s.filter((o) => !Gt.has(o) && o.length > 2);
|
|
1826
1831
|
return n.length > 0 ? n[n.length - 1] : s[s.length - 2];
|
|
1827
1832
|
}
|
|
1828
1833
|
return e;
|
|
@@ -1830,7 +1835,7 @@ function re(r) {
|
|
|
1830
1835
|
return "";
|
|
1831
1836
|
}
|
|
1832
1837
|
}
|
|
1833
|
-
function
|
|
1838
|
+
function ce(r) {
|
|
1834
1839
|
const t = [];
|
|
1835
1840
|
r.name || t.push("name is required");
|
|
1836
1841
|
let e = !1;
|
|
@@ -1843,7 +1848,7 @@ function ae(r) {
|
|
|
1843
1848
|
e = r.types.length === 1 && r.types[0] === "physical";
|
|
1844
1849
|
}
|
|
1845
1850
|
else r.type !== void 0 ? (ot.has(r.type) || t.push(`invalid type '${r.type}', must be one of ${[...ot].join(", ")}`), e = r.type === "physical") : t.push("either type or types is required");
|
|
1846
|
-
return r.root_type && !
|
|
1851
|
+
return r.root_type && !qt.has(r.root_type) && t.push(`invalid root_type '${r.root_type}'`), !e && !r.url && t.push("url is required for non-physical resources"), t;
|
|
1847
1852
|
}
|
|
1848
1853
|
const b = class b {
|
|
1849
1854
|
constructor(t, e = "") {
|
|
@@ -1892,35 +1897,35 @@ let rt = b;
|
|
|
1892
1897
|
export {
|
|
1893
1898
|
x as A,
|
|
1894
1899
|
rt as B,
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1900
|
+
oe as C,
|
|
1901
|
+
ce as D,
|
|
1902
|
+
Kt as G,
|
|
1903
|
+
ne as I,
|
|
1904
|
+
Vt as L,
|
|
1905
|
+
ie as M,
|
|
1906
|
+
se as S,
|
|
1902
1907
|
$t as a,
|
|
1903
1908
|
O as b,
|
|
1904
|
-
|
|
1909
|
+
re as c,
|
|
1905
1910
|
gt as d,
|
|
1906
|
-
|
|
1907
|
-
|
|
1911
|
+
Yt as e,
|
|
1912
|
+
ee as f,
|
|
1908
1913
|
_t as g,
|
|
1909
1914
|
dt as h,
|
|
1910
1915
|
W as i,
|
|
1911
1916
|
q as j,
|
|
1912
1917
|
At as k,
|
|
1913
1918
|
Q as l,
|
|
1914
|
-
|
|
1919
|
+
Zt as m,
|
|
1915
1920
|
mt as n,
|
|
1916
1921
|
Pt as o,
|
|
1917
|
-
|
|
1918
|
-
|
|
1922
|
+
te as p,
|
|
1923
|
+
zt as q,
|
|
1919
1924
|
U as r,
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1925
|
+
Ht as s,
|
|
1926
|
+
Qt as t,
|
|
1927
|
+
ae as u,
|
|
1928
|
+
Xt as v,
|
|
1924
1929
|
nt as w,
|
|
1925
1930
|
pt as x,
|
|
1926
1931
|
j as y,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var St=Object.create;var it=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var jt=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Et(t))!$t.call(r,n)&&n!==e&&it(r,n,{get:()=>t[n],enumerable:!(s=vt(t,n))||s.enumerable});return r};var Pt=(r,t,e)=>(e=r!=null?St(At(r)):{},jt(t||!r||!r.__esModule?it(e,"default",{value:r,enumerable:!0}):e,r));const Tt={official:0,draft:1},Ct={0:"official",1:"draft"},Bt={book:0,collection:2,work:3,entity:4},Ft={0:"book",2:"collection",3:"work",4:"entity"},dt=62n,yt=59n,gt=19n,pt=8n,mt=(1n<<40n)-1n,Lt=(1n<<3n)-1n,Rt=(1n<<11n)-1n,Dt=(1n<<8n)-1n,H="0123456789abcdefghijklmnopqrstuvwxyz",_t=new Map;for(let r=0;r<H.length;r++)_t.set(H[r],BigInt(r));function W(r){if(r===0n)return H[0];let t="";for(;r>0n;)t=H[Number(r%36n)]+t,r=r/36n;return t}function Z(r){let t=0n;for(const e of r){const s=_t.get(e);if(s===void 0)throw new Error(`Invalid Base36 character: ${e}`);t=t*36n+s}return t}const rt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",wt=new Map;for(let r=0;r<rt.length;r++)wt.set(rt[r],BigInt(r));function bt(r){let t=0n;for(const e of r){const s=wt.get(e);if(s===void 0)throw new Error(`Invalid Base58 character: ${e}`);t=t*58n+s}return t}function I(r){return/[A-Z]/.test(r)?bt(r):Z(r)}const Mt=W,Ut=Z;function A(r){const t=Number(r>>dt&1n),e=Number(r>>yt&Lt),s=r>>gt&mt,n=Number(r>>pt&Rt),o=Number(r&Dt);return{status:Ct[t]??"draft",type:Ft[e]??"book",timestamp:s,machineId:n,sequence:o}}function K(r,t,e,s,n){return BigInt(Tt[r])<<dt|BigInt(Bt[t])<<yt|(e&mt)<<gt|BigInt(s)<<pt|BigInt(n)}function F(r){return A(I(r))}function kt(r){return F(r).type}function Ot(r){return F(r).status}const z={book:"Book",collection:"Collection",work:"Work",entity:"Entity"},Nt={Book:"book",Collection:"collection",Work:"work",Entity:"entity"},N=16;function G(r,t=N){let e=0;for(let s=0;s<r.length;s++)e=Math.imul(e,31)+r.charCodeAt(s)>>>0;return e%t}function at(r){const t={},e=r.dating;if(typeof e!="object"||e===null)return t;const s=e.era;typeof s=="string"&&s&&(t.era=s);const n=e.year;if(typeof n=="number")t.sort_year=n;else{const o=e.year_range;Array.isArray(o)&&o.length===2&&typeof o[0]=="number"&&(t.sort_year=o[0])}return t}function k(...r){const t=r.join("/");return t.startsWith("//")?"//"+t.slice(2).replace(/\/+/g,"/"):t.replace(/\/+/g,"/")}function It(r){return r.replace(/[^㐀-䶿一-鿿豈-a-zA-Z0-9\u{20000}-\u{3134f}]/gu,"")||"Undefined"}class tt{constructor(t,e){this.fs=t,this.officialRoot=k(e,"book-index"),this.draftRoot=k(e,"book-index-draft")}getRootByStatus(t){return t==="draft"?this.draftRoot:this.officialRoot}getRootById(t){const e=I(t),s=A(e);return this.getRootByStatus(s.status)}getPath(t,e,s){const n=this.getRootById(e),o=e.padEnd(3,"_").substring(0,3),[i,c,a]=[o[0],o[1],o[2]],h=z[t];return k(n,h,i,c,a,`${e}-${It(s)}.json`)}async saveItem(t,e,s){const n=s.title||s.书名||"未命名",o=s.edition||"",i=o?`${n}${o}`:n,c=this.getPath(t,e,i),a=await this.findFileById(e);if(a&&a!==c)try{await this.fs.deleteFile(a)}catch{}const h=c.substring(0,c.lastIndexOf("/"));await this.fs.mkdir(h),s.id=e,s.type=t,await this.fs.writeFile(c,JSON.stringify(s,Wt,2));const u=this.getRootById(e),l=c.substring(u.length+1);return await this.updateIndexEntry(u,s,t,l),c}async updateIndexEntry(t,e,s,n){const o=e.id||"";if(!o)return;const i=`${s}s`,c=await this.loadShard(t,i,o);let a="",h="",u="";const l=e.authors;if(Array.isArray(l)&&l.length>0){const y=l[0];typeof y=="object"&&y!==null?(a=y.name||"",h=y.dynasty||"",u=y.role||""):a=String(y)}else typeof l=="string"&&(a=l);!h&&typeof e.dynasty=="string"&&(h=e.dynasty);let f="";const d=e.current_location;typeof d=="object"&&d!==null?f=d.name||"":typeof d=="string"&&(f=d);const _=Array.isArray(e.additional_titles)?e.additional_titles.map(y=>typeof y=="string"?y:y==null?void 0:y.book_title).filter(Boolean):void 0,w=Array.isArray(e.attached_texts)?e.attached_texts.map(y=>typeof y=="string"?y:y==null?void 0:y.book_title).filter(Boolean):void 0;let S;const x=e.juan_count;typeof x=="number"?S=x:typeof x=="object"&&x!==null&&(S=x.number||void 0);const P=typeof e.measure_info=="string"?e.measure_info:"";let $=!1,v=!1;const E=e.resources;if(Array.isArray(E))for(const y of E){if(typeof y!="object"||y===null)continue;const B=y.types;if(Array.isArray(B))B.includes("text")&&($=!0),B.includes("image")&&(v=!0);else{const j=y.type;(j==="text"||j==="text+image")&&($=!0),(j==="image"||j==="text+image")&&(v=!0)}}const p={id:o,title:e.title||"未命名",type:z[s],path:n,author:a,holder:f,...at(e)};_&&_.length>0&&(p.additional_titles=_),w&&w.length>0&&(p.attached_texts=w),S&&(p.juan_count=S),P&&(p.measure_info=P);const T=typeof e.edition=="string"?e.edition:"";T&&(p.edition=T),$&&(p.has_text=!0),v&&(p.has_image=!0),h&&(p.dynasty=h),u&&(p.role=u);const C=typeof e.subtype=="string"?e.subtype:"";C&&(p.subtype=C);const R=typeof e.period=="string"?e.period:"";R&&(p.period=R);const m=typeof e.loss_status=="string"?e.loss_status:"";m&&(p.loss_status=m);const D=typeof e.original_title=="string"?e.original_title:"";D&&(p.original_title=D);const M=typeof e.work_id=="string"?e.work_id:"";M&&(p.work_id=M);const U=typeof e._promoted_to=="string"?e._promoted_to:typeof e.promoted_to=="string"?e.promoted_to:"";U&&(p.promoted_to=U),c[o]=p,await this.saveShard(t,i,o,c)}async deleteItem(t){const e=await this.findFileById(t);if(!e)return!1;const s=I(t),n=A(s),o=this.getRootByStatus(n.status),i=`${n.type}s`,c=await this.loadShard(o,i,t);return c[t]&&(delete c[t],await this.saveShard(o,i,t,c)),await this.fs.deleteFile(e),!0}async findFileById(t){const e=t.padEnd(3,"_").substring(0,3),[s,n,o]=[e[0],e[1],e[2]];for(const i of[this.officialRoot,this.draftRoot])for(const c of["Book","Collection","Work"]){const a=k(i,c,s,n,o);if(await this.fs.exists(a))try{const u=(await this.fs.readdir(a)).find(l=>l.startsWith(`${t}-`)&&l.endsWith(".json"));if(u)return k(a,u)}catch{}}return null}async loadMetadata(t){try{const e=await this.fs.readFile(t);return JSON.parse(e)}catch{return{}}}async getItem(t){const e=await this.findFileById(t);if(!e)return null;const s=await this.loadMetadata(e);return Object.keys(s).length>0?s:null}async loadEntries(t,e){const s=e?[this.getRootByStatus(e)]:[this.officialRoot,this.draftRoot],n=[],o=`${t}s`;for(const i of s){const c=await this.loadAllShards(i,o);for(const[a,h]of Object.entries(c))n.push({id:a,title:h.title,type:t,author:h.author||void 0,dynasty:h.dynasty||void 0,role:h.role||void 0,path:k(i,h.path),additional_titles:h.additional_titles,attached_texts:h.attached_texts,edition:h.edition,juan_count:h.juan_count,has_text:h.has_text,has_image:h.has_image,era:h.era,sort_year:h.sort_year})}return n}async searchEntries(t,e,s){const n=await this.loadEntries(e,s);return V(n,t)}async searchAll(t,e=5,s){const n=["work","book","collection"],o=await Promise.all(n.map(i=>this.searchEntries(t,i,s)));return{works:o[0].slice(0,e),books:o[1].slice(0,e),collections:o[2].slice(0,e),totalWorks:o[0].length,totalBooks:o[1].length,totalCollections:o[2].length}}async rebuildIndex(t){var n;const e=this.getRootByStatus(t),s={books:Object.fromEntries(Array.from({length:N},(o,i)=>[i,{}])),collections:{0:{}},works:Object.fromEntries(Array.from({length:N},(o,i)=>[i,{}]))};for(const o of["Book","Collection","Work"]){const i=k(e,o);if(!await this.fs.exists(i))continue;const a=`${Nt[o]}s`,h=await this.fs.glob(i,"**/*.json");for(const u of h)if(!u.includes("/index/"))try{const l=await this.loadMetadata(u);let f=l.id||l.ID||"";if(!f){const g=u.substring(u.lastIndexOf("/")+1);g.includes("-")&&(f=g.split("-")[0])}if(!f)continue;const d=u.substring(e.length+1);let _="",w="",S="";const x=l.authors;if(Array.isArray(x)&&x.length>0){const g=x[0];typeof g=="object"&&g!==null?(_=g.name||"",w=g.dynasty||"",S=g.role||""):_=String(g)}!w&&typeof l.dynasty=="string"&&(w=l.dynasty);const P=Array.isArray(l.additional_titles)?l.additional_titles.map(g=>typeof g=="string"?g:g==null?void 0:g.book_title).filter(Boolean):void 0,$=Array.isArray(l.attached_texts)?l.attached_texts.map(g=>typeof g=="string"?g:g==null?void 0:g.book_title).filter(Boolean):void 0;let v;const E=l.juan_count;typeof E=="number"?v=E:typeof E=="object"&&E!==null&&(v=E.number||void 0);const p=typeof l.measure_info=="string"?l.measure_info:"";let T=!1,C=!1;const R=l.resources;if(Array.isArray(R))for(const g of R){if(typeof g!="object"||g===null)continue;const q=g.types;if(Array.isArray(q))q.includes("text")&&(T=!0),q.includes("image")&&(C=!0);else{const J=g.type;(J==="text"||J==="text+image")&&(T=!0),(J==="image"||J==="text+image")&&(C=!0)}}const m={id:f,title:l.title||"未命名",type:o,path:d,author:_,holder:typeof l.current_location=="object"&&((n=l.current_location)==null?void 0:n.name)||"",...at(l)};P&&P.length>0&&(m.additional_titles=P),$&&$.length>0&&(m.attached_texts=$),v&&(m.juan_count=v),p&&(m.measure_info=p);const D=typeof l.edition=="string"?l.edition:"";D&&(m.edition=D),T&&(m.has_text=!0),C&&(m.has_image=!0),w&&(m.dynasty=w),S&&(m.role=S);const M=typeof l.subtype=="string"?l.subtype:"";M&&(m.subtype=M);const U=typeof l.period=="string"?l.period:"";U&&(m.period=U);const y=typeof l.loss_status=="string"?l.loss_status:"";y&&(m.loss_status=y);const B=typeof l.original_title=="string"?l.original_title:"";B&&(m.original_title=B);const j=typeof l.work_id=="string"?l.work_id:"";j&&(m.work_id=j);const ot=typeof l._promoted_to=="string"?l._promoted_to:typeof l.promoted_to=="string"?l.promoted_to:"";ot&&(m.promoted_to=ot);const xt=a==="collections"?0:G(f);s[a][xt][f]=m}catch{}}for(const[o,i]of Object.entries(s))for(const[c,a]of Object.entries(i)){const h=this.shardPath(e,o,Number(c)),u=h.substring(0,h.lastIndexOf("/"));await this.fs.mkdir(u),await this.fs.writeFile(h,JSON.stringify(ct(a),null,await this.detectShardIndent(h)))}}getAssetDir(t){const e=this.getRootById(t),s=I(t),o=A(s).type,i=t.padEnd(3,"_").substring(0,3),[c,a,h]=[i[0],i[1],i[2]],u=z[o];return k(e,u,c,a,h,t)}async initAssetDir(t){const e=this.getAssetDir(t);return await this.fs.mkdir(e),e}async hasAssetDir(t){const e=this.getAssetDir(t);return this.fs.exists(e)}shardPath(t,e,s){return e==="collections"?k(t,"index","collections.json"):k(t,"index",e,`${s.toString(16)}.json`)}async loadShard(t,e,s){const n=G(s),o=this.shardPath(t,e,n);try{if(!await this.fs.exists(o))return{};const i=await this.fs.readFile(o);return JSON.parse(i)}catch{return{}}}async detectShardIndent(t,e=2){try{if(!await this.fs.exists(t))return e;const n=(await this.fs.readFile(t)).split(`
|
|
2
|
-
`)[1];if(n===void 0)return e;const o=n.replace(/^ +/,"");return!o||o.startsWith("}")?e:n.length-o.length||e}catch{return e}}async saveShard(t,e,s,n){const o=G(s),i=this.shardPath(t,e,o),c=i.substring(0,i.lastIndexOf("/"));await this.fs.mkdir(c);const a=await this.detectShardIndent(i);await this.fs.writeFile(i,JSON.stringify(ct(n),null,a))}async loadAllShards(t,e){const s={};if(e==="collections"){const n=this.shardPath(t,e,0);try{if(await this.fs.exists(n)){const o=await this.fs.readFile(n);Object.assign(s,JSON.parse(o))}}catch{}return s}for(let n=0;n<N;n++){const o=this.shardPath(t,e,n);try{if(await this.fs.exists(o)){const i=await this.fs.readFile(o);Object.assign(s,JSON.parse(i))}}catch{}}return s}}function Y(r,t){const e=t.toLowerCase();let s=0;const n=r.title.toLowerCase();n===e?s=200:n.startsWith(e)?s=150:n.includes(e)&&(s=100);const o=[...r.additional_titles||[],...r.attached_texts||[]];for(const h of o){const u=h.toLowerCase();u===e?s=Math.max(s,120):u.startsWith(e)?s=Math.max(s,90):u.includes(e)&&(s=Math.max(s,60))}let i=0;if(r.author){const h=r.author.toLowerCase();h===e?i=80:h.includes(e)&&(i=50)}let c=0;r.dynasty&&r.dynasty.toLowerCase().includes(e)&&(c=30);let a=s;return a===0&&(a=Math.max(i,c)),a===0?0:(a+=Math.max(0,20-n.length),r.type==="work"?a=Math.round(a*1.05):r.type==="collection"&&(a=Math.round(a*1.02)),r.has_text&&(a+=3),r.has_image&&(a+=2),a)}function ct(r){const t={};for(const e of Object.keys(r).sort())t[e]=r[e];return t}function Wt(r,t){return t===null?void 0:t}function V(r,t){const e=r.map(s=>({entry:s,score:Y(s,t)})).filter(s=>s.score>0);return e.sort((s,n)=>n.score!==s.score?n.score-s.score:s.entry.title.length-n.entry.title.length),e.map(s=>s.entry)}function lt(r,t,e,s){const n=r.map(o=>{const i=Y(o,t);let c=0;const a=s[o.id];if(a&&e){const h={...o,title:a.t??o.title,author:a.a??o.author,additional_titles:a.at??o.additional_titles,attached_texts:a.axt??o.attached_texts};c=Y(h,e)}return{entry:o,score:Math.max(i,c)}}).filter(o=>o.score>0);return n.sort((o,i)=>i.score!==o.score?i.score-o.score:o.entry.title.length-i.entry.title.length),n.map(o=>o.entry)}function Jt(r){const t=r.volumes??[];let e,s;if(t.length===0)e=[];else if(typeof t[0]=="number")e=t;else{s=[],e=[];for(const o of t){const i=o.volume;e.push(i);const c={};for(const[a,h]of Object.entries(o))a==="volume"||a==="status"||a==="file"||typeof h=="string"&&(a.includes("url")||a.includes("id"))&&(c[a]=h);s.push({volume:i,status:o.status,urls:Object.keys(c).length>0?c:void 0,file:o.file})}}const n={title:r.title??"",book_id:r.book_id??null,work_id:r.work_id??null,volumes:e,section:r.section,sub_items:r.sub_items,edition:r.edition,expected_volumes:r.expected_volumes,found_volumes:r.found_volumes,missing_volumes:r.missing_vols??r.missing_volumes};s&&(n.volume_details=s);for(const o of Object.keys(n))n[o]===void 0&&delete n[o];return n}function Gt(r){const t={total_books:r.total_books??0};return r.processed_volumes!=null&&(t.processed_volumes=r.processed_volumes),r.matched_works!=null&&(t.matched_works=r.matched_works),r.unmatched_works!=null&&(t.unmatched_works=r.unmatched_works),r.total_found_volumes!=null&&(t.total_found_volumes=r.total_found_volumes),t}function et(r){var n;const t=r,e=(t.books??[]).map(Jt),s={collection_id:t.collection_id??"",title:t.title??"",total_volumes:t.total_volumes??0,stats:Gt(t.stats??{}),books:e};return t.source&&(s.source=t.source),t.resource_id&&(s.resource_id=t.resource_id),t.resource_name&&(s.resource_name=t.resource_name),(n=t.sections)!=null&&n.length&&(s.sections=t.sections),t.volume_index&&Object.keys(t.volume_index).length>0&&(s.volume_index=t.volume_index),s}function st(r){const t=new Map;if(!r||typeof r!="object")return t;const e=r;if(typeof e.version!="number")return console.warn("[promotions] missing version field; treating as empty"),t;if(e.version!==1)return console.warn(`[promotions] unknown version ${e.version}; treating as empty`),t;const s=e.promotions;if(!s||typeof s!="object")return t;for(const[n,o]of Object.entries(s))o&&typeof o=="object"&&typeof o.production_id=="string"&&t.set(n,o.production_id);return t}const Ht="https://raw.githubusercontent.com",qt=["https://fastly.jsdelivr.net/gh","https://cdn.jsdelivr.net/gh"],zt=5e3;class Kt{constructor(t){this.cache=null,this.cacheLoading=null,this.pathMap=new Map,this.promotions=new Map,this.searchSCache=null,this.t2sConverter=null,this.config={org:t.org,repos:t.repos,baseUrl:t.baseUrl??Ht,cdnUrls:t.cdnUrls??qt,timeout:t.timeout??zt}}async fetchPromotions(){try{const t=await this.fetchFileWithFallback(this.config.repos.draft,"promotions.json");return st(t)}catch{return new Map}}async ensureLoaded(){if(this.cache)return this.cache;if(this.cacheLoading)return this.cacheLoading;this.cacheLoading=(async()=>{const[t,e,s]=await Promise.all([this.fetchPromotions(),this.fetchIndex(this.config.repos.draft).catch(i=>(console.warn("Failed to fetch draft index:",i),{books:{},collections:{},works:{}})),this.fetchIndex(this.config.repos.official).catch(i=>(console.warn("Failed to fetch official index:",i),{books:{},collections:{},works:{}}))]);this.promotions=t;const n=[...this.parseIndexResponse(e,!0),...this.parseIndexResponse(s,!1)],o=new Map;for(const i of n)i.isDraft&&i.promoted_to||o.set(i.id,i);return this.cache=Array.from(o.values()),this.cache})();try{return await this.cacheLoading}finally{this.cache||(this.cacheLoading=null)}}async fetchFileWithFallback(t,e){const s=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(e)}`;try{return await this.fetchJson(s)}catch{}for(const n of this.config.cdnUrls){const o=`${n}/${this.config.org}/${t}@main/${encodeURI(e)}`;try{return await this.fetchJson(o)}catch{continue}}throw new Error(`Failed to fetch ${e} for ${t} from all sources`)}async probeIndex(t){const e="index/collections.json",s=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(e)}`;try{if((await fetch(s,{method:"HEAD",signal:AbortSignal.timeout(this.config.timeout)})).ok)return!0}catch{}for(const i of this.config.cdnUrls){const c=`${i}/${this.config.org}/${t}@main/${encodeURI(e)}`;try{if((await fetch(c,{method:"HEAD",signal:AbortSignal.timeout(this.config.timeout)})).ok)return!0}catch{continue}}const n="index/works/0.json",o=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(n)}`;try{if((await fetch(o,{method:"HEAD",signal:AbortSignal.timeout(this.config.timeout)})).ok)return!0}catch{}for(const i of this.config.cdnUrls){const c=`${i}/${this.config.org}/${t}@main/${encodeURI(n)}`;try{if((await fetch(c,{method:"HEAD",signal:AbortSignal.timeout(this.config.timeout)})).ok)return!0}catch{continue}}return!1}async fetchIndex(t){if(!await this.probeIndex(t))return{books:{},collections:{},works:{}};const s={books:{},collections:{},works:{}};try{const o=await this.fetchFileWithFallback(t,"index/collections.json");s.collections=o}catch{}const n=[];for(const o of["books","works"])for(let i=0;i<N;i++){const c=`index/${o}/${i.toString(16)}.json`;n.push(this.fetchFileWithFallback(t,c).then(a=>{Object.assign(s[o],a)}).catch(()=>{}))}return await Promise.all(n),s}async fetchJson(t){const e=await fetch(t,{cache:"no-store",signal:AbortSignal.timeout(this.config.timeout)});if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}parseIndexResponse(t,e){var o,i;const s=[],n=[["books","book"],["collections","collection"],["works","work"],["entities","entity"]];for(const[c,a]of n){const h=t[c];if(h)for(const u of Object.values(h)){const l=u,f=a==="entity"?l.primary_name||u.title||u.name||u.id:u.title||u.name||u.id;s.push({id:u.id,title:f,type:a,isDraft:e,author:u.author,dynasty:u.dynasty,role:u.role,path:u.path,additional_titles:(o=l.additional_titles)==null?void 0:o.map(d=>typeof d=="string"?d:d==null?void 0:d.book_title).filter(Boolean),attached_texts:(i=l.attached_texts)==null?void 0:i.map(d=>typeof d=="string"?d:d==null?void 0:d.book_title).filter(Boolean),edition:l.edition,juan_count:l.juan_count,has_text:l.has_text,has_image:l.has_image,has_collated:l.has_collated,subtype:l.subtype,primary_name:l.primary_name,birth_year:l.birth_year,death_year:l.death_year,cbdb_id:l.cbdb_id,promoted_to:l.promoted_to}),this.pathMap.set(u.id,{path:u.path,isDraft:e})}}return s}async ensureSearchSBuilt(){var n,o;if(this.searchSCache)return{searchS:this.searchSCache,converter:this.t2sConverter||null};if(this.t2sConverter===!1)return{searchS:{},converter:null};try{const i=await import("opencc-js");this.t2sConverter=i.Converter({from:"tw",to:"cn"})}catch{return this.t2sConverter=!1,this.searchSCache={},{searchS:{},converter:null}}const t=await this.ensureLoaded(),e=this.t2sConverter,s={};for(const i of t){const c={},a=e(i.title);if(a!==i.title&&(c.t=a),i.author){const h=e(i.author);h!==i.author&&(c.a=h)}if((n=i.additional_titles)!=null&&n.length){const h=i.additional_titles.map(e);h.some((u,l)=>u!==i.additional_titles[l])&&(c.at=h)}if((o=i.attached_texts)!=null&&o.length){const h=i.attached_texts.map(e);h.some((u,l)=>u!==i.attached_texts[l])&&(c.axt=h)}Object.keys(c).length>0&&(s[i.id]=c)}return this.searchSCache=s,{searchS:s,converter:e}}async loadEntries(t,e){let n=(await this.ensureLoaded()).filter(l=>l.type===t);const o=e.sortBy||"title",i=e.sortOrder||"asc";n.sort((l,f)=>{const d=String(l[o]??""),_=String(f[o]??""),w=d.localeCompare(_,"zh");return i==="asc"?w:-w});const c=e.page||1,a=e.pageSize||50,h=(c-1)*a;return{entries:n.slice(h,h+a),total:n.length,page:c,pageSize:a}}async search(t,e,s){const n=await this.ensureLoaded(),{searchS:o,converter:i}=await this.ensureSearchSBuilt(),c=n.filter(_=>_.type===e),a=i?i(t):void 0,u=Object.keys(o).length>0?lt(c,t,a,o):V(c,t),l=s.page||1,f=s.pageSize||50,d=(l-1)*f;return{entries:u.slice(d,d+f),total:u.length,page:l,pageSize:f}}async searchAll(t,e=5){const s=await this.ensureLoaded(),{searchS:n,converter:o}=await this.ensureSearchSBuilt(),i=["work","book","collection"],c=o?o(t):void 0,a=Object.keys(n).length>0,h=i.map(u=>{const l=s.filter(f=>f.type===u);return a?lt(l,t,c,n):V(l,t)});return{works:h[0].slice(0,e),books:h[1].slice(0,e),collections:h[2].slice(0,e),totalWorks:h[0].length,totalBooks:h[1].length,totalCollections:h[2].length}}async getItem(t){const e=await this.ensureLoaded(),s=this.promotions.get(t)??t,n=s!==t?t:void 0,o=this.pathMap.get(s);let i=null;if(o){const c=o.isDraft?this.config.repos.draft:this.config.repos.official;if(i=await this.fetchItemByPath(c,o.path),i){const a=e.find(h=>h.id===s);a!=null&&a.has_collated&&(i.has_collated=!0)}}else i=await this.findItemById(s);return i&&i.type==="entity"&&!i.title&&i.primary_name&&(i.title=i.primary_name),i&&n&&(i.redirected_from=n),i}async getEntry(t){const e=await this.ensureLoaded(),s=this.promotions.get(t)??t,n=s!==t?t:void 0,o=e.find(a=>a.id===s);if(o)return n?{...o,redirected_from:n}:o;const i=await this.findItemById(s);if(!i)return null;const c=this.buildEntryFromItem(s,i);return n?{...c,redirected_from:n}:c}async getAllEntries(){return this.ensureLoaded()}async saveItem(){throw new Error("GithubStorage 为只读模式,不支持保存")}async deleteItem(){throw new Error("GithubStorage 为只读模式,不支持删除")}async generateId(){throw new Error("GithubStorage 为只读模式,不支持生成 ID")}async fetchItemByPath(t,e){let s=null;const n=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(e)}`;try{s=await this.fetchJson(n)}catch{}if(!s)for(const o of this.config.cdnUrls){const i=`${o}/${this.config.org}/${t}@main/${encodeURI(e)}`;try{s=await this.fetchJson(i);break}catch{continue}}return s}async findItemById(t){const e={book:"Book",collection:"Collection",work:"Work",entity:"Entity"};let s,n;try{const u=A(I(t));s=u.type,n=u.status}catch{return null}const o=n==="draft"?this.config.repos.draft:this.config.repos.official,i=e[s],c=t.padEnd(3,"_").substring(0,3),a=`${i}/${c[0]}/${c[1]}/${c[2]}`,h=`https://api.github.com/repos/${this.config.org}/${o}/contents/${a}`;try{const u=await fetch(h,{signal:AbortSignal.timeout(this.config.timeout)});if(!u.ok)return null;const f=(await u.json()).find(_=>_.name.startsWith(`${t}-`)&&_.name.endsWith(".json"));if(!f)return null;const d=await this.fetchItemByPath(o,f.path);return d&&this.pathMap.set(t,{path:f.path,isDraft:n==="draft"}),d}catch{return null}}buildEntryFromItem(t,e){const s=(e.type||"").toLowerCase(),n=s==="work"?"work":s==="collection"?"collection":"book";let o;const i=e.authors;if(Array.isArray(i)&&i.length>0){const h=i[0];o=typeof h=="object"&&h!==null?h.name||"":String(h)}let c=!0;try{c=A(I(t)).status==="draft"}catch{}const a=this.pathMap.get(t);return{id:t,title:e.title||e.书名||t,type:n,isDraft:c,author:o,dynasty:e.dynasty,role:e.role,path:(a==null?void 0:a.path)||"",juan_count:e.n_juan,has_collated:e.has_collated}}async fetchFile(t,e){const s=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(e)}`;try{return await this.fetchJson(s)}catch{}for(const n of this.config.cdnUrls){const o=`${n}/${this.config.org}/${t}@main/${encodeURI(e)}`;try{return await this.fetchJson(o)}catch{continue}}return null}async resolveItemPath(t){await this.ensureLoaded();let e=this.pathMap.get(t);if(!e&&(await this.findItemById(t),e=this.pathMap.get(t),!e))return null;const s=e.isDraft?this.config.repos.draft:this.config.repos.official,n=e.path.substring(0,e.path.lastIndexOf("/"));return{repo:s,dir:n}}async getCollectionCatalogs(t){const e=await this.resolveItemPath(t);if(!e)return null;const s=await this.getItem(t);if(!s)return null;const n=s.resources||[];if(n.length===0)return null;const o=[];for(const i of n){const c=`${e.dir}/${t}/${i.id}/volume_book_mapping.json`,a=await this.fetchFile(e.repo,c);a&&o.push({resource_id:i.id,short_name:i.short_name,data:et(a)})}return o.length>0?o:null}async getCollectionCatalog(t){var s;const e=await this.getCollectionCatalogs(t);return((s=e==null?void 0:e[0])==null?void 0:s.data)??null}async getLineageGraph(t){const e=await this.resolveItemPath(t);if(!e)return null;const s=`${e.dir}/${t}/lineage_graph.json`;return this.fetchFile(e.repo,s)}async getCatalogProgress(){return this.fetchFile(this.config.repos.draft,"resource-catalog.json")}async getCollectionProgress(){return this.fetchFile(this.config.repos.draft,"resource-collection.json")}async getResourceProgress(){return this.fetchFile(this.config.repos.draft,"resource.json")}async getSiteProgress(){return this.fetchFile(this.config.repos.draft,"resource-site.json")}async getRecommended(){return this.fetchFile(this.config.repos.draft,"recommended.json")}clearCache(){this.cache=null,this.pathMap.clear(),this.searchSCache=null,this.t2sConverter=null}}const ht=255;class nt{constructor(t){if(this.lastTimestamp=-1,this.lastStatus=null,this.sequence=0,t<0||t>2047)throw new Error("Machine ID must be between 0 and 2047");this.machineId=t}nextId(t,e){let s=this._getCurrentTimestamp(t);if(s<this.lastTimestamp&&t===this.lastStatus)throw new Error("Clock moved backwards. Refusing to generate ID.");s===this.lastTimestamp&&t===this.lastStatus?(this.sequence=this.sequence+1&ht,this.sequence===0&&(s=this._tilNextUnit(this.lastTimestamp,t))):this.sequence=0,this.lastTimestamp=s,this.lastStatus=t;const n=K(t,e,BigInt(s),this.machineId,this.sequence);return W(n)}nextIdRaw(t,e){let s=this._getCurrentTimestamp(t);if(s<this.lastTimestamp&&t===this.lastStatus)throw new Error("Clock moved backwards. Refusing to generate ID.");return s===this.lastTimestamp&&t===this.lastStatus?(this.sequence=this.sequence+1&ht,this.sequence===0&&(s=this._tilNextUnit(this.lastTimestamp,t))):this.sequence=0,this.lastTimestamp=s,this.lastStatus=t,K(t,e,BigInt(s),this.machineId,this.sequence)}_getCurrentTimestamp(t){const e=Date.now();return t==="draft"?e:Math.floor(e/1e3)}_tilNextUnit(t,e){let s=this._getCurrentTimestamp(e);for(;s<=t;)s=this._getCurrentTimestamp(e);return s}}class Yt{constructor(t){this.recentEntities=[],this.storage=new tt(t.fs,t.workspaceRoot),this.idGen=new nt(t.machineId??0),this.fs=t.fs,this.workspaceRoot=t.workspaceRoot}async loadEntries(t,e){const s=await this.storage.loadEntries(t);return this.paginate(s,e)}async search(t,e,s){const n=await this.storage.searchEntries(t,e);return this.paginate(n,s)}async searchAll(t,e){return this.storage.searchAll(t,e)}async getItem(t){const e=await this.storage.getItem(t);return e&&e.type==="entity"&&!e.title&&e.primary_name&&(e.title=e.primary_name),e}async saveItem(t){const e=t.id;if(!e)throw new Error("metadata.id is required");const s=t.type||this.extractTypeFromId(e),n=await this.storage.saveItem(s,e,t);return{id:e,path:n}}async deleteItem(t){if(!await this.storage.deleteItem(t))throw new Error(`Item not found: ${t}`)}async generateId(t,e){return this.idGen.nextId(e,t)}async getEntry(t){const e=await this.storage.getItem(t);if(!e)return null;const s=e.type||this.extractTypeFromId(t);return{id:t,title:e.title||"未命名",type:s,author:this.extractAuthor(e),dynasty:this.extractYear(e)}}async getAllEntries(){const t=["book","collection","work"],e=[];for(const s of t){const n=await this.storage.loadEntries(s);e.push(...n)}return e}async getRelations(t){const e=await this.storage.getItem(t);if(!e)return null;const s={},n=e.type||this.extractTypeFromId(t);if(n==="book"){if(e.work_id){const o=await this.resolveEntity(e.work_id);o&&(s.belongsToWork={...o,type:"work"})}if(e.contained_in&&Array.isArray(e.contained_in)&&e.contained_in.length>0){const o=e.contained_in[0],i=typeof o=="string"?o:o.id;if(i){const c=await this.resolveEntity(i);c&&(s.belongsToCollection={...c,type:"collection"})}}}else if(n==="collection"){if(e.books&&Array.isArray(e.books)){const o=await Promise.all(e.books.map(i=>this.resolveEntity(i)));s.containedBooks=o.filter(i=>i!==null).map(i=>({...i,type:"book"}))}}else if(n==="work"){if(e.parent_work&&typeof e.parent_work=="object"){const o=e.parent_work;s.parentWork={id:o.id,title:o.title,type:"work"}}if(e.books&&Array.isArray(e.books)){const o=await Promise.all(e.books.map(i=>this.resolveEntity(i)));s.containedBooks=o.filter(i=>i!==null).map(i=>({...i,type:"book"}))}}return s}async linkEntity(t,e,s){const n=await this.storage.getItem(t);if(!n)throw new Error(`Source not found: ${t}`);const o=n.type||this.extractTypeFromId(t);switch(e){case"belongsToWork":case"work_id":n.work_id=s;break;case"belongsToCollection":case"contained_in":Array.isArray(n.contained_in)||(n.contained_in=[]);{const i=n.contained_in;i.some(a=>(typeof a=="string"?a:a.id)===s)||i.push({id:s})}break;case"parentWork":case"parent_work":{const i=await this.storage.getItem(s);n.parent_work={id:s,title:(i==null?void 0:i.title)||""};break}case"containedBooks":case"books":Array.isArray(n.books)||(n.books=[]),n.books.includes(s)||n.books.push(s);break;default:throw new Error(`Unknown relation field: ${e}`)}await this.storage.saveItem(o,t,n)}async unlinkEntity(t,e){const s=await this.storage.getItem(t);if(!s)throw new Error(`Source not found: ${t}`);const n=s.type||this.extractTypeFromId(t);switch(e){case"belongsToWork":case"work_id":delete s.work_id;break;case"belongsToCollection":case"contained_in":s.contained_in=[];break;case"parentWork":case"parent_work":delete s.parent_work;break;case"containedBooks":case"books":s.books=[];break;default:throw new Error(`Unknown relation field: ${e}`)}await this.storage.saveItem(n,t,s)}async createAndLink(t,e,s){const n=this.idGen.nextId("draft",s.type),o={id:n,type:s.type,title:s.title,...s.inheritData||{}};return await this.storage.saveItem(s.type,n,o),await this.linkEntity(t,e,n),{id:n}}async searchEntities(t,e){const s=e&&e!=="all"?[e]:["book","collection","work"],n=[];for(const o of s){const i=await this.storage.searchEntries(t,o);for(const c of i)n.push({id:c.id,title:c.title,type:c.type,author:c.author,dynasty:c.dynasty})}return n}async getRecentEntities(){return this.recentEntities}async addRecentEntity(t){this.recentEntities=[t,...this.recentEntities.filter(e=>e.id!==t.id)].slice(0,20)}async getCollectionCatalog(t){const e=await this.storage.findFileById(t);if(!e)return null;const n=e.substring(0,e.lastIndexOf("/"))+"/volume_book_mapping.json";try{const o=await this.storage.loadMetadata(n);return Object.keys(o).length===0?null:o}catch{return null}}async getRecommended(){const t=this.workspaceRoot+"/book-index-draft/recommended.json";try{const e=await this.fs.readFile(t);return JSON.parse(e)}catch{return null}}getAssetDir(t){return this.storage.getAssetDir(t)}async initAssetDir(t){return this.storage.initAssetDir(t)}async hasAssetDir(t){return this.storage.hasAssetDir(t)}getBookIndexStorage(){return this.storage}async rebuildIndex(t){await this.storage.rebuildIndex(t)}extractTypeFromId(t){try{const e=I(t);return A(e).type}catch{return"book"}}extractAuthor(t){const e=t.authors;if(Array.isArray(e)&&e.length>0){const s=e[0];return typeof s=="object"&&s!==null?s.name||"":String(s)}}extractYear(t){const e=t.publication_info;if(typeof e=="object"&&e!==null)return e.year||void 0}async resolveEntity(t){const e=await this.storage.getItem(t);return e?{id:t,title:e.title||"未命名"}:null}paginate(t,e){const s=e.page??1,n=e.pageSize??50;if(e.sortBy){const a=e.sortBy,h=e.sortOrder==="desc"?-1:1;t.sort((u,l)=>{const f=u[a]??"",d=l[a]??"";return f<d?-h:f>d?h:0})}const o=t.length,i=(s-1)*n;return{entries:t.slice(i,i+n),total:o,page:s,pageSize:n}}}const Vt=["default","manifest","fragments","sources"],Xt=/^[a-z][a-z0-9-]*$/;function X(r){return typeof r!="string"?!1:r==="default"?!0:Xt.test(r)&&!Vt.includes(r)}function Qt(r){return/^\d+$/.test(r)}function O(r){return r.length>0&&!r.includes("..")&&!/[\\/?#%\s\u0000-\u001f\u007f]/.test(r)}const Zt=/^(整理本|整理|转录全文|轉錄全文|转录|轉錄|全文|文本)$/;function te(r){for(const t of[r.label,r.source_name]){const e=t==null?void 0:t.trim();if(e&&!Zt.test(e))return e}return r.label||r.source_name||r.key}function ee(r,t){const e=(t==null?void 0:t.chapters)??[];if(e.length===0)return null;if(r){const s=e.find(n=>n.file===r.file);if(s)return s.file;if(r.n!==void 0){const n=e.find(o=>o.n===r.n);if(n)return n.file}}return e[0].file}function se(r,t){const e=r==null?void 0:r.versions;if(!(!e||e.length===0))return(t!=null?e.find(s=>s.key===t):void 0)??e.find(s=>s.key==="default")??e[0]}const ne="/data",oe=1e4;class ie{constructor(t={}){this.chunkCache=new Map,this.chunkLoading=new Map,this.manifest=null,this.manifestLoading=null,this.tiyaoCache=new Map,this.tiyaoLoading=new Map,this.metaCache=null,this.metaLoading=null,this.promotions=null,this.promotionsLoading=null,this.versionPromise=null,this.versionInjected=!1,this.basePath=t.basePath??ne,this.timeout=t.timeout??oe,t.version!==void 0&&(this.version=t.version??null,this.versionInjected=!0)}async ensureVersion(){return this.version!==void 0?this.version:this.versionPromise?this.versionPromise:(this.versionPromise=(async()=>{try{const t=await fetch(`${this.basePath}/version.json`,{cache:"no-cache",signal:AbortSignal.timeout(this.timeout)});if(!t.ok)return null;const e=await t.json(),s=e==null?void 0:e.commitId;return!s||s==="unknown"?null:s.slice(0,12)}catch{return null}})(),this.version=await this.versionPromise,this.version)}async fetchJson(t){const e=await this.ensureVersion(),s=e?`${t}${t.includes("?")?"&":"?"}v=${e}`:t,n=await fetch(s,{cache:"no-cache",signal:AbortSignal.timeout(this.timeout)});if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);return n.json()}async ensurePromotions(){if(this.promotions)return this.promotions;if(this.promotionsLoading)return this.promotionsLoading;this.promotionsLoading=(async()=>{try{const t=await this.fetchJson(`${this.basePath}/promotions.json`);this.promotions=st(t)}catch{this.promotions=new Map}return this.promotions})();try{return await this.promotionsLoading}finally{this.promotionsLoading=null}}async loadManifest(){if(this.manifest)return this.manifest;if(this.manifestLoading)return this.manifestLoading;this.manifestLoading=(async()=>{try{this.manifest=await this.fetchJson(`${this.basePath}/chunks/_manifest.json`)}catch{this.manifest=[]}return this.manifest})();try{return await this.manifestLoading}finally{this.manifest||(this.manifestLoading=null)}}async resolvePrefix(t){const e=await this.loadManifest();let s=0,n=e.length-1,o=null;for(;s<=n;){const i=s+n>>1;e[i]<=t?(o=e[i],s=i+1):n=i-1}if(o&&t.startsWith(o))return o;for(const i of e)if(t.startsWith(i))return i;return null}async loadChunk(t){if(this.chunkCache.has(t))return this.chunkCache.get(t);const e=this.chunkLoading.get(t);if(e)return e;const s=(async()=>{try{const n=await this.fetchJson(`${this.basePath}/chunks/${t}.json`);return this.chunkCache.set(t,n),n}catch{return this.chunkCache.set(t,{}),{}}})();this.chunkLoading.set(t,s);try{return await s}finally{this.chunkLoading.delete(t)}}async loadChunkForId(t){const e=await this.resolvePrefix(t);return e?this.loadChunk(e):{}}async loadTiyaoGroup(t,e){const s=`${t}-${e}`;if(this.tiyaoCache.has(s))return this.tiyaoCache.get(s);const n=this.tiyaoLoading.get(s);if(n)return n;const o=c=>String(c).padStart(3,"0"),i=(async()=>{const c=await this.fetchJson(`${this.basePath}/tiyao/juan-${o(t)}-${o(e)}.json`);return this.tiyaoCache.set(s,c),c})();this.tiyaoLoading.set(s,i);try{return await i}finally{this.tiyaoLoading.delete(s)}}async getCounts(){if(this.metaCache)return this.metaCache;if(this.metaLoading){const t=await this.metaLoading;if(t)return t;throw new Error("BundleStorage: meta.json 加载失败")}this.metaLoading=(async()=>{const t=await this.fetchJson(`${this.basePath}/meta.json`);if(!t||typeof t.works!="number")throw new Error("BundleStorage: meta.json 格式无效");return this.metaCache=t,t})();try{const t=await this.metaLoading;if(!t)throw new Error("BundleStorage: meta.json 加载失败");return t}finally{this.metaLoading=null}}async getResourceCounts(){return(await this.getCounts()).resourceCounts??{hasText:0,hasImage:0}}async getSubtypeStats(){return(await this.getCounts()).subtypeStats??{}}async loadEntries(t,e){throw new Error("BundleStorage.loadEntries 已废弃:请使用 worker 搜索")}async search(t,e,s){throw new Error("BundleStorage.search 已废弃:请使用 worker 搜索")}async searchAll(t,e=5){throw new Error("BundleStorage.searchAll 已废弃:请使用 worker 搜索")}async getItem(t){try{const s=(await this.ensurePromotions()).get(t)??t,n=s!==t?t:void 0,i=(await this.loadChunkForId(s))[s]||null;return i&&(i.type==="entity"&&!i.title&&i.primary_name&&(i.title=i.primary_name),n&&(i.redirected_from=n)),i}catch{return null}}async getEntry(t){var e,s;try{const o=(await this.ensurePromotions()).get(t)??t,i=o!==t?t:void 0,a=(await this.loadChunkForId(o))[o];if(!a)return null;const h=kt(o),u=h==="entity"?a.primary_name||a.title||a.name||o:a.title||a.name||o;return{id:o,title:u,type:h,isDraft:!0,author:a.author,dynasty:a.dynasty,role:a.role,additional_titles:(e=a.additional_titles)==null?void 0:e.map(l=>typeof l=="string"?l:l==null?void 0:l.book_title).filter(Boolean),attached_texts:(s=a.attached_texts)==null?void 0:s.map(l=>typeof l=="string"?l:l==null?void 0:l.book_title).filter(Boolean),edition:a.edition,juan_count:a.juan_count,has_text:a.has_text,has_image:a.has_image,has_collated:a.has_collated,subtype:a.subtype,primary_name:a.primary_name,birth_year:a.birth_year,death_year:a.death_year,cbdb_id:a.cbdb_id,...i?{redirected_from:i}:{}}}catch{return null}}async getAllEntries(){throw new Error("BundleStorage.getAllEntries 已废弃:请使用 getEntry / worker 搜索")}async saveItem(){throw new Error("BundleStorage 为只读模式,不支持保存")}async deleteItem(){throw new Error("BundleStorage 为只读模式,不支持删除")}async generateId(){throw new Error("BundleStorage 为只读模式,不支持生成 ID")}async getCollectionCatalogs(t){const e=await this.getItem(t);if(!e)return null;const s=e.resources||[];if(s.length===0)return null;const n=[];for(const o of s)try{const i=await this.fetchJson(`${this.basePath}/items/${t}/${o.id}/volume_book_mapping.json`);i&&n.push({resource_id:o.id,short_name:o.short_name,data:et(i)})}catch{}return n.length>0?n:null}async getCollectionCatalog(t){var s;const e=await this.getCollectionCatalogs(t);return((s=e==null?void 0:e[0])==null?void 0:s.data)??null}async getTextManifest(t){if(!O(t))return null;try{const e=await this.fetchJson(`${this.basePath}/items/${t}/manifest.json`);return e&&Array.isArray(e.versions)?e:null}catch{return null}}async getTextIndex(t,e){if(!O(t)||!X(e))return null;try{const s=await this.fetchJson(`${this.basePath}/items/${t}/${e}/index.json`);return s&&Array.isArray(s.chapters)?s:null}catch{return null}}async getChapter(t,e,s,n){if(!O(t)||!X(e)||!O(s))return null;const o=`${this.basePath}/items/${t}/${e}/${s}`,i=await this.ensureVersion(),c=i?`${o}.txt?v=${i}`:`${o}.txt`,a=fetch(c,{cache:"no-cache",signal:AbortSignal.timeout(this.timeout)}).then(f=>f.ok?f.text():null).catch(()=>null),h=n!=null&&n.json?this.fetchJson(`${o}.json`).catch(()=>null):Promise.resolve(null),[u,l]=await Promise.all([a,h]);return u!=null||l?{md:u,json:l}:null}async getLineageGraph(t){try{return await this.fetchJson(`${this.basePath}/items/${t}/lineage_graph.json`)}catch{return null}}async getCatalogProgress(){try{return await this.fetchJson(`${this.basePath}/resource-catalog.json`)}catch{return null}}async getCollectionProgress(){try{return await this.fetchJson(`${this.basePath}/resource-collection.json`)}catch{return null}}async getResourceProgress(){try{return await this.fetchJson(`${this.basePath}/resource.json`)}catch{return null}}async getSiteProgress(){try{return await this.fetchJson(`${this.basePath}/resource-site.json`)}catch{return null}}async getRecommended(){try{return await this.fetchJson(`${this.basePath}/recommended.json`)}catch{return null}}clearCache(){this.chunkCache.clear(),this.chunkLoading.clear(),this.manifest=null,this.manifestLoading=null,this.tiyaoCache.clear(),this.tiyaoLoading.clear(),this.metaCache=null,this.metaLoading=null,this.versionInjected||(this.version=void 0,this.versionPromise=null)}}class L extends Error{constructor(t){super(t),this.name="BookIndexError"}}class re extends L{constructor(t){super(t),this.name="StorageError"}}class ae extends L{constructor(t){super(t),this.name="IdGenerationError"}}class ce extends L{constructor(t){super(t),this.name="ConfigError"}}class le extends L{constructor(t){super(t),this.name="MigrationError"}}class he{constructor(t,e,s=1){this.storage=new tt(t,e),this.idGen=new nt(s)}generateId(t="book",e="draft"){return this.idGen.nextIdRaw(e,t)}encodeId(t){return W(t)}decodeId(t){return I(t)}async saveItem(t,e,s="draft"){let n=t.id||t.ID;if(n)try{const i=F(n);e||(e=i.type)}catch{throw new L(`Invalid ID format: ${n}`)}else e||(e=t.type||"book"),n=this.idGen.nextId(s,e),t.id=n;return await this.storage.saveItem(e,n,t)}async getItem(t){return this.storage.getItem(t)}async findItemPath(t){return this.storage.findFileById(t)}async updateField(t,e,s){const n=await this.storage.findFileById(t);if(!n)return!1;try{const o=await this.storage.loadMetadata(n),i={基本信息:null,介绍:"description",资源:"resources",收藏历史:"history",其他版本:"related_books"},c=e in i?i[e]:e;if(c===null)return!1;if(c==="description"&&typeof s=="string"){const h=o[c]||{};o[c]={text:s,sources:h.sources||[]}}else o[c]=s;const a=F(t);return await this.storage.saveItem(a.type,t,o),!0}catch{return!1}}async deleteItem(t){return this.storage.deleteItem(t)}async rebuildIndices(){await this.storage.rebuildIndex("official"),await this.storage.rebuildIndex("draft")}getAssetDir(t){return this.storage.getAssetDir(t)}async initAssetDir(t){return this.storage.initAssetDir(t)}async hasAssetDir(t){return this.storage.hasAssetDir(t)}getStorage(){return this.storage}}const ue={wikisource:"wikisource",shidianguji:"shidianguji",archive:"archive",ctext:"ctext",nlc:"nlc","read.nlc":"nlc","db.sido":"sido","guji.artx":"guji-artx","digital.library":"digital-library"},ut=new Set(["text","image","text+image","physical"]),ft=new Set(["text","image","physical"]),fe=new Set(["catalog","search"]),de=new Set(["com","org","net","cn","edu","gov","io","jp","tw","hk"]);function ye(r){if(!r)return"";try{const e=new URL(r).hostname;for(const[n,o]of Object.entries(ue))if(e.includes(n))return o;const s=e.split(".");if(s.length>=2){const n=s.filter(o=>!de.has(o)&&o.length>2);return n.length>0?n[n.length-1]:s[s.length-2]}return e}catch{return""}}function ge(r){const t=[];r.name||t.push("name is required");let e=!1;if(r.types!==void 0)if(!Array.isArray(r.types)||r.types.length===0)t.push("types must be a non-empty array when present");else{for(const s of r.types)ft.has(s)||t.push(`invalid types atom '${s}', must be one of ${[...ft].join(", ")}`);e=r.types.length===1&&r.types[0]==="physical"}else r.type!==void 0?(ut.has(r.type)||t.push(`invalid type '${r.type}', must be one of ${[...ut].join(", ")}`),e=r.type==="physical"):t.push("either type or types is required");return r.root_type&&!fe.has(r.root_type)&&t.push(`invalid root_type '${r.root_type}'`),!e&&!r.url&&t.push("url is required for non-physical resources"),t}const b=class b{constructor(t,e=""){if(this._type=null,this.title=e,typeof t=="string"){t.startsWith(b.PREFIX)&&(t=t.slice(b.PREFIX.length)),this.idStr=t;try{this.idInt=I(t)}catch{this.idInt=0n}}else this.idInt=t,this.idStr=W(t);if(this.idInt>0n)try{const s=F(this.idStr);this._type=s.type}catch{}}get type(){return this._type}getIcon(){return this._type===null?"":this._type==="book"?"📖 ":this._type==="collection"?"📚 ":this._type==="work"?"📜 ":""}render(t=!1){return`[${t?this.getIcon():""}${this.title}](${b.PREFIX}${this.idStr})`}static parseFromLink(t){const e=t.match(/\[(.*?)\]\((.*?)\)/);if(e){const s=e[1],n=e[2];if(n.startsWith(b.PREFIX)){const o=n.slice(b.PREFIX.length);return new b(o,s)}}return null}static isBidLink(t){return t.startsWith(b.PREFIX)}};b.PROTOCOL="bid:\\\\",b.PREFIX="bid:\\\\";let Q=b;exports.BidLink=Q;exports.BookIndexError=L;exports.BookIndexManager=he;exports.BookIndexStorage=tt;exports.BundleStorage=ie;exports.ConfigError=ce;exports.GithubStorage=Kt;exports.IdGenerationError=ae;exports.IdGenerator=nt;exports.LocalStorage=Yt;exports.MigrationError=le;exports.StorageError=re;exports.base36Decode=Z;exports.base36Encode=W;exports.base58Decode=bt;exports.buildId=K;exports.buildPromotionMap=st;exports.cleanName=It;exports.decodeId=Ut;exports.decodeIdString=F;exports.encodeId=Mt;exports.extractIdFromUrl=ye;exports.extractStatus=Ot;exports.extractType=kt;exports.isChapterSegment=Qt;exports.isSafeSegment=O;exports.isTextKey=X;exports.matchChapterAcrossVersions=ee;exports.normalizeCatalog=et;exports.parseId=A;exports.pickTextVersion=se;exports.shardOf=G;exports.smartDecode=I;exports.textVersionLabel=te;exports.validateResource=ge;
|
|
1
|
+
"use strict";var St=Object.create;var it=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var At=Object.getPrototypeOf,$t=Object.prototype.hasOwnProperty;var jt=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Et(t))!$t.call(r,n)&&n!==e&&it(r,n,{get:()=>t[n],enumerable:!(s=vt(t,n))||s.enumerable});return r};var Pt=(r,t,e)=>(e=r!=null?St(At(r)):{},jt(t||!r||!r.__esModule?it(e,"default",{value:r,enumerable:!0}):e,r));const Tt={official:0,draft:1},Ct={0:"official",1:"draft"},Bt={book:0,collection:2,work:3,entity:4},Lt={0:"book",2:"collection",3:"work",4:"entity"},dt=62n,yt=59n,gt=19n,pt=8n,mt=(1n<<40n)-1n,Ft=(1n<<3n)-1n,Rt=(1n<<11n)-1n,Dt=(1n<<8n)-1n,H="0123456789abcdefghijklmnopqrstuvwxyz",_t=new Map;for(let r=0;r<H.length;r++)_t.set(H[r],BigInt(r));function W(r){if(r===0n)return H[0];let t="";for(;r>0n;)t=H[Number(r%36n)]+t,r=r/36n;return t}function Z(r){let t=0n;for(const e of r){const s=_t.get(e);if(s===void 0)throw new Error(`Invalid Base36 character: ${e}`);t=t*36n+s}return t}const rt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",wt=new Map;for(let r=0;r<rt.length;r++)wt.set(rt[r],BigInt(r));function bt(r){let t=0n;for(const e of r){const s=wt.get(e);if(s===void 0)throw new Error(`Invalid Base58 character: ${e}`);t=t*58n+s}return t}function I(r){return/[A-Z]/.test(r)?bt(r):Z(r)}const Mt=W,Ut=Z;function A(r){const t=Number(r>>dt&1n),e=Number(r>>yt&Ft),s=r>>gt&mt,n=Number(r>>pt&Rt),o=Number(r&Dt);return{status:Ct[t]??"draft",type:Lt[e]??"book",timestamp:s,machineId:n,sequence:o}}function K(r,t,e,s,n){return BigInt(Tt[r])<<dt|BigInt(Bt[t])<<yt|(e&mt)<<gt|BigInt(s)<<pt|BigInt(n)}function L(r){return A(I(r))}function kt(r){return L(r).type}function Ot(r){return L(r).status}const z={book:"Book",collection:"Collection",work:"Work",entity:"Entity"},Nt={Book:"book",Collection:"collection",Work:"work",Entity:"entity"},N=16;function G(r,t=N){let e=0;for(let s=0;s<r.length;s++)e=Math.imul(e,31)+r.charCodeAt(s)>>>0;return e%t}function at(r){const t={},e=r.dating;if(typeof e!="object"||e===null)return t;const s=e.era;typeof s=="string"&&s&&(t.era=s);const n=e.year;if(typeof n=="number")t.sort_year=n;else{const o=e.year_range;Array.isArray(o)&&o.length===2&&typeof o[0]=="number"&&(t.sort_year=o[0])}return t}function k(...r){const t=r.join("/");return t.startsWith("//")?"//"+t.slice(2).replace(/\/+/g,"/"):t.replace(/\/+/g,"/")}function It(r){return r.replace(/[^㐀-䶿一-鿿豈-a-zA-Z0-9\u{20000}-\u{3134f}]/gu,"")||"Undefined"}class tt{constructor(t,e){this.fs=t,this.officialRoot=k(e,"book-index"),this.draftRoot=k(e,"book-index-draft")}getRootByStatus(t){return t==="draft"?this.draftRoot:this.officialRoot}getRootById(t){const e=I(t),s=A(e);return this.getRootByStatus(s.status)}getPath(t,e,s){const n=this.getRootById(e),o=e.padEnd(3,"_").substring(0,3),[i,c,a]=[o[0],o[1],o[2]],h=z[t];return k(n,h,i,c,a,`${e}-${It(s)}.json`)}async saveItem(t,e,s){const n=s.title||s.书名||"未命名",o=s.edition||"",i=o?`${n}${o}`:n,c=this.getPath(t,e,i),a=await this.findFileById(e);if(a&&a!==c)try{await this.fs.deleteFile(a)}catch{}const h=c.substring(0,c.lastIndexOf("/"));await this.fs.mkdir(h),s.id=e,s.type=t,await this.fs.writeFile(c,JSON.stringify(s,Wt,2));const u=this.getRootById(e),l=c.substring(u.length+1);return await this.updateIndexEntry(u,s,t,l),c}async updateIndexEntry(t,e,s,n){const o=e.id||"";if(!o)return;const i=`${s}s`,c=await this.loadShard(t,i,o);let a="",h="",u="";const l=e.authors;if(Array.isArray(l)&&l.length>0){const y=l[0];typeof y=="object"&&y!==null?(a=y.name||"",h=y.dynasty||"",u=y.role||""):a=String(y)}else typeof l=="string"&&(a=l);!h&&typeof e.dynasty=="string"&&(h=e.dynasty);let f="";const d=e.current_location;typeof d=="object"&&d!==null?f=d.name||"":typeof d=="string"&&(f=d);const _=Array.isArray(e.additional_titles)?e.additional_titles.map(y=>typeof y=="string"?y:y==null?void 0:y.book_title).filter(Boolean):void 0,w=Array.isArray(e.attached_texts)?e.attached_texts.map(y=>typeof y=="string"?y:y==null?void 0:y.book_title).filter(Boolean):void 0;let S;const x=e.juan_count;typeof x=="number"?S=x:typeof x=="object"&&x!==null&&(S=x.number||void 0);const P=typeof e.measure_info=="string"?e.measure_info:"";let $=!1,v=!1;const E=e.resources;if(Array.isArray(E))for(const y of E){if(typeof y!="object"||y===null)continue;const B=y.types;if(Array.isArray(B))B.includes("text")&&($=!0),B.includes("image")&&(v=!0);else{const j=y.type;(j==="text"||j==="text+image")&&($=!0),(j==="image"||j==="text+image")&&(v=!0)}}const p={id:o,title:e.title||"未命名",type:z[s],path:n,author:a,holder:f,...at(e)};_&&_.length>0&&(p.additional_titles=_),w&&w.length>0&&(p.attached_texts=w),S&&(p.juan_count=S),P&&(p.measure_info=P);const T=typeof e.edition=="string"?e.edition:"";T&&(p.edition=T),$&&(p.has_text=!0),v&&(p.has_image=!0),h&&(p.dynasty=h),u&&(p.role=u);const C=typeof e.subtype=="string"?e.subtype:"";C&&(p.subtype=C);const R=typeof e.period=="string"?e.period:"";R&&(p.period=R);const m=typeof e.loss_status=="string"?e.loss_status:"";m&&(p.loss_status=m);const D=typeof e.original_title=="string"?e.original_title:"";D&&(p.original_title=D);const M=typeof e.work_id=="string"?e.work_id:"";M&&(p.work_id=M);const U=typeof e._promoted_to=="string"?e._promoted_to:typeof e.promoted_to=="string"?e.promoted_to:"";U&&(p.promoted_to=U),c[o]=p,await this.saveShard(t,i,o,c)}async deleteItem(t){const e=await this.findFileById(t);if(!e)return!1;const s=I(t),n=A(s),o=this.getRootByStatus(n.status),i=`${n.type}s`,c=await this.loadShard(o,i,t);return c[t]&&(delete c[t],await this.saveShard(o,i,t,c)),await this.fs.deleteFile(e),!0}async findFileById(t){const e=t.padEnd(3,"_").substring(0,3),[s,n,o]=[e[0],e[1],e[2]];for(const i of[this.officialRoot,this.draftRoot])for(const c of["Book","Collection","Work"]){const a=k(i,c,s,n,o);if(await this.fs.exists(a))try{const u=(await this.fs.readdir(a)).find(l=>l.startsWith(`${t}-`)&&l.endsWith(".json"));if(u)return k(a,u)}catch{}}return null}async loadMetadata(t){try{const e=await this.fs.readFile(t);return JSON.parse(e)}catch{return{}}}async getItem(t){const e=await this.findFileById(t);if(!e)return null;const s=await this.loadMetadata(e);return Object.keys(s).length>0?s:null}async loadEntries(t,e){const s=e?[this.getRootByStatus(e)]:[this.officialRoot,this.draftRoot],n=[],o=`${t}s`;for(const i of s){const c=await this.loadAllShards(i,o);for(const[a,h]of Object.entries(c))n.push({id:a,title:h.title,type:t,author:h.author||void 0,dynasty:h.dynasty||void 0,role:h.role||void 0,path:k(i,h.path),additional_titles:h.additional_titles,attached_texts:h.attached_texts,edition:h.edition,juan_count:h.juan_count,has_text:h.has_text,has_image:h.has_image,era:h.era,sort_year:h.sort_year})}return n}async searchEntries(t,e,s){const n=await this.loadEntries(e,s);return V(n,t)}async searchAll(t,e=5,s){const n=["work","book","collection"],o=await Promise.all(n.map(i=>this.searchEntries(t,i,s)));return{works:o[0].slice(0,e),books:o[1].slice(0,e),collections:o[2].slice(0,e),totalWorks:o[0].length,totalBooks:o[1].length,totalCollections:o[2].length}}async rebuildIndex(t){var n;const e=this.getRootByStatus(t),s={books:Object.fromEntries(Array.from({length:N},(o,i)=>[i,{}])),collections:{0:{}},works:Object.fromEntries(Array.from({length:N},(o,i)=>[i,{}]))};for(const o of["Book","Collection","Work"]){const i=k(e,o);if(!await this.fs.exists(i))continue;const a=`${Nt[o]}s`,h=await this.fs.glob(i,"**/*.json");for(const u of h)if(!u.includes("/index/"))try{const l=await this.loadMetadata(u);let f=l.id||l.ID||"";if(!f){const g=u.substring(u.lastIndexOf("/")+1);g.includes("-")&&(f=g.split("-")[0])}if(!f)continue;const d=u.substring(e.length+1);let _="",w="",S="";const x=l.authors;if(Array.isArray(x)&&x.length>0){const g=x[0];typeof g=="object"&&g!==null?(_=g.name||"",w=g.dynasty||"",S=g.role||""):_=String(g)}!w&&typeof l.dynasty=="string"&&(w=l.dynasty);const P=Array.isArray(l.additional_titles)?l.additional_titles.map(g=>typeof g=="string"?g:g==null?void 0:g.book_title).filter(Boolean):void 0,$=Array.isArray(l.attached_texts)?l.attached_texts.map(g=>typeof g=="string"?g:g==null?void 0:g.book_title).filter(Boolean):void 0;let v;const E=l.juan_count;typeof E=="number"?v=E:typeof E=="object"&&E!==null&&(v=E.number||void 0);const p=typeof l.measure_info=="string"?l.measure_info:"";let T=!1,C=!1;const R=l.resources;if(Array.isArray(R))for(const g of R){if(typeof g!="object"||g===null)continue;const q=g.types;if(Array.isArray(q))q.includes("text")&&(T=!0),q.includes("image")&&(C=!0);else{const J=g.type;(J==="text"||J==="text+image")&&(T=!0),(J==="image"||J==="text+image")&&(C=!0)}}const m={id:f,title:l.title||"未命名",type:o,path:d,author:_,holder:typeof l.current_location=="object"&&((n=l.current_location)==null?void 0:n.name)||"",...at(l)};P&&P.length>0&&(m.additional_titles=P),$&&$.length>0&&(m.attached_texts=$),v&&(m.juan_count=v),p&&(m.measure_info=p);const D=typeof l.edition=="string"?l.edition:"";D&&(m.edition=D),T&&(m.has_text=!0),C&&(m.has_image=!0),w&&(m.dynasty=w),S&&(m.role=S);const M=typeof l.subtype=="string"?l.subtype:"";M&&(m.subtype=M);const U=typeof l.period=="string"?l.period:"";U&&(m.period=U);const y=typeof l.loss_status=="string"?l.loss_status:"";y&&(m.loss_status=y);const B=typeof l.original_title=="string"?l.original_title:"";B&&(m.original_title=B);const j=typeof l.work_id=="string"?l.work_id:"";j&&(m.work_id=j);const ot=typeof l._promoted_to=="string"?l._promoted_to:typeof l.promoted_to=="string"?l.promoted_to:"";ot&&(m.promoted_to=ot);const xt=a==="collections"?0:G(f);s[a][xt][f]=m}catch{}}for(const[o,i]of Object.entries(s))for(const[c,a]of Object.entries(i)){const h=this.shardPath(e,o,Number(c)),u=h.substring(0,h.lastIndexOf("/"));await this.fs.mkdir(u),await this.fs.writeFile(h,JSON.stringify(ct(a),null,await this.detectShardIndent(h)))}}getAssetDir(t){const e=this.getRootById(t),s=I(t),o=A(s).type,i=t.padEnd(3,"_").substring(0,3),[c,a,h]=[i[0],i[1],i[2]],u=z[o];return k(e,u,c,a,h,t)}async initAssetDir(t){const e=this.getAssetDir(t);return await this.fs.mkdir(e),e}async hasAssetDir(t){const e=this.getAssetDir(t);return this.fs.exists(e)}shardPath(t,e,s){return e==="collections"?k(t,"index","collections.json"):k(t,"index",e,`${s.toString(16)}.json`)}async loadShard(t,e,s){const n=G(s),o=this.shardPath(t,e,n);try{if(!await this.fs.exists(o))return{};const i=await this.fs.readFile(o);return JSON.parse(i)}catch{return{}}}async detectShardIndent(t,e=2){try{if(!await this.fs.exists(t))return e;const n=(await this.fs.readFile(t)).split(`
|
|
2
|
+
`)[1];if(n===void 0)return e;const o=n.replace(/^ +/,"");return!o||o.startsWith("}")?e:n.length-o.length||e}catch{return e}}async saveShard(t,e,s,n){const o=G(s),i=this.shardPath(t,e,o),c=i.substring(0,i.lastIndexOf("/"));await this.fs.mkdir(c);const a=await this.detectShardIndent(i);await this.fs.writeFile(i,JSON.stringify(ct(n),null,a))}async loadAllShards(t,e){const s={};if(e==="collections"){const n=this.shardPath(t,e,0);try{if(await this.fs.exists(n)){const o=await this.fs.readFile(n);Object.assign(s,JSON.parse(o))}}catch{}return s}for(let n=0;n<N;n++){const o=this.shardPath(t,e,n);try{if(await this.fs.exists(o)){const i=await this.fs.readFile(o);Object.assign(s,JSON.parse(i))}}catch{}}return s}}function Y(r,t){const e=t.toLowerCase();let s=0;const n=r.title.toLowerCase();n===e?s=200:n.startsWith(e)?s=150:n.includes(e)&&(s=100);const o=[...r.additional_titles||[],...r.attached_texts||[]];for(const h of o){const u=h.toLowerCase();u===e?s=Math.max(s,120):u.startsWith(e)?s=Math.max(s,90):u.includes(e)&&(s=Math.max(s,60))}let i=0;if(r.author){const h=r.author.toLowerCase();h===e?i=80:h.includes(e)&&(i=50)}let c=0;r.dynasty&&r.dynasty.toLowerCase().includes(e)&&(c=30);let a=s;return a===0&&(a=Math.max(i,c)),a===0?0:(a+=Math.max(0,20-n.length),r.type==="work"?a=Math.round(a*1.05):r.type==="collection"&&(a=Math.round(a*1.02)),r.has_text&&(a+=3),r.has_image&&(a+=2),a)}function ct(r){const t={};for(const e of Object.keys(r).sort())t[e]=r[e];return t}function Wt(r,t){return t===null?void 0:t}function V(r,t){const e=r.map(s=>({entry:s,score:Y(s,t)})).filter(s=>s.score>0);return e.sort((s,n)=>n.score!==s.score?n.score-s.score:s.entry.title.length-n.entry.title.length),e.map(s=>s.entry)}function lt(r,t,e,s){const n=r.map(o=>{const i=Y(o,t);let c=0;const a=s[o.id];if(a&&e){const h={...o,title:a.t??o.title,author:a.a??o.author,additional_titles:a.at??o.additional_titles,attached_texts:a.axt??o.attached_texts};c=Y(h,e)}return{entry:o,score:Math.max(i,c)}}).filter(o=>o.score>0);return n.sort((o,i)=>i.score!==o.score?i.score-o.score:o.entry.title.length-i.entry.title.length),n.map(o=>o.entry)}function Jt(r){const t=r.volumes??[];let e,s;if(t.length===0)e=[];else if(typeof t[0]=="number")e=t;else{s=[],e=[];for(const o of t){const i=o.volume;e.push(i);const c={};for(const[a,h]of Object.entries(o))a==="volume"||a==="status"||a==="file"||typeof h=="string"&&(a.includes("url")||a.includes("id"))&&(c[a]=h);s.push({volume:i,status:o.status,urls:Object.keys(c).length>0?c:void 0,file:o.file})}}const n={title:r.title??"",book_id:r.book_id??null,work_id:r.work_id??null,volumes:e,section:r.section,sub_items:r.sub_items,edition:r.edition,expected_volumes:r.expected_volumes,found_volumes:r.found_volumes,missing_volumes:r.missing_vols??r.missing_volumes};s&&(n.volume_details=s);for(const o of Object.keys(n))n[o]===void 0&&delete n[o];return n}function Gt(r){const t={total_books:r.total_books??0};return r.processed_volumes!=null&&(t.processed_volumes=r.processed_volumes),r.matched_works!=null&&(t.matched_works=r.matched_works),r.unmatched_works!=null&&(t.unmatched_works=r.unmatched_works),r.total_found_volumes!=null&&(t.total_found_volumes=r.total_found_volumes),t}function et(r){var n;const t=r,e=(t.books??[]).map(Jt),s={collection_id:t.collection_id??"",title:t.title??"",total_volumes:t.total_volumes??0,stats:Gt(t.stats??{}),books:e};return t.source&&(s.source=t.source),t.resource_id&&(s.resource_id=t.resource_id),t.resource_name&&(s.resource_name=t.resource_name),(n=t.sections)!=null&&n.length&&(s.sections=t.sections),t.volume_index&&Object.keys(t.volume_index).length>0&&(s.volume_index=t.volume_index),s}function st(r){const t=new Map;if(!r||typeof r!="object")return t;const e=r;if(typeof e.version!="number")return console.warn("[promotions] missing version field; treating as empty"),t;if(e.version!==1)return console.warn(`[promotions] unknown version ${e.version}; treating as empty`),t;const s=e.promotions;if(!s||typeof s!="object")return t;for(const[n,o]of Object.entries(s))o&&typeof o=="object"&&typeof o.production_id=="string"&&t.set(n,o.production_id);return t}const Ht="https://raw.githubusercontent.com",qt=["https://fastly.jsdelivr.net/gh","https://cdn.jsdelivr.net/gh"],zt=5e3;class Kt{constructor(t){this.cache=null,this.cacheLoading=null,this.pathMap=new Map,this.promotions=new Map,this.searchSCache=null,this.t2sConverter=null,this.config={org:t.org,repos:t.repos,baseUrl:t.baseUrl??Ht,cdnUrls:t.cdnUrls??qt,timeout:t.timeout??zt}}async fetchPromotions(){try{const t=await this.fetchFileWithFallback(this.config.repos.draft,"promotions.json");return st(t)}catch{return new Map}}async ensureLoaded(){if(this.cache)return this.cache;if(this.cacheLoading)return this.cacheLoading;this.cacheLoading=(async()=>{const[t,e,s]=await Promise.all([this.fetchPromotions(),this.fetchIndex(this.config.repos.draft).catch(i=>(console.warn("Failed to fetch draft index:",i),{books:{},collections:{},works:{}})),this.fetchIndex(this.config.repos.official).catch(i=>(console.warn("Failed to fetch official index:",i),{books:{},collections:{},works:{}}))]);this.promotions=t;const n=[...this.parseIndexResponse(e,!0),...this.parseIndexResponse(s,!1)],o=new Map;for(const i of n)i.isDraft&&i.promoted_to||o.set(i.id,i);return this.cache=Array.from(o.values()),this.cache})();try{return await this.cacheLoading}finally{this.cache||(this.cacheLoading=null)}}async fetchFileWithFallback(t,e){const s=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(e)}`;try{return await this.fetchJson(s)}catch{}for(const n of this.config.cdnUrls){const o=`${n}/${this.config.org}/${t}@main/${encodeURI(e)}`;try{return await this.fetchJson(o)}catch{continue}}throw new Error(`Failed to fetch ${e} for ${t} from all sources`)}async probeIndex(t){const e="index/collections.json",s=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(e)}`;try{if((await fetch(s,{method:"HEAD",signal:AbortSignal.timeout(this.config.timeout)})).ok)return!0}catch{}for(const i of this.config.cdnUrls){const c=`${i}/${this.config.org}/${t}@main/${encodeURI(e)}`;try{if((await fetch(c,{method:"HEAD",signal:AbortSignal.timeout(this.config.timeout)})).ok)return!0}catch{continue}}const n="index/works/0.json",o=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(n)}`;try{if((await fetch(o,{method:"HEAD",signal:AbortSignal.timeout(this.config.timeout)})).ok)return!0}catch{}for(const i of this.config.cdnUrls){const c=`${i}/${this.config.org}/${t}@main/${encodeURI(n)}`;try{if((await fetch(c,{method:"HEAD",signal:AbortSignal.timeout(this.config.timeout)})).ok)return!0}catch{continue}}return!1}async fetchIndex(t){if(!await this.probeIndex(t))return{books:{},collections:{},works:{}};const s={books:{},collections:{},works:{}};try{const o=await this.fetchFileWithFallback(t,"index/collections.json");s.collections=o}catch{}const n=[];for(const o of["books","works"])for(let i=0;i<N;i++){const c=`index/${o}/${i.toString(16)}.json`;n.push(this.fetchFileWithFallback(t,c).then(a=>{Object.assign(s[o],a)}).catch(()=>{}))}return await Promise.all(n),s}async fetchJson(t){const e=await fetch(t,{cache:"no-store",signal:AbortSignal.timeout(this.config.timeout)});if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);return e.json()}parseIndexResponse(t,e){var o,i;const s=[],n=[["books","book"],["collections","collection"],["works","work"],["entities","entity"]];for(const[c,a]of n){const h=t[c];if(h)for(const u of Object.values(h)){const l=u,f=a==="entity"?l.primary_name||u.title||u.name||u.id:u.title||u.name||u.id;s.push({id:u.id,title:f,type:a,isDraft:e,author:u.author,dynasty:u.dynasty,role:u.role,path:u.path,additional_titles:(o=l.additional_titles)==null?void 0:o.map(d=>typeof d=="string"?d:d==null?void 0:d.book_title).filter(Boolean),attached_texts:(i=l.attached_texts)==null?void 0:i.map(d=>typeof d=="string"?d:d==null?void 0:d.book_title).filter(Boolean),edition:l.edition,juan_count:l.juan_count,has_text:l.has_text,has_image:l.has_image,has_collated:l.has_collated,subtype:l.subtype,primary_name:l.primary_name,birth_year:l.birth_year,death_year:l.death_year,cbdb_id:l.cbdb_id,promoted_to:l.promoted_to}),this.pathMap.set(u.id,{path:u.path,isDraft:e})}}return s}async ensureSearchSBuilt(){var n,o;if(this.searchSCache)return{searchS:this.searchSCache,converter:this.t2sConverter||null};if(this.t2sConverter===!1)return{searchS:{},converter:null};try{const i=await import("opencc-js");this.t2sConverter=i.Converter({from:"tw",to:"cn"})}catch{return this.t2sConverter=!1,this.searchSCache={},{searchS:{},converter:null}}const t=await this.ensureLoaded(),e=this.t2sConverter,s={};for(const i of t){const c={},a=e(i.title);if(a!==i.title&&(c.t=a),i.author){const h=e(i.author);h!==i.author&&(c.a=h)}if((n=i.additional_titles)!=null&&n.length){const h=i.additional_titles.map(e);h.some((u,l)=>u!==i.additional_titles[l])&&(c.at=h)}if((o=i.attached_texts)!=null&&o.length){const h=i.attached_texts.map(e);h.some((u,l)=>u!==i.attached_texts[l])&&(c.axt=h)}Object.keys(c).length>0&&(s[i.id]=c)}return this.searchSCache=s,{searchS:s,converter:e}}async loadEntries(t,e){let n=(await this.ensureLoaded()).filter(l=>l.type===t);const o=e.sortBy||"title",i=e.sortOrder||"asc";n.sort((l,f)=>{const d=String(l[o]??""),_=String(f[o]??""),w=d.localeCompare(_,"zh");return i==="asc"?w:-w});const c=e.page||1,a=e.pageSize||50,h=(c-1)*a;return{entries:n.slice(h,h+a),total:n.length,page:c,pageSize:a}}async search(t,e,s){const n=await this.ensureLoaded(),{searchS:o,converter:i}=await this.ensureSearchSBuilt(),c=n.filter(_=>_.type===e),a=i?i(t):void 0,u=Object.keys(o).length>0?lt(c,t,a,o):V(c,t),l=s.page||1,f=s.pageSize||50,d=(l-1)*f;return{entries:u.slice(d,d+f),total:u.length,page:l,pageSize:f}}async searchAll(t,e=5){const s=await this.ensureLoaded(),{searchS:n,converter:o}=await this.ensureSearchSBuilt(),i=["work","book","collection"],c=o?o(t):void 0,a=Object.keys(n).length>0,h=i.map(u=>{const l=s.filter(f=>f.type===u);return a?lt(l,t,c,n):V(l,t)});return{works:h[0].slice(0,e),books:h[1].slice(0,e),collections:h[2].slice(0,e),totalWorks:h[0].length,totalBooks:h[1].length,totalCollections:h[2].length}}async getItem(t){const e=await this.ensureLoaded(),s=this.promotions.get(t)??t,n=s!==t?t:void 0,o=this.pathMap.get(s);let i=null;if(o){const c=o.isDraft?this.config.repos.draft:this.config.repos.official;if(i=await this.fetchItemByPath(c,o.path),i){const a=e.find(h=>h.id===s);a!=null&&a.has_collated&&(i.has_collated=!0)}}else i=await this.findItemById(s);return i&&i.type==="entity"&&!i.title&&i.primary_name&&(i.title=i.primary_name),i&&n&&(i.redirected_from=n),i}async getEntry(t){const e=await this.ensureLoaded(),s=this.promotions.get(t)??t,n=s!==t?t:void 0,o=e.find(a=>a.id===s);if(o)return n?{...o,redirected_from:n}:o;const i=await this.findItemById(s);if(!i)return null;const c=this.buildEntryFromItem(s,i);return n?{...c,redirected_from:n}:c}async getAllEntries(){return this.ensureLoaded()}async saveItem(){throw new Error("GithubStorage 为只读模式,不支持保存")}async deleteItem(){throw new Error("GithubStorage 为只读模式,不支持删除")}async generateId(){throw new Error("GithubStorage 为只读模式,不支持生成 ID")}async fetchItemByPath(t,e){let s=null;const n=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(e)}`;try{s=await this.fetchJson(n)}catch{}if(!s)for(const o of this.config.cdnUrls){const i=`${o}/${this.config.org}/${t}@main/${encodeURI(e)}`;try{s=await this.fetchJson(i);break}catch{continue}}return s}async findItemById(t){const e={book:"Book",collection:"Collection",work:"Work",entity:"Entity"};let s,n;try{const u=A(I(t));s=u.type,n=u.status}catch{return null}const o=n==="draft"?this.config.repos.draft:this.config.repos.official,i=e[s],c=t.padEnd(3,"_").substring(0,3),a=`${i}/${c[0]}/${c[1]}/${c[2]}`,h=`https://api.github.com/repos/${this.config.org}/${o}/contents/${a}`;try{const u=await fetch(h,{signal:AbortSignal.timeout(this.config.timeout)});if(!u.ok)return null;const f=(await u.json()).find(_=>_.name.startsWith(`${t}-`)&&_.name.endsWith(".json"));if(!f)return null;const d=await this.fetchItemByPath(o,f.path);return d&&this.pathMap.set(t,{path:f.path,isDraft:n==="draft"}),d}catch{return null}}buildEntryFromItem(t,e){const s=(e.type||"").toLowerCase(),n=s==="work"?"work":s==="collection"?"collection":"book";let o;const i=e.authors;if(Array.isArray(i)&&i.length>0){const h=i[0];o=typeof h=="object"&&h!==null?h.name||"":String(h)}let c=!0;try{c=A(I(t)).status==="draft"}catch{}const a=this.pathMap.get(t);return{id:t,title:e.title||e.书名||t,type:n,isDraft:c,author:o,dynasty:e.dynasty,role:e.role,path:(a==null?void 0:a.path)||"",juan_count:e.n_juan,has_collated:e.has_collated}}async fetchFile(t,e){const s=`${this.config.baseUrl}/${this.config.org}/${t}/main/${encodeURI(e)}`;try{return await this.fetchJson(s)}catch{}for(const n of this.config.cdnUrls){const o=`${n}/${this.config.org}/${t}@main/${encodeURI(e)}`;try{return await this.fetchJson(o)}catch{continue}}return null}async resolveItemPath(t){await this.ensureLoaded();let e=this.pathMap.get(t);if(!e&&(await this.findItemById(t),e=this.pathMap.get(t),!e))return null;const s=e.isDraft?this.config.repos.draft:this.config.repos.official,n=e.path.substring(0,e.path.lastIndexOf("/"));return{repo:s,dir:n}}async getCollectionCatalogs(t){const e=await this.resolveItemPath(t);if(!e)return null;const s=await this.getItem(t);if(!s)return null;const n=s.resources||[];if(n.length===0)return null;const o=[];for(const i of n){const c=`${e.dir}/${t}/${i.id}/volume_book_mapping.json`,a=await this.fetchFile(e.repo,c);a&&o.push({resource_id:i.id,short_name:i.short_name,data:et(a)})}return o.length>0?o:null}async getCollectionCatalog(t){var s;const e=await this.getCollectionCatalogs(t);return((s=e==null?void 0:e[0])==null?void 0:s.data)??null}async getLineageGraph(t){const e=await this.resolveItemPath(t);if(!e)return null;const s=`${e.dir}/${t}/lineage_graph.json`;return this.fetchFile(e.repo,s)}async getCatalogProgress(){return this.fetchFile(this.config.repos.draft,"resource-catalog.json")}async getCollectionProgress(){return this.fetchFile(this.config.repos.draft,"resource-collection.json")}async getResourceProgress(){return this.fetchFile(this.config.repos.draft,"resource.json")}async getSiteProgress(){return this.fetchFile(this.config.repos.draft,"resource-site.json")}async getRecommended(){return this.fetchFile(this.config.repos.draft,"recommended.json")}clearCache(){this.cache=null,this.pathMap.clear(),this.searchSCache=null,this.t2sConverter=null}}const ht=255;class nt{constructor(t){if(this.lastTimestamp=-1,this.lastStatus=null,this.sequence=0,t<0||t>2047)throw new Error("Machine ID must be between 0 and 2047");this.machineId=t}nextId(t,e){let s=this._getCurrentTimestamp(t);if(s<this.lastTimestamp&&t===this.lastStatus)throw new Error("Clock moved backwards. Refusing to generate ID.");s===this.lastTimestamp&&t===this.lastStatus?(this.sequence=this.sequence+1&ht,this.sequence===0&&(s=this._tilNextUnit(this.lastTimestamp,t))):this.sequence=0,this.lastTimestamp=s,this.lastStatus=t;const n=K(t,e,BigInt(s),this.machineId,this.sequence);return W(n)}nextIdRaw(t,e){let s=this._getCurrentTimestamp(t);if(s<this.lastTimestamp&&t===this.lastStatus)throw new Error("Clock moved backwards. Refusing to generate ID.");return s===this.lastTimestamp&&t===this.lastStatus?(this.sequence=this.sequence+1&ht,this.sequence===0&&(s=this._tilNextUnit(this.lastTimestamp,t))):this.sequence=0,this.lastTimestamp=s,this.lastStatus=t,K(t,e,BigInt(s),this.machineId,this.sequence)}_getCurrentTimestamp(t){const e=Date.now();return t==="draft"?e:Math.floor(e/1e3)}_tilNextUnit(t,e){let s=this._getCurrentTimestamp(e);for(;s<=t;)s=this._getCurrentTimestamp(e);return s}}class Yt{constructor(t){this.recentEntities=[],this.storage=new tt(t.fs,t.workspaceRoot),this.idGen=new nt(t.machineId??0),this.fs=t.fs,this.workspaceRoot=t.workspaceRoot}async loadEntries(t,e){const s=await this.storage.loadEntries(t);return this.paginate(s,e)}async search(t,e,s){const n=await this.storage.searchEntries(t,e);return this.paginate(n,s)}async searchAll(t,e){return this.storage.searchAll(t,e)}async getItem(t){const e=await this.storage.getItem(t);return e&&e.type==="entity"&&!e.title&&e.primary_name&&(e.title=e.primary_name),e}async saveItem(t){const e=t.id;if(!e)throw new Error("metadata.id is required");const s=t.type||this.extractTypeFromId(e),n=await this.storage.saveItem(s,e,t);return{id:e,path:n}}async deleteItem(t){if(!await this.storage.deleteItem(t))throw new Error(`Item not found: ${t}`)}async generateId(t,e){return this.idGen.nextId(e,t)}async getEntry(t){const e=await this.storage.getItem(t);if(!e)return null;const s=e.type||this.extractTypeFromId(t);return{id:t,title:e.title||"未命名",type:s,author:this.extractAuthor(e),dynasty:this.extractYear(e)}}async getAllEntries(){const t=["book","collection","work"],e=[];for(const s of t){const n=await this.storage.loadEntries(s);e.push(...n)}return e}async getRelations(t){const e=await this.storage.getItem(t);if(!e)return null;const s={},n=e.type||this.extractTypeFromId(t);if(n==="book"){if(e.work_id){const o=await this.resolveEntity(e.work_id);o&&(s.belongsToWork={...o,type:"work"})}if(e.contained_in&&Array.isArray(e.contained_in)&&e.contained_in.length>0){const o=e.contained_in[0],i=typeof o=="string"?o:o.id;if(i){const c=await this.resolveEntity(i);c&&(s.belongsToCollection={...c,type:"collection"})}}}else if(n==="collection"){if(e.books&&Array.isArray(e.books)){const o=await Promise.all(e.books.map(i=>this.resolveEntity(i)));s.containedBooks=o.filter(i=>i!==null).map(i=>({...i,type:"book"}))}}else if(n==="work"){if(e.parent_work&&typeof e.parent_work=="object"){const o=e.parent_work;s.parentWork={id:o.id,title:o.title,type:"work"}}if(e.books&&Array.isArray(e.books)){const o=await Promise.all(e.books.map(i=>this.resolveEntity(i)));s.containedBooks=o.filter(i=>i!==null).map(i=>({...i,type:"book"}))}}return s}async linkEntity(t,e,s){const n=await this.storage.getItem(t);if(!n)throw new Error(`Source not found: ${t}`);const o=n.type||this.extractTypeFromId(t);switch(e){case"belongsToWork":case"work_id":n.work_id=s;break;case"belongsToCollection":case"contained_in":Array.isArray(n.contained_in)||(n.contained_in=[]);{const i=n.contained_in;i.some(a=>(typeof a=="string"?a:a.id)===s)||i.push({id:s})}break;case"parentWork":case"parent_work":{const i=await this.storage.getItem(s);n.parent_work={id:s,title:(i==null?void 0:i.title)||""};break}case"containedBooks":case"books":Array.isArray(n.books)||(n.books=[]),n.books.includes(s)||n.books.push(s);break;default:throw new Error(`Unknown relation field: ${e}`)}await this.storage.saveItem(o,t,n)}async unlinkEntity(t,e){const s=await this.storage.getItem(t);if(!s)throw new Error(`Source not found: ${t}`);const n=s.type||this.extractTypeFromId(t);switch(e){case"belongsToWork":case"work_id":delete s.work_id;break;case"belongsToCollection":case"contained_in":s.contained_in=[];break;case"parentWork":case"parent_work":delete s.parent_work;break;case"containedBooks":case"books":s.books=[];break;default:throw new Error(`Unknown relation field: ${e}`)}await this.storage.saveItem(n,t,s)}async createAndLink(t,e,s){const n=this.idGen.nextId("draft",s.type),o={id:n,type:s.type,title:s.title,...s.inheritData||{}};return await this.storage.saveItem(s.type,n,o),await this.linkEntity(t,e,n),{id:n}}async searchEntities(t,e){const s=e&&e!=="all"?[e]:["book","collection","work"],n=[];for(const o of s){const i=await this.storage.searchEntries(t,o);for(const c of i)n.push({id:c.id,title:c.title,type:c.type,author:c.author,dynasty:c.dynasty})}return n}async getRecentEntities(){return this.recentEntities}async addRecentEntity(t){this.recentEntities=[t,...this.recentEntities.filter(e=>e.id!==t.id)].slice(0,20)}async getCollectionCatalog(t){const e=await this.storage.findFileById(t);if(!e)return null;const n=e.substring(0,e.lastIndexOf("/"))+"/volume_book_mapping.json";try{const o=await this.storage.loadMetadata(n);return Object.keys(o).length===0?null:o}catch{return null}}async getRecommended(){const t=this.workspaceRoot+"/book-index-draft/recommended.json";try{const e=await this.fs.readFile(t);return JSON.parse(e)}catch{return null}}getAssetDir(t){return this.storage.getAssetDir(t)}async initAssetDir(t){return this.storage.initAssetDir(t)}async hasAssetDir(t){return this.storage.hasAssetDir(t)}getBookIndexStorage(){return this.storage}async rebuildIndex(t){await this.storage.rebuildIndex(t)}extractTypeFromId(t){try{const e=I(t);return A(e).type}catch{return"book"}}extractAuthor(t){const e=t.authors;if(Array.isArray(e)&&e.length>0){const s=e[0];return typeof s=="object"&&s!==null?s.name||"":String(s)}}extractYear(t){const e=t.publication_info;if(typeof e=="object"&&e!==null)return e.year||void 0}async resolveEntity(t){const e=await this.storage.getItem(t);return e?{id:t,title:e.title||"未命名"}:null}paginate(t,e){const s=e.page??1,n=e.pageSize??50;if(e.sortBy){const a=e.sortBy,h=e.sortOrder==="desc"?-1:1;t.sort((u,l)=>{const f=u[a]??"",d=l[a]??"";return f<d?-h:f>d?h:0})}const o=t.length,i=(s-1)*n;return{entries:t.slice(i,i+n),total:o,page:s,pageSize:n}}}const Vt=["default","manifest","fragments","sources"],Xt=/^[a-z][a-z0-9-]*$/;function X(r){return typeof r!="string"?!1:r==="default"?!0:Xt.test(r)&&!Vt.includes(r)}function Qt(r){return/^\d+$/.test(r)}function O(r){return r.length>0&&!r.includes("..")&&!/[\\/?#%\s\u0000-\u001f\u007f]/.test(r)}const Zt=/^(整理本|整理|转录全文|轉錄全文|转录|轉錄|全文|文本)$/;function te(r){var s;const t=ee(r),e=(s=r.edition_label)==null?void 0:s.trim();return e&&e!==t?`${e} · ${t}`:t}function ee(r){for(const t of[r.label,r.source_name]){const e=t==null?void 0:t.trim();if(e&&!Zt.test(e))return e}return r.label||r.source_name||r.key}function se(r,t){const e=(t==null?void 0:t.chapters)??[];if(e.length===0)return null;if(r){const s=e.find(n=>n.file===r.file);if(s)return s.file;if(r.n!==void 0){const n=e.find(o=>o.n===r.n);if(n)return n.file}}return e[0].file}function ne(r,t){const e=r==null?void 0:r.versions;if(!(!e||e.length===0))return(t!=null?e.find(s=>s.key===t):void 0)??e.find(s=>s.key==="default")??e[0]}const oe="/data",ie=1e4;class re{constructor(t={}){this.chunkCache=new Map,this.chunkLoading=new Map,this.manifest=null,this.manifestLoading=null,this.tiyaoCache=new Map,this.tiyaoLoading=new Map,this.metaCache=null,this.metaLoading=null,this.promotions=null,this.promotionsLoading=null,this.versionPromise=null,this.versionInjected=!1,this.basePath=t.basePath??oe,this.timeout=t.timeout??ie,t.version!==void 0&&(this.version=t.version??null,this.versionInjected=!0)}async ensureVersion(){return this.version!==void 0?this.version:this.versionPromise?this.versionPromise:(this.versionPromise=(async()=>{try{const t=await fetch(`${this.basePath}/version.json`,{cache:"no-cache",signal:AbortSignal.timeout(this.timeout)});if(!t.ok)return null;const e=await t.json(),s=e==null?void 0:e.commitId;return!s||s==="unknown"?null:s.slice(0,12)}catch{return null}})(),this.version=await this.versionPromise,this.version)}async fetchJson(t){const e=await this.ensureVersion(),s=e?`${t}${t.includes("?")?"&":"?"}v=${e}`:t,n=await fetch(s,{cache:"no-cache",signal:AbortSignal.timeout(this.timeout)});if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);return n.json()}async ensurePromotions(){if(this.promotions)return this.promotions;if(this.promotionsLoading)return this.promotionsLoading;this.promotionsLoading=(async()=>{try{const t=await this.fetchJson(`${this.basePath}/promotions.json`);this.promotions=st(t)}catch{this.promotions=new Map}return this.promotions})();try{return await this.promotionsLoading}finally{this.promotionsLoading=null}}async loadManifest(){if(this.manifest)return this.manifest;if(this.manifestLoading)return this.manifestLoading;this.manifestLoading=(async()=>{try{this.manifest=await this.fetchJson(`${this.basePath}/chunks/_manifest.json`)}catch{this.manifest=[]}return this.manifest})();try{return await this.manifestLoading}finally{this.manifest||(this.manifestLoading=null)}}async resolvePrefix(t){const e=await this.loadManifest();let s=0,n=e.length-1,o=null;for(;s<=n;){const i=s+n>>1;e[i]<=t?(o=e[i],s=i+1):n=i-1}if(o&&t.startsWith(o))return o;for(const i of e)if(t.startsWith(i))return i;return null}async loadChunk(t){if(this.chunkCache.has(t))return this.chunkCache.get(t);const e=this.chunkLoading.get(t);if(e)return e;const s=(async()=>{try{const n=await this.fetchJson(`${this.basePath}/chunks/${t}.json`);return this.chunkCache.set(t,n),n}catch{return this.chunkCache.set(t,{}),{}}})();this.chunkLoading.set(t,s);try{return await s}finally{this.chunkLoading.delete(t)}}async loadChunkForId(t){const e=await this.resolvePrefix(t);return e?this.loadChunk(e):{}}async loadTiyaoGroup(t,e){const s=`${t}-${e}`;if(this.tiyaoCache.has(s))return this.tiyaoCache.get(s);const n=this.tiyaoLoading.get(s);if(n)return n;const o=c=>String(c).padStart(3,"0"),i=(async()=>{const c=await this.fetchJson(`${this.basePath}/tiyao/juan-${o(t)}-${o(e)}.json`);return this.tiyaoCache.set(s,c),c})();this.tiyaoLoading.set(s,i);try{return await i}finally{this.tiyaoLoading.delete(s)}}async getCounts(){if(this.metaCache)return this.metaCache;if(this.metaLoading){const t=await this.metaLoading;if(t)return t;throw new Error("BundleStorage: meta.json 加载失败")}this.metaLoading=(async()=>{const t=await this.fetchJson(`${this.basePath}/meta.json`);if(!t||typeof t.works!="number")throw new Error("BundleStorage: meta.json 格式无效");return this.metaCache=t,t})();try{const t=await this.metaLoading;if(!t)throw new Error("BundleStorage: meta.json 加载失败");return t}finally{this.metaLoading=null}}async getResourceCounts(){return(await this.getCounts()).resourceCounts??{hasText:0,hasImage:0}}async getSubtypeStats(){return(await this.getCounts()).subtypeStats??{}}async loadEntries(t,e){throw new Error("BundleStorage.loadEntries 已废弃:请使用 worker 搜索")}async search(t,e,s){throw new Error("BundleStorage.search 已废弃:请使用 worker 搜索")}async searchAll(t,e=5){throw new Error("BundleStorage.searchAll 已废弃:请使用 worker 搜索")}async getItem(t){try{const s=(await this.ensurePromotions()).get(t)??t,n=s!==t?t:void 0,i=(await this.loadChunkForId(s))[s]||null;return i&&(i.type==="entity"&&!i.title&&i.primary_name&&(i.title=i.primary_name),n&&(i.redirected_from=n)),i}catch{return null}}async getEntry(t){var e,s;try{const o=(await this.ensurePromotions()).get(t)??t,i=o!==t?t:void 0,a=(await this.loadChunkForId(o))[o];if(!a)return null;const h=kt(o),u=h==="entity"?a.primary_name||a.title||a.name||o:a.title||a.name||o;return{id:o,title:u,type:h,isDraft:!0,author:a.author,dynasty:a.dynasty,role:a.role,additional_titles:(e=a.additional_titles)==null?void 0:e.map(l=>typeof l=="string"?l:l==null?void 0:l.book_title).filter(Boolean),attached_texts:(s=a.attached_texts)==null?void 0:s.map(l=>typeof l=="string"?l:l==null?void 0:l.book_title).filter(Boolean),edition:a.edition,juan_count:a.juan_count,has_text:a.has_text,has_image:a.has_image,has_collated:a.has_collated,subtype:a.subtype,primary_name:a.primary_name,birth_year:a.birth_year,death_year:a.death_year,cbdb_id:a.cbdb_id,...i?{redirected_from:i}:{}}}catch{return null}}async getAllEntries(){throw new Error("BundleStorage.getAllEntries 已废弃:请使用 getEntry / worker 搜索")}async saveItem(){throw new Error("BundleStorage 为只读模式,不支持保存")}async deleteItem(){throw new Error("BundleStorage 为只读模式,不支持删除")}async generateId(){throw new Error("BundleStorage 为只读模式,不支持生成 ID")}async getCollectionCatalogs(t){const e=await this.getItem(t);if(!e)return null;const s=e.resources||[];if(s.length===0)return null;const n=[];for(const o of s)try{const i=await this.fetchJson(`${this.basePath}/items/${t}/${o.id}/volume_book_mapping.json`);i&&n.push({resource_id:o.id,short_name:o.short_name,data:et(i)})}catch{}return n.length>0?n:null}async getCollectionCatalog(t){var s;const e=await this.getCollectionCatalogs(t);return((s=e==null?void 0:e[0])==null?void 0:s.data)??null}async getTextManifest(t){if(!O(t))return null;try{const e=await this.fetchJson(`${this.basePath}/items/${t}/manifest.json`);return e&&Array.isArray(e.versions)?e:null}catch{return null}}async getTextIndex(t,e){if(!O(t)||!X(e))return null;try{const s=await this.fetchJson(`${this.basePath}/items/${t}/${e}/index.json`);return s&&Array.isArray(s.chapters)?s:null}catch{return null}}async getChapter(t,e,s,n){if(!O(t)||!X(e)||!O(s))return null;const o=`${this.basePath}/items/${t}/${e}/${s}`,i=await this.ensureVersion(),c=i?`${o}.txt?v=${i}`:`${o}.txt`,a=fetch(c,{cache:"no-cache",signal:AbortSignal.timeout(this.timeout)}).then(f=>f.ok?f.text():null).catch(()=>null),h=n!=null&&n.json?this.fetchJson(`${o}.json`).catch(()=>null):Promise.resolve(null),[u,l]=await Promise.all([a,h]);return u!=null||l?{md:u,json:l}:null}async getLineageGraph(t){try{return await this.fetchJson(`${this.basePath}/items/${t}/lineage_graph.json`)}catch{return null}}async getCatalogProgress(){try{return await this.fetchJson(`${this.basePath}/resource-catalog.json`)}catch{return null}}async getCollectionProgress(){try{return await this.fetchJson(`${this.basePath}/resource-collection.json`)}catch{return null}}async getResourceProgress(){try{return await this.fetchJson(`${this.basePath}/resource.json`)}catch{return null}}async getSiteProgress(){try{return await this.fetchJson(`${this.basePath}/resource-site.json`)}catch{return null}}async getRecommended(){try{return await this.fetchJson(`${this.basePath}/recommended.json`)}catch{return null}}clearCache(){this.chunkCache.clear(),this.chunkLoading.clear(),this.manifest=null,this.manifestLoading=null,this.tiyaoCache.clear(),this.tiyaoLoading.clear(),this.metaCache=null,this.metaLoading=null,this.versionInjected||(this.version=void 0,this.versionPromise=null)}}class F extends Error{constructor(t){super(t),this.name="BookIndexError"}}class ae extends F{constructor(t){super(t),this.name="StorageError"}}class ce extends F{constructor(t){super(t),this.name="IdGenerationError"}}class le extends F{constructor(t){super(t),this.name="ConfigError"}}class he extends F{constructor(t){super(t),this.name="MigrationError"}}class ue{constructor(t,e,s=1){this.storage=new tt(t,e),this.idGen=new nt(s)}generateId(t="book",e="draft"){return this.idGen.nextIdRaw(e,t)}encodeId(t){return W(t)}decodeId(t){return I(t)}async saveItem(t,e,s="draft"){let n=t.id||t.ID;if(n)try{const i=L(n);e||(e=i.type)}catch{throw new F(`Invalid ID format: ${n}`)}else e||(e=t.type||"book"),n=this.idGen.nextId(s,e),t.id=n;return await this.storage.saveItem(e,n,t)}async getItem(t){return this.storage.getItem(t)}async findItemPath(t){return this.storage.findFileById(t)}async updateField(t,e,s){const n=await this.storage.findFileById(t);if(!n)return!1;try{const o=await this.storage.loadMetadata(n),i={基本信息:null,介绍:"description",资源:"resources",收藏历史:"history",其他版本:"related_books"},c=e in i?i[e]:e;if(c===null)return!1;if(c==="description"&&typeof s=="string"){const h=o[c]||{};o[c]={text:s,sources:h.sources||[]}}else o[c]=s;const a=L(t);return await this.storage.saveItem(a.type,t,o),!0}catch{return!1}}async deleteItem(t){return this.storage.deleteItem(t)}async rebuildIndices(){await this.storage.rebuildIndex("official"),await this.storage.rebuildIndex("draft")}getAssetDir(t){return this.storage.getAssetDir(t)}async initAssetDir(t){return this.storage.initAssetDir(t)}async hasAssetDir(t){return this.storage.hasAssetDir(t)}getStorage(){return this.storage}}const fe={wikisource:"wikisource",shidianguji:"shidianguji",archive:"archive",ctext:"ctext",nlc:"nlc","read.nlc":"nlc","db.sido":"sido","guji.artx":"guji-artx","digital.library":"digital-library"},ut=new Set(["text","image","text+image","physical"]),ft=new Set(["text","image","physical"]),de=new Set(["catalog","search"]),ye=new Set(["com","org","net","cn","edu","gov","io","jp","tw","hk"]);function ge(r){if(!r)return"";try{const e=new URL(r).hostname;for(const[n,o]of Object.entries(fe))if(e.includes(n))return o;const s=e.split(".");if(s.length>=2){const n=s.filter(o=>!ye.has(o)&&o.length>2);return n.length>0?n[n.length-1]:s[s.length-2]}return e}catch{return""}}function pe(r){const t=[];r.name||t.push("name is required");let e=!1;if(r.types!==void 0)if(!Array.isArray(r.types)||r.types.length===0)t.push("types must be a non-empty array when present");else{for(const s of r.types)ft.has(s)||t.push(`invalid types atom '${s}', must be one of ${[...ft].join(", ")}`);e=r.types.length===1&&r.types[0]==="physical"}else r.type!==void 0?(ut.has(r.type)||t.push(`invalid type '${r.type}', must be one of ${[...ut].join(", ")}`),e=r.type==="physical"):t.push("either type or types is required");return r.root_type&&!de.has(r.root_type)&&t.push(`invalid root_type '${r.root_type}'`),!e&&!r.url&&t.push("url is required for non-physical resources"),t}const b=class b{constructor(t,e=""){if(this._type=null,this.title=e,typeof t=="string"){t.startsWith(b.PREFIX)&&(t=t.slice(b.PREFIX.length)),this.idStr=t;try{this.idInt=I(t)}catch{this.idInt=0n}}else this.idInt=t,this.idStr=W(t);if(this.idInt>0n)try{const s=L(this.idStr);this._type=s.type}catch{}}get type(){return this._type}getIcon(){return this._type===null?"":this._type==="book"?"📖 ":this._type==="collection"?"📚 ":this._type==="work"?"📜 ":""}render(t=!1){return`[${t?this.getIcon():""}${this.title}](${b.PREFIX}${this.idStr})`}static parseFromLink(t){const e=t.match(/\[(.*?)\]\((.*?)\)/);if(e){const s=e[1],n=e[2];if(n.startsWith(b.PREFIX)){const o=n.slice(b.PREFIX.length);return new b(o,s)}}return null}static isBidLink(t){return t.startsWith(b.PREFIX)}};b.PROTOCOL="bid:\\\\",b.PREFIX="bid:\\\\";let Q=b;exports.BidLink=Q;exports.BookIndexError=F;exports.BookIndexManager=ue;exports.BookIndexStorage=tt;exports.BundleStorage=re;exports.ConfigError=le;exports.GithubStorage=Kt;exports.IdGenerationError=ce;exports.IdGenerator=nt;exports.LocalStorage=Yt;exports.MigrationError=he;exports.StorageError=ae;exports.base36Decode=Z;exports.base36Encode=W;exports.base58Decode=bt;exports.buildId=K;exports.buildPromotionMap=st;exports.cleanName=It;exports.decodeId=Ut;exports.decodeIdString=L;exports.encodeId=Mt;exports.extractIdFromUrl=ge;exports.extractStatus=Ot;exports.extractType=kt;exports.isChapterSegment=Qt;exports.isSafeSegment=O;exports.isTextKey=X;exports.matchChapterAcrossVersions=se;exports.normalizeCatalog=et;exports.parseId=A;exports.pickTextVersion=ne;exports.shardOf=G;exports.smartDecode=I;exports.textVersionLabel=te;exports.validateResource=pe;
|
package/dist/storage.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./storage-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./storage-entry-DPsx0DgD.cjs");exports.BidLink=r.BidLink;exports.BookIndexError=r.BookIndexError;exports.BookIndexManager=r.BookIndexManager;exports.BookIndexStorage=r.BookIndexStorage;exports.BundleStorage=r.BundleStorage;exports.ConfigError=r.ConfigError;exports.GithubStorage=r.GithubStorage;exports.IdGenerationError=r.IdGenerationError;exports.IdGenerator=r.IdGenerator;exports.LocalStorage=r.LocalStorage;exports.MigrationError=r.MigrationError;exports.StorageError=r.StorageError;exports.buildPromotionMap=r.buildPromotionMap;exports.extractIdFromUrl=r.extractIdFromUrl;exports.validateResource=r.validateResource;
|
package/dist/storage.d.ts
CHANGED
|
@@ -1646,6 +1646,8 @@ declare interface TextVersion {
|
|
|
1646
1646
|
kind: TextKind;
|
|
1647
1647
|
/** 下拉显示名——只写来源(整理本/維基文庫/維基文庫 2) */
|
|
1648
1648
|
label: string;
|
|
1649
|
+
/** 版本名(底本):「四部叢刊本」「文淵閣四庫全書本」;可选,没有就不写(book-text 901182c50b) */
|
|
1650
|
+
edition_label?: string;
|
|
1649
1651
|
/** 来源短名:collated/wikisource/kanripo/shidian… */
|
|
1650
1652
|
source?: string;
|
|
1651
1653
|
source_name?: string;
|
package/dist/storage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as o, b as e, c as s, d as t, f as n, C as d, G as i, I as g, g as I, L as B, M as S, S as l, n as u, u as x, D as E } from "./storage-entry-
|
|
1
|
+
import { B as o, b as e, c as s, d as t, f as n, C as d, G as i, I as g, g as I, L as B, M as S, S as l, n as u, u as x, D as E } from "./storage-entry-BezDJLqe.js";
|
|
2
2
|
export {
|
|
3
3
|
o as BidLink,
|
|
4
4
|
e as BookIndexError,
|