book-index-ui 0.1.9 → 0.1.10

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 CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Ut=Object.create;var Ve=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Zt=(t,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Gt(n))!Jt.call(t,r)&&r!==i&&Ve(t,r,{get:()=>n[r],enumerable:!(o=Yt(n,r))||o.enumerable});return t};var Xt=(t,n,i)=>(i=t!=null?Ut(Kt(t)):{},Zt(n||!t||!t.__esModule?Ve(i,"default",{value:t,enumerable:!0}):i,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./storage-entry-PvW2YlW7.cjs"),e=require("react/jsx-runtime"),p=require("react"),je=p.createContext(null),ht={indexType:{work:"作品",book:"書籍",collection:"叢編"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"實體資源"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"實體"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:"#e8f5e9",fg:"#2e7d32"},粗校:{label:"粗校",bg:"#fff3e0",fg:"#e65100"},AI整理:{label:"AI整理",bg:"#e3f2fd",fg:"#1565c0"}},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:"+ 添加收錄來源",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:"上級作品",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:"📖 著錄於",resources:"資源",textResources:"📝 文字資源 (Text Resources)",imageResources:"🖼️ 圖片資源 (Image Resources)",sources:"📚 資料來源 (Sources)",provenance:"📜 收藏歷史 (Provenance)",relatedVersions:"相關版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危險區域 (Danger Zone)",aliases:"別名",appendix:"附錄",containedIn:"收入",belongsToWork:"所屬作品",locationHistory:"流轉���史",historyOverview:"歷史沿革",containedBooks:"收錄書籍",relations:"關聯關係",summary:"提要",comment:"按語",additionalComment:"附按",indexed:"收錄",relatedWorks:"相關作品",containedWorks:"包含作品"},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:"清除全部",searchTitle:"搜索古籍索引",searchSubtitle:"輸入關鍵詞搜索作品、書籍或叢編",searchBookName:"搜索書名...",alias:"別名"},home:{title:"古籍索引",subtitle:"從左側搜索框輸入關鍵詞,查找作品、書籍或叢編",recommendedBrowse:"推薦瀏覽",catalogTab:"叢書目錄",siteTab:"在線資源",recommendTab:"推薦",statusInProgress:"進行中",statusDone:"已完成",statusTodo:"未開始",typeCatalog:"目錄",typeCollection:"資源集合",totalPending:"待統計",progressFormat:"{imported} / {total}",siteCoverage:"資源覆蓋"},browser:{title:"古籍資源索引",subtitle:""},detailTab:{basicInfo:"基本信息",catalog:"目錄",collectionCatalog:"叢編目錄",collatedEdition:"整理本",catalogSuffix:"·目錄"},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)",dynastyLabel:"朝代/年份 (Dynasty/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:"條"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暫無資源信息",hasTranslation:"有",noTranslation:"無",structure:"層級",coverage:"覆蓋",notFoundEntry:"未找到該條目",loadFailed:"加載失敗",textResource:"文字資源",imageResource:"圖片資源"}},qt={indexType:{work:"作品",book:"书籍",collection:"丛编"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"实体资源"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"实体"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:"#e8f5e9",fg:"#2e7d32"},粗校:{label:"粗校",bg:"#fff3e0",fg:"#e65100"},AI整理:{label:"AI整理",bg:"#e3f2fd",fg:"#1565c0"}},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:"+ 添加收录来源",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:"上级作品",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:"📖 著录于",resources:"资源",textResources:"📝 文字资源 (Text Resources)",imageResources:"🖼️ 图片资源 (Image Resources)",sources:"📚 资料来源 (Sources)",provenance:"📜 收藏历史 (Provenance)",relatedVersions:"相关版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危险区域 (Danger Zone)",aliases:"别名",appendix:"附录",containedIn:"收入",belongsToWork:"所属作品",locationHistory:"流转历史",historyOverview:"历史沿革",containedBooks:"收录书籍",relations:"关联关系",summary:"提要",comment:"按语",additionalComment:"附按",indexed:"收录",relatedWorks:"相关作品",containedWorks:"包含作品"},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:"清除全部",searchTitle:"搜索古籍索引",searchSubtitle:"输入关键词搜索作品、书籍或丛编",searchBookName:"搜索书名...",alias:"别名"},home:{title:"古籍索引",subtitle:"从左侧搜索框输入关键词,查找作品、书籍或丛编",recommendedBrowse:"推荐浏览",catalogTab:"丛书目录",siteTab:"在线资源",recommendTab:"推荐",statusInProgress:"进行中",statusDone:"已完成",statusTodo:"未开始",typeCatalog:"目录",typeCollection:"资源集合",totalPending:"待统计",progressFormat:"{imported} / {total}",siteCoverage:"资源覆盖"},browser:{title:"古籍资源索引",subtitle:""},detailTab:{basicInfo:"基本信息",catalog:"目录",collectionCatalog:"丛编目录",collatedEdition:"整理本",catalogSuffix:"·目录"},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)",dynastyLabel:"朝代/年份 (Dynasty/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:"条"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暂无资源信息",hasTranslation:"有",noTranslation:"无",structure:"层级",coverage:"覆盖",notFoundEntry:"未找到该条目",loadFailed:"加载失败",textResource:"文字资源",imageResource:"图片资源"}},Qt={"zh-Hant":ht,"zh-Hans":qt},bt="bim-locale";function en(){try{const t=localStorage.getItem(bt);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function tn(t){try{localStorage.setItem(bt,t)}catch{}}const nn=({locale:t,onLocaleChange:n,children:i})=>{const[o,r]=p.useState(t??en()??"zh-Hant"),l=t??o,[d,s]=p.useState(null);p.useEffect(()=>{l==="zh-Hans"?import("opencc-js/t2cn").then(g=>{const u=g.Converter({from:"tw",to:"cn"});s(()=>u)}).catch(()=>{s(()=>g=>g)}):s(null)},[l]);const a=p.useCallback(g=>{r(g),tn(g),n==null||n(g)},[n]),x=p.useMemo(()=>({locale:l,setLocale:a,messages:Qt[l],converter:d}),[l,a,d]);return e.jsx(je.Provider,{value:x,children:i})};function $(){const t=p.useContext(je);return(t==null?void 0:t.messages)??ht}const on=2e3;function F(){const t=p.useContext(je),n=(t==null?void 0:t.locale)??"zh-Hant",i=(t==null?void 0:t.converter)??null,o=p.useRef(new Map),r=p.useRef(n);r.current!==n&&(o.current.clear(),r.current=n);const l=p.useCallback(d=>{if(!d)return"";if(!i)return d;const s=o.current.get(d);if(s!==void 0)return s;const a=i(d);if(o.current.size>=on){const x=o.current.keys().next().value;x!==void 0&&o.current.delete(x)}return o.current.set(d,a),a},[i]);return p.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function Se(t,n){return t.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}function rn(t){if(!t)return"";try{const n=new URL(t).hostname,i={"zh.wikisource.org":"wikisource","www.shidianguji.com":"shidianguji","shidianguji.com":"shidianguji","archive.org":"archive","ctext.org":"ctext","read.nlc.cn":"nlc","www.digital.archives.go.jp":"japan_archives"};if(i[n])return i[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function ln(){return{id:"",name:"",url:"",type:"text",details:""}}const We=({items:t,onChange:n,onDownload:i,downloadStatuses:o,filterType:r})=>{const l=$(),[d,s]=p.useState(null),a=[{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}],x=[{value:"catalog",label:l.rootType.catalog},{value:"search",label:l.rootType.search}],g=b=>r?r==="text"?b==="text"||b==="text+image":r==="image"?b==="image"||b==="text+image"||b==="physical":b===r:!0,u=t.map((b,_)=>({item:b,originalIndex:_})).filter(({item:b})=>g(b.type)),f=()=>{const b=ln();r&&(b.type=r),n([...t,b]),s(t.length)},c=b=>{n(t.filter((_,y)=>y!==b)),s(null)},j=(b,_,y)=>{const w=[...t];if(w[b]={...w[b],[_]:y},_==="url"&&!w[b].id){const C=rn(y);C&&(w[b].id=C)}n(w)},S=(b,_,y)=>{const C={...t[b].metadata||{}};y?C[_]=y:delete C[_],j(b,"metadata",Object.keys(C).length>0?C:void 0)},h=(b,_)=>{const y=_.trim()?_.split(/[,,、]/).map(w=>w.trim()).filter(Boolean):void 0;j(b,"structure",y)},W=(b,_,y)=>{const C=t[b].coverage||{level:1,ranges:""};_==="level"?C.level=parseInt(y)||1:C.ranges=y,j(b,"coverage",C.ranges?C:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[u.map(({item:b,originalIndex:_})=>{var y,w,C,v;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>s(d===_?null:_),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:d===_?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:sn(b.type),color:"#fff"},children:((y=a.find(m=>m.value===b.type))==null?void 0:y.label)||b.type}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${l.editor.resourcePlaceholder} ${_+1}`}),b.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&e.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&b.url&&an(_,o==null?void 0:o[_],i,l),e.jsx("button",{onClick:m=>{m.stopPropagation(),c(_)},style:{background:"transparent",border:"none",color:"var(--bim-danger, #f44336)",cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),d===_&&e.jsxs("div",{style:{padding:"12px",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[(b.type==="image"||b.type==="text+image")&&b.url&&dn(b,l),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:be,children:[e.jsx("span",{style:me,children:l.label.type}),e.jsx("select",{value:b.type,onChange:m=>j(_,"type",m.target.value),style:{...oe,flex:1},children:a.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))})]}),e.jsxs("label",{style:be,children:[e.jsx("span",{style:me,children:l.label.rootType}),e.jsx("select",{value:b.root_type||"catalog",onChange:m=>j(_,"root_type",m.target.value),style:{...oe,flex:1},children:x.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:b.id,onChange:m=>j(_,"id",m.target.value),placeholder:l.editor.idAutoExtract,style:{...oe,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:b.name,onChange:m=>j(_,"name",m.target.value),placeholder:l.editor.resourceName,style:{...oe,flex:1}})]}),e.jsx("input",{type:"text",value:b.url,onChange:m=>j(_,"url",m.target.value),placeholder:l.editor.resourceUrl,style:oe}),e.jsx("input",{type:"text",value:((w=b.structure)==null?void 0:w.join("、"))||"",onChange:m=>h(_,m.target.value),placeholder:l.editor.structurePlaceholder,style:oe}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:be,children:[e.jsx("span",{style:me,children:l.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((C=b.coverage)==null?void 0:C.level)??"",onChange:m=>W(_,"level",m.target.value),placeholder:"1",style:{...oe,width:"60px"}})]}),e.jsxs("label",{style:{...be,flex:1},children:[e.jsx("span",{style:me,children:l.label.coverageRange}),e.jsx("input",{type:"text",value:((v=b.coverage)==null?void 0:v.ranges)||"",onChange:m=>W(_,"ranges",m.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...oe,flex:1}})]})]}),e.jsx("textarea",{value:b.details||"",onChange:m=>j(_,"details",m.target.value),placeholder:l.editor.detailsPlaceholder,style:{...oe,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:"1px solid var(--bim-widget-border, #e0e0e0)",paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginBottom:"6px"},children:l.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([m,R])=>{var I;return e.jsxs("label",{style:{...be,gap:"4px"},children:[e.jsx("span",{style:{...me,minWidth:"56px"},children:R}),e.jsx("input",{type:"text",value:((I=b.metadata)==null?void 0:I[m])||"",onChange:A=>S(_,m,A.target.value),placeholder:R,style:{...oe,flex:1}})]},m)})})]})]})]})]},_)}),e.jsxs("button",{onClick:f,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:"1px dashed var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"transparent",color:"var(--bim-fg, #333)",cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:l.action.addResource})]})]})};function sn(t){switch(t){case"text":return"#2196f3";case"image":return"#ff9800";case"text+image":return"#9c27b0";case"physical":return"#795548"}}function an(t,n,i,o){const r=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return e.jsx("button",{onClick:d=>{d.stopPropagation(),r||i(t,"")},disabled:r,style:{background:"transparent",border:"none",color:l?"var(--bim-success, #4caf50)":r?"var(--bim-desc-fg, #717171)":"var(--bim-link-fg, #0066cc)",cursor:r?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:r?.6:.9},title:l?o.download.completed:r?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:l?"✓":r?"⏳":"⬇"})}function dn(t,n){const i=/\.(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:i?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:"#00000010"},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:"#00000010",borderRadius:"4px",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:n.editor.imageResourceLink})})}const oe={width:"100%",padding:"6px 8px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},be={display:"flex",alignItems:"center",gap:"6px"},me={fontSize:"12px",color:"var(--bim-desc-fg, #717171)",whiteSpace:"nowrap"},cn={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃"};function pn(t){try{const n=new URL(t).hostname;return cn[n]}catch{return}}const Ne={text:"#2196f3",image:"#ff9800","text+image":"#9c27b0",physical:"#795548"},xn=["text","image","text+image","physical"];function un(t){const n=l=>{const d=l.match(/^(.+?)·第(\d+)[冊册]$/);if(d)return[d[1],parseInt(d[2])];const s=l.match(/^(.+?)[·(](\d+)[)]?$/);return s?[s[1],parseInt(s[2])]:null},i=new Map,o=[],r=new Set;for(let l=0;l<t.length;l++){const d=t[l];if(d.volumes&&d.volumes.length>0)continue;const s=n(d.name);if(!s)continue;const[a,x]=s,g=`${a}|${d.type}`;i.has(g)||i.set(g,{base:{...d,name:a,url:"",volumes:[]},volumes:[]}),i.get(g).volumes.push({volume:x,url:d.url||void 0,status:"found"}),r.add(l)}for(const[,l]of i)if(l.volumes.length>=2)l.volumes.sort((d,s)=>d.volume-s.volume),l.base.volumes=l.volumes,l.base.expected_volumes=l.volumes.length,o.push(l.base);else for(let d=0;d<t.length;d++)if(r.has(d)){const s=n(t[d].name);s&&`${s[0]}|${t[d].type}`==`${l.base.name}|${l.base.type}`&&r.delete(d)}for(let l=0;l<t.length;l++)r.has(l)||o.push(t[l]);return o}const De=({items:t,groupByType:n=!0})=>{const i=$(),o=p.useMemo(()=>un(t||[]),[t]),r={text:i.resourceType.text,image:i.resourceType.image,"text+image":i.resourceType.textImage,physical:i.resourceType.physical};if(!o||o.length===0)return e.jsx("div",{style:{padding:"16px",color:"var(--bim-desc-fg, #717171)",fontSize:"13px",textAlign:"center"},children:i.misc.noResources});if(!n)return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:o.map((d,s)=>e.jsx(Ye,{item:d},d.id||s))});const l=xn.map(d=>({type:d,items:o.filter(s=>s.type===d)})).filter(d=>d.items.length>0);return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:l.map(({type:d,items:s})=>e.jsxs("div",{children:[e.jsxs("h4",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:600,color:Ne[d],display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{display:"inline-block",width:"4px",height:"14px",borderRadius:"2px",background:Ne[d]}}),r[d],e.jsxs("span",{style:{fontWeight:400,opacity:.6},children:["(",s.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:s.map((a,x)=>e.jsx(Ye,{item:a},a.id||x))})]},d))})},Ue=t=>{const n=t.volumes&&t.volumes.length>0;return t.details&&!n||t.structure||t.coverage||t.metadata&&Object.keys(t.metadata).length>0},mt=({value:t})=>{const i=$().checkType[t];return i?e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",borderRadius:"3px",fontSize:"11px",fontWeight:500,background:i.bg,color:i.fg},children:i.label}):e.jsx("span",{children:t})},gn=(t,n,i,o)=>{if(t==="check_type"&&typeof n=="string")return e.jsx(mt,{value:n});if(t==="has_translation")return n?i.misc.hasTranslation:i.misc.noTranslation;const r=String(n);return o?o(r):r};function fn(t,n){try{if(new URL(t).hostname.includes("wikimedia.org")){const r=t.match(/\/wiki\/File:(.+?)(?:#|$)/);if(r)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(r[1]))}&page=${n}`;const l=new URL(t);return l.searchParams.set("page",String(n)),l.toString()}return t}catch{return t}}function hn(t){if(!t)return;const n=t.file_page_range||t.page_range;if(!n||typeof n!="string")return;const i=n.match(/^(\d+)/);return i?parseInt(i[1],10):void 0}function bn(t){if(t.url)return t.url;for(const[n,i]of Object.entries(t))if(n.endsWith("_url")&&typeof i=="string")return i}const mn={bw:{label:"",bg:"#f5f5f5",fg:"#757575"},color:{label:"",bg:"#fff8e1",fg:"#f57f17"}},Ye=({item:t})=>{var f;const n=$(),{convert:i}=F(),[o,r]=p.useState(!1),l=p.useMemo(()=>(t.url?pn(t.url):void 0)||i(t.name),[t.url,t.name,i]),d=p.useMemo(()=>!t.volumes||t.volumes.length===0?null:t.volumes.map(c=>({...c,url:c.url||bn(c)})),[t.volumes]),s=d&&d.length>0,a=s?d.filter(c=>c.status!=="missing").length:0,x=s?d.length-a:0,g=t.expected_volumes??(s?d.length:0),u=t.color_mode?{...mn[t.color_mode],label:n.colorMode[t.color_mode]}:null;return e.jsxs("div",{style:{padding:"10px 14px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:Ue(t)||s?"6px":"0"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:"var(--bim-fg, #333)"},children:l}),u&&e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",borderRadius:"3px",fontSize:"11px",fontWeight:500,background:u.bg,color:u.fg},children:u.label}),t.source_label&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)",fontStyle:"italic"},children:t.source_label}),((f=t.metadata)==null?void 0:f.check_type)&&e.jsx(mt,{value:t.metadata.check_type}),s&&e.jsxs("button",{onClick:()=>r(!o),style:{padding:"1px 8px",fontSize:"11px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"3px",background:"transparent",color:"var(--bim-desc-fg, #717171)",cursor:"pointer"},children:[a,"/",g,n.unit.volume,x>0&&e.jsxs("span",{style:{color:"#e67e22",marginLeft:"4px"},children:["缺",x]}),e.jsx("span",{style:{marginLeft:"4px"},children:o?"▲":"▼"})]}),t.url&&e.jsx("a",{href:(()=>{const c=hn(t.metadata);return c?fn(t.url,c):t.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--bim-link-fg, #0066cc)",textDecoration:"none"},children:n.action.visit})]}),Ue(t)&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",display:"flex",gap:"12px",flexWrap:"wrap"},children:[t.metadata&&Object.entries(t.metadata).filter(([c])=>c!=="check_type").map(([c,j])=>e.jsxs("span",{children:[n.metadata[c]||c,": ",gn(c,j,n,i)]},c)),t.details&&!s&&e.jsx("span",{children:i(t.details)}),t.structure&&e.jsxs("span",{children:[n.misc.structure,": ",t.structure.join(" → ")]}),t.coverage&&e.jsxs("span",{children:[n.misc.coverage,": L",t.coverage.level," ",t.coverage.ranges]})]}),s&&o&&e.jsx("div",{style:{marginTop:"8px",padding:"8px 0",borderTop:"1px solid var(--bim-widget-border, #f0f0f0)",display:"flex",flexWrap:"wrap",gap:"4px"},children:d.map(c=>{const j=c.status==="missing";return e.jsx("span",{style:{display:"inline-flex"},children:c.url&&!j?e.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 6px",fontSize:"11px",borderRadius:"3px",border:"1px solid var(--bim-widget-border, #e0e0e0)",color:"var(--bim-link-fg, #0066cc)",textDecoration:"none",lineHeight:1.4},title:c.label||`${c.volume}`,children:c.volume}):e.jsx("span",{style:{display:"inline-block",padding:"2px 6px",fontSize:"11px",borderRadius:"3px",border:"1px solid transparent",color:j?"#e67e22":"var(--bim-desc-fg, #999)",textDecoration:j?"line-through":"none",opacity:j?.6:1,lineHeight:1.4},children:c.volume})},c.volume)})})]})},yt=({indexSource:t,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:r,onConfigurePath:l,onSelectFolder:d})=>{const s=$(),a=t==="local",x=(n==null?void 0:n.isDraft)??!0,g=(n==null?void 0:n.repoPath)||"",u=g?g.split(/[/\\]/).pop()||g:"",f={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:"var(--bim-primary-soft, #0078d415)",color:"var(--bim-primary, #0078d4)"},c={onMouseOver:S=>S.currentTarget.style.opacity="0.8",onMouseOut:S=>S.currentTarget.style.opacity="1"},j=e.jsxs("div",{onClick:r,title:x?s.mode.switchToOfficial:s.mode.switchToDraft,style:{...f,background:x?"var(--bim-warning, #ff9800)":"var(--bim-success, #4caf50)",color:"white"},...c,children:[e.jsx("span",{children:x?"📝":"📚"}),e.jsx("span",{children:x?"draft":"official"})]});return i==="index-browser"?a?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[j,e.jsxs("div",{onClick:o,title:s.mode.switchToSync,style:f,...c,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:s.mode.localMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:d,title:g||s.mode.selectFolder,style:{...f,paddingLeft:"8px",paddingRight:"8px"},...c,children:[e.jsx("span",{children:"📂"}),u&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[j,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:o,title:s.mode.switchToLocal,style:f,...c,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:s.mode.syncMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:l,title:u||s.mode.configurePath,style:{...f,background:"transparent",padding:"6px",fontSize:"12px"},...c,children:e.jsx("span",{children:"⚙️"})})]})]}):e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsxs("div",{onClick:o,title:a?s.mode.switchToGithub:s.mode.switchToLocal,style:f,...c,children:[e.jsx("span",{children:a?"📁":"🌐"}),e.jsx("span",{children:a?s.mode.localMode:s.mode.githubSync}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),a&&e.jsxs("div",{onClick:d,title:g||s.mode.selectFolder,style:{...f,paddingLeft:"8px",paddingRight:"8px",minWidth:g?"100px":"auto",justifyContent:"space-between"},...c,children:[e.jsx("span",{children:"📂"}),u&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]}),!a&&u&&e.jsxs("div",{style:{...f,background:"#2196f3",color:"white",cursor:"default"},title:g,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:u})]})]})},_e="bim-search-history",Ge=10,Ke=8;function ve(){try{const t=localStorage.getItem(_e);return t?JSON.parse(t):[]}catch{return[]}}function yn(t){try{const n=ve().filter(i=>i!==t);n.unshift(t),n.length>Ge&&(n.length=Ge),localStorage.setItem(_e,JSON.stringify(n))}catch{}}function vn(t){try{const n=ve().filter(i=>i!==t);localStorage.setItem(_e,JSON.stringify(n))}catch{}}function jn(){try{localStorage.removeItem(_e)}catch{}}const vt=({transport:t,value:n,onChange:i,onSearch:o,onEntrySelect:r,placeholder:l})=>{const d=$(),s=l??d.search.placeholder,a={work:d.indexType.work,book:d.indexType.book,collection:d.indexType.collection},[x,g]=p.useState(!1),[u,f]=p.useState([]),[c,j]=p.useState(-1),[S,h]=p.useState(null),[W,b]=p.useState(ve),_=p.useRef(null),y=p.useRef(null),w=p.useRef(null);p.useEffect(()=>{if(!t.getAllEntries)return;let k=!1;return t.getAllEntries().then(B=>{k||h(B)}).catch(()=>{}),()=>{k=!0}},[t]);const C=p.useCallback(k=>{if(!k.trim())return W.map(z=>({type:"history",text:z}));if(!S)return[];const B=k.toLowerCase(),H=[],E=[];for(const z of S){if(H.length+E.length>=Ke*2)break;const D=z.title.toLowerCase();if(D.startsWith(B))H.push({type:"entry",text:z.title,entry:z});else if(D.includes(B))E.push({type:"entry",text:z.title,entry:z});else if(z.additional_titles){for(const N of z.additional_titles)if(N.toLowerCase().includes(B)){H.push({type:"entry",text:`${z.title}`,entry:z});break}}}return[...H,...E].slice(0,Ke)},[S,W]);p.useEffect(()=>{f(C(n)),j(-1)},[n,C]),p.useEffect(()=>{const k=B=>{w.current&&!w.current.contains(B.target)&&g(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]),p.useEffect(()=>{const k=B=>{var H,E;if(B.key==="/"&&document.activeElement!==_.current){const z=(H=document.activeElement)==null?void 0:H.tagName;if(z==="INPUT"||z==="TEXTAREA"||z==="SELECT")return;B.preventDefault(),(E=_.current)==null||E.focus()}};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[]);const v=p.useCallback(k=>{k.trim()&&(yn(k.trim()),b(ve())),o(k),g(!1)},[o]),m=p.useCallback(k=>{k.type==="history"?(i(k.text),v(k.text)):k.entry&&(r?(r(k.entry),g(!1)):(i(k.text),v(k.text)))},[i,v,r]),R=p.useCallback(k=>{if(!x||u.length===0){k.key==="Enter"&&v(n);return}switch(k.key){case"ArrowDown":k.preventDefault(),j(B=>(B+1)%u.length);break;case"ArrowUp":k.preventDefault(),j(B=>(B-1+u.length)%u.length);break;case"Enter":k.preventDefault(),c>=0&&c<u.length?m(u[c]):v(n);break;case"Escape":k.preventDefault(),g(!1);break}},[x,u,c,n,v,m]),I=p.useCallback((k,B)=>{B.stopPropagation(),vn(k),b(ve()),f(H=>H.filter(E=>!(E.type==="history"&&E.text===k)))},[]),A=p.useCallback(k=>{k.stopPropagation(),jn(),b([]),f([])},[]);p.useEffect(()=>{if(c>=0&&y.current){const k=y.current.children;k[c]&&k[c].scrollIntoView({block:"nearest"})}},[c]);const L=!n.trim()&&W.length>0;return e.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[e.jsx("input",{ref:_,type:"text",placeholder:s,value:n,onChange:k=>{i(k.target.value),g(!0)},onFocus:()=>g(!0),onKeyDown:R,style:{width:"100%",padding:"8px 12px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"6px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",fontSize:"14px",boxSizing:"border-box"}}),x&&u.length>0&&e.jsxs("div",{ref:y,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:"var(--bim-input-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",zIndex:100,maxHeight:"320px",overflow:"auto"},children:[L&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:"var(--bim-desc-fg, #717171)",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[e.jsx("span",{children:d.search.history}),e.jsx("button",{onClick:A,style:{border:"none",background:"transparent",color:"var(--bim-desc-fg, #717171)",cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:d.search.clearAll})]}),u.map((k,B)=>e.jsxs("div",{onClick:()=>m(k),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:"var(--bim-fg, #333)",background:B===c?"var(--bim-list-active-bg, #e8f0fe)":"transparent"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:k.type==="history"?"🕐":"🔍"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.text}),k.entry&&e.jsxs("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)",flexShrink:0},children:[a[k.entry.type],k.entry.edition&&` · ${k.entry.edition}`,k.entry.author&&` · ${k.entry.author}`]}),k.type==="history"&&e.jsx("button",{onClick:H=>I(k.text,H),style:{border:"none",background:"transparent",color:"var(--bim-desc-fg, #717171)",cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:d.action.remove,children:"×"})]},`${k.type}-${k.text}-${B}`))]})]})},Pe="bim-recent-ids",Je="bim-recent-entries",Ze=50,Re=5,Sn=50,kn=200;function $e(){try{const t=localStorage.getItem(Pe);if(t)return JSON.parse(t);const n=localStorage.getItem(Je);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(Pe,JSON.stringify(i)),localStorage.removeItem(Je),i}return[]}catch{return[]}}function wn(t){try{const n=$e().filter(i=>i!==t);n.unshift(t),n.length>Ze&&(n.length=Ze),localStorage.setItem(Pe,JSON.stringify(n))}catch{}}const Cn={works:"totalWorks",books:"totalBooks",collections:"totalCollections"},Ae=({transport:t,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:r,onSwitchMode:l,onToggleDraft:d,onConfigurePath:s,onSelectFolder:a,hideModeIndicator:x,initialQuery:g,onQueryChange:u,headerRight:f})=>{const c=$(),j=[{type:"work",icon:"✍️",name:c.indexType.work,key:"works"},{type:"book",icon:"📖",name:c.indexType.book,key:"books"},{type:"collection",icon:"📚",name:c.indexType.collection,key:"collections"}],[S,h]=p.useState(g??""),[W,b]=p.useState(null),[_,y]=p.useState(null),[w,C]=p.useState(!1),[v,m]=p.useState(null),[R,I]=p.useState(""),[A,L]=p.useState(!g),[k,B]=p.useState($e),[H,E]=p.useState([]),[z,D]=p.useState(!1),[N,Y]=p.useState(!1),[M,ee]=p.useState(null),q=p.useRef(void 0),te=p.useRef(!1),ne=p.useCallback(async(P,G)=>{if(!P.trim()){L(!0),b(null),y(null);return}L(!1),C(!0),I("");try{if(t.searchAll){const V=await t.searchAll(P,G??Re);b(V)}else{const V=["work","book","collection"],Z=await Promise.all(V.map(se=>t.search(P,se,{page:1,pageSize:G??Re})));b({works:Z[0].entries,books:Z[1].entries,collections:Z[2].entries,totalWorks:Z[0].total,totalBooks:Z[1].total,totalCollections:Z[2].total})}}catch(V){I(V instanceof Error?V.message:String(V)),b(null)}finally{C(!1)}},[t]);p.useEffect(()=>{let P=!1;const G=["work","book","collection"];return Promise.all(G.map(V=>t.loadEntries(V,{page:1,pageSize:1}).catch(()=>({total:0})))).then(V=>{P||ee({works:V[0].total,books:V[1].total,collections:V[2].total})}),()=>{P=!0}},[t]),p.useEffect(()=>{te.current||!(g!=null&&g.trim())||(te.current=!0,ne(g))},[g,ne]);const xe=p.useCallback(P=>{if(h(P),u==null||u(P),!P.trim()){L(!0),b(null),y(null);return}q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{y(null),ne(P)},kn)},[ne,u]),le=p.useCallback(P=>{q.current&&clearTimeout(q.current),u==null||u(P),ne(P)},[ne,u]),U=p.useCallback(P=>{y(P),ne(S,Sn)},[S,ne]);p.useEffect(()=>{if(!k.length){E([]);return}let P=!1;return D(!0),Promise.all(k.slice(0,10).map(async G=>{var V,Z,se;try{if(t.getEntry){const K=await t.getEntry(G);if(K)return K}const ae=await t.getItem(G);if(ae){const K=ae.authors;return{id:G,title:ae.title||G,type:ae.type||"work",author:(V=K==null?void 0:K[0])==null?void 0:V.name,dynasty:(Z=K==null?void 0:K[0])==null?void 0:Z.dynasty,role:(se=K==null?void 0:K[0])==null?void 0:se.role,edition:ae.edition||void 0}}}catch{}return null})).then(G=>{P||(E(G.filter(V=>V!==null)),D(!1))}),()=>{P=!0}},[k,t]);const he=P=>{m(P.id),wn(P.id),B($e()),o==null||o(P)},ke=P=>j.find(G=>G.type===P),Te=W&&(W.works.length>0||W.books.length>0||W.collections.length>0);return e.jsxs("div",{className:"bim-browser-container",children:[e.jsx("header",{style:{padding:"12px 20px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h1",{style:{margin:0,fontSize:"18px",color:"var(--bim-fg, #333)"},children:c.browser.title}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,!x&&e.jsx(yt,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:l,onToggleDraft:d,onConfigurePath:s,onSelectFolder:a})]})]})}),e.jsxs("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:[e.jsx(vt,{transport:t,value:S,onChange:xe,onSearch:le,onEntrySelect:he}),r&&e.jsx("button",{onClick:()=>r("work"),style:{padding:"8px 14px",border:"1px solid var(--bim-primary, #0078d4)",borderRadius:"6px",background:"transparent",color:"var(--bim-primary, #0078d4)",cursor:"pointer",fontSize:"13px"},children:c.action.newEntry})]}),M&&A&&e.jsxs("div",{style:{padding:"0 20px 8px",fontSize:"12px",color:"var(--bim-desc-fg, #999)"},children:[c.indexType.work," ",e.jsx("strong",{style:{color:"var(--bim-fg, #555)"},children:M.works.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),c.indexType.book," ",e.jsx("strong",{style:{color:"var(--bim-fg, #555)"},children:M.books.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),c.indexType.collection," ",e.jsx("strong",{style:{color:"var(--bim-fg, #555)"},children:M.collections.toLocaleString()})]}),e.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:w?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:"var(--bim-desc-fg, #717171)"},children:c.search.searching}):R?e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("div",{style:{fontSize:"24px",marginBottom:"8px"},children:"⚠️"}),e.jsx("p",{style:{color:"var(--bim-desc-fg, #717171)"},children:R})]}):A?e.jsx("div",{style:{flex:1},children:z?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:"var(--bim-desc-fg, #717171)"},children:c.search.loading}):H.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 0",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:c.search.recentBrowse}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:H.slice(0,N?10:3).map(P=>e.jsx(Xe,{entry:P,selected:v===P.id,onClick:he,getConfig:ke},P.id))}),!N&&H.length>3&&e.jsx("button",{onClick:()=>Y(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:"var(--bim-primary, #0078d4)",background:"transparent",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",cursor:"pointer"},children:c.action.expandMore})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px"},children:"📚"}),e.jsx("h3",{style:{margin:"0 0 8px",color:"var(--bim-fg, #333)"},children:c.search.searchTitle}),e.jsx("p",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:c.search.searchSubtitle})]})}):Te?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:j.map(({type:P,icon:G,name:V,key:Z})=>{const se=W[Z],ae=Cn[Z],K=W[ae];if(se.length===0)return null;const we=!(_===P)&&K>Re;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",marginBottom:"6px"},children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--bim-fg, #333)"},children:[G," ",V,e.jsxs("span",{style:{fontWeight:400,color:"var(--bim-desc-fg, #717171)",marginLeft:"6px"},children:[K," ",c.unit.items]})]}),we&&e.jsx("button",{onClick:()=>U(P),style:{border:"none",background:"transparent",color:"var(--bim-primary, #0078d4)",cursor:"pointer",fontSize:"12px"},children:c.action.viewAll})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:se.map(T=>e.jsx(Xe,{entry:T,selected:v===T.id,onClick:he,getConfig:ke,query:S},T.id))})]},P)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px"},children:"📚"}),e.jsx("h3",{style:{margin:"0 0 8px",color:"var(--bim-fg, #333)"},children:Se(c.search.noResultsFor,{query:S})}),e.jsx("p",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:c.search.tryOther})]})})]})},Xe=({entry:t,selected:n,onClick:i,getConfig:o,query:r})=>{const l=$(),{convert:d}=F(),s=r&&t.additional_titles?t.additional_titles.find(a=>a.toLowerCase().includes(r.toLowerCase())):void 0;return e.jsxs("div",{onClick:()=>i(t),style:{display:"flex",alignItems:"flex-start",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:n?"1px solid var(--bim-primary, #0078d4)":"1px solid var(--bim-widget-border, #e0e0e0)",cursor:"pointer",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:o(t.type).icon}),e.jsx("span",{style:{fontSize:"9px",color:"var(--bim-desc-fg, #999)",lineHeight:1},children:o(t.type).name})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--bim-fg, #333)"},children:d(t.title)}),e.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[t.has_text&&e.jsx("span",{title:l.misc.textResource,children:"📝"}),t.has_image&&e.jsx("span",{title:l.misc.imageResource,children:"🖼️"})]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)"},children:d(t.edition)}),t.juan_count!=null&&t.juan_count>0&&e.jsxs("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)"},children:[t.juan_count,l.unit.juan]})]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginTop:"2px"},children:[t.dynasty&&e.jsxs("span",{children:["〔",d(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:d(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",d(t.role)]})]}),s&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)",marginTop:"2px"},children:[l.search.alias,":",d(s)]})]}),e.jsx("span",{style:{opacity:.4,marginTop:"2px"},children:"→"})]})},In=["〇","一","二","三","四","五","六","七","八","九"],qe=["","十","百","千"];function jt(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),i=n.length;let o="",r=!1;for(let l=0;l<i;l++){const d=parseInt(n[l]),s=i-1-l;d===0?r=!0:(r&&o&&(o+="〇"),r=!1,d===1&&s===1&&l===0?o+=qe[s]:o+=In[d]+qe[s])}return o}function St({type:t}){const n=$(),i={book:"#c0392b",work:"#8e6f3e",collection:"#2471a3"};return e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:i[t],border:`1px solid ${i[t]}40`,borderRadius:"2px",background:`${i[t]}08`},children:n.indexType[t]})}function zn({isDraft:t}){const n=$();return e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:t?"#e67e22":"#27ae60",border:`1px solid ${t?"#e67e2240":"#27ae6040"}`,borderRadius:"2px",background:t?"#e67e2208":"#27ae6008"},children:t?n.status.draft:n.status.official})}function _n({id:t}){const n=$(),[i,o]=p.useState(!1),r=()=>{navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"3px 8px 3px 10px",fontSize:"12px",color:"var(--bim-desc-fg, #717171)",background:"#f6f6f6",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px"},children:[e.jsx("span",{children:n.label.id}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:"12px",color:"var(--bim-fg, #333)"},children:t}),e.jsx("span",{onClick:r,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"13px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:l=>l.currentTarget.style.opacity="1",onMouseLeave:l=>l.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function Q({children:t,extra:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",letterSpacing:"1px"},children:t}),e.jsx("span",{style:{flex:1}}),n]})}function re({label:t,children:n}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[e.jsx("span",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"12px"},children:t}),e.jsx("span",{style:{color:"var(--bim-fg, #333)"},children:n})]})}function kt({authors:t,type:n}){const{convert:i}=F();return e.jsx("span",{style:{fontSize:"14px",color:"var(--bim-fg, #333)",lineHeight:1.6},children:t.map((o,r)=>e.jsxs("span",{children:[r>0&&e.jsx("span",{style:{color:"var(--bim-desc-fg, #aaa)",margin:"0 4px"},children:"·"}),o.dynasty&&e.jsxs("span",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"12px"},children:["〔",i(o.dynasty),"〕"]}),e.jsx("span",{style:{fontWeight:500},children:i(o.name)}),o.role&&e.jsxs("span",{style:{color:"var(--bim-desc-fg, #999)",fontSize:"12px",marginLeft:"2px"},children:[" ",i(o.role)]})]},r))})}function pe({id:t,label:n,onNavigate:i,renderLink:o}){return o?e.jsx(e.Fragment,{children:o(t,n)}):i?e.jsx("a",{href:`/${t}`,onClick:r=>{r.metaKey||r.ctrlKey||(r.preventDefault(),i(t))},style:{color:"var(--bim-link-fg, #0066cc)",cursor:"pointer",textDecoration:"none",borderBottom:"1px dashed var(--bim-link-fg, #0066cc)",paddingBottom:"1px"},onMouseEnter:r=>r.currentTarget.style.borderBottomStyle="solid",onMouseLeave:r=>r.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{children:n||t})}function Tn({id:t,title:n,edition:i,type:o,isDraft:r,authors:l,volumeText:d,meta:s,headerExtra:a}){return e.jsxs("div",{style:{marginBottom:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"12px"},children:[e.jsxs("h1",{style:{fontSize:"24px",fontWeight:700,color:"var(--bim-fg, #1a1a1a)",margin:"0 0 6px",lineHeight:1.3,letterSpacing:"0.5px",flex:1,minWidth:0},children:[n,i&&e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--bim-desc-fg, #717171)",marginLeft:"6px"},children:i}),d&&e.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:"var(--bim-desc-fg, #717171)",marginLeft:"8px"},children:d})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,paddingTop:"4px"},children:[e.jsx(St,{type:o}),e.jsx(zn,{isDraft:r}),e.jsx(_n,{id:t}),a]})]}),((l==null?void 0:l.length)||s.length>0)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[l&&l.length>0&&e.jsx(kt,{authors:l,type:o}),s]})]})}function Rn({items:t,onNavigate:n,renderLink:i}){const o=$(),{convert:r}=F();if(!t.length)return null;const[l,d]=p.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:o.section.indexed}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map((s,a)=>{const x=l===a;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...x?{boxShadow:"0 1px 4px rgba(0,0,0,0.06)"}:{}},children:[e.jsxs("div",{onClick:()=>d(x?null:a),style:{padding:"8px 12px",background:"var(--bim-input-bg, #fff)",cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[e.jsx("span",{style:{fontSize:"10px",color:"var(--bim-desc-fg, #717171)",transition:"transform 0.15s",transform:x?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--bim-fg, #333)"},children:r(s.source)}),!x&&s.title_info&&e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r(s.title_info)}),s.source_bid&&e.jsx("span",{onClick:g=>g.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:e.jsx(pe,{id:s.source_bid,label:o.action.view,onNavigate:n,renderLink:i})})]}),x&&e.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[(s.title_info||s.author_info||s.edition)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[s.title_info&&e.jsx(re,{label:o.label.titleInfo,children:r(s.title_info)}),s.author_info&&e.jsx(re,{label:o.label.authorInfo,children:r(s.author_info)}),s.edition&&e.jsx(re,{label:o.label.edition,children:r(s.edition)})]}),s.summary&&e.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:"3px solid var(--bim-primary, #8e6f3e)",background:"color-mix(in srgb, var(--bim-primary, #8e6f3e) 4%, transparent)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:o.section.summary}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #333)",lineHeight:1.9,margin:0,textAlign:"justify"},children:r(s.summary)})]}),s.comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:"3px solid var(--bim-desc-fg, #aaa)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:o.section.comment}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:r(s.comment)})]}),s.additional_comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:"3px solid var(--bim-desc-fg, #ccc)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:o.section.additionalComment}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:r(s.additional_comment)})]})]})]},a)})})]})}function En({items:t}){const n=$(),{convert:i}=F();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:n.section.aliases}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((o,r)=>e.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:"var(--bim-fg, #333)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)"},children:i(o)},r))})]}):null}function Ln({items:t}){const n=$(),{convert:i}=F();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:n.section.appendix}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((o,r)=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:"var(--bim-fg, #333)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)"},children:["《",i(o.book_title),"》",o.n_juan!=null&&e.jsxs("span",{style:{color:"var(--bim-desc-fg, #999)",fontSize:"12px"},children:[o.n_juan,n.unit.juan]})]},r))})]}):null}function Bn({items:t}){const n=$(),{convert:i}=F();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:n.section.locationHistory}),e.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[e.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:"var(--bim-widget-border, #ddd)"}}),t.map((o,r)=>e.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[e.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:"var(--bim-primary, #8e6f3e)",border:"1.5px solid var(--bim-input-bg, #fff)"}}),e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:"var(--bim-fg, #333)"},children:i(o.name)}),o.description&&e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",marginLeft:"8px"},children:i(o.description)})]},r))]})]}):null}function Wn({items:t}){const n=$(),{convert:i}=F();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:n.section.historyOverview}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map((o,r)=>e.jsxs("div",{style:{fontSize:"13px",color:"var(--bim-fg, #333)",lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[e.jsx("span",{style:{position:"absolute",left:0,top:0,color:"var(--bim-desc-fg, #ccc)"},children:"·"}),i(o)]},r))})]}):null}function Qe({title:t,ids:n,transport:i,onNavigate:o,renderLink:r}){const{convert:l}=F(),[d,s]=p.useState([]);return p.useEffect(()=>{if(!n.length){s([]);return}if(!i){s(n.map(x=>({id:x})));return}let a=!1;return Promise.all(n.map(x=>i.getItem(x).then(g=>({id:x,title:g?g.title:void 0,edition:g?g.edition:void 0,type:g?g.type:void 0})).catch(()=>({id:x})))).then(x=>{a||s(x)}),()=>{a=!0}},[n,i]),n.length?e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[t,e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #aaa)",fontWeight:400},children:["(",n.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(d.length?d:n.map(a=>({id:a}))).map(a=>{const x=a.edition?`${l(a.title)||a.id}(${l(a.edition)})`:l(a.title)||void 0;return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",transition:"border-color 0.15s"},children:e.jsx(pe,{id:a.id,label:x,onNavigate:o,renderLink:r})},a.id)})})]}):null}function Pn({book:t,onNavigate:n,renderLink:i}){const o=$(),{convert:r}=F(),[l,d]=p.useState(!1),s=t.resources&&t.resources.length>0,a=t.edition?`${r(t.title)||t.id}(${r(t.edition)})`:r(t.title)||void 0;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{padding:"10px 14px",borderBottom:s&&!l?"1px solid var(--bim-widget-border, #e0e0e0)":"none",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(pe,{id:t.id,label:a,onNavigate:n,renderLink:i})}),s&&e.jsx("span",{onClick:()=>d(x=>!x),style:{cursor:"pointer",fontSize:"10px",color:"var(--bim-desc-fg, #999)",userSelect:"none",transition:"transform 0.15s",transform:l?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:l?o.action.expand:o.action.collapse,children:"▼"})]}),s&&!l&&e.jsx("div",{style:{padding:"10px 14px"},children:e.jsx(De,{items:t.resources,groupByType:!0})})]})}function $n({ids:t,transport:n,onNavigate:i,renderLink:o}){const r=$(),[l,d]=p.useState([]);return p.useEffect(()=>{if(!t.length){d([]);return}if(!n){d(t.map(a=>({id:a})));return}let s=!1;return Promise.all(t.map(a=>n.getItem(a).then(x=>({id:a,title:x?x.title:void 0,edition:x?x.edition:void 0,resources:x?x.resources:void 0})).catch(()=>({id:a})))).then(a=>{s||d(a)}),()=>{s=!0}},[t,n]),t.length?e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[r.section.relatedVersions,e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #aaa)",fontWeight:400},children:["(",t.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:(l.length?l:t.map(s=>({id:s}))).map(s=>e.jsx(Pn,{book:s,onNavigate:i,renderLink:o},s.id))})]}):null}function An({workData:t,onNavigate:n,renderLink:i}){var l,d,s;const o=$(),{convert:r}=F();return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",overflow:"hidden",background:"var(--bim-input-bg, #fff)",marginTop:"4px"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",display:"flex",alignItems:"center",gap:"8px",background:"color-mix(in srgb, var(--bim-primary, #8e6f3e) 4%, transparent)"},children:[e.jsx(St,{type:"work"}),e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:"var(--bim-fg, #333)"},children:e.jsx(pe,{id:t.id,label:r(t.title),onNavigate:n,renderLink:i})}),((l=t.juan_count)==null?void 0:l.number)!=null&&t.juan_count.number>0&&e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:[jt(t.juan_count.number),o.unit.juan]})]}),e.jsxs("div",{style:{padding:"12px 16px"},children:[t.authors&&t.authors.length>0&&e.jsx(kt,{authors:t.authors,type:"work"}),((d=t.description)==null?void 0:d.text)&&e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #444)",lineHeight:1.8,margin:(s=t.authors)!=null&&s.length?"8px 0 0":"0",textAlign:"justify"},children:r(t.description.text)}),t.parent_work&&e.jsx("div",{style:{marginTop:"8px",fontSize:"13px"},children:e.jsx(re,{label:o.label.parentWork,children:e.jsx(pe,{id:t.parent_work.id,label:r(t.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function Mn({items:t,onNavigate:n,renderLink:i}){const o=$(),{convert:r}=F();return t.length?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:t.map(l=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:"1px solid #2471a340",borderRadius:"4px",background:"#2471a308"},children:[e.jsx("span",{style:{fontSize:"11px",color:"#2471a3"},children:o.indexType.collection}),e.jsx(pe,{id:l.id,label:r(l.title)||l.id,onNavigate:n,renderLink:i}),l.volume_index!=null&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)",marginLeft:"2px"},children:Se(o.catalog.volume,{n:l.volume_index})})]},l.id))}):null}const He=({data:t,id:n,transport:i,onNavigate:o,renderLink:r,headerExtra:l,className:d,style:s})=>{var A,L,k,B,H,E;const a=$(),{convert:x}=F(),[g,u]=p.useState(null),[f,c]=p.useState(!1),[j,S]=p.useState(null),[h,W]=p.useState(null),[b,_]=p.useState([]),y=t||g;if(p.useEffect(()=>{if(t||!n||!i)return;let z=!1;return c(!0),S(null),i.getItem(n).then(D=>{z||(D?u(D):S(a.misc.notFoundEntry))}).catch(D=>{z||S(D instanceof Error?D.message:a.misc.loadFailed)}).finally(()=>{z||c(!1)}),()=>{z=!0}},[t,n,i]),p.useEffect(()=>{if(!y||!i){W(null),_([]);return}let z=!1;const D=y.type==="book"||y.type==="collection"?y.work_id:void 0;if(D?i.getItem(D).then(N=>{!z&&N&&N.type==="work"&&W(N)}).catch(()=>{}):W(null),y.type==="book"){const N=y;N.contained_in&&N.contained_in.length>0?Promise.all(N.contained_in.map(Y=>{const M=typeof Y=="string"?Y:Y.id,ee=typeof Y=="string"?void 0:Y.volume_index;return i.getItem(M).then(q=>({id:M,title:q&&q.title||M,volume_index:ee})).catch(()=>({id:M,title:M,volume_index:ee}))})).then(Y=>{z||_(Y)}):_([])}else _([]);return()=>{z=!0}},[y,i]),f)return e.jsx("div",{className:d,style:{...s,padding:"24px"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((z,D)=>e.jsx("div",{style:{height:D===1?"32px":"16px",width:`${z}px`,background:"var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",opacity:.4}},D))})});if(j)return e.jsx("div",{className:d,style:{...s,padding:"24px",textAlign:"center",color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:j});if(!y)return null;const w=y.type==="book"?y:null,C=y.type==="collection"?y:null,v=y.type==="work"?y:null;let m=!1;try{m=O.extractStatus(y.id)==="draft"}catch{}let R="";(A=y.juan_count)!=null&&A.number?R=jt(y.juan_count.number)+a.unit.juan:(L=y.juan_count)!=null&&L.description&&(R=x(y.juan_count.description));const I=[];return(k=y.publication_info)!=null&&k.year&&I.push(e.jsx(re,{label:a.label.year,children:y.publication_info.year},"year")),(B=y.current_location)!=null&&B.name&&I.push(e.jsx(re,{label:a.label.currentLocation,children:x(y.current_location.name)},"loc")),(H=y.page_count)!=null&&H.description&&I.push(e.jsx(re,{label:a.label.pageCount,children:y.page_count.description},"page")),w!=null&&w.edition&&I.push(e.jsx(re,{label:a.label.edition,children:x(w.edition)},"ver")),v!=null&&v.parent_work&&I.push(e.jsx(re,{label:a.label.parentWork,children:e.jsx(pe,{id:v.parent_work.id,label:x(v.parent_work.title),onNavigate:o,renderLink:r})},"pw")),v!=null&&v.parent_works&&v.parent_works.length>0&&!v.parent_work&&I.push(e.jsx(re,{label:a.label.parentWork,children:v.parent_works.map((z,D)=>e.jsxs("span",{children:[D>0&&"、",e.jsx(pe,{id:z,onNavigate:o,renderLink:r})]},z))},"pws")),e.jsxs("div",{className:d,style:s,children:[e.jsx(Tn,{id:y.id,title:x(y.title),edition:y.edition?x(y.edition):void 0,type:y.type,isDraft:m,authors:y.authors,volumeText:R,meta:I,headerExtra:l}),((E=y.description)==null?void 0:E.text)&&e.jsx("p",{style:{fontSize:"14px",color:"var(--bim-fg, #444)",lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"},children:x(y.description.text)}),b.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:a.section.containedIn}),e.jsx(Mn,{items:b,onNavigate:o,renderLink:r})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:a.section.belongsToWork}),e.jsx(An,{workData:h,onNavigate:o,renderLink:r})]}),y.additional_works&&y.additional_works.length>0&&e.jsx(Ln,{items:y.additional_works}),y.additional_titles&&y.additional_titles.length>0&&e.jsx(En,{items:y.additional_titles}),y.indexed_by&&y.indexed_by.length>0&&e.jsx(Rn,{items:y.indexed_by,onNavigate:o,renderLink:r}),y.resources&&y.resources.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:a.section.resources}),e.jsx(De,{items:y.resources,groupByType:!0})]}),(w==null?void 0:w.location_history)&&w.location_history.length>0&&e.jsx(Bn,{items:w.location_history}),(C==null?void 0:C.history)&&C.history.length>0&&e.jsx(Wn,{items:C.history}),(w==null?void 0:w.related_books)&&w.related_books.length>0&&e.jsx(Qe,{title:a.section.relatedVersions,ids:w.related_books,transport:i,onNavigate:o,renderLink:r}),(C==null?void 0:C.books)&&C.books.length>0&&e.jsx(Qe,{title:a.section.containedBooks,ids:C.books,transport:i,onNavigate:o,renderLink:r}),(v==null?void 0:v.books)&&v.books.length>0&&e.jsx($n,{ids:v.books,transport:i,onNavigate:o,renderLink:r}),(v==null?void 0:v.related_works)&&v.related_works.length>0&&(()=>{const z=[],D=v.related_works.filter(M=>M.relation==="part_of"),N=v.related_works.filter(M=>M.relation==="has_part"),Y=v.related_works.filter(M=>!M.relation);return D.length>0&&z.push({label:a.section.belongsToWork,items:D}),N.length>0&&z.push({label:a.section.containedWorks,items:N}),Y.length>0&&z.push({label:a.section.relatedWorks,items:Y}),z.map(M=>e.jsxs("div",{children:[e.jsxs(Q,{children:[M.label,e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #aaa)",fontWeight:400},children:["(",M.items.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:M.items.map(ee=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)"},children:e.jsx(pe,{id:ee.id,label:x(ee.title),onNavigate:o,renderLink:r})},ee.id))})]},M.label))})()]})};function Fn({data:t}){const n=$(),{convert:i}=F(),{stats:o}=t,r=o.processed_volumes??o.total_found_volumes,l=r!=null&&t.total_volumes>0?Math.round(r/t.total_volumes*100):null;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:"var(--bim-fg, #1a1a1a)",margin:"0 0 8px"},children:i(t.title)}),t.resource_name&&e.jsx("div",{style:{fontSize:"13px",color:"var(--bim-desc-fg, #717171)",marginBottom:"6px"},children:i(t.resource_name)}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:"var(--bim-desc-fg, #717171)"},children:[e.jsxs("span",{children:[n.catalog.totalVolumes," ",e.jsx("strong",{style:{color:"var(--bim-fg, #333)"},children:t.total_volumes})," ",n.unit.volume]}),l!=null&&e.jsxs("span",{children:[n.catalog.processed," ",e.jsx("strong",{style:{color:"var(--bim-fg, #333)"},children:r})," ",n.unit.volume," (",l,"%)"]}),e.jsxs("span",{children:[n.catalog.contains," ",e.jsx("strong",{style:{color:"var(--bim-fg, #333)"},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&e.jsxs("span",{children:[n.catalog.matched," ",e.jsx("strong",{style:{color:"var(--bim-fg, #333)"},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&e.jsxs("span",{children:[n.catalog.unmatched," ",e.jsx("strong",{style:{color:"#e67e22"},children:o.unmatched_works})," ",n.unit.bu]})]}),t.source&&e.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:"var(--bim-desc-fg, #999)"},children:[n.catalog.source," ",t.source]})]})}function Dn({sections:t,activeSection:n,onSelect:i}){const o=$();return e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[e.jsx("button",{onClick:()=>i(null),style:et(n===null),children:o.catalog.all}),t.map(r=>e.jsxs("button",{onClick:()=>i(r.name),style:et(n===r.name),children:[r.name,r.volume_range&&e.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[r.volume_range[0],"–",r.volume_range[1]]})]},r.name))]})}function et(t){return{padding:"4px 12px",border:t?"1px solid var(--bim-primary, #2471a3)":"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:t?"color-mix(in srgb, var(--bim-primary, #2471a3) 8%, transparent)":"transparent",color:t?"var(--bim-primary, #2471a3)":"var(--bim-fg, #333)",cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}function Hn({id:t,label:n,onNavigate:i,renderLink:o}){return o?e.jsx(e.Fragment,{children:o(t,n)}):i?e.jsx("a",{href:`/${t}`,onClick:r=>{r.metaKey||r.ctrlKey||(r.preventDefault(),i(t))},style:{color:"var(--bim-link-fg, #0066cc)",cursor:"pointer",textDecoration:"none",borderBottom:"1px dashed var(--bim-link-fg, #0066cc)",paddingBottom:"1px",fontSize:"12px"},onMouseEnter:r=>r.currentTarget.style.borderBottomStyle="solid",onMouseLeave:r=>r.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)"},children:n||t})}function On(t,n){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const i=t[0],o=t[t.length-1];return o-i+1===t.length?`${i}–${o}`:t.length<=3?t.join(", "):`${i}–${o} (${t.length}${n})`}function tt({book:t,onNavigate:n,renderLink:i,showVolumes:o}){const r=$(),{convert:l}=F(),d=t.book_id||t.work_id,s=o&&t.volumes.length>0?On(t.volumes,r.unit.volume):null,a=t.missing_volumes&&t.missing_volumes.length>0;return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:"1px solid var(--bim-widget-border, #f0f0f0)",fontSize:"14px",lineHeight:1.8},children:[o&&e.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:"var(--bim-desc-fg, #999)",textAlign:"right"},children:s}),e.jsxs("span",{style:{flex:1,fontWeight:500,color:"var(--bim-fg, #1a1a1a)"},children:[l(t.title),t.sub_items&&t.sub_items.length>0&&e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",fontWeight:400,marginLeft:"6px"},children:["(",t.sub_items.map(x=>l(x)).join("、"),")"]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #aaa)",fontWeight:400,marginLeft:"8px"},children:l(t.edition)})]}),t.expected_volumes!=null&&e.jsxs("span",{style:{fontSize:"11px",color:a?"#e67e22":"var(--bim-desc-fg, #999)",flexShrink:0},children:[t.found_volumes??0,"/",t.expected_volumes,r.unit.volume]}),d&&e.jsx(Hn,{id:d,label:t.book_id?r.indexType.book:r.indexType.work,onNavigate:n,renderLink:i}),!d&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #ccc)",flexShrink:0},children:r.catalog.unmatched_label})]})}const wt=({data:t,collectionId:n,transport:i,onNavigate:o,renderLink:r,className:l,style:d})=>{const s=$(),[a,x]=p.useState(null),[g,u]=p.useState(!1),[f,c]=p.useState(null),[j,S]=p.useState(null),[h,W]=p.useState(""),b=t||a;p.useEffect(()=>{if(t||!n||!(i!=null&&i.getCollectionCatalog))return;let v=!1;return u(!0),c(null),i.getCollectionCatalog(n).then(m=>{v||(m?x(m):c(s.catalog.notFound))}).catch(m=>{v||c(m instanceof Error?m.message:s.catalog.loadFailed)}).finally(()=>{v||u(!1)}),()=>{v=!0}},[t,n,i,s]);const _=(b==null?void 0:b.sections)&&b.sections.length>0,y=p.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const v=b.books.map(R=>R.volumes[0]).filter(R=>R!=null);return new Set(v).size<v.length},[b]),w=p.useMemo(()=>{if(!b)return[];let v=b.books;if(j&&(v=v.filter(m=>m.section===j)),h.trim()){const m=h.trim().toLowerCase();v=v.filter(R=>R.title.toLowerCase().includes(m)||R.sub_items&&R.sub_items.some(I=>I.toLowerCase().includes(m))||R.edition&&R.edition.toLowerCase().includes(m))}return v},[b,j,h]),C=p.useMemo(()=>{if(!y)return null;const v=[],m=new Map;for(const I of w){if(!I.volumes||I.volumes.length===0)continue;const A=I.volumes[0];m.has(A)||m.set(A,[]),m.get(A).push(I)}const R=[...m.keys()].sort((I,A)=>I-A);for(const I of R)v.push({volume:I,books:m.get(I)});return v},[w,y]);return g?e.jsx("div",{className:l,style:{...d,padding:"24px"},children:e.jsx("div",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:s.catalog.loading})}):f?e.jsx("div",{className:l,style:{...d,padding:"24px",textAlign:"center",color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:f}):b?e.jsxs("div",{className:l,style:d,children:[e.jsx(Fn,{data:b}),_&&e.jsx(Dn,{sections:b.sections,activeSection:j,onSelect:S}),e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("input",{type:"text",placeholder:s.search.searchBookName,value:h,onChange:v=>W(v.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",fontSize:"13px",boxSizing:"border-box"}}),e.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:"var(--bim-desc-fg, #999)"},children:[w.length," ",s.unit.bu]})]}),e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden"},children:[C?C.map((v,m)=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"4px 12px",background:"var(--bim-bg, #f8f8f8)",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",fontSize:"12px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",position:"sticky",top:0,zIndex:1},children:Se(s.catalog.volume,{n:v.volume})}),v.books.map((R,I)=>e.jsx(tt,{book:R,onNavigate:o,renderLink:r,showVolumes:R.volumes.length>1},`${v.volume}-${I}`))]},`${v.volume}-${m}`)):w.map((v,m)=>e.jsx(tt,{book:v,onNavigate:o,renderLink:r,showVolumes:!0},m)),w.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:"var(--bim-desc-fg, #999)",fontSize:"13px"},children:s.catalog.noMatch})]})]}):null},Vn=["〇","一","二","三","四","五","六","七","八","九"],nt=["","十","百","千"],Nn=["","萬","億"];function Ct(t){if(t===0)return"〇";if(t<0)return`負${Ct(-t)}`;const n=[];let i=t,o=0;for(;i>0;){const r=i%1e4;r>0?n.unshift(Un(r,o>0)+Nn[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Un(t,n){const i=[];let o=t;for(;o>0;)i.unshift(o%10),o=Math.floor(o/10);let r="";for(let l=0;l<i.length;l++){const d=i[l],s=i.length-1-l;d===0?r&&!r.endsWith("〇")&&(r+="〇"):d===1&&s===1&&l===0&&!n?r+=nt[s]:r+=Vn[d]+nt[s]}return r.replace(/〇$/,"")}const It={部:"#2471a3",类:"#8e6f3e",书:"#c0392b",其他:"#717171"};function Yn(t){const n=t.replace(".json","");return n==="fulu"?"附錄":n.startsWith("juanshou")?`卷首${n.replace("juanshou","")}`:n.startsWith("juan")?`卷${n.replace("juan","").replace(/^0+/,"")}`:n}function zt({file:t,isActive:n,onSelect:i}){return e.jsx("button",{onClick:()=>i(t),style:{padding:"3px 8px",border:n?"1px solid var(--bim-primary, #8e6f3e)":"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"3px",background:n?"color-mix(in srgb, var(--bim-primary, #8e6f3e) 10%, transparent)":"transparent",color:n?"var(--bim-primary, #8e6f3e)":"var(--bim-fg, #333)",cursor:"pointer",fontSize:"12px",fontWeight:n?600:400,lineHeight:1.4},children:Yn(t)})}function _t(t,n){var i;return t.files.includes(n)?!0:!!((i=t.children)!=null&&i.some(o=>_t(o,n)))}function Tt(t){var o;const n=t.files.length,i=((o=t.children)==null?void 0:o.reduce((r,l)=>r+Tt(l),0))||0;return n+i}function Rt({group:t,activeFile:n,onSelect:i,depth:o=0}){var x;const r=_t(t,n||""),[l,d]=p.useState(r),s=Tt(t),a=!!((x=t.children)!=null&&x.length);return p.useEffect(()=>{r&&d(!0)},[r]),e.jsxs("div",{style:{marginBottom:o===0?"4px":"2px"},children:[e.jsxs("div",{onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"6px",padding:o===0?"4px 8px":"2px 8px",paddingLeft:`${8+o*16}px`,cursor:"pointer",userSelect:"none",fontSize:o===0?"13px":"12px",fontWeight:o===0?600:500,color:r?"var(--bim-primary, #8e6f3e)":"var(--bim-fg, #333)"},children:[e.jsx("span",{style:{fontSize:"9px",transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"}),e.jsx("span",{children:t.label}),e.jsxs("span",{style:{fontSize:"11px",fontWeight:400,color:"var(--bim-desc-fg, #999)"},children:["(",s,")"]})]}),l&&e.jsxs(e.Fragment,{children:[t.files.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",padding:`4px 0 4px ${24+o*16}px`},children:t.files.map(g=>e.jsx(zt,{file:g,isActive:n===g,onSelect:i},g))}),a&&t.children.map((g,u)=>e.jsx(Rt,{group:g,activeFile:n,onSelect:i,depth:o+1},u))]})]})}function Gn({files:t,groups:n,activeFile:i,onSelect:o}){return n&&n.length>0?e.jsx("div",{style:{marginBottom:"16px"},children:n.map((r,l)=>e.jsx(Rt,{group:r,activeFile:i,onSelect:o},l))}):e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",marginBottom:"16px",maxHeight:"120px",overflow:"auto",padding:"4px 0"},children:t.map(r=>e.jsx(zt,{file:r,isActive:i===r,onSelect:o},r))})}function Kn({type:t}){const n=It[t]||"#717171";return e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:n,border:`1px solid ${n}40`,borderRadius:"2px",background:`${n}08`,flexShrink:0},children:t})}function Jn({section:t,onNavigate:n}){const{convert:i}=F(),[o,r]=p.useState(!1),l=!!t.summary,d=!!t.comment,s=!!t.additional_comment,a=l||d||s;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden",marginBottom:"6px"},children:[e.jsxs("div",{onClick:()=>a&&r(!o),style:{padding:"8px 12px",display:"flex",alignItems:"baseline",gap:"8px",cursor:a?"pointer":"default",userSelect:"none",background:"var(--bim-input-bg, #fff)"},children:[a&&e.jsx("span",{style:{fontSize:"9px",color:"var(--bim-desc-fg, #717171)",transition:"transform 0.15s",transform:o?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--bim-fg, #1a1a1a)",flex:1},children:[t.book_title?`《${i(t.book_title)}》`:i(t.title),t.n_juan!=null&&e.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:"var(--bim-desc-fg, #999)",marginLeft:"6px"},children:[Ct(t.n_juan),"卷"]})]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #aaa)"},children:i(t.edition)}),t.tag&&e.jsx("span",{style:{fontSize:"11px",color:"#e74c3c"},children:t.tag==="triangle"?"△":t.tag}),t.work_id&&n&&e.jsx("a",{href:`/${t.work_id}`,onClick:x=>{x.metaKey||x.ctrlKey||(x.preventDefault(),x.stopPropagation(),n(t.work_id))},style:{fontSize:"11px",color:"var(--bim-link-fg, #0066cc)",cursor:"pointer",textDecoration:"none",flexShrink:0},title:"查看作品",children:"→作品"})]}),o&&a&&e.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:"1px solid var(--bim-widget-border, #f0f0f0)",background:"var(--bim-bg, #fafafa)"},children:[t.author_info&&e.jsx("div",{style:{fontSize:"13px",color:"var(--bim-desc-fg, #717171)",marginBottom:"8px"},children:i(t.author_info)}),t.summary&&e.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:"3px solid var(--bim-primary, #8e6f3e)",background:"color-mix(in srgb, var(--bim-primary, #8e6f3e) 4%, transparent)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:"提要"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #333)",lineHeight:1.9,margin:0,textAlign:"justify"},children:i(t.summary)})]}),t.comment&&e.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:"3px solid var(--bim-desc-fg, #aaa)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:"按語"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:i(t.comment)})]}),t.additional_comment&&e.jsxs("div",{style:{padding:"8px 14px",borderLeft:"3px solid var(--bim-desc-fg, #ccc)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:"附按"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:i(t.additional_comment)})]})]})]})}function Zn({section:t}){const{convert:n}=F(),[i,o]=p.useState(!1),r=!!t.content;return e.jsxs("div",{style:{padding:"12px 0 6px"},children:[e.jsxs("div",{onClick:()=>r&&o(!i),style:{display:"flex",alignItems:"center",gap:"8px",cursor:r?"pointer":"default",userSelect:"none"},children:[e.jsx(Kn,{type:t.type}),e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:"var(--bim-fg, #1a1a1a)"},children:n(t.title)}),r&&e.jsx("span",{style:{fontSize:"9px",color:"var(--bim-desc-fg, #999)",transition:"transform 0.15s",transform:i?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),i&&r&&e.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid ${It[t.type]||"#717171"}40`,borderRadius:"0 4px 4px 0",background:"var(--bim-bg, #fafafa)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #333)",lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:n(t.content)})})]})}function Xn({section:t}){const{convert:n}=F();if(!t.content&&!t.title)return null;const i=n((t.content||t.title||"").replace(/\n{2,}/g,`
1
+ "use strict";var Ut=Object.create;var Ve=Object.defineProperty;var Yt=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var Zt=(t,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Gt(n))!Jt.call(t,r)&&r!==i&&Ve(t,r,{get:()=>n[r],enumerable:!(o=Yt(n,r))||o.enumerable});return t};var Xt=(t,n,i)=>(i=t!=null?Ut(Kt(t)):{},Zt(n||!t||!t.__esModule?Ve(i,"default",{value:t,enumerable:!0}):i,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./storage-entry-BTPkj9f0.cjs"),e=require("react/jsx-runtime"),p=require("react"),je=p.createContext(null),ht={indexType:{work:"作品",book:"書籍",collection:"叢編"},resourceType:{text:"文字資源",image:"圖片資源",textImage:"文字+圖片資源",physical:"實體資源"},resourceTypeShort:{text:"文字",image:"圖片",textImage:"文字+圖片",physical:"實體"},rootType:{catalog:"目錄式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:"#e8f5e9",fg:"#2e7d32"},粗校:{label:"粗校",bg:"#fff3e0",fg:"#e65100"},AI整理:{label:"AI整理",bg:"#e3f2fd",fg:"#1565c0"}},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:"+ 添加收錄來源",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:"上級作品",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:"📖 著錄於",resources:"資源",textResources:"📝 文字資源 (Text Resources)",imageResources:"🖼️ 圖片資源 (Image Resources)",sources:"📚 資料來源 (Sources)",provenance:"📜 收藏歷史 (Provenance)",relatedVersions:"相關版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危險區域 (Danger Zone)",aliases:"別名",appendix:"附錄",containedIn:"收入",belongsToWork:"所屬作品",locationHistory:"流轉���史",historyOverview:"歷史沿革",containedBooks:"收錄書籍",relations:"關聯關係",summary:"提要",comment:"按語",additionalComment:"附按",indexed:"收錄",relatedWorks:"相關作品",containedWorks:"包含作品"},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:"清除全部",searchTitle:"搜索古籍索引",searchSubtitle:"輸入關鍵詞搜索作品、書籍或叢編",searchBookName:"搜索書名...",alias:"別名"},home:{title:"古籍索引",subtitle:"從左側搜索框輸入關鍵詞,查找作品、書籍或叢編",recommendedBrowse:"推薦瀏覽",catalogTab:"叢書目錄",siteTab:"在線資源",recommendTab:"推薦",statusInProgress:"進行中",statusDone:"已完成",statusTodo:"未開始",typeCatalog:"目錄",typeCollection:"資源集合",totalPending:"待統計",progressFormat:"{imported} / {total}",siteCoverage:"資源覆蓋"},browser:{title:"古籍資源索引",subtitle:""},detailTab:{basicInfo:"基本信息",catalog:"目錄",collectionCatalog:"叢編目錄",collatedEdition:"整理本",catalogSuffix:"·目錄"},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)",dynastyLabel:"朝代/年份 (Dynasty/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:"條"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暫無資源信息",hasTranslation:"有",noTranslation:"無",structure:"層級",coverage:"覆蓋",notFoundEntry:"未找到該條目",loadFailed:"加載失敗",textResource:"文字資源",imageResource:"圖片資源"}},qt={indexType:{work:"作品",book:"书籍",collection:"丛编"},resourceType:{text:"文字资源",image:"图片资源",textImage:"文字+图片资源",physical:"实体资源"},resourceTypeShort:{text:"文字",image:"图片",textImage:"文字+图片",physical:"实体"},rootType:{catalog:"目录式",search:"搜索式"},status:{draft:"草稿",official:"正式"},checkType:{精校:{label:"精校",bg:"#e8f5e9",fg:"#2e7d32"},粗校:{label:"粗校",bg:"#fff3e0",fg:"#e65100"},AI整理:{label:"AI整理",bg:"#e3f2fd",fg:"#1565c0"}},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:"+ 添加收录来源",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:"上级作品",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:"📖 著录于",resources:"资源",textResources:"📝 文字资源 (Text Resources)",imageResources:"🖼️ 图片资源 (Image Resources)",sources:"📚 资料来源 (Sources)",provenance:"📜 收藏历史 (Provenance)",relatedVersions:"相关版本",otherEditions:"📚 其他版本 (Other Editions)",dangerZone:"危险区域 (Danger Zone)",aliases:"别名",appendix:"附录",containedIn:"收入",belongsToWork:"所属作品",locationHistory:"流转历史",historyOverview:"历史沿革",containedBooks:"收录书籍",relations:"关联关系",summary:"提要",comment:"按语",additionalComment:"附按",indexed:"收录",relatedWorks:"相关作品",containedWorks:"包含作品"},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:"清除全部",searchTitle:"搜索古籍索引",searchSubtitle:"输入关键词搜索作品、书籍或丛编",searchBookName:"搜索书名...",alias:"别名"},home:{title:"古籍索引",subtitle:"从左侧搜索框输入关键词,查找作品、书籍或丛编",recommendedBrowse:"推荐浏览",catalogTab:"丛书目录",siteTab:"在线资源",recommendTab:"推荐",statusInProgress:"进行中",statusDone:"已完成",statusTodo:"未开始",typeCatalog:"目录",typeCollection:"资源集合",totalPending:"待统计",progressFormat:"{imported} / {total}",siteCoverage:"资源覆盖"},browser:{title:"古籍资源索引",subtitle:""},detailTab:{basicInfo:"基本信息",catalog:"目录",collectionCatalog:"丛编目录",collatedEdition:"整理本",catalogSuffix:"·目录"},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)",dynastyLabel:"朝代/年份 (Dynasty/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:"条"},colorMode:{bw:"黑白",color:"彩色"},misc:{noResources:"暂无资源信息",hasTranslation:"有",noTranslation:"无",structure:"层级",coverage:"覆盖",notFoundEntry:"未找到该条目",loadFailed:"加载失败",textResource:"文字资源",imageResource:"图片资源"}},Qt={"zh-Hant":ht,"zh-Hans":qt},bt="bim-locale";function en(){try{const t=localStorage.getItem(bt);if(t==="zh-Hant"||t==="zh-Hans")return t}catch{}}function tn(t){try{localStorage.setItem(bt,t)}catch{}}const nn=({locale:t,onLocaleChange:n,children:i})=>{const[o,r]=p.useState(t??en()??"zh-Hant"),l=t??o,[d,s]=p.useState(null);p.useEffect(()=>{l==="zh-Hans"?import("opencc-js/t2cn").then(g=>{const u=g.Converter({from:"tw",to:"cn"});s(()=>u)}).catch(()=>{s(()=>g=>g)}):s(null)},[l]);const a=p.useCallback(g=>{r(g),tn(g),n==null||n(g)},[n]),x=p.useMemo(()=>({locale:l,setLocale:a,messages:Qt[l],converter:d}),[l,a,d]);return e.jsx(je.Provider,{value:x,children:i})};function $(){const t=p.useContext(je);return(t==null?void 0:t.messages)??ht}const on=2e3;function F(){const t=p.useContext(je),n=(t==null?void 0:t.locale)??"zh-Hant",i=(t==null?void 0:t.converter)??null,o=p.useRef(new Map),r=p.useRef(n);r.current!==n&&(o.current.clear(),r.current=n);const l=p.useCallback(d=>{if(!d)return"";if(!i)return d;const s=o.current.get(d);if(s!==void 0)return s;const a=i(d);if(o.current.size>=on){const x=o.current.keys().next().value;x!==void 0&&o.current.delete(x)}return o.current.set(d,a),a},[i]);return p.useMemo(()=>({convert:l,locale:n,isSimplified:n==="zh-Hans"}),[l,n])}function Se(t,n){return t.replace(/\{(\w+)\}/g,(i,o)=>String(n[o]??""))}function rn(t){if(!t)return"";try{const n=new URL(t).hostname,i={"zh.wikisource.org":"wikisource","www.shidianguji.com":"shidianguji","shidianguji.com":"shidianguji","archive.org":"archive","ctext.org":"ctext","read.nlc.cn":"nlc","www.digital.archives.go.jp":"japan_archives"};if(i[n])return i[n];const o=n.split(".");return o.length>=2?o[o.length-2]:n}catch{return""}}function ln(){return{id:"",name:"",url:"",type:"text",details:""}}const We=({items:t,onChange:n,onDownload:i,downloadStatuses:o,filterType:r})=>{const l=$(),[d,s]=p.useState(null),a=[{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}],x=[{value:"catalog",label:l.rootType.catalog},{value:"search",label:l.rootType.search}],g=b=>r?r==="text"?b==="text"||b==="text+image":r==="image"?b==="image"||b==="text+image"||b==="physical":b===r:!0,u=t.map((b,_)=>({item:b,originalIndex:_})).filter(({item:b})=>g(b.type)),f=()=>{const b=ln();r&&(b.type=r),n([...t,b]),s(t.length)},c=b=>{n(t.filter((_,y)=>y!==b)),s(null)},j=(b,_,y)=>{const w=[...t];if(w[b]={...w[b],[_]:y},_==="url"&&!w[b].id){const C=rn(y);C&&(w[b].id=C)}n(w)},S=(b,_,y)=>{const C={...t[b].metadata||{}};y?C[_]=y:delete C[_],j(b,"metadata",Object.keys(C).length>0?C:void 0)},h=(b,_)=>{const y=_.trim()?_.split(/[,,、]/).map(w=>w.trim()).filter(Boolean):void 0;j(b,"structure",y)},W=(b,_,y)=>{const C=t[b].coverage||{level:1,ranges:""};_==="level"?C.level=parseInt(y)||1:C.ranges=y,j(b,"coverage",C.ranges?C:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[u.map(({item:b,originalIndex:_})=>{var y,w,C,v;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>s(d===_?null:_),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:d===_?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:sn(b.type),color:"#fff"},children:((y=a.find(m=>m.value===b.type))==null?void 0:y.label)||b.type}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:b.name||`${l.editor.resourcePlaceholder} ${_+1}`}),b.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:b.id}),b.url&&e.jsx("a",{href:b.url,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),i&&b.url&&an(_,o==null?void 0:o[_],i,l),e.jsx("button",{onClick:m=>{m.stopPropagation(),c(_)},style:{background:"transparent",border:"none",color:"var(--bim-danger, #f44336)",cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:l.editor.deleteThisResource,children:"✕"})]}),d===_&&e.jsxs("div",{style:{padding:"12px",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[(b.type==="image"||b.type==="text+image")&&b.url&&dn(b,l),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:be,children:[e.jsx("span",{style:me,children:l.label.type}),e.jsx("select",{value:b.type,onChange:m=>j(_,"type",m.target.value),style:{...oe,flex:1},children:a.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))})]}),e.jsxs("label",{style:be,children:[e.jsx("span",{style:me,children:l.label.rootType}),e.jsx("select",{value:b.root_type||"catalog",onChange:m=>j(_,"root_type",m.target.value),style:{...oe,flex:1},children:x.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:b.id,onChange:m=>j(_,"id",m.target.value),placeholder:l.editor.idAutoExtract,style:{...oe,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:b.name,onChange:m=>j(_,"name",m.target.value),placeholder:l.editor.resourceName,style:{...oe,flex:1}})]}),e.jsx("input",{type:"text",value:b.url,onChange:m=>j(_,"url",m.target.value),placeholder:l.editor.resourceUrl,style:oe}),e.jsx("input",{type:"text",value:((w=b.structure)==null?void 0:w.join("、"))||"",onChange:m=>h(_,m.target.value),placeholder:l.editor.structurePlaceholder,style:oe}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:be,children:[e.jsx("span",{style:me,children:l.label.coverageLevel}),e.jsx("input",{type:"number",min:1,value:((C=b.coverage)==null?void 0:C.level)??"",onChange:m=>W(_,"level",m.target.value),placeholder:"1",style:{...oe,width:"60px"}})]}),e.jsxs("label",{style:{...be,flex:1},children:[e.jsx("span",{style:me,children:l.label.coverageRange}),e.jsx("input",{type:"text",value:((v=b.coverage)==null?void 0:v.ranges)||"",onChange:m=>W(_,"ranges",m.target.value),placeholder:l.editor.coverageRangePlaceholder,style:{...oe,flex:1}})]})]}),e.jsx("textarea",{value:b.details||"",onChange:m=>j(_,"details",m.target.value),placeholder:l.editor.detailsPlaceholder,style:{...oe,minHeight:"60px",resize:"vertical"}}),e.jsxs("div",{style:{borderTop:"1px solid var(--bim-widget-border, #e0e0e0)",paddingTop:"8px",marginTop:"4px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginBottom:"6px"},children:l.label.metadata}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:Object.entries(l.metadata).map(([m,R])=>{var I;return e.jsxs("label",{style:{...be,gap:"4px"},children:[e.jsx("span",{style:{...me,minWidth:"56px"},children:R}),e.jsx("input",{type:"text",value:((I=b.metadata)==null?void 0:I[m])||"",onChange:A=>S(_,m,A.target.value),placeholder:R,style:{...oe,flex:1}})]},m)})})]})]})]})]},_)}),e.jsxs("button",{onClick:f,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:"1px dashed var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"transparent",color:"var(--bim-fg, #333)",cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:l.action.addResource})]})]})};function sn(t){switch(t){case"text":return"#2196f3";case"image":return"#ff9800";case"text+image":return"#9c27b0";case"physical":return"#795548"}}function an(t,n,i,o){const r=(n==null?void 0:n.status)==="downloading",l=(n==null?void 0:n.status)==="completed";return e.jsx("button",{onClick:d=>{d.stopPropagation(),r||i(t,"")},disabled:r,style:{background:"transparent",border:"none",color:l?"var(--bim-success, #4caf50)":r?"var(--bim-desc-fg, #717171)":"var(--bim-link-fg, #0066cc)",cursor:r?"default":"pointer",padding:"2px 6px",fontSize:"12px",opacity:r?.6:.9},title:l?o.download.completed:r?`${o.download.downloading} ${(n==null?void 0:n.progress)||0}%`:o.download.downloadThis,children:l?"✓":r?"⏳":"⬇"})}function dn(t,n){const i=/\.(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:i?e.jsx("div",{style:{width:"100%",maxHeight:"150px",overflow:"hidden",borderRadius:"4px",background:"#00000010"},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:"#00000010",borderRadius:"4px",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:n.editor.imageResourceLink})})}const oe={width:"100%",padding:"6px 8px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},be={display:"flex",alignItems:"center",gap:"6px"},me={fontSize:"12px",color:"var(--bim-desc-fg, #717171)",whiteSpace:"nowrap"},cn={"commons.wikimedia.org":"維基共享","zh.wikisource.org":"維基文庫","taiwanebook.ncl.edu.tw":"臺灣華文電子書庫","ctext.org":"中國哲學書電子化計劃"};function pn(t){try{const n=new URL(t).hostname;return cn[n]}catch{return}}const Ne={text:"#2196f3",image:"#ff9800","text+image":"#9c27b0",physical:"#795548"},xn=["text","image","text+image","physical"];function un(t){const n=l=>{const d=l.match(/^(.+?)·第(\d+)[冊册]$/);if(d)return[d[1],parseInt(d[2])];const s=l.match(/^(.+?)[·(](\d+)[)]?$/);return s?[s[1],parseInt(s[2])]:null},i=new Map,o=[],r=new Set;for(let l=0;l<t.length;l++){const d=t[l];if(d.volumes&&d.volumes.length>0)continue;const s=n(d.name);if(!s)continue;const[a,x]=s,g=`${a}|${d.type}`;i.has(g)||i.set(g,{base:{...d,name:a,url:"",volumes:[]},volumes:[]}),i.get(g).volumes.push({volume:x,url:d.url||void 0,status:"found"}),r.add(l)}for(const[,l]of i)if(l.volumes.length>=2)l.volumes.sort((d,s)=>d.volume-s.volume),l.base.volumes=l.volumes,l.base.expected_volumes=l.volumes.length,o.push(l.base);else for(let d=0;d<t.length;d++)if(r.has(d)){const s=n(t[d].name);s&&`${s[0]}|${t[d].type}`==`${l.base.name}|${l.base.type}`&&r.delete(d)}for(let l=0;l<t.length;l++)r.has(l)||o.push(t[l]);return o}const De=({items:t,groupByType:n=!0})=>{const i=$(),o=p.useMemo(()=>un(t||[]),[t]),r={text:i.resourceType.text,image:i.resourceType.image,"text+image":i.resourceType.textImage,physical:i.resourceType.physical};if(!o||o.length===0)return e.jsx("div",{style:{padding:"16px",color:"var(--bim-desc-fg, #717171)",fontSize:"13px",textAlign:"center"},children:i.misc.noResources});if(!n)return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:o.map((d,s)=>e.jsx(Ye,{item:d},d.id||s))});const l=xn.map(d=>({type:d,items:o.filter(s=>s.type===d)})).filter(d=>d.items.length>0);return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:l.map(({type:d,items:s})=>e.jsxs("div",{children:[e.jsxs("h4",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:600,color:Ne[d],display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{display:"inline-block",width:"4px",height:"14px",borderRadius:"2px",background:Ne[d]}}),r[d],e.jsxs("span",{style:{fontWeight:400,opacity:.6},children:["(",s.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:s.map((a,x)=>e.jsx(Ye,{item:a},a.id||x))})]},d))})},Ue=t=>{const n=t.volumes&&t.volumes.length>0;return t.details&&!n||t.structure||t.coverage||t.metadata&&Object.keys(t.metadata).length>0},mt=({value:t})=>{const i=$().checkType[t];return i?e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",borderRadius:"3px",fontSize:"11px",fontWeight:500,background:i.bg,color:i.fg},children:i.label}):e.jsx("span",{children:t})},gn=(t,n,i,o)=>{if(t==="check_type"&&typeof n=="string")return e.jsx(mt,{value:n});if(t==="has_translation")return n?i.misc.hasTranslation:i.misc.noTranslation;const r=String(n);return o?o(r):r};function fn(t,n){try{if(new URL(t).hostname.includes("wikimedia.org")){const r=t.match(/\/wiki\/File:(.+?)(?:#|$)/);if(r)return`https://commons.wikimedia.org/w/index.php?title=File%3A${encodeURIComponent(decodeURIComponent(r[1]))}&page=${n}`;const l=new URL(t);return l.searchParams.set("page",String(n)),l.toString()}return t}catch{return t}}function hn(t){if(!t)return;const n=t.file_page_range||t.page_range;if(!n||typeof n!="string")return;const i=n.match(/^(\d+)/);return i?parseInt(i[1],10):void 0}function bn(t){if(t.url)return t.url;for(const[n,i]of Object.entries(t))if(n.endsWith("_url")&&typeof i=="string")return i}const mn={bw:{label:"",bg:"#f5f5f5",fg:"#757575"},color:{label:"",bg:"#fff8e1",fg:"#f57f17"}},Ye=({item:t})=>{var f;const n=$(),{convert:i}=F(),[o,r]=p.useState(!1),l=p.useMemo(()=>(t.url?pn(t.url):void 0)||i(t.name),[t.url,t.name,i]),d=p.useMemo(()=>!t.volumes||t.volumes.length===0?null:t.volumes.map(c=>({...c,url:c.url||bn(c)})),[t.volumes]),s=d&&d.length>0,a=s?d.filter(c=>c.status!=="missing").length:0,x=s?d.length-a:0,g=t.expected_volumes??(s?d.length:0),u=t.color_mode?{...mn[t.color_mode],label:n.colorMode[t.color_mode]}:null;return e.jsxs("div",{style:{padding:"10px 14px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:Ue(t)||s?"6px":"0"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:"var(--bim-fg, #333)"},children:l}),u&&e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",borderRadius:"3px",fontSize:"11px",fontWeight:500,background:u.bg,color:u.fg},children:u.label}),t.source_label&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)",fontStyle:"italic"},children:t.source_label}),((f=t.metadata)==null?void 0:f.check_type)&&e.jsx(mt,{value:t.metadata.check_type}),s&&e.jsxs("button",{onClick:()=>r(!o),style:{padding:"1px 8px",fontSize:"11px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"3px",background:"transparent",color:"var(--bim-desc-fg, #717171)",cursor:"pointer"},children:[a,"/",g,n.unit.volume,x>0&&e.jsxs("span",{style:{color:"#e67e22",marginLeft:"4px"},children:["缺",x]}),e.jsx("span",{style:{marginLeft:"4px"},children:o?"▲":"▼"})]}),t.url&&e.jsx("a",{href:(()=>{const c=hn(t.metadata);return c?fn(t.url,c):t.url})(),target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--bim-link-fg, #0066cc)",textDecoration:"none"},children:n.action.visit})]}),Ue(t)&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",display:"flex",gap:"12px",flexWrap:"wrap"},children:[t.metadata&&Object.entries(t.metadata).filter(([c])=>c!=="check_type").map(([c,j])=>e.jsxs("span",{children:[n.metadata[c]||c,": ",gn(c,j,n,i)]},c)),t.details&&!s&&e.jsx("span",{children:i(t.details)}),t.structure&&e.jsxs("span",{children:[n.misc.structure,": ",t.structure.join(" → ")]}),t.coverage&&e.jsxs("span",{children:[n.misc.coverage,": L",t.coverage.level," ",t.coverage.ranges]})]}),s&&o&&e.jsx("div",{style:{marginTop:"8px",padding:"8px 0",borderTop:"1px solid var(--bim-widget-border, #f0f0f0)",display:"flex",flexWrap:"wrap",gap:"4px"},children:d.map(c=>{const j=c.status==="missing";return e.jsx("span",{style:{display:"inline-flex"},children:c.url&&!j?e.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",padding:"2px 6px",fontSize:"11px",borderRadius:"3px",border:"1px solid var(--bim-widget-border, #e0e0e0)",color:"var(--bim-link-fg, #0066cc)",textDecoration:"none",lineHeight:1.4},title:c.label||`${c.volume}`,children:c.volume}):e.jsx("span",{style:{display:"inline-block",padding:"2px 6px",fontSize:"11px",borderRadius:"3px",border:"1px solid transparent",color:j?"#e67e22":"var(--bim-desc-fg, #999)",textDecoration:j?"line-through":"none",opacity:j?.6:1,lineHeight:1.4},children:c.volume})},c.volume)})})]})},yt=({indexSource:t,syncConfig:n,variant:i="index-browser",onSwitchMode:o,onToggleDraft:r,onConfigurePath:l,onSelectFolder:d})=>{const s=$(),a=t==="local",x=(n==null?void 0:n.isDraft)??!0,g=(n==null?void 0:n.repoPath)||"",u=g?g.split(/[/\\]/).pop()||g:"",f={display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"8px",fontSize:"12px",fontWeight:500,cursor:"pointer",transition:"opacity 0.2s",border:"none",background:"var(--bim-primary-soft, #0078d415)",color:"var(--bim-primary, #0078d4)"},c={onMouseOver:S=>S.currentTarget.style.opacity="0.8",onMouseOut:S=>S.currentTarget.style.opacity="1"},j=e.jsxs("div",{onClick:r,title:x?s.mode.switchToOfficial:s.mode.switchToDraft,style:{...f,background:x?"var(--bim-warning, #ff9800)":"var(--bim-success, #4caf50)",color:"white"},...c,children:[e.jsx("span",{children:x?"📝":"📚"}),e.jsx("span",{children:x?"draft":"official"})]});return i==="index-browser"?a?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[j,e.jsxs("div",{onClick:o,title:s.mode.switchToSync,style:f,...c,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:s.mode.localMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:d,title:g||s.mode.selectFolder,style:{...f,paddingLeft:"8px",paddingRight:"8px"},...c,children:[e.jsx("span",{children:"📂"}),u&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[j,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:o,title:s.mode.switchToLocal,style:f,...c,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:s.mode.syncMode}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:l,title:u||s.mode.configurePath,style:{...f,background:"transparent",padding:"6px",fontSize:"12px"},...c,children:e.jsx("span",{children:"⚙️"})})]})]}):e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsxs("div",{onClick:o,title:a?s.mode.switchToGithub:s.mode.switchToLocal,style:f,...c,children:[e.jsx("span",{children:a?"📁":"🌐"}),e.jsx("span",{children:a?s.mode.localMode:s.mode.githubSync}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),a&&e.jsxs("div",{onClick:d,title:g||s.mode.selectFolder,style:{...f,paddingLeft:"8px",paddingRight:"8px",minWidth:g?"100px":"auto",justifyContent:"space-between"},...c,children:[e.jsx("span",{children:"📂"}),u&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:u})]}),!a&&u&&e.jsxs("div",{style:{...f,background:"#2196f3",color:"white",cursor:"default"},title:g,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:u})]})]})},_e="bim-search-history",Ge=10,Ke=8;function ve(){try{const t=localStorage.getItem(_e);return t?JSON.parse(t):[]}catch{return[]}}function yn(t){try{const n=ve().filter(i=>i!==t);n.unshift(t),n.length>Ge&&(n.length=Ge),localStorage.setItem(_e,JSON.stringify(n))}catch{}}function vn(t){try{const n=ve().filter(i=>i!==t);localStorage.setItem(_e,JSON.stringify(n))}catch{}}function jn(){try{localStorage.removeItem(_e)}catch{}}const vt=({transport:t,value:n,onChange:i,onSearch:o,onEntrySelect:r,placeholder:l})=>{const d=$(),s=l??d.search.placeholder,a={work:d.indexType.work,book:d.indexType.book,collection:d.indexType.collection},[x,g]=p.useState(!1),[u,f]=p.useState([]),[c,j]=p.useState(-1),[S,h]=p.useState(null),[W,b]=p.useState(ve),_=p.useRef(null),y=p.useRef(null),w=p.useRef(null);p.useEffect(()=>{if(!t.getAllEntries)return;let k=!1;return t.getAllEntries().then(B=>{k||h(B)}).catch(()=>{}),()=>{k=!0}},[t]);const C=p.useCallback(k=>{if(!k.trim())return W.map(z=>({type:"history",text:z}));if(!S)return[];const B=k.toLowerCase(),H=[],E=[];for(const z of S){if(H.length+E.length>=Ke*2)break;const D=z.title.toLowerCase();if(D.startsWith(B))H.push({type:"entry",text:z.title,entry:z});else if(D.includes(B))E.push({type:"entry",text:z.title,entry:z});else if(z.additional_titles){for(const N of z.additional_titles)if(N.toLowerCase().includes(B)){H.push({type:"entry",text:`${z.title}`,entry:z});break}}}return[...H,...E].slice(0,Ke)},[S,W]);p.useEffect(()=>{f(C(n)),j(-1)},[n,C]),p.useEffect(()=>{const k=B=>{w.current&&!w.current.contains(B.target)&&g(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]),p.useEffect(()=>{const k=B=>{var H,E;if(B.key==="/"&&document.activeElement!==_.current){const z=(H=document.activeElement)==null?void 0:H.tagName;if(z==="INPUT"||z==="TEXTAREA"||z==="SELECT")return;B.preventDefault(),(E=_.current)==null||E.focus()}};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[]);const v=p.useCallback(k=>{k.trim()&&(yn(k.trim()),b(ve())),o(k),g(!1)},[o]),m=p.useCallback(k=>{k.type==="history"?(i(k.text),v(k.text)):k.entry&&(r?(r(k.entry),g(!1)):(i(k.text),v(k.text)))},[i,v,r]),R=p.useCallback(k=>{if(!x||u.length===0){k.key==="Enter"&&v(n);return}switch(k.key){case"ArrowDown":k.preventDefault(),j(B=>(B+1)%u.length);break;case"ArrowUp":k.preventDefault(),j(B=>(B-1+u.length)%u.length);break;case"Enter":k.preventDefault(),c>=0&&c<u.length?m(u[c]):v(n);break;case"Escape":k.preventDefault(),g(!1);break}},[x,u,c,n,v,m]),I=p.useCallback((k,B)=>{B.stopPropagation(),vn(k),b(ve()),f(H=>H.filter(E=>!(E.type==="history"&&E.text===k)))},[]),A=p.useCallback(k=>{k.stopPropagation(),jn(),b([]),f([])},[]);p.useEffect(()=>{if(c>=0&&y.current){const k=y.current.children;k[c]&&k[c].scrollIntoView({block:"nearest"})}},[c]);const L=!n.trim()&&W.length>0;return e.jsxs("div",{ref:w,style:{position:"relative",flex:1},children:[e.jsx("input",{ref:_,type:"text",placeholder:s,value:n,onChange:k=>{i(k.target.value),g(!0)},onFocus:()=>g(!0),onKeyDown:R,style:{width:"100%",padding:"8px 12px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"6px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",fontSize:"14px",boxSizing:"border-box"}}),x&&u.length>0&&e.jsxs("div",{ref:y,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:"var(--bim-input-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",zIndex:100,maxHeight:"320px",overflow:"auto"},children:[L&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 12px",fontSize:"11px",color:"var(--bim-desc-fg, #717171)",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[e.jsx("span",{children:d.search.history}),e.jsx("button",{onClick:A,style:{border:"none",background:"transparent",color:"var(--bim-desc-fg, #717171)",cursor:"pointer",fontSize:"11px",padding:"0 4px"},children:d.search.clearAll})]}),u.map((k,B)=>e.jsxs("div",{onClick:()=>m(k),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",cursor:"pointer",fontSize:"13px",color:"var(--bim-fg, #333)",background:B===c?"var(--bim-list-active-bg, #e8f0fe)":"transparent"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.5,width:"16px",textAlign:"center"},children:k.type==="history"?"🕐":"🔍"}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.text}),k.entry&&e.jsxs("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)",flexShrink:0},children:[a[k.entry.type],k.entry.edition&&` · ${k.entry.edition}`,k.entry.author&&` · ${k.entry.author}`]}),k.type==="history"&&e.jsx("button",{onClick:H=>I(k.text,H),style:{border:"none",background:"transparent",color:"var(--bim-desc-fg, #717171)",cursor:"pointer",fontSize:"12px",padding:"0 2px",lineHeight:1},title:d.action.remove,children:"×"})]},`${k.type}-${k.text}-${B}`))]})]})},Pe="bim-recent-ids",Je="bim-recent-entries",Ze=50,Re=5,Sn=50,kn=200;function $e(){try{const t=localStorage.getItem(Pe);if(t)return JSON.parse(t);const n=localStorage.getItem(Je);if(n){const i=JSON.parse(n).map(o=>o.id);return localStorage.setItem(Pe,JSON.stringify(i)),localStorage.removeItem(Je),i}return[]}catch{return[]}}function wn(t){try{const n=$e().filter(i=>i!==t);n.unshift(t),n.length>Ze&&(n.length=Ze),localStorage.setItem(Pe,JSON.stringify(n))}catch{}}const Cn={works:"totalWorks",books:"totalBooks",collections:"totalCollections"},Ae=({transport:t,indexSource:n="local",syncConfig:i,onEntryClick:o,onNewEntry:r,onSwitchMode:l,onToggleDraft:d,onConfigurePath:s,onSelectFolder:a,hideModeIndicator:x,initialQuery:g,onQueryChange:u,headerRight:f})=>{const c=$(),j=[{type:"work",icon:"✍️",name:c.indexType.work,key:"works"},{type:"book",icon:"📖",name:c.indexType.book,key:"books"},{type:"collection",icon:"📚",name:c.indexType.collection,key:"collections"}],[S,h]=p.useState(g??""),[W,b]=p.useState(null),[_,y]=p.useState(null),[w,C]=p.useState(!1),[v,m]=p.useState(null),[R,I]=p.useState(""),[A,L]=p.useState(!g),[k,B]=p.useState($e),[H,E]=p.useState([]),[z,D]=p.useState(!1),[N,Y]=p.useState(!1),[M,ee]=p.useState(null),q=p.useRef(void 0),te=p.useRef(!1),ne=p.useCallback(async(P,G)=>{if(!P.trim()){L(!0),b(null),y(null);return}L(!1),C(!0),I("");try{if(t.searchAll){const V=await t.searchAll(P,G??Re);b(V)}else{const V=["work","book","collection"],Z=await Promise.all(V.map(se=>t.search(P,se,{page:1,pageSize:G??Re})));b({works:Z[0].entries,books:Z[1].entries,collections:Z[2].entries,totalWorks:Z[0].total,totalBooks:Z[1].total,totalCollections:Z[2].total})}}catch(V){I(V instanceof Error?V.message:String(V)),b(null)}finally{C(!1)}},[t]);p.useEffect(()=>{let P=!1;const G=["work","book","collection"];return Promise.all(G.map(V=>t.loadEntries(V,{page:1,pageSize:1}).catch(()=>({total:0})))).then(V=>{P||ee({works:V[0].total,books:V[1].total,collections:V[2].total})}),()=>{P=!0}},[t]),p.useEffect(()=>{te.current||!(g!=null&&g.trim())||(te.current=!0,ne(g))},[g,ne]);const xe=p.useCallback(P=>{if(h(P),u==null||u(P),!P.trim()){L(!0),b(null),y(null);return}q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{y(null),ne(P)},kn)},[ne,u]),le=p.useCallback(P=>{q.current&&clearTimeout(q.current),u==null||u(P),ne(P)},[ne,u]),U=p.useCallback(P=>{y(P),ne(S,Sn)},[S,ne]);p.useEffect(()=>{if(!k.length){E([]);return}let P=!1;return D(!0),Promise.all(k.slice(0,10).map(async G=>{var V,Z,se;try{if(t.getEntry){const K=await t.getEntry(G);if(K)return K}const ae=await t.getItem(G);if(ae){const K=ae.authors;return{id:G,title:ae.title||G,type:ae.type||"work",author:(V=K==null?void 0:K[0])==null?void 0:V.name,dynasty:(Z=K==null?void 0:K[0])==null?void 0:Z.dynasty,role:(se=K==null?void 0:K[0])==null?void 0:se.role,edition:ae.edition||void 0}}}catch{}return null})).then(G=>{P||(E(G.filter(V=>V!==null)),D(!1))}),()=>{P=!0}},[k,t]);const he=P=>{m(P.id),wn(P.id),B($e()),o==null||o(P)},ke=P=>j.find(G=>G.type===P),Te=W&&(W.works.length>0||W.books.length>0||W.collections.length>0);return e.jsxs("div",{className:"bim-browser-container",children:[e.jsx("header",{style:{padding:"12px 20px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h1",{style:{margin:0,fontSize:"18px",color:"var(--bim-fg, #333)"},children:c.browser.title}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f,!x&&e.jsx(yt,{variant:"index-browser",indexSource:n,syncConfig:i,onSwitchMode:l,onToggleDraft:d,onConfigurePath:s,onSelectFolder:a})]})]})}),e.jsxs("div",{style:{display:"flex",gap:"8px",padding:"12px 20px",alignItems:"center"},children:[e.jsx(vt,{transport:t,value:S,onChange:xe,onSearch:le,onEntrySelect:he}),r&&e.jsx("button",{onClick:()=>r("work"),style:{padding:"8px 14px",border:"1px solid var(--bim-primary, #0078d4)",borderRadius:"6px",background:"transparent",color:"var(--bim-primary, #0078d4)",cursor:"pointer",fontSize:"13px"},children:c.action.newEntry})]}),M&&A&&e.jsxs("div",{style:{padding:"0 20px 8px",fontSize:"12px",color:"var(--bim-desc-fg, #999)"},children:[c.indexType.work," ",e.jsx("strong",{style:{color:"var(--bim-fg, #555)"},children:M.works.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),c.indexType.book," ",e.jsx("strong",{style:{color:"var(--bim-fg, #555)"},children:M.books.toLocaleString()}),e.jsx("span",{style:{margin:"0 6px"},children:"·"}),c.indexType.collection," ",e.jsx("strong",{style:{color:"var(--bim-fg, #555)"},children:M.collections.toLocaleString()})]}),e.jsx("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:w?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:"var(--bim-desc-fg, #717171)"},children:c.search.searching}):R?e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("div",{style:{fontSize:"24px",marginBottom:"8px"},children:"⚠️"}),e.jsx("p",{style:{color:"var(--bim-desc-fg, #717171)"},children:R})]}):A?e.jsx("div",{style:{flex:1},children:z?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:"var(--bim-desc-fg, #717171)"},children:c.search.loading}):H.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 0",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:c.search.recentBrowse}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:H.slice(0,N?10:3).map(P=>e.jsx(Xe,{entry:P,selected:v===P.id,onClick:he,getConfig:ke},P.id))}),!N&&H.length>3&&e.jsx("button",{onClick:()=>Y(!0),style:{display:"block",margin:"8px auto 0",padding:"4px 16px",fontSize:"12px",color:"var(--bim-primary, #0078d4)",background:"transparent",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",cursor:"pointer"},children:c.action.expandMore})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px"},children:"📚"}),e.jsx("h3",{style:{margin:"0 0 8px",color:"var(--bim-fg, #333)"},children:c.search.searchTitle}),e.jsx("p",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:c.search.searchSubtitle})]})}):Te?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:j.map(({type:P,icon:G,name:V,key:Z})=>{const se=W[Z],ae=Cn[Z],K=W[ae];if(se.length===0)return null;const we=!(_===P)&&K>Re;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",marginBottom:"6px"},children:[e.jsxs("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--bim-fg, #333)"},children:[G," ",V,e.jsxs("span",{style:{fontWeight:400,color:"var(--bim-desc-fg, #717171)",marginLeft:"6px"},children:[K," ",c.unit.items]})]}),we&&e.jsx("button",{onClick:()=>U(P),style:{border:"none",background:"transparent",color:"var(--bim-primary, #0078d4)",cursor:"pointer",fontSize:"12px"},children:c.action.viewAll})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:se.map(T=>e.jsx(Xe,{entry:T,selected:v===T.id,onClick:he,getConfig:ke,query:S},T.id))})]},P)})}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px"},children:"📚"}),e.jsx("h3",{style:{margin:"0 0 8px",color:"var(--bim-fg, #333)"},children:Se(c.search.noResultsFor,{query:S})}),e.jsx("p",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:c.search.tryOther})]})})]})},Xe=({entry:t,selected:n,onClick:i,getConfig:o,query:r})=>{const l=$(),{convert:d}=F(),s=r&&t.additional_titles?t.additional_titles.find(a=>a.toLowerCase().includes(r.toLowerCase())):void 0;return e.jsxs("div",{onClick:()=>i(t),style:{display:"flex",alignItems:"flex-start",gap:"10px",padding:"10px 12px",borderRadius:"6px",border:n?"1px solid var(--bim-primary, #0078d4)":"1px solid var(--bim-widget-border, #e0e0e0)",cursor:"pointer",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",marginTop:"2px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:o(t.type).icon}),e.jsx("span",{style:{fontSize:"9px",color:"var(--bim-desc-fg, #999)",lineHeight:1},children:o(t.type).name})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--bim-fg, #333)"},children:d(t.title)}),e.jsxs("span",{style:{display:"flex",gap:"2px",fontSize:"12px",opacity:.7},children:[t.has_text&&e.jsx("span",{title:l.misc.textResource,children:"📝"}),t.has_image&&e.jsx("span",{title:l.misc.imageResource,children:"🖼️"})]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)"},children:d(t.edition)}),t.juan_count!=null&&t.juan_count>0&&e.jsxs("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)"},children:[t.juan_count,l.unit.juan]})]}),(t.dynasty||t.author)&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginTop:"2px"},children:[t.dynasty&&e.jsxs("span",{children:["〔",d(t.dynasty),"〕"]}),t.author&&e.jsx("span",{children:d(t.author)}),t.role&&t.role!=="author"&&e.jsxs("span",{children:[" ",d(t.role)]})]}),s&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)",marginTop:"2px"},children:[l.search.alias,":",d(s)]})]}),e.jsx("span",{style:{opacity:.4,marginTop:"2px"},children:"→"})]})},In=["〇","一","二","三","四","五","六","七","八","九"],qe=["","十","百","千"];function jt(t){if(t<=0)return"";if(t>=1e4)return String(t);const n=String(t),i=n.length;let o="",r=!1;for(let l=0;l<i;l++){const d=parseInt(n[l]),s=i-1-l;d===0?r=!0:(r&&o&&(o+="〇"),r=!1,d===1&&s===1&&l===0?o+=qe[s]:o+=In[d]+qe[s])}return o}function St({type:t}){const n=$(),i={book:"#c0392b",work:"#8e6f3e",collection:"#2471a3"};return e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:i[t],border:`1px solid ${i[t]}40`,borderRadius:"2px",background:`${i[t]}08`},children:n.indexType[t]})}function zn({isDraft:t}){const n=$();return e.jsx("span",{style:{display:"inline-block",padding:"1px 6px",fontSize:"11px",fontWeight:500,letterSpacing:"1px",color:t?"#e67e22":"#27ae60",border:`1px solid ${t?"#e67e2240":"#27ae6040"}`,borderRadius:"2px",background:t?"#e67e2208":"#27ae6008"},children:t?n.status.draft:n.status.official})}function _n({id:t}){const n=$(),[i,o]=p.useState(!1),r=()=>{navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1500)})};return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"3px 8px 3px 10px",fontSize:"12px",color:"var(--bim-desc-fg, #717171)",background:"#f6f6f6",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px"},children:[e.jsx("span",{children:n.label.id}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:"12px",color:"var(--bim-fg, #333)"},children:t}),e.jsx("span",{onClick:r,title:i?n.action.copied:n.action.copy,style:{cursor:"pointer",fontSize:"13px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:l=>l.currentTarget.style.opacity="1",onMouseLeave:l=>l.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function Q({children:t,extra:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:"20px",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",letterSpacing:"1px"},children:t}),e.jsx("span",{style:{flex:1}}),n]})}function re({label:t,children:n}){return e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"4px",fontSize:"13px"},children:[e.jsx("span",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"12px"},children:t}),e.jsx("span",{style:{color:"var(--bim-fg, #333)"},children:n})]})}function kt({authors:t,type:n}){const{convert:i}=F();return e.jsx("span",{style:{fontSize:"14px",color:"var(--bim-fg, #333)",lineHeight:1.6},children:t.map((o,r)=>e.jsxs("span",{children:[r>0&&e.jsx("span",{style:{color:"var(--bim-desc-fg, #aaa)",margin:"0 4px"},children:"·"}),o.dynasty&&e.jsxs("span",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"12px"},children:["〔",i(o.dynasty),"〕"]}),e.jsx("span",{style:{fontWeight:500},children:i(o.name)}),o.role&&e.jsxs("span",{style:{color:"var(--bim-desc-fg, #999)",fontSize:"12px",marginLeft:"2px"},children:[" ",i(o.role)]})]},r))})}function pe({id:t,label:n,onNavigate:i,renderLink:o}){return o?e.jsx(e.Fragment,{children:o(t,n)}):i?e.jsx("a",{href:`/${t}`,onClick:r=>{r.metaKey||r.ctrlKey||(r.preventDefault(),i(t))},style:{color:"var(--bim-link-fg, #0066cc)",cursor:"pointer",textDecoration:"none",borderBottom:"1px dashed var(--bim-link-fg, #0066cc)",paddingBottom:"1px"},onMouseEnter:r=>r.currentTarget.style.borderBottomStyle="solid",onMouseLeave:r=>r.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{children:n||t})}function Tn({id:t,title:n,edition:i,type:o,isDraft:r,authors:l,volumeText:d,meta:s,headerExtra:a}){return e.jsxs("div",{style:{marginBottom:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"12px"},children:[e.jsxs("h1",{style:{fontSize:"24px",fontWeight:700,color:"var(--bim-fg, #1a1a1a)",margin:"0 0 6px",lineHeight:1.3,letterSpacing:"0.5px",flex:1,minWidth:0},children:[n,i&&e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--bim-desc-fg, #717171)",marginLeft:"6px"},children:i}),d&&e.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:"var(--bim-desc-fg, #717171)",marginLeft:"8px"},children:d})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,paddingTop:"4px"},children:[e.jsx(St,{type:o}),e.jsx(zn,{isDraft:r}),e.jsx(_n,{id:t}),a]})]}),((l==null?void 0:l.length)||s.length>0)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"baseline",gap:"12px",marginTop:"6px"},children:[l&&l.length>0&&e.jsx(kt,{authors:l,type:o}),s]})]})}function Rn({items:t,onNavigate:n,renderLink:i}){const o=$(),{convert:r}=F();if(!t.length)return null;const[l,d]=p.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:o.section.indexed}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map((s,a)=>{const x=l===a;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...x?{boxShadow:"0 1px 4px rgba(0,0,0,0.06)"}:{}},children:[e.jsxs("div",{onClick:()=>d(x?null:a),style:{padding:"8px 12px",background:"var(--bim-input-bg, #fff)",cursor:"pointer",display:"flex",alignItems:"baseline",gap:"6px",userSelect:"none"},children:[e.jsx("span",{style:{fontSize:"10px",color:"var(--bim-desc-fg, #717171)",transition:"transform 0.15s",transform:x?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--bim-fg, #333)"},children:r(s.source)}),!x&&s.title_info&&e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r(s.title_info)}),s.source_bid&&e.jsx("span",{onClick:g=>g.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:e.jsx(pe,{id:s.source_bid,label:o.action.view,onNavigate:n,renderLink:i})})]}),x&&e.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[(s.title_info||s.author_info||s.edition)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[s.title_info&&e.jsx(re,{label:o.label.titleInfo,children:r(s.title_info)}),s.author_info&&e.jsx(re,{label:o.label.authorInfo,children:r(s.author_info)}),s.edition&&e.jsx(re,{label:o.label.edition,children:r(s.edition)})]}),s.summary&&e.jsxs("div",{style:{marginTop:"6px",padding:"10px 14px",borderLeft:"3px solid var(--bim-primary, #8e6f3e)",background:"color-mix(in srgb, var(--bim-primary, #8e6f3e) 4%, transparent)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:o.section.summary}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #333)",lineHeight:1.9,margin:0,textAlign:"justify"},children:r(s.summary)})]}),s.comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:"3px solid var(--bim-desc-fg, #aaa)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:o.section.comment}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:r(s.comment)})]}),s.additional_comment&&e.jsxs("div",{style:{marginTop:"8px",padding:"8px 14px",borderLeft:"3px solid var(--bim-desc-fg, #ccc)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:o.section.additionalComment}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:r(s.additional_comment)})]})]})]},a)})})]})}function En({items:t}){const n=$(),{convert:i}=F();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:n.section.aliases}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((o,r)=>e.jsx("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:"var(--bim-fg, #333)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)"},children:i(o)},r))})]}):null}function Ln({items:t}){const n=$(),{convert:i}=F();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:n.section.appendix}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((o,r)=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"baseline",gap:"3px",padding:"3px 8px",fontSize:"13px",color:"var(--bim-fg, #333)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)"},children:["《",i(o.book_title),"》",o.n_juan!=null&&e.jsxs("span",{style:{color:"var(--bim-desc-fg, #999)",fontSize:"12px"},children:[o.n_juan,n.unit.juan]})]},r))})]}):null}function Bn({items:t}){const n=$(),{convert:i}=F();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:n.section.locationHistory}),e.jsxs("div",{style:{position:"relative",paddingLeft:"18px"},children:[e.jsx("div",{style:{position:"absolute",left:"4px",top:"6px",bottom:"6px",width:"1px",background:"var(--bim-widget-border, #ddd)"}}),t.map((o,r)=>e.jsxs("div",{style:{position:"relative",marginBottom:"10px"},children:[e.jsx("div",{style:{position:"absolute",left:"-16px",top:"5px",width:"7px",height:"7px",borderRadius:"50%",background:"var(--bim-primary, #8e6f3e)",border:"1.5px solid var(--bim-input-bg, #fff)"}}),e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:"var(--bim-fg, #333)"},children:i(o.name)}),o.description&&e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",marginLeft:"8px"},children:i(o.description)})]},r))]})]}):null}function Wn({items:t}){const n=$(),{convert:i}=F();return t.length?e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:n.section.historyOverview}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map((o,r)=>e.jsxs("div",{style:{fontSize:"13px",color:"var(--bim-fg, #333)",lineHeight:1.7,paddingLeft:"12px",position:"relative"},children:[e.jsx("span",{style:{position:"absolute",left:0,top:0,color:"var(--bim-desc-fg, #ccc)"},children:"·"}),i(o)]},r))})]}):null}function Qe({title:t,ids:n,transport:i,onNavigate:o,renderLink:r}){const{convert:l}=F(),[d,s]=p.useState([]);return p.useEffect(()=>{if(!n.length){s([]);return}if(!i){s(n.map(x=>({id:x})));return}let a=!1;return Promise.all(n.map(x=>i.getItem(x).then(g=>({id:x,title:g?g.title:void 0,edition:g?g.edition:void 0,type:g?g.type:void 0})).catch(()=>({id:x})))).then(x=>{a||s(x)}),()=>{a=!0}},[n,i]),n.length?e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[t,e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #aaa)",fontWeight:400},children:["(",n.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:(d.length?d:n.map(a=>({id:a}))).map(a=>{const x=a.edition?`${l(a.title)||a.id}(${l(a.edition)})`:l(a.title)||void 0;return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",transition:"border-color 0.15s"},children:e.jsx(pe,{id:a.id,label:x,onNavigate:o,renderLink:r})},a.id)})})]}):null}function Pn({book:t,onNavigate:n,renderLink:i}){const o=$(),{convert:r}=F(),[l,d]=p.useState(!1),s=t.resources&&t.resources.length>0,a=t.edition?`${r(t.title)||t.id}(${r(t.edition)})`:r(t.title)||void 0;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{padding:"10px 14px",borderBottom:s&&!l?"1px solid var(--bim-widget-border, #e0e0e0)":"none",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(pe,{id:t.id,label:a,onNavigate:n,renderLink:i})}),s&&e.jsx("span",{onClick:()=>d(x=>!x),style:{cursor:"pointer",fontSize:"10px",color:"var(--bim-desc-fg, #999)",userSelect:"none",transition:"transform 0.15s",transform:l?"rotate(-90deg)":"rotate(0deg)",display:"inline-block"},title:l?o.action.expand:o.action.collapse,children:"▼"})]}),s&&!l&&e.jsx("div",{style:{padding:"10px 14px"},children:e.jsx(De,{items:t.resources,groupByType:!0})})]})}function $n({ids:t,transport:n,onNavigate:i,renderLink:o}){const r=$(),[l,d]=p.useState([]);return p.useEffect(()=>{if(!t.length){d([]);return}if(!n){d(t.map(a=>({id:a})));return}let s=!1;return Promise.all(t.map(a=>n.getItem(a).then(x=>({id:a,title:x?x.title:void 0,edition:x?x.edition:void 0,resources:x?x.resources:void 0})).catch(()=>({id:a})))).then(a=>{s||d(a)}),()=>{s=!0}},[t,n]),t.length?e.jsxs(e.Fragment,{children:[e.jsxs(Q,{children:[r.section.relatedVersions,e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #aaa)",fontWeight:400},children:["(",t.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:(l.length?l:t.map(s=>({id:s}))).map(s=>e.jsx(Pn,{book:s,onNavigate:i,renderLink:o},s.id))})]}):null}function An({workData:t,onNavigate:n,renderLink:i}){var l,d,s;const o=$(),{convert:r}=F();return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",overflow:"hidden",background:"var(--bim-input-bg, #fff)",marginTop:"4px"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",display:"flex",alignItems:"center",gap:"8px",background:"color-mix(in srgb, var(--bim-primary, #8e6f3e) 4%, transparent)"},children:[e.jsx(St,{type:"work"}),e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:"var(--bim-fg, #333)"},children:e.jsx(pe,{id:t.id,label:r(t.title),onNavigate:n,renderLink:i})}),((l=t.juan_count)==null?void 0:l.number)!=null&&t.juan_count.number>0&&e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:[jt(t.juan_count.number),o.unit.juan]})]}),e.jsxs("div",{style:{padding:"12px 16px"},children:[t.authors&&t.authors.length>0&&e.jsx(kt,{authors:t.authors,type:"work"}),((d=t.description)==null?void 0:d.text)&&e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #444)",lineHeight:1.8,margin:(s=t.authors)!=null&&s.length?"8px 0 0":"0",textAlign:"justify"},children:r(t.description.text)}),t.parent_work&&e.jsx("div",{style:{marginTop:"8px",fontSize:"13px"},children:e.jsx(re,{label:o.label.parentWork,children:e.jsx(pe,{id:t.parent_work.id,label:r(t.parent_work.title),onNavigate:n,renderLink:i})})})]})]})}function Mn({items:t,onNavigate:n,renderLink:i}){const o=$(),{convert:r}=F();return t.length?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginTop:"6px"},children:t.map(l=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:"1px solid #2471a340",borderRadius:"4px",background:"#2471a308"},children:[e.jsx("span",{style:{fontSize:"11px",color:"#2471a3"},children:o.indexType.collection}),e.jsx(pe,{id:l.id,label:r(l.title)||l.id,onNavigate:n,renderLink:i}),l.volume_index!=null&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)",marginLeft:"2px"},children:Se(o.catalog.volume,{n:l.volume_index})})]},l.id))}):null}const He=({data:t,id:n,transport:i,onNavigate:o,renderLink:r,headerExtra:l,className:d,style:s})=>{var A,L,k,B,H,E;const a=$(),{convert:x}=F(),[g,u]=p.useState(null),[f,c]=p.useState(!1),[j,S]=p.useState(null),[h,W]=p.useState(null),[b,_]=p.useState([]),y=t||g;if(p.useEffect(()=>{if(t||!n||!i)return;let z=!1;return c(!0),S(null),i.getItem(n).then(D=>{z||(D?u(D):S(a.misc.notFoundEntry))}).catch(D=>{z||S(D instanceof Error?D.message:a.misc.loadFailed)}).finally(()=>{z||c(!1)}),()=>{z=!0}},[t,n,i]),p.useEffect(()=>{if(!y||!i){W(null),_([]);return}let z=!1;const D=y.type==="book"||y.type==="collection"?y.work_id:void 0;if(D?i.getItem(D).then(N=>{!z&&N&&N.type==="work"&&W(N)}).catch(()=>{}):W(null),y.type==="book"){const N=y;N.contained_in&&N.contained_in.length>0?Promise.all(N.contained_in.map(Y=>{const M=typeof Y=="string"?Y:Y.id,ee=typeof Y=="string"?void 0:Y.volume_index;return i.getItem(M).then(q=>({id:M,title:q&&q.title||M,volume_index:ee})).catch(()=>({id:M,title:M,volume_index:ee}))})).then(Y=>{z||_(Y)}):_([])}else _([]);return()=>{z=!0}},[y,i]),f)return e.jsx("div",{className:d,style:{...s,padding:"24px"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((z,D)=>e.jsx("div",{style:{height:D===1?"32px":"16px",width:`${z}px`,background:"var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",opacity:.4}},D))})});if(j)return e.jsx("div",{className:d,style:{...s,padding:"24px",textAlign:"center",color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:j});if(!y)return null;const w=y.type==="book"?y:null,C=y.type==="collection"?y:null,v=y.type==="work"?y:null;let m=!1;try{m=O.extractStatus(y.id)==="draft"}catch{}let R="";(A=y.juan_count)!=null&&A.number?R=jt(y.juan_count.number)+a.unit.juan:(L=y.juan_count)!=null&&L.description&&(R=x(y.juan_count.description));const I=[];return(k=y.publication_info)!=null&&k.year&&I.push(e.jsx(re,{label:a.label.year,children:y.publication_info.year},"year")),(B=y.current_location)!=null&&B.name&&I.push(e.jsx(re,{label:a.label.currentLocation,children:x(y.current_location.name)},"loc")),(H=y.page_count)!=null&&H.description&&I.push(e.jsx(re,{label:a.label.pageCount,children:y.page_count.description},"page")),w!=null&&w.edition&&I.push(e.jsx(re,{label:a.label.edition,children:x(w.edition)},"ver")),v!=null&&v.parent_work&&I.push(e.jsx(re,{label:a.label.parentWork,children:e.jsx(pe,{id:v.parent_work.id,label:x(v.parent_work.title),onNavigate:o,renderLink:r})},"pw")),v!=null&&v.parent_works&&v.parent_works.length>0&&!v.parent_work&&I.push(e.jsx(re,{label:a.label.parentWork,children:v.parent_works.map((z,D)=>e.jsxs("span",{children:[D>0&&"、",e.jsx(pe,{id:z,onNavigate:o,renderLink:r})]},z))},"pws")),e.jsxs("div",{className:d,style:s,children:[e.jsx(Tn,{id:y.id,title:x(y.title),edition:y.edition?x(y.edition):void 0,type:y.type,isDraft:m,authors:y.authors,volumeText:R,meta:I,headerExtra:l}),((E=y.description)==null?void 0:E.text)&&e.jsx("p",{style:{fontSize:"14px",color:"var(--bim-fg, #444)",lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"},children:x(y.description.text)}),b.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:a.section.containedIn}),e.jsx(Mn,{items:b,onNavigate:o,renderLink:r})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:a.section.belongsToWork}),e.jsx(An,{workData:h,onNavigate:o,renderLink:r})]}),y.additional_works&&y.additional_works.length>0&&e.jsx(Ln,{items:y.additional_works}),y.additional_titles&&y.additional_titles.length>0&&e.jsx(En,{items:y.additional_titles}),y.indexed_by&&y.indexed_by.length>0&&e.jsx(Rn,{items:y.indexed_by,onNavigate:o,renderLink:r}),y.resources&&y.resources.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Q,{children:a.section.resources}),e.jsx(De,{items:y.resources,groupByType:!0})]}),(w==null?void 0:w.location_history)&&w.location_history.length>0&&e.jsx(Bn,{items:w.location_history}),(C==null?void 0:C.history)&&C.history.length>0&&e.jsx(Wn,{items:C.history}),(w==null?void 0:w.related_books)&&w.related_books.length>0&&e.jsx(Qe,{title:a.section.relatedVersions,ids:w.related_books,transport:i,onNavigate:o,renderLink:r}),(C==null?void 0:C.books)&&C.books.length>0&&e.jsx(Qe,{title:a.section.containedBooks,ids:C.books,transport:i,onNavigate:o,renderLink:r}),(v==null?void 0:v.books)&&v.books.length>0&&e.jsx($n,{ids:v.books,transport:i,onNavigate:o,renderLink:r}),(v==null?void 0:v.related_works)&&v.related_works.length>0&&(()=>{const z=[],D=v.related_works.filter(M=>M.relation==="part_of"),N=v.related_works.filter(M=>M.relation==="has_part"),Y=v.related_works.filter(M=>!M.relation);return D.length>0&&z.push({label:a.section.belongsToWork,items:D}),N.length>0&&z.push({label:a.section.containedWorks,items:N}),Y.length>0&&z.push({label:a.section.relatedWorks,items:Y}),z.map(M=>e.jsxs("div",{children:[e.jsxs(Q,{children:[M.label,e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #aaa)",fontWeight:400},children:["(",M.items.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:M.items.map(ee=>e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"3px 10px",fontSize:"13px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)"},children:e.jsx(pe,{id:ee.id,label:x(ee.title),onNavigate:o,renderLink:r})},ee.id))})]},M.label))})()]})};function Fn({data:t}){const n=$(),{convert:i}=F(),{stats:o}=t,r=o.processed_volumes??o.total_found_volumes,l=r!=null&&t.total_volumes>0?Math.round(r/t.total_volumes*100):null;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:"var(--bim-fg, #1a1a1a)",margin:"0 0 8px"},children:i(t.title)}),t.resource_name&&e.jsx("div",{style:{fontSize:"13px",color:"var(--bim-desc-fg, #717171)",marginBottom:"6px"},children:i(t.resource_name)}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"16px",fontSize:"13px",color:"var(--bim-desc-fg, #717171)"},children:[e.jsxs("span",{children:[n.catalog.totalVolumes," ",e.jsx("strong",{style:{color:"var(--bim-fg, #333)"},children:t.total_volumes})," ",n.unit.volume]}),l!=null&&e.jsxs("span",{children:[n.catalog.processed," ",e.jsx("strong",{style:{color:"var(--bim-fg, #333)"},children:r})," ",n.unit.volume," (",l,"%)"]}),e.jsxs("span",{children:[n.catalog.contains," ",e.jsx("strong",{style:{color:"var(--bim-fg, #333)"},children:o.total_books})," ",n.unit.bu]}),o.matched_works!=null&&o.matched_works>0&&e.jsxs("span",{children:[n.catalog.matched," ",e.jsx("strong",{style:{color:"var(--bim-fg, #333)"},children:o.matched_works})," ",n.unit.bu]}),o.unmatched_works!=null&&o.unmatched_works>0&&e.jsxs("span",{children:[n.catalog.unmatched," ",e.jsx("strong",{style:{color:"#e67e22"},children:o.unmatched_works})," ",n.unit.bu]})]}),t.source&&e.jsxs("div",{style:{marginTop:"6px",fontSize:"12px",color:"var(--bim-desc-fg, #999)"},children:[n.catalog.source," ",t.source]})]})}function Dn({sections:t,activeSection:n,onSelect:i}){const o=$();return e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"16px"},children:[e.jsx("button",{onClick:()=>i(null),style:et(n===null),children:o.catalog.all}),t.map(r=>e.jsxs("button",{onClick:()=>i(r.name),style:et(n===r.name),children:[r.name,r.volume_range&&e.jsxs("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"4px"},children:[r.volume_range[0],"–",r.volume_range[1]]})]},r.name))]})}function et(t){return{padding:"4px 12px",border:t?"1px solid var(--bim-primary, #2471a3)":"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:t?"color-mix(in srgb, var(--bim-primary, #2471a3) 8%, transparent)":"transparent",color:t?"var(--bim-primary, #2471a3)":"var(--bim-fg, #333)",cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}function Hn({id:t,label:n,onNavigate:i,renderLink:o}){return o?e.jsx(e.Fragment,{children:o(t,n)}):i?e.jsx("a",{href:`/${t}`,onClick:r=>{r.metaKey||r.ctrlKey||(r.preventDefault(),i(t))},style:{color:"var(--bim-link-fg, #0066cc)",cursor:"pointer",textDecoration:"none",borderBottom:"1px dashed var(--bim-link-fg, #0066cc)",paddingBottom:"1px",fontSize:"12px"},onMouseEnter:r=>r.currentTarget.style.borderBottomStyle="solid",onMouseLeave:r=>r.currentTarget.style.borderBottomStyle="dashed",children:n||t}):e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)"},children:n||t})}function On(t,n){if(t.length===0)return"";if(t.length===1)return`${t[0]}`;const i=t[0],o=t[t.length-1];return o-i+1===t.length?`${i}–${o}`:t.length<=3?t.join(", "):`${i}–${o} (${t.length}${n})`}function tt({book:t,onNavigate:n,renderLink:i,showVolumes:o}){const r=$(),{convert:l}=F(),d=t.book_id||t.work_id,s=o&&t.volumes.length>0?On(t.volumes,r.unit.volume):null,a=t.missing_volumes&&t.missing_volumes.length>0;return e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",padding:"6px 12px",borderBottom:"1px solid var(--bim-widget-border, #f0f0f0)",fontSize:"14px",lineHeight:1.8},children:[o&&e.jsx("span",{style:{flexShrink:0,minWidth:"48px",fontSize:"12px",color:"var(--bim-desc-fg, #999)",textAlign:"right"},children:s}),e.jsxs("span",{style:{flex:1,fontWeight:500,color:"var(--bim-fg, #1a1a1a)"},children:[l(t.title),t.sub_items&&t.sub_items.length>0&&e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",fontWeight:400,marginLeft:"6px"},children:["(",t.sub_items.map(x=>l(x)).join("、"),")"]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #aaa)",fontWeight:400,marginLeft:"8px"},children:l(t.edition)})]}),t.expected_volumes!=null&&e.jsxs("span",{style:{fontSize:"11px",color:a?"#e67e22":"var(--bim-desc-fg, #999)",flexShrink:0},children:[t.found_volumes??0,"/",t.expected_volumes,r.unit.volume]}),d&&e.jsx(Hn,{id:d,label:t.book_id?r.indexType.book:r.indexType.work,onNavigate:n,renderLink:i}),!d&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #ccc)",flexShrink:0},children:r.catalog.unmatched_label})]})}const wt=({data:t,collectionId:n,transport:i,onNavigate:o,renderLink:r,className:l,style:d})=>{const s=$(),[a,x]=p.useState(null),[g,u]=p.useState(!1),[f,c]=p.useState(null),[j,S]=p.useState(null),[h,W]=p.useState(""),b=t||a;p.useEffect(()=>{if(t||!n||!(i!=null&&i.getCollectionCatalog))return;let v=!1;return u(!0),c(null),i.getCollectionCatalog(n).then(m=>{v||(m?x(m):c(s.catalog.notFound))}).catch(m=>{v||c(m instanceof Error?m.message:s.catalog.loadFailed)}).finally(()=>{v||u(!1)}),()=>{v=!0}},[t,n,i,s]);const _=(b==null?void 0:b.sections)&&b.sections.length>0,y=p.useMemo(()=>{if(!b)return!1;if(b.volume_index&&Object.keys(b.volume_index).length>0)return!0;const v=b.books.map(R=>R.volumes[0]).filter(R=>R!=null);return new Set(v).size<v.length},[b]),w=p.useMemo(()=>{if(!b)return[];let v=b.books;if(j&&(v=v.filter(m=>m.section===j)),h.trim()){const m=h.trim().toLowerCase();v=v.filter(R=>R.title.toLowerCase().includes(m)||R.sub_items&&R.sub_items.some(I=>I.toLowerCase().includes(m))||R.edition&&R.edition.toLowerCase().includes(m))}return v},[b,j,h]),C=p.useMemo(()=>{if(!y)return null;const v=[],m=new Map;for(const I of w){if(!I.volumes||I.volumes.length===0)continue;const A=I.volumes[0];m.has(A)||m.set(A,[]),m.get(A).push(I)}const R=[...m.keys()].sort((I,A)=>I-A);for(const I of R)v.push({volume:I,books:m.get(I)});return v},[w,y]);return g?e.jsx("div",{className:l,style:{...d,padding:"24px"},children:e.jsx("div",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:s.catalog.loading})}):f?e.jsx("div",{className:l,style:{...d,padding:"24px",textAlign:"center",color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:f}):b?e.jsxs("div",{className:l,style:d,children:[e.jsx(Fn,{data:b}),_&&e.jsx(Dn,{sections:b.sections,activeSection:j,onSelect:S}),e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("input",{type:"text",placeholder:s.search.searchBookName,value:h,onChange:v=>W(v.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",fontSize:"13px",boxSizing:"border-box"}}),e.jsxs("span",{style:{marginLeft:"12px",fontSize:"12px",color:"var(--bim-desc-fg, #999)"},children:[w.length," ",s.unit.bu]})]}),e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden"},children:[C?C.map((v,m)=>e.jsxs("div",{children:[e.jsx("div",{style:{padding:"4px 12px",background:"var(--bim-bg, #f8f8f8)",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",fontSize:"12px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",position:"sticky",top:0,zIndex:1},children:Se(s.catalog.volume,{n:v.volume})}),v.books.map((R,I)=>e.jsx(tt,{book:R,onNavigate:o,renderLink:r,showVolumes:R.volumes.length>1},`${v.volume}-${I}`))]},`${v.volume}-${m}`)):w.map((v,m)=>e.jsx(tt,{book:v,onNavigate:o,renderLink:r,showVolumes:!0},m)),w.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:"var(--bim-desc-fg, #999)",fontSize:"13px"},children:s.catalog.noMatch})]})]}):null},Vn=["〇","一","二","三","四","五","六","七","八","九"],nt=["","十","百","千"],Nn=["","萬","億"];function Ct(t){if(t===0)return"〇";if(t<0)return`負${Ct(-t)}`;const n=[];let i=t,o=0;for(;i>0;){const r=i%1e4;r>0?n.unshift(Un(r,o>0)+Nn[o]):n.length>0&&n.unshift("〇"),i=Math.floor(i/1e4),o++}return n.join("").replace(/〇+/g,"〇").replace(/〇$/,"")}function Un(t,n){const i=[];let o=t;for(;o>0;)i.unshift(o%10),o=Math.floor(o/10);let r="";for(let l=0;l<i.length;l++){const d=i[l],s=i.length-1-l;d===0?r&&!r.endsWith("〇")&&(r+="〇"):d===1&&s===1&&l===0&&!n?r+=nt[s]:r+=Vn[d]+nt[s]}return r.replace(/〇$/,"")}const It={部:"#2471a3",类:"#8e6f3e",书:"#c0392b",其他:"#717171"};function Yn(t){const n=t.replace(".json","");return n==="fulu"?"附錄":n.startsWith("juanshou")?`卷首${n.replace("juanshou","")}`:n.startsWith("juan")?`卷${n.replace("juan","").replace(/^0+/,"")}`:n}function zt({file:t,isActive:n,onSelect:i}){return e.jsx("button",{onClick:()=>i(t),style:{padding:"3px 8px",border:n?"1px solid var(--bim-primary, #8e6f3e)":"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"3px",background:n?"color-mix(in srgb, var(--bim-primary, #8e6f3e) 10%, transparent)":"transparent",color:n?"var(--bim-primary, #8e6f3e)":"var(--bim-fg, #333)",cursor:"pointer",fontSize:"12px",fontWeight:n?600:400,lineHeight:1.4},children:Yn(t)})}function _t(t,n){var i;return t.files.includes(n)?!0:!!((i=t.children)!=null&&i.some(o=>_t(o,n)))}function Tt(t){var o;const n=t.files.length,i=((o=t.children)==null?void 0:o.reduce((r,l)=>r+Tt(l),0))||0;return n+i}function Rt({group:t,activeFile:n,onSelect:i,depth:o=0}){var x;const r=_t(t,n||""),[l,d]=p.useState(r),s=Tt(t),a=!!((x=t.children)!=null&&x.length);return p.useEffect(()=>{r&&d(!0)},[r]),e.jsxs("div",{style:{marginBottom:o===0?"4px":"2px"},children:[e.jsxs("div",{onClick:()=>d(!l),style:{display:"flex",alignItems:"center",gap:"6px",padding:o===0?"4px 8px":"2px 8px",paddingLeft:`${8+o*16}px`,cursor:"pointer",userSelect:"none",fontSize:o===0?"13px":"12px",fontWeight:o===0?600:500,color:r?"var(--bim-primary, #8e6f3e)":"var(--bim-fg, #333)"},children:[e.jsx("span",{style:{fontSize:"9px",transition:"transform 0.15s",transform:l?"rotate(90deg)":"none",display:"inline-block"},children:"▶"}),e.jsx("span",{children:t.label}),e.jsxs("span",{style:{fontSize:"11px",fontWeight:400,color:"var(--bim-desc-fg, #999)"},children:["(",s,")"]})]}),l&&e.jsxs(e.Fragment,{children:[t.files.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",padding:`4px 0 4px ${24+o*16}px`},children:t.files.map(g=>e.jsx(zt,{file:g,isActive:n===g,onSelect:i},g))}),a&&t.children.map((g,u)=>e.jsx(Rt,{group:g,activeFile:n,onSelect:i,depth:o+1},u))]})]})}function Gn({files:t,groups:n,activeFile:i,onSelect:o}){return n&&n.length>0?e.jsx("div",{style:{marginBottom:"16px"},children:n.map((r,l)=>e.jsx(Rt,{group:r,activeFile:i,onSelect:o},l))}):e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px",marginBottom:"16px",maxHeight:"120px",overflow:"auto",padding:"4px 0"},children:t.map(r=>e.jsx(zt,{file:r,isActive:i===r,onSelect:o},r))})}function Kn({type:t}){const n=It[t]||"#717171";return e.jsx("span",{style:{display:"inline-block",padding:"1px 5px",fontSize:"10px",fontWeight:500,color:n,border:`1px solid ${n}40`,borderRadius:"2px",background:`${n}08`,flexShrink:0},children:t})}function Jn({section:t,onNavigate:n}){const{convert:i}=F(),[o,r]=p.useState(!1),l=!!t.summary,d=!!t.comment,s=!!t.additional_comment,a=l||d||s;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden",marginBottom:"6px"},children:[e.jsxs("div",{onClick:()=>a&&r(!o),style:{padding:"8px 12px",display:"flex",alignItems:"baseline",gap:"8px",cursor:a?"pointer":"default",userSelect:"none",background:"var(--bim-input-bg, #fff)"},children:[a&&e.jsx("span",{style:{fontSize:"9px",color:"var(--bim-desc-fg, #717171)",transition:"transform 0.15s",transform:o?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--bim-fg, #1a1a1a)",flex:1},children:[t.book_title?`《${i(t.book_title)}》`:i(t.title),t.n_juan!=null&&e.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:"var(--bim-desc-fg, #999)",marginLeft:"6px"},children:[Ct(t.n_juan),"卷"]})]}),t.edition&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #aaa)"},children:i(t.edition)}),t.tag&&e.jsx("span",{style:{fontSize:"11px",color:"#e74c3c"},children:t.tag==="triangle"?"△":t.tag}),t.work_id&&n&&e.jsx("a",{href:`/${t.work_id}`,onClick:x=>{x.metaKey||x.ctrlKey||(x.preventDefault(),x.stopPropagation(),n(t.work_id))},style:{fontSize:"11px",color:"var(--bim-link-fg, #0066cc)",cursor:"pointer",textDecoration:"none",flexShrink:0},title:"查看作品",children:"→作品"})]}),o&&a&&e.jsxs("div",{style:{padding:"8px 12px 12px",borderTop:"1px solid var(--bim-widget-border, #f0f0f0)",background:"var(--bim-bg, #fafafa)"},children:[t.author_info&&e.jsx("div",{style:{fontSize:"13px",color:"var(--bim-desc-fg, #717171)",marginBottom:"8px"},children:i(t.author_info)}),t.summary&&e.jsxs("div",{style:{marginBottom:"8px",padding:"10px 14px",borderLeft:"3px solid var(--bim-primary, #8e6f3e)",background:"color-mix(in srgb, var(--bim-primary, #8e6f3e) 4%, transparent)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:"提要"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #333)",lineHeight:1.9,margin:0,textAlign:"justify"},children:i(t.summary)})]}),t.comment&&e.jsxs("div",{style:{marginBottom:"8px",padding:"8px 14px",borderLeft:"3px solid var(--bim-desc-fg, #aaa)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:"按語"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:i(t.comment)})]}),t.additional_comment&&e.jsxs("div",{style:{padding:"8px 14px",borderLeft:"3px solid var(--bim-desc-fg, #ccc)",borderRadius:"0 4px 4px 0"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",letterSpacing:"1px"},children:"附按"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:i(t.additional_comment)})]})]})]})}function Zn({section:t}){const{convert:n}=F(),[i,o]=p.useState(!1),r=!!t.content;return e.jsxs("div",{style:{padding:"12px 0 6px"},children:[e.jsxs("div",{onClick:()=>r&&o(!i),style:{display:"flex",alignItems:"center",gap:"8px",cursor:r?"pointer":"default",userSelect:"none"},children:[e.jsx(Kn,{type:t.type}),e.jsx("span",{style:{fontSize:"15px",fontWeight:600,color:"var(--bim-fg, #1a1a1a)"},children:n(t.title)}),r&&e.jsx("span",{style:{fontSize:"9px",color:"var(--bim-desc-fg, #999)",transition:"transform 0.15s",transform:i?"rotate(90deg)":"none",display:"inline-block"},children:"▶"})]}),i&&r&&e.jsx("div",{style:{marginTop:"8px",padding:"10px 14px",borderLeft:`3px solid ${It[t.type]||"#717171"}40`,borderRadius:"0 4px 4px 0",background:"var(--bim-bg, #fafafa)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #333)",lineHeight:1.9,margin:0,textAlign:"justify",whiteSpace:"pre-line"},children:n(t.content)})})]})}function Xn({section:t}){const{convert:n}=F();if(!t.content&&!t.title)return null;const i=n((t.content||t.title||"").replace(/\n{2,}/g,`
2
2
  `));return e.jsx("div",{style:{padding:"6px 0",fontSize:"13px",color:"var(--bim-desc-fg, #717171)",lineHeight:1.7,whiteSpace:"pre-line"},children:i})}function qn({juan:t,searchQuery:n,onNavigate:i}){const{convert:o}=F(),r=p.useMemo(()=>{if(!n.trim())return t.sections;const d=n.trim().toLowerCase();return t.sections.filter(s=>{var a,x,g,u,f;return((a=s.title)==null?void 0:a.toLowerCase().includes(d))||((x=s.book_title)==null?void 0:x.toLowerCase().includes(d))||((g=s.author)==null?void 0:g.toLowerCase().includes(d))||((u=s.author_info)==null?void 0:u.toLowerCase().includes(d))||((f=s.summary)==null?void 0:f.toLowerCase().includes(d))})},[t.sections,n]),l=r.filter(d=>d.type==="书").length;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"12px",marginBottom:"12px"},children:[e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--bim-fg, #1a1a1a)",margin:0},children:o(t.title)}),t.source_url&&e.jsx("a",{href:t.source_url,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--bim-link-fg, #0066cc)",textDecoration:"none"},children:"原文 ↗"}),e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",marginLeft:"auto"},children:[l," 部书"]})]}),r.map((d,s)=>d.type==="书"?e.jsx(Jn,{section:d,onNavigate:i},s):d.type==="部"||d.type==="类"?e.jsx(Zn,{section:d},s):e.jsx(Xn,{section:d},s)),r.length===0&&e.jsx("div",{style:{padding:"32px",textAlign:"center",color:"var(--bim-desc-fg, #999)",fontSize:"13px"},children:"无匹配结果"})]})}const Et=({index:t,workId:n,transport:i,onNavigate:o,activeJuan:r,onJuanChange:l,className:d,style:s})=>{const[a,x]=p.useState(null),[g,u]=p.useState(!1),[f,c]=p.useState(null),[j,S]=p.useState(null),[h,W]=p.useState(null),[b,_]=p.useState(!1),[y,w]=p.useState(""),C=r??j,v=p.useCallback(L=>{S(L),l==null||l(L)},[l]),m=t||a;p.useEffect(()=>{if(t||!n||!(i!=null&&i.getCollatedEditionIndex))return;let L=!1;return u(!0),c(null),i.getCollatedEditionIndex(n).then(k=>{L||(k?(x(k),!r&&k.juan_files.length>0&&v(k.juan_files[0])):c("未找到整理本数据"))}).catch(k=>{L||c(k instanceof Error?k.message:"加载失败")}).finally(()=>{L||u(!1)}),()=>{L=!0}},[t,n,i,r,v]),p.useEffect(()=>{const L=t||a;L&&L.juan_files&&L.juan_files.length>0&&!C&&v(L.juan_files[0])},[t,a,C,v]);const R=n||(m==null?void 0:m.work_id),I=p.useCallback(async L=>{if(!(!R||!(i!=null&&i.getCollatedJuan))){_(!0),W(null);try{const k=await i.getCollatedJuan(R,L);W(k)}catch{W(null)}finally{_(!1)}}},[R,i]);p.useEffect(()=>{C&&I(C)},[C,I]);const A=L=>{v(L),w("")};return g?e.jsx("div",{className:d,style:{...s,padding:"24px"},children:e.jsx("div",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:"加载整理本..."})}):f?e.jsx("div",{className:d,style:{...s,padding:"24px",textAlign:"center",color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:f}):m?e.jsxs("div",{className:d,style:s,children:[e.jsx("div",{style:{marginBottom:"16px"},children:e.jsxs("div",{style:{fontSize:"13px",color:"var(--bim-desc-fg, #717171)"},children:["共 ",e.jsx("strong",{style:{color:"var(--bim-fg, #333)"},children:m.total_juan})," 卷"]})}),e.jsx(Gn,{files:m.juan_files,groups:m.juan_groups,activeFile:C,onSelect:A}),e.jsx("div",{style:{marginBottom:"12px"},children:e.jsx("input",{type:"text",placeholder:"搜索书名、作者...",value:y,onChange:L=>w(L.target.value),style:{width:"100%",maxWidth:"320px",padding:"6px 10px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",fontSize:"13px",boxSizing:"border-box"}})}),b?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:"加载中..."}):h?e.jsx(qn,{juan:h,searchQuery:y,onNavigate:o}):C?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--bim-desc-fg, #999)",fontSize:"13px"},children:"选择一卷查看内容"}):null]}):null},Qn=[{id:"FCNcSJbF77V",title:"欽定四庫全書·文淵閣本",description:"清·紀昀等編,藏於臺灣國立故宮博物院",group:"推薦叢編"},{id:"FCmH8kWxMhR",title:"二十四史百衲本",description:"民國·張元濟輯,商務印書館影印",group:"推薦叢編"},{id:"FCmYiXcTfuZ",title:"二十四史武英殿本",description:"清乾隆四年武英殿刻本",group:"推薦叢編"},{id:"FCmbeajrbJw",title:"武英殿聚珍版叢書",description:"清乾隆間武英殿活字印本",group:"推薦叢編"},{id:"GY4HvsY3w3u",title:"欽定四庫全書總目",description:"清·紀昀等編,200卷",group:"經典作品"},{id:"GY4JKKQaPYB",title:"欽定四庫全書簡明目錄",description:"清·紀昀等編,20卷",group:"經典作品"},{id:"GY4JM7j7yi7",title:"史記",description:"西漢·司馬遷,130卷",group:"經典作品"},{id:"GY3ty2LN9ro",title:"易經",description:"西周·周文王",group:"經典作品"}],Me=({transport:t,onNavigate:n,recommendedIds:i,activeTab:o,onTabChange:r})=>{const l=$(),[d,s]=p.useState(null),[a,x]=p.useState([]),[g,u]=p.useState("recommend"),f=o??g,c=w=>{u(w),r==null||r(w)},[j,S]=p.useState(!0),[h,W]=p.useState(null),[b,_]=p.useState(null);p.useEffect(()=>{if(!t.getAllEntries)return;let w=!1;return t.getAllEntries().then(C=>{if(w)return;const v=C.filter(I=>I.type==="work").length,m=C.filter(I=>I.type==="book").length,R=C.filter(I=>I.type==="collection").length;s({works:v,books:m,collections:R})}).catch(()=>{}),()=>{w=!0}},[t]),p.useEffect(()=>{let w=!1;return(async()=>{if(i)return i;if(t.getRecommended)try{const v=await t.getRecommended();if(v!=null&&v.groups)return v.groups.flatMap(m=>m.items.map(R=>({...R,group:m.name})))}catch{}return Qn})().then(async v=>{if(w)return;const m=v.filter(I=>I.id);if(m.length===0){S(!1);return}const R=await Promise.all(m.map(async I=>{try{let A=null;if(t.getEntry)A=await t.getEntry(I.id);else{const L=await t.getItem(I.id);L&&(A={id:I.id,title:L.title||I.id,type:L.type||"work"})}if(A)return{...A,group:I.group,fallbackDescription:I.description}}catch{}return{id:I.id,title:I.title,type:I.id.startsWith("FC")?"collection":"work",group:I.group,fallbackDescription:I.description}}));w||(x(R.filter(I=>I!==null)),S(!1))}),()=>{w=!0}},[t,i]),p.useEffect(()=>{if(!t.getResourceProgress)return;let w=!1;return t.getResourceProgress().then(C=>{w||W(C)}).catch(()=>{}),()=>{w=!0}},[t]),p.useEffect(()=>{if(!t.getSiteProgress)return;let w=!1;return t.getSiteProgress().then(C=>{w||_(C)}).catch(()=>{}),()=>{w=!0}},[t]);const y=w=>{switch(w){case"work":return"✍️";case"book":return"📖";case"collection":return"📚"}};return e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",height:"100%",padding:"20px",color:"var(--bim-fg, #333)"},children:e.jsxs("div",{style:{width:"100%",maxWidth:"600px",marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",marginBottom:"16px"},children:[e.jsx(Ee,{label:l.home.recommendTab,active:f==="recommend",onClick:()=>c("recommend")}),e.jsx(Ee,{label:l.home.catalogTab,active:f==="catalog",onClick:()=>c("catalog")}),e.jsx(Ee,{label:l.home.siteTab,active:f==="site",onClick:()=>c("site")})]}),f==="recommend"&&e.jsx(eo,{recommended:a,loading:j,onNavigate:n,getIcon:y,t:l}),f==="catalog"&&e.jsx(to,{progress:h,t:l,onNavigate:n}),f==="site"&&e.jsx(oo,{progress:b,t:l,totalWorks:(d==null?void 0:d.works)??0})]})})},Ee=({label:t,active:n,onClick:i})=>e.jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",fontWeight:n?600:400,color:n?"var(--bim-primary, #2563eb)":"var(--bim-desc-fg, #717171)",background:"none",border:"none",borderBottom:n?"2px solid var(--bim-primary, #2563eb)":"2px solid transparent",cursor:"pointer",marginBottom:"-1px"},children:t}),eo=({recommended:t,loading:n,onNavigate:i,getIcon:o,t:r})=>{if(n)return e.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:"var(--bim-desc-fg, #717171)",fontSize:"14px"},children:"..."});if(t.length===0)return null;const l=new Map;for(const d of t){const s=d.group||r.home.recommendedBrowse;l.has(s)||l.set(s,[]),l.get(s).push(d)}return e.jsx(e.Fragment,{children:Array.from(l.entries()).map(([d,s])=>e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:"var(--bim-desc-fg, #717171)",marginBottom:"8px"},children:d}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"8px"},children:s.map(a=>{const x=a.dynasty||a.author?`${a.dynasty?`〔${a.dynasty}〕`:""}${a.author||""}`:a.fallbackDescription;return e.jsxs("a",{href:`/${a.id}`,onClick:g=>{g.metaKey||g.ctrlKey||(g.preventDefault(),i==null||i(a.id))},style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 16px",borderRadius:"8px",border:"1px solid var(--bim-widget-border, #e0e0e0)",cursor:"pointer",background:"var(--bim-input-bg, #fff)",textDecoration:"none",color:"inherit"},children:[e.jsx("span",{style:{fontSize:"20px"},children:o(a.type)}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[a.title,a.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:"var(--bim-desc-fg, #717171)",marginLeft:"4px"},children:a.edition})]}),x&&e.jsx("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x})]})]},a.id)})})]},d))})},to=({progress:t,t:n,onNavigate:i})=>{if(!t)return e.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:"var(--bim-desc-fg, #717171)",fontSize:"14px"},children:"..."});const o=[...t.resources].sort((s,a)=>s.priority-a.priority),r=["in_progress","done","todo"],l={in_progress:n.home.statusInProgress,done:n.home.statusDone,todo:n.home.statusTodo},d={in_progress:"#f59e0b",done:"#10b981",todo:"#9ca3af"};return e.jsx("div",{children:r.map(s=>{const a=o.filter(x=>x.status===s);return a.length===0?null:e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:"var(--bim-desc-fg, #717171)",marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:d[s]}}),l[s]," (",a.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:a.map(x=>e.jsx(no,{item:x,t:n,statusColor:d[s],onNavigate:i},x.id))})]},s)})})},no=({item:t,t:n,statusColor:i,onNavigate:o})=>{const r=t.total>0?Math.round(t.imported/t.total*100):0,l=t.type==="catalog"?n.home.typeCatalog:n.home.typeCollection;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:"1px solid var(--bim-widget-border, #e0e0e0)",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(()=>{const d=t.edition?`${t.name}·${t.edition}`:t.name,s=t.collection_id||t.work_id;return s&&o?e.jsx("a",{href:`/${s}`,onClick:a=>{a.metaKey||a.ctrlKey||(a.preventDefault(),o(s))},style:{color:"inherit",textDecoration:"none",borderBottom:"1px dashed var(--bim-link-fg, #0066cc)"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:d}):t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:d}):d})()}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"4px",background:"var(--bim-widget-border, #e0e0e0)",color:"var(--bim-desc-fg, #717171)",whiteSpace:"nowrap"},children:t.collection_id?n.indexType.collection:t.work_id?n.indexType.work:l})]}),e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",whiteSpace:"nowrap",marginLeft:"8px"},children:t.total>0?Se(n.home.progressFormat,{imported:String(t.imported),total:String(t.total)}):n.home.totalPending})]}),t.total>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:"var(--bim-widget-border, #e0e0e0)",overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${r}%`,borderRadius:"2px",background:i,transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginTop:"4px"},children:t.description})]})},oo=({progress:t,t:n,totalWorks:i})=>{if(!t)return e.jsx("div",{style:{textAlign:"center",padding:"32px 0",color:"var(--bim-desc-fg, #717171)",fontSize:"14px"},children:"..."});const o=[...t.resources].sort((a,x)=>a.priority-x.priority),r=o.filter(a=>a.imported>0),l=o.filter(a=>a.imported===0),d=r.reduce((a,x)=>Math.max(a,x.imported),0),s=i>0?Math.round(d/i*100):0;return e.jsxs("div",{children:[i>0&&e.jsxs("div",{style:{padding:"12px 16px",marginBottom:"16px",borderRadius:"8px",background:"color-mix(in srgb, var(--bim-primary, #2563eb) 6%, transparent)",fontSize:"13px",color:"var(--bim-fg, #333)"},children:[n.home.siteCoverage,": ",e.jsx("strong",{children:d.toLocaleString()})," / ",i.toLocaleString()," ",n.indexType.work," (",s,"%)"]}),r.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:"var(--bim-desc-fg, #717171)",marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:"#10b981"}}),n.home.statusInProgress," (",r.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:r.map(a=>e.jsx(ot,{item:a,t:n,totalWorks:i},a.id))})]}),l.length>0&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"13px",fontWeight:500,color:"var(--bim-desc-fg, #717171)",marginBottom:"8px"},children:[e.jsx("span",{style:{display:"inline-block",width:"8px",height:"8px",borderRadius:"50%",background:"#9ca3af"}}),n.home.statusTodo," (",l.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:l.map(a=>e.jsx(ot,{item:a,t:n,totalWorks:i},a.id))})]})]})},ot=({item:t,t:n,totalWorks:i})=>{const o=i>0?Math.round(t.imported/i*100):0;return e.jsxs("div",{style:{padding:"12px 16px",borderRadius:"8px",border:"1px solid var(--bim-widget-border, #e0e0e0)",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px",minWidth:0},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:t.url?e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"none"},children:t.name}):t.name})}),e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",whiteSpace:"nowrap",marginLeft:"8px"},children:t.imported>0?`${t.imported.toLocaleString()} ${n.indexType.work} (${o}%)`:n.home.statusTodo})]}),t.imported>0&&i>0&&e.jsx("div",{style:{height:"4px",borderRadius:"2px",background:"var(--bim-widget-border, #e0e0e0)",overflow:"hidden",marginBottom:"4px"},children:e.jsx("div",{style:{height:"100%",width:`${o}%`,borderRadius:"2px",background:"#10b981",transition:"width 0.3s ease"}})}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginTop:"4px"},children:t.description})]})},it="(max-width: 768px)";function io(){const[t,n]=p.useState(()=>typeof window>"u"?!1:window.matchMedia(it).matches);return p.useEffect(()=>{const i=window.matchMedia(it),o=r=>n(r.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),t}const ro=({transport:t,hideModeIndicator:n=!0,onEntryClick:i,recommendedIds:o})=>{var H;const r=$(),{convert:l}=F(),d=io(),[s,a]=p.useState(null),[x,g]=p.useState(null),[u,f]=p.useState(!1),[c,j]=p.useState("detail"),[S,h]=p.useState([]),[W,b]=p.useState(!1),[_,y]=p.useState(null),[w,C]=p.useState(!1),v=p.useCallback(async E=>{if(!t.getCollatedEditionIndex){y(null);return}C(!0);try{const z=await t.getCollatedEditionIndex(E);y(z)}catch{y(null)}finally{C(!1)}},[t]),m=p.useCallback(async E=>{if(!t.getCollectionCatalogs&&!t.getCollectionCatalog){h([]);return}b(!0);try{if(t.getCollectionCatalogs){const z=await t.getCollectionCatalogs(E);h(z||[])}else if(t.getCollectionCatalog){const z=await t.getCollectionCatalog(E);h(z?[{resource_id:"",data:z}]:[])}}catch{h([])}finally{b(!1)}},[t]),R=p.useCallback(async E=>{if(i){i(E);return}a(E),g(null),h([]),y(null),j("detail"),f(!0);try{const z=await t.getItem(E.id);z&&(g(z),z.type==="collection"?m(E.id):z.type==="work"&&z.has_collated&&v(E.id))}catch(z){console.error("加载详情失败:",z)}finally{f(!1)}},[t,i,m,v]),I=p.useCallback(async E=>{g(null),h([]),y(null),j("detail"),f(!0);try{const z=await t.getItem(E);z&&(g(z),a({id:E,title:z.title||E,type:z.type||"book"}),z.type==="collection"?m(E):z.type==="work"&&z.has_collated&&v(E))}catch(z){console.error("导航失败:",z)}finally{f(!1)}},[t,m,v]),A=(x==null?void 0:x.type)==="collection"&&(S.length>0||W)||(x==null?void 0:x.type)==="work"&&(_||w),L=d&&(u||x),k=p.useCallback(()=>{a(null),g(null),h([]),y(null),j("detail")},[]),B=e.jsx(e.Fragment,{children:u?e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:e.jsx("span",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"14px"},children:"加载中..."})}):x?e.jsxs(e.Fragment,{children:[A&&e.jsxs("div",{style:{display:"flex",gap:"0",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",padding:d?"0 12px":"0 48px",background:"var(--bim-input-bg, #fff)",flexShrink:0,overflowX:d?"auto":void 0},children:[e.jsx("button",{onClick:()=>j("detail"),style:Ce(c==="detail"),children:r.detailTab.basicInfo}),x.type==="collection"&&W&&S.length===0&&e.jsxs("button",{onClick:()=>{},style:Ce(!1),children:[r.detailTab.catalog,e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]}),x.type==="collection"&&S.map(E=>e.jsx("button",{onClick:()=>j(`catalog:${E.resource_id}`),style:Ce(c===`catalog:${E.resource_id}`),children:E.short_name?`${l(E.short_name)}${r.detailTab.catalogSuffix}`:r.detailTab.collectionCatalog},E.resource_id)),x.type==="work"&&(_||w)&&e.jsxs("button",{onClick:()=>j("collated"),style:Ce(c==="collated"),children:[r.detailTab.collatedEdition,w&&e.jsx("span",{style:{marginLeft:"4px",fontSize:"11px",opacity:.6},children:"..."})]})]}),e.jsx("div",{style:{padding:d?"16px 12px":"32px 48px",maxWidth:"900px",flex:1,overflow:"auto"},children:c==="detail"?e.jsx(He,{data:x,transport:t,onNavigate:I}):c.startsWith("catalog:")?e.jsx(wt,{data:(H=S.find(E=>`catalog:${E.resource_id}`===c))==null?void 0:H.data,onNavigate:I}):c==="collated"?e.jsx(Et,{index:_||void 0,workId:x.id,transport:t,onNavigate:I}):null})]}):e.jsx(Me,{transport:t,onNavigate:I,recommendedIds:o})});return d?e.jsx("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:"var(--bim-bg, #f5f5f5)",color:"var(--bim-fg, #333)"},children:L?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",background:"var(--bim-input-bg, #fff)",flexShrink:0},children:e.jsxs("button",{onClick:k,style:{padding:"4px 12px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"transparent",color:"var(--bim-fg, #333)",cursor:"pointer",fontSize:"13px"},children:["← ",r.detailTab.basicInfo]})}),e.jsx("div",{style:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"},children:B})]}):e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[e.jsx(Ae,{transport:t,onEntryClick:R,hideModeIndicator:n}),!x&&e.jsx(Me,{transport:t,onNavigate:I,recommendedIds:o})]})}):e.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif',background:"var(--bim-bg, #f5f5f5)",color:"var(--bim-fg, #333)"},children:[e.jsx("div",{style:{width:"420px",flexShrink:0,borderRight:"1px solid var(--bim-widget-border, #e0e0e0)",display:"flex",flexDirection:"column",background:"var(--bim-input-bg, #fff)",overflow:"hidden"},children:e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsx(Ae,{transport:t,onEntryClick:R,hideModeIndicator:n})})}),e.jsx("div",{style:{flex:1,overflow:"auto",background:"var(--bim-bg, #f5f5f5)",display:"flex",flexDirection:"column"},children:B})]})};function Ce(t){return{padding:"10px 16px",border:"none",borderBottom:t?"2px solid var(--bim-primary, #0078d4)":"2px solid transparent",background:"transparent",color:t?"var(--bim-primary, #0078d4)":"var(--bim-desc-fg, #717171)",cursor:"pointer",fontSize:"13px",fontWeight:t?600:400}}const lo=({data:t,onNavigate:n,className:i,style:o})=>{var g;const r=$(),{convert:l}=F(),[d,s]=p.useState(((g=t.divisions[0])==null?void 0:g.name)??null),[a,x]=p.useState(null);return e.jsxs("div",{className:i,style:o,children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:600,color:"var(--bim-fg, #1a1a1a)",margin:"0 0 8px"},children:l(t.title)}),t.stats&&e.jsxs("div",{style:{fontSize:"13px",color:"var(--bim-desc-fg, #717171)",display:"flex",gap:"16px"},children:[t.total_volumes!=null&&e.jsxs("span",{children:[r.catalog.totalVolumes," ",e.jsx("strong",{children:t.total_volumes})," ",r.unit.juan]}),t.stats.zhulu!=null&&e.jsxs("span",{children:["著錄 ",e.jsx("strong",{children:t.stats.zhulu})," ",r.unit.bu]}),t.stats.cunmu!=null&&e.jsxs("span",{children:["存目 ",e.jsx("strong",{children:t.stats.cunmu})," ",r.unit.bu]}),t.stats.categories!=null&&e.jsxs("span",{children:[t.stats.categories," 類"]})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.divisions.map(u=>e.jsx(so,{division:u,expanded:d===u.name,onToggle:()=>s(d===u.name?null:u.name),expandedCat:a,onCatToggle:f=>x(a===f?null:f),onNavigate:n},u.name))})]})},so=({division:t,expanded:n,onToggle:i,expandedCat:o,onCatToggle:r,onNavigate:l})=>{const{convert:d}=F(),s=t.categories.reduce((a,x)=>{const g=x.stats||{zhulu:0,cunmu:0};return a+(g.zhulu||0)+(g.cunmu||0)},0);return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:"none",background:n?"color-mix(in srgb, var(--bim-primary, #2563eb) 6%, transparent)":"var(--bim-bg, #f8f8f8)",cursor:"pointer",fontSize:"15px",fontWeight:600,color:"var(--bim-fg, #333)",textAlign:"left"},children:[e.jsx("span",{children:d(t.name)}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:400,color:"var(--bim-desc-fg, #717171)"},children:[t.categories.length," 類 · ",s," 部",e.jsx("span",{style:{marginLeft:"8px"},children:n?"▲":"▼"})]})]}),n&&e.jsx("div",{style:{padding:"4px 0"},children:t.categories.map(a=>{const x=`${t.name}/${a.name}`;return e.jsx(ao,{category:a,expanded:o===x,onToggle:()=>r(x),onNavigate:l},a.name)})})]})},ao=({category:t,expanded:n,onToggle:i,onNavigate:o})=>{var a,x,g,u;const{convert:r}=F(),l=((a=t.books)==null?void 0:a.zhulu)||[],d=((x=t.books)==null?void 0:x.cunmu)||[],s=(((g=t.stats)==null?void 0:g.zhulu)||l.length)+(((u=t.stats)==null?void 0:u.cunmu)||d.length);return e.jsxs("div",{children:[e.jsxs("button",{onClick:i,style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 14px 6px 28px",border:"none",background:n?"var(--bim-input-bg, #fff)":"transparent",cursor:"pointer",fontSize:"13px",color:"var(--bim-fg, #333)",textAlign:"left"},children:[e.jsxs("span",{style:{fontWeight:500},children:[r(t.name),t.volumes&&e.jsxs("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #999)",marginLeft:"8px",fontWeight:400},children:["卷",t.volumes]})]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #999)"},children:[s," 部 ",n?"▲":"▼"]})]}),n&&(l.length>0||d.length>0)&&e.jsxs("div",{style:{padding:"4px 14px 8px 42px"},children:[l.length>0&&e.jsx(rt,{label:"著錄",books:l,onNavigate:o}),d.length>0&&e.jsx(rt,{label:"存目",books:d,onNavigate:o})]})]})},rt=({label:t,books:n,onNavigate:i})=>{const{convert:o}=F(),[r,l]=p.useState(n.length<=20),d=r?n:n.slice(0,10);return e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #999)",marginBottom:"4px",fontWeight:500},children:[t," (",n.length,")"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:d.map((s,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"8px",fontSize:"13px",lineHeight:1.6},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--bim-fg, #333)"},children:s.work_id&&i?e.jsx("a",{href:`/${s.work_id}`,onClick:x=>{x.metaKey||x.ctrlKey||(x.preventDefault(),i(s.work_id))},style:{color:"inherit",textDecoration:"none",borderBottom:"1px dashed var(--bim-link-fg, #0066cc)"},children:o(s.title)}):o(s.title)}),s.volumes&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #999)"},children:o(s.volumes)}),s.author&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #aaa)"},children:o(s.author).slice(0,20)})]},a))}),!r&&e.jsxs("button",{onClick:()=>l(!0),style:{marginTop:"4px",padding:"2px 12px",fontSize:"11px",color:"var(--bim-primary, #0078d4)",background:"transparent",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",cursor:"pointer"},children:["展開全部 ",n.length," 條"]})]})},ie=({title:t,onSave:n,onAskAI:i,extraButtons:o,children:r})=>{const l=$();return e.jsxs("div",{style:{background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"var(--bim-fg, #333)"},children:t}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o,i&&e.jsx("button",{onClick:i,style:po,children:"AI"}),n&&e.jsx("button",{onClick:n,style:co,children:l.action.save})]})]}),r]})},co={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",cursor:"pointer"},po={padding:"4px 12px",fontSize:"12px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"transparent",color:"var(--bim-fg, #333)",cursor:"pointer"},X=({label:t,value:n,onChange:i,placeholder:o,disabled:r})=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{display:"block",fontSize:"11px",color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",fontWeight:500},children:t}),e.jsx("input",{type:"text",value:n,onChange:l=>i(l.target.value),placeholder:o,disabled:r,style:{width:"100%",padding:"6px 8px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]}),ue=({value:t,onChange:n,placeholder:i})=>{const o=p.useRef(null);return p.useEffect(()=>{o.current&&(o.current.style.height="auto",o.current.style.height=`${o.current.scrollHeight}px`)},[t]),e.jsx("textarea",{ref:o,value:t||"",onChange:r=>n(r.target.value),placeholder:i,style:{width:"100%",minHeight:"40px",resize:"none",overflow:"hidden",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"2px",padding:"8px",fontFamily:"inherit",fontSize:"13px",lineHeight:"1.4",outline:"none",boxSizing:"border-box",display:"block"}})},ze=({children:t,color:n,style:i})=>e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:n||"var(--bim-primary-soft, rgba(0,120,212,0.15))",color:n?"#fff":"var(--bim-fg, #333)",...i},children:t});function xo(t){const n=t.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return n?{name:n[1],id:n[2]}:null}const Ie=({value:t,onChange:n,label:i})=>{const[o,r]=p.useState(!1),l=p.useRef(null),d=xo(t||"");return p.useEffect(()=>{o&&l.current&&l.current.focus()},[o]),!o&&d?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:lt,children:i}),e.jsxs("div",{onClick:()=>r(!0),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"2px",background:"var(--bim-input-bg, #fff)",cursor:"pointer",minHeight:"30px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:"var(--bim-fg, #333)"},children:d.name}),e.jsx(ze,{children:d.id})]})]}):e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:lt,children:i}),e.jsx("input",{ref:l,type:"text",value:t||"",onChange:s=>n(s.target.value),onBlur:()=>r(!1),style:{width:"100%",padding:"6px 8px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"2px",fontSize:"13px",boxSizing:"border-box",outline:"none"}})]})},lt={display:"block",fontSize:"11px",color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",fontWeight:500};function uo(t){switch(t){case"url":return"#2196f3";case"bookID":return"#4caf50";default:return"var(--bim-desc-fg, #717171)"}}function go(t){switch(t){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const Lt=({items:t,onChange:n,onOpenEntityPicker:i})=>{const o=$(),[r,l]=p.useState(null),d=()=>{n([...t,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),l(t.length)},s=u=>{n(t.filter((f,c)=>c!==u)),r===u&&l(null)},a=(u,f,c)=>{const j=[...t];j[u]={...j[u],[f]:c},n(j)},x=(u,f)=>{const c=[...t];c[u]={...c[u],type:f,id:"",name:""},n(c),f==="bookID"&&i&&i(j=>{const S=[...t];S[u]={...S[u],id:j.id,name:j.title,type:"bookID"},n(S)})},g=u=>{i&&i(f=>{const c=[...t];c[u]={...c[u],id:f.id,name:f.title,type:"bookID"},n(c)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((u,f)=>e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",cursor:"pointer",gap:"8px"},onClick:()=>l(r===f?null:f),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:r===f?"▼":"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:"var(--bim-fg, #333)"},children:u.name||`${o.editor.sourcePlaceholder} ${f+1}`}),u.type&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:uo(u.type),color:"white",borderRadius:"3px",fontWeight:500},children:go(u.type)}),e.jsx("button",{onClick:c=>{c.stopPropagation(),s(f)},style:{background:"transparent",border:"none",color:"var(--bim-danger, #f44336)",cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:o.editor.deleteThisSource,children:"✕"})]}),r===f&&e.jsx("div",{style:{padding:"12px",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[!u.type&&e.jsxs("div",{children:[e.jsx("label",{style:ce,children:o.editor.selectSourceType}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsxs("button",{onClick:()=>x(f,"bookID"),style:{...st,borderColor:"#4caf50",color:"#4caf50"},children:[e.jsx("span",{style:{fontSize:"18px"},children:"📚"}),e.jsx("span",{children:"Book ID"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.fromExistingBook})]}),e.jsxs("button",{onClick:()=>x(f,"url"),style:{...st,borderColor:"#2196f3",color:"#2196f3"},children:[e.jsx("span",{style:{fontSize:"18px"},children:"🔗"}),e.jsx("span",{children:"URL"}),e.jsx("span",{style:{fontSize:"11px",opacity:.7},children:o.editor.enterUrl})]})]})]}),u.type==="bookID"&&e.jsx(e.Fragment,{children:e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:ce,children:o.action.selectBookOrWork}),e.jsx("button",{onClick:()=>{const c=[...t];c[f]={...c[f],type:"",id:"",name:""},n(c)},style:at,children:o.action.changeType})]}),u.id&&u.name?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 14px",background:"var(--bim-bg, #fff)",border:"1px solid #4caf50",borderRadius:"6px"},children:[e.jsx("span",{style:{color:"#4caf50",fontSize:"16px"},children:"✓"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:u.name}),e.jsx("code",{style:{fontSize:"11px",background:"var(--bim-primary-soft, rgba(0,120,212,0.15))",padding:"2px 6px",borderRadius:"3px"},children:u.id})]}),e.jsx("button",{onClick:()=>g(f),style:{background:"transparent",border:"1px solid var(--bim-widget-border, #e0e0e0)",color:"var(--bim-fg, #333)",cursor:"pointer",padding:"4px 10px",borderRadius:"4px",fontSize:"12px"},children:o.action.reselect})]}):e.jsxs("button",{onClick:()=>g(f),style:{width:"100%",padding:"14px",border:"2px dashed var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",background:"transparent",color:"var(--bim-fg, #333)",cursor:"pointer",fontSize:"13px",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[e.jsx("span",{children:"🔍"}),e.jsx("span",{children:o.action.clickToSelectBookOrWork})]})]})}),u.type==="url"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("label",{style:ce,children:o.label.sourceName}),e.jsx("button",{onClick:()=>{const c=[...t];c[f]={...c[f],type:"",id:"",name:""},n(c)},style:at,children:o.action.changeType})]}),e.jsx("input",{type:"text",value:u.name,onChange:c=>a(f,"name",c.target.value),placeholder:o.editor.sourceNamePlaceholder,style:ge})]}),e.jsxs("div",{children:[e.jsx("label",{style:ce,children:o.label.urlAddress}),e.jsx("input",{type:"text",value:u.id,onChange:c=>a(f,"id",c.target.value),placeholder:"https://...",style:ge})]})]}),u.type&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{borderTop:"1px dashed var(--bim-widget-border, #e0e0e0)",paddingTop:"12px",marginTop:"4px"},children:e.jsx("label",{style:{...ce,opacity:.7},children:o.label.optionalInfo})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:ce,children:o.label.detailsOptional}),e.jsx("input",{type:"text",value:u.details,onChange:c=>a(f,"details",c.target.value),placeholder:o.editor.detailsPlaceholder,style:ge})]}),e.jsxs("div",{children:[e.jsx("label",{style:ce,children:o.label.positionOptional}),e.jsx("input",{type:"text",value:u.position,onChange:c=>a(f,"position",c.target.value),placeholder:"如: 卷三, p.52",style:ge})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:ce,children:o.label.dataVersionOptional}),e.jsx("input",{type:"text",value:u.version,onChange:c=>a(f,"version",c.target.value),placeholder:"如: v1.0, 2024-01",style:ge})]}),e.jsxs("div",{children:[e.jsx("label",{style:ce,children:o.label.processorVersionOptional}),e.jsx("input",{type:"text",value:u.processor_version,onChange:c=>a(f,"processor_version",c.target.value),placeholder:"如: v0.1",style:ge})]})]})]})]})})]},f)),e.jsxs("button",{onClick:d,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",padding:"8px 16px",border:"1px dashed var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"transparent",color:"var(--bim-fg, #333)",cursor:"pointer",fontSize:"13px",opacity:.8},children:[e.jsx("span",{children:"+"}),e.jsx("span",{children:o.action.addSource})]})]})},ce={display:"block",fontSize:"11px",color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",fontWeight:500},ge={width:"100%",padding:"6px 8px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"2px",fontSize:"13px",boxSizing:"border-box"},st={flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",padding:"16px 12px",background:"var(--bim-bg, #fff)",border:"2px solid",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:500,transition:"all 0.2s"},at={background:"transparent",border:"none",color:"var(--bim-link-fg, #0066cc)",cursor:"pointer",fontSize:"11px",padding:0};function Bt(t){if(!t||!t.trim())return[];try{const n=JSON.parse(t);if(Array.isArray(n))return n.map(i=>({id:i.id||"",name:i.name||"",type:i.type||"",details:i.details||"",position:i.position||"",version:i.version||"",processor_version:i.processor_version||""}))}catch{}return[]}function Wt(t){return!t||t.length===0?"":JSON.stringify(t)}const Pt=({entityType:t,entityId:n,entityTitle:i,parentWork:o,parentCollection:r,belongsToWork:l,belongsToCollection:d,childWorks:s,childCollections:a,containedBooks:x,siblingBooks:g,onLinkEntity:u,onUnlinkEntity:f,onViewEntity:c,onCreateAndLink:j,onSaveRelations:S})=>{const h=$();return e.jsxs("div",{style:{background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",padding:"16px",marginBottom:"12px"},children:[e.jsxs("div",{style:{fontSize:"14px",fontWeight:600,marginBottom:"16px",paddingBottom:"8px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:"🔗"}),e.jsx("span",{children:h.section.relations})]}),S&&e.jsx("button",{onClick:S,style:fo,children:h.action.save})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[t==="book"&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{direction:"up",title:h.relation.belongsToWork,entity:l,onView:c,onUnlink:()=>f("workId"),onLink:()=>u("workId","work"),onCreate:()=>j("workId","work",{title:i}),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),e.jsx(ye,{direction:"up",title:h.relation.containedInCollection,entity:d,onView:c,onUnlink:()=>f("collectionId"),onLink:()=>u("collectionId","collection"),onCreate:()=>j("collectionId","collection",{title:i}),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),l&&g&&g.length>0&&e.jsx(fe,{direction:"horizontal",title:`${h.relation.siblingVersions} (${g.length})`,entities:g,onView:c,onAdd:()=>j("siblingBook","book",{workId:l.id}),addLabel:h.relation.addVersionForWork,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore})]}),t==="work"&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{direction:"up",title:h.relation.parentWork,entity:o,onView:c,onUnlink:()=>f("parentWorkId"),onLink:()=>u("parentWorkId","work"),onCreate:()=>j("parentWorkId","work"),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),s&&s.length>0&&e.jsx(fe,{direction:"down",title:`${h.relation.childWorks} (${s.length})`,entities:s,onView:c,onAdd:()=>j("childWork","work",{parentWorkId:n}),addLabel:h.action.addSubWork,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore}),a&&a.length>0&&e.jsx(fe,{direction:"down",title:`${h.relation.collectionImpl} (${a.length})`,entities:a,onView:c,onAdd:()=>j("childCollection","collection",{workId:n}),addLabel:h.action.addCollectionImpl,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore}),e.jsx(fe,{direction:"down",title:`${h.relation.allVersions} (${(x==null?void 0:x.length)??0})`,entities:x||[],onView:c,onAdd:()=>j("childBook","book",{workId:n}),addLabel:h.action.addVersion,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore})]}),t==="collection"&&e.jsxs(e.Fragment,{children:[e.jsx(ye,{direction:"up",title:h.relation.correspondingWork,entity:l,onView:c,onUnlink:()=>f("workId"),onLink:()=>u("workId","work"),onCreate:()=>j("workId","work",{title:i}),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),e.jsx(ye,{direction:"up",title:h.relation.parentCollection,entity:r,onView:c,onUnlink:()=>f("parentCollectionId"),onLink:()=>u("parentCollectionId","collection"),onCreate:()=>j("parentCollectionId","collection"),linkLabel:h.action.linkExisting,createLabel:h.action.createAndLink,notLinkedLabel:h.relation.notLinked,viewLabel:h.action.viewEntity,unlinkLabel:h.action.unlink}),e.jsx(fe,{direction:"down",title:`${h.relation.childCollections} (${(a==null?void 0:a.length)??0})`,entities:a||[],onView:c,onAdd:()=>j("childCollection","collection",{parentCollectionId:n}),addLabel:h.action.addSubCollection,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore}),e.jsx(fe,{direction:"down",title:`${h.relation.containedBooks} (${(x==null?void 0:x.length)??0})`,entities:x||[],onView:c,onAdd:()=>j("childBook","book",{collectionId:n}),addLabel:h.action.addBook,noneLabel:h.relation.none,expandMoreLabel:h.action.expandMore})]})]})]})},ye=({direction:t,title:n,entity:i,onView:o,onUnlink:r,onLink:l,onCreate:d,linkLabel:s,createLabel:a,notLinkedLabel:x,viewLabel:g,unlinkLabel:u})=>{const f=t==="up"?"#2196f3":t==="down"?"#4caf50":"#ff9800",c=t==="up"?"⬆️":t==="down"?"⬇️":"↔️";return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",padding:"10px",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{fontSize:"12px",color:f,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:c}),e.jsx("span",{children:n})]}),i?e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",background:"var(--bim-bg, #fff)",borderRadius:"4px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:$t(i.type)}),e.jsx("span",{style:{fontWeight:500},children:i.title}),e.jsx("span",{style:{fontSize:"11px",opacity:.6},children:i.id})]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx(dt,{onClick:()=>o(i),title:g,children:"👁️"}),e.jsx(dt,{onClick:r,title:u,danger:!0,children:"✕"})]})]}):e.jsx("div",{style:{padding:"8px",background:"var(--bim-bg, #fff)",borderRadius:"4px",color:"var(--bim-desc-fg, #717171)",fontSize:"12px",textAlign:"center"},children:x}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsx(Fe,{onClick:l,children:s}),e.jsx(Fe,{onClick:d,primary:!0,children:a})]})]})},fe=({direction:t,title:n,entities:i,onView:o,onAdd:r,addLabel:l,noneLabel:d,expandMoreLabel:s})=>{const[a,x]=p.useState(!1),g=t==="up"?"#2196f3":t==="down"?"#4caf50":"#ff9800",u=t==="up"?"⬆️":t==="down"?"⬇️":"↔️",f=a?i:i.slice(0,5);return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",padding:"10px",background:"var(--bim-input-bg, #fff)"},children:[e.jsxs("div",{style:{fontSize:"12px",color:g,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:u}),e.jsx("span",{children:n})]}),i.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[f.map(c=>e.jsxs("div",{onClick:()=>o(c),style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 8px",background:"var(--bim-bg, #fff)",borderRadius:"4px",cursor:"pointer",fontSize:"13px"},children:[e.jsx("span",{children:$t(c.type)}),e.jsx("span",{children:c.title})]},c.id)),i.length>5&&!a&&e.jsxs("div",{onClick:()=>x(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:"var(--bim-link-fg, #0066cc)",cursor:"pointer"},children:[s," (",i.length-5,")"]})]}):e.jsx("div",{style:{padding:"8px",background:"var(--bim-bg, #fff)",borderRadius:"4px",color:"var(--bim-desc-fg, #717171)",fontSize:"12px",textAlign:"center"},children:d}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs(Fe,{onClick:r,primary:!0,children:["+ ",l]})})]})},dt=({onClick:t,title:n,danger:i,children:o})=>e.jsx("button",{onClick:r=>{r.stopPropagation(),t()},title:n,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:i?"var(--bim-danger, #f44336)":"inherit",opacity:.7},children:o}),Fe=({onClick:t,primary:n,children:i})=>e.jsx("button",{onClick:t,style:{padding:"4px 10px",fontSize:"11px",border:n?"none":"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:n?"var(--bim-primary, #0078d4)":"transparent",color:n?"var(--bim-primary-fg, #fff)":"inherit",cursor:"pointer"},children:i});function $t(t){switch(t){case"work":return"📜";case"book":return"📖";case"collection":return"📚"}}const fo={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},At=({isOpen:t,entityType:n,title:i,onSelect:o,onCancel:r,onCreate:l,searchResults:d,onSearch:s,isLoading:a,excludeId:x})=>{const[g,u]=p.useState(""),f=x?d.filter(h=>h.id!==x):d;p.useEffect(()=>{t&&(u(""),s(""))},[t]);const c=h=>{u(h),s(h)};if(!t)return null;const j=n==="work"?"作品":n==="book"?"书籍":"丛编",S=n==="work"?"📜":n==="book"?"📖":"📚";return e.jsx("div",{style:ho,children:e.jsxs("div",{style:bo,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:i}),e.jsx("button",{onClick:r,style:mo,children:"✕"})]}),e.jsx("div",{style:{padding:"12px 16px"},children:e.jsx("input",{type:"text",value:g,onChange:h=>c(h.target.value),placeholder:`搜索${j}名称或 ID...`,autoFocus:!0,style:yo})}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:a?e.jsx("div",{style:Le,children:"搜索中..."}):f.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:f.map(h=>e.jsxs("div",{onClick:()=>o(h),style:vo,children:[e.jsx("span",{style:{fontSize:"16px"},children:S}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[h.title,h.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,opacity:.6,marginLeft:"4px"},children:h.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[h.id,h.author&&` · ${h.author}`,h.dynasty&&` · ${h.dynasty}`]})]})]},h.id))}):g?e.jsxs("div",{style:Le,children:["未找到匹配的",j]}):e.jsxs("div",{style:Le,children:["输入关键词搜索",j]})}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsxs("button",{onClick:l,style:jo,children:["创建新",j,"并关联"]})]})]})})},ho={position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},bo={background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",width:"500px",maxWidth:"calc(100vw - 32px)",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 20px rgba(0,0,0,0.3)"},mo={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},yo={width:"100%",padding:"10px 12px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",fontSize:"13px",boxSizing:"border-box"},vo={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:"var(--bim-primary-soft, rgba(0,120,212,0.05))"},Le={padding:"20px",textAlign:"center",color:"var(--bim-desc-fg, #717171)"},jo={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",cursor:"pointer"},ct={work:"作品",book:"书籍",collection:"丛编"},So={work:"📜",book:"📖",collection:"📚"},Mt=({isOpen:t,entityType:n,relationField:i,inheritData:o,onConfirm:r,onCancel:l})=>{const[d,s]=p.useState(""),a=p.useRef(null);p.useEffect(()=>{t&&(s((o==null?void 0:o.title)||""),setTimeout(()=>{var f,c;(f=a.current)==null||f.focus(),(c=a.current)==null||c.select()},100))},[t,o==null?void 0:o.title]);const x=f=>{f.key==="Enter"&&d.trim()?g():f.key==="Escape"&&l()},g=()=>{d.trim()&&r(d.trim(),{...o,title:d.trim()})};if(!t)return null;const u=()=>{switch(i){case"parentWorkId":return"创建父作品";case"workId":return"创建所属作品";case"collectionId":return"创建所属丛编";case"parentCollectionId":return"创建父丛编";case"childWork":return"创建子作品";case"childBook":case"siblingBook":return"创建书籍";case"childCollection":return"创建子丛编";default:return`创建新${ct[n]}`}};return e.jsx("div",{style:ko,onClick:f=>{f.target===f.currentTarget&&l()},children:e.jsxs("div",{style:wo,onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:So[n]}),e.jsx("span",{children:u()})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:"var(--bim-fg, #333)"},children:[n==="work"?"作品名":n==="collection"?"丛编名":"书名",e.jsx("span",{style:{color:"var(--bim-danger, #f44336)",marginLeft:"4px"},children:"*"})]}),e.jsx("input",{ref:a,type:"text",value:d,onChange:f=>s(f.target.value),onKeyDown:x,placeholder:`请输入${ct[n]}名称...`,style:Co})]}),((o==null?void 0:o.author)||(o==null?void 0:o.dynasty))&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",background:"var(--bim-input-bg, #fff)",padding:"8px 12px",borderRadius:"4px",marginBottom:"16px"},children:[e.jsx("div",{style:{marginBottom:"4px",fontWeight:500},children:"将继承以下信息:"}),(o==null?void 0:o.author)&&e.jsxs("div",{children:["作者: ",o.author]}),(o==null?void 0:o.dynasty)&&e.jsxs("div",{children:["朝代/年份: ",o.dynasty]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{onClick:l,style:Io,children:"取消"}),e.jsx("button",{onClick:g,disabled:!d.trim(),style:{...zo,opacity:d.trim()?1:.6,cursor:d.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},ko={position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},wo={background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",padding:"20px",width:"100%",maxWidth:"min(500px, calc(100vw - 32px))",boxShadow:"0 4px 20px rgba(0,0,0,0.3)"},Co={width:"100%",padding:"8px 12px",fontSize:"14px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"4px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",outline:"none",boxSizing:"border-box"},Io={padding:"8px 16px",fontSize:"13px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"transparent",color:"var(--bim-fg, #333)",cursor:"pointer"},zo={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)"};function _o(t){switch(t){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Ft(t){switch(t){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function To(t){switch(t){case"work":return"#4caf50";case"collection":return"#2196f3";case"book":return"#ff9800";default:return"var(--bim-desc-fg, #717171)"}}const Dt=({isOpen:t,title:n,filterType:i="all",recentEntities:o=[],excludeId:r,showCreateButton:l=!1,createButtonText:d,onSelect:s,onCancel:a,onCreate:x,onSearch:g})=>{const[u,f]=p.useState(""),[c,j]=p.useState([]),[S,h]=p.useState(!1),[W,b]=p.useState("recent");p.useEffect(()=>{t&&(f(""),j([]),b(o.length>0?"recent":"search"))},[t,o.length]),p.useEffect(()=>{if(!u.trim()){j([]);return}const m=setTimeout(async()=>{h(!0);try{j(await g(u,i))}catch{j([])}finally{h(!1)}},300);return()=>clearTimeout(m)},[u,i,g]);const _=p.useCallback(m=>{f(m.target.value),m.target.value.trim()&&b("search")},[]),y=p.useCallback(m=>r?m.filter(R=>R.id!==r):m,[r]);if(!t)return null;const w=n||(i==="all"?"选择实体":`选择${Ft(i)}`),C=y(o),v=y(c);return e.jsx("div",{style:Eo,children:e.jsxs("div",{style:Lo,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 20px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600},children:w}),e.jsx("button",{onClick:a,style:Bo,children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px 12px"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",value:u,onChange:_,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Wo}),e.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),S&&e.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),C.length>0&&e.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[e.jsxs(pt,{active:W==="recent",onClick:()=>b("recent"),children:["最近使用 (",C.length,")"]}),e.jsxs(pt,{active:W==="search",onClick:()=>b("search"),children:["搜索结果 ",v.length>0&&`(${v.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:W==="recent"&&C.length>0?e.jsx(xt,{entities:C,onSelect:s}):u.trim()?S?e.jsx(Be,{message:"搜索中..."}):v.length>0?e.jsx(xt,{entities:v,onSelect:s}):e.jsx(Be,{message:"未找到匹配的结果"}):e.jsx(Be,{message:"输入关键词开始搜索"})}),l&&x&&e.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",opacity:.7},children:"找不到?"}),e.jsx("button",{onClick:x,style:Po,children:d||"创建新实体"})]})]})})},pt=({active:t,onClick:n,children:i})=>e.jsx("button",{onClick:n,style:{padding:"10px 16px",border:"none",borderBottom:t?"2px solid var(--bim-primary, #0078d4)":"2px solid transparent",background:"transparent",color:t?"var(--bim-fg, #333)":"var(--bim-desc-fg, #717171)",cursor:"pointer",fontSize:"12px",fontWeight:t?600:400,marginBottom:"-1px"},children:i}),xt=({entities:t,onSelect:n})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map(i=>e.jsx(Ro,{entity:i,onClick:()=>n(i)},i.id))}),Ro=({entity:t,onClick:n})=>{const[i,o]=p.useState(!1);return e.jsxs("div",{onClick:n,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:i?"var(--bim-primary-soft, rgba(0,120,212,0.15))":"var(--bim-primary-soft, rgba(0,120,212,0.05))",transition:"background 0.1s"},children:[e.jsx("span",{style:{fontSize:"18px"},children:_o(t.type)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[t.title,t.edition&&e.jsx("span",{style:{fontSize:"11px",fontWeight:400,color:"var(--bim-desc-fg, #717171)",marginLeft:"4px"},children:t.edition})]}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7,display:"flex",alignItems:"center",gap:"6px",marginTop:"2px"},children:[e.jsx("code",{style:{fontSize:"10px",background:"var(--bim-primary-soft, rgba(0,120,212,0.15))",padding:"1px 4px",borderRadius:"2px"},children:t.id}),t.author&&e.jsx("span",{children:t.author}),t.dynasty&&e.jsx("span",{children:t.dynasty})]})]}),e.jsx("span",{style:{fontSize:"10px",padding:"3px 8px",background:To(t.type),color:"white",borderRadius:"4px",fontWeight:500,flexShrink:0},children:Ft(t.type)})]})},Be=({message:t})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:t}),Eo={position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Lo={background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",width:"550px",maxWidth:"calc(100vw - 32px)",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 20px rgba(0,0,0,0.3)"},Bo={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Wo={width:"100%",padding:"12px 16px",paddingLeft:"40px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"6px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",fontSize:"13px",boxSizing:"border-box"},Po={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",cursor:"pointer"},$o={work:"#4caf50",collection:"#2196f3",book:"#ff9800"},Ao={work:"📜",collection:"📚",book:"📖"},Ht=({data:t,onChange:n,onSave:i,transport:o,onNavigate:r,showDelete:l,onDelete:d,onAskAI:s,renderSectionActions:a,onDownloadResource:x,downloadStatuses:g,relations:u,onRelationsChange:f})=>{var we;const c=$(),[j,S]=p.useState(!1),[h,W]=p.useState("work"),[b,_]=p.useState(""),[y,w]=p.useState(""),[C,v]=p.useState([]),[m,R]=p.useState(!1),[I,A]=p.useState(!1),[L,k]=p.useState("work"),[B,H]=p.useState(""),[E,z]=p.useState(),[D,N]=p.useState(!1),[Y,M]=p.useState(null),[ee,q]=p.useState([]);p.useRef(null);const te=t.type,ne=te==="work",xe=te==="collection",le=te==="book",U=p.useCallback((T,J)=>{n({...t,[T]:J})},[t,n]),he=p.useCallback((T,J)=>{_(T),W(J),w(c.editor.selectToLink+c.indexType[J]),v([]),S(!0)},[c]),ke=p.useCallback(T=>{o!=null&&o.unlinkEntity&&o.unlinkEntity(t.id,T)},[o,t.id]),Te=p.useCallback(T=>{r==null||r(T.id,T.type)},[r]),P=p.useCallback((T,J,de)=>{const Nt={...de,author:(de==null?void 0:de.author)||t.author,dynasty:(de==null?void 0:de.dynasty)||t.dynasty};k(J),H(T),z(Nt),A(!0)},[t.author,t.dynasty]),G=p.useCallback((T,J)=>{o!=null&&o.createAndLink&&o.createAndLink(t.id,B,{type:L,title:T,inheritData:J}),A(!1)},[o,t.id,B,L]),V=p.useCallback(T=>{if(!T.trim()){v([]);return}R(!0),o!=null&&o.searchEntities&&o.searchEntities(T,h).then(J=>{v(J),R(!1)}).catch(()=>{v([]),R(!1)})},[o,h]),Z=p.useCallback(T=>{o!=null&&o.linkEntity&&o.linkEntity(t.id,b,T.id),S(!1)},[o,t.id,b]),se=p.useCallback(()=>{i()},[i]),ae=p.useCallback(T=>{M(()=>T),N(!0),o!=null&&o.getRecentEntities&&o.getRecentEntities().then(q).catch(()=>{})},[o]),K=p.useCallback((T,J)=>o!=null&&o.searchEntities?o.searchEntities(T,J==="all"?void 0:J):Promise.resolve([]),[o]),Oe=p.useCallback(T=>{o!=null&&o.addRecentEntity&&o.addRecentEntity(T),q(J=>[T,...J.filter(de=>de.id!==T.id)].slice(0,10)),Y==null||Y(T),N(!1),M(null)},[o,Y]);return e.jsxs("div",{style:{padding:"16px",maxWidth:"900px",margin:"0 auto"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)",paddingBottom:"16px"},children:e.jsxs("h1",{style:{fontSize:"20px",fontWeight:600,margin:0,display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:Ao[te]}),e.jsx("span",{children:t.title||c.editor.untitled}),e.jsx(ze,{children:t.id}),e.jsx(ze,{color:$o[te],children:c.indexType[te]})]})}),e.jsx(ie,{title:c.section.basicInfo,onSave:i,onAskAI:s?()=>s("基本信息"):void 0,extraButtons:a==null?void 0:a("基本信息"),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsx(Ie,{label:ne?c.editor.workTitle:xe?c.editor.collectionTitle:c.editor.bookTitle,value:t.title,onChange:T=>U("title",T)}),le&&e.jsx(Ie,{label:c.editor.belongsToWork,value:t.workName||"",onChange:T=>U("workName",T)}),e.jsx(X,{label:c.editor.authorLabel,value:t.author||"",onChange:T=>U("author",T)}),e.jsx(X,{label:c.editor.dynastyLabel,value:t.dynasty||"",onChange:T=>U("dynasty",T)}),(le||xe)&&e.jsx(Ie,{label:c.editor.containedIn,value:t.collection||"",onChange:T=>U("collection",T)}),(le||xe)&&e.jsx(X,{label:c.editor.holderLabel,value:t.holder||"",onChange:T=>U("holder",T)}),(le||xe)&&e.jsx(X,{label:le?c.editor.pageLabel:c.editor.volumeLabel,value:t.pages||"",onChange:T=>U("pages",T)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(X,{label:c.editor.firstImageLabel,value:t.firstImage||"",onChange:T=>U("firstImage",T)})})]})}),e.jsx(ie,{title:c.section.description,onSave:i,onAskAI:s?()=>s("介绍"):void 0,children:e.jsx(ue,{value:t.description||"",onChange:T=>U("description",T),placeholder:c.editor.descriptionPlaceholder})}),(((we=t.additional_works)==null?void 0:we.length)||0)>0&&e.jsx(ie,{title:c.section.additionalWorks,onSave:i,children:e.jsx(Mo,{items:t.additional_works||[],onChange:T=>U("additional_works",T)})}),e.jsx(ie,{title:c.section.indexedBy,onSave:i,onAskAI:s?()=>s("收录于"):void 0,children:e.jsx(Fo,{items:t.indexed_by||[],onChange:T=>U("indexed_by",T)})}),e.jsx(ie,{title:c.section.textResources,onSave:i,onAskAI:s?()=>s("资源"):void 0,children:e.jsx(We,{items:t.resources||[],onChange:T=>U("resources",T),onDownload:x,downloadStatuses:g,filterType:"text"})}),e.jsx(ie,{title:c.section.imageResources,onSave:i,children:e.jsx(We,{items:t.resources||[],onChange:T=>U("resources",T),onDownload:x,downloadStatuses:g,filterType:"image"})}),e.jsx(ie,{title:c.section.sources,onSave:i,onAskAI:s?()=>s("资料来源"):void 0,children:e.jsx(Lt,{items:Bt(t.sources||""),onChange:T=>U("sources",Wt(T)),onOpenEntityPicker:ae})}),(le||xe)&&e.jsx(ie,{title:c.section.provenance,onSave:i,onAskAI:s?()=>s("收藏历史"):void 0,children:e.jsx(ue,{value:t.provenance||"",onChange:T=>U("provenance",T),placeholder:c.editor.provenancePlaceholder})}),le&&e.jsx(ie,{title:c.section.otherEditions,onSave:i,onAskAI:s?()=>s("其他版本"):void 0,children:e.jsx(ue,{value:t.otherEditions||"",onChange:T=>U("otherEditions",T),placeholder:c.editor.otherEditionsPlaceholder})}),e.jsx(Pt,{entityType:te,entityId:t.id,entityTitle:t.title,parentWork:u==null?void 0:u.parentWork,parentCollection:u==null?void 0:u.parentCollection,belongsToWork:u==null?void 0:u.belongsToWork,belongsToCollection:u==null?void 0:u.belongsToCollection,childWorks:u==null?void 0:u.childWorks,childCollections:u==null?void 0:u.childCollections,containedBooks:u==null?void 0:u.containedBooks,siblingBooks:u==null?void 0:u.siblingBooks,onLinkEntity:he,onUnlinkEntity:ke,onViewEntity:Te,onCreateAndLink:P,onSaveRelations:se}),l&&d&&e.jsxs("div",{style:{marginTop:"40px",padding:"16px",border:"1px solid rgba(244,67,54,0.13)",background:"rgba(244,67,54,0.03)",borderRadius:"4px"},children:[e.jsx("div",{style:{color:"var(--bim-danger, #f44336)",fontWeight:600,marginBottom:"8px"},children:c.section.dangerZone}),e.jsx("p",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginBottom:"12px"},children:c.editor.dangerZoneDesc}),e.jsx("button",{onClick:d,style:{padding:"8px 16px",fontSize:"13px",border:"1px solid var(--bim-danger, #f44336)",borderRadius:"4px",background:"transparent",color:"var(--bim-danger, #f44336)",cursor:"pointer"},children:c.editor.deleteEntity})]}),e.jsx(At,{isOpen:j,entityType:h,title:y,onSelect:Z,onCancel:()=>S(!1),onCreate:()=>{S(!1),P(b,h)},searchResults:C,onSearch:V,isLoading:m,excludeId:t.id}),e.jsx(Mt,{isOpen:I,entityType:L,relationField:B,inheritData:E,onConfirm:G,onCancel:()=>A(!1)}),e.jsx(Dt,{isOpen:D,title:c.action.selectBookOrWork,filterType:"all",recentEntities:ee,excludeId:t.id,onSelect:Oe,onCancel:()=>{N(!1),M(null)},onSearch:K})]})};function Mo({items:t,onChange:n}){const i=$(),o=(d,s,a)=>{const x=t.map((g,u)=>u===d?{...g,[s]:a}:g);n(x)},r=d=>n(t.filter((s,a)=>a!==d)),l=()=>n([...t,{book_title:""}]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((d,s)=>e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(X,{label:i.editor.bookNameLabel,value:d.book_title,onChange:a=>o(s,"book_title",a)}),e.jsx("div",{style:{width:"100px"},children:e.jsx(X,{label:i.label.juanCount,value:d.n_juan!=null?String(d.n_juan):"",onChange:a=>o(s,"n_juan",a&&parseInt(a,10)||void 0)})}),e.jsx("button",{onClick:()=>r(s),style:{padding:"4px 8px",fontSize:"12px",border:"1px solid #ddd",borderRadius:"4px",background:"transparent",cursor:"pointer",color:"#999",marginTop:"18px"},children:"✕"})]},s)),e.jsx("button",{onClick:l,style:{padding:"6px 12px",fontSize:"12px",border:"1px dashed #ccc",borderRadius:"4px",background:"transparent",cursor:"pointer",color:"#666",alignSelf:"flex-start"},children:i.action.addAdditionalWork})]})}function Fo({items:t,onChange:n}){const i=$(),[o,r]=p.useState(null),l=(a,x,g)=>{const u=t.map((f,c)=>c===a?{...f,[x]:g||void 0}:f);n(u)},d=a=>{n(t.filter((x,g)=>g!==a)),o===a&&r(null)},s=()=>{n([...t,{source:""}]),r(t.length)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((a,x)=>{const g=o===x;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:g?"color-mix(in srgb, var(--bim-primary, #0078d4) 5%, transparent)":"transparent",cursor:"pointer"},onClick:()=>r(g?null:x),children:[e.jsx("span",{style:{fontSize:"10px",color:"var(--bim-desc-fg, #717171)",transition:"transform 0.2s",transform:g?"rotate(90deg)":"none"},children:"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:a.source||i.editor.unnamedSource}),a.source_bid&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)"},children:a.source_bid}),e.jsx("button",{onClick:u=>{u.stopPropagation(),d(x)},style:{padding:"2px 6px",fontSize:"11px",border:"1px solid #ddd",borderRadius:"3px",background:"transparent",cursor:"pointer",color:"#999"},children:"✕"})]}),!g&&(a.title_info||a.author_info)&&e.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:[a.title_info,a.title_info&&a.author_info&&" — ",a.author_info]}),g&&e.jsxs("div",{style:{padding:"8px 12px 12px",display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(X,{label:i.label.sourceName,value:a.source,onChange:u=>l(x,"source",u)}),e.jsx(X,{label:i.label.sourceBid,value:a.source_bid||"",onChange:u=>l(x,"source_bid",u)})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(X,{label:i.label.titleInfo,value:a.title_info||"",onChange:u=>l(x,"title_info",u)}),e.jsx(X,{label:i.label.authorInfo,value:a.author_info||"",onChange:u=>l(x,"author_info",u)})]}),e.jsx(X,{label:i.label.edition,value:a.edition||"",onChange:u=>l(x,"edition",u)}),e.jsx(ue,{value:a.summary||"",onChange:u=>l(x,"summary",u),placeholder:i.editor.summaryPlaceholder}),e.jsx(ue,{value:a.comment||"",onChange:u=>l(x,"comment",u),placeholder:i.editor.commentPlaceholder}),e.jsx(ue,{value:a.additional_comment||"",onChange:u=>l(x,"additional_comment",u),placeholder:i.editor.additionalCommentPlaceholder})]})]},x)}),e.jsx("button",{onClick:s,style:{padding:"6px 12px",fontSize:"12px",border:"1px dashed #ccc",borderRadius:"4px",background:"transparent",cursor:"pointer",color:"#666",alignSelf:"flex-start"},children:i.action.addIndexedBy})]})}function Ot(t){var s,a,x,g,u,f,c;const n=((a=(s=t.authors)==null?void 0:s[0])==null?void 0:a.name)||"",i=((x=t.publication_info)==null?void 0:x.year)||"",o=((g=t.current_location)==null?void 0:g.name)||"",r=(u=t.page_count)!=null&&u.number?String(t.page_count.number):((f=t.page_count)==null?void 0:f.description)||"",l=typeof t.description=="object"&&t.description!==null&&t.description.text||"",d={id:t.id,title:t.title,type:t.type,author:n,dynasty:i,holder:o,pages:r,description:l,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by};if(t.type==="work"){const j=t;if(Array.isArray(j.related_works)){const S=j.related_works.find(h=>h.relation==="part_of");S&&(d.parentWorkId=S.id,d.parentWorkName=S.title)}}if(t.type==="book"){const j=t;d.workId=j.work_id,Array.isArray(j.contained_in)&&j.contained_in.length>0&&(d.collectionId=(c=j.contained_in[0])==null?void 0:c.id)}return d}function Do(t){const n={id:t.id,title:t.title,type:t.type,description:t.description?{text:t.description}:void 0,authors:t.author?[{name:t.author}]:void 0,publication_info:t.dynasty?{year:t.dynasty}:void 0,current_location:t.holder?{name:t.holder}:void 0,page_count:t.pages?{number:parseInt(t.pages)||0,description:t.pages}:void 0,resources:t.resources,additional_works:t.additional_works,indexed_by:t.indexed_by};return t.type==="work"&&t.parentWorkId&&(n.related_works=[{id:t.parentWorkId,title:t.parentWorkName||"",relation:"part_of"}]),t.type==="book"&&(n.work_id=t.workId,t.collectionId&&(n.contained_in=[{id:t.collectionId}])),n}const Ho=t=>{const{data:n,id:i,transport:o,mode:r="view",onModeChange:l,onChange:d,onSave:s,onDelete:a,onNavigate:x,renderLink:g,onAskAI:u,renderSectionActions:f,onDownloadResource:c,downloadStatuses:j,relations:S,onRelationsChange:h,headerExtra:W,className:b,style:_}=t;$();const[y,w]=p.useState(r),C=l?r:y;p.useEffect(()=>{r!==y&&w(r)},[r]);const v=p.useCallback(()=>{const B=C==="view"?"edit":"view";l?l(B):w(B)},[C,l]),[m,R]=p.useState(null);p.useEffect(()=>{i&&o&&o.getItem(i).then(B=>{B&&R(B)})},[i,o]);const I=n||m,A=p.useMemo(()=>I?Ot(I):null,[I]),L=l||!n?e.jsx("button",{onClick:v,style:{padding:"4px 12px",fontSize:"12px",border:"1px solid var(--bim-widget-border, #d0d0d0)",borderRadius:"4px",background:C==="edit"?"var(--bim-accent-bg, #1976d2)":"transparent",color:C==="edit"?"#fff":"var(--bim-fg, #333)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},title:C==="view"?"切换到编辑模式":"切换到查看模式",children:C==="view"?"✏️ 编辑":"👁 查看"}):null,k=e.jsxs(e.Fragment,{children:[L,W]});return!I&&!A?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"#999"},children:"加载中..."}):C==="view"?e.jsx(He,{data:I,transport:o,onNavigate:x?B=>x(B):void 0,renderLink:g,headerExtra:k,className:b,style:_}):A?e.jsxs("div",{className:b,style:_,children:[k&&e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",padding:"8px 0",gap:"8px"},children:k}),e.jsx(Ht,{data:A,onChange:d||(()=>{}),onSave:s||(()=>{}),transport:o,onNavigate:x,showDelete:!!a,onDelete:a,onAskAI:u,renderSectionActions:f,onDownloadResource:c,downloadStatuses:j,relations:S,onRelationsChange:h})]}):e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"#999"},children:"无数据"})},ut=[{value:"bug",label:"反馈错误",icon:"🐛",placeholder:"请描述您发现的错误,包括页面位置和具体内容"},{value:"resource",label:"添加资源",icon:"📚",placeholder:"请提供完整资源链接和简要版本说明"}],Vt=({isOpen:t,onClose:n,onSubmit:i})=>{const[o,r]=p.useState(null),[l,d]=p.useState(""),[s,a]=p.useState("idle"),[x,g]=p.useState(""),u=p.useRef(null);p.useEffect(()=>{t&&(r(null),d(""),a("idle"),g(""))},[t]),p.useEffect(()=>{o&&setTimeout(()=>{var S;return(S=u.current)==null?void 0:S.focus()},100)},[o]),p.useEffect(()=>{if(s==="success"){const S=setTimeout(n,2e3);return()=>clearTimeout(S)}},[s,n]),p.useEffect(()=>{if(!t)return;const S=h=>{h.key==="Escape"&&n()};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,n]);const f=async()=>{if(!(!o||!l.trim())){a("submitting"),g("");try{await i({type:o,content:l.trim()}),a("success")}catch(S){a("error"),g(S instanceof Error?S.message:"提交失败,请稍后重试")}}};if(!t)return null;const c=o&&l.trim()&&s!=="submitting",j=ut.find(S=>S.value===o);return e.jsx("div",{style:Oo,onClick:S=>{S.target===S.currentTarget&&n()},children:e.jsxs("div",{style:Vo,onClick:S=>S.stopPropagation(),children:[e.jsxs("div",{style:No,children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:600},children:"反馈"}),e.jsx("button",{onClick:n,style:Uo,"aria-label":"关闭",children:"✕"})]}),s==="success"?e.jsxs("div",{style:Zo,children:[e.jsx("span",{style:{fontSize:"32px"},children:"✓"}),e.jsx("div",{style:{fontSize:"15px",fontWeight:500},children:"感谢您的反馈!"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:ut.map(S=>e.jsxs("button",{onClick:()=>r(S.value),style:{...Yo,...o===S.value?Go:{}},children:[e.jsx("span",{children:S.icon})," ",S.label]},S.value))}),e.jsx("textarea",{ref:u,value:l,onChange:S=>d(S.target.value),placeholder:(j==null?void 0:j.placeholder)||"请先选择反馈类型",maxLength:2e3,disabled:!o||s==="submitting",style:{...Ko,opacity:o?1:.6}}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",textAlign:"right",marginBottom:"12px"},children:[l.length," / 2000"]}),s==="error"&&e.jsx("div",{style:Xo,children:x}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{onClick:f,disabled:!c,style:{...Jo,opacity:c?1:.6,cursor:c?"pointer":"not-allowed"},children:s==="submitting"?"提交中...":"提交反馈"})})]})]})})},Oo={position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},Vo={background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",padding:"20px",width:"450px",maxWidth:"90vw",boxShadow:"0 4px 20px rgba(0,0,0,0.3)"},No={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},Uo={background:"none",border:"none",fontSize:"16px",cursor:"pointer",color:"var(--bim-desc-fg, #999)",padding:"4px 8px",borderRadius:"4px"},Yo={flex:1,padding:"10px 12px",fontSize:"13px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-fg, #333)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",transition:"border-color 0.2s, background 0.2s"},Go={borderColor:"var(--bim-primary, #0078d4)",background:"var(--bim-list-active-bg, #e8f0fe)",color:"var(--bim-primary, #0078d4)",fontWeight:500},Ko={width:"100%",minHeight:"120px",padding:"10px 12px",fontSize:"14px",lineHeight:"1.6",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"6px",background:"var(--bim-input-bg, #fff)",color:"var(--bim-input-fg, #333)",outline:"none",boxSizing:"border-box",resize:"vertical",fontFamily:"inherit"},Jo={padding:"8px 24px",fontSize:"14px",border:"none",borderRadius:"6px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",fontWeight:500},Zo={display:"flex",flexDirection:"column",alignItems:"center",gap:"12px",padding:"32px 0",color:"var(--bim-success, #4caf50)"},Xo={fontSize:"13px",color:"var(--bim-danger, #f44336)",padding:"8px 12px",background:"rgba(244,67,54,0.08)",borderRadius:"4px",marginBottom:"12px"},qo=({onSubmit:t,position:n={bottom:24,right:24}})=>{const[i,o]=p.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>o(!0),style:{...Qo,bottom:n.bottom,right:n.right},"aria-label":"反馈",title:"反馈",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),e.jsx(Vt,{isOpen:i,onClose:()=>o(!1),onSubmit:t})]})},Qo={position:"fixed",zIndex:900,width:"48px",height:"48px",borderRadius:"50%",border:"none",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 8px rgba(0,0,0,0.25)",transition:"transform 0.2s, box-shadow 0.2s"},ei={bug:{label:"错误反馈",color:"var(--bim-danger, #f44336)"},resource:{label:"资源建议",color:"var(--bim-primary, #0078d4)"}},ti={pending:{label:"待处理",color:"var(--bim-warning, #ff9800)"},resolved:{label:"已处理",color:"var(--bim-success, #4caf50)"}};function ni(t){try{const n=new Date(t),i=o=>String(o).padStart(2,"0");return`${n.getFullYear()}-${i(n.getMonth()+1)}-${i(n.getDate())} ${i(n.getHours())}:${i(n.getMinutes())}`}catch{return t}}const oi=({items:t,loading:n})=>n?e.jsx("div",{style:gt,children:"加载中..."}):t.length===0?e.jsx("div",{style:gt,children:"暂无反馈"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:t.map(i=>{const o=ei[i.type],r=ti[i.status];return e.jsxs("div",{style:ii,children:[e.jsxs("div",{style:ri,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{...ft,background:o.color},children:o.label}),e.jsx("span",{style:{...ft,background:r.color},children:r.label})]}),e.jsx("span",{style:li,children:ni(i.createdAt)})]}),e.jsx("div",{style:si,children:i.content}),i.reply&&e.jsxs("div",{style:ai,children:[e.jsx("div",{style:di,children:"回复"}),e.jsx("div",{children:i.reply})]})]},i.id)})}),gt={textAlign:"center",padding:"40px 0",color:"var(--bim-desc-fg, #999)",fontSize:"14px"},ii={background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",padding:"16px"},ri={display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",flexWrap:"wrap",gap:"8px"},ft={fontSize:"12px",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontWeight:500},li={fontSize:"12px",color:"var(--bim-desc-fg, #999)"},si={fontSize:"14px",lineHeight:"1.6",color:"var(--bim-fg, #333)",whiteSpace:"pre-wrap"},ai={marginTop:"12px",padding:"10px 12px",background:"var(--bim-input-bg, #f5f5f5)",borderRadius:"6px",fontSize:"13px",lineHeight:"1.6",color:"var(--bim-fg, #333)"},di={fontSize:"12px",fontWeight:600,marginBottom:"4px",color:"var(--bim-primary, #0078d4)"},ci=({style:t})=>{const n=p.useContext(je);if(!n)return null;const{locale:i,setLocale:o}=n,r=i==="zh-Hant",l=()=>o(r?"zh-Hans":"zh-Hant");return e.jsxs("button",{type:"button",onClick:l,title:r?"切换为简体":"切換為繁體",style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"4px 10px",fontSize:"13px",fontWeight:500,lineHeight:1,border:"1px solid var(--bim-border, #ddd)",borderRadius:"4px",background:"var(--bim-bg, #fff)",color:"var(--bim-fg, #333)",cursor:"pointer",userSelect:"none",...t},children:[e.jsx("span",{style:{color:r?"var(--bim-primary, #0078d4)":void 0,fontWeight:r?700:400},children:"繁"}),e.jsx("span",{style:{opacity:.3},children:"/"}),e.jsx("span",{style:{color:r?void 0:"var(--bim-primary, #0078d4)",fontWeight:r?400:700},children:"简"})]})};exports.BidLink=O.BidLink;exports.BookIndexError=O.BookIndexError;exports.BookIndexManager=O.BookIndexManager;exports.BookIndexStorage=O.BookIndexStorage;exports.BundleStorage=O.BundleStorage;exports.ConfigError=O.ConfigError;exports.GithubStorage=O.GithubStorage;exports.IdGenerationError=O.IdGenerationError;exports.IdGenerator=O.IdGenerator;exports.LocalStorage=O.LocalStorage;exports.MigrationError=O.MigrationError;exports.StorageError=O.StorageError;exports.base58Decode=O.base58Decode;exports.base58Encode=O.base58Encode;exports.buildId=O.buildId;exports.decodeIdString=O.decodeIdString;exports.extractIdFromUrl=O.extractIdFromUrl;exports.extractStatus=O.extractStatus;exports.extractType=O.extractType;exports.normalizeCatalog=O.normalizeCatalog;exports.parseId=O.parseId;exports.validateResource=O.validateResource;exports.Badge=ze;exports.CollatedEdition=Et;exports.CollectionCatalog=wt;exports.CreateEntityDialog=Mt;exports.EntityPickerDialog=Dt;exports.EntitySelector=At;exports.FeedbackButton=qo;exports.FeedbackDialog=Vt;exports.FeedbackList=oi;exports.FormInput=X;exports.FormTextArea=ue;exports.HomePage=Me;exports.IndexApp=ro;exports.IndexBrowser=Ae;exports.IndexDetail=He;exports.IndexEditor=Ht;exports.IndexView=Ho;exports.LocaleContext=je;exports.LocaleProvider=nn;exports.LocaleToggle=ci;exports.ModeIndicator=yt;exports.RelationPanel=Pt;exports.ResourceEditor=We;exports.ResourceList=De;exports.SearchInput=vt;exports.Section=ie;exports.SmartBidInput=Ie;exports.SourceEditor=Lt;exports.WorkCatalog=lo;exports.detailToEditor=Ot;exports.editorToDetail=Do;exports.formatTemplate=Se;exports.parseSourceString=Bt;exports.stringifySources=Wt;exports.useConvert=F;exports.useT=$;