book-index-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +843 -0
- package/dist/index.js +3029 -0
- package/dist/transport-entry-BJ9qfFuT.js +763 -0
- package/dist/transport-entry-xDGrIF89.cjs +1 -0
- package/dist/transport.cjs +1 -0
- package/dist/transport.d.ts +504 -0
- package/dist/transport.js +10 -0
- package/package.json +62 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("./transport-entry-xDGrIF89.cjs"),e=require("react/jsx-runtime"),g=require("react");class lt{constructor(i){this.pendingRequests=new Map,this.requestId=0,this.handleMessage=n=>{const{requestId:r,command:a,data:p,error:u}=n.data||{};if(r&&this.pendingRequests.has(r)){const{resolve:l,reject:f}=this.pendingRequests.get(r);this.pendingRequests.delete(r),u?f(new Error(u)):l(p)}},this.vscode=i||window.acquireVsCodeApi(),window.addEventListener("message",this.handleMessage)}request(i,n={}){return new Promise((r,a)=>{const p=`req_${++this.requestId}`;this.pendingRequests.set(p,{resolve:r,reject:a}),this.vscode.postMessage({command:i,requestId:p,...n}),setTimeout(()=>{this.pendingRequests.has(p)&&(this.pendingRequests.delete(p),a(new Error(`Request ${i} timed out`)))},3e4)})}async loadEntries(i,n){return this.request("loadEntries",{type:i,...n})}async search(i,n,r){return this.request("search",{query:i,type:n,...r})}async getItem(i){return this.request("getItem",{id:i})}async saveItem(i){return this.request("saveItem",{metadata:i})}async deleteItem(i){return this.request("deleteItem",{id:i})}async generateId(i,n){return this.request("generateId",{type:i,status:n})}dispose(){window.removeEventListener("message",this.handleMessage),this.pendingRequests.clear()}}function ot(t){if(!t)return"";try{const i=new URL(t).hostname,n={"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(n[i])return n[i];const r=i.split(".");return r.length>=2?r[r.length-2]:i}catch{return""}}const ye=[{value:"text",label:"文字"},{value:"image",label:"图片"},{value:"text+image",label:"文字+图片"},{value:"physical",label:"实体"}],dt=[{value:"catalog",label:"目录式"},{value:"search",label:"搜索式"}];function at(){return{id:"",name:"",url:"",type:"text",details:""}}const Le=({items:t,onChange:i,onDownload:n,downloadStatuses:r,filterType:a})=>{const[p,u]=g.useState(null),l=a?t.map((x,d)=>({item:x,originalIndex:d})).filter(({item:x})=>x.type===a):t.map((x,d)=>({item:x,originalIndex:d})),f=()=>{const x=at();a&&(x.type=a),i([...t,x]),u(t.length)},y=x=>{i(t.filter((d,m)=>m!==x)),u(null)},s=(x,d,m)=>{const v=[...t];if(v[x]={...v[x],[d]:m},d==="url"&&!v[x].id){const S=ot(m);S&&(v[x].id=S)}i(v)},o=(x,d)=>{const m=d.trim()?d.split(/[,,、]/).map(v=>v.trim()).filter(Boolean):void 0;s(x,"structure",m)},c=(x,d,m)=>{const S=t[x].coverage||{level:1,ranges:""};d==="level"?S.level=parseInt(m)||1:S.ranges=m,s(x,"coverage",S.ranges?S:void 0)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[l.map(({item:x,originalIndex:d})=>{var m,v,S,_;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:()=>u(p===d?null:d),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:p===d?"▼":"▶"}),e.jsx("span",{style:{fontSize:"11px",padding:"1px 6px",borderRadius:"3px",background:ct(x.type),color:"#fff"},children:((m=ye.find(j=>j.value===x.type))==null?void 0:m.label)||x.type}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:x.name||`资源 ${d+1}`}),x.id&&e.jsx("span",{style:{fontSize:"11px",opacity:.5},children:x.id}),x.url&&e.jsx("a",{href:x.url,target:"_blank",rel:"noopener noreferrer",onClick:j=>j.stopPropagation(),style:{fontSize:"12px",opacity:.7},children:"🔗"}),n&&x.url&&pt(d,r==null?void 0:r[d],n),e.jsx("button",{onClick:j=>{j.stopPropagation(),y(d)},style:{background:"transparent",border:"none",color:"var(--bim-danger, #f44336)",cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:"删除此资源",children:"✕"})]}),p===d&&e.jsxs("div",{style:{padding:"12px",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[(x.type==="image"||x.type==="text+image")&&x.url&&xt(x),e.jsxs("div",{style:{display:"grid",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:le,children:[e.jsx("span",{style:oe,children:"类型"}),e.jsx("select",{value:x.type,onChange:j=>s(d,"type",j.target.value),style:{...U,flex:1},children:ye.map(j=>e.jsx("option",{value:j.value,children:j.label},j.value))})]}),e.jsxs("label",{style:le,children:[e.jsx("span",{style:oe,children:"根类型"}),e.jsx("select",{value:x.root_type||"catalog",onChange:j=>s(d,"root_type",j.target.value),style:{...U,flex:1},children:dt.map(j=>e.jsx("option",{value:j.value,children:j.label},j.value))})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("input",{type:"text",value:x.id,onChange:j=>s(d,"id",j.target.value),placeholder:"ID (自动从URL提取)",style:{...U,width:"140px",flexShrink:0}}),e.jsx("input",{type:"text",value:x.name,onChange:j=>s(d,"name",j.target.value),placeholder:"资源名称",style:{...U,flex:1}})]}),e.jsx("input",{type:"text",value:x.url,onChange:j=>s(d,"url",j.target.value),placeholder:"资源链接 (URL)",style:U}),e.jsx("input",{type:"text",value:((v=x.structure)==null?void 0:v.join("、"))||"",onChange:j=>o(d,j.target.value),placeholder:"层级结构 (如: 册、卷)",style:U}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("label",{style:le,children:[e.jsx("span",{style:oe,children:"覆盖层级"}),e.jsx("input",{type:"number",min:1,value:((S=x.coverage)==null?void 0:S.level)??"",onChange:j=>c(d,"level",j.target.value),placeholder:"1",style:{...U,width:"60px"}})]}),e.jsxs("label",{style:{...le,flex:1},children:[e.jsx("span",{style:oe,children:"覆盖范围"}),e.jsx("input",{type:"text",value:((_=x.coverage)==null?void 0:_.ranges)||"",onChange:j=>c(d,"ranges",j.target.value),placeholder:"如: 2,3,5-8",style:{...U,flex:1}})]})]}),e.jsx("textarea",{value:x.details||"",onChange:j=>s(d,"details",j.target.value),placeholder:"详细说明",style:{...U,minHeight:"60px",resize:"vertical"}})]})]})]},d)}),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:"添加资源"})]})]})};function ct(t){switch(t){case"text":return"#2196f3";case"image":return"#ff9800";case"text+image":return"#9c27b0";case"physical":return"#795548"}}function pt(t,i,n){const r=(i==null?void 0:i.status)==="downloading",a=(i==null?void 0:i.status)==="completed";return e.jsx("button",{onClick:p=>{p.stopPropagation(),r||n(t,"")},disabled:r,style:{background:"transparent",border:"none",color:a?"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:a?"下载完成":r?`下载中 ${(i==null?void 0:i.progress)||0}%`:"下载此资源",children:a?"✓":r?"⏳":"⬇"})}function xt(t){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:n=>{n.target.style.display="none"}})}):e.jsx("div",{style:{padding:"12px",background:"#00000010",borderRadius:"4px",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:"图片资源链接"})})}const U={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"},le={display:"flex",alignItems:"center",gap:"6px"},oe={fontSize:"12px",color:"var(--bim-desc-fg, #717171)",whiteSpace:"nowrap"},gt={text:"文字资源",image:"图片资源","text+image":"文字+图片资源",physical:"实体资源"},me={text:"#2196f3",image:"#ff9800","text+image":"#9c27b0",physical:"#795548"},ut=["text","image","text+image","physical"],$e=({items:t,groupByType:i=!0})=>{if(!t||t.length===0)return e.jsx("div",{style:{padding:"16px",color:"var(--bim-desc-fg, #717171)",fontSize:"13px",textAlign:"center"},children:"暂无资源信息"});if(!i)return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:t.map((r,a)=>e.jsx(ve,{item:r},r.id||a))});const n=ut.map(r=>({type:r,items:t.filter(a=>a.type===r)})).filter(r=>r.items.length>0);return e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:n.map(({type:r,items:a})=>e.jsxs("div",{children:[e.jsxs("h4",{style:{margin:"0 0 8px",fontSize:"13px",fontWeight:600,color:me[r],display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{display:"inline-block",width:"4px",height:"14px",borderRadius:"2px",background:me[r]}}),gt[r],e.jsxs("span",{style:{fontWeight:400,opacity:.6},children:["(",a.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:a.map((p,u)=>e.jsx(ve,{item:p},p.id||u))})]},r))})},ve=({item:t})=>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:t.details||t.structure?"6px":"0"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:500,color:"var(--bim-fg, #333)"},children:t.name}),t.url&&e.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--bim-link-fg, #0066cc)",textDecoration:"none"},children:"访问 →"})]}),(t.details||t.structure||t.coverage)&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",display:"flex",gap:"12px",flexWrap:"wrap"},children:[t.details&&e.jsx("span",{children:t.details}),t.structure&&e.jsxs("span",{children:["层级: ",t.structure.join(" → ")]}),t.coverage&&e.jsxs("span",{children:["覆盖: L",t.coverage.level," ",t.coverage.ranges]})]})]}),Pe=({indexSource:t,syncConfig:i,variant:n="index-browser",onSwitchMode:r,onToggleDraft:a,onConfigurePath:p,onSelectFolder:u})=>{const l=t==="local",f=(i==null?void 0:i.isDraft)??!0,y=(i==null?void 0:i.repoPath)||"",s=y?y.split(/[/\\]/).pop()||y:"",o={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:d=>d.currentTarget.style.opacity="0.8",onMouseOut:d=>d.currentTarget.style.opacity="1"},x=e.jsxs("div",{onClick:a,title:`点击切换到 ${f?"official":"draft"} 仓库`,style:{...o,background:f?"var(--bim-warning, #ff9800)":"var(--bim-success, #4caf50)",color:"white"},...c,children:[e.jsx("span",{children:f?"📝":"📚"}),e.jsx("span",{children:f?"draft":"official"})]});return n==="index-browser"?l?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[x,e.jsxs("div",{onClick:r,title:"点击切换到同步模式",style:o,...c,children:[e.jsx("span",{children:"📁"}),e.jsx("span",{children:"本地模式"}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsxs("div",{onClick:u,title:y||"选择本地文件夹",style:{...o,paddingLeft:"8px",paddingRight:"8px"},...c,children:[e.jsx("span",{children:"📂"}),s&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:s})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[x,e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("div",{onClick:r,title:"点击切换到本地模式",style:o,...c,children:[e.jsx("span",{children:"🌐"}),e.jsx("span",{children:"同步模式:"}),e.jsx("span",{style:{opacity:.6,marginLeft:"4px"},children:"⇄"})]}),e.jsx("div",{onClick:p,title:s||"配置同步路径",style:{...o,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:r,title:l?"点击切换到 GitHub 同步模式":"点击切换到本地模式",style:o,...c,children:[e.jsx("span",{children:l?"📁":"🌐"}),e.jsx("span",{children:l?"本地模式":"GitHub 同步"}),e.jsx("span",{style:{opacity:.6},children:"⇄"})]}),l&&e.jsxs("div",{onClick:u,title:y||"选择本地文件夹",style:{...o,paddingLeft:"8px",paddingRight:"8px",minWidth:y?"100px":"auto",justifyContent:"space-between"},...c,children:[e.jsx("span",{children:"📂"}),s&&e.jsx("span",{style:{fontSize:"11px",opacity:.9},children:s})]}),!l&&s&&e.jsxs("div",{style:{...o,background:"#2196f3",color:"white",cursor:"default"},title:y,children:[e.jsx("span",{children:"📂"}),e.jsx("span",{style:{fontSize:"11px"},children:s})]})]})},je=50,Fe="bim-recent-entries",Se=50;function ue(){try{const t=localStorage.getItem(Fe);return t?JSON.parse(t):[]}catch{return[]}}function ft(t){try{const i=ue().filter(n=>n.id!==t.id);i.unshift(t),i.length>Se&&(i.length=Se),localStorage.setItem(Fe,JSON.stringify(i))}catch{}}const ke=[{type:"work",icon:"✍️",name:"作品"},{type:"book",icon:"📖",name:"书籍"},{type:"collection",icon:"📚",name:"丛编"}],He=({transport:t,indexSource:i="local",syncConfig:n,onEntryClick:r,onNewEntry:a,onSwitchMode:p,onToggleDraft:u,onConfigurePath:l,onSelectFolder:f,hideModeIndicator:y})=>{const[s,o]=g.useState("work"),[c,x]=g.useState(""),[d,m]=g.useState([]),[v,S]=g.useState(!1),[_,j]=g.useState(null),[I,P]=g.useState(""),[R,W]=g.useState(0),[w,F]=g.useState(1),[H,E]=g.useState("title"),[z,ee]=g.useState("asc"),[J,te]=g.useState(!0),[ne,ce]=g.useState(ue),G=g.useCallback(h=>({page:h,pageSize:je,sortBy:H,sortOrder:z}),[H,z]),V=g.useCallback(async(h,C)=>{S(!0),P("");try{const k=await t.loadEntries(h,G(C));m(k.entries),W(k.total),F(k.page)}catch(k){P(k instanceof Error?k.message:String(k)),m([])}finally{S(!1)}},[t,G]),N=g.useCallback(async(h=1)=>{if(!c.trim()){te(!0),m([]),W(0);return}te(!1),S(!0),P("");try{const C=await t.search(c,s,G(h));m(C.entries),W(C.total),F(C.page)}catch(C){P(C instanceof Error?C.message:String(C)),m([])}finally{S(!1)}},[t,c,s,G]);g.useEffect(()=>{F(1),J||V(s,1)},[s,H,z,V,J]);const se=h=>{F(h),N(h)},A=Math.ceil(R/je),q=h=>{j(h.id),ft(h),ce(ue()),r==null||r(h)},$=h=>ke.find(C=>C.type===h);return e.jsxs("div",{className:"bim-browser-container",children:[e.jsx("header",{style:{padding:"16px 20px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{margin:0,fontSize:"18px",color:"var(--bim-fg, #333)"},children:"索引浏览器"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:"浏览和管理古籍元数据"})]}),!y&&e.jsx(Pe,{variant:"index-browser",indexSource:i,syncConfig:n,onSwitchMode:p,onToggleDraft:u,onConfigurePath:l,onSelectFolder:f})]})}),e.jsx("div",{style:{display:"flex",gap:"4px",padding:"8px 20px"},children:ke.map(({type:h,icon:C,name:k})=>e.jsxs("button",{onClick:()=>o(h),style:{display:"flex",alignItems:"center",gap:"4px",padding:"6px 14px",border:"none",borderRadius:"6px",background:s===h?"var(--bim-primary, #0078d4)":"transparent",color:s===h?"var(--bim-primary-fg, #fff)":"var(--bim-fg, #333)",cursor:"pointer",fontSize:"13px",fontWeight:s===h?600:400},children:[e.jsx("span",{children:C}),e.jsx("span",{children:k})]},h))}),e.jsxs("div",{style:{display:"flex",gap:"8px",padding:"8px 20px",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",flex:1,gap:"4px"},children:[e.jsx("input",{type:"text",placeholder:`搜索${$(s).name}...`,value:c,onChange:h=>{x(h.target.value),h.target.value.trim()||(te(!0),m([]),W(0))},onKeyDown:h=>h.key==="Enter"&&N(),style:{flex:1,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"}}),e.jsx("button",{onClick:()=>N(),style:{padding:"6px 14px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",cursor:"pointer",fontSize:"13px"},children:"搜索"})]}),a&&e.jsxs("button",{onClick:()=>a(s),style:{padding:"6px 14px",border:"1px solid var(--bim-primary, #0078d4)",borderRadius:"4px",background:"transparent",color:"var(--bim-primary, #0078d4)",cursor:"pointer",fontSize:"13px"},children:["+ 新建",$(s).name]})]}),e.jsxs("div",{style:{padding:"0 20px 20px",flex:1,display:"flex",flexDirection:"column"},children:[v?e.jsx("div",{style:{textAlign:"center",padding:"40px",color:"var(--bim-desc-fg, #717171)"},children:"加载中..."}):I?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:I})]}):J?e.jsx("div",{style:{flex:1},children:ne.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 0",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:"最近浏览"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:ne.map(h=>e.jsxs("div",{onClick:()=>q(h),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",borderRadius:"6px",border:_===h.id?"1px solid var(--bim-primary, #0078d4)":"1px solid var(--bim-widget-border, #e0e0e0)",cursor:"pointer",background:"var(--bim-input-bg, #fff)"},children:[e.jsx("span",{style:{fontSize:"18px"},children:$(h.type).icon}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:"var(--bim-fg, #333)"},children:h.title}),(h.dynasty||h.author)&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginTop:"2px"},children:[h.dynasty&&e.jsxs("span",{children:["〔",h.dynasty,"〕"]}),h.author&&e.jsx("span",{children:h.author}),h.role&&h.role!=="author"&&e.jsxs("span",{children:[" ",h.role]})]})]}),e.jsx("span",{style:{opacity:.4},children:"→"})]},h.id))})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px"},children:$(s).icon}),e.jsxs("h3",{style:{margin:"0 0 8px",color:"var(--bim-fg, #333)"},children:["输入关键词搜索",$(s).name]}),e.jsx("p",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:"浏览过的条目会显示在这里"})]})}):d.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:[e.jsxs("span",{children:["共 ",R," 条",$(s).name,A>1&&` (第 ${w}/${A} 页)`]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{children:"排序:"}),e.jsxs("select",{value:H,onChange:h=>E(h.target.value),style:{fontSize:"12px",border:"1px solid var(--bim-input-border, #ccc)",borderRadius:"3px",padding:"2px 4px"},children:[e.jsx("option",{value:"title",children:"标题"}),e.jsx("option",{value:"id",children:"ID"}),e.jsx("option",{value:"author",children:"作者"}),e.jsx("option",{value:"dynasty",children:"朝代"})]}),e.jsx("button",{onClick:()=>ee(h=>h==="asc"?"desc":"asc"),style:{border:"none",background:"transparent",cursor:"pointer",fontSize:"12px"},title:z==="asc"?"升序":"降序",children:z==="asc"?"↑":"↓"})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:d.map(h=>e.jsxs("div",{onClick:()=>q(h),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",borderRadius:"6px",border:_===h.id?"1px solid var(--bim-primary, #0078d4)":"1px solid var(--bim-widget-border, #e0e0e0)",cursor:"pointer",background:"var(--bim-input-bg, #fff)"},children:[e.jsx("span",{style:{fontSize:"18px"},children:$(h.type).icon}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:"var(--bim-fg, #333)"},children:h.title}),(h.dynasty||h.author)&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginTop:"2px"},children:[h.dynasty&&e.jsxs("span",{children:["〔",h.dynasty,"〕"]}),h.author&&e.jsx("span",{children:h.author}),h.role&&h.role!=="author"&&e.jsxs("span",{children:[" ",h.role]})]})]}),e.jsx("span",{style:{opacity:.4},children:"→"})]},h.id))}),A>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"12px",padding:"16px 0"},children:[e.jsx("button",{disabled:w<=1,onClick:()=>se(w-1),style:we(w<=1),children:"上一页"}),e.jsxs("span",{style:{fontSize:"13px",color:"var(--bim-desc-fg, #717171)"},children:[w," / ",A]}),e.jsx("button",{disabled:w>=A,onClick:()=>se(w+1),style:we(w>=A),children:"下一页"})]})]}):e.jsxs("div",{style:{textAlign:"center",padding:"40px"},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px"},children:$(s).icon}),e.jsxs("h3",{style:{margin:"0 0 8px",color:"var(--bim-fg, #333)"},children:["未找到匹配的",$(s).name]}),e.jsx("p",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:"尝试其他搜索关键词"})]}),!v&&!I&&R>0&&!J&&e.jsxs("div",{style:{textAlign:"center",padding:"16px 0 4px",fontSize:"12px",color:"var(--bim-desc-fg, #717171)",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)",marginTop:"auto"},children:["共收录 ",R," 部",$(s).name]})]})]})};function we(t){return{padding:"6px 14px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"transparent",color:"var(--bim-fg, #333)",cursor:t?"default":"pointer",fontSize:"13px",opacity:t?.4:1}}const ht={book:"书籍",work:"作品",collection:"丛编"},bt=["〇","一","二","三","四","五","六","七","八","九"],Ce=["","十","百","千"];function yt(t){if(t<=0)return"";if(t>=1e4)return String(t);const i=String(t),n=i.length;let r="",a=!1;for(let p=0;p<n;p++){const u=parseInt(i[p]),l=n-1-p;u===0?a=!0:(a&&r&&(r+="〇"),a=!1,u===1&&l===1&&p===0?r+=Ce[l]:r+=bt[u]+Ce[l])}return r}function mt({type:t}){const 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:ht[t]})}function vt({isDraft:t}){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?"草稿":"正式"})}function jt({id:t}){const[i,n]=g.useState(!1),r=()=>{navigator.clipboard.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!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:"ID:"}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:"12px",color:"var(--bim-fg, #333)"},children:t}),e.jsx("span",{onClick:r,title:i?"已复制":"复制 ID",style:{cursor:"pointer",fontSize:"13px",opacity:i?1:.5,transition:"opacity 0.15s"},onMouseEnter:a=>a.currentTarget.style.opacity="1",onMouseLeave:a=>a.currentTarget.style.opacity=i?"1":"0.5",children:i?"✓":"⧉"})]})}function X({children:t,extra:i}){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}}),i]})}function M({label:t,children:i}){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:i})]})}function St({authors:t,type:i}){return e.jsx("div",{style:{fontSize:"14px",color:"var(--bim-fg, #333)",lineHeight:1.6},children:t.map((n,r)=>e.jsxs("span",{children:[r>0&&e.jsx("span",{style:{color:"var(--bim-desc-fg, #aaa)",margin:"0 4px"},children:"·"}),n.dynasty&&e.jsxs("span",{style:{color:"var(--bim-desc-fg, #717171)",fontSize:"12px"},children:["〔",n.dynasty,"〕"]}),e.jsx("span",{style:{fontWeight:500},children:n.name}),n.role&&e.jsxs("span",{style:{color:"var(--bim-desc-fg, #999)",fontSize:"12px",marginLeft:"2px"},children:[" ",n.role]})]},r))})}function ie({id:t,label:i,onNavigate:n,renderLink:r}){return r?e.jsx(e.Fragment,{children:r(t,i)}):n?e.jsx("span",{onClick:()=>n(t),style:{color:"var(--bim-link-fg, #0066cc)",cursor:"pointer",textDecoration:"none",borderBottom:"1px dashed var(--bim-link-fg, #0066cc)",paddingBottom:"1px"},onMouseEnter:a=>a.currentTarget.style.borderBottomStyle="solid",onMouseLeave:a=>a.currentTarget.style.borderBottomStyle="dashed",children:i||t}):e.jsx("span",{children:i||t})}function kt({id:t,title:i,type:n,isDraft:r,authors:a,volumeText:p,meta:u,headerExtra:l}){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:[i,p&&e.jsx("span",{style:{fontSize:"15px",fontWeight:400,color:"var(--bim-desc-fg, #717171)",marginLeft:"8px"},children:p})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0,paddingTop:"4px"},children:[e.jsx(mt,{type:n}),e.jsx(vt,{isDraft:r}),e.jsx(jt,{id:t}),l]})]}),a&&a.length>0&&e.jsx(St,{authors:a,type:n}),u.length>0&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"12px",marginTop:"6px"},children:u})]})}function wt({items:t,onNavigate:i,renderLink:n}){if(!t.length)return null;const[r,a]=g.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(X,{children:"收录"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map((p,u)=>{const l=r===u;return e.jsxs("div",{style:{border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"6px",overflow:"hidden",transition:"box-shadow 0.15s",...l?{boxShadow:"0 1px 4px rgba(0,0,0,0.06)"}:{}},children:[e.jsxs("div",{onClick:()=>a(l?null:u),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:l?"rotate(90deg)":"none",display:"inline-block",flexShrink:0},children:"▶"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--bim-fg, #333)"},children:p.source}),!l&&p.title_info&&e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.title_info}),p.source_bid&&e.jsx("span",{onClick:f=>f.stopPropagation(),style:{fontSize:"11px",marginLeft:"auto",flexShrink:0},children:e.jsx(ie,{id:p.source_bid,label:"查看 →",onNavigate:i,renderLink:n})})]}),l&&e.jsxs("div",{style:{padding:"4px 12px 12px",borderTop:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[(p.title_info||p.author_info||p.version)&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px 16px",padding:"8px 0",fontSize:"13px"},children:[p.title_info&&e.jsx(M,{label:"题名",children:p.title_info}),p.author_info&&e.jsx(M,{label:"著者",children:p.author_info}),p.version&&e.jsx(M,{label:"版本",children:p.version})]}),p.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:"提要"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #333)",lineHeight:1.9,margin:0,textAlign:"justify"},children:p.summary})]}),p.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:"按語"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:p.comment})]}),p.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:"附按"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--bim-fg, #555)",lineHeight:1.8,margin:0,fontStyle:"italic"},children:p.additional_comment})]})]})]},u)})})]})}function Ct({items:t}){return t.length?e.jsxs(e.Fragment,{children:[e.jsx(X,{children:"附录"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:t.map((i,n)=>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.book_title,"》",i.n_juan!=null&&e.jsxs("span",{style:{color:"var(--bim-desc-fg, #999)",fontSize:"12px"},children:[i.n_juan,"卷"]})]},n))})]}):null}function zt({items:t}){return t.length?e.jsxs(e.Fragment,{children:[e.jsx(X,{children:"流转历史"}),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((i,n)=>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.name}),i.description&&e.jsx("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #999)",marginLeft:"8px"},children:i.description})]},n))]})]}):null}function It({items:t}){return t.length?e.jsxs(e.Fragment,{children:[e.jsx(X,{children:"历史沿革"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map((i,n)=>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]},n))})]}):null}function pe({title:t,ids:i,onNavigate:n,renderLink:r}){return i.length?e.jsxs(e.Fragment,{children:[e.jsxs(X,{children:[t,e.jsxs("span",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #aaa)",fontWeight:400},children:["(",i.length,")"]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:i.map(a=>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(ie,{id:a,onNavigate:n,renderLink:r})},a))})]}):null}const Oe=({data:t,id:i,transport:n,onNavigate:r,renderLink:a,headerExtra:p,className:u,style:l})=>{var P,R,W,w,F,H;const[f,y]=g.useState(null),[s,o]=g.useState(!1),[c,x]=g.useState(null),d=t||f;if(g.useEffect(()=>{if(t||!i||!n)return;let E=!1;return o(!0),x(null),n.getItem(i).then(z=>{E||(z?y(z):x("未找到该条目"))}).catch(z=>{E||x(z instanceof Error?z.message:"加载失败")}).finally(()=>{E||o(!1)}),()=>{E=!0}},[t,i,n]),s)return e.jsx("div",{className:u,style:{...l,padding:"24px"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[180,260,160].map((E,z)=>e.jsx("div",{style:{height:z===1?"32px":"16px",width:`${E}px`,background:"var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",opacity:.4}},z))})});if(c)return e.jsx("div",{className:u,style:{...l,padding:"24px",textAlign:"center",color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:c});if(!d)return null;const m=d.type==="book"?d:null,v=d.type==="collection"?d:null,S=d.type==="work"?d:null;let _=!1;try{_=B.extractStatus(d.id)==="draft"}catch{}let j="";(P=d.volume_count)!=null&&P.number?j=yt(d.volume_count.number)+"卷":(R=d.volume_count)!=null&&R.description&&(j=d.volume_count.description);const I=[];return(W=d.publication_info)!=null&&W.year&&I.push(e.jsx(M,{label:"年代",children:d.publication_info.year},"year")),(w=d.current_location)!=null&&w.name&&I.push(e.jsx(M,{label:"现藏",children:d.current_location.name},"loc")),(F=d.page_count)!=null&&F.description&&I.push(e.jsx(M,{label:"页",children:d.page_count.description},"page")),m!=null&&m.contained_in&&m.contained_in.length>0&&I.push(e.jsx(M,{label:"收录于",children:m.contained_in.join("、")},"in")),m!=null&&m.work_id&&I.push(e.jsx(M,{label:"所属作品",children:e.jsx(ie,{id:m.work_id,onNavigate:r,renderLink:a})},"work")),S!=null&&S.parent_work&&I.push(e.jsx(M,{label:"上级作品",children:e.jsx(ie,{id:S.parent_work.id,label:S.parent_work.title,onNavigate:r,renderLink:a})},"pw")),S!=null&&S.parent_works&&S.parent_works.length>0&&!S.parent_work&&I.push(e.jsx(M,{label:"上级作品",children:S.parent_works.map((E,z)=>e.jsxs("span",{children:[z>0&&"、",e.jsx(ie,{id:E,onNavigate:r,renderLink:a})]},E))},"pws")),e.jsxs("div",{className:u,style:l,children:[e.jsx(kt,{id:d.id,title:d.title,type:d.type,isDraft:_,authors:d.authors,volumeText:j,meta:I,headerExtra:p}),((H=d.description)==null?void 0:H.text)&&e.jsx("p",{style:{fontSize:"14px",color:"var(--bim-fg, #444)",lineHeight:1.9,margin:"0 0 4px",textAlign:"justify"},children:d.description.text}),d.additional_titles&&d.additional_titles.length>0&&e.jsx(Ct,{items:d.additional_titles}),d.indexed_by&&d.indexed_by.length>0&&e.jsx(wt,{items:d.indexed_by,onNavigate:r,renderLink:a}),d.resources&&d.resources.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(X,{children:"资源"}),e.jsx($e,{items:d.resources,groupByType:!0})]}),(m==null?void 0:m.location_history)&&m.location_history.length>0&&e.jsx(zt,{items:m.location_history}),(v==null?void 0:v.history)&&v.history.length>0&&e.jsx(It,{items:v.history}),(m==null?void 0:m.related_books)&&m.related_books.length>0&&e.jsx(pe,{title:"相关版本",ids:m.related_books,onNavigate:r,renderLink:a}),(v==null?void 0:v.books)&&v.books.length>0&&e.jsx(pe,{title:"收录书籍",ids:v.books,onNavigate:r,renderLink:a}),(S==null?void 0:S.books)&&S.books.length>0&&e.jsx(pe,{title:"相关版本",ids:S.books,onNavigate:r,renderLink:a})]})},Rt=({transport:t,hideModeIndicator:i=!0,onEntryClick:n})=>{const[r,a]=g.useState(null),[p,u]=g.useState(null),[l,f]=g.useState(!1),y=g.useCallback(async o=>{if(n){n(o);return}a(o),u(null),f(!0);try{const c=await t.getItem(o.id);c&&u(c)}catch(c){console.error("加载详情失败:",c)}finally{f(!1)}},[t,n]),s=g.useCallback(async o=>{u(null),f(!0);try{const c=await t.getItem(o);c&&(u(c),a({id:o,title:c.title||o,type:c.type||"book"}))}catch(c){console.error("导航失败:",c)}finally{f(!1)}},[t]);return 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(He,{transport:t,onEntryClick:y,hideModeIndicator:i})})}),e.jsx("div",{style:{flex:1,overflow:"auto",background:"var(--bim-bg, #f5f5f5)"},children:l?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:"加载中..."})}):p?e.jsx("div",{style:{padding:"32px 48px",maxWidth:"900px"},children:e.jsx(Oe,{data:p,transport:t,onNavigate:s})}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",height:"100%",color:"var(--bim-desc-fg, #717171)"},children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"📚"}),e.jsx("h2",{style:{margin:"0 0 8px",fontWeight:400,fontSize:"18px"},children:"古籍索引浏览器"}),e.jsx("p",{style:{margin:0,fontSize:"14px"},children:"从左侧选择一个条目查看详情"})]})})]})},D=({title:t,onSave:i,onAskAI:n,extraButtons:r,children:a})=>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:[r,n&&e.jsx("button",{onClick:n,style:Et,children:"AI"}),i&&e.jsx("button",{onClick:i,style:_t,children:"保存"})]})]}),a]}),_t={padding:"4px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",cursor:"pointer"},Et={padding:"4px 12px",fontSize:"12px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"transparent",color:"var(--bim-fg, #333)",cursor:"pointer"},L=({label:t,value:i,onChange:n,placeholder:r,disabled:a})=>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:i,onChange:p=>n(p.target.value),placeholder:r,disabled:a,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"}})]}),Q=({value:t,onChange:i,placeholder:n})=>{const r=g.useRef(null);return g.useEffect(()=>{r.current&&(r.current.style.height="auto",r.current.style.height=`${r.current.scrollHeight}px`)},[t]),e.jsx("textarea",{ref:r,value:t||"",onChange:a=>i(a.target.value),placeholder:n,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"}})},ae=({children:t,color:i,style:n})=>e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",background:i||"var(--bim-primary-soft, rgba(0,120,212,0.15))",color:i?"#fff":"var(--bim-fg, #333)",...n},children:t});function Tt(t){const i=t.match(/^\[(.+?)\]\(bid:(.+?)\)$/);return i?{name:i[1],id:i[2]}:null}const de=({value:t,onChange:i,label:n})=>{const[r,a]=g.useState(!1),p=g.useRef(null),u=Tt(t||"");return g.useEffect(()=>{r&&p.current&&p.current.focus()},[r]),!r&&u?e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:ze,children:n}),e.jsxs("div",{onClick:()=>a(!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:u.name}),e.jsx(ae,{children:u.id})]})]}):e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:ze,children:n}),e.jsx("input",{ref:p,type:"text",value:t||"",onChange:l=>i(l.target.value),onBlur:()=>a(!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"}})]})},ze={display:"block",fontSize:"11px",color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",fontWeight:500};function Bt(t){switch(t){case"url":return"#2196f3";case"bookID":return"#4caf50";default:return"var(--bim-desc-fg, #717171)"}}function Wt(t){switch(t){case"url":return"URL";case"bookID":return"Book ID";default:return"未选择"}}const qe=({items:t,onChange:i,onOpenEntityPicker:n})=>{const[r,a]=g.useState(null),p=()=>{i([...t,{id:"",name:"",type:"",details:"",position:"",version:"",processor_version:""}]),a(t.length)},u=s=>{i(t.filter((o,c)=>c!==s)),r===s&&a(null)},l=(s,o,c)=>{const x=[...t];x[s]={...x[s],[o]:c},i(x)},f=(s,o)=>{const c=[...t];c[s]={...c[s],type:o,id:"",name:""},i(c),o==="bookID"&&n&&n(x=>{const d=[...t];d[s]={...d[s],id:x.id,name:x.title,type:"bookID"},i(d)})},y=s=>{n&&n(o=>{const c=[...t];c[s]={...c[s],id:o.id,name:o.title,type:"bookID"},i(c)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((s,o)=>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:()=>a(r===o?null:o),children:[e.jsx("span",{style:{opacity:.6,fontSize:"12px"},children:r===o?"▼":"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500,color:"var(--bim-fg, #333)"},children:s.name||`来源 ${o+1}`}),s.type&&e.jsx("span",{style:{fontSize:"11px",padding:"2px 8px",background:Bt(s.type),color:"white",borderRadius:"3px",fontWeight:500},children:Wt(s.type)}),e.jsx("button",{onClick:c=>{c.stopPropagation(),u(o)},style:{background:"transparent",border:"none",color:"var(--bim-danger, #f44336)",cursor:"pointer",padding:"2px 6px",fontSize:"14px"},title:"删除此来源",children:"✕"})]}),r===o&&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:[!s.type&&e.jsxs("div",{children:[e.jsx("label",{style:Y,children:"选择来源类型"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsxs("button",{onClick:()=>f(o,"bookID"),style:{...Ie,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:"从现有书籍选择"})]}),e.jsxs("button",{onClick:()=>f(o,"url"),style:{...Ie,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:"输入网址链接"})]})]})]}),s.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:Y,children:"选择书籍/作品"}),e.jsx("button",{onClick:()=>{const c=[...t];c[o]={...c[o],type:"",id:"",name:""},i(c)},style:Re,children:"更换类型"})]}),s.id&&s.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:s.name}),e.jsx("code",{style:{fontSize:"11px",background:"var(--bim-primary-soft, rgba(0,120,212,0.15))",padding:"2px 6px",borderRadius:"3px"},children:s.id})]}),e.jsx("button",{onClick:()=>y(o),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:"重选"})]}):e.jsxs("button",{onClick:()=>y(o),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:"点击选择书籍/作品"})]})]})}),s.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:Y,children:"来源名称"}),e.jsx("button",{onClick:()=>{const c=[...t];c[o]={...c[o],type:"",id:"",name:""},i(c)},style:Re,children:"更换类型"})]}),e.jsx("input",{type:"text",value:s.name,onChange:c=>l(o,"name",c.target.value),placeholder:"如: 维基文库、中国基本古籍库",style:K})]}),e.jsxs("div",{children:[e.jsx("label",{style:Y,children:"URL 地址"}),e.jsx("input",{type:"text",value:s.id,onChange:c=>l(o,"id",c.target.value),placeholder:"https://...",style:K})]})]}),s.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:{...Y,opacity:.7},children:"可选信息"})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsxs("label",{style:Y,children:["详细说明 ",e.jsx("span",{style:{opacity:.5},children:"(可选)"})]}),e.jsx("input",{type:"text",value:s.details,onChange:c=>l(o,"details",c.target.value),placeholder:"补充说明",style:K})]}),e.jsxs("div",{children:[e.jsxs("label",{style:Y,children:["位置/页码 ",e.jsx("span",{style:{opacity:.5},children:"(可选)"})]}),e.jsx("input",{type:"text",value:s.position,onChange:c=>l(o,"position",c.target.value),placeholder:"如: 卷三, p.52",style:K})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsxs("div",{children:[e.jsxs("label",{style:Y,children:["数据版本 ",e.jsx("span",{style:{opacity:.5},children:"(可选)"})]}),e.jsx("input",{type:"text",value:s.version,onChange:c=>l(o,"version",c.target.value),placeholder:"如: v1.0, 2024-01",style:K})]}),e.jsxs("div",{children:[e.jsxs("label",{style:Y,children:["处理器版本 ",e.jsx("span",{style:{opacity:.5},children:"(可选)"})]}),e.jsx("input",{type:"text",value:s.processor_version,onChange:c=>l(o,"processor_version",c.target.value),placeholder:"如: v0.1",style:K})]})]})]})]})})]},o)),e.jsxs("button",{onClick:p,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:"添加来源"})]})]})},Y={display:"block",fontSize:"11px",color:"var(--bim-desc-fg, #717171)",marginBottom:"4px",fontWeight:500},K={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"},Ie={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"},Re={background:"transparent",border:"none",color:"var(--bim-link-fg, #0066cc)",cursor:"pointer",fontSize:"11px",padding:0};function Me(t){if(!t||!t.trim())return[];try{const i=JSON.parse(t);if(Array.isArray(i))return i.map(n=>({id:n.id||"",name:n.name||"",type:n.type||"",details:n.details||"",position:n.position||"",version:n.version||"",processor_version:n.processor_version||""}))}catch{}return[]}function Ae(t){return!t||t.length===0?"":JSON.stringify(t)}const Ue=({entityType:t,entityId:i,entityTitle:n,parentWork:r,parentCollection:a,belongsToWork:p,belongsToCollection:u,childWorks:l,childCollections:f,containedBooks:y,siblingBooks:s,onLinkEntity:o,onUnlinkEntity:c,onViewEntity:x,onCreateAndLink:d,onSaveRelations:m})=>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:"关联关系"})]}),m&&e.jsx("button",{onClick:m,style:Lt,children:"保存"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[t==="book"&&e.jsxs(e.Fragment,{children:[e.jsx(re,{direction:"up",title:"所属作品 (Work)",entity:p,onView:x,onUnlink:()=>c("workId"),onLink:()=>o("workId","work"),onCreate:()=>d("workId","work",{title:n})}),e.jsx(re,{direction:"up",title:"收录于丛编 (Collection)",entity:u,onView:x,onUnlink:()=>c("collectionId"),onLink:()=>o("collectionId","collection"),onCreate:()=>d("collectionId","collection",{title:n})}),p&&s&&s.length>0&&e.jsx(Z,{direction:"horizontal",title:`同作品其他版本 (${s.length})`,entities:s,onView:x,onAdd:()=>d("siblingBook","book",{workId:p.id}),addLabel:"为此作品添加新版本"})]}),t==="work"&&e.jsxs(e.Fragment,{children:[e.jsx(re,{direction:"up",title:"父作品 (Parent Work)",entity:r,onView:x,onUnlink:()=>c("parentWorkId"),onLink:()=>o("parentWorkId","work"),onCreate:()=>d("parentWorkId","work")}),l&&l.length>0&&e.jsx(Z,{direction:"down",title:`子作品 (${l.length})`,entities:l,onView:x,onAdd:()=>d("childWork","work",{parentWorkId:i}),addLabel:"添加子作品"}),f&&f.length>0&&e.jsx(Z,{direction:"down",title:`丛编实现 (${f.length})`,entities:f,onView:x,onAdd:()=>d("childCollection","collection",{workId:i}),addLabel:"添加丛编实现"}),e.jsx(Z,{direction:"down",title:`所有版本 (${(y==null?void 0:y.length)??0})`,entities:y||[],onView:x,onAdd:()=>d("childBook","book",{workId:i}),addLabel:"添加新版本"})]}),t==="collection"&&e.jsxs(e.Fragment,{children:[e.jsx(re,{direction:"up",title:"对应作品 (Work)",entity:p,onView:x,onUnlink:()=>c("workId"),onLink:()=>o("workId","work"),onCreate:()=>d("workId","work",{title:n})}),e.jsx(re,{direction:"up",title:"父丛编 (Parent Collection)",entity:a,onView:x,onUnlink:()=>c("parentCollectionId"),onLink:()=>o("parentCollectionId","collection"),onCreate:()=>d("parentCollectionId","collection")}),e.jsx(Z,{direction:"down",title:`子丛编 (${(f==null?void 0:f.length)??0})`,entities:f||[],onView:x,onAdd:()=>d("childCollection","collection",{parentCollectionId:i}),addLabel:"添加子丛编"}),e.jsx(Z,{direction:"down",title:`包含书籍 (${(y==null?void 0:y.length)??0})`,entities:y||[],onView:x,onAdd:()=>d("childBook","book",{collectionId:i}),addLabel:"添加书籍"})]})]})]}),re=({direction:t,title:i,entity:n,onView:r,onUnlink:a,onLink:p,onCreate:u})=>{const l=t==="up"?"#2196f3":t==="down"?"#4caf50":"#ff9800",f=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:l,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:f}),e.jsx("span",{children:i})]}),n?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:Ye(n.type)}),e.jsx("span",{style:{fontWeight:500},children:n.title}),e.jsx("span",{style:{fontSize:"11px",opacity:.6},children:n.id})]}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[e.jsx(_e,{onClick:()=>r(n),title:"查看",children:"👁️"}),e.jsx(_e,{onClick:a,title:"解除关联",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:"(未关联)"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:[e.jsx(fe,{onClick:p,children:"+ 关联现有"}),e.jsx(fe,{onClick:u,primary:!0,children:"+ 创建并关联"})]})]})},Z=({direction:t,title:i,entities:n,onView:r,onAdd:a,addLabel:p})=>{const[u,l]=g.useState(!1),f=t==="up"?"#2196f3":t==="down"?"#4caf50":"#ff9800",y=t==="up"?"⬆️":t==="down"?"⬇️":"↔️",s=u?n:n.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:f,fontWeight:500,marginBottom:"8px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx("span",{children:y}),e.jsx("span",{children:i})]}),n.length>0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[s.map(o=>e.jsxs("div",{onClick:()=>r(o),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:Ye(o.type)}),e.jsx("span",{children:o.title})]},o.id)),n.length>5&&!u&&e.jsxs("div",{onClick:()=>l(!0),style:{padding:"4px 8px",textAlign:"center",fontSize:"12px",color:"var(--bim-link-fg, #0066cc)",cursor:"pointer"},children:["展开更多 (",n.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:"(暂无)"}),e.jsx("div",{style:{marginTop:"8px"},children:e.jsxs(fe,{onClick:a,primary:!0,children:["+ ",p]})})]})},_e=({onClick:t,title:i,danger:n,children:r})=>e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},title:i,style:{background:"transparent",border:"none",cursor:"pointer",padding:"2px 6px",fontSize:"12px",color:n?"var(--bim-danger, #f44336)":"inherit",opacity:.7},children:r}),fe=({onClick:t,primary:i,children:n})=>e.jsx("button",{onClick:t,style:{padding:"4px 10px",fontSize:"11px",border:i?"none":"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:i?"var(--bim-primary, #0078d4)":"transparent",color:i?"var(--bim-primary-fg, #fff)":"inherit",cursor:"pointer"},children:n});function Ye(t){switch(t){case"work":return"📜";case"book":return"📖";case"collection":return"📚"}}const Lt={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"},De=({isOpen:t,entityType:i,title:n,onSelect:r,onCancel:a,onCreate:p,searchResults:u,onSearch:l,isLoading:f,excludeId:y})=>{const[s,o]=g.useState(""),c=y?u.filter(v=>v.id!==y):u;g.useEffect(()=>{t&&(o(""),l(""))},[t]);const x=v=>{o(v),l(v)};if(!t)return null;const d=i==="work"?"作品":i==="book"?"书籍":"丛编",m=i==="work"?"📜":i==="book"?"📖":"📚";return e.jsx("div",{style:$t,children:e.jsxs("div",{style:Pt,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:n}),e.jsx("button",{onClick:a,style:Ft,children:"✕"})]}),e.jsx("div",{style:{padding:"12px 16px"},children:e.jsx("input",{type:"text",value:s,onChange:v=>x(v.target.value),placeholder:`搜索${d}名称或 ID...`,autoFocus:!0,style:Ht})}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"0 16px"},children:f?e.jsx("div",{style:xe,children:"搜索中..."}):c.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:c.map(v=>e.jsxs("div",{onClick:()=>r(v),style:Ot,children:[e.jsx("span",{style:{fontSize:"16px"},children:m}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:v.title}),e.jsxs("div",{style:{fontSize:"11px",opacity:.7},children:[v.id,v.author&&` · ${v.author}`,v.dynasty&&` · ${v.dynasty}`]})]})]},v.id))}):s?e.jsxs("div",{style:xe,children:["未找到匹配的",d]}):e.jsxs("div",{style:xe,children:["输入关键词搜索",d]})}),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:p,style:qt,children:["创建新",d,"并关联"]})]})]})})},$t={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},Pt={background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",width:"500px",maxHeight:"70vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 20px rgba(0,0,0,0.3)"},Ft={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit"},Ht={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"},Ot={display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",borderRadius:"4px",cursor:"pointer",background:"var(--bim-primary-soft, rgba(0,120,212,0.05))"},xe={padding:"20px",textAlign:"center",color:"var(--bim-desc-fg, #717171)"},qt={padding:"6px 12px",fontSize:"12px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",cursor:"pointer"},Ee={work:"作品",book:"书籍",collection:"丛编"},Mt={work:"📜",book:"📖",collection:"📚"},Ge=({isOpen:t,entityType:i,relationField:n,inheritData:r,onConfirm:a,onCancel:p})=>{const[u,l]=g.useState(""),f=g.useRef(null);g.useEffect(()=>{t&&(l((r==null?void 0:r.title)||""),setTimeout(()=>{var c,x;(c=f.current)==null||c.focus(),(x=f.current)==null||x.select()},100))},[t,r==null?void 0:r.title]);const y=c=>{c.key==="Enter"&&u.trim()?s():c.key==="Escape"&&p()},s=()=>{u.trim()&&a(u.trim(),{...r,title:u.trim()})};if(!t)return null;const o=()=>{switch(n){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`创建新${Ee[i]}`}};return e.jsx("div",{style:At,onClick:c=>{c.target===c.currentTarget&&p()},children:e.jsxs("div",{style:Ut,onClick:c=>c.stopPropagation(),children:[e.jsxs("div",{style:{fontSize:"16px",fontWeight:600,marginBottom:"16px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{children:Mt[i]}),e.jsx("span",{children:o()})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"13px",marginBottom:"6px",color:"var(--bim-fg, #333)"},children:[i==="work"?"作品名":i==="collection"?"丛编名":"书名",e.jsx("span",{style:{color:"var(--bim-danger, #f44336)",marginLeft:"4px"},children:"*"})]}),e.jsx("input",{ref:f,type:"text",value:u,onChange:c=>l(c.target.value),onKeyDown:y,placeholder:`请输入${Ee[i]}名称...`,style:Yt})]}),((r==null?void 0:r.author)||(r==null?void 0:r.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:"将继承以下信息:"}),(r==null?void 0:r.author)&&e.jsxs("div",{children:["作者: ",r.author]}),(r==null?void 0:r.dynasty)&&e.jsxs("div",{children:["朝代/年份: ",r.dynasty]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[e.jsx("button",{onClick:p,style:Dt,children:"取消"}),e.jsx("button",{onClick:s,disabled:!u.trim(),style:{...Gt,opacity:u.trim()?1:.6,cursor:u.trim()?"pointer":"not-allowed"},children:"创建"})]})]})})},At={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},Ut={background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",padding:"20px",minWidth:"400px",maxWidth:"500px",boxShadow:"0 4px 20px rgba(0,0,0,0.3)"},Yt={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"},Dt={padding:"8px 16px",fontSize:"13px",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"4px",background:"transparent",color:"var(--bim-fg, #333)",cursor:"pointer"},Gt={padding:"8px 16px",fontSize:"13px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)"};function Vt(t){switch(t){case"work":return"📜";case"collection":return"📚";case"book":return"📖";default:return"📄"}}function Ve(t){switch(t){case"work":return"作品";case"collection":return"丛编";case"book":return"书籍";default:return"实体"}}function Nt(t){switch(t){case"work":return"#4caf50";case"collection":return"#2196f3";case"book":return"#ff9800";default:return"var(--bim-desc-fg, #717171)"}}const Ne=({isOpen:t,title:i,filterType:n="all",recentEntities:r=[],excludeId:a,showCreateButton:p=!1,createButtonText:u,onSelect:l,onCancel:f,onCreate:y,onSearch:s})=>{const[o,c]=g.useState(""),[x,d]=g.useState([]),[m,v]=g.useState(!1),[S,_]=g.useState("recent");g.useEffect(()=>{t&&(c(""),d([]),_(r.length>0?"recent":"search"))},[t,r.length]),g.useEffect(()=>{if(!o.trim()){d([]);return}const w=setTimeout(async()=>{v(!0);try{d(await s(o,n))}catch{d([])}finally{v(!1)}},300);return()=>clearTimeout(w)},[o,n,s]);const j=g.useCallback(w=>{c(w.target.value),w.target.value.trim()&&_("search")},[]),I=g.useCallback(w=>a?w.filter(F=>F.id!==a):w,[a]);if(!t)return null;const P=i||(n==="all"?"选择实体":`选择${Ve(n)}`),R=I(r),W=I(x);return e.jsx("div",{style:Jt,children:e.jsxs("div",{style:Kt,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:P}),e.jsx("button",{onClick:f,style:Zt,children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px 12px"},children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",value:o,onChange:j,placeholder:"输入名称或 ID 搜索...",autoFocus:!0,style:Xt}),e.jsx("span",{style:{position:"absolute",left:"14px",top:"50%",transform:"translateY(-50%)",opacity:.5,fontSize:"14px"},children:"🔍"}),m&&e.jsx("span",{style:{position:"absolute",right:"14px",top:"50%",transform:"translateY(-50%)",fontSize:"12px",opacity:.6},children:"搜索中..."})]})}),R.length>0&&e.jsxs("div",{style:{display:"flex",padding:"0 20px",gap:"4px",borderBottom:"1px solid var(--bim-widget-border, #e0e0e0)"},children:[e.jsxs(Te,{active:S==="recent",onClick:()=>_("recent"),children:["最近使用 (",R.length,")"]}),e.jsxs(Te,{active:S==="search",onClick:()=>_("search"),children:["搜索结果 ",W.length>0&&`(${W.length})`]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 20px",minHeight:"200px",maxHeight:"400px"},children:S==="recent"&&R.length>0?e.jsx(Be,{entities:R,onSelect:l}):o.trim()?m?e.jsx(ge,{message:"搜索中..."}):W.length>0?e.jsx(Be,{entities:W,onSelect:l}):e.jsx(ge,{message:"未找到匹配的结果"}):e.jsx(ge,{message:"输入关键词开始搜索"})}),p&&y&&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:y,style:er,children:u||"创建新实体"})]})]})})},Te=({active:t,onClick:i,children:n})=>e.jsx("button",{onClick:i,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:n}),Be=({entities:t,onSelect:i})=>e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:t.map(n=>e.jsx(Qt,{entity:n,onClick:()=>i(n)},n.id))}),Qt=({entity:t,onClick:i})=>{const[n,r]=g.useState(!1);return e.jsxs("div",{onClick:i,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 14px",borderRadius:"6px",cursor:"pointer",background:n?"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:Vt(t.type)}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"13px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.title}),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:Nt(t.type),color:"white",borderRadius:"4px",fontWeight:500,flexShrink:0},children:Ve(t.type)})]})},ge=({message:t})=>e.jsx("div",{style:{padding:"40px 20px",textAlign:"center",color:"var(--bim-desc-fg, #717171)",fontSize:"13px"},children:t}),Jt={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},Kt={background:"var(--bim-bg, #fff)",border:"1px solid var(--bim-widget-border, #e0e0e0)",borderRadius:"8px",width:"550px",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:"0 4px 20px rgba(0,0,0,0.3)"},Zt={background:"transparent",border:"none",fontSize:"18px",cursor:"pointer",opacity:.7,color:"inherit",padding:"4px 8px"},Xt={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"},er={padding:"6px 14px",fontSize:"12px",border:"none",borderRadius:"4px",background:"var(--bim-primary, #0078d4)",color:"var(--bim-primary-fg, #fff)",cursor:"pointer"},tr={work:"#4caf50",collection:"#2196f3",book:"#ff9800"},We={work:"作品",collection:"丛书",book:"书籍"},rr={work:"📜",collection:"📚",book:"📖"},ir=({data:t,onChange:i,onSave:n,transport:r,onNavigate:a,showDelete:p,onDelete:u,onAskAI:l,renderSectionActions:f,onDownloadResource:y,downloadStatuses:s,relations:o,onRelationsChange:c})=>{var be;const[x,d]=g.useState(!1),[m,v]=g.useState("work"),[S,_]=g.useState(""),[j,I]=g.useState(""),[P,R]=g.useState([]),[W,w]=g.useState(!1),[F,H]=g.useState(!1),[E,z]=g.useState("work"),[ee,J]=g.useState(""),[te,ne]=g.useState(),[ce,G]=g.useState(!1),[V,N]=g.useState(null),[se,A]=g.useState([]);g.useRef(null);const q=t.type,$=q==="work",h=q==="collection",C=q==="book",k=g.useCallback((b,T)=>{i({...t,[b]:T})},[t,i]),Qe=g.useCallback((b,T)=>{_(b),v(T);const O=We[T];I(`选择要关联的${O}`),R([]),d(!0)},[]),Je=g.useCallback(b=>{r!=null&&r.unlinkEntity&&r.unlinkEntity(t.id,b)},[r,t.id]),Ke=g.useCallback(b=>{a==null||a(b.id,b.type)},[a]),he=g.useCallback((b,T,O)=>{const st={...O,author:(O==null?void 0:O.author)||t.author,dynasty:(O==null?void 0:O.dynasty)||t.dynasty};z(T),J(b),ne(st),H(!0)},[t.author,t.dynasty]),Ze=g.useCallback((b,T)=>{r!=null&&r.createAndLink&&r.createAndLink(t.id,ee,{type:E,title:b,inheritData:T}),H(!1)},[r,t.id,ee,E]),Xe=g.useCallback(b=>{if(!b.trim()){R([]);return}w(!0),r!=null&&r.searchEntities&&r.searchEntities(b,m).then(T=>{R(T),w(!1)}).catch(()=>{R([]),w(!1)})},[r,m]),et=g.useCallback(b=>{r!=null&&r.linkEntity&&r.linkEntity(t.id,S,b.id),d(!1)},[r,t.id,S]),tt=g.useCallback(()=>{n()},[n]),rt=g.useCallback(b=>{N(()=>b),G(!0),r!=null&&r.getRecentEntities&&r.getRecentEntities().then(A).catch(()=>{})},[r]),it=g.useCallback((b,T)=>r!=null&&r.searchEntities?r.searchEntities(b,T==="all"?void 0:T):Promise.resolve([]),[r]),nt=g.useCallback(b=>{r!=null&&r.addRecentEntity&&r.addRecentEntity(b),A(T=>[b,...T.filter(O=>O.id!==b.id)].slice(0,10)),V==null||V(b),G(!1),N(null)},[r,V]);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:rr[q]}),e.jsx("span",{children:t.title||"未命名"}),e.jsx(ae,{children:t.id}),e.jsx(ae,{color:tr[q],children:We[q]})]})}),e.jsx(D,{title:"📊 基本信息",onSave:n,onAskAI:l?()=>l("基本信息"):void 0,extraButtons:f==null?void 0:f("基本信息"),children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsx(de,{label:$?"作品名 (Work Title)":h?"丛书名 (Collection Title)":"书名 (Book Title)",value:t.title,onChange:b=>k("title",b)}),C&&e.jsx(de,{label:"所属作品 (Work)",value:t.workName||"",onChange:b=>k("workName",b)}),e.jsx(L,{label:"作者 (Author)",value:t.author||"",onChange:b=>k("author",b)}),e.jsx(L,{label:"朝代/年份 (Dynasty/Year)",value:t.dynasty||"",onChange:b=>k("dynasty",b)}),(C||h)&&e.jsx(de,{label:"收录于 (Collection)",value:t.collection||"",onChange:b=>k("collection",b)}),(C||h)&&e.jsx(L,{label:"现藏于 (Holder)",value:t.holder||"",onChange:b=>k("holder",b)}),(C||h)&&e.jsx(L,{label:C?"页数 (Pages)":"册数 (Volumes)",value:t.pages||"",onChange:b=>k("pages",b)}),e.jsx("div",{style:{gridColumn:"1 / -1"},children:e.jsx(L,{label:"首页图片 (First Image URL)",value:t.firstImage||"",onChange:b=>k("firstImage",b)})})]})}),e.jsx(D,{title:"📝 介绍 (Description)",onSave:n,onAskAI:l?()=>l("介绍"):void 0,children:e.jsx(Q,{value:t.description||"",onChange:b=>k("description",b),placeholder:"简要介绍..."})}),(((be=t.additional_titles)==null?void 0:be.length)||0)>0&&e.jsx(D,{title:"📑 副题/附录 (Additional Titles)",onSave:n,children:e.jsx(nr,{items:t.additional_titles||[],onChange:b=>k("additional_titles",b)})}),e.jsx(D,{title:"📖 收录于 (Indexed By)",onSave:n,onAskAI:l?()=>l("收录于"):void 0,children:e.jsx(sr,{items:t.indexed_by||[],onChange:b=>k("indexed_by",b)})}),e.jsx(D,{title:"🔗 资源 (Resources)",onSave:n,onAskAI:l?()=>l("资源"):void 0,children:e.jsx(Le,{items:t.resources||[],onChange:b=>k("resources",b),onDownload:y,downloadStatuses:s})}),e.jsx(D,{title:"📚 资料来源 (Sources)",onSave:n,onAskAI:l?()=>l("资料来源"):void 0,children:e.jsx(qe,{items:Me(t.sources||""),onChange:b=>k("sources",Ae(b)),onOpenEntityPicker:rt})}),(C||h)&&e.jsx(D,{title:"📜 收藏历史 (Provenance)",onSave:n,onAskAI:l?()=>l("收藏历史"):void 0,children:e.jsx(Q,{value:t.provenance||"",onChange:b=>k("provenance",b),placeholder:"该资源的流传与收藏记录..."})}),C&&e.jsx(D,{title:"📚 其他版本 (Other Editions)",onSave:n,onAskAI:l?()=>l("其他版本"):void 0,children:e.jsx(Q,{value:t.otherEditions||"",onChange:b=>k("otherEditions",b),placeholder:"相关版本的 ID..."})}),e.jsx(Ue,{entityType:q,entityId:t.id,entityTitle:t.title,parentWork:o==null?void 0:o.parentWork,parentCollection:o==null?void 0:o.parentCollection,belongsToWork:o==null?void 0:o.belongsToWork,belongsToCollection:o==null?void 0:o.belongsToCollection,childWorks:o==null?void 0:o.childWorks,childCollections:o==null?void 0:o.childCollections,containedBooks:o==null?void 0:o.containedBooks,siblingBooks:o==null?void 0:o.siblingBooks,onLinkEntity:Qe,onUnlinkEntity:Je,onViewEntity:Ke,onCreateAndLink:he,onSaveRelations:tt}),p&&u&&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:"危险区域 (Danger Zone)"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--bim-desc-fg, #717171)",marginBottom:"12px"},children:"从索引库中永久删除该实体的所有元数据文件。"}),e.jsx("button",{onClick:u,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:"删除该实体 (Delete Entity)"})]}),e.jsx(De,{isOpen:x,entityType:m,title:j,onSelect:et,onCancel:()=>d(!1),onCreate:()=>{d(!1),he(S,m)},searchResults:P,onSearch:Xe,isLoading:W,excludeId:t.id}),e.jsx(Ge,{isOpen:F,entityType:E,relationField:ee,inheritData:te,onConfirm:Ze,onCancel:()=>H(!1)}),e.jsx(Ne,{isOpen:ce,title:"选择书籍/作品",filterType:"all",recentEntities:se,excludeId:t.id,onSelect:nt,onCancel:()=>{G(!1),N(null)},onSearch:it})]})};function nr({items:t,onChange:i}){const n=(p,u,l)=>{const f=t.map((y,s)=>s===p?{...y,[u]:l}:y);i(f)},r=p=>i(t.filter((u,l)=>l!==p)),a=()=>i([...t,{book_title:""}]);return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((p,u)=>e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx(L,{label:"书名",value:p.book_title,onChange:l=>n(u,"book_title",l)}),e.jsx("div",{style:{width:"100px"},children:e.jsx(L,{label:"卷数",value:p.n_juan!=null?String(p.n_juan):"",onChange:l=>n(u,"n_juan",l&&parseInt(l,10)||void 0)})}),e.jsx("button",{onClick:()=>r(u),style:{padding:"4px 8px",fontSize:"12px",border:"1px solid #ddd",borderRadius:"4px",background:"transparent",cursor:"pointer",color:"#999",marginTop:"18px"},children:"✕"})]},u)),e.jsx("button",{onClick:a,style:{padding:"6px 12px",fontSize:"12px",border:"1px dashed #ccc",borderRadius:"4px",background:"transparent",cursor:"pointer",color:"#666",alignSelf:"flex-start"},children:"+ 添加副题"})]})}function sr({items:t,onChange:i}){const[n,r]=g.useState(null),a=(l,f,y)=>{const s=t.map((o,c)=>c===l?{...o,[f]:y||void 0}:o);i(s)},p=l=>{i(t.filter((f,y)=>y!==l)),n===l&&r(null)},u=()=>{i([...t,{source:""}]),r(t.length)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[t.map((l,f)=>{const y=n===f;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:y?"color-mix(in srgb, var(--bim-primary, #0078d4) 5%, transparent)":"transparent",cursor:"pointer"},onClick:()=>r(y?null:f),children:[e.jsx("span",{style:{fontSize:"10px",color:"var(--bim-desc-fg, #717171)",transition:"transform 0.2s",transform:y?"rotate(90deg)":"none"},children:"▶"}),e.jsx("span",{style:{flex:1,fontSize:"13px",fontWeight:500},children:l.source||"(未命名来源)"}),l.source_bid&&e.jsx("span",{style:{fontSize:"11px",color:"var(--bim-desc-fg, #717171)"},children:l.source_bid}),e.jsx("button",{onClick:s=>{s.stopPropagation(),p(f)},style:{padding:"2px 6px",fontSize:"11px",border:"1px solid #ddd",borderRadius:"3px",background:"transparent",cursor:"pointer",color:"#999"},children:"✕"})]}),!y&&(l.title_info||l.author_info)&&e.jsxs("div",{style:{padding:"0 12px 8px 28px",fontSize:"12px",color:"var(--bim-desc-fg, #717171)"},children:[l.title_info,l.title_info&&l.author_info&&" — ",l.author_info]}),y&&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(L,{label:"来源名称",value:l.source,onChange:s=>a(f,"source",s)}),e.jsx(L,{label:"来源 BID",value:l.source_bid||"",onChange:s=>a(f,"source_bid",s)})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:[e.jsx(L,{label:"题名",value:l.title_info||"",onChange:s=>a(f,"title_info",s)}),e.jsx(L,{label:"著者",value:l.author_info||"",onChange:s=>a(f,"author_info",s)})]}),e.jsx(L,{label:"版本",value:l.version||"",onChange:s=>a(f,"version",s)}),e.jsx(Q,{value:l.summary||"",onChange:s=>a(f,"summary",s),placeholder:"提要..."}),e.jsx(Q,{value:l.comment||"",onChange:s=>a(f,"comment",s),placeholder:"按語..."}),e.jsx(Q,{value:l.additional_comment||"",onChange:s=>a(f,"additional_comment",s),placeholder:"附按..."})]})]},f)}),e.jsx("button",{onClick:u,style:{padding:"6px 12px",fontSize:"12px",border:"1px dashed #ccc",borderRadius:"4px",background:"transparent",cursor:"pointer",color:"#666",alignSelf:"flex-start"},children:"+ 添加收录来源"})]})}exports.BookIndexStorage=B.BookIndexStorage;exports.GithubTransport=B.GithubTransport;exports.HttpTransport=B.HttpTransport;exports.IdGenerator=B.IdGenerator;exports.LocalTransport=B.LocalTransport;exports.base58Decode=B.base58Decode;exports.base58Encode=B.base58Encode;exports.buildId=B.buildId;exports.decodeIdString=B.decodeIdString;exports.extractIdFromUrl=B.extractIdFromUrl;exports.extractStatus=B.extractStatus;exports.extractType=B.extractType;exports.parseId=B.parseId;exports.validateResource=B.validateResource;exports.Badge=ae;exports.CreateEntityDialog=Ge;exports.EntityPickerDialog=Ne;exports.EntitySelector=De;exports.FormInput=L;exports.FormTextArea=Q;exports.IndexApp=Rt;exports.IndexBrowser=He;exports.IndexDetail=Oe;exports.IndexEditor=ir;exports.ModeIndicator=Pe;exports.RelationPanel=Ue;exports.ResourceEditor=Le;exports.ResourceList=$e;exports.Section=D;exports.SmartBidInput=de;exports.SourceEditor=qe;exports.VscodeTransport=lt;exports.parseSourceString=Me;exports.stringifySources=Ae;
|