@bigduu/lotus 2026.5.31 → 2026.6.2

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 (72) hide show
  1. package/dist/assets/App-CiBjfJbZ.js +245 -0
  2. package/dist/assets/App-D0TZLRrI.css +1 -0
  3. package/dist/assets/{MetricsService-BmWgjSY6.js → MetricsService-B6NNBaFU.js} +1 -1
  4. package/dist/assets/{SubAgentsPanel-CwthoMI_.js → SubAgentsPanel-CJmIvsg3.js} +1 -1
  5. package/dist/assets/{architectureDiagram-3BPJPVTR-Dy1WYxWM.js → architectureDiagram-3BPJPVTR-B6Aigvp7.js} +1 -1
  6. package/dist/assets/{blockDiagram-GPEHLZMM-aedwN9_l.js → blockDiagram-GPEHLZMM-BG4jFash.js} +1 -1
  7. package/dist/assets/{c4Diagram-AAUBKEIU-cg0iSka3.js → c4Diagram-AAUBKEIU-Bmsq6Nwl.js} +1 -1
  8. package/dist/assets/{chunk-2J33WTMH-Db_IUuVS.js → chunk-2J33WTMH-BeBOyD8r.js} +1 -1
  9. package/dist/assets/{chunk-4BX2VUAB-BUYjDrtk.js → chunk-4BX2VUAB-CvWY7Izk.js} +1 -1
  10. package/dist/assets/{chunk-55IACEB6-C5iBqUl4.js → chunk-55IACEB6-CSRfOrIS.js} +1 -1
  11. package/dist/assets/{chunk-727SXJPM-Blb-tKDG.js → chunk-727SXJPM-k_VOeRRa.js} +1 -1
  12. package/dist/assets/{chunk-AQP2D5EJ-F4YtqWlO.js → chunk-AQP2D5EJ-eCCYzF54.js} +1 -1
  13. package/dist/assets/{chunk-FMBD7UC4-Bq8SpeDt.js → chunk-FMBD7UC4-B7yGAY4w.js} +1 -1
  14. package/dist/assets/{chunk-ND2GUHAM-ByS3BRpp.js → chunk-ND2GUHAM-pNlL9ELu.js} +1 -1
  15. package/dist/assets/{chunk-QZHKN3VN-aUC9E4oT.js → chunk-QZHKN3VN-C46sDVU5.js} +1 -1
  16. package/dist/assets/classDiagram-4FO5ZUOK-Bt1SwZSt.js +1 -0
  17. package/dist/assets/classDiagram-v2-Q7XG4LA2-Bt1SwZSt.js +1 -0
  18. package/dist/assets/{cose-bilkent-S5V4N54A-Vu5Gdzcz.js → cose-bilkent-S5V4N54A-BbJSEGbL.js} +1 -1
  19. package/dist/assets/{dagre-BM42HDAG-G5OewMg7.js → dagre-BM42HDAG-DAgnHbAW.js} +1 -1
  20. package/dist/assets/{diagram-2AECGRRQ-D5JG5BbH.js → diagram-2AECGRRQ-DvSwTGxM.js} +1 -1
  21. package/dist/assets/{diagram-5GNKFQAL-CwnMGQxg.js → diagram-5GNKFQAL-DEJHaLfu.js} +1 -1
  22. package/dist/assets/{diagram-KO2AKTUF-DZYVd7GF.js → diagram-KO2AKTUF-DrqjmP_T.js} +1 -1
  23. package/dist/assets/{diagram-LMA3HP47-CdJV02zy.js → diagram-LMA3HP47-Bjo5cwtc.js} +1 -1
  24. package/dist/assets/{diagram-OG6HWLK6-B0fpvJJt.js → diagram-OG6HWLK6-Xt8OEUbk.js} +1 -1
  25. package/dist/assets/{en-US-Bn6iZkOI.js → en-US-Bj91Ptrm.js} +1 -1
  26. package/dist/assets/{erDiagram-TEJ5UH35-DT7eq9xF.js → erDiagram-TEJ5UH35-CyY6UxKD.js} +1 -1
  27. package/dist/assets/{flowDiagram-I6XJVG4X-B49chWNh.js → flowDiagram-I6XJVG4X-CxYF-4G3.js} +1 -1
  28. package/dist/assets/{ganttDiagram-6RSMTGT7-CHb8jAv1.js → ganttDiagram-6RSMTGT7-CPOiW77k.js} +1 -1
  29. package/dist/assets/{gitGraphDiagram-PVQCEYII-CngI0KWW.js → gitGraphDiagram-PVQCEYII-DrOgkuZM.js} +1 -1
  30. package/dist/assets/{index-DVH1B_uO.js → index-2nERrqJS.js} +1 -1
  31. package/dist/assets/index-B4T1KHs6.js +1 -0
  32. package/dist/assets/{index-VJlNpEpx.js → index-BWX57hkV.js} +1 -1
  33. package/dist/assets/{index-Sgj4-nUv.js → index-BeXVgYXk.js} +1 -1
  34. package/dist/assets/{index-Cg_ukrG-.js → index-BjFjcKGZ.js} +1 -1
  35. package/dist/assets/{index-BGDt8oDL.js → index-BmrwviZb.js} +1 -1
  36. package/dist/assets/{index-BVoCiggE.js → index-D6dXobma.js} +1 -1
  37. package/dist/assets/{index-CJUZhol6.js → index-DNS3k4mM.js} +1 -1
  38. package/dist/assets/{index-D6scerhZ.js → index-DPAR85WM.js} +1 -1
  39. package/dist/assets/index-Di8pH-kP.js +8 -0
  40. package/dist/assets/index-DiWM3I28.js +22 -0
  41. package/dist/assets/{infoDiagram-5YYISTIA-BaIG0z2C.js → infoDiagram-5YYISTIA-C84arbm7.js} +1 -1
  42. package/dist/assets/{ishikawaDiagram-YF4QCWOH-D01QkFfb.js → ishikawaDiagram-YF4QCWOH-CcecJvgD.js} +1 -1
  43. package/dist/assets/{journeyDiagram-JHISSGLW-CKBuDJCY.js → journeyDiagram-JHISSGLW-BUqT2Za3.js} +1 -1
  44. package/dist/assets/{kanban-definition-UN3LZRKU-CjX9GiJB.js → kanban-definition-UN3LZRKU-CzZzby99.js} +1 -1
  45. package/dist/assets/main-CvPZyRz3.js +8 -0
  46. package/dist/assets/{mindmap-definition-RKZ34NQL-6JLvFVXa.js → mindmap-definition-RKZ34NQL-CmVDGb3s.js} +1 -1
  47. package/dist/assets/{pieDiagram-4H26LBE5-D4cNQ3ti.js → pieDiagram-4H26LBE5-DH2IiUT-.js} +1 -1
  48. package/dist/assets/{quadrantDiagram-W4KKPZXB-Dedmyssy.js → quadrantDiagram-W4KKPZXB--NA0nuaI.js} +1 -1
  49. package/dist/assets/{requirementDiagram-4Y6WPE33-Dj4h0X4J.js → requirementDiagram-4Y6WPE33-DgTgIhBX.js} +1 -1
  50. package/dist/assets/{sankeyDiagram-5OEKKPKP-BRBTHSKo.js → sankeyDiagram-5OEKKPKP-CALJaoqk.js} +1 -1
  51. package/dist/assets/{sequenceDiagram-3UESZ5HK-o8kMGEwZ.js → sequenceDiagram-3UESZ5HK-BXGdJmYN.js} +1 -1
  52. package/dist/assets/{stateDiagram-AJRCARHV-DVQ3rByA.js → stateDiagram-AJRCARHV-CLL4nh4w.js} +1 -1
  53. package/dist/assets/{stateDiagram-v2-BHNVJYJU-Bcon_ENq.js → stateDiagram-v2-BHNVJYJU-CFglal-4.js} +1 -1
  54. package/dist/assets/{timeline-definition-PNZ67QCA-CszgjZln.js → timeline-definition-PNZ67QCA-BIZqkLkh.js} +1 -1
  55. package/dist/assets/{vendor-charts-BETi7DVC.js → vendor-charts-CRpjYi1a.js} +1 -1
  56. package/dist/assets/{vendor-mermaid-B_9yBBtL.js → vendor-mermaid-DBtTSFLf.js} +3 -3
  57. package/dist/assets/{vendor-pdf-ByUYUPlZ.js → vendor-pdf-DpZo6MNQ.js} +3 -3
  58. package/dist/assets/{vennDiagram-CIIHVFJN-7OBV2019.js → vennDiagram-CIIHVFJN-D1jzM1K8.js} +1 -1
  59. package/dist/assets/{wardley-L42UT6IY-C4EL3m5F.js → wardley-L42UT6IY-Yq8es9jt.js} +1 -1
  60. package/dist/assets/{wardleyDiagram-YWT4CUSO-Ehr7A28a.js → wardleyDiagram-YWT4CUSO-DlhxW9kY.js} +1 -1
  61. package/dist/assets/{xychartDiagram-2RQKCTM6-CRdOURrD.js → xychartDiagram-2RQKCTM6-BipN62gu.js} +1 -1
  62. package/dist/assets/{zh-CN-Cw8YiQz9.js → zh-CN-C8K1JeQZ.js} +1 -1
  63. package/dist/index.html +2 -2
  64. package/package.json +1 -1
  65. package/dist/assets/App-BAFyf064.js +0 -245
  66. package/dist/assets/App-DNZiQHSs.css +0 -1
  67. package/dist/assets/classDiagram-4FO5ZUOK-CdcCCQ8L.js +0 -1
  68. package/dist/assets/classDiagram-v2-Q7XG4LA2-CdcCCQ8L.js +0 -1
  69. package/dist/assets/index-BNXMB2Gh.js +0 -1
  70. package/dist/assets/index-jNr_4aYr.js +0 -8
  71. package/dist/assets/index-p5QnuY4O.js +0 -22
  72. package/dist/assets/main-C1pyfoEz.js +0 -8
@@ -1,4 +1,4 @@
1
- import{p as he}from"./chunk-4BX2VUAB-BUYjDrtk.js";import{I as $e}from"./chunk-QZHKN3VN-aUC9E4oT.js";import{ap as fe,ao as ge,a4 as ue,a5 as ye,a6 as xe,a7 as me,a8 as $,aA as Q,ab as k,aa as pe,a9 as z,an as be,aB as we,av as ke,ai as L,aC as ve,aD as Ee,aE as Ce}from"./vendor-mermaid-B_9yBBtL.js";import{p as Be}from"./wardley-L42UT6IY-C4EL3m5F.js";import"./vendor-antd-CKNrd1kL.js";import"./vendor-i18n-Dm-c3D_C.js";var p={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},Te=Ee.gitGraph,D=$(()=>ve({...Te,...Q().gitGraph}),"getConfig"),i=new $e(()=>{const e=D(),r=e.mainBranchName,t=e.mainBranchOrder;return{mainBranchName:r,commits:new Map,head:null,branchConfig:new Map([[r,{name:r,order:t}]]),branches:new Map([[r,null]]),currBranch:r,direction:"LR",seq:0,options:{}}});function K(){return Ce({length:7})}$(K,"getID");function ae(e,r){const t=Object.create(null);return e.reduce((o,s)=>{const d=r(s);return t[d]||(t[d]=!0,o.push(s)),o},[])}$(ae,"uniqBy");var Le=$(function(e){i.records.direction=e},"setDirection"),Me=$(function(e){k.debug("options str",e),e=e==null?void 0:e.trim(),e=e||"{}";try{i.records.options=JSON.parse(e)}catch(r){k.error("error while parsing gitGraph options",r.message)}},"setOptions"),Re=$(function(){return i.records.options},"getOptions"),Ie=$(function(e){let r=e.msg,t=e.id;const o=e.type;let s=e.tags;k.info("commit",r,t,o,s),k.debug("Entering commit:",r,t,o,s);const d=D();t=L.sanitizeText(t,d),r=L.sanitizeText(r,d),s=s==null?void 0:s.map(a=>L.sanitizeText(a,d));const n={id:t||i.records.seq+"-"+K(),message:r,seq:i.records.seq++,type:o??p.NORMAL,tags:s??[],parents:i.records.head==null?[]:[i.records.head.id],branch:i.records.currBranch};i.records.head=n,k.info("main branch",d.mainBranchName),i.records.commits.has(n.id)&&k.warn(`Commit ID ${n.id} already exists`),i.records.commits.set(n.id,n),i.records.branches.set(i.records.currBranch,n.id),k.debug("in pushCommit "+n.id)},"commit"),Oe=$(function(e){let r=e.name;const t=e.order;if(r=L.sanitizeText(r,D()),i.records.branches.has(r))throw new Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${r}")`);i.records.branches.set(r,i.records.head!=null?i.records.head.id:null),i.records.branchConfig.set(r,{name:r,order:t}),ne(r),k.debug("in createBranch")},"branch"),_e=$(e=>{let r=e.branch,t=e.id;const o=e.type,s=e.tags,d=D();r=L.sanitizeText(r,d),t&&(t=L.sanitizeText(t,d));const n=i.records.branches.get(i.records.currBranch),a=i.records.branches.get(r),l=n?i.records.commits.get(n):void 0,h=a?i.records.commits.get(a):void 0;if(l&&h&&l.branch===r)throw new Error(`Cannot merge branch '${r}' into itself.`);if(i.records.currBranch===r){const c=new Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},c}if(l===void 0||!l){const c=new Error(`Incorrect usage of "merge". Current branch (${i.records.currBranch})has no commits`);throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["commit"]},c}if(!i.records.branches.has(r)){const c=new Error('Incorrect usage of "merge". Branch to be merged ('+r+") does not exist");throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:[`branch ${r}`]},c}if(h===void 0||!h){const c=new Error('Incorrect usage of "merge". Branch to be merged ('+r+") has no commits");throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:['"commit"']},c}if(l===h){const c=new Error('Incorrect usage of "merge". Both branches have same head');throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},c}if(t&&i.records.commits.has(t)){const c=new Error('Incorrect usage of "merge". Commit with id:'+t+" already exists, use different custom id");throw c.hash={text:`merge ${r} ${t} ${o} ${s==null?void 0:s.join(" ")}`,token:`merge ${r} ${t} ${o} ${s==null?void 0:s.join(" ")}`,expected:[`merge ${r} ${t}_UNIQUE ${o} ${s==null?void 0:s.join(" ")}`]},c}const g=a||"",f={id:t||`${i.records.seq}-${K()}`,message:`merged branch ${r} into ${i.records.currBranch}`,seq:i.records.seq++,parents:i.records.head==null?[]:[i.records.head.id,g],branch:i.records.currBranch,type:p.MERGE,customType:o,customId:!!t,tags:s??[]};i.records.head=f,i.records.commits.set(f.id,f),i.records.branches.set(i.records.currBranch,f.id),k.debug(i.records.branches),k.debug("in mergeBranch")},"merge"),Ge=$(function(e){let r=e.id,t=e.targetId,o=e.tags,s=e.parent;k.debug("Entering cherryPick:",r,t,o);const d=D();if(r=L.sanitizeText(r,d),t=L.sanitizeText(t,d),o=o==null?void 0:o.map(l=>L.sanitizeText(l,d)),s=L.sanitizeText(s,d),!r||!i.records.commits.has(r)){const l=new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw l.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},l}const n=i.records.commits.get(r);if(n===void 0||!n)throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(s&&!(Array.isArray(n.parents)&&n.parents.includes(s)))throw new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");const a=n.branch;if(n.type===p.MERGE&&!s)throw new Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");if(!t||!i.records.commits.has(t)){if(a===i.records.currBranch){const f=new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw f.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},f}const l=i.records.branches.get(i.records.currBranch);if(l===void 0||!l){const f=new Error(`Incorrect usage of "cherry-pick". Current branch (${i.records.currBranch})has no commits`);throw f.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},f}const h=i.records.commits.get(l);if(h===void 0||!h){const f=new Error(`Incorrect usage of "cherry-pick". Current branch (${i.records.currBranch})has no commits`);throw f.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},f}const g={id:i.records.seq+"-"+K(),message:`cherry-picked ${n==null?void 0:n.message} into ${i.records.currBranch}`,seq:i.records.seq++,parents:i.records.head==null?[]:[i.records.head.id,n.id],branch:i.records.currBranch,type:p.CHERRY_PICK,tags:o?o.filter(Boolean):[`cherry-pick:${n.id}${n.type===p.MERGE?`|parent:${s}`:""}`]};i.records.head=g,i.records.commits.set(g.id,g),i.records.branches.set(i.records.currBranch,g.id),k.debug(i.records.branches),k.debug("in cherryPick")}},"cherryPick"),ne=$(function(e){if(e=L.sanitizeText(e,D()),i.records.branches.has(e)){i.records.currBranch=e;const r=i.records.branches.get(i.records.currBranch);r===void 0||!r?i.records.head=null:i.records.head=i.records.commits.get(r)??null}else{const r=new Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`);throw r.hash={text:`checkout ${e}`,token:`checkout ${e}`,expected:[`branch ${e}`]},r}},"checkout");function X(e,r,t){const o=e.indexOf(r);o===-1?e.push(t):e.splice(o,1,t)}$(X,"upsert");function Z(e){const r=e.reduce((s,d)=>s.seq>d.seq?s:d,e[0]);let t="";e.forEach(function(s){s===r?t+=" *":t+=" |"});const o=[t,r.id,r.seq];for(const s in i.records.branches)i.records.branches.get(s)===r.id&&o.push(s);if(k.debug(o.join(" ")),r.parents&&r.parents.length==2&&r.parents[0]&&r.parents[1]){const s=i.records.commits.get(r.parents[0]);X(e,r,s),r.parents[1]&&e.push(i.records.commits.get(r.parents[1]))}else{if(r.parents.length==0)return;if(r.parents[0]){const s=i.records.commits.get(r.parents[0]);X(e,r,s)}}e=ae(e,s=>s.id),Z(e)}$(Z,"prettyPrintCommitHistory");var He=$(function(){k.debug(i.records.commits);const e=se()[0];Z([e])},"prettyPrint"),Ae=$(function(){i.reset(),ke()},"clear"),Se=$(function(){return[...i.records.branchConfig.values()].map((r,t)=>r.order!==null&&r.order!==void 0?r:{...r,order:parseFloat(`0.${t}`)}).sort((r,t)=>(r.order??0)-(t.order??0)).map(({name:r})=>({name:r}))},"getBranchesAsObjArray"),De=$(function(){return i.records.branches},"getBranches"),Pe=$(function(){return i.records.commits},"getCommits"),se=$(function(){const e=[...i.records.commits.values()];return e.forEach(function(r){k.debug(r.id)}),e.sort((r,t)=>r.seq-t.seq),e},"getCommitsArray"),We=$(function(){return i.records.currBranch},"getCurrentBranch"),qe=$(function(){return i.records.direction},"getDirection"),Ne=$(function(){return i.records.head},"getHead"),oe={commitType:p,getConfig:D,setDirection:Le,setOptions:Me,getOptions:Re,commit:Ie,branch:Oe,merge:_e,cherryPick:Ge,checkout:ne,prettyPrint:He,clear:Ae,getBranchesAsObjArray:Se,getBranches:De,getCommits:Pe,getCommitsArray:se,getCurrentBranch:We,getDirection:qe,getHead:Ne,setAccTitle:me,getAccTitle:xe,getAccDescription:ye,setAccDescription:ue,setDiagramTitle:ge,getDiagramTitle:fe},Fe=$((e,r)=>{he(e,r),e.dir&&r.setDirection(e.dir);for(const t of e.statements)ze(t,r)},"populate"),ze=$((e,r)=>{const o={Commit:$(s=>r.commit(Ye(s)),"Commit"),Branch:$(s=>r.branch(je(s)),"Branch"),Merge:$(s=>r.merge(Ue(s)),"Merge"),Checkout:$(s=>r.checkout(Ke(s)),"Checkout"),CherryPicking:$(s=>r.cherryPick(Ve(s)),"CherryPicking")}[e.$type];o?o(e):k.error(`Unknown statement type: ${e.$type}`)},"parseStatement"),Ye=$(e=>({id:e.id,msg:e.message??"",type:e.type!==void 0?p[e.type]:p.NORMAL,tags:e.tags??void 0}),"parseCommit"),je=$(e=>({name:e.name,order:e.order??0}),"parseBranch"),Ue=$(e=>({branch:e.branch,id:e.id??"",type:e.type!==void 0?p[e.type]:void 0,tags:e.tags??void 0}),"parseMerge"),Ke=$(e=>e.branch,"parseCheckout"),Ve=$(e=>{var t;return{id:e.id,targetId:"",tags:((t=e.tags)==null?void 0:t.length)===0?void 0:e.tags,parent:e.parent}},"parseCherryPicking"),Xe={parse:$(async e=>{const r=await Be("gitGraph",e);k.debug(r),Fe(r,oe)},"parse")},G=10,H=40,M=4,I=2,A=8,V=new Set(["redux","redux-dark","redux-color","redux-dark-color"]),J=12,ee=new Set(["redux-color","redux-dark-color"]),Je=new Set(["dark","redux-dark","redux-dark-color","neo-dark"]),S=$((e,r,t=!1)=>t&&e>0?(e-1)%(r-1)+1:e%r,"calcColorIndex"),B=new Map,T=new Map,j=30,N=new Map,U=[],O=0,y="LR",Qe=$(()=>{B.clear(),T.clear(),N.clear(),O=0,U=[],y="LR"},"clear"),ce=$(e=>{const r=document.createElementNS("http://www.w3.org/2000/svg","text");return(typeof e=="string"?e.split(/\\n|\n|<br\s*\/?>/gi):e).forEach(o=>{const s=document.createElementNS("http://www.w3.org/2000/svg","tspan");s.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),s.setAttribute("dy","1em"),s.setAttribute("x","0"),s.setAttribute("class","row"),s.textContent=o.trim(),r.appendChild(s)}),r},"drawText"),ie=$(e=>{let r,t,o;return y==="BT"?(t=$((s,d)=>s<=d,"comparisonFunc"),o=1/0):(t=$((s,d)=>s>=d,"comparisonFunc"),o=0),e.forEach(s=>{var n,a;const d=y==="TB"||y=="BT"?(n=T.get(s))==null?void 0:n.y:(a=T.get(s))==null?void 0:a.x;d!==void 0&&t(d,o)&&(r=s,o=d)}),r},"findClosestParent"),Ze=$(e=>{let r="",t=1/0;return e.forEach(o=>{const s=T.get(o).y;s<=t&&(r=o,t=s)}),r||void 0},"findClosestParentBT"),er=$((e,r,t)=>{let o=t,s=t;const d=[];e.forEach(n=>{const a=r.get(n);if(!a)throw new Error(`Commit not found for key ${n}`);a.parents.length?(o=tr(a),s=Math.max(o,s)):d.push(a),ar(a,o)}),o=s,d.forEach(n=>{nr(n,o,t)}),e.forEach(n=>{const a=r.get(n);if(a!=null&&a.parents.length){const l=Ze(a.parents);o=T.get(l).y-H,o<=s&&(s=o);const h=B.get(a.branch).pos,g=o-G;T.set(a.id,{x:h,y:g})}})},"setParallelBTPos"),rr=$(e=>{var o;const r=ie(e.parents.filter(s=>s!==null));if(!r)throw new Error(`Closest parent not found for commit ${e.id}`);const t=(o=T.get(r))==null?void 0:o.y;if(t===void 0)throw new Error(`Closest parent position not found for commit ${e.id}`);return t},"findClosestParentPos"),tr=$(e=>rr(e)+H,"calculateCommitPosition"),ar=$((e,r)=>{const t=B.get(e.branch);if(!t)throw new Error(`Branch not found for commit ${e.id}`);const o=t.pos,s=r+G;return T.set(e.id,{x:o,y:s}),{x:o,y:s}},"setCommitPosition"),nr=$((e,r,t)=>{const o=B.get(e.branch);if(!o)throw new Error(`Branch not found for commit ${e.id}`);const s=r+t,d=o.pos;T.set(e.id,{x:d,y:s})},"setRootPosition"),sr=$((e,r,t,o,s,d)=>{const{theme:n}=z(),a=V.has(n??""),l=ee.has(n??""),h=Je.has(n??"");if(d===p.HIGHLIGHT)e.append("rect").attr("x",t.x-10+(a?3:0)).attr("y",t.y-10+(a?3:0)).attr("width",a?14:20).attr("height",a?14:20).attr("class",`commit ${r.id} commit-highlight${S(s,A,l)} ${o}-outer`),e.append("rect").attr("x",t.x-6+(a?2:0)).attr("y",t.y-6+(a?2:0)).attr("width",a?8:12).attr("height",a?8:12).attr("class",`commit ${r.id} commit${S(s,A,l)} ${o}-inner`);else if(d===p.CHERRY_PICK)e.append("circle").attr("cx",t.x).attr("cy",t.y).attr("r",a?7:10).attr("class",`commit ${r.id} ${o}`),e.append("circle").attr("cx",t.x-3).attr("cy",t.y+2).attr("r",a?2.5:2.75).attr("fill",h?"#000000":"#fff").attr("class",`commit ${r.id} ${o}`),e.append("circle").attr("cx",t.x+3).attr("cy",t.y+2).attr("r",a?2.5:2.75).attr("fill",h?"#000000":"#fff").attr("class",`commit ${r.id} ${o}`),e.append("line").attr("x1",t.x+3).attr("y1",t.y+1).attr("x2",t.x).attr("y2",t.y-5).attr("stroke",h?"#000000":"#fff").attr("class",`commit ${r.id} ${o}`),e.append("line").attr("x1",t.x-3).attr("y1",t.y+1).attr("x2",t.x).attr("y2",t.y-5).attr("stroke",h?"#000000":"#fff").attr("class",`commit ${r.id} ${o}`);else{const g=e.append("circle");if(g.attr("cx",t.x),g.attr("cy",t.y),g.attr("r",a?7:10),g.attr("class",`commit ${r.id} commit${S(s,A,l)}`),d===p.MERGE){const f=e.append("circle");f.attr("cx",t.x),f.attr("cy",t.y),f.attr("r",a?5:6),f.attr("class",`commit ${o} ${r.id} commit${S(s,A,l)}`)}if(d===p.REVERSE){const f=e.append("path"),c=a?4:5;f.attr("d",`M ${t.x-c},${t.y-c}L${t.x+c},${t.y+c}M${t.x-c},${t.y+c}L${t.x+c},${t.y-c}`).attr("class",`commit ${o} ${r.id} commit${S(s,A,l)}`)}}},"drawCommitBullet"),or=$((e,r,t,o,s)=>{var d;if(r.type!==p.CHERRY_PICK&&(r.customId&&r.type===p.MERGE||r.type!==p.MERGE)&&s.showCommitLabel){const n=e.append("g"),a=n.insert("rect").attr("class","commit-label-bkg"),l=n.append("text").attr("x",o).attr("y",t.y+25).attr("class","commit-label").text(r.id),h=(d=l.node())==null?void 0:d.getBBox();if(h&&(a.attr("x",t.posWithOffset-h.width/2-I).attr("y",t.y+13.5).attr("width",h.width+2*I).attr("height",h.height+2*I),y==="TB"||y==="BT"?(a.attr("x",t.x-(h.width+4*M+5)).attr("y",t.y-12),l.attr("x",t.x-(h.width+4*M)).attr("y",t.y+h.height-12)):l.attr("x",t.posWithOffset-h.width/2),s.rotateCommitLabel))if(y==="TB"||y==="BT")l.attr("transform","rotate(-45, "+t.x+", "+t.y+")"),a.attr("transform","rotate(-45, "+t.x+", "+t.y+")");else{const g=-7.5-(h.width+10)/25*9.5,f=10+h.width/25*8.5;n.attr("transform","translate("+g+", "+f+") rotate(-45, "+o+", "+t.y+")")}}},"drawCommitLabel"),cr=$((e,r,t,o)=>{var s;if(r.tags.length>0){let d=0,n=0,a=0;const l=[];for(const h of r.tags.reverse()){const g=e.insert("polygon"),f=e.append("circle"),c=e.append("text").attr("y",t.y-16-d).attr("class","tag-label").text(h),x=(s=c.node())==null?void 0:s.getBBox();if(!x)throw new Error("Tag bbox not found");n=Math.max(n,x.width),a=Math.max(a,x.height),c.attr("x",t.posWithOffset-x.width/2),l.push({tag:c,hole:f,rect:g,yOffset:d}),d+=20}for(const{tag:h,hole:g,rect:f,yOffset:c}of l){const x=a/2,u=t.y-19.2-c;if(f.attr("class","tag-label-bkg").attr("points",`
1
+ import{p as he}from"./chunk-4BX2VUAB-CvWY7Izk.js";import{I as $e}from"./chunk-QZHKN3VN-C46sDVU5.js";import{ap as fe,ao as ge,a4 as ue,a5 as ye,a6 as xe,a7 as me,a8 as $,aA as Q,ab as k,aa as pe,a9 as z,an as be,aB as we,av as ke,ai as L,aC as ve,aD as Ee,aE as Ce}from"./vendor-mermaid-DBtTSFLf.js";import{p as Be}from"./wardley-L42UT6IY-Yq8es9jt.js";import"./vendor-antd-CKNrd1kL.js";import"./vendor-i18n-Dm-c3D_C.js";var p={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},Te=Ee.gitGraph,D=$(()=>ve({...Te,...Q().gitGraph}),"getConfig"),i=new $e(()=>{const e=D(),r=e.mainBranchName,t=e.mainBranchOrder;return{mainBranchName:r,commits:new Map,head:null,branchConfig:new Map([[r,{name:r,order:t}]]),branches:new Map([[r,null]]),currBranch:r,direction:"LR",seq:0,options:{}}});function K(){return Ce({length:7})}$(K,"getID");function ae(e,r){const t=Object.create(null);return e.reduce((o,s)=>{const d=r(s);return t[d]||(t[d]=!0,o.push(s)),o},[])}$(ae,"uniqBy");var Le=$(function(e){i.records.direction=e},"setDirection"),Me=$(function(e){k.debug("options str",e),e=e==null?void 0:e.trim(),e=e||"{}";try{i.records.options=JSON.parse(e)}catch(r){k.error("error while parsing gitGraph options",r.message)}},"setOptions"),Re=$(function(){return i.records.options},"getOptions"),Ie=$(function(e){let r=e.msg,t=e.id;const o=e.type;let s=e.tags;k.info("commit",r,t,o,s),k.debug("Entering commit:",r,t,o,s);const d=D();t=L.sanitizeText(t,d),r=L.sanitizeText(r,d),s=s==null?void 0:s.map(a=>L.sanitizeText(a,d));const n={id:t||i.records.seq+"-"+K(),message:r,seq:i.records.seq++,type:o??p.NORMAL,tags:s??[],parents:i.records.head==null?[]:[i.records.head.id],branch:i.records.currBranch};i.records.head=n,k.info("main branch",d.mainBranchName),i.records.commits.has(n.id)&&k.warn(`Commit ID ${n.id} already exists`),i.records.commits.set(n.id,n),i.records.branches.set(i.records.currBranch,n.id),k.debug("in pushCommit "+n.id)},"commit"),Oe=$(function(e){let r=e.name;const t=e.order;if(r=L.sanitizeText(r,D()),i.records.branches.has(r))throw new Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${r}")`);i.records.branches.set(r,i.records.head!=null?i.records.head.id:null),i.records.branchConfig.set(r,{name:r,order:t}),ne(r),k.debug("in createBranch")},"branch"),_e=$(e=>{let r=e.branch,t=e.id;const o=e.type,s=e.tags,d=D();r=L.sanitizeText(r,d),t&&(t=L.sanitizeText(t,d));const n=i.records.branches.get(i.records.currBranch),a=i.records.branches.get(r),l=n?i.records.commits.get(n):void 0,h=a?i.records.commits.get(a):void 0;if(l&&h&&l.branch===r)throw new Error(`Cannot merge branch '${r}' into itself.`);if(i.records.currBranch===r){const c=new Error('Incorrect usage of "merge". Cannot merge a branch to itself');throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},c}if(l===void 0||!l){const c=new Error(`Incorrect usage of "merge". Current branch (${i.records.currBranch})has no commits`);throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["commit"]},c}if(!i.records.branches.has(r)){const c=new Error('Incorrect usage of "merge". Branch to be merged ('+r+") does not exist");throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:[`branch ${r}`]},c}if(h===void 0||!h){const c=new Error('Incorrect usage of "merge". Branch to be merged ('+r+") has no commits");throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:['"commit"']},c}if(l===h){const c=new Error('Incorrect usage of "merge". Both branches have same head');throw c.hash={text:`merge ${r}`,token:`merge ${r}`,expected:["branch abc"]},c}if(t&&i.records.commits.has(t)){const c=new Error('Incorrect usage of "merge". Commit with id:'+t+" already exists, use different custom id");throw c.hash={text:`merge ${r} ${t} ${o} ${s==null?void 0:s.join(" ")}`,token:`merge ${r} ${t} ${o} ${s==null?void 0:s.join(" ")}`,expected:[`merge ${r} ${t}_UNIQUE ${o} ${s==null?void 0:s.join(" ")}`]},c}const g=a||"",f={id:t||`${i.records.seq}-${K()}`,message:`merged branch ${r} into ${i.records.currBranch}`,seq:i.records.seq++,parents:i.records.head==null?[]:[i.records.head.id,g],branch:i.records.currBranch,type:p.MERGE,customType:o,customId:!!t,tags:s??[]};i.records.head=f,i.records.commits.set(f.id,f),i.records.branches.set(i.records.currBranch,f.id),k.debug(i.records.branches),k.debug("in mergeBranch")},"merge"),Ge=$(function(e){let r=e.id,t=e.targetId,o=e.tags,s=e.parent;k.debug("Entering cherryPick:",r,t,o);const d=D();if(r=L.sanitizeText(r,d),t=L.sanitizeText(t,d),o=o==null?void 0:o.map(l=>L.sanitizeText(l,d)),s=L.sanitizeText(s,d),!r||!i.records.commits.has(r)){const l=new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');throw l.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},l}const n=i.records.commits.get(r);if(n===void 0||!n)throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');if(s&&!(Array.isArray(n.parents)&&n.parents.includes(s)))throw new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");const a=n.branch;if(n.type===p.MERGE&&!s)throw new Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");if(!t||!i.records.commits.has(t)){if(a===i.records.currBranch){const f=new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');throw f.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},f}const l=i.records.branches.get(i.records.currBranch);if(l===void 0||!l){const f=new Error(`Incorrect usage of "cherry-pick". Current branch (${i.records.currBranch})has no commits`);throw f.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},f}const h=i.records.commits.get(l);if(h===void 0||!h){const f=new Error(`Incorrect usage of "cherry-pick". Current branch (${i.records.currBranch})has no commits`);throw f.hash={text:`cherryPick ${r} ${t}`,token:`cherryPick ${r} ${t}`,expected:["cherry-pick abc"]},f}const g={id:i.records.seq+"-"+K(),message:`cherry-picked ${n==null?void 0:n.message} into ${i.records.currBranch}`,seq:i.records.seq++,parents:i.records.head==null?[]:[i.records.head.id,n.id],branch:i.records.currBranch,type:p.CHERRY_PICK,tags:o?o.filter(Boolean):[`cherry-pick:${n.id}${n.type===p.MERGE?`|parent:${s}`:""}`]};i.records.head=g,i.records.commits.set(g.id,g),i.records.branches.set(i.records.currBranch,g.id),k.debug(i.records.branches),k.debug("in cherryPick")}},"cherryPick"),ne=$(function(e){if(e=L.sanitizeText(e,D()),i.records.branches.has(e)){i.records.currBranch=e;const r=i.records.branches.get(i.records.currBranch);r===void 0||!r?i.records.head=null:i.records.head=i.records.commits.get(r)??null}else{const r=new Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`);throw r.hash={text:`checkout ${e}`,token:`checkout ${e}`,expected:[`branch ${e}`]},r}},"checkout");function X(e,r,t){const o=e.indexOf(r);o===-1?e.push(t):e.splice(o,1,t)}$(X,"upsert");function Z(e){const r=e.reduce((s,d)=>s.seq>d.seq?s:d,e[0]);let t="";e.forEach(function(s){s===r?t+=" *":t+=" |"});const o=[t,r.id,r.seq];for(const s in i.records.branches)i.records.branches.get(s)===r.id&&o.push(s);if(k.debug(o.join(" ")),r.parents&&r.parents.length==2&&r.parents[0]&&r.parents[1]){const s=i.records.commits.get(r.parents[0]);X(e,r,s),r.parents[1]&&e.push(i.records.commits.get(r.parents[1]))}else{if(r.parents.length==0)return;if(r.parents[0]){const s=i.records.commits.get(r.parents[0]);X(e,r,s)}}e=ae(e,s=>s.id),Z(e)}$(Z,"prettyPrintCommitHistory");var He=$(function(){k.debug(i.records.commits);const e=se()[0];Z([e])},"prettyPrint"),Ae=$(function(){i.reset(),ke()},"clear"),Se=$(function(){return[...i.records.branchConfig.values()].map((r,t)=>r.order!==null&&r.order!==void 0?r:{...r,order:parseFloat(`0.${t}`)}).sort((r,t)=>(r.order??0)-(t.order??0)).map(({name:r})=>({name:r}))},"getBranchesAsObjArray"),De=$(function(){return i.records.branches},"getBranches"),Pe=$(function(){return i.records.commits},"getCommits"),se=$(function(){const e=[...i.records.commits.values()];return e.forEach(function(r){k.debug(r.id)}),e.sort((r,t)=>r.seq-t.seq),e},"getCommitsArray"),We=$(function(){return i.records.currBranch},"getCurrentBranch"),qe=$(function(){return i.records.direction},"getDirection"),Ne=$(function(){return i.records.head},"getHead"),oe={commitType:p,getConfig:D,setDirection:Le,setOptions:Me,getOptions:Re,commit:Ie,branch:Oe,merge:_e,cherryPick:Ge,checkout:ne,prettyPrint:He,clear:Ae,getBranchesAsObjArray:Se,getBranches:De,getCommits:Pe,getCommitsArray:se,getCurrentBranch:We,getDirection:qe,getHead:Ne,setAccTitle:me,getAccTitle:xe,getAccDescription:ye,setAccDescription:ue,setDiagramTitle:ge,getDiagramTitle:fe},Fe=$((e,r)=>{he(e,r),e.dir&&r.setDirection(e.dir);for(const t of e.statements)ze(t,r)},"populate"),ze=$((e,r)=>{const o={Commit:$(s=>r.commit(Ye(s)),"Commit"),Branch:$(s=>r.branch(je(s)),"Branch"),Merge:$(s=>r.merge(Ue(s)),"Merge"),Checkout:$(s=>r.checkout(Ke(s)),"Checkout"),CherryPicking:$(s=>r.cherryPick(Ve(s)),"CherryPicking")}[e.$type];o?o(e):k.error(`Unknown statement type: ${e.$type}`)},"parseStatement"),Ye=$(e=>({id:e.id,msg:e.message??"",type:e.type!==void 0?p[e.type]:p.NORMAL,tags:e.tags??void 0}),"parseCommit"),je=$(e=>({name:e.name,order:e.order??0}),"parseBranch"),Ue=$(e=>({branch:e.branch,id:e.id??"",type:e.type!==void 0?p[e.type]:void 0,tags:e.tags??void 0}),"parseMerge"),Ke=$(e=>e.branch,"parseCheckout"),Ve=$(e=>{var t;return{id:e.id,targetId:"",tags:((t=e.tags)==null?void 0:t.length)===0?void 0:e.tags,parent:e.parent}},"parseCherryPicking"),Xe={parse:$(async e=>{const r=await Be("gitGraph",e);k.debug(r),Fe(r,oe)},"parse")},G=10,H=40,M=4,I=2,A=8,V=new Set(["redux","redux-dark","redux-color","redux-dark-color"]),J=12,ee=new Set(["redux-color","redux-dark-color"]),Je=new Set(["dark","redux-dark","redux-dark-color","neo-dark"]),S=$((e,r,t=!1)=>t&&e>0?(e-1)%(r-1)+1:e%r,"calcColorIndex"),B=new Map,T=new Map,j=30,N=new Map,U=[],O=0,y="LR",Qe=$(()=>{B.clear(),T.clear(),N.clear(),O=0,U=[],y="LR"},"clear"),ce=$(e=>{const r=document.createElementNS("http://www.w3.org/2000/svg","text");return(typeof e=="string"?e.split(/\\n|\n|<br\s*\/?>/gi):e).forEach(o=>{const s=document.createElementNS("http://www.w3.org/2000/svg","tspan");s.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve"),s.setAttribute("dy","1em"),s.setAttribute("x","0"),s.setAttribute("class","row"),s.textContent=o.trim(),r.appendChild(s)}),r},"drawText"),ie=$(e=>{let r,t,o;return y==="BT"?(t=$((s,d)=>s<=d,"comparisonFunc"),o=1/0):(t=$((s,d)=>s>=d,"comparisonFunc"),o=0),e.forEach(s=>{var n,a;const d=y==="TB"||y=="BT"?(n=T.get(s))==null?void 0:n.y:(a=T.get(s))==null?void 0:a.x;d!==void 0&&t(d,o)&&(r=s,o=d)}),r},"findClosestParent"),Ze=$(e=>{let r="",t=1/0;return e.forEach(o=>{const s=T.get(o).y;s<=t&&(r=o,t=s)}),r||void 0},"findClosestParentBT"),er=$((e,r,t)=>{let o=t,s=t;const d=[];e.forEach(n=>{const a=r.get(n);if(!a)throw new Error(`Commit not found for key ${n}`);a.parents.length?(o=tr(a),s=Math.max(o,s)):d.push(a),ar(a,o)}),o=s,d.forEach(n=>{nr(n,o,t)}),e.forEach(n=>{const a=r.get(n);if(a!=null&&a.parents.length){const l=Ze(a.parents);o=T.get(l).y-H,o<=s&&(s=o);const h=B.get(a.branch).pos,g=o-G;T.set(a.id,{x:h,y:g})}})},"setParallelBTPos"),rr=$(e=>{var o;const r=ie(e.parents.filter(s=>s!==null));if(!r)throw new Error(`Closest parent not found for commit ${e.id}`);const t=(o=T.get(r))==null?void 0:o.y;if(t===void 0)throw new Error(`Closest parent position not found for commit ${e.id}`);return t},"findClosestParentPos"),tr=$(e=>rr(e)+H,"calculateCommitPosition"),ar=$((e,r)=>{const t=B.get(e.branch);if(!t)throw new Error(`Branch not found for commit ${e.id}`);const o=t.pos,s=r+G;return T.set(e.id,{x:o,y:s}),{x:o,y:s}},"setCommitPosition"),nr=$((e,r,t)=>{const o=B.get(e.branch);if(!o)throw new Error(`Branch not found for commit ${e.id}`);const s=r+t,d=o.pos;T.set(e.id,{x:d,y:s})},"setRootPosition"),sr=$((e,r,t,o,s,d)=>{const{theme:n}=z(),a=V.has(n??""),l=ee.has(n??""),h=Je.has(n??"");if(d===p.HIGHLIGHT)e.append("rect").attr("x",t.x-10+(a?3:0)).attr("y",t.y-10+(a?3:0)).attr("width",a?14:20).attr("height",a?14:20).attr("class",`commit ${r.id} commit-highlight${S(s,A,l)} ${o}-outer`),e.append("rect").attr("x",t.x-6+(a?2:0)).attr("y",t.y-6+(a?2:0)).attr("width",a?8:12).attr("height",a?8:12).attr("class",`commit ${r.id} commit${S(s,A,l)} ${o}-inner`);else if(d===p.CHERRY_PICK)e.append("circle").attr("cx",t.x).attr("cy",t.y).attr("r",a?7:10).attr("class",`commit ${r.id} ${o}`),e.append("circle").attr("cx",t.x-3).attr("cy",t.y+2).attr("r",a?2.5:2.75).attr("fill",h?"#000000":"#fff").attr("class",`commit ${r.id} ${o}`),e.append("circle").attr("cx",t.x+3).attr("cy",t.y+2).attr("r",a?2.5:2.75).attr("fill",h?"#000000":"#fff").attr("class",`commit ${r.id} ${o}`),e.append("line").attr("x1",t.x+3).attr("y1",t.y+1).attr("x2",t.x).attr("y2",t.y-5).attr("stroke",h?"#000000":"#fff").attr("class",`commit ${r.id} ${o}`),e.append("line").attr("x1",t.x-3).attr("y1",t.y+1).attr("x2",t.x).attr("y2",t.y-5).attr("stroke",h?"#000000":"#fff").attr("class",`commit ${r.id} ${o}`);else{const g=e.append("circle");if(g.attr("cx",t.x),g.attr("cy",t.y),g.attr("r",a?7:10),g.attr("class",`commit ${r.id} commit${S(s,A,l)}`),d===p.MERGE){const f=e.append("circle");f.attr("cx",t.x),f.attr("cy",t.y),f.attr("r",a?5:6),f.attr("class",`commit ${o} ${r.id} commit${S(s,A,l)}`)}if(d===p.REVERSE){const f=e.append("path"),c=a?4:5;f.attr("d",`M ${t.x-c},${t.y-c}L${t.x+c},${t.y+c}M${t.x-c},${t.y+c}L${t.x+c},${t.y-c}`).attr("class",`commit ${o} ${r.id} commit${S(s,A,l)}`)}}},"drawCommitBullet"),or=$((e,r,t,o,s)=>{var d;if(r.type!==p.CHERRY_PICK&&(r.customId&&r.type===p.MERGE||r.type!==p.MERGE)&&s.showCommitLabel){const n=e.append("g"),a=n.insert("rect").attr("class","commit-label-bkg"),l=n.append("text").attr("x",o).attr("y",t.y+25).attr("class","commit-label").text(r.id),h=(d=l.node())==null?void 0:d.getBBox();if(h&&(a.attr("x",t.posWithOffset-h.width/2-I).attr("y",t.y+13.5).attr("width",h.width+2*I).attr("height",h.height+2*I),y==="TB"||y==="BT"?(a.attr("x",t.x-(h.width+4*M+5)).attr("y",t.y-12),l.attr("x",t.x-(h.width+4*M)).attr("y",t.y+h.height-12)):l.attr("x",t.posWithOffset-h.width/2),s.rotateCommitLabel))if(y==="TB"||y==="BT")l.attr("transform","rotate(-45, "+t.x+", "+t.y+")"),a.attr("transform","rotate(-45, "+t.x+", "+t.y+")");else{const g=-7.5-(h.width+10)/25*9.5,f=10+h.width/25*8.5;n.attr("transform","translate("+g+", "+f+") rotate(-45, "+o+", "+t.y+")")}}},"drawCommitLabel"),cr=$((e,r,t,o)=>{var s;if(r.tags.length>0){let d=0,n=0,a=0;const l=[];for(const h of r.tags.reverse()){const g=e.insert("polygon"),f=e.append("circle"),c=e.append("text").attr("y",t.y-16-d).attr("class","tag-label").text(h),x=(s=c.node())==null?void 0:s.getBBox();if(!x)throw new Error("Tag bbox not found");n=Math.max(n,x.width),a=Math.max(a,x.height),c.attr("x",t.posWithOffset-x.width/2),l.push({tag:c,hole:f,rect:g,yOffset:d}),d+=20}for(const{tag:h,hole:g,rect:f,yOffset:c}of l){const x=a/2,u=t.y-19.2-c;if(f.attr("class","tag-label-bkg").attr("points",`
2
2
  ${o-n/2-M/2},${u+I}
3
3
  ${o-n/2-M/2},${u-I}
4
4
  ${t.posWithOffset-n/2-M},${u-x-I}
@@ -1 +1 @@
1
- import{j as e}from"./vendor-markdown-DrYaLZhb.js";import{u as N,a as _}from"./vendor-i18n-Dm-c3D_C.js";import{u as T,n as P,q as y,p as V}from"./App-BAFyf064.js";import{F as v,q as n,o as c,U as C,al as I,aj as R,am as S,ae as w,t as $}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-B_9yBBtL.js";import"./main-C1pyfoEz.js";const{useToken:E}=$,F=r=>{const o=r.replace(/\/$/,"").split("/").filter(Boolean);return o.length<=2?r:`~/${o.slice(-2).join("/")}`},G=({sessionId:r})=>{const{t:o}=N(),{token:x}=E(),t=T(P(r)),f=T(a=>a.systemPrompts),l=t==null?void 0:t.config.workspacePath,i=t==null?void 0:t.config.systemPromptId,s=t==null?void 0:t.config.tokenUsage,k=(t==null?void 0:t.config.compressionEvents)??[],m=_.useMemo(()=>{if(!i)return null;const a=f.find(B=>B.id===i);return(a==null?void 0:a.name)||i},[i,f]),p=_.useMemo(()=>t!=null&&t.messages?t.messages.filter(a=>a.role==="user"&&"type"in a&&a.type==="file_reference").length:0,[t==null?void 0:t.messages]);if(!t)return null;const h=(s==null?void 0:s.summaryTokens)??0,g=k.length,d=(s==null?void 0:s.promptCachedToolOutputs)??0,u=(s==null?void 0:s.promptCachedToolTokensSaved)??0,b=h>0||g>0,j=d>0||u>0;return l||m||p>0||b||j?e.jsx("div",{className:"lotus-context-bar",style:{borderBottomColor:x.colorBorderSecondary,backgroundColor:x.colorBgContainer},children:e.jsxs(v,{align:"center",gap:6,wrap:"wrap",className:"lotus-context-bar__content",children:[l&&e.jsx(n,{title:o("chat.contextBar.workspaceTooltip",{path:l,defaultValue:"Workspace context: {{path}}"}),children:e.jsxs(c,{className:"lotus-context-bar__tag",icon:e.jsx(C,{}),bordered:!1,children:[e.jsx("span",{className:"lotus-context-bar__tag-label",children:o("chat.contextBar.workspace",{defaultValue:"Workspace"})}),F(l)]})}),p>0&&e.jsx(n,{title:o("chat.contextBar.fileRefsTooltip",{count:p,defaultValue:"{{count}} file reference(s) in this session"}),children:e.jsxs(c,{className:"lotus-context-bar__tag",icon:e.jsx(I,{}),bordered:!1,children:[e.jsx("span",{className:"lotus-context-bar__tag-label",children:o("chat.contextBar.files",{defaultValue:"Files"})}),p]})}),m&&e.jsx(n,{title:o("chat.contextBar.promptTooltip",{name:m,defaultValue:"System prompt: {{name}}"}),children:e.jsxs(c,{className:"lotus-context-bar__tag",icon:e.jsx(R,{}),bordered:!1,children:[e.jsx("span",{className:"lotus-context-bar__tag-label",children:o("chat.contextBar.prompt",{defaultValue:"Prompt"})}),m]})}),b&&e.jsx(n,{title:o("chat.contextBar.summaryTooltip",{tokens:y(h),count:g,defaultValue:"Conversation summary contributes {{tokens}} tokens. {{count}} compression event(s) archived older messages."}),children:e.jsx(c,{className:"lotus-context-bar__tag lotus-context-bar__tag--signal",icon:e.jsx(S,{}),bordered:!1,color:"gold",children:o("chat.contextBar.summary",{defaultValue:"Summary"})})}),j&&e.jsx(n,{title:o("chat.contextBar.promptCacheTooltip",{count:d,tokens:y(u),defaultValue:"{{count}} tool output(s) were compacted into prompt-side cache notes, saving {{tokens}} tokens."}),children:e.jsxs(c,{className:"lotus-context-bar__tag lotus-context-bar__tag--signal",icon:e.jsx(w,{}),bordered:!1,color:"green",children:[e.jsx("span",{className:"lotus-context-bar__tag-label",children:o("chat.contextBar.promptCache",{defaultValue:"Prompt cache"})}),u>0?V(u):d]})})]})}):null};export{G as ContextBar,G as default};
1
+ import{j as e}from"./vendor-markdown-DrYaLZhb.js";import{u as N,a as _}from"./vendor-i18n-Dm-c3D_C.js";import{u as T,p as P,t as y,q as V}from"./App-CiBjfJbZ.js";import{F as v,q as n,o as c,U as C,al as I,aj as R,am as S,ae as w,t as $}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-DBtTSFLf.js";import"./main-CvPZyRz3.js";const{useToken:E}=$,F=r=>{const o=r.replace(/\/$/,"").split("/").filter(Boolean);return o.length<=2?r:`~/${o.slice(-2).join("/")}`},G=({sessionId:r})=>{const{t:o}=N(),{token:x}=E(),t=T(P(r)),f=T(a=>a.systemPrompts),l=t==null?void 0:t.config.workspacePath,i=t==null?void 0:t.config.systemPromptId,s=t==null?void 0:t.config.tokenUsage,k=(t==null?void 0:t.config.compressionEvents)??[],m=_.useMemo(()=>{if(!i)return null;const a=f.find(B=>B.id===i);return(a==null?void 0:a.name)||i},[i,f]),p=_.useMemo(()=>t!=null&&t.messages?t.messages.filter(a=>a.role==="user"&&"type"in a&&a.type==="file_reference").length:0,[t==null?void 0:t.messages]);if(!t)return null;const h=(s==null?void 0:s.summaryTokens)??0,g=k.length,d=(s==null?void 0:s.promptCachedToolOutputs)??0,u=(s==null?void 0:s.promptCachedToolTokensSaved)??0,b=h>0||g>0,j=d>0||u>0;return l||m||p>0||b||j?e.jsx("div",{className:"lotus-context-bar",style:{borderBottomColor:x.colorBorderSecondary,backgroundColor:x.colorBgContainer},children:e.jsxs(v,{align:"center",gap:6,wrap:"wrap",className:"lotus-context-bar__content",children:[l&&e.jsx(n,{title:o("chat.contextBar.workspaceTooltip",{path:l,defaultValue:"Workspace context: {{path}}"}),children:e.jsxs(c,{className:"lotus-context-bar__tag",icon:e.jsx(C,{}),bordered:!1,children:[e.jsx("span",{className:"lotus-context-bar__tag-label",children:o("chat.contextBar.workspace",{defaultValue:"Workspace"})}),F(l)]})}),p>0&&e.jsx(n,{title:o("chat.contextBar.fileRefsTooltip",{count:p,defaultValue:"{{count}} file reference(s) in this session"}),children:e.jsxs(c,{className:"lotus-context-bar__tag",icon:e.jsx(I,{}),bordered:!1,children:[e.jsx("span",{className:"lotus-context-bar__tag-label",children:o("chat.contextBar.files",{defaultValue:"Files"})}),p]})}),m&&e.jsx(n,{title:o("chat.contextBar.promptTooltip",{name:m,defaultValue:"System prompt: {{name}}"}),children:e.jsxs(c,{className:"lotus-context-bar__tag",icon:e.jsx(R,{}),bordered:!1,children:[e.jsx("span",{className:"lotus-context-bar__tag-label",children:o("chat.contextBar.prompt",{defaultValue:"Prompt"})}),m]})}),b&&e.jsx(n,{title:o("chat.contextBar.summaryTooltip",{tokens:y(h),count:g,defaultValue:"Conversation summary contributes {{tokens}} tokens. {{count}} compression event(s) archived older messages."}),children:e.jsx(c,{className:"lotus-context-bar__tag lotus-context-bar__tag--signal",icon:e.jsx(S,{}),bordered:!1,color:"gold",children:o("chat.contextBar.summary",{defaultValue:"Summary"})})}),j&&e.jsx(n,{title:o("chat.contextBar.promptCacheTooltip",{count:d,tokens:y(u),defaultValue:"{{count}} tool output(s) were compacted into prompt-side cache notes, saving {{tokens}} tokens."}),children:e.jsxs(c,{className:"lotus-context-bar__tag lotus-context-bar__tag--signal",icon:e.jsx(w,{}),bordered:!1,color:"green",children:[e.jsx("span",{className:"lotus-context-bar__tag-label",children:o("chat.contextBar.promptCache",{defaultValue:"Prompt cache"})}),u>0?V(u):d]})})]})}):null};export{G as ContextBar,G as default};
@@ -0,0 +1 @@
1
+ import{j as s}from"./vendor-markdown-DrYaLZhb.js";import{u as g,a as c,i as m}from"./vendor-i18n-Dm-c3D_C.js";import{u as p,s as y,E as T}from"./App-CiBjfJbZ.js";import{t as v,ad as S,ae as w,v as R,I as k,U as A,aa as I,o as b,w as M}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-DBtTSFLf.js";import"./main-CvPZyRz3.js";const C=5,D=5,$=5,E=o=>{if(!o)return"";try{const n=Date.now()-new Date(o).getTime();if(n<0)return"";const t=Math.floor(n/1e3);if(t<60)return m.t("chat.home.justNow");const l=Math.floor(t/60);if(l<60)return m.t("chat.home.minutesAgo",{count:l});const a=Math.floor(l/60);if(a<24)return m.t("chat.home.hoursAgo",{count:a});const r=Math.floor(a/24);return r<30?m.t("chat.home.daysAgo",{count:r}):new Date(o).toLocaleDateString()}catch{return""}},P=(o,n)=>n?"is-running":o.lastRunStatus==="error"?"is-error":o.pinned?"is-pinned":"is-idle",x=({chat:o,onOpen:n,textSecondary:t})=>{const{t:l}=g(),a=p(y(o.id)),r=o.config.workspacePath?o.config.workspacePath.split("/").pop()||o.config.workspacePath:null;return s.jsxs("button",{type:"button",className:"lotus-home-session-item",onClick:()=>n(o.id),children:[s.jsx("span",{className:`lotus-home-session-status ${P(o,a)}`}),s.jsxs("span",{className:"lotus-home-session-content",children:[s.jsx("span",{className:"lotus-home-session-title",children:o.title}),s.jsxs("span",{className:"lotus-home-session-meta",style:{color:t},children:[s.jsx("span",{children:E(o.updatedAt)}),r?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"lotus-home-session-meta-sep"}),s.jsxs("span",{children:[s.jsx(A,{style:{marginRight:3}}),r]})]}):null,o.messageCount!=null?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"lotus-home-session-meta-sep"}),s.jsxs("span",{children:[s.jsx(I,{style:{marginRight:3}}),o.messageCount]})]}):null]})]}),a?s.jsx(b,{color:"green",bordered:!1,style:{margin:0,fontSize:11},children:l("chat.home.running")}):null,s.jsx(M,{className:"lotus-home-session-arrow"})]})},U=({onOpenSession:o})=>{const{t:n}=g(),{token:t}=v.useToken(),l=p(e=>e.chats),a=c.useCallback(e=>y(e)(p.getState()),[]),r=c.useMemo(()=>l.filter(e=>a(e.id)).slice(0,D),[l,a]),d=c.useMemo(()=>l.filter(e=>e.pinned&&!a(e.id)).slice(0,$),[l,a]),j=c.useMemo(()=>{const e=new Set(r.map(i=>i.id)),f=new Set(d.map(i=>i.id));return l.filter(i=>i.kind!=="child"&&!e.has(i.id)&&!f.has(i.id)).sort((i,h)=>{const N=i.updatedAt?new Date(i.updatedAt).getTime():i.createdAt;return(h.updatedAt?new Date(h.updatedAt).getTime():h.createdAt)-N}).slice(0,C)},[l,r,d]),u=c.useCallback(e=>{o(e)},[o]);return s.jsx("div",{className:"lotus-home-dashboard",children:s.jsxs("div",{className:"lotus-home-dashboard-inner",children:[s.jsxs("div",{className:"lotus-home-header",children:[s.jsx("span",{className:"lotus-home-header-icon",style:{background:`${t.colorPrimary}15`,color:t.colorPrimary},children:s.jsx(S,{})}),s.jsxs("div",{className:"lotus-home-header-text",children:[s.jsx("h2",{style:{color:t.colorText},children:n("home.title","Welcome to Bodhi")}),s.jsx("p",{style:{color:t.colorTextSecondary},children:n("home.subtitle","Here's an overview of your workspace.")})]})]}),s.jsx("div",{className:"lotus-home-launcher-shell","data-tour-id":"task-templates",children:s.jsx(T,{embedded:!0,layoutMode:"staggered"})}),s.jsxs("div",{className:"lotus-home-secondary-sections",children:[r.length>0?s.jsxs("div",{className:"lotus-home-section",children:[s.jsxs("div",{className:"lotus-home-section-title",style:{color:t.colorTextSecondary},children:[s.jsx(w,{className:"lotus-home-section-icon",style:{color:t.colorSuccess}}),s.jsx("span",{children:n("home.sections.running","Running Now")})]}),s.jsx("div",{className:"lotus-home-session-list",children:r.map(e=>s.jsx(x,{chat:e,onOpen:u,textSecondary:t.colorTextTertiary},e.id))})]}):null,d.length>0?s.jsxs("div",{className:"lotus-home-section",children:[s.jsxs("div",{className:"lotus-home-section-title",style:{color:t.colorTextSecondary},children:[s.jsx(R,{className:"lotus-home-section-icon",style:{color:"var(--lotus-gold)"}}),s.jsx("span",{children:n("home.sections.pinned","Pinned")})]}),s.jsx("div",{className:"lotus-home-session-list",children:d.map(e=>s.jsx(x,{chat:e,onOpen:u,textSecondary:t.colorTextTertiary},e.id))})]}):null,j.length>0?s.jsxs("div",{className:"lotus-home-section",children:[s.jsxs("div",{className:"lotus-home-section-title",style:{color:t.colorTextSecondary},children:[s.jsx(k,{className:"lotus-home-section-icon"}),s.jsx("span",{children:n("home.sections.recent","Recent Sessions")})]}),s.jsx("div",{className:"lotus-home-session-list",children:j.map(e=>s.jsx(x,{chat:e,onOpen:u,textSecondary:t.colorTextTertiary},e.id))})]}):null,l.length===0?s.jsx("div",{className:"lotus-home-empty-hint",style:{color:t.colorTextTertiary},children:n("home.empty","No sessions yet. Create one to get started!")}):null]})]})})};export{U as HomeDashboard,U as default};
@@ -1 +1 @@
1
- var te=Object.defineProperty;var se=(i,t,s)=>t in i?te(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var D=(i,t,s)=>se(i,typeof t!="symbol"?t+"":t,s);import{j as e}from"./vendor-markdown-DrYaLZhb.js";import{u as C,a as o,i as U}from"./vendor-i18n-Dm-c3D_C.js";import{M as L,B as ae}from"./App-BAFyf064.js";import{X as O,t as J,l as V,a2 as N,j as S,N as T,aw as Z,ax as re,ay as ie,az as Y,G as ne,W as Q,Q as W,z as B,U as E,F as M,aA as K,aB as ce,p as oe,H as le,A as $,a3 as de,aC as he}from"./vendor-antd-CKNrd1kL.js";import"./main-C1pyfoEz.js";import"./vendor-mermaid-B_9yBBtL.js";const pe=({visible:i,onClose:t,onSelect:s})=>{const{t:n}=C(),{message:r}=O.useApp(),{token:a}=J.useToken(),{Text:c}=V,[u,j]=o.useState(!1),[l,m]=o.useState(""),[g,k]=o.useState(),[v,w]=o.useState([]),[I,f]=o.useState([]);o.useEffect(()=>{i&&y()},[i]);const y=async d=>{j(!0);try{const p=await L.browseFolder(d);m(p.current_path),k(p.parent_path),w(p.folders)}catch(p){console.error(n("chat.folderBrowser.readFolderError"),p),r.error(n("chat.folderBrowser.readFolderError"))}finally{j(!1)}},x=d=>{f([...I,l]),y(d.path)},z=()=>{g&&(f(I.slice(0,-1)),y(g))},R=()=>{f([]),y()},P=()=>{s(l),t()},b=()=>{if(!l)return[];const d=l.split(/[/\\]/).filter(Boolean);return l.startsWith("/")&&d.unshift("/"),d},_=d=>{const F=b().slice(0,d+1).join("/"),H=(l.startsWith("/"),F);y(H)};return e.jsx(N,{title:n("chat.folderBrowser.title"),open:i,onCancel:t,width:700,footer:null,children:e.jsxs(S,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsxs(S,{children:[e.jsx(T,{icon:e.jsx(Z,{}),onClick:R,size:"small",children:n("common.home")}),e.jsx(T,{icon:e.jsx(re,{}),onClick:z,disabled:!g,size:"small",children:n("common.parentDirectory")}),e.jsx(T,{type:"primary",icon:e.jsx(ie,{}),onClick:P,size:"small",children:n("chat.folderBrowser.selectCurrent")})]}),e.jsx(Y,{children:b().map((d,p)=>e.jsx(Y.Item,{children:e.jsx(T,{type:"link",size:"small",onClick:()=>_(p),style:{padding:0},children:d==="/"?e.jsx(Z,{}):d})},p))}),e.jsxs(ne,{size:"small",styles:{body:{padding:a.paddingXS}},children:[e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("common.currentPath")})," ",e.jsx(c,{code:!0,children:l})]}),e.jsx(Q,{spinning:u,children:v.length===0&&!u?e.jsx(W,{image:W.PRESENTED_IMAGE_SIMPLE,description:e.jsx(c,{type:"secondary",children:n("chat.folderBrowser.emptyFolder")})}):e.jsx(B,{dataSource:v,style:{maxHeight:400,overflowY:"auto"},renderItem:d=>e.jsx(B.Item,{style:{padding:0},children:e.jsx(T,{type:"text",icon:e.jsx(E,{}),onClick:()=>x(d),style:{width:"100%",textAlign:"left",padding:`${a.paddingXS}px ${a.paddingSM}px`},children:d.name})})})}),e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("chat.folderBrowser.tip")})]})})};class ue{constructor(t={}){D(this,"cache",new Map);D(this,"pendingValidations",new Map);D(this,"options");this.options={debounceMs:t.debounceMs??300,cacheTimeoutMs:t.cacheTimeoutMs??5*60*1e3,maxRetries:t.maxRetries??3}}async validateWorkspace(t){if(!t||t.trim().length===0)return{path:"",is_valid:!1,error_message:U.t("chat.workspace.errorEnterPath")};const s=t.trim(),n=this.getCachedResult(s);if(n)return n;const r=this.pendingValidations.get(s);if(r)return r;const a=this.performValidation(s);this.pendingValidations.set(s,a);try{const c=await a;return this.setCachedResult(s,c),c}finally{this.pendingValidations.delete(s)}}validateWorkspaceDebounced(t,s){let n;return n=setTimeout(async()=>{try{const a=await this.validateWorkspace(t);s(a)}catch(a){const c={path:t,is_valid:!1,error_message:a instanceof Error?a.message:U.t("chat.workspace.checkDescription")};s(c)}},this.options.debounceMs),()=>{clearTimeout(n)}}clearCache(){this.cache.clear()}getCachedResult(t){const s=this.cache.get(t);return s?Date.now()-s.timestamp>this.options.cacheTimeoutMs?(this.cache.delete(t),null):s.result:null}setCachedResult(t,s){this.cache.set(t,{result:s,timestamp:Date.now()})}async performValidation(t,s=0){try{return await ae.post("workspace/validate",{path:t})}catch(n){if(s<this.options.maxRetries&&this.isRetryableError(n))return await this.delay(Math.pow(2,s)*1e3),this.performValidation(t,s+1);throw n}}isRetryableError(t){return t instanceof Error?t.message.includes("Failed to fetch")||t.message.includes("HTTP error! status: 5"):!1}delay(t){return new Promise(s=>setTimeout(s,t))}async validateMultiplePaths(t){const n=[];for(let r=0;r<t.length;r+=5){const a=t.slice(r,r+5),c=await Promise.all(a.map(u=>this.validateWorkspace(u)));n.push(...c),r+5<t.length&&await this.delay(100)}return n}}const ge=new ue,me=({value:i="",onChange:t,showRecentWorkspaces:s,showSuggestions:n,onValidationChange:r})=>{const{message:a}=O.useApp(),{t:c}=C(),[u,j]=o.useState(i),[l,m]=o.useState({isValidating:!1,result:null}),[g,k]=o.useState([]),[v,w]=o.useState(!1),[I,f]=o.useState([]),[y,x]=o.useState(!1),[z,R]=o.useState(!1),P=o.useRef(null),b=o.useRef(null);o.useEffect(()=>{j(i)},[i]);const _=o.useCallback(async()=>{x(!0);try{const h=await L.getRecentWorkspaces();k(h.slice(0,5))}catch(h){console.error("Failed to load recent workspaces:",h),k([])}finally{x(!1)}},[]),d=o.useCallback(async()=>{R(!0);try{const h=await L.getPathSuggestions();f(h.suggestions.slice(0,8))}catch(h){console.error("Failed to load suggestions:",h),f([])}finally{R(!1)}},[]);o.useEffect(()=>{s&&_(),n&&d();const h=P.current,A=b.current;return()=>{h&&h.abort(),A&&A()}},[s,n,_,d]);const p=o.useCallback(h=>{j(h),t&&t(h),P.current&&P.current.abort(),b.current&&b.current(),h.trim()?(m({isValidating:!0,result:null}),b.current=ge.validateWorkspaceDebounced(h.trim(),A=>{m({isValidating:!1,result:A}),r&&r(A)})):(m({isValidating:!1,result:null}),r&&r(null))},[t,r]),F=o.useCallback(()=>{w(!0)},[]),H=o.useCallback(h=>{p(h),a.success(c("chat.workspace.folderSelected"))},[p,a,c]),ee=o.useCallback(h=>{p(h)},[p]);return{path:u,validationStatus:l,recentWorkspaces:g,suggestions:I,isLoadingRecent:y,isLoadingSuggestions:z,folderBrowserVisible:v,setFolderBrowserVisible:w,handlePathChange:p,handleBrowseClick:F,handleFolderSelect:H,handleWorkspaceSelect:ee}},{Text:X}=V,xe=({show:i,isLoading:t,recentWorkspaces:s,onSelect:n,token:r})=>{const{t:a}=C();return i?e.jsxs(M,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(S,{style:{paddingInline:r.paddingSM},children:[e.jsx(K,{}),e.jsx(X,{strong:!0,children:a("chat.workspace.recentTitle")})]}),t?e.jsx(M,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(Q,{size:"small"})}):s.length===0?e.jsx(W,{description:a("chat.workspace.noRecentWorkspaces"),image:W.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(B,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(B.Item,{style:{padding:0},children:e.jsx(T,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(M,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(S,{children:[e.jsx(E,{style:{color:r.colorWarning}}),e.jsx(X,{strong:!0,children:c.workspace_name||c.path.split("/").pop()||a("chat.workspace.defaultWorkspaceName")})]}),e.jsx(X,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},{Text:G}=V,fe=(i,t)=>{switch(i.suggestion_type){case"home":return e.jsx(Z,{style:{color:t.colorPrimary}});case"documents":case"desktop":case"downloads":return e.jsx(E,{style:{color:t.colorSuccess}});case"recent":return e.jsx(K,{style:{color:t.colorWarning}});default:return e.jsx(E,{})}},ye=({show:i,isLoading:t,suggestions:s,onSelect:n,token:r})=>{const{t:a}=C();return i?e.jsxs(M,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(S,{style:{paddingInline:r.paddingSM},children:[e.jsx(E,{}),e.jsx(G,{strong:!0,children:a("chat.workspace.suggestedTitle")})]}),t?e.jsx(M,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(Q,{size:"small"})}):s.length===0?e.jsx(W,{description:a("chat.workspace.noSuggestions"),image:W.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(B,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(B.Item,{style:{padding:0},children:e.jsx(T,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(M,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(S,{children:[fe(c,r),e.jsx(G,{strong:!0,children:c.name})]}),e.jsx(G,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},je=({isValidating:i,result:t,token:s})=>i?e.jsx(ce,{style:{color:s.colorPrimary}}):t?t.is_valid?e.jsx(oe,{style:{color:s.colorSuccess}}):e.jsx(le,{style:{color:s.colorError}}):null,{Text:q}=V,we=({result:i,token:t})=>{const{t:s}=C();return i?e.jsx("div",{style:{marginTop:t.marginXS},children:i.is_valid?e.jsx($,{type:"success",message:e.jsxs(S,{children:[e.jsx("span",{children:s("chat.workspace.validWorkspace")}),i.workspace_name&&e.jsxs(q,{type:"secondary",children:["(",i.workspace_name,")"]}),i.file_count!==void 0&&e.jsx(q,{type:"secondary",children:s("chat.workspace.fileCount",{count:i.file_count})})]}),showIcon:!0}):e.jsx($,{type:"error",message:i.error_message||s("validation.invalidPath"),showIcon:!0})}):null},{Text:Se}=V,ke=({value:i="",onChange:t,placeholder:s,disabled:n=!1,allowBrowse:r=!0,showRecentWorkspaces:a=!0,showSuggestions:c=!0,onValidationChange:u,className:j,style:l})=>{const{t:m}=C(),{token:g}=J.useToken(),k=s??m("chat.workspace.placeholder"),{path:v,validationStatus:w,recentWorkspaces:I,suggestions:f,isLoadingRecent:y,isLoadingSuggestions:x,folderBrowserVisible:z,setFolderBrowserVisible:R,handlePathChange:P,handleBrowseClick:b,handleFolderSelect:_,handleWorkspaceSelect:d}=me({value:i,onChange:t,showRecentWorkspaces:a,showSuggestions:c,onValidationChange:u});return e.jsxs("div",{className:j,style:l,children:[e.jsx(de,{value:v,onChange:p=>P(p.target.value),placeholder:k,disabled:n,size:"middle",style:{width:"100%"},suffix:e.jsx(je,{isValidating:w.isValidating,result:w.result,token:g}),addonBefore:e.jsxs(S,{children:[e.jsx(E,{}),e.jsx(Se,{children:m("chat.workspace.label")})]}),addonAfter:r?e.jsx(T,{"aria-label":m("chat.workspace.browseFolder"),title:m("chat.workspace.browseFolder"),icon:e.jsx(E,{}),onClick:b,disabled:n,type:"text",size:"middle",style:{display:"inline-flex",alignItems:"center"}}):void 0}),e.jsx(we,{result:w.result,token:g}),(a||c)&&e.jsxs(e.Fragment,{children:[e.jsx(he,{style:{margin:"16px 0 12px 0"}}),e.jsx(xe,{show:a,isLoading:y,recentWorkspaces:I,onSelect:d,token:g}),e.jsx(ye,{show:c,isLoading:x,suggestions:f,onSelect:d,token:g})]}),e.jsx(pe,{visible:z,onClose:()=>R(!1),onSelect:_})]})},{Title:be}=V,_e=({open:i,initialPath:t="",loading:s=!1,onSubmit:n,onCancel:r})=>{const{t:a}=C(),{message:c}=O.useApp(),[u,j]=o.useState(t),[l,m]=o.useState(null),[g,k]=o.useState(!1);o.useEffect(()=>{i&&(j(t),m(null))},[i,t]);const v=x=>{j(x)},w=x=>{m(x)},I=async()=>{if(!u.trim()){c.error(a("chat.workspace.errorEnterPath"));return}l&&!l.is_valid?N.confirm({title:a("chat.workspace.invalidTitle"),content:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.issuesDetected")}),e.jsx("p",{children:l.error_message||a("chat.workspace.invalidTitle")}),e.jsx("p",{children:a("chat.workspace.confirmSaveInvalid")})]}),okText:a("common.saveAnyway"),cancelText:a("common.cancel"),onOk:()=>f()}):f()},f=async()=>{k(!0);try{l!=null&&l.is_valid&&await L.addRecentWorkspace(u.trim(),{workspace_name:l.workspace_name}),n(u.trim())}catch(x){console.error("Failed to save workspace path:",x),c.error(a("chat.workspace.errorSaveFailed"))}finally{k(!1)}},y=!u.trim()||s||g;return e.jsx(N,{open:i,title:e.jsx(S,{children:e.jsx(be,{level:4,style:{margin:0},children:a("chat.workspace.modalTitle")})}),okText:a("common.save"),cancelText:a("common.cancel"),onOk:I,onCancel:r,okButtonProps:{disabled:y,loading:g||s},width:600,destroyOnClose:!0,children:e.jsxs(S,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsx($,{message:a("chat.workspace.descriptionTitle"),description:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.descriptionP1")}),e.jsx("p",{children:a("chat.workspace.descriptionP2")})]}),type:"info",showIcon:!0}),e.jsx(ke,{value:u,onChange:v,onValidationChange:w,placeholder:a("chat.workspace.placeholder"),disabled:g,allowBrowse:!0,showRecentWorkspaces:!0,showSuggestions:!0}),l&&!l.is_valid&&e.jsx($,{message:a("chat.workspace.checkTitle"),description:l.error_message||a("chat.workspace.checkDescription"),type:"warning",showIcon:!0})]})})};export{_e as default};
1
+ var te=Object.defineProperty;var se=(i,t,s)=>t in i?te(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var D=(i,t,s)=>se(i,typeof t!="symbol"?t+"":t,s);import{j as e}from"./vendor-markdown-DrYaLZhb.js";import{u as C,a as o,i as U}from"./vendor-i18n-Dm-c3D_C.js";import{N as L,D as ae}from"./App-CiBjfJbZ.js";import{X as O,t as J,l as V,a2 as N,j as S,N as T,aw as Z,ax as re,ay as ie,az as Y,G as ne,W as Q,Q as W,z as B,U as E,F as M,aA as K,aB as ce,p as oe,H as le,A as $,a3 as de,aC as he}from"./vendor-antd-CKNrd1kL.js";import"./main-CvPZyRz3.js";import"./vendor-mermaid-DBtTSFLf.js";const pe=({visible:i,onClose:t,onSelect:s})=>{const{t:n}=C(),{message:r}=O.useApp(),{token:a}=J.useToken(),{Text:c}=V,[u,j]=o.useState(!1),[l,m]=o.useState(""),[g,k]=o.useState(),[v,w]=o.useState([]),[I,f]=o.useState([]);o.useEffect(()=>{i&&y()},[i]);const y=async d=>{j(!0);try{const p=await L.browseFolder(d);m(p.current_path),k(p.parent_path),w(p.folders)}catch(p){console.error(n("chat.folderBrowser.readFolderError"),p),r.error(n("chat.folderBrowser.readFolderError"))}finally{j(!1)}},x=d=>{f([...I,l]),y(d.path)},z=()=>{g&&(f(I.slice(0,-1)),y(g))},R=()=>{f([]),y()},P=()=>{s(l),t()},b=()=>{if(!l)return[];const d=l.split(/[/\\]/).filter(Boolean);return l.startsWith("/")&&d.unshift("/"),d},_=d=>{const F=b().slice(0,d+1).join("/"),H=(l.startsWith("/"),F);y(H)};return e.jsx(N,{title:n("chat.folderBrowser.title"),open:i,onCancel:t,width:700,footer:null,children:e.jsxs(S,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsxs(S,{children:[e.jsx(T,{icon:e.jsx(Z,{}),onClick:R,size:"small",children:n("common.home")}),e.jsx(T,{icon:e.jsx(re,{}),onClick:z,disabled:!g,size:"small",children:n("common.parentDirectory")}),e.jsx(T,{type:"primary",icon:e.jsx(ie,{}),onClick:P,size:"small",children:n("chat.folderBrowser.selectCurrent")})]}),e.jsx(Y,{children:b().map((d,p)=>e.jsx(Y.Item,{children:e.jsx(T,{type:"link",size:"small",onClick:()=>_(p),style:{padding:0},children:d==="/"?e.jsx(Z,{}):d})},p))}),e.jsxs(ne,{size:"small",styles:{body:{padding:a.paddingXS}},children:[e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("common.currentPath")})," ",e.jsx(c,{code:!0,children:l})]}),e.jsx(Q,{spinning:u,children:v.length===0&&!u?e.jsx(W,{image:W.PRESENTED_IMAGE_SIMPLE,description:e.jsx(c,{type:"secondary",children:n("chat.folderBrowser.emptyFolder")})}):e.jsx(B,{dataSource:v,style:{maxHeight:400,overflowY:"auto"},renderItem:d=>e.jsx(B.Item,{style:{padding:0},children:e.jsx(T,{type:"text",icon:e.jsx(E,{}),onClick:()=>x(d),style:{width:"100%",textAlign:"left",padding:`${a.paddingXS}px ${a.paddingSM}px`},children:d.name})})})}),e.jsx(c,{type:"secondary",style:{fontSize:12},children:n("chat.folderBrowser.tip")})]})})};class ue{constructor(t={}){D(this,"cache",new Map);D(this,"pendingValidations",new Map);D(this,"options");this.options={debounceMs:t.debounceMs??300,cacheTimeoutMs:t.cacheTimeoutMs??5*60*1e3,maxRetries:t.maxRetries??3}}async validateWorkspace(t){if(!t||t.trim().length===0)return{path:"",is_valid:!1,error_message:U.t("chat.workspace.errorEnterPath")};const s=t.trim(),n=this.getCachedResult(s);if(n)return n;const r=this.pendingValidations.get(s);if(r)return r;const a=this.performValidation(s);this.pendingValidations.set(s,a);try{const c=await a;return this.setCachedResult(s,c),c}finally{this.pendingValidations.delete(s)}}validateWorkspaceDebounced(t,s){let n;return n=setTimeout(async()=>{try{const a=await this.validateWorkspace(t);s(a)}catch(a){const c={path:t,is_valid:!1,error_message:a instanceof Error?a.message:U.t("chat.workspace.checkDescription")};s(c)}},this.options.debounceMs),()=>{clearTimeout(n)}}clearCache(){this.cache.clear()}getCachedResult(t){const s=this.cache.get(t);return s?Date.now()-s.timestamp>this.options.cacheTimeoutMs?(this.cache.delete(t),null):s.result:null}setCachedResult(t,s){this.cache.set(t,{result:s,timestamp:Date.now()})}async performValidation(t,s=0){try{return await ae.post("workspace/validate",{path:t})}catch(n){if(s<this.options.maxRetries&&this.isRetryableError(n))return await this.delay(Math.pow(2,s)*1e3),this.performValidation(t,s+1);throw n}}isRetryableError(t){return t instanceof Error?t.message.includes("Failed to fetch")||t.message.includes("HTTP error! status: 5"):!1}delay(t){return new Promise(s=>setTimeout(s,t))}async validateMultiplePaths(t){const n=[];for(let r=0;r<t.length;r+=5){const a=t.slice(r,r+5),c=await Promise.all(a.map(u=>this.validateWorkspace(u)));n.push(...c),r+5<t.length&&await this.delay(100)}return n}}const ge=new ue,me=({value:i="",onChange:t,showRecentWorkspaces:s,showSuggestions:n,onValidationChange:r})=>{const{message:a}=O.useApp(),{t:c}=C(),[u,j]=o.useState(i),[l,m]=o.useState({isValidating:!1,result:null}),[g,k]=o.useState([]),[v,w]=o.useState(!1),[I,f]=o.useState([]),[y,x]=o.useState(!1),[z,R]=o.useState(!1),P=o.useRef(null),b=o.useRef(null);o.useEffect(()=>{j(i)},[i]);const _=o.useCallback(async()=>{x(!0);try{const h=await L.getRecentWorkspaces();k(h.slice(0,5))}catch(h){console.error("Failed to load recent workspaces:",h),k([])}finally{x(!1)}},[]),d=o.useCallback(async()=>{R(!0);try{const h=await L.getPathSuggestions();f(h.suggestions.slice(0,8))}catch(h){console.error("Failed to load suggestions:",h),f([])}finally{R(!1)}},[]);o.useEffect(()=>{s&&_(),n&&d();const h=P.current,A=b.current;return()=>{h&&h.abort(),A&&A()}},[s,n,_,d]);const p=o.useCallback(h=>{j(h),t&&t(h),P.current&&P.current.abort(),b.current&&b.current(),h.trim()?(m({isValidating:!0,result:null}),b.current=ge.validateWorkspaceDebounced(h.trim(),A=>{m({isValidating:!1,result:A}),r&&r(A)})):(m({isValidating:!1,result:null}),r&&r(null))},[t,r]),F=o.useCallback(()=>{w(!0)},[]),H=o.useCallback(h=>{p(h),a.success(c("chat.workspace.folderSelected"))},[p,a,c]),ee=o.useCallback(h=>{p(h)},[p]);return{path:u,validationStatus:l,recentWorkspaces:g,suggestions:I,isLoadingRecent:y,isLoadingSuggestions:z,folderBrowserVisible:v,setFolderBrowserVisible:w,handlePathChange:p,handleBrowseClick:F,handleFolderSelect:H,handleWorkspaceSelect:ee}},{Text:X}=V,xe=({show:i,isLoading:t,recentWorkspaces:s,onSelect:n,token:r})=>{const{t:a}=C();return i?e.jsxs(M,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(S,{style:{paddingInline:r.paddingSM},children:[e.jsx(K,{}),e.jsx(X,{strong:!0,children:a("chat.workspace.recentTitle")})]}),t?e.jsx(M,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(Q,{size:"small"})}):s.length===0?e.jsx(W,{description:a("chat.workspace.noRecentWorkspaces"),image:W.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(B,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(B.Item,{style:{padding:0},children:e.jsx(T,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(M,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(S,{children:[e.jsx(E,{style:{color:r.colorWarning}}),e.jsx(X,{strong:!0,children:c.workspace_name||c.path.split("/").pop()||a("chat.workspace.defaultWorkspaceName")})]}),e.jsx(X,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},{Text:G}=V,fe=(i,t)=>{switch(i.suggestion_type){case"home":return e.jsx(Z,{style:{color:t.colorPrimary}});case"documents":case"desktop":case"downloads":return e.jsx(E,{style:{color:t.colorSuccess}});case"recent":return e.jsx(K,{style:{color:t.colorWarning}});default:return e.jsx(E,{})}},ye=({show:i,isLoading:t,suggestions:s,onSelect:n,token:r})=>{const{t:a}=C();return i?e.jsxs(M,{vertical:!0,gap:r.marginXS,style:{marginTop:r.marginMD},children:[e.jsxs(S,{style:{paddingInline:r.paddingSM},children:[e.jsx(E,{}),e.jsx(G,{strong:!0,children:a("chat.workspace.suggestedTitle")})]}),t?e.jsx(M,{justify:"center",style:{padding:r.paddingSM},children:e.jsx(Q,{size:"small"})}):s.length===0?e.jsx(W,{description:a("chat.workspace.noSuggestions"),image:W.PRESENTED_IMAGE_SIMPLE,style:{padding:r.paddingSM}}):e.jsx(B,{size:"small",dataSource:s,style:{paddingInline:r.paddingSM},renderItem:c=>e.jsx(B.Item,{style:{padding:0},children:e.jsx(T,{type:"text",onClick:()=>n(c.path),style:{width:"100%",textAlign:"left",padding:`${r.paddingXS}px 0`,height:"auto"},children:e.jsxs(M,{justify:"space-between",align:"center",style:{width:"100%"},children:[e.jsxs(S,{children:[fe(c,r),e.jsx(G,{strong:!0,children:c.name})]}),e.jsx(G,{type:"secondary",ellipsis:{tooltip:c.path},style:{fontSize:12,maxWidth:"55%",textAlign:"right"},children:c.path})]})})})})]}):null},je=({isValidating:i,result:t,token:s})=>i?e.jsx(ce,{style:{color:s.colorPrimary}}):t?t.is_valid?e.jsx(oe,{style:{color:s.colorSuccess}}):e.jsx(le,{style:{color:s.colorError}}):null,{Text:q}=V,we=({result:i,token:t})=>{const{t:s}=C();return i?e.jsx("div",{style:{marginTop:t.marginXS},children:i.is_valid?e.jsx($,{type:"success",message:e.jsxs(S,{children:[e.jsx("span",{children:s("chat.workspace.validWorkspace")}),i.workspace_name&&e.jsxs(q,{type:"secondary",children:["(",i.workspace_name,")"]}),i.file_count!==void 0&&e.jsx(q,{type:"secondary",children:s("chat.workspace.fileCount",{count:i.file_count})})]}),showIcon:!0}):e.jsx($,{type:"error",message:i.error_message||s("validation.invalidPath"),showIcon:!0})}):null},{Text:Se}=V,ke=({value:i="",onChange:t,placeholder:s,disabled:n=!1,allowBrowse:r=!0,showRecentWorkspaces:a=!0,showSuggestions:c=!0,onValidationChange:u,className:j,style:l})=>{const{t:m}=C(),{token:g}=J.useToken(),k=s??m("chat.workspace.placeholder"),{path:v,validationStatus:w,recentWorkspaces:I,suggestions:f,isLoadingRecent:y,isLoadingSuggestions:x,folderBrowserVisible:z,setFolderBrowserVisible:R,handlePathChange:P,handleBrowseClick:b,handleFolderSelect:_,handleWorkspaceSelect:d}=me({value:i,onChange:t,showRecentWorkspaces:a,showSuggestions:c,onValidationChange:u});return e.jsxs("div",{className:j,style:l,children:[e.jsx(de,{value:v,onChange:p=>P(p.target.value),placeholder:k,disabled:n,size:"middle",style:{width:"100%"},suffix:e.jsx(je,{isValidating:w.isValidating,result:w.result,token:g}),addonBefore:e.jsxs(S,{children:[e.jsx(E,{}),e.jsx(Se,{children:m("chat.workspace.label")})]}),addonAfter:r?e.jsx(T,{"aria-label":m("chat.workspace.browseFolder"),title:m("chat.workspace.browseFolder"),icon:e.jsx(E,{}),onClick:b,disabled:n,type:"text",size:"middle",style:{display:"inline-flex",alignItems:"center"}}):void 0}),e.jsx(we,{result:w.result,token:g}),(a||c)&&e.jsxs(e.Fragment,{children:[e.jsx(he,{style:{margin:"16px 0 12px 0"}}),e.jsx(xe,{show:a,isLoading:y,recentWorkspaces:I,onSelect:d,token:g}),e.jsx(ye,{show:c,isLoading:x,suggestions:f,onSelect:d,token:g})]}),e.jsx(pe,{visible:z,onClose:()=>R(!1),onSelect:_})]})},{Title:be}=V,_e=({open:i,initialPath:t="",loading:s=!1,onSubmit:n,onCancel:r})=>{const{t:a}=C(),{message:c}=O.useApp(),[u,j]=o.useState(t),[l,m]=o.useState(null),[g,k]=o.useState(!1);o.useEffect(()=>{i&&(j(t),m(null))},[i,t]);const v=x=>{j(x)},w=x=>{m(x)},I=async()=>{if(!u.trim()){c.error(a("chat.workspace.errorEnterPath"));return}l&&!l.is_valid?N.confirm({title:a("chat.workspace.invalidTitle"),content:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.issuesDetected")}),e.jsx("p",{children:l.error_message||a("chat.workspace.invalidTitle")}),e.jsx("p",{children:a("chat.workspace.confirmSaveInvalid")})]}),okText:a("common.saveAnyway"),cancelText:a("common.cancel"),onOk:()=>f()}):f()},f=async()=>{k(!0);try{l!=null&&l.is_valid&&await L.addRecentWorkspace(u.trim(),{workspace_name:l.workspace_name}),n(u.trim())}catch(x){console.error("Failed to save workspace path:",x),c.error(a("chat.workspace.errorSaveFailed"))}finally{k(!1)}},y=!u.trim()||s||g;return e.jsx(N,{open:i,title:e.jsx(S,{children:e.jsx(be,{level:4,style:{margin:0},children:a("chat.workspace.modalTitle")})}),okText:a("common.save"),cancelText:a("common.cancel"),onOk:I,onCancel:r,okButtonProps:{disabled:y,loading:g||s},width:600,destroyOnClose:!0,children:e.jsxs(S,{direction:"vertical",size:"middle",style:{width:"100%"},children:[e.jsx($,{message:a("chat.workspace.descriptionTitle"),description:e.jsxs("div",{children:[e.jsx("p",{children:a("chat.workspace.descriptionP1")}),e.jsx("p",{children:a("chat.workspace.descriptionP2")})]}),type:"info",showIcon:!0}),e.jsx(ke,{value:u,onChange:v,onValidationChange:w,placeholder:a("chat.workspace.placeholder"),disabled:g,allowBrowse:!0,showRecentWorkspaces:!0,showSuggestions:!0}),l&&!l.is_valid&&e.jsx($,{message:a("chat.workspace.checkTitle"),description:l.error_message||a("chat.workspace.checkDescription"),type:"warning",showIcon:!0})]})})};export{_e as default};
@@ -1 +1 @@
1
- import{j as s}from"./vendor-markdown-DrYaLZhb.js";import{u as M,a as S}from"./vendor-i18n-Dm-c3D_C.js";import{u as I,n as b,p as w,q as T,I as A}from"./App-BAFyf064.js";import{m as B}from"./MetricsService-BmWgjSY6.js";import{t as W,ah as D,aa as $,ai as R,J as _,q as v,aj as k,x as F,ak as L,I as q,o as z}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-B_9yBBtL.js";import"./main-C1pyfoEz.js";const N=new Map,O=new Set(["Write","Edit","apply_patch","NotebookEdit"]),P=l=>{const n=l.match(/(?:file_path|Wrote file|Edited file)[:\s]*["']?([^\s"',]+)/i);if(n){const o=n[1];return o.split("/").pop()||o}return null},H=(l,n)=>{const o=n-l;if(o<0)return"";const e=Math.floor(o/1e3);if(e<60)return`${e}s`;const i=Math.floor(e/60);return i<60?`${i}m ${e%60}s`:`${Math.floor(i/60)}h ${i%60}m`},J=l=>{var p,j;let n=0,o=0,e=0,i=0,y=!1,x=0,d="";const h=new Set;let u=0,t=0;for(const a of l){const c=a.createdAt?new Date(a.createdAt).getTime():0;if(c>0&&(u===0||c<u)&&(u=c),c>t&&(t=c),a.isCompressed){y=!0,x++;continue}if(a.role==="user"&&!("type"in a&&a.type==="file_reference")&&n++,a.role==="assistant"){if("type"in a&&a.type==="tool_call"&&(e+=((p=a.toolCalls)==null?void 0:p.length)??0),"type"in a&&a.type==="tool_result"){const m=a;if(m.isError&&i++,O.has(m.toolName)){const f=P(((j=m.result)==null?void 0:j.result)??"");f&&h.add(f)}}if("type"in a&&a.type==="text"){o++;const m=a.content||"";m.length>0&&m.length>30&&(d=m.slice(0,300))}}}return{messageCount:l.length,userMessageCount:n,assistantMessageCount:o,toolCallCount:e,toolErrorCount:i,fileChanges:Array.from(h).slice(0,10),lastAssistantExcerpt:d,hasCompression:y,compressionCount:x,duration:u>0&&t>u?H(u,t):""}},Z=({sessionId:l,compact:n=!1})=>{const{t:o}=M(),{token:e}=W.useToken(),[i,y]=S.useState(!1),[x,d]=S.useState(()=>N.get(l)),h=I(b(l)),u=h==null?void 0:h.messages,t=S.useMemo(()=>!u||u.length===0?null:J(u),[u]);if(S.useEffect(()=>{let r=!1;const g=N.get(l);return g!==void 0?(d(g),()=>{r=!0}):(d(void 0),B.getSessionDetail(l).then(C=>{if(r)return;const E=(C==null?void 0:C.session)??null;N.set(l,E),d(E)},()=>{r||(N.set(l,null),d(null))}),()=>{r=!0})},[l]),!t||t.messageCount<3)return null;const p=t.fileChanges.length>0,j=t.lastAssistantExcerpt.length>0,a=n&&p?t.fileChanges:[],c=x==null?void 0:x.total_token_usage,m=c?w(c.total_tokens):null,f=c?s.jsxs("div",{style:{minWidth:180},children:[s.jsx("div",{style:{fontWeight:600,marginBottom:4},children:o("sessionSummary.totalTokens","Total tokens")}),s.jsxs("div",{children:[o("sessionSummary.promptTokens","Prompt"),":"," ",T(c.prompt_tokens)]}),s.jsxs("div",{children:[o("sessionSummary.completionTokens","Completion"),":"," ",T(c.completion_tokens)]}),s.jsxs("div",{children:[o("sessionSummary.totalTokens","Total tokens"),":"," ",T(c.total_tokens)]})]}):null;return s.jsxs("div",{className:`lotus-session-summary ${n?"lotus-session-summary--compact":""}`,style:{borderColor:e.colorBorderSecondary,background:`${e.colorBgElevated}`},children:[s.jsxs("div",{className:"lotus-session-summary-header",onClick:()=>y(r=>!r),role:"button",tabIndex:0,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),y(g=>!g))},"aria-expanded":i,children:[s.jsx("span",{className:"lotus-session-summary-header-icon",style:{color:e.colorPrimary},children:s.jsx(D,{})}),s.jsx("span",{className:"lotus-session-summary-header-title",style:{color:e.colorText},children:o("sessionSummary.title","Session Summary")}),!i&&s.jsxs("span",{className:"lotus-session-summary-stats",children:[s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx($,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.messageCount})]}),t.toolCallCount>0&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(R,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.toolCallCount})]}),p&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(_,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.fileChanges.length})]}),m&&s.jsx(v,{title:f,children:s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(k,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:m})]})})]}),s.jsx("span",{className:`lotus-session-summary-toggle ${i?"is-expanded":""}`,style:{color:e.colorTextTertiary},children:s.jsx(F,{})})]}),i&&s.jsxs("div",{className:"lotus-session-summary-body",children:[s.jsxs("div",{className:"lotus-session-summary-stats",children:[s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx($,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.messageCount})," ",o("sessionSummary.messages","messages")]})]}),s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx("span",{className:"lotus-session-summary-stat-icon",children:"👤"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.userMessageCount})," ",o("sessionSummary.userTurns","user")]})]}),s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx("span",{className:"lotus-session-summary-stat-icon",children:"🤖"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.assistantMessageCount})," ",o("sessionSummary.assistantTurns","assistant")]})]}),t.toolCallCount>0&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(R,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.toolCallCount})," ",o("sessionSummary.toolCalls","tool calls")]})]}),t.toolErrorCount>0&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:"#ff4d4f"},children:[s.jsx(L,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.toolErrorCount})," ",o("sessionSummary.errors","errors")]})]}),t.duration&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(q,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{children:t.duration})]}),t.hasCompression&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(k,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.compressionCount})," ",o("sessionSummary.compressions","compressions")]})]}),m&&s.jsx(v,{title:f,children:s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(k,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:m})," ",o("sessionSummary.totalTokens","total tokens")]})]})})]}),p&&s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:n?10:11,fontWeight:600,color:e.colorTextSecondary,marginBottom:n?2:4,textTransform:"uppercase",letterSpacing:.3},children:o("sessionSummary.filesChanged","Files Changed")}),n?s.jsx(A,{items:a,style:{lineHeight:1.4,wordBreak:"break-word",whiteSpace:"normal"}}):s.jsx("div",{className:"lotus-session-summary-files",children:t.fileChanges.map(r=>s.jsx(v,{title:r,children:s.jsxs(z,{bordered:!1,className:"lotus-session-summary-file-tag",children:[s.jsx(_,{style:{marginRight:4}}),r]})},r))})]}),j&&s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:n?10:11,fontWeight:600,color:e.colorTextSecondary,marginBottom:n?2:4,textTransform:"uppercase",letterSpacing:.3},children:o("sessionSummary.lastResponse","Latest Response")}),s.jsx("div",{className:"lotus-session-summary-conclusion",style:{color:e.colorTextSecondary},children:t.lastAssistantExcerpt})]})]})]})};export{Z as SessionSummaryCard,Z as default};
1
+ import{j as s}from"./vendor-markdown-DrYaLZhb.js";import{u as M,a as S}from"./vendor-i18n-Dm-c3D_C.js";import{u as I,p as b,q as w,t as T,I as A}from"./App-CiBjfJbZ.js";import{m as B}from"./MetricsService-B6NNBaFU.js";import{t as W,ah as D,aa as $,ai as R,J as _,q as v,aj as k,x as F,ak as L,I as q,o as z}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-DBtTSFLf.js";import"./main-CvPZyRz3.js";const N=new Map,O=new Set(["Write","Edit","apply_patch","NotebookEdit"]),P=l=>{const n=l.match(/(?:file_path|Wrote file|Edited file)[:\s]*["']?([^\s"',]+)/i);if(n){const o=n[1];return o.split("/").pop()||o}return null},H=(l,n)=>{const o=n-l;if(o<0)return"";const e=Math.floor(o/1e3);if(e<60)return`${e}s`;const i=Math.floor(e/60);return i<60?`${i}m ${e%60}s`:`${Math.floor(i/60)}h ${i%60}m`},J=l=>{var p,j;let n=0,o=0,e=0,i=0,y=!1,x=0,d="";const h=new Set;let u=0,t=0;for(const a of l){const c=a.createdAt?new Date(a.createdAt).getTime():0;if(c>0&&(u===0||c<u)&&(u=c),c>t&&(t=c),a.isCompressed){y=!0,x++;continue}if(a.role==="user"&&!("type"in a&&a.type==="file_reference")&&n++,a.role==="assistant"){if("type"in a&&a.type==="tool_call"&&(e+=((p=a.toolCalls)==null?void 0:p.length)??0),"type"in a&&a.type==="tool_result"){const m=a;if(m.isError&&i++,O.has(m.toolName)){const f=P(((j=m.result)==null?void 0:j.result)??"");f&&h.add(f)}}if("type"in a&&a.type==="text"){o++;const m=a.content||"";m.length>0&&m.length>30&&(d=m.slice(0,300))}}}return{messageCount:l.length,userMessageCount:n,assistantMessageCount:o,toolCallCount:e,toolErrorCount:i,fileChanges:Array.from(h).slice(0,10),lastAssistantExcerpt:d,hasCompression:y,compressionCount:x,duration:u>0&&t>u?H(u,t):""}},Z=({sessionId:l,compact:n=!1})=>{const{t:o}=M(),{token:e}=W.useToken(),[i,y]=S.useState(!1),[x,d]=S.useState(()=>N.get(l)),h=I(b(l)),u=h==null?void 0:h.messages,t=S.useMemo(()=>!u||u.length===0?null:J(u),[u]);if(S.useEffect(()=>{let r=!1;const g=N.get(l);return g!==void 0?(d(g),()=>{r=!0}):(d(void 0),B.getSessionDetail(l).then(C=>{if(r)return;const E=(C==null?void 0:C.session)??null;N.set(l,E),d(E)},()=>{r||(N.set(l,null),d(null))}),()=>{r=!0})},[l]),!t||t.messageCount<3)return null;const p=t.fileChanges.length>0,j=t.lastAssistantExcerpt.length>0,a=n&&p?t.fileChanges:[],c=x==null?void 0:x.total_token_usage,m=c?w(c.total_tokens):null,f=c?s.jsxs("div",{style:{minWidth:180},children:[s.jsx("div",{style:{fontWeight:600,marginBottom:4},children:o("sessionSummary.totalTokens","Total tokens")}),s.jsxs("div",{children:[o("sessionSummary.promptTokens","Prompt"),":"," ",T(c.prompt_tokens)]}),s.jsxs("div",{children:[o("sessionSummary.completionTokens","Completion"),":"," ",T(c.completion_tokens)]}),s.jsxs("div",{children:[o("sessionSummary.totalTokens","Total tokens"),":"," ",T(c.total_tokens)]})]}):null;return s.jsxs("div",{className:`lotus-session-summary ${n?"lotus-session-summary--compact":""}`,style:{borderColor:e.colorBorderSecondary,background:`${e.colorBgElevated}`},children:[s.jsxs("div",{className:"lotus-session-summary-header",onClick:()=>y(r=>!r),role:"button",tabIndex:0,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),y(g=>!g))},"aria-expanded":i,children:[s.jsx("span",{className:"lotus-session-summary-header-icon",style:{color:e.colorPrimary},children:s.jsx(D,{})}),s.jsx("span",{className:"lotus-session-summary-header-title",style:{color:e.colorText},children:o("sessionSummary.title","Session Summary")}),!i&&s.jsxs("span",{className:"lotus-session-summary-stats",children:[s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx($,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.messageCount})]}),t.toolCallCount>0&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(R,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.toolCallCount})]}),p&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(_,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.fileChanges.length})]}),m&&s.jsx(v,{title:f,children:s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(k,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{className:"lotus-session-summary-stat-value",children:m})]})})]}),s.jsx("span",{className:`lotus-session-summary-toggle ${i?"is-expanded":""}`,style:{color:e.colorTextTertiary},children:s.jsx(F,{})})]}),i&&s.jsxs("div",{className:"lotus-session-summary-body",children:[s.jsxs("div",{className:"lotus-session-summary-stats",children:[s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx($,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.messageCount})," ",o("sessionSummary.messages","messages")]})]}),s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx("span",{className:"lotus-session-summary-stat-icon",children:"👤"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.userMessageCount})," ",o("sessionSummary.userTurns","user")]})]}),s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx("span",{className:"lotus-session-summary-stat-icon",children:"🤖"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.assistantMessageCount})," ",o("sessionSummary.assistantTurns","assistant")]})]}),t.toolCallCount>0&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(R,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.toolCallCount})," ",o("sessionSummary.toolCalls","tool calls")]})]}),t.toolErrorCount>0&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:"#ff4d4f"},children:[s.jsx(L,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.toolErrorCount})," ",o("sessionSummary.errors","errors")]})]}),t.duration&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(q,{className:"lotus-session-summary-stat-icon"}),s.jsx("span",{children:t.duration})]}),t.hasCompression&&s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(k,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:t.compressionCount})," ",o("sessionSummary.compressions","compressions")]})]}),m&&s.jsx(v,{title:f,children:s.jsxs("span",{className:"lotus-session-summary-stat",style:{color:e.colorTextSecondary},children:[s.jsx(k,{className:"lotus-session-summary-stat-icon"}),s.jsxs("span",{children:[s.jsx("span",{className:"lotus-session-summary-stat-value",children:m})," ",o("sessionSummary.totalTokens","total tokens")]})]})})]}),p&&s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:n?10:11,fontWeight:600,color:e.colorTextSecondary,marginBottom:n?2:4,textTransform:"uppercase",letterSpacing:.3},children:o("sessionSummary.filesChanged","Files Changed")}),n?s.jsx(A,{items:a,style:{lineHeight:1.4,wordBreak:"break-word",whiteSpace:"normal"}}):s.jsx("div",{className:"lotus-session-summary-files",children:t.fileChanges.map(r=>s.jsx(v,{title:r,children:s.jsxs(z,{bordered:!1,className:"lotus-session-summary-file-tag",children:[s.jsx(_,{style:{marginRight:4}}),r]})},r))})]}),j&&s.jsxs("div",{children:[s.jsx("div",{style:{fontSize:n?10:11,fontWeight:600,color:e.colorTextSecondary,marginBottom:n?2:4,textTransform:"uppercase",letterSpacing:.3},children:o("sessionSummary.lastResponse","Latest Response")}),s.jsx("div",{className:"lotus-session-summary-conclusion",style:{color:e.colorTextSecondary},children:t.lastAssistantExcerpt})]})]})]})};export{Z as SessionSummaryCard,Z as default};
@@ -1 +1 @@
1
- import{j as t,M as E,r as F,h as H}from"./vendor-markdown-DrYaLZhb.js";import{i as I,u as G,a as p}from"./vendor-i18n-Dm-c3D_C.js";import{j as y,N as v,G as X,l as T,z as A,ag as Y,o as f,ap as q,aq as N,ar as O,as as Q,a2 as J,Q as K,D as U,t as V}from"./vendor-antd-CKNrd1kL.js";import{y as W,u as B,z as Z}from"./App-BAFyf064.js";import"./vendor-mermaid-B_9yBBtL.js";import"./main-C1pyfoEz.js";const _=({buttons:r,className:e,style:g,size:l="middle",align:n="right"})=>{const h={className:e,style:{width:"100%",justifyContent:n==="left"?"flex-start":n==="center"?"center":"flex-end",...g}};return t.jsx(y,{...h,children:r.map(a=>t.jsx(v,{type:a.type||"default",disabled:a.disabled,loading:a.loading,danger:a.danger,onClick:a.onClick,size:l,icon:a.icon,children:a.text},a.key))})},k=(r,e)=>({key:"cancel",text:e||I.t("common.cancel"),type:"default",onClick:r}),ee=(r,e)=>({key:"ok",text:(e==null?void 0:e.text)||I.t("common.ok"),type:"primary",disabled:e==null?void 0:e.disabled,loading:e==null?void 0:e.loading,onClick:r}),{Text:b,Paragraph:te}=T,re=({content:r,token:e,showGradient:g,onClick:l})=>t.jsx(X,{size:"small",style:{marginLeft:e.marginLG,marginTop:e.marginXS,backgroundColor:e.colorBgLayout,borderColor:e.colorBorderSecondary},styles:{body:{padding:e.paddingMD}},onClick:l,children:t.jsxs("div",{style:{maxHeight:"60vh",overflowY:"auto",position:"relative",paddingRight:e.paddingXS},children:[t.jsx(E,{remarkPlugins:[F],components:{p:({children:n})=>t.jsx(te,{style:{marginBottom:e.marginSM},children:n}),ol:({children:n})=>t.jsx("ol",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:n}),ul:({children:n})=>t.jsx("ul",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:n}),li:({children:n})=>t.jsx("li",{style:{marginBottom:e.marginXS},children:n}),h1:({children:n})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading3,marginBottom:e.marginSM,display:"block"},children:n}),h2:({children:n})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading4,marginBottom:e.marginSM,display:"block"},children:n}),code:({inline:n,className:h,children:a,...i})=>{const o=/language-(\w+)/.exec(h||"");return n?t.jsx("code",{className:h,style:{backgroundColor:e.colorFillTertiary,padding:"0 4px",borderRadius:e.borderRadiusSM,fontSize:e.fontSizeSM},...i,children:a}):t.jsx(H,{style:W,language:(o==null?void 0:o[1])||"text",PreTag:"div",wrapLongLines:!0,children:String(a).replace(/\n$/,"")})}},children:r||"No content available."}),g?t.jsx("div",{style:{position:"sticky",bottom:0,height:48,background:`linear-gradient(180deg, transparent, ${e.colorBgLayout})`,pointerEvents:"none",marginTop:-48}}):null]})}),{Text:L,Paragraph:se}=T,ne=({prompt:r,token:e,isSelected:g,isExpanded:l,onSelect:n,onToggleExpand:h,onCopy:a})=>{const{t:i}=G(),o=r.content||"",{nonEmptyLineCount:j,wordCount:u,characterCount:P,showGradient:x}=p.useMemo(()=>{const S=(o?o.split(/\r?\n/):[]).filter(w=>w.trim().length>0).length,C=o.trim()?o.trim().split(/\s+/).filter(Boolean).length:0,m=o.length;return{nonEmptyLineCount:S,wordCount:C,characterCount:m,showGradient:!l&&m>600}},[o,l]);return t.jsx(A.Item,{style:{cursor:"pointer",padding:e.paddingMD,borderRadius:e.borderRadius,border:g?`2px solid ${e.colorPrimary}`:`1px solid ${e.colorBorderSecondary}`,marginBottom:e.marginXS,backgroundColor:g?e.colorPrimaryBg:e.colorBgContainer,transition:"all 0.2s ease"},onClick:()=>n(r.id),children:t.jsxs(y,{direction:"vertical",style:{width:"100%"},size:e.marginSM,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",width:"100%",gap:e.marginSM},children:[t.jsxs(y,{align:"start",children:[t.jsx(Y,{checked:g,onChange:()=>n(r.id),onClick:c=>c.stopPropagation()}),t.jsxs("div",{children:[t.jsx(L,{strong:!0,children:r.name||r.id}),t.jsx("div",{children:t.jsx(L,{code:!0,style:{fontSize:e.fontSizeSM,color:e.colorTextSecondary},children:r.id})})]}),r.isDefault?t.jsx(f,{color:"warning",children:i("chat.systemPromptSelector.defaultTag")}):null]}),t.jsxs(y,{size:"small",children:[t.jsx(v,{type:"text",size:"small",icon:l?t.jsx(q,{}):t.jsx(N,{}),onClick:c=>{c.stopPropagation(),h(r.id)},children:i(l?"chat.systemPromptSelector.hide":"chat.systemPromptSelector.preview")}),t.jsx(v,{type:"text",size:"small",icon:t.jsx(O,{}),onClick:c=>a(c,r),children:i("chat.systemPromptSelector.copy")})]})]}),r.description?t.jsx(L,{type:"secondary",style:{marginLeft:e.marginLG,fontSize:e.fontSizeSM},children:r.description}):null,t.jsxs(y,{size:"small",wrap:!0,style:{marginLeft:e.marginLG},children:[t.jsx(f,{color:"processing",children:i("chat.systemPromptSelector.lines",{count:j})}),t.jsx(f,{color:"purple",children:i("chat.systemPromptSelector.words",{count:u})}),t.jsx(f,{color:"success",children:i("chat.systemPromptSelector.chars",{count:P})})]}),l?t.jsx(re,{content:o,token:e,showGradient:x,onClick:c=>c.stopPropagation()}):t.jsx(se,{type:"secondary",ellipsis:{rows:3},style:{marginLeft:e.marginLG,marginBottom:0,color:e.colorTextSecondary},children:o||i("chat.systemPromptSelector.noContent")})]})},r.id)},{Text:ae}=T,{useToken:ie}=V,he=({open:r,onClose:e,onSelect:g,prompts:l,title:n,showCancelButton:h=!0})=>{const{t:a}=G(),{token:i}=ie(),[o,j]=Q.useMessage(),u=B(s=>s.lastSelectedPromptId),P=B(s=>s.setLastSelectedPromptId),[x,c]=p.useState(null),[S,C]=p.useState(null),m=p.useMemo(()=>l.filter(s=>s.id&&s.id.trim()!==""),[l]),w=async(s,d)=>{s.stopPropagation();const M=d.content??"";try{await Z(M),o.success(a("success.promptCopied",{name:d.name}))}catch(D){console.error("[SystemPromptSelector] Failed to copy prompt:",D),o.error(a("error.copyPromptFailed"))}},R=n??a("chat.prompt.selectorTitle");p.useEffect(()=>{if(r){const s=m.find(M=>M.isDefault),d=u||(s==null?void 0:s.id)||(m.length>0?m[0].id:null);c(d)}},[r,u,m.length]);const $=s=>{c(s.id),P(s.id),g(s),e()},z=()=>{e()};return t.jsxs(t.Fragment,{children:[j,t.jsxs(J,{title:t.jsxs(y,{children:[t.jsx(U,{}),R]}),open:r,onCancel:z,width:700,footer:t.jsx(_,{buttons:[...h?[k(z)]:[],ee(()=>{const s=m.find(d=>d.id===x);s&&$(s)},{text:a("chat.prompt.createButton"),disabled:!x})]}),styles:{body:{maxHeight:"70vh",overflowY:"auto",padding:i.paddingMD}},children:[t.jsx("div",{style:{marginBottom:i.marginMD},children:t.jsx(ae,{type:"secondary",style:{fontSize:i.fontSizeSM},children:a("chat.prompt.helperText")})}),m.length===0?t.jsx(K,{description:a("chat.prompt.emptyDescription"),style:{margin:i.marginLG}}):t.jsx("div",{children:m.map(s=>t.jsx(ne,{prompt:s,token:i,isSelected:x===s.id,isExpanded:S===s.id,onSelect:d=>c(d),onToggleExpand:d=>C(S===d?null:d),onCopy:w},s.id))})]})]})};export{he as default};
1
+ import{j as t,M as E,r as F,h as H}from"./vendor-markdown-DrYaLZhb.js";import{i as I,u as G,a as p}from"./vendor-i18n-Dm-c3D_C.js";import{j as y,N as v,G as X,l as B,z as A,ag as Y,o as f,ap as q,aq as N,ar as O,as as Q,a2 as J,Q as K,D as U,t as V}from"./vendor-antd-CKNrd1kL.js";import{z as W,u as z,B as Z}from"./App-CiBjfJbZ.js";import"./vendor-mermaid-DBtTSFLf.js";import"./main-CvPZyRz3.js";const _=({buttons:r,className:e,style:g,size:l="middle",align:n="right"})=>{const h={className:e,style:{width:"100%",justifyContent:n==="left"?"flex-start":n==="center"?"center":"flex-end",...g}};return t.jsx(y,{...h,children:r.map(a=>t.jsx(v,{type:a.type||"default",disabled:a.disabled,loading:a.loading,danger:a.danger,onClick:a.onClick,size:l,icon:a.icon,children:a.text},a.key))})},k=(r,e)=>({key:"cancel",text:e||I.t("common.cancel"),type:"default",onClick:r}),ee=(r,e)=>({key:"ok",text:(e==null?void 0:e.text)||I.t("common.ok"),type:"primary",disabled:e==null?void 0:e.disabled,loading:e==null?void 0:e.loading,onClick:r}),{Text:b,Paragraph:te}=B,re=({content:r,token:e,showGradient:g,onClick:l})=>t.jsx(X,{size:"small",style:{marginLeft:e.marginLG,marginTop:e.marginXS,backgroundColor:e.colorBgLayout,borderColor:e.colorBorderSecondary},styles:{body:{padding:e.paddingMD}},onClick:l,children:t.jsxs("div",{style:{maxHeight:"60vh",overflowY:"auto",position:"relative",paddingRight:e.paddingXS},children:[t.jsx(E,{remarkPlugins:[F],components:{p:({children:n})=>t.jsx(te,{style:{marginBottom:e.marginSM},children:n}),ol:({children:n})=>t.jsx("ol",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:n}),ul:({children:n})=>t.jsx("ul",{style:{marginBottom:e.marginSM,paddingLeft:e.paddingLG},children:n}),li:({children:n})=>t.jsx("li",{style:{marginBottom:e.marginXS},children:n}),h1:({children:n})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading3,marginBottom:e.marginSM,display:"block"},children:n}),h2:({children:n})=>t.jsx(b,{strong:!0,style:{fontSize:e.fontSizeHeading4,marginBottom:e.marginSM,display:"block"},children:n}),code:({inline:n,className:h,children:a,...i})=>{const o=/language-(\w+)/.exec(h||"");return n?t.jsx("code",{className:h,style:{backgroundColor:e.colorFillTertiary,padding:"0 4px",borderRadius:e.borderRadiusSM,fontSize:e.fontSizeSM},...i,children:a}):t.jsx(H,{style:W,language:(o==null?void 0:o[1])||"text",PreTag:"div",wrapLongLines:!0,children:String(a).replace(/\n$/,"")})}},children:r||"No content available."}),g?t.jsx("div",{style:{position:"sticky",bottom:0,height:48,background:`linear-gradient(180deg, transparent, ${e.colorBgLayout})`,pointerEvents:"none",marginTop:-48}}):null]})}),{Text:L,Paragraph:se}=B,ne=({prompt:r,token:e,isSelected:g,isExpanded:l,onSelect:n,onToggleExpand:h,onCopy:a})=>{const{t:i}=G(),o=r.content||"",{nonEmptyLineCount:j,wordCount:u,characterCount:P,showGradient:x}=p.useMemo(()=>{const S=(o?o.split(/\r?\n/):[]).filter(w=>w.trim().length>0).length,C=o.trim()?o.trim().split(/\s+/).filter(Boolean).length:0,m=o.length;return{nonEmptyLineCount:S,wordCount:C,characterCount:m,showGradient:!l&&m>600}},[o,l]);return t.jsx(A.Item,{style:{cursor:"pointer",padding:e.paddingMD,borderRadius:e.borderRadius,border:g?`2px solid ${e.colorPrimary}`:`1px solid ${e.colorBorderSecondary}`,marginBottom:e.marginXS,backgroundColor:g?e.colorPrimaryBg:e.colorBgContainer,transition:"all 0.2s ease"},onClick:()=>n(r.id),children:t.jsxs(y,{direction:"vertical",style:{width:"100%"},size:e.marginSM,children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",width:"100%",gap:e.marginSM},children:[t.jsxs(y,{align:"start",children:[t.jsx(Y,{checked:g,onChange:()=>n(r.id),onClick:c=>c.stopPropagation()}),t.jsxs("div",{children:[t.jsx(L,{strong:!0,children:r.name||r.id}),t.jsx("div",{children:t.jsx(L,{code:!0,style:{fontSize:e.fontSizeSM,color:e.colorTextSecondary},children:r.id})})]}),r.isDefault?t.jsx(f,{color:"warning",children:i("chat.systemPromptSelector.defaultTag")}):null]}),t.jsxs(y,{size:"small",children:[t.jsx(v,{type:"text",size:"small",icon:l?t.jsx(q,{}):t.jsx(N,{}),onClick:c=>{c.stopPropagation(),h(r.id)},children:i(l?"chat.systemPromptSelector.hide":"chat.systemPromptSelector.preview")}),t.jsx(v,{type:"text",size:"small",icon:t.jsx(O,{}),onClick:c=>a(c,r),children:i("chat.systemPromptSelector.copy")})]})]}),r.description?t.jsx(L,{type:"secondary",style:{marginLeft:e.marginLG,fontSize:e.fontSizeSM},children:r.description}):null,t.jsxs(y,{size:"small",wrap:!0,style:{marginLeft:e.marginLG},children:[t.jsx(f,{color:"processing",children:i("chat.systemPromptSelector.lines",{count:j})}),t.jsx(f,{color:"purple",children:i("chat.systemPromptSelector.words",{count:u})}),t.jsx(f,{color:"success",children:i("chat.systemPromptSelector.chars",{count:P})})]}),l?t.jsx(re,{content:o,token:e,showGradient:x,onClick:c=>c.stopPropagation()}):t.jsx(se,{type:"secondary",ellipsis:{rows:3},style:{marginLeft:e.marginLG,marginBottom:0,color:e.colorTextSecondary},children:o||i("chat.systemPromptSelector.noContent")})]})},r.id)},{Text:ae}=B,{useToken:ie}=V,he=({open:r,onClose:e,onSelect:g,prompts:l,title:n,showCancelButton:h=!0})=>{const{t:a}=G(),{token:i}=ie(),[o,j]=Q.useMessage(),u=z(s=>s.lastSelectedPromptId),P=z(s=>s.setLastSelectedPromptId),[x,c]=p.useState(null),[S,C]=p.useState(null),m=p.useMemo(()=>l.filter(s=>s.id&&s.id.trim()!==""),[l]),w=async(s,d)=>{s.stopPropagation();const M=d.content??"";try{await Z(M),o.success(a("success.promptCopied",{name:d.name}))}catch(D){console.error("[SystemPromptSelector] Failed to copy prompt:",D),o.error(a("error.copyPromptFailed"))}},R=n??a("chat.prompt.selectorTitle");p.useEffect(()=>{if(r){const s=m.find(M=>M.isDefault),d=u||(s==null?void 0:s.id)||(m.length>0?m[0].id:null);c(d)}},[r,u,m.length]);const $=s=>{c(s.id),P(s.id),g(s),e()},T=()=>{e()};return t.jsxs(t.Fragment,{children:[j,t.jsxs(J,{title:t.jsxs(y,{children:[t.jsx(U,{}),R]}),open:r,onCancel:T,width:700,footer:t.jsx(_,{buttons:[...h?[k(T)]:[],ee(()=>{const s=m.find(d=>d.id===x);s&&$(s)},{text:a("chat.prompt.createButton"),disabled:!x})]}),styles:{body:{maxHeight:"70vh",overflowY:"auto",padding:i.paddingMD}},children:[t.jsx("div",{style:{marginBottom:i.marginMD},children:t.jsx(ae,{type:"secondary",style:{fontSize:i.fontSizeSM},children:a("chat.prompt.helperText")})}),m.length===0?t.jsx(K,{description:a("chat.prompt.emptyDescription"),style:{margin:i.marginLG}}):t.jsx("div",{children:m.map(s=>t.jsx(ne,{prompt:s,token:i,isSelected:x===s.id,isExpanded:S===s.id,onSelect:d=>c(d),onToggleExpand:d=>C(S===d?null:d),onCopy:w},s.id))})]})]})};export{he as default};
@@ -1 +1 @@
1
- import{j as t}from"./vendor-markdown-DrYaLZhb.js";import{u as b,a as x}from"./vendor-i18n-Dm-c3D_C.js";import{u as i}from"./App-BAFyf064.js";import{X as w,Y as n,N as l,Z as T,z as c,o as R,$ as k,a0 as v,a1 as C,a2 as E,a3 as d}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-B_9yBBtL.js";import"./main-C1pyfoEz.js";const V=()=>{const{t:s}=b(),{message:r}=w.useApp(),f=i(e=>e.systemPrompts),P=i(e=>e.addSystemPrompt),j=i(e=>e.updateSystemPrompt),M=i(e=>e.deleteSystemPrompt),[h,u]=x.useState(!1),[a,p]=x.useState(null),[o]=n.useForm(),g=(e=null)=>{if(e!=null&&e.isDefault){r.warning(s("settings.systemPromptManager.defaultPromptLocked"));return}p(e),o.setFieldsValue(e||{name:"",description:"",content:""}),u(!0)},y=()=>{u(!1),p(null),o.resetFields()},S=async()=>{if(a!=null&&a.isDefault){r.warning(s("settings.systemPromptManager.defaultPromptLocked"));return}try{const e=await o.validateFields();a?(await j({...a,...e}),r.success(s("settings.systemPromptManager.updateSuccess"))):(await P(e),r.success(s("settings.systemPromptManager.addSuccess"))),y()}catch(e){console.error("Failed to save prompt:",e),r.error(e instanceof Error?e.message:s("settings.systemPromptManager.saveError"))}},I=async e=>{try{await M(e),r.success(s("settings.systemPromptManager.deleteSuccess"))}catch(m){console.error("Failed to delete prompt:",m),r.error(m instanceof Error?m.message:s("settings.systemPromptManager.deleteError"))}};return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[t.jsx("h2",{children:s("settings.systemPromptManager.title")}),t.jsx(l,{type:"primary",icon:t.jsx(T,{}),onClick:()=>g(),children:s("settings.systemPromptManager.addButton")})]}),t.jsx(c,{itemLayout:"horizontal",dataSource:f,renderItem:e=>t.jsxs(c.Item,{actions:[e.isDefault?null:t.jsx(l,{type:"text",icon:t.jsx(k,{}),onClick:()=>g(e)}),e.isDefault?null:t.jsx(v,{title:s("settings.systemPromptManager.deleteConfirm"),onConfirm:()=>I(e.id),okText:s("common.yes"),cancelText:s("common.no"),children:t.jsx(l,{type:"text",danger:!0,icon:t.jsx(C,{}),"aria-label":s("common.delete")})})],children:[t.jsx(c.Item.Meta,{title:e.name,description:e.description||e.content.substring(0,200)+(e.content.length>200?"...":"")}),e.isDefault&&t.jsx(R,{children:s("settings.systemPromptManager.defaultTag")})]})}),t.jsx(E,{title:s(a?"settings.systemPromptManager.editTitle":"settings.systemPromptManager.addTitle"),open:h,onOk:S,onCancel:y,width:"60%",forceRender:!0,children:t.jsxs(n,{form:o,layout:"vertical",name:"system_prompt_form",children:[t.jsx(n.Item,{name:"name",label:s("settings.systemPromptManager.nameLabel"),rules:[{required:!0,message:s("settings.systemPromptManager.nameRequired")}],children:t.jsx(d,{})}),t.jsx(n.Item,{name:"description",label:s("settings.systemPromptManager.descriptionLabel"),rules:[{required:!1,message:s("settings.systemPromptManager.descriptionRequired")}],children:t.jsx(d.TextArea,{rows:3})}),t.jsx(n.Item,{name:"content",label:s("settings.systemPromptManager.contentLabel"),rules:[{required:!0,message:s("settings.systemPromptManager.contentRequired")}],children:t.jsx(d.TextArea,{rows:10})})]})})]})};export{V as default};
1
+ import{j as t}from"./vendor-markdown-DrYaLZhb.js";import{u as b,a as x}from"./vendor-i18n-Dm-c3D_C.js";import{u as i}from"./App-CiBjfJbZ.js";import{X as w,Y as n,N as l,Z as T,z as c,o as R,$ as k,a0 as v,a1 as C,a2 as E,a3 as d}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-DBtTSFLf.js";import"./main-CvPZyRz3.js";const V=()=>{const{t:s}=b(),{message:r}=w.useApp(),f=i(e=>e.systemPrompts),P=i(e=>e.addSystemPrompt),j=i(e=>e.updateSystemPrompt),M=i(e=>e.deleteSystemPrompt),[h,u]=x.useState(!1),[a,p]=x.useState(null),[o]=n.useForm(),g=(e=null)=>{if(e!=null&&e.isDefault){r.warning(s("settings.systemPromptManager.defaultPromptLocked"));return}p(e),o.setFieldsValue(e||{name:"",description:"",content:""}),u(!0)},y=()=>{u(!1),p(null),o.resetFields()},S=async()=>{if(a!=null&&a.isDefault){r.warning(s("settings.systemPromptManager.defaultPromptLocked"));return}try{const e=await o.validateFields();a?(await j({...a,...e}),r.success(s("settings.systemPromptManager.updateSuccess"))):(await P(e),r.success(s("settings.systemPromptManager.addSuccess"))),y()}catch(e){console.error("Failed to save prompt:",e),r.error(e instanceof Error?e.message:s("settings.systemPromptManager.saveError"))}},I=async e=>{try{await M(e),r.success(s("settings.systemPromptManager.deleteSuccess"))}catch(m){console.error("Failed to delete prompt:",m),r.error(m instanceof Error?m.message:s("settings.systemPromptManager.deleteError"))}};return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[t.jsx("h2",{children:s("settings.systemPromptManager.title")}),t.jsx(l,{type:"primary",icon:t.jsx(T,{}),onClick:()=>g(),children:s("settings.systemPromptManager.addButton")})]}),t.jsx(c,{itemLayout:"horizontal",dataSource:f,renderItem:e=>t.jsxs(c.Item,{actions:[e.isDefault?null:t.jsx(l,{type:"text",icon:t.jsx(k,{}),onClick:()=>g(e)}),e.isDefault?null:t.jsx(v,{title:s("settings.systemPromptManager.deleteConfirm"),onConfirm:()=>I(e.id),okText:s("common.yes"),cancelText:s("common.no"),children:t.jsx(l,{type:"text",danger:!0,icon:t.jsx(C,{}),"aria-label":s("common.delete")})})],children:[t.jsx(c.Item.Meta,{title:e.name,description:e.description||e.content.substring(0,200)+(e.content.length>200?"...":"")}),e.isDefault&&t.jsx(R,{children:s("settings.systemPromptManager.defaultTag")})]})}),t.jsx(E,{title:s(a?"settings.systemPromptManager.editTitle":"settings.systemPromptManager.addTitle"),open:h,onOk:S,onCancel:y,width:"60%",forceRender:!0,children:t.jsxs(n,{form:o,layout:"vertical",name:"system_prompt_form",children:[t.jsx(n.Item,{name:"name",label:s("settings.systemPromptManager.nameLabel"),rules:[{required:!0,message:s("settings.systemPromptManager.nameRequired")}],children:t.jsx(d,{})}),t.jsx(n.Item,{name:"description",label:s("settings.systemPromptManager.descriptionLabel"),rules:[{required:!1,message:s("settings.systemPromptManager.descriptionRequired")}],children:t.jsx(d.TextArea,{rows:3})}),t.jsx(n.Item,{name:"content",label:s("settings.systemPromptManager.contentLabel"),rules:[{required:!0,message:s("settings.systemPromptManager.contentRequired")}],children:t.jsx(d.TextArea,{rows:10})})]})})]})};export{V as default};
@@ -1 +1 @@
1
- import{j as n}from"./vendor-markdown-DrYaLZhb.js";import{u as V,a as d}from"./vendor-i18n-Dm-c3D_C.js";import{u as h,b as H,c as W,d as B,e as A,f as Q,A as z,g as G,o as Y,i as X}from"./App-BAFyf064.js";import{t as Z,X as J,a4 as ee,Z as te,a5 as se,a6 as ne,a7 as oe,a8 as ae,a9 as ie,aa as le,a2 as re,ab as de,a3 as ce,l as me,I as ue,ac as pe,o as ge}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-B_9yBBtL.js";import"./main-C1pyfoEz.js";const be=(()=>{let e=null,o=[],a=new Map;return i=>{if(i===e)return o;const p=i.map(c=>{const l=a.get(c.id),g={id:c.id,title:c.title,kind:c.kind,pinned:c.pinned,updatedAt:c.updatedAt,workspacePath:c.config.workspacePath};return l&&l.title===g.title&&l.kind===g.kind&&l.pinned===g.pinned&&l.updatedAt===g.updatedAt&&l.workspacePath===g.workspacePath?l:g}),P=p.length===o.length&&p.every((c,l)=>c===o[l]);return e=i,a=new Map(p.map(c=>[c.id,c])),P?o:(o=p,p)}})(),fe=[{id:"settings-provider",tabKey:"provider",titleKey:"commandPalette.actions.openProviderSettings",fallbackTitle:"Open Provider Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["api","key","openai","anthropic","gemini","model"]},{id:"settings-model-limits",tabKey:"model-limits",titleKey:"commandPalette.actions.openModelLimits",fallbackTitle:"Open Model Limits",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["token","context","window","budget","limit"]},{id:"settings-prompts",tabKey:"prompts",titleKey:"commandPalette.actions.openPrompts",fallbackTitle:"Open System Prompts",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["system","prompt","persona","instruction"]},{id:"settings-skills",tabKey:"skills",titleKey:"commandPalette.actions.openSkills",fallbackTitle:"Open Skills",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["skill","capability","plugin"]},{id:"settings-mcp",tabKey:"mcp",titleKey:"commandPalette.actions.openMcpSettings",fallbackTitle:"Open MCP Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["mcp","server","tool","external"]},{id:"settings-workflows",tabKey:"workflows",titleKey:"commandPalette.actions.openWorkflowSettings",fallbackTitle:"Open Workflow Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["workflow","automation","template"]},{id:"settings-hooks",tabKey:"hooks",titleKey:"commandPalette.actions.openHooks",fallbackTitle:"Open Hooks",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["hook","event","trigger","callback"]},{id:"settings-schedules",tabKey:"schedules",titleKey:"commandPalette.actions.openSchedulesSettings",fallbackTitle:"Open Schedules",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Ops",keywords:["schedule","cron","recurring","timer","automated"]},{id:"settings-sessions",tabKey:"sessions",titleKey:"commandPalette.actions.openSessionsSettings",fallbackTitle:"Open Session Monitor",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["session","monitor","cleanup","history"]},{id:"settings-metrics",tabKey:"metrics",titleKey:"commandPalette.actions.openMetrics",fallbackTitle:"Open Metrics Dashboard",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["metrics","dashboard","analytics","usage","stats"]},{id:"settings-masking",tabKey:"masking",titleKey:"commandPalette.actions.openMasking",fallbackTitle:"Open Keyword Masking",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"Security & privacy",badge:"Security",keywords:["mask","redact","privacy","keyword","sensitive"]},{id:"settings-env",tabKey:"env-vars",titleKey:"commandPalette.actions.openEnvVars",fallbackTitle:"Open Environment Variables",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["env","environment","variable","config"]},{id:"settings-config",tabKey:"config",titleKey:"commandPalette.actions.openConfig",fallbackTitle:"Open Configuration",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["config","json","bamboo","data","path"]},{id:"settings-app",tabKey:"app",titleKey:"commandPalette.actions.openAppSettings",fallbackTitle:"Open App Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["app","application","reset","theme","language"]}],ye=(e,o)=>{const a=[e.title,e.id,e.kind||"root"];return e.pinned&&a.push("pinned","pin"),o&&a.push("running","processing"),e.workspacePath&&a.push(e.workspacePath),e.updatedAt&&a.push(e.updatedAt),a.filter(Boolean)},ke=(e,o,a)=>{const i=[];if(e.kind==="child"?i.push(o):i.push(a),e.workspacePath&&i.push(e.workspacePath),e.updatedAt)try{i.push(new Date(e.updatedAt).toLocaleString())}catch{i.push(e.updatedAt)}return i.join(" • ")},Se=(e,o)=>{const a=o.trim().toLowerCase();return a?e.filter(i=>[i.title,i.subtitle||"",...i.keywords].join(" ").toLowerCase().includes(a)):e},we=e=>{if(!(e instanceof HTMLElement))return!1;const o=e.tagName.toLowerCase();return e.isContentEditable?!0:o==="input"||o==="textarea"||o==="select"},v="__LOTUS_COMMAND_PALETTE_FORCE_OPEN__",ve=()=>{const{t:e}=V(),{token:o}=Z.useToken(),a=typeof document<"u"&&document.body.getAttribute("data-vdi-safe")==="true",{message:i}=J.useApp(),p=h(t=>be(t.chats)),P=h(t=>t.addChat),c=h(t=>t.lastSelectedPromptId),l=h(t=>t.systemPrompts),g=h(H(t=>Object.entries(t.executionBySession).filter(([,s])=>X(s.phase)).map(([s])=>s).sort())),[b,f]=d.useState(()=>typeof window>"u"?!1:window[v]?(delete window[v],!0):!1),[E,x]=d.useState(""),[k,S]=d.useState(0),j=d.useRef(null),M=d.useRef(null),C=W(t=>t.open),O=B(t=>t.toggleTheme),I=B(t=>t.themeMode),K=A(t=>t.sidebar.collapsed),L=A(t=>t.setSidebarCollapsed),T=Q(t=>t.mode),N=Q(t=>t.toggleMode),R=d.useCallback(async()=>{var $,q;const t=l.find(w=>w.id===c),s=(t==null?void 0:t.id)||(l.length>0?(($=l.find(w=>w.id==="general_assistant"))==null?void 0:$.id)||l[0].id:""),m=await P({title:e("chat.sidebar.newSession"),createdAt:Date.now(),messages:[],config:{systemPromptId:s,baseSystemPrompt:(t==null?void 0:t.content)||(l.length>0?((q=l.find(w=>w.id==="general_assistant"))==null?void 0:q.content)||l[0].content:""),lastUsedEnhancedPrompt:null}}),{activeLeafId:r,setLeafSessionId:y,setActiveLeafId:U}=A.getState();y(r,m),U(r)},[P,c,l,e]),_=d.useMemo(()=>{const t=fe.filter(s=>!(T==="simple"&&z.has(s.tabKey))).map(s=>({id:s.id,kind:"action",title:e(s.titleKey,s.fallbackTitle),subtitle:e(s.subtitleKey||"commandPalette.groups.settings",s.fallbackSubtitle||"System settings"),keywords:[s.tabKey,s.badge||"","settings","config",...s.keywords||[]],icon:n.jsx(ee,{}),badge:s.badge,onSelect:()=>{C("chat",s.tabKey)}}));return[{id:"new-session",kind:"action",title:e("commandPalette.actions.newSession","Create New Session"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["new","create","session","chat","conversation"],icon:n.jsx(te,{}),badge:e("commandPalette.badges.quickAction","Action"),onSelect:async()=>{await R()}},{id:"toggle-theme",kind:"action",title:I==="dark"?e("commandPalette.actions.switchToLight","Switch to Light Mode"):e("commandPalette.actions.switchToDark","Switch to Dark Mode"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["theme","dark","light","mode","appearance","toggle","color"],icon:n.jsx(se,{}),badge:I==="dark"?"☀️":"🌙",onSelect:()=>{O()}},{id:"toggle-sidebar",kind:"action",title:K?e("commandPalette.actions.showSidebar","Show Sidebar"):e("commandPalette.actions.hideSidebar","Hide Sidebar"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["sidebar","toggle","hide","show","panel","menu"],icon:K?n.jsx(ne,{}):n.jsx(oe,{}),badge:"Layout",onSelect:()=>{L(!K)}},{id:"split-pane",kind:"action",title:e("commandPalette.actions.splitPane","Split Pane"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["split","pane","multi","dual","side","layout"],icon:n.jsx(ae,{}),badge:"Layout",onSelect:()=>{const{tree:s,activeLeafId:m,splitLeaf:r}=A.getState();G(s).length<4&&r(m,"vertical")}},...t,{id:"toggle-experience-mode",kind:"action",title:T==="simple"?e("commandPalette.actions.switchToAdvanced","Switch to Advanced Mode"):e("commandPalette.actions.switchToSimple","Switch to Simple Mode"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["mode","simple","advanced","beginner","expert","experience","complexity"],icon:n.jsx(ie,{}),badge:T==="simple"?"Simple":"Advanced",onSelect:()=>{N()}}]},[R,C,O,I,K,L,T,N,e]),D=d.useMemo(()=>{if(!b)return[];const t=new Set(g);return p.map(s=>{const m=t.has(s.id);return{id:`session-${s.id}`,kind:"session",title:s.title,subtitle:ke(s,e("commandPalette.badges.childSession","Child session"),e("commandPalette.badges.rootSession","Session")),keywords:ye(s,m),icon:n.jsx(le,{}),badge:s.pinned?e("commandPalette.badges.pinned","Pinned"):m?e("commandPalette.badges.running","Running"):s.kind==="child"?e("commandPalette.badges.child","Child"):void 0,onSelect:()=>{Y(s.id)}}})},[b,g,p,e]),F=d.useMemo(()=>[..._,...D],[_,D]),u=d.useMemo(()=>Se(F,E).slice(0,40),[F,E]);return d.useEffect(()=>{S(t=>u.length===0?0:Math.min(t,u.length-1))},[u.length]),d.useEffect(()=>{if(!b)return;const t=window.setTimeout(()=>{var s,m;(s=j.current)==null||s.focus(),(m=j.current)==null||m.select()},0);return()=>window.clearTimeout(t)},[b]),d.useEffect(()=>{if(typeof window>"u")return;const t=s=>{if((s.metaKey||s.ctrlKey)&&s.key.toLowerCase()==="k"){s.preventDefault(),f(r=>!r);return}if(b){if(s.key==="Escape"){s.preventDefault(),f(!1);return}if(!(we(s.target)&&s.key!=="ArrowUp"&&s.key!=="ArrowDown"&&s.key!=="Enter")){if(s.key==="ArrowDown"){s.preventDefault(),S(r=>u.length===0?0:(r+1)%u.length);return}if(s.key==="ArrowUp"){s.preventDefault(),S(r=>u.length===0?0:r===0?u.length-1:r-1);return}if(s.key==="Enter"){const r=u[k];if(!r)return;s.preventDefault(),(async()=>{try{await r.onSelect(),f(!1),x("")}catch(y){console.error("[CommandPalette] action failed",y),i.error(y instanceof Error?y.message:e("commandPalette.errors.actionFailed","Command failed"))}})()}}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[u,i,b,k,e]),d.useEffect(()=>{b||(x(""),S(0))},[b]),d.useEffect(()=>{typeof window>"u"||!window[v]||(delete window[v],f(!0))},[]),d.useEffect(()=>{const t=M.current;if(!t)return;const s=t.querySelector(`[data-command-index="${k}"]`);s==null||s.scrollIntoView({block:"nearest"})},[k]),n.jsx(re,{open:b,onCancel:()=>f(!1),footer:null,centered:!0,width:680,destroyOnClose:!0,className:"lotus-command-palette-modal",title:null,closable:!1,styles:{content:{padding:12,borderRadius:o.borderRadiusLG,overflow:"hidden",background:o.colorBgElevated,backdropFilter:a?"none":"blur(18px)",WebkitBackdropFilter:a?"none":"blur(18px)"},body:{padding:0},mask:{backdropFilter:a?"none":"blur(6px)",WebkitBackdropFilter:a?"none":"blur(6px)"}},children:n.jsxs("div",{className:"lotus-command-palette-shell",children:[n.jsxs("div",{className:"lotus-command-palette-search",children:[n.jsx(de,{style:{color:o.colorTextTertiary,fontSize:16}}),n.jsx(ce,{ref:j,value:E,onChange:t=>x(t.target.value),variant:"borderless",placeholder:e("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),"aria-label":e("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),suffix:n.jsx(me.Text,{type:"secondary",style:{fontSize:12},children:"⌘K"})})]}),n.jsxs("div",{className:"lotus-command-palette-hint",children:[n.jsx(ue,{}),n.jsx("span",{children:e("commandPalette.navigationHint","Use ↑↓ to navigate, Enter to open, and Esc to close.")})]}),n.jsx("div",{ref:M,className:"lotus-command-palette-list",role:"listbox",children:u.length===0?n.jsxs("div",{className:"lotus-command-palette-empty",children:[n.jsx(pe,{}),n.jsx("span",{children:e("commandPalette.empty","No matching commands")})]}):u.map((t,s)=>{const m=s===k;return n.jsxs("button",{type:"button",className:`lotus-command-palette-item ${m?"is-selected":""}`,"data-command-index":s,onMouseEnter:()=>S(s),onClick:()=>{(async()=>{try{await t.onSelect(),f(!1),x("")}catch(r){console.error("[CommandPalette] action failed",r),i.error(r instanceof Error?r.message:e("commandPalette.errors.actionFailed","Command failed"))}})()},children:[n.jsx("span",{className:"lotus-command-palette-item-icon",children:t.icon}),n.jsxs("span",{className:"lotus-command-palette-item-content",children:[n.jsxs("span",{className:"lotus-command-palette-item-title-row",children:[n.jsx("span",{className:"lotus-command-palette-item-title",children:t.title}),t.badge?n.jsx(ge,{bordered:!1,children:t.badge}):null]}),t.subtitle?n.jsx("span",{className:"lotus-command-palette-item-subtitle",children:t.subtitle}):null]})]},t.id)})})]})})};export{ve as CommandPalette,ve as default};
1
+ import{j as n}from"./vendor-markdown-DrYaLZhb.js";import{u as V,a as d}from"./vendor-i18n-Dm-c3D_C.js";import{u as h,b as H,c as W,d as B,e as A,f as Q,A as z,g as G,o as Y,i as X}from"./App-CiBjfJbZ.js";import{t as Z,X as J,a4 as ee,Z as te,a5 as se,a6 as ne,a7 as oe,a8 as ae,a9 as ie,aa as le,a2 as re,ab as de,a3 as ce,l as me,I as ue,ac as pe,o as ge}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-DBtTSFLf.js";import"./main-CvPZyRz3.js";const be=(()=>{let e=null,o=[],a=new Map;return i=>{if(i===e)return o;const p=i.map(c=>{const l=a.get(c.id),g={id:c.id,title:c.title,kind:c.kind,pinned:c.pinned,updatedAt:c.updatedAt,workspacePath:c.config.workspacePath};return l&&l.title===g.title&&l.kind===g.kind&&l.pinned===g.pinned&&l.updatedAt===g.updatedAt&&l.workspacePath===g.workspacePath?l:g}),P=p.length===o.length&&p.every((c,l)=>c===o[l]);return e=i,a=new Map(p.map(c=>[c.id,c])),P?o:(o=p,p)}})(),fe=[{id:"settings-provider",tabKey:"provider",titleKey:"commandPalette.actions.openProviderSettings",fallbackTitle:"Open Provider Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["api","key","openai","anthropic","gemini","model"]},{id:"settings-model-limits",tabKey:"model-limits",titleKey:"commandPalette.actions.openModelLimits",fallbackTitle:"Open Model Limits",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["token","context","window","budget","limit"]},{id:"settings-prompts",tabKey:"prompts",titleKey:"commandPalette.actions.openPrompts",fallbackTitle:"Open System Prompts",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"AI",keywords:["system","prompt","persona","instruction"]},{id:"settings-skills",tabKey:"skills",titleKey:"commandPalette.actions.openSkills",fallbackTitle:"Open Skills",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["skill","capability","plugin"]},{id:"settings-mcp",tabKey:"mcp",titleKey:"commandPalette.actions.openMcpSettings",fallbackTitle:"Open MCP Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["mcp","server","tool","external"]},{id:"settings-workflows",tabKey:"workflows",titleKey:"commandPalette.actions.openWorkflowSettings",fallbackTitle:"Open Workflow Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["workflow","automation","template"]},{id:"settings-hooks",tabKey:"hooks",titleKey:"commandPalette.actions.openHooks",fallbackTitle:"Open Hooks",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Tools",keywords:["hook","event","trigger","callback"]},{id:"settings-schedules",tabKey:"schedules",titleKey:"commandPalette.actions.openSchedulesSettings",fallbackTitle:"Open Schedules",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Ops",keywords:["schedule","cron","recurring","timer","automated"]},{id:"settings-sessions",tabKey:"sessions",titleKey:"commandPalette.actions.openSessionsSettings",fallbackTitle:"Open Session Monitor",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["session","monitor","cleanup","history"]},{id:"settings-metrics",tabKey:"metrics",titleKey:"commandPalette.actions.openMetrics",fallbackTitle:"Open Metrics Dashboard",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"Monitor",keywords:["metrics","dashboard","analytics","usage","stats"]},{id:"settings-masking",tabKey:"masking",titleKey:"commandPalette.actions.openMasking",fallbackTitle:"Open Keyword Masking",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"Security & privacy",badge:"Security",keywords:["mask","redact","privacy","keyword","sensitive"]},{id:"settings-env",tabKey:"env-vars",titleKey:"commandPalette.actions.openEnvVars",fallbackTitle:"Open Environment Variables",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["env","environment","variable","config"]},{id:"settings-config",tabKey:"config",titleKey:"commandPalette.actions.openConfig",fallbackTitle:"Open Configuration",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["config","json","bamboo","data","path"]},{id:"settings-app",tabKey:"app",titleKey:"commandPalette.actions.openAppSettings",fallbackTitle:"Open App Settings",subtitleKey:"commandPalette.groups.settings",fallbackSubtitle:"System settings",badge:"System",keywords:["app","application","reset","theme","language"]}],ye=(e,o)=>{const a=[e.title,e.id,e.kind||"root"];return e.pinned&&a.push("pinned","pin"),o&&a.push("running","processing"),e.workspacePath&&a.push(e.workspacePath),e.updatedAt&&a.push(e.updatedAt),a.filter(Boolean)},ke=(e,o,a)=>{const i=[];if(e.kind==="child"?i.push(o):i.push(a),e.workspacePath&&i.push(e.workspacePath),e.updatedAt)try{i.push(new Date(e.updatedAt).toLocaleString())}catch{i.push(e.updatedAt)}return i.join(" • ")},Se=(e,o)=>{const a=o.trim().toLowerCase();return a?e.filter(i=>[i.title,i.subtitle||"",...i.keywords].join(" ").toLowerCase().includes(a)):e},we=e=>{if(!(e instanceof HTMLElement))return!1;const o=e.tagName.toLowerCase();return e.isContentEditable?!0:o==="input"||o==="textarea"||o==="select"},v="__LOTUS_COMMAND_PALETTE_FORCE_OPEN__",ve=()=>{const{t:e}=V(),{token:o}=Z.useToken(),a=typeof document<"u"&&document.body.getAttribute("data-vdi-safe")==="true",{message:i}=J.useApp(),p=h(t=>be(t.chats)),P=h(t=>t.addChat),c=h(t=>t.lastSelectedPromptId),l=h(t=>t.systemPrompts),g=h(H(t=>Object.entries(t.executionBySession).filter(([,s])=>X(s.phase)).map(([s])=>s).sort())),[b,f]=d.useState(()=>typeof window>"u"?!1:window[v]?(delete window[v],!0):!1),[E,x]=d.useState(""),[k,S]=d.useState(0),j=d.useRef(null),M=d.useRef(null),C=W(t=>t.open),O=B(t=>t.toggleTheme),I=B(t=>t.themeMode),K=A(t=>t.sidebar.collapsed),L=A(t=>t.setSidebarCollapsed),T=Q(t=>t.mode),N=Q(t=>t.toggleMode),R=d.useCallback(async()=>{var $,q;const t=l.find(w=>w.id===c),s=(t==null?void 0:t.id)||(l.length>0?(($=l.find(w=>w.id==="general_assistant"))==null?void 0:$.id)||l[0].id:""),m=await P({title:e("chat.sidebar.newSession"),createdAt:Date.now(),messages:[],config:{systemPromptId:s,baseSystemPrompt:(t==null?void 0:t.content)||(l.length>0?((q=l.find(w=>w.id==="general_assistant"))==null?void 0:q.content)||l[0].content:""),lastUsedEnhancedPrompt:null}}),{activeLeafId:r,setLeafSessionId:y,setActiveLeafId:U}=A.getState();y(r,m),U(r)},[P,c,l,e]),_=d.useMemo(()=>{const t=fe.filter(s=>!(T==="simple"&&z.has(s.tabKey))).map(s=>({id:s.id,kind:"action",title:e(s.titleKey,s.fallbackTitle),subtitle:e(s.subtitleKey||"commandPalette.groups.settings",s.fallbackSubtitle||"System settings"),keywords:[s.tabKey,s.badge||"","settings","config",...s.keywords||[]],icon:n.jsx(ee,{}),badge:s.badge,onSelect:()=>{C("chat",s.tabKey)}}));return[{id:"new-session",kind:"action",title:e("commandPalette.actions.newSession","Create New Session"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["new","create","session","chat","conversation"],icon:n.jsx(te,{}),badge:e("commandPalette.badges.quickAction","Action"),onSelect:async()=>{await R()}},{id:"toggle-theme",kind:"action",title:I==="dark"?e("commandPalette.actions.switchToLight","Switch to Light Mode"):e("commandPalette.actions.switchToDark","Switch to Dark Mode"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["theme","dark","light","mode","appearance","toggle","color"],icon:n.jsx(se,{}),badge:I==="dark"?"☀️":"🌙",onSelect:()=>{O()}},{id:"toggle-sidebar",kind:"action",title:K?e("commandPalette.actions.showSidebar","Show Sidebar"):e("commandPalette.actions.hideSidebar","Hide Sidebar"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["sidebar","toggle","hide","show","panel","menu"],icon:K?n.jsx(ne,{}):n.jsx(oe,{}),badge:"Layout",onSelect:()=>{L(!K)}},{id:"split-pane",kind:"action",title:e("commandPalette.actions.splitPane","Split Pane"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["split","pane","multi","dual","side","layout"],icon:n.jsx(ae,{}),badge:"Layout",onSelect:()=>{const{tree:s,activeLeafId:m,splitLeaf:r}=A.getState();G(s).length<4&&r(m,"vertical")}},...t,{id:"toggle-experience-mode",kind:"action",title:T==="simple"?e("commandPalette.actions.switchToAdvanced","Switch to Advanced Mode"):e("commandPalette.actions.switchToSimple","Switch to Simple Mode"),subtitle:e("commandPalette.groups.quickActions","Quick actions"),keywords:["mode","simple","advanced","beginner","expert","experience","complexity"],icon:n.jsx(ie,{}),badge:T==="simple"?"Simple":"Advanced",onSelect:()=>{N()}}]},[R,C,O,I,K,L,T,N,e]),D=d.useMemo(()=>{if(!b)return[];const t=new Set(g);return p.map(s=>{const m=t.has(s.id);return{id:`session-${s.id}`,kind:"session",title:s.title,subtitle:ke(s,e("commandPalette.badges.childSession","Child session"),e("commandPalette.badges.rootSession","Session")),keywords:ye(s,m),icon:n.jsx(le,{}),badge:s.pinned?e("commandPalette.badges.pinned","Pinned"):m?e("commandPalette.badges.running","Running"):s.kind==="child"?e("commandPalette.badges.child","Child"):void 0,onSelect:()=>{Y(s.id)}}})},[b,g,p,e]),F=d.useMemo(()=>[..._,...D],[_,D]),u=d.useMemo(()=>Se(F,E).slice(0,40),[F,E]);return d.useEffect(()=>{S(t=>u.length===0?0:Math.min(t,u.length-1))},[u.length]),d.useEffect(()=>{if(!b)return;const t=window.setTimeout(()=>{var s,m;(s=j.current)==null||s.focus(),(m=j.current)==null||m.select()},0);return()=>window.clearTimeout(t)},[b]),d.useEffect(()=>{if(typeof window>"u")return;const t=s=>{if((s.metaKey||s.ctrlKey)&&s.key.toLowerCase()==="k"){s.preventDefault(),f(r=>!r);return}if(b){if(s.key==="Escape"){s.preventDefault(),f(!1);return}if(!(we(s.target)&&s.key!=="ArrowUp"&&s.key!=="ArrowDown"&&s.key!=="Enter")){if(s.key==="ArrowDown"){s.preventDefault(),S(r=>u.length===0?0:(r+1)%u.length);return}if(s.key==="ArrowUp"){s.preventDefault(),S(r=>u.length===0?0:r===0?u.length-1:r-1);return}if(s.key==="Enter"){const r=u[k];if(!r)return;s.preventDefault(),(async()=>{try{await r.onSelect(),f(!1),x("")}catch(y){console.error("[CommandPalette] action failed",y),i.error(y instanceof Error?y.message:e("commandPalette.errors.actionFailed","Command failed"))}})()}}}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[u,i,b,k,e]),d.useEffect(()=>{b||(x(""),S(0))},[b]),d.useEffect(()=>{typeof window>"u"||!window[v]||(delete window[v],f(!0))},[]),d.useEffect(()=>{const t=M.current;if(!t)return;const s=t.querySelector(`[data-command-index="${k}"]`);s==null||s.scrollIntoView({block:"nearest"})},[k]),n.jsx(re,{open:b,onCancel:()=>f(!1),footer:null,centered:!0,width:680,destroyOnClose:!0,className:"lotus-command-palette-modal",title:null,closable:!1,styles:{content:{padding:12,borderRadius:o.borderRadiusLG,overflow:"hidden",background:o.colorBgElevated,backdropFilter:a?"none":"blur(18px)",WebkitBackdropFilter:a?"none":"blur(18px)"},body:{padding:0},mask:{backdropFilter:a?"none":"blur(6px)",WebkitBackdropFilter:a?"none":"blur(6px)"}},children:n.jsxs("div",{className:"lotus-command-palette-shell",children:[n.jsxs("div",{className:"lotus-command-palette-search",children:[n.jsx(de,{style:{color:o.colorTextTertiary,fontSize:16}}),n.jsx(ce,{ref:j,value:E,onChange:t=>x(t.target.value),variant:"borderless",placeholder:e("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),"aria-label":e("commandPalette.searchPlaceholder","Search sessions, settings, and actions"),suffix:n.jsx(me.Text,{type:"secondary",style:{fontSize:12},children:"⌘K"})})]}),n.jsxs("div",{className:"lotus-command-palette-hint",children:[n.jsx(ue,{}),n.jsx("span",{children:e("commandPalette.navigationHint","Use ↑↓ to navigate, Enter to open, and Esc to close.")})]}),n.jsx("div",{ref:M,className:"lotus-command-palette-list",role:"listbox",children:u.length===0?n.jsxs("div",{className:"lotus-command-palette-empty",children:[n.jsx(pe,{}),n.jsx("span",{children:e("commandPalette.empty","No matching commands")})]}):u.map((t,s)=>{const m=s===k;return n.jsxs("button",{type:"button",className:`lotus-command-palette-item ${m?"is-selected":""}`,"data-command-index":s,onMouseEnter:()=>S(s),onClick:()=>{(async()=>{try{await t.onSelect(),f(!1),x("")}catch(r){console.error("[CommandPalette] action failed",r),i.error(r instanceof Error?r.message:e("commandPalette.errors.actionFailed","Command failed"))}})()},children:[n.jsx("span",{className:"lotus-command-palette-item-icon",children:t.icon}),n.jsxs("span",{className:"lotus-command-palette-item-content",children:[n.jsxs("span",{className:"lotus-command-palette-item-title-row",children:[n.jsx("span",{className:"lotus-command-palette-item-title",children:t.title}),t.badge?n.jsx(ge,{bordered:!1,children:t.badge}):null]}),t.subtitle?n.jsx("span",{className:"lotus-command-palette-item-subtitle",children:t.subtitle}):null]})]},t.id)})})]})})};export{ve as CommandPalette,ve as default};
@@ -1 +1 @@
1
- import{j as o}from"./vendor-markdown-DrYaLZhb.js";import{u as G,R as N,a as P}from"./vendor-i18n-Dm-c3D_C.js";import{u as y,I as w}from"./App-BAFyf064.js";import{t as O,j as h,k as Q,l as J,n as v,o as f,B as U,p as F,q as I,u as V,v as Y,w as Z,x as oo,y as X,A as so,P as eo,z as E,D as to,E as no,F as ro,G as lo,H as io,I as ao}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-B_9yBBtL.js";import"./main-C1pyfoEz.js";const{Text:p}=J,co=a=>({pending:{icon:o.jsx(ao,{}),color:a.colorTextTertiary,textKey:"components.todoList.status.pending",tagColor:"default"},in_progress:{icon:o.jsx(v,{spin:!0}),color:a.colorPrimary,textKey:"components.todoList.status.inProgress",tagColor:"processing"},completed:{icon:o.jsx(F,{}),color:a.colorSuccess,textKey:"components.todoList.status.completed",tagColor:"success"},blocked:{icon:o.jsx(io,{}),color:a.colorError,textKey:"components.todoList.status.blocked",tagColor:"error"}}),fo=({sessionId:a,initialCollapsed:K=!0,compact:t=!1})=>{const{t:n}=G(),{token:e}=O.useToken(),A=N.useMemo(()=>co(e),[e]),g=y(s=>s.chats.find(c=>c.id===a)),j=(g==null?void 0:g.kind)==="child"&&(g.parentSessionId||g.rootSessionId)||a,l=y(s=>s.taskLists[j]),H=y(s=>s.activeItems[j]),x=y(s=>s.evaluationStates[j]),[r,R]=P.useState(K),[i,W]=P.useState(!1),m=(x==null?void 0:x.isEvaluating)||!1,S=(x==null?void 0:x.reasoning)||null,T=l?{session_id:l.session_id,title:l.title,items:l.items,progress:{completed:l.items.filter(s=>s.status==="completed").length,total:l.items.length,percentage:l.items.length>0?Math.round(l.items.filter(s=>s.status==="completed").length/l.items.length*100):0}}:null;if(!T)return null;const C=()=>{i||R(!r)},D=s=>{s.stopPropagation(),W(!i),i||R(!1)},{title:M,items:q,progress:d}=T,L=d.percentage===100,_=o.jsxs(h,{onClick:C,style:{cursor:"pointer",width:"100%"},size:t?6:8,children:[o.jsx(Q,{style:{color:e.colorPrimary}}),o.jsx(p,{strong:!0,style:{fontSize:t?14:15},children:M||n("components.todoList.title")}),m&&(t?o.jsx(w,{nowrap:!0,items:[o.jsxs(o.Fragment,{children:[o.jsx(v,{spin:!0,style:{color:e.colorPrimary,marginRight:4}}),n("components.todoList.evaluating")]})]}):o.jsx(f,{icon:o.jsx(v,{spin:!0}),color:"processing",children:n("components.todoList.evaluating")})),!r&&d.total>0&&o.jsx(U,{count:`${d.completed}/${d.total}`,style:{backgroundColor:L?e.colorSuccess:e.colorPrimary}})]}),k=o.jsxs(h,{size:t?6:8,children:[d.total>0&&r&&o.jsxs(p,{type:"secondary",style:{fontSize:t?12:13},children:[d.completed,"/",d.total,L&&o.jsx(F,{style:{color:e.colorSuccess,marginLeft:4}})]}),o.jsx(I,{title:n(i?"components.todoList.unpin":"components.todoList.pin"),children:o.jsx("span",{onClick:D,style:{cursor:"pointer",color:i?e.colorPrimary:e.colorTextSecondary,fontSize:t?14:16},children:i?o.jsx(V,{}):o.jsx(Y,{})})}),!i&&o.jsx("span",{onClick:C,style:{cursor:"pointer",color:e.colorTextSecondary,fontSize:12,transform:r?"rotate(-90deg)":void 0,transition:"transform 0.2s"},children:r?o.jsx(Z,{}):o.jsx(oo,{})})]}),b=r?null:o.jsxs(o.Fragment,{children:[S?t?o.jsxs(p,{type:"secondary",style:{display:"block",marginBottom:e.marginXS,fontSize:12,paddingLeft:e.paddingXS,borderLeft:`2px solid ${e.colorPrimaryBorder}`,lineHeight:1.45},children:[o.jsx(X,{style:{marginRight:6}}),S]}):o.jsx(so,{icon:o.jsx(X,{}),message:n("components.todoList.llmEvaluation"),description:S,type:"info",showIcon:!0,style:{marginBottom:16}}):null,d.total>0&&o.jsx("div",{style:{marginBottom:t?e.marginXS:16},children:o.jsx(eo,{percent:d.percentage,size:"small",status:L?"success":"active",format:s=>o.jsxs(p,{type:"secondary",children:[s,"%"]})})}),o.jsx(E,{size:"small",split:!1,dataSource:q,renderItem:s=>{var z,B;const c=A[s.status],u=H===s.id,$=n(c.textKey);return o.jsx(E.Item,{style:{padding:t?"6px 0":"12px 0",borderLeft:u?`3px solid ${e.colorPrimary}`:"3px solid transparent",paddingLeft:u?t?8:12:t?10:15,backgroundColor:t?"transparent":u?e.colorPrimaryBg:"transparent",borderRadius:t?0:4,marginBottom:t?0:4},children:o.jsx("div",{style:{width:"100%"},children:o.jsxs(h,{align:"start",style:{width:"100%"},size:t?6:8,children:[o.jsx(I,{title:$,children:o.jsx("span",{style:{color:c.color,fontSize:t?14:16},children:c.icon})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx(p,{style:{textDecoration:s.status==="completed"?"line-through":"none",color:s.status==="completed"?e.colorTextSecondary:e.colorText,fontWeight:u?500:400,fontSize:t?13:void 0},children:s.description}),o.jsx("div",{style:{marginTop:t?3:4},children:t?o.jsx(w,{block:!0,items:[o.jsx("span",{style:{color:c.color},children:$}),s.tool_calls_count!==void 0&&s.tool_calls_count>0?`${s.tool_calls_count} ${n("components.todoList.tools")}`:null,((z=s.depends_on)==null?void 0:z.length)>0?`${s.depends_on.length} ${n("components.todoList.dependencies")}`:null]}):o.jsxs(h,{size:t?6:8,wrap:!0,children:[o.jsx(f,{color:c.tagColor,children:$}),s.tool_calls_count!==void 0&&s.tool_calls_count>0&&o.jsxs(f,{icon:o.jsx(to,{}),color:"processing",children:[s.tool_calls_count," ",n("components.todoList.tools")]}),((B=s.depends_on)==null?void 0:B.length)>0&&o.jsx(I,{title:n("components.todoList.dependsOn",{deps:s.depends_on.join(", ")}),children:o.jsxs(f,{icon:o.jsx(no,{}),children:[s.depends_on.length," ",n("components.todoList.dependencies")]})})]})}),s.status==="completed"&&s.summary&&o.jsx(p,{type:"secondary",style:t?{display:"block",marginTop:4,fontSize:12,paddingLeft:e.paddingXS,borderLeft:`2px solid ${e.colorSuccessBorder}`,color:e.colorSuccess,lineHeight:1.45}:{display:"block",marginTop:6,fontSize:12,padding:"4px 8px",backgroundColor:e.colorSuccessBg,borderRadius:4,color:e.colorSuccess},children:s.summary}),s.notes&&o.jsx(p,{type:"secondary",style:t?{display:"block",marginTop:4,fontSize:12,paddingLeft:e.paddingXS,borderLeft:`2px solid ${e.colorBorderSecondary}`,lineHeight:1.45}:{display:"block",marginTop:6,fontSize:12,padding:"4px 8px",backgroundColor:e.colorFillQuaternary,borderRadius:4},children:s.notes})]})]})})})}})]});return t?o.jsxs("section",{"data-testid":"todo-list-panel",style:{width:"100%",minWidth:0,marginBottom:e.marginXS,overflow:"hidden",opacity:r&&!i?.9:1},children:[o.jsxs(ro,{align:"center",justify:"space-between",gap:e.marginXS,style:{padding:`${e.paddingXXS??2}px 0 ${e.paddingXS}px`,borderBottom:r?void 0:`1px solid ${m?e.colorPrimaryBorder:e.colorBorderSecondary}`},children:[o.jsx("div",{style:{flex:1,minWidth:0},children:_}),o.jsx("div",{style:{flex:"0 0 auto"},children:k})]}),b?o.jsx("div",{style:{padding:`0 0 ${e.paddingXS}px`},children:b}):null]}):o.jsx(lo,{size:"small",className:"lotus-settings-card",style:{marginBottom:16,borderRadius:8,boxShadow:m?`0 0 0 2px ${e.colorPrimaryBorder}`:"0 2px 8px rgba(0, 0, 0, 0.06)",opacity:r&&!i?.9:1},styles:{body:{padding:r?"12px 16px":16}},title:_,extra:k,children:b})};export{fo as TodoList,fo as default};
1
+ import{j as o}from"./vendor-markdown-DrYaLZhb.js";import{u as G,R as N,a as P}from"./vendor-i18n-Dm-c3D_C.js";import{u as y,I as w}from"./App-CiBjfJbZ.js";import{t as O,j as h,k as Q,l as J,n as v,o as f,B as U,p as F,q as I,u as V,v as Y,w as Z,x as oo,y as X,A as so,P as eo,z as E,D as to,E as no,F as ro,G as lo,H as io,I as ao}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-DBtTSFLf.js";import"./main-CvPZyRz3.js";const{Text:p}=J,co=a=>({pending:{icon:o.jsx(ao,{}),color:a.colorTextTertiary,textKey:"components.todoList.status.pending",tagColor:"default"},in_progress:{icon:o.jsx(v,{spin:!0}),color:a.colorPrimary,textKey:"components.todoList.status.inProgress",tagColor:"processing"},completed:{icon:o.jsx(F,{}),color:a.colorSuccess,textKey:"components.todoList.status.completed",tagColor:"success"},blocked:{icon:o.jsx(io,{}),color:a.colorError,textKey:"components.todoList.status.blocked",tagColor:"error"}}),fo=({sessionId:a,initialCollapsed:K=!0,compact:t=!1})=>{const{t:n}=G(),{token:e}=O.useToken(),A=N.useMemo(()=>co(e),[e]),g=y(s=>s.chats.find(c=>c.id===a)),j=(g==null?void 0:g.kind)==="child"&&(g.parentSessionId||g.rootSessionId)||a,l=y(s=>s.taskLists[j]),H=y(s=>s.activeItems[j]),x=y(s=>s.evaluationStates[j]),[r,R]=P.useState(K),[i,W]=P.useState(!1),m=(x==null?void 0:x.isEvaluating)||!1,S=(x==null?void 0:x.reasoning)||null,T=l?{session_id:l.session_id,title:l.title,items:l.items,progress:{completed:l.items.filter(s=>s.status==="completed").length,total:l.items.length,percentage:l.items.length>0?Math.round(l.items.filter(s=>s.status==="completed").length/l.items.length*100):0}}:null;if(!T)return null;const C=()=>{i||R(!r)},D=s=>{s.stopPropagation(),W(!i),i||R(!1)},{title:M,items:q,progress:d}=T,L=d.percentage===100,_=o.jsxs(h,{onClick:C,style:{cursor:"pointer",width:"100%"},size:t?6:8,children:[o.jsx(Q,{style:{color:e.colorPrimary}}),o.jsx(p,{strong:!0,style:{fontSize:t?14:15},children:M||n("components.todoList.title")}),m&&(t?o.jsx(w,{nowrap:!0,items:[o.jsxs(o.Fragment,{children:[o.jsx(v,{spin:!0,style:{color:e.colorPrimary,marginRight:4}}),n("components.todoList.evaluating")]})]}):o.jsx(f,{icon:o.jsx(v,{spin:!0}),color:"processing",children:n("components.todoList.evaluating")})),!r&&d.total>0&&o.jsx(U,{count:`${d.completed}/${d.total}`,style:{backgroundColor:L?e.colorSuccess:e.colorPrimary}})]}),k=o.jsxs(h,{size:t?6:8,children:[d.total>0&&r&&o.jsxs(p,{type:"secondary",style:{fontSize:t?12:13},children:[d.completed,"/",d.total,L&&o.jsx(F,{style:{color:e.colorSuccess,marginLeft:4}})]}),o.jsx(I,{title:n(i?"components.todoList.unpin":"components.todoList.pin"),children:o.jsx("span",{onClick:D,style:{cursor:"pointer",color:i?e.colorPrimary:e.colorTextSecondary,fontSize:t?14:16},children:i?o.jsx(V,{}):o.jsx(Y,{})})}),!i&&o.jsx("span",{onClick:C,style:{cursor:"pointer",color:e.colorTextSecondary,fontSize:12,transform:r?"rotate(-90deg)":void 0,transition:"transform 0.2s"},children:r?o.jsx(Z,{}):o.jsx(oo,{})})]}),b=r?null:o.jsxs(o.Fragment,{children:[S?t?o.jsxs(p,{type:"secondary",style:{display:"block",marginBottom:e.marginXS,fontSize:12,paddingLeft:e.paddingXS,borderLeft:`2px solid ${e.colorPrimaryBorder}`,lineHeight:1.45},children:[o.jsx(X,{style:{marginRight:6}}),S]}):o.jsx(so,{icon:o.jsx(X,{}),message:n("components.todoList.llmEvaluation"),description:S,type:"info",showIcon:!0,style:{marginBottom:16}}):null,d.total>0&&o.jsx("div",{style:{marginBottom:t?e.marginXS:16},children:o.jsx(eo,{percent:d.percentage,size:"small",status:L?"success":"active",format:s=>o.jsxs(p,{type:"secondary",children:[s,"%"]})})}),o.jsx(E,{size:"small",split:!1,dataSource:q,renderItem:s=>{var z,B;const c=A[s.status],u=H===s.id,$=n(c.textKey);return o.jsx(E.Item,{style:{padding:t?"6px 0":"12px 0",borderLeft:u?`3px solid ${e.colorPrimary}`:"3px solid transparent",paddingLeft:u?t?8:12:t?10:15,backgroundColor:t?"transparent":u?e.colorPrimaryBg:"transparent",borderRadius:t?0:4,marginBottom:t?0:4},children:o.jsx("div",{style:{width:"100%"},children:o.jsxs(h,{align:"start",style:{width:"100%"},size:t?6:8,children:[o.jsx(I,{title:$,children:o.jsx("span",{style:{color:c.color,fontSize:t?14:16},children:c.icon})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx(p,{style:{textDecoration:s.status==="completed"?"line-through":"none",color:s.status==="completed"?e.colorTextSecondary:e.colorText,fontWeight:u?500:400,fontSize:t?13:void 0},children:s.description}),o.jsx("div",{style:{marginTop:t?3:4},children:t?o.jsx(w,{block:!0,items:[o.jsx("span",{style:{color:c.color},children:$}),s.tool_calls_count!==void 0&&s.tool_calls_count>0?`${s.tool_calls_count} ${n("components.todoList.tools")}`:null,((z=s.depends_on)==null?void 0:z.length)>0?`${s.depends_on.length} ${n("components.todoList.dependencies")}`:null]}):o.jsxs(h,{size:t?6:8,wrap:!0,children:[o.jsx(f,{color:c.tagColor,children:$}),s.tool_calls_count!==void 0&&s.tool_calls_count>0&&o.jsxs(f,{icon:o.jsx(to,{}),color:"processing",children:[s.tool_calls_count," ",n("components.todoList.tools")]}),((B=s.depends_on)==null?void 0:B.length)>0&&o.jsx(I,{title:n("components.todoList.dependsOn",{deps:s.depends_on.join(", ")}),children:o.jsxs(f,{icon:o.jsx(no,{}),children:[s.depends_on.length," ",n("components.todoList.dependencies")]})})]})}),s.status==="completed"&&s.summary&&o.jsx(p,{type:"secondary",style:t?{display:"block",marginTop:4,fontSize:12,paddingLeft:e.paddingXS,borderLeft:`2px solid ${e.colorSuccessBorder}`,color:e.colorSuccess,lineHeight:1.45}:{display:"block",marginTop:6,fontSize:12,padding:"4px 8px",backgroundColor:e.colorSuccessBg,borderRadius:4,color:e.colorSuccess},children:s.summary}),s.notes&&o.jsx(p,{type:"secondary",style:t?{display:"block",marginTop:4,fontSize:12,paddingLeft:e.paddingXS,borderLeft:`2px solid ${e.colorBorderSecondary}`,lineHeight:1.45}:{display:"block",marginTop:6,fontSize:12,padding:"4px 8px",backgroundColor:e.colorFillQuaternary,borderRadius:4},children:s.notes})]})]})})})}})]});return t?o.jsxs("section",{"data-testid":"todo-list-panel",style:{width:"100%",minWidth:0,marginBottom:e.marginXS,overflow:"hidden",opacity:r&&!i?.9:1},children:[o.jsxs(ro,{align:"center",justify:"space-between",gap:e.marginXS,style:{padding:`${e.paddingXXS??2}px 0 ${e.paddingXS}px`,borderBottom:r?void 0:`1px solid ${m?e.colorPrimaryBorder:e.colorBorderSecondary}`},children:[o.jsx("div",{style:{flex:1,minWidth:0},children:_}),o.jsx("div",{style:{flex:"0 0 auto"},children:k})]}),b?o.jsx("div",{style:{padding:`0 0 ${e.paddingXS}px`},children:b}):null]}):o.jsx(lo,{size:"small",className:"lotus-settings-card",style:{marginBottom:16,borderRadius:8,boxShadow:m?`0 0 0 2px ${e.colorPrimaryBorder}`:"0 2px 8px rgba(0, 0, 0, 0.06)",opacity:r&&!i?.9:1},styles:{body:{padding:r?"12px 16px":16}},title:_,extra:k,children:b})};export{fo as TodoList,fo as default};
@@ -1 +1 @@
1
- import{j as a}from"./vendor-markdown-DrYaLZhb.js";import{t as $,w as v,x as B}from"./App-BAFyf064.js";import{a as l,u as E}from"./vendor-i18n-Dm-c3D_C.js";import{W as T,t as M,o as L,an as D,ao as K,ae as F,U as z}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-B_9yBBtL.js";import"./main-C1pyfoEz.js";const X=({visible:p,searchText:k,onSelect:j,onCancel:g,onAutoComplete:f})=>{const[o,i]=l.useState([]),[c,R]=l.useState([]),[d,u]=l.useState(0),[N,I]=l.useState(!1),S=l.useRef(null),h=l.useRef(null);l.useEffect(()=>{if(!p)return;const s=$.getInstance();(async()=>{I(!0);try{const r=await s.listCommands();v("[CommandSelector]","[CommandSelector] Fetched commands:",r),i(r),u(0)}catch(r){console.error("[CommandSelector] Failed to fetch commands:",r),i([])}finally{I(!1)}})()},[p]),l.useEffect(()=>{const s=o.filter(e=>{var x,y,b,C,w;const r=k.toLowerCase(),n=(e.displayName??"").toLowerCase();return e.name.toLowerCase().includes(r)||n.includes(r)||e.description.toLowerCase().includes(r)||e.type==="mcp"&&[(x=e.metadata)==null?void 0:x.serverId,(y=e.metadata)==null?void 0:y.serverName,(b=e.metadata)==null?void 0:b.originalName].filter(m=>typeof m=="string").some(m=>m.toLowerCase().includes(r))||(((C=e.category)==null?void 0:C.toLowerCase().includes(r))??!1)||(((w=e.tags)==null?void 0:w.some(m=>m.toLowerCase().includes(r)))??!1)});R(s),u(0)},[o,k]),l.useEffect(()=>{if(!h.current||!S.current)return;const s=S.current,e=h.current,r=s.getBoundingClientRect(),n=e.getBoundingClientRect();n.top<r.top?e.scrollIntoView({block:"start",behavior:"smooth"}):n.bottom>r.bottom&&e.scrollIntoView({block:"end",behavior:"smooth"})},[d,c]);const t=l.useCallback(async s=>{try{j({name:s.name,type:s.type,id:s.id})}catch(e){console.error(`[CommandSelector] Failed to select command '${s.name}':`,e)}},[j]);return l.useEffect(()=>{const s=e=>{if(p)switch(e.key){case"ArrowDown":case"n":if(e.key==="n"&&!e.ctrlKey)break;e.preventDefault(),e.stopPropagation(),u(r=>r<c.length-1?r+1:0);break;case"ArrowUp":case"p":if(e.key==="p"&&!e.ctrlKey)break;e.preventDefault(),e.stopPropagation(),u(r=>r>0?r-1:c.length-1);break;case"Enter":e.preventDefault(),e.stopPropagation(),c[d]&&t(c[d]);break;case" ":case"Tab":e.preventDefault(),e.stopPropagation(),c[d]&&f&&f(c[d].name);break;case"Escape":e.preventDefault(),e.stopPropagation(),g();break}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[p,c,d,g,f,t]),{containerRef:S,selectedItemRef:h,filteredCommands:c,selectedIndex:d,setSelectedIndex:u,isLoading:N,handleCommandSelect:t}},{useToken:P}=M,A={workflow:{color:"blue",icon:a.jsx(z,{}),labelKey:"chat.commandSelector.types.workflow"},skill:{color:"green",icon:a.jsx(F,{}),labelKey:"chat.commandSelector.types.skill"},mcp:{color:"purple",icon:a.jsx(K,{}),labelKey:"chat.commandSelector.types.mcp"},goal:{color:"gold",icon:a.jsx(D,{}),labelKey:"chat.commandSelector.types.goal"}},Q=({visible:p,onSelect:k,onCancel:j,searchText:g,onAutoComplete:f})=>{const{token:o}=P(),{t:i}=E(),{containerRef:c,selectedItemRef:R,filteredCommands:d,selectedIndex:u,setSelectedIndex:N,isLoading:I,handleCommandSelect:S}=X({visible:p,searchText:g,onSelect:k,onCancel:j,onAutoComplete:f});if(!p)return null;if(I)return a.jsxs("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary,padding:`${o.paddingSM}px ${o.paddingMD}px`,zIndex:1e3,marginBottom:o.marginXS,textAlign:"center"},children:[a.jsx(T,{size:"small"})," ",i("chat.commandSelector.loading")]});if(d.length===0)return a.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary,padding:`${o.paddingSM}px ${o.paddingMD}px`,zIndex:1e3,marginBottom:o.marginXS,textAlign:"center",color:o.colorTextSecondary},children:g?i("chat.commandSelector.emptyWithSearch",{search:g}):i("chat.commandSelector.empty")});const h=(t,s)=>{var b,C,w;const e=A[t.type],r=s===u,n=t.type==="mcp"?B(t.name):null,x=t.type==="mcp"?((b=t.metadata)==null?void 0:b.originalName)||(n==null?void 0:n.toolName)||t.displayName||t.name:null,y=t.type==="mcp"&&(((C=t.metadata)==null?void 0:C.serverName)||((w=t.metadata)==null?void 0:w.serverId)||(n==null?void 0:n.serverId))||null;return a.jsxs("div",{ref:r?R:null,className:`command-selector-item ${r?"selected":""}`,onClick:()=>S(t),onMouseEnter:()=>N(s),children:[a.jsxs("div",{className:"command-selector-item-header",children:[a.jsxs("div",{className:"command-selector-item-name",style:{color:o.colorPrimary},children:["/",t.type==="mcp"&&x?x:t.name]}),a.jsxs("div",{style:{display:"flex",gap:o.marginXS},children:[t.type==="mcp"&&y&&a.jsx(L,{color:"processing",children:y}),a.jsxs(L,{color:e.color,children:[e.icon," ",i(e.labelKey)]})]})]}),a.jsx("div",{className:"command-selector-item-description",style:{color:o.colorTextSecondary},children:t.description}),t.type==="mcp"&&y&&a.jsxs("div",{className:"command-selector-item-category",style:{color:o.colorTextTertiary},children:[i("common.server")," ",y]}),t.category&&a.jsxs("div",{className:"command-selector-item-category",style:{color:o.colorTextTertiary},children:[i("common.category")," ",t.category]}),t.tags&&t.tags.length>0&&a.jsx("div",{className:"command-selector-item-tags",children:t.tags.slice(0,3).map(m=>a.jsx(L,{children:m},m))})]},t.id)};return a.jsxs("div",{ref:c,className:"command-selector-container",style:{background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary},children:[a.jsx("div",{style:{padding:`${o.paddingXXS}px ${o.paddingSM}px`,borderBottom:`1px solid ${o.colorBorderSecondary}`,background:o.colorFillQuaternary,fontSize:o.fontSizeSM,color:o.colorTextTertiary},children:i("chat.commandSelector.navigationHint")}),d.map((t,s)=>h(t,s))]})};export{Q as default};
1
+ import{j as a}from"./vendor-markdown-DrYaLZhb.js";import{w as $,x as v,y as B}from"./App-CiBjfJbZ.js";import{a as l,u as E}from"./vendor-i18n-Dm-c3D_C.js";import{W as T,t as M,o as L,an as D,ao as K,ae as F,U as z}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-DBtTSFLf.js";import"./main-CvPZyRz3.js";const X=({visible:p,searchText:k,onSelect:j,onCancel:g,onAutoComplete:f})=>{const[o,i]=l.useState([]),[c,R]=l.useState([]),[d,u]=l.useState(0),[N,I]=l.useState(!1),S=l.useRef(null),h=l.useRef(null);l.useEffect(()=>{if(!p)return;const s=$.getInstance();(async()=>{I(!0);try{const r=await s.listCommands();v("[CommandSelector]","[CommandSelector] Fetched commands:",r),i(r),u(0)}catch(r){console.error("[CommandSelector] Failed to fetch commands:",r),i([])}finally{I(!1)}})()},[p]),l.useEffect(()=>{const s=o.filter(e=>{var x,y,b,C,w;const r=k.toLowerCase(),n=(e.displayName??"").toLowerCase();return e.name.toLowerCase().includes(r)||n.includes(r)||e.description.toLowerCase().includes(r)||e.type==="mcp"&&[(x=e.metadata)==null?void 0:x.serverId,(y=e.metadata)==null?void 0:y.serverName,(b=e.metadata)==null?void 0:b.originalName].filter(m=>typeof m=="string").some(m=>m.toLowerCase().includes(r))||(((C=e.category)==null?void 0:C.toLowerCase().includes(r))??!1)||(((w=e.tags)==null?void 0:w.some(m=>m.toLowerCase().includes(r)))??!1)});R(s),u(0)},[o,k]),l.useEffect(()=>{if(!h.current||!S.current)return;const s=S.current,e=h.current,r=s.getBoundingClientRect(),n=e.getBoundingClientRect();n.top<r.top?e.scrollIntoView({block:"start",behavior:"smooth"}):n.bottom>r.bottom&&e.scrollIntoView({block:"end",behavior:"smooth"})},[d,c]);const t=l.useCallback(async s=>{try{j({name:s.name,type:s.type,id:s.id})}catch(e){console.error(`[CommandSelector] Failed to select command '${s.name}':`,e)}},[j]);return l.useEffect(()=>{const s=e=>{if(p)switch(e.key){case"ArrowDown":case"n":if(e.key==="n"&&!e.ctrlKey)break;e.preventDefault(),e.stopPropagation(),u(r=>r<c.length-1?r+1:0);break;case"ArrowUp":case"p":if(e.key==="p"&&!e.ctrlKey)break;e.preventDefault(),e.stopPropagation(),u(r=>r>0?r-1:c.length-1);break;case"Enter":e.preventDefault(),e.stopPropagation(),c[d]&&t(c[d]);break;case" ":case"Tab":e.preventDefault(),e.stopPropagation(),c[d]&&f&&f(c[d].name);break;case"Escape":e.preventDefault(),e.stopPropagation(),g();break}};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[p,c,d,g,f,t]),{containerRef:S,selectedItemRef:h,filteredCommands:c,selectedIndex:d,setSelectedIndex:u,isLoading:N,handleCommandSelect:t}},{useToken:P}=M,A={workflow:{color:"blue",icon:a.jsx(z,{}),labelKey:"chat.commandSelector.types.workflow"},skill:{color:"green",icon:a.jsx(F,{}),labelKey:"chat.commandSelector.types.skill"},mcp:{color:"purple",icon:a.jsx(K,{}),labelKey:"chat.commandSelector.types.mcp"},goal:{color:"gold",icon:a.jsx(D,{}),labelKey:"chat.commandSelector.types.goal"}},Q=({visible:p,onSelect:k,onCancel:j,searchText:g,onAutoComplete:f})=>{const{token:o}=P(),{t:i}=E(),{containerRef:c,selectedItemRef:R,filteredCommands:d,selectedIndex:u,setSelectedIndex:N,isLoading:I,handleCommandSelect:S}=X({visible:p,searchText:g,onSelect:k,onCancel:j,onAutoComplete:f});if(!p)return null;if(I)return a.jsxs("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary,padding:`${o.paddingSM}px ${o.paddingMD}px`,zIndex:1e3,marginBottom:o.marginXS,textAlign:"center"},children:[a.jsx(T,{size:"small"})," ",i("chat.commandSelector.loading")]});if(d.length===0)return a.jsx("div",{style:{position:"absolute",bottom:"100%",left:0,right:0,background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary,padding:`${o.paddingSM}px ${o.paddingMD}px`,zIndex:1e3,marginBottom:o.marginXS,textAlign:"center",color:o.colorTextSecondary},children:g?i("chat.commandSelector.emptyWithSearch",{search:g}):i("chat.commandSelector.empty")});const h=(t,s)=>{var b,C,w;const e=A[t.type],r=s===u,n=t.type==="mcp"?B(t.name):null,x=t.type==="mcp"?((b=t.metadata)==null?void 0:b.originalName)||(n==null?void 0:n.toolName)||t.displayName||t.name:null,y=t.type==="mcp"&&(((C=t.metadata)==null?void 0:C.serverName)||((w=t.metadata)==null?void 0:w.serverId)||(n==null?void 0:n.serverId))||null;return a.jsxs("div",{ref:r?R:null,className:`command-selector-item ${r?"selected":""}`,onClick:()=>S(t),onMouseEnter:()=>N(s),children:[a.jsxs("div",{className:"command-selector-item-header",children:[a.jsxs("div",{className:"command-selector-item-name",style:{color:o.colorPrimary},children:["/",t.type==="mcp"&&x?x:t.name]}),a.jsxs("div",{style:{display:"flex",gap:o.marginXS},children:[t.type==="mcp"&&y&&a.jsx(L,{color:"processing",children:y}),a.jsxs(L,{color:e.color,children:[e.icon," ",i(e.labelKey)]})]})]}),a.jsx("div",{className:"command-selector-item-description",style:{color:o.colorTextSecondary},children:t.description}),t.type==="mcp"&&y&&a.jsxs("div",{className:"command-selector-item-category",style:{color:o.colorTextTertiary},children:[i("common.server")," ",y]}),t.category&&a.jsxs("div",{className:"command-selector-item-category",style:{color:o.colorTextTertiary},children:[i("common.category")," ",t.category]}),t.tags&&t.tags.length>0&&a.jsx("div",{className:"command-selector-item-tags",children:t.tags.slice(0,3).map(m=>a.jsx(L,{children:m},m))})]},t.id)};return a.jsxs("div",{ref:c,className:"command-selector-container",style:{background:o.colorBgContainer,border:`1px solid ${o.colorBorderSecondary}`,borderRadius:o.borderRadiusSM,boxShadow:o.boxShadowSecondary},children:[a.jsx("div",{style:{padding:`${o.paddingXXS}px ${o.paddingSM}px`,borderBottom:`1px solid ${o.colorBorderSecondary}`,background:o.colorFillQuaternary,fontSize:o.fontSizeSM,color:o.colorTextTertiary},children:i("chat.commandSelector.navigationHint")}),d.map((t,s)=>h(t,s))]})};export{Q as default};
@@ -0,0 +1,8 @@
1
+ import{j as l}from"./vendor-markdown-DrYaLZhb.js";import{R as ye,u as he,a as r}from"./vendor-i18n-Dm-c3D_C.js";import{u as b,b as ve,h as xe,j as _e,k as T,r as Ce,l as Ee,m as Se,s as qe,a as Y,n as L,C as A}from"./App-CiBjfJbZ.js";import{X as Re,l as we,N as Z,x as ke,af as be,ag as H,j as ee,$ as Te,t as je}from"./vendor-antd-CKNrd1kL.js";import"./vendor-mermaid-DBtTSFLf.js";import"./main-CvPZyRz3.js";const De="_questionCard_15meh_1",Ne="_questionHeader_15meh_8",Be="_headerLeft_15meh_27",Ie="_questionIcon_15meh_35",Pe="_questionText_15meh_40",Qe="_collapseBtn_15meh_52",Le="_questionBody_15meh_57",Ae="_optionsGroup_15meh_61",He="_optionItem_15meh_65",Fe="_customHint_15meh_81",Ge="_questionFooter_15meh_93",a={questionCard:De,questionHeader:Ne,headerLeft:Be,questionIcon:Ie,questionText:Pe,collapseBtn:Qe,questionBody:Le,optionsGroup:Ae,optionItem:He,customHint:Fe,questionFooter:Ge},{Text:j}=we,{useToken:ze}=je,Me=n=>{const f=(n||"").replace(/\\r\\n/g,`
2
+ `).replace(/\\n/g,`
3
+ `).replace(/\r\n?/g,`
4
+ `).trim();return f?f.includes(`
5
+ `)?f:f.replace(/\s+(?=\d+[).]\s)/g,`
6
+ `).replace(/\s+(?=[一二三四五六七八九十]+[、.]\s)/g,`
7
+ `).replace(/\s+(?=[-*•]\s)/g,`
8
+ `):""};const te=({sessionId:n,onResponseSubmitted:f,onQuestionAppeared:F})=>{const{t:v}=he(),{token:x}=ze(),{message:D}=Re.useApp(),[g,C]=r.useState(null),[N,G]=r.useState(!1),[ne,B]=r.useState(!0),[R,w]=r.useState(!1),u=r.useRef(0),p=r.useRef(0),m=r.useRef(null),c=r.useRef(null),_=r.useRef(0),k=r.useRef(F);k.current=F;const E=r.useCallback(()=>{_.current+=1,_.current},[n]),[I,oe]=r.useState(()=>typeof document>"u"?!0:!document.hidden),{markRespondStart:re,markSettleTimeout:z,applyExecutionStarted:se,setPendingQuestion:M,clearPendingQuestion:S,sessionModelRef:y,sessionReasoningEffort:le,inputReasoningEffort:ie,isCurrentSession:P}=b(ve(e=>{var s,i,d,J;const t=n?e.chats.find(ge=>ge.id===n)??null:null;return{markRespondStart:e.markRespondStart,markSettleTimeout:e.markSettleTimeout,applyExecutionStarted:e.applyExecutionStarted,setPendingQuestion:e.setPendingQuestion,clearPendingQuestion:e.clearPendingQuestion,sessionModelRef:((s=t==null?void 0:t.config)==null?void 0:s.model_ref)??null,sessionReasoningEffort:((i=t==null?void 0:t.config)==null?void 0:i.reasoningEffort)??null,inputReasoningEffort:n?((J=(d=e.inputStates)==null?void 0:d[n])==null?void 0:J.reasoningEffort)??null:null,isCurrentSession:e.currentSessionId===n}})),o=b(xe(n)),q=_e(y),O=T(e=>e.currentProvider),$=T(e=>e.providerConfig),V=T(e=>e.providerInstances),ue=r.useMemo(()=>Ce($,q,(y==null?void 0:y.provider)??O,V),[q,y==null?void 0:y.provider,$,O,V]),ae=r.useMemo(()=>n?Ee(n):void 0,[n]),ce=Se({sessionEffort:le,inputEffort:ie,persistedEffort:ae,providerDefault:ue}),h=r.useCallback(()=>{var t,s;const e=(t=b.getState().executionBySession)==null?void 0:t[n];return e?{phase:e.phase,generation:e.generation,backendRunId:e.backendRunId??null,backendIsRunning:e.backend.isRunning,hasPendingQuestion:e.interaction.pendingQuestion!=null,pendingQuestionToolCallId:((s=e.interaction.pendingQuestion)==null?void 0:s.toolCallId)??null,tokenCount:e.stream.tokenCount,hasTokens:e.stream.hasTokens,activeReasons:e.activeReasons}:null},[n]),K=b(qe(n)),U=r.useCallback(async()=>{const e=_.current;try{const t=await Y.get(`respond/${n}/pending`);if(e!==_.current)return;if(t.has_pending_question){const s={question:t.question??"",options:t.options??[],allowCustom:t.allow_custom??!0,toolCallId:t.tool_call_id??null},i=L({sessionId:n,...s});if(c.current===i){u.current=0,p.current=0;return}c.current=null,M(n,s),u.current=0,p.current=0}else c.current=null,S(n),m.current=null,u.current+=1,u.current>=6?p.current=2:u.current>=2&&(p.current=1)}catch(t){if(e!==_.current)return;if(t instanceof Error&&t.message.includes("404")){c.current=null,S(n),m.current=null,u.current+=1;return}c.current=null,S(n),m.current=null,u.current+=1,u.current>=6?p.current=2:u.current>=2&&(p.current=1),console.error("Failed to fetch pending question:",t)}finally{if(e!==_.current)return;B(!1)}},[n,M,S]);r.useEffect(()=>{E(),u.current=0,p.current=0,m.current=null,c.current=null,B(!0),C(null),w(!1)},[n,E]),r.useEffect(()=>{if(typeof document>"u")return;const e=()=>{oe(!document.hidden)};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[]),r.useEffect(()=>{var e;if(o){const t=L({sessionId:n,question:o.question,options:o.options,allowCustom:o.allowCustom,toolCallId:o.toolCallId});m.current===t||(C(null),w(!1),(e=k.current)==null||e.call(k)),m.current=t,c.current!==null&&c.current!==t&&(c.current=null)}else m.current=null},[n,o,o==null?void 0:o.allowCustom,o==null?void 0:o.options,o==null?void 0:o.question,o==null?void 0:o.toolCallId]);const W=r.useCallback(()=>{if(o)return null;if(K)return P?I?5e3:15e3:null;if(!P||!I)return null;const e=p.current;return e===0?3e4:e===1?6e4:12e4},[o,K,P,I]);r.useEffect(()=>{if(o){B(!1);return}let e=!1,t=null;const s=async()=>{if(e||N||(await U(),e))return;const i=W();i!==null&&(t=setTimeout(s,i))};return s(),()=>{e=!0,t&&clearTimeout(t)}},[o,U,W,N]),r.useEffect(()=>{if(typeof window>"u")return;const e=t=>{var d;const i=((d=t.detail)==null?void 0:d.sessionId)??null;!i||i!==n||(h(),E(),C(null),m.current=null,u.current=0)};return window.addEventListener(A,e),()=>{window.removeEventListener(A,e)}},[n,E,h]);const de=r.useCallback(e=>{C(e)},[]),fe=async()=>{if(!g||g==="custom"){D.warning(v("components.questionDialog.selectOptionWarning"));return}G(!0),o==null||o.toolCallId,h(),E();const e=re(n,(o==null?void 0:o.toolCallId)??null);h(),await new Promise(t=>setTimeout(t,0));try{const t={};T.getState().isProviderModelRefEnabled()&&q&&(t.model_ref=q,t.provider=q.provider);const s=await Y.post(`respond/${n}`,{response:g,reasoning_effort:ce,...t});h(),D.success(v("components.questionDialog.responseSubmitted")),c.current=o?L({sessionId:n,question:o.question,options:o.options,allowCustom:o.allowCustom,toolCallId:o.toolCallId}):null,C(null),u.current=0,S(n),typeof window<"u"&&window.dispatchEvent(new CustomEvent(A,{detail:{sessionId:n}}));const i=s==null?void 0:s.auto_resume_status,d=s==null?void 0:s.run_id;h(),i==="started"||i==="already_running"?(se(n,d??"",e),h(),void 0):(i==="error"||!i)&&(console.error("[QuestionDialog] Failed to auto-resume agent execution"),z(n)),f==null||f()}catch(t){console.error("Failed to submit response:",t),D.error(t instanceof Error?t.message:v("components.questionDialog.submitFailed")),z(n)}finally{G(!1)}};if(ne||!o)return null;const{question:pe,options:Q,allowCustom:me}=o,X=Me(pe);return l.jsxs("div",{className:a.questionCard,style:{background:x.colorBgContainer,borderColor:x.colorBorderSecondary,border:`1px solid ${x.colorBorderSecondary}`},children:[l.jsxs("div",{className:a.questionHeader,"data-collapsed":R?"true":"false",onClick:()=>w(e=>!e),role:"button",tabIndex:0,onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&w(t=>!t)},children:[l.jsxs("span",{className:a.headerLeft,children:[l.jsx("span",{className:a.questionIcon,children:"🤔"}),l.jsx(j,{strong:!0,className:a.questionText,style:{color:x.colorPrimary,whiteSpace:"pre-wrap"},title:R?X:void 0,children:X})]}),l.jsx(Z,{type:"text",size:"small",icon:R?l.jsx(ke,{}):l.jsx(be,{}),className:a.collapseBtn,tabIndex:-1})]}),!R&&l.jsxs("div",{className:a.questionBody,children:[l.jsx(H.Group,{className:a.optionsGroup,value:g,onChange:e=>de(e.target.value),children:l.jsxs(ee,{direction:"vertical",size:4,style:{width:"100%"},children:[Q==null?void 0:Q.map((e,t)=>l.jsx(H,{value:e,className:a.optionItem,children:l.jsx(j,{style:{color:x.colorText},children:e})},t)),me&&l.jsx(H,{value:"custom",className:a.optionItem,children:l.jsxs(ee,{size:4,children:[l.jsx(Te,{}),l.jsx(j,{style:{color:x.colorText},children:v("components.questionDialog.otherTypeBelow")})]})})]})}),g==="custom"&&l.jsx("div",{className:a.customHint,children:l.jsx(j,{type:"secondary",style:{fontSize:12},children:v("components.questionDialog.customAnswerTip")})}),g&&g!=="custom"&&l.jsx("div",{className:a.questionFooter,children:l.jsx(Z,{type:"primary",size:"small",onClick:fe,loading:N,children:v("components.questionDialog.confirm")})})]})]})};te.displayName="QuestionDialog";const Oe=ye.memo(te);Oe.displayName="QuestionDialog";export{Oe as QuestionDialog,Oe as default};