@bkm016/basalt 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{chunk-mfb3dgs8.js → chunk-1c9nr9rs.js} +1 -1
- package/{chunk-z9p6s986.js → chunk-4hf0r9hv.js} +3 -3
- package/{chunk-p886jr17.js → chunk-6ae9810t.js} +2 -2
- package/{chunk-6hx9y86d.js → chunk-6exa9fp7.js} +1 -1
- package/{chunk-xk3t5ves.js → chunk-8jn0yax5.js} +132 -132
- package/{chunk-xq74x4gc.js → chunk-8r4baw9e.js} +1 -1
- package/{chunk-nysatg77.js → chunk-9ymm1gge.js} +167 -156
- package/{chunk-qjnx4fsn.js → chunk-b350b01x.js} +3 -3
- package/{chunk-59hg9a84.js → chunk-bv96b8q7.js} +1 -1
- package/{chunk-343jsm46.js → chunk-e8x8zwkg.js} +1 -1
- package/{chunk-k38jaz6c.js → chunk-ehnc8g6v.js} +2 -2
- package/{chunk-kcn05erf.js → chunk-fzftb4n2.js} +3 -3
- package/{chunk-0rasqm8y.js → chunk-nrdszs0g.js} +2 -2
- package/{chunk-qs161f2q.js → chunk-p78wde92.js} +1 -1
- package/{chunk-39mh7h58.js → chunk-pna1wh02.js} +1 -1
- package/{chunk-edcf97ka.js → chunk-q6tgpaf3.js} +1 -1
- package/{chunk-qe76naq9.js → chunk-rqn67tm8.js} +1 -1
- package/{chunk-en7z6ne5.js → chunk-v9ttcf6r.js} +1 -1
- package/{chunk-9v3b7jjv.js → chunk-vv9csar7.js} +1 -1
- package/{chunk-81x8r8w4.js → chunk-xba6fr5v.js} +1 -1
- package/{chunk-03wzwnn6.js → chunk-ypxs8djn.js} +1 -1
- package/compiled.js +4 -4
- package/package.json +1 -1
- package/ui-test-worker.js +2 -2
- package/web/{chunk-kpmd893m.js → chunk-0qnetvsc.js} +4 -4
- package/web/{chunk-mvm68qtt.js → chunk-0zb330w3.js} +4 -4
- package/web/{chunk-78m018ya.js → chunk-0zyekjym.js} +1 -1
- package/web/chunk-11byy7vm.js +1 -0
- package/web/chunk-160x5pv7.js +1 -0
- package/web/{chunk-ysw5fs45.js → chunk-19g09ekr.js} +5 -5
- package/web/chunk-1gzprnyd.js +1 -0
- package/web/{chunk-7wzszsf5.js → chunk-1hx4xtdk.js} +2 -2
- package/web/{chunk-wspk8qbg.js → chunk-1je4p601.js} +4 -4
- package/web/{chunk-3haw3wcw.js → chunk-1np2aamb.js} +3 -3
- package/web/{chunk-qftcdcps.js → chunk-1rjtqf8h.js} +2 -2
- package/web/{chunk-54mgncq3.js → chunk-23258z1r.js} +1 -1
- package/web/{chunk-y3tb6410.js → chunk-27592nd8.js} +3 -3
- package/web/chunk-27tchdxd.js +2 -0
- package/web/{chunk-7hpqrfgg.js → chunk-2hqmdqn3.js} +1 -1
- package/web/chunk-2q79n966.js +2 -0
- package/web/{chunk-nfpff7yf.js → chunk-2ws74tfa.js} +10 -10
- package/web/{chunk-9vr6hpmk.js → chunk-2z8epr8f.js} +7 -7
- package/web/{chunk-k4qrqmdk.js → chunk-36e78034.js} +2 -2
- package/web/{chunk-vpegzgzb.js → chunk-3gj2t10x.js} +8 -8
- package/web/{chunk-2gsf89vs.js → chunk-444xfger.js} +4 -4
- package/web/{chunk-988e9wx6.js → chunk-4k62e61g.js} +5 -5
- package/web/{chunk-8sr9w61v.js → chunk-4z6wma3s.js} +2 -2
- package/web/{chunk-qcdej581.js → chunk-5sss3r97.js} +1 -1
- package/web/chunk-5wkqqa59.js +1 -0
- package/web/{chunk-s2ps0ct5.js → chunk-5yczs6sb.js} +1 -1
- package/web/chunk-5yn7mwvt.js +1 -0
- package/web/{chunk-mv7jgmnb.js → chunk-6ty9vw27.js} +3 -3
- package/web/chunk-705tkt2r.js +1 -0
- package/web/{chunk-j6wcszxq.js → chunk-753qp8sa.js} +2 -2
- package/web/{chunk-3rxhs9qm.js → chunk-75kzvpf3.js} +8 -8
- package/web/{chunk-hdtvrh0f.js → chunk-75meb0dh.js} +2 -2
- package/web/{chunk-y6mcxfm0.js → chunk-76e3npmd.js} +1 -1
- package/web/chunk-7p04dn0k.js +1 -0
- package/web/chunk-7rb3v8gy.js +1 -0
- package/web/{chunk-797bh7z6.js → chunk-7yz88k97.js} +3 -3
- package/web/{chunk-p79c7aak.js → chunk-85d7jkp0.js} +1 -1
- package/web/chunk-90kgn35s.js +1 -0
- package/web/chunk-931y1g0h.js +1 -0
- package/web/chunk-bcp6na49.js +1145 -0
- package/web/chunk-bz1q7qdd.js +8 -0
- package/web/chunk-c0evk1xy.js +1 -0
- package/web/{chunk-ahn2frbt.js → chunk-c0hdp2zj.js} +1 -1
- package/web/{chunk-25sn840r.js → chunk-c1z290wm.js} +2 -2
- package/web/{chunk-vg346gxc.js → chunk-cge0cjfm.js} +1 -1
- package/web/{chunk-ffywf5w5.js → chunk-chh8bg2h.js} +11 -11
- package/web/{chunk-7zfqppsx.js → chunk-ctmxm4qd.js} +2 -2
- package/web/{chunk-hbwxtbq3.js → chunk-e229cr90.js} +1 -1
- package/web/{chunk-xhqvzmfj.js → chunk-e9mmkrc3.js} +5 -5
- package/web/{chunk-s70aj1v5.js → chunk-ef03t1mb.js} +5 -5
- package/web/{chunk-783s8jds.js → chunk-f8nnrk6y.js} +4 -4
- package/web/{chunk-8ttp8fh3.js → chunk-fcrswzgm.js} +3 -3
- package/web/{chunk-w5q7978e.js → chunk-ffn1a0zw.js} +1 -1
- package/web/chunk-fw4fa7j6.js +1 -0
- package/web/chunk-fx8hheqz.js +1 -0
- package/web/{chunk-vxm7n7w6.js → chunk-g8wy9sa6.js} +11 -11
- package/web/{chunk-pafw34vg.js → chunk-gaf9brzv.js} +2 -2
- package/web/{chunk-npw1s1h2.js → chunk-gj16e7z0.js} +1 -1
- package/web/{chunk-tjd8qp87.js → chunk-gjchc4kg.js} +1 -1
- package/web/chunk-h1y8y203.js +1 -0
- package/web/{chunk-sgkevxdf.js → chunk-h6vy008x.js} +1 -1
- package/web/{chunk-zsat72qd.js → chunk-h8mhnze5.js} +55 -55
- package/web/{chunk-7kywe73f.js → chunk-hhnhgthx.js} +2 -2
- package/web/{chunk-jzge034r.js → chunk-j27mtdr2.js} +1 -1
- package/web/chunk-jys02310.js +1 -0
- package/web/chunk-kew13yzg.js +1 -0
- package/web/{chunk-zx3h7v72.js → chunk-kx5r8nf2.js} +1 -1
- package/web/{chunk-d3hyf9yd.js → chunk-m7c0xk69.js} +1 -1
- package/web/{chunk-59g6rrew.js → chunk-madrcnm1.js} +2 -2
- package/web/{chunk-vwv6pqy7.js → chunk-mcm3t5wr.js} +1 -1
- package/web/{chunk-mn2wv9ye.js → chunk-mrnx4f74.js} +2 -2
- package/web/chunk-mtdsrtc5.js +1 -0
- package/web/{chunk-aknsydan.js → chunk-mv5axm2y.js} +4 -4
- package/web/{chunk-ya696bfe.js → chunk-n3f5a91k.js} +1 -1
- package/web/{chunk-dwtatme7.js → chunk-n3spc397.js} +1 -1
- package/web/{chunk-feanedhx.js → chunk-nhc280n0.js} +1 -1
- package/web/chunk-nx1bcekh.js +2 -0
- package/web/{chunk-wfgrdabk.js → chunk-p0jghn6b.js} +1 -1
- package/web/chunk-p8t7s4z4.js +1 -0
- package/web/chunk-pgh1cx6w.js +1 -0
- package/web/{chunk-g3szt4c4.js → chunk-ps489yjy.js} +1 -1
- package/web/{chunk-kk5rw81s.js → chunk-qbhv18t0.js} +2 -2
- package/web/{chunk-c7fqrs8j.js → chunk-qgzn0ha5.js} +1 -1
- package/web/{chunk-faskbfjf.js → chunk-qtwxq6hj.js} +3 -3
- package/web/chunk-qwp3dhmf.js +1 -0
- package/web/{chunk-bahccwb9.js → chunk-qwwqdmhv.js} +1 -1
- package/web/{chunk-9h0f3gar.js → chunk-rjh54ygb.js} +5 -5
- package/web/chunk-ryh8jdzy.js +1 -0
- package/web/chunk-s3t8dkkz.js +1 -0
- package/web/chunk-sk1w7f7h.js +1 -0
- package/web/chunk-smkrxjm5.js +1 -0
- package/web/{chunk-s45g7fp6.js → chunk-sv5ph7fa.js} +1 -1
- package/web/{chunk-2gvz70wr.js → chunk-t89tfrpj.js} +8 -8
- package/web/{chunk-qv1w36ja.js → chunk-t9pg7qf8.js} +2 -2
- package/web/{chunk-xf1hnpme.js → chunk-t9twxmsg.js} +1 -1
- package/web/{chunk-ptpkv0te.js → chunk-tfdchqn4.js} +1 -1
- package/web/{chunk-p4pqtybm.js → chunk-tfsrk2rc.js} +24 -24
- package/web/{chunk-we4mhfmq.js → chunk-tvvggvjt.js} +8 -8
- package/web/chunk-ty87gdvr.js +1 -0
- package/web/{chunk-ppa21760.js → chunk-v16s0x7c.js} +1 -1
- package/web/{chunk-zpzvz973.js → chunk-vb2z2azk.js} +10 -10
- package/web/{chunk-snaepr87.js → chunk-vcnsvj49.js} +9 -9
- package/web/{chunk-2c7kxr4v.js → chunk-vgyp8wa2.js} +2 -2
- package/web/chunk-vh8pkcem.css +1 -0
- package/web/{chunk-17wwzrp4.js → chunk-vjnvfb8z.js} +1 -1
- package/web/{chunk-32dh0hft.js → chunk-vphzndz8.js} +1 -1
- package/web/{chunk-r8p741qj.js → chunk-w60dxtyz.js} +1 -1
- package/web/{chunk-1zwc09e8.js → chunk-wcj3bxdf.js} +2 -2
- package/web/{chunk-ex8rmqn1.js → chunk-wgmwgaw4.js} +5 -5
- package/web/{chunk-51b8n5e1.js → chunk-wvt76598.js} +1 -1
- package/web/chunk-y0mef85j.js +1 -0
- package/web/{chunk-410qdvmv.js → chunk-y2ykn1gm.js} +1 -1
- package/web/{chunk-jdx7qp2w.js → chunk-ybqt106a.js} +2 -2
- package/web/{chunk-wkhj4hsw.js → chunk-ym9qfsjs.js} +4 -4
- package/web/{chunk-fx3d48e6.js → chunk-ypdptddq.js} +1 -1
- package/web/{chunk-tdzh6nsz.js → chunk-z08c63ph.js} +2 -2
- package/web/{chunk-k9fyqrhp.js → chunk-z2hvvkf5.js} +2 -2
- package/web/chunk-z6x74qfh.js +1 -0
- package/web/{chunk-zkq1xknc.js → chunk-z86pjpqp.js} +1 -1
- package/web/{chunk-rjakb64x.js → chunk-zh0vjc6g.js} +1 -1
- package/web/chunk-zns9wmab.js +1 -0
- package/web/index.html +1 -1
- package/web/sw.js +17 -1
- package/web/chunk-15g9pnzy.js +0 -1
- package/web/chunk-19tkjg9w.js +0 -1
- package/web/chunk-26sp6jre.js +0 -1
- package/web/chunk-2s3my1jn.js +0 -1
- package/web/chunk-4qehf2xx.js +0 -2
- package/web/chunk-6481wt3t.js +0 -1
- package/web/chunk-6ehecat3.js +0 -1
- package/web/chunk-6m8hq6ph.js +0 -1
- package/web/chunk-73941p08.js +0 -1
- package/web/chunk-8zg89764.js +0 -1
- package/web/chunk-9vrp249f.js +0 -2
- package/web/chunk-dcegr80c.js +0 -1
- package/web/chunk-g7bcntpm.js +0 -1
- package/web/chunk-gr1tjqbd.js +0 -1
- package/web/chunk-j031r08w.js +0 -1
- package/web/chunk-jge7nn3s.js +0 -1
- package/web/chunk-jy8zat04.js +0 -1
- package/web/chunk-k8s7kye3.js +0 -1
- package/web/chunk-k9zn1n6d.js +0 -1
- package/web/chunk-kg3tksv7.js +0 -1
- package/web/chunk-md9j949p.js +0 -1
- package/web/chunk-nk7jkpam.js +0 -1
- package/web/chunk-nmvt1rn3.js +0 -1
- package/web/chunk-npyrdsf8.css +0 -1
- package/web/chunk-nzzxv84v.js +0 -8
- package/web/chunk-rcexbkjj.js +0 -1
- package/web/chunk-say8bvkc.js +0 -1
- package/web/chunk-sjffrcq9.js +0 -1
- package/web/chunk-tncc9e57.js +0 -1
- package/web/chunk-ty2rmwda.js +0 -1142
- package/web/chunk-v22hp18w.js +0 -1
- package/web/chunk-ve9dz857.js +0 -2
- package/web/chunk-xq70hgre.js +0 -1
- package/web/chunk-zkv025s5.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{H}from"./chunk-
|
|
2
|
-
`+r);let o=qt(),p=Gt(),b=o.nodeRadius*1.6,X=u.db,m=X.getWardleyData(),tt=X.getDiagramTitle(),Y=m.size?.width??o.width,M=m.size?.height??o.height,Z=V(i);Z.selectAll("*").remove(),F(Z,M,Y,o.useMaxWidth),Z.attr("viewBox",`0 0 ${Y} ${M}`);let z=Z.append("g").attr("class","wardley-map"),nt=Z.append("defs");nt.append("marker").attr("id",`arrow-${i}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",p.evolutionStroke).attr("stroke","none"),nt.append("marker").attr("id",`link-arrow-end-${i}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",p.linkStroke).attr("stroke","none"),nt.append("marker").attr("id",`link-arrow-start-${i}`).attr("viewBox","0 0 10 10").attr("refX",1).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z").attr("fill",p.linkStroke).attr("stroke","none"),z.append("rect").attr("class","wardley-background").attr("width",Y).attr("height",M).attr("fill",p.backgroundColor);let U=Y-o.padding*2,K=M-o.padding*2;if(tt)z.append("text").attr("class","wardley-title").attr("x",Y/2).attr("y",o.padding/2).attr("fill",p.axisTextColor).attr("font-size",o.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(tt);let O=t((e)=>o.padding+e/100*U,"projectX"),D=t((e)=>M-o.padding-e/100*K,"projectY"),et=z.append("g").attr("class","wardley-axes");et.append("line").attr("x1",o.padding).attr("x2",Y-o.padding).attr("y1",M-o.padding).attr("y2",M-o.padding).attr("stroke",p.axisColor).attr("stroke-width",1),et.append("line").attr("x1",o.padding).attr("x2",o.padding).attr("y1",o.padding).attr("y2",M-o.padding).attr("stroke",p.axisColor).attr("stroke-width",1);let Lt=m.axes.xLabel??"Evolution",Tt=m.axes.yLabel??"Visibility";et.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",o.padding+U/2).attr("y",M-o.padding/4).attr("fill",p.axisTextColor).attr("font-size",o.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(Lt),et.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",o.padding/3).attr("y",o.padding+K/2).attr("fill",p.axisTextColor).attr("font-size",o.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${o.padding/3} ${o.padding+K/2})`).text(Tt);let Q=m.axes.stages&&m.axes.stages.length>0?m.axes.stages:Dt;if(Q.length>0){let e=z.append("g").attr("class","wardley-stages"),d=m.axes.stageBoundaries,s=[];if(d&&d.length===Q.length){let c=0;d.forEach((f)=>{s.push({start:c,end:f}),c=f})}else{let c=1/Q.length;Q.forEach((f,g)=>{s.push({start:g*c,end:(g+1)*c})})}Q.forEach((c,f)=>{let g=s[f],w=o.padding+g.start*U,y=o.padding+g.end*U,k=(w+y)/2;if(f>0)e.append("line").attr("x1",w).attr("x2",w).attr("y1",o.padding).attr("y2",M-o.padding).attr("stroke","#000").attr("stroke-width",1).attr("stroke-dasharray","5 5").attr("opacity",0.8);e.append("text").attr("class","wardley-stage-label").attr("x",k).attr("y",M-o.padding/1.5).attr("fill",p.axisTextColor).attr("font-size",o.axisFontSize-2).attr("text-anchor","middle").text(c)})}if(o.showGrid){let e=z.append("g").attr("class","wardley-grid");for(let d=1;d<4;d++){let s=d/4,c=o.padding+U*s;e.append("line").attr("x1",c).attr("x2",c).attr("y1",o.padding).attr("y2",M-o.padding).attr("stroke",p.gridColor).attr("stroke-dasharray","2 6"),e.append("line").attr("x1",o.padding).attr("x2",Y-o.padding).attr("y1",M-o.padding-K*s).attr("y2",M-o.padding-K*s).attr("stroke",p.gridColor).attr("stroke-dasharray","2 6")}}let h=new Map;if(m.nodes.forEach((e)=>{h.set(e.id,{x:O(e.x),y:D(e.y),node:e})}),m.pipelines.length>0){let e=z.append("g").attr("class","wardley-pipelines"),d=z.append("g").attr("class","wardley-pipeline-links");m.pipelines.forEach((s)=>{if(s.componentIds.length===0)return;let c=s.componentIds.map((y)=>({id:y,pos:h.get(y),node:m.nodes.find((k)=>k.id===y)})).filter((y)=>y.pos&&y.node).sort((y,k)=>y.node.x-k.node.x);for(let y=0;y<c.length-1;y++){let k=c[y],v=c[y+1];d.append("line").attr("class","wardley-pipeline-evolution-link").attr("x1",k.pos.x).attr("y1",k.pos.y).attr("x2",v.pos.x).attr("y2",v.pos.y).attr("stroke",p.linkStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4")}let f=1/0,g=-1/0,w=0;if(s.componentIds.forEach((y)=>{let k=h.get(y);if(k)f=Math.min(f,k.x),g=Math.max(g,k.x),w=k.y}),f!==1/0&&g!==-1/0){let k=o.nodeRadius*4,v=w-k/2,W=h.get(s.nodeId);if(W){let B=(f+g)/2;W.x=B,W.y=v-b/6}e.append("rect").attr("class","wardley-pipeline-box").attr("x",f-15).attr("y",v).attr("width",g-f+30).attr("height",k).attr("fill","none").attr("stroke",p.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}})}let dt=z.append("g").attr("class","wardley-links"),lt=new Map;m.pipelines.forEach((e)=>{lt.set(e.nodeId,new Set(e.componentIds))});let ct=m.links.filter((e)=>{if(!h.has(e.source)||!h.has(e.target))return!1;if(lt.get(e.target)?.has(e.source))return!1;return!0});dt.selectAll("line").data(ct).enter().append("line").attr("class",(e)=>`wardley-link${e.dashed?" wardley-link--dashed":""}`).attr("x1",(e)=>{let d=h.get(e.source),s=h.get(e.target),f=m.nodes.find((k)=>k.id===e.source).isPipelineParent?b/Math.sqrt(2):o.nodeRadius,g=s.x-d.x,w=s.y-d.y,y=Math.sqrt(g*g+w*w);return d.x+g/y*f}).attr("y1",(e)=>{let d=h.get(e.source),s=h.get(e.target),f=m.nodes.find((k)=>k.id===e.source).isPipelineParent?b/Math.sqrt(2):o.nodeRadius,g=s.x-d.x,w=s.y-d.y,y=Math.sqrt(g*g+w*w);return d.y+w/y*f}).attr("x2",(e)=>{let d=h.get(e.source),s=h.get(e.target),f=m.nodes.find((k)=>k.id===e.target).isPipelineParent?b/Math.sqrt(2):o.nodeRadius,g=d.x-s.x,w=d.y-s.y,y=Math.sqrt(g*g+w*w);return s.x+g/y*f}).attr("y2",(e)=>{let d=h.get(e.source),s=h.get(e.target),f=m.nodes.find((k)=>k.id===e.target).isPipelineParent?b/Math.sqrt(2):o.nodeRadius,g=d.x-s.x,w=d.y-s.y,y=Math.sqrt(g*g+w*w);return s.y+w/y*f}).attr("stroke",p.linkStroke).attr("stroke-width",1).attr("stroke-dasharray",(e)=>e.dashed?"6 6":null).attr("marker-end",(e)=>{if(e.flow==="forward"||e.flow==="bidirectional")return`url(#link-arrow-end-${i})`;return null}).attr("marker-start",(e)=>{if(e.flow==="backward"||e.flow==="bidirectional")return`url(#link-arrow-start-${i})`;return null}),dt.selectAll("text").data(ct.filter((e)=>e.label)).enter().append("text").attr("class","wardley-link-label").attr("x",(e)=>{let d=h.get(e.source),s=h.get(e.target),c=(d.x+s.x)/2,f=s.y-d.y,g=s.x-d.x,w=Math.sqrt(g*g+f*f),y=8,k=f/w;return c+k*8}).attr("y",(e)=>{let d=h.get(e.source),s=h.get(e.target),c=(d.y+s.y)/2,f=s.x-d.x,g=s.y-d.y,w=Math.sqrt(f*f+g*g),y=8,k=-f/w;return c+k*8}).attr("fill",p.axisTextColor).attr("font-size",o.labelFontSize).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("transform",(e)=>{let d=h.get(e.source),s=h.get(e.target),c=(d.x+s.x)/2,f=(d.y+s.y)/2,g=s.x-d.x,w=s.y-d.y,y=Math.sqrt(g*g+w*w),k=8,v=w/y,W=-g/y,B=c+v*8,at=f+W*8,_=Math.atan2(w,g)*180/Math.PI;if(_>90||_<-90)_+=180;return`rotate(${_} ${B} ${at})`}).text((e)=>e.label);let Wt=z.append("g").attr("class","wardley-trends"),At=m.trends.map((e)=>{let d=h.get(e.nodeId);if(!d)return null;let s=O(e.targetX),c=D(e.targetY),f=s-d.x,g=c-d.y,w=Math.sqrt(f*f+g*g),y=o.nodeRadius+2,k=w>y?s-f/w*y:s,v=w>y?c-g/w*y:c;return{origin:d,targetX:s,targetY:c,adjustedX2:k,adjustedY2:v}}).filter((e)=>e!==null);Wt.selectAll("line").data(At).enter().append("line").attr("class","wardley-trend").attr("x1",(e)=>e.origin.x).attr("y1",(e)=>e.origin.y).attr("x2",(e)=>e.adjustedX2).attr("y2",(e)=>e.adjustedY2).attr("stroke",p.evolutionStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4").attr("marker-end",`url(#arrow-${i})`);let I=z.append("g").attr("class","wardley-nodes").selectAll("g").data(m.nodes).enter().append("g").attr("class",(e)=>["wardley-node",e.className?`wardley-node--${e.className}`:""].filter(Boolean).join(" "));I.filter((e)=>e.sourceStrategy==="outsource").append("circle").attr("class","wardley-outsource-overlay").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius*2).attr("fill","#666").attr("stroke",p.componentStroke).attr("stroke-width",1),I.filter((e)=>e.sourceStrategy==="buy").append("circle").attr("class","wardley-buy-overlay").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius*2).attr("fill","#ccc").attr("stroke",p.componentStroke).attr("stroke-width",1),I.filter((e)=>e.sourceStrategy==="build").append("circle").attr("class","wardley-build-overlay").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius*2).attr("fill","#eee").attr("stroke","#000").attr("stroke-width",1);let G=I.filter((e)=>e.sourceStrategy==="market");G.append("circle").attr("class","wardley-market-overlay").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius*2).attr("fill","white").attr("stroke",p.componentStroke).attr("stroke-width",1),I.filter((e)=>!e.isPipelineParent&&e.sourceStrategy!=="market"&&e.className!=="anchor").append("circle").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius).attr("fill",p.componentFill).attr("stroke",p.componentStroke).attr("stroke-width",1);let st=o.nodeRadius*0.7,N=o.nodeRadius*1.2;if(G.append("line").attr("class","wardley-market-line").attr("x1",(e)=>h.get(e.id).x).attr("y1",(e)=>h.get(e.id).y-N).attr("x2",(e)=>h.get(e.id).x-N*Math.cos(Math.PI/6)).attr("y2",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("stroke",p.componentStroke).attr("stroke-width",1),G.append("line").attr("class","wardley-market-line").attr("x1",(e)=>h.get(e.id).x-N*Math.cos(Math.PI/6)).attr("y1",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("x2",(e)=>h.get(e.id).x+N*Math.cos(Math.PI/6)).attr("y2",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("stroke",p.componentStroke).attr("stroke-width",1),G.append("line").attr("class","wardley-market-line").attr("x1",(e)=>h.get(e.id).x+N*Math.cos(Math.PI/6)).attr("y1",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("x2",(e)=>h.get(e.id).x).attr("y2",(e)=>h.get(e.id).y-N).attr("stroke",p.componentStroke).attr("stroke-width",1),G.append("circle").attr("class","wardley-market-dot").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y-N).attr("r",st).attr("fill","white").attr("stroke",p.componentStroke).attr("stroke-width",2),G.append("circle").attr("class","wardley-market-dot").attr("cx",(e)=>h.get(e.id).x-N*Math.cos(Math.PI/6)).attr("cy",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("r",st).attr("fill","white").attr("stroke",p.componentStroke).attr("stroke-width",2),G.append("circle").attr("class","wardley-market-dot").attr("cx",(e)=>h.get(e.id).x+N*Math.cos(Math.PI/6)).attr("cy",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("r",st).attr("fill","white").attr("stroke",p.componentStroke).attr("stroke-width",2),I.filter((e)=>e.isPipelineParent===!0).append("rect").attr("x",(e)=>h.get(e.id).x-b/2).attr("y",(e)=>h.get(e.id).y-b/2).attr("width",b).attr("height",b).attr("fill",p.componentFill).attr("stroke",p.componentStroke).attr("stroke-width",1),I.filter((e)=>e.inertia===!0).append("line").attr("class","wardley-inertia").attr("x1",(e)=>{let d=h.get(e.id),s=e.isPipelineParent?b/2+15:o.nodeRadius+15;if(e.sourceStrategy)s+=o.nodeRadius+10;return d.x+s}).attr("y1",(e)=>{let d=h.get(e.id),s=e.isPipelineParent?b:o.nodeRadius*2;return d.y-s/2}).attr("x2",(e)=>{let d=h.get(e.id),s=e.isPipelineParent?b/2+15:o.nodeRadius+15;if(e.sourceStrategy)s+=o.nodeRadius+10;return d.x+s}).attr("y2",(e)=>{let d=h.get(e.id),s=e.isPipelineParent?b:o.nodeRadius*2;return d.y+s/2}).attr("stroke",p.componentStroke).attr("stroke-width",6),I.append("text").attr("x",(e)=>{let d=h.get(e.id);if(e.className==="anchor")return e.labelOffsetX!==void 0?d.x+e.labelOffsetX:d.x;let s=o.nodeLabelOffset;if(e.sourceStrategy&&e.labelOffsetX===void 0)s+=10;let c=e.labelOffsetX??s;return d.x+c}).attr("y",(e)=>{let d=h.get(e.id);if(e.className==="anchor")return e.labelOffsetY!==void 0?d.y+e.labelOffsetY:d.y-3;let s=-o.nodeLabelOffset;if(e.sourceStrategy&&e.labelOffsetY===void 0)s-=10;let c=e.labelOffsetY??s;return d.y+c}).attr("class","wardley-node-label").attr("fill",(e)=>{if(e.className==="evolved")return p.evolutionStroke;if(e.className==="anchor")return"#000";return p.componentLabelColor}).attr("font-size",o.labelFontSize).attr("font-weight",(e)=>e.className==="anchor"?"bold":"normal").attr("text-anchor",(e)=>e.className==="anchor"?"middle":"start").attr("dominant-baseline",(e)=>e.className==="anchor"?"middle":"auto").text((e)=>e.label),m.annotations.length>0){let e=z.append("g").attr("class","wardley-annotations");if(m.annotations.forEach((d)=>{let s=d.coordinates.map((c)=>({x:O(c.x),y:D(c.y)}));if(s.length>1)for(let c=0;c<s.length-1;c++)e.append("line").attr("class","wardley-annotation-line").attr("x1",s[c].x).attr("y1",s[c].y).attr("x2",s[c+1].x).attr("y2",s[c+1].y).attr("stroke",p.axisColor).attr("stroke-width",1.5).attr("stroke-dasharray","4 4");s.forEach((c)=>{let f=e.append("g").attr("class","wardley-annotation");f.append("circle").attr("cx",c.x).attr("cy",c.y).attr("r",10).attr("fill","white").attr("stroke",p.axisColor).attr("stroke-width",1.5),f.append("text").attr("x",c.x).attr("y",c.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",10).attr("fill",p.axisTextColor).attr("font-weight","bold").text(d.number)})}),m.annotationsBox){let d=O(m.annotationsBox.x),s=D(m.annotationsBox.y),c=10,f=16,g=11,w=e.append("g").attr("class","wardley-annotations-box"),y=[...m.annotations].filter((v)=>v.text).sort((v,W)=>v.number-W.number),k=[];if(y.forEach((v,W)=>{let B=w.append("text").attr("x",d+c).attr("y",s+c+(W+1)*f).attr("font-size",g).attr("fill",p.axisTextColor).attr("text-anchor","start").attr("dominant-baseline","middle").text(`${v.number}. ${v.text}`);k.push(B)}),k.length>0){let v=0,W=0;k.forEach((it)=>{let rt=it.node(),Yt=rt.getComputedTextLength();v=Math.max(v,Yt);let It=rt.getBBox();W=Math.max(W,It.height)});let B=v+c*2+105,at=y.length*f+c*2+W/2,_=o.padding,Xt=Y-o.padding-B,Et=o.padding,Ht=M-o.padding-at;d=Math.max(_,Math.min(d,Xt)),s=Math.max(Et,Math.min(s,Ht)),k.forEach((it,rt)=>{it.attr("x",d+c).attr("y",s+c+(rt+1)*f)}),w.insert("rect","text").attr("x",d).attr("y",s).attr("width",B).attr("height",at).attr("fill","white").attr("stroke",p.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}}}if(m.notes.length>0){let e=z.append("g").attr("class","wardley-notes");m.notes.forEach((d)=>{let s=O(d.x),c=D(d.y);e.append("text").attr("x",s).attr("y",c).attr("text-anchor","start").attr("font-size",11).attr("fill",p.axisTextColor).attr("font-weight","bold").text(d.text)})}if(m.accelerators.length>0){let e=z.append("g").attr("class","wardley-accelerators");m.accelerators.forEach((d)=>{let s=O(d.x),c=D(d.y),f=60,g=30,w=20,y=`
|
|
1
|
+
import{H}from"./chunk-85d7jkp0.js";import{t,a,we,x,F,C,S,E,T,A,I,R,l,V,j}from"./chunk-h8mhnze5.js";import{J}from"./chunk-tfsrk2rc.js";var ot=t((r,i)=>{let n=r<=1?r*100:r;if(n<0||n>100)throw Error(`${i} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${r}`);return n},"toPercent"),q=t((r,i,n)=>({x:ot(i,`${n} evolution`),y:ot(r,`${n} visibility`)}),"toCoordinates"),pt=t((r)=>{if(!r)return;if(r==="+<>")return"bidirectional";if(r==="+<")return"backward";if(r==="+>")return"forward";return},"getFlowFromPort"),Bt=t((r)=>{if(!r?.startsWith("+"))return{};let n=/^\+'([^']*)'/.exec(r)?.[1];if(r.includes("<>"))return{flow:"bidirectional",label:n};if(r.includes("<"))return{flow:"backward",label:n};if(r.includes(">"))return{flow:"forward",label:n};return{label:n}},"extractFlowFromArrow"),Ft=t((r,i)=>{if(H(r,i),r.size)i.setSize(r.size.width,r.size.height);if(r.evolution){let n=r.evolution.stages.map((o)=>{if(o.secondName)return`${o.name.trim()} / ${o.secondName.trim()}`;return o.name.trim()}),u=r.evolution.stages.filter((o)=>o.boundary!==void 0).map((o)=>o.boundary);i.updateAxes({stages:n,stageBoundaries:u})}if(r.anchors.forEach((n)=>{let u=q(n.visibility,n.evolution,`Anchor "${n.name}"`);i.addNode(n.name,n.name,u.x,u.y,"anchor")}),r.components.forEach((n)=>{let u=q(n.visibility,n.evolution,`Component "${n.name}"`),o=n.label?(n.label.negX?-1:1)*n.label.offsetX:void 0,p=n.label?(n.label.negY?-1:1)*n.label.offsetY:void 0,b=n.decorator?.strategy;i.addNode(n.name,n.name,u.x,u.y,"component",o,p,n.inertia,b)}),r.notes.forEach((n)=>{let u=q(n.visibility,n.evolution,`Note "${n.text}"`);i.addNote(n.text,u.x,u.y)}),r.pipelines.forEach((n)=>{let u=i.getNode(n.parent);if(!u||typeof u.y!=="number")throw Error(`Pipeline "${n.parent}" must reference an existing component with coordinates.`);let o=u.y;i.startPipeline(n.parent),n.components.forEach((p)=>{let b=`${n.parent}_${p.name}`,W=p.label?(p.label.negX?-1:1)*p.label.offsetX:void 0,m=p.label?(p.label.negY?-1:1)*p.label.offsetY:void 0,tt=ot(p.evolution,`Pipeline component "${p.name}" evolution`);i.addNode(b,p.name,tt,o,"pipeline-component",W,m),i.addPipelineComponent(n.parent,b)})}),r.links.forEach((n)=>{let u=!!n.arrow&&(n.arrow.includes("-.->")||n.arrow.includes(".-.")),o=pt(n.fromPort)??pt(n.toPort),{flow:p,label:b}=Bt(n.arrow);if(!o&&p)o=p;let W=n.linkLabel,m=b??W;i.addLink(i.resolveNodeId(n.from),i.resolveNodeId(n.to),u,m,o)}),r.evolves.forEach((n)=>{let u=i.getNode(n.component);if(u?.y!==void 0){let o=ot(n.target,`Evolve target for "${n.component}"`);i.addTrend(n.component,o,u.y)}}),r.annotations.length>0){let n=r.annotations[0],u=q(n.x,n.y,"Annotations box");i.setAnnotationsBox(u.x,u.y)}r.annotation.forEach((n)=>{let u=q(n.x,n.y,`Annotation ${n.number}`);i.addAnnotation(n.number,[{x:u.x,y:u.y}],n.text)}),r.accelerators.forEach((n)=>{let u=q(n.x,n.y,`Accelerator "${n.name}"`);i.addAccelerator(n.name,u.x,u.y)}),r.deaccelerators.forEach((n)=>{let u=q(n.x,n.y,`Deaccelerator "${n.name}"`);i.addDeaccelerator(n.name,u.x,u.y)})},"populateDb"),ht={parser:{yy:void 0},parse:t(async(r)=>{let i=await J("wardley",r);a.debug(i);let n=ht.parser?.yy;if(!n||typeof n.addNode!=="function")throw Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Ft(i,n)},"parse")},Rt=class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}static{t(this,"WardleyBuilder")}addNode(r){let i=this.nodes.get(r.id)??{id:r.id,label:r.label},n={...i,...r,className:r.className??i.className,labelOffsetX:r.labelOffsetX??i.labelOffsetX,labelOffsetY:r.labelOffsetY??i.labelOffsetY};this.nodes.set(r.id,n)}addLink(r){this.links.push(r)}addTrend(r){this.trends.set(r.nodeId,r)}startPipeline(r){this.pipelines.set(r,{nodeId:r,componentIds:[]});let i=this.nodes.get(r);if(i)i.isPipelineParent=!0}addPipelineComponent(r,i){let n=this.pipelines.get(r);if(n)n.componentIds.push(i);let u=this.nodes.get(i);if(u)u.inPipeline=!0}addAnnotation(r){this.annotations.push(r)}addNote(r){this.notes.push(r)}addAccelerator(r){this.accelerators.push(r)}addDeaccelerator(r){this.deaccelerators.push(r)}setAnnotationsBox(r,i){this.annotationsBox={x:r,y:i}}setAxes(r){this.axes={...this.axes,...r}}setSize(r,i){this.size={width:r,height:i}}getNode(r){return this.nodes.get(r)}resolveNodeId(r){if(this.nodes.has(r))return r;for(let[i,n]of this.nodes)if(n.label===r)return i;return r}build(){let r=[];for(let i of this.nodes.values()){if(typeof i.x!=="number"||typeof i.y!=="number")throw Error(`Node "${i.label}" is missing coordinates`);r.push(i)}return{nodes:r,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}},P=new Rt;function ft(){return l()["wardley-beta"]}t(ft,"getConfig");function xt(r,i,n,u,o,p,b,W,m){P.addNode({id:r,label:i,x:n,y:u,className:o,labelOffsetX:p,labelOffsetY:b,inertia:W,sourceStrategy:m})}t(xt,"addNode");function gt(r,i,n=!1,u,o){P.addLink({source:r,target:i,dashed:n,label:u,flow:o})}t(gt,"addLink");function yt(r,i,n){P.addTrend({nodeId:r,targetX:i,targetY:n})}t(yt,"addTrend");function ut(r,i,n){P.addAnnotation({number:r,coordinates:i,text:n})}t(ut,"addAnnotation");function wt(r,i,n){P.addNote({text:r,x:i,y:n})}t(wt,"addNote");function mt(r,i,n){P.addAccelerator({name:r,x:i,y:n})}t(mt,"addAccelerator");function kt(r,i,n){P.addDeaccelerator({name:r,x:i,y:n})}t(kt,"addDeaccelerator");function bt(r,i){P.setAnnotationsBox(r,i)}t(bt,"setAnnotationsBox");function $t(r,i){P.setSize(r,i)}t($t,"setSize");function vt(r){P.startPipeline(r)}t(vt,"startPipeline");function Pt(r,i){P.addPipelineComponent(r,i)}t(Pt,"addPipelineComponent");function Ct(r){P.setAxes(r)}t(Ct,"updateAxes");function St(r){return P.getNode(r)}t(St,"getNode");function Mt(r){return P.resolveNodeId(r)}t(Mt,"resolveNodeId");function Nt(){return P.build()}t(Nt,"getWardleyData");function zt(){P.clear(),C()}t(zt,"clear");var Ot={getConfig:ft,addNode:xt,addLink:gt,addTrend:yt,addAnnotation:ut,addNote:wt,addAccelerator:mt,addDeaccelerator:kt,setAnnotationsBox:bt,setSize:$t,startPipeline:vt,addPipelineComponent:Pt,updateAxes:Ct,getNode:St,resolveNodeId:Mt,getWardleyData:Nt,clear:zt,setAccTitle:S,getAccTitle:E,setDiagramTitle:I,getDiagramTitle:R,getAccDescription:A,setAccDescription:T},Dt=["Genesis","Custom Built","Product","Commodity"],Gt=t(()=>{let{themeVariables:r}=l();return{backgroundColor:r.wardley?.backgroundColor??r.background??"#fff",axisColor:r.wardley?.axisColor??"#000",axisTextColor:r.wardley?.axisTextColor??r.primaryTextColor??"#222",gridColor:r.wardley?.gridColor??"rgba(100, 100, 100, 0.2)",componentFill:r.wardley?.componentFill??"#fff",componentStroke:r.wardley?.componentStroke??"#000",componentLabelColor:r.wardley?.componentLabelColor??r.primaryTextColor??"#222",linkStroke:r.wardley?.linkStroke??"#000",evolutionStroke:r.wardley?.evolutionStroke??"#dc3545",annotationStroke:r.wardley?.annotationStroke??"#000",annotationTextColor:r.wardley?.annotationTextColor??r.primaryTextColor??"#222",annotationFill:r.wardley?.annotationFill??r.background??"#fff"}},"getTheme"),qt=t(()=>{let r=l()["wardley-beta"];return{width:r?.width??900,height:r?.height??600,padding:r?.padding??48,nodeRadius:r?.nodeRadius??6,nodeLabelOffset:r?.nodeLabelOffset??8,axisFontSize:r?.axisFontSize??12,labelFontSize:r?.labelFontSize??10,showGrid:r?.showGrid??!1,useMaxWidth:r?.useMaxWidth??!0}},"getConfigValues"),jt=t((r,i,n,u)=>{a.debug(`Rendering Wardley map
|
|
2
|
+
`+r);let o=qt(),p=Gt(),b=o.nodeRadius*1.6,W=u.db,m=W.getWardleyData(),tt=W.getDiagramTitle(),X=m.size?.width??o.width,M=m.size?.height??o.height,Z=V(i);Z.selectAll("*").remove(),F(Z,M,X,o.useMaxWidth),Z.attr("viewBox",`0 0 ${X} ${M}`);let z=Z.append("g").attr("class","wardley-map"),nt=Z.append("defs");nt.append("marker").attr("id",`arrow-${i}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",p.evolutionStroke).attr("stroke","none"),nt.append("marker").attr("id",`link-arrow-end-${i}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",p.linkStroke).attr("stroke","none"),nt.append("marker").attr("id",`link-arrow-start-${i}`).attr("viewBox","0 0 10 10").attr("refX",1).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z").attr("fill",p.linkStroke).attr("stroke","none"),z.append("rect").attr("class","wardley-background").attr("width",X).attr("height",M).attr("fill",p.backgroundColor);let U=X-o.padding*2,K=M-o.padding*2;if(tt)z.append("text").attr("class","wardley-title").attr("x",X/2).attr("y",o.padding/2).attr("fill",p.axisTextColor).attr("font-size",o.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(tt);let O=t((e)=>o.padding+e/100*U,"projectX"),D=t((e)=>M-o.padding-e/100*K,"projectY"),et=z.append("g").attr("class","wardley-axes");et.append("line").attr("x1",o.padding).attr("x2",X-o.padding).attr("y1",M-o.padding).attr("y2",M-o.padding).attr("stroke",p.axisColor).attr("stroke-width",1),et.append("line").attr("x1",o.padding).attr("x2",o.padding).attr("y1",o.padding).attr("y2",M-o.padding).attr("stroke",p.axisColor).attr("stroke-width",1);let Lt=m.axes.xLabel??"Evolution",Tt=m.axes.yLabel??"Visibility";et.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",o.padding+U/2).attr("y",M-o.padding/4).attr("fill",p.axisTextColor).attr("font-size",o.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(Lt),et.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",o.padding/3).attr("y",o.padding+K/2).attr("fill",p.axisTextColor).attr("font-size",o.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${o.padding/3} ${o.padding+K/2})`).text(Tt);let Q=m.axes.stages&&m.axes.stages.length>0?m.axes.stages:Dt;if(Q.length>0){let e=z.append("g").attr("class","wardley-stages"),d=m.axes.stageBoundaries,s=[];if(d&&d.length===Q.length){let c=0;d.forEach((f)=>{s.push({start:c,end:f}),c=f})}else{let c=1/Q.length;Q.forEach((f,g)=>{s.push({start:g*c,end:(g+1)*c})})}Q.forEach((c,f)=>{let g=s[f],w=o.padding+g.start*U,y=o.padding+g.end*U,k=(w+y)/2;if(f>0)e.append("line").attr("x1",w).attr("x2",w).attr("y1",o.padding).attr("y2",M-o.padding).attr("stroke","#000").attr("stroke-width",1).attr("stroke-dasharray","5 5").attr("opacity",0.8);e.append("text").attr("class","wardley-stage-label").attr("x",k).attr("y",M-o.padding/1.5).attr("fill",p.axisTextColor).attr("font-size",o.axisFontSize-2).attr("text-anchor","middle").text(c)})}if(o.showGrid){let e=z.append("g").attr("class","wardley-grid");for(let d=1;d<4;d++){let s=d/4,c=o.padding+U*s;e.append("line").attr("x1",c).attr("x2",c).attr("y1",o.padding).attr("y2",M-o.padding).attr("stroke",p.gridColor).attr("stroke-dasharray","2 6"),e.append("line").attr("x1",o.padding).attr("x2",X-o.padding).attr("y1",M-o.padding-K*s).attr("y2",M-o.padding-K*s).attr("stroke",p.gridColor).attr("stroke-dasharray","2 6")}}let h=new Map;if(m.nodes.forEach((e)=>{h.set(e.id,{x:O(e.x),y:D(e.y),node:e})}),m.pipelines.length>0){let e=z.append("g").attr("class","wardley-pipelines"),d=z.append("g").attr("class","wardley-pipeline-links");m.pipelines.forEach((s)=>{if(s.componentIds.length===0)return;let c=s.componentIds.map((y)=>({id:y,pos:h.get(y),node:m.nodes.find((k)=>k.id===y)})).filter((y)=>y.pos&&y.node).sort((y,k)=>y.node.x-k.node.x);for(let y=0;y<c.length-1;y++){let k=c[y],v=c[y+1];d.append("line").attr("class","wardley-pipeline-evolution-link").attr("x1",k.pos.x).attr("y1",k.pos.y).attr("x2",v.pos.x).attr("y2",v.pos.y).attr("stroke",p.linkStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4")}let f=1/0,g=-1/0,w=0;if(s.componentIds.forEach((y)=>{let k=h.get(y);if(k)f=Math.min(f,k.x),g=Math.max(g,k.x),w=k.y}),f!==1/0&&g!==-1/0){let k=o.nodeRadius*4,v=w-k/2,L=h.get(s.nodeId);if(L){let B=(f+g)/2;L.x=B,L.y=v-b/6}e.append("rect").attr("class","wardley-pipeline-box").attr("x",f-15).attr("y",v).attr("width",g-f+30).attr("height",k).attr("fill","none").attr("stroke",p.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}})}let dt=z.append("g").attr("class","wardley-links"),lt=new Map;m.pipelines.forEach((e)=>{lt.set(e.nodeId,new Set(e.componentIds))});let ct=m.links.filter((e)=>{if(!h.has(e.source)||!h.has(e.target))return!1;if(lt.get(e.target)?.has(e.source))return!1;return!0});dt.selectAll("line").data(ct).enter().append("line").attr("class",(e)=>`wardley-link${e.dashed?" wardley-link--dashed":""}`).attr("x1",(e)=>{let d=h.get(e.source),s=h.get(e.target),f=m.nodes.find((k)=>k.id===e.source).isPipelineParent?b/Math.sqrt(2):o.nodeRadius,g=s.x-d.x,w=s.y-d.y,y=Math.sqrt(g*g+w*w);return d.x+g/y*f}).attr("y1",(e)=>{let d=h.get(e.source),s=h.get(e.target),f=m.nodes.find((k)=>k.id===e.source).isPipelineParent?b/Math.sqrt(2):o.nodeRadius,g=s.x-d.x,w=s.y-d.y,y=Math.sqrt(g*g+w*w);return d.y+w/y*f}).attr("x2",(e)=>{let d=h.get(e.source),s=h.get(e.target),f=m.nodes.find((k)=>k.id===e.target).isPipelineParent?b/Math.sqrt(2):o.nodeRadius,g=d.x-s.x,w=d.y-s.y,y=Math.sqrt(g*g+w*w);return s.x+g/y*f}).attr("y2",(e)=>{let d=h.get(e.source),s=h.get(e.target),f=m.nodes.find((k)=>k.id===e.target).isPipelineParent?b/Math.sqrt(2):o.nodeRadius,g=d.x-s.x,w=d.y-s.y,y=Math.sqrt(g*g+w*w);return s.y+w/y*f}).attr("stroke",p.linkStroke).attr("stroke-width",1).attr("stroke-dasharray",(e)=>e.dashed?"6 6":null).attr("marker-end",(e)=>{if(e.flow==="forward"||e.flow==="bidirectional")return`url(#link-arrow-end-${i})`;return null}).attr("marker-start",(e)=>{if(e.flow==="backward"||e.flow==="bidirectional")return`url(#link-arrow-start-${i})`;return null}),dt.selectAll("text").data(ct.filter((e)=>e.label)).enter().append("text").attr("class","wardley-link-label").attr("x",(e)=>{let d=h.get(e.source),s=h.get(e.target),c=(d.x+s.x)/2,f=s.y-d.y,g=s.x-d.x,w=Math.sqrt(g*g+f*f),y=8,k=f/w;return c+k*8}).attr("y",(e)=>{let d=h.get(e.source),s=h.get(e.target),c=(d.y+s.y)/2,f=s.x-d.x,g=s.y-d.y,w=Math.sqrt(f*f+g*g),y=8,k=-f/w;return c+k*8}).attr("fill",p.axisTextColor).attr("font-size",o.labelFontSize).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("transform",(e)=>{let d=h.get(e.source),s=h.get(e.target),c=(d.x+s.x)/2,f=(d.y+s.y)/2,g=s.x-d.x,w=s.y-d.y,y=Math.sqrt(g*g+w*w),k=8,v=w/y,L=-g/y,B=c+v*8,at=f+L*8,_=Math.atan2(w,g)*180/Math.PI;if(_>90||_<-90)_+=180;return`rotate(${_} ${B} ${at})`}).text((e)=>e.label);let Wt=z.append("g").attr("class","wardley-trends"),At=m.trends.map((e)=>{let d=h.get(e.nodeId);if(!d)return null;let s=O(e.targetX),c=D(e.targetY),f=s-d.x,g=c-d.y,w=Math.sqrt(f*f+g*g),y=o.nodeRadius+2,k=w>y?s-f/w*y:s,v=w>y?c-g/w*y:c;return{origin:d,targetX:s,targetY:c,adjustedX2:k,adjustedY2:v}}).filter((e)=>e!==null);Wt.selectAll("line").data(At).enter().append("line").attr("class","wardley-trend").attr("x1",(e)=>e.origin.x).attr("y1",(e)=>e.origin.y).attr("x2",(e)=>e.adjustedX2).attr("y2",(e)=>e.adjustedY2).attr("stroke",p.evolutionStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4").attr("marker-end",`url(#arrow-${i})`);let Y=z.append("g").attr("class","wardley-nodes").selectAll("g").data(m.nodes).enter().append("g").attr("class",(e)=>["wardley-node",e.className?`wardley-node--${e.className}`:""].filter(Boolean).join(" "));Y.filter((e)=>e.sourceStrategy==="outsource").append("circle").attr("class","wardley-outsource-overlay").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius*2).attr("fill","#666").attr("stroke",p.componentStroke).attr("stroke-width",1),Y.filter((e)=>e.sourceStrategy==="buy").append("circle").attr("class","wardley-buy-overlay").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius*2).attr("fill","#ccc").attr("stroke",p.componentStroke).attr("stroke-width",1),Y.filter((e)=>e.sourceStrategy==="build").append("circle").attr("class","wardley-build-overlay").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius*2).attr("fill","#eee").attr("stroke","#000").attr("stroke-width",1);let G=Y.filter((e)=>e.sourceStrategy==="market");G.append("circle").attr("class","wardley-market-overlay").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius*2).attr("fill","white").attr("stroke",p.componentStroke).attr("stroke-width",1),Y.filter((e)=>!e.isPipelineParent&&e.sourceStrategy!=="market"&&e.className!=="anchor").append("circle").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y).attr("r",o.nodeRadius).attr("fill",p.componentFill).attr("stroke",p.componentStroke).attr("stroke-width",1);let st=o.nodeRadius*0.7,N=o.nodeRadius*1.2;if(G.append("line").attr("class","wardley-market-line").attr("x1",(e)=>h.get(e.id).x).attr("y1",(e)=>h.get(e.id).y-N).attr("x2",(e)=>h.get(e.id).x-N*Math.cos(Math.PI/6)).attr("y2",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("stroke",p.componentStroke).attr("stroke-width",1),G.append("line").attr("class","wardley-market-line").attr("x1",(e)=>h.get(e.id).x-N*Math.cos(Math.PI/6)).attr("y1",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("x2",(e)=>h.get(e.id).x+N*Math.cos(Math.PI/6)).attr("y2",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("stroke",p.componentStroke).attr("stroke-width",1),G.append("line").attr("class","wardley-market-line").attr("x1",(e)=>h.get(e.id).x+N*Math.cos(Math.PI/6)).attr("y1",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("x2",(e)=>h.get(e.id).x).attr("y2",(e)=>h.get(e.id).y-N).attr("stroke",p.componentStroke).attr("stroke-width",1),G.append("circle").attr("class","wardley-market-dot").attr("cx",(e)=>h.get(e.id).x).attr("cy",(e)=>h.get(e.id).y-N).attr("r",st).attr("fill","white").attr("stroke",p.componentStroke).attr("stroke-width",2),G.append("circle").attr("class","wardley-market-dot").attr("cx",(e)=>h.get(e.id).x-N*Math.cos(Math.PI/6)).attr("cy",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("r",st).attr("fill","white").attr("stroke",p.componentStroke).attr("stroke-width",2),G.append("circle").attr("class","wardley-market-dot").attr("cx",(e)=>h.get(e.id).x+N*Math.cos(Math.PI/6)).attr("cy",(e)=>h.get(e.id).y+N*Math.sin(Math.PI/6)).attr("r",st).attr("fill","white").attr("stroke",p.componentStroke).attr("stroke-width",2),Y.filter((e)=>e.isPipelineParent===!0).append("rect").attr("x",(e)=>h.get(e.id).x-b/2).attr("y",(e)=>h.get(e.id).y-b/2).attr("width",b).attr("height",b).attr("fill",p.componentFill).attr("stroke",p.componentStroke).attr("stroke-width",1),Y.filter((e)=>e.inertia===!0).append("line").attr("class","wardley-inertia").attr("x1",(e)=>{let d=h.get(e.id),s=e.isPipelineParent?b/2+15:o.nodeRadius+15;if(e.sourceStrategy)s+=o.nodeRadius+10;return d.x+s}).attr("y1",(e)=>{let d=h.get(e.id),s=e.isPipelineParent?b:o.nodeRadius*2;return d.y-s/2}).attr("x2",(e)=>{let d=h.get(e.id),s=e.isPipelineParent?b/2+15:o.nodeRadius+15;if(e.sourceStrategy)s+=o.nodeRadius+10;return d.x+s}).attr("y2",(e)=>{let d=h.get(e.id),s=e.isPipelineParent?b:o.nodeRadius*2;return d.y+s/2}).attr("stroke",p.componentStroke).attr("stroke-width",6),Y.append("text").attr("x",(e)=>{let d=h.get(e.id);if(e.className==="anchor")return e.labelOffsetX!==void 0?d.x+e.labelOffsetX:d.x;let s=o.nodeLabelOffset;if(e.sourceStrategy&&e.labelOffsetX===void 0)s+=10;let c=e.labelOffsetX??s;return d.x+c}).attr("y",(e)=>{let d=h.get(e.id);if(e.className==="anchor")return e.labelOffsetY!==void 0?d.y+e.labelOffsetY:d.y-3;let s=-o.nodeLabelOffset;if(e.sourceStrategy&&e.labelOffsetY===void 0)s-=10;let c=e.labelOffsetY??s;return d.y+c}).attr("class","wardley-node-label").attr("fill",(e)=>{if(e.className==="evolved")return p.evolutionStroke;if(e.className==="anchor")return"#000";return p.componentLabelColor}).attr("font-size",o.labelFontSize).attr("font-weight",(e)=>e.className==="anchor"?"bold":"normal").attr("text-anchor",(e)=>e.className==="anchor"?"middle":"start").attr("dominant-baseline",(e)=>e.className==="anchor"?"middle":"auto").text((e)=>e.label),m.annotations.length>0){let e=z.append("g").attr("class","wardley-annotations");if(m.annotations.forEach((d)=>{let s=d.coordinates.map((c)=>({x:O(c.x),y:D(c.y)}));if(s.length>1)for(let c=0;c<s.length-1;c++)e.append("line").attr("class","wardley-annotation-line").attr("x1",s[c].x).attr("y1",s[c].y).attr("x2",s[c+1].x).attr("y2",s[c+1].y).attr("stroke",p.axisColor).attr("stroke-width",1.5).attr("stroke-dasharray","4 4");s.forEach((c)=>{let f=e.append("g").attr("class","wardley-annotation");f.append("circle").attr("cx",c.x).attr("cy",c.y).attr("r",10).attr("fill","white").attr("stroke",p.axisColor).attr("stroke-width",1.5),f.append("text").attr("x",c.x).attr("y",c.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",10).attr("fill",p.axisTextColor).attr("font-weight","bold").text(d.number)})}),m.annotationsBox){let d=O(m.annotationsBox.x),s=D(m.annotationsBox.y),c=10,f=16,g=11,w=e.append("g").attr("class","wardley-annotations-box"),y=[...m.annotations].filter((v)=>v.text).sort((v,L)=>v.number-L.number),k=[];if(y.forEach((v,L)=>{let B=w.append("text").attr("x",d+c).attr("y",s+c+(L+1)*f).attr("font-size",g).attr("fill",p.axisTextColor).attr("text-anchor","start").attr("dominant-baseline","middle").text(`${v.number}. ${v.text}`);k.push(B)}),k.length>0){let v=0,L=0;k.forEach((it)=>{let rt=it.node(),Yt=rt.getComputedTextLength();v=Math.max(v,Yt);let It=rt.getBBox();L=Math.max(L,It.height)});let B=v+c*2+105,at=y.length*f+c*2+L/2,_=o.padding,Xt=X-o.padding-B,Et=o.padding,Ht=M-o.padding-at;d=Math.max(_,Math.min(d,Xt)),s=Math.max(Et,Math.min(s,Ht)),k.forEach((it,rt)=>{it.attr("x",d+c).attr("y",s+c+(rt+1)*f)}),w.insert("rect","text").attr("x",d).attr("y",s).attr("width",B).attr("height",at).attr("fill","white").attr("stroke",p.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}}}if(m.notes.length>0){let e=z.append("g").attr("class","wardley-notes");m.notes.forEach((d)=>{let s=O(d.x),c=D(d.y);e.append("text").attr("x",s).attr("y",c).attr("text-anchor","start").attr("font-size",11).attr("fill",p.axisTextColor).attr("font-weight","bold").text(d.text)})}if(m.accelerators.length>0){let e=z.append("g").attr("class","wardley-accelerators");m.accelerators.forEach((d)=>{let s=O(d.x),c=D(d.y),f=60,g=30,w=20,y=`
|
|
3
3
|
M ${s} ${c-15}
|
|
4
4
|
L ${s+60-20} ${c-15}
|
|
5
5
|
L ${s+60-20} ${c-15-8}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h,o,v,i,r,m,e,n,y,lt}from"./chunk-ty2rmwda.js";var V="__chat__";function M(t){if(!Number.isFinite(t)||t<=0)return"0";if(t<1000)return Math.round(t).toString();if(t<1e6)return`${(t/1000).toFixed(1)}K`;if(t<1e9)return`${(t/1e6).toFixed(2)}M`;return`${(t/1e9).toFixed(2)}B`}function L(t){let u=Number.isFinite(t)?Math.max(0,t):0;return Math.round(u).toLocaleString("en-US")}function P(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.floor(t/1000)}s`;if(t<3600000){let c=Math.floor(t/1000),a=Math.floor(c/60),f=c%60;return f>0?`${a}m ${f}s`:`${a}m`}if(t<259200000){let c=Math.floor(t/60000),a=Math.floor(c/60),f=c%60;return f>0?`${a}h ${f}m`:`${a}h`}let u=Math.floor(t/3600000),g=Math.floor(u/24),p=u%24;return p>0?`${g}d ${p}h`:`${g}d`}function ae(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.round(t/1000)}s`;if(t<3600000)return`${Math.round(t/60000)}m`;if(t<86400000){let p=t/3600000;return`${p>=10?Math.round(p).toString():p.toFixed(1).replace(/\.0$/,"")}h`}let u=t/86400000;return`${u>=10?Math.round(u).toString():u.toFixed(1).replace(/\.0$/,"")}d`}function B(t,u=1){if(!Number.isFinite(t)||t<=0)return"0%";let g=10**-u/100;if(t<g)return`<${(g*100).toFixed(u)}%`;return`${(t*100).toFixed(u)}%`}function Q(t){if(!Number.isFinite(t)||t<=0)return"0 B";if(t<1024)return`${Math.round(t)} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(2)} MB`;return`${(t/1073741824).toFixed(2)} GB`}function W(t){let u=t.split("-"),g=u[1],p=u[2];if(g!==void 0&&p!==void 0)return`${g}/${p}`;return t}function Z(t){let u=t.split("-"),g=u[0],p=u[1],c=u[2];if(g===void 0||p===void 0||c===void 0)return t;let a=Number(g),f=Number(p)-1,b=Number(c),w=new Date(Date.UTC(a,f,b)),C=["周日","周一","周二","周三","周四","周五","周六"],D=w.getUTCDay(),F=C[D]??"";return`${t} ${F}`}function se(t,u=Date.now()){if(t===null||t===void 0||!Number.isFinite(t)||t<=0)return"从未";let g=Math.max(0,u-t);if(g<60000)return"刚刚";if(g<3600000)return`${Math.max(1,Math.floor(g/60000))} 分钟前`;if(g<86400000)return`${Math.max(1,Math.floor(g/3600000))} 小时前`;if(g<2592000000)return`${Math.max(1,Math.floor(g/86400000))} 天前`;let p=new Date(t),c=p.getFullYear(),a=String(p.getMonth()+1).padStart(2,"0"),f=String(p.getDate()).padStart(2,"0");return`${c}-${a}-${f}`}function K(t){return e("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-raised",children:e("div",{className:"h-full rounded-full bg-accent transition-all duration-300",style:{width:`${t.percent}%`}})})}function Y(t){return e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:t.children})}function G(t){return e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:t.children})}function J(t){return n(G,{children:[n("span",{children:["输入 ",e("span",{className:"text-ink",children:M(t.stat.inputTokens)})]}),n("span",{children:["输出 ",e("span",{className:"text-ink",children:M(t.stat.outputTokens)})]}),n("span",{children:["缓存读 ",e("span",{className:"text-ink",children:M(t.stat.cacheReadTokens)}),t.cacheHitRate!==void 0&&n("span",{className:"text-faint",children:[" (",B(t.cacheHitRate),")"]})]})]})}function oe(t){let{projects:u,selectedProjectID:g,onSelectProject:p}=t,{style:c}=y();if(u.length===0)return e("div",{className:c("surface.empty"),children:"暂无项目统计数据"});return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let f=a.projectID??V,b=g===f,w=Math.max(a.tokenShare>0?1:0,a.tokenShare*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate",children:a.name}),e("span",{className:c("control.badge","font-mono truncate max-w-[240px]"),title:a.directory||"未绑定项目目录",children:a.directory||"独立会话"}),e("button",{type:"button",onClick:()=>p(b?null:f),className:"rounded px-1.5 py-0.5 text-[11px] text-accent hover:bg-accent/10 transition-colors cursor-pointer shrink-0",children:b?"取消筛选":"筛选"})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),n("span",{className:"text-[11px] text-faint",children:["(",B(a.tokenShare),")"]})]})]}),e(K,{percent:w}),n(Y,{children:[e(J,{stat:a,cacheHitRate:a.cacheHitRate}),n(G,{children:[n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.sessionCount.toLocaleString()})," 会话"]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:a.toolCalls.toLocaleString()})," 次"]})]})]})]},f)})})}function re(t){let{models:u}=t,{ModelIcon:g,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无模型调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e(g,{modelID:c.model,className:"size-4 shrink-0"}),e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.shortName}),e("span",{className:p("control.badge","font-mono shrink-0"),children:c.provider})]}),n("div",{className:"flex items-baseline gap-2.5 font-mono tabular-nums shrink-0",children:[c.avgTps!==null&&n("span",{className:"text-[11px] text-dim",children:[c.avgTps.toFixed(1)," tok/s"]}),n("span",{className:"text-xs font-medium text-ink",title:L(c.totalTokens),children:[M(c.totalTokens)," ",n("span",{className:"text-[11px] font-normal text-faint",children:["(",B(c.share),")"]})]})]})]}),e(K,{percent:a}),n(Y,{children:[e(J,{stat:c,cacheHitRate:c.cacheHitRate}),n(G,{children:[n("span",{children:[e("span",{className:"text-ink",children:c.turns.toLocaleString()})," 轮",c.errors>0?n("span",{className:"text-danger",children:[" (",c.errors," 错)"]}):null]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:c.toolCalls.toLocaleString()})," 次"]}),c.generationMs>0&&n("span",{children:["推理 ",e("span",{className:"text-ink",children:ae(c.generationMs)})]})]})]})]},c.model)})})}function ie(t){let{tools:u}=t,{StatusChip:g,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无工具调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100),f=c.successRate>=0.95?"success":c.successRate>=0.8?"warning":"danger",b=Math.max(0,c.calls-c.errors),w=c.calls>0?Math.round(c.outputBytes/c.calls):0;return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.name}),n(g,{tone:f,children:["成功率 ",B(c.successRate)]})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[n("span",{className:"text-xs font-medium text-ink",children:[c.calls.toLocaleString()," 次"]}),n("span",{className:"text-[11px] text-faint",children:["(",B(c.share),")"]})]})]}),e(K,{percent:a}),n(Y,{children:[n(G,{children:[n("span",{children:["成功 ",e("span",{className:"text-ink",children:b.toLocaleString()})," 次"]}),n("span",{children:["失败 ",e("span",{className:c.errors>0?"text-danger":"text-ink",children:c.errors.toLocaleString()})," 次"]})]}),n(G,{children:[n("span",{children:["累计输出 ",e("span",{className:"text-ink",children:Q(c.outputBytes)})]}),n("span",{children:["单次均值 ",e("span",{className:"text-ink",children:Q(w)})]})]})]})]},c.name)})})}function le(t){let{sessions:u,onOpenSession:g}=t,{style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无高消耗会话记录"});let c=Math.max(1,...u.map((a)=>a.totalTokens));return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let f=c>0?Math.max(1,a.totalTokens/c*100):0,b=a.model.split("/").pop()??a.model;return n("button",{type:"button",onClick:()=>g(a.id),className:"group block w-full p-4 text-left space-y-2.5 hover:bg-raised/40 transition-colors cursor-pointer",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate group-hover:text-accent transition-colors",children:a.title.trim()||"新会话"}),e("span",{className:p("control.badge","font-mono truncate max-w-[140px] shrink-0"),title:a.projectName,children:a.projectName}),a.kind==="sub"&&e("span",{className:"rounded bg-accent/15 px-1.5 py-0.5 text-[10.5px] text-accent shrink-0",children:"子代理"}),a.archivedAt!==null&&e("span",{className:p("control.badge","shrink-0"),children:"已归档"})]}),n("div",{className:"flex items-center gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),e(lt,{className:"size-3.5 text-faint group-hover:text-ink group-hover:translate-x-0.5 transition-all"})]})]}),e(K,{percent:f}),n(Y,{children:[e(J,{stat:a}),n(G,{children:[e("span",{className:"text-ink",children:b}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.assistantTurns})," 轮"]}),e("span",{className:"text-faint",children:se(a.updated)})]})]})]},a.id)})})}var ce=[{value:"tokens",label:"Token 用量"},{value:"duration",label:"活跃耗时"},{value:"activity",label:"交互轮次"}];function ue(t){let{cn:u,Segmented:g,SettingGroup:p,style:c}=y(),{daily:a}=t,[f,b]=r("tokens"),[w,C]=r(null),D=v(()=>a.some((s)=>s.totalTokens>0||s.activeDurationMs>0||s.runs>0),[a]),F=v(()=>{if(a.length===0)return{totalText:"0",avgText:"0",peakDate:"—",peakValueText:"0"};if(f==="tokens"){let S=a.reduce((_,A)=>_+A.totalTokens,0),R=a.filter((_)=>_.totalTokens>0).length,N=a[0];for(let _ of a)if(!N||_.totalTokens>N.totalTokens)N=_;return{totalText:M(S),totalFullText:L(S),avgText:R>0?M(Math.round(S/R)):"0",peakDate:N&&N.totalTokens>0?W(N.date):"—",peakValueText:N&&N.totalTokens>0?M(N.totalTokens):"0"}}if(f==="duration"){let S=a.reduce((_,A)=>_+A.activeDurationMs,0),R=a.filter((_)=>_.activeDurationMs>0).length,N=a[0];for(let _ of a)if(!N||_.activeDurationMs>N.activeDurationMs)N=_;return{totalText:P(S),totalFullText:P(S),avgText:R>0?P(Math.round(S/R)):"0s",peakDate:N&&N.activeDurationMs>0?W(N.date):"—",peakValueText:N&&N.activeDurationMs>0?P(N.activeDurationMs):"0s"}}let s=a.reduce((S,R)=>S+R.assistantTurns,0),l=a.reduce((S,R)=>S+R.userMessages,0),x=s+l,T=a.filter((S)=>S.assistantTurns>0||S.userMessages>0).length,k=a[0];for(let S of a){let R=k?k.assistantTurns+k.userMessages:0;if(!k||S.assistantTurns+S.userMessages>R)k=S}let H=k?k.assistantTurns+k.userMessages:0;return{totalText:`${x.toLocaleString()} 轮`,totalFullText:`助手 ${s.toLocaleString()} 轮 · 用户 ${l.toLocaleString()} 问`,avgText:T>0?`${(x/T).toFixed(1)} 轮/天`:"0 轮/天",peakDate:k&&H>0?W(k.date):"—",peakValueText:k&&H>0?`${H.toLocaleString()} 轮`:"0 轮"}},[a,f]),j=v(()=>{if(w){let s=a.find((l)=>l.date===w);if(s)return s}for(let s=a.length-1;s>=0;s--){let l=a[s];if(l&&(l.totalTokens>0||l.activeDurationMs>0||l.runs>0))return l}return a[a.length-1]},[a,w]),z=v(()=>{if(f==="tokens")return Math.max(1,...a.map((s)=>s.totalTokens));if(f==="duration")return Math.max(1000,...a.map((s)=>s.activeDurationMs));return Math.max(1,...a.map((s)=>s.assistantTurns+s.userMessages))},[a,f]),d=v(()=>{if(a.length<=7)return a.map((x)=>x.date);let s=6,l=[];for(let x=0;x<s;x++){let T=Math.round(x*(a.length-1)/(s-1)),k=a[T];if(k)l.push(k.date)}return l},[a]);if(!D)return e(p,{title:"每日趋势",action:e(g,{value:f,onChange:(s)=>b(s),options:ce}),children:e("div",{className:c("surface.empty"),children:"当前时间范围内暂无活跃数据"})});return e(p,{title:"每日趋势",action:e(g,{value:f,onChange:(s)=>b(s),options:ce}),children:n("div",{className:"p-4 space-y-4",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 font-mono text-dim tabular-nums",children:[n("span",{children:["汇总 ",e("span",{className:"text-ink",children:F.totalText})]}),n("span",{children:["日均 ",e("span",{className:"text-ink",children:F.avgText})]}),n("span",{children:["峰值 ",e("span",{className:"text-ink",children:F.peakValueText}),F.peakDate!=="—"?n("span",{className:"text-faint",children:[" (",F.peakDate,")"]}):null]})]}),n("div",{className:"flex items-center gap-3 text-[11px] text-dim",children:[f==="tokens"&&n(m,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent/40"}),"缓存读"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"输入"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"输出"]})]}),f==="duration"&&n(m,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"工作调度"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"模型推理"]})]}),f==="activity"&&n(m,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"助手回复"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"用户提问"]})]})]})]}),n("div",{className:"relative h-44 w-full pt-1",children:[n("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none pb-5 text-[10px] text-faint/60",children:[e("div",{className:"border-b border-line/40 w-full"}),e("div",{className:"border-b border-line/30 w-full"}),e("div",{className:"border-b border-line/40 w-full"})]}),n("section",{"aria-label":"每日趋势柱状序列",className:"relative h-full flex flex-col justify-between",onMouseLeave:()=>C(null),children:[e("div",{className:"flex-1 flex items-end gap-1 sm:gap-1.5 pb-2",children:a.map((s)=>{let l=s.totalTokens;if(f==="duration")l=s.activeDurationMs;else if(f==="activity")l=s.assistantTurns+s.userMessages;let x=l<=0,T=x?0:Math.max(3,Math.min(100,l/z*100)),k=j?.date===s.date;return n("button",{type:"button","aria-label":`${s.date} 统计数据`,className:"flex-1 h-full flex flex-col justify-end items-center group cursor-pointer relative min-w-0 bg-transparent p-0 border-0 focus:outline-hidden",onMouseEnter:()=>C(s.date),onFocus:()=>C(s.date),onClick:()=>C(s.date),children:[e("div",{className:u("absolute inset-y-0 w-full rounded-xs transition-colors pointer-events-none",k?"bg-accent/10":"group-hover:bg-raised/60")}),x?e("div",{className:"h-1 w-full max-w-[24px] rounded-full bg-raised group-hover:bg-dim/30"}):n("div",{className:"w-full max-w-[24px] rounded-t-xs overflow-hidden flex flex-col justify-end transition-all duration-150",style:{height:`${T}%`},children:[f==="tokens"&&n(m,{children:[s.outputTokens>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.outputTokens/s.totalTokens*100}%`}}),s.inputTokens+s.cacheWriteTokens>0&&e("div",{className:"bg-accent transition-all duration-200",style:{height:`${(s.inputTokens+s.cacheWriteTokens)/s.totalTokens*100}%`}}),s.cacheReadTokens>0&&e("div",{className:"bg-accent/40 transition-all duration-200",style:{height:`${s.cacheReadTokens/s.totalTokens*100}%`}})]}),f==="duration"&&n(m,{children:[s.generationMs>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${Math.min(100,s.generationMs/Math.max(1,s.activeDurationMs)*100)}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]}),f==="activity"&&n(m,{children:[s.userMessages>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.userMessages/Math.max(1,s.assistantTurns+s.userMessages)*100}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]})]}),k&&e("div",{className:"absolute -bottom-1 size-1 rounded-full bg-accent"})]},s.date)})}),e("div",{className:u("flex items-center pt-1.5 text-[10px] text-faint font-mono tabular-nums",a.length<=7?"gap-1 sm:gap-1.5":"justify-between"),children:d.map((s)=>e("div",{className:u("whitespace-nowrap",a.length<=7&&"flex-1 text-center"),children:W(s)},s))})]})]}),e("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-line pt-3 font-mono text-xs tabular-nums",children:j?n(m,{children:[e("span",{className:"text-ink",children:Z(j.date)}),n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 text-dim",children:[n("span",{children:["Token ",e("span",{className:"text-ink",children:M(j.totalTokens)})]}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(j.activeDurationMs)})]}),n("span",{children:["交互 ",n("span",{className:"text-ink",children:[j.assistantTurns+j.userMessages," 轮"]})]}),n("span",{children:["工具 ",n("span",{className:"text-ink",children:[j.toolCalls," 次"]})]})]})]}):e("span",{className:"font-sans text-faint",children:"悬停柱状图查看单日明细"})})]})})}function pe(t){let{cn:u,SettingGroup:g}=y(),{daily:p,hourly:c}=t,[a,f]=r(null),b=v(()=>{let l=new Map;for(let T of c)l.set(T.hour,T);let x=[];for(let T=0;T<24;T++){let k=l.get(T);if(k)x.push(k);else x.push({hour:T,totalTokens:0,activeDurationMs:0,userMessages:0,assistantTurns:0,runs:0})}return x},[c]),w=v(()=>{let l=b[0];for(let x of b)if(!l||x.totalTokens>l.totalTokens)l=x;return l&&l.totalTokens>0?l:null},[b]),C=v(()=>b.reduce((l,x)=>l+x.totalTokens,0),[b]),D=v(()=>Math.max(1,...b.map((l)=>l.totalTokens)),[b]),F=v(()=>{if(C<=0)return 0;return b.filter((x)=>x.hour>=8&&x.hour<20).reduce((x,T)=>x+T.totalTokens,0)/C},[b,C]),j=v(()=>Math.max(1,...p.map((l)=>l.totalTokens)),[p]),z=v(()=>{let l=0,x=0;for(let T of p)if(T.totalTokens>0||T.activeDurationMs>0||T.runs>0){if(x++,x>l)l=x}else x=0;return l},[p]),d=v(()=>p.filter((l)=>l.totalTokens>0||l.activeDurationMs>0||l.runs>0).length,[p]),s=a!==null?b[a]:w;return n(g,{title:"活跃时段与热力",action:n("div",{className:"flex items-center gap-3 font-mono text-xs text-faint tabular-nums",children:[n("span",{children:["日间占比 ",B(F)]}),n("span",{children:["连续活跃 ",z," 天"]}),n("span",{children:["活跃 ",d,"/",p.length," 天"]})]}),children:[n("div",{className:"p-4 space-y-3",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[e("span",{className:"text-dim",children:"24 小时分布"}),s?n("div",{className:"flex items-center gap-3 font-mono text-dim tabular-nums",children:[n("span",{className:"text-ink",children:[a!==null?"时段 ":"高峰 ",String(s.hour).padStart(2,"0"),":00 -"," ",String((s.hour+1)%24).padStart(2,"0"),":00"]}),e("span",{className:"text-ink",children:M(s.totalTokens)}),s.activeDurationMs>0&&e("span",{children:P(s.activeDurationMs)})]}):e("span",{className:"text-faint",children:"暂无时段分布"})]}),n("section",{"aria-label":"24 小时活跃分布序列",className:"h-28 w-full flex flex-col justify-between pt-1",onMouseLeave:()=>f(null),children:[e("div",{className:"flex-1 flex items-end gap-1.5 pb-1.5",children:b.map((l)=>{let x=w?.hour===l.hour,T=a===l.hour,k=l.totalTokens>0?Math.max(6,l.totalTokens/D*100):0,H=`${String(l.hour).padStart(2,"0")}:00 - ${String((l.hour+1)%24).padStart(2,"0")}:00
|
|
1
|
+
import{h,o,v,i,r,m,e,n,y,lt}from"./chunk-bcp6na49.js";var V="__chat__";function M(t){if(!Number.isFinite(t)||t<=0)return"0";if(t<1000)return Math.round(t).toString();if(t<1e6)return`${(t/1000).toFixed(1)}K`;if(t<1e9)return`${(t/1e6).toFixed(2)}M`;return`${(t/1e9).toFixed(2)}B`}function L(t){let u=Number.isFinite(t)?Math.max(0,t):0;return Math.round(u).toLocaleString("en-US")}function P(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.floor(t/1000)}s`;if(t<3600000){let c=Math.floor(t/1000),a=Math.floor(c/60),f=c%60;return f>0?`${a}m ${f}s`:`${a}m`}if(t<259200000){let c=Math.floor(t/60000),a=Math.floor(c/60),f=c%60;return f>0?`${a}h ${f}m`:`${a}h`}let u=Math.floor(t/3600000),g=Math.floor(u/24),p=u%24;return p>0?`${g}d ${p}h`:`${g}d`}function ae(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.round(t/1000)}s`;if(t<3600000)return`${Math.round(t/60000)}m`;if(t<86400000){let p=t/3600000;return`${p>=10?Math.round(p).toString():p.toFixed(1).replace(/\.0$/,"")}h`}let u=t/86400000;return`${u>=10?Math.round(u).toString():u.toFixed(1).replace(/\.0$/,"")}d`}function B(t,u=1){if(!Number.isFinite(t)||t<=0)return"0%";let g=10**-u/100;if(t<g)return`<${(g*100).toFixed(u)}%`;return`${(t*100).toFixed(u)}%`}function Q(t){if(!Number.isFinite(t)||t<=0)return"0 B";if(t<1024)return`${Math.round(t)} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(2)} MB`;return`${(t/1073741824).toFixed(2)} GB`}function W(t){let u=t.split("-"),g=u[1],p=u[2];if(g!==void 0&&p!==void 0)return`${g}/${p}`;return t}function Z(t){let u=t.split("-"),g=u[0],p=u[1],c=u[2];if(g===void 0||p===void 0||c===void 0)return t;let a=Number(g),f=Number(p)-1,b=Number(c),w=new Date(Date.UTC(a,f,b)),C=["周日","周一","周二","周三","周四","周五","周六"],D=w.getUTCDay(),F=C[D]??"";return`${t} ${F}`}function se(t,u=Date.now()){if(t===null||t===void 0||!Number.isFinite(t)||t<=0)return"从未";let g=Math.max(0,u-t);if(g<60000)return"刚刚";if(g<3600000)return`${Math.max(1,Math.floor(g/60000))} 分钟前`;if(g<86400000)return`${Math.max(1,Math.floor(g/3600000))} 小时前`;if(g<2592000000)return`${Math.max(1,Math.floor(g/86400000))} 天前`;let p=new Date(t),c=p.getFullYear(),a=String(p.getMonth()+1).padStart(2,"0"),f=String(p.getDate()).padStart(2,"0");return`${c}-${a}-${f}`}function K(t){return e("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-raised",children:e("div",{className:"h-full rounded-full bg-accent transition-all duration-300",style:{width:`${t.percent}%`}})})}function Y(t){return e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:t.children})}function G(t){return e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:t.children})}function J(t){return n(G,{children:[n("span",{children:["输入 ",e("span",{className:"text-ink",children:M(t.stat.inputTokens)})]}),n("span",{children:["输出 ",e("span",{className:"text-ink",children:M(t.stat.outputTokens)})]}),n("span",{children:["缓存读 ",e("span",{className:"text-ink",children:M(t.stat.cacheReadTokens)}),t.cacheHitRate!==void 0&&n("span",{className:"text-faint",children:[" (",B(t.cacheHitRate),")"]})]})]})}function oe(t){let{projects:u,selectedProjectID:g,onSelectProject:p}=t,{style:c}=y();if(u.length===0)return e("div",{className:c("surface.empty"),children:"暂无项目统计数据"});return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let f=a.projectID??V,b=g===f,w=Math.max(a.tokenShare>0?1:0,a.tokenShare*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate",children:a.name}),e("span",{className:c("control.badge","font-mono truncate max-w-[240px]"),title:a.directory||"未绑定项目目录",children:a.directory||"独立会话"}),e("button",{type:"button",onClick:()=>p(b?null:f),className:"rounded px-1.5 py-0.5 text-[11px] text-accent hover:bg-accent/10 transition-colors cursor-pointer shrink-0",children:b?"取消筛选":"筛选"})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),n("span",{className:"text-[11px] text-faint",children:["(",B(a.tokenShare),")"]})]})]}),e(K,{percent:w}),n(Y,{children:[e(J,{stat:a,cacheHitRate:a.cacheHitRate}),n(G,{children:[n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.sessionCount.toLocaleString()})," 会话"]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:a.toolCalls.toLocaleString()})," 次"]})]})]})]},f)})})}function re(t){let{models:u}=t,{ModelIcon:g,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无模型调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e(g,{modelID:c.model,className:"size-4 shrink-0"}),e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.shortName}),e("span",{className:p("control.badge","font-mono shrink-0"),children:c.provider})]}),n("div",{className:"flex items-baseline gap-2.5 font-mono tabular-nums shrink-0",children:[c.avgTps!==null&&n("span",{className:"text-[11px] text-dim",children:[c.avgTps.toFixed(1)," tok/s"]}),n("span",{className:"text-xs font-medium text-ink",title:L(c.totalTokens),children:[M(c.totalTokens)," ",n("span",{className:"text-[11px] font-normal text-faint",children:["(",B(c.share),")"]})]})]})]}),e(K,{percent:a}),n(Y,{children:[e(J,{stat:c,cacheHitRate:c.cacheHitRate}),n(G,{children:[n("span",{children:[e("span",{className:"text-ink",children:c.turns.toLocaleString()})," 轮",c.errors>0?n("span",{className:"text-danger",children:[" (",c.errors," 错)"]}):null]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:c.toolCalls.toLocaleString()})," 次"]}),c.generationMs>0&&n("span",{children:["推理 ",e("span",{className:"text-ink",children:ae(c.generationMs)})]})]})]})]},c.model)})})}function ie(t){let{tools:u}=t,{StatusChip:g,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无工具调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100),f=c.successRate>=0.95?"success":c.successRate>=0.8?"warning":"danger",b=Math.max(0,c.calls-c.errors),w=c.calls>0?Math.round(c.outputBytes/c.calls):0;return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.name}),n(g,{tone:f,children:["成功率 ",B(c.successRate)]})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[n("span",{className:"text-xs font-medium text-ink",children:[c.calls.toLocaleString()," 次"]}),n("span",{className:"text-[11px] text-faint",children:["(",B(c.share),")"]})]})]}),e(K,{percent:a}),n(Y,{children:[n(G,{children:[n("span",{children:["成功 ",e("span",{className:"text-ink",children:b.toLocaleString()})," 次"]}),n("span",{children:["失败 ",e("span",{className:c.errors>0?"text-danger":"text-ink",children:c.errors.toLocaleString()})," 次"]})]}),n(G,{children:[n("span",{children:["累计输出 ",e("span",{className:"text-ink",children:Q(c.outputBytes)})]}),n("span",{children:["单次均值 ",e("span",{className:"text-ink",children:Q(w)})]})]})]})]},c.name)})})}function le(t){let{sessions:u,onOpenSession:g}=t,{style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无高消耗会话记录"});let c=Math.max(1,...u.map((a)=>a.totalTokens));return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let f=c>0?Math.max(1,a.totalTokens/c*100):0,b=a.model.split("/").pop()??a.model;return n("button",{type:"button",onClick:()=>g(a.id),className:"group block w-full p-4 text-left space-y-2.5 hover:bg-raised/40 transition-colors cursor-pointer",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate group-hover:text-accent transition-colors",children:a.title.trim()||"新会话"}),e("span",{className:p("control.badge","font-mono truncate max-w-[140px] shrink-0"),title:a.projectName,children:a.projectName}),a.kind==="sub"&&e("span",{className:"rounded bg-accent/15 px-1.5 py-0.5 text-[10.5px] text-accent shrink-0",children:"子代理"}),a.archivedAt!==null&&e("span",{className:p("control.badge","shrink-0"),children:"已归档"})]}),n("div",{className:"flex items-center gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),e(lt,{className:"size-3.5 text-faint group-hover:text-ink group-hover:translate-x-0.5 transition-all"})]})]}),e(K,{percent:f}),n(Y,{children:[e(J,{stat:a}),n(G,{children:[e("span",{className:"text-ink",children:b}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.assistantTurns})," 轮"]}),e("span",{className:"text-faint",children:se(a.updated)})]})]})]},a.id)})})}var ce=[{value:"tokens",label:"Token 用量"},{value:"duration",label:"活跃耗时"},{value:"activity",label:"交互轮次"}];function ue(t){let{cn:u,Segmented:g,SettingGroup:p,style:c}=y(),{daily:a}=t,[f,b]=r("tokens"),[w,C]=r(null),D=v(()=>a.some((s)=>s.totalTokens>0||s.activeDurationMs>0||s.runs>0),[a]),F=v(()=>{if(a.length===0)return{totalText:"0",avgText:"0",peakDate:"—",peakValueText:"0"};if(f==="tokens"){let S=a.reduce((_,A)=>_+A.totalTokens,0),R=a.filter((_)=>_.totalTokens>0).length,N=a[0];for(let _ of a)if(!N||_.totalTokens>N.totalTokens)N=_;return{totalText:M(S),totalFullText:L(S),avgText:R>0?M(Math.round(S/R)):"0",peakDate:N&&N.totalTokens>0?W(N.date):"—",peakValueText:N&&N.totalTokens>0?M(N.totalTokens):"0"}}if(f==="duration"){let S=a.reduce((_,A)=>_+A.activeDurationMs,0),R=a.filter((_)=>_.activeDurationMs>0).length,N=a[0];for(let _ of a)if(!N||_.activeDurationMs>N.activeDurationMs)N=_;return{totalText:P(S),totalFullText:P(S),avgText:R>0?P(Math.round(S/R)):"0s",peakDate:N&&N.activeDurationMs>0?W(N.date):"—",peakValueText:N&&N.activeDurationMs>0?P(N.activeDurationMs):"0s"}}let s=a.reduce((S,R)=>S+R.assistantTurns,0),l=a.reduce((S,R)=>S+R.userMessages,0),x=s+l,T=a.filter((S)=>S.assistantTurns>0||S.userMessages>0).length,k=a[0];for(let S of a){let R=k?k.assistantTurns+k.userMessages:0;if(!k||S.assistantTurns+S.userMessages>R)k=S}let H=k?k.assistantTurns+k.userMessages:0;return{totalText:`${x.toLocaleString()} 轮`,totalFullText:`助手 ${s.toLocaleString()} 轮 · 用户 ${l.toLocaleString()} 问`,avgText:T>0?`${(x/T).toFixed(1)} 轮/天`:"0 轮/天",peakDate:k&&H>0?W(k.date):"—",peakValueText:k&&H>0?`${H.toLocaleString()} 轮`:"0 轮"}},[a,f]),j=v(()=>{if(w){let s=a.find((l)=>l.date===w);if(s)return s}for(let s=a.length-1;s>=0;s--){let l=a[s];if(l&&(l.totalTokens>0||l.activeDurationMs>0||l.runs>0))return l}return a[a.length-1]},[a,w]),z=v(()=>{if(f==="tokens")return Math.max(1,...a.map((s)=>s.totalTokens));if(f==="duration")return Math.max(1000,...a.map((s)=>s.activeDurationMs));return Math.max(1,...a.map((s)=>s.assistantTurns+s.userMessages))},[a,f]),d=v(()=>{if(a.length<=7)return a.map((x)=>x.date);let s=6,l=[];for(let x=0;x<s;x++){let T=Math.round(x*(a.length-1)/(s-1)),k=a[T];if(k)l.push(k.date)}return l},[a]);if(!D)return e(p,{title:"每日趋势",action:e(g,{value:f,onChange:(s)=>b(s),options:ce}),children:e("div",{className:c("surface.empty"),children:"当前时间范围内暂无活跃数据"})});return e(p,{title:"每日趋势",action:e(g,{value:f,onChange:(s)=>b(s),options:ce}),children:n("div",{className:"p-4 space-y-4",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 font-mono text-dim tabular-nums",children:[n("span",{children:["汇总 ",e("span",{className:"text-ink",children:F.totalText})]}),n("span",{children:["日均 ",e("span",{className:"text-ink",children:F.avgText})]}),n("span",{children:["峰值 ",e("span",{className:"text-ink",children:F.peakValueText}),F.peakDate!=="—"?n("span",{className:"text-faint",children:[" (",F.peakDate,")"]}):null]})]}),n("div",{className:"flex items-center gap-3 text-[11px] text-dim",children:[f==="tokens"&&n(m,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent/40"}),"缓存读"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"输入"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"输出"]})]}),f==="duration"&&n(m,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"工作调度"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"模型推理"]})]}),f==="activity"&&n(m,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"助手回复"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"用户提问"]})]})]})]}),n("div",{className:"relative h-44 w-full pt-1",children:[n("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none pb-5 text-[10px] text-faint/60",children:[e("div",{className:"border-b border-line/40 w-full"}),e("div",{className:"border-b border-line/30 w-full"}),e("div",{className:"border-b border-line/40 w-full"})]}),n("section",{"aria-label":"每日趋势柱状序列",className:"relative h-full flex flex-col justify-between",onMouseLeave:()=>C(null),children:[e("div",{className:"flex-1 flex items-end gap-1 sm:gap-1.5 pb-2",children:a.map((s)=>{let l=s.totalTokens;if(f==="duration")l=s.activeDurationMs;else if(f==="activity")l=s.assistantTurns+s.userMessages;let x=l<=0,T=x?0:Math.max(3,Math.min(100,l/z*100)),k=j?.date===s.date;return n("button",{type:"button","aria-label":`${s.date} 统计数据`,className:"flex-1 h-full flex flex-col justify-end items-center group cursor-pointer relative min-w-0 bg-transparent p-0 border-0 focus:outline-hidden",onMouseEnter:()=>C(s.date),onFocus:()=>C(s.date),onClick:()=>C(s.date),children:[e("div",{className:u("absolute inset-y-0 w-full rounded-xs transition-colors pointer-events-none",k?"bg-accent/10":"group-hover:bg-raised/60")}),x?e("div",{className:"h-1 w-full max-w-[24px] rounded-full bg-raised group-hover:bg-dim/30"}):n("div",{className:"w-full max-w-[24px] rounded-t-xs overflow-hidden flex flex-col justify-end transition-all duration-150",style:{height:`${T}%`},children:[f==="tokens"&&n(m,{children:[s.outputTokens>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.outputTokens/s.totalTokens*100}%`}}),s.inputTokens+s.cacheWriteTokens>0&&e("div",{className:"bg-accent transition-all duration-200",style:{height:`${(s.inputTokens+s.cacheWriteTokens)/s.totalTokens*100}%`}}),s.cacheReadTokens>0&&e("div",{className:"bg-accent/40 transition-all duration-200",style:{height:`${s.cacheReadTokens/s.totalTokens*100}%`}})]}),f==="duration"&&n(m,{children:[s.generationMs>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${Math.min(100,s.generationMs/Math.max(1,s.activeDurationMs)*100)}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]}),f==="activity"&&n(m,{children:[s.userMessages>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.userMessages/Math.max(1,s.assistantTurns+s.userMessages)*100}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]})]}),k&&e("div",{className:"absolute -bottom-1 size-1 rounded-full bg-accent"})]},s.date)})}),e("div",{className:u("flex items-center pt-1.5 text-[10px] text-faint font-mono tabular-nums",a.length<=7?"gap-1 sm:gap-1.5":"justify-between"),children:d.map((s)=>e("div",{className:u("whitespace-nowrap",a.length<=7&&"flex-1 text-center"),children:W(s)},s))})]})]}),e("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-line pt-3 font-mono text-xs tabular-nums",children:j?n(m,{children:[e("span",{className:"text-ink",children:Z(j.date)}),n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 text-dim",children:[n("span",{children:["Token ",e("span",{className:"text-ink",children:M(j.totalTokens)})]}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(j.activeDurationMs)})]}),n("span",{children:["交互 ",n("span",{className:"text-ink",children:[j.assistantTurns+j.userMessages," 轮"]})]}),n("span",{children:["工具 ",n("span",{className:"text-ink",children:[j.toolCalls," 次"]})]})]})]}):e("span",{className:"font-sans text-faint",children:"悬停柱状图查看单日明细"})})]})})}function pe(t){let{cn:u,SettingGroup:g}=y(),{daily:p,hourly:c}=t,[a,f]=r(null),b=v(()=>{let l=new Map;for(let T of c)l.set(T.hour,T);let x=[];for(let T=0;T<24;T++){let k=l.get(T);if(k)x.push(k);else x.push({hour:T,totalTokens:0,activeDurationMs:0,userMessages:0,assistantTurns:0,runs:0})}return x},[c]),w=v(()=>{let l=b[0];for(let x of b)if(!l||x.totalTokens>l.totalTokens)l=x;return l&&l.totalTokens>0?l:null},[b]),C=v(()=>b.reduce((l,x)=>l+x.totalTokens,0),[b]),D=v(()=>Math.max(1,...b.map((l)=>l.totalTokens)),[b]),F=v(()=>{if(C<=0)return 0;return b.filter((x)=>x.hour>=8&&x.hour<20).reduce((x,T)=>x+T.totalTokens,0)/C},[b,C]),j=v(()=>Math.max(1,...p.map((l)=>l.totalTokens)),[p]),z=v(()=>{let l=0,x=0;for(let T of p)if(T.totalTokens>0||T.activeDurationMs>0||T.runs>0){if(x++,x>l)l=x}else x=0;return l},[p]),d=v(()=>p.filter((l)=>l.totalTokens>0||l.activeDurationMs>0||l.runs>0).length,[p]),s=a!==null?b[a]:w;return n(g,{title:"活跃时段与热力",action:n("div",{className:"flex items-center gap-3 font-mono text-xs text-faint tabular-nums",children:[n("span",{children:["日间占比 ",B(F)]}),n("span",{children:["连续活跃 ",z," 天"]}),n("span",{children:["活跃 ",d,"/",p.length," 天"]})]}),children:[n("div",{className:"p-4 space-y-3",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[e("span",{className:"text-dim",children:"24 小时分布"}),s?n("div",{className:"flex items-center gap-3 font-mono text-dim tabular-nums",children:[n("span",{className:"text-ink",children:[a!==null?"时段 ":"高峰 ",String(s.hour).padStart(2,"0"),":00 -"," ",String((s.hour+1)%24).padStart(2,"0"),":00"]}),e("span",{className:"text-ink",children:M(s.totalTokens)}),s.activeDurationMs>0&&e("span",{children:P(s.activeDurationMs)})]}):e("span",{className:"text-faint",children:"暂无时段分布"})]}),n("section",{"aria-label":"24 小时活跃分布序列",className:"h-28 w-full flex flex-col justify-between pt-1",onMouseLeave:()=>f(null),children:[e("div",{className:"flex-1 flex items-end gap-1.5 pb-1.5",children:b.map((l)=>{let x=w?.hour===l.hour,T=a===l.hour,k=l.totalTokens>0?Math.max(6,l.totalTokens/D*100):0,H=`${String(l.hour).padStart(2,"0")}:00 - ${String((l.hour+1)%24).padStart(2,"0")}:00
|
|
2
2
|
消耗: ${L(l.totalTokens)} Token
|
|
3
3
|
耗时: ${P(l.activeDurationMs)}
|
|
4
4
|
助手轮次: ${l.assistantTurns} 轮`;return e("button",{type:"button","aria-label":`${String(l.hour).padStart(2,"0")}:00 时段统计`,className:"flex-1 h-full flex flex-col justify-end items-center group relative cursor-pointer bg-transparent p-0 border-0 focus:outline-hidden",title:H,onMouseEnter:()=>f(l.hour),onFocus:()=>f(l.hour),onClick:()=>f(l.hour),children:k>0?e("div",{className:u("w-full max-w-[20px] rounded-t-xs transition-all duration-200",x||T?"bg-accent":"bg-accent/55 group-hover:bg-accent"),style:{height:`${k}%`}}):e("div",{className:"h-1 w-full max-w-[20px] rounded-full bg-raised group-hover:bg-dim/30"})},l.hour)})}),n("div",{className:"flex justify-between items-center text-[10px] text-faint font-mono pt-1.5 border-t border-line/40",children:[e("span",{children:"00:00"}),e("span",{children:"04:00"}),e("span",{children:"08:00"}),e("span",{children:"12:00"}),e("span",{children:"16:00"}),e("span",{children:"20:00"}),e("span",{children:"23:00"})]})]})]}),n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"text-xs text-dim",children:["自然日热力 (",p.length," 天)"]}),e("div",{className:"flex flex-wrap items-center gap-1.5",children:p.map((l)=>{let x="bg-raised";if(l.totalTokens>0){let k=l.totalTokens/j;if(k<=0.33)x="bg-accent/30";else if(k<=0.66)x="bg-accent/60";else x="bg-accent"}let T=`${Z(l.date)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Bi}from"./chunk-tfsrk2rc.js";export{Bi as createTreeViewServices};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o,G,i,r,m,e,n,y,te,
|
|
1
|
+
import{o,G,i,r,m,e,n,y,te,re}from"./chunk-bcp6na49.js";import{ia}from"./chunk-nx1bcekh.js";var T=[{id:"exa",name:"Exa",description:"免密钥 · 综合搜索"},{id:"tavily",name:"Tavily",description:"免密钥 · 支持域名筛选"},{id:"parallel",name:"Parallel",description:"免密钥 · 网页搜索"},{id:"firecrawl",name:"Firecrawl",description:"免密钥 · 网页内容"},{id:"tinyfish",name:"TinyFish",description:"免密钥 · 搜索摘要"},{id:"searxng",name:"SearXNG",description:"免密钥 · 需自建服务"},{id:"brave",name:"Brave",description:"需密钥 · 独立搜索引擎"}];function D(t){return{enabled:t.search.provider!=="off",provider:t.search.provider==="off"?"auto":t.search.provider,searxngUrl:t.search.searxngUrl??"",proxy:t.proxy??"",acceptLanguage:t.acceptLanguage??""}}function I(t,c){return{search:{provider:t.enabled?t.provider:"off",searxngUrl:t.searxngUrl},keys:{...c},proxy:t.proxy,acceptLanguage:t.acceptLanguage}}function A(t,c,u){let p=D(t);if(c.enabled!==p.enabled)return!0;if(c.enabled&&c.provider!==p.provider)return!0;return c.searxngUrl!==p.searxngUrl||c.proxy!==p.proxy||c.acceptLanguage!==p.acceptLanguage||Object.keys(u).length>0}function z({notice:t}){let{cn:c}=y();if(!t)return null;let u=t.type==="success"?ia:te;return n("div",{role:t.type==="error"?"alert":"status",className:c("flex items-start gap-2 text-xs",t.type==="success"?"text-success":"text-danger"),children:[e(u,{className:"mt-0.5 size-4 shrink-0","aria-hidden":"true"}),e("span",{className:"min-w-0 break-words",children:t.text})]})}function q(t){let{Button:c,Input:u,Switch:p,Select:x,StatusChip:S,SettingActions:R,SettingGroup:P,SettingRow:C,cn:w}=y(),b=G(),l=t.busy!==void 0;return n("form",{id:`${b}-form`,className:"min-w-0 space-y-5",onSubmit:async(s)=>{s.preventDefault(),await t.onSave()},children:[n(P,{title:"联网搜索",children:[e(C,{title:"启用搜索",description:"查询会发送至所选搜索服务",children:e(p,{label:"启用联网搜索",disabled:l,checked:t.draft.enabled,onCheckedChange:(s)=>t.onDraft({...t.draft,enabled:s})})}),e(C,{title:"搜索渠道",description:"自动:Exa → Tavily → Parallel → Firecrawl → TinyFish",children:e("div",{className:"w-48",children:e(x,{id:`${b}-provider`,value:t.draft.provider,disabled:l||!t.draft.enabled,className:"min-w-0",groups:[{options:[{value:"auto",label:"自动",description:"失败时依次切换渠道"},...T.map((s)=>({value:s.id,label:s.name}))]}],onValueChange:(s)=>{let a=s==="auto"?s:T.find((k)=>k.id===s)?.id;if(a)t.onDraft({...t.draft,provider:a})}})})}),(t.draft.provider==="searxng"||t.draft.searxngUrl)&&e(C,{vertical:!0,title:"自建 SearXNG 地址",children:e(u,{id:`${b}-searxng`,"aria-label":"自建 SearXNG 地址",type:"url",maxLength:2000,disabled:l||!t.draft.enabled,value:t.draft.searxngUrl,placeholder:"https://search.example.com",onChange:(s)=>t.onDraft({...t.draft,searxngUrl:s.target.value})})})]}),e(P,{title:"渠道与密钥",description:"检测使用已保存的配置",action:n(c,{type:"button",size:"sm",variant:"ghost",disabled:l,className:"text-dim",onClick:async()=>await t.onCheck("all"),children:[e(re,{className:w("size-3.5",t.checking==="all"&&"animate-spin"),"aria-hidden":"true"}),t.checking==="all"?"正在检测…":"全部检测"]}),children:T.map((s)=>{let a=s.id,k=a==="searxng"?void 0:t.saved.keys[a],K=k?.source==="environment",W=a==="searxng"?void 0:t.keys[a],h=W==="",v=t.checks[a],L=t.checking==="all"||t.checking===a,f=k?.configured?"已配置密钥":"未配置";if(a==="searxng")f=t.saved.search.searxngUrl?"已配置地址":"未配置地址";if(K)f="来自环境变量";if(h)f="待移除";if(W)f="待保存密钥";let E=v&&!v.ok&&!L?v.error??(v.kind==="search"?v.meta?.failed[0]?.error:v.meta?.error)??"检测失败,请检查配置。":void 0;return n("div",{className:"min-w-0",children:[n(C,{title:s.name,description:n(m,{children:[s.description,K&&" · 请在服务端环境变量中更换或移除",E&&e("span",{role:"status",className:"block break-words text-danger",children:E})]}),children:[L?e(S,{tone:"neutral",pulse:!0,children:"检测中"}):v?e(S,{tone:v.ok?"success":"danger",children:v.ok?`可用 ${v.elapsedMs} ms`:"不可用"}):e("span",{className:w("text-xs",W!==void 0?"text-warning":"text-faint"),children:f}),a!=="searxng"&&!K&&n(m,{children:[e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,"aria-label":`${k?.configured?"更换":"设置"} ${s.name} 密钥`,"aria-expanded":t.editingKey===a,"aria-controls":`${b}-${a}-key-editor`,onClick:()=>t.onEditKey(t.editingKey===a?void 0:a),children:k?.configured?"更换":"设置密钥"}),k?.configured&&!h&&e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,"aria-label":`移除 ${s.name} 密钥`,onClick:()=>{t.onKeys({...t.keys,[a]:""}),t.onEditKey(void 0)},children:"移除"})]}),e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,"aria-label":`检测 ${s.name}`,onClick:async()=>await t.onCheck(a),children:"检测"})]}),a!=="searxng"&&t.editingKey===a&&n("div",{id:`${b}-${a}-key-editor`,className:"flex items-center gap-2 pb-3",children:[e(u,{id:`${b}-${a}-key`,"aria-label":`${s.name} API 密钥`,type:"password",autoComplete:"new-password",maxLength:4000,disabled:l,value:t.keys[a]??"",placeholder:"输入新密钥,保存后生效;只写入,不回显",onChange:(N)=>{let d={...t.keys};if(N.target.value.trim())d[a]=N.target.value;else delete d[a];t.onKeys(d)}}),e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,onClick:()=>{let N={...t.keys};delete N[a],t.onKeys(N),t.onEditKey(void 0)},children:"取消"})]})]},a)})}),n(P,{title:"网络",children:[e(C,{vertical:!0,title:"代理 URL",description:"留空使用服务端环境代理",children:e(u,{id:`${b}-proxy`,"aria-label":"代理 URL",type:"url",maxLength:2000,disabled:l,value:t.draft.proxy,placeholder:"http://127.0.0.1:7890",onChange:(s)=>t.onDraft({...t.draft,proxy:s.target.value})})}),e(C,{vertical:!0,title:"Accept-Language",children:e(u,{id:`${b}-language`,"aria-label":"Accept-Language",maxLength:200,disabled:l,value:t.draft.acceptLanguage,placeholder:"en-US,en;q=0.9",onChange:(s)=>t.onDraft({...t.draft,acceptLanguage:s.target.value})})})]}),n(R,{children:[e("div",{className:"mr-auto min-w-0",children:e(z,{notice:t.notice})}),t.dirty&&e(c,{type:"button",size:"sm",variant:"ghost",disabled:l,onClick:t.onRestore,children:"撤销更改"}),e(c,{form:`${b}-form`,type:"submit",size:"sm",variant:"primary",disabled:l||!t.dirty,children:t.busy==="save"?"保存中…":"保存"})]})]})}function O({connection:t}){let{Button:c}=y(),[u,p]=r(),[x,S]=r(),[R,P]=r({}),[C,w]=r(),[b,l]=r("load"),[s,a]=r(),[k,K]=r({}),[W,h]=r(),[v,L]=r(0),f=i(void 0);o(()=>{let d=new AbortController;return f.current=d,l("load"),h(void 0),p(void 0),S(void 0),P({}),w(void 0),K({}),t.request("/api/plugins/webfetch/settings",{signal:d.signal,cache:v>0?"reload":"default"}).then((g)=>{if(d.signal.aborted)return;p(g),S(D(g))}).catch((g)=>{if(!d.signal.aborted)h({type:"error",text:g instanceof Error?g.message:"加载设置失败,请重试。"})}).finally(()=>{if(!d.signal.aborted)f.current=void 0,l(void 0)}),()=>{d.abort(),f.current?.abort(),f.current=void 0}},[t,v]);async function E(){if(f.current||!u||!x||!A(u,x,R))return;let d=new AbortController;f.current=d,l("save"),h(void 0);try{let g=await t.request("/api/plugins/webfetch/settings",{method:"PATCH",signal:d.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify(I(x,R))});if(d.signal.aborted)return;p(g),S(D(g)),P({}),w(void 0),K({}),h({type:"success",text:"设置已保存。"})}catch(g){if(!d.signal.aborted)h({type:"error",text:g instanceof Error?g.message:"保存失败,请重试。"})}finally{if(!d.signal.aborted)f.current=void 0,l(void 0)}}async function N(d){if(f.current||!u)return;let g=new AbortController;f.current=g,l("test"),a(d),h(void 0);try{let U=await t.request(`/api/plugins/webfetch/test?provider=${d}`,{method:"POST",signal:g.signal});if(g.signal.aborted)return;K((M)=>{let F={...M};for(let B of U.checks)if(B.kind==="search"&&B.provider)F[B.provider]=B;return F})}catch(U){if(!g.signal.aborted)h({type:"error",text:U instanceof Error?U.message:"检测失败,请重试。"})}finally{if(!g.signal.aborted)f.current=void 0,l(void 0),a(void 0)}}if(!u||!x)return n("div",{className:"min-w-0 space-y-3",children:[b==="load"&&e("p",{role:"status",className:"text-sm text-dim",children:"正在加载设置…"}),e(z,{notice:W}),b!=="load"&&e(c,{type:"button",size:"sm",variant:"ghost",onClick:()=>L(v+1),children:"重新加载"})]});return e(q,{saved:u,draft:x,keys:R,editingKey:C,dirty:A(u,x,R),busy:b==="load"?void 0:b,checking:s,checks:k,notice:W,onDraft:(d)=>{S(d),h(void 0)},onKeys:(d)=>{P(d),h(void 0)},onEditKey:w,onSave:E,onCheck:N,onRestore:()=>{S(D(u)),P({}),w(void 0),h(void 0)}})}export{O as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ii}from"./chunk-tfsrk2rc.js";export{Ii as createTreemapServices};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{B,o,v,i,r,m,e,n,y,U,
|
|
2
|
-
`):t}function z(){return n("div",{role:"status","aria-busy":"true","aria-label":"正在加载上下文",className:"space-y-2 animate-pulse",children:[e("div",{className:"h-10 rounded-xl border border-line bg-panel/40"}),e("div",{className:"h-10 rounded-xl border border-line bg-panel/40"}),e("div",{className:"h-10 rounded-xl border border-line bg-panel/40"})]})}function k(t){let{style:c}=y();return e("p",{className:c("surface.empty"),children:t.children})}function E(t){let{Code:c}=y();return e(c,{code:t.code,lang:t.lang,className:"text-[11px]! leading-relaxed! [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_pre]:[overflow-wrap:anywhere]"})}function O(t){let{cn:c}=y();if(!t.items.length)return e(k,{children:"新会话还没有上下文。发送第一条消息后,这里会显示构成。"});let d=t.items.reduce((s,a)=>s+a.tokens,0)||1;return n("div",{className:"space-y-2.5",children:[e("div",{className:"flex h-2 overflow-hidden rounded-full bg-raised",children:t.items.map((s,a)=>e("span",{className:c(R[a%R.length],"transition-[width] duration-300 ease-out-quint"),title:`${s.label}:${s.tokens.toLocaleString()} token`,style:{width:`${s.tokens/d*100}%`}},s.id))}),e("div",{className:"space-y-1.5",children:t.items.map((s,a)=>e(Q,{item:s,total:d,index:a,color:R[a%R.length]??"bg-accent"},s.id))})]})}function Q(t){let{cn:c,Chevron:d,CopyButton:s,style:a,useTheme:u}=y();u();let[p,f]=r(!1),g=(t.item.tokens/t.total*100).toFixed(1),l=v(()=>p&&t.item.detail?
|
|
1
|
+
import{B,o,v,i,r,m,e,n,y,U,ki,Mo,so,Fr,ir,Po,lo,Oo,ua,da,Fn,Ci,Si}from"./chunk-bcp6na49.js";var D={sealed:"已封存",folded:"已折叠",archived:"已移出"},R=["bg-accent","bg-accent-strong","bg-warning","bg-success"];function W(t,c){if(t.startsWith("recent-"))return"json";let d=c.trimStart();if(!d)return"markdown";if(d.startsWith("{")||d.startsWith("["))return"json";if(/^<[a-zA-Z_][\w.-]*(?:\s+[^>]*)?>/.test(d))return"xml";return"markdown"}function A(t){if(!t||t.length>32000)return t;if(!t.trimStart().startsWith("<"))return t;let d=[],s=0,a=(p)=>" ".repeat(p),u=/(<([a-zA-Z_][\w.-]*)(?:\s+[^>]*)?>([^\r\n<]*)<\/\2>)|(<\/[a-zA-Z_][\w.-]*>)|(<[a-zA-Z_][\w.-]*(?:\s+[^>]*)?\/>)|(<[a-zA-Z_][\w.-]*(?:\s+[^>]*)?>)|([^<]+)/g;for(let p of t.matchAll(u)){let[,f,,,g,l,x,h]=p;if(f)d.push(`${a(s)}${f.trim()}`);else if(g)s=Math.max(0,s-1),d.push(`${a(s)}${g.trim()}`);else if(x)d.push(`${a(s)}${x.trim()}`),s++;else if(l)d.push(`${a(s)}${l.trim()}`);else if(h){let N=h.trim();if(N)for(let S of N.split(/\r?\n/)){let I=S.trim();if(I)d.push(`${a(s)}${I}`)}}}return d.length>0?d.join(`
|
|
2
|
+
`):t}function z(){return n("div",{role:"status","aria-busy":"true","aria-label":"正在加载上下文",className:"space-y-2 animate-pulse",children:[e("div",{className:"h-10 rounded-xl border border-line bg-panel/40"}),e("div",{className:"h-10 rounded-xl border border-line bg-panel/40"}),e("div",{className:"h-10 rounded-xl border border-line bg-panel/40"})]})}function k(t){let{style:c}=y();return e("p",{className:c("surface.empty"),children:t.children})}function E(t){let{Code:c}=y();return e(c,{code:t.code,lang:t.lang,className:"text-[11px]! leading-relaxed! [&_pre]:whitespace-pre-wrap [&_pre]:break-words [&_pre]:[overflow-wrap:anywhere]"})}function O(t){let{cn:c}=y();if(!t.items.length)return e(k,{children:"新会话还没有上下文。发送第一条消息后,这里会显示构成。"});let d=t.items.reduce((s,a)=>s+a.tokens,0)||1;return n("div",{className:"space-y-2.5",children:[e("div",{className:"flex h-2 overflow-hidden rounded-full bg-raised",children:t.items.map((s,a)=>e("span",{className:c(R[a%R.length],"transition-[width] duration-300 ease-out-quint"),title:`${s.label}:${s.tokens.toLocaleString()} token`,style:{width:`${s.tokens/d*100}%`}},s.id))}),e("div",{className:"space-y-1.5",children:t.items.map((s,a)=>e(Q,{item:s,total:d,index:a,color:R[a%R.length]??"bg-accent"},s.id))})]})}function Q(t){let{cn:c,Chevron:d,CopyButton:s,style:a,useTheme:u}=y();u();let[p,f]=r(!1),g=(t.item.tokens/t.total*100).toFixed(1),l=v(()=>p&&t.item.detail?ir(t.item.detail):"",[p,t.item.detail]),x=v(()=>l?W(t.item.id,l):"markdown",[l,t.item.id]),h=v(()=>{if(!l)return"";return x==="xml"?A(l):l},[l,x]);return n("div",{"data-state":p?"open":"closed",className:a("surface.interactive","group/collapsible"),children:[n("button",{type:"button","aria-expanded":p,onClick:()=>f((N)=>!N),className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs",children:[e("span",{className:c("size-2 shrink-0 rounded-full",t.color),"aria-hidden":!0}),e("span",{className:"min-w-0 flex-1 truncate font-medium text-ink",children:t.item.label}),t.item.state&&e("span",{className:a("control.badge","text-[10px]"),children:D[t.item.state]}),e("span",{className:"font-mono tabular-nums text-dim",children:t.item.tokens.toLocaleString()}),n("span",{className:"w-10 text-right font-mono text-[11px] tabular-nums text-faint",children:[g,"%"]}),e(d,{className:"-rotate-90 text-faint group-data-[state=open]/collapsible:rotate-90"})]}),p&&n("div",{className:"border-t border-line/60 bg-raised/20 px-3 py-2 text-xs text-dim",children:[e("div",{className:"mb-2 h-1 overflow-hidden rounded-full bg-raised",children:e("div",{className:c("h-full",t.color),style:{width:`${g}%`}})}),h?n("div",{className:a("surface.subtle","group/detail relative overflow-hidden rounded-lg bg-panel/70 p-2.5"),children:[e("div",{className:"absolute right-1.5 top-1.5 z-10",children:e(s,{text:t.item.detail,size:"icon-xs",className:"bg-raised/60 hover:bg-raised text-faint hover:text-ink backdrop-blur-sm"})}),e("div",{className:"max-h-80 overflow-y-auto pr-6 text-dim",children:e(E,{code:h,lang:x})})]}):e("p",{className:"py-2 text-center text-xs text-faint",children:"(空)"})]})]})}var M=40,Y={accent:"bg-accent/15 text-accent",success:"bg-success/15 text-success",warning:"bg-warning/15 text-warning",danger:"bg-danger/15 text-danger",neutral:"bg-raised text-dim"};function L(t){let{Button:c,CopyButton:d,style:s,useTheme:a}=y();a();let[u,p]=r(M),f=i(null),g=u<t.entries.length;o(()=>{let x=f.current;if(!x||!g||typeof IntersectionObserver>"u")return;let h=new IntersectionObserver((N)=>{if(N.some((S)=>S.isIntersecting))p((S)=>Math.min(t.entries.length,S+M))},{rootMargin:"480px"});return h.observe(x),()=>h.disconnect()},[g,t.entries.length]);let l=v(()=>t.entries.slice(-u).reverse(),[t.entries,u]);if(!t.entries.length)return e(k,{children:"还没有消息。"});return n("div",{className:"space-y-1.5",children:[n("div",{className:s("surface.subtle","flex items-center justify-between px-3 py-1.5 text-xs text-faint"),children:[n("span",{children:["共 ",t.entries.length," 条记录"]}),e(d,{text:()=>t.entries.map((x)=>JSON.stringify(x,null,2)).join(`
|
|
3
3
|
|
|
4
|
-
`),size:"icon-xs",label:"复制全部原始 JSON",className:"hover:bg-raised text-faint hover:text-ink"})]}),l.map((x)=>e(ee,{entry:x},x.seq)),g&&n("div",{ref:f,className:s("surface.subtle","flex items-center justify-between bg-panel/40 px-3 py-2 text-xs text-faint"),children:[n("span",{children:["已显示 ",l.length," / ",t.entries.length," 条"]}),n("div",{className:"flex items-center gap-1.5",children:[e(c,{size:"sm",variant:"ghost",onClick:()=>p((x)=>Math.min(t.entries.length,x+M)),children:"加载更多"}),e(c,{size:"sm",variant:"ghost",onClick:()=>p(t.entries.length),children:"显示全部"})]})]})]})}var ee=B(function(c){let{Chevron:d,CopyButton:s,style:a,useTheme:u}=y();u();let[p,f]=r(!1),g=Io(c.entry),l=v(()=>Lo(c.entry.time),[c.entry.time]);return n("div",{"data-state":p?"open":"closed",className:a("surface.interactive","group/collapsible"),children:[n("button",{type:"button","aria-expanded":p,onClick:()=>f((x)=>!x),className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs",children:[n("span",{className:"shrink-0 font-mono text-[10.5px] tabular-nums text-faint",children:["#",c.entry.seq]}),e("span",{className:a("control.badge","shrink-0 font-medium text-[10px]",Y[g.tone]),children:g.badge}),e("span",{className:"min-w-0 flex-1 truncate text-ink",children:g.title}),g.meta&&e("span",{className:a("control.badge","shrink-0 font-mono text-[10px] text-faint"),children:g.meta}),e("span",{className:"shrink-0 font-mono text-[10.5px] tabular-nums text-faint",children:l}),e(d,{className:"-rotate-90 text-faint group-data-[state=open]/collapsible:rotate-90"})]}),p&&e("div",{className:"border-t border-line/60 bg-raised/20 px-3 py-2.5 text-xs text-dim",children:n("div",{className:"space-y-2",children:[n("div",{className:"flex items-center justify-between text-[11px] text-faint",children:[n("span",{className:"font-mono",children:[c.entry.type," · #",c.entry.seq]}),e(s,{text:()=>JSON.stringify(c.entry,null,2),size:"icon-xs",label:"复制此条 JSON",className:"bg-raised/60 hover:bg-raised text-faint hover:text-ink"})]}),e(te,{entry:c.entry})]})})]})});function te(t){let{style:c,useTheme:d}=y();d();let s=t.entry;if(s.type==="user")return n("div",{className:"space-y-2",children:[s.text&&e("pre",{className:c("surface.subtle","max-h-72 overflow-y-auto p-2.5 font-sans text-xs leading-relaxed text-ink whitespace-pre-wrap break-words [overflow-wrap:anywhere]"),children:Br(s.text)}),s.attachments&&s.attachments.length>0&&n("div",{className:"space-y-1",children:[n("div",{className:"text-[10.5px] font-medium text-faint",children:["附件(",s.attachments.length,")"]}),e("div",{className:"flex flex-wrap gap-1.5",children:s.attachments.map((a,u)=>{let p=a.kind==="image"?Math.floor(a.data.length*0.75):a.data.length;return n("div",{className:c("surface.subtle","inline-flex items-center gap-1.5 px-2 py-1 text-[11px]"),children:[e("span",{className:c("control.badge","text-[10px] text-faint"),children:a.kind==="image"?"图片":a.kind==="path"?"路径":"文本"}),e("span",{className:"max-w-40 truncate font-medium text-ink",children:a.name}),n("span",{className:"font-mono text-[10px] text-faint",children:[a.mimeType," · ",ro(p)]})]},`${a.name}-${u}`)})})]}),s.notices&&s.notices.length>0&&n("div",{className:"space-y-1",children:[n("div",{className:"text-[10.5px] font-medium text-faint",children:["通知来源(",s.notices.length,")"]}),s.notices.map((a)=>n("div",{className:c("surface.subtle","flex items-center justify-between px-2.5 py-1.5 font-mono text-[11px]"),children:[n("span",{className:"truncate text-ink",children:[a.sourceKind,"/",a.sourceID]}),e("span",{className:"text-faint",children:a.state})]},a.dedupeKey))]})]});if(s.type==="assistant")return n("div",{className:"space-y-2",children:[n("div",{className:"font-mono text-[11px] text-faint",children:["模型:",s.model]}),s.error&&e("div",{className:"rounded-lg border border-danger/30 bg-danger/8 px-2.5 py-2 text-xs text-danger",children:s.error}),s.parts.map((a,u)=>{if(a.type==="thinking")return n("div",{className:c("surface.subtle","p-2.5 space-y-1"),children:[e("div",{className:"text-[10.5px] font-medium text-faint",children:"思考"}),e("pre",{className:"max-h-60 overflow-y-auto font-sans text-xs italic leading-relaxed text-dim whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:Br(a.text)})]},`thinking-${u}`);if(a.type==="text")return n("div",{className:c("surface.subtle","p-2.5 space-y-1"),children:[e("div",{className:"text-[10.5px] font-medium text-faint",children:"回复"}),e("pre",{className:"max-h-60 overflow-y-auto font-sans text-xs leading-relaxed text-ink whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:Br(a.text)})]},`text-${u}`);return n("div",{className:c("surface.subtle","p-2.5 space-y-1.5"),children:[n("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[n("span",{className:"font-mono font-medium text-ink",children:["工具调用 · ",a.name]}),e("span",{className:"truncate font-mono text-[10px] text-faint",children:a.id})]}),e("div",{className:"max-h-60 overflow-y-auto text-dim",children:e(E,{code:ar(JSON.stringify(a.input,ao,2)),lang:"json"})})]},a.id||`tool-${u}`)})]});if(s.type==="tool_result")return n("div",{className:"space-y-2",children:[n("div",{className:"flex flex-wrap items-center gap-2 font-mono text-[11px] text-faint",children:[e("span",{className:"text-ink",children:s.name}),e("span",{children:"·"}),e("span",{className:"truncate",children:s.callID}),e("span",{className:c("control.badge","ml-auto font-sans text-[10px]",s.isError?"bg-danger/15 text-danger":"text-dim"),children:s.isError?"执行失败":"执行完成"})]}),s.images&&s.images.length>0&&e("div",{className:"flex flex-wrap gap-1.5",children:s.images.map((a,u)=>n("span",{className:c("surface.subtle","px-2 py-1 font-mono text-[10.5px] text-faint"),children:["图片 #",u+1," · ",a.mimeType," · ",ro(Math.floor(a.data.length*0.75))]},`${a.mimeType}-${u}`))}),bi(s.output)?e("pre",{className:c("surface.subtle","max-h-72 overflow-y-auto p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words [overflow-wrap:anywhere]",s.isError?"text-danger":"text-dim"),children:Br(s.output)}):e("p",{className:"py-1 text-faint",children:"(无文本输出)"})]});return e("pre",{className:c("surface.subtle","max-h-72 overflow-y-auto p-2.5 font-mono text-[11px] leading-relaxed text-dim whitespace-pre-wrap break-words [overflow-wrap:anywhere]"),children:Do(s)})}function j(t){let{cn:c,style:d,useTheme:s}=y();if(s(),!t.todos.length)return e(k,{children:"暂无待办。"});return e("ul",{className:"space-y-1.5",children:t.todos.map((a)=>n("li",{className:d("surface.interactive","flex items-start gap-2.5 px-3 py-2 text-xs"),children:[n("span",{className:c("mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors duration-300",a.status==="completed"&&"border-success bg-success text-panel",a.status==="in_progress"&&"border-accent",a.status==="pending"&&"border-line-strong"),children:[a.status==="completed"&&e(U,{className:"size-2.5 animate-pop",strokeWidth:3.5}),a.status==="in_progress"&&e("span",{className:"size-1.5 animate-pulse rounded-full bg-accent"})]}),e("span",{className:c("min-w-0 flex-1 break-words leading-relaxed [overflow-wrap:anywhere]",a.status==="completed"&&"text-faint line-through decoration-faint/60",a.status==="in_progress"&&"font-medium text-ink",a.status==="pending"&&"text-dim"),children:a.content})]},`${a.status}-${a.content}`))})}function F(t){let{cn:c,style:d,useTheme:s}=y();s();let[a,u]=r("all"),p=v(()=>t.tools.filter((l)=>l.deferred).length,[t.tools]),f=t.tools.length-p,g=v(()=>{if(a==="deferred")return t.tools.filter((l)=>l.deferred);if(a==="active")return t.tools.filter((l)=>!l.deferred);return t.tools},[t.tools,a]);if(!t.tools.length)return e(k,{children:"当前会话没有可用工具。"});return n("div",{className:"space-y-2",children:[p>0&&n("div",{className:"flex items-center gap-1 text-[11px]",children:[n("button",{type:"button",onClick:()=>u("all"),className:c("rounded-lg px-2 py-1 transition-colors",a==="all"?"bg-raised font-medium text-ink":"text-faint hover:text-dim"),children:["全部 (",t.tools.length,")"]}),n("button",{type:"button",onClick:()=>u("active"),className:c("rounded-lg px-2 py-1 transition-colors",a==="active"?"bg-raised font-medium text-ink":"text-faint hover:text-dim"),children:["常驻 (",f,")"]}),n("button",{type:"button",onClick:()=>u("deferred"),className:c("rounded-lg px-2 py-1 transition-colors",a==="deferred"?"bg-raised font-medium text-ink":"text-faint hover:text-dim"),children:["延迟加载 (",p,")"]})]}),e("div",{className:"space-y-1.5",children:g.map((l)=>e(ae,{tool:l},`${l.group}-${l.name}`))})]})}function ae(t){let{Chevron:c,CopyButton:d,style:s,useTheme:a}=y();a();let[u,p]=r(!1),f=v(()=>u?JSON.stringify(t.tool.schema,null,2):"",[u,t.tool.schema]);return n("div",{"data-state":u?"open":"closed",className:s("surface.interactive","group/collapsible"),children:[n("button",{type:"button","aria-expanded":u,onClick:()=>p((g)=>!g),className:"flex w-full items-center justify-between px-3 py-2 text-left text-xs",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 truncate font-mono text-ink",children:[e("span",{className:"truncate",children:t.tool.name}),t.tool.group&&e("span",{className:s("control.badge","font-sans text-[10px]"),children:t.tool.group}),t.tool.deferred&&e("span",{className:s("control.badge","font-sans text-[10px]"),children:"延迟加载"})]}),e(c,{className:"-rotate-90 text-faint group-data-[state=open]/collapsible:rotate-90"})]}),u&&n("div",{className:"border-t border-line/60 bg-raised/20 px-3 py-2 text-xs text-dim",children:[t.tool.deferred&&e("div",{className:s("surface.subtle","mb-2 px-2.5 py-1.5 text-[11px] text-faint"),children:"延迟加载:此工具默认以精简描述挂载,模型通过 toolsearch 取回定义后才向上下文注入完整参数 Schema。"}),t.tool.description&&e("pre",{className:"mb-2 max-h-60 overflow-y-auto font-sans text-xs leading-relaxed text-dim whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:ar(t.tool.description)}),n("div",{className:s("surface.subtle","group/schema relative overflow-hidden rounded-lg p-2.5"),children:[e("div",{className:"absolute right-1.5 top-1.5 z-10",children:e(d,{text:f,size:"icon-xs",className:"bg-raised/60 hover:bg-raised text-faint hover:text-ink backdrop-blur-sm"})}),e("div",{className:"max-h-72 overflow-y-auto pr-6 text-dim",children:e(E,{code:ar(f),lang:"json"})})]})]})]})}function se(){try{let t=localStorage.getItem("basalt.contextSidebar.tab");if(t==="tools"||t==="todos"||t==="raw")return t}catch{}return"breakdown"}function ne(t){let{style:c,useTheme:d}=y();return d(),n("div",{className:c("surface.panel","bg-panel/70 px-3 py-2"),children:[e("div",{className:"text-[10px] font-medium uppercase tracking-wider text-faint",children:t.label}),e("div",{className:"mt-0.5 truncate font-mono text-xs font-semibold tabular-nums text-ink",children:t.value})]})}function Oe(t){let{Button:c,StatusChip:d,Segmented:s,cn:a,style:u,useTheme:p}=y();p();let[f,g]=r(se),[l,x]=r(()=>Fn.get(t.session.id)),[h,N]=r(!1),[S,I]=r(0),[H,J]=r(!1);o(()=>{let b=setTimeout(()=>J(!0),140);return()=>clearTimeout(b)},[]),o(()=>{let b=Fn.get(t.session.id);if(b)x(b);return xi((T,G)=>{if(T===t.session.id)x(G)})},[t.session.id]),o(()=>{let b=new AbortController;return N(!1),t.connection.request(`/api/sessions/${encodeURIComponent(t.session.id)}/context`,{signal:AbortSignal.any([b.signal,AbortSignal.timeout(15000)])}).then((T)=>{if(!b.signal.aborted)_i(t.session.id,T),x(T)},()=>{if(!b.signal.aborted)N(!0)}),()=>b.abort()},[t.connection,t.session.id,t.session.updated,t.entries.length,S]);let w=ca(l?.items??[],l?.usableWindow,l?.calibratedTokens,l?.lastInputTokens,l?.hasPendingOutput),C=ua(w.percent),_=l?.lastCacheHitRate,P=l?.usage?.cacheHitRate,q=_===void 0?"—":`${(_*100).toFixed(1)}%`,Z=P===void 0?"—":`${(P*100).toFixed(1)}%`,K=(b)=>{g(b);try{localStorage.setItem("basalt.contextSidebar.tab",b)}catch{}},V=[{value:"breakdown",label:"构成"},{value:"tools",label:n("span",{className:"inline-flex items-center gap-1",children:["工具",l&&e("span",{className:"text-[10px] text-faint tabular-nums",children:l.tools.length})]})},{value:"todos",label:n("span",{className:"inline-flex items-center gap-1",children:["待办",t.session.todos.length>0&&e("span",{className:"text-[10px] text-faint tabular-nums",children:t.session.todos.length})]})},{value:"raw",label:"原始消息"}],X=n("div",{className:"px-3.5 pt-1 pb-3",children:[n("div",{className:"flex items-start justify-between gap-3",children:[n("div",{children:[e("div",{className:"text-[10.5px] font-medium uppercase tracking-wider text-faint",children:"上下文用量"}),n("div",{className:"mt-0.5 flex items-baseline gap-1.5",children:[e("span",{className:"font-mono text-xl font-semibold tabular-nums text-ink",children:l?w.totalTokens.toLocaleString():"—"}),n("span",{className:"font-mono text-xs text-dim",children:["/ ",l?.usableWindow.toLocaleString()??"—"]})]})]}),e(d,{tone:C==="overflow"||C==="near_limit"?"danger":C==="sealing"?"warning":"success",children:C==="overflow"?"预计超限":C==="near_limit"?"接近上限":C==="sealing"?"接近封存":"正常"})]}),w.percent!==null&&e("meter",{className:"sr-only","aria-label":"可用上下文窗口占比",min:0,max:100,value:Math.min(100,w.percent)}),e("div",{"aria-hidden":!0,className:a("relative mt-2.5 h-2 w-full overflow-hidden rounded-full bg-raised",!l&&"animate-pulse"),children:e("div",{className:"h-full rounded-full bg-accent transition-[width] duration-500 ease-out-quint",style:{width:`${Math.min(100,w.percent??0)}%`}})}),n("div",{className:"mt-2 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-dim",children:w.percent===null?"暂无窗口数据":`${w.percent.toFixed(1)}% 可用窗口`}),n("span",{className:"text-faint",children:["总窗口 ",l?.contextWindow.toLocaleString()??"—"," · 80% 封存 · 97% 折叠"]})]}),l?.usage&&(l.usage.input>0||l.usage.output>0||l.usage.cacheRead>0||l.usage.cacheWrite>0||l.usage.cost>0)&&e("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[["Input",l.usage.input.toLocaleString()],["Output",l.usage.output.toLocaleString()],["缓存命中 当前 / 平均",`${q} / ${Z}`],["平均 TPS",l.usage.tps!==void 0?`${l.usage.tps.toFixed(1)} tok/s`:"—"]].map(([b,T])=>e(ne,{label:b,value:T},b))})]});return n(m,{children:[X,e("div",{className:"px-3 py-2",children:e(s,{value:f,onChange:K,options:V,className:"w-full grid grid-cols-4"})}),n("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:[h&&!l&&n("div",{role:"alert",className:"flex items-center justify-between rounded-xl border border-danger/30 bg-danger/8 px-3 py-2 text-xs text-danger",children:[e("span",{children:"上下文加载失败。"}),e(c,{size:"sm",variant:"ghost",onClick:()=>I((b)=>b+1),children:"重试"})]}),e("div",{children:!H?e(z,{}):n(m,{children:[f==="raw"&&e(L,{entries:t.entries}),f==="todos"&&e(j,{todos:t.session.todos}),f==="breakdown"&&(l?e(O,{items:w.items}):!h?e(z,{}):null),f==="tools"&&(l?e(F,{tools:l.tools??[]}):!h?e(z,{}):null)]})},f)]})]})}export{Oe as ContextSidebar};
|
|
4
|
+
`),size:"icon-xs",label:"复制全部原始 JSON",className:"hover:bg-raised text-faint hover:text-ink"})]}),l.map((x)=>e(ee,{entry:x},x.seq)),g&&n("div",{ref:f,className:s("surface.subtle","flex items-center justify-between bg-panel/40 px-3 py-2 text-xs text-faint"),children:[n("span",{children:["已显示 ",l.length," / ",t.entries.length," 条"]}),n("div",{className:"flex items-center gap-1.5",children:[e(c,{size:"sm",variant:"ghost",onClick:()=>p((x)=>Math.min(t.entries.length,x+M)),children:"加载更多"}),e(c,{size:"sm",variant:"ghost",onClick:()=>p(t.entries.length),children:"显示全部"})]})]})]})}var ee=B(function(c){let{Chevron:d,CopyButton:s,style:a,useTheme:u}=y();u();let[p,f]=r(!1),g=Po(c.entry),l=v(()=>Mo(c.entry.time),[c.entry.time]);return n("div",{"data-state":p?"open":"closed",className:a("surface.interactive","group/collapsible"),children:[n("button",{type:"button","aria-expanded":p,onClick:()=>f((x)=>!x),className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs",children:[n("span",{className:"shrink-0 font-mono text-[10.5px] tabular-nums text-faint",children:["#",c.entry.seq]}),e("span",{className:a("control.badge","shrink-0 font-medium text-[10px]",Y[g.tone]),children:g.badge}),e("span",{className:"min-w-0 flex-1 truncate text-ink",children:g.title}),g.meta&&e("span",{className:a("control.badge","shrink-0 font-mono text-[10px] text-faint"),children:g.meta}),e("span",{className:"shrink-0 font-mono text-[10.5px] tabular-nums text-faint",children:l}),e(d,{className:"-rotate-90 text-faint group-data-[state=open]/collapsible:rotate-90"})]}),p&&e("div",{className:"border-t border-line/60 bg-raised/20 px-3 py-2.5 text-xs text-dim",children:n("div",{className:"space-y-2",children:[n("div",{className:"flex items-center justify-between text-[11px] text-faint",children:[n("span",{className:"font-mono",children:[c.entry.type," · #",c.entry.seq]}),e(s,{text:()=>JSON.stringify(c.entry,null,2),size:"icon-xs",label:"复制此条 JSON",className:"bg-raised/60 hover:bg-raised text-faint hover:text-ink"})]}),e(te,{entry:c.entry})]})})]})});function te(t){let{style:c,useTheme:d}=y();d();let s=t.entry;if(s.type==="user")return n("div",{className:"space-y-2",children:[s.text&&e("pre",{className:c("surface.subtle","max-h-72 overflow-y-auto p-2.5 font-sans text-xs leading-relaxed text-ink whitespace-pre-wrap break-words [overflow-wrap:anywhere]"),children:Fr(s.text)}),s.attachments&&s.attachments.length>0&&n("div",{className:"space-y-1",children:[n("div",{className:"text-[10.5px] font-medium text-faint",children:["附件(",s.attachments.length,")"]}),e("div",{className:"flex flex-wrap gap-1.5",children:s.attachments.map((a,u)=>{let p=a.kind==="image"?Math.floor(a.data.length*0.75):a.data.length;return n("div",{className:c("surface.subtle","inline-flex items-center gap-1.5 px-2 py-1 text-[11px]"),children:[e("span",{className:c("control.badge","text-[10px] text-faint"),children:a.kind==="image"?"图片":a.kind==="path"?"路径":"文本"}),e("span",{className:"max-w-40 truncate font-medium text-ink",children:a.name}),n("span",{className:"font-mono text-[10px] text-faint",children:[a.mimeType," · ",so(p)]})]},`${a.name}-${u}`)})})]}),s.notices&&s.notices.length>0&&n("div",{className:"space-y-1",children:[n("div",{className:"text-[10.5px] font-medium text-faint",children:["通知来源(",s.notices.length,")"]}),s.notices.map((a)=>n("div",{className:c("surface.subtle","flex items-center justify-between px-2.5 py-1.5 font-mono text-[11px]"),children:[n("span",{className:"truncate text-ink",children:[a.sourceKind,"/",a.sourceID]}),e("span",{className:"text-faint",children:a.state})]},a.dedupeKey))]})]});if(s.type==="assistant")return n("div",{className:"space-y-2",children:[n("div",{className:"font-mono text-[11px] text-faint",children:["模型:",s.model]}),s.error&&e("div",{className:"rounded-lg border border-danger/30 bg-danger/8 px-2.5 py-2 text-xs text-danger",children:s.error}),s.parts.map((a,u)=>{if(a.type==="thinking")return n("div",{className:c("surface.subtle","p-2.5 space-y-1"),children:[e("div",{className:"text-[10.5px] font-medium text-faint",children:"思考"}),e("pre",{className:"max-h-60 overflow-y-auto font-sans text-xs italic leading-relaxed text-dim whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:Fr(a.text)})]},`thinking-${u}`);if(a.type==="text")return n("div",{className:c("surface.subtle","p-2.5 space-y-1"),children:[e("div",{className:"text-[10.5px] font-medium text-faint",children:"回复"}),e("pre",{className:"max-h-60 overflow-y-auto font-sans text-xs leading-relaxed text-ink whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:Fr(a.text)})]},`text-${u}`);return n("div",{className:c("surface.subtle","p-2.5 space-y-1.5"),children:[n("div",{className:"flex items-center justify-between gap-2 text-[11px]",children:[n("span",{className:"font-mono font-medium text-ink",children:["工具调用 · ",a.name]}),e("span",{className:"truncate font-mono text-[10px] text-faint",children:a.id})]}),e("div",{className:"max-h-60 overflow-y-auto text-dim",children:e(E,{code:ir(JSON.stringify(a.input,lo,2)),lang:"json"})})]},a.id||`tool-${u}`)})]});if(s.type==="tool_result")return n("div",{className:"space-y-2",children:[n("div",{className:"flex flex-wrap items-center gap-2 font-mono text-[11px] text-faint",children:[e("span",{className:"text-ink",children:s.name}),e("span",{children:"·"}),e("span",{className:"truncate",children:s.callID}),e("span",{className:c("control.badge","ml-auto font-sans text-[10px]",s.isError?"bg-danger/15 text-danger":"text-dim"),children:s.isError?"执行失败":"执行完成"})]}),s.images&&s.images.length>0&&e("div",{className:"flex flex-wrap gap-1.5",children:s.images.map((a,u)=>n("span",{className:c("surface.subtle","px-2 py-1 font-mono text-[10.5px] text-faint"),children:["图片 #",u+1," · ",a.mimeType," · ",so(Math.floor(a.data.length*0.75))]},`${a.mimeType}-${u}`))}),ki(s.output)?e("pre",{className:c("surface.subtle","max-h-72 overflow-y-auto p-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words [overflow-wrap:anywhere]",s.isError?"text-danger":"text-dim"),children:Fr(s.output)}):e("p",{className:"py-1 text-faint",children:"(无文本输出)"})]});return e("pre",{className:c("surface.subtle","max-h-72 overflow-y-auto p-2.5 font-mono text-[11px] leading-relaxed text-dim whitespace-pre-wrap break-words [overflow-wrap:anywhere]"),children:Oo(s)})}function j(t){let{cn:c,style:d,useTheme:s}=y();if(s(),!t.todos.length)return e(k,{children:"暂无待办。"});return e("ul",{className:"space-y-1.5",children:t.todos.map((a)=>n("li",{className:d("surface.interactive","flex items-start gap-2.5 px-3 py-2 text-xs"),children:[n("span",{className:c("mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border transition-colors duration-300",a.status==="completed"&&"border-success bg-success text-panel",a.status==="in_progress"&&"border-accent",a.status==="pending"&&"border-line-strong"),children:[a.status==="completed"&&e(U,{className:"size-2.5 animate-pop",strokeWidth:3.5}),a.status==="in_progress"&&e("span",{className:"size-1.5 animate-pulse rounded-full bg-accent"})]}),e("span",{className:c("min-w-0 flex-1 break-words leading-relaxed [overflow-wrap:anywhere]",a.status==="completed"&&"text-faint line-through decoration-faint/60",a.status==="in_progress"&&"font-medium text-ink",a.status==="pending"&&"text-dim"),children:a.content})]},`${a.status}-${a.content}`))})}function F(t){let{cn:c,style:d,useTheme:s}=y();s();let[a,u]=r("all"),p=v(()=>t.tools.filter((l)=>l.deferred).length,[t.tools]),f=t.tools.length-p,g=v(()=>{if(a==="deferred")return t.tools.filter((l)=>l.deferred);if(a==="active")return t.tools.filter((l)=>!l.deferred);return t.tools},[t.tools,a]);if(!t.tools.length)return e(k,{children:"当前会话没有可用工具。"});return n("div",{className:"space-y-2",children:[p>0&&n("div",{className:"flex items-center gap-1 text-[11px]",children:[n("button",{type:"button",onClick:()=>u("all"),className:c("rounded-lg px-2 py-1 transition-colors",a==="all"?"bg-raised font-medium text-ink":"text-faint hover:text-dim"),children:["全部 (",t.tools.length,")"]}),n("button",{type:"button",onClick:()=>u("active"),className:c("rounded-lg px-2 py-1 transition-colors",a==="active"?"bg-raised font-medium text-ink":"text-faint hover:text-dim"),children:["常驻 (",f,")"]}),n("button",{type:"button",onClick:()=>u("deferred"),className:c("rounded-lg px-2 py-1 transition-colors",a==="deferred"?"bg-raised font-medium text-ink":"text-faint hover:text-dim"),children:["延迟加载 (",p,")"]})]}),e("div",{className:"space-y-1.5",children:g.map((l)=>e(ae,{tool:l},`${l.group}-${l.name}`))})]})}function ae(t){let{Chevron:c,CopyButton:d,style:s,useTheme:a}=y();a();let[u,p]=r(!1),f=v(()=>u?JSON.stringify(t.tool.schema,null,2):"",[u,t.tool.schema]);return n("div",{"data-state":u?"open":"closed",className:s("surface.interactive","group/collapsible"),children:[n("button",{type:"button","aria-expanded":u,onClick:()=>p((g)=>!g),className:"flex w-full items-center justify-between px-3 py-2 text-left text-xs",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 truncate font-mono text-ink",children:[e("span",{className:"truncate",children:t.tool.name}),t.tool.group&&e("span",{className:s("control.badge","font-sans text-[10px]"),children:t.tool.group}),t.tool.deferred&&e("span",{className:s("control.badge","font-sans text-[10px]"),children:"延迟加载"})]}),e(c,{className:"-rotate-90 text-faint group-data-[state=open]/collapsible:rotate-90"})]}),u&&n("div",{className:"border-t border-line/60 bg-raised/20 px-3 py-2 text-xs text-dim",children:[t.tool.deferred&&e("div",{className:s("surface.subtle","mb-2 px-2.5 py-1.5 text-[11px] text-faint"),children:"延迟加载:此工具默认以精简描述挂载,模型通过 toolsearch 取回定义后才向上下文注入完整参数 Schema。"}),t.tool.description&&e("pre",{className:"mb-2 max-h-60 overflow-y-auto font-sans text-xs leading-relaxed text-dim whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:ir(t.tool.description)}),n("div",{className:s("surface.subtle","group/schema relative overflow-hidden rounded-lg p-2.5"),children:[e("div",{className:"absolute right-1.5 top-1.5 z-10",children:e(d,{text:f,size:"icon-xs",className:"bg-raised/60 hover:bg-raised text-faint hover:text-ink backdrop-blur-sm"})}),e("div",{className:"max-h-72 overflow-y-auto pr-6 text-dim",children:e(E,{code:ir(f),lang:"json"})})]})]})]})}function se(){try{let t=localStorage.getItem("basalt.contextSidebar.tab");if(t==="tools"||t==="todos"||t==="raw")return t}catch{}return"breakdown"}function ne(t){let{style:c,useTheme:d}=y();return d(),n("div",{className:c("surface.panel","bg-panel/70 px-3 py-2"),children:[e("div",{className:"text-[10px] font-medium uppercase tracking-wider text-faint",children:t.label}),e("div",{className:"mt-0.5 truncate font-mono text-xs font-semibold tabular-nums text-ink",children:t.value})]})}function Oe(t){let{Button:c,StatusChip:d,Segmented:s,cn:a,style:u,useTheme:p}=y();p();let[f,g]=r(se),[l,x]=r(()=>Fn.get(t.session.id)),[h,N]=r(!1),[S,I]=r(0),[H,J]=r(!1);o(()=>{let b=setTimeout(()=>J(!0),140);return()=>clearTimeout(b)},[]),o(()=>{let b=Fn.get(t.session.id);if(b)x(b);return Ci((T,G)=>{if(T===t.session.id)x(G)})},[t.session.id]),o(()=>{let b=new AbortController;return N(!1),t.connection.request(`/api/sessions/${encodeURIComponent(t.session.id)}/context`,{signal:AbortSignal.any([b.signal,AbortSignal.timeout(15000)])}).then((T)=>{if(!b.signal.aborted)Si(t.session.id,T),x(T)},()=>{if(!b.signal.aborted)N(!0)}),()=>b.abort()},[t.connection,t.session.id,t.session.updated,t.entries.length,S]);let w=ua(l?.items??[],l?.usableWindow,l?.calibratedTokens,l?.lastInputTokens,l?.hasPendingOutput),C=da(w.percent),_=l?.lastCacheHitRate,P=l?.usage?.cacheHitRate,q=_===void 0?"—":`${(_*100).toFixed(1)}%`,Z=P===void 0?"—":`${(P*100).toFixed(1)}%`,K=(b)=>{g(b);try{localStorage.setItem("basalt.contextSidebar.tab",b)}catch{}},V=[{value:"breakdown",label:"构成"},{value:"tools",label:n("span",{className:"inline-flex items-center gap-1",children:["工具",l&&e("span",{className:"text-[10px] text-faint tabular-nums",children:l.tools.length})]})},{value:"todos",label:n("span",{className:"inline-flex items-center gap-1",children:["待办",t.session.todos.length>0&&e("span",{className:"text-[10px] text-faint tabular-nums",children:t.session.todos.length})]})},{value:"raw",label:"原始消息"}],X=n("div",{className:"px-3.5 pt-1 pb-3",children:[n("div",{className:"flex items-start justify-between gap-3",children:[n("div",{children:[e("div",{className:"text-[10.5px] font-medium uppercase tracking-wider text-faint",children:"上下文用量"}),n("div",{className:"mt-0.5 flex items-baseline gap-1.5",children:[e("span",{className:"font-mono text-xl font-semibold tabular-nums text-ink",children:l?w.totalTokens.toLocaleString():"—"}),n("span",{className:"font-mono text-xs text-dim",children:["/ ",l?.usableWindow.toLocaleString()??"—"]})]})]}),e(d,{tone:C==="overflow"||C==="near_limit"?"danger":C==="sealing"?"warning":"success",children:C==="overflow"?"预计超限":C==="near_limit"?"接近上限":C==="sealing"?"接近封存":"正常"})]}),w.percent!==null&&e("meter",{className:"sr-only","aria-label":"可用上下文窗口占比",min:0,max:100,value:Math.min(100,w.percent)}),e("div",{"aria-hidden":!0,className:a("relative mt-2.5 h-2 w-full overflow-hidden rounded-full bg-raised",!l&&"animate-pulse"),children:e("div",{className:"h-full rounded-full bg-accent transition-[width] duration-500 ease-out-quint",style:{width:`${Math.min(100,w.percent??0)}%`}})}),n("div",{className:"mt-2 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-dim",children:w.percent===null?"暂无窗口数据":`${w.percent.toFixed(1)}% 可用窗口`}),n("span",{className:"text-faint",children:["总窗口 ",l?.contextWindow.toLocaleString()??"—"," · 80% 封存 · 97% 折叠"]})]}),l?.usage&&(l.usage.input>0||l.usage.output>0||l.usage.cacheRead>0||l.usage.cacheWrite>0||l.usage.cost>0)&&e("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[["Input",l.usage.input.toLocaleString()],["Output",l.usage.output.toLocaleString()],["缓存命中 当前 / 平均",`${q} / ${Z}`],["平均 TPS",l.usage.tps!==void 0?`${l.usage.tps.toFixed(1)} tok/s`:"—"]].map(([b,T])=>e(ne,{label:b,value:T},b))})]});return n(m,{children:[X,e("div",{className:"px-3 py-2",children:e(s,{value:f,onChange:K,options:V,className:"w-full grid grid-cols-4"})}),n("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:[h&&!l&&n("div",{role:"alert",className:"flex items-center justify-between rounded-xl border border-danger/30 bg-danger/8 px-3 py-2 text-xs text-danger",children:[e("span",{children:"上下文加载失败。"}),e(c,{size:"sm",variant:"ghost",onClick:()=>I((b)=>b+1),children:"重试"})]}),e("div",{children:!H?e(z,{}):n(m,{children:[f==="raw"&&e(L,{entries:t.entries}),f==="todos"&&e(j,{todos:t.session.todos}),f==="breakdown"&&(l?e(O,{items:w.items}):!h?e(z,{}):null),f==="tools"&&(l?e(F,{tools:l.tools??[]}):!h?e(z,{}):null)]})},f)]})]})}export{Oe as ContextSidebar};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Oi}from"./chunk-tfsrk2rc.js";export{Oi as createPacketServices};
|