@markus-global/cli 0.9.7-rc.1 → 0.9.7

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.
Files changed (62) hide show
  1. package/dist/markus.mjs +106 -40
  2. package/dist/web-ui/assets/{CommentInput-CIxUL6dU.js → CommentInput-JPZATTdP.js} +1 -1
  3. package/dist/web-ui/assets/{ContentRenderer-Bb_drUpO.js → ContentRenderer-gaxBn1N9.js} +2 -2
  4. package/dist/web-ui/assets/{DeliverableShareModal-BEeIlXig.js → DeliverableShareModal-B6qqZgFc.js} +1 -1
  5. package/dist/web-ui/assets/{Deliverables-CJFzxbLw.js → Deliverables-BUi9KGwf.js} +1 -1
  6. package/dist/web-ui/assets/{Notifications-Cz2LKhGE.js → Notifications-W-Mx_v6q.js} +1 -1
  7. package/dist/web-ui/assets/{Search-dq45wHQN.js → Search-Cxtd9r1S.js} +1 -1
  8. package/dist/web-ui/assets/{Settings-WAXEtxMR.js → Settings-Q87nTBy5.js} +1 -1
  9. package/dist/web-ui/assets/{Store-DOGCOxTK.js → Store-BK54Nx60.js} +1 -1
  10. package/dist/web-ui/assets/{Team-NM2SsmjN.js → Team-CWRLD5sM.js} +4 -4
  11. package/dist/web-ui/assets/{Work-ornw-1Zh.js → Work-xejZ7HCT.js} +1 -1
  12. package/dist/web-ui/assets/{arc-D4xcu8MX.js → arc-BqhlYS08.js} +1 -1
  13. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-DP3EZPSb.js → architectureDiagram-3BPJPVTR-C8fUeKGJ.js} +1 -1
  14. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-BnSHtwXa.js → blockDiagram-GPEHLZMM-eILAtQzQ.js} +1 -1
  15. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-DpPSihlY.js → c4Diagram-AAUBKEIU-DdV7TyX_.js} +1 -1
  16. package/dist/web-ui/assets/channel-C-TW97LX.js +1 -0
  17. package/dist/web-ui/assets/{chunk-2J33WTMH-DD5lZIGF.js → chunk-2J33WTMH-BwuewEg2.js} +1 -1
  18. package/dist/web-ui/assets/{chunk-4BX2VUAB-D9wu9GG0.js → chunk-4BX2VUAB-Bv26FANh.js} +1 -1
  19. package/dist/web-ui/assets/{chunk-55IACEB6-p_n2ARjh.js → chunk-55IACEB6-DFTeZroI.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-727SXJPM-BiTqi43c.js → chunk-727SXJPM-i7IiTNSf.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-AQP2D5EJ-DVPMedje.js → chunk-AQP2D5EJ-BoPcIU1Z.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-FMBD7UC4-B53AqN8D.js → chunk-FMBD7UC4-DTXl3WfT.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-ND2GUHAM-sACe_lkd.js → chunk-ND2GUHAM-DdzR-Jnl.js} +1 -1
  24. package/dist/web-ui/assets/{chunk-QZHKN3VN-B0qDAQUW.js → chunk-QZHKN3VN-DqSW43I1.js} +1 -1
  25. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-C92nY4nN.js +1 -0
  26. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-C92nY4nN.js +1 -0
  27. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-BzZayQQf.js → cose-bilkent-S5V4N54A-C-UFRPSb.js} +1 -1
  28. package/dist/web-ui/assets/{dagre-BM42HDAG-DjcfWzm_.js → dagre-BM42HDAG-92ucBloh.js} +1 -1
  29. package/dist/web-ui/assets/{diagram-2AECGRRQ-CEK9T3rW.js → diagram-2AECGRRQ-B8zRoWWP.js} +1 -1
  30. package/dist/web-ui/assets/{diagram-5GNKFQAL-BJsJPwEI.js → diagram-5GNKFQAL-CM3pWtYN.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-KO2AKTUF-BZlki2qo.js → diagram-KO2AKTUF-V7UmwGTe.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-LMA3HP47-Bkmh3WcY.js → diagram-LMA3HP47-DG1RtUeD.js} +1 -1
  33. package/dist/web-ui/assets/{diagram-OG6HWLK6-4THSXHiA.js → diagram-OG6HWLK6-BTwLdZJw.js} +1 -1
  34. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-CPj2HGe-.js → erDiagram-TEJ5UH35-BNXeXKHH.js} +1 -1
  35. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-Bu8HgFqR.js → flowDiagram-I6XJVG4X-VP_sRWgd.js} +1 -1
  36. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-C5gs9b9P.js → ganttDiagram-6RSMTGT7-CvnpoufX.js} +1 -1
  37. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DxnBgR_T.js → gitGraphDiagram-PVQCEYII-zO7DNQqQ.js} +1 -1
  38. package/dist/web-ui/assets/{index-CiAGgfZx.js → index-B1VN5yM1.js} +4 -4
  39. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-D4M-cR8I.js → infoDiagram-5YYISTIA-BSGbaVLq.js} +1 -1
  40. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Oiq6jknk.js → ishikawaDiagram-YF4QCWOH-BatvAQOH.js} +1 -1
  41. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-D2gmyCKv.js → journeyDiagram-JHISSGLW-Cajy4fZr.js} +1 -1
  42. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-DqjzkO8l.js → kanban-definition-UN3LZRKU-DLpKR4E5.js} +1 -1
  43. package/dist/web-ui/assets/{mermaid.core-N5tL3hIv.js → mermaid.core-B4fv65oQ.js} +5 -5
  44. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-ATHsVy0v.js → mindmap-definition-RKZ34NQL-C2HVqxfu.js} +1 -1
  45. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CprLr2Gv.js → pieDiagram-4H26LBE5-Bswg7SQl.js} +1 -1
  46. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-0uN86dlU.js → quadrantDiagram-W4KKPZXB-CyYiDqNE.js} +1 -1
  47. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CQmWbZXW.js → requirementDiagram-4Y6WPE33-BWZmKUo8.js} +1 -1
  48. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-D6kdJsQI.js → sankeyDiagram-5OEKKPKP-C3imZVxk.js} +1 -1
  49. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-1Y79snKt.js → sequenceDiagram-3UESZ5HK-BrySebCt.js} +1 -1
  50. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-BqmCPSIN.js → stateDiagram-AJRCARHV-0Lp5CycE.js} +1 -1
  51. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-QVZbqffU.js +1 -0
  52. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-OG71KAzb.js → timeline-definition-PNZ67QCA-BIGJbkoS.js} +1 -1
  53. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-V9c-71bn.js → vennDiagram-CIIHVFJN-CS9GEvPk.js} +1 -1
  54. package/dist/web-ui/assets/{wardley-L42UT6IY-C3A6_LpL.js → wardley-L42UT6IY-BSNtMxtd.js} +1 -1
  55. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-B54ZiT7U.js → wardleyDiagram-YWT4CUSO-CaEGOjwH.js} +1 -1
  56. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-DpWlpUfV.js → xychartDiagram-2RQKCTM6-Cr_pwOHb.js} +1 -1
  57. package/dist/web-ui/index.html +1 -1
  58. package/package.json +8 -1
  59. package/dist/web-ui/assets/channel-DSB2MBEK.js +0 -1
  60. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-D5cDjaiz.js +0 -1
  61. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-D5cDjaiz.js +0 -1
  62. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DRaoGsBn.js +0 -1
@@ -1,3 +1,3 @@
1
- import{u as nt,j as e,r as a,a as us,b as xs,m as fs,d as hs,c as ms,l as p,w as tt,o as Ut,p as ps,P as L,n as Q,M as gs,q as Pe,h as bs,i as zt,s as ys}from"./index-CiAGgfZx.js";import{resolveFormat as vs,ContentRenderer as js}from"./ContentRenderer-Bb_drUpO.js";import{c as ks,D as Ns}from"./DeliverableShareModal-BEeIlXig.js";function M(u){return Array.isArray(u)?u.map(o=>String(o).trim()).filter(Boolean):typeof u=="string"&&u?u.split(",").map(o=>o.trim()).filter(Boolean):[]}function ws(u){return u.files&&typeof u.files=="object"&&!Array.isArray(u.files)?u.files:null}function J({label:u,value:o}){return o?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:u}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:o})]}):null}function re({label:u,value:o,color:c}){if(!o)return null;const n={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:u}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${n[c]??n.gray} capitalize inline-block`,children:o})]})}function st({files:u}){const{t:o}=nt(["builder","common"]),[c,n]=a.useState(Object.keys(u)[0]??""),x=Object.keys(u);return x.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:o("builder:artifact.files",{count:x.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:x.map(b=>e.jsx("button",{onClick:()=>n(b),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${c===b?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:b},b))}),c&&u[c]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:u[c]})]})]})}function Ss({artifact:u,mode:o}){const{t:c}=nt(["builder","common"]),n=ws(u),x=u.agent,b=u.team,A=u.dependencies,N=u.displayName??u.name;if(o==="agent"){const k=x?.roleName,$=x?.agentRole,y=x?.llmProvider,P=x?.llmModel,g=M(A?.env),I=M(A?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(J,{label:c("builder:artifact.name"),value:N}),e.jsx(J,{label:c("builder:artifact.description"),value:u.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[k&&e.jsx(re,{label:c("builder:artifact.baseTemplate"),value:k,color:"indigo"}),e.jsx(re,{label:c("builder:artifact.agentRole"),value:$,color:$==="manager"?"purple":"cyan"})]}),M(u.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:M(u.tags).map(v=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:v},v))}),(y||P)&&e.jsxs("div",{className:"flex gap-2",children:[y&&e.jsx(re,{label:c("builder:artifact.llmProvider"),value:y,color:"gray"}),P&&e.jsx(re,{label:c("builder:artifact.llmModel"),value:P,color:"gray"})]}),g.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:g.map(v=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:v},v))})]}),I.length>0&&e.jsx(J,{label:c("builder:artifact.skills"),value:I.join(", ")}),n&&e.jsx(st,{files:n})]})}if(o==="team"){const $=b?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(J,{label:c("builder:artifact.name"),value:N}),e.jsx(J,{label:c("builder:artifact.description"),value:u.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(re,{label:c("builder:artifact.category"),value:u.category,color:"indigo"})}),M(u.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:M(u.tags).map(y=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:y},y))}),n&&e.jsx(st,{files:n}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c("builder:artifact.members",{count:$.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:$.map((y,P)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${y.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:y.role==="manager"?"★":P+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:y.name}),typeof y.roleName=="string"&&y.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:y.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(y.count??1)]})]}),M(y.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:M(y.skills).map(g=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:g},g))})]},P))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(J,{label:c("builder:artifact.name"),value:N}),e.jsx(J,{label:c("builder:artifact.description"),value:u.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(re,{label:c("builder:artifact.category"),value:u.category,color:"indigo"})}),n&&e.jsx(st,{files:n}),M(u.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:M(u.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))})]})}const ne={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Cs=["file","directory"];function Be(u){return/^https?:\/\//i.test(u)}function S(u){return u?.shareStatus??null}function Ls(u,o){const c=Date.now(),n=new Date(u).getTime(),x=c-n,b=Math.floor(x/6e4);if(b<1)return o("time.justNow");if(b<60)return o("time.minutesAgo",{count:b});const A=Math.floor(b/60);if(A<24)return o("time.hoursAgo",{count:A});const N=Math.floor(A/24);if(N===1)return o("time.yesterday");if(N<30)return o("time.daysAgo",{count:N});const k=Math.floor(N/30);return k<12?o("time.monthsAgo",{count:k}):o("time.yearsAgo",{count:Math.floor(k/12)})}const F={agent:{icon:"✦",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",color:"bg-amber-500/10 text-amber-600"}};function Ts({authUser:u,previewMode:o,previewData:c}={}){const{t:n}=nt(["deliverables","common"]),x=us(),b=xs(L.DELIVERABLES),A=fs({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[N,k]=a.useState(!1),$=a.useRef(N);$.current=N,a.useEffect(()=>{if(!x)return;const t=()=>{$.current&&k(!1)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[x]);const y=100,P=5e3,[g,I]=a.useState(c?.items??[]),[v,ae]=a.useState(c?.items?.length??0),[le,at]=a.useState(!1),[lt,it]=a.useState(c?.projects??[]),[ot,ct]=a.useState(c?.agents??[]),[dt,Kt]=a.useState([]),[_,ut]=a.useState(!c),[ye,ve]=a.useState(""),[ie,je]=a.useState(""),[B,oe]=a.useState(""),[D,ce]=a.useState(""),[R,xt]=a.useState("date"),[r,C]=a.useState(()=>c?.initialSelectedId&&c.items?c.items.find(t=>t.id===c.initialSelectedId)??c.items[0]??null:c?.items?.[0]??null),[De,ft]=a.useState(null),[ht,mt]=a.useState(""),[U,Gt]=a.useState(!0),[Ve,de]=a.useState(()=>{const t=new Date,s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return new Set([s])}),[He,qt]=a.useState(!1),[We,pt]=a.useState(!1),Yt=a.useMemo(()=>[{id:"date"},{id:"project"},{id:"team"},{id:"agent"}],[]),Qt=a.useCallback(t=>{xt(t)},[]),gt=hs(Yt,R,Qt),z=a.useRef(null),[ke,Ne]=a.useState(null),[we,bt]=a.useState("markdown"),[ue,yt]=a.useState(null),[xe,vt]=a.useState(null),[jt,kt]=a.useState(!1),[Nt,fe]=a.useState(!1),[Se,wt]=a.useState(!1),[Fe,Ce]=a.useState(null),[Jt,_e]=a.useState(!1),[Ue,Xt]=a.useState(""),[St,Zt]=a.useState(new Set),[V,O]=a.useState(!1),E=ms(),X=E?.keyboardPane??"content",[he,Z]=a.useState(null),[ee,K]=a.useState(!1),[me,ze]=a.useState(""),[H,G]=a.useState(!1),[Oe,Ct]=a.useState(!1),[Ke,q]=a.useState(null),Ge=a.useRef(null),Lt=a.useCallback(t=>{t&&(t.style.height="auto",t.style.height=t.scrollHeight+"px")},[]),It=a.useRef(void 0);a.useEffect(()=>{Lt(Ge.current)},[me,ee,Lt]);const T=(t,s)=>{ft({type:t,text:s}),setTimeout(()=>ft(null),3e3)},Rt=async t=>{await ys(t)?(wt(!0),setTimeout(()=>wt(!1),1500)):T("error",n("detail.copyFailed"))},Le=a.useMemo(()=>new Map(ot.map(t=>[t.id,t])),[ot]),qe=a.useMemo(()=>new Map(lt.map(t=>[t.id,t])),[lt]),Et=a.useMemo(()=>new Map(dt.map(t=>[t.id,t])),[dt]),Ie=a.useCallback(t=>{if(!t||t==="default")return null;const s=qe.get(t)?.name;return!s||s==="default"?null:s},[qe]);a.useEffect(()=>{o||(p.projects.list().then(t=>it(t.projects)).catch(()=>{}),p.agents.list().then(t=>ct(t.agents??[])).catch(()=>{}),p.teams.list().then(t=>Kt(t.teams??[])).catch(()=>{}),p.system.storage().then(t=>Xt(t.dataDir+"/shared")).catch(()=>{}),p.deliverables.checkHealth().then(t=>Zt(new Set(t.missingFiles))).catch(()=>{}))},[o]),a.useEffect(()=>(It.current=setTimeout(()=>je(ye),300),()=>clearTimeout(It.current)),[ye]);const te=a.useMemo(()=>({q:ie||void 0,type:B||void 0,artifactType:D||void 0}),[ie,B,D]),se=R==="date"?y:P,Ye=a.useCallback((t,s)=>s?{...s,hubShareId:s.hubShareId!=null?s.hubShareId:t.hubShareId??null,shareStatus:s.shareStatus!=null?s.shareStatus:t.shareStatus??null,shareUrl:s.shareUrl!=null?s.shareUrl:t.shareUrl??null,shareVisibility:s.shareVisibility!=null?s.shareVisibility:t.shareVisibility??null,shareReason:s.shareReason!=null?s.shareReason:t.shareReason}:t,[]),Re=a.useCallback(async()=>{try{const{results:t,total:s}=await p.deliverables.search({...te,offset:0,limit:se});I(i=>i.map(l=>{const f=t.find(d=>d.id===l.id);return f?Ye(l,f):l})),ae(s),C(i=>{if(!i)return null;const l=t.find(f=>f.id===i.id);return l?Ye(i,l):i})}catch{}},[te,se,Ye]),Y=a.useCallback(async()=>{ut(!0),z.current?.scrollTo({top:0,behavior:"instant"});try{const{results:t,total:s}=await p.deliverables.search({...te,offset:0,limit:se});I(t),ae(s),C(i=>i&&t.some(l=>l.id===i.id)?i:null)}catch{I([]),ae(0),C(null)}ut(!1)},[te,se]),Ee=a.useCallback(async()=>{if(!(le||g.length>=v)){at(!0);try{const{results:t,total:s}=await p.deliverables.search({...te,offset:g.length,limit:se});I(i=>[...i,...t]),ae(s)}catch{}at(!1)}},[te,se,g.length,v,le]);a.useEffect(()=>{o||Y()},[Y,o]),a.useEffect(()=>{!o||!c||(I(c.items??[]),ae(c.items?.length??0),it(c.projects??[]),ct(c.agents??[]),c.initialSelectedId&&C(c.items?.find(t=>t.id===c.initialSelectedId)??c.items?.[0]??null))},[o,c]);const Qe=a.useRef(r);Qe.current=r,a.useEffect(()=>{if(o||!b)return;const t=tt.on("deliverable:created",()=>Y()),s=tt.on("deliverable:updated",l=>{Re();const f=l.payload?.deliverableId;f&&Qe.current?.id===f&&p.deliverables.get(f).then(d=>{d.deliverable&&(C(h=>({...h??d.deliverable,...d.deliverable,hubShareId:h?.hubShareId??d.deliverable.hubShareId??null,shareStatus:h?.shareStatus??d.deliverable.shareStatus??null,shareUrl:h?.shareUrl??d.deliverable.shareUrl??null,shareVisibility:h?.shareVisibility??d.deliverable.shareVisibility??null,shareReason:h?.shareReason??d.deliverable.shareReason??null})),At(d.deliverable))}).catch(()=>{})}),i=tt.on("deliverable:removed",()=>Y());return()=>{t(),s(),i()}},[Re,b,o]);const Tt=a.useMemo(()=>ks(Ut,bs.getUrl()),[]);a.useEffect(()=>{if(o||!b||!Ut())return;let t=!1;const s=async()=>{try{const l=await Tt.listMine();if(t)return;const f=new Map,d=new Map;for(const m of l)m.id&&f.set(m.id,m),m.localId&&d.set(m.localId,m);const h=new Map;I(m=>m.map(j=>{const w=j.hubShareId&&f.get(j.hubShareId)||d.get(j.id);if(!w)return j;const be={hubShareId:j.hubShareId??w.id??null,shareStatus:w.status??null,shareUrl:w.url??null,shareVisibility:j.shareVisibility??w.visibility??null,...w.reason!=null?{shareReason:w.reason}:{}};return h.set(j.id,be),{...j,...be}})),C(m=>{if(!m)return m;const j=h.get(m.id);return j?{...m,...j}:m});for(const[m,j]of h)p.deliverables.update(m,j).catch(w=>{console.warn("[deliverables] Hub 分享状态本地持久化失败:",w)})}catch{}};s();const i=setInterval(s,3e4);return()=>{t=!0,clearInterval(i)}},[Tt,b,o]);const Te=a.useRef(null),Je=a.useRef(g);Je.current=g;const pe=a.useCallback(t=>{const s=l=>{C(l),x&&(k(!0),history.pushState({mobileDetail:L.DELIVERABLES},"",window.location.hash))},i=Je.current.find(l=>l.id===t);if(i){s(i);return}p.deliverables.get(t).then(l=>{l.deliverable&&s(l.deliverable)}).catch(()=>{})},[x]);a.useEffect(()=>{if(o)return;const t=window.location.hash.slice(1).split("/"),s=ps(t[0])===L.DELIVERABLES?t[1]:void 0,i=localStorage.getItem("markus_nav_openDeliverable")||s;i&&(localStorage.removeItem("markus_nav_openDeliverable"),Je.current.length>0?pe(i):Te.current=i);const l=f=>{const d=f.detail;d?.params?.openDeliverable&&(localStorage.removeItem("markus_nav_openDeliverable"),pe(d.params.openDeliverable))};return window.addEventListener("markus:navigate",l),()=>window.removeEventListener("markus:navigate",l)},[pe,o]),a.useEffect(()=>{const t=Te.current;!t||g.length===0||(Te.current=null,pe(t))},[g,pe]);const Mt=a.useCallback(()=>{const t=z.current;!t||_||le||g.length>=v||t.scrollHeight<=t.clientHeight+100&&Ee()},[_,le,g.length,v,Ee]);a.useEffect(()=>{const t=z.current;if(!t)return;const s=()=>{t.scrollTop+t.clientHeight>=t.scrollHeight-100&&Ee()};return t.addEventListener("scroll",s,{passive:!0}),()=>t.removeEventListener("scroll",s)},[Ee]),a.useEffect(()=>{Mt()},[Mt,U,Ve]);const W=a.useMemo(()=>{const t=new Map;for(const i of g){let l,f;if(R==="project"){const d=Ie(i.projectId);l=d?i.projectId??"_none":"_none",f=d??n("noProject")}else if(R==="team"){const h=(i.agentId?Le.get(i.agentId):void 0)?.teamId??"_none";l=h,f=h!=="_none"?Et.get(h)?.name??h:n("noTeam")}else if(R==="agent")l=i.agentId??"_none",f=i.agentId?Le.get(i.agentId)?.name??i.agentId:n("common:unknown");else{const d=new Date(i.updatedAt);l=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`,f=l}t.has(l)||t.set(l,{label:f,items:[]}),t.get(l).items.push(i)}const s=[...t.entries()];return R==="date"?s.sort((i,l)=>l[0].localeCompare(i[0])):s.sort((i,l)=>i[1].label.localeCompare(l[1].label)),s},[g,R,qe,Le,Et,n]);a.useEffect(()=>{if(R==="date"&&U){const t=new Date,s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;de(new Set([s]))}else de(new Set)},[R]);const es=async t=>{mt("remove");try{await p.deliverables.remove(t.id),T("success",n("removed")),C(null),Y()}catch(s){T("error",n("common:error",{message:String(s)}))}mt("")},ts=a.useCallback(t=>{const s=Qe.current,i=s?.id;if(!i)return;const l={hubShareId:t.id??null,shareStatus:t.status??null,shareUrl:t.url??null,shareVisibility:t.visibility??null,...t.reason!=null||t.status==="rejected"?{shareReason:t.reason??s?.shareReason??null}:{}},f={...l,shareStatus:l.shareStatus??s?.shareStatus??null};C(d=>d&&d.id===i?{...d,...f}:d),I(d=>d.map(h=>h.id===i?{...h,...f}:h)),(async()=>{try{await p.deliverables.update(i,l)}catch(d){console.warn("[deliverables] 分享状态本地回写失败,将由 Hub 轮询补偿:",d)}Re()})()},[Re]),ss=()=>{Q.navigate(L.BUILDER)},At=async t=>{if(t.reference&&!Be(t.reference)){if(t.type==="directory"){fe(!0);return}kt(!0);try{const s=await p.files.preview(t.reference);if(s.type==="image"&&s.mimeType)yt({src:`data:${s.mimeType};base64,${s.content}`,name:s.name});else if(s.type==="audio"||s.type==="video"){const i=s.streamUrl||(s.path?p.files.streamUrl(s.path):p.files.streamUrl(t.reference));vt({kind:s.type,src:i,name:s.name})}else s.type==="binary"?fe(!0):typeof s.content=="string"?(Ne(s.content),bt(vs({format:t.format,reference:t.reference,content:s.content}))):fe(!0)}catch{Ne(null),t.type==="file"&&fe(!0)}kt(!1)}};a.useEffect(()=>{o||(Ne(null),bt("markdown"),yt(null),vt(null),fe(!1),r&&At(r))},[r?.id,o]);const $t=a.useCallback(t=>U!==Ve.has(t),[U,Ve]),Pt=W.length>0&&W.every(([t])=>$t(t)),rs=a.useCallback(t=>{de(s=>{const i=new Set(s);return i.has(t)?i.delete(t):i.add(t),i})},[]),Bt=a.useCallback(t=>{de(s=>{if(s.has(t)===U)return s;const i=new Set(s);return U?i.add(t):i.delete(t),i})},[U]),ns=a.useCallback(()=>{Gt(t=>!t),de(new Set)},[]),Me=!!(B||D||ie),Dt=a.useCallback(()=>{oe(""),ce(""),ve(""),je("")},[]),ge=a.useMemo(()=>W.flatMap(([,t])=>t.items),[W]);a.useEffect(()=>{o||x||_||r||Te.current||ge.length!==0&&C(ge[0])},[o,x,_,r,ge]);const Xe=a.useRef(null);a.useEffect(()=>{if(!r){Xe.current=null;return}if(Xe.current===r.id)return;const t=W.find(([,s])=>s.items.some(i=>i.id===r.id));t&&(Xe.current=r.id,Bt(t[0]))},[r?.id,W,Bt]);const Vt=a.useRef(null),Ht=a.useRef(null),Ae=a.useRef(!1),Wt=a.useRef(X);a.useEffect(()=>{if(o||x||!b)return;const t=Wt.current;Wt.current=X,!(X!=="l1"||t==="l1")&&V&&(Ae.current=!0,O(!1))},[X,o,x,b,V]),a.useEffect(()=>{if(o||x||!b)return;const t=s=>{if(s.metaKey||s.ctrlKey){if(s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement){s.key==="Escape"&&(s.target.blur(),s.preventDefault());return}if(zt(s.target))return;if(s.key==="f"){s.preventDefault(),Vt.current?.focus();return}if(s.key.toLowerCase()==="b"){s.preventDefault(),O(w=>{const be=!w;return be&&(Ae.current=!0,E?.setKeyboardPane("l1"),requestAnimationFrame(()=>Ht.current?.focus())),be});return}if(s.key.toLowerCase()==="l"){s.preventDefault(),et();return}return s.altKey,void 0}if(E?.keyboardPane==="l0")return;if(s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement){s.key==="Escape"&&(s.target.blur(),s.preventDefault());return}if(zt(s.target)||s.metaKey||s.ctrlKey||s.altKey)return;const l=s.key.length===1?s.key.toLowerCase():s.key;if(l==="h"||l==="ArrowLeft"){s.preventDefault(),V&&O(!1),E?.setL0FocusPageId(L.DELIVERABLES),E?.setLeftCollapsed(!1),E?.setKeyboardPane("l0");return}if(l==="l"||l==="ArrowRight"){s.preventDefault(),V&&O(!1),E?.keyboardPane!=="l1"&&E?.setKeyboardPane("l1");return}const f=l==="j"||l==="ArrowDown"?1:l==="k"||l==="ArrowUp"?-1:0;if(!f)return;s.preventDefault(),E?.setKeyboardPane("l1"),V&&(Ae.current=!0,O(!1));const d=ge;if(d.length===0)return;const h=r?d.findIndex(w=>w.id===r.id):-1,m=h<0?f>0?-1:0:h,j=Math.max(0,Math.min(d.length-1,m+f));Ft(d[j]),requestAnimationFrame(()=>{document.querySelector(`[data-deliverable-id="${d[j].id}"]`)?.scrollIntoView({block:"nearest"})})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[ge,r,o,x,b,E,V]);const $e=a.useRef(null),as=a.useCallback(t=>{if(!x)return;const s=z.current;!s||s.scrollTop>0||($e.current={y:t.touches[0].clientY,scrollTop:s.scrollTop})},[x]),ls=a.useCallback(t=>{if(!x||!$e.current||We)return;const s=t.changedTouches[0].clientY-$e.current.y;$e.current=null,s>80&&z.current&&z.current.scrollTop<=0&&(pt(!0),Y().finally(()=>pt(!1)))},[x,We,Y]),Ft=t=>{const s=()=>{C(t),_e(!1),K(!1),G(!1),x&&(k(!0),history.pushState({mobileDetail:L.DELIVERABLES},"",window.location.hash))};H?q({action:s}):s()},is=()=>{if(!H){const t=ke??r?.summary??"";ze(t)}K(!0)},os=()=>{H?q({action:()=>{K(!1),G(!1)}}):K(!1)},_t=async()=>{if(!(!r?.reference||Oe)){Ct(!0);try{await p.files.write(r.reference,me),Ne(me),G(!1),K(!1),T("success",n("detail.saved"))}catch(t){T("error",n("detail.saveFailed")+": "+String(t))}Ct(!1)}},cs=()=>{K(!1),G(!1),q(null)};a.useEffect(()=>{if(!H)return;const t=s=>{s.preventDefault()};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[H]),a.useEffect(()=>{if(!H)return;const t=s=>{s.preventDefault(),s.stopImmediatePropagation(),q({action:()=>{K(!1),G(!1);const{page:i,params:l}=s.detail||{};i&&Q.navigate(i,l)}})};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[H]);const Ze=a.useRef(null),et=a.useCallback((t,s)=>{const i=r?.agentId??"",l=r?.id??"",f={};l&&(f.openDeliverable=l);const d=[];if(l){const h=r?.title?.trim()||l,m=h.length>40?`${h.slice(0,24)}…${h.slice(-12)}`:h;d.push({label:`📄 ${m}`,content:["[deliverable]",`ID: ${l}`,`Title: ${r?.title??""}`,r?.reference?`Reference: ${r.reference}`:"",r?.taskId?`Task: ${r.taskId}`:"",r?.projectId?`Project: ${r.projectId}`:""].filter(Boolean).join(`
1
+ import{u as nt,j as e,r as a,a as us,b as xs,m as fs,d as hs,c as ms,l as p,w as tt,o as Ut,p as ps,P as L,n as Q,M as gs,q as Pe,h as bs,i as zt,s as ys}from"./index-B1VN5yM1.js";import{resolveFormat as vs,ContentRenderer as js}from"./ContentRenderer-gaxBn1N9.js";import{c as ks,D as Ns}from"./DeliverableShareModal-B6qqZgFc.js";function M(u){return Array.isArray(u)?u.map(o=>String(o).trim()).filter(Boolean):typeof u=="string"&&u?u.split(",").map(o=>o.trim()).filter(Boolean):[]}function ws(u){return u.files&&typeof u.files=="object"&&!Array.isArray(u.files)?u.files:null}function J({label:u,value:o}){return o?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:u}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:o})]}):null}function re({label:u,value:o,color:c}){if(!o)return null;const n={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:u}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${n[c]??n.gray} capitalize inline-block`,children:o})]})}function st({files:u}){const{t:o}=nt(["builder","common"]),[c,n]=a.useState(Object.keys(u)[0]??""),x=Object.keys(u);return x.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:o("builder:artifact.files",{count:x.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:x.map(b=>e.jsx("button",{onClick:()=>n(b),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${c===b?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:b},b))}),c&&u[c]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:u[c]})]})]})}function Ss({artifact:u,mode:o}){const{t:c}=nt(["builder","common"]),n=ws(u),x=u.agent,b=u.team,A=u.dependencies,N=u.displayName??u.name;if(o==="agent"){const k=x?.roleName,$=x?.agentRole,y=x?.llmProvider,P=x?.llmModel,g=M(A?.env),I=M(A?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(J,{label:c("builder:artifact.name"),value:N}),e.jsx(J,{label:c("builder:artifact.description"),value:u.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[k&&e.jsx(re,{label:c("builder:artifact.baseTemplate"),value:k,color:"indigo"}),e.jsx(re,{label:c("builder:artifact.agentRole"),value:$,color:$==="manager"?"purple":"cyan"})]}),M(u.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:M(u.tags).map(v=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:v},v))}),(y||P)&&e.jsxs("div",{className:"flex gap-2",children:[y&&e.jsx(re,{label:c("builder:artifact.llmProvider"),value:y,color:"gray"}),P&&e.jsx(re,{label:c("builder:artifact.llmModel"),value:P,color:"gray"})]}),g.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:g.map(v=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:v},v))})]}),I.length>0&&e.jsx(J,{label:c("builder:artifact.skills"),value:I.join(", ")}),n&&e.jsx(st,{files:n})]})}if(o==="team"){const $=b?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(J,{label:c("builder:artifact.name"),value:N}),e.jsx(J,{label:c("builder:artifact.description"),value:u.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(re,{label:c("builder:artifact.category"),value:u.category,color:"indigo"})}),M(u.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:M(u.tags).map(y=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:y},y))}),n&&e.jsx(st,{files:n}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c("builder:artifact.members",{count:$.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:$.map((y,P)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${y.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:y.role==="manager"?"★":P+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:y.name}),typeof y.roleName=="string"&&y.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:y.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(y.count??1)]})]}),M(y.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:M(y.skills).map(g=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:g},g))})]},P))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(J,{label:c("builder:artifact.name"),value:N}),e.jsx(J,{label:c("builder:artifact.description"),value:u.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(re,{label:c("builder:artifact.category"),value:u.category,color:"indigo"})}),n&&e.jsx(st,{files:n}),M(u.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:M(u.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))})]})}const ne={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Cs=["file","directory"];function Be(u){return/^https?:\/\//i.test(u)}function S(u){return u?.shareStatus??null}function Ls(u,o){const c=Date.now(),n=new Date(u).getTime(),x=c-n,b=Math.floor(x/6e4);if(b<1)return o("time.justNow");if(b<60)return o("time.minutesAgo",{count:b});const A=Math.floor(b/60);if(A<24)return o("time.hoursAgo",{count:A});const N=Math.floor(A/24);if(N===1)return o("time.yesterday");if(N<30)return o("time.daysAgo",{count:N});const k=Math.floor(N/30);return k<12?o("time.monthsAgo",{count:k}):o("time.yearsAgo",{count:Math.floor(k/12)})}const F={agent:{icon:"✦",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",color:"bg-amber-500/10 text-amber-600"}};function Ts({authUser:u,previewMode:o,previewData:c}={}){const{t:n}=nt(["deliverables","common"]),x=us(),b=xs(L.DELIVERABLES),A=fs({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[N,k]=a.useState(!1),$=a.useRef(N);$.current=N,a.useEffect(()=>{if(!x)return;const t=()=>{$.current&&k(!1)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[x]);const y=100,P=5e3,[g,I]=a.useState(c?.items??[]),[v,ae]=a.useState(c?.items?.length??0),[le,at]=a.useState(!1),[lt,it]=a.useState(c?.projects??[]),[ot,ct]=a.useState(c?.agents??[]),[dt,Kt]=a.useState([]),[_,ut]=a.useState(!c),[ye,ve]=a.useState(""),[ie,je]=a.useState(""),[B,oe]=a.useState(""),[D,ce]=a.useState(""),[R,xt]=a.useState("date"),[r,C]=a.useState(()=>c?.initialSelectedId&&c.items?c.items.find(t=>t.id===c.initialSelectedId)??c.items[0]??null:c?.items?.[0]??null),[De,ft]=a.useState(null),[ht,mt]=a.useState(""),[U,Gt]=a.useState(!0),[Ve,de]=a.useState(()=>{const t=new Date,s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return new Set([s])}),[He,qt]=a.useState(!1),[We,pt]=a.useState(!1),Yt=a.useMemo(()=>[{id:"date"},{id:"project"},{id:"team"},{id:"agent"}],[]),Qt=a.useCallback(t=>{xt(t)},[]),gt=hs(Yt,R,Qt),z=a.useRef(null),[ke,Ne]=a.useState(null),[we,bt]=a.useState("markdown"),[ue,yt]=a.useState(null),[xe,vt]=a.useState(null),[jt,kt]=a.useState(!1),[Nt,fe]=a.useState(!1),[Se,wt]=a.useState(!1),[Fe,Ce]=a.useState(null),[Jt,_e]=a.useState(!1),[Ue,Xt]=a.useState(""),[St,Zt]=a.useState(new Set),[V,O]=a.useState(!1),E=ms(),X=E?.keyboardPane??"content",[he,Z]=a.useState(null),[ee,K]=a.useState(!1),[me,ze]=a.useState(""),[H,G]=a.useState(!1),[Oe,Ct]=a.useState(!1),[Ke,q]=a.useState(null),Ge=a.useRef(null),Lt=a.useCallback(t=>{t&&(t.style.height="auto",t.style.height=t.scrollHeight+"px")},[]),It=a.useRef(void 0);a.useEffect(()=>{Lt(Ge.current)},[me,ee,Lt]);const T=(t,s)=>{ft({type:t,text:s}),setTimeout(()=>ft(null),3e3)},Rt=async t=>{await ys(t)?(wt(!0),setTimeout(()=>wt(!1),1500)):T("error",n("detail.copyFailed"))},Le=a.useMemo(()=>new Map(ot.map(t=>[t.id,t])),[ot]),qe=a.useMemo(()=>new Map(lt.map(t=>[t.id,t])),[lt]),Et=a.useMemo(()=>new Map(dt.map(t=>[t.id,t])),[dt]),Ie=a.useCallback(t=>{if(!t||t==="default")return null;const s=qe.get(t)?.name;return!s||s==="default"?null:s},[qe]);a.useEffect(()=>{o||(p.projects.list().then(t=>it(t.projects)).catch(()=>{}),p.agents.list().then(t=>ct(t.agents??[])).catch(()=>{}),p.teams.list().then(t=>Kt(t.teams??[])).catch(()=>{}),p.system.storage().then(t=>Xt(t.dataDir+"/shared")).catch(()=>{}),p.deliverables.checkHealth().then(t=>Zt(new Set(t.missingFiles))).catch(()=>{}))},[o]),a.useEffect(()=>(It.current=setTimeout(()=>je(ye),300),()=>clearTimeout(It.current)),[ye]);const te=a.useMemo(()=>({q:ie||void 0,type:B||void 0,artifactType:D||void 0}),[ie,B,D]),se=R==="date"?y:P,Ye=a.useCallback((t,s)=>s?{...s,hubShareId:s.hubShareId!=null?s.hubShareId:t.hubShareId??null,shareStatus:s.shareStatus!=null?s.shareStatus:t.shareStatus??null,shareUrl:s.shareUrl!=null?s.shareUrl:t.shareUrl??null,shareVisibility:s.shareVisibility!=null?s.shareVisibility:t.shareVisibility??null,shareReason:s.shareReason!=null?s.shareReason:t.shareReason}:t,[]),Re=a.useCallback(async()=>{try{const{results:t,total:s}=await p.deliverables.search({...te,offset:0,limit:se});I(i=>i.map(l=>{const f=t.find(d=>d.id===l.id);return f?Ye(l,f):l})),ae(s),C(i=>{if(!i)return null;const l=t.find(f=>f.id===i.id);return l?Ye(i,l):i})}catch{}},[te,se,Ye]),Y=a.useCallback(async()=>{ut(!0),z.current?.scrollTo({top:0,behavior:"instant"});try{const{results:t,total:s}=await p.deliverables.search({...te,offset:0,limit:se});I(t),ae(s),C(i=>i&&t.some(l=>l.id===i.id)?i:null)}catch{I([]),ae(0),C(null)}ut(!1)},[te,se]),Ee=a.useCallback(async()=>{if(!(le||g.length>=v)){at(!0);try{const{results:t,total:s}=await p.deliverables.search({...te,offset:g.length,limit:se});I(i=>[...i,...t]),ae(s)}catch{}at(!1)}},[te,se,g.length,v,le]);a.useEffect(()=>{o||Y()},[Y,o]),a.useEffect(()=>{!o||!c||(I(c.items??[]),ae(c.items?.length??0),it(c.projects??[]),ct(c.agents??[]),c.initialSelectedId&&C(c.items?.find(t=>t.id===c.initialSelectedId)??c.items?.[0]??null))},[o,c]);const Qe=a.useRef(r);Qe.current=r,a.useEffect(()=>{if(o||!b)return;const t=tt.on("deliverable:created",()=>Y()),s=tt.on("deliverable:updated",l=>{Re();const f=l.payload?.deliverableId;f&&Qe.current?.id===f&&p.deliverables.get(f).then(d=>{d.deliverable&&(C(h=>({...h??d.deliverable,...d.deliverable,hubShareId:h?.hubShareId??d.deliverable.hubShareId??null,shareStatus:h?.shareStatus??d.deliverable.shareStatus??null,shareUrl:h?.shareUrl??d.deliverable.shareUrl??null,shareVisibility:h?.shareVisibility??d.deliverable.shareVisibility??null,shareReason:h?.shareReason??d.deliverable.shareReason??null})),At(d.deliverable))}).catch(()=>{})}),i=tt.on("deliverable:removed",()=>Y());return()=>{t(),s(),i()}},[Re,b,o]);const Tt=a.useMemo(()=>ks(Ut,bs.getUrl()),[]);a.useEffect(()=>{if(o||!b||!Ut())return;let t=!1;const s=async()=>{try{const l=await Tt.listMine();if(t)return;const f=new Map,d=new Map;for(const m of l)m.id&&f.set(m.id,m),m.localId&&d.set(m.localId,m);const h=new Map;I(m=>m.map(j=>{const w=j.hubShareId&&f.get(j.hubShareId)||d.get(j.id);if(!w)return j;const be={hubShareId:j.hubShareId??w.id??null,shareStatus:w.status??null,shareUrl:w.url??null,shareVisibility:j.shareVisibility??w.visibility??null,...w.reason!=null?{shareReason:w.reason}:{}};return h.set(j.id,be),{...j,...be}})),C(m=>{if(!m)return m;const j=h.get(m.id);return j?{...m,...j}:m});for(const[m,j]of h)p.deliverables.update(m,j).catch(w=>{console.warn("[deliverables] Hub 分享状态本地持久化失败:",w)})}catch{}};s();const i=setInterval(s,3e4);return()=>{t=!0,clearInterval(i)}},[Tt,b,o]);const Te=a.useRef(null),Je=a.useRef(g);Je.current=g;const pe=a.useCallback(t=>{const s=l=>{C(l),x&&(k(!0),history.pushState({mobileDetail:L.DELIVERABLES},"",window.location.hash))},i=Je.current.find(l=>l.id===t);if(i){s(i);return}p.deliverables.get(t).then(l=>{l.deliverable&&s(l.deliverable)}).catch(()=>{})},[x]);a.useEffect(()=>{if(o)return;const t=window.location.hash.slice(1).split("/"),s=ps(t[0])===L.DELIVERABLES?t[1]:void 0,i=localStorage.getItem("markus_nav_openDeliverable")||s;i&&(localStorage.removeItem("markus_nav_openDeliverable"),Je.current.length>0?pe(i):Te.current=i);const l=f=>{const d=f.detail;d?.params?.openDeliverable&&(localStorage.removeItem("markus_nav_openDeliverable"),pe(d.params.openDeliverable))};return window.addEventListener("markus:navigate",l),()=>window.removeEventListener("markus:navigate",l)},[pe,o]),a.useEffect(()=>{const t=Te.current;!t||g.length===0||(Te.current=null,pe(t))},[g,pe]);const Mt=a.useCallback(()=>{const t=z.current;!t||_||le||g.length>=v||t.scrollHeight<=t.clientHeight+100&&Ee()},[_,le,g.length,v,Ee]);a.useEffect(()=>{const t=z.current;if(!t)return;const s=()=>{t.scrollTop+t.clientHeight>=t.scrollHeight-100&&Ee()};return t.addEventListener("scroll",s,{passive:!0}),()=>t.removeEventListener("scroll",s)},[Ee]),a.useEffect(()=>{Mt()},[Mt,U,Ve]);const W=a.useMemo(()=>{const t=new Map;for(const i of g){let l,f;if(R==="project"){const d=Ie(i.projectId);l=d?i.projectId??"_none":"_none",f=d??n("noProject")}else if(R==="team"){const h=(i.agentId?Le.get(i.agentId):void 0)?.teamId??"_none";l=h,f=h!=="_none"?Et.get(h)?.name??h:n("noTeam")}else if(R==="agent")l=i.agentId??"_none",f=i.agentId?Le.get(i.agentId)?.name??i.agentId:n("common:unknown");else{const d=new Date(i.updatedAt);l=`${d.getFullYear()}-${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")}`,f=l}t.has(l)||t.set(l,{label:f,items:[]}),t.get(l).items.push(i)}const s=[...t.entries()];return R==="date"?s.sort((i,l)=>l[0].localeCompare(i[0])):s.sort((i,l)=>i[1].label.localeCompare(l[1].label)),s},[g,R,qe,Le,Et,n]);a.useEffect(()=>{if(R==="date"&&U){const t=new Date,s=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;de(new Set([s]))}else de(new Set)},[R]);const es=async t=>{mt("remove");try{await p.deliverables.remove(t.id),T("success",n("removed")),C(null),Y()}catch(s){T("error",n("common:error",{message:String(s)}))}mt("")},ts=a.useCallback(t=>{const s=Qe.current,i=s?.id;if(!i)return;const l={hubShareId:t.id??null,shareStatus:t.status??null,shareUrl:t.url??null,shareVisibility:t.visibility??null,...t.reason!=null||t.status==="rejected"?{shareReason:t.reason??s?.shareReason??null}:{}},f={...l,shareStatus:l.shareStatus??s?.shareStatus??null};C(d=>d&&d.id===i?{...d,...f}:d),I(d=>d.map(h=>h.id===i?{...h,...f}:h)),(async()=>{try{await p.deliverables.update(i,l)}catch(d){console.warn("[deliverables] 分享状态本地回写失败,将由 Hub 轮询补偿:",d)}Re()})()},[Re]),ss=()=>{Q.navigate(L.BUILDER)},At=async t=>{if(t.reference&&!Be(t.reference)){if(t.type==="directory"){fe(!0);return}kt(!0);try{const s=await p.files.preview(t.reference);if(s.type==="image"&&s.mimeType)yt({src:`data:${s.mimeType};base64,${s.content}`,name:s.name});else if(s.type==="audio"||s.type==="video"){const i=s.streamUrl||(s.path?p.files.streamUrl(s.path):p.files.streamUrl(t.reference));vt({kind:s.type,src:i,name:s.name})}else s.type==="binary"?fe(!0):typeof s.content=="string"?(Ne(s.content),bt(vs({format:t.format,reference:t.reference,content:s.content}))):fe(!0)}catch{Ne(null),t.type==="file"&&fe(!0)}kt(!1)}};a.useEffect(()=>{o||(Ne(null),bt("markdown"),yt(null),vt(null),fe(!1),r&&At(r))},[r?.id,o]);const $t=a.useCallback(t=>U!==Ve.has(t),[U,Ve]),Pt=W.length>0&&W.every(([t])=>$t(t)),rs=a.useCallback(t=>{de(s=>{const i=new Set(s);return i.has(t)?i.delete(t):i.add(t),i})},[]),Bt=a.useCallback(t=>{de(s=>{if(s.has(t)===U)return s;const i=new Set(s);return U?i.add(t):i.delete(t),i})},[U]),ns=a.useCallback(()=>{Gt(t=>!t),de(new Set)},[]),Me=!!(B||D||ie),Dt=a.useCallback(()=>{oe(""),ce(""),ve(""),je("")},[]),ge=a.useMemo(()=>W.flatMap(([,t])=>t.items),[W]);a.useEffect(()=>{o||x||_||r||Te.current||ge.length!==0&&C(ge[0])},[o,x,_,r,ge]);const Xe=a.useRef(null);a.useEffect(()=>{if(!r){Xe.current=null;return}if(Xe.current===r.id)return;const t=W.find(([,s])=>s.items.some(i=>i.id===r.id));t&&(Xe.current=r.id,Bt(t[0]))},[r?.id,W,Bt]);const Vt=a.useRef(null),Ht=a.useRef(null),Ae=a.useRef(!1),Wt=a.useRef(X);a.useEffect(()=>{if(o||x||!b)return;const t=Wt.current;Wt.current=X,!(X!=="l1"||t==="l1")&&V&&(Ae.current=!0,O(!1))},[X,o,x,b,V]),a.useEffect(()=>{if(o||x||!b)return;const t=s=>{if(s.metaKey||s.ctrlKey){if(s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement){s.key==="Escape"&&(s.target.blur(),s.preventDefault());return}if(zt(s.target))return;if(s.key==="f"){s.preventDefault(),Vt.current?.focus();return}if(s.key.toLowerCase()==="b"){s.preventDefault(),O(w=>{const be=!w;return be&&(Ae.current=!0,E?.setKeyboardPane("l1"),requestAnimationFrame(()=>Ht.current?.focus())),be});return}if(s.key.toLowerCase()==="l"){s.preventDefault(),et();return}return s.altKey,void 0}if(E?.keyboardPane==="l0")return;if(s.target instanceof HTMLInputElement||s.target instanceof HTMLTextAreaElement){s.key==="Escape"&&(s.target.blur(),s.preventDefault());return}if(zt(s.target)||s.metaKey||s.ctrlKey||s.altKey)return;const l=s.key.length===1?s.key.toLowerCase():s.key;if(l==="h"||l==="ArrowLeft"){s.preventDefault(),V&&O(!1),E?.setL0FocusPageId(L.DELIVERABLES),E?.setLeftCollapsed(!1),E?.setKeyboardPane("l0");return}if(l==="l"||l==="ArrowRight"){s.preventDefault(),V&&O(!1),E?.keyboardPane!=="l1"&&E?.setKeyboardPane("l1");return}const f=l==="j"||l==="ArrowDown"?1:l==="k"||l==="ArrowUp"?-1:0;if(!f)return;s.preventDefault(),E?.setKeyboardPane("l1"),V&&(Ae.current=!0,O(!1));const d=ge;if(d.length===0)return;const h=r?d.findIndex(w=>w.id===r.id):-1,m=h<0?f>0?-1:0:h,j=Math.max(0,Math.min(d.length-1,m+f));Ft(d[j]),requestAnimationFrame(()=>{document.querySelector(`[data-deliverable-id="${d[j].id}"]`)?.scrollIntoView({block:"nearest"})})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[ge,r,o,x,b,E,V]);const $e=a.useRef(null),as=a.useCallback(t=>{if(!x)return;const s=z.current;!s||s.scrollTop>0||($e.current={y:t.touches[0].clientY,scrollTop:s.scrollTop})},[x]),ls=a.useCallback(t=>{if(!x||!$e.current||We)return;const s=t.changedTouches[0].clientY-$e.current.y;$e.current=null,s>80&&z.current&&z.current.scrollTop<=0&&(pt(!0),Y().finally(()=>pt(!1)))},[x,We,Y]),Ft=t=>{const s=()=>{C(t),_e(!1),K(!1),G(!1),x&&(k(!0),history.pushState({mobileDetail:L.DELIVERABLES},"",window.location.hash))};H?q({action:s}):s()},is=()=>{if(!H){const t=ke??r?.summary??"";ze(t)}K(!0)},os=()=>{H?q({action:()=>{K(!1),G(!1)}}):K(!1)},_t=async()=>{if(!(!r?.reference||Oe)){Ct(!0);try{await p.files.write(r.reference,me),Ne(me),G(!1),K(!1),T("success",n("detail.saved"))}catch(t){T("error",n("detail.saveFailed")+": "+String(t))}Ct(!1)}},cs=()=>{K(!1),G(!1),q(null)};a.useEffect(()=>{if(!H)return;const t=s=>{s.preventDefault()};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[H]),a.useEffect(()=>{if(!H)return;const t=s=>{s.preventDefault(),s.stopImmediatePropagation(),q({action:()=>{K(!1),G(!1);const{page:i,params:l}=s.detail||{};i&&Q.navigate(i,l)}})};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[H]);const Ze=a.useRef(null),et=a.useCallback((t,s)=>{const i=r?.agentId??"",l=r?.id??"",f={};l&&(f.openDeliverable=l);const d=[];if(l){const h=r?.title?.trim()||l,m=h.length>40?`${h.slice(0,24)}…${h.slice(-12)}`:h;d.push({label:`📄 ${m}`,content:["[deliverable]",`ID: ${l}`,`Title: ${r?.title??""}`,r?.reference?`Reference: ${r.reference}`:"",r?.taskId?`Task: ${r.taskId}`:"",r?.projectId?`Project: ${r.projectId}`:""].filter(Boolean).join(`
2
2
  `)})}if(t?.trim()){const h=t.trim().length>40?`${t.trim().slice(0,24)}…${t.trim().slice(-12)}`:t.trim();if(s){const m=r?.reference??"";d.push({label:`🌐 ${h}`,content:["[html-selection]",`Text: "${t.trim()}"`,`CSS Selector: ${s.cssSelector}`,`XPath: ${s.xpath}`,m?`File: ${m}`:""].filter(Boolean).join(`
3
3
  `)})}else d.push({label:`📝 ${h}`,content:t.trim()})}d.length>0&&(f.chatChips=JSON.stringify(d)),i&&(f.agentId=i),Z(null),window.getSelection()?.removeAllRanges(),Q.navigate(L.TEAM,f)},[r]),ds=a.useCallback(t=>{if(!t.text.trim())return;const i=Ze.current?.querySelector("iframe")?.getBoundingClientRect(),l=(i?.left??0)+t.rect.x+t.rect.width/2,f=(i?.top??0)+t.rect.y;Z({x:l,y:f,text:t.text,htmlMeta:{xpath:t.xpath,cssSelector:t.cssSelector}})},[]);return a.useEffect(()=>{const t=Ze.current;if(!t)return;const s=()=>{requestAnimationFrame(()=>{const l=window.getSelection(),f=l?.toString().trim();if(!f||!l?.rangeCount){Z(null);return}const d=l.getRangeAt(0);if(!t.contains(d.commonAncestorContainer)){Z(null);return}const h=d.getBoundingClientRect();Z({x:h.left+h.width/2,y:h.top,text:f})})},i=l=>{const f=document.getElementById("selection-toolbar");f&&f.contains(l.target)||Z(null)};return t.addEventListener("mouseup",s),document.addEventListener("mousedown",i),()=>{t.removeEventListener("mouseup",s),document.removeEventListener("mousedown",i)}},[]),e.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[e.jsxs("div",{ref:Ht,tabIndex:-1,"data-keyboard-pane":"l1",className:`${x?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0 outline-none ${!x&&X==="l1"?"ring-1 ring-inset ring-brand-500/30":""}`,style:x?N?{display:"none"}:void 0:V?{display:"none"}:{width:A.width},children:[e.jsxs("div",{"data-electron-drag":!0,className:"p-4 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[x&&e.jsx(gs,{}),!x&&e.jsx("button",{onClick:()=>O(!0),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",title:n("sidebar.collapse"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[n("title"),v>0&&e.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",v,")"]})]})]})}),e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:Vt,value:ye,onChange:t=>ve(t.target.value),placeholder:n("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg pl-8 pr-8 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),ye&&e.jsx("button",{onClick:()=>{ve(""),je("")},className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 flex items-center justify-center rounded-full bg-surface-overlay text-fg-tertiary hover:text-fg-secondary transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),Ue&&!x&&e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated rounded-lg text-[10px] text-fg-tertiary",children:[e.jsx("span",{className:"truncate font-mono",children:Ue}),e.jsx("button",{onClick:()=>{p.system.openPath(Ue)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:n("common:open")})]}),x&&e.jsxs("button",{onClick:()=>qt(t=>!t),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${He||Me?"bg-brand-500/15 text-brand-500":"bg-surface-elevated text-fg-secondary"}`,children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"12",y1:"18",x2:"20",y2:"18"})]}),n("filters.filtersLabel"),Me&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"}),e.jsx("svg",{className:`w-3 h-3 ml-auto transition-transform ${He?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),e.jsxs("div",{className:x&&!He?"hidden":"space-y-3",children:[e.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[e.jsx(rt,{label:n("filters.allTypes"),value:"",current:B||D||"",onClick:()=>{oe(""),ce("")}}),Cs.map(t=>e.jsx(rt,{label:`${ne[t]?.icon??""} ${t}`,value:t,current:B,onClick:s=>{oe(s),ce("")}},t)),["agent","team","skill"].map(t=>e.jsx(rt,{label:`${F[t].icon} ${n(`artifactTypes.${t}`)}`,value:t,current:D,onClick:s=>{ce(s),oe("")}},t))]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary",children:n("filters.group")}),["date","project","team","agent"].map(t=>e.jsx("button",{onClick:()=>{xt(t)},className:`px-2 py-1 rounded text-xs transition-colors ${R===t?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:n(`groupBy.${t}`)},t)),W.length>1&&e.jsx("button",{onClick:ns,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:n(Pt?"expandAllTooltip":"collapseAllTooltip"),children:n(Pt?"expandAll":"collapseAll")})]})]}),Me&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[ie&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:["“",ie,"”",e.jsx("button",{onClick:()=>{ve(""),je("")},className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),B&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[ne[B]?.icon," ",B,e.jsx("button",{onClick:()=>oe(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),D&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[F[D]?.icon," ",n(`artifactTypes.${D}`),e.jsx("button",{onClick:()=>ce(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("button",{onClick:Dt,className:"text-[10px] text-fg-tertiary hover:text-brand-500 ml-auto transition-colors",children:n("filters.clearAll")})]})]}),De&&e.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${De.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:De.text}),e.jsxs("div",{ref:z,className:"flex-1 overflow-y-auto p-2 space-y-1 transition-opacity duration-150",style:{opacity:_?.5:1},onTouchStart:x?t=>{gt.onTouchStart(t),as(t)}:void 0,onTouchEnd:x?t=>{gt.onTouchEnd(t),ls(t)}:void 0,children:[We&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-brand-500",children:[e.jsx(Ot,{})," ",e.jsx("span",{className:"text-[10px]",children:n("filters.refreshing")})]}),_?e.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(t=>e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},t))}):g.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),Me?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:n("empty.noResults")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:n("empty.noResultsHint")}),e.jsx("button",{onClick:Dt,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:n("filters.clearAll")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:n("empty.title")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:n("empty.subtitle")}),e.jsx("button",{onClick:()=>Q.navigate(L.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:n("empty.goToWork")})]})]}):W.map(([t,s])=>{const i=$t(t);return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>rs(t),className:"w-full flex items-center gap-1.5 px-2 py-2 rounded-md hover:bg-surface-elevated/50 transition-colors group/header border-b border-border-subtle/50",children:[e.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${i?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),e.jsx("span",{className:"text-[11px] font-semibold text-fg-tertiary uppercase tracking-wider truncate",children:s.label}),e.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated px-1.5 py-0.5 rounded-full shrink-0",children:[s.items.length,g.length<v?"+":""]})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-200 ${i?"max-h-0 opacity-0":"max-h-[5000px] opacity-100"}`,children:s.items.map(l=>e.jsx("button",{"data-deliverable-id":l.id,onClick:()=>Ft(l),className:`w-full text-left px-3 py-2 rounded-lg transition-all duration-150 ${r?.id===l.id?X==="l1"?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"bg-brand-600/15 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"hover:bg-surface-elevated/60 border-l-2 border-l-transparent border-y border-r border-transparent"}`,children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[l.artifactType&&F[l.artifactType]?e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${F[l.artifactType].color}`,children:F[l.artifactType].icon}):e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${ne[l.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:ne[l.type]?.icon??l.type.charAt(0)}),e.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:l.title}),S(l)==="published"&&e.jsxs("svg",{className:"shrink-0 text-green-500",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":n("share.published",{defaultValue:"已发布到 Hub"}),children:[e.jsx("title",{children:n("share.published",{defaultValue:"已发布到 Hub"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),S(l)==="pending_review"&&e.jsxs("svg",{className:"shrink-0 text-amber-500 animate-pulse",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":n("share.pendingReview",{defaultValue:"Hub 审核中"}),children:[e.jsx("title",{children:n("share.pendingReview",{defaultValue:"Hub 审核中"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),S(l)==="rejected"&&e.jsxs("svg",{className:"shrink-0 text-red-500",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":n("share.rejected",{defaultValue:"Hub 已拒绝"}),children:[e.jsx("title",{children:n("share.rejected",{defaultValue:"Hub 已拒绝"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),St.has(l.id)&&e.jsx("span",{className:"shrink-0 text-amber-500",title:n("detail.fileMissing"),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),e.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ls(l.updatedAt,n)})]})},l.id))})]},t)}),le&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[e.jsx(Ot,{})," ",e.jsx("span",{className:"text-[10px]",children:n("common:loadingMore")})]}),!_&&g.length>0&&e.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:g.length<v?n("count.partial",{loaded:g.length,total:v}):n("count.total",{total:v})})]})]}),!x&&e.jsx("div",{className:"w-2 shrink-0 cursor-col-resize group relative flex items-center justify-center hover:bg-brand-500/5 transition-colors",onMouseDown:A.onResizeStart,children:e.jsxs("div",{className:"flex flex-col gap-1 items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),e.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"})]})}),(!x||N)&&e.jsxs("div",{"data-no-drag":!0,className:"flex-1 overflow-hidden min-w-0 flex relative self-stretch",children:[e.jsxs("div",{ref:Ze,className:"flex-1 overflow-y-auto min-w-0 h-full",children:[V&&!x&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-primary/80 backdrop-blur-sm px-4 py-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{Ae.current=!0,O(!1)},className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",title:n("sidebar.expand"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:r?.title??n("detail.details")})]}),x&&e.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary px-4 py-2.5 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",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("polyline",{points:"15 18 9 12 15 6"})})}),e.jsx("span",{className:"text-sm font-medium truncate",children:r?.title??n("detail.details")})]}),r?e.jsxs("div",{className:"p-6 space-y-4",children:[!o&&St.has(r.id)&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/20 rounded-lg text-amber-600 text-xs",children:[e.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("span",{children:n("detail.fileMissing")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:r.title}),!o&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("button",{onClick:()=>_e(!0),title:n("share.title",{defaultValue:"分享到 Markus Hub"}),"aria-label":n("share.title",{defaultValue:"分享到 Markus Hub"}),className:`relative p-1.5 rounded-lg transition-colors ${S(r)==="published"?"text-green-500 hover:text-green-400 hover:bg-green-500/10":S(r)==="pending_review"?"text-amber-500 hover:text-amber-400 hover:bg-amber-500/10":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),S(r)==="published"||S(r)==="pending_review"||S(r)==="rejected"?e.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 rounded-full border border-surface-primary ${S(r)==="published"?"bg-green-500":S(r)==="pending_review"?"bg-amber-500 animate-pulse":"bg-red-500"}`,"aria-hidden":!0}):null]}),e.jsx("button",{onClick:()=>Ce(r),disabled:!!ht,className:"p-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 shrink-0",title:n("common:remove"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${ne[r.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[ne[r.type]?.icon??""," ",r.type]}),r.artifactType&&F[r.artifactType]&&e.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${F[r.artifactType].color}`,children:[F[r.artifactType].icon," ",n("detail.builderWithType",{type:n(`artifactTypes.${r.artifactType}`)})]}),r.tags.length>0&&r.tags.map(t=>e.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:t},t)),S(r)==="published"&&e.jsxs("a",{href:r.shareUrl??void 0,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-green-500/15 text-green-600 hover:bg-green-500/25 hover:underline",title:r.shareUrl??void 0,children:[e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),n("share.published",{defaultValue:"已发布"})]}),S(r)==="pending_review"&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-amber-500/15 text-amber-500",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500 animate-pulse"}),n("share.pendingReview",{defaultValue:"审核中"})]}),S(r)==="rejected"&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium bg-red-500/15 text-red-500",title:r.shareReason??void 0,children:[n("share.rejected",{defaultValue:"已拒绝"}),r.shareReason?e.jsxs("span",{className:"text-red-400/90 font-normal",children:["— ",r.shareReason]}):null]})]}),(r.taskId||r.agentId||Ie(r.projectId))&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.taskId&&e.jsx("button",{onClick:()=>Q.navigate(L.WORK,{openTask:r.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2 py-0.5 rounded",children:n("links.task",{id:`${r.taskId.slice(0,12)}...`})}),r.agentId&&e.jsx("button",{onClick:()=>Q.navigate(L.TEAM,{selectAgent:r.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:n("links.agent",{name:Le.get(r.agentId)?.name??r.agentId.slice(0,12)})}),Ie(r.projectId)&&e.jsx("button",{onClick:()=>Q.navigate(L.WORK,{projectId:r.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:n("links.project",{name:Ie(r.projectId)})})]}),(r.diffStats||r.testResults)&&e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[r.diffStats&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[n("diffStats.title"),":"]}),e.jsx("span",{className:"text-fg-secondary",children:n("diffStats.files",{count:r.diffStats.filesChanged})}),e.jsxs("span",{className:"text-green-600",children:["+",r.diffStats.additions]}),e.jsxs("span",{className:"text-red-500",children:["-",r.diffStats.deletions]})]}),r.testResults&&e.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[e.jsxs("span",{className:"text-fg-tertiary font-medium",children:[n("testResults.title"),":"]}),e.jsx("span",{className:"text-green-600",children:n("testResults.passed",{count:r.testResults.passed})}),e.jsx("span",{className:"text-red-500",children:n("testResults.failed",{count:r.testResults.failed})}),e.jsx("span",{className:"text-fg-secondary",children:n("testResults.skipped",{count:r.testResults.skipped})})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap",children:[e.jsxs("span",{children:[n("metadata.created")," ",new Date(r.createdAt).toLocaleString()]}),e.jsxs("span",{children:[n("metadata.updated")," ",new Date(r.updatedAt).toLocaleString()]}),e.jsx("span",{className:"text-fg-muted select-all",children:r.id.slice(0,12)})]}),r.reference&&!Be(r.reference)&&r.type==="file"&&e.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[e.jsx("button",{onClick:()=>{p.files.reveal(r.reference).catch(()=>T("error",n("detail.failedToOpenBrowser")))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:n("detail.openInFileBrowser"),children:r.reference}),e.jsx("button",{onClick:()=>{p.files.reveal(r.reference).catch(()=>T("error",n("detail.failedToOpenBrowser")))},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",title:n("detail.revealInFinder"),children:n("common:open")}),e.jsx("button",{onClick:()=>Rt(r.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Se?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:n("detail.copyPath"),children:n(Se?"common:copied":"common:copy")})]}),r.reference&&!Be(r.reference)&&r.type!=="file"&&r.type!=="directory"&&e.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:r.reference})]}),r.artifactType&&r.artifactData?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Ss,{artifact:r.artifactData,mode:r.artifactType})}),r.reference&&e.jsxs("div",{className:"px-3 py-2 bg-surface-elevated rounded-lg",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:n("detail.artifactDirectory")}),e.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:r.reference})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("button",{onClick:ss,className:"flex-1 px-4 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:n("detail.openInBuilder")})}),r.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Pe,{content:r.summary,className:"text-fg-secondary text-sm"})})]}):r.reference&&Be(r.reference)?e.jsxs("div",{className:"space-y-4",children:[r.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Pe,{content:r.summary,className:"text-fg-secondary text-sm"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsxs("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),e.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:r.reference}),e.jsx("button",{onClick:()=>window.open(r.reference,"_blank","noopener,noreferrer"),className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:n("detail.openUrl")})]})]}):r.type==="directory"&&r.reference?e.jsxs("div",{className:"space-y-4",children:[r.summary&&e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsx(Pe,{content:r.summary,className:"text-fg-secondary text-sm"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsx("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:r.reference}),e.jsx("button",{onClick:()=>{p.files.reveal(r.reference).catch(()=>T("error",n("detail.failedToOpenBrowser")))},className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:n("detail.openInFileBrowser")})]})]}):e.jsxs("div",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:[(ke||r.summary)&&!jt&&!ue&&!Nt&&r.reference&&r.type==="file"&&(we==="markdown"||we==="text"||we==="html")&&e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border-subtle bg-surface-secondary/50",children:[e.jsx("button",{onClick:os,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${ee?"text-fg-tertiary hover:text-fg-secondary":"bg-brand-600/20 text-brand-500"}`,children:n("detail.preview")}),e.jsx("button",{onClick:is,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${ee?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:n("detail.edit")}),e.jsx("div",{className:"flex-1"}),ee&&e.jsx("button",{onClick:_t,disabled:!H||Oe,className:"px-3 py-1 rounded text-xs font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:n(Oe?"detail.saving":"detail.save")})]}),e.jsx("div",{className:"p-5",children:jt?e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-full"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-5/6"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-4/6"}),e.jsx("div",{className:"h-32 bg-surface-overlay/40 rounded-lg w-full mt-2"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-2/3"})]}):ue?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("img",{src:ue.src,alt:ue.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:ue.name})]}):xe?e.jsxs("div",{className:"flex flex-col gap-3 py-4",children:[xe.kind==="audio"?e.jsx("audio",{controls:!0,preload:"metadata",src:xe.src,className:"w-full"}):e.jsx("video",{controls:!0,preload:"metadata",src:xe.src,className:"w-full max-h-[60vh] rounded-lg bg-black"}),e.jsx("span",{className:"text-xs text-fg-tertiary",children:xe.name})]}):ke?ee?e.jsx("div",{className:"animate-fadeIn",children:e.jsx("textarea",{ref:Ge,value:me,onChange:t=>{ze(t.target.value),G(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1})},"edit"):e.jsx("div",{className:"animate-fadeIn",children:e.jsx(js,{content:ke,format:we,className:"text-fg-secondary text-sm",onHtmlSelection:ds,basePath:r?.reference?r.reference.replace(/[/\\][^/\\]+$/,""):void 0})},"preview"):Nt?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:n("detail.cannotPreview",{type:r.type})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{p.files.reveal(r.reference).catch(()=>T("error",n("detail.failedToOpen")))},className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:n("detail.openInFileBrowser"),children:r.reference}),e.jsx("button",{onClick:()=>{p.files.reveal(r.reference).catch(()=>T("error",n("detail.failedToOpen")))},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:n("common:open")}),e.jsx("button",{onClick:()=>Rt(r.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Se?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:n(Se?"common:copied":"common:copy")})]})]}):r.summary?ee?e.jsx("textarea",{ref:Ge,value:me,onChange:t=>{ze(t.target.value),G(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1}):e.jsx(Pe,{content:r.summary,className:"text-fg-secondary text-sm"}):e.jsx("p",{className:"text-sm text-fg-tertiary italic",children:n("detail.noContent")})})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center text-fg-tertiary space-y-3 max-w-xs",children:[e.jsx("div",{className:"w-16 h-16 mx-auto rounded-2xl bg-surface-elevated/60 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),e.jsx("p",{className:"text-sm text-fg-secondary",children:n("detail.selectToView")}),!x&&e.jsx("p",{className:"text-[10px] text-fg-muted",children:n("detail.keyboardHint")})]})})]}),r?.agentId&&!x&&e.jsx("button",{type:"button",onClick:()=>et(),className:"absolute bottom-6 right-6 z-20 w-12 h-12 rounded-full bg-brand-600 hover:bg-brand-500 text-white shadow-lg shadow-black/20 flex items-center justify-center transition-transform hover:scale-105 animate-fab-in",title:n("chat.openChat",{defaultValue:"Open in Team Chat"}),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"})})})]}),he&&e.jsx("div",{id:"selection-toolbar",className:"fixed z-50 -translate-x-1/2 -translate-y-full bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden",style:{left:he.x,top:he.y-8},children:e.jsxs("button",{onMouseDown:t=>{t.preventDefault(),t.stopPropagation(),et(he.text,he.htmlMeta)},className:"px-3 py-1.5 text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-1.5 whitespace-nowrap",children:[e.jsx("svg",{width:"12",height:"12",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"})}),n("contextMenu.addToConversation")]})}),Jt&&r&&e.jsx(Ns,{item:r,onClose:()=>_e(!1),onShared:ts}),Fe&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>Ce(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:n("detail.confirmRemoveTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:n("detail.confirmRemoveMessage",{name:Fe.title})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>Ce(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:n("common:cancel")}),e.jsx("button",{onClick:()=>{const t=Fe;Ce(null),es(t)},disabled:!!ht,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors disabled:opacity-50",children:n("common:remove")})]})]})}),Ke&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>q(null),children:e.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{className:"w-5 h-5 text-amber-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary",children:n("detail.unsavedTitle")}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:n("detail.unsavedMessage")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>q(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:n("common:cancel")}),e.jsx("button",{onClick:()=>{cs(),Ke.action()},className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:n("detail.discard")}),e.jsx("button",{onClick:async()=>{await _t(),Ke.action(),q(null)},className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",children:n("detail.saveAndLeave")})]})]})})]})}function rt({label:u,value:o,current:c,onClick:n}){return e.jsx("button",{onClick:()=>n(c===o?"":o),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${c===o?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:u})}function Ot(){return e.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}export{Ts as DeliverablesPage};
@@ -1 +1 @@
1
- import{u as o,a as l,j as e,M as t,N as n}from"./index-CiAGgfZx.js";function r({authUser:s}){const{t:a}=o("nav"),i=l();return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{"data-electron-drag":!0,className:"flex items-center gap-2 px-4 h-14",children:[i&&e.jsx(t,{}),e.jsx("h2",{className:"text-base font-bold",children:a("notifications")})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(n,{collapsed:!1,userId:s?.id,embeddedMode:!0})})]})}export{r as NotificationsPage};
1
+ import{u as o,a as l,j as e,M as t,N as n}from"./index-B1VN5yM1.js";function r({authUser:s}){const{t:a}=o("nav"),i=l();return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{"data-electron-drag":!0,className:"flex items-center gap-2 px-4 h-14",children:[i&&e.jsx(t,{}),e.jsx("h2",{className:"text-base font-bold",children:a("notifications")})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(n,{collapsed:!1,userId:s?.id,embeddedMode:!0})})]})}export{r as NotificationsPage};
@@ -1 +1 @@
1
- import{u as I,r as i,l as c,j as e,n as d,P as x,A as O}from"./index-CiAGgfZx.js";function D(){const{t:l}=I(["common","home","work"]),[u,y]=i.useState(""),[r,o]=i.useState("all"),[t,m]=i.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[h,b]=i.useState(!1),[w,p]=i.useState(!1),v=i.useRef(null),j=i.useRef(void 0);i.useEffect(()=>{setTimeout(()=>v.current?.focus(),100)},[]);const W=i.useCallback(async s=>{if(!s.trim()){m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1);return}b(!0),p(!0);const n=s.toLowerCase();try{const[N,C,V,R,L,A]=await Promise.allSettled([c.agents.list(),c.tasks.list({search:s,pageSize:20}),c.requirements.list(),c.projects.list(),c.deliverables.search({q:s,limit:20}),c.teams.list()]),E=N.status==="fulfilled"?N.value.agents.filter(a=>a.name?.toLowerCase().includes(n)||a.role?.toLowerCase().includes(n)):[],M=C.status==="fulfilled"?C.value.tasks:[],H=V.status==="fulfilled"?V.value.requirements.filter(a=>a.title?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],T=R.status==="fulfilled"?R.value.projects.filter(a=>a.name?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],z=L.status==="fulfilled"?L.value.results:[],S=[];if(A.status==="fulfilled"){const a=await Promise.allSettled(A.value.teams.map(f=>c.workflows.list(f.id)));for(const f of a)if(f.status==="fulfilled")for(const g of f.value.workflows)(g.name.toLowerCase().includes(n)||(g.displayName||"").toLowerCase().includes(n)||g.description?.toLowerCase().includes(n))&&S.push(g)}m({agents:E,tasks:M,requirements:H,projects:T,deliverables:z,workflows:S})}catch{m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{b(!1)}},[]),B=s=>{y(s),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>W(s),400)},q=[{id:"all",label:l("common:all",{defaultValue:"全部"})},{id:"agents",label:l("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:l("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:l("common:requirements",{defaultValue:"需求"})},{id:"projects",label:l("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:l("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:l("common:workflows",{defaultValue:"工作流"})}],k=t.agents.length>0||t.tasks.length>0||t.requirements.length>0||t.projects.length>0||t.deliverables.length>0||t.workflows.length>0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>d.navigate(x.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 12H5"}),e.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),e.jsxs("div",{className:"flex-1 relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:v,value:u,onChange:s=>B(s.target.value),placeholder:l("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),u&&e.jsx("button",{onClick:()=>{y(""),m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1),v.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:q.map(s=>e.jsx("button",{onClick:()=>o(s.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${r===s.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:s.label},s.id))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[h&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:l("common:loading")})}),!h&&w&&!k&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&k&&e.jsxs("div",{className:"space-y-4",children:[(r==="all"||r==="agents")&&t.agents.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:agents",{defaultValue:"智能体"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.agents.slice(0,8):t.agents).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.TEAM,{agentId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(O,{name:s.name||"Agent",avatarUrl:s.avatarUrl,size:32}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:s.name}),e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.role||s.status})]}),e.jsx(P,{status:s.status})]},s.id))}),r==="all"&&t.agents.length>8&&e.jsxs("button",{onClick:()=>o("agents"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.agents.length,")"]})]}),(r==="all"||r==="tasks")&&t.tasks.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:tasks",{defaultValue:"任务"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.tasks.slice(0,8):t.tasks).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openTask:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(K,{status:s.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.tasks.length>8&&e.jsxs("button",{onClick:()=>o("tasks"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.tasks.length,")"]})]}),(r==="all"||r==="requirements")&&t.requirements.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:requirements",{defaultValue:"需求"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.requirements.slice(0,8):t.requirements).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openRequirement:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${s.status==="approved"?"text-green-500 bg-green-500/15":s.status==="pending"?"text-amber-500 bg-amber-500/15":s.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.requirements.length>8&&e.jsxs("button",{onClick:()=>o("requirements"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.requirements.length,")"]})]}),(r==="all"||r==="projects")&&t.projects.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:projects",{defaultValue:"项目"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.projects.slice(0,8):t.projects).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{projectId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.name}),s.description&&e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.description})]})]},s.id))}),r==="all"&&t.projects.length>8&&e.jsxs("button",{onClick:()=>o("projects"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.projects.length,")"]})]}),(r==="all"||r==="deliverables")&&t.deliverables.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:deliverables",{defaultValue:"交付物"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.deliverables.slice(0,8):t.deliverables).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.DELIVERABLES,{openDeliverable:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.type," · ",s.status]})]})]},s.id))}),r==="all"&&t.deliverables.length>8&&e.jsxs("button",{onClick:()=>o("deliverables"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.deliverables.length,")"]})]}),(r==="all"||r==="workflows")&&t.workflows.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:workflows",{defaultValue:"工作流"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.workflows.slice(0,8):t.workflows).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{boardType:"workflows"}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.displayName||s.name}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.stepCount," steps · v",s.version]})]})]},s.name))}),r==="all"&&t.workflows.length>8&&e.jsxs("button",{onClick:()=>o("workflows"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.workflows.length,")"]})]})]}),!h&&!w&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:search")})]})]})]})}function P({status:l}){const u=l==="active"||l==="idle"?"bg-green-500":l==="working"||l==="busy"?"bg-blue-500":"bg-gray-400";return e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u}`})}function K({status:l}){const u=l==="completed"?"text-green-500 bg-green-500/15":l==="in_progress"?"text-blue-500 bg-blue-500/15":l==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${u}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}export{D as SearchPage};
1
+ import{u as I,r as i,l as c,j as e,n as d,P as x,A as O}from"./index-B1VN5yM1.js";function D(){const{t:l}=I(["common","home","work"]),[u,y]=i.useState(""),[r,o]=i.useState("all"),[t,m]=i.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[h,b]=i.useState(!1),[w,p]=i.useState(!1),v=i.useRef(null),j=i.useRef(void 0);i.useEffect(()=>{setTimeout(()=>v.current?.focus(),100)},[]);const W=i.useCallback(async s=>{if(!s.trim()){m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1);return}b(!0),p(!0);const n=s.toLowerCase();try{const[N,C,V,R,L,A]=await Promise.allSettled([c.agents.list(),c.tasks.list({search:s,pageSize:20}),c.requirements.list(),c.projects.list(),c.deliverables.search({q:s,limit:20}),c.teams.list()]),E=N.status==="fulfilled"?N.value.agents.filter(a=>a.name?.toLowerCase().includes(n)||a.role?.toLowerCase().includes(n)):[],M=C.status==="fulfilled"?C.value.tasks:[],H=V.status==="fulfilled"?V.value.requirements.filter(a=>a.title?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],T=R.status==="fulfilled"?R.value.projects.filter(a=>a.name?.toLowerCase().includes(n)||a.description?.toLowerCase().includes(n)):[],z=L.status==="fulfilled"?L.value.results:[],S=[];if(A.status==="fulfilled"){const a=await Promise.allSettled(A.value.teams.map(f=>c.workflows.list(f.id)));for(const f of a)if(f.status==="fulfilled")for(const g of f.value.workflows)(g.name.toLowerCase().includes(n)||(g.displayName||"").toLowerCase().includes(n)||g.description?.toLowerCase().includes(n))&&S.push(g)}m({agents:E,tasks:M,requirements:H,projects:T,deliverables:z,workflows:S})}catch{m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{b(!1)}},[]),B=s=>{y(s),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>W(s),400)},q=[{id:"all",label:l("common:all",{defaultValue:"全部"})},{id:"agents",label:l("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:l("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:l("common:requirements",{defaultValue:"需求"})},{id:"projects",label:l("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:l("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:l("common:workflows",{defaultValue:"工作流"})}],k=t.agents.length>0||t.tasks.length>0||t.requirements.length>0||t.projects.length>0||t.deliverables.length>0||t.workflows.length>0;return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>d.navigate(x.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 12H5"}),e.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),e.jsxs("div",{className:"flex-1 relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:v,value:u,onChange:s=>B(s.target.value),placeholder:l("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),u&&e.jsx("button",{onClick:()=>{y(""),m({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),p(!1),v.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:q.map(s=>e.jsx("button",{onClick:()=>o(s.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${r===s.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:s.label},s.id))})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[h&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:l("common:loading")})}),!h&&w&&!k&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&k&&e.jsxs("div",{className:"space-y-4",children:[(r==="all"||r==="agents")&&t.agents.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:agents",{defaultValue:"智能体"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.agents.slice(0,8):t.agents).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.TEAM,{agentId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(O,{name:s.name||"Agent",avatarUrl:s.avatarUrl,size:32}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:s.name}),e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.role||s.status})]}),e.jsx(P,{status:s.status})]},s.id))}),r==="all"&&t.agents.length>8&&e.jsxs("button",{onClick:()=>o("agents"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.agents.length,")"]})]}),(r==="all"||r==="tasks")&&t.tasks.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:tasks",{defaultValue:"任务"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.tasks.slice(0,8):t.tasks).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openTask:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx(K,{status:s.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.tasks.length>8&&e.jsxs("button",{onClick:()=>o("tasks"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.tasks.length,")"]})]}),(r==="all"||r==="requirements")&&t.requirements.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:requirements",{defaultValue:"需求"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.requirements.slice(0,8):t.requirements).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{openRequirement:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${s.status==="approved"?"text-green-500 bg-green-500/15":s.status==="pending"?"text-amber-500 bg-amber-500/15":s.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.status," · ",s.priority||""]})]})]},s.id))}),r==="all"&&t.requirements.length>8&&e.jsxs("button",{onClick:()=>o("requirements"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.requirements.length,")"]})]}),(r==="all"||r==="projects")&&t.projects.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:projects",{defaultValue:"项目"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.projects.slice(0,8):t.projects).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{projectId:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.name}),s.description&&e.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:s.description})]})]},s.id))}),r==="all"&&t.projects.length>8&&e.jsxs("button",{onClick:()=>o("projects"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.projects.length,")"]})]}),(r==="all"||r==="deliverables")&&t.deliverables.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:deliverables",{defaultValue:"交付物"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.deliverables.slice(0,8):t.deliverables).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.DELIVERABLES,{openDeliverable:s.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.title}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.type," · ",s.status]})]})]},s.id))}),r==="all"&&t.deliverables.length>8&&e.jsxs("button",{onClick:()=>o("deliverables"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.deliverables.length,")"]})]}),(r==="all"||r==="workflows")&&t.workflows.length>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:l("common:workflows",{defaultValue:"工作流"})}),e.jsx("div",{className:"space-y-1",children:(r==="all"?t.workflows.slice(0,8):t.workflows).map(s=>e.jsxs("button",{onClick:()=>d.navigate(x.WORK,{boardType:"workflows"}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-fg-primary truncate",children:s.displayName||s.name}),e.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[s.stepCount," steps · v",s.version]})]})]},s.name))}),r==="all"&&t.workflows.length>8&&e.jsxs("button",{onClick:()=>o("workflows"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[l("common:showAll",{defaultValue:"查看全部"})," (",t.workflows.length,")"]})]})]}),!h&&!w&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("p",{className:"text-sm text-fg-tertiary",children:l("common:search")})]})]})]})}function P({status:l}){const u=l==="active"||l==="idle"?"bg-green-500":l==="working"||l==="busy"?"bg-blue-500":"bg-gray-400";return e.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${u}`})}function K({status:l}){const u=l==="completed"?"text-green-500 bg-green-500/15":l==="in_progress"?"text-blue-500 bg-blue-500/15":l==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${u}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}export{D as SearchPage};
@@ -1,4 +1,4 @@
1
- import{u as pe,r as i,j as e,D as Pn,v as xa,l as V,a as ma,b as ga,c as fa,W as Lr,n as ns,X as pa,Y as Rr,P as Br,h as Ve,i as ha,Z as An,w as ba,o as as,t as Os,_ as ya}from"./index-CiAGgfZx.js";function va(s,r){for(var o=0;o<r.length;o++){const n=r[o];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in s)){const t=Object.getOwnPropertyDescriptor(n,a);t&&Object.defineProperty(s,a,t.get?t:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}function ja(s){return s>=1e6?`${(s/1e6).toFixed(s%1e6===0?0:1)}M`:s>=1e3?`${(s/1e3).toFixed((s%1e3===0,0))}K`:String(s)}function Na(s){return s.maxInputTokens>0||s.inputCostPer1MTokens>0||s.outputCostPer1MTokens>0}function os(s){if(s.tier)return s.tier;const r=s.id.toLowerCase(),o=/opus|5\.4|o3-(?!mini)|o1-(?!mini)|gemini.*ultra|sonnet-4-20/,n=/haiku|flash|nano|lite|small|fast|free|8b|7b|1b|3b/;return/o4-mini|o3-mini|o1-mini|gpt-4o-mini/.test(r)?"pro":o.test(r)?"max":n.test(r)?"base":"pro"}const Or={max:"bg-purple-500/20 text-purple-400 border-purple-500/30",pro:"bg-blue-500/20 text-blue-400 border-blue-500/30",base:"bg-gray-500/20 text-gray-400 border-gray-500/30"};function Mn({models:s,selectedModel:r,onSelect:o,loading:n,compact:a,maxVisible:t,showTiers:d}){const{t:u}=pe("settings"),[x,f]=i.useState(""),[v,T]=i.useState(!1),[m,C]=i.useState(""),w=i.useMemo(()=>{let g=s;if(x){const j=x.toLowerCase();g=g.filter(S=>S.id.toLowerCase().includes(j))}return m&&(g=g.filter(j=>os(j)===m)),g},[s,x,m]),h=i.useMemo(()=>{const g={max:0,pro:0,base:0};for(const j of s)g[os(j)]++;return g},[s]),U=t??(a?5:10),y=v?w:w.slice(0,U),A=w.length>U;return n?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-tertiary",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin"}),u("modelPicker.loading")]}):s.length===0?e.jsx("div",{className:"py-3 text-sm text-fg-tertiary",children:u("modelPicker.empty")}):e.jsxs("div",{className:"space-y-2",children:[d&&s.length>3&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>C(""),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${m?"bg-surface-overlay text-fg-tertiary hover:text-fg-secondary":"bg-brand-500/20 text-brand-500"}`,children:u("modelPicker.allCount",{count:s.length})}),["max","pro","base"].filter(g=>h[g]>0).map(g=>e.jsx("button",{onClick:()=>C(m===g?"":g),className:`px-2 py-0.5 rounded text-[10px] font-medium uppercase transition-colors border ${m===g?Or[g]:"border-transparent bg-surface-overlay text-fg-tertiary hover:text-fg-secondary"}`,children:u("modelPicker.tierCount",{tier:u(`modelRouting.tier.${g}`),count:h[g]})},g))]}),s.length>5&&e.jsx("input",{type:"text",value:x,onChange:g=>{f(g.target.value),T(!1)},placeholder:u("modelPicker.filterPlaceholder"),className:"w-full px-3 py-1.5 bg-surface-overlay border border-border-default rounded-lg text-xs text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500"}),e.jsx("div",{className:`space-y-1 ${a?"max-h-[280px] overflow-y-auto":""}`,children:y.map(g=>{const j=g.id===r,S=os(g);return e.jsxs("button",{type:"button",onClick:()=>o(g.id),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${j?"bg-brand-500/10 border border-brand-500/30":"hover:bg-surface-overlay border border-transparent"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full border-2 flex items-center justify-center ${j?"border-brand-500":"border-border-default"}`,children:j&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"})}),e.jsx("span",{className:`text-xs font-medium ${j?"text-brand-500":"text-fg-primary"}`,children:g.id}),d&&e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase border ${Or[S]}`,children:u(`modelRouting.tier.${S}`)})]}),e.jsx("div",{className:"flex items-center gap-2",children:j&&e.jsx("span",{className:"text-[10px] text-brand-500 font-medium",children:u("modelPicker.active")})})]}),Na(g)&&g.maxInputTokens>0&&e.jsx("div",{className:"ml-5 mt-0.5 flex items-center gap-2 text-[10px] text-fg-tertiary flex-wrap",children:e.jsxs("span",{children:[ja(g.maxInputTokens)," ",u("modelPicker.ctx")]})}),!a&&e.jsxs("div",{className:"ml-5 mt-1 flex items-center gap-1.5 flex-wrap",children:[g.capabilities.functionCalling&&e.jsx(lt,{label:u("modelPicker.capabilities.tools")}),g.capabilities.vision&&e.jsx(lt,{label:u("modelPicker.capabilities.vision")}),g.capabilities.reasoning&&e.jsx(lt,{label:u("modelPicker.capabilities.reasoning")}),g.capabilities.promptCaching&&e.jsx(lt,{label:u("modelPicker.capabilities.caching")}),g.capabilities.webSearch&&e.jsx(lt,{label:u("modelPicker.capabilities.search")})]})]},g.id)})}),A&&!v&&e.jsx("button",{type:"button",onClick:()=>T(!0),className:"text-xs text-brand-500 hover:text-brand-400 px-3",children:u("modelPicker.showAll",{count:w.length})}),v&&A&&e.jsx("button",{type:"button",onClick:()=>T(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary px-3",children:u("modelPicker.showLess")})]})}function lt({label:s}){return e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] bg-surface-overlay text-fg-tertiary border border-border-default",children:s})}function _s({value:s,options:r,placeholder:o,onChange:n}){const{t:a}=pe("settings"),[t,d]=i.useState(!1),[u,x]=i.useState(""),f=i.useRef(null),v=i.useRef(null),T=i.useRef(null),[m,C]=i.useState(-1);i.useEffect(()=>{function g(j){f.current&&!f.current.contains(j.target)&&d(!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),i.useEffect(()=>{t&&v.current&&v.current.focus()},[t]);const w=i.useMemo(()=>{if(!u.trim())return r;const g=u.toLowerCase();return r.filter(j=>j.modelId.toLowerCase().includes(g)||j.modelName.toLowerCase().includes(g)||j.provider.toLowerCase().includes(g)||j.providerLabel.toLowerCase().includes(g)||j.tier&&j.tier.toLowerCase().includes(g))},[r,u]),h=i.useMemo(()=>{const g=new Map;for(const S of w){const R=S.providerLabel;g.has(R)||g.set(R,[]),g.get(R).push(S)}const j={max:0,pro:1,base:2};for(const S of g.values())S.sort((R,E)=>(j[R.tier??"base"]??9)-(j[E.tier??"base"]??9));return g},[w]),U=i.useMemo(()=>{const g=[];for(const j of h.values())g.push(...j);return g},[h]),y=i.useMemo(()=>{if(!s)return o??a("modelRouting.auto");const g=r.find(j=>`${j.provider}/${j.modelId}`===s);return g?`${g.providerLabel}/${g.modelName}`:s},[s,r,o,a]);function A(g){if(!t){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),d(!0));return}switch(g.key){case"ArrowDown":g.preventDefault(),C(j=>Math.min(j+1,U.length-1));break;case"ArrowUp":g.preventDefault(),C(j=>Math.max(j-1,-1));break;case"Enter":g.preventDefault(),m===-1?n(""):U[m]&&n(`${U[m].provider}/${U[m].modelId}`),d(!1),x("");break;case"Escape":d(!1),x("");break}}return i.useEffect(()=>{T.current&&m>=0&&T.current.querySelector(`[data-focus-index="${m}"]`)?.scrollIntoView({block:"nearest"})},[m]),e.jsxs("div",{ref:f,className:"relative",onKeyDown:A,children:[e.jsx("button",{type:"button",onClick:()=>{d(!t),x(""),C(-1)},className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary text-left truncate focus:outline-none focus:border-brand-500",children:y}),t&&e.jsxs("div",{className:"absolute z-50 mt-1 w-full min-w-[240px] max-h-[280px] bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden flex flex-col",children:[e.jsx("div",{className:"p-1.5 border-b border-border-default",children:e.jsx("input",{ref:v,type:"text",value:u,onChange:g=>{x(g.target.value),C(-1)},placeholder:a("modelPicker.searchPlaceholder")||"Search models...",className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary focus:outline-none focus:border-brand-500"})}),e.jsxs("div",{ref:T,className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:`px-3 py-1.5 text-xs cursor-pointer ${m===-1?"bg-brand-500/20 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,onClick:()=>{n(""),d(!1),x("")},children:o??a("modelRouting.auto")}),[...h.entries()].map(([g,j])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1 text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider bg-surface-overlay/50 sticky top-0",children:g}),j.map(S=>{const R=U.indexOf(S),E=`${S.provider}/${S.modelId}`===s;return e.jsxs("div",{"data-focus-index":R,className:`px-3 py-1.5 text-xs cursor-pointer flex items-center gap-2 ${R===m?"bg-brand-500/20":E?"bg-surface-overlay":"hover:bg-surface-overlay/50"}`,onClick:()=>{n(`${S.provider}/${S.modelId}`),d(!1),x("")},children:[e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:S.modelName}),S.tier&&e.jsx(wa,{tier:S.tier}),S.costTier&&e.jsx("span",{className:"text-[9px] text-fg-tertiary",children:S.costTier})]},`${S.provider}/${S.modelId}`)})]},g)),U.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-fg-tertiary text-center",children:a("modelPicker.empty")})]})]})]})}function wa({tier:s}){const r={max:"bg-purple-500/20 text-purple-400",pro:"bg-blue-500/20 text-blue-400",base:"bg-gray-500/20 text-gray-400"};return e.jsx("span",{className:`px-1 py-0.5 rounded text-[8px] font-bold uppercase ${r[s]??r.base}`,children:s})}const ka=500,_r=[{groupKey:"image",capabilities:["image_recognition","image_generation"]},{groupKey:"audio",capabilities:["audio_tts","audio_stt"]},{groupKey:"video",capabilities:["video_generation"]}];function Ca({onSave:s,configuredProviders:r}){const{t:o}=pe(["settings","common"]),[n,a]=i.useState({}),[t,d]=i.useState(null),[u,x]=i.useState(!1),[f,v]=i.useState(null),[T,m]=i.useState(!0),[C,w]=i.useState("idle"),[h,U]=i.useState(null),[y,A]=i.useState({}),[g,j]=i.useState(!1),[S,R]=i.useState("idle"),[E,B]=i.useState(null),[K,_]=i.useState(!1),O=i.useRef(null),F=i.useRef(null),b=i.useMemo(()=>r.map(c=>c.name).sort().join(","),[r]);i.useEffect(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{a(c.capabilityRouting?.assignments??{}),d(c.routingDefaultModel??null),x(!0)}).catch(c=>{v(String(c)),x(!0)})},[b]),i.useEffect(()=>{let c=!1;return m(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>{if(c)return;const D=[];for(const $ of k.providers)for(const W of $.models)D.push({provider:$.provider,providerLabel:$.displayName,modelId:W.id,modelName:W.name,mode:W.mode,tier:W.tier,costTier:W.costTier,capabilities:W.capabilities});U(D)}).catch(()=>{c||U(null)}).finally(()=>{c||m(!1)}),()=>{c=!0}},[b]),i.useEffect(()=>{fetch("/api/models/suggested-assignments",{credentials:"include"}).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{A(c.suggestions),j(!0)}).catch(()=>j(!0))},[b]);const P=i.useCallback(c=>{w("saving"),s(c).then(()=>{w("saved"),setTimeout(()=>w(k=>k==="saved"?"idle":k),2e3)}).catch(()=>{w("error"),setTimeout(()=>w(k=>k==="error"?"idle":k),3e3)})},[s]),M=i.useCallback((c,k)=>{F.current={capabilityRouting:c!==void 0?{assignments:c}:F.current?.capabilityRouting,routingDefaultModel:k!==void 0?k:F.current?.routingDefaultModel},O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{const D=F.current;F.current=null,D&&P(D)},ka)},[P]),q=i.useMemo(()=>r.flatMap(c=>(c.models??[{id:c.model,name:c.model}]).map(k=>({provider:c.name,providerLabel:c.displayName??c.name,modelId:k.id,modelName:k.name}))),[r]),Q=h??q,re=i.useMemo(()=>Object.entries(n).map(([c,k])=>`${c}:${k?.provider??""}/${k?.model??""}`).sort().join("|"),[n]);i.useEffect(()=>{!u||!h||h.length===0||h.some(c=>!!c.modelId)&&(a(c=>{let k=!1;const D={...c};for(const $ of _r)for(const W of $.capabilities){const Z=D[W];if(!Z?.model)continue;const X=Tn(h,W);if(X.length===0)continue;X.some(ce=>ce.provider===Z.provider&&ce.modelId===Z.model)||(delete D[W],k=!0)}return k?(M(D),D):c}),d(c=>{if(!c?.model||h.some(W=>W.provider===c.provider&&W.modelId===c.model))return c;const D=h.find(W=>W.provider==="markus"),$=D?{provider:D.provider,model:D.modelId}:{provider:h[0].provider,model:h[0].modelId};return s({routingDefaultModel:$}),$}))},[u,h,b,M,re]);const oe=i.useCallback(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{a(c.capabilityRouting?.assignments??{}),d(c.routingDefaultModel??null)}).catch(()=>{}),m(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{const k=[];for(const D of c.providers)for(const $ of D.models)k.push({provider:D.provider,providerLabel:D.displayName,modelId:$.id,modelName:$.name,mode:$.mode,tier:$.tier,costTier:$.costTier,capabilities:$.capabilities});U(k)}).catch(()=>{}).finally(()=>m(!1))},[]),xe=i.useCallback(async()=>{if(S!=="working"){R("working"),B(null);try{const c=await fetch("/api/settings/llm/restore-recommended",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}}),k=await c.json().catch(()=>({}));if(!c.ok||!k.ok)throw new Error(k.error??`HTTP ${c.status}`);k.capabilityRouting&&a(k.capabilityRouting.assignments??{}),k.routingDefaultModel!==void 0&&d(k.routingDefaultModel),oe(),R("idle"),w("saved"),setTimeout(()=>w(D=>D==="saved"?"idle":D),2e3)}catch(c){R("error"),B(c instanceof Error?c.message:String(c)),setTimeout(()=>R("idle"),4e3)}}},[S,oe]),ee=Q.length>0;return u?f?e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-xl p-4 text-xs text-red-400",children:o("modelRouting.loadError",{error:f})}):T&&!ee?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin text-brand-500",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),e.jsx("span",{children:o("modelRouting.loadingModels")})]})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Aa,{status:C,t:o}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>_(!0),disabled:S==="working",className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-brand-500/40 disabled:opacity-50 transition-colors",children:o(S==="working"?"modelRouting.restoreWorking":"modelRouting.restoreRecommended")}),E&&e.jsx("span",{className:"text-[10px] text-red-400 max-w-xs text-right",children:E})]})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:o("modelRouting.defaultModelTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:o("modelRouting.defaultModelDesc")})]}),e.jsx("div",{className:"max-w-md",children:e.jsx(_s,{value:t?`${t.provider}/${t.model}`:"",options:Q,placeholder:o("modelRouting.defaultModelPlaceholder"),onChange:c=>{if(!c)d(null),M(void 0,null);else{const[k,...D]=c.split("/"),$={provider:k,model:D.join("/")};if(d($),n.text){const W={...n};delete W.text,a(W),M(W,$)}else M(void 0,$)}}})})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:o("modelRouting.capabilityAssignTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:o("modelRouting.capabilityAssignDesc")})]}),r.length===0&&e.jsx("div",{className:"p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg text-xs text-yellow-400",children:o("modelRouting.noProvidersHint")}),r.length>0&&e.jsx("div",{className:"space-y-4",children:_r.map(c=>e.jsx(Sa,{groupKey:c.groupKey,capabilities:c.capabilities,assignments:n,suggestions:y,allModels:Q,configuredProviderNames:new Set(r.map(k=>k.name)),t:o,onAssign:(k,D)=>{const $={...n};D?$[k]=D:delete $[k],a($),M($)}},c.groupKey))})]}),K&&e.jsx(Pn,{variant:"primary",title:o("modelRouting.restoreRecommended"),message:o("modelRouting.restoreConfirm"),confirmLabel:o("common:confirm"),onConfirm:()=>{_(!1),xe()},onCancel:()=>_(!1)})]}):e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-surface-overlay rounded w-1/3 mb-3"}),e.jsx("div",{className:"h-3 bg-surface-overlay rounded w-2/3 mb-4"}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(c=>e.jsx("div",{className:"h-10 bg-surface-overlay rounded-lg"},c))})]})})}function Sa({groupKey:s,capabilities:r,assignments:o,suggestions:n,allModels:a,configuredProviderNames:t,t:d,onAssign:u}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 px-1",children:d(`modelRouting.capabilityGroups.${s}`)}),e.jsx("div",{className:"space-y-1",children:r.map(x=>{const f=o[x],v=n[x],T=f?`${f.provider}/${f.model}`:"",m=Tn(a,x),C=v?m.find(A=>A.provider===v.provider&&A.modelId===v.model)?.modelName??v.model:void 0,w=m.length>0,h=f?Pa(a,f.provider,f.model):void 0,U=f&&!t.has(f.provider),y=!!(f&&w&&x!=="text"&&!m.some(A=>A.provider===f.provider&&A.modelId===f.model));return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-lg ${y?"bg-red-500/10 border border-red-500/30":U?"bg-yellow-500/10 border border-yellow-500/30":!w&&!f?"bg-amber-500/5 border border-amber-500/20":"bg-surface-overlay/40"}`,children:[e.jsx("div",{className:"w-28 shrink-0",children:e.jsx("span",{className:"text-xs text-fg-primary",children:d(`modelRouting.capabilities.${x}`)})}),e.jsx("div",{className:"flex-1 min-w-0",children:y?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-xs text-red-400",children:["⚠ ",f.model]}),e.jsx("span",{className:"text-[10px] text-red-400/70",children:d("modelRouting.mismatchHint")})]}),e.jsx(_s,{value:"",options:m,placeholder:d("modelRouting.selectModel"),onChange:A=>{if(!A)u(x,null);else{const[g,...j]=A.split("/");u(x,{provider:g,model:j.join("/")})}}})]}):w?e.jsx(_s,{value:T,options:m,placeholder:C?`${C} (${d("modelRouting.suggested")})`:d("modelRouting.selectModel"),onChange:A=>{if(!A)u(x,null);else{const[g,...j]=A.split("/");u(x,{provider:g,model:j.join("/")})}}}):e.jsxs("span",{className:"text-xs text-amber-400",children:[d("modelRouting.noModelAvailable"),e.jsxs("span",{className:"text-fg-tertiary ml-1",children:["— ",d("modelRouting.addProviderHint")]})]})}),e.jsxs("div",{className:"w-14 shrink-0 flex justify-end",children:[y&&e.jsx("span",{className:"text-[10px] text-red-400 font-medium",title:d("modelRouting.mismatchHint"),children:"⚠"}),!y&&U&&e.jsx("span",{className:"text-[10px] text-yellow-400 font-medium",title:d("modelRouting.staleProvider"),children:"⚠"}),!y&&!U&&h&&e.jsx(Dr,{tier:h}),!y&&!U&&!h&&f&&e.jsx(Dr,{tier:"unknown"})]}),e.jsx("div",{className:"w-8 shrink-0 flex justify-end",children:f&&e.jsx("button",{onClick:()=>u(x,null),className:"text-fg-tertiary hover:text-red-400 transition-colors",title:d("modelRouting.clear"),children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]},x)})})]})}function Pa(s,r,o){return s.find(a=>a.provider===r&&a.modelId===o)?.tier}function Aa({status:s,t:r}){if(s==="idle")return null;const o={idle:"",saving:"text-fg-tertiary",saved:"text-green-400",error:"text-red-400"},n={idle:"",saving:r("modelRouting.saving"),saved:r("modelRouting.saved"),error:r("modelRouting.saveError")};return e.jsx("div",{className:`text-xs font-medium transition-opacity ${o[s]}`,children:n[s]})}function Dr({tier:s}){const r={max:"bg-purple-500/20 text-purple-400 border-purple-500/30",pro:"bg-blue-500/20 text-blue-400 border-blue-500/30",base:"bg-gray-500/20 text-gray-400 border-gray-500/30",unknown:"bg-gray-500/10 text-fg-tertiary border-border-default"};return e.jsx("span",{className:`px-1.5 py-0.5 text-[9px] rounded font-semibold uppercase border ${r[s]??r.unknown}`,children:s==="unknown"?"—":s})}const Ma=new Set(["imageGeneration","tts","stt","videoGeneration","audioOutput","audioInput"]);function Tn(s,r){if(r==="text")return s.filter(d=>!(d.capabilities&&d.capabilities.some(u=>Ma.has(u))||d.mode&&d.mode!=="chat"));const o={image_generation:["image_generation"],audio_tts:["audio_speech"],audio_stt:["audio_transcription"],video_generation:["video_generation"]},n={image_recognition:["vision"],image_generation:["imageGeneration"],audio_tts:["tts"],audio_stt:["stt"],video_generation:["videoGeneration"]},a=o[r],t=n[r];return s.filter(d=>!!(d.capabilities&&d.capabilities.length>0&&t&&t.some(u=>d.capabilities.includes(u))||a&&d.mode&&a.includes(d.mode)))}const At=[{id:"markus",label:"Markus Cloud AI",envKey:"MARKUS_SUBSCRIPTION_KEY",defaultModel:""},{id:"anthropic",label:"Anthropic",envKey:"ANTHROPIC_API_KEY",defaultModel:"claude-opus-4-6"},{id:"openai",label:"OpenAI",envKey:"OPENAI_API_KEY",defaultModel:"gpt-5.4"},{id:"google",label:"Google Gemini",envKey:"GOOGLE_API_KEY",defaultModel:"gemini-3-1-pro"},{id:"deepseek",label:"DeepSeek",envKey:"DEEPSEEK_API_KEY",baseUrl:"https://api.deepseek.com",defaultModel:"deepseek-v4-flash"},{id:"siliconflow",label:"SiliconFlow (中国)",envKey:"SILICONFLOW_API_KEY",baseUrl:"https://api.siliconflow.cn/v1",defaultModel:"Qwen/Qwen3.5-35B-A3B"},{id:"siliconflow-intl",label:"SiliconFlow (Global)",envKey:"SILICONFLOW_INTL_API_KEY",baseUrl:"https://api-st.siliconflow.cn/v1",defaultModel:"Qwen/Qwen3.5-35B-A3B"},{id:"minimax",label:"MiniMax (Global)",envKey:"MINIMAX_API_KEY",baseUrl:"https://api.minimax.io/v1",defaultModel:"MiniMax-M3"},{id:"minimax-cn",label:"MiniMax (中国)",envKey:"MINIMAX_CN_API_KEY",baseUrl:"https://api.minimaxi.com/v1",defaultModel:"MiniMax-M3"},{id:"openrouter",label:"OpenRouter",envKey:"OPENROUTER_API_KEY",baseUrl:"https://openrouter.ai/api/v1",defaultModel:"xiaomi/mimo-v2-pro:free"},{id:"zai",label:"ZAI (GLM)",envKey:"ZAI_API_KEY",baseUrl:"https://api.z.ai/api/paas/v4",defaultModel:"glm-5.1"},{id:"xai",label:"xAI (Grok)",envKey:"XAI_API_KEY",baseUrl:"https://api.x.ai/v1",defaultModel:"grok-3"},{id:"mistral",label:"Mistral AI",envKey:"MISTRAL_API_KEY",baseUrl:"https://api.mistral.ai/v1",defaultModel:"mistral-large-latest"},{id:"groq",label:"Groq",envKey:"GROQ_API_KEY",baseUrl:"https://api.groq.com/openai/v1",defaultModel:"llama-3.3-70b-versatile"},{id:"perplexity",label:"Perplexity",envKey:"PERPLEXITY_API_KEY",baseUrl:"https://api.perplexity.ai",defaultModel:"sonar-pro"},{id:"cohere",label:"Cohere",envKey:"COHERE_API_KEY",baseUrl:"https://api.cohere.ai/compatibility/v1",defaultModel:"command-r-plus"},{id:"together_ai",label:"Together AI",envKey:"TOGETHER_API_KEY",baseUrl:"https://api.together.xyz/v1",defaultModel:"meta-llama/Llama-3.3-70B-Instruct-Turbo"},{id:"fireworks_ai",label:"Fireworks AI",envKey:"FIREWORKS_API_KEY",baseUrl:"https://api.fireworks.ai/inference/v1",defaultModel:"accounts/fireworks/models/llama-v3p3-70b-instruct"},{id:"moonshot",label:"Moonshot (Kimi)",envKey:"MOONSHOT_API_KEY",baseUrl:"https://api.moonshot.cn/v1",defaultModel:"moonshot-v1-auto"},{id:"volcengine",label:"Volcengine (Doubao)",envKey:"VOLCENGINE_API_KEY",baseUrl:"https://ark.cn-beijing.volces.com/api/v3",defaultModel:"doubao-1.5-pro-32k"},{id:"dashscope",label:"DashScope (Qwen)",envKey:"DASHSCOPE_API_KEY",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode/v1",defaultModel:"qwen-max"},{id:"ollama",label:"Ollama (Local)",envKey:"OLLAMA_BASE_URL",baseUrl:"http://localhost:11434/v1",defaultModel:"llama3"},{id:"atlascloud",label:"Atlas Cloud (Full-Modal)",envKey:"ATLASCLOUD_API_KEY",baseUrl:"https://api.atlascloud.ai/v1",defaultModel:"claude-sonnet-4-6"},{id:"strongly",label:"Strongly.AI (Full-Modal)",envKey:"STRONGLY_API_KEY",baseUrl:"https://api.strongly.ai/v1",defaultModel:"claude-sonnet-4-6"}];var Je={},is,Kr;function Ta(){return Kr||(Kr=1,is=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),is}var ls={},Ke={},Ur;function He(){if(Ur)return Ke;Ur=1;let s;const r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Ke.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},Ke.getSymbolTotalCodewords=function(n){return r[n]},Ke.getBCHDigit=function(o){let n=0;for(;o!==0;)n++,o>>>=1;return n},Ke.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');s=n},Ke.isKanjiModeEnabled=function(){return typeof s<"u"},Ke.toSJIS=function(n){return s(n)},Ke}var ds={},Fr;function Ks(){return Fr||(Fr=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+o)}}s.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},s.from=function(n,a){if(s.isValid(n))return n;try{return r(n)}catch{return a}}})(ds)),ds}var cs,$r;function Ea(){if($r)return cs;$r=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(r){const o=Math.floor(r/8);return(this.buffer[o]>>>7-r%8&1)===1},put:function(r,o){for(let n=0;n<o;n++)this.putBit((r>>>o-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),r&&(this.buffer[o]|=128>>>this.length%8),this.length++}},cs=s,cs}var us,Vr;function Ia(){if(Vr)return us;Vr=1;function s(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return s.prototype.set=function(r,o,n,a){const t=r*this.size+o;this.data[t]=n,a&&(this.reservedBit[t]=!0)},s.prototype.get=function(r,o){return this.data[r*this.size+o]},s.prototype.xor=function(r,o,n){this.data[r*this.size+o]^=n},s.prototype.isReserved=function(r,o){return this.reservedBit[r*this.size+o]},us=s,us}var xs={},Hr;function La(){return Hr||(Hr=1,(function(s){const r=He().getSymbolSize;s.getRowColCoords=function(n){if(n===1)return[];const a=Math.floor(n/7)+2,t=r(n),d=t===145?26:Math.ceil((t-13)/(2*a-2))*2,u=[t-7];for(let x=1;x<a-1;x++)u[x]=u[x-1]-d;return u.push(6),u.reverse()},s.getPositions=function(n){const a=[],t=s.getRowColCoords(n),d=t.length;for(let u=0;u<d;u++)for(let x=0;x<d;x++)u===0&&x===0||u===0&&x===d-1||u===d-1&&x===0||a.push([t[u],t[x]]);return a}})(xs)),xs}var ms={},qr;function Ra(){if(qr)return ms;qr=1;const s=He().getSymbolSize,r=7;return ms.getPositions=function(n){const a=s(n);return[[0,0],[a-r,0],[0,a-r]]},ms}var gs={},zr;function Ba(){return zr||(zr=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};s.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},s.from=function(a){return s.isValid(a)?parseInt(a,10):void 0},s.getPenaltyN1=function(a){const t=a.size;let d=0,u=0,x=0,f=null,v=null;for(let T=0;T<t;T++){u=x=0,f=v=null;for(let m=0;m<t;m++){let C=a.get(T,m);C===f?u++:(u>=5&&(d+=r.N1+(u-5)),f=C,u=1),C=a.get(m,T),C===v?x++:(x>=5&&(d+=r.N1+(x-5)),v=C,x=1)}u>=5&&(d+=r.N1+(u-5)),x>=5&&(d+=r.N1+(x-5))}return d},s.getPenaltyN2=function(a){const t=a.size;let d=0;for(let u=0;u<t-1;u++)for(let x=0;x<t-1;x++){const f=a.get(u,x)+a.get(u,x+1)+a.get(u+1,x)+a.get(u+1,x+1);(f===4||f===0)&&d++}return d*r.N2},s.getPenaltyN3=function(a){const t=a.size;let d=0,u=0,x=0;for(let f=0;f<t;f++){u=x=0;for(let v=0;v<t;v++)u=u<<1&2047|a.get(f,v),v>=10&&(u===1488||u===93)&&d++,x=x<<1&2047|a.get(v,f),v>=10&&(x===1488||x===93)&&d++}return d*r.N3},s.getPenaltyN4=function(a){let t=0;const d=a.data.length;for(let x=0;x<d;x++)t+=a.data[x];return Math.abs(Math.ceil(t*100/d/5)-10)*r.N4};function o(n,a,t){switch(n){case s.Patterns.PATTERN000:return(a+t)%2===0;case s.Patterns.PATTERN001:return a%2===0;case s.Patterns.PATTERN010:return t%3===0;case s.Patterns.PATTERN011:return(a+t)%3===0;case s.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(t/3))%2===0;case s.Patterns.PATTERN101:return a*t%2+a*t%3===0;case s.Patterns.PATTERN110:return(a*t%2+a*t%3)%2===0;case s.Patterns.PATTERN111:return(a*t%3+(a+t)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}s.applyMask=function(a,t){const d=t.size;for(let u=0;u<d;u++)for(let x=0;x<d;x++)t.isReserved(x,u)||t.xor(x,u,o(a,x,u))},s.getBestMask=function(a,t){const d=Object.keys(s.Patterns).length;let u=0,x=1/0;for(let f=0;f<d;f++){t(f),s.applyMask(f,a);const v=s.getPenaltyN1(a)+s.getPenaltyN2(a)+s.getPenaltyN3(a)+s.getPenaltyN4(a);s.applyMask(f,a),v<x&&(x=v,u=f)}return u}})(gs)),gs}var Mt={},Wr;function En(){if(Wr)return Mt;Wr=1;const s=Ks(),r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Mt.getBlocksCount=function(a,t){switch(t){case s.L:return r[(a-1)*4+0];case s.M:return r[(a-1)*4+1];case s.Q:return r[(a-1)*4+2];case s.H:return r[(a-1)*4+3];default:return}},Mt.getTotalCodewordsCount=function(a,t){switch(t){case s.L:return o[(a-1)*4+0];case s.M:return o[(a-1)*4+1];case s.Q:return o[(a-1)*4+2];case s.H:return o[(a-1)*4+3];default:return}},Mt}var fs={},dt={},Gr;function Oa(){if(Gr)return dt;Gr=1;const s=new Uint8Array(512),r=new Uint8Array(256);return(function(){let n=1;for(let a=0;a<255;a++)s[a]=n,r[n]=a,n<<=1,n&256&&(n^=285);for(let a=255;a<512;a++)s[a]=s[a-255]})(),dt.log=function(n){if(n<1)throw new Error("log("+n+")");return r[n]},dt.exp=function(n){return s[n]},dt.mul=function(n,a){return n===0||a===0?0:s[r[n]+r[a]]},dt}var Yr;function _a(){return Yr||(Yr=1,(function(s){const r=Oa();s.mul=function(n,a){const t=new Uint8Array(n.length+a.length-1);for(let d=0;d<n.length;d++)for(let u=0;u<a.length;u++)t[d+u]^=r.mul(n[d],a[u]);return t},s.mod=function(n,a){let t=new Uint8Array(n);for(;t.length-a.length>=0;){const d=t[0];for(let x=0;x<a.length;x++)t[x]^=r.mul(a[x],d);let u=0;for(;u<t.length&&t[u]===0;)u++;t=t.slice(u)}return t},s.generateECPolynomial=function(n){let a=new Uint8Array([1]);for(let t=0;t<n;t++)a=s.mul(a,new Uint8Array([1,r.exp(t)]));return a}})(fs)),fs}var ps,Jr;function Da(){if(Jr)return ps;Jr=1;const s=_a();function r(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(n){this.degree=n,this.genPoly=s.generateECPolynomial(this.degree)},r.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(n.length+this.degree);a.set(n);const t=s.mod(a,this.genPoly),d=this.degree-t.length;if(d>0){const u=new Uint8Array(this.degree);return u.set(t,d),u}return t},ps=r,ps}var hs={},bs={},ys={},Qr;function In(){return Qr||(Qr=1,ys.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),ys}var Me={},Xr;function Ln(){if(Xr)return Me;Xr=1;const s="[0-9]+",r="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
1
+ import{u as pe,r as i,j as e,D as Pn,v as xa,l as V,a as ma,b as ga,c as fa,W as Lr,n as ns,X as pa,Y as Rr,P as Br,h as Ve,i as ha,Z as An,w as ba,o as as,t as Os,_ as ya}from"./index-B1VN5yM1.js";function va(s,r){for(var o=0;o<r.length;o++){const n=r[o];if(typeof n!="string"&&!Array.isArray(n)){for(const a in n)if(a!=="default"&&!(a in s)){const t=Object.getOwnPropertyDescriptor(n,a);t&&Object.defineProperty(s,a,t.get?t:{enumerable:!0,get:()=>n[a]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}function ja(s){return s>=1e6?`${(s/1e6).toFixed(s%1e6===0?0:1)}M`:s>=1e3?`${(s/1e3).toFixed((s%1e3===0,0))}K`:String(s)}function Na(s){return s.maxInputTokens>0||s.inputCostPer1MTokens>0||s.outputCostPer1MTokens>0}function os(s){if(s.tier)return s.tier;const r=s.id.toLowerCase(),o=/opus|5\.4|o3-(?!mini)|o1-(?!mini)|gemini.*ultra|sonnet-4-20/,n=/haiku|flash|nano|lite|small|fast|free|8b|7b|1b|3b/;return/o4-mini|o3-mini|o1-mini|gpt-4o-mini/.test(r)?"pro":o.test(r)?"max":n.test(r)?"base":"pro"}const Or={max:"bg-purple-500/20 text-purple-400 border-purple-500/30",pro:"bg-blue-500/20 text-blue-400 border-blue-500/30",base:"bg-gray-500/20 text-gray-400 border-gray-500/30"};function Mn({models:s,selectedModel:r,onSelect:o,loading:n,compact:a,maxVisible:t,showTiers:d}){const{t:u}=pe("settings"),[x,f]=i.useState(""),[v,T]=i.useState(!1),[m,C]=i.useState(""),w=i.useMemo(()=>{let g=s;if(x){const j=x.toLowerCase();g=g.filter(S=>S.id.toLowerCase().includes(j))}return m&&(g=g.filter(j=>os(j)===m)),g},[s,x,m]),h=i.useMemo(()=>{const g={max:0,pro:0,base:0};for(const j of s)g[os(j)]++;return g},[s]),U=t??(a?5:10),y=v?w:w.slice(0,U),A=w.length>U;return n?e.jsxs("div",{className:"flex items-center gap-2 py-4 text-sm text-fg-tertiary",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-brand-500 border-t-transparent rounded-full animate-spin"}),u("modelPicker.loading")]}):s.length===0?e.jsx("div",{className:"py-3 text-sm text-fg-tertiary",children:u("modelPicker.empty")}):e.jsxs("div",{className:"space-y-2",children:[d&&s.length>3&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>C(""),className:`px-2 py-0.5 rounded text-[10px] transition-colors ${m?"bg-surface-overlay text-fg-tertiary hover:text-fg-secondary":"bg-brand-500/20 text-brand-500"}`,children:u("modelPicker.allCount",{count:s.length})}),["max","pro","base"].filter(g=>h[g]>0).map(g=>e.jsx("button",{onClick:()=>C(m===g?"":g),className:`px-2 py-0.5 rounded text-[10px] font-medium uppercase transition-colors border ${m===g?Or[g]:"border-transparent bg-surface-overlay text-fg-tertiary hover:text-fg-secondary"}`,children:u("modelPicker.tierCount",{tier:u(`modelRouting.tier.${g}`),count:h[g]})},g))]}),s.length>5&&e.jsx("input",{type:"text",value:x,onChange:g=>{f(g.target.value),T(!1)},placeholder:u("modelPicker.filterPlaceholder"),className:"w-full px-3 py-1.5 bg-surface-overlay border border-border-default rounded-lg text-xs text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500"}),e.jsx("div",{className:`space-y-1 ${a?"max-h-[280px] overflow-y-auto":""}`,children:y.map(g=>{const j=g.id===r,S=os(g);return e.jsxs("button",{type:"button",onClick:()=>o(g.id),className:`w-full text-left px-3 py-2 rounded-lg transition-colors ${j?"bg-brand-500/10 border border-brand-500/30":"hover:bg-surface-overlay border border-transparent"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-3 h-3 rounded-full border-2 flex items-center justify-center ${j?"border-brand-500":"border-border-default"}`,children:j&&e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"})}),e.jsx("span",{className:`text-xs font-medium ${j?"text-brand-500":"text-fg-primary"}`,children:g.id}),d&&e.jsx("span",{className:`px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase border ${Or[S]}`,children:u(`modelRouting.tier.${S}`)})]}),e.jsx("div",{className:"flex items-center gap-2",children:j&&e.jsx("span",{className:"text-[10px] text-brand-500 font-medium",children:u("modelPicker.active")})})]}),Na(g)&&g.maxInputTokens>0&&e.jsx("div",{className:"ml-5 mt-0.5 flex items-center gap-2 text-[10px] text-fg-tertiary flex-wrap",children:e.jsxs("span",{children:[ja(g.maxInputTokens)," ",u("modelPicker.ctx")]})}),!a&&e.jsxs("div",{className:"ml-5 mt-1 flex items-center gap-1.5 flex-wrap",children:[g.capabilities.functionCalling&&e.jsx(lt,{label:u("modelPicker.capabilities.tools")}),g.capabilities.vision&&e.jsx(lt,{label:u("modelPicker.capabilities.vision")}),g.capabilities.reasoning&&e.jsx(lt,{label:u("modelPicker.capabilities.reasoning")}),g.capabilities.promptCaching&&e.jsx(lt,{label:u("modelPicker.capabilities.caching")}),g.capabilities.webSearch&&e.jsx(lt,{label:u("modelPicker.capabilities.search")})]})]},g.id)})}),A&&!v&&e.jsx("button",{type:"button",onClick:()=>T(!0),className:"text-xs text-brand-500 hover:text-brand-400 px-3",children:u("modelPicker.showAll",{count:w.length})}),v&&A&&e.jsx("button",{type:"button",onClick:()=>T(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary px-3",children:u("modelPicker.showLess")})]})}function lt({label:s}){return e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] bg-surface-overlay text-fg-tertiary border border-border-default",children:s})}function _s({value:s,options:r,placeholder:o,onChange:n}){const{t:a}=pe("settings"),[t,d]=i.useState(!1),[u,x]=i.useState(""),f=i.useRef(null),v=i.useRef(null),T=i.useRef(null),[m,C]=i.useState(-1);i.useEffect(()=>{function g(j){f.current&&!f.current.contains(j.target)&&d(!1)}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),i.useEffect(()=>{t&&v.current&&v.current.focus()},[t]);const w=i.useMemo(()=>{if(!u.trim())return r;const g=u.toLowerCase();return r.filter(j=>j.modelId.toLowerCase().includes(g)||j.modelName.toLowerCase().includes(g)||j.provider.toLowerCase().includes(g)||j.providerLabel.toLowerCase().includes(g)||j.tier&&j.tier.toLowerCase().includes(g))},[r,u]),h=i.useMemo(()=>{const g=new Map;for(const S of w){const R=S.providerLabel;g.has(R)||g.set(R,[]),g.get(R).push(S)}const j={max:0,pro:1,base:2};for(const S of g.values())S.sort((R,E)=>(j[R.tier??"base"]??9)-(j[E.tier??"base"]??9));return g},[w]),U=i.useMemo(()=>{const g=[];for(const j of h.values())g.push(...j);return g},[h]),y=i.useMemo(()=>{if(!s)return o??a("modelRouting.auto");const g=r.find(j=>`${j.provider}/${j.modelId}`===s);return g?`${g.providerLabel}/${g.modelName}`:s},[s,r,o,a]);function A(g){if(!t){(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),d(!0));return}switch(g.key){case"ArrowDown":g.preventDefault(),C(j=>Math.min(j+1,U.length-1));break;case"ArrowUp":g.preventDefault(),C(j=>Math.max(j-1,-1));break;case"Enter":g.preventDefault(),m===-1?n(""):U[m]&&n(`${U[m].provider}/${U[m].modelId}`),d(!1),x("");break;case"Escape":d(!1),x("");break}}return i.useEffect(()=>{T.current&&m>=0&&T.current.querySelector(`[data-focus-index="${m}"]`)?.scrollIntoView({block:"nearest"})},[m]),e.jsxs("div",{ref:f,className:"relative",onKeyDown:A,children:[e.jsx("button",{type:"button",onClick:()=>{d(!t),x(""),C(-1)},className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary text-left truncate focus:outline-none focus:border-brand-500",children:y}),t&&e.jsxs("div",{className:"absolute z-50 mt-1 w-full min-w-[240px] max-h-[280px] bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden flex flex-col",children:[e.jsx("div",{className:"p-1.5 border-b border-border-default",children:e.jsx("input",{ref:v,type:"text",value:u,onChange:g=>{x(g.target.value),C(-1)},placeholder:a("modelPicker.searchPlaceholder")||"Search models...",className:"w-full px-2 py-1 bg-surface-overlay border border-border-default rounded text-xs text-fg-primary focus:outline-none focus:border-brand-500"})}),e.jsxs("div",{ref:T,className:"overflow-y-auto flex-1",children:[e.jsx("div",{className:`px-3 py-1.5 text-xs cursor-pointer ${m===-1?"bg-brand-500/20 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,onClick:()=>{n(""),d(!1),x("")},children:o??a("modelRouting.auto")}),[...h.entries()].map(([g,j])=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 py-1 text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider bg-surface-overlay/50 sticky top-0",children:g}),j.map(S=>{const R=U.indexOf(S),E=`${S.provider}/${S.modelId}`===s;return e.jsxs("div",{"data-focus-index":R,className:`px-3 py-1.5 text-xs cursor-pointer flex items-center gap-2 ${R===m?"bg-brand-500/20":E?"bg-surface-overlay":"hover:bg-surface-overlay/50"}`,onClick:()=>{n(`${S.provider}/${S.modelId}`),d(!1),x("")},children:[e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:S.modelName}),S.tier&&e.jsx(wa,{tier:S.tier}),S.costTier&&e.jsx("span",{className:"text-[9px] text-fg-tertiary",children:S.costTier})]},`${S.provider}/${S.modelId}`)})]},g)),U.length===0&&e.jsx("div",{className:"px-3 py-3 text-xs text-fg-tertiary text-center",children:a("modelPicker.empty")})]})]})]})}function wa({tier:s}){const r={max:"bg-purple-500/20 text-purple-400",pro:"bg-blue-500/20 text-blue-400",base:"bg-gray-500/20 text-gray-400"};return e.jsx("span",{className:`px-1 py-0.5 rounded text-[8px] font-bold uppercase ${r[s]??r.base}`,children:s})}const ka=500,_r=[{groupKey:"image",capabilities:["image_recognition","image_generation"]},{groupKey:"audio",capabilities:["audio_tts","audio_stt"]},{groupKey:"video",capabilities:["video_generation"]}];function Ca({onSave:s,configuredProviders:r}){const{t:o}=pe(["settings","common"]),[n,a]=i.useState({}),[t,d]=i.useState(null),[u,x]=i.useState(!1),[f,v]=i.useState(null),[T,m]=i.useState(!0),[C,w]=i.useState("idle"),[h,U]=i.useState(null),[y,A]=i.useState({}),[g,j]=i.useState(!1),[S,R]=i.useState("idle"),[E,B]=i.useState(null),[K,_]=i.useState(!1),O=i.useRef(null),F=i.useRef(null),b=i.useMemo(()=>r.map(c=>c.name).sort().join(","),[r]);i.useEffect(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{a(c.capabilityRouting?.assignments??{}),d(c.routingDefaultModel??null),x(!0)}).catch(c=>{v(String(c)),x(!0)})},[b]),i.useEffect(()=>{let c=!1;return m(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(k=>{if(!k.ok)throw new Error(`HTTP ${k.status}`);return k.json()}).then(k=>{if(c)return;const D=[];for(const $ of k.providers)for(const W of $.models)D.push({provider:$.provider,providerLabel:$.displayName,modelId:W.id,modelName:W.name,mode:W.mode,tier:W.tier,costTier:W.costTier,capabilities:W.capabilities});U(D)}).catch(()=>{c||U(null)}).finally(()=>{c||m(!1)}),()=>{c=!0}},[b]),i.useEffect(()=>{fetch("/api/models/suggested-assignments",{credentials:"include"}).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{A(c.suggestions),j(!0)}).catch(()=>j(!0))},[b]);const P=i.useCallback(c=>{w("saving"),s(c).then(()=>{w("saved"),setTimeout(()=>w(k=>k==="saved"?"idle":k),2e3)}).catch(()=>{w("error"),setTimeout(()=>w(k=>k==="error"?"idle":k),3e3)})},[s]),M=i.useCallback((c,k)=>{F.current={capabilityRouting:c!==void 0?{assignments:c}:F.current?.capabilityRouting,routingDefaultModel:k!==void 0?k:F.current?.routingDefaultModel},O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{const D=F.current;F.current=null,D&&P(D)},ka)},[P]),q=i.useMemo(()=>r.flatMap(c=>(c.models??[{id:c.model,name:c.model}]).map(k=>({provider:c.name,providerLabel:c.displayName??c.name,modelId:k.id,modelName:k.name}))),[r]),Q=h??q,re=i.useMemo(()=>Object.entries(n).map(([c,k])=>`${c}:${k?.provider??""}/${k?.model??""}`).sort().join("|"),[n]);i.useEffect(()=>{!u||!h||h.length===0||h.some(c=>!!c.modelId)&&(a(c=>{let k=!1;const D={...c};for(const $ of _r)for(const W of $.capabilities){const Z=D[W];if(!Z?.model)continue;const X=Tn(h,W);if(X.length===0)continue;X.some(ce=>ce.provider===Z.provider&&ce.modelId===Z.model)||(delete D[W],k=!0)}return k?(M(D),D):c}),d(c=>{if(!c?.model||h.some(W=>W.provider===c.provider&&W.modelId===c.model))return c;const D=h.find(W=>W.provider==="markus"),$=D?{provider:D.provider,model:D.modelId}:{provider:h[0].provider,model:h[0].modelId};return s({routingDefaultModel:$}),$}))},[u,h,b,M,re]);const oe=i.useCallback(()=>{fetch("/api/settings/llm/routing",{credentials:"include"}).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{a(c.capabilityRouting?.assignments??{}),d(c.routingDefaultModel??null)}).catch(()=>{}),m(!0),fetch("/api/models/routing-candidates",{credentials:"include"}).then(c=>{if(!c.ok)throw new Error(`HTTP ${c.status}`);return c.json()}).then(c=>{const k=[];for(const D of c.providers)for(const $ of D.models)k.push({provider:D.provider,providerLabel:D.displayName,modelId:$.id,modelName:$.name,mode:$.mode,tier:$.tier,costTier:$.costTier,capabilities:$.capabilities});U(k)}).catch(()=>{}).finally(()=>m(!1))},[]),xe=i.useCallback(async()=>{if(S!=="working"){R("working"),B(null);try{const c=await fetch("/api/settings/llm/restore-recommended",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"}}),k=await c.json().catch(()=>({}));if(!c.ok||!k.ok)throw new Error(k.error??`HTTP ${c.status}`);k.capabilityRouting&&a(k.capabilityRouting.assignments??{}),k.routingDefaultModel!==void 0&&d(k.routingDefaultModel),oe(),R("idle"),w("saved"),setTimeout(()=>w(D=>D==="saved"?"idle":D),2e3)}catch(c){R("error"),B(c instanceof Error?c.message:String(c)),setTimeout(()=>R("idle"),4e3)}}},[S,oe]),ee=Q.length>0;return u?f?e.jsx("div",{className:"bg-red-500/10 border border-red-500/30 rounded-xl p-4 text-xs text-red-400",children:o("modelRouting.loadError",{error:f})}):T&&!ee?e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin text-brand-500",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),e.jsx("span",{children:o("modelRouting.loadingModels")})]})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(Aa,{status:C,t:o}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>_(!0),disabled:S==="working",className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-brand-500/40 disabled:opacity-50 transition-colors",children:o(S==="working"?"modelRouting.restoreWorking":"modelRouting.restoreRecommended")}),E&&e.jsx("span",{className:"text-[10px] text-red-400 max-w-xs text-right",children:E})]})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:o("modelRouting.defaultModelTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:o("modelRouting.defaultModelDesc")})]}),e.jsx("div",{className:"max-w-md",children:e.jsx(_s,{value:t?`${t.provider}/${t.model}`:"",options:Q,placeholder:o("modelRouting.defaultModelPlaceholder"),onChange:c=>{if(!c)d(null),M(void 0,null);else{const[k,...D]=c.split("/"),$={provider:k,model:D.join("/")};if(d($),n.text){const W={...n};delete W.text,a(W),M(W,$)}else M(void 0,$)}}})})]}),e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-fg-primary",children:o("modelRouting.capabilityAssignTitle")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:o("modelRouting.capabilityAssignDesc")})]}),r.length===0&&e.jsx("div",{className:"p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg text-xs text-yellow-400",children:o("modelRouting.noProvidersHint")}),r.length>0&&e.jsx("div",{className:"space-y-4",children:_r.map(c=>e.jsx(Sa,{groupKey:c.groupKey,capabilities:c.capabilities,assignments:n,suggestions:y,allModels:Q,configuredProviderNames:new Set(r.map(k=>k.name)),t:o,onAssign:(k,D)=>{const $={...n};D?$[k]=D:delete $[k],a($),M($)}},c.groupKey))})]}),K&&e.jsx(Pn,{variant:"primary",title:o("modelRouting.restoreRecommended"),message:o("modelRouting.restoreConfirm"),confirmLabel:o("common:confirm"),onConfirm:()=>{_(!1),xe()},onCancel:()=>_(!1)})]}):e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-surface-overlay rounded w-1/3 mb-3"}),e.jsx("div",{className:"h-3 bg-surface-overlay rounded w-2/3 mb-4"}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(c=>e.jsx("div",{className:"h-10 bg-surface-overlay rounded-lg"},c))})]})})}function Sa({groupKey:s,capabilities:r,assignments:o,suggestions:n,allModels:a,configuredProviderNames:t,t:d,onAssign:u}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2 px-1",children:d(`modelRouting.capabilityGroups.${s}`)}),e.jsx("div",{className:"space-y-1",children:r.map(x=>{const f=o[x],v=n[x],T=f?`${f.provider}/${f.model}`:"",m=Tn(a,x),C=v?m.find(A=>A.provider===v.provider&&A.modelId===v.model)?.modelName??v.model:void 0,w=m.length>0,h=f?Pa(a,f.provider,f.model):void 0,U=f&&!t.has(f.provider),y=!!(f&&w&&x!=="text"&&!m.some(A=>A.provider===f.provider&&A.modelId===f.model));return e.jsxs("div",{className:`flex items-center gap-3 px-3 py-2 rounded-lg ${y?"bg-red-500/10 border border-red-500/30":U?"bg-yellow-500/10 border border-yellow-500/30":!w&&!f?"bg-amber-500/5 border border-amber-500/20":"bg-surface-overlay/40"}`,children:[e.jsx("div",{className:"w-28 shrink-0",children:e.jsx("span",{className:"text-xs text-fg-primary",children:d(`modelRouting.capabilities.${x}`)})}),e.jsx("div",{className:"flex-1 min-w-0",children:y?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"text-xs text-red-400",children:["⚠ ",f.model]}),e.jsx("span",{className:"text-[10px] text-red-400/70",children:d("modelRouting.mismatchHint")})]}),e.jsx(_s,{value:"",options:m,placeholder:d("modelRouting.selectModel"),onChange:A=>{if(!A)u(x,null);else{const[g,...j]=A.split("/");u(x,{provider:g,model:j.join("/")})}}})]}):w?e.jsx(_s,{value:T,options:m,placeholder:C?`${C} (${d("modelRouting.suggested")})`:d("modelRouting.selectModel"),onChange:A=>{if(!A)u(x,null);else{const[g,...j]=A.split("/");u(x,{provider:g,model:j.join("/")})}}}):e.jsxs("span",{className:"text-xs text-amber-400",children:[d("modelRouting.noModelAvailable"),e.jsxs("span",{className:"text-fg-tertiary ml-1",children:["— ",d("modelRouting.addProviderHint")]})]})}),e.jsxs("div",{className:"w-14 shrink-0 flex justify-end",children:[y&&e.jsx("span",{className:"text-[10px] text-red-400 font-medium",title:d("modelRouting.mismatchHint"),children:"⚠"}),!y&&U&&e.jsx("span",{className:"text-[10px] text-yellow-400 font-medium",title:d("modelRouting.staleProvider"),children:"⚠"}),!y&&!U&&h&&e.jsx(Dr,{tier:h}),!y&&!U&&!h&&f&&e.jsx(Dr,{tier:"unknown"})]}),e.jsx("div",{className:"w-8 shrink-0 flex justify-end",children:f&&e.jsx("button",{onClick:()=>u(x,null),className:"text-fg-tertiary hover:text-red-400 transition-colors",title:d("modelRouting.clear"),children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})})]},x)})})]})}function Pa(s,r,o){return s.find(a=>a.provider===r&&a.modelId===o)?.tier}function Aa({status:s,t:r}){if(s==="idle")return null;const o={idle:"",saving:"text-fg-tertiary",saved:"text-green-400",error:"text-red-400"},n={idle:"",saving:r("modelRouting.saving"),saved:r("modelRouting.saved"),error:r("modelRouting.saveError")};return e.jsx("div",{className:`text-xs font-medium transition-opacity ${o[s]}`,children:n[s]})}function Dr({tier:s}){const r={max:"bg-purple-500/20 text-purple-400 border-purple-500/30",pro:"bg-blue-500/20 text-blue-400 border-blue-500/30",base:"bg-gray-500/20 text-gray-400 border-gray-500/30",unknown:"bg-gray-500/10 text-fg-tertiary border-border-default"};return e.jsx("span",{className:`px-1.5 py-0.5 text-[9px] rounded font-semibold uppercase border ${r[s]??r.unknown}`,children:s==="unknown"?"—":s})}const Ma=new Set(["imageGeneration","tts","stt","videoGeneration","audioOutput","audioInput"]);function Tn(s,r){if(r==="text")return s.filter(d=>!(d.capabilities&&d.capabilities.some(u=>Ma.has(u))||d.mode&&d.mode!=="chat"));const o={image_generation:["image_generation"],audio_tts:["audio_speech"],audio_stt:["audio_transcription"],video_generation:["video_generation"]},n={image_recognition:["vision"],image_generation:["imageGeneration"],audio_tts:["tts"],audio_stt:["stt"],video_generation:["videoGeneration"]},a=o[r],t=n[r];return s.filter(d=>!!(d.capabilities&&d.capabilities.length>0&&t&&t.some(u=>d.capabilities.includes(u))||a&&d.mode&&a.includes(d.mode)))}const At=[{id:"markus",label:"Markus Cloud AI",envKey:"MARKUS_SUBSCRIPTION_KEY",defaultModel:""},{id:"anthropic",label:"Anthropic",envKey:"ANTHROPIC_API_KEY",defaultModel:"claude-opus-4-6"},{id:"openai",label:"OpenAI",envKey:"OPENAI_API_KEY",defaultModel:"gpt-5.4"},{id:"google",label:"Google Gemini",envKey:"GOOGLE_API_KEY",defaultModel:"gemini-3-1-pro"},{id:"deepseek",label:"DeepSeek",envKey:"DEEPSEEK_API_KEY",baseUrl:"https://api.deepseek.com",defaultModel:"deepseek-v4-flash"},{id:"siliconflow",label:"SiliconFlow (中国)",envKey:"SILICONFLOW_API_KEY",baseUrl:"https://api.siliconflow.cn/v1",defaultModel:"Qwen/Qwen3.5-35B-A3B"},{id:"siliconflow-intl",label:"SiliconFlow (Global)",envKey:"SILICONFLOW_INTL_API_KEY",baseUrl:"https://api-st.siliconflow.cn/v1",defaultModel:"Qwen/Qwen3.5-35B-A3B"},{id:"minimax",label:"MiniMax (Global)",envKey:"MINIMAX_API_KEY",baseUrl:"https://api.minimax.io/v1",defaultModel:"MiniMax-M3"},{id:"minimax-cn",label:"MiniMax (中国)",envKey:"MINIMAX_CN_API_KEY",baseUrl:"https://api.minimaxi.com/v1",defaultModel:"MiniMax-M3"},{id:"openrouter",label:"OpenRouter",envKey:"OPENROUTER_API_KEY",baseUrl:"https://openrouter.ai/api/v1",defaultModel:"xiaomi/mimo-v2-pro:free"},{id:"zai",label:"ZAI (GLM)",envKey:"ZAI_API_KEY",baseUrl:"https://api.z.ai/api/paas/v4",defaultModel:"glm-5.1"},{id:"xai",label:"xAI (Grok)",envKey:"XAI_API_KEY",baseUrl:"https://api.x.ai/v1",defaultModel:"grok-3"},{id:"mistral",label:"Mistral AI",envKey:"MISTRAL_API_KEY",baseUrl:"https://api.mistral.ai/v1",defaultModel:"mistral-large-latest"},{id:"groq",label:"Groq",envKey:"GROQ_API_KEY",baseUrl:"https://api.groq.com/openai/v1",defaultModel:"llama-3.3-70b-versatile"},{id:"perplexity",label:"Perplexity",envKey:"PERPLEXITY_API_KEY",baseUrl:"https://api.perplexity.ai",defaultModel:"sonar-pro"},{id:"cohere",label:"Cohere",envKey:"COHERE_API_KEY",baseUrl:"https://api.cohere.ai/compatibility/v1",defaultModel:"command-r-plus"},{id:"together_ai",label:"Together AI",envKey:"TOGETHER_API_KEY",baseUrl:"https://api.together.xyz/v1",defaultModel:"meta-llama/Llama-3.3-70B-Instruct-Turbo"},{id:"fireworks_ai",label:"Fireworks AI",envKey:"FIREWORKS_API_KEY",baseUrl:"https://api.fireworks.ai/inference/v1",defaultModel:"accounts/fireworks/models/llama-v3p3-70b-instruct"},{id:"moonshot",label:"Moonshot (Kimi)",envKey:"MOONSHOT_API_KEY",baseUrl:"https://api.moonshot.cn/v1",defaultModel:"moonshot-v1-auto"},{id:"volcengine",label:"Volcengine (Doubao)",envKey:"VOLCENGINE_API_KEY",baseUrl:"https://ark.cn-beijing.volces.com/api/v3",defaultModel:"doubao-1.5-pro-32k"},{id:"dashscope",label:"DashScope (Qwen)",envKey:"DASHSCOPE_API_KEY",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode/v1",defaultModel:"qwen-max"},{id:"ollama",label:"Ollama (Local)",envKey:"OLLAMA_BASE_URL",baseUrl:"http://localhost:11434/v1",defaultModel:"llama3"},{id:"atlascloud",label:"Atlas Cloud (Full-Modal)",envKey:"ATLASCLOUD_API_KEY",baseUrl:"https://api.atlascloud.ai/v1",defaultModel:"claude-sonnet-4-6"},{id:"strongly",label:"Strongly.AI (Full-Modal)",envKey:"STRONGLY_API_KEY",baseUrl:"https://api.strongly.ai/v1",defaultModel:"claude-sonnet-4-6"}];var Je={},is,Kr;function Ta(){return Kr||(Kr=1,is=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),is}var ls={},Ke={},Ur;function He(){if(Ur)return Ke;Ur=1;let s;const r=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Ke.getSymbolSize=function(n){if(!n)throw new Error('"version" cannot be null or undefined');if(n<1||n>40)throw new Error('"version" should be in range from 1 to 40');return n*4+17},Ke.getSymbolTotalCodewords=function(n){return r[n]},Ke.getBCHDigit=function(o){let n=0;for(;o!==0;)n++,o>>>=1;return n},Ke.setToSJISFunction=function(n){if(typeof n!="function")throw new Error('"toSJISFunc" is not a valid function.');s=n},Ke.isKanjiModeEnabled=function(){return typeof s<"u"},Ke.toSJIS=function(n){return s(n)},Ke}var ds={},Fr;function Ks(){return Fr||(Fr=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function r(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+o)}}s.isValid=function(n){return n&&typeof n.bit<"u"&&n.bit>=0&&n.bit<4},s.from=function(n,a){if(s.isValid(n))return n;try{return r(n)}catch{return a}}})(ds)),ds}var cs,$r;function Ea(){if($r)return cs;$r=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(r){const o=Math.floor(r/8);return(this.buffer[o]>>>7-r%8&1)===1},put:function(r,o){for(let n=0;n<o;n++)this.putBit((r>>>o-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),r&&(this.buffer[o]|=128>>>this.length%8),this.length++}},cs=s,cs}var us,Vr;function Ia(){if(Vr)return us;Vr=1;function s(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}return s.prototype.set=function(r,o,n,a){const t=r*this.size+o;this.data[t]=n,a&&(this.reservedBit[t]=!0)},s.prototype.get=function(r,o){return this.data[r*this.size+o]},s.prototype.xor=function(r,o,n){this.data[r*this.size+o]^=n},s.prototype.isReserved=function(r,o){return this.reservedBit[r*this.size+o]},us=s,us}var xs={},Hr;function La(){return Hr||(Hr=1,(function(s){const r=He().getSymbolSize;s.getRowColCoords=function(n){if(n===1)return[];const a=Math.floor(n/7)+2,t=r(n),d=t===145?26:Math.ceil((t-13)/(2*a-2))*2,u=[t-7];for(let x=1;x<a-1;x++)u[x]=u[x-1]-d;return u.push(6),u.reverse()},s.getPositions=function(n){const a=[],t=s.getRowColCoords(n),d=t.length;for(let u=0;u<d;u++)for(let x=0;x<d;x++)u===0&&x===0||u===0&&x===d-1||u===d-1&&x===0||a.push([t[u],t[x]]);return a}})(xs)),xs}var ms={},qr;function Ra(){if(qr)return ms;qr=1;const s=He().getSymbolSize,r=7;return ms.getPositions=function(n){const a=s(n);return[[0,0],[a-r,0],[0,a-r]]},ms}var gs={},zr;function Ba(){return zr||(zr=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const r={N1:3,N2:3,N3:40,N4:10};s.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7},s.from=function(a){return s.isValid(a)?parseInt(a,10):void 0},s.getPenaltyN1=function(a){const t=a.size;let d=0,u=0,x=0,f=null,v=null;for(let T=0;T<t;T++){u=x=0,f=v=null;for(let m=0;m<t;m++){let C=a.get(T,m);C===f?u++:(u>=5&&(d+=r.N1+(u-5)),f=C,u=1),C=a.get(m,T),C===v?x++:(x>=5&&(d+=r.N1+(x-5)),v=C,x=1)}u>=5&&(d+=r.N1+(u-5)),x>=5&&(d+=r.N1+(x-5))}return d},s.getPenaltyN2=function(a){const t=a.size;let d=0;for(let u=0;u<t-1;u++)for(let x=0;x<t-1;x++){const f=a.get(u,x)+a.get(u,x+1)+a.get(u+1,x)+a.get(u+1,x+1);(f===4||f===0)&&d++}return d*r.N2},s.getPenaltyN3=function(a){const t=a.size;let d=0,u=0,x=0;for(let f=0;f<t;f++){u=x=0;for(let v=0;v<t;v++)u=u<<1&2047|a.get(f,v),v>=10&&(u===1488||u===93)&&d++,x=x<<1&2047|a.get(v,f),v>=10&&(x===1488||x===93)&&d++}return d*r.N3},s.getPenaltyN4=function(a){let t=0;const d=a.data.length;for(let x=0;x<d;x++)t+=a.data[x];return Math.abs(Math.ceil(t*100/d/5)-10)*r.N4};function o(n,a,t){switch(n){case s.Patterns.PATTERN000:return(a+t)%2===0;case s.Patterns.PATTERN001:return a%2===0;case s.Patterns.PATTERN010:return t%3===0;case s.Patterns.PATTERN011:return(a+t)%3===0;case s.Patterns.PATTERN100:return(Math.floor(a/2)+Math.floor(t/3))%2===0;case s.Patterns.PATTERN101:return a*t%2+a*t%3===0;case s.Patterns.PATTERN110:return(a*t%2+a*t%3)%2===0;case s.Patterns.PATTERN111:return(a*t%3+(a+t)%2)%2===0;default:throw new Error("bad maskPattern:"+n)}}s.applyMask=function(a,t){const d=t.size;for(let u=0;u<d;u++)for(let x=0;x<d;x++)t.isReserved(x,u)||t.xor(x,u,o(a,x,u))},s.getBestMask=function(a,t){const d=Object.keys(s.Patterns).length;let u=0,x=1/0;for(let f=0;f<d;f++){t(f),s.applyMask(f,a);const v=s.getPenaltyN1(a)+s.getPenaltyN2(a)+s.getPenaltyN3(a)+s.getPenaltyN4(a);s.applyMask(f,a),v<x&&(x=v,u=f)}return u}})(gs)),gs}var Mt={},Wr;function En(){if(Wr)return Mt;Wr=1;const s=Ks(),r=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Mt.getBlocksCount=function(a,t){switch(t){case s.L:return r[(a-1)*4+0];case s.M:return r[(a-1)*4+1];case s.Q:return r[(a-1)*4+2];case s.H:return r[(a-1)*4+3];default:return}},Mt.getTotalCodewordsCount=function(a,t){switch(t){case s.L:return o[(a-1)*4+0];case s.M:return o[(a-1)*4+1];case s.Q:return o[(a-1)*4+2];case s.H:return o[(a-1)*4+3];default:return}},Mt}var fs={},dt={},Gr;function Oa(){if(Gr)return dt;Gr=1;const s=new Uint8Array(512),r=new Uint8Array(256);return(function(){let n=1;for(let a=0;a<255;a++)s[a]=n,r[n]=a,n<<=1,n&256&&(n^=285);for(let a=255;a<512;a++)s[a]=s[a-255]})(),dt.log=function(n){if(n<1)throw new Error("log("+n+")");return r[n]},dt.exp=function(n){return s[n]},dt.mul=function(n,a){return n===0||a===0?0:s[r[n]+r[a]]},dt}var Yr;function _a(){return Yr||(Yr=1,(function(s){const r=Oa();s.mul=function(n,a){const t=new Uint8Array(n.length+a.length-1);for(let d=0;d<n.length;d++)for(let u=0;u<a.length;u++)t[d+u]^=r.mul(n[d],a[u]);return t},s.mod=function(n,a){let t=new Uint8Array(n);for(;t.length-a.length>=0;){const d=t[0];for(let x=0;x<a.length;x++)t[x]^=r.mul(a[x],d);let u=0;for(;u<t.length&&t[u]===0;)u++;t=t.slice(u)}return t},s.generateECPolynomial=function(n){let a=new Uint8Array([1]);for(let t=0;t<n;t++)a=s.mul(a,new Uint8Array([1,r.exp(t)]));return a}})(fs)),fs}var ps,Jr;function Da(){if(Jr)return ps;Jr=1;const s=_a();function r(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return r.prototype.initialize=function(n){this.degree=n,this.genPoly=s.generateECPolynomial(this.degree)},r.prototype.encode=function(n){if(!this.genPoly)throw new Error("Encoder not initialized");const a=new Uint8Array(n.length+this.degree);a.set(n);const t=s.mod(a,this.genPoly),d=this.degree-t.length;if(d>0){const u=new Uint8Array(this.degree);return u.set(t,d),u}return t},ps=r,ps}var hs={},bs={},ys={},Qr;function In(){return Qr||(Qr=1,ys.isValid=function(r){return!isNaN(r)&&r>=1&&r<=40}),ys}var Me={},Xr;function Ln(){if(Xr)return Me;Xr=1;const s="[0-9]+",r="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const n="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
2
2
  ]))+`;Me.KANJI=new RegExp(o,"g"),Me.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Me.BYTE=new RegExp(n,"g"),Me.NUMERIC=new RegExp(s,"g"),Me.ALPHANUMERIC=new RegExp(r,"g");const a=new RegExp("^"+o+"$"),t=new RegExp("^"+s+"$"),d=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Me.testKanji=function(x){return a.test(x)},Me.testNumeric=function(x){return t.test(x)},Me.testAlphanumeric=function(x){return d.test(x)},Me}var Zr;function qe(){return Zr||(Zr=1,(function(s){const r=In(),o=Ln();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(t,d){if(!t.ccBits)throw new Error("Invalid mode: "+t);if(!r.isValid(d))throw new Error("Invalid version: "+d);return d>=1&&d<10?t.ccBits[0]:d<27?t.ccBits[1]:t.ccBits[2]},s.getBestModeForData=function(t){return o.testNumeric(t)?s.NUMERIC:o.testAlphanumeric(t)?s.ALPHANUMERIC:o.testKanji(t)?s.KANJI:s.BYTE},s.toString=function(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")},s.isValid=function(t){return t&&t.bit&&t.ccBits};function n(a){if(typeof a!="string")throw new Error("Param is not a string");switch(a.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+a)}}s.from=function(t,d){if(s.isValid(t))return t;try{return n(t)}catch{return d}}})(bs)),bs}var en;function Ka(){return en||(en=1,(function(s){const r=He(),o=En(),n=Ks(),a=qe(),t=In(),d=7973,u=r.getBCHDigit(d);function x(m,C,w){for(let h=1;h<=40;h++)if(C<=s.getCapacity(h,w,m))return h}function f(m,C){return a.getCharCountIndicator(m,C)+4}function v(m,C){let w=0;return m.forEach(function(h){const U=f(h.mode,C);w+=U+h.getBitsLength()}),w}function T(m,C){for(let w=1;w<=40;w++)if(v(m,w)<=s.getCapacity(w,C,a.MIXED))return w}s.from=function(C,w){return t.isValid(C)?parseInt(C,10):w},s.getCapacity=function(C,w,h){if(!t.isValid(C))throw new Error("Invalid QR Code version");typeof h>"u"&&(h=a.BYTE);const U=r.getSymbolTotalCodewords(C),y=o.getTotalCodewordsCount(C,w),A=(U-y)*8;if(h===a.MIXED)return A;const g=A-f(h,C);switch(h){case a.NUMERIC:return Math.floor(g/10*3);case a.ALPHANUMERIC:return Math.floor(g/11*2);case a.KANJI:return Math.floor(g/13);case a.BYTE:default:return Math.floor(g/8)}},s.getBestVersionForData=function(C,w){let h;const U=n.from(w,n.M);if(Array.isArray(C)){if(C.length>1)return T(C,U);if(C.length===0)return 1;h=C[0]}else h=C;return x(h.mode,h.getLength(),U)},s.getEncodedBits=function(C){if(!t.isValid(C)||C<7)throw new Error("Invalid QR Code version");let w=C<<12;for(;r.getBCHDigit(w)-u>=0;)w^=d<<r.getBCHDigit(w)-u;return C<<12|w}})(hs)),hs}var vs={},tn;function Ua(){if(tn)return vs;tn=1;const s=He(),r=1335,o=21522,n=s.getBCHDigit(r);return vs.getEncodedBits=function(t,d){const u=t.bit<<3|d;let x=u<<10;for(;s.getBCHDigit(x)-n>=0;)x^=r<<s.getBCHDigit(x)-n;return(u<<10|x)^o},vs}var js={},Ns,sn;function Fa(){if(sn)return Ns;sn=1;const s=qe();function r(o){this.mode=s.NUMERIC,this.data=o.toString()}return r.getBitsLength=function(n){return 10*Math.floor(n/3)+(n%3?n%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(n){let a,t,d;for(a=0;a+3<=this.data.length;a+=3)t=this.data.substr(a,3),d=parseInt(t,10),n.put(d,10);const u=this.data.length-a;u>0&&(t=this.data.substr(a),d=parseInt(t,10),n.put(d,u*3+1))},Ns=r,Ns}var ws,rn;function $a(){if(rn)return ws;rn=1;const s=qe(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(n){this.mode=s.ALPHANUMERIC,this.data=n}return o.getBitsLength=function(a){return 11*Math.floor(a/2)+6*(a%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(a){let t;for(t=0;t+2<=this.data.length;t+=2){let d=r.indexOf(this.data[t])*45;d+=r.indexOf(this.data[t+1]),a.put(d,11)}this.data.length%2&&a.put(r.indexOf(this.data[t]),6)},ws=o,ws}var ks,nn;function Va(){if(nn)return ks;nn=1;const s=qe();function r(o){this.mode=s.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return r.getBitsLength=function(n){return n*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(o){for(let n=0,a=this.data.length;n<a;n++)o.put(this.data[n],8)},ks=r,ks}var Cs,an;function Ha(){if(an)return Cs;an=1;const s=qe(),r=He();function o(n){this.mode=s.KANJI,this.data=n}return o.getBitsLength=function(a){return a*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(n){let a;for(a=0;a<this.data.length;a++){let t=r.toSJIS(this.data[a]);if(t>=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[a]+`
3
3
  Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),n.put(t,13)}},Cs=o,Cs}var Ss={exports:{}},on;function qa(){return on||(on=1,(function(s){var r={single_source_shortest_paths:function(o,n,a){var t={},d={};d[n]=0;var u=r.PriorityQueue.make();u.push(n,0);for(var x,f,v,T,m,C,w,h,U;!u.empty();){x=u.pop(),f=x.value,T=x.cost,m=o[f]||{};for(v in m)m.hasOwnProperty(v)&&(C=m[v],w=T+C,h=d[v],U=typeof d[v]>"u",(U||h>w)&&(d[v]=w,u.push(v,w),t[v]=f))}if(typeof a<"u"&&typeof d[a]>"u"){var y=["Could not find a path from ",n," to ",a,"."].join("");throw new Error(y)}return t},extract_shortest_path_from_predecessor_list:function(o,n){for(var a=[],t=n;t;)a.push(t),o[t],t=o[t];return a.reverse(),a},find_path:function(o,n,a){var t=r.single_source_shortest_paths(o,n,a);return r.extract_shortest_path_from_predecessor_list(t,a)},PriorityQueue:{make:function(o){var n=r.PriorityQueue,a={},t;o=o||{};for(t in n)n.hasOwnProperty(t)&&(a[t]=n[t]);return a.queue=[],a.sorter=o.sorter||n.default_sorter,a},default_sorter:function(o,n){return o.cost-n.cost},push:function(o,n){var a={value:o,cost:n};this.queue.push(a),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=r})(Ss)),Ss.exports}var ln;function za(){return ln||(ln=1,(function(s){const r=qe(),o=Fa(),n=$a(),a=Va(),t=Ha(),d=Ln(),u=He(),x=qa();function f(y){return unescape(encodeURIComponent(y)).length}function v(y,A,g){const j=[];let S;for(;(S=y.exec(g))!==null;)j.push({data:S[0],index:S.index,mode:A,length:S[0].length});return j}function T(y){const A=v(d.NUMERIC,r.NUMERIC,y),g=v(d.ALPHANUMERIC,r.ALPHANUMERIC,y);let j,S;return u.isKanjiModeEnabled()?(j=v(d.BYTE,r.BYTE,y),S=v(d.KANJI,r.KANJI,y)):(j=v(d.BYTE_KANJI,r.BYTE,y),S=[]),A.concat(g,j,S).sort(function(E,B){return E.index-B.index}).map(function(E){return{data:E.data,mode:E.mode,length:E.length}})}function m(y,A){switch(A){case r.NUMERIC:return o.getBitsLength(y);case r.ALPHANUMERIC:return n.getBitsLength(y);case r.KANJI:return t.getBitsLength(y);case r.BYTE:return a.getBitsLength(y)}}function C(y){return y.reduce(function(A,g){const j=A.length-1>=0?A[A.length-1]:null;return j&&j.mode===g.mode?(A[A.length-1].data+=g.data,A):(A.push(g),A)},[])}function w(y){const A=[];for(let g=0;g<y.length;g++){const j=y[g];switch(j.mode){case r.NUMERIC:A.push([j,{data:j.data,mode:r.ALPHANUMERIC,length:j.length},{data:j.data,mode:r.BYTE,length:j.length}]);break;case r.ALPHANUMERIC:A.push([j,{data:j.data,mode:r.BYTE,length:j.length}]);break;case r.KANJI:A.push([j,{data:j.data,mode:r.BYTE,length:f(j.data)}]);break;case r.BYTE:A.push([{data:j.data,mode:r.BYTE,length:f(j.data)}])}}return A}function h(y,A){const g={},j={start:{}};let S=["start"];for(let R=0;R<y.length;R++){const E=y[R],B=[];for(let K=0;K<E.length;K++){const _=E[K],O=""+R+K;B.push(O),g[O]={node:_,lastCount:0},j[O]={};for(let F=0;F<S.length;F++){const b=S[F];g[b]&&g[b].node.mode===_.mode?(j[b][O]=m(g[b].lastCount+_.length,_.mode)-m(g[b].lastCount,_.mode),g[b].lastCount+=_.length):(g[b]&&(g[b].lastCount=_.length),j[b][O]=m(_.length,_.mode)+4+r.getCharCountIndicator(_.mode,A))}}S=B}for(let R=0;R<S.length;R++)j[S[R]].end=0;return{map:j,table:g}}function U(y,A){let g;const j=r.getBestModeForData(y);if(g=r.from(A,j),g!==r.BYTE&&g.bit<j.bit)throw new Error('"'+y+'" cannot be encoded with mode '+r.toString(g)+`.
4
4
  Suggested mode is: `+r.toString(j));switch(g===r.KANJI&&!u.isKanjiModeEnabled()&&(g=r.BYTE),g){case r.NUMERIC:return new o(y);case r.ALPHANUMERIC:return new n(y);case r.KANJI:return new t(y);case r.BYTE:return new a(y)}}s.fromArray=function(A){return A.reduce(function(g,j){return typeof j=="string"?g.push(U(j,null)):j.data&&g.push(U(j.data,j.mode)),g},[])},s.fromString=function(A,g){const j=T(A,u.isKanjiModeEnabled()),S=w(j),R=h(S,g),E=x.find_path(R.map,"start","end"),B=[];for(let K=1;K<E.length-1;K++)B.push(R.table[E[K]].node);return s.fromArray(C(B))},s.rawSplit=function(A){return s.fromArray(T(A,u.isKanjiModeEnabled()))}})(js)),js}var dn;function Wa(){if(dn)return ls;dn=1;const s=He(),r=Ks(),o=Ea(),n=Ia(),a=La(),t=Ra(),d=Ba(),u=En(),x=Da(),f=Ka(),v=Ua(),T=qe(),m=za();function C(R,E){const B=R.size,K=t.getPositions(E);for(let _=0;_<K.length;_++){const O=K[_][0],F=K[_][1];for(let b=-1;b<=7;b++)if(!(O+b<=-1||B<=O+b))for(let P=-1;P<=7;P++)F+P<=-1||B<=F+P||(b>=0&&b<=6&&(P===0||P===6)||P>=0&&P<=6&&(b===0||b===6)||b>=2&&b<=4&&P>=2&&P<=4?R.set(O+b,F+P,!0,!0):R.set(O+b,F+P,!1,!0))}}function w(R){const E=R.size;for(let B=8;B<E-8;B++){const K=B%2===0;R.set(B,6,K,!0),R.set(6,B,K,!0)}}function h(R,E){const B=a.getPositions(E);for(let K=0;K<B.length;K++){const _=B[K][0],O=B[K][1];for(let F=-2;F<=2;F++)for(let b=-2;b<=2;b++)F===-2||F===2||b===-2||b===2||F===0&&b===0?R.set(_+F,O+b,!0,!0):R.set(_+F,O+b,!1,!0)}}function U(R,E){const B=R.size,K=f.getEncodedBits(E);let _,O,F;for(let b=0;b<18;b++)_=Math.floor(b/3),O=b%3+B-8-3,F=(K>>b&1)===1,R.set(_,O,F,!0),R.set(O,_,F,!0)}function y(R,E,B){const K=R.size,_=v.getEncodedBits(E,B);let O,F;for(O=0;O<15;O++)F=(_>>O&1)===1,O<6?R.set(O,8,F,!0):O<8?R.set(O+1,8,F,!0):R.set(K-15+O,8,F,!0),O<8?R.set(8,K-O-1,F,!0):O<9?R.set(8,15-O-1+1,F,!0):R.set(8,15-O-1,F,!0);R.set(K-8,8,1,!0)}function A(R,E){const B=R.size;let K=-1,_=B-1,O=7,F=0;for(let b=B-1;b>0;b-=2)for(b===6&&b--;;){for(let P=0;P<2;P++)if(!R.isReserved(_,b-P)){let M=!1;F<E.length&&(M=(E[F]>>>O&1)===1),R.set(_,b-P,M),O--,O===-1&&(F++,O=7)}if(_+=K,_<0||B<=_){_-=K,K=-K;break}}}function g(R,E,B){const K=new o;B.forEach(function(P){K.put(P.mode.bit,4),K.put(P.getLength(),T.getCharCountIndicator(P.mode,R)),P.write(K)});const _=s.getSymbolTotalCodewords(R),O=u.getTotalCodewordsCount(R,E),F=(_-O)*8;for(K.getLengthInBits()+4<=F&&K.put(0,4);K.getLengthInBits()%8!==0;)K.putBit(0);const b=(F-K.getLengthInBits())/8;for(let P=0;P<b;P++)K.put(P%2?17:236,8);return j(K,R,E)}function j(R,E,B){const K=s.getSymbolTotalCodewords(E),_=u.getTotalCodewordsCount(E,B),O=K-_,F=u.getBlocksCount(E,B),b=K%F,P=F-b,M=Math.floor(K/F),q=Math.floor(O/F),Q=q+1,re=M-q,oe=new x(re);let xe=0;const ee=new Array(F),c=new Array(F);let k=0;const D=new Uint8Array(R.buffer);for(let ie=0;ie<F;ie++){const ce=ie<P?q:Q;ee[ie]=D.slice(xe,xe+ce),c[ie]=oe.encode(ee[ie]),xe+=ce,k=Math.max(k,ce)}const $=new Uint8Array(K);let W=0,Z,X;for(Z=0;Z<k;Z++)for(X=0;X<F;X++)Z<ee[X].length&&($[W++]=ee[X][Z]);for(Z=0;Z<re;Z++)for(X=0;X<F;X++)$[W++]=c[X][Z];return $}function S(R,E,B,K){let _;if(Array.isArray(R))_=m.fromArray(R);else if(typeof R=="string"){let M=E;if(!M){const q=m.rawSplit(R);M=f.getBestVersionForData(q,B)}_=m.fromString(R,M||40)}else throw new Error("Invalid data");const O=f.getBestVersionForData(_,B);if(!O)throw new Error("The amount of data is too big to be stored in a QR Code");if(!E)E=O;else if(E<O)throw new Error(`